mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-16 05:03:33 +00:00
9377 lines
288 KiB
JavaScript
9377 lines
288 KiB
JavaScript
import {
|
|
require_react_dom
|
|
} from "./chunk-JD3UC7WK.js";
|
|
import {
|
|
require_jsx_runtime
|
|
} from "./chunk-L53IR3KW.js";
|
|
import {
|
|
require_react
|
|
} from "./chunk-776SV3ZX.js";
|
|
import {
|
|
__commonJS,
|
|
__toESM
|
|
} from "./chunk-V4OQ3NZ2.js";
|
|
|
|
// ../../../node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.4/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
|
|
var require_use_sync_external_store_shim_development = __commonJS({
|
|
"../../../node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.4/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
|
|
"use strict";
|
|
(function() {
|
|
function is(x, y) {
|
|
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
}
|
|
function useSyncExternalStore$2(subscribe2, getSnapshot) {
|
|
didWarnOld18Alpha || void 0 === React18.startTransition || (didWarnOld18Alpha = true, console.error(
|
|
"You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
|
|
));
|
|
var value = getSnapshot();
|
|
if (!didWarnUncachedGetSnapshot) {
|
|
var cachedValue = getSnapshot();
|
|
objectIs(value, cachedValue) || (console.error(
|
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
), didWarnUncachedGetSnapshot = true);
|
|
}
|
|
cachedValue = useState5({
|
|
inst: { value, getSnapshot }
|
|
});
|
|
var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
|
|
useLayoutEffect3(
|
|
function() {
|
|
inst.value = value;
|
|
inst.getSnapshot = getSnapshot;
|
|
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
},
|
|
[subscribe2, value, getSnapshot]
|
|
);
|
|
useEffect7(
|
|
function() {
|
|
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
return subscribe2(function() {
|
|
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
});
|
|
},
|
|
[subscribe2]
|
|
);
|
|
useDebugValue(value);
|
|
return value;
|
|
}
|
|
function checkIfSnapshotChanged(inst) {
|
|
var latestGetSnapshot = inst.getSnapshot;
|
|
inst = inst.value;
|
|
try {
|
|
var nextValue = latestGetSnapshot();
|
|
return !objectIs(inst, nextValue);
|
|
} catch (error) {
|
|
return true;
|
|
}
|
|
}
|
|
function useSyncExternalStore$1(subscribe2, getSnapshot) {
|
|
return getSnapshot();
|
|
}
|
|
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
var React18 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState5 = React18.useState, useEffect7 = React18.useEffect, useLayoutEffect3 = React18.useLayoutEffect, useDebugValue = React18.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
|
|
exports.useSyncExternalStore = void 0 !== React18.useSyncExternalStore ? React18.useSyncExternalStore : shim;
|
|
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
})();
|
|
}
|
|
});
|
|
|
|
// ../../../node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.4/node_modules/use-sync-external-store/shim/index.js
|
|
var require_shim = __commonJS({
|
|
"../../../node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.4/node_modules/use-sync-external-store/shim/index.js"(exports, module) {
|
|
"use strict";
|
|
if (false) {
|
|
module.exports = null;
|
|
} else {
|
|
module.exports = require_use_sync_external_store_shim_development();
|
|
}
|
|
}
|
|
});
|
|
|
|
// ../../../node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.4/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
|
|
var require_with_selector_development = __commonJS({
|
|
"../../../node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.4/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
|
|
"use strict";
|
|
(function() {
|
|
function is(x, y) {
|
|
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
}
|
|
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
var React18 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = shim.useSyncExternalStore, useRef7 = React18.useRef, useEffect7 = React18.useEffect, useMemo4 = React18.useMemo, useDebugValue = React18.useDebugValue;
|
|
exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
var instRef = useRef7(null);
|
|
if (null === instRef.current) {
|
|
var inst = { hasValue: false, value: null };
|
|
instRef.current = inst;
|
|
} else inst = instRef.current;
|
|
instRef = useMemo4(
|
|
function() {
|
|
function memoizedSelector(nextSnapshot) {
|
|
if (!hasMemo) {
|
|
hasMemo = true;
|
|
memoizedSnapshot = nextSnapshot;
|
|
nextSnapshot = selector(nextSnapshot);
|
|
if (void 0 !== isEqual && inst.hasValue) {
|
|
var currentSelection = inst.value;
|
|
if (isEqual(currentSelection, nextSnapshot))
|
|
return memoizedSelection = currentSelection;
|
|
}
|
|
return memoizedSelection = nextSnapshot;
|
|
}
|
|
currentSelection = memoizedSelection;
|
|
if (objectIs(memoizedSnapshot, nextSnapshot))
|
|
return currentSelection;
|
|
var nextSelection = selector(nextSnapshot);
|
|
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
|
|
return memoizedSnapshot = nextSnapshot, currentSelection;
|
|
memoizedSnapshot = nextSnapshot;
|
|
return memoizedSelection = nextSelection;
|
|
}
|
|
var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
|
|
return [
|
|
function() {
|
|
return memoizedSelector(getSnapshot());
|
|
},
|
|
null === maybeGetServerSnapshot ? void 0 : function() {
|
|
return memoizedSelector(maybeGetServerSnapshot());
|
|
}
|
|
];
|
|
},
|
|
[getSnapshot, getServerSnapshot, selector, isEqual]
|
|
);
|
|
var value = useSyncExternalStore(subscribe2, instRef[0], instRef[1]);
|
|
useEffect7(
|
|
function() {
|
|
inst.hasValue = true;
|
|
inst.value = value;
|
|
},
|
|
[value]
|
|
);
|
|
useDebugValue(value);
|
|
return value;
|
|
};
|
|
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
})();
|
|
}
|
|
});
|
|
|
|
// ../../../node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.4/node_modules/use-sync-external-store/shim/with-selector.js
|
|
var require_with_selector = __commonJS({
|
|
"../../../node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.4/node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
|
|
"use strict";
|
|
if (false) {
|
|
module.exports = null;
|
|
} else {
|
|
module.exports = require_with_selector_development();
|
|
}
|
|
}
|
|
});
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+store@0.9.2/node_modules/@tanstack/store/dist/esm/alien.js
|
|
var ReactiveFlags = ((ReactiveFlags2) => {
|
|
ReactiveFlags2[ReactiveFlags2["None"] = 0] = "None";
|
|
ReactiveFlags2[ReactiveFlags2["Mutable"] = 1] = "Mutable";
|
|
ReactiveFlags2[ReactiveFlags2["Watching"] = 2] = "Watching";
|
|
ReactiveFlags2[ReactiveFlags2["RecursedCheck"] = 4] = "RecursedCheck";
|
|
ReactiveFlags2[ReactiveFlags2["Recursed"] = 8] = "Recursed";
|
|
ReactiveFlags2[ReactiveFlags2["Dirty"] = 16] = "Dirty";
|
|
ReactiveFlags2[ReactiveFlags2["Pending"] = 32] = "Pending";
|
|
return ReactiveFlags2;
|
|
})(ReactiveFlags || {});
|
|
function createReactiveSystem({
|
|
update,
|
|
notify,
|
|
unwatched
|
|
}) {
|
|
return {
|
|
link: link22,
|
|
unlink: unlink22,
|
|
propagate: propagate22,
|
|
checkDirty: checkDirty22,
|
|
shallowPropagate: shallowPropagate22
|
|
};
|
|
function link22(dep, sub, version) {
|
|
const prevDep = sub.depsTail;
|
|
if (prevDep !== void 0 && prevDep.dep === dep) {
|
|
return;
|
|
}
|
|
const nextDep = prevDep !== void 0 ? prevDep.nextDep : sub.deps;
|
|
if (nextDep !== void 0 && nextDep.dep === dep) {
|
|
nextDep.version = version;
|
|
sub.depsTail = nextDep;
|
|
return;
|
|
}
|
|
const prevSub = dep.subsTail;
|
|
if (prevSub !== void 0 && prevSub.version === version && prevSub.sub === sub) {
|
|
return;
|
|
}
|
|
const newLink = sub.depsTail = dep.subsTail = {
|
|
version,
|
|
dep,
|
|
sub,
|
|
prevDep,
|
|
nextDep,
|
|
prevSub,
|
|
nextSub: void 0
|
|
};
|
|
if (nextDep !== void 0) {
|
|
nextDep.prevDep = newLink;
|
|
}
|
|
if (prevDep !== void 0) {
|
|
prevDep.nextDep = newLink;
|
|
} else {
|
|
sub.deps = newLink;
|
|
}
|
|
if (prevSub !== void 0) {
|
|
prevSub.nextSub = newLink;
|
|
} else {
|
|
dep.subs = newLink;
|
|
}
|
|
}
|
|
function unlink22(link3, sub = link3.sub) {
|
|
const dep = link3.dep;
|
|
const prevDep = link3.prevDep;
|
|
const nextDep = link3.nextDep;
|
|
const nextSub = link3.nextSub;
|
|
const prevSub = link3.prevSub;
|
|
if (nextDep !== void 0) {
|
|
nextDep.prevDep = prevDep;
|
|
} else {
|
|
sub.depsTail = prevDep;
|
|
}
|
|
if (prevDep !== void 0) {
|
|
prevDep.nextDep = nextDep;
|
|
} else {
|
|
sub.deps = nextDep;
|
|
}
|
|
if (nextSub !== void 0) {
|
|
nextSub.prevSub = prevSub;
|
|
} else {
|
|
dep.subsTail = prevSub;
|
|
}
|
|
if (prevSub !== void 0) {
|
|
prevSub.nextSub = nextSub;
|
|
} else if ((dep.subs = nextSub) === void 0) {
|
|
unwatched(dep);
|
|
}
|
|
return nextDep;
|
|
}
|
|
function propagate22(link3) {
|
|
let next = link3.nextSub;
|
|
let stack;
|
|
top: do {
|
|
const sub = link3.sub;
|
|
let flags = sub.flags;
|
|
if (!(flags & (4 | 8 | 16 | 32))) {
|
|
sub.flags = flags | 32;
|
|
} else if (!(flags & (4 | 8))) {
|
|
flags = 0;
|
|
} else if (!(flags & 4)) {
|
|
sub.flags = flags & -9 | 32;
|
|
} else if (!(flags & (16 | 32)) && isValidLink(link3, sub)) {
|
|
sub.flags = flags | (8 | 32);
|
|
flags &= 1;
|
|
} else {
|
|
flags = 0;
|
|
}
|
|
if (flags & 2) {
|
|
notify(sub);
|
|
}
|
|
if (flags & 1) {
|
|
const subSubs = sub.subs;
|
|
if (subSubs !== void 0) {
|
|
const nextSub = (link3 = subSubs).nextSub;
|
|
if (nextSub !== void 0) {
|
|
stack = { value: next, prev: stack };
|
|
next = nextSub;
|
|
}
|
|
continue;
|
|
}
|
|
}
|
|
if ((link3 = next) !== void 0) {
|
|
next = link3.nextSub;
|
|
continue;
|
|
}
|
|
while (stack !== void 0) {
|
|
link3 = stack.value;
|
|
stack = stack.prev;
|
|
if (link3 !== void 0) {
|
|
next = link3.nextSub;
|
|
continue top;
|
|
}
|
|
}
|
|
break;
|
|
} while (true);
|
|
}
|
|
function checkDirty22(link3, sub) {
|
|
let stack;
|
|
let checkDepth = 0;
|
|
let dirty = false;
|
|
top: do {
|
|
const dep = link3.dep;
|
|
const flags = dep.flags;
|
|
if (sub.flags & 16) {
|
|
dirty = true;
|
|
} else if ((flags & (1 | 16)) === (1 | 16)) {
|
|
if (update(dep)) {
|
|
const subs = dep.subs;
|
|
if (subs.nextSub !== void 0) {
|
|
shallowPropagate22(subs);
|
|
}
|
|
dirty = true;
|
|
}
|
|
} else if ((flags & (1 | 32)) === (1 | 32)) {
|
|
if (link3.nextSub !== void 0 || link3.prevSub !== void 0) {
|
|
stack = { value: link3, prev: stack };
|
|
}
|
|
link3 = dep.deps;
|
|
sub = dep;
|
|
++checkDepth;
|
|
continue;
|
|
}
|
|
if (!dirty) {
|
|
const nextDep = link3.nextDep;
|
|
if (nextDep !== void 0) {
|
|
link3 = nextDep;
|
|
continue;
|
|
}
|
|
}
|
|
while (checkDepth--) {
|
|
const firstSub = sub.subs;
|
|
const hasMultipleSubs = firstSub.nextSub !== void 0;
|
|
if (hasMultipleSubs) {
|
|
link3 = stack.value;
|
|
stack = stack.prev;
|
|
} else {
|
|
link3 = firstSub;
|
|
}
|
|
if (dirty) {
|
|
if (update(sub)) {
|
|
if (hasMultipleSubs) {
|
|
shallowPropagate22(firstSub);
|
|
}
|
|
sub = link3.sub;
|
|
continue;
|
|
}
|
|
dirty = false;
|
|
} else {
|
|
sub.flags &= -33;
|
|
}
|
|
sub = link3.sub;
|
|
const nextDep = link3.nextDep;
|
|
if (nextDep !== void 0) {
|
|
link3 = nextDep;
|
|
continue top;
|
|
}
|
|
}
|
|
return dirty;
|
|
} while (true);
|
|
}
|
|
function shallowPropagate22(link3) {
|
|
do {
|
|
const sub = link3.sub;
|
|
const flags = sub.flags;
|
|
if ((flags & (32 | 16)) === 32) {
|
|
sub.flags = flags | 16;
|
|
if ((flags & (2 | 4)) === 2) {
|
|
notify(sub);
|
|
}
|
|
}
|
|
} while ((link3 = link3.nextSub) !== void 0);
|
|
}
|
|
function isValidLink(checkLink, sub) {
|
|
let link3 = sub.depsTail;
|
|
while (link3 !== void 0) {
|
|
if (link3 === checkLink) {
|
|
return true;
|
|
}
|
|
link3 = link3.prevDep;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
var batchDepth = 0;
|
|
var notifyIndex = 0;
|
|
var queuedLength = 0;
|
|
var queued = [];
|
|
var { link, unlink, propagate, checkDirty, shallowPropagate } = createReactiveSystem({
|
|
update(node) {
|
|
if (node.depsTail !== void 0) {
|
|
return updateComputed(node);
|
|
} else {
|
|
return updateSignal(node);
|
|
}
|
|
},
|
|
notify(effect2) {
|
|
let insertIndex = queuedLength;
|
|
let firstInsertedIndex = insertIndex;
|
|
do {
|
|
queued[insertIndex++] = effect2;
|
|
effect2.flags &= -3;
|
|
effect2 = effect2.subs?.sub;
|
|
if (effect2 === void 0 || !(effect2.flags & 2)) {
|
|
break;
|
|
}
|
|
} while (true);
|
|
queuedLength = insertIndex;
|
|
while (firstInsertedIndex < --insertIndex) {
|
|
const left = queued[firstInsertedIndex];
|
|
queued[firstInsertedIndex++] = queued[insertIndex];
|
|
queued[insertIndex] = left;
|
|
}
|
|
},
|
|
unwatched(node) {
|
|
if (!(node.flags & 1)) {
|
|
effectScopeOper.call(node);
|
|
} else if (node.depsTail !== void 0) {
|
|
node.depsTail = void 0;
|
|
node.flags = 1 | 16;
|
|
purgeDeps(node);
|
|
}
|
|
}
|
|
});
|
|
function getBatchDepth() {
|
|
return batchDepth;
|
|
}
|
|
function startBatch() {
|
|
++batchDepth;
|
|
}
|
|
function endBatch() {
|
|
if (!--batchDepth) {
|
|
flush();
|
|
}
|
|
}
|
|
function updateComputed(c) {
|
|
c.depsTail = void 0;
|
|
c.flags = 1 | 4;
|
|
try {
|
|
const oldValue = c.value;
|
|
return oldValue !== (c.value = c.getter(oldValue));
|
|
} finally {
|
|
c.flags &= -5;
|
|
purgeDeps(c);
|
|
}
|
|
}
|
|
function updateSignal(s) {
|
|
s.flags = 1;
|
|
return s.currentValue !== (s.currentValue = s.pendingValue);
|
|
}
|
|
function run(e) {
|
|
const flags = e.flags;
|
|
if (flags & 16 || flags & 32 && checkDirty(e.deps, e)) {
|
|
e.depsTail = void 0;
|
|
e.flags = 2 | 4;
|
|
try {
|
|
;
|
|
e.fn();
|
|
} finally {
|
|
e.flags &= -5;
|
|
purgeDeps(e);
|
|
}
|
|
} else {
|
|
e.flags = 2;
|
|
}
|
|
}
|
|
function flush() {
|
|
try {
|
|
while (notifyIndex < queuedLength) {
|
|
const effect2 = queued[notifyIndex];
|
|
queued[notifyIndex++] = void 0;
|
|
run(effect2);
|
|
}
|
|
} finally {
|
|
while (notifyIndex < queuedLength) {
|
|
const effect2 = queued[notifyIndex];
|
|
queued[notifyIndex++] = void 0;
|
|
effect2.flags |= 2 | 8;
|
|
}
|
|
notifyIndex = 0;
|
|
queuedLength = 0;
|
|
}
|
|
}
|
|
function effectScopeOper() {
|
|
this.depsTail = void 0;
|
|
this.flags = 0;
|
|
purgeDeps(this);
|
|
const sub = this.subs;
|
|
if (sub !== void 0) {
|
|
unlink(sub);
|
|
}
|
|
}
|
|
function purgeDeps(sub) {
|
|
const depsTail = sub.depsTail;
|
|
let dep = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
|
|
while (dep !== void 0) {
|
|
dep = unlink(dep, sub);
|
|
}
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+store@0.9.2/node_modules/@tanstack/store/dist/esm/atom.js
|
|
function toObserver(nextHandler, errorHandler, completionHandler) {
|
|
const isObserver = typeof nextHandler === "object";
|
|
const self2 = isObserver ? nextHandler : void 0;
|
|
return {
|
|
next: (isObserver ? nextHandler.next : nextHandler)?.bind(self2),
|
|
error: (isObserver ? nextHandler.error : errorHandler)?.bind(self2),
|
|
complete: (isObserver ? nextHandler.complete : completionHandler)?.bind(
|
|
self2
|
|
)
|
|
};
|
|
}
|
|
var queuedEffects = [];
|
|
var cycle = 0;
|
|
var { link: link2, unlink: unlink2, propagate: propagate2, checkDirty: checkDirty2, shallowPropagate: shallowPropagate2 } = createReactiveSystem({
|
|
update(atom) {
|
|
return atom._update();
|
|
},
|
|
// eslint-disable-next-line no-shadow
|
|
notify(effect2) {
|
|
queuedEffects[queuedEffectsLength++] = effect2;
|
|
effect2.flags &= ~ReactiveFlags.Watching;
|
|
},
|
|
unwatched(atom) {
|
|
if (atom.depsTail !== void 0) {
|
|
atom.depsTail = void 0;
|
|
atom.flags = ReactiveFlags.Mutable | ReactiveFlags.Dirty;
|
|
purgeDeps2(atom);
|
|
}
|
|
}
|
|
});
|
|
var notifyIndex2 = 0;
|
|
var queuedEffectsLength = 0;
|
|
var activeSub;
|
|
function purgeDeps2(sub) {
|
|
const depsTail = sub.depsTail;
|
|
let dep = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
|
|
while (dep !== void 0) {
|
|
dep = unlink2(dep, sub);
|
|
}
|
|
}
|
|
function flush2() {
|
|
if (getBatchDepth() > 0) {
|
|
return;
|
|
}
|
|
while (notifyIndex2 < queuedEffectsLength) {
|
|
const effect2 = queuedEffects[notifyIndex2];
|
|
queuedEffects[notifyIndex2++] = void 0;
|
|
effect2.notify();
|
|
}
|
|
notifyIndex2 = 0;
|
|
queuedEffectsLength = 0;
|
|
}
|
|
function createAtom(valueOrFn, options) {
|
|
const isComputed = typeof valueOrFn === "function";
|
|
const getter = valueOrFn;
|
|
const atom = {
|
|
_snapshot: isComputed ? void 0 : valueOrFn,
|
|
subs: void 0,
|
|
subsTail: void 0,
|
|
deps: void 0,
|
|
depsTail: void 0,
|
|
flags: isComputed ? ReactiveFlags.None : ReactiveFlags.Mutable,
|
|
get() {
|
|
if (activeSub !== void 0) {
|
|
link2(atom, activeSub, cycle);
|
|
}
|
|
return atom._snapshot;
|
|
},
|
|
subscribe(observerOrFn) {
|
|
const obs = toObserver(observerOrFn);
|
|
const observed = { current: false };
|
|
const e = effect(() => {
|
|
atom.get();
|
|
if (!observed.current) {
|
|
observed.current = true;
|
|
} else {
|
|
obs.next?.(atom._snapshot);
|
|
}
|
|
});
|
|
return {
|
|
unsubscribe: () => {
|
|
e.stop();
|
|
}
|
|
};
|
|
},
|
|
_update(getValue) {
|
|
const prevSub = activeSub;
|
|
const compare = options?.compare ?? Object.is;
|
|
if (isComputed) {
|
|
activeSub = atom;
|
|
++cycle;
|
|
atom.depsTail = void 0;
|
|
} else if (getValue === void 0) {
|
|
return false;
|
|
}
|
|
if (isComputed) {
|
|
atom.flags = ReactiveFlags.Mutable | ReactiveFlags.RecursedCheck;
|
|
}
|
|
try {
|
|
const oldValue = atom._snapshot;
|
|
const newValue = typeof getValue === "function" ? getValue(oldValue) : getValue === void 0 && isComputed ? getter(oldValue) : getValue;
|
|
if (oldValue === void 0 || !compare(oldValue, newValue)) {
|
|
atom._snapshot = newValue;
|
|
return true;
|
|
}
|
|
return false;
|
|
} finally {
|
|
activeSub = prevSub;
|
|
if (isComputed) {
|
|
atom.flags &= ~ReactiveFlags.RecursedCheck;
|
|
}
|
|
purgeDeps2(atom);
|
|
}
|
|
}
|
|
};
|
|
if (isComputed) {
|
|
atom.flags = ReactiveFlags.Mutable | ReactiveFlags.Dirty;
|
|
atom.get = function() {
|
|
const flags = atom.flags;
|
|
if (flags & ReactiveFlags.Dirty || flags & ReactiveFlags.Pending && checkDirty2(atom.deps, atom)) {
|
|
if (atom._update()) {
|
|
const subs = atom.subs;
|
|
if (subs !== void 0) {
|
|
shallowPropagate2(subs);
|
|
}
|
|
}
|
|
} else if (flags & ReactiveFlags.Pending) {
|
|
atom.flags = flags & ~ReactiveFlags.Pending;
|
|
}
|
|
if (activeSub !== void 0) {
|
|
link2(atom, activeSub, cycle);
|
|
}
|
|
return atom._snapshot;
|
|
};
|
|
} else {
|
|
atom.set = function(valueOrFn2) {
|
|
if (atom._update(valueOrFn2)) {
|
|
const subs = atom.subs;
|
|
if (subs !== void 0) {
|
|
propagate2(subs);
|
|
shallowPropagate2(subs);
|
|
flush2();
|
|
}
|
|
}
|
|
};
|
|
}
|
|
return atom;
|
|
}
|
|
function effect(fn) {
|
|
const run2 = () => {
|
|
const prevSub = activeSub;
|
|
activeSub = effectObj;
|
|
++cycle;
|
|
effectObj.depsTail = void 0;
|
|
effectObj.flags = ReactiveFlags.Watching | ReactiveFlags.RecursedCheck;
|
|
try {
|
|
return fn();
|
|
} finally {
|
|
activeSub = prevSub;
|
|
effectObj.flags &= ~ReactiveFlags.RecursedCheck;
|
|
purgeDeps2(effectObj);
|
|
}
|
|
};
|
|
const effectObj = {
|
|
deps: void 0,
|
|
depsTail: void 0,
|
|
subs: void 0,
|
|
subsTail: void 0,
|
|
flags: ReactiveFlags.Watching | ReactiveFlags.RecursedCheck,
|
|
notify() {
|
|
const flags = this.flags;
|
|
if (flags & ReactiveFlags.Dirty || flags & ReactiveFlags.Pending && checkDirty2(this.deps, this)) {
|
|
run2();
|
|
} else {
|
|
this.flags = ReactiveFlags.Watching;
|
|
}
|
|
},
|
|
stop() {
|
|
this.flags = ReactiveFlags.None;
|
|
this.depsTail = void 0;
|
|
purgeDeps2(this);
|
|
}
|
|
};
|
|
run2();
|
|
return effectObj;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+store@0.9.2/node_modules/@tanstack/store/dist/esm/store.js
|
|
var Store = class {
|
|
constructor(valueOrFn) {
|
|
this.atom = createAtom(
|
|
valueOrFn
|
|
);
|
|
}
|
|
setState(updater) {
|
|
this.atom.set(updater);
|
|
}
|
|
get state() {
|
|
return this.atom.get();
|
|
}
|
|
get() {
|
|
return this.state;
|
|
}
|
|
subscribe(observerOrFn) {
|
|
return this.atom.subscribe(toObserver(observerOrFn));
|
|
}
|
|
};
|
|
var ReadonlyStore = class {
|
|
constructor(valueOrFn) {
|
|
this.atom = createAtom(
|
|
valueOrFn
|
|
);
|
|
}
|
|
get state() {
|
|
return this.atom.get();
|
|
}
|
|
get() {
|
|
return this.state;
|
|
}
|
|
subscribe(observerOrFn) {
|
|
return this.atom.subscribe(toObserver(observerOrFn));
|
|
}
|
|
};
|
|
function createStore(valueOrFn) {
|
|
if (typeof valueOrFn === "function") {
|
|
return new ReadonlyStore(valueOrFn);
|
|
}
|
|
return new Store(valueOrFn);
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+store@0.9.2/node_modules/@tanstack/store/dist/esm/batch.js
|
|
function batch(fn) {
|
|
try {
|
|
startBatch();
|
|
fn();
|
|
} finally {
|
|
endBatch();
|
|
flush2();
|
|
}
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+history@1.161.4/node_modules/@tanstack/history/dist/esm/index.js
|
|
var stateIndexKey = "__TSR_index";
|
|
var popStateEvent = "popstate";
|
|
var beforeUnloadEvent = "beforeunload";
|
|
function createHistory(opts) {
|
|
let location = opts.getLocation();
|
|
const subscribers = /* @__PURE__ */ new Set();
|
|
const notify = (action) => {
|
|
location = opts.getLocation();
|
|
subscribers.forEach((subscriber) => subscriber({ location, action }));
|
|
};
|
|
const handleIndexChange = (action) => {
|
|
if (opts.notifyOnIndexChange ?? true) notify(action);
|
|
else location = opts.getLocation();
|
|
};
|
|
const tryNavigation = async ({
|
|
task,
|
|
navigateOpts,
|
|
...actionInfo
|
|
}) => {
|
|
const ignoreBlocker = navigateOpts?.ignoreBlocker ?? false;
|
|
if (ignoreBlocker) {
|
|
task();
|
|
return;
|
|
}
|
|
const blockers = opts.getBlockers?.() ?? [];
|
|
const isPushOrReplace = actionInfo.type === "PUSH" || actionInfo.type === "REPLACE";
|
|
if (typeof document !== "undefined" && blockers.length && isPushOrReplace) {
|
|
for (const blocker of blockers) {
|
|
const nextLocation = parseHref(actionInfo.path, actionInfo.state);
|
|
const isBlocked = await blocker.blockerFn({
|
|
currentLocation: location,
|
|
nextLocation,
|
|
action: actionInfo.type
|
|
});
|
|
if (isBlocked) {
|
|
opts.onBlocked?.();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
task();
|
|
};
|
|
return {
|
|
get location() {
|
|
return location;
|
|
},
|
|
get length() {
|
|
return opts.getLength();
|
|
},
|
|
subscribers,
|
|
subscribe: (cb) => {
|
|
subscribers.add(cb);
|
|
return () => {
|
|
subscribers.delete(cb);
|
|
};
|
|
},
|
|
push: (path, state, navigateOpts) => {
|
|
const currentIndex = location.state[stateIndexKey];
|
|
state = assignKeyAndIndex(currentIndex + 1, state);
|
|
tryNavigation({
|
|
task: () => {
|
|
opts.pushState(path, state);
|
|
notify({ type: "PUSH" });
|
|
},
|
|
navigateOpts,
|
|
type: "PUSH",
|
|
path,
|
|
state
|
|
});
|
|
},
|
|
replace: (path, state, navigateOpts) => {
|
|
const currentIndex = location.state[stateIndexKey];
|
|
state = assignKeyAndIndex(currentIndex, state);
|
|
tryNavigation({
|
|
task: () => {
|
|
opts.replaceState(path, state);
|
|
notify({ type: "REPLACE" });
|
|
},
|
|
navigateOpts,
|
|
type: "REPLACE",
|
|
path,
|
|
state
|
|
});
|
|
},
|
|
go: (index, navigateOpts) => {
|
|
tryNavigation({
|
|
task: () => {
|
|
opts.go(index);
|
|
handleIndexChange({ type: "GO", index });
|
|
},
|
|
navigateOpts,
|
|
type: "GO"
|
|
});
|
|
},
|
|
back: (navigateOpts) => {
|
|
tryNavigation({
|
|
task: () => {
|
|
opts.back(navigateOpts?.ignoreBlocker ?? false);
|
|
handleIndexChange({ type: "BACK" });
|
|
},
|
|
navigateOpts,
|
|
type: "BACK"
|
|
});
|
|
},
|
|
forward: (navigateOpts) => {
|
|
tryNavigation({
|
|
task: () => {
|
|
opts.forward(navigateOpts?.ignoreBlocker ?? false);
|
|
handleIndexChange({ type: "FORWARD" });
|
|
},
|
|
navigateOpts,
|
|
type: "FORWARD"
|
|
});
|
|
},
|
|
canGoBack: () => location.state[stateIndexKey] !== 0,
|
|
createHref: (str) => opts.createHref(str),
|
|
block: (blocker) => {
|
|
if (!opts.setBlockers) return () => {
|
|
};
|
|
const blockers = opts.getBlockers?.() ?? [];
|
|
opts.setBlockers([...blockers, blocker]);
|
|
return () => {
|
|
const blockers2 = opts.getBlockers?.() ?? [];
|
|
opts.setBlockers?.(blockers2.filter((b) => b !== blocker));
|
|
};
|
|
},
|
|
flush: () => opts.flush?.(),
|
|
destroy: () => opts.destroy?.(),
|
|
notify
|
|
};
|
|
}
|
|
function assignKeyAndIndex(index, state) {
|
|
if (!state) {
|
|
state = {};
|
|
}
|
|
const key = createRandomKey();
|
|
return {
|
|
...state,
|
|
key,
|
|
// TODO: Remove in v2 - use __TSR_key instead
|
|
__TSR_key: key,
|
|
[stateIndexKey]: index
|
|
};
|
|
}
|
|
function createBrowserHistory(opts) {
|
|
const win = opts?.window ?? (typeof document !== "undefined" ? window : void 0);
|
|
const originalPushState = win.history.pushState;
|
|
const originalReplaceState = win.history.replaceState;
|
|
let blockers = [];
|
|
const _getBlockers = () => blockers;
|
|
const _setBlockers = (newBlockers) => blockers = newBlockers;
|
|
const createHref = opts?.createHref ?? ((path) => path);
|
|
const parseLocation = opts?.parseLocation ?? (() => parseHref(
|
|
`${win.location.pathname}${win.location.search}${win.location.hash}`,
|
|
win.history.state
|
|
));
|
|
if (!win.history.state?.__TSR_key && !win.history.state?.key) {
|
|
const addedKey = createRandomKey();
|
|
win.history.replaceState(
|
|
{
|
|
[stateIndexKey]: 0,
|
|
key: addedKey,
|
|
// TODO: Remove in v2 - use __TSR_key instead
|
|
__TSR_key: addedKey
|
|
},
|
|
""
|
|
);
|
|
}
|
|
let currentLocation = parseLocation();
|
|
let rollbackLocation;
|
|
let nextPopIsGo = false;
|
|
let ignoreNextPop = false;
|
|
let skipBlockerNextPop = false;
|
|
let ignoreNextBeforeUnload = false;
|
|
const getLocation = () => currentLocation;
|
|
let next;
|
|
let scheduled;
|
|
const flush3 = () => {
|
|
if (!next) {
|
|
return;
|
|
}
|
|
history._ignoreSubscribers = true;
|
|
(next.isPush ? win.history.pushState : win.history.replaceState)(
|
|
next.state,
|
|
"",
|
|
next.href
|
|
);
|
|
history._ignoreSubscribers = false;
|
|
next = void 0;
|
|
scheduled = void 0;
|
|
rollbackLocation = void 0;
|
|
};
|
|
const queueHistoryAction = (type, destHref, state) => {
|
|
const href = createHref(destHref);
|
|
if (!scheduled) {
|
|
rollbackLocation = currentLocation;
|
|
}
|
|
currentLocation = parseHref(destHref, state);
|
|
next = {
|
|
href,
|
|
state,
|
|
isPush: next?.isPush || type === "push"
|
|
};
|
|
if (!scheduled) {
|
|
scheduled = Promise.resolve().then(() => flush3());
|
|
}
|
|
};
|
|
const onPushPop = (type) => {
|
|
currentLocation = parseLocation();
|
|
history.notify({ type });
|
|
};
|
|
const onPushPopEvent = async () => {
|
|
if (ignoreNextPop) {
|
|
ignoreNextPop = false;
|
|
return;
|
|
}
|
|
const nextLocation = parseLocation();
|
|
const delta = nextLocation.state[stateIndexKey] - currentLocation.state[stateIndexKey];
|
|
const isForward = delta === 1;
|
|
const isBack = delta === -1;
|
|
const isGo = !isForward && !isBack || nextPopIsGo;
|
|
nextPopIsGo = false;
|
|
const action = isGo ? "GO" : isBack ? "BACK" : "FORWARD";
|
|
const notify = isGo ? {
|
|
type: "GO",
|
|
index: delta
|
|
} : {
|
|
type: isBack ? "BACK" : "FORWARD"
|
|
};
|
|
if (skipBlockerNextPop) {
|
|
skipBlockerNextPop = false;
|
|
} else {
|
|
const blockers2 = _getBlockers();
|
|
if (typeof document !== "undefined" && blockers2.length) {
|
|
for (const blocker of blockers2) {
|
|
const isBlocked = await blocker.blockerFn({
|
|
currentLocation,
|
|
nextLocation,
|
|
action
|
|
});
|
|
if (isBlocked) {
|
|
ignoreNextPop = true;
|
|
win.history.go(1);
|
|
history.notify(notify);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
currentLocation = parseLocation();
|
|
history.notify(notify);
|
|
};
|
|
const onBeforeUnload = (e) => {
|
|
if (ignoreNextBeforeUnload) {
|
|
ignoreNextBeforeUnload = false;
|
|
return;
|
|
}
|
|
let shouldBlock = false;
|
|
const blockers2 = _getBlockers();
|
|
if (typeof document !== "undefined" && blockers2.length) {
|
|
for (const blocker of blockers2) {
|
|
const shouldHaveBeforeUnload = blocker.enableBeforeUnload ?? true;
|
|
if (shouldHaveBeforeUnload === true) {
|
|
shouldBlock = true;
|
|
break;
|
|
}
|
|
if (typeof shouldHaveBeforeUnload === "function" && shouldHaveBeforeUnload() === true) {
|
|
shouldBlock = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (shouldBlock) {
|
|
e.preventDefault();
|
|
return e.returnValue = "";
|
|
}
|
|
return;
|
|
};
|
|
const history = createHistory({
|
|
getLocation,
|
|
getLength: () => win.history.length,
|
|
pushState: (href, state) => queueHistoryAction("push", href, state),
|
|
replaceState: (href, state) => queueHistoryAction("replace", href, state),
|
|
back: (ignoreBlocker) => {
|
|
if (ignoreBlocker) skipBlockerNextPop = true;
|
|
ignoreNextBeforeUnload = true;
|
|
return win.history.back();
|
|
},
|
|
forward: (ignoreBlocker) => {
|
|
if (ignoreBlocker) skipBlockerNextPop = true;
|
|
ignoreNextBeforeUnload = true;
|
|
win.history.forward();
|
|
},
|
|
go: (n) => {
|
|
nextPopIsGo = true;
|
|
win.history.go(n);
|
|
},
|
|
createHref: (href) => createHref(href),
|
|
flush: flush3,
|
|
destroy: () => {
|
|
win.history.pushState = originalPushState;
|
|
win.history.replaceState = originalReplaceState;
|
|
win.removeEventListener(beforeUnloadEvent, onBeforeUnload, {
|
|
capture: true
|
|
});
|
|
win.removeEventListener(popStateEvent, onPushPopEvent);
|
|
},
|
|
onBlocked: () => {
|
|
if (rollbackLocation && currentLocation !== rollbackLocation) {
|
|
currentLocation = rollbackLocation;
|
|
}
|
|
},
|
|
getBlockers: _getBlockers,
|
|
setBlockers: _setBlockers,
|
|
notifyOnIndexChange: false
|
|
});
|
|
win.addEventListener(beforeUnloadEvent, onBeforeUnload, { capture: true });
|
|
win.addEventListener(popStateEvent, onPushPopEvent);
|
|
win.history.pushState = function(...args) {
|
|
const res = originalPushState.apply(win.history, args);
|
|
if (!history._ignoreSubscribers) onPushPop("PUSH");
|
|
return res;
|
|
};
|
|
win.history.replaceState = function(...args) {
|
|
const res = originalReplaceState.apply(win.history, args);
|
|
if (!history._ignoreSubscribers) onPushPop("REPLACE");
|
|
return res;
|
|
};
|
|
return history;
|
|
}
|
|
function createHashHistory(opts) {
|
|
const win = opts?.window ?? (typeof document !== "undefined" ? window : void 0);
|
|
return createBrowserHistory({
|
|
window: win,
|
|
parseLocation: () => {
|
|
const hashSplit = win.location.hash.split("#").slice(1);
|
|
const pathPart = hashSplit[0] ?? "/";
|
|
const searchPart = win.location.search;
|
|
const hashEntries = hashSplit.slice(1);
|
|
const hashPart = hashEntries.length === 0 ? "" : `#${hashEntries.join("#")}`;
|
|
const hashHref = `${pathPart}${searchPart}${hashPart}`;
|
|
return parseHref(hashHref, win.history.state);
|
|
},
|
|
createHref: (href) => `${win.location.pathname}${win.location.search}#${href}`
|
|
});
|
|
}
|
|
function createMemoryHistory(opts = {
|
|
initialEntries: ["/"]
|
|
}) {
|
|
const entries = opts.initialEntries;
|
|
let index = opts.initialIndex ? Math.min(Math.max(opts.initialIndex, 0), entries.length - 1) : entries.length - 1;
|
|
const states = entries.map(
|
|
(_entry, index2) => assignKeyAndIndex(index2, void 0)
|
|
);
|
|
const getLocation = () => parseHref(entries[index], states[index]);
|
|
let blockers = [];
|
|
const _getBlockers = () => blockers;
|
|
const _setBlockers = (newBlockers) => blockers = newBlockers;
|
|
return createHistory({
|
|
getLocation,
|
|
getLength: () => entries.length,
|
|
pushState: (path, state) => {
|
|
if (index < entries.length - 1) {
|
|
entries.splice(index + 1);
|
|
states.splice(index + 1);
|
|
}
|
|
states.push(state);
|
|
entries.push(path);
|
|
index = Math.max(entries.length - 1, 0);
|
|
},
|
|
replaceState: (path, state) => {
|
|
states[index] = state;
|
|
entries[index] = path;
|
|
},
|
|
back: () => {
|
|
index = Math.max(index - 1, 0);
|
|
},
|
|
forward: () => {
|
|
index = Math.min(index + 1, entries.length - 1);
|
|
},
|
|
go: (n) => {
|
|
index = Math.min(Math.max(index + n, 0), entries.length - 1);
|
|
},
|
|
createHref: (path) => path,
|
|
getBlockers: _getBlockers,
|
|
setBlockers: _setBlockers
|
|
});
|
|
}
|
|
function sanitizePath(path) {
|
|
let sanitized = path.replace(/[\x00-\x1f\x7f]/g, "");
|
|
if (sanitized.startsWith("//")) {
|
|
sanitized = "/" + sanitized.replace(/^\/+/, "");
|
|
}
|
|
return sanitized;
|
|
}
|
|
function parseHref(href, state) {
|
|
const sanitizedHref = sanitizePath(href);
|
|
const hashIndex = sanitizedHref.indexOf("#");
|
|
const searchIndex = sanitizedHref.indexOf("?");
|
|
const addedKey = createRandomKey();
|
|
return {
|
|
href: sanitizedHref,
|
|
pathname: sanitizedHref.substring(
|
|
0,
|
|
hashIndex > 0 ? searchIndex > 0 ? Math.min(hashIndex, searchIndex) : hashIndex : searchIndex > 0 ? searchIndex : sanitizedHref.length
|
|
),
|
|
hash: hashIndex > -1 ? sanitizedHref.substring(hashIndex) : "",
|
|
search: searchIndex > -1 ? sanitizedHref.slice(
|
|
searchIndex,
|
|
hashIndex === -1 ? void 0 : hashIndex
|
|
) : "",
|
|
state: state || { [stateIndexKey]: 0, key: addedKey, __TSR_key: addedKey }
|
|
};
|
|
}
|
|
function createRandomKey() {
|
|
return (Math.random() + 1).toString(36).substring(7);
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/isServer/development.js
|
|
var isServer = void 0;
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/utils/batch.js
|
|
function batch2(fn) {
|
|
if (isServer) {
|
|
return fn();
|
|
}
|
|
let result;
|
|
batch(() => {
|
|
result = fn();
|
|
});
|
|
return result;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/utils.js
|
|
function last(arr) {
|
|
return arr[arr.length - 1];
|
|
}
|
|
function isFunction(d) {
|
|
return typeof d === "function";
|
|
}
|
|
function functionalUpdate(updater, previous) {
|
|
if (isFunction(updater)) {
|
|
return updater(previous);
|
|
}
|
|
return updater;
|
|
}
|
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
|
function replaceEqualDeep(prev, _next, _depth = 0) {
|
|
if (isServer) {
|
|
return _next;
|
|
}
|
|
if (prev === _next) {
|
|
return prev;
|
|
}
|
|
if (_depth > 500) return _next;
|
|
const next = _next;
|
|
const array = isPlainArray(prev) && isPlainArray(next);
|
|
if (!array && !(isPlainObject(prev) && isPlainObject(next))) return next;
|
|
const prevItems = array ? prev : getEnumerableOwnKeys(prev);
|
|
if (!prevItems) return next;
|
|
const nextItems = array ? next : getEnumerableOwnKeys(next);
|
|
if (!nextItems) return next;
|
|
const prevSize = prevItems.length;
|
|
const nextSize = nextItems.length;
|
|
const copy = array ? new Array(nextSize) : {};
|
|
let equalItems = 0;
|
|
for (let i = 0; i < nextSize; i++) {
|
|
const key = array ? i : nextItems[i];
|
|
const p = prev[key];
|
|
const n = next[key];
|
|
if (p === n) {
|
|
copy[key] = p;
|
|
if (array ? i < prevSize : hasOwn.call(prev, key)) equalItems++;
|
|
continue;
|
|
}
|
|
if (p === null || n === null || typeof p !== "object" || typeof n !== "object") {
|
|
copy[key] = n;
|
|
continue;
|
|
}
|
|
const v = replaceEqualDeep(p, n, _depth + 1);
|
|
copy[key] = v;
|
|
if (v === p) equalItems++;
|
|
}
|
|
return prevSize === nextSize && equalItems === prevSize ? prev : copy;
|
|
}
|
|
function getEnumerableOwnKeys(o) {
|
|
const names = Object.getOwnPropertyNames(o);
|
|
for (const name of names) {
|
|
if (!isEnumerable.call(o, name)) return false;
|
|
}
|
|
const symbols = Object.getOwnPropertySymbols(o);
|
|
if (symbols.length === 0) return names;
|
|
const keys = names;
|
|
for (const symbol of symbols) {
|
|
if (!isEnumerable.call(o, symbol)) return false;
|
|
keys.push(symbol);
|
|
}
|
|
return keys;
|
|
}
|
|
function isPlainObject(o) {
|
|
if (!hasObjectPrototype(o)) {
|
|
return false;
|
|
}
|
|
const ctor = o.constructor;
|
|
if (typeof ctor === "undefined") {
|
|
return true;
|
|
}
|
|
const prot = ctor.prototype;
|
|
if (!hasObjectPrototype(prot)) {
|
|
return false;
|
|
}
|
|
if (!prot.hasOwnProperty("isPrototypeOf")) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
function hasObjectPrototype(o) {
|
|
return Object.prototype.toString.call(o) === "[object Object]";
|
|
}
|
|
function isPlainArray(value) {
|
|
return Array.isArray(value) && value.length === Object.keys(value).length;
|
|
}
|
|
function deepEqual(a, b, opts) {
|
|
if (a === b) {
|
|
return true;
|
|
}
|
|
if (typeof a !== typeof b) {
|
|
return false;
|
|
}
|
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
if (a.length !== b.length) return false;
|
|
for (let i = 0, l = a.length; i < l; i++) {
|
|
if (!deepEqual(a[i], b[i], opts)) return false;
|
|
}
|
|
return true;
|
|
}
|
|
if (isPlainObject(a) && isPlainObject(b)) {
|
|
const ignoreUndefined = opts?.ignoreUndefined ?? true;
|
|
if (opts?.partial) {
|
|
for (const k in b) {
|
|
if (!ignoreUndefined || b[k] !== void 0) {
|
|
if (!deepEqual(a[k], b[k], opts)) return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
let aCount = 0;
|
|
if (!ignoreUndefined) {
|
|
aCount = Object.keys(a).length;
|
|
} else {
|
|
for (const k in a) {
|
|
if (a[k] !== void 0) aCount++;
|
|
}
|
|
}
|
|
let bCount = 0;
|
|
for (const k in b) {
|
|
if (!ignoreUndefined || b[k] !== void 0) {
|
|
bCount++;
|
|
if (bCount > aCount || !deepEqual(a[k], b[k], opts)) return false;
|
|
}
|
|
}
|
|
return aCount === bCount;
|
|
}
|
|
return false;
|
|
}
|
|
function createControlledPromise(onResolve) {
|
|
let resolveLoadPromise;
|
|
let rejectLoadPromise;
|
|
const controlledPromise = new Promise((resolve, reject) => {
|
|
resolveLoadPromise = resolve;
|
|
rejectLoadPromise = reject;
|
|
});
|
|
controlledPromise.status = "pending";
|
|
controlledPromise.resolve = (value) => {
|
|
controlledPromise.status = "resolved";
|
|
controlledPromise.value = value;
|
|
resolveLoadPromise(value);
|
|
onResolve?.(value);
|
|
};
|
|
controlledPromise.reject = (e) => {
|
|
controlledPromise.status = "rejected";
|
|
rejectLoadPromise(e);
|
|
};
|
|
return controlledPromise;
|
|
}
|
|
function isModuleNotFoundError(error) {
|
|
if (typeof error?.message !== "string") return false;
|
|
return error.message.startsWith("Failed to fetch dynamically imported module") || error.message.startsWith("error loading dynamically imported module") || error.message.startsWith("Importing a module script failed");
|
|
}
|
|
function isPromise(value) {
|
|
return Boolean(
|
|
value && typeof value === "object" && typeof value.then === "function"
|
|
);
|
|
}
|
|
function findLast(array, predicate) {
|
|
for (let i = array.length - 1; i >= 0; i--) {
|
|
const item = array[i];
|
|
if (predicate(item)) return item;
|
|
}
|
|
return void 0;
|
|
}
|
|
function sanitizePathSegment(segment) {
|
|
return segment.replace(/[\x00-\x1f\x7f]/g, "");
|
|
}
|
|
function decodeSegment(segment) {
|
|
let decoded;
|
|
try {
|
|
decoded = decodeURI(segment);
|
|
} catch {
|
|
decoded = segment.replaceAll(/%[0-9A-F]{2}/gi, (match) => {
|
|
try {
|
|
return decodeURI(match);
|
|
} catch {
|
|
return match;
|
|
}
|
|
});
|
|
}
|
|
return sanitizePathSegment(decoded);
|
|
}
|
|
var DEFAULT_PROTOCOL_ALLOWLIST = [
|
|
// Standard web navigation
|
|
"http:",
|
|
"https:",
|
|
// Common browser-safe actions
|
|
"mailto:",
|
|
"tel:"
|
|
];
|
|
function isDangerousProtocol(url, allowlist) {
|
|
if (!url) return false;
|
|
try {
|
|
const parsed = new URL(url);
|
|
return !allowlist.has(parsed.protocol);
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
var HTML_ESCAPE_LOOKUP = {
|
|
"&": "\\u0026",
|
|
">": "\\u003e",
|
|
"<": "\\u003c",
|
|
"\u2028": "\\u2028",
|
|
"\u2029": "\\u2029"
|
|
};
|
|
var HTML_ESCAPE_REGEX = /[&><\u2028\u2029]/g;
|
|
function escapeHtml(str) {
|
|
return str.replace(HTML_ESCAPE_REGEX, (match) => HTML_ESCAPE_LOOKUP[match]);
|
|
}
|
|
function decodePath(path) {
|
|
if (!path) return { path, handledProtocolRelativeURL: false };
|
|
if (!/[%\\\x00-\x1f\x7f]/.test(path) && !path.startsWith("//")) {
|
|
return { path, handledProtocolRelativeURL: false };
|
|
}
|
|
const re = /%25|%5C/gi;
|
|
let cursor = 0;
|
|
let result = "";
|
|
let match;
|
|
while (null !== (match = re.exec(path))) {
|
|
result += decodeSegment(path.slice(cursor, match.index)) + match[0];
|
|
cursor = re.lastIndex;
|
|
}
|
|
result = result + decodeSegment(cursor ? path.slice(cursor) : path);
|
|
let handledProtocolRelativeURL = false;
|
|
if (result.startsWith("//")) {
|
|
handledProtocolRelativeURL = true;
|
|
result = "/" + result.replace(/^\/+/, "");
|
|
}
|
|
return { path: result, handledProtocolRelativeURL };
|
|
}
|
|
function encodePathLikeUrl(path) {
|
|
if (!/\s|[^\u0000-\u007F]/.test(path)) return path;
|
|
return path.replace(/\s|[^\u0000-\u007F]/gu, encodeURIComponent);
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
var isProduction = false;
|
|
var prefix = "Invariant failed";
|
|
function invariant(condition, message) {
|
|
if (condition) {
|
|
return;
|
|
}
|
|
if (isProduction) {
|
|
throw new Error(prefix);
|
|
}
|
|
var provided = typeof message === "function" ? message() : message;
|
|
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
throw new Error(value);
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/lru-cache.js
|
|
function createLRUCache(max) {
|
|
const cache = /* @__PURE__ */ new Map();
|
|
let oldest;
|
|
let newest;
|
|
const touch = (entry) => {
|
|
if (!entry.next) return;
|
|
if (!entry.prev) {
|
|
entry.next.prev = void 0;
|
|
oldest = entry.next;
|
|
entry.next = void 0;
|
|
if (newest) {
|
|
entry.prev = newest;
|
|
newest.next = entry;
|
|
}
|
|
} else {
|
|
entry.prev.next = entry.next;
|
|
entry.next.prev = entry.prev;
|
|
entry.next = void 0;
|
|
if (newest) {
|
|
newest.next = entry;
|
|
entry.prev = newest;
|
|
}
|
|
}
|
|
newest = entry;
|
|
};
|
|
return {
|
|
get(key) {
|
|
const entry = cache.get(key);
|
|
if (!entry) return void 0;
|
|
touch(entry);
|
|
return entry.value;
|
|
},
|
|
set(key, value) {
|
|
if (cache.size >= max && oldest) {
|
|
const toDelete = oldest;
|
|
cache.delete(toDelete.key);
|
|
if (toDelete.next) {
|
|
oldest = toDelete.next;
|
|
toDelete.next.prev = void 0;
|
|
}
|
|
if (toDelete === newest) {
|
|
newest = void 0;
|
|
}
|
|
}
|
|
const existing = cache.get(key);
|
|
if (existing) {
|
|
existing.value = value;
|
|
touch(existing);
|
|
} else {
|
|
const entry = { key, value, prev: newest };
|
|
if (newest) newest.next = entry;
|
|
newest = entry;
|
|
if (!oldest) oldest = entry;
|
|
cache.set(key, entry);
|
|
}
|
|
},
|
|
clear() {
|
|
cache.clear();
|
|
oldest = void 0;
|
|
newest = void 0;
|
|
}
|
|
};
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/new-process-route-tree.js
|
|
var SEGMENT_TYPE_PATHNAME = 0;
|
|
var SEGMENT_TYPE_PARAM = 1;
|
|
var SEGMENT_TYPE_WILDCARD = 2;
|
|
var SEGMENT_TYPE_OPTIONAL_PARAM = 3;
|
|
var SEGMENT_TYPE_INDEX = 4;
|
|
var SEGMENT_TYPE_PATHLESS = 5;
|
|
function getOpenAndCloseBraces(part) {
|
|
const openBrace = part.indexOf("{");
|
|
if (openBrace === -1) return null;
|
|
const closeBrace = part.indexOf("}", openBrace);
|
|
if (closeBrace === -1) return null;
|
|
const afterOpen = openBrace + 1;
|
|
if (afterOpen >= part.length) return null;
|
|
return [openBrace, closeBrace];
|
|
}
|
|
function parseSegment(path, start, output = new Uint16Array(6)) {
|
|
const next = path.indexOf("/", start);
|
|
const end = next === -1 ? path.length : next;
|
|
const part = path.substring(start, end);
|
|
if (!part || !part.includes("$")) {
|
|
output[0] = SEGMENT_TYPE_PATHNAME;
|
|
output[1] = start;
|
|
output[2] = start;
|
|
output[3] = end;
|
|
output[4] = end;
|
|
output[5] = end;
|
|
return output;
|
|
}
|
|
if (part === "$") {
|
|
const total = path.length;
|
|
output[0] = SEGMENT_TYPE_WILDCARD;
|
|
output[1] = start;
|
|
output[2] = start;
|
|
output[3] = total;
|
|
output[4] = total;
|
|
output[5] = total;
|
|
return output;
|
|
}
|
|
if (part.charCodeAt(0) === 36) {
|
|
output[0] = SEGMENT_TYPE_PARAM;
|
|
output[1] = start;
|
|
output[2] = start + 1;
|
|
output[3] = end;
|
|
output[4] = end;
|
|
output[5] = end;
|
|
return output;
|
|
}
|
|
const braces = getOpenAndCloseBraces(part);
|
|
if (braces) {
|
|
const [openBrace, closeBrace] = braces;
|
|
const firstChar = part.charCodeAt(openBrace + 1);
|
|
if (firstChar === 45) {
|
|
if (openBrace + 2 < part.length && part.charCodeAt(openBrace + 2) === 36) {
|
|
const paramStart = openBrace + 3;
|
|
const paramEnd = closeBrace;
|
|
if (paramStart < paramEnd) {
|
|
output[0] = SEGMENT_TYPE_OPTIONAL_PARAM;
|
|
output[1] = start + openBrace;
|
|
output[2] = start + paramStart;
|
|
output[3] = start + paramEnd;
|
|
output[4] = start + closeBrace + 1;
|
|
output[5] = end;
|
|
return output;
|
|
}
|
|
}
|
|
} else if (firstChar === 36) {
|
|
const dollarPos = openBrace + 1;
|
|
const afterDollar = openBrace + 2;
|
|
if (afterDollar === closeBrace) {
|
|
output[0] = SEGMENT_TYPE_WILDCARD;
|
|
output[1] = start + openBrace;
|
|
output[2] = start + dollarPos;
|
|
output[3] = start + afterDollar;
|
|
output[4] = start + closeBrace + 1;
|
|
output[5] = path.length;
|
|
return output;
|
|
}
|
|
output[0] = SEGMENT_TYPE_PARAM;
|
|
output[1] = start + openBrace;
|
|
output[2] = start + afterDollar;
|
|
output[3] = start + closeBrace;
|
|
output[4] = start + closeBrace + 1;
|
|
output[5] = end;
|
|
return output;
|
|
}
|
|
}
|
|
output[0] = SEGMENT_TYPE_PATHNAME;
|
|
output[1] = start;
|
|
output[2] = start;
|
|
output[3] = end;
|
|
output[4] = end;
|
|
output[5] = end;
|
|
return output;
|
|
}
|
|
function parseSegments(defaultCaseSensitive, data, route, start, node, depth, onRoute) {
|
|
onRoute?.(route);
|
|
let cursor = start;
|
|
{
|
|
const path = route.fullPath ?? route.from;
|
|
const length = path.length;
|
|
const caseSensitive = route.options?.caseSensitive ?? defaultCaseSensitive;
|
|
const skipOnParamError = !!(route.options?.params?.parse && route.options?.skipRouteOnParseError?.params);
|
|
while (cursor < length) {
|
|
const segment = parseSegment(path, cursor, data);
|
|
let nextNode;
|
|
const start2 = cursor;
|
|
const end = segment[5];
|
|
cursor = end + 1;
|
|
depth++;
|
|
const kind = segment[0];
|
|
switch (kind) {
|
|
case SEGMENT_TYPE_PATHNAME: {
|
|
const value = path.substring(segment[2], segment[3]);
|
|
if (caseSensitive) {
|
|
const existingNode = node.static?.get(value);
|
|
if (existingNode) {
|
|
nextNode = existingNode;
|
|
} else {
|
|
node.static ??= /* @__PURE__ */ new Map();
|
|
const next = createStaticNode(
|
|
route.fullPath ?? route.from
|
|
);
|
|
next.parent = node;
|
|
next.depth = depth;
|
|
nextNode = next;
|
|
node.static.set(value, next);
|
|
}
|
|
} else {
|
|
const name = value.toLowerCase();
|
|
const existingNode = node.staticInsensitive?.get(name);
|
|
if (existingNode) {
|
|
nextNode = existingNode;
|
|
} else {
|
|
node.staticInsensitive ??= /* @__PURE__ */ new Map();
|
|
const next = createStaticNode(
|
|
route.fullPath ?? route.from
|
|
);
|
|
next.parent = node;
|
|
next.depth = depth;
|
|
nextNode = next;
|
|
node.staticInsensitive.set(name, next);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case SEGMENT_TYPE_PARAM: {
|
|
const prefix_raw = path.substring(start2, segment[1]);
|
|
const suffix_raw = path.substring(segment[4], end);
|
|
const actuallyCaseSensitive = caseSensitive && !!(prefix_raw || suffix_raw);
|
|
const prefix2 = !prefix_raw ? void 0 : actuallyCaseSensitive ? prefix_raw : prefix_raw.toLowerCase();
|
|
const suffix = !suffix_raw ? void 0 : actuallyCaseSensitive ? suffix_raw : suffix_raw.toLowerCase();
|
|
const existingNode = !skipOnParamError && node.dynamic?.find(
|
|
(s) => !s.skipOnParamError && s.caseSensitive === actuallyCaseSensitive && s.prefix === prefix2 && s.suffix === suffix
|
|
);
|
|
if (existingNode) {
|
|
nextNode = existingNode;
|
|
} else {
|
|
const next = createDynamicNode(
|
|
SEGMENT_TYPE_PARAM,
|
|
route.fullPath ?? route.from,
|
|
actuallyCaseSensitive,
|
|
prefix2,
|
|
suffix
|
|
);
|
|
nextNode = next;
|
|
next.depth = depth;
|
|
next.parent = node;
|
|
node.dynamic ??= [];
|
|
node.dynamic.push(next);
|
|
}
|
|
break;
|
|
}
|
|
case SEGMENT_TYPE_OPTIONAL_PARAM: {
|
|
const prefix_raw = path.substring(start2, segment[1]);
|
|
const suffix_raw = path.substring(segment[4], end);
|
|
const actuallyCaseSensitive = caseSensitive && !!(prefix_raw || suffix_raw);
|
|
const prefix2 = !prefix_raw ? void 0 : actuallyCaseSensitive ? prefix_raw : prefix_raw.toLowerCase();
|
|
const suffix = !suffix_raw ? void 0 : actuallyCaseSensitive ? suffix_raw : suffix_raw.toLowerCase();
|
|
const existingNode = !skipOnParamError && node.optional?.find(
|
|
(s) => !s.skipOnParamError && s.caseSensitive === actuallyCaseSensitive && s.prefix === prefix2 && s.suffix === suffix
|
|
);
|
|
if (existingNode) {
|
|
nextNode = existingNode;
|
|
} else {
|
|
const next = createDynamicNode(
|
|
SEGMENT_TYPE_OPTIONAL_PARAM,
|
|
route.fullPath ?? route.from,
|
|
actuallyCaseSensitive,
|
|
prefix2,
|
|
suffix
|
|
);
|
|
nextNode = next;
|
|
next.parent = node;
|
|
next.depth = depth;
|
|
node.optional ??= [];
|
|
node.optional.push(next);
|
|
}
|
|
break;
|
|
}
|
|
case SEGMENT_TYPE_WILDCARD: {
|
|
const prefix_raw = path.substring(start2, segment[1]);
|
|
const suffix_raw = path.substring(segment[4], end);
|
|
const actuallyCaseSensitive = caseSensitive && !!(prefix_raw || suffix_raw);
|
|
const prefix2 = !prefix_raw ? void 0 : actuallyCaseSensitive ? prefix_raw : prefix_raw.toLowerCase();
|
|
const suffix = !suffix_raw ? void 0 : actuallyCaseSensitive ? suffix_raw : suffix_raw.toLowerCase();
|
|
const next = createDynamicNode(
|
|
SEGMENT_TYPE_WILDCARD,
|
|
route.fullPath ?? route.from,
|
|
actuallyCaseSensitive,
|
|
prefix2,
|
|
suffix
|
|
);
|
|
nextNode = next;
|
|
next.parent = node;
|
|
next.depth = depth;
|
|
node.wildcard ??= [];
|
|
node.wildcard.push(next);
|
|
}
|
|
}
|
|
node = nextNode;
|
|
}
|
|
if (skipOnParamError && route.children && !route.isRoot && route.id && route.id.charCodeAt(route.id.lastIndexOf("/") + 1) === 95) {
|
|
const pathlessNode = createStaticNode(
|
|
route.fullPath ?? route.from
|
|
);
|
|
pathlessNode.kind = SEGMENT_TYPE_PATHLESS;
|
|
pathlessNode.parent = node;
|
|
depth++;
|
|
pathlessNode.depth = depth;
|
|
node.pathless ??= [];
|
|
node.pathless.push(pathlessNode);
|
|
node = pathlessNode;
|
|
}
|
|
const isLeaf = (route.path || !route.children) && !route.isRoot;
|
|
if (isLeaf && path.endsWith("/")) {
|
|
const indexNode = createStaticNode(
|
|
route.fullPath ?? route.from
|
|
);
|
|
indexNode.kind = SEGMENT_TYPE_INDEX;
|
|
indexNode.parent = node;
|
|
depth++;
|
|
indexNode.depth = depth;
|
|
node.index = indexNode;
|
|
node = indexNode;
|
|
}
|
|
node.parse = route.options?.params?.parse ?? null;
|
|
node.skipOnParamError = skipOnParamError;
|
|
node.parsingPriority = route.options?.skipRouteOnParseError?.priority ?? 0;
|
|
if (isLeaf && !node.route) {
|
|
node.route = route;
|
|
node.fullPath = route.fullPath ?? route.from;
|
|
}
|
|
}
|
|
if (route.children)
|
|
for (const child of route.children) {
|
|
parseSegments(
|
|
defaultCaseSensitive,
|
|
data,
|
|
child,
|
|
cursor,
|
|
node,
|
|
depth,
|
|
onRoute
|
|
);
|
|
}
|
|
}
|
|
function sortDynamic(a, b) {
|
|
if (a.skipOnParamError && !b.skipOnParamError) return -1;
|
|
if (!a.skipOnParamError && b.skipOnParamError) return 1;
|
|
if (a.skipOnParamError && b.skipOnParamError && (a.parsingPriority || b.parsingPriority))
|
|
return b.parsingPriority - a.parsingPriority;
|
|
if (a.prefix && b.prefix && a.prefix !== b.prefix) {
|
|
if (a.prefix.startsWith(b.prefix)) return -1;
|
|
if (b.prefix.startsWith(a.prefix)) return 1;
|
|
}
|
|
if (a.suffix && b.suffix && a.suffix !== b.suffix) {
|
|
if (a.suffix.endsWith(b.suffix)) return -1;
|
|
if (b.suffix.endsWith(a.suffix)) return 1;
|
|
}
|
|
if (a.prefix && !b.prefix) return -1;
|
|
if (!a.prefix && b.prefix) return 1;
|
|
if (a.suffix && !b.suffix) return -1;
|
|
if (!a.suffix && b.suffix) return 1;
|
|
if (a.caseSensitive && !b.caseSensitive) return -1;
|
|
if (!a.caseSensitive && b.caseSensitive) return 1;
|
|
return 0;
|
|
}
|
|
function sortTreeNodes(node) {
|
|
if (node.pathless) {
|
|
for (const child of node.pathless) {
|
|
sortTreeNodes(child);
|
|
}
|
|
}
|
|
if (node.static) {
|
|
for (const child of node.static.values()) {
|
|
sortTreeNodes(child);
|
|
}
|
|
}
|
|
if (node.staticInsensitive) {
|
|
for (const child of node.staticInsensitive.values()) {
|
|
sortTreeNodes(child);
|
|
}
|
|
}
|
|
if (node.dynamic?.length) {
|
|
node.dynamic.sort(sortDynamic);
|
|
for (const child of node.dynamic) {
|
|
sortTreeNodes(child);
|
|
}
|
|
}
|
|
if (node.optional?.length) {
|
|
node.optional.sort(sortDynamic);
|
|
for (const child of node.optional) {
|
|
sortTreeNodes(child);
|
|
}
|
|
}
|
|
if (node.wildcard?.length) {
|
|
node.wildcard.sort(sortDynamic);
|
|
for (const child of node.wildcard) {
|
|
sortTreeNodes(child);
|
|
}
|
|
}
|
|
}
|
|
function createStaticNode(fullPath) {
|
|
return {
|
|
kind: SEGMENT_TYPE_PATHNAME,
|
|
depth: 0,
|
|
pathless: null,
|
|
index: null,
|
|
static: null,
|
|
staticInsensitive: null,
|
|
dynamic: null,
|
|
optional: null,
|
|
wildcard: null,
|
|
route: null,
|
|
fullPath,
|
|
parent: null,
|
|
parse: null,
|
|
skipOnParamError: false,
|
|
parsingPriority: 0
|
|
};
|
|
}
|
|
function createDynamicNode(kind, fullPath, caseSensitive, prefix2, suffix) {
|
|
return {
|
|
kind,
|
|
depth: 0,
|
|
pathless: null,
|
|
index: null,
|
|
static: null,
|
|
staticInsensitive: null,
|
|
dynamic: null,
|
|
optional: null,
|
|
wildcard: null,
|
|
route: null,
|
|
fullPath,
|
|
parent: null,
|
|
parse: null,
|
|
skipOnParamError: false,
|
|
parsingPriority: 0,
|
|
caseSensitive,
|
|
prefix: prefix2,
|
|
suffix
|
|
};
|
|
}
|
|
function processRouteMasks(routeList, processedTree) {
|
|
const segmentTree = createStaticNode("/");
|
|
const data = new Uint16Array(6);
|
|
for (const route of routeList) {
|
|
parseSegments(false, data, route, 1, segmentTree, 0);
|
|
}
|
|
sortTreeNodes(segmentTree);
|
|
processedTree.masksTree = segmentTree;
|
|
processedTree.flatCache = createLRUCache(1e3);
|
|
}
|
|
function findFlatMatch(path, processedTree) {
|
|
path ||= "/";
|
|
const cached = processedTree.flatCache.get(path);
|
|
if (cached) return cached;
|
|
const result = findMatch(path, processedTree.masksTree);
|
|
processedTree.flatCache.set(path, result);
|
|
return result;
|
|
}
|
|
function findSingleMatch(from, caseSensitive, fuzzy, path, processedTree) {
|
|
from ||= "/";
|
|
path ||= "/";
|
|
const key = caseSensitive ? `case\0${from}` : from;
|
|
let tree = processedTree.singleCache.get(key);
|
|
if (!tree) {
|
|
tree = createStaticNode("/");
|
|
const data = new Uint16Array(6);
|
|
parseSegments(caseSensitive, data, { from }, 1, tree, 0);
|
|
processedTree.singleCache.set(key, tree);
|
|
}
|
|
return findMatch(path, tree, fuzzy);
|
|
}
|
|
function findRouteMatch(path, processedTree, fuzzy = false) {
|
|
const key = fuzzy ? path : `nofuzz\0${path}`;
|
|
const cached = processedTree.matchCache.get(key);
|
|
if (cached !== void 0) return cached;
|
|
path ||= "/";
|
|
let result;
|
|
try {
|
|
result = findMatch(
|
|
path,
|
|
processedTree.segmentTree,
|
|
fuzzy
|
|
);
|
|
} catch (err) {
|
|
if (err instanceof URIError) {
|
|
result = null;
|
|
} else {
|
|
throw err;
|
|
}
|
|
}
|
|
if (result) result.branch = buildRouteBranch(result.route);
|
|
processedTree.matchCache.set(key, result);
|
|
return result;
|
|
}
|
|
function trimPathRight(path) {
|
|
return path === "/" ? path : path.replace(/\/{1,}$/, "");
|
|
}
|
|
function processRouteTree(routeTree, caseSensitive = false, initRoute) {
|
|
const segmentTree = createStaticNode(routeTree.fullPath);
|
|
const data = new Uint16Array(6);
|
|
const routesById = {};
|
|
const routesByPath = {};
|
|
let index = 0;
|
|
parseSegments(caseSensitive, data, routeTree, 1, segmentTree, 0, (route) => {
|
|
initRoute?.(route, index);
|
|
invariant(
|
|
!(route.id in routesById),
|
|
`Duplicate routes found with id: ${String(route.id)}`
|
|
);
|
|
routesById[route.id] = route;
|
|
if (index !== 0 && route.path) {
|
|
const trimmedFullPath = trimPathRight(route.fullPath);
|
|
if (!routesByPath[trimmedFullPath] || route.fullPath.endsWith("/")) {
|
|
routesByPath[trimmedFullPath] = route;
|
|
}
|
|
}
|
|
index++;
|
|
});
|
|
sortTreeNodes(segmentTree);
|
|
const processedTree = {
|
|
segmentTree,
|
|
singleCache: createLRUCache(1e3),
|
|
matchCache: createLRUCache(1e3),
|
|
flatCache: null,
|
|
masksTree: null
|
|
};
|
|
return {
|
|
processedTree,
|
|
routesById,
|
|
routesByPath
|
|
};
|
|
}
|
|
function findMatch(path, segmentTree, fuzzy = false) {
|
|
const parts = path.split("/");
|
|
const leaf = getNodeMatch(path, parts, segmentTree, fuzzy);
|
|
if (!leaf) return null;
|
|
const [rawParams] = extractParams(path, parts, leaf);
|
|
return {
|
|
route: leaf.node.route,
|
|
rawParams,
|
|
parsedParams: leaf.parsedParams
|
|
};
|
|
}
|
|
function extractParams(path, parts, leaf) {
|
|
const list = buildBranch(leaf.node);
|
|
let nodeParts = null;
|
|
const rawParams = {};
|
|
let partIndex = leaf.extract?.part ?? 0;
|
|
let nodeIndex = leaf.extract?.node ?? 0;
|
|
let pathIndex = leaf.extract?.path ?? 0;
|
|
let segmentCount = leaf.extract?.segment ?? 0;
|
|
for (; nodeIndex < list.length; partIndex++, nodeIndex++, pathIndex++, segmentCount++) {
|
|
const node = list[nodeIndex];
|
|
if (node.kind === SEGMENT_TYPE_INDEX) break;
|
|
if (node.kind === SEGMENT_TYPE_PATHLESS) {
|
|
segmentCount--;
|
|
partIndex--;
|
|
pathIndex--;
|
|
continue;
|
|
}
|
|
const part = parts[partIndex];
|
|
const currentPathIndex = pathIndex;
|
|
if (part) pathIndex += part.length;
|
|
if (node.kind === SEGMENT_TYPE_PARAM) {
|
|
nodeParts ??= leaf.node.fullPath.split("/");
|
|
const nodePart = nodeParts[segmentCount];
|
|
const preLength = node.prefix?.length ?? 0;
|
|
const isCurlyBraced = nodePart.charCodeAt(preLength) === 123;
|
|
if (isCurlyBraced) {
|
|
const sufLength = node.suffix?.length ?? 0;
|
|
const name = nodePart.substring(
|
|
preLength + 2,
|
|
nodePart.length - sufLength - 1
|
|
);
|
|
const value = part.substring(preLength, part.length - sufLength);
|
|
rawParams[name] = decodeURIComponent(value);
|
|
} else {
|
|
const name = nodePart.substring(1);
|
|
rawParams[name] = decodeURIComponent(part);
|
|
}
|
|
} else if (node.kind === SEGMENT_TYPE_OPTIONAL_PARAM) {
|
|
if (leaf.skipped & 1 << nodeIndex) {
|
|
partIndex--;
|
|
pathIndex = currentPathIndex - 1;
|
|
continue;
|
|
}
|
|
nodeParts ??= leaf.node.fullPath.split("/");
|
|
const nodePart = nodeParts[segmentCount];
|
|
const preLength = node.prefix?.length ?? 0;
|
|
const sufLength = node.suffix?.length ?? 0;
|
|
const name = nodePart.substring(
|
|
preLength + 3,
|
|
nodePart.length - sufLength - 1
|
|
);
|
|
const value = node.suffix || node.prefix ? part.substring(preLength, part.length - sufLength) : part;
|
|
if (value) rawParams[name] = decodeURIComponent(value);
|
|
} else if (node.kind === SEGMENT_TYPE_WILDCARD) {
|
|
const n = node;
|
|
const value = path.substring(
|
|
currentPathIndex + (n.prefix?.length ?? 0),
|
|
path.length - (n.suffix?.length ?? 0)
|
|
);
|
|
const splat = decodeURIComponent(value);
|
|
rawParams["*"] = splat;
|
|
rawParams._splat = splat;
|
|
break;
|
|
}
|
|
}
|
|
if (leaf.rawParams) Object.assign(rawParams, leaf.rawParams);
|
|
return [
|
|
rawParams,
|
|
{
|
|
part: partIndex,
|
|
node: nodeIndex,
|
|
path: pathIndex,
|
|
segment: segmentCount
|
|
}
|
|
];
|
|
}
|
|
function buildRouteBranch(route) {
|
|
const list = [route];
|
|
while (route.parentRoute) {
|
|
route = route.parentRoute;
|
|
list.push(route);
|
|
}
|
|
list.reverse();
|
|
return list;
|
|
}
|
|
function buildBranch(node) {
|
|
const list = Array(node.depth + 1);
|
|
do {
|
|
list[node.depth] = node;
|
|
node = node.parent;
|
|
} while (node);
|
|
return list;
|
|
}
|
|
function getNodeMatch(path, parts, segmentTree, fuzzy) {
|
|
if (path === "/" && segmentTree.index)
|
|
return { node: segmentTree.index, skipped: 0 };
|
|
const trailingSlash = !last(parts);
|
|
const pathIsIndex = trailingSlash && path !== "/";
|
|
const partsLength = parts.length - (trailingSlash ? 1 : 0);
|
|
const stack = [
|
|
{
|
|
node: segmentTree,
|
|
index: 1,
|
|
skipped: 0,
|
|
depth: 1,
|
|
statics: 1,
|
|
dynamics: 0,
|
|
optionals: 0
|
|
}
|
|
];
|
|
let wildcardMatch = null;
|
|
let bestFuzzy = null;
|
|
let bestMatch = null;
|
|
while (stack.length) {
|
|
const frame = stack.pop();
|
|
const { node, index, skipped, depth, statics, dynamics, optionals } = frame;
|
|
let { extract, rawParams, parsedParams } = frame;
|
|
if (node.skipOnParamError) {
|
|
const result = validateMatchParams(path, parts, frame);
|
|
if (!result) continue;
|
|
rawParams = frame.rawParams;
|
|
extract = frame.extract;
|
|
parsedParams = frame.parsedParams;
|
|
}
|
|
if (fuzzy && node.route && node.kind !== SEGMENT_TYPE_INDEX && isFrameMoreSpecific(bestFuzzy, frame)) {
|
|
bestFuzzy = frame;
|
|
}
|
|
const isBeyondPath = index === partsLength;
|
|
if (isBeyondPath) {
|
|
if (node.route && !pathIsIndex && isFrameMoreSpecific(bestMatch, frame)) {
|
|
bestMatch = frame;
|
|
}
|
|
if (!node.optional && !node.wildcard && !node.index && !node.pathless)
|
|
continue;
|
|
}
|
|
const part = isBeyondPath ? void 0 : parts[index];
|
|
let lowerPart;
|
|
if (isBeyondPath && node.index) {
|
|
const indexFrame = {
|
|
node: node.index,
|
|
index,
|
|
skipped,
|
|
depth: depth + 1,
|
|
statics,
|
|
dynamics,
|
|
optionals,
|
|
extract,
|
|
rawParams,
|
|
parsedParams
|
|
};
|
|
let indexValid = true;
|
|
if (node.index.skipOnParamError) {
|
|
const result = validateMatchParams(path, parts, indexFrame);
|
|
if (!result) indexValid = false;
|
|
}
|
|
if (indexValid) {
|
|
if (statics === partsLength && !dynamics && !optionals && !skipped) {
|
|
return indexFrame;
|
|
}
|
|
if (isFrameMoreSpecific(bestMatch, indexFrame)) {
|
|
bestMatch = indexFrame;
|
|
}
|
|
}
|
|
}
|
|
if (node.wildcard && isFrameMoreSpecific(wildcardMatch, frame)) {
|
|
for (const segment of node.wildcard) {
|
|
const { prefix: prefix2, suffix } = segment;
|
|
if (prefix2) {
|
|
if (isBeyondPath) continue;
|
|
const casePart = segment.caseSensitive ? part : lowerPart ??= part.toLowerCase();
|
|
if (!casePart.startsWith(prefix2)) continue;
|
|
}
|
|
if (suffix) {
|
|
if (isBeyondPath) continue;
|
|
const end = parts.slice(index).join("/").slice(-suffix.length);
|
|
const casePart = segment.caseSensitive ? end : end.toLowerCase();
|
|
if (casePart !== suffix) continue;
|
|
}
|
|
const frame2 = {
|
|
node: segment,
|
|
index: partsLength,
|
|
skipped,
|
|
depth,
|
|
statics,
|
|
dynamics,
|
|
optionals,
|
|
extract,
|
|
rawParams,
|
|
parsedParams
|
|
};
|
|
if (segment.skipOnParamError) {
|
|
const result = validateMatchParams(path, parts, frame2);
|
|
if (!result) continue;
|
|
}
|
|
wildcardMatch = frame2;
|
|
break;
|
|
}
|
|
}
|
|
if (node.optional) {
|
|
const nextSkipped = skipped | 1 << depth;
|
|
const nextDepth = depth + 1;
|
|
for (let i = node.optional.length - 1; i >= 0; i--) {
|
|
const segment = node.optional[i];
|
|
stack.push({
|
|
node: segment,
|
|
index,
|
|
skipped: nextSkipped,
|
|
depth: nextDepth,
|
|
statics,
|
|
dynamics,
|
|
optionals,
|
|
extract,
|
|
rawParams,
|
|
parsedParams
|
|
});
|
|
}
|
|
if (!isBeyondPath) {
|
|
for (let i = node.optional.length - 1; i >= 0; i--) {
|
|
const segment = node.optional[i];
|
|
const { prefix: prefix2, suffix } = segment;
|
|
if (prefix2 || suffix) {
|
|
const casePart = segment.caseSensitive ? part : lowerPart ??= part.toLowerCase();
|
|
if (prefix2 && !casePart.startsWith(prefix2)) continue;
|
|
if (suffix && !casePart.endsWith(suffix)) continue;
|
|
}
|
|
stack.push({
|
|
node: segment,
|
|
index: index + 1,
|
|
skipped,
|
|
depth: nextDepth,
|
|
statics,
|
|
dynamics,
|
|
optionals: optionals + 1,
|
|
extract,
|
|
rawParams,
|
|
parsedParams
|
|
});
|
|
}
|
|
}
|
|
}
|
|
if (!isBeyondPath && node.dynamic && part) {
|
|
for (let i = node.dynamic.length - 1; i >= 0; i--) {
|
|
const segment = node.dynamic[i];
|
|
const { prefix: prefix2, suffix } = segment;
|
|
if (prefix2 || suffix) {
|
|
const casePart = segment.caseSensitive ? part : lowerPart ??= part.toLowerCase();
|
|
if (prefix2 && !casePart.startsWith(prefix2)) continue;
|
|
if (suffix && !casePart.endsWith(suffix)) continue;
|
|
}
|
|
stack.push({
|
|
node: segment,
|
|
index: index + 1,
|
|
skipped,
|
|
depth: depth + 1,
|
|
statics,
|
|
dynamics: dynamics + 1,
|
|
optionals,
|
|
extract,
|
|
rawParams,
|
|
parsedParams
|
|
});
|
|
}
|
|
}
|
|
if (!isBeyondPath && node.staticInsensitive) {
|
|
const match = node.staticInsensitive.get(
|
|
lowerPart ??= part.toLowerCase()
|
|
);
|
|
if (match) {
|
|
stack.push({
|
|
node: match,
|
|
index: index + 1,
|
|
skipped,
|
|
depth: depth + 1,
|
|
statics: statics + 1,
|
|
dynamics,
|
|
optionals,
|
|
extract,
|
|
rawParams,
|
|
parsedParams
|
|
});
|
|
}
|
|
}
|
|
if (!isBeyondPath && node.static) {
|
|
const match = node.static.get(part);
|
|
if (match) {
|
|
stack.push({
|
|
node: match,
|
|
index: index + 1,
|
|
skipped,
|
|
depth: depth + 1,
|
|
statics: statics + 1,
|
|
dynamics,
|
|
optionals,
|
|
extract,
|
|
rawParams,
|
|
parsedParams
|
|
});
|
|
}
|
|
}
|
|
if (node.pathless) {
|
|
const nextDepth = depth + 1;
|
|
for (let i = node.pathless.length - 1; i >= 0; i--) {
|
|
const segment = node.pathless[i];
|
|
stack.push({
|
|
node: segment,
|
|
index,
|
|
skipped,
|
|
depth: nextDepth,
|
|
statics,
|
|
dynamics,
|
|
optionals,
|
|
extract,
|
|
rawParams,
|
|
parsedParams
|
|
});
|
|
}
|
|
}
|
|
}
|
|
if (bestMatch && wildcardMatch) {
|
|
return isFrameMoreSpecific(wildcardMatch, bestMatch) ? bestMatch : wildcardMatch;
|
|
}
|
|
if (bestMatch) return bestMatch;
|
|
if (wildcardMatch) return wildcardMatch;
|
|
if (fuzzy && bestFuzzy) {
|
|
let sliceIndex = bestFuzzy.index;
|
|
for (let i = 0; i < bestFuzzy.index; i++) {
|
|
sliceIndex += parts[i].length;
|
|
}
|
|
const splat = sliceIndex === path.length ? "/" : path.slice(sliceIndex);
|
|
bestFuzzy.rawParams ??= {};
|
|
bestFuzzy.rawParams["**"] = decodeURIComponent(splat);
|
|
return bestFuzzy;
|
|
}
|
|
return null;
|
|
}
|
|
function validateMatchParams(path, parts, frame) {
|
|
try {
|
|
const [rawParams, state] = extractParams(path, parts, frame);
|
|
frame.rawParams = rawParams;
|
|
frame.extract = state;
|
|
const parsed = frame.node.parse(rawParams);
|
|
frame.parsedParams = Object.assign({}, frame.parsedParams, parsed);
|
|
return true;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
function isFrameMoreSpecific(prev, next) {
|
|
if (!prev) return true;
|
|
return next.statics > prev.statics || next.statics === prev.statics && (next.dynamics > prev.dynamics || next.dynamics === prev.dynamics && (next.optionals > prev.optionals || next.optionals === prev.optionals && ((next.node.kind === SEGMENT_TYPE_INDEX) > (prev.node.kind === SEGMENT_TYPE_INDEX) || next.node.kind === SEGMENT_TYPE_INDEX === (prev.node.kind === SEGMENT_TYPE_INDEX) && next.depth > prev.depth)));
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/path.js
|
|
function joinPaths(paths) {
|
|
return cleanPath(
|
|
paths.filter((val) => {
|
|
return val !== void 0;
|
|
}).join("/")
|
|
);
|
|
}
|
|
function cleanPath(path) {
|
|
return path.replace(/\/{2,}/g, "/");
|
|
}
|
|
function trimPathLeft(path) {
|
|
return path === "/" ? path : path.replace(/^\/{1,}/, "");
|
|
}
|
|
function trimPathRight2(path) {
|
|
const len = path.length;
|
|
return len > 1 && path[len - 1] === "/" ? path.replace(/\/{1,}$/, "") : path;
|
|
}
|
|
function trimPath(path) {
|
|
return trimPathRight2(trimPathLeft(path));
|
|
}
|
|
function removeTrailingSlash(value, basepath) {
|
|
if (value?.endsWith("/") && value !== "/" && value !== `${basepath}/`) {
|
|
return value.slice(0, -1);
|
|
}
|
|
return value;
|
|
}
|
|
function exactPathTest(pathName1, pathName2, basepath) {
|
|
return removeTrailingSlash(pathName1, basepath) === removeTrailingSlash(pathName2, basepath);
|
|
}
|
|
function resolvePath({
|
|
base,
|
|
to,
|
|
trailingSlash = "never",
|
|
cache
|
|
}) {
|
|
const isAbsolute = to.startsWith("/");
|
|
const isBase = !isAbsolute && to === ".";
|
|
let key;
|
|
if (cache) {
|
|
key = isAbsolute ? to : isBase ? base : base + "\0" + to;
|
|
const cached = cache.get(key);
|
|
if (cached) return cached;
|
|
}
|
|
let baseSegments;
|
|
if (isBase) {
|
|
baseSegments = base.split("/");
|
|
} else if (isAbsolute) {
|
|
baseSegments = to.split("/");
|
|
} else {
|
|
baseSegments = base.split("/");
|
|
while (baseSegments.length > 1 && last(baseSegments) === "") {
|
|
baseSegments.pop();
|
|
}
|
|
const toSegments = to.split("/");
|
|
for (let index = 0, length = toSegments.length; index < length; index++) {
|
|
const value = toSegments[index];
|
|
if (value === "") {
|
|
if (!index) {
|
|
baseSegments = [value];
|
|
} else if (index === length - 1) {
|
|
baseSegments.push(value);
|
|
} else ;
|
|
} else if (value === "..") {
|
|
baseSegments.pop();
|
|
} else if (value === ".") ;
|
|
else {
|
|
baseSegments.push(value);
|
|
}
|
|
}
|
|
}
|
|
if (baseSegments.length > 1) {
|
|
if (last(baseSegments) === "") {
|
|
if (trailingSlash === "never") {
|
|
baseSegments.pop();
|
|
}
|
|
} else if (trailingSlash === "always") {
|
|
baseSegments.push("");
|
|
}
|
|
}
|
|
let segment;
|
|
let joined = "";
|
|
for (let i = 0; i < baseSegments.length; i++) {
|
|
if (i > 0) joined += "/";
|
|
const part = baseSegments[i];
|
|
if (!part) continue;
|
|
segment = parseSegment(part, 0, segment);
|
|
const kind = segment[0];
|
|
if (kind === SEGMENT_TYPE_PATHNAME) {
|
|
joined += part;
|
|
continue;
|
|
}
|
|
const end = segment[5];
|
|
const prefix2 = part.substring(0, segment[1]);
|
|
const suffix = part.substring(segment[4], end);
|
|
const value = part.substring(segment[2], segment[3]);
|
|
if (kind === SEGMENT_TYPE_PARAM) {
|
|
joined += prefix2 || suffix ? `${prefix2}{$${value}}${suffix}` : `$${value}`;
|
|
} else if (kind === SEGMENT_TYPE_WILDCARD) {
|
|
joined += prefix2 || suffix ? `${prefix2}{$}${suffix}` : "$";
|
|
} else {
|
|
joined += `${prefix2}{-$${value}}${suffix}`;
|
|
}
|
|
}
|
|
joined = cleanPath(joined);
|
|
const result = joined || "/";
|
|
if (key && cache) cache.set(key, result);
|
|
return result;
|
|
}
|
|
function compileDecodeCharMap(pathParamsAllowedCharacters) {
|
|
const charMap = new Map(
|
|
pathParamsAllowedCharacters.map((char) => [encodeURIComponent(char), char])
|
|
);
|
|
const pattern = Array.from(charMap.keys()).map((key) => key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
const regex = new RegExp(pattern, "g");
|
|
return (encoded) => encoded.replace(regex, (match) => charMap.get(match) ?? match);
|
|
}
|
|
function encodeParam(key, params, decoder) {
|
|
const value = params[key];
|
|
if (typeof value !== "string") return value;
|
|
if (key === "_splat") {
|
|
if (/^[a-zA-Z0-9\-._~!/]*$/.test(value)) return value;
|
|
return value.split("/").map((segment) => encodePathParam(segment, decoder)).join("/");
|
|
} else {
|
|
return encodePathParam(value, decoder);
|
|
}
|
|
}
|
|
function interpolatePath({
|
|
path,
|
|
params,
|
|
decoder,
|
|
// `server` is marked @internal and stripped from .d.ts by `stripInternal`.
|
|
// We avoid destructuring it in the function signature so the emitted
|
|
// declaration doesn't reference a property that no longer exists.
|
|
...rest
|
|
}) {
|
|
let isMissingParams = false;
|
|
const usedParams = {};
|
|
if (!path || path === "/")
|
|
return { interpolatedPath: "/", usedParams, isMissingParams };
|
|
if (!path.includes("$"))
|
|
return { interpolatedPath: path, usedParams, isMissingParams };
|
|
if (isServer ?? rest.server) {
|
|
if (path.indexOf("{") === -1) {
|
|
const length2 = path.length;
|
|
let cursor2 = 0;
|
|
let joined2 = "";
|
|
while (cursor2 < length2) {
|
|
while (cursor2 < length2 && path.charCodeAt(cursor2) === 47) cursor2++;
|
|
if (cursor2 >= length2) break;
|
|
const start = cursor2;
|
|
let end = path.indexOf("/", cursor2);
|
|
if (end === -1) end = length2;
|
|
cursor2 = end;
|
|
const part = path.substring(start, end);
|
|
if (!part) continue;
|
|
if (part.charCodeAt(0) === 36) {
|
|
if (part.length === 1) {
|
|
const splat = params._splat;
|
|
usedParams._splat = splat;
|
|
usedParams["*"] = splat;
|
|
if (!splat) {
|
|
isMissingParams = true;
|
|
continue;
|
|
}
|
|
const value = encodeParam("_splat", params, decoder);
|
|
joined2 += "/" + value;
|
|
} else {
|
|
const key = part.substring(1);
|
|
if (!isMissingParams && !(key in params)) {
|
|
isMissingParams = true;
|
|
}
|
|
usedParams[key] = params[key];
|
|
const value = encodeParam(key, params, decoder) ?? "undefined";
|
|
joined2 += "/" + value;
|
|
}
|
|
} else {
|
|
joined2 += "/" + part;
|
|
}
|
|
}
|
|
if (path.endsWith("/")) joined2 += "/";
|
|
const interpolatedPath2 = joined2 || "/";
|
|
return { usedParams, interpolatedPath: interpolatedPath2, isMissingParams };
|
|
}
|
|
}
|
|
const length = path.length;
|
|
let cursor = 0;
|
|
let segment;
|
|
let joined = "";
|
|
while (cursor < length) {
|
|
const start = cursor;
|
|
segment = parseSegment(path, start, segment);
|
|
const end = segment[5];
|
|
cursor = end + 1;
|
|
if (start === end) continue;
|
|
const kind = segment[0];
|
|
if (kind === SEGMENT_TYPE_PATHNAME) {
|
|
joined += "/" + path.substring(start, end);
|
|
continue;
|
|
}
|
|
if (kind === SEGMENT_TYPE_WILDCARD) {
|
|
const splat = params._splat;
|
|
usedParams._splat = splat;
|
|
usedParams["*"] = splat;
|
|
const prefix2 = path.substring(start, segment[1]);
|
|
const suffix = path.substring(segment[4], end);
|
|
if (!splat) {
|
|
isMissingParams = true;
|
|
if (prefix2 || suffix) {
|
|
joined += "/" + prefix2 + suffix;
|
|
}
|
|
continue;
|
|
}
|
|
const value = encodeParam("_splat", params, decoder);
|
|
joined += "/" + prefix2 + value + suffix;
|
|
continue;
|
|
}
|
|
if (kind === SEGMENT_TYPE_PARAM) {
|
|
const key = path.substring(segment[2], segment[3]);
|
|
if (!isMissingParams && !(key in params)) {
|
|
isMissingParams = true;
|
|
}
|
|
usedParams[key] = params[key];
|
|
const prefix2 = path.substring(start, segment[1]);
|
|
const suffix = path.substring(segment[4], end);
|
|
const value = encodeParam(key, params, decoder) ?? "undefined";
|
|
joined += "/" + prefix2 + value + suffix;
|
|
continue;
|
|
}
|
|
if (kind === SEGMENT_TYPE_OPTIONAL_PARAM) {
|
|
const key = path.substring(segment[2], segment[3]);
|
|
const valueRaw = params[key];
|
|
if (valueRaw == null) continue;
|
|
usedParams[key] = valueRaw;
|
|
const prefix2 = path.substring(start, segment[1]);
|
|
const suffix = path.substring(segment[4], end);
|
|
const value = encodeParam(key, params, decoder) ?? "";
|
|
joined += "/" + prefix2 + value + suffix;
|
|
continue;
|
|
}
|
|
}
|
|
if (path.endsWith("/")) joined += "/";
|
|
const interpolatedPath = joined || "/";
|
|
return { usedParams, interpolatedPath, isMissingParams };
|
|
}
|
|
function encodePathParam(value, decoder) {
|
|
const encoded = encodeURIComponent(value);
|
|
return decoder?.(encoded) ?? encoded;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/not-found.js
|
|
function notFound(options = {}) {
|
|
options.isNotFound = true;
|
|
if (options.throw) throw options;
|
|
return options;
|
|
}
|
|
function isNotFound(obj) {
|
|
return !!obj?.isNotFound;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/scroll-restoration.js
|
|
function getSafeSessionStorage() {
|
|
try {
|
|
if (typeof window !== "undefined" && typeof window.sessionStorage === "object") {
|
|
return window.sessionStorage;
|
|
}
|
|
} catch {
|
|
}
|
|
return void 0;
|
|
}
|
|
var storageKey = "tsr-scroll-restoration-v1_3";
|
|
var throttle = (fn, wait) => {
|
|
let timeout;
|
|
return (...args) => {
|
|
if (!timeout) {
|
|
timeout = setTimeout(() => {
|
|
fn(...args);
|
|
timeout = null;
|
|
}, wait);
|
|
}
|
|
};
|
|
};
|
|
function createScrollRestorationCache() {
|
|
const safeSessionStorage = getSafeSessionStorage();
|
|
if (!safeSessionStorage) {
|
|
return null;
|
|
}
|
|
const persistedState = safeSessionStorage.getItem(storageKey);
|
|
let state = persistedState ? JSON.parse(persistedState) : {};
|
|
return {
|
|
state,
|
|
// This setter is simply to make sure that we set the sessionStorage right
|
|
// after the state is updated. It doesn't necessarily need to be a functional
|
|
// update.
|
|
set: (updater) => {
|
|
state = functionalUpdate(updater, state) || state;
|
|
try {
|
|
safeSessionStorage.setItem(storageKey, JSON.stringify(state));
|
|
} catch {
|
|
console.warn(
|
|
"[ts-router] Could not persist scroll restoration state to sessionStorage."
|
|
);
|
|
}
|
|
}
|
|
};
|
|
}
|
|
var scrollRestorationCache = createScrollRestorationCache();
|
|
var defaultGetScrollRestorationKey = (location) => {
|
|
return location.state.__TSR_key || location.href;
|
|
};
|
|
function getCssSelector(el) {
|
|
const path = [];
|
|
let parent;
|
|
while (parent = el.parentNode) {
|
|
path.push(
|
|
`${el.tagName}:nth-child(${Array.prototype.indexOf.call(parent.children, el) + 1})`
|
|
);
|
|
el = parent;
|
|
}
|
|
return `${path.reverse().join(" > ")}`.toLowerCase();
|
|
}
|
|
var ignoreScroll = false;
|
|
function restoreScroll({
|
|
storageKey: storageKey2,
|
|
key,
|
|
behavior,
|
|
shouldScrollRestoration,
|
|
scrollToTopSelectors,
|
|
location
|
|
}) {
|
|
let byKey;
|
|
try {
|
|
byKey = JSON.parse(sessionStorage.getItem(storageKey2) || "{}");
|
|
} catch (error) {
|
|
console.error(error);
|
|
return;
|
|
}
|
|
const resolvedKey = key || window.history.state?.__TSR_key;
|
|
const elementEntries = byKey[resolvedKey];
|
|
ignoreScroll = true;
|
|
scroll: {
|
|
if (shouldScrollRestoration && elementEntries && Object.keys(elementEntries).length > 0) {
|
|
for (const elementSelector in elementEntries) {
|
|
const entry = elementEntries[elementSelector];
|
|
if (elementSelector === "window") {
|
|
window.scrollTo({
|
|
top: entry.scrollY,
|
|
left: entry.scrollX,
|
|
behavior
|
|
});
|
|
} else if (elementSelector) {
|
|
const element = document.querySelector(elementSelector);
|
|
if (element) {
|
|
element.scrollLeft = entry.scrollX;
|
|
element.scrollTop = entry.scrollY;
|
|
}
|
|
}
|
|
}
|
|
break scroll;
|
|
}
|
|
const hash = (location ?? window.location).hash.split("#", 2)[1];
|
|
if (hash) {
|
|
const hashScrollIntoViewOptions = window.history.state?.__hashScrollIntoViewOptions ?? true;
|
|
if (hashScrollIntoViewOptions) {
|
|
const el = document.getElementById(hash);
|
|
if (el) {
|
|
el.scrollIntoView(hashScrollIntoViewOptions);
|
|
}
|
|
}
|
|
break scroll;
|
|
}
|
|
const scrollOptions = { top: 0, left: 0, behavior };
|
|
window.scrollTo(scrollOptions);
|
|
if (scrollToTopSelectors) {
|
|
for (const selector of scrollToTopSelectors) {
|
|
if (selector === "window") continue;
|
|
const element = typeof selector === "function" ? selector() : document.querySelector(selector);
|
|
if (element) element.scrollTo(scrollOptions);
|
|
}
|
|
}
|
|
}
|
|
ignoreScroll = false;
|
|
}
|
|
function setupScrollRestoration(router, force) {
|
|
if (!scrollRestorationCache && !(isServer ?? router.isServer)) {
|
|
return;
|
|
}
|
|
const shouldScrollRestoration = force ?? router.options.scrollRestoration ?? false;
|
|
if (shouldScrollRestoration) {
|
|
router.isScrollRestoring = true;
|
|
}
|
|
if ((isServer ?? router.isServer) || router.isScrollRestorationSetup || !scrollRestorationCache) {
|
|
return;
|
|
}
|
|
router.isScrollRestorationSetup = true;
|
|
ignoreScroll = false;
|
|
const getKey = router.options.getScrollRestorationKey || defaultGetScrollRestorationKey;
|
|
window.history.scrollRestoration = "manual";
|
|
const onScroll = (event) => {
|
|
if (ignoreScroll || !router.isScrollRestoring) {
|
|
return;
|
|
}
|
|
let elementSelector = "";
|
|
if (event.target === document || event.target === window) {
|
|
elementSelector = "window";
|
|
} else {
|
|
const attrId = event.target.getAttribute(
|
|
"data-scroll-restoration-id"
|
|
);
|
|
if (attrId) {
|
|
elementSelector = `[data-scroll-restoration-id="${attrId}"]`;
|
|
} else {
|
|
elementSelector = getCssSelector(event.target);
|
|
}
|
|
}
|
|
const restoreKey = getKey(router.state.location);
|
|
scrollRestorationCache.set((state) => {
|
|
const keyEntry = state[restoreKey] ||= {};
|
|
const elementEntry = keyEntry[elementSelector] ||= {};
|
|
if (elementSelector === "window") {
|
|
elementEntry.scrollX = window.scrollX || 0;
|
|
elementEntry.scrollY = window.scrollY || 0;
|
|
} else if (elementSelector) {
|
|
const element = document.querySelector(elementSelector);
|
|
if (element) {
|
|
elementEntry.scrollX = element.scrollLeft || 0;
|
|
elementEntry.scrollY = element.scrollTop || 0;
|
|
}
|
|
}
|
|
return state;
|
|
});
|
|
};
|
|
if (typeof document !== "undefined") {
|
|
document.addEventListener("scroll", throttle(onScroll, 100), true);
|
|
}
|
|
router.subscribe("onRendered", (event) => {
|
|
const cacheKey = getKey(event.toLocation);
|
|
if (!router.resetNextScroll) {
|
|
router.resetNextScroll = true;
|
|
return;
|
|
}
|
|
if (typeof router.options.scrollRestoration === "function") {
|
|
const shouldRestore = router.options.scrollRestoration({
|
|
location: router.latestLocation
|
|
});
|
|
if (!shouldRestore) {
|
|
return;
|
|
}
|
|
}
|
|
restoreScroll({
|
|
storageKey,
|
|
key: cacheKey,
|
|
behavior: router.options.scrollRestorationBehavior,
|
|
shouldScrollRestoration: router.isScrollRestoring,
|
|
scrollToTopSelectors: router.options.scrollToTopSelectors,
|
|
location: router.history.location
|
|
});
|
|
if (router.isScrollRestoring) {
|
|
scrollRestorationCache.set((state) => {
|
|
state[cacheKey] ||= {};
|
|
return state;
|
|
});
|
|
}
|
|
});
|
|
}
|
|
function handleHashScroll(router) {
|
|
if (typeof document !== "undefined" && document.querySelector) {
|
|
const hashScrollIntoViewOptions = router.state.location.state.__hashScrollIntoViewOptions ?? true;
|
|
if (hashScrollIntoViewOptions && router.state.location.hash !== "") {
|
|
const el = document.getElementById(router.state.location.hash);
|
|
if (el) {
|
|
el.scrollIntoView(hashScrollIntoViewOptions);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/qss.js
|
|
function encode(obj, stringify = String) {
|
|
const result = new URLSearchParams();
|
|
for (const key in obj) {
|
|
const val = obj[key];
|
|
if (val !== void 0) {
|
|
result.set(key, stringify(val));
|
|
}
|
|
}
|
|
return result.toString();
|
|
}
|
|
function toValue(str) {
|
|
if (!str) return "";
|
|
if (str === "false") return false;
|
|
if (str === "true") return true;
|
|
return +str * 0 === 0 && +str + "" === str ? +str : str;
|
|
}
|
|
function decode(str) {
|
|
const searchParams = new URLSearchParams(str);
|
|
const result = {};
|
|
for (const [key, value] of searchParams.entries()) {
|
|
const previousValue = result[key];
|
|
if (previousValue == null) {
|
|
result[key] = toValue(value);
|
|
} else if (Array.isArray(previousValue)) {
|
|
previousValue.push(toValue(value));
|
|
} else {
|
|
result[key] = [previousValue, toValue(value)];
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/searchParams.js
|
|
var defaultParseSearch = parseSearchWith(JSON.parse);
|
|
var defaultStringifySearch = stringifySearchWith(
|
|
JSON.stringify,
|
|
JSON.parse
|
|
);
|
|
function parseSearchWith(parser) {
|
|
return (searchStr) => {
|
|
if (searchStr[0] === "?") {
|
|
searchStr = searchStr.substring(1);
|
|
}
|
|
const query = decode(searchStr);
|
|
for (const key in query) {
|
|
const value = query[key];
|
|
if (typeof value === "string") {
|
|
try {
|
|
query[key] = parser(value);
|
|
} catch (_err) {
|
|
}
|
|
}
|
|
}
|
|
return query;
|
|
};
|
|
}
|
|
function stringifySearchWith(stringify, parser) {
|
|
const hasParser = typeof parser === "function";
|
|
function stringifyValue(val) {
|
|
if (typeof val === "object" && val !== null) {
|
|
try {
|
|
return stringify(val);
|
|
} catch (_err) {
|
|
}
|
|
} else if (hasParser && typeof val === "string") {
|
|
try {
|
|
parser(val);
|
|
return stringify(val);
|
|
} catch (_err) {
|
|
}
|
|
}
|
|
return val;
|
|
}
|
|
return (search) => {
|
|
const searchStr = encode(search, stringifyValue);
|
|
return searchStr ? `?${searchStr}` : "";
|
|
};
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/root.js
|
|
var rootRouteId = "__root__";
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/redirect.js
|
|
function redirect(opts) {
|
|
opts.statusCode = opts.statusCode || opts.code || 307;
|
|
if (!opts._builtLocation && !opts.reloadDocument && typeof opts.href === "string") {
|
|
try {
|
|
new URL(opts.href);
|
|
opts.reloadDocument = true;
|
|
} catch {
|
|
}
|
|
}
|
|
const headers = new Headers(opts.headers);
|
|
if (opts.href && headers.get("Location") === null) {
|
|
headers.set("Location", opts.href);
|
|
}
|
|
const response = new Response(null, {
|
|
status: opts.statusCode,
|
|
headers
|
|
});
|
|
response.options = opts;
|
|
if (opts.throw) {
|
|
throw response;
|
|
}
|
|
return response;
|
|
}
|
|
function isRedirect(obj) {
|
|
return obj instanceof Response && !!obj.options;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/load-matches.js
|
|
var triggerOnReady = (inner) => {
|
|
if (!inner.rendered) {
|
|
inner.rendered = true;
|
|
return inner.onReady?.();
|
|
}
|
|
};
|
|
var resolvePreload = (inner, matchId) => {
|
|
return !!(inner.preload && !inner.router.state.matches.some((d) => d.id === matchId));
|
|
};
|
|
var buildMatchContext = (inner, index, includeCurrentMatch = true) => {
|
|
const context = {
|
|
...inner.router.options.context ?? {}
|
|
};
|
|
const end = includeCurrentMatch ? index : index - 1;
|
|
for (let i = 0; i <= end; i++) {
|
|
const innerMatch = inner.matches[i];
|
|
if (!innerMatch) continue;
|
|
const m = inner.router.getMatch(innerMatch.id);
|
|
if (!m) continue;
|
|
Object.assign(context, m.__routeContext, m.__beforeLoadContext);
|
|
}
|
|
return context;
|
|
};
|
|
var getNotFoundBoundaryIndex = (inner, err) => {
|
|
if (!inner.matches.length) {
|
|
return void 0;
|
|
}
|
|
const requestedRouteId = err.routeId;
|
|
const matchedRootIndex = inner.matches.findIndex(
|
|
(m) => m.routeId === inner.router.routeTree.id
|
|
);
|
|
const rootIndex = matchedRootIndex >= 0 ? matchedRootIndex : 0;
|
|
let startIndex = requestedRouteId ? inner.matches.findIndex((match) => match.routeId === requestedRouteId) : inner.firstBadMatchIndex ?? inner.matches.length - 1;
|
|
if (startIndex < 0) {
|
|
startIndex = rootIndex;
|
|
}
|
|
for (let i = startIndex; i >= 0; i--) {
|
|
const match = inner.matches[i];
|
|
const route = inner.router.looseRoutesById[match.routeId];
|
|
if (route.options.notFoundComponent) {
|
|
return i;
|
|
}
|
|
}
|
|
return requestedRouteId ? startIndex : rootIndex;
|
|
};
|
|
var handleRedirectAndNotFound = (inner, match, err) => {
|
|
if (!isRedirect(err) && !isNotFound(err)) return;
|
|
if (isRedirect(err) && err.redirectHandled && !err.options.reloadDocument) {
|
|
throw err;
|
|
}
|
|
if (match) {
|
|
match._nonReactive.beforeLoadPromise?.resolve();
|
|
match._nonReactive.loaderPromise?.resolve();
|
|
match._nonReactive.beforeLoadPromise = void 0;
|
|
match._nonReactive.loaderPromise = void 0;
|
|
match._nonReactive.error = err;
|
|
inner.updateMatch(match.id, (prev) => ({
|
|
...prev,
|
|
status: isRedirect(err) ? "redirected" : prev.status === "pending" ? "success" : prev.status,
|
|
context: buildMatchContext(inner, match.index),
|
|
isFetching: false,
|
|
error: err
|
|
}));
|
|
if (isNotFound(err) && !err.routeId) {
|
|
err.routeId = match.routeId;
|
|
}
|
|
match._nonReactive.loadPromise?.resolve();
|
|
}
|
|
if (isRedirect(err)) {
|
|
inner.rendered = true;
|
|
err.options._fromLocation = inner.location;
|
|
err.redirectHandled = true;
|
|
err = inner.router.resolveRedirect(err);
|
|
}
|
|
throw err;
|
|
};
|
|
var shouldSkipLoader = (inner, matchId) => {
|
|
const match = inner.router.getMatch(matchId);
|
|
if (!match) {
|
|
return true;
|
|
}
|
|
if (!(isServer ?? inner.router.isServer) && match._nonReactive.dehydrated) {
|
|
return true;
|
|
}
|
|
if ((isServer ?? inner.router.isServer) && match.ssr === false) {
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
var syncMatchContext = (inner, matchId, index) => {
|
|
const nextContext = buildMatchContext(inner, index);
|
|
inner.updateMatch(matchId, (prev) => {
|
|
return {
|
|
...prev,
|
|
context: nextContext
|
|
};
|
|
});
|
|
};
|
|
var handleSerialError = (inner, index, err, routerCode) => {
|
|
const { id: matchId, routeId } = inner.matches[index];
|
|
const route = inner.router.looseRoutesById[routeId];
|
|
if (err instanceof Promise) {
|
|
throw err;
|
|
}
|
|
err.routerCode = routerCode;
|
|
inner.firstBadMatchIndex ??= index;
|
|
handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err);
|
|
try {
|
|
route.options.onError?.(err);
|
|
} catch (errorHandlerErr) {
|
|
err = errorHandlerErr;
|
|
handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err);
|
|
}
|
|
inner.updateMatch(matchId, (prev) => {
|
|
prev._nonReactive.beforeLoadPromise?.resolve();
|
|
prev._nonReactive.beforeLoadPromise = void 0;
|
|
prev._nonReactive.loadPromise?.resolve();
|
|
return {
|
|
...prev,
|
|
error: err,
|
|
status: "error",
|
|
isFetching: false,
|
|
updatedAt: Date.now(),
|
|
abortController: new AbortController()
|
|
};
|
|
});
|
|
if (!inner.preload && !isRedirect(err) && !isNotFound(err)) {
|
|
inner.serialError ??= err;
|
|
}
|
|
};
|
|
var isBeforeLoadSsr = (inner, matchId, index, route) => {
|
|
const existingMatch = inner.router.getMatch(matchId);
|
|
const parentMatchId = inner.matches[index - 1]?.id;
|
|
const parentMatch = parentMatchId ? inner.router.getMatch(parentMatchId) : void 0;
|
|
if (inner.router.isShell()) {
|
|
existingMatch.ssr = route.id === rootRouteId;
|
|
return;
|
|
}
|
|
if (parentMatch?.ssr === false) {
|
|
existingMatch.ssr = false;
|
|
return;
|
|
}
|
|
const parentOverride = (tempSsr2) => {
|
|
if (tempSsr2 === true && parentMatch?.ssr === "data-only") {
|
|
return "data-only";
|
|
}
|
|
return tempSsr2;
|
|
};
|
|
const defaultSsr = inner.router.options.defaultSsr ?? true;
|
|
if (route.options.ssr === void 0) {
|
|
existingMatch.ssr = parentOverride(defaultSsr);
|
|
return;
|
|
}
|
|
if (typeof route.options.ssr !== "function") {
|
|
existingMatch.ssr = parentOverride(route.options.ssr);
|
|
return;
|
|
}
|
|
const { search, params } = existingMatch;
|
|
const ssrFnContext = {
|
|
search: makeMaybe(search, existingMatch.searchError),
|
|
params: makeMaybe(params, existingMatch.paramsError),
|
|
location: inner.location,
|
|
matches: inner.matches.map((match) => ({
|
|
index: match.index,
|
|
pathname: match.pathname,
|
|
fullPath: match.fullPath,
|
|
staticData: match.staticData,
|
|
id: match.id,
|
|
routeId: match.routeId,
|
|
search: makeMaybe(match.search, match.searchError),
|
|
params: makeMaybe(match.params, match.paramsError),
|
|
ssr: match.ssr
|
|
}))
|
|
};
|
|
const tempSsr = route.options.ssr(ssrFnContext);
|
|
if (isPromise(tempSsr)) {
|
|
return tempSsr.then((ssr) => {
|
|
existingMatch.ssr = parentOverride(ssr ?? defaultSsr);
|
|
});
|
|
}
|
|
existingMatch.ssr = parentOverride(tempSsr ?? defaultSsr);
|
|
return;
|
|
};
|
|
var setupPendingTimeout = (inner, matchId, route, match) => {
|
|
if (match._nonReactive.pendingTimeout !== void 0) return;
|
|
const pendingMs = route.options.pendingMs ?? inner.router.options.defaultPendingMs;
|
|
const shouldPending = !!(inner.onReady && !(isServer ?? inner.router.isServer) && !resolvePreload(inner, matchId) && (route.options.loader || route.options.beforeLoad || routeNeedsPreload(route)) && typeof pendingMs === "number" && pendingMs !== Infinity && (route.options.pendingComponent ?? inner.router.options?.defaultPendingComponent));
|
|
if (shouldPending) {
|
|
const pendingTimeout = setTimeout(() => {
|
|
triggerOnReady(inner);
|
|
}, pendingMs);
|
|
match._nonReactive.pendingTimeout = pendingTimeout;
|
|
}
|
|
};
|
|
var preBeforeLoadSetup = (inner, matchId, route) => {
|
|
const existingMatch = inner.router.getMatch(matchId);
|
|
if (!existingMatch._nonReactive.beforeLoadPromise && !existingMatch._nonReactive.loaderPromise)
|
|
return;
|
|
setupPendingTimeout(inner, matchId, route, existingMatch);
|
|
const then = () => {
|
|
const match = inner.router.getMatch(matchId);
|
|
if (match.preload && (match.status === "redirected" || match.status === "notFound")) {
|
|
handleRedirectAndNotFound(inner, match, match.error);
|
|
}
|
|
};
|
|
return existingMatch._nonReactive.beforeLoadPromise ? existingMatch._nonReactive.beforeLoadPromise.then(then) : then();
|
|
};
|
|
var executeBeforeLoad = (inner, matchId, index, route) => {
|
|
const match = inner.router.getMatch(matchId);
|
|
const prevLoadPromise = match._nonReactive.loadPromise;
|
|
match._nonReactive.loadPromise = createControlledPromise(() => {
|
|
prevLoadPromise?.resolve();
|
|
});
|
|
const { paramsError, searchError } = match;
|
|
if (paramsError) {
|
|
handleSerialError(inner, index, paramsError, "PARSE_PARAMS");
|
|
}
|
|
if (searchError) {
|
|
handleSerialError(inner, index, searchError, "VALIDATE_SEARCH");
|
|
}
|
|
setupPendingTimeout(inner, matchId, route, match);
|
|
const abortController = new AbortController();
|
|
let isPending = false;
|
|
const pending = () => {
|
|
if (isPending) return;
|
|
isPending = true;
|
|
inner.updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
isFetching: "beforeLoad",
|
|
fetchCount: prev.fetchCount + 1,
|
|
abortController
|
|
// Note: We intentionally don't update context here.
|
|
// Context should only be updated after beforeLoad resolves to avoid
|
|
// components seeing incomplete context during async beforeLoad execution.
|
|
}));
|
|
};
|
|
const resolve = () => {
|
|
match._nonReactive.beforeLoadPromise?.resolve();
|
|
match._nonReactive.beforeLoadPromise = void 0;
|
|
inner.updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
isFetching: false
|
|
}));
|
|
};
|
|
if (!route.options.beforeLoad) {
|
|
batch2(() => {
|
|
pending();
|
|
resolve();
|
|
});
|
|
return;
|
|
}
|
|
match._nonReactive.beforeLoadPromise = createControlledPromise();
|
|
const context = {
|
|
...buildMatchContext(inner, index, false),
|
|
...match.__routeContext
|
|
};
|
|
const { search, params, cause } = match;
|
|
const preload = resolvePreload(inner, matchId);
|
|
const beforeLoadFnContext = {
|
|
search,
|
|
abortController,
|
|
params,
|
|
preload,
|
|
context,
|
|
location: inner.location,
|
|
navigate: (opts) => inner.router.navigate({
|
|
...opts,
|
|
_fromLocation: inner.location
|
|
}),
|
|
buildLocation: inner.router.buildLocation,
|
|
cause: preload ? "preload" : cause,
|
|
matches: inner.matches,
|
|
routeId: route.id,
|
|
...inner.router.options.additionalContext
|
|
};
|
|
const updateContext = (beforeLoadContext2) => {
|
|
if (beforeLoadContext2 === void 0) {
|
|
batch2(() => {
|
|
pending();
|
|
resolve();
|
|
});
|
|
return;
|
|
}
|
|
if (isRedirect(beforeLoadContext2) || isNotFound(beforeLoadContext2)) {
|
|
pending();
|
|
handleSerialError(inner, index, beforeLoadContext2, "BEFORE_LOAD");
|
|
}
|
|
batch2(() => {
|
|
pending();
|
|
inner.updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
__beforeLoadContext: beforeLoadContext2
|
|
}));
|
|
resolve();
|
|
});
|
|
};
|
|
let beforeLoadContext;
|
|
try {
|
|
beforeLoadContext = route.options.beforeLoad(beforeLoadFnContext);
|
|
if (isPromise(beforeLoadContext)) {
|
|
pending();
|
|
return beforeLoadContext.catch((err) => {
|
|
handleSerialError(inner, index, err, "BEFORE_LOAD");
|
|
}).then(updateContext);
|
|
}
|
|
} catch (err) {
|
|
pending();
|
|
handleSerialError(inner, index, err, "BEFORE_LOAD");
|
|
}
|
|
updateContext(beforeLoadContext);
|
|
return;
|
|
};
|
|
var handleBeforeLoad = (inner, index) => {
|
|
const { id: matchId, routeId } = inner.matches[index];
|
|
const route = inner.router.looseRoutesById[routeId];
|
|
const serverSsr = () => {
|
|
if (isServer ?? inner.router.isServer) {
|
|
const maybePromise = isBeforeLoadSsr(inner, matchId, index, route);
|
|
if (isPromise(maybePromise)) return maybePromise.then(queueExecution);
|
|
}
|
|
return queueExecution();
|
|
};
|
|
const execute = () => executeBeforeLoad(inner, matchId, index, route);
|
|
const queueExecution = () => {
|
|
if (shouldSkipLoader(inner, matchId)) return;
|
|
const result = preBeforeLoadSetup(inner, matchId, route);
|
|
return isPromise(result) ? result.then(execute) : execute();
|
|
};
|
|
return serverSsr();
|
|
};
|
|
var executeHead = (inner, matchId, route) => {
|
|
const match = inner.router.getMatch(matchId);
|
|
if (!match) {
|
|
return;
|
|
}
|
|
if (!route.options.head && !route.options.scripts && !route.options.headers) {
|
|
return;
|
|
}
|
|
const assetContext = {
|
|
ssr: inner.router.options.ssr,
|
|
matches: inner.matches,
|
|
match,
|
|
params: match.params,
|
|
loaderData: match.loaderData
|
|
};
|
|
return Promise.all([
|
|
route.options.head?.(assetContext),
|
|
route.options.scripts?.(assetContext),
|
|
route.options.headers?.(assetContext)
|
|
]).then(([headFnContent, scripts, headers]) => {
|
|
const meta = headFnContent?.meta;
|
|
const links = headFnContent?.links;
|
|
const headScripts = headFnContent?.scripts;
|
|
const styles = headFnContent?.styles;
|
|
return {
|
|
meta,
|
|
links,
|
|
headScripts,
|
|
headers,
|
|
scripts,
|
|
styles
|
|
};
|
|
});
|
|
};
|
|
var getLoaderContext = (inner, matchPromises, matchId, index, route) => {
|
|
const parentMatchPromise = matchPromises[index - 1];
|
|
const { params, loaderDeps, abortController, cause } = inner.router.getMatch(matchId);
|
|
const context = buildMatchContext(inner, index);
|
|
const preload = resolvePreload(inner, matchId);
|
|
return {
|
|
params,
|
|
deps: loaderDeps,
|
|
preload: !!preload,
|
|
parentMatchPromise,
|
|
abortController,
|
|
context,
|
|
location: inner.location,
|
|
navigate: (opts) => inner.router.navigate({
|
|
...opts,
|
|
_fromLocation: inner.location
|
|
}),
|
|
cause: preload ? "preload" : cause,
|
|
route,
|
|
...inner.router.options.additionalContext
|
|
};
|
|
};
|
|
var runLoader = async (inner, matchPromises, matchId, index, route) => {
|
|
try {
|
|
const match = inner.router.getMatch(matchId);
|
|
try {
|
|
if (!(isServer ?? inner.router.isServer) || match.ssr === true) {
|
|
loadRouteChunk(route);
|
|
}
|
|
const loaderResult = route.options.loader?.(
|
|
getLoaderContext(inner, matchPromises, matchId, index, route)
|
|
);
|
|
const loaderResultIsPromise = route.options.loader && isPromise(loaderResult);
|
|
const willLoadSomething = !!(loaderResultIsPromise || route._lazyPromise || route._componentsPromise || route.options.head || route.options.scripts || route.options.headers || match._nonReactive.minPendingPromise);
|
|
if (willLoadSomething) {
|
|
inner.updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
isFetching: "loader"
|
|
}));
|
|
}
|
|
if (route.options.loader) {
|
|
const loaderData = loaderResultIsPromise ? await loaderResult : loaderResult;
|
|
handleRedirectAndNotFound(
|
|
inner,
|
|
inner.router.getMatch(matchId),
|
|
loaderData
|
|
);
|
|
if (loaderData !== void 0) {
|
|
inner.updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
loaderData
|
|
}));
|
|
}
|
|
}
|
|
if (route._lazyPromise) await route._lazyPromise;
|
|
const pendingPromise = match._nonReactive.minPendingPromise;
|
|
if (pendingPromise) await pendingPromise;
|
|
if (route._componentsPromise) await route._componentsPromise;
|
|
inner.updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
error: void 0,
|
|
context: buildMatchContext(inner, index),
|
|
status: "success",
|
|
isFetching: false,
|
|
updatedAt: Date.now()
|
|
}));
|
|
} catch (e) {
|
|
let error = e;
|
|
if (error?.name === "AbortError") {
|
|
if (match.abortController.signal.aborted) {
|
|
match._nonReactive.loaderPromise?.resolve();
|
|
match._nonReactive.loaderPromise = void 0;
|
|
return;
|
|
}
|
|
inner.updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
status: prev.status === "pending" ? "success" : prev.status,
|
|
isFetching: false,
|
|
context: buildMatchContext(inner, index)
|
|
}));
|
|
return;
|
|
}
|
|
const pendingPromise = match._nonReactive.minPendingPromise;
|
|
if (pendingPromise) await pendingPromise;
|
|
if (isNotFound(e)) {
|
|
await route.options.notFoundComponent?.preload?.();
|
|
}
|
|
handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), e);
|
|
try {
|
|
route.options.onError?.(e);
|
|
} catch (onErrorError) {
|
|
error = onErrorError;
|
|
handleRedirectAndNotFound(
|
|
inner,
|
|
inner.router.getMatch(matchId),
|
|
onErrorError
|
|
);
|
|
}
|
|
inner.updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
error,
|
|
context: buildMatchContext(inner, index),
|
|
status: "error",
|
|
isFetching: false
|
|
}));
|
|
}
|
|
} catch (err) {
|
|
const match = inner.router.getMatch(matchId);
|
|
if (match) {
|
|
match._nonReactive.loaderPromise = void 0;
|
|
}
|
|
handleRedirectAndNotFound(inner, match, err);
|
|
}
|
|
};
|
|
var loadRouteMatch = async (inner, matchPromises, index) => {
|
|
async function handleLoader(preload, prevMatch, previousRouteMatchId, match2, route2) {
|
|
const age = Date.now() - prevMatch.updatedAt;
|
|
const staleAge = preload ? route2.options.preloadStaleTime ?? inner.router.options.defaultPreloadStaleTime ?? 3e4 : route2.options.staleTime ?? inner.router.options.defaultStaleTime ?? 0;
|
|
const shouldReloadOption = route2.options.shouldReload;
|
|
const shouldReload = typeof shouldReloadOption === "function" ? shouldReloadOption(
|
|
getLoaderContext(inner, matchPromises, matchId, index, route2)
|
|
) : shouldReloadOption;
|
|
const { status, invalid } = match2;
|
|
const staleMatchShouldReload = age > staleAge && (!!inner.forceStaleReload || match2.cause === "enter" || previousRouteMatchId !== void 0 && previousRouteMatchId !== match2.id);
|
|
loaderShouldRunAsync = status === "success" && (invalid || (shouldReload ?? staleMatchShouldReload));
|
|
if (preload && route2.options.preload === false) ;
|
|
else if (loaderShouldRunAsync && !inner.sync) {
|
|
loaderIsRunningAsync = true;
|
|
(async () => {
|
|
try {
|
|
await runLoader(inner, matchPromises, matchId, index, route2);
|
|
const match3 = inner.router.getMatch(matchId);
|
|
match3._nonReactive.loaderPromise?.resolve();
|
|
match3._nonReactive.loadPromise?.resolve();
|
|
match3._nonReactive.loaderPromise = void 0;
|
|
} catch (err) {
|
|
if (isRedirect(err)) {
|
|
await inner.router.navigate(err.options);
|
|
}
|
|
}
|
|
})();
|
|
} else if (status !== "success" || loaderShouldRunAsync && inner.sync) {
|
|
await runLoader(inner, matchPromises, matchId, index, route2);
|
|
} else {
|
|
syncMatchContext(inner, matchId, index);
|
|
}
|
|
}
|
|
const { id: matchId, routeId } = inner.matches[index];
|
|
let loaderShouldRunAsync = false;
|
|
let loaderIsRunningAsync = false;
|
|
const route = inner.router.looseRoutesById[routeId];
|
|
if (shouldSkipLoader(inner, matchId)) {
|
|
const match2 = inner.router.getMatch(matchId);
|
|
if (!match2) {
|
|
return inner.matches[index];
|
|
}
|
|
syncMatchContext(inner, matchId, index);
|
|
if (isServer ?? inner.router.isServer) {
|
|
return inner.router.getMatch(matchId);
|
|
}
|
|
} else {
|
|
const prevMatch = inner.router.getMatch(matchId);
|
|
const previousRouteMatchId = inner.router.state.matches[index]?.routeId === routeId ? inner.router.state.matches[index].id : inner.router.state.matches.find((d) => d.routeId === routeId)?.id;
|
|
const preload = resolvePreload(inner, matchId);
|
|
if (prevMatch._nonReactive.loaderPromise) {
|
|
if (prevMatch.status === "success" && !inner.sync && !prevMatch.preload) {
|
|
return prevMatch;
|
|
}
|
|
await prevMatch._nonReactive.loaderPromise;
|
|
const match2 = inner.router.getMatch(matchId);
|
|
const error = match2._nonReactive.error || match2.error;
|
|
if (error) {
|
|
handleRedirectAndNotFound(inner, match2, error);
|
|
}
|
|
if (match2.status === "pending") {
|
|
await handleLoader(
|
|
preload,
|
|
prevMatch,
|
|
previousRouteMatchId,
|
|
match2,
|
|
route
|
|
);
|
|
}
|
|
} else {
|
|
const nextPreload = preload && !inner.router.state.matches.some((d) => d.id === matchId);
|
|
const match2 = inner.router.getMatch(matchId);
|
|
match2._nonReactive.loaderPromise = createControlledPromise();
|
|
if (nextPreload !== match2.preload) {
|
|
inner.updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
preload: nextPreload
|
|
}));
|
|
}
|
|
await handleLoader(preload, prevMatch, previousRouteMatchId, match2, route);
|
|
}
|
|
}
|
|
const match = inner.router.getMatch(matchId);
|
|
if (!loaderIsRunningAsync) {
|
|
match._nonReactive.loaderPromise?.resolve();
|
|
match._nonReactive.loadPromise?.resolve();
|
|
}
|
|
clearTimeout(match._nonReactive.pendingTimeout);
|
|
match._nonReactive.pendingTimeout = void 0;
|
|
if (!loaderIsRunningAsync) match._nonReactive.loaderPromise = void 0;
|
|
match._nonReactive.dehydrated = void 0;
|
|
const nextIsFetching = loaderIsRunningAsync ? match.isFetching : false;
|
|
if (nextIsFetching !== match.isFetching || match.invalid !== false) {
|
|
inner.updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
isFetching: nextIsFetching,
|
|
invalid: false
|
|
}));
|
|
return inner.router.getMatch(matchId);
|
|
} else {
|
|
return match;
|
|
}
|
|
};
|
|
async function loadMatches(arg) {
|
|
const inner = arg;
|
|
const matchPromises = [];
|
|
if (!(isServer ?? inner.router.isServer) && inner.router.state.matches.some((d) => d._forcePending)) {
|
|
triggerOnReady(inner);
|
|
}
|
|
let beforeLoadNotFound;
|
|
for (let i = 0; i < inner.matches.length; i++) {
|
|
try {
|
|
const beforeLoad = handleBeforeLoad(inner, i);
|
|
if (isPromise(beforeLoad)) await beforeLoad;
|
|
} catch (err) {
|
|
if (isRedirect(err)) {
|
|
throw err;
|
|
}
|
|
if (isNotFound(err)) {
|
|
beforeLoadNotFound = err;
|
|
} else {
|
|
if (!inner.preload) throw err;
|
|
}
|
|
break;
|
|
}
|
|
if (inner.serialError) {
|
|
break;
|
|
}
|
|
}
|
|
const baseMaxIndexExclusive = inner.firstBadMatchIndex ?? inner.matches.length;
|
|
const boundaryIndex = beforeLoadNotFound && !inner.preload ? getNotFoundBoundaryIndex(inner, beforeLoadNotFound) : void 0;
|
|
const maxIndexExclusive = beforeLoadNotFound && inner.preload ? 0 : boundaryIndex !== void 0 ? Math.min(boundaryIndex + 1, baseMaxIndexExclusive) : baseMaxIndexExclusive;
|
|
let firstNotFound;
|
|
let firstUnhandledRejection;
|
|
for (let i = 0; i < maxIndexExclusive; i++) {
|
|
matchPromises.push(loadRouteMatch(inner, matchPromises, i));
|
|
}
|
|
try {
|
|
await Promise.all(matchPromises);
|
|
} catch {
|
|
const settled = await Promise.allSettled(matchPromises);
|
|
for (const result of settled) {
|
|
if (result.status !== "rejected") continue;
|
|
const reason = result.reason;
|
|
if (isRedirect(reason)) {
|
|
throw reason;
|
|
}
|
|
if (isNotFound(reason)) {
|
|
firstNotFound ??= reason;
|
|
} else {
|
|
firstUnhandledRejection ??= reason;
|
|
}
|
|
}
|
|
if (firstUnhandledRejection !== void 0) {
|
|
throw firstUnhandledRejection;
|
|
}
|
|
}
|
|
const notFoundToThrow = firstNotFound ?? (beforeLoadNotFound && !inner.preload ? beforeLoadNotFound : void 0);
|
|
let headMaxIndex = inner.serialError ? inner.firstBadMatchIndex ?? 0 : inner.matches.length - 1;
|
|
if (!notFoundToThrow && beforeLoadNotFound && inner.preload) {
|
|
return inner.matches;
|
|
}
|
|
if (notFoundToThrow) {
|
|
const renderedBoundaryIndex = getNotFoundBoundaryIndex(
|
|
inner,
|
|
notFoundToThrow
|
|
);
|
|
invariant(
|
|
renderedBoundaryIndex !== void 0,
|
|
"Could not find match for notFound boundary"
|
|
);
|
|
const boundaryMatch = inner.matches[renderedBoundaryIndex];
|
|
const boundaryRoute = inner.router.looseRoutesById[boundaryMatch.routeId];
|
|
const defaultNotFoundComponent = inner.router.options?.defaultNotFoundComponent;
|
|
if (!boundaryRoute.options.notFoundComponent && defaultNotFoundComponent) {
|
|
boundaryRoute.options.notFoundComponent = defaultNotFoundComponent;
|
|
}
|
|
notFoundToThrow.routeId = boundaryMatch.routeId;
|
|
const boundaryIsRoot = boundaryMatch.routeId === inner.router.routeTree.id;
|
|
inner.updateMatch(boundaryMatch.id, (prev) => ({
|
|
...prev,
|
|
...boundaryIsRoot ? (
|
|
// For root boundary, use globalNotFound so the root component's
|
|
// shell still renders and <Outlet> handles the not-found display,
|
|
// instead of replacing the entire root shell via status='notFound'.
|
|
{ status: "success", globalNotFound: true, error: void 0 }
|
|
) : (
|
|
// For non-root boundaries, set status:'notFound' so MatchInner
|
|
// renders the notFoundComponent directly.
|
|
{ status: "notFound", error: notFoundToThrow }
|
|
),
|
|
isFetching: false
|
|
}));
|
|
headMaxIndex = renderedBoundaryIndex;
|
|
await loadRouteChunk(boundaryRoute);
|
|
} else if (!inner.preload) {
|
|
const rootMatch = inner.matches[0];
|
|
if (!rootMatch.globalNotFound) {
|
|
const currentRootMatch = inner.router.getMatch(rootMatch.id);
|
|
if (currentRootMatch?.globalNotFound) {
|
|
inner.updateMatch(rootMatch.id, (prev) => ({
|
|
...prev,
|
|
globalNotFound: false,
|
|
error: void 0
|
|
}));
|
|
}
|
|
}
|
|
}
|
|
if (inner.serialError && inner.firstBadMatchIndex !== void 0) {
|
|
const errorRoute = inner.router.looseRoutesById[inner.matches[inner.firstBadMatchIndex].routeId];
|
|
await loadRouteChunk(errorRoute);
|
|
}
|
|
for (let i = 0; i <= headMaxIndex; i++) {
|
|
const match = inner.matches[i];
|
|
const { id: matchId, routeId } = match;
|
|
const route = inner.router.looseRoutesById[routeId];
|
|
try {
|
|
const headResult = executeHead(inner, matchId, route);
|
|
if (headResult) {
|
|
const head = await headResult;
|
|
inner.updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
...head
|
|
}));
|
|
}
|
|
} catch (err) {
|
|
console.error(`Error executing head for route ${routeId}:`, err);
|
|
}
|
|
}
|
|
const readyPromise = triggerOnReady(inner);
|
|
if (isPromise(readyPromise)) {
|
|
await readyPromise;
|
|
}
|
|
if (notFoundToThrow) {
|
|
throw notFoundToThrow;
|
|
}
|
|
if (inner.serialError && !inner.preload && !inner.onReady) {
|
|
throw inner.serialError;
|
|
}
|
|
return inner.matches;
|
|
}
|
|
async function loadRouteChunk(route) {
|
|
if (!route._lazyLoaded && route._lazyPromise === void 0) {
|
|
if (route.lazyFn) {
|
|
route._lazyPromise = route.lazyFn().then((lazyRoute) => {
|
|
const { id: _id, ...options } = lazyRoute.options;
|
|
Object.assign(route.options, options);
|
|
route._lazyLoaded = true;
|
|
route._lazyPromise = void 0;
|
|
});
|
|
} else {
|
|
route._lazyLoaded = true;
|
|
}
|
|
}
|
|
if (!route._componentsLoaded && route._componentsPromise === void 0) {
|
|
const loadComponents = () => {
|
|
const preloads = [];
|
|
for (const type of componentTypes) {
|
|
const preload = route.options[type]?.preload;
|
|
if (preload) preloads.push(preload());
|
|
}
|
|
if (preloads.length)
|
|
return Promise.all(preloads).then(() => {
|
|
route._componentsLoaded = true;
|
|
route._componentsPromise = void 0;
|
|
});
|
|
route._componentsLoaded = true;
|
|
route._componentsPromise = void 0;
|
|
return;
|
|
};
|
|
route._componentsPromise = route._lazyPromise ? route._lazyPromise.then(loadComponents) : loadComponents();
|
|
}
|
|
return route._componentsPromise;
|
|
}
|
|
function makeMaybe(value, error) {
|
|
if (error) {
|
|
return { status: "error", error };
|
|
}
|
|
return { status: "success", value };
|
|
}
|
|
function routeNeedsPreload(route) {
|
|
for (const componentType of componentTypes) {
|
|
if (route.options[componentType]?.preload) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
var componentTypes = [
|
|
"component",
|
|
"errorComponent",
|
|
"pendingComponent",
|
|
"notFoundComponent"
|
|
];
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/rewrite.js
|
|
function composeRewrites(rewrites) {
|
|
return {
|
|
input: ({ url }) => {
|
|
for (const rewrite of rewrites) {
|
|
url = executeRewriteInput(rewrite, url);
|
|
}
|
|
return url;
|
|
},
|
|
output: ({ url }) => {
|
|
for (let i = rewrites.length - 1; i >= 0; i--) {
|
|
url = executeRewriteOutput(rewrites[i], url);
|
|
}
|
|
return url;
|
|
}
|
|
};
|
|
}
|
|
function rewriteBasepath(opts) {
|
|
const trimmedBasepath = trimPath(opts.basepath);
|
|
const normalizedBasepath = `/${trimmedBasepath}`;
|
|
const normalizedBasepathWithSlash = `${normalizedBasepath}/`;
|
|
const checkBasepath = opts.caseSensitive ? normalizedBasepath : normalizedBasepath.toLowerCase();
|
|
const checkBasepathWithSlash = opts.caseSensitive ? normalizedBasepathWithSlash : normalizedBasepathWithSlash.toLowerCase();
|
|
return {
|
|
input: ({ url }) => {
|
|
const pathname = opts.caseSensitive ? url.pathname : url.pathname.toLowerCase();
|
|
if (pathname === checkBasepath) {
|
|
url.pathname = "/";
|
|
} else if (pathname.startsWith(checkBasepathWithSlash)) {
|
|
url.pathname = url.pathname.slice(normalizedBasepath.length);
|
|
}
|
|
return url;
|
|
},
|
|
output: ({ url }) => {
|
|
url.pathname = joinPaths(["/", trimmedBasepath, url.pathname]);
|
|
return url;
|
|
}
|
|
};
|
|
}
|
|
function executeRewriteInput(rewrite, url) {
|
|
const res = rewrite?.input?.({ url });
|
|
if (res) {
|
|
if (typeof res === "string") {
|
|
return new URL(res);
|
|
} else if (res instanceof URL) {
|
|
return res;
|
|
}
|
|
}
|
|
return url;
|
|
}
|
|
function executeRewriteOutput(rewrite, url) {
|
|
const res = rewrite?.output?.({ url });
|
|
if (res) {
|
|
if (typeof res === "string") {
|
|
return new URL(res);
|
|
} else if (res instanceof URL) {
|
|
return res;
|
|
}
|
|
}
|
|
return url;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/router.js
|
|
function defaultSerializeError(err) {
|
|
if (err instanceof Error) {
|
|
const obj = {
|
|
name: err.name,
|
|
message: err.message
|
|
};
|
|
if (true) {
|
|
obj.stack = err.stack;
|
|
}
|
|
return obj;
|
|
}
|
|
return {
|
|
data: err
|
|
};
|
|
}
|
|
function getLocationChangeInfo(routerState) {
|
|
const fromLocation = routerState.resolvedLocation;
|
|
const toLocation = routerState.location;
|
|
const pathChanged = fromLocation?.pathname !== toLocation.pathname;
|
|
const hrefChanged = fromLocation?.href !== toLocation.href;
|
|
const hashChanged = fromLocation?.hash !== toLocation.hash;
|
|
return { fromLocation, toLocation, pathChanged, hrefChanged, hashChanged };
|
|
}
|
|
function filterRedirectedCachedMatches(matches) {
|
|
const filtered = matches.filter((d) => d.status !== "redirected");
|
|
return filtered.length === matches.length ? matches : filtered;
|
|
}
|
|
function createServerStore(initialState) {
|
|
const store = {
|
|
state: initialState,
|
|
setState: (updater) => {
|
|
store.state = updater(store.state);
|
|
}
|
|
};
|
|
return store;
|
|
}
|
|
var RouterCore = class {
|
|
/**
|
|
* @deprecated Use the `createRouter` function instead
|
|
*/
|
|
constructor(options) {
|
|
this.tempLocationKey = `${Math.round(
|
|
Math.random() * 1e7
|
|
)}`;
|
|
this.resetNextScroll = true;
|
|
this.shouldViewTransition = void 0;
|
|
this.isViewTransitionTypesSupported = void 0;
|
|
this.subscribers = /* @__PURE__ */ new Set();
|
|
this.isScrollRestoring = false;
|
|
this.isScrollRestorationSetup = false;
|
|
this.startTransition = (fn) => fn();
|
|
this.update = (newOptions) => {
|
|
if (true) {
|
|
if (newOptions.notFoundRoute) {
|
|
console.warn(
|
|
"The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/framework/react/guide/not-found-errors#migrating-from-notfoundroute for more info."
|
|
);
|
|
}
|
|
}
|
|
const prevOptions = this.options;
|
|
const prevBasepath = this.basepath ?? prevOptions?.basepath ?? "/";
|
|
const basepathWasUnset = this.basepath === void 0;
|
|
const prevRewriteOption = prevOptions?.rewrite;
|
|
this.options = {
|
|
...prevOptions,
|
|
...newOptions
|
|
};
|
|
this.isServer = this.options.isServer ?? typeof document === "undefined";
|
|
this.protocolAllowlist = new Set(this.options.protocolAllowlist);
|
|
if (this.options.pathParamsAllowedCharacters)
|
|
this.pathParamsDecoder = compileDecodeCharMap(
|
|
this.options.pathParamsAllowedCharacters
|
|
);
|
|
if (!this.history || this.options.history && this.options.history !== this.history) {
|
|
if (!this.options.history) {
|
|
if (!(isServer ?? this.isServer)) {
|
|
this.history = createBrowserHistory();
|
|
}
|
|
} else {
|
|
this.history = this.options.history;
|
|
}
|
|
}
|
|
this.origin = this.options.origin;
|
|
if (!this.origin) {
|
|
if (!(isServer ?? this.isServer) && window?.origin && window.origin !== "null") {
|
|
this.origin = window.origin;
|
|
} else {
|
|
this.origin = "http://localhost";
|
|
}
|
|
}
|
|
if (this.history) {
|
|
this.updateLatestLocation();
|
|
}
|
|
if (this.options.routeTree !== this.routeTree) {
|
|
this.routeTree = this.options.routeTree;
|
|
let processRouteTreeResult;
|
|
if ((isServer ?? this.isServer) && false) {
|
|
const cached = globalThis.__TSR_CACHE__;
|
|
this.resolvePathCache = cached.resolvePathCache;
|
|
processRouteTreeResult = cached.processRouteTreeResult;
|
|
} else {
|
|
this.resolvePathCache = createLRUCache(1e3);
|
|
processRouteTreeResult = this.buildRouteTree();
|
|
if ((isServer ?? this.isServer) && false) {
|
|
globalThis.__TSR_CACHE__ = {
|
|
routeTree: this.routeTree,
|
|
processRouteTreeResult,
|
|
resolvePathCache: this.resolvePathCache
|
|
};
|
|
}
|
|
}
|
|
this.setRoutes(processRouteTreeResult);
|
|
}
|
|
if (!this.__store && this.latestLocation) {
|
|
if (isServer ?? this.isServer) {
|
|
this.__store = createServerStore(
|
|
getInitialRouterState(this.latestLocation)
|
|
);
|
|
} else {
|
|
this.__store = createStore(getInitialRouterState(this.latestLocation));
|
|
setupScrollRestoration(this);
|
|
}
|
|
}
|
|
let needsLocationUpdate = false;
|
|
const nextBasepath = this.options.basepath ?? "/";
|
|
const nextRewriteOption = this.options.rewrite;
|
|
const basepathChanged = basepathWasUnset || prevBasepath !== nextBasepath;
|
|
const rewriteChanged = prevRewriteOption !== nextRewriteOption;
|
|
if (basepathChanged || rewriteChanged) {
|
|
this.basepath = nextBasepath;
|
|
const rewrites = [];
|
|
const trimmed = trimPath(nextBasepath);
|
|
if (trimmed && trimmed !== "/") {
|
|
rewrites.push(
|
|
rewriteBasepath({
|
|
basepath: nextBasepath
|
|
})
|
|
);
|
|
}
|
|
if (nextRewriteOption) {
|
|
rewrites.push(nextRewriteOption);
|
|
}
|
|
this.rewrite = rewrites.length === 0 ? void 0 : rewrites.length === 1 ? rewrites[0] : composeRewrites(rewrites);
|
|
if (this.history) {
|
|
this.updateLatestLocation();
|
|
}
|
|
needsLocationUpdate = true;
|
|
}
|
|
if (needsLocationUpdate && this.__store) {
|
|
this.__store.setState((s) => ({
|
|
...s,
|
|
location: this.latestLocation
|
|
}));
|
|
}
|
|
if (typeof window !== "undefined" && "CSS" in window && typeof window.CSS?.supports === "function") {
|
|
this.isViewTransitionTypesSupported = window.CSS.supports(
|
|
"selector(:active-view-transition-type(a)"
|
|
);
|
|
}
|
|
};
|
|
this.updateLatestLocation = () => {
|
|
this.latestLocation = this.parseLocation(
|
|
this.history.location,
|
|
this.latestLocation
|
|
);
|
|
};
|
|
this.buildRouteTree = () => {
|
|
const result = processRouteTree(
|
|
this.routeTree,
|
|
this.options.caseSensitive,
|
|
(route, i) => {
|
|
route.init({
|
|
originalIndex: i
|
|
});
|
|
}
|
|
);
|
|
if (this.options.routeMasks) {
|
|
processRouteMasks(this.options.routeMasks, result.processedTree);
|
|
}
|
|
return result;
|
|
};
|
|
this.subscribe = (eventType, fn) => {
|
|
const listener = {
|
|
eventType,
|
|
fn
|
|
};
|
|
this.subscribers.add(listener);
|
|
return () => {
|
|
this.subscribers.delete(listener);
|
|
};
|
|
};
|
|
this.emit = (routerEvent) => {
|
|
this.subscribers.forEach((listener) => {
|
|
if (listener.eventType === routerEvent.type) {
|
|
listener.fn(routerEvent);
|
|
}
|
|
});
|
|
};
|
|
this.parseLocation = (locationToParse, previousLocation) => {
|
|
const parse = ({
|
|
pathname,
|
|
search,
|
|
hash,
|
|
href,
|
|
state
|
|
}) => {
|
|
if (!this.rewrite && !/[ \x00-\x1f\x7f\u0080-\uffff]/.test(pathname)) {
|
|
const parsedSearch2 = this.options.parseSearch(search);
|
|
const searchStr2 = this.options.stringifySearch(parsedSearch2);
|
|
return {
|
|
href: pathname + searchStr2 + hash,
|
|
publicHref: href,
|
|
pathname: decodePath(pathname).path,
|
|
external: false,
|
|
searchStr: searchStr2,
|
|
search: replaceEqualDeep(
|
|
previousLocation?.search,
|
|
parsedSearch2
|
|
),
|
|
hash: decodePath(hash.slice(1)).path,
|
|
state: replaceEqualDeep(previousLocation?.state, state)
|
|
};
|
|
}
|
|
const fullUrl = new URL(href, this.origin);
|
|
const url = executeRewriteInput(this.rewrite, fullUrl);
|
|
const parsedSearch = this.options.parseSearch(url.search);
|
|
const searchStr = this.options.stringifySearch(parsedSearch);
|
|
url.search = searchStr;
|
|
const fullPath = url.href.replace(url.origin, "");
|
|
return {
|
|
href: fullPath,
|
|
publicHref: href,
|
|
pathname: decodePath(url.pathname).path,
|
|
external: !!this.rewrite && url.origin !== this.origin,
|
|
searchStr,
|
|
search: replaceEqualDeep(previousLocation?.search, parsedSearch),
|
|
hash: decodePath(url.hash.slice(1)).path,
|
|
state: replaceEqualDeep(previousLocation?.state, state)
|
|
};
|
|
};
|
|
const location = parse(locationToParse);
|
|
const { __tempLocation, __tempKey } = location.state;
|
|
if (__tempLocation && (!__tempKey || __tempKey === this.tempLocationKey)) {
|
|
const parsedTempLocation = parse(__tempLocation);
|
|
parsedTempLocation.state.key = location.state.key;
|
|
parsedTempLocation.state.__TSR_key = location.state.__TSR_key;
|
|
delete parsedTempLocation.state.__tempLocation;
|
|
return {
|
|
...parsedTempLocation,
|
|
maskedLocation: location
|
|
};
|
|
}
|
|
return location;
|
|
};
|
|
this.resolvePathWithBase = (from, path) => {
|
|
const resolvedPath = resolvePath({
|
|
base: from,
|
|
to: cleanPath(path),
|
|
trailingSlash: this.options.trailingSlash,
|
|
cache: this.resolvePathCache
|
|
});
|
|
return resolvedPath;
|
|
};
|
|
this.matchRoutes = (pathnameOrNext, locationSearchOrOpts, opts) => {
|
|
if (typeof pathnameOrNext === "string") {
|
|
return this.matchRoutesInternal(
|
|
{
|
|
pathname: pathnameOrNext,
|
|
search: locationSearchOrOpts
|
|
},
|
|
opts
|
|
);
|
|
}
|
|
return this.matchRoutesInternal(pathnameOrNext, locationSearchOrOpts);
|
|
};
|
|
this.getMatchedRoutes = (pathname) => {
|
|
return getMatchedRoutes({
|
|
pathname,
|
|
routesById: this.routesById,
|
|
processedTree: this.processedTree
|
|
});
|
|
};
|
|
this.cancelMatch = (id) => {
|
|
const match = this.getMatch(id);
|
|
if (!match) return;
|
|
match.abortController.abort();
|
|
clearTimeout(match._nonReactive.pendingTimeout);
|
|
match._nonReactive.pendingTimeout = void 0;
|
|
};
|
|
this.cancelMatches = () => {
|
|
const currentPendingMatches = this.state.matches.filter(
|
|
(match) => match.status === "pending"
|
|
);
|
|
const currentLoadingMatches = this.state.matches.filter(
|
|
(match) => match.isFetching === "loader"
|
|
);
|
|
const matchesToCancelArray = /* @__PURE__ */ new Set([
|
|
...this.state.pendingMatches ?? [],
|
|
...currentPendingMatches,
|
|
...currentLoadingMatches
|
|
]);
|
|
matchesToCancelArray.forEach((match) => {
|
|
this.cancelMatch(match.id);
|
|
});
|
|
};
|
|
this.buildLocation = (opts) => {
|
|
const build = (dest = {}) => {
|
|
const currentLocation = dest._fromLocation || this.pendingBuiltLocation || this.latestLocation;
|
|
const lightweightResult = this.matchRoutesLightweight(currentLocation);
|
|
if (dest.from && true && dest._isNavigate) {
|
|
const allFromMatches = this.getMatchedRoutes(dest.from).matchedRoutes;
|
|
const matchedFrom = findLast(lightweightResult.matchedRoutes, (d) => {
|
|
return comparePaths(d.fullPath, dest.from);
|
|
});
|
|
const matchedCurrent = findLast(allFromMatches, (d) => {
|
|
return comparePaths(d.fullPath, lightweightResult.fullPath);
|
|
});
|
|
if (!matchedFrom && !matchedCurrent) {
|
|
console.warn(`Could not find match for from: ${dest.from}`);
|
|
}
|
|
}
|
|
const defaultedFromPath = dest.unsafeRelative === "path" ? currentLocation.pathname : dest.from ?? lightweightResult.fullPath;
|
|
const fromPath = this.resolvePathWithBase(defaultedFromPath, ".");
|
|
const fromSearch = lightweightResult.search;
|
|
const fromParams = { ...lightweightResult.params };
|
|
const nextTo = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(fromPath, ".");
|
|
const nextParams = dest.params === false || dest.params === null ? {} : (dest.params ?? true) === true ? fromParams : Object.assign(
|
|
fromParams,
|
|
functionalUpdate(dest.params, fromParams)
|
|
);
|
|
const destMatchResult = this.getMatchedRoutes(nextTo);
|
|
let destRoutes = destMatchResult.matchedRoutes;
|
|
const isGlobalNotFound = !destMatchResult.foundRoute || destMatchResult.foundRoute.path !== "/" && destMatchResult.routeParams["**"];
|
|
if (isGlobalNotFound && this.options.notFoundRoute) {
|
|
destRoutes = [...destRoutes, this.options.notFoundRoute];
|
|
}
|
|
if (Object.keys(nextParams).length > 0) {
|
|
for (const route of destRoutes) {
|
|
const fn = route.options.params?.stringify ?? route.options.stringifyParams;
|
|
if (fn) {
|
|
try {
|
|
Object.assign(nextParams, fn(nextParams));
|
|
} catch {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const nextPathname = opts.leaveParams ? (
|
|
// Use the original template path for interpolation
|
|
// This preserves the original parameter syntax including optional parameters
|
|
nextTo
|
|
) : decodePath(
|
|
interpolatePath({
|
|
path: nextTo,
|
|
params: nextParams,
|
|
decoder: this.pathParamsDecoder,
|
|
server: this.isServer
|
|
}).interpolatedPath
|
|
).path;
|
|
let nextSearch = fromSearch;
|
|
if (opts._includeValidateSearch && this.options.search?.strict) {
|
|
const validatedSearch = {};
|
|
destRoutes.forEach((route) => {
|
|
if (route.options.validateSearch) {
|
|
try {
|
|
Object.assign(
|
|
validatedSearch,
|
|
validateSearch(route.options.validateSearch, {
|
|
...validatedSearch,
|
|
...nextSearch
|
|
})
|
|
);
|
|
} catch {
|
|
}
|
|
}
|
|
});
|
|
nextSearch = validatedSearch;
|
|
}
|
|
nextSearch = applySearchMiddleware({
|
|
search: nextSearch,
|
|
dest,
|
|
destRoutes,
|
|
_includeValidateSearch: opts._includeValidateSearch
|
|
});
|
|
nextSearch = replaceEqualDeep(fromSearch, nextSearch);
|
|
const searchStr = this.options.stringifySearch(nextSearch);
|
|
const hash = dest.hash === true ? currentLocation.hash : dest.hash ? functionalUpdate(dest.hash, currentLocation.hash) : void 0;
|
|
const hashStr = hash ? `#${hash}` : "";
|
|
let nextState = dest.state === true ? currentLocation.state : dest.state ? functionalUpdate(dest.state, currentLocation.state) : {};
|
|
nextState = replaceEqualDeep(currentLocation.state, nextState);
|
|
const fullPath = `${nextPathname}${searchStr}${hashStr}`;
|
|
let href;
|
|
let publicHref;
|
|
let external = false;
|
|
if (this.rewrite) {
|
|
const url = new URL(fullPath, this.origin);
|
|
const rewrittenUrl = executeRewriteOutput(this.rewrite, url);
|
|
href = url.href.replace(url.origin, "");
|
|
if (rewrittenUrl.origin !== this.origin) {
|
|
publicHref = rewrittenUrl.href;
|
|
external = true;
|
|
} else {
|
|
publicHref = rewrittenUrl.pathname + rewrittenUrl.search + rewrittenUrl.hash;
|
|
}
|
|
} else {
|
|
href = encodePathLikeUrl(fullPath);
|
|
publicHref = href;
|
|
}
|
|
return {
|
|
publicHref,
|
|
href,
|
|
pathname: nextPathname,
|
|
search: nextSearch,
|
|
searchStr,
|
|
state: nextState,
|
|
hash: hash ?? "",
|
|
external,
|
|
unmaskOnReload: dest.unmaskOnReload
|
|
};
|
|
};
|
|
const buildWithMatches = (dest = {}, maskedDest) => {
|
|
const next = build(dest);
|
|
let maskedNext = maskedDest ? build(maskedDest) : void 0;
|
|
if (!maskedNext) {
|
|
const params = {};
|
|
if (this.options.routeMasks) {
|
|
const match = findFlatMatch(
|
|
next.pathname,
|
|
this.processedTree
|
|
);
|
|
if (match) {
|
|
Object.assign(params, match.rawParams);
|
|
const {
|
|
from: _from,
|
|
params: maskParams,
|
|
...maskProps
|
|
} = match.route;
|
|
const nextParams = maskParams === false || maskParams === null ? {} : (maskParams ?? true) === true ? params : Object.assign(params, functionalUpdate(maskParams, params));
|
|
maskedDest = {
|
|
from: opts.from,
|
|
...maskProps,
|
|
params: nextParams
|
|
};
|
|
maskedNext = build(maskedDest);
|
|
}
|
|
}
|
|
}
|
|
if (maskedNext) {
|
|
next.maskedLocation = maskedNext;
|
|
}
|
|
return next;
|
|
};
|
|
if (opts.mask) {
|
|
return buildWithMatches(opts, {
|
|
from: opts.from,
|
|
...opts.mask
|
|
});
|
|
}
|
|
return buildWithMatches(opts);
|
|
};
|
|
this.commitLocation = async ({
|
|
viewTransition,
|
|
ignoreBlocker,
|
|
...next
|
|
}) => {
|
|
const isSameState = () => {
|
|
const ignoredProps = [
|
|
"key",
|
|
// TODO: Remove in v2 - use __TSR_key instead
|
|
"__TSR_key",
|
|
"__TSR_index",
|
|
"__hashScrollIntoViewOptions"
|
|
];
|
|
ignoredProps.forEach((prop) => {
|
|
next.state[prop] = this.latestLocation.state[prop];
|
|
});
|
|
const isEqual = deepEqual(next.state, this.latestLocation.state);
|
|
ignoredProps.forEach((prop) => {
|
|
delete next.state[prop];
|
|
});
|
|
return isEqual;
|
|
};
|
|
const isSameUrl = trimPathRight2(this.latestLocation.href) === trimPathRight2(next.href);
|
|
const previousCommitPromise = this.commitLocationPromise;
|
|
this.commitLocationPromise = createControlledPromise(() => {
|
|
previousCommitPromise?.resolve();
|
|
});
|
|
if (isSameUrl && isSameState()) {
|
|
this.load();
|
|
} else {
|
|
let {
|
|
// eslint-disable-next-line prefer-const
|
|
maskedLocation,
|
|
// eslint-disable-next-line prefer-const
|
|
hashScrollIntoView,
|
|
...nextHistory
|
|
} = next;
|
|
if (maskedLocation) {
|
|
nextHistory = {
|
|
...maskedLocation,
|
|
state: {
|
|
...maskedLocation.state,
|
|
__tempKey: void 0,
|
|
__tempLocation: {
|
|
...nextHistory,
|
|
search: nextHistory.searchStr,
|
|
state: {
|
|
...nextHistory.state,
|
|
__tempKey: void 0,
|
|
__tempLocation: void 0,
|
|
__TSR_key: void 0,
|
|
key: void 0
|
|
// TODO: Remove in v2 - use __TSR_key instead
|
|
}
|
|
}
|
|
}
|
|
};
|
|
if (nextHistory.unmaskOnReload ?? this.options.unmaskOnReload ?? false) {
|
|
nextHistory.state.__tempKey = this.tempLocationKey;
|
|
}
|
|
}
|
|
nextHistory.state.__hashScrollIntoViewOptions = hashScrollIntoView ?? this.options.defaultHashScrollIntoView ?? true;
|
|
this.shouldViewTransition = viewTransition;
|
|
this.history[next.replace ? "replace" : "push"](
|
|
nextHistory.publicHref,
|
|
nextHistory.state,
|
|
{ ignoreBlocker }
|
|
);
|
|
}
|
|
this.resetNextScroll = next.resetScroll ?? true;
|
|
if (!this.history.subscribers.size) {
|
|
this.load();
|
|
}
|
|
return this.commitLocationPromise;
|
|
};
|
|
this.buildAndCommitLocation = ({
|
|
replace,
|
|
resetScroll,
|
|
hashScrollIntoView,
|
|
viewTransition,
|
|
ignoreBlocker,
|
|
href,
|
|
...rest
|
|
} = {}) => {
|
|
if (href) {
|
|
const currentIndex = this.history.location.state.__TSR_index;
|
|
const parsed = parseHref(href, {
|
|
__TSR_index: replace ? currentIndex : currentIndex + 1
|
|
});
|
|
const hrefUrl = new URL(parsed.pathname, this.origin);
|
|
const rewrittenUrl = executeRewriteInput(this.rewrite, hrefUrl);
|
|
rest.to = rewrittenUrl.pathname;
|
|
rest.search = this.options.parseSearch(parsed.search);
|
|
rest.hash = parsed.hash.slice(1);
|
|
}
|
|
const location = this.buildLocation({
|
|
...rest,
|
|
_includeValidateSearch: true
|
|
});
|
|
this.pendingBuiltLocation = location;
|
|
const commitPromise = this.commitLocation({
|
|
...location,
|
|
viewTransition,
|
|
replace,
|
|
resetScroll,
|
|
hashScrollIntoView,
|
|
ignoreBlocker
|
|
});
|
|
Promise.resolve().then(() => {
|
|
if (this.pendingBuiltLocation === location) {
|
|
this.pendingBuiltLocation = void 0;
|
|
}
|
|
});
|
|
return commitPromise;
|
|
};
|
|
this.navigate = async ({
|
|
to,
|
|
reloadDocument,
|
|
href,
|
|
publicHref,
|
|
...rest
|
|
}) => {
|
|
let hrefIsUrl = false;
|
|
if (href) {
|
|
try {
|
|
new URL(`${href}`);
|
|
hrefIsUrl = true;
|
|
} catch {
|
|
}
|
|
}
|
|
if (hrefIsUrl && !reloadDocument) {
|
|
reloadDocument = true;
|
|
}
|
|
if (reloadDocument) {
|
|
if (to !== void 0 || !href) {
|
|
const location = this.buildLocation({ to, ...rest });
|
|
href = href ?? location.publicHref;
|
|
publicHref = publicHref ?? location.publicHref;
|
|
}
|
|
const reloadHref = !hrefIsUrl && publicHref ? publicHref : href;
|
|
if (isDangerousProtocol(reloadHref, this.protocolAllowlist)) {
|
|
if (true) {
|
|
console.warn(
|
|
`Blocked navigation to dangerous protocol: ${reloadHref}`
|
|
);
|
|
}
|
|
return Promise.resolve();
|
|
}
|
|
if (!rest.ignoreBlocker) {
|
|
const historyWithBlockers = this.history;
|
|
const blockers = historyWithBlockers.getBlockers?.() ?? [];
|
|
for (const blocker of blockers) {
|
|
if (blocker?.blockerFn) {
|
|
const shouldBlock = await blocker.blockerFn({
|
|
currentLocation: this.latestLocation,
|
|
nextLocation: this.latestLocation,
|
|
// External URLs don't have a next location in our router
|
|
action: "PUSH"
|
|
});
|
|
if (shouldBlock) {
|
|
return Promise.resolve();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (rest.replace) {
|
|
window.location.replace(reloadHref);
|
|
} else {
|
|
window.location.href = reloadHref;
|
|
}
|
|
return Promise.resolve();
|
|
}
|
|
return this.buildAndCommitLocation({
|
|
...rest,
|
|
href,
|
|
to,
|
|
_isNavigate: true
|
|
});
|
|
};
|
|
this.beforeLoad = () => {
|
|
this.cancelMatches();
|
|
this.updateLatestLocation();
|
|
if (isServer ?? this.isServer) {
|
|
const nextLocation = this.buildLocation({
|
|
to: this.latestLocation.pathname,
|
|
search: true,
|
|
params: true,
|
|
hash: true,
|
|
state: true,
|
|
_includeValidateSearch: true
|
|
});
|
|
if (this.latestLocation.publicHref !== nextLocation.publicHref) {
|
|
const href = this.getParsedLocationHref(nextLocation);
|
|
if (nextLocation.external) {
|
|
throw redirect({ href });
|
|
} else {
|
|
throw redirect({ href, _builtLocation: nextLocation });
|
|
}
|
|
}
|
|
}
|
|
const pendingMatches = this.matchRoutes(this.latestLocation);
|
|
this.__store.setState((s) => ({
|
|
...s,
|
|
status: "pending",
|
|
statusCode: 200,
|
|
isLoading: true,
|
|
location: this.latestLocation,
|
|
pendingMatches,
|
|
// If a cached moved to pendingMatches, remove it from cachedMatches
|
|
cachedMatches: s.cachedMatches.filter(
|
|
(d) => !pendingMatches.some((e) => e.id === d.id)
|
|
)
|
|
}));
|
|
};
|
|
this.load = async (opts) => {
|
|
let redirect2;
|
|
let notFound2;
|
|
let loadPromise;
|
|
const previousLocation = this.state.resolvedLocation ?? this.state.location;
|
|
loadPromise = new Promise((resolve) => {
|
|
this.startTransition(async () => {
|
|
try {
|
|
this.beforeLoad();
|
|
const next = this.latestLocation;
|
|
const prevLocation = this.state.resolvedLocation;
|
|
if (!this.state.redirect) {
|
|
this.emit({
|
|
type: "onBeforeNavigate",
|
|
...getLocationChangeInfo({
|
|
resolvedLocation: prevLocation,
|
|
location: next
|
|
})
|
|
});
|
|
}
|
|
this.emit({
|
|
type: "onBeforeLoad",
|
|
...getLocationChangeInfo({
|
|
resolvedLocation: prevLocation,
|
|
location: next
|
|
})
|
|
});
|
|
await loadMatches({
|
|
router: this,
|
|
sync: opts?.sync,
|
|
forceStaleReload: previousLocation.href === next.href,
|
|
matches: this.state.pendingMatches,
|
|
location: next,
|
|
updateMatch: this.updateMatch,
|
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
onReady: async () => {
|
|
this.startTransition(() => {
|
|
this.startViewTransition(async () => {
|
|
let exitingMatches = [];
|
|
let hookExitingMatches = [];
|
|
let hookEnteringMatches = [];
|
|
let hookStayingMatches = [];
|
|
batch2(() => {
|
|
this.__store.setState((s) => {
|
|
const previousMatches = s.matches;
|
|
const newMatches = s.pendingMatches || s.matches;
|
|
exitingMatches = previousMatches.filter(
|
|
(match) => !newMatches.some((d) => d.id === match.id)
|
|
);
|
|
hookExitingMatches = previousMatches.filter(
|
|
(match) => !newMatches.some((d) => d.routeId === match.routeId)
|
|
);
|
|
hookEnteringMatches = newMatches.filter(
|
|
(match) => !previousMatches.some(
|
|
(d) => d.routeId === match.routeId
|
|
)
|
|
);
|
|
hookStayingMatches = newMatches.filter(
|
|
(match) => previousMatches.some(
|
|
(d) => d.routeId === match.routeId
|
|
)
|
|
);
|
|
return {
|
|
...s,
|
|
isLoading: false,
|
|
loadedAt: Date.now(),
|
|
matches: newMatches,
|
|
pendingMatches: void 0,
|
|
/**
|
|
* When committing new matches, cache any exiting matches that are still usable.
|
|
* Routes that resolved with `status: 'error'` or `status: 'notFound'` are
|
|
* deliberately excluded from `cachedMatches` so that subsequent invalidations
|
|
* or reloads re-run their loaders instead of reusing the failed/not-found data.
|
|
*/
|
|
cachedMatches: [
|
|
...s.cachedMatches,
|
|
...exitingMatches.filter(
|
|
(d) => d.status !== "error" && d.status !== "notFound" && d.status !== "redirected"
|
|
)
|
|
]
|
|
};
|
|
});
|
|
this.clearExpiredCache();
|
|
});
|
|
[
|
|
[hookExitingMatches, "onLeave"],
|
|
[hookEnteringMatches, "onEnter"],
|
|
[hookStayingMatches, "onStay"]
|
|
].forEach(([matches, hook]) => {
|
|
matches.forEach((match) => {
|
|
this.looseRoutesById[match.routeId].options[hook]?.(
|
|
match
|
|
);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}
|
|
});
|
|
} catch (err) {
|
|
if (isRedirect(err)) {
|
|
redirect2 = err;
|
|
if (!(isServer ?? this.isServer)) {
|
|
this.navigate({
|
|
...redirect2.options,
|
|
replace: true,
|
|
ignoreBlocker: true
|
|
});
|
|
}
|
|
} else if (isNotFound(err)) {
|
|
notFound2 = err;
|
|
}
|
|
this.__store.setState((s) => ({
|
|
...s,
|
|
statusCode: redirect2 ? redirect2.status : notFound2 ? 404 : s.matches.some((d) => d.status === "error") ? 500 : 200,
|
|
redirect: redirect2
|
|
}));
|
|
}
|
|
if (this.latestLoadPromise === loadPromise) {
|
|
this.commitLocationPromise?.resolve();
|
|
this.latestLoadPromise = void 0;
|
|
this.commitLocationPromise = void 0;
|
|
}
|
|
resolve();
|
|
});
|
|
});
|
|
this.latestLoadPromise = loadPromise;
|
|
await loadPromise;
|
|
while (this.latestLoadPromise && loadPromise !== this.latestLoadPromise) {
|
|
await this.latestLoadPromise;
|
|
}
|
|
let newStatusCode = void 0;
|
|
if (this.hasNotFoundMatch()) {
|
|
newStatusCode = 404;
|
|
} else if (this.__store.state.matches.some((d) => d.status === "error")) {
|
|
newStatusCode = 500;
|
|
}
|
|
if (newStatusCode !== void 0) {
|
|
this.__store.setState((s) => ({
|
|
...s,
|
|
statusCode: newStatusCode
|
|
}));
|
|
}
|
|
};
|
|
this.startViewTransition = (fn) => {
|
|
const shouldViewTransition = this.shouldViewTransition ?? this.options.defaultViewTransition;
|
|
this.shouldViewTransition = void 0;
|
|
if (shouldViewTransition && typeof document !== "undefined" && "startViewTransition" in document && typeof document.startViewTransition === "function") {
|
|
let startViewTransitionParams;
|
|
if (typeof shouldViewTransition === "object" && this.isViewTransitionTypesSupported) {
|
|
const next = this.latestLocation;
|
|
const prevLocation = this.state.resolvedLocation;
|
|
const resolvedViewTransitionTypes = typeof shouldViewTransition.types === "function" ? shouldViewTransition.types(
|
|
getLocationChangeInfo({
|
|
resolvedLocation: prevLocation,
|
|
location: next
|
|
})
|
|
) : shouldViewTransition.types;
|
|
if (resolvedViewTransitionTypes === false) {
|
|
fn();
|
|
return;
|
|
}
|
|
startViewTransitionParams = {
|
|
update: fn,
|
|
types: resolvedViewTransitionTypes
|
|
};
|
|
} else {
|
|
startViewTransitionParams = fn;
|
|
}
|
|
document.startViewTransition(startViewTransitionParams);
|
|
} else {
|
|
fn();
|
|
}
|
|
};
|
|
this.updateMatch = (id, updater) => {
|
|
this.startTransition(() => {
|
|
const matchesKey = this.state.pendingMatches?.some((d) => d.id === id) ? "pendingMatches" : this.state.matches.some((d) => d.id === id) ? "matches" : this.state.cachedMatches.some((d) => d.id === id) ? "cachedMatches" : "";
|
|
if (matchesKey) {
|
|
if (matchesKey === "cachedMatches") {
|
|
this.__store.setState((s) => ({
|
|
...s,
|
|
cachedMatches: filterRedirectedCachedMatches(
|
|
s.cachedMatches.map((d) => d.id === id ? updater(d) : d)
|
|
)
|
|
}));
|
|
} else {
|
|
this.__store.setState((s) => ({
|
|
...s,
|
|
[matchesKey]: s[matchesKey]?.map(
|
|
(d) => d.id === id ? updater(d) : d
|
|
)
|
|
}));
|
|
}
|
|
}
|
|
});
|
|
};
|
|
this.getMatch = (matchId) => {
|
|
const findFn = (d) => d.id === matchId;
|
|
return this.state.cachedMatches.find(findFn) ?? this.state.pendingMatches?.find(findFn) ?? this.state.matches.find(findFn);
|
|
};
|
|
this.invalidate = (opts) => {
|
|
const invalidate = (d) => {
|
|
if (opts?.filter?.(d) ?? true) {
|
|
return {
|
|
...d,
|
|
invalid: true,
|
|
...opts?.forcePending || d.status === "error" || d.status === "notFound" ? { status: "pending", error: void 0 } : void 0
|
|
};
|
|
}
|
|
return d;
|
|
};
|
|
this.__store.setState((s) => ({
|
|
...s,
|
|
matches: s.matches.map(invalidate),
|
|
cachedMatches: s.cachedMatches.map(invalidate),
|
|
pendingMatches: s.pendingMatches?.map(invalidate)
|
|
}));
|
|
this.shouldViewTransition = false;
|
|
return this.load({ sync: opts?.sync });
|
|
};
|
|
this.getParsedLocationHref = (location) => {
|
|
return location.publicHref || "/";
|
|
};
|
|
this.resolveRedirect = (redirect2) => {
|
|
const locationHeader = redirect2.headers.get("Location");
|
|
if (!redirect2.options.href || redirect2.options._builtLocation) {
|
|
const location = redirect2.options._builtLocation ?? this.buildLocation(redirect2.options);
|
|
const href = this.getParsedLocationHref(location);
|
|
redirect2.options.href = href;
|
|
redirect2.headers.set("Location", href);
|
|
} else if (locationHeader) {
|
|
try {
|
|
const url = new URL(locationHeader);
|
|
if (this.origin && url.origin === this.origin) {
|
|
const href = url.pathname + url.search + url.hash;
|
|
redirect2.options.href = href;
|
|
redirect2.headers.set("Location", href);
|
|
}
|
|
} catch {
|
|
}
|
|
}
|
|
if (redirect2.options.href && !redirect2.options._builtLocation && // Check for dangerous protocols before processing the redirect
|
|
isDangerousProtocol(redirect2.options.href, this.protocolAllowlist)) {
|
|
throw new Error(
|
|
true ? `Redirect blocked: unsafe protocol in href "${redirect2.options.href}". Allowed protocols: ${Array.from(this.protocolAllowlist).join(", ")}.` : "Redirect blocked: unsafe protocol"
|
|
);
|
|
}
|
|
if (!redirect2.headers.get("Location")) {
|
|
redirect2.headers.set("Location", redirect2.options.href);
|
|
}
|
|
return redirect2;
|
|
};
|
|
this.clearCache = (opts) => {
|
|
const filter = opts?.filter;
|
|
if (filter !== void 0) {
|
|
this.__store.setState((s) => {
|
|
return {
|
|
...s,
|
|
cachedMatches: s.cachedMatches.filter(
|
|
(m) => !filter(m)
|
|
)
|
|
};
|
|
});
|
|
} else {
|
|
this.__store.setState((s) => {
|
|
return {
|
|
...s,
|
|
cachedMatches: []
|
|
};
|
|
});
|
|
}
|
|
};
|
|
this.clearExpiredCache = () => {
|
|
const filter = (d) => {
|
|
const route = this.looseRoutesById[d.routeId];
|
|
if (!route.options.loader) {
|
|
return true;
|
|
}
|
|
const gcTime = (d.preload ? route.options.preloadGcTime ?? this.options.defaultPreloadGcTime : route.options.gcTime ?? this.options.defaultGcTime) ?? 5 * 60 * 1e3;
|
|
const isError = d.status === "error";
|
|
if (isError) return true;
|
|
const gcEligible = Date.now() - d.updatedAt >= gcTime;
|
|
return gcEligible;
|
|
};
|
|
this.clearCache({ filter });
|
|
};
|
|
this.loadRouteChunk = loadRouteChunk;
|
|
this.preloadRoute = async (opts) => {
|
|
const next = opts._builtLocation ?? this.buildLocation(opts);
|
|
let matches = this.matchRoutes(next, {
|
|
throwOnError: true,
|
|
preload: true,
|
|
dest: opts
|
|
});
|
|
const activeMatchIds = new Set(
|
|
[...this.state.matches, ...this.state.pendingMatches ?? []].map(
|
|
(d) => d.id
|
|
)
|
|
);
|
|
const loadedMatchIds = /* @__PURE__ */ new Set([
|
|
...activeMatchIds,
|
|
...this.state.cachedMatches.map((d) => d.id)
|
|
]);
|
|
batch2(() => {
|
|
matches.forEach((match) => {
|
|
if (!loadedMatchIds.has(match.id)) {
|
|
this.__store.setState((s) => ({
|
|
...s,
|
|
cachedMatches: [...s.cachedMatches, match]
|
|
}));
|
|
}
|
|
});
|
|
});
|
|
try {
|
|
matches = await loadMatches({
|
|
router: this,
|
|
matches,
|
|
location: next,
|
|
preload: true,
|
|
updateMatch: (id, updater) => {
|
|
if (activeMatchIds.has(id)) {
|
|
matches = matches.map((d) => d.id === id ? updater(d) : d);
|
|
} else {
|
|
this.updateMatch(id, updater);
|
|
}
|
|
}
|
|
});
|
|
return matches;
|
|
} catch (err) {
|
|
if (isRedirect(err)) {
|
|
if (err.options.reloadDocument) {
|
|
return void 0;
|
|
}
|
|
return await this.preloadRoute({
|
|
...err.options,
|
|
_fromLocation: next
|
|
});
|
|
}
|
|
if (!isNotFound(err)) {
|
|
console.error(err);
|
|
}
|
|
return void 0;
|
|
}
|
|
};
|
|
this.matchRoute = (location, opts) => {
|
|
const matchLocation = {
|
|
...location,
|
|
to: location.to ? this.resolvePathWithBase(location.from || "", location.to) : void 0,
|
|
params: location.params || {},
|
|
leaveParams: true
|
|
};
|
|
const next = this.buildLocation(matchLocation);
|
|
if (opts?.pending && this.state.status !== "pending") {
|
|
return false;
|
|
}
|
|
const pending = opts?.pending === void 0 ? !this.state.isLoading : opts.pending;
|
|
const baseLocation = pending ? this.latestLocation : this.state.resolvedLocation || this.state.location;
|
|
const match = findSingleMatch(
|
|
next.pathname,
|
|
opts?.caseSensitive ?? false,
|
|
opts?.fuzzy ?? false,
|
|
baseLocation.pathname,
|
|
this.processedTree
|
|
);
|
|
if (!match) {
|
|
return false;
|
|
}
|
|
if (location.params) {
|
|
if (!deepEqual(match.rawParams, location.params, { partial: true })) {
|
|
return false;
|
|
}
|
|
}
|
|
if (opts?.includeSearch ?? true) {
|
|
return deepEqual(baseLocation.search, next.search, { partial: true }) ? match.rawParams : false;
|
|
}
|
|
return match.rawParams;
|
|
};
|
|
this.hasNotFoundMatch = () => {
|
|
return this.__store.state.matches.some(
|
|
(d) => d.status === "notFound" || d.globalNotFound
|
|
);
|
|
};
|
|
this.update({
|
|
defaultPreloadDelay: 50,
|
|
defaultPendingMs: 1e3,
|
|
defaultPendingMinMs: 500,
|
|
context: void 0,
|
|
...options,
|
|
caseSensitive: options.caseSensitive ?? false,
|
|
notFoundMode: options.notFoundMode ?? "fuzzy",
|
|
stringifySearch: options.stringifySearch ?? defaultStringifySearch,
|
|
parseSearch: options.parseSearch ?? defaultParseSearch,
|
|
protocolAllowlist: options.protocolAllowlist ?? DEFAULT_PROTOCOL_ALLOWLIST
|
|
});
|
|
if (typeof document !== "undefined") {
|
|
self.__TSR_ROUTER__ = this;
|
|
}
|
|
}
|
|
isShell() {
|
|
return !!this.options.isShell;
|
|
}
|
|
isPrerendering() {
|
|
return !!this.options.isPrerendering;
|
|
}
|
|
get state() {
|
|
return this.__store.state;
|
|
}
|
|
setRoutes({
|
|
routesById,
|
|
routesByPath,
|
|
processedTree
|
|
}) {
|
|
this.routesById = routesById;
|
|
this.routesByPath = routesByPath;
|
|
this.processedTree = processedTree;
|
|
const notFoundRoute = this.options.notFoundRoute;
|
|
if (notFoundRoute) {
|
|
notFoundRoute.init({
|
|
originalIndex: 99999999999
|
|
});
|
|
this.routesById[notFoundRoute.id] = notFoundRoute;
|
|
}
|
|
}
|
|
get looseRoutesById() {
|
|
return this.routesById;
|
|
}
|
|
getParentContext(parentMatch) {
|
|
const parentMatchId = parentMatch?.id;
|
|
const parentContext = !parentMatchId ? this.options.context ?? void 0 : parentMatch.context ?? this.options.context ?? void 0;
|
|
return parentContext;
|
|
}
|
|
matchRoutesInternal(next, opts) {
|
|
const matchedRoutesResult = this.getMatchedRoutes(next.pathname);
|
|
const { foundRoute, routeParams, parsedParams } = matchedRoutesResult;
|
|
let { matchedRoutes } = matchedRoutesResult;
|
|
let isGlobalNotFound = false;
|
|
if (
|
|
// If we found a route, and it's not an index route and we have left over path
|
|
foundRoute ? foundRoute.path !== "/" && routeParams["**"] : (
|
|
// Or if we didn't find a route and we have left over path
|
|
trimPathRight2(next.pathname)
|
|
)
|
|
) {
|
|
if (this.options.notFoundRoute) {
|
|
matchedRoutes = [...matchedRoutes, this.options.notFoundRoute];
|
|
} else {
|
|
isGlobalNotFound = true;
|
|
}
|
|
}
|
|
const globalNotFoundRouteId = isGlobalNotFound ? findGlobalNotFoundRouteId(this.options.notFoundMode, matchedRoutes) : void 0;
|
|
const matches = new Array(matchedRoutes.length);
|
|
const previousMatchesByRouteId = new Map(
|
|
this.state.matches.map((match) => [match.routeId, match])
|
|
);
|
|
for (let index = 0; index < matchedRoutes.length; index++) {
|
|
const route = matchedRoutes[index];
|
|
const parentMatch = matches[index - 1];
|
|
let preMatchSearch;
|
|
let strictMatchSearch;
|
|
let searchError;
|
|
{
|
|
const parentSearch = parentMatch?.search ?? next.search;
|
|
const parentStrictSearch = parentMatch?._strictSearch ?? void 0;
|
|
try {
|
|
const strictSearch = validateSearch(route.options.validateSearch, { ...parentSearch }) ?? void 0;
|
|
preMatchSearch = {
|
|
...parentSearch,
|
|
...strictSearch
|
|
};
|
|
strictMatchSearch = { ...parentStrictSearch, ...strictSearch };
|
|
searchError = void 0;
|
|
} catch (err) {
|
|
let searchParamError = err;
|
|
if (!(err instanceof SearchParamError)) {
|
|
searchParamError = new SearchParamError(err.message, {
|
|
cause: err
|
|
});
|
|
}
|
|
if (opts?.throwOnError) {
|
|
throw searchParamError;
|
|
}
|
|
preMatchSearch = parentSearch;
|
|
strictMatchSearch = {};
|
|
searchError = searchParamError;
|
|
}
|
|
}
|
|
const loaderDeps = route.options.loaderDeps?.({
|
|
search: preMatchSearch
|
|
}) ?? "";
|
|
const loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) : "";
|
|
const { interpolatedPath, usedParams } = interpolatePath({
|
|
path: route.fullPath,
|
|
params: routeParams,
|
|
decoder: this.pathParamsDecoder,
|
|
server: this.isServer
|
|
});
|
|
const matchId = (
|
|
// route.id for disambiguation
|
|
route.id + // interpolatedPath for param changes
|
|
interpolatedPath + // explicit deps
|
|
loaderDepsHash
|
|
);
|
|
const existingMatch = this.getMatch(matchId);
|
|
const previousMatch = previousMatchesByRouteId.get(route.id);
|
|
const strictParams = existingMatch?._strictParams ?? usedParams;
|
|
let paramsError = void 0;
|
|
if (!existingMatch) {
|
|
try {
|
|
extractStrictParams(route, usedParams, parsedParams, strictParams);
|
|
} catch (err) {
|
|
if (isNotFound(err) || isRedirect(err)) {
|
|
paramsError = err;
|
|
} else {
|
|
paramsError = new PathParamError(err.message, {
|
|
cause: err
|
|
});
|
|
}
|
|
if (opts?.throwOnError) {
|
|
throw paramsError;
|
|
}
|
|
}
|
|
}
|
|
Object.assign(routeParams, strictParams);
|
|
const cause = previousMatch ? "stay" : "enter";
|
|
let match;
|
|
if (existingMatch) {
|
|
match = {
|
|
...existingMatch,
|
|
cause,
|
|
params: previousMatch?.params ?? routeParams,
|
|
_strictParams: strictParams,
|
|
search: previousMatch ? replaceEqualDeep(previousMatch.search, preMatchSearch) : replaceEqualDeep(existingMatch.search, preMatchSearch),
|
|
_strictSearch: strictMatchSearch
|
|
};
|
|
} else {
|
|
const status = route.options.loader || route.options.beforeLoad || route.lazyFn || routeNeedsPreload(route) ? "pending" : "success";
|
|
match = {
|
|
id: matchId,
|
|
ssr: isServer ?? this.isServer ? void 0 : route.options.ssr,
|
|
index,
|
|
routeId: route.id,
|
|
params: previousMatch?.params ?? routeParams,
|
|
_strictParams: strictParams,
|
|
pathname: interpolatedPath,
|
|
updatedAt: Date.now(),
|
|
search: previousMatch ? replaceEqualDeep(previousMatch.search, preMatchSearch) : preMatchSearch,
|
|
_strictSearch: strictMatchSearch,
|
|
searchError: void 0,
|
|
status,
|
|
isFetching: false,
|
|
error: void 0,
|
|
paramsError,
|
|
__routeContext: void 0,
|
|
_nonReactive: {
|
|
loadPromise: createControlledPromise()
|
|
},
|
|
__beforeLoadContext: void 0,
|
|
context: {},
|
|
abortController: new AbortController(),
|
|
fetchCount: 0,
|
|
cause,
|
|
loaderDeps: previousMatch ? replaceEqualDeep(previousMatch.loaderDeps, loaderDeps) : loaderDeps,
|
|
invalid: false,
|
|
preload: false,
|
|
links: void 0,
|
|
scripts: void 0,
|
|
headScripts: void 0,
|
|
meta: void 0,
|
|
staticData: route.options.staticData || {},
|
|
fullPath: route.fullPath
|
|
};
|
|
}
|
|
if (!opts?.preload) {
|
|
match.globalNotFound = globalNotFoundRouteId === route.id;
|
|
}
|
|
match.searchError = searchError;
|
|
const parentContext = this.getParentContext(parentMatch);
|
|
match.context = {
|
|
...parentContext,
|
|
...match.__routeContext,
|
|
...match.__beforeLoadContext
|
|
};
|
|
matches[index] = match;
|
|
}
|
|
for (let index = 0; index < matches.length; index++) {
|
|
const match = matches[index];
|
|
const route = this.looseRoutesById[match.routeId];
|
|
const existingMatch = this.getMatch(match.id);
|
|
const previousMatch = previousMatchesByRouteId.get(match.routeId);
|
|
match.params = previousMatch ? replaceEqualDeep(previousMatch.params, routeParams) : routeParams;
|
|
if (!existingMatch) {
|
|
const parentMatch = matches[index - 1];
|
|
const parentContext = this.getParentContext(parentMatch);
|
|
if (route.options.context) {
|
|
const contextFnContext = {
|
|
deps: match.loaderDeps,
|
|
params: match.params,
|
|
context: parentContext ?? {},
|
|
location: next,
|
|
navigate: (opts2) => this.navigate({ ...opts2, _fromLocation: next }),
|
|
buildLocation: this.buildLocation,
|
|
cause: match.cause,
|
|
abortController: match.abortController,
|
|
preload: !!match.preload,
|
|
matches,
|
|
routeId: route.id
|
|
};
|
|
match.__routeContext = route.options.context(contextFnContext) ?? void 0;
|
|
}
|
|
match.context = {
|
|
...parentContext,
|
|
...match.__routeContext,
|
|
...match.__beforeLoadContext
|
|
};
|
|
}
|
|
}
|
|
return matches;
|
|
}
|
|
/**
|
|
* Lightweight route matching for buildLocation.
|
|
* Only computes fullPath, accumulated search, and params - skipping expensive
|
|
* operations like AbortController, ControlledPromise, loaderDeps, and full match objects.
|
|
*/
|
|
matchRoutesLightweight(location) {
|
|
const { matchedRoutes, routeParams, parsedParams } = this.getMatchedRoutes(
|
|
location.pathname
|
|
);
|
|
const lastRoute = last(matchedRoutes);
|
|
const accumulatedSearch = { ...location.search };
|
|
for (const route of matchedRoutes) {
|
|
try {
|
|
Object.assign(
|
|
accumulatedSearch,
|
|
validateSearch(route.options.validateSearch, accumulatedSearch)
|
|
);
|
|
} catch {
|
|
}
|
|
}
|
|
const lastStateMatch = last(this.state.matches);
|
|
const canReuseParams = lastStateMatch && lastStateMatch.routeId === lastRoute.id && location.pathname === this.state.location.pathname;
|
|
let params;
|
|
if (canReuseParams) {
|
|
params = lastStateMatch.params;
|
|
} else {
|
|
const strictParams = { ...routeParams };
|
|
for (const route of matchedRoutes) {
|
|
try {
|
|
extractStrictParams(
|
|
route,
|
|
routeParams,
|
|
parsedParams ?? {},
|
|
strictParams
|
|
);
|
|
} catch {
|
|
}
|
|
}
|
|
params = strictParams;
|
|
}
|
|
return {
|
|
matchedRoutes,
|
|
fullPath: lastRoute.fullPath,
|
|
search: accumulatedSearch,
|
|
params
|
|
};
|
|
}
|
|
};
|
|
var SearchParamError = class extends Error {
|
|
};
|
|
var PathParamError = class extends Error {
|
|
};
|
|
var normalize = (str) => str.endsWith("/") && str.length > 1 ? str.slice(0, -1) : str;
|
|
function comparePaths(a, b) {
|
|
return normalize(a) === normalize(b);
|
|
}
|
|
function lazyFn(fn, key) {
|
|
return async (...args) => {
|
|
const imported = await fn();
|
|
return imported[key || "default"](...args);
|
|
};
|
|
}
|
|
function getInitialRouterState(location) {
|
|
return {
|
|
loadedAt: 0,
|
|
isLoading: false,
|
|
isTransitioning: false,
|
|
status: "idle",
|
|
resolvedLocation: void 0,
|
|
location,
|
|
matches: [],
|
|
pendingMatches: [],
|
|
cachedMatches: [],
|
|
statusCode: 200
|
|
};
|
|
}
|
|
function validateSearch(validateSearch2, input) {
|
|
if (validateSearch2 == null) return {};
|
|
if ("~standard" in validateSearch2) {
|
|
const result = validateSearch2["~standard"].validate(input);
|
|
if (result instanceof Promise)
|
|
throw new SearchParamError("Async validation not supported");
|
|
if (result.issues)
|
|
throw new SearchParamError(JSON.stringify(result.issues, void 0, 2), {
|
|
cause: result
|
|
});
|
|
return result.value;
|
|
}
|
|
if ("parse" in validateSearch2) {
|
|
return validateSearch2.parse(input);
|
|
}
|
|
if (typeof validateSearch2 === "function") {
|
|
return validateSearch2(input);
|
|
}
|
|
return {};
|
|
}
|
|
function getMatchedRoutes({
|
|
pathname,
|
|
routesById,
|
|
processedTree
|
|
}) {
|
|
const routeParams = {};
|
|
const trimmedPath = trimPathRight2(pathname);
|
|
let foundRoute = void 0;
|
|
let parsedParams = void 0;
|
|
const match = findRouteMatch(trimmedPath, processedTree, true);
|
|
if (match) {
|
|
foundRoute = match.route;
|
|
Object.assign(routeParams, match.rawParams);
|
|
parsedParams = Object.assign({}, match.parsedParams);
|
|
}
|
|
const matchedRoutes = match?.branch || [routesById[rootRouteId]];
|
|
return { matchedRoutes, routeParams, foundRoute, parsedParams };
|
|
}
|
|
function applySearchMiddleware({
|
|
search,
|
|
dest,
|
|
destRoutes,
|
|
_includeValidateSearch
|
|
}) {
|
|
const middleware = buildMiddlewareChain(destRoutes);
|
|
return middleware(search, dest, _includeValidateSearch ?? false);
|
|
}
|
|
function buildMiddlewareChain(destRoutes) {
|
|
const context = {
|
|
dest: null,
|
|
_includeValidateSearch: false,
|
|
middlewares: []
|
|
};
|
|
for (const route of destRoutes) {
|
|
if ("search" in route.options) {
|
|
if (route.options.search?.middlewares) {
|
|
context.middlewares.push(...route.options.search.middlewares);
|
|
}
|
|
} else if (route.options.preSearchFilters || route.options.postSearchFilters) {
|
|
const legacyMiddleware = ({ search, next }) => {
|
|
let nextSearch = search;
|
|
if ("preSearchFilters" in route.options && route.options.preSearchFilters) {
|
|
nextSearch = route.options.preSearchFilters.reduce(
|
|
(prev, next2) => next2(prev),
|
|
search
|
|
);
|
|
}
|
|
const result = next(nextSearch);
|
|
if ("postSearchFilters" in route.options && route.options.postSearchFilters) {
|
|
return route.options.postSearchFilters.reduce(
|
|
(prev, next2) => next2(prev),
|
|
result
|
|
);
|
|
}
|
|
return result;
|
|
};
|
|
context.middlewares.push(legacyMiddleware);
|
|
}
|
|
if (route.options.validateSearch) {
|
|
const validate = ({ search, next }) => {
|
|
const result = next(search);
|
|
if (!context._includeValidateSearch) return result;
|
|
try {
|
|
const validatedSearch = {
|
|
...result,
|
|
...validateSearch(route.options.validateSearch, result) ?? void 0
|
|
};
|
|
return validatedSearch;
|
|
} catch {
|
|
return result;
|
|
}
|
|
};
|
|
context.middlewares.push(validate);
|
|
}
|
|
}
|
|
const final = ({ search }) => {
|
|
const dest = context.dest;
|
|
if (!dest.search) {
|
|
return {};
|
|
}
|
|
if (dest.search === true) {
|
|
return search;
|
|
}
|
|
return functionalUpdate(dest.search, search);
|
|
};
|
|
context.middlewares.push(final);
|
|
const applyNext = (index, currentSearch, middlewares) => {
|
|
if (index >= middlewares.length) {
|
|
return currentSearch;
|
|
}
|
|
const middleware = middlewares[index];
|
|
const next = (newSearch) => {
|
|
return applyNext(index + 1, newSearch, middlewares);
|
|
};
|
|
return middleware({ search: currentSearch, next });
|
|
};
|
|
return function middleware(search, dest, _includeValidateSearch) {
|
|
context.dest = dest;
|
|
context._includeValidateSearch = _includeValidateSearch;
|
|
return applyNext(0, search, context.middlewares);
|
|
};
|
|
}
|
|
function findGlobalNotFoundRouteId(notFoundMode, routes) {
|
|
if (notFoundMode !== "root") {
|
|
for (let i = routes.length - 1; i >= 0; i--) {
|
|
const route = routes[i];
|
|
if (route.children) {
|
|
return route.id;
|
|
}
|
|
}
|
|
}
|
|
return rootRouteId;
|
|
}
|
|
function extractStrictParams(route, referenceParams, parsedParams, accumulatedParams) {
|
|
const parseParams = route.options.params?.parse ?? route.options.parseParams;
|
|
if (parseParams) {
|
|
if (route.options.skipRouteOnParseError) {
|
|
for (const key in referenceParams) {
|
|
if (key in parsedParams) {
|
|
accumulatedParams[key] = parsedParams[key];
|
|
}
|
|
}
|
|
} else {
|
|
const result = parseParams(accumulatedParams);
|
|
Object.assign(accumulatedParams, result);
|
|
}
|
|
}
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/defer.js
|
|
var TSR_DEFERRED_PROMISE = /* @__PURE__ */ Symbol.for("TSR_DEFERRED_PROMISE");
|
|
function defer(_promise, options) {
|
|
const promise = _promise;
|
|
if (promise[TSR_DEFERRED_PROMISE]) {
|
|
return promise;
|
|
}
|
|
promise[TSR_DEFERRED_PROMISE] = { status: "pending" };
|
|
promise.then((data) => {
|
|
promise[TSR_DEFERRED_PROMISE].status = "success";
|
|
promise[TSR_DEFERRED_PROMISE].data = data;
|
|
}).catch((error) => {
|
|
promise[TSR_DEFERRED_PROMISE].status = "error";
|
|
promise[TSR_DEFERRED_PROMISE].error = {
|
|
data: (options?.serializeError ?? defaultSerializeError)(error),
|
|
__isServerError: true
|
|
};
|
|
});
|
|
return promise;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/link.js
|
|
var preloadWarning = "Error preloading route! ☝️";
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/Matches.js
|
|
var isMatch = (match, path) => {
|
|
const parts = path.split(".");
|
|
let part;
|
|
let i = 0;
|
|
let value = match;
|
|
while ((part = parts[i++]) != null && value != null) {
|
|
value = value[part];
|
|
}
|
|
return value != null;
|
|
};
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/route.js
|
|
var BaseRoute = class {
|
|
constructor(options) {
|
|
this.init = (opts) => {
|
|
this.originalIndex = opts.originalIndex;
|
|
const options2 = this.options;
|
|
const isRoot = !options2?.path && !options2?.id;
|
|
this.parentRoute = this.options.getParentRoute?.();
|
|
if (isRoot) {
|
|
this._path = rootRouteId;
|
|
} else if (!this.parentRoute) {
|
|
invariant(
|
|
false,
|
|
`Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`
|
|
);
|
|
}
|
|
let path = isRoot ? rootRouteId : options2?.path;
|
|
if (path && path !== "/") {
|
|
path = trimPathLeft(path);
|
|
}
|
|
const customId = options2?.id || path;
|
|
let id = isRoot ? rootRouteId : joinPaths([
|
|
this.parentRoute.id === rootRouteId ? "" : this.parentRoute.id,
|
|
customId
|
|
]);
|
|
if (path === rootRouteId) {
|
|
path = "/";
|
|
}
|
|
if (id !== rootRouteId) {
|
|
id = joinPaths(["/", id]);
|
|
}
|
|
const fullPath = id === rootRouteId ? "/" : joinPaths([this.parentRoute.fullPath, path]);
|
|
this._path = path;
|
|
this._id = id;
|
|
this._fullPath = fullPath;
|
|
this._to = trimPathRight2(fullPath);
|
|
};
|
|
this.addChildren = (children) => {
|
|
return this._addFileChildren(children);
|
|
};
|
|
this._addFileChildren = (children) => {
|
|
if (Array.isArray(children)) {
|
|
this.children = children;
|
|
}
|
|
if (typeof children === "object" && children !== null) {
|
|
this.children = Object.values(children);
|
|
}
|
|
return this;
|
|
};
|
|
this._addFileTypes = () => {
|
|
return this;
|
|
};
|
|
this.updateLoader = (options2) => {
|
|
Object.assign(this.options, options2);
|
|
return this;
|
|
};
|
|
this.update = (options2) => {
|
|
Object.assign(this.options, options2);
|
|
return this;
|
|
};
|
|
this.lazy = (lazyFn2) => {
|
|
this.lazyFn = lazyFn2;
|
|
return this;
|
|
};
|
|
this.redirect = (opts) => redirect({ from: this.fullPath, ...opts });
|
|
this.options = options || {};
|
|
this.isRoot = !options?.getParentRoute;
|
|
if (options?.id && options?.path) {
|
|
throw new Error(`Route cannot have both an 'id' and a 'path' option.`);
|
|
}
|
|
}
|
|
get to() {
|
|
return this._to;
|
|
}
|
|
get id() {
|
|
return this._id;
|
|
}
|
|
get path() {
|
|
return this._path;
|
|
}
|
|
get fullPath() {
|
|
return this._fullPath;
|
|
}
|
|
};
|
|
var BaseRouteApi = class {
|
|
constructor({ id }) {
|
|
this.notFound = (opts) => {
|
|
return notFound({ routeId: this.id, ...opts });
|
|
};
|
|
this.redirect = (opts) => redirect({ from: this.id, ...opts });
|
|
this.id = id;
|
|
}
|
|
};
|
|
var BaseRootRoute = class extends BaseRoute {
|
|
constructor(options) {
|
|
super(options);
|
|
}
|
|
};
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/config.js
|
|
var createRouterConfig = (options) => {
|
|
return {
|
|
serializationAdapters: options.serializationAdapters,
|
|
defaultSsr: options.defaultSsr
|
|
};
|
|
};
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/searchMiddleware.js
|
|
function retainSearchParams(keys) {
|
|
return ({ search, next }) => {
|
|
const result = next(search);
|
|
if (keys === true) {
|
|
return { ...search, ...result };
|
|
}
|
|
const copy = { ...result };
|
|
keys.forEach((key) => {
|
|
if (!(key in copy)) {
|
|
copy[key] = search[key];
|
|
}
|
|
});
|
|
return copy;
|
|
};
|
|
}
|
|
function stripSearchParams(input) {
|
|
return ({ search, next }) => {
|
|
if (input === true) {
|
|
return {};
|
|
}
|
|
const result = { ...next(search) };
|
|
if (Array.isArray(input)) {
|
|
input.forEach((key) => {
|
|
delete result[key];
|
|
});
|
|
} else {
|
|
Object.entries(input).forEach(
|
|
([key, value]) => {
|
|
if (deepEqual(result[key], value)) {
|
|
delete result[key];
|
|
}
|
|
}
|
|
);
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/seroval@1.5.1/node_modules/seroval/dist/esm/development/index.mjs
|
|
var Feature = ((Feature2) => {
|
|
Feature2[Feature2["AggregateError"] = 1] = "AggregateError";
|
|
Feature2[Feature2["ArrowFunction"] = 2] = "ArrowFunction";
|
|
Feature2[Feature2["ErrorPrototypeStack"] = 4] = "ErrorPrototypeStack";
|
|
Feature2[Feature2["ObjectAssign"] = 8] = "ObjectAssign";
|
|
Feature2[Feature2["BigIntTypedArray"] = 16] = "BigIntTypedArray";
|
|
Feature2[Feature2["RegExp"] = 32] = "RegExp";
|
|
return Feature2;
|
|
})(Feature || {});
|
|
var ALL_ENABLED = 1 | 2 | 4 | 8 | 16 | 32;
|
|
var SYM_ASYNC_ITERATOR = Symbol.asyncIterator;
|
|
var SYM_HAS_INSTANCE = Symbol.hasInstance;
|
|
var SYM_IS_CONCAT_SPREADABLE = Symbol.isConcatSpreadable;
|
|
var SYM_ITERATOR = Symbol.iterator;
|
|
var SYM_MATCH = Symbol.match;
|
|
var SYM_MATCH_ALL = Symbol.matchAll;
|
|
var SYM_REPLACE = Symbol.replace;
|
|
var SYM_SEARCH = Symbol.search;
|
|
var SYM_SPECIES = Symbol.species;
|
|
var SYM_SPLIT = Symbol.split;
|
|
var SYM_TO_PRIMITIVE = Symbol.toPrimitive;
|
|
var SYM_TO_STRING_TAG = Symbol.toStringTag;
|
|
var SYM_UNSCOPABLES = Symbol.unscopables;
|
|
var INV_SYMBOL_REF = {
|
|
[SYM_ASYNC_ITERATOR]: 0,
|
|
[SYM_HAS_INSTANCE]: 1,
|
|
[SYM_IS_CONCAT_SPREADABLE]: 2,
|
|
[SYM_ITERATOR]: 3,
|
|
[SYM_MATCH]: 4,
|
|
[SYM_MATCH_ALL]: 5,
|
|
[SYM_REPLACE]: 6,
|
|
[SYM_SEARCH]: 7,
|
|
[SYM_SPECIES]: 8,
|
|
[SYM_SPLIT]: 9,
|
|
[SYM_TO_PRIMITIVE]: 10,
|
|
[SYM_TO_STRING_TAG]: 11,
|
|
[SYM_UNSCOPABLES]: 12
|
|
/* Unscopables */
|
|
};
|
|
var NIL = void 0;
|
|
var CONSTANT_VAL = {
|
|
[
|
|
2
|
|
/* True */
|
|
]: true,
|
|
[
|
|
3
|
|
/* False */
|
|
]: false,
|
|
[
|
|
1
|
|
/* Undefined */
|
|
]: NIL,
|
|
[
|
|
0
|
|
/* Null */
|
|
]: null,
|
|
[
|
|
4
|
|
/* NegZero */
|
|
]: -0,
|
|
[
|
|
5
|
|
/* Inf */
|
|
]: Number.POSITIVE_INFINITY,
|
|
[
|
|
6
|
|
/* NegInf */
|
|
]: Number.NEGATIVE_INFINITY,
|
|
[
|
|
7
|
|
/* Nan */
|
|
]: Number.NaN
|
|
};
|
|
function createSerovalNode(t, i, s, c, m, p, e, a, f, b, o, l) {
|
|
return {
|
|
t,
|
|
i,
|
|
s,
|
|
c,
|
|
m,
|
|
p,
|
|
e,
|
|
a,
|
|
f,
|
|
b,
|
|
o,
|
|
l
|
|
};
|
|
}
|
|
function createConstantNode(value) {
|
|
return createSerovalNode(
|
|
2,
|
|
NIL,
|
|
value,
|
|
NIL,
|
|
NIL,
|
|
NIL,
|
|
NIL,
|
|
NIL,
|
|
NIL,
|
|
NIL,
|
|
NIL,
|
|
NIL
|
|
);
|
|
}
|
|
var TRUE_NODE = createConstantNode(
|
|
2
|
|
/* True */
|
|
);
|
|
var FALSE_NODE = createConstantNode(
|
|
3
|
|
/* False */
|
|
);
|
|
var UNDEFINED_NODE = createConstantNode(
|
|
1
|
|
/* Undefined */
|
|
);
|
|
var NULL_NODE = createConstantNode(
|
|
0
|
|
/* Null */
|
|
);
|
|
var NEG_ZERO_NODE = createConstantNode(
|
|
4
|
|
/* NegZero */
|
|
);
|
|
var INFINITY_NODE = createConstantNode(
|
|
5
|
|
/* Inf */
|
|
);
|
|
var NEG_INFINITY_NODE = createConstantNode(
|
|
6
|
|
/* NegInf */
|
|
);
|
|
var NAN_NODE = createConstantNode(
|
|
7
|
|
/* Nan */
|
|
);
|
|
var REFERENCES_KEY = "__SEROVAL_REFS__";
|
|
var GLOBAL_CONTEXT_REFERENCES = "$R";
|
|
var GLOBAL_CONTEXT_R = `self.${GLOBAL_CONTEXT_REFERENCES}`;
|
|
var INV_REFERENCE = /* @__PURE__ */ new Map();
|
|
if (typeof globalThis !== "undefined") {
|
|
Object.defineProperty(globalThis, REFERENCES_KEY, {
|
|
value: INV_REFERENCE,
|
|
configurable: true,
|
|
writable: false,
|
|
enumerable: false
|
|
});
|
|
} else if (typeof window !== "undefined") {
|
|
Object.defineProperty(window, REFERENCES_KEY, {
|
|
value: INV_REFERENCE,
|
|
configurable: true,
|
|
writable: false,
|
|
enumerable: false
|
|
});
|
|
} else if (typeof self !== "undefined") {
|
|
Object.defineProperty(self, REFERENCES_KEY, {
|
|
value: INV_REFERENCE,
|
|
configurable: true,
|
|
writable: false,
|
|
enumerable: false
|
|
});
|
|
} else if (typeof global !== "undefined") {
|
|
Object.defineProperty(global, REFERENCES_KEY, {
|
|
value: INV_REFERENCE,
|
|
configurable: true,
|
|
writable: false,
|
|
enumerable: false
|
|
});
|
|
}
|
|
var { toString: objectToString } = Object.prototype;
|
|
var PROMISE_CONSTRUCTOR = () => {
|
|
const resolver = {
|
|
p: 0,
|
|
s: 0,
|
|
f: 0
|
|
};
|
|
resolver.p = new Promise((resolve, reject) => {
|
|
resolver.s = resolve;
|
|
resolver.f = reject;
|
|
});
|
|
return resolver;
|
|
};
|
|
var PROMISE_SUCCESS = (resolver, data) => {
|
|
resolver.s(data);
|
|
resolver.p.s = 1;
|
|
resolver.p.v = data;
|
|
};
|
|
var PROMISE_FAILURE = (resolver, data) => {
|
|
resolver.f(data);
|
|
resolver.p.s = 2;
|
|
resolver.p.v = data;
|
|
};
|
|
var SERIALIZED_PROMISE_CONSTRUCTOR = PROMISE_CONSTRUCTOR.toString();
|
|
var SERIALIZED_PROMISE_SUCCESS = PROMISE_SUCCESS.toString();
|
|
var SERIALIZED_PROMISE_FAILURE = PROMISE_FAILURE.toString();
|
|
var STREAM_CONSTRUCTOR = () => {
|
|
const buffer = [];
|
|
const listeners = [];
|
|
let alive = true;
|
|
let success = false;
|
|
let count = 0;
|
|
const flush3 = (value, mode, x) => {
|
|
for (x = 0; x < count; x++) {
|
|
if (listeners[x]) {
|
|
listeners[x][mode](value);
|
|
}
|
|
}
|
|
};
|
|
const up = (listener, x, z, current) => {
|
|
for (x = 0, z = buffer.length; x < z; x++) {
|
|
current = buffer[x];
|
|
if (!alive && x === z - 1) {
|
|
listener[success ? "return" : "throw"](current);
|
|
} else {
|
|
listener.next(current);
|
|
}
|
|
}
|
|
};
|
|
const on = (listener, temp) => {
|
|
if (alive) {
|
|
temp = count++;
|
|
listeners[temp] = listener;
|
|
}
|
|
up(listener);
|
|
return () => {
|
|
if (alive) {
|
|
listeners[temp] = listeners[count];
|
|
listeners[count--] = void 0;
|
|
}
|
|
};
|
|
};
|
|
return {
|
|
__SEROVAL_STREAM__: true,
|
|
on: (listener) => on(listener),
|
|
next: (value) => {
|
|
if (alive) {
|
|
buffer.push(value);
|
|
flush3(value, "next");
|
|
}
|
|
},
|
|
throw: (value) => {
|
|
if (alive) {
|
|
buffer.push(value);
|
|
flush3(value, "throw");
|
|
alive = false;
|
|
success = false;
|
|
listeners.length = 0;
|
|
}
|
|
},
|
|
return: (value) => {
|
|
if (alive) {
|
|
buffer.push(value);
|
|
flush3(value, "return");
|
|
alive = false;
|
|
success = true;
|
|
listeners.length = 0;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
var SERIALIZED_STREAM_CONSTRUCTOR = STREAM_CONSTRUCTOR.toString();
|
|
var ITERATOR_CONSTRUCTOR = (symbol) => (sequence) => () => {
|
|
let index = 0;
|
|
const instance = {
|
|
[symbol]: () => instance,
|
|
next: () => {
|
|
if (index > sequence.d) {
|
|
return {
|
|
done: true,
|
|
value: void 0
|
|
};
|
|
}
|
|
const currentIndex = index++;
|
|
const data = sequence.v[currentIndex];
|
|
if (currentIndex === sequence.t) {
|
|
throw data;
|
|
}
|
|
return {
|
|
done: currentIndex === sequence.d,
|
|
value: data
|
|
};
|
|
}
|
|
};
|
|
return instance;
|
|
};
|
|
var SERIALIZED_ITERATOR_CONSTRUCTOR = ITERATOR_CONSTRUCTOR.toString();
|
|
var ASYNC_ITERATOR_CONSTRUCTOR = (symbol, createPromise) => (stream) => () => {
|
|
let count = 0;
|
|
let doneAt = -1;
|
|
let isThrow = false;
|
|
const buffer = [];
|
|
const pending = [];
|
|
const finalize = (i = 0, len = pending.length) => {
|
|
for (; i < len; i++) {
|
|
pending[i].s({
|
|
done: true,
|
|
value: void 0
|
|
});
|
|
}
|
|
};
|
|
stream.on({
|
|
next: (value) => {
|
|
const temp = pending.shift();
|
|
if (temp) {
|
|
temp.s({ done: false, value });
|
|
}
|
|
buffer.push(value);
|
|
},
|
|
throw: (value) => {
|
|
const temp = pending.shift();
|
|
if (temp) {
|
|
temp.f(value);
|
|
}
|
|
finalize();
|
|
doneAt = buffer.length;
|
|
isThrow = true;
|
|
buffer.push(value);
|
|
},
|
|
return: (value) => {
|
|
const temp = pending.shift();
|
|
if (temp) {
|
|
temp.s({ done: true, value });
|
|
}
|
|
finalize();
|
|
doneAt = buffer.length;
|
|
buffer.push(value);
|
|
}
|
|
});
|
|
const instance = {
|
|
[symbol]: () => instance,
|
|
next: () => {
|
|
if (doneAt === -1) {
|
|
const index2 = count++;
|
|
if (index2 >= buffer.length) {
|
|
const temp = createPromise();
|
|
pending.push(temp);
|
|
return temp.p;
|
|
}
|
|
return {
|
|
done: false,
|
|
value: buffer[index2]
|
|
};
|
|
}
|
|
if (count > doneAt) {
|
|
return {
|
|
done: true,
|
|
value: void 0
|
|
};
|
|
}
|
|
const index = count++;
|
|
const value = buffer[index];
|
|
if (index !== doneAt) {
|
|
return {
|
|
done: false,
|
|
value
|
|
};
|
|
}
|
|
if (isThrow) {
|
|
throw value;
|
|
}
|
|
return {
|
|
done: true,
|
|
value
|
|
};
|
|
}
|
|
};
|
|
return instance;
|
|
};
|
|
var SERIALIZED_ASYNC_ITERATOR_CONSTRUCTOR = ASYNC_ITERATOR_CONSTRUCTOR.toString();
|
|
var ARRAY_BUFFER_CONSTRUCTOR = (b64) => {
|
|
const decoded = atob(b64);
|
|
const length = decoded.length;
|
|
const arr = new Uint8Array(length);
|
|
for (let i = 0; i < length; i++) {
|
|
arr[i] = decoded.charCodeAt(i);
|
|
}
|
|
return arr.buffer;
|
|
};
|
|
var SERIALIZED_ARRAY_BUFFER_CONSTRUCTOR = ARRAY_BUFFER_CONSTRUCTOR.toString();
|
|
var createIterator = ITERATOR_CONSTRUCTOR(SYM_ITERATOR);
|
|
function createStream() {
|
|
return STREAM_CONSTRUCTOR();
|
|
}
|
|
var createAsyncIterable = ASYNC_ITERATOR_CONSTRUCTOR(
|
|
SYM_ASYNC_ITERATOR,
|
|
PROMISE_CONSTRUCTOR
|
|
);
|
|
var SerovalMode = ((SerovalMode2) => {
|
|
SerovalMode2[SerovalMode2["Vanilla"] = 1] = "Vanilla";
|
|
SerovalMode2[SerovalMode2["Cross"] = 2] = "Cross";
|
|
return SerovalMode2;
|
|
})(SerovalMode || {});
|
|
function createPlugin(plugin) {
|
|
return plugin;
|
|
}
|
|
var RETURN = () => T;
|
|
var SERIALIZED_RETURN = RETURN.toString();
|
|
var IS_MODERN = /=>/.test(SERIALIZED_RETURN);
|
|
var REF_START_CHARS = "hjkmoquxzABCDEFGHIJKLNPQRTUVWXYZ$_";
|
|
var REF_START_CHARS_LEN = REF_START_CHARS.length;
|
|
var REF_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_";
|
|
var REF_CHARS_LEN = REF_CHARS.length;
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/ssr/serializer/transformer.js
|
|
function createSerializationAdapter(opts) {
|
|
return opts;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/seroval-plugins@1.5.1_seroval@1.5.1/node_modules/seroval-plugins/dist/esm/development/web.mjs
|
|
var PROMISE_TO_ABORT_SIGNAL = (promise) => {
|
|
const controller = new AbortController();
|
|
const abort = controller.abort.bind(controller);
|
|
promise.then(abort, abort);
|
|
return controller;
|
|
};
|
|
function resolveAbortSignalResult(resolve) {
|
|
resolve(this.reason);
|
|
}
|
|
function resolveAbortSignal(resolve) {
|
|
this.addEventListener("abort", resolveAbortSignalResult.bind(this, resolve), {
|
|
once: true
|
|
});
|
|
}
|
|
function abortSignalToPromise(signal) {
|
|
return new Promise(resolveAbortSignal.bind(signal));
|
|
}
|
|
var ABORT_CONTROLLER = {};
|
|
var AbortControllerFactoryPlugin = createPlugin({
|
|
tag: "seroval-plugins/web/AbortControllerFactoryPlugin",
|
|
test(value) {
|
|
return value === ABORT_CONTROLLER;
|
|
},
|
|
parse: {
|
|
sync() {
|
|
return ABORT_CONTROLLER;
|
|
},
|
|
async async() {
|
|
return await Promise.resolve(ABORT_CONTROLLER);
|
|
},
|
|
stream() {
|
|
return ABORT_CONTROLLER;
|
|
}
|
|
},
|
|
serialize() {
|
|
return PROMISE_TO_ABORT_SIGNAL.toString();
|
|
},
|
|
deserialize() {
|
|
return PROMISE_TO_ABORT_SIGNAL;
|
|
}
|
|
});
|
|
var AbortSignalPlugin = createPlugin({
|
|
tag: "seroval-plugins/web/AbortSignal",
|
|
extends: [AbortControllerFactoryPlugin],
|
|
test(value) {
|
|
if (typeof AbortSignal === "undefined") {
|
|
return false;
|
|
}
|
|
return value instanceof AbortSignal;
|
|
},
|
|
parse: {
|
|
sync(value, ctx) {
|
|
if (value.aborted) {
|
|
return {
|
|
reason: ctx.parse(value.reason)
|
|
};
|
|
}
|
|
return {};
|
|
},
|
|
async async(value, ctx) {
|
|
if (value.aborted) {
|
|
return {
|
|
reason: await ctx.parse(value.reason)
|
|
};
|
|
}
|
|
const result = await abortSignalToPromise(value);
|
|
return {
|
|
reason: await ctx.parse(result)
|
|
};
|
|
},
|
|
stream(value, ctx) {
|
|
if (value.aborted) {
|
|
return {
|
|
reason: ctx.parse(value.reason)
|
|
};
|
|
}
|
|
const promise = abortSignalToPromise(value);
|
|
return {
|
|
factory: ctx.parse(ABORT_CONTROLLER),
|
|
controller: ctx.parse(promise)
|
|
};
|
|
}
|
|
},
|
|
serialize(node, ctx) {
|
|
if (node.reason) {
|
|
return "AbortSignal.abort(" + ctx.serialize(node.reason) + ")";
|
|
}
|
|
if (node.controller && node.factory) {
|
|
return "(" + ctx.serialize(node.factory) + ")(" + ctx.serialize(node.controller) + ").signal";
|
|
}
|
|
return "(new AbortController).signal";
|
|
},
|
|
deserialize(node, ctx) {
|
|
if (node.reason) {
|
|
return AbortSignal.abort(ctx.deserialize(node.reason));
|
|
}
|
|
if (node.controller) {
|
|
return PROMISE_TO_ABORT_SIGNAL(ctx.deserialize(node.controller)).signal;
|
|
}
|
|
const controller = new AbortController();
|
|
return controller.signal;
|
|
}
|
|
});
|
|
var BlobPlugin = createPlugin({
|
|
tag: "seroval-plugins/web/Blob",
|
|
test(value) {
|
|
if (typeof Blob === "undefined") {
|
|
return false;
|
|
}
|
|
return value instanceof Blob;
|
|
},
|
|
parse: {
|
|
async async(value, ctx) {
|
|
return {
|
|
type: await ctx.parse(value.type),
|
|
buffer: await ctx.parse(await value.arrayBuffer())
|
|
};
|
|
}
|
|
},
|
|
serialize(node, ctx) {
|
|
return "new Blob([" + ctx.serialize(node.buffer) + "],{type:" + ctx.serialize(node.type) + "})";
|
|
},
|
|
deserialize(node, ctx) {
|
|
return new Blob([ctx.deserialize(node.buffer)], {
|
|
type: ctx.deserialize(node.type)
|
|
});
|
|
}
|
|
});
|
|
function createCustomEventOptions(current) {
|
|
return {
|
|
detail: current.detail,
|
|
bubbles: current.bubbles,
|
|
cancelable: current.cancelable,
|
|
composed: current.composed
|
|
};
|
|
}
|
|
var CustomEventPlugin = createPlugin({
|
|
tag: "seroval-plugins/web/CustomEvent",
|
|
test(value) {
|
|
if (typeof CustomEvent === "undefined") {
|
|
return false;
|
|
}
|
|
return value instanceof CustomEvent;
|
|
},
|
|
parse: {
|
|
sync(value, ctx) {
|
|
return {
|
|
type: ctx.parse(value.type),
|
|
options: ctx.parse(createCustomEventOptions(value))
|
|
};
|
|
},
|
|
async async(value, ctx) {
|
|
return {
|
|
type: await ctx.parse(value.type),
|
|
options: await ctx.parse(createCustomEventOptions(value))
|
|
};
|
|
},
|
|
stream(value, ctx) {
|
|
return {
|
|
type: ctx.parse(value.type),
|
|
options: ctx.parse(createCustomEventOptions(value))
|
|
};
|
|
}
|
|
},
|
|
serialize(node, ctx) {
|
|
return "new CustomEvent(" + ctx.serialize(node.type) + "," + ctx.serialize(node.options) + ")";
|
|
},
|
|
deserialize(node, ctx) {
|
|
return new CustomEvent(
|
|
ctx.deserialize(node.type),
|
|
ctx.deserialize(node.options)
|
|
);
|
|
}
|
|
});
|
|
var DOMExceptionPlugin = createPlugin({
|
|
tag: "seroval-plugins/web/DOMException",
|
|
test(value) {
|
|
if (typeof DOMException === "undefined") {
|
|
return false;
|
|
}
|
|
return value instanceof DOMException;
|
|
},
|
|
parse: {
|
|
sync(value, ctx) {
|
|
return {
|
|
name: ctx.parse(value.name),
|
|
message: ctx.parse(value.message)
|
|
};
|
|
},
|
|
async async(value, ctx) {
|
|
return {
|
|
name: await ctx.parse(value.name),
|
|
message: await ctx.parse(value.message)
|
|
};
|
|
},
|
|
stream(value, ctx) {
|
|
return {
|
|
name: ctx.parse(value.name),
|
|
message: ctx.parse(value.message)
|
|
};
|
|
}
|
|
},
|
|
serialize(node, ctx) {
|
|
return "new DOMException(" + ctx.serialize(node.message) + "," + ctx.serialize(node.name) + ")";
|
|
},
|
|
deserialize(node, ctx) {
|
|
return new DOMException(
|
|
ctx.deserialize(node.message),
|
|
ctx.deserialize(node.name)
|
|
);
|
|
}
|
|
});
|
|
function createEventOptions(current) {
|
|
return {
|
|
bubbles: current.bubbles,
|
|
cancelable: current.cancelable,
|
|
composed: current.composed
|
|
};
|
|
}
|
|
var EventPlugin = createPlugin({
|
|
tag: "seroval-plugins/web/Event",
|
|
test(value) {
|
|
if (typeof Event === "undefined") {
|
|
return false;
|
|
}
|
|
return value instanceof Event;
|
|
},
|
|
parse: {
|
|
sync(value, ctx) {
|
|
return {
|
|
type: ctx.parse(value.type),
|
|
options: ctx.parse(createEventOptions(value))
|
|
};
|
|
},
|
|
async async(value, ctx) {
|
|
return {
|
|
type: await ctx.parse(value.type),
|
|
options: await ctx.parse(createEventOptions(value))
|
|
};
|
|
},
|
|
stream(value, ctx) {
|
|
return {
|
|
type: ctx.parse(value.type),
|
|
options: ctx.parse(createEventOptions(value))
|
|
};
|
|
}
|
|
},
|
|
serialize(node, ctx) {
|
|
return "new Event(" + ctx.serialize(node.type) + "," + ctx.serialize(node.options) + ")";
|
|
},
|
|
deserialize(node, ctx) {
|
|
return new Event(
|
|
ctx.deserialize(node.type),
|
|
ctx.deserialize(node.options)
|
|
);
|
|
}
|
|
});
|
|
var FilePlugin = createPlugin({
|
|
tag: "seroval-plugins/web/File",
|
|
test(value) {
|
|
if (typeof File === "undefined") {
|
|
return false;
|
|
}
|
|
return value instanceof File;
|
|
},
|
|
parse: {
|
|
async async(value, ctx) {
|
|
return {
|
|
name: await ctx.parse(value.name),
|
|
options: await ctx.parse({
|
|
type: value.type,
|
|
lastModified: value.lastModified
|
|
}),
|
|
buffer: await ctx.parse(await value.arrayBuffer())
|
|
};
|
|
}
|
|
},
|
|
serialize(node, ctx) {
|
|
return "new File([" + ctx.serialize(node.buffer) + "]," + ctx.serialize(node.name) + "," + ctx.serialize(node.options) + ")";
|
|
},
|
|
deserialize(node, ctx) {
|
|
return new File(
|
|
[ctx.deserialize(node.buffer)],
|
|
ctx.deserialize(node.name),
|
|
ctx.deserialize(node.options)
|
|
);
|
|
}
|
|
});
|
|
var file_default = FilePlugin;
|
|
function convertFormData(instance) {
|
|
const items = [];
|
|
instance.forEach((value, key) => {
|
|
items.push([key, value]);
|
|
});
|
|
return items;
|
|
}
|
|
var FORM_DATA_FACTORY = {};
|
|
var FORM_DATA_FACTORY_CONSTRUCTOR = (e, f = new FormData(), i = 0, s = e.length, t) => {
|
|
for (; i < s; i++) {
|
|
t = e[i];
|
|
f.append(t[0], t[1]);
|
|
}
|
|
return f;
|
|
};
|
|
var FormDataFactoryPlugin = createPlugin({
|
|
tag: "seroval-plugins/web/FormDataFactory",
|
|
test(value) {
|
|
return value === FORM_DATA_FACTORY;
|
|
},
|
|
parse: {
|
|
sync() {
|
|
return FORM_DATA_FACTORY;
|
|
},
|
|
async async() {
|
|
return await Promise.resolve(FORM_DATA_FACTORY);
|
|
},
|
|
stream() {
|
|
return FORM_DATA_FACTORY;
|
|
}
|
|
},
|
|
serialize() {
|
|
return FORM_DATA_FACTORY_CONSTRUCTOR.toString();
|
|
},
|
|
deserialize() {
|
|
return FORM_DATA_FACTORY;
|
|
}
|
|
});
|
|
var FormDataPlugin = createPlugin({
|
|
tag: "seroval-plugins/web/FormData",
|
|
extends: [file_default, FormDataFactoryPlugin],
|
|
test(value) {
|
|
if (typeof FormData === "undefined") {
|
|
return false;
|
|
}
|
|
return value instanceof FormData;
|
|
},
|
|
parse: {
|
|
sync(value, ctx) {
|
|
return {
|
|
factory: ctx.parse(FORM_DATA_FACTORY),
|
|
entries: ctx.parse(convertFormData(value))
|
|
};
|
|
},
|
|
async async(value, ctx) {
|
|
return {
|
|
factory: await ctx.parse(FORM_DATA_FACTORY),
|
|
entries: await ctx.parse(convertFormData(value))
|
|
};
|
|
},
|
|
stream(value, ctx) {
|
|
return {
|
|
factory: ctx.parse(FORM_DATA_FACTORY),
|
|
entries: ctx.parse(convertFormData(value))
|
|
};
|
|
}
|
|
},
|
|
serialize(node, ctx) {
|
|
return "(" + ctx.serialize(node.factory) + ")(" + ctx.serialize(node.entries) + ")";
|
|
},
|
|
deserialize(node, ctx) {
|
|
return FORM_DATA_FACTORY_CONSTRUCTOR(
|
|
ctx.deserialize(node.entries)
|
|
);
|
|
}
|
|
});
|
|
function convertHeaders(instance) {
|
|
const items = [];
|
|
instance.forEach((value, key) => {
|
|
items.push([key, value]);
|
|
});
|
|
return items;
|
|
}
|
|
var HeadersPlugin = createPlugin({
|
|
tag: "seroval-plugins/web/Headers",
|
|
test(value) {
|
|
if (typeof Headers === "undefined") {
|
|
return false;
|
|
}
|
|
return value instanceof Headers;
|
|
},
|
|
parse: {
|
|
sync(value, ctx) {
|
|
return {
|
|
value: ctx.parse(convertHeaders(value))
|
|
};
|
|
},
|
|
async async(value, ctx) {
|
|
return {
|
|
value: await ctx.parse(convertHeaders(value))
|
|
};
|
|
},
|
|
stream(value, ctx) {
|
|
return {
|
|
value: ctx.parse(convertHeaders(value))
|
|
};
|
|
}
|
|
},
|
|
serialize(node, ctx) {
|
|
return "new Headers(" + ctx.serialize(node.value) + ")";
|
|
},
|
|
deserialize(node, ctx) {
|
|
return new Headers(ctx.deserialize(node.value));
|
|
}
|
|
});
|
|
var headers_default = HeadersPlugin;
|
|
var ImageDataPlugin = createPlugin({
|
|
tag: "seroval-plugins/web/ImageData",
|
|
test(value) {
|
|
if (typeof ImageData === "undefined") {
|
|
return false;
|
|
}
|
|
return value instanceof ImageData;
|
|
},
|
|
parse: {
|
|
sync(value, ctx) {
|
|
return {
|
|
data: ctx.parse(value.data),
|
|
width: ctx.parse(value.width),
|
|
height: ctx.parse(value.height),
|
|
options: ctx.parse({
|
|
colorSpace: value.colorSpace
|
|
})
|
|
};
|
|
},
|
|
async async(value, ctx) {
|
|
return {
|
|
data: await ctx.parse(value.data),
|
|
width: await ctx.parse(value.width),
|
|
height: await ctx.parse(value.height),
|
|
options: await ctx.parse({
|
|
colorSpace: value.colorSpace
|
|
})
|
|
};
|
|
},
|
|
stream(value, ctx) {
|
|
return {
|
|
data: ctx.parse(value.data),
|
|
width: ctx.parse(value.width),
|
|
height: ctx.parse(value.height),
|
|
options: ctx.parse({
|
|
colorSpace: value.colorSpace
|
|
})
|
|
};
|
|
}
|
|
},
|
|
serialize(node, ctx) {
|
|
return "new ImageData(" + ctx.serialize(node.data) + "," + ctx.serialize(node.width) + "," + ctx.serialize(node.height) + "," + ctx.serialize(node.options) + ")";
|
|
},
|
|
deserialize(node, ctx) {
|
|
return new ImageData(
|
|
ctx.deserialize(node.data),
|
|
ctx.deserialize(node.width),
|
|
ctx.deserialize(node.height),
|
|
ctx.deserialize(node.options)
|
|
);
|
|
}
|
|
});
|
|
var READABLE_STREAM_FACTORY = {};
|
|
var READABLE_STREAM_FACTORY_CONSTRUCTOR = (stream) => new ReadableStream({
|
|
start: (controller) => {
|
|
stream.on({
|
|
next: (value) => {
|
|
try {
|
|
controller.enqueue(value);
|
|
} catch (_error) {
|
|
}
|
|
},
|
|
throw: (value) => {
|
|
controller.error(value);
|
|
},
|
|
return: () => {
|
|
try {
|
|
controller.close();
|
|
} catch (_error) {
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
var ReadableStreamFactoryPlugin = createPlugin({
|
|
tag: "seroval-plugins/web/ReadableStreamFactory",
|
|
test(value) {
|
|
return value === READABLE_STREAM_FACTORY;
|
|
},
|
|
parse: {
|
|
sync() {
|
|
return READABLE_STREAM_FACTORY;
|
|
},
|
|
async async() {
|
|
return await Promise.resolve(READABLE_STREAM_FACTORY);
|
|
},
|
|
stream() {
|
|
return READABLE_STREAM_FACTORY;
|
|
}
|
|
},
|
|
serialize() {
|
|
return READABLE_STREAM_FACTORY_CONSTRUCTOR.toString();
|
|
},
|
|
deserialize() {
|
|
return READABLE_STREAM_FACTORY;
|
|
}
|
|
});
|
|
function toStream(value) {
|
|
const stream = createStream();
|
|
const reader = value.getReader();
|
|
async function push() {
|
|
try {
|
|
const result = await reader.read();
|
|
if (result.done) {
|
|
stream.return(result.value);
|
|
} else {
|
|
stream.next(result.value);
|
|
await push();
|
|
}
|
|
} catch (error) {
|
|
stream.throw(error);
|
|
}
|
|
}
|
|
push().catch(() => {
|
|
});
|
|
return stream;
|
|
}
|
|
var ReadableStreamPlugin = createPlugin({
|
|
tag: "seroval/plugins/web/ReadableStream",
|
|
extends: [ReadableStreamFactoryPlugin],
|
|
test(value) {
|
|
if (typeof ReadableStream === "undefined") {
|
|
return false;
|
|
}
|
|
return value instanceof ReadableStream;
|
|
},
|
|
parse: {
|
|
sync(_value, ctx) {
|
|
return {
|
|
factory: ctx.parse(READABLE_STREAM_FACTORY),
|
|
stream: ctx.parse(createStream())
|
|
};
|
|
},
|
|
async async(value, ctx) {
|
|
return {
|
|
factory: await ctx.parse(READABLE_STREAM_FACTORY),
|
|
stream: await ctx.parse(toStream(value))
|
|
};
|
|
},
|
|
stream(value, ctx) {
|
|
return {
|
|
factory: ctx.parse(READABLE_STREAM_FACTORY),
|
|
stream: ctx.parse(toStream(value))
|
|
};
|
|
}
|
|
},
|
|
serialize(node, ctx) {
|
|
return "(" + ctx.serialize(node.factory) + ")(" + ctx.serialize(node.stream) + ")";
|
|
},
|
|
deserialize(node, ctx) {
|
|
const stream = ctx.deserialize(node.stream);
|
|
return READABLE_STREAM_FACTORY_CONSTRUCTOR(stream);
|
|
}
|
|
});
|
|
var readable_stream_default = ReadableStreamPlugin;
|
|
function createRequestOptions(current, body) {
|
|
return {
|
|
body,
|
|
cache: current.cache,
|
|
credentials: current.credentials,
|
|
headers: current.headers,
|
|
integrity: current.integrity,
|
|
keepalive: current.keepalive,
|
|
method: current.method,
|
|
mode: current.mode,
|
|
redirect: current.redirect,
|
|
referrer: current.referrer,
|
|
referrerPolicy: current.referrerPolicy
|
|
};
|
|
}
|
|
var RequestPlugin = createPlugin({
|
|
tag: "seroval-plugins/web/Request",
|
|
extends: [readable_stream_default, headers_default],
|
|
test(value) {
|
|
if (typeof Request === "undefined") {
|
|
return false;
|
|
}
|
|
return value instanceof Request;
|
|
},
|
|
parse: {
|
|
async async(value, ctx) {
|
|
return {
|
|
url: await ctx.parse(value.url),
|
|
options: await ctx.parse(
|
|
createRequestOptions(
|
|
value,
|
|
value.body && !value.bodyUsed ? await value.clone().arrayBuffer() : null
|
|
)
|
|
)
|
|
};
|
|
},
|
|
stream(value, ctx) {
|
|
return {
|
|
url: ctx.parse(value.url),
|
|
options: ctx.parse(
|
|
createRequestOptions(
|
|
value,
|
|
value.body && !value.bodyUsed ? value.clone().body : null
|
|
)
|
|
)
|
|
};
|
|
}
|
|
},
|
|
serialize(node, ctx) {
|
|
return "new Request(" + ctx.serialize(node.url) + "," + ctx.serialize(node.options) + ")";
|
|
},
|
|
deserialize(node, ctx) {
|
|
return new Request(
|
|
ctx.deserialize(node.url),
|
|
ctx.deserialize(node.options)
|
|
);
|
|
}
|
|
});
|
|
function createResponseOptions(current) {
|
|
return {
|
|
headers: current.headers,
|
|
status: current.status,
|
|
statusText: current.statusText
|
|
};
|
|
}
|
|
var ResponsePlugin = createPlugin({
|
|
tag: "seroval-plugins/web/Response",
|
|
extends: [readable_stream_default, headers_default],
|
|
test(value) {
|
|
if (typeof Response === "undefined") {
|
|
return false;
|
|
}
|
|
return value instanceof Response;
|
|
},
|
|
parse: {
|
|
async async(value, ctx) {
|
|
return {
|
|
body: await ctx.parse(
|
|
value.body && !value.bodyUsed ? await value.clone().arrayBuffer() : null
|
|
),
|
|
options: await ctx.parse(createResponseOptions(value))
|
|
};
|
|
},
|
|
stream(value, ctx) {
|
|
return {
|
|
body: ctx.parse(
|
|
value.body && !value.bodyUsed ? value.clone().body : null
|
|
),
|
|
options: ctx.parse(createResponseOptions(value))
|
|
};
|
|
}
|
|
},
|
|
serialize(node, ctx) {
|
|
return "new Response(" + ctx.serialize(node.body) + "," + ctx.serialize(node.options) + ")";
|
|
},
|
|
deserialize(node, ctx) {
|
|
return new Response(
|
|
ctx.deserialize(node.body),
|
|
ctx.deserialize(node.options)
|
|
);
|
|
}
|
|
});
|
|
var URLPlugin = createPlugin({
|
|
tag: "seroval-plugins/web/URL",
|
|
test(value) {
|
|
if (typeof URL === "undefined") {
|
|
return false;
|
|
}
|
|
return value instanceof URL;
|
|
},
|
|
parse: {
|
|
sync(value, ctx) {
|
|
return {
|
|
value: ctx.parse(value.href)
|
|
};
|
|
},
|
|
async async(value, ctx) {
|
|
return {
|
|
value: await ctx.parse(value.href)
|
|
};
|
|
},
|
|
stream(value, ctx) {
|
|
return {
|
|
value: ctx.parse(value.href)
|
|
};
|
|
}
|
|
},
|
|
serialize(node, ctx) {
|
|
return "new URL(" + ctx.serialize(node.value) + ")";
|
|
},
|
|
deserialize(node, ctx) {
|
|
return new URL(ctx.deserialize(node.value));
|
|
}
|
|
});
|
|
var URLSearchParamsPlugin = createPlugin({
|
|
tag: "seroval-plugins/web/URLSearchParams",
|
|
test(value) {
|
|
if (typeof URLSearchParams === "undefined") {
|
|
return false;
|
|
}
|
|
return value instanceof URLSearchParams;
|
|
},
|
|
parse: {
|
|
sync(value, ctx) {
|
|
return {
|
|
value: ctx.parse(value.toString())
|
|
};
|
|
},
|
|
async async(value, ctx) {
|
|
return {
|
|
value: await ctx.parse(value.toString())
|
|
};
|
|
},
|
|
stream(value, ctx) {
|
|
return {
|
|
value: ctx.parse(value.toString())
|
|
};
|
|
}
|
|
},
|
|
serialize(node, ctx) {
|
|
return "new URLSearchParams(" + ctx.serialize(node.value) + ")";
|
|
},
|
|
deserialize(node, ctx) {
|
|
return new URLSearchParams(ctx.deserialize(node.value));
|
|
}
|
|
});
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/ssr/serializer/ShallowErrorPlugin.js
|
|
var ShallowErrorPlugin = createPlugin({
|
|
tag: "$TSR/Error",
|
|
test(value) {
|
|
return value instanceof Error;
|
|
},
|
|
parse: {
|
|
sync(value, ctx) {
|
|
return {
|
|
message: ctx.parse(value.message)
|
|
};
|
|
},
|
|
async async(value, ctx) {
|
|
return {
|
|
message: await ctx.parse(value.message)
|
|
};
|
|
},
|
|
stream(value, ctx) {
|
|
return {
|
|
message: ctx.parse(value.message)
|
|
};
|
|
}
|
|
},
|
|
serialize(node, ctx) {
|
|
return "new Error(" + ctx.serialize(node.message) + ")";
|
|
},
|
|
deserialize(node, ctx) {
|
|
return new Error(ctx.deserialize(node.message));
|
|
}
|
|
});
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+router-core@1.166.4/node_modules/@tanstack/router-core/dist/esm/ssr/serializer/RawStream.js
|
|
var RawStream = class {
|
|
constructor(stream, options) {
|
|
this.stream = stream;
|
|
this.hint = options?.hint ?? "binary";
|
|
}
|
|
};
|
|
var BufferCtor = globalThis.Buffer;
|
|
var hasNodeBuffer = !!BufferCtor && typeof BufferCtor.from === "function";
|
|
function uint8ArrayToBase64(bytes) {
|
|
if (bytes.length === 0) return "";
|
|
if (hasNodeBuffer) {
|
|
return BufferCtor.from(bytes).toString("base64");
|
|
}
|
|
const CHUNK_SIZE = 32768;
|
|
const chunks = [];
|
|
for (let i = 0; i < bytes.length; i += CHUNK_SIZE) {
|
|
const chunk = bytes.subarray(i, i + CHUNK_SIZE);
|
|
chunks.push(String.fromCharCode.apply(null, chunk));
|
|
}
|
|
return btoa(chunks.join(""));
|
|
}
|
|
function base64ToUint8Array(base64) {
|
|
if (base64.length === 0) return new Uint8Array(0);
|
|
if (hasNodeBuffer) {
|
|
const buf = BufferCtor.from(base64, "base64");
|
|
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
}
|
|
const binary = atob(base64);
|
|
const bytes = new Uint8Array(binary.length);
|
|
for (let i = 0; i < binary.length; i++) {
|
|
bytes[i] = binary.charCodeAt(i);
|
|
}
|
|
return bytes;
|
|
}
|
|
var RAW_STREAM_FACTORY_BINARY = /* @__PURE__ */ Object.create(null);
|
|
var RAW_STREAM_FACTORY_TEXT = /* @__PURE__ */ Object.create(null);
|
|
var RAW_STREAM_FACTORY_CONSTRUCTOR_BINARY = (stream) => new ReadableStream({
|
|
start(controller) {
|
|
stream.on({
|
|
next(base64) {
|
|
try {
|
|
controller.enqueue(base64ToUint8Array(base64));
|
|
} catch {
|
|
}
|
|
},
|
|
throw(error) {
|
|
controller.error(error);
|
|
},
|
|
return() {
|
|
try {
|
|
controller.close();
|
|
} catch {
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
var textEncoderForFactory = new TextEncoder();
|
|
var RAW_STREAM_FACTORY_CONSTRUCTOR_TEXT = (stream) => {
|
|
return new ReadableStream({
|
|
start(controller) {
|
|
stream.on({
|
|
next(value) {
|
|
try {
|
|
if (typeof value === "string") {
|
|
controller.enqueue(textEncoderForFactory.encode(value));
|
|
} else {
|
|
controller.enqueue(base64ToUint8Array(value.$b64));
|
|
}
|
|
} catch {
|
|
}
|
|
},
|
|
throw(error) {
|
|
controller.error(error);
|
|
},
|
|
return() {
|
|
try {
|
|
controller.close();
|
|
} catch {
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var FACTORY_BINARY = `(s=>new ReadableStream({start(c){s.on({next(b){try{const d=atob(b),a=new Uint8Array(d.length);for(let i=0;i<d.length;i++)a[i]=d.charCodeAt(i);c.enqueue(a)}catch(_){}},throw(e){c.error(e)},return(){try{c.close()}catch(_){}}})}}))`;
|
|
var FACTORY_TEXT = `(s=>{const e=new TextEncoder();return new ReadableStream({start(c){s.on({next(v){try{if(typeof v==='string'){c.enqueue(e.encode(v))}else{const d=atob(v.$b64),a=new Uint8Array(d.length);for(let i=0;i<d.length;i++)a[i]=d.charCodeAt(i);c.enqueue(a)}}catch(_){}},throw(x){c.error(x)},return(){try{c.close()}catch(_){}}})}})})`;
|
|
function toBinaryStream(readable) {
|
|
const stream = createStream();
|
|
const reader = readable.getReader();
|
|
(async () => {
|
|
try {
|
|
while (true) {
|
|
const { done, value } = await reader.read();
|
|
if (done) {
|
|
stream.return(void 0);
|
|
break;
|
|
}
|
|
stream.next(uint8ArrayToBase64(value));
|
|
}
|
|
} catch (error) {
|
|
stream.throw(error);
|
|
} finally {
|
|
reader.releaseLock();
|
|
}
|
|
})();
|
|
return stream;
|
|
}
|
|
function toTextStream(readable) {
|
|
const stream = createStream();
|
|
const reader = readable.getReader();
|
|
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
(async () => {
|
|
try {
|
|
while (true) {
|
|
const { done, value } = await reader.read();
|
|
if (done) {
|
|
try {
|
|
const remaining = decoder.decode();
|
|
if (remaining.length > 0) {
|
|
stream.next(remaining);
|
|
}
|
|
} catch {
|
|
}
|
|
stream.return(void 0);
|
|
break;
|
|
}
|
|
try {
|
|
const text = decoder.decode(value, { stream: true });
|
|
if (text.length > 0) {
|
|
stream.next(text);
|
|
}
|
|
} catch {
|
|
stream.next({ $b64: uint8ArrayToBase64(value) });
|
|
}
|
|
}
|
|
} catch (error) {
|
|
stream.throw(error);
|
|
} finally {
|
|
reader.releaseLock();
|
|
}
|
|
})();
|
|
return stream;
|
|
}
|
|
var RawStreamFactoryBinaryPlugin = createPlugin({
|
|
tag: "tss/RawStreamFactory",
|
|
test(value) {
|
|
return value === RAW_STREAM_FACTORY_BINARY;
|
|
},
|
|
parse: {
|
|
sync() {
|
|
return void 0;
|
|
},
|
|
async() {
|
|
return Promise.resolve(void 0);
|
|
},
|
|
stream() {
|
|
return void 0;
|
|
}
|
|
},
|
|
serialize() {
|
|
return FACTORY_BINARY;
|
|
},
|
|
deserialize() {
|
|
return RAW_STREAM_FACTORY_BINARY;
|
|
}
|
|
});
|
|
var RawStreamFactoryTextPlugin = createPlugin({
|
|
tag: "tss/RawStreamFactoryText",
|
|
test(value) {
|
|
return value === RAW_STREAM_FACTORY_TEXT;
|
|
},
|
|
parse: {
|
|
sync() {
|
|
return void 0;
|
|
},
|
|
async() {
|
|
return Promise.resolve(void 0);
|
|
},
|
|
stream() {
|
|
return void 0;
|
|
}
|
|
},
|
|
serialize() {
|
|
return FACTORY_TEXT;
|
|
},
|
|
deserialize() {
|
|
return RAW_STREAM_FACTORY_TEXT;
|
|
}
|
|
});
|
|
var RawStreamSSRPlugin = createPlugin({
|
|
tag: "tss/RawStream",
|
|
extends: [RawStreamFactoryBinaryPlugin, RawStreamFactoryTextPlugin],
|
|
test(value) {
|
|
return value instanceof RawStream;
|
|
},
|
|
parse: {
|
|
sync(value, ctx) {
|
|
const factory = value.hint === "text" ? RAW_STREAM_FACTORY_TEXT : RAW_STREAM_FACTORY_BINARY;
|
|
return {
|
|
hint: value.hint,
|
|
factory: ctx.parse(factory),
|
|
stream: ctx.parse(createStream())
|
|
};
|
|
},
|
|
async async(value, ctx) {
|
|
const factory = value.hint === "text" ? RAW_STREAM_FACTORY_TEXT : RAW_STREAM_FACTORY_BINARY;
|
|
const encodedStream = value.hint === "text" ? toTextStream(value.stream) : toBinaryStream(value.stream);
|
|
return {
|
|
hint: value.hint,
|
|
factory: await ctx.parse(factory),
|
|
stream: await ctx.parse(encodedStream)
|
|
};
|
|
},
|
|
stream(value, ctx) {
|
|
const factory = value.hint === "text" ? RAW_STREAM_FACTORY_TEXT : RAW_STREAM_FACTORY_BINARY;
|
|
const encodedStream = value.hint === "text" ? toTextStream(value.stream) : toBinaryStream(value.stream);
|
|
return {
|
|
hint: value.hint,
|
|
factory: ctx.parse(factory),
|
|
stream: ctx.parse(encodedStream)
|
|
};
|
|
}
|
|
},
|
|
serialize(node, ctx) {
|
|
return "(" + ctx.serialize(node.factory) + ")(" + ctx.serialize(node.stream) + ")";
|
|
},
|
|
deserialize(node, ctx) {
|
|
const stream = ctx.deserialize(node.stream);
|
|
return node.hint === "text" ? RAW_STREAM_FACTORY_CONSTRUCTOR_TEXT(stream) : RAW_STREAM_FACTORY_CONSTRUCTOR_BINARY(stream);
|
|
}
|
|
});
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/awaited.js
|
|
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
var React2 = __toESM(require_react(), 1);
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/utils.js
|
|
var React = __toESM(require_react(), 1);
|
|
var REACT_USE = "use";
|
|
var reactUse = React[REACT_USE];
|
|
var useLayoutEffect2 = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
function usePrevious(value) {
|
|
const ref = React.useRef({
|
|
value,
|
|
prev: null
|
|
});
|
|
const current = ref.current.value;
|
|
if (value !== current) {
|
|
ref.current = {
|
|
value,
|
|
prev: current
|
|
};
|
|
}
|
|
return ref.current.prev;
|
|
}
|
|
function useIntersectionObserver(ref, callback, intersectionObserverOptions2 = {}, options = {}) {
|
|
React.useEffect(() => {
|
|
if (!ref.current || options.disabled || typeof IntersectionObserver !== "function") {
|
|
return;
|
|
}
|
|
const observer = new IntersectionObserver(([entry]) => {
|
|
callback(entry);
|
|
}, intersectionObserverOptions2);
|
|
observer.observe(ref.current);
|
|
return () => {
|
|
observer.disconnect();
|
|
};
|
|
}, [callback, intersectionObserverOptions2, options.disabled, ref]);
|
|
}
|
|
function useForwardedRef(ref) {
|
|
const innerRef = React.useRef(null);
|
|
React.useImperativeHandle(ref, () => innerRef.current, []);
|
|
return innerRef;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/awaited.js
|
|
function useAwaited({ promise: _promise }) {
|
|
if (reactUse) {
|
|
const data = reactUse(_promise);
|
|
return data;
|
|
}
|
|
const promise = defer(_promise);
|
|
if (promise[TSR_DEFERRED_PROMISE].status === "pending") {
|
|
throw promise;
|
|
}
|
|
if (promise[TSR_DEFERRED_PROMISE].status === "error") {
|
|
throw promise[TSR_DEFERRED_PROMISE].error;
|
|
}
|
|
return promise[TSR_DEFERRED_PROMISE].data;
|
|
}
|
|
function Await(props) {
|
|
const inner = (0, import_jsx_runtime.jsx)(AwaitInner, { ...props });
|
|
if (props.fallback) {
|
|
return (0, import_jsx_runtime.jsx)(React2.Suspense, { fallback: props.fallback, children: inner });
|
|
}
|
|
return inner;
|
|
}
|
|
function AwaitInner(props) {
|
|
const data = useAwaited(props);
|
|
return props.children(data);
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/CatchBoundary.js
|
|
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
|
|
var React3 = __toESM(require_react(), 1);
|
|
function CatchBoundary(props) {
|
|
const errorComponent = props.errorComponent ?? ErrorComponent;
|
|
return (0, import_jsx_runtime2.jsx)(
|
|
CatchBoundaryImpl,
|
|
{
|
|
getResetKey: props.getResetKey,
|
|
onCatch: props.onCatch,
|
|
children: ({ error, reset }) => {
|
|
if (error) {
|
|
return React3.createElement(errorComponent, {
|
|
error,
|
|
reset
|
|
});
|
|
}
|
|
return props.children;
|
|
}
|
|
}
|
|
);
|
|
}
|
|
var CatchBoundaryImpl = class extends React3.Component {
|
|
constructor() {
|
|
super(...arguments);
|
|
this.state = { error: null };
|
|
}
|
|
static getDerivedStateFromProps(props) {
|
|
return { resetKey: props.getResetKey() };
|
|
}
|
|
static getDerivedStateFromError(error) {
|
|
return { error };
|
|
}
|
|
reset() {
|
|
this.setState({ error: null });
|
|
}
|
|
componentDidUpdate(prevProps, prevState) {
|
|
if (prevState.error && prevState.resetKey !== this.state.resetKey) {
|
|
this.reset();
|
|
}
|
|
}
|
|
componentDidCatch(error, errorInfo) {
|
|
if (this.props.onCatch) {
|
|
this.props.onCatch(error, errorInfo);
|
|
}
|
|
}
|
|
render() {
|
|
return this.props.children({
|
|
error: this.state.resetKey !== this.props.getResetKey() ? null : this.state.error,
|
|
reset: () => {
|
|
this.reset();
|
|
}
|
|
});
|
|
}
|
|
};
|
|
function ErrorComponent({ error }) {
|
|
const [show, setShow] = React3.useState(true);
|
|
return (0, import_jsx_runtime2.jsxs)("div", { style: { padding: ".5rem", maxWidth: "100%" }, children: [
|
|
(0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: ".5rem" }, children: [
|
|
(0, import_jsx_runtime2.jsx)("strong", { style: { fontSize: "1rem" }, children: "Something went wrong!" }),
|
|
(0, import_jsx_runtime2.jsx)(
|
|
"button",
|
|
{
|
|
style: {
|
|
appearance: "none",
|
|
fontSize: ".6em",
|
|
border: "1px solid currentColor",
|
|
padding: ".1rem .2rem",
|
|
fontWeight: "bold",
|
|
borderRadius: ".25rem"
|
|
},
|
|
onClick: () => setShow((d) => !d),
|
|
children: show ? "Hide Error" : "Show Error"
|
|
}
|
|
)
|
|
] }),
|
|
(0, import_jsx_runtime2.jsx)("div", { style: { height: ".25rem" } }),
|
|
show ? (0, import_jsx_runtime2.jsx)("div", { children: (0, import_jsx_runtime2.jsx)(
|
|
"pre",
|
|
{
|
|
style: {
|
|
fontSize: ".7em",
|
|
border: "1px solid red",
|
|
borderRadius: ".25rem",
|
|
padding: ".3rem",
|
|
color: "red",
|
|
overflow: "auto"
|
|
},
|
|
children: error.message ? (0, import_jsx_runtime2.jsx)("code", { children: error.message }) : null
|
|
}
|
|
) }) : null
|
|
] });
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/ClientOnly.js
|
|
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
|
|
var import_react = __toESM(require_react(), 1);
|
|
function ClientOnly({ children, fallback = null }) {
|
|
return useHydrated() ? (0, import_jsx_runtime3.jsx)(import_react.default.Fragment, { children }) : (0, import_jsx_runtime3.jsx)(import_react.default.Fragment, { children: fallback });
|
|
}
|
|
function useHydrated() {
|
|
return import_react.default.useSyncExternalStore(
|
|
subscribe,
|
|
() => true,
|
|
() => false
|
|
);
|
|
}
|
|
function subscribe() {
|
|
return () => {
|
|
};
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js
|
|
var isProduction2 = false;
|
|
function warning(condition, message) {
|
|
if (!isProduction2) {
|
|
if (condition) {
|
|
return;
|
|
}
|
|
var text = "Warning: " + message;
|
|
if (typeof console !== "undefined") {
|
|
console.warn(text);
|
|
}
|
|
try {
|
|
throw Error(text);
|
|
} catch (x) {
|
|
}
|
|
}
|
|
}
|
|
var tiny_warning_esm_default = warning;
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/route.js
|
|
var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
|
|
var import_react4 = __toESM(require_react(), 1);
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/useMatch.js
|
|
var React7 = __toESM(require_react(), 1);
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-store@0.9.2_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-store/dist/esm/useStore.js
|
|
var import_react2 = __toESM(require_react(), 1);
|
|
var import_with_selector = __toESM(require_with_selector(), 1);
|
|
function defaultCompare(a, b) {
|
|
return a === b;
|
|
}
|
|
function useStore(atom, selector, compare = defaultCompare) {
|
|
const subscribe2 = (0, import_react2.useCallback)(
|
|
(handleStoreChange) => {
|
|
if (!atom) {
|
|
return () => {
|
|
};
|
|
}
|
|
const { unsubscribe } = atom.subscribe(handleStoreChange);
|
|
return unsubscribe;
|
|
},
|
|
[atom]
|
|
);
|
|
const boundGetSnapshot = (0, import_react2.useCallback)(() => atom?.get(), [atom]);
|
|
const selectedSnapshot = (0, import_with_selector.useSyncExternalStoreWithSelector)(
|
|
subscribe2,
|
|
boundGetSnapshot,
|
|
boundGetSnapshot,
|
|
selector,
|
|
compare
|
|
);
|
|
return selectedSnapshot;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/useRouterState.js
|
|
var import_react3 = __toESM(require_react(), 1);
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/useRouter.js
|
|
var React5 = __toESM(require_react(), 1);
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/routerContext.js
|
|
var React4 = __toESM(require_react(), 1);
|
|
var routerContext = React4.createContext(null);
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/useRouter.js
|
|
function useRouter(opts) {
|
|
const value = React5.useContext(routerContext);
|
|
tiny_warning_esm_default(
|
|
!((opts?.warn ?? true) && !value),
|
|
"useRouter must be used inside a <RouterProvider> component!"
|
|
);
|
|
return value;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/useRouterState.js
|
|
function useRouterState(opts) {
|
|
const contextRouter = useRouter({
|
|
warn: opts?.router === void 0
|
|
});
|
|
const router = opts?.router || contextRouter;
|
|
const _isServer = isServer ?? router.isServer;
|
|
if (_isServer) {
|
|
const state = router.state;
|
|
return opts?.select ? opts.select(state) : state;
|
|
}
|
|
const previousResult = (
|
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
(0, import_react3.useRef)(void 0)
|
|
);
|
|
return useStore(router.__store, (state) => {
|
|
if (opts?.select) {
|
|
if (opts.structuralSharing ?? router.options.defaultStructuralSharing) {
|
|
const newSlice = replaceEqualDeep(
|
|
previousResult.current,
|
|
opts.select(state)
|
|
);
|
|
previousResult.current = newSlice;
|
|
return newSlice;
|
|
}
|
|
return opts.select(state);
|
|
}
|
|
return state;
|
|
});
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/matchContext.js
|
|
var React6 = __toESM(require_react(), 1);
|
|
var matchContext = React6.createContext(void 0);
|
|
var dummyMatchContext = React6.createContext(
|
|
void 0
|
|
);
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/useMatch.js
|
|
function useMatch(opts) {
|
|
const nearestMatchId = React7.useContext(
|
|
opts.from ? dummyMatchContext : matchContext
|
|
);
|
|
const matchSelection = useRouterState({
|
|
select: (state) => {
|
|
const match = state.matches.find(
|
|
(d) => opts.from ? opts.from === d.routeId : d.id === nearestMatchId
|
|
);
|
|
invariant(
|
|
!((opts.shouldThrow ?? true) && !match),
|
|
`Could not find ${opts.from ? `an active match from "${opts.from}"` : "a nearest match!"}`
|
|
);
|
|
if (match === void 0) {
|
|
return void 0;
|
|
}
|
|
return opts.select ? opts.select(match) : match;
|
|
},
|
|
structuralSharing: opts.structuralSharing
|
|
});
|
|
return matchSelection;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/useLoaderData.js
|
|
function useLoaderData(opts) {
|
|
return useMatch({
|
|
from: opts.from,
|
|
strict: opts.strict,
|
|
structuralSharing: opts.structuralSharing,
|
|
select: (s) => {
|
|
return opts.select ? opts.select(s.loaderData) : s.loaderData;
|
|
}
|
|
});
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/useLoaderDeps.js
|
|
function useLoaderDeps(opts) {
|
|
const { select, ...rest } = opts;
|
|
return useMatch({
|
|
...rest,
|
|
select: (s) => {
|
|
return select ? select(s.loaderDeps) : s.loaderDeps;
|
|
}
|
|
});
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/useParams.js
|
|
function useParams(opts) {
|
|
return useMatch({
|
|
from: opts.from,
|
|
shouldThrow: opts.shouldThrow,
|
|
structuralSharing: opts.structuralSharing,
|
|
strict: opts.strict,
|
|
select: (match) => {
|
|
const params = opts.strict === false ? match.params : match._strictParams;
|
|
return opts.select ? opts.select(params) : params;
|
|
}
|
|
});
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/useSearch.js
|
|
function useSearch(opts) {
|
|
return useMatch({
|
|
from: opts.from,
|
|
strict: opts.strict,
|
|
shouldThrow: opts.shouldThrow,
|
|
structuralSharing: opts.structuralSharing,
|
|
select: (match) => {
|
|
return opts.select ? opts.select(match.search) : match.search;
|
|
}
|
|
});
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/useNavigate.js
|
|
var React8 = __toESM(require_react(), 1);
|
|
function useNavigate(_defaultOpts) {
|
|
const router = useRouter();
|
|
return React8.useCallback(
|
|
(options) => {
|
|
return router.navigate({
|
|
...options,
|
|
from: options.from ?? _defaultOpts?.from
|
|
});
|
|
},
|
|
[_defaultOpts?.from, router]
|
|
);
|
|
}
|
|
function Navigate(props) {
|
|
const router = useRouter();
|
|
const navigate = useNavigate();
|
|
const previousPropsRef = React8.useRef(null);
|
|
useLayoutEffect2(() => {
|
|
if (previousPropsRef.current !== props) {
|
|
navigate(props);
|
|
previousPropsRef.current = props;
|
|
}
|
|
}, [router, props, navigate]);
|
|
return null;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/useRouteContext.js
|
|
function useRouteContext(opts) {
|
|
return useMatch({
|
|
...opts,
|
|
select: (match) => opts.select ? opts.select(match.context) : match.context
|
|
});
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/link.js
|
|
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
|
|
var React9 = __toESM(require_react(), 1);
|
|
var import_react_dom = __toESM(require_react_dom(), 1);
|
|
function useLinkProps(options, forwardedRef) {
|
|
const router = useRouter();
|
|
const innerRef = useForwardedRef(forwardedRef);
|
|
const _isServer = isServer ?? router.isServer;
|
|
const {
|
|
// custom props
|
|
activeProps,
|
|
inactiveProps,
|
|
activeOptions,
|
|
to,
|
|
preload: userPreload,
|
|
preloadDelay: userPreloadDelay,
|
|
hashScrollIntoView,
|
|
replace,
|
|
startTransition: startTransition2,
|
|
resetScroll,
|
|
viewTransition,
|
|
// element props
|
|
children,
|
|
target,
|
|
disabled,
|
|
style,
|
|
className,
|
|
onClick,
|
|
onBlur,
|
|
onFocus,
|
|
onMouseEnter,
|
|
onMouseLeave,
|
|
onTouchStart,
|
|
ignoreBlocker,
|
|
// prevent these from being returned
|
|
params: _params,
|
|
search: _search,
|
|
hash: _hash,
|
|
state: _state,
|
|
mask: _mask,
|
|
reloadDocument: _reloadDocument,
|
|
unsafeRelative: _unsafeRelative,
|
|
from: _from,
|
|
_fromLocation,
|
|
...propsSafeToSpread
|
|
} = options;
|
|
if (_isServer) {
|
|
const safeInternal = isSafeInternal(to);
|
|
if (typeof to === "string" && !safeInternal && // Quick checks to avoid `new URL` in common internal-like cases
|
|
to.indexOf(":") > -1) {
|
|
try {
|
|
new URL(to);
|
|
if (isDangerousProtocol(to, router.protocolAllowlist)) {
|
|
if (true) {
|
|
console.warn(`Blocked Link with dangerous protocol: ${to}`);
|
|
}
|
|
return {
|
|
...propsSafeToSpread,
|
|
ref: innerRef,
|
|
href: void 0,
|
|
...children && { children },
|
|
...target && { target },
|
|
...disabled && { disabled },
|
|
...style && { style },
|
|
...className && { className }
|
|
};
|
|
}
|
|
return {
|
|
...propsSafeToSpread,
|
|
ref: innerRef,
|
|
href: to,
|
|
...children && { children },
|
|
...target && { target },
|
|
...disabled && { disabled },
|
|
...style && { style },
|
|
...className && { className }
|
|
};
|
|
} catch {
|
|
}
|
|
}
|
|
const next2 = router.buildLocation({ ...options, from: options.from });
|
|
const hrefOptionPublicHref2 = next2.maskedLocation ? next2.maskedLocation.publicHref : next2.publicHref;
|
|
const hrefOptionExternal2 = next2.maskedLocation ? next2.maskedLocation.external : next2.external;
|
|
const hrefOption2 = getHrefOption(
|
|
hrefOptionPublicHref2,
|
|
hrefOptionExternal2,
|
|
router.history,
|
|
disabled
|
|
);
|
|
const externalLink2 = (() => {
|
|
if (hrefOption2?.external) {
|
|
if (isDangerousProtocol(hrefOption2.href, router.protocolAllowlist)) {
|
|
if (true) {
|
|
console.warn(
|
|
`Blocked Link with dangerous protocol: ${hrefOption2.href}`
|
|
);
|
|
}
|
|
return void 0;
|
|
}
|
|
return hrefOption2.href;
|
|
}
|
|
if (safeInternal) return void 0;
|
|
if (typeof to === "string" && to.indexOf(":") > -1) {
|
|
try {
|
|
new URL(to);
|
|
if (isDangerousProtocol(to, router.protocolAllowlist)) {
|
|
if (true) {
|
|
console.warn(`Blocked Link with dangerous protocol: ${to}`);
|
|
}
|
|
return void 0;
|
|
}
|
|
return to;
|
|
} catch {
|
|
}
|
|
}
|
|
return void 0;
|
|
})();
|
|
const isActive2 = (() => {
|
|
if (externalLink2) return false;
|
|
const currentLocation = router.state.location;
|
|
const exact = activeOptions?.exact ?? false;
|
|
if (exact) {
|
|
const testExact = exactPathTest(
|
|
currentLocation.pathname,
|
|
next2.pathname,
|
|
router.basepath
|
|
);
|
|
if (!testExact) {
|
|
return false;
|
|
}
|
|
} else {
|
|
const currentPathSplit = removeTrailingSlash(
|
|
currentLocation.pathname,
|
|
router.basepath
|
|
);
|
|
const nextPathSplit = removeTrailingSlash(
|
|
next2.pathname,
|
|
router.basepath
|
|
);
|
|
const pathIsFuzzyEqual = currentPathSplit.startsWith(nextPathSplit) && (currentPathSplit.length === nextPathSplit.length || currentPathSplit[nextPathSplit.length] === "/");
|
|
if (!pathIsFuzzyEqual) {
|
|
return false;
|
|
}
|
|
}
|
|
const includeSearch = activeOptions?.includeSearch ?? true;
|
|
if (includeSearch) {
|
|
if (currentLocation.search !== next2.search) {
|
|
const currentSearchEmpty = !currentLocation.search || typeof currentLocation.search === "object" && Object.keys(currentLocation.search).length === 0;
|
|
const nextSearchEmpty = !next2.search || typeof next2.search === "object" && Object.keys(next2.search).length === 0;
|
|
if (!(currentSearchEmpty && nextSearchEmpty)) {
|
|
const searchTest = deepEqual(currentLocation.search, next2.search, {
|
|
partial: !exact,
|
|
ignoreUndefined: !activeOptions?.explicitUndefined
|
|
});
|
|
if (!searchTest) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (activeOptions?.includeHash) {
|
|
return false;
|
|
}
|
|
return true;
|
|
})();
|
|
if (externalLink2) {
|
|
return {
|
|
...propsSafeToSpread,
|
|
ref: innerRef,
|
|
href: externalLink2,
|
|
...children && { children },
|
|
...target && { target },
|
|
...disabled && { disabled },
|
|
...style && { style },
|
|
...className && { className }
|
|
};
|
|
}
|
|
const resolvedActiveProps2 = isActive2 ? functionalUpdate(activeProps, {}) ?? STATIC_ACTIVE_OBJECT : STATIC_EMPTY_OBJECT;
|
|
const resolvedInactiveProps2 = isActive2 ? STATIC_EMPTY_OBJECT : functionalUpdate(inactiveProps, {}) ?? STATIC_EMPTY_OBJECT;
|
|
const resolvedStyle2 = (() => {
|
|
const baseStyle = style;
|
|
const activeStyle = resolvedActiveProps2.style;
|
|
const inactiveStyle = resolvedInactiveProps2.style;
|
|
if (!baseStyle && !activeStyle && !inactiveStyle) {
|
|
return void 0;
|
|
}
|
|
if (baseStyle && !activeStyle && !inactiveStyle) {
|
|
return baseStyle;
|
|
}
|
|
if (!baseStyle && activeStyle && !inactiveStyle) {
|
|
return activeStyle;
|
|
}
|
|
if (!baseStyle && !activeStyle && inactiveStyle) {
|
|
return inactiveStyle;
|
|
}
|
|
return {
|
|
...baseStyle,
|
|
...activeStyle,
|
|
...inactiveStyle
|
|
};
|
|
})();
|
|
const resolvedClassName2 = (() => {
|
|
const baseClassName = className;
|
|
const activeClassName = resolvedActiveProps2.className;
|
|
const inactiveClassName = resolvedInactiveProps2.className;
|
|
if (!baseClassName && !activeClassName && !inactiveClassName) {
|
|
return "";
|
|
}
|
|
let out = "";
|
|
if (baseClassName) {
|
|
out = baseClassName;
|
|
}
|
|
if (activeClassName) {
|
|
out = out ? `${out} ${activeClassName}` : activeClassName;
|
|
}
|
|
if (inactiveClassName) {
|
|
out = out ? `${out} ${inactiveClassName}` : inactiveClassName;
|
|
}
|
|
return out;
|
|
})();
|
|
return {
|
|
...propsSafeToSpread,
|
|
...resolvedActiveProps2,
|
|
...resolvedInactiveProps2,
|
|
href: hrefOption2?.href,
|
|
ref: innerRef,
|
|
disabled: !!disabled,
|
|
target,
|
|
...resolvedStyle2 && { style: resolvedStyle2 },
|
|
...resolvedClassName2 && { className: resolvedClassName2 },
|
|
...disabled && STATIC_DISABLED_PROPS,
|
|
...isActive2 && STATIC_ACTIVE_PROPS
|
|
};
|
|
}
|
|
const isHydrated = useHydrated();
|
|
const currentLocationState = useRouterState({
|
|
select: (s) => {
|
|
const leaf = s.matches[s.matches.length - 1];
|
|
return {
|
|
search: leaf?.search,
|
|
hash: s.location.hash,
|
|
path: leaf?.pathname
|
|
// path + params
|
|
};
|
|
},
|
|
structuralSharing: true
|
|
});
|
|
const from = options.from;
|
|
const _options = React9.useMemo(
|
|
() => {
|
|
return { ...options, from };
|
|
},
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
[
|
|
router,
|
|
currentLocationState,
|
|
from,
|
|
options._fromLocation,
|
|
options.hash,
|
|
options.to,
|
|
options.search,
|
|
options.params,
|
|
options.state,
|
|
options.mask,
|
|
options.unsafeRelative
|
|
]
|
|
);
|
|
const next = React9.useMemo(
|
|
() => router.buildLocation({ ..._options }),
|
|
[router, _options]
|
|
);
|
|
const hrefOptionPublicHref = next.maskedLocation ? next.maskedLocation.publicHref : next.publicHref;
|
|
const hrefOptionExternal = next.maskedLocation ? next.maskedLocation.external : next.external;
|
|
const hrefOption = React9.useMemo(
|
|
() => getHrefOption(
|
|
hrefOptionPublicHref,
|
|
hrefOptionExternal,
|
|
router.history,
|
|
disabled
|
|
),
|
|
[disabled, hrefOptionExternal, hrefOptionPublicHref, router.history]
|
|
);
|
|
const externalLink = React9.useMemo(() => {
|
|
if (hrefOption?.external) {
|
|
if (isDangerousProtocol(hrefOption.href, router.protocolAllowlist)) {
|
|
if (true) {
|
|
console.warn(
|
|
`Blocked Link with dangerous protocol: ${hrefOption.href}`
|
|
);
|
|
}
|
|
return void 0;
|
|
}
|
|
return hrefOption.href;
|
|
}
|
|
const safeInternal = isSafeInternal(to);
|
|
if (safeInternal) return void 0;
|
|
if (typeof to !== "string" || to.indexOf(":") === -1) return void 0;
|
|
try {
|
|
new URL(to);
|
|
if (isDangerousProtocol(to, router.protocolAllowlist)) {
|
|
if (true) {
|
|
console.warn(`Blocked Link with dangerous protocol: ${to}`);
|
|
}
|
|
return void 0;
|
|
}
|
|
return to;
|
|
} catch {
|
|
}
|
|
return void 0;
|
|
}, [to, hrefOption, router.protocolAllowlist]);
|
|
const isActive = useRouterState({
|
|
select: (s) => {
|
|
if (externalLink) return false;
|
|
if (activeOptions?.exact) {
|
|
const testExact = exactPathTest(
|
|
s.location.pathname,
|
|
next.pathname,
|
|
router.basepath
|
|
);
|
|
if (!testExact) {
|
|
return false;
|
|
}
|
|
} else {
|
|
const currentPathSplit = removeTrailingSlash(
|
|
s.location.pathname,
|
|
router.basepath
|
|
);
|
|
const nextPathSplit = removeTrailingSlash(
|
|
next.pathname,
|
|
router.basepath
|
|
);
|
|
const pathIsFuzzyEqual = currentPathSplit.startsWith(nextPathSplit) && (currentPathSplit.length === nextPathSplit.length || currentPathSplit[nextPathSplit.length] === "/");
|
|
if (!pathIsFuzzyEqual) {
|
|
return false;
|
|
}
|
|
}
|
|
if (activeOptions?.includeSearch ?? true) {
|
|
const searchTest = deepEqual(s.location.search, next.search, {
|
|
partial: !activeOptions?.exact,
|
|
ignoreUndefined: !activeOptions?.explicitUndefined
|
|
});
|
|
if (!searchTest) {
|
|
return false;
|
|
}
|
|
}
|
|
if (activeOptions?.includeHash) {
|
|
return isHydrated && s.location.hash === next.hash;
|
|
}
|
|
return true;
|
|
}
|
|
});
|
|
const resolvedActiveProps = isActive ? functionalUpdate(activeProps, {}) ?? STATIC_ACTIVE_OBJECT : STATIC_EMPTY_OBJECT;
|
|
const resolvedInactiveProps = isActive ? STATIC_EMPTY_OBJECT : functionalUpdate(inactiveProps, {}) ?? STATIC_EMPTY_OBJECT;
|
|
const resolvedClassName = [
|
|
className,
|
|
resolvedActiveProps.className,
|
|
resolvedInactiveProps.className
|
|
].filter(Boolean).join(" ");
|
|
const resolvedStyle = (style || resolvedActiveProps.style || resolvedInactiveProps.style) && {
|
|
...style,
|
|
...resolvedActiveProps.style,
|
|
...resolvedInactiveProps.style
|
|
};
|
|
const [isTransitioning, setIsTransitioning] = React9.useState(false);
|
|
const hasRenderFetched = React9.useRef(false);
|
|
const preload = options.reloadDocument || externalLink ? false : userPreload ?? router.options.defaultPreload;
|
|
const preloadDelay = userPreloadDelay ?? router.options.defaultPreloadDelay ?? 0;
|
|
const doPreload = React9.useCallback(() => {
|
|
router.preloadRoute({ ..._options, _builtLocation: next }).catch((err) => {
|
|
console.warn(err);
|
|
console.warn(preloadWarning);
|
|
});
|
|
}, [router, _options, next]);
|
|
const preloadViewportIoCallback = React9.useCallback(
|
|
(entry) => {
|
|
if (entry?.isIntersecting) {
|
|
doPreload();
|
|
}
|
|
},
|
|
[doPreload]
|
|
);
|
|
useIntersectionObserver(
|
|
innerRef,
|
|
preloadViewportIoCallback,
|
|
intersectionObserverOptions,
|
|
{ disabled: !!disabled || !(preload === "viewport") }
|
|
);
|
|
React9.useEffect(() => {
|
|
if (hasRenderFetched.current) {
|
|
return;
|
|
}
|
|
if (!disabled && preload === "render") {
|
|
doPreload();
|
|
hasRenderFetched.current = true;
|
|
}
|
|
}, [disabled, doPreload, preload]);
|
|
const handleClick = (e) => {
|
|
const elementTarget = e.currentTarget.getAttribute("target");
|
|
const effectiveTarget = target !== void 0 ? target : elementTarget;
|
|
if (!disabled && !isCtrlEvent(e) && !e.defaultPrevented && (!effectiveTarget || effectiveTarget === "_self") && e.button === 0) {
|
|
e.preventDefault();
|
|
(0, import_react_dom.flushSync)(() => {
|
|
setIsTransitioning(true);
|
|
});
|
|
const unsub = router.subscribe("onResolved", () => {
|
|
unsub();
|
|
setIsTransitioning(false);
|
|
});
|
|
router.navigate({
|
|
..._options,
|
|
replace,
|
|
resetScroll,
|
|
hashScrollIntoView,
|
|
startTransition: startTransition2,
|
|
viewTransition,
|
|
ignoreBlocker
|
|
});
|
|
}
|
|
};
|
|
if (externalLink) {
|
|
return {
|
|
...propsSafeToSpread,
|
|
ref: innerRef,
|
|
href: externalLink,
|
|
...children && { children },
|
|
...target && { target },
|
|
...disabled && { disabled },
|
|
...style && { style },
|
|
...className && { className },
|
|
...onClick && { onClick },
|
|
...onBlur && { onBlur },
|
|
...onFocus && { onFocus },
|
|
...onMouseEnter && { onMouseEnter },
|
|
...onMouseLeave && { onMouseLeave },
|
|
...onTouchStart && { onTouchStart }
|
|
};
|
|
}
|
|
const enqueueIntentPreload = (e) => {
|
|
if (disabled || preload !== "intent") return;
|
|
if (!preloadDelay) {
|
|
doPreload();
|
|
return;
|
|
}
|
|
const eventTarget = e.currentTarget;
|
|
if (timeoutMap.has(eventTarget)) {
|
|
return;
|
|
}
|
|
const id = setTimeout(() => {
|
|
timeoutMap.delete(eventTarget);
|
|
doPreload();
|
|
}, preloadDelay);
|
|
timeoutMap.set(eventTarget, id);
|
|
};
|
|
const handleTouchStart = (_) => {
|
|
if (disabled || preload !== "intent") return;
|
|
doPreload();
|
|
};
|
|
const handleLeave = (e) => {
|
|
if (disabled || !preload || !preloadDelay) return;
|
|
const eventTarget = e.currentTarget;
|
|
const id = timeoutMap.get(eventTarget);
|
|
if (id) {
|
|
clearTimeout(id);
|
|
timeoutMap.delete(eventTarget);
|
|
}
|
|
};
|
|
return {
|
|
...propsSafeToSpread,
|
|
...resolvedActiveProps,
|
|
...resolvedInactiveProps,
|
|
href: hrefOption?.href,
|
|
ref: innerRef,
|
|
onClick: composeHandlers([onClick, handleClick]),
|
|
onBlur: composeHandlers([onBlur, handleLeave]),
|
|
onFocus: composeHandlers([onFocus, enqueueIntentPreload]),
|
|
onMouseEnter: composeHandlers([onMouseEnter, enqueueIntentPreload]),
|
|
onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),
|
|
onTouchStart: composeHandlers([onTouchStart, handleTouchStart]),
|
|
disabled: !!disabled,
|
|
target,
|
|
...resolvedStyle && { style: resolvedStyle },
|
|
...resolvedClassName && { className: resolvedClassName },
|
|
...disabled && STATIC_DISABLED_PROPS,
|
|
...isActive && STATIC_ACTIVE_PROPS,
|
|
...isHydrated && isTransitioning && STATIC_TRANSITIONING_PROPS
|
|
};
|
|
}
|
|
var STATIC_EMPTY_OBJECT = {};
|
|
var STATIC_ACTIVE_OBJECT = { className: "active" };
|
|
var STATIC_DISABLED_PROPS = { role: "link", "aria-disabled": true };
|
|
var STATIC_ACTIVE_PROPS = { "data-status": "active", "aria-current": "page" };
|
|
var STATIC_TRANSITIONING_PROPS = { "data-transitioning": "transitioning" };
|
|
var timeoutMap = /* @__PURE__ */ new WeakMap();
|
|
var intersectionObserverOptions = {
|
|
rootMargin: "100px"
|
|
};
|
|
var composeHandlers = (handlers) => (e) => {
|
|
for (const handler of handlers) {
|
|
if (!handler) continue;
|
|
if (e.defaultPrevented) return;
|
|
handler(e);
|
|
}
|
|
};
|
|
function getHrefOption(publicHref, external, history, disabled) {
|
|
if (disabled) return void 0;
|
|
if (external) {
|
|
return { href: publicHref, external: true };
|
|
}
|
|
return {
|
|
href: history.createHref(publicHref) || "/",
|
|
external: false
|
|
};
|
|
}
|
|
function isSafeInternal(to) {
|
|
if (typeof to !== "string") return false;
|
|
const zero = to.charCodeAt(0);
|
|
if (zero === 47) return to.charCodeAt(1) !== 47;
|
|
return zero === 46;
|
|
}
|
|
function createLink(Comp) {
|
|
return React9.forwardRef(function CreatedLink(props, ref) {
|
|
return (0, import_jsx_runtime4.jsx)(Link, { ...props, _asChild: Comp, ref });
|
|
});
|
|
}
|
|
var Link = React9.forwardRef(
|
|
(props, ref) => {
|
|
const { _asChild, ...rest } = props;
|
|
const { type: _type, ...linkProps } = useLinkProps(rest, ref);
|
|
const children = typeof rest.children === "function" ? rest.children({
|
|
isActive: linkProps["data-status"] === "active"
|
|
}) : rest.children;
|
|
if (!_asChild) {
|
|
const { disabled: _, ...rest2 } = linkProps;
|
|
return React9.createElement("a", rest2, children);
|
|
}
|
|
return React9.createElement(_asChild, linkProps, children);
|
|
}
|
|
);
|
|
function isCtrlEvent(e) {
|
|
return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
|
|
}
|
|
var linkOptions = (options) => {
|
|
return options;
|
|
};
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/route.js
|
|
function getRouteApi(id) {
|
|
return new RouteApi({ id });
|
|
}
|
|
var RouteApi = class extends BaseRouteApi {
|
|
/**
|
|
* @deprecated Use the `getRouteApi` function instead.
|
|
*/
|
|
constructor({ id }) {
|
|
super({ id });
|
|
this.useMatch = (opts) => {
|
|
return useMatch({
|
|
select: opts?.select,
|
|
from: this.id,
|
|
structuralSharing: opts?.structuralSharing
|
|
});
|
|
};
|
|
this.useRouteContext = (opts) => {
|
|
return useRouteContext({ ...opts, from: this.id });
|
|
};
|
|
this.useSearch = (opts) => {
|
|
return useSearch({
|
|
select: opts?.select,
|
|
structuralSharing: opts?.structuralSharing,
|
|
from: this.id
|
|
});
|
|
};
|
|
this.useParams = (opts) => {
|
|
return useParams({
|
|
select: opts?.select,
|
|
structuralSharing: opts?.structuralSharing,
|
|
from: this.id
|
|
});
|
|
};
|
|
this.useLoaderDeps = (opts) => {
|
|
return useLoaderDeps({ ...opts, from: this.id, strict: false });
|
|
};
|
|
this.useLoaderData = (opts) => {
|
|
return useLoaderData({ ...opts, from: this.id, strict: false });
|
|
};
|
|
this.useNavigate = () => {
|
|
const router = useRouter();
|
|
return useNavigate({ from: router.routesById[this.id].fullPath });
|
|
};
|
|
this.notFound = (opts) => {
|
|
return notFound({ routeId: this.id, ...opts });
|
|
};
|
|
this.Link = import_react4.default.forwardRef((props, ref) => {
|
|
const router = useRouter();
|
|
const fullPath = router.routesById[this.id].fullPath;
|
|
return (0, import_jsx_runtime5.jsx)(Link, { ref, from: fullPath, ...props });
|
|
});
|
|
}
|
|
};
|
|
var Route = class extends BaseRoute {
|
|
/**
|
|
* @deprecated Use the `createRoute` function instead.
|
|
*/
|
|
constructor(options) {
|
|
super(options);
|
|
this.useMatch = (opts) => {
|
|
return useMatch({
|
|
select: opts?.select,
|
|
from: this.id,
|
|
structuralSharing: opts?.structuralSharing
|
|
});
|
|
};
|
|
this.useRouteContext = (opts) => {
|
|
return useRouteContext({ ...opts, from: this.id });
|
|
};
|
|
this.useSearch = (opts) => {
|
|
return useSearch({
|
|
select: opts?.select,
|
|
structuralSharing: opts?.structuralSharing,
|
|
from: this.id
|
|
});
|
|
};
|
|
this.useParams = (opts) => {
|
|
return useParams({
|
|
select: opts?.select,
|
|
structuralSharing: opts?.structuralSharing,
|
|
from: this.id
|
|
});
|
|
};
|
|
this.useLoaderDeps = (opts) => {
|
|
return useLoaderDeps({ ...opts, from: this.id });
|
|
};
|
|
this.useLoaderData = (opts) => {
|
|
return useLoaderData({ ...opts, from: this.id });
|
|
};
|
|
this.useNavigate = () => {
|
|
return useNavigate({ from: this.fullPath });
|
|
};
|
|
this.Link = import_react4.default.forwardRef(
|
|
(props, ref) => {
|
|
return (0, import_jsx_runtime5.jsx)(Link, { ref, from: this.fullPath, ...props });
|
|
}
|
|
);
|
|
this.$$typeof = /* @__PURE__ */ Symbol.for("react.memo");
|
|
}
|
|
};
|
|
function createRoute(options) {
|
|
return new Route(
|
|
// TODO: Help us TypeChris, you're our only hope!
|
|
options
|
|
);
|
|
}
|
|
function createRootRouteWithContext() {
|
|
return (options) => {
|
|
return createRootRoute(options);
|
|
};
|
|
}
|
|
var rootRouteWithContext = createRootRouteWithContext;
|
|
var RootRoute = class extends BaseRootRoute {
|
|
/**
|
|
* @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
|
|
*/
|
|
constructor(options) {
|
|
super(options);
|
|
this.useMatch = (opts) => {
|
|
return useMatch({
|
|
select: opts?.select,
|
|
from: this.id,
|
|
structuralSharing: opts?.structuralSharing
|
|
});
|
|
};
|
|
this.useRouteContext = (opts) => {
|
|
return useRouteContext({ ...opts, from: this.id });
|
|
};
|
|
this.useSearch = (opts) => {
|
|
return useSearch({
|
|
select: opts?.select,
|
|
structuralSharing: opts?.structuralSharing,
|
|
from: this.id
|
|
});
|
|
};
|
|
this.useParams = (opts) => {
|
|
return useParams({
|
|
select: opts?.select,
|
|
structuralSharing: opts?.structuralSharing,
|
|
from: this.id
|
|
});
|
|
};
|
|
this.useLoaderDeps = (opts) => {
|
|
return useLoaderDeps({ ...opts, from: this.id });
|
|
};
|
|
this.useLoaderData = (opts) => {
|
|
return useLoaderData({ ...opts, from: this.id });
|
|
};
|
|
this.useNavigate = () => {
|
|
return useNavigate({ from: this.fullPath });
|
|
};
|
|
this.Link = import_react4.default.forwardRef(
|
|
(props, ref) => {
|
|
return (0, import_jsx_runtime5.jsx)(Link, { ref, from: this.fullPath, ...props });
|
|
}
|
|
);
|
|
this.$$typeof = /* @__PURE__ */ Symbol.for("react.memo");
|
|
}
|
|
};
|
|
function createRootRoute(options) {
|
|
return new RootRoute(options);
|
|
}
|
|
function createRouteMask(opts) {
|
|
return opts;
|
|
}
|
|
var NotFoundRoute = class extends Route {
|
|
constructor(options) {
|
|
super({
|
|
...options,
|
|
id: "404"
|
|
});
|
|
}
|
|
};
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/fileRoute.js
|
|
function createFileRoute(path) {
|
|
if (typeof path === "object") {
|
|
return new FileRoute(path, {
|
|
silent: true
|
|
}).createRoute(path);
|
|
}
|
|
return new FileRoute(path, {
|
|
silent: true
|
|
}).createRoute;
|
|
}
|
|
var FileRoute = class {
|
|
constructor(path, _opts) {
|
|
this.path = path;
|
|
this.createRoute = (options) => {
|
|
if (true) {
|
|
tiny_warning_esm_default(
|
|
this.silent,
|
|
"FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead."
|
|
);
|
|
}
|
|
const route = createRoute(options);
|
|
route.isRoot = false;
|
|
return route;
|
|
};
|
|
this.silent = _opts?.silent;
|
|
}
|
|
};
|
|
function FileRouteLoader(_path) {
|
|
if (true) {
|
|
tiny_warning_esm_default(
|
|
false,
|
|
`FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \`createFileRoute('/path/to/file')(options)\` options`
|
|
);
|
|
}
|
|
return (loaderFn) => loaderFn;
|
|
}
|
|
var LazyRoute = class {
|
|
constructor(opts) {
|
|
this.useMatch = (opts2) => {
|
|
return useMatch({
|
|
select: opts2?.select,
|
|
from: this.options.id,
|
|
structuralSharing: opts2?.structuralSharing
|
|
});
|
|
};
|
|
this.useRouteContext = (opts2) => {
|
|
return useRouteContext({ ...opts2, from: this.options.id });
|
|
};
|
|
this.useSearch = (opts2) => {
|
|
return useSearch({
|
|
select: opts2?.select,
|
|
structuralSharing: opts2?.structuralSharing,
|
|
from: this.options.id
|
|
});
|
|
};
|
|
this.useParams = (opts2) => {
|
|
return useParams({
|
|
select: opts2?.select,
|
|
structuralSharing: opts2?.structuralSharing,
|
|
from: this.options.id
|
|
});
|
|
};
|
|
this.useLoaderDeps = (opts2) => {
|
|
return useLoaderDeps({ ...opts2, from: this.options.id });
|
|
};
|
|
this.useLoaderData = (opts2) => {
|
|
return useLoaderData({ ...opts2, from: this.options.id });
|
|
};
|
|
this.useNavigate = () => {
|
|
const router = useRouter();
|
|
return useNavigate({ from: router.routesById[this.options.id].fullPath });
|
|
};
|
|
this.options = opts;
|
|
this.$$typeof = /* @__PURE__ */ Symbol.for("react.memo");
|
|
}
|
|
};
|
|
function createLazyRoute(id) {
|
|
return (opts) => {
|
|
return new LazyRoute({
|
|
id,
|
|
...opts
|
|
});
|
|
};
|
|
}
|
|
function createLazyFileRoute(id) {
|
|
if (typeof id === "object") {
|
|
return new LazyRoute(id);
|
|
}
|
|
return (opts) => new LazyRoute({ id, ...opts });
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/lazyRouteComponent.js
|
|
var React10 = __toESM(require_react(), 1);
|
|
function lazyRouteComponent(importer, exportName) {
|
|
let loadPromise;
|
|
let comp;
|
|
let error;
|
|
let reload;
|
|
const load = () => {
|
|
if (!loadPromise) {
|
|
loadPromise = importer().then((res) => {
|
|
loadPromise = void 0;
|
|
comp = res[exportName ?? "default"];
|
|
}).catch((err) => {
|
|
error = err;
|
|
if (isModuleNotFoundError(error)) {
|
|
if (error instanceof Error && typeof window !== "undefined" && typeof sessionStorage !== "undefined") {
|
|
const storageKey2 = `tanstack_router_reload:${error.message}`;
|
|
if (!sessionStorage.getItem(storageKey2)) {
|
|
sessionStorage.setItem(storageKey2, "1");
|
|
reload = true;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return loadPromise;
|
|
};
|
|
const lazyComp = function Lazy(props) {
|
|
if (reload) {
|
|
window.location.reload();
|
|
throw new Promise(() => {
|
|
});
|
|
}
|
|
if (error) {
|
|
throw error;
|
|
}
|
|
if (!comp) {
|
|
if (reactUse) {
|
|
reactUse(load());
|
|
} else {
|
|
throw load();
|
|
}
|
|
}
|
|
return React10.createElement(comp, props);
|
|
};
|
|
lazyComp.preload = load;
|
|
return lazyComp;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/Matches.js
|
|
var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
|
|
var React13 = __toESM(require_react(), 1);
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/Transitioner.js
|
|
var React11 = __toESM(require_react(), 1);
|
|
function Transitioner() {
|
|
const router = useRouter();
|
|
const mountLoadForRouter = React11.useRef({ router, mounted: false });
|
|
const [isTransitioning, setIsTransitioning] = React11.useState(false);
|
|
const { hasPendingMatches, isLoading } = useRouterState({
|
|
select: (s) => ({
|
|
isLoading: s.isLoading,
|
|
hasPendingMatches: s.matches.some((d) => d.status === "pending")
|
|
}),
|
|
structuralSharing: true
|
|
});
|
|
const previousIsLoading = usePrevious(isLoading);
|
|
const isAnyPending = isLoading || isTransitioning || hasPendingMatches;
|
|
const previousIsAnyPending = usePrevious(isAnyPending);
|
|
const isPagePending = isLoading || hasPendingMatches;
|
|
const previousIsPagePending = usePrevious(isPagePending);
|
|
router.startTransition = (fn) => {
|
|
setIsTransitioning(true);
|
|
React11.startTransition(() => {
|
|
fn();
|
|
setIsTransitioning(false);
|
|
});
|
|
};
|
|
React11.useEffect(() => {
|
|
const unsub = router.history.subscribe(router.load);
|
|
const nextLocation = router.buildLocation({
|
|
to: router.latestLocation.pathname,
|
|
search: true,
|
|
params: true,
|
|
hash: true,
|
|
state: true,
|
|
_includeValidateSearch: true
|
|
});
|
|
if (trimPathRight2(router.latestLocation.publicHref) !== trimPathRight2(nextLocation.publicHref)) {
|
|
router.commitLocation({ ...nextLocation, replace: true });
|
|
}
|
|
return () => {
|
|
unsub();
|
|
};
|
|
}, [router, router.history]);
|
|
useLayoutEffect2(() => {
|
|
if (
|
|
// if we are hydrating from SSR, loading is triggered in ssr-client
|
|
typeof window !== "undefined" && router.ssr || mountLoadForRouter.current.router === router && mountLoadForRouter.current.mounted
|
|
) {
|
|
return;
|
|
}
|
|
mountLoadForRouter.current = { router, mounted: true };
|
|
const tryLoad = async () => {
|
|
try {
|
|
await router.load();
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
};
|
|
tryLoad();
|
|
}, [router]);
|
|
useLayoutEffect2(() => {
|
|
if (previousIsLoading && !isLoading) {
|
|
router.emit({
|
|
type: "onLoad",
|
|
// When the new URL has committed, when the new matches have been loaded into state.matches
|
|
...getLocationChangeInfo(router.state)
|
|
});
|
|
}
|
|
}, [previousIsLoading, router, isLoading]);
|
|
useLayoutEffect2(() => {
|
|
if (previousIsPagePending && !isPagePending) {
|
|
router.emit({
|
|
type: "onBeforeRouteMount",
|
|
...getLocationChangeInfo(router.state)
|
|
});
|
|
}
|
|
}, [isPagePending, previousIsPagePending, router]);
|
|
useLayoutEffect2(() => {
|
|
if (previousIsAnyPending && !isAnyPending) {
|
|
const changeInfo = getLocationChangeInfo(router.state);
|
|
router.emit({
|
|
type: "onResolved",
|
|
...changeInfo
|
|
});
|
|
router.__store.setState((s) => ({
|
|
...s,
|
|
status: "idle",
|
|
resolvedLocation: s.location
|
|
}));
|
|
if (changeInfo.hrefChanged) {
|
|
handleHashScroll(router);
|
|
}
|
|
}
|
|
}, [isAnyPending, previousIsAnyPending, router]);
|
|
return null;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/Match.js
|
|
var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
|
|
var React12 = __toESM(require_react(), 1);
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/not-found.js
|
|
var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
|
|
function CatchNotFound(props) {
|
|
const resetKey = useRouterState({
|
|
select: (s) => `not-found-${s.location.pathname}-${s.status}`
|
|
});
|
|
return (0, import_jsx_runtime6.jsx)(
|
|
CatchBoundary,
|
|
{
|
|
getResetKey: () => resetKey,
|
|
onCatch: (error, errorInfo) => {
|
|
if (isNotFound(error)) {
|
|
props.onCatch?.(error, errorInfo);
|
|
} else {
|
|
throw error;
|
|
}
|
|
},
|
|
errorComponent: ({ error }) => {
|
|
if (isNotFound(error)) {
|
|
return props.fallback?.(error);
|
|
} else {
|
|
throw error;
|
|
}
|
|
},
|
|
children: props.children
|
|
}
|
|
);
|
|
}
|
|
function DefaultGlobalNotFound() {
|
|
return (0, import_jsx_runtime6.jsx)("p", { children: "Not Found" });
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/SafeFragment.js
|
|
var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
|
|
function SafeFragment(props) {
|
|
return (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: props.children });
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/renderRouteNotFound.js
|
|
var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
|
|
function renderRouteNotFound(router, route, data) {
|
|
if (!route.options.notFoundComponent) {
|
|
if (router.options.defaultNotFoundComponent) {
|
|
return (0, import_jsx_runtime8.jsx)(router.options.defaultNotFoundComponent, { ...data });
|
|
}
|
|
if (true) {
|
|
tiny_warning_esm_default(
|
|
route.options.notFoundComponent,
|
|
`A notFoundError was encountered on the route with ID "${route.id}", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<p>Not Found</p>)`
|
|
);
|
|
}
|
|
return (0, import_jsx_runtime8.jsx)(DefaultGlobalNotFound, {});
|
|
}
|
|
return (0, import_jsx_runtime8.jsx)(route.options.notFoundComponent, { ...data });
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/scroll-restoration.js
|
|
var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/ScriptOnce.js
|
|
var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
|
|
function ScriptOnce({ children }) {
|
|
const router = useRouter();
|
|
if (!(isServer ?? router.isServer)) {
|
|
return null;
|
|
}
|
|
return (0, import_jsx_runtime9.jsx)(
|
|
"script",
|
|
{
|
|
nonce: router.options.ssr?.nonce,
|
|
dangerouslySetInnerHTML: {
|
|
__html: children + ";document.currentScript.remove()"
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/scroll-restoration.js
|
|
function ScrollRestoration() {
|
|
const router = useRouter();
|
|
if (!router.isScrollRestoring || !(isServer ?? router.isServer)) {
|
|
return null;
|
|
}
|
|
if (typeof router.options.scrollRestoration === "function") {
|
|
const shouldRestore = router.options.scrollRestoration({
|
|
location: router.latestLocation
|
|
});
|
|
if (!shouldRestore) {
|
|
return null;
|
|
}
|
|
}
|
|
const getKey = router.options.getScrollRestorationKey || defaultGetScrollRestorationKey;
|
|
const userKey = getKey(router.latestLocation);
|
|
const resolvedKey = userKey !== defaultGetScrollRestorationKey(router.latestLocation) ? userKey : void 0;
|
|
const restoreScrollOptions = {
|
|
storageKey,
|
|
shouldScrollRestoration: true
|
|
};
|
|
if (resolvedKey) {
|
|
restoreScrollOptions.key = resolvedKey;
|
|
}
|
|
return (0, import_jsx_runtime10.jsx)(
|
|
ScriptOnce,
|
|
{
|
|
children: `(${restoreScroll.toString()})(${escapeHtml(JSON.stringify(restoreScrollOptions))})`
|
|
}
|
|
);
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/Match.js
|
|
var Match = React12.memo(function MatchImpl({
|
|
matchId
|
|
}) {
|
|
const router = useRouter();
|
|
const matchState = useRouterState({
|
|
select: (s) => {
|
|
const matchIndex = s.matches.findIndex((d) => d.id === matchId);
|
|
const match = s.matches[matchIndex];
|
|
invariant(
|
|
match,
|
|
`Could not find match for matchId "${matchId}". Please file an issue!`
|
|
);
|
|
return {
|
|
routeId: match.routeId,
|
|
ssr: match.ssr,
|
|
_displayPending: match._displayPending,
|
|
resetKey: s.loadedAt,
|
|
parentRouteId: s.matches[matchIndex - 1]?.routeId
|
|
};
|
|
},
|
|
structuralSharing: true
|
|
});
|
|
const route = router.routesById[matchState.routeId];
|
|
const PendingComponent = route.options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
const pendingElement = PendingComponent ? (0, import_jsx_runtime11.jsx)(PendingComponent, {}) : null;
|
|
const routeErrorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent;
|
|
const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch;
|
|
const routeNotFoundComponent = route.isRoot ? (
|
|
// If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component
|
|
route.options.notFoundComponent ?? router.options.notFoundRoute?.options.component
|
|
) : route.options.notFoundComponent;
|
|
const resolvedNoSsr = matchState.ssr === false || matchState.ssr === "data-only";
|
|
const ResolvedSuspenseBoundary = (
|
|
// If we're on the root route, allow forcefully wrapping in suspense
|
|
(!route.isRoot || route.options.wrapInSuspense || resolvedNoSsr) && (route.options.wrapInSuspense ?? PendingComponent ?? (route.options.errorComponent?.preload || resolvedNoSsr)) ? React12.Suspense : SafeFragment
|
|
);
|
|
const ResolvedCatchBoundary = routeErrorComponent ? CatchBoundary : SafeFragment;
|
|
const ResolvedNotFoundBoundary = routeNotFoundComponent ? CatchNotFound : SafeFragment;
|
|
const ShellComponent = route.isRoot ? route.options.shellComponent ?? SafeFragment : SafeFragment;
|
|
return (0, import_jsx_runtime11.jsxs)(ShellComponent, { children: [
|
|
(0, import_jsx_runtime11.jsx)(matchContext.Provider, { value: matchId, children: (0, import_jsx_runtime11.jsx)(ResolvedSuspenseBoundary, { fallback: pendingElement, children: (0, import_jsx_runtime11.jsx)(
|
|
ResolvedCatchBoundary,
|
|
{
|
|
getResetKey: () => matchState.resetKey,
|
|
errorComponent: routeErrorComponent || ErrorComponent,
|
|
onCatch: (error, errorInfo) => {
|
|
if (isNotFound(error)) throw error;
|
|
tiny_warning_esm_default(false, `Error in route match: ${matchId}`);
|
|
routeOnCatch?.(error, errorInfo);
|
|
},
|
|
children: (0, import_jsx_runtime11.jsx)(
|
|
ResolvedNotFoundBoundary,
|
|
{
|
|
fallback: (error) => {
|
|
if (!routeNotFoundComponent || error.routeId && error.routeId !== matchState.routeId || !error.routeId && !route.isRoot)
|
|
throw error;
|
|
return React12.createElement(routeNotFoundComponent, error);
|
|
},
|
|
children: resolvedNoSsr || matchState._displayPending ? (0, import_jsx_runtime11.jsx)(ClientOnly, { fallback: pendingElement, children: (0, import_jsx_runtime11.jsx)(MatchInner, { matchId }) }) : (0, import_jsx_runtime11.jsx)(MatchInner, { matchId })
|
|
}
|
|
)
|
|
}
|
|
) }) }),
|
|
matchState.parentRouteId === rootRouteId && router.options.scrollRestoration ? (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
(0, import_jsx_runtime11.jsx)(OnRendered, {}),
|
|
(0, import_jsx_runtime11.jsx)(ScrollRestoration, {})
|
|
] }) : null
|
|
] });
|
|
});
|
|
function OnRendered() {
|
|
const router = useRouter();
|
|
const prevLocationRef = React12.useRef(
|
|
void 0
|
|
);
|
|
return (0, import_jsx_runtime11.jsx)(
|
|
"script",
|
|
{
|
|
suppressHydrationWarning: true,
|
|
ref: (el) => {
|
|
if (el && (prevLocationRef.current === void 0 || prevLocationRef.current.href !== router.latestLocation.href)) {
|
|
router.emit({
|
|
type: "onRendered",
|
|
...getLocationChangeInfo(router.state)
|
|
});
|
|
prevLocationRef.current = router.latestLocation;
|
|
}
|
|
}
|
|
},
|
|
router.latestLocation.state.__TSR_key
|
|
);
|
|
}
|
|
var MatchInner = React12.memo(function MatchInnerImpl({
|
|
matchId
|
|
}) {
|
|
const router = useRouter();
|
|
const { match, key, routeId } = useRouterState({
|
|
select: (s) => {
|
|
const match2 = s.matches.find((d) => d.id === matchId);
|
|
const routeId2 = match2.routeId;
|
|
const remountFn = router.routesById[routeId2].options.remountDeps ?? router.options.defaultRemountDeps;
|
|
const remountDeps = remountFn?.({
|
|
routeId: routeId2,
|
|
loaderDeps: match2.loaderDeps,
|
|
params: match2._strictParams,
|
|
search: match2._strictSearch
|
|
});
|
|
const key2 = remountDeps ? JSON.stringify(remountDeps) : void 0;
|
|
return {
|
|
key: key2,
|
|
routeId: routeId2,
|
|
match: {
|
|
id: match2.id,
|
|
status: match2.status,
|
|
error: match2.error,
|
|
invalid: match2.invalid,
|
|
_forcePending: match2._forcePending,
|
|
_displayPending: match2._displayPending
|
|
}
|
|
};
|
|
},
|
|
structuralSharing: true
|
|
});
|
|
const route = router.routesById[routeId];
|
|
const out = React12.useMemo(() => {
|
|
const Comp = route.options.component ?? router.options.defaultComponent;
|
|
if (Comp) {
|
|
return (0, import_jsx_runtime11.jsx)(Comp, {}, key);
|
|
}
|
|
return (0, import_jsx_runtime11.jsx)(Outlet, {});
|
|
}, [key, route.options.component, router.options.defaultComponent]);
|
|
if (match._displayPending) {
|
|
throw router.getMatch(match.id)?._nonReactive.displayPendingPromise;
|
|
}
|
|
if (match._forcePending) {
|
|
throw router.getMatch(match.id)?._nonReactive.minPendingPromise;
|
|
}
|
|
if (match.status === "pending") {
|
|
const pendingMinMs = route.options.pendingMinMs ?? router.options.defaultPendingMinMs;
|
|
if (pendingMinMs) {
|
|
const routerMatch = router.getMatch(match.id);
|
|
if (routerMatch && !routerMatch._nonReactive.minPendingPromise) {
|
|
if (!(isServer ?? router.isServer)) {
|
|
const minPendingPromise = createControlledPromise();
|
|
routerMatch._nonReactive.minPendingPromise = minPendingPromise;
|
|
setTimeout(() => {
|
|
minPendingPromise.resolve();
|
|
routerMatch._nonReactive.minPendingPromise = void 0;
|
|
}, pendingMinMs);
|
|
}
|
|
}
|
|
}
|
|
throw router.getMatch(match.id)?._nonReactive.loadPromise;
|
|
}
|
|
if (match.status === "notFound") {
|
|
invariant(isNotFound(match.error), "Expected a notFound error");
|
|
return renderRouteNotFound(router, route, match.error);
|
|
}
|
|
if (match.status === "redirected") {
|
|
invariant(isRedirect(match.error), "Expected a redirect error");
|
|
throw router.getMatch(match.id)?._nonReactive.loadPromise;
|
|
}
|
|
if (match.status === "error") {
|
|
if (isServer ?? router.isServer) {
|
|
const RouteErrorComponent = (route.options.errorComponent ?? router.options.defaultErrorComponent) || ErrorComponent;
|
|
return (0, import_jsx_runtime11.jsx)(
|
|
RouteErrorComponent,
|
|
{
|
|
error: match.error,
|
|
reset: void 0,
|
|
info: {
|
|
componentStack: ""
|
|
}
|
|
}
|
|
);
|
|
}
|
|
throw match.error;
|
|
}
|
|
return out;
|
|
});
|
|
var Outlet = React12.memo(function OutletImpl() {
|
|
const router = useRouter();
|
|
const matchId = React12.useContext(matchContext);
|
|
const routeId = useRouterState({
|
|
select: (s) => s.matches.find((d) => d.id === matchId)?.routeId
|
|
});
|
|
const route = router.routesById[routeId];
|
|
const parentGlobalNotFound = useRouterState({
|
|
select: (s) => {
|
|
const matches = s.matches;
|
|
const parentMatch = matches.find((d) => d.id === matchId);
|
|
invariant(
|
|
parentMatch,
|
|
`Could not find parent match for matchId "${matchId}"`
|
|
);
|
|
return parentMatch.globalNotFound;
|
|
}
|
|
});
|
|
const childMatchId = useRouterState({
|
|
select: (s) => {
|
|
const matches = s.matches;
|
|
const index = matches.findIndex((d) => d.id === matchId);
|
|
return matches[index + 1]?.id;
|
|
}
|
|
});
|
|
const pendingElement = router.options.defaultPendingComponent ? (0, import_jsx_runtime11.jsx)(router.options.defaultPendingComponent, {}) : null;
|
|
if (parentGlobalNotFound) {
|
|
return renderRouteNotFound(router, route, void 0);
|
|
}
|
|
if (!childMatchId) {
|
|
return null;
|
|
}
|
|
const nextMatch = (0, import_jsx_runtime11.jsx)(Match, { matchId: childMatchId });
|
|
if (routeId === rootRouteId) {
|
|
return (0, import_jsx_runtime11.jsx)(React12.Suspense, { fallback: pendingElement, children: nextMatch });
|
|
}
|
|
return nextMatch;
|
|
});
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/Matches.js
|
|
function Matches() {
|
|
const router = useRouter();
|
|
const rootRoute = router.routesById[rootRouteId];
|
|
const PendingComponent = rootRoute.options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
const pendingElement = PendingComponent ? (0, import_jsx_runtime12.jsx)(PendingComponent, {}) : null;
|
|
const ResolvedSuspense = (isServer ?? router.isServer) || typeof document !== "undefined" && router.ssr ? SafeFragment : React13.Suspense;
|
|
const inner = (0, import_jsx_runtime12.jsxs)(ResolvedSuspense, { fallback: pendingElement, children: [
|
|
!(isServer ?? router.isServer) && (0, import_jsx_runtime12.jsx)(Transitioner, {}),
|
|
(0, import_jsx_runtime12.jsx)(MatchesInner, {})
|
|
] });
|
|
return router.options.InnerWrap ? (0, import_jsx_runtime12.jsx)(router.options.InnerWrap, { children: inner }) : inner;
|
|
}
|
|
function MatchesInner() {
|
|
const router = useRouter();
|
|
const matchId = useRouterState({
|
|
select: (s) => {
|
|
return s.matches[0]?.id;
|
|
}
|
|
});
|
|
const resetKey = useRouterState({
|
|
select: (s) => s.loadedAt
|
|
});
|
|
const matchComponent = matchId ? (0, import_jsx_runtime12.jsx)(Match, { matchId }) : null;
|
|
return (0, import_jsx_runtime12.jsx)(matchContext.Provider, { value: matchId, children: router.options.disableGlobalCatchBoundary ? matchComponent : (0, import_jsx_runtime12.jsx)(
|
|
CatchBoundary,
|
|
{
|
|
getResetKey: () => resetKey,
|
|
errorComponent: ErrorComponent,
|
|
onCatch: true ? (error) => {
|
|
tiny_warning_esm_default(
|
|
false,
|
|
`The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`
|
|
);
|
|
tiny_warning_esm_default(false, error.message || error.toString());
|
|
} : void 0,
|
|
children: matchComponent
|
|
}
|
|
) });
|
|
}
|
|
function useMatchRoute() {
|
|
const router = useRouter();
|
|
useRouterState({
|
|
select: (s) => [s.location.href, s.resolvedLocation?.href, s.status],
|
|
structuralSharing: true
|
|
});
|
|
return React13.useCallback(
|
|
(opts) => {
|
|
const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts;
|
|
return router.matchRoute(rest, {
|
|
pending,
|
|
caseSensitive,
|
|
fuzzy,
|
|
includeSearch
|
|
});
|
|
},
|
|
[router]
|
|
);
|
|
}
|
|
function MatchRoute(props) {
|
|
const matchRoute = useMatchRoute();
|
|
const params = matchRoute(props);
|
|
if (typeof props.children === "function") {
|
|
return props.children(params);
|
|
}
|
|
return params ? props.children : null;
|
|
}
|
|
function useMatches(opts) {
|
|
return useRouterState({
|
|
select: (state) => {
|
|
const matches = state.matches;
|
|
return opts?.select ? opts.select(matches) : matches;
|
|
},
|
|
structuralSharing: opts?.structuralSharing
|
|
});
|
|
}
|
|
function useParentMatches(opts) {
|
|
const contextMatchId = React13.useContext(matchContext);
|
|
return useMatches({
|
|
select: (matches) => {
|
|
matches = matches.slice(
|
|
0,
|
|
matches.findIndex((d) => d.id === contextMatchId)
|
|
);
|
|
return opts?.select ? opts.select(matches) : matches;
|
|
},
|
|
structuralSharing: opts?.structuralSharing
|
|
});
|
|
}
|
|
function useChildMatches(opts) {
|
|
const contextMatchId = React13.useContext(matchContext);
|
|
return useMatches({
|
|
select: (matches) => {
|
|
matches = matches.slice(
|
|
matches.findIndex((d) => d.id === contextMatchId) + 1
|
|
);
|
|
return opts?.select ? opts.select(matches) : matches;
|
|
},
|
|
structuralSharing: opts?.structuralSharing
|
|
});
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/router.js
|
|
var createRouter = (options) => {
|
|
return new Router(options);
|
|
};
|
|
var Router = class extends RouterCore {
|
|
constructor(options) {
|
|
super(options);
|
|
}
|
|
};
|
|
if (typeof globalThis !== "undefined") {
|
|
globalThis.createFileRoute = createFileRoute;
|
|
globalThis.createLazyFileRoute = createLazyFileRoute;
|
|
} else if (typeof window !== "undefined") {
|
|
window.createFileRoute = createFileRoute;
|
|
window.createLazyFileRoute = createLazyFileRoute;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/RouterProvider.js
|
|
var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
|
|
function RouterContextProvider({
|
|
router,
|
|
children,
|
|
...rest
|
|
}) {
|
|
if (Object.keys(rest).length > 0) {
|
|
router.update({
|
|
...router.options,
|
|
...rest,
|
|
context: {
|
|
...router.options.context,
|
|
...rest.context
|
|
}
|
|
});
|
|
}
|
|
const provider = (0, import_jsx_runtime13.jsx)(routerContext.Provider, { value: router, children });
|
|
if (router.options.Wrap) {
|
|
return (0, import_jsx_runtime13.jsx)(router.options.Wrap, { children: provider });
|
|
}
|
|
return provider;
|
|
}
|
|
function RouterProvider({ router, ...rest }) {
|
|
return (0, import_jsx_runtime13.jsx)(RouterContextProvider, { router, ...rest, children: (0, import_jsx_runtime13.jsx)(Matches, {}) });
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/ScrollRestoration.js
|
|
function useScrollRestoration() {
|
|
const router = useRouter();
|
|
setupScrollRestoration(router, true);
|
|
}
|
|
function ScrollRestoration2(_props) {
|
|
useScrollRestoration();
|
|
if (true) {
|
|
console.warn(
|
|
"The ScrollRestoration component is deprecated. Use createRouter's `scrollRestoration` option instead."
|
|
);
|
|
}
|
|
return null;
|
|
}
|
|
function useElementScrollRestoration(options) {
|
|
useScrollRestoration();
|
|
const router = useRouter();
|
|
const getKey = options.getKey || defaultGetScrollRestorationKey;
|
|
let elementSelector = "";
|
|
if (options.id) {
|
|
elementSelector = `[data-scroll-restoration-id="${options.id}"]`;
|
|
} else {
|
|
const element = options.getElement?.();
|
|
if (!element) {
|
|
return;
|
|
}
|
|
elementSelector = element instanceof Window ? "window" : getCssSelector(element);
|
|
}
|
|
const restoreKey = getKey(router.latestLocation);
|
|
const byKey = scrollRestorationCache?.state[restoreKey];
|
|
return byKey?.[elementSelector];
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/useBlocker.js
|
|
var React14 = __toESM(require_react(), 1);
|
|
function _resolveBlockerOpts(opts, condition) {
|
|
if (opts === void 0) {
|
|
return {
|
|
shouldBlockFn: () => true,
|
|
withResolver: false
|
|
};
|
|
}
|
|
if ("shouldBlockFn" in opts) {
|
|
return opts;
|
|
}
|
|
if (typeof opts === "function") {
|
|
const shouldBlock2 = Boolean(condition ?? true);
|
|
const _customBlockerFn2 = async () => {
|
|
if (shouldBlock2) return await opts();
|
|
return false;
|
|
};
|
|
return {
|
|
shouldBlockFn: _customBlockerFn2,
|
|
enableBeforeUnload: shouldBlock2,
|
|
withResolver: false
|
|
};
|
|
}
|
|
const shouldBlock = Boolean(opts.condition ?? true);
|
|
const fn = opts.blockerFn;
|
|
const _customBlockerFn = async () => {
|
|
if (shouldBlock && fn !== void 0) {
|
|
return await fn();
|
|
}
|
|
return shouldBlock;
|
|
};
|
|
return {
|
|
shouldBlockFn: _customBlockerFn,
|
|
enableBeforeUnload: shouldBlock,
|
|
withResolver: fn === void 0
|
|
};
|
|
}
|
|
function useBlocker(opts, condition) {
|
|
const {
|
|
shouldBlockFn,
|
|
enableBeforeUnload = true,
|
|
disabled = false,
|
|
withResolver = false
|
|
} = _resolveBlockerOpts(opts, condition);
|
|
const router = useRouter();
|
|
const { history } = router;
|
|
const [resolver, setResolver] = React14.useState({
|
|
status: "idle",
|
|
current: void 0,
|
|
next: void 0,
|
|
action: void 0,
|
|
proceed: void 0,
|
|
reset: void 0
|
|
});
|
|
React14.useEffect(() => {
|
|
const blockerFnComposed = async (blockerFnArgs) => {
|
|
function getLocation(location) {
|
|
const parsedLocation = router.parseLocation(location);
|
|
const matchedRoutes = router.getMatchedRoutes(parsedLocation.pathname);
|
|
if (matchedRoutes.foundRoute === void 0) {
|
|
return {
|
|
routeId: "__notFound__",
|
|
fullPath: parsedLocation.pathname,
|
|
pathname: parsedLocation.pathname,
|
|
params: matchedRoutes.routeParams,
|
|
search: router.options.parseSearch(location.search)
|
|
};
|
|
}
|
|
return {
|
|
routeId: matchedRoutes.foundRoute.id,
|
|
fullPath: matchedRoutes.foundRoute.fullPath,
|
|
pathname: parsedLocation.pathname,
|
|
params: matchedRoutes.routeParams,
|
|
search: router.options.parseSearch(location.search)
|
|
};
|
|
}
|
|
const current = getLocation(blockerFnArgs.currentLocation);
|
|
const next = getLocation(blockerFnArgs.nextLocation);
|
|
if (current.routeId === "__notFound__" && next.routeId !== "__notFound__") {
|
|
return false;
|
|
}
|
|
const shouldBlock = await shouldBlockFn({
|
|
action: blockerFnArgs.action,
|
|
current,
|
|
next
|
|
});
|
|
if (!withResolver) {
|
|
return shouldBlock;
|
|
}
|
|
if (!shouldBlock) {
|
|
return false;
|
|
}
|
|
const promise = new Promise((resolve) => {
|
|
setResolver({
|
|
status: "blocked",
|
|
current,
|
|
next,
|
|
action: blockerFnArgs.action,
|
|
proceed: () => resolve(false),
|
|
reset: () => resolve(true)
|
|
});
|
|
});
|
|
const canNavigateAsync = await promise;
|
|
setResolver({
|
|
status: "idle",
|
|
current: void 0,
|
|
next: void 0,
|
|
action: void 0,
|
|
proceed: void 0,
|
|
reset: void 0
|
|
});
|
|
return canNavigateAsync;
|
|
};
|
|
return disabled ? void 0 : history.block({ blockerFn: blockerFnComposed, enableBeforeUnload });
|
|
}, [
|
|
shouldBlockFn,
|
|
enableBeforeUnload,
|
|
disabled,
|
|
withResolver,
|
|
history,
|
|
router
|
|
]);
|
|
return resolver;
|
|
}
|
|
var _resolvePromptBlockerArgs = (props) => {
|
|
if ("shouldBlockFn" in props) {
|
|
return { ...props };
|
|
}
|
|
const shouldBlock = Boolean(props.condition ?? true);
|
|
const fn = props.blockerFn;
|
|
const _customBlockerFn = async () => {
|
|
if (shouldBlock && fn !== void 0) {
|
|
return await fn();
|
|
}
|
|
return shouldBlock;
|
|
};
|
|
return {
|
|
shouldBlockFn: _customBlockerFn,
|
|
enableBeforeUnload: shouldBlock,
|
|
withResolver: fn === void 0
|
|
};
|
|
};
|
|
function Block(opts) {
|
|
const { children, ...rest } = opts;
|
|
const args = _resolvePromptBlockerArgs(rest);
|
|
const resolver = useBlocker(args);
|
|
return children ? typeof children === "function" ? children(resolver) : children : null;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/useLocation.js
|
|
function useLocation(opts) {
|
|
return useRouterState({
|
|
select: (state) => opts?.select ? opts.select(state.location) : state.location
|
|
});
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/useCanGoBack.js
|
|
function useCanGoBack() {
|
|
return useRouterState({ select: (s) => s.location.state.__TSR_index !== 0 });
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/Asset.js
|
|
var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
|
|
var React15 = __toESM(require_react(), 1);
|
|
function Asset({
|
|
tag,
|
|
attrs,
|
|
children,
|
|
nonce
|
|
}) {
|
|
switch (tag) {
|
|
case "title":
|
|
return (0, import_jsx_runtime14.jsx)("title", { ...attrs, suppressHydrationWarning: true, children });
|
|
case "meta":
|
|
return (0, import_jsx_runtime14.jsx)("meta", { ...attrs, suppressHydrationWarning: true });
|
|
case "link":
|
|
return (0, import_jsx_runtime14.jsx)("link", { ...attrs, nonce, suppressHydrationWarning: true });
|
|
case "style":
|
|
return (0, import_jsx_runtime14.jsx)(
|
|
"style",
|
|
{
|
|
...attrs,
|
|
dangerouslySetInnerHTML: { __html: children },
|
|
nonce
|
|
}
|
|
);
|
|
case "script":
|
|
return (0, import_jsx_runtime14.jsx)(Script, { attrs, children });
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
function Script({
|
|
attrs,
|
|
children
|
|
}) {
|
|
const router = useRouter();
|
|
const hydrated = useHydrated();
|
|
const dataScript = typeof attrs?.type === "string" && attrs.type !== "" && attrs.type !== "text/javascript" && attrs.type !== "module";
|
|
if (attrs?.src && typeof children === "string" && children.trim().length) {
|
|
console.warn(
|
|
"[TanStack Router] <Script> received both `src` and `children`. The `children` content will be ignored. Remove `children` or remove `src`."
|
|
);
|
|
}
|
|
React15.useEffect(() => {
|
|
if (dataScript) return;
|
|
if (attrs?.src) {
|
|
const normSrc = (() => {
|
|
try {
|
|
const base = document.baseURI || window.location.href;
|
|
return new URL(attrs.src, base).href;
|
|
} catch {
|
|
return attrs.src;
|
|
}
|
|
})();
|
|
const existingScript = Array.from(
|
|
document.querySelectorAll("script[src]")
|
|
).find((el) => el.src === normSrc);
|
|
if (existingScript) {
|
|
return;
|
|
}
|
|
const script = document.createElement("script");
|
|
for (const [key, value] of Object.entries(attrs)) {
|
|
if (key !== "suppressHydrationWarning" && value !== void 0 && value !== false) {
|
|
script.setAttribute(
|
|
key,
|
|
typeof value === "boolean" ? "" : String(value)
|
|
);
|
|
}
|
|
}
|
|
document.head.appendChild(script);
|
|
return () => {
|
|
if (script.parentNode) {
|
|
script.parentNode.removeChild(script);
|
|
}
|
|
};
|
|
}
|
|
if (typeof children === "string") {
|
|
const typeAttr = typeof attrs?.type === "string" ? attrs.type : "text/javascript";
|
|
const nonceAttr = typeof attrs?.nonce === "string" ? attrs.nonce : void 0;
|
|
const existingScript = Array.from(
|
|
document.querySelectorAll("script:not([src])")
|
|
).find((el) => {
|
|
if (!(el instanceof HTMLScriptElement)) return false;
|
|
const sType = el.getAttribute("type") ?? "text/javascript";
|
|
const sNonce = el.getAttribute("nonce") ?? void 0;
|
|
return el.textContent === children && sType === typeAttr && sNonce === nonceAttr;
|
|
});
|
|
if (existingScript) {
|
|
return;
|
|
}
|
|
const script = document.createElement("script");
|
|
script.textContent = children;
|
|
if (attrs) {
|
|
for (const [key, value] of Object.entries(attrs)) {
|
|
if (key !== "suppressHydrationWarning" && value !== void 0 && value !== false) {
|
|
script.setAttribute(
|
|
key,
|
|
typeof value === "boolean" ? "" : String(value)
|
|
);
|
|
}
|
|
}
|
|
}
|
|
document.head.appendChild(script);
|
|
return () => {
|
|
if (script.parentNode) {
|
|
script.parentNode.removeChild(script);
|
|
}
|
|
};
|
|
}
|
|
return void 0;
|
|
}, [attrs, children, dataScript]);
|
|
if (isServer ?? router.isServer) {
|
|
if (attrs?.src) {
|
|
return (0, import_jsx_runtime14.jsx)("script", { ...attrs, suppressHydrationWarning: true });
|
|
}
|
|
if (typeof children === "string") {
|
|
return (0, import_jsx_runtime14.jsx)(
|
|
"script",
|
|
{
|
|
...attrs,
|
|
dangerouslySetInnerHTML: { __html: children },
|
|
suppressHydrationWarning: true
|
|
}
|
|
);
|
|
}
|
|
return null;
|
|
}
|
|
if (dataScript && typeof children === "string") {
|
|
return (0, import_jsx_runtime14.jsx)(
|
|
"script",
|
|
{
|
|
...attrs,
|
|
suppressHydrationWarning: true,
|
|
dangerouslySetInnerHTML: { __html: children }
|
|
}
|
|
);
|
|
}
|
|
if (!hydrated) {
|
|
if (attrs?.src) {
|
|
return (0, import_jsx_runtime14.jsx)("script", { ...attrs, suppressHydrationWarning: true });
|
|
}
|
|
if (typeof children === "string") {
|
|
return (0, import_jsx_runtime14.jsx)(
|
|
"script",
|
|
{
|
|
...attrs,
|
|
dangerouslySetInnerHTML: { __html: children },
|
|
suppressHydrationWarning: true
|
|
}
|
|
);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/headContentUtils.js
|
|
var React16 = __toESM(require_react(), 1);
|
|
var useTags = () => {
|
|
const router = useRouter();
|
|
const nonce = router.options.ssr?.nonce;
|
|
const routeMeta = useRouterState({
|
|
select: (state) => {
|
|
return state.matches.map((match) => match.meta).filter(Boolean);
|
|
}
|
|
});
|
|
const meta = React16.useMemo(() => {
|
|
const resultMeta = [];
|
|
const metaByAttribute = {};
|
|
let title;
|
|
for (let i = routeMeta.length - 1; i >= 0; i--) {
|
|
const metas = routeMeta[i];
|
|
for (let j = metas.length - 1; j >= 0; j--) {
|
|
const m = metas[j];
|
|
if (!m) continue;
|
|
if (m.title) {
|
|
if (!title) {
|
|
title = {
|
|
tag: "title",
|
|
children: m.title
|
|
};
|
|
}
|
|
} else if ("script:ld+json" in m) {
|
|
try {
|
|
const json = JSON.stringify(m["script:ld+json"]);
|
|
resultMeta.push({
|
|
tag: "script",
|
|
attrs: {
|
|
type: "application/ld+json"
|
|
},
|
|
children: escapeHtml(json)
|
|
});
|
|
} catch {
|
|
}
|
|
} else {
|
|
const attribute = m.name ?? m.property;
|
|
if (attribute) {
|
|
if (metaByAttribute[attribute]) {
|
|
continue;
|
|
} else {
|
|
metaByAttribute[attribute] = true;
|
|
}
|
|
}
|
|
resultMeta.push({
|
|
tag: "meta",
|
|
attrs: {
|
|
...m,
|
|
nonce
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
if (title) {
|
|
resultMeta.push(title);
|
|
}
|
|
if (nonce) {
|
|
resultMeta.push({
|
|
tag: "meta",
|
|
attrs: {
|
|
property: "csp-nonce",
|
|
content: nonce
|
|
}
|
|
});
|
|
}
|
|
resultMeta.reverse();
|
|
return resultMeta;
|
|
}, [routeMeta, nonce]);
|
|
const links = useRouterState({
|
|
select: (state) => {
|
|
const constructed = state.matches.map((match) => match.links).filter(Boolean).flat(1).map((link3) => ({
|
|
tag: "link",
|
|
attrs: {
|
|
...link3,
|
|
nonce
|
|
}
|
|
}));
|
|
const manifest = router.ssr?.manifest;
|
|
const assets = state.matches.map((match) => manifest?.routes[match.routeId]?.assets ?? []).filter(Boolean).flat(1).filter((asset) => asset.tag === "link").map(
|
|
(asset) => ({
|
|
tag: "link",
|
|
attrs: {
|
|
...asset.attrs,
|
|
suppressHydrationWarning: true,
|
|
nonce
|
|
}
|
|
})
|
|
);
|
|
return [...constructed, ...assets];
|
|
},
|
|
structuralSharing: true
|
|
});
|
|
const preloadLinks = useRouterState({
|
|
select: (state) => {
|
|
const preloadLinks2 = [];
|
|
state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach(
|
|
(route) => router.ssr?.manifest?.routes[route.id]?.preloads?.filter(Boolean).forEach((preload) => {
|
|
preloadLinks2.push({
|
|
tag: "link",
|
|
attrs: {
|
|
rel: "modulepreload",
|
|
href: preload,
|
|
nonce
|
|
}
|
|
});
|
|
})
|
|
);
|
|
return preloadLinks2;
|
|
},
|
|
structuralSharing: true
|
|
});
|
|
const styles = useRouterState({
|
|
select: (state) => state.matches.map((match) => match.styles).flat(1).filter(Boolean).map(({ children, ...attrs }) => ({
|
|
tag: "style",
|
|
attrs: {
|
|
...attrs,
|
|
nonce
|
|
},
|
|
children
|
|
})),
|
|
structuralSharing: true
|
|
});
|
|
const headScripts = useRouterState({
|
|
select: (state) => state.matches.map((match) => match.headScripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
|
|
tag: "script",
|
|
attrs: {
|
|
...script,
|
|
nonce
|
|
},
|
|
children
|
|
})),
|
|
structuralSharing: true
|
|
});
|
|
return uniqBy(
|
|
[
|
|
...meta,
|
|
...preloadLinks,
|
|
...links,
|
|
...styles,
|
|
...headScripts
|
|
],
|
|
(d) => {
|
|
return JSON.stringify(d);
|
|
}
|
|
);
|
|
};
|
|
function uniqBy(arr, fn) {
|
|
const seen = /* @__PURE__ */ new Set();
|
|
return arr.filter((item) => {
|
|
const key = fn(item);
|
|
if (seen.has(key)) {
|
|
return false;
|
|
}
|
|
seen.add(key);
|
|
return true;
|
|
});
|
|
}
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/Scripts.js
|
|
var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
|
|
var import_react5 = __toESM(require_react(), 1);
|
|
var Scripts = () => {
|
|
const router = useRouter();
|
|
const nonce = router.options.ssr?.nonce;
|
|
const assetScripts = useRouterState({
|
|
select: (state) => {
|
|
const assetScripts2 = [];
|
|
const manifest = router.ssr?.manifest;
|
|
if (!manifest) {
|
|
return [];
|
|
}
|
|
state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach(
|
|
(route) => manifest.routes[route.id]?.assets?.filter((d) => d.tag === "script").forEach((asset) => {
|
|
assetScripts2.push({
|
|
tag: "script",
|
|
attrs: { ...asset.attrs, nonce },
|
|
children: asset.children
|
|
});
|
|
})
|
|
);
|
|
return assetScripts2;
|
|
},
|
|
structuralSharing: true
|
|
});
|
|
const { scripts } = useRouterState({
|
|
select: (state) => ({
|
|
scripts: state.matches.map((match) => match.scripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
|
|
tag: "script",
|
|
attrs: {
|
|
...script,
|
|
suppressHydrationWarning: true,
|
|
nonce
|
|
},
|
|
children
|
|
}))
|
|
}),
|
|
structuralSharing: true
|
|
});
|
|
let serverBufferedScript = void 0;
|
|
if (router.serverSsr) {
|
|
serverBufferedScript = router.serverSsr.takeBufferedScripts();
|
|
}
|
|
const allScripts = [...scripts, ...assetScripts];
|
|
if (serverBufferedScript) {
|
|
allScripts.unshift(serverBufferedScript);
|
|
}
|
|
return (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children: allScripts.map((asset, i) => (0, import_react5.createElement)(Asset, { ...asset, key: `tsr-scripts-${asset.tag}-${i}` })) });
|
|
};
|
|
|
|
// ../../../node_modules/.pnpm/@tanstack+react-router@1.166.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-router/dist/esm/HeadContent.dev.js
|
|
var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
|
|
var React17 = __toESM(require_react(), 1);
|
|
var import_react6 = __toESM(require_react(), 1);
|
|
var DEV_STYLES_ATTR = "data-tanstack-router-dev-styles";
|
|
function HeadContent() {
|
|
const tags = useTags();
|
|
const router = useRouter();
|
|
const nonce = router.options.ssr?.nonce;
|
|
const hydrated = useHydrated();
|
|
React17.useEffect(() => {
|
|
if (hydrated) {
|
|
document.querySelectorAll(`link[${DEV_STYLES_ATTR}]`).forEach((el) => el.remove());
|
|
}
|
|
}, [hydrated]);
|
|
const filteredTags = hydrated ? tags.filter((tag) => !tag.attrs?.[DEV_STYLES_ATTR]) : tags;
|
|
return (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: filteredTags.map((tag) => (0, import_react6.createElement)(Asset, { ...tag, key: `tsr-meta-${JSON.stringify(tag)}`, nonce })) });
|
|
}
|
|
export {
|
|
Asset,
|
|
Await,
|
|
Block,
|
|
CatchBoundary,
|
|
CatchNotFound,
|
|
ClientOnly,
|
|
DEFAULT_PROTOCOL_ALLOWLIST,
|
|
DefaultGlobalNotFound,
|
|
ErrorComponent,
|
|
FileRoute,
|
|
FileRouteLoader,
|
|
HeadContent,
|
|
LazyRoute,
|
|
Link,
|
|
Match,
|
|
MatchRoute,
|
|
Matches,
|
|
Navigate,
|
|
NotFoundRoute,
|
|
Outlet,
|
|
RootRoute,
|
|
Route,
|
|
RouteApi,
|
|
Router,
|
|
RouterContextProvider,
|
|
RouterProvider,
|
|
ScriptOnce,
|
|
Scripts,
|
|
ScrollRestoration2 as ScrollRestoration,
|
|
SearchParamError,
|
|
cleanPath,
|
|
composeRewrites,
|
|
createBrowserHistory,
|
|
createControlledPromise,
|
|
createFileRoute,
|
|
createHashHistory,
|
|
createHistory,
|
|
createLazyFileRoute,
|
|
createLazyRoute,
|
|
createLink,
|
|
createMemoryHistory,
|
|
createRootRoute,
|
|
createRootRouteWithContext,
|
|
createRoute,
|
|
createRouteMask,
|
|
createRouter,
|
|
createRouterConfig,
|
|
createSerializationAdapter,
|
|
deepEqual,
|
|
defaultParseSearch,
|
|
defaultStringifySearch,
|
|
defer,
|
|
functionalUpdate,
|
|
getRouteApi,
|
|
interpolatePath,
|
|
isMatch,
|
|
isNotFound,
|
|
isPlainArray,
|
|
isPlainObject,
|
|
isRedirect,
|
|
joinPaths,
|
|
lazyFn,
|
|
lazyRouteComponent,
|
|
linkOptions,
|
|
notFound,
|
|
parseSearchWith,
|
|
redirect,
|
|
replaceEqualDeep,
|
|
resolvePath,
|
|
retainSearchParams,
|
|
rootRouteId,
|
|
rootRouteWithContext,
|
|
stringifySearchWith,
|
|
stripSearchParams,
|
|
trimPath,
|
|
trimPathLeft,
|
|
trimPathRight2 as trimPathRight,
|
|
useAwaited,
|
|
useBlocker,
|
|
useCanGoBack,
|
|
useChildMatches,
|
|
useElementScrollRestoration,
|
|
useHydrated,
|
|
useLinkProps,
|
|
useLoaderData,
|
|
useLoaderDeps,
|
|
useLocation,
|
|
useMatch,
|
|
useMatchRoute,
|
|
useMatches,
|
|
useNavigate,
|
|
useParams,
|
|
useParentMatches,
|
|
useRouteContext,
|
|
useRouter,
|
|
useRouterState,
|
|
useSearch,
|
|
useTags
|
|
};
|
|
//# sourceMappingURL=@tanstack_react-router.js.map
|