@real-router/core 0.150.0 → 0.151.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{Router-_0vZHk6R.js → Router-vdonCekD.js} +2 -2
- package/dist/cjs/Router-vdonCekD.js.map +1 -0
- package/dist/cjs/RouterError-aGkUvcJJ.js +2 -0
- package/dist/cjs/RouterError-aGkUvcJJ.js.map +1 -0
- package/dist/cjs/RouterError.d.ts +3 -0
- package/dist/cjs/RouterError.d.ts.map +1 -1
- package/dist/cjs/api.js +1 -1
- package/dist/cjs/api.js.map +1 -1
- package/dist/cjs/{helpers-B2Zsa5R_.js → helpers-DdpDlqWS.js} +2 -2
- package/dist/cjs/{helpers-B2Zsa5R_.js.map → helpers-DdpDlqWS.js.map} +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/{internals-C18omEfg.js → internals-BEKzn5ug.js} +2 -2
- package/dist/cjs/{internals-C18omEfg.js.map → internals-BEKzn5ug.js.map} +1 -1
- package/dist/cjs/utils.js +1 -1
- package/dist/cjs/validation.js +1 -1
- package/dist/esm/Router-BMHsXAXA.mjs +2 -0
- package/dist/esm/Router-BMHsXAXA.mjs.map +1 -0
- package/dist/esm/RouterError-DyPeuufj.mjs +2 -0
- package/dist/esm/RouterError-DyPeuufj.mjs.map +1 -0
- package/dist/esm/RouterError.d.mts +3 -0
- package/dist/esm/RouterError.d.mts.map +1 -1
- package/dist/esm/api.mjs +1 -1
- package/dist/esm/api.mjs.map +1 -1
- package/dist/esm/{helpers-BnQy9vYH.mjs → helpers-BXXeSrT8.mjs} +2 -2
- package/dist/esm/{helpers-BnQy9vYH.mjs.map → helpers-BXXeSrT8.mjs.map} +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/internals-BNRNi6Fp.mjs +2 -0
- package/dist/esm/{internals-CBAb3okL.mjs.map → internals-BNRNi6Fp.mjs.map} +1 -1
- package/dist/esm/utils.mjs +1 -1
- package/dist/esm/validation.mjs +1 -1
- package/package.json +1 -1
- package/dist/cjs/Router-_0vZHk6R.js.map +0 -1
- package/dist/cjs/RouterError-CentZBJj.js +0 -2
- package/dist/cjs/RouterError-CentZBJj.js.map +0 -1
- package/dist/esm/Router-DVdK_R0k.mjs +0 -2
- package/dist/esm/Router-DVdK_R0k.mjs.map +0 -1
- package/dist/esm/RouterError-Dy1_FfLa.mjs +0 -2
- package/dist/esm/RouterError-Dy1_FfLa.mjs.map +0 -1
- package/dist/esm/internals-CBAb3okL.mjs +0 -2
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=Object.freeze({ROUTER_NOT_STARTED:`NOT_STARTED`,NO_START_PATH_OR_STATE:`NO_START_PATH_OR_STATE`,ROUTER_ALREADY_STARTED:`ALREADY_STARTED`,ROUTE_NOT_FOUND:`ROUTE_NOT_FOUND`,SAME_STATES:`SAME_STATES`,CANNOT_DEACTIVATE:`CANNOT_DEACTIVATE`,CANNOT_ACTIVATE:`CANNOT_ACTIVATE`,TRANSITION_ERR:`TRANSITION_ERR`,TRANSITION_CANCELLED:`CANCELLED`,ROUTER_DISPOSED:`DISPOSED`,PLUGIN_CONFLICT:`PLUGIN_CONFLICT`,CONTEXT_NAMESPACE_ALREADY_CLAIMED:`CONTEXT_NAMESPACE_ALREADY_CLAIMED`,REENTRANT_NAVIGATION:`REENTRANT_NAVIGATION`,REENTRANT_TREE_MUTATION:`REENTRANT_TREE_MUTATION`,ROUTER_NOT_STOPPED:`NOT_STOPPED`,WRONG_CHANNEL:`WRONG_CHANNEL`}),t=`@@router/UNKNOWN_ROUTE`,n=`__proto__`,r=Object.freeze({UNKNOWN_ROUTE:t}),i=Object.freeze({ROUTER_START:`onStart`,ROUTER_STOP:`onStop`,TRANSITION_START:`onTransitionStart`,TRANSITION_LEAVE_APPROVE:`onTransitionLeaveApprove`,TRANSITION_CANCEL:`onTransitionCancel`,TRANSITION_SUCCESS:`onTransitionSuccess`,TRANSITION_ERROR:`onTransitionError`}),a=Object.freeze({ROUTER_START:`$start`,ROUTER_STOP:`$stop`,TRANSITION_START:`$$start`,TRANSITION_LEAVE_APPROVE:`$$leaveApprove`,TRANSITION_CANCEL:`$$cancel`,TRANSITION_SUCCESS:`$$success`,TRANSITION_ERROR:`$$error`}),o=Object.freeze({maxDependencies:100,maxPlugins:50,maxListeners:1e4,warnListeners:1e3,maxLifecycleHandlers:200}),s=Object.freeze({}),c=Object.freeze({}),l=Object.freeze({}),u=Object.freeze({deactivated:Object.freeze([]),activated:Object.freeze([]),intersection:``}),d=Object.freeze({phase:`activating`,reason:`success`,segments:u}),f=Object.create,p=Object.entries;function m(){return f(null)}function h(e){return{...e}}const g=Object.defineProperty,_=Object.hasOwn;function v(e){return _(e,`__proto__`)&&g(e,n,{value:e[n],writable:!0,enumerable:!1,configurable:!0}),e}function y(e,t,n){t in e&&!_(e,t)?g(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function b(e,t){for(let[n,r]of p(t))y(e,n,r)}const x=Object.freeze,S=Object.entries,C=Object.values,w=Object.hasOwn,T=new Set(C(e)),E=new Set([`code`,`segment`,`path`]),D=new Set([`setCode`,`setErrorInstance`,`setAdditionalFields`,`hasField`,`getField`,`toJSON`]);function O(e){return x(e)}var k=class extends Error{segment;path;code;constructor(e,{message:t,segment:n,path:r,...i}={}){super(t??e),this.name=`RouterError`,this.code=e,this.segment=n,this.path=r;for(let[e,t]of S(i)){if(E.has(e))throw M.type`Cannot set reserved property "${e}"`;e!==`__proto__`&&!D.has(e)&&y(this,e,t)}}setCode(e){this.code=e,T.has(this.message)&&(this.message=e)}setErrorInstance(e){if(!e)throw N.type`err parameter is required and must be an Error instance`;this.message=e.message,y(this,`cause`,e.cause),this.stack=e.stack??``}setAdditionalFields(e){for(let[t,n]of S(e)){if(E.has(t))throw P.type`Cannot set reserved property "${t}"`;t!==`__proto__`&&!D.has(t)&&y(this,t,n)}}hasField(e){return w(this,e)}getField(e){return w(this,e)?this[e]:void 0}toJSON(){let e={code:this.code,message:this.message};this.segment!==void 0&&(e.segment=this.segment),this.path!==void 0&&(e.path=this.path);let t=new Set([`code`,`message`,`segment`,`path`,`stack`,`name`]);for(let n in this)w(this,n)&&!t.has(n)&&y(e,n,this[n]);return e}};const A=(e,t)=>{let n=e[0];for(let[r,i]of t.entries())n+=String(i)+e[r+1];return n};function j(e,t){let n=t===void 0||t===``?`[${e}] `:`[${e}.${t}] `,r=(e,t)=>n+A(e,t),i=e=>((t,...n)=>Array.isArray(t)?e(r(t,n)):(n,...i)=>e(r(n,i),t));return{type:i((e,t)=>TypeError(e,t)),plain:i((e,t)=>Error(e,t)),ref:(e,...t)=>ReferenceError(r(e,t)),range:(e,...t)=>RangeError(r(e,t)),code:(e,t)=>(n,...i)=>O(new k(e,{...t,message:r(n,i)}))}}const M=j(`RouterError`),N=j(`RouterError`,`setErrorInstance`),P=j(`RouterError`,`setAdditionalFields`),F={plain:(e,...t)=>Error(`Internal error (please report): ${A(e,t)}`)};Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return a}});
|
|
2
|
-
//# sourceMappingURL=RouterError-CentZBJj.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RouterError-CentZBJj.js","names":["objectEntries","hasOwn","errorCodes","UNKNOWN_ROUTE","UNSAFE_KEY","constants","plugins","events","DEFAULT_LIMITS","EMPTY_PARAMS","EMPTY_SEARCH","EMPTY_OPTS","FROZEN_EMPTY_SEGMENTS","DEFAULT_TRANSITION","objectCreate","objectEntries$1","emptyRecord","publishRecord","source","defineProperty","hasOwn$1","concealUnsafeKey","record","putField","key","target","value","copyFields","freeze","objectEntries","objectValues","hasOwn","errorCodeValues","reservedProperties","reservedMethods","freezeThrownError","error","RouterError","rest","message","code","segment","path","newCode","err","fields","result","excludeKeys","interpolate","text","strings","index","values","raiser","head","door","receiver","flavour","first","build","options","atRouterError","atSetErrorInstance","atSetAdditionalFields","internalDefect"],"sources":["../../src/constants.ts","../../src/utils/ingest.ts","../../src/RouterError.ts"],"sourcesContent":["// packages/core/src/constants.ts\n\nimport type {\n EventToNameMap,\n EventToPluginMap,\n ErrorCodeToValueMap,\n ErrorCodeKeys,\n ErrorCodeValues,\n TransitionMeta,\n} from \"./types\";\n\nexport type ConstantsKeys = \"UNKNOWN_ROUTE\";\n\nexport type Constants = Readonly<Record<ConstantsKeys, string>>;\n\n// =============================================================================\n// Error Codes (migrated from router-error)\n// =============================================================================\n\nexport type ErrorCodes = Record<ErrorCodeKeys, ErrorCodeValues>;\n\n/**\n * Error codes for router operations.\n * Used to identify specific failure scenarios in navigation and lifecycle.\n * Frozen to prevent accidental modifications.\n */\nexport const errorCodes: ErrorCodeToValueMap = Object.freeze({\n ROUTER_NOT_STARTED: \"NOT_STARTED\", // navigate() called before start()\n NO_START_PATH_OR_STATE: \"NO_START_PATH_OR_STATE\", // start() without initial route\n ROUTER_ALREADY_STARTED: \"ALREADY_STARTED\", // start() called twice\n ROUTE_NOT_FOUND: \"ROUTE_NOT_FOUND\", // Navigation to non-existent route\n SAME_STATES: \"SAME_STATES\", // Navigate to current route without reload\n CANNOT_DEACTIVATE: \"CANNOT_DEACTIVATE\", // canDeactivate guard blocked navigation\n CANNOT_ACTIVATE: \"CANNOT_ACTIVATE\", // canActivate guard blocked navigation\n TRANSITION_ERR: \"TRANSITION_ERR\", // Generic transition failure\n TRANSITION_CANCELLED: \"CANCELLED\", // Navigation cancelled by user or new navigation\n ROUTER_DISPOSED: \"DISPOSED\", // Router has been disposed\n PLUGIN_CONFLICT: \"PLUGIN_CONFLICT\", // Plugin tried to extend router with already-existing property\n CONTEXT_NAMESPACE_ALREADY_CLAIMED: \"CONTEXT_NAMESPACE_ALREADY_CLAIMED\", // Plugin tried to claim a context namespace already owned by another plugin\n REENTRANT_NAVIGATION: \"REENTRANT_NAVIGATION\", // a navigation (the navigate family, or start() restarting the router) called synchronously from inside a navigation core has not finished with (banned — defer it)\n REENTRANT_TREE_MUTATION: \"REENTRANT_TREE_MUTATION\", // a tree mutator — route-CRUD or setRootPath (#1751) — called synchronously from inside a subscribeChanges handler (banned — use await/async/queueMicrotask)\n ROUTER_NOT_STOPPED: \"NOT_STOPPED\", // clear() called while a state is committed — tear down with stop() first, or swap the tree with replace() (#1612)\n WRONG_CHANNEL: \"WRONG_CHANNEL\", // a declared query key was supplied in the path channel (`params`) instead of `search` (#1572)\n});\n\n/**\n * General router constants.\n * Special route names and identifiers.\n */\nexport const UNKNOWN_ROUTE = \"@@router/UNKNOWN_ROUTE\";\n\n/**\n * The one key the router will not copy into a state channel (#1792), and — at\n * `getDependenciesApi.getAll` — will not hand back out of a container either.\n *\n * `__proto__` is the only ACCESSOR among `Object.prototype`'s twelve own\n * members, so `target[key] = value` for that one name reaches the inherited\n * setter: no own key is created, the value vanishes with no error and no log,\n * and an OBJECT value replaces the target's prototype instead.\n *\n * ⚠ Core REFUSES it nowhere — not at a door, not at registration. It is dropped\n * where core copies into a CHANNEL and kept everywhere else, because a route's\n * custom fields and a plugin's context namespace are not containers a consumer\n * merges.\n *\n * ⚠ A `grep` for this constant does not find the sites carrying the opposite\n * contract: they go through `putField` (#1852), which keeps every name.\n *\n * The rule this serves, the doors exempt from it and the level it closes are\n * `INVARIANTS.md` — *Supported input shapes*, *WRITE* (#1852) and *HAND-OUT*\n * (#1957), with `handed-out-containers-1957.test.ts` as the authority. They are\n * deliberately not restated here: this docblock carried a second copy of that\n * section, and the two had already diverged.\n */\nexport const UNSAFE_KEY = \"__proto__\";\n\nexport const constants: Constants = Object.freeze({\n UNKNOWN_ROUTE,\n});\n\n/**\n * Plugin method names.\n * Maps to methods that plugins can implement to hook into router lifecycle.\n */\nexport const plugins: EventToPluginMap = Object.freeze({\n ROUTER_START: \"onStart\", // Plugin method called when router starts\n ROUTER_STOP: \"onStop\", // Plugin method called when router stops\n TRANSITION_START: \"onTransitionStart\", // Plugin method called when navigation begins\n TRANSITION_LEAVE_APPROVE: \"onTransitionLeaveApprove\", // Plugin method called when deactivation guards pass\n TRANSITION_CANCEL: \"onTransitionCancel\", // Plugin method called when navigation cancelled\n TRANSITION_SUCCESS: \"onTransitionSuccess\", // Plugin method called when navigation succeeds\n TRANSITION_ERROR: \"onTransitionError\", // Plugin method called when navigation fails\n});\n\n/**\n * Event names for router event system.\n * Used with addEventListener/removeEventListener for reactive subscriptions.\n */\nexport const events: EventToNameMap = Object.freeze({\n ROUTER_START: \"$start\", // Emitted when router.start() succeeds\n ROUTER_STOP: \"$stop\", // Emitted when router.stop() is called\n TRANSITION_START: \"$$start\", // Emitted when navigation begins\n TRANSITION_LEAVE_APPROVE: \"$$leaveApprove\", // Emitted when deactivation guards pass\n TRANSITION_CANCEL: \"$$cancel\", // Emitted when navigation is cancelled\n TRANSITION_SUCCESS: \"$$success\", // Emitted when navigation completes successfully\n TRANSITION_ERROR: \"$$error\", // Emitted when navigation fails\n});\n\nexport const DEFAULT_LIMITS = Object.freeze({\n maxDependencies: 100,\n maxPlugins: 50,\n maxListeners: 10_000,\n warnListeners: 1000,\n maxLifecycleHandlers: 200,\n} as const);\n\nexport const EMPTY_PARAMS: Readonly<Record<string, never>> = Object.freeze({});\n\n/**\n * Shared frozen empty query bag reused for `State.search` when a navigation\n * carries no query params — the search-channel twin of {@link EMPTY_PARAMS}\n * (RFC-4 M2 / #1548). Lets `makeState` reuse one frozen `{}` (zero transient\n * allocation, #1027) instead of minting an object per query-less state.\n */\nexport const EMPTY_SEARCH: Readonly<Record<string, never>> = Object.freeze({});\n\n/**\n * Shared frozen empty `NavigationOptions`, substituted by the facade when a\n * caller passes none — the options-channel twin of {@link EMPTY_PARAMS}.\n *\n * ⚑ It lives here rather than in `Router.ts` so the entry door can recognise it\n * by IDENTITY (#1962). `navigate(\"b\")` is the commonest call in the library, and\n * matching this singleton is what keeps the door's cost on it to one comparison\n * instead of a copy nobody asked for.\n */\n/**\n * The options bag the facade substitutes when the caller passes none.\n *\n * ⚠ **An ordinary `{}`, and the flags read off it are own-gated at the read\n * instead (#2132).** This object reaches the entry unchanged, so an ambient\n * `Object.prototype.signal` would answer here with no caller bag in the picture\n * at all — core acting on an option nobody supplied. A prototype-less singleton\n * closes that structurally and was measured too expensive: `Object.create(null)`\n * puts it in V8's dictionary mode, and every downstream read of the bag becomes\n * a hash lookup — **+7.6 %** per navigation on this path, **+39.6 %** on the one\n * that copies. The gates cost **+2.9 %** / **+3.0 %**.\n */\nexport const EMPTY_OPTS: Readonly<Record<string, never>> = Object.freeze({});\n\nconst FROZEN_EMPTY_SEGMENTS = Object.freeze({\n deactivated: Object.freeze([]) as unknown as string[],\n activated: Object.freeze([]) as unknown as string[],\n intersection: \"\",\n});\n\nexport const DEFAULT_TRANSITION = Object.freeze({\n phase: \"activating\",\n reason: \"success\",\n segments: FROZEN_EMPTY_SEGMENTS,\n}) as TransitionMeta;\n","// packages/core/src/utils/ingest.ts\n//\n// One discipline for the records core BUILDS under a key it did not CHOOSE.\n//\n// Two halves, and they answer different questions — a reader who takes them for\n// one primitive will draw the wrong conclusion from either:\n//\n// `emptyRecord` / `publishRecord` (#1825) — a record with no prototype for the\n// BUILD, handed out plain. Used where the record is core's alone:\n// `buildParamMeta`, the segment-meta walk.\n// `putField` / `copyFields` (#1852) — a guarded WRITE for the records that\n// cannot be prototype-less because they are published, read on every render,\n// or belong to someone else. Used across core and, through\n// `@real-router/core/utils`, by four plugins.\n// ⚠ The site COUNTS deliberately do not live here. This comment carried\n// \"twenty-one in core, fourteen across four plugins\" and both halves were\n// wrong (22 and 13, measured) — a second copy of a number `CLAUDE.md`\n// already calls descriptive-not-contract. The count lives in `CLAUDE.md`\n// (\"The WRITE side of the same rule\"); the CONTRACT is the derived set in\n// `tests/functional/computed-key-write-authority-1852.test.ts`.\n//\n// ⚠ Neither decides whether a key is PUBLISHED. `__proto__` stays out of\n// `state.params` / `state.search` by a separate skip at the channel copy sites\n// in `helpers.ts`, and stays IN a route's custom fields and a plugin's context\n// namespace, because those are not containers a consumer merges. See `putField`'s\n// docblock for that split.\n//\n// `concealUnsafeKey` (#1957) is the one member of this file that DOES decide\n// that — for exactly one record, `buildMeta`'s, which core both hands out\n// and reads back by key. It withholds the name from ENUMERATION rather than\n// removing it, because removing it is a measured behaviour loss there. The\n// doors that only hand a container OUT drop the key instead\n// (`dropUnsafeKey`, `helpers.ts`).\n//\n// ⚠ The rest are WRITE-side primitives only, and the boundary is deliberate. A\n// READ-side primitive that walks a caller's prototype chain was written here,\n// wired, measured — and removed: `CLAUDE.md` \"Supported Input Shapes\" settles\n// that axis already (\"own enumerable properties only\", owner decision\n// 2026-08-18), and core is the layer that DEGRADES on a violation while\n// `@real-router/validation-plugin` is the layer that reports it. A primitive\n// that honoured inherited keys would have made core contradict its own canon,\n// and it additionally admitted the ambient `Object.prototype` — the #1840\n// class, introduced by the fix.\n//\n// So what is left is the half the canon does not cover: what happens when core\n// writes into a record of its own under a key it did not choose.\n\nimport { UNSAFE_KEY } from \"../constants\";\n\n/** Captured like the deciding seven, but this one BUILDS the guarantee (#2072). */\nconst objectCreate = Object.create;\n\nconst objectEntries = Object.entries;\n\n/**\n * The target discipline: a record with NO prototype.\n *\n * ⚑ This one line closes two axes at once, which is why it is a primitive and\n * not an idiom. #1856 tabulates them as a structural trade — a key-by-key copy\n * fixes `\"__proto__\"` but turns a `[[DefineOwnProperty]]` into a `[[Set]]`, so\n * an ambient accessor starts throwing — and calls the conflict unavoidable. It\n * is unavoidable only while the target inherits from `Object.prototype`:\n *\n * - `\"__proto__\"` (#1825, #1794, #1809) is an ordinary key here, because the\n * magic accessor lives on `Object.prototype` and this object has none.\n * - an ambient accessor named `id` / `page` / `tab` (#1852) cannot hijack the\n * write for the same reason. #1852 notes the key's provenance is\n * irrelevant — `SegmentMatcher` writes a name from the ROUTE TABLE and\n * throws just the same — so a name-based skip cannot close it and this can.\n */\nexport function emptyRecord<V>(): Record<string, V> {\n return objectCreate(null) as Record<string, V>;\n}\n\n/**\n * Hand a privately-built record out with the ORDINARY prototype, keeping every\n * own key — including a literal `\"__proto__\"`.\n *\n * Discovered by measurement, not designed: wiring `emptyRecord` into\n * `buildParamMeta` alone reds **21** existing tests, all of the shape\n * `expected { id: 'url' } to strictly equal { id: 'url' }` — identical content,\n * different prototype, because `toStrictEqual` compares prototypes and\n * `paramTypeMap` is published through `getPluginApi(router).getTree()`. A\n * prototype-less record is not a drop-in at a published surface.\n *\n * The spread is what makes this work rather than undo it: it\n * `[[DefineOwnProperty]]`s, so an own `\"__proto__\"` carried on the private\n * record lands as an ordinary own key here (measured: own keys\n * `[\"__proto__\",\"keep\"]`, value intact, prototype back to `Object.prototype`).\n * Writing that same key into a fresh `{}` with `[[Set]]` loses it entirely\n * (measured: own keys `[]`) — which is the defect the private record exists to\n * avoid.\n *\n * So the rule is: **build private, publish plain.** The window in which the\n * ambient-accessor hazard (#1852) could bite is the build, and the build never\n * touches `Object.prototype`.\n */\nexport function publishRecord<V>(source: Record<string, V>): Record<string, V> {\n return { ...source };\n}\n\n/**\n * Captured at module load for the reason `helpers.ts` gives for `freeze` /\n * `hasOwn` / `objectKeys`: this is the operation {@link putField} writes\n * through, so a guard reading it late would be reading whatever an application\n * had re-pointed it to.\n */\nconst defineProperty = Object.defineProperty;\nconst hasOwn = Object.hasOwn;\n\n/**\n * Withhold `UNSAFE_KEY` from ENUMERATION on a record core hands out AND reads\n * back by key (#1957).\n *\n * ⚑ The hazard is the CONSUMER's merge, not core's own write. `Object.assign`\n * and a `for…in` copy `[[Set]]` each own ENUMERABLE key on the TARGET, where\n * `Object.prototype`'s `\"__proto__\"` accessor replaces that target's prototype\n * instead of adding an entry.\n *\n * ⚠ A SPREAD is NOT in that list. `{ ...source }` performs `CreateDataProperty`,\n * i.e. `[[DefineOwnProperty]]`, which never reaches an inherited accessor —\n * measured on the poisoned bag, on a null-prototype carrier and through a\n * pass-through Proxy, a spread swaps in none of the three. The list is exactly\n * `Object.assign` or a `for…in` copy (#1823), and the hazard is that narrow.\n *\n * So the SOURCE's own prototype decides nothing either — measured, an\n * `Object.create(null)` source swaps the target exactly the same — and the only\n * two fixes are removing the key or removing it from enumeration.\n *\n * ⚠ **Dropping is not a milder fix here, it is a WRONG one.** The route-meta\n * record is core's working table: `segmentParamsEqual` reads `meta[segmentName]`\n * on every navigation, so with the entry gone the read reaches the INHERITED\n * accessor and answers `Object.prototype` — an object, whose `Object.keys` is\n * `[]`, so the segment reports \"params unchanged\". Measured end to end on a\n * route named `__proto__`: `/p/1` → `/p/2` activates `[\"__proto__\"]` today and\n * `[]` with the entry deleted. Core accepts that name (#1801), so the loss is\n * real and silent.\n *\n * Non-enumerable keeps the read exact for core AND for a consumer asking by\n * key, while `Object.assign` / a spread / `for…in` skip it — measured, all\n * three.\n *\n * ⚠ NOT applied by {@link publishRecord} itself. Its other caller is\n * `buildParamMeta`, whose map core ENUMERATES (`Object.keys` in\n * `segmentParamsEqual`, `for…in` in `hasAnyParam`) and which is not a swap\n * primitive anyway: a param's value is the string `\"url\"` / `\"query\"`, and the\n * inherited setter ignores primitives.\n *\n * Returns the input untouched, with no descriptor write, when the key is absent\n * — which is every ordinary route.\n */\nexport function concealUnsafeKey<V>(\n record: Record<string, V>,\n): Record<string, V> {\n if (!hasOwn(record, UNSAFE_KEY)) {\n return record;\n }\n\n defineProperty(record, UNSAFE_KEY, {\n value: record[UNSAFE_KEY],\n writable: true,\n enumerable: false,\n configurable: true,\n });\n\n return record;\n}\n\n/**\n * Write one field of a record core BUILDS under a key it did not choose.\n *\n * ⚑ The rule this exists to enforce: **a caller's object contributes DATA, and\n * nothing else.** No trap, no accessor, no inherited member of a bag handed to\n * the router may change what the router ends up holding — which is what\n * \"treat it as a pure dictionary\" means on the WRITE side. `Object.keys` and\n * the one-read-per-key discipline (#1854 / #1899) already say it on the read\n * side; this is the other half.\n *\n * Plain `target[key] = value` cannot say it. `[[Set]]` walks the prototype\n * chain first, so a key that resolves to an accessor or a non-writable data\n * property up there is HIJACKED — the write dispatches into application code\n * (or is silently dropped in sloppy mode, and throws in a module). The key's\n * provenance is irrelevant: `SegmentMatcher` writes a name straight off the\n * ROUTE TABLE, so `id` / `tab` / `page` are as exposed as `__proto__` (#1852),\n * and a name-based skip therefore cannot close it.\n *\n * `Object.defineProperty` CAN say it — it ignores the chain entirely — but it\n * measures ~100 ns per field against ~0 for a store, which is why #1852 priced\n * it as unaffordable on a path that runs per navigation and per `<Link>`\n * render.\n *\n * So the write is guarded rather than replaced: **ask the chain first, and pay\n * only where it answers.** In a pristine environment `in` answers `false` for\n * every name an application routes under, so the store is taken and nothing is\n * paid. It covers both halves of the hazard, which a `__proto__` name test does\n * not: an accessor (getter-only THROWS, getter+setter silently diverts the\n * value) and a **non-writable** data property. Verified on all four shapes plus\n * the overwrite cases.\n *\n * ⚠ It asks `key in target`, NOT `key in Object.prototype`, and the difference\n * is the whole robustness of the primitive rather than a style choice. The\n * cheaper form is right only while every target is a fresh `{}`, i.e. while its\n * chain IS `Object.prototype` — measured, a target inheriting the accessor from\n * anywhere else walks straight past that predicate and throws. Asking the\n * object\n * being written to cannot be wrong for any target. Measured cost of the\n * difference, measured when the two forms were compared directly: a wash on\n * every arc, bought for a predicate with no precondition. ⚠ Those figures\n * predate both the `!hasOwn` term and the restored channel skips, and the\n * number\n * that supersedes them is below — the whole guard sits under the noise floor,\n * so\n * the choice between the two predicates cannot be visible in it.\n *\n * ⚑ **`&& !hasOwn`, and that second term is not an optimisation — it is what\n * keeps this a guarded WRITE instead of a redefinition.** When the key is\n * already an OWN property of the target, `[[Set]]` finds it and never consults\n * the chain, so a plain store is both safe AND semantically right there.\n * `defineProperty` is not: it replaces the whole DESCRIPTOR with this\n * function's\n * fixed one, and that has three measured consequences.\n *\n * - It **throws where a plain store works**: a `configurable: false` own key\n * (a sealed target, an array's `length`) refuses `defineProperty` while\n * accepting an assignment.\n * - It **silently unlocks**: an own `writable: false` key was overwritten and\n * came back writable, and an own `enumerable: false` key came back\n * enumerable — a \"guarded write\" that also removes the guard.\n * - It **changed a shipped shape**, which is how this was caught rather than\n * reasoned about. `RouterError`'s own `stack` is a non-enumerable accessor;\n * `wrapSyncError` passes `stack` through here, so every error built from a\n * thrown one gained an own enumerable `stack`. `Object.keys(err)` changed,\n * and two errors differing only in stack stopped comparing equal under\n * `isDeepStrictEqual` / `toEqual`. The two arms of `rethrowAsRouterError`\n * disagreed with each other, because one of them assigns.\n *\n * `in` answers `false` for a fresh bag's new key and short-circuits, so\n * `hasOwn`\n * runs only on the rare branch it disambiguates. ⚠ That short-circuit does NOT\n * leave the hot path untouched — one dictionary lookup per written field is the\n * price, and it is measured below.\n *\n * ⚠ The alternative that looks equivalent and is not: a prototype-less target.\n * It also closes the axis, and it costs far MORE, because the price is not on\n * the write at all — V8 puts such an object in dictionary mode, so every later\n * READ of the bag pays. Re-measured on the SHIPPED tree rather than carried\n * over from an earlier one: `buildPath` goes **+65.4 %** (one path slot) and\n * **+36.2 %** (slot + query). `{ __proto__: null }` as a literal is no better\n * (76 ns vs 70 ns for `Object.create(null)`, against 7.5 ns plain).\n *\n * ⚑ **The guard COSTS, and \"not measurable\" is a resolution artefact.** Medians\n * of five floor at an A/A of 5-6 %, which hides it; on a quiet machine this\n * harness floors at 0.1-1.7 %, and at that resolution the cost is plain.\n * Same-session A/B, ALTERNATING PROCESSES (two\n * copies of the module in one process is not a valid A/B), medians of 20 pairs,\n * against the SHIPPED bundle rather than `src`, each arc's own A/A floor in\n * brackets:\n *\n * buildPath, splat param 232.4 -> 260.3 ns +12.0 % (0.7 %)\n * isActiveRoute, exact 117.5 -> 125.4 ns +6.8 % (0.1 %)\n * matchPath, path params 664.0 -> 693.8 ns +4.5 % (0.8 %)\n * buildPath, static 97.5 -> 99.2 ns +1.7 % (1.7 %)\n * buildPath, one path slot 145.0 -> 140.5 ns -3.1 % (1.0 %)\n * isActiveRoute, sibling 38.4 -> 38.3 ns -0.3 % (0.3 %)\n *\n * Isolated by building the tree with the predicate replaced by `false`: it is\n * worth -6.1 % on the splat arc and -7.5 % on the exact one, i.e. the whole of\n * the regression there; the rest of `matchPath`'s is `withoutUnsafeKey`\n * (#1904), -2.1 %.\n *\n * ⚠ The old claim was less a bad measurement than a measurement of the WRONG\n * ARCS. `warm-params` and the sibling arm genuinely do not move — those are the\n * two it sampled — while the splat and exact arms do. Sampling what does not\n * move and generalising to \"not measurable\" is the same trap the reachability\n * arguments elsewhere in this file are written against.\n *\n * The price is ACCEPTED, deliberately, and three cheaper forms were measured\n * and rejected before accepting it:\n *\n * - asking a captured `Object.prototype` instead of the target, so the `in`\n * receiver is monomorphic: every arc inside the A/A floor. The cost is the\n * dictionary lookup, not who is asked.\n * - a prototype-less accumulator in `normalizeChannel` published through\n * `publishRecord`: **+134 % … +284 %** — the dictionary-mode price above,\n * now measured end to end rather than argued.\n * - an optimistic plain store repaired afterwards (`hasOwn` + `try`/`catch`):\n * -3.5 % and -2.8 % on two arcs but **+8.3 %** on a third, and it re-opens\n * the descriptor question `&& !hasOwn(target, key)` exists to close.\n *\n * ⚠ **CodSpeed reports this change at -13.83 %, and that is not the shipped\n * cost.** The gap is measured, not assumed. The suite runs\n * `tsx tests/benchmarks/run.ts` — against `src`, unbundled — so its flamegraph\n * carries ESM module-namespace getter frames (`get (ingest.ts)`, 2.67 % of one\n * arc) that the bundle does not have: `grep -c 'get: ()' dist/esm/index.mjs` is\n * 0. `Simulation` mode additionally over-counts instructions a superscalar CPU\n * hides. On the worst-reported arc the sign inverts — -17.25 % simulated,\n * -3.1 % (i.e. FASTER) in the bundle.\n *\n * A prototype-less channel additionally changes a PUBLISHED shape:\n * `state.params` would stop inheriting from `Object.prototype`, which reds\n * tests across **17 packages**, none of them for a behavioural reason.\n *\n * ⚠ **The package count is the half that holds; the TEST count is not restated,\n * because it moves with the tier while the shape does not.** Published as \"263\n * in 15\", corrected to 352/17 by a full-monorepo run, and 374/17 when re-run on\n * 2026-09-04 — three figures, one answer. Re-run the mutation rather than trust\n * a number here: make the two channel singletons and the channel accumulators\n * `Object.create(null)` and run the monorepo. It was never a question of which\n * sites to mutate, because 17 came back every time.\n *\n * The qualitative half is the load-bearing one: the failures are\n * `AssertionError`, none are thrown; they are `toStrictEqual` cells plus a\n * handful of explicit prototype pins; and NO `toEqual` / `toMatchObject` cell\n * moves, which is the internal control that only the prototype axis shifted.\n *\n * ⚑ `defineProperty` also makes `__proto__` an ordinary own key rather than a\n * write that swaps the target's prototype — which is why the `claim.write`\n * (#1191), `assignParam` (#855) and custom-field (#1788) special cases could be\n * replaced by this one primitive instead of kept beside it.\n *\n * ⚠ **It does NOT decide whether that key is PUBLISHED, and the two questions\n * were briefly conflated here.** The channel copy sites in `helpers.ts` still\n * drop `__proto__` before it reaches `state.params` / `state.search`, and that\n * skip is orthogonal to this primitive: a bag core hands BACK carrying the key\n * is a prototype-swap primitive for any consumer that merges it with\n * `Object.assign` — measured, `?__proto__` alone yields `null` and\n * `?__proto__=1&__proto__=2` an array, and the inherited setter accepts both.\n * `getDependenciesApi.getAll()` deletes the same key for the same reason and in\n * those words. Where the record does NOT escape to a merging consumer — a\n * route's custom fields, a plugin's context namespace — the key stays as data,\n * which is what #1788 and #1191 are about.\n */\nexport function putField<V>(\n target: Record<string, V>,\n key: string,\n value: V,\n): void {\n if (key in target && !hasOwn(target, key)) {\n defineProperty(target, key, {\n value,\n writable: true,\n enumerable: true,\n configurable: true,\n });\n } else {\n target[key] = value;\n }\n}\n\n/**\n * {@link putField} for a whole source record — what `Object.assign` would do,\n * without the hazard.\n *\n * ⚑ It exists because `Object.assign` IS the hazard, written in a form a census\n * keyed on `dst[key] = value` cannot see. It copies with `[[Set]]`, one key at\n * a\n * time, so every argument in {@link putField}'s docblock applies to it verbatim\n * — and it is the reason this class needed a second look after the obvious\n * sweep: the matcher's junction walk builds `childParams` with a computed-key\n * literal (safe: that DEFINES) and then commits it with `Object.assign` (not).\n * Measured with an ambient setter under a route's own param name, the route\n * still MATCHED and `state.params` came back empty — the URL's parameter gone,\n * with no error anywhere.\n *\n * `Object.entries` for the walk: it hands back the value it already read, so\n * there is exactly ONE read per key and no window for a drifting accessor\n * between the test and the use (#1899). It is also the idiom the sibling copy\n * loops use.\n *\n * ⚠ **Two things it does NOT buy, both measured.**\n *\n * - It is **not** a filter against a lying Proxy source. `ownKeys` is asked\n * first, so a key that list does not contain cannot appear — but a source\n * whose `ownKeys` DOES name a phantom and whose descriptor trap calls it\n * enumerable gets that phantom copied, identically to `Object.assign`. The\n * #1854 protection is narrower than \"the trap is never consulted\".\n * - It is **not** a drop-in for `Object.assign`. `Object.entries` is\n * string-keyed, so own enumerable SYMBOL entries are dropped where\n * `Object.assign` copies them. That matches core's stated policy for the\n * channels (\"symbols are dropped, always\") and is a real behaviour difference\n * from `Object.assign` at one call site (`persistent-params`' factory). ⚠ It also disagrees with `publishRecord`\n * two functions up, which spreads and therefore keeps symbols — the same\n * internal split `helpers.ts` records as the #1792 defect.\n */\nexport function copyFields<V>(\n target: Record<string, V>,\n source: Record<string, V>,\n): void {\n for (const [key, value] of objectEntries(source)) {\n putField(target, key, value);\n }\n}\n","// packages/core/src/RouterError.ts\n\nimport { errorCodes, UNSAFE_KEY } from \"./constants\";\nimport { putField } from \"./utils/ingest\";\n\n/** Captured like the deciding seven, but this one BUILDS the guarantee (#2073). */\nconst freeze = Object.freeze;\n\nconst objectEntries = Object.entries;\nconst objectValues = Object.values;\n\n// Pre-compute Set of error code values for O(1) lookup in setCode()\n// This avoids creating array and doing linear search on every setCode() call\n// ⚑ Captured at module load, for the reason `helpers.ts` states over its own\n// three: an application can re-point `Object.hasOwn` after boot, and this one\n// gates a PUBLIC read (#1829). ⚠ The file's four other intrinsic reads are still\n// raw — #1971 owns that sweep, and a point fix here would be the N+1 it exists\n// to prevent; capturing the read this commit ADDS is not the same thing as\n// sweeping the ones it found.\nconst hasOwn = Object.hasOwn;\n\nconst errorCodeValues = new Set(objectValues(errorCodes));\n\n// Reserved built-in properties - throw error if user tries to set these\nconst reservedProperties = new Set([\"code\", \"segment\", \"path\"]);\n\n// Reserved method names - silently ignore attempts to overwrite these\nconst reservedMethods = new Set([\n \"setCode\",\n \"setErrorInstance\",\n \"setAdditionalFields\",\n \"hasField\",\n \"getField\",\n \"toJSON\",\n]);\n\n/**\n * Freeze a `RouterError` at the moment it stops being core's to change — the\n * throw (#1960).\n *\n * ⚑ At the THROW, never in the constructor. `RouterError` publishes three\n * mutators (`setCode`, `setErrorInstance`, `setAdditionalFields`) with worked\n * examples in the wiki, and `rethrowAsRouterError` copies an error and re-codes\n * the copy before throwing it. Freezing on construction was measured: it reds\n * across the tier and concentrates in this class's own suite, because it\n * withdraws published API from errors a CONSUMER builds. Freezing here\n * withdraws exactly one thing — writing to an error core threw at you — which\n * #1606 already established is corruption when the instance is one of the\n * cached, process-shared ones, and which a repository-wide sweep of every\n * `catch` binding found nobody doing.\n *\n * ⚠ Only for errors core CONSTRUCTED. A re-thrown foreign error stays untouched:\n * freezing someone else's object on the way through is the hazard, not the fix.\n */\nexport function freezeThrownError<E extends RouterError>(error: E): E {\n return freeze(error);\n}\n\nexport class RouterError extends Error {\n [key: string]: unknown;\n\n // Using public properties to ensure structural compatibility\n // with the `RouterError` interface in `types/base.ts`\n readonly segment: string | undefined;\n readonly path: string | undefined;\n\n // Note: code appears to be writable but setCode() should be used\n // to properly update both code and message together\n code: string;\n\n /**\n * Creates a new RouterError instance.\n *\n * The options object accepts built-in fields (message, segment, path)\n * and any additional custom fields, which will all be attached to the error instance.\n *\n * @param code - The error code (e.g., \"ROUTE_NOT_FOUND\", \"CANNOT_ACTIVATE\")\n * @param options - Optional configuration object\n * @param options.message - Custom error message (defaults to code if not provided)\n * @param options.segment - The route segment where the error occurred\n * @param options.path - The full path where the error occurred\n *\n * @example\n * ```typescript\n * // Basic error\n * const err1 = new RouterError(\"ROUTE_NOT_FOUND\");\n *\n * // Error with custom message\n * const err2 = new RouterError(\"ERR\", { message: \"Something went wrong\" });\n *\n * // Error with context and custom fields\n * const err3 = new RouterError(\"CANNOT_ACTIVATE\", {\n * message: \"Insufficient permissions\",\n * segment: \"admin\",\n * path: \"/admin/users\",\n * userId: \"123\" // custom field\n * });\n * ```\n */\n constructor(\n code: string,\n {\n message,\n segment,\n path,\n ...rest\n }: {\n [key: string]: unknown;\n message?: string | undefined;\n segment?: string | undefined;\n path?: string | undefined;\n } = {},\n ) {\n super(message ?? code);\n\n // Subclasses don't auto-set `name`; without this `error.name` inherits\n // \"Error\", breaking `error.name === \"RouterError\"` checks at catch sites that\n // can't `instanceof` across bundle boundaries.\n this.name = \"RouterError\";\n\n this.code = code;\n this.segment = segment;\n this.path = path;\n\n // Assign custom fields, checking reserved properties and filtering out reserved method names\n // Issue #39: Throw for reserved properties to match setAdditionalFields behavior\n for (const [key, value] of objectEntries(rest)) {\n if (reservedProperties.has(key)) {\n throw atRouterError.type`Cannot set reserved property \"${key}\"`;\n }\n\n // ⚑ `UNSAFE_KEY` skipped for the reason the state channels give (#1852):\n // this instance is a container core hands out and `toJSON` serializes, so\n // an own `\"__proto__\"` on it is a prototype-swap primitive for whoever\n // merges or re-parses the error — measured, a guard throwing a plain\n // object put the key into `JSON.stringify(err)`.\n //\n // ⚠ Plain assignment is the alternative that looks equivalent and is\n // worse than losing the key: measured, `new RouterError(\"X\", bag)` swaps\n // the INSTANCE's prototype and `instanceof RouterError` answers `false`.\n // `putField` keeps the instance intact; the skip keeps the key off a\n // container someone will merge.\n if (key !== UNSAFE_KEY && !reservedMethods.has(key)) {\n // ⚑ `putField` (#1852). The target is `this`, whose chain runs\n // `RouterError.prototype → Error.prototype → Object.prototype`, and the\n // key comes from the caller's bag. `reservedProperties` / `reservedMethods`\n // above filter by NAME and therefore cannot see an ambient one: measured,\n // an accessor under a custom field name threw out of the constructor,\n // and a setter left the field non-own while reading back the hijacked\n // value.\n putField(this as unknown as Record<string, unknown>, key, value);\n }\n }\n }\n\n /**\n * Updates the error code and conditionally updates the message.\n *\n * If the current message is one of the standard error code values\n * (e.g., \"ROUTE_NOT_FOUND\", \"SAME_STATES\"), it will be replaced with the new code.\n * This allows keeping error messages in sync with codes when using standard error codes.\n *\n * If the message is custom (not a standard error code), it will be preserved.\n *\n * @param newCode - The new error code to set\n *\n * @example\n * // Message follows code (standard error code as message)\n * const err = new RouterError(\"ROUTE_NOT_FOUND\", { message: \"ROUTE_NOT_FOUND\" });\n * err.setCode(\"CUSTOM_ERROR\"); // message becomes \"CUSTOM_ERROR\"\n *\n * @example\n * // Custom message is preserved\n * const err = new RouterError(\"ERR\", { message: \"Custom error message\" });\n * err.setCode(\"NEW_CODE\"); // message stays \"Custom error message\"\n */\n setCode(newCode: string): void {\n this.code = newCode;\n\n // Only update message if it's a standard error code value (not a custom message)\n if (errorCodeValues.has(this.message)) {\n this.message = newCode;\n }\n }\n\n /**\n * Copies properties from another Error instance to this RouterError.\n *\n * This method updates the message, cause, and stack trace from the provided error.\n * Useful for wrapping native errors while preserving error context.\n *\n * @param err - The Error instance to copy properties from\n * @throws {TypeError} If err is null or undefined\n *\n * @example\n * ```typescript\n * const routerErr = new RouterError(\"TRANSITION_ERR\");\n * try {\n * // some operation that might fail\n * } catch (nativeErr) {\n * routerErr.setErrorInstance(nativeErr);\n * throw routerErr;\n * }\n * ```\n */\n setErrorInstance(err: Error): void {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!err) {\n throw atSetErrorInstance.type`err parameter is required and must be an Error instance`;\n }\n\n this.message = err.message;\n // ⚑ `putField` for THIS slot only, and the set was recounted rather than\n // assumed (#2142 / #1852). `message` and `stack` are already own on every\n // instance — `super(message ?? code)` always passes a string, and the\n // `Error` constructor installs `stack` — so their assignments define own\n // data and cannot reach the chain. `cause` has no own slot unless the\n // constructor was given one, and this class never is.\n //\n // ⚠ Measured on the plain form: an ambient `Object.prototype.cause` setter\n // took the value and left `cause` absent, and a getter-only one made this\n // line THROW — from inside the method that wraps a native failure into the\n // router's own error, so the throw would replace the error being reported.\n putField(this as unknown as Record<string, unknown>, \"cause\", err.cause);\n this.stack = err.stack ?? \"\";\n }\n\n /**\n * Adds custom fields to the error object.\n *\n * This method allows attaching arbitrary data to the error for debugging or logging purposes.\n * All fields become accessible as properties on the error instance and are included in JSON serialization.\n *\n * Reserved method names (setCode, setErrorInstance, setAdditionalFields, hasField, getField, toJSON)\n * are automatically filtered out to prevent accidental overwriting of class methods.\n *\n * @param fields - Object containing custom fields to add to the error\n *\n * @example\n * ```typescript\n * const err = new RouterError(\"CANNOT_ACTIVATE\");\n * err.setAdditionalFields({\n * userId: \"123\",\n * attemptedRoute: \"/admin\",\n * reason: \"insufficient permissions\"\n * });\n *\n * console.log(err.userId); // \"123\"\n * console.log(JSON.stringify(err)); // includes all custom fields\n * ```\n */\n setAdditionalFields(fields: Record<string, unknown>): void {\n // Assign fields, throwing for reserved properties, silently ignoring methods\n for (const [key, value] of objectEntries(fields)) {\n if (reservedProperties.has(key)) {\n throw atSetAdditionalFields.type`Cannot set reserved property \"${key}\"`;\n }\n\n // ⚑ `UNSAFE_KEY` skipped, and `putField` rather than assignment, for the\n // reasons the constructor's own field loop states (#1852). Not restated\n // here — one mechanism, one explanation.\n if (key !== UNSAFE_KEY && !reservedMethods.has(key)) {\n // ⚑ `putField` (#1852). The target is `this`, whose chain runs\n // `RouterError.prototype → Error.prototype → Object.prototype`, and the\n // key comes from the caller's bag. `reservedProperties` / `reservedMethods`\n // above filter by NAME and therefore cannot see an ambient one: measured,\n // an accessor under a custom field name threw out of the constructor,\n // and a setter left the field non-own while reading back the hijacked\n // value.\n putField(this as unknown as Record<string, unknown>, key, value);\n }\n }\n }\n\n /**\n * Checks if a custom field exists on the error object.\n *\n * This method checks for both custom fields added via setAdditionalFields()\n * and built-in fields (code, message, segment, etc.).\n *\n * @param key - The field name to check\n * @returns `true` if the field exists, `false` otherwise\n *\n * @example\n * ```typescript\n * const err = new RouterError(\"ROUTE_NOT_FOUND\", {\n * segment: \"users\",\n * path: \"/users/7\",\n * });\n * err.setAdditionalFields({ userId: \"123\" });\n *\n * err.hasField(\"code\"); // true\n * err.hasField(\"segment\"); // true\n * err.hasField(\"path\"); // true\n * err.hasField(\"userId\"); // true\n * err.hasField(\"unknown\"); // false\n * ```\n */\n hasField(key: string): boolean {\n // ⚑ `hasOwn`, not `in` (#1829). `in` walks the prototype chain, so this\n // answered `true` for `Object.prototype`'s twelve members and for the\n // class's own six methods — eighteen names for an error carrying ONE field\n // and `toString` / `constructor` are ordinary strings arriving from a config\n // key, a route param name or a serialized payload.\n //\n // ⚠ NOT `toJSON`'s `excludeKeys`, which the issue proposed. Measured against\n // the docstring above: that set excludes `code`, `segment` and `path`,\n // which this method documents as answering `true`. The two functions ask\n // different questions (what to SERIALIZE vs what the error CARRIES), so\n // agreeing on those three is the contract and diverging on `message` /\n // `stack` / `name` is not drift.\n return hasOwn(this, key);\n }\n\n /**\n * Retrieves a custom field value from the error object.\n *\n * This method can access both custom fields and built-in fields.\n * Returns `undefined` if the field doesn't exist.\n *\n * @param key - The field name to retrieve\n * @returns The field value, or `undefined` if it doesn't exist\n *\n * @example\n * ```typescript\n * const err = new RouterError(\"ERR\");\n * err.setAdditionalFields({ userId: \"123\", role: \"admin\" });\n *\n * err.getField(\"userId\"); // \"123\"\n * err.getField(\"role\"); // \"admin\"\n * err.getField(\"code\"); // \"ERR\" (built-in field)\n * err.getField(\"unknown\"); // undefined\n * ```\n */\n getField(key: string): unknown {\n // Reachable without `hasField` — a consumer may just read — so the same gate\n // stands here rather than being implied by the predicate (#1829). Before\n // this, `getField(\"toString\")` handed back the native function.\n return hasOwn(this, key) ? this[key] : undefined;\n }\n\n /**\n * Serializes the error to a JSON-compatible object.\n *\n * This method is automatically called by JSON.stringify() and includes:\n * - Built-in fields: code, message, segment (if set), path (if set)\n * - All custom fields added via setAdditionalFields() or constructor\n * - Excludes: stack trace (for security/cleanliness)\n *\n * @returns A plain object representation of the error, suitable for JSON serialization\n *\n * @example\n * ```typescript\n * const err = new RouterError(\"ROUTE_NOT_FOUND\", {\n * message: \"Route not found\",\n * path: \"/admin/users/123\"\n * });\n * err.setAdditionalFields({ userId: \"123\" });\n *\n * JSON.stringify(err);\n * // {\n * // \"code\": \"ROUTE_NOT_FOUND\",\n * // \"message\": \"Route not found\",\n * // \"path\": \"/admin/users/123\",\n * // \"userId\": \"123\"\n * // }\n * ```\n */\n toJSON(): Record<string, unknown> {\n const result: Record<string, unknown> = {\n code: this.code,\n message: this.message,\n };\n\n if (this.segment !== undefined) {\n result.segment = this.segment;\n }\n if (this.path !== undefined) {\n result.path = this.path;\n }\n\n // add all public fields\n // Using Set.has() for O(1) lookup instead of Array.includes() O(n)\n // Overall complexity: O(n) instead of O(n*m)\n const excludeKeys = new Set([\n \"code\",\n \"message\",\n \"segment\",\n \"path\",\n \"stack\",\n // `name` is now an own enumerable prop (constructor sets it to\n // \"RouterError\"); it's class metadata, not a custom field — keep it out of\n // the serialized output (preserves toJSON shape).\n \"name\",\n ]);\n\n for (const key in this) {\n if (hasOwn(this, key) && !excludeKeys.has(key)) {\n // ⚑ `putField` (#1852): `result` is a fresh literal and the keys are the\n // user's own error fields. Measured, a setter under one of them made the\n // field vanish from the serialized output with no error at all.\n putField(result, key, this[key]);\n }\n }\n\n return result;\n }\n}\n\n/**\n * A receiver a reader can IMPORT, plus this package's own name for a refusal no\n * call reaches (#1845). The door beside it is an unconstrained `string`, so the\n * type is not the guard — `message-prefix-authority-1845` judges the argument.\n */\nexport type Receiver =\n \"router\" | \"RouterError\" | \"cloneRouter\" | \"validation-plugin\";\n\ntype Tag<E extends Error> = (\n strings: TemplateStringsArray,\n ...values: unknown[]\n) => E;\n\n/** One member per constructor the refusal surface holds. */\nexport interface Raiser {\n /**\n * ⚠ `type` and `plain` also take `ErrorOptions` and RETURN the tag, because\n * `cause` cannot be attached afterwards: measured, the constructor defines it\n * non-enumerable and an assignment defines it enumerable.\n */\n type: Tag<TypeError> & ((options: ErrorOptions) => Tag<TypeError>);\n plain: Tag<Error> & ((options: ErrorOptions) => Tag<Error>);\n ref: Tag<ReferenceError>;\n range: Tag<RangeError>;\n /**\n * A coded `RouterError`, frozen for the throw (#1960) — so a site using this\n * flavour needs no `freezeThrownError` of its own. `fields` carries the bag's\n * other entries; `message` is not among them, since the template writes it.\n */\n code: (\n code: string,\n fields?: Readonly<Record<string, unknown>>,\n ) => Tag<RouterError>;\n}\n\n/** A refusal unreachable from caller input: no bracket, an explicit marker. */\nexport interface InternalDefect {\n plain: Tag<Error>;\n}\n\nconst interpolate = (\n strings: TemplateStringsArray,\n values: readonly unknown[],\n): string => {\n let text = strings[0];\n\n for (const [index, value] of values.entries()) {\n text += String(value) + strings[index + 1];\n }\n\n return text;\n};\n\n/**\n * Build the refusals of one door, so the head is written once per module rather\n * than once per throw (#2487).\n *\n * ```ts\n * const at = raiser(\"router\", \"buildPath\");\n *\n * throw at.type`Missing required param '${name}'`;\n * throw at.code(errorCodes.ROUTE_NOT_FOUND, { routeName })`No route '${routeName}'`;\n * ```\n *\n * ⚠ It RETURNS the error rather than throwing it, so the site keeps `throw` —\n * which greps, narrows types natively, and leaves room to tag the error between\n * construction and throw, as the search-params config fault does.\n *\n * ⚠ Omit `door` only where several doors reach one raiser; a head that names a\n * door the caller never called is the defect this exists to remove.\n */\nexport function raiser(receiver: Receiver, door?: string): Raiser {\n // An empty door reads as the bare form rather than printing `[router.]`, a\n // head that looks like a door without naming one.\n const head =\n door === undefined || door === \"\"\n ? `[${receiver}] `\n : `[${receiver}.${door}] `;\n const message = (\n strings: TemplateStringsArray,\n values: readonly unknown[],\n ): string => head + interpolate(strings, values);\n\n const flavour = <E extends Error>(\n build: (text: string, options?: ErrorOptions) => E,\n ): Tag<E> & ((options: ErrorOptions) => Tag<E>) =>\n ((\n first: TemplateStringsArray | ErrorOptions,\n ...values: readonly unknown[]\n ) =>\n Array.isArray(first)\n ? build(message(first as TemplateStringsArray, values))\n : (strings: TemplateStringsArray, ...rest: readonly unknown[]) =>\n build(message(strings, rest), first as ErrorOptions)) as Tag<E> &\n ((options: ErrorOptions) => Tag<E>);\n\n return {\n type: flavour((text, options) => new TypeError(text, options)),\n plain: flavour((text, options) => new Error(text, options)),\n ref: (strings, ...values) => new ReferenceError(message(strings, values)),\n range: (strings, ...values) => new RangeError(message(strings, values)),\n code:\n (code, fields) =>\n (strings, ...values) =>\n freezeThrownError(\n new RouterError(code, {\n ...fields,\n message: message(strings, values),\n }),\n ),\n };\n}\nconst atRouterError = raiser(\"RouterError\");\nconst atSetErrorInstance = raiser(\"RouterError\", \"setErrorInstance\");\nconst atSetAdditionalFields = raiser(\"RouterError\", \"setAdditionalFields\");\n\n/**\n * A defect a caller cannot provoke. Unbracketed on purpose: there is no door to\n * name, and a marker is greppable where a bare sentence is not (#1845).\n */\nexport const internalDefect: InternalDefect = {\n plain: (strings, ...values) =>\n new Error(\n `Internal error (please report): ${interpolate(strings, values)}`,\n ),\n};\n"],"mappings":"AA0BA,MAAaE,EAAkC,OAAO,OAAO,CAC3D,mBAAoB,cACpB,uBAAwB,yBACxB,uBAAwB,kBACxB,gBAAiB,kBACjB,YAAa,cACb,kBAAmB,oBACnB,gBAAiB,kBACjB,eAAgB,iBAChB,qBAAsB,YACtB,gBAAiB,WACjB,gBAAiB,kBACjB,kCAAmC,oCACnC,qBAAsB,uBACtB,wBAAyB,0BACzB,mBAAoB,cACpB,cAAe,eACjB,CAAC,EAMYC,EAAgB,yBAyBhBC,EAAa,YAEbC,EAAuB,OAAO,OAAO,CAChD,eACF,CAAC,EAMYC,EAA4B,OAAO,OAAO,CACrD,aAAc,UACd,YAAa,SACb,iBAAkB,oBAClB,yBAA0B,2BAC1B,kBAAmB,qBACnB,mBAAoB,sBACpB,iBAAkB,mBACpB,CAAC,EAMYC,EAAyB,OAAO,OAAO,CAClD,aAAc,SACd,YAAa,QACb,iBAAkB,UAClB,yBAA0B,iBAC1B,kBAAmB,WACnB,mBAAoB,YACpB,iBAAkB,SACpB,CAAC,EAEYC,EAAiB,OAAO,OAAO,CAC1C,gBAAiB,IACjB,WAAY,GACZ,aAAc,IACd,cAAe,IACf,qBAAsB,GACxB,CAAU,EAEGC,EAAgD,OAAO,OAAO,CAAC,CAAC,EAQhEC,EAAgD,OAAO,OAAO,CAAC,CAAC,EAuBhEC,EAA8C,OAAO,OAAO,CAAC,CAAC,EAErEC,EAAwB,OAAO,OAAO,CAC1C,YAAa,OAAO,OAAO,CAAC,CAAC,EAC7B,UAAW,OAAO,OAAO,CAAC,CAAC,EAC3B,aAAc,EAChB,CAAC,EAEYC,EAAqB,OAAO,OAAO,CAC9C,MAAO,aACP,OAAQ,UACR,SAAUD,CACZ,CAAC,EC7GKE,EAAe,OAAO,OAEtBd,EAAgB,OAAO,QAkB7B,SAAgBgB,GAAoC,CAClD,OAAOF,EAAa,IAAI,CAC1B,CAyBA,SAAgBG,EAAiB,EAA8C,CAC7E,MAAO,CAAE,GAAGC,CAAO,CACrB,CAQA,MAAMC,EAAiB,OAAO,eACxBlB,EAAS,OAAO,OA2CtB,SAAgBoB,EACd,EACmB,CAYnB,OAXKpB,EAAOqB,EAAA,WAAkB,GAI9BH,EAAeG,EAAQlB,EAAY,CACjC,MAAOkB,EAAOlB,GACd,SAAU,GACV,WAAY,GACZ,aAAc,EAChB,CAAC,EAEMkB,CACT,CAsKA,SAAgBC,EACd,EACA,EACA,EACM,CACFC,KAAOC,GAAU,CAACxB,EAAOwB,EAAQD,CAAG,EACtCL,EAAeM,EAAQD,EAAK,CAC1B,QACA,SAAU,GACV,WAAY,GACZ,aAAc,EAChB,CAAC,EAED,EAAOA,GAAOE,CAElB,CAqCA,SAAgBC,EACd,EACA,EACM,CACN,IAAK,GAAM,CAACH,EAAKE,KAAU1B,EAAckB,CAAM,EAC7CK,EAASE,EAAQD,EAAKE,CAAK,CAE/B,CCjYA,MAAME,EAAS,OAAO,OAEhBC,EAAgB,OAAO,QACvBC,EAAe,OAAO,OAUtBC,EAAS,OAAO,OAEhBC,EAAkB,IAAI,IAAIF,EAAa5B,CAAU,CAAC,EAGlD+B,EAAqB,IAAI,IAAI,CAAC,OAAQ,UAAW,MAAM,CAAC,EAGxDC,EAAkB,IAAI,IAAI,CAC9B,UACA,mBACA,sBACA,WACA,WACA,QACF,CAAC,EAoBD,SAAgBC,EAAyC,EAAa,CACpE,OAAOP,EAAOQ,CAAK,CACrB,CAEA,IAAaC,EAAb,cAAiC,KAAM,CAKrC,QACA,KAIA,KA+BA,YACE,EACA,CACE,UACA,UACA,OACA,GAAGC,GAMD,CAAC,EACL,CACA,MAAMC,GAAWC,CAAI,EAKrB,KAAK,KAAO,cAEZ,KAAK,KAAOA,EACZ,KAAK,QAAUC,EACf,KAAK,KAAOC,EAIZ,IAAK,GAAM,CAAClB,EAAKE,KAAUG,EAAcS,CAAI,EAAG,CAC9C,GAAIL,EAAmB,IAAIT,CAAG,EAC5B,KAAM,GAAc,IAAI,iCAAiCA,EAAI,GAc3DA,IAAA,aAAsB,CAACU,EAAgB,IAAIV,CAAG,GAQhDD,EAAS,KAA4CC,EAAKE,CAAK,CAEnE,CACF,CAuBA,QAAQ,EAAuB,CAC7B,KAAK,KAAOiB,EAGRX,EAAgB,IAAI,KAAK,OAAO,IAClC,KAAK,QAAUW,EAEnB,CAsBA,iBAAiB,EAAkB,CAEjC,GAAI,CAACC,EACH,KAAM,GAAmB,IAAI,0DAG/B,KAAK,QAAUA,EAAI,QAYnBrB,EAAS,KAA4C,QAASqB,EAAI,KAAK,EACvE,KAAK,MAAQA,EAAI,OAAS,EAC5B,CA0BA,oBAAoB,EAAuC,CAEzD,IAAK,GAAM,CAACpB,EAAKE,KAAUG,EAAcgB,CAAM,EAAG,CAChD,GAAIZ,EAAmB,IAAIT,CAAG,EAC5B,KAAM,GAAsB,IAAI,iCAAiCA,EAAI,GAMnEA,IAAA,aAAsB,CAACU,EAAgB,IAAIV,CAAG,GAQhDD,EAAS,KAA4CC,EAAKE,CAAK,CAEnE,CACF,CA0BA,SAAS,EAAsB,CAa7B,OAAOK,EAAO,KAAMP,CAAG,CACzB,CAsBA,SAAS,EAAsB,CAI7B,OAAOO,EAAO,KAAMP,CAAG,EAAI,KAAKA,GAAO,IAAA,EACzC,CA6BA,QAAkC,CAChC,IAAMsB,EAAkC,CACtC,KAAM,KAAK,KACX,QAAS,KAAK,OAChB,EAEI,KAAK,UAAY,IAAA,KACnB,EAAO,QAAU,KAAK,SAEpB,KAAK,OAAS,IAAA,KAChB,EAAO,KAAO,KAAK,MAMrB,IAAMC,EAAc,IAAI,IAAI,CAC1B,OACA,UACA,UACA,OACA,QAIA,MACF,CAAC,EAED,IAAK,IAAMvB,KAAO,KACZO,EAAO,KAAMP,CAAG,GAAK,CAACuB,EAAY,IAAIvB,CAAG,GAI3CD,EAASuB,EAAQtB,EAAK,KAAKA,EAAI,EAInC,OAAOsB,CACT,CACF,EA0CA,MAAME,GACJ,EACA,IACW,CACX,IAAIC,EAAOC,EAAQ,GAEnB,IAAK,GAAM,CAACC,EAAOzB,KAAU0B,EAAO,QAAQ,EAC1C,GAAQ,OAAO1B,CAAK,EAAIwB,EAAQC,EAAQ,GAG1C,OAAOF,CACT,EAoBA,SAAgBI,EAAO,EAAoB,EAAuB,CAGhE,IAAMC,EACJC,IAAS,IAAA,IAAaA,IAAS,GAC3B,IAAIC,EAAS,IACb,IAAIA,EAAS,GAAGD,EAAK,IACrBhB,GACJ,EACA,IACWe,EAAON,EAAYE,EAASE,CAAM,EAEzCK,EACJ,KAGE,EACA,GAAGL,IAEH,MAAM,QAAQM,CAAK,EACfC,EAAMpB,EAAQmB,EAA+BN,CAAM,CAAC,GACnD,EAA+B,GAAGd,IACjCqB,EAAMpB,EAAQW,EAASZ,CAAI,EAAGoB,CAAqB,GAG7D,MAAO,CACL,KAAMD,GAAS,EAAM,IAAgB,UAAUR,EAAMW,CAAO,CAAC,EAC7D,MAAOH,GAAS,EAAM,IAAgB,MAAMR,EAAMW,CAAO,CAAC,EAC1D,KAAM,EAAS,GAAGR,IAAe,eAAeb,EAAQW,EAASE,CAAM,CAAC,EACxE,OAAQ,EAAS,GAAGA,IAAe,WAAWb,EAAQW,EAASE,CAAM,CAAC,EACtE,MACG,EAAM,KACN,EAAS,GAAGA,IACXjB,EACE,IAAIE,EAAYG,EAAM,CACpB,GAAGK,EACH,QAASN,EAAQW,EAASE,CAAM,CAClC,CAAC,CACH,CACN,CACF,CACA,MAAMS,EAAgBR,EAAO,aAAa,EACpCS,EAAqBT,EAAO,cAAe,kBAAkB,EAC7DU,EAAwBV,EAAO,cAAe,qBAAqB,EAM5DW,EAAiC,CAC5C,OAAQ,EAAS,GAAGZ,IACd,MACF,mCAAmCJ,EAAYE,EAASE,CAAM,GAChE,CACJ,E"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{_ as e,a as t,b as n,c as r,d as i,f as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h,v as g,y as _}from"./RouterError-Dy1_FfLa.mjs";import{C as v,S as y,_ as b,a as x,b as S,c as C,d as w,g as ee,h as te,i as ne,l as re,m as ie,n as T,o as E,p as ae,r as D,s as oe,t as se,u as ce,v as le,w as ue,x as de,y as fe}from"./internals-CBAb3okL.mjs";import{_ as O,a as pe,c as me,d as he,f as k,g as ge,h as _e,i as ve,l as ye,m as be,n as xe,o as A,p as j,r as Se,s as Ce,t as M,u as we}from"./helpers-BnQy9vYH.mjs";const Te=Object.entries,Ee=Object.hasOwn;function De(e,t,n){if(e===void 0||n.length===0)return e;let r,i=!1;for(let[a,o]of Te(e))Ee(t,a)&&t[a]!==void 0&&n.includes(a)?i=!0:(r??={},s(r,a,o));return r===void 0?i?void 0:e:r}function Oe(e,t,n){for(let[r,i]of Te(e))de(n,r,i,t(r),"this route's `defaultParams`","Move it to `defaultSearch`")}const ke=Object.entries,Ae=Object.freeze;function je(e,t,n){let r,i=!1;for(let[a,o]of ke(e))t.includes(a)?(r??={},s(r,a,o)):(i=!0,n?.(a));return i?Ae(r??c):e}function Me(e,t){let n=e.path,r=n.startsWith(`~`),i=r?n.slice(1):n,a=i!==``&&!i.startsWith(`/`)&&!i.startsWith(`?`)?`/${i}`:i,o={name:e.name,path:a,absolute:r,children:[],parent:t};if(e.children)for(let t of e.children){let e=Me(t,o);o.children.push(e)}return o}function Ne(e,t,n){let r=Me({name:e,path:t},null);for(let e of n){let t=Me(e,r);r.children.push(t)}return r}const Pe=/[^\w!$'()*+,.:;|~-]/gu,Fe=/[^\w!$'()*+,.:;|~-]/u,Ie=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,Le=e=>t=>{try{return e(t)}catch{return e(t.replaceAll(Ie,`�`))}},Re=Le(e=>e.replaceAll(Pe,e=>encodeURIComponent(e))),ze={default:e=>Fe.test(e)?Re(e):e,uri:Le(encodeURI),uriComponent:Le(encodeURIComponent),none:e=>e},Be={default:decodeURIComponent,uri:decodeURI,uriComponent:decodeURIComponent,none:e=>e},Ve={default:`%2F`,uri:`/`,uriComponent:`%2F`,none:`/`},He=(e,t)=>{let n=ze[t],r=Ve[t],i=String(e).split(`/`),a=n(i[0]);for(let e=1;e<i.length;e++)a+=(i[e-1]===``?r:`/`)+n(i[e]);return a},Ue=Object.freeze(Object.create(null));function We(){return{staticChildren:Ue,hasChildren:!1,paramChild:void 0,splatChild:void 0,route:void 0,slashChildRoute:void 0}}function N(e){return e.length>1&&e.endsWith(`/`)?e.slice(0,-1):e}function Ge(e,t){return e===``?t:t===``?e:e.endsWith(`/`)&&t.startsWith(`/`)?e+t.slice(1):e+t}function Ke(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function qe(e){let t=0;for(;t<e.length;)if(e.codePointAt(t)===37){if(t+2>=e.length)return!1;let n=e.codePointAt(t+1)??0,r=e.codePointAt(t+2)??0;if(!Ke(n)||!Ke(r))return!1;t+=3}else t++;return!0}const Je=Object.freeze([]),Ye=Object.freeze(new Set),Xe=Object.freeze([]),Ze=Object.freeze({}),Qe=Object.freeze({}),$e=Object.freeze({});function et(e,t){let n=e.kind===`splat`;return{paramName:e.name,encoder:n?e=>He(e,t):ze[t]}}function tt(e,t,n,r){let i=new Set(r);for(let e of t)for(let t of e.paramMeta.urlParams)i.add(t);if(i.size===0)return{buildStaticParts:[e],buildParamSlots:Xe};let a=[],o=[],s=``,c=S(e),l=c.length-1;for(let[e,t]of c.entries()){let r=fe(t);(`error`in r||r.kind!==`splat`||e===l)&&(e>0&&(s+=`/`),`error`in r||r.kind===`static`?s+=t:(a.push(s),s=``,o.push(et(r,n))))}return a.push(s),{buildStaticParts:a,buildParamSlots:o}}const P=o(`router`);function nt(e,t,n){throw P.plain`Parameter name conflict at the same path position: '${n}${e}' and '${n}${t}'. One position binds one name across every route that shares it. Rename one — e.g. use '${n}${e}' in both.`}function rt(){throw P.plain`Empty parameter name: a ':'/'*' marker must be followed by a name (e.g. ':id', '*rest'), and a segment cannot end in a bare '?'.`}function it(e){throw P.plain`Fused parameter marker in segment "${e}": a ':'/'*' marker must begin a segment — write 'a/:b', not 'a:b'.`}function at(e){throw P.plain`Trailing parameter marker in segment "${e}": a param name cannot end in a bare ':' or '*'. Drop the stray marker.`}function ot(e){throw P.plain`Optional params are not supported: "${e}" — declare two sibling routes instead, one with the segment and one without.`}function st(e){throw P.plain`Regex constraints are not supported: '<' and '>' are reserved in path segments ("${e}"). Match it as a plain string and validate the value in a canActivate guard.`}function ct(e){throw P.plain`Non-ASCII static segment "${e}": match compares static keys raw and rejects non-ASCII input, so this route can never match. Percent-encode it (e.g. "/caf%C3%A9") or use a param.`}function lt(e,t){switch(e){case`name-less`:return rt();case`trailing-marker`:return at(t);case`fused-marker`:return it(t);case`optional-removed`:return ot(t);case`constraint-removed`:return st(t)}}function ut(e,t){let n=new Set,r=``;for(let e of t){if(n.has(e)){r=e;break}n.add(e)}throw P.plain`Duplicate parameter name '${r}' in route "${e}": a name must be unique within a route — the second position overwrites the first. Rename one.`}function dt(e,t){throw P.plain`Invalid query-param declaration "${t}" in route "${e}": a query-param name cannot contain '<' or '>'. Rename it.`}function ft(e){throw P.plain`Double slashes are not allowed in path "${e}": the route would build a URL its own matcher refuses. Remove the empty segment.`}function pt(e,t){throw P.plain`Duplicate route path: routes "${e}" and "${t}" resolve to the same URL — the later would shadow the earlier. Give them distinct paths.`}function mt(e,t){throw P.plain`Index route "${e}" (path "/") under the splat parent "${t}" is unreachable: the wildcard match never reaches the index node. Give the index a distinct path, or make the parent static.`}function ht(e,t){return e.paramChild?e.paramChild.name!==t&&nt(e.paramChild.name,t,`:`):e.paramChild={node:We(),name:t},e.paramChild.node}function gt(e,t){return e.splatChild?e.splatChild.name!==t&&nt(e.splatChild.name,t,`*`):e.splatChild={node:We(),name:t},e.splatChild.node}const _t=Object.create;function vt(e,t){e.route!==void 0&&e.route!==t&&pt(e.route.name,t.name),e.route=t}function yt(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>=128)return!0;return!1}function bt(e,t,n){let r=N(n);r===`/`?vt(e.root,t):xt(e,e.root,r,1,t)}function xt(e,t,n,r,i){let a=n.length;for(;r<=a;){let i=n.indexOf(`/`,r),o=i===-1?a:i,s=n.slice(r,o);t=Tt(e,t,s),r=o+1}vt(t,i)}function St(e,t,n){let r=n.length;for(;r>1&&n.codePointAt(r-1)===47;)--r;let i=n.slice(0,r);i.slice(i.lastIndexOf(`/`)+1).startsWith(`*`)&&mt(t.name,n);let a=Ct(e,n);a.slashChildRoute=t}function Ct(e,t){return wt(e,e.root,t)}function wt(e,t,n){let r=N(n);if(r===`/`||r===``)return t;let i=t,a=1,o=r.length;for(;a<=o;){let t=r.indexOf(`/`,a),n=t===-1?o:t;if(n<=a)break;let s=r.slice(a,n);i=Tt(e,i,s),a=n+1}return i}function Tt(e,t,n){let r=fe(n);if(`error`in r&&rt(),r.kind===`splat`){let e=gt(t,r.name);return t.hasChildren=!0,e}if(r.kind===`param`){let e=ht(t,r.name);return t.hasChildren=!0,e}yt(n)&&ct(n);let i=e.options.caseSensitive?n:n.toLowerCase();return i in t.staticChildren||(t.staticChildren===Ue&&(t.staticChildren=_t(null)),t.staticChildren[i]=We(),t.hasChildren=!0),t.staticChildren[i]}const Et=Object.freeze,Dt=Object.hasOwn;function Ot(e){let t=S(e);for(let[n,r]of t.entries())r===``&&n>0&&n<t.length-1&&ft(e)}function kt(e){for(let t of S(e)){let e=fe(t);`error`in e&<(e.error,t)}}function At(e,t,n,r,i){let a=t.fullName===``;a||r.push(t);let o=t.absolute,s=t.paramMeta===ee?t.path:t.paramMeta.pathPattern,c=o&&s.startsWith(`~`)?s.slice(1):s,l=o?c:s;Ot(t.path),kt(l);let u=l,d=o?u:Ge(n,u),f=a?i:jt(e,t,d,o?``:n,r,i);for(let n of t.children.values())At(e,n,d,r,f);a||r.pop()}function jt(e,t,n,r,i,a){let o=It(n,r),s=Et([...i]),c=Mt(s),l=N(n),u=Et(Lt(e.rootQueryParams,i)),{buildStaticParts:d,buildParamSlots:f}=tt(o?N(r):l,o?i.slice(0,-1):i,e.options.urlParamsEncoding,e.rootUrlParams),p=f.map(e=>e.paramName),m=p.length===0?Ye:new Set(p);m.size!==p.length&&ut(t.fullName,p),Rt(t.fullName,u);let h={name:t.fullName,parent:a,matchSegments:s,meta:c,declaredQueryParams:u,declaredQueryParamsSet:u.length===0?Ye:new Set(u),hasTrailingSlash:n.length>1&&n.endsWith(`/`),buildStaticParts:d,buildParamSlots:f,buildParamNamesSet:m,cachedResult:void 0};return t.paramMeta.urlParams.length===0&&(h.cachedResult=Et({segments:h.matchSegments,params:Ze,search:Qe,meta:h.meta})),e.routesByName.set(t.fullName,h),o?Pt(e,h,r):Ft(e,h,n,l,t),h}function Mt(e){let n;for(let t of e)Nt(t.paramTypeMap)&&(n??=p(),n[t.fullName]=t.paramTypeMap);return n===void 0?$e:Et(t(r(n)))}function Nt(e){for(let t in e)if(Dt(e,t))return!0;return!1}function Pt(e,t,n){St(e,t,n);let r=N(n),i=e.options.caseSensitive?r:r.toLowerCase();e.staticCache.has(i)&&e.staticCache.set(i,t)}function Ft(e,t,n,r,i){if(bt(e,t,n),i.paramMeta.urlParams.length===0){let n=e.options.caseSensitive?r:r.toLowerCase();e.staticCache.set(n,t)}}function It(e,t){return N(e)===N(t)}function Lt(e,t){let n=[];e.length>0&&n.push(...e);for(let e of t)e.paramMeta.queryParams.length>0&&n.push(...e.paramMeta.queryParams);return n.length===0?Je:n}function Rt(e,t){for(let n of t)b.test(n)&&dt(e,n)}const zt=o(`router`,`buildPath`),Bt=Symbol.for(`real-router.searchParams.configFault`),Vt=Object.hasOwn,Ht=Object.keys,Ut=Object.getOwnPropertyDescriptor;function Wt(e){try{return Ut(e,Bt)?.configurable===!1}catch{return!1}}function Gt(e){return typeof e==`string`?e:typeof e==`object`?JSON.stringify(e):String(e)}const Kt=Object.freeze({});function qt(e,t){return e===`strict`?t?`always`:`never`:e}var Jt=class{get options(){return this.#e}#e;#t=We();#n=new Map;#r=new Map;#i={cleanPath:``,normalized:``,queryString:void 0};#a=[];#o=``;#s;#c;constructor(e){let t=e.urlParamsEncoding??`default`,n=typeof t==`string`?t:String(t),r=Vt(ze,n)?n:`default`;this.#e={caseSensitive:e.caseSensitive??!0,strictTrailingSlash:e.strictTrailingSlash??!1,strictQueryParams:e.strictQueryParams??!1,urlParamsEncoding:r,parseQueryString:e.parseQueryString,buildQueryString:e.buildQueryString},this.#s=this.#e.caseSensitive,this.#c=this.#e.urlParamsEncoding===`none`?null:Be[this.#e.urlParamsEncoding]}registerTree(e){this.#a=e.paramMeta.queryParams,At({root:this.#t,options:this.#e,routesByName:this.#n,staticCache:this.#r,rootQueryParams:this.#a,rootUrlParams:e.paramMeta.urlParams},e,``,[],null)}match(e){if(!this.#f(e))return;let{cleanPath:t,normalized:n,queryString:r}=this.#i,i=this.#s?n:n.toLowerCase(),a=this.#r.get(i);if(a)return this.#e.strictTrailingSlash&&!this.#g(t,a)?void 0:r===void 0&&a.cachedResult?a.cachedResult:this.#m(a,{},r);let o={},s=this.#_(n,o);if(s&&(!this.#e.strictTrailingSlash||this.#g(t,s))&&this.#b(o))return this.#m(s,o,r)}buildPath(e,t,n,r){let i=this.#n.get(e);if(!i)throw zt.plain`'${e}' is not defined`;let a=this.#l(i,t),o=this.#u(a,qt(r?.trailingSlash,i.hasTrailingSlash)),s=this.#d(i,n??t,r?.queryParamsMode);return o+(s?`?${s}`:``)}getSegmentsByName(e){return this.#n.get(e)?.matchSegments}getMetaByName(e){return this.#n.get(e)?.meta}getDeclaredQueryParams(e){return this.#n.get(e)?.declaredQueryParams}hasRoute(e){return this.#n.has(e)}#l(e,t){let n=e.buildStaticParts,r=e.buildParamSlots;if(r.length===0)return n[0];let i=n[0];for(let[e,a]of r.entries()){let r=t!=null&&Vt(t,a.paramName)?t[a.paramName]:void 0;if(r==null)throw zt.plain`Missing required param '${a.paramName}'`;if(r===``)throw zt.plain`Missing required param '${a.paramName}' (empty string)`;let o=a.encoder(Gt(r));i+=o+n[e+1]}return i}#u(e,t){return t===`always`&&!e.endsWith(`/`)?`${e}/`:t===`never`&&e!==`/`&&e.endsWith(`/`)?e.slice(0,-1):e}#d(e,t,n){if(!t||e.declaredQueryParams.length===0&&n!==`loose`)return``;let r={},i=!1;for(let n of e.declaredQueryParams)Vt(t,n)&&(s(r,n,t[n]),i=!0);if(n===`loose`)for(let n of Ht(t))e.declaredQueryParamsSet.has(n)||e.buildParamNamesSet.has(n)||(s(r,n,t[n]),i=!0);return i?this.#e.buildQueryString(r):``}#f(e){if(e===``&&(e=`/`),e.codePointAt(0)!==47)return!1;let t=this.#p(e);if(t===-2)return!1;t===-3&&(e=this.#o);let n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1):void 0;if(r!==void 0){let e=r.indexOf(`#`);e!==-1&&(r=r.slice(0,e))}let i=N(n);return this.#i.cleanPath=n,this.#i.normalized=i,this.#i.queryString=r,!0}#p(e){let t=!1;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);if(r===35)return this.#o=e.slice(0,n),-3;if(r===63)return n;if(r>=128)return-2;if(r===47){if(t)return-2;t=!0}else t=!1}return-1}#m(e,t,n){let r=Kt;if(n!==void 0){let t=this.#h(e,n);if(t===void 0)return;r=t}return{segments:e.matchSegments,params:t,search:r,meta:e.meta}}#h(e,t){let n;try{n=this.#e.parseQueryString(t)}catch(e){if(Wt(e))throw e;return}if(this.#e.strictQueryParams){let t=e.declaredQueryParamsSet;for(let e of Ht(n))if(!t.has(e))return}return n}#g(e,t){return(e.length>1&&e.endsWith(`/`))===t.hasTrailingSlash}#_(e,t){return e.length===1?this.#t.slashChildRoute??this.#t.route:this.#v(this.#t,e,1,t)}#v(e,t,n,r){let i=e,a=t.length,o=this.#s;for(;n<=a;){let e=t.indexOf(`/`,n),c=e===-1?a:e,l=t.slice(n,c),d=o?l:l.toLowerCase(),f;if(d in i.staticChildren){let e=i.staticChildren[d];if(i.splatChild!==void 0){let a={},o=this.#v(e,t,c+1,a);return o===void 0?this.#y(i.splatChild,t,n,r):(u(r,a),o)}f=e}else if(i.paramChild){let e=i.paramChild;if(i.splatChild!==void 0){let a={[e.name]:l},o=this.#v(e.node,t,c+1,a);return o===void 0?this.#y(i.splatChild,t,n,r):(u(r,a),o)}f=e.node,s(r,e.name,l)}else if(i.splatChild)return this.#y(i.splatChild,t,n,r);else return;i=f,n=c+1}return i.slashChildRoute??i.route}#y(e,t,n,r){let i=e.node;if(!i.hasChildren)return s(r,e.name,t.slice(n)),i.route;let a={},o=this.#v(i,t,n,a);return o?(u(r,a),o):(s(r,e.name,t.slice(n)),i.route)}#b(e){let t=this.#c;if(!t)return!0;for(let n of Ht(e)){let r=e[n];if(r.includes(`%`)){if(!qe(r))return!1;try{e[n]=t(r)}catch{return!1}}}return!0}};const F=Object.freeze,Yt=Object.freeze(new Map),Xt=Object.freeze([]);function Zt(e){return e.parent?.name?`${e.parent.fullName}.${e.name}`:e.name}function Qt(e){let t=new Map;for(let n of e)t.set(n.name,n);return t}function $t(e,t){let n=[],r=[];for(let i of e){let e=en(i,t);n.push(e),e.absolute||r.push(e)}return{childrenMap:Qt(n),nonAbsoluteChildren:r}}function en(e,t){let n=le(e.path),r=n.urlParams.length===0&&n.queryParams.length===0&&n.pathPattern===e.path?ee:n,i=r.paramTypeMap,a={name:e.name,path:e.path,absolute:e.absolute,parent:t,children:void 0,paramMeta:r,nonAbsoluteChildren:void 0,fullName:``,paramTypeMap:i};if(a.fullName=Zt(a),e.children.length===0)a.children=Yt,a.nonAbsoluteChildren=Xt;else{let{childrenMap:t,nonAbsoluteChildren:n}=$t(e.children,a);a.children=t,a.nonAbsoluteChildren=n,F(a.nonAbsoluteChildren),F(a.children)}return F(i),F(r.urlParams),F(r.queryParams),F(r),F(a),a}function tn(e){return en(e,null)}function nn(e,t,n){return tn(Ne(e,t,n))}function rn(e){let t=e.absolute?`~${e.path}`:e.path,n={name:e.name,path:t};return e.children.size>0&&s(n,`children`,Array.from(e.children.values(),rn)),n}function an(e){return Array.from(e.children.values(),rn)}const on=e=>{let t=e.indexOf(`%`),n=e.indexOf(`+`);if(t===-1&&n===-1)return e;let r=n===-1?e:e.replaceAll(`+`,` `);return t===-1?r:decodeURIComponent(r)},sn=(e,t)=>{if(e===void 0)return t.boolean.decodeUndefined();let n=t.boolean.decodeRaw(e);if(n!==null)return n;let r=on(e),i=t.number.decode(r);return i===null?t.boolean.decodeValue(r):i},cn=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,ln=e=>{try{return encodeURIComponent(e)}catch(t){if(!(t instanceof URIError))throw t;return encodeURIComponent(String(e).replaceAll(cn,`�`))}},un=o(`router`),dn=e=>{let t=typeof e;if(t!==`string`&&t!==`number`&&t!==`boolean`)throw un.type`Invalid query value: an array element must be a string, number, or boolean — received ${t}`;return ln(e)},fn=(e,t,n,r)=>{let i=`${e}${n}`,a=[];for(let e of t)if(e===null){let e=r.encode(i);e&&a.push(e)}else a.push(`${i}=${dn(e)}`);return a.join(`&`)},pn={none:{encodeArray:(e,t,n)=>fn(e,t,``,n)},brackets:{encodeArray:(e,t,n)=>fn(e,t,`[]`,n)},index:{encodeArray:(e,t,n)=>{let r=[];for(let[i,a]of t.entries()){let t=`${e}[${i}]`;if(a===null){let e=n.encode(t);e&&r.push(e)}else r.push(`${t}=${dn(a)}`)}return r.join(`&`)},indexed:!0},comma:{encodeArray:(e,t)=>{let n=[];for(let e of t)e!==null&&n.push(dn(e));return n.length===0?``:`${e}=${n.join(`,`)}`},decodeValue:e=>e.includes(`,`)?e.split(`,`):null}},mn={none:{encode:(e,t)=>`${e}=${t}`,decodeUndefined:()=>null,decodeRaw:()=>null,decodeValue:e=>e},auto:{encode:(e,t)=>`${e}=${t}`,decodeUndefined:()=>null,decodeRaw:e=>e===`true`||e!==`false`&&null,decodeValue:e=>e},"empty-true":{encode:(e,t)=>t?e:`${e}=false`,decodeUndefined:()=>!0,decodeRaw:e=>e===`true`||e!==`false`&&null,decodeValue:e=>e}},hn={default:{encode:e=>e},hidden:{encode:()=>``}},gn={auto:{decode:e=>{let t=e.length;if(t===0)return null;let n=+(e.codePointAt(0)===45);if(n===t||t-n>1&&e.codePointAt(n)===48&&e.codePointAt(n+1)!==46)return null;let r=!1;for(let i=n;i<t;i++){let a=e.codePointAt(i);if(!(a!==void 0&&a>=48&&a<=57)){if(a===46&&!r&&i!==n&&i!==t-1)r=!0;else return null}}let i=Number(e);return String(i)!==e||!Number.isSafeInteger(i)&&!r?null:i}},none:{decode:()=>null}},_n=o(`router`),vn=Object.defineProperty,yn=Object.keys,bn=Object.hasOwn,xn=Symbol.for(`real-router.searchParams.configFault`),Sn=(e,t,n)=>{let r=typeof t==`string`?t:String(t);if(!bn(e,r)){let t=_n.type`Invalid "queryParams.${n}": "${r}" — expected ${yn(e).map(e=>`"${e}"`).join(` | `)}`;throw vn(t,xn,{value:!0}),t}return e[r]},Cn=(e,t,n,r)=>({boolean:Sn(mn,t,`booleanFormat`),null:Sn(hn,n,`nullFormat`),number:Sn(gn,r,`numberFormat`),array:Sn(pn,e,`arrayFormat`)}),wn=Object.freeze({boolean:mn.auto,null:hn.default,number:gn.auto,array:pn.none}),I=Object.freeze({arrayFormat:`none`,booleanFormat:`auto`,nullFormat:`default`,numberFormat:`auto`}),Tn=Object.freeze({...I,strategies:wn}),En=e=>{if(!e||e.arrayFormat===void 0&&e.booleanFormat===void 0&&e.nullFormat===void 0&&e.numberFormat===void 0)return Tn;let t=e.arrayFormat??I.arrayFormat,n=e.booleanFormat??I.booleanFormat,r=e.nullFormat??I.nullFormat,i=e.numberFormat??I.numberFormat;return{arrayFormat:t,booleanFormat:n,nullFormat:r,numberFormat:i,strategies:Cn(t,n,r,i)}},Dn=e=>ln(e),On=(e,t,n)=>{let r=Dn(e);switch(typeof t){case`string`:case`number`:return`${r}=${Dn(t)}`;case`boolean`:return n.strategies.boolean.encode(r,t);case`object`:return t===null?n.strategies.null.encode(r):Array.isArray(t)?n.strategies.array.encodeArray(r,t,n.strategies.null):`${r}=${Dn(t)}`;default:return`${r}=${Dn(t)}`}},kn=Object.hasOwn,An=Object.keys;function jn(e,t,n){s(e,t,n)}function Mn(e,t,n,r){if(!kn(e,t)){jn(e,t,r?[n]:n);return}let i=e[t];Array.isArray(i)?i.push(n):jn(e,t,[i,n])}function Nn(e,t,n){let r=t+1,i=0,a=!1;for(;r<n;){let t=e.codePointAt(r);if(t===93)return a?i:null;if(t!==void 0&&t>=48&&t<=57)i=i*10+(t-48),a=!0,r++;else return null}return null}function Pn(e,t,n){let{searchPart:r,nameEnd:i,nameSourceEnd:a,rawValue:o,decodedName:s}=e,c=Nn(r,i,a);if(c===null)return!1;let l=sn(o,t),u=n.get(s);return u===void 0?n.set(s,[[c,l]]):u.push([c,l]),!0}function Fn(e,t,n,r,i,a,o){let s=a!==-1&&a<n?e.slice(a+1,n):void 0,c=s===void 0?n:a,l=c,u=!1;for(let n=t;n<c;n++)if(e.codePointAt(n)===91){l=n,u=!0;break}let d=on(e.slice(t,l));if(!(o!==void 0&&u&&Pn({searchPart:e,nameEnd:l,nameSourceEnd:c,rawValue:s,decodedName:d},i,o))){if(!u&&s!==void 0&&i.array.decodeValue){let e=i.array.decodeValue(s);if(e){for(let t of e)Mn(r,d,sn(t,i),!0);return}}Mn(r,d,sn(s,i),u)}}const In=(e,t)=>{if(e===``||e===`?`)return{};let n={};return Ln(e,n,t.strategies),n};function Ln(e,t,n){let r=n.array.indexed?new Map:void 0,i=0,a=e.length,o=-2;for(;i<a;){let s=e.indexOf(`&`,i);s===-1&&(s=a),s>i&&(o!==-1&&o<i&&(o=e.indexOf(`=`,i)),Fn(e,i,s,t,n,o,r)),i=s+1}if(r!==void 0)for(let[e,n]of r)n.sort((e,t)=>e[0]-t[0]),jn(t,e,n.map(e=>e[1]))}const Rn=(e,t)=>{let n=An(e);if(n.length===0)return``;let r=[];for(let i of n){let n=e[i];if(n===void 0)continue;let a=On(i,n,t);a&&r.push(a)}return r.join(`&`)};function zn(e){let t=e?.queryParams,n=En(t);return new Jt({...e?.caseSensitive!==void 0&&{caseSensitive:e.caseSensitive},...e?.strictTrailingSlash!==void 0&&{strictTrailingSlash:e.strictTrailingSlash},...e?.strictQueryParams!==void 0&&{strictQueryParams:e.strictQueryParams},...e?.urlParamsEncoding!==void 0&&{urlParamsEncoding:e.urlParamsEncoding},parseQueryString:e=>In(e,n),buildQueryString:e=>Rn(e,n)})}const Bn=o(`router`,`addEventListener`),Vn=o(`router`,`subscribeChanges`),Hn=o(`router`,`addInterceptor`),Un=o(`router`,`addCheck`),Wn=o(`router`,`extendRouter`),L=o(`router`),Gn=Object.keys,Kn=Object.values,R=Object.hasOwn,qn=Object.getOwnPropertyDescriptor,Jn=Object.getPrototypeOf,Yn=Object,Xn=new Set(Kn(_));function Zn(e){if(!Xn.has(e))throw Bn.type`Invalid event name: ${String(e)}. Must be one of: ${[...Xn].join(`, `)}`}function Qn(e){if(typeof e!=`function`)throw Bn.type`callback must be a function, got ${typeof e}`}function $n(e){if(typeof e!=`function`)throw Vn.type`Expected a function`}function er(e,t){if(typeof e!=`string`||!R(D,e))throw Hn.type`Invalid method: ${typeof e==`string`?`"${e}"`:typeof e}. Must be one of: ${Gn(D).join(`, `)}`;if(typeof t!=`function`)throw Hn.type`interceptor must be a function, got ${typeof t}`}function tr(e,t){if(typeof e!=`string`||!R(T,e))throw Un.type`Invalid position: ${typeof e==`string`?`"${e}"`:typeof e}. Must be one of: ${Gn(T).join(`, `)}`;if(typeof t!=`function`)throw Un.type`check must be a function, got ${typeof t}`}function nr(e,t){if(typeof e!=`string`)throw o(`router`,t).type`Route name must be a string, got ${typeof e}`}function rr(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=Jn(e);return t===null||t.constructor===Yn}function ir(e){if(!rr(e))throw L.type`dependencies must be a plain object`}function ar(e){return e===null?`null`:typeof e==`object`?`a non-plain object`:typeof e}function or(e){if(!rr(e))throw Wn.type`extensions must be a plain object, got ${ar(e)}`}function sr(e,t){ir(e);let n=e,r=[];for(let e of Gn(n)){if(qn(n,e)?.get)throw L.type`dependencies cannot contain getters: "${e}"`;let t=n[e];t!==void 0&&r.push([e,t])}for(let[e,n]of r)t(e,n)}function cr(e){let t=[];for(let n of e){let e=n;if(typeof e!=`object`||!e||Array.isArray(e))throw L.type`route must be a non-array object`;ae(e,`addRoute`);let r={...e},i=r.children;i&&s(r,`children`,cr(i)),t.push(r)}return t}const lr=new Set([`all`,`warn-error`,`error-only`,`none`]);function ur(e){return typeof e==`string`&&lr.has(e)}function dr(e){return typeof e==`string`?`"${e}"`:typeof e==`object`?JSON.stringify(e):String(e)}function fr(e){for(let t of Gn(e))if(t!==`level`&&t!==`callback`&&t!==`callbackIgnoresLevel`)throw L.type`Unknown logger config property: "${t}"`}function pr(e){if(!R(e,`level`))return;let t=e.level;if(t!==void 0){if(!ur(t))throw L.type`Invalid logger level: ${dr(t)}. Expected: "all" | "warn-error" | "error-only" | "none"`;return t}}function mr(e){if(!R(e,`callbackIgnoresLevel`))return;let t=e.callbackIgnoresLevel;if(t!==void 0){if(typeof t!=`boolean`)throw L.type`Logger callbackIgnoresLevel must be a boolean, got ${typeof t}`;return t}}function hr(e){if(typeof e!=`object`||!e)throw L.type`Logger config must be an object`;let t=e;fr(t);let n=p(),r=pr(t);if(r!==void 0&&(n.level=r),R(t,`callback`)){let e=t.callback;if(e!==void 0&&typeof e!=`function`)throw L.type`Logger callback must be a function, got ${typeof e}`;n.callback=e}let i=mr(t);return i!==void 0&&(n.callbackIgnoresLevel=i),n}const gr=Object.create;function _r(e,t,n){e[t]=n}function vr(e,t){return e.dependencies[t]}function yr(e){e.dependencies=gr(null)}function br(e){return Ce({...e.dependencies})}function xr(e,t){let n=gr(null),r=e,i=n;return sr(r,(e,t)=>{_r(i,e,t)}),{dependencies:n,limits:t}}const z={defaultRoute:``,defaultParams:{},defaultSearch:{},trailingSlash:`preserve`,caseSensitive:!0,queryParamsMode:`loose`,queryParams:I,urlParamsEncoding:`default`,allowNotFound:!0,rewritePathOnMatch:!0},Sr=[`strict`,`never`,`always`,`preserve`],Cr=[`default`,`strict`,`loose`];function wr(e){return e!==void 0&&Sr.includes(e)?e:z.trailingSlash}function Tr(e){return e!==void 0&&Cr.includes(e)?e:z.queryParamsMode}const Er=o(`router`);function Dr(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Er.type`options must be a plain object`}const Or=Object.freeze;var kr=class{#e;constructor(e={}){this.#e=Or(Ce({...z,...e}))}static validateOptionsIsObject(e){Dr(e)}get(){return this.#e}};function Ar(e,t){return typeof e==`function`?e(t):e}const jr=Object.keys;function Mr(e,t,n,r,i){let a=e.pathNames(t);if(a!==void 0)for(let e of jr(n))!r.includes(e)&&!a.includes(e)&&i(t,e)}function B(e,t,n,r,i){let a=String(t),o=i?.resolveForward===!1?{name:a,params:n,search:r}:e.resolveForward(a,n,r),s=o.name,l=k(o.params,d),u=i?.diagnoseUndeclared===!0?e.reportUndeclaredParamKey:void 0;u&&Mr(e,s,l,e.queryNames(s),u);let f=e.defaultParams(s),p=e.defaultSearch(s);if((o.search===void 0||o.search===c)&&f===void 0&&p===void 0)return{name:s,path:l,query:c};let m=e.queryNames(s),h=e.reportDroppedQueryKey,g=i?.resolveForward===!1?De(p,l,m):p,_=k(o.search,c),v=he(g,_);return{name:s,path:we(f,l),query:e.admitsUndeclaredQuery()?v:je(v,e.printedQueryNames(s),t=>{h!==void 0&&e.pathNames(s)!==void 0&&h(s,t)})}}function V(e,t){return t.buildPath(e.name,e.path,e.query)}const Nr=Object.freeze;function Pr(e,t){let n={name:e.name,params:e.path,search:e.query,path:t,context:{},transition:i};return Nr(n.params),n}function H(e,t){return me(Pr(e,t))}function Fr(e,t){return Pr(e,t)}var Ir=class{#e;#t;get(){return this.#e.current}getPrevious(){return this.#e.previous}setContext(e){this.#e=e}setDependencies(e){this.#t=e}makeState(e,t,n,r){let i=this.#t.port(),a=B(i,e,t??d,n,{resolveForward:!1});return y(`makeState`,a.name,a.path,i.queryNames(a.name)),H(a,r??V(a,i))}areStatesEqual(e,t,n=!0){if(!e||!t)return!!e==!!t;let r=e.name;return r===t.name?n?ge(e.params,t.params,this.#t.getUrlParams(r)):_e(e.params,t.params)&&_e(e.search,t.search):!1}};const Lr=Object.keys,Rr={[n.ROUTER_START]:_.ROUTER_START,[n.ROUTER_STOP]:_.ROUTER_STOP,[n.TRANSITION_SUCCESS]:_.TRANSITION_SUCCESS,[n.TRANSITION_START]:_.TRANSITION_START,[n.TRANSITION_LEAVE_APPROVE]:_.TRANSITION_LEAVE_APPROVE,[n.TRANSITION_ERROR]:_.TRANSITION_ERROR,[n.TRANSITION_CANCEL]:_.TRANSITION_CANCEL},zr=Lr(Rr),Br=`router.usePlugin`,Vr=o(`router`,`usePlugin`);function Hr(e){if(!(e&&typeof e==`object`)||Array.isArray(e))throw Vr.type`Plugin factory must return an object, got ${typeof e}`;if(typeof e.then==`function`)throw Vr.type`Async plugin factories are not supported. Factory returned a Promise instead of a plugin object.`}const Ur=Object.freeze;var Wr=class e{#e=new Set;#t=new Set;#n;static validatePlugin(e){Hr(e)}setDependencies(e){this.#n=e}count(){return this.#e.size}use(...e){if(this.#n.getValidator()?.plugins.validateCountThresholds(this.#e.size+e.length),e.length===1){let t=e[0],n=this.#i(t);this.#e.add(t);let r=!1,i=()=>{if(!r){r=!0,this.#e.delete(t),this.#t.delete(i);try{n()}catch(e){this.#n.logger.error(Br,`Error during cleanup:`,e)}}};return this.#t.add(i),i}let t=this.#r(e),n=[];try{for(let e of t){let t=this.#i(e);n.push({factory:e,cleanup:t})}}catch(e){for(let{cleanup:e}of n)try{e()}catch(e){this.#n.logger.error(Br,`Cleanup error:`,e)}throw e}for(let{factory:e}of n)this.#e.add(e);let r=!1,i=()=>{if(!r){r=!0,this.#t.delete(i);for(let{factory:e}of n)this.#e.delete(e);for(let{cleanup:e}of n)try{e()}catch(e){this.#n.logger.error(Br,`Error during cleanup:`,e)}}};return this.#t.add(i),i}getAll(){return[...this.#e]}disposeAll(){for(let e of this.#t)e();this.#e.clear(),this.#t.clear()}#r(e){let t=new Set;for(let n of e)t.has(n)?this.#n.getValidator()?.plugins.warnBatchDuplicates(e):t.add(n);return t}#i(t){let n=this.#n.compileFactory(t);e.validatePlugin(n),this.#n.getValidator()?.plugins.validatePluginKeys(n),Ur(n);let r=[];for(let e of zr)e in n&&(typeof n[e]==`function`?(r.push(this.#n.addEventListener(Rr[e],n[e])),e===`onStart`&&this.#n.canNavigate()&&this.#n.emitDiagnostic(se.PLUGIN_AFTER_START,e)):this.#n.getValidator()?.plugins.warnPluginMethodType(e));return()=>{for(let e of r)e();typeof n.teardown==`function`&&n.teardown()}}};const U=Object.create,Gr=()=>!0,Kr=()=>!1,qr=()=>Gr,Jr=()=>Kr;function Yr(e){return e?qr:Jr}function Xr(e,t,n){n===void 0?e.delete(t):e.set(t,n)}var Zr=class{#e=new Map;#t=new Map;#n=new Map;#r=new Map;#i=new Map;#a=new Map;#o=new Map;#s=new Map;#c=new Map;#l=new Map;#u=[this.#i,this.#a];#d;setDependencies(e){this.#d=e}getHandlerCount(e){let t=e===`activate`?this.#e:this.#n,n=e===`activate`?this.#t:this.#r;if(t.size===0)return n.size;if(n.size===0)return t.size;let r=new Set(t.keys());for(let e of n.keys())r.add(e);return r.size}preflightHandlerLimit(e,t,n){let r=this.#d.getValidator();if(!r)return;let i=(e,t,i)=>{let{definition:a,external:o}=this.#g(e),s=0;for(let e of t)(n?o.has(e):a.has(e)||o.has(e))||s++;if(s===0)return;let c=n?o.size:this.getHandlerCount(e);r.lifecycle.validateHandlerLimit(c+s-1,i)};i(`activate`,e,`canActivate`),i(`deactivate`,t,`canDeactivate`)}addCanActivate(e,t,n,r){this.#f(`activate`,e,t,n,`canActivate`,r)}addCanDeactivate(e,t,n,r){this.#f(`deactivate`,e,t,n,`canDeactivate`,r)}clearCanActivate(e,t){this.#p(`activate`,e,t)}clearCanDeactivate(e,t){this.#p(`deactivate`,e,t)}clearAll(){this.#e.clear(),this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#a.clear(),this.#i.clear(),this.#o.clear(),this.#s.clear(),this.#c.clear(),this.#l.clear()}clearDefinitionGuards(){for(let e of this.#e.keys())this.#c.delete(e),this.#t.has(e)?this.#m(`activate`,e):this.#a.delete(e);for(let e of this.#n.keys())this.#o.delete(e),this.#r.has(e)?this.#m(`deactivate`,e):this.#i.delete(e);this.#e.clear(),this.#n.clear()}getFactories(){let e=U(null),t=U(null);for(let[t,n]of this.#n)e[t]=n;for(let[t,n]of this.#r)e[t]=n;for(let[e,n]of this.#e)t[e]=n;for(let[e,n]of this.#t)t[e]=n;return[e,t]}getFactoriesByOrigin(){let e=U(null),t=U(null),n=U(null),r=U(null);for(let[t,n]of this.#n)e[t]=n;for(let[e,n]of this.#e)t[e]=n;for(let[e,t]of this.#r)n[e]=t;for(let[e,t]of this.#t)r[e]=t;return{definition:[e,t],external:[n,r]}}getFunctions(){return this.#u}canNavigateTo(e,t,n,r){for(let t of e)if(!this.#_(this.#i,t,n,r,`canNavigateTo`))return!1;for(let e of t)if(!this.#_(this.#a,e,n,r,`canNavigateTo`))return!1;return!0}compileGuardFactory(e,t){let n=typeof e==`boolean`?Yr(e):e,r=this.#d.compileFactory(n);if(typeof r!=`function`)throw o(`router`,t).type`Factory must return a function, got ${typeof r}`;return r}#f(e,t,n,r,i,a){let o=this.#g(e),s=e===`activate`?this.#a:this.#i,c=r?o.definition:o.external,l=r?o.external:o.definition;if(c.has(t)||l.has(t))this.#d.getValidator()?.lifecycle.warnOverwrite(t,e,i);else{let t=this.#d.getValidator();if(t){let n=this.getHandlerCount(e);t.lifecycle.validateHandlerLimit(n,i),t.lifecycle.validateCountThresholds(n+1,i)}}let u=typeof n==`boolean`?Yr(n):n,d=c.get(t),f=this.#h(e),p=r?f.definition:f.external,m=p.get(t);c.set(t,u);let h=r&&l.has(t);try{let e=a??this.compileGuardFactory(u,i);p.set(t,e),h||s.set(t,e)}catch(n){throw Xr(c,t,d),Xr(p,t,m),this.#m(e,t),n}}#p(e,t,n){let{definition:r,external:i}=this.#g(e),a=this.#h(e),o=n!==`external`&&r.delete(t),s=n!==`definition`&&i.delete(t);o&&a.definition.delete(t),s&&a.external.delete(t),(o||s)&&this.#m(e,t)}#m(e,t){let n=this.#h(e),r=e===`activate`?this.#a:this.#i,i=n.external.get(t)??n.definition.get(t);i?r.set(t,i):r.delete(t)}#h(e){return e===`activate`?{definition:this.#c,external:this.#l}:{definition:this.#o,external:this.#s}}#g(e){return e===`activate`?{definition:this.#e,external:this.#t}:{definition:this.#n,external:this.#r}}#_(e,t,n,r,i){let a=e.get(t);if(!a)return!0;try{let e=a(n,r);return typeof e==`boolean`?e:(this.#d.getValidator()?.lifecycle.warnAsyncGuardSync(t,i),!1)}catch(e){return this.#d.logger.warn(`router.${i}`,`Guard for "${t}" threw — treated as navigation-blocking (returned false)`,e),!1}}};const Qr=new Set([`name`,`path`,`children`,`canActivate`,`canDeactivate`,`forwardTo`,`encodeParams`,`decodeParams`,`defaultParams`,`defaultSearch`]),$r=Object.freeze,W=Object.create,ei=Object.hasOwn,ti=Object.keys;function ni(){return{decoders:W(null),encoders:W(null),defaultParams:W(null),defaultSearch:W(null),forwardMap:W(null),forwardFnMap:W(null)}}function ri(e){return ti(e.forwardMap).length>0||ti(e.forwardFnMap).length>0}function ii(e,t){for(let n of ti(t))Object.assign(e[n],t[n])}function ai(e,t){for(let n in e)if(ei(t,n)&&!pe(e[n],t[n]))return!1;return!0}function oi(e){return typeof e==`string`?e:`<non-string>`}function si(e,t){for(let n in e)if(!pe(e[n],t[n]))return!1;return!0}function ci(e){let t={name:e.name,path:e.path};return e.children&&s(t,`children`,e.children.map(e=>ci(e))),t}function li(e,t,n){if(n.add(t),e.children)for(let r of e.children)li(r,`${t}.${r.name}`,n)}function ui(e,t,n=``){for(let r=0;r<e.length;r++){let i=e[r],a=n?`${n}.${i.name}`:i.name;if(a===t){e.splice(r,1);let t=new Set;return li(i,a,t),t}if(i.children&&t.startsWith(`${a}.`)){let e=ui(i.children,t,a);if(e)return e}}}function di(e,t){for(let n of ti(e))t(n)&&delete e[n]}function fi(e,t){let n=t.search(/[?#]/),r=n===-1?t:t.slice(0,n);if(r===`/`||r.endsWith(`/`))return t;let i=e.search(/[?#]/),a=i===-1?e:e.slice(0,i);return a.length>1&&a.endsWith(`/`)?`${r}/${n===-1?``:t.slice(n)}`:t}function pi(e){let t=[];for(let n of e)for(let e of n.paramMeta.urlParams)t.push(e);return t}const mi=$r([]);function hi(e,t,n){let r=n.get(t);if(r!==void 0)return r;let i=e.getSegmentsByName(t);if(!i)return mi;let a=$r(pi(i));return n.set(t,a),a}function gi(e,t){return hi(e.matcher,t,e.urlParamsCache)}const _i=$r([]);function vi(e,t,n,r){let i=r.get(t);if(i!==void 0)return i;let a=e.getDeclaredQueryParams(t);if(!a)return _i;let o=hi(e,t,n),s=$r(a.filter(e=>!o.includes(e)));return r.set(t,s),s}function yi(e,t){return e.getDeclaredQueryParams(t)??_i}function bi(e,t){return vi(e.matcher,t,e.urlParamsCache,e.queryParamsCache)}function xi(e,t,n){let r=new Map,i=new Map;Oe(t.defaultParams,t=>vi(e,t,r,i),n)}const Si=o(`router`);function Ci(e,t,n=100){let r=String(e),i=new Set,a=[r],o=r;for(;;){let e=t[o];if(!e)break;let r=String(e);if(i.has(r)){let e=a.indexOf(r),t=[...a.slice(e),r];throw Si.plain`Circular forwardTo: ${t.join(` → `)}`}if(i.add(o),a.push(r),o=r,a.length>n)throw Si.plain`forwardTo chain exceeds maximum depth (${n}): ${a.join(` → `)}`}return o}const wi=o(`router`),Ti=o(`router`,`addRoute`),Ei=Object.freeze,G=Object.create,Di=Object.entries,Oi=Object.keys,ki=Object.defineProperty,Ai=Object.fromEntries;function ji(e,t,n){let r=nn(``,t,e),i=zn(n);return i.registerTree(r),{tree:r,matcher:i}}function Mi(e,t=e.definitions){let n=ji(t,e.rootPath,e.matcherOptions);e.tree=n.tree,e.matcher=n.matcher,e.urlParamsCache.clear(),e.queryParamsCache.clear()}function Ni(e,t){let n=ji(e.definitions,t,e.matcherOptions);xi(n.matcher,e.config,`setRootPath`),e.rootPath=t,e.tree=n.tree,e.matcher=n.matcher,e.urlParamsCache.clear(),e.queryParamsCache.clear()}function Pi(e,t){Mi(e,t),K(e,Li(e.config))}function Fi(e){Ii(e),Mi(e,[])}function Ii(e){Object.assign(e.config,ni()),K(e,G(null)),e.routeCustomFields=G(null)}function K(e,t){e.resolvedForwardMap=t,e.hasAnyForward=ri(e.config)}function Li(e){let t=G(null);for(let n of Oi(e.forwardMap))t[n]=Ci(n,e.forwardMap);return t}function Ri(e,t){if(typeof e!=`function`){if(typeof e!=`string`&&e!==null)throw wi.type`forwardTo must be a string or function for route "${t}", got ${typeof e}`;return}let n=e.constructor.name===`AsyncFunction`,r=e.toString().includes(`__awaiter`);if(n||r)throw wi.type`forwardTo callback cannot be async for route "${t}". Async functions break matchPath/buildPath.`}function zi(e,t,n){t&&w(`encodeParams`,t,n,void 0),e&&w(`decodeParams`,e,n,void 0)}function Bi(e,t,n,r){if(Ri(e.forwardTo,t),e.canActivate){let n=typeof e.forwardTo==`string`?e.forwardTo:`[dynamic]`;r.warn(`router`,`Route "${t}" has both forwardTo and canActivate. canActivate will be ignored because forwardTo creates a redirect (industry standard). Move canActivate to the target route "${n}".`)}if(e.canDeactivate){let n=typeof e.forwardTo==`string`?e.forwardTo:`[dynamic]`;r.warn(`router`,`Route "${t}" has both forwardTo and canDeactivate. canDeactivate will be ignored because forwardTo creates a redirect (industry standard). Move canDeactivate to the target route "${n}".`)}typeof e.forwardTo==`string`?n.forwardMap[t]=e.forwardTo:n.forwardFnMap[t]=e.forwardTo}function Vi(e,t,n,r,i,a,o){let{decodeParams:s,encodeParams:c}=e;zi(s,c,t);let l=Ai(Di(e).filter(([e])=>!Qr.has(e)));Oi(l).length>0&&(r[t]=Ei(l)),e.canActivate&&i.set(t,e.canActivate),e.canDeactivate&&a.set(t,e.canDeactivate),e.forwardTo&&Bi(e,t,n,o),s&&(n.decoders[t]=e=>s(e)??e),c&&(n.encoders[t]=e=>c(e)??e),e.defaultParams&&(n.defaultParams[t]=A(`defaultParams`,e.defaultParams)),e.defaultSearch&&(n.defaultSearch[t]=A(`defaultSearch`,e.defaultSearch))}function Hi(e,t,n,r,i,a,o=``){for(let s of e){let e=o?`${o}.${s.name}`:s.name;Vi(s,e,t,n,r,i,a),s.children&&Hi(s.children,t,n,r,i,a,e)}}function Ui(e){let t=ni();return ii(t,e),t}function Wi(e,t,n){if(n.length===0)return[...e,...t];let[r,...i]=n;return e.map(e=>{if(e.name!==r)return e;let n=e.children??[];return{...e,children:i.length===0?[...n,...t]:Wi(n,t,i)}})}function Gi(e,t,n){for(let r of e){let e=t?`${t}.${r.name}`:r.name;n(e),r.children&&Gi(r.children,e,n)}}function Ki(e,t,n){let r=new Set;Gi(e,t,e=>{if(r.has(e))throw o(`router`,n).plain`Duplicate route "${e}" in batch`;r.add(e)})}function qi(e,t){if(nr(e,t),e.startsWith(`@@`))throw o(`router`,t).plain`Route name "${e}" uses the reserved "${`@@`}" prefix. Routes with this prefix are internal and cannot be modified through the public API.`}function Ji(e,t){for(let n of e)qi(n.name,t),n.children&&Ji(n.children,t)}function Yi(e,t){for(let n of e)te(n.name,t),n.children&&Yi(n.children,t)}function Xi(e,t){for(let n of e)ie(n.name,t),n.children&&Xi(n.children,t)}function Zi(e,t,n){let r=new Map,i=(e,t)=>{for(let a of e){let e=r.get(t);if(e?.has(a.path))throw o(`router`,n).plain`Path "${a.path}" is already defined`;e?e.add(a.path):r.set(t,new Set([a.path])),a.children&&i(a.children,t?`${t}.${a.name}`:a.name)}};i(e,t)}function Qi(e,t,n){if(Ji(t,`addRoute`),Yi(t,`addRoute`),Xi(t,`addRoute`),n!==void 0&&!e.matcher.hasRoute(n))throw Ti.plain`Parent route "${n}" does not exist`;Gi(t,n??``,t=>{if(e.matcher.hasRoute(t))throw Ti.plain`Route "${t}" already exists`}),Ki(t,n??``,`addRoute`),Zi(t,n??``,`addRoute`)}function $i({definitions:e,routesForHandlers:t,config:n,routeCustomFields:r,handlerParentName:i,rootPath:a,matcherOptions:o,logger:s}){let c=new Map,l=new Map;Hi(t,n,r,c,l,s,i);let u=Li(n),{tree:d,matcher:f}=ji(e,a,o);return{config:n,routeCustomFields:r,pendingCanActivate:c,pendingCanDeactivate:l,tree:d,matcher:f,resolvedForwardMap:u}}function ea(e,t,n,r){return $i({definitions:Wi(e.definitions,t.map(e=>ci(e)),n===void 0?[]:n.split(`.`)),routesForHandlers:t,config:Ui(e.config),routeCustomFields:Object.assign(G(null),e.routeCustomFields),handlerParentName:n??``,rootPath:e.rootPath,matcherOptions:e.matcherOptions,logger:r})}function ta(e,t,n,r){return $i({definitions:e.map(e=>ci(e)),routesForHandlers:e,config:ni(),routeCustomFields:G(null),handlerParentName:``,rootPath:t,matcherOptions:n,logger:r})}function na(e,t,n){let r=[];for(let[i,a]of e)r.push([i,a,t(a,n)]);return r}function ra(e,t){return{activate:na(e.pendingCanActivate,t.compileGuard,`canActivate`),deactivate:na(e.pendingCanDeactivate,t.compileGuard,`canDeactivate`)}}function ia(e,t,n){let r=e.depsStore,{activate:i,deactivate:a}=n??ra(t,r);Object.assign(e.config,t.config),e.routeCustomFields=t.routeCustomFields,e.tree=t.tree,e.matcher=t.matcher,e.urlParamsCache.clear(),e.queryParamsCache.clear(),K(e,t.resolvedForwardMap);for(let[e,t,n]of i)r.addActivateGuard(e,t,n);for(let[e,t,n]of a)r.addDeactivateGuard(e,t,n)}function q(e){return e===null?e:e||void 0}function aa(e,t){return t==null?t:A(e,t)}function oa(e,t,n,r){let{forwardTo:i,defaultParams:a,defaultSearch:o,decodeParams:s,encodeParams:c,canActivate:l,canDeactivate:u}=r,d=q(i),f=aa(`defaultParams`,q(a)),p=aa(`defaultSearch`,q(o)),m=q(s),h=q(c),g=q(l),_=q(u);f!=null&&de(`updateRoute`,n,f,bi(e,n),"this route's `defaultParams`","Move it to `defaultSearch`"),zi(m,h,n);let v=d===void 0?void 0:sa(n,d,e.config),y=ca(e,n,r),b=g==null?void 0:t.compileGuardFactory(g,`canActivate`),x=_==null?void 0:t.compileGuardFactory(_,`canDeactivate`);return t.preflightHandlerLimit(b===void 0?[]:[n],x===void 0?[]:[n],!1),y!==void 0&&(Oi(y).length>0?e.routeCustomFields[n]=Ei(y):delete e.routeCustomFields[n]),v!==void 0&&(e.config.forwardMap=v.forwardMap,e.config.forwardFnMap=v.forwardFnMap,K(e,v.resolved)),ua(e,n,{defaultParams:f,defaultSearch:p,decodeParams:m,encodeParams:h}),da(t,`activate`,n,g,b),da(t,`deactivate`,n,_,x),{forwardTo:d,defaultParams:f,defaultSearch:p,decodeParams:m,encodeParams:h}}function sa(e,t,n){Ri(t,e);let r=Object.assign(G(null),n.forwardMap),i=Object.assign(G(null),n.forwardFnMap);return t===null?(delete r[e],delete i[e]):typeof t==`string`?(delete i[e],r[e]=t):(delete r[e],i[e]=t),{forwardMap:r,forwardFnMap:i,resolved:Li({...n,forwardMap:r})}}function ca(e,t,n){let r;for(let i of Oi(n)){if(Qr.has(i))continue;let a=n[i];a!==void 0&&(r??={...e.routeCustomFields[t]},a===null?delete r[i]:s(r,i,a))}return r}function la(e,t,n){n!==void 0&&(n===null?delete e[t]:e[t]=n)}function ua(e,t,n){if(la(e.config.defaultParams,t,n.defaultParams),la(e.config.defaultSearch,t,n.defaultSearch),n.decodeParams!==void 0){if(n.decodeParams===null)delete e.config.decoders[t];else{let r=n.decodeParams;e.config.decoders[t]=e=>r(e)??e}}if(n.encodeParams!==void 0){if(n.encodeParams===null)delete e.config.encoders[t];else{let r=n.encodeParams;e.config.encoders[t]=e=>r(e)??e}}}function da(e,t,n,r,i){r!==void 0&&(t===`activate`?r===null?e.clearCanActivate(n,`definition`):e.addCanActivate(n,r,!0,i):r===null?e.clearCanDeactivate(n,`definition`):e.addCanDeactivate(n,r,!0,i))}function fa(e,t,n){let r=e;Ji(r,`addRoute`),Yi(r,void 0),Xi(r,void 0),Ki(r,``,`addRoute`);let i=ta(r,``,t,n),a={get definitions(){return an(a.tree)},config:i.config,tree:i.tree,matcher:i.matcher,urlParamsCache:new Map,queryParamsCache:new Map,resolvedForwardMap:i.resolvedForwardMap,hasAnyForward:ri(i.config),routeCustomFields:i.routeCustomFields,rootPath:``,matcherOptions:t,depsStore:void 0,lifecycleNamespace:void 0,revalidating:!1,pendingCanActivate:i.pendingCanActivate,pendingCanDeactivate:i.pendingCanDeactivate};return xi(a.matcher,a.config,`addRoute`),ki(a,`matcherOptions`,{writable:!1,configurable:!1}),a}const pa=Object.freeze,ma=Object.keys,ha=[];Object.freeze(ha);function ga(e){let t=e.split(`.`),n=t.length,r=[t[0]],i=t[0].length;for(let a=1;a<n-1;a++)i+=1+t[a].length,r.push(e.slice(0,i));return r.push(e),r}const _a=new Set([`string`,`number`,`boolean`]);function va(e){return _a.has(typeof e)}function ya(e,t,n,r){let i=t[e];if(!i||typeof i!=`object`)return!0;for(let e of ma(i)){let t=n.params[e],i=r.params[e];if(va(t)&&va(i)&&String(t)!==String(i))return!1}return!0}function ba(e,t,n,r,i,a){for(let o=0;o<a;o++){let a=r[o];if(a!==i[o]||!ya(a,e,t,n))return o}return a}const xa=new Map;function J(e){let t=xa.get(e);if(t)return t;let n=Sa(e);return pa(n),xa.set(e,n),n}function Sa(e){if(!e)return[``];let t=e.indexOf(`.`);if(t===-1)return[e];let n=e.indexOf(`.`,t+1);if(n===-1)return[e.slice(0,t),e];let r=e.indexOf(`.`,n+1);return r===-1?[e.slice(0,t),e.slice(0,n),e]:e.indexOf(`.`,r+1)===-1?[e.slice(0,t),e.slice(0,n),e.slice(0,r),e]:ga(e)}let Ca,wa,Ta=null,Ea,Da,Oa=null;function ka(e,t,n){if(!t)return{intersection:``,toActivate:J(e.name),toDeactivate:ha};let r=n(e.name),i=n(t.name);if(!r&&!i)return{intersection:``,toActivate:J(e.name),toDeactivate:J(t.name)};let a=J(e.name),o=J(t.name),s=Math.min(o.length,a.length),c=ba(r??i,e,t,a,o,s),l;if(c>=o.length)l=ha;else if(c===0&&o.length===1)l=o;else{l=[];for(let e=o.length-1;e>=c;e--)l.push(o[e])}let u=c===0?a:a.slice(c);return{intersection:c>0?o[c-1]:``,toDeactivate:l,toActivate:u}}function Aa(e,t,n){if(Ta!==null&&e===Ca&&t===wa)return Ta;if(Oa!==null&&e===Ea&&t===Da)return Oa;let r=ka(e,t,n);return Ea=Ca,Da=wa,Oa=Ta,Ca=e,wa=t,Ta=r,r}const ja=o(`router`),Ma=o(`router`,`shouldUpdateNode`),Na=Object.freeze,Y=Object.hasOwn;function Pa(e,t){return{name:t??e.segments.at(-1).fullName,params:e.params,search:e.search,meta:e.meta}}function Fa(e){let t=wr(e);return t===`preserve`?void 0:t}var Ia=class{#e;#t;#n;get#r(){return this.#e.depsStore}constructor(e,t,n){this.#e=fa(e,t,n)}static shouldUpdateNode(e,t){return(n,r)=>{if(!(n&&typeof n==`object`&&`name`in n))throw Ma.type`toState must be valid State object`;if(n.transition?.reload||e===``)return!0;let{intersection:i,toActivate:a,toDeactivate:o}=Aa(n,r,t);return e===i||a.includes(e)?!0:o.includes(e)}}isRevalidating(){return this.#e.revalidating}setDependencies(e){this.#e.depsStore=e}flushPendingGuards(){let e=this.#r;for(let[t,n]of this.#e.pendingCanActivate)e.addActivateGuard(t,n);this.#e.pendingCanActivate.clear();for(let[t,n]of this.#e.pendingCanDeactivate)e.addDeactivateGuard(t,n);this.#e.pendingCanDeactivate.clear()}setLifecycleNamespace(e){this.#e.lifecycleNamespace=e}setRootPath(e){Ni(this.#e,e)}hasRoute(e){return this.#e.matcher.hasRoute(e)}clearRoutes(){Fi(this.#e)}buildPath(t,n,r,i){if(t===e.UNKNOWN_ROUTE)return typeof n.path==`string`?n.path:``;let a=this.#e.config.encoders[t];if(typeof a==`function`){let e=a({params:{...n},search:{...r}});return this.#e.matcher.buildPath(t,e.params,e.search,this.#c(i))}return this.#e.matcher.buildPath(t,n,r,this.#c(i))}buildPathFromIntent(t,n,r){return t===e.UNKNOWN_ROUTE?this.#r.port.buildPath(t,k(n,d),r??c):V(B(this.#r.port,t,n,r,{resolveForward:!1}),this.#r.port)}matchPath(e,t){let n=t,r=this.#e.matcher.match(e);if(!r)return;let i=Pa(r),{name:a}=i,o=O(i.params),s=O(i.search),c=this.#e.config.decoders[a],l;if(typeof c==`function`){l=c({params:o,search:s});let e=l.params;l={params:e,search:l.search},this.#r.getValidator()?.routes.validateStateBuilderArgs(a,e,`matchPath`),de(`matchPath`,a,e,this.getQueryParams(a),"the `params` returned by this route's `decodeParams`")}else l={params:o,search:s};let u=B(this.#r.port,a,l.params,l.search),d=u.name;y(`matchPath`,u.name,u.path,this.getQueryParams(u.name));let f=u.path,p=u.query,m=e;if(n.rewritePathOnMatch){let t=this.#e.config.encoders[d],r=typeof t==`function`?t({params:f,search:p}):{params:f,search:p},i=n.trailingSlash;try{m=this.#e.matcher.buildPath(d,r.params,r.search,{trailingSlash:Fa(i),queryParamsMode:Tr(n.queryParamsMode)}),wr(i)===`preserve`&&(m=fi(e,m))}catch{m=e}}return H(u,m)}forwardState(e,t,n){let r=n??c;if(Y(this.#e.config.forwardFnMap,e)){let n=this.#e.config.forwardFnMap[e],{target:i,chain:a,params:o}=this.#l(e,n,t);return this.#s(i,a,o,r)}let i=this.#e.resolvedForwardMap[e]??e;if(i!==e&&Y(this.#e.config.forwardFnMap,i)){let n=this.#e.config.forwardFnMap[i],{target:a,chain:o,params:s}=this.#l(i,n,t);return this.#s(a,[...this.#o(e),...o],s,r)}return i===e?{name:e,params:t,search:r}:this.#s(i,this.#o(e),t,r)}buildStateResolved(e,t){let n=this.#e.matcher.getSegmentsByName(e);if(n)return Pa({segments:n,params:t,search:{},meta:this.#e.matcher.getMetaByName(e)},e)}isActiveRoute(e,t=d,n=c,r=!1,i=!0){if(this.#i(e,t,n,r,i))return!0;if(!this.#e.hasAnyForward)return!1;let a;try{a=typeof e==`string`?e:String(e)}catch{return!1}if(!Y(this.#e.config.forwardMap,a)&&!Y(this.#e.config.forwardFnMap,a))return!1;let o;try{o=this.forwardState(e,t,n)}catch(t){return this.#r.logger.warn(`router.isActiveRoute`,`Dynamic forwardTo of route "${oi(e)}" threw while resolving the active-link destination; treating the link as inactive.`,t),!1}return this.#i(o.name,o.params,o.search,r,i)}getMetaForState(e){return this.#e.matcher.hasRoute(e)?this.#e.matcher.getMetaByName(e):void 0}getUrlParams(e){return gi(this.#e,e)}getQueryParams(e){return bi(this.#e,e)}getPrintedQueryParams(e){return yi(this.#e.matcher,e)}getStore(){return this.#e}getPort(){return this.#r.port}#i(e,t,n,r,i){try{return this.#a(e,t,n,r,i)}catch(t){return this.#r.logger.warn(`router.isActiveRoute`,`Reading the arguments for route "${oi(e)}" threw while resolving the active-link state; treating the link as inactive.`,t),!1}}#a(e,t,n,r,i){let a=this.#r.getState();if(!a)return!1;let o=a.name;if(o!==e&&!o.startsWith(`${e}.`)&&!e.startsWith(`${o}.`))return!1;let s=B(this.#r.port,e,t,n,{resolveForward:!1});if(r||o===e){let e=Fr(s,``);return!this.#r.areStatesEqual(e,a,!0)||!ai(s.path,a.params)?!1:i||_e(e.search,a.search)}return!(!o.startsWith(`${e}.`)||!ai(s.path,a.params)||!i&&!si(s.query,a.search))}#o(e){let t=[],n=e;for(;Y(this.#e.config.forwardMap,n);)t.push(n),n=this.#e.config.forwardMap[n];return t}#s(e,t,n,r){let i,a;for(let e of t)i=ye(this.#e.config.defaultParams[e],i),a=ye(this.#e.config.defaultSearch[e],a);return{name:e,params:k(ye(i,n),d),search:k(ye(a,r),c)}}#c(e){return this.#t?(e!==this.#n&&this.#r.logger.warn(`router.buildPath`,"`options` differs from the cached source reference; router options are immutable per router instance, so the first-cached buildPath options are reused (#957)."),this.#t):(this.#n=e,this.#t=Na({trailingSlash:Fa(e?.trailingSlash),queryParamsMode:Tr(e?.queryParamsMode)}),this.#t)}#l(e,t,n){let r=M(n),i=new Set([e]),a=[e],o=t(this.#r.getDependency,r),s=0;if(typeof o!=`string`)throw ja.type`forwardTo callback must return a string, got ${typeof o}`;for(;s<100;){if(this.#e.matcher.getSegmentsByName(o)===void 0)throw ja.plain`Route "${o}" does not exist`;if(i.has(o)){let e=[...i,o].join(` → `);throw ja.plain`Circular forwardTo: ${e}`}if(i.add(o),Y(this.#e.config.forwardFnMap,o)){let e=this.#e.config.forwardFnMap[o];a.push(o),o=e(this.#r.getDependency,r),s++;continue}let e=this.#e.config.forwardMap[o];if(e!==void 0)a.push(o),o=e,s++;else return{target:o,chain:a,params:r}}throw ja.plain`forwardTo exceeds maximum depth of ${100}`}};const La=o(`router`),Ra=new m(g.ROUTER_NOT_STARTED),za=new m(g.SAME_STATES),Ba=La.code(g.ROUTER_NOT_STARTED)`cannot commit before the start navigation does — the boot would overwrite it; defer with queueMicrotask/await, or navigate after start() resolves`;Object.freeze(Ra),Object.freeze(za),Object.freeze(Ba);const Va=Promise.reject(Ra),Ha=Promise.reject(za),Ua=Promise.reject(Ba);Va.catch(()=>{}),Ha.catch(()=>{}),Ua.catch(()=>{});const Wa=new Set([g.SAME_STATES,g.TRANSITION_CANCELLED,g.ROUTER_NOT_STARTED,g.ROUTE_NOT_FOUND,g.CANNOT_ACTIVATE,g.CANNOT_DEACTIVATE,g.ROUTER_ALREADY_STARTED]);function Ga(e){return e instanceof m&&Wa.has(e.code)}const Ka=new Set([Va,Ha,Ua]),X=Object.freeze;function qa(e){let{fromState:t,toDeactivate:n,toActivate:r,intersection:i}=e;X(n),X(r);let a={phase:`activating`,reason:`success`,segments:X({deactivated:n,activated:r,intersection:i})};return t?.name!==void 0&&(a.from=t.name),e.reload!==void 0&&(a.reload=e.reload),e.replace!==void 0&&(a.replace=e.replace),e.redirected!==void 0&&(a.redirected=e.redirected),X(a)}function Ja(t,n){let{toState:r,fromState:i,toDeactivate:a,toActivate:o}=n;if(r.name!==e.UNKNOWN_ROUTE&&!t.hasRoute(r.name)){let e=l(new m(g.ROUTE_NOT_FOUND,{routeName:r.name}));throw t.sendTransitionFail(i,e,n),e}let s=n,c={...r,transition:qa(n)},u=X(c);n.toState=u;let d=t.canCommitTransition(s);if(!d)throw l(new m(g.TRANSITION_CANCELLED));for(let e of a)!o.includes(e)&&n.canDeactivateFunctions.has(e)&&t.clearCanDeactivate(e,d);return t.sendTransitionDone(s),u}const Ya=Object.entries;function Xa(e){return e instanceof m&&e.code===g.TRANSITION_CANCELLED}function Za(e){return Xa(e)?e:l(new m(g.TRANSITION_CANCELLED,{reason:e}))}function Qa(e,t,n,r){Xa(t)?e.cancelIfInFlight(r,t):e.isTransitioning()&&e.sendTransitionFail(n,t,r)}function $a(e,t,n){if(e instanceof DOMException&&e.name===`AbortError`)throw l(new m(g.TRANSITION_CANCELLED));if(Xa(e))throw e;eo(e,t,n)}function eo(e,t,n){if(e instanceof m){let{code:n,message:r,...i}=e.toJSON(),a=new m(n,{...i,message:r});throw a.setCode(t),a.stack=e.stack??``,l(a)}throw l(new m(t,no(e,n)))}const to=new Set([`code`,`segment`,`path`,`then`]);function no(e,t){let n={segment:t};if(e instanceof Error){let t=e.message,r=e.stack,i=`cause`in e?e.cause:void 0;return{...n,message:t,stack:r,...i!==void 0&&{cause:i}}}if(e&&typeof e==`object`){let t={};for(let[n,r]of Ya(e))n!==`__proto__`&&!to.has(n)&&s(t,n,r);return{...n,...t}}return n}async function ro(e,t,n){let r;try{r=await e}catch(e){$a(e,t,n);return}if(!r)throw l(new m(t,{segment:n}))}function io(e,t,n,r,i,a,o,s,c,u){if(!c())throw l(new m(g.TRANSITION_CANCELLED));if(e===1){let n=u();return n===void 0?void 0:{phase:e,index:t+1,pending:n}}let d=n[t],f=r.get(d);if(!f)return;let p=!1;try{p=f(a,o,s)}catch(e){$a(e,i,d)}let h;try{h=p.then}catch(e){$a(e,i,d)}if(typeof h==`function`){let n=p;return{phase:e,index:t+1,pending:new Promise((e,t)=>{Reflect.apply(h,n,[e,t])})}}if(!p)throw l(new m(i,{segment:d}))}function ao(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=e===1,m=e===0;if(!p&&!(m?o:s))return;let h=m?i:a,_=p?1:h.length,v=m?n:r,y=m?g.CANNOT_DEACTIVATE:g.CANNOT_ACTIVATE;for(let n=t;n<_;n++){let t=io(e,n,h,v,y,c,l,u,d,f);if(t!==void 0)return t}}function oo(e,t,n,r,i,a,o,s,c,l,u,d,f){for(let p=d;p<=2;p++){let m=ao(p,p===d?f:0,e,t,n,r,i,a,o,s,c,l,u);if(m!==void 0)return m}}async function so(e,t,n,r,i,a,o,s,c,l,u,d){let f=e;for(;f!==void 0;){if(f.phase===1)await f.pending;else{let e=f.phase===0;await ro(f.pending,e?g.CANNOT_DEACTIVATE:g.CANNOT_ACTIVATE,(e?r:i)[f.index-1])}f=oo(t,n,r,i,a,o,s,c,l,u,d,f.phase,f.index)}}function co(e,t,n,r,i,a,o,s,c,l,u){let d=oo(e,t,n,r,i,a,o,s,c,l,u,0,0);return d===void 0?void 0:so(d,e,t,n,r,i,a,o,s,c,l,u)}const lo=Object.freeze,uo=Object.freeze([]),fo=new Map;function po(e,t){return t?lo({...e,replace:!0}):e}function mo(e,t,n,r){return!!e&&!t&&!n&&e.path===r.path}function ho(e,t){if(e.size===0)return!1;for(let n of t)if(e.has(n))return!0;return!1}function go(e){let t=e.controller;if(t!==void 0)return t;let n=new AbortController;return e.cancelReason!==void 0&&n.abort(e.cancelReason),e.controller=n,n}function _o(e,t){t.externalSignal!==void 0&&t.cancelReason===void 0&&t.hasGuards&&e.bridgeExternalSignal(t)}function vo(e,t,n,r,i,a,o,s,c,u){To(e,a);let d=e.hasLeaveListeners()||e.hasPreCommitListeners(),f={toState:t,fromState:n,opts:r,suspendable:i!==void 0||d,forceDeactivate:u,toDeactivate:uo,toActivate:uo,intersection:``,canDeactivateFunctions:fo,canActivateFunctions:fo,shouldDeactivate:!1,shouldActivate:!1,hasGuards:!1,controller:void 0,cancelReason:void 0,detachExternalBridge:void 0,externalSignal:i,reload:o,replace:s,redirected:c};if(!e.startTransition(f))throw l(new m(g.TRANSITION_CANCELLED));return f}function yo(e,t){return e.sendLeaveApprove(t),Ja(e,t)}function bo(t,n){let[r,i]=t.getLifecycleFunctions(),{toDeactivate:a,toActivate:o,intersection:s}=Aa(n.toState,n.fromState,e=>t.getMetaForState(e));n.canDeactivateFunctions=r,n.canActivateFunctions=i,n.toDeactivate=a,n.toActivate=o,n.intersection=s,n.shouldDeactivate=!!n.fromState&&!n.forceDeactivate&&a.length>0,n.shouldActivate=n.toState.name!==e.UNKNOWN_ROUTE&&o.length>0,n.hasGuards=n.shouldDeactivate&&ho(r,a)||n.shouldActivate&&ho(i,o)}function xo(t,n,r){let i,a;try{i=t.getState();let o=be(r),s=o?.aborted===!0?o:void 0;r=ve(r);let c=j(r,`reload`),u=j(r,`force`),d=j(r,`replace`),f=j(r,`redirected`),p=j(r,`forceDeactivate`)===!0,h=i?.name===e.UNKNOWN_ROUTE&&!d,_=h||d;if(r=po(r,h),mo(i,c,u,n))return t.emitTransitionError(n,i,za),Ha;let v=vo(t,n,i,r,o,s,c,_,f,p);a=v;let y=v.externalSignal;if(y?.aborted===!0&&t.cancelNavigation(y.reason),bo(t,v),_o(t,v),!v.hasGuards&&!v.suspendable)return yo(t,v);let{canDeactivateFunctions:b,canActivateFunctions:x,toDeactivate:S,toActivate:C,shouldDeactivate:w,shouldActivate:ee,hasGuards:te}=v,ne=n;if(!te){let e=wo(t,v);if(e!==void 0)return e}if(te){let e=go(v),r=()=>!e.signal.aborted,a=e.signal,o=co(b,x,S,C,w,ee,n,i,a,r,()=>{if(t.sendLeaveApprove(v),t.hasLeaveListeners())return t.awaitLeaveListeners(ne,i,a)});if(o!==void 0)return So(t,o,v,e);if(!r())throw l(new m(g.TRANSITION_CANCELLED))}return Ja(t,v)}catch(e){let n=Co(t,e,{nav:a,fromState:i});return Promise.reject(n)}}async function So(e,t,n,r){let i=()=>!r.signal.aborted,a=n.externalSignal,o,s=!1,c,u=new Promise(e=>{r.signal.aborted?e():(o=()=>{e()},r.signal.addEventListener(`abort`,o,{once:!0}))});t.catch(()=>{});try{if(a?.aborted)throw l(new m(g.TRANSITION_CANCELLED,{reason:a.reason}));if(await Promise.race([t,u]),!i())throw l(new m(g.TRANSITION_CANCELLED));let r=Ja(e,n);return s=!0,r}catch(t){let r=i()?t:Za(t);throw c=r,Qa(e,r,n.fromState,n),r}finally{o&&r.signal.removeEventListener(`abort`,o),s||r.abort(c)}}function Co(e,t,n){let{nav:r}=n;if(e.dispatchAbort(r?.controller,t),r!==void 0){let i=e.isTransitioning()?t:Za(t);return Qa(e,i,n.fromState,r),i}return t}function wo(e,t){let{toState:n,fromState:r}=t;if(e.hasLeaveListeners()&&go(t),e.sendLeaveApprove(t),e.hasLeaveListeners()){let i=go(t),a=e.awaitLeaveListeners(n,r,i.signal);return a===void 0?void 0:So(e,a,t,i)}}function To(e,t){if(e.isTransitioning()&&(e.logger.warn(`router.navigate`,`Concurrent navigation detected on shared router instance. For SSR, use cloneRouter() to create isolated instance per request.`),e.cancelNavigation()),t!==void 0)throw l(new m(g.TRANSITION_CANCELLED,{reason:t.reason}))}const Eo=Object.freeze,Do=o(`router`,`navigateToNotFound`),Oo=Object.freeze([e.UNKNOWN_ROUTE]),ko=Object.freeze({replace:!0});function Ao(t,n,r){To(t,void 0);let i=t.getState(),a=i?J(i.name).toReversed():[];Eo(a);let o={deactivated:a,activated:Oo,intersection:``};Eo(o);let s={phase:`activating`,...i&&{from:i.name},reason:`success`,replace:!0,segments:o};Eo(s);let l={name:e.UNKNOWN_ROUTE,params:d,search:c,path:n,transition:s,context:{}};if(Eo(l),r&&i!==void 0&&!t.canDeactivateCurrent(a,l,i)){let e=Do.code(g.CANNOT_DEACTIVATE,{path:n})`a canDeactivate guard on "${i.name}" refused to leave for ${n}`;throw t.emitTransitionError(void 0,i,e),e}return t.systemCommit(l,i,ko)}function jo(e,t){return Ao(e,t,!0)}function Mo(e,t){return Ao(e,t,!1)}const No=o(`router`,`navigateToState`),Po=o(`router`,`navigateToDefault`);var Fo=class{#e;#t;#n=0;setDependencies(e){this.#e=e,this.#t=t=>{Ga(t)||e.logger.error(`router.navigate`,`Unexpected navigation error`,t)}}navigate(e,t,n,r){return this.#r(this.#i(e,t,n,r))}navigateToState(e,t){return this.#r(this.#a(e,t))}navigateToDefault(e){return this.#r(this.#s(e))}navigateToNotFound(e){return jo(this.#e,e)}revalidateToNotFound(e){return Mo(this.#e,e)}isPreparing(){return this.#n>0}#r(e){return e instanceof Promise&&!Ka.has(e)&&e.catch(this.#t),e}#i(e,t,n,r){let i=this.#e;if(!i.canNavigate())return i.isStarting()?Ua:Va;let a;this.#n++;try{a=i.buildNavigateState(e,t,n)}catch(e){return Promise.reject(e)}finally{this.#n--}if(!a){let t=l(new m(g.ROUTE_NOT_FOUND,{routeName:e}));return i.emitTransitionError(void 0,i.getState(),t),Promise.reject(t)}return xo(this.#e,a,r)}#a(t,n){let r=this.#e;if(!r.canNavigate())return r.isStarting()?Ua:Va;let i=t.name;if(i!==e.UNKNOWN_ROUTE&&!r.hasRoute(i)){let e=l(new m(g.ROUTE_NOT_FOUND,{routeName:i}));return r.emitTransitionError(void 0,r.getState(),e),Promise.reject(e)}let a=v(t.params,r.getQueryParams(i));if(a!==void 0){let e=No.code(g.WRONG_CHANNEL,{routeName:i})`${ue(i,a,"`state.params`")}`;return r.emitTransitionError(void 0,r.getState(),e),Promise.reject(e)}let o;try{o=this.#o(t,i)}catch(e){return Promise.reject(e)}return xo(this.#e,o,n)}#o(e,t){let n={name:t,params:xe(e.params,d),search:xe(e.search,c),path:e.path,context:{...e.context},transition:i};return me(n)}#s(e){let t=this.#e;if(!t.getOptions().defaultRoute)return Promise.reject(Po.code(g.ROUTE_NOT_FOUND)`no defaultRoute is configured — pass one to createRouter, or navigate to a route by name`);let n,r,i;this.#n++;try{({route:n,params:r,search:i}=t.resolveDefault())}catch(e){return Promise.reject(e)}finally{this.#n--}return n?typeof n==`string`?this.#i(n,r,i,e):Promise.reject(Po.code(g.ROUTE_NOT_FOUND)`defaultRoute resolved to ${typeof n}, which cannot name a route`):Promise.reject(Po.code(g.ROUTE_NOT_FOUND)`defaultRoute resolved to an empty name`)}};const Io={},Lo=o(`router`,`start`),Ro=Object.freeze({replace:!0});function zo(e){return[e,e?.reason].some(e=>e instanceof m&&e.code===g.ROUTE_NOT_FOUND)}var Bo=class{#e;setDependencies(e){this.#e=e}async start(e){let t=this.#e;if(t.isIdle())throw l(new m(g.TRANSITION_CANCELLED));let n=t.getOptions();if(typeof e!=`string`)throw Lo.type`path must be a string, got ${typeof e}`;let r=t.getRootPath(),i=t.matchPath(e);if(!i&&!n.allowNotFound){let t=new m(g.ROUTE_NOT_FOUND,{path:e});throw l(t)}if(t.completeStart(),i!==void 0&&t.getRootPath()!==r&&(i=t.matchPath(e),!i&&!n.allowNotFound))throw l(new m(g.ROUTE_NOT_FOUND,{path:e}));if(i)try{return await t.navigateToState(i,Ro)}catch(r){if(!n.allowNotFound||!zo(r))throw r;return t.navigateToNotFound(e)}return t.navigateToNotFound(e)}};const Vo={},Ho=Object.create,Uo=Object.entries,Wo=Object.hasOwn,Go=Object.values,Ko=new WeakMap;function qo(e,t,n){if(typeof n==`string`)return{target:n,when:void 0,update:void 0};let r=n.when,i=n.update;if(r!==void 0&&typeof r!=`function`)throw f.plain`transitions["${e}"]["${t}"].when is not a function`;if(i!==void 0&&typeof i!=`function`)throw f.plain`transitions["${e}"]["${t}"].update is not a function`;return{target:n.target,when:r,update:i}}function Jo(e){let t=Ko.get(e);if(t!==void 0)return t;let n=e,r=Ho(null);for(let[e,t]of Uo(n)){let n=Ho(null);for(let[r,i]of Uo(t))i!==void 0&&(n[r]=qo(e,r,i));r[e]=n}for(let e of Go(r))for(let t of Go(e))if(t!==void 0&&r[t.target]===void 0)throw f.plain`state "${t.target}" is not declared in config.transitions`;return Ko.set(e,r),r}var Yo=class{#e;#t;#n=0;#r=null;#i;#a;#o=[];constructor(e){let t=e.initial;if(this.#e=t,this.#i=e.context,this.#a=Jo(e.transitions),this.#a[t]===void 0)throw f.plain`state "${t}" is not declared in config.transitions`;this.#t=this.#a[t]}send(e,t){let n=this.#t[e];if(n===void 0)return this.#e;let r=t,i=n.when;if(i!==void 0&&!i(this.#i,r))return this.#e;let a=n.target,o=n.update,s=this.#e;if(this.#e=a,this.#t=this.#a[a],o?.(this.#i,r),this.#r!==null){let t=this.#r.get(s)?.get(e);t!==void 0&&t(r)}if(this.#n>0){let t={from:s,to:a,event:e,payload:r};for(let e of this.#o)e!==null&&e(t)}return this.#e}canSend(e,t){let n=this.#t[e];return n===void 0?!1:n.when===void 0||n.when(this.#i,t)}getState(){return this.#e}getContext(){return this.#i}on(e,t,n){let r=this.#a[e];if(r===void 0)throw f.plain`state "${e}" is not declared in config.transitions`;if(!Wo(r,t))throw f.plain`event "${t}" has no edge from state "${e}"`;this.#r??=new Map;let i=this.#r.get(e);i||(i=new Map,this.#r.set(e,i));let a=n;return i.set(t,a),()=>{let n=this.#r?.get(e);n?.get(t)===a&&n.delete(t)}}onTransition(e){let t=this.#o.indexOf(null),n;t===-1?(n=this.#o.length,this.#o.push(e)):(this.#o[t]=e,n=t),this.#n++;let r=!0;return()=>{r&&(r=!1,this.#o[n]=null,this.#n--)}}};const Z={IDLE:`IDLE`,STARTING:`STARTING`,READY:`READY`,TRANSITION_STARTED:`TRANSITION_STARTED`,LEAVE_APPROVED:`LEAVE_APPROVED`,DISPOSED:`DISPOSED`},Q={START:`START`,STARTED:`STARTED`,NAVIGATE:`NAVIGATE`,LEAVE_APPROVE:`LEAVE_APPROVE`,COMPLETE:`COMPLETE`,FAIL:`FAIL`,CANCEL:`CANCEL`,STOP:`STOP`,DISPOSE:`DISPOSE`,SYSTEM_COMMIT:`SYSTEM_COMMIT`};function Xo(){return{inflight:void 0,current:void 0,previous:void 0}}const Zo=(e,t)=>t?.nav===void 0||t.nav===e.inflight,Qo=(e,t)=>t!==void 0&&t===e.inflight&&t.externalSignal?.aborted!==!0,$o=(e,t)=>{e.previous=e.current,e.current=me(t)},es=(e,t)=>{$o(e,t.toState),e.inflight=void 0},ts=(e,t)=>{$o(e,t.toState)},ns=e=>{e.previous=e.current,e.current=void 0},rs=e=>{e.current=void 0,e.previous=void 0,e.inflight=void 0},is=(e,t)=>{e.inflight=t},as={[Z.IDLE]:{[Q.START]:Z.STARTING,[Q.DISPOSE]:{target:Z.DISPOSED,update:rs}},[Z.STARTING]:{[Q.STARTED]:Z.READY,[Q.FAIL]:Z.IDLE,[Q.STOP]:{target:Z.IDLE,update:ns},[Q.DISPOSE]:{target:Z.DISPOSED,update:rs}},[Z.READY]:{[Q.NAVIGATE]:{target:Z.TRANSITION_STARTED,update:is},[Q.SYSTEM_COMMIT]:{target:Z.READY,update:ts},[Q.STOP]:{target:Z.IDLE,update:ns},[Q.DISPOSE]:{target:Z.DISPOSED,update:rs}},[Z.TRANSITION_STARTED]:{[Q.NAVIGATE]:{target:Z.TRANSITION_STARTED,update:is},[Q.LEAVE_APPROVE]:Z.LEAVE_APPROVED,[Q.CANCEL]:Z.READY,[Q.FAIL]:{target:Z.READY,when:Zo},[Q.DISPOSE]:{target:Z.DISPOSED,update:rs}},[Z.LEAVE_APPROVED]:{[Q.NAVIGATE]:{target:Z.TRANSITION_STARTED,update:is},[Q.COMPLETE]:{target:Z.READY,when:Qo,update:es},[Q.CANCEL]:Z.READY,[Q.FAIL]:{target:Z.READY,when:Zo},[Q.DISPOSE]:{target:Z.DISPOSED,update:rs}},[Z.DISPOSED]:{}};function os(){return new Yo({initial:Z.IDLE,context:Xo(),transitions:as})}const ss=o(`router`,`subscribe`),cs=o(`router`,`subscribeChanges`),ls=o(`router`,`subscribeDiagnostic`),us=o(`router`,`subscribeLeave`),ds=Object.freeze,fs=`TREE_CHANGED`;function ps(e){return e instanceof Error?e:Error(String(e))}function ms(e,t,n){return new Promise((r,i)=>{let a=()=>{let e=n.reason;i(e instanceof m&&e.code===g.TRANSITION_CANCELLED?e:l(new m(g.TRANSITION_CANCELLED,{reason:e})))};n.aborted?a():(n.addEventListener(`abort`,a,{once:!0}),Promise.allSettled(e).then(e=>{if(n.removeEventListener(`abort`,a),n.aborted)return;if(t!==void 0){i(ps(t));return}let o=e.find(e=>e.status===`rejected`);o===void 0?r():i(ps(o.reason))}))})}function hs(e,t,n){return e.addEventListener(`abort`,t,{once:!0}),()=>{n(),e.removeEventListener(`abort`,t)}}var gs=class{#e;#t;#n;#r=[];#i=0;constructor(e){this.#e=e.routerFSM,this.#t=e.emitter,this.#s()}static validateSubscribeListener(e){if(typeof e!=`function`)throw ss.type`Expected a function. For Observable pattern use observable(router) from @real-router/rx`}static validateSubscribeLeaveListener(e){if(typeof e!=`function`)throw us.type`Expected a function`}emitRouterStart(){this.#i++;try{this.#t.emit(_.ROUTER_START)}finally{this.#i--}}emitRouterStop(){this.#t.emit(_.ROUTER_STOP)}emitTransitionStart(e,t,n){this.#i++;try{this.#t.emit(_.TRANSITION_START,e,t)}finally{this.#i--}}emitTransitionSuccess(e,t,n){this.#i++;try{this.#t.emit(_.TRANSITION_SUCCESS,e,t,n)}finally{this.#i--}}emitTransitionError(e,t,n){this.#i++;try{this.#t.emit(_.TRANSITION_ERROR,e,t,n)}finally{this.#i--}}emitTransitionCancel(e,t){this.#i++;try{this.#t.emit(_.TRANSITION_CANCEL,e,t)}finally{this.#i--}}emitTransitionLeaveApprove(e,t){this.#i++;try{this.#t.emit(_.TRANSITION_LEAVE_APPROVE,e,t)}finally{this.#i--}}dispatchAbort(e,t){if(e!==void 0){this.#i++;try{e.abort(t)}finally{this.#i--}}}isProcessing(){return this.#i>0}emitTreeChanged(e){this.#t.emit(fs,e)}isEmittingTreeChanged(){return this.#t.isDispatching(fs)}subscribeTreeChanged(e){if(this.isDisposed())throw cs.code(g.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;return this.#t.on(fs,t=>{e(t)})}emitDiagnostic(e,...t){this.#t.emit(e,...t)}subscribeDiagnostic(e,t){if(this.isDisposed())throw ls.code(g.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;return this.#t.on(e,(...e)=>{t(...e)})}treeChangedListenerCount(){return this.#t.listenerCount(fs)}sendStart(){this.#e.send(Q.START)}sendStop(){this.#e.send(Q.STOP)}sendDispose(){this.#e.send(Q.DISPOSE)}sendStarted(){this.#e.send(Q.STARTED)}sendNavigate(e){return this.#e.send(Q.NAVIGATE,e)===Z.TRANSITION_STARTED}canCommitTransition(e){return this.#e.canSend(Q.COMPLETE,e)}sendComplete(e){this.#e.send(Q.COMPLETE,e)}sendLeaveApprove(e){this.#e.send(Q.LEAVE_APPROVE,e)}sendFail(e,t,n){this.#e.send(Q.FAIL,{nav:n,fromState:e,error:t})}sendCancel(e,t){this.#e.send(Q.CANCEL,{fromState:e,reason:t})}systemCommit(e){let{toState:t}=e,n=t.transition,r={name:t.name,params:xe(t.params,d),search:xe(t.search,c),path:t.path,context:{...t.context},...n!=null&&{transition:Se(n)}};if(!this.#e.canSend(Q.SYSTEM_COMMIT))throw l(this.#o());return this.#e.send(Q.SYSTEM_COMMIT,{...e,toState:r}),r}canBeginTransition(){return this.#e.canSend(Q.NAVIGATE)}canStart(){return this.#e.canSend(Q.START)}canCancel(){return this.#e.canSend(Q.CANCEL)}isActive(){let e=this.#e.getState();return e!==Z.IDLE&&e!==Z.DISPOSED}isDisposed(){return this.#e.getState()===Z.DISPOSED}isTransitioning(){let e=this.#e.getState();return e===Z.TRANSITION_STARTED||e===Z.LEAVE_APPROVED}isLeaveApproved(){return this.#e.getState()===Z.LEAVE_APPROVED}isReady(){return this.#e.getState()===Z.READY}isStarting(){return this.#e.getState()===Z.STARTING}isIdle(){return this.#e.getState()===Z.IDLE}addEventListener(e,t){return this.#a(e,`addEventListener`),this.#t.on(e,t)}subscribe(e){if(this.isDisposed())throw ss.code(g.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;return this.#a(_.TRANSITION_SUCCESS,`subscribe`),this.#t.on(_.TRANSITION_SUCCESS,(t,n)=>e({route:t,previousRoute:n}))}subscribeLeave(e){if(this.isDisposed())throw us.code(g.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;this.#r.push(e);let t=!1;return()=>{if(t)return;t=!0;let n=this.#r.indexOf(e);n!==-1&&this.#r.splice(n,1)}}hasLeaveListeners(){return this.#r.length>0}hasPreCommitListeners(){return this.#t.listenerCount(_.TRANSITION_START)>0||this.#t.listenerCount(_.TRANSITION_LEAVE_APPROVE)>0}awaitLeaveListeners(e,t,n){if(t===void 0)return;let r=ds({route:t,nextRoute:e,signal:n}),i,a,o=[...this.#r];this.#i++;try{for(let e of o)try{let t=e(r);t!==void 0&&typeof t.then==`function`&&(i??=[],i.push(t))}catch(e){a===void 0&&(a=e)}}finally{this.#i--}if(i===void 0){if(a!==void 0)throw ps(a)}else return ms(i,a,n)}clearAll(){this.#t.clearAll(),this.#r.length=0}setLimits(e){this.#t.setLimits(e)}setValidatorAccessor(e){this.#n=e}sendCancelIfPossible(e,t){this.canCancel()&&this.sendCancel(e,t)}sendCancelIfInFlight(e,t,n){this.#e.getContext().inflight===e&&this.sendCancelIfPossible(t,n)}bridgeExternalSignal(e){let t=e.externalSignal;return t===void 0||e.detachExternalBridge!==void 0||(e.detachExternalBridge=hs(t,()=>{this.sendCancelIfPossible(this.#e.getContext().current,t.reason)},()=>{e.detachExternalBridge=void 0})),Vo}#a(e,t){let n=this.#n?.();n&&n.eventBus.validateCountThresholds(this.#t.listenerCount(e)+1,e,t)}#o(){if(this.isDisposed())return new m(g.ROUTER_DISPOSED,{message:`[router] cannot commit a state on a disposed router — dispose() is terminal`});let e;return e=this.isTransitioning()?`[router] cannot commit a state while a transition is in flight — the navigation in progress commits its own`:this.isStarting()?`[router] cannot commit before the start navigation does — the boot would overwrite it; await start() first`:`[router] cannot commit a state before the router has started`,new m(g.ROUTER_NOT_STARTED,{message:e})}#s(){let e=this.#e;e.on(Z.STARTING,Q.STARTED,()=>{this.emitRouterStart()}),e.on(Z.READY,Q.STOP,()=>{this.emitRouterStop()});let t=e=>{let t=e.externalSignal!==void 0&&(this.hasLeaveListeners()||this.hasPreCommitListeners())?this.bridgeExternalSignal(e):Vo;this.emitTransitionStart(e.toState,e.fromState,t)};e.on(Z.READY,Q.NAVIGATE,t),e.on(Z.TRANSITION_STARTED,Q.NAVIGATE,t),e.on(Z.LEAVE_APPROVED,Q.NAVIGATE,t),e.on(Z.TRANSITION_STARTED,Q.LEAVE_APPROVE,e=>{this.emitTransitionLeaveApprove(e.toState,e.fromState)}),e.on(Z.LEAVE_APPROVED,Q.COMPLETE,e=>{e.detachExternalBridge?.(),this.emitTransitionSuccess(e.toState,e.fromState,e.opts)});let n=e=>{let{fromState:t,reason:n}=e,r=this.#e.getContext().inflight,i=n??l(new m(g.TRANSITION_CANCELLED));r.cancelReason=i,this.dispatchAbort(r.controller,i),r.detachExternalBridge?.(),this.emitTransitionCancel(r.toState,t)};e.on(Z.TRANSITION_STARTED,Q.CANCEL,n),e.on(Z.LEAVE_APPROVED,Q.CANCEL,n),e.on(Z.READY,Q.SYSTEM_COMMIT,e=>{this.emitTransitionSuccess(e.toState,e.fromState,e.opts)});let r=e=>{let t=this.#e.getContext().inflight;t?.detachExternalBridge?.(),this.emitTransitionError(t?.toState,e.fromState,e.error)};e.on(Z.LEAVE_APPROVED,Q.FAIL,r),e.on(Z.TRANSITION_STARTED,Q.FAIL,r),e.on(Z.STARTING,Q.FAIL,e=>{this.emitTransitionError(void 0,e.fromState,e.error)})}};const _s=Object.freeze;function vs(e){return bs(e)&&!Object.isFrozen(e)&&e!==z.defaultParams&&e!==z.defaultSearch}function ys(e){let{defaultParams:t,defaultSearch:n}=e;return _s({...vs(t)&&{defaultParams:new WeakRef(t)},...vs(n)&&{defaultSearch:new WeakRef(n)}})}function bs(e){return typeof e==`object`&&!!e}function xs(e){let t={...e};return e.limits!=null&&(t.limits=A(`limits`,e.limits)),bs(e.defaultParams)&&(t.defaultParams=A(`defaultParams`,e.defaultParams)),bs(e.defaultSearch)&&(t.defaultSearch=A(`defaultSearch`,e.defaultSearch)),t}const Ss=Object.keys,Cs=Object.freeze;function ws(e={}){let t={...h,...e};return Cs({maxDependencies:Number(t.maxDependencies),maxPlugins:Number(t.maxPlugins),maxListeners:Number(t.maxListeners),warnListeners:Number(t.warnListeners),maxLifecycleHandlers:Number(t.maxLifecycleHandlers)})}function Ts(e){return e==null?void 0:Cs(Ss(e))}const Es=o(`router`),Ds=Object.freeze,Os=Object.freeze({});function ks(e,t){let n;try{n=t[e]}catch(t){throw Es.type({cause:t})`Invalid "queryParams.${e}": reading it threw.`}if(n!=null){if(typeof n==`string`)return n;try{return String(n)}catch(t){throw Es.type({cause:t})`Invalid "queryParams.${e}": its value cannot be converted to a string.`}}}function As(e){if(e==null)return`default`;try{return String(e)}catch(e){throw Es.type({cause:e})`Invalid "urlParamsEncoding": coercing it threw.`}}function js(e){if(!e)return Os;let t=ks(`arrayFormat`,e),n=ks(`booleanFormat`,e),r=ks(`nullFormat`,e),i=ks(`numberFormat`,e);return Ds({...t!==void 0&&{arrayFormat:t},...n!==void 0&&{booleanFormat:n},...r!==void 0&&{nullFormat:r},...i!==void 0&&{numberFormat:i}})}function Ms(e){return Ds({strictTrailingSlash:e.trailingSlash===`strict`,caseSensitive:e.caseSensitive,strictQueryParams:e.queryParamsMode===`strict`,urlParamsEncoding:As(e.urlParamsEncoding),queryParams:js(e.queryParams)})}const Ns=new m(g.ROUTER_ALREADY_STARTED);Object.freeze(Ns);const Ps=o(`router`),Fs={maxListeners:0,warnListeners:0};var Is=class{#e=new Map;#t=new Set;#n=null;#r=Fs;#i;#a;constructor(e){e?.limits&&(this.#r=e.limits),this.#i=e?.onListenerError??null,this.#a=e?.onListenerWarn??null}setLimits(e){this.#r=e}on(e,t){let n=this.#e.get(e),r=n?.size??0;if(n?.has(t))throw Ps.plain`Duplicate listener for "${e}"`;let{maxListeners:i,warnListeners:a}=this.#r;if(i!==0&&r>=i)throw Ps.plain`Listener limit (${i}) reached for "${e}"`;a!==0&&r===a&&this.#a!==null&&(this.#n??=new Set,this.#n.has(e)||(this.#a(e,a),this.#n.add(e)));let o=n;return o===void 0&&(o=new Set,this.#e.set(e,o)),o.add(t),()=>{this.off(e,t)}}off(e,t){let n=this.#e.get(e);n&&(n.delete(t),n.size===0&&(this.#e.delete(e),this.#n?.delete(e)))}emit(e,t,n,r,i){let a=this.#e.get(e);if(!a||a.size===0||this.#t.has(e))return;let o=arguments.length-1;this.#t.add(e);try{if(a.size===1){let[s]=a;this.#o(e,s,o,t,n,r,i)}else{let s=[...a];for(let a of s)this.#o(e,a,o,t,n,r,i)}}finally{this.#t.delete(e)}}clearAll(){this.#e.clear(),this.#n=null}listenerCount(e){return this.#e.get(e)?.size??0}isDispatching(e){return this.#t.has(e)}#o(e,t,n,r,i,a,o){try{let s=this.#s(t,n,r,i,a,o),c=s?.then;typeof c==`function`&&new Promise((e,t)=>{c.call(s,e,t)}).catch(t=>{this.#i?.(e,t)})}catch(t){this.#i?.(e,t)}}#s(e,t,n,r,i,a){switch(t){case 0:return e();case 1:return e(n);case 2:return e(n,r);case 3:return e(n,r,i);default:return e(n,r,i,a)}}};const Ls=Object.freeze({log:0,warn:1,error:2}),Rs=Object.freeze({all:0,"warn-error":1,"error-only":2,none:3}),zs=Object.hasOwn;var Bs=class{#e={level:`all`,callback:void 0,callbackIgnoresLevel:!1};#t=0;#n=!1;constructor(e){e&&this.configure(e)}configure(e){let t=hr(e),n=t.level;n!==void 0&&(this.#e.level=n,this.#t=Rs[n]),zs(t,`callback`)&&(this.#e.callback=t.callback),t.callbackIgnoresLevel!==void 0&&(this.#e.callbackIgnoresLevel=t.callbackIgnoresLevel)}getConfig(){return{level:this.#e.level,callback:this.#e.callback,callbackIgnoresLevel:this.#e.callbackIgnoresLevel}}log(e,t,...n){this.#r(`log`,e,t,n)}warn(e,t,...n){this.#r(`warn`,e,t,n)}error(e,t,...n){this.#r(`error`,e,t,n)}#r(e,t,n,r){if(this.#e.level===`none`&&!this.#e.callbackIgnoresLevel)return;let i=Ls[e]<this.#t;i||this.#i(e,t,n,r),this.#a(e,t,n,i,r)}#i(e,t,n,r){if(typeof console<`u`&&typeof console[e]==`function`){let i=t?`[${t}] ${n}`:n;console[e](i,...r)}}#a(e,t,n,r,i){if(!(!this.#e.callback||!this.#e.callbackIgnoresLevel&&r)&&!this.#n){this.#n=!0;try{let r=this.#e.callback(e,t,n,...i);r!=null&&typeof r.then==`function`&&Promise.resolve(r).catch(e=>{this.#o(`[router] Error in async callback:`,e)})}catch(e){this.#o(`[router] Error in callback:`,e)}finally{this.#n=!1}}}#o(e,t){typeof console<`u`&&typeof console.error==`function`&&console.error(e,t)}};function Vs(e){let t=t=>vr(e.dependenciesStore,t),n=Hs(e.router,t),r=Js(e),i=()=>E(e.router).validator;Us(e),Ws(e,i),Gs(e,n,i),Ks(e,r,i,t),qs(e,n,i),Ys(e,r,t),Xs(e),Zs(e,r)}function Hs(e,t){return n=>n(e,t)}function Us(e){e.eventBus.setLimits({maxListeners:e.limits.maxListeners,warnListeners:e.limits.warnListeners})}function Ws(e,t){e.eventBus.setValidatorAccessor(t)}function Gs(e,t,n){let r={logger:E(e.router).logger,compileFactory:t,getValidator:n};e.routeLifecycle.setDependencies(r)}function Ks(e,t,n,r){let i={logger:E(e.router).logger,getValidator:n,port:t,addActivateGuard:(t,n,r)=>{e.routeLifecycle.addCanActivate(t,n,!0,r)},addDeactivateGuard:(t,n,r)=>{e.routeLifecycle.addCanDeactivate(t,n,!0,r)},compileGuard:(t,n)=>e.routeLifecycle.compileGuardFactory(t,n),getState:()=>e.state.get(),areStatesEqual:(t,n,r)=>e.state.areStatesEqual(t,n,r),getDependency:r};e.routes.setDependencies(i),e.routes.setLifecycleNamespace(e.routeLifecycle)}function qs(e,t,n){let r={logger:E(e.router).logger,addEventListener:(t,n)=>e.eventBus.addEventListener(t,n),canNavigate:()=>e.eventBus.canBeginTransition(),compileFactory:t,getValidator:n,emitDiagnostic:(t,...n)=>{e.eventBus.emitDiagnostic(t,...n)}};e.plugins.setDependencies(r)}function Js(e){let t=E(e.router),n=e.routes.getStore(),r=(e,n)=>{t.validator?.state.reportUndeclaredParamKey(e,n)},i=(e,n)=>{t.validator?.state.reportDroppedQueryKey(e,n)};return{resolveForward:(e,n,r)=>t.forwardState(e,n,r),defaultParams:e=>n.config.defaultParams[e],defaultSearch:e=>n.config.defaultSearch[e],buildPath:(t,n,r)=>e.routes.buildPath(t,n,r,e.options.get()),queryNames:t=>e.routes.getQueryParams(t),printedQueryNames:t=>e.routes.getPrintedQueryParams(t),pathNames:t=>e.routes.hasRoute(t)?e.routes.getUrlParams(t):void 0,admitsUndeclaredQuery:()=>Tr(e.options.get().queryParamsMode)===`loose`,get reportDroppedQueryKey(){return t.validator?i:void 0},get reportUndeclaredParamKey(){return t.validator?r:void 0}}}function Ys(e,t,n){let r=e=>n(e),i={logger:E(e.router).logger,getOptions:()=>e.options.get(),hasRoute:t=>e.routes.hasRoute(t),getQueryParams:t=>e.routes.getQueryParams(t),getMetaForState:t=>e.routes.getMetaForState(t),getState:()=>e.state.get(),buildNavigateState:(n,r,i)=>{E(e.router).validator?.routes.validateStateBuilderArgs(n,r,`navigate`);let a=B(t,n,r,i,{diagnoseUndeclared:!0});if(e.routes.getMetaForState(a.name)!==void 0)return y(`navigate`,a.name,a.path,t.queryNames(a.name)),H(a,V(a,t))},resolveDefault:()=>{let t=e.options.get(),n=E(e.router),i=Ar(t.defaultRoute,r),a=Ar(t.defaultParams,r),o=Ar(t.defaultSearch,r);return typeof t.defaultRoute==`function`&&n.validator?.options.validateResolvedDefaultRoute(i),{route:i,params:a,search:o}},startTransition:t=>e.eventBus.sendNavigate(t),systemCommit:(t,n,r)=>e.eventBus.systemCommit({toState:t,fromState:n,opts:r}),cancelNavigation:t=>{e.eventBus.sendCancelIfPossible(e.state.get(),t)},cancelIfInFlight:(t,n)=>{e.eventBus.sendCancelIfInFlight(t,e.state.get(),n)},dispatchAbort:(t,n)=>{e.eventBus.dispatchAbort(t,n)},bridgeExternalSignal:t=>{e.eventBus.bridgeExternalSignal(t)},canCommitTransition:t=>e.eventBus.canCommitTransition(t)?Io:void 0,sendTransitionDone:t=>{e.eventBus.sendComplete(t)},sendTransitionFail:(t,n,r)=>{e.eventBus.sendFail(t,n,r)},emitTransitionError:(t,n,r)=>{e.eventBus.emitTransitionError(t,n,r)},sendLeaveApprove:t=>{e.eventBus.sendLeaveApprove(t)},canNavigate:()=>e.eventBus.canBeginTransition(),isStarting:()=>e.eventBus.isStarting(),getLifecycleFunctions:()=>e.routeLifecycle.getFunctions(),canDeactivateCurrent:(t,n,r)=>e.routeLifecycle.canNavigateTo(t,[],n,r),isTransitioning:()=>e.eventBus.isTransitioning(),clearCanDeactivate:(t,n)=>{e.routeLifecycle.clearCanDeactivate(t,`external`)},hasLeaveListeners:()=>e.eventBus.hasLeaveListeners(),hasPreCommitListeners:()=>e.eventBus.hasPreCommitListeners(),awaitLeaveListeners:(t,n,r)=>e.eventBus.awaitLeaveListeners(t,n,r)};e.navigation.setDependencies(i)}function Xs(e){e.lifecycle.setDependencies({getOptions:()=>e.options.get(),navigateToState:(t,n)=>e.navigation.navigateToState(t,n),navigateToNotFound:t=>e.navigation.navigateToNotFound(t),matchPath:t=>e.routes.matchPath(t,e.options.get()),getRootPath:()=>e.routes.getStore().rootPath,completeStart:()=>{e.eventBus.sendStarted()},isIdle:()=>e.eventBus.isIdle()})}function Zs(e,t){e.state.setDependencies({port:()=>t,getUrlParams:t=>e.routes.getUrlParams(t)})}const Qs=o(`router`,`navigateToNotFound`),$s=o(`router`,`usePlugin`),ec=o(`router`,`start`),tc=o(`router`);var nc=class e{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;constructor(t=[],n={},r={}){let{logger:i,...o}=n,s=new Bs(i?hr(i):void 0);this.#f=e=>{Ga(e)||s.error(`router.start`,`Unexpected start error`,e)},kr.validateOptionsIsObject(n),ir(r);let c=cr(t),u=xs(o);this.#r=ys(o),this.#e=new kr(u),this.#t=ws(u.limits),this.#n=Ts(u.limits),this.#i=xr(r,this.#t),this.#a=new Ir,this.#o=new Ia(c,Ms(this.#e.get()),s),this.#s=new Zr,this.#c=new Wr,this.#l=new Fo,this.#u=new Bo;let f=os();this.#a.setContext(f.getContext());let p=new Is({onListenerError:(e,t)=>{s.error(`router`,`Error in listener for ${e}:`,t)},onListenerWarn:(e,t)=>{s.warn(`router.addEventListener`,`Event "${e}" has ${t} listeners — possible memory leak`)}});this.#d=new gs({routerFSM:f,emitter:p});let h=new Map,_=new Map,v=e=>{let t=e.params,n=e.search;return{name:e.name,params:t==null?t:O(t),search:n==null?n:O(n)}},y=x(D.forwardState,(e,t,n)=>this.#o.forwardState(e,t,n),h,v,rc),b=((e,t,n)=>{let r=y(e,t,n),i=r.name,a=r.params;de(`forwardState`,i,a,this.#o.getQueryParams(i),()=>i===e?"the `params` bag leaving the forwardState chain":`the \`params\` bag leaving the forwardState chain (forwarded here from "${e}")`);let o=r.search,s=o==null;return{name:i,params:O(a??d),search:s?o:O(o)}}),S=x(D.forwardState,(e,t,n)=>({name:e,params:t,search:n}),h,v,rc);this.#p=(e,t,n)=>{let r=S(e,t,n),i=r.params,a=r.search;return this.#o.buildPathFromIntent(r.name,i??d,a)};let w={logger:s,makeState:(e,t,n,r)=>{ce(w,`makeState`,e,t);let i=M(t);return w.validator?.state.validateMakeStateArgs(e,i,r),w.validator?.navigation.validateSearch(n,`makeState`),this.#a.makeState(e,i,n,r)},getMetaForState:e=>this.#o.getMetaForState(e),getDeclaredQueryNames:e=>this.#o.getQueryParams(e),forwardState:b,buildStateResolved:(e,t)=>this.#o.buildStateResolved(e,t),buildPathResolved:(e,t,n)=>{let r=M(t);return w.validator?.navigation.validateParamsShape(t,`buildPathResolved`),w.validator?.navigation.validateSearch(n,`buildPathResolved`),C(w.checks,T[`buildPathResolved:params`],r),this.#o.buildPathFromIntent(e,r??d,n)},port:()=>this.#o.getPort(),matchPath:(e,t)=>(w.validator?.routes.validateMatchPathArgs(e),this.#o.matchPath(e,t??this.#e.get())),getOptions:()=>this.#e.get(),getAdoptedOrigins:()=>this.#r,addEventListener:(e,t)=>(re(w.isDisposed),Zn(e),Qn(t),w.validator?.eventBus.validateListenerArgs(e,t),this.#d.addEventListener(e,t)),subscribeDiagnostic:(e,t)=>this.#d.subscribeDiagnostic(e,t),treeChanged:{emit:e=>{this.#d.emitTreeChanged(e)},subscribe:e=>this.#d.subscribeTreeChanged(e),listenerCount:()=>this.#d.treeChangedListenerCount(),isEmitting:()=>this.#d.isEmittingTreeChanged()},emitTransitionError:e=>{this.#d.emitTransitionError(void 0,this.#a.get(),e)},navigateToNotFound:e=>{if(e!==void 0&&typeof e!=`string`)throw Qs.type`path must be a string, got ${typeof e}`;return this.#l.navigateToNotFound(e)},revalidateToNotFound:e=>this.#l.revalidateToNotFound(e),start:ne(D.start,e=>this.#u.start(e),h),navigateToState:(t,n)=>(re(w.isDisposed),w.validator?.navigation.validateNavigateToStateArgs(t),n!==void 0&&w.validator?.navigation.validateNavigationOptions(n,`navigateToState`),this.#g(),e.#m(this.#l.navigateToState(t,n??a))),interceptors:h,checks:_,setRootPath:e=>{w.validator?.routes.validateSetRootPathArgs(e),this.#o.setRootPath(e)},getRootPath:()=>this.#o.getStore().rootPath,getTree:()=>this.#o.getStore().tree,isDisposed:()=>this.#d.isDisposed(),validator:null,dependenciesGetStore:()=>this.#i,getCloneState:()=>({options:{...this.#e.get()},dependencies:br(this.#i),pluginFactories:this.#c.getAll(),loggerConfig:s.getConfig(),limits:this.#t,limitKeys:this.#n}),routeGetStore:()=>this.#o.getStore(),getStateName:()=>this.#a.get()?.name,isTransitioning:()=>this.#d.isTransitioning(),systemCommit:(e,t,n)=>{let r=e.name;if(r!==`@@router/UNKNOWN_ROUTE`&&!this.#o.hasRoute(r))throw l(new m(g.ROUTE_NOT_FOUND,{routeName:r}));return this.#d.systemCommit({toState:e,fromState:t,opts:n})},routerExtensions:[],contextClaimRecords:new Map};oe(this,w),Vs({router:this,options:this.#e,limits:this.#t,dependenciesStore:this.#i,state:this.#a,routes:this.#o,routeLifecycle:this.#s,plugins:this.#c,navigation:this.#l,lifecycle:this.#u,eventBus:this.#d}),this.isActiveRoute=this.isActiveRoute.bind(this),this.buildPath=this.buildPath.bind(this),this.getState=this.getState.bind(this),this.getPreviousState=this.getPreviousState.bind(this),this.areStatesEqual=this.areStatesEqual.bind(this),this.shouldUpdateNode=this.shouldUpdateNode.bind(this),this.isActive=this.isActive.bind(this),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this.dispose=this.dispose.bind(this),this.canNavigateTo=this.canNavigateTo.bind(this),this.usePlugin=this.usePlugin.bind(this),this.navigate=this.navigate.bind(this),this.navigateToDefault=this.navigateToDefault.bind(this),this.navigateToNotFound=this.navigateToNotFound.bind(this),this.subscribe=this.subscribe.bind(this),this.subscribeLeave=this.subscribeLeave.bind(this),this.isLeaveApproved=this.isLeaveApproved.bind(this);try{this.#o.flushPendingGuards()}catch(e){throw this.dispose(),e}}isActiveRoute(e,t,n,r,i){let a=E(this);return a.validator?.routes.validateIsActiveRouteArgs(e,t,r,i),a.validator?.navigation.validateSearch(n,`isActiveRoute`),a.validator?.routes.validateRouteName(e,`isActiveRoute`),e===``?(a.logger.warn(`router.isActiveRoute`,`isActiveRoute("") called with empty string. Root node is not considered a parent of any route.`),!1):this.#o.isActiveRoute(e,t,n,r,i)}buildPath(e,t,n){let r=E(this);r.validator?.routes.validateBuildPathArgs(e,t),r.validator?.navigation.validateParamsShape(t,`buildPath`),r.validator?.navigation.validateSearch(n,`buildPath`);let i=M(t);return C(r.checks,T[`buildPath:params`],i),this.#p(e,i??d,n)}getState(){return this.#a.get()}getPreviousState(){return this.#a.getPrevious()}areStatesEqual(e,t,n=!0){return E(this).validator?.state.validateAreStatesEqualArgs(e,t,n),this.#a.areStatesEqual(e,t,n)}shouldUpdateNode(e){return E(this).validator?.routes.validateShouldUpdateNodeArgs(e),Ia.shouldUpdateNode(e,e=>this.#o.getMetaForState(e))}isActive(){return this.#d.isActive()}start(e){let t=this.#h(e);return t.catch(this.#f),t}stop(){return this.#d.sendCancelIfPossible(this.#a.get()),!this.#d.isReady()&&!this.#d.isTransitioning()&&!this.#d.isStarting()||this.#d.sendStop(),this}dispose(){if(this.#d.isDisposed())return;this.#d.sendCancelIfPossible(this.#a.get()),(this.#d.isReady()||this.#d.isTransitioning())&&this.#d.sendStop(),this.#d.sendDispose(),this.#d.clearAll(),this.#c.disposeAll();let e=E(this);for(let t of e.routerExtensions)for(let e of t.keys)delete this[e];e.routerExtensions.length=0,e.contextClaimRecords.clear(),e.interceptors.clear(),e.checks.clear(),this.#o.clearRoutes(),this.#s.clearAll(),yr(this.#i),this.#v()}canNavigateTo(e,t,n){let r=E(this);C(r.checks,T[`canNavigateTo:entry`],e,t,n);let i;try{i=M(t)}catch(t){return r.logger.warn(`router.canNavigateTo`,`Reading the params bag for route "${e}" threw; treating the route as unreachable.`,t),!1}if(C(r.checks,T[`canNavigateTo:params`],i),!this.#o.hasRoute(e)||v(t,this.#o.getQueryParams(e))!==void 0)return!1;let a=this.#o.getPort(),o;try{o=B(a,e,i??d,n)}catch(t){return r.logger.warn(`router.canNavigateTo`,`Resolving route "${e}" threw while answering the predicate; treating the route as unreachable.`,t),!1}let s;try{s=H(o,V(o,a))}catch{return!1}let c=this.#a.get(),{toDeactivate:l,toActivate:u}=Aa(s,c,e=>this.#o.getMetaForState(e));return this.#s.canNavigateTo(l,u,s,c)}usePlugin(...e){if(this.#d.isDisposed())throw $s.code(g.ROUTER_DISPOSED)`cannot install a plugin on a disposed router — dispose() is terminal`;let t=e.filter(Boolean);if(t.length===0)return()=>{};let n=E(this);n.validator?.plugins.validatePluginLimit(this.#c.count(),this.#t);for(let e of t)n.validator?.plugins.validateNoDuplicatePlugins(e,this.#c.getAll());return this.#c.use(...t)}subscribe(e){return gs.validateSubscribeListener(e),this.#d.subscribe(e)}subscribeLeave(e){return gs.validateSubscribeLeaveListener(e),this.#d.subscribeLeave(e)}isLeaveApproved(){return this.#d.isLeaveApproved()}navigate(t,n,r,i){this.#g();let o=E(this),s,c,l,u;typeof t==`object`&&t?(s=t.name,c=t.params,l=t.search,u=n??a):(s=t,c=n,l=r,u=i??a),ce(o,`navigate`,s,c),C(o.checks,T[`navigate:entry`],s,c,l,u);let f;try{f=M(c)}catch(e){return Promise.reject(e)}return C(o.checks,T[`navigate:params`],f),e.#m(this.#l.navigate(s,f??d,l,u))}navigateToDefault(t){this.#g();let n=E(this);n.validator?.navigation.validateNavigateToDefaultArgs(t);let r=t??a;return n.validator?.navigation.validateNavigationOptions(r,`navigateToDefault`),e.#m(this.#l.navigateToDefault(r))}navigateToNotFound(e){if(this.#g(),!this.#d.isActive())throw l(new m(g.ROUTER_NOT_STARTED));if(e!==void 0&&typeof e!=`string`)throw Qs.type`path must be a string, got ${typeof e}`;if(e!==void 0)return this.#l.navigateToNotFound(e);let t=this.#a.get();if(t===void 0)throw Qs.code(g.ROUTER_NOT_STARTED)`cannot derive the path before the start navigation commits — pass an explicit path`;return this.#l.navigateToNotFound(t.path)}static#m(e){return e instanceof Promise?e:Promise.resolve(e)}#h(e){if(!this.#d.canStart())return Promise.reject(Ns);this.#g(),E(this).validator?.navigation.validateStartArgs(e),this.#d.sendStart();let t;try{let n=E(this).start(e);t=typeof n?.then==`function`?n:Promise.reject(ec.type`a \`start\` interceptor returned without calling next(). Every start interceptor must return \`next(path)\`.`)}catch(e){t=Promise.reject(e)}return t.catch(e=>this.#_(e))}#g(){if(this.#d.isProcessing())throw tc.code(g.REENTRANT_NAVIGATION)`cannot start a navigation from inside a router event listener or an abort listener of a navigation's signal — the nested navigation would commit a state the outer one overwrites. Defer it: queueMicrotask(() => router.navigate(...)), await the current transition, or use an async listener.`;if(this.#l.isPreparing())throw tc.code(g.REENTRANT_NAVIGATION)`cannot start a navigation from inside a forwardState interceptor, a route's encodeParams or dynamic forwardTo callback, or a defaultRoute/defaultParams/defaultSearch option callback — they run while a navigation is being prepared, before it is announced. Defer it: queueMicrotask(() => router.navigate(...)).`;if(this.#o.isRevalidating())throw tc.code(g.REENTRANT_NAVIGATION)`cannot start a navigation from inside replace()'s revalidation — the revalidation would then defer to a commit that may never happen. Defer it: queueMicrotask(() => router.navigate(...)).`}#_(e){throw this.#d.isReady()&&this.#a.get()===void 0?this.#d.sendStop():this.#d.isStarting()&&this.#d.sendFail(void 0,e),e}#v(){this.navigate=$,this.navigateToDefault=$,this.navigateToNotFound=$,this.start=$,this.stop=$,this.usePlugin=$,this.subscribe=$,this.subscribeLeave=$,this.canNavigateTo=$}};function $(){throw tc.code(g.ROUTER_DISPOSED)`this router is disposed — dispose() is terminal and swapped every method to refuse`}function rc(e,t,n){return[e,M(t),M(n)]}export{_r as A,gi as C,yr as D,B as E,$n as F,cr as I,sr as L,or as M,er as N,vr as O,nr as P,rn as R,ui as S,V as T,Fi as _,Qi as a,ii as b,Zi as c,Yi as d,ea as f,ra as g,Pi as h,ia as i,tr as j,br as k,Ji as l,oa as m,Aa as n,Xi as o,ta as p,K as r,Ki as s,nc as t,qi as u,Ci as v,H as w,di as x,xi as y,an as z};
|
|
2
|
-
//# sourceMappingURL=Router-DVdK_R0k.mjs.map
|