242 lines
7.0 KiB
JavaScript
242 lines
7.0 KiB
JavaScript
// Metro module 1516 (f1517).
|
|
import validatePathConfig from "./validatePathConfig";
|
|
import fromEntries from "./fromEntries";
|
|
import * as _validateArrayFormatSeparator from "./validateArrayFormatSeparator";
|
|
function $mk69344($env) {
|
|
return (a0) => {
|
|
let r66;
|
|
const [r28, r8] = a0;
|
|
const r7 = $env[0];
|
|
if (typeof r8 === "string") {
|
|
r66 = {
|
|
pattern: r7 ? (0, $env.$parent[5])(r7, r8) : r8
|
|
};
|
|
} else {
|
|
if (r8.exact && r8.path === void 0) {
|
|
throw new Error("A 'path' needs to be specified when specifying 'exact: true'. If you don't want this screen in the URL, specify it as empty string, e.g. `path: ''`.");
|
|
}
|
|
const r9 = r8.exact !== true ? $env.$parent[5](r7 || "", r8.path || "") : r8.path || "";
|
|
const screens2 = r8.screens;
|
|
let screens3 = void 0;
|
|
if (screens2) {
|
|
const r42 = $env.$parent;
|
|
const r43 = r42[6];
|
|
const screens = r8.screens;
|
|
let env24448;
|
|
const r45 = env24448 = {
|
|
$parent: r42
|
|
};
|
|
env24448[0] = r9;
|
|
screens3 = (0, r42[0])(r42[2][1])(Object.entries(screens).map($mk69344(r45)));
|
|
}
|
|
r66 = {
|
|
pattern: r9 == null ? void 0 : r9.split("/").filter(Boolean).join("/"),
|
|
stringify: r8.stringify,
|
|
screens: screens3
|
|
};
|
|
}
|
|
return [r28, r66];
|
|
};
|
|
}
|
|
let getParamName, joinPaths, createNormalizedConfigs;
|
|
let env1216 = {};
|
|
const getActiveRoute = (a0) => {
|
|
const r7 = typeof a0.index === "number" ? a0.routes[a0.index] : a0.routes[a0.routes.length - 1];
|
|
return r7.state ? getActiveRoute(r7.state) : r7;
|
|
};
|
|
getParamName = (a0) => {};
|
|
joinPaths = function joinPaths(...args) {
|
|
const r4 = [];
|
|
return r4.concat.apply(r4, [...args.map((arg) => arg.split("/"))]).filter(Boolean).join("/");
|
|
};
|
|
createNormalizedConfigs = (a0, a1) => {};
|
|
export default function getPathFromState(a0, a1) {
|
|
let r21, r173;
|
|
if (a0 == null) {
|
|
throw Error("Got 'undefined' for the navigation state. You must pass a valid state object.");
|
|
}
|
|
if (a1) {
|
|
validatePathConfig(a1);
|
|
}
|
|
if (a1?.screens) {
|
|
const screens = a1?.screens;
|
|
let env13076;
|
|
const r62 = Object.entries(screens);
|
|
const r64 = env13076 = {
|
|
$parent: env1216
|
|
};
|
|
r21 = fromEntries(r62.map($mk69344(r64)));
|
|
} else {
|
|
r21 = {};
|
|
}
|
|
let env13077;
|
|
const r20 = env13077 = {
|
|
$parent: env1216
|
|
};
|
|
const r19 = {};
|
|
env13077[0] = r19;
|
|
let r68 = "/";
|
|
let r69 = "/";
|
|
let r70 = a0;
|
|
while (r70) {
|
|
const index = r70.index;
|
|
const r24 = r70;
|
|
const r29 = r68;
|
|
const r25 = typeof index === "number" ? r24.index : 0;
|
|
let env13078 = {
|
|
$parent: r20
|
|
};
|
|
const r72 = r24.routes[r25];
|
|
env13078[1] = r72;
|
|
const r79 = typeof a0.index === "number" ? a0.routes[a0.index] : a0.routes[a0.routes.length - 1];
|
|
const state = r79.state;
|
|
let r82 = r79;
|
|
if (state) {
|
|
const state2 = r79.state;
|
|
const r90 = typeof state2.index === "number" ? state2.routes[state2.index] : state2.routes[state2.routes.length - 1];
|
|
r82 = r90.state ? getActiveRoute(r90.state) : r90;
|
|
}
|
|
const r32 = [];
|
|
const r4 = r72.name in r21;
|
|
let r5 = true;
|
|
let r34 = r21;
|
|
let r33 = r72;
|
|
let r97 = void 0;
|
|
let r98 = r34;
|
|
let r99 = r33;
|
|
let r100 = void 0;
|
|
let r101 = void 0;
|
|
if (r4) {
|
|
do {
|
|
const pattern = r34[r33.name].pattern;
|
|
r32.push(r33.name);
|
|
const params = r33.params;
|
|
const r8 = r5;
|
|
const r42 = r34;
|
|
const r41 = r33;
|
|
const r105 = r97;
|
|
let r106 = r105;
|
|
if (params) {
|
|
const stringify2 = r42[r41.name]?.stringify;
|
|
const stringify = stringify2;
|
|
const r119 = fromEntries(Object.entries(r41.params).map((item) => {
|
|
const [r23, r7] = item;
|
|
return [r23, (stringify == null ? void 0 : stringify[r23]) ? stringify[r23](r7) : String(r7)];
|
|
}));
|
|
if (pattern) {
|
|
Object.assign(r19, r119);
|
|
}
|
|
r106 = r105;
|
|
if (r82 === r41) {
|
|
const r123 = {
|
|
...r119
|
|
};
|
|
env13078[0] = r123;
|
|
r106 = r123;
|
|
if (pattern != null) {
|
|
pattern.split("/").filter((item) => item.startsWith(":")).forEach((item) => {
|
|
const r14 = item.replace(/^:/, "").replace(/\?$/, "");
|
|
const r15 = env13078[0];
|
|
if (r15) {
|
|
delete r15[r14];
|
|
}
|
|
});
|
|
r106 = r123;
|
|
}
|
|
}
|
|
}
|
|
const screens2 = r42[r41.name].screens;
|
|
let r137 = false;
|
|
let r138 = r42;
|
|
let r139 = r41;
|
|
if (screens2) {
|
|
const state3 = r41.state;
|
|
r137 = false;
|
|
r138 = r42;
|
|
r139 = r41;
|
|
if (state3 !== void 0) {
|
|
const r150 = r41.state.routes[typeof r41.state.index === "number" ? r41.state.index : r41.state.routes.length - 1];
|
|
const screens3 = r42[r41.name].screens;
|
|
r137 = false;
|
|
r138 = r42;
|
|
r139 = r41;
|
|
if (screens3) {
|
|
const r10 = r150.name in screens3;
|
|
r137 = false;
|
|
r138 = r42;
|
|
r139 = r41;
|
|
if (r10) {
|
|
env13078[1] = r150;
|
|
r137 = r8;
|
|
r138 = screens3;
|
|
r139 = r150;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const r156 = r139.name in r138;
|
|
r98 = r138;
|
|
r99 = r139;
|
|
r100 = r106;
|
|
r101 = pattern;
|
|
if (!r156) {
|
|
break;
|
|
}
|
|
r34 = r138;
|
|
r33 = r139;
|
|
r97 = r106;
|
|
r98 = r34;
|
|
r99 = r33;
|
|
r100 = r97;
|
|
r101 = pattern;
|
|
r5 = r137;
|
|
} while (r5);
|
|
}
|
|
if (r101 === void 0) {
|
|
r101 = r32.join("/");
|
|
}
|
|
const r163 = r98[r99.name] !== void 0 ? r29 + r101.split("/").map((item) => {
|
|
const replace = item.replace;
|
|
let r10 = "";
|
|
const r13 = replace.call(item, /^:/, "").replace(/\?$/, "");
|
|
if (item === "*") {
|
|
return env13078[1].name;
|
|
}
|
|
if (item.startsWith(":")) {
|
|
const r23 = env13077[0][r13];
|
|
if (!(r23 === void 0 && item.endsWith("?"))) {
|
|
r10 = encodeURIComponent(r23);
|
|
}
|
|
return r10;
|
|
}
|
|
return encodeURIComponent(item);
|
|
}).join("/") : r29 + encodeURIComponent(r99.name);
|
|
if (!r100) {
|
|
const params2 = r82.params;
|
|
env13078[0] = params2;
|
|
r100 = params2;
|
|
}
|
|
if (r99.state) {
|
|
r173 = r163 + "/";
|
|
} else {
|
|
r173 = r163;
|
|
if (r100) {
|
|
for (const key in r100) {
|
|
if (r100[key] === "undefined") {
|
|
delete r100[key];
|
|
}
|
|
}
|
|
const r187 = _validateArrayFormatSeparator.stringify(r100, {
|
|
sort: false
|
|
});
|
|
r173 = r187 ? r163 + `?${r187}` : r163;
|
|
}
|
|
}
|
|
r70 = r99.state;
|
|
r68 = r173;
|
|
r69 = r68;
|
|
}
|
|
const r193 = r69.replace(/\/+/g, "/");
|
|
return r193.length > 1 ? r193.replace(/\/$/, "") : r193;
|
|
};
|