@real-router/core 0.36.1 → 0.37.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.
Files changed (37) hide show
  1. package/README.md +144 -168
  2. package/dist/cjs/api.js +1 -1
  3. package/dist/cjs/api.js.map +1 -1
  4. package/dist/cjs/index.js +1 -1
  5. package/dist/cjs/index.js.map +1 -1
  6. package/dist/cjs/metafile-cjs.json +1 -1
  7. package/dist/esm/api.mjs +1 -1
  8. package/dist/esm/api.mjs.map +1 -1
  9. package/dist/esm/chunk-CG7TKDP3.mjs +1 -0
  10. package/dist/esm/chunk-CG7TKDP3.mjs.map +1 -0
  11. package/dist/esm/index.mjs +1 -1
  12. package/dist/esm/metafile-esm.json +1 -1
  13. package/package.json +7 -7
  14. package/src/Router.ts +33 -12
  15. package/src/api/getPluginApi.ts +19 -4
  16. package/src/api/getRoutesApi.ts +0 -20
  17. package/src/constants.ts +2 -0
  18. package/src/fsm/routerFSM.ts +2 -21
  19. package/src/internals.ts +21 -2
  20. package/src/namespaces/EventBusNamespace/EventBusNamespace.ts +40 -37
  21. package/src/namespaces/NavigationNamespace/NavigationNamespace.ts +221 -153
  22. package/src/namespaces/NavigationNamespace/constants.ts +55 -0
  23. package/src/namespaces/NavigationNamespace/transition/completeTransition.ts +100 -0
  24. package/src/namespaces/NavigationNamespace/transition/errorHandling.ts +34 -0
  25. package/src/namespaces/NavigationNamespace/transition/guardPhase.ts +214 -0
  26. package/src/namespaces/NavigationNamespace/types.ts +14 -30
  27. package/src/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.ts +6 -1
  28. package/src/namespaces/RoutesNamespace/RoutesNamespace.ts +36 -35
  29. package/src/namespaces/RoutesNamespace/forwardToValidation.ts +2 -5
  30. package/src/namespaces/RoutesNamespace/types.ts +1 -2
  31. package/src/namespaces/StateNamespace/StateNamespace.ts +13 -17
  32. package/src/transitionPath.ts +68 -39
  33. package/src/wiring/RouterWiringBuilder.ts +16 -15
  34. package/dist/esm/chunk-HZ7RFKT5.mjs +0 -1
  35. package/dist/esm/chunk-HZ7RFKT5.mjs.map +0 -1
  36. package/src/namespaces/NavigationNamespace/transition/executeLifecycleGuards.ts +0 -52
  37. package/src/namespaces/NavigationNamespace/transition/index.ts +0 -93
@@ -25,6 +25,9 @@ interface TransitionPath {
25
25
  const ROUTE_SEGMENT_SEPARATOR = ".";
26
26
  const EMPTY_INTERSECTION = "";
27
27
  const DEFAULT_ROUTE_NAME = "";
28
+ const FROZEN_EMPTY_ARRAY: string[] = [];
29
+
30
+ Object.freeze(FROZEN_EMPTY_ARRAY);
28
31
 
29
32
  /**
30
33
  * Builds a reversed copy of a string array.
@@ -181,45 +184,46 @@ function pointOfDifference(
181
184
  * Validation significantly slows down nameToIDs execution.
182
185
  * The input should be validated by the function/method that calls nameToIDs.
183
186
  */
187
+ const nameToIDsCache = new Map<string, string[]>();
188
+
184
189
  export function nameToIDs(name: string): string[] {
185
- // ===== FAST PATH 1: Empty string (root route) =====
186
- // Most common in initial navigation
190
+ const cached = nameToIDsCache.get(name);
191
+
192
+ if (cached) {
193
+ return cached;
194
+ }
195
+
196
+ const result = computeNameToIDs(name);
197
+
198
+ Object.freeze(result);
199
+ nameToIDsCache.set(name, result);
200
+
201
+ return result;
202
+ }
203
+
204
+ function computeNameToIDs(name: string): string[] {
187
205
  if (!name) {
188
206
  return [DEFAULT_ROUTE_NAME];
189
207
  }
190
208
 
191
- // ===== FAST PATH 2: Single segment (no dots) =====
192
- // Very common: 'home', 'users', 'settings', etc.
193
209
  const firstDot = name.indexOf(ROUTE_SEGMENT_SEPARATOR);
194
210
 
195
211
  if (firstDot === -1) {
196
212
  return [name];
197
213
  }
198
214
 
199
- // ===== FAST PATH 3: Two segments =====
200
- // Common: 'users.list', 'admin.dashboard', etc.
201
215
  const secondDot = name.indexOf(ROUTE_SEGMENT_SEPARATOR, firstDot + 1);
202
216
 
203
217
  if (secondDot === -1) {
204
- return [
205
- name.slice(0, firstDot), // 'users'
206
- name, // 'users.list'
207
- ];
218
+ return [name.slice(0, firstDot), name];
208
219
  }
209
220
 
210
- // ===== FAST PATH 4: Three segments =====
211
- // Common: 'users.profile.edit', 'app.settings.general', etc.
212
221
  const thirdDot = name.indexOf(ROUTE_SEGMENT_SEPARATOR, secondDot + 1);
213
222
 
214
223
  if (thirdDot === -1) {
215
- return [
216
- name.slice(0, firstDot), // 'users'
217
- name.slice(0, secondDot), // 'users.profile'
218
- name, // 'users.profile.edit'
219
- ];
224
+ return [name.slice(0, firstDot), name.slice(0, secondDot), name];
220
225
  }
221
226
 
222
- // ===== FAST PATH 5: Four segments =====
223
227
  const fourthDot = name.indexOf(ROUTE_SEGMENT_SEPARATOR, thirdDot + 1);
224
228
 
225
229
  if (fourthDot === -1) {
@@ -231,8 +235,6 @@ export function nameToIDs(name: string): string[] {
231
235
  ];
232
236
  }
233
237
 
234
- // ===== STANDARD PATH: 5+ segments =====
235
- // Less common, use general algorithm with optimizations
236
238
  return nameToIDsGeneral(name);
237
239
  }
238
240
 
@@ -315,9 +317,13 @@ export function nameToIDs(name: string): string[] {
315
317
  // Single-entry cache: shouldUpdateNode calls getTransitionPath N times per
316
318
  // navigation with the same state objects (once per subscribed node).
317
319
  // Cache by reference eliminates N-1 redundant computations.
318
- let cachedToState: State | undefined;
319
- let cachedFromState: State | undefined;
320
- let cachedResult: TransitionPath | null = null;
320
+ let cached1To: State | undefined;
321
+ let cached1From: State | undefined;
322
+ let cached1Result: TransitionPath | null = null;
323
+
324
+ let cached2To: State | undefined;
325
+ let cached2From: State | undefined;
326
+ let cached2Result: TransitionPath | null = null;
321
327
 
322
328
  function computeTransitionPath(
323
329
  toState: State,
@@ -329,7 +335,7 @@ function computeTransitionPath(
329
335
  return {
330
336
  intersection: EMPTY_INTERSECTION,
331
337
  toActivate: nameToIDs(toState.name),
332
- toDeactivate: [],
338
+ toDeactivate: FROZEN_EMPTY_ARRAY,
333
339
  };
334
340
  }
335
341
 
@@ -365,14 +371,23 @@ function computeTransitionPath(
365
371
 
366
372
  // Optimization: Build deactivation list in reverse order directly
367
373
  // instead of slice(i).toReversed() which creates 2 arrays
368
- const toDeactivate: string[] = [];
369
-
370
- for (let j = fromStateIds.length - 1; j >= i; j--) {
371
- toDeactivate.push(fromStateIds[j]);
374
+ let toDeactivate: string[];
375
+
376
+ if (i >= fromStateIds.length) {
377
+ toDeactivate = FROZEN_EMPTY_ARRAY;
378
+ } else if (i === 0 && fromStateIds.length === 1) {
379
+ // Single-segment route: reversed = original, reuse cached frozen array
380
+ toDeactivate = fromStateIds;
381
+ } else {
382
+ toDeactivate = [];
383
+
384
+ for (let j = fromStateIds.length - 1; j >= i; j--) {
385
+ toDeactivate.push(fromStateIds[j]);
386
+ }
372
387
  }
373
388
 
374
- // Build activation list (forward order for proper initialization)
375
- const toActivate = toStateIds.slice(i);
389
+ // Build activation list reuse cached frozen array when using full list
390
+ const toActivate = i === 0 ? toStateIds : toStateIds.slice(i);
376
391
 
377
392
  // Determine intersection point (common ancestor)
378
393
  const intersection = i > 0 ? fromStateIds[i - 1] : EMPTY_INTERSECTION;
@@ -387,24 +402,38 @@ function computeTransitionPath(
387
402
  export function getTransitionPath(
388
403
  toState: State,
389
404
  fromState?: State,
390
- opts?: { reload?: boolean },
405
+ reload?: boolean,
391
406
  ): TransitionPath {
392
- if (opts?.reload) {
407
+ if (reload) {
393
408
  return computeTransitionPath(toState, fromState);
394
409
  }
410
+
395
411
  if (
396
- cachedResult !== null &&
397
- toState === cachedToState &&
398
- fromState === cachedFromState
412
+ cached1Result !== null &&
413
+ toState === cached1To &&
414
+ fromState === cached1From
399
415
  ) {
400
- return cachedResult;
416
+ return cached1Result;
417
+ }
418
+
419
+ /* v8 ignore next 6 -- @preserve: 2nd cache slot hit path exercised by alternating navigation benchmarks, not unit tests */
420
+ if (
421
+ cached2Result !== null &&
422
+ toState === cached2To &&
423
+ fromState === cached2From
424
+ ) {
425
+ return cached2Result;
401
426
  }
402
427
 
403
428
  const result = computeTransitionPath(toState, fromState);
404
429
 
405
- cachedToState = toState;
406
- cachedFromState = fromState;
407
- cachedResult = result;
430
+ cached2To = cached1To;
431
+ cached2From = cached1From;
432
+ cached2Result = cached1Result;
433
+
434
+ cached1To = toState;
435
+ cached1From = fromState;
436
+ cached1Result = result;
408
437
 
409
438
  return result;
410
439
  }
@@ -110,10 +110,7 @@ export class RouterWiringBuilder<
110
110
  setState: (state) => {
111
111
  this.state.set(state);
112
112
  },
113
- buildStateWithSegments: <P extends Params = Params>(
114
- routeName: string,
115
- routeParams: P,
116
- ) => {
113
+ buildNavigateState: (routeName, routeParams) => {
117
114
  const ctx = getInternals(this.router);
118
115
 
119
116
  if (!ctx.noValidate) {
@@ -121,15 +118,15 @@ export class RouterWiringBuilder<
121
118
  }
122
119
 
123
120
  const { name, params } = ctx.forwardState(routeName, routeParams);
121
+ const meta = this.routes.getMetaForState(name);
124
122
 
125
- return this.routes.buildStateWithSegmentsResolved(name, params);
126
- },
127
- makeState: (name, params, path, meta) =>
128
- this.state.makeState(name, params, path, meta),
129
- buildPath: (route, params) => {
130
- const ctx = getInternals(this.router);
123
+ if (meta === undefined) {
124
+ return;
125
+ }
131
126
 
132
- return ctx.buildPath(route, params);
127
+ const path = ctx.buildPath(name, params);
128
+
129
+ return this.state.makeState(name, params, path, meta, undefined, true);
133
130
  },
134
131
  areStatesEqual: (state1, state2, ignoreQueryParams) =>
135
132
  this.state.areStatesEqual(state1, state2, ignoreQueryParams),
@@ -154,10 +151,14 @@ export class RouterWiringBuilder<
154
151
  this.eventBus.sendNavigate(toState, fromState);
155
152
  },
156
153
  cancelNavigation: () => {
157
- this.eventBus.sendCancel(
158
- this.eventBus.getCurrentToState()!, // eslint-disable-line @typescript-eslint/no-non-null-assertion -- guaranteed set before TRANSITIONING
159
- this.state.get(),
160
- );
154
+ const toState = this.eventBus.getCurrentToState();
155
+
156
+ /* v8 ignore next -- @preserve: getCurrentToState() guaranteed set before TRANSITIONING */
157
+ if (toState === undefined) {
158
+ return;
159
+ }
160
+
161
+ this.eventBus.sendCancel(toState, this.state.get());
161
162
  },
162
163
  sendTransitionDone: (state, fromState, opts) => {
163
164
  this.eventBus.sendComplete(state, fromState, opts);
@@ -1 +0,0 @@
1
- import{logger as t}from"@real-router/logger";import{FSM as e}from"@real-router/fsm";var r=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"}),n="@@router/UNKNOWN_ROUTE",o={UNKNOWN_ROUTE:n},i="onStart",s="onStop",a="onTransitionStart",c="onTransitionCancel",u="onTransitionSuccess",l="onTransitionError",d={ROUTER_START:"$start",ROUTER_STOP:"$stop",TRANSITION_START:"$$start",TRANSITION_CANCEL:"$$cancel",TRANSITION_SUCCESS:"$$success",TRANSITION_ERROR:"$$error"},h=new Set([d.ROUTER_START,d.TRANSITION_START,d.TRANSITION_SUCCESS,d.TRANSITION_ERROR,d.TRANSITION_CANCEL,d.ROUTER_STOP]),f={maxDependencies:100,maxPlugins:50,maxListeners:1e4,warnListeners:1e3,maxEventDepth:5,maxLifecycleHandlers:200},p={maxDependencies:{min:0,max:1e4},maxPlugins:{min:0,max:1e3},maxListeners:{min:0,max:1e5},warnListeners:{min:0,max:1e5},maxEventDepth:{min:0,max:100},maxLifecycleHandlers:{min:0,max:1e4}},m=["replace","reload","force","forceDeactivate","redirected"],g=/\S/,v=/^[A-Z_a-z][\w-]*(?:\.[A-Z_a-z][\w-]*)*$/;function y(t,e){return new TypeError(`[router.${t}] ${e}`)}function w(t,e=new WeakSet){if(null==t)return!0;const r=typeof t;if("string"===r||"boolean"===r)return!0;if("number"===r)return Number.isFinite(t);if("function"===r||"symbol"===r)return!1;if(Array.isArray(t))return!e.has(t)&&(e.add(t),t.every(t=>w(t,e)));if("object"===r){if(e.has(t))return!1;e.add(t);const r=Object.getPrototypeOf(t);return(null===r||r===Object.prototype)&&Object.values(t).every(t=>w(t,e))}return!1}function T(t){if(null==t)return!0;const e=typeof t;return"string"===e||"boolean"===e||"number"===e&&Number.isFinite(t)}function b(t){if("object"!=typeof t||null===t||Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);if(null!==e&&e!==Object.prototype)return!1;let r=!1;for(const e in t){if(!Object.hasOwn(t,e))continue;const n=t[e];if(!T(n)){const t=typeof n;if("function"===t||"symbol"===t)return!1;r=!0;break}}return!r||w(t)}function S(t){return"string"==typeof t}function E(t){return"boolean"==typeof t}function A(t,e){return t in e}function O(t,e){if("string"!=typeof t)throw y(e,"Route name must be a string, got "+typeof t);if(""!==t){if(!g.test(t))throw y(e,"Route name cannot contain only whitespace");if(t.length>1e4)throw y(e,"Route name exceeds maximum length of 10000 characters. This is a technical safety limit.");if(!t.startsWith("@@")&&!v.test(t))throw y(e,`Invalid route name "${t}". Each segment must start with a letter or underscore, followed by letters, numbers, underscores, or hyphens. Segments are separated by dots (e.g., "users.profile").`)}}function P(t){return null===t?"null":Array.isArray(t)?`array[${t.length}]`:"object"==typeof t?"constructor"in t&&"Object"!==t.constructor.name?t.constructor.name:"object":typeof t}function $(t,e){if(!function(t){return"object"==typeof t&&null!==t&&function(t){return function(t){return"string"==typeof t&&(""===t||!(t.length>1e4)&&(!!t.startsWith("@@")||v.test(t)))}(t.name)&&"string"==typeof t.path&&b(t.params)}(t)}(t))throw new TypeError(`[${e}] Invalid state structure: ${P(t)}. Expected State object with name, params, and path properties.`)}var N=new WeakSet;function R(t){if(null!==t&&"object"==typeof t&&!Object.isFrozen(t))if(Object.freeze(t),Array.isArray(t))for(const e of t)R(e);else for(const e in t)R(t[e])}function C(t){return t?(N.has(t)||(R(t),N.add(t)),t):t}function D(t){return{warn:Math.floor(.2*t),error:Math.floor(.5*t)}}var j=new Set(Object.values(r)),F=new Set(["code","segment","path","redirect"]),I=new Set(["setCode","setErrorInstance","setAdditionalFields","hasField","getField","toJSON"]),x=class extends Error{segment;path;redirect;code;constructor(t,{message:e,segment:r,path:n,redirect:o,...i}={}){super(e??t),this.code=t,this.segment=r,this.path=n,this.redirect=o?function(t){if(!t)return t;if(null===(e=t)||"object"!=typeof e||"string"!=typeof e.name||"string"!=typeof e.path||"object"!=typeof e.params||null===e.params)throw new TypeError("[deepFreezeState] Expected valid State object, got: "+typeof t);var e;const r=structuredClone(t),n=new WeakSet;return function t(e){if(null===e||"object"!=typeof e)return;if(n.has(e))return;n.add(e),Object.freeze(e);const r=Array.isArray(e)?e:Object.values(e);for(const e of r)t(e)}(r),r}(o):void 0;for(const[t,e]of Object.entries(i)){if(F.has(t))throw new TypeError(`[RouterError] Cannot set reserved property "${t}"`);I.has(t)||(this[t]=e)}}setCode(t){this.code=t,j.has(this.message)&&(this.message=t)}setErrorInstance(t){if(!t)throw new TypeError("[RouterError.setErrorInstance] err parameter is required and must be an Error instance");this.message=t.message,this.cause=t.cause,this.stack=t.stack??""}setAdditionalFields(t){for(const[e,r]of Object.entries(t)){if(F.has(e))throw new TypeError(`[RouterError.setAdditionalFields] Cannot set reserved property "${e}"`);I.has(e)||(this[e]=r)}}hasField(t){return t in this}getField(t){return this[t]}toJSON(){const t={code:this.code,message:this.message};void 0!==this.segment&&(t.segment=this.segment),void 0!==this.path&&(t.path=this.path),void 0!==this.redirect&&(t.redirect=this.redirect);const e=new Set(["code","message","segment","path","redirect","stack"]);for(const r in this)Object.hasOwn(this,r)&&!e.has(r)&&(t[r]=this[r]);return t}},L={maxListeners:0,warnListeners:0,maxEventDepth:0},_=class extends Error{},M=class{#t=new Map;#e=null;#r=L;#n;#o;constructor(t){t?.limits&&(this.#r=t.limits),this.#n=t?.onListenerError??null,this.#o=t?.onListenerWarn??null}static validateCallback(t,e){if("function"!=typeof t)throw new TypeError(`Expected callback to be a function for event ${e}`)}setLimits(t){this.#r=t}on(t,e){const r=this.#i(t);if(r.has(e))throw new Error(`Duplicate listener for "${t}"`);const{maxListeners:n,warnListeners:o}=this.#r;if(0!==o&&r.size===o&&this.#o?.(t,o),0!==n&&r.size>=n)throw new Error(`Listener limit (${n}) reached for "${t}"`);return r.add(e),()=>{this.off(t,e)}}off(t,e){this.#t.get(t)?.delete(e)}emit(t,...e){const r=this.#t.get(t);r&&0!==r.size&&(0!==this.#r.maxEventDepth?this.#s(r,t,e):this.#a(r,t,e))}clearAll(){this.#t.clear(),this.#e=null}listenerCount(t){return this.#t.get(t)?.size??0}#a(t,e,r){const n=[...t];for(const t of n)try{this.#c(t,r)}catch(t){this.#n?.(e,t)}}#c(t,e){switch(e.length){case 0:t();break;case 1:t(e[0]);break;case 2:t(e[0],e[1]);break;case 3:t(e[0],e[1],e[2]);break;default:Function.prototype.apply.call(t,void 0,e)}}#s(t,e,r){this.#e??=new Map;const n=this.#e,o=n.get(e)??0;if(o>=this.#r.maxEventDepth)throw new _(`Maximum recursion depth (${this.#r.maxEventDepth}) exceeded for event: ${e}`);try{n.set(e,o+1);const i=[...t];for(const t of i)try{this.#c(t,r)}catch(t){if(t instanceof _)throw t;this.#n?.(e,t)}}finally{n.set(e,n.get(e)-1)}}#i(t){const e=this.#t.get(t);if(e)return e;const r=new Set;return this.#t.set(t,r),r}},U="IDLE",k="STARTING",B="READY",q="TRANSITIONING",z="DISPOSED",W="START",G="STARTED",V="NAVIGATE",Q="COMPLETE",H="FAIL",K="CANCEL",J="STOP",Y="DISPOSE",Z={initial:U,context:null,transitions:{[U]:{[W]:k,[Y]:z},[k]:{[G]:B,[H]:U},[B]:{[V]:q,[H]:B,[J]:U},[q]:{[V]:q,[Q]:B,[K]:B,[H]:B},[z]:{}}},X=new WeakMap;function tt(t){const e=X.get(t);if(!e)throw new TypeError("[real-router] Invalid router instance — not found in internals registry");return e}function et(t,e,r){return(...n)=>{const o=r.get(t);return o&&0!==o.length?function(t,e,r){let n=e;for(const e of t){const t=n;n=(...r)=>e(t,...r)}return n(...r)}(o,e,n):e(...n)}}var rt={defaultRoute:"",defaultParams:{},trailingSlash:"preserve",queryParamsMode:"loose",queryParams:{arrayFormat:"none",booleanFormat:"none",nullFormat:"default"},urlParamsEncoding:"default",allowNotFound:!0,rewritePathOnMatch:!0,noValidate:!1},nt={trailingSlash:["strict","never","always","preserve"],queryParamsMode:["default","strict","loose"],urlParamsEncoding:["default","uri","uriComponent","none"]},ot={arrayFormat:["none","brackets","index","comma"],booleanFormat:["none","string","empty-true"],nullFormat:["default","hidden"]};function it(t){Object.freeze(t);for(const e of Object.keys(t)){const r=t[e];r&&"object"==typeof r&&r.constructor===Object&&it(r)}return t}function st(t,e){return"function"==typeof t?t(e):t}function at(t,e,r){if("function"==typeof e&&("defaultRoute"===t||"defaultParams"===t))return;const n=rt[t];if(n&&"object"==typeof n)return function(t,e,r){if(!t||"object"!=typeof t||t.constructor!==Object)throw new TypeError(`[router.${r}] Invalid type for "${e}": expected plain object, got ${P(t)}`);for(const n in t)if(Object.getOwnPropertyDescriptor(t,n)?.get)throw new TypeError(`[router.${r}] Getters not allowed in "${e}": "${n}"`)}(e,t,r),void("queryParams"===t&&function(t,e){for(const r in t){if(!A(r,ot)){const t=Object.keys(ot).map(t=>`"${t}"`).join(", ");throw new TypeError(`[router.${e}] Unknown queryParams key: "${r}". Valid keys: ${t}`)}const n=t[r],o=ot[r];if(!o.includes(n)){const t=o.map(t=>`"${t}"`).join(", ");throw new TypeError(`[router.${e}] Invalid value for queryParams.${r}: expected one of ${t}, got "${String(n)}"`)}}}(e,r));if(typeof e!=typeof n)throw new TypeError(`[router.${r}] Invalid type for "${t}": expected ${typeof n}, got ${typeof e}`);t in nt&&function(t,e,r){const n=nt[t];if(!n.includes(e)){const o=n.map(t=>`"${t}"`).join(", ");throw new TypeError(`[router.${r}] Invalid value for "${t}": expected one of ${o}, got "${String(e)}"`)}}(t,e,r)}function ct(t,e,r){if("limits"===t)return void 0!==e&&function(t,e){if(!t||"object"!=typeof t||t.constructor!==Object)throw new TypeError(`[router.${e}]: invalid limits: expected plain object, got ${typeof t}`);for(const[r,n]of Object.entries(t)){if(!Object.hasOwn(p,r))throw new TypeError(`[router.${e}]: unknown limit: "${r}"`);void 0!==n&&ut(r,n,e)}}(e,r),!0;throw new TypeError(`[router.${r}] Unknown option: "${t}"`)}function ut(t,e,r){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError(`[router.${r}]: limit "${t}" must be an integer, got ${String(e)}`);const n=p[t];if(e<n.min||e>n.max)throw new RangeError(`[router.${r}]: limit "${t}" must be between ${n.min} and ${n.max}, got ${e}`)}var lt=class{#u;constructor(t={}){this.#u=it({...rt,...t})}static validateOptions(t,e){!function(t,e){if(!t||"object"!=typeof t||t.constructor!==Object)throw new TypeError(`[router.${e}] Invalid options: expected plain object, got ${P(t)}`);for(const[r,n]of Object.entries(t))A(r,rt)?void 0!==n&&at(r,n,e):ct(r,n,e)}(t,e)}get(){return this.#u}};function dt(t,e){return t===e||!(!Array.isArray(t)||!Array.isArray(e))&&t.length===e.length&&t.every((t,r)=>dt(t,e[r]))}var ht=class{#l=0;#d=void 0;#h=void 0;#f;#p=new Map;static validateAreStatesEqualArgs(t,e,r){if(null!=t&&$(t,"areStatesEqual"),null!=e&&$(e,"areStatesEqual"),void 0!==r&&"boolean"!=typeof r)throw new TypeError(`[router.areStatesEqual] Invalid ignoreQueryParams: ${P(r)}. Expected boolean.`)}get(){return this.#d}set(t){this.#h=this.#d,this.#d=t?C(t):void 0}getPrevious(){return this.#h}reset(){this.#d=void 0,this.#h=void 0,this.#p.clear(),this.#l=0}setDependencies(t){this.#f=t}makeState(t,e,r,n,o){const i=n?{...n,id:o??++this.#l,params:n.params}:void 0,s=this.#f.getDefaultParams();let a;return a=Object.hasOwn(s,t)?{...s[t],...e}:e?{...e}:{},C({name:t,params:a,path:r??this.#f.buildPath(t,e),meta:i})}areStatesEqual(t,e,r=!0){if(!t||!e)return!!t==!!e;if(t.name!==e.name)return!1;if(r){const r=t.meta?.params??e.meta?.params;return(r?function(t){const e=[];for(const r in t){const n=t[r];for(const t in n)"url"===n[t]&&e.push(t)}return e}(r):this.#m(t.name)).every(r=>dt(t.params[r],e.params[r]))}const n=Object.keys(t.params),o=Object.keys(e.params);return n.length===o.length&&n.every(r=>r in e.params&&dt(t.params[r],e.params[r]))}#m(t){const e=this.#p.get(t);if(void 0!==e)return e;const r=this.#f.getUrlParams(t);return this.#p.set(t,r),r}},ft={[i]:d.ROUTER_START,[s]:d.ROUTER_STOP,[u]:d.TRANSITION_SUCCESS,[a]:d.TRANSITION_START,[l]:d.TRANSITION_ERROR,[c]:d.TRANSITION_CANCEL},pt=Object.keys(ft).filter(t=>A(t,ft)),mt="router.usePlugin",gt=class e{#g=new Set;#v=new Set;#f;#y=f;static validateUsePluginArgs(t){!function(t){for(const[e,r]of t.entries())if("function"!=typeof r)throw new TypeError(`[router.usePlugin] Expected plugin factory function at index ${e}, got ${P(r)}`)}(t)}static validatePlugin(t){!function(t){if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError(`[router.usePlugin] Plugin factory must return an object, got ${P(t)}`);if("function"==typeof t.then)throw new TypeError("[router.usePlugin] Async plugin factories are not supported. Factory returned a Promise instead of a plugin object.");for(const e in t)if("teardown"!==e&&!A(e,ft))throw new TypeError(`[router.usePlugin] Unknown property '${e}'. Plugin must only contain event handlers and optional teardown.`)}(t)}static validatePluginLimit(t,e,r){!function(t,e,r=f.maxPlugins){if(0!==r&&t+e>r)throw new Error(`[router.usePlugin] Plugin limit exceeded (${r}). Current: ${t}, Attempting to add: ${e}. This indicates an architectural problem. Consider consolidating plugins.`)}(t,e,r)}static validateNoDuplicatePlugins(t,e){for(const r of t)if(e(r))throw new Error("[router.usePlugin] Plugin factory already registered. To re-register, first unsubscribe the existing plugin.")}setDependencies(t){this.#f=t}setLimits(t){this.#y=t}count(){return this.#g.size}use(...e){if(this.#w(e.length),1===e.length){const r=e[0],n=this.#T(r);this.#g.add(r);let o=!1;const i=()=>{if(!o){o=!0,this.#g.delete(r),this.#v.delete(i);try{n()}catch(e){t.error(mt,"Error during cleanup:",e)}}};return this.#v.add(i),i}const r=this.#b(e),n=[];try{for(const t of r){const e=this.#T(t);n.push({factory:t,cleanup:e})}}catch(e){for(const{cleanup:e}of n)try{e()}catch(e){t.error(mt,"Cleanup error:",e)}throw e}for(const{factory:t}of n)this.#g.add(t);let o=!1;const i=()=>{if(!o){o=!0,this.#v.delete(i);for(const{factory:t}of n)this.#g.delete(t);for(const{cleanup:e}of n)try{e()}catch(e){t.error(mt,"Error during cleanup:",e)}}};return this.#v.add(i),i}getAll(){return[...this.#g]}has(t){return this.#g.has(t)}disposeAll(){for(const t of this.#v)t();this.#g.clear(),this.#v.clear()}#w(e){const r=this.#y.maxPlugins;if(0===r)return;const n=e+this.#g.size,{warn:o,error:i}=D(r);n>=i?t.error(mt,`${n} plugins registered! This is excessive and will impact performance. Hard limit at ${r}.`):n>=o&&t.warn(mt,`${n} plugins registered. Consider if all are necessary.`)}#b(e){const r=new Set;for(const n of e)r.has(n)?t.warn(mt,"Duplicate factory in batch, will be registered once"):r.add(n);return r}#T(r){const n=this.#f.compileFactory(r);e.validatePlugin(n),Object.freeze(n);const o=[];for(const e of pt)e in n&&("function"==typeof n[e]?(o.push(this.#f.addEventListener(ft[e],n[e])),"onStart"===e&&this.#f.canNavigate()&&t.warn(mt,"Router already started, onStart will not be called")):t.warn(mt,`Property '${e}' is not a function, skipping`));return()=>{for(const t of o)t();"function"==typeof n.teardown&&n.teardown()}}};function vt(t,e){if(!E(t)&&"function"!=typeof t)throw new TypeError(`[router.${e}] Handler must be a boolean or factory function, got ${P(t)}`)}function yt(t,e,r){if(t)throw new Error(`[router.${r}] Cannot modify route "${e}" during its own registration`)}function wt(t,e,r=f.maxLifecycleHandlers){if(0!==r&&t>=r)throw new Error(`[router.${e}] Lifecycle handler limit exceeded (${r}). This indicates too many routes with individual handlers. Consider using plugins for cross-cutting concerns.`)}var Tt=class{#S=new Map;#E=new Map;#A=new Map;#O=new Map;#P=new Set;#$=new Set;#N=new Set;#f;#y=f;setDependencies(t){this.#f=t}setLimits(t){this.#y=t}addCanActivate(t,e,r,n=!1){n?this.#$.add(t):this.#$.delete(t),r||yt(this.#P.has(t),t,"addActivateGuard");const o=this.#E.has(t);o||r||wt(this.#E.size+1,"addActivateGuard",this.#y.maxLifecycleHandlers),this.#R("activate",t,e,this.#E,this.#O,"canActivate",o)}addCanDeactivate(t,e,r,n=!1){n?this.#N.add(t):this.#N.delete(t),r||yt(this.#P.has(t),t,"addDeactivateGuard");const o=this.#S.has(t);o||r||wt(this.#S.size+1,"addDeactivateGuard",this.#y.maxLifecycleHandlers),this.#R("deactivate",t,e,this.#S,this.#A,"canDeactivate",o)}clearCanActivate(t){this.#E.delete(t),this.#O.delete(t),this.#$.delete(t)}clearCanDeactivate(t){this.#S.delete(t),this.#A.delete(t),this.#N.delete(t)}clearAll(){this.#E.clear(),this.#O.clear(),this.#S.clear(),this.#A.clear(),this.#$.clear(),this.#N.clear()}clearDefinitionGuards(){for(const t of this.#$)this.#E.delete(t),this.#O.delete(t);for(const t of this.#N)this.#S.delete(t),this.#A.delete(t);this.#$.clear(),this.#N.clear()}getFactories(){const t={},e={};for(const[e,r]of this.#S)t[e]=r;for(const[t,r]of this.#E)e[t]=r;return[t,e]}getFunctions(){return[this.#A,this.#O]}canNavigateTo(t,e,r,n){for(const e of t)if(!this.#C(this.#A,e,r,n,"canNavigateTo"))return!1;for(const t of e)if(!this.#C(this.#O,t,r,n,"canNavigateTo"))return!1;return!0}#R(e,r,n,o,i,s,a){a?t.warn(`router.${s}`,`Overwriting existing ${e} handler for route "${r}"`):this.#w(o.size+1,s);const c=E(n)?function(t){const e=()=>t;return()=>e}(n):n;o.set(r,c),this.#P.add(r);try{const t=this.#f.compileFactory(c);if("function"!=typeof t)throw new TypeError(`[router.${s}] Factory must return a function, got ${P(t)}`);i.set(r,t)}catch(t){throw o.delete(r),t}finally{this.#P.delete(r)}}#C(e,r,n,o,i){const s=e.get(r);if(!s)return!0;try{const e=s(n,o);return"boolean"==typeof e?e:(t.warn(`router.${i}`,`Guard for "${r}" returned a Promise. Sync check cannot resolve async guards — returning false.`),!1)}catch{return!1}}#w(e,r){const n=this.#y.maxLifecycleHandlers;if(0===n)return;const{warn:o,error:i}=D(n);e>=i?t.error(`router.${r}`,`${e} lifecycle handlers registered! This is excessive. Hard limit at ${n}.`):e>=o&&t.warn(`router.${r}`,`${e} lifecycle handlers registered. Consider consolidating logic.`)}},bt=new Set;function St(){return{decoders:Object.create(null),encoders:Object.create(null),defaultParams:Object.create(null),forwardMap:Object.create(null),forwardFnMap:Object.create(null)}}function Et(t){const e={name:t.name,path:t.path};return t.children&&(e.children=t.children.map(t=>Et(t))),e}function At(t,e,r=""){for(let n=0;n<t.length;n++){const o=t[n],i=r?`${r}.${o.name}`:o.name;if(i===e)return t.splice(n,1),!0;if(o.children&&e.startsWith(`${i}.`)&&At(o.children,e,i))return!0}return!1}function Ot(t,e){for(const r of Object.keys(t))e(r)&&delete t[r]}function Pt(t){return`(${t.replaceAll(/(^<|>$)/g,"")})`}var $t=/([:*])([^/?<]+)(<[^>]+>)?(\?)?/g,Nt=/([:*][^/?<]+(?:<[^>]+>)?)\?(?=\/|$)/g,Rt=/\?(.+)$/,Ct=/[^\w!$'()*+,.:;|~-]/gu,Dt=/[^\w!$'()*+,.:;|~-]/u,jt={default:t=>Dt.test(t)?t.replaceAll(Ct,t=>encodeURIComponent(t)):t,uri:encodeURI,uriComponent:encodeURIComponent,none:t=>t},Ft={default:decodeURIComponent,uri:decodeURI,uriComponent:decodeURIComponent,none:t=>t};function It(){return{staticChildren:Object.create(null),paramChild:void 0,splatChild:void 0,route:void 0,slashChildRoute:void 0}}function xt(t){return t.length>1&&t.endsWith("/")?t.slice(0,-1):t}function Lt(t){const e={};if(0===t.length)return e;const r=t.split("&");for(const t of r){const r=t.indexOf("=");-1===r?e[t]="":e[t.slice(0,r)]=t.slice(r+1)}return e}function _t(t){const e=[];for(const r of Object.keys(t)){const n=t[r],o=encodeURIComponent(r);e.push(""===n?o:`${o}=${encodeURIComponent(String(n))}`)}return e.join("&")}function Mt(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function Ut(t){let e=0;for(;e<t.length;)if("%"===t[e]){if(e+2>=t.length)return!1;const r=t.codePointAt(e+1)??0,n=t.codePointAt(e+2)??0;if(!Mt(r)||!Mt(n))return!1;e+=3}else e++;return!0}var kt=/<[^>]*>/g;function Bt(t,e,r,n,o){const i=""===e.fullName;i||n.push(e);const s=e.absolute,a=e.paramMeta.pathPattern,c=s&&a.startsWith("~")?a.slice(1):a,u=(s?c:a).replaceAll(kt,""),l=s?u:(h=u,""===(d=r)?h:""===h?d:d+h);var d,h;let f=o;i||(f=function(t,e,r,n,o,i){const s=(g=n,xt(r)===xt(g)),a=Object.freeze([...o]),c=function(t){const e={};for(const r of t)e[r.fullName]=r.paramTypeMap;return Object.freeze(e)}(a),u=xt(r),l=function(t,e){const r=[];t.length>0&&r.push(...t);for(const t of e)t.paramMeta.queryParams.length>0&&r.push(...t.paramMeta.queryParams);return r}(t.rootQueryParams,o),d=function(t){const e=new Map;for(const r of t)for(const[t,n]of r.paramMeta.constraintPatterns)e.set(t,n);return e}(o),h=s?xt(n):u,{buildStaticParts:f,buildParamSlots:p}=function(t,e,r){const n=new Set,o=new Set;for(const t of e){for(const e of t.paramMeta.urlParams)n.add(e);for(const e of t.paramMeta.spatParams)o.add(e)}if(0===n.size)return{buildStaticParts:[t],buildParamSlots:[]};const i=[],s=[],a=/[:*]([\w]+)(?:<[^>]*>)?(\?)?/gu;let c,u=0;for(;null!==(c=a.exec(t));){const e=c[1],n="?"===c[2];i.push(t.slice(u,c.index));const a=o.has(e);s.push({paramName:e,isOptional:n,encoder:a?t=>{const e=jt[r],n=t.split("/");let o=e(n[0]);for(let t=1;t<n.length;t++)o+=`/${e(n[t])}`;return o}:jt[r]}),u=c.index+c[0].length}return i.push(t.slice(u)),{buildStaticParts:i,buildParamSlots:s}}(h,s?o.slice(0,-1):o,t.options.urlParamsEncoding),m={name:e.fullName,parent:i,depth:o.length-1,matchSegments:a,meta:c,declaredQueryParams:l,declaredQueryParamsSet:new Set(l),hasTrailingSlash:r.length>1&&r.endsWith("/"),constraintPatterns:d,hasConstraints:d.size>0,buildStaticParts:f,buildParamSlots:p,buildParamNamesSet:new Set(p.map(t=>t.paramName))};var g;return t.routesByName.set(e.fullName,m),t.segmentsByName.set(e.fullName,a),t.metaByName.set(e.fullName,c),s?function(t,e,r){var n,o;n=e,(function(t,e,r){const n=xt(r);if("/"===n||""===n)return e;let o=e,i=1;const s=n.length;for(;i<=s;){const e=n.indexOf("/",i),r=-1===e?s:e;if(r<=i)break;o=zt(t,o,n.slice(i,r)),i=r+1}return o}(o=t,o.root,r)).slashChildRoute=n;const i=xt(r),s=t.options.caseSensitive?i:i.toLowerCase();t.staticCache.has(s)&&t.staticCache.set(s,e)}(t,m,n):function(t,e,r,n,o){if(function(t,e,r){const n=xt(r);"/"!==n?qt(t,t.root,n,1,e):t.root.route=e}(t,e,r),0===o.paramMeta.urlParams.length){const r=t.options.caseSensitive?n:n.toLowerCase();t.staticCache.set(r,e)}}(t,m,r,u,e),m}(t,e,l,s?"":r,n,o));for(const r of e.children.values())Bt(t,r,l,n,f);i||n.pop()}function qt(t,e,r,n,o){const i=r.length;for(;n<=i;){const s=r.indexOf("/",n),a=-1===s?i:s,c=r.slice(n,a);if(c.endsWith("?")){const n=c.slice(1).replaceAll(kt,"").replace(/\?$/,"");return e.paramChild??={node:It(),name:n},qt(t,e.paramChild.node,r,a+1,o),void(a>=i?e.route??=o:qt(t,e,r,a+1,o))}e=zt(t,e,c),n=a+1}e.route=o}function zt(t,e,r){if(r.startsWith("*")){const t=r.slice(1);return e.splatChild??={node:It(),name:t},e.splatChild.node}if(r.startsWith(":")){const t=r.slice(1).replaceAll(kt,"").replace(/\?$/,"");return e.paramChild??={node:It(),name:t},e.paramChild.node}const n=t.options.caseSensitive?r:r.toLowerCase();return n in e.staticChildren||(e.staticChildren[n]=It()),e.staticChildren[n]}var Wt=/[\u0080-\uFFFF]/,Gt=class{get options(){return this.#t}#t;#e=It();#o=new Map;#i=new Map;#r=new Map;#s=new Map;#n="";#D=[];constructor(t){this.#t={caseSensitive:t?.caseSensitive??!0,strictTrailingSlash:t?.strictTrailingSlash??!1,strictQueryParams:t?.strictQueryParams??!1,urlParamsEncoding:t?.urlParamsEncoding??"default",parseQueryString:t?.parseQueryString??Lt,buildQueryString:t?.buildQueryString??_t}}registerTree(t){this.#D=t.paramMeta.queryParams,Bt({root:this.#e,options:this.#t,routesByName:this.#o,segmentsByName:this.#i,metaByName:this.#r,staticCache:this.#s,rootQueryParams:this.#D},t,"",[],null)}match(t){const e=this.#a(t);if(!e)return;const[r,n,o]=e,i=this.#t.caseSensitive?n:n.toLowerCase(),s=this.#s.get(i);if(s){if(this.#t.strictTrailingSlash&&!this.#c(r,s))return;return this.#j(s,{},o)}const a={},c=this.#F(n,a);return!c||this.#t.strictTrailingSlash&&!this.#c(r,c)||c.hasConstraints&&!this.#I(a,c)||!this.#x(a)?void 0:this.#j(c,a,o)}buildPath(t,e,r){const n=this.#o.get(t);if(!n)throw new Error(`[SegmentMatcher.buildPath] '${t}' is not defined`);n.hasConstraints&&e&&this.#L(n,t,e);const o=this.#_(n,e),i=this.#M(o,r?.trailingSlash),s=this.#U(n,e,r?.queryParamsMode);return i+(s?`?${s}`:"")}getSegmentsByName(t){return this.#i.get(t)}getMetaByName(t){return this.#r.get(t)}hasRoute(t){return this.#o.has(t)}setRootPath(t){this.#n=t}#L(t,e,r){for(const[n,o]of t.constraintPatterns){const t=r[n];if(null!=t){const r="object"==typeof t?JSON.stringify(t):String(t);if(!o.pattern.test(r))throw new Error(`[SegmentMatcher.buildPath] '${e}' — param '${n}' value '${r}' does not match constraint '${o.constraint}'`)}}}#_(t,e){const r=t.buildStaticParts,n=t.buildParamSlots;if(0===n.length)return this.#n+r[0];let o=this.#n+r[0];for(const[t,i]of n.entries()){const n=e?.[i.paramName];if(null==n){if(!i.isOptional)throw new Error(`[SegmentMatcher.buildPath] Missing required param '${i.paramName}'`);o.length>1&&o.endsWith("/")&&(o=o.slice(0,-1)),o+=r[t+1];continue}const s="object"==typeof n?JSON.stringify(n):String(n);o+=i.encoder(s)+r[t+1]}return o}#M(t,e){return"always"!==e||t.endsWith("/")?"never"===e&&"/"!==t&&t.endsWith("/")?t.slice(0,-1):t:`${t}/`}#U(t,e,r){if(!e)return"";const n={};let o=!1;for(const r of t.declaredQueryParams)r in e&&(n[r]=e[r],o=!0);if("loose"===r)for(const r in e)!Object.hasOwn(e,r)||t.declaredQueryParamsSet.has(r)||t.buildParamNamesSet.has(r)||(n[r]=e[r],o=!0);return o?this.#t.buildQueryString(n):""}#a(t){if(""===t&&(t="/"),!t.startsWith("/"))return;const e=t.indexOf("#");if(-1!==e&&(t=t.slice(0,e)),Wt.test(t))return;if(this.#n.length>0){if(!t.startsWith(this.#n))return;t=t.slice(this.#n.length)||"/"}const r=t.indexOf("?"),n=-1===r?t:t.slice(0,r),o=-1===r?void 0:t.slice(r+1);return n.includes("//")?void 0:[n,xt(n),o]}#j(t,e,r){if(void 0!==r){const n=this.#t.parseQueryString(r);if(this.#t.strictQueryParams){const e=t.declaredQueryParamsSet;for(const t of Object.keys(n))if(!e.has(t))return}for(const t of Object.keys(n))e[t]=n[t]}return{segments:t.matchSegments,params:e,meta:t.meta}}#c(t,e){return(t.length>1&&t.endsWith("/"))===e.hasTrailingSlash}#F(t,e){return 1===t.length?this.#e.slashChildRoute??this.#e.route:this.#k(this.#e,t,1,e)}#k(t,e,r,n){let o=t;const i=e.length;for(;r<=i;){const t=e.indexOf("/",r),s=-1===t?i:t,a=e.slice(r,s),c=this.#t.caseSensitive?a:a.toLowerCase();let u;if(c in o.staticChildren)u=o.staticChildren[c];else{if(!o.paramChild){if(o.splatChild){const t={},i=this.#k(o.splatChild.node,e,r,t);return i?(Object.assign(n,t),i):(n[o.splatChild.name]=e.slice(r),o.splatChild.node.route)}return}u=o.paramChild.node,n[o.paramChild.name]=a}o=u,r=s+1}return o.slashChildRoute??o.route}#x(t){const e=this.#t.urlParamsEncoding;if("none"===e)return!0;const r=Ft[e];for(const e in t){const n=t[e];if(n.includes("%")){if(!Ut(n))return!1;t[e]=r(n)}}return!0}#I(t,e){for(const[r,n]of e.constraintPatterns)if(!n.pattern.test(t[r]))return!1;return!0}},Vt=t=>{const e=t.indexOf("%"),r=t.indexOf("+");if(-1===e&&-1===r)return t;const n=-1===r?t:t.split("+").join(" ");return-1===e?n:decodeURIComponent(n)},Qt=t=>{const e=typeof t;if("string"!==e&&"number"!==e&&"boolean"!==e)throw new TypeError(`[search-params] Array element must be a string, number, or boolean — received ${"object"===e&&null===t?"null":e}`);return encodeURIComponent(t)},Ht={none:{encodeArray:(t,e)=>e.map(e=>`${t}=${Qt(e)}`).join("&")},brackets:{encodeArray:(t,e)=>e.map(e=>`${t}[]=${Qt(e)}`).join("&")},index:{encodeArray:(t,e)=>e.map((e,r)=>`${t}[${r}]=${Qt(e)}`).join("&")},comma:{encodeArray:(t,e)=>`${t}=${e.map(t=>Qt(t)).join(",")}`}},Kt={none:{encode:(t,e)=>`${t}=${e}`,decodeUndefined:()=>null,decodeRaw:()=>null,decodeValue:t=>t},string:{encode:(t,e)=>`${t}=${e}`,decodeUndefined:()=>null,decodeRaw:t=>"true"===t||"false"!==t&&null,decodeValue:t=>t},"empty-true":{encode:(t,e)=>e?t:`${t}=false`,decodeUndefined:()=>!0,decodeRaw:()=>null,decodeValue:t=>t}},Jt={default:{encode:t=>t},hidden:{encode:()=>""}},Yt=(t,e,r)=>({boolean:Kt[e],null:Jt[r],array:Ht[t]}),Zt={arrayFormat:"none",booleanFormat:"none",nullFormat:"default",strategies:{boolean:Kt.none,null:Jt.default,array:Ht.none}},Xt=t=>{if(!t||void 0===t.arrayFormat&&void 0===t.booleanFormat&&void 0===t.nullFormat)return Zt;const e=t.arrayFormat??"none",r=t.booleanFormat??"none",n=t.nullFormat??"default";return{arrayFormat:e,booleanFormat:r,nullFormat:n,strategies:Yt(e,r,n)}},te=t=>encodeURIComponent(t),ee=(t,e,r)=>{const n=te(t);switch(typeof e){case"string":case"number":default:return`${n}=${te(e)}`;case"boolean":return r.strategies.boolean.encode(n,e);case"object":return null===e?r.strategies.null.encode(n):Array.isArray(e)?r.strategies.array.encodeArray(n,e):`${n}=${te(e)}`}};function re(t,e,r,n,o){const i=t.indexOf("=",e),s=-1!==i&&i<r,a=t.slice(e,s?i:r),{name:c,hasBrackets:u}=function(t){const e=t.indexOf("[");return-1===e?{name:t,hasBrackets:!1}:{name:t.slice(0,e),hasBrackets:!0}}(a);var l,d,h,f,p;!function(t,e,r,n){const o=t[e];void 0===o?t[e]=n?[r]:r:Array.isArray(o)?o.push(r):t[e]=[o,r]}(n,Vt(c),(l=t,d=i,h=r,f=s,p=o,p?((t,e)=>{if(void 0===t)return e.boolean.decodeUndefined();const r=e.boolean.decodeRaw(t);if(null!==r)return r;const n=Vt(t);return e.boolean.decodeValue(n)})(f?l.slice(d+1,h):void 0,p):f?Vt(l.slice(d+1,h)):null),u)}function ne(t,e){const r=t.path,n=r.startsWith("~"),o=n?r.slice(1):r,i={name:t.name,path:o,absolute:n,children:[],parent:e,nonAbsoluteChildren:[],fullName:""};if(t.children)for(const e of t.children){const t=ne(e,i);i.children.push(t)}return i}function oe(t,e){return t.endsWith("/")&&e.startsWith("/")?t+e.slice(1):t+e}function ie(t){const e=new Map;for(const r of t)e.set(r.name,r);return e}function se(t,e,r){const n=function(t){const e=[],r=[],n=[],o={},i=new Map,s=t.replaceAll(Nt,"$1"),a=Rt.exec(s);if(null!==a){const e=a[1].split("&");for(const t of e){const e=t.trim();e.length>0&&(r.push(e),o[e]="query")}t=t.slice(0,a.index)}let c;for(;null!==(c=$t.exec(t));){const t=c[2],r=c[3];if("*"===c[1])n.push(t),e.push(t),o[t]="url";else if(e.push(t),o[t]="url",r){const e=`^${Pt(r)}$`;i.set(t,{pattern:new RegExp(e),constraint:r})}}return{urlParams:e,queryParams:r,spatParams:n,paramTypeMap:o,constraintPatterns:i,pathPattern:t}}(t.path),o=function(t){const e={};for(const r of t.urlParams)e[r]="url";for(const r of t.queryParams)e[r]="query";return e}(n),i={name:t.name,path:t.path,absolute:t.absolute,parent:e,children:void 0,paramMeta:n,nonAbsoluteChildren:void 0,fullName:"",staticPath:null,paramTypeMap:o};var s;i.fullName=(s=i,s.parent?.name?`${s.parent.fullName}.${s.name}`:s.name);const{childrenMap:a,nonAbsoluteChildren:c}=function(t,e,r){const n=[],o=[];for(const i of t){const t=se(i,e,r);n.push(t),t.absolute||o.push(t)}return{childrenMap:ie(n),nonAbsoluteChildren:o}}(t.children,i,r);return i.children=a,i.nonAbsoluteChildren=c,i.staticPath=function(t){if(!t.path)return null;const{urlParams:e,queryParams:r,spatParams:n}=t.paramMeta;if(e.length>0||r.length>0||n.length>0)return null;const o=[];let i=t.parent;for(;i?.path;)o.unshift(i),i=i.parent;let s="";for(const t of o){const{urlParams:e,queryParams:r,spatParams:n}=t.paramMeta;if(e.length>0||r.length>0||n.length>0)return null;s=t.absolute?t.path:oe(s,t.path)}return t.absolute?t.path:oe(s,t.path)}(i),r&&(Object.freeze(c),Object.freeze(o),Object.freeze(i.children),Object.freeze(i)),i}function ae(t,e,r,n){return function(t,e){const r=[];return{add(t){return r.push(t),this},addMany(t){return r.push(...t),this},build:n=>function(t,e=!0){return se(t,null,e)}(function(t,e,r){const n=ne({name:t,path:e},null);for(const t of r){const e=ne(t,n);n.children.push(e)}return n}(t,e,r),!n?.skipFreeze)}}(t,e).addMany(r).build(n)}function ce(t){const e={name:t.name,path:t.absolute?`~${t.path}`:t.path};return t.children.size>0&&(e.children=[...t.children.values()].map(t=>ce(t))),e}function ue(t){return[...t.children.values()].map(t=>ce(t))}function le(t){const e=t?.queryParams;return new Gt({...void 0===t?.caseSensitive?void 0:{caseSensitive:t.caseSensitive},...void 0===t?.strictTrailingSlash?void 0:{strictTrailingSlash:t.strictTrailingSlash},...void 0===t?.strictQueryParams?void 0:{strictQueryParams:t.strictQueryParams},...void 0===t?.urlParamsEncoding?void 0:{urlParamsEncoding:t.urlParamsEncoding},parseQueryString:t=>((t,e)=>{const r=(t=>{const e=t.indexOf("?");return-1===e?t:t.slice(e+1)})(t);if(""===r||"?"===r)return{};if(!e)return function(t){const e={};return function(t,e){let r=0;const n=t.length;for(;r<n;){let o=t.indexOf("&",r);-1===o&&(o=n),re(t,r,o,e),r=o+1}}(t,e),e}(r);const n=Xt(e),o={};let i=0;const s=r.length;for(;i<s;){let t=r.indexOf("&",i);-1===t&&(t=s),re(r,i,t,o,n.strategies),i=t+1}return o})(t,e),buildQueryString:t=>((t,e)=>{const r=Object.keys(t);if(0===r.length)return"";const n=Xt(e),o=[];for(const e of r){const r=t[e];if(void 0===r)continue;const i=ee(e,r,n);i&&o.push(i)}return o.join("&")})(t,e)})}function de(t,e){return new TypeError(`[router.${t}] ${e}`)}var he=/^[A-Z_a-z][\w-]*$/,fe=/\S/;function pe(t){return null===t?"null":"object"==typeof t?"constructor"in t&&"Object"!==t.constructor.name?t.constructor.name:"object":typeof t}function me(t,e){if(!e.includes("."))return t.children.get(e);let r=t;for(const t of e.split("."))if(r=r.children.get(t),!r)return;return r}function ge(t,e,r,n="",o,i){!function(t,e){if(!t||"object"!=typeof t)throw new TypeError(`[router.${e}] Route must be an object, got ${pe(t)}`);const r=Object.getPrototypeOf(t);if(r!==Object.prototype&&null!==r)throw new TypeError(`[router.${e}] Route must be a plain object, got ${pe(t)}`);if(function(t){for(const e of Object.keys(t)){const r=Object.getOwnPropertyDescriptor(t,e);if(r&&(r.get||r.set))return!0}return!1}(t))throw new TypeError(`[router.${e}] Route must not have getters or setters`)}(t,e);const s=t;!function(t,e){if("string"!=typeof t.name)throw new TypeError(`[router.${e}] Route name must be a string, got ${pe(t.name)}`);const r=t.name;if(""===r)throw new TypeError(`[router.${e}] Route name cannot be empty`);if(!fe.test(r))throw new TypeError(`[router.${e}] Route name cannot contain only whitespace`);if(r.length>1e4)throw new TypeError(`[router.${e}] Route name exceeds maximum length of 10000 characters`);if(!r.startsWith("@@")){if(r.includes("."))throw new TypeError(`[router.${e}] Route name "${r}" cannot contain dots. Use children array or { parent } option in addRoute() instead.`);if(!he.test(r))throw new TypeError(`[router.${e}] Invalid route name "${r}". Name must start with a letter or underscore, followed by letters, numbers, underscores, or hyphens.`)}}(s,e),function(t,e,r,n){if("string"!=typeof t){let e;throw e=null===t?"null":Array.isArray(t)?"array":typeof t,de(r,`Route path must be a string, got ${e}`)}if(""===t)return;if(/\s/.test(t))throw de(r,`Invalid path for route "${e}": whitespace not allowed in "${t}"`);if(!/^([/?~]|[^/]+$)/.test(t))throw de(r,`Route "${e}" has invalid path format: "${t}". Path should start with '/', '~', '?' or be a relative segment.`);if(t.includes("//"))throw de(r,`Invalid path for route "${e}": double slashes not allowed in "${t}"`);const o=n&&Object.values(n.paramTypeMap).includes("url");if(t.startsWith("~")&&o)throw de(r,`Absolute path "${t}" cannot be used under parent route with URL parameters`)}(s.path,s.name,e,r),function(t,e){if(void 0!==t.encodeParams&&"function"!=typeof t.encodeParams)throw new TypeError(`[router.${e}] Route "${String(t.name)}" encodeParams must be a function`)}(s,e),function(t,e){if(void 0!==t.decodeParams&&"function"!=typeof t.decodeParams)throw new TypeError(`[router.${e}] Route "${String(t.name)}" decodeParams must be a function`)}(s,e);const a=s.name,c=n?`${n}.${a}`:a;r&&c&&function(t,e,r){if(me(t,e))throw new Error(`[router.${r}] Route "${e}" already exists`)}(r,c,e),o&&function(t,e,r){if(t.has(e))throw new Error(`[router.${r}] Duplicate route "${e}" in batch`);t.add(e)}(o,c,e);const u=s.path,l=n;if(r&&function(t,e,r,n){const o=""===e?t:me(t,e);if(o)for(const t of o.children.values())if(t.path===r)throw new Error(`[router.${n}] Path "${r}" is already defined`)}(r,l,u,e),i&&function(t,e,r,n){const o=t.get(e);if(o?.has(r))throw new Error(`[router.${n}] Path "${r}" is already defined`);o?o.add(r):t.set(e,new Set([r]))}(i,l,u,e),void 0!==s.children){if(!Array.isArray(s.children))throw new TypeError(`[router.${e}] Route "${a}" children must be an array, got ${pe(s.children)}`);for(const t of s.children)ge(t,e,r,c,o,i)}}function ve(t,e){if(void 0!==t.canActivate&&"function"!=typeof t.canActivate)throw new TypeError(`[router.addRoute] canActivate must be a function for route "${e}", got ${P(t.canActivate)}`);if(void 0!==t.canDeactivate&&"function"!=typeof t.canDeactivate)throw new TypeError(`[router.addRoute] canDeactivate must be a function for route "${e}", got ${P(t.canDeactivate)}`);if(void 0!==t.defaultParams){const r=t.defaultParams;if(null===r||"object"!=typeof r||Array.isArray(r))throw new TypeError(`[router.addRoute] defaultParams must be an object for route "${e}", got ${P(t.defaultParams)}`)}if("AsyncFunction"===t.decodeParams?.constructor.name)throw new TypeError(`[router.addRoute] decodeParams cannot be async for route "${e}". Async functions break matchPath/buildPath.`);if("AsyncFunction"===t.encodeParams?.constructor.name)throw new TypeError(`[router.addRoute] encodeParams cannot be async for route "${e}". Async functions break matchPath/buildPath.`);if(function(t,e){if(void 0!==t&&"function"==typeof t){const r="AsyncFunction"===t.constructor.name,n=t.toString().includes("__awaiter");if(r||n)throw new TypeError(`[router.addRoute] forwardTo callback cannot be async for route "${e}". Async functions break matchPath/buildPath.`)}}(t.forwardTo,e),t.children)for(const r of t.children)ve(r,`${e}.${r.name}`)}function ye(t){const e=new Set,r=/[*:]([A-Z_a-z]\w*)/g;let n;for(;null!==(n=r.exec(t));)e.add(n[1]);return e}function we(t){const e=new Set;for(const r of t)for(const t of ye(r))e.add(t);return e}function Te(t,e,r="",n=[]){for(const o of t){const t=r?`${r}.${o.name}`:o.name,i=[...n,o.path];if(t===e)return i;if(o.children&&e.startsWith(`${t}.`))return Te(o.children,e,t,i)}throw new Error(`[internal] collectPathsToRoute: route "${e}" not found`)}function be(t,e=""){const r=new Set;for(const n of t){const t=e?`${e}.${n.name}`:n.name;if(r.add(t),n.children)for(const e of be(n.children,t))r.add(e)}return r}function Se(t,e=""){const r=new Map;for(const n of t){const t=e?`${e}.${n.name}`:n.name;if(n.forwardTo&&"string"==typeof n.forwardTo&&r.set(t,n.forwardTo),n.children)for(const[e,o]of Se(n.children,t))r.set(e,o)}return r}function Ee(t,e,r,n){return e?function(t){const e=new Set;for(const r of t){for(const t of r.paramMeta.urlParams)e.add(t);for(const t of r.paramMeta.spatParams)e.add(t)}return e}(function(t,e){const r=[],n=e.includes(".")?e.split("."):[e];""!==t.path&&r.push(t);let o=t;for(const t of n){const e=o.children.get(t);if(!e)return null;r.push(e),o=e}return r}(r,t)):we(Te(n,t))}function Ae(t,e,r,n,o){const i=function(t,e){const r=e.split(".");let n=t;for(const t of r)if(n=n.children.get(t),!n)return!1;return!0}(o,e),s=n.has(e);if(!i&&!s)throw new Error(`[router.addRoute] forwardTo target "${e}" does not exist for route "${t}"`);const a=we(Te(r,t)),c=[...Ee(e,i,o,r)].filter(t=>!a.has(t));if(c.length>0)throw new Error(`[router.addRoute] forwardTo target "${e}" requires params [${c.join(", ")}] that are not available in source route "${t}"`)}function Oe(t,e,r=100){const n=new Set,o=[t];let i=t;for(;e[i];){const t=e[i];if(n.has(t)){const e=o.indexOf(t),r=[...o.slice(e),t];throw new Error(`Circular forwardTo: ${r.join(" → ")}`)}if(n.add(i),o.push(t),i=t,o.length>r)throw new Error(`forwardTo chain exceeds maximum depth (${r}): ${o.join(" → ")}`)}return i}function Pe(t,e,r){const n=be(t),o=Se(t),i={...e};for(const[t,e]of o)i[t]=e;for(const[e,i]of o)Ae(e,i,t,n,r);for(const t of Object.keys(i))Oe(t,i)}function $e(t,e){if(t.startsWith("@@"))throw new Error(`[router.${e}] Route name "${t}" uses the reserved "@@" prefix. Routes with this prefix are internal and cannot be modified through the public API.`)}function Ne(t,e){for(const r of t)r&&"object"==typeof r&&"string"==typeof r.name&&($e(r.name,e),r.children&&Ne(r.children,e))}function Re(t){O(t,"removeRoute")}function Ce(t){if("string"!=typeof t)throw new TypeError(`[router.setRootPath] rootPath must be a string, got ${P(t)}`)}function De(t){for(const e of t){if(null===e||"object"!=typeof e||Array.isArray(e))throw new TypeError(`[router.addRoute] Route must be an object, got ${P(e)}`);ve(e,e.name)}}function je(t){if("string"!=typeof t||""===t)throw new TypeError(`[router.addRoute] parent option must be a non-empty string, got ${P(t)}`);O(t,"addRoute")}function Fe(t,e,r){if(!S(t))throw new TypeError(`[router.${r}] Invalid routeName: ${P(t)}. Expected string.`);if(!b(e))throw new TypeError(`[router.${r}] Invalid routeParams: ${P(e)}. Expected plain object.`)}function Ie(t,e){if(O(t,"updateRoute"),""===t)throw new ReferenceError("[router.updateRoute] Invalid name: empty string. Cannot update root node.");if(null===e)throw new TypeError("[real-router] updateRoute: updates must be an object, got null");if("object"!=typeof e||Array.isArray(e))throw new TypeError(`[real-router] updateRoute: updates must be an object, got ${P(e)}`)}function xe(t,e){if("AsyncFunction"===t.constructor.name||t.toString().includes("__awaiter"))throw new TypeError(`[real-router] updateRoute: ${e} cannot be an async function`)}function Le(t,e){if(null!=t){if("function"!=typeof t)throw new TypeError(`[real-router] updateRoute: ${e} must be a function or null, got ${typeof t}`);xe(t,e)}}function _e(t,e,r,n){if(null!=t){if("string"!=typeof t&&"function"!=typeof t)throw new TypeError(`[real-router] updateRoute: forwardTo must be a string, function, or null, got ${P(t)}`);"function"==typeof t&&xe(t,"forwardTo callback")}if(null!=e&&("object"!=typeof e||Array.isArray(e)))throw new TypeError(`[real-router] updateRoute: defaultParams must be an object or null, got ${P(e)}`);Le(r,"decodeParams"),Le(n,"encodeParams")}function Me(t){if(!S(t))throw new TypeError("[real-router] matchPath: path must be a string, got "+typeof t)}function Ue(t,e,r,n){if(n&&e){let t=e;for(const e of n.split("."))if(t=t.children.get(e),!t)throw new Error(`[router.addRoute] Parent route "${n}" does not exist`)}const o=new Set,i=new Map;for(const r of t)ge(r,"addRoute",e,n??"",o,i);e&&r&&Pe(t,r,e)}function ke(e,r,n){if(r){const n=r===e,o=r.startsWith(`${e}.`);if(n||o)return t.warn("router.removeRoute",`Cannot remove route "${e}" — it is currently active${n?"":` (current: "${r}")`}. Navigate away first.`),!1}return n&&t.warn("router.removeRoute",`Route "${e}" removed while navigation is in progress. This may cause unexpected behavior.`),!0}function Be(e){return!e||(t.error("router.clearRoutes","Cannot clear routes while navigation is in progress. Wait for navigation to complete."),!1)}function qe(t,e,r,n,o){if(!r(t))throw new ReferenceError(`[real-router] updateRoute: route "${t}" does not exist`);if(null!=e&&"string"==typeof e){if(!r(e))throw new Error(`[real-router] updateRoute: forwardTo target "${e}" does not exist`);(function(t,e,r){const n=r.getSegmentsByName(t),o=r.getSegmentsByName(e),i=function(t){const e=new Set;for(const r of t)for(const t of r.paramMeta.urlParams)e.add(t);return e}(n),s=[];for(const t of o)for(const e of t.paramMeta.urlParams)s.push(e);const a=s.filter(t=>!i.has(t));if(a.length>0)throw new Error(`[real-router] forwardTo target "${e}" requires params [${a.join(", ")}] that are not available in source route "${t}"`)})(t,e,n),function(t,e,r){Oe(t,{...r.forwardMap,[t]:e})}(t,e,o)}}function ze(t,e,r){const n=ae("",e,t),o=le(r);return o.registerTree(n),{tree:n,matcher:o}}function We(t,e){const r=ze(t.definitions,t.rootPath,t.matcherOptions);t.tree=r.tree,t.matcher=r.matcher,t.resolvedForwardMap=He(t.config,e)}function Ge(t){const e=ze(t.definitions,t.rootPath,t.matcherOptions);t.tree=e.tree,t.matcher=e.matcher}function Ve(t){Qe(t),Ge(t)}function Qe(t){t.definitions.length=0,Object.assign(t.config,St()),t.resolvedForwardMap=Object.create(null),t.routeCustomFields=Object.create(null)}function He(t,e){return e?Je(t):Ke(t)}function Ke(t){const e=Object.create(null);for(const r of Object.keys(t.forwardMap))e[r]=Oe(r,t.forwardMap);return e}function Je(t){const e=Object.create(null);for(const r of Object.keys(t.forwardMap)){let n=r;for(;t.forwardMap[n];)n=t.forwardMap[n];e[r]=n}return e}function Ye(e,r,n,o,i,s,a){const c=new Set(["name","path","children","canActivate","canDeactivate","forwardTo","encodeParams","decodeParams","defaultParams"]),u=Object.fromEntries(Object.entries(e).filter(([t])=>!c.has(t)));Object.keys(u).length>0&&(o[r]=u),e.canActivate&&(a?a.addActivateGuard(r,e.canActivate):i.set(r,e.canActivate)),e.canDeactivate&&(a?a.addDeactivateGuard(r,e.canDeactivate):s.set(r,e.canDeactivate)),e.forwardTo&&function(e,r,n){if(e.canActivate&&t.warn("real-router",`Route "${r}" has both forwardTo and canActivate. canActivate will be ignored because forwardTo creates a redirect (industry standard). Move canActivate to the target route "${"string"==typeof e.forwardTo?e.forwardTo:"[dynamic]"}".`),e.canDeactivate&&t.warn("real-router",`Route "${r}" has both forwardTo and canDeactivate. canDeactivate will be ignored because forwardTo creates a redirect (industry standard). Move canDeactivate to the target route "${"string"==typeof e.forwardTo?e.forwardTo:"[dynamic]"}".`),"function"==typeof e.forwardTo){const t="AsyncFunction"===e.forwardTo.constructor.name,n=e.forwardTo.toString().includes("__awaiter");if(t||n)throw new TypeError(`forwardTo callback cannot be async for route "${r}". Async functions break matchPath/buildPath.`)}"string"==typeof e.forwardTo?n.forwardMap[r]=e.forwardTo:n.forwardFnMap[r]=e.forwardTo}(e,r,n),e.decodeParams&&(n.decoders[r]=t=>e.decodeParams?.(t)??t),e.encodeParams&&(n.encoders[r]=t=>e.encodeParams?.(t)??t),e.defaultParams&&(n.defaultParams[r]=e.defaultParams)}function Ze(t,e,r,n,o,i,s=""){for(const a of t){const t=s?`${s}.${a.name}`:a.name;Ye(a,t,e,r,n,o,i),a.children&&Ze(a.children,e,r,n,o,i,t)}}var Xe,tr,er=".";function rr(t){const e=[];for(let r=t.length-1;r>=0;r--)e.push(t[r]);return e}function nr(t){const e=typeof t;return"string"===e||"number"===e||"boolean"===e}function or(t,e,r){const n=e.meta?.params[t];if(!n||"object"!=typeof n)return!0;for(const t of Object.keys(n)){const n=e.params[t],o=r.params[t];if(nr(n)&&nr(o)&&String(n)!==String(o))return!1}return!0}function ir(t){if(!t)return[""];const e=t.indexOf(er);if(-1===e)return[t];const r=t.indexOf(er,e+1);if(-1===r)return[t.slice(0,e),t];const n=t.indexOf(er,r+1);return-1===n?[t.slice(0,e),t.slice(0,r),t]:-1===t.indexOf(er,n+1)?[t.slice(0,e),t.slice(0,r),t.slice(0,n),t]:function(t){const e=t.split(er),r=e.length,n=[e[0]];let o=e[0].length;for(let i=1;i<r-1;i++)o+=1+e[i].length,n.push(t.slice(0,o));return n.push(t),n}(t)}var sr=null;function ar(t,e){if(!e)return{intersection:"",toActivate:ir(t.name),toDeactivate:[]};if(void 0===t.meta?.params&&void 0===e.meta?.params)return{intersection:"",toActivate:ir(t.name),toDeactivate:rr(ir(e.name))};const r=ir(t.name),n=ir(e.name),o=function(t,e,r,n,o){for(let i=0;i<o;i++){const o=r[i];if(o!==n[i])return i;if(!or(o,t,e))return i}return o}(t,e,r,n,Math.min(n.length,r.length)),i=[];for(let t=n.length-1;t>=o;t--)i.push(n[t]);const s=r.slice(o);return{intersection:o>0?n[o-1]:"",toDeactivate:i,toActivate:s}}function cr(t,e,r){if(r?.reload)return ar(t,e);if(null!==sr&&t===Xe&&e===tr)return sr;const n=ar(t,e);return Xe=t,tr=e,sr=n,n}function ur(t,e){var r;return{name:e??(r=t.segments,r.at(-1)?.fullName??""),params:t.params,meta:t.meta}}var lr=class{#B;get#f(){return this.#B.depsStore}constructor(t=[],e=!1,r){this.#B=function(t,e,r){const n=[],o=St(),i=Object.create(null),s=new Map,a=new Map;for(const e of t)n.push(Et(e));const{tree:c,matcher:u}=ze(n,"",r);return Ze(t,o,i,s,a,void 0,""),{definitions:n,config:o,tree:c,matcher:u,resolvedForwardMap:e?Je(o):Ke(o),routeCustomFields:i,rootPath:"",matcherOptions:r,depsStore:void 0,lifecycleNamespace:void 0,pendingCanActivate:s,pendingCanDeactivate:a,treeOperations:{commitTreeChanges:We,resetStore:Ve,nodeToDefinition:ce,validateRoutes:Ue}}}(t,e,r)}static shouldUpdateNode(t){return(e,r)=>{if(!e||"object"!=typeof e||!("name"in e))throw new TypeError("[router.shouldUpdateNode] toState must be valid State object");if(e.transition?.reload)return!0;if(""===t&&!r)return!0;const{intersection:n,toActivate:o,toDeactivate:i}=cr(e,r);return t===n||!!o.includes(t)||i.includes(t)}}setDependencies(t){this.#B.depsStore=t;for(const[e,r]of this.#B.pendingCanActivate)t.addActivateGuard(e,r);this.#B.pendingCanActivate.clear();for(const[e,r]of this.#B.pendingCanDeactivate)t.addDeactivateGuard(e,r);this.#B.pendingCanDeactivate.clear()}setLifecycleNamespace(t){this.#B.lifecycleNamespace=t}setRootPath(t){this.#B.rootPath=t,Ge(this.#B)}hasRoute(t){return this.#B.matcher.hasRoute(t)}clearRoutes(){Ve(this.#B)}buildPath(t,e,r){if(t===o.UNKNOWN_ROUTE)return S(e?.path)?e.path:"";const n=Object.hasOwn(this.#B.config.defaultParams,t)?{...this.#B.config.defaultParams[t],...e}:e??{},i="function"==typeof this.#B.config.encoders[t]?this.#B.config.encoders[t]({...n}):n,s=r?.trailingSlash;return this.#B.matcher.buildPath(t,i,{trailingSlash:"never"===s||"always"===s?s:void 0,queryParamsMode:r?.queryParamsMode})}matchPath(t,e){const r=e,n=this.#B.matcher.match(t);if(!n)return;const o=ur(n),{name:i,params:s,meta:a}=o,c="function"==typeof this.#B.config.decoders[i]?this.#B.config.decoders[i](s):s,{name:u,params:l}=this.#f.forwardState(i,c);let d=t;if(r.rewritePathOnMatch){const t="function"==typeof this.#B.config.encoders[u]?this.#B.config.encoders[u]({...l}):l,e=r.trailingSlash;d=this.#B.matcher.buildPath(u,t,{trailingSlash:"never"===e||"always"===e?e:void 0,queryParamsMode:r.queryParamsMode})}return this.#f.makeState(u,l,d,{params:a})}forwardState(t,e){if(Object.hasOwn(this.#B.config.forwardFnMap,t)){const r=this.#q(t,e),n=this.#B.config.forwardFnMap[t],o=this.#z(t,n,e);return{name:o,params:this.#q(o,r)}}const r=this.#B.resolvedForwardMap[t]??t;if(r!==t&&Object.hasOwn(this.#B.config.forwardFnMap,r)){const n=this.#q(t,e),o=this.#B.config.forwardFnMap[r],i=this.#z(r,o,e);return{name:i,params:this.#q(i,n)}}if(r!==t){const n=this.#q(t,e);return{name:r,params:this.#q(r,n)}}return{name:t,params:this.#q(t,e)}}buildStateResolved(t,e){const r=this.#B.matcher.getSegmentsByName(t);if(r)return ur({segments:r,params:e,meta:this.#B.matcher.getMetaByName(t)},t)}buildStateWithSegmentsResolved(t,e){const r=this.#B.matcher.getSegmentsByName(t);if(r)return{state:ur({segments:r,params:e,meta:this.#B.matcher.getMetaByName(t)},t),segments:r}}isActiveRoute(t,e={},r=!1,n=!0){bt.has(t)||(O(t,"isActiveRoute"),bt.add(t));const o=this.#f.getState();if(!o)return!1;const i=o.name;if(i!==t&&!i.startsWith(`${t}.`)&&!t.startsWith(`${i}.`))return!1;const s=this.#B.config.defaultParams[t];if(r||i===t){const r=s?{...s,...e}:e;return this.#f.areStatesEqual({name:t,params:r,path:""},o,n)}const a=o.params;return!!function(t,e){for(const r in t)if(t[r]!==e[r])return!1;return!0}(e,a)&&(!s||function(t,e,r){for(const n in t)if(!(n in r)&&t[n]!==e[n])return!1;return!0}(s,a,e))}getUrlParams(t){const e=this.#B.matcher.getSegmentsByName(t);return e?function(t){const e=[];for(const r of t)for(const t of r.paramMeta.urlParams)e.push(t);return e}(e):[]}getStore(){return this.#B}#q(t,e){return Object.hasOwn(this.#B.config.defaultParams,t)?{...this.#B.config.defaultParams[t],...e}:e}#z(t,e,r){const n=new Set([t]);let o=e(this.#f.getDependency,r),i=0;if("string"!=typeof o)throw new TypeError("forwardTo callback must return a string, got "+typeof o);for(;i<100;){if(void 0===this.#B.matcher.getSegmentsByName(o))throw new Error(`Route "${o}" does not exist`);if(n.has(o)){const t=[...n,o].join(" → ");throw new Error(`Circular forwardTo detected: ${t}`)}if(n.add(o),Object.hasOwn(this.#B.config.forwardFnMap,o)){o=(0,this.#B.config.forwardFnMap[o])(this.#f.getDependency,r),i++;continue}const t=this.#B.config.forwardMap[o];if(void 0===t)return o;o=t,i++}throw new Error("forwardTo exceeds maximum depth of 100")}};function dr(t,e,r){if(t instanceof x)throw t.setCode(e),t;throw new x(e,function(t,e){const r={segment:e};if(t instanceof Error)return{...r,message:t.message,stack:t.stack,..."cause"in t&&void 0!==t.cause&&{cause:t.cause}};if(t&&"object"==typeof t){const e={};for(const[r,n]of Object.entries(t))hr.has(r)||(e[r]=n);return{...r,...e}}return r}(t,r))}var hr=new Set(["code","segment","path","redirect"]);async function fr(t,e,n,o,i,s,a){const c=o.filter(e=>t.has(e));if(0===c.length)return;let u;for(const o of c){if(s())throw new x(r.TRANSITION_CANCELLED);const c=t.get(o);try{u=await c(e,n,a)}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)throw new x(r.TRANSITION_CANCELLED,{reason:a.reason});dr(t,i,o)}if(!u)throw new x(i,{segment:o})}}var pr=[o.UNKNOWN_ROUTE];Object.freeze(pr);var mr={replace:!0};Object.freeze(mr);var gr=class{#f;#W=null;static validateNavigateArgs(t){!function(t){if("string"!=typeof t)throw new TypeError(`[router.navigate] Invalid route name: expected string, got ${P(t)}`)}(t)}static validateNavigateToDefaultArgs(t){!function(t){if(void 0!==t&&("object"!=typeof t||null===t))throw new TypeError(`[router.navigateToDefault] Invalid options: ${P(t)}. Expected NavigationOptions object.`)}(t)}static validateNavigationOptions(t,e){!function(t,e){if(!function(t){if("object"!=typeof t||null===t||Array.isArray(t))return!1;const e=t;for(const t of m){const r=e[t];if(void 0!==r&&"boolean"!=typeof r)return!1}const r=e.signal;return!(void 0!==r&&!(r instanceof AbortSignal))}(t))throw new TypeError(`[router.${e}] Invalid options: ${P(t)}. Expected NavigationOptions object.`)}(t,e)}setDependencies(t){this.#f=t}async navigate(t,e,n){if(!this.#f.canNavigate())throw new x(r.ROUTER_NOT_STARTED);const i=this.#f,s=i.buildStateWithSegments(t,e);if(!s){const t=new x(r.ROUTE_NOT_FOUND);throw i.emitTransitionError(void 0,i.getState(),t),t}const{state:a}=s,c=i.makeState(a.name,a.params,i.buildPath(a.name,a.params),{params:a.meta}),u=i.getState();if(n=function(t,e){return e?.name!==o.UNKNOWN_ROUTE||t.replace?t:{...t,replace:!0}}(n,u),u&&!n.reload&&!n.force&&i.areStatesEqual(u,c,!1)){const t=new x(r.SAME_STATES);throw i.emitTransitionError(c,u,t),t}this.#G();const l=new AbortController;if(this.#W=l,n.signal){if(n.signal.aborted)throw this.#W=null,new x(r.TRANSITION_CANCELLED,{reason:n.signal.reason});n.signal.addEventListener("abort",()=>{l.abort(n.signal?.reason)},{once:!0,signal:l.signal})}i.startTransition(c,u);try{const{state:t,meta:e}=await async function(t,e,n,i,s){const[a,c]=t.getLifecycleFunctions(),u=e.name===o.UNKNOWN_ROUTE,l=()=>s.aborted||!t.isActive(),{toDeactivate:d,toActivate:h,intersection:f}=cr(e,n,void 0===i.reload?void 0:{reload:i.reload}),p=!u&&h.length>0;if(n&&!i.forceDeactivate&&d.length>0&&await fr(a,e,n,d,r.CANNOT_DEACTIVATE,l,s),l())throw new x(r.TRANSITION_CANCELLED);if(p&&await fr(c,e,n,h,r.CANNOT_ACTIVATE,l,s),l())throw new x(r.TRANSITION_CANCELLED);if(n)for(const e of d)!h.includes(e)&&a.has(e)&&t.clearCanDeactivate(e);return{state:e,meta:{phase:"activating",segments:{deactivated:d,activated:h,intersection:f}}}}(i,c,u,n,l.signal);if(t.name===o.UNKNOWN_ROUTE||i.hasRoute(t.name)){const r=function(t,e,r,n){const o={phase:e.phase,...void 0!==r?.name&&{from:r.name},reason:"success",segments:e.segments,...void 0!==n.reload&&{reload:n.reload},...void 0!==n.redirected&&{redirected:n.redirected}};return Object.freeze(o.segments.deactivated),Object.freeze(o.segments.activated),Object.freeze(o.segments),Object.freeze(o),{...t,transition:o}}(t,e,u,n);i.setState(r);const o=void 0===n.signal?n:function({signal:t,...e}){return e}(n);return i.sendTransitionDone(r,u,o),r}{const e=new x(r.ROUTE_NOT_FOUND,{routeName:t.name});throw i.sendTransitionFail(t,u,e),e}}catch(t){throw function(t,e,n,o){e.code!==r.TRANSITION_CANCELLED&&e.code!==r.ROUTE_NOT_FOUND&&t.sendTransitionFail(n,o,e)}(i,t,c,u),t}finally{l.abort(),this.#W===l&&(this.#W=null)}}async navigateToDefault(t){const e=this.#f;if(!e.getOptions().defaultRoute)throw new x(r.ROUTE_NOT_FOUND,{routeName:"defaultRoute not configured"});const{route:n,params:o}=e.resolveDefault();if(!n)throw new x(r.ROUTE_NOT_FOUND,{routeName:"defaultRoute resolved to empty"});return this.navigate(n,o,t)}navigateToNotFound(t){this.#G();const e=this.#f.getState(),r=e?ir(e.name).toReversed():[];Object.freeze(r);const n={deactivated:r,activated:pr,intersection:""};Object.freeze(n);const i={phase:"activating",...e&&{from:e.name},reason:"success",segments:n};Object.freeze(i);const s={name:o.UNKNOWN_ROUTE,params:{},path:t,transition:i};return Object.freeze(s),this.#f.setState(s),this.#f.emitTransitionSuccess(s,e,mr),s}abortCurrentNavigation(){this.#W?.abort(new x(r.TRANSITION_CANCELLED)),this.#W=null}#G(){this.#f.isTransitioning()&&(t.warn("router.navigate","Concurrent navigation detected on shared router instance. For SSR, use cloneRouter() to create isolated instance per request."),this.#W?.abort(new x(r.TRANSITION_CANCELLED)),this.#f.cancelNavigation())}},vr={replace:!0};Object.freeze(vr);var yr=class{#f;static validateStartArgs(t){if(1!==t.length||"string"!=typeof t[0])throw new Error("[router.start] Expected exactly 1 string argument (startPath).")}setDependencies(t){this.#f=t}async start(t){const e=this.#f,n=e.getOptions(),o=e.matchPath(t);if(!o&&!n.allowNotFound){const n=new x(r.ROUTE_NOT_FOUND,{path:t});throw e.emitTransitionError(void 0,void 0,n),n}return e.completeStart(),o?e.navigate(o.name,o.params,vr):e.navigateToNotFound(t)}stop(){this.#f.clearState()}},wr=class{#V;#Q;#H;constructor(t){this.#V=t.routerFSM,this.#Q=t.emitter,this.#H=void 0,this.#K()}static validateSubscribeListener(t){if("function"!=typeof t)throw new TypeError("[router.subscribe] Expected a function. For Observable pattern use @real-router/rx package")}emitRouterStart(){this.#Q.emit(d.ROUTER_START)}emitRouterStop(){this.#Q.emit(d.ROUTER_STOP)}emitTransitionStart(t,e){this.#Q.emit(d.TRANSITION_START,t,e)}emitTransitionSuccess(t,e,r){this.#Q.emit(d.TRANSITION_SUCCESS,t,e,r)}emitTransitionError(t,e,r){this.#Q.emit(d.TRANSITION_ERROR,t,e,r)}emitTransitionCancel(t,e){this.#Q.emit(d.TRANSITION_CANCEL,t,e)}sendStart(){this.#V.send(W)}sendStop(){this.#V.send(J)}sendDispose(){this.#V.send(Y)}sendStarted(){this.#V.send(G)}sendNavigate(t,e){this.#H=t,this.#V.send(V,{toState:t,fromState:e})}sendComplete(t,e,r={}){const n=this.#H;this.#V.send(Q,{state:t,fromState:e,opts:r}),this.#H===n&&(this.#H=void 0)}sendFail(t,e,r){const n=this.#H;this.#V.send(H,{toState:t,fromState:e,error:r}),this.#H===n&&(this.#H=void 0)}sendFailSafe(t,e,r){this.isReady()?this.sendFail(t,e,r):this.emitTransitionError(t,e,r)}sendCancel(t,e){const r=this.#H;this.#V.send(K,{toState:t,fromState:e}),this.#H===r&&(this.#H=void 0)}canBeginTransition(){return this.#V.canSend(V)}canStart(){return this.#V.canSend(W)}canCancel(){return this.#V.canSend(K)}isActive(){const t=this.#V.getState();return t!==U&&t!==z}isDisposed(){return this.#V.getState()===z}isTransitioning(){return this.#V.getState()===q}isReady(){return this.#V.getState()===B}getCurrentToState(){return this.#H}addEventListener(t,e){return this.#Q.on(t,e)}subscribe(t){return this.#Q.on(d.TRANSITION_SUCCESS,(e,r)=>{t({route:e,previousRoute:r})})}clearAll(){this.#Q.clearAll()}setLimits(t){this.#Q.setLimits(t)}sendCancelIfTransitioning(t){this.canCancel()&&this.sendCancel(this.#H,t)}#K(){const t=this.#V;t.on(k,G,()=>{this.emitRouterStart()}),t.on(B,J,()=>{this.emitRouterStop()}),t.on(B,V,t=>{this.emitTransitionStart(t.toState,t.fromState)}),t.on(q,Q,t=>{this.emitTransitionSuccess(t.state,t.fromState,t.opts)}),t.on(q,K,t=>{this.emitTransitionCancel(t.toState,t.fromState)}),t.on(k,H,t=>{this.emitTransitionError(t.toState,t.fromState,t.error)}),t.on(B,H,t=>{this.emitTransitionError(t.toState,t.fromState,t.error)}),t.on(q,H,t=>{this.emitTransitionError(t.toState,t.fromState,t.error)})}};function Tr(t,e){if("string"!=typeof t)throw new TypeError(`[router.${e}]: dependency name must be a string, got ${typeof t}`)}function br(t){if("string"!=typeof t)throw new TypeError("[router.setDependency]: dependency name must be a string, got "+typeof t)}function Sr(t,e){if(!t||"object"!=typeof t||t.constructor!==Object)throw new TypeError(`[router.${e}] Invalid argument: expected plain object, received ${P(t)}`);for(const r in t)if(Object.getOwnPropertyDescriptor(t,r)?.get)throw new TypeError(`[router.${e}] Getters not allowed: "${r}"`)}function Er(t,e){if(void 0===t)throw new ReferenceError(`[router.getDependency]: dependency "${e}" not found`)}function Ar(t,e,r,n=f.maxDependencies){if(0===n)return;const o=t+e;if(o>=n)throw new Error(`[router.${r}] Dependency limit exceeded (${n}). Current: ${o}. This is likely a bug in your code.`)}var Or=new x(r.ROUTER_ALREADY_STARTED),Pr=new Set(["all","warn-error","error-only"]);var $r=class{router;options;limits;dependenciesStore;state;routes;routeLifecycle;plugins;navigation;lifecycle;eventBus;constructor(t){this.router=t.router,this.options=t.options,this.limits=t.limits,this.dependenciesStore=t.dependenciesStore,this.state=t.state,this.routes=t.routes,this.routeLifecycle=t.routeLifecycle,this.plugins=t.plugins,this.navigation=t.navigation,this.lifecycle=t.lifecycle,this.eventBus=t.eventBus}wireLimits(){this.dependenciesStore.limits=this.limits,this.plugins.setLimits(this.limits),this.eventBus.setLimits({maxListeners:this.limits.maxListeners,warnListeners:this.limits.warnListeners,maxEventDepth:this.limits.maxEventDepth}),this.routeLifecycle.setLimits(this.limits)}wireRouteLifecycleDeps(){const t={compileFactory:this.createCompileFactory()};this.routeLifecycle.setDependencies(t)}wireRoutesDeps(){this.routes.setDependencies({addActivateGuard:(t,e)=>{this.routeLifecycle.addCanActivate(t,e,!0,!0)},addDeactivateGuard:(t,e)=>{this.routeLifecycle.addCanDeactivate(t,e,!0,!0)},makeState:(t,e,r,n)=>this.state.makeState(t,e,r,n),getState:()=>this.state.get(),areStatesEqual:(t,e,r)=>this.state.areStatesEqual(t,e,r),getDependency:t=>this.dependenciesStore.dependencies[t],forwardState:(t,e)=>{const r=tt(this.router);return r.noValidate||Fe(t,e,"forwardState"),r.forwardState(t,e)}}),this.routes.setLifecycleNamespace(this.routeLifecycle)}wirePluginsDeps(){const t={addEventListener:(t,e)=>this.eventBus.addEventListener(t,e),canNavigate:()=>this.eventBus.canBeginTransition(),compileFactory:this.createCompileFactory()};this.plugins.setDependencies(t)}wireNavigationDeps(){this.navigation.setDependencies({getOptions:()=>this.options.get(),hasRoute:t=>this.routes.hasRoute(t),getState:()=>this.state.get(),setState:t=>{this.state.set(t)},buildStateWithSegments:(t,e)=>{const r=tt(this.router);r.noValidate||Fe(t,e,"navigate");const{name:n,params:o}=r.forwardState(t,e);return this.routes.buildStateWithSegmentsResolved(n,o)},makeState:(t,e,r,n)=>this.state.makeState(t,e,r,n),buildPath:(t,e)=>tt(this.router).buildPath(t,e),areStatesEqual:(t,e,r)=>this.state.areStatesEqual(t,e,r),resolveDefault:()=>{const t=this.options.get();return{route:st(t.defaultRoute,t=>this.dependenciesStore.dependencies[t]),params:st(t.defaultParams,t=>this.dependenciesStore.dependencies[t])}},startTransition:(t,e)=>{this.eventBus.sendNavigate(t,e)},cancelNavigation:()=>{this.eventBus.sendCancel(this.eventBus.getCurrentToState(),this.state.get())},sendTransitionDone:(t,e,r)=>{this.eventBus.sendComplete(t,e,r)},sendTransitionFail:(t,e,r)=>{this.eventBus.sendFail(t,e,r)},emitTransitionError:(t,e,r)=>{this.eventBus.sendFailSafe(t,e,r)},emitTransitionSuccess:(t,e,r)=>{this.eventBus.emitTransitionSuccess(t,e,r)},canNavigate:()=>this.eventBus.canBeginTransition(),getLifecycleFunctions:()=>this.routeLifecycle.getFunctions(),isActive:()=>this.router.isActive(),isTransitioning:()=>this.eventBus.isTransitioning(),clearCanDeactivate:t=>{this.routeLifecycle.clearCanDeactivate(t)}})}wireLifecycleDeps(){this.lifecycle.setDependencies({getOptions:()=>this.options.get(),navigate:(t,e,r)=>this.navigation.navigate(t,e,r),navigateToNotFound:t=>this.navigation.navigateToNotFound(t),clearState:()=>{this.state.set(void 0)},matchPath:t=>this.routes.matchPath(t,this.options.get()),completeStart:()=>{this.eventBus.sendStarted()},emitTransitionError:(t,e,r)=>{this.eventBus.sendFail(t,e,r)}})}wireStateDeps(){this.state.setDependencies({getDefaultParams:()=>this.routes.getStore().config.defaultParams,buildPath:(t,e)=>tt(this.router).buildPath(t,e),getUrlParams:t=>this.routes.getUrlParams(t)})}createCompileFactory(){const{router:t,dependenciesStore:e}=this;return r=>r(t,t=>e.dependencies[t])}},Nr=class n{#u;#y;#J;#Y;#Z;#X;#g;#tt;#et;#rt;#nt;constructor(r=[],n={},o={}){n.logger&&function(t){if("object"!=typeof t||null===t)throw new TypeError("Logger config must be an object");const e=t;for(const t of Object.keys(e))if("level"!==t&&"callback"!==t)throw new TypeError(`Unknown logger config property: "${t}"`);if("level"in e&&void 0!==e.level&&("string"!=typeof(r=e.level)||!Pr.has(r)))throw new TypeError(`Invalid logger level: ${function(t){return"string"==typeof t?`"${t}"`:"object"==typeof t?JSON.stringify(t):String(t)}(e.level)}. Expected: "all" | "warn-error" | "error-only"`);var r;if("callback"in e&&void 0!==e.callback&&"function"!=typeof e.callback)throw new TypeError("Logger callback must be a function, got "+typeof e.callback);return!0}(n.logger)&&(t.configure(n.logger),delete n.logger),lt.validateOptions(n,"constructor");const i=n.noValidate??!1;i||Sr(o,"constructor"),!i&&r.length>0&&(De(r),Ue(r)),this.#u=new lt(n),this.#y=function(t={}){return{...f,...t}}(n.limits),this.#J=function(t={}){const e=Object.create(null);for(const r in t)void 0!==t[r]&&(e[r]=t[r]);return{dependencies:e,limits:f}}(o),this.#Y=new ht,this.#Z=new lr(r,i,function(t){return{strictTrailingSlash:"strict"===t.trailingSlash,strictQueryParams:"strict"===t.queryParamsMode,urlParamsEncoding:t.urlParamsEncoding,queryParams:t.queryParams}}(this.#u.get())),this.#X=new Tt,this.#g=new gt,this.#tt=new gr,this.#et=new yr,this.#nt=i;const s=new e(Z),a=new M({onListenerError:(e,r)=>{t.error("Router",`Error in listener for ${e}:`,r)},onListenerWarn:(e,r)=>{t.warn("router.addEventListener",`Event "${e}" has ${r} listeners — possible memory leak`)}});var c;this.#rt=new wr({routerFSM:s,emitter:a}),(c=new $r({router:this,options:this.#u,limits:this.#y,dependenciesStore:this.#J,state:this.#Y,routes:this.#Z,routeLifecycle:this.#X,plugins:this.#g,navigation:this.#tt,lifecycle:this.#et,eventBus:this.#rt})).wireLimits(),c.wireRouteLifecycleDeps(),c.wireRoutesDeps(),c.wirePluginsDeps(),c.wireNavigationDeps(),c.wireLifecycleDeps(),c.wireStateDeps();const u=new Map;var l;l={makeState:(t,e,r,n,o)=>this.#Y.makeState(t,e,r,n,o),forwardState:et("forwardState",(t,e)=>this.#Z.forwardState(t,e),u),buildStateResolved:(t,e)=>this.#Z.buildStateResolved(t,e),matchPath:(t,e)=>this.#Z.matchPath(t,e),getOptions:()=>this.#u.get(),addEventListener:(t,e)=>this.#rt.addEventListener(t,e),buildPath:et("buildPath",(t,e)=>this.#Z.buildPath(t,e??{},this.#u.get()),u),start:et("start",t=>(i||yr.validateStartArgs([t]),this.#et.start(t)),u),interceptors:u,setRootPath:t=>{this.#Z.setRootPath(t)},getRootPath:()=>this.#Z.getStore().rootPath,getTree:()=>this.#Z.getStore().tree,isDisposed:()=>this.#rt.isDisposed(),noValidate:i,dependenciesGetStore:()=>this.#J,cloneOptions:()=>({...this.#u.get()}),cloneDependencies:()=>({...this.#J.dependencies}),getLifecycleFactories:()=>this.#X.getFactories(),getPluginFactories:()=>this.#g.getAll(),routeGetStore:()=>this.#Z.getStore(),getStateName:()=>this.#Y.get()?.name,isTransitioning:()=>this.#rt.isTransitioning(),clearState:()=>{this.#Y.set(void 0)},setState:t=>{this.#Y.set(t)},routerExtensions:[]},X.set(this,l),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)}isActiveRoute(e,r,n,o){return this.#nt||function(t,e,r,n){if(!S(t))throw new TypeError("Route name must be a string");if(void 0!==e&&!b(e))throw new TypeError("[router.isActiveRoute] Invalid params structure");if(void 0!==r&&"boolean"!=typeof r)throw new TypeError("[router.isActiveRoute] strictEquality must be a boolean, got "+typeof r);if(void 0!==n&&"boolean"!=typeof n)throw new TypeError("[router.isActiveRoute] ignoreQueryParams must be a boolean, got "+typeof n)}(e,r,n,o),""===e?(t.warn("real-router",'isActiveRoute("") called with empty string. Root node is not considered a parent of any route.'),!1):this.#Z.isActiveRoute(e,r,n,o)}buildPath(t,e){return this.#nt||function(t){if(!S(t)||""===t)throw new TypeError("[real-router] buildPath: route must be a non-empty string, got "+("string"==typeof t?'""':typeof t))}(t),tt(this).buildPath(t,e)}getState(){return this.#Y.get()}getPreviousState(){return this.#Y.getPrevious()}areStatesEqual(t,e,r=!0){return this.#nt||ht.validateAreStatesEqualArgs(t,e,r),this.#Y.areStatesEqual(t,e,r)}shouldUpdateNode(t){return this.#nt||function(t){if(!S(t))throw new TypeError("[router.shouldUpdateNode] nodeName must be a string, got "+typeof t)}(t),lr.shouldUpdateNode(t)}isActive(){return this.#rt.isActive()}start(t){if(!this.#rt.canStart())return Promise.reject(Or);this.#rt.sendStart();const e=tt(this).start(t).catch(t=>{throw this.#rt.isReady()&&(this.#et.stop(),this.#rt.sendStop()),t});return n.#ot(e),e}stop(){return this.#tt.abortCurrentNavigation(),this.#rt.sendCancelIfTransitioning(this.#Y.get()),this.#rt.isReady()||this.#rt.isTransitioning()?(this.#et.stop(),this.#rt.sendStop(),this):this}dispose(){if(this.#rt.isDisposed())return;this.#tt.abortCurrentNavigation(),this.#rt.sendCancelIfTransitioning(this.#Y.get()),(this.#rt.isReady()||this.#rt.isTransitioning())&&(this.#et.stop(),this.#rt.sendStop()),this.#rt.sendDispose(),this.#rt.clearAll(),this.#g.disposeAll();const t=tt(this);for(const e of t.routerExtensions)for(const t of e.keys)delete this[t];t.routerExtensions.length=0,this.#Z.clearRoutes(),this.#X.clearAll(),this.#Y.reset(),this.#J.dependencies=Object.create(null),this.#it()}canNavigateTo(t,e){if(this.#nt||O(t,"canNavigateTo"),!this.#Z.hasRoute(t))return!1;const r=tt(this),{name:n,params:o}=r.forwardState(t,e??{}),i=this.#Y.makeState(n,o),s=this.#Y.get(),{toDeactivate:a,toActivate:c}=cr(i,s);return this.#X.canNavigateTo(a,c,i,s)}usePlugin(...t){return this.#nt||(gt.validateUsePluginArgs(t),gt.validatePluginLimit(this.#g.count(),t.length,this.#y.maxPlugins),gt.validateNoDuplicatePlugins(t,this.#g.has.bind(this.#g))),this.#g.use(...t)}subscribe(t){return this.#nt||wr.validateSubscribeListener(t),this.#rt.subscribe(t)}navigate(t,e,r){this.#nt||gr.validateNavigateArgs(t);const o=r??{};this.#nt||gr.validateNavigationOptions(o,"navigate");const i=this.#tt.navigate(t,e??{},o);return n.#ot(i),i}navigateToDefault(t){this.#nt||gr.validateNavigateToDefaultArgs(t);const e=t??{};this.#nt||gr.validateNavigationOptions(e,"navigateToDefault");const r=this.#tt.navigateToDefault(e);return n.#ot(r),r}navigateToNotFound(t){if(!this.#rt.isActive())throw new x(r.ROUTER_NOT_STARTED);const e=t??this.#Y.get().path;return this.#tt.navigateToNotFound(e)}static#st=e=>{e instanceof x&&(e.code===r.SAME_STATES||e.code===r.TRANSITION_CANCELLED||e.code===r.ROUTER_NOT_STARTED||e.code===r.ROUTE_NOT_FOUND)||t.error("router.navigate","Unexpected navigation error",e)};static#ot(t){t.catch(n.#st)}#it(){this.navigate=Rr,this.navigateToDefault=Rr,this.navigateToNotFound=Rr,this.start=Rr,this.stop=Rr,this.usePlugin=Rr,this.subscribe=Rr,this.canNavigateTo=Rr}};function Rr(){throw new x(r.ROUTER_DISPOSED)}export{Nr as Router,x as RouterError,n as UNKNOWN_ROUTE,S as b,Ot as clearConfigEntries,Qe as clearRouteData,D as computeThresholds,o as constants,r as errorCodes,d as events,ue as f,O as g,tt as getInternals,P as j,He as refreshForwardMap,Ze as registerAllRouteHandlers,At as removeFromDefinitions,b as s,Et as sanitizeRoute,$e as throwIfInternalRoute,Ne as throwIfInternalRouteInArray,h as validEventNames,De as validateAddRouteArgs,Be as validateClearRoutes,Sr as validateDependenciesObject,Er as validateDependencyExists,Ar as validateDependencyLimit,Tr as validateDependencyName,vt as validateHandler,Me as validateMatchPathArgs,je as validateParentOption,ke as validateRemoveRoute,Re as validateRemoveRouteArgs,br as validateSetDependencyArgs,Ce as validateSetRootPathArgs,Fe as validateStateBuilderArgs,qe as validateUpdateRoute,Ie as validateUpdateRouteBasicArgs,_e as validateUpdateRoutePropertyTypes};//# sourceMappingURL=chunk-HZ7RFKT5.mjs.map