@real-router/core 0.24.0 → 0.25.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/README.md +0 -15
- package/dist/cjs/index.d.ts +4 -10
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/metafile-cjs.json +1 -1
- package/dist/esm/index.d.mts +4 -10
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/metafile-esm.json +1 -1
- package/package.json +4 -4
- package/src/Router.ts +11 -54
- package/src/RouterError.ts +1 -1
- package/src/constants.ts +1 -3
- package/src/helpers.ts +1 -1
- package/src/index.ts +1 -3
- package/src/namespaces/CloneNamespace/CloneNamespace.ts +6 -6
- package/src/namespaces/CloneNamespace/types.ts +3 -7
- package/src/namespaces/DependenciesNamespace/DependenciesNamespace.ts +2 -4
- package/src/namespaces/NavigationNamespace/NavigationNamespace.ts +1 -0
- package/src/namespaces/NavigationNamespace/transition/{wrapSyncError.ts → errorHandling.ts} +23 -17
- package/src/namespaces/NavigationNamespace/transition/executeLifecycleHooks.ts +6 -6
- package/src/namespaces/NavigationNamespace/transition/index.ts +3 -21
- package/src/namespaces/NavigationNamespace/types.ts +0 -4
- package/src/namespaces/PluginsNamespace/PluginsNamespace.ts +2 -2
- package/src/namespaces/RouteLifecycleNamespace/validators.ts +1 -1
- package/src/namespaces/RoutesNamespace/RoutesNamespace.ts +50 -31
- package/src/namespaces/RoutesNamespace/stateBuilder.ts +1 -1
- package/src/namespaces/index.ts +0 -2
- package/src/transitionPath.ts +4 -40
- package/src/typeGuards.ts +1 -1
- package/src/types.ts +0 -12
- package/src/wiring/RouterWiringBuilder.ts +1 -17
- package/src/wiring/types.ts +0 -3
- package/src/wiring/wireRouter.ts +0 -1
- package/src/namespaces/MiddlewareNamespace/MiddlewareNamespace.ts +0 -221
- package/src/namespaces/MiddlewareNamespace/constants.ts +0 -3
- package/src/namespaces/MiddlewareNamespace/index.ts +0 -5
- package/src/namespaces/MiddlewareNamespace/types.ts +0 -28
- package/src/namespaces/MiddlewareNamespace/validators.ts +0 -95
- package/src/namespaces/NavigationNamespace/transition/executeMiddleware.ts +0 -56
- package/src/namespaces/NavigationNamespace/transition/makeError.ts +0 -37
- package/src/namespaces/NavigationNamespace/transition/mergeStates.ts +0 -54
- package/src/namespaces/NavigationNamespace/transition/processLifecycleResult.ts +0 -69
package/README.md
CHANGED
|
@@ -193,21 +193,6 @@ const unsubscribe = router.usePlugin(browserPluginFactory());
|
|
|
193
193
|
|
|
194
194
|
---
|
|
195
195
|
|
|
196
|
-
### Middleware
|
|
197
|
-
|
|
198
|
-
#### `router.useMiddleware(middlewareFactory)`
|
|
199
|
-
|
|
200
|
-
Registers middleware for the navigation pipeline. [Wiki](https://github.com/greydragon888/real-router/wiki/useMiddleware)
|
|
201
|
-
|
|
202
|
-
```typescript
|
|
203
|
-
router.useMiddleware((router) => (toState, fromState, done) => {
|
|
204
|
-
console.log("Navigating:", toState.name);
|
|
205
|
-
done();
|
|
206
|
-
});
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
---
|
|
210
|
-
|
|
211
196
|
## Advanced API
|
|
212
197
|
|
|
213
198
|
### Routes
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EventToPluginMap, EventToNameMap, ErrorCodeKeys, ErrorCodeValues, ErrorCodeToValueMap, DefaultDependencies, Options, Params, State, StateMetaInput, SimpleState, RouteTreeState, Unsubscribe, EventName, Plugin, SubscribeFn, NavigationOptions, GuardFn, ForwardToCallback,
|
|
2
|
-
export { ActivationFn, Config, DefaultDependencies, GuardFn, Listener,
|
|
1
|
+
import { EventToPluginMap, EventToNameMap, ErrorCodeKeys, ErrorCodeValues, ErrorCodeToValueMap, DefaultDependencies, Options, Params, State, StateMetaInput, SimpleState, RouteTreeState, Unsubscribe, EventName, Plugin, SubscribeFn, NavigationOptions, GuardFn, ForwardToCallback, EventsKeys, ActivationFn, Navigator } from '@real-router/types';
|
|
2
|
+
export { ActivationFn, Config, DefaultDependencies, GuardFn, Listener, NavigationOptions, Navigator, Options, Params, Plugin, SimpleState, State, StateMeta, SubscribeFn, SubscribeState, Subscription, Unsubscribe } from '@real-router/types';
|
|
3
3
|
|
|
4
4
|
type ConstantsKeys = "UNKNOWN_ROUTE";
|
|
5
5
|
type Constants = Record<ConstantsKeys, string>;
|
|
@@ -36,7 +36,6 @@ declare const events: EventToNameMap;
|
|
|
36
36
|
* - StateNamespace: state storage (getState, setState, getPreviousState)
|
|
37
37
|
* - RoutesNamespace: route tree operations
|
|
38
38
|
* - RouteLifecycleNamespace: canActivate/canDeactivate guards
|
|
39
|
-
* - MiddlewareNamespace: middleware chain
|
|
40
39
|
* - PluginsNamespace: plugin lifecycle
|
|
41
40
|
* - NavigationNamespace: navigate, navigateToState
|
|
42
41
|
* - RouterLifecycleNamespace: start, stop, isStarted
|
|
@@ -58,6 +57,7 @@ declare class Router<Dependencies extends DefaultDependencies = DefaultDependenc
|
|
|
58
57
|
removeRoute(name: string): this;
|
|
59
58
|
clearRoutes(): this;
|
|
60
59
|
getRoute(name: string): Route<Dependencies> | undefined;
|
|
60
|
+
getRouteConfig(name: string): Record<string, unknown> | undefined;
|
|
61
61
|
hasRoute(name: string): boolean;
|
|
62
62
|
updateRoute(name: string, updates: RouteConfigUpdate<Dependencies>): this;
|
|
63
63
|
isActiveRoute(name: string, params?: Params, strictEquality?: boolean, ignoreQueryParams?: boolean): boolean;
|
|
@@ -84,7 +84,6 @@ declare class Router<Dependencies extends DefaultDependencies = DefaultDependenc
|
|
|
84
84
|
removeDeactivateGuard(name: string): void;
|
|
85
85
|
canNavigateTo(name: string, params?: Params): boolean;
|
|
86
86
|
usePlugin(...plugins: PluginFactory<Dependencies>[]): Unsubscribe;
|
|
87
|
-
useMiddleware(...middlewares: MiddlewareFactory<Dependencies>[]): Unsubscribe;
|
|
88
87
|
setDependency<K extends keyof Dependencies & string>(dependencyName: K, dependency: Dependencies[K]): this;
|
|
89
88
|
setDependencies(deps: Dependencies): this;
|
|
90
89
|
getDependency<K extends keyof Dependencies>(key: K): Dependencies[K];
|
|
@@ -219,11 +218,6 @@ type ActivationFnFactory<Dependencies extends DefaultDependencies = DefaultDepen
|
|
|
219
218
|
* Receives the router instance and a dependency getter.
|
|
220
219
|
*/
|
|
221
220
|
type GuardFnFactory<Dependencies extends DefaultDependencies = DefaultDependencies> = (router: Router<Dependencies>, getDependency: <K extends keyof Dependencies>(key: K) => Dependencies[K]) => GuardFn;
|
|
222
|
-
/**
|
|
223
|
-
* Factory function for creating middleware.
|
|
224
|
-
* Receives the router instance and a dependency getter.
|
|
225
|
-
*/
|
|
226
|
-
type MiddlewareFactory<Dependencies extends DefaultDependencies = DefaultDependencies> = (router: Router<Dependencies>, getDependency: <K extends keyof Dependencies>(key: K) => Dependencies[K]) => Middleware;
|
|
227
221
|
/**
|
|
228
222
|
* Factory function for creating plugins.
|
|
229
223
|
* Receives the router instance and a dependency getter.
|
|
@@ -437,4 +431,4 @@ declare const createRouter: <Dependencies extends DefaultDependencies = DefaultD
|
|
|
437
431
|
|
|
438
432
|
declare const getNavigator: <Dependencies extends DefaultDependencies = DefaultDependencies>(router: Router<Dependencies>) => Navigator;
|
|
439
433
|
|
|
440
|
-
export { type ActivationFnFactory, type BuildStateResultWithSegments, type Constants, type ErrorCodes, type GuardFnFactory, type
|
|
434
|
+
export { type ActivationFnFactory, type BuildStateResultWithSegments, type Constants, type ErrorCodes, type GuardFnFactory, type PluginFactory, type Route, type RouteConfigUpdate, Router, RouterError, constants, createRouter, errorCodes, events, getNavigator };
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=require("@real-router/logger"),t=require("@real-router/fsm"),r={maxListeners:0,warnListeners:0,maxEventDepth:0},i=class extends Error{},n=class{#e=new Map;#t=null;#r=r;#i;#n;constructor(e){e?.limits&&(this.#r=e.limits),this.#i=e?.onListenerError??null,this.#n=e?.onListenerWarn??null}static validateCallback(e,t){if("function"!=typeof e)throw new TypeError(`Expected callback to be a function for event ${t}`)}setLimits(e){this.#r=e}on(e,t){const r=this.#a(e);if(r.has(t))throw new Error(`Duplicate listener for "${e}"`);const{maxListeners:i,warnListeners:n}=this.#r;if(0!==n&&r.size===n&&this.#n?.(e,n),0!==i&&r.size>=i)throw new Error(`Listener limit (${i}) reached for "${e}"`);return r.add(t),()=>{this.off(e,t)}}off(e,t){this.#e.get(e)?.delete(t)}emit(e,...t){const r=this.#e.get(e);r&&0!==r.size&&(0!==this.#r.maxEventDepth?this.#s(r,e,t):this.#o(r,e,t))}clearAll(){this.#e.clear(),this.#t=null}listenerCount(e){return this.#e.get(e)?.size??0}#o(e,t,r){const i=[...e];for(const e of i)try{this.#c(e,r)}catch(e){this.#i?.(t,e)}}#c(e,t){switch(t.length){case 0:e();break;case 1:e(t[0]);break;case 2:e(t[0],t[1]);break;case 3:e(t[0],t[1],t[2]);break;default:Function.prototype.apply.call(e,void 0,t)}}#s(e,t,r){this.#t??=new Map;const n=this.#t,a=n.get(t)??0;if(a>=this.#r.maxEventDepth)throw new i(`Maximum recursion depth (${this.#r.maxEventDepth}) exceeded for event: ${t}`);try{n.set(t,a+1);const s=[...e];for(const e of s)try{this.#c(e,r)}catch(e){if(e instanceof i)throw e;this.#i?.(t,e)}}finally{n.set(t,n.get(t)-1)}}#a(e){const t=this.#e.get(e);if(t)return t;const r=new Set;return this.#e.set(e,r),r}},a=["replace","reload","force","forceDeactivate","redirected"],s=/\S/,o=/^[A-Z_a-z][\w-]*(?:\.[A-Z_a-z][\w-]*)*$/;function c(e,t){return new TypeError(`[router.${e}] ${t}`)}function d(e,t=new WeakSet){if(null==e)return!0;const r=typeof e;if("string"===r||"boolean"===r)return!0;if("number"===r)return Number.isFinite(e);if("function"===r||"symbol"===r)return!1;if(Array.isArray(e))return!t.has(e)&&(t.add(e),e.every(e=>d(e,t)));if("object"===r){if(t.has(e))return!1;t.add(e);const r=Object.getPrototypeOf(e);return(null===r||r===Object.prototype)&&Object.values(e).every(e=>d(e,t))}return!1}function u(e){if(null==e)return!0;const t=typeof e;return"string"===t||"boolean"===t||"number"===t&&Number.isFinite(e)}function l(e){if("object"!=typeof e||null===e||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);if(null!==t&&t!==Object.prototype)return!1;let r=!1;for(const t in e){if(!Object.hasOwn(e,t))continue;const i=e[t];if(!u(i)){const e=typeof i;if("function"===e||"symbol"===e)return!1;r=!0;break}}return!r||d(e)}function h(e){return"object"==typeof e&&null!==e&&function(e){return function(e){return"string"==typeof e&&(""===e||!(e.length>1e4)&&(!!e.startsWith("@@")||o.test(e)))}(e.name)&&"string"==typeof e.path&&l(e.params)}(e)}function f(e){return"string"==typeof e}function p(e){return"boolean"==typeof e}function m(e,t){return e in t}function g(e,t){if("string"!=typeof e)throw c(t,"Route name must be a string, got "+typeof e);if(""!==e){if(!s.test(e))throw c(t,"Route name cannot contain only whitespace");if(e.length>1e4)throw c(t,"Route name exceeds maximum length of 10000 characters. This is a technical safety limit.");if(!e.startsWith("@@")&&!o.test(e))throw c(t,`Invalid route name "${e}". 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 v(e){return null===e?"null":Array.isArray(e)?`array[${e.length}]`:"object"==typeof e?"constructor"in e&&"Object"!==e.constructor.name?e.constructor.name:"object":typeof e}function w(e,t){if(!h(e))throw new TypeError(`[${t}] Invalid state structure: ${v(e)}. Expected State object with name, params, and path properties.`)}var y=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"}),T={UNKNOWN_ROUTE:"@@router/UNKNOWN_ROUTE"},b="onStart",S="onStop",R="onTransitionStart",A="onTransitionCancel",E="onTransitionSuccess",P="onTransitionError",$={ROUTER_START:"$start",ROUTER_STOP:"$stop",TRANSITION_START:"$$start",TRANSITION_CANCEL:"$$cancel",TRANSITION_SUCCESS:"$$success",TRANSITION_ERROR:"$$error"},O=new Set([$.ROUTER_START,$.TRANSITION_START,$.TRANSITION_SUCCESS,$.TRANSITION_ERROR,$.TRANSITION_CANCEL,$.ROUTER_STOP]),D={maxDependencies:100,maxPlugins:50,maxMiddleware:50,maxListeners:1e4,warnListeners:1e3,maxEventDepth:5,maxLifecycleHandlers:200},N={maxDependencies:{min:0,max:1e4},maxPlugins:{min:0,max:1e3},maxMiddleware:{min:0,max:1e3},maxListeners:{min:0,max:1e5},warnListeners:{min:0,max:1e5},maxEventDepth:{min:0,max:100},maxLifecycleHandlers:{min:0,max:1e4}},C="IDLE",j="STARTING",F="READY",M="TRANSITIONING",x="DISPOSED",I="START",L="STARTED",k="NAVIGATE",U="COMPLETE",_="FAIL",B="CANCEL",V="STOP",G="DISPOSE",q={initial:C,context:null,transitions:{[C]:{[I]:j,[G]:x},[j]:{[L]:F,[_]:C},[F]:{[k]:M,[_]:F,[V]:C},[M]:{[k]:M,[U]:F,[B]:F,[_]:F},[x]:{}}},z=new WeakSet;function W(e){if(null!==e&&"object"==typeof e&&!Object.isFrozen(e))if(Object.freeze(e),Array.isArray(e))for(const t of e)W(t);else for(const t in e)W(e[t])}function H(e){return e?(z.has(e)||(W(e),z.add(e)),e):e}function Q(e){return{warn:Math.floor(.2*e),error:Math.floor(.5*e)}}var K=class{#d=Object.create(null);#u=D;constructor(e={}){this.setMultiple(e)}static validateName(e,t){!function(e,t){if("string"!=typeof e)throw new TypeError(`[router.${t}]: dependency name must be a string, got ${typeof e}`)}(e,t)}static validateSetDependencyArgs(e){!function(e){if("string"!=typeof e)throw new TypeError("[router.setDependency]: dependency name must be a string, got "+typeof e)}(e)}static validateDependenciesObject(e,t){!function(e,t){if(!e||"object"!=typeof e||e.constructor!==Object)throw new TypeError(`[router.${t}] Invalid argument: expected plain object, received ${v(e)}`);for(const r in e)if(Object.getOwnPropertyDescriptor(e,r)?.get)throw new TypeError(`[router.${t}] Getters not allowed: "${r}"`)}(e,t)}static validateDependencyExists(e,t){!function(e,t){if(void 0===e)throw new ReferenceError(`[router.getDependency]: dependency "${t}" not found`)}(e,t)}static validateDependencyLimit(e,t,r,i){!function(e,t,r,i=D.maxDependencies){if(0===i)return;const n=e+t;if(n>=i)throw new Error(`[router.${r}] Dependency limit exceeded (${i}). Current: ${n}. This is likely a bug in your code.`)}(e,t,r,i)}setLimits(e){this.#u=e}set(t,r){if(void 0===r)return!1;if(Object.hasOwn(this.#d,t)){const i=this.#d[t],n=i!==r,a=Number.isNaN(i)&&Number.isNaN(r);n&&!a&&e.logger.warn("router.setDependency","Router dependency already exists and is being overwritten:",t)}else this.#l("setDependency");return this.#d[t]=r,!0}setMultiple(t){const r=[];for(const e in t)void 0!==t[e]&&(Object.hasOwn(this.#d,e)&&r.push(e),this.#d[e]=t[e]);r.length>0&&e.logger.warn("router.setDependencies","Overwritten:",r.join(", "))}get(e){return this.#d[e]}getAll(){return{...this.#d}}count(){return Object.keys(this.#d).length}remove(t){Object.hasOwn(this.#d,t)||e.logger.warn("router.removeDependency",`Attempted to remove non-existent dependency: "${v(t)}"`),delete this.#d[t]}has(e){return Object.hasOwn(this.#d,e)}reset(){for(const e in this.#d)delete this.#d[e]}#l(t){const r=this.#u.maxDependencies;if(0===r)return;const i=Object.keys(this.#d).length,{warn:n,error:a}=Q(r);if(i===n)e.logger.warn(`router.${t}`,`${n} dependencies registered. Consider if all are necessary.`);else if(i===a)e.logger.error(`router.${t}`,`${a} dependencies registered! This indicates architectural problems. Hard limit at ${r}.`);else if(i>=r)throw new Error(`[router.${t}] Dependency limit exceeded (${r}). Current: ${i}. This is likely a bug in your code. If you genuinely need more dependencies, your architecture needs refactoring.`)}},J={defaultRoute:"",defaultParams:{},trailingSlash:"preserve",queryParamsMode:"loose",queryParams:{arrayFormat:"none",booleanFormat:"none",nullFormat:"default"},urlParamsEncoding:"default",allowNotFound:!0,rewritePathOnMatch:!0,noValidate:!1},Y={trailingSlash:["strict","never","always","preserve"],queryParamsMode:["default","strict","loose"],urlParamsEncoding:["default","uri","uriComponent","none"]},Z={arrayFormat:["none","brackets","index","comma"],booleanFormat:["none","string","empty-true"],nullFormat:["default","hidden"]};function X(e){Object.freeze(e);for(const t of Object.keys(e)){const r=e[t];r&&"object"==typeof r&&r.constructor===Object&&X(r)}return e}function ee(e,t){return"function"==typeof e?e(t):e}function te(e,t,r){if("function"==typeof t&&("defaultRoute"===e||"defaultParams"===e))return;const i=J[e];if(i&&"object"==typeof i)return function(e,t,r){if(!e||"object"!=typeof e||e.constructor!==Object)throw new TypeError(`[router.${r}] Invalid type for "${t}": expected plain object, got ${v(e)}`);for(const i in e)if(Object.getOwnPropertyDescriptor(e,i)?.get)throw new TypeError(`[router.${r}] Getters not allowed in "${t}": "${i}"`)}(t,e,r),void("queryParams"===e&&function(e,t){for(const r in e){if(!m(r,Z)){const e=Object.keys(Z).map(e=>`"${e}"`).join(", ");throw new TypeError(`[router.${t}] Unknown queryParams key: "${r}". Valid keys: ${e}`)}const i=e[r],n=Z[r];if(!n.includes(i)){const e=n.map(e=>`"${e}"`).join(", ");throw new TypeError(`[router.${t}] Invalid value for queryParams.${r}: expected one of ${e}, got "${String(i)}"`)}}}(t,r));if(typeof t!=typeof i)throw new TypeError(`[router.${r}] Invalid type for "${e}": expected ${typeof i}, got ${typeof t}`);e in Y&&function(e,t,r){const i=Y[e];if(!i.includes(t)){const n=i.map(e=>`"${e}"`).join(", ");throw new TypeError(`[router.${r}] Invalid value for "${e}": expected one of ${n}, got "${String(t)}"`)}}(e,t,r)}function re(e,t,r){if("limits"===e)return void 0!==t&&function(e,t){if(!e||"object"!=typeof e||e.constructor!==Object)throw new TypeError(`[router.${t}]: invalid limits: expected plain object, got ${typeof e}`);for(const[r,i]of Object.entries(e)){if(!Object.hasOwn(N,r))throw new TypeError(`[router.${t}]: unknown limit: "${r}"`);void 0!==i&&ie(r,i,t)}}(t,r),!0;throw new TypeError(`[router.${r}] Unknown option: "${e}"`)}function ie(e,t,r){if("number"!=typeof t||!Number.isInteger(t))throw new TypeError(`[router.${r}]: limit "${e}" must be an integer, got ${String(t)}`);const i=N[e];if(t<i.min||t>i.max)throw new RangeError(`[router.${r}]: limit "${e}" must be between ${i.min} and ${i.max}, got ${t}`)}var ne=class{#h;constructor(e={}){this.#h=X({...J,...e})}static validateOptions(e,t){!function(e,t){if(!e||"object"!=typeof e||e.constructor!==Object)throw new TypeError(`[router.${t}] Invalid options: expected plain object, got ${v(e)}`);for(const[r,i]of Object.entries(e))m(r,J)?void 0!==i&&te(r,i,t):re(r,i,t)}(e,t)}get(){return this.#h}};function ae(e,t){return e===t||!(!Array.isArray(e)||!Array.isArray(t))&&e.length===t.length&&e.every((e,r)=>ae(e,t[r]))}var se=class{#f=0;#p=void 0;#m=void 0;#g;#v=new Map;static validateMakeStateArgs(e,t,r,i){if(!f(e))throw new TypeError(`[router.makeState] Invalid name: ${v(e)}. Expected string.`);if(void 0!==t&&!l(t))throw new TypeError(`[router.makeState] Invalid params: ${v(t)}. Expected plain object.`);if(void 0!==r&&!f(r))throw new TypeError(`[router.makeState] Invalid path: ${v(r)}. Expected string.`);if(void 0!==i&&"number"!=typeof i)throw new TypeError(`[router.makeState] Invalid forceId: ${v(i)}. Expected number.`)}static validateAreStatesEqualArgs(e,t,r){if(null!=e&&w(e,"areStatesEqual"),null!=t&&w(t,"areStatesEqual"),void 0!==r&&"boolean"!=typeof r)throw new TypeError(`[router.areStatesEqual] Invalid ignoreQueryParams: ${v(r)}. Expected boolean.`)}get(){return this.#p}set(e){this.#m=this.#p,this.#p=e?H(e):void 0}getPrevious(){return this.#m}reset(){this.#p=void 0,this.#m=void 0,this.#v.clear(),this.#f=0}setDependencies(e){this.#g=e}makeState(e,t,r,i,n){const a=i?{...i,id:n??++this.#f,params:i.params,options:i.options}:void 0,s=this.#g.getDefaultParams();let o;return o=Object.hasOwn(s,e)?{...s[e],...t}:t?{...t}:{},H({name:e,params:o,path:r??this.#g.buildPath(e,t),meta:a})}makeNotFoundState(e,t){return this.makeState(T.UNKNOWN_ROUTE,{path:e},e,{options:t,params:{}})}areStatesEqual(e,t,r=!0){if(!e||!t)return!!e==!!t;if(e.name!==t.name)return!1;if(r){const r=e.meta?.params??t.meta?.params;return(r?function(e){const t=[];for(const r in e){const i=e[r];for(const e in i)"url"===i[e]&&t.push(e)}return t}(r):this.#w(e.name)).every(r=>ae(e.params[r],t.params[r]))}const i=Object.keys(e.params),n=Object.keys(t.params);return i.length===n.length&&i.every(r=>r in t.params&&ae(e.params[r],t.params[r]))}#w(e){const t=this.#v.get(e);if(void 0!==t)return t;const r=this.#g.getUrlParams(e);return this.#v.set(e,r),r}},oe="router.useMiddleware";function ce(e){return e.name||"anonymous"}var de=class{#y=new Set;#T=new Map;#b;#g;#u=D;static validateUseMiddlewareArgs(e){!function(e){for(const[t,r]of e.entries())if("function"!=typeof r)throw new TypeError(`[${oe}] Expected middleware factory function at index ${t}, got ${v(r)}`)}(e)}static validateMiddleware(e,t){!function(e,t){if("function"!=typeof e)throw new TypeError(`[${oe}] Middleware factory must return a function, got ${v(e)}. Factory: ${ce(t)}`)}(e,t)}static validateNoDuplicates(e,t){!function(e,t){for(const r of e)if(t(r))throw new Error(`[${oe}] Middleware factory already registered. To re-register, first unsubscribe the existing middleware. Factory: ${ce(r)}`)}(e,t)}static validateMiddlewareLimit(e,t,r){!function(e,t,r=D.maxMiddleware){if(0!==r&&e+t>r)throw new Error(`[${oe}] Middleware limit exceeded (${r}). Current: ${e}, Attempting to add: ${t}. This indicates an architectural problem. Consider consolidating middleware.`)}(e,t,r)}setRouter(e){this.#b=e}setDependencies(e){this.#g=e}setLimits(e){this.#u=e}count(){return this.#y.size}initialize(...e){const t=[];for(const r of e){const e=r(this.#b,this.#g.getDependency);t.push({factory:r,middleware:e})}return t}commit(e){this.#S(e.length);for(const{factory:t,middleware:r}of e)this.#y.add(t),this.#T.set(t,r);let t=!1;return()=>{if(!t){t=!0;for(const{factory:t}of e)this.#y.delete(t),this.#T.delete(t)}}}getFactories(){return[...this.#y]}has(e){return this.#y.has(e)}getFunctions(){return[...this.#T.values()]}clearAll(){this.#y.clear(),this.#T.clear()}#S(t){const r=this.#u.maxMiddleware;if(0===r)return;const i=t+this.#y.size,{warn:n,error:a}=Q(r);i>=a?e.logger.error(oe,`${i} middleware registered! This is excessive and will impact performance. Hard limit at ${r}.`):i>=n&&e.logger.warn(oe,`${i} middleware registered. Consider if all are necessary.`)}},ue={[b]:$.ROUTER_START,[S]:$.ROUTER_STOP,[E]:$.TRANSITION_SUCCESS,[R]:$.TRANSITION_START,[P]:$.TRANSITION_ERROR,[A]:$.TRANSITION_CANCEL},le=Object.keys(ue).filter(e=>m(e,ue)),he="router.usePlugin",fe=class t{#R=new Set;#A=new Set;#b;#g;#u=D;static validateUsePluginArgs(e){!function(e){for(const[t,r]of e.entries())if("function"!=typeof r)throw new TypeError(`[router.usePlugin] Expected plugin factory function at index ${t}, got ${v(r)}`)}(e)}static validatePlugin(e){!function(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new TypeError(`[router.usePlugin] Plugin factory must return an object, got ${v(e)}`);if("function"==typeof e.then)throw new TypeError("[router.usePlugin] Async plugin factories are not supported. Factory returned a Promise instead of a plugin object.");for(const t in e)if("teardown"!==t&&!m(t,ue))throw new TypeError(`[router.usePlugin] Unknown property '${t}'. Plugin must only contain event handlers and optional teardown.`)}(e)}static validatePluginLimit(e,t,r){!function(e,t,r=D.maxPlugins){if(0!==r&&e+t>r)throw new Error(`[router.usePlugin] Plugin limit exceeded (${r}). Current: ${e}, Attempting to add: ${t}. This indicates an architectural problem. Consider consolidating plugins.`)}(e,t,r)}static validateNoDuplicatePlugins(e,t){for(const r of e)if(t(r))throw new Error("[router.usePlugin] Plugin factory already registered. To re-register, first unsubscribe the existing plugin.")}setRouter(e){this.#b=e}setDependencies(e){this.#g=e}setLimits(e){this.#u=e}count(){return this.#R.size}use(...t){if(this.#S(t.length),1===t.length){const r=t[0],i=this.#E(r);this.#R.add(r);let n=!1;const a=()=>{if(!n){n=!0,this.#R.delete(r),this.#A.delete(a);try{i()}catch(t){e.logger.error(he,"Error during cleanup:",t)}}};return this.#A.add(a),a}const r=this.#P(t),i=[];try{for(const e of r){const t=this.#E(e);i.push({factory:e,cleanup:t})}}catch(t){for(const{cleanup:t}of i)try{t()}catch(t){e.logger.error(he,"Cleanup error:",t)}throw t}for(const{factory:e}of i)this.#R.add(e);let n=!1;const a=()=>{if(!n){n=!0,this.#A.delete(a);for(const{factory:e}of i)this.#R.delete(e);for(const{cleanup:t}of i)try{t()}catch(t){e.logger.error(he,"Error during cleanup:",t)}}};return this.#A.add(a),a}getAll(){return[...this.#R]}has(e){return this.#R.has(e)}disposeAll(){for(const e of this.#A)e();this.#R.clear(),this.#A.clear()}#S(t){const r=this.#u.maxPlugins;if(0===r)return;const i=t+this.#R.size,{warn:n,error:a}=Q(r);i>=a?e.logger.error(he,`${i} plugins registered! This is excessive and will impact performance. Hard limit at ${r}.`):i>=n&&e.logger.warn(he,`${i} plugins registered. Consider if all are necessary.`)}#P(t){const r=new Set;for(const i of t)r.has(i)?e.logger.warn(he,"Duplicate factory in batch, will be registered once"):r.add(i);return r}#E(r){const i=r(this.#b,this.#g.getDependency);t.validatePlugin(i),Object.freeze(i);const n=[];for(const t of le)t in i&&("function"==typeof i[t]?(n.push(this.#g.addEventListener(ue[t],i[t])),"onStart"===t&&this.#g.canNavigate()&&e.logger.warn(he,"Router already started, onStart will not be called")):e.logger.warn(he,`Property '${t}' is not a function, skipping`));return()=>{for(const e of n)e();"function"==typeof i.teardown&&i.teardown()}}};function pe(e,t,r){if(e)throw new Error(`[router.${r}] Cannot modify route "${t}" during its own registration`)}function me(e,t,r=D.maxLifecycleHandlers){if(0!==r&&e>=r)throw new Error(`[router.${t}] Lifecycle handler limit exceeded (${r}). This indicates too many routes with individual handlers. Consider using middleware for cross-cutting concerns.`)}var ge=class{#$=new Map;#O=new Map;#D=new Map;#N=new Map;#C=new Set;#b;#g;#u=D;static validateHandler(e,t){!function(e,t){if(!p(e)&&"function"!=typeof e)throw new TypeError(`[router.${t}] Handler must be a boolean or factory function, got ${v(e)}`)}(e,t)}setRouter(e){this.#b=e}setDependencies(e){this.#g=e}setLimits(e){this.#u=e}addCanActivate(e,t,r){r||pe(this.#C.has(e),e,"addActivateGuard");const i=this.#O.has(e);i||r||me(this.#O.size+1,"addActivateGuard",this.#u.maxLifecycleHandlers),this.#j("activate",e,t,this.#O,this.#N,"canActivate",i)}addCanDeactivate(e,t,r){r||pe(this.#C.has(e),e,"addDeactivateGuard");const i=this.#$.has(e);i||r||me(this.#$.size+1,"addDeactivateGuard",this.#u.maxLifecycleHandlers),this.#j("deactivate",e,t,this.#$,this.#D,"canDeactivate",i)}clearCanActivate(e){this.#O.delete(e),this.#N.delete(e)}clearCanDeactivate(e){this.#$.delete(e),this.#D.delete(e)}clearAll(){this.#O.clear(),this.#N.clear(),this.#$.clear(),this.#D.clear()}getFactories(){const e={},t={};for(const[t,r]of this.#$)e[t]=r;for(const[e,r]of this.#O)t[e]=r;return[e,t]}getFunctions(){return[this.#D,this.#N]}checkActivateGuardSync(e,t,r){return this.#F(this.#N,e,t,r,"checkActivateGuardSync")}checkDeactivateGuardSync(e,t,r){return this.#F(this.#D,e,t,r,"checkDeactivateGuardSync")}#j(t,r,i,n,a,s,o){o?e.logger.warn(`router.${s}`,`Overwriting existing ${t} handler for route "${r}"`):this.#S(n.size+1,s);const c=p(i)?function(e){const t=()=>e;return()=>t}(i):i;n.set(r,c),this.#C.add(r);try{const e=c(this.#b,this.#g.getDependency);if("function"!=typeof e)throw new TypeError(`[router.${s}] Factory must return a function, got ${v(e)}`);a.set(r,e)}catch(e){throw n.delete(r),e}finally{this.#C.delete(r)}}#F(t,r,i,n,a){const s=t.get(r);if(!s)return!0;try{const t=s(i,n);return"boolean"==typeof t?t:(e.logger.warn(`router.${a}`,`Guard for "${r}" returned a Promise. Sync check cannot resolve async guards — returning false.`),!1)}catch{return!1}}#S(t,r){const i=this.#u.maxLifecycleHandlers;if(0===i)return;const{warn:n,error:a}=Q(i);t>=a?e.logger.error(`router.${r}`,`${t} lifecycle handlers registered! This is excessive. Hard limit at ${i}.`):t>=n&&e.logger.warn(`router.${r}`,`${t} lifecycle handlers registered. Consider consolidating logic.`)}};function ve(e){return`(${e.replaceAll(/(^<|>$)/g,"")})`}var we=/([:*])([^/?<]+)(<[^>]+>)?(\?)?/g,ye=/([:*][^/?<]+(?:<[^>]+>)?)\?(?=\/|$)/g,Te=/\?(.+)$/,be=/[^\w!$'()*+,.:;|~-]/gu,Se=/[^\w!$'()*+,.:;|~-]/u,Re={default:e=>Se.test(e)?e.replaceAll(be,e=>encodeURIComponent(e)):e,uri:encodeURI,uriComponent:encodeURIComponent,none:e=>e},Ae={default:decodeURIComponent,uri:decodeURI,uriComponent:decodeURIComponent,none:e=>e};function Ee(){return{staticChildren:Object.create(null),paramChild:void 0,splatChild:void 0,route:void 0,slashChildRoute:void 0}}function Pe(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function $e(e){const t={};if(0===e.length)return t;const r=e.split("&");for(const e of r){const r=e.indexOf("=");-1===r?t[e]="":t[e.slice(0,r)]=e.slice(r+1)}return t}function Oe(e){const t=[];for(const r of Object.keys(e)){const i=e[r],n=encodeURIComponent(r);t.push(""===i?n:`${n}=${encodeURIComponent(String(i))}`)}return t.join("&")}function De(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Ne(e){let t=0;for(;t<e.length;)if("%"===e[t]){if(t+2>=e.length)return!1;const r=e.codePointAt(t+1)??0,i=e.codePointAt(t+2)??0;if(!De(r)||!De(i))return!1;t+=3}else t++;return!0}var Ce=/<[^>]*>/g;function je(e,t,r,i,n){const a=""===t.fullName;a||i.push(t);const s=t.absolute,o=t.paramMeta.pathPattern,c=s&&o.startsWith("~")?o.slice(1):o,d=(s?c:o).replaceAll(Ce,""),u=s?d:(h=d,""===(l=r)?h:""===h?l:l+h);var l,h;let f=n;a||(f=function(e,t,r,i,n,a){const s=(g=i,Pe(r)===Pe(g)),o=Object.freeze([...n]),c=function(e){const t={};for(const r of e)t[r.fullName]=r.paramTypeMap;return Object.freeze(t)}(o),d=Pe(r),u=function(e,t){const r=[];e.length>0&&r.push(...e);for(const e of t)e.paramMeta.queryParams.length>0&&r.push(...e.paramMeta.queryParams);return r}(e.rootQueryParams,n),l=function(e){const t=new Map;for(const r of e)for(const[e,i]of r.paramMeta.constraintPatterns)t.set(e,i);return t}(n),h=s?Pe(i):d,{buildStaticParts:f,buildParamSlots:p}=function(e,t,r){const i=new Set,n=new Set;for(const e of t){for(const t of e.paramMeta.urlParams)i.add(t);for(const t of e.paramMeta.spatParams)n.add(t)}if(0===i.size)return{buildStaticParts:[e],buildParamSlots:[]};const a=[],s=[],o=/[:*]([\w]+)(?:<[^>]*>)?(\?)?/gu;let c,d=0;for(;null!==(c=o.exec(e));){const t=c[1],i="?"===c[2];a.push(e.slice(d,c.index));const o=n.has(t);s.push({paramName:t,isOptional:i,encoder:o?e=>{const t=Re[r],i=e.split("/");let n=t(i[0]);for(let e=1;e<i.length;e++)n+=`/${t(i[e])}`;return n}:Re[r]}),d=c.index+c[0].length}return a.push(e.slice(d)),{buildStaticParts:a,buildParamSlots:s}}(h,s?n.slice(0,-1):n,e.options.urlParamsEncoding),m={name:t.fullName,parent:a,depth:n.length-1,matchSegments:o,meta:c,declaredQueryParams:u,declaredQueryParamsSet:new Set(u),hasTrailingSlash:r.length>1&&r.endsWith("/"),constraintPatterns:l,hasConstraints:l.size>0,buildStaticParts:f,buildParamSlots:p};var g;return e.routesByName.set(t.fullName,m),e.segmentsByName.set(t.fullName,o),e.metaByName.set(t.fullName,c),s?function(e,t,r){var i,n;i=t,(function(e,t,r){const i=Pe(r);if("/"===i||""===i)return t;let n=t,a=1;const s=i.length;for(;a<=s;){const t=i.indexOf("/",a),r=-1===t?s:t;if(r<=a)break;n=Me(e,n,i.slice(a,r)),a=r+1}return n}(n=e,n.root,r)).slashChildRoute=i;const a=Pe(r),s=e.options.caseSensitive?a:a.toLowerCase();e.staticCache.has(s)&&e.staticCache.set(s,t)}(e,m,i):function(e,t,r,i,n){if(function(e,t,r){const i=Pe(r);"/"!==i?Fe(e,e.root,i,1,t):e.root.route=t}(e,t,r),0===n.paramMeta.urlParams.length){const r=e.options.caseSensitive?i:i.toLowerCase();e.staticCache.set(r,t)}}(e,m,r,d,t),m}(e,t,u,s?"":r,i,n));for(const r of t.children.values())je(e,r,u,i,f);a||i.pop()}function Fe(e,t,r,i,n){const a=r.length;for(;i<=a;){const s=r.indexOf("/",i),o=-1===s?a:s,c=r.slice(i,o);if(c.endsWith("?")){const i=c.slice(1).replaceAll(Ce,"").replace(/\?$/,"");return t.paramChild??={node:Ee(),name:i},Fe(e,t.paramChild.node,r,o+1,n),void(o>=a?t.route??=n:Fe(e,t,r,o+1,n))}t=Me(e,t,c),i=o+1}t.route=n}function Me(e,t,r){if(r.startsWith("*")){const e=r.slice(1);return t.splatChild??={node:Ee(),name:e},t.splatChild.node}if(r.startsWith(":")){const e=r.slice(1).replaceAll(Ce,"").replace(/\?$/,"");return t.paramChild??={node:Ee(),name:e},t.paramChild.node}const i=e.options.caseSensitive?r:r.toLowerCase();return i in t.staticChildren||(t.staticChildren[i]=Ee()),t.staticChildren[i]}var xe=/[\u0080-\uFFFF]/,Ie=class{get options(){return this.#e}#e;#t=Ee();#n=new Map;#a=new Map;#r=new Map;#s=new Map;#i="";#M=[];constructor(e){this.#e={caseSensitive:e?.caseSensitive??!0,strictTrailingSlash:e?.strictTrailingSlash??!1,strictQueryParams:e?.strictQueryParams??!1,urlParamsEncoding:e?.urlParamsEncoding??"default",parseQueryString:e?.parseQueryString??$e,buildQueryString:e?.buildQueryString??Oe}}registerTree(e){this.#M=e.paramMeta.queryParams,je({root:this.#t,options:this.#e,routesByName:this.#n,segmentsByName:this.#a,metaByName:this.#r,staticCache:this.#s,rootQueryParams:this.#M},e,"",[],null)}match(e){const t=this.#o(e);if(!t)return;const[r,i,n]=t,a=this.#e.caseSensitive?i:i.toLowerCase(),s=this.#s.get(a);if(s){if(this.#e.strictTrailingSlash&&!this.#c(r,s))return;return this.#x(s,{},n)}const o={},c=this.#I(i,o);return!c||this.#e.strictTrailingSlash&&!this.#c(r,c)||c.hasConstraints&&!this.#L(o,c)||!this.#k(o)?void 0:this.#x(c,o,n)}buildPath(e,t,r){const i=this.#n.get(e);if(!i)throw new Error(`[SegmentMatcher.buildPath] '${e}' is not defined`);i.hasConstraints&&t&&this.#U(i,e,t);const n=this.#_(i,t),a=this.#B(n,r?.trailingSlash),s=this.#V(i,t,r?.queryParamsMode);return a+(s?`?${s}`:"")}getSegmentsByName(e){return this.#a.get(e)}getMetaByName(e){return this.#r.get(e)}hasRoute(e){return this.#n.has(e)}setRootPath(e){this.#i=e}#U(e,t,r){for(const[i,n]of e.constraintPatterns){const e=r[i];if(null!=e){const r="object"==typeof e?JSON.stringify(e):String(e);if(!n.pattern.test(r))throw new Error(`[SegmentMatcher.buildPath] '${t}' — param '${i}' value '${r}' does not match constraint '${n.constraint}'`)}}}#_(e,t){const r=e.buildStaticParts,i=e.buildParamSlots;if(0===i.length)return this.#i+r[0];let n=this.#i+r[0];for(const[e,a]of i.entries()){const i=t?.[a.paramName];if(null==i){if(!a.isOptional)throw new Error(`[SegmentMatcher.buildPath] Missing required param '${a.paramName}'`);n.length>1&&n.endsWith("/")&&(n=n.slice(0,-1)),n+=r[e+1];continue}const s="object"==typeof i?JSON.stringify(i):String(i);n+=a.encoder(s)+r[e+1]}return n}#B(e,t){return"always"!==t||e.endsWith("/")?"never"===t&&"/"!==e&&e.endsWith("/")?e.slice(0,-1):e:`${e}/`}#V(e,t,r){if(!t)return"";const i=[...e.declaredQueryParams];if("loose"===r){const r=new Set(e.buildParamSlots.map(e=>e.paramName));for(const n in t)!Object.hasOwn(t,n)||e.declaredQueryParamsSet.has(n)||r.has(n)||i.push(n)}const n={};for(const e of i)e in t&&(n[e]=t[e]);return 0===Object.keys(n).length?"":this.#e.buildQueryString(n)}#o(e){if(""===e&&(e="/"),!e.startsWith("/"))return;const t=e.indexOf("#");if(-1!==t&&(e=e.slice(0,t)),xe.test(e))return;if(this.#i.length>0){if(!e.startsWith(this.#i))return;e=e.slice(this.#i.length)||"/"}const r=e.indexOf("?"),i=-1===r?e:e.slice(0,r),n=-1===r?void 0:e.slice(r+1);return i.includes("//")?void 0:[i,Pe(i),n]}#x(e,t,r){if(void 0!==r){const i=this.#e.parseQueryString(r);if(this.#e.strictQueryParams){const t=e.declaredQueryParamsSet;for(const e of Object.keys(i))if(!t.has(e))return}for(const e of Object.keys(i))t[e]=i[e]}return{segments:e.matchSegments,params:t,meta:e.meta}}#c(e,t){return(e.length>1&&e.endsWith("/"))===t.hasTrailingSlash}#I(e,t){return 1===e.length?this.#t.slashChildRoute??this.#t.route:this.#G(this.#t,e,1,t)}#G(e,t,r,i){let n=e;const a=t.length;for(;r<=a;){const e=t.indexOf("/",r),s=-1===e?a:e,o=t.slice(r,s),c=this.#e.caseSensitive?o:o.toLowerCase();let d;if(c in n.staticChildren)d=n.staticChildren[c];else{if(!n.paramChild){if(n.splatChild){const e={},a=this.#G(n.splatChild.node,t,r,e);return a?(Object.assign(i,e),a):(i[n.splatChild.name]=t.slice(r),n.splatChild.node.route)}return}d=n.paramChild.node,i[n.paramChild.name]=o}n=d,r=s+1}return n.slashChildRoute??n.route}#k(e){const t=this.#e.urlParamsEncoding;if("none"===t)return!0;const r=Ae[t];for(const t in e){const i=e[t];if(i.includes("%")){if(!Ne(i))return!1;e[t]=r(i)}}return!0}#L(e,t){for(const[r,i]of t.constraintPatterns)if(!i.pattern.test(e[r]))return!1;return!0}},Le=e=>{const t=e.indexOf("%"),r=e.indexOf("+");if(-1===t&&-1===r)return e;const i=-1===r?e:e.split("+").join(" ");return-1===t?i:decodeURIComponent(i)},ke=e=>{const t=typeof e;if("string"!==t&&"number"!==t&&"boolean"!==t)throw new TypeError(`[search-params] Array element must be a string, number, or boolean — received ${"object"===t&&null===e?"null":t}`);return encodeURIComponent(e)},Ue={none:{encodeArray:(e,t)=>t.map(t=>`${e}=${ke(t)}`).join("&")},brackets:{encodeArray:(e,t)=>t.map(t=>`${e}[]=${ke(t)}`).join("&")},index:{encodeArray:(e,t)=>t.map((t,r)=>`${e}[${r}]=${ke(t)}`).join("&")},comma:{encodeArray:(e,t)=>`${e}=${t.map(e=>ke(e)).join(",")}`}},_e={none:{encode:(e,t)=>`${e}=${t}`,decodeUndefined:()=>null,decodeRaw:()=>null,decodeValue:e=>e},string:{encode:(e,t)=>`${e}=${t}`,decodeUndefined:()=>null,decodeRaw:e=>"true"===e||"false"!==e&&null,decodeValue:e=>e},"empty-true":{encode:(e,t)=>t?e:`${e}=false`,decodeUndefined:()=>!0,decodeRaw:()=>null,decodeValue:e=>e}},Be={default:{encode:e=>e},hidden:{encode:()=>""}},Ve=(e,t,r)=>({boolean:_e[t],null:Be[r],array:Ue[e]}),Ge={arrayFormat:"none",booleanFormat:"none",nullFormat:"default",strategies:{boolean:_e.none,null:Be.default,array:Ue.none}},qe=e=>{if(!e||void 0===e.arrayFormat&&void 0===e.booleanFormat&&void 0===e.nullFormat)return Ge;const t=e.arrayFormat??"none",r=e.booleanFormat??"none",i=e.nullFormat??"default";return{arrayFormat:t,booleanFormat:r,nullFormat:i,strategies:Ve(t,r,i)}},ze=e=>encodeURIComponent(e),We=(e,t,r)=>{const i=ze(e);switch(typeof t){case"string":case"number":default:return`${i}=${ze(t)}`;case"boolean":return r.strategies.boolean.encode(i,t);case"object":return null===t?r.strategies.null.encode(i):Array.isArray(t)?r.strategies.array.encodeArray(i,t):`${i}=${ze(t)}`}};function He(e,t,r,i,n){const a=e.indexOf("=",t),s=-1!==a&&a<r,o=e.slice(t,s?a:r),{name:c,hasBrackets:d}=function(e){const t=e.indexOf("[");return-1===t?{name:e,hasBrackets:!1}:{name:e.slice(0,t),hasBrackets:!0}}(o);var u,l,h,f,p;!function(e,t,r,i){const n=e[t];void 0===n?e[t]=i?[r]:r:Array.isArray(n)?n.push(r):e[t]=[n,r]}(i,Le(c),(u=e,l=a,h=r,f=s,p=n,p?((e,t)=>{if(void 0===e)return t.boolean.decodeUndefined();const r=t.boolean.decodeRaw(e);if(null!==r)return r;const i=Le(e);return t.boolean.decodeValue(i)})(f?u.slice(l+1,h):void 0,p):f?Le(u.slice(l+1,h)):null),d)}function Qe(e,t){const r=e.path,i=r.startsWith("~"),n=i?r.slice(1):r,a={name:e.name,path:n,absolute:i,children:[],parent:t,nonAbsoluteChildren:[],fullName:""};if(e.children)for(const t of e.children){const e=Qe(t,a);a.children.push(e)}return a}function Ke(e,t){return e.endsWith("/")&&t.startsWith("/")?e+t.slice(1):e+t}function Je(e){const t=new Map;for(const r of e)t.set(r.name,r);return t}function Ye(e,t,r){const i=function(e){const t=[],r=[],i=[],n={},a=new Map,s=e.replaceAll(ye,"$1"),o=Te.exec(s);if(null!==o){const t=o[1].split("&");for(const e of t){const t=e.trim();t.length>0&&(r.push(t),n[t]="query")}e=e.slice(0,o.index)}let c;for(;null!==(c=we.exec(e));){const e=c[2],r=c[3];if("*"===c[1])i.push(e),t.push(e),n[e]="url";else if(t.push(e),n[e]="url",r){const t=`^${ve(r)}$`;a.set(e,{pattern:new RegExp(t),constraint:r})}}return{urlParams:t,queryParams:r,spatParams:i,paramTypeMap:n,constraintPatterns:a,pathPattern:e}}(e.path),n=function(e){const t={};for(const r of e.urlParams)t[r]="url";for(const r of e.queryParams)t[r]="query";return t}(i),a={name:e.name,path:e.path,absolute:e.absolute,parent:t,children:void 0,paramMeta:i,nonAbsoluteChildren:void 0,fullName:"",staticPath:null,paramTypeMap:n};var s;a.fullName=(s=a,s.parent?.name?`${s.parent.fullName}.${s.name}`:s.name);const{childrenMap:o,nonAbsoluteChildren:c}=function(e,t,r){const i=[],n=[];for(const a of e){const e=Ye(a,t,r);i.push(e),e.absolute||n.push(e)}return{childrenMap:Je(i),nonAbsoluteChildren:n}}(e.children,a,r);return a.children=o,a.nonAbsoluteChildren=c,a.staticPath=function(e){if(!e.path)return null;const{urlParams:t,queryParams:r,spatParams:i}=e.paramMeta;if(t.length>0||r.length>0||i.length>0)return null;const n=[];let a=e.parent;for(;a?.path;)n.unshift(a),a=a.parent;let s="";for(const e of n){const{urlParams:t,queryParams:r,spatParams:i}=e.paramMeta;if(t.length>0||r.length>0||i.length>0)return null;s=e.absolute?e.path:Ke(s,e.path)}return e.absolute?e.path:Ke(s,e.path)}(a),r&&(Object.freeze(c),Object.freeze(n),Object.freeze(a.children),Object.freeze(a)),a}function Ze(e,t,r,i){return function(e,t){const r=[];return{add(e){return r.push(e),this},addMany(e){return r.push(...e),this},build:i=>function(e,t=!0){return Ye(e,null,t)}(function(e,t,r){const i=Qe({name:e,path:t},null);for(const e of r){const t=Qe(e,i);i.children.push(t)}return i}(e,t,r),!i?.skipFreeze)}}(e,t).addMany(r).build(i)}function Xe(e){const t={name:e.name,path:e.absolute?`~${e.path}`:e.path};return e.children.size>0&&(t.children=[...e.children.values()].map(e=>Xe(e))),t}function et(e){const t=e?.queryParams;return new Ie({...void 0===e?.caseSensitive?void 0:{caseSensitive:e.caseSensitive},...void 0===e?.strictTrailingSlash?void 0:{strictTrailingSlash:e.strictTrailingSlash},...void 0===e?.strictQueryParams?void 0:{strictQueryParams:e.strictQueryParams},...void 0===e?.urlParamsEncoding?void 0:{urlParamsEncoding:e.urlParamsEncoding},parseQueryString:e=>((e,t)=>{const r=(e=>{const t=e.indexOf("?");return-1===t?e:e.slice(t+1)})(e);if(""===r||"?"===r)return{};if(!t)return function(e){const t={};return function(e,t){let r=0;const i=e.length;for(;r<i;){let n=e.indexOf("&",r);-1===n&&(n=i),He(e,r,n,t),r=n+1}}(e,t),t}(r);const i=qe(t),n={};let a=0;const s=r.length;for(;a<s;){let e=r.indexOf("&",a);-1===e&&(e=s),He(r,a,e,n,i.strategies),a=e+1}return n})(e,t),buildQueryString:e=>((e,t)=>{const r=Object.keys(e);if(0===r.length)return"";const i=qe(t),n=[];for(const t of r){const r=e[t];if(void 0===r)continue;const a=We(t,r,i);a&&n.push(a)}return n.join("&")})(e,t)})}function tt(e,t){return new TypeError(`[router.${e}] ${t}`)}var rt=/^[A-Z_a-z][\w-]*$/,it=/\S/;function nt(e){return null===e?"null":"object"==typeof e?"constructor"in e&&"Object"!==e.constructor.name?e.constructor.name:"object":typeof e}function at(e,t){if(!t.includes("."))return e.children.get(t);let r=e;for(const e of t.split("."))if(r=r.children.get(e),!r)return;return r}function st(e,t,r,i="",n,a){!function(e,t){if(!e||"object"!=typeof e)throw new TypeError(`[router.${t}] Route must be an object, got ${nt(e)}`);const r=Object.getPrototypeOf(e);if(r!==Object.prototype&&null!==r)throw new TypeError(`[router.${t}] Route must be a plain object, got ${nt(e)}`);if(function(e){for(const t of Object.keys(e)){const r=Object.getOwnPropertyDescriptor(e,t);if(r&&(r.get||r.set))return!0}return!1}(e))throw new TypeError(`[router.${t}] Route must not have getters or setters`)}(e,t);const s=e;!function(e,t){if("string"!=typeof e.name)throw new TypeError(`[router.${t}] Route name must be a string, got ${nt(e.name)}`);const r=e.name;if(""===r)throw new TypeError(`[router.${t}] Route name cannot be empty`);if(!it.test(r))throw new TypeError(`[router.${t}] Route name cannot contain only whitespace`);if(r.length>1e4)throw new TypeError(`[router.${t}] Route name exceeds maximum length of 10000 characters`);if(!r.startsWith("@@")){if(r.includes("."))throw new TypeError(`[router.${t}] Route name "${r}" cannot contain dots. Use children array or { parent } option in addRoute() instead.`);if(!rt.test(r))throw new TypeError(`[router.${t}] Invalid route name "${r}". Name must start with a letter or underscore, followed by letters, numbers, underscores, or hyphens.`)}}(s,t),function(e,t,r,i){if("string"!=typeof e){let t;throw t=null===e?"null":Array.isArray(e)?"array":typeof e,tt(r,`Route path must be a string, got ${t}`)}if(""===e)return;if(/\s/.test(e))throw tt(r,`Invalid path for route "${t}": whitespace not allowed in "${e}"`);if(!/^([/?~]|[^/]+$)/.test(e))throw tt(r,`Route "${t}" has invalid path format: "${e}". Path should start with '/', '~', '?' or be a relative segment.`);if(e.includes("//"))throw tt(r,`Invalid path for route "${t}": double slashes not allowed in "${e}"`);const n=i&&Object.values(i.paramTypeMap).includes("url");if(e.startsWith("~")&&n)throw tt(r,`Absolute path "${e}" cannot be used under parent route with URL parameters`)}(s.path,s.name,t,r),function(e,t){if(void 0!==e.encodeParams&&"function"!=typeof e.encodeParams)throw new TypeError(`[router.${t}] Route "${String(e.name)}" encodeParams must be a function`)}(s,t),function(e,t){if(void 0!==e.decodeParams&&"function"!=typeof e.decodeParams)throw new TypeError(`[router.${t}] Route "${String(e.name)}" decodeParams must be a function`)}(s,t);const o=s.name,c=i?`${i}.${o}`:o;r&&c&&function(e,t,r){if(at(e,t))throw new Error(`[router.${r}] Route "${t}" already exists`)}(r,c,t),n&&function(e,t,r){if(e.has(t))throw new Error(`[router.${r}] Duplicate route "${t}" in batch`);e.add(t)}(n,c,t);const d=s.path,u=i;if(r&&function(e,t,r,i){const n=""===t?e:at(e,t);if(n)for(const e of n.children.values())if(e.path===r)throw new Error(`[router.${i}] Path "${r}" is already defined`)}(r,u,d,t),a&&function(e,t,r,i){const n=e.get(t);if(n?.has(r))throw new Error(`[router.${i}] Path "${r}" is already defined`);n?n.add(r):e.set(t,new Set([r]))}(a,u,d,t),void 0!==s.children){if(!Array.isArray(s.children))throw new TypeError(`[router.${t}] Route "${o}" children must be an array, got ${nt(s.children)}`);for(const e of s.children)st(e,t,r,c,n,a)}}var ot=new Set;function ct(e){const t={name:e.name,path:e.path};return e.children&&(t.children=e.children.map(e=>ct(e))),t}function dt(e,t,r=""){for(let i=0;i<e.length;i++){const n=e[i],a=r?`${r}.${n.name}`:n.name;if(a===t)return e.splice(i,1),!0;if(n.children&&t.startsWith(`${a}.`)&&dt(n.children,t,a))return!0}return!1}function ut(e,t){for(const r of Object.keys(e))t(r)&&delete e[r]}function lt(e,t){if(void 0!==e.canActivate&&"function"!=typeof e.canActivate)throw new TypeError(`[router.addRoute] canActivate must be a function for route "${t}", got ${v(e.canActivate)}`);if(void 0!==e.canDeactivate&&"function"!=typeof e.canDeactivate)throw new TypeError(`[router.addRoute] canDeactivate must be a function for route "${t}", got ${v(e.canDeactivate)}`);if(void 0!==e.defaultParams){const r=e.defaultParams;if(null===r||"object"!=typeof r||Array.isArray(r))throw new TypeError(`[router.addRoute] defaultParams must be an object for route "${t}", got ${v(e.defaultParams)}`)}if("AsyncFunction"===e.decodeParams?.constructor.name)throw new TypeError(`[router.addRoute] decodeParams cannot be async for route "${t}". Async functions break matchPath/buildPath.`);if("AsyncFunction"===e.encodeParams?.constructor.name)throw new TypeError(`[router.addRoute] encodeParams cannot be async for route "${t}". Async functions break matchPath/buildPath.`);if(function(e,t){if(void 0!==e&&"function"==typeof e){const r="AsyncFunction"===e.constructor.name,i=e.toString().includes("__awaiter");if(r||i)throw new TypeError(`[router.addRoute] forwardTo callback cannot be async for route "${t}". Async functions break matchPath/buildPath.`)}}(e.forwardTo,t),e.children)for(const r of e.children)lt(r,`${t}.${r.name}`)}function ht(e){const t=new Set,r=/[*:]([A-Z_a-z]\w*)/g;let i;for(;null!==(i=r.exec(e));)t.add(i[1]);return t}function ft(e){const t=new Set;for(const r of e)for(const e of ht(r))t.add(e);return t}function pt(e,t,r="",i=[]){for(const n of e){const e=r?`${r}.${n.name}`:n.name,a=[...i,n.path];if(e===t)return a;if(n.children&&t.startsWith(`${e}.`))return pt(n.children,t,e,a)}throw new Error(`[internal] collectPathsToRoute: route "${t}" not found`)}function mt(e,t=""){const r=new Set;for(const i of e){const e=t?`${t}.${i.name}`:i.name;if(r.add(e),i.children)for(const t of mt(i.children,e))r.add(t)}return r}function gt(e,t=""){const r=new Map;for(const i of e){const e=t?`${t}.${i.name}`:i.name;if(i.forwardTo&&"string"==typeof i.forwardTo&&r.set(e,i.forwardTo),i.children)for(const[t,n]of gt(i.children,e))r.set(t,n)}return r}function vt(e,t,r,i){return t?function(e){const t=new Set;for(const r of e){for(const e of r.paramMeta.urlParams)t.add(e);for(const e of r.paramMeta.spatParams)t.add(e)}return t}(function(e,t){const r=[],i=t.includes(".")?t.split("."):[t];""!==e.path&&r.push(e);let n=e;for(const e of i){const t=n.children.get(e);if(!t)return null;r.push(t),n=t}return r}(r,e)):ft(pt(i,e))}function wt(e,t,r,i,n){const a=function(e,t){const r=t.split(".");let i=e;for(const e of r)if(i=i.children.get(e),!i)return!1;return!0}(n,t),s=i.has(t);if(!a&&!s)throw new Error(`[router.addRoute] forwardTo target "${t}" does not exist for route "${e}"`);const o=ft(pt(r,e)),c=[...vt(t,a,n,r)].filter(e=>!o.has(e));if(c.length>0)throw new Error(`[router.addRoute] forwardTo target "${t}" requires params [${c.join(", ")}] that are not available in source route "${e}"`)}function yt(e,t,r=100){const i=new Set,n=[e];let a=e;for(;t[a];){const e=t[a];if(i.has(e)){const t=n.indexOf(e),r=[...n.slice(t),e];throw new Error(`Circular forwardTo: ${r.join(" → ")}`)}if(i.add(a),n.push(e),a=e,n.length>r)throw new Error(`forwardTo chain exceeds maximum depth (${r}): ${n.join(" → ")}`)}return a}function Tt(e,t,r){const i=mt(e),n=gt(e),a={...t};for(const[e,t]of n)a[e]=t;for(const[t,a]of n)wt(t,a,e,i,r);for(const e of Object.keys(a))yt(e,a)}function bt(e,t){var r;return{name:t??(r=e.segments,r.at(-1)?.fullName??""),params:e.params,meta:e.meta}}function St(e,t){if("AsyncFunction"===e.constructor.name||e.toString().includes("__awaiter"))throw new TypeError(`[real-router] updateRoute: ${t} cannot be an async function`)}function Rt(e,t){if(null!=e){if("function"!=typeof e)throw new TypeError(`[real-router] updateRoute: ${t} must be a function or null, got ${typeof e}`);St(e,t)}}var At=".";function Et(e){const t=[];for(let r=e.length-1;r>=0;r--)t.push(e[r]);return t}function Pt(e,t){const r=t.meta?.params[e];if(!r||"object"!=typeof r)return{};const i={};for(const e in r){if(!Object.hasOwn(r,e))continue;if(void 0===r[e])continue;const n=t.params[e];null!=n&&("string"!=typeof n&&"number"!=typeof n&&"boolean"!=typeof n||(i[e]=String(n)))}return i}function $t(e){if(!e)return[""];const t=e.indexOf(At);if(-1===t)return[e];const r=e.indexOf(At,t+1);if(-1===r)return[e.slice(0,t),e];const i=e.indexOf(At,r+1);return-1===i?[e.slice(0,t),e.slice(0,r),e]:-1===e.indexOf(At,i+1)?[e.slice(0,t),e.slice(0,r),e.slice(0,i),e]:function(e){const t=e.split(At),r=t.length,i=[t[0]];let n=t[0].length;for(let a=1;a<r-1;a++)n+=1+t[a].length,i.push(e.slice(0,n));return i.push(e),i}(e)}function Ot(e,t){if(!t)return{intersection:"",toActivate:$t(e.name),toDeactivate:[]};if((e.meta?.options??{}).reload)return{intersection:"",toActivate:$t(e.name),toDeactivate:Et($t(t.name))};const r=void 0!==e.meta?.params,i=void 0!==t.meta?.params;if(!r&&!i)return{intersection:"",toActivate:$t(e.name),toDeactivate:Et($t(t.name))};if(e.name===t.name&&r&&i){const r=e.meta&&0===Object.keys(e.meta.params).length,i=t.meta&&0===Object.keys(t.meta.params).length;if(r&&i)return{intersection:e.name,toActivate:[],toDeactivate:[]}}const n=$t(e.name),a=$t(t.name),s=function(e,t,r,i,n){for(let a=0;a<n;a++){const n=r[a],s=i[a];if(n!==s)return a;const o=Pt(n,e),c=Pt(s,t),d=Object.keys(o),u=Object.keys(c);if(d.length!==u.length)return a;for(const e of d)if(o[e]!==c[e])return a}return n}(e,t,n,a,Math.min(a.length,n.length)),o=[];for(let e=a.length-1;e>=s;e--)o.push(a[e]);const c=n.slice(s);return{intersection:s>0?a[s-1]:"",toDeactivate:o,toActivate:c}}var Dt=Object.freeze({}),Nt=class{#q=[];#z=function(){return{decoders:Object.create(null),encoders:Object.create(null),defaultParams:Object.create(null),forwardMap:Object.create(null),forwardFnMap:Object.create(null)}}();#W=Object.create(null);#H=new Map;#Q=new Map;#K="";#J;#Y;#Z;#X;#ee;#te;get#g(){if(!this.#X)throw new Error("[real-router] RoutesNamespace: dependencies not initialized");return this.#X}constructor(e=[],t=!1,r){this.#te=t,this.#Z=r;for(const t of e)this.#q.push(ct(t));this.#J=Ze("",this.#K,this.#q),this.#Y=et(r),this.#Y.registerTree(this.#J),this.#re(e),t?this.#ie():this.#ne()}static validateRemoveRouteArgs(e){!function(e){g(e,"removeRoute")}(e)}static validateSetRootPathArgs(e){!function(e){if("string"!=typeof e)throw new TypeError(`[router.setRootPath] rootPath must be a string, got ${v(e)}`)}(e)}static validateAddRouteArgs(e){!function(e){for(const t of e){if(null===t||"object"!=typeof t||Array.isArray(t))throw new TypeError(`[router.addRoute] Route must be an object, got ${v(t)}`);lt(t,t.name)}}(e)}static validateParentOption(e){!function(e){if("string"!=typeof e||""===e)throw new TypeError(`[router.addRoute] parent option must be a non-empty string, got ${v(e)}`);g(e,"addRoute")}(e)}static validateIsActiveRouteArgs(e,t,r,i){!function(e,t,r,i){if(!f(e))throw new TypeError("Route name must be a string");if(void 0!==t&&!l(t))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!==i&&"boolean"!=typeof i)throw new TypeError("[router.isActiveRoute] ignoreQueryParams must be a boolean, got "+typeof i)}(e,t,r,i)}static validateStateBuilderArgs(e,t,r){!function(e,t,r){if(!f(e))throw new TypeError(`[router.${r}] Invalid routeName: ${v(e)}. Expected string.`);if(!l(t))throw new TypeError(`[router.${r}] Invalid routeParams: ${v(t)}. Expected plain object.`)}(e,t,r)}static validateUpdateRouteBasicArgs(e,t){!function(e,t){if(g(e,"updateRoute"),""===e)throw new ReferenceError("[router.updateRoute] Invalid name: empty string. Cannot update root node.");if(null===t)throw new TypeError("[real-router] updateRoute: updates must be an object, got null");if("object"!=typeof t||Array.isArray(t))throw new TypeError(`[real-router] updateRoute: updates must be an object, got ${v(t)}`)}(e,t)}static validateUpdateRoutePropertyTypes(e,t,r,i){!function(e,t,r,i){if(null!=e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError(`[real-router] updateRoute: forwardTo must be a string, function, or null, got ${v(e)}`);"function"==typeof e&&St(e,"forwardTo callback")}if(null!=t&&("object"!=typeof t||Array.isArray(t)))throw new TypeError(`[real-router] updateRoute: defaultParams must be an object or null, got ${v(t)}`);Rt(r,"decodeParams"),Rt(i,"encodeParams")}(e,t,r,i)}static validateBuildPathArgs(e){!function(e){if(!f(e)||""===e)throw new TypeError("[real-router] buildPath: route must be a non-empty string, got "+("string"==typeof e?'""':typeof e))}(e)}static validateMatchPathArgs(e){!function(e){if(!f(e))throw new TypeError("[real-router] matchPath: path must be a string, got "+typeof e)}(e)}static validateShouldUpdateNodeArgs(e){!function(e){if(!f(e))throw new TypeError("[router.shouldUpdateNode] nodeName must be a string, got "+typeof e)}(e)}static validateRoutes(e,t,r,i){!function(e,t,r,i){if(i&&t){let e=t;for(const t of i.split("."))if(e=e.children.get(t),!e)throw new Error(`[router.addRoute] Parent route "${i}" does not exist`)}const n=new Set,a=new Map;for(const r of e)st(r,"addRoute",t,i??"",n,a);t&&r&&Tt(e,r,t)}(e,t,r,i)}setDependencies(e){this.#X=e;for(const[t,r]of this.#H)e.addActivateGuard(t,r);this.#H.clear();for(const[t,r]of this.#Q)e.addDeactivateGuard(t,r);this.#Q.clear()}setLifecycleNamespace(e){this.#ee=e}getRootPath(){return this.#K}getTree(){return this.#J}getForwardRecord(){return this.#z.forwardMap}setRootPath(e){this.#K=e,this.#ae()}hasRoute(e){return this.#Y.hasRoute(e)}getRoute(e){const t=this.#Y.getSegmentsByName(e);if(!t)return;const r=Xe(this.#se(t));return this.#oe(r,e)}addRoutes(e,t){if(t){const r=this.#ce(this.#q,t);r.children??=[];for(const t of e)r.children.push(ct(t))}else for(const t of e)this.#q.push(ct(t));this.#re(e,t??""),this.#ae(),this.#de()}removeRoute(e){return!!dt(this.#q,e)&&(this.#ue(e),this.#ae(),this.#de(),!0)}updateRouteConfig(e,t){if(void 0!==t.forwardTo&&this.#le(e,t.forwardTo),void 0!==t.defaultParams&&(null===t.defaultParams?delete this.#z.defaultParams[e]:this.#z.defaultParams[e]=t.defaultParams),void 0!==t.decodeParams)if(null===t.decodeParams)delete this.#z.decoders[e];else{const r=t.decodeParams;this.#z.decoders[e]=e=>r(e)??e}if(void 0!==t.encodeParams)if(null===t.encodeParams)delete this.#z.encoders[e];else{const r=t.encodeParams;this.#z.encoders[e]=e=>r(e)??e}}clearRoutes(){this.#q.length=0;for(const e in this.#z.decoders)delete this.#z.decoders[e];for(const e in this.#z.encoders)delete this.#z.encoders[e];for(const e in this.#z.defaultParams)delete this.#z.defaultParams[e];for(const e in this.#z.forwardMap)delete this.#z.forwardMap[e];for(const e in this.#z.forwardFnMap)delete this.#z.forwardFnMap[e];for(const e in this.#W)delete this.#W[e];this.#ae()}buildPath(e,t,r){if(e===T.UNKNOWN_ROUTE)return f(t?.path)?t.path:"";const i=Object.hasOwn(this.#z.defaultParams,e)?{...this.#z.defaultParams[e],...t}:t??{},n="function"==typeof this.#z.encoders[e]?this.#z.encoders[e]({...i}):i,a=r?.trailingSlash;return this.#Y.buildPath(e,n,{trailingSlash:"never"===a||"always"===a?a:void 0,queryParamsMode:r?.queryParamsMode})}matchPath(e,t){const r=t,i=this.#Y.match(e);if(!i)return;const n=bt(i),{name:a,params:s,meta:o}=n,c="function"==typeof this.#z.decoders[a]?this.#z.decoders[a](s):s,{name:d,params:u}=this.#g.forwardState(a,c);let l=e;if(r.rewritePathOnMatch){const e="function"==typeof this.#z.encoders[d]?this.#z.encoders[d]({...u}):u,t=r.trailingSlash;l=this.#Y.buildPath(d,e,{trailingSlash:"never"===t||"always"===t?t:void 0,queryParamsMode:r.queryParamsMode})}return this.#g.makeState(d,u,l,{params:o,options:Dt})}forwardState(e,t){if(Object.hasOwn(this.#z.forwardFnMap,e)){const r=this.#he(e,t),i=this.#z.forwardFnMap[e],n=this.#fe(e,i,t);return{name:n,params:this.#he(n,r)}}const r=this.#W[e]??e;if(r!==e&&Object.hasOwn(this.#z.forwardFnMap,r)){const i=this.#he(e,t),n=this.#z.forwardFnMap[r],a=this.#fe(r,n,t);return{name:a,params:this.#he(a,i)}}if(r!==e){const i=this.#he(e,t);return{name:r,params:this.#he(r,i)}}return{name:e,params:this.#he(e,t)}}buildStateResolved(e,t){const r=this.#Y.getSegmentsByName(e);if(r)return bt({segments:r,params:t,meta:this.#Y.getMetaByName(e)},e)}buildStateWithSegmentsResolved(e,t){const r=this.#Y.getSegmentsByName(e);if(r)return{state:bt({segments:r,params:t,meta:this.#Y.getMetaByName(e)},e),segments:r}}isActiveRoute(e,t={},r=!1,i=!0){ot.has(e)||(g(e,"isActiveRoute"),ot.add(e));const n=this.#g.getState();if(!n)return!1;const a=n.name;if(a!==e&&!a.startsWith(`${e}.`)&&!e.startsWith(`${a}.`))return!1;const s=this.#z.defaultParams[e];if(r||a===e){const r=s?{...s,...t}:t;return this.#g.areStatesEqual({name:e,params:r,path:""},n,i)}const o=n.params;return!!function(e,t){for(const r in e)if(e[r]!==t[r])return!1;return!0}(t,o)&&(!s||function(e,t,r){for(const i in e)if(!(i in r)&&e[i]!==t[i])return!1;return!0}(s,o,t))}shouldUpdateNode(e){return(t,r)=>{if(!t||"object"!=typeof t||!("name"in t))throw new TypeError("[router.shouldUpdateNode] toState must be valid State object");if(t.meta?.options.reload)return!0;if(""===e&&!r)return!0;const{intersection:i,toActivate:n,toDeactivate:a}=Ot(t,r);return e===i||!!n.includes(e)||a.includes(e)}}getConfig(){return this.#z}getUrlParams(e){const t=this.#Y.getSegmentsByName(e);return t?this.#pe(t):[]}getResolvedForwardMap(){return this.#W}setResolvedForwardMap(e){Object.assign(this.#W,e)}applyClonedConfig(e,t){Object.assign(this.#z.decoders,e.decoders),Object.assign(this.#z.encoders,e.encoders),Object.assign(this.#z.defaultParams,e.defaultParams),Object.assign(this.#z.forwardMap,e.forwardMap),Object.assign(this.#z.forwardFnMap,e.forwardFnMap),this.setResolvedForwardMap({...t})}cloneRoutes(){return[...this.#J.children.values()].map(e=>Xe(e))}validateForwardToParamCompatibility(e,t){const r=this.#me(e),i=this.#me(t),n=this.#ge(r),a=this.#pe(i).filter(e=>!n.has(e));if(a.length>0)throw new Error(`[real-router] forwardTo target "${t}" requires params [${a.join(", ")}] that are not available in source route "${e}"`)}validateForwardToCycle(e,t){yt(e,{...this.#z.forwardMap,[e]:t})}validateRemoveRoute(t,r,i){if(r){const i=r===t,n=r.startsWith(`${t}.`);if(i||n)return e.logger.warn("router.removeRoute",`Cannot remove route "${t}" — it is currently active${i?"":` (current: "${r}")`}. Navigate away first.`),!1}return i&&e.logger.warn("router.removeRoute",`Route "${t}" removed while navigation is in progress. This may cause unexpected behavior.`),!0}validateClearRoutes(t){return!t||(e.logger.error("router.clearRoutes","Cannot clear routes while navigation is in progress. Wait for navigation to complete."),!1)}validateUpdateRoute(e,t){if(!this.hasRoute(e))throw new ReferenceError(`[real-router] updateRoute: route "${e}" does not exist`);if(null!=t&&"string"==typeof t){if(!this.hasRoute(t))throw new Error(`[real-router] updateRoute: forwardTo target "${t}" does not exist`);this.validateForwardToParamCompatibility(e,t),this.validateForwardToCycle(e,t)}}#le(e,t){null===t?(delete this.#z.forwardMap[e],delete this.#z.forwardFnMap[e]):"string"==typeof t?(delete this.#z.forwardFnMap[e],this.#z.forwardMap[e]=t):(delete this.#z.forwardMap[e],this.#z.forwardFnMap[e]=t),this.#de()}#he(e,t){return Object.hasOwn(this.#z.defaultParams,e)?{...this.#z.defaultParams[e],...t}:t}#fe(e,t,r){const i=new Set([e]);let n=t(this.#g.getDependency,r),a=0;if("string"!=typeof n)throw new TypeError("forwardTo callback must return a string, got "+typeof n);for(;a<100;){if(void 0===this.#Y.getSegmentsByName(n))throw new Error(`Route "${n}" does not exist`);if(i.has(n)){const e=[...i,n].join(" → ");throw new Error(`Circular forwardTo detected: ${e}`)}if(i.add(n),Object.hasOwn(this.#z.forwardFnMap,n)){n=(0,this.#z.forwardFnMap[n])(this.#g.getDependency,r),a++;continue}const e=this.#z.forwardMap[n];if(void 0===e)return n;n=e,a++}throw new Error("forwardTo exceeds maximum depth of 100")}#ae(){this.#J=Ze("",this.#K,this.#q),this.#Y=et(this.#Z),this.#Y.registerTree(this.#J)}#me(e){return this.#Y.getSegmentsByName(e)}#se(e){return e.at(-1)}#ge(e){const t=new Set;for(const r of e)for(const e of r.paramMeta.urlParams)t.add(e);return t}#pe(e){const t=[];for(const r of e)for(const e of r.paramMeta.urlParams)t.push(e);return t}#de(){this.#te?this.#ie():this.#ne()}#ne(){for(const e in this.#W)delete this.#W[e];for(const e of Object.keys(this.#z.forwardMap))this.#W[e]=yt(e,this.#z.forwardMap)}#ie(){for(const e in this.#W)delete this.#W[e];for(const e of Object.keys(this.#z.forwardMap)){let t=e;for(;this.#z.forwardMap[t];)t=this.#z.forwardMap[t];this.#W[e]=t}}#ue(e){const t=t=>t===e||t.startsWith(`${e}.`);ut(this.#z.decoders,t),ut(this.#z.encoders,t),ut(this.#z.defaultParams,t),ut(this.#z.forwardMap,t),ut(this.#z.forwardFnMap,t),ut(this.#z.forwardMap,e=>t(this.#z.forwardMap[e]));const[r,i]=this.#ee.getFactories();for(const e of Object.keys(i))t(e)&&this.#ee.clearCanActivate(e);for(const e of Object.keys(r))t(e)&&this.#ee.clearCanDeactivate(e)}#re(e,t=""){for(const r of e){const e=t?`${t}.${r.name}`:r.name;this.#ve(r,e),r.children&&this.#re(r.children,e)}}#ve(e,t){e.canActivate&&(this.#X?this.#X.addActivateGuard(t,e.canActivate):this.#H.set(t,e.canActivate)),e.canDeactivate&&(this.#X?this.#X.addDeactivateGuard(t,e.canDeactivate):this.#Q.set(t,e.canDeactivate)),e.forwardTo&&this.#we(e,t),e.decodeParams&&(this.#z.decoders[t]=t=>e.decodeParams?.(t)??t),e.encodeParams&&(this.#z.encoders[t]=t=>e.encodeParams?.(t)??t),e.defaultParams&&(this.#z.defaultParams[t]=e.defaultParams)}#ce(e,t,r=""){for(const i of e){const e=r?`${r}.${i.name}`:i.name;if(e===t)return i;if(i.children&&t.startsWith(`${e}.`))return this.#ce(i.children,t,e)}}#we(t,r){if(t.canActivate&&e.logger.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 t.forwardTo?t.forwardTo:"[dynamic]"}".`),t.canDeactivate&&e.logger.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 t.forwardTo?t.forwardTo:"[dynamic]"}".`),"function"==typeof t.forwardTo){const e="AsyncFunction"===t.forwardTo.constructor.name,i=t.forwardTo.toString().includes("__awaiter");if(e||i)throw new TypeError(`forwardTo callback cannot be async for route "${r}". Async functions break matchPath/buildPath.`)}"string"==typeof t.forwardTo?this.#z.forwardMap[r]=t.forwardTo:this.#z.forwardFnMap[r]=t.forwardTo}#oe(e,t){const r={name:e.name,path:e.path},i=this.#z.forwardFnMap[t],n=this.#z.forwardMap[t];void 0!==i?r.forwardTo=i:void 0!==n&&(r.forwardTo=n),t in this.#z.defaultParams&&(r.defaultParams=this.#z.defaultParams[t]),t in this.#z.decoders&&(r.decodeParams=this.#z.decoders[t]),t in this.#z.encoders&&(r.encodeParams=this.#z.encoders[t]);const[a,s]=this.#ee.getFactories();return t in s&&(r.canActivate=s[t]),t in a&&(r.canDeactivate=a[t]),e.children&&(r.children=e.children.map(e=>this.#oe(e,`${t}.${e.name}`))),r}},Ct=new Set(["code","segment","path","redirect"]),jt=new Set(Object.values(y)),Ft=new Set(["code","segment","path","redirect"]),Mt=new Set(["setCode","setErrorInstance","setAdditionalFields","hasField","getField","toJSON"]),xt=class extends Error{segment;path;redirect;code;constructor(e,{message:t,segment:r,path:i,redirect:n,...a}={}){super(t??e),this.code=e,this.segment=r,this.path=i,this.redirect=n?function(e){if(!e)return e;if(null===(t=e)||"object"!=typeof t||"string"!=typeof t.name||"string"!=typeof t.path||"object"!=typeof t.params||null===t.params)throw new TypeError("[deepFreezeState] Expected valid State object, got: "+typeof e);var t;const r=structuredClone(e),i=new WeakSet;return function e(t){if(null===t||"object"!=typeof t)return;if(i.has(t))return;i.add(t),Object.freeze(t);const r=Array.isArray(t)?t:Object.values(t);for(const t of r)e(t)}(r),r}(n):void 0;for(const[e,t]of Object.entries(a)){if(Ft.has(e))throw new TypeError(`[RouterError] Cannot set reserved property "${e}"`);Mt.has(e)||(this[e]=t)}}setCode(e){this.code=e,jt.has(this.message)&&(this.message=e)}setErrorInstance(e){if(!e)throw new TypeError("[RouterError.setErrorInstance] err parameter is required and must be an Error instance");this.message=e.message,this.cause=e.cause,this.stack=e.stack??""}setAdditionalFields(e){for(const[t,r]of Object.entries(e)){if(Ft.has(t))throw new TypeError(`[RouterError.setAdditionalFields] Cannot set reserved property "${t}"`);Mt.has(t)||(this[t]=r)}}hasField(e){return e in this}getField(e){return this[e]}toJSON(){const e={code:this.code,message:this.message};void 0!==this.segment&&(e.segment=this.segment),void 0!==this.path&&(e.path=this.path),void 0!==this.redirect&&(e.redirect=this.redirect);const t=new Set(["code","message","segment","path","redirect","stack"]);for(const r in this)Object.hasOwn(this,r)&&!t.has(r)&&(e[r]=this[r]);return e}};function It(e,t,r){if(e instanceof xt)throw e.setCode(t),e;throw new xt(t,function(e,t){const r=t?{segment:t}:{};if(e instanceof Error)return{...r,message:e.message,stack:e.stack,..."cause"in e&&void 0!==e.cause&&{cause:e.cause}};if(e&&"object"==typeof e){const t={};for(const[r,i]of Object.entries(e))Ct.has(r)||(t[r]=i);return{...r,...t}}return r}(e,r))}var Lt=async(e,t,r,i,n,a)=>{const s=i.filter(t=>e.has(t));if(0!==s.length)for(const i of s){if(a())throw new xt(y.TRANSITION_CANCELLED);const s=e.get(i);let o;try{o=await s(t,r)}catch(e){It(e,n,i)}if(!o)throw new xt(n,{segment:i})}},kt=(e,t)=>{const r=e.meta,i=t.meta,n=r?.params,a=i?.params,s=n&&a?{...n,...a}:n??a??{},o={id:1,options:{},...i,...r,params:s};return{...e,meta:o}},Ut=async(e,t)=>{if(void 0===e)return t;if("boolean"==typeof e){if(e)return t;throw new xt(y.TRANSITION_ERR,{})}if(h(e))return e;try{const r=await e;return await Ut(r,t)}catch(e){throw new xt(y.TRANSITION_ERR,function(e,t){return e instanceof Error?{...t,message:e.message,stack:e.stack,..."cause"in e&&void 0!==e.cause&&{cause:e.cause}}:e&&"object"==typeof e?{...t,...e}:t}(e,{}))}};var _t=class t{#ye;#g;#Te;static validateNavigateArgs(e){!function(e){if("string"!=typeof e)throw new TypeError(`[router.navigate] Invalid route name: expected string, got ${v(e)}`)}(e)}static validateNavigateToStateArgs(e,t,r){!function(e,t,r){if(!e||"object"!=typeof e||"string"!=typeof e.name||"string"!=typeof e.path)throw new TypeError("[router.navigateToState] Invalid toState: expected State object with name and path");if(void 0!==t&&(!t||"object"!=typeof t||"string"!=typeof t.name))throw new TypeError("[router.navigateToState] Invalid fromState: expected State object or undefined");if("object"!=typeof r||null===r)throw new TypeError(`[router.navigateToState] Invalid opts: expected NavigationOptions object, got ${v(r)}`)}(e,t,r)}static validateNavigateToDefaultArgs(e){!function(e){if(void 0!==e&&("object"!=typeof e||null===e))throw new TypeError(`[router.navigateToDefault] Invalid options: ${v(e)}. Expected NavigationOptions object.`)}(e)}static validateNavigationOptions(e,t){!function(e,t){if(!function(e){if("object"!=typeof e||null===e||Array.isArray(e))return!1;const t=e;for(const e of a){const r=t[e];if(void 0!==r&&"boolean"!=typeof r)return!1}return!0}(e))throw new TypeError(`[router.${t}] Invalid options: ${v(e)}. Expected NavigationOptions object.`)}(e,t)}setCanNavigate(e){this.#ye=e}setDependencies(e){this.#g=e}setTransitionDependencies(e){this.#Te=e}async navigate(e,t,r){if(!this.#ye())throw new xt(y.ROUTER_NOT_STARTED);const i=this.#g,n=i.buildStateWithSegments(e,t);if(!n){const e=new xt(y.ROUTE_NOT_FOUND);throw i.emitTransitionError(void 0,i.getState(),e),e}const{state:a}=n,s=i.makeState(a.name,a.params,i.buildPath(a.name,a.params),{params:a.meta,options:r}),o=i.getState();if(!r.reload&&!r.force&&i.areStatesEqual(o,s,!1)){const e=new xt(y.SAME_STATES);throw i.emitTransitionError(s,o,e),e}return this.navigateToState(s,o,r)}async navigateToState(r,i,n){const a=this.#g,s=this.#Te;s.isTransitioning()&&(e.logger.warn("router.navigate","Concurrent navigation detected on shared router instance. For SSR, use router.clone() to create isolated instance per request."),a.cancelNavigation()),a.startTransition(r,i);try{const{state:o,meta:c}=await async function(t,r,i,n){const[a,s]=t.getLifecycleFunctions(),o=t.getMiddlewareFunctions(),c=r.name===T.UNKNOWN_ROUTE,d=()=>!t.isActive(),{toDeactivate:u,toActivate:l,intersection:f}=Ot(r,i),p=!c&&l.length>0,m=o.length>0;let g=r;if(i&&!n.forceDeactivate&&u.length>0&&await Lt(a,r,i,u,y.CANNOT_DEACTIVATE,d),d())throw new xt(y.TRANSITION_CANCELLED);if(p&&await Lt(s,r,i,l,y.CANNOT_ACTIVATE,d),d())throw new xt(y.TRANSITION_CANCELLED);if(m&&(g=await(async(t,r,i,n)=>{let a=r;for(const r of t){if(n())throw new xt(y.TRANSITION_CANCELLED);try{const t=r(a,i),n=await Ut(t,a);n!==a&&h(n)&&((n.name!==a.name||n.params!==a.params||n.path!==a.path)&&e.logger.error("core:middleware","Warning: State mutated during middleware execution",{from:a,to:n}),a=kt(n,a))}catch(e){It(e,y.TRANSITION_ERR)}}return a})(o,g,i,d)),d())throw new xt(y.TRANSITION_CANCELLED);if(i){const e=$t(r.name),n=$t(i.name);for(const r of n)!e.includes(r)&&a.has(r)&&t.clearCanDeactivate(r)}return{state:g,meta:{phase:"middleware",segments:{deactivated:u,activated:l,intersection:f}}}}(s,r,i,n);if(o.name===T.UNKNOWN_ROUTE||a.hasRoute(o.name)){const e=t.#be(o,c,i);return a.setState(e),a.sendTransitionDone(e,i,n),e}{const e=new xt(y.ROUTE_NOT_FOUND,{routeName:o.name});throw a.sendTransitionError(o,i,e),e}}catch(e){throw this.#Se(e,r,i),e}}async navigateToDefault(e){const t=this.#g,r=t.getOptions();if(!r.defaultRoute)throw new xt(y.ROUTE_NOT_FOUND,{routeName:"defaultRoute not configured"});const i=ee(r.defaultRoute,t.getDependency);if(!i)throw new xt(y.ROUTE_NOT_FOUND,{routeName:"defaultRoute resolved to empty"});const n=ee(r.defaultParams,t.getDependency);return this.navigate(i,n,e)}static#be(e,t,r){const i={phase:t.phase,...void 0!==r?.name&&{from:r.name},reason:"success",segments:t.segments};return Object.freeze(i.segments.deactivated),Object.freeze(i.segments.activated),Object.freeze(i.segments),Object.freeze(i),{...e,transition:i}}#Se(e,t,r){const i=e;i.code!==y.TRANSITION_CANCELLED&&i.code!==y.ROUTE_NOT_FOUND&&(i.code===y.CANNOT_ACTIVATE||i.code===y.CANNOT_DEACTIVATE?this.#g.sendTransitionBlocked(t,r,i):this.#g.sendTransitionError(t,r,i))}},Bt=class{#Re;#g;static validateStartArgs(e){if(1!==e.length||"string"!=typeof e[0])throw new Error("[router.start] Expected exactly 1 string argument (startPath).")}setNavigateToState(e){this.#Re=e}setDependencies(e){this.#g=e}async start(e){const t=this.#g,r=t.getOptions(),i={replace:!0},n=t.matchPath(e);if(!n&&!r.allowNotFound){const r=new xt(y.ROUTE_NOT_FOUND,{path:e});throw t.emitTransitionError(void 0,void 0,r),r}let a;if(t.completeStart(),n)a=await this.#Re(n,void 0,i);else{const r=t.makeNotFoundState(e,i);a=await this.#Re(r,void 0,i)}return a}stop(){this.#g.setState()}},Vt=class{#Ae;static validateCloneArgs(e){if(void 0!==e){if(!e||"object"!=typeof e||e.constructor!==Object)throw new TypeError(`[router.clone] Invalid dependencies: expected plain object or undefined, received ${v(e)}`);for(const t in e)if(Object.getOwnPropertyDescriptor(e,t)?.get)throw new TypeError(`[router.clone] Getters not allowed in dependencies: "${t}"`)}}setGetCloneData(e){this.#Ae=e}clone(e,t,r){const i=this.#Ae(),n={...i.dependencies,...e},a=t(i.routes,i.options,n);for(const[e,t]of Object.entries(i.canDeactivateFactories))a.addDeactivateGuard(e,t);for(const[e,t]of Object.entries(i.canActivateFactories))a.addActivateGuard(e,t);return i.middlewareFactories.length>0&&a.useMiddleware(...i.middlewareFactories),i.pluginFactories.length>0&&a.usePlugin(...i.pluginFactories),r(a,i.routeConfig,i.resolvedForwardMap),a}},Gt=class e{#Ee;#Pe;#$e;constructor(e){this.#Ee=e.routerFSM,this.#Pe=e.emitter,this.#$e=void 0,this.#Oe()}static validateEventName(e){if(!O.has(e))throw new Error(`Invalid event name: ${String(e)}`)}static validateListenerArgs(t,r){if(e.validateEventName(t),"function"!=typeof r)throw new TypeError(`Expected callback to be a function for event ${t}`)}static validateSubscribeListener(e){if("function"!=typeof e)throw new TypeError("[router.subscribe] Expected a function. For Observable pattern use @real-router/rx package")}emitRouterStart(){this.#Pe.emit($.ROUTER_START)}emitRouterStop(){this.#Pe.emit($.ROUTER_STOP)}emitTransitionStart(e,t){this.#Pe.emit($.TRANSITION_START,e,t)}emitTransitionSuccess(e,t,r){this.#Pe.emit($.TRANSITION_SUCCESS,e,t,r)}emitTransitionError(e,t,r){this.#Pe.emit($.TRANSITION_ERROR,e,t,r)}emitTransitionCancel(e,t){this.#Pe.emit($.TRANSITION_CANCEL,e,t)}sendStart(){this.#Ee.send(I)}sendStop(){this.#Ee.send(V)}sendDispose(){this.#Ee.send(G)}completeStart(){this.#Ee.send(L)}beginTransition(e,t){this.#$e=e,this.#Ee.send(k,{toState:e,fromState:t})}completeTransition(e,t,r={}){this.#Ee.send(U,{state:e,fromState:t,opts:r}),this.#$e=void 0}failTransition(e,t,r){this.#Ee.send(_,{toState:e,fromState:t,error:r}),this.#$e=void 0}cancelTransition(e,t){this.#Ee.send(B,{toState:e,fromState:t}),this.#$e=void 0}emitOrFailTransitionError(e,t,r){this.#Ee.getState()===F?this.#Ee.send(_,{toState:e,fromState:t,error:r}):this.emitTransitionError(e,t,r)}canBeginTransition(){return this.#Ee.canSend(k)}canStart(){return this.#Ee.canSend(I)}canCancel(){return this.#Ee.canSend(B)}isActive(){const e=this.#Ee.getState();return e!==C&&e!==x}isDisposed(){return this.#Ee.getState()===x}isTransitioning(){return this.#Ee.getState()===M}isReady(){return this.#Ee.getState()===F}getCurrentToState(){return this.#$e}addEventListener(e,t){return this.#Pe.on(e,t)}subscribe(e){return this.#Pe.on($.TRANSITION_SUCCESS,(t,r)=>{e({route:t,previousRoute:r})})}clearAll(){this.#Pe.clearAll()}setLimits(e){this.#Pe.setLimits(e)}cancelTransitionIfRunning(e){this.canCancel()&&this.cancelTransition(this.#$e,e)}#Oe(){const e=this.#Ee;e.on(j,L,()=>{this.emitRouterStart()}),e.on(F,V,()=>{this.emitRouterStop()}),e.on(F,k,e=>{this.emitTransitionStart(e.toState,e.fromState)}),e.on(M,U,e=>{this.emitTransitionSuccess(e.state,e.fromState,e.opts)}),e.on(M,B,e=>{this.emitTransitionCancel(e.toState,e.fromState)}),e.on(j,_,e=>{this.emitTransitionError(e.toState,e.fromState,e.error)}),e.on(F,_,e=>{this.emitTransitionError(e.toState,e.fromState,e.error)}),e.on(M,_,e=>{this.emitTransitionError(e.toState,e.fromState,e.error)})}},qt=new xt(y.ROUTER_ALREADY_STARTED),zt=new Set(["all","warn-error","error-only"]);var Wt=class{router;options;limits;dependencies;state;routes;routeLifecycle;middleware;plugins;navigation;lifecycle;clone;eventBus;constructor(e){this.router=e.router,this.options=e.options,this.limits=e.limits,this.dependencies=e.dependencies,this.state=e.state,this.routes=e.routes,this.routeLifecycle=e.routeLifecycle,this.middleware=e.middleware,this.plugins=e.plugins,this.navigation=e.navigation,this.lifecycle=e.lifecycle,this.clone=e.clone,this.eventBus=e.eventBus}wireLimits(){this.dependencies.setLimits(this.limits),this.plugins.setLimits(this.limits),this.middleware.setLimits(this.limits),this.eventBus.setLimits({maxListeners:this.limits.maxListeners,warnListeners:this.limits.warnListeners,maxEventDepth:this.limits.maxEventDepth}),this.routeLifecycle.setLimits(this.limits)}wireRouteLifecycleDeps(){this.routeLifecycle.setRouter(this.router),this.routeLifecycle.setDependencies({getDependency:e=>this.dependencies.get(e)})}wireRoutesDeps(){this.routes.setDependencies({addActivateGuard:(e,t)=>{this.router.addActivateGuard(e,t)},addDeactivateGuard:(e,t)=>{this.router.addDeactivateGuard(e,t)},makeState:(e,t,r,i)=>this.state.makeState(e,t,r,i),getState:()=>this.state.get(),areStatesEqual:(e,t,r)=>this.state.areStatesEqual(e,t,r),getDependency:e=>this.dependencies.get(e),forwardState:(e,t)=>this.router.forwardState(e,t)}),this.routes.setLifecycleNamespace(this.routeLifecycle)}wireMiddlewareDeps(){this.middleware.setRouter(this.router),this.middleware.setDependencies({getDependency:e=>this.dependencies.get(e)})}wirePluginsDeps(){this.plugins.setRouter(this.router),this.plugins.setDependencies({addEventListener:(e,t)=>this.eventBus.addEventListener(e,t),canNavigate:()=>this.eventBus.canBeginTransition(),getDependency:e=>this.dependencies.get(e)})}wireNavigationDeps(){this.navigation.setDependencies({getOptions:()=>this.options.get(),hasRoute:e=>this.routes.hasRoute(e),getState:()=>this.state.get(),setState:e=>{this.state.set(e)},buildStateWithSegments:(e,t)=>{const{name:r,params:i}=this.router.forwardState(e,t);return this.routes.buildStateWithSegmentsResolved(r,i)},makeState:(e,t,r,i)=>this.state.makeState(e,t,r,i),buildPath:(e,t)=>this.routes.buildPath(e,t,this.options.get()),areStatesEqual:(e,t,r)=>this.state.areStatesEqual(e,t,r),getDependency:e=>this.dependencies.get(e),startTransition:(e,t)=>{this.eventBus.beginTransition(e,t)},cancelNavigation:()=>{this.eventBus.cancelTransition(this.eventBus.getCurrentToState(),this.state.get())},sendTransitionDone:(e,t,r)=>{this.eventBus.completeTransition(e,t,r)},sendTransitionBlocked:(e,t,r)=>{this.eventBus.failTransition(e,t,r)},sendTransitionError:(e,t,r)=>{this.eventBus.failTransition(e,t,r)},emitTransitionError:(e,t,r)=>{this.eventBus.emitOrFailTransitionError(e,t,r)}}),this.navigation.setTransitionDependencies({getLifecycleFunctions:()=>this.routeLifecycle.getFunctions(),getMiddlewareFunctions:()=>this.middleware.getFunctions(),isActive:()=>this.router.isActive(),isTransitioning:()=>this.eventBus.isTransitioning(),clearCanDeactivate:e=>{this.routeLifecycle.clearCanDeactivate(e)}})}wireLifecycleDeps(){this.lifecycle.setDependencies({getOptions:()=>this.options.get(),makeNotFoundState:(e,t)=>this.state.makeNotFoundState(e,t),setState:e=>{this.state.set(e)},matchPath:e=>this.routes.matchPath(e,this.options.get()),completeStart:()=>{this.eventBus.completeStart()},emitTransitionError:(e,t,r)=>{this.eventBus.failTransition(e,t,r)}})}wireStateDeps(){this.state.setDependencies({getDefaultParams:()=>this.routes.getConfig().defaultParams,buildPath:(e,t)=>this.routes.buildPath(e,t,this.options.get()),getUrlParams:e=>this.routes.getUrlParams(e)})}wireCloneCallbacks(){this.clone.setGetCloneData(()=>{const[e,t]=this.routeLifecycle.getFactories();return{routes:this.routes.cloneRoutes(),options:{...this.options.get()},dependencies:this.dependencies.getAll(),canDeactivateFactories:e,canActivateFactories:t,middlewareFactories:this.middleware.getFactories(),pluginFactories:this.plugins.getAll(),routeConfig:this.routes.getConfig(),resolvedForwardMap:this.routes.getResolvedForwardMap()}})}wireCyclicDeps(){this.navigation.setCanNavigate(()=>this.eventBus.canBeginTransition()),this.lifecycle.setNavigateToState((e,t,r)=>this.navigation.navigateToState(e,t,r))}},Ht=class r{#h;#u;#d;#De;#Ne;#Ce;#je;#R;#Fe;#Me;#xe;#Ie;#te;constructor(r=[],i={},a={}){i.logger&&function(e){if("object"!=typeof e||null===e)throw new TypeError("Logger config must be an object");const t=e;for(const e of Object.keys(t))if("level"!==e&&"callback"!==e)throw new TypeError(`Unknown logger config property: "${e}"`);if("level"in t&&void 0!==t.level&&("string"!=typeof(r=t.level)||!zt.has(r)))throw new TypeError(`Invalid logger level: ${function(e){return"string"==typeof e?`"${e}"`:"object"==typeof e?JSON.stringify(e):String(e)}(t.level)}. Expected: "all" | "warn-error" | "error-only"`);var r;if("callback"in t&&void 0!==t.callback&&"function"!=typeof t.callback)throw new TypeError("Logger callback must be a function, got "+typeof t.callback);return!0}(i.logger)&&(e.logger.configure(i.logger),delete i.logger),ne.validateOptions(i,"constructor");const s=i.noValidate??!1;s||K.validateDependenciesObject(a,"constructor"),!s&&r.length>0&&(Nt.validateAddRouteArgs(r),Nt.validateRoutes(r)),this.#h=new ne(i),this.#u=function(e={}){return{...D,...e}}(i.limits),this.#d=new K(a),this.#De=new se,this.#Ne=new Nt(r,s,function(e){return{strictTrailingSlash:"strict"===e.trailingSlash,strictQueryParams:"strict"===e.queryParamsMode,urlParamsEncoding:e.urlParamsEncoding,queryParams:e.queryParams}}(this.#h.get())),this.#Ce=new ge,this.#je=new de,this.#R=new fe,this.#Fe=new _t,this.#Me=new Bt,this.#xe=new Vt,this.#te=s;const o=new t.FSM(q),c=new n({onListenerError:(t,r)=>{e.logger.error("Router",`Error in listener for ${t}:`,r)},onListenerWarn:(t,r)=>{e.logger.warn("router.addEventListener",`Event "${t}" has ${r} listeners — possible memory leak`)}});var d;this.#Ie=new Gt({routerFSM:o,emitter:c}),(d=new Wt({router:this,options:this.#h,limits:this.#u,dependencies:this.#d,state:this.#De,routes:this.#Ne,routeLifecycle:this.#Ce,middleware:this.#je,plugins:this.#R,navigation:this.#Fe,lifecycle:this.#Me,clone:this.#xe,eventBus:this.#Ie})).wireLimits(),d.wireRouteLifecycleDeps(),d.wireRoutesDeps(),d.wireMiddlewareDeps(),d.wirePluginsDeps(),d.wireNavigationDeps(),d.wireLifecycleDeps(),d.wireStateDeps(),d.wireCloneCallbacks(),d.wireCyclicDeps(),this.addRoute=this.addRoute.bind(this),this.removeRoute=this.removeRoute.bind(this),this.clearRoutes=this.clearRoutes.bind(this),this.getRoute=this.getRoute.bind(this),this.hasRoute=this.hasRoute.bind(this),this.updateRoute=this.updateRoute.bind(this),this.isActiveRoute=this.isActiveRoute.bind(this),this.buildPath=this.buildPath.bind(this),this.matchPath=this.matchPath.bind(this),this.setRootPath=this.setRootPath.bind(this),this.getRootPath=this.getRootPath.bind(this),this.makeState=this.makeState.bind(this),this.getState=this.getState.bind(this),this.getPreviousState=this.getPreviousState.bind(this),this.areStatesEqual=this.areStatesEqual.bind(this),this.forwardState=this.forwardState.bind(this),this.buildState=this.buildState.bind(this),this.buildNavigationState=this.buildNavigationState.bind(this),this.shouldUpdateNode=this.shouldUpdateNode.bind(this),this.getOptions=this.getOptions.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.addActivateGuard=this.addActivateGuard.bind(this),this.addDeactivateGuard=this.addDeactivateGuard.bind(this),this.removeActivateGuard=this.removeActivateGuard.bind(this),this.removeDeactivateGuard=this.removeDeactivateGuard.bind(this),this.canNavigateTo=this.canNavigateTo.bind(this),this.usePlugin=this.usePlugin.bind(this),this.useMiddleware=this.useMiddleware.bind(this),this.setDependency=this.setDependency.bind(this),this.setDependencies=this.setDependencies.bind(this),this.getDependency=this.getDependency.bind(this),this.getDependencies=this.getDependencies.bind(this),this.removeDependency=this.removeDependency.bind(this),this.hasDependency=this.hasDependency.bind(this),this.resetDependencies=this.resetDependencies.bind(this),this.addEventListener=this.addEventListener.bind(this),this.navigate=this.navigate.bind(this),this.navigateToDefault=this.navigateToDefault.bind(this),this.navigateToState=this.navigateToState.bind(this),this.subscribe=this.subscribe.bind(this),this.clone=this.clone.bind(this)}addRoute(e,t){const r=Array.isArray(e)?e:[e],i=t?.parent;return this.#te||(void 0!==i&&Nt.validateParentOption(i),Nt.validateAddRouteArgs(r),Nt.validateRoutes(r,this.#Ne.getTree(),this.#Ne.getForwardRecord(),i)),this.#Ne.addRoutes(r,i),this}removeRoute(t){return this.#te||Nt.validateRemoveRouteArgs(t),this.#Ne.validateRemoveRoute(t,this.#De.get()?.name,this.#Ie.isTransitioning())?(this.#Ne.removeRoute(t)||e.logger.warn("router.removeRoute",`Route "${t}" not found. No changes made.`),this):this}clearRoutes(){const e=this.#Ie.isTransitioning();return this.#Ne.validateClearRoutes(e)?(this.#Ne.clearRoutes(),this.#Ce.clearAll(),this.#De.set(void 0),this):this}getRoute(e){return this.#te||g(e,"getRoute"),this.#Ne.getRoute(e)}hasRoute(e){return this.#te||g(e,"hasRoute"),this.#Ne.hasRoute(e)}updateRoute(t,r){this.#te||Nt.validateUpdateRouteBasicArgs(t,r);const{forwardTo:i,defaultParams:n,decodeParams:a,encodeParams:s,canActivate:o,canDeactivate:c}=r;return this.#te||Nt.validateUpdateRoutePropertyTypes(i,n,a,s),this.#Ie.isTransitioning()&&e.logger.error("router.updateRoute",`Updating route "${t}" while navigation is in progress. This may cause unexpected behavior.`),this.#te||this.#Ne.validateUpdateRoute(t,i),this.#Ne.updateRouteConfig(t,{forwardTo:i,defaultParams:n,decodeParams:a,encodeParams:s}),void 0!==o&&(null===o?this.#Ce.clearCanActivate(t):this.addActivateGuard(t,o)),void 0!==c&&(null===c?this.#Ce.clearCanDeactivate(t):this.addDeactivateGuard(t,c)),this}isActiveRoute(t,r,i,n){return this.#te||Nt.validateIsActiveRouteArgs(t,r,i,n),""===t?(e.logger.warn("real-router",'isActiveRoute("") called with empty string. Root node is not considered a parent of any route.'),!1):this.#Ne.isActiveRoute(t,r,i,n)}buildPath(e,t){return this.#te||Nt.validateBuildPathArgs(e),this.#Ne.buildPath(e,t,this.#h.get())}matchPath(e){return this.#te||Nt.validateMatchPathArgs(e),this.#Ne.matchPath(e,this.#h.get())}setRootPath(e){this.#te||Nt.validateSetRootPathArgs(e),this.#Ne.setRootPath(e)}getRootPath(){return this.#Ne.getRootPath()}makeState(e,t,r,i,n){return this.#te||se.validateMakeStateArgs(e,t,r,n),this.#De.makeState(e,t,r,i,n)}getState(){return this.#De.get()}getPreviousState(){return this.#De.getPrevious()}areStatesEqual(e,t,r=!0){return this.#te||se.validateAreStatesEqualArgs(e,t,r),this.#De.areStatesEqual(e,t,r)}forwardState(e,t){return this.#te||Nt.validateStateBuilderArgs(e,t,"forwardState"),this.#Ne.forwardState(e,t)}buildState(e,t){this.#te||Nt.validateStateBuilderArgs(e,t,"buildState");const{name:r,params:i}=this.forwardState(e,t);return this.#Ne.buildStateResolved(r,i)}buildNavigationState(e,t={}){this.#te||Nt.validateStateBuilderArgs(e,t,"buildNavigationState");const r=this.buildState(e,t);if(r)return this.makeState(r.name,r.params,this.buildPath(r.name,r.params),{params:r.meta,options:{}})}shouldUpdateNode(e){return this.#te||Nt.validateShouldUpdateNodeArgs(e),this.#Ne.shouldUpdateNode(e)}getOptions(){return this.#h.get()}isActive(){return this.#Ie.isActive()}async start(e){if(this.#te||Bt.validateStartArgs([e]),!this.#Ie.canStart())throw qt;this.#Ie.sendStart();try{return await this.#Me.start(e)}catch(e){throw this.#Ie.isReady()&&(this.#Me.stop(),this.#Ie.sendStop()),e}}stop(){return this.#Ie.cancelTransitionIfRunning(this.#De.get()),this.#Ie.isReady()||this.#Ie.isTransitioning()?(this.#Me.stop(),this.#Ie.sendStop(),this):this}dispose(){this.#Ie.isDisposed()||(this.#Ie.cancelTransitionIfRunning(this.#De.get()),(this.#Ie.isReady()||this.#Ie.isTransitioning())&&(this.#Me.stop(),this.#Ie.sendStop()),this.#Ie.sendDispose(),this.#Ie.clearAll(),this.#R.disposeAll(),this.#je.clearAll(),this.#Ne.clearRoutes(),this.#Ce.clearAll(),this.#De.reset(),this.#d.reset(),this.#Le())}addDeactivateGuard(e,t){return this.#te||(g(e,"addDeactivateGuard"),ge.validateHandler(t,"addDeactivateGuard")),this.#Ce.addCanDeactivate(e,t,this.#te),this}addActivateGuard(e,t){return this.#te||(g(e,"addActivateGuard"),ge.validateHandler(t,"addActivateGuard")),this.#Ce.addCanActivate(e,t,this.#te),this}removeActivateGuard(e){this.#te||g(e,"removeActivateGuard"),this.#Ce.clearCanActivate(e)}removeDeactivateGuard(e){this.#te||g(e,"removeDeactivateGuard"),this.#Ce.clearCanDeactivate(e)}canNavigateTo(e,t){if(this.#te||g(e,"canNavigateTo"),!this.hasRoute(e))return!1;const{name:r,params:i}=this.forwardState(e,t??{}),n=this.makeState(r,i),a=this.getState(),{toDeactivate:s,toActivate:o}=Ot(n,a);for(const e of s)if(!this.#Ce.checkDeactivateGuardSync(e,n,a))return!1;for(const e of o)if(!this.#Ce.checkActivateGuardSync(e,n,a))return!1;return!0}usePlugin(...e){return this.#te||(fe.validateUsePluginArgs(e),fe.validatePluginLimit(this.#R.count(),e.length,this.#u.maxPlugins),fe.validateNoDuplicatePlugins(e,this.#R.has.bind(this.#R))),this.#R.use(...e)}useMiddleware(...e){this.#te||(de.validateUseMiddlewareArgs(e),de.validateNoDuplicates(e,this.#je.has.bind(this.#je)),de.validateMiddlewareLimit(this.#je.count(),e.length,this.#u.maxMiddleware));const t=this.#je.initialize(...e);if(!this.#te)for(const{middleware:e,factory:r}of t)de.validateMiddleware(e,r);return this.#je.commit(t)}setDependency(e,t){return this.#te||K.validateSetDependencyArgs(e),this.#d.set(e,t),this}setDependencies(e){return this.#te||(K.validateDependenciesObject(e,"setDependencies"),K.validateDependencyLimit(this.#d.count(),Object.keys(e).length,"setDependencies",this.#u.maxDependencies)),this.#d.setMultiple(e),this}getDependency(e){this.#te||K.validateName(e,"getDependency");const t=this.#d.get(e);return this.#te||K.validateDependencyExists(t,e),t}getDependencies(){return this.#d.getAll()}removeDependency(e){return this.#te||K.validateName(e,"removeDependency"),this.#d.remove(e),this}hasDependency(e){return this.#te||K.validateName(e,"hasDependency"),this.#d.has(e)}resetDependencies(){return this.#d.reset(),this}addEventListener(e,t){return this.#te||Gt.validateListenerArgs(e,t),this.#Ie.addEventListener(e,t)}subscribe(e){return this.#te||Gt.validateSubscribeListener(e),this.#Ie.subscribe(e)}navigate(e,t,i){this.#te||_t.validateNavigateArgs(e);const n=i??{};this.#te||_t.validateNavigationOptions(n,"navigate");const a=this.#Fe.navigate(e,t??{},n);return r.#ke(a),a}navigateToDefault(e){this.#te||_t.validateNavigateToDefaultArgs(e);const t=e??{};this.#te||_t.validateNavigationOptions(t,"navigateToDefault");const i=this.#Fe.navigateToDefault(t);return r.#ke(i),i}navigateToState(e,t,r){return this.#te||_t.validateNavigateToStateArgs(e,t,r),this.#Fe.navigateToState(e,t,r)}clone(e){return this.#te||Vt.validateCloneArgs(e),this.#xe.clone(e,(e,t,i)=>new r(e,t,i),(e,t,r)=>{e.#Ne.applyClonedConfig(t,r)})}static#Ue=t=>{t instanceof xt&&(t.code===y.SAME_STATES||t.code===y.TRANSITION_CANCELLED||t.code===y.ROUTER_NOT_STARTED||t.code===y.ROUTE_NOT_FOUND)||e.logger.error("router.navigate","Unexpected navigation error",t)};static#ke(e){e.catch(r.#Ue)}#Le(){this.navigate=Qt,this.navigateToDefault=Qt,this.navigateToState=Qt,this.start=Qt,this.stop=Qt,this.addRoute=Qt,this.removeRoute=Qt,this.clearRoutes=Qt,this.updateRoute=Qt,this.addActivateGuard=Qt,this.addDeactivateGuard=Qt,this.removeActivateGuard=Qt,this.removeDeactivateGuard=Qt,this.usePlugin=Qt,this.useMiddleware=Qt,this.setDependency=Qt,this.setDependencies=Qt,this.removeDependency=Qt,this.resetDependencies=Qt,this.addEventListener=Qt,this.subscribe=Qt,this.setRootPath=Qt,this.clone=Qt,this.canNavigateTo=Qt}};function Qt(){throw new xt(y.ROUTER_DISPOSED)}exports.Router=Ht,exports.RouterError=xt,exports.constants=T,exports.createRouter=(e=[],t={},r={})=>new Ht(e,t,r),exports.errorCodes=y,exports.events=$,exports.getNavigator=e=>Object.freeze({navigate:e.navigate,getState:e.getState,isActiveRoute:e.isActiveRoute,canNavigateTo:e.canNavigateTo,subscribe:e.subscribe});//# sourceMappingURL=index.js.map
|
|
1
|
+
var t=require("@real-router/logger"),e=require("@real-router/fsm"),r={maxListeners:0,warnListeners:0,maxEventDepth:0},n=class extends Error{},i=class{#t=new Map;#e=null;#r=r;#n;#i;constructor(t){t?.limits&&(this.#r=t.limits),this.#n=t?.onListenerError??null,this.#i=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.#a(t);if(r.has(e))throw new Error(`Duplicate listener for "${t}"`);const{maxListeners:n,warnListeners:i}=this.#r;if(0!==i&&r.size===i&&this.#i?.(t,i),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.#o(r,t,e))}clearAll(){this.#t.clear(),this.#e=null}listenerCount(t){return this.#t.get(t)?.size??0}#o(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 i=this.#e,a=i.get(e)??0;if(a>=this.#r.maxEventDepth)throw new n(`Maximum recursion depth (${this.#r.maxEventDepth}) exceeded for event: ${e}`);try{i.set(e,a+1);const s=[...t];for(const t of s)try{this.#c(t,r)}catch(t){if(t instanceof n)throw t;this.#n?.(e,t)}}finally{i.set(e,i.get(e)-1)}}#a(t){const e=this.#t.get(t);if(e)return e;const r=new Set;return this.#t.set(t,r),r}},a=["replace","reload","force","forceDeactivate","redirected"],s=/\S/,o=/^[A-Z_a-z][\w-]*(?:\.[A-Z_a-z][\w-]*)*$/;function c(t,e){return new TypeError(`[router.${t}] ${e}`)}function u(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=>u(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=>u(t,e))}return!1}function d(t){if(null==t)return!0;const e=typeof t;return"string"===e||"boolean"===e||"number"===e&&Number.isFinite(t)}function l(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(!d(n)){const t=typeof n;if("function"===t||"symbol"===t)return!1;r=!0;break}}return!r||u(t)}function h(t){return"string"==typeof t}function f(t){return"boolean"==typeof t}function p(t,e){return t in e}function g(t,e){if("string"!=typeof t)throw c(e,"Route name must be a string, got "+typeof t);if(""!==t){if(!s.test(t))throw c(e,"Route name cannot contain only whitespace");if(t.length>1e4)throw c(e,"Route name exceeds maximum length of 10000 characters. This is a technical safety limit.");if(!t.startsWith("@@")&&!o.test(t))throw c(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 m(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 v(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("@@")||o.test(t)))}(t.name)&&"string"==typeof t.path&&l(t.params)}(t)}(t))throw new TypeError(`[${e}] Invalid state structure: ${m(t)}. Expected State object with name, params, and path properties.`)}var y=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"}),w={UNKNOWN_ROUTE:"@@router/UNKNOWN_ROUTE"},b="onStart",T="onStop",S="onTransitionStart",R="onTransitionCancel",A="onTransitionSuccess",E="onTransitionError",P={ROUTER_START:"$start",ROUTER_STOP:"$stop",TRANSITION_START:"$$start",TRANSITION_CANCEL:"$$cancel",TRANSITION_SUCCESS:"$$success",TRANSITION_ERROR:"$$error"},O=new Set([P.ROUTER_START,P.TRANSITION_START,P.TRANSITION_SUCCESS,P.TRANSITION_ERROR,P.TRANSITION_CANCEL,P.ROUTER_STOP]),$={maxDependencies:100,maxPlugins:50,maxListeners:1e4,warnListeners:1e3,maxEventDepth:5,maxLifecycleHandlers:200},D={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}},N="IDLE",C="STARTING",j="READY",F="TRANSITIONING",M="DISPOSED",x="START",I="STARTED",L="NAVIGATE",k="COMPLETE",U="FAIL",_="CANCEL",B="STOP",V="DISPOSE",G={initial:N,context:null,transitions:{[N]:{[x]:C,[V]:M},[C]:{[I]:j,[U]:N},[j]:{[L]:F,[U]:j,[B]:N},[F]:{[L]:F,[k]:j,[_]:j,[U]:j},[M]:{}}},q=new WeakSet;function z(t){if(null!==t&&"object"==typeof t&&!Object.isFrozen(t))if(Object.freeze(t),Array.isArray(t))for(const e of t)z(e);else for(const e in t)z(t[e])}function W(t){return t?(q.has(t)||(z(t),q.add(t)),t):t}function H(t){return{warn:Math.floor(.2*t),error:Math.floor(.5*t)}}var Q=class{#u=Object.create(null);#d=$;constructor(t={}){this.setMultiple(t)}static validateName(t,e){!function(t,e){if("string"!=typeof t)throw new TypeError(`[router.${e}]: dependency name must be a string, got ${typeof t}`)}(t,e)}static validateSetDependencyArgs(t){!function(t){if("string"!=typeof t)throw new TypeError("[router.setDependency]: dependency name must be a string, got "+typeof t)}(t)}static validateDependenciesObject(t,e){!function(t,e){if(!t||"object"!=typeof t||t.constructor!==Object)throw new TypeError(`[router.${e}] Invalid argument: expected plain object, received ${m(t)}`);for(const r in t)if(Object.getOwnPropertyDescriptor(t,r)?.get)throw new TypeError(`[router.${e}] Getters not allowed: "${r}"`)}(t,e)}static validateDependencyExists(t,e){!function(t,e){if(void 0===t)throw new ReferenceError(`[router.getDependency]: dependency "${e}" not found`)}(t,e)}static validateDependencyLimit(t,e,r,n){!function(t,e,r,n=$.maxDependencies){if(0===n)return;const i=t+e;if(i>=n)throw new Error(`[router.${r}] Dependency limit exceeded (${n}). Current: ${i}. This is likely a bug in your code.`)}(t,e,r,n)}setLimits(t){this.#d=t}set(e,r){if(void 0===r)return!1;if(Object.hasOwn(this.#u,e)){const n=this.#u[e],i=n!==r,a=Number.isNaN(n)&&Number.isNaN(r);i&&!a&&t.logger.warn("router.setDependency","Router dependency already exists and is being overwritten:",e)}else this.#l("setDependency");return this.#u[e]=r,!0}setMultiple(e){const r=[];for(const t in e)void 0!==e[t]&&(Object.hasOwn(this.#u,t)&&r.push(t),this.#u[t]=e[t]);r.length>0&&t.logger.warn("router.setDependencies","Overwritten:",r.join(", "))}get(t){return this.#u[t]}getAll(){return{...this.#u}}count(){return Object.keys(this.#u).length}remove(e){Object.hasOwn(this.#u,e)||t.logger.warn("router.removeDependency",`Attempted to remove non-existent dependency: "${m(e)}"`),delete this.#u[e]}has(t){return Object.hasOwn(this.#u,t)}reset(){this.#u=Object.create(null)}#l(e){const r=this.#d.maxDependencies;if(0===r)return;const n=Object.keys(this.#u).length,{warn:i,error:a}=H(r);if(n===i)t.logger.warn(`router.${e}`,`${i} dependencies registered. Consider if all are necessary.`);else if(n===a)t.logger.error(`router.${e}`,`${a} dependencies registered! This indicates architectural problems. Hard limit at ${r}.`);else if(n>=r)throw new Error(`[router.${e}] Dependency limit exceeded (${r}). Current: ${n}. This is likely a bug in your code. If you genuinely need more dependencies, your architecture needs refactoring.`)}},K={defaultRoute:"",defaultParams:{},trailingSlash:"preserve",queryParamsMode:"loose",queryParams:{arrayFormat:"none",booleanFormat:"none",nullFormat:"default"},urlParamsEncoding:"default",allowNotFound:!0,rewritePathOnMatch:!0,noValidate:!1},J={trailingSlash:["strict","never","always","preserve"],queryParamsMode:["default","strict","loose"],urlParamsEncoding:["default","uri","uriComponent","none"]},Y={arrayFormat:["none","brackets","index","comma"],booleanFormat:["none","string","empty-true"],nullFormat:["default","hidden"]};function Z(t){Object.freeze(t);for(const e of Object.keys(t)){const r=t[e];r&&"object"==typeof r&&r.constructor===Object&&Z(r)}return t}function X(t,e){return"function"==typeof t?t(e):t}function tt(t,e,r){if("function"==typeof e&&("defaultRoute"===t||"defaultParams"===t))return;const n=K[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 ${m(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(!p(r,Y)){const t=Object.keys(Y).map(t=>`"${t}"`).join(", ");throw new TypeError(`[router.${e}] Unknown queryParams key: "${r}". Valid keys: ${t}`)}const n=t[r],i=Y[r];if(!i.includes(n)){const t=i.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 J&&function(t,e,r){const n=J[t];if(!n.includes(e)){const i=n.map(t=>`"${t}"`).join(", ");throw new TypeError(`[router.${r}] Invalid value for "${t}": expected one of ${i}, got "${String(e)}"`)}}(t,e,r)}function et(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(D,r))throw new TypeError(`[router.${e}]: unknown limit: "${r}"`);void 0!==n&&rt(r,n,e)}}(e,r),!0;throw new TypeError(`[router.${r}] Unknown option: "${t}"`)}function rt(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=D[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 nt=class{#h;constructor(t={}){this.#h=Z({...K,...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 ${m(t)}`);for(const[r,n]of Object.entries(t))p(r,K)?void 0!==n&&tt(r,n,e):et(r,n,e)}(t,e)}get(){return this.#h}};function it(t,e){return t===e||!(!Array.isArray(t)||!Array.isArray(e))&&t.length===e.length&&t.every((t,r)=>it(t,e[r]))}var at=class{#f=0;#p=void 0;#g=void 0;#m;#v=new Map;static validateMakeStateArgs(t,e,r,n){if(!h(t))throw new TypeError(`[router.makeState] Invalid name: ${m(t)}. Expected string.`);if(void 0!==e&&!l(e))throw new TypeError(`[router.makeState] Invalid params: ${m(e)}. Expected plain object.`);if(void 0!==r&&!h(r))throw new TypeError(`[router.makeState] Invalid path: ${m(r)}. Expected string.`);if(void 0!==n&&"number"!=typeof n)throw new TypeError(`[router.makeState] Invalid forceId: ${m(n)}. Expected number.`)}static validateAreStatesEqualArgs(t,e,r){if(null!=t&&v(t,"areStatesEqual"),null!=e&&v(e,"areStatesEqual"),void 0!==r&&"boolean"!=typeof r)throw new TypeError(`[router.areStatesEqual] Invalid ignoreQueryParams: ${m(r)}. Expected boolean.`)}get(){return this.#p}set(t){this.#g=this.#p,this.#p=t?W(t):void 0}getPrevious(){return this.#g}reset(){this.#p=void 0,this.#g=void 0,this.#v.clear(),this.#f=0}setDependencies(t){this.#m=t}makeState(t,e,r,n,i){const a=n?{...n,id:i??++this.#f,params:n.params,options:n.options}:void 0,s=this.#m.getDefaultParams();let o;return o=Object.hasOwn(s,t)?{...s[t],...e}:e?{...e}:{},W({name:t,params:o,path:r??this.#m.buildPath(t,e),meta:a})}makeNotFoundState(t,e){return this.makeState(w.UNKNOWN_ROUTE,{path:t},t,{options:e,params:{}})}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.#y(t.name)).every(r=>it(t.params[r],e.params[r]))}const n=Object.keys(t.params),i=Object.keys(e.params);return n.length===i.length&&n.every(r=>r in e.params&&it(t.params[r],e.params[r]))}#y(t){const e=this.#v.get(t);if(void 0!==e)return e;const r=this.#m.getUrlParams(t);return this.#v.set(t,r),r}},st={[b]:P.ROUTER_START,[T]:P.ROUTER_STOP,[A]:P.TRANSITION_SUCCESS,[S]:P.TRANSITION_START,[E]:P.TRANSITION_ERROR,[R]:P.TRANSITION_CANCEL},ot=Object.keys(st).filter(t=>p(t,st)),ct="router.usePlugin",ut=class e{#w=new Set;#b=new Set;#T;#m;#d=$;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 ${m(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 ${m(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&&!p(e,st))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=$.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.")}setRouter(t){this.#T=t}setDependencies(t){this.#m=t}setLimits(t){this.#d=t}count(){return this.#w.size}use(...e){if(this.#S(e.length),1===e.length){const r=e[0],n=this.#R(r);this.#w.add(r);let i=!1;const a=()=>{if(!i){i=!0,this.#w.delete(r),this.#b.delete(a);try{n()}catch(e){t.logger.error(ct,"Error during cleanup:",e)}}};return this.#b.add(a),a}const r=this.#A(e),n=[];try{for(const t of r){const e=this.#R(t);n.push({factory:t,cleanup:e})}}catch(e){for(const{cleanup:e}of n)try{e()}catch(e){t.logger.error(ct,"Cleanup error:",e)}throw e}for(const{factory:t}of n)this.#w.add(t);let i=!1;const a=()=>{if(!i){i=!0,this.#b.delete(a);for(const{factory:t}of n)this.#w.delete(t);for(const{cleanup:e}of n)try{e()}catch(e){t.logger.error(ct,"Error during cleanup:",e)}}};return this.#b.add(a),a}getAll(){return[...this.#w]}has(t){return this.#w.has(t)}disposeAll(){for(const t of this.#b)t();this.#w.clear(),this.#b.clear()}#S(e){const r=this.#d.maxPlugins;if(0===r)return;const n=e+this.#w.size,{warn:i,error:a}=H(r);n>=a?t.logger.error(ct,`${n} plugins registered! This is excessive and will impact performance. Hard limit at ${r}.`):n>=i&&t.logger.warn(ct,`${n} plugins registered. Consider if all are necessary.`)}#A(e){const r=new Set;for(const n of e)r.has(n)?t.logger.warn(ct,"Duplicate factory in batch, will be registered once"):r.add(n);return r}#R(r){const n=r(this.#T,this.#m.getDependency);e.validatePlugin(n),Object.freeze(n);const i=[];for(const e of ot)e in n&&("function"==typeof n[e]?(i.push(this.#m.addEventListener(st[e],n[e])),"onStart"===e&&this.#m.canNavigate()&&t.logger.warn(ct,"Router already started, onStart will not be called")):t.logger.warn(ct,`Property '${e}' is not a function, skipping`));return()=>{for(const t of i)t();"function"==typeof n.teardown&&n.teardown()}}};function dt(t,e,r){if(t)throw new Error(`[router.${r}] Cannot modify route "${e}" during its own registration`)}function lt(t,e,r=$.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 ht=class{#E=new Map;#P=new Map;#O=new Map;#$=new Map;#D=new Set;#T;#m;#d=$;static validateHandler(t,e){!function(t,e){if(!f(t)&&"function"!=typeof t)throw new TypeError(`[router.${e}] Handler must be a boolean or factory function, got ${m(t)}`)}(t,e)}setRouter(t){this.#T=t}setDependencies(t){this.#m=t}setLimits(t){this.#d=t}addCanActivate(t,e,r){r||dt(this.#D.has(t),t,"addActivateGuard");const n=this.#P.has(t);n||r||lt(this.#P.size+1,"addActivateGuard",this.#d.maxLifecycleHandlers),this.#N("activate",t,e,this.#P,this.#$,"canActivate",n)}addCanDeactivate(t,e,r){r||dt(this.#D.has(t),t,"addDeactivateGuard");const n=this.#E.has(t);n||r||lt(this.#E.size+1,"addDeactivateGuard",this.#d.maxLifecycleHandlers),this.#N("deactivate",t,e,this.#E,this.#O,"canDeactivate",n)}clearCanActivate(t){this.#P.delete(t),this.#$.delete(t)}clearCanDeactivate(t){this.#E.delete(t),this.#O.delete(t)}clearAll(){this.#P.clear(),this.#$.clear(),this.#E.clear(),this.#O.clear()}getFactories(){const t={},e={};for(const[e,r]of this.#E)t[e]=r;for(const[t,r]of this.#P)e[t]=r;return[t,e]}getFunctions(){return[this.#O,this.#$]}checkActivateGuardSync(t,e,r){return this.#C(this.#$,t,e,r,"checkActivateGuardSync")}checkDeactivateGuardSync(t,e,r){return this.#C(this.#O,t,e,r,"checkDeactivateGuardSync")}#N(e,r,n,i,a,s,o){o?t.logger.warn(`router.${s}`,`Overwriting existing ${e} handler for route "${r}"`):this.#S(i.size+1,s);const c=f(n)?function(t){const e=()=>t;return()=>e}(n):n;i.set(r,c),this.#D.add(r);try{const t=c(this.#T,this.#m.getDependency);if("function"!=typeof t)throw new TypeError(`[router.${s}] Factory must return a function, got ${m(t)}`);a.set(r,t)}catch(t){throw i.delete(r),t}finally{this.#D.delete(r)}}#C(e,r,n,i,a){const s=e.get(r);if(!s)return!0;try{const e=s(n,i);return"boolean"==typeof e?e:(t.logger.warn(`router.${a}`,`Guard for "${r}" returned a Promise. Sync check cannot resolve async guards — returning false.`),!1)}catch{return!1}}#S(e,r){const n=this.#d.maxLifecycleHandlers;if(0===n)return;const{warn:i,error:a}=H(n);e>=a?t.logger.error(`router.${r}`,`${e} lifecycle handlers registered! This is excessive. Hard limit at ${n}.`):e>=i&&t.logger.warn(`router.${r}`,`${e} lifecycle handlers registered. Consider consolidating logic.`)}};function ft(t){return`(${t.replaceAll(/(^<|>$)/g,"")})`}var pt=/([:*])([^/?<]+)(<[^>]+>)?(\?)?/g,gt=/([:*][^/?<]+(?:<[^>]+>)?)\?(?=\/|$)/g,mt=/\?(.+)$/,vt=/[^\w!$'()*+,.:;|~-]/gu,yt=/[^\w!$'()*+,.:;|~-]/u,wt={default:t=>yt.test(t)?t.replaceAll(vt,t=>encodeURIComponent(t)):t,uri:encodeURI,uriComponent:encodeURIComponent,none:t=>t},bt={default:decodeURIComponent,uri:decodeURI,uriComponent:decodeURIComponent,none:t=>t};function Tt(){return{staticChildren:Object.create(null),paramChild:void 0,splatChild:void 0,route:void 0,slashChildRoute:void 0}}function St(t){return t.length>1&&t.endsWith("/")?t.slice(0,-1):t}function Rt(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 At(t){const e=[];for(const r of Object.keys(t)){const n=t[r],i=encodeURIComponent(r);e.push(""===n?i:`${i}=${encodeURIComponent(String(n))}`)}return e.join("&")}function Et(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function Pt(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(!Et(r)||!Et(n))return!1;e+=3}else e++;return!0}var Ot=/<[^>]*>/g;function $t(t,e,r,n,i){const a=""===e.fullName;a||n.push(e);const s=e.absolute,o=e.paramMeta.pathPattern,c=s&&o.startsWith("~")?o.slice(1):o,u=(s?c:o).replaceAll(Ot,""),d=s?u:(h=u,""===(l=r)?h:""===h?l:l+h);var l,h;let f=i;a||(f=function(t,e,r,n,i,a){const s=(m=n,St(r)===St(m)),o=Object.freeze([...i]),c=function(t){const e={};for(const r of t)e[r.fullName]=r.paramTypeMap;return Object.freeze(e)}(o),u=St(r),d=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,i),l=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}(i),h=s?St(n):u,{buildStaticParts:f,buildParamSlots:p}=function(t,e,r){const n=new Set,i=new Set;for(const t of e){for(const e of t.paramMeta.urlParams)n.add(e);for(const e of t.paramMeta.spatParams)i.add(e)}if(0===n.size)return{buildStaticParts:[t],buildParamSlots:[]};const a=[],s=[],o=/[:*]([\w]+)(?:<[^>]*>)?(\?)?/gu;let c,u=0;for(;null!==(c=o.exec(t));){const e=c[1],n="?"===c[2];a.push(t.slice(u,c.index));const o=i.has(e);s.push({paramName:e,isOptional:n,encoder:o?t=>{const e=wt[r],n=t.split("/");let i=e(n[0]);for(let t=1;t<n.length;t++)i+=`/${e(n[t])}`;return i}:wt[r]}),u=c.index+c[0].length}return a.push(t.slice(u)),{buildStaticParts:a,buildParamSlots:s}}(h,s?i.slice(0,-1):i,t.options.urlParamsEncoding),g={name:e.fullName,parent:a,depth:i.length-1,matchSegments:o,meta:c,declaredQueryParams:d,declaredQueryParamsSet:new Set(d),hasTrailingSlash:r.length>1&&r.endsWith("/"),constraintPatterns:l,hasConstraints:l.size>0,buildStaticParts:f,buildParamSlots:p};var m;return t.routesByName.set(e.fullName,g),t.segmentsByName.set(e.fullName,o),t.metaByName.set(e.fullName,c),s?function(t,e,r){var n,i;n=e,(function(t,e,r){const n=St(r);if("/"===n||""===n)return e;let i=e,a=1;const s=n.length;for(;a<=s;){const e=n.indexOf("/",a),r=-1===e?s:e;if(r<=a)break;i=Nt(t,i,n.slice(a,r)),a=r+1}return i}(i=t,i.root,r)).slashChildRoute=n;const a=St(r),s=t.options.caseSensitive?a:a.toLowerCase();t.staticCache.has(s)&&t.staticCache.set(s,e)}(t,g,n):function(t,e,r,n,i){if(function(t,e,r){const n=St(r);"/"!==n?Dt(t,t.root,n,1,e):t.root.route=e}(t,e,r),0===i.paramMeta.urlParams.length){const r=t.options.caseSensitive?n:n.toLowerCase();t.staticCache.set(r,e)}}(t,g,r,u,e),g}(t,e,d,s?"":r,n,i));for(const r of e.children.values())$t(t,r,d,n,f);a||n.pop()}function Dt(t,e,r,n,i){const a=r.length;for(;n<=a;){const s=r.indexOf("/",n),o=-1===s?a:s,c=r.slice(n,o);if(c.endsWith("?")){const n=c.slice(1).replaceAll(Ot,"").replace(/\?$/,"");return e.paramChild??={node:Tt(),name:n},Dt(t,e.paramChild.node,r,o+1,i),void(o>=a?e.route??=i:Dt(t,e,r,o+1,i))}e=Nt(t,e,c),n=o+1}e.route=i}function Nt(t,e,r){if(r.startsWith("*")){const t=r.slice(1);return e.splatChild??={node:Tt(),name:t},e.splatChild.node}if(r.startsWith(":")){const t=r.slice(1).replaceAll(Ot,"").replace(/\?$/,"");return e.paramChild??={node:Tt(),name:t},e.paramChild.node}const n=t.options.caseSensitive?r:r.toLowerCase();return n in e.staticChildren||(e.staticChildren[n]=Tt()),e.staticChildren[n]}var Ct=/[\u0080-\uFFFF]/,jt=class{get options(){return this.#t}#t;#e=Tt();#i=new Map;#a=new Map;#r=new Map;#s=new Map;#n="";#j=[];constructor(t){this.#t={caseSensitive:t?.caseSensitive??!0,strictTrailingSlash:t?.strictTrailingSlash??!1,strictQueryParams:t?.strictQueryParams??!1,urlParamsEncoding:t?.urlParamsEncoding??"default",parseQueryString:t?.parseQueryString??Rt,buildQueryString:t?.buildQueryString??At}}registerTree(t){this.#j=t.paramMeta.queryParams,$t({root:this.#e,options:this.#t,routesByName:this.#i,segmentsByName:this.#a,metaByName:this.#r,staticCache:this.#s,rootQueryParams:this.#j},t,"",[],null)}match(t){const e=this.#o(t);if(!e)return;const[r,n,i]=e,a=this.#t.caseSensitive?n:n.toLowerCase(),s=this.#s.get(a);if(s){if(this.#t.strictTrailingSlash&&!this.#c(r,s))return;return this.#F(s,{},i)}const o={},c=this.#M(n,o);return!c||this.#t.strictTrailingSlash&&!this.#c(r,c)||c.hasConstraints&&!this.#x(o,c)||!this.#I(o)?void 0:this.#F(c,o,i)}buildPath(t,e,r){const n=this.#i.get(t);if(!n)throw new Error(`[SegmentMatcher.buildPath] '${t}' is not defined`);n.hasConstraints&&e&&this.#L(n,t,e);const i=this.#k(n,e),a=this.#U(i,r?.trailingSlash),s=this.#_(n,e,r?.queryParamsMode);return a+(s?`?${s}`:"")}getSegmentsByName(t){return this.#a.get(t)}getMetaByName(t){return this.#r.get(t)}hasRoute(t){return this.#i.has(t)}setRootPath(t){this.#n=t}#L(t,e,r){for(const[n,i]of t.constraintPatterns){const t=r[n];if(null!=t){const r="object"==typeof t?JSON.stringify(t):String(t);if(!i.pattern.test(r))throw new Error(`[SegmentMatcher.buildPath] '${e}' — param '${n}' value '${r}' does not match constraint '${i.constraint}'`)}}}#k(t,e){const r=t.buildStaticParts,n=t.buildParamSlots;if(0===n.length)return this.#n+r[0];let i=this.#n+r[0];for(const[t,a]of n.entries()){const n=e?.[a.paramName];if(null==n){if(!a.isOptional)throw new Error(`[SegmentMatcher.buildPath] Missing required param '${a.paramName}'`);i.length>1&&i.endsWith("/")&&(i=i.slice(0,-1)),i+=r[t+1];continue}const s="object"==typeof n?JSON.stringify(n):String(n);i+=a.encoder(s)+r[t+1]}return i}#U(t,e){return"always"!==e||t.endsWith("/")?"never"===e&&"/"!==t&&t.endsWith("/")?t.slice(0,-1):t:`${t}/`}#_(t,e,r){if(!e)return"";const n=[...t.declaredQueryParams];if("loose"===r){const r=new Set(t.buildParamSlots.map(t=>t.paramName));for(const i in e)!Object.hasOwn(e,i)||t.declaredQueryParamsSet.has(i)||r.has(i)||n.push(i)}const i={};for(const t of n)t in e&&(i[t]=e[t]);return 0===Object.keys(i).length?"":this.#t.buildQueryString(i)}#o(t){if(""===t&&(t="/"),!t.startsWith("/"))return;const e=t.indexOf("#");if(-1!==e&&(t=t.slice(0,e)),Ct.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),i=-1===r?void 0:t.slice(r+1);return n.includes("//")?void 0:[n,St(n),i]}#F(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}#M(t,e){return 1===t.length?this.#e.slashChildRoute??this.#e.route:this.#B(this.#e,t,1,e)}#B(t,e,r,n){let i=t;const a=e.length;for(;r<=a;){const t=e.indexOf("/",r),s=-1===t?a:t,o=e.slice(r,s),c=this.#t.caseSensitive?o:o.toLowerCase();let u;if(c in i.staticChildren)u=i.staticChildren[c];else{if(!i.paramChild){if(i.splatChild){const t={},a=this.#B(i.splatChild.node,e,r,t);return a?(Object.assign(n,t),a):(n[i.splatChild.name]=e.slice(r),i.splatChild.node.route)}return}u=i.paramChild.node,n[i.paramChild.name]=o}i=u,r=s+1}return i.slashChildRoute??i.route}#I(t){const e=this.#t.urlParamsEncoding;if("none"===e)return!0;const r=bt[e];for(const e in t){const n=t[e];if(n.includes("%")){if(!Pt(n))return!1;t[e]=r(n)}}return!0}#x(t,e){for(const[r,n]of e.constraintPatterns)if(!n.pattern.test(t[r]))return!1;return!0}},Ft=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)},Mt=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)},xt={none:{encodeArray:(t,e)=>e.map(e=>`${t}=${Mt(e)}`).join("&")},brackets:{encodeArray:(t,e)=>e.map(e=>`${t}[]=${Mt(e)}`).join("&")},index:{encodeArray:(t,e)=>e.map((e,r)=>`${t}[${r}]=${Mt(e)}`).join("&")},comma:{encodeArray:(t,e)=>`${t}=${e.map(t=>Mt(t)).join(",")}`}},It={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}},Lt={default:{encode:t=>t},hidden:{encode:()=>""}},kt=(t,e,r)=>({boolean:It[e],null:Lt[r],array:xt[t]}),Ut={arrayFormat:"none",booleanFormat:"none",nullFormat:"default",strategies:{boolean:It.none,null:Lt.default,array:xt.none}},_t=t=>{if(!t||void 0===t.arrayFormat&&void 0===t.booleanFormat&&void 0===t.nullFormat)return Ut;const e=t.arrayFormat??"none",r=t.booleanFormat??"none",n=t.nullFormat??"default";return{arrayFormat:e,booleanFormat:r,nullFormat:n,strategies:kt(e,r,n)}},Bt=t=>encodeURIComponent(t),Vt=(t,e,r)=>{const n=Bt(t);switch(typeof e){case"string":case"number":default:return`${n}=${Bt(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}=${Bt(e)}`}};function Gt(t,e,r,n,i){const a=t.indexOf("=",e),s=-1!==a&&a<r,o=t.slice(e,s?a: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}}(o);var d,l,h,f,p;!function(t,e,r,n){const i=t[e];void 0===i?t[e]=n?[r]:r:Array.isArray(i)?i.push(r):t[e]=[i,r]}(n,Ft(c),(d=t,l=a,h=r,f=s,p=i,p?((t,e)=>{if(void 0===t)return e.boolean.decodeUndefined();const r=e.boolean.decodeRaw(t);if(null!==r)return r;const n=Ft(t);return e.boolean.decodeValue(n)})(f?d.slice(l+1,h):void 0,p):f?Ft(d.slice(l+1,h)):null),u)}function qt(t,e){const r=t.path,n=r.startsWith("~"),i=n?r.slice(1):r,a={name:t.name,path:i,absolute:n,children:[],parent:e,nonAbsoluteChildren:[],fullName:""};if(t.children)for(const e of t.children){const t=qt(e,a);a.children.push(t)}return a}function zt(t,e){return t.endsWith("/")&&e.startsWith("/")?t+e.slice(1):t+e}function Wt(t){const e=new Map;for(const r of t)e.set(r.name,r);return e}function Ht(t,e,r){const n=function(t){const e=[],r=[],n=[],i={},a=new Map,s=t.replaceAll(gt,"$1"),o=mt.exec(s);if(null!==o){const e=o[1].split("&");for(const t of e){const e=t.trim();e.length>0&&(r.push(e),i[e]="query")}t=t.slice(0,o.index)}let c;for(;null!==(c=pt.exec(t));){const t=c[2],r=c[3];if("*"===c[1])n.push(t),e.push(t),i[t]="url";else if(e.push(t),i[t]="url",r){const e=`^${ft(r)}$`;a.set(t,{pattern:new RegExp(e),constraint:r})}}return{urlParams:e,queryParams:r,spatParams:n,paramTypeMap:i,constraintPatterns:a,pathPattern:t}}(t.path),i=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),a={name:t.name,path:t.path,absolute:t.absolute,parent:e,children:void 0,paramMeta:n,nonAbsoluteChildren:void 0,fullName:"",staticPath:null,paramTypeMap:i};var s;a.fullName=(s=a,s.parent?.name?`${s.parent.fullName}.${s.name}`:s.name);const{childrenMap:o,nonAbsoluteChildren:c}=function(t,e,r){const n=[],i=[];for(const a of t){const t=Ht(a,e,r);n.push(t),t.absolute||i.push(t)}return{childrenMap:Wt(n),nonAbsoluteChildren:i}}(t.children,a,r);return a.children=o,a.nonAbsoluteChildren=c,a.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 i=[];let a=t.parent;for(;a?.path;)i.unshift(a),a=a.parent;let s="";for(const t of i){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:zt(s,t.path)}return t.absolute?t.path:zt(s,t.path)}(a),r&&(Object.freeze(c),Object.freeze(i),Object.freeze(a.children),Object.freeze(a)),a}function Qt(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 Ht(t,null,e)}(function(t,e,r){const n=qt({name:t,path:e},null);for(const t of r){const e=qt(t,n);n.children.push(e)}return n}(t,e,r),!n?.skipFreeze)}}(t,e).addMany(r).build(n)}function Kt(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=>Kt(t))),e}function Jt(t){const e=t?.queryParams;return new jt({...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 i=t.indexOf("&",r);-1===i&&(i=n),Gt(t,r,i,e),r=i+1}}(t,e),e}(r);const n=_t(e),i={};let a=0;const s=r.length;for(;a<s;){let t=r.indexOf("&",a);-1===t&&(t=s),Gt(r,a,t,i,n.strategies),a=t+1}return i})(t,e),buildQueryString:t=>((t,e)=>{const r=Object.keys(t);if(0===r.length)return"";const n=_t(e),i=[];for(const e of r){const r=t[e];if(void 0===r)continue;const a=Vt(e,r,n);a&&i.push(a)}return i.join("&")})(t,e)})}function Yt(t,e){return new TypeError(`[router.${t}] ${e}`)}var Zt=/^[A-Z_a-z][\w-]*$/,Xt=/\S/;function te(t){return null===t?"null":"object"==typeof t?"constructor"in t&&"Object"!==t.constructor.name?t.constructor.name:"object":typeof t}function ee(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 re(t,e,r,n="",i,a){!function(t,e){if(!t||"object"!=typeof t)throw new TypeError(`[router.${e}] Route must be an object, got ${te(t)}`);const r=Object.getPrototypeOf(t);if(r!==Object.prototype&&null!==r)throw new TypeError(`[router.${e}] Route must be a plain object, got ${te(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 ${te(t.name)}`);const r=t.name;if(""===r)throw new TypeError(`[router.${e}] Route name cannot be empty`);if(!Xt.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(!Zt.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,Yt(r,`Route path must be a string, got ${e}`)}if(""===t)return;if(/\s/.test(t))throw Yt(r,`Invalid path for route "${e}": whitespace not allowed in "${t}"`);if(!/^([/?~]|[^/]+$)/.test(t))throw Yt(r,`Route "${e}" has invalid path format: "${t}". Path should start with '/', '~', '?' or be a relative segment.`);if(t.includes("//"))throw Yt(r,`Invalid path for route "${e}": double slashes not allowed in "${t}"`);const i=n&&Object.values(n.paramTypeMap).includes("url");if(t.startsWith("~")&&i)throw Yt(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 o=s.name,c=n?`${n}.${o}`:o;r&&c&&function(t,e,r){if(ee(t,e))throw new Error(`[router.${r}] Route "${e}" already exists`)}(r,c,e),i&&function(t,e,r){if(t.has(e))throw new Error(`[router.${r}] Duplicate route "${e}" in batch`);t.add(e)}(i,c,e);const u=s.path,d=n;if(r&&function(t,e,r,n){const i=""===e?t:ee(t,e);if(i)for(const t of i.children.values())if(t.path===r)throw new Error(`[router.${n}] Path "${r}" is already defined`)}(r,d,u,e),a&&function(t,e,r,n){const i=t.get(e);if(i?.has(r))throw new Error(`[router.${n}] Path "${r}" is already defined`);i?i.add(r):t.set(e,new Set([r]))}(a,d,u,e),void 0!==s.children){if(!Array.isArray(s.children))throw new TypeError(`[router.${e}] Route "${o}" children must be an array, got ${te(s.children)}`);for(const t of s.children)re(t,e,r,c,i,a)}}var ne=new Set;function ie(){return{decoders:Object.create(null),encoders:Object.create(null),defaultParams:Object.create(null),forwardMap:Object.create(null),forwardFnMap:Object.create(null)}}function ae(t){const e={name:t.name,path:t.path};return t.children&&(e.children=t.children.map(t=>ae(t))),e}function se(t,e,r=""){for(let n=0;n<t.length;n++){const i=t[n],a=r?`${r}.${i.name}`:i.name;if(a===e)return t.splice(n,1),!0;if(i.children&&e.startsWith(`${a}.`)&&se(i.children,e,a))return!0}return!1}function oe(t,e){for(const r of Object.keys(t))e(r)&&delete t[r]}function ce(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 ${m(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 ${m(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 ${m(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)ce(r,`${e}.${r.name}`)}function ue(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 de(t){const e=new Set;for(const r of t)for(const t of ue(r))e.add(t);return e}function le(t,e,r="",n=[]){for(const i of t){const t=r?`${r}.${i.name}`:i.name,a=[...n,i.path];if(t===e)return a;if(i.children&&e.startsWith(`${t}.`))return le(i.children,e,t,a)}throw new Error(`[internal] collectPathsToRoute: route "${e}" not found`)}function he(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 he(n.children,t))r.add(e)}return r}function fe(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,i]of fe(n.children,t))r.set(e,i)}return r}function pe(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 i=t;for(const t of n){const e=i.children.get(t);if(!e)return null;r.push(e),i=e}return r}(r,t)):de(le(n,t))}function ge(t,e,r,n,i){const a=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}(i,e),s=n.has(e);if(!a&&!s)throw new Error(`[router.addRoute] forwardTo target "${e}" does not exist for route "${t}"`);const o=de(le(r,t)),c=[...pe(e,a,i,r)].filter(t=>!o.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 me(t,e,r=100){const n=new Set,i=[t];let a=t;for(;e[a];){const t=e[a];if(n.has(t)){const e=i.indexOf(t),r=[...i.slice(e),t];throw new Error(`Circular forwardTo: ${r.join(" → ")}`)}if(n.add(a),i.push(t),a=t,i.length>r)throw new Error(`forwardTo chain exceeds maximum depth (${r}): ${i.join(" → ")}`)}return a}function ve(t,e,r){const n=he(t),i=fe(t),a={...e};for(const[t,e]of i)a[t]=e;for(const[e,a]of i)ge(e,a,t,n,r);for(const t of Object.keys(a))me(t,a)}function ye(t,e){var r;return{name:e??(r=t.segments,r.at(-1)?.fullName??""),params:t.params,meta:t.meta}}function we(t,e){if("AsyncFunction"===t.constructor.name||t.toString().includes("__awaiter"))throw new TypeError(`[real-router] updateRoute: ${e} cannot be an async function`)}function be(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}`);we(t,e)}}var Te=".";function Se(t){const e=[];for(let r=t.length-1;r>=0;r--)e.push(t[r]);return e}function Re(t,e){const r=e.meta?.params[t];if(!r||"object"!=typeof r)return{};const n={};for(const t of Object.keys(r)){const r=e.params[t];null!=r&&("string"!=typeof r&&"number"!=typeof r&&"boolean"!=typeof r||(n[t]=String(r)))}return n}function Ae(t){if(!t)return[""];const e=t.indexOf(Te);if(-1===e)return[t];const r=t.indexOf(Te,e+1);if(-1===r)return[t.slice(0,e),t];const n=t.indexOf(Te,r+1);return-1===n?[t.slice(0,e),t.slice(0,r),t]:-1===t.indexOf(Te,n+1)?[t.slice(0,e),t.slice(0,r),t.slice(0,n),t]:function(t){const e=t.split(Te),r=e.length,n=[e[0]];let i=e[0].length;for(let a=1;a<r-1;a++)i+=1+e[a].length,n.push(t.slice(0,i));return n.push(t),n}(t)}function Ee(t,e){if(!e)return{intersection:"",toActivate:Ae(t.name),toDeactivate:[]};if((t.meta?.options??{}).reload)return{intersection:"",toActivate:Ae(t.name),toDeactivate:Se(Ae(e.name))};if(void 0===t.meta?.params&&void 0===e.meta?.params)return{intersection:"",toActivate:Ae(t.name),toDeactivate:Se(Ae(e.name))};const r=Ae(t.name),n=Ae(e.name),i=function(t,e,r,n,i){for(let a=0;a<i;a++){const i=r[a],s=n[a];if(i!==s)return a;const o=Re(i,t),c=Re(s,e),u=Object.keys(o);for(const t of u)if(o[t]!==c[t])return a}return i}(t,e,r,n,Math.min(n.length,r.length)),a=[];for(let t=n.length-1;t>=i;t--)a.push(n[t]);const s=r.slice(i);return{intersection:i>0?n[i-1]:"",toDeactivate:a,toActivate:s}}var Pe=Object.freeze({}),Oe=class{#V=[];#G=ie();#q=Object.create(null);#z=Object.create(null);#W=new Map;#H=new Map;#Q="";#K;#J;#Y;#Z;#X;#tt;get#m(){if(!this.#Z)throw new Error("[real-router] RoutesNamespace: dependencies not initialized");return this.#Z}constructor(t=[],e=!1,r){this.#tt=e,this.#Y=r;for(const e of t)this.#V.push(ae(e));this.#K=Qt("",this.#Q,this.#V),this.#J=Jt(r),this.#J.registerTree(this.#K),this.#et(t),e?this.#rt():this.#nt()}static validateRemoveRouteArgs(t){!function(t){g(t,"removeRoute")}(t)}static validateSetRootPathArgs(t){!function(t){if("string"!=typeof t)throw new TypeError(`[router.setRootPath] rootPath must be a string, got ${m(t)}`)}(t)}static validateAddRouteArgs(t){!function(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 ${m(e)}`);ce(e,e.name)}}(t)}static validateParentOption(t){!function(t){if("string"!=typeof t||""===t)throw new TypeError(`[router.addRoute] parent option must be a non-empty string, got ${m(t)}`);g(t,"addRoute")}(t)}static validateIsActiveRouteArgs(t,e,r,n){!function(t,e,r,n){if(!h(t))throw new TypeError("Route name must be a string");if(void 0!==e&&!l(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)}(t,e,r,n)}static validateStateBuilderArgs(t,e,r){!function(t,e,r){if(!h(t))throw new TypeError(`[router.${r}] Invalid routeName: ${m(t)}. Expected string.`);if(!l(e))throw new TypeError(`[router.${r}] Invalid routeParams: ${m(e)}. Expected plain object.`)}(t,e,r)}static validateUpdateRouteBasicArgs(t,e){!function(t,e){if(g(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 ${m(e)}`)}(t,e)}static validateUpdateRoutePropertyTypes(t,e,r,n){!function(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 ${m(t)}`);"function"==typeof t&&we(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 ${m(e)}`);be(r,"decodeParams"),be(n,"encodeParams")}(t,e,r,n)}static validateBuildPathArgs(t){!function(t){if(!h(t)||""===t)throw new TypeError("[real-router] buildPath: route must be a non-empty string, got "+("string"==typeof t?'""':typeof t))}(t)}static validateMatchPathArgs(t){!function(t){if(!h(t))throw new TypeError("[real-router] matchPath: path must be a string, got "+typeof t)}(t)}static validateShouldUpdateNodeArgs(t){!function(t){if(!h(t))throw new TypeError("[router.shouldUpdateNode] nodeName must be a string, got "+typeof t)}(t)}static validateRoutes(t,e,r,n){!function(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 i=new Set,a=new Map;for(const r of t)re(r,"addRoute",e,n??"",i,a);e&&r&&ve(t,r,e)}(t,e,r,n)}setDependencies(t){this.#Z=t;for(const[e,r]of this.#W)t.addActivateGuard(e,r);this.#W.clear();for(const[e,r]of this.#H)t.addDeactivateGuard(e,r);this.#H.clear()}setLifecycleNamespace(t){this.#X=t}getRootPath(){return this.#Q}getTree(){return this.#K}getForwardRecord(){return this.#G.forwardMap}setRootPath(t){this.#Q=t,this.#it()}hasRoute(t){return this.#J.hasRoute(t)}getRoute(t){const e=this.#J.getSegmentsByName(t);if(!e)return;const r=Kt(this.#at(e));return this.#st(r,t)}getRouteConfig(t){if(this.#J.hasRoute(t))return this.#z[t]}getRouteCustomFields(){return this.#z}addRoutes(t,e){if(e){const r=this.#ot(this.#V,e);r.children??=[];for(const e of t)r.children.push(ae(e))}else for(const e of t)this.#V.push(ae(e));this.#et(t,e??""),this.#it(),this.#ct()}removeRoute(t){return!!se(this.#V,t)&&(this.#ut(t),this.#it(),this.#ct(),!0)}updateRouteConfig(t,e){if(void 0!==e.forwardTo&&this.#dt(t,e.forwardTo),void 0!==e.defaultParams&&(null===e.defaultParams?delete this.#G.defaultParams[t]:this.#G.defaultParams[t]=e.defaultParams),void 0!==e.decodeParams)if(null===e.decodeParams)delete this.#G.decoders[t];else{const r=e.decodeParams;this.#G.decoders[t]=t=>r(t)??t}if(void 0!==e.encodeParams)if(null===e.encodeParams)delete this.#G.encoders[t];else{const r=e.encodeParams;this.#G.encoders[t]=t=>r(t)??t}}clearRoutes(){this.#V.length=0,Object.assign(this.#G,ie()),this.#q=Object.create(null),this.#z=Object.create(null),this.#it()}buildPath(t,e,r){if(t===w.UNKNOWN_ROUTE)return h(e?.path)?e.path:"";const n=Object.hasOwn(this.#G.defaultParams,t)?{...this.#G.defaultParams[t],...e}:e??{},i="function"==typeof this.#G.encoders[t]?this.#G.encoders[t]({...n}):n,a=r?.trailingSlash;return this.#J.buildPath(t,i,{trailingSlash:"never"===a||"always"===a?a:void 0,queryParamsMode:r?.queryParamsMode})}matchPath(t,e){const r=e,n=this.#J.match(t);if(!n)return;const i=ye(n),{name:a,params:s,meta:o}=i,c="function"==typeof this.#G.decoders[a]?this.#G.decoders[a](s):s,{name:u,params:d}=this.#m.forwardState(a,c);let l=t;if(r.rewritePathOnMatch){const t="function"==typeof this.#G.encoders[u]?this.#G.encoders[u]({...d}):d,e=r.trailingSlash;l=this.#J.buildPath(u,t,{trailingSlash:"never"===e||"always"===e?e:void 0,queryParamsMode:r.queryParamsMode})}return this.#m.makeState(u,d,l,{params:o,options:Pe})}forwardState(t,e){if(Object.hasOwn(this.#G.forwardFnMap,t)){const r=this.#lt(t,e),n=this.#G.forwardFnMap[t],i=this.#ht(t,n,e);return{name:i,params:this.#lt(i,r)}}const r=this.#q[t]??t;if(r!==t&&Object.hasOwn(this.#G.forwardFnMap,r)){const n=this.#lt(t,e),i=this.#G.forwardFnMap[r],a=this.#ht(r,i,e);return{name:a,params:this.#lt(a,n)}}if(r!==t){const n=this.#lt(t,e);return{name:r,params:this.#lt(r,n)}}return{name:t,params:this.#lt(t,e)}}buildStateResolved(t,e){const r=this.#J.getSegmentsByName(t);if(r)return ye({segments:r,params:e,meta:this.#J.getMetaByName(t)},t)}buildStateWithSegmentsResolved(t,e){const r=this.#J.getSegmentsByName(t);if(r)return{state:ye({segments:r,params:e,meta:this.#J.getMetaByName(t)},t),segments:r}}isActiveRoute(t,e={},r=!1,n=!0){ne.has(t)||(g(t,"isActiveRoute"),ne.add(t));const i=this.#m.getState();if(!i)return!1;const a=i.name;if(a!==t&&!a.startsWith(`${t}.`)&&!t.startsWith(`${a}.`))return!1;const s=this.#G.defaultParams[t];if(r||a===t){const r=s?{...s,...e}:e;return this.#m.areStatesEqual({name:t,params:r,path:""},i,n)}const o=i.params;return!!function(t,e){for(const r in t)if(t[r]!==e[r])return!1;return!0}(e,o)&&(!s||function(t,e,r){for(const n in t)if(!(n in r)&&t[n]!==e[n])return!1;return!0}(s,o,e))}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.meta?.options.reload)return!0;if(""===t&&!r)return!0;const{intersection:n,toActivate:i,toDeactivate:a}=Ee(e,r);return t===n||!!i.includes(t)||a.includes(t)}}getConfig(){return this.#G}getUrlParams(t){const e=this.#J.getSegmentsByName(t);return e?this.#ft(e):[]}getResolvedForwardMap(){return this.#q}setResolvedForwardMap(t){Object.assign(this.#q,t)}applyClonedConfig(t,e,r){Object.assign(this.#G.decoders,t.decoders),Object.assign(this.#G.encoders,t.encoders),Object.assign(this.#G.defaultParams,t.defaultParams),Object.assign(this.#G.forwardMap,t.forwardMap),Object.assign(this.#G.forwardFnMap,t.forwardFnMap),this.setResolvedForwardMap({...e}),Object.assign(this.#z,r)}cloneRoutes(){return[...this.#K.children.values()].map(t=>Kt(t))}validateForwardToParamCompatibility(t,e){const r=this.#pt(t),n=this.#pt(e),i=this.#gt(r),a=this.#ft(n).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}"`)}validateForwardToCycle(t,e){me(t,{...this.#G.forwardMap,[t]:e})}validateRemoveRoute(e,r,n){if(r){const n=r===e,i=r.startsWith(`${e}.`);if(n||i)return t.logger.warn("router.removeRoute",`Cannot remove route "${e}" — it is currently active${n?"":` (current: "${r}")`}. Navigate away first.`),!1}return n&&t.logger.warn("router.removeRoute",`Route "${e}" removed while navigation is in progress. This may cause unexpected behavior.`),!0}validateClearRoutes(e){return!e||(t.logger.error("router.clearRoutes","Cannot clear routes while navigation is in progress. Wait for navigation to complete."),!1)}validateUpdateRoute(t,e){if(!this.hasRoute(t))throw new ReferenceError(`[real-router] updateRoute: route "${t}" does not exist`);if(null!=e&&"string"==typeof e){if(!this.hasRoute(e))throw new Error(`[real-router] updateRoute: forwardTo target "${e}" does not exist`);this.validateForwardToParamCompatibility(t,e),this.validateForwardToCycle(t,e)}}#dt(t,e){null===e?(delete this.#G.forwardMap[t],delete this.#G.forwardFnMap[t]):"string"==typeof e?(delete this.#G.forwardFnMap[t],this.#G.forwardMap[t]=e):(delete this.#G.forwardMap[t],this.#G.forwardFnMap[t]=e),this.#ct()}#lt(t,e){return Object.hasOwn(this.#G.defaultParams,t)?{...this.#G.defaultParams[t],...e}:e}#ht(t,e,r){const n=new Set([t]);let i=e(this.#m.getDependency,r),a=0;if("string"!=typeof i)throw new TypeError("forwardTo callback must return a string, got "+typeof i);for(;a<100;){if(void 0===this.#J.getSegmentsByName(i))throw new Error(`Route "${i}" does not exist`);if(n.has(i)){const t=[...n,i].join(" → ");throw new Error(`Circular forwardTo detected: ${t}`)}if(n.add(i),Object.hasOwn(this.#G.forwardFnMap,i)){i=(0,this.#G.forwardFnMap[i])(this.#m.getDependency,r),a++;continue}const t=this.#G.forwardMap[i];if(void 0===t)return i;i=t,a++}throw new Error("forwardTo exceeds maximum depth of 100")}#it(){this.#K=Qt("",this.#Q,this.#V),this.#J=Jt(this.#Y),this.#J.registerTree(this.#K)}#pt(t){return this.#J.getSegmentsByName(t)}#at(t){return t.at(-1)}#gt(t){const e=new Set;for(const r of t)for(const t of r.paramMeta.urlParams)e.add(t);return e}#ft(t){const e=[];for(const r of t)for(const t of r.paramMeta.urlParams)e.push(t);return e}#ct(){this.#tt?this.#rt():this.#nt()}#nt(){this.#q=Object.create(null);for(const t of Object.keys(this.#G.forwardMap))this.#q[t]=me(t,this.#G.forwardMap)}#rt(){this.#q=Object.create(null);for(const t of Object.keys(this.#G.forwardMap)){let e=t;for(;this.#G.forwardMap[e];)e=this.#G.forwardMap[e];this.#q[t]=e}}#ut(t){const e=e=>e===t||e.startsWith(`${t}.`);oe(this.#G.decoders,e),oe(this.#G.encoders,e),oe(this.#G.defaultParams,e),oe(this.#G.forwardMap,e),oe(this.#G.forwardFnMap,e),oe(this.#z,e),oe(this.#G.forwardMap,t=>e(this.#G.forwardMap[t]));const[r,n]=this.#X.getFactories();for(const t of Object.keys(n))e(t)&&this.#X.clearCanActivate(t);for(const t of Object.keys(r))e(t)&&this.#X.clearCanDeactivate(t)}#et(t,e=""){for(const r of t){const t=e?`${e}.${r.name}`:r.name;this.#mt(r,t),r.children&&this.#et(r.children,t)}}#mt(t,e){const r=new Set(["name","path","children","canActivate","canDeactivate","forwardTo","encodeParams","decodeParams","defaultParams"]),n=Object.fromEntries(Object.entries(t).filter(([t])=>!r.has(t)));Object.keys(n).length>0&&(this.#z[e]=n),t.canActivate&&(this.#Z?this.#Z.addActivateGuard(e,t.canActivate):this.#W.set(e,t.canActivate)),t.canDeactivate&&(this.#Z?this.#Z.addDeactivateGuard(e,t.canDeactivate):this.#H.set(e,t.canDeactivate)),t.forwardTo&&this.#vt(t,e),t.decodeParams&&(this.#G.decoders[e]=e=>t.decodeParams?.(e)??e),t.encodeParams&&(this.#G.encoders[e]=e=>t.encodeParams?.(e)??e),t.defaultParams&&(this.#G.defaultParams[e]=t.defaultParams)}#ot(t,e,r=""){for(const n of t){const t=r?`${r}.${n.name}`:n.name;if(t===e)return n;if(n.children&&e.startsWith(`${t}.`))return this.#ot(n.children,e,t)}}#vt(e,r){if(e.canActivate&&t.logger.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.logger.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?this.#G.forwardMap[r]=e.forwardTo:this.#G.forwardFnMap[r]=e.forwardTo}#st(t,e){const r={name:t.name,path:t.path},n=this.#G.forwardFnMap[e],i=this.#G.forwardMap[e];void 0!==n?r.forwardTo=n:void 0!==i&&(r.forwardTo=i),e in this.#G.defaultParams&&(r.defaultParams=this.#G.defaultParams[e]),e in this.#G.decoders&&(r.decodeParams=this.#G.decoders[e]),e in this.#G.encoders&&(r.encodeParams=this.#G.encoders[e]);const[a,s]=this.#X.getFactories();return e in s&&(r.canActivate=s[e]),e in a&&(r.canDeactivate=a[e]),t.children&&(r.children=t.children.map(t=>this.#st(t,`${e}.${t.name}`))),r}},$e=new Set(Object.values(y)),De=new Set(["code","segment","path","redirect"]),Ne=new Set(["setCode","setErrorInstance","setAdditionalFields","hasField","getField","toJSON"]),Ce=class extends Error{segment;path;redirect;code;constructor(t,{message:e,segment:r,path:n,redirect:i,...a}={}){super(e??t),this.code=t,this.segment=r,this.path=n,this.redirect=i?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}(i):void 0;for(const[t,e]of Object.entries(a)){if(De.has(t))throw new TypeError(`[RouterError] Cannot set reserved property "${t}"`);Ne.has(t)||(this[t]=e)}}setCode(t){this.code=t,$e.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(De.has(e))throw new TypeError(`[RouterError.setAdditionalFields] Cannot set reserved property "${e}"`);Ne.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}};function je(t,e,r){if(t instanceof Ce)throw t.setCode(e),t;throw new Ce(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))Fe.has(r)||(e[r]=n);return{...r,...e}}return r}(t,r))}var Fe=new Set(["code","segment","path","redirect"]);async function Me(t,e,r,n,i,a){const s=n.filter(e=>t.has(e));if(0===s.length)return;let o;for(const n of s){if(a())throw new Ce(y.TRANSITION_CANCELLED);const s=t.get(n);try{o=await s(e,r)}catch(t){je(t,i,n)}if(!o)throw new Ce(i,{segment:n})}}var xe=class e{#yt;#m;#wt;static validateNavigateArgs(t){!function(t){if("string"!=typeof t)throw new TypeError(`[router.navigate] Invalid route name: expected string, got ${m(t)}`)}(t)}static validateNavigateToStateArgs(t,e,r){!function(t,e,r){if(!t||"object"!=typeof t||"string"!=typeof t.name||"string"!=typeof t.path)throw new TypeError("[router.navigateToState] Invalid toState: expected State object with name and path");if(void 0!==e&&(!e||"object"!=typeof e||"string"!=typeof e.name))throw new TypeError("[router.navigateToState] Invalid fromState: expected State object or undefined");if("object"!=typeof r||null===r)throw new TypeError(`[router.navigateToState] Invalid opts: expected NavigationOptions object, got ${m(r)}`)}(t,e,r)}static validateNavigateToDefaultArgs(t){!function(t){if(void 0!==t&&("object"!=typeof t||null===t))throw new TypeError(`[router.navigateToDefault] Invalid options: ${m(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 a){const r=e[t];if(void 0!==r&&"boolean"!=typeof r)return!1}return!0}(t))throw new TypeError(`[router.${e}] Invalid options: ${m(t)}. Expected NavigationOptions object.`)}(t,e)}setCanNavigate(t){this.#yt=t}setDependencies(t){this.#m=t}setTransitionDependencies(t){this.#wt=t}async navigate(t,e,r){if(!this.#yt())throw new Ce(y.ROUTER_NOT_STARTED);const n=this.#m,i=n.buildStateWithSegments(t,e);if(!i){const t=new Ce(y.ROUTE_NOT_FOUND);throw n.emitTransitionError(void 0,n.getState(),t),t}const{state:a}=i,s=n.makeState(a.name,a.params,n.buildPath(a.name,a.params),{params:a.meta,options:r}),o=n.getState();if(!r.reload&&!r.force&&n.areStatesEqual(o,s,!1)){const t=new Ce(y.SAME_STATES);throw n.emitTransitionError(s,o,t),t}return this.navigateToState(s,o,r)}async navigateToState(r,n,i){const a=this.#m,s=this.#wt;s.isTransitioning()&&(t.logger.warn("router.navigate","Concurrent navigation detected on shared router instance. For SSR, use router.clone() to create isolated instance per request."),a.cancelNavigation()),a.startTransition(r,n);try{const{state:t,meta:o}=await async function(t,e,r,n){const[i,a]=t.getLifecycleFunctions(),s=e.name===w.UNKNOWN_ROUTE,o=()=>!t.isActive(),{toDeactivate:c,toActivate:u,intersection:d}=Ee(e,r),l=!s&&u.length>0;if(r&&!n.forceDeactivate&&c.length>0&&await Me(i,e,r,c,y.CANNOT_DEACTIVATE,o),o())throw new Ce(y.TRANSITION_CANCELLED);if(l&&await Me(a,e,r,u,y.CANNOT_ACTIVATE,o),o())throw new Ce(y.TRANSITION_CANCELLED);if(r){const n=Ae(e.name),a=Ae(r.name);for(const e of a)!n.includes(e)&&i.has(e)&&t.clearCanDeactivate(e)}return{state:e,meta:{phase:"activating",segments:{deactivated:c,activated:u,intersection:d}}}}(s,r,n,i);if(t.name===w.UNKNOWN_ROUTE||a.hasRoute(t.name)){const r=e.#bt(t,o,n);return a.setState(r),a.sendTransitionDone(r,n,i),r}{const e=new Ce(y.ROUTE_NOT_FOUND,{routeName:t.name});throw a.sendTransitionError(t,n,e),e}}catch(t){throw this.#Tt(t,r,n),t}}async navigateToDefault(t){const e=this.#m,r=e.getOptions();if(!r.defaultRoute)throw new Ce(y.ROUTE_NOT_FOUND,{routeName:"defaultRoute not configured"});const n=X(r.defaultRoute,e.getDependency);if(!n)throw new Ce(y.ROUTE_NOT_FOUND,{routeName:"defaultRoute resolved to empty"});const i=X(r.defaultParams,e.getDependency);return this.navigate(n,i,t)}static#bt(t,e,r){const n={phase:e.phase,...void 0!==r?.name&&{from:r.name},reason:"success",segments:e.segments};return Object.freeze(n.segments.deactivated),Object.freeze(n.segments.activated),Object.freeze(n.segments),Object.freeze(n),{...t,transition:n}}#Tt(t,e,r){const n=t;n.code!==y.TRANSITION_CANCELLED&&n.code!==y.ROUTE_NOT_FOUND&&(n.code===y.CANNOT_ACTIVATE||n.code===y.CANNOT_DEACTIVATE?this.#m.sendTransitionBlocked(e,r,n):this.#m.sendTransitionError(e,r,n))}},Ie=class{#St;#m;static validateStartArgs(t){if(1!==t.length||"string"!=typeof t[0])throw new Error("[router.start] Expected exactly 1 string argument (startPath).")}setNavigateToState(t){this.#St=t}setDependencies(t){this.#m=t}async start(t){const e=this.#m,r=e.getOptions(),n={replace:!0},i=e.matchPath(t);if(!i&&!r.allowNotFound){const r=new Ce(y.ROUTE_NOT_FOUND,{path:t});throw e.emitTransitionError(void 0,void 0,r),r}let a;if(e.completeStart(),i)a=await this.#St(i,void 0,n);else{const r=e.makeNotFoundState(t,n);a=await this.#St(r,void 0,n)}return a}stop(){this.#m.setState()}},Le=class{#Rt;static validateCloneArgs(t){if(void 0!==t){if(!t||"object"!=typeof t||t.constructor!==Object)throw new TypeError(`[router.clone] Invalid dependencies: expected plain object or undefined, received ${m(t)}`);for(const e in t)if(Object.getOwnPropertyDescriptor(t,e)?.get)throw new TypeError(`[router.clone] Getters not allowed in dependencies: "${e}"`)}}setGetCloneData(t){this.#Rt=t}clone(t,e,r){const n=this.#Rt(),i={...n.dependencies,...t},a=e(n.routes,n.options,i);for(const[t,e]of Object.entries(n.canDeactivateFactories))a.addDeactivateGuard(t,e);for(const[t,e]of Object.entries(n.canActivateFactories))a.addActivateGuard(t,e);return n.pluginFactories.length>0&&a.usePlugin(...n.pluginFactories),r(a,n.routeConfig,n.resolvedForwardMap,n.routeCustomFields),a}},ke=class t{#At;#Et;#Pt;constructor(t){this.#At=t.routerFSM,this.#Et=t.emitter,this.#Pt=void 0,this.#Ot()}static validateEventName(t){if(!O.has(t))throw new Error(`Invalid event name: ${String(t)}`)}static validateListenerArgs(e,r){if(t.validateEventName(e),"function"!=typeof r)throw new TypeError(`Expected callback to be a function for event ${e}`)}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.#Et.emit(P.ROUTER_START)}emitRouterStop(){this.#Et.emit(P.ROUTER_STOP)}emitTransitionStart(t,e){this.#Et.emit(P.TRANSITION_START,t,e)}emitTransitionSuccess(t,e,r){this.#Et.emit(P.TRANSITION_SUCCESS,t,e,r)}emitTransitionError(t,e,r){this.#Et.emit(P.TRANSITION_ERROR,t,e,r)}emitTransitionCancel(t,e){this.#Et.emit(P.TRANSITION_CANCEL,t,e)}sendStart(){this.#At.send(x)}sendStop(){this.#At.send(B)}sendDispose(){this.#At.send(V)}completeStart(){this.#At.send(I)}beginTransition(t,e){this.#Pt=t,this.#At.send(L,{toState:t,fromState:e})}completeTransition(t,e,r={}){this.#At.send(k,{state:t,fromState:e,opts:r}),this.#Pt=void 0}failTransition(t,e,r){this.#At.send(U,{toState:t,fromState:e,error:r}),this.#Pt=void 0}cancelTransition(t,e){this.#At.send(_,{toState:t,fromState:e}),this.#Pt=void 0}emitOrFailTransitionError(t,e,r){this.#At.getState()===j?this.#At.send(U,{toState:t,fromState:e,error:r}):this.emitTransitionError(t,e,r)}canBeginTransition(){return this.#At.canSend(L)}canStart(){return this.#At.canSend(x)}canCancel(){return this.#At.canSend(_)}isActive(){const t=this.#At.getState();return t!==N&&t!==M}isDisposed(){return this.#At.getState()===M}isTransitioning(){return this.#At.getState()===F}isReady(){return this.#At.getState()===j}getCurrentToState(){return this.#Pt}addEventListener(t,e){return this.#Et.on(t,e)}subscribe(t){return this.#Et.on(P.TRANSITION_SUCCESS,(e,r)=>{t({route:e,previousRoute:r})})}clearAll(){this.#Et.clearAll()}setLimits(t){this.#Et.setLimits(t)}cancelTransitionIfRunning(t){this.canCancel()&&this.cancelTransition(this.#Pt,t)}#Ot(){const t=this.#At;t.on(C,I,()=>{this.emitRouterStart()}),t.on(j,B,()=>{this.emitRouterStop()}),t.on(j,L,t=>{this.emitTransitionStart(t.toState,t.fromState)}),t.on(F,k,t=>{this.emitTransitionSuccess(t.state,t.fromState,t.opts)}),t.on(F,_,t=>{this.emitTransitionCancel(t.toState,t.fromState)}),t.on(C,U,t=>{this.emitTransitionError(t.toState,t.fromState,t.error)}),t.on(j,U,t=>{this.emitTransitionError(t.toState,t.fromState,t.error)}),t.on(F,U,t=>{this.emitTransitionError(t.toState,t.fromState,t.error)})}},Ue=new Ce(y.ROUTER_ALREADY_STARTED),_e=new Set(["all","warn-error","error-only"]);var Be=class{router;options;limits;dependencies;state;routes;routeLifecycle;plugins;navigation;lifecycle;clone;eventBus;constructor(t){this.router=t.router,this.options=t.options,this.limits=t.limits,this.dependencies=t.dependencies,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.clone=t.clone,this.eventBus=t.eventBus}wireLimits(){this.dependencies.setLimits(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(){this.routeLifecycle.setRouter(this.router),this.routeLifecycle.setDependencies({getDependency:t=>this.dependencies.get(t)})}wireRoutesDeps(){this.routes.setDependencies({addActivateGuard:(t,e)=>{this.router.addActivateGuard(t,e)},addDeactivateGuard:(t,e)=>{this.router.addDeactivateGuard(t,e)},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.dependencies.get(t),forwardState:(t,e)=>this.router.forwardState(t,e)}),this.routes.setLifecycleNamespace(this.routeLifecycle)}wirePluginsDeps(){this.plugins.setRouter(this.router),this.plugins.setDependencies({addEventListener:(t,e)=>this.eventBus.addEventListener(t,e),canNavigate:()=>this.eventBus.canBeginTransition(),getDependency:t=>this.dependencies.get(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{name:r,params:n}=this.router.forwardState(t,e);return this.routes.buildStateWithSegmentsResolved(r,n)},makeState:(t,e,r,n)=>this.state.makeState(t,e,r,n),buildPath:(t,e)=>this.routes.buildPath(t,e,this.options.get()),areStatesEqual:(t,e,r)=>this.state.areStatesEqual(t,e,r),getDependency:t=>this.dependencies.get(t),startTransition:(t,e)=>{this.eventBus.beginTransition(t,e)},cancelNavigation:()=>{this.eventBus.cancelTransition(this.eventBus.getCurrentToState(),this.state.get())},sendTransitionDone:(t,e,r)=>{this.eventBus.completeTransition(t,e,r)},sendTransitionBlocked:(t,e,r)=>{this.eventBus.failTransition(t,e,r)},sendTransitionError:(t,e,r)=>{this.eventBus.failTransition(t,e,r)},emitTransitionError:(t,e,r)=>{this.eventBus.emitOrFailTransitionError(t,e,r)}}),this.navigation.setTransitionDependencies({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(),makeNotFoundState:(t,e)=>this.state.makeNotFoundState(t,e),setState:t=>{this.state.set(t)},matchPath:t=>this.routes.matchPath(t,this.options.get()),completeStart:()=>{this.eventBus.completeStart()},emitTransitionError:(t,e,r)=>{this.eventBus.failTransition(t,e,r)}})}wireStateDeps(){this.state.setDependencies({getDefaultParams:()=>this.routes.getConfig().defaultParams,buildPath:(t,e)=>this.routes.buildPath(t,e,this.options.get()),getUrlParams:t=>this.routes.getUrlParams(t)})}wireCloneCallbacks(){this.clone.setGetCloneData(()=>{const[t,e]=this.routeLifecycle.getFactories();return{routes:this.routes.cloneRoutes(),options:{...this.options.get()},dependencies:this.dependencies.getAll(),canDeactivateFactories:t,canActivateFactories:e,pluginFactories:this.plugins.getAll(),routeConfig:this.routes.getConfig(),resolvedForwardMap:this.routes.getResolvedForwardMap(),routeCustomFields:this.routes.getRouteCustomFields()}})}wireCyclicDeps(){this.navigation.setCanNavigate(()=>this.eventBus.canBeginTransition()),this.lifecycle.setNavigateToState((t,e,r)=>this.navigation.navigateToState(t,e,r))}},Ve=class r{#h;#d;#u;#$t;#Dt;#Nt;#w;#Ct;#jt;#Ft;#Mt;#tt;constructor(r=[],n={},a={}){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)||!_e.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.logger.configure(n.logger),delete n.logger),nt.validateOptions(n,"constructor");const s=n.noValidate??!1;s||Q.validateDependenciesObject(a,"constructor"),!s&&r.length>0&&(Oe.validateAddRouteArgs(r),Oe.validateRoutes(r)),this.#h=new nt(n),this.#d=function(t={}){return{...$,...t}}(n.limits),this.#u=new Q(a),this.#$t=new at,this.#Dt=new Oe(r,s,function(t){return{strictTrailingSlash:"strict"===t.trailingSlash,strictQueryParams:"strict"===t.queryParamsMode,urlParamsEncoding:t.urlParamsEncoding,queryParams:t.queryParams}}(this.#h.get())),this.#Nt=new ht,this.#w=new ut,this.#Ct=new xe,this.#jt=new Ie,this.#Ft=new Le,this.#tt=s;const o=new e.FSM(G),c=new i({onListenerError:(e,r)=>{t.logger.error("Router",`Error in listener for ${e}:`,r)},onListenerWarn:(e,r)=>{t.logger.warn("router.addEventListener",`Event "${e}" has ${r} listeners — possible memory leak`)}});var u;this.#Mt=new ke({routerFSM:o,emitter:c}),(u=new Be({router:this,options:this.#h,limits:this.#d,dependencies:this.#u,state:this.#$t,routes:this.#Dt,routeLifecycle:this.#Nt,plugins:this.#w,navigation:this.#Ct,lifecycle:this.#jt,clone:this.#Ft,eventBus:this.#Mt})).wireLimits(),u.wireRouteLifecycleDeps(),u.wireRoutesDeps(),u.wirePluginsDeps(),u.wireNavigationDeps(),u.wireLifecycleDeps(),u.wireStateDeps(),u.wireCloneCallbacks(),u.wireCyclicDeps(),this.addRoute=this.addRoute.bind(this),this.removeRoute=this.removeRoute.bind(this),this.clearRoutes=this.clearRoutes.bind(this),this.getRoute=this.getRoute.bind(this),this.getRouteConfig=this.getRouteConfig.bind(this),this.hasRoute=this.hasRoute.bind(this),this.updateRoute=this.updateRoute.bind(this),this.isActiveRoute=this.isActiveRoute.bind(this),this.buildPath=this.buildPath.bind(this),this.matchPath=this.matchPath.bind(this),this.setRootPath=this.setRootPath.bind(this),this.getRootPath=this.getRootPath.bind(this),this.makeState=this.makeState.bind(this),this.getState=this.getState.bind(this),this.getPreviousState=this.getPreviousState.bind(this),this.areStatesEqual=this.areStatesEqual.bind(this),this.forwardState=this.forwardState.bind(this),this.buildState=this.buildState.bind(this),this.buildNavigationState=this.buildNavigationState.bind(this),this.shouldUpdateNode=this.shouldUpdateNode.bind(this),this.getOptions=this.getOptions.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.addActivateGuard=this.addActivateGuard.bind(this),this.addDeactivateGuard=this.addDeactivateGuard.bind(this),this.removeActivateGuard=this.removeActivateGuard.bind(this),this.removeDeactivateGuard=this.removeDeactivateGuard.bind(this),this.canNavigateTo=this.canNavigateTo.bind(this),this.usePlugin=this.usePlugin.bind(this),this.setDependency=this.setDependency.bind(this),this.setDependencies=this.setDependencies.bind(this),this.getDependency=this.getDependency.bind(this),this.getDependencies=this.getDependencies.bind(this),this.removeDependency=this.removeDependency.bind(this),this.hasDependency=this.hasDependency.bind(this),this.resetDependencies=this.resetDependencies.bind(this),this.addEventListener=this.addEventListener.bind(this),this.navigate=this.navigate.bind(this),this.navigateToDefault=this.navigateToDefault.bind(this),this.navigateToState=this.navigateToState.bind(this),this.subscribe=this.subscribe.bind(this),this.clone=this.clone.bind(this)}addRoute(t,e){const r=Array.isArray(t)?t:[t],n=e?.parent;return this.#tt||(void 0!==n&&Oe.validateParentOption(n),Oe.validateAddRouteArgs(r),Oe.validateRoutes(r,this.#Dt.getTree(),this.#Dt.getForwardRecord(),n)),this.#Dt.addRoutes(r,n),this}removeRoute(e){return this.#tt||Oe.validateRemoveRouteArgs(e),this.#Dt.validateRemoveRoute(e,this.#$t.get()?.name,this.#Mt.isTransitioning())?(this.#Dt.removeRoute(e)||t.logger.warn("router.removeRoute",`Route "${e}" not found. No changes made.`),this):this}clearRoutes(){const t=this.#Mt.isTransitioning();return this.#Dt.validateClearRoutes(t)?(this.#Dt.clearRoutes(),this.#Nt.clearAll(),this.#$t.set(void 0),this):this}getRoute(t){return this.#tt||g(t,"getRoute"),this.#Dt.getRoute(t)}getRouteConfig(t){return this.#Dt.getRouteConfig(t)}hasRoute(t){return this.#tt||g(t,"hasRoute"),this.#Dt.hasRoute(t)}updateRoute(e,r){this.#tt||Oe.validateUpdateRouteBasicArgs(e,r);const{forwardTo:n,defaultParams:i,decodeParams:a,encodeParams:s,canActivate:o,canDeactivate:c}=r;return this.#tt||Oe.validateUpdateRoutePropertyTypes(n,i,a,s),this.#Mt.isTransitioning()&&t.logger.error("router.updateRoute",`Updating route "${e}" while navigation is in progress. This may cause unexpected behavior.`),this.#tt||this.#Dt.validateUpdateRoute(e,n),this.#Dt.updateRouteConfig(e,{forwardTo:n,defaultParams:i,decodeParams:a,encodeParams:s}),void 0!==o&&(null===o?this.#Nt.clearCanActivate(e):this.addActivateGuard(e,o)),void 0!==c&&(null===c?this.#Nt.clearCanDeactivate(e):this.addDeactivateGuard(e,c)),this}isActiveRoute(e,r,n,i){return this.#tt||Oe.validateIsActiveRouteArgs(e,r,n,i),""===e?(t.logger.warn("real-router",'isActiveRoute("") called with empty string. Root node is not considered a parent of any route.'),!1):this.#Dt.isActiveRoute(e,r,n,i)}buildPath(t,e){return this.#tt||Oe.validateBuildPathArgs(t),this.#Dt.buildPath(t,e,this.#h.get())}matchPath(t){return this.#tt||Oe.validateMatchPathArgs(t),this.#Dt.matchPath(t,this.#h.get())}setRootPath(t){this.#tt||Oe.validateSetRootPathArgs(t),this.#Dt.setRootPath(t)}getRootPath(){return this.#Dt.getRootPath()}makeState(t,e,r,n,i){return this.#tt||at.validateMakeStateArgs(t,e,r,i),this.#$t.makeState(t,e,r,n,i)}getState(){return this.#$t.get()}getPreviousState(){return this.#$t.getPrevious()}areStatesEqual(t,e,r=!0){return this.#tt||at.validateAreStatesEqualArgs(t,e,r),this.#$t.areStatesEqual(t,e,r)}forwardState(t,e){return this.#tt||Oe.validateStateBuilderArgs(t,e,"forwardState"),this.#Dt.forwardState(t,e)}buildState(t,e){this.#tt||Oe.validateStateBuilderArgs(t,e,"buildState");const{name:r,params:n}=this.forwardState(t,e);return this.#Dt.buildStateResolved(r,n)}buildNavigationState(t,e={}){this.#tt||Oe.validateStateBuilderArgs(t,e,"buildNavigationState");const r=this.buildState(t,e);if(r)return this.makeState(r.name,r.params,this.buildPath(r.name,r.params),{params:r.meta,options:{}})}shouldUpdateNode(t){return this.#tt||Oe.validateShouldUpdateNodeArgs(t),this.#Dt.shouldUpdateNode(t)}getOptions(){return this.#h.get()}isActive(){return this.#Mt.isActive()}async start(t){if(this.#tt||Ie.validateStartArgs([t]),!this.#Mt.canStart())throw Ue;this.#Mt.sendStart();try{return await this.#jt.start(t)}catch(t){throw this.#Mt.isReady()&&(this.#jt.stop(),this.#Mt.sendStop()),t}}stop(){return this.#Mt.cancelTransitionIfRunning(this.#$t.get()),this.#Mt.isReady()||this.#Mt.isTransitioning()?(this.#jt.stop(),this.#Mt.sendStop(),this):this}dispose(){this.#Mt.isDisposed()||(this.#Mt.cancelTransitionIfRunning(this.#$t.get()),(this.#Mt.isReady()||this.#Mt.isTransitioning())&&(this.#jt.stop(),this.#Mt.sendStop()),this.#Mt.sendDispose(),this.#Mt.clearAll(),this.#w.disposeAll(),this.#Dt.clearRoutes(),this.#Nt.clearAll(),this.#$t.reset(),this.#u.reset(),this.#xt())}addDeactivateGuard(t,e){return this.#tt||(g(t,"addDeactivateGuard"),ht.validateHandler(e,"addDeactivateGuard")),this.#Nt.addCanDeactivate(t,e,this.#tt),this}addActivateGuard(t,e){return this.#tt||(g(t,"addActivateGuard"),ht.validateHandler(e,"addActivateGuard")),this.#Nt.addCanActivate(t,e,this.#tt),this}removeActivateGuard(t){this.#tt||g(t,"removeActivateGuard"),this.#Nt.clearCanActivate(t)}removeDeactivateGuard(t){this.#tt||g(t,"removeDeactivateGuard"),this.#Nt.clearCanDeactivate(t)}canNavigateTo(t,e){if(this.#tt||g(t,"canNavigateTo"),!this.hasRoute(t))return!1;const{name:r,params:n}=this.forwardState(t,e??{}),i=this.makeState(r,n),a=this.getState(),{toDeactivate:s,toActivate:o}=Ee(i,a);for(const t of s)if(!this.#Nt.checkDeactivateGuardSync(t,i,a))return!1;for(const t of o)if(!this.#Nt.checkActivateGuardSync(t,i,a))return!1;return!0}usePlugin(...t){return this.#tt||(ut.validateUsePluginArgs(t),ut.validatePluginLimit(this.#w.count(),t.length,this.#d.maxPlugins),ut.validateNoDuplicatePlugins(t,this.#w.has.bind(this.#w))),this.#w.use(...t)}setDependency(t,e){return this.#tt||Q.validateSetDependencyArgs(t),this.#u.set(t,e),this}setDependencies(t){return this.#tt||(Q.validateDependenciesObject(t,"setDependencies"),Q.validateDependencyLimit(this.#u.count(),Object.keys(t).length,"setDependencies",this.#d.maxDependencies)),this.#u.setMultiple(t),this}getDependency(t){this.#tt||Q.validateName(t,"getDependency");const e=this.#u.get(t);return this.#tt||Q.validateDependencyExists(e,t),e}getDependencies(){return this.#u.getAll()}removeDependency(t){return this.#tt||Q.validateName(t,"removeDependency"),this.#u.remove(t),this}hasDependency(t){return this.#tt||Q.validateName(t,"hasDependency"),this.#u.has(t)}resetDependencies(){return this.#u.reset(),this}addEventListener(t,e){return this.#tt||ke.validateListenerArgs(t,e),this.#Mt.addEventListener(t,e)}subscribe(t){return this.#tt||ke.validateSubscribeListener(t),this.#Mt.subscribe(t)}navigate(t,e,n){this.#tt||xe.validateNavigateArgs(t);const i=n??{};this.#tt||xe.validateNavigationOptions(i,"navigate");const a=this.#Ct.navigate(t,e??{},i);return r.#It(a),a}navigateToDefault(t){this.#tt||xe.validateNavigateToDefaultArgs(t);const e=t??{};this.#tt||xe.validateNavigationOptions(e,"navigateToDefault");const n=this.#Ct.navigateToDefault(e);return r.#It(n),n}navigateToState(t,e,r){return this.#tt||xe.validateNavigateToStateArgs(t,e,r),this.#Ct.navigateToState(t,e,r)}clone(t){return this.#tt||Le.validateCloneArgs(t),this.#Ft.clone(t,(t,e,n)=>new r(t,e,n),(t,e,r,n)=>{t.#Dt.applyClonedConfig(e,r,n)})}static#Lt=e=>{e instanceof Ce&&(e.code===y.SAME_STATES||e.code===y.TRANSITION_CANCELLED||e.code===y.ROUTER_NOT_STARTED||e.code===y.ROUTE_NOT_FOUND)||t.logger.error("router.navigate","Unexpected navigation error",e)};static#It(t){t.catch(r.#Lt)}#xt(){this.navigate=Ge,this.navigateToDefault=Ge,this.navigateToState=Ge,this.start=Ge,this.stop=Ge,this.addRoute=Ge,this.removeRoute=Ge,this.clearRoutes=Ge,this.updateRoute=Ge,this.addActivateGuard=Ge,this.addDeactivateGuard=Ge,this.removeActivateGuard=Ge,this.removeDeactivateGuard=Ge,this.usePlugin=Ge,this.setDependency=Ge,this.setDependencies=Ge,this.removeDependency=Ge,this.resetDependencies=Ge,this.addEventListener=Ge,this.subscribe=Ge,this.setRootPath=Ge,this.clone=Ge,this.canNavigateTo=Ge}};function Ge(){throw new Ce(y.ROUTER_DISPOSED)}exports.Router=Ve,exports.RouterError=Ce,exports.constants=w,exports.createRouter=(t=[],e={},r={})=>new Ve(t,e,r),exports.errorCodes=y,exports.events=P,exports.getNavigator=t=>Object.freeze({navigate:t.navigate,getState:t.getState,isActiveRoute:t.isActiveRoute,canNavigateTo:t.canNavigateTo,subscribe:t.subscribe});//# sourceMappingURL=index.js.map
|