Files
Hello/web/node_modules/.vite/deps/@tanstack_react-router.js
T

7481 lines
267 KiB
JavaScript

"use client";
import {
require_jsx_runtime
} from "./chunk-3YC6FNW3.js";
import {
__commonJS,
__toESM,
require_react
} from "./chunk-VL44HY2N.js";
// 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/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, getSnapshot2) {
didWarnOld18Alpha || void 0 === React3.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 = getSnapshot2();
if (!didWarnUncachedGetSnapshot) {
var cachedValue = getSnapshot2();
objectIs(value, cachedValue) || (console.error(
"The result of getSnapshot should be cached to avoid an infinite loop"
), didWarnUncachedGetSnapshot = true);
}
cachedValue = useState7({
inst: { value, getSnapshot: getSnapshot2 }
});
var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
useLayoutEffect3(
function() {
inst.value = value;
inst.getSnapshot = getSnapshot2;
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
},
[subscribe2, value, getSnapshot2]
);
useEffect6(
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, getSnapshot2) {
return getSnapshot2();
}
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
var React3 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState7 = React3.useState, useEffect6 = React3.useEffect, useLayoutEffect3 = React3.useLayoutEffect, useDebugValue = React3.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 !== React3.useSyncExternalStore ? React3.useSyncExternalStore : shim;
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
})();
}
});
// node_modules/use-sync-external-store/shim/index.js
var require_shim = __commonJS({
"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/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
var require_with_selector_development = __commonJS({
"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 React3 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = shim.useSyncExternalStore, useRef5 = React3.useRef, useEffect6 = React3.useEffect, useMemo5 = React3.useMemo, useDebugValue = React3.useDebugValue;
exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot2, getServerSnapshot2, selector, isEqual) {
var instRef = useRef5(null);
if (null === instRef.current) {
var inst = { hasValue: false, value: null };
instRef.current = inst;
} else inst = instRef.current;
instRef = useMemo5(
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 === getServerSnapshot2 ? null : getServerSnapshot2;
return [
function() {
return memoizedSelector(getSnapshot2());
},
null === maybeGetServerSnapshot ? void 0 : function() {
return memoizedSelector(maybeGetServerSnapshot());
}
];
},
[getSnapshot2, getServerSnapshot2, selector, isEqual]
);
var value = useSyncExternalStore(subscribe2, instRef[0], instRef[1]);
useEffect6(
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/use-sync-external-store/shim/with-selector.js
var require_with_selector = __commonJS({
"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/@tanstack/react-router/dist/esm/utils.js
var React$1 = __toESM(require_react(), 1);
// 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 == null ? void 0 : obj.isNotFound) === true;
}
// node_modules/@tanstack/router-core/dist/esm/root.js
var rootRouteId = "__root__";
// node_modules/@tanstack/router-core/dist/esm/redirect.js
function redirect(opts) {
opts.statusCode = opts.statusCode || opts.code || 307;
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/@tanstack/router-core/dist/esm/utils.js
function last(arr) {
return arr[arr.length - 1];
}
function functionalUpdate(updater, previous) {
if (typeof updater === "function") return updater(previous);
return updater;
}
var hasOwn = Object.prototype.hasOwnProperty;
function hasKeys(obj) {
for (const key in obj) if (hasOwn.call(obj, key)) return true;
return false;
}
var createNull = () => /* @__PURE__ */ Object.create(null);
var nullReplaceEqualDeep = (prev, next) => replaceEqualDeep(prev, next, true);
function replaceEqualDeep(prev, next, _nullProto, _depth = 0) {
if (isServer) return next;
if (prev === next) return prev;
if (_depth++ > 500) return next;
const array = Array.isArray(prev) && Array.isArray(next);
if (!array && !(isPlainObject(prev) && isPlainObject(next))) return next;
const prevKeys = Object.keys(prev);
const previousCount = prevKeys.length;
const nextKeys = Object.keys(next);
const length = nextKeys.length;
if (array ? previousCount !== prev.length || length !== next.length || previousCount && last(prevKeys) !== `${previousCount - 1}` || length && last(nextKeys) !== `${length - 1}` : previousCount !== Object.getOwnPropertyNames(prev).length || length !== Object.getOwnPropertyNames(next).length || Object.getOwnPropertySymbols(next).length) return next;
let i = 0;
let child;
let previous;
let key;
if (array) {
for (; i < length; i++) {
key = i;
previous = prev[key];
child = next[key];
child = previous === child ? previous : typeof previous === "object" ? replaceEqualDeep(previous, child, _nullProto, _depth) : child;
if (child !== previous) break;
}
if (i === length && previousCount === length) return prev;
} else {
let equal = previousCount === length;
let unchanged = true;
for (; i < length; i++) {
key = nextKeys[i];
previous = prev[key];
const incoming = next[key];
child = previous === incoming ? previous : typeof previous === "object" ? replaceEqualDeep(previous, incoming, _nullProto, _depth) : incoming;
equal && (equal = child === previous && (prevKeys[i] === key || hasOwn.call(prev, key)));
unchanged && (unchanged = Object.is(child, incoming));
prevKeys[i] = child;
}
if (equal) return Object.getOwnPropertySymbols(prev).length ? next : prev;
if (unchanged) return next;
}
const copy = array ? nextKeys.fill(0) : _nullProto ? createNull() : {};
for (let j = 0; j < length; j++) {
key = array ? j : nextKeys[j];
if (array) {
previous = prev[key];
if (j > i) {
child = next[key];
child = previous === child ? previous : typeof previous === "object" ? replaceEqualDeep(previous, child, _nullProto, _depth) : child;
}
copy[key] = j < i ? previous : child;
} else copy[key] = prevKeys[j];
}
return copy;
}
function isPlainObject(o) {
var _a;
if (!o || typeof o !== "object") return false;
return (((_a = Object.getPrototypeOf(o)) == null ? void 0 : _a.constructor) ?? Object) === Object;
}
function deepEqual(a, b, partial, explicitUndefined) {
if (a === b) return true;
if (Array.isArray(a) && Array.isArray(b)) {
if (a.length !== b.length) return false;
for (let i = 0, l = a.length; i < l; i++) {
const av = a[i];
const bv = b[i];
if (av !== bv && !deepEqual(av, bv, partial, explicitUndefined)) return false;
}
return true;
}
if (isPlainObject(a) && isPlainObject(b)) {
if (partial) {
for (const k in b) if (explicitUndefined || b[k] !== void 0) {
if (!deepEqual(a[k], b[k], partial, explicitUndefined)) return false;
}
return true;
}
let aCount = 0;
if (explicitUndefined) aCount = Object.keys(a).length;
else for (const k in a) if (a[k] !== void 0) aCount++;
for (const k in b) if (explicitUndefined || b[k] !== void 0) {
if (aCount-- === 0 || !deepEqual(a[k], b[k], partial, explicitUndefined)) return false;
}
return aCount === 0;
}
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 == null ? void 0 : onResolve(value);
};
controlledPromise.reject = (e) => {
controlledPromise.status = "rejected";
rejectLoadPromise(e);
};
return controlledPromise;
}
function isModuleNotFoundError(error) {
if (typeof (error == null ? void 0 : 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 findLast(array, predicate) {
for (let i = array.length - 1; i >= 0; i--) {
const item = array[i];
if (predicate(item)) return item;
}
}
var PATH_UNSAFE_RE = /[\x00-\x1f\x7f"<>`{}]/g;
function sanitizePathSegment(segment) {
return segment.replace(PATH_UNSAFE_RE, (ch) => "%" + ch.charCodeAt(0).toString(16).toUpperCase().padStart(2, "0"));
}
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 = [
"http:",
"https:",
"mailto:",
"tel:"
];
function getUrlScheme(url) {
var _a, _b;
if (url[0] === "/") return;
if (!url.includes(":")) return;
return (_b = (_a = /^[\x00-\x20]*([a-z][a-z\d+.\t\n\r-]*:)/i.exec(url)) == null ? void 0 : _a[1]) == null ? void 0 : _b.replace(/[\t\n\r]/g, "").toLowerCase();
}
var protocolRelativePrefixRegex = /^[\x00-\x20]*[\\/][\t\n\r]*[\\/]/;
function isDangerousProtocol(url, allowlist) {
if (!url) return false;
if (protocolRelativePrefixRegex.test(url)) return true;
const scheme = getUrlScheme(url);
return scheme ? !allowlist.has(scheme) : 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;
let result = path;
if (/[%\\\x00-\x1f\x7f]/.test(path)) {
const re = /%25|%5C/gi;
let cursor = 0;
let match;
result = "";
while (null !== (match = re.exec(path))) {
result += decodeSegment(path.slice(cursor, match.index)) + match[0];
cursor = re.lastIndex;
}
result += decodeSegment(cursor ? path.slice(cursor) : path);
}
return result;
}
function encodePathLikeUrl(path) {
if (!/[\s\u0080-\uFFFF]/.test(path)) return path;
return path.replace(/\s|[^\u0000-\u007F]/gu, encodeURIComponent);
}
function arraysEqual(a, b) {
if (a === b) return true;
if (a.length !== b.length) return false;
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
return true;
}
// 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(/^\/+/, "");
}
function trimPathRight(path) {
const len = path.length;
return len > 1 && path[len - 1] === "/" ? path.replace(/\/+$/, "") : path;
}
function trimPath(path) {
return trimPathRight(trimPathLeft(path));
}
function removeTrailingSlash(value, basepath) {
if ((value == null ? void 0 : value.endsWith("/")) && value !== "/" && value !== `${basepath}/`) return value.slice(0, -1);
return value;
}
function resolvePath(base, to, trailingSlash = "never", cache) {
if (to.includes("//")) to = cleanPath(to);
if (to.startsWith("/")) {
if (to.length === 1 || trailingSlash === "preserve") return to;
if (trailingSlash === "always") return to.endsWith("/") ? to : `${to}/`;
return to.endsWith("/") ? to.slice(0, -1) : to;
}
const isBase = to === ".";
let key;
if (cache) {
key = isBase ? base : base + "\0" + to;
const cached = cache.get(key);
if (cached) return cached;
}
let baseSegments;
if (isBase) baseSegments = base.split("/");
else {
if (base.includes("//")) base = cleanPath(base);
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 if (value === "..") if (baseSegments.length > 1) baseSegments.pop();
else baseSegments = [""];
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("");
}
const joined = baseSegments.join("/");
const result = (isBase ? cleanPath(joined) : joined) || "/";
if (key && cache) cache.set(key, result);
return result;
}
function compileDecodeCharMap(pathParamsAllowedCharacters) {
const charMap = new Map(pathParamsAllowedCharacters.map((char) => [encodeURIComponent(char), char]));
const regex = new RegExp([...charMap.keys()].join("|").replace(/[.*()]/g, "\\$&"), "g");
return (encoded) => encoded.replace(regex, (match) => charMap.get(match) ?? match);
}
function isMissingSplat(value) {
return value == null || value === "";
}
function encodeParam(key, value, decoder) {
if (typeof value !== "string") return "" + (value ?? void 0);
const splat = key === "_splat";
if (splat && (!value || /^[a-zA-Z0-9\-._~!/]*$/.test(value))) return value;
let encoded = encodeURIComponent(value);
if (splat) encoded = encoded.replaceAll("%2F", "/");
return decoder ? decoder(encoded) : encoded;
}
function interpolatePath(path, segments, params, decoder, usedParams) {
const trailingSlash = path.endsWith("/") ? "/" : "";
let joined = "";
for (const part of segments) {
if (typeof part === "string") {
joined += part;
continue;
}
const [kind, key, prefix, rawSuffix] = part;
const splat = kind === 2;
const suffix = splat && rawSuffix !== void 0 ? rawSuffix + trailingSlash : rawSuffix;
let paramValue = params[key];
if (kind === 3 && paramValue == null) continue;
if (usedParams) {
usedParams[key] = paramValue;
if (splat) usedParams["*"] = paramValue;
}
if (splat && isMissingSplat(paramValue)) {
if (prefix === "/" && !suffix) continue;
paramValue = "";
}
joined += prefix + encodeParam(key, paramValue, decoder) + (suffix || "");
}
return joined + trailingSlash || "/";
}
// node_modules/@tanstack/router-core/dist/esm/sieve-cache.js
function createSieveCache(max) {
const cache = /* @__PURE__ */ new Map();
let hand;
let newest;
return {
get(key) {
const entry = cache.get(key);
if (!entry) return;
entry.visited = true;
return entry.value;
},
set(key, value) {
const existing = cache.get(key);
if (existing) {
existing.value = value;
return;
}
if (cache.size >= max) {
let node = hand == null ? void 0 : hand.next().value;
while (!node || node.visited) {
if (node) node.visited = false;
else hand = cache.values();
node = hand.next().value;
}
if (node === newest) hand = void 0;
cache.delete(node.key);
}
const entry = {
key,
value,
visited: false
};
newest = entry;
cache.set(key, entry);
},
clear() {
cache.clear();
hand = void 0;
newest = void 0;
}
};
}
// node_modules/@tanstack/router-core/dist/esm/invariant.js
function invariant() {
throw new Error("Invariant failed");
}
// node_modules/@tanstack/router-core/dist/esm/new-process-route-tree.js
var SEGMENT_TYPE_INDEX = 4;
var SEGMENT_TYPE_PATHLESS = 5;
function getParamNames(data) {
const cached = data.names;
if (cached) return cached;
const keys = [];
for (const segment of data) if (typeof segment !== "string") keys.push(segment[1]);
return data.names = keys;
}
function parseSegment(path, start, end) {
const part = path.substring(start, end);
if (part.charCodeAt(0) === 36) return part.length === 1 ? [
2,
"_splat",
"",
void 0
] : [
1,
part.substring(1),
"",
""
];
const open = part.indexOf("{");
if (open >= 0) {
const close = part.indexOf("}", open);
const optional = part.charCodeAt(open + 1) === 45;
const nameStart = open + (optional ? 3 : 2);
if (close >= 0 && part.charCodeAt(nameStart - 1) === 36 && (!optional || nameStart < close)) {
const key = part.substring(nameStart, close);
return [
optional ? 3 : key ? 1 : 2,
key || "_splat",
part.substring(0, open),
path.substring(start + close + 1, key ? end : path.length)
];
}
}
return part;
}
function parseSegments(defaultCaseSensitive, route, start, node, dynamicListsToSort, parentInterpolation) {
var _a, _b;
let cursor = start;
const path = route.fullPath ?? route.from;
const options = route.options;
const length = path.length;
const literalEnd = path.endsWith("/") ? length - 1 : length;
const caseSensitive = (options == null ? void 0 : options.caseSensitive) ?? defaultCaseSensitive;
const parseParams = ((_a = options == null ? void 0 : options.params) == null ? void 0 : _a.parse) ?? (options == null ? void 0 : options.parseParams);
let interpolation;
let literalStart = parentInterpolation ? start - 1 : 0;
if (!node || path.includes("$")) {
interpolation = (parentInterpolation == null ? void 0 : parentInterpolation.slice()) ?? [];
const tail = last(interpolation);
if (tail && typeof tail !== "string" && tail[0] === 2) {
interpolation[interpolation.length - 1] = [
tail[0],
tail[1],
tail[2],
tail[3] === void 0 ? void 0 : tail[3] + path.substring(start - (path[start - 2] === "/" ? 2 : 1), literalEnd)
];
literalStart = length;
}
}
while (cursor < length) {
const start2 = cursor;
const next = path.indexOf("/", start2);
let end = next === -1 ? length : next;
const segment = parseSegment(path, start2, end);
cursor = end + 1;
let nextNode;
if (typeof segment === "string") {
if (!node) continue;
let name = segment;
let staticChildren;
if (caseSensitive) staticChildren = node.static ?? (node.static = /* @__PURE__ */ new Map());
else {
name = segment.toLowerCase();
staticChildren = node.staticInsensitive ?? (node.staticInsensitive = /* @__PURE__ */ new Map());
}
const existingNode = staticChildren.get(name);
if (existingNode) nextNode = existingNode;
else {
const next2 = createSegmentNode(node);
nextNode = next2;
staticChildren.set(name, next2);
}
} else {
const kind = segment[0];
let prefix = segment[2];
let suffix = segment[3] ?? "";
if (kind === 2) {
end = length;
cursor = end + 1;
}
if (interpolation && literalStart < end) {
if (literalStart < start2 - 1) interpolation.push(path.substring(literalStart, start2 - 1));
segment[2] = "/" + prefix;
if (kind === 2 && segment[3] !== void 0 && literalEnd < length) segment[3] = suffix.slice(0, -1);
interpolation.push(segment);
literalStart = end;
}
if (!node) continue;
const actuallyCaseSensitive = caseSensitive && !!(prefix || suffix);
if (!caseSensitive) {
prefix = prefix.toLowerCase();
suffix = suffix.toLowerCase();
}
const siblings = kind === 1 ? node.dynamic ?? (node.dynamic = []) : kind === 3 ? node.optional ?? (node.optional = []) : node.wildcard ?? (node.wildcard = []);
const existingNode = kind !== 2 && !parseParams && siblings.find((s) => !s.parse && s.caseSensitive === actuallyCaseSensitive && s.prefix === prefix && s.suffix === suffix);
if (existingNode) nextNode = existingNode;
else {
const next2 = createSegmentNode(node, kind, actuallyCaseSensitive, prefix, suffix);
nextNode = next2;
siblings.push(next2);
if (siblings.length === 2) dynamicListsToSort == null ? void 0 : dynamicListsToSort.push(siblings);
}
}
node = nextNode;
}
if (interpolation && literalStart < literalEnd) interpolation.push(path.substring(literalStart, literalEnd));
const segmentData = interpolation == null ? void 0 : interpolation.slice();
if (!node) return segmentData;
if (parseParams && route.children && !route.isRoot && route.id && route.id.charCodeAt(route.id.lastIndexOf("/") + 1) === 95) {
const pathlessNode = createSegmentNode(node, SEGMENT_TYPE_PATHLESS);
(node.pathless ?? (node.pathless = [])).push(pathlessNode);
node = pathlessNode;
}
const isLeaf = (route.path || !route.children) && !route.isRoot;
if (isLeaf && literalEnd < length) {
const indexNode = createSegmentNode(node, SEGMENT_TYPE_INDEX);
node.index = indexNode;
node = indexNode;
}
node.parse = parseParams ?? null;
node.priority = ((_b = options == null ? void 0 : options.params) == null ? void 0 : _b.priority) ?? 0;
if (!node.route) {
node.data = segmentData;
if (isLeaf) node.route = route;
}
return [
node,
cursor,
segmentData
];
}
function sortDynamic(a, b) {
if (a.parse && !b.parse) return -1;
if (!a.parse && b.parse) return 1;
if (a.parse && b.parse && (a.priority || b.priority)) return b.priority - a.priority;
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 createSegmentNode(parent, kind = 0, caseSensitive, prefix, suffix) {
return {
kind,
depth: parent ? parent.depth + 1 : 0,
pathless: null,
index: null,
static: null,
staticInsensitive: null,
dynamic: null,
optional: null,
wildcard: null,
route: null,
data: void 0,
parent,
parse: null,
priority: 0,
caseSensitive,
prefix,
suffix
};
}
function processRouteMasks(routeList, processedTree) {
const segmentTree = createSegmentNode();
const dynamicListsToSort = [];
function visit(route, start, parentNode, parentInterpolation) {
const [node, cursor, segments] = parseSegments(false, route, start, parentNode, dynamicListsToSort, parentInterpolation);
if (route.children) for (const child of route.children) visit(child, cursor, node, segments);
}
for (const route of routeList) visit(route, 1, segmentTree);
for (const nodes of dynamicListsToSort) nodes.sort(sortDynamic);
processedTree.masksTree = segmentTree;
processedTree.flatCache = createSieveCache(1e3);
}
function findFlatMatch(path, processedTree) {
path || (path = "/");
const cached = processedTree.flatCache.get(path);
if (cached !== void 0) return cached;
const result = findMatch(path, processedTree.masksTree);
processedTree.flatCache.set(path, result);
return result;
}
function findSingleMatch(from, caseSensitive, fuzzy, path, processedTree) {
from || (from = "/");
path || (path = "/");
const key = caseSensitive ? `case\0${from}` : from;
let tree = processedTree.singleCache.get(key);
if (!tree) {
tree = createSegmentNode();
parseSegments(caseSensitive, { from }, 1, tree);
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 || (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 processRouteTree(routeTree, caseSensitive = false) {
const segmentTree = createSegmentNode();
const dynamicListsToSort = [];
const routesById = {};
const routesByPath = {};
let index = 0;
function visit(route, start, parentNode, parentInterpolation) {
route.init(index);
if (route.id in routesById) {
if (true) throw new Error(`Invariant failed: Duplicate routes found with id: ${String(route.id)}`);
invariant();
}
routesById[route.id] = route;
if (index !== 0 && route.path) {
const trimmedFullPath = trimPathRight(route.fullPath);
if (!routesByPath[trimmedFullPath] || route.fullPath.endsWith("/")) routesByPath[trimmedFullPath] = route;
}
index++;
const [node, cursor, segments] = parseSegments(caseSensitive, route, start, parentNode, dynamicListsToSort, parentInterpolation);
route._interpolation = segments;
if (route.children) for (const child of route.children) visit(child, cursor, node, segments);
}
visit(routeTree, 1, segmentTree);
for (const nodes of dynamicListsToSort) nodes.sort(sortDynamic);
return {
processedTree: {
segmentTree,
singleCache: createSieveCache(1e3),
matchCache: createSieveCache(1e3),
flatCache: null,
masksTree: null
},
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
};
}
function extractParams(path, parts, leaf) {
var _a, _b, _c, _d;
const list = buildBranch(leaf.node);
const names = leaf.node.data && getParamNames(leaf.node.data);
const rawParams = /* @__PURE__ */ Object.create(null);
let partIndex = ((_a = leaf.extract) == null ? void 0 : _a.part) ?? 0;
let nodeIndex = ((_b = leaf.extract) == null ? void 0 : _b.node) ?? 0;
let pathIndex = ((_c = leaf.extract) == null ? void 0 : _c.path) ?? 0;
let paramIndex = ((_d = leaf.extract) == null ? void 0 : _d.param) ?? 0;
for (; nodeIndex < list.length; partIndex++, nodeIndex++, pathIndex++) {
const node = list[nodeIndex];
if (node.kind === SEGMENT_TYPE_INDEX) break;
if (node.kind === SEGMENT_TYPE_PATHLESS) {
partIndex--;
pathIndex--;
continue;
}
const part = parts[partIndex];
const currentPathIndex = pathIndex;
if (part) pathIndex += part.length;
if (node.kind === 1 || node.kind === 3) {
const name = names[paramIndex++];
if (node.kind === 3 && leaf.skipped & 1 << nodeIndex) {
partIndex--;
pathIndex = currentPathIndex - 1;
continue;
}
const value = node.suffix || node.prefix ? part.substring(node.prefix.length, part.length - node.suffix.length) : part;
if (value || node.kind === 1) rawParams[name] = decodeURIComponent(value);
} else if (node.kind === 2) {
const n = node;
const value = path.substring(currentPathIndex + n.prefix.length, path.length - n.suffix.length);
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,
param: paramIndex
}];
}
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,
statics: 0,
dynamics: 0,
optionals: 0
}];
let bestFuzzy = null;
let bestMatch = null;
while (stack.length) {
const frame = stack.pop();
const { node, index, skipped, statics, dynamics, optionals } = frame;
let { extract, rawParams } = frame;
if (node.kind === 2 && node.route && !isFrameMoreSpecific(bestMatch, frame)) continue;
if (node.parse) {
if (!validateParseParams(path, parts, frame)) continue;
rawParams = frame.rawParams;
extract = frame.extract;
}
if (fuzzy && node.route && node.kind !== SEGMENT_TYPE_INDEX && isFrameMoreSpecific(bestFuzzy, frame)) bestFuzzy = frame;
const isBeyondPath = index === partsLength;
if (isBeyondPath) {
if (node.route && (!pathIsIndex || node.kind === SEGMENT_TYPE_INDEX || node.kind === 2) && 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,
statics,
dynamics,
optionals,
extract,
rawParams
};
let indexValid = true;
if (node.index.parse) {
if (!validateParseParams(path, parts, indexFrame)) indexValid = false;
}
if (indexValid) {
if (!dynamics && !optionals && !skipped && isPerfectStaticMatch(statics, partsLength)) return indexFrame;
if (isFrameMoreSpecific(bestMatch, indexFrame)) bestMatch = indexFrame;
}
}
if (node.wildcard) for (let i = node.wildcard.length - 1; i >= 0; i--) {
const segment = node.wildcard[i];
const { prefix, suffix } = segment;
if (prefix) {
if (isBeyondPath) continue;
if (!(segment.caseSensitive ? part : lowerPart ?? (lowerPart = part.toLowerCase())).startsWith(prefix)) continue;
}
if (suffix) {
if (isBeyondPath) continue;
const end = parts.slice(index).join("/");
const suffixPart = end.slice(-suffix.length);
if ((segment.caseSensitive ? suffixPart : suffixPart.toLowerCase()) !== suffix || end.length - suffix.length < prefix.length) continue;
}
stack.push({
node: segment,
index: partsLength,
skipped,
statics,
dynamics,
optionals,
extract,
rawParams
});
}
if (node.optional) {
const nextSkipped = skipped | 1 << node.depth + 1;
for (let i = node.optional.length - 1; i >= 0; i--) {
const segment = node.optional[i];
stack.push({
node: segment,
index,
skipped: nextSkipped,
statics,
dynamics,
optionals,
extract,
rawParams
});
}
if (!isBeyondPath) for (let i = node.optional.length - 1; i >= 0; i--) {
const segment = node.optional[i];
const { prefix, suffix } = segment;
if (prefix || suffix) {
const casePart = segment.caseSensitive ? part : lowerPart ?? (lowerPart = part.toLowerCase());
if (prefix && !casePart.startsWith(prefix)) continue;
if (suffix && casePart.indexOf(suffix, casePart.length - suffix.length) < prefix.length) continue;
}
stack.push({
node: segment,
index: index + 1,
skipped,
statics,
dynamics,
optionals: optionals + segmentScore(partsLength, index),
extract,
rawParams
});
}
}
if (!isBeyondPath && node.dynamic && part) for (let i = node.dynamic.length - 1; i >= 0; i--) {
const segment = node.dynamic[i];
const { prefix, suffix } = segment;
if (prefix || suffix) {
const casePart = segment.caseSensitive ? part : lowerPart ?? (lowerPart = part.toLowerCase());
if (prefix && !casePart.startsWith(prefix)) continue;
if (suffix && casePart.indexOf(suffix, casePart.length - suffix.length) < prefix.length) continue;
}
stack.push({
node: segment,
index: index + 1,
skipped,
statics,
dynamics: dynamics + segmentScore(partsLength, index),
optionals,
extract,
rawParams
});
}
if (!isBeyondPath && node.staticInsensitive) {
const match = node.staticInsensitive.get(lowerPart ?? (lowerPart = part.toLowerCase()));
if (match) stack.push({
node: match,
index: index + 1,
skipped,
statics: statics + segmentScore(partsLength, index),
dynamics,
optionals,
extract,
rawParams
});
}
if (!isBeyondPath && node.static) {
const match = node.static.get(part);
if (match) stack.push({
node: match,
index: index + 1,
skipped,
statics: statics + segmentScore(partsLength, index),
dynamics,
optionals,
extract,
rawParams
});
}
if (node.pathless) for (let i = node.pathless.length - 1; i >= 0; i--) {
const segment = node.pathless[i];
stack.push({
node: segment,
index,
skipped,
statics,
dynamics,
optionals,
extract,
rawParams
});
}
}
if (bestMatch) return bestMatch;
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 = /* @__PURE__ */ Object.create(null));
bestFuzzy.rawParams["**"] = decodeURIComponent(splat);
return bestFuzzy;
}
return null;
}
function segmentScore(partsLength, index) {
return 2 ** (partsLength - index - 1);
}
function isPerfectStaticMatch(statics, partsLength) {
return statics === 2 ** (partsLength - 1) - 1;
}
function validateParseParams(path, parts, frame) {
let rawParams;
let state;
try {
[rawParams, state] = extractParams(path, parts, frame);
} catch {
return null;
}
frame.rawParams = rawParams;
frame.extract = state;
if (!frame.node.parse) return true;
try {
if (frame.node.parse(rawParams) === false) return null;
} catch {
}
return true;
}
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.node.depth > prev.node.depth)));
}
// node_modules/@tanstack/router-core/dist/esm/scroll-restoration.js
function getSafeSessionStorage() {
try {
return sessionStorage;
} catch {
return;
}
}
var storageKey = "tsr-scroll-restoration-v1_3";
var safeSessionStorage = getSafeSessionStorage();
function createScrollRestorationCache() {
try {
return JSON.parse((safeSessionStorage == null ? void 0 : safeSessionStorage.getItem("tsr-scroll-restoration-v1_3")) || "{}");
} catch {
return {};
}
}
function persistScrollRestorationCache() {
try {
safeSessionStorage == null ? void 0 : safeSessionStorage.setItem(storageKey, JSON.stringify(scrollRestorationCache));
} catch {
if (true) console.warn("[ts-router] Could not persist scroll restoration state to sessionStorage.");
}
}
var scrollRestorationCache = createScrollRestorationCache();
var scrollRestorationIdAttribute = "data-scroll-restoration-id";
var defaultGetScrollRestorationKey = (location) => {
return location.state.__TSR_key || location.href;
};
function getScrollRestorationSelector(element) {
const attrId = element.getAttribute(scrollRestorationIdAttribute);
if (attrId) return `[${scrollRestorationIdAttribute}="${attrId}"]`;
let selector = "";
let el = element;
let parent;
while (parent = el.parentNode) {
let index = 1;
let sibling = el;
while (sibling = sibling.previousElementSibling) index++;
const part = `${el.localName}:nth-child(${index})`;
selector = selector ? `${part} > ${selector}` : part;
el = parent;
}
return selector;
}
function getElementScrollRestorationEntry(router, options) {
var _a;
const entries = scrollRestorationCache[(options.getKey || defaultGetScrollRestorationKey)(router.latestLocation)];
if (!entries) return;
if (options.id) return entries[`[${scrollRestorationIdAttribute}="${options.id}"]`];
const element = (_a = options.getElement) == null ? void 0 : _a.call(options);
if (!element) return;
return entries[element === window ? windowScrollTarget : getScrollRestorationSelector(element)];
}
var ignoreScroll = false;
var windowScrollTarget = "window";
function getElement(selector) {
try {
return typeof selector === "function" ? selector() : document.querySelector(selector);
} catch {
}
}
function getScrollToTopElements(scrollToTopSelectors) {
const elements = /* @__PURE__ */ new Set();
for (const selector of scrollToTopSelectors) {
if (selector === windowScrollTarget) continue;
const element = getElement(selector);
if (element) elements.add(element);
}
return elements;
}
function setupScrollRestoration(router, force) {
const shouldSetupScrollRestoration = force ?? router.options.scrollRestoration;
const scroll = router._scroll;
if (shouldSetupScrollRestoration) scroll.restoring = true;
if (isServer ?? router.isServer) return;
const getKey = router.options.getScrollRestorationKey || defaultGetScrollRestorationKey;
const trackedScrollTargets = /* @__PURE__ */ new Set();
const snapshotCurrentScrollTargets = (restoreKey) => {
const keyEntry = scrollRestorationCache[restoreKey] || (scrollRestorationCache[restoreKey] = {});
for (const target of trackedScrollTargets) if (target === document) keyEntry[windowScrollTarget] = {
scrollX,
scrollY
};
else if (target.isConnected) keyEntry[getScrollRestorationSelector(target)] = {
scrollX: target.scrollLeft,
scrollY: target.scrollTop
};
};
if (shouldSetupScrollRestoration && !scroll.restoration) {
scroll.restoration = true;
ignoreScroll = false;
history.scrollRestoration = "manual";
document.addEventListener("scroll", (event) => {
if (ignoreScroll) return;
trackedScrollTargets.add(event.target);
}, true);
router.subscribe("onBeforeLoad", (event) => {
if (event.fromLocation) snapshotCurrentScrollTargets(getKey(event.fromLocation));
trackedScrollTargets.clear();
});
addEventListener("pagehide", () => {
snapshotCurrentScrollTargets(getKey(router.stores.resolvedLocation.get() ?? router.stores.location.get()));
persistScrollRestorationCache();
});
}
if (scroll.reset) return;
scroll.reset = true;
router.subscribe("onRendered", (event) => {
var _a;
const behavior = router.options.scrollRestorationBehavior;
const scrollToTopSelectors = router.options.scrollToTopSelectors;
const shouldResetScroll = scroll.next;
const hashNavigation = scroll.hash;
let scrollToTopElements;
trackedScrollTargets.clear();
scroll.next = true;
scroll.hash = false;
if (typeof router.options.scrollRestoration === "function" && !router.options.scrollRestoration({ location: router.latestLocation })) return;
const cacheKey = getKey(event.toLocation);
const fromCacheKey = event.fromLocation && getKey(event.fromLocation);
if (scroll.restoring && fromCacheKey && fromCacheKey !== cacheKey) {
const fromElementEntries = scrollRestorationCache[fromCacheKey];
if (fromElementEntries) {
let toElementEntries = scrollRestorationCache[cacheKey];
for (const elementSelector in fromElementEntries) {
if (elementSelector === windowScrollTarget) {
if (shouldResetScroll) continue;
} else {
const element = getElement(elementSelector);
if (!element) continue;
if (shouldResetScroll && scrollToTopSelectors) {
scrollToTopElements ?? (scrollToTopElements = getScrollToTopElements(scrollToTopSelectors));
if (scrollToTopElements.has(element)) continue;
}
}
if (!toElementEntries) toElementEntries = scrollRestorationCache[cacheKey] = {};
toElementEntries[elementSelector] ?? (toElementEntries[elementSelector] = fromElementEntries[elementSelector]);
}
}
}
ignoreScroll = true;
try {
const hash = event.toLocation.hash;
const hashScrollIntoViewOptions = event.toLocation.state.__hashScrollIntoViewOptions ?? true;
let windowRestored = false;
if (shouldResetScroll) {
if (!hash && scrollToTopSelectors) scrollToTopElements ?? (scrollToTopElements = getScrollToTopElements(scrollToTopSelectors));
const skipWindowRestore = hash && hashScrollIntoViewOptions && hashNavigation;
const elementEntries = scroll.restoring ? scrollRestorationCache[cacheKey] : void 0;
if (elementEntries) for (const elementSelector in elementEntries) {
const { scrollX: scrollX2, scrollY: scrollY2 } = elementEntries[elementSelector];
if (elementSelector === windowScrollTarget) {
if (skipWindowRestore) continue;
scrollTo({
top: scrollY2,
left: scrollX2,
behavior
});
windowRestored = true;
} else {
const element = getElement(elementSelector);
if (element) {
element.scrollLeft = scrollX2;
element.scrollTop = scrollY2;
scrollToTopElements == null ? void 0 : scrollToTopElements.delete(element);
}
}
}
if (!hash) {
const scrollOptions = {
top: 0,
left: 0,
behavior
};
if (!windowRestored) scrollTo(scrollOptions);
if (scrollToTopElements) for (const element of scrollToTopElements) element.scrollTo(scrollOptions);
}
}
if (!windowRestored && hash && hashScrollIntoViewOptions) (_a = document.getElementById(hash)) == null ? void 0 : _a.scrollIntoView(hashScrollIntoViewOptions);
} finally {
ignoreScroll = false;
}
});
}
// node_modules/@tanstack/router-core/dist/esm/qss.js
function encode(obj, stringify = String) {
let result;
for (const key in obj) {
const val = obj[key];
if (val !== void 0) (result || (result = new URLSearchParams())).set(key, stringify(val));
}
return result ? 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 = /* @__PURE__ */ Object.create(null);
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/@tanstack/router-core/dist/esm/searchParams.js
var jsonStart = /^(?:\s|["[{\d-]|fa|nu|tr)/;
var defaultParseSearch = parseSearchWith(JSON.parse);
var defaultStringifySearch = stringifySearchWith(JSON.stringify, JSON.parse);
function parseSearchWith(parser) {
const isJsonParser = parser === JSON.parse;
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") {
if (isJsonParser && !jsonStart.test(value)) continue;
try {
query[key] = parser(value);
} catch (_err) {
}
}
}
return query;
};
}
function stringifySearchWith(stringify, parser) {
const isJsonParser = parser === JSON.parse;
function stringifyValue(val) {
if (val && typeof val === "object") try {
return stringify(val);
} catch (_err) {
}
else if (parser && typeof val === "string") {
if (isJsonParser && !jsonStart.test(val)) return val;
try {
parser(val);
return stringify(val);
} catch (_err) {
}
}
return val;
}
return (search) => {
const searchStr = encode(search, stringifyValue);
return searchStr ? `?${searchStr}` : "";
};
}
// 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(basepath, caseSensitive, rewrite) {
const trimmedBasepath = trimPath(basepath);
const normalizedBasepath = `/${trimmedBasepath}`;
const checkBasepath = caseSensitive ? normalizedBasepath : normalizedBasepath.toLowerCase();
const checkBasepathWithSlash = `${checkBasepath}/`;
const basepathRewrite = {
input: ({ url }) => {
const pathname = 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 = cleanPath(`/${trimmedBasepath}${url.pathname}`);
return url;
}
};
return rewrite ? {
input: ({ url }) => executeRewriteInput(rewrite, basepathRewrite.input({ url })),
output: ({ url }) => basepathRewrite.output({ url: executeRewriteOutput(rewrite, url) })
} : basepathRewrite;
}
function executeRewriteInput(rewrite, url) {
var _a;
const res = (_a = rewrite == null ? void 0 : rewrite.input) == null ? void 0 : _a.call(rewrite, { url });
if (res) {
if (typeof res === "string") return new URL(res);
else if (res instanceof URL) return res;
}
return url;
}
function executeRewriteOutput(rewrite, url) {
var _a;
const res = (_a = rewrite == null ? void 0 : rewrite.output) == null ? void 0 : _a.call(rewrite, { url });
if (res) {
if (typeof res === "string") return new URL(res);
else if (res instanceof URL) return res;
}
return url;
}
// node_modules/@tanstack/router-core/dist/esm/stores.js
function createNonReactiveMutableStore(initialValue) {
let value = initialValue;
return {
get() {
return value;
},
set(nextOrUpdater) {
value = functionalUpdate(nextOrUpdater, value);
}
};
}
function createNonReactiveReadonlyStore(read) {
return { get() {
return read();
} };
}
function createRouterStores(initialLocation, config) {
const { createMutableStore, createReadonlyStore, batch: batch2 } = config;
const byRoute = /* @__PURE__ */ new Map();
const status = createMutableStore("idle");
const location = createMutableStore(initialLocation);
const resolvedLocation = createMutableStore(void 0);
const ids = createMutableStore([]);
const matches = createReadonlyStore(() => ids.get().map((id) => byRoute.get(id).get()));
const __store = createReadonlyStore(() => ({
status: status.get(),
isLoading: status.get() === "pending",
matches: matches.get(),
location: location.get(),
resolvedLocation: resolvedLocation.get()
}));
function getMatchStore(routeId) {
let matchStore = byRoute.get(routeId);
if (!matchStore) {
matchStore = createMutableStore(void 0);
byRoute.set(routeId, matchStore);
}
return matchStore;
}
const store = {
status,
location,
resolvedLocation,
ids,
matches,
byRoute,
__store,
getMatchStore,
setMatches
};
function setMatches(nextMatches) {
const previousIds = ids.get();
const nextIds = nextMatches.map((match) => match.routeId);
batch2(() => {
if (!arraysEqual(previousIds, nextIds)) ids.set(nextIds);
for (const id of previousIds) if (!nextIds.includes(id)) byRoute.get(id).set(() => void 0);
for (const nextMatch of nextMatches) {
const matchStore = getMatchStore(nextMatch.routeId);
if (matchStore.get() !== nextMatch) matchStore.set(nextMatch);
}
});
}
return store;
}
// node_modules/@tanstack/history/dist/esm/index.js
var stateIndexKey = "__TSR_index";
var popStateEvent = "popstate";
var beforeUnloadEvent = "beforeunload";
var protocolRelativePrefix = /^[\x00-\x20]*(?:[\\/][\t\n\r]*){2,}/;
function normalizeProtocolRelative(url) {
const match = protocolRelativePrefix.exec(url);
return match ? "/" + url.slice(match[0].length) : url;
}
function normalizeHref(href) {
if (/[\x00-\x1f\x7f]/.test(href)) href = href.replace(/[\x00-\x1f\x7f]/g, (character) => " \n\r".includes(character) ? "" : encodeURIComponent(character));
return normalizeProtocolRelative(href);
}
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 }) => {
var _a, _b;
if ((navigateOpts == null ? void 0 : navigateOpts.ignoreBlocker) ?? false) {
task();
return;
}
const blockers = ((_a = opts.getBlockers) == null ? void 0 : _a.call(opts)) ?? [];
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);
if (await blocker.blockerFn({
currentLocation: location,
nextLocation,
action: actionInfo.type
})) {
(_b = opts.onBlocked) == null ? void 0 : _b.call(opts);
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, (navigateOpts == null ? void 0 : navigateOpts.ignoreBlocker) ?? false);
handleIndexChange({
type: "GO",
index
});
},
navigateOpts,
type: "GO"
});
},
back: (navigateOpts) => {
tryNavigation({
task: () => {
opts.back((navigateOpts == null ? void 0 : navigateOpts.ignoreBlocker) ?? false);
handleIndexChange({ type: "BACK" });
},
navigateOpts,
type: "BACK"
});
},
forward: (navigateOpts) => {
tryNavigation({
task: () => {
opts.forward((navigateOpts == null ? void 0 : navigateOpts.ignoreBlocker) ?? false);
handleIndexChange({ type: "FORWARD" });
},
navigateOpts,
type: "FORWARD"
});
},
canGoBack: () => location.state[stateIndexKey] !== 0,
createHref: (str) => opts.createHref(str),
block: (blocker) => {
var _a;
if (!opts.setBlockers) return () => {
};
const blockers = ((_a = opts.getBlockers) == null ? void 0 : _a.call(opts)) ?? [];
opts.setBlockers([...blockers, blocker]);
return () => {
var _a2, _b;
const blockers2 = ((_a2 = opts.getBlockers) == null ? void 0 : _a2.call(opts)) ?? [];
(_b = opts.setBlockers) == null ? void 0 : _b.call(opts, blockers2.filter((b) => b !== blocker));
};
},
flush: () => {
var _a;
return (_a = opts.flush) == null ? void 0 : _a.call(opts);
},
destroy: () => {
var _a;
return (_a = opts.destroy) == null ? void 0 : _a.call(opts);
},
notify,
_getBlockers: () => {
var _a;
return ((_a = opts.getBlockers) == null ? void 0 : _a.call(opts)) ?? [];
}
};
}
function assignKeyAndIndex(index, state) {
const key = createRandomKey();
return {
...state,
key,
__TSR_key: key,
[stateIndexKey]: index
};
}
function createBrowserHistory(opts) {
var _a, _b;
const win = (opts == null ? void 0 : 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 = (path) => normalizeHref((opts == null ? void 0 : opts.createHref) ? opts.createHref(path) : path);
const parseLocation = (opts == null ? void 0 : opts.parseLocation) ?? (() => parseHref(`${win.location.pathname}${win.location.search}${win.location.hash}`, win.history.state));
if (!((_a = win.history.state) == null ? void 0 : _a.__TSR_key) && !((_b = win.history.state) == null ? void 0 : _b.key)) {
const addedKey = createRandomKey();
win.history.replaceState({
[stateIndexKey]: 0,
key: addedKey,
__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;
const flush2 = () => {
if (!next) return;
history2._ignoreSubscribers = true;
(next[2] ? win.history.pushState : win.history.replaceState)(next[1], "", next[0]);
history2._ignoreSubscribers = false;
next = void 0;
rollbackLocation = void 0;
};
const queueHistoryAction = (isPush, destHref, state) => {
const href = (opts == null ? void 0 : opts.createHref) ? createHref(destHref) : void 0;
const hasPendingAction = !!next;
if (!hasPendingAction) rollbackLocation = currentLocation;
currentLocation = parseHref(destHref, state);
next = [
href ?? currentLocation.href,
state,
(next == null ? void 0 : next[2]) || isPush
];
if (!hasPendingAction) queueMicrotask(() => flush2());
};
const onPushPop = (type) => {
currentLocation = parseLocation();
history2.notify({ type });
};
const onPushPopEvent = async () => {
ignoreNextBeforeUnload = false;
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) if (await blocker.blockerFn({
currentLocation,
nextLocation,
action
})) {
ignoreNextPop = true;
win.history.go(-delta);
history2.notify(notify);
return;
}
}
}
currentLocation = parseLocation();
history2.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 = "";
}
};
const history2 = createHistory({
getLocation,
getLength: () => win.history.length,
pushState: (href, state) => queueHistoryAction(true, href, state),
replaceState: (href, state) => queueHistoryAction(false, 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, ignoreBlocker) => {
nextPopIsGo = true;
if (ignoreBlocker) {
skipBlockerNextPop = true;
ignoreNextBeforeUnload = true;
}
win.history.go(n);
},
createHref: (href) => createHref(href),
flush: flush2,
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
});
history2._ignoreNextBeforeUnload = (href) => {
ignoreNextBeforeUnload = false;
try {
href = new URL(href, win.document.baseURI).href;
ignoreNextBeforeUnload = /^https?:/.test(href) && (!href.includes("#") || href.split("#")[0] !== win.location.href.split("#")[0]);
} catch {
}
};
win.addEventListener(beforeUnloadEvent, onBeforeUnload, { capture: true });
win.addEventListener(popStateEvent, onPushPopEvent);
win.history.pushState = function(...args) {
const res = originalPushState.apply(win.history, args);
if (!history2._ignoreSubscribers) onPushPop("PUSH");
return res;
};
win.history.replaceState = function(...args) {
const res = originalReplaceState.apply(win.history, args);
if (!history2._ignoreSubscribers) onPushPop("REPLACE");
return res;
};
return history2;
}
function createHashHistory(opts) {
const win = (opts == null ? void 0 : 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);
return parseHref(`${pathPart}${searchPart}${hashEntries.length === 0 ? "" : `#${hashEntries.join("#")}`}`, 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) => {
index = index < entries.length - 1 ? index + 1 : entries.length;
states[index] = state;
entries[index] = path;
if (index < entries.length - 1) {
entries.length = index + 1;
states.length = index + 1;
}
},
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: normalizeHref,
getBlockers: _getBlockers,
setBlockers: _setBlockers
});
}
function parseHref(href, state) {
const sanitizedHref = normalizeHref(href);
const hashIndex = sanitizedHref.indexOf("#");
const searchIndex = sanitizedHref.indexOf("?");
if (!state) {
const key = createRandomKey();
state = {
[stateIndexKey]: 0,
key,
__TSR_key: key
};
}
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
};
}
function createRandomKey() {
return (Math.random() + 1).toString(36).substring(7);
}
// node_modules/@tanstack/router-core/dist/esm/router.js
function isExternalUrl(url, origin) {
return url.protocol !== "http:" && url.protocol !== "https:" || url.origin !== origin || !!url.username || !!url.password;
}
function getUrlPath(url) {
return url.pathname + url.search + url.hash;
}
function routeNeedsLoad(route) {
var _a, _b;
return route.options.loader || route.options.beforeLoad || route.lazyFn || ((_a = route.options.component) == null ? void 0 : _a.preload) || ((_b = route.options.pendingComponent) == null ? void 0 : _b.preload);
}
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(location, resolvedLocation) {
return {
fromLocation: resolvedLocation,
toLocation: location,
pathChanged: (resolvedLocation == null ? void 0 : resolvedLocation.pathname) !== location.pathname,
hrefChanged: (resolvedLocation == null ? void 0 : resolvedLocation.href) !== location.href,
hashChanged: (resolvedLocation == null ? void 0 : resolvedLocation.hash) !== location.hash
};
}
function _getUserHistoryState({ key: _key, __TSR_key: _tsrKey, __TSR_index: _tsrIndex, __hashScrollIntoViewOptions: _hashScroll, ...state }) {
return state;
}
function lifecycleEnd(matches) {
return matches.findIndex((match) => match.status === "error" || match.status === "notFound" || match._notFound) + 1;
}
function runRouteLifecycle(router, previous, matches, previousEnd, nextEnd, owner) {
var _a, _b, _c, _d;
if (previousEnd) previous = previous.slice(0, previousEnd);
if (nextEnd) matches = matches.slice(0, nextEnd);
for (const match of previous) {
if (owner && router._tx !== owner) return;
if (!matches.some((candidate) => candidate.routeId === match.routeId)) (_b = (_a = router.routesById[match.routeId].options).onLeave) == null ? void 0 : _b.call(_a, match);
}
for (const match of matches) {
if (owner && router._tx !== owner) return;
(_d = (_c = router.routesById[match.routeId].options)[previous.some((candidate) => candidate.routeId === match.routeId) ? "onStay" : "onEnter"]) == null ? void 0 : _d.call(_c, match);
}
}
var RouterCore = class {
/**
* @deprecated Use the `createRouter` function instead
*/
constructor(options, getStoreConfig) {
var _a;
this.tempLocationKey = `${Math.round(Math.random() * 1e7)}`;
this._scroll = { next: true };
this.subscribers = /* @__PURE__ */ new Set();
this._cache = /* @__PURE__ */ new Map();
this._committed = [];
this.startTransition = async (fn) => {
fn();
return false;
};
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;
this.options = {
...prevOptions,
...newOptions
};
this.isServer = this.options.isServer ?? isServer ?? typeof document === "undefined";
if (!(isServer ?? this.isServer)) this.staticLocations = /* @__PURE__ */ new WeakMap();
this.protocolAllowlist = new Set(this.options.protocolAllowlist);
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 == null ? void 0 : window.origin) && window.origin !== "null") this.origin = window.origin;
else this.origin = "http://localhost";
const nextBasepath = this.options.basepath ?? "/";
const nextRewriteOption = this.options.rewrite;
const rewriteChanged = this.basepath !== nextBasepath || (prevOptions == null ? void 0 : prevOptions.rewrite) !== nextRewriteOption || (prevOptions == null ? void 0 : prevOptions.caseSensitive) !== this.options.caseSensitive;
if (rewriteChanged) {
this.basepath = nextBasepath;
this.rewrite = nextBasepath !== "/" && trimPath(nextBasepath) ? rewriteBasepath(nextBasepath, this.options.caseSensitive, nextRewriteOption) : nextRewriteOption;
}
if (this.history) this.updateLatestLocation();
if (this.options.routeTree !== this.routeTree || (isServer ?? this.isServer) && (prevOptions == null ? void 0 : prevOptions.caseSensitive) !== this.options.caseSensitive) {
this.routeTree = this.options.routeTree;
let processRouteTreeResult;
if (false) processRouteTreeResult = globalThis.__TSR_CACHE__.processRouteTreeResult;
else {
processRouteTreeResult = this.buildRouteTree();
if (false) globalThis.__TSR_CACHE__ = {
routeTree: this.routeTree,
caseSensitive: this.options.caseSensitive,
processRouteTreeResult
};
}
this.setRoutes(processRouteTreeResult);
}
if (!this.stores) {
if (this.latestLocation) {
const config = this.getStoreConfig(this);
this.batch = config.batch;
this.stores = createRouterStores(this.latestLocation, config);
if (!(isServer ?? this.isServer)) setupScrollRestoration(this);
}
} else if (rewriteChanged) this.stores.location.set(this.latestLocation);
};
this.updateLatestLocation = () => {
this.latestLocation = this.parseLocation(this.history.location, this.latestLocation);
};
this.buildRouteTree = () => {
const result = processRouteTree(this.routeTree, this.options.caseSensitive);
if (this.options.routeMasks) processRouteMasks(this.options.routeMasks, result.processedTree);
return {
...result,
resolvePathCache: createSieveCache(1e3)
};
};
this.subscribe = (eventType, fn) => {
const listener = {
eventType,
fn
};
this.subscribers.add(listener);
return () => {
this.subscribers.delete(listener);
};
};
this.emit = (routerEvent) => {
for (const listener of this.subscribers) if (listener.eventType === routerEvent.type) try {
listener.fn(routerEvent);
} catch (e) {
console.error(e);
}
};
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: pathname + searchStr2 + hash,
pathname: decodePath(pathname),
external: false,
searchStr: searchStr2,
search: nullReplaceEqualDeep(previousLocation == null ? void 0 : previousLocation.search, parsedSearch2),
hash: decodePath(hash.slice(1)),
state: replaceEqualDeep(previousLocation == null ? void 0 : previousLocation.state, state)
};
}
const url = executeRewriteInput(this.rewrite, new URL(href, this.origin));
const parsedSearch = this.options.parseSearch(url.search);
const searchStr = this.options.stringifySearch(parsedSearch);
url.search = searchStr;
return {
href: url.href.replace(url.origin, ""),
publicHref: href,
pathname: decodePath(normalizeProtocolRelative(url.pathname)),
external: !!this.rewrite && isExternalUrl(url, this.origin),
searchStr,
search: nullReplaceEqualDeep(previousLocation == null ? void 0 : previousLocation.search, parsedSearch),
hash: decodePath(url.hash.slice(1)),
state: replaceEqualDeep(previousLocation == null ? void 0 : previousLocation.state, state)
};
};
const location = parse(locationToParse, locationToParse.state);
const { __tempLocation, __tempKey } = location.state;
if (__tempLocation && (!__tempKey || __tempKey === this.tempLocationKey)) {
const parsedTempLocation = parse(__tempLocation, {
...__tempLocation.state,
__tempLocation: void 0,
key: location.state.key,
__TSR_key: location.state.__TSR_key
});
parsedTempLocation.maskedLocation = location;
return parsedTempLocation;
}
return location;
};
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) => {
const rawParams = /* @__PURE__ */ Object.create(null);
const match = findRouteMatch(trimPathRight(pathname), this.processedTree, true);
if (match) Object.assign(rawParams, match.rawParams);
return [
(match == null ? void 0 : match.branch) || [this.routesById["__root__"]],
rawParams,
match == null ? void 0 : match.route
];
};
this.buildLocation = (opts) => {
if (!(isServer ?? this.isServer)) {
const cached = this.staticLocations.get(opts);
if (cached) return cached;
}
let usedCurrent = false;
const build = (dest = {}) => {
var _a2;
if (dest.href) {
const parsed = parseHref(dest.href, {});
dest = {
...dest,
to: executeRewriteInput(this.rewrite, new URL(parsed.pathname, this.origin)).pathname,
search: this.options.parseSearch(parsed.search),
hash: parsed.hash.slice(1)
};
}
const currentLocation = dest._fromLocation || this._pendingLocation || this.latestLocation;
let lightweight;
const current = () => {
usedCurrent = true;
return currentLocation;
};
const currentMatch = () => {
usedCurrent = true;
return lightweight ?? (lightweight = this.matchRoutesLightweight(currentLocation));
};
if (dest.from && dest._isNavigate) {
const [allFromMatches] = this.getMatchedRoutes(dest.from);
const [matchedRoutes, fullPath2] = currentMatch();
const matchedFrom = findLast(matchedRoutes, (d) => {
return comparePaths(d.fullPath, dest.from);
});
const matchedCurrent = findLast(allFromMatches, (d) => {
return comparePaths(d.fullPath, fullPath2);
});
if (!matchedFrom && !matchedCurrent) console.warn(`Could not find match for from: ${dest.from}`);
}
const to = dest.to ? `${dest.to}` : ".";
const nextTo = resolvePath(to[0] === "/" ? "" : dest.unsafeRelative === "path" ? current().pathname : dest.from ?? currentMatch()[1], to, this.options.trailingSlash, this.resolvePathCache);
const destRoute = this.routesByPath[trimPathRight(nextTo)];
const isTemplate = nextTo.includes("$");
let destRoutes;
if (destRoute) destRoutes = destRoute._branch ?? (destRoute._branch = buildRouteBranch(destRoute));
else if (isTemplate) destRoutes = [];
else {
const [matchedRoutes, rawParams, foundRoute] = this.getMatchedRoutes(nextTo);
destRoutes = matchedRoutes;
if (this.options.notFoundRoute && (!foundRoute || foundRoute.path !== "/" && rawParams["**"])) destRoutes = [...destRoutes, this.options.notFoundRoute];
}
const interpolation = isTemplate ? (destRoute == null ? void 0 : destRoute._interpolation) ?? parseSegments(false, { fullPath: nextTo }, 0) : void 0;
let nextParams;
for (const route of destRoutes) {
const fn = ((_a2 = route.options.params) == null ? void 0 : _a2.stringify) ?? route.options.stringifyParams;
if (fn) {
const fromParams = currentMatch()[3];
nextParams ?? (nextParams = resolveNextParams(dest.params, fromParams));
if (!hasKeys(nextParams)) break;
if (nextParams === fromParams) nextParams = Object.assign(createNull(), nextParams);
try {
Object.assign(nextParams, fn(nextParams));
} catch {
}
}
}
nextParams ?? (nextParams = resolveNextParams(dest.params, needsInheritedParams(dest.params, interpolation) ? currentMatch()[3] : EMPTY_RECORD));
const nextPathname = opts.leaveParams ? nextTo : normalizeProtocolRelative(decodePath(interpolation ? interpolatePath(nextTo, interpolation, nextParams, this.pathParamsDecoder) : nextTo));
if (destRoute && !opts.leaveParams) try {
const foundRoute = this.getMatchedRoutes(nextPathname)[2];
if ((foundRoute == null ? void 0 : foundRoute.id) !== destRoute.id) console.warn(`Generated path "${nextPathname}" for route "${destRoute.id}" matched route "${foundRoute == null ? void 0 : foundRoute.id}" instead. This can happen when multiple route templates resolve to the same URL. Use the route template that matches the intended route, or adjust params.stringify if it changed the target path.`);
} catch {
}
const middlewares = getSearchMiddlewares(destRoutes, opts._includeValidateSearch);
const fromSearch = () => {
var _a3;
let search = currentMatch()[2];
if (opts._includeValidateSearch && ((_a3 = this.options.search) == null ? void 0 : _a3.strict)) {
const validatedSearch = {};
destRoutes.forEach((route) => {
if (route.options.validateSearch) try {
Object.assign(validatedSearch, validateSearch(route.options.validateSearch, {
...validatedSearch,
...search
}));
} catch {
}
});
search = validatedSearch;
}
return search;
};
const nextSearch = middlewares.length ? applySearchMiddleware(middlewares, fromSearch(), dest) : dest.search === true ? fromSearch() : typeof dest.search === "function" ? dest.search(fromSearch()) : dest.search || EMPTY_RECORD;
const searchStr = this.options.stringifySearch(nextSearch);
const hash = dest.hash === true ? current().hash : typeof dest.hash === "function" ? dest.hash(current().hash) : dest.hash || void 0;
const hashStr = hash ? `#${hash}` : "";
const nextState = !dest.state ? EMPTY_RECORD : dest.state === true ? current().state : typeof dest.state === "function" ? dest.state(current().state) : dest.state;
const fullPath = `${nextPathname}${searchStr}${hashStr}`;
let href;
let publicHref;
let external = false;
if (this.rewrite) {
const url = new URL(fullPath, this.origin);
const origin = url.origin;
const rewrittenUrl = executeRewriteOutput(this.rewrite, url);
href = getUrlPath(url);
if (isExternalUrl(rewrittenUrl, origin)) {
publicHref = rewrittenUrl.href;
external = true;
} else publicHref = normalizeProtocolRelative(getUrlPath(rewrittenUrl));
} else {
href = encodePathLikeUrl(fullPath);
publicHref = href;
}
return {
publicHref,
href,
pathname: nextPathname,
search: nextSearch,
searchStr,
state: nextState,
hash: hash ?? "",
external,
unmaskOnReload: dest.unmaskOnReload
};
};
const next = build(opts);
if (opts.mask) next.maskedLocation = build({
from: opts.from,
...opts.mask
});
else if (this.options.routeMasks) {
const match = findFlatMatch(next.pathname, this.processedTree);
if (match) {
const params = Object.assign(createNull(), match.rawParams);
const { from: _from, params: maskParams, ...maskProps } = match.route;
const nextParams = resolveNextParams(maskParams, params);
next.maskedLocation = build({
from: opts.from,
...maskProps,
params: nextParams
});
}
}
if (!(isServer ?? this.isServer) && !usedCurrent && opts._fromLocation && !next.maskedLocation) this.staticLocations.set(opts, next);
return next;
};
this.commitLocation = async ({ viewTransition, ignoreBlocker, ...next }) => {
if (isServer ?? this.isServer) return;
const nextLocation = next.maskedLocation ?? next;
if (nextLocation.external && !(isServer ?? this.isServer)) return documentNavigation(this, nextLocation.publicHref, {
replace: next.replace,
ignoreBlocker
});
let historyAction;
const isSameLocation = trimPathRight(this.latestLocation.href) === trimPathRight(next.href) && deepEqual(_getUserHistoryState(next.state), _getUserHistoryState(this.latestLocation.state));
const previousCommitPromise = this._commitPromise;
let resolve;
const commitPromise = new Promise((done) => {
resolve = done;
});
commitPromise.resolve = () => {
resolve();
previousCommitPromise == null ? void 0 : previousCommitPromise.resolve();
};
this._commitPromise = commitPromise;
if (isSameLocation) this.load();
else {
let { maskedLocation, 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
}
}
}
};
if (nextHistory.unmaskOnReload ?? this.options.unmaskOnReload ?? false) nextHistory.state.__tempKey = this.tempLocationKey;
}
nextHistory.state = {
...nextHistory.state,
__hashScrollIntoViewOptions: hashScrollIntoView ?? this.options.defaultHashScrollIntoView ?? true
};
this.shouldViewTransition = viewTransition;
historyAction = next.replace ? "REPLACE" : "PUSH";
this.history[historyAction === "REPLACE" ? "replace" : "push"](nextHistory.publicHref, nextHistory.state, { ignoreBlocker });
if (!this.history.subscribers.size) this.load({ action: { type: historyAction } });
}
this._scroll.next = next.resetScroll ?? true;
return this._commitPromise;
};
this.buildAndCommitLocation = ({ replace, resetScroll, hashScrollIntoView, viewTransition, ignoreBlocker, ...rest } = {}) => {
if (isServer ?? this.isServer) return Promise.resolve();
const location = this.buildLocation({
...rest,
_includeValidateSearch: true
});
this._pendingLocation = location;
const commitPromise = this.commitLocation({
...location,
viewTransition,
replace,
resetScroll,
hashScrollIntoView,
ignoreBlocker
});
queueMicrotask(() => {
if (this._pendingLocation === location) this._pendingLocation = void 0;
});
return commitPromise;
};
this.navigate = async ({ to, reloadDocument, href, publicHref, ...rest }) => {
if (isServer ?? this.isServer) return;
const hrefScheme = href ? getUrlScheme(href) : void 0;
if (hrefScheme || reloadDocument) {
if (to !== void 0 || !href) {
const location = this.buildLocation({
to,
...rest
});
const publicLocation = location.maskedLocation ?? location;
href ?? (href = publicLocation.publicHref);
publicHref ?? (publicHref = publicLocation.publicHref);
}
const reloadHref = !hrefScheme && publicHref ? publicHref : href;
return documentNavigation(this, reloadHref, rest);
}
return this.buildAndCommitLocation({
...rest,
href,
to,
_isNavigate: true
});
};
this.load = async (opts) => {
if (isServer ?? this.isServer) return loadServerRoute(this, opts);
this.updateLatestLocation();
if (opts == null ? void 0 : opts.action) this._scroll.hash = opts.action.type === "PUSH" || opts.action.type === "REPLACE";
await loadClientRoute(this, opts);
};
this.startViewTransition = (fn) => {
var _a2, _b;
const shouldViewTransition = this.shouldViewTransition ?? this.options.defaultViewTransition;
this.shouldViewTransition = void 0;
if (shouldViewTransition && !(isServer ?? typeof document === "undefined") && typeof document.startViewTransition === "function") {
let startViewTransitionParams;
if (typeof shouldViewTransition === "object" && ((_b = (_a2 = window.CSS) == null ? void 0 : _a2.supports) == null ? void 0 : _b.call(_a2, "selector(:active-view-transition-type(a))"))) {
const next = this.latestLocation;
const prevLocation = this.stores.resolvedLocation.get();
const resolvedViewTransitionTypes = typeof shouldViewTransition.types === "function" ? shouldViewTransition.types(getLocationChangeInfo(next, prevLocation)) : shouldViewTransition.types;
if (resolvedViewTransitionTypes === false) return fn();
startViewTransitionParams = {
update: fn,
types: resolvedViewTransitionTypes
};
} else startViewTransitionParams = fn;
return document.startViewTransition(startViewTransitionParams).updateCallbackDone;
}
return fn();
};
this.invalidate = (opts) => {
var _a2, _b;
const committedMatches = this._committed;
const filter = opts == null ? void 0 : opts.filter;
const preloads = this._preloads;
const invalidIds = /* @__PURE__ */ new Set();
const consider = (match) => {
if (!filter || filter(match)) invalidIds.add(match.id);
};
committedMatches.forEach(consider);
this._cache.forEach(consider);
preloads == null ? void 0 : preloads.forEach((matches) => matches.forEach(consider));
(_a2 = this._tx) == null ? void 0 : _a2[3].forEach(consider);
const discardedPreloads = [];
for (const [controller, matches] of preloads ?? []) if (matches.some((match) => invalidIds.has(match.id))) {
preloads.delete(controller);
discardedPreloads.push(controller);
}
const invalidate = (d) => {
if (invalidIds.has(d.id)) {
const route = this.routesById[d.routeId];
const next = {
...d,
invalid: true,
...((opts == null ? void 0 : opts.forcePending) || d.status === "error" || d.status === "notFound") && routeNeedsLoad(route) ? {
status: "pending",
error: void 0
} : void 0
};
d._flight = void 0;
return next;
}
return d;
};
this._committed = committedMatches.map(invalidate);
for (const [id, match] of this._cache) if (invalidIds.has(id)) {
match.invalid = true;
if (opts == null ? void 0 : opts.forcePending) match.status = "pending";
}
for (const id of invalidIds) (_b = this._flights) == null ? void 0 : _b.delete(id);
for (const controller of discardedPreloads) controller.abort();
this.shouldViewTransition = false;
return this.load({ sync: opts == null ? void 0 : opts.sync });
};
this.resolveRedirect = (redirect2) => {
const options2 = redirect2.options;
let href = redirect2.headers.get("Location") || options2.href;
if (!href) {
const location = this.buildLocation(options2);
href = (location.maskedLocation ?? location).publicHref || "/";
}
let scheme;
if (protocolRelativePrefixRegex.test(href) || (scheme = getUrlScheme(href)) && !this.protocolAllowlist.has(scheme)) throw new Error(true ? `Redirect blocked: unsafe protocol in href "${href}". Allowed protocols: ${Array.from(this.protocolAllowlist).join(", ")}.` : "Redirect blocked: unsafe protocol");
if (scheme === "http:" || scheme === "https:") {
const url = new URL(href);
if (url.pathname.startsWith("//")) href = url.href;
else if (!isExternalUrl(url, this.origin)) {
href = getUrlPath(url);
scheme = void 0;
}
}
if (scheme) options2.reloadDocument = true;
options2.href = href;
redirect2.headers.set("Location", href);
return redirect2;
};
this.clearCache = (opts) => {
var _a2;
const cached = this._cache;
const preloads = this._preloads;
const filter = opts == null ? void 0 : opts.filter;
const discarded = [];
const discardedIds = [];
for (const [id, match] of cached) if (!filter || filter(match)) {
discardedIds.push(id);
discarded.push(match);
}
const abort = [];
for (const [controller, matches] of preloads ?? []) if (!filter || matches.some(filter)) {
abort.push(controller);
discarded.push(...matches);
}
for (const id of discardedIds) cached.delete(id);
for (const controller of abort) preloads.delete(controller);
for (const match of discarded) {
const flight = match._flight;
match._flight = void 0;
if (flight && !--flight[2]) {
if (((_a2 = this._flights) == null ? void 0 : _a2.get(match.id)) === flight) this._flights.delete(match.id);
abort.push(flight[1]);
}
}
for (const controller of abort) controller.abort();
};
this.loadRouteChunk = loadRouteChunk;
this.preloadRoute = (opts) => preloadClientRoute(this, opts);
this.matchRoute = (location, opts) => {
const matchLocation = {
...location,
to: location.to ? resolvePath(location.from || "", location.to, this.options.trailingSlash, this.resolvePathCache) : void 0,
params: location.params || {},
leaveParams: true
};
const next = this.buildLocation(matchLocation);
const isPending = this.stores.status.get() === "pending";
if ((opts == null ? void 0 : opts.pending) && !isPending) return false;
const baseLocation = (opts == null ? void 0 : opts.pending) ?? !isPending ? this.latestLocation : this.stores.resolvedLocation.get() || this.stores.location.get();
const match = findSingleMatch(next.pathname, (opts == null ? void 0 : opts.caseSensitive) ?? false, (opts == null ? void 0 : opts.fuzzy) ?? false, baseLocation.pathname, this.processedTree);
if (!match) return false;
if (location.params) {
if (!deepEqual(match.rawParams, location.params, true)) return false;
}
if ((opts == null ? void 0 : opts.includeSearch) ?? true) return deepEqual(baseLocation.search, next.search, true) ? match.rawParams : false;
return match.rawParams;
};
this.getStoreConfig = getStoreConfig;
if ((_a = options.pathParamsAllowedCharacters) == null ? void 0 : _a.length) this.pathParamsDecoder = compileDecodeCharMap(options.pathParamsAllowedCharacters);
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 (!(isServer ?? typeof document === "undefined")) self.__TSR_ROUTER__ = this;
}
isShell() {
return !!this.options.isShell;
}
get state() {
return this.stores.__store.get();
}
setRoutes(caches) {
Object.assign(this, caches);
this.lightweightCache = /* @__PURE__ */ new WeakMap();
if (!(isServer ?? this.isServer)) this.staticLocations = /* @__PURE__ */ new WeakMap();
const notFoundRoute = this.options.notFoundRoute;
if (notFoundRoute) {
notFoundRoute.init(99999999999);
if (this.routesById[notFoundRoute.id] !== notFoundRoute) notFoundRoute._interpolation = parseSegments(false, notFoundRoute, 0);
this.routesById[notFoundRoute.id] = notFoundRoute;
}
}
matchRoutesInternal(next, opts) {
var _a, _b;
const [initialMatchedRoutes, rawParams, foundRoute] = this.getMatchedRoutes(next.pathname);
let matchedRoutes = initialMatchedRoutes;
let isGlobalNotFound = false;
if (foundRoute ? foundRoute.path !== "/" && rawParams["**"] : trimPathRight(next.pathname)) if (this.options.notFoundRoute) matchedRoutes = [...matchedRoutes, this.options.notFoundRoute];
else isGlobalNotFound = true;
const _notFoundRouteId = isGlobalNotFound ? findGlobalNotFoundRouteId(this.options.notFoundMode, matchedRoutes) : void 0;
const matches = new Array(matchedRoutes.length);
const committed = this._committed;
const previousAt = (route, index) => {
const match = committed[index];
return (match == null ? void 0 : match.routeId) === route.id ? match : route === this.options.notFoundRoute ? committed.find((candidate) => candidate.routeId === route.id) : void 0;
};
let strictParams;
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 == null ? void 0 : parentMatch.search) ?? next.search;
const parentStrictSearch = (parentMatch == null ? void 0 : parentMatch._strictSearch) ?? void 0;
try {
const strictSearch = validateSearch(route.options.validateSearch, { ...parentSearch }) ?? void 0;
preMatchSearch = {
...parentSearch,
...strictSearch
};
strictMatchSearch = {
...parentStrictSearch,
...strictSearch
};
} catch (err) {
let searchParamError = err;
if (!(err instanceof SearchParamError)) searchParamError = new SearchParamError(err.message, { cause: err });
if (opts == null ? void 0 : opts.throwOnError) throw searchParamError;
preMatchSearch = parentSearch;
strictMatchSearch = {};
searchError = searchParamError;
}
}
let loaderDeps = "";
let loaderDepsHash = "";
try {
loaderDeps = ((_b = (_a = route.options).loaderDeps) == null ? void 0 : _b.call(_a, { search: preMatchSearch })) ?? "";
loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) || "" : "";
} catch (cause2) {
if (opts == null ? void 0 : opts.throwOnError) throw cause2;
searchError ?? (searchError = cause2);
}
const usedParams = createNull();
const interpolatedPath = route._interpolation ? interpolatePath(route.fullPath, route._interpolation, rawParams, this.pathParamsDecoder, usedParams) : route.fullPath;
const matchId = route.id + interpolatedPath + loaderDepsHash;
const previousMatch = previousAt(route, index);
const existingMatch = (opts == null ? void 0 : opts._rematerialize) ? void 0 : this._cache.get(matchId) ?? ((previousMatch == null ? void 0 : previousMatch.id) === matchId ? previousMatch : void 0);
strictParams = (existingMatch == null ? void 0 : existingMatch._strictParams) ?? Object.assign(usedParams, strictParams);
let paramsError;
if (!existingMatch) try {
extractStrictParams(route, strictParams);
} catch (err) {
if (isNotFound(err) || isRedirect(err)) paramsError = err;
else paramsError = new PathParamError(err.message, { cause: err });
if (opts == null ? void 0 : opts.throwOnError) throw paramsError;
}
const cause = previousMatch ? "stay" : "enter";
let match;
if (existingMatch) match = {
...existingMatch,
cause,
search: previousMatch ? nullReplaceEqualDeep(previousMatch.search, preMatchSearch) : nullReplaceEqualDeep(existingMatch.search, preMatchSearch),
_strictSearch: strictMatchSearch,
searchError
};
else {
const status = routeNeedsLoad(route) ? "pending" : "success";
match = {
id: matchId,
ssr: isServer ?? this.isServer ? void 0 : route.options.ssr,
index,
routeId: route.id,
params: (previousMatch == null ? void 0 : previousMatch.params) ?? strictParams,
_strictParams: strictParams,
pathname: interpolatedPath,
updatedAt: Date.now(),
search: previousMatch ? nullReplaceEqualDeep(previousMatch.search, preMatchSearch) : preMatchSearch,
_strictSearch: strictMatchSearch,
searchError,
status,
isFetching: false,
error: void 0,
paramsError,
context: {},
abortController: (opts == null ? void 0 : opts._controller) ?? new AbortController(),
cause,
loaderDeps: previousMatch ? replaceEqualDeep(previousMatch.loaderDeps, loaderDeps) : loaderDeps,
invalid: false,
preload: false,
staticData: route.options.staticData || {},
fullPath: route.fullPath
};
}
const _notFound = _notFoundRouteId === route.id;
if (match._notFound && !_notFound) match.error = void 0;
match._notFound = _notFound;
matches[index] = match;
}
for (let index = 0; index < matches.length; index++) {
const match = matches[index];
match.params = match.cause === "stay" ? nullReplaceEqualDeep(match.params, strictParams) : strictParams;
if (opts == null ? void 0 : opts._controller) match.context = {};
}
return matches;
}
/**
* Lightweight route matching for buildLocation.
* Only computes fullPath, accumulated search, and params - skipping expensive
* operations like AbortController, loaderDeps, and full match objects.
*/
matchRoutesLightweight(location) {
const lastRouteId = last(this.stores.ids.get());
const lastStateMatch = lastRouteId ? this.stores.byRoute.get(lastRouteId).get() : void 0;
const lastStateMatchId = lastStateMatch == null ? void 0 : lastStateMatch.id;
const cached = this.lightweightCache.get(location);
if (cached && cached[0] === lastStateMatchId) return cached[1];
const [matchedRoutes, rawParams] = 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 canReuseParams = lastStateMatch && lastStateMatch.routeId === lastRoute.id && lastStateMatch.pathname === location.pathname;
let params;
if (canReuseParams) params = lastStateMatch.params;
else {
const strictParams = rawParams;
for (const route of matchedRoutes) try {
extractStrictParams(route, strictParams);
} catch {
}
params = strictParams;
}
const result = [
matchedRoutes,
lastRoute.fullPath,
accumulatedSearch,
params
];
this.lightweightCache.set(location, [lastStateMatchId, result]);
return result;
}
};
async function documentNavigation(router, href, { replace, ignoreBlocker }) {
var _a, _b;
if (isDangerousProtocol(href, router.protocolAllowlist)) {
if (true) console.warn(`Blocked navigation to dangerous protocol: ${href}`);
return;
}
if (!ignoreBlocker) {
const blockers = router.history._getBlockers();
for (const blocker of blockers) if (blocker == null ? void 0 : blocker.blockerFn) {
if (await blocker.blockerFn({
currentLocation: router.history.location,
nextLocation: router.history.location,
action: replace ? "REPLACE" : "PUSH"
})) return;
}
}
(_b = (_a = router.history)._ignoreNextBeforeUnload) == null ? void 0 : _b.call(_a, href);
if (replace) window.location.replace(href);
else window.location.href = href;
}
if (true) {
RouterCore.prototype._replaceRouteChunk = replaceRouteChunk;
RouterCore.prototype._refreshRoute = async function() {
this._serverResult = void 0;
this.updateLatestLocation();
await refreshClientRoute(this);
};
}
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) => {
return (await fn())[key || "default"](...args);
};
}
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 resolveNextParams(spec, base) {
if (spec === void 0 || spec === true) return base;
const next = /* @__PURE__ */ Object.create(null);
if (spec === false || spec === null) return next;
if (typeof spec === "function") {
Object.assign(next, base);
return Object.assign(next, spec(next));
}
return Object.assign(next, base, spec);
}
function needsInheritedParams(spec, interpolation) {
if (typeof spec === "function") return true;
if (!interpolation || spec === false || spec === null) return false;
return spec === void 0 || spec === true || interpolation.some((part) => typeof part !== "string" && !hasOwn.call(spec, part[1]));
}
var EMPTY_RECORD = Object.freeze({});
function getSearchMiddlewares(destRoutes, includeValidateSearch) {
var _a;
const middlewares = [];
for (let i = 0; i < destRoutes.length; i++) {
const routeOptions = destRoutes[i].options;
if ("search" in routeOptions) {
if ((_a = routeOptions.search) == null ? void 0 : _a.middlewares) middlewares.push(...routeOptions.search.middlewares);
} else if (routeOptions.preSearchFilters || routeOptions.postSearchFilters) {
const legacyMiddleware = ({ search, next }) => {
const result = next(routeOptions.preSearchFilters ? routeOptions.preSearchFilters.reduce((prev, next2) => next2(prev), search) : search);
return routeOptions.postSearchFilters ? routeOptions.postSearchFilters.reduce((prev, next2) => next2(prev), result) : result;
};
middlewares.push(legacyMiddleware);
}
const routeValidateSearch = routeOptions.validateSearch;
if (includeValidateSearch && routeValidateSearch) {
const validate = ({ search, next, meta }) => {
const result = next(search);
try {
const validated = validateSearch(routeValidateSearch, result);
if (meta && validated) {
for (const key in validated) if (!(key in result)) (meta.defaulted || (meta.defaulted = /* @__PURE__ */ new Map())).set(key, validated[key]);
}
return {
...result,
...validated
};
} catch {
}
return result;
};
middlewares.push(validate);
}
}
return middlewares;
}
function applySearchMiddleware(middlewares, search, dest) {
const applyNext = (index, currentSearch, meta) => {
if (index >= middlewares.length) {
if (!dest.search) return {};
if (dest.search === true) return currentSearch;
const result = functionalUpdate(dest.search, currentSearch);
if (meta) meta.explicit = result;
return result;
}
const next = (newSearch, collectMeta) => {
if (collectMeta) {
const nextMeta = meta || {};
return {
search: applyNext(index + 1, newSearch, nextMeta),
meta: nextMeta
};
}
return applyNext(index + 1, newSearch, meta);
};
return middlewares[index]({
search: currentSearch,
next,
meta
});
};
return applyNext(0, search);
}
function findGlobalNotFoundRouteId(notFoundMode, routes) {
if (notFoundMode !== "root") {
let fallback;
for (let i = routes.length - 1; i >= 0; i--) {
const route = routes[i];
if (route.options.notFoundComponent) return route.id;
fallback || (fallback = route.children && route.id);
}
if (fallback) return fallback;
}
return rootRouteId;
}
function extractStrictParams(route, accumulatedParams) {
var _a;
const parseParams = ((_a = route.options.params) == null ? void 0 : _a.parse) ?? route.options.parseParams;
if (parseParams) Object.assign(accumulatedParams, parseParams(accumulatedParams));
}
// node_modules/@tanstack/router-core/dist/esm/load-client.js
function replaceRouteChunk(route, lazyFn2) {
route.lazyFn = lazyFn2 ?? route.lazyFn;
route._lazy = void 0;
}
function preloadComponent(route, type) {
var _a, _b;
return (_b = (_a = route.options[type]) == null ? void 0 : _a.preload) == null ? void 0 : _b.call(_a);
}
function loadComponents(route, onPendingReady) {
const component = preloadComponent(route, "component");
let pending = preloadComponent(route, "pendingComponent");
if (onPendingReady) if (pending) pending = pending.then(onPendingReady);
else onPendingReady();
if (component && pending) return Promise.all([component, pending]).then(() => {
});
return component ?? pending;
}
function loadRouteChunk(route, componentType, onPendingReady) {
const afterLazy = () => componentType === false ? void 0 : componentType ? preloadComponent(route, componentType) : loadComponents(route, onPendingReady);
const current = route._lazy;
if (current) return current === true ? afterLazy() : current.then(afterLazy);
if (!route.lazyFn) return afterLazy();
const promise = route.lazyFn().then((lazyRoute) => {
if (route._lazy === promise) {
const { id: _id, ...options } = lazyRoute.options;
Object.assign(route.options, options);
route._lazy = true;
}
}, (error) => {
if (route._lazy === promise) route._lazy = void 0;
throw error;
});
route._lazy = promise;
return promise.then(afterLazy);
}
function _getRenderedMatches(matches) {
const end = matches.findIndex((match) => match.status !== "success" || match._notFound) + 1;
return end && end < matches.length ? matches.slice(0, end) : matches;
}
function _getAssetMatches(matches) {
let end = matches.length;
for (let index = 0; index < end; index++) {
const match = matches[index];
if (match._assetEnd !== void 0) {
end = Math.min(end, Math.max(index + 1, match._assetEnd));
continue;
}
if (match.status !== "success" || match._notFound) {
end = index + 1;
break;
}
}
return end < matches.length ? matches.slice(0, end) : matches;
}
var SUCCESS = 0;
var ERROR = 1;
var NOT_FOUND = 2;
var REDIRECTED = 3;
var CANCELED_OUTCOME = [4];
function isControl(result) {
return typeof result[0] === "number";
}
function waitFor(value, signal) {
if (signal.aborted) return Promise.race([Promise.reject(signal), value]);
return new Promise((resolve, reject) => {
const abort = () => reject(signal);
signal.addEventListener("abort", abort, { once: true });
Promise.resolve(value).then(resolve, reject).then(() => signal.removeEventListener("abort", abort));
});
}
function getRoute(router, match) {
return router.routesById[match.routeId];
}
function normalize2(value, rejected, routeId) {
if (isRedirect(value)) return [REDIRECTED, value];
if (isNotFound(value)) {
value.routeId || (value.routeId = routeId);
return [NOT_FOUND, value];
}
if (!rejected) return [SUCCESS, value];
if (typeof (value == null ? void 0 : value.then) === "function") value = new Error("A Promise was thrown", { cause: value });
return [ERROR, value];
}
function normalizeError(route, cause) {
var _a, _b;
let outcome = normalize2(cause, true, route.id);
if (outcome[0] !== ERROR) return outcome;
try {
(_b = (_a = route.options).onError) == null ? void 0 : _b.call(_a, outcome[1]);
} catch (onErrorCause) {
outcome = normalize2(onErrorCause, true, route.id);
}
return outcome;
}
function normalizeLaneError(router, lane, route, cause, options) {
if (options[0].signal.aborted) return CANCELED_OUTCOME;
return materializeRedirect(router, lane, route, normalizeError(route, cause), options);
}
async function contextualize(router, lane, options, end, planSuccessfulLane, retainedEnd) {
var _a, _b;
const [location, matches] = lane;
const signal = options[0].signal;
const preload = !!options[3];
for (let index = options[6] ?? 0; index < end; index++) {
const match = matches[index];
const route = getRoute(router, match);
match.abortController = options[0];
const parentContext = ((_a = matches[index - 1]) == null ? void 0 : _a.context) ?? router.options.context ?? {};
const common = {
params: match.params,
location,
navigate: (opts) => router.navigate({
...opts,
_fromLocation: location
}),
buildLocation: router.buildLocation,
cause: preload ? "preload" : match.cause,
abortController: options[0],
preload,
matches,
routeId: route.id
};
try {
const routeContext = match._ctx || (match._ctx = route.options.context ? route.options.context({
...common,
deps: match.loaderDeps,
context: parentContext
}) || {} : void 0);
match.context = {
...parentContext,
...routeContext
};
} catch (cause) {
releaseFlight(router, match);
return [index, normalizeLaneError(router, lane, route, cause, options)];
}
if (signal.aborted) return [index, CANCELED_OUTCOME];
const validationError = match.paramsError ?? match.searchError;
if (validationError !== void 0) {
releaseFlight(router, match);
return [index, normalizeLaneError(router, lane, route, validationError, options)];
}
const beforeLoad = route.options.beforeLoad;
if (!beforeLoad) continue;
const previousStatus = match.status;
if (index >= retainedEnd) {
match.status = "pending";
(_b = options[7]) == null ? void 0 : _b.call(options);
}
try {
setFetching(router, match, "beforeLoad", options[0]);
const value = beforeLoad({
...common,
search: match.search,
context: match.context,
...router.options.additionalContext
});
const result = await (typeof (value == null ? void 0 : value.then) === "function" ? waitFor(value, signal) : value);
if (signal.aborted) return [index, CANCELED_OUTCOME];
const outcome = materializeRedirect(router, lane, route, normalize2(result, false, route.id), options);
if (outcome[0] !== SUCCESS) {
releaseFlight(router, match);
return [index, outcome];
}
match.context = {
...match.context,
...result
};
} catch (cause) {
releaseFlight(router, match);
return [index, normalizeLaneError(router, lane, route, cause, options)];
} finally {
match.status = previousStatus;
setFetching(router, match, false, options[0]);
}
}
planSuccessfulLane();
}
function releaseOwnedFlight(router, match, flight) {
var _a;
if (!flight || --flight[2]) return;
if (((_a = router._flights) == null ? void 0 : _a.get(match.id)) === flight) {
const current = router._tx;
if (current && !current[0].signal.aborted && !current[3].includes(match) && current[3].some((candidate) => candidate.id === match.id) && current[3].some((candidate) => candidate.isFetching === "beforeLoad")) return;
router._flights.delete(match.id);
}
return flight[1];
}
function releaseFlight(router, match) {
var _a;
const flight = match._flight;
match._flight = void 0;
(_a = releaseOwnedFlight(router, match, flight)) == null ? void 0 : _a.abort();
}
function transferMatchResources(router, previous, next, deferSameIdFlight) {
var _a;
const abort = [];
for (const match of previous) if (!(next == null ? void 0 : next.includes(match))) {
const flight = match._flight;
match._flight = void 0;
if (deferSameIdFlight && (flight == null ? void 0 : flight[2]) === 1 && ((_a = router._flights) == null ? void 0 : _a.get(match.id)) === flight && (next == null ? void 0 : next.some((candidate) => candidate.id === match.id))) flight[2] = 0;
else {
const controller = releaseOwnedFlight(router, match, flight);
if (controller) abort.push(controller);
}
}
for (const controller of abort) controller.abort();
}
function acquireMatchResources(matches) {
for (const match of matches) {
const flight = match._flight;
if (flight) flight[2]++;
}
}
function setFetching(router, match, value, owner) {
var _a;
match.isFetching = value;
if (owner && ((_a = router._tx) == null ? void 0 : _a[0]) !== owner) return;
const store = router.stores.byRoute.get(match.routeId);
const presented = store == null ? void 0 : store.get();
if ((presented == null ? void 0 : presented.id) === match.id) store.set({
...presented,
isFetching: value
});
}
function getLoaderContext(router, lane, match, route, controller, parentMatchPromise, preload) {
const location = lane[0];
return {
params: match.params,
location,
navigate: (opts) => router.navigate({
...opts,
_fromLocation: location
}),
cause: preload ? "preload" : match.cause,
abortController: controller,
preload,
deps: match.loaderDeps,
parentMatchPromise,
context: match.context,
route,
...router.options.additionalContext
};
}
async function loadResource(router, lane, match, route, loader, parentMatchPromise, options) {
const owner = options[0];
const signal = owner.signal;
if (signal.aborted) return CANCELED_OUTCOME;
if (!loader) return [SUCCESS, void 0];
let flight = match._flight;
setFetching(router, match, "loader", owner);
try {
if (!flight) {
const controller = new AbortController();
flight = [
Promise.resolve().then(() => loader(getLoaderContext(router, lane, match, route, controller, parentMatchPromise, !!options[3]))).then((value) => normalize2(value, false, route.id), (cause) => normalize2(cause, true, route.id)).then((result) => {
var _a;
if (result[0] !== SUCCESS && ((_a = router._flights) == null ? void 0 : _a.get(match.id)) === flight) {
router._flights.delete(match.id);
if (!flight[2]) controller.abort();
}
return result[0] === ERROR && flight[2] ? normalizeError(route, result[1]) : result;
}),
controller,
1
];
(router._flights ?? (router._flights = /* @__PURE__ */ new Map())).set(match.id, flight);
}
match._flight = flight;
match.abortController = flight[1];
return materializeRedirect(router, lane, route, await waitFor(flight[0], signal), options);
} catch (cause) {
if (cause !== signal || !signal.aborted) throw cause;
releaseFlight(router, match);
return CANCELED_OUTCOME;
} finally {
setFetching(router, match, false, owner);
}
}
function settleInto(match, result, preload) {
if (result[0] === REDIRECTED) return;
match.status = "success";
match.error = void 0;
if (result[0] === SUCCESS) {
match.loaderData = result[1];
match.invalid = false;
match.updatedAt = Date.now();
match.preload = preload;
} else match.invalid = true;
}
function cacheLoaderMatch(router, match, planned) {
const current = router._cache.get(match.id);
if (current !== planned || router._committed.some((candidate) => candidate.id === match.id && candidate._flight === match._flight)) return;
const cached = {
...match,
_notFound: void 0,
context: {}
};
if (cached._flight) cached._flight[2]++;
router._cache.set(match.id, cached);
if (current) releaseFlight(router, current);
}
function getParentSnapshot(match, outcome) {
if (outcome[0] === ERROR || outcome[0] === NOT_FOUND) return {
...match,
status: outcome[0] === ERROR ? "error" : "notFound",
error: outcome[1],
_flight: void 0
};
return match;
}
function createLoaderTask(router, lane, index, tasks, semanticParent, options, retainedEnd) {
var _a, _b, _c;
const match = lane[1][index];
const route = getRoute(router, match);
const preload = !!options[3];
const plannedCacheMatch = router._cache.get(match.id);
let configured;
let reload = false;
let reloadFailure;
try {
if (match.status === "success") {
configured = route.options.shouldReload;
if (typeof configured === "function") configured = configured(getLoaderContext(router, lane, match, route, options[0], semanticParent, preload));
if (options[0].signal.aborted) reloadFailure = CANCELED_OUTCOME;
}
if (!reloadFailure) if (match.status !== "success") reload = true;
else {
const staleAge = preload || match.preload ? route.options.preloadStaleTime ?? router.options.defaultPreloadStaleTime ?? 3e4 : route.options.staleTime ?? router.options.defaultStaleTime ?? 0;
reload = !!(match.invalid || configured || configured === void 0 && Date.now() - match.updatedAt >= staleAge && (options[5] || match.cause === "enter" || options[2].some((candidate2) => candidate2.routeId === match.routeId && candidate2.id !== match.id)));
}
} catch (cause) {
match.invalid = true;
releaseFlight(router, match);
reloadFailure = normalizeLaneError(router, lane, route, cause, options);
}
const routeLoader = route.options.loader;
const isLoaderFn = typeof routeLoader === "function";
const loader = isLoaderFn ? routeLoader : routeLoader == null ? void 0 : routeLoader.handler;
const preloadable = !preload || route.options.preload !== false;
let donor = preloadable && routeLoader && !((_a = router._tx) == null ? void 0 : _a[6]) ? (_b = router._flights) == null ? void 0 : _b.get(match.id) : void 0;
if (donor === match._flight || reloadFailure) donor = void 0;
else if (donor && !reload && !preload && configured === void 0) reload = true;
else if (!reload) donor = void 0;
const background = !!(routeLoader && reload && match.status === "success" && !preload && !options[4] && ((isLoaderFn ? void 0 : routeLoader.staleReloadMode) ?? router.options.defaultStaleReloadMode) !== "blocking");
const loaded = reload && preloadable;
const blocking = loaded && !background && (match.status !== "success" || !!routeLoader);
const onReady = index >= retainedEnd ? options[7] : void 0;
const onLazyReady = route.lazyFn && route._lazy !== true ? onReady : void 0;
if (loaded && !routeLoader) {
match.invalid = false;
match.updatedAt = Date.now();
}
if (donor) donor[2]++;
if (blocking) {
const acceptedFlight = match._flight;
match._flight = donor;
(_c = releaseOwnedFlight(router, match, acceptedFlight)) == null ? void 0 : _c.abort();
if (index >= retainedEnd) match.status = "pending";
onReady == null ? void 0 : onReady();
}
if (!loaded) match.isFetching = false;
const outcome = !reloadFailure && blocking ? loadResource(router, lane, match, route, loader, semanticParent, options).then((result) => {
settleInto(match, result, preload);
if (result[0] === SUCCESS) {
if (routeLoader && !options[0].signal.aborted) cacheLoaderMatch(router, match, plannedCacheMatch);
if (index >= retainedEnd) match.status = "pending";
}
return result;
}) : Promise.resolve(reloadFailure ?? [SUCCESS, match.loaderData]);
const chunkFailure = (async () => {
try {
const chunk = loadRouteChunk(route, void 0, onLazyReady);
if (chunk) await waitFor(chunk, options[0].signal);
} catch (cause) {
if (!lane[1].some((candidate2, candidateIndex) => candidateIndex <= index && (candidate2.status === "error" || candidate2.status === "notFound" || candidate2._notFound))) return [index, normalizeLaneError(router, lane, route, cause, options)];
}
const result = await outcome;
if (blocking && result[0] === SUCCESS && match.status === "pending" && !options[0].signal.aborted) {
match.status = "success";
onReady == null ? void 0 : onReady();
}
})();
tasks.push([
index,
outcome,
chunkFailure
]);
if (!background) return outcome.then((result) => getParentSnapshot(match, result));
const candidate = {
...match,
status: "pending",
preload: false,
_flight: donor
};
match.invalid = false;
match.isFetching = "loader";
const backgroundOutcome = loadResource(router, lane, candidate, route, loader, semanticParent, options).then((result) => {
match.isFetching = false;
settleInto(candidate, result, false);
return result;
});
(lane[2] ?? (lane[2] = [])).push([
index,
backgroundOutcome,
chunkFailure,
candidate
]);
return backgroundOutcome.then((result) => getParentSnapshot(candidate, result));
}
async function getNotFoundBoundary(router, matches, indexed, signal, fallback = 0) {
const cause = indexed == null ? void 0 : indexed[1][1];
let index = (cause == null ? void 0 : cause.routeId) ? matches.findIndex((match) => match.routeId === cause.routeId) : (indexed == null ? void 0 : indexed[0]) ?? matches.length - 1;
if (index < 0) index = 0;
for (let i = index; i >= 0; i--) {
const route = getRoute(router, matches[i]);
try {
const loading = loadRouteChunk(route, false);
if (loading) await waitFor(loading, signal);
} catch (cause2) {
if (cause2 === signal && signal.aborted) throw cause2;
}
if (route.options.notFoundComponent) return i;
}
return (cause == null ? void 0 : cause.routeId) ? index : fallback;
}
function discardBackground(router, lane) {
if (lane[2]) {
transferMatchResources(router, lane[2].map((task) => task[3]));
lane[2] = void 0;
}
}
async function settleTasks(tasks, serialFailure, redirectTasks, gate) {
let loaderFailure;
try {
await Promise.all(tasks.map((task) => task[1].then(async (outcome) => {
const taskIndex = task[0];
if (gate && taskIndex >= await gate) return;
if (outcome[0] >= REDIRECTED) throw [taskIndex, outcome];
if (!loaderFailure && outcome[0] !== SUCCESS) {
loaderFailure = [taskIndex, outcome];
await Promise.all((redirectTasks ?? []).map((nextTask) => {
if (nextTask[0] <= taskIndex) return;
return nextTask[1].then((nextOutcome) => {
if (nextOutcome[0] === REDIRECTED) throw [nextTask[0], nextOutcome];
});
}));
}
})));
} catch (cause) {
return cause;
}
return serialFailure ?? loaderFailure;
}
function materializeRedirect(router, lane, route, outcome, options, failed) {
while (outcome[0] === REDIRECTED) {
const redirect2 = outcome[1];
const redirectOptions = redirect2.options;
try {
if (redirectOptions.href || redirect2.headers.has("Location")) {
router.resolveRedirect(redirect2);
if (redirectOptions.reloadDocument) return outcome;
}
if (redirectOptions.reloadDocument ? options[3] : options[1] >= 20) return outcome;
const location = router.buildLocation({
...redirectOptions,
_fromLocation: lane[0],
_includeValidateSearch: true
});
const publicLocation = location.maskedLocation ?? location;
if (publicLocation.external) {
const resolved = redirect2.clone();
resolved.options = { ...redirectOptions };
resolved.headers.set("Location", publicLocation.publicHref);
router.resolveRedirect(resolved);
return options[3] ? [REDIRECTED, resolved] : [
REDIRECTED,
resolved,
publicLocation
];
}
return [
REDIRECTED,
redirect2,
location
];
} catch (cause) {
outcome = failed ? [ERROR, cause] : normalizeError(route, cause);
failed = true;
}
}
return outcome;
}
async function reduceLane(router, lane, tasks, controller, settlement, onReady) {
const matches = lane[1];
let failure = await settlement;
let redirectLimitExceeded = false;
const plannedBoundary = matches.findIndex((match) => match._notFound);
const boundaryOf = (found) => found[1][0] === NOT_FOUND ? getNotFoundBoundary(router, matches, found, controller.signal) : found[0];
let readinessEnd = plannedBoundary < 0 ? matches.length : plannedBoundary;
if (((failure == null ? void 0 : failure[1][0]) ?? 0) >= REDIRECTED) readinessEnd = 0;
else if (failure) {
readinessEnd = failure[2] ?? (failure[2] = await boundaryOf(failure));
for (const task of tasks) {
if (task[0] >= readinessEnd) break;
const outcome = await task[1];
if (outcome[0] !== SUCCESS && outcome[0] < REDIRECTED && !("loaderData" in matches[task[0]])) {
failure = [task[0], outcome];
readinessEnd = failure[2] = await boundaryOf(failure);
break;
}
}
}
for (const task of tasks) {
if (task[0] >= readinessEnd) break;
const chunkFailure = await task[2];
if (!chunkFailure) continue;
failure = chunkFailure;
break;
}
if (((failure == null ? void 0 : failure[1][0]) ?? 0) >= REDIRECTED) {
const outcome = failure[1];
if (outcome[0] !== REDIRECTED || outcome[1].options.reloadDocument || outcome[2]) {
discardBackground(router, lane);
return outcome;
}
redirectLimitExceeded = true;
failure = [0, [ERROR, new Error("Too many redirects")]];
}
const boundary = failure ? failure[2] ?? await boundaryOf(failure) : plannedBoundary;
if (boundary >= 0) {
const outcome = failure == null ? void 0 : failure[1];
const kind = outcome == null ? void 0 : outcome[0];
const match = matches[boundary];
const cause = outcome == null ? void 0 : outcome[1];
const install = () => {
if (outcome) {
match._notFound = void 0;
if (kind === ERROR) match.status = "error";
else {
cause.routeId = match.routeId;
if (match.routeId === router.routeTree.id) {
match.status = "success";
match._notFound = true;
} else match.status = "notFound";
}
match.error = cause;
match.isFetching = false;
}
};
install();
if (!outcome) onReady == null ? void 0 : onReady();
const route = getRoute(router, match);
try {
await waitFor(outcome ? Promise.resolve().then(() => loadRouteChunk(route, kind === ERROR ? "errorComponent" : "notFoundComponent")) : Promise.all([loadRouteChunk(route), loadRouteChunk(route, "notFoundComponent")]), controller.signal);
} catch (cause2) {
if (cause2 === controller.signal && controller.signal.aborted) {
discardBackground(router, lane);
return CANCELED_OUTCOME;
}
}
if (!outcome) match.status = "success";
else if (redirectLimitExceeded) {
controller.abort();
await Promise.all([
...tasks.map((task) => task[1]),
...tasks.map((task) => task[2]),
...(lane[2] ?? []).map((task) => task[1])
]);
discardBackground(router, lane);
transferMatchResources(router, matches);
install();
}
}
return lane;
}
async function projectLane(router, lane, signal, start = 0, end = lane[1].length) {
var _a, _b;
const matches = lane[1];
for (let index = start; index < end; index++) {
const match = matches[index];
const routeOptions = getRoute(router, match).options;
if (routeOptions.head || routeOptions.scripts) try {
const context = {
ssr: router.options.ssr,
matches,
match,
params: match.params,
loaderData: match.loaderData
};
const [head, scripts] = await waitFor(Promise.all([(_a = routeOptions.head) == null ? void 0 : _a.call(routeOptions, context), (_b = routeOptions.scripts) == null ? void 0 : _b.call(routeOptions, context)]), signal);
match.meta = head == null ? void 0 : head.meta;
match.links = head == null ? void 0 : head.links;
match.headScripts = head == null ? void 0 : head.scripts;
match.styles = head == null ? void 0 : head.styles;
match.scripts = scripts;
} catch (cause) {
if (cause === signal && signal.aborted) break;
console.error(cause);
}
if (match.status !== "success" || match._notFound) break;
}
return lane;
}
async function executeClientLane(router, location, matches, options) {
var _a;
const matched = [location, matches];
const signal = options[0].signal;
let reduced;
try {
const presented = router.stores.matches.get();
let plannedBoundary = matches.findIndex((match) => match._notFound);
if (router.options.notFoundMode !== "root" && plannedBoundary >= 0) {
const boundary = await getNotFoundBoundary(router, matches, void 0, signal, plannedBoundary);
matches[plannedBoundary]._notFound = void 0;
matches[boundary]._notFound = true;
plannedBoundary = boundary;
}
let end = plannedBoundary < 0 ? matches.length : plannedBoundary + 1;
let retainedEnd = 0;
while (retainedEnd < end && retainedEnd !== plannedBoundary) {
const match = matches[retainedEnd];
const committed = options[2][retainedEnd];
const visible = presented[retainedEnd];
if ((committed == null ? void 0 : committed.id) !== match.id || committed.status !== "success" || match.preload || (visible == null ? void 0 : visible.id) !== match.id || visible.status !== "success") break;
retainedEnd++;
if (committed._notFound || visible._notFound) break;
}
const tasks = [];
const start = options[6] ?? 0;
let semanticParent = start ? Promise.resolve(matches[start - 1]) : void 0;
const planSuccessfulLane = () => {
for (let index = start; index < end; index++) {
if (signal.aborted) break;
semanticParent = createLoaderTask(router, matched, index, tasks, semanticParent, options, retainedEnd);
}
};
const failure = await contextualize(router, matched, options, end, planSuccessfulLane, retainedEnd);
if (failure) {
options[4] = true;
end = failure[0];
if (failure[1][0] === NOT_FOUND) {
const boundary = await getNotFoundBoundary(router, matches, failure, signal);
failure[2] = boundary;
end = Math.min(end, boundary + 1);
} else if (failure[1][0] >= REDIRECTED) end = 0;
planSuccessfulLane();
}
if (!signal.aborted && !options[3]) {
const abort = [];
for (const [id, flight] of router._flights ?? []) if (!flight[2]) {
router._flights.delete(id);
abort.push(flight[1]);
}
for (const controller of abort) controller.abort();
}
const reduction = reduceLane(router, matched, tasks, options[0], settleTasks(tasks, failure, matched[2]), options[7]);
if ((_a = matched[2]) == null ? void 0 : _a.length) matched[3] = settleTasks(matched[2], void 0, void 0, reduction.then((foreground) => isControl(foreground) ? 0 : _getRenderedMatches(matches).length, () => 0));
reduced = await reduction;
} catch (cause) {
discardBackground(router, matched);
if (cause === signal && signal.aborted) return CANCELED_OUTCOME;
throw cause;
}
if (isControl(reduced)) return reduced;
return projectLane(router, reduced, signal, options[6] === matches.length ? options[6] : 0);
}
function offerPending(router, tx) {
var _a, _b;
if (router._tx !== tx) return;
const matches = tx[3];
const presented = router.stores.matches.get();
let session = router._pending;
for (let index = 0; index < matches.length; index++) {
const match = matches[index];
const success = match.status === "success" && !match._notFound;
const presentedPending = ((_a = presented[index]) == null ? void 0 : _a.id) === match.id && ((_b = presented[index]) == null ? void 0 : _b.status) === "pending";
if (success && !presentedPending) continue;
const route = getRoute(router, match);
const delay = success || match.invalid ? 0 : route.options.pendingMs ?? router.options.defaultPendingMs;
const component = route.options.pendingComponent ?? router.options.defaultPendingComponent;
if (!component || typeof delay !== "number" || delay === Infinity) {
if (session) {
session[0] = tx;
session[2] = 0;
session[4] = true;
}
return;
}
const min = route.options.pendingMinMs ?? router.options.defaultPendingMinMs ?? 0;
let tookOver = false;
if ((session == null ? void 0 : session[1]) === match.id) {
tookOver = session[0] !== tx;
session[0] = tx;
} else {
clearTimeout(session == null ? void 0 : session[3]);
router._pending = session = void 0;
}
if (!session) router._pending = session = [
tx,
match.id,
presentedPending ? Date.now() + min : tx[4] + delay,
void 0,
presentedPending || void 0,
component
];
if (session[4] && !tookOver && session[5] === component) return;
session[5] = component;
if (!session[4]) {
clearTimeout(session[3]);
const remaining = session[2] - Date.now();
if (remaining > 0) {
session[3] = setTimeout(() => offerPending(router, tx), remaining);
return;
}
session[2] = 0;
}
const offered = matches.map((match2) => ({
...match2,
_flight: void 0
}));
offered[index].status = "pending";
const ack = session[4] = router.startTransition(() => router.stores.setMatches(offered), offered).then((rendered) => {
if (rendered && router._pending === session && session[4] === ack && !session[2]) session[2] = Date.now() + min;
return rendered;
});
return;
}
}
function finishPending(router, tx) {
var _a;
const session = router._pending;
if (router._tx === tx || !((_a = router._tx) == null ? void 0 : _a[3].some((match) => match.id === (session == null ? void 0 : session[1])))) {
clearTimeout(session == null ? void 0 : session[3]);
router._pending = void 0;
}
}
async function awaitPendingMinimum(router, tx) {
const session = router._pending;
if (!session) return;
clearTimeout(session[3]);
const remaining = session[2] - Date.now();
if (!session[4] || remaining <= 0 || !_getRenderedMatches(tx[3]).some((match) => match.id === session[1])) return;
let timer;
try {
await waitFor(new Promise((resolve) => {
timer = setTimeout(resolve, remaining);
}), tx[0].signal);
} catch {
}
clearTimeout(timer);
}
function publishMatches(router, matches) {
router._committed = matches;
router.stores.setMatches(matches);
}
function commitMatches(router, tx, matches, resolvedPrefix) {
var _a;
const previous = router._committed;
const previousEnd = router._lifecycleEnd;
const previousCached = router._cache;
for (const match of matches) {
match.preload = false;
if (resolvedPrefix) match._assetEnd = void 0;
}
const cut = _getRenderedMatches(matches).length;
const cached = /* @__PURE__ */ new Map();
if (!tx[6]) {
const now = Date.now();
const superseded = /* @__PURE__ */ new Set();
for (let index = 0; index < matches.length; index++) {
const match = matches[index];
if (index < cut || match.status === "success") superseded.add(match.id);
}
for (const match of [...previous, ...previousCached.values()]) {
if (match.status !== "success" || superseded.has(match.id)) continue;
const route = getRoute(router, match);
if (!route.options.loader || now - match.updatedAt >= (match.preload ? route.options.preloadGcTime ?? router.options.defaultPreloadGcTime ?? 3e5 : route.options.gcTime ?? router.options.defaultGcTime ?? 3e5)) continue;
cached.set(match.id, previousCached.get(match.id) === match ? match : {
...match,
_flight: void 0,
isFetching: false,
context: {}
});
}
}
tx[3] = [];
router._cache = cached;
const nextEnd = router._lifecycleEnd = lifecycleEnd(matches);
publishMatches(router, matches);
transferMatchResources(router, [...previousCached.values(), ...previous].filter((match) => match._flight && cached.get(match.id) !== match), matches);
if (true) {
const handoff = (_a = tx[6]) == null ? void 0 : _a[0];
if (handoff && router._handoff === handoff) handoff[1]();
}
runRouteLifecycle(router, previous, matches, previousEnd, nextEnd, tx);
}
async function awaitCurrent(router, owner) {
let current = router._tx;
while (current && current !== owner) {
owner = current;
await current[5];
current = router._tx;
}
}
function followRedirect(router, tx, outcome) {
const options = outcome[1].options;
const location = outcome[2];
if (!location) return router.navigate({
...options,
replace: true,
ignoreBlocker: true
});
if (options.reloadDocument) return router.navigate({
href: (location.maskedLocation ?? location).publicHref,
reloadDocument: true,
replace: true,
ignoreBlocker: true
});
location._redirects = tx[1] + 1;
router._pendingLocation = location;
const committed = router.commitLocation({
...location,
viewTransition: options.viewTransition,
replace: true,
resetScroll: options.resetScroll,
hashScrollIntoView: options.hashScrollIntoView,
ignoreBlocker: true
});
queueMicrotask(() => {
if (router._pendingLocation === location) router._pendingLocation = void 0;
});
return committed;
}
async function runBackground(router, tx, base, tasks, settlement) {
const next = base.map((match) => ({ ...match }));
acquireMatchResources(next);
for (const task of tasks) {
releaseFlight(router, next[task[0]]);
next[task[0]] = task[3];
}
const lane = [tx[2], next];
let reduced;
try {
reduced = await reduceLane(router, lane, tasks, tx[0], settlement);
} catch (cause) {
transferMatchResources(router, next);
throw cause;
}
if (isControl(reduced)) {
transferMatchResources(router, next);
if (reduced[0] === REDIRECTED && router._tx === tx && router._committed === base) await followRedirect(router, tx, reduced);
return;
}
await projectLane(router, reduced, tx[0].signal);
if (router._tx !== tx || router._committed !== base) {
transferMatchResources(router, next);
return;
}
for (const match of next) {
const cached = router._cache.get(match.id);
if ((cached == null ? void 0 : cached._flight) && cached._flight === match._flight) {
router._cache.delete(match.id);
releaseFlight(router, cached);
}
}
publishMatches(router, next);
transferMatchResources(router, base, next);
}
async function runClientTransaction(router, tx, forceStaleReload, onReady, sync, resolvedPrefix) {
const result = await executeClientLane(router, tx[2], tx[3], [
tx[0],
tx[1],
router._committed,
void 0,
sync,
forceStaleReload,
resolvedPrefix,
onReady
]);
if (isControl(result)) {
const follow = result[0] === REDIRECTED && router._tx === tx;
if (!follow || result[1].options.reloadDocument) finishPending(router, tx);
transferMatchResources(router, tx[3]);
tx[3] = [];
if (!follow) return;
if (router._tx !== tx) {
finishPending(router, tx);
return;
}
if (tx[6]) router._refreshNextLoad = true;
await followRedirect(router, tx, result);
return;
}
const matches = result[1];
if (router._tx === tx) await awaitPendingMinimum(router, tx);
if (router._tx !== tx) {
finishPending(router, tx);
transferMatchResources(router, matches);
discardBackground(router, result);
return;
}
const toLocation = tx[2];
const changeInfo = getLocationChangeInfo(toLocation, router.stores.resolvedLocation.get());
const background = result[2];
await router.startViewTransition(async () => {
var _a;
if (router._tx === tx) await awaitPendingMinimum(router, tx);
if (router._tx !== tx) {
finishPending(router, tx);
transferMatchResources(router, matches);
discardBackground(router, result);
return;
}
const commit = () => {
finishPending(router, tx);
commitMatches(router, tx, matches, resolvedPrefix);
if (router._tx !== tx) return;
router.emit({
type: "onLoad",
...changeInfo
});
if (router._tx === tx) router.emit({
type: "onBeforeRouteMount",
...changeInfo
});
};
const rendered = await router.startTransition(commit, matches);
if (tx[6]) tx[6] = void 0;
if (router._tx !== tx) {
discardBackground(router, result);
return;
}
if (background == null ? void 0 : background.length) runBackground(router, tx, matches, background, result[3]).catch(console.error);
router.batch(() => {
router.stores.resolvedLocation.set(toLocation);
router.stores.status.set("idle");
if (router._tx === tx) router.emit({
type: "onResolved",
...changeInfo
});
if (rendered && router._tx === tx) router.emit({
type: "onRendered",
...changeInfo
});
});
if (router._tx !== tx) return;
(_a = router._commitPromise) == null ? void 0 : _a.resolve();
router._commitPromise = void 0;
});
}
async function loadClientRoute(router, opts) {
var _a, _b;
let rematerialize = false;
if (true) rematerialize = !!router._refreshNextLoad || !!((_a = router._tx) == null ? void 0 : _a[6]);
const previousOwner = router._tx;
const resolvedLocation = router.stores.resolvedLocation.get();
const previousLocation = resolvedLocation ?? router.stores.location.get();
const location = router.latestLocation;
const pendingLocation = router._pendingLocation;
const redirects = (pendingLocation == null ? void 0 : pendingLocation.href) === location.href ? pendingLocation._redirects ?? 0 : 0;
const handoff = router._handoff;
const hydrationController = rematerialize ? void 0 : handoff == null ? void 0 : handoff[0]();
const preflight = new AbortController();
const previousPreflight = router._preflight;
router._preflight = preflight;
if (!rematerialize && !hydrationController) handoff == null ? void 0 : handoff[1]();
previousPreflight == null ? void 0 : previousPreflight.abort();
if (!preflight.signal.aborted) {
const changeInfo = getLocationChangeInfo(location, resolvedLocation);
router.emit({
type: "onBeforeNavigate",
...changeInfo
});
if (!preflight.signal.aborted) router.emit({
type: "onBeforeLoad",
...changeInfo
});
}
if (preflight.signal.aborted) {
await awaitCurrent(router, previousOwner);
return;
}
const sameHref = previousLocation.href === location.href;
let controller = preflight;
const matches = rematerialize ? router.matchRoutes(location, {
_controller: preflight,
_rematerialize: true
}) : router.matchRoutes(location, { _controller: preflight });
acquireMatchResources(matches);
const resolvedPrefix = hydrationController ? handoff[1](matches) : void 0;
if (resolvedPrefix) controller = hydrationController;
else hydrationController == null ? void 0 : hydrationController.abort();
if (preflight.signal.aborted) {
transferMatchResources(router, matches);
await awaitCurrent(router, previousOwner);
return;
}
router._preflight = void 0;
let settle;
const run = () => runClientTransaction(router, tx, sameHref, () => offerPending(router, tx), opts == null ? void 0 : opts.sync, resolvedPrefix);
const done = (opts == null ? void 0 : opts.sync) ? new Promise((resolve) => settle = resolve) : Promise.resolve().then(run);
const tx = [
controller,
redirects,
location,
matches,
Date.now(),
done.then(() => awaitCurrent(router, tx))
];
if (rematerialize) {
tx[6] = [handoff];
router._refreshNextLoad = void 0;
}
router._tx = tx;
if (previousOwner) {
for (const match of router.stores.matches.get()) {
if (router._tx !== tx) break;
if (match.isFetching) setFetching(router, match, false);
}
previousOwner[0].abort();
transferMatchResources(router, previousOwner[3], tx[3], true);
}
if (router._tx !== tx) {
transferMatchResources(router, tx[3]);
tx[3] = [];
settle == null ? void 0 : settle();
await awaitCurrent(router, tx);
return;
}
router.batch(() => {
router.stores.status.set("pending");
router.stores.location.set(location);
});
if (resolvedPrefix || !router._committed.length && ((_b = matches[0]) == null ? void 0 : _b.status) !== "success" && !matches.some((match) => match._notFound)) offerPending(router, tx);
settle == null ? void 0 : settle(run());
await tx[5];
}
async function refreshClientRoute(router) {
var _a;
const pending = router._tx;
if (pending && !pending[6] && router.stores.status.get() === "pending") {
await pending[5];
if (router._tx !== pending) await awaitCurrent(router, pending);
}
(_a = router._flights) == null ? void 0 : _a.clear();
router.clearCache();
router._refreshNextLoad = true;
await loadClientRoute(router, { sync: true });
}
async function preloadClientRoute(router, opts) {
var _a, _b;
if (router._refreshNextLoad || ((_a = router._tx) == null ? void 0 : _a[6])) return;
let location = router.buildLocation(opts);
for (let redirects = 0; ; redirects++) {
const base = router._committed;
const controller = new AbortController();
let matches;
let active;
let result;
try {
try {
matches = router.matchRoutes(location, { _controller: controller });
acquireMatchResources(matches);
active = (router._preloads ?? (router._preloads = /* @__PURE__ */ new Map())).set(controller, matches);
result = await executeClientLane(router, location, matches, [
controller,
redirects,
base,
true
]);
} finally {
if (active) {
active = active.delete(controller);
transferMatchResources(router, matches);
}
controller.abort();
}
if (!isControl(result)) return result[1];
if (!active || result.length < 3 || (router._refreshNextLoad || ((_b = router._tx) == null ? void 0 : _b[6]))) return;
location = result[2];
} catch (cause) {
if (!isNotFound(cause)) console.error(cause);
return;
}
}
}
// node_modules/@tanstack/router-core/dist/esm/await-signal.js
function observeLate(callback, value) {
if (!callback) return;
try {
const result = callback(value);
if (result !== void 0) Promise.resolve(result).catch(() => {
});
} catch {
}
}
function waitForReason(value, signal, onLate, onLateError) {
const promise = Promise.resolve(value);
if (signal.aborted) {
promise.then((result) => observeLate(onLate, result), (error) => observeLate(onLateError, error));
return Promise.reject(signal.reason);
}
return new Promise((resolve, reject) => {
const abort = () => reject(signal.reason);
signal.addEventListener("abort", abort, { once: true });
promise.then((result) => {
signal.removeEventListener("abort", abort);
if (signal.aborted) observeLate(onLate, result);
else resolve(result);
}, (error) => {
signal.removeEventListener("abort", abort);
if (signal.aborted) observeLate(onLateError, error);
else reject(error);
});
});
}
// node_modules/@tanstack/router-core/dist/esm/load-server.js
var SUCCESS2 = 0;
var ERROR2 = 1;
var NOT_FOUND2 = 2;
var REDIRECTED2 = 3;
var SKIPPED = 4;
var MATCH_SETTLED_ABORT_REASON = Object.freeze({
name: "AbortError",
message: "TanStack Router aborted this server match because it settled."
});
var REDIRECT_ABORT_REASON = Object.freeze({
name: "AbortError",
message: "TanStack Router aborted this server match because of a redirect."
});
function getRoute2(router, match) {
return router.routesById[match.routeId];
}
function normalize3(value, rejected) {
if (isRedirect(value)) return [REDIRECTED2, value];
if (isNotFound(value)) return [NOT_FOUND2, value];
if (rejected && typeof (value == null ? void 0 : value.then) === "function") value = new Error("A Promise was thrown", { cause: value });
return rejected ? [ERROR2, value] : [SUCCESS2, value];
}
function normalizeError2(router, lane, route, cause, signal, notify = true) {
var _a, _b;
signal == null ? void 0 : signal.throwIfAborted();
let outcome = normalize3(cause, true);
if (outcome[0] !== ERROR2) return materializeRedirect2(router, lane, route, outcome, signal, notify);
try {
(_b = (_a = route.options).onError) == null ? void 0 : _b.call(_a, outcome[1]);
} catch (onErrorCause) {
outcome = normalize3(onErrorCause, true);
}
signal == null ? void 0 : signal.throwIfAborted();
return materializeRedirect2(router, lane, route, outcome, signal, notify);
}
function materializeRedirect2(router, lane, route, outcome, signal, notify = true) {
if (outcome[0] !== REDIRECTED2) return outcome;
signal == null ? void 0 : signal.throwIfAborted();
try {
outcome[1].options._fromLocation = lane.location;
router.resolveRedirect(outcome[1]);
signal == null ? void 0 : signal.throwIfAborted();
return outcome;
} catch (cause) {
signal == null ? void 0 : signal.throwIfAborted();
return notify ? normalizeError2(router, lane, route, cause, signal, false) : [ERROR2, cause];
}
}
function maybe(value, cause) {
if (cause !== void 0) return {
status: "error",
error: cause
};
return {
status: "success",
value
};
}
function navigateFrom(router, location) {
return (options) => router.navigate({
...options,
_fromLocation: location
});
}
function waitFor2(value, signal) {
return signal ? waitForReason(value, signal) : value;
}
function resolveSsr(router, lane, index) {
var _a;
const match = lane.matches[index];
const route = getRoute2(router, match);
const parentSsr = (_a = lane.matches[index - 1]) == null ? void 0 : _a.ssr;
if (router.isShell()) return route.id === rootRouteId;
if (parentSsr === false) return false;
const inherit = (value) => {
return value === true && parentSsr === "data-only" ? "data-only" : value;
};
const defaultSsr = router.options.defaultSsr ?? true;
const inheritedDefault = inherit(defaultSsr);
match.ssr = inheritedDefault;
const option = route.options.ssr;
if (option === void 0) return inheritedDefault;
if (typeof option !== "function") return inherit(option);
const context = {
search: maybe(match.search, match.searchError),
params: maybe(match.params, match.paramsError),
location: lane.location,
matches: lane.matches.map((candidate) => ({
index: candidate.index,
pathname: candidate.pathname,
fullPath: candidate.fullPath,
staticData: candidate.staticData,
id: candidate.id,
routeId: candidate.routeId,
search: maybe(candidate.search, candidate.searchError),
params: maybe(candidate.params, candidate.paramsError),
ssr: candidate.ssr
}))
};
try {
return Promise.resolve(option(context)).then((value) => inherit(value ?? defaultSsr));
} catch (cause) {
return Promise.reject(cause);
}
}
function stampNotFound(match, outcome) {
if (outcome[0] === NOT_FOUND2 && !outcome[1].routeId) outcome[1].routeId = match.routeId;
return outcome;
}
async function contextualize2(router, lane, signal) {
const globalBoundary = lane.matches.findIndex((match) => match._notFound);
let end = globalBoundary < 0 ? lane.matches.length : globalBoundary + 1;
let failure;
let parentContext = { ...router.options.context ?? {} };
for (let index = 0; index < end; index++) {
const match = lane.matches[index];
const route = getRoute2(router, match);
try {
const ssr = resolveSsr(router, lane, index);
match.ssr = ssr instanceof Promise ? await ssr : ssr;
} catch (cause) {
signal == null ? void 0 : signal.throwIfAborted();
failure = [index, stampNotFound(match, normalizeError2(router, lane, route, cause, signal))];
end = index;
}
signal == null ? void 0 : signal.throwIfAborted();
if ((failure == null ? void 0 : failure[1][0]) === REDIRECTED2) break;
match.__beforeLoadContext = void 0;
let context = parentContext;
try {
let routeContext;
if (route.options.context) {
const routeContextOptions = {
deps: match.loaderDeps,
params: match.params,
context: parentContext,
location: lane.location,
navigate: navigateFrom(router, lane.location),
buildLocation: router.buildLocation,
cause: match.cause,
abortController: match.abortController,
preload: false,
matches: lane.matches,
routeId: route.id
};
routeContext = route.options.context(routeContextOptions) ?? void 0;
}
context = {
...parentContext,
...routeContext
};
match.context = context;
} catch (cause) {
signal == null ? void 0 : signal.throwIfAborted();
if (!failure) failure = [index, stampNotFound(match, normalizeError2(router, lane, route, cause, signal))];
end = index;
break;
}
signal == null ? void 0 : signal.throwIfAborted();
if (failure) break;
const validationError = match.paramsError ?? match.searchError;
if (validationError !== void 0) {
failure = [index, stampNotFound(match, normalizeError2(router, lane, route, validationError, signal))];
end = index;
break;
}
signal == null ? void 0 : signal.throwIfAborted();
if (match.ssr === false || !route.options.beforeLoad) {
parentContext = context;
continue;
}
const abortController = match.abortController;
const options = {
search: match.search,
abortController,
params: match.params,
preload: false,
context,
location: lane.location,
navigate: navigateFrom(router, lane.location),
buildLocation: router.buildLocation,
cause: match.cause,
matches: lane.matches,
routeId: route.id,
...router.options.additionalContext
};
try {
const beforeLoadContext = await route.options.beforeLoad(options);
signal == null ? void 0 : signal.throwIfAborted();
const outcome = stampNotFound(match, materializeRedirect2(router, lane, route, normalize3(beforeLoadContext, false), signal));
if (outcome[0] !== SUCCESS2) {
failure = [index, outcome];
end = index;
break;
}
match.__beforeLoadContext = beforeLoadContext;
match.context = {
...context,
...beforeLoadContext
};
parentContext = match.context;
} catch (cause) {
signal == null ? void 0 : signal.throwIfAborted();
failure = [index, stampNotFound(match, normalizeError2(router, lane, route, cause, signal))];
end = index;
break;
}
}
return {
location: lane.location,
matches: lane.matches,
end,
failure
};
}
function getLoaderContext2(router, lane, match, route, index, tasks) {
var _a;
return {
params: match.params,
deps: match.loaderDeps,
preload: false,
parentMatchPromise: (_a = tasks[index - 1]) == null ? void 0 : _a.match,
abortController: match.abortController,
context: match.context,
location: lane.location,
navigate: navigateFrom(router, lane.location),
cause: match.cause,
route,
...router.options.additionalContext
};
}
function createLoaderTask2(router, lane, index, tasks, signal) {
const match = lane.matches[index];
const route = getRoute2(router, match);
let outcome;
if (match.ssr === false) outcome = Promise.resolve([SKIPPED]);
else {
const routeLoader = route.options.loader;
const loader = typeof routeLoader === "function" ? routeLoader : routeLoader == null ? void 0 : routeLoader.handler;
if (!loader) outcome = Promise.resolve([SUCCESS2, void 0]);
else outcome = Promise.resolve().then(() => loader(getLoaderContext2(router, lane, match, route, index, tasks))).then((result) => normalize3(result, false), (cause) => normalize3(cause, true)).then((result) => {
if ((signal == null ? void 0 : signal.aborted) || match.abortController.signal.reason === REDIRECT_ABORT_REASON) return [SKIPPED];
if (result[0] === ERROR2) result = normalizeError2(router, lane, route, result[1], signal);
else result = materializeRedirect2(router, lane, route, result, signal);
return stampNotFound(match, result);
});
}
const parentMatch = outcome.then((result) => {
const snapshot = { ...match };
if (result[0] === SUCCESS2) {
snapshot.loaderData = result[1];
snapshot.status = "success";
snapshot.error = void 0;
snapshot.invalid = false;
snapshot.isFetching = false;
} else if (result[0] === ERROR2) {
snapshot.status = "error";
snapshot.error = result[1];
} else if (result[0] === NOT_FOUND2) {
snapshot.status = "notFound";
snapshot.error = result[1];
}
return snapshot;
});
return {
index,
outcome,
match: parentMatch
};
}
async function getNotFoundBoundary2(router, matches, indexed, signal, fallback = 0) {
const cause = indexed == null ? void 0 : indexed[1][1];
let index = (cause == null ? void 0 : cause.routeId) ? matches.findIndex((match) => match.routeId === cause.routeId) : (indexed == null ? void 0 : indexed[0]) ?? matches.length - 1;
if (index < 0) index = 0;
for (let candidate = index; candidate >= 0; candidate--) {
const route = getRoute2(router, matches[candidate]);
try {
const loading = loadRouteChunk(route, false);
if (loading) await loading;
} catch {
signal == null ? void 0 : signal.throwIfAborted();
}
signal == null ? void 0 : signal.throwIfAborted();
if (route.options.notFoundComponent) return candidate;
}
return (cause == null ? void 0 : cause.routeId) ? index : fallback;
}
function abortMatches(matches, start = 0, reason = MATCH_SETTLED_ABORT_REASON) {
for (let index = start; index < matches.length; index++) matches[index].abortController.abort(reason);
}
async function applyFailure(router, lane, indexed, signal) {
if (!indexed) {
const boundary2 = lane.matches.findIndex((match2) => match2._notFound);
if (boundary2 >= 0) {
abortMatches(lane.matches, boundary2 + 1);
return {
status: 404,
boundary: boundary2,
kind: NOT_FOUND2
};
}
return { status: 200 };
}
const [index, outcome] = indexed;
if (outcome[0] === ERROR2) {
const match2 = lane.matches[index];
match2._notFound = void 0;
match2.status = "error";
match2.error = outcome[1];
match2.isFetching = false;
abortMatches(lane.matches, index + 1);
return {
status: 500,
boundary: index,
kind: ERROR2
};
}
const boundary = indexed[2] ?? await getNotFoundBoundary2(router, lane.matches, indexed, signal);
const match = lane.matches[boundary];
const cause = outcome[1];
cause.routeId = match.routeId;
match._notFound = void 0;
if (match.routeId === router.routeTree.id) {
match.status = "success";
match._notFound = true;
match.error = cause;
} else {
match.status = "notFound";
match.error = cause;
}
match.isFetching = false;
abortMatches(lane.matches, boundary + 1);
return {
status: 404,
boundary,
kind: NOT_FOUND2
};
}
async function loadNormalChunks(router, lane, end, signal) {
const chunks = [];
for (let index = 0; index < lane.matches.length; index++) {
const match = lane.matches[index];
if (index >= end || match.ssr !== true || match.status !== "success") continue;
const route = getRoute2(router, match);
try {
const loading = loadRouteChunk(route);
if (loading) {
const chunk = loading.then(() => {
signal == null ? void 0 : signal.throwIfAborted();
}, (cause) => {
signal == null ? void 0 : signal.throwIfAborted();
return [index, stampNotFound(match, normalizeError2(router, lane, route, cause, signal))];
});
chunk.catch(() => {
});
chunks.push(chunk);
}
} catch (cause) {
signal == null ? void 0 : signal.throwIfAborted();
chunks.push([index, stampNotFound(match, normalizeError2(router, lane, route, cause, signal))]);
}
}
for (const chunk of chunks) {
const indexed = Array.isArray(chunk) ? chunk : await chunk;
if (indexed) return indexed;
}
}
async function projectLane2(router, lane, signal) {
var _a, _b, _c;
for (const match of lane.matches) {
const routeOptions = getRoute2(router, match).options;
if (routeOptions.head || routeOptions.scripts || routeOptions.headers) {
const context = {
ssr: router.options.ssr,
matches: lane.matches,
match,
params: match.params,
loaderData: match.loaderData
};
try {
const [head, scripts, headers] = await Promise.all([
(_a = routeOptions.head) == null ? void 0 : _a.call(routeOptions, context),
(_b = routeOptions.scripts) == null ? void 0 : _b.call(routeOptions, context),
(_c = routeOptions.headers) == null ? void 0 : _c.call(routeOptions, context)
]);
signal == null ? void 0 : signal.throwIfAborted();
match.meta = head == null ? void 0 : head.meta;
match.links = head == null ? void 0 : head.links;
match.headScripts = head == null ? void 0 : head.scripts;
match.styles = head == null ? void 0 : head.styles;
match.scripts = scripts;
match.headers = headers;
} catch (cause) {
signal == null ? void 0 : signal.throwIfAborted();
console.error(cause);
}
}
if (match.ssr === false || match.status !== "success" || match._notFound) break;
}
}
async function executeServerLane(router, location, matchedMatches, signal) {
var _a, _b, _c, _d;
const matched = {
location,
matches: matchedMatches.map((match) => ({
...match,
__beforeLoadContext: void 0,
context: {},
isFetching: false,
abortController: new AbortController()
}))
};
const abortLane = () => abortMatches(matched.matches, 0, (signal == null ? void 0 : signal.reason) ?? MATCH_SETTLED_ABORT_REASON);
if (signal == null ? void 0 : signal.aborted) {
abortLane();
signal.throwIfAborted();
}
signal == null ? void 0 : signal.addEventListener("abort", abortLane, { once: true });
try {
const plannedGlobalBoundary = matched.matches.findIndex((match) => match._notFound);
if (router.options.notFoundMode !== "root" && plannedGlobalBoundary >= 0) {
const boundary = await getNotFoundBoundary2(router, matched.matches, void 0, signal, plannedGlobalBoundary);
if (boundary !== plannedGlobalBoundary) {
matched.matches[plannedGlobalBoundary]._notFound = void 0;
matched.matches[boundary]._notFound = true;
}
}
const lane = await contextualize2(router, matched, signal);
signal == null ? void 0 : signal.throwIfAborted();
let loaderEnd = lane.end;
if (((_a = lane.failure) == null ? void 0 : _a[1][0]) === REDIRECTED2) loaderEnd = 0;
else if (((_b = lane.failure) == null ? void 0 : _b[1][0]) === NOT_FOUND2) {
lane.failure[2] = await getNotFoundBoundary2(router, lane.matches, lane.failure, signal);
loaderEnd = Math.min(loaderEnd, lane.failure[2] + 1);
}
const tasks = [];
for (let index = 0; index < loaderEnd; index++) {
const task = createLoaderTask2(router, lane, index, tasks, signal);
tasks.push(task);
}
let loaderFailure;
let control = ((_c = lane.failure) == null ? void 0 : _c[1][0]) === REDIRECTED2 ? lane.failure : void 0;
try {
await Promise.all(tasks.map((task) => task.outcome.then((loadedOutcome) => {
const match = lane.matches[task.index];
const outcome = loadedOutcome;
if (outcome[0] === SUCCESS2) {
match.loaderData = outcome[1];
match.status = "success";
match.error = void 0;
match.invalid = false;
match.isFetching = false;
match.updatedAt = Date.now();
} else if (outcome[0] === REDIRECTED2) {
control = [task.index, outcome];
throw control;
} else {
if (match.ssr !== false) {
match.status = "success";
match.error = void 0;
match.invalid = true;
match.isFetching = false;
}
if (!loaderFailure && outcome[0] !== SKIPPED) loaderFailure = [task.index, outcome];
}
})));
} catch (cause) {
if (!Array.isArray(cause)) throw cause;
control = cause;
}
signal == null ? void 0 : signal.throwIfAborted();
if ((control == null ? void 0 : control[1][0]) === REDIRECTED2) {
abortMatches(lane.matches, 0, REDIRECT_ABORT_REASON);
return {
type: "redirect",
redirect: control[1][1]
};
}
let failure = lane.failure ?? loaderFailure;
const plannedBoundary = lane.matches.findIndex((match) => match._notFound);
let readinessEnd;
if (failure) {
const outcomeEnd = failure[2] ?? (failure[2] = failure[1][0] === NOT_FOUND2 ? await getNotFoundBoundary2(router, lane.matches, failure, signal) : failure[0]);
for (const task of tasks) {
if (task.index >= outcomeEnd) break;
const outcome = await task.outcome;
if (outcome[0] !== SUCCESS2 && outcome[0] < REDIRECTED2 && !("loaderData" in lane.matches[task.index])) {
failure = [task.index, outcome];
failure[2] = outcome[0] === NOT_FOUND2 ? await getNotFoundBoundary2(router, lane.matches, failure, signal) : task.index;
break;
}
}
readinessEnd = failure[2];
} else readinessEnd = plannedBoundary < 0 ? lane.matches.length : plannedBoundary;
const requiredFailure = await loadNormalChunks(router, lane, readinessEnd, signal);
signal == null ? void 0 : signal.throwIfAborted();
if (requiredFailure) {
if (requiredFailure[1][0] === REDIRECTED2) {
abortMatches(lane.matches, 0, REDIRECT_ABORT_REASON);
return {
type: "redirect",
redirect: requiredFailure[1][1]
};
}
failure = requiredFailure;
}
const terminal = await applyFailure(router, lane, failure, signal);
if (terminal.boundary !== void 0) {
const match = lane.matches[terminal.boundary];
if (match.ssr === true) {
const route = getRoute2(router, match);
try {
if (terminal.kind === ERROR2) await loadRouteChunk(route, "errorComponent");
else if (match._notFound) await Promise.all([loadRouteChunk(route), loadRouteChunk(route, "notFoundComponent")]);
else await loadRouteChunk(route, "notFoundComponent");
} catch {
}
signal == null ? void 0 : signal.throwIfAborted();
}
}
signal == null ? void 0 : signal.throwIfAborted();
await projectLane2(router, {
location: lane.location,
matches: lane.matches
}, signal);
signal == null ? void 0 : signal.throwIfAborted();
(_d = router.serverSsr) == null ? void 0 : _d.onCleanup((settled) => {
if (!settled) abortLane();
});
return {
type: "render",
status: terminal.status,
matches: lane.matches
};
} finally {
signal == null ? void 0 : signal.removeEventListener("abort", abortLane);
}
}
async function loadServerRoute(router, opts) {
var _a, _b, _c, _d;
router.updateLatestLocation();
const next = router.latestLocation;
const previous = router._committed;
const previousEnd = router._lifecycleEnd;
let result;
try {
const canonical = router.buildLocation({
to: next.pathname,
search: true,
params: true,
hash: true,
state: true,
_includeValidateSearch: true
});
if (next.publicHref !== canonical.publicHref) throw redirect({ href: canonical.publicHref || "/" });
const changeInfo = getLocationChangeInfo(next, router.stores.resolvedLocation.get());
router.emit({
type: "onBeforeNavigate",
...changeInfo
});
router.emit({
type: "onBeforeLoad",
...changeInfo
});
(_a = opts == null ? void 0 : opts._signal) == null ? void 0 : _a.throwIfAborted();
result = await waitFor2(executeServerLane(router, next, router.matchRoutes(next), opts == null ? void 0 : opts._signal), opts == null ? void 0 : opts._signal);
(_b = opts == null ? void 0 : opts._signal) == null ? void 0 : _b.throwIfAborted();
} catch (cause) {
(_c = opts == null ? void 0 : opts._signal) == null ? void 0 : _c.throwIfAborted();
if (!isRedirect(cause)) throw cause;
cause.options._fromLocation = next;
result = {
type: "redirect",
redirect: router.resolveRedirect(cause)
};
}
router._serverResult = result;
let nextEnd = 0;
router.batch(() => {
router.stores.location.set(next);
router.stores.status.set("idle");
if (result.type === "render") {
router._committed = result.matches;
nextEnd = router._lifecycleEnd = lifecycleEnd(result.matches);
router.stores.setMatches(result.matches);
router.stores.resolvedLocation.set(next);
}
});
if (result.type === "render") runRouteLifecycle(router, previous, result.matches, previousEnd, nextEnd);
(_d = router._commitPromise) == null ? void 0 : _d.resolve();
router._commitPromise = void 0;
}
// node_modules/@tanstack/router-core/dist/esm/isServer/development.js
var isServer = void 0;
// node_modules/@tanstack/react-router/dist/esm/utils.js
var reactUse = React$1["use"];
var useLayoutEffect2 = isServer ?? typeof window === "undefined" ? React$1.useEffect : React$1.useLayoutEffect;
// node_modules/@tanstack/router-core/dist/esm/defer.js
var TSR_DEFERRED_PROMISE = 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 == null ? void 0 : options.serializeError) ?? defaultSerializeError)(error),
__isServerError: true
};
});
return promise;
}
// node_modules/@tanstack/router-core/dist/esm/link.js
var preloadWarning = "Error preloading route! ☝️";
// node_modules/@tanstack/router-core/dist/esm/manifest.js
var DEV_STYLES_ATTR = "data-tanstack-router-dev-styles";
function getAssetCrossOrigin(assetCrossOrigin, kind) {
if (!assetCrossOrigin) return;
if (typeof assetCrossOrigin === "string") return assetCrossOrigin;
return assetCrossOrigin[kind];
}
function getManifestScriptFormat(manifest) {
return (manifest == null ? void 0 : manifest.scriptFormat) ?? "module";
}
function getScriptPreloadAttrs(manifest, link2, assetCrossOrigin) {
const preloadLink2 = resolveManifestAssetLink(link2);
const crossOrigin = getAssetCrossOrigin(assetCrossOrigin, "script") ?? preloadLink2.crossOrigin;
return {
...getManifestScriptFormat(manifest) === "iife" ? {
rel: "preload",
as: "script"
} : { rel: "modulepreload" },
href: preloadLink2.href,
...crossOrigin ? { crossOrigin } : {}
};
}
function resolveManifestAssetLink(link2) {
if (typeof link2 === "string") return {
href: link2,
crossOrigin: void 0
};
return link2;
}
function appendUniqueUserTags(target, tags) {
if (tags.length === 0) return;
if (tags.length === 1) {
target.push(tags[0]);
return;
}
const seen = /* @__PURE__ */ new Set();
for (const tag of tags) {
const key = JSON.stringify(tag);
if (seen.has(key)) continue;
seen.add(key);
target.push(tag);
}
}
function resolveManifestCssLink(link2) {
if (typeof link2 === "string") return {
href: link2,
crossOrigin: void 0
};
return link2;
}
// 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/@tanstack/router-core/dist/esm/ssr/bodyScripts.js
function getSsrBodyScriptParts(matches, manifest, nonce, routeScriptAttrs2) {
var _a;
const assetMatches = _getAssetMatches(matches);
const routeScripts = [];
const manifestScripts = [];
for (const match of assetMatches) for (const script of Array.isArray(match.scripts) ? match.scripts : []) {
if (!script) continue;
const { children, ...attrs } = script;
routeScripts.push({
tag: "script",
attrs: {
...attrs,
...routeScriptAttrs2,
nonce
},
children
});
}
if (manifest) for (const match of assetMatches) for (const asset of ((_a = manifest.routes[match.routeId]) == null ? void 0 : _a.scripts) ?? []) manifestScripts.push({
tag: "script",
attrs: {
...asset.attrs,
nonce
},
children: asset.children
});
return [routeScripts, manifestScripts];
}
function composeSsrBodyScripts([routeScripts, manifestScripts], initialHydrationScripts) {
if (!initialHydrationScripts) return [...routeScripts, ...manifestScripts];
return [
...initialHydrationScripts.before,
...routeScripts,
...manifestScripts,
initialHydrationScripts.boundary
];
}
// node_modules/@tanstack/router-core/dist/esm/route.js
var BaseRoute = class {
get to() {
return this._to;
}
get id() {
return this._id;
}
get path() {
return this._path;
}
get fullPath() {
return this._fullPath;
}
constructor(options) {
this.init = (originalIndex) => {
var _a, _b;
this.originalIndex = originalIndex;
this._branch = void 0;
const options2 = this.options;
const isRoot = !(options2 == null ? void 0 : options2.path) && !(options2 == null ? void 0 : options2.id);
this.parentRoute = (_b = (_a = this.options).getParentRoute) == null ? void 0 : _b.call(_a);
if (isRoot) this._path = rootRouteId;
else if (!this.parentRoute) {
if (true) throw new Error(`Invariant failed: Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`);
invariant();
}
let path = isRoot ? rootRouteId : options2 == null ? void 0 : options2.path;
if (path && path !== "/") path = trimPathLeft(path);
const customId = (options2 == null ? void 0 : options2.id) || path;
const id = isRoot ? rootRouteId : cleanPath((this.parentRoute.id === "__root__" ? "" : this.parentRoute.id) + "/" + (customId ?? ""));
if (path === "__root__") path = "/";
const fullPath = id === "__root__" ? "/" : path === void 0 ? this.parentRoute.fullPath : cleanPath(this.parentRoute.fullPath + "/" + path);
this._path = path;
this._id = id;
this._fullPath = fullPath;
this._to = trimPathRight(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 == null ? void 0 : options.getParentRoute);
if ((options == null ? void 0 : options.id) && (options == null ? void 0 : options.path)) throw new Error(`Route cannot have both an 'id' and a 'path' option.`);
}
};
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/@tanstack/router-core/dist/esm/config.js
var createRouterConfig = (options) => {
return {
serializationAdapters: options.serializationAdapters,
defaultSsr: options.defaultSsr
};
};
// node_modules/@tanstack/router-core/dist/esm/searchMiddleware.js
function retainSearchParams(keys) {
return ({ search, next }) => {
var _a, _b, _c, _d, _e, _f;
const { search: resultSearch, meta } = next(search, true);
if (keys === true) {
const copy2 = {
...search,
...resultSearch
};
const removed = meta.removed;
const explicit2 = meta.explicit;
for (const key of (removed == null ? void 0 : removed.keys()) || []) if (explicit2 && hasOwn.call(explicit2, key) || deepEqual(search[key], removed.get(key))) delete copy2[key];
for (const key of meta.removedAny || []) delete copy2[key];
for (const key of ((_a = meta.defaulted) == null ? void 0 : _a.keys()) || []) if (key in search && !((_b = meta.removedAny) == null ? void 0 : _b.has(key)) && !(((_c = meta.removed) == null ? void 0 : _c.has(key)) && (explicit2 && hasOwn.call(explicit2, key) || deepEqual(search[key], meta.removed.get(key))))) copy2[key] = search[key];
return copy2;
}
const copy = { ...resultSearch };
const explicit = meta.explicit;
for (const key of keys) {
const stringKey = key;
if (!(((_d = meta.removedAny) == null ? void 0 : _d.has(stringKey)) || ((_e = meta.removed) == null ? void 0 : _e.has(stringKey)) && (explicit && hasOwn.call(explicit, stringKey) || deepEqual(search[key], meta.removed.get(stringKey)))) && (!(key in copy) || key in search && ((_f = meta.defaulted) == null ? void 0 : _f.has(stringKey)) && deepEqual(copy[key], meta.defaulted.get(stringKey)))) copy[key] = search[key];
}
return copy;
};
}
function stripSearchParams(input) {
return (({ search, next, meta }) => {
if (input === true) {
Object.keys(search).forEach((key) => {
if (meta) (meta.removedAny || (meta.removedAny = /* @__PURE__ */ new Set())).add(key);
});
return {};
}
const result = { ...next(search) };
if (Array.isArray(input)) input.forEach((key) => {
delete result[key];
if (meta) (meta.removedAny || (meta.removedAny = /* @__PURE__ */ new Set())).add(key);
});
else Object.entries(input).forEach(([key, value]) => {
if (deepEqual(result[key], value)) {
delete result[key];
if (meta) (meta.removed || (meta.removed = /* @__PURE__ */ new Map())).set(key, value);
}
});
return result;
});
}
// node_modules/@tanstack/router-core/dist/esm/ssr/serializer/transformer.js
function createSerializationAdapter(opts) {
if (true) {
if (!opts.key || /[\0"\\<\b\t\f\r\n\u2028\u2029\uD800-\uDFFF]/.test(opts.key)) throw new Error(`createSerializationAdapter: key ${JSON.stringify(opts.key)} is invalid. Serialization adapter keys must be non-empty and not contain NUL, ", \\, <, backspace, tab, form feed, line terminators, or UTF-16 surrogate code units.`);
}
return opts;
}
// node_modules/seroval/dist/dev/index.js
var Feature = (function(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";
Feature2[Feature2["Temporal"] = 64] = "Temporal";
return Feature2;
})({});
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
};
var CONSTANT_VAL = {
[2]: true,
[3]: false,
[1]: void 0,
[0]: null,
[4]: -0,
[5]: Number.POSITIVE_INFINITY,
[6]: Number.NEGATIVE_INFINITY,
[7]: 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, void 0, value, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0);
}
var TRUE_NODE = createConstantNode(2);
var FALSE_NODE = createConstantNode(3);
var UNDEFINED_NODE = createConstantNode(1);
var NULL_NODE = createConstantNode(0);
var NEG_ZERO_NODE = createConstantNode(4);
var INFINITY_NODE = createConstantNode(5);
var NEG_INFINITY_NODE = createConstantNode(6);
var NAN_NODE = createConstantNode(7);
var { toString: objectToString } = Object.prototype;
var REFERENCES_KEY = "__SEROVAL_REFS__";
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 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 internal = {
flush(value, mode, x) {
for (x = 0; x < count; x++) {
const listener = listeners[x];
if (listener) listener[mode](value);
}
},
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);
}
},
on(listener, temp = 0) {
let subscribed = alive;
if (alive) {
for (temp = 0; temp < count; temp++) if (!listeners[temp]) break;
if (temp === count) count++;
listeners[temp] = listener;
}
internal.up(listener);
return () => {
if (alive && subscribed) {
subscribed = false;
listeners[temp] = void 0;
while (count > 0 && !listeners[count - 1]) count--;
listeners.length = count;
}
};
}
};
return {
__SEROVAL_STREAM__: true,
on(listener) {
return internal.on(listener);
},
next(value) {
if (alive) {
buffer.push(value);
internal.flush(value, "next");
}
},
throw(value) {
if (alive) {
buffer.push(value);
internal.flush(value, "throw");
alive = false;
success = false;
listeners.length = 0;
}
},
return(value) {
if (alive) {
buffer.push(value);
internal.flush(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]() {
return 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 internal = { 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);
internal.finalize();
doneAt = buffer.length;
isThrow = true;
buffer.push(value);
},
return(value) {
const temp = pending.shift();
if (temp) temp.s({
done: true,
value
});
internal.finalize();
doneAt = buffer.length;
buffer.push(value);
}
});
const instance = {
[symbol]() {
return 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);
var createAsyncIterable = ASYNC_ITERATOR_CONSTRUCTOR(SYM_ASYNC_ITERATOR, PROMISE_CONSTRUCTOR);
var SerovalMode = (function(SerovalMode2) {
SerovalMode2[SerovalMode2["Vanilla"] = 1] = "Vanilla";
SerovalMode2[SerovalMode2["Cross"] = 2] = "Cross";
return SerovalMode2;
})({});
var RETURN = () => T;
var SERIALIZED_RETURN = RETURN.toString();
var IS_MODERN = /=>/.test(SERIALIZED_RETURN);
// node_modules/@tanstack/react-router/dist/esm/awaited.js
var React$12 = __toESM(require_react(), 1);
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
function useAwaited({ promise: _promise }) {
if (reactUse) return reactUse(_promise);
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)(React$12.Suspense, {
fallback: props.fallback,
children: inner
});
return inner;
}
function AwaitInner(props) {
const data = useAwaited(props);
return props.children(data);
}
// node_modules/@tanstack/react-router/dist/esm/nonRouteComponentContext.js
var React$13 = __toESM(require_react(), 1);
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
var nonRouteComponentContext = true ? React$13.createContext(void 0) : void 0;
function wrapInNonRouteComponentContext(element, component) {
return (0, import_jsx_runtime2.jsx)(nonRouteComponentContext.Provider, {
value: component,
children: element
});
}
// node_modules/@tanstack/react-router/dist/esm/CatchBoundary.js
var React$14 = __toESM(require_react(), 1);
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
var CatchBoundary = class extends React$14.Component {
constructor(..._args) {
super(..._args);
this.state = { error: 0 };
this.reset = () => {
this.setState({ error: 0 });
};
}
static getDerivedStateFromProps(props, state) {
const resetKey = props.getResetKey();
if (state.error && state.resetKey !== resetKey) return {
resetKey,
error: 0
};
return { resetKey };
}
static getDerivedStateFromError(error) {
return { error: [error] };
}
componentDidCatch(error, errorInfo) {
var _a, _b;
(_b = (_a = this.props).onCatch) == null ? void 0 : _b.call(_a, error, errorInfo);
}
render() {
const error = this.state.error;
if (error) {
const element = React$14.createElement(this.props.errorComponent ?? ErrorComponent, {
error: error[0],
reset: this.reset
});
return true ? wrapInNonRouteComponentContext(element, "errorComponent") : element;
}
return this.props.children;
}
};
function ErrorComponent({ error }) {
const [show, setShow] = React$14.useState(true);
return (0, import_jsx_runtime3.jsxs)("div", {
style: {
padding: ".5rem",
maxWidth: "100%"
},
children: [
(0, import_jsx_runtime3.jsxs)("div", {
style: {
display: "flex",
alignItems: "center",
gap: ".5rem"
},
children: [(0, import_jsx_runtime3.jsx)("strong", {
style: { fontSize: "1rem" },
children: "Something went wrong!"
}), (0, import_jsx_runtime3.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_runtime3.jsx)("div", { style: { height: ".25rem" } }),
show ? (0, import_jsx_runtime3.jsx)("div", { children: (0, import_jsx_runtime3.jsx)("pre", {
style: {
fontSize: ".7em",
border: "1px solid red",
borderRadius: ".25rem",
padding: ".3rem",
color: "red",
overflow: "auto"
},
children: (error == null ? void 0 : error.message) ? (0, import_jsx_runtime3.jsx)("code", { children: error.message }) : null
}) }) : null
]
});
}
// node_modules/@tanstack/react-router/dist/esm/ClientOnly.js
var import_react = __toESM(require_react(), 1);
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
var getSnapshot = () => true;
var getServerSnapshot = () => false;
function ClientOnly({ children, fallback = null }) {
return (0, import_jsx_runtime4.jsx)(import_react.default.Fragment, { children: useHydrated() ? children : fallback });
}
function useHydrated() {
return import_react.default.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
}
function subscribe() {
return () => {
};
}
// node_modules/@tanstack/react-router/dist/esm/routerContext.js
var React$15 = __toESM(require_react(), 1);
var routerContext = React$15.createContext(null);
// node_modules/@tanstack/react-router/dist/esm/useRouter.js
var React$16 = __toESM(require_react(), 1);
function useRouter(opts) {
const value = React$16.useContext(routerContext);
if (!value) warnMissingRouter(opts);
return value;
}
function warnMissingRouter(opts) {
if ((opts == null ? void 0 : opts.warn) ?? true) console.warn("Warning: useRouter must be used inside a <RouterProvider> component!");
}
// node_modules/@tanstack/react-router/dist/esm/matchContext.js
var React$17 = __toESM(require_react(), 1);
var matchContext = React$17.createContext(void 0);
var dummyMatchContext = React$17.createContext(void 0);
// node_modules/@tanstack/react-router/dist/esm/useMatch.js
var React$18 = __toESM(require_react(), 1);
// node_modules/@tanstack/react-store/dist/createStoreContext.js
var import_react2 = __toESM(require_react(), 1);
var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
// node_modules/@tanstack/store/dist/alien.js
function createReactiveSystem({ update, notify, unwatched }) {
return {
link: link2,
unlink: unlink2,
propagate: propagate2,
checkDirty: checkDirty2,
shallowPropagate: shallowPropagate2
};
function link2(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 unlink2(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 propagate2(link3) {
let next = link3.nextSub;
let stack;
top: do {
const sub = link3.sub;
let flags = sub.flags;
if (!(flags & 60)) sub.flags = flags | 32;
else if (!(flags & (4 | 8))) flags = 0;
else if (!(flags & 4)) sub.flags = flags & ~8 | 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 checkDirty2(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) shallowPropagate2(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) shallowPropagate2(firstSub);
sub = link3.sub;
continue;
}
dirty = false;
} else sub.flags &= ~32;
sub = link3.sub;
const nextDep = link3.nextDep;
if (nextDep !== void 0) {
link3 = nextDep;
continue top;
}
}
return dirty;
} while (true);
}
function shallowPropagate2(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;
}
}
// node_modules/@tanstack/store/dist/atom.js
function toObserver(nextHandler, errorHandler, completionHandler) {
var _a, _b, _c;
const isObserver = typeof nextHandler === "object";
const self2 = isObserver ? nextHandler : void 0;
return {
next: (_a = isObserver ? nextHandler.next : nextHandler) == null ? void 0 : _a.bind(self2),
error: (_b = isObserver ? nextHandler.error : errorHandler) == null ? void 0 : _b.bind(self2),
complete: (_c = isObserver ? nextHandler.complete : completionHandler) == null ? void 0 : _c.bind(self2)
};
}
var queuedEffects = [];
var cycle = 0;
var { link, unlink, propagate, checkDirty, shallowPropagate } = createReactiveSystem({
update(atom) {
return atom._update();
},
notify(effect2) {
queuedEffects[queuedEffectsLength++] = effect2;
effect2.flags &= ~2;
},
unwatched(atom) {
if (atom.depsTail !== void 0) {
atom.depsTail = void 0;
atom.flags = 1 | 16;
purgeDeps(atom);
}
}
});
var notifyIndex = 0;
var queuedEffectsLength = 0;
var activeSub;
var batchDepth = 0;
function batch(fn) {
try {
++batchDepth;
fn();
} finally {
if (!--batchDepth) flush();
}
}
function purgeDeps(sub) {
const depsTail = sub.depsTail;
let dep = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
while (dep !== void 0) dep = unlink(dep, sub);
}
function flush() {
if (batchDepth > 0) return;
while (notifyIndex < queuedEffectsLength) {
const effect2 = queuedEffects[notifyIndex];
queuedEffects[notifyIndex++] = void 0;
effect2.notify();
}
notifyIndex = 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 ? 0 : 1,
get() {
if (activeSub !== void 0) link(atom, activeSub, cycle);
return atom._snapshot;
},
subscribe(observerOrFn) {
const obs = toObserver(observerOrFn);
const observed = { current: false };
const e = effect(() => {
var _a;
atom.get();
if (!observed.current) observed.current = true;
else (_a = obs.next) == null ? void 0 : _a.call(obs, atom._snapshot);
});
return { unsubscribe: () => {
e.stop();
} };
},
_update(getValue) {
const prevSub = activeSub;
const compare = (options == null ? void 0 : options.compare) ?? Object.is;
if (isComputed) {
activeSub = atom;
++cycle;
atom.depsTail = void 0;
} else if (getValue === void 0) return false;
if (isComputed) atom.flags = 1 | 4;
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 &= ~4;
purgeDeps(atom);
}
}
};
if (isComputed) {
atom.flags = 1 | 16;
atom.get = function() {
const flags = atom.flags;
if (flags & 16 || flags & 32 && checkDirty(atom.deps, atom)) {
if (atom._update()) {
const subs = atom.subs;
if (subs !== void 0) shallowPropagate(subs);
}
} else if (flags & 32) atom.flags = flags & ~32;
if (activeSub !== void 0) link(atom, activeSub, cycle);
return atom._snapshot;
};
} else atom.set = function(valueOrFn2) {
if (atom._update(valueOrFn2)) {
const subs = atom.subs;
if (subs !== void 0) {
propagate(subs);
shallowPropagate(subs);
flush();
}
}
};
return atom;
}
function effect(fn) {
const run = () => {
const prevSub = activeSub;
activeSub = effectObj;
++cycle;
effectObj.depsTail = void 0;
effectObj.flags = 2 | 4;
try {
return fn();
} finally {
activeSub = prevSub;
effectObj.flags &= ~4;
purgeDeps(effectObj);
}
};
const effectObj = {
deps: void 0,
depsTail: void 0,
subs: void 0,
subsTail: void 0,
flags: 2 | 4,
notify() {
const flags = this.flags;
if (flags & 16 || flags & 32 && checkDirty(this.deps, this)) run();
else this.flags = 2;
},
stop() {
this.flags = 0;
this.depsTail = void 0;
purgeDeps(this);
}
};
run();
return effectObj;
}
// node_modules/@tanstack/react-store/dist/useCreateAtom.js
var import_react3 = __toESM(require_react(), 1);
// node_modules/@tanstack/react-store/dist/useCreateStore.js
var import_react4 = __toESM(require_react(), 1);
// node_modules/@tanstack/react-store/dist/useSelector.js
var import_react5 = __toESM(require_react(), 1);
var import_with_selector = __toESM(require_with_selector(), 1);
function defaultCompare(a, b) {
return a === b;
}
function useSelector(source, selector = (s) => s, options) {
const compare = (options == null ? void 0 : options.compare) ?? defaultCompare;
const subscribe2 = (0, import_react5.useCallback)((handleStoreChange) => {
const { unsubscribe } = source.subscribe(handleStoreChange);
return unsubscribe;
}, [source]);
const getSnapshot2 = (0, import_react5.useCallback)(() => source.get(), [source]);
return (0, import_with_selector.useSyncExternalStoreWithSelector)(subscribe2, getSnapshot2, getSnapshot2, selector, compare);
}
// node_modules/@tanstack/react-store/dist/_useStore.js
var import_react6 = __toESM(require_react(), 1);
// node_modules/@tanstack/react-router/dist/esm/useMatch.js
var dummyMatch = {};
function useStructuralSharing(opts, router) {
const previousResult = React$18.useRef();
return (slice) => {
const selected = (opts == null ? void 0 : opts.select) ? opts.select(slice) : slice;
if ((opts == null ? void 0 : opts.structuralSharing) ?? router.options.defaultStructuralSharing) return previousResult.current = replaceEqualDeep(previousResult.current, selected);
return selected;
};
}
function useMatch(opts) {
const router = useRouter();
const nearestRouteId = React$18.useContext(opts.from ? dummyMatchContext : matchContext);
const routeId = opts.from ?? nearestRouteId;
const matchStore = router.stores.getMatchStore(routeId);
if (isServer ?? router.isServer) {
const match = matchStore.get();
if (!match) {
if (opts.shouldThrow ?? true) {
if (true) throw new Error(`Invariant failed: Could not find ${opts.from ? `an active match from "${opts.from}"` : "a nearest match!"}`);
invariant();
}
return;
}
return opts.select ? opts.select(match) : match;
}
const selector = useStructuralSharing(opts, router);
const matchSelection = useSelector(matchStore, (match) => match ? selector(match) : dummyMatch);
if (matchSelection !== dummyMatch) return matchSelection;
if (opts.shouldThrow ?? true) {
if (true) throw new Error(`Invariant failed: Could not find ${opts.from ? `an active match from "${opts.from}"` : "a nearest match!"}`);
invariant();
}
}
// node_modules/@tanstack/react-router/dist/esm/useLoaderData.js
function useLoaderData(opts) {
return useMatch({
from: opts.from,
strict: opts.strict,
structuralSharing: opts.structuralSharing,
select: (match) => {
return opts.select ? opts.select(match.loaderData) : match.loaderData;
}
});
}
// node_modules/@tanstack/react-router/dist/esm/useLoaderDeps.js
function useLoaderDeps(opts) {
const { select, ...rest } = opts;
return useMatch({
...rest,
select: (match) => {
return select ? select(match.loaderDeps) : match.loaderDeps;
}
});
}
// 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/@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/@tanstack/react-router/dist/esm/useNavigate.js
var React$19 = __toESM(require_react(), 1);
function useNavigate(_defaultOpts) {
const router = useRouter();
return React$19.useCallback((options) => {
return router.navigate({
...options,
from: options.from ?? (_defaultOpts == null ? void 0 : _defaultOpts.from)
});
}, [_defaultOpts == null ? void 0 : _defaultOpts.from, router]);
}
function Navigate(props) {
const router = useRouter();
const navigate = useNavigate();
const previousPropsRef = React$19.useRef(null);
useLayoutEffect2(() => {
if (previousPropsRef.current !== props) {
navigate(props);
previousPropsRef.current = props;
}
}, [
router,
props,
navigate
]);
return null;
}
// 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/@tanstack/react-router/dist/esm/link.js
var React$110 = __toESM(require_react(), 1);
var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
function useStableValues(...values) {
const ref = React$110.useRef(values);
const stable = ref.current;
values.forEach((value, index) => {
if (!deepEqual(stable[index], value, false, true)) stable[index] = value;
});
return ref.current;
}
function preloadLink(router, options) {
router.preloadRoute(options).catch((err) => {
console.warn(err);
console.warn(preloadWarning);
});
}
var LINK_SELECTOR_OPTIONS = { compare: (a, b) => a[0] === b[0] && a[1] === b[1] };
function resolveExternalLink(to, protocolAllowlist) {
const scheme = typeof to === "string" && getUrlScheme(to);
if (!scheme) return;
if (!protocolAllowlist.has(scheme)) {
if (true) console.warn(`Blocked Link with dangerous protocol: ${to}`);
return null;
}
return to;
}
function resolveIsActive(location, next, activeOptions, basepath, isHydrated) {
const currentPath = removeTrailingSlash(location.pathname, basepath);
const nextPath = removeTrailingSlash(next.pathname, basepath);
if ((activeOptions == null ? void 0 : activeOptions.exact) ? currentPath !== nextPath : !(currentPath.startsWith(nextPath) && (currentPath.length === nextPath.length || currentPath[nextPath.length] === "/"))) return false;
if ((activeOptions == null ? void 0 : activeOptions.includeSearch) ?? true) {
if (!deepEqual(location.search, next.search, !(activeOptions == null ? void 0 : activeOptions.exact), activeOptions == null ? void 0 : activeOptions.explicitUndefined)) return false;
}
if (activeOptions == null ? void 0 : activeOptions.includeHash) return isHydrated && location.hash === next.hash;
return true;
}
function useLinkProps(options, forwardedRef, host) {
const router = useRouter();
if (isServer ?? router.isServer) return getServerLinkProps(router, options, forwardedRef, host);
const innerRef = React$110.useRef(null);
const mergedRef = React$110.useCallback((element) => {
innerRef.current = element;
if (typeof forwardedRef === "function") return forwardedRef(element);
if (forwardedRef) forwardedRef.current = element;
}, [forwardedRef]);
const { activeOptions, to, preload: userPreload, preloadDelay: userPreloadDelay, hashScrollIntoView, replace, startTransition: startTransition2, resetScroll, viewTransition, ignoreBlocker, disabled, target, onClick, onBlur, onFocus, onMouseEnter, onMouseLeave, onTouchStart } = options;
const isHydrated = useHydrated();
const [stableSearch, stableParams, stableActiveOptions] = useStableValues(options.search, options.params, activeOptions);
const [_options, dest] = React$110.useMemo(() => [options, { ...options }], [
router,
options.from,
options._fromLocation,
options.hash,
options.to,
stableSearch,
stableParams,
options.state,
options.mask,
options.unsafeRelative
]);
const selectLinkState = React$110.useCallback((location) => {
const directExternalLink = resolveExternalLink(to, router.protocolAllowlist);
if (directExternalLink !== void 0) return [directExternalLink ?? void 0];
if (!_options._fromLocation) dest._fromLocation = location;
const next = router.buildLocation(dest);
const hrefOption = getHrefOption(next, router, disabled);
return [hrefOption, !disabled && (!hrefOption || getUrlScheme(hrefOption)) ? void 0 : resolveIsActive(location, next, stableActiveOptions, router.basepath, isHydrated)];
}, [
stableActiveOptions,
disabled,
isHydrated,
_options,
dest,
router,
to
]);
const [href, isActive] = useSelector(router.stores.location, selectLinkState, LINK_SELECTOR_OPTIONS);
const externalLink = isActive === void 0 ? href : void 0;
const linkDisabled = disabled || href === void 0;
const hasRenderFetched = React$110.useRef(false);
const preload = options.reloadDocument || externalLink || linkDisabled ? false : userPreload ?? router.options.defaultPreload;
const preloadDelay = userPreloadDelay ?? router.options.defaultPreloadDelay ?? 0;
const enqueuePreload = React$110.useCallback((e) => {
const isIntersecting = e == null ? void 0 : e.isIntersecting;
if (!(isIntersecting ?? preload === "intent")) {
if (isIntersecting === false) cancelPreload(innerRef);
return;
}
if (!preloadDelay) {
preloadLink(router, _options);
return;
}
if (timeoutMap.has(innerRef)) return;
timeoutMap.set(innerRef, setTimeout(() => {
timeoutMap.delete(innerRef);
preloadLink(router, _options);
}, preloadDelay));
}, [
router,
_options,
innerRef,
preload,
preloadDelay
]);
React$110.useEffect(() => {
if (preload === "render" && !hasRenderFetched.current) {
hasRenderFetched.current = true;
preloadLink(router, _options);
}
let observer;
if (preload === "viewport" && innerRef.current && typeof IntersectionObserver === "function") {
observer = new IntersectionObserver((entries) => enqueuePreload(entries.pop()), { rootMargin: "100px" });
observer.observe(innerRef.current);
}
return () => {
observer == null ? void 0 : observer.disconnect();
cancelPreload(innerRef);
};
}, [
router,
_options,
preload,
enqueuePreload,
innerRef
]);
const props = collectElementProps(options, host);
props.ref = forwardedRef ? mergedRef : innerRef;
if (externalLink) {
props.href = externalLink;
return props;
}
const handleClick = (e) => {
const effectiveTarget = target ?? e.currentTarget.getAttribute("target");
if (!linkDisabled && !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && !e.defaultPrevented && (!effectiveTarget || effectiveTarget === "_self") && e.button === 0) {
e.preventDefault();
router.navigate({
..._options,
replace,
resetScroll,
hashScrollIntoView,
startTransition: startTransition2,
viewTransition,
ignoreBlocker
});
}
};
const handleTouchStart = () => {
if (preload === "intent") preloadLink(router, _options);
};
const handleLeave = () => {
if (preload === "intent") cancelPreload(innerRef);
};
props.onClick = composeHandlers(onClick, handleClick);
props.onBlur = composeHandlers(onBlur, handleLeave);
props.onFocus = composeHandlers(onFocus, enqueuePreload);
props.onMouseEnter = composeHandlers(onMouseEnter, enqueuePreload);
props.onMouseLeave = composeHandlers(onMouseLeave, handleLeave);
props.onTouchStart = composeHandlers(onTouchStart, handleTouchStart);
return applyLinkState(props, options, isActive, href, linkDisabled, host);
}
var STATIC_EMPTY_OBJECT = {};
var STATIC_ACTIVE_OBJECT = { className: "active" };
var ROUTER_OPTION_KEYS = /* @__PURE__ */ new Set([
"to",
"params",
"search",
"hash",
"state",
"mask",
"from",
"unsafeRelative",
"_fromLocation",
"reloadDocument",
"preload",
"preloadDelay",
"preloadIntentProximity",
"hashScrollIntoView",
"replace",
"startTransition",
"resetScroll",
"viewTransition",
"ignoreBlocker",
"activeProps",
"inactiveProps",
"activeOptions",
"_asChild"
]);
function collectElementProps(options, host) {
const props = {};
for (const key in options) {
if (ROUTER_OPTION_KEYS.has(key) || key === "type" && host !== void 0 || key === "disabled" && host === "a") continue;
props[key] = options[key];
}
return props;
}
function applyLinkState(props, options, isActive, href, linkDisabled, host) {
const { activeProps, inactiveProps, className, style, target } = options;
const stateProps = functionalUpdate(isActive ? activeProps : inactiveProps, {}) ?? (isActive ? STATIC_ACTIVE_OBJECT : STATIC_EMPTY_OBJECT);
Object.assign(props, stateProps);
props.href = href;
if (host !== "a") props.disabled = linkDisabled;
props.target = target;
const stateStyle = stateProps.style;
if (style || stateStyle) props.style = style && stateStyle ? {
...style,
...stateStyle
} : style || stateStyle;
const stateClassName = stateProps.className;
if (className || stateClassName) props.className = className ? stateClassName ? `${className} ${stateClassName}` : className : stateClassName;
if (linkDisabled) {
props.role = "link";
props["aria-disabled"] = true;
}
if (isActive) {
props["data-status"] = "active";
props["aria-current"] = "page";
}
return props;
}
function getServerLinkProps(router, options, forwardedRef, host) {
const { to, disabled, activeOptions } = options;
const directExternalLink = resolveExternalLink(to, router.protocolAllowlist);
const next = directExternalLink === void 0 ? router.buildLocation(options) : void 0;
const hrefOption = next ? getHrefOption(next, router, disabled) : directExternalLink ?? void 0;
const linkDisabled = disabled || !hrefOption;
const externalLink = directExternalLink ?? (hrefOption && getUrlScheme(hrefOption) ? hrefOption : void 0);
const props = collectElementProps(options, host);
props.ref = forwardedRef;
if (externalLink) {
props.href = externalLink;
return props;
}
return applyLinkState(props, options, !!next && !(!disabled && !hrefOption) && resolveIsActive(router.stores.location.get(), next, activeOptions, router.basepath, false), hrefOption, linkDisabled, host);
}
var timeoutMap = /* @__PURE__ */ new WeakMap();
var cancelPreload = (eventTarget) => {
clearTimeout(timeoutMap.get(eventTarget));
timeoutMap.delete(eventTarget);
};
var composeHandlers = (first, second) => {
if (!first) return second;
return (event) => event.defaultPrevented || (first(event), event.defaultPrevented || second(event));
};
function getHrefOption(next, router, disabled) {
if (disabled) return;
const location = next.maskedLocation ?? next;
const href = location.external ? location.publicHref : router.history.createHref(location.publicHref) || "/";
if ((location.external || href !== location.publicHref) && isDangerousProtocol(href, router.protocolAllowlist)) {
if (true) console.warn(`Blocked Link with dangerous protocol: ${href}`);
return;
}
return href;
}
function createLink(Comp) {
return React$110.forwardRef(function CreatedLink(props, ref) {
return (0, import_jsx_runtime6.jsx)(Link, {
...props,
_asChild: Comp,
ref
});
});
}
var Link = React$110.memo(React$110.forwardRef((props, ref) => {
const host = props._asChild || "a";
const linkProps = useLinkProps(props, ref, host);
const children = typeof props.children === "function" ? props.children({ isActive: linkProps["data-status"] === "active" }) : props.children;
return React$110.createElement(host, linkProps, children);
}), areLinkPropsEqual);
function areLinkPropsEqual(prev, next) {
let extraKeys = 0;
for (const key in next) {
extraKeys++;
if (prev[key] === next[key]) continue;
if (!ROUTER_OPTION_KEYS.has(key) || !deepEqual(prev[key], next[key], false, true)) return false;
}
for (const _key in prev) extraKeys--;
return extraKeys === 0;
}
var linkOptions = (options) => {
return options;
};
// node_modules/@tanstack/react-router/dist/esm/route.js
var import_react7 = __toESM(require_react(), 1);
var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
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({
...opts,
from: this.id
});
};
this.useRouteContext = (opts) => {
return useRouteContext({
...opts,
from: this.id
});
};
this.useSearch = (opts) => {
return useSearch({
...opts,
from: this.id
});
};
this.useParams = (opts) => {
return useParams({
...opts,
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 = () => {
return useNavigate({ from: useRouter().routesById[this.id].fullPath });
};
this.notFound = (opts) => {
return notFound({
routeId: this.id,
...opts
});
};
this.Link = import_react7.default.forwardRef((props, ref) => {
const fullPath = useRouter().routesById[this.id].fullPath;
return (0, import_jsx_runtime7.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({
...opts,
from: this.id
});
};
this.useRouteContext = (opts) => {
return useRouteContext({
...opts,
from: this.id
});
};
this.useSearch = (opts) => {
return useSearch({
...opts,
from: this.id
});
};
this.useParams = (opts) => {
return useParams({
...opts,
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_react7.default.forwardRef((props, ref) => {
return (0, import_jsx_runtime7.jsx)(Link, {
ref,
from: this.fullPath,
...props
});
});
}
};
function createRoute(options) {
return new Route(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({
...opts,
from: this.id
});
};
this.useRouteContext = (opts) => {
return useRouteContext({
...opts,
from: this.id
});
};
this.useSearch = (opts) => {
return useSearch({
...opts,
from: this.id
});
};
this.useParams = (opts) => {
return useParams({
...opts,
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_react7.default.forwardRef((props, ref) => {
return (0, import_jsx_runtime7.jsx)(Link, {
ref,
from: this.fullPath,
...props
});
});
}
};
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/@tanstack/react-router/dist/esm/fileRoute.js
function createFileRoute(path) {
return (options) => {
const route = createRoute(options);
route.isRoot = false;
return route;
};
}
var FileRoute = class {
constructor(path, _opts) {
this.path = path;
this.createRoute = (options) => {
if (true) {
if (!this.silent) console.warn("Warning: 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 == null ? void 0 : _opts.silent;
}
};
function FileRouteLoader(_path) {
if (true) console.warn(`Warning: FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in 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({
...opts2,
from: this.options.id
});
};
this.useRouteContext = (opts2) => {
return useRouteContext({
...opts2,
from: this.options.id
});
};
this.useSearch = (opts2) => {
return useSearch({
...opts2,
from: this.options.id
});
};
this.useParams = (opts2) => {
return useParams({
...opts2,
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 = () => {
return useNavigate({ from: useRouter().routesById[this.options.id].fullPath });
};
this.options = opts;
}
};
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/@tanstack/react-router/dist/esm/lazyRouteComponent.js
var React$111 = __toESM(require_react(), 1);
function lazyRouteComponent(importer, exportName) {
let loadPromise;
let comp;
let error;
const load = () => {
if (!loadPromise) {
error = void 0;
loadPromise = importer().then((res) => {
if (!(isServer ?? typeof window === "undefined")) {
loadPromise = void 0;
lazyComp.preload = void 0;
}
comp = res[exportName ?? "default"];
}).catch((err) => {
loadPromise = void 0;
error = err;
});
}
return loadPromise;
};
const lazyComp = function Lazy(props) {
if (error) {
if (isModuleNotFoundError(error) && !(isServer ?? typeof window === "undefined") && typeof sessionStorage !== "undefined") {
const storageKey2 = `tanstack_router_reload:${error.message}`;
if (!sessionStorage.getItem(storageKey2)) {
sessionStorage.setItem(storageKey2, "1");
window.location.reload();
throw new Promise(() => {
});
}
}
throw error;
}
if (!comp) if (reactUse) reactUse(load());
else throw load();
return React$111.createElement(comp, props);
};
lazyComp.preload = load;
return lazyComp;
}
// node_modules/@tanstack/react-router/dist/esm/not-found.js
var import_react8 = __toESM(require_react(), 1);
var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
function CatchNotFound(props) {
const router = useRouter();
if (isServer ?? router.isServer) {
const resetKey2 = `not-found-${router.stores.location.get().pathname}-${router.stores.status.get()}`;
return (0, import_jsx_runtime8.jsx)(CatchBoundary, {
getResetKey: () => resetKey2,
onCatch: (error, errorInfo) => {
var _a;
if (isNotFound(error)) (_a = props.onCatch) == null ? void 0 : _a.call(props, error, errorInfo);
else throw error;
},
errorComponent: ({ error }) => {
var _a;
if (isNotFound(error)) return (_a = props.fallback) == null ? void 0 : _a.call(props, error);
else throw error;
},
children: props.children
});
}
const resetKey = `not-found-${useSelector(router.stores.location, (location) => location.pathname)}-${useSelector(router.stores.status)}`;
return (0, import_jsx_runtime8.jsx)(CatchBoundary, {
getResetKey: () => resetKey,
onCatch: (error, errorInfo) => {
var _a;
if (isNotFound(error)) (_a = props.onCatch) == null ? void 0 : _a.call(props, error, errorInfo);
else throw error;
},
errorComponent: ({ error }) => {
var _a;
if (isNotFound(error)) return (_a = props.fallback) == null ? void 0 : _a.call(props, error);
else throw error;
},
children: props.children
});
}
function DefaultGlobalNotFound() {
return (0, import_jsx_runtime8.jsx)("p", { children: "Not Found" });
}
// node_modules/@tanstack/react-router/dist/esm/ScriptOnce.js
var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
function ScriptOnce({ children }) {
var _a;
const router = useRouter();
if (!(isServer ?? router.isServer)) return null;
return (0, import_jsx_runtime9.jsx)("script", {
nonce: (_a = router.options.ssr) == null ? void 0 : _a.nonce,
dangerouslySetInnerHTML: { __html: children + ";document.currentScript.remove()" }
});
}
// node_modules/@tanstack/react-router/dist/esm/SafeFragment.js
var import_react9 = __toESM(require_react(), 1);
var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
function SafeFragment(props) {
return (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: props.children });
}
// node_modules/@tanstack/react-router/dist/esm/renderRouteNotFound.js
var import_react10 = __toESM(require_react(), 1);
var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
function renderRouteNotFound(router, route, data) {
if (!route.options.notFoundComponent) {
if (router.options.defaultNotFoundComponent) {
const notFoundElement2 = (0, import_jsx_runtime11.jsx)(router.options.defaultNotFoundComponent, { ...data });
return true ? wrapInNonRouteComponentContext(notFoundElement2, "notFoundComponent") : notFoundElement2;
}
if (true) {
if (!route.options.notFoundComponent) console.warn(`Warning: 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_runtime11.jsx)(DefaultGlobalNotFound, {});
}
const notFoundElement = (0, import_jsx_runtime11.jsx)(route.options.notFoundComponent, { ...data });
return true ? wrapInNonRouteComponentContext(notFoundElement, "notFoundComponent") : notFoundElement;
}
// node_modules/@tanstack/react-router/dist/esm/scroll-restoration.js
var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
// node_modules/@tanstack/router-core/dist/esm/scroll-restoration-script/client.js
function getScrollRestorationScriptForRouter(_router) {
return null;
}
// node_modules/@tanstack/react-router/dist/esm/scroll-restoration.js
function ScrollRestoration() {
const script = getScrollRestorationScriptForRouter(useRouter());
if (!script) return null;
return (0, import_jsx_runtime12.jsx)(ScriptOnce, { children: script });
}
// node_modules/@tanstack/react-router/dist/esm/Match.js
var React$112 = __toESM(require_react(), 1);
var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
function renderPending(router, route) {
const PendingComponent = (route == null ? void 0 : route.options.pendingComponent) ?? router.options.defaultPendingComponent;
if (!PendingComponent) return null;
const pendingElement = (0, import_jsx_runtime13.jsx)(PendingComponent, {});
return true ? wrapInNonRouteComponentContext(pendingElement, "pendingComponent") : pendingElement;
}
var outletMatchSelectionEqual = (a, b) => a[0] === b[0] && a[1] === b[1];
var canWrapInSuspense = (router, route, ssr) => !route.isRoot || route.options.shellComponent || route.options.wrapInSuspense || ssr === false || ssr === "data-only" || !((isServer ?? router.isServer) || router.ssr);
var Match = React$112.memo(function MatchImpl({ routeId }) {
const router = useRouter();
if (isServer ?? router.isServer) return (0, import_jsx_runtime13.jsx)(MatchView, {
router,
match: router.stores.byRoute.get(routeId).get()
});
return (0, import_jsx_runtime13.jsx)(MatchView, {
router,
match: useSelector(router.stores.getMatchStore(routeId))
});
});
function MatchView({ router, match }) {
var _a, _b, _c;
const route = router.routesById[match.routeId];
const pendingElement = renderPending(router, route);
const routeErrorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent;
const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch;
const routeNotFoundComponent = route.isRoot ? route.options.notFoundComponent ?? ((_a = router.options.notFoundRoute) == null ? void 0 : _a.options.component) : route.options.notFoundComponent;
const resolvedNoSsr = match.ssr === false || match.ssr === "data-only";
const ResolvedSuspenseBoundary = canWrapInSuspense(router, route, match.ssr) && (route.options.wrapInSuspense ?? pendingElement ?? (((_b = route.options.errorComponent) == null ? void 0 : _b.preload) || resolvedNoSsr)) ? React$112.Suspense : SafeFragment;
const ResolvedCatchBoundary = routeErrorComponent ? CatchBoundary : SafeFragment;
const ResolvedNotFoundBoundary = routeNotFoundComponent ? CatchNotFound : SafeFragment;
return (0, import_jsx_runtime13.jsxs)(route.isRoot ? route.options.shellComponent ?? SafeFragment : SafeFragment, { children: [(0, import_jsx_runtime13.jsx)(matchContext.Provider, {
value: match.routeId,
children: (0, import_jsx_runtime13.jsx)(ResolvedSuspenseBoundary, {
fallback: pendingElement,
children: (0, import_jsx_runtime13.jsx)(ResolvedCatchBoundary, {
getResetKey: () => match,
errorComponent: routeErrorComponent,
onCatch: (error, errorInfo) => {
if (isNotFound(error)) {
error.routeId ?? (error.routeId = match.routeId);
throw error;
}
if (true) console.warn(`Warning: Error in route match: ${match.id}`);
routeOnCatch == null ? void 0 : routeOnCatch(error, errorInfo);
},
children: (0, import_jsx_runtime13.jsx)(ResolvedNotFoundBoundary, {
fallback: (error) => {
error.routeId ?? (error.routeId = match.routeId);
if (error.routeId !== match.routeId) throw error;
const notFoundElement = React$112.createElement(routeNotFoundComponent, error);
return true ? wrapInNonRouteComponentContext(notFoundElement, "notFoundComponent") : notFoundElement;
},
children: resolvedNoSsr ? (0, import_jsx_runtime13.jsx)(ClientOnly, {
fallback: pendingElement,
children: (0, import_jsx_runtime13.jsx)(MatchInner, { match })
}) : (0, import_jsx_runtime13.jsx)(MatchInner, { match })
})
})
})
}), (isServer ?? router.isServer) && ((_c = route.parentRoute) == null ? void 0 : _c.id) === rootRouteId && router.options.scrollRestoration ? (0, import_jsx_runtime13.jsx)(ScrollRestoration, {}) : null] });
}
var MatchInner = React$112.memo(function MatchInnerImpl({ match }) {
const router = useRouter();
const routeId = match.routeId;
const route = router.routesById[routeId];
const key = React$112.useMemo(() => {
var _a;
const remountDeps = (_a = route.options.remountDeps ?? router.options.defaultRemountDeps) == null ? void 0 : _a({
routeId,
loaderDeps: match.loaderDeps,
params: match._strictParams,
search: match._strictSearch
});
return remountDeps ? JSON.stringify(remountDeps) : void 0;
}, [
routeId,
match.loaderDeps,
match._strictParams,
match._strictSearch,
route.options.remountDeps,
router.options.defaultRemountDeps
]);
const out = React$112.useMemo(() => {
const Comp = route.options.component ?? router.options.defaultComponent;
return Comp ? (0, import_jsx_runtime13.jsx)(Comp, {}, key) : (0, import_jsx_runtime13.jsx)(Outlet, {});
}, [
key,
route.options.component,
router.options.defaultComponent
]);
if (match.status === "pending") {
if (router.ssr && !canWrapInSuspense(router, route, match.ssr)) return out;
if (router._tx) throw router._tx[5];
return renderPending(router, route);
}
if (match.status === "notFound") return renderRouteNotFound(router, route, match.error);
if (match.status === "error") {
if (isServer ?? router.isServer) {
const errorElement = (0, import_jsx_runtime13.jsx)((route.options.errorComponent ?? router.options.defaultErrorComponent) || ErrorComponent, {
error: match.error,
reset: void 0,
info: { componentStack: "" }
});
return true ? wrapInNonRouteComponentContext(errorElement, "errorComponent") : errorElement;
}
throw match.error;
}
return out;
});
var Outlet = React$112.memo(function OutletImpl() {
var _a;
if (true) {
const nonRouteComponent = React$112.useContext(nonRouteComponentContext);
if (nonRouteComponent) console.warn(`Warning: An <Outlet /> was rendered inside a ${nonRouteComponent}. <Outlet /> should only be rendered inside a route component.`);
}
const router = useRouter();
const routeId = React$112.useContext(matchContext);
let parentGlobalNotFound;
let parentNotFoundError;
let childRouteId;
if (isServer ?? router.isServer) {
const matches = router.stores.matches.get();
const parentIndex = matches.findIndex((match) => match.routeId === routeId);
const parentMatch = matches[parentIndex];
parentGlobalNotFound = !!parentMatch._notFound;
parentNotFoundError = parentMatch.error;
childRouteId = (_a = matches[parentIndex + 1]) == null ? void 0 : _a.routeId;
} else {
const parentMatchStore = router.stores.getMatchStore(routeId);
[parentGlobalNotFound, parentNotFoundError] = useSelector(parentMatchStore, (match) => [!!match._notFound, match.error], { compare: outletMatchSelectionEqual });
childRouteId = useSelector(router.stores.ids, (ids) => {
return ids[ids.indexOf(routeId) + 1];
});
}
if (parentGlobalNotFound) return renderRouteNotFound(router, router.routesById[routeId], parentNotFoundError);
if (!childRouteId) return null;
const nextMatch = (0, import_jsx_runtime13.jsx)(Match, { routeId: childRouteId });
if (routeId === rootRouteId) return (0, import_jsx_runtime13.jsx)(React$112.Suspense, {
fallback: renderPending(router),
children: nextMatch
});
return nextMatch;
});
// node_modules/@tanstack/react-router/dist/esm/Transitioner.js
var React$113 = __toESM(require_react(), 1);
function settleOwner(owner, rendered) {
const settle = owner[1];
owner.length = 0;
settle == null ? void 0 : settle(rendered);
}
function Transitioner({ t }) {
const router = useRouter();
const acknowledgement = router._rendered ?? (router._rendered = []);
const mounted = true ? React$113.useRef(false) : void 0;
router.startTransition = (fn, expected) => new Promise((resolve) => {
settleOwner(acknowledgement, false);
acknowledgement.push(expected, resolve);
t(router);
React$113.startTransition(fn);
});
useLayoutEffect2(() => {
const unsub = router.history.subscribe(router.load);
if (mounted == null ? void 0 : mounted.current) return unsub;
if (mounted) mounted.current = true;
router.updateLatestLocation();
const location = router.latestLocation;
const nextLocation = router.buildLocation({
to: location.pathname,
search: true,
params: true,
hash: true,
state: true,
_includeValidateSearch: true
});
if (trimPathRight(location.publicHref) !== trimPathRight(nextLocation.publicHref)) {
router.commitLocation({
...nextLocation,
replace: true,
ignoreBlocker: true
});
return unsub;
}
const resolvedLocation = router.stores.resolvedLocation.get();
if ((resolvedLocation == null ? void 0 : resolvedLocation.href) === location.href && resolvedLocation.state.__TSR_key === location.state.__TSR_key) acknowledgement.push(router.stores.matches.get(), (rendered) => {
if (rendered) router.emit({
type: "onRendered",
...getLocationChangeInfo(resolvedLocation, resolvedLocation)
});
});
else if (!router._tx) router.load({ sync: true }).catch(console.error);
return unsub;
}, [router, router.history]);
return null;
}
// node_modules/@tanstack/react-router/dist/esm/Matches.js
var React$114 = __toESM(require_react(), 1);
var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
function Matches() {
const router = useRouter();
const rootRoute = router.routesById[rootRouteId];
const pendingElement = renderPending(router, rootRoute);
const ResolvedSuspense = (isServer ?? router.isServer) || router.ssr ? SafeFragment : React$114.Suspense;
const inner = (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [!(isServer ?? router.isServer) && (0, import_jsx_runtime14.jsx)(Transitioner, { t: React$114.useState()[1] }), (0, import_jsx_runtime14.jsx)(ResolvedSuspense, {
fallback: pendingElement,
children: (0, import_jsx_runtime14.jsx)(MatchesInner, {})
})] });
return router.options.InnerWrap ? (0, import_jsx_runtime14.jsx)(router.options.InnerWrap, { children: inner }) : inner;
}
function MatchesInner() {
const router = useRouter();
const acknowledgement = router._rendered;
const matches = isServer ?? router.isServer ? router.stores.matches.get() : useSelector(router.stores.matches, (value) => acknowledgement[0] ?? value);
const match = matches[0];
const routeId = match == null ? void 0 : match.routeId;
useLayoutEffect2(() => {
if (acknowledgement[0] === matches) settleOwner(acknowledgement, true);
}, [acknowledgement, matches]);
const matchComponent = routeId ? (0, import_jsx_runtime14.jsx)(Match, { routeId }) : null;
return (0, import_jsx_runtime14.jsx)(matchContext.Provider, {
value: routeId,
children: router.options.disableGlobalCatchBoundary ? matchComponent : (0, import_jsx_runtime14.jsx)(CatchBoundary, {
getResetKey: () => match,
onCatch: true ? (error) => {
console.warn(`Warning: The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`);
console.warn("Warning:", error);
} : void 0,
children: matchComponent
})
});
}
function useMatchRoute() {
const router = useRouter();
if (isServer ?? router.isServer) return (opts) => {
const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts;
return router.matchRoute(rest, {
pending,
caseSensitive,
fuzzy,
includeSearch
});
};
return React$114.useCallback((opts) => {
const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts;
return router.matchRoute(rest, {
pending,
caseSensitive,
fuzzy,
includeSearch
});
}, [
router,
useSelector(router.stores.location, (location) => location.href),
useSelector(router.stores.resolvedLocation, (location) => location == null ? void 0 : location.href),
useSelector(router.stores.status)
]);
}
function MatchRoute(props) {
const params = useMatchRoute()(props);
if (typeof props.children === "function") return props.children(params);
return params ? props.children : null;
}
function useMatches(opts) {
const router = useRouter();
if (isServer ?? router.isServer) {
const matches = router.stores.matches.get();
return (opts == null ? void 0 : opts.select) ? opts.select(matches) : matches;
}
return useSelector(router.stores.matches, useStructuralSharing(opts, router));
}
function useParentMatches(opts) {
const contextRouteId = React$114.useContext(matchContext);
return useMatches({
select: (matches) => {
matches = matches.slice(0, matches.findIndex((d) => d.routeId === contextRouteId));
return (opts == null ? void 0 : opts.select) ? opts.select(matches) : matches;
},
structuralSharing: opts == null ? void 0 : opts.structuralSharing
});
}
function useChildMatches(opts) {
const contextRouteId = React$114.useContext(matchContext);
return useMatches({
select: (matches) => {
matches = matches.slice(matches.findIndex((d) => d.routeId === contextRouteId) + 1);
return (opts == null ? void 0 : opts.select) ? opts.select(matches) : matches;
},
structuralSharing: opts == null ? void 0 : opts.structuralSharing
});
}
// node_modules/@tanstack/react-router/dist/esm/routerStores.js
var getStoreFactory = (opts) => {
if (isServer ?? opts.isServer) return {
createMutableStore: createNonReactiveMutableStore,
createReadonlyStore: createNonReactiveReadonlyStore,
batch: (fn) => fn()
};
return {
createMutableStore: createAtom,
createReadonlyStore: createAtom,
batch
};
};
// 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, getStoreFactory);
}
};
// node_modules/@tanstack/react-router/dist/esm/RouterProvider.js
var import_react11 = __toESM(require_react(), 1);
var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
function RouterContextProvider({ router, children, ...rest }) {
if (hasKeys(rest)) router.update({
...router.options,
...rest,
context: {
...router.options.context,
...rest.context
}
});
const provider = (0, import_jsx_runtime15.jsx)(routerContext.Provider, {
value: router,
children
});
if (router.options.Wrap) return (0, import_jsx_runtime15.jsx)(router.options.Wrap, { children: provider });
return provider;
}
function RouterProvider({ router, ...rest }) {
return (0, import_jsx_runtime15.jsx)(RouterContextProvider, {
router,
...rest,
children: (0, import_jsx_runtime15.jsx)(Matches, {})
});
}
// node_modules/@tanstack/react-router/dist/esm/ScrollRestoration.js
function useScrollRestoration() {
setupScrollRestoration(useRouter(), 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();
return getElementScrollRestorationEntry(useRouter(), options);
}
// node_modules/@tanstack/react-router/dist/esm/useBlocker.js
var React$115 = __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: history2 } = router;
const [resolver, setResolver] = React$115.useState({
status: "idle",
current: void 0,
next: void 0,
action: void 0,
proceed: void 0,
reset: void 0
});
React$115.useEffect(() => {
const blockerFnComposed = async (blockerFnArgs) => {
function getLocation(location) {
const parsedLocation = router.parseLocation(location);
const [, rawParams, foundRoute] = router.getMatchedRoutes(parsedLocation.pathname);
if (foundRoute === void 0) return {
routeId: "__notFound__",
fullPath: parsedLocation.pathname,
pathname: parsedLocation.pathname,
params: rawParams,
search: router.options.parseSearch(location.search)
};
return {
routeId: foundRoute.id,
fullPath: foundRoute.fullPath,
pathname: parsedLocation.pathname,
params: rawParams,
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 canNavigateAsync = await new Promise((resolve) => {
setResolver({
status: "blocked",
current,
next,
action: blockerFnArgs.action,
proceed: () => resolve(false),
reset: () => resolve(true)
});
});
setResolver({
status: "idle",
current: void 0,
next: void 0,
action: void 0,
proceed: void 0,
reset: void 0
});
return canNavigateAsync;
};
return disabled ? void 0 : history2.block({
blockerFn: blockerFnComposed,
enableBeforeUnload
});
}, [
shouldBlockFn,
enableBeforeUnload,
disabled,
withResolver,
history2,
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 resolver = useBlocker(_resolvePromptBlockerArgs(rest));
return children ? typeof children === "function" ? children(resolver) : children : null;
}
// node_modules/@tanstack/react-router/dist/esm/useRouterState.js
function useRouterState(opts) {
const contextRouter = useRouter({ warn: (opts == null ? void 0 : opts.router) === void 0 });
const router = (opts == null ? void 0 : opts.router) || contextRouter;
if (isServer ?? router.isServer) {
const state = router.stores.__store.get();
return (opts == null ? void 0 : opts.select) ? opts.select(state) : state;
}
return useSelector(router.stores.__store, useStructuralSharing(opts, router));
}
// node_modules/@tanstack/react-router/dist/esm/useLocation.js
function useLocation(opts) {
const router = useRouter();
if (isServer ?? router.isServer) {
const location = router.stores.location.get();
return (opts == null ? void 0 : opts.select) ? opts.select(location) : location;
}
return useSelector(router.stores.location, useStructuralSharing(opts, router));
}
// node_modules/@tanstack/react-router/dist/esm/useCanGoBack.js
function useCanGoBack() {
const router = useRouter();
if (isServer ?? router.isServer) return router.stores.location.get().state.__TSR_index !== 0;
return useSelector(router.stores.location, (location) => location.state.__TSR_index !== 0);
}
// node_modules/@tanstack/react-router/dist/esm/Asset.js
var React$116 = __toESM(require_react(), 1);
var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
var INLINE_CSS_HYDRATION_ATTR = "data-tsr-inline-css";
var noopScriptHandler = () => {
};
function setScriptAttrs(script, attrs) {
if (!attrs) return;
for (const [key, value] of Object.entries(attrs)) if (key !== "suppressHydrationWarning" && value !== void 0 && value !== false) script.setAttribute(key, typeof value === "boolean" ? "" : String(value));
}
function Asset(asset) {
const { attrs, children, nonce, preventScriptHoist } = asset;
const innerHTML = React$116.useMemo(() => children === void 0 ? void 0 : { __html: children }, [children]);
switch (asset.tag) {
case "title":
return (0, import_jsx_runtime16.jsx)("title", {
...attrs,
suppressHydrationWarning: true,
children
});
case "meta":
return (0, import_jsx_runtime16.jsx)("meta", {
...attrs,
suppressHydrationWarning: true
});
case "link":
return (0, import_jsx_runtime16.jsx)("link", {
...attrs,
precedence: (attrs == null ? void 0 : attrs.precedence) ?? ((attrs == null ? void 0 : attrs.rel) === "stylesheet" ? "default" : void 0),
nonce,
suppressHydrationWarning: true
});
case "style":
if (asset.inlineCss && (process.env.TSS_INLINE_CSS_ENABLED === "true" || process.env.TSS_INLINE_CSS_ENABLED === void 0 && isServer)) return (0, import_jsx_runtime16.jsx)(InlineCssStyle, {
attrs,
nonce,
children
});
return (0, import_jsx_runtime16.jsx)("style", {
...attrs,
dangerouslySetInnerHTML: innerHTML,
nonce
});
case "script":
return (0, import_jsx_runtime16.jsx)(Script, {
attrs,
preventScriptHoist,
children
});
default:
return null;
}
}
function InlineCssStyle({ attrs, children, nonce }) {
const isInlineCssPlaceholder = children === void 0;
const [hydratedInlineCss] = React$116.useState(() => {
var _a;
if (!isInlineCssPlaceholder || typeof document === "undefined") return;
return ((_a = document.querySelector(`style[${INLINE_CSS_HYDRATION_ATTR}]`)) == null ? void 0 : _a.textContent) ?? void 0;
});
const html = isInlineCssPlaceholder ? hydratedInlineCss ?? "" : children ?? "";
const innerHTML = React$116.useMemo(() => ({ __html: html }), [html]);
return (0, import_jsx_runtime16.jsx)("style", {
...attrs,
[INLINE_CSS_HYDRATION_ATTR]: "",
dangerouslySetInnerHTML: innerHTML,
nonce,
suppressHydrationWarning: true
});
}
function Script({ attrs, children, preventScriptHoist }) {
const router = useRouter();
const hydrated = useHydrated();
const innerHTML = React$116.useMemo(() => children === void 0 ? void 0 : { __html: children }, [children]);
const dataScript = typeof (attrs == null ? void 0 : attrs.type) === "string" && attrs.type !== "" && attrs.type !== "text/javascript" && attrs.type !== "module";
if ((attrs == null ? void 0 : 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`.");
React$116.useEffect(() => {
if (dataScript) return;
if (attrs == null ? void 0 : attrs.src) {
const link2 = document.createElement("a");
link2.href = attrs.src;
const normSrc = link2.href;
for (const el of document.scripts) if (el.src === normSrc) return;
const script = document.createElement("script");
setScriptAttrs(script, attrs);
document.head.appendChild(script);
return () => script.remove();
}
if (typeof children === "string") {
const typeAttr = typeof (attrs == null ? void 0 : attrs.type) === "string" ? attrs.type : "text/javascript";
const nonceAttr = typeof (attrs == null ? void 0 : attrs.nonce) === "string" ? attrs.nonce : void 0;
for (const el of document.scripts) {
if (el.hasAttribute("src")) continue;
const sType = el.getAttribute("type") ?? "text/javascript";
const sNonce = el.getAttribute("nonce") ?? void 0;
if (el.textContent === children && sType === typeAttr && sNonce === nonceAttr) return;
}
const script = document.createElement("script");
script.textContent = children;
setScriptAttrs(script, attrs);
document.head.appendChild(script);
return () => script.remove();
}
}, [
attrs,
children,
dataScript
]);
if (isServer ?? router.isServer) {
if (attrs == null ? void 0 : attrs.src) {
if (!preventScriptHoist) return (0, import_jsx_runtime16.jsx)("script", {
...attrs,
suppressHydrationWarning: true
});
return (0, import_jsx_runtime16.jsx)("script", {
...attrs,
onLoad: noopScriptHandler,
suppressHydrationWarning: true
});
}
if (typeof children === "string") return (0, import_jsx_runtime16.jsx)("script", {
...attrs,
dangerouslySetInnerHTML: innerHTML,
suppressHydrationWarning: true
});
return null;
}
if (dataScript && typeof children === "string") return (0, import_jsx_runtime16.jsx)("script", {
...attrs,
suppressHydrationWarning: true,
dangerouslySetInnerHTML: innerHTML
});
if (!hydrated) {
if (attrs == null ? void 0 : attrs.src) return (0, import_jsx_runtime16.jsx)("script", {
...attrs,
suppressHydrationWarning: true
});
if (typeof children === "string") return (0, import_jsx_runtime16.jsx)("script", {
...attrs,
dangerouslySetInnerHTML: innerHTML,
suppressHydrationWarning: true
});
}
return null;
}
// node_modules/@tanstack/react-router/dist/esm/headContentUtils.js
var React$117 = __toESM(require_react(), 1);
function buildTagsFromMatches(router, nonce, matches, assetCrossOrigin) {
var _a;
matches = _getAssetMatches(matches);
const routeMeta = matches.map((match) => match.meta).filter((meta) => meta !== void 0);
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();
const constructedLinks = matches.flatMap((match) => match.links ?? []).filter((link2) => link2 !== void 0).map((link2) => ({
tag: "link",
attrs: {
...link2,
nonce
}
}));
const manifest = (_a = router.ssr) == null ? void 0 : _a.manifest;
const manifestCssTags = [];
if (manifest) {
matches.forEach((match) => {
var _a2, _b;
(_b = (_a2 = manifest.routes[match.routeId]) == null ? void 0 : _a2.css) == null ? void 0 : _b.forEach((link2) => {
const resolvedLink = resolveManifestCssLink(link2);
manifestCssTags.push({
tag: "link",
attrs: {
rel: "stylesheet",
...resolvedLink,
crossOrigin: getAssetCrossOrigin(assetCrossOrigin, "stylesheet") ?? resolvedLink.crossOrigin,
suppressHydrationWarning: true,
nonce
}
});
});
});
if (manifest.inlineStyle) manifestCssTags.push({
tag: "style",
attrs: {
...manifest.inlineStyle.attrs,
nonce
},
children: manifest.inlineStyle.children,
inlineCss: true
});
}
const preloadLinks = [];
if (manifest) matches.forEach((match) => {
var _a2, _b;
(_b = (_a2 = manifest.routes[match.routeId]) == null ? void 0 : _a2.preloads) == null ? void 0 : _b.forEach((preload) => {
preloadLinks.push({
tag: "link",
attrs: {
...getScriptPreloadAttrs(manifest, preload, assetCrossOrigin),
nonce
}
});
});
});
const styles = matches.flatMap((match) => match.styles ?? []).filter((style) => style !== void 0).map(({ children, ...attrs }) => ({
tag: "style",
attrs: {
...attrs,
nonce
},
children
}));
const headScripts = matches.flatMap((match) => match.headScripts ?? []).filter((script) => script !== void 0).map(({ children, ...script }) => ({
tag: "script",
attrs: {
...script,
nonce
},
children
}));
const tags = [];
appendUniqueUserTags(tags, resultMeta);
tags.push(...preloadLinks);
appendUniqueUserTags(tags, constructedLinks);
tags.push(...manifestCssTags);
appendUniqueUserTags(tags, styles);
appendUniqueUserTags(tags, headScripts);
return tags;
}
var useTags = (assetCrossOrigin) => {
var _a;
const router = useRouter();
const nonce = (_a = router.options.ssr) == null ? void 0 : _a.nonce;
if (isServer ?? router.isServer) return buildTagsFromMatches(router, nonce, router.stores.matches.get(), assetCrossOrigin);
const selectTags = React$117.useCallback((matches) => buildTagsFromMatches(router, nonce, matches, assetCrossOrigin), [
assetCrossOrigin,
nonce,
router
]);
return useSelector(router.stores.matches, selectTags, { compare: deepEqual });
};
// node_modules/@tanstack/react-router/dist/esm/Scripts.js
var import_react12 = __toESM(require_react(), 1);
var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
var routeScriptAttrs = { suppressHydrationWarning: true };
var Scripts = () => {
var _a, _b;
const router = useRouter();
const nonce = (_a = router.options.ssr) == null ? void 0 : _a.nonce;
const getParts = (matches) => {
var _a2, _b2;
const parts = getSsrBodyScriptParts(matches, (_a2 = router.ssr) == null ? void 0 : _a2.manifest, nonce, routeScriptAttrs);
for (const script of parts[1]) if (typeof ((_b2 = script.attrs) == null ? void 0 : _b2.src) === "string") {
const scriptWithHoist = script;
scriptWithHoist.preventScriptHoist = true;
}
return parts;
};
const getScripts = (matches) => {
return composeSsrBodyScripts(getParts(matches));
};
if (isServer ?? router.isServer) return renderScripts(composeSsrBodyScripts(getParts(router.stores.matches.get()), (_b = router.serverSsr) == null ? void 0 : _b.takeInitialHydrationScriptTags()));
return renderScripts(useSelector(router.stores.matches, getScripts, { compare: deepEqual }));
};
function renderScripts(scripts) {
return (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: scripts.map((asset, i) => (0, import_react12.createElement)(Asset, {
...asset,
key: `tsr-scripts-${asset.tag}-${i}`
})) });
}
// node_modules/@tanstack/react-router/dist/esm/HeadContent.js
var import_react13 = __toESM(require_react(), 1);
var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
// node_modules/@tanstack/react-router/dist/esm/HeadContent.dev.js
var React$118 = __toESM(require_react(), 1);
var import_react14 = __toESM(require_react(), 1);
var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
function HeadContent2(props) {
var _a;
const tags = useTags(props.assetCrossOrigin);
const nonce = (_a = useRouter().options.ssr) == null ? void 0 : _a.nonce;
const hydrated = useHydrated();
React$118.useEffect(() => {
if (hydrated) document.querySelectorAll(`link[${DEV_STYLES_ATTR}]`).forEach((el) => el.remove());
}, [hydrated]);
return (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: (hydrated ? tags.filter((tag) => {
var _a2;
return tag.tag !== "link" || ((_a2 = tag.attrs) == null ? void 0 : _a2[DEV_STYLES_ATTR]) !== true;
}) : tags).map((tag) => (0, import_react14.createElement)(Asset, {
...tag,
key: `tsr-meta-${JSON.stringify(tag)}`,
nonce
})) });
}
export {
Asset,
Await,
Block,
CatchBoundary,
CatchNotFound,
ClientOnly,
DEFAULT_PROTOCOL_ALLOWLIST,
DefaultGlobalNotFound,
ErrorComponent,
FileRoute,
FileRouteLoader,
HeadContent2 as 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,
isRedirect,
joinPaths,
lazyFn,
lazyRouteComponent,
linkOptions,
notFound,
parseSearchWith,
reactUse,
redirect,
replaceEqualDeep,
resolvePath,
retainSearchParams,
rootRouteId,
rootRouteWithContext,
stringifySearchWith,
stripSearchParams,
trimPath,
trimPathLeft,
trimPathRight,
useAwaited,
useBlocker,
useCanGoBack,
useChildMatches,
useElementScrollRestoration,
useHydrated,
useLayoutEffect2 as useLayoutEffect,
useLinkProps,
useLoaderData,
useLoaderDeps,
useLocation,
useMatch,
useMatchRoute,
useMatches,
useNavigate,
useParams,
useParentMatches,
useRouteContext,
useRouter,
useRouterState,
useSearch,
useTags
};
/*! Bundled license information:
use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
(**
* @license React
* use-sync-external-store-shim.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
(**
* @license React
* use-sync-external-store-shim/with-selector.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
*/
//# sourceMappingURL=@tanstack_react-router.js.map