Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/05xxx/module_5021.js (118.4 MB)
79 lines
2.4 KiB
TypeScript
79 lines
2.4 KiB
TypeScript
// Module ID: 12507
|
|
// Function ID: 12508
|
|
// Name: SharedStateUtils
|
|
// Dependencies: [32, 19, 7821, 2]
|
|
// Exports: useModalState, useUrlParts
|
|
|
|
// Module 12507 (SharedStateUtils)
|
|
import MaskedLinkStoreMethodsAdditional from "MaskedLinkStoreMethodsAdditional" /* 7821 */;
|
|
import _slicedToArray from "module_32" /* 32 */;
|
|
import noop from "module_19" /* 19 */;
|
|
|
|
require = fn;
|
|
const size = fn(2);
|
|
const result = size.fileFinishedImporting("modules/masked_link/SharedStateUtils.tsx");
|
|
|
|
export const useUrlParts = function useUrlParts(url) {
|
|
closure_0 = url;
|
|
const items = [url];
|
|
const memo = noop.useMemo(() => {
|
|
const url = { protocol: MaskedLinkStoreMethodsAdditional.getProtocol(str), hostname: null };
|
|
url.hostname = MaskedLinkStoreMethodsAdditional.getHostname(str);
|
|
return url;
|
|
}, items);
|
|
({ protocol, hostname } = memo);
|
|
let str = "";
|
|
if ("//" === url.substr(protocol.length, 2)) {
|
|
str = "//";
|
|
}
|
|
url = { protocol, authorityPrefix: str, hostname, theRestOfTheUrl: url.replace("" + protocol + str + hostname, "") };
|
|
return url;
|
|
};
|
|
export const useModalState = function useModalState(url) {
|
|
const str = url.url;
|
|
const trustUrl = url.trustUrl;
|
|
const onConfirm = url.onConfirm;
|
|
const onCancel = url.onCancel;
|
|
const onClose = url.onClose;
|
|
const tmp = onConfirm(onCancel.useState(false), 2);
|
|
const shouldTrustUrl = tmp[0];
|
|
const items = [str];
|
|
const memo = onCancel.useMemo(() => {
|
|
const url = { protocol: MaskedLinkStoreMethodsAdditional.getProtocol(str), hostname: null };
|
|
url.hostname = MaskedLinkStoreMethodsAdditional.getHostname(str);
|
|
return url;
|
|
}, items);
|
|
({ protocol, hostname } = memo);
|
|
let str2 = "";
|
|
if ("//" === str.substr(protocol.length, 2)) {
|
|
str2 = "//";
|
|
}
|
|
const items1 = [str, shouldTrustUrl, trustUrl, onConfirm, onClose];
|
|
const replaced = str.replace("" + protocol + str2 + hostname, "");
|
|
const items2 = [onCancel, onClose];
|
|
const callback = obj.useCallback(() => {
|
|
if (first) {
|
|
trustUrl(str);
|
|
}
|
|
onConfirm();
|
|
if (onClose != null) {
|
|
onClose();
|
|
}
|
|
}, items1);
|
|
url = {
|
|
protocol,
|
|
authorityPrefix: str2,
|
|
hostname,
|
|
theRestOfTheUrl: replaced,
|
|
shouldTrustUrl,
|
|
setShouldTrustUrl: tmp[1],
|
|
handleConfirm: callback,
|
|
handleCancel: obj.useCallback(() => {
|
|
onCancel();
|
|
if (onClose != null) {
|
|
onClose();
|
|
}
|
|
}, items2)
|
|
};
|
|
return url;
|
|
};
|