@real-router/core 0.172.0 → 0.173.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-DP-Axjj2.js +2 -0
- package/dist/cjs/Router-DP-Axjj2.js.map +1 -0
- package/dist/cjs/Router.d.ts.map +1 -1
- package/dist/cjs/api.js +1 -1
- package/dist/cjs/api.js.map +1 -1
- package/dist/cjs/engine/createMatcher.d.ts +0 -17
- package/dist/cjs/engine/createMatcher.d.ts.map +1 -1
- package/dist/cjs/engine/index.d.ts +2 -2
- package/dist/cjs/engine/search-params/index.d.ts +1 -1
- package/dist/cjs/helpers-BCSkINAR.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/route-batch-ByWFZwIP.js +2 -0
- package/dist/cjs/route-batch-ByWFZwIP.js.map +1 -0
- package/dist/cjs/types/api.d.ts +3 -6
- package/dist/cjs/types/api.d.ts.map +1 -1
- package/dist/cjs/types/base.d.ts +3 -6
- package/dist/cjs/types/base.d.ts.map +1 -1
- package/dist/cjs/types.d.ts +1 -7
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/validation.d.ts +9 -11
- package/dist/cjs/validation.js +1 -1
- package/dist/esm/Router-BuBcRFcb.mjs +2 -0
- package/dist/esm/Router-BuBcRFcb.mjs.map +1 -0
- package/dist/esm/Router.d.mts.map +1 -1
- package/dist/esm/api.mjs +1 -1
- package/dist/esm/api.mjs.map +1 -1
- package/dist/esm/engine/createMatcher.d.mts +0 -17
- package/dist/esm/engine/createMatcher.d.mts.map +1 -1
- package/dist/esm/engine/index.d.mts +2 -2
- package/dist/esm/engine/search-params/index.d.mts +1 -1
- package/dist/esm/helpers-LeSZEDaV.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/route-batch-BHxxucx6.mjs +2 -0
- package/dist/esm/route-batch-BHxxucx6.mjs.map +1 -0
- package/dist/esm/types/api.d.mts +3 -6
- package/dist/esm/types/api.d.mts.map +1 -1
- package/dist/esm/types/base.d.mts +3 -6
- package/dist/esm/types/base.d.mts.map +1 -1
- package/dist/esm/types.d.mts +1 -7
- package/dist/esm/types.d.mts.map +1 -1
- package/dist/esm/validation.d.mts +9 -11
- package/dist/esm/validation.mjs +1 -1
- package/package.json +1 -1
- package/dist/cjs/Router-CbpheBEo.js +0 -2
- package/dist/cjs/Router-CbpheBEo.js.map +0 -1
- package/dist/cjs/dependenciesStore.d.ts +0 -36
- package/dist/cjs/dependenciesStore.d.ts.map +0 -1
- package/dist/cjs/internals-C0q224rS.js +0 -2
- package/dist/cjs/internals-C0q224rS.js.map +0 -1
- package/dist/cjs/internals.d.ts +0 -158
- package/dist/cjs/internals.d.ts.map +0 -1
- package/dist/cjs/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.ts +0 -191
- package/dist/cjs/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.ts.map +0 -1
- package/dist/cjs/namespaces/RouteLifecycleNamespace/index.d.ts +0 -3
- package/dist/cjs/namespaces/RouteLifecycleNamespace/types.d.ts +0 -17
- package/dist/cjs/namespaces/RouteLifecycleNamespace/types.d.ts.map +0 -1
- package/dist/cjs/namespaces/RoutesNamespace/RoutesNamespace.d.ts +0 -7
- package/dist/cjs/namespaces/RoutesNamespace/index.d.ts +0 -4
- package/dist/cjs/namespaces/RoutesNamespace/routesStore.d.ts +0 -105
- package/dist/cjs/namespaces/RoutesNamespace/routesStore.d.ts.map +0 -1
- package/dist/cjs/namespaces/RoutesNamespace/types.d.ts +0 -71
- package/dist/cjs/namespaces/RoutesNamespace/types.d.ts.map +0 -1
- package/dist/cjs/pipeline/buildURL.d.ts +0 -2
- package/dist/cjs/pipeline/canonicalize.d.ts +0 -3
- package/dist/cjs/pipeline/index.d.ts +0 -22
- package/dist/cjs/pipeline/materialize.d.ts +0 -2
- package/dist/cjs/pipeline/port.d.ts +0 -193
- package/dist/cjs/pipeline/port.d.ts.map +0 -1
- package/dist/cjs/pipeline/types.d.ts +0 -1
- package/dist/cjs/transitionPath.d.ts +0 -1
- package/dist/cjs/types/internal.d.ts +0 -23
- package/dist/cjs/types/internal.d.ts.map +0 -1
- package/dist/esm/Router-DYuv6lN0.mjs +0 -2
- package/dist/esm/Router-DYuv6lN0.mjs.map +0 -1
- package/dist/esm/dependenciesStore.d.mts +0 -36
- package/dist/esm/dependenciesStore.d.mts.map +0 -1
- package/dist/esm/internals-JRDAPvLO.mjs +0 -2
- package/dist/esm/internals-JRDAPvLO.mjs.map +0 -1
- package/dist/esm/internals.d.mts +0 -158
- package/dist/esm/internals.d.mts.map +0 -1
- package/dist/esm/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.mts +0 -191
- package/dist/esm/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.mts.map +0 -1
- package/dist/esm/namespaces/RouteLifecycleNamespace/index.d.mts +0 -3
- package/dist/esm/namespaces/RouteLifecycleNamespace/types.d.mts +0 -17
- package/dist/esm/namespaces/RouteLifecycleNamespace/types.d.mts.map +0 -1
- package/dist/esm/namespaces/RoutesNamespace/RoutesNamespace.d.mts +0 -7
- package/dist/esm/namespaces/RoutesNamespace/index.d.mts +0 -4
- package/dist/esm/namespaces/RoutesNamespace/routesStore.d.mts +0 -105
- package/dist/esm/namespaces/RoutesNamespace/routesStore.d.mts.map +0 -1
- package/dist/esm/namespaces/RoutesNamespace/types.d.mts +0 -71
- package/dist/esm/namespaces/RoutesNamespace/types.d.mts.map +0 -1
- package/dist/esm/pipeline/buildURL.d.mts +0 -2
- package/dist/esm/pipeline/canonicalize.d.mts +0 -3
- package/dist/esm/pipeline/index.d.mts +0 -22
- package/dist/esm/pipeline/materialize.d.mts +0 -2
- package/dist/esm/pipeline/port.d.mts +0 -193
- package/dist/esm/pipeline/port.d.mts.map +0 -1
- package/dist/esm/pipeline/types.d.mts +0 -1
- package/dist/esm/transitionPath.d.mts +0 -1
- package/dist/esm/types/internal.d.mts +0 -23
- package/dist/esm/types/internal.d.mts.map +0 -1
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { Params, SearchParams, State } from "../types/base.js";
|
|
2
|
-
import "../types.js";
|
|
3
|
-
/**
|
|
4
|
-
* The pipeline's read-model over the routes layer — a narrow port, not a new
|
|
5
|
-
* layer. The module stays pure and mock-testable; the router implements the
|
|
6
|
-
* port at wiring time (`wiring/wireNamespaces.ts`).
|
|
7
|
-
*
|
|
8
|
-
* ⚠ **ONE end is interceptable, and which one is a position, not a taste.** The
|
|
9
|
-
* signatures describe the pipeline's contract, not where the implementation
|
|
10
|
-
* goes:
|
|
11
|
-
*
|
|
12
|
-
* - `resolveForward` is wired to the `forwardState` SEAM (`Router.ts`, the
|
|
13
|
-
* interceptable built at `SEAM.forwardState`),
|
|
14
|
-
* i.e. the interceptable chain PLUS the centralized channel ASSERTION. There
|
|
15
|
-
* is no channel-SEPARATION wrapper behind it: the seam REFUSES a
|
|
16
|
-
* mis-channelled bag (`assertChannelCorrect`, `src/channels/guard.ts`) rather
|
|
17
|
-
* than repairing one behind the producer's back. Channel-correctness is the
|
|
18
|
-
* producer's contract, not something the port quietly restores. Calling
|
|
19
|
-
* the namespace primitive directly would switch off both the interceptors and
|
|
20
|
-
* that check.
|
|
21
|
-
* - `buildPath` is wired STRAIGHT to the namespace primitive — nothing
|
|
22
|
-
* interceptable stands between this port and the engine (#1938). A seam here
|
|
23
|
-
* would sit BELOW the route-default merge, where an injection reaches the URL
|
|
24
|
-
* and not `state.search`; `forwardState` is the seam that sits above it, and
|
|
25
|
-
* every door runs that one, `router.buildPath` included (#2087). One
|
|
26
|
-
* position, one answer.
|
|
27
|
-
*
|
|
28
|
-
* ⚠ It hands over `canonical.query` on every call, so the primitive's
|
|
29
|
-
* `search` is REQUIRED rather than defaulted. This port is its only caller.
|
|
30
|
-
*
|
|
31
|
-
* Accessors arrived with their consumers, as designed — `queryNames` with the
|
|
32
|
-
* channel guard, `admitsUndeclaredQuery` and later `printedQueryNames` with the
|
|
33
|
-
* mode gate (#1575 / #1932), `pathNames` and two sinks with the diagnostics
|
|
34
|
-
* (#1579 / #1584), a third sink with the codec diagnostic (#2905). One
|
|
35
|
-
* member the design (RFC §4.5) listed never arrived at all: `encode`. The route
|
|
36
|
-
* codecs stayed with the entry points that own their direction (`buildPath`
|
|
37
|
-
* calls `config.encoders`, `matchPath` calls `config.decoders`), so the port
|
|
38
|
-
* never grew a stage for them — which is the case for adding a member only
|
|
39
|
-
* together with its caller, since one added early is dead weight nothing
|
|
40
|
-
* detects (knip has no issue type for unused members of an interface).
|
|
41
|
-
*/
|
|
42
|
-
export interface RouteResolver {
|
|
43
|
-
/**
|
|
44
|
-
* Stage ① — resolve the `forwardTo` chain (layering the hops' defaults) and
|
|
45
|
-
* hand back channel-correct bags. Channel-correct by REFUSAL, not by repair:
|
|
46
|
-
* the seam asserts and throws (see the header). `search` flows THROUGH the
|
|
47
|
-
* interceptor zone, not past it: `search-schema` validates the query channel
|
|
48
|
-
* here on the URL→State direction.
|
|
49
|
-
*/
|
|
50
|
-
resolveForward: (name: string, params: Params, search?: SearchParams) => {
|
|
51
|
-
name: string;
|
|
52
|
-
params: Params;
|
|
53
|
-
search?: SearchParams | undefined;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Stage ③ input — the route's per-channel defaults. Split by field, never
|
|
57
|
-
* inferred: `defaultParams` owns the path channel, `defaultSearch` the query
|
|
58
|
-
* channel (RFC-4 M2 / #1548).
|
|
59
|
-
*
|
|
60
|
-
* Two accessors rather than one returning `{ params, search }`: `navigate` is
|
|
61
|
-
* the hot path, and the combined form allocated one throwaway object per
|
|
62
|
-
* navigation. That allocation is the deterministic reason; the bench arm it
|
|
63
|
-
* was measured on also carried a per-call `getInternals`, and the harness's
|
|
64
|
-
* own A/A spread is wider than the delta, so no percentage is attributable to
|
|
65
|
-
* this accessor alone.
|
|
66
|
-
*
|
|
67
|
-
* Also the ROUTE half of the fast-path gate (#1589), which is why these two are
|
|
68
|
-
* the only reads `canonicalize` still makes before it. A dedicated
|
|
69
|
-
* `mergesNothing()` predicate answering the same question in ONE hop was built
|
|
70
|
-
* and measured: it buys the fast path a further ~10 ns but makes the DEFAULTS
|
|
71
|
-
* path re-read both values below the gate — a fourth hop, +6.5 % there. Reading
|
|
72
|
-
* the values themselves regresses nothing, because the slow path was going to
|
|
73
|
-
* need them anyway.
|
|
74
|
-
*/
|
|
75
|
-
defaultParams: (name: string) => Params | undefined;
|
|
76
|
-
defaultSearch: (name: string) => SearchParams | undefined;
|
|
77
|
-
/**
|
|
78
|
-
* Stage ⑤a printer — builds the URL from already-merged channels. Kept in
|
|
79
|
-
* raw-channel form (not `Canonical`) so the port never has to know about the
|
|
80
|
-
* brand and stays mockable on its own; `buildURL` is the primitive that
|
|
81
|
-
* accepts nothing but a `Canonical`.
|
|
82
|
-
*/
|
|
83
|
-
buildPath: (name: string, params: Params, search: SearchParams) => string;
|
|
84
|
-
/**
|
|
85
|
-
* The route's declared `?query` names MINUS its path slots — the registry that
|
|
86
|
-
* decides **which channel owns a key** (#1556 / #843 / #1549). A name that
|
|
87
|
-
* also occupies a path slot (`/items/:id?id`) is absent here by construction:
|
|
88
|
-
* it is legitimately path-owned, so the path value stays in `state.params`
|
|
89
|
-
* and the rebuild's precedence holds.
|
|
90
|
-
*
|
|
91
|
-
* ⚠ This is NOT the list of names the build prints, and the difference is one
|
|
92
|
-
* route shape wide (#1932). The consumers that CLASSIFY read this one — the
|
|
93
|
-
* always-on channel guard, the default withhold, the undeclared-key
|
|
94
|
-
* diagnostic. The mode gate asks the OTHER question and reads
|
|
95
|
-
* {@link RouteResolver.printedQueryNames}.
|
|
96
|
-
*/
|
|
97
|
-
queryNames: (name: string) => readonly string[];
|
|
98
|
-
/**
|
|
99
|
-
* The route's declared `?query` names AS PRINTED — the collision left in
|
|
100
|
-
* (#1932). The matcher keeps path-slot collisions in `declaredQueryParams`
|
|
101
|
-
* and the query-string build reads that same array, so a key is printed iff
|
|
102
|
-
* it appears here.
|
|
103
|
-
*
|
|
104
|
-
* ⚑ The mode gate's registry, and only the gate's. Its question is "will this
|
|
105
|
-
* key survive into `state.path`?", which is what buys
|
|
106
|
-
* `keys(state.search) ⊆ keys(matchPath(state.path).search)` — an invariant the
|
|
107
|
-
* SUBTRACTED list cannot answer for, since it withholds a name the build
|
|
108
|
-
* prints.
|
|
109
|
-
*/
|
|
110
|
-
printedQueryNames: (name: string) => readonly string[];
|
|
111
|
-
/**
|
|
112
|
-
* The mode gate (#1575) — `true` exactly for `queryParamsMode: "loose"`, the
|
|
113
|
-
* one mode whose build prints undeclared query keys. Read as a boolean rather
|
|
114
|
-
* than leaking the mode itself into the pipeline: the pipeline's question is
|
|
115
|
-
* "may an undeclared key be canonical here?", not "which mode is this?".
|
|
116
|
-
*/
|
|
117
|
-
admitsUndeclaredQuery: () => boolean;
|
|
118
|
-
/**
|
|
119
|
-
* The mode gate's opt-in diagnostic sink (#1575) — `undefined` while nothing
|
|
120
|
-
* listens to the router's `DROPPED_QUERY_KEY` kind, so bare core drops
|
|
121
|
-
* silently and the pipeline pays nothing. Resolved per read, not captured: a
|
|
122
|
-
* listener subscribes after wiring.
|
|
123
|
-
*
|
|
124
|
-
* ⚠ Like its sibling below, the absence has to be REAL: the router implements
|
|
125
|
-
* this as a GETTER returning `undefined` while the kind has no listener, not
|
|
126
|
-
* as a closure that forwards to the emitter. A closure is always truthy, so
|
|
127
|
-
* the pipeline's `?.` would read as taken and bare core would pay the
|
|
128
|
-
* `pathNames` existence lookup (#1584) once per dropped key with nothing to
|
|
129
|
-
* feed. The `| undefined` in the type is what lets the getter say so under
|
|
130
|
-
* `exactOptionalPropertyTypes`.
|
|
131
|
-
*
|
|
132
|
-
* Optional on the interface so a MOCK port (the property tests) stays a
|
|
133
|
-
* four-liner: the pipeline's contract is the drop, not the report.
|
|
134
|
-
*/
|
|
135
|
-
reportDroppedQueryKey?: ((routeName: string, key: string) => void) | undefined;
|
|
136
|
-
/**
|
|
137
|
-
* The PATH slot names the route's URL prints, the root's (`setRootPath`)
|
|
138
|
-
* included, or `undefined` when there is NO SUCH ROUTE — the other half of
|
|
139
|
-
* "is this key declared?". Needed only by the undeclared-key
|
|
140
|
-
* diagnostic (#1579), which asks whether a key is declared ANYWHERE;
|
|
141
|
-
* `queryNames` alone cannot answer that.
|
|
142
|
-
*
|
|
143
|
-
* ⚠ The `undefined` arm is load-bearing, not defensive (#1584). An empty array
|
|
144
|
-
* is what an EXISTING route with no path slots returns, so `[]` cannot say
|
|
145
|
-
* "no such route" — and the diagnostic, reading `[]` for both, reported every
|
|
146
|
-
* key in the caller's bag as "declared nowhere on route X" for a route X that
|
|
147
|
-
* has no declarations only because it has no existence. That blames the params
|
|
148
|
-
* for a typo in the ROUTE name, which is the most misleading direction
|
|
149
|
-
* available. The matcher already knows the difference (`getSegmentsByName`
|
|
150
|
-
* answers `undefined`), so this member carries it rather than flattening it
|
|
151
|
-
* to `[]`.
|
|
152
|
-
*
|
|
153
|
-
* `queryNames` is deliberately NOT given the same arm: its consumers — the
|
|
154
|
-
* diagnostic, the default merge and the channel guard — all want `[]` for a
|
|
155
|
-
* missing route, and only this one asks a question that presupposes
|
|
156
|
-
* existence.
|
|
157
|
-
*/
|
|
158
|
-
pathNames: (name: string) => readonly string[] | undefined;
|
|
159
|
-
/**
|
|
160
|
-
* Opt-in sink for a key the route declares NOWHERE (#1579 — the params half
|
|
161
|
-
* of #1553). Absent while nothing listens to the `UNDECLARED_PARAM_KEY`
|
|
162
|
-
* kind, and the absence is what keeps the scan off the hot path: core checks
|
|
163
|
-
* one `undefined` and skips the walk entirely.
|
|
164
|
-
*
|
|
165
|
-
* ⚠ The absence has to be REAL — the router implements this member as a
|
|
166
|
-
* GETTER returning `undefined` while the kind has no listener, not as a
|
|
167
|
-
* closure that forwards to the emitter. A closure is always truthy, so the
|
|
168
|
-
* gate would read as taken and bare core would walk the caller's bag on
|
|
169
|
-
* every commit; the `| undefined` in the type is what lets the getter say so
|
|
170
|
-
* under `exactOptionalPropertyTypes`.
|
|
171
|
-
*
|
|
172
|
-
* A diagnostic, never a gate — core keeps the key in `state.params` as
|
|
173
|
-
* app-level data (wiki `Route.md`). Dropping it was measured and rejected: it
|
|
174
|
-
* retires a shipped capability, and "declared nowhere" cannot tell a typo from
|
|
175
|
-
* `navigate("users", { id })` on a parent whose CHILD declares `:id`.
|
|
176
|
-
*/
|
|
177
|
-
reportUndeclaredParamKey?: ((routeName: string, key: string) => void) | undefined;
|
|
178
|
-
/**
|
|
179
|
-
* Opt-in sink for a route codec's round trip (#2905). Absent while nothing
|
|
180
|
-
* listens to the `CODEC_ROUND_TRIP` kind, so bare core reads one `undefined`
|
|
181
|
-
* per commit and looks up no codec for it.
|
|
182
|
-
*
|
|
183
|
-
* ⚑ Read by the two committing producers, not by `canonicalize`: what is
|
|
184
|
-
* judged is the state they build, which exists only after ⑤. The router's
|
|
185
|
-
* implementation raises the kind with the route's codecs and the path slots
|
|
186
|
-
* its URL prints, and only for a route that has a codec.
|
|
187
|
-
*
|
|
188
|
-
* ⚠ A GETTER on the router's port, like the two sinks above, so the absence
|
|
189
|
-
* is real.
|
|
190
|
-
*/
|
|
191
|
-
reportCodecRoundTrip?: ((state: State) => void) | undefined;
|
|
192
|
-
}
|
|
193
|
-
//# sourceMappingURL=port.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"port.d.ts","names":[],"sources":["../../../src/pipeline/port.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2CiB;;;;;;;;EAQf,iBACE,cACA,QAAQ,QACR,SAAS;IAET;IACA,QAAQ;IAIR,SAAS;;;;;;;;;;;;;;;;;;;;;;EAuBX,gBAAgB,iBAAiB;EACjC,gBAAgB,iBAAiB;;;;;;;EAQjC,YAAY,cAAc,QAAQ,QAAQ,QAAQ;;;;;;;;;;;;;;EAelD,aAAa;;;;;;;;;;;;;EAcb,oBAAoB;;;;;;;EAQpB;;;;;;;;;;;;;;;;;;EAmBA,0BACI,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;EAwBvB,YAAY;;;;;;;;;;;;;;;;;;;EAoBZ,6BACI,mBAAmB;;;;;;;;;;;;;;EAevB,yBAAyB,OAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "../types.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./types.js";
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core-internal types. NOT part of the public `@real-router/core/types` surface
|
|
3
|
-
* (the `./index` barrel deliberately does not re-export these), so they never
|
|
4
|
-
* leak onto the subpath or the package root. Core modules import them directly
|
|
5
|
-
* from `./types/internal`.
|
|
6
|
-
*
|
|
7
|
-
* Imports pull from the sibling declaration files (not `./index`) to keep
|
|
8
|
-
* `internal.ts` off the barrel's re-export cycle (`import-x/no-cycle`).
|
|
9
|
-
* Exception: the augmentation-target interfaces (`NavigationOptions`,
|
|
10
|
-
* `StateContext`) are declared lexically IN `./index` (#1540) and can only be
|
|
11
|
-
* imported from there — acyclic here, since the barrel never re-exports
|
|
12
|
-
* `internal.ts`.
|
|
13
|
-
*/
|
|
14
|
-
import "./api.js";
|
|
15
|
-
import "./base.js";
|
|
16
|
-
import "../types.js";
|
|
17
|
-
import { LimitsConfig } from "./limits.js";
|
|
18
|
-
import "./tree-changed.js";
|
|
19
|
-
/**
|
|
20
|
-
* Immutable limits configuration type.
|
|
21
|
-
*/
|
|
22
|
-
export type Limits = Readonly<LimitsConfig>;
|
|
23
|
-
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","names":[],"sources":["../../../src/types/internal.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;YAyDY,SAAS,SAAS"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{A as e,C as t,D as n,E as r,O as i,S as a,T as o,_ as s,a as c,c as l,d as u,f as d,g as f,h as p,i as m,j as h,k as g,l as _,n as v,o as y,p as b,r as x,s as S,t as C,u as ee,v as te,w as ne,x as re,y as w}from"./internals-JRDAPvLO.mjs";import{A as ie,B as T,C as E,D as ae,E as oe,F as D,M as se,N as ce,O,P as k,R as A,S as j,T as le,V as M,_ as ue,a as de,b as N,c as fe,d as pe,f as me,g as he,h as ge,i as _e,j as ve,k as ye,l as be,m as xe,n as Se,o as P,p as Ce,r as we,s as Te,t as F,u as Ee,v as De,w as Oe,x as I,y as L,z as R}from"./helpers-LeSZEDaV.mjs";const ke=Object.entries,Ae=Object.hasOwn;function je(e,t,n){if(e===void 0||n.length===0)return e;let r,i=!1;for(let[a,o]of ke(e))Ae(t,a)&&t[a]!==void 0&&n.includes(a)?i=!0:(r??={},O(r,a,o));return r===void 0?i?void 0:e:r}function Me(e,t,n){for(let[r,a]of ke(e))i(n,r,a,t(r),"this route's `defaultParams`","Move it to `defaultSearch`")}const Ne=Object.entries,Pe=Object.freeze;function Fe(e,t,n){let r,i=!1;for(let[a,o]of Ne(e))t.includes(a)?(r??={},O(r,a,o)):(i=!0,n?.(a));return i?Pe(r??D):e}function Ie(e,t){let n=e.path,r=n.startsWith(`~`),i=r?n.slice(1):n,a=i!==``&&!i.startsWith(`/`)&&!i.startsWith(`?`)?`/${i}`:i,o={name:e.name,path:a,absolute:r,children:[],parent:t};if(e.children)for(let t of e.children){let e=Ie(t,o);o.children.push(e)}return o}function Le(e,t,n){let r=Ie({name:e,path:t},null);for(let e of n){let t=Ie(e,r);r.children.push(t)}return r}const Re=/[^\w!$'()*+,.:;|~-]/gu,ze=/[^\w!$'()*+,.:;|~-]/u,Be=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,Ve=e=>t=>{try{return e(t)}catch{return e(t.replaceAll(Be,`�`))}},He=Ve(e=>e.replaceAll(Re,e=>encodeURIComponent(e))),Ue={default:e=>ze.test(e)?He(e):e,uri:Ve(encodeURI),uriComponent:Ve(encodeURIComponent),none:e=>e},We={default:decodeURIComponent,uri:decodeURI,uriComponent:decodeURIComponent,none:e=>e},Ge={default:`%2F`,uri:`/`,uriComponent:`%2F`,none:`/`},Ke=(e,t)=>{let n=Ue[t],r=Ge[t],i=String(e).split(`/`),a=n(i[0]);for(let e=1;e<i.length;e++)a+=(i[e-1]===``?r:`/`)+n(i[e]);return a},qe=Object.freeze(Object.create(null));function Je(){return{staticChildren:qe,hasChildren:!1,paramChild:void 0,splatChild:void 0,route:void 0,slashChildRoute:void 0}}function z(e){return e.length>1&&e.endsWith(`/`)?e.slice(0,-1):e}function Ye(e,t){return e===``?t:t===``?e:e.endsWith(`/`)&&t.startsWith(`/`)?e+t.slice(1):e+t}function Xe(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Ze(e){let t=0;for(;t<e.length;)if(e.codePointAt(t)===37){if(t+2>=e.length)return!1;let n=e.codePointAt(t+1)??0,r=e.codePointAt(t+2)??0;if(!Xe(n)||!Xe(r))return!1;t+=3}else t++;return!0}const Qe=Object.freeze([]),$e=Object.freeze(new Set),et=Object.freeze([]),tt=Object.freeze({}),nt=Object.freeze({}),rt=Object.freeze({});function it(e,t){let n=e.kind===`splat`;return{paramName:e.name,encoder:n?e=>Ke(e,t):Ue[t]}}function at(e,t,i,a){let o=new Set(a);for(let e of t)for(let t of e.paramMeta.urlParams)o.add(t);if(o.size===0)return{buildStaticParts:[e],buildParamSlots:et};let s=[],c=[],l=``,u=n(e),d=u.length-1;for(let[e,t]of u.entries()){let n=r(t);(`error`in n||n.kind!==`splat`||e===d)&&(e>0&&(l+=`/`),`error`in n||n.kind===`static`?l+=t:(s.push(l),l=``,c.push(it(n,i))))}return s.push(l),{buildStaticParts:s,buildParamSlots:c}}const B=E(`router`);function ot(e,t,n){throw B.plain`Parameter name conflict at the same path position: '${n}${e}' and '${n}${t}'. One position binds one name across every route that shares it. Rename one — e.g. use '${n}${e}' in both.`}function st(){throw B.plain`Empty parameter name: a ':'/'*' marker must be followed by a name (e.g. ':id', '*rest'), and a segment cannot end in a bare '?'.`}function ct(e){throw B.plain`Fused parameter marker in segment "${e}": a ':'/'*' marker must begin a segment — write 'a/:b', not 'a:b'.`}function lt(e){throw B.plain`Trailing parameter marker in segment "${e}": a param name cannot end in a bare ':' or '*'. Drop the stray marker.`}function ut(e){throw B.plain`Optional params are not supported: "${e}" — declare two sibling routes instead, one with the segment and one without.`}function dt(e){throw B.plain`Regex constraints are not supported: '<' and '>' are reserved in path segments ("${e}"). Match it as a plain string and validate the value in a canActivate guard.`}function ft(e){throw B.plain`Non-ASCII static segment "${e}": match compares static keys raw and rejects non-ASCII input, so this route can never match. Percent-encode it (e.g. "/caf%C3%A9") or use a param.`}function pt(e,t){switch(e){case`name-less`:return st();case`trailing-marker`:return lt(t);case`fused-marker`:return ct(t);case`optional-removed`:return ut(t);case`constraint-removed`:return dt(t)}}function mt(e,t){let n=new Set,r=``;for(let e of t){if(n.has(e)){r=e;break}n.add(e)}throw B.plain`Duplicate parameter name '${r}' in route "${e}": a name must be unique within a route — the second position overwrites the first. Rename one.`}function ht(e,t){throw B.plain`Invalid query-param declaration "${t}" in route "${e}": a query-param name cannot contain '<' or '>'. Rename it.`}function gt(e){throw B.plain`Double slashes are not allowed in path "${e}": the route would build a URL its own matcher refuses. Remove the empty segment.`}function _t(e,t){throw B.plain`Duplicate route path: routes "${e}" and "${t}" resolve to the same URL — the later would shadow the earlier. Give them distinct paths.`}function vt(e,t){throw B.plain`Index route "${e}" (path "/") under the splat parent "${t}" is unreachable: the wildcard match never reaches the index node. Give the index a distinct path, or make the parent static.`}function yt(e,t){return e.paramChild?e.paramChild.name!==t&&ot(e.paramChild.name,t,`:`):e.paramChild={node:Je(),name:t},e.paramChild.node}function bt(e,t){return e.splatChild?e.splatChild.name!==t&&ot(e.splatChild.name,t,`*`):e.splatChild={node:Je(),name:t},e.splatChild.node}const xt=Object.create;function St(e,t){e.route!==void 0&&e.route!==t&&_t(e.route.name,t.name),e.route=t}function Ct(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>=128)return!0;return!1}function wt(e,t,n){let r=z(n);r===`/`?St(e.root,t):Tt(e,e.root,r,1,t)}function Tt(e,t,n,r,i){let a=n.length;for(;r<=a;){let i=n.indexOf(`/`,r),o=i===-1?a:i,s=n.slice(r,o);t=kt(e,t,s),r=o+1}St(t,i)}function Et(e,t,n){let r=n.length;for(;r>1&&n.codePointAt(r-1)===47;)--r;let i=n.slice(0,r);i.slice(i.lastIndexOf(`/`)+1).startsWith(`*`)&&vt(t.name,n);let a=Dt(e,n);a.slashChildRoute=t}function Dt(e,t){return Ot(e,e.root,t)}function Ot(e,t,n){let r=z(n);if(r===`/`||r===``)return t;let i=t,a=1,o=r.length;for(;a<=o;){let t=r.indexOf(`/`,a),n=t===-1?o:t;if(n<=a)break;let s=r.slice(a,n);i=kt(e,i,s),a=n+1}return i}function kt(e,t,n){let i=r(n);if(`error`in i&&st(),i.kind===`splat`){let e=bt(t,i.name);return t.hasChildren=!0,e}if(i.kind===`param`){let e=yt(t,i.name);return t.hasChildren=!0,e}Ct(n)&&ft(n);let a=e.options.caseSensitive?n:n.toLowerCase();return a in t.staticChildren||(t.staticChildren===qe&&(t.staticChildren=xt(null)),t.staticChildren[a]=Je(),t.hasChildren=!0),t.staticChildren[a]}const At=Object.freeze,jt=Object.hasOwn;function Mt(e){let t=n(e);for(let[n,r]of t.entries())r===``&&n>0&&n<t.length-1&>(e)}function Nt(e){for(let t of n(e)){let e=r(t);`error`in e&&pt(e.error,t)}}function Pt(e,n,r,i,a){let o=n.fullName===``;o||i.push(n);let s=n.absolute,c=n.paramMeta===t?n.path:n.paramMeta.pathPattern,l=s&&c.startsWith(`~`)?c.slice(1):c,u=s?l:c;Mt(n.path),Nt(u);let d=u,f=s?d:Ye(r,d),p=o?a:Ft(e,n,f,s?``:r,i,a);for(let t of n.children.values())Pt(e,t,f,i,p);o||i.pop()}function Ft(e,t,n,r,i,a){let o=Bt(n,r),s=At([...i]),c=It(s),l=z(n),u=At(Vt(e.rootQueryParams,i)),{buildStaticParts:d,buildParamSlots:f}=at(o?z(r):l,o?i.slice(0,-1):i,e.options.urlParamsEncoding,e.rootUrlParams),p=f.map(e=>e.paramName),m=p.length===0?$e:new Set(p);m.size!==p.length&&mt(t.fullName,p),Ht(t.fullName,u);let h={name:t.fullName,parent:a,matchSegments:s,meta:c,declaredQueryParams:u,declaredQueryParamsSet:u.length===0?$e:new Set(u),hasTrailingSlash:n.length>1&&n.endsWith(`/`),buildStaticParts:d,buildParamSlots:f,buildParamNamesSet:m,cachedResult:void 0};return t.paramMeta.urlParams.length===0&&(h.cachedResult=At({segments:h.matchSegments,params:tt,search:nt,meta:h.meta})),e.routesByName.set(t.fullName,h),o?Rt(e,h,r):zt(e,h,n,l,t),h}function It(e){let t;for(let n of e)Lt(n.paramTypeMap)&&(t??=oe(),t[n.fullName]=n.paramTypeMap);return t===void 0?rt:At(Oe(ae(t)))}function Lt(e){for(let t in e)if(jt(e,t))return!0;return!1}function Rt(e,t,n){Et(e,t,n);let r=z(n),i=e.options.caseSensitive?r:r.toLowerCase();e.staticCache.has(i)&&e.staticCache.set(i,t)}function zt(e,t,n,r,i){if(wt(e,t,n),i.paramMeta.urlParams.length===0){let n=e.options.caseSensitive?r:r.toLowerCase();e.staticCache.set(n,t)}}function Bt(e,t){return z(e)===z(t)}function Vt(e,t){let n=[];e.length>0&&n.push(...e);for(let e of t)e.paramMeta.queryParams.length>0&&n.push(...e.paramMeta.queryParams);return n.length===0?Qe:n}function Ht(e,t){for(let n of t)ne.test(n)&&ht(e,n)}const Ut=E(`router`,`buildPath`),Wt=Symbol.for(`real-router.searchParams.configFault`),Gt=Object.hasOwn,Kt=Object.keys,qt=Object.getOwnPropertyDescriptor;function Jt(e){try{return qt(e,Wt)?.configurable===!1}catch{return!1}}function Yt(e){return typeof e==`string`?e:typeof e==`object`?JSON.stringify(e):String(e)}const Xt=Object.freeze({});function Zt(e,t){return e===`strict`?t?`always`:`never`:e}var Qt=class{get options(){return this.#e}#e;#t=Je();#n=new Map;#r=new Map;#i={cleanPath:``,normalized:``,queryString:void 0};#a=[];#o=``;#s;#c;constructor(e){let t=e.urlParamsEncoding??`default`,n=typeof t==`string`?t:String(t),r=Gt(Ue,n)?n:`default`;this.#e={caseSensitive:e.caseSensitive??!0,strictTrailingSlash:e.strictTrailingSlash??!1,strictQueryParams:e.strictQueryParams??!1,urlParamsEncoding:r,parseQueryString:e.parseQueryString,buildQueryString:e.buildQueryString},this.#s=this.#e.caseSensitive,this.#c=this.#e.urlParamsEncoding===`none`?null:We[this.#e.urlParamsEncoding]}registerTree(e){this.#a=e.paramMeta.queryParams,Pt({root:this.#t,options:this.#e,routesByName:this.#n,staticCache:this.#r,rootQueryParams:this.#a,rootUrlParams:e.paramMeta.urlParams},e,``,[],null)}match(e){if(!this.#f(e))return;let{cleanPath:t,normalized:n,queryString:r}=this.#i,i=this.#s?n:n.toLowerCase(),a=this.#r.get(i);if(a)return this.#e.strictTrailingSlash&&!this.#g(t,a)?void 0:r===void 0&&a.cachedResult?a.cachedResult:this.#m(a,{},r);let o={},s=this.#_(n,o);if(s&&(!this.#e.strictTrailingSlash||this.#g(t,s))&&this.#b(o))return this.#m(s,o,r)}buildPath(e,t,n,r){let i=this.#n.get(e);if(!i)throw Ut.plain`'${e}' is not defined`;let a=this.#l(i,t),o=this.#u(a,Zt(r?.trailingSlash,i.hasTrailingSlash)),s=this.#d(i,n??t,r?.queryParamsMode);return o+(s?`?${s}`:``)}getSegmentsByName(e){return this.#n.get(e)?.matchSegments}getMetaByName(e){return this.#n.get(e)?.meta}getDeclaredQueryParams(e){return this.#n.get(e)?.declaredQueryParams}hasRoute(e){return this.#n.has(e)}#l(e,t){let n=e.buildStaticParts,r=e.buildParamSlots;if(r.length===0)return n[0];let i=n[0];for(let[e,a]of r.entries()){let r=t!=null&&Gt(t,a.paramName)?t[a.paramName]:void 0;if(r==null)throw Ut.plain`Missing required param '${a.paramName}'`;if(r===``)throw Ut.plain`Missing required param '${a.paramName}' (empty string)`;let o=a.encoder(Yt(r));i+=o+n[e+1]}return i}#u(e,t){return t===`always`&&!e.endsWith(`/`)?`${e}/`:t===`never`&&e!==`/`&&e.endsWith(`/`)?e.slice(0,-1):e}#d(e,t,n){if(!t||e.declaredQueryParams.length===0&&n!==`loose`)return``;let r={},i=!1;for(let n of e.declaredQueryParams)Gt(t,n)&&(O(r,n,t[n]),i=!0);if(n===`loose`)for(let n of Kt(t))e.declaredQueryParamsSet.has(n)||e.buildParamNamesSet.has(n)||(O(r,n,t[n]),i=!0);return i?this.#e.buildQueryString(r):``}#f(e){if(e===``&&(e=`/`),e.codePointAt(0)!==47)return!1;let t=this.#p(e);if(t===-2)return!1;t===-3&&(e=this.#o);let n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1):void 0;if(r!==void 0){let e=r.indexOf(`#`);e!==-1&&(r=r.slice(0,e))}let i=z(n);return this.#i.cleanPath=n,this.#i.normalized=i,this.#i.queryString=r,!0}#p(e){let t=!1;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);if(r===35)return this.#o=e.slice(0,n),-3;if(r===63)return n;if(r>=128)return-2;if(r===47){if(t)return-2;t=!0}else t=!1}return-1}#m(e,t,n){let r=Xt;if(n!==void 0){let t=this.#h(e,n);if(t===void 0)return;r=t}return{segments:e.matchSegments,params:t,search:r,meta:e.meta}}#h(e,t){let n;try{n=this.#e.parseQueryString(t)}catch(e){if(Jt(e))throw e;return}if(this.#e.strictQueryParams){let t=e.declaredQueryParamsSet;for(let e of Kt(n))if(!t.has(e))return}return n}#g(e,t){return(e.length>1&&e.endsWith(`/`))===t.hasTrailingSlash}#_(e,t){return e.length===1?this.#t.slashChildRoute??this.#t.route:this.#v(this.#t,e,1,t)}#v(e,t,n,r){let i=e,a=t.length,o=this.#s;for(;n<=a;){let e=t.indexOf(`/`,n),s=e===-1?a:e,c=t.slice(n,s),l=o?c:c.toLowerCase(),u;if(l in i.staticChildren){let e=i.staticChildren[l];if(i.splatChild!==void 0){let a={},o=this.#v(e,t,s+1,a);return o===void 0?this.#y(i.splatChild,t,n,r):(le(r,a),o)}u=e}else if(i.paramChild){let e=i.paramChild;if(i.splatChild!==void 0){let a={[e.name]:c},o=this.#v(e.node,t,s+1,a);return o===void 0?this.#y(i.splatChild,t,n,r):(le(r,a),o)}u=e.node,O(r,e.name,c)}else if(i.splatChild)return this.#y(i.splatChild,t,n,r);else return;i=u,n=s+1}return i.slashChildRoute??i.route}#y(e,t,n,r){let i=e.node;if(!i.hasChildren)return O(r,e.name,t.slice(n)),i.route;let a={},o=this.#v(i,t,n,a);return o?(le(r,a),o):(O(r,e.name,t.slice(n)),i.route)}#b(e){let t=this.#c;if(!t)return!0;for(let n of Kt(e)){let r=e[n];if(r.includes(`%`)){if(!Ze(r))return!1;try{e[n]=t(r)}catch{return!1}}}return!0}};const V=Object.freeze,$t=Object.freeze(new Map),en=Object.freeze([]);function tn(e){return e.parent?.name?`${e.parent.fullName}.${e.name}`:e.name}function nn(e){let t=new Map;for(let n of e)t.set(n.name,n);return t}function rn(e,t){let n=[],r=[];for(let i of e){let e=an(i,t);n.push(e),e.absolute||r.push(e)}return{childrenMap:nn(n),nonAbsoluteChildren:r}}function an(e,n){let r=o(e.path),i=r.urlParams.length===0&&r.queryParams.length===0&&r.pathPattern===e.path?t:r,a=i.paramTypeMap,s={name:e.name,path:e.path,absolute:e.absolute,parent:n,children:void 0,paramMeta:i,nonAbsoluteChildren:void 0,fullName:``,paramTypeMap:a};if(s.fullName=tn(s),e.children.length===0)s.children=$t,s.nonAbsoluteChildren=en;else{let{childrenMap:t,nonAbsoluteChildren:n}=rn(e.children,s);s.children=t,s.nonAbsoluteChildren=n,V(s.nonAbsoluteChildren),V(s.children)}return V(a),V(i.urlParams),V(i.queryParams),V(i),V(s),s}function on(e){return an(e,null)}function sn(e,t,n){return on(Le(e,t,n))}function cn(e){let t=e.absolute?`~${e.path}`:e.path,n={name:e.name,path:t};return e.children.size>0&&O(n,`children`,Array.from(e.children.values(),cn)),n}function ln(e){return Array.from(e.children.values(),cn)}function un(e){let t=e?.queryParams,n=a(t);return new Qt({...e?.caseSensitive!==void 0&&{caseSensitive:e.caseSensitive},...e?.strictTrailingSlash!==void 0&&{strictTrailingSlash:e.strictTrailingSlash},...e?.strictQueryParams!==void 0&&{strictQueryParams:e.strictQueryParams},...e?.urlParamsEncoding!==void 0&&{urlParamsEncoding:e.urlParamsEncoding},parseQueryString:e=>w(e,n),buildQueryString:e=>te(e,n)})}const dn=E(`router`,`addEventListener`),fn=E(`router`,`subscribeChanges`),pn=E(`router`,`addInterceptor`),mn=E(`router`,`addCheck`),hn=E(`router`,`extendRouter`),H=E(`router`),gn=Object.keys,_n=Object.values,vn=Object.hasOwn,yn=Object.getOwnPropertyDescriptor,bn=Object.getPrototypeOf,xn=Object,Sn=new Set(_n(T));function Cn(e){if(!Sn.has(e))throw dn.type`Invalid event name: ${String(e)}. Must be one of: ${[...Sn].join(`, `)}`}function wn(e){if(typeof e!=`function`)throw dn.type`callback must be a function, got ${typeof e}`}function Tn(e){if(typeof e!=`function`)throw fn.type`Expected a function`}function En(e,t){if(typeof e!=`string`||!vn(x,e))throw pn.type`Invalid method: ${typeof e==`string`?`"${e}"`:typeof e}. Must be one of: ${gn(x).join(`, `)}`;if(typeof t!=`function`)throw pn.type`interceptor must be a function, got ${typeof t}`}function Dn(e,t){if(typeof e!=`string`||!vn(v,e))throw mn.type`Invalid position: ${typeof e==`string`?`"${e}"`:typeof e}. Must be one of: ${gn(v).join(`, `)}`;if(typeof t!=`function`)throw mn.type`check must be a function, got ${typeof t}`}function On(e,t){if(typeof e!=`string`)throw E(`router`,t).type`Route name must be a string, got ${typeof e}`}function kn(e,t){if(e===``)throw E(`router`,t).type`A guard on the root node "" never runs: no navigation activates or deactivates the root`}function An(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=bn(e);return t===null||t.constructor===xn}function jn(e){if(!An(e))throw H.type`dependencies must be a plain object`}function Mn(e){return e===null?`null`:typeof e==`object`?`a non-plain object`:typeof e}function Nn(e){if(!An(e))throw hn.type`extensions must be a plain object, got ${Mn(e)}`}function Pn(e,t){jn(e);let n=e,r=[];for(let e of gn(n)){if(yn(n,e)?.get)throw H.type`dependencies cannot contain getters: "${e}"`;let t=n[e];t!==void 0&&r.push([e,t])}for(let[e,n]of r)t(e,n)}function Fn(e){let t=[];for(let n of e){let e=n;if(typeof e!=`object`||!e||Array.isArray(e))throw H.type`route must be a non-array object`;p(e,`addRoute`);let r={...e},i=r.children;i&&O(r,`children`,Fn(i)),t.push(r)}return t}const In=new Set([`all`,`warn-error`,`error-only`,`none`]);function Ln(e){return typeof e==`string`&&In.has(e)}function Rn(e){return typeof e==`string`?`"${e}"`:typeof e==`object`?JSON.stringify(e):String(e)}function zn(e){for(let t of gn(e))if(t!==`level`&&t!==`callback`&&t!==`callbackIgnoresLevel`)throw H.type`Unknown logger config property: "${t}"`}function Bn(e){if(!vn(e,`level`))return;let t=e.level;if(t!==void 0){if(!Ln(t))throw H.type`Invalid logger level: ${Rn(t)}. Expected: "all" | "warn-error" | "error-only" | "none"`;return t}}function Vn(e){if(!vn(e,`callbackIgnoresLevel`))return;let t=e.callbackIgnoresLevel;if(t!==void 0){if(typeof t!=`boolean`)throw H.type`Logger callbackIgnoresLevel must be a boolean, got ${typeof t}`;return t}}function Hn(e){if(typeof e!=`object`||!e)throw H.type`Logger config must be an object`;let t=e;zn(t);let n=oe(),r=Bn(t);if(r!==void 0&&(n.level=r),vn(t,`callback`)){let e=t.callback;if(e!==void 0&&typeof e!=`function`)throw H.type`Logger callback must be a function, got ${typeof e}`;n.callback=e}let i=Vn(t);return i!==void 0&&(n.callbackIgnoresLevel=i),n}const Un=Object.create,Wn=Object.freeze,Gn=Object.defineProperty;function Kn(e,t,n){e[t]=n}function qn(e,t){return e.dependencies[t]}function Jn(e){e.dependencies=Un(null)}function Yn(e){return Te({...e.dependencies})}function Xn(e,t,n){let r=Un(null),i=e,a=r;Pn(i,(e,t)=>{Kn(a,e,t)});let o={dependencies:r,limits:t,diagnostics:Wn(n)};return Gn(o,`diagnostics`,{writable:!1,configurable:!1}),o}const Zn={defaultRoute:``,defaultParams:{},defaultSearch:{},trailingSlash:`preserve`,caseSensitive:!0,queryParamsMode:`loose`,queryParams:re,urlParamsEncoding:`default`,allowNotFound:!0,rewritePathOnMatch:!0},Qn=[`strict`,`never`,`always`,`preserve`],$n=[`default`,`strict`,`loose`];function er(e){return e!==void 0&&Qn.includes(e)?e:Zn.trailingSlash}function tr(e){return e!==void 0&&$n.includes(e)?e:Zn.queryParamsMode}const nr=E(`router`);function rr(e){if(!e||typeof e!=`object`||Array.isArray(e))throw nr.type`options must be a plain object`}const ir=Object.freeze;var ar=class{#e;constructor(e={}){this.#e=ir(Te({...Zn,...e}))}static validateOptionsIsObject(e){rr(e)}get(){return this.#e}};function or(e,t){return typeof e==`function`?e(t):e}const sr=Object.keys;function cr(e,t,n,r,i){let a=e.pathNames(t);if(a!==void 0)for(let e of sr(n))!r.includes(e)&&!a.includes(e)&&i(t,e)}function U(e,t,n,r,i){let a=String(t),o=i?.resolveForward===!1?{name:a,params:n,search:r}:e.resolveForward(a,n,r),s=o.name,c=Ce(o.params,k),l=i?.diagnoseUndeclared===!0?e.reportUndeclaredParamKey:void 0;l&&cr(e,s,c,e.queryNames(s),l);let u=e.defaultParams(s),d=e.defaultSearch(s);if((o.search===void 0||o.search===D)&&u===void 0&&d===void 0)return{name:s,path:c,query:D};let f=e.queryNames(s),p=e.reportDroppedQueryKey,m=i?.resolveForward===!1?je(d,c,f):d,h=Ce(o.search,D),g=me(m,h);return{name:s,path:pe(u,c),query:e.admitsUndeclaredQuery()?g:Fe(g,e.printedQueryNames(s),t=>{p!==void 0&&e.pathNames(s)!==void 0&&p(s,t)})}}function lr(e,t){return t.buildPath(e.name,e.path,e.query)}const ur=Object.freeze;function dr(e,t){let n={name:e.name,params:e.path,search:e.query,path:t,context:{},transition:se};return ur(n.params),n}function fr(e,t){return fe(dr(e,t))}function pr(e,t){return dr(e,t)}var mr=class{#e;#t;get(){return this.#e.current}getPrevious(){return this.#e.previous}setContext(e){this.#e=e}setDependencies(e){this.#t=e}makeState(e,t,n,r){let i=this.#t.port(),a=U(i,e,t??k,n,{resolveForward:!1});return g(`makeState`,a.name,a.path,i.queryNames(a.name)),fr(a,r??lr(a,i))}areStatesEqual(e,t,n=!0){if(!e||!t)return!!e==!!t;let r=e.name;return r===t.name?n?De(e.params,t.params,this.#t.getUrlParams(r)):ue(e.params,t.params)&&ue(e.search,t.search):!1}};const hr=Object.keys,gr={[M.ROUTER_START]:T.ROUTER_START,[M.ROUTER_STOP]:T.ROUTER_STOP,[M.TRANSITION_SUCCESS]:T.TRANSITION_SUCCESS,[M.TRANSITION_START]:T.TRANSITION_START,[M.TRANSITION_LEAVE_APPROVE]:T.TRANSITION_LEAVE_APPROVE,[M.TRANSITION_ERROR]:T.TRANSITION_ERROR,[M.TRANSITION_CANCEL]:T.TRANSITION_CANCEL},_r=hr(gr),vr=E(`router`,`usePlugin`);function yr(e){if(e)throw vr.code(R.ROUTER_DISPOSED)`cannot install a plugin on a disposed router — dispose() is terminal`}function br(e){if(!(e&&typeof e==`object`)||Array.isArray(e))throw vr.type`Plugin factory must return an object, got ${typeof e}`;if(typeof e.then==`function`)throw vr.type`Async plugin factories are not supported. Factory returned a Promise instead of a plugin object.`}const xr=Object.freeze;function Sr(e,t){try{d(e(),t)}catch(e){t(e)}}var Cr=class e{#e=new Set;#t=new Set;#n;static validatePlugin(e){br(e)}static validateNotDisposed(e){yr(e)}setDependencies(e){this.#n=e}count(){return this.#e.size}use(...e){if(this.#n.emitDiagnostic(C.USE_PLUGIN_COUNT,this.#e.size+e.length),e.length===1){let t=e[0],n=this.#o(t);this.#e.add(t);let r=!1,i=()=>{r||(r=!0,this.#e.delete(t),this.#t.delete(i),Sr(n,this.#r))};return this.#t.add(i),i}let t=this.#a(e),n=[];try{for(let e of t){let t=this.#o(e);n.push({factory:e,cleanup:t})}}catch(e){for(let{cleanup:e}of n)Sr(e,this.#i);throw e}for(let{factory:e}of n)this.#e.add(e);let r=!1,i=()=>{if(!r){r=!0,this.#t.delete(i);for(let{factory:e}of n)this.#e.delete(e);for(let{cleanup:e}of n)Sr(e,this.#r)}};return this.#t.add(i),i}getAll(){return[...this.#e]}disposeAll(){for(let e of this.#t)e();this.#e.clear(),this.#t.clear()}#r=e=>{this.#n.logger.error(`router`,`Error during cleanup:`,e)};#i=e=>{this.#n.logger.error(`router.usePlugin`,`Cleanup error:`,e)};#a(e){let t=new Set;for(let n of e)t.has(n)?this.#n.emitDiagnostic(C.USE_PLUGIN_DUPLICATE_IN_BATCH):t.add(n);return t}#o(t){e.validateNotDisposed(this.#n.isDisposed());let n=this.#n.compileFactory(t);e.validatePlugin(n),this.#n.runChecks(v[`usePlugin:plugin`],n),xr(n);let r=[];for(let e of _r)e in n&&(typeof n[e]==`function`?(r.push(this.#n.addEventListener(gr[e],n[e])),e===`onStart`&&this.#n.canNavigate()&&this.#n.emitDiagnostic(C.PLUGIN_AFTER_START,e)):this.#n.emitDiagnostic(C.USE_PLUGIN_HOOK_NOT_FUNCTION,e));let i=()=>{for(let e of r)e();if(typeof n.teardown==`function`)return n.teardown()};return this.#n.isDisposed()&&Sr(i,this.#i),e.validateNotDisposed(this.#n.isDisposed()),i}};const W=Object.create,wr=()=>!0,Tr=()=>!1,Er=()=>wr,Dr=()=>Tr;function Or(e){return e?Er:Dr}const kr={activate:{count:v[`canActivate:count`],counted:C.CAN_ACTIVATE_COUNT,overwritten:C.CAN_ACTIVATE_OVERWRITE},deactivate:{count:v[`canDeactivate:count`],counted:C.CAN_DEACTIVATE_COUNT,overwritten:C.CAN_DEACTIVATE_OVERWRITE}};function Ar(e,t,n){n===void 0?e.delete(t):e.set(t,n)}var jr=class{#e=new Map;#t=new Map;#n=new Map;#r=new Map;#i=new Map;#a=new Map;#o=new Map;#s=new Map;#c=new Map;#l=new Map;#u=[this.#i,this.#a];#d;setDependencies(e){this.#d=e}getHandlerCount(e){let t=e===`activate`?this.#e:this.#n,n=e===`activate`?this.#t:this.#r;if(t.size===0)return n.size;if(n.size===0)return t.size;let r=new Set(t.keys());for(let e of n.keys())r.add(e);return r.size}preflightHandlerLimit(e,t,n){this.#f(`activate`,e,n),this.#f(`deactivate`,t,n)}addCanActivate(e,t,n,r){this.#p(`activate`,e,t,n,`canActivate`,r)}addCanDeactivate(e,t,n,r){this.#p(`deactivate`,e,t,n,`canDeactivate`,r)}clearCanActivate(e,t){this.#m(`activate`,e,t)}clearCanDeactivate(e,t){this.#m(`deactivate`,e,t)}clearAll(){this.#e.clear(),this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#a.clear(),this.#i.clear(),this.#o.clear(),this.#s.clear(),this.#c.clear(),this.#l.clear()}clearDefinitionGuards(){for(let e of this.#e.keys())this.#c.delete(e),this.#t.has(e)?this.#h(`activate`,e):this.#a.delete(e);for(let e of this.#n.keys())this.#o.delete(e),this.#r.has(e)?this.#h(`deactivate`,e):this.#i.delete(e);this.#e.clear(),this.#n.clear()}getFactories(){let e=W(null),t=W(null);for(let[t,n]of this.#n)e[t]=n;for(let[t,n]of this.#r)e[t]=n;for(let[e,n]of this.#e)t[e]=n;for(let[e,n]of this.#t)t[e]=n;return[e,t]}getFactoriesByOrigin(){let e=W(null),t=W(null),n=W(null),r=W(null);for(let[t,n]of this.#n)e[t]=n;for(let[e,n]of this.#e)t[e]=n;for(let[e,t]of this.#r)n[e]=t;for(let[e,t]of this.#t)r[e]=t;return{definition:[e,t],external:[n,r]}}getFunctions(){return this.#u}canNavigateTo(e,t,n,r,i){for(let t of e)if(!this.#v(this.#i,t,n,r,i))return!1;for(let e of t)if(!this.#v(this.#a,e,n,r,i))return!1;return!0}compileGuardFactory(e,t){let n=typeof e==`boolean`?Or(e):e,r=this.#d.compileFactory(n);if(typeof r!=`function`)throw E(`router`,t).type`Factory must return a function, got ${typeof r}`;return r}#f(e,t,n){let r=kr[e].count;if(!this.#d.hasChecks(r))return;let{definition:i,external:a}=this.#_(e),o=0;for(let e of t)(n?a.has(e):i.has(e)||a.has(e))||o++;if(o===0)return;let s=n?a.size:this.getHandlerCount(e);this.#d.runChecks(r,s+o-1)}#p(e,t,n,r,i,a){let o=this.#_(e),s=e===`activate`?this.#a:this.#i,c=r?o.definition:o.external,l=r?o.external:o.definition,u=kr[e];if(c.has(t)||l.has(t))this.#d.emitDiagnostic(u.overwritten,t);else if(this.#d.hasChecks(u.count)||this.#d.diagnosticListenerCount(u.counted)>0){let t=this.getHandlerCount(e);this.#d.runChecks(u.count,t),this.#d.emitDiagnostic(u.counted,t+1)}let d=typeof n==`boolean`?Or(n):n,f=c.get(t),p=this.#g(e),m=r?p.definition:p.external,h=m.get(t);c.set(t,d);let g=r&&l.has(t);try{let e=a??this.compileGuardFactory(d,i);m.set(t,e),g||s.set(t,e)}catch(n){throw Ar(c,t,f),Ar(m,t,h),this.#h(e,t),n}}#m(e,t,n){let{definition:r,external:i}=this.#_(e),a=this.#g(e),o=n!==`external`&&r.delete(t),s=n!==`definition`&&i.delete(t);o&&a.definition.delete(t),s&&a.external.delete(t),(o||s)&&this.#h(e,t)}#h(e,t){let n=this.#g(e),r=e===`activate`?this.#a:this.#i,i=n.external.get(t)??n.definition.get(t);i?r.set(t,i):r.delete(t)}#g(e){return e===`activate`?{definition:this.#c,external:this.#l}:{definition:this.#o,external:this.#s}}#_(e){return e===`activate`?{definition:this.#e,external:this.#t}:{definition:this.#n,external:this.#r}}#v(e,t,n,r,i){let a=e.get(t);if(!a)return!0;try{let e=a(n,r);return typeof e==`boolean`?e:(typeof e?.then==`function`?(Promise.resolve(e).catch(()=>void 0),this.#d.emitDiagnostic(C.SYNC_GUARD_THENABLE,t,i)):this.#d.emitDiagnostic(C.SYNC_GUARD_NON_BOOLEAN,t,e,i),!1)}catch(e){return this.#d.logger.warn(`router.${i}`,`Guard for "${t}" threw — treated as navigation-blocking (returned false)`,e),!1}}};const Mr=new Set([`name`,`path`,`children`,`canActivate`,`canDeactivate`,`forwardTo`,`encodeParams`,`decodeParams`,`defaultParams`,`defaultSearch`]),Nr=Object.freeze,G=Object.create,Pr=Object.hasOwn,Fr=Object.keys;function Ir(){return{decoders:G(null),encoders:G(null),defaultParams:G(null),defaultSearch:G(null),forwardMap:G(null),forwardFnMap:G(null)}}function Lr(e){return Fr(e.forwardMap).length>0||Fr(e.forwardFnMap).length>0}function Rr(e,t){for(let n of Fr(t))Object.assign(e[n],t[n])}function zr(e,t){for(let n in e)if(Pr(t,n)&&!de(e[n],t[n]))return!1;return!0}function Br(e){return typeof e==`string`?e:`<non-string>`}function Vr(e,t){for(let n in e)if(!de(e[n],t[n]))return!1;return!0}function Hr(e){let t={name:e.name,path:e.path};return e.children&&O(t,`children`,e.children.map(e=>Hr(e))),t}function Ur(e,t,n){if(n.add(t),e.children)for(let r of e.children)Ur(r,`${t}.${r.name}`,n)}function Wr(e,t,n=``){for(let r=0;r<e.length;r++){let i=e[r],a=n?`${n}.${i.name}`:i.name;if(a===t){e.splice(r,1);let t=new Set;return Ur(i,a,t),t}if(i.children&&t.startsWith(`${a}.`)){let e=Wr(i.children,t,a);if(e)return e}}}function Gr(e,t){for(let n of Fr(e))t(n)&&delete e[n]}function Kr(e,t){let n=t.search(/[?#]/),r=n===-1?t:t.slice(0,n);if(r===`/`||r.endsWith(`/`))return t;let i=e.search(/[?#]/),a=i===-1?e:e.slice(0,i);return a.length>1&&a.endsWith(`/`)?`${r}/${n===-1?``:t.slice(n)}`:t}function qr(e){let t=[];for(let n of e)for(let e of n.paramMeta.urlParams)t.push(e);return t}const Jr=Nr([]);function Yr(e,t,n){let r=n.get(t);if(r!==void 0)return r;let i=e.getSegmentsByName(t);if(!i)return Jr;let a=Nr(qr(i));return n.set(t,a),a}function Xr(e,t){return Yr(e.matcher,t,e.urlParamsCache)}const Zr=Nr([]);function Qr(e,t,n,r){let i=r.get(t);if(i!==void 0)return i;let a=e.getDeclaredQueryParams(t);if(!a)return Zr;let o=Yr(e,t,n),s=Nr(a.filter(e=>!o.includes(e)));return r.set(t,s),s}function $r(e,t){return e.getDeclaredQueryParams(t)??Zr}function ei(e,t){return Qr(e.matcher,t,e.urlParamsCache,e.queryParamsCache)}function ti(e,t,n){let r=new Map,i=new Map;Me(t.defaultParams,t=>Qr(e,t,r,i),n)}const ni=E(`router`);function ri(e,t,n=100){let r=String(e),i=new Set,a=[r],o=r;for(;;){let e=t[o];if(!e)break;let r=String(e);if(i.has(r)){let e=a.indexOf(r),t=[...a.slice(e),r];throw ni.plain`Circular forwardTo: ${t.join(` → `)}`}if(i.add(o),a.push(r),o=r,a.length>n)throw ni.plain`forwardTo chain exceeds maximum depth (${n}): ${a.join(` → `)}`}return o}const ii=E(`router`),ai=E(`router`,`addRoute`),oi=Object.freeze,K=Object.create,si=Object.entries,ci=Object.keys,li=Object.defineProperty,ui=Object.fromEntries;function di(e,t,n){let r=sn(``,t,e),i=un(n);return i.registerTree(r),{tree:r,matcher:i}}function fi(e,t=e.definitions){let n=di(t,e.rootPath,e.matcherOptions);e.tree=n.tree,e.matcher=n.matcher,e.urlParamsCache.clear(),e.queryParamsCache.clear()}function pi(e,t){let n=di(e.definitions,t,e.matcherOptions);ti(n.matcher,e.config,`setRootPath`),e.rootPath=t,e.tree=n.tree,e.matcher=n.matcher,e.urlParamsCache.clear(),e.queryParamsCache.clear()}function mi(e,t){fi(e,t),_i(e,vi(e.config))}function hi(e){gi(e),fi(e,[])}function gi(e){Object.assign(e.config,Ir()),_i(e,K(null)),e.routeCustomFields=K(null)}function _i(e,t){e.resolvedForwardMap=t,e.hasAnyForward=Lr(e.config)}function vi(e){let t=K(null);for(let n of ci(e.forwardMap))t[n]=ri(n,e.forwardMap);return t}function yi(e,t){if(typeof e!=`function`){if(typeof e!=`string`&&e!==null)throw ii.type`forwardTo must be a string or function for route "${t}", got ${typeof e}`;return}let n=e.constructor.name===`AsyncFunction`,r=e.toString().includes(`__awaiter`);if(n||r)throw ii.type`forwardTo callback cannot be async for route "${t}". Async functions break matchPath/buildPath.`}function bi(e,t,n){t&&b(`encodeParams`,t,n,void 0),e&&b(`decodeParams`,e,n,void 0)}function xi(e,t,n,r){if(yi(e.forwardTo,t),e.canActivate){let n=typeof e.forwardTo==`string`?e.forwardTo:`[dynamic]`;r.warn(`router`,`Route "${t}" has both forwardTo and canActivate. canActivate will be ignored because forwardTo creates a redirect (industry standard). Move canActivate to the target route "${n}".`)}if(e.canDeactivate){let n=typeof e.forwardTo==`string`?e.forwardTo:`[dynamic]`;r.warn(`router`,`Route "${t}" has both forwardTo and canDeactivate. canDeactivate will be ignored because forwardTo creates a redirect (industry standard). Move canDeactivate to the target route "${n}".`)}typeof e.forwardTo==`string`?n.forwardMap[t]=e.forwardTo:n.forwardFnMap[t]=e.forwardTo}function Si(e,t,n,r,i,a,o){let{decodeParams:s,encodeParams:c}=e;bi(s,c,t);let l=ui(si(e).filter(([e])=>!Mr.has(e)));ci(l).length>0&&(r[t]=oi(l)),e.canActivate&&i.set(t,e.canActivate),e.canDeactivate&&a.set(t,e.canDeactivate),e.forwardTo&&xi(e,t,n,o),s&&(n.decoders[t]=e=>s(e)??e),c&&(n.encoders[t]=e=>c(e)??e),e.defaultParams&&(n.defaultParams[t]=P(`defaultParams`,e.defaultParams)),e.defaultSearch&&(n.defaultSearch[t]=P(`defaultSearch`,e.defaultSearch))}function Ci(e,t,n,r,i,a,o=``){for(let s of e){let e=o?`${o}.${s.name}`:s.name;Si(s,e,t,n,r,i,a),s.children&&Ci(s.children,t,n,r,i,a,e)}}function wi(e){let t=Ir();return Rr(t,e),t}function Ti(e,t,n){if(n.length===0)return[...e,...t];let[r,...i]=n;return e.map(e=>{if(e.name!==r)return e;let n=e.children??[];return{...e,children:i.length===0?[...n,...t]:Ti(n,t,i)}})}function Ei(e,t,n){for(let r of e){let e=t?`${t}.${r.name}`:r.name;n(e),r.children&&Ei(r.children,e,n)}}function Di(e,t,n){let r=new Set;Ei(e,t,e=>{if(r.has(e))throw E(`router`,n).plain`Duplicate route "${e}" in batch`;r.add(e)})}function Oi(e,t){if(On(e,t),e.startsWith(`@@`))throw E(`router`,t).plain`Route name "${e}" uses the reserved "${`@@`}" prefix. Routes with this prefix are internal and cannot be modified through the public API.`}function ki(e,t){for(let n of e)Oi(n.name,t),n.children&&ki(n.children,t)}function Ai(e,t){for(let n of e)s(n.name,t),n.children&&Ai(n.children,t)}function ji(e,t){for(let n of e)f(n.name,t),n.children&&ji(n.children,t)}function Mi(e,t,n){let r=new Map,i=(e,t)=>{for(let a of e){let e=r.get(t);if(e?.has(a.path))throw E(`router`,n).plain`Path "${a.path}" is already defined`;e?e.add(a.path):r.set(t,new Set([a.path])),a.children&&i(a.children,t?`${t}.${a.name}`:a.name)}};i(e,t)}function Ni(e,t,n){if(ki(t,`addRoute`),Ai(t,`addRoute`),ji(t,`addRoute`),n!==void 0&&!e.matcher.hasRoute(n))throw ai.plain`Parent route "${n}" does not exist`;Ei(t,n??``,t=>{if(e.matcher.hasRoute(t))throw ai.plain`Route "${t}" already exists`}),Di(t,n??``,`addRoute`),Mi(t,n??``,`addRoute`)}function Pi({definitions:e,routesForHandlers:t,config:n,routeCustomFields:r,handlerParentName:i,rootPath:a,matcherOptions:o,logger:s}){let c=new Map,l=new Map;Ci(t,n,r,c,l,s,i);let u=vi(n),{tree:d,matcher:f}=di(e,a,o);return{config:n,routeCustomFields:r,pendingCanActivate:c,pendingCanDeactivate:l,tree:d,matcher:f,resolvedForwardMap:u}}function Fi(e,t,n,r){return Pi({definitions:Ti(e.definitions,t.map(e=>Hr(e)),n===void 0?[]:n.split(`.`)),routesForHandlers:t,config:wi(e.config),routeCustomFields:Object.assign(K(null),e.routeCustomFields),handlerParentName:n??``,rootPath:e.rootPath,matcherOptions:e.matcherOptions,logger:r})}function Ii(e,t,n,r){return Pi({definitions:e.map(e=>Hr(e)),routesForHandlers:e,config:Ir(),routeCustomFields:K(null),handlerParentName:``,rootPath:t,matcherOptions:n,logger:r})}function Li(e,t,n){let r=[];for(let[i,a]of e)r.push([i,a,t(a,n)]);return r}function Ri(e,t){return{activate:Li(e.pendingCanActivate,t.compileGuard,`canActivate`),deactivate:Li(e.pendingCanDeactivate,t.compileGuard,`canDeactivate`)}}function zi(e,t,n){let r=e.depsStore,{activate:i,deactivate:a}=n??Ri(t,r);Object.assign(e.config,t.config),e.routeCustomFields=t.routeCustomFields,e.tree=t.tree,e.matcher=t.matcher,e.urlParamsCache.clear(),e.queryParamsCache.clear(),_i(e,t.resolvedForwardMap);for(let[e,t,n]of i)r.addActivateGuard(e,t,n);for(let[e,t,n]of a)r.addDeactivateGuard(e,t,n)}function q(e){return e===null?e:e||void 0}function Bi(e,t){return t==null?t:P(e,t)}function Vi(e,t,n,r){let{forwardTo:a,defaultParams:o,defaultSearch:s,decodeParams:c,encodeParams:l,canActivate:u,canDeactivate:d}=r,f=q(a),p=Bi(`defaultParams`,q(o)),m=Bi(`defaultSearch`,q(s)),h=q(c),g=q(l),_=q(u),v=q(d);p!=null&&i(`updateRoute`,n,p,ei(e,n),"this route's `defaultParams`","Move it to `defaultSearch`"),bi(h,g,n);let y=f===void 0?void 0:Hi(n,f,e.config),b=Ui(e,n,r),x=_==null?void 0:t.compileGuardFactory(_,`canActivate`),S=v==null?void 0:t.compileGuardFactory(v,`canDeactivate`);return t.preflightHandlerLimit(x===void 0?[]:[n],S===void 0?[]:[n],!1),b!==void 0&&(ci(b).length>0?e.routeCustomFields[n]=oi(b):delete e.routeCustomFields[n]),y!==void 0&&(e.config.forwardMap=y.forwardMap,e.config.forwardFnMap=y.forwardFnMap,_i(e,y.resolved)),Gi(e,n,{defaultParams:p,defaultSearch:m,decodeParams:h,encodeParams:g}),Ki(t,`activate`,n,_,x),Ki(t,`deactivate`,n,v,S),{forwardTo:f,defaultParams:p,defaultSearch:m,decodeParams:h,encodeParams:g}}function Hi(e,t,n){yi(t,e);let r=Object.assign(K(null),n.forwardMap),i=Object.assign(K(null),n.forwardFnMap);return t===null?(delete r[e],delete i[e]):typeof t==`string`?(delete i[e],r[e]=t):(delete r[e],i[e]=t),{forwardMap:r,forwardFnMap:i,resolved:vi({...n,forwardMap:r})}}function Ui(e,t,n){let r;for(let i of ci(n)){if(Mr.has(i))continue;let a=n[i];a!==void 0&&(r??={...e.routeCustomFields[t]},a===null?delete r[i]:O(r,i,a))}return r}function Wi(e,t,n){n!==void 0&&(n===null?delete e[t]:e[t]=n)}function Gi(e,t,n){if(Wi(e.config.defaultParams,t,n.defaultParams),Wi(e.config.defaultSearch,t,n.defaultSearch),n.decodeParams!==void 0){if(n.decodeParams===null)delete e.config.decoders[t];else{let r=n.decodeParams;e.config.decoders[t]=e=>r(e)??e}}if(n.encodeParams!==void 0){if(n.encodeParams===null)delete e.config.encoders[t];else{let r=n.encodeParams;e.config.encoders[t]=e=>r(e)??e}}}function Ki(e,t,n,r,i){r!==void 0&&(t===`activate`?r===null?e.clearCanActivate(n,`definition`):e.addCanActivate(n,r,!0,i):r===null?e.clearCanDeactivate(n,`definition`):e.addCanDeactivate(n,r,!0,i))}function qi(e,t,n,r){let i=e;ki(i,`addRoute`),Ai(i,void 0),ji(i,void 0),Di(i,``,`addRoute`);let a=Ii(i,``,t,n),o={get definitions(){return ln(o.tree)},config:a.config,tree:a.tree,matcher:a.matcher,urlParamsCache:new Map,queryParamsCache:new Map,resolvedForwardMap:a.resolvedForwardMap,hasAnyForward:Lr(a.config),routeCustomFields:a.routeCustomFields,rootPath:``,matcherOptions:t,depsStore:void 0,lifecycleNamespace:void 0,treeChanged:oi(r),revalidating:!1,pendingCanActivate:a.pendingCanActivate,pendingCanDeactivate:a.pendingCanDeactivate};return ti(o.matcher,o.config,`addRoute`),li(o,`matcherOptions`,{writable:!1,configurable:!1}),li(o,`treeChanged`,{writable:!1,configurable:!1}),o}function Ji(e,t,n){li(e,t,{value:n,writable:!1,configurable:!1})}const Yi=Object.freeze,Xi=Object.keys,Zi=[];Object.freeze(Zi);function Qi(e){let t=e.split(`.`),n=t.length,r=[t[0]],i=t[0].length;for(let a=1;a<n-1;a++)i+=1+t[a].length,r.push(e.slice(0,i));return r.push(e),r}function $i(e,t){if(e===t)return!0;let n=Array.isArray(e),r=Array.isArray(t);if(!n&&!r)return be(e)&&be(t)?xe(e)===xe(t):de(e,t);let i=n?e:[e],a=r?t:[t],o=i.length;if(o!==a.length)return!1;for(let e=0;e<o;e++)if(!$i(i[e],a[e]))return!1;return!0}function ea(e,t,n,r){let i=t[e];if(!i||typeof i!=`object`)return!0;for(let e of Xi(i))if(!$i(n.params[e],r.params[e])||!$i(n.search[e],r.search[e]))return!1;return!0}function ta(e,t,n,r,i,a){for(let o=0;o<a;o++){let a=r[o];if(a!==i[o]||!ea(a,e,t,n))return o}return a}const na=new Map;function J(e){let t=na.get(e);if(t)return t;let n=ra(e);return Yi(n),na.set(e,n),n}function ra(e){if(!e)return[``];let t=e.indexOf(`.`);if(t===-1)return[e];let n=e.indexOf(`.`,t+1);if(n===-1)return[e.slice(0,t),e];let r=e.indexOf(`.`,n+1);return r===-1?[e.slice(0,t),e.slice(0,n),e]:e.indexOf(`.`,r+1)===-1?[e.slice(0,t),e.slice(0,n),e.slice(0,r),e]:Qi(e)}let ia,aa,oa=null,sa,ca,la=null;function ua(e,t,n){if(!t)return{intersection:``,toActivate:J(e.name),toDeactivate:Zi};let r=n(e.name),i=n(t.name);if(!r&&!i)return{intersection:``,toActivate:J(e.name),toDeactivate:J(t.name)};let a=J(e.name),o=J(t.name),s=Math.min(o.length,a.length),c=ta(r??i,e,t,a,o,s),l;if(c>=o.length)l=Zi;else if(c===0&&o.length===1)l=o;else{l=[];for(let e=o.length-1;e>=c;e--)l.push(o[e])}let u=c===0?a:a.slice(c);return{intersection:c>0?o[c-1]:``,toDeactivate:l,toActivate:u}}function da(e,t,n){if(oa!==null&&e===ia&&t===aa)return oa;if(la!==null&&e===sa&&t===ca)return la;let r=ua(e,t,n);return sa=ia,ca=aa,la=oa,ia=e,aa=t,oa=r,r}const fa=E(`router`),pa=E(`router`,`shouldUpdateNode`),ma=Object.freeze,Y=Object.hasOwn;function ha(e,t){return{name:t??e.segments.at(-1).fullName,params:e.params,search:e.search,meta:e.meta}}function ga(e){let t=er(e);return t===`preserve`?void 0:t}var _a=class{#e;#t;#n;get#r(){return this.#e.depsStore}constructor(e,t,n,r){this.#e=qi(e,t,n,r)}static shouldUpdateNode(e,t){return(n,r)=>{if(!(n&&typeof n==`object`&&`name`in n))throw pa.type`toState must be valid State object`;if(n.transition?.reload||e===``)return!0;let{intersection:i,toActivate:a,toDeactivate:o}=da(n,r,t);return e===i||a.includes(e)?!0:o.includes(e)}}isRevalidating(){return this.#e.revalidating}setDependencies(e){Ji(this.#e,`depsStore`,e)}flushPendingGuards(){let e=this.#r;for(let[t,n]of this.#e.pendingCanActivate)e.addActivateGuard(t,n);this.#e.pendingCanActivate.clear();for(let[t,n]of this.#e.pendingCanDeactivate)e.addDeactivateGuard(t,n);this.#e.pendingCanDeactivate.clear()}setLifecycleNamespace(e){Ji(this.#e,`lifecycleNamespace`,e)}setRootPath(e){pi(this.#e,e)}hasRoute(e){return this.#e.matcher.hasRoute(e)}clearRoutes(){hi(this.#e)}buildPath(e,t,n,r){if(e===A.UNKNOWN_ROUTE)return typeof t.path==`string`?t.path:``;let i=this.#e.config.encoders[e];if(typeof i==`function`){let a=i({params:{...t},search:{...n}});return this.#e.matcher.buildPath(e,a.params??t,a.search??n,this.#c(r))}return this.#e.matcher.buildPath(e,t,n,this.#c(r))}buildPathFromIntent(e,t,n){return e===A.UNKNOWN_ROUTE?this.#r.port.buildPath(e,Ce(t,k),n??D):lr(U(this.#r.port,e,t,n,{resolveForward:!1}),this.#r.port)}matchPath(e,t){let n=t,r=this.#e.matcher.match(e);if(!r)return;let a=ha(r),{name:o}=a,s=L(a.params),c=L(a.search),l=this.#e.config.decoders[o],u;if(typeof l==`function`){u=l({params:s,search:c});let e=u,t=e.params,n=t??s;u={params:n,search:e.search??c},_(this.#r.checks,v[`matchPath:decoded`],o,t),i(`matchPath`,o,n,this.getQueryParams(o),"the `params` returned by this route's `decodeParams`")}else u={params:s,search:c};let d=U(this.#r.port,o,u.params,u.search),f=d.name;g(`matchPath`,d.name,d.path,this.getQueryParams(d.name));let p=d.path,m=d.query,h=e;if(n.rewritePathOnMatch)try{let t=this.#e.config.encoders[f],r=typeof t==`function`?t({params:{...p},search:{...m}}):{params:p,search:m},i=n.trailingSlash;h=this.#e.matcher.buildPath(f,r.params??p,r.search??m,{trailingSlash:ga(i),queryParamsMode:tr(n.queryParamsMode)}),er(i)===`preserve`&&(h=Kr(e,h))}catch{h=e}return fr(d,h)}forwardState(e,t,n){let r=n??D;if(Y(this.#e.config.forwardFnMap,e)){let n=this.#e.config.forwardFnMap[e],{target:i,chain:a,params:o}=this.#l(e,n,t);return this.#s(i,a,o,r)}let i=this.#e.resolvedForwardMap[e]??e;if(i!==e&&Y(this.#e.config.forwardFnMap,i)){let n=this.#e.config.forwardFnMap[i],{target:a,chain:o,params:s}=this.#l(i,n,t);return this.#s(a,[...this.#o(e),...o],s,r)}return i===e?{name:e,params:t,search:r}:this.#s(i,this.#o(e),t,r)}buildStateResolved(e,t){let n=this.#e.matcher.getSegmentsByName(e);if(n)return ha({segments:n,params:t,search:{},meta:this.#e.matcher.getMetaByName(e)},e)}isActiveRoute(e,t=k,n=D,r=!1,i=!0){if(this.#i(e,t,n,r,i))return!0;if(!this.#e.hasAnyForward)return!1;let a;try{a=typeof e==`string`?e:String(e)}catch{return!1}if(!Y(this.#e.config.forwardMap,a)&&!Y(this.#e.config.forwardFnMap,a))return!1;let o;try{o=this.forwardState(e,t,n)}catch(t){return this.#r.logger.warn(`router.isActiveRoute`,`Dynamic forwardTo of route "${Br(e)}" threw while resolving the active-link destination; treating the link as inactive.`,t),!1}return this.#i(o.name,o.params,o.search,r,i)}getMetaForState(e){return this.#e.matcher.hasRoute(e)?this.#e.matcher.getMetaByName(e):void 0}getUrlParams(e){return Xr(this.#e,e)}getQueryParams(e){return ei(this.#e,e)}getPrintedQueryParams(e){return $r(this.#e.matcher,e)}getStore(){return this.#e}getPort(){return this.#r.port}#i(e,t,n,r,i){try{return this.#a(e,t,n,r,i)}catch(t){return this.#r.logger.warn(`router.isActiveRoute`,`Reading the arguments for route "${Br(e)}" threw while resolving the active-link state; treating the link as inactive.`,t),!1}}#a(e,t,n,r,i){let a=this.#r.getState();if(!a)return!1;let o=a.name;if(o!==e&&!o.startsWith(`${e}.`)&&!e.startsWith(`${o}.`))return!1;let s=U(this.#r.port,e,t,n,{resolveForward:!1});if(r||o===e){let e=pr(s,``);return!this.#r.areStatesEqual(e,a,!0)||!zr(s.path,a.params)?!1:i||ue(e.search,a.search)}return!(!o.startsWith(`${e}.`)||!zr(s.path,a.params)||!i&&!Vr(s.query,a.search))}#o(e){let t=[],n=e;for(;Y(this.#e.config.forwardMap,n);)t.push(n),n=this.#e.config.forwardMap[n];return t}#s(e,t,n,r){let i,a;for(let e of t)i=Ee(this.#e.config.defaultParams[e],i),a=Ee(this.#e.config.defaultSearch[e],a);return{name:e,params:Ce(Ee(i,n),k),search:Ce(Ee(a,r),D)}}#c(e){return this.#t?(e!==this.#n&&this.#r.logger.warn(`router.buildPath`,"`options` differs from the cached source reference; router options are immutable per router instance, so the first-cached buildPath options are reused (#957)."),this.#t):(this.#n=e,this.#t=ma({trailingSlash:ga(e?.trailingSlash),queryParamsMode:tr(e?.queryParamsMode)}),this.#t)}#l(e,t,n){let r=F(n),i=new Set([e]),a=[e],o=t(this.#r.getDependency,r),s=0;if(typeof o!=`string`)throw fa.type`forwardTo callback must return a string, got ${typeof o}`;for(;s<100;){if(this.#e.matcher.getSegmentsByName(o)===void 0)throw fa.plain`Route "${o}" does not exist`;if(i.has(o)){let e=[...i,o].join(` → `);throw fa.plain`Circular forwardTo: ${e}`}if(i.add(o),Y(this.#e.config.forwardFnMap,o)){let e=this.#e.config.forwardFnMap[o];a.push(o),o=e(this.#r.getDependency,r),s++;continue}let e=this.#e.config.forwardMap[o];if(e!==void 0)a.push(o),o=e,s++;else return{target:o,chain:a,params:r}}throw fa.plain`forwardTo exceeds maximum depth of ${100}`}};const va=E(`router`),ya=new N(R.ROUTER_NOT_STARTED),ba=new N(R.SAME_STATES),xa=va.code(R.ROUTER_NOT_STARTED)`cannot commit before the start navigation does — the boot would overwrite it; defer with queueMicrotask/await, or navigate after start() resolves`;Object.freeze(ya),Object.freeze(ba),Object.freeze(xa);const Sa=Promise.reject(ya),Ca=Promise.reject(ba),wa=Promise.reject(xa);Sa.catch(()=>{}),Ca.catch(()=>{}),wa.catch(()=>{});const Ta=new Set([R.SAME_STATES,R.TRANSITION_CANCELLED,R.ROUTER_NOT_STARTED,R.ROUTE_NOT_FOUND,R.CANNOT_ACTIVATE,R.CANNOT_DEACTIVATE,R.ROUTER_ALREADY_STARTED]);function Ea(e){return e instanceof N&&Ta.has(e.code)}const Da=new Set([Sa,Ca,wa]),Oa=Object.freeze;function ka(e){let{fromState:t,toDeactivate:n,toActivate:r,intersection:i}=e;Oa(n),Oa(r);let a={phase:`activating`,reason:`success`,segments:Oa({deactivated:n,activated:r,intersection:i})};return t?.name!==void 0&&(a.from=t.name),e.reload!==void 0&&(a.reload=e.reload),e.replace!==void 0&&(a.replace=e.replace),e.redirected!==void 0&&(a.redirected=e.redirected),Oa(a)}function Aa(e,t){let{toState:n,fromState:r,toDeactivate:i,toActivate:a}=t;if(n.name!==A.UNKNOWN_ROUTE&&!e.hasRoute(n.name)){let i=I(new N(R.ROUTE_NOT_FOUND,{routeName:n.name}));throw e.sendTransitionFail(r,i,t),i}let o=t,s={...n,transition:ka(t)},c=Oa(s);t.toState=c;let l=e.canCommitTransition(o);if(!l)throw I(new N(R.TRANSITION_CANCELLED));for(let n of i)!a.includes(n)&&t.canDeactivateFunctions.has(n)&&e.clearCanDeactivate(n,l);return e.sendTransitionDone(o),c}const ja=Object.entries;function Ma(e){return e instanceof N&&e.code===R.TRANSITION_CANCELLED}function Na(e){return Ma(e)?e:I(new N(R.TRANSITION_CANCELLED,{reason:e}))}function Pa(e,t,n,r){Ma(t)?e.cancelIfInFlight(r,t):e.isTransitioning()&&e.sendTransitionFail(n,t,r)}function Fa(e,t,n){if(ye(e)&&La(e,t,n),e instanceof DOMException&&e.name===`AbortError`)throw I(new N(R.TRANSITION_CANCELLED));if(Ma(e))throw e;La(e,t,n)}function Ia(e){return ye(e)?Ra(e,R.CANNOT_DEACTIVATE):e}function La(e,t,n){throw e instanceof N?Ra(e,t):I(new N(t,Ba(e,n)))}function Ra(e,t){let{code:n,message:r,...i}=e.toJSON(),a=new N(n,{...i,message:r});return a.setCode(t),a.stack=e.stack??``,I(a)}const za=new Set([`code`,`segment`,`path`,`then`]);function Ba(e,t){let n={segment:t};if(e instanceof Error){let t=e.message,r=e.stack,i=`cause`in e?e.cause:void 0;return{...n,message:t,stack:r,...i!==void 0&&{cause:i}}}if(e&&typeof e==`object`){let t={};for(let[n,r]of ja(e))n!==`__proto__`&&!za.has(n)&&O(t,n,r);return{...n,...t}}return n}async function Va(e,t,n,r){let i;try{i=await e}catch(e){Fa(e,t,n);return}if(i!==!0)throw i!==!1&&r(n,i),I(new N(t,{segment:n}))}function Ha(e,t,n,r,i,a,o,s,c,l,u){if(!c())throw I(new N(R.TRANSITION_CANCELLED));if(e===1){let n=l();return n===void 0?void 0:{phase:e,index:t+1,pending:n}}let d=n[t],f=r.get(d);if(!f)return;let p;try{p=f(a,o,s)}catch(e){Fa(e,i,d)}if(p!==!0){if(p!==!1){let n=Ua(p,i,d);if(n!==void 0)return{phase:e,index:t+1,pending:n};u(d,p)}throw I(new N(i,{segment:d}))}}function Ua(e,t,n){let r;try{r=e?.then}catch(e){Fa(e,t,n)}if(typeof r==`function`)return new Promise((t,n)=>{Reflect.apply(r,e,[t,n])})}function Wa(e,t,n,r,i,a,o,s,c,l,u,d,f,p){let m=e===1,h=e===0;if(!m&&!(h?o:s))return;let g=h?i:a,_=m?1:g.length,v=h?n:r,y=h?R.CANNOT_DEACTIVATE:R.CANNOT_ACTIVATE;for(let n=t;n<_;n++){let t=Ha(e,n,g,v,y,c,l,u,d,f,p);if(t!==void 0)return t}}function Ga(e,t,n,r,i,a,o,s,c,l,u,d,f,p){for(let m=f;m<=2;m++){let h=Wa(m,m===f?p:0,e,t,n,r,i,a,o,s,c,l,u,d);if(h!==void 0)return h}}async function Ka(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=e;for(;p!==void 0;){if(p.phase===1)await p.pending;else{let e=p.phase===0;await Va(p.pending,e?R.CANNOT_DEACTIVATE:R.CANNOT_ACTIVATE,(e?r:i)[p.index-1],f)}p=Ga(t,n,r,i,a,o,s,c,l,u,d,f,p.phase,p.index)}}function qa(e,t,n,r,i,a,o,s,c,l,u,d){let f=Ga(e,t,n,r,i,a,o,s,c,l,u,d,0,0);return f===void 0?void 0:Ka(f,e,t,n,r,i,a,o,s,c,l,u,d)}const Ja=Object.freeze,Ya=Object.freeze([]),Xa=new Map;function Za(e,t){return t?Ja({...e,replace:!0}):e}function Qa(e,t,n,r){return!!e&&!t&&!n&&e.path===r.path}function $a(e,t){if(e.size===0)return!1;for(let n of t)if(e.has(n))return!0;return!1}function eo(e){let t=e.controller;if(t!==void 0)return t;let n=new AbortController;return e.cancelReason!==void 0&&(n.abort(e.cancelReason),ie(n.signal.reason)),e.controller=n,n}function to(e,t){t.externalSignal!==void 0&&t.cancelReason===void 0&&t.hasGuards&&e.bridgeExternalSignal(t)}function no(e,t,n,r,i,a,o,s,c,l){lo(e,a);let u=e.hasLeaveListeners()||e.hasPreCommitListeners(),d={toState:t,fromState:n,opts:r,suspendable:i!==void 0||u,forceDeactivate:l,toDeactivate:Ya,toActivate:Ya,intersection:``,canDeactivateFunctions:Xa,canActivateFunctions:Xa,shouldDeactivate:!1,shouldActivate:!1,hasGuards:!1,controller:void 0,cancelReason:void 0,detachExternalBridge:void 0,externalSignal:i,reload:o,replace:s,redirected:c};if(!e.startTransition(d))throw I(new N(R.TRANSITION_CANCELLED));return d}function ro(e,t){return e.sendLeaveApprove(t),Aa(e,t)}function io(e,t){let[n,r]=e.getLifecycleFunctions(),{toDeactivate:i,toActivate:a,intersection:o}=da(t.toState,t.fromState,t=>e.getMetaForState(t));t.canDeactivateFunctions=n,t.canActivateFunctions=r,t.toDeactivate=i,t.toActivate=a,t.intersection=o,t.shouldDeactivate=!!t.fromState&&!t.forceDeactivate&&i.length>0,t.shouldActivate=t.toState.name!==A.UNKNOWN_ROUTE&&a.length>0,t.hasGuards=t.shouldDeactivate&&$a(n,i)||t.shouldActivate&&$a(r,a)}function ao(e,t,n){let r,i;try{let a=he(n),o=a?.aborted===!0?a:void 0;n=_e(n),r=e.getState();let s=ge(n,`reload`),c=ge(n,`force`),l=ge(n,`replace`),u=ge(n,`redirected`),d=ge(n,`forceDeactivate`)===!0,f=r?.name===A.UNKNOWN_ROUTE&&!l,p=f||l;if(n=Za(n,f),Qa(r,s,c,t))return e.emitTransitionError(t,r,ba),Ca;let m=no(e,t,r,n,a,o,s,p,u,d);i=m;let h=m.externalSignal;if(h?.aborted===!0&&e.cancelNavigation(h.reason),io(e,m),to(e,m),!m.hasGuards&&!m.suspendable)return ro(e,m);let{canDeactivateFunctions:g,canActivateFunctions:_,toDeactivate:v,toActivate:y,shouldDeactivate:b,shouldActivate:x,hasGuards:S}=m,C=t;if(!S){let t=co(e,m);if(t!==void 0)return t}if(S){let n=eo(m),i=()=>!n.signal.aborted,a=n.signal,o=qa(g,_,v,y,b,x,t,r,a,i,()=>{if(e.sendLeaveApprove(m),e.hasLeaveListeners())return e.awaitLeaveListeners(C,r,a)},e.warnNonBooleanGuard);if(o!==void 0)return oo(e,o,m,n);if(!i())throw I(new N(R.TRANSITION_CANCELLED))}return Aa(e,m)}catch(t){let n=so(e,t,{nav:i,fromState:r});return ie(n),Promise.reject(n)}}async function oo(e,t,n,r){let i=()=>!r.signal.aborted,a=n.externalSignal,o,s=!1,c,l=new Promise(e=>{r.signal.aborted?e():(o=()=>{e()},r.signal.addEventListener(`abort`,o,{once:!0}))});t.catch(()=>{});try{if(a?.aborted)throw I(new N(R.TRANSITION_CANCELLED,{reason:a.reason}));if(await Promise.race([t,l]),!i())throw I(new N(R.TRANSITION_CANCELLED));let r=Aa(e,n);return s=!0,r}catch(t){let r=i()?t:Na(t);throw c=r,Pa(e,r,n.fromState,n),ie(r),r}finally{o&&r.signal.removeEventListener(`abort`,o),s||(r.abort(c),ie(r.signal.reason))}}function so(e,t,n){let{nav:r}=n;if(e.dispatchAbort(r?.controller,t),r!==void 0){let i=r.cancelReason===void 0?t:Na(t);return Pa(e,i,n.fromState,r),i}return t}function co(e,t){let{toState:n,fromState:r}=t;if(e.hasLeaveListeners()&&eo(t),e.sendLeaveApprove(t),e.hasLeaveListeners()){let i=eo(t),a=e.awaitLeaveListeners(n,r,i.signal);return a===void 0?void 0:oo(e,a,t,i)}}function lo(e,t){if(e.isTransitioning()&&(e.logger.warn(`router`,`Concurrent navigation detected on shared router instance. For SSR, use cloneRouter() to create isolated instance per request.`),e.cancelNavigation()),t!==void 0)throw I(new N(R.TRANSITION_CANCELLED,{reason:t.reason}))}const uo=Object.freeze,fo=E(`router`,`navigateToNotFound`),po=Object.freeze([A.UNKNOWN_ROUTE]),mo=Object.freeze({replace:!0});function ho(e,t,n){lo(e,void 0);let r=e.getState(),i=r?J(r.name).toReversed():[];uo(i);let a={deactivated:i,activated:po,intersection:``};uo(a);let o={phase:`activating`,...r&&{from:r.name},reason:`success`,replace:!0,segments:a};uo(o);let s={name:A.UNKNOWN_ROUTE,params:k,search:D,path:t,transition:o,context:{}};if(uo(s),n&&r!==void 0&&!e.canDeactivateCurrent(i,s,r)){let n=fo.code(R.CANNOT_DEACTIVATE,{path:t})`a canDeactivate guard on "${r.name}" refused to leave for ${t}`;throw e.emitTransitionError(void 0,r,n),n}return e.systemCommit(s,r,mo)}function go(e,t){return ho(e,t,!0)}function _o(e,t){return ho(e,t,!1)}const vo=E(`router`,`navigateToState`),yo=E(`router`,`navigateToDefault`);var bo=class{#e;#t;#n=0;#r=0;setDependencies(e){this.#e=e,this.#t=t=>{Ea(t)||e.logger.error(`router`,`Unexpected navigation error`,t)}}navigate(e,t,n,r){return this.#i(this.#a(e,t,n,r))}navigateToState(e,t){return this.#i(this.#o(e,t))}navigateToDefault(e){return this.#i(this.#c(e))}navigateToNotFound(e){this.#r++;try{return go(this.#e,e)}finally{this.#r--}}isCommittingNotFound(){return this.#r>0}revalidateToNotFound(e){return _o(this.#e,e)}isPreparing(){return this.#n>0}#i(e){return e instanceof Promise&&!Da.has(e)&&e.catch(this.#t),e}#a(e,t,n,r){let i=this.#e;if(!i.canNavigate())return i.isStarting()?wa:Sa;let a;this.#n++;try{a=i.buildNavigateState(e,t,n)}catch(e){return Promise.reject(e)}finally{this.#n--}if(!a){let t=I(new N(R.ROUTE_NOT_FOUND,{routeName:e}));return i.emitTransitionError(void 0,i.getState(),t),Promise.reject(t)}return ao(this.#e,a,r)}#o(t,n){let r=this.#e;if(!r.canNavigate())return r.isStarting()?wa:Sa;let i=t.name;if(i!==A.UNKNOWN_ROUTE&&!r.hasRoute(i)){let e=I(new N(R.ROUTE_NOT_FOUND,{routeName:i}));return r.emitTransitionError(void 0,r.getState(),e),Promise.reject(e)}let a=e(t.params,r.getQueryParams(i));if(a!==void 0){let e=vo.code(R.WRONG_CHANNEL,{routeName:i})`${h(i,a,"`state.params`")}`;return r.emitTransitionError(void 0,r.getState(),e),Promise.reject(e)}let o;try{o=this.#s(t,i)}catch(e){return Promise.reject(e)}return ao(this.#e,o,n)}#s(e,t){let n={name:t,params:Se(e.params,k),search:Se(e.search,D),path:e.path,context:{...e.context},transition:se};return fe(n)}#c(e){let t=this.#e;if(!t.getOptions().defaultRoute)return Promise.reject(yo.code(R.ROUTE_NOT_FOUND)`no defaultRoute is configured — pass one to createRouter, or navigate to a route by name`);let n,r,i;this.#n++;try{({route:n,params:r,search:i}=t.resolveDefault())}catch(e){return Promise.reject(e)}finally{this.#n--}return n?typeof n==`string`?this.#a(n,r,i,e):Promise.reject(yo.code(R.ROUTE_NOT_FOUND)`defaultRoute resolved to ${typeof n}, which cannot name a route`):Promise.reject(yo.code(R.ROUTE_NOT_FOUND)`defaultRoute resolved to an empty name`)}};const xo={},So=E(`router`,`start`),Co=Object.freeze({replace:!0});function wo(e){return e instanceof N&&e.code===R.ROUTE_NOT_FOUND}var To=class{#e;setDependencies(e){this.#e=e}async start(e){let t=this.#e;if(t.isIdle())throw I(new N(R.TRANSITION_CANCELLED));let n=t.getOptions();if(typeof e!=`string`)throw So.type`path must be a string, got ${typeof e}`;let r=t.getRootPath(),i=t.matchPath(e);if(!i&&!n.allowNotFound){let t=new N(R.ROUTE_NOT_FOUND,{path:e});throw I(t)}if(t.completeStart(),i!==void 0&&t.getRootPath()!==r&&(i=t.matchPath(e),!i&&!n.allowNotFound))throw I(new N(R.ROUTE_NOT_FOUND,{path:e}));if(i)try{return await t.navigateToState(i,Co)}catch(r){if(!n.allowNotFound||!wo(r))throw r;return t.navigateToNotFound(e)}return t.navigateToNotFound(e)}};const Eo={},Do=Object.create,Oo=Object.entries,ko=Object.hasOwn,Ao=Object.values,jo=new WeakMap;function Mo(e,t,n){if(typeof n==`string`)return{target:n,when:void 0,update:void 0};let r=n.when,i=n.update;if(r!==void 0&&typeof r!=`function`)throw j.plain`transitions["${e}"]["${t}"].when is not a function`;if(i!==void 0&&typeof i!=`function`)throw j.plain`transitions["${e}"]["${t}"].update is not a function`;return{target:n.target,when:r,update:i}}function No(e){let t=jo.get(e);if(t!==void 0)return t;let n=e,r=Do(null);for(let[e,t]of Oo(n)){let n=Do(null);for(let[r,i]of Oo(t))i!==void 0&&(n[r]=Mo(e,r,i));r[e]=n}for(let e of Ao(r))for(let t of Ao(e))if(t!==void 0&&r[t.target]===void 0)throw j.plain`state "${t.target}" is not declared in config.transitions`;return jo.set(e,r),r}var Po=class{#e;#t;#n=0;#r=null;#i;#a;#o=[];constructor(e){let t=e.initial;if(this.#e=t,this.#i=e.context,this.#a=No(e.transitions),this.#a[t]===void 0)throw j.plain`state "${t}" is not declared in config.transitions`;this.#t=this.#a[t]}send(e,t){let n=this.#t[e];if(n===void 0)return this.#e;let r=t,i=n.when;if(i!==void 0&&!i(this.#i,r))return this.#e;let a=n.target,o=n.update,s=this.#e;if(this.#e=a,this.#t=this.#a[a],o?.(this.#i,r),this.#r!==null){let t=this.#r.get(s)?.get(e);t!==void 0&&t(r)}if(this.#n>0){let t={from:s,to:a,event:e,payload:r};for(let e of this.#o)e!==null&&e(t)}return this.#e}canSend(e,t){let n=this.#t[e];return n===void 0?!1:n.when===void 0||n.when(this.#i,t)}getState(){return this.#e}getContext(){return this.#i}on(e,t,n){let r=this.#a[e];if(r===void 0)throw j.plain`state "${e}" is not declared in config.transitions`;if(!ko(r,t))throw j.plain`event "${t}" has no edge from state "${e}"`;this.#r??=new Map;let i=this.#r.get(e);i||(i=new Map,this.#r.set(e,i));let a=n;return i.set(t,a),()=>{let n=this.#r?.get(e);n?.get(t)===a&&n.delete(t)}}onTransition(e){let t=this.#o.indexOf(null),n;t===-1?(n=this.#o.length,this.#o.push(e)):(this.#o[t]=e,n=t),this.#n++;let r=!0;return()=>{r&&(r=!1,this.#o[n]=null,this.#n--)}}};const X={IDLE:`IDLE`,STARTING:`STARTING`,READY:`READY`,TRANSITION_STARTED:`TRANSITION_STARTED`,LEAVE_APPROVED:`LEAVE_APPROVED`,DISPOSED:`DISPOSED`},Z={START:`START`,STARTED:`STARTED`,NAVIGATE:`NAVIGATE`,LEAVE_APPROVE:`LEAVE_APPROVE`,COMPLETE:`COMPLETE`,FAIL:`FAIL`,CANCEL:`CANCEL`,STOP:`STOP`,DISPOSE:`DISPOSE`,SYSTEM_COMMIT:`SYSTEM_COMMIT`};function Fo(){return{inflight:void 0,current:void 0,previous:void 0}}const Io=(e,t)=>t?.nav===void 0||t.nav===e.inflight,Lo=(e,t)=>t!==void 0&&t===e.inflight&&t.externalSignal?.aborted!==!0,Ro=(e,t)=>{e.previous=e.current,e.current=fe(t)},zo=(e,t)=>{Ro(e,t.toState),e.inflight=void 0},Bo=(e,t)=>{Ro(e,t.toState)},Vo=e=>{e.previous=e.current,e.current=void 0},Ho=e=>{e.current=void 0,e.previous=void 0,e.inflight=void 0},Uo=(e,t)=>{e.inflight=t},Wo={[X.IDLE]:{[Z.START]:X.STARTING,[Z.DISPOSE]:{target:X.DISPOSED,update:Ho}},[X.STARTING]:{[Z.STARTED]:X.READY,[Z.FAIL]:X.IDLE,[Z.STOP]:{target:X.IDLE,update:Vo},[Z.DISPOSE]:{target:X.DISPOSED,update:Ho}},[X.READY]:{[Z.NAVIGATE]:{target:X.TRANSITION_STARTED,update:Uo},[Z.SYSTEM_COMMIT]:{target:X.READY,update:Bo},[Z.STOP]:{target:X.IDLE,update:Vo},[Z.DISPOSE]:{target:X.DISPOSED,update:Ho}},[X.TRANSITION_STARTED]:{[Z.NAVIGATE]:{target:X.TRANSITION_STARTED,update:Uo},[Z.LEAVE_APPROVE]:X.LEAVE_APPROVED,[Z.CANCEL]:X.READY,[Z.FAIL]:{target:X.READY,when:Io},[Z.DISPOSE]:{target:X.DISPOSED,update:Ho}},[X.LEAVE_APPROVED]:{[Z.NAVIGATE]:{target:X.TRANSITION_STARTED,update:Uo},[Z.COMPLETE]:{target:X.READY,when:Lo,update:zo},[Z.CANCEL]:X.READY,[Z.FAIL]:{target:X.READY,when:Io},[Z.DISPOSE]:{target:X.DISPOSED,update:Ho}},[X.DISPOSED]:{}};function Go(){return new Po({initial:X.IDLE,context:Fo(),transitions:Wo})}const Ko=E(`router`,`subscribe`),qo=E(`router`,`subscribeChanges`),Jo=E(`router`,`subscribeDiagnostic`),Yo=E(`router`,`subscribeLeave`),Xo=Object.freeze,Zo=`TREE_CHANGED`;function Qo(e){return e instanceof Error?e:Error(String(e))}function $o(e,t,n){return new Promise((r,i)=>{let a=()=>{let e=n.reason;i(e instanceof N&&e.code===R.TRANSITION_CANCELLED?e:I(new N(R.TRANSITION_CANCELLED,{reason:e})))};n.aborted?(Promise.allSettled(e),a()):(n.addEventListener(`abort`,a,{once:!0}),Promise.allSettled(e).then(e=>{if(n.removeEventListener(`abort`,a),n.aborted)return;if(t!==void 0){i(Qo(Ia(t)));return}let o=e.find(e=>e.status===`rejected`);o===void 0?r():i(Qo(Ia(o.reason)))}))})}function es(e,t,n){return e.addEventListener(`abort`,t,{once:!0}),()=>{n(),e.removeEventListener(`abort`,t)}}var ts=class{#e;#t;#n=[];#r=0;constructor(e){this.#e=e.routerFSM,this.#t=e.emitter,this.#o()}static validateSubscribeListener(e){if(typeof e!=`function`)throw Ko.type`Expected a function. For Observable pattern use observable(router) from @real-router/rx`}static validateSubscribeLeaveListener(e){if(typeof e!=`function`)throw Yo.type`Expected a function`}emitRouterStart(){this.#r++;try{this.#t.emit(T.ROUTER_START)}finally{this.#r--}}emitRouterStop(){this.#t.emit(T.ROUTER_STOP)}emitTransitionStart(e,t,n){this.#r++;try{this.#t.emit(T.TRANSITION_START,e,t)}finally{this.#r--}}emitTransitionSuccess(e,t,n){this.#r++;try{this.#t.emit(T.TRANSITION_SUCCESS,e,t,n)}finally{this.#r--}}emitTransitionError(e,t,n){this.#r++;try{this.#t.emit(T.TRANSITION_ERROR,e,t,n)}finally{this.#r--}}emitTransitionCancel(e,t){this.#r++;try{this.#t.emit(T.TRANSITION_CANCEL,e,t)}finally{this.#r--}}emitTransitionLeaveApprove(e,t){this.#r++;try{this.#t.emit(T.TRANSITION_LEAVE_APPROVE,e,t)}finally{this.#r--}}dispatchAbort(e,t){if(e!==void 0){this.#r++;try{e.abort(t),ie(e.signal.reason)}finally{this.#r--}}}isProcessing(){return this.#r>0}emitTreeChanged(e){this.#t.emit(Zo,e)}isEmittingTreeChanged(){return this.#t.isDispatching(Zo)}subscribeTreeChanged(e){if(this.isDisposed())throw qo.code(R.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;return this.#t.on(Zo,t=>e(t))}emitDiagnostic(e,...t){this.#t.emit(e,...t)}subscribeDiagnostic(e,t){if(this.isDisposed())throw Jo.code(R.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;return this.#t.on(e,(...e)=>t(...e))}treeChangedListenerCount(){return this.#t.listenerCount(Zo)}diagnosticListenerCount(e){return this.#t.listenerCount(e)}sendStart(){this.#e.send(Z.START)}sendStop(){this.#e.send(Z.STOP)}sendStopForDispose(){this.#r++;try{this.#e.send(Z.STOP)}finally{this.#r--}}sendDispose(){this.#e.send(Z.DISPOSE)}sendStarted(){this.#e.send(Z.STARTED)}sendNavigate(e){return this.#e.send(Z.NAVIGATE,e)===X.TRANSITION_STARTED}canCommitTransition(e){return this.#e.canSend(Z.COMPLETE,e)}sendComplete(e){this.#e.send(Z.COMPLETE,e)}sendLeaveApprove(e){this.#e.send(Z.LEAVE_APPROVE,e)}sendFail(e,t,n){this.#e.send(Z.FAIL,{nav:n,fromState:e,error:t})}sendCancel(e,t){this.#e.send(Z.CANCEL,{fromState:e,reason:t})}systemCommit(e,t){let{toState:n}=e,r=n.transition,i={name:t,params:Se(n.params,k),search:Se(n.search,D),path:n.path,context:{...n.context},...r!=null&&{transition:we(r)}};if(!this.#e.canSend(Z.SYSTEM_COMMIT))throw I(this.#a());return this.#e.send(Z.SYSTEM_COMMIT,{...e,toState:i}),i}canBeginTransition(){return this.#e.canSend(Z.NAVIGATE)}canStart(){return this.#e.canSend(Z.START)}canCancel(){return this.#e.canSend(Z.CANCEL)}isActive(){let e=this.#e.getState();return e!==X.IDLE&&e!==X.DISPOSED}isDisposed(){return this.#e.getState()===X.DISPOSED}isTransitioning(){let e=this.#e.getState();return e===X.TRANSITION_STARTED||e===X.LEAVE_APPROVED}isLeaveApproved(){return this.#e.getState()===X.LEAVE_APPROVED}isReady(){return this.#e.getState()===X.READY}isStarting(){return this.#e.getState()===X.STARTING}isIdle(){return this.#e.getState()===X.IDLE}addEventListener(e,t,n){return this.#i(e,n),this.#t.on(e,t)}subscribe(e){if(this.isDisposed()||(this.#i(T.TRANSITION_SUCCESS,`subscribe`),this.isDisposed()))throw Ko.code(R.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;return this.#t.on(T.TRANSITION_SUCCESS,(t,n)=>e({route:t,previousRoute:n}))}subscribeLeave(e){if(this.isDisposed())throw Yo.code(R.ROUTER_DISPOSED)`cannot subscribe on a disposed router — dispose() is terminal`;this.#n.push(e);let t=!1;return()=>{if(t)return;t=!0;let n=this.#n.indexOf(e);n!==-1&&this.#n.splice(n,1)}}hasLeaveListeners(){return this.#n.length>0}hasPreCommitListeners(){return this.#t.listenerCount(T.TRANSITION_START)>0||this.#t.listenerCount(T.TRANSITION_LEAVE_APPROVE)>0}awaitLeaveListeners(e,t,n){if(t===void 0)return;let r=Xo({route:t,nextRoute:e,signal:n}),i,a,o=[...this.#n];this.#r++;try{for(let e of o)try{let t=e(r);t!==void 0&&typeof t.then==`function`&&(i??=[],i.push(t))}catch(e){a===void 0&&(a=e)}}finally{this.#r--}if(i===void 0){if(a!==void 0)throw Qo(Ia(a))}else return $o(i,a,n)}clearAll(){this.#t.clearAll(),this.#n.length=0}setLimits(e){this.#t.setLimits(e)}sendCancelIfPossible(e,t){this.canCancel()&&this.sendCancel(e,t)}sendCancelIfInFlight(e,t,n){this.#e.getContext().inflight===e&&this.sendCancelIfPossible(t,n)}bridgeExternalSignal(e){let t=e.externalSignal;if(t===void 0||e.detachExternalBridge!==void 0)return Eo;let n=es(t,()=>{this.sendCancelIfPossible(this.#e.getContext().current,t.reason)},()=>{e.detachExternalBridge=void 0});return e.cancelReason===void 0?e.detachExternalBridge=n:n(),Eo}#i(e,t){this.emitDiagnostic(C.LISTENER_COUNT,this.#t.listenerCount(e)+1,e,t)}#a(){if(this.isDisposed())return new N(R.ROUTER_DISPOSED,{message:`[router] cannot commit a state on a disposed router — dispose() is terminal`});let e;return e=this.isTransitioning()?`[router] cannot commit a state while a transition is in flight — the navigation in progress commits its own`:this.isStarting()?`[router] cannot commit before the start navigation does — the boot would overwrite it; await start() first`:`[router] cannot commit a state before the router has started`,new N(R.ROUTER_NOT_STARTED,{message:e})}#o(){let e=this.#e;e.on(X.STARTING,Z.STARTED,()=>{this.emitRouterStart()}),e.on(X.READY,Z.STOP,()=>{this.emitRouterStop()});let t=e=>{let t=e.externalSignal!==void 0&&(this.hasLeaveListeners()||this.hasPreCommitListeners())?this.bridgeExternalSignal(e):Eo;this.emitTransitionStart(e.toState,e.fromState,t)};e.on(X.READY,Z.NAVIGATE,t),e.on(X.TRANSITION_STARTED,Z.NAVIGATE,t),e.on(X.LEAVE_APPROVED,Z.NAVIGATE,t),e.on(X.TRANSITION_STARTED,Z.LEAVE_APPROVE,e=>{this.emitTransitionLeaveApprove(e.toState,e.fromState)}),e.on(X.LEAVE_APPROVED,Z.COMPLETE,e=>{e.detachExternalBridge?.(),this.emitTransitionSuccess(e.toState,e.fromState,e.opts)});let n=e=>{let{fromState:t,reason:n}=e,r=this.#e.getContext().inflight,i=n??I(new N(R.TRANSITION_CANCELLED));r.cancelReason=i,this.dispatchAbort(r.controller,i),r.detachExternalBridge?.(),this.emitTransitionCancel(r.toState,t)};e.on(X.TRANSITION_STARTED,Z.CANCEL,n),e.on(X.LEAVE_APPROVED,Z.CANCEL,n),e.on(X.READY,Z.SYSTEM_COMMIT,e=>{this.emitTransitionSuccess(e.toState,e.fromState,e.opts)});let r=e=>{let t=this.#e.getContext().inflight;t?.detachExternalBridge?.(),this.emitTransitionError(t?.toState,e.fromState,e.error)};e.on(X.LEAVE_APPROVED,Z.FAIL,r),e.on(X.TRANSITION_STARTED,Z.FAIL,r),e.on(X.STARTING,Z.FAIL,e=>{this.emitTransitionError(void 0,e.fromState,e.error)})}};const ns=Object.freeze;function rs(e){return as(e)&&!Object.isFrozen(e)&&e!==Zn.defaultParams&&e!==Zn.defaultSearch}function is(e){let{defaultParams:t,defaultSearch:n}=e;return ns({...rs(t)&&{defaultParams:new WeakRef(t)},...rs(n)&&{defaultSearch:new WeakRef(n)}})}function as(e){return typeof e==`object`&&!!e}function os(e){let t={...e};return e.limits!=null&&(t.limits=P(`limits`,e.limits)),as(e.defaultParams)&&(t.defaultParams=P(`defaultParams`,e.defaultParams)),as(e.defaultSearch)&&(t.defaultSearch=P(`defaultSearch`,e.defaultSearch)),t}const ss=Object.keys,cs=Object.freeze;function ls(e={}){let t={...ve,...e};return cs({maxDependencies:Number(t.maxDependencies),maxPlugins:Number(t.maxPlugins),maxListeners:Number(t.maxListeners),warnListeners:Number(t.warnListeners),maxLifecycleHandlers:Number(t.maxLifecycleHandlers)})}function us(e){return e==null?void 0:cs(ss(e))}const ds=E(`router`),fs=Object.freeze,ps=Object.freeze({});function ms(e,t){let n;try{n=t[e]}catch(t){throw ds.type({cause:t})`Invalid "queryParams.${e}": reading it threw.`}if(n!=null){if(typeof n==`string`)return n;try{return String(n)}catch(t){throw ds.type({cause:t})`Invalid "queryParams.${e}": its value cannot be converted to a string.`}}}function hs(e){if(e==null)return`default`;try{return String(e)}catch(e){throw ds.type({cause:e})`Invalid "urlParamsEncoding": coercing it threw.`}}function gs(e){if(!e)return ps;let t=ms(`arrayFormat`,e),n=ms(`booleanFormat`,e),r=ms(`nullFormat`,e),i=ms(`numberFormat`,e);return fs({...t!==void 0&&{arrayFormat:t},...n!==void 0&&{booleanFormat:n},...r!==void 0&&{nullFormat:r},...i!==void 0&&{numberFormat:i}})}function _s(e){return fs({strictTrailingSlash:e.trailingSlash===`strict`,caseSensitive:e.caseSensitive,strictQueryParams:e.queryParamsMode===`strict`,urlParamsEncoding:hs(e.urlParamsEncoding),queryParams:gs(e.queryParams)})}const vs=new N(R.ROUTER_ALREADY_STARTED);Object.freeze(vs);const ys=E(`router`),bs={maxListeners:0,warnListeners:0};var xs=class{#e=new Map;#t=new Set;#n=null;#r=bs;#i;#a;constructor(e){e?.limits&&(this.#r=e.limits),this.#i=e?.onListenerError??null,this.#a=e?.onListenerWarn??null}setLimits(e){this.#r=e}on(e,t){let n=this.#e.get(e),r=n?.size??0;if(n?.has(t))throw ys.plain`Duplicate listener for "${e}"`;let{maxListeners:i,warnListeners:a}=this.#r;if(i!==0&&r>=i)throw ys.plain`Listener limit (${i}) reached for "${e}"`;a!==0&&r===a&&this.#a!==null&&(this.#n??=new Set,this.#n.has(e)||(this.#a(e,a),this.#n.add(e)));let o=n;return o===void 0&&(o=new Set,this.#e.set(e,o)),o.add(t),()=>{this.off(e,t)}}off(e,t){let n=this.#e.get(e);n&&(n.delete(t),n.size===0&&(this.#e.delete(e),this.#n?.delete(e)))}emit(e,t,n,r,i){let a=this.#e.get(e);if(!a||a.size===0||this.#t.has(e))return;let o=arguments.length-1;this.#t.add(e);try{if(a.size===1){let[s]=a;this.#o(e,s,o,t,n,r,i)}else{let s=[...a];for(let a of s)this.#o(e,a,o,t,n,r,i)}}finally{this.#t.delete(e)}}clearAll(){this.#e.clear(),this.#n=null}listenerCount(e){return this.#e.get(e)?.size??0}isDispatching(e){return this.#t.has(e)}#o(e,t,n,r,i,a,o){try{let s=this.#s(t,n,r,i,a,o),c=s?.then;typeof c==`function`&&new Promise((e,t)=>{c.call(s,e,t)}).catch(t=>{this.#i?.(e,t)})}catch(t){this.#i?.(e,t)}}#s(e,t,n,r,i,a){switch(t){case 0:return e();case 1:return e(n);case 2:return e(n,r);case 3:return e(n,r,i);default:return e(n,r,i,a)}}};const Ss=Object.freeze({log:0,warn:1,error:2}),Cs=Object.freeze({all:0,"warn-error":1,"error-only":2,none:3}),ws=Object.hasOwn;var Ts=class{#e={level:`all`,callback:void 0,callbackIgnoresLevel:!1};#t=0;#n=!1;constructor(e){e&&this.configure(e)}isInCallback(){return this.#n}configure(e){let t=Hn(e),n=t.level;n!==void 0&&(this.#e.level=n,this.#t=Cs[n]),ws(t,`callback`)&&(this.#e.callback=t.callback),t.callbackIgnoresLevel!==void 0&&(this.#e.callbackIgnoresLevel=t.callbackIgnoresLevel)}getConfig(){return{level:this.#e.level,callback:this.#e.callback,callbackIgnoresLevel:this.#e.callbackIgnoresLevel}}log(e,t,...n){this.#r(`log`,e,t,n)}warn(e,t,...n){this.#r(`warn`,e,t,n)}error(e,t,...n){this.#r(`error`,e,t,n)}#r(e,t,n,r){if(this.#e.level===`none`&&!this.#e.callbackIgnoresLevel)return;let i=Ss[e]<this.#t;i||this.#i(e,t,n,r),this.#a(e,t,n,i,r)}#i(e,t,n,r){if(typeof console<`u`&&typeof console[e]==`function`){let i=t?`[${t}] ${n}`:n;console[e](i,...r)}}#a(e,t,n,r,i){if(!(!this.#e.callback||!this.#e.callbackIgnoresLevel&&r)&&!this.#n){this.#n=!0;try{let r=this.#e.callback(e,t,n,...i);r!=null&&typeof r.then==`function`&&Promise.resolve(r).catch(e=>{this.#o(`[router] Error in async callback:`,e)})}catch(e){this.#o(`[router] Error in callback:`,e)}finally{this.#n=!1}}}#o(e,t){typeof console<`u`&&typeof console.error==`function`&&console.error(e,t)}};function Es(e){let t=t=>qn(e.dependenciesStore,t),n=Ds(e.router,t),r=Ms(e);Os(e),ks(e,n),As(e,r,t),js(e,n),Ns(e,r,t),Ps(e),Fs(e,r)}function Ds(e,t){return n=>n(e,t)}function Os(e){e.eventBus.setLimits({maxListeners:e.limits.maxListeners,warnListeners:e.limits.warnListeners})}function ks(e,t){let n={logger:y(e.router).logger,compileFactory:t,runChecks:(t,...n)=>{_(y(e.router).checks,t,...n)},hasChecks:t=>S(y(e.router).checks,t),emitDiagnostic:(t,...n)=>{e.eventBus.emitDiagnostic(t,...n)},diagnosticListenerCount:t=>e.eventBus.diagnosticListenerCount(t)};e.routeLifecycle.setDependencies(n)}function As(e,t,n){let r={logger:y(e.router).logger,checks:y(e.router).checks,port:t,addActivateGuard:(t,n,r)=>{e.routeLifecycle.addCanActivate(t,n,!0,r)},addDeactivateGuard:(t,n,r)=>{e.routeLifecycle.addCanDeactivate(t,n,!0,r)},compileGuard:(t,n)=>e.routeLifecycle.compileGuardFactory(t,n),getState:()=>e.state.get(),areStatesEqual:(t,n,r)=>e.state.areStatesEqual(t,n,r),getDependency:n};e.routes.setDependencies(r),e.routes.setLifecycleNamespace(e.routeLifecycle)}function js(e,t){let n={logger:y(e.router).logger,addEventListener:(t,n)=>e.eventBus.addEventListener(t,n,`usePlugin`),canNavigate:()=>e.eventBus.canBeginTransition(),compileFactory:t,isDisposed:()=>e.eventBus.isDisposed(),runChecks:(t,...n)=>{_(y(e.router).checks,t,...n)},emitDiagnostic:(t,...n)=>{e.eventBus.emitDiagnostic(t,...n)}};e.plugins.setDependencies(n)}function Ms(e){let t=y(e.router),n=e.routes.getStore(),r=(t,n)=>{e.eventBus.emitDiagnostic(C.UNDECLARED_PARAM_KEY,t,n)},i=(t,n)=>{e.eventBus.emitDiagnostic(C.DROPPED_QUERY_KEY,t,n)},a=t=>{let r=e.routes.getUrlParams(t),i=n.tree.paramMeta.urlParams;return i.length===0?r:[...i,...r]},o=t=>{let{name:r}=t,i={encode:n.config.encoders[r],decode:n.config.decoders[r]};(i.encode!==void 0||i.decode!==void 0)&&e.eventBus.emitDiagnostic(C.CODEC_ROUND_TRIP,t,i,a(r))};return{resolveForward:(e,n,r)=>t.forwardState(e,n,r),defaultParams:e=>n.config.defaultParams[e],defaultSearch:e=>n.config.defaultSearch[e],buildPath:(t,n,r)=>e.routes.buildPath(t,n,r,e.options.get()),queryNames:t=>e.routes.getQueryParams(t),printedQueryNames:t=>e.routes.getPrintedQueryParams(t),pathNames:t=>e.routes.hasRoute(t)?a(t):void 0,admitsUndeclaredQuery:()=>tr(e.options.get().queryParamsMode)===`loose`,get reportDroppedQueryKey(){return e.eventBus.diagnosticListenerCount(C.DROPPED_QUERY_KEY)>0?i:void 0},get reportUndeclaredParamKey(){return e.eventBus.diagnosticListenerCount(C.UNDECLARED_PARAM_KEY)>0?r:void 0},get reportCodecRoundTrip(){return e.eventBus.diagnosticListenerCount(C.CODEC_ROUND_TRIP)>0?o:void 0}}}function Ns(e,t,n){let r=e=>n(e),i={logger:y(e.router).logger,getOptions:()=>e.options.get(),hasRoute:t=>e.routes.hasRoute(t),getQueryParams:t=>e.routes.getQueryParams(t),getMetaForState:t=>e.routes.getMetaForState(t),getState:()=>e.state.get(),buildNavigateState:(n,r,i)=>{_(y(e.router).checks,v[`navigate:state`],n,r);let a=U(t,n,r,i,{diagnoseUndeclared:!0});if(e.routes.getMetaForState(a.name)===void 0)return;g(`navigate`,a.name,a.path,t.queryNames(a.name));let o=fr(a,lr(a,t));return t.reportCodecRoundTrip?.(o),o},resolveDefault:()=>{let t=e.options.get(),n=y(e.router),i=or(t.defaultRoute,r),a=or(t.defaultParams,r),o=or(t.defaultSearch,r);return typeof t.defaultRoute==`function`&&_(n.checks,v[`navigateToDefault:route`],i),{route:i,params:a,search:o}},startTransition:t=>e.eventBus.sendNavigate(t),systemCommit:(t,n,r)=>e.eventBus.systemCommit({toState:t,fromState:n,opts:r},t.name),cancelNavigation:t=>{e.eventBus.sendCancelIfPossible(e.state.get(),t)},cancelIfInFlight:(t,n)=>{e.eventBus.sendCancelIfInFlight(t,e.state.get(),n)},dispatchAbort:(t,n)=>{e.eventBus.dispatchAbort(t,n)},bridgeExternalSignal:t=>{e.eventBus.bridgeExternalSignal(t)},canCommitTransition:t=>e.eventBus.canCommitTransition(t)?xo:void 0,sendTransitionDone:t=>{e.eventBus.sendComplete(t)},sendTransitionFail:(t,n,r)=>{e.eventBus.sendFail(t,n,r)},emitTransitionError:(t,n,r)=>{e.eventBus.emitTransitionError(t,n,r)},sendLeaveApprove:t=>{e.eventBus.sendLeaveApprove(t)},canNavigate:()=>e.eventBus.canBeginTransition(),isStarting:()=>e.eventBus.isStarting(),getLifecycleFunctions:()=>e.routeLifecycle.getFunctions(),warnNonBooleanGuard:(t,n)=>{e.eventBus.emitDiagnostic(C.GUARD_NON_BOOLEAN,t,n)},canDeactivateCurrent:(t,n,r)=>e.routeLifecycle.canNavigateTo(t,[],n,r,`navigateToNotFound`),isTransitioning:()=>e.eventBus.isTransitioning(),clearCanDeactivate:(t,n)=>{e.routeLifecycle.clearCanDeactivate(t,`external`)},hasLeaveListeners:()=>e.eventBus.hasLeaveListeners(),hasPreCommitListeners:()=>e.eventBus.hasPreCommitListeners(),awaitLeaveListeners:(t,n,r)=>e.eventBus.awaitLeaveListeners(t,n,r)};e.navigation.setDependencies(i)}function Ps(e){e.lifecycle.setDependencies({getOptions:()=>e.options.get(),navigateToState:(t,n)=>e.navigation.navigateToState(t,n),navigateToNotFound:t=>e.navigation.navigateToNotFound(t),matchPath:t=>e.routes.matchPath(t,e.options.get()),getRootPath:()=>e.routes.getStore().rootPath,completeStart:()=>{e.eventBus.sendStarted()},isIdle:()=>e.eventBus.isIdle()})}function Fs(e,t){e.state.setDependencies({port:()=>t,getUrlParams:t=>e.routes.getUrlParams(t)})}const Is=E(`router`,`navigateToNotFound`),Ls=E(`router`,`start`),Q=E(`router`);var Rs=class t{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;constructor(e=[],n={},r={}){let{logger:a,...o}=n,s=new Ts(a?Hn(a):void 0);this.#f=s,this.#p=e=>{Ea(e)||s.error(`router.start`,`Unexpected start error`,e)},ar.validateOptionsIsObject(n),jn(r);let d=Fn(e),f=os(o);this.#r=is(o),this.#e=new ar(f),this.#t=ls(f.limits),this.#n=us(f.limits);let p={emit:(e,...t)=>{this.#d.emitDiagnostic(e,...t)},listenerCount:e=>this.#d.diagnosticListenerCount(e)};this.#i=Xn(r,this.#t,p),this.#a=new mr;let h={emit:e=>{this.#d.emitTreeChanged(e)},subscribe:e=>this.#d.subscribeTreeChanged(e),listenerCount:()=>this.#d.treeChangedListenerCount(),isEmitting:()=>this.#d.isEmittingTreeChanged()};this.#o=new _a(d,_s(this.#e.get()),s,h),this.#s=new jr,this.#c=new Cr,this.#l=new bo,this.#u=new To;let g=Go();this.#a.setContext(g.getContext());let y=new xs({onListenerError:(e,t)=>{s.error(`router`,`Error in listener for ${e}:`,t)},onListenerWarn:(e,t)=>{s.warn(`router`,`Event "${e}" has ${t} listeners — possible memory leak`)}});this.#d=new ts({routerFSM:g,emitter:y});let b=new Map,S=new Map,C=e=>{let t=e.params,n=e.search;return{name:e.name,params:t==null?t:L(t),search:n==null?n:L(n)}},te=c(x.forwardState,(e,t,n)=>this.#o.forwardState(e,t,n),b,C,zs),ne=((e,t,n)=>{let r=te(e,t,n),a=r.name,o=r.params;i(`forwardState`,a,o,this.#o.getQueryParams(a),()=>a===e?"the `params` bag leaving the forwardState chain":`the \`params\` bag leaving the forwardState chain (forwarded here from "${e}")`);let s=r.search,c=s==null;return{name:a,params:L(o??k),search:c?s:L(s)}}),re=c(x.forwardState,(e,t,n)=>({name:e,params:t,search:n}),b,C,zs);this.#h=(e,t,n)=>{let r=re(e,t,n),i=r.params,a=r.search;return this.#o.buildPathFromIntent(r.name,i??k,a)},this.#m=m(x.start,e=>this.#u.start(e),b);let w={logger:s,makeState:(e,t,n,r)=>{u(w,`makeState`,e,t);let i=F(t);return _(w.checks,v[`makeState:state`],e,i,n,r),this.#a.makeState(e,i,n,r)},getMetaForState:e=>this.#o.getMetaForState(e),getDeclaredQueryNames:e=>this.#o.getQueryParams(e),forwardState:ne,buildStateResolved:(e,t)=>this.#o.buildStateResolved(e,t),buildPathResolved:(e,t,n)=>{let r=F(t);return _(w.checks,v[`buildPathResolved:entry`],t,n),_(w.checks,v[`buildPathResolved:params`],r),this.#o.buildPathFromIntent(e,r??k,n)},port:()=>this.#o.getPort(),matchPath:(e,t)=>(_(w.checks,v[`matchPath:entry`],e),this.#o.matchPath(e,t??this.#e.get())),getOptions:()=>this.#e.get(),getAdoptedOrigins:()=>this.#r,addEventListener:(e,t)=>{ee(w.isDisposed),Cn(e),wn(t);let n=this.#d.addEventListener(e,t,`addEventListener`);return ee(w.isDisposed),n},subscribeDiagnostic:(e,t)=>this.#d.subscribeDiagnostic(e,t),emitTransitionError:e=>{this.#d.emitTransitionError(void 0,this.#a.get(),e)},navigateToNotFound:e=>{if(this.#y(),e!==void 0&&typeof e!=`string`)throw Is.type`path must be a string, got ${typeof e}`;return this.#l.navigateToNotFound(e)},revalidateToNotFound:e=>(this.#b(),this.#l.revalidateToNotFound(e)),start:e=>this.start(e),navigateToState:(e,n)=>(ee(w.isDisposed),_(S,v[`navigateToState:entry`],e,n),this.#y(),t.#g(this.#l.navigateToState(e,n??ce))),interceptors:b,checks:S,setRootPath:e=>{_(S,v[`setRootPath:entry`],e),this.#o.setRootPath(e)},getRootPath:()=>this.#o.getStore().rootPath,getTree:()=>this.#o.getStore().tree,isDisposed:()=>this.#d.isDisposed(),dependenciesGetStore:()=>this.#i,getCloneState:()=>({options:{...this.#e.get()},dependencies:Yn(this.#i),pluginFactories:this.#c.getAll(),loggerConfig:s.getConfig(),limits:this.#t,limitKeys:this.#n}),routeGetStore:()=>this.#o.getStore(),getStateName:()=>this.#a.get()?.name,isTransitioning:()=>this.#d.isTransitioning(),systemCommit:(e,t,n)=>{this.#b();let r=e.name;if(r!==`@@router/UNKNOWN_ROUTE`&&!this.#o.hasRoute(r))throw I(new N(R.ROUTE_NOT_FOUND,{routeName:r}));return this.#d.systemCommit({toState:e,fromState:t,opts:n},r)},routerExtensions:[],contextClaimRecords:new Map};l(this,w),Es({router:this,options:this.#e,limits:this.#t,dependenciesStore:this.#i,state:this.#a,routes:this.#o,routeLifecycle:this.#s,plugins:this.#c,navigation:this.#l,lifecycle:this.#u,eventBus:this.#d}),this.isActiveRoute=this.isActiveRoute.bind(this),this.buildPath=this.buildPath.bind(this),this.getState=this.getState.bind(this),this.getPreviousState=this.getPreviousState.bind(this),this.areStatesEqual=this.areStatesEqual.bind(this),this.shouldUpdateNode=this.shouldUpdateNode.bind(this),this.isActive=this.isActive.bind(this),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this.dispose=this.dispose.bind(this),this.canNavigateTo=this.canNavigateTo.bind(this),this.usePlugin=this.usePlugin.bind(this),this.navigate=this.navigate.bind(this),this.navigateToDefault=this.navigateToDefault.bind(this),this.navigateToNotFound=this.navigateToNotFound.bind(this),this.subscribe=this.subscribe.bind(this),this.subscribeLeave=this.subscribeLeave.bind(this),this.isLeaveApproved=this.isLeaveApproved.bind(this);try{this.#o.flushPendingGuards()}catch(e){throw this.dispose(),e}}isActiveRoute(e,t,n,r,i){let a=y(this);return _(a.checks,v[`isActiveRoute:entry`],e,t,n,r,i),this.#d.diagnosticListenerCount(C.IS_ACTIVE_ROUTE)>0&&this.#d.emitDiagnostic(C.IS_ACTIVE_ROUTE,e,t),e===``?(a.logger.warn(`router.isActiveRoute`,`isActiveRoute("") called with empty string. Root node is not considered a parent of any route.`),!1):this.#o.isActiveRoute(e,t,n,r,i)}buildPath(e,t,n){let r=y(this);_(r.checks,v[`buildPath:entry`],e,t,n),this.#d.diagnosticListenerCount(C.BUILD_PATH)>0&&this.#d.emitDiagnostic(C.BUILD_PATH,e,t);let i=F(t);return _(r.checks,v[`buildPath:params`],i),this.#h(e,i??k,n)}getState(){return this.#a.get()}getPreviousState(){return this.#a.getPrevious()}areStatesEqual(e,t,n=!0){return _(y(this).checks,v[`areStatesEqual:entry`],e,t,n),this.#a.areStatesEqual(e,t,n)}shouldUpdateNode(e){return _(y(this).checks,v[`shouldUpdateNode:entry`],e),_a.shouldUpdateNode(e,e=>this.#o.getMetaForState(e))}isActive(){return this.#d.isActive()}start(e){let t=this.#_(e);return t.catch(this.#p),t}stop(){return this.#d.sendCancelIfPossible(this.#a.get()),!this.#d.isReady()&&!this.#d.isTransitioning()&&!this.#d.isStarting()||this.#d.sendStop(),this}dispose(){if(this.#d.isDisposed())return;this.#d.sendCancelIfPossible(this.#a.get()),(this.#d.isReady()||this.#d.isTransitioning())&&this.#d.sendStopForDispose(),this.#d.sendDispose(),this.#d.clearAll(),this.#c.disposeAll();let e=y(this);for(let t of e.routerExtensions)for(let e of t.keys)delete this[e];e.routerExtensions.length=0,e.contextClaimRecords.clear(),e.interceptors.clear(),e.checks.clear(),this.#o.clearRoutes(),this.#s.clearAll(),Jn(this.#i),this.#S()}canNavigateTo(t,n,r){let i=y(this);_(i.checks,v[`canNavigateTo:entry`],t,n,r);let a;try{a=F(n)}catch(e){return i.logger.warn(`router.canNavigateTo`,`Reading the params bag for route "${t}" threw; treating the route as unreachable.`,e),!1}if(_(i.checks,v[`canNavigateTo:params`],a),!this.#o.hasRoute(t)||e(n,this.#o.getQueryParams(t))!==void 0)return!1;let o=this.#o.getPort(),s;try{s=U(o,t,a??k,r)}catch(e){return i.logger.warn(`router.canNavigateTo`,`Resolving route "${t}" threw while answering the predicate; treating the route as unreachable.`,e),!1}let c;try{c=fr(s,lr(s,o))}catch{return!1}let l=this.#a.get(),{toDeactivate:u,toActivate:d}=da(c,l,e=>this.#o.getMetaForState(e));return this.#s.canNavigateTo(u,d,c,l,`canNavigateTo`)}usePlugin(...e){Cr.validateNotDisposed(this.#d.isDisposed());let t=e.filter(Boolean);if(t.length===0)return()=>{};let{checks:n}=y(this);if(S(n,v[`usePlugin:count`])&&_(n,v[`usePlugin:count`],this.#c.count(),new Set(t).size,this.#t.maxPlugins),S(n,v[`usePlugin:entry`])){let e=this.#c.getAll();for(let r of t)_(n,v[`usePlugin:entry`],r,e)}return this.#c.use(...t)}subscribe(e){return ts.validateSubscribeListener(e),this.#d.subscribe(e)}subscribeLeave(e){return ts.validateSubscribeLeaveListener(e),this.#d.subscribeLeave(e)}isLeaveApproved(){return this.#d.isLeaveApproved()}navigate(e,n,r,i){this.#y();let a=y(this),o,s,c,l;typeof e==`object`&&e?(o=e.name,s=e.params,c=e.search,l=n??ce):(o=e,s=n,c=r,l=i??ce),u(a,`navigate`,o,s),_(a.checks,v[`navigate:entry`],o,s,c,l);let d;try{d=F(s)}catch(e){return Promise.reject(e)}return _(a.checks,v[`navigate:params`],d),t.#g(this.#l.navigate(o,d??k,c,l))}navigateToDefault(e){this.#y();let n=y(this);return _(n.checks,v[`navigateToDefault:entry`],e),this.#d.emitDiagnostic(C.NAVIGATE_TO_DEFAULT),ee(n.isDisposed),t.#g(this.#l.navigateToDefault(e??ce))}navigateToNotFound(e){if(this.#y(),!this.#d.isActive())throw I(new N(R.ROUTER_NOT_STARTED));if(e!==void 0&&typeof e!=`string`)throw Is.type`path must be a string, got ${typeof e}`;if(e!==void 0)return this.#l.navigateToNotFound(e);let t=this.#a.get();if(t===void 0)throw Is.code(R.ROUTER_NOT_STARTED)`cannot derive the path before the start navigation commits — pass an explicit path`;return this.#l.navigateToNotFound(t.path)}static#g(e){return e instanceof Promise?e:Promise.resolve(e)}#_(e){if(!this.#d.canStart())return Promise.reject(vs);this.#y(),_(y(this).checks,v[`start:entry`],e),this.#d.sendStart();let t;try{let n=this.#m(e);t=typeof n?.then==`function`?n:Promise.reject(Ls.type`a \`start\` interceptor returned without calling next(). Every start interceptor must return \`next(path)\`.`)}catch(e){t=Promise.reject(e)}return t.then(e=>(this.#v(),e),e=>this.#x(e))}#v(){if(this.#d.isIdle())throw I(new N(R.TRANSITION_CANCELLED))}#y(){if(this.#f.isInCallback())throw Q.code(R.REENTRANT_NAVIGATION)`cannot start a navigation from inside the logger's callback — core logs from the middle of its own operations, and a navigation started there would run inside the one being logged. Defer it: queueMicrotask(() => router.navigate(...)).`;if(this.#d.isProcessing())throw Q.code(R.REENTRANT_NAVIGATION)`cannot start a navigation from inside a router event listener or an abort listener of a navigation's signal — the nested navigation would commit a state the outer one overwrites. Defer it: queueMicrotask(() => router.navigate(...)), await the current transition, or use an async listener.`;if(this.#l.isPreparing())throw Q.code(R.REENTRANT_NAVIGATION)`cannot start a navigation from inside a forwardState interceptor, a route's encodeParams or dynamic forwardTo callback, or a defaultRoute/defaultParams/defaultSearch option callback — they run while a navigation is being prepared, before it is announced. Defer it: queueMicrotask(() => router.navigate(...)).`;if(this.#l.isCommittingNotFound())throw Q.code(R.REENTRANT_NAVIGATION)`cannot start a navigation from inside a canDeactivate guard that navigateToNotFound() consults — the 404 commits from the state read before the guard was asked. A guard does not redirect: return false to stay, or defer the navigation: queueMicrotask(() => router.navigate(...)).`;if(this.#o.isRevalidating())throw Q.code(R.REENTRANT_NAVIGATION)`cannot start a navigation from inside replace()'s revalidation — the revalidation would then defer to a commit that may never happen. Defer it: queueMicrotask(() => router.navigate(...)).`}#b(){this.#o.isRevalidating()||this.#y()}#x(e){throw this.#v(),this.#d.isReady()&&this.#a.get()===void 0?this.#d.sendStop():this.#d.isStarting()&&this.#d.sendFail(void 0,e),e}#S(){this.navigate=$,this.navigateToDefault=$,this.navigateToNotFound=$,this.start=$,this.stop=$,this.usePlugin=$,this.subscribe=$,this.subscribeLeave=$,this.canNavigateTo=$}};function $(){throw Q.code(R.ROUTER_DISPOSED)`this router is disposed — dispose() is terminal and swapped every method to refuse`}function zs(e,t,n){return[e,F(t),F(n)]}export{Kn as A,ln as B,Xr as C,Jn as D,U as E,On as F,Tn as I,Fn as L,Nn as M,kn as N,qn as O,En as P,Pn as R,Wr as S,lr as T,hi as _,Ni as a,Rr as b,Mi as c,Ai as d,Fi as f,Ri as g,mi as h,zi as i,Dn as j,Yn as k,ki as l,Vi as m,da as n,ji as o,Ii as p,_i as r,Di as s,Rs as t,Oi as u,ri as v,fr as w,Gr as x,ti as y,cn as z};
|
|
2
|
-
//# sourceMappingURL=Router-DYuv6lN0.mjs.map
|