@real-router/core 0.40.1 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{Router-B-Pev7K2.d.ts → Router-DoJ3NWsT.d.ts} +1 -1
- package/dist/cjs/{RouterValidator-mx2Zooya.d.ts → RouterValidator-CaIeCVeB.d.ts} +1 -1
- package/dist/cjs/api.d.ts +1 -1
- package/dist/cjs/api.js +1 -1
- package/dist/cjs/api.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -3
- 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/cjs/utils.js +1 -1
- package/dist/cjs/utils.js.map +1 -1
- package/dist/cjs/validation.d.ts +4 -4
- package/dist/cjs/validation.js.map +1 -1
- package/dist/esm/{Router-B-Pev7K2.d.mts → Router-DoJ3NWsT.d.mts} +1 -1
- package/dist/esm/{RouterValidator-mx2Zooya.d.mts → RouterValidator-CaIeCVeB.d.mts} +1 -1
- package/dist/esm/api.d.mts +1 -1
- package/dist/esm/api.mjs +1 -1
- package/dist/esm/{chunk-5QXFUUDL.mjs → chunk-EPF2YSMX.mjs} +1 -1
- package/dist/esm/{chunk-5QXFUUDL.mjs.map → chunk-EPF2YSMX.mjs.map} +1 -1
- package/dist/esm/chunk-UPJLWPEL.mjs +1 -0
- package/dist/esm/chunk-UPJLWPEL.mjs.map +1 -0
- package/dist/esm/{chunk-QUUNDESP.mjs → chunk-UUG7DSTN.mjs} +1 -1
- package/dist/esm/chunk-UUG7DSTN.mjs.map +1 -0
- package/dist/esm/chunk-XQJDGUQE.mjs +1 -0
- package/dist/esm/chunk-XQJDGUQE.mjs.map +1 -0
- package/dist/esm/index.d.mts +3 -3
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/metafile-esm.json +1 -1
- package/dist/esm/utils.mjs +1 -1
- package/dist/esm/validation.d.mts +4 -4
- package/dist/esm/validation.mjs +1 -1
- package/package.json +2 -2
- package/src/Router.ts +4 -6
- package/src/api/getPluginApi.ts +2 -3
- package/src/helpers.ts +0 -1
- package/src/index.ts +0 -1
- package/src/internals.ts +4 -5
- package/src/namespaces/NavigationNamespace/NavigationNamespace.ts +0 -1
- package/src/namespaces/OptionsNamespace/helpers.ts +0 -1
- package/src/namespaces/RouterLifecycleNamespace/types.ts +1 -3
- package/src/namespaces/RoutesNamespace/RoutesNamespace.ts +3 -3
- package/src/namespaces/RoutesNamespace/types.ts +2 -2
- package/src/namespaces/StateNamespace/StateNamespace.ts +30 -34
- package/src/namespaces/StateNamespace/helpers.ts +8 -27
- package/src/stateMetaStore.ts +15 -0
- package/src/transitionPath.ts +13 -16
- package/src/types/RouterValidator.ts +0 -1
- package/src/wiring/RouterWiringBuilder.ts +1 -1
- package/dist/esm/chunk-HHIXK5UM.mjs +0 -1
- package/dist/esm/chunk-HHIXK5UM.mjs.map +0 -1
- package/dist/esm/chunk-MNRZAE7T.mjs +0 -1
- package/dist/esm/chunk-MNRZAE7T.mjs.map +0 -1
- package/dist/esm/chunk-QUUNDESP.mjs.map +0 -1
|
@@ -27,7 +27,7 @@ declare class Router<Dependencies extends DefaultDependencies = DefaultDependenc
|
|
|
27
27
|
constructor(routes?: Route<Dependencies>[], options?: Partial<Options>, dependencies?: Dependencies);
|
|
28
28
|
isActiveRoute(name: string, params?: Params, strictEquality?: boolean, ignoreQueryParams?: boolean): boolean;
|
|
29
29
|
buildPath(route: string, params?: Params): string;
|
|
30
|
-
getState<P extends Params = Params
|
|
30
|
+
getState<P extends Params = Params>(): State<P> | undefined;
|
|
31
31
|
getPreviousState(): State | undefined;
|
|
32
32
|
areStatesEqual(state1: State | undefined, state2: State | undefined, ignoreQueryParams?: boolean): boolean;
|
|
33
33
|
shouldUpdateNode(nodeName: string): (toState: State, fromState?: State) => boolean;
|
|
@@ -121,7 +121,7 @@ interface RouterValidator {
|
|
|
121
121
|
* State validation methods
|
|
122
122
|
*/
|
|
123
123
|
state: {
|
|
124
|
-
validateMakeStateArgs: (name: unknown, params: unknown, path: unknown
|
|
124
|
+
validateMakeStateArgs: (name: unknown, params: unknown, path: unknown) => void;
|
|
125
125
|
validateAreStatesEqualArgs: (s1: unknown, s2: unknown, ignoreQP: unknown) => void;
|
|
126
126
|
};
|
|
127
127
|
/**
|
package/dist/cjs/api.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PluginApi as PluginApi$1, DefaultDependencies, Router, RoutesApi, DependenciesApi, LifecycleApi } from '@real-router/types';
|
|
2
2
|
export { DependenciesApi, LifecycleApi, RoutesApi } from '@real-router/types';
|
|
3
3
|
import { R as RouteTree } from './index.d-y2b-8_3Y.js';
|
|
4
|
-
import { R as Router$1 } from './Router-
|
|
4
|
+
import { R as Router$1 } from './Router-DoJ3NWsT.js';
|
|
5
5
|
|
|
6
6
|
interface PluginApi extends Omit<PluginApi$1, "getTree"> {
|
|
7
7
|
getTree: () => RouteTree;
|
package/dist/cjs/api.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=require("@real-router/logger"),t=require("@real-router/fsm"),n=Object.freeze({ROUTER_NOT_STARTED:"NOT_STARTED",NO_START_PATH_OR_STATE:"NO_START_PATH_OR_STATE",ROUTER_ALREADY_STARTED:"ALREADY_STARTED",ROUTE_NOT_FOUND:"ROUTE_NOT_FOUND",SAME_STATES:"SAME_STATES",CANNOT_DEACTIVATE:"CANNOT_DEACTIVATE",CANNOT_ACTIVATE:"CANNOT_ACTIVATE",TRANSITION_ERR:"TRANSITION_ERR",TRANSITION_CANCELLED:"CANCELLED",ROUTER_DISPOSED:"DISPOSED",PLUGIN_CONFLICT:"PLUGIN_CONFLICT"}),r="@@router/UNKNOWN_ROUTE",i="onStart",a="onStop",s="onTransitionStart",o="onTransitionCancel",c="onTransitionSuccess",d="onTransitionError",l="$start",u="$stop",h="$$start",f="$$cancel",p="$$success",g="$$error",m={maxDependencies:100,maxPlugins:50,maxListeners:1e4,warnListeners:1e3,maxEventDepth:5,maxLifecycleHandlers:200},v=Object.freeze({}),S=new WeakSet;function y(e){if(null!==e&&"object"==typeof e&&!Object.isFrozen(e))if(Object.freeze(e),Array.isArray(e))for(const t of e)y(t);else for(const t in e)y(e[t])}function w(e){return e?(S.has(e)||(y(e),S.add(e)),e):e}var T=new Set(Object.values(n)),b=new Set(["code","segment","path","redirect"]),A=new Set(["setCode","setErrorInstance","setAdditionalFields","hasField","getField","toJSON"]),P=class extends Error{segment;path;redirect;code;constructor(e,{message:t,segment:n,path:r,redirect:i,...a}={}){super(t??e),this.code=e,this.segment=n,this.path=r,this.redirect=i?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 n=structuredClone(e),r=new WeakSet;return function e(t){if(null===t||"object"!=typeof t)return;if(r.has(t))return;r.add(t),Object.freeze(t);const n=Array.isArray(t)?t:Object.values(t);for(const t of n)e(t)}(n),n}(i):void 0;for(const[e,t]of Object.entries(a)){if(b.has(e))throw new TypeError(`[RouterError] Cannot set reserved property "${e}"`);A.has(e)||(this[e]=t)}}setCode(e){this.code=e,T.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,n]of Object.entries(e)){if(b.has(t))throw new TypeError(`[RouterError.setAdditionalFields] Cannot set reserved property "${t}"`);A.has(t)||(this[t]=n)}}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 n in this)Object.hasOwn(this,n)&&!t.has(n)&&(e[n]=this[n]);return e}};function N(e){if(e())throw new P(n.ROUTER_DISPOSED)}var O=new WeakMap;function D(e){const t=O.get(e);if(!t)throw new TypeError("[real-router] Invalid router instance — not found in internals registry");return t}function E(e,t,n){let r=t;for(const t of e){const e=r;r=(...n)=>t(e,...n)}return r(...n)}function R(e,t,n){return(r,i)=>{const a=n.get(e);return a&&0!==a.length?E(a,t,[r,i]):t(r,i)}}function C(e,t){for(const n of e){if(null===n||"object"!=typeof n||Array.isArray(n))throw new TypeError("route must be a non-array object");t?.routes.guardRouteCallbacks(n),t?.routes.guardNoAsyncCallbacks(n);const e=n.children;e&&C(e,t)}}function F(){return{decoders:Object.create(null),encoders:Object.create(null),defaultParams:Object.create(null),forwardMap:Object.create(null),forwardFnMap:Object.create(null)}}function j(e){const t={name:e.name,path:e.path};return e.children&&(t.children=e.children.map(e=>j(e))),t}function L(e,t,n=""){for(let r=0;r<e.length;r++){const i=e[r],a=n?`${n}.${i.name}`:i.name;if(a===t)return e.splice(r,1),!0;if(i.children&&t.startsWith(`${a}.`)&&L(i.children,t,a))return!0}return!1}function M(e,t){for(const n of Object.keys(e))t(n)&&delete e[n]}function I(t){return!t||(e.logger.error("router.clearRoutes","Cannot clear routes while navigation is in progress. Wait for navigation to complete."),!1)}function $(e){return`(${e.replaceAll(/(^<|>$)/g,"")})`}var B=/([:*])([^/?<]+)(<[^>]+>)?(\?)?/g,x=/([:*][^/?<]+(?:<[^>]+>)?)\?(?=\/|$)/g,_=/\?(.+)$/,U=/[^\w!$'()*+,.:;|~-]/gu,k=/[^\w!$'()*+,.:;|~-]/u,G={default:e=>k.test(e)?e.replaceAll(U,e=>encodeURIComponent(e)):e,uri:encodeURI,uriComponent:encodeURIComponent,none:e=>e},z={default:decodeURIComponent,uri:decodeURI,uriComponent:decodeURIComponent,none:e=>e};function q(){return{staticChildren:Object.create(null),paramChild:void 0,splatChild:void 0,route:void 0,slashChildRoute:void 0}}function V(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function W(e){const t={};if(0===e.length)return t;const n=e.split("&");for(const e of n){const n=e.indexOf("=");-1===n?t[e]="":t[e.slice(0,n)]=e.slice(n+1)}return t}function Q(e){const t=[];for(const n of Object.keys(e)){const r=e[n],i=encodeURIComponent(n);t.push(""===r?i:`${i}=${encodeURIComponent(String(r))}`)}return t.join("&")}function H(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function J(e){let t=0;for(;t<e.length;)if("%"===e[t]){if(t+2>=e.length)return!1;const n=e.codePointAt(t+1)??0,r=e.codePointAt(t+2)??0;if(!H(n)||!H(r))return!1;t+=3}else t++;return!0}var Y=/<[^>]*>/g;function K(e,t,n,r,i){const a=""===t.fullName;a||r.push(t);const s=t.absolute,o=t.paramMeta.pathPattern,c=s&&o.startsWith("~")?o.slice(1):o,d=(s?c:o).replaceAll(Y,""),l=s?d:(h=d,""===(u=n)?h:""===h?u:u+h);var u,h;let f=i;a||(f=function(e,t,n,r,i,a){const s=(m=r,V(n)===V(m)),o=Object.freeze([...i]),c=function(e){const t={};for(const n of e)t[n.fullName]=n.paramTypeMap;return Object.freeze(t)}(o),d=V(n),l=function(e,t){const n=[];e.length>0&&n.push(...e);for(const e of t)e.paramMeta.queryParams.length>0&&n.push(...e.paramMeta.queryParams);return n}(e.rootQueryParams,i),u=function(e){const t=new Map;for(const n of e)for(const[e,r]of n.paramMeta.constraintPatterns)t.set(e,r);return t}(i),h=s?V(r):d,{buildStaticParts:f,buildParamSlots:p}=function(e,t,n){const r=new Set,i=new Set;for(const e of t){for(const t of e.paramMeta.urlParams)r.add(t);for(const t of e.paramMeta.spatParams)i.add(t)}if(0===r.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],r="?"===c[2];a.push(e.slice(d,c.index));const o=i.has(t);s.push({paramName:t,isOptional:r,encoder:o?e=>{const t=G[n],r=e.split("/");let i=t(r[0]);for(let e=1;e<r.length;e++)i+=`/${t(r[e])}`;return i}:G[n]}),d=c.index+c[0].length}return a.push(e.slice(d)),{buildStaticParts:a,buildParamSlots:s}}(h,s?i.slice(0,-1):i,e.options.urlParamsEncoding),g={name:t.fullName,parent:a,depth:i.length-1,matchSegments:o,meta:c,declaredQueryParams:l,declaredQueryParamsSet:new Set(l),hasTrailingSlash:n.length>1&&n.endsWith("/"),constraintPatterns:u,hasConstraints:u.size>0,buildStaticParts:f,buildParamSlots:p,buildParamNamesSet:new Set(p.map(e=>e.paramName))};var m;return e.routesByName.set(t.fullName,g),e.segmentsByName.set(t.fullName,o),e.metaByName.set(t.fullName,c),s?function(e,t,n){var r,i;r=t,(function(e,t,n){const r=V(n);if("/"===r||""===r)return t;let i=t,a=1;const s=r.length;for(;a<=s;){const t=r.indexOf("/",a),n=-1===t?s:t;if(n<=a)break;i=Z(e,i,r.slice(a,n)),a=n+1}return i}(i=e,i.root,n)).slashChildRoute=r;const a=V(n),s=e.options.caseSensitive?a:a.toLowerCase();e.staticCache.has(s)&&e.staticCache.set(s,t)}(e,g,r):function(e,t,n,r,i){if(function(e,t,n){const r=V(n);"/"!==r?X(e,e.root,r,1,t):e.root.route=t}(e,t,n),0===i.paramMeta.urlParams.length){const n=e.options.caseSensitive?r:r.toLowerCase();e.staticCache.set(n,t)}}(e,g,n,d,t),g}(e,t,l,s?"":n,r,i));for(const n of t.children.values())K(e,n,l,r,f);a||r.pop()}function X(e,t,n,r,i){const a=n.length;for(;r<=a;){const s=n.indexOf("/",r),o=-1===s?a:s,c=n.slice(r,o);if(c.endsWith("?")){const r=c.slice(1).replaceAll(Y,"").replace(/\?$/,"");return t.paramChild??={node:q(),name:r},X(e,t.paramChild.node,n,o+1,i),void(o>=a?t.route??=i:X(e,t,n,o+1,i))}t=Z(e,t,c),r=o+1}t.route=i}function Z(e,t,n){if(n.startsWith("*")){const e=n.slice(1);return t.splatChild??={node:q(),name:e},t.splatChild.node}if(n.startsWith(":")){const e=n.slice(1).replaceAll(Y,"").replace(/\?$/,"");return t.paramChild??={node:q(),name:e},t.paramChild.node}const r=e.options.caseSensitive?n:n.toLowerCase();return r in t.staticChildren||(t.staticChildren[r]=q()),t.staticChildren[r]}var ee=/[\u0080-\uFFFF]/,te=class{get options(){return this.#e}#e;#t=q();#n=new Map;#r=new Map;#i=new Map;#a=new Map;#s="";#o=[];constructor(e){this.#e={caseSensitive:e?.caseSensitive??!0,strictTrailingSlash:e?.strictTrailingSlash??!1,strictQueryParams:e?.strictQueryParams??!1,urlParamsEncoding:e?.urlParamsEncoding??"default",parseQueryString:e?.parseQueryString??W,buildQueryString:e?.buildQueryString??Q}}registerTree(e){this.#o=e.paramMeta.queryParams,K({root:this.#t,options:this.#e,routesByName:this.#n,segmentsByName:this.#r,metaByName:this.#i,staticCache:this.#a,rootQueryParams:this.#o},e,"",[],null)}match(e){const t=this.#c(e);if(!t)return;const[n,r,i]=t,a=this.#e.caseSensitive?r:r.toLowerCase(),s=this.#a.get(a);if(s){if(this.#e.strictTrailingSlash&&!this.#d(n,s))return;return this.#l(s,{},i)}const o={},c=this.#u(r,o);return!c||this.#e.strictTrailingSlash&&!this.#d(n,c)||c.hasConstraints&&!this.#h(o,c)||!this.#f(o)?void 0:this.#l(c,o,i)}buildPath(e,t,n){const r=this.#n.get(e);if(!r)throw new Error(`[SegmentMatcher.buildPath] '${e}' is not defined`);r.hasConstraints&&t&&this.#p(r,e,t);const i=this.#g(r,t),a=this.#m(i,n?.trailingSlash),s=this.#v(r,t,n?.queryParamsMode);return a+(s?`?${s}`:"")}getSegmentsByName(e){return this.#r.get(e)}getMetaByName(e){return this.#i.get(e)}hasRoute(e){return this.#n.has(e)}setRootPath(e){this.#s=e}#p(e,t,n){for(const[r,i]of e.constraintPatterns){const e=n[r];if(null!=e){const n="object"==typeof e?JSON.stringify(e):String(e);if(!i.pattern.test(n))throw new Error(`[SegmentMatcher.buildPath] '${t}' — param '${r}' value '${n}' does not match constraint '${i.constraint}'`)}}}#g(e,t){const n=e.buildStaticParts,r=e.buildParamSlots;if(0===r.length)return this.#s+n[0];let i=this.#s+n[0];for(const[e,a]of r.entries()){const r=t?.[a.paramName];if(null==r){if(!a.isOptional)throw new Error(`[SegmentMatcher.buildPath] Missing required param '${a.paramName}'`);i.length>1&&i.endsWith("/")&&(i=i.slice(0,-1)),i+=n[e+1];continue}const s="object"==typeof r?JSON.stringify(r):String(r);i+=a.encoder(s)+n[e+1]}return i}#m(e,t){return"always"!==t||e.endsWith("/")?"never"===t&&"/"!==e&&e.endsWith("/")?e.slice(0,-1):e:`${e}/`}#v(e,t,n){if(!t)return"";const r={};let i=!1;for(const n of e.declaredQueryParams)n in t&&(r[n]=t[n],i=!0);if("loose"===n)for(const n in t)!Object.hasOwn(t,n)||e.declaredQueryParamsSet.has(n)||e.buildParamNamesSet.has(n)||(r[n]=t[n],i=!0);return i?this.#e.buildQueryString(r):""}#c(e){if(""===e&&(e="/"),!e.startsWith("/"))return;const t=e.indexOf("#");if(-1!==t&&(e=e.slice(0,t)),ee.test(e))return;if(this.#s.length>0){if(!e.startsWith(this.#s))return;e=e.slice(this.#s.length)||"/"}const n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),i=-1===n?void 0:e.slice(n+1);return r.includes("//")?void 0:[r,V(r),i]}#l(e,t,n){if(void 0!==n){const r=this.#e.parseQueryString(n);if(this.#e.strictQueryParams){const t=e.declaredQueryParamsSet;for(const e of Object.keys(r))if(!t.has(e))return}for(const e of Object.keys(r))t[e]=r[e]}return{segments:e.matchSegments,params:t,meta:e.meta}}#d(e,t){return(e.length>1&&e.endsWith("/"))===t.hasTrailingSlash}#u(e,t){return 1===e.length?this.#t.slashChildRoute??this.#t.route:this.#S(this.#t,e,1,t)}#S(e,t,n,r){let i=e;const a=t.length;for(;n<=a;){const e=t.indexOf("/",n),s=-1===e?a:e,o=t.slice(n,s),c=this.#e.caseSensitive?o:o.toLowerCase();let d;if(c in i.staticChildren)d=i.staticChildren[c];else{if(!i.paramChild){if(i.splatChild){const e={},a=this.#S(i.splatChild.node,t,n,e);return a?(Object.assign(r,e),a):(r[i.splatChild.name]=t.slice(n),i.splatChild.node.route)}return}d=i.paramChild.node,r[i.paramChild.name]=o}i=d,n=s+1}return i.slashChildRoute??i.route}#f(e){const t=this.#e.urlParamsEncoding;if("none"===t)return!0;const n=z[t];for(const t in e){const r=e[t];if(r.includes("%")){if(!J(r))return!1;e[t]=n(r)}}return!0}#h(e,t){for(const[n,r]of t.constraintPatterns)if(!r.pattern.test(e[n]))return!1;return!0}},ne=e=>{const t=e.indexOf("%"),n=e.indexOf("+");if(-1===t&&-1===n)return e;const r=-1===n?e:e.split("+").join(" ");return-1===t?r:decodeURIComponent(r)},re=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)},ie={none:{encodeArray:(e,t)=>t.map(t=>`${e}=${re(t)}`).join("&")},brackets:{encodeArray:(e,t)=>t.map(t=>`${e}[]=${re(t)}`).join("&")},index:{encodeArray:(e,t)=>t.map((t,n)=>`${e}[${n}]=${re(t)}`).join("&")},comma:{encodeArray:(e,t)=>`${e}=${t.map(e=>re(e)).join(",")}`}},ae={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}},se={default:{encode:e=>e},hidden:{encode:()=>""}},oe=(e,t,n)=>({boolean:ae[t],null:se[n],array:ie[e]}),ce={arrayFormat:"none",booleanFormat:"none",nullFormat:"default",strategies:{boolean:ae.none,null:se.default,array:ie.none}},de=e=>{if(!e||void 0===e.arrayFormat&&void 0===e.booleanFormat&&void 0===e.nullFormat)return ce;const t=e.arrayFormat??"none",n=e.booleanFormat??"none",r=e.nullFormat??"default";return{arrayFormat:t,booleanFormat:n,nullFormat:r,strategies:oe(t,n,r)}},le=e=>encodeURIComponent(e),ue=(e,t,n)=>{const r=le(e);switch(typeof t){case"string":case"number":default:return`${r}=${le(t)}`;case"boolean":return n.strategies.boolean.encode(r,t);case"object":return null===t?n.strategies.null.encode(r):Array.isArray(t)?n.strategies.array.encodeArray(r,t):`${r}=${le(t)}`}};function he(e,t,n,r,i){const a=e.indexOf("=",t),s=-1!==a&&a<n,o=e.slice(t,s?a:n),{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 l,u,h,f,p;!function(e,t,n,r){const i=e[t];void 0===i?e[t]=r?[n]:n:Array.isArray(i)?i.push(n):e[t]=[i,n]}(r,ne(c),(l=e,u=a,h=n,f=s,p=i,p?((e,t)=>{if(void 0===e)return t.boolean.decodeUndefined();const n=t.boolean.decodeRaw(e);if(null!==n)return n;const r=ne(e);return t.boolean.decodeValue(r)})(f?l.slice(u+1,h):void 0,p):f?ne(l.slice(u+1,h)):null),d)}function fe(e,t){const n=e.path,r=n.startsWith("~"),i=r?n.slice(1):n,a={name:e.name,path:i,absolute:r,children:[],parent:t,nonAbsoluteChildren:[],fullName:""};if(e.children)for(const t of e.children){const e=fe(t,a);a.children.push(e)}return a}function pe(e,t){return e.endsWith("/")&&t.startsWith("/")?e+t.slice(1):e+t}function ge(e){const t=new Map;for(const n of e)t.set(n.name,n);return t}function me(e,t,n){const r=function(e){const t=[],n=[],r=[],i={},a=new Map,s=e.replaceAll(x,"$1"),o=_.exec(s);if(null!==o){const t=o[1].split("&");for(const e of t){const t=e.trim();t.length>0&&(n.push(t),i[t]="query")}e=e.slice(0,o.index)}let c;for(;null!==(c=B.exec(e));){const e=c[2],n=c[3];if("*"===c[1])r.push(e),t.push(e),i[e]="url";else if(t.push(e),i[e]="url",n){const t=`^${$(n)}$`;a.set(e,{pattern:new RegExp(t),constraint:n})}}return{urlParams:t,queryParams:n,spatParams:r,paramTypeMap:i,constraintPatterns:a,pathPattern:e}}(e.path),i=function(e){const t={};for(const n of e.urlParams)t[n]="url";for(const n of e.queryParams)t[n]="query";return t}(r),a={name:e.name,path:e.path,absolute:e.absolute,parent:t,children:void 0,paramMeta:r,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(e,t,n){const r=[],i=[];for(const a of e){const e=me(a,t,n);r.push(e),e.absolute||i.push(e)}return{childrenMap:ge(r),nonAbsoluteChildren:i}}(e.children,a,n);return a.children=o,a.nonAbsoluteChildren=c,a.staticPath=function(e){if(!e.path)return null;const{urlParams:t,queryParams:n,spatParams:r}=e.paramMeta;if(t.length>0||n.length>0||r.length>0)return null;const i=[];let a=e.parent;for(;a?.path;)i.unshift(a),a=a.parent;let s="";for(const e of i){const{urlParams:t,queryParams:n,spatParams:r}=e.paramMeta;if(t.length>0||n.length>0||r.length>0)return null;s=e.absolute?e.path:pe(s,e.path)}return e.absolute?e.path:pe(s,e.path)}(a),n&&(Object.freeze(c),Object.freeze(i),Object.freeze(a.children),Object.freeze(a)),a}function ve(e,t,n,r){return function(e,t){const n=[];return{add(e){return n.push(e),this},addMany(e){return n.push(...e),this},build:r=>function(e,t=!0){return me(e,null,t)}(function(e,t,n){const r=fe({name:e,path:t},null);for(const e of n){const t=fe(e,r);r.children.push(t)}return r}(e,t,n),!r?.skipFreeze)}}(e,t).addMany(n).build(r)}function Se(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=>Se(e))),t}function ye(e){const t=e?.queryParams;return new te({...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 n=(e=>{const t=e.indexOf("?");return-1===t?e:e.slice(t+1)})(e);if(""===n||"?"===n)return{};if(!t)return function(e){const t={};return function(e,t){let n=0;const r=e.length;for(;n<r;){let i=e.indexOf("&",n);-1===i&&(i=r),he(e,n,i,t),n=i+1}}(e,t),t}(n);const r=de(t),i={};let a=0;const s=n.length;for(;a<s;){let e=n.indexOf("&",a);-1===e&&(e=s),he(n,a,e,i,r.strategies),a=e+1}return i})(e,t),buildQueryString:e=>((e,t)=>{const n=Object.keys(e);if(0===n.length)return"";const r=de(t),i=[];for(const t of n){const n=e[t];if(void 0===n)continue;const a=ue(t,n,r);a&&i.push(a)}return i.join("&")})(e,t)})}function we(e,t,n=100){const r=new Set,i=[e];let a=e;for(;t[a];){const e=t[a];if(r.has(e)){const t=i.indexOf(e),n=[...i.slice(t),e];throw new Error(`Circular forwardTo: ${n.join(" → ")}`)}if(r.add(a),i.push(e),a=e,i.length>n)throw new Error(`forwardTo chain exceeds maximum depth (${n}): ${i.join(" → ")}`)}return a}function Te(e,t,n){const r=ve("",t,e),i=ye(n);return i.registerTree(r),{tree:r,matcher:i}}function be(e){const t=Te(e.definitions,e.rootPath,e.matcherOptions);e.tree=t.tree,e.matcher=t.matcher,e.resolvedForwardMap=Oe(e.config)}function Ae(e){const t=Te(e.definitions,e.rootPath,e.matcherOptions);e.tree=t.tree,e.matcher=t.matcher}function Pe(e){Ne(e),Ae(e)}function Ne(e){e.definitions.length=0,Object.assign(e.config,F()),e.resolvedForwardMap=Object.create(null),e.routeCustomFields=Object.create(null)}function Oe(e){const t=Object.create(null);for(const n of Object.keys(e.forwardMap))t[n]=we(n,e.forwardMap);return t}function De(t,n,r,i,a,s,o){const c=new Set(["name","path","children","canActivate","canDeactivate","forwardTo","encodeParams","decodeParams","defaultParams"]),d=Object.fromEntries(Object.entries(t).filter(([e])=>!c.has(e)));Object.keys(d).length>0&&(i[n]=d),t.canActivate&&(o?o.addActivateGuard(n,t.canActivate):a.set(n,t.canActivate)),t.canDeactivate&&(o?o.addDeactivateGuard(n,t.canDeactivate):s.set(n,t.canDeactivate)),t.forwardTo&&function(t,n,r){if(t.canActivate&&e.logger.warn("real-router",`Route "${n}" 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 "${n}" 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,r=t.forwardTo.toString().includes("__awaiter");if(e||r)throw new TypeError(`forwardTo callback cannot be async for route "${n}". Async functions break matchPath/buildPath.`)}"string"==typeof t.forwardTo?r.forwardMap[n]=t.forwardTo:r.forwardFnMap[n]=t.forwardTo}(t,n,r),t.decodeParams&&(r.decoders[n]=e=>t.decodeParams?.(e)??e),t.encodeParams&&(r.encoders[n]=e=>t.encodeParams?.(e)??e),t.defaultParams&&(r.defaultParams[n]=t.defaultParams)}function Ee(e,t,n,r,i,a,s=""){for(const o of e){const e=s?`${s}.${o.name}`:o.name;De(o,e,t,n,r,i,a),o.children&&Ee(o.children,t,n,r,i,a,e)}}function Re(e,t,n=""){for(const r of e){const e=n?`${n}.${r.name}`:r.name;if(e===t)return r;if(r.children&&t.startsWith(`${e}.`))return Re(r.children,t,e)}}function Ce(e,t,n,r){const i={name:e.name,path:e.path},a=n.forwardFnMap[t],s=n.forwardMap[t];void 0!==a?i.forwardTo=a:void 0!==s&&(i.forwardTo=s),t in n.defaultParams&&(i.defaultParams=n.defaultParams[t]),t in n.decoders&&(i.decodeParams=n.decoders[t]),t in n.encoders&&(i.encodeParams=n.encoders[t]);const[o,c]=r;return t in c&&(i.canActivate=c[t]),t in o&&(i.canDeactivate=o[t]),e.children&&(i.children=e.children.map(e=>Ce(e,`${t}.${e.name}`,n,r))),i}function Fe(e,t,n){if(n){const r=Re(e.definitions,n);r.children??=[];for(const e of t)r.children.push(j(e))}else for(const n of t)e.definitions.push(j(n));Ee(t,e.config,e.routeCustomFields,e.pendingCanActivate,e.pendingCanDeactivate,e.depsStore,n??""),e.treeOperations.commitTreeChanges(e)}function je(e,t){return!!L(e.definitions,t)&&(function(e,t,n,r){const i=t=>t===e||t.startsWith(`${e}.`);M(t.decoders,i),M(t.encoders,i),M(t.defaultParams,i),M(t.forwardMap,i),M(t.forwardFnMap,i),M(n,i),M(t.forwardMap,e=>i(t.forwardMap[e]));const[a,s]=r.getFactories();for(const e of Object.keys(s))i(e)&&r.clearCanActivate(e);for(const e of Object.keys(a))i(e)&&r.clearCanDeactivate(e)}(t,e.config,e.routeCustomFields,e.lifecycleNamespace),e.treeOperations.commitTreeChanges(e),!0)}function Le(e,t){const n=e.matcher.getSegmentsByName(t);if(!n)return;const r=n.at(-1),i=e.treeOperations.nodeToDefinition(r),a=e.lifecycleNamespace.getFactories();return Ce(i,t,e.config,a)}function Me(e){const t=D(e),n=t.routeGetStore().lifecycleNamespace;return{addActivateGuard(e,r){N(t.isDisposed),t.validator?.routes.validateRouteName(e,"addActivateGuard"),t.validator?.lifecycle.validateHandler(r,"addActivateGuard");const i=n.getHandlerCount("activate");t.validator?.lifecycle.validateHandlerLimit(i,t.dependenciesGetStore().limits,"canActivate"),n.addCanActivate(e,r)},addDeactivateGuard(e,r){N(t.isDisposed),t.validator?.routes.validateRouteName(e,"addDeactivateGuard"),t.validator?.lifecycle.validateHandler(r,"addDeactivateGuard");const i=n.getHandlerCount("deactivate");t.validator?.lifecycle.validateHandlerLimit(i,t.dependenciesGetStore().limits,"canDeactivate"),n.addCanDeactivate(e,r)},removeActivateGuard(e){N(t.isDisposed),t.validator?.routes.validateRouteName(e,"removeActivateGuard"),n.clearCanActivate(e)},removeDeactivateGuard(e){N(t.isDisposed),t.validator?.routes.validateRouteName(e,"removeDeactivateGuard"),n.clearCanDeactivate(e)}}}var Ie={maxListeners:0,warnListeners:0,maxEventDepth:0},$e=class extends Error{},Be=class{#e=new Map;#t=null;#i=Ie;#s;#n;constructor(e){e?.limits&&(this.#i=e.limits),this.#s=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.#i=e}on(e,t){const n=this.#r(e);if(n.has(t))throw new Error(`Duplicate listener for "${e}"`);const{maxListeners:r,warnListeners:i}=this.#i;if(0!==i&&n.size===i&&this.#n?.(e,i),0!==r&&n.size>=r)throw new Error(`Listener limit (${r}) reached for "${e}"`);return n.add(t),()=>{this.off(e,t)}}off(e,t){this.#e.get(e)?.delete(t)}emit(e,t,n,r,i){const a=this.#e.get(e);if(!a||0===a.size)return;const s=arguments.length-1;0!==this.#i.maxEventDepth?this.#a(a,e,s,t,n,r,i):this.#d(a,e,s,t,n,r,i)}clearAll(){this.#e.clear(),this.#t=null}listenerCount(e){return this.#e.get(e)?.size??0}#d(e,t,n,r,i,a,s){if(1===e.size){const[o]=e;try{this.#c(o,n,r,i,a,s)}catch(e){this.#s?.(t,e)}return}const o=[...e];for(const e of o)try{this.#c(e,n,r,i,a,s)}catch(e){this.#s?.(t,e)}}#c(e,t,n,r,i,a){switch(t){case 0:e();break;case 1:e(n);break;case 2:e(n,r);break;case 3:e(n,r,i);break;default:e(n,r,i,a)}}#a(e,t,n,r,i,a,s){this.#t??=new Map;const o=this.#t,c=o.get(t)??0;if(c>=this.#i.maxEventDepth)throw new $e(`Maximum recursion depth (${this.#i.maxEventDepth}) exceeded for event: ${t}`);try{o.set(t,c+1);const d=1===e.size?e:[...e];for(const e of d)try{this.#c(e,n,r,i,a,s)}catch(e){if(e instanceof $e)throw e;this.#s?.(t,e)}}finally{o.set(t,o.get(t)-1)}}#r(e){const t=this.#e.get(e);if(t)return t;const n=new Set;return this.#e.set(e,n),n}},xe="IDLE",_e="STARTING",Ue="READY",ke="TRANSITIONING",Ge="DISPOSED",ze="START",qe="STARTED",Ve="NAVIGATE",We="COMPLETE",Qe="FAIL",He="CANCEL",Je="STOP",Ye="DISPOSE",Ke={initial:xe,context:null,transitions:{[xe]:{[ze]:_e,[Ye]:Ge},[_e]:{[qe]:Ue,[Qe]:xe},[Ue]:{[Ve]:ke,[Qe]:Ue,[Je]:xe},[ke]:{[Ve]:ke,[We]:Ue,[He]:Ue,[Qe]:Ue},[Ge]:{}}},Xe={defaultRoute:"",defaultParams:{},trailingSlash:"preserve",queryParamsMode:"loose",queryParams:{arrayFormat:"none",booleanFormat:"none",nullFormat:"default"},urlParamsEncoding:"default",allowNotFound:!0,rewritePathOnMatch:!0};function Ze(e){Object.freeze(e);for(const t of Object.keys(e)){const n=e[t];n&&"object"==typeof n&&n.constructor===Object&&Ze(n)}return e}function et(e,t){return"function"==typeof e?e(t):e}var tt=class{#y;constructor(e={}){this.#y=Ze({...Xe,...e})}static validateOptionsIsObject(e){!function(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new TypeError("[router.constructor] options must be a plain object")}(e)}get(){return this.#y}};function nt(e,t){return e===t||!(!Array.isArray(e)||!Array.isArray(t))&&e.length===t.length&&e.every((e,n)=>nt(e,t[n]))}var rt=class{#w=0;#T=void 0;#b=void 0;#A;#P=new Map;get(){return this.#T}set(e){this.#b=this.#T,this.#T=e?w(e):void 0}getPrevious(){return this.#b}reset(){this.#T=void 0,this.#b=void 0,this.#P.clear(),this.#w=0}setDependencies(e){this.#A=e}makeState(e,t,n,r,i,a){const s=r?{id:i??++this.#w,params:r}:void 0,o=this.#A.getDefaultParams();let c;c=Object.hasOwn(o,e)?{...o[e],...t}:t&&t!==v?{...t}:v;const d={name:e,params:c,path:n??this.#A.buildPath(e,t),meta:s};return a?d:w(d)}areStatesEqual(e,t,n=!0){if(!e||!t)return!!e==!!t;if(e.name!==t.name)return!1;if(n){const n=e.meta?.params??t.meta?.params;return(n?function(e){const t=[];for(const n in e){const r=e[n];for(const e in r)"url"===r[e]&&t.push(e)}return t}(n):this.#N(e.name)).every(n=>nt(e.params[n],t.params[n]))}const r=Object.keys(e.params),i=Object.keys(t.params);return r.length===i.length&&r.every(n=>n in t.params&&nt(e.params[n],t.params[n]))}#N(e){const t=this.#P.get(e);if(void 0!==t)return t;const n=this.#A.getUrlParams(e);return this.#P.set(e,n),n}},it={[i]:l,[a]:u,[c]:p,[s]:h,[d]:g,[o]:f},at=Object.keys(it),st="router.usePlugin",ot=class t{#O=new Set;#D=new Set;#A;#E=m;#R=null;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 "+typeof 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.")}(e)}static validateNoDuplicatePlugins(e,t){for(const n of e)if(t(n))throw new Error("[router.usePlugin] Plugin factory already registered. To re-register, first unsubscribe the existing plugin.")}setDependencies(e){this.#A=e}setLimits(e){this.#E=e,this.#E}setValidatorGetter(e){this.#R=e}count(){return this.#O.size}use(...t){if(this.#R?.()?.plugins.validateCountThresholds(this.#O.size+t.length),1===t.length){const n=t[0],r=this.#C(n);this.#O.add(n);let i=!1;const a=()=>{if(!i){i=!0,this.#O.delete(n),this.#D.delete(a);try{r()}catch(t){e.logger.error(st,"Error during cleanup:",t)}}};return this.#D.add(a),a}const n=this.#F(t),r=[];try{for(const e of n){const t=this.#C(e);r.push({factory:e,cleanup:t})}}catch(t){for(const{cleanup:t}of r)try{t()}catch(t){e.logger.error(st,"Cleanup error:",t)}throw t}for(const{factory:e}of r)this.#O.add(e);let i=!1;const a=()=>{if(!i){i=!0,this.#D.delete(a);for(const{factory:e}of r)this.#O.delete(e);for(const{cleanup:t}of r)try{t()}catch(t){e.logger.error(st,"Error during cleanup:",t)}}};return this.#D.add(a),a}getAll(){return[...this.#O]}has(e){return this.#O.has(e)}disposeAll(){for(const e of this.#D)e();this.#O.clear(),this.#D.clear()}#F(e){const t=new Set;for(const n of e)t.has(n)?this.#R?.()?.plugins.warnBatchDuplicates(e):t.add(n);return t}#C(e){const n=this.#A.compileFactory(e);t.validatePlugin(n),this.#R?.()?.plugins.validatePluginKeys(n),Object.freeze(n);const r=[];for(const e of at)e in n&&("function"==typeof n[e]?(r.push(this.#A.addEventListener(it[e],n[e])),"onStart"===e&&this.#A.canNavigate()&&this.#R?.()?.plugins.warnPluginAfterStart(e)):this.#R?.()?.plugins.warnPluginMethodType(e));return()=>{for(const e of r)e();"function"==typeof n.teardown&&n.teardown()}}},ct=class{#j=new Map;#L=new Map;#M=new Map;#I=new Map;#$=[this.#M,this.#I];#B=new Set;#x=new Set;#_=new Set;#A;#E=m;#R=null;setDependencies(e){this.#A=e}setLimits(e){this.#E=e,this.#E}setValidatorGetter(e){this.#R=e}getHandlerCount(e){return"activate"===e?this.#L.size:this.#j.size}addCanActivate(e,t,n=!1){n?this.#x.add(e):this.#x.delete(e);const r=this.#L.has(e);this.#U("activate",e,t,this.#L,this.#I,"canActivate",r)}addCanDeactivate(e,t,n=!1){n?this.#_.add(e):this.#_.delete(e);const r=this.#j.has(e);this.#U("deactivate",e,t,this.#j,this.#M,"canDeactivate",r)}clearCanActivate(e){this.#L.delete(e),this.#I.delete(e),this.#x.delete(e)}clearCanDeactivate(e){this.#j.delete(e),this.#M.delete(e),this.#_.delete(e)}clearAll(){this.#L.clear(),this.#I.clear(),this.#j.clear(),this.#M.clear(),this.#x.clear(),this.#_.clear()}clearDefinitionGuards(){for(const e of this.#x)this.#L.delete(e),this.#I.delete(e);for(const e of this.#_)this.#j.delete(e),this.#M.delete(e);this.#x.clear(),this.#_.clear()}getFactories(){const e={},t={};for(const[t,n]of this.#j)e[t]=n;for(const[e,n]of this.#L)t[e]=n;return[e,t]}getFunctions(){return this.#$}canNavigateTo(e,t,n,r){for(const t of e)if(!this.#k(this.#M,t,n,r,"canNavigateTo"))return!1;for(const e of t)if(!this.#k(this.#I,e,n,r,"canNavigateTo"))return!1;return!0}#U(e,t,n,r,i,a,s){s?this.#R?.()?.lifecycle.warnOverwrite(t,e,a):this.#R?.()?.lifecycle.validateCountThresholds(r.size+1,a);const o="boolean"==typeof n?function(e){const t=()=>e;return()=>t}(n):n;r.set(t,o),this.#B.add(t);try{const e=this.#A.compileFactory(o);if("function"!=typeof e)throw new TypeError(`[router.${a}] Factory must return a function, got ${typeof e}`);i.set(t,e)}catch(e){throw r.delete(t),e}finally{this.#B.delete(t)}}#k(e,t,n,r,i){const a=e.get(t);if(!a)return!0;try{const e=a(n,r);return"boolean"==typeof e?e:(this.#R?.()?.lifecycle.warnAsyncGuardSync(t,i),!1)}catch{return!1}}},dt=".",lt=[];function ut(e){const t=[];for(let n=e.length-1;n>=0;n--)t.push(e[n]);return t}function ht(e){const t=typeof e;return"string"===t||"number"===t||"boolean"===t}function ft(e,t,n){const r=t.meta?.params[e];if(!r||"object"!=typeof r)return!0;for(const e of Object.keys(r)){const r=t.params[e],i=n.params[e];if(ht(r)&&ht(i)&&String(r)!==String(i))return!1}return!0}Object.freeze(lt);var pt,gt,mt=new Map;function vt(e){const t=mt.get(e);if(t)return t;const n=function(e){if(!e)return[""];const t=e.indexOf(dt);if(-1===t)return[e];const n=e.indexOf(dt,t+1);if(-1===n)return[e.slice(0,t),e];const r=e.indexOf(dt,n+1);if(-1===r)return[e.slice(0,t),e.slice(0,n),e];return-1===e.indexOf(dt,r+1)?[e.slice(0,t),e.slice(0,n),e.slice(0,r),e]:function(e){const t=e.split(dt),n=t.length,r=[t[0]];let i=t[0].length;for(let a=1;a<n-1;a++)i+=1+t[a].length,r.push(e.slice(0,i));return r.push(e),r}(e)}(e);return Object.freeze(n),mt.set(e,n),n}var St,yt,wt=null,Tt=null;function bt(e,t){if(!t)return{intersection:"",toActivate:vt(e.name),toDeactivate:lt};if(void 0===e.meta?.params&&void 0===t.meta?.params)return{intersection:"",toActivate:vt(e.name),toDeactivate:ut(vt(t.name))};const n=vt(e.name),r=vt(t.name),i=function(e,t,n,r,i){for(let a=0;a<i;a++){const i=n[a];if(i!==r[a])return a;if(!ft(i,e,t))return a}return i}(e,t,n,r,Math.min(r.length,n.length));let a;if(i>=r.length)a=lt;else if(0===i&&1===r.length)a=r;else{a=[];for(let e=r.length-1;e>=i;e--)a.push(r[e])}const s=0===i?n:n.slice(i);return{intersection:i>0?r[i-1]:"",toDeactivate:a,toActivate:s}}function At(e,t,n){if(n)return bt(e,t);if(null!==wt&&e===pt&&t===gt)return wt;if(null!==Tt&&e===St&&t===yt)return Tt;const r=bt(e,t);return St=pt,yt=gt,Tt=wt,pt=e,gt=t,wt=r,r}function Pt(e,t){var n;return{name:t??(n=e.segments,n.at(-1)?.fullName??""),params:e.params,meta:e.meta}}var Nt=class{#G;#z;get#A(){return this.#G.depsStore}constructor(e=[],t){this.#G=function(e,t){const n=[],r=F(),i=Object.create(null),a=new Map,s=new Map;for(const t of e)n.push(j(t));const{tree:o,matcher:c}=Te(n,"",t);return Ee(e,r,i,a,s,void 0,""),{definitions:n,config:r,tree:o,matcher:c,resolvedForwardMap:Oe(r),routeCustomFields:i,rootPath:"",matcherOptions:t,depsStore:void 0,lifecycleNamespace:void 0,pendingCanActivate:a,pendingCanDeactivate:s,treeOperations:{commitTreeChanges:be,resetStore:Pe,nodeToDefinition:Se}}}(e,t)}static shouldUpdateNode(e){return(t,n)=>{if(!t||"object"!=typeof t||!("name"in t))throw new TypeError("[router.shouldUpdateNode] toState must be valid State object");if(t.transition?.reload)return!0;if(""===e&&!n)return!0;const{intersection:r,toActivate:i,toDeactivate:a}=At(t,n);return e===r||!!i.includes(e)||a.includes(e)}}setDependencies(e){this.#G.depsStore=e;for(const[t,n]of this.#G.pendingCanActivate)e.addActivateGuard(t,n);this.#G.pendingCanActivate.clear();for(const[t,n]of this.#G.pendingCanDeactivate)e.addDeactivateGuard(t,n);this.#G.pendingCanDeactivate.clear()}setLifecycleNamespace(e){this.#G.lifecycleNamespace=e}setRootPath(e){this.#G.rootPath=e,Ae(this.#G)}hasRoute(e){return this.#G.matcher.hasRoute(e)}clearRoutes(){Pe(this.#G)}buildPath(e,t,n){if(e===r)return"string"==typeof t?.path?t.path:"";const i=Object.hasOwn(this.#G.config.defaultParams,e)?{...this.#G.config.defaultParams[e],...t}:t??{},a="function"==typeof this.#G.config.encoders[e]?this.#G.config.encoders[e]({...i}):i;return this.#G.matcher.buildPath(e,a,this.#q(n))}matchPath(e,t){const n=t,r=this.#G.matcher.match(e);if(!r)return;const i=Pt(r),{name:a,params:s,meta:o}=i,c="function"==typeof this.#G.config.decoders[a]?this.#G.config.decoders[a](s):s,{name:d,params:l}=this.#A.forwardState(a,c);let u=e;if(n.rewritePathOnMatch){const e="function"==typeof this.#G.config.encoders[d]?this.#G.config.encoders[d]({...l}):l,t=n.trailingSlash;u=this.#G.matcher.buildPath(d,e,{trailingSlash:"never"===t||"always"===t?t:void 0,queryParamsMode:n.queryParamsMode})}return this.#A.makeState(d,l,u,o)}forwardState(e,t){if(Object.hasOwn(this.#G.config.forwardFnMap,e)){const n=this.#V(e,t),r=this.#G.config.forwardFnMap[e],i=this.#W(e,r,t);return{name:i,params:this.#V(i,n)}}const n=this.#G.resolvedForwardMap[e]??e;if(n!==e&&Object.hasOwn(this.#G.config.forwardFnMap,n)){const r=this.#V(e,t),i=this.#G.config.forwardFnMap[n],a=this.#W(n,i,t);return{name:a,params:this.#V(a,r)}}if(n!==e){const r=this.#V(e,t);return{name:n,params:this.#V(n,r)}}return{name:e,params:this.#V(e,t)}}buildStateResolved(e,t){const n=this.#G.matcher.getSegmentsByName(e);if(n)return Pt({segments:n,params:t,meta:this.#G.matcher.getMetaByName(e)},e)}isActiveRoute(e,t={},n=!1,r=!0){const i=this.#A.getState();if(!i)return!1;const a=i.name;if(a!==e&&!a.startsWith(`${e}.`)&&!e.startsWith(`${a}.`))return!1;const s=this.#G.config.defaultParams[e];if(n||a===e){const n=s?{...s,...t}:t;return this.#A.areStatesEqual({name:e,params:n,path:""},i,r)}const o=i.params;return!!function(e,t){for(const n in e)if(e[n]!==t[n])return!1;return!0}(t,o)&&(!s||function(e,t,n){for(const r in e)if(!(r in n)&&e[r]!==t[r])return!1;return!0}(s,o,t))}getMetaForState(e){return this.#G.matcher.hasRoute(e)?this.#G.matcher.getMetaByName(e):void 0}getUrlParams(e){const t=this.#G.matcher.getSegmentsByName(e);return t?function(e){const t=[];for(const n of e)for(const e of n.paramMeta.urlParams)t.push(e);return t}(t):[]}getStore(){return this.#G}#V(e,t){return Object.hasOwn(this.#G.config.defaultParams,e)?{...this.#G.config.defaultParams[e],...t}:t}#q(e){if(this.#z)return this.#z;const t=e?.trailingSlash;return this.#z=Object.freeze({trailingSlash:"never"===t||"always"===t?t:void 0,queryParamsMode:e?.queryParamsMode}),this.#z}#W(e,t,n){const r=new Set([e]);let i=t(this.#A.getDependency,n),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.#G.matcher.getSegmentsByName(i))throw new Error(`Route "${i}" does not exist`);if(r.has(i)){const e=[...r,i].join(" → ");throw new Error(`Circular forwardTo detected: ${e}`)}if(r.add(i),Object.hasOwn(this.#G.config.forwardFnMap,i)){i=(0,this.#G.config.forwardFnMap[i])(this.#A.getDependency,n),a++;continue}const e=this.#G.config.forwardMap[i];if(void 0===e)return i;i=e,a++}throw new Error("forwardTo exceeds maximum depth of 100")}},Ot=new P(n.ROUTER_NOT_STARTED),Dt=new P(n.ROUTE_NOT_FOUND),Et=new P(n.SAME_STATES),Rt=Promise.reject(Ot),Ct=Promise.reject(Dt),Ft=Promise.reject(Et);function jt(e,t){const{toState:i,fromState:a,opts:s,toDeactivate:o,toActivate:c,intersection:d}=t;if(i.name!==r&&!e.hasRoute(i.name)){const t=new P(n.ROUTE_NOT_FOUND,{routeName:i.name});throw e.sendTransitionFail(i,a,t),t}if(a)for(const n of o)!c.includes(n)&&t.canDeactivateFunctions.has(n)&&e.clearCanDeactivate(n);i.transition=function(e,t,n,r,i){const a={phase:"activating",reason:"success",segments:{deactivated:n,activated:r,intersection:i}};return void 0!==e?.name&&(a.from=e.name),void 0!==t.reload&&(a.reload=t.reload),void 0!==t.redirected&&(a.redirected=t.redirected),a}(a,s,o,c,d);const l=w(i);e.setState(l);const u=void 0===s.signal?s:function({signal:e,...t}){return t}(s);return e.sendTransitionDone(l,a,u),l}function Lt(e,t,r,i){t.code!==n.TRANSITION_CANCELLED&&t.code!==n.ROUTE_NOT_FOUND&&e.sendTransitionFail(r,i,t)}function Mt(e,t,r){if(e instanceof DOMException&&"AbortError"===e.name)throw new P(n.TRANSITION_CANCELLED);!function(e,t,n){if(e instanceof P)throw e.setCode(t),e;throw new P(t,function(e,t){const n={segment:t};if(e instanceof Error)return{...n,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[n,r]of Object.entries(e))It.has(n)||(t[n]=r);return{...n,...t}}return n}(e,n))}(e,t,r)}Rt.catch(()=>{}),Ct.catch(()=>{}),Ft.catch(()=>{});var It=new Set(["code","segment","path","redirect"]);async function $t(e,t,n){let r;try{r=await e}catch(e){return void Mt(e,t,n)}if(!r)throw new P(t,{segment:n})}async function Bt(e,t,r,i,a,s,o,c,d,l){await $t(d,r,l);for(let d=c;d<t.length;d++){if(!o())throw new P(n.TRANSITION_CANCELLED);const c=t[d],l=e.get(c);if(!l)continue;let u=!1;try{u=l(i,a,s)}catch(e){Mt(e,r,c)}if(u instanceof Promise)await $t(u,r,c);else if(!u)throw new P(r,{segment:c})}}function xt(e,t,r,i,a,s,o){for(const[c,d]of t.entries()){if(!o())throw new P(n.TRANSITION_CANCELLED);const l=e.get(d);if(!l)continue;let u=!1;try{u=l(i,a,s)}catch(e){Mt(e,r,d)}if(u instanceof Promise)return Bt(e,t,r,i,a,s,o,c+1,u,d);if(!u)throw new P(r,{segment:d})}}var _t=[r];Object.freeze(_t);var Ut={replace:!0};Object.freeze(Ut);var kt=class{lastSyncResolved=!1;lastSyncRejected=!1;#A;#Q=null;#H=0;setDependencies(e){this.#A=e}navigate(e,t,i){this.lastSyncResolved=!1;const a=this.#A;if(!a.canNavigate())return this.lastSyncRejected=!0,Rt;let s,o,c=!1,d=null;try{if(s=a.buildNavigateState(e,t),!s)return a.emitTransitionError(void 0,a.getState(),Dt),this.lastSyncRejected=!0,Ct;if(o=a.getState(),i=function(e,t){return t?.name!==r||e.replace?e:{...e,replace:!0}}(i,o),function(e,t,n){return!!e&&!t.reload&&!t.force&&e.path===n.path}(o,i,s))return a.emitTransitionError(s,o,Et),this.lastSyncRejected=!0,Ft;if(this.#J(),i.signal?.aborted)throw new P(n.TRANSITION_CANCELLED,{reason:i.signal.reason});const l=++this.#H;if(a.startTransition(s,o),c=!0,this.#H!==l)throw new P(n.TRANSITION_CANCELLED);const[u,h]=a.getLifecycleFunctions(),f=s.name===r,{toDeactivate:p,toActivate:g,intersection:m}=At(s,o,i.reload),v=o&&!i.forceDeactivate&&p.length>0,S=!f&&g.length>0;if(u.size>0||h.size>0){d=new AbortController,this.#Q=d;const e=()=>this.#H===l&&a.isActive(),t=function(e,t,r,i,a,s,o,c,d,l){if(a){const a=xt(e,r,n.CANNOT_DEACTIVATE,o,c,d,l);if(void 0!==a)return async function(e,t,r,i,a,s,o,c){if(await e,!c())throw new P(n.TRANSITION_CANCELLED);if(i){const e=xt(t,r,n.CANNOT_ACTIVATE,a,s,o,c);if(void 0!==e&&await e,!c())throw new P(n.TRANSITION_CANCELLED)}}(a,t,i,s,o,c,d,l)}if(!l())throw new P(n.TRANSITION_CANCELLED);if(s)return xt(t,i,n.CANNOT_ACTIVATE,o,c,d,l)}(u,h,p,g,!!v,S,s,o,d.signal,e);if(void 0!==t)return this.#Y(t,{toState:s,fromState:o,opts:i,toDeactivate:p,toActivate:g,intersection:m,canDeactivateFunctions:u},d,l);if(!e())throw new P(n.TRANSITION_CANCELLED);this.#K(d)}return this.lastSyncResolved=!0,Promise.resolve(jt(a,{toState:s,fromState:o,opts:i,toDeactivate:p,toActivate:g,intersection:m,canDeactivateFunctions:u}))}catch(e){return this.#X(e,d,c,s,o),Promise.reject(e)}}navigateToDefault(e){const t=this.#A;if(!t.getOptions().defaultRoute)return Promise.reject(new P(n.ROUTE_NOT_FOUND,{routeName:"defaultRoute not configured"}));const{route:r,params:i}=t.resolveDefault();return r?this.navigate(r,i,e):Promise.reject(new P(n.ROUTE_NOT_FOUND,{routeName:"defaultRoute resolved to empty"}))}navigateToNotFound(e){this.#J();const t=this.#A.getState(),n=t?vt(t.name).toReversed():[];Object.freeze(n);const i={deactivated:n,activated:_t,intersection:""};Object.freeze(i);const a={phase:"activating",...t&&{from:t.name},reason:"success",segments:i};Object.freeze(a);const s={name:r,params:{},path:e,transition:a};return Object.freeze(s),this.#A.setState(s),this.#A.emitTransitionSuccess(s,t,Ut),s}abortCurrentNavigation(){this.#Q?.abort(new P(n.TRANSITION_CANCELLED)),this.#Q=null}async#Y(e,t,r,i){const a=this.#A,s=()=>this.#H===i&&!r.signal.aborted&&a.isActive();try{if(t.opts.signal){if(t.opts.signal.aborted)throw new P(n.TRANSITION_CANCELLED,{reason:t.opts.signal.reason});t.opts.signal.addEventListener("abort",()=>{r.abort(t.opts.signal?.reason)},{once:!0,signal:r.signal})}if(await e,!s())throw new P(n.TRANSITION_CANCELLED);return jt(a,t)}catch(e){throw Lt(a,e,t.toState,t.fromState),e}finally{this.#K(r)}}#X(e,t,n,r,i){t&&this.#K(t),n&&r&&Lt(this.#A,e,r,i)}#K(e){e.abort(),this.#Q===e&&(this.#Q=null)}#J(){this.#A.isTransitioning()&&(e.logger.warn("router.navigate","Concurrent navigation detected on shared router instance. For SSR, use cloneRouter() to create isolated instance per request."),this.#Q?.abort(new P(n.TRANSITION_CANCELLED)),this.#A.cancelNavigation())}},Gt={replace:!0};Object.freeze(Gt);var zt=class{#A;setDependencies(e){this.#A=e}async start(e){const t=this.#A,r=t.getOptions(),i=t.matchPath(e);if(!i&&!r.allowNotFound){const r=new P(n.ROUTE_NOT_FOUND,{path:e});throw t.emitTransitionError(void 0,void 0,r),r}return t.completeStart(),i?t.navigate(i.name,i.params,Gt):t.navigateToNotFound(e)}stop(){this.#A.clearState()}},qt=class{#Z;#ee;#te;#ne;#re;#ie;constructor(e){this.#Z=e.routerFSM,this.#ee=e.emitter,this.#te=void 0,this.#ae()}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.#ee.emit(l)}emitRouterStop(){this.#ee.emit(u)}emitTransitionStart(e,t){this.#ee.emit(h,e,t)}emitTransitionSuccess(e,t,n){this.#ee.emit(p,e,t,n)}emitTransitionError(e,t,n){this.#ee.emit(g,e,t,n)}emitTransitionCancel(e,t){this.#ee.emit(f,e,t)}sendStart(){this.#Z.send(ze)}sendStop(){this.#Z.send(Je)}sendDispose(){this.#Z.send(Ye)}sendStarted(){this.#Z.send(qe)}sendNavigate(e,t){this.#te=e,this.#Z.forceState(ke),this.emitTransitionStart(e,t)}sendComplete(e,t,n={}){this.#Z.forceState(Ue),this.emitTransitionSuccess(e,t,n),this.#te===e&&(this.#te=void 0)}sendFail(e,t,n){const r=this.#te;this.#ne=e,this.#re=t,this.#ie=n,this.#Z.send(Qe),this.#te===r&&(this.#te=void 0)}sendFailSafe(e,t,n){this.isReady()?this.sendFail(e,t,n):this.emitTransitionError(e,t,n)}sendCancel(e,t){const n=this.#te;this.#ne=e,this.#re=t,this.#Z.send(He),this.#te===n&&(this.#te=void 0)}canBeginTransition(){return this.#Z.canSend(Ve)}canStart(){return this.#Z.canSend(ze)}canCancel(){return this.#Z.canSend(He)}isActive(){const e=this.#Z.getState();return e!==xe&&e!==Ge}isDisposed(){return this.#Z.getState()===Ge}isTransitioning(){return this.#Z.getState()===ke}isReady(){return this.#Z.getState()===Ue}getCurrentToState(){return this.#te}addEventListener(e,t){return this.#ee.on(e,t)}subscribe(e){return this.#ee.on(p,(t,n)=>{e({route:t,previousRoute:n})})}clearAll(){this.#ee.clearAll()}setLimits(e){this.#ee.setLimits(e)}sendCancelIfTransitioning(e){this.canCancel()&&this.sendCancel(this.#te,e)}#se(){this.emitTransitionError(this.#ne,this.#re,this.#ie)}#ae(){const e=this.#Z;e.on(_e,qe,()=>{this.emitRouterStart()}),e.on(Ue,Je,()=>{this.emitRouterStop()}),e.on(ke,He,()=>{const e=this.#ne;void 0!==e&&this.emitTransitionCancel(e,this.#re)}),e.on(_e,Qe,()=>{this.#se()}),e.on(Ue,Qe,()=>{this.#se()}),e.on(ke,Qe,()=>{this.#se()})}},Vt=new P(n.ROUTER_ALREADY_STARTED),Wt=new Set(["all","warn-error","error-only"]);var Qt=class{router;options;limits;dependenciesStore;state;routes;routeLifecycle;plugins;navigation;lifecycle;eventBus;constructor(e){this.router=e.router,this.options=e.options,this.limits=e.limits,this.dependenciesStore=e.dependenciesStore,this.state=e.state,this.routes=e.routes,this.routeLifecycle=e.routeLifecycle,this.plugins=e.plugins,this.navigation=e.navigation,this.lifecycle=e.lifecycle,this.eventBus=e.eventBus}wireLimits(){this.dependenciesStore.limits=this.limits,this.plugins.setLimits(this.limits),this.eventBus.setLimits({maxListeners:this.limits.maxListeners,warnListeners:this.limits.warnListeners,maxEventDepth:this.limits.maxEventDepth}),this.routeLifecycle.setLimits(this.limits)}wireRouteLifecycleDeps(){const e={compileFactory:this.createCompileFactory()};this.routeLifecycle.setDependencies(e),this.routeLifecycle.setValidatorGetter(()=>{try{return D(this.router).validator}catch{return null}})}wireRoutesDeps(){this.routes.setDependencies({addActivateGuard:(e,t)=>{this.routeLifecycle.addCanActivate(e,t,!0)},addDeactivateGuard:(e,t)=>{this.routeLifecycle.addCanDeactivate(e,t,!0)},makeState:(e,t,n,r)=>this.state.makeState(e,t,n,r),getState:()=>this.state.get(),areStatesEqual:(e,t,n)=>this.state.areStatesEqual(e,t,n),getDependency:e=>this.dependenciesStore.dependencies[e],forwardState:(e,t)=>{const n=D(this.router);return n.validator?.routes.validateStateBuilderArgs(e,t,"forwardState"),n.forwardState(e,t)}}),this.routes.setLifecycleNamespace(this.routeLifecycle)}wirePluginsDeps(){const e={addEventListener:(e,t)=>this.eventBus.addEventListener(e,t),canNavigate:()=>this.eventBus.canBeginTransition(),compileFactory:this.createCompileFactory()};this.plugins.setDependencies(e),this.plugins.setValidatorGetter(()=>{try{return D(this.router).validator}catch{return null}})}wireNavigationDeps(){this.navigation.setDependencies({getOptions:()=>this.options.get(),hasRoute:e=>this.routes.hasRoute(e),getState:()=>this.state.get(),setState:e=>{this.state.set(e)},buildNavigateState:(e,t)=>{const n=D(this.router);n.validator?.routes.validateStateBuilderArgs(e,t,"navigate");const{name:r,params:i}=n.forwardState(e,t),a=this.routes.getMetaForState(r);if(void 0===a)return;const s=n.buildPath(r,i);return this.state.makeState(r,i,s,a,void 0,!0)},resolveDefault:()=>{const e=this.options.get();return{route:et(e.defaultRoute,e=>this.dependenciesStore.dependencies[e]),params:et(e.defaultParams,e=>this.dependenciesStore.dependencies[e])}},startTransition:(e,t)=>{this.eventBus.sendNavigate(e,t)},cancelNavigation:()=>{const e=this.eventBus.getCurrentToState();void 0!==e&&this.eventBus.sendCancel(e,this.state.get())},sendTransitionDone:(e,t,n)=>{this.eventBus.sendComplete(e,t,n)},sendTransitionFail:(e,t,n)=>{this.eventBus.sendFail(e,t,n)},emitTransitionError:(e,t,n)=>{this.eventBus.sendFailSafe(e,t,n)},emitTransitionSuccess:(e,t,n)=>{this.eventBus.emitTransitionSuccess(e,t,n)},canNavigate:()=>this.eventBus.canBeginTransition(),getLifecycleFunctions:()=>this.routeLifecycle.getFunctions(),isActive:()=>this.router.isActive(),isTransitioning:()=>this.eventBus.isTransitioning(),clearCanDeactivate:e=>{this.routeLifecycle.clearCanDeactivate(e)}})}wireLifecycleDeps(){this.lifecycle.setDependencies({getOptions:()=>this.options.get(),navigate:(e,t,n)=>this.navigation.navigate(e,t,n),navigateToNotFound:e=>this.navigation.navigateToNotFound(e),clearState:()=>{this.state.set(void 0)},matchPath:e=>this.routes.matchPath(e,this.options.get()),completeStart:()=>{this.eventBus.sendStarted()},emitTransitionError:(e,t,n)=>{this.eventBus.sendFail(e,t,n)}})}wireStateDeps(){this.state.setDependencies({getDefaultParams:()=>this.routes.getStore().config.defaultParams,buildPath:(e,t)=>D(this.router).buildPath(e,t),getUrlParams:e=>this.routes.getUrlParams(e)})}createCompileFactory(){const{router:e,dependenciesStore:t}=this;return n=>n(e,e=>t.dependencies[e])}},Ht=Object.freeze({}),Jt=class r{#y;#E;#oe;#ce;#de;#le;#O;#ue;#he;#fe;constructor(n=[],r={},i={}){r.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(n=t.level)||!Wt.has(n)))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 n;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}(r.logger)&&(e.logger.configure(r.logger),delete r.logger),tt.validateOptionsIsObject(r),function(e){if(!e||"object"!=typeof e||e.constructor!==Object)throw new TypeError("dependencies must be a plain object");for(const t in e)if(Object.getOwnPropertyDescriptor(e,t)?.get)throw new TypeError(`dependencies cannot contain getters: "${t}"`)}(i),n.length>0&&C(n),this.#y=new tt(r),this.#E=function(e={}){return{...m,...e}}(r.limits),this.#oe=function(e={}){const t=Object.create(null);for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return{dependencies:t,limits:m}}(i),this.#ce=new rt,this.#de=new Nt(n,function(e){return{strictTrailingSlash:"strict"===e.trailingSlash,strictQueryParams:"strict"===e.queryParamsMode,urlParamsEncoding:e.urlParamsEncoding,queryParams:e.queryParams}}(this.#y.get())),this.#le=new ct,this.#O=new ot,this.#ue=new kt,this.#he=new zt;const a=new t.FSM(Ke),s=new Be({onListenerError:(t,n)=>{e.logger.error("Router",`Error in listener for ${t}:`,n)},onListenerWarn:(t,n)=>{e.logger.warn("router.addEventListener",`Event "${t}" has ${n} listeners — possible memory leak`)}});var o;this.#fe=new qt({routerFSM:a,emitter:s}),(o=new Qt({router:this,options:this.#y,limits:this.#E,dependenciesStore:this.#oe,state:this.#ce,routes:this.#de,routeLifecycle:this.#le,plugins:this.#O,navigation:this.#ue,lifecycle:this.#he,eventBus:this.#fe})).wireLimits(),o.wireRouteLifecycleDeps(),o.wireRoutesDeps(),o.wirePluginsDeps(),o.wireNavigationDeps(),o.wireLifecycleDeps(),o.wireStateDeps();const c=new Map;var d,l,u;d={makeState:(e,t,n,r,i)=>this.#ce.makeState(e,t,n,r,i),forwardState:R("forwardState",(e,t)=>this.#de.forwardState(e,t),c),buildStateResolved:(e,t)=>this.#de.buildStateResolved(e,t),matchPath:(e,t)=>this.#de.matchPath(e,t),getOptions:()=>this.#y.get(),addEventListener:(e,t)=>this.#fe.addEventListener(e,t),buildPath:R("buildPath",(e,t)=>this.#de.buildPath(e,t??v,this.#y.get()),c),start:(l=e=>this.#he.start(e),u=c,(...e)=>{const t=u.get("start");return t&&0!==t.length?E(t,l,e):l(...e)}),interceptors:c,setRootPath:e=>{this.#de.setRootPath(e)},getRootPath:()=>this.#de.getStore().rootPath,getTree:()=>this.#de.getStore().tree,isDisposed:()=>this.#fe.isDisposed(),validator:null,dependenciesGetStore:()=>this.#oe,cloneOptions:()=>({...this.#y.get()}),cloneDependencies:()=>({...this.#oe.dependencies}),getLifecycleFactories:()=>this.#le.getFactories(),getPluginFactories:()=>this.#O.getAll(),routeGetStore:()=>this.#de.getStore(),getStateName:()=>this.#ce.get()?.name,isTransitioning:()=>this.#fe.isTransitioning(),clearState:()=>{this.#ce.set(void 0)},setState:e=>{this.#ce.set(e)},routerExtensions:[]},O.set(this,d),this.isActiveRoute=this.isActiveRoute.bind(this),this.buildPath=this.buildPath.bind(this),this.getState=this.getState.bind(this),this.getPreviousState=this.getPreviousState.bind(this),this.areStatesEqual=this.areStatesEqual.bind(this),this.shouldUpdateNode=this.shouldUpdateNode.bind(this),this.isActive=this.isActive.bind(this),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this.dispose=this.dispose.bind(this),this.canNavigateTo=this.canNavigateTo.bind(this),this.usePlugin=this.usePlugin.bind(this),this.navigate=this.navigate.bind(this),this.navigateToDefault=this.navigateToDefault.bind(this),this.navigateToNotFound=this.navigateToNotFound.bind(this),this.subscribe=this.subscribe.bind(this)}isActiveRoute(t,n,r,i){return D(this).validator?.routes.validateIsActiveRouteArgs(t,n,r,i),D(this).validator?.routes.validateRouteName(t,"isActiveRoute"),""===t?(e.logger.warn("real-router",'isActiveRoute("") called with empty string. Root node is not considered a parent of any route.'),!1):this.#de.isActiveRoute(t,n,r,i)}buildPath(e,t){const n=D(this);return n.validator?.routes.validateBuildPathArgs(e),n.validator?.navigation.validateParams(t,"buildPath"),n.buildPath(e,t)}getState(){return this.#ce.get()}getPreviousState(){return this.#ce.getPrevious()}areStatesEqual(e,t,n=!0){return D(this).validator?.state.validateAreStatesEqualArgs(e,t,n),this.#ce.areStatesEqual(e,t,n)}shouldUpdateNode(e){return D(this).validator?.routes.validateShouldUpdateNodeArgs(e),Nt.shouldUpdateNode(e)}isActive(){return this.#fe.isActive()}start(e){if(!this.#fe.canStart())return Promise.reject(Vt);D(this).validator?.navigation.validateStartArgs(e),this.#fe.sendStart();const t=D(this).start(e).catch(e=>{throw this.#fe.isReady()&&(this.#he.stop(),this.#fe.sendStop()),e});return r.#pe(t),t}stop(){return this.#ue.abortCurrentNavigation(),this.#fe.sendCancelIfTransitioning(this.#ce.get()),this.#fe.isReady()||this.#fe.isTransitioning()?(this.#he.stop(),this.#fe.sendStop(),this):this}dispose(){if(this.#fe.isDisposed())return;this.#ue.abortCurrentNavigation(),this.#fe.sendCancelIfTransitioning(this.#ce.get()),(this.#fe.isReady()||this.#fe.isTransitioning())&&(this.#he.stop(),this.#fe.sendStop()),this.#fe.sendDispose(),this.#fe.clearAll(),this.#O.disposeAll();const e=D(this);for(const t of e.routerExtensions)for(const e of t.keys)delete this[e];e.routerExtensions.length=0,this.#de.clearRoutes(),this.#le.clearAll(),this.#ce.reset(),this.#oe.dependencies=Object.create(null),this.#ge()}canNavigateTo(e,t){const n=D(this);if(n.validator?.routes.validateRouteName(e,"canNavigateTo"),n.validator?.navigation.validateParams(t,"canNavigateTo"),!this.#de.hasRoute(e))return!1;const{name:r,params:i}=n.forwardState(e,t??{}),a=this.#ce.makeState(r,i),s=this.#ce.get(),{toDeactivate:o,toActivate:c}=At(a,s);return this.#le.canNavigateTo(o,c,a,s)}usePlugin(...e){const t=e.filter(Boolean);if(0===t.length)return()=>{};const n=D(this);n.validator?.plugins.validatePluginLimit(this.#O.count(),this.#E);for(const e of t)n.validator?.plugins.validateNoDuplicatePlugins(e,this.#O.getAll());return this.#O.use(...t)}subscribe(e){return qt.validateSubscribeListener(e),this.#fe.subscribe(e)}navigate(e,t,n){const i=D(this);i.validator?.navigation.validateNavigateArgs(e),i.validator?.navigation.validateParams(t,"navigate");const a=n??Ht;i.validator?.navigation.validateNavigationOptions(a,"navigate");const s=this.#ue.navigate(e,t??v,a);return this.#ue.lastSyncResolved?this.#ue.lastSyncResolved=!1:this.#ue.lastSyncRejected?this.#ue.lastSyncRejected=!1:r.#pe(s),s}navigateToDefault(e){const t=D(this);t.validator?.navigation.validateNavigateToDefaultArgs(e);const n=e??Ht;t.validator?.navigation.validateNavigationOptions(n,"navigateToDefault");const i=this.#ue.navigateToDefault(n);return this.#ue.lastSyncResolved?this.#ue.lastSyncResolved=!1:this.#ue.lastSyncRejected?this.#ue.lastSyncRejected=!1:r.#pe(i),i}navigateToNotFound(e){if(!this.#fe.isActive())throw new P(n.ROUTER_NOT_STARTED);if(void 0!==e&&"string"!=typeof e)throw new TypeError("[router.navigateToNotFound] path must be a string, got "+typeof e);const t=e??this.#ce.get().path;return this.#ue.navigateToNotFound(t)}static#me=t=>{t instanceof P&&(t.code===n.SAME_STATES||t.code===n.TRANSITION_CANCELLED||t.code===n.ROUTER_NOT_STARTED||t.code===n.ROUTE_NOT_FOUND)||e.logger.error("router.navigate","Unexpected navigation error",t)};static#pe(e){e.catch(r.#me)}#ge(){this.navigate=Yt,this.navigateToDefault=Yt,this.navigateToNotFound=Yt,this.start=Yt,this.stop=Yt,this.usePlugin=Yt,this.subscribe=Yt,this.canNavigateTo=Yt}};function Yt(){throw new P(n.ROUTER_DISPOSED)}exports.cloneRouter=function(e,t){const r=D(e);if(r.isDisposed())throw new P(n.ROUTER_DISPOSED);r.validator?.dependencies.validateCloneArgs(t);const i=r.routeGetStore(),a=[...i.tree.children.values()].map(e=>Se(e)),s=i.config,o=i.resolvedForwardMap,c=i.routeCustomFields,d=r.cloneOptions(),l=r.cloneDependencies(),[u,h]=r.getLifecycleFactories(),f=r.getPluginFactories(),p={...l,...t},g=new Jt(a,d,p),m=Me(g);for(const[e,t]of Object.entries(u))m.addDeactivateGuard(e,t);for(const[e,t]of Object.entries(h))m.addActivateGuard(e,t);f.length>0&&g.usePlugin(...f);const v=D(g).routeGetStore();return Object.assign(v.config.decoders,s.decoders),Object.assign(v.config.encoders,s.encoders),Object.assign(v.config.defaultParams,s.defaultParams),Object.assign(v.config.forwardMap,s.forwardMap),Object.assign(v.config.forwardFnMap,s.forwardFnMap),Object.assign(v.resolvedForwardMap,o),Object.assign(v.routeCustomFields,c),g},exports.getDependenciesApi=function(e){const t=D(e);return{get:e=>{t.validator?.dependencies.validateDependencyName(e,"getDependency");const n=t.dependenciesGetStore(),r=n.dependencies[e];return t.validator?.dependencies.validateDependencyExists(e,n),r},getAll:()=>({...t.dependenciesGetStore().dependencies}),set:(e,n)=>{N(t.isDisposed),t.validator?.dependencies.validateSetDependencyArgs(e,n,"setDependency"),function(e,t,n,r){if(void 0===n)return!1;if(Object.hasOwn(e.dependencies,t)){const i=e.dependencies[t],a=i!==n,s=Number.isNaN(i)&&Number.isNaN(n);a&&!s&&r?.dependencies.warnOverwrite(t,"setDependency")}else r?.dependencies.validateDependencyCount(e,"setDependency");e.dependencies[t]=n}(t.dependenciesGetStore(),e,n,t.validator)},setAll:e=>{N(t.isDisposed);const n=t.dependenciesGetStore();t.validator?.dependencies.validateDependenciesObject(e,"setDependencies"),t.validator?.dependencies.validateDependencyLimit(n,n.limits),function(e,t,n){const r=[];for(const i in t)void 0!==t[i]&&(Object.hasOwn(e.dependencies,i)?r.push(i):n?.dependencies.validateDependencyCount(e,"setDependencies"),e.dependencies[i]=t[i]);r.length>0&&n?.dependencies.warnBatchOverwrite(r,"setDependencies")}(n,e,t.validator)},remove:e=>{N(t.isDisposed),t.validator?.dependencies.validateDependencyName(e,"removeDependency");const n=t.dependenciesGetStore();Object.hasOwn(n.dependencies,e)||t.validator?.dependencies.warnRemoveNonExistent(e),delete n.dependencies[e]},reset:()=>{N(t.isDisposed),t.dependenciesGetStore().dependencies=Object.create(null)},has:e=>(t.validator?.dependencies.validateDependencyName(e,"hasDependency"),Object.hasOwn(t.dependenciesGetStore().dependencies,e))}},exports.getLifecycleApi=Me,exports.getPluginApi=function(e){const t=D(e);return{makeState:(e,n,r,i,a)=>(t.validator?.state.validateMakeStateArgs(e,n,r,a),t.makeState(e,n,r,i?.params,a)),buildState:(e,n)=>{t.validator?.routes.validateStateBuilderArgs(e,n,"buildState");const{name:r,params:i}=t.forwardState(e,n);return t.buildStateResolved(r,i)},forwardState:(e,n)=>(t.validator?.routes.validateStateBuilderArgs(e,n,"forwardState"),t.forwardState(e,n)),matchPath:e=>(t.validator?.routes.validateMatchPathArgs(e),t.matchPath(e,t.getOptions())),setRootPath:e=>{N(t.isDisposed),t.validator?.routes.validateSetRootPathArgs(e),t.setRootPath(e)},getRootPath:t.getRootPath,addEventListener:(e,n)=>(N(t.isDisposed),t.validator?.eventBus.validateListenerArgs(e,n),t.addEventListener(e,n)),buildNavigationState:(e,n={})=>{t.validator?.routes.validateStateBuilderArgs(e,n,"buildNavigationState");const{name:r,params:i}=t.forwardState(e,n),a=t.buildStateResolved(r,i);if(a)return t.makeState(a.name,a.params,t.buildPath(a.name,a.params),a.meta)},getOptions:t.getOptions,getTree:t.getTree,addInterceptor:(e,n)=>{N(t.isDisposed),t.validator?.plugins.validateAddInterceptorArgs(e,n);let r=t.interceptors.get(e);return r||(r=[],t.interceptors.set(e,r)),r.push(n),()=>{const e=r.indexOf(n);-1!==e&&r.splice(e,1)}},getRouteConfig:e=>{const n=t.routeGetStore();if(n.matcher.hasRoute(e))return n.routeCustomFields[e]},extendRouter:r=>{N(t.isDisposed);const i=Object.keys(r);for(const t of i)if(t in e)throw new P(n.PLUGIN_CONFLICT,{message:`Cannot extend router: property "${t}" already exists`});for(const t of i)e[t]=r[t];const a={keys:i};t.routerExtensions.push(a);let s=!1;return()=>{if(s)return;s=!0;for(const t of a.keys)delete e[t];const n=t.routerExtensions.indexOf(a);-1!==n&&t.routerExtensions.splice(n,1)}}}},exports.getRoutesApi=function(t){const n=D(t),r=n.routeGetStore();return{add:(e,t)=>{N(n.isDisposed);const i=Array.isArray(e)?e:[e],a=t?.parent;C(i,n.validator),void 0!==a&&n.validator?.routes.validateParentOption(a,r.tree),n.validator?.routes.throwIfInternalRouteInArray(i,"addRoute"),n.validator?.routes.validateAddRouteArgs(i),n.validator?.routes.validateRoutes(i,r),Fe(r,i,a)},remove:t=>{N(n.isDisposed),n.validator?.routes.validateRemoveRouteArgs(t),n.validator?.routes.throwIfInternalRoute(t,"removeRoute");const i=function(t,n,r){if(n){const r=n===t,i=n.startsWith(`${t}.`);if(r||i)return e.logger.warn("router.removeRoute",`Cannot remove route "${t}" — it is currently active${r?"":` (current: "${n}")`}. Navigate away first.`),!1}return r&&e.logger.warn("router.removeRoute",`Route "${t}" removed while navigation is in progress. This may cause unexpected behavior.`),!0}(t,n.getStateName(),n.isTransitioning());i&&(je(r,t)||e.logger.warn("router.removeRoute",`Route "${t}" not found. No changes made.`))},update:(t,i)=>{N(n.isDisposed),n.validator?.routes.validateUpdateRouteBasicArgs(t,i),n.validator?.routes.throwIfInternalRoute(t,"updateRoute");const{forwardTo:a,defaultParams:s,decodeParams:o,encodeParams:c,canActivate:d,canDeactivate:l}=i;n.validator?.routes.validateUpdateRoutePropertyTypes(t,i),n.isTransitioning()&&e.logger.error("router.updateRoute",`Updating route "${t}" while navigation is in progress. This may cause unexpected behavior.`),n.validator?.routes.validateUpdateRoute(t,i,r),function(e,t,n){if(void 0!==n.forwardTo&&(e.resolvedForwardMap=function(e,t,n){return null===t?(delete n.forwardMap[e],delete n.forwardFnMap[e]):"string"==typeof t?(delete n.forwardFnMap[e],n.forwardMap[e]=t):(delete n.forwardMap[e],n.forwardFnMap[e]=t),(e=>Oe(e))(n)}(t,n.forwardTo,e.config)),void 0!==n.defaultParams&&(null===n.defaultParams?delete e.config.defaultParams[t]:e.config.defaultParams[t]=n.defaultParams),void 0!==n.decodeParams)if(null===n.decodeParams)delete e.config.decoders[t];else{const r=n.decodeParams;e.config.decoders[t]=e=>r(e)??e}if(void 0!==n.encodeParams)if(null===n.encodeParams)delete e.config.encoders[t];else{const r=n.encodeParams;e.config.encoders[t]=e=>r(e)??e}}(r,t,{forwardTo:a,defaultParams:s,decodeParams:o,encodeParams:c}),void 0!==d&&(null===d?r.lifecycleNamespace.clearCanActivate(t):r.lifecycleNamespace.addCanActivate(t,d,!0)),void 0!==l&&(null===l?r.lifecycleNamespace.clearCanDeactivate(t):r.lifecycleNamespace.addCanDeactivate(t,l,!0))},clear:()=>{N(n.isDisposed),I(n.isTransitioning())&&(r.treeOperations.resetStore(r),r.lifecycleNamespace.clearAll(),n.clearState())},has:e=>(n.validator?.routes.validateRouteName(e,"hasRoute"),r.matcher.hasRoute(e)),get:e=>(n.validator?.routes.validateRouteName(e,"getRoute"),Le(r,e)),replace:e=>{N(n.isDisposed);const i=Array.isArray(e)?e:[e];if(!I(n.isTransitioning()))return;C(i,n.validator),n.validator?.routes.throwIfInternalRouteInArray(i,"replaceRoutes"),n.validator?.routes.validateAddRouteArgs(i),n.validator?.routes.validateRoutes(i,r);const a=t.getState()?.path;!function(e,t,n,r){Ne(e),e.lifecycleNamespace.clearDefinitionGuards();for(const n of t)e.definitions.push(j(n));if(Ee(t,e.config,e.routeCustomFields,e.pendingCanActivate,e.pendingCanDeactivate,e.depsStore,""),e.treeOperations.commitTreeChanges(e),void 0!==r){const e=n.matchPath(r,n.getOptions());e?n.setState(e):n.clearState()}}(r,i,n,a)}}};//# sourceMappingURL=api.js.map
|
|
1
|
+
var e=require("@real-router/logger"),t=require("@real-router/fsm"),n=Object.freeze({ROUTER_NOT_STARTED:"NOT_STARTED",NO_START_PATH_OR_STATE:"NO_START_PATH_OR_STATE",ROUTER_ALREADY_STARTED:"ALREADY_STARTED",ROUTE_NOT_FOUND:"ROUTE_NOT_FOUND",SAME_STATES:"SAME_STATES",CANNOT_DEACTIVATE:"CANNOT_DEACTIVATE",CANNOT_ACTIVATE:"CANNOT_ACTIVATE",TRANSITION_ERR:"TRANSITION_ERR",TRANSITION_CANCELLED:"CANCELLED",ROUTER_DISPOSED:"DISPOSED",PLUGIN_CONFLICT:"PLUGIN_CONFLICT"}),r="@@router/UNKNOWN_ROUTE",i="onStart",a="onStop",s="onTransitionStart",o="onTransitionCancel",c="onTransitionSuccess",d="onTransitionError",l="$start",u="$stop",h="$$start",f="$$cancel",p="$$success",g="$$error",m={maxDependencies:100,maxPlugins:50,maxListeners:1e4,warnListeners:1e3,maxEventDepth:5,maxLifecycleHandlers:200},v=Object.freeze({}),S=new WeakSet;function y(e){if(null!==e&&"object"==typeof e&&!Object.isFrozen(e))if(Object.freeze(e),Array.isArray(e))for(const t of e)y(t);else for(const t in e)y(e[t])}function w(e){return e?(S.has(e)||(y(e),S.add(e)),e):e}var T=new Set(Object.values(n)),b=new Set(["code","segment","path","redirect"]),A=new Set(["setCode","setErrorInstance","setAdditionalFields","hasField","getField","toJSON"]),P=class extends Error{segment;path;redirect;code;constructor(e,{message:t,segment:n,path:r,redirect:i,...a}={}){super(t??e),this.code=e,this.segment=n,this.path=r,this.redirect=i?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 n=structuredClone(e),r=new WeakSet;return function e(t){if(null===t||"object"!=typeof t)return;if(r.has(t))return;r.add(t),Object.freeze(t);const n=Array.isArray(t)?t:Object.values(t);for(const t of n)e(t)}(n),n}(i):void 0;for(const[e,t]of Object.entries(a)){if(b.has(e))throw new TypeError(`[RouterError] Cannot set reserved property "${e}"`);A.has(e)||(this[e]=t)}}setCode(e){this.code=e,T.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,n]of Object.entries(e)){if(b.has(t))throw new TypeError(`[RouterError.setAdditionalFields] Cannot set reserved property "${t}"`);A.has(t)||(this[t]=n)}}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 n in this)Object.hasOwn(this,n)&&!t.has(n)&&(e[n]=this[n]);return e}};function N(e){if(e())throw new P(n.ROUTER_DISPOSED)}var O=new WeakMap;function D(e){const t=O.get(e);if(!t)throw new TypeError("[real-router] Invalid router instance — not found in internals registry");return t}function E(e,t,n){let r=t;for(const t of e){const e=r;r=(...n)=>t(e,...n)}return r(...n)}function R(e,t,n){return(r,i)=>{const a=n.get(e);return a&&0!==a.length?E(a,t,[r,i]):t(r,i)}}function C(e,t){for(const n of e){if(null===n||"object"!=typeof n||Array.isArray(n))throw new TypeError("route must be a non-array object");t?.routes.guardRouteCallbacks(n),t?.routes.guardNoAsyncCallbacks(n);const e=n.children;e&&C(e,t)}}function F(){return{decoders:Object.create(null),encoders:Object.create(null),defaultParams:Object.create(null),forwardMap:Object.create(null),forwardFnMap:Object.create(null)}}function j(e){const t={name:e.name,path:e.path};return e.children&&(t.children=e.children.map(e=>j(e))),t}function L(e,t,n=""){for(let r=0;r<e.length;r++){const i=e[r],a=n?`${n}.${i.name}`:i.name;if(a===t)return e.splice(r,1),!0;if(i.children&&t.startsWith(`${a}.`)&&L(i.children,t,a))return!0}return!1}function M(e,t){for(const n of Object.keys(e))t(n)&&delete e[n]}function I(t){return!t||(e.logger.error("router.clearRoutes","Cannot clear routes while navigation is in progress. Wait for navigation to complete."),!1)}function $(e){return`(${e.replaceAll(/(^<|>$)/g,"")})`}var B=/([:*])([^/?<]+)(<[^>]+>)?(\?)?/g,x=/([:*][^/?<]+(?:<[^>]+>)?)\?(?=\/|$)/g,_=/\?(.+)$/,k=/[^\w!$'()*+,.:;|~-]/gu,U=/[^\w!$'()*+,.:;|~-]/u,G={default:e=>U.test(e)?e.replaceAll(k,e=>encodeURIComponent(e)):e,uri:encodeURI,uriComponent:encodeURIComponent,none:e=>e},z={default:decodeURIComponent,uri:decodeURI,uriComponent:decodeURIComponent,none:e=>e};function q(){return{staticChildren:Object.create(null),paramChild:void 0,splatChild:void 0,route:void 0,slashChildRoute:void 0}}function W(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function V(e){const t={};if(0===e.length)return t;const n=e.split("&");for(const e of n){const n=e.indexOf("=");-1===n?t[e]="":t[e.slice(0,n)]=e.slice(n+1)}return t}function Q(e){const t=[];for(const n of Object.keys(e)){const r=e[n],i=encodeURIComponent(n);t.push(""===r?i:`${i}=${encodeURIComponent(String(r))}`)}return t.join("&")}function H(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function J(e){let t=0;for(;t<e.length;)if("%"===e[t]){if(t+2>=e.length)return!1;const n=e.codePointAt(t+1)??0,r=e.codePointAt(t+2)??0;if(!H(n)||!H(r))return!1;t+=3}else t++;return!0}var Y=/<[^>]*>/g;function K(e,t,n,r,i){const a=""===t.fullName;a||r.push(t);const s=t.absolute,o=t.paramMeta.pathPattern,c=s&&o.startsWith("~")?o.slice(1):o,d=(s?c:o).replaceAll(Y,""),l=s?d:(h=d,""===(u=n)?h:""===h?u:u+h);var u,h;let f=i;a||(f=function(e,t,n,r,i,a){const s=(m=r,W(n)===W(m)),o=Object.freeze([...i]),c=function(e){const t={};for(const n of e)t[n.fullName]=n.paramTypeMap;return Object.freeze(t)}(o),d=W(n),l=function(e,t){const n=[];e.length>0&&n.push(...e);for(const e of t)e.paramMeta.queryParams.length>0&&n.push(...e.paramMeta.queryParams);return n}(e.rootQueryParams,i),u=function(e){const t=new Map;for(const n of e)for(const[e,r]of n.paramMeta.constraintPatterns)t.set(e,r);return t}(i),h=s?W(r):d,{buildStaticParts:f,buildParamSlots:p}=function(e,t,n){const r=new Set,i=new Set;for(const e of t){for(const t of e.paramMeta.urlParams)r.add(t);for(const t of e.paramMeta.spatParams)i.add(t)}if(0===r.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],r="?"===c[2];a.push(e.slice(d,c.index));const o=i.has(t);s.push({paramName:t,isOptional:r,encoder:o?e=>{const t=G[n],r=e.split("/");let i=t(r[0]);for(let e=1;e<r.length;e++)i+=`/${t(r[e])}`;return i}:G[n]}),d=c.index+c[0].length}return a.push(e.slice(d)),{buildStaticParts:a,buildParamSlots:s}}(h,s?i.slice(0,-1):i,e.options.urlParamsEncoding),g={name:t.fullName,parent:a,depth:i.length-1,matchSegments:o,meta:c,declaredQueryParams:l,declaredQueryParamsSet:new Set(l),hasTrailingSlash:n.length>1&&n.endsWith("/"),constraintPatterns:u,hasConstraints:u.size>0,buildStaticParts:f,buildParamSlots:p,buildParamNamesSet:new Set(p.map(e=>e.paramName))};var m;return e.routesByName.set(t.fullName,g),e.segmentsByName.set(t.fullName,o),e.metaByName.set(t.fullName,c),s?function(e,t,n){var r,i;r=t,(function(e,t,n){const r=W(n);if("/"===r||""===r)return t;let i=t,a=1;const s=r.length;for(;a<=s;){const t=r.indexOf("/",a),n=-1===t?s:t;if(n<=a)break;i=Z(e,i,r.slice(a,n)),a=n+1}return i}(i=e,i.root,n)).slashChildRoute=r;const a=W(n),s=e.options.caseSensitive?a:a.toLowerCase();e.staticCache.has(s)&&e.staticCache.set(s,t)}(e,g,r):function(e,t,n,r,i){if(function(e,t,n){const r=W(n);"/"!==r?X(e,e.root,r,1,t):e.root.route=t}(e,t,n),0===i.paramMeta.urlParams.length){const n=e.options.caseSensitive?r:r.toLowerCase();e.staticCache.set(n,t)}}(e,g,n,d,t),g}(e,t,l,s?"":n,r,i));for(const n of t.children.values())K(e,n,l,r,f);a||r.pop()}function X(e,t,n,r,i){const a=n.length;for(;r<=a;){const s=n.indexOf("/",r),o=-1===s?a:s,c=n.slice(r,o);if(c.endsWith("?")){const r=c.slice(1).replaceAll(Y,"").replace(/\?$/,"");return t.paramChild??={node:q(),name:r},X(e,t.paramChild.node,n,o+1,i),void(o>=a?t.route??=i:X(e,t,n,o+1,i))}t=Z(e,t,c),r=o+1}t.route=i}function Z(e,t,n){if(n.startsWith("*")){const e=n.slice(1);return t.splatChild??={node:q(),name:e},t.splatChild.node}if(n.startsWith(":")){const e=n.slice(1).replaceAll(Y,"").replace(/\?$/,"");return t.paramChild??={node:q(),name:e},t.paramChild.node}const r=e.options.caseSensitive?n:n.toLowerCase();return r in t.staticChildren||(t.staticChildren[r]=q()),t.staticChildren[r]}var ee=/[\u0080-\uFFFF]/,te=class{get options(){return this.#e}#e;#t=q();#n=new Map;#r=new Map;#i=new Map;#a=new Map;#s="";#o=[];constructor(e){this.#e={caseSensitive:e?.caseSensitive??!0,strictTrailingSlash:e?.strictTrailingSlash??!1,strictQueryParams:e?.strictQueryParams??!1,urlParamsEncoding:e?.urlParamsEncoding??"default",parseQueryString:e?.parseQueryString??V,buildQueryString:e?.buildQueryString??Q}}registerTree(e){this.#o=e.paramMeta.queryParams,K({root:this.#t,options:this.#e,routesByName:this.#n,segmentsByName:this.#r,metaByName:this.#i,staticCache:this.#a,rootQueryParams:this.#o},e,"",[],null)}match(e){const t=this.#c(e);if(!t)return;const[n,r,i]=t,a=this.#e.caseSensitive?r:r.toLowerCase(),s=this.#a.get(a);if(s){if(this.#e.strictTrailingSlash&&!this.#d(n,s))return;return this.#l(s,{},i)}const o={},c=this.#u(r,o);return!c||this.#e.strictTrailingSlash&&!this.#d(n,c)||c.hasConstraints&&!this.#h(o,c)||!this.#f(o)?void 0:this.#l(c,o,i)}buildPath(e,t,n){const r=this.#n.get(e);if(!r)throw new Error(`[SegmentMatcher.buildPath] '${e}' is not defined`);r.hasConstraints&&t&&this.#p(r,e,t);const i=this.#g(r,t),a=this.#m(i,n?.trailingSlash),s=this.#v(r,t,n?.queryParamsMode);return a+(s?`?${s}`:"")}getSegmentsByName(e){return this.#r.get(e)}getMetaByName(e){return this.#i.get(e)}hasRoute(e){return this.#n.has(e)}setRootPath(e){this.#s=e}#p(e,t,n){for(const[r,i]of e.constraintPatterns){const e=n[r];if(null!=e){const n="object"==typeof e?JSON.stringify(e):String(e);if(!i.pattern.test(n))throw new Error(`[SegmentMatcher.buildPath] '${t}' — param '${r}' value '${n}' does not match constraint '${i.constraint}'`)}}}#g(e,t){const n=e.buildStaticParts,r=e.buildParamSlots;if(0===r.length)return this.#s+n[0];let i=this.#s+n[0];for(const[e,a]of r.entries()){const r=t?.[a.paramName];if(null==r){if(!a.isOptional)throw new Error(`[SegmentMatcher.buildPath] Missing required param '${a.paramName}'`);i.length>1&&i.endsWith("/")&&(i=i.slice(0,-1)),i+=n[e+1];continue}const s="object"==typeof r?JSON.stringify(r):String(r);i+=a.encoder(s)+n[e+1]}return i}#m(e,t){return"always"!==t||e.endsWith("/")?"never"===t&&"/"!==e&&e.endsWith("/")?e.slice(0,-1):e:`${e}/`}#v(e,t,n){if(!t)return"";const r={};let i=!1;for(const n of e.declaredQueryParams)n in t&&(r[n]=t[n],i=!0);if("loose"===n)for(const n in t)!Object.hasOwn(t,n)||e.declaredQueryParamsSet.has(n)||e.buildParamNamesSet.has(n)||(r[n]=t[n],i=!0);return i?this.#e.buildQueryString(r):""}#c(e){if(""===e&&(e="/"),!e.startsWith("/"))return;const t=e.indexOf("#");if(-1!==t&&(e=e.slice(0,t)),ee.test(e))return;if(this.#s.length>0){if(!e.startsWith(this.#s))return;e=e.slice(this.#s.length)||"/"}const n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),i=-1===n?void 0:e.slice(n+1);return r.includes("//")?void 0:[r,W(r),i]}#l(e,t,n){if(void 0!==n){const r=this.#e.parseQueryString(n);if(this.#e.strictQueryParams){const t=e.declaredQueryParamsSet;for(const e of Object.keys(r))if(!t.has(e))return}for(const e of Object.keys(r))t[e]=r[e]}return{segments:e.matchSegments,params:t,meta:e.meta}}#d(e,t){return(e.length>1&&e.endsWith("/"))===t.hasTrailingSlash}#u(e,t){return 1===e.length?this.#t.slashChildRoute??this.#t.route:this.#S(this.#t,e,1,t)}#S(e,t,n,r){let i=e;const a=t.length;for(;n<=a;){const e=t.indexOf("/",n),s=-1===e?a:e,o=t.slice(n,s),c=this.#e.caseSensitive?o:o.toLowerCase();let d;if(c in i.staticChildren)d=i.staticChildren[c];else{if(!i.paramChild){if(i.splatChild){const e={},a=this.#S(i.splatChild.node,t,n,e);return a?(Object.assign(r,e),a):(r[i.splatChild.name]=t.slice(n),i.splatChild.node.route)}return}d=i.paramChild.node,r[i.paramChild.name]=o}i=d,n=s+1}return i.slashChildRoute??i.route}#f(e){const t=this.#e.urlParamsEncoding;if("none"===t)return!0;const n=z[t];for(const t in e){const r=e[t];if(r.includes("%")){if(!J(r))return!1;e[t]=n(r)}}return!0}#h(e,t){for(const[n,r]of t.constraintPatterns)if(!r.pattern.test(e[n]))return!1;return!0}},ne=e=>{const t=e.indexOf("%"),n=e.indexOf("+");if(-1===t&&-1===n)return e;const r=-1===n?e:e.split("+").join(" ");return-1===t?r:decodeURIComponent(r)},re=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)},ie={none:{encodeArray:(e,t)=>t.map(t=>`${e}=${re(t)}`).join("&")},brackets:{encodeArray:(e,t)=>t.map(t=>`${e}[]=${re(t)}`).join("&")},index:{encodeArray:(e,t)=>t.map((t,n)=>`${e}[${n}]=${re(t)}`).join("&")},comma:{encodeArray:(e,t)=>`${e}=${t.map(e=>re(e)).join(",")}`}},ae={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}},se={default:{encode:e=>e},hidden:{encode:()=>""}},oe=(e,t,n)=>({boolean:ae[t],null:se[n],array:ie[e]}),ce={arrayFormat:"none",booleanFormat:"none",nullFormat:"default",strategies:{boolean:ae.none,null:se.default,array:ie.none}},de=e=>{if(!e||void 0===e.arrayFormat&&void 0===e.booleanFormat&&void 0===e.nullFormat)return ce;const t=e.arrayFormat??"none",n=e.booleanFormat??"none",r=e.nullFormat??"default";return{arrayFormat:t,booleanFormat:n,nullFormat:r,strategies:oe(t,n,r)}},le=e=>encodeURIComponent(e),ue=(e,t,n)=>{const r=le(e);switch(typeof t){case"string":case"number":default:return`${r}=${le(t)}`;case"boolean":return n.strategies.boolean.encode(r,t);case"object":return null===t?n.strategies.null.encode(r):Array.isArray(t)?n.strategies.array.encodeArray(r,t):`${r}=${le(t)}`}};function he(e,t,n,r,i){const a=e.indexOf("=",t),s=-1!==a&&a<n,o=e.slice(t,s?a:n),{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 l,u,h,f,p;!function(e,t,n,r){const i=e[t];void 0===i?e[t]=r?[n]:n:Array.isArray(i)?i.push(n):e[t]=[i,n]}(r,ne(c),(l=e,u=a,h=n,f=s,p=i,p?((e,t)=>{if(void 0===e)return t.boolean.decodeUndefined();const n=t.boolean.decodeRaw(e);if(null!==n)return n;const r=ne(e);return t.boolean.decodeValue(r)})(f?l.slice(u+1,h):void 0,p):f?ne(l.slice(u+1,h)):null),d)}function fe(e,t){const n=e.path,r=n.startsWith("~"),i=r?n.slice(1):n,a={name:e.name,path:i,absolute:r,children:[],parent:t,nonAbsoluteChildren:[],fullName:""};if(e.children)for(const t of e.children){const e=fe(t,a);a.children.push(e)}return a}function pe(e,t){return e.endsWith("/")&&t.startsWith("/")?e+t.slice(1):e+t}function ge(e){const t=new Map;for(const n of e)t.set(n.name,n);return t}function me(e,t,n){const r=function(e){const t=[],n=[],r=[],i={},a=new Map,s=e.replaceAll(x,"$1"),o=_.exec(s);if(null!==o){const t=o[1].split("&");for(const e of t){const t=e.trim();t.length>0&&(n.push(t),i[t]="query")}e=e.slice(0,o.index)}let c;for(;null!==(c=B.exec(e));){const e=c[2],n=c[3];if("*"===c[1])r.push(e),t.push(e),i[e]="url";else if(t.push(e),i[e]="url",n){const t=`^${$(n)}$`;a.set(e,{pattern:new RegExp(t),constraint:n})}}return{urlParams:t,queryParams:n,spatParams:r,paramTypeMap:i,constraintPatterns:a,pathPattern:e}}(e.path),i=function(e){const t={};for(const n of e.urlParams)t[n]="url";for(const n of e.queryParams)t[n]="query";return t}(r),a={name:e.name,path:e.path,absolute:e.absolute,parent:t,children:void 0,paramMeta:r,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(e,t,n){const r=[],i=[];for(const a of e){const e=me(a,t,n);r.push(e),e.absolute||i.push(e)}return{childrenMap:ge(r),nonAbsoluteChildren:i}}(e.children,a,n);return a.children=o,a.nonAbsoluteChildren=c,a.staticPath=function(e){if(!e.path)return null;const{urlParams:t,queryParams:n,spatParams:r}=e.paramMeta;if(t.length>0||n.length>0||r.length>0)return null;const i=[];let a=e.parent;for(;a?.path;)i.unshift(a),a=a.parent;let s="";for(const e of i){const{urlParams:t,queryParams:n,spatParams:r}=e.paramMeta;if(t.length>0||n.length>0||r.length>0)return null;s=e.absolute?e.path:pe(s,e.path)}return e.absolute?e.path:pe(s,e.path)}(a),n&&(Object.freeze(c),Object.freeze(i),Object.freeze(a.children),Object.freeze(a)),a}function ve(e,t,n,r){return function(e,t){const n=[];return{add(e){return n.push(e),this},addMany(e){return n.push(...e),this},build:r=>function(e,t=!0){return me(e,null,t)}(function(e,t,n){const r=fe({name:e,path:t},null);for(const e of n){const t=fe(e,r);r.children.push(t)}return r}(e,t,n),!r?.skipFreeze)}}(e,t).addMany(n).build(r)}function Se(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=>Se(e))),t}function ye(e){const t=e?.queryParams;return new te({...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 n=(e=>{const t=e.indexOf("?");return-1===t?e:e.slice(t+1)})(e);if(""===n||"?"===n)return{};if(!t)return function(e){const t={};return function(e,t){let n=0;const r=e.length;for(;n<r;){let i=e.indexOf("&",n);-1===i&&(i=r),he(e,n,i,t),n=i+1}}(e,t),t}(n);const r=de(t),i={};let a=0;const s=n.length;for(;a<s;){let e=n.indexOf("&",a);-1===e&&(e=s),he(n,a,e,i,r.strategies),a=e+1}return i})(e,t),buildQueryString:e=>((e,t)=>{const n=Object.keys(e);if(0===n.length)return"";const r=de(t),i=[];for(const t of n){const n=e[t];if(void 0===n)continue;const a=ue(t,n,r);a&&i.push(a)}return i.join("&")})(e,t)})}function we(e,t,n=100){const r=new Set,i=[e];let a=e;for(;t[a];){const e=t[a];if(r.has(e)){const t=i.indexOf(e),n=[...i.slice(t),e];throw new Error(`Circular forwardTo: ${n.join(" → ")}`)}if(r.add(a),i.push(e),a=e,i.length>n)throw new Error(`forwardTo chain exceeds maximum depth (${n}): ${i.join(" → ")}`)}return a}function Te(e,t,n){const r=ve("",t,e),i=ye(n);return i.registerTree(r),{tree:r,matcher:i}}function be(e){const t=Te(e.definitions,e.rootPath,e.matcherOptions);e.tree=t.tree,e.matcher=t.matcher,e.resolvedForwardMap=Oe(e.config)}function Ae(e){const t=Te(e.definitions,e.rootPath,e.matcherOptions);e.tree=t.tree,e.matcher=t.matcher}function Pe(e){Ne(e),Ae(e)}function Ne(e){e.definitions.length=0,Object.assign(e.config,F()),e.resolvedForwardMap=Object.create(null),e.routeCustomFields=Object.create(null)}function Oe(e){const t=Object.create(null);for(const n of Object.keys(e.forwardMap))t[n]=we(n,e.forwardMap);return t}function De(t,n,r,i,a,s,o){const c=new Set(["name","path","children","canActivate","canDeactivate","forwardTo","encodeParams","decodeParams","defaultParams"]),d=Object.fromEntries(Object.entries(t).filter(([e])=>!c.has(e)));Object.keys(d).length>0&&(i[n]=d),t.canActivate&&(o?o.addActivateGuard(n,t.canActivate):a.set(n,t.canActivate)),t.canDeactivate&&(o?o.addDeactivateGuard(n,t.canDeactivate):s.set(n,t.canDeactivate)),t.forwardTo&&function(t,n,r){if(t.canActivate&&e.logger.warn("real-router",`Route "${n}" 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 "${n}" 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,r=t.forwardTo.toString().includes("__awaiter");if(e||r)throw new TypeError(`forwardTo callback cannot be async for route "${n}". Async functions break matchPath/buildPath.`)}"string"==typeof t.forwardTo?r.forwardMap[n]=t.forwardTo:r.forwardFnMap[n]=t.forwardTo}(t,n,r),t.decodeParams&&(r.decoders[n]=e=>t.decodeParams?.(e)??e),t.encodeParams&&(r.encoders[n]=e=>t.encodeParams?.(e)??e),t.defaultParams&&(r.defaultParams[n]=t.defaultParams)}function Ee(e,t,n,r,i,a,s=""){for(const o of e){const e=s?`${s}.${o.name}`:o.name;De(o,e,t,n,r,i,a),o.children&&Ee(o.children,t,n,r,i,a,e)}}function Re(e,t,n=""){for(const r of e){const e=n?`${n}.${r.name}`:r.name;if(e===t)return r;if(r.children&&t.startsWith(`${e}.`))return Re(r.children,t,e)}}function Ce(e,t,n,r){const i={name:e.name,path:e.path},a=n.forwardFnMap[t],s=n.forwardMap[t];void 0!==a?i.forwardTo=a:void 0!==s&&(i.forwardTo=s),t in n.defaultParams&&(i.defaultParams=n.defaultParams[t]),t in n.decoders&&(i.decodeParams=n.decoders[t]),t in n.encoders&&(i.encodeParams=n.encoders[t]);const[o,c]=r;return t in c&&(i.canActivate=c[t]),t in o&&(i.canDeactivate=o[t]),e.children&&(i.children=e.children.map(e=>Ce(e,`${t}.${e.name}`,n,r))),i}function Fe(e,t,n){if(n){const r=Re(e.definitions,n);r.children??=[];for(const e of t)r.children.push(j(e))}else for(const n of t)e.definitions.push(j(n));Ee(t,e.config,e.routeCustomFields,e.pendingCanActivate,e.pendingCanDeactivate,e.depsStore,n??""),e.treeOperations.commitTreeChanges(e)}function je(e,t){return!!L(e.definitions,t)&&(function(e,t,n,r){const i=t=>t===e||t.startsWith(`${e}.`);M(t.decoders,i),M(t.encoders,i),M(t.defaultParams,i),M(t.forwardMap,i),M(t.forwardFnMap,i),M(n,i),M(t.forwardMap,e=>i(t.forwardMap[e]));const[a,s]=r.getFactories();for(const e of Object.keys(s))i(e)&&r.clearCanActivate(e);for(const e of Object.keys(a))i(e)&&r.clearCanDeactivate(e)}(t,e.config,e.routeCustomFields,e.lifecycleNamespace),e.treeOperations.commitTreeChanges(e),!0)}function Le(e,t){const n=e.matcher.getSegmentsByName(t);if(!n)return;const r=n.at(-1),i=e.treeOperations.nodeToDefinition(r),a=e.lifecycleNamespace.getFactories();return Ce(i,t,e.config,a)}function Me(e){const t=D(e),n=t.routeGetStore().lifecycleNamespace;return{addActivateGuard(e,r){N(t.isDisposed),t.validator?.routes.validateRouteName(e,"addActivateGuard"),t.validator?.lifecycle.validateHandler(r,"addActivateGuard");const i=n.getHandlerCount("activate");t.validator?.lifecycle.validateHandlerLimit(i,t.dependenciesGetStore().limits,"canActivate"),n.addCanActivate(e,r)},addDeactivateGuard(e,r){N(t.isDisposed),t.validator?.routes.validateRouteName(e,"addDeactivateGuard"),t.validator?.lifecycle.validateHandler(r,"addDeactivateGuard");const i=n.getHandlerCount("deactivate");t.validator?.lifecycle.validateHandlerLimit(i,t.dependenciesGetStore().limits,"canDeactivate"),n.addCanDeactivate(e,r)},removeActivateGuard(e){N(t.isDisposed),t.validator?.routes.validateRouteName(e,"removeActivateGuard"),n.clearCanActivate(e)},removeDeactivateGuard(e){N(t.isDisposed),t.validator?.routes.validateRouteName(e,"removeDeactivateGuard"),n.clearCanDeactivate(e)}}}var Ie={maxListeners:0,warnListeners:0,maxEventDepth:0},$e=class extends Error{},Be=class{#e=new Map;#t=null;#i=Ie;#s;#n;constructor(e){e?.limits&&(this.#i=e.limits),this.#s=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.#i=e}on(e,t){const n=this.#r(e);if(n.has(t))throw new Error(`Duplicate listener for "${e}"`);const{maxListeners:r,warnListeners:i}=this.#i;if(0!==i&&n.size===i&&this.#n?.(e,i),0!==r&&n.size>=r)throw new Error(`Listener limit (${r}) reached for "${e}"`);return n.add(t),()=>{this.off(e,t)}}off(e,t){this.#e.get(e)?.delete(t)}emit(e,t,n,r,i){const a=this.#e.get(e);if(!a||0===a.size)return;const s=arguments.length-1;0!==this.#i.maxEventDepth?this.#a(a,e,s,t,n,r,i):this.#d(a,e,s,t,n,r,i)}clearAll(){this.#e.clear(),this.#t=null}listenerCount(e){return this.#e.get(e)?.size??0}#d(e,t,n,r,i,a,s){if(1===e.size){const[o]=e;try{this.#c(o,n,r,i,a,s)}catch(e){this.#s?.(t,e)}return}const o=[...e];for(const e of o)try{this.#c(e,n,r,i,a,s)}catch(e){this.#s?.(t,e)}}#c(e,t,n,r,i,a){switch(t){case 0:e();break;case 1:e(n);break;case 2:e(n,r);break;case 3:e(n,r,i);break;default:e(n,r,i,a)}}#a(e,t,n,r,i,a,s){this.#t??=new Map;const o=this.#t,c=o.get(t)??0;if(c>=this.#i.maxEventDepth)throw new $e(`Maximum recursion depth (${this.#i.maxEventDepth}) exceeded for event: ${t}`);try{o.set(t,c+1);const d=1===e.size?e:[...e];for(const e of d)try{this.#c(e,n,r,i,a,s)}catch(e){if(e instanceof $e)throw e;this.#s?.(t,e)}}finally{o.set(t,o.get(t)-1)}}#r(e){const t=this.#e.get(e);if(t)return t;const n=new Set;return this.#e.set(e,n),n}},xe="IDLE",_e="STARTING",ke="READY",Ue="TRANSITIONING",Ge="DISPOSED",ze="START",qe="STARTED",We="NAVIGATE",Ve="COMPLETE",Qe="FAIL",He="CANCEL",Je="STOP",Ye="DISPOSE",Ke={initial:xe,context:null,transitions:{[xe]:{[ze]:_e,[Ye]:Ge},[_e]:{[qe]:ke,[Qe]:xe},[ke]:{[We]:Ue,[Qe]:ke,[Je]:xe},[Ue]:{[We]:Ue,[Ve]:ke,[He]:ke,[Qe]:ke},[Ge]:{}}},Xe={defaultRoute:"",defaultParams:{},trailingSlash:"preserve",queryParamsMode:"loose",queryParams:{arrayFormat:"none",booleanFormat:"none",nullFormat:"default"},urlParamsEncoding:"default",allowNotFound:!0,rewritePathOnMatch:!0};function Ze(e){Object.freeze(e);for(const t of Object.keys(e)){const n=e[t];n&&"object"==typeof n&&n.constructor===Object&&Ze(n)}return e}function et(e,t){return"function"==typeof e?e(t):e}var tt=class{#y;constructor(e={}){this.#y=Ze({...Xe,...e})}static validateOptionsIsObject(e){!function(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new TypeError("[router.constructor] options must be a plain object")}(e)}get(){return this.#y}};function nt(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!nt(e[n],t[n]))return!1;return!0}return!1}var rt=new WeakMap;function it(e){return rt.get(e)}var at=class{#w=void 0;#T=void 0;#b;#A=new Map;get(){return this.#w}set(e){this.#T=this.#w,this.#w=e?w(e):void 0}getPrevious(){return this.#T}reset(){this.#w=void 0,this.#T=void 0,this.#A.clear()}setDependencies(e){this.#b=e}makeState(e,t,n,r,i){const a=this.#b.getDefaultParams();let s;s=Object.hasOwn(a,e)?{...a[e],...t}:t&&t!==v?{...t}:v;const o={name:e,params:s,path:n??this.#b.buildPath(e,t)};return r&&function(e,t){rt.set(e,t)}(o,r),i?o:w(o)}areStatesEqual(e,t,n=!0){if(!e||!t)return!!e==!!t;if(e.name!==t.name)return!1;if(n){const n=this.#P(e.name);for(const r of n)if(!nt(e.params[r],t.params[r]))return!1;return!0}const r=Object.keys(e.params),i=Object.keys(t.params);if(r.length!==i.length)return!1;for(const n of r)if(!(n in t.params)||!nt(e.params[n],t.params[n]))return!1;return!0}#P(e){const t=this.#A.get(e);if(void 0!==t)return t;const n=this.#b.getUrlParams(e);return this.#A.set(e,n),n}},st={[i]:l,[a]:u,[c]:p,[s]:h,[d]:g,[o]:f},ot=Object.keys(st),ct="router.usePlugin",dt=class t{#N=new Set;#O=new Set;#b;#D=m;#E=null;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 "+typeof 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.")}(e)}static validateNoDuplicatePlugins(e,t){for(const n of e)if(t(n))throw new Error("[router.usePlugin] Plugin factory already registered. To re-register, first unsubscribe the existing plugin.")}setDependencies(e){this.#b=e}setLimits(e){this.#D=e,this.#D}setValidatorGetter(e){this.#E=e}count(){return this.#N.size}use(...t){if(this.#E?.()?.plugins.validateCountThresholds(this.#N.size+t.length),1===t.length){const n=t[0],r=this.#R(n);this.#N.add(n);let i=!1;const a=()=>{if(!i){i=!0,this.#N.delete(n),this.#O.delete(a);try{r()}catch(t){e.logger.error(ct,"Error during cleanup:",t)}}};return this.#O.add(a),a}const n=this.#C(t),r=[];try{for(const e of n){const t=this.#R(e);r.push({factory:e,cleanup:t})}}catch(t){for(const{cleanup:t}of r)try{t()}catch(t){e.logger.error(ct,"Cleanup error:",t)}throw t}for(const{factory:e}of r)this.#N.add(e);let i=!1;const a=()=>{if(!i){i=!0,this.#O.delete(a);for(const{factory:e}of r)this.#N.delete(e);for(const{cleanup:t}of r)try{t()}catch(t){e.logger.error(ct,"Error during cleanup:",t)}}};return this.#O.add(a),a}getAll(){return[...this.#N]}has(e){return this.#N.has(e)}disposeAll(){for(const e of this.#O)e();this.#N.clear(),this.#O.clear()}#C(e){const t=new Set;for(const n of e)t.has(n)?this.#E?.()?.plugins.warnBatchDuplicates(e):t.add(n);return t}#R(e){const n=this.#b.compileFactory(e);t.validatePlugin(n),this.#E?.()?.plugins.validatePluginKeys(n),Object.freeze(n);const r=[];for(const e of ot)e in n&&("function"==typeof n[e]?(r.push(this.#b.addEventListener(st[e],n[e])),"onStart"===e&&this.#b.canNavigate()&&this.#E?.()?.plugins.warnPluginAfterStart(e)):this.#E?.()?.plugins.warnPluginMethodType(e));return()=>{for(const e of r)e();"function"==typeof n.teardown&&n.teardown()}}},lt=class{#F=new Map;#j=new Map;#L=new Map;#M=new Map;#I=[this.#L,this.#M];#$=new Set;#B=new Set;#x=new Set;#b;#D=m;#E=null;setDependencies(e){this.#b=e}setLimits(e){this.#D=e,this.#D}setValidatorGetter(e){this.#E=e}getHandlerCount(e){return"activate"===e?this.#j.size:this.#F.size}addCanActivate(e,t,n=!1){n?this.#B.add(e):this.#B.delete(e);const r=this.#j.has(e);this.#_("activate",e,t,this.#j,this.#M,"canActivate",r)}addCanDeactivate(e,t,n=!1){n?this.#x.add(e):this.#x.delete(e);const r=this.#F.has(e);this.#_("deactivate",e,t,this.#F,this.#L,"canDeactivate",r)}clearCanActivate(e){this.#j.delete(e),this.#M.delete(e),this.#B.delete(e)}clearCanDeactivate(e){this.#F.delete(e),this.#L.delete(e),this.#x.delete(e)}clearAll(){this.#j.clear(),this.#M.clear(),this.#F.clear(),this.#L.clear(),this.#B.clear(),this.#x.clear()}clearDefinitionGuards(){for(const e of this.#B)this.#j.delete(e),this.#M.delete(e);for(const e of this.#x)this.#F.delete(e),this.#L.delete(e);this.#B.clear(),this.#x.clear()}getFactories(){const e={},t={};for(const[t,n]of this.#F)e[t]=n;for(const[e,n]of this.#j)t[e]=n;return[e,t]}getFunctions(){return this.#I}canNavigateTo(e,t,n,r){for(const t of e)if(!this.#k(this.#L,t,n,r,"canNavigateTo"))return!1;for(const e of t)if(!this.#k(this.#M,e,n,r,"canNavigateTo"))return!1;return!0}#_(e,t,n,r,i,a,s){s?this.#E?.()?.lifecycle.warnOverwrite(t,e,a):this.#E?.()?.lifecycle.validateCountThresholds(r.size+1,a);const o="boolean"==typeof n?function(e){const t=()=>e;return()=>t}(n):n;r.set(t,o),this.#$.add(t);try{const e=this.#b.compileFactory(o);if("function"!=typeof e)throw new TypeError(`[router.${a}] Factory must return a function, got ${typeof e}`);i.set(t,e)}catch(e){throw r.delete(t),e}finally{this.#$.delete(t)}}#k(e,t,n,r,i){const a=e.get(t);if(!a)return!0;try{const e=a(n,r);return"boolean"==typeof e?e:(this.#E?.()?.lifecycle.warnAsyncGuardSync(t,i),!1)}catch{return!1}}},ut=".",ht=[];function ft(e){const t=[];for(let n=e.length-1;n>=0;n--)t.push(e[n]);return t}function pt(e){const t=typeof e;return"string"===t||"number"===t||"boolean"===t}function gt(e,t,n,r){const i=t[e];if(!i||"object"!=typeof i)return!0;for(const e of Object.keys(i)){const t=n.params[e],i=r.params[e];if(pt(t)&&pt(i)&&String(t)!==String(i))return!1}return!0}Object.freeze(ht);var mt,vt,St=new Map;function yt(e){const t=St.get(e);if(t)return t;const n=function(e){if(!e)return[""];const t=e.indexOf(ut);if(-1===t)return[e];const n=e.indexOf(ut,t+1);if(-1===n)return[e.slice(0,t),e];const r=e.indexOf(ut,n+1);if(-1===r)return[e.slice(0,t),e.slice(0,n),e];return-1===e.indexOf(ut,r+1)?[e.slice(0,t),e.slice(0,n),e.slice(0,r),e]:function(e){const t=e.split(ut),n=t.length,r=[t[0]];let i=t[0].length;for(let a=1;a<n-1;a++)i+=1+t[a].length,r.push(e.slice(0,i));return r.push(e),r}(e)}(e);return Object.freeze(n),St.set(e,n),n}var wt,Tt,bt=null,At=null;function Pt(e,t){if(null!==bt&&e===mt&&t===vt)return bt;if(null!==At&&e===wt&&t===Tt)return At;const n=function(e,t){if(!t)return{intersection:"",toActivate:yt(e.name),toDeactivate:ht};const n=it(e),r=it(t);if(!n&&!r)return{intersection:"",toActivate:yt(e.name),toDeactivate:ft(yt(t.name))};const i=yt(e.name),a=yt(t.name),s=function(e,t,n,r,i,a){for(let s=0;s<a;s++){const a=r[s];if(a!==i[s])return s;if(!gt(a,e,t,n))return s}return a}(n??r,e,t,i,a,Math.min(a.length,i.length));let o;if(s>=a.length)o=ht;else if(0===s&&1===a.length)o=a;else{o=[];for(let e=a.length-1;e>=s;e--)o.push(a[e])}const c=0===s?i:i.slice(s);return{intersection:s>0?a[s-1]:"",toDeactivate:o,toActivate:c}}(e,t);return wt=mt,Tt=vt,At=bt,mt=e,vt=t,bt=n,n}function Nt(e,t){var n;return{name:t??(n=e.segments,n.at(-1)?.fullName??""),params:e.params,meta:e.meta}}var Ot=class{#U;#G;get#b(){return this.#U.depsStore}constructor(e=[],t){this.#U=function(e,t){const n=[],r=F(),i=Object.create(null),a=new Map,s=new Map;for(const t of e)n.push(j(t));const{tree:o,matcher:c}=Te(n,"",t);return Ee(e,r,i,a,s,void 0,""),{definitions:n,config:r,tree:o,matcher:c,resolvedForwardMap:Oe(r),routeCustomFields:i,rootPath:"",matcherOptions:t,depsStore:void 0,lifecycleNamespace:void 0,pendingCanActivate:a,pendingCanDeactivate:s,treeOperations:{commitTreeChanges:be,resetStore:Pe,nodeToDefinition:Se}}}(e,t)}static shouldUpdateNode(e){return(t,n)=>{if(!t||"object"!=typeof t||!("name"in t))throw new TypeError("[router.shouldUpdateNode] toState must be valid State object");if(t.transition?.reload)return!0;if(""===e&&!n)return!0;const{intersection:r,toActivate:i,toDeactivate:a}=Pt(t,n);return e===r||!!i.includes(e)||a.includes(e)}}setDependencies(e){this.#U.depsStore=e;for(const[t,n]of this.#U.pendingCanActivate)e.addActivateGuard(t,n);this.#U.pendingCanActivate.clear();for(const[t,n]of this.#U.pendingCanDeactivate)e.addDeactivateGuard(t,n);this.#U.pendingCanDeactivate.clear()}setLifecycleNamespace(e){this.#U.lifecycleNamespace=e}setRootPath(e){this.#U.rootPath=e,Ae(this.#U)}hasRoute(e){return this.#U.matcher.hasRoute(e)}clearRoutes(){Pe(this.#U)}buildPath(e,t,n){if(e===r)return"string"==typeof t?.path?t.path:"";const i=Object.hasOwn(this.#U.config.defaultParams,e)?{...this.#U.config.defaultParams[e],...t}:t??{},a="function"==typeof this.#U.config.encoders[e]?this.#U.config.encoders[e]({...i}):i;return this.#U.matcher.buildPath(e,a,this.#z(n))}matchPath(e,t){const n=t,r=this.#U.matcher.match(e);if(!r)return;const i=Nt(r),{name:a,params:s,meta:o}=i,c="function"==typeof this.#U.config.decoders[a]?this.#U.config.decoders[a](s):s,{name:d,params:l}=this.#b.forwardState(a,c);let u=e;if(n.rewritePathOnMatch){const e="function"==typeof this.#U.config.encoders[d]?this.#U.config.encoders[d]({...l}):l,t=n.trailingSlash;u=this.#U.matcher.buildPath(d,e,{trailingSlash:"never"===t||"always"===t?t:void 0,queryParamsMode:n.queryParamsMode})}return this.#b.makeState(d,l,u,o)}forwardState(e,t){if(Object.hasOwn(this.#U.config.forwardFnMap,e)){const n=this.#q(e,t),r=this.#U.config.forwardFnMap[e],i=this.#W(e,r,t);return{name:i,params:this.#q(i,n)}}const n=this.#U.resolvedForwardMap[e]??e;if(n!==e&&Object.hasOwn(this.#U.config.forwardFnMap,n)){const r=this.#q(e,t),i=this.#U.config.forwardFnMap[n],a=this.#W(n,i,t);return{name:a,params:this.#q(a,r)}}if(n!==e){const r=this.#q(e,t);return{name:n,params:this.#q(n,r)}}return{name:e,params:this.#q(e,t)}}buildStateResolved(e,t){const n=this.#U.matcher.getSegmentsByName(e);if(n)return Nt({segments:n,params:t,meta:this.#U.matcher.getMetaByName(e)},e)}isActiveRoute(e,t={},n=!1,r=!0){const i=this.#b.getState();if(!i)return!1;const a=i.name;if(a!==e&&!a.startsWith(`${e}.`)&&!e.startsWith(`${a}.`))return!1;const s=this.#U.config.defaultParams[e];if(n||a===e){const n=s?{...s,...t}:t;return this.#b.areStatesEqual({name:e,params:n,path:""},i,r)}const o=i.params;return!!function(e,t){for(const n in e)if(e[n]!==t[n])return!1;return!0}(t,o)&&(!s||function(e,t,n){for(const r in e)if(!(r in n)&&e[r]!==t[r])return!1;return!0}(s,o,t))}getMetaForState(e){return this.#U.matcher.hasRoute(e)?this.#U.matcher.getMetaByName(e):void 0}getUrlParams(e){const t=this.#U.matcher.getSegmentsByName(e);return t?function(e){const t=[];for(const n of e)for(const e of n.paramMeta.urlParams)t.push(e);return t}(t):[]}getStore(){return this.#U}#q(e,t){return Object.hasOwn(this.#U.config.defaultParams,e)?{...this.#U.config.defaultParams[e],...t}:t}#z(e){if(this.#G)return this.#G;const t=e?.trailingSlash;return this.#G=Object.freeze({trailingSlash:"never"===t||"always"===t?t:void 0,queryParamsMode:e?.queryParamsMode}),this.#G}#W(e,t,n){const r=new Set([e]);let i=t(this.#b.getDependency,n),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.#U.matcher.getSegmentsByName(i))throw new Error(`Route "${i}" does not exist`);if(r.has(i)){const e=[...r,i].join(" → ");throw new Error(`Circular forwardTo detected: ${e}`)}if(r.add(i),Object.hasOwn(this.#U.config.forwardFnMap,i)){i=(0,this.#U.config.forwardFnMap[i])(this.#b.getDependency,n),a++;continue}const e=this.#U.config.forwardMap[i];if(void 0===e)return i;i=e,a++}throw new Error("forwardTo exceeds maximum depth of 100")}},Dt=new P(n.ROUTER_NOT_STARTED),Et=new P(n.ROUTE_NOT_FOUND),Rt=new P(n.SAME_STATES),Ct=Promise.reject(Dt),Ft=Promise.reject(Et),jt=Promise.reject(Rt);function Lt(e,t){const{toState:i,fromState:a,opts:s,toDeactivate:o,toActivate:c,intersection:d}=t;if(i.name!==r&&!e.hasRoute(i.name)){const t=new P(n.ROUTE_NOT_FOUND,{routeName:i.name});throw e.sendTransitionFail(i,a,t),t}if(a)for(const n of o)!c.includes(n)&&t.canDeactivateFunctions.has(n)&&e.clearCanDeactivate(n);i.transition=function(e,t,n,r,i){const a={phase:"activating",reason:"success",segments:{deactivated:n,activated:r,intersection:i}};return void 0!==e?.name&&(a.from=e.name),void 0!==t.reload&&(a.reload=t.reload),void 0!==t.redirected&&(a.redirected=t.redirected),a}(a,s,o,c,d);const l=w(i);e.setState(l);const u=void 0===s.signal?s:function({signal:e,...t}){return t}(s);return e.sendTransitionDone(l,a,u),l}function Mt(e,t,r,i){t.code!==n.TRANSITION_CANCELLED&&t.code!==n.ROUTE_NOT_FOUND&&e.sendTransitionFail(r,i,t)}function It(e,t,r){if(e instanceof DOMException&&"AbortError"===e.name)throw new P(n.TRANSITION_CANCELLED);!function(e,t,n){if(e instanceof P)throw e.setCode(t),e;throw new P(t,function(e,t){const n={segment:t};if(e instanceof Error)return{...n,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[n,r]of Object.entries(e))$t.has(n)||(t[n]=r);return{...n,...t}}return n}(e,n))}(e,t,r)}Ct.catch(()=>{}),Ft.catch(()=>{}),jt.catch(()=>{});var $t=new Set(["code","segment","path","redirect"]);async function Bt(e,t,n){let r;try{r=await e}catch(e){return void It(e,t,n)}if(!r)throw new P(t,{segment:n})}async function xt(e,t,r,i,a,s,o,c,d,l){await Bt(d,r,l);for(let d=c;d<t.length;d++){if(!o())throw new P(n.TRANSITION_CANCELLED);const c=t[d],l=e.get(c);if(!l)continue;let u=!1;try{u=l(i,a,s)}catch(e){It(e,r,c)}if(u instanceof Promise)await Bt(u,r,c);else if(!u)throw new P(r,{segment:c})}}function _t(e,t,r,i,a,s,o){for(const[c,d]of t.entries()){if(!o())throw new P(n.TRANSITION_CANCELLED);const l=e.get(d);if(!l)continue;let u=!1;try{u=l(i,a,s)}catch(e){It(e,r,d)}if(u instanceof Promise)return xt(e,t,r,i,a,s,o,c+1,u,d);if(!u)throw new P(r,{segment:d})}}var kt=[r];Object.freeze(kt);var Ut={replace:!0};Object.freeze(Ut);var Gt=class{lastSyncResolved=!1;lastSyncRejected=!1;#b;#V=null;#Q=0;setDependencies(e){this.#b=e}navigate(e,t,i){this.lastSyncResolved=!1;const a=this.#b;if(!a.canNavigate())return this.lastSyncRejected=!0,Ct;let s,o,c=!1,d=null;try{if(s=a.buildNavigateState(e,t),!s)return a.emitTransitionError(void 0,a.getState(),Et),this.lastSyncRejected=!0,Ft;if(o=a.getState(),i=function(e,t){return t?.name!==r||e.replace?e:{...e,replace:!0}}(i,o),function(e,t,n){return!!e&&!t.reload&&!t.force&&e.path===n.path}(o,i,s))return a.emitTransitionError(s,o,Rt),this.lastSyncRejected=!0,jt;if(this.#H(),i.signal?.aborted)throw new P(n.TRANSITION_CANCELLED,{reason:i.signal.reason});const l=++this.#Q;if(a.startTransition(s,o),c=!0,this.#Q!==l)throw new P(n.TRANSITION_CANCELLED);const[u,h]=a.getLifecycleFunctions(),f=s.name===r,{toDeactivate:p,toActivate:g,intersection:m}=Pt(s,o),v=o&&!i.forceDeactivate&&p.length>0,S=!f&&g.length>0;if(u.size>0||h.size>0){d=new AbortController,this.#V=d;const e=()=>this.#Q===l&&a.isActive(),t=function(e,t,r,i,a,s,o,c,d,l){if(a){const a=_t(e,r,n.CANNOT_DEACTIVATE,o,c,d,l);if(void 0!==a)return async function(e,t,r,i,a,s,o,c){if(await e,!c())throw new P(n.TRANSITION_CANCELLED);if(i){const e=_t(t,r,n.CANNOT_ACTIVATE,a,s,o,c);if(void 0!==e&&await e,!c())throw new P(n.TRANSITION_CANCELLED)}}(a,t,i,s,o,c,d,l)}if(!l())throw new P(n.TRANSITION_CANCELLED);if(s)return _t(t,i,n.CANNOT_ACTIVATE,o,c,d,l)}(u,h,p,g,!!v,S,s,o,d.signal,e);if(void 0!==t)return this.#J(t,{toState:s,fromState:o,opts:i,toDeactivate:p,toActivate:g,intersection:m,canDeactivateFunctions:u},d,l);if(!e())throw new P(n.TRANSITION_CANCELLED);this.#Y(d)}return this.lastSyncResolved=!0,Promise.resolve(Lt(a,{toState:s,fromState:o,opts:i,toDeactivate:p,toActivate:g,intersection:m,canDeactivateFunctions:u}))}catch(e){return this.#K(e,d,c,s,o),Promise.reject(e)}}navigateToDefault(e){const t=this.#b;if(!t.getOptions().defaultRoute)return Promise.reject(new P(n.ROUTE_NOT_FOUND,{routeName:"defaultRoute not configured"}));const{route:r,params:i}=t.resolveDefault();return r?this.navigate(r,i,e):Promise.reject(new P(n.ROUTE_NOT_FOUND,{routeName:"defaultRoute resolved to empty"}))}navigateToNotFound(e){this.#H();const t=this.#b.getState(),n=t?yt(t.name).toReversed():[];Object.freeze(n);const i={deactivated:n,activated:kt,intersection:""};Object.freeze(i);const a={phase:"activating",...t&&{from:t.name},reason:"success",segments:i};Object.freeze(a);const s={name:r,params:{},path:e,transition:a};return Object.freeze(s),this.#b.setState(s),this.#b.emitTransitionSuccess(s,t,Ut),s}abortCurrentNavigation(){this.#V?.abort(new P(n.TRANSITION_CANCELLED)),this.#V=null}async#J(e,t,r,i){const a=this.#b,s=()=>this.#Q===i&&!r.signal.aborted&&a.isActive();try{if(t.opts.signal){if(t.opts.signal.aborted)throw new P(n.TRANSITION_CANCELLED,{reason:t.opts.signal.reason});t.opts.signal.addEventListener("abort",()=>{r.abort(t.opts.signal?.reason)},{once:!0,signal:r.signal})}if(await e,!s())throw new P(n.TRANSITION_CANCELLED);return Lt(a,t)}catch(e){throw Mt(a,e,t.toState,t.fromState),e}finally{this.#Y(r)}}#K(e,t,n,r,i){t&&this.#Y(t),n&&r&&Mt(this.#b,e,r,i)}#Y(e){e.abort(),this.#V===e&&(this.#V=null)}#H(){this.#b.isTransitioning()&&(e.logger.warn("router.navigate","Concurrent navigation detected on shared router instance. For SSR, use cloneRouter() to create isolated instance per request."),this.#V?.abort(new P(n.TRANSITION_CANCELLED)),this.#b.cancelNavigation())}},zt={replace:!0};Object.freeze(zt);var qt=class{#b;setDependencies(e){this.#b=e}async start(e){const t=this.#b,r=t.getOptions(),i=t.matchPath(e);if(!i&&!r.allowNotFound){const r=new P(n.ROUTE_NOT_FOUND,{path:e});throw t.emitTransitionError(void 0,void 0,r),r}return t.completeStart(),i?t.navigate(i.name,i.params,zt):t.navigateToNotFound(e)}stop(){this.#b.clearState()}},Wt=class{#X;#Z;#ee;#te;#ne;#re;constructor(e){this.#X=e.routerFSM,this.#Z=e.emitter,this.#ee=void 0,this.#ie()}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.#Z.emit(l)}emitRouterStop(){this.#Z.emit(u)}emitTransitionStart(e,t){this.#Z.emit(h,e,t)}emitTransitionSuccess(e,t,n){this.#Z.emit(p,e,t,n)}emitTransitionError(e,t,n){this.#Z.emit(g,e,t,n)}emitTransitionCancel(e,t){this.#Z.emit(f,e,t)}sendStart(){this.#X.send(ze)}sendStop(){this.#X.send(Je)}sendDispose(){this.#X.send(Ye)}sendStarted(){this.#X.send(qe)}sendNavigate(e,t){this.#ee=e,this.#X.forceState(Ue),this.emitTransitionStart(e,t)}sendComplete(e,t,n={}){this.#X.forceState(ke),this.emitTransitionSuccess(e,t,n),this.#ee===e&&(this.#ee=void 0)}sendFail(e,t,n){const r=this.#ee;this.#te=e,this.#ne=t,this.#re=n,this.#X.send(Qe),this.#ee===r&&(this.#ee=void 0)}sendFailSafe(e,t,n){this.isReady()?this.sendFail(e,t,n):this.emitTransitionError(e,t,n)}sendCancel(e,t){const n=this.#ee;this.#te=e,this.#ne=t,this.#X.send(He),this.#ee===n&&(this.#ee=void 0)}canBeginTransition(){return this.#X.canSend(We)}canStart(){return this.#X.canSend(ze)}canCancel(){return this.#X.canSend(He)}isActive(){const e=this.#X.getState();return e!==xe&&e!==Ge}isDisposed(){return this.#X.getState()===Ge}isTransitioning(){return this.#X.getState()===Ue}isReady(){return this.#X.getState()===ke}getCurrentToState(){return this.#ee}addEventListener(e,t){return this.#Z.on(e,t)}subscribe(e){return this.#Z.on(p,(t,n)=>{e({route:t,previousRoute:n})})}clearAll(){this.#Z.clearAll()}setLimits(e){this.#Z.setLimits(e)}sendCancelIfTransitioning(e){this.canCancel()&&this.sendCancel(this.#ee,e)}#ae(){this.emitTransitionError(this.#te,this.#ne,this.#re)}#ie(){const e=this.#X;e.on(_e,qe,()=>{this.emitRouterStart()}),e.on(ke,Je,()=>{this.emitRouterStop()}),e.on(Ue,He,()=>{const e=this.#te;void 0!==e&&this.emitTransitionCancel(e,this.#ne)}),e.on(_e,Qe,()=>{this.#ae()}),e.on(ke,Qe,()=>{this.#ae()}),e.on(Ue,Qe,()=>{this.#ae()})}},Vt=new P(n.ROUTER_ALREADY_STARTED),Qt=new Set(["all","warn-error","error-only"]);var Ht=class{router;options;limits;dependenciesStore;state;routes;routeLifecycle;plugins;navigation;lifecycle;eventBus;constructor(e){this.router=e.router,this.options=e.options,this.limits=e.limits,this.dependenciesStore=e.dependenciesStore,this.state=e.state,this.routes=e.routes,this.routeLifecycle=e.routeLifecycle,this.plugins=e.plugins,this.navigation=e.navigation,this.lifecycle=e.lifecycle,this.eventBus=e.eventBus}wireLimits(){this.dependenciesStore.limits=this.limits,this.plugins.setLimits(this.limits),this.eventBus.setLimits({maxListeners:this.limits.maxListeners,warnListeners:this.limits.warnListeners,maxEventDepth:this.limits.maxEventDepth}),this.routeLifecycle.setLimits(this.limits)}wireRouteLifecycleDeps(){const e={compileFactory:this.createCompileFactory()};this.routeLifecycle.setDependencies(e),this.routeLifecycle.setValidatorGetter(()=>{try{return D(this.router).validator}catch{return null}})}wireRoutesDeps(){this.routes.setDependencies({addActivateGuard:(e,t)=>{this.routeLifecycle.addCanActivate(e,t,!0)},addDeactivateGuard:(e,t)=>{this.routeLifecycle.addCanDeactivate(e,t,!0)},makeState:(e,t,n,r)=>this.state.makeState(e,t,n,r),getState:()=>this.state.get(),areStatesEqual:(e,t,n)=>this.state.areStatesEqual(e,t,n),getDependency:e=>this.dependenciesStore.dependencies[e],forwardState:(e,t)=>{const n=D(this.router);return n.validator?.routes.validateStateBuilderArgs(e,t,"forwardState"),n.forwardState(e,t)}}),this.routes.setLifecycleNamespace(this.routeLifecycle)}wirePluginsDeps(){const e={addEventListener:(e,t)=>this.eventBus.addEventListener(e,t),canNavigate:()=>this.eventBus.canBeginTransition(),compileFactory:this.createCompileFactory()};this.plugins.setDependencies(e),this.plugins.setValidatorGetter(()=>{try{return D(this.router).validator}catch{return null}})}wireNavigationDeps(){this.navigation.setDependencies({getOptions:()=>this.options.get(),hasRoute:e=>this.routes.hasRoute(e),getState:()=>this.state.get(),setState:e=>{this.state.set(e)},buildNavigateState:(e,t)=>{const n=D(this.router);n.validator?.routes.validateStateBuilderArgs(e,t,"navigate");const{name:r,params:i}=n.forwardState(e,t),a=this.routes.getMetaForState(r);if(void 0===a)return;const s=n.buildPath(r,i);return this.state.makeState(r,i,s,a,!0)},resolveDefault:()=>{const e=this.options.get();return{route:et(e.defaultRoute,e=>this.dependenciesStore.dependencies[e]),params:et(e.defaultParams,e=>this.dependenciesStore.dependencies[e])}},startTransition:(e,t)=>{this.eventBus.sendNavigate(e,t)},cancelNavigation:()=>{const e=this.eventBus.getCurrentToState();void 0!==e&&this.eventBus.sendCancel(e,this.state.get())},sendTransitionDone:(e,t,n)=>{this.eventBus.sendComplete(e,t,n)},sendTransitionFail:(e,t,n)=>{this.eventBus.sendFail(e,t,n)},emitTransitionError:(e,t,n)=>{this.eventBus.sendFailSafe(e,t,n)},emitTransitionSuccess:(e,t,n)=>{this.eventBus.emitTransitionSuccess(e,t,n)},canNavigate:()=>this.eventBus.canBeginTransition(),getLifecycleFunctions:()=>this.routeLifecycle.getFunctions(),isActive:()=>this.router.isActive(),isTransitioning:()=>this.eventBus.isTransitioning(),clearCanDeactivate:e=>{this.routeLifecycle.clearCanDeactivate(e)}})}wireLifecycleDeps(){this.lifecycle.setDependencies({getOptions:()=>this.options.get(),navigate:(e,t,n)=>this.navigation.navigate(e,t,n),navigateToNotFound:e=>this.navigation.navigateToNotFound(e),clearState:()=>{this.state.set(void 0)},matchPath:e=>this.routes.matchPath(e,this.options.get()),completeStart:()=>{this.eventBus.sendStarted()},emitTransitionError:(e,t,n)=>{this.eventBus.sendFail(e,t,n)}})}wireStateDeps(){this.state.setDependencies({getDefaultParams:()=>this.routes.getStore().config.defaultParams,buildPath:(e,t)=>D(this.router).buildPath(e,t),getUrlParams:e=>this.routes.getUrlParams(e)})}createCompileFactory(){const{router:e,dependenciesStore:t}=this;return n=>n(e,e=>t.dependencies[e])}},Jt=Object.freeze({}),Yt=class r{#y;#D;#se;#oe;#ce;#de;#N;#le;#ue;#he;constructor(n=[],r={},i={}){r.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(n=t.level)||!Qt.has(n)))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 n;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}(r.logger)&&(e.logger.configure(r.logger),delete r.logger),tt.validateOptionsIsObject(r),function(e){if(!e||"object"!=typeof e||e.constructor!==Object)throw new TypeError("dependencies must be a plain object");for(const t in e)if(Object.getOwnPropertyDescriptor(e,t)?.get)throw new TypeError(`dependencies cannot contain getters: "${t}"`)}(i),n.length>0&&C(n),this.#y=new tt(r),this.#D=function(e={}){return{...m,...e}}(r.limits),this.#se=function(e={}){const t=Object.create(null);for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return{dependencies:t,limits:m}}(i),this.#oe=new at,this.#ce=new Ot(n,function(e){return{strictTrailingSlash:"strict"===e.trailingSlash,strictQueryParams:"strict"===e.queryParamsMode,urlParamsEncoding:e.urlParamsEncoding,queryParams:e.queryParams}}(this.#y.get())),this.#de=new lt,this.#N=new dt,this.#le=new Gt,this.#ue=new qt;const a=new t.FSM(Ke),s=new Be({onListenerError:(t,n)=>{e.logger.error("Router",`Error in listener for ${t}:`,n)},onListenerWarn:(t,n)=>{e.logger.warn("router.addEventListener",`Event "${t}" has ${n} listeners — possible memory leak`)}});var o;this.#he=new Wt({routerFSM:a,emitter:s}),(o=new Ht({router:this,options:this.#y,limits:this.#D,dependenciesStore:this.#se,state:this.#oe,routes:this.#ce,routeLifecycle:this.#de,plugins:this.#N,navigation:this.#le,lifecycle:this.#ue,eventBus:this.#he})).wireLimits(),o.wireRouteLifecycleDeps(),o.wireRoutesDeps(),o.wirePluginsDeps(),o.wireNavigationDeps(),o.wireLifecycleDeps(),o.wireStateDeps();const c=new Map;var d,l,u;d={makeState:(e,t,n,r)=>this.#oe.makeState(e,t,n,r),forwardState:R("forwardState",(e,t)=>this.#ce.forwardState(e,t),c),buildStateResolved:(e,t)=>this.#ce.buildStateResolved(e,t),matchPath:(e,t)=>this.#ce.matchPath(e,t),getOptions:()=>this.#y.get(),addEventListener:(e,t)=>this.#he.addEventListener(e,t),buildPath:R("buildPath",(e,t)=>this.#ce.buildPath(e,t??v,this.#y.get()),c),start:(l=e=>this.#ue.start(e),u=c,(...e)=>{const t=u.get("start");return t&&0!==t.length?E(t,l,e):l(...e)}),interceptors:c,setRootPath:e=>{this.#ce.setRootPath(e)},getRootPath:()=>this.#ce.getStore().rootPath,getTree:()=>this.#ce.getStore().tree,isDisposed:()=>this.#he.isDisposed(),validator:null,dependenciesGetStore:()=>this.#se,cloneOptions:()=>({...this.#y.get()}),cloneDependencies:()=>({...this.#se.dependencies}),getLifecycleFactories:()=>this.#de.getFactories(),getPluginFactories:()=>this.#N.getAll(),routeGetStore:()=>this.#ce.getStore(),getStateName:()=>this.#oe.get()?.name,isTransitioning:()=>this.#he.isTransitioning(),clearState:()=>{this.#oe.set(void 0)},setState:e=>{this.#oe.set(e)},routerExtensions:[]},O.set(this,d),this.isActiveRoute=this.isActiveRoute.bind(this),this.buildPath=this.buildPath.bind(this),this.getState=this.getState.bind(this),this.getPreviousState=this.getPreviousState.bind(this),this.areStatesEqual=this.areStatesEqual.bind(this),this.shouldUpdateNode=this.shouldUpdateNode.bind(this),this.isActive=this.isActive.bind(this),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this.dispose=this.dispose.bind(this),this.canNavigateTo=this.canNavigateTo.bind(this),this.usePlugin=this.usePlugin.bind(this),this.navigate=this.navigate.bind(this),this.navigateToDefault=this.navigateToDefault.bind(this),this.navigateToNotFound=this.navigateToNotFound.bind(this),this.subscribe=this.subscribe.bind(this)}isActiveRoute(t,n,r,i){return D(this).validator?.routes.validateIsActiveRouteArgs(t,n,r,i),D(this).validator?.routes.validateRouteName(t,"isActiveRoute"),""===t?(e.logger.warn("real-router",'isActiveRoute("") called with empty string. Root node is not considered a parent of any route.'),!1):this.#ce.isActiveRoute(t,n,r,i)}buildPath(e,t){const n=D(this);return n.validator?.routes.validateBuildPathArgs(e),n.validator?.navigation.validateParams(t,"buildPath"),n.buildPath(e,t)}getState(){return this.#oe.get()}getPreviousState(){return this.#oe.getPrevious()}areStatesEqual(e,t,n=!0){return D(this).validator?.state.validateAreStatesEqualArgs(e,t,n),this.#oe.areStatesEqual(e,t,n)}shouldUpdateNode(e){return D(this).validator?.routes.validateShouldUpdateNodeArgs(e),Ot.shouldUpdateNode(e)}isActive(){return this.#he.isActive()}start(e){if(!this.#he.canStart())return Promise.reject(Vt);D(this).validator?.navigation.validateStartArgs(e),this.#he.sendStart();const t=D(this).start(e).catch(e=>{throw this.#he.isReady()&&(this.#ue.stop(),this.#he.sendStop()),e});return r.#fe(t),t}stop(){return this.#le.abortCurrentNavigation(),this.#he.sendCancelIfTransitioning(this.#oe.get()),this.#he.isReady()||this.#he.isTransitioning()?(this.#ue.stop(),this.#he.sendStop(),this):this}dispose(){if(this.#he.isDisposed())return;this.#le.abortCurrentNavigation(),this.#he.sendCancelIfTransitioning(this.#oe.get()),(this.#he.isReady()||this.#he.isTransitioning())&&(this.#ue.stop(),this.#he.sendStop()),this.#he.sendDispose(),this.#he.clearAll(),this.#N.disposeAll();const e=D(this);for(const t of e.routerExtensions)for(const e of t.keys)delete this[e];e.routerExtensions.length=0,this.#ce.clearRoutes(),this.#de.clearAll(),this.#oe.reset(),this.#se.dependencies=Object.create(null),this.#pe()}canNavigateTo(e,t){const n=D(this);if(n.validator?.routes.validateRouteName(e,"canNavigateTo"),n.validator?.navigation.validateParams(t,"canNavigateTo"),!this.#ce.hasRoute(e))return!1;const{name:r,params:i}=n.forwardState(e,t??{}),a=this.#oe.makeState(r,i),s=this.#oe.get(),{toDeactivate:o,toActivate:c}=Pt(a,s);return this.#de.canNavigateTo(o,c,a,s)}usePlugin(...e){const t=e.filter(Boolean);if(0===t.length)return()=>{};const n=D(this);n.validator?.plugins.validatePluginLimit(this.#N.count(),this.#D);for(const e of t)n.validator?.plugins.validateNoDuplicatePlugins(e,this.#N.getAll());return this.#N.use(...t)}subscribe(e){return Wt.validateSubscribeListener(e),this.#he.subscribe(e)}navigate(e,t,n){const i=D(this);i.validator?.navigation.validateNavigateArgs(e),i.validator?.navigation.validateParams(t,"navigate");const a=n??Jt;i.validator?.navigation.validateNavigationOptions(a,"navigate");const s=this.#le.navigate(e,t??v,a);return this.#le.lastSyncResolved?this.#le.lastSyncResolved=!1:this.#le.lastSyncRejected?this.#le.lastSyncRejected=!1:r.#fe(s),s}navigateToDefault(e){const t=D(this);t.validator?.navigation.validateNavigateToDefaultArgs(e);const n=e??Jt;t.validator?.navigation.validateNavigationOptions(n,"navigateToDefault");const i=this.#le.navigateToDefault(n);return this.#le.lastSyncResolved?this.#le.lastSyncResolved=!1:this.#le.lastSyncRejected?this.#le.lastSyncRejected=!1:r.#fe(i),i}navigateToNotFound(e){if(!this.#he.isActive())throw new P(n.ROUTER_NOT_STARTED);if(void 0!==e&&"string"!=typeof e)throw new TypeError("[router.navigateToNotFound] path must be a string, got "+typeof e);const t=e??this.#oe.get().path;return this.#le.navigateToNotFound(t)}static#ge=t=>{t instanceof P&&(t.code===n.SAME_STATES||t.code===n.TRANSITION_CANCELLED||t.code===n.ROUTER_NOT_STARTED||t.code===n.ROUTE_NOT_FOUND)||e.logger.error("router.navigate","Unexpected navigation error",t)};static#fe(e){e.catch(r.#ge)}#pe(){this.navigate=Kt,this.navigateToDefault=Kt,this.navigateToNotFound=Kt,this.start=Kt,this.stop=Kt,this.usePlugin=Kt,this.subscribe=Kt,this.canNavigateTo=Kt}};function Kt(){throw new P(n.ROUTER_DISPOSED)}exports.cloneRouter=function(e,t){const r=D(e);if(r.isDisposed())throw new P(n.ROUTER_DISPOSED);r.validator?.dependencies.validateCloneArgs(t);const i=r.routeGetStore(),a=[...i.tree.children.values()].map(e=>Se(e)),s=i.config,o=i.resolvedForwardMap,c=i.routeCustomFields,d=r.cloneOptions(),l=r.cloneDependencies(),[u,h]=r.getLifecycleFactories(),f=r.getPluginFactories(),p={...l,...t},g=new Yt(a,d,p),m=Me(g);for(const[e,t]of Object.entries(u))m.addDeactivateGuard(e,t);for(const[e,t]of Object.entries(h))m.addActivateGuard(e,t);f.length>0&&g.usePlugin(...f);const v=D(g).routeGetStore();return Object.assign(v.config.decoders,s.decoders),Object.assign(v.config.encoders,s.encoders),Object.assign(v.config.defaultParams,s.defaultParams),Object.assign(v.config.forwardMap,s.forwardMap),Object.assign(v.config.forwardFnMap,s.forwardFnMap),Object.assign(v.resolvedForwardMap,o),Object.assign(v.routeCustomFields,c),g},exports.getDependenciesApi=function(e){const t=D(e);return{get:e=>{t.validator?.dependencies.validateDependencyName(e,"getDependency");const n=t.dependenciesGetStore(),r=n.dependencies[e];return t.validator?.dependencies.validateDependencyExists(e,n),r},getAll:()=>({...t.dependenciesGetStore().dependencies}),set:(e,n)=>{N(t.isDisposed),t.validator?.dependencies.validateSetDependencyArgs(e,n,"setDependency"),function(e,t,n,r){if(void 0===n)return!1;if(Object.hasOwn(e.dependencies,t)){const i=e.dependencies[t],a=i!==n,s=Number.isNaN(i)&&Number.isNaN(n);a&&!s&&r?.dependencies.warnOverwrite(t,"setDependency")}else r?.dependencies.validateDependencyCount(e,"setDependency");e.dependencies[t]=n}(t.dependenciesGetStore(),e,n,t.validator)},setAll:e=>{N(t.isDisposed);const n=t.dependenciesGetStore();t.validator?.dependencies.validateDependenciesObject(e,"setDependencies"),t.validator?.dependencies.validateDependencyLimit(n,n.limits),function(e,t,n){const r=[];for(const i in t)void 0!==t[i]&&(Object.hasOwn(e.dependencies,i)?r.push(i):n?.dependencies.validateDependencyCount(e,"setDependencies"),e.dependencies[i]=t[i]);r.length>0&&n?.dependencies.warnBatchOverwrite(r,"setDependencies")}(n,e,t.validator)},remove:e=>{N(t.isDisposed),t.validator?.dependencies.validateDependencyName(e,"removeDependency");const n=t.dependenciesGetStore();Object.hasOwn(n.dependencies,e)||t.validator?.dependencies.warnRemoveNonExistent(e),delete n.dependencies[e]},reset:()=>{N(t.isDisposed),t.dependenciesGetStore().dependencies=Object.create(null)},has:e=>(t.validator?.dependencies.validateDependencyName(e,"hasDependency"),Object.hasOwn(t.dependenciesGetStore().dependencies,e))}},exports.getLifecycleApi=Me,exports.getPluginApi=function(e){const t=D(e);return{makeState:(e,n,r,i)=>(t.validator?.state.validateMakeStateArgs(e,n,r),t.makeState(e,n,r,i?.params)),buildState:(e,n)=>{t.validator?.routes.validateStateBuilderArgs(e,n,"buildState");const{name:r,params:i}=t.forwardState(e,n);return t.buildStateResolved(r,i)},forwardState:(e,n)=>(t.validator?.routes.validateStateBuilderArgs(e,n,"forwardState"),t.forwardState(e,n)),matchPath:e=>(t.validator?.routes.validateMatchPathArgs(e),t.matchPath(e,t.getOptions())),setRootPath:e=>{N(t.isDisposed),t.validator?.routes.validateSetRootPathArgs(e),t.setRootPath(e)},getRootPath:t.getRootPath,addEventListener:(e,n)=>(N(t.isDisposed),t.validator?.eventBus.validateListenerArgs(e,n),t.addEventListener(e,n)),buildNavigationState:(e,n={})=>{t.validator?.routes.validateStateBuilderArgs(e,n,"buildNavigationState");const{name:r,params:i}=t.forwardState(e,n),a=t.buildStateResolved(r,i);if(a)return t.makeState(a.name,a.params,t.buildPath(a.name,a.params),a.meta)},getOptions:t.getOptions,getTree:t.getTree,addInterceptor:(e,n)=>{N(t.isDisposed),t.validator?.plugins.validateAddInterceptorArgs(e,n);let r=t.interceptors.get(e);return r||(r=[],t.interceptors.set(e,r)),r.push(n),()=>{const e=r.indexOf(n);-1!==e&&r.splice(e,1)}},getRouteConfig:e=>{const n=t.routeGetStore();if(n.matcher.hasRoute(e))return n.routeCustomFields[e]},extendRouter:r=>{N(t.isDisposed);const i=Object.keys(r);for(const t of i)if(t in e)throw new P(n.PLUGIN_CONFLICT,{message:`Cannot extend router: property "${t}" already exists`});for(const t of i)e[t]=r[t];const a={keys:i};t.routerExtensions.push(a);let s=!1;return()=>{if(s)return;s=!0;for(const t of a.keys)delete e[t];const n=t.routerExtensions.indexOf(a);-1!==n&&t.routerExtensions.splice(n,1)}}}},exports.getRoutesApi=function(t){const n=D(t),r=n.routeGetStore();return{add:(e,t)=>{N(n.isDisposed);const i=Array.isArray(e)?e:[e],a=t?.parent;C(i,n.validator),void 0!==a&&n.validator?.routes.validateParentOption(a,r.tree),n.validator?.routes.throwIfInternalRouteInArray(i,"addRoute"),n.validator?.routes.validateAddRouteArgs(i),n.validator?.routes.validateRoutes(i,r),Fe(r,i,a)},remove:t=>{N(n.isDisposed),n.validator?.routes.validateRemoveRouteArgs(t),n.validator?.routes.throwIfInternalRoute(t,"removeRoute");const i=function(t,n,r){if(n){const r=n===t,i=n.startsWith(`${t}.`);if(r||i)return e.logger.warn("router.removeRoute",`Cannot remove route "${t}" — it is currently active${r?"":` (current: "${n}")`}. Navigate away first.`),!1}return r&&e.logger.warn("router.removeRoute",`Route "${t}" removed while navigation is in progress. This may cause unexpected behavior.`),!0}(t,n.getStateName(),n.isTransitioning());i&&(je(r,t)||e.logger.warn("router.removeRoute",`Route "${t}" not found. No changes made.`))},update:(t,i)=>{N(n.isDisposed),n.validator?.routes.validateUpdateRouteBasicArgs(t,i),n.validator?.routes.throwIfInternalRoute(t,"updateRoute");const{forwardTo:a,defaultParams:s,decodeParams:o,encodeParams:c,canActivate:d,canDeactivate:l}=i;n.validator?.routes.validateUpdateRoutePropertyTypes(t,i),n.isTransitioning()&&e.logger.error("router.updateRoute",`Updating route "${t}" while navigation is in progress. This may cause unexpected behavior.`),n.validator?.routes.validateUpdateRoute(t,i,r),function(e,t,n){if(void 0!==n.forwardTo&&(e.resolvedForwardMap=function(e,t,n){return null===t?(delete n.forwardMap[e],delete n.forwardFnMap[e]):"string"==typeof t?(delete n.forwardFnMap[e],n.forwardMap[e]=t):(delete n.forwardMap[e],n.forwardFnMap[e]=t),(e=>Oe(e))(n)}(t,n.forwardTo,e.config)),void 0!==n.defaultParams&&(null===n.defaultParams?delete e.config.defaultParams[t]:e.config.defaultParams[t]=n.defaultParams),void 0!==n.decodeParams)if(null===n.decodeParams)delete e.config.decoders[t];else{const r=n.decodeParams;e.config.decoders[t]=e=>r(e)??e}if(void 0!==n.encodeParams)if(null===n.encodeParams)delete e.config.encoders[t];else{const r=n.encodeParams;e.config.encoders[t]=e=>r(e)??e}}(r,t,{forwardTo:a,defaultParams:s,decodeParams:o,encodeParams:c}),void 0!==d&&(null===d?r.lifecycleNamespace.clearCanActivate(t):r.lifecycleNamespace.addCanActivate(t,d,!0)),void 0!==l&&(null===l?r.lifecycleNamespace.clearCanDeactivate(t):r.lifecycleNamespace.addCanDeactivate(t,l,!0))},clear:()=>{N(n.isDisposed),I(n.isTransitioning())&&(r.treeOperations.resetStore(r),r.lifecycleNamespace.clearAll(),n.clearState())},has:e=>(n.validator?.routes.validateRouteName(e,"hasRoute"),r.matcher.hasRoute(e)),get:e=>(n.validator?.routes.validateRouteName(e,"getRoute"),Le(r,e)),replace:e=>{N(n.isDisposed);const i=Array.isArray(e)?e:[e];if(!I(n.isTransitioning()))return;C(i,n.validator),n.validator?.routes.throwIfInternalRouteInArray(i,"replaceRoutes"),n.validator?.routes.validateAddRouteArgs(i),n.validator?.routes.validateRoutes(i,r);const a=t.getState()?.path;!function(e,t,n,r){Ne(e),e.lifecycleNamespace.clearDefinitionGuards();for(const n of t)e.definitions.push(j(n));if(Ee(t,e.config,e.routeCustomFields,e.pendingCanActivate,e.pendingCanDeactivate,e.depsStore,""),e.treeOperations.commitTreeChanges(e),void 0!==r){const e=n.matchPath(r,n.getOptions());e?n.setState(e):n.clearState()}}(r,i,n,a)}}};//# sourceMappingURL=api.js.map
|