91 lines
2.5 KiB
TypeScript
91 lines
2.5 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 "_slicedToArray" /* 32 */;
|
|
import react from "react" /* 19 */;
|
|
import size from "module_2" /* 2 */;
|
|
|
|
const result = size.fileFinishedImporting("modules/masked_link/SharedStateUtils.tsx");
|
|
|
|
export const useUrlParts = function useUrlParts(url) {
|
|
let hostname;
|
|
let protocol;
|
|
let closure_0 = url;
|
|
const items = [url];
|
|
const memo = react.useMemo(() => {
|
|
let obj2;
|
|
let obj3;
|
|
const url = { protocol: obj2.getProtocol(str), hostname: obj3.getHostname(str) };
|
|
obj2 = MaskedLinkStoreMethodsAdditional;
|
|
obj3 = MaskedLinkStoreMethodsAdditional;
|
|
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) {
|
|
let first;
|
|
let hostname;
|
|
let protocol;
|
|
let tmp3;
|
|
const str = url.url;
|
|
const trustUrl = url.trustUrl;
|
|
const onConfirm = url.onConfirm;
|
|
const onCancel = url.onCancel;
|
|
const onClose = url.onClose;
|
|
first = undefined;
|
|
[first, tmp3] = react.useState(false);
|
|
const items = [str];
|
|
const memo = react.useMemo(() => {
|
|
let obj2;
|
|
let obj3;
|
|
const url = { protocol: obj2.getProtocol(str), hostname: obj3.getHostname(str) };
|
|
obj2 = MaskedLinkStoreMethodsAdditional;
|
|
obj3 = MaskedLinkStoreMethodsAdditional;
|
|
return url;
|
|
}, items);
|
|
({ protocol, hostname } = memo);
|
|
let str2 = "";
|
|
if ("//" === str.substr(protocol.length, 2)) {
|
|
str2 = "//";
|
|
}
|
|
const items1 = [str, first, trustUrl, onConfirm, onClose];
|
|
const replaced = str.replace("" + protocol + str2 + hostname, "");
|
|
const items2 = [onCancel, onClose];
|
|
const callback = obj.useCallback(() => {
|
|
const tmp = first;
|
|
if (tmp) {
|
|
trustUrl(str);
|
|
}
|
|
onConfirm();
|
|
if (onClose != null) {
|
|
onClose();
|
|
}
|
|
}, items1);
|
|
url = {
|
|
protocol,
|
|
authorityPrefix: str2,
|
|
hostname,
|
|
theRestOfTheUrl: replaced,
|
|
shouldTrustUrl: first,
|
|
setShouldTrustUrl: tmp3,
|
|
handleConfirm: callback,
|
|
handleCancel: obj.useCallback(() => {
|
|
onCancel();
|
|
if (onClose != null) {
|
|
onClose();
|
|
}
|
|
}, items2)
|
|
};
|
|
return url;
|
|
};
|