@real-router/core 0.40.1 → 0.42.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-B2tmtNiM.d.ts +353 -0
- package/dist/cjs/Router-CVNR-dug.js +6 -0
- package/dist/cjs/Router-CVNR-dug.js.map +1 -0
- package/dist/cjs/RouterError-BkgjTHQg.js +2 -0
- package/dist/cjs/RouterError-BkgjTHQg.js.map +1 -0
- package/dist/cjs/RouterValidator-TUi8eT8Q.d.ts +112 -0
- package/dist/cjs/api.d.ts +17 -12
- package/dist/cjs/api.js +2 -1
- package/dist/cjs/api.js.map +1 -1
- package/dist/cjs/getPluginApi-BXrM_Nwv.js +2 -0
- package/dist/cjs/getPluginApi-BXrM_Nwv.js.map +1 -0
- package/dist/cjs/index.d.ts +206 -196
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internals-na15rxo_.js +2 -0
- package/dist/cjs/internals-na15rxo_.js.map +1 -0
- package/dist/cjs/utils.d.ts +6 -3
- package/dist/cjs/utils.js +2 -1
- package/dist/cjs/utils.js.map +1 -1
- package/dist/cjs/validation.d.ts +153 -152
- package/dist/cjs/validation.js +1 -1
- package/dist/esm/Router-4JRfQLMM.d.mts +353 -0
- package/dist/esm/Router-C_k70gHi.mjs +6 -0
- package/dist/esm/Router-C_k70gHi.mjs.map +1 -0
- package/dist/esm/RouterError-D0RlQE_5.mjs +2 -0
- package/dist/esm/RouterError-D0RlQE_5.mjs.map +1 -0
- package/dist/esm/RouterValidator-DphcVMEp.d.mts +112 -0
- package/dist/esm/api.d.mts +17 -12
- package/dist/esm/api.mjs +2 -1
- package/dist/esm/api.mjs.map +1 -1
- package/dist/esm/getPluginApi-D0bBPuLp.mjs +2 -0
- package/dist/esm/getPluginApi-D0bBPuLp.mjs.map +1 -0
- package/dist/esm/index.d.mts +206 -196
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/internals-CCymabFj.mjs +2 -0
- package/dist/{cjs/validation.js.map → esm/internals-CCymabFj.mjs.map} +1 -1
- package/dist/esm/utils.d.mts +6 -3
- package/dist/esm/utils.mjs +2 -1
- package/dist/esm/utils.mjs.map +1 -1
- package/dist/esm/validation.d.mts +153 -152
- package/dist/esm/validation.mjs +1 -1
- package/package.json +5 -7
- package/src/Router.ts +4 -6
- package/src/api/getPluginApi.ts +2 -3
- package/src/helpers.ts +9 -7
- package/src/index.ts +0 -1
- package/src/internals.ts +4 -5
- package/src/namespaces/NavigationNamespace/NavigationNamespace.ts +0 -1
- package/src/namespaces/OptionsNamespace/constants.ts +1 -0
- 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/cjs/Router-B-Pev7K2.d.ts +0 -46
- package/dist/cjs/RouterValidator-mx2Zooya.d.ts +0 -136
- package/dist/cjs/index.d-y2b-8_3Y.d.ts +0 -236
- package/dist/cjs/metafile-cjs.json +0 -1
- package/dist/esm/Router-B-Pev7K2.d.mts +0 -46
- package/dist/esm/RouterValidator-mx2Zooya.d.mts +0 -136
- package/dist/esm/chunk-5QXFUUDL.mjs +0 -1
- package/dist/esm/chunk-5QXFUUDL.mjs.map +0 -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 +0 -1
- package/dist/esm/chunk-QUUNDESP.mjs.map +0 -1
- package/dist/esm/index.d-y2b-8_3Y.d.mts +0 -236
- package/dist/esm/metafile-esm.json +0 -1
- package/dist/esm/validation.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/constants.ts","../../src/helpers.ts","../../src/RouterError.ts"],"names":[],"mappings":";AAyBO,IAAM,UAAA,GAAkC,OAAO,MAAA,CAAO;AAAA,EAC3D,kBAAA,EAAoB,aAAA;AAAA;AAAA,EACpB,sBAAA,EAAwB,wBAAA;AAAA;AAAA,EACxB,sBAAA,EAAwB,iBAAA;AAAA;AAAA,EACxB,eAAA,EAAiB,iBAAA;AAAA;AAAA,EACjB,WAAA,EAAa,aAAA;AAAA;AAAA,EACb,iBAAA,EAAmB,mBAAA;AAAA;AAAA,EACnB,eAAA,EAAiB,iBAAA;AAAA;AAAA,EACjB,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAChB,oBAAA,EAAsB,WAAA;AAAA;AAAA,EACtB,eAAA,EAAiB,UAAA;AAAA;AAAA,EACjB,eAAA,EAAiB;AAAA;AACnB,CAAC;AAMM,IAAM,aAAA,GAAgB;AAEtB,IAAM,SAAA,GAAuB;AAAA,EAClC;AACF;AAMO,IAAM,OAAA,GAA4B;AAAA,EACvC,YAAA,EAAc,SAAA;AAAA;AAAA,EACd,WAAA,EAAa,QAAA;AAAA;AAAA,EACb,gBAAA,EAAkB,mBAAA;AAAA;AAAA,EAClB,iBAAA,EAAmB,oBAAA;AAAA;AAAA,EACnB,kBAAA,EAAoB,qBAAA;AAAA;AAAA,EACpB,gBAAA,EAAkB;AAAA;AACpB;AAMO,IAAM,MAAA,GAAyB;AAAA,EACpC,YAAA,EAAc,QAAA;AAAA;AAAA,EACd,WAAA,EAAa,OAAA;AAAA;AAAA,EACb,gBAAA,EAAkB,SAAA;AAAA;AAAA,EAClB,iBAAA,EAAmB,UAAA;AAAA;AAAA,EACnB,k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;AAAA,MACX,SAAS,IAAA,CAAK;AAAA,KAChB;AAEA,IAAA,IAAI,IAAA,CAAK,YAAY,MAAA,EAAW;AAC9B,MAAA,MAAA,CAAO,UAAU,IAAA,CAAK,OAAA;AAAA,IACxB;AACA,IAAA,IAAI,IAAA,CAAK,SAAS,MAAA,EAAW;AAC3B,MAAA,MAAA,CAAO,OAAO,IAAA,CAAK,IAAA;AAAA,IACrB;AACA,IAAA,IAAI,IAAA,CAAK,aAAa,MAAA,EAAW;AAC/B,MAAA,MAAA,CAAO,WAAW,IAAA,CAAK,QAAA;AAAA,IACzB;AAKA,IAAA,MAAM,WAAA,uBAAkB,GAAA,CAAI;AAAA,MAC1B,MAAA;AAAA,MACA,SAAA;AAAA,MACA,SAAA;AAAA,MACA,MAAA;AAAA,MACA,UAAA;AAAA,MACA;AAAA,KACD,CAAA;AAED,IAAA,KAAA,MAAW,OAAO,IAAA,EAAM;AACtB,MAAA,IAAI,MAAA,CAAO,OAAO,IAAA,EAAM,GAAG,KAAK,CAAC,WAAA,CAAY,GAAA,CAAI,GAAG,CAAA,EAAG;AACrD,QAAA,MAAA,CAAO,GAAG,CAAA,GAAI,IAAA,CAAK,GAAG,CAAA;AAAA,MACxB;AAAA,IACF;AAEA,IAAA,OAAO,MAAA;AAAA,EACT;AACF","file":"chunk-5QXFUUDL.mjs","sourcesContent":["// packages/core/src/constants.ts\n\nimport type {\n EventToNameMap,\n EventToPluginMap,\n ErrorCodeToValueMap,\n ErrorCodeKeys,\n ErrorCodeValues,\n} from \"@real-router/types\";\n\nexport type ConstantsKeys = \"UNKNOWN_ROUTE\";\n\nexport type Constants = Record<ConstantsKeys, string>;\n\n// =============================================================================\n// Error Codes (migrated from router-error)\n// =============================================================================\n\nexport type ErrorCodes = Record<ErrorCodeKeys, ErrorCodeValues>;\n\n/**\n * Error codes for router operations.\n * Used to identify specific failure scenarios in navigation and lifecycle.\n * Frozen to prevent accidental modifications.\n */\nexport const errorCodes: ErrorCodeToValueMap = Object.freeze({\n ROUTER_NOT_STARTED: \"NOT_STARTED\", // navigate() called before start()\n NO_START_PATH_OR_STATE: \"NO_START_PATH_OR_STATE\", // start() without initial route\n ROUTER_ALREADY_STARTED: \"ALREADY_STARTED\", // start() called twice\n ROUTE_NOT_FOUND: \"ROUTE_NOT_FOUND\", // Navigation to non-existent route\n SAME_STATES: \"SAME_STATES\", // Navigate to current route without reload\n CANNOT_DEACTIVATE: \"CANNOT_DEACTIVATE\", // canDeactivate guard blocked navigation\n CANNOT_ACTIVATE: \"CANNOT_ACTIVATE\", // canActivate guard blocked navigation\n TRANSITION_ERR: \"TRANSITION_ERR\", // Generic transition failure\n TRANSITION_CANCELLED: \"CANCELLED\", // Navigation cancelled by user or new navigation\n ROUTER_DISPOSED: \"DISPOSED\", // Router has been disposed\n PLUGIN_CONFLICT: \"PLUGIN_CONFLICT\", // Plugin tried to extend router with already-existing property\n});\n\n/**\n * General router constants.\n * Special route names and identifiers.\n */\nexport const UNKNOWN_ROUTE = \"@@router/UNKNOWN_ROUTE\";\n\nexport const constants: Constants = {\n UNKNOWN_ROUTE,\n};\n\n/**\n * Plugin method names.\n * Maps to methods that plugins can implement to hook into router lifecycle.\n */\nexport const plugins: EventToPluginMap = {\n ROUTER_START: \"onStart\", // Plugin method called when router starts\n ROUTER_STOP: \"onStop\", // Plugin method called when router stops\n TRANSITION_START: \"onTransitionStart\", // Plugin method called when navigation begins\n TRANSITION_CANCEL: \"onTransitionCancel\", // Plugin method called when navigation cancelled\n TRANSITION_SUCCESS: \"onTransitionSuccess\", // Plugin method called when navigation succeeds\n TRANSITION_ERROR: \"onTransitionError\", // Plugin method called when navigation fails\n};\n\n/**\n * Event names for router event system.\n * Used with addEventListener/removeEventListener for reactive subscriptions.\n */\nexport const events: EventToNameMap = {\n ROUTER_START: \"$start\", // Emitted when router.start() succeeds\n ROUTER_STOP: \"$stop\", // Emitted when router.stop() is called\n TRANSITION_START: \"$$start\", // Emitted when navigation begins\n TRANSITION_CANCEL: \"$$cancel\", // Emitted when navigation is cancelled\n TRANSITION_SUCCESS: \"$$success\", // Emitted when navigation completes successfully\n TRANSITION_ERROR: \"$$error\", // Emitted when navigation fails\n};\n\nexport const DEFAULT_LIMITS = {\n maxDependencies: 100,\n maxPlugins: 50,\n maxListeners: 10_000,\n warnListeners: 1000,\n maxEventDepth: 5,\n maxLifecycleHandlers: 200,\n} as const;\n\nexport const EMPTY_PARAMS: Readonly<Record<string, never>> = Object.freeze({});\n","// packages/core/src/helpers.ts\n\nimport { DEFAULT_LIMITS } from \"./constants\";\n\nimport type { Limits } from \"./types\";\nimport type { State, LimitsConfig } from \"@real-router/types\";\n\n// =============================================================================\n// State Helpers\n// =============================================================================\n\n/**\n * Structural type guard for State object.\n * Only checks required fields exist with correct types.\n * Does NOT validate params serializability (allows circular refs).\n *\n * Use `isState` from type-guards for full validation (serializable params).\n * Use this for internal operations like deepFreezeState that handle any object structure.\n *\n * @param value - Value to check\n * @returns true if value has State structure\n * @internal\n */\nfunction isStateStructural(value: unknown): value is State {\n if (value === null || typeof value !== \"object\") {\n return false;\n }\n\n const obj = value as Record<string, unknown>;\n\n return (\n typeof obj.name === \"string\" &&\n typeof obj.path === \"string\" &&\n typeof obj.params === \"object\" &&\n obj.params !== null\n );\n}\n\n/**\n * Deep freezes State object to prevent mutations.\n * Creates a deep clone first, then recursively freezes the clone and all nested objects.\n * Uses simple recursive freezing after cloning (no need for WeakSet since clone has no circular refs).\n *\n * @param state - The State object to freeze\n * @returns A frozen deep clone of the state\n * @throws {TypeError} If state is not a valid State object\n *\n * @example\n * const state = { name: 'home', params: {}, path: '/' };\n * const frozen = deepFreezeState(state);\n * // frozen.params is now immutable\n * // original state is unchanged\n */\nexport function deepFreezeState<T extends State>(state: T): T {\n // Early return for null/undefined\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!state) {\n return state;\n }\n\n // Validate State structure (structural check, allows circular refs)\n if (!isStateStructural(state)) {\n throw new TypeError(\n `[deepFreezeState] Expected valid State object, got: ${typeof state}`,\n );\n }\n\n // Create a deep clone to avoid mutating the original\n // structuredClone preserves circular references, so we need to track visited objects\n const clonedState = structuredClone(state);\n\n // WeakSet to track visited objects (prevent infinite recursion with circular refs)\n const visited = new WeakSet<object>();\n\n // Recursive freeze function with circular reference protection\n function freezeClonedRecursive(obj: unknown): void {\n // Skip primitives, null, undefined\n // Note: typeof undefined === \"undefined\" !== \"object\", so checking undefined is redundant\n if (obj === null || typeof obj !== \"object\") {\n return;\n }\n\n // Skip already visited objects (circular reference protection)\n if (visited.has(obj)) {\n return;\n }\n\n // Mark as visited\n visited.add(obj);\n\n // Freeze the object/array itself\n Object.freeze(obj);\n\n // Get all values to freeze recursively\n const values = Array.isArray(obj) ? obj : Object.values(obj);\n\n // Recursively freeze nested values\n for (const value of values) {\n freezeClonedRecursive(value);\n }\n }\n\n // Freeze the entire cloned state tree\n freezeClonedRecursive(clonedState);\n\n return clonedState;\n}\n\n// WeakSet to track already frozen root objects for O(1) re-freeze check\nconst frozenRoots = new WeakSet<object>();\n\n// Module-scope recursive freeze function - better JIT optimization, no allocation per call\nfunction freezeRecursive(obj: unknown): void {\n // Skip primitives, null\n if (obj === null || typeof obj !== \"object\") {\n return;\n }\n\n // Skip already frozen objects (handles potential shared refs)\n if (Object.isFrozen(obj)) {\n return;\n }\n\n // Freeze the object/array\n Object.freeze(obj);\n\n // Iterate without Object.values() allocation\n if (Array.isArray(obj)) {\n for (const item of obj) {\n freezeRecursive(item);\n }\n } else {\n for (const key in obj) {\n freezeRecursive((obj as Record<string, unknown>)[key]);\n }\n }\n}\n\n/**\n * Freezes State object in-place without cloning.\n * Optimized for hot paths where state is known to be a fresh object.\n *\n * IMPORTANT: Only use this when you know the state is a fresh object\n * that hasn't been exposed to external code yet (e.g., from makeState()).\n *\n * @param state - The State object to freeze (must be a fresh object)\n * @returns The same state object, now frozen\n * @internal\n */\nexport function freezeStateInPlace<T extends State>(state: T): T {\n // Early return for null/undefined - state from makeState() is never null\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!state) {\n return state;\n }\n\n // Fast path: already processed root object - O(1) check\n if (frozenRoots.has(state)) {\n return state;\n }\n\n // Freeze the entire state tree\n freezeRecursive(state);\n\n // Mark root as processed for future calls\n frozenRoots.add(state);\n\n return state;\n}\n\n/**\n * Merges user limits with defaults.\n * Returns frozen object for immutability.\n */\nexport function createLimits(userLimits: Partial<LimitsConfig> = {}): Limits {\n return { ...DEFAULT_LIMITS, ...userLimits };\n}\n","// packages/core/src/RouterError.ts\n\nimport { errorCodes } from \"./constants\";\nimport { deepFreezeState } from \"./helpers\";\n\nimport type { State } from \"@real-router/types\";\n\n// Pre-compute Set of error code values for O(1) lookup in setCode()\n// This avoids creating array and doing linear search on every setCode() call\nconst errorCodeValues = new Set(Object.values(errorCodes));\n\n// Reserved built-in properties - throw error if user tries to set these\nconst reservedProperties = new Set([\"code\", \"segment\", \"path\", \"redirect\"]);\n\n// Reserved method names - silently ignore attempts to overwrite these\nconst reservedMethods = new Set([\n \"setCode\",\n \"setErrorInstance\",\n \"setAdditionalFields\",\n \"hasField\",\n \"getField\",\n \"toJSON\",\n]);\n\nexport class RouterError extends Error {\n [key: string]: unknown;\n\n // Using public properties to ensure structural compatibility\n // with RouterError interface in core-types\n readonly segment: string | undefined;\n readonly path: string | undefined;\n readonly redirect: State | undefined;\n\n // Note: code appears to be writable but setCode() should be used\n // to properly update both code and message together\n code: string;\n\n /**\n * Creates a new RouterError instance.\n *\n * The options object accepts built-in fields (message, segment, path, redirect)\n * and any additional custom fields, which will all be attached to the error instance.\n *\n * @param code - The error code (e.g., \"ROUTE_NOT_FOUND\", \"CANNOT_ACTIVATE\")\n * @param options - Optional configuration object\n * @param options.message - Custom error message (defaults to code if not provided)\n * @param options.segment - The route segment where the error occurred\n * @param options.path - The full path where the error occurred\n * @param options.redirect - Optional redirect state for navigation errors\n *\n * @example\n * ```typescript\n * // Basic error\n * const err1 = new RouterError(\"ROUTE_NOT_FOUND\");\n *\n * // Error with custom message\n * const err2 = new RouterError(\"ERR\", { message: \"Something went wrong\" });\n *\n * // Error with context and custom fields\n * const err3 = new RouterError(\"CANNOT_ACTIVATE\", {\n * message: \"Insufficient permissions\",\n * segment: \"admin\",\n * path: \"/admin/users\",\n * userId: \"123\" // custom field\n * });\n *\n * // Error with redirect\n * const err4 = new RouterError(\"TRANSITION_ERR\", {\n * redirect: { name: \"home\", path: \"/\", params: {} }\n * });\n * ```\n */\n constructor(\n code: string,\n {\n message,\n segment,\n path,\n redirect,\n ...rest\n }: {\n [key: string]: unknown;\n message?: string | undefined;\n segment?: string | undefined;\n path?: string | undefined;\n redirect?: State | undefined;\n } = {},\n ) {\n super(message ?? code);\n\n this.code = code;\n this.segment = segment;\n this.path = path;\n // Deep freeze redirect to prevent mutations (creates a frozen clone)\n this.redirect = redirect ? deepFreezeState(redirect) : undefined;\n\n // Assign custom fields, checking reserved properties and filtering out reserved method names\n // Issue #39: Throw for reserved properties to match setAdditionalFields behavior\n for (const [key, value] of Object.entries(rest)) {\n if (reservedProperties.has(key)) {\n throw new TypeError(\n `[RouterError] Cannot set reserved property \"${key}\"`,\n );\n }\n\n if (!reservedMethods.has(key)) {\n this[key] = value;\n }\n }\n }\n\n /**\n * Updates the error code and conditionally updates the message.\n *\n * If the current message is one of the standard error code values\n * (e.g., \"ROUTE_NOT_FOUND\", \"SAME_STATES\"), it will be replaced with the new code.\n * This allows keeping error messages in sync with codes when using standard error codes.\n *\n * If the message is custom (not a standard error code), it will be preserved.\n *\n * @param newCode - The new error code to set\n *\n * @example\n * // Message follows code (standard error code as message)\n * const err = new RouterError(\"ROUTE_NOT_FOUND\", { message: \"ROUTE_NOT_FOUND\" });\n * err.setCode(\"CUSTOM_ERROR\"); // message becomes \"CUSTOM_ERROR\"\n *\n * @example\n * // Custom message is preserved\n * const err = new RouterError(\"ERR\", { message: \"Custom error message\" });\n * err.setCode(\"NEW_CODE\"); // message stays \"Custom error message\"\n */\n setCode(newCode: string): void {\n this.code = newCode;\n\n // Only update message if it's a standard error code value (not a custom message)\n if (errorCodeValues.has(this.message)) {\n this.message = newCode;\n }\n }\n\n /**\n * Copies properties from another Error instance to this RouterError.\n *\n * This method updates the message, cause, and stack trace from the provided error.\n * Useful for wrapping native errors while preserving error context.\n *\n * @param err - The Error instance to copy properties from\n * @throws {TypeError} If err is null or undefined\n *\n * @example\n * ```typescript\n * const routerErr = new RouterError(\"TRANSITION_ERR\");\n * try {\n * // some operation that might fail\n * } catch (nativeErr) {\n * routerErr.setErrorInstance(nativeErr);\n * throw routerErr;\n * }\n * ```\n */\n setErrorInstance(err: Error): void {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!err) {\n throw new TypeError(\n \"[RouterError.setErrorInstance] err parameter is required and must be an Error instance\",\n );\n }\n\n this.message = err.message;\n this.cause = err.cause;\n this.stack = err.stack ?? \"\";\n }\n\n /**\n * Adds custom fields to the error object.\n *\n * This method allows attaching arbitrary data to the error for debugging or logging purposes.\n * All fields become accessible as properties on the error instance and are included in JSON serialization.\n *\n * Reserved method names (setCode, setErrorInstance, setAdditionalFields, hasField, getField, toJSON)\n * are automatically filtered out to prevent accidental overwriting of class methods.\n *\n * @param fields - Object containing custom fields to add to the error\n *\n * @example\n * ```typescript\n * const err = new RouterError(\"CANNOT_ACTIVATE\");\n * err.setAdditionalFields({\n * userId: \"123\",\n * attemptedRoute: \"/admin\",\n * reason: \"insufficient permissions\"\n * });\n *\n * console.log(err.userId); // \"123\"\n * console.log(JSON.stringify(err)); // includes all custom fields\n * ```\n */\n setAdditionalFields(fields: Record<string, unknown>): void {\n // Assign fields, throwing for reserved properties, silently ignoring methods\n for (const [key, value] of Object.entries(fields)) {\n if (reservedProperties.has(key)) {\n throw new TypeError(\n `[RouterError.setAdditionalFields] Cannot set reserved property \"${key}\"`,\n );\n }\n\n if (!reservedMethods.has(key)) {\n this[key] = value;\n }\n }\n }\n\n /**\n * Checks if a custom field exists on the error object.\n *\n * This method checks for both custom fields added via setAdditionalFields()\n * and built-in fields (code, message, segment, etc.).\n *\n * @param key - The field name to check\n * @returns `true` if the field exists, `false` otherwise\n *\n * @example\n * ```typescript\n * const err = new RouterError(\"ERR\", { segment: \"users\" });\n * err.setAdditionalFields({ userId: \"123\" });\n *\n * err.hasField(\"userId\"); // true\n * err.hasField(\"segment\"); // true\n * err.hasField(\"unknown\"); // false\n * ```\n */\n hasField(key: string): boolean {\n return key in this;\n }\n\n /**\n * Retrieves a custom field value from the error object.\n *\n * This method can access both custom fields and built-in fields.\n * Returns `undefined` if the field doesn't exist.\n *\n * @param key - The field name to retrieve\n * @returns The field value, or `undefined` if it doesn't exist\n *\n * @example\n * ```typescript\n * const err = new RouterError(\"ERR\");\n * err.setAdditionalFields({ userId: \"123\", role: \"admin\" });\n *\n * err.getField(\"userId\"); // \"123\"\n * err.getField(\"role\"); // \"admin\"\n * err.getField(\"code\"); // \"ERR\" (built-in field)\n * err.getField(\"unknown\"); // undefined\n * ```\n */\n getField(key: string): unknown {\n return this[key];\n }\n\n /**\n * Serializes the error to a JSON-compatible object.\n *\n * This method is automatically called by JSON.stringify() and includes:\n * - Built-in fields: code, message, segment (if set), path (if set), redirect (if set)\n * - All custom fields added via setAdditionalFields() or constructor\n * - Excludes: stack trace (for security/cleanliness)\n *\n * @returns A plain object representation of the error, suitable for JSON serialization\n *\n * @example\n * ```typescript\n * const err = new RouterError(\"ROUTE_NOT_FOUND\", {\n * message: \"Route not found\",\n * path: \"/admin/users/123\"\n * });\n * err.setAdditionalFields({ userId: \"123\" });\n *\n * JSON.stringify(err);\n * // {\n * // \"code\": \"ROUTE_NOT_FOUND\",\n * // \"message\": \"Route not found\",\n * // \"path\": \"/admin/users/123\",\n * // \"userId\": \"123\"\n * // }\n * ```\n */\n toJSON(): Record<string, unknown> {\n const result: Record<string, unknown> = {\n code: this.code,\n message: this.message,\n };\n\n if (this.segment !== undefined) {\n result.segment = this.segment;\n }\n if (this.path !== undefined) {\n result.path = this.path;\n }\n if (this.redirect !== undefined) {\n result.redirect = this.redirect;\n }\n\n // add all public fields\n // Using Set.has() for O(1) lookup instead of Array.includes() O(n)\n // Overall complexity: O(n) instead of O(n*m)\n const excludeKeys = new Set([\n \"code\",\n \"message\",\n \"segment\",\n \"path\",\n \"redirect\",\n \"stack\",\n ]);\n\n for (const key in this) {\n if (Object.hasOwn(this, key) && !excludeKeys.has(key)) {\n result[key] = this[key];\n }\n }\n\n return result;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{RouterError as t,errorCodes as e}from"./chunk-5QXFUUDL.mjs";import{getInternals as a}from"./chunk-QUUNDESP.mjs";function r(a){if(a())throw new t(e.ROUTER_DISPOSED)}function o(o){const s=a(o);return{makeState:(t,e,a,r,o)=>(s.validator?.state.validateMakeStateArgs(t,e,a,o),s.makeState(t,e,a,r?.params,o)),buildState:(t,e)=>{s.validator?.routes.validateStateBuilderArgs(t,e,"buildState");const{name:a,params:r}=s.forwardState(t,e);return s.buildStateResolved(a,r)},forwardState:(t,e)=>(s.validator?.routes.validateStateBuilderArgs(t,e,"forwardState"),s.forwardState(t,e)),matchPath:t=>(s.validator?.routes.validateMatchPathArgs(t),s.matchPath(t,s.getOptions())),setRootPath:t=>{r(s.isDisposed),s.validator?.routes.validateSetRootPathArgs(t),s.setRootPath(t)},getRootPath:s.getRootPath,addEventListener:(t,e)=>(r(s.isDisposed),s.validator?.eventBus.validateListenerArgs(t,e),s.addEventListener(t,e)),buildNavigationState:(t,e={})=>{s.validator?.routes.validateStateBuilderArgs(t,e,"buildNavigationState");const{name:a,params:r}=s.forwardState(t,e),o=s.buildStateResolved(a,r);if(o)return s.makeState(o.name,o.params,s.buildPath(o.name,o.params),o.meta)},getOptions:s.getOptions,getTree:s.getTree,addInterceptor:(t,e)=>{r(s.isDisposed),s.validator?.plugins.validateAddInterceptorArgs(t,e);let a=s.interceptors.get(t);return a||(a=[],s.interceptors.set(t,a)),a.push(e),()=>{const t=a.indexOf(e);-1!==t&&a.splice(t,1)}},getRouteConfig:t=>{const e=s.routeGetStore();if(e.matcher.hasRoute(t))return e.routeCustomFields[t]},extendRouter:a=>{r(s.isDisposed);const i=Object.keys(a);for(const a of i)if(a in o)throw new t(e.PLUGIN_CONFLICT,{message:`Cannot extend router: property "${a}" already exists`});for(const t of i)o[t]=a[t];const n={keys:i};s.routerExtensions.push(n);let d=!1;return()=>{if(d)return;d=!0;for(const t of n.keys)delete o[t];const t=s.routerExtensions.indexOf(n);-1!==t&&s.routerExtensions.splice(t,1)}}}}export{o as getPluginApi,r as throwIfDisposed};//# sourceMappingURL=chunk-HHIXK5UM.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/helpers.ts","../../src/api/getPluginApi.ts"],"names":[],"mappings":";AAKO,SAAS,gBAAgB,UAAA,EAAiC;AAC/D,EAAA,IAAI,YAAW,EAAG;AAChB,IAAA,MAAM,IAAI,WAAA,CAAY,UAAA,CAAW,eAAe,CAAA;AAAA,EAClD;AACF;;;ACDO,SAAS,aAEd,MAAA,EAAyC;AACzC,EAAA,MAAM,GAAA,GAAM,aAAa,MAAM,CAAA;AAE/B,EAAA,OAAO;AAAA,IACL,WAAW,CAAC,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,MAAM,OAAA,KAAY;AAChD,MAAA,GAAA,CAAI,WAAW,KAAA,CAAM,qBAAA,CAAsB,IAAA,EAAM,MAAA,EAAQ,MAAM,OAAO,CAAA;AAEtE,MAAA,OAAO,GAAA,CAAI,SAAA;AAAA,QACT,IAAA;AAAA,QACA,MAAA;AAAA,QACA,IAAA;AAAA,QACA,IAAA,EAAM,MAAA;AAAA,QAGN;AAAA,OACF;AAAA,IACF,CAAA;AAAA,IACA,UAAA,EAAY,CAAC,SAAA,EAAW,WAAA,KAAgB;AACtC,MAAA,GAAA,CAAI,WAAW,MAAA,CAAO,wBAAA;AAAA,QACpB,SAAA;AAAA,QACA,WAAA;AAAA,QACA;AAAA,OACF;AAEA,MAAA,MAAM,EA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;AAAA,QAChD;AAEA,QAAA,MAAM,GAAA,GAAM,GAAA,CAAI,gBAAA,CAAiB,OAAA,CAAQ,eAAe,CAAA;AAExD,QAAA,IAAI,QAAQ,EAAA,EAAI;AACd,UAAA,GAAA,CAAI,gBAAA,CAAiB,MAAA,CAAO,GAAA,EAAK,CAAC,CAAA;AAAA,QACpC;AAAA,MACF,CAAA;AAAA,IACF;AAAA,GACF;AACF","file":"chunk-HHIXK5UM.mjs","sourcesContent":["// packages/core/src/api/helpers.ts\n\nimport { errorCodes } from \"../constants\";\nimport { RouterError } from \"../RouterError\";\n\nexport function throwIfDisposed(isDisposed: () => boolean): void {\n if (isDisposed()) {\n throw new RouterError(errorCodes.ROUTER_DISPOSED);\n }\n}\n","import { throwIfDisposed } from \"./helpers\";\nimport { errorCodes } from \"../constants\";\nimport { getInternals } from \"../internals\";\nimport { RouterError } from \"../RouterError\";\n\nimport type { PluginApi } from \"./types\";\nimport type { DefaultDependencies, Params, Router } from \"@real-router/types\";\n\nexport function getPluginApi<\n Dependencies extends DefaultDependencies = DefaultDependencies,\n>(router: Router<Dependencies>): PluginApi {\n const ctx = getInternals(router);\n\n return {\n makeState: (name, params, path, meta, forceId) => {\n ctx.validator?.state.validateMakeStateArgs(name, params, path, forceId);\n\n return ctx.makeState(\n name,\n params,\n path,\n meta?.params as\n | Record<string, Record<string, \"url\" | \"query\">>\n | undefined,\n forceId,\n );\n },\n buildState: (routeName, routeParams) => {\n ctx.validator?.routes.validateStateBuilderArgs(\n routeName,\n routeParams,\n \"buildState\",\n );\n\n const { name, params } = ctx.forwardState(routeName, routeParams);\n\n return ctx.buildStateResolved(name, params);\n },\n forwardState: <P extends Params = Params>(\n routeName: string,\n routeParams: P,\n ) => {\n ctx.validator?.routes.validateStateBuilderArgs(\n routeName,\n routeParams,\n \"forwardState\",\n );\n\n return ctx.forwardState(routeName, routeParams);\n },\n matchPath: (path) => {\n ctx.validator?.routes.validateMatchPathArgs(path);\n\n return ctx.matchPath(path, ctx.getOptions());\n },\n setRootPath: (rootPath) => {\n throwIfDisposed(ctx.isDisposed);\n\n ctx.validator?.routes.validateSetRootPathArgs(rootPath);\n\n ctx.setRootPath(rootPath);\n },\n getRootPath: ctx.getRootPath,\n addEventListener: (eventName, cb) => {\n throwIfDisposed(ctx.isDisposed);\n\n ctx.validator?.eventBus.validateListenerArgs(eventName, cb);\n\n return ctx.addEventListener(eventName, cb);\n },\n buildNavigationState: (name, params = {}) => {\n ctx.validator?.routes.validateStateBuilderArgs(\n name,\n params,\n \"buildNavigationState\",\n );\n\n const { name: resolvedName, params: resolvedParams } = ctx.forwardState(\n name,\n params,\n );\n const routeInfo = ctx.buildStateResolved(resolvedName, resolvedParams);\n\n if (!routeInfo) {\n return;\n }\n\n return ctx.makeState(\n routeInfo.name,\n routeInfo.params,\n ctx.buildPath(routeInfo.name, routeInfo.params),\n routeInfo.meta,\n );\n },\n getOptions: ctx.getOptions,\n getTree: ctx.getTree,\n addInterceptor: (method, fn) => {\n throwIfDisposed(ctx.isDisposed);\n ctx.validator?.plugins.validateAddInterceptorArgs(method, fn);\n let list = ctx.interceptors.get(method);\n\n if (!list) {\n list = [];\n ctx.interceptors.set(method, list);\n }\n\n list.push(fn);\n\n return () => {\n const index = list.indexOf(fn);\n\n if (index !== -1) {\n list.splice(index, 1);\n }\n };\n },\n getRouteConfig: (name) => {\n const store = ctx.routeGetStore();\n\n if (!store.matcher.hasRoute(name)) {\n return;\n }\n\n return store.routeCustomFields[name];\n },\n extendRouter: (extensions: Record<string, unknown>) => {\n throwIfDisposed(ctx.isDisposed);\n\n const keys = Object.keys(extensions);\n\n for (const key of keys) {\n if (key in router) {\n throw new RouterError(errorCodes.PLUGIN_CONFLICT, {\n message: `Cannot extend router: property \"${key}\" already exists`,\n });\n }\n }\n\n for (const key of keys) {\n (router as Record<string, unknown>)[key] = extensions[key];\n }\n\n const extensionRecord = { keys };\n\n ctx.routerExtensions.push(extensionRecord);\n\n let removed = false;\n\n return () => {\n if (removed) {\n return;\n }\n\n removed = true;\n\n for (const key of extensionRecord.keys) {\n delete (router as Record<string, unknown>)[key];\n }\n\n const idx = ctx.routerExtensions.indexOf(extensionRecord);\n\n if (idx !== -1) {\n ctx.routerExtensions.splice(idx, 1);\n }\n };\n },\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{plugins as t,events as e,RouterError as n,errorCodes as i,constants as s,createLimits as r,EMPTY_PARAMS as a,DEFAULT_LIMITS as o,freezeStateInPlace as c}from"./chunk-5QXFUUDL.mjs";import{registerInternals as u,createInterceptable as l,createInterceptable2 as h,getInternals as d}from"./chunk-QUUNDESP.mjs";import{logger as f}from"@real-router/logger";import{FSM as p}from"@real-router/fsm";function m(t,e,n=100){const i=new Set,s=[t];let r=t;for(;e[r];){const t=e[r];if(i.has(t)){const e=s.indexOf(t),n=[...s.slice(e),t];throw new Error(`Circular forwardTo: ${n.join(" → ")}`)}if(i.add(r),s.push(t),r=t,s.length>n)throw new Error(`forwardTo chain exceeds maximum depth (${n}): ${s.join(" → ")}`)}return r}var g={maxListeners:0,warnListeners:0,maxEventDepth:0},v=class extends Error{},S=class{#t=new Map;#e=null;#n=g;#i;#s;constructor(t){t?.limits&&(this.#n=t.limits),this.#i=t?.onListenerError??null,this.#s=t?.onListenerWarn??null}static validateCallback(t,e){if("function"!=typeof t)throw new TypeError(`Expected callback to be a function for event ${e}`)}setLimits(t){this.#n=t}on(t,e){const n=this.#r(t);if(n.has(e))throw new Error(`Duplicate listener for "${t}"`);const{maxListeners:i,warnListeners:s}=this.#n;if(0!==s&&n.size===s&&this.#s?.(t,s),0!==i&&n.size>=i)throw new Error(`Listener limit (${i}) reached for "${t}"`);return n.add(e),()=>{this.off(t,e)}}off(t,e){this.#t.get(t)?.delete(e)}emit(t,e,n,i,s){const r=this.#t.get(t);if(!r||0===r.size)return;const a=arguments.length-1;0!==this.#n.maxEventDepth?this.#a(r,t,a,e,n,i,s):this.#o(r,t,a,e,n,i,s)}clearAll(){this.#t.clear(),this.#e=null}listenerCount(t){return this.#t.get(t)?.size??0}#o(t,e,n,i,s,r,a){if(1===t.size){const[o]=t;try{this.#c(o,n,i,s,r,a)}catch(t){this.#i?.(e,t)}return}const o=[...t];for(const t of o)try{this.#c(t,n,i,s,r,a)}catch(t){this.#i?.(e,t)}}#c(t,e,n,i,s,r){switch(e){case 0:t();break;case 1:t(n);break;case 2:t(n,i);break;case 3:t(n,i,s);break;default:t(n,i,s,r)}}#a(t,e,n,i,s,r,a){this.#e??=new Map;const o=this.#e,c=o.get(e)??0;if(c>=this.#n.maxEventDepth)throw new v(`Maximum recursion depth (${this.#n.maxEventDepth}) exceeded for event: ${e}`);try{o.set(e,c+1);const u=1===t.size?t:[...t];for(const t of u)try{this.#c(t,n,i,s,r,a)}catch(t){if(t instanceof v)throw t;this.#i?.(e,t)}}finally{o.set(e,o.get(e)-1)}}#r(t){const e=this.#t.get(t);if(e)return e;const n=new Set;return this.#t.set(t,n),n}},y="IDLE",T="STARTING",w="READY",b="TRANSITIONING",N="DISPOSED",P="START",A="STARTED",O="NAVIGATE",E="COMPLETE",R="FAIL",C="CANCEL",D="STOP",F="DISPOSE",j={initial:y,context:null,transitions:{[y]:{[P]:T,[F]:N},[T]:{[A]:w,[R]:y},[w]:{[O]:b,[R]:w,[D]:y},[b]:{[O]:b,[E]:w,[C]:w,[R]:w},[N]:{}}};function L(t,e){for(const n of t){if(null===n||"object"!=typeof n||Array.isArray(n))throw new TypeError("route must be a non-array object");e?.routes.guardRouteCallbacks(n),e?.routes.guardNoAsyncCallbacks(n);const t=n.children;t&&L(t,e)}}var I={defaultRoute:"",defaultParams:{},trailingSlash:"preserve",queryParamsMode:"loose",queryParams:{arrayFormat:"none",booleanFormat:"none",nullFormat:"default"},urlParamsEncoding:"default",allowNotFound:!0,rewritePathOnMatch:!0};function M(t){Object.freeze(t);for(const e of Object.keys(t)){const n=t[e];n&&"object"==typeof n&&n.constructor===Object&&M(n)}return t}function U(t,e){return"function"==typeof t?t(e):t}var $=class{#u;constructor(t={}){this.#u=M({...I,...t})}static validateOptionsIsObject(t){!function(t){if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("[router.constructor] options must be a plain object")}(t)}get(){return this.#u}};function B(t,e){return t===e||!(!Array.isArray(t)||!Array.isArray(e))&&t.length===e.length&&t.every((t,n)=>B(t,e[n]))}var _=class{#l=0;#h=void 0;#d=void 0;#f;#p=new Map;get(){return this.#h}set(t){this.#d=this.#h,this.#h=t?c(t):void 0}getPrevious(){return this.#d}reset(){this.#h=void 0,this.#d=void 0,this.#p.clear(),this.#l=0}setDependencies(t){this.#f=t}makeState(t,e,n,i,s,r){const o=i?{id:s??++this.#l,params:i}:void 0,u=this.#f.getDefaultParams();let l;l=Object.hasOwn(u,t)?{...u[t],...e}:e&&e!==a?{...e}:a;const h={name:t,params:l,path:n??this.#f.buildPath(t,e),meta:o};return r?h:c(h)}areStatesEqual(t,e,n=!0){if(!t||!e)return!!t==!!e;if(t.name!==e.name)return!1;if(n){const n=t.meta?.params??e.meta?.params;return(n?function(t){const e=[];for(const n in t){const i=t[n];for(const t in i)"url"===i[t]&&e.push(t)}return e}(n):this.#m(t.name)).every(n=>B(t.params[n],e.params[n]))}const i=Object.keys(t.params),s=Object.keys(e.params);return i.length===s.length&&i.every(n=>n in e.params&&B(t.params[n],e.params[n]))}#m(t){const e=this.#p.get(t);if(void 0!==e)return e;const n=this.#f.getUrlParams(t);return this.#p.set(t,n),n}},k={[t.ROUTER_START]:e.ROUTER_START,[t.ROUTER_STOP]:e.ROUTER_STOP,[t.TRANSITION_SUCCESS]:e.TRANSITION_SUCCESS,[t.TRANSITION_START]:e.TRANSITION_START,[t.TRANSITION_ERROR]:e.TRANSITION_ERROR,[t.TRANSITION_CANCEL]:e.TRANSITION_CANCEL},x=Object.keys(k),z="router.usePlugin",G=class t{#g=new Set;#v=new Set;#f;#S=o;#y=null;static validatePlugin(t){!function(t){if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("[router.usePlugin] Plugin factory must return an object, got "+typeof t);if("function"==typeof t.then)throw new TypeError("[router.usePlugin] Async plugin factories are not supported. Factory returned a Promise instead of a plugin object.")}(t)}static validateNoDuplicatePlugins(t,e){for(const n of t)if(e(n))throw new Error("[router.usePlugin] Plugin factory already registered. To re-register, first unsubscribe the existing plugin.")}setDependencies(t){this.#f=t}setLimits(t){this.#S=t,this.#S}setValidatorGetter(t){this.#y=t}count(){return this.#g.size}use(...t){if(this.#y?.()?.plugins.validateCountThresholds(this.#g.size+t.length),1===t.length){const e=t[0],n=this.#T(e);this.#g.add(e);let i=!1;const s=()=>{if(!i){i=!0,this.#g.delete(e),this.#v.delete(s);try{n()}catch(t){f.error(z,"Error during cleanup:",t)}}};return this.#v.add(s),s}const e=this.#w(t),n=[];try{for(const t of e){const e=this.#T(t);n.push({factory:t,cleanup:e})}}catch(t){for(const{cleanup:t}of n)try{t()}catch(t){f.error(z,"Cleanup error:",t)}throw t}for(const{factory:t}of n)this.#g.add(t);let i=!1;const s=()=>{if(!i){i=!0,this.#v.delete(s);for(const{factory:t}of n)this.#g.delete(t);for(const{cleanup:t}of n)try{t()}catch(t){f.error(z,"Error during cleanup:",t)}}};return this.#v.add(s),s}getAll(){return[...this.#g]}has(t){return this.#g.has(t)}disposeAll(){for(const t of this.#v)t();this.#g.clear(),this.#v.clear()}#w(t){const e=new Set;for(const n of t)e.has(n)?this.#y?.()?.plugins.warnBatchDuplicates(t):e.add(n);return e}#T(e){const n=this.#f.compileFactory(e);t.validatePlugin(n),this.#y?.()?.plugins.validatePluginKeys(n),Object.freeze(n);const i=[];for(const t of x)t in n&&("function"==typeof n[t]?(i.push(this.#f.addEventListener(k[t],n[t])),"onStart"===t&&this.#f.canNavigate()&&this.#y?.()?.plugins.warnPluginAfterStart(t)):this.#y?.()?.plugins.warnPluginMethodType(t));return()=>{for(const t of i)t();"function"==typeof n.teardown&&n.teardown()}}},q=class{#b=new Map;#N=new Map;#P=new Map;#A=new Map;#O=[this.#P,this.#A];#E=new Set;#R=new Set;#C=new Set;#f;#S=o;#y=null;setDependencies(t){this.#f=t}setLimits(t){this.#S=t,this.#S}setValidatorGetter(t){this.#y=t}getHandlerCount(t){return"activate"===t?this.#N.size:this.#b.size}addCanActivate(t,e,n=!1){n?this.#R.add(t):this.#R.delete(t);const i=this.#N.has(t);this.#D("activate",t,e,this.#N,this.#A,"canActivate",i)}addCanDeactivate(t,e,n=!1){n?this.#C.add(t):this.#C.delete(t);const i=this.#b.has(t);this.#D("deactivate",t,e,this.#b,this.#P,"canDeactivate",i)}clearCanActivate(t){this.#N.delete(t),this.#A.delete(t),this.#R.delete(t)}clearCanDeactivate(t){this.#b.delete(t),this.#P.delete(t),this.#C.delete(t)}clearAll(){this.#N.clear(),this.#A.clear(),this.#b.clear(),this.#P.clear(),this.#R.clear(),this.#C.clear()}clearDefinitionGuards(){for(const t of this.#R)this.#N.delete(t),this.#A.delete(t);for(const t of this.#C)this.#b.delete(t),this.#P.delete(t);this.#R.clear(),this.#C.clear()}getFactories(){const t={},e={};for(const[e,n]of this.#b)t[e]=n;for(const[t,n]of this.#N)e[t]=n;return[t,e]}getFunctions(){return this.#O}canNavigateTo(t,e,n,i){for(const e of t)if(!this.#F(this.#P,e,n,i,"canNavigateTo"))return!1;for(const t of e)if(!this.#F(this.#A,t,n,i,"canNavigateTo"))return!1;return!0}#D(t,e,n,i,s,r,a){a?this.#y?.()?.lifecycle.warnOverwrite(e,t,r):this.#y?.()?.lifecycle.validateCountThresholds(i.size+1,r);const o="boolean"==typeof n?function(t){const e=()=>t;return()=>e}(n):n;i.set(e,o),this.#E.add(e);try{const t=this.#f.compileFactory(o);if("function"!=typeof t)throw new TypeError(`[router.${r}] Factory must return a function, got ${typeof t}`);s.set(e,t)}catch(t){throw i.delete(e),t}finally{this.#E.delete(e)}}#F(t,e,n,i,s){const r=t.get(e);if(!r)return!0;try{const t=r(n,i);return"boolean"==typeof t?t:(this.#y?.()?.lifecycle.warnAsyncGuardSync(e,s),!1)}catch{return!1}}};function W(){return{decoders:Object.create(null),encoders:Object.create(null),defaultParams:Object.create(null),forwardMap:Object.create(null),forwardFnMap:Object.create(null)}}function Q(t){const e={name:t.name,path:t.path};return t.children&&(e.children=t.children.map(t=>Q(t))),e}function V(t,e,n=""){for(let i=0;i<t.length;i++){const s=t[i],r=n?`${n}.${s.name}`:s.name;if(r===e)return t.splice(i,1),!0;if(s.children&&e.startsWith(`${r}.`)&&V(s.children,e,r))return!0}return!1}function K(t,e){for(const n of Object.keys(t))e(n)&&delete t[n]}function H(t){return`(${t.replaceAll(/(^<|>$)/g,"")})`}var J=/([:*])([^/?<]+)(<[^>]+>)?(\?)?/g,Y=/([:*][^/?<]+(?:<[^>]+>)?)\?(?=\/|$)/g,X=/\?(.+)$/,Z=/[^\w!$'()*+,.:;|~-]/gu,tt=/[^\w!$'()*+,.:;|~-]/u,et={default:t=>tt.test(t)?t.replaceAll(Z,t=>encodeURIComponent(t)):t,uri:encodeURI,uriComponent:encodeURIComponent,none:t=>t},nt={default:decodeURIComponent,uri:decodeURI,uriComponent:decodeURIComponent,none:t=>t};function it(){return{staticChildren:Object.create(null),paramChild:void 0,splatChild:void 0,route:void 0,slashChildRoute:void 0}}function st(t){return t.length>1&&t.endsWith("/")?t.slice(0,-1):t}function rt(t){const e={};if(0===t.length)return e;const n=t.split("&");for(const t of n){const n=t.indexOf("=");-1===n?e[t]="":e[t.slice(0,n)]=t.slice(n+1)}return e}function at(t){const e=[];for(const n of Object.keys(t)){const i=t[n],s=encodeURIComponent(n);e.push(""===i?s:`${s}=${encodeURIComponent(String(i))}`)}return e.join("&")}function ot(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function ct(t){let e=0;for(;e<t.length;)if("%"===t[e]){if(e+2>=t.length)return!1;const n=t.codePointAt(e+1)??0,i=t.codePointAt(e+2)??0;if(!ot(n)||!ot(i))return!1;e+=3}else e++;return!0}var ut=/<[^>]*>/g;function lt(t,e,n,i,s){const r=""===e.fullName;r||i.push(e);const a=e.absolute,o=e.paramMeta.pathPattern,c=a&&o.startsWith("~")?o.slice(1):o,u=(a?c:o).replaceAll(ut,""),l=a?u:(d=u,""===(h=n)?d:""===d?h:h+d);var h,d;let f=s;r||(f=function(t,e,n,i,s,r){const a=(g=i,st(n)===st(g)),o=Object.freeze([...s]),c=function(t){const e={};for(const n of t)e[n.fullName]=n.paramTypeMap;return Object.freeze(e)}(o),u=st(n),l=function(t,e){const n=[];t.length>0&&n.push(...t);for(const t of e)t.paramMeta.queryParams.length>0&&n.push(...t.paramMeta.queryParams);return n}(t.rootQueryParams,s),h=function(t){const e=new Map;for(const n of t)for(const[t,i]of n.paramMeta.constraintPatterns)e.set(t,i);return e}(s),d=a?st(i):u,{buildStaticParts:f,buildParamSlots:p}=function(t,e,n){const i=new Set,s=new Set;for(const t of e){for(const e of t.paramMeta.urlParams)i.add(e);for(const e of t.paramMeta.spatParams)s.add(e)}if(0===i.size)return{buildStaticParts:[t],buildParamSlots:[]};const r=[],a=[],o=/[:*]([\w]+)(?:<[^>]*>)?(\?)?/gu;let c,u=0;for(;null!==(c=o.exec(t));){const e=c[1],i="?"===c[2];r.push(t.slice(u,c.index));const o=s.has(e);a.push({paramName:e,isOptional:i,encoder:o?t=>{const e=et[n],i=t.split("/");let s=e(i[0]);for(let t=1;t<i.length;t++)s+=`/${e(i[t])}`;return s}:et[n]}),u=c.index+c[0].length}return r.push(t.slice(u)),{buildStaticParts:r,buildParamSlots:a}}(d,a?s.slice(0,-1):s,t.options.urlParamsEncoding),m={name:e.fullName,parent:r,depth:s.length-1,matchSegments:o,meta:c,declaredQueryParams:l,declaredQueryParamsSet:new Set(l),hasTrailingSlash:n.length>1&&n.endsWith("/"),constraintPatterns:h,hasConstraints:h.size>0,buildStaticParts:f,buildParamSlots:p,buildParamNamesSet:new Set(p.map(t=>t.paramName))};var g;return t.routesByName.set(e.fullName,m),t.segmentsByName.set(e.fullName,o),t.metaByName.set(e.fullName,c),a?function(t,e,n){var i,s;i=e,(function(t,e,n){const i=st(n);if("/"===i||""===i)return e;let s=e,r=1;const a=i.length;for(;r<=a;){const e=i.indexOf("/",r),n=-1===e?a:e;if(n<=r)break;s=dt(t,s,i.slice(r,n)),r=n+1}return s}(s=t,s.root,n)).slashChildRoute=i;const r=st(n),a=t.options.caseSensitive?r:r.toLowerCase();t.staticCache.has(a)&&t.staticCache.set(a,e)}(t,m,i):function(t,e,n,i,s){if(function(t,e,n){const i=st(n);"/"!==i?ht(t,t.root,i,1,e):t.root.route=e}(t,e,n),0===s.paramMeta.urlParams.length){const n=t.options.caseSensitive?i:i.toLowerCase();t.staticCache.set(n,e)}}(t,m,n,u,e),m}(t,e,l,a?"":n,i,s));for(const n of e.children.values())lt(t,n,l,i,f);r||i.pop()}function ht(t,e,n,i,s){const r=n.length;for(;i<=r;){const a=n.indexOf("/",i),o=-1===a?r:a,c=n.slice(i,o);if(c.endsWith("?")){const i=c.slice(1).replaceAll(ut,"").replace(/\?$/,"");return e.paramChild??={node:it(),name:i},ht(t,e.paramChild.node,n,o+1,s),void(o>=r?e.route??=s:ht(t,e,n,o+1,s))}e=dt(t,e,c),i=o+1}e.route=s}function dt(t,e,n){if(n.startsWith("*")){const t=n.slice(1);return e.splatChild??={node:it(),name:t},e.splatChild.node}if(n.startsWith(":")){const t=n.slice(1).replaceAll(ut,"").replace(/\?$/,"");return e.paramChild??={node:it(),name:t},e.paramChild.node}const i=t.options.caseSensitive?n:n.toLowerCase();return i in e.staticChildren||(e.staticChildren[i]=it()),e.staticChildren[i]}var ft=/[\u0080-\uFFFF]/,pt=class{get options(){return this.#t}#t;#e=it();#s=new Map;#r=new Map;#n=new Map;#a=new Map;#i="";#j=[];constructor(t){this.#t={caseSensitive:t?.caseSensitive??!0,strictTrailingSlash:t?.strictTrailingSlash??!1,strictQueryParams:t?.strictQueryParams??!1,urlParamsEncoding:t?.urlParamsEncoding??"default",parseQueryString:t?.parseQueryString??rt,buildQueryString:t?.buildQueryString??at}}registerTree(t){this.#j=t.paramMeta.queryParams,lt({root:this.#e,options:this.#t,routesByName:this.#s,segmentsByName:this.#r,metaByName:this.#n,staticCache:this.#a,rootQueryParams:this.#j},t,"",[],null)}match(t){const e=this.#c(t);if(!e)return;const[n,i,s]=e,r=this.#t.caseSensitive?i:i.toLowerCase(),a=this.#a.get(r);if(a){if(this.#t.strictTrailingSlash&&!this.#o(n,a))return;return this.#L(a,{},s)}const o={},c=this.#I(i,o);return!c||this.#t.strictTrailingSlash&&!this.#o(n,c)||c.hasConstraints&&!this.#M(o,c)||!this.#U(o)?void 0:this.#L(c,o,s)}buildPath(t,e,n){const i=this.#s.get(t);if(!i)throw new Error(`[SegmentMatcher.buildPath] '${t}' is not defined`);i.hasConstraints&&e&&this.#$(i,t,e);const s=this.#B(i,e),r=this.#_(s,n?.trailingSlash),a=this.#k(i,e,n?.queryParamsMode);return r+(a?`?${a}`:"")}getSegmentsByName(t){return this.#r.get(t)}getMetaByName(t){return this.#n.get(t)}hasRoute(t){return this.#s.has(t)}setRootPath(t){this.#i=t}#$(t,e,n){for(const[i,s]of t.constraintPatterns){const t=n[i];if(null!=t){const n="object"==typeof t?JSON.stringify(t):String(t);if(!s.pattern.test(n))throw new Error(`[SegmentMatcher.buildPath] '${e}' — param '${i}' value '${n}' does not match constraint '${s.constraint}'`)}}}#B(t,e){const n=t.buildStaticParts,i=t.buildParamSlots;if(0===i.length)return this.#i+n[0];let s=this.#i+n[0];for(const[t,r]of i.entries()){const i=e?.[r.paramName];if(null==i){if(!r.isOptional)throw new Error(`[SegmentMatcher.buildPath] Missing required param '${r.paramName}'`);s.length>1&&s.endsWith("/")&&(s=s.slice(0,-1)),s+=n[t+1];continue}const a="object"==typeof i?JSON.stringify(i):String(i);s+=r.encoder(a)+n[t+1]}return s}#_(t,e){return"always"!==e||t.endsWith("/")?"never"===e&&"/"!==t&&t.endsWith("/")?t.slice(0,-1):t:`${t}/`}#k(t,e,n){if(!e)return"";const i={};let s=!1;for(const n of t.declaredQueryParams)n in e&&(i[n]=e[n],s=!0);if("loose"===n)for(const n in e)!Object.hasOwn(e,n)||t.declaredQueryParamsSet.has(n)||t.buildParamNamesSet.has(n)||(i[n]=e[n],s=!0);return s?this.#t.buildQueryString(i):""}#c(t){if(""===t&&(t="/"),!t.startsWith("/"))return;const e=t.indexOf("#");if(-1!==e&&(t=t.slice(0,e)),ft.test(t))return;if(this.#i.length>0){if(!t.startsWith(this.#i))return;t=t.slice(this.#i.length)||"/"}const n=t.indexOf("?"),i=-1===n?t:t.slice(0,n),s=-1===n?void 0:t.slice(n+1);return i.includes("//")?void 0:[i,st(i),s]}#L(t,e,n){if(void 0!==n){const i=this.#t.parseQueryString(n);if(this.#t.strictQueryParams){const e=t.declaredQueryParamsSet;for(const t of Object.keys(i))if(!e.has(t))return}for(const t of Object.keys(i))e[t]=i[t]}return{segments:t.matchSegments,params:e,meta:t.meta}}#o(t,e){return(t.length>1&&t.endsWith("/"))===e.hasTrailingSlash}#I(t,e){return 1===t.length?this.#e.slashChildRoute??this.#e.route:this.#x(this.#e,t,1,e)}#x(t,e,n,i){let s=t;const r=e.length;for(;n<=r;){const t=e.indexOf("/",n),a=-1===t?r:t,o=e.slice(n,a),c=this.#t.caseSensitive?o:o.toLowerCase();let u;if(c in s.staticChildren)u=s.staticChildren[c];else{if(!s.paramChild){if(s.splatChild){const t={},r=this.#x(s.splatChild.node,e,n,t);return r?(Object.assign(i,t),r):(i[s.splatChild.name]=e.slice(n),s.splatChild.node.route)}return}u=s.paramChild.node,i[s.paramChild.name]=o}s=u,n=a+1}return s.slashChildRoute??s.route}#U(t){const e=this.#t.urlParamsEncoding;if("none"===e)return!0;const n=nt[e];for(const e in t){const i=t[e];if(i.includes("%")){if(!ct(i))return!1;t[e]=n(i)}}return!0}#M(t,e){for(const[n,i]of e.constraintPatterns)if(!i.pattern.test(t[n]))return!1;return!0}},mt=t=>{const e=t.indexOf("%"),n=t.indexOf("+");if(-1===e&&-1===n)return t;const i=-1===n?t:t.split("+").join(" ");return-1===e?i:decodeURIComponent(i)},gt=t=>{const e=typeof t;if("string"!==e&&"number"!==e&&"boolean"!==e)throw new TypeError(`[search-params] Array element must be a string, number, or boolean — received ${"object"===e&&null===t?"null":e}`);return encodeURIComponent(t)},vt={none:{encodeArray:(t,e)=>e.map(e=>`${t}=${gt(e)}`).join("&")},brackets:{encodeArray:(t,e)=>e.map(e=>`${t}[]=${gt(e)}`).join("&")},index:{encodeArray:(t,e)=>e.map((e,n)=>`${t}[${n}]=${gt(e)}`).join("&")},comma:{encodeArray:(t,e)=>`${t}=${e.map(t=>gt(t)).join(",")}`}},St={none:{encode:(t,e)=>`${t}=${e}`,decodeUndefined:()=>null,decodeRaw:()=>null,decodeValue:t=>t},string:{encode:(t,e)=>`${t}=${e}`,decodeUndefined:()=>null,decodeRaw:t=>"true"===t||"false"!==t&&null,decodeValue:t=>t},"empty-true":{encode:(t,e)=>e?t:`${t}=false`,decodeUndefined:()=>!0,decodeRaw:()=>null,decodeValue:t=>t}},yt={default:{encode:t=>t},hidden:{encode:()=>""}},Tt=(t,e,n)=>({boolean:St[e],null:yt[n],array:vt[t]}),wt={arrayFormat:"none",booleanFormat:"none",nullFormat:"default",strategies:{boolean:St.none,null:yt.default,array:vt.none}},bt=t=>{if(!t||void 0===t.arrayFormat&&void 0===t.booleanFormat&&void 0===t.nullFormat)return wt;const e=t.arrayFormat??"none",n=t.booleanFormat??"none",i=t.nullFormat??"default";return{arrayFormat:e,booleanFormat:n,nullFormat:i,strategies:Tt(e,n,i)}},Nt=t=>encodeURIComponent(t),Pt=(t,e,n)=>{const i=Nt(t);switch(typeof e){case"string":case"number":default:return`${i}=${Nt(e)}`;case"boolean":return n.strategies.boolean.encode(i,e);case"object":return null===e?n.strategies.null.encode(i):Array.isArray(e)?n.strategies.array.encodeArray(i,e):`${i}=${Nt(e)}`}};function At(t,e,n,i,s){const r=t.indexOf("=",e),a=-1!==r&&r<n,o=t.slice(e,a?r:n),{name:c,hasBrackets:u}=function(t){const e=t.indexOf("[");return-1===e?{name:t,hasBrackets:!1}:{name:t.slice(0,e),hasBrackets:!0}}(o);var l,h,d,f,p;!function(t,e,n,i){const s=t[e];void 0===s?t[e]=i?[n]:n:Array.isArray(s)?s.push(n):t[e]=[s,n]}(i,mt(c),(l=t,h=r,d=n,f=a,p=s,p?((t,e)=>{if(void 0===t)return e.boolean.decodeUndefined();const n=e.boolean.decodeRaw(t);if(null!==n)return n;const i=mt(t);return e.boolean.decodeValue(i)})(f?l.slice(h+1,d):void 0,p):f?mt(l.slice(h+1,d)):null),u)}function Ot(t,e){const n=t.path,i=n.startsWith("~"),s=i?n.slice(1):n,r={name:t.name,path:s,absolute:i,children:[],parent:e,nonAbsoluteChildren:[],fullName:""};if(t.children)for(const e of t.children){const t=Ot(e,r);r.children.push(t)}return r}function Et(t,e){return t.endsWith("/")&&e.startsWith("/")?t+e.slice(1):t+e}function Rt(t){const e=new Map;for(const n of t)e.set(n.name,n);return e}function Ct(t,e,n){const i=function(t){const e=[],n=[],i=[],s={},r=new Map,a=t.replaceAll(Y,"$1"),o=X.exec(a);if(null!==o){const e=o[1].split("&");for(const t of e){const e=t.trim();e.length>0&&(n.push(e),s[e]="query")}t=t.slice(0,o.index)}let c;for(;null!==(c=J.exec(t));){const t=c[2],n=c[3];if("*"===c[1])i.push(t),e.push(t),s[t]="url";else if(e.push(t),s[t]="url",n){const e=`^${H(n)}$`;r.set(t,{pattern:new RegExp(e),constraint:n})}}return{urlParams:e,queryParams:n,spatParams:i,paramTypeMap:s,constraintPatterns:r,pathPattern:t}}(t.path),s=function(t){const e={};for(const n of t.urlParams)e[n]="url";for(const n of t.queryParams)e[n]="query";return e}(i),r={name:t.name,path:t.path,absolute:t.absolute,parent:e,children:void 0,paramMeta:i,nonAbsoluteChildren:void 0,fullName:"",staticPath:null,paramTypeMap:s};var a;r.fullName=(a=r,a.parent?.name?`${a.parent.fullName}.${a.name}`:a.name);const{childrenMap:o,nonAbsoluteChildren:c}=function(t,e,n){const i=[],s=[];for(const r of t){const t=Ct(r,e,n);i.push(t),t.absolute||s.push(t)}return{childrenMap:Rt(i),nonAbsoluteChildren:s}}(t.children,r,n);return r.children=o,r.nonAbsoluteChildren=c,r.staticPath=function(t){if(!t.path)return null;const{urlParams:e,queryParams:n,spatParams:i}=t.paramMeta;if(e.length>0||n.length>0||i.length>0)return null;const s=[];let r=t.parent;for(;r?.path;)s.unshift(r),r=r.parent;let a="";for(const t of s){const{urlParams:e,queryParams:n,spatParams:i}=t.paramMeta;if(e.length>0||n.length>0||i.length>0)return null;a=t.absolute?t.path:Et(a,t.path)}return t.absolute?t.path:Et(a,t.path)}(r),n&&(Object.freeze(c),Object.freeze(s),Object.freeze(r.children),Object.freeze(r)),r}function Dt(t,e,n,i){return function(t,e){const n=[];return{add(t){return n.push(t),this},addMany(t){return n.push(...t),this},build:i=>function(t,e=!0){return Ct(t,null,e)}(function(t,e,n){const i=Ot({name:t,path:e},null);for(const t of n){const e=Ot(t,i);i.children.push(e)}return i}(t,e,n),!i?.skipFreeze)}}(t,e).addMany(n).build(i)}function Ft(t){const e={name:t.name,path:t.absolute?`~${t.path}`:t.path};return t.children.size>0&&(e.children=[...t.children.values()].map(t=>Ft(t))),e}function jt(t){return[...t.children.values()].map(t=>Ft(t))}function Lt(t){const e=t?.queryParams;return new pt({...void 0===t?.caseSensitive?void 0:{caseSensitive:t.caseSensitive},...void 0===t?.strictTrailingSlash?void 0:{strictTrailingSlash:t.strictTrailingSlash},...void 0===t?.strictQueryParams?void 0:{strictQueryParams:t.strictQueryParams},...void 0===t?.urlParamsEncoding?void 0:{urlParamsEncoding:t.urlParamsEncoding},parseQueryString:t=>((t,e)=>{const n=(t=>{const e=t.indexOf("?");return-1===e?t:t.slice(e+1)})(t);if(""===n||"?"===n)return{};if(!e)return function(t){const e={};return function(t,e){let n=0;const i=t.length;for(;n<i;){let s=t.indexOf("&",n);-1===s&&(s=i),At(t,n,s,e),n=s+1}}(t,e),e}(n);const i=bt(e),s={};let r=0;const a=n.length;for(;r<a;){let t=n.indexOf("&",r);-1===t&&(t=a),At(n,r,t,s,i.strategies),r=t+1}return s})(t,e),buildQueryString:t=>((t,e)=>{const n=Object.keys(t);if(0===n.length)return"";const i=bt(e),s=[];for(const e of n){const n=t[e];if(void 0===n)continue;const r=Pt(e,n,i);r&&s.push(r)}return s.join("&")})(t,e)})}function It(t,e,n){const i=Dt("",e,t),s=Lt(n);return s.registerTree(i),{tree:i,matcher:s}}function Mt(t){const e=It(t.definitions,t.rootPath,t.matcherOptions);t.tree=e.tree,t.matcher=e.matcher,t.resolvedForwardMap=_t(t.config)}function Ut(t){const e=It(t.definitions,t.rootPath,t.matcherOptions);t.tree=e.tree,t.matcher=e.matcher}function $t(t){Bt(t),Ut(t)}function Bt(t){t.definitions.length=0,Object.assign(t.config,W()),t.resolvedForwardMap=Object.create(null),t.routeCustomFields=Object.create(null)}function _t(t){const e=Object.create(null);for(const n of Object.keys(t.forwardMap))e[n]=m(n,t.forwardMap);return e}function kt(t,e,n,i,s,r,a){const o=new Set(["name","path","children","canActivate","canDeactivate","forwardTo","encodeParams","decodeParams","defaultParams"]),c=Object.fromEntries(Object.entries(t).filter(([t])=>!o.has(t)));Object.keys(c).length>0&&(i[e]=c),t.canActivate&&(a?a.addActivateGuard(e,t.canActivate):s.set(e,t.canActivate)),t.canDeactivate&&(a?a.addDeactivateGuard(e,t.canDeactivate):r.set(e,t.canDeactivate)),t.forwardTo&&function(t,e,n){if(t.canActivate&&f.warn("real-router",`Route "${e}" 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&&f.warn("real-router",`Route "${e}" 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 n="AsyncFunction"===t.forwardTo.constructor.name,i=t.forwardTo.toString().includes("__awaiter");if(n||i)throw new TypeError(`forwardTo callback cannot be async for route "${e}". Async functions break matchPath/buildPath.`)}"string"==typeof t.forwardTo?n.forwardMap[e]=t.forwardTo:n.forwardFnMap[e]=t.forwardTo}(t,e,n),t.decodeParams&&(n.decoders[e]=e=>t.decodeParams?.(e)??e),t.encodeParams&&(n.encoders[e]=e=>t.encodeParams?.(e)??e),t.defaultParams&&(n.defaultParams[e]=t.defaultParams)}function xt(t,e,n,i,s,r,a=""){for(const o of t){const t=a?`${a}.${o.name}`:o.name;kt(o,t,e,n,i,s,r),o.children&&xt(o.children,e,n,i,s,r,t)}}var zt=".",Gt=[];function qt(t){const e=[];for(let n=t.length-1;n>=0;n--)e.push(t[n]);return e}function Wt(t){const e=typeof t;return"string"===e||"number"===e||"boolean"===e}function Qt(t,e,n){const i=e.meta?.params[t];if(!i||"object"!=typeof i)return!0;for(const t of Object.keys(i)){const i=e.params[t],s=n.params[t];if(Wt(i)&&Wt(s)&&String(i)!==String(s))return!1}return!0}Object.freeze(Gt);var Vt,Kt,Ht=new Map;function Jt(t){const e=Ht.get(t);if(e)return e;const n=function(t){if(!t)return[""];const e=t.indexOf(zt);if(-1===e)return[t];const n=t.indexOf(zt,e+1);if(-1===n)return[t.slice(0,e),t];const i=t.indexOf(zt,n+1);if(-1===i)return[t.slice(0,e),t.slice(0,n),t];return-1===t.indexOf(zt,i+1)?[t.slice(0,e),t.slice(0,n),t.slice(0,i),t]:function(t){const e=t.split(zt),n=e.length,i=[e[0]];let s=e[0].length;for(let r=1;r<n-1;r++)s+=1+e[r].length,i.push(t.slice(0,s));return i.push(t),i}(t)}(t);return Object.freeze(n),Ht.set(t,n),n}var Yt,Xt,Zt=null,te=null;function ee(t,e){if(!e)return{intersection:"",toActivate:Jt(t.name),toDeactivate:Gt};if(void 0===t.meta?.params&&void 0===e.meta?.params)return{intersection:"",toActivate:Jt(t.name),toDeactivate:qt(Jt(e.name))};const n=Jt(t.name),i=Jt(e.name),s=function(t,e,n,i,s){for(let r=0;r<s;r++){const s=n[r];if(s!==i[r])return r;if(!Qt(s,t,e))return r}return s}(t,e,n,i,Math.min(i.length,n.length));let r;if(s>=i.length)r=Gt;else if(0===s&&1===i.length)r=i;else{r=[];for(let t=i.length-1;t>=s;t--)r.push(i[t])}const a=0===s?n:n.slice(s);return{intersection:s>0?i[s-1]:"",toDeactivate:r,toActivate:a}}function ne(t,e,n){if(n)return ee(t,e);if(null!==Zt&&t===Vt&&e===Kt)return Zt;if(null!==te&&t===Yt&&e===Xt)return te;const i=ee(t,e);return Yt=Vt,Xt=Kt,te=Zt,Vt=t,Kt=e,Zt=i,i}function ie(t,e){var n;return{name:e??(n=t.segments,n.at(-1)?.fullName??""),params:t.params,meta:t.meta}}var se=class{#z;#G;get#f(){return this.#z.depsStore}constructor(t=[],e){this.#z=function(t,e){const n=[],i=W(),s=Object.create(null),r=new Map,a=new Map;for(const e of t)n.push(Q(e));const{tree:o,matcher:c}=It(n,"",e);return xt(t,i,s,r,a,void 0,""),{definitions:n,config:i,tree:o,matcher:c,resolvedForwardMap:_t(i),routeCustomFields:s,rootPath:"",matcherOptions:e,depsStore:void 0,lifecycleNamespace:void 0,pendingCanActivate:r,pendingCanDeactivate:a,treeOperations:{commitTreeChanges:Mt,resetStore:$t,nodeToDefinition:Ft}}}(t,e)}static shouldUpdateNode(t){return(e,n)=>{if(!e||"object"!=typeof e||!("name"in e))throw new TypeError("[router.shouldUpdateNode] toState must be valid State object");if(e.transition?.reload)return!0;if(""===t&&!n)return!0;const{intersection:i,toActivate:s,toDeactivate:r}=ne(e,n);return t===i||!!s.includes(t)||r.includes(t)}}setDependencies(t){this.#z.depsStore=t;for(const[e,n]of this.#z.pendingCanActivate)t.addActivateGuard(e,n);this.#z.pendingCanActivate.clear();for(const[e,n]of this.#z.pendingCanDeactivate)t.addDeactivateGuard(e,n);this.#z.pendingCanDeactivate.clear()}setLifecycleNamespace(t){this.#z.lifecycleNamespace=t}setRootPath(t){this.#z.rootPath=t,Ut(this.#z)}hasRoute(t){return this.#z.matcher.hasRoute(t)}clearRoutes(){$t(this.#z)}buildPath(t,e,n){if(t===s.UNKNOWN_ROUTE)return"string"==typeof e?.path?e.path:"";const i=Object.hasOwn(this.#z.config.defaultParams,t)?{...this.#z.config.defaultParams[t],...e}:e??{},r="function"==typeof this.#z.config.encoders[t]?this.#z.config.encoders[t]({...i}):i;return this.#z.matcher.buildPath(t,r,this.#q(n))}matchPath(t,e){const n=e,i=this.#z.matcher.match(t);if(!i)return;const s=ie(i),{name:r,params:a,meta:o}=s,c="function"==typeof this.#z.config.decoders[r]?this.#z.config.decoders[r](a):a,{name:u,params:l}=this.#f.forwardState(r,c);let h=t;if(n.rewritePathOnMatch){const t="function"==typeof this.#z.config.encoders[u]?this.#z.config.encoders[u]({...l}):l,e=n.trailingSlash;h=this.#z.matcher.buildPath(u,t,{trailingSlash:"never"===e||"always"===e?e:void 0,queryParamsMode:n.queryParamsMode})}return this.#f.makeState(u,l,h,o)}forwardState(t,e){if(Object.hasOwn(this.#z.config.forwardFnMap,t)){const n=this.#W(t,e),i=this.#z.config.forwardFnMap[t],s=this.#Q(t,i,e);return{name:s,params:this.#W(s,n)}}const n=this.#z.resolvedForwardMap[t]??t;if(n!==t&&Object.hasOwn(this.#z.config.forwardFnMap,n)){const i=this.#W(t,e),s=this.#z.config.forwardFnMap[n],r=this.#Q(n,s,e);return{name:r,params:this.#W(r,i)}}if(n!==t){const i=this.#W(t,e);return{name:n,params:this.#W(n,i)}}return{name:t,params:this.#W(t,e)}}buildStateResolved(t,e){const n=this.#z.matcher.getSegmentsByName(t);if(n)return ie({segments:n,params:e,meta:this.#z.matcher.getMetaByName(t)},t)}isActiveRoute(t,e={},n=!1,i=!0){const s=this.#f.getState();if(!s)return!1;const r=s.name;if(r!==t&&!r.startsWith(`${t}.`)&&!t.startsWith(`${r}.`))return!1;const a=this.#z.config.defaultParams[t];if(n||r===t){const n=a?{...a,...e}:e;return this.#f.areStatesEqual({name:t,params:n,path:""},s,i)}const o=s.params;return!!function(t,e){for(const n in t)if(t[n]!==e[n])return!1;return!0}(e,o)&&(!a||function(t,e,n){for(const i in t)if(!(i in n)&&t[i]!==e[i])return!1;return!0}(a,o,e))}getMetaForState(t){return this.#z.matcher.hasRoute(t)?this.#z.matcher.getMetaByName(t):void 0}getUrlParams(t){const e=this.#z.matcher.getSegmentsByName(t);return e?function(t){const e=[];for(const n of t)for(const t of n.paramMeta.urlParams)e.push(t);return e}(e):[]}getStore(){return this.#z}#W(t,e){return Object.hasOwn(this.#z.config.defaultParams,t)?{...this.#z.config.defaultParams[t],...e}:e}#q(t){if(this.#G)return this.#G;const e=t?.trailingSlash;return this.#G=Object.freeze({trailingSlash:"never"===e||"always"===e?e:void 0,queryParamsMode:t?.queryParamsMode}),this.#G}#Q(t,e,n){const i=new Set([t]);let s=e(this.#f.getDependency,n),r=0;if("string"!=typeof s)throw new TypeError("forwardTo callback must return a string, got "+typeof s);for(;r<100;){if(void 0===this.#z.matcher.getSegmentsByName(s))throw new Error(`Route "${s}" does not exist`);if(i.has(s)){const t=[...i,s].join(" → ");throw new Error(`Circular forwardTo detected: ${t}`)}if(i.add(s),Object.hasOwn(this.#z.config.forwardFnMap,s)){s=(0,this.#z.config.forwardFnMap[s])(this.#f.getDependency,n),r++;continue}const t=this.#z.config.forwardMap[s];if(void 0===t)return s;s=t,r++}throw new Error("forwardTo exceeds maximum depth of 100")}},re=new n(i.ROUTER_NOT_STARTED),ae=new n(i.ROUTE_NOT_FOUND),oe=new n(i.SAME_STATES),ce=Promise.reject(re),ue=Promise.reject(ae),le=Promise.reject(oe);function he(t,e){const{toState:r,fromState:a,opts:o,toDeactivate:u,toActivate:l,intersection:h}=e;if(r.name!==s.UNKNOWN_ROUTE&&!t.hasRoute(r.name)){const e=new n(i.ROUTE_NOT_FOUND,{routeName:r.name});throw t.sendTransitionFail(r,a,e),e}if(a)for(const n of u)!l.includes(n)&&e.canDeactivateFunctions.has(n)&&t.clearCanDeactivate(n);r.transition=function(t,e,n,i,s){const r={phase:"activating",reason:"success",segments:{deactivated:n,activated:i,intersection:s}};return void 0!==t?.name&&(r.from=t.name),void 0!==e.reload&&(r.reload=e.reload),void 0!==e.redirected&&(r.redirected=e.redirected),r}(a,o,u,l,h);const d=c(r);t.setState(d);const f=void 0===o.signal?o:function({signal:t,...e}){return e}(o);return t.sendTransitionDone(d,a,f),d}function de(t,e,n,s){e.code!==i.TRANSITION_CANCELLED&&e.code!==i.ROUTE_NOT_FOUND&&t.sendTransitionFail(n,s,e)}function fe(t,e,s){if(t instanceof DOMException&&"AbortError"===t.name)throw new n(i.TRANSITION_CANCELLED);!function(t,e,i){if(t instanceof n)throw t.setCode(e),t;throw new n(e,function(t,e){const n={segment:e};if(t instanceof Error)return{...n,message:t.message,stack:t.stack,..."cause"in t&&void 0!==t.cause&&{cause:t.cause}};if(t&&"object"==typeof t){const e={};for(const[n,i]of Object.entries(t))pe.has(n)||(e[n]=i);return{...n,...e}}return n}(t,i))}(t,e,s)}ce.catch(()=>{}),ue.catch(()=>{}),le.catch(()=>{});var pe=new Set(["code","segment","path","redirect"]);async function me(t,e,i){let s;try{s=await t}catch(t){return void fe(t,e,i)}if(!s)throw new n(e,{segment:i})}async function ge(t,e,s,r,a,o,c,u,l,h){await me(l,s,h);for(let l=u;l<e.length;l++){if(!c())throw new n(i.TRANSITION_CANCELLED);const u=e[l],h=t.get(u);if(!h)continue;let d=!1;try{d=h(r,a,o)}catch(t){fe(t,s,u)}if(d instanceof Promise)await me(d,s,u);else if(!d)throw new n(s,{segment:u})}}function ve(t,e,s,r,a,o,c){for(const[u,l]of e.entries()){if(!c())throw new n(i.TRANSITION_CANCELLED);const h=t.get(l);if(!h)continue;let d=!1;try{d=h(r,a,o)}catch(t){fe(t,s,l)}if(d instanceof Promise)return ge(t,e,s,r,a,o,c,u+1,d,l);if(!d)throw new n(s,{segment:l})}}var Se=[s.UNKNOWN_ROUTE];Object.freeze(Se);var ye={replace:!0};Object.freeze(ye);var Te=class{lastSyncResolved=!1;lastSyncRejected=!1;#f;#V=null;#K=0;setDependencies(t){this.#f=t}navigate(t,e,r){this.lastSyncResolved=!1;const a=this.#f;if(!a.canNavigate())return this.lastSyncRejected=!0,ce;let o,c,u=!1,l=null;try{if(o=a.buildNavigateState(t,e),!o)return a.emitTransitionError(void 0,a.getState(),ae),this.lastSyncRejected=!0,ue;if(c=a.getState(),r=function(t,e){return e?.name!==s.UNKNOWN_ROUTE||t.replace?t:{...t,replace:!0}}(r,c),function(t,e,n){return!!t&&!e.reload&&!e.force&&t.path===n.path}(c,r,o))return a.emitTransitionError(o,c,oe),this.lastSyncRejected=!0,le;if(this.#H(),r.signal?.aborted)throw new n(i.TRANSITION_CANCELLED,{reason:r.signal.reason});const h=++this.#K;if(a.startTransition(o,c),u=!0,this.#K!==h)throw new n(i.TRANSITION_CANCELLED);const[d,f]=a.getLifecycleFunctions(),p=o.name===s.UNKNOWN_ROUTE,{toDeactivate:m,toActivate:g,intersection:v}=ne(o,c,r.reload),S=c&&!r.forceDeactivate&&m.length>0,y=!p&&g.length>0;if(d.size>0||f.size>0){l=new AbortController,this.#V=l;const t=()=>this.#K===h&&a.isActive(),e=function(t,e,s,r,a,o,c,u,l,h){if(a){const a=ve(t,s,i.CANNOT_DEACTIVATE,c,u,l,h);if(void 0!==a)return async function(t,e,s,r,a,o,c,u){if(await t,!u())throw new n(i.TRANSITION_CANCELLED);if(r){const t=ve(e,s,i.CANNOT_ACTIVATE,a,o,c,u);if(void 0!==t&&await t,!u())throw new n(i.TRANSITION_CANCELLED)}}(a,e,r,o,c,u,l,h)}if(!h())throw new n(i.TRANSITION_CANCELLED);if(o)return ve(e,r,i.CANNOT_ACTIVATE,c,u,l,h)}(d,f,m,g,!!S,y,o,c,l.signal,t);if(void 0!==e)return this.#J(e,{toState:o,fromState:c,opts:r,toDeactivate:m,toActivate:g,intersection:v,canDeactivateFunctions:d},l,h);if(!t())throw new n(i.TRANSITION_CANCELLED);this.#Y(l)}return this.lastSyncResolved=!0,Promise.resolve(he(a,{toState:o,fromState:c,opts:r,toDeactivate:m,toActivate:g,intersection:v,canDeactivateFunctions:d}))}catch(t){return this.#X(t,l,u,o,c),Promise.reject(t)}}navigateToDefault(t){const e=this.#f;if(!e.getOptions().defaultRoute)return Promise.reject(new n(i.ROUTE_NOT_FOUND,{routeName:"defaultRoute not configured"}));const{route:s,params:r}=e.resolveDefault();return s?this.navigate(s,r,t):Promise.reject(new n(i.ROUTE_NOT_FOUND,{routeName:"defaultRoute resolved to empty"}))}navigateToNotFound(t){this.#H();const e=this.#f.getState(),n=e?Jt(e.name).toReversed():[];Object.freeze(n);const i={deactivated:n,activated:Se,intersection:""};Object.freeze(i);const r={phase:"activating",...e&&{from:e.name},reason:"success",segments:i};Object.freeze(r);const a={name:s.UNKNOWN_ROUTE,params:{},path:t,transition:r};return Object.freeze(a),this.#f.setState(a),this.#f.emitTransitionSuccess(a,e,ye),a}abortCurrentNavigation(){this.#V?.abort(new n(i.TRANSITION_CANCELLED)),this.#V=null}async#J(t,e,s,r){const a=this.#f,o=()=>this.#K===r&&!s.signal.aborted&&a.isActive();try{if(e.opts.signal){if(e.opts.signal.aborted)throw new n(i.TRANSITION_CANCELLED,{reason:e.opts.signal.reason});e.opts.signal.addEventListener("abort",()=>{s.abort(e.opts.signal?.reason)},{once:!0,signal:s.signal})}if(await t,!o())throw new n(i.TRANSITION_CANCELLED);return he(a,e)}catch(t){throw de(a,t,e.toState,e.fromState),t}finally{this.#Y(s)}}#X(t,e,n,i,s){e&&this.#Y(e),n&&i&&de(this.#f,t,i,s)}#Y(t){t.abort(),this.#V===t&&(this.#V=null)}#H(){this.#f.isTransitioning()&&(f.warn("router.navigate","Concurrent navigation detected on shared router instance. For SSR, use cloneRouter() to create isolated instance per request."),this.#V?.abort(new n(i.TRANSITION_CANCELLED)),this.#f.cancelNavigation())}},we={replace:!0};Object.freeze(we);var be=class{#f;setDependencies(t){this.#f=t}async start(t){const e=this.#f,s=e.getOptions(),r=e.matchPath(t);if(!r&&!s.allowNotFound){const s=new n(i.ROUTE_NOT_FOUND,{path:t});throw e.emitTransitionError(void 0,void 0,s),s}return e.completeStart(),r?e.navigate(r.name,r.params,we):e.navigateToNotFound(t)}stop(){this.#f.clearState()}},Ne=class{#Z;#tt;#et;#nt;#it;#st;constructor(t){this.#Z=t.routerFSM,this.#tt=t.emitter,this.#et=void 0,this.#rt()}static validateSubscribeListener(t){if("function"!=typeof t)throw new TypeError("[router.subscribe] Expected a function. For Observable pattern use @real-router/rx package")}emitRouterStart(){this.#tt.emit(e.ROUTER_START)}emitRouterStop(){this.#tt.emit(e.ROUTER_STOP)}emitTransitionStart(t,n){this.#tt.emit(e.TRANSITION_START,t,n)}emitTransitionSuccess(t,n,i){this.#tt.emit(e.TRANSITION_SUCCESS,t,n,i)}emitTransitionError(t,n,i){this.#tt.emit(e.TRANSITION_ERROR,t,n,i)}emitTransitionCancel(t,n){this.#tt.emit(e.TRANSITION_CANCEL,t,n)}sendStart(){this.#Z.send(P)}sendStop(){this.#Z.send(D)}sendDispose(){this.#Z.send(F)}sendStarted(){this.#Z.send(A)}sendNavigate(t,e){this.#et=t,this.#Z.forceState(b),this.emitTransitionStart(t,e)}sendComplete(t,e,n={}){this.#Z.forceState(w),this.emitTransitionSuccess(t,e,n),this.#et===t&&(this.#et=void 0)}sendFail(t,e,n){const i=this.#et;this.#nt=t,this.#it=e,this.#st=n,this.#Z.send(R),this.#et===i&&(this.#et=void 0)}sendFailSafe(t,e,n){this.isReady()?this.sendFail(t,e,n):this.emitTransitionError(t,e,n)}sendCancel(t,e){const n=this.#et;this.#nt=t,this.#it=e,this.#Z.send(C),this.#et===n&&(this.#et=void 0)}canBeginTransition(){return this.#Z.canSend(O)}canStart(){return this.#Z.canSend(P)}canCancel(){return this.#Z.canSend(C)}isActive(){const t=this.#Z.getState();return t!==y&&t!==N}isDisposed(){return this.#Z.getState()===N}isTransitioning(){return this.#Z.getState()===b}isReady(){return this.#Z.getState()===w}getCurrentToState(){return this.#et}addEventListener(t,e){return this.#tt.on(t,e)}subscribe(t){return this.#tt.on(e.TRANSITION_SUCCESS,(e,n)=>{t({route:e,previousRoute:n})})}clearAll(){this.#tt.clearAll()}setLimits(t){this.#tt.setLimits(t)}sendCancelIfTransitioning(t){this.canCancel()&&this.sendCancel(this.#et,t)}#at(){this.emitTransitionError(this.#nt,this.#it,this.#st)}#rt(){const t=this.#Z;t.on(T,A,()=>{this.emitRouterStart()}),t.on(w,D,()=>{this.emitRouterStop()}),t.on(b,C,()=>{const t=this.#nt;void 0!==t&&this.emitTransitionCancel(t,this.#it)}),t.on(T,R,()=>{this.#at()}),t.on(w,R,()=>{this.#at()}),t.on(b,R,()=>{this.#at()})}},Pe=new n(i.ROUTER_ALREADY_STARTED),Ae=new Set(["all","warn-error","error-only"]);var Oe=class{router;options;limits;dependenciesStore;state;routes;routeLifecycle;plugins;navigation;lifecycle;eventBus;constructor(t){this.router=t.router,this.options=t.options,this.limits=t.limits,this.dependenciesStore=t.dependenciesStore,this.state=t.state,this.routes=t.routes,this.routeLifecycle=t.routeLifecycle,this.plugins=t.plugins,this.navigation=t.navigation,this.lifecycle=t.lifecycle,this.eventBus=t.eventBus}wireLimits(){this.dependenciesStore.limits=this.limits,this.plugins.setLimits(this.limits),this.eventBus.setLimits({maxListeners:this.limits.maxListeners,warnListeners:this.limits.warnListeners,maxEventDepth:this.limits.maxEventDepth}),this.routeLifecycle.setLimits(this.limits)}wireRouteLifecycleDeps(){const t={compileFactory:this.createCompileFactory()};this.routeLifecycle.setDependencies(t),this.routeLifecycle.setValidatorGetter(()=>{try{return d(this.router).validator}catch{return null}})}wireRoutesDeps(){this.routes.setDependencies({addActivateGuard:(t,e)=>{this.routeLifecycle.addCanActivate(t,e,!0)},addDeactivateGuard:(t,e)=>{this.routeLifecycle.addCanDeactivate(t,e,!0)},makeState:(t,e,n,i)=>this.state.makeState(t,e,n,i),getState:()=>this.state.get(),areStatesEqual:(t,e,n)=>this.state.areStatesEqual(t,e,n),getDependency:t=>this.dependenciesStore.dependencies[t],forwardState:(t,e)=>{const n=d(this.router);return n.validator?.routes.validateStateBuilderArgs(t,e,"forwardState"),n.forwardState(t,e)}}),this.routes.setLifecycleNamespace(this.routeLifecycle)}wirePluginsDeps(){const t={addEventListener:(t,e)=>this.eventBus.addEventListener(t,e),canNavigate:()=>this.eventBus.canBeginTransition(),compileFactory:this.createCompileFactory()};this.plugins.setDependencies(t),this.plugins.setValidatorGetter(()=>{try{return d(this.router).validator}catch{return null}})}wireNavigationDeps(){this.navigation.setDependencies({getOptions:()=>this.options.get(),hasRoute:t=>this.routes.hasRoute(t),getState:()=>this.state.get(),setState:t=>{this.state.set(t)},buildNavigateState:(t,e)=>{const n=d(this.router);n.validator?.routes.validateStateBuilderArgs(t,e,"navigate");const{name:i,params:s}=n.forwardState(t,e),r=this.routes.getMetaForState(i);if(void 0===r)return;const a=n.buildPath(i,s);return this.state.makeState(i,s,a,r,void 0,!0)},resolveDefault:()=>{const t=this.options.get();return{route:U(t.defaultRoute,t=>this.dependenciesStore.dependencies[t]),params:U(t.defaultParams,t=>this.dependenciesStore.dependencies[t])}},startTransition:(t,e)=>{this.eventBus.sendNavigate(t,e)},cancelNavigation:()=>{const t=this.eventBus.getCurrentToState();void 0!==t&&this.eventBus.sendCancel(t,this.state.get())},sendTransitionDone:(t,e,n)=>{this.eventBus.sendComplete(t,e,n)},sendTransitionFail:(t,e,n)=>{this.eventBus.sendFail(t,e,n)},emitTransitionError:(t,e,n)=>{this.eventBus.sendFailSafe(t,e,n)},emitTransitionSuccess:(t,e,n)=>{this.eventBus.emitTransitionSuccess(t,e,n)},canNavigate:()=>this.eventBus.canBeginTransition(),getLifecycleFunctions:()=>this.routeLifecycle.getFunctions(),isActive:()=>this.router.isActive(),isTransitioning:()=>this.eventBus.isTransitioning(),clearCanDeactivate:t=>{this.routeLifecycle.clearCanDeactivate(t)}})}wireLifecycleDeps(){this.lifecycle.setDependencies({getOptions:()=>this.options.get(),navigate:(t,e,n)=>this.navigation.navigate(t,e,n),navigateToNotFound:t=>this.navigation.navigateToNotFound(t),clearState:()=>{this.state.set(void 0)},matchPath:t=>this.routes.matchPath(t,this.options.get()),completeStart:()=>{this.eventBus.sendStarted()},emitTransitionError:(t,e,n)=>{this.eventBus.sendFail(t,e,n)}})}wireStateDeps(){this.state.setDependencies({getDefaultParams:()=>this.routes.getStore().config.defaultParams,buildPath:(t,e)=>d(this.router).buildPath(t,e),getUrlParams:t=>this.routes.getUrlParams(t)})}createCompileFactory(){const{router:t,dependenciesStore:e}=this;return n=>n(t,t=>e.dependencies[t])}},Ee=Object.freeze({}),Re=class t{#u;#S;#ot;#ct;#ut;#lt;#g;#ht;#dt;#ft;constructor(t=[],e={},n={}){e.logger&&function(t){if("object"!=typeof t||null===t)throw new TypeError("Logger config must be an object");const e=t;for(const t of Object.keys(e))if("level"!==t&&"callback"!==t)throw new TypeError(`Unknown logger config property: "${t}"`);if("level"in e&&void 0!==e.level&&("string"!=typeof(n=e.level)||!Ae.has(n)))throw new TypeError(`Invalid logger level: ${function(t){return"string"==typeof t?`"${t}"`:"object"==typeof t?JSON.stringify(t):String(t)}(e.level)}. Expected: "all" | "warn-error" | "error-only"`);var n;if("callback"in e&&void 0!==e.callback&&"function"!=typeof e.callback)throw new TypeError("Logger callback must be a function, got "+typeof e.callback);return!0}(e.logger)&&(f.configure(e.logger),delete e.logger),$.validateOptionsIsObject(e),function(t){if(!t||"object"!=typeof t||t.constructor!==Object)throw new TypeError("dependencies must be a plain object");for(const e in t)if(Object.getOwnPropertyDescriptor(t,e)?.get)throw new TypeError(`dependencies cannot contain getters: "${e}"`)}(n),t.length>0&&L(t),this.#u=new $(e),this.#S=r(e.limits),this.#ot=function(t={}){const e=Object.create(null);for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return{dependencies:e,limits:o}}(n),this.#ct=new _,this.#ut=new se(t,function(t){return{strictTrailingSlash:"strict"===t.trailingSlash,strictQueryParams:"strict"===t.queryParamsMode,urlParamsEncoding:t.urlParamsEncoding,queryParams:t.queryParams}}(this.#u.get())),this.#lt=new q,this.#g=new G,this.#ht=new Te,this.#dt=new be;const i=new p(j),s=new S({onListenerError:(t,e)=>{f.error("Router",`Error in listener for ${t}:`,e)},onListenerWarn:(t,e)=>{f.warn("router.addEventListener",`Event "${t}" has ${e} listeners — possible memory leak`)}});var c;this.#ft=new Ne({routerFSM:i,emitter:s}),(c=new Oe({router:this,options:this.#u,limits:this.#S,dependenciesStore:this.#ot,state:this.#ct,routes:this.#ut,routeLifecycle:this.#lt,plugins:this.#g,navigation:this.#ht,lifecycle:this.#dt,eventBus:this.#ft})).wireLimits(),c.wireRouteLifecycleDeps(),c.wireRoutesDeps(),c.wirePluginsDeps(),c.wireNavigationDeps(),c.wireLifecycleDeps(),c.wireStateDeps();const d=new Map;u(this,{makeState:(t,e,n,i,s)=>this.#ct.makeState(t,e,n,i,s),forwardState:h("forwardState",(t,e)=>this.#ut.forwardState(t,e),d),buildStateResolved:(t,e)=>this.#ut.buildStateResolved(t,e),matchPath:(t,e)=>this.#ut.matchPath(t,e),getOptions:()=>this.#u.get(),addEventListener:(t,e)=>this.#ft.addEventListener(t,e),buildPath:h("buildPath",(t,e)=>this.#ut.buildPath(t,e??a,this.#u.get()),d),start:l("start",t=>this.#dt.start(t),d),interceptors:d,setRootPath:t=>{this.#ut.setRootPath(t)},getRootPath:()=>this.#ut.getStore().rootPath,getTree:()=>this.#ut.getStore().tree,isDisposed:()=>this.#ft.isDisposed(),validator:null,dependenciesGetStore:()=>this.#ot,cloneOptions:()=>({...this.#u.get()}),cloneDependencies:()=>({...this.#ot.dependencies}),getLifecycleFactories:()=>this.#lt.getFactories(),getPluginFactories:()=>this.#g.getAll(),routeGetStore:()=>this.#ut.getStore(),getStateName:()=>this.#ct.get()?.name,isTransitioning:()=>this.#ft.isTransitioning(),clearState:()=>{this.#ct.set(void 0)},setState:t=>{this.#ct.set(t)},routerExtensions:[]}),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,e,n,i){return d(this).validator?.routes.validateIsActiveRouteArgs(t,e,n,i),d(this).validator?.routes.validateRouteName(t,"isActiveRoute"),""===t?(f.warn("real-router",'isActiveRoute("") called with empty string. Root node is not considered a parent of any route.'),!1):this.#ut.isActiveRoute(t,e,n,i)}buildPath(t,e){const n=d(this);return n.validator?.routes.validateBuildPathArgs(t),n.validator?.navigation.validateParams(e,"buildPath"),n.buildPath(t,e)}getState(){return this.#ct.get()}getPreviousState(){return this.#ct.getPrevious()}areStatesEqual(t,e,n=!0){return d(this).validator?.state.validateAreStatesEqualArgs(t,e,n),this.#ct.areStatesEqual(t,e,n)}shouldUpdateNode(t){return d(this).validator?.routes.validateShouldUpdateNodeArgs(t),se.shouldUpdateNode(t)}isActive(){return this.#ft.isActive()}start(e){if(!this.#ft.canStart())return Promise.reject(Pe);d(this).validator?.navigation.validateStartArgs(e),this.#ft.sendStart();const n=d(this).start(e).catch(t=>{throw this.#ft.isReady()&&(this.#dt.stop(),this.#ft.sendStop()),t});return t.#pt(n),n}stop(){return this.#ht.abortCurrentNavigation(),this.#ft.sendCancelIfTransitioning(this.#ct.get()),this.#ft.isReady()||this.#ft.isTransitioning()?(this.#dt.stop(),this.#ft.sendStop(),this):this}dispose(){if(this.#ft.isDisposed())return;this.#ht.abortCurrentNavigation(),this.#ft.sendCancelIfTransitioning(this.#ct.get()),(this.#ft.isReady()||this.#ft.isTransitioning())&&(this.#dt.stop(),this.#ft.sendStop()),this.#ft.sendDispose(),this.#ft.clearAll(),this.#g.disposeAll();const t=d(this);for(const e of t.routerExtensions)for(const t of e.keys)delete this[t];t.routerExtensions.length=0,this.#ut.clearRoutes(),this.#lt.clearAll(),this.#ct.reset(),this.#ot.dependencies=Object.create(null),this.#mt()}canNavigateTo(t,e){const n=d(this);if(n.validator?.routes.validateRouteName(t,"canNavigateTo"),n.validator?.navigation.validateParams(e,"canNavigateTo"),!this.#ut.hasRoute(t))return!1;const{name:i,params:s}=n.forwardState(t,e??{}),r=this.#ct.makeState(i,s),a=this.#ct.get(),{toDeactivate:o,toActivate:c}=ne(r,a);return this.#lt.canNavigateTo(o,c,r,a)}usePlugin(...t){const e=t.filter(Boolean);if(0===e.length)return()=>{};const n=d(this);n.validator?.plugins.validatePluginLimit(this.#g.count(),this.#S);for(const t of e)n.validator?.plugins.validateNoDuplicatePlugins(t,this.#g.getAll());return this.#g.use(...e)}subscribe(t){return Ne.validateSubscribeListener(t),this.#ft.subscribe(t)}navigate(e,n,i){const s=d(this);s.validator?.navigation.validateNavigateArgs(e),s.validator?.navigation.validateParams(n,"navigate");const r=i??Ee;s.validator?.navigation.validateNavigationOptions(r,"navigate");const o=this.#ht.navigate(e,n??a,r);return this.#ht.lastSyncResolved?this.#ht.lastSyncResolved=!1:this.#ht.lastSyncRejected?this.#ht.lastSyncRejected=!1:t.#pt(o),o}navigateToDefault(e){const n=d(this);n.validator?.navigation.validateNavigateToDefaultArgs(e);const i=e??Ee;n.validator?.navigation.validateNavigationOptions(i,"navigateToDefault");const s=this.#ht.navigateToDefault(i);return this.#ht.lastSyncResolved?this.#ht.lastSyncResolved=!1:this.#ht.lastSyncRejected?this.#ht.lastSyncRejected=!1:t.#pt(s),s}navigateToNotFound(t){if(!this.#ft.isActive())throw new n(i.ROUTER_NOT_STARTED);if(void 0!==t&&"string"!=typeof t)throw new TypeError("[router.navigateToNotFound] path must be a string, got "+typeof t);const e=t??this.#ct.get().path;return this.#ht.navigateToNotFound(e)}static#gt=t=>{t instanceof n&&(t.code===i.SAME_STATES||t.code===i.TRANSITION_CANCELLED||t.code===i.ROUTER_NOT_STARTED||t.code===i.ROUTE_NOT_FOUND)||f.error("router.navigate","Unexpected navigation error",t)};static#pt(e){e.catch(t.#gt)}#mt(){this.navigate=Ce,this.navigateToDefault=Ce,this.navigateToNotFound=Ce,this.start=Ce,this.stop=Ce,this.usePlugin=Ce,this.subscribe=Ce,this.canNavigateTo=Ce}};function Ce(){throw new n(i.ROUTER_DISPOSED)}export{Re as Router,K as clearConfigEntries,Bt as clearRouteData,jt as f,L as guardRouteStructure,_t as refreshForwardMap,xt as registerAllRouteHandlers,V as removeFromDefinitions,m as resolveForwardChain,Q as sanitizeRoute};//# sourceMappingURL=chunk-MNRZAE7T.mjs.map
|