@real-router/validation-plugin 0.17.3 → 0.17.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -121,7 +121,7 @@ If the retrospective pass fails, the plugin rolls back cleanly. The router is le
121
121
  | Dependencies | `setDependency` args, dependency name format, full store structure |
122
122
  | Plugins | Plugin count vs `maxPlugins` limit, plugin hook names |
123
123
  | Lifecycle | Guard/hook handler type, count vs `maxLifecycleHandlers` |
124
- | Navigation | `navigate` args, `navigateToDefault` args, `NavigationOptions` shape, `params` validation (navigate, buildPath, canNavigateTo), `start` path validation |
124
+ | Navigation | `navigate` args, `navigateToDefault` args, `NavigationOptions` shape, `params` validation (navigate, buildPath, canNavigateTo), `start` path validation, a `defaultParams` / `defaultSearch` bag mutated after `createRouter()` |
125
125
  | State | `makeState` args, `areStatesEqual` args |
126
126
  | Event bus | Event name format, listener args |
127
127
  | Retrospective | Existing route tree integrity, `forwardTo` consistency, decoder/encoder types, dependency store structure, limits consistency, static `defaultRoute` resolves to a registered route |
@@ -14,7 +14,7 @@ import { RouterValidator } from "@real-router/core/validation";
14
14
  * `AnyOptions = Options<never>` in core): it fails on both compilers, because
15
15
  * this plugin actually reads dependencies.
16
16
  */
17
- declare function validationPlugin<Dependencies extends DefaultDependencies = DefaultDependencies>(): PluginFactory<Dependencies>;
17
+ export declare function validationPlugin<Dependencies extends DefaultDependencies = DefaultDependencies>(): PluginFactory<Dependencies>;
18
18
  //#endregion
19
- export { type RouterValidator, validationPlugin };
19
+ export type { RouterValidator };
20
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/validationPlugin.ts"],"mappings":";;;;;;;;;;;;;;;;iBA+VgB,iBACd,qBAAqB,sBAAsB,wBACxC,cAAc"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/validationPlugin.ts"],"mappings":";;;;;;;;;;;;;;;;wBA8WgB,iBACd,qBAAqB,sBAAsB,wBACxC,cAAc"}
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@real-router/core"),t=require("@real-router/core/utils"),n=require("@real-router/core/validation");const r=Object.freeze({maxDependencies:100,maxPlugins:50,maxListeners:1e4,warnListeners:1e3,maxLifecycleHandlers:200});function i(e){return{warn:Math.floor(e*.2),error:Math.floor(e*.5)}}function a(e){return typeof e==`string`}function o(e){return typeof e==`boolean`}function s(e,t){return e in t}const c=Object.getPrototypeOf,l=Object.values,u=Object.hasOwn;function ee(e){if(Array.isArray(e))return!0;let t=c(e);return t===null||t===Object.prototype}function te(e,t){let n=Array.isArray(e)?e:l(e);for(let e of n)t.push(e)}function ne(e){let t=typeof e;return t===`string`||t===`boolean`||t===`number`&&Number.isFinite(e)}var d=class{container;constructor(e){this.container=e}};function re(e,t,n,r){return n.has(e)?!1:r.has(e)?!0:ee(e)?(n.add(e),t.push(new d(e)),te(e,t),!0):!1}function ie(e){let t=[e],n=new WeakSet,r=new WeakSet;for(;t.length>0;){let e=t.pop();if(e instanceof d){n.delete(e.container),r.add(e.container);continue}if(e!=null){if(typeof e==`object`){if(!re(e,t,n,r))return!1;continue}if(!ne(e))return!1}}return!0}function ae(e){if(e==null)return!0;let t=typeof e;return t===`string`||t===`boolean`||t===`number`&&Number.isFinite(e)}function f(e){try{return oe(e)}catch{return!1}}function oe(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=c(e);if(t!==null&&t!==Object.prototype)return!1;let n=!1;for(let t in e){if(!u(e,t))continue;let r=e[t];if(!ae(r)){let e=typeof r;if(e===`function`||e===`symbol`)return!1;n=!0;break}}return!n||ie(e)}const se=[`replace`,`reload`,`force`,`forceDeactivate`,`redirected`];function ce(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;for(let e of se){let n=t[e];if(n!==void 0&&typeof n!=`boolean`)return!1}let n=t.signal;return n===void 0||n instanceof AbortSignal}const le=/\S/,p=/^[A-Z_a-z][\w-]*(?:\.[A-Z_a-z][\w-]*)*$/;function m(e,t){return TypeError(`[router.${e}] ${t}`)}function ue(e){return typeof e==`string`?e===``?!0:e.length>1e4?!1:e.startsWith(`@@`)?!0:p.test(e):!1}function de(e){return ue(e.name)&&typeof e.path==`string`&&f(e.params)}function h(e){return typeof e!=`object`||!e?!1:de(e)}function g(e,t){if(typeof e!=`string`)throw m(t,`Route name must be a string, got ${typeof e}`);if(e!==``){if(!le.test(e))throw m(t,`Route name cannot contain only whitespace`);if(e.length>1e4)throw m(t,`Route name exceeds maximum length of 10000 characters. This is a technical safety limit.`);if(!e.startsWith(`@@`)&&!p.test(e))throw m(t,`Invalid route name "${e}". Each segment must start with a letter or underscore, followed by letters, numbers, underscores, or hyphens. Segments are separated by dots (e.g., "users.profile").`)}}function _(e){if(e===null)return`null`;if(Array.isArray(e))return`array[${e.length}]`;if(typeof e==`object`){try{let t=e.constructor;if(typeof t==`function`&&t.name!==`Object`)return t.name||`object`}catch{}return`object`}return typeof e}const v=Object.keys,y=Object.getOwnPropertyDescriptor,fe=Object.getPrototypeOf,pe=Object;function b(e){if(!e||typeof e!=`object`)return!1;let t=fe(e);return t===null||t.constructor===pe}function me(e,t){if(typeof e!=`string`)throw TypeError(`[router.${t}] dependency name must be a string, got ${typeof e}`)}function he(e){if(typeof e!=`string`)throw TypeError(`[router.setDependency] dependency name must be a string, got ${typeof e}`)}function ge(e,t){if(!b(e))throw TypeError(`[router.${t}] Invalid argument: expected plain object, received ${_(e)}`);for(let n of v(e))if(y(e,n)?.get)throw TypeError(`[router.${t}] Getters not allowed: "${n}"`)}function _e(e,t){if(e===void 0)throw ReferenceError(`[router.getDependency] dependency "${t}" not found`)}function ve(e,t,n){let a=e,o=a.limits?.maxDependencies??r.maxDependencies;if(o===0)return;let s=v(a.dependencies).length,{warn:c,error:l}=i(o);if(s>=o)throw RangeError(`[router.${t}] Dependency limit exceeded (${o}). Current: ${s}.`);s===l?n.error(`router.${t}`,`${s} dependencies registered! This indicates architectural problems. Hard limit at ${o}.`):s===c&&n.warn(`router.${t}`,`${s} dependencies registered. Consider if all are necessary.`)}function ye(e){if(e!==void 0){if(!b(e))throw TypeError(`[cloneRouter] Invalid dependencies: expected plain object or undefined, received ${typeof e}`);for(let t of v(e))if(y(e,t)?.get)throw TypeError(`[cloneRouter] Getters not allowed in dependencies: "${t}"`)}}function be(e,t,n){n.warn(`router.${t}`,`Router dependency already exists and is being overwritten:`,e)}function xe(e,t,n){n.warn(`router.${t}`,`Overwritten:`,e.join(`, `))}function Se(e,t){t.warn(`router.removeDependency`,`Attempted to remove non-existent dependency: "${typeof e==`string`?e:String(e)}"`)}const Ce=Object.values,we=new Set(Ce(e.events));function Te(e){if(!we.has(e))throw TypeError(`[router.addEventListener] Invalid event name: ${String(e)}. Must be one of: $start, $stop, $$start, $$leaveApprove, $$cancel, $$success, $$error`)}function Ee(e,t){if(Te(e),typeof t!=`function`)throw TypeError(`[router.addEventListener] callback must be a function, got ${typeof t}`)}function De(e,t,n,a,o=r.maxListeners){if(o===0)return;let{warn:s,error:c}=i(o);e>=c?a.error(`router.${n}`,`${e} listeners registered for "${t}"! This is excessive. Hard limit at ${o}.`):e>=s&&a.warn(`router.${n}`,`${e} listeners registered for "${t}". Consider whether all are necessary — a growing count usually means a missing unsubscribe.`)}function Oe(e,t){if(!o(e)&&typeof e!=`function`)throw TypeError(`[router.${t}] Handler must be a boolean or factory function, got ${_(e)}`)}function ke(e,t,n=r.maxLifecycleHandlers){if(n!==0&&e>=n)throw RangeError(`[router.${t}] Lifecycle handler limit exceeded (${n}). This indicates too many routes with individual handlers. Consider using plugins for cross-cutting concerns.`)}function Ae(e,t,n,r){if(n===0)return;let{warn:a,error:o}=i(n);e>=o?r.error(`router.${t}`,`${e} lifecycle handlers registered! This is excessive. Hard limit at ${n}.`):e>=a&&r.warn(`router.${t}`,`${e} lifecycle handlers registered. Consider consolidating logic.`)}function je(e,t,n,r){r.warn(`router.${n}`,`Overwriting existing ${t} handler for route "${e}"`)}function x(e,t,n){n.warn(`router.${t}`,`Guard for "${e}" returned a Promise. Sync check cannot resolve async guards — returning false.`)}const S=Object.hasOwn;function Me(e){if(typeof e!=`string`)throw TypeError(`[router.navigate] Invalid route name: expected string, got ${_(e)}`)}function Ne(e){if(e!==void 0&&(typeof e!=`object`||!e))throw TypeError(`[router.navigateToDefault] Invalid options: ${_(e)}. Expected NavigationOptions object.`)}function Pe(e){if(typeof e!=`object`||!e)throw TypeError(`[router.navigateToState] Invalid state: ${_(e)}. Expected State object.`);let t=e;if(!a(t.name))throw TypeError(`[router.navigateToState] Invalid state.name: ${_(t.name)}. Expected string.`);if(!f(t.params))throw TypeError(`[router.navigateToState] Invalid state.params: ${_(t.params)}. Expected plain object.`);if(!a(t.path))throw TypeError(`[router.navigateToState] Invalid state.path: ${_(t.path)}. Expected string.`)}function Fe(e,t){if(!ce(e))throw TypeError(`[router.${t}] Invalid options: ${_(e)}. Expected NavigationOptions object.`)}const C=/[\u0000-\u001F\u007F]/;function Ie(e,t){for(let n in e){if(!S(e,n))continue;let r=e[n],i=typeof r;if(i===`symbol`||i===`bigint`)throw TypeError(`[router.${t}] param "${n}" cannot be a ${i} — it does not round-trip through the URL path. Use a string, number, or boolean.`);if(i===`string`&&C.test(r))throw TypeError(`[router.${t}] param "${n}" must not contain control characters (NUL / C0 / DEL) — they corrupt the URL path.`)}}function Le(e,t){if(e!==void 0&&(typeof e==`object`&&e&&!Array.isArray(e)&&Ie(e,t),!f(e)))throw TypeError(`[router.${t}] params must be a plain object, got ${_(e)}`)}function Re(e,t){if(e!==void 0&&(typeof e!=`object`||!e||Array.isArray(e)))throw TypeError(`[router.${t}] search must be a plain object, got ${_(e)}`)}function ze(e){if(e!==void 0&&typeof e!=`string`)throw TypeError(`[router.start] path must be a string, got ${_(e)}.`);if(typeof e==`string`){if(C.test(e))throw TypeError(`[router.start] path must not contain control characters (NUL / C0 / DEL).`);if(e!==``&&!e.startsWith(`/`))throw TypeError(`[router.start] path must start with "/", got "${e}".`)}}const w=Object.entries,Be=Object.hasOwn,Ve=Object.keys,T={trailingSlash:[`strict`,`never`,`always`,`preserve`],queryParamsMode:[`default`,`strict`,`loose`],urlParamsEncoding:[`default`,`uri`,`uriComponent`,`none`]},E={arrayFormat:[`none`,`brackets`,`index`,`comma`],booleanFormat:[`none`,`auto`,`empty-true`],nullFormat:[`default`,`hidden`],numberFormat:[`none`,`auto`]},He=new Set([`defaultRoute`,`defaultParams`,`defaultSearch`,`trailingSlash`,`caseSensitive`,`queryParamsMode`,`queryParams`,`urlParamsEncoding`,`allowNotFound`,`rewritePathOnMatch`,`logger`,`limits`]),D={maxDependencies:{min:0,max:1e4},maxPlugins:{min:0,max:1e3},maxListeners:{min:0,max:1e5},warnListeners:{min:0,max:1e5},maxLifecycleHandlers:{min:0,max:1e4}};function Ue(e,t,n){if(typeof t!=`number`||!Number.isInteger(t))throw TypeError(`[router.${n}] limit "${e}" must be an integer, got ${String(t)}`);let r=D[e];if(t<r.min||t>r.max)throw RangeError(`[router.${n}] limit "${e}" must be between ${r.min} and ${r.max}, got ${t}`)}function We(e,t){if(!e||typeof e!=`object`||e.constructor!==Object)throw TypeError(`[router.${t}] invalid limits: expected plain object, got ${typeof e}`);for(let[n,r]of w(e)){if(!Be(D,n))throw TypeError(`[router.${t}] unknown limit: "${n}"`);r!==void 0&&Ue(n,r,t)}let{warnListeners:n,maxListeners:r}=e;if(typeof n==`number`&&typeof r==`number`&&r>0&&n>r)throw RangeError(`[router.${t}] "limits.warnListeners" (${n}) must not exceed "limits.maxListeners" (${r}) — the warning channel would be unreachable`)}function O(e,t,n,r){if(e!==void 0&&(typeof e!=`string`||!n.includes(e))){let i=n.map(e=>`"${e}"`).join(`, `);throw TypeError(`[router.${r}] Invalid "${t}": "${typeof e==`string`?e:`(${typeof e})`}". Must be one of: ${i}`)}}function Ge(e,t){if(e!==void 0&&typeof e!=`string`&&typeof e!=`function`)throw TypeError(`[router.${t}] Invalid "defaultRoute": expected string or function, got ${typeof e}`)}function k(e,t,n){if(e!==void 0&&typeof e!=`function`&&(!e||typeof e!=`object`||Array.isArray(e)||e.constructor!==Object))throw TypeError(`[router.${n}] Invalid "${t}": expected plain object or function, got ${typeof e}`)}function Ke(e,t){if(e===void 0)return;if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`[router.${t}] Invalid "queryParams": expected plain object`);let n=e;for(let[e,r]of w(n)){if(!s(e,E))throw TypeError(`[router.${t}] Invalid "queryParams.${e}": unknown option`);O(r,`queryParams.${e}`,E[e],t)}}function qe(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`[router.${t}] Invalid options: expected plain object`);let n=e;for(let e of Ve(n))if(!He.has(e))throw TypeError(`[router.${t}] Unknown option: "${e}"`);if(Ge(n.defaultRoute,t),k(n.defaultParams,`defaultParams`,t),k(n.defaultSearch,`defaultSearch`,t),O(n.trailingSlash,`trailingSlash`,T.trailingSlash,t),O(n.queryParamsMode,`queryParamsMode`,T.queryParamsMode,t),O(n.urlParamsEncoding,`urlParamsEncoding`,T.urlParamsEncoding,t),n.allowNotFound!==void 0&&typeof n.allowNotFound!=`boolean`)throw TypeError(`[router.${t}] Invalid "allowNotFound": expected boolean, got ${typeof n.allowNotFound}`);if(n.rewritePathOnMatch!==void 0&&typeof n.rewritePathOnMatch!=`boolean`)throw TypeError(`[router.${t}] Invalid "rewritePathOnMatch": expected boolean, got ${typeof n.rewritePathOnMatch}`);if(n.caseSensitive!==void 0&&typeof n.caseSensitive!=`boolean`)throw TypeError(`[router.${t}] Invalid "caseSensitive": expected boolean, got ${typeof n.caseSensitive}`);Ke(n.queryParams,t),n.limits!==void 0&&We(n.limits,t)}const Je=Object.hasOwn,A=`router.usePlugin`,Ye={onStart:!0,onStop:!0,onTransitionStart:!0,onTransitionLeaveApprove:!0,onTransitionSuccess:!0,onTransitionError:!0,onTransitionCancel:!0};function Xe(e,t,n=r.maxPlugins){if(n!==0&&e+t>n)throw RangeError(`[router.usePlugin] Plugin limit exceeded (${n}). Current: ${e}, Attempting to add: ${t}. This indicates an architectural problem. Consider consolidating plugins.`)}function Ze(e,t){if(t.includes(e))throw Error(`[router.usePlugin] Plugin factory already registered. To re-register, first unsubscribe the existing plugin.`)}function Qe(e,t,n){if(t===0)return;let{warn:r,error:a}=i(t);e>=a?n.error(A,`${e} plugins registered! This is excessive. Hard limit at ${t}.`):e>=r&&n.warn(A,`${e} plugins registered. Consider if all are necessary.`)}function $e(e){for(let t in e)if(!(t===`teardown`||Je(Ye,t)))throw TypeError(`[router.usePlugin] Unknown property '${t}'. Plugin must only contain event handlers and optional teardown.`)}function et(e){e.warn(A,`Duplicate factory in batch, will be registered once`)}function tt(e,t){t.warn(A,`Property '${e}' is not a function, skipping`)}function nt(e,t){e===`onStart`&&t.warn(A,`Router already started, onStart will not be called`)}const j=Object.entries,rt=Object.getOwnPropertyDescriptor,M=Object.keys;function N(e,t){if(!e||typeof e!=`object`)throw TypeError(`[validation-plugin] ${t}: store must be an object`);let n=e;if(!Array.isArray(n.definitions))throw TypeError(`[validation-plugin] ${t}: store.definitions must be an array`);if(!n.config||typeof n.config!=`object`)throw TypeError(`[validation-plugin] ${t}: store.config must be an object`);if(!n.tree||typeof n.tree!=`object`)throw TypeError(`[validation-plugin] ${t}: store.tree must be an object`);return n}function P(e,t,n=``){for(let r of e){let e=n?`${n}.${r.name}`:r.name;t(r,e),r.children&&P(r.children,t,e)}}function F(e,t){let n=t.split(`.`),r=e;for(let e of n)if(r=r.children.get(e),!r)return!1;return!0}function it(t,n){try{return(0,e.resolveForwardChain)(t,n)}catch(e){throw Error(`[validation-plugin] ${e.message}`,{cause:e})}}function I(e){let t=new Set;for(let n of e)for(let e of n.paramMeta.urlParams)t.add(e);return t}function L(e,t,n){let r=e;if(r.constructor.name===`AsyncFunction`||r.toString().includes(`__awaiter`))throw TypeError(`[validation-plugin] Route "${n}" ${t} cannot be async`)}function at(e){P(N(e,`validateExistingRoutes`).definitions,(e,t)=>{if(typeof e.name!=`string`||!e.name)throw TypeError(`[validation-plugin] validateExistingRoutes: route has invalid name: ${e.name}`);if(typeof e.path!=`string`)throw TypeError(`[validation-plugin] validateExistingRoutes: route "${t}" has non-string path (${typeof e.path})`)})}function ot(e){let{config:t,tree:n,matcher:r}=N(e,`validateForwardToConsistency`);for(let[e,i]of j(t.forwardMap)){if(!F(n,i))throw Error(`[validation-plugin] validateForwardToConsistency: forwardTo target "${i}" does not exist in tree (source route: "${e}")`);let t=r.getSegmentsByName(e),a=r.getSegmentsByName(i);if(t&&a){let n=I(t),r=[...I(a)].filter(e=>!n.has(e));if(r.length>0)throw Error(`[validation-plugin] validateForwardToConsistency: forwardTo target "${i}" requires params [${r.join(`, `)}] not available in source route "${e}"`)}}for(let e of M(t.forwardMap))it(e,t.forwardMap)}function R(e,t){for(let[n,r]of j(e))if(typeof r!=`object`||!r||Array.isArray(r))throw TypeError(`[validation-plugin] validateRoutePropertiesStore: route "${n}" ${t} must be a plain object, got ${Array.isArray(r)?`array`:typeof r}`)}function st(e){let{config:t}=N(e,`validateRoutePropertiesStore`);for(let[e,n]of j(t.decoders)){if(typeof n!=`function`)throw TypeError(`[validation-plugin] validateRoutePropertiesStore: route "${e}" decoder must be a function, got ${typeof n}`);L(n,`decoder`,e)}for(let[e,n]of j(t.encoders)){if(typeof n!=`function`)throw TypeError(`[validation-plugin] validateRoutePropertiesStore: route "${e}" encoder must be a function, got ${typeof n}`);L(n,`encoder`,e)}R(t.defaultParams,`defaultParams`),R(t.defaultSearch,`defaultSearch`);for(let[e,n]of j(t.forwardFnMap)){if(typeof n!=`function`)throw TypeError(`[validation-plugin] validateRoutePropertiesStore: route "${e}" forwardTo callback must be a function, got ${typeof n}`);L(n,`forwardTo callback`,e)}}function ct(e){let{config:t,tree:n}=N(e,`validateForwardToTargetsStore`);for(let[e,r]of j(t.forwardMap))if(!F(n,r))throw Error(`[validation-plugin] validateForwardToTargetsStore: forwardTo target "${r}" does not exist for route "${e}"`)}function lt(e){if(!e||typeof e!=`object`)throw TypeError(`[validation-plugin] validateDependenciesStructure: deps must be an object`);let t=e;if(!t.dependencies||typeof t.dependencies!=`object`)throw TypeError(`[validation-plugin] validateDependenciesStructure: deps.dependencies must be an object`);let n=t.dependencies;for(let e of M(n))if(rt(n,e)?.get)throw TypeError(`[validation-plugin] validateDependenciesStructure: dependency "${e}" must not use a getter`);if(!t.limits||typeof t.limits!=`object`)throw TypeError(`[validation-plugin] validateDependenciesStructure: deps.limits must be an object`);let r=t.limits;for(let e of[`maxDependencies`,`maxPlugins`,`maxListeners`,`warnListeners`,`maxLifecycleHandlers`])if(!Number.isInteger(r[e]))throw TypeError(`[validation-plugin] validateDependenciesStructure: deps.limits.${e} must be an integer, got ${String(r[e])}`)}function ut(e){let t=e&&typeof e==`object`?e:{};return t.limits&&typeof t.limits==`object`?t.limits:{}}function dt(e,t){if(!e||typeof e!=`object`)return;let n=e,r=n.dependencies,i=n.limits;if(!r||typeof r!=`object`||!i||typeof i!=`object`)return;let a=M(r).length,o=i,s=t.maxDependencies,c=o.maxDependencies,l=typeof s==`number`?s:c;if(typeof l==`number`&&l>0&&a>l)throw RangeError(`[validation-plugin] validateLimitsConsistency: dependency count (${a}) exceeds maxDependencies limit (${l})`)}function ft(e,t){dt(t,ut(e))}function z(e,t){if(!(typeof e!=`string`||!e)&&!F(N(t,`validateResolvedDefaultRoute`).tree,e))throw Error(`[validation-plugin] defaultRoute resolved to non-existent route: "${e}"`)}const pt=Object.keys;function mt(e,t){if(e!==void 0){if(typeof e!=`string`&&typeof e!=`function`)throw TypeError(`[router.addRoute] forwardTo must be a string or function for route "${t}", got ${_(e)}`);if(typeof e==`function`){let n=e.constructor.name===`AsyncFunction`,r=e.toString().includes(`__awaiter`);if(n||r)throw TypeError(`[router.addRoute] forwardTo callback cannot be async for route "${t}". Async functions break matchPath/buildPath.`)}}}function B(e,t,n){if(e!==void 0&&(typeof e!=`object`||!e||Array.isArray(e)))throw TypeError(`[router.addRoute] ${t} must be an object for route "${n}", got ${_(e)}`)}function V(e,t){if(e.canActivate!==void 0&&typeof e.canActivate!=`function`)throw TypeError(`[router.addRoute] canActivate must be a function for route "${t}", got ${_(e.canActivate)}`);if(e.canDeactivate!==void 0&&typeof e.canDeactivate!=`function`)throw TypeError(`[router.addRoute] canDeactivate must be a function for route "${t}", got ${_(e.canDeactivate)}`);if(B(e.defaultParams,`defaultParams`,t),B(e.defaultSearch,`defaultSearch`,t),e.decodeParams?.constructor.name===`AsyncFunction`)throw TypeError(`[router.addRoute] decodeParams cannot be async for route "${t}". Async functions break matchPath/buildPath.`);if(e.encodeParams?.constructor.name===`AsyncFunction`)throw TypeError(`[router.addRoute] encodeParams cannot be async for route "${t}". Async functions break matchPath/buildPath.`);if(mt(e.forwardTo,t),e.children)for(let n of e.children)V(n,`${t}.${n.name}`)}function ht(e){let t=new Set,n=/[*:]([A-Z_a-z]\w*)/g,r;for(;(r=n.exec(e))!==null;)t.add(r[1]);return t}function H(e){let t=new Set;for(let n of e)for(let e of ht(n))t.add(e);return t}function U(e,t,n=``,r=[]){for(let i of e){let e=n?`${n}.${i.name}`:i.name,a=[...r,i.path];if(e===t)return a;if(i.children&&t.startsWith(`${e}.`))return U(i.children,t,e,a)}throw Error(`[internal] collectPathsToRoute: route "${t}" not found`)}function W(e,t=``){let n=new Set;for(let r of e){let e=t?`${t}.${r.name}`:r.name;if(n.add(e),r.children)for(let t of W(r.children,e))n.add(t)}return n}function G(e,t=``){let n=new Map;for(let r of e){let e=t?`${t}.${r.name}`:r.name;if(r.forwardTo&&typeof r.forwardTo==`string`&&n.set(e,r.forwardTo),r.children)for(let[t,i]of G(r.children,e))n.set(t,i)}return n}function K(e){let t=new Set;for(let n of e)for(let e of n.paramMeta.urlParams)t.add(e);return t}function gt(e,t,n,r){return t?K(n.getSegmentsByName(e)??[]):H(U(r,e))}const _t=new Set;function vt(e,t,n,r,i,a){let o=i.hasRoute(t),s=r.has(t);if(!o&&!s)throw ReferenceError(`[router.addRoute] forwardTo target "${t}" does not exist for route "${e}"`);let c=new Set([...a,...H(U(n,e))]),l=[...gt(t,o,i,n)].filter(e=>!c.has(e));if(l.length>0)throw Error(`[router.addRoute] forwardTo target "${t}" requires params [${l.join(`, `)}] that are not available in source route "${e}"`)}function yt(n,r,i,a){let o=W(n),s=a?new Set([...o].map(e=>`${a}.${e}`)):o,c=a?K(i.getSegmentsByName(a)):_t,l=G(n),u={...r};for(let[e,n]of l)(0,t.putField)(u,e,n);for(let[e,t]of l)vt(e,t,n,s,i,c);for(let t of pt(u))(0,e.resolveForwardChain)(t,u)}function q(e,t){if(e.startsWith(`@@`))throw Error(`[router.${t}] Route name "${e}" uses the reserved "@@" prefix. Routes with this prefix are internal and cannot be modified through the public API.`)}function J(e,t){for(let n of e)n&&typeof n==`object`&&typeof n.name==`string`&&(q(n.name,t),n.children&&J(n.children,t))}function bt(e){g(e,`removeRoute`)}function xt(e){if(typeof e!=`string`)throw TypeError(`[router.setRootPath] rootPath must be a string, got ${_(e)}`)}function Y(e){return e.constructor.name===`AsyncFunction`||String(e).includes(`__awaiter`)}function St(e){let t=e;if(t.canActivate!==void 0&&typeof t.canActivate!=`function`)throw TypeError(`[router.addRoute] canActivate must be a function, got ${_(t.canActivate)}`);if(t.canDeactivate!==void 0&&typeof t.canDeactivate!=`function`)throw TypeError(`[router.addRoute] canDeactivate must be a function, got ${_(t.canDeactivate)}`)}function Ct(e){let t=e,n=t.name;if(t.decodeParams!==void 0&&Y(t.decodeParams))throw TypeError(`[router.addRoute] decodeParams cannot be async for route "${String(n)}"`);if(t.encodeParams!==void 0&&Y(t.encodeParams))throw TypeError(`[router.addRoute] encodeParams cannot be async for route "${String(n)}"`);if(typeof t.forwardTo==`function`&&Y(t.forwardTo))throw TypeError(`[router.addRoute] forwardTo callback cannot be async for route "${String(n)}"`)}function wt(e){for(let t of e){if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`[router.addRoute] Route must be an object, got ${_(t)}`);V(t,t.name)}}function Tt(e){if(typeof e!=`string`||e===``)throw TypeError(`[router.addRoute] parent option must be a non-empty string, got ${_(e)}`);g(e,`addRoute`)}function Et(e,t,n,r){if(!a(e))throw TypeError(`[router.isActiveRoute] name must be a string, got ${typeof e}`);if(t!==void 0&&!f(t))throw TypeError(`[router.isActiveRoute] params must be a plain object, got ${_(t)}`);if(n!==void 0&&typeof n!=`boolean`)throw TypeError(`[router.isActiveRoute] strictEquality must be a boolean, got ${typeof n}`);if(r!==void 0&&typeof r!=`boolean`)throw TypeError(`[router.isActiveRoute] ignoreQueryParams must be a boolean, got ${typeof r}`)}function Dt(e,t,n){if(!a(e))throw TypeError(`[router.${n}] Invalid routeName: ${_(e)}. Expected string.`);if(!f(t))throw TypeError(`[router.${n}] Invalid routeParams: ${_(t)}. Expected plain object.`)}function Ot(e,t){if(g(e,`updateRoute`),e===``)throw ReferenceError(`[router.updateRoute] Invalid name: empty string. Cannot update root node.`);if(t===null)throw TypeError(`[router.updateRoute] updates must be an object, got null`);if(typeof t!=`object`||Array.isArray(t))throw TypeError(`[router.updateRoute] updates must be an object, got ${_(t)}`)}function X(e,t){if(e.constructor.name===`AsyncFunction`||e.toString().includes(`__awaiter`))throw TypeError(`[router.updateRoute] ${t} cannot be an async function`)}function Z(e,t){if(e!=null){if(typeof e!=`function`)throw TypeError(`[router.updateRoute] ${t} must be a function or null, got ${typeof e}`);X(e,t)}}function kt(e){let{forwardTo:t,defaultParams:n,defaultSearch:r,decodeParams:i,encodeParams:a,canActivate:o,canDeactivate:s}=e;if(t!=null){if(typeof t!=`string`&&typeof t!=`function`)throw TypeError(`[router.updateRoute] forwardTo must be a string, function, or null, got ${_(t)}`);typeof t==`function`&&X(t,`forwardTo callback`)}Q(n,`defaultParams`),Q(r,`defaultSearch`),Z(i,`decodeParams`),Z(a,`encodeParams`),Z(o,`canActivate`),Z(s,`canDeactivate`)}function Q(e,t){if(e!=null&&(typeof e!=`object`||Array.isArray(e)))throw TypeError(`[router.updateRoute] ${t} must be an object or null, got ${_(e)}`)}function At(e){if(!a(e)||e===``)throw TypeError(`[router.buildPath] route must be a non-empty string, got ${typeof e==`string`?`""`:typeof e}`)}function jt(e){if(!a(e))throw TypeError(`[router.matchPath] path must be a string, got ${typeof e}`)}function Mt(e){if(!a(e))throw TypeError(`[router.shouldUpdateNode] nodeName must be a string, got ${typeof e}`)}function $(e,t,r,i,a){if(a&&t){let e=t;for(let t of a.split(`.`))if(e=e.children.get(t),!e)throw ReferenceError(`[router.addRoute] Parent route "${a}" does not exist`)}let o=new Set,s=new Map;for(let r of e)(0,n.validateRoute)(r,`addRoute`,t,a??``,o,s);r&&i&&yt(e,i,r,a)}function Nt(e){let t=new Set;for(let n of e)for(let e of n.paramMeta.urlParams)t.add(e);return t}function Pt(e,t,n){let r=n.getSegmentsByName(e),i=n.getSegmentsByName(t),a=Nt(r),o=[];for(let e of i)for(let t of e.paramMeta.urlParams)o.push(t);let s=o.filter(e=>!a.has(e));if(s.length>0)throw Error(`[router.addRoute] forwardTo target "${t}" requires params [${s.join(`, `)}] that are not available in source route "${e}"`)}function Ft(t,n,r){(0,e.resolveForwardChain)(t,{...r.forwardMap,[t]:n})}function It(e,t,n,r,i){if(!n(e))throw ReferenceError(`[router.updateRoute] route "${e}" does not exist`);if(t!=null&&typeof t==`string`){if(!n(t))throw Error(`[router.updateRoute] forwardTo target "${t}" does not exist`);Pt(e,t,r),Ft(e,t,i)}}function Lt(e,t,n){if(!a(e))throw TypeError(`[router.makeState] Invalid name: ${_(e)}. Expected string.`);if(t!==void 0&&!f(t))throw TypeError(`[router.makeState] Invalid params: ${_(t)}. Expected plain object.`);if(n!==void 0&&!a(n))throw TypeError(`[router.makeState] Invalid path: ${_(n)}. Expected string.`)}function Rt(){let e=new Set;return function(t,n){let r=`${t} ${n}`;e.has(r)||(e.add(r),console.warn(`[router] Query key "${n}" is not declared on route "${t}" (\`?${n}\`), so the current \`queryParamsMode\` will not print it — it was dropped from \`state.search\` rather than published beside a \`state.path\` that cannot show it. Declare it on the route path, or use \`queryParamsMode: "loose"\` to keep undeclared keys. A \`defaultSearch\` entry for "${n}" is dead config in this mode for the same reason.`))}}function zt(){let e=new Set;return function(t,n){let r=`${t} ${n}`;e.has(r)||(e.add(r),console.warn(`[router] Param "${n}" is declared nowhere on route "${t}" — neither as a path slot (:${n}) nor as a query param (?${n}), so it stays in state.params but never reaches the URL. The state will not round-trip: matchPath(state.path) cannot recover it. Declare it on the route path if it belongs in the URL, or pass it through the search channel; keep it here only if it is deliberately app-level data.`))}}function Bt(e){return{routes:{validateBuildPathArgs:At,validateMatchPathArgs:jt,validateIsActiveRouteArgs:Et,validateShouldUpdateNodeArgs:Mt,validateStateBuilderArgs:Dt,validateAddRouteArgs(e){wt(e)},validateRoutes(e,t,n){let r=t;$(e,r.tree,r.matcher,r.config?.forwardMap,n)},validateRemoveRouteArgs:bt,validateUpdateRouteBasicArgs:Ot,validateUpdateRoutePropertyTypes(e,t){let n=t;kt({forwardTo:n.forwardTo,defaultParams:n.defaultParams,defaultSearch:n.defaultSearch,decodeParams:n.decodeParams,encodeParams:n.encodeParams,canActivate:n.canActivate,canDeactivate:n.canDeactivate})},validateUpdateRoute(e,t,n){let r=n,i=t.forwardTo;It(e,i,e=>r.matcher.hasRoute(e),r.matcher,r.config)},validateParentOption(e,t){Tt(e);let n=t;for(let t of e.split(`.`)){let r=n.children.get(t);if(!r)throw ReferenceError(`[router.addRoute] Parent route "${e}" does not exist`);n=r}},validateRouteName(e,t){g(e,t)},throwIfInternalRoute(e,t){q(e,t)},throwIfInternalRouteInArray(e,t){J(e,t)},validateSetRootPathArgs:xt,guardRouteCallbacks:St,guardNoAsyncCallbacks:Ct},options:{validateOptions:qe,validateResolvedDefaultRoute:z},dependencies:{validateDependencyName:me,validateSetDependencyArgs(e,t,n){he(e)},validateDependenciesObject:ge,validateDependencyExists(e,t){let n=t.dependencies?.[e];_e(n,e)},validateDependencyCount(t,n){ve(t,n,e.logger)},validateCloneArgs:ye,warnOverwrite(t,n){be(t,n,e.logger)},warnBatchOverwrite(t,n){xe(t,n,e.logger)},warnRemoveNonExistent(t){Se(t,e.logger)}},plugins:{validatePluginLimit(e,t){Xe(e,1,t?.maxPlugins)},validateNoDuplicatePlugins:Ze,validatePluginKeys:$e,validateCountThresholds(t){Qe(t,e.getOptions().limits?.maxPlugins??r.maxPlugins,e.logger)},warnBatchDuplicates(){et(e.logger)},warnPluginMethodType(t){tt(t,e.logger)},warnPluginAfterStart(t){nt(t,e.logger)}},lifecycle:{validateHandler:Oe,validateHandlerLimit(t,n){ke(t,n,e.getOptions().limits?.maxLifecycleHandlers??r.maxLifecycleHandlers)},validateCountThresholds(t,n){Ae(t,n,e.getOptions().limits?.maxLifecycleHandlers??r.maxLifecycleHandlers,e.logger)},warnOverwrite(t,n,r){je(t,n,r,e.logger)},warnAsyncGuardSync(t,n){x(t,n,e.logger)}},navigation:{validateNavigateArgs:Me,validateNavigateToDefaultArgs:Ne,validateNavigateToStateArgs:Pe,validateNavigationOptions:Fe,validateParams:Le,validateSearch:Re,validateStartArgs:ze},state:{validateMakeStateArgs:Lt,reportDroppedQueryKey:Rt(),reportUndeclaredParamKey:zt(),validateAreStatesEqualArgs(e,t,n){if(!h(e))throw TypeError(`[router.areStatesEqual] Invalid state1: ${_(e)}. Expected State object.`);if(!h(t))throw TypeError(`[router.areStatesEqual] Invalid state2: ${_(t)}. Expected State object.`);if(n!==void 0&&!o(n))throw TypeError(`[router.areStatesEqual] Invalid ignoreQueryParams: ${_(n)}. Expected boolean.`)}},eventBus:{validateListenerArgs(e,t){Ee(e,t)},validateCountThresholds(t,n,i){let a=e.getOptions().limits?.maxListeners??r.maxListeners;De(t,n,i,e.logger,a)}}}}function Vt(){return r=>{let i=(0,n.getInternals)(r);if(r.isActive())throw(0,t.freezeThrownError)(new e.RouterError(`VALIDATION_PLUGIN_AFTER_START`,{message:`validation-plugin must be registered before router.start()`}));i.validator=Bt(i);try{let e=i.routeGetStore(),t=i.dependenciesGetStore(),n=i.getOptions();at(e),ot(e),st(e),ct(e),lt(t),ft(n,t),i.validator.options.validateOptions(n,`constructor (retrospective)`),typeof n.defaultRoute==`string`&&z(n.defaultRoute,e)}catch(e){throw i.validator=null,e}return{teardown(){i.validator=null}}}}exports.validationPlugin=Vt;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@real-router/core"),t=require("@real-router/core/utils"),n=require("@real-router/core/validation");const r=Object.freeze({maxDependencies:100,maxPlugins:50,maxListeners:1e4,warnListeners:1e3,maxLifecycleHandlers:200});function i(e){return{warn:Math.floor(e*.2),error:Math.floor(e*.5)}}function a(e){return typeof e==`string`}function o(e){return typeof e==`boolean`}function s(e,t){return e in t}const c=Object.getPrototypeOf,l=Object.values,u=Object.hasOwn;function ee(e){if(Array.isArray(e))return!0;let t=c(e);return t===null||t===Object.prototype}function te(e,t){let n=Array.isArray(e)?e:l(e);for(let e of n)t.push(e)}function ne(e){let t=typeof e;return t===`string`||t===`boolean`||t===`number`&&Number.isFinite(e)}var d=class{container;constructor(e){this.container=e}};function re(e,t,n,r){return n.has(e)?!1:r.has(e)?!0:ee(e)?(n.add(e),t.push(new d(e)),te(e,t),!0):!1}function ie(e){let t=[e],n=new WeakSet,r=new WeakSet;for(;t.length>0;){let e=t.pop();if(e instanceof d){n.delete(e.container),r.add(e.container);continue}if(e!=null){if(typeof e==`object`){if(!re(e,t,n,r))return!1;continue}if(!ne(e))return!1}}return!0}function ae(e){if(e==null)return!0;let t=typeof e;return t===`string`||t===`boolean`||t===`number`&&Number.isFinite(e)}function f(e){try{return oe(e)}catch{return!1}}function oe(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=c(e);if(t!==null&&t!==Object.prototype)return!1;let n=!1;for(let t in e){if(!u(e,t))continue;let r=e[t];if(!ae(r)){let e=typeof r;if(e===`function`||e===`symbol`)return!1;n=!0;break}}return!n||ie(e)}const se=[`replace`,`reload`,`force`,`forceDeactivate`,`redirected`];function ce(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;for(let e of se){let n=t[e];if(n!==void 0&&typeof n!=`boolean`)return!1}let n=t.signal;return n===void 0||n instanceof AbortSignal}const le=/\S/,p=/^[A-Z_a-z][\w-]*(?:\.[A-Z_a-z][\w-]*)*$/;function m(e,t){return TypeError(`[router.${e}] ${t}`)}function ue(e){return typeof e==`string`?e===``?!0:e.length>1e4?!1:e.startsWith(`@@`)?!0:p.test(e):!1}function de(e){return ue(e.name)&&typeof e.path==`string`&&f(e.params)}function h(e){return typeof e!=`object`||!e?!1:de(e)}function g(e,t){if(typeof e!=`string`)throw m(t,`Route name must be a string, got ${typeof e}`);if(e!==``){if(!le.test(e))throw m(t,`Route name cannot contain only whitespace`);if(e.length>1e4)throw m(t,`Route name exceeds maximum length of 10000 characters. This is a technical safety limit.`);if(!e.startsWith(`@@`)&&!p.test(e))throw m(t,`Invalid route name "${e}". Each segment must start with a letter or underscore, followed by letters, numbers, underscores, or hyphens. Segments are separated by dots (e.g., "users.profile").`)}}function _(e){if(e===null)return`null`;if(Array.isArray(e))return`array[${e.length}]`;if(typeof e==`object`){try{let t=e.constructor;if(typeof t==`function`&&t.name!==`Object`)return t.name||`object`}catch{}return`object`}return typeof e}const v=Object.entries,fe=[`defaultParams`,`defaultSearch`],pe=e=>new Map(v(e)),me=(e,t)=>{let n=v(e);return n.length!==t.size||n.some(([e,n])=>!t.has(e)||!Object.is(t.get(e),n))};var he=class{#e=new Map;#t=new Set;watch(e){for(let t of fe){let n=e[t],r=n?.deref();n!==void 0&&r!==void 0&&this.#e.set(t,{ref:n,before:pe(r)})}}check(e){for(let[t,{ref:n,before:r}]of this.#e){if(this.#t.has(t))continue;let i=n.deref();i!==void 0&&me(i,r)&&(this.#t.add(t),e.warn(`router.navigateToDefault`,`mutating \`${t}\` after createRouter() no longer affects routing — the router copied it at construction. Use the callback form (\`${t}: () => ({ … })\`), which is resolved at the point of use.`))}}};const y=Object.keys,b=Object.getOwnPropertyDescriptor,ge=Object.getPrototypeOf,_e=Object;function x(e){if(!e||typeof e!=`object`)return!1;let t=ge(e);return t===null||t.constructor===_e}function ve(e,t){if(typeof e!=`string`)throw TypeError(`[router.${t}] dependency name must be a string, got ${typeof e}`)}function ye(e){if(typeof e!=`string`)throw TypeError(`[router.setDependency] dependency name must be a string, got ${typeof e}`)}function be(e,t){if(!x(e))throw TypeError(`[router.${t}] Invalid argument: expected plain object, received ${_(e)}`);for(let n of y(e))if(b(e,n)?.get)throw TypeError(`[router.${t}] Getters not allowed: "${n}"`)}function xe(e,t){if(e===void 0)throw ReferenceError(`[router.getDependency] dependency "${t}" not found`)}function Se(e,t,n){let a=e,o=a.limits?.maxDependencies??r.maxDependencies;if(o===0)return;let s=y(a.dependencies).length,{warn:c,error:l}=i(o);if(s>=o)throw RangeError(`[router.${t}] Dependency limit exceeded (${o}). Current: ${s}.`);s===l?n.error(`router.${t}`,`${s} dependencies registered! This indicates architectural problems. Hard limit at ${o}.`):s===c&&n.warn(`router.${t}`,`${s} dependencies registered. Consider if all are necessary.`)}function Ce(e){if(e!==void 0){if(!x(e))throw TypeError(`[cloneRouter] Invalid dependencies: expected plain object or undefined, received ${typeof e}`);for(let t of y(e))if(b(e,t)?.get)throw TypeError(`[cloneRouter] Getters not allowed in dependencies: "${t}"`)}}function we(e,t,n){n.warn(`router.${t}`,`Router dependency already exists and is being overwritten:`,e)}function Te(e,t,n){n.warn(`router.${t}`,`Overwritten:`,e.join(`, `))}function Ee(e,t){t.warn(`router.removeDependency`,`Attempted to remove non-existent dependency: "${typeof e==`string`?e:String(e)}"`)}const De=Object.values,Oe=new Set(De(e.events));function ke(e){if(!Oe.has(e))throw TypeError(`[router.addEventListener] Invalid event name: ${String(e)}. Must be one of: $start, $stop, $$start, $$leaveApprove, $$cancel, $$success, $$error`)}function Ae(e,t){if(ke(e),typeof t!=`function`)throw TypeError(`[router.addEventListener] callback must be a function, got ${typeof t}`)}function je(e,t,n,a,o=r.maxListeners){if(o===0)return;let{warn:s,error:c}=i(o);e>=c?a.error(`router.${n}`,`${e} listeners registered for "${t}"! This is excessive. Hard limit at ${o}.`):e>=s&&a.warn(`router.${n}`,`${e} listeners registered for "${t}". Consider whether all are necessary — a growing count usually means a missing unsubscribe.`)}function S(e,t){if(!o(e)&&typeof e!=`function`)throw TypeError(`[router.${t}] Handler must be a boolean or factory function, got ${_(e)}`)}function Me(e,t,n=r.maxLifecycleHandlers){if(n!==0&&e>=n)throw RangeError(`[router.${t}] Lifecycle handler limit exceeded (${n}). This indicates too many routes with individual handlers. Consider using plugins for cross-cutting concerns.`)}function Ne(e,t,n,r){if(n===0)return;let{warn:a,error:o}=i(n);e>=o?r.error(`router.${t}`,`${e} lifecycle handlers registered! This is excessive. Hard limit at ${n}.`):e>=a&&r.warn(`router.${t}`,`${e} lifecycle handlers registered. Consider consolidating logic.`)}function Pe(e,t,n,r){r.warn(`router.${n}`,`Overwriting existing ${t} handler for route "${e}"`)}function Fe(e,t,n){n.warn(`router.${t}`,`Guard for "${e}" returned a Promise. Sync check cannot resolve async guards — returning false.`)}const Ie=Object.hasOwn;function Le(e){if(typeof e!=`string`)throw TypeError(`[router.navigate] Invalid route name: expected string, got ${_(e)}`)}function Re(e){if(e!==void 0&&(typeof e!=`object`||!e))throw TypeError(`[router.navigateToDefault] Invalid options: ${_(e)}. Expected NavigationOptions object.`)}function ze(e){if(typeof e!=`object`||!e)throw TypeError(`[router.navigateToState] Invalid state: ${_(e)}. Expected State object.`);let t=e;if(!a(t.name))throw TypeError(`[router.navigateToState] Invalid state.name: ${_(t.name)}. Expected string.`);if(!f(t.params))throw TypeError(`[router.navigateToState] Invalid state.params: ${_(t.params)}. Expected plain object.`);if(!a(t.path))throw TypeError(`[router.navigateToState] Invalid state.path: ${_(t.path)}. Expected string.`)}function Be(e,t){if(!ce(e))throw TypeError(`[router.${t}] Invalid options: ${_(e)}. Expected NavigationOptions object.`)}const C=/[\u0000-\u001F\u007F]/;function Ve(e,t){for(let n in e){if(!Ie(e,n))continue;let r=e[n],i=typeof r;if(i===`symbol`||i===`bigint`)throw TypeError(`[router.${t}] param "${n}" cannot be a ${i} — it does not round-trip through the URL path. Use a string, number, or boolean.`);if(i===`string`&&C.test(r))throw TypeError(`[router.${t}] param "${n}" must not contain control characters (NUL / C0 / DEL) — they corrupt the URL path.`)}}function He(e,t){if(e!==void 0&&(typeof e==`object`&&e&&!Array.isArray(e)&&Ve(e,t),!f(e)))throw TypeError(`[router.${t}] params must be a plain object, got ${_(e)}`)}function Ue(e,t){if(e!==void 0&&(typeof e!=`object`||!e||Array.isArray(e)))throw TypeError(`[router.${t}] search must be a plain object, got ${_(e)}`)}function We(e){if(e!==void 0&&typeof e!=`string`)throw TypeError(`[router.start] path must be a string, got ${_(e)}.`);if(typeof e==`string`){if(C.test(e))throw TypeError(`[router.start] path must not contain control characters (NUL / C0 / DEL).`);if(e!==``&&!e.startsWith(`/`))throw TypeError(`[router.start] path must start with "/", got "${e}".`)}}const w=Object.entries,Ge=Object.hasOwn,Ke=Object.keys,T={trailingSlash:[`strict`,`never`,`always`,`preserve`],queryParamsMode:[`default`,`strict`,`loose`],urlParamsEncoding:[`default`,`uri`,`uriComponent`,`none`]},E={arrayFormat:[`none`,`brackets`,`index`,`comma`],booleanFormat:[`none`,`auto`,`empty-true`],nullFormat:[`default`,`hidden`],numberFormat:[`none`,`auto`]},qe=new Set([`defaultRoute`,`defaultParams`,`defaultSearch`,`trailingSlash`,`caseSensitive`,`queryParamsMode`,`queryParams`,`urlParamsEncoding`,`allowNotFound`,`rewritePathOnMatch`,`logger`,`limits`]),D={maxDependencies:{min:0,max:1e4},maxPlugins:{min:0,max:1e3},maxListeners:{min:0,max:1e5},warnListeners:{min:0,max:1e5},maxLifecycleHandlers:{min:0,max:1e4}};function Je(e,t,n){if(typeof t!=`number`||!Number.isInteger(t))throw TypeError(`[router.${n}] limit "${e}" must be an integer, got ${String(t)}`);let r=D[e];if(t<r.min||t>r.max)throw RangeError(`[router.${n}] limit "${e}" must be between ${r.min} and ${r.max}, got ${t}`)}function Ye(e,t){if(!e||typeof e!=`object`||e.constructor!==Object)throw TypeError(`[router.${t}] invalid limits: expected plain object, got ${typeof e}`);for(let[n,r]of w(e)){if(!Ge(D,n))throw TypeError(`[router.${t}] unknown limit: "${n}"`);r!==void 0&&Je(n,r,t)}let{warnListeners:n,maxListeners:r}=e;if(typeof n==`number`&&typeof r==`number`&&r>0&&n>r)throw RangeError(`[router.${t}] "limits.warnListeners" (${n}) must not exceed "limits.maxListeners" (${r}) — the warning channel would be unreachable`)}function O(e,t,n,r){if(e!==void 0&&(typeof e!=`string`||!n.includes(e))){let i=n.map(e=>`"${e}"`).join(`, `);throw TypeError(`[router.${r}] Invalid "${t}": "${typeof e==`string`?e:`(${typeof e})`}". Must be one of: ${i}`)}}function Xe(e,t){if(e!==void 0&&typeof e!=`string`&&typeof e!=`function`)throw TypeError(`[router.${t}] Invalid "defaultRoute": expected string or function, got ${typeof e}`)}function k(e,t,n){if(e!==void 0&&typeof e!=`function`&&(!e||typeof e!=`object`||Array.isArray(e)||e.constructor!==Object))throw TypeError(`[router.${n}] Invalid "${t}": expected plain object or function, got ${typeof e}`)}function Ze(e,t){if(e===void 0)return;if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`[router.${t}] Invalid "queryParams": expected plain object`);let n=e;for(let[e,r]of w(n)){if(!s(e,E))throw TypeError(`[router.${t}] Invalid "queryParams.${e}": unknown option`);O(r,`queryParams.${e}`,E[e],t)}}function Qe(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`[router.${t}] Invalid options: expected plain object`);let n=e;for(let e of Ke(n))if(!qe.has(e))throw TypeError(`[router.${t}] Unknown option: "${e}"`);if(Xe(n.defaultRoute,t),k(n.defaultParams,`defaultParams`,t),k(n.defaultSearch,`defaultSearch`,t),O(n.trailingSlash,`trailingSlash`,T.trailingSlash,t),O(n.queryParamsMode,`queryParamsMode`,T.queryParamsMode,t),O(n.urlParamsEncoding,`urlParamsEncoding`,T.urlParamsEncoding,t),n.allowNotFound!==void 0&&typeof n.allowNotFound!=`boolean`)throw TypeError(`[router.${t}] Invalid "allowNotFound": expected boolean, got ${typeof n.allowNotFound}`);if(n.rewritePathOnMatch!==void 0&&typeof n.rewritePathOnMatch!=`boolean`)throw TypeError(`[router.${t}] Invalid "rewritePathOnMatch": expected boolean, got ${typeof n.rewritePathOnMatch}`);if(n.caseSensitive!==void 0&&typeof n.caseSensitive!=`boolean`)throw TypeError(`[router.${t}] Invalid "caseSensitive": expected boolean, got ${typeof n.caseSensitive}`);Ze(n.queryParams,t),n.limits!==void 0&&Ye(n.limits,t)}const $e=Object.hasOwn,A=`router.usePlugin`,et={onStart:!0,onStop:!0,onTransitionStart:!0,onTransitionLeaveApprove:!0,onTransitionSuccess:!0,onTransitionError:!0,onTransitionCancel:!0};function tt(e,t,n=r.maxPlugins){if(n!==0&&e+t>n)throw RangeError(`[router.usePlugin] Plugin limit exceeded (${n}). Current: ${e}, Attempting to add: ${t}. This indicates an architectural problem. Consider consolidating plugins.`)}function nt(e,t){if(t.includes(e))throw Error(`[router.usePlugin] Plugin factory already registered. To re-register, first unsubscribe the existing plugin.`)}function rt(e,t,n){if(t===0)return;let{warn:r,error:a}=i(t);e>=a?n.error(A,`${e} plugins registered! This is excessive. Hard limit at ${t}.`):e>=r&&n.warn(A,`${e} plugins registered. Consider if all are necessary.`)}function it(e){for(let t in e)if(!(t===`teardown`||$e(et,t)))throw TypeError(`[router.usePlugin] Unknown property '${t}'. Plugin must only contain event handlers and optional teardown.`)}function at(e){e.warn(A,`Duplicate factory in batch, will be registered once`)}function ot(e,t){t.warn(A,`Property '${e}' is not a function, skipping`)}function st(e,t){e===`onStart`&&t.warn(A,`Router already started, onStart will not be called`)}const j=Object.entries,ct=Object.getOwnPropertyDescriptor,M=Object.keys;function N(e,t){if(!e||typeof e!=`object`)throw TypeError(`[validation-plugin] ${t}: store must be an object`);let n=e;if(!Array.isArray(n.definitions))throw TypeError(`[validation-plugin] ${t}: store.definitions must be an array`);if(!n.config||typeof n.config!=`object`)throw TypeError(`[validation-plugin] ${t}: store.config must be an object`);if(!n.tree||typeof n.tree!=`object`)throw TypeError(`[validation-plugin] ${t}: store.tree must be an object`);return n}function P(e,t,n=``){for(let r of e){let e=n?`${n}.${r.name}`:r.name;t(r,e),r.children&&P(r.children,t,e)}}function F(e,t){let n=t.split(`.`),r=e;for(let e of n)if(r=r.children.get(e),!r)return!1;return!0}function lt(t,n){try{return(0,e.resolveForwardChain)(t,n)}catch(e){throw Error(`[validation-plugin] ${e.message}`,{cause:e})}}function I(e){let t=new Set;for(let n of e)for(let e of n.paramMeta.urlParams)t.add(e);return t}function L(e,t,n){let r=e;if(r.constructor.name===`AsyncFunction`||r.toString().includes(`__awaiter`))throw TypeError(`[validation-plugin] Route "${n}" ${t} cannot be async`)}function ut(e){P(N(e,`validateExistingRoutes`).definitions,(e,t)=>{if(typeof e.name!=`string`||!e.name)throw TypeError(`[validation-plugin] validateExistingRoutes: route has invalid name: ${e.name}`);if(typeof e.path!=`string`)throw TypeError(`[validation-plugin] validateExistingRoutes: route "${t}" has non-string path (${typeof e.path})`)})}function dt(e){let{config:t,tree:n,matcher:r}=N(e,`validateForwardToConsistency`);for(let[e,i]of j(t.forwardMap)){if(!F(n,i))throw Error(`[validation-plugin] validateForwardToConsistency: forwardTo target "${i}" does not exist in tree (source route: "${e}")`);let t=r.getSegmentsByName(e),a=r.getSegmentsByName(i);if(t&&a){let n=I(t),r=[...I(a)].filter(e=>!n.has(e));if(r.length>0)throw Error(`[validation-plugin] validateForwardToConsistency: forwardTo target "${i}" requires params [${r.join(`, `)}] not available in source route "${e}"`)}}for(let e of M(t.forwardMap))lt(e,t.forwardMap)}function R(e,t){for(let[n,r]of j(e))if(typeof r!=`object`||!r||Array.isArray(r))throw TypeError(`[validation-plugin] validateRoutePropertiesStore: route "${n}" ${t} must be a plain object, got ${Array.isArray(r)?`array`:typeof r}`)}function ft(e){let{config:t}=N(e,`validateRoutePropertiesStore`);for(let[e,n]of j(t.decoders)){if(typeof n!=`function`)throw TypeError(`[validation-plugin] validateRoutePropertiesStore: route "${e}" decoder must be a function, got ${typeof n}`);L(n,`decoder`,e)}for(let[e,n]of j(t.encoders)){if(typeof n!=`function`)throw TypeError(`[validation-plugin] validateRoutePropertiesStore: route "${e}" encoder must be a function, got ${typeof n}`);L(n,`encoder`,e)}R(t.defaultParams,`defaultParams`),R(t.defaultSearch,`defaultSearch`);for(let[e,n]of j(t.forwardFnMap)){if(typeof n!=`function`)throw TypeError(`[validation-plugin] validateRoutePropertiesStore: route "${e}" forwardTo callback must be a function, got ${typeof n}`);L(n,`forwardTo callback`,e)}}function pt(e){let{config:t,tree:n}=N(e,`validateForwardToTargetsStore`);for(let[e,r]of j(t.forwardMap))if(!F(n,r))throw Error(`[validation-plugin] validateForwardToTargetsStore: forwardTo target "${r}" does not exist for route "${e}"`)}function mt(e){if(!e||typeof e!=`object`)throw TypeError(`[validation-plugin] validateDependenciesStructure: deps must be an object`);let t=e;if(!t.dependencies||typeof t.dependencies!=`object`)throw TypeError(`[validation-plugin] validateDependenciesStructure: deps.dependencies must be an object`);let n=t.dependencies;for(let e of M(n))if(ct(n,e)?.get)throw TypeError(`[validation-plugin] validateDependenciesStructure: dependency "${e}" must not use a getter`);if(!t.limits||typeof t.limits!=`object`)throw TypeError(`[validation-plugin] validateDependenciesStructure: deps.limits must be an object`);let r=t.limits;for(let e of[`maxDependencies`,`maxPlugins`,`maxListeners`,`warnListeners`,`maxLifecycleHandlers`])if(!Number.isInteger(r[e]))throw TypeError(`[validation-plugin] validateDependenciesStructure: deps.limits.${e} must be an integer, got ${String(r[e])}`)}function ht(e){let t=e&&typeof e==`object`?e:{};return t.limits&&typeof t.limits==`object`?t.limits:{}}function gt(e,t){if(!e||typeof e!=`object`)return;let n=e,r=n.dependencies,i=n.limits;if(!r||typeof r!=`object`||!i||typeof i!=`object`)return;let a=M(r).length,o=i,s=t.maxDependencies,c=o.maxDependencies,l=typeof s==`number`?s:c;if(typeof l==`number`&&l>0&&a>l)throw RangeError(`[validation-plugin] validateLimitsConsistency: dependency count (${a}) exceeds maxDependencies limit (${l})`)}function _t(e,t){gt(t,ht(e))}function z(e,t){if(typeof e==`string`&&e&&!F(N(t,`validateResolvedDefaultRoute`).tree,e))throw Error(`[validation-plugin] defaultRoute resolved to non-existent route: "${e}"`)}const vt=Object.keys;function yt(e,t){if(e!==void 0){if(typeof e!=`string`&&typeof e!=`function`)throw TypeError(`[router.addRoute] forwardTo must be a string or function for route "${t}", got ${_(e)}`);if(typeof e==`function`){let n=e.constructor.name===`AsyncFunction`,r=e.toString().includes(`__awaiter`);if(n||r)throw TypeError(`[router.addRoute] forwardTo callback cannot be async for route "${t}". Async functions break matchPath/buildPath.`)}}}function B(e,t,n){if(e!==void 0&&(typeof e!=`object`||!e||Array.isArray(e)))throw TypeError(`[router.addRoute] ${t} must be an object for route "${n}", got ${_(e)}`)}function V(e,t){if(e.canActivate!==void 0&&typeof e.canActivate!=`function`)throw TypeError(`[router.addRoute] canActivate must be a function for route "${t}", got ${_(e.canActivate)}`);if(e.canDeactivate!==void 0&&typeof e.canDeactivate!=`function`)throw TypeError(`[router.addRoute] canDeactivate must be a function for route "${t}", got ${_(e.canDeactivate)}`);if(B(e.defaultParams,`defaultParams`,t),B(e.defaultSearch,`defaultSearch`,t),e.decodeParams?.constructor.name===`AsyncFunction`)throw TypeError(`[router.addRoute] decodeParams cannot be async for route "${t}". Async functions break matchPath/buildPath.`);if(e.encodeParams?.constructor.name===`AsyncFunction`)throw TypeError(`[router.addRoute] encodeParams cannot be async for route "${t}". Async functions break matchPath/buildPath.`);if(yt(e.forwardTo,t),e.children)for(let n of e.children)V(n,`${t}.${n.name}`)}function bt(e){let t=new Set,n=/[*:]([A-Z_a-z]\w*)/g,r;for(;(r=n.exec(e))!==null;)t.add(r[1]);return t}function H(e){let t=new Set;for(let n of e)for(let e of bt(n))t.add(e);return t}function U(e,t,n=``,r=[]){for(let i of e){let e=n?`${n}.${i.name}`:i.name,a=[...r,i.path];if(e===t)return a;if(i.children&&t.startsWith(`${e}.`))return U(i.children,t,e,a)}throw Error(`[internal] collectPathsToRoute: route "${t}" not found`)}function W(e,t=``){let n=new Set;for(let r of e){let e=t?`${t}.${r.name}`:r.name;if(n.add(e),r.children)for(let t of W(r.children,e))n.add(t)}return n}function G(e,t=``){let n=new Map;for(let r of e){let e=t?`${t}.${r.name}`:r.name;if(r.forwardTo&&typeof r.forwardTo==`string`&&n.set(e,r.forwardTo),r.children)for(let[t,i]of G(r.children,e))n.set(t,i)}return n}function K(e){let t=new Set;for(let n of e)for(let e of n.paramMeta.urlParams)t.add(e);return t}function xt(e,t,n,r){return t?K(n.getSegmentsByName(e)??[]):H(U(r,e))}const St=new Set;function Ct(e,t,n,r,i,a){let o=i.hasRoute(t),s=r.has(t);if(!o&&!s)throw ReferenceError(`[router.addRoute] forwardTo target "${t}" does not exist for route "${e}"`);let c=new Set([...a,...H(U(n,e))]),l=[...xt(t,o,i,n)].filter(e=>!c.has(e));if(l.length>0)throw Error(`[router.addRoute] forwardTo target "${t}" requires params [${l.join(`, `)}] that are not available in source route "${e}"`)}function wt(n,r,i,a){let o=W(n),s=a?new Set([...o].map(e=>`${a}.${e}`)):o,c=a?K(i.getSegmentsByName(a)):St,l=G(n),u={...r};for(let[e,n]of l)(0,t.putField)(u,e,n);for(let[e,t]of l)Ct(e,t,n,s,i,c);for(let t of vt(u))(0,e.resolveForwardChain)(t,u)}function q(e,t){if(e.startsWith(`@@`))throw Error(`[router.${t}] Route name "${e}" uses the reserved "@@" prefix. Routes with this prefix are internal and cannot be modified through the public API.`)}function J(e,t){for(let n of e)n&&typeof n==`object`&&typeof n.name==`string`&&(q(n.name,t),n.children&&J(n.children,t))}function Tt(e){g(e,`removeRoute`)}function Et(e){if(typeof e!=`string`)throw TypeError(`[router.setRootPath] rootPath must be a string, got ${_(e)}`)}function Y(e){return e.constructor.name===`AsyncFunction`||String(e).includes(`__awaiter`)}function Dt(e){let t=e;if(t.canActivate!==void 0&&typeof t.canActivate!=`function`)throw TypeError(`[router.addRoute] canActivate must be a function, got ${_(t.canActivate)}`);if(t.canDeactivate!==void 0&&typeof t.canDeactivate!=`function`)throw TypeError(`[router.addRoute] canDeactivate must be a function, got ${_(t.canDeactivate)}`)}function Ot(e){let t=e,n=t.name;if(t.decodeParams!==void 0&&Y(t.decodeParams))throw TypeError(`[router.addRoute] decodeParams cannot be async for route "${String(n)}"`);if(t.encodeParams!==void 0&&Y(t.encodeParams))throw TypeError(`[router.addRoute] encodeParams cannot be async for route "${String(n)}"`);if(typeof t.forwardTo==`function`&&Y(t.forwardTo))throw TypeError(`[router.addRoute] forwardTo callback cannot be async for route "${String(n)}"`)}function kt(e){for(let t of e){if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`[router.addRoute] Route must be an object, got ${_(t)}`);V(t,t.name)}}function At(e){if(typeof e!=`string`||e===``)throw TypeError(`[router.addRoute] parent option must be a non-empty string, got ${_(e)}`);g(e,`addRoute`)}function jt(e,t,n,r){if(!a(e))throw TypeError(`[router.isActiveRoute] name must be a string, got ${typeof e}`);if(t!==void 0&&!f(t))throw TypeError(`[router.isActiveRoute] params must be a plain object, got ${_(t)}`);if(n!==void 0&&typeof n!=`boolean`)throw TypeError(`[router.isActiveRoute] strictEquality must be a boolean, got ${typeof n}`);if(r!==void 0&&typeof r!=`boolean`)throw TypeError(`[router.isActiveRoute] ignoreQueryParams must be a boolean, got ${typeof r}`)}function Mt(e,t,n){if(!a(e))throw TypeError(`[router.${n}] Invalid routeName: ${_(e)}. Expected string.`);if(!f(t))throw TypeError(`[router.${n}] Invalid routeParams: ${_(t)}. Expected plain object.`)}function Nt(e,t){if(g(e,`updateRoute`),e===``)throw ReferenceError(`[router.updateRoute] Invalid name: empty string. Cannot update root node.`);if(t===null)throw TypeError(`[router.updateRoute] updates must be an object, got null`);if(typeof t!=`object`||Array.isArray(t))throw TypeError(`[router.updateRoute] updates must be an object, got ${_(t)}`)}function X(e,t){if(e.constructor.name===`AsyncFunction`||e.toString().includes(`__awaiter`))throw TypeError(`[router.updateRoute] ${t} cannot be an async function`)}function Z(e,t){if(e!=null){if(typeof e!=`function`)throw TypeError(`[router.updateRoute] ${t} must be a function or null, got ${typeof e}`);X(e,t)}}function Pt(e){let{forwardTo:t,defaultParams:n,defaultSearch:r,decodeParams:i,encodeParams:a,canActivate:o,canDeactivate:s}=e;if(t!=null){if(typeof t!=`string`&&typeof t!=`function`)throw TypeError(`[router.updateRoute] forwardTo must be a string, function, or null, got ${_(t)}`);typeof t==`function`&&X(t,`forwardTo callback`)}Q(n,`defaultParams`),Q(r,`defaultSearch`),Z(i,`decodeParams`),Z(a,`encodeParams`),Z(o,`canActivate`),Z(s,`canDeactivate`)}function Q(e,t){if(e!=null&&(typeof e!=`object`||Array.isArray(e)))throw TypeError(`[router.updateRoute] ${t} must be an object or null, got ${_(e)}`)}function Ft(e){if(!a(e)||e===``)throw TypeError(`[router.buildPath] route must be a non-empty string, got ${typeof e==`string`?`""`:typeof e}`)}function It(e){if(!a(e))throw TypeError(`[router.matchPath] path must be a string, got ${typeof e}`)}function Lt(e){if(!a(e))throw TypeError(`[router.shouldUpdateNode] nodeName must be a string, got ${typeof e}`)}function Rt(e,t,r,i,a){if(a&&t){let e=t;for(let t of a.split(`.`))if(e=e.children.get(t),!e)throw ReferenceError(`[router.addRoute] Parent route "${a}" does not exist`)}let o=new Set,s=new Map;for(let r of e)(0,n.validateRoute)(r,`addRoute`,t,a??``,o,s);r&&i&&wt(e,i,r,a)}function zt(e){let t=new Set;for(let n of e)for(let e of n.paramMeta.urlParams)t.add(e);return t}function $(e,t,n){let r=n.getSegmentsByName(e),i=n.getSegmentsByName(t),a=zt(r),o=[];for(let e of i)for(let t of e.paramMeta.urlParams)o.push(t);let s=o.filter(e=>!a.has(e));if(s.length>0)throw Error(`[router.addRoute] forwardTo target "${t}" requires params [${s.join(`, `)}] that are not available in source route "${e}"`)}function Bt(t,n,r){let i={...r.forwardMap,[t]:n};(0,e.resolveForwardChain)(t,i)}function Vt(e,t,n,r,i){if(!n(e))throw ReferenceError(`[router.updateRoute] route "${e}" does not exist`);if(t!=null&&typeof t==`string`){if(!n(t))throw Error(`[router.updateRoute] forwardTo target "${t}" does not exist`);$(e,t,r),Bt(e,t,i)}}function Ht(e,t,n){if(!a(e))throw TypeError(`[router.makeState] Invalid name: ${_(e)}. Expected string.`);if(t!==void 0&&!f(t))throw TypeError(`[router.makeState] Invalid params: ${_(t)}. Expected plain object.`);if(n!==void 0&&!a(n))throw TypeError(`[router.makeState] Invalid path: ${_(n)}. Expected string.`)}function Ut(){let e=new Set;return function(t,n){let r=`${t} ${n}`;e.has(r)||(e.add(r),console.warn(`[router] Query key "${n}" is not declared on route "${t}" (\`?${n}\`), so the current \`queryParamsMode\` will not print it — it was dropped from \`state.search\` rather than published beside a \`state.path\` that cannot show it. Declare it on the route path, or use \`queryParamsMode: "loose"\` to keep undeclared keys. A \`defaultSearch\` entry for "${n}" is dead config in this mode for the same reason.`))}}function Wt(){let e=new Set;return function(t,n){let r=`${t} ${n}`;e.has(r)||(e.add(r),console.warn(`[router] Param "${n}" is declared nowhere on route "${t}" — neither as a path slot (:${n}) nor as a query param (?${n}), so it stays in state.params but never reaches the URL. The state will not round-trip: matchPath(state.path) cannot recover it. Declare it on the route path if it belongs in the URL, or pass it through the search channel; keep it here only if it is deliberately app-level data.`))}}function Gt(e,t){return{routes:{validateBuildPathArgs:Ft,validateMatchPathArgs:It,validateIsActiveRouteArgs:jt,validateShouldUpdateNodeArgs:Lt,validateStateBuilderArgs:Mt,validateAddRouteArgs(e){kt(e)},validateRoutes(e,t,n){let r=t;Rt(e,r.tree,r.matcher,r.config?.forwardMap,n)},validateRemoveRouteArgs:Tt,validateUpdateRouteBasicArgs:Nt,validateUpdateRoutePropertyTypes(e,t){let n=t;Pt({forwardTo:n.forwardTo,defaultParams:n.defaultParams,defaultSearch:n.defaultSearch,decodeParams:n.decodeParams,encodeParams:n.encodeParams,canActivate:n.canActivate,canDeactivate:n.canDeactivate})},validateUpdateRoute(e,t,n){let r=n,i=t.forwardTo;Vt(e,i,e=>r.matcher.hasRoute(e),r.matcher,r.config)},validateParentOption(e,t){At(e);let n=t;for(let t of e.split(`.`)){let r=n.children.get(t);if(!r)throw ReferenceError(`[router.addRoute] Parent route "${e}" does not exist`);n=r}},validateRouteName(e,t){g(e,t)},throwIfInternalRoute(e,t){q(e,t)},throwIfInternalRouteInArray(e,t){J(e,t)},validateSetRootPathArgs:Et,guardRouteCallbacks:Dt,guardNoAsyncCallbacks:Ot},options:{validateOptions:Qe,validateResolvedDefaultRoute:z},dependencies:{validateDependencyName:ve,validateSetDependencyArgs(e,t,n){ye(e)},validateDependenciesObject:be,validateDependencyExists(e,t){let n=t.dependencies?.[e];xe(n,e)},validateDependencyCount(t,n){Se(t,n,e.logger)},validateCloneArgs:Ce,warnOverwrite(t,n){we(t,n,e.logger)},warnBatchOverwrite(t,n){Te(t,n,e.logger)},warnRemoveNonExistent(t){Ee(t,e.logger)}},plugins:{validatePluginLimit(e,t){tt(e,1,t?.maxPlugins)},validateNoDuplicatePlugins:nt,validatePluginKeys:it,validateCountThresholds(t){rt(t,e.getOptions().limits?.maxPlugins??r.maxPlugins,e.logger)},warnBatchDuplicates(){at(e.logger)},warnPluginMethodType(t){ot(t,e.logger)},warnPluginAfterStart(t){st(t,e.logger)}},lifecycle:{validateHandler:S,validateHandlerLimit(t,n){Me(t,n,e.getOptions().limits?.maxLifecycleHandlers??r.maxLifecycleHandlers)},validateCountThresholds(t,n){Ne(t,n,e.getOptions().limits?.maxLifecycleHandlers??r.maxLifecycleHandlers,e.logger)},warnOverwrite(t,n,r){Pe(t,n,r,e.logger)},warnAsyncGuardSync(t,n){Fe(t,n,e.logger)}},navigation:{validateNavigateArgs:Le,validateNavigateToDefaultArgs(n){Re(n),t.check(e.logger)},validateNavigateToStateArgs:ze,validateNavigationOptions:Be,validateParams:He,validateSearch:Ue,validateStartArgs:We},state:{validateMakeStateArgs:Ht,reportDroppedQueryKey:Ut(),reportUndeclaredParamKey:Wt(),validateAreStatesEqualArgs(e,t,n){if(!h(e))throw TypeError(`[router.areStatesEqual] Invalid state1: ${_(e)}. Expected State object.`);if(!h(t))throw TypeError(`[router.areStatesEqual] Invalid state2: ${_(t)}. Expected State object.`);if(n!==void 0&&!o(n))throw TypeError(`[router.areStatesEqual] Invalid ignoreQueryParams: ${_(n)}. Expected boolean.`)}},eventBus:{validateListenerArgs(e,t){Ae(e,t)},validateCountThresholds(t,n,i){let a=e.getOptions().limits?.maxListeners??r.maxListeners;je(t,n,i,e.logger,a)}}}}function Kt(){return r=>{let i=(0,n.getInternals)(r);if(r.isActive())throw(0,t.freezeThrownError)(new e.RouterError(`VALIDATION_PLUGIN_AFTER_START`,{message:`validation-plugin must be registered before router.start()`}));let a=new he;a.watch(i.getAdoptedOrigins()),i.validator=Gt(i,a);try{let e=i.routeGetStore(),t=i.dependenciesGetStore(),n=i.getOptions();ut(e),dt(e),ft(e),pt(e),mt(t),_t(n,t),i.validator.options.validateOptions(n,`constructor (retrospective)`),typeof n.defaultRoute==`string`&&z(n.defaultRoute,e)}catch(e){throw i.validator=null,e}return{teardown(){i.validator=null}}}}exports.validationPlugin=Kt;
2
2
  //# sourceMappingURL=index.js.map