@jskit-ai/assistant-voice 0.1.1 → 0.1.2

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.
Files changed (47) hide show
  1. package/examples/conversation/package.json +8 -8
  2. package/package.json +1 -1
  3. package/examples/conversation/dist/assets/error-DOwCrGXH.js +0 -1
  4. package/examples/conversation/dist/assets/index-Bq1DwQwF.js +0 -90
  5. package/examples/conversation/dist/assets/index-Bw7_l3Cu.css +0 -1
  6. package/examples/conversation/dist/assets/placement-CUwf_TAl.js +0 -1
  7. package/examples/conversation/dist/assets/placementTopology-CUwf_TAl.js +0 -1
  8. package/examples/conversation/dist/index.html +0 -3
  9. package/examples/conversation/node_modules/.vite/deps/@jskit-ai_kernel_client_moduleBootstrap.js +0 -824
  10. package/examples/conversation/node_modules/.vite/deps/@jskit-ai_kernel_client_moduleBootstrap.js.map +0 -1
  11. package/examples/conversation/node_modules/.vite/deps/@mdi_js.js +0 -7450
  12. package/examples/conversation/node_modules/.vite/deps/@mdi_js.js.map +0 -1
  13. package/examples/conversation/node_modules/.vite/deps/@tanstack_vue-query.js +0 -3965
  14. package/examples/conversation/node_modules/.vite/deps/@tanstack_vue-query.js.map +0 -1
  15. package/examples/conversation/node_modules/.vite/deps/VTooltip-Nwckus73.js +0 -2311
  16. package/examples/conversation/node_modules/.vite/deps/VTooltip-Nwckus73.js.map +0 -1
  17. package/examples/conversation/node_modules/.vite/deps/_metadata.json +0 -110
  18. package/examples/conversation/node_modules/.vite/deps/defineComponent-Bx_4rnHZ.js +0 -710
  19. package/examples/conversation/node_modules/.vite/deps/defineComponent-Bx_4rnHZ.js.map +0 -1
  20. package/examples/conversation/node_modules/.vite/deps/dist-CUIjXXPV.js +0 -3878
  21. package/examples/conversation/node_modules/.vite/deps/dist-CUIjXXPV.js.map +0 -1
  22. package/examples/conversation/node_modules/.vite/deps/hotkey-parsing-B5h5TiMG.js +0 -1214
  23. package/examples/conversation/node_modules/.vite/deps/hotkey-parsing-B5h5TiMG.js.map +0 -1
  24. package/examples/conversation/node_modules/.vite/deps/icons-DPtxVIU0.js +0 -98
  25. package/examples/conversation/node_modules/.vite/deps/icons-DPtxVIU0.js.map +0 -1
  26. package/examples/conversation/node_modules/.vite/deps/json-rest-schema.js +0 -2071
  27. package/examples/conversation/node_modules/.vite/deps/json-rest-schema.js.map +0 -1
  28. package/examples/conversation/node_modules/.vite/deps/package.json +0 -3
  29. package/examples/conversation/node_modules/.vite/deps/pinia.js +0 -1453
  30. package/examples/conversation/node_modules/.vite/deps/pinia.js.map +0 -1
  31. package/examples/conversation/node_modules/.vite/deps/socket__io-client.js +0 -3899
  32. package/examples/conversation/node_modules/.vite/deps/socket__io-client.js.map +0 -1
  33. package/examples/conversation/node_modules/.vite/deps/theme-BSn2V8xv.js +0 -1301
  34. package/examples/conversation/node_modules/.vite/deps/theme-BSn2V8xv.js.map +0 -1
  35. package/examples/conversation/node_modules/.vite/deps/vue-router.js +0 -2989
  36. package/examples/conversation/node_modules/.vite/deps/vue-router.js.map +0 -1
  37. package/examples/conversation/node_modules/.vite/deps/vue.js +0 -2
  38. package/examples/conversation/node_modules/.vite/deps/vue.runtime.esm-bundler-DWdvffrK.js +0 -8890
  39. package/examples/conversation/node_modules/.vite/deps/vue.runtime.esm-bundler-DWdvffrK.js.map +0 -1
  40. package/examples/conversation/node_modules/.vite/deps/vuetify.js +0 -413
  41. package/examples/conversation/node_modules/.vite/deps/vuetify.js.map +0 -1
  42. package/examples/conversation/node_modules/.vite/deps/vuetify_components.js +0 -25370
  43. package/examples/conversation/node_modules/.vite/deps/vuetify_components.js.map +0 -1
  44. package/examples/conversation/node_modules/.vite/deps/vuetify_directives.js +0 -132
  45. package/examples/conversation/node_modules/.vite/deps/vuetify_directives.js.map +0 -1
  46. package/examples/conversation/node_modules/.vite/deps/vuetify_iconsets_mdi-svg.js +0 -70
  47. package/examples/conversation/node_modules/.vite/deps/vuetify_iconsets_mdi-svg.js.map +0 -1
@@ -1,2989 +0,0 @@
1
- import { Kn as ref, Nt as onDeactivated, Ot as nextTick, U as computed, Ut as provide, Wn as reactive, Yn as shallowRef, _n as watchEffect, gn as watch, kt as onActivated, nr as unref, nt as defineComponent, pt as h, qn as shallowReactive, ut as getCurrentInstance, xt as inject, zt as onUnmounted } from "./vue.runtime.esm-bundler-DWdvffrK.js";
2
- import { n as createConsoleReporter, r as defineDiagnostics, t as setupDevToolsPlugin } from "./dist-CUIjXXPV.js";
3
- //#region ../../../../node_modules/vue-router/dist/useApi-BPuI6ZR9.js
4
- /*!
5
- * vue-router v5.3.1
6
- * (c) 2026 Eduardo San Martin Morote
7
- * @license MIT
8
- */
9
- /**
10
- * Checks if a path is absolute, meaning it starts with a `/`.
11
- *
12
- * @param path - path to check
13
- *
14
- * @internal
15
- */
16
- var isAbsolutePath = (path) => path.startsWith("/");
17
- /**
18
- * Allows differentiating lazy components from functional components and vue-class-component
19
- * @internal
20
- *
21
- * @param component
22
- */
23
- function isRouteComponent(component) {
24
- return typeof component === "object" || "displayName" in component || "props" in component || "__vccOpts" in component;
25
- }
26
- function isESModule(obj) {
27
- return obj.__esModule || obj[Symbol.toStringTag] === "Module" || obj.default && isRouteComponent(obj.default);
28
- }
29
- var assign = Object.assign;
30
- function applyToParams(fn, params) {
31
- const newParams = {};
32
- for (const key in params) {
33
- const value = params[key];
34
- newParams[key] = isArray(value) ? value.map(fn) : fn(value);
35
- }
36
- return newParams;
37
- }
38
- var noop = () => {};
39
- /**
40
- * Typesafe alternative to Array.isArray
41
- * https://github.com/microsoft/TypeScript/pull/48228
42
- *
43
- * @internal
44
- */
45
- var isArray = Array.isArray;
46
- function mergeOptions(defaults, partialOptions) {
47
- const options = {};
48
- for (const key in defaults) options[key] = key in partialOptions ? partialOptions[key] : defaults[key];
49
- return options;
50
- }
51
- var NavigationFailureSymbol = Symbol("navigation failure");
52
- /**
53
- * Enumeration with all possible types for navigation failures. Can be passed to
54
- * {@link isNavigationFailure} to check for specific failures.
55
- */
56
- var NavigationFailureType = /* @__PURE__ */ function(NavigationFailureType) {
57
- /**
58
- * An aborted navigation is a navigation that failed because a navigation
59
- * guard returned `false` or called `next(false)`
60
- */
61
- NavigationFailureType[NavigationFailureType["aborted"] = 4] = "aborted";
62
- /**
63
- * A cancelled navigation is a navigation that failed because a more recent
64
- * navigation finished started (not necessarily finished).
65
- */
66
- NavigationFailureType[NavigationFailureType["cancelled"] = 8] = "cancelled";
67
- /**
68
- * A duplicated navigation is a navigation that failed because it was
69
- * initiated while already being at the exact same location.
70
- */
71
- NavigationFailureType[NavigationFailureType["duplicated"] = 16] = "duplicated";
72
- return NavigationFailureType;
73
- }({});
74
- var ErrorTypeMessages = {
75
- [1]({ location, currentLocation }) {
76
- return `No match for\n ${JSON.stringify(location)}${currentLocation ? "\nwhile being at\n" + JSON.stringify(currentLocation) : ""}`;
77
- },
78
- [2]({ from, to }) {
79
- return `Redirected from "${from.fullPath}" to "${stringifyRoute(to)}" via a navigation guard.`;
80
- },
81
- [4]({ from, to }) {
82
- return `Navigation aborted from "${from.fullPath}" to "${to.fullPath}" via a navigation guard.`;
83
- },
84
- [8]({ from, to }) {
85
- return `Navigation cancelled from "${from.fullPath}" to "${to.fullPath}" with a new navigation.`;
86
- },
87
- [16]({ from, to: _to }) {
88
- return `Avoided redundant navigation to current location: "${from.fullPath}".`;
89
- }
90
- };
91
- /**
92
- * Creates a typed NavigationFailure object.
93
- * @internal
94
- * @param type - NavigationFailureType
95
- * @param params - { from, to }
96
- */
97
- function createRouterError(type, params) {
98
- return assign(new Error(ErrorTypeMessages[type](params)), {
99
- type,
100
- [NavigationFailureSymbol]: true
101
- }, params);
102
- }
103
- function isNavigationFailure(error, type) {
104
- return error instanceof Error && NavigationFailureSymbol in error && (type == null || !!(error.type & type));
105
- }
106
- var propertiesToLog = [
107
- "params",
108
- "query",
109
- "hash"
110
- ];
111
- /**
112
- * Stringifies a raw location for display in dev warnings.
113
- *
114
- * @internal
115
- */
116
- function stringifyRoute(to) {
117
- if (!to || typeof to === "string") return to;
118
- if (to.path != null) return to.path;
119
- const location = {};
120
- for (const key of propertiesToLog) if (key in to) location[key] = to[key];
121
- return JSON.stringify(location, null, 2);
122
- }
123
- /**
124
- * Runtime diagnostics catalog for Vue Router.
125
- *
126
- * Every entry has a stable `VUE_ROUTER_R####` code, a `why` that states the problem
127
- * (the diagnosis only, never the remedy) and a `fix` that states the remedy
128
- * (only, never the diagnosis). They are complementary: the reporter prints
129
- * both, so neither repeats the other. The diagnosis substrings asserted by the
130
- * warning tests stay in `why`. All call sites stay behind the existing `__DEV__` (or
131
- * `process.env.NODE_ENV !== 'production'`) guards and remain bare expression
132
- * statements so they tree-shake out of production builds.
133
- *
134
- * Codes are permanent: never rename or reuse one.
135
- * - `VUE_ROUTER_R0###` core runtime warnings
136
- * - `VUE_ROUTER_R1###` experimental data-loaders
137
- */
138
- var diagnostics = /*#__PURE__*/ defineDiagnostics({
139
- reporters: [/*#__PURE__*/ createConsoleReporter()],
140
- codes: {
141
- VUE_ROUTER_R0001: {
142
- why: (p) => `Parent route "${p.name}" not found when adding child route`,
143
- fix: "Add the parent route before its children, or check the parent name for typos.",
144
- docs: "https://router.vuejs.org/guide/advanced/dynamic-routing.html#Adding-nested-routes"
145
- },
146
- VUE_ROUTER_R0002: {
147
- why: (p) => `Cannot remove non-existent route "${p.name}"`,
148
- fix: "Check the route name; it may already have been removed or was never added.",
149
- docs: "https://router.vuejs.org/guide/advanced/dynamic-routing.html#Removing-routes"
150
- },
151
- VUE_ROUTER_R0003: {
152
- why: (p) => `Location "${stringifyRoute(p.location)}" resolved to "${p.href}". A resolved location cannot start with multiple slashes.`,
153
- fix: "Remove the leading slashes from the location or fix the route configuration."
154
- },
155
- VUE_ROUTER_R0004: {
156
- why: (p) => `No match found for location with path "${stringifyRoute(p.path)}"`,
157
- fix: "Add a route matching this path or check for typos in the location.",
158
- docs: "https://router.vuejs.org/guide/essentials/dynamic-matching.html#Catch-all-404-Not-found-Route"
159
- },
160
- VUE_ROUTER_R0005: {
161
- why: (p) => `router.resolve() was passed an invalid location. This will fail in production.\nLocation: ${stringifyRoute(p.rawLocation)}`,
162
- fix: "Pass a valid route location: a string path or an object with `path` or `name`."
163
- },
164
- VUE_ROUTER_R0006: {
165
- why: (p) => `Path "${p.path}" was passed with params but they will be ignored because a "path" was passed.`,
166
- fix: "Use a named route `{ name, params }` instead of `{ path, params }`.",
167
- docs: "https://router.vuejs.org/guide/essentials/navigation.html#Navigate-to-a-different-location"
168
- },
169
- VUE_ROUTER_R0007: {
170
- why: (p) => `A \`hash\` should always start with the character "#" but received "${p.hash}".`,
171
- fix: (p) => `Prepend "#" to the hash in your route location: use "#${p.hash}".`
172
- },
173
- VUE_ROUTER_R0008: {
174
- why: (p) => `Invalid redirect found:\n${p.target}\n when navigating to "${p.to}".\nThis will break in production.`,
175
- fix: "A redirect must resolve to a location with a `name` or `path`; return one of those (or a string path) from `redirect`.",
176
- docs: "https://router.vuejs.org/guide/essentials/redirect-and-alias.html#Redirect"
177
- },
178
- VUE_ROUTER_R0009: {
179
- why: (p) => `Detected a possibly infinite redirection in a navigation guard when going from "${p.from}" to "${p.to}". Aborting to avoid a Stack Overflow. This might break in production if not fixed.`,
180
- fix: "A guard is returning a new location on every call; make that return conditional so it only redirects when actually needed.",
181
- docs: "https://router.vuejs.org/guide/advanced/navigation-guards.html#Global-Before-Guards"
182
- },
183
- VUE_ROUTER_R0010: {
184
- why: "Uncaught error during route navigation",
185
- fix: "Register an error handler with `router.onError()` to handle navigation errors."
186
- },
187
- VUE_ROUTER_R0011: {
188
- why: "Unexpected error when starting the router:",
189
- fix: "Inspect the actual cause; a navigation guard or async component likely threw during the initial navigation."
190
- },
191
- VUE_ROUTER_R0020: {
192
- why: (p) => `No active route record was found when calling \`${p.fn}()\`. Maybe you called it inside of App.vue?`,
193
- fix: "Call it from a component rendered inside <router-view> (a page component or one of its children), not from App.vue.",
194
- docs: "https://router.vuejs.org/guide/advanced/composition-api.html#Navigation-Guards"
195
- },
196
- VUE_ROUTER_R0021: {
197
- why: "No active route record was found when reactivating component with navigation guard. This is likely a bug in vue-router.",
198
- fix: "Report with a minimal reproduction at https://github.com/vuejs/router/issues/new/choose."
199
- },
200
- VUE_ROUTER_R0022: {
201
- why: (p) => `${p.fn}() was called outside of component setup but it must be called at the top of a setup function`,
202
- fix: "Call it synchronously at the top of `setup()`, before any `await`.",
203
- docs: "https://router.vuejs.org/guide/advanced/composition-api.html#Navigation-Guards"
204
- },
205
- VUE_ROUTER_R0023: {
206
- why: (p) => `The "next" callback was never called inside of ${p.name ? `"${p.name}"` : ""}:\n${p.guard}`,
207
- fix: "Make sure `next()` runs on every branch, including early returns and async paths, or drop the `next` parameter and return the value instead.",
208
- docs: "https://router.vuejs.org/guide/advanced/navigation-guards.html#Optional-third-argument-next"
209
- },
210
- VUE_ROUTER_R0024: {
211
- why: (p) => `The "next" callback was called more than once in one navigation guard when going from "${p.from}" to "${p.to}". This will fail in production.`,
212
- fix: "Call `next()` exactly once per guard: remove the extra call, or migrate to returning the value you passed to `next()`.",
213
- docs: "https://router.vuejs.org/guide/advanced/navigation-guards.html#Optional-third-argument-next"
214
- },
215
- VUE_ROUTER_R0025: {
216
- why: "The `next()` callback in navigation guards is deprecated.",
217
- fix: "Return the value instead: `next()` becomes `return`, `next(false)` becomes `return false`, `next(\"/path\")` becomes `return \"/path\"`.",
218
- docs: "https://router.vuejs.org/guide/advanced/navigation-guards.html#Optional-third-argument-next"
219
- },
220
- VUE_ROUTER_R0026: {
221
- why: (p) => `Record with path "${p.path}" is either missing a "component(s)" or "children" property.`,
222
- fix: "Add a `component`, `components`, or `children` to the route record.",
223
- docs: "https://router.vuejs.org/guide/essentials/nested-routes.html"
224
- },
225
- VUE_ROUTER_R0027: {
226
- why: (p) => `Component "${p.name}" in record with path "${p.path}" is not a valid component. Received "${p.received}".`,
227
- fix: "Pass a component or a function returning a Promise that resolves to one."
228
- },
229
- VUE_ROUTER_R0028: {
230
- why: (p) => `Component "${p.name}" in record with path "${p.path}" is a Promise instead of a function that returns a Promise. This will break in production if not fixed.`,
231
- fix: `Defer the import in an arrow function so it loads lazily: write "() => import('./MyPage.vue')", not "import('./MyPage.vue')".`,
232
- docs: "https://router.vuejs.org/guide/advanced/lazy-loading.html"
233
- },
234
- VUE_ROUTER_R0029: {
235
- why: (p) => `Component "${p.name}" in record with path "${p.path}" is defined using "defineAsyncComponent()".`,
236
- fix: `Drop the wrapper and pass "() => import('./MyPage.vue')" directly; the router handles lazy components itself.`,
237
- docs: "https://router.vuejs.org/guide/advanced/lazy-loading.html#Relationship-to-async-components"
238
- },
239
- VUE_ROUTER_R0030: {
240
- why: (p) => `Component "${p.name}" in record with path "${p.path}" is a function that does not return a Promise. This will break in production if not fixed.`,
241
- fix: "Return a dynamic import (`() => import(\"./MyPage.vue\")`) from the function, or add a `displayName` if it is a functional component.",
242
- docs: "https://router.vuejs.org/guide/advanced/lazy-loading.html"
243
- },
244
- VUE_ROUTER_R0040: {
245
- why: (p) => `Because "${p.el}" starts with "#", scrollBehavior resolves it as an element id via document.getElementById("${p.el.slice(1)}"), not as a CSS selector. No element has that id, but "${p.el}" does match an element with document.querySelector().`,
246
- fix: (p) => `Resolve the element yourself and return the node: el: document.querySelector('${p.el}').`,
247
- docs: "https://router.vuejs.org/guide/advanced/scroll-behavior.html"
248
- },
249
- VUE_ROUTER_R0041: {
250
- why: (p) => `The selector "${p.el}" is invalid. See https://mathiasbynens.be/notes/css-escapes or CSS.escape (https://developer.mozilla.org/en-US/docs/Web/API/CSS/escape) for the escaping rules.`,
251
- fix: "Build an id selector as `#${CSS.escape(id)}` so special characters in the id are escaped.",
252
- docs: "https://router.vuejs.org/guide/advanced/scroll-behavior.html"
253
- },
254
- VUE_ROUTER_R0042: {
255
- why: (p) => `Couldn't find element using selector "${p.el}" returned by scrollBehavior.`,
256
- fix: "Return a selector that matches an existing element, or guard against missing elements.",
257
- docs: "https://router.vuejs.org/guide/advanced/scroll-behavior.html"
258
- },
259
- VUE_ROUTER_R0050: {
260
- why: (p) => {
261
- let to;
262
- try {
263
- to = p.to === void 0 ? "undefined" : JSON.stringify(p.to);
264
- } catch {
265
- to = String(p.to);
266
- }
267
- return `Invalid value for prop "to" in useLink()\n- to: ${to}`;
268
- },
269
- fix: "Pass a valid route location (a string path or an object) to the \"to\" prop."
270
- },
271
- VUE_ROUTER_R0060: {
272
- why: (p) => `<router-view> can no longer be used directly inside <${p.comp}>.`,
273
- fix: (p) => `Wrap the slot's resolved component with <${p.comp}> instead of nesting <router-view> in it:\n\n<router-view v-slot="{ Component }">\n <${p.comp}>\n <component :is="Component" />\n </${p.comp}>\n</router-view>`,
274
- docs: "https://router.vuejs.org/guide/advanced/router-view-slot.html#KeepAlive-Transition"
275
- },
276
- VUE_ROUTER_R0070: {
277
- why: (p) => `Cannot resolve a relative location without an absolute path. Trying to resolve "${p.to}" from "${p.from}".`,
278
- fix: (p) => `Resolve from an absolute \`from\` path that starts with "/", e.g. "/${p.from}".`
279
- },
280
- VUE_ROUTER_R0080: {
281
- why: (p) => `Error decoding "${p.text}". Using original value`,
282
- fix: "Ensure the value is correctly percent-encoded."
283
- },
284
- VUE_ROUTER_R0090: {
285
- why: (p) => `Found duplicated params with name "${p.name}" for path "${p.path}". Only the last one will be available on "$route.params".`,
286
- fix: "Give each param a unique name within the path.",
287
- docs: "https://router.vuejs.org/guide/essentials/route-matching-syntax.html"
288
- },
289
- VUE_ROUTER_R0100: {
290
- why: (p) => `Discarded invalid param(s) "${p.params}" when navigating.` + p.inherited + ` See https://github.com/vuejs/router/commit/e887570 for more details.`,
291
- fix: "Only pass params that exist on the target route."
292
- },
293
- VUE_ROUTER_R0101: {
294
- why: (p) => `The Matcher cannot resolve relative paths but received "${p.path}". Unless you directly called \`matcher.resolve("${p.path}")\`, this is probably a bug in vue-router. Please open an issue at https://github.com/vuejs/router/issues/new/choose.`,
295
- fix: "Pass an absolute path (starting with \"/\") to the matcher."
296
- },
297
- VUE_ROUTER_R0102: {
298
- why: (p) => `Alias "${p.alias}" and the original record: "${p.original}" must have the exact same param named "${p.name}"`,
299
- fix: "Use the same param names in the alias as in the original route.",
300
- docs: "https://router.vuejs.org/guide/essentials/redirect-and-alias.html#Alias"
301
- },
302
- VUE_ROUTER_R0103: {
303
- why: (p) => `The route named "${p.name}" has a child without a name, an empty path, and no children. Using that name won't render the empty path child, so this is probably a mistake.`,
304
- fix: "Move the `name` onto the empty-path child; or, if intentional, give the child its own name to silence this.",
305
- docs: "https://router.vuejs.org/guide/essentials/nested-routes.html#Nested-Named-Routes"
306
- },
307
- VUE_ROUTER_R0104: {
308
- why: (p) => `Absolute path "${p.path}" must have the exact same param named "${p.name}" as its parent "${p.parent}".`,
309
- fix: "Include the parent route params in the absolute child path.",
310
- docs: "https://router.vuejs.org/guide/essentials/nested-routes.html"
311
- },
312
- VUE_ROUTER_R0105: {
313
- why: (p) => `Finding ancestor route "${p.ancestor}" failed for "${p.record}"`,
314
- fix: "Report a reproduction at https://github.com/vuejs/router/issues/new/choose."
315
- },
316
- VUE_ROUTER_R0110: {
317
- why: `A hash base must end with a "#"`,
318
- fix: (p) => `Append "#" to the "base" argument passed to "createWebHashHistory()": "${p.base}" should be "${p.suggestion}".`
319
- },
320
- VUE_ROUTER_R0120: {
321
- why: "Error with push/replace State",
322
- fix: "The browser rejected the history API call; check for cross-origin or rate-limit issues."
323
- },
324
- VUE_ROUTER_R0121: {
325
- why: "history.state seems to have been manually replaced without preserving the necessary values.\nYou can find more information at https://router.vuejs.org/guide/migration/#Usage-of-history-state",
326
- fix: "Merge the router's state into your own when calling it manually: `history.replaceState({ ...history.state, ...yourState }, '', url)`.",
327
- docs: "https://router.vuejs.org/guide/migration.html#Usage-of-history-state"
328
- },
329
- VUE_ROUTER_R1001: {
330
- why: (p) => `Data loader "${String(p.key)}" has a different parent than the current context. This shouldn't be happening.`,
331
- fix: "Report a bug with a minimal reproduction at https://github.com/vuejs/router/."
332
- },
333
- VUE_ROUTER_R1002: {
334
- why: "Returning a NavigationResult is deprecated.",
335
- fix: "Replace `return new NavigationResult(to)` with `reroute(to)`, which throws internally to reroute.",
336
- docs: "https://router.vuejs.org/data-loaders/navigation-aware.html#Controlling-the-navigation-with-reroute-"
337
- },
338
- VUE_ROUTER_R1003: {
339
- why: (p) => `Loader "${p.key}"'s "commit()" was called but there is no staged data.`,
340
- fix: "Ensure the loader resolved before calling `commit()`.",
341
- docs: "https://router.vuejs.org/data-loaders/defining-loaders.html#Delaying-data-updates-with-commit"
342
- },
343
- VUE_ROUTER_R1004: {
344
- why: (p) => "A loader returned a NavigationResult but is not registered on the route." + p.key,
345
- fix: "Export the loader from the page component so it gets registered, e.g. `export const useUserData = defineLoader(...)`.",
346
- docs: "https://router.vuejs.org/data-loaders/organization.html"
347
- },
348
- VUE_ROUTER_R1005: {
349
- why: (p) => `Data loader "${p.key}" has itself as parent. This shouldn't be happening.`,
350
- fix: "Report a bug with a minimal reproduction at https://github.com/vuejs/router/."
351
- },
352
- VUE_ROUTER_R1006: {
353
- why: (p) => `A query was defined with the same key as the loader "[${p.key}]".\nSee https://pinia-colada.esm.dev/#TODO`,
354
- fix: "If the key is meant to match, use the data loader directly; otherwise rename the `useQuery()` key so it no longer collides.",
355
- docs: "https://router.vuejs.org/data-loaders/colada.html"
356
- },
357
- VUE_ROUTER_R1007: {
358
- why: "Data Loader was setup twice.",
359
- fix: "Register `DataLoaderPlugin` a single time via `app.use()`.",
360
- docs: "https://router.vuejs.org/data-loaders.html#Installation"
361
- },
362
- VUE_ROUTER_R1008: {
363
- why: "Data Loader is experimental and subject to breaking changes in the future.",
364
- docs: "https://router.vuejs.org/data-loaders.html"
365
- },
366
- VUE_ROUTER_R1009: {
367
- why: "Returning a NavigationResult from a loader is deprecated.",
368
- fix: "Call `reroute(to)` inside the loader instead of returning `new NavigationResult(to)`; it throws internally to reroute.",
369
- docs: "https://router.vuejs.org/data-loaders/navigation-aware.html#Controlling-the-navigation-with-reroute-"
370
- }
371
- }
372
- });
373
- /**
374
- * RouteRecord being rendered by the closest ancestor Router View. Used for
375
- * `onBeforeRouteUpdate` and `onBeforeRouteLeave`. rvlm stands for Router View
376
- * Location Matched
377
- *
378
- * @internal
379
- */
380
- var matchedRouteKey = Symbol("router view location matched");
381
- /**
382
- * Allows overriding the router view depth to control which component in
383
- * `matched` is rendered. rvd stands for Router View Depth
384
- *
385
- * @internal
386
- */
387
- var viewDepthKey = Symbol("router view depth");
388
- /**
389
- * Allows overriding the router instance returned by `useRouter` in tests. r
390
- * stands for router
391
- *
392
- * @internal
393
- */
394
- var routerKey = Symbol("router");
395
- /**
396
- * Allows overriding the current route returned by `useRoute` in tests. rl
397
- * stands for route location
398
- *
399
- * @internal
400
- */
401
- var routeLocationKey = Symbol("route location");
402
- /**
403
- * Allows overriding the current route used by router-view. Internally this is
404
- * used when the `route` prop is passed.
405
- *
406
- * @internal
407
- */
408
- var routerViewLocationKey = Symbol("router view location");
409
- /**
410
- * Returns the router instance. Equivalent to using `$router` inside
411
- * templates.
412
- */
413
- function useRouter() {
414
- return inject(routerKey);
415
- }
416
- /**
417
- * Returns the current route location. Equivalent to using `$route` inside
418
- * templates.
419
- */
420
- function useRoute(_name) {
421
- return inject(routeLocationKey);
422
- }
423
- //#endregion
424
- //#region ../../../../node_modules/vue-router/dist/devtools-CN5uWJaH.js
425
- /*!
426
- * vue-router v5.3.1
427
- * (c) 2026 Eduardo San Martin Morote
428
- * @license MIT
429
- */
430
- var isBrowser = typeof document !== "undefined";
431
- /**
432
- * Encoding Rules (␣ = Space)
433
- * - Path: ␣ " < > # ? { }
434
- * - Query: ␣ " < > # & =
435
- * - Hash: ␣ " < > `
436
- *
437
- * On top of that, the RFC3986 (https://tools.ietf.org/html/rfc3986#section-2.2)
438
- * defines some extra characters to be encoded. Most browsers do not encode them
439
- * in encodeURI https://github.com/whatwg/url/issues/369, so it may be safer to
440
- * also encode `!'()*`. Leaving un-encoded only ASCII alphanumeric(`a-zA-Z0-9`)
441
- * plus `-._~`. This extra safety should be applied to query by patching the
442
- * string returned by encodeURIComponent encodeURI also encodes `[\]^`. `\`
443
- * should be encoded to avoid ambiguity. Browsers (IE, FF, C) transform a `\`
444
- * into a `/` if directly typed in. The _backtick_ (`````) should also be
445
- * encoded everywhere because some browsers like FF encode it when directly
446
- * written while others don't. Safari and IE don't encode ``"<>{}``` in hash.
447
- */
448
- var HASH_RE = /#/g;
449
- var AMPERSAND_RE = /&/g;
450
- var SLASH_RE = /\//g;
451
- var EQUAL_RE = /=/g;
452
- var IM_RE = /\?/g;
453
- var PLUS_RE = /\+/g;
454
- /**
455
- * NOTE: It's not clear to me if we should encode the + symbol in queries, it
456
- * seems to be less flexible than not doing so and I can't find out the legacy
457
- * systems requiring this for regular requests like text/html. In the standard,
458
- * the encoding of the plus character is only mentioned for
459
- * application/x-www-form-urlencoded
460
- * (https://url.spec.whatwg.org/#urlencoded-parsing) and most browsers seems lo
461
- * leave the plus character as is in queries. To be more flexible, we allow the
462
- * plus character on the query, but it can also be manually encoded by the user.
463
- *
464
- * Resources:
465
- * - https://url.spec.whatwg.org/#urlencoded-parsing
466
- * - https://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20
467
- */
468
- var ENC_BRACKET_OPEN_RE = /%5B/g;
469
- var ENC_BRACKET_CLOSE_RE = /%5D/g;
470
- var ENC_CARET_RE = /%5E/g;
471
- var ENC_BACKTICK_RE = /%60/g;
472
- var ENC_CURLY_OPEN_RE = /%7B/g;
473
- var ENC_PIPE_RE = /%7C/g;
474
- var ENC_CURLY_CLOSE_RE = /%7D/g;
475
- var ENC_SPACE_RE = /%20/g;
476
- /**
477
- * Encode characters that need to be encoded on the path, search and hash
478
- * sections of the URL.
479
- *
480
- * @internal
481
- * @param text - string to encode
482
- * @returns encoded string
483
- */
484
- function commonEncode(text) {
485
- return text == null ? "" : encodeURI("" + text).replace(ENC_PIPE_RE, "|").replace(ENC_BRACKET_OPEN_RE, "[").replace(ENC_BRACKET_CLOSE_RE, "]");
486
- }
487
- /**
488
- * Encode characters that need to be encoded on the hash section of the URL.
489
- *
490
- * @param text - string to encode
491
- * @returns encoded string
492
- */
493
- function encodeHash(text) {
494
- return commonEncode(text).replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
495
- }
496
- /**
497
- * Encode characters that need to be encoded query values on the query
498
- * section of the URL.
499
- *
500
- * @param text - string to encode
501
- * @returns encoded string
502
- */
503
- function encodeQueryValue(text) {
504
- return commonEncode(text).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
505
- }
506
- /**
507
- * Like `encodeQueryValue` but also encodes the `=` character.
508
- *
509
- * @param text - string to encode
510
- */
511
- function encodeQueryKey(text) {
512
- return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
513
- }
514
- /**
515
- * Encode characters that need to be encoded on the path section of the URL.
516
- *
517
- * @param text - string to encode
518
- * @returns encoded string
519
- */
520
- function encodePath(text) {
521
- return commonEncode(text).replace(HASH_RE, "%23").replace(IM_RE, "%3F");
522
- }
523
- /**
524
- * Encode characters that need to be encoded on the path section of the URL as a
525
- * param. This function encodes everything {@link encodePath} does plus the
526
- * slash (`/`) character. If `text` is `null` or `undefined`, returns an empty
527
- * string instead.
528
- *
529
- * @param text - string to encode
530
- * @returns encoded string
531
- */
532
- function encodeParam(text) {
533
- return encodePath(text).replace(SLASH_RE, "%2F");
534
- }
535
- function decode(text) {
536
- if (text == null) return null;
537
- try {
538
- return decodeURIComponent("" + text);
539
- } catch {
540
- diagnostics.VUE_ROUTER_R0080({ text: "" + text });
541
- }
542
- return "" + text;
543
- }
544
- var TRAILING_SLASH_RE = /\/$/;
545
- var removeTrailingSlash = (path) => path.replace(TRAILING_SLASH_RE, "");
546
- /**
547
- * Transforms a URI into a normalized history location
548
- *
549
- * @param parseQuery
550
- * @param location - URI to normalize
551
- * @param currentLocation - current absolute location. Allows resolving relative
552
- * paths. Must start with `/`. Defaults to `/`
553
- * @returns a normalized history location
554
- */
555
- function parseURL(parseQuery, location, currentLocation = "/") {
556
- let path, query = {}, searchString = "", hash = "";
557
- const hashPos = location.indexOf("#");
558
- let searchPos = location.indexOf("?");
559
- searchPos = hashPos >= 0 && searchPos > hashPos ? -1 : searchPos;
560
- if (searchPos >= 0) {
561
- path = location.slice(0, searchPos);
562
- searchString = location.slice(searchPos, hashPos > 0 ? hashPos : location.length);
563
- query = parseQuery(searchString.slice(1));
564
- }
565
- if (hashPos >= 0) {
566
- path = path || location.slice(0, hashPos);
567
- hash = location.slice(hashPos, location.length);
568
- }
569
- path = resolveRelativePath(path != null ? path : location, currentLocation);
570
- return {
571
- fullPath: path + searchString + hash,
572
- path,
573
- query,
574
- hash: decode(hash)
575
- };
576
- }
577
- /**
578
- * Stringifies a URL object
579
- *
580
- * @param stringifyQuery
581
- * @param location
582
- */
583
- function stringifyURL(stringifyQuery, location) {
584
- const query = location.query ? stringifyQuery(location.query) : "";
585
- return location.path + (query && "?") + query + (location.hash || "");
586
- }
587
- /**
588
- * Strips off the base from the beginning of a location.pathname in a non-case-sensitive way.
589
- *
590
- * @param pathname - location.pathname
591
- * @param base - base to strip off
592
- */
593
- function stripBase(pathname, base) {
594
- if (!base || !pathname.toLowerCase().startsWith(base.toLowerCase())) return pathname;
595
- return pathname.slice(base.length) || "/";
596
- }
597
- /**
598
- * Checks if two RouteLocation are equal. This means that both locations are
599
- * pointing towards the same {@link RouteRecord} and that all `params`, `query`
600
- * parameters and `hash` are the same
601
- *
602
- * @param stringifyQuery - A function that takes a query object of type LocationQueryRaw and returns a string representation of it.
603
- * @param a - first {@link RouteLocation}
604
- * @param b - second {@link RouteLocation}
605
- */
606
- function isSameRouteLocation(stringifyQuery, a, b) {
607
- const aLastIndex = a.matched.length - 1;
608
- const bLastIndex = b.matched.length - 1;
609
- return aLastIndex > -1 && aLastIndex === bLastIndex && isSameRouteRecord(a.matched[aLastIndex], b.matched[bLastIndex]) && isSameRouteLocationParams(a.params, b.params) && stringifyQuery(a.query) === stringifyQuery(b.query) && a.hash === b.hash;
610
- }
611
- /**
612
- * Check if two `RouteRecords` are equal. Takes into account aliases: they are
613
- * considered equal to the `RouteRecord` they are aliasing.
614
- *
615
- * @param a - first {@link RouteRecord}
616
- * @param b - second {@link RouteRecord}
617
- */
618
- function isSameRouteRecord(a, b) {
619
- return (a.aliasOf || a) === (b.aliasOf || b);
620
- }
621
- function isSameRouteLocationParams(a, b) {
622
- if (Object.keys(a).length !== Object.keys(b).length) return false;
623
- for (var key in a) if (!isSameRouteLocationParamsValue(a[key], b[key])) return false;
624
- return true;
625
- }
626
- function isSameRouteLocationParamsValue(a, b) {
627
- return isArray(a) ? isEquivalentArray(a, b) : isArray(b) ? isEquivalentArray(b, a) : (a && a.valueOf()) === (b && b.valueOf());
628
- }
629
- /**
630
- * Check if two arrays are the same or if an array with one single entry is the
631
- * same as another primitive value. Used to check query and parameters
632
- *
633
- * @param a - array of values
634
- * @param b - array of values or a single value
635
- */
636
- function isEquivalentArray(a, b) {
637
- return isArray(b) ? a.length === b.length && a.every((value, i) => value === b[i]) : a.length === 1 && a[0] === b;
638
- }
639
- /**
640
- * Resolves a relative path that starts with `.`.
641
- *
642
- * @param to - path location we are resolving
643
- * @param from - currentLocation.path, should start with `/`
644
- */
645
- function resolveRelativePath(to, from) {
646
- if (isAbsolutePath(to)) return to;
647
- if (!isAbsolutePath(from)) {
648
- diagnostics.VUE_ROUTER_R0070({
649
- to,
650
- from
651
- });
652
- return to;
653
- }
654
- if (!to) return from;
655
- const fromSegments = from.split("/");
656
- const toSegments = to.split("/");
657
- const lastToSegment = toSegments[toSegments.length - 1];
658
- if (lastToSegment === ".." || lastToSegment === ".") toSegments.push("");
659
- let position = fromSegments.length - 1;
660
- let toPosition;
661
- let segment;
662
- for (toPosition = 0; toPosition < toSegments.length; toPosition++) {
663
- segment = toSegments[toPosition];
664
- if (segment === ".") continue;
665
- if (segment === "..") {
666
- if (position > 1) position--;
667
- } else break;
668
- }
669
- return fromSegments.slice(0, position).join("/") + "/" + toSegments.slice(toPosition).join("/");
670
- }
671
- /**
672
- * Initial route location where the router is. Can be used in navigation guards
673
- * to differentiate the initial navigation.
674
- *
675
- * @example
676
- * ```js
677
- * import { START_LOCATION } from 'vue-router'
678
- *
679
- * router.beforeEach((to, from) => {
680
- * if (from === START_LOCATION) {
681
- * // initial navigation
682
- * }
683
- * })
684
- * ```
685
- */
686
- var START_LOCATION_NORMALIZED = {
687
- path: "/",
688
- name: void 0,
689
- params: {},
690
- query: {},
691
- hash: "",
692
- fullPath: "/",
693
- matched: [],
694
- meta: {},
695
- redirectedFrom: void 0
696
- };
697
- /**
698
- * Normalizes a base by removing any trailing slash and reading the base tag if
699
- * present.
700
- *
701
- * @param base - base to normalize
702
- */
703
- function normalizeBase(base) {
704
- if (!base) {
705
- if (isBrowser) {
706
- const baseEl = document.querySelector("base");
707
- base = baseEl && baseEl.getAttribute("href") || "/";
708
- base = base.replace(/^\w+:\/\/[^/]+/, "");
709
- } else base = "/";
710
- }
711
- if (base[0] !== "/" && base[0] !== "#") base = "/" + base;
712
- return removeTrailingSlash(base);
713
- }
714
- var BEFORE_HASH_RE = /^[^#]+#/;
715
- function createHref(base, location) {
716
- return base.replace(BEFORE_HASH_RE, "#") + location;
717
- }
718
- function getElementPosition(el, offset) {
719
- const docRect = document.documentElement.getBoundingClientRect();
720
- const elRect = el.getBoundingClientRect();
721
- return {
722
- behavior: offset.behavior,
723
- left: elRect.left - docRect.left - (offset.left || 0),
724
- top: elRect.top - docRect.top - (offset.top || 0)
725
- };
726
- }
727
- var computeScrollPosition = () => history.scrollRestoration === "manual" ? {
728
- left: window.scrollX,
729
- top: window.scrollY
730
- } : null;
731
- function scrollToPosition(position) {
732
- let scrollToOptions;
733
- if ("el" in position) {
734
- const positionEl = position.el;
735
- const isIdSelector = typeof positionEl === "string" && positionEl.startsWith("#");
736
- /**
737
- * `id`s can accept pretty much any characters, including CSS combinators
738
- * like `>` or `~`. It's still possible to retrieve elements using
739
- * `document.getElementById('~')` but it needs to be escaped when using
740
- * `document.querySelector('#\\~')` for it to be valid. The only
741
- * requirements for `id`s are them to be unique on the page and to not be
742
- * empty (`id=""`). Because of that, when passing an id selector, it should
743
- * be properly escaped for it to work with `querySelector`. We could check
744
- * for the id selector to be simple (no CSS combinators `+ >~`) but that
745
- * would make things inconsistent since they are valid characters for an
746
- * `id` but would need to be escaped when using `querySelector`, breaking
747
- * their usage and ending up in no selector returned. Selectors need to be
748
- * escaped:
749
- *
750
- * - `#1-thing` becomes `#\31 -thing`
751
- * - `#with~symbols` becomes `#with\\~symbols`
752
- *
753
- * - More information about the topic can be found at
754
- * https://mathiasbynens.be/notes/html5-id-class.
755
- * - Practical example: https://mathiasbynens.be/demo/html5-id
756
- */
757
- if (typeof position.el === "string") {
758
- if (!isIdSelector || !document.getElementById(position.el.slice(1))) try {
759
- const foundEl = document.querySelector(position.el);
760
- if (isIdSelector && foundEl) {
761
- diagnostics.VUE_ROUTER_R0040({ el: position.el });
762
- return;
763
- }
764
- } catch {
765
- diagnostics.VUE_ROUTER_R0041({ el: position.el });
766
- return;
767
- }
768
- }
769
- const el = typeof positionEl === "string" ? isIdSelector ? document.getElementById(positionEl.slice(1)) : document.querySelector(positionEl) : positionEl;
770
- if (!el) {
771
- diagnostics.VUE_ROUTER_R0042({ el: position.el });
772
- return;
773
- }
774
- scrollToOptions = getElementPosition(el, position);
775
- } else scrollToOptions = position;
776
- if ("scrollBehavior" in document.documentElement.style) window.scrollTo(scrollToOptions);
777
- else window.scrollTo(scrollToOptions.left != null ? scrollToOptions.left : window.scrollX, scrollToOptions.top != null ? scrollToOptions.top : window.scrollY);
778
- }
779
- function getScrollKey(path, delta) {
780
- return (history.state ? history.state.position - delta : -1) + path;
781
- }
782
- var scrollPositions = /* @__PURE__ */ new Map();
783
- function saveScrollPosition(key) {
784
- scrollPositions.set(key, computeScrollPosition());
785
- }
786
- function getSavedScrollPosition(key) {
787
- const scroll = scrollPositions.get(key);
788
- scrollPositions.delete(key);
789
- return scroll;
790
- }
791
- /**
792
- * ScrollBehavior instance used by the router to compute and restore the scroll
793
- * position when navigating.
794
- */
795
- function isRouteLocation(route) {
796
- return typeof route === "string" || route && typeof route === "object";
797
- }
798
- function isRouteName(name) {
799
- return typeof name === "string" || typeof name === "symbol";
800
- }
801
- /**
802
- * Transforms a queryString into a {@link LocationQuery} object. Accept both, a
803
- * version with the leading `?` and without Should work as URLSearchParams
804
-
805
- * @internal
806
- *
807
- * @param search - search string to parse
808
- * @returns a query object
809
- */
810
- function parseQuery(search) {
811
- const query = {};
812
- if (search === "" || search === "?") return query;
813
- const searchParams = (search[0] === "?" ? search.slice(1) : search).split("&");
814
- for (let i = 0; i < searchParams.length; ++i) {
815
- const searchParam = searchParams[i].replace(PLUS_RE, " ");
816
- const eqPos = searchParam.indexOf("=");
817
- const key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos));
818
- const value = eqPos < 0 ? null : decode(searchParam.slice(eqPos + 1));
819
- if (key in query) {
820
- let currentValue = query[key];
821
- if (!isArray(currentValue)) currentValue = query[key] = [currentValue];
822
- currentValue.push(value);
823
- } else query[key] = value;
824
- }
825
- return query;
826
- }
827
- /**
828
- * Stringifies a {@link LocationQueryRaw} object. Like `URLSearchParams`, it
829
- * doesn't prepend a `?`
830
- *
831
- * @internal
832
- *
833
- * @param query - query object to stringify
834
- * @returns string version of the query without the leading `?`
835
- */
836
- function stringifyQuery(query) {
837
- let search = "";
838
- for (let key in query) {
839
- const value = query[key];
840
- key = encodeQueryKey(key);
841
- if (value == null) {
842
- if (value !== void 0) search += (search.length ? "&" : "") + key;
843
- continue;
844
- }
845
- (isArray(value) ? value.map((v) => v && encodeQueryValue(v)) : [value && encodeQueryValue(value)]).forEach((value) => {
846
- if (value !== void 0) {
847
- search += (search.length ? "&" : "") + key;
848
- if (value != null) search += "=" + value;
849
- }
850
- });
851
- }
852
- return search;
853
- }
854
- /**
855
- * Transforms a {@link LocationQueryRaw} into a {@link LocationQuery} by casting
856
- * numbers into strings, removing keys with an undefined value and replacing
857
- * undefined with null in arrays
858
- *
859
- * @param query - query object to normalize
860
- * @returns a normalized query object
861
- */
862
- function normalizeQuery(query) {
863
- const normalizedQuery = {};
864
- for (const key in query) {
865
- const value = query[key];
866
- if (value !== void 0) normalizedQuery[key] = isArray(value) ? value.map((v) => v == null ? null : "" + v) : value == null ? value : "" + value;
867
- }
868
- return normalizedQuery;
869
- }
870
- /**
871
- * Create a list of callbacks that can be reset. Used to create before and after navigation guards list
872
- */
873
- function useCallbacks() {
874
- let handlers = [];
875
- function add(handler) {
876
- handlers.push(handler);
877
- return () => {
878
- const i = handlers.indexOf(handler);
879
- if (i > -1) handlers.splice(i, 1);
880
- };
881
- }
882
- function reset() {
883
- handlers = [];
884
- }
885
- return {
886
- add,
887
- list: () => handlers.slice(),
888
- reset
889
- };
890
- }
891
- function registerGuard(activeRecordRef, name, guard) {
892
- const record = activeRecordRef.value;
893
- if (!record) {
894
- {
895
- const fnName = name === "updateGuards" ? "onBeforeRouteUpdate" : "onBeforeRouteLeave";
896
- diagnostics.VUE_ROUTER_R0020({ fn: fnName });
897
- }
898
- return;
899
- }
900
- let currentRecord = record;
901
- const removeFromList = () => {
902
- currentRecord[name].delete(guard);
903
- };
904
- onUnmounted(removeFromList);
905
- onDeactivated(removeFromList);
906
- onActivated(() => {
907
- const newRecord = activeRecordRef.value;
908
- if (!newRecord) diagnostics.VUE_ROUTER_R0021();
909
- if (newRecord) currentRecord = newRecord;
910
- currentRecord[name].add(guard);
911
- });
912
- currentRecord[name].add(guard);
913
- }
914
- /**
915
- * Add a navigation guard that triggers whenever the component for the current
916
- * location is about to be left. Similar to {@link beforeRouteLeave} but can be
917
- * used in any component. The guard is removed when the component is unmounted.
918
- *
919
- * @param leaveGuard - {@link NavigationGuard}
920
- */
921
- function onBeforeRouteLeave(leaveGuard) {
922
- if (!getCurrentInstance()) {
923
- diagnostics.VUE_ROUTER_R0022({ fn: "onBeforeRouteLeave" });
924
- return;
925
- }
926
- registerGuard(inject(matchedRouteKey, {}), "leaveGuards", leaveGuard);
927
- }
928
- /**
929
- * Add a navigation guard that triggers whenever the current location is about
930
- * to be updated. Similar to {@link beforeRouteUpdate} but can be used in any
931
- * component. The guard is removed when the component is unmounted.
932
- *
933
- * @param updateGuard - {@link NavigationGuard}
934
- */
935
- function onBeforeRouteUpdate(updateGuard) {
936
- if (!getCurrentInstance()) {
937
- diagnostics.VUE_ROUTER_R0022({ fn: "onBeforeRouteUpdate" });
938
- return;
939
- }
940
- registerGuard(inject(matchedRouteKey, {}), "updateGuards", updateGuard);
941
- }
942
- function guardToPromiseFn(guard, to, from, record, name, runWithContext = (fn) => fn()) {
943
- const enterCallbackArray = record && (record.enterCallbacks[name] = record.enterCallbacks[name] || []);
944
- return () => new Promise((resolve, reject) => {
945
- const next = (valid) => {
946
- if (valid === false) reject(createRouterError(4, {
947
- from,
948
- to
949
- }));
950
- else if (valid instanceof Error) reject(valid);
951
- else if (isRouteLocation(valid)) reject(createRouterError(2, {
952
- from: to,
953
- to: valid
954
- }));
955
- else {
956
- if (enterCallbackArray && record.enterCallbacks[name] === enterCallbackArray && typeof valid === "function") enterCallbackArray.push(valid);
957
- resolve();
958
- }
959
- };
960
- const guardReturn = runWithContext(() => guard.call(record && record.instances[name], to, from, withDeprecationWarning(canOnlyBeCalledOnce(next, to, from))));
961
- let guardCall = Promise.resolve(guardReturn);
962
- if (guard.length < 3) guardCall = guardCall.then(next);
963
- if (guard.length > 2) {
964
- const guardInfo = {
965
- name: guard.name,
966
- guard: guard.toString()
967
- };
968
- if (typeof guardReturn === "object" && "then" in guardReturn) guardCall = guardCall.then((resolvedValue) => {
969
- if (!next._called) {
970
- diagnostics.VUE_ROUTER_R0023(guardInfo);
971
- return Promise.reject(/* @__PURE__ */ new Error("Invalid navigation guard"));
972
- }
973
- return resolvedValue;
974
- });
975
- else if (guardReturn !== void 0) {
976
- if (!next._called) {
977
- diagnostics.VUE_ROUTER_R0023(guardInfo);
978
- reject(/* @__PURE__ */ new Error("Invalid navigation guard"));
979
- return;
980
- }
981
- }
982
- }
983
- guardCall.catch((err) => reject(err));
984
- });
985
- }
986
- /**
987
- * Wraps the next callback to warn when it is used. Dev-only: when __DEV__ is
988
- * false (production builds), this branch is dead code and is stripped from the
989
- * bundle.
990
- *
991
- * @internal
992
- */
993
- function withDeprecationWarning(next) {
994
- let warned = false;
995
- return function() {
996
- if (!warned) {
997
- warned = true;
998
- diagnostics.VUE_ROUTER_R0025();
999
- }
1000
- return next.apply(this, arguments);
1001
- };
1002
- }
1003
- function canOnlyBeCalledOnce(next, to, from) {
1004
- let called = 0;
1005
- return function() {
1006
- if (called++ === 1) diagnostics.VUE_ROUTER_R0024({
1007
- from: from.fullPath,
1008
- to: to.fullPath
1009
- });
1010
- next._called = true;
1011
- if (called === 1) next.apply(null, arguments);
1012
- };
1013
- }
1014
- function extractComponentsGuards(matched, guardType, to, from, runWithContext = (fn) => fn()) {
1015
- const guards = [];
1016
- for (const record of matched) {
1017
- if (!record.components && record.children && !record.children.length) diagnostics.VUE_ROUTER_R0026({ path: record.path });
1018
- for (const name in record.components) {
1019
- let rawComponent = record.components[name];
1020
- if (!rawComponent || typeof rawComponent !== "object" && typeof rawComponent !== "function") {
1021
- diagnostics.VUE_ROUTER_R0027({
1022
- name,
1023
- path: record.path,
1024
- received: String(rawComponent)
1025
- });
1026
- throw new Error("Invalid route component");
1027
- } else if ("then" in rawComponent) {
1028
- diagnostics.VUE_ROUTER_R0028({
1029
- name,
1030
- path: record.path
1031
- });
1032
- const promise = rawComponent;
1033
- rawComponent = () => promise;
1034
- } else if (rawComponent.__asyncLoader && !rawComponent.__warnedDefineAsync) {
1035
- rawComponent.__warnedDefineAsync = true;
1036
- diagnostics.VUE_ROUTER_R0029({
1037
- name,
1038
- path: record.path
1039
- });
1040
- }
1041
- if (guardType !== "beforeRouteEnter" && !record.instances[name]) continue;
1042
- if (isRouteComponent(rawComponent)) {
1043
- const guard = (rawComponent.__vccOpts || rawComponent)[guardType];
1044
- guard && guards.push(guardToPromiseFn(guard, to, from, record, name, runWithContext));
1045
- } else {
1046
- let componentPromise = rawComponent();
1047
- if (!("catch" in componentPromise)) {
1048
- diagnostics.VUE_ROUTER_R0030({
1049
- name,
1050
- path: record.path
1051
- });
1052
- componentPromise = Promise.resolve(componentPromise);
1053
- }
1054
- guards.push(() => componentPromise.then((resolved) => {
1055
- if (!resolved) throw new Error(`Couldn't resolve component "${name}" at "${record.path}"`);
1056
- const resolvedComponent = isESModule(resolved) ? resolved.default : resolved;
1057
- record.mods[name] = resolved;
1058
- record.components[name] = resolvedComponent;
1059
- const guard = (resolvedComponent.__vccOpts || resolvedComponent)[guardType];
1060
- return guard && guardToPromiseFn(guard, to, from, record, name, runWithContext)();
1061
- }));
1062
- }
1063
- }
1064
- }
1065
- return guards;
1066
- }
1067
- /**
1068
- * Ensures a route is loaded, so it can be passed as o prop to `<RouterView>`.
1069
- *
1070
- * @param route - resolved route to load
1071
- */
1072
- function loadRouteLocation(route) {
1073
- return route.matched.every((record) => record.redirect) ? Promise.reject(/* @__PURE__ */ new Error("Cannot load a route that redirects.")) : Promise.all(route.matched.map((record) => record.components && Promise.all(Object.keys(record.components).reduce((promises, name) => {
1074
- const rawComponent = record.components[name];
1075
- if (typeof rawComponent === "function" && !("displayName" in rawComponent)) promises.push(rawComponent().then((resolved) => {
1076
- if (!resolved) return Promise.reject(/* @__PURE__ */ new Error(`Couldn't resolve component "${name}" at "${record.path}". Ensure you passed a function that returns a promise.`));
1077
- const resolvedComponent = isESModule(resolved) ? resolved.default : resolved;
1078
- record.mods[name] = resolved;
1079
- record.components[name] = resolvedComponent;
1080
- }));
1081
- return promises;
1082
- }, [])))).then(() => route);
1083
- }
1084
- /**
1085
- * Split the leaving, updating, and entering records.
1086
- * @internal
1087
- *
1088
- * @param to - Location we are navigating to
1089
- * @param from - Location we are navigating from
1090
- */
1091
- function extractChangingRecords(to, from) {
1092
- const leavingRecords = [];
1093
- const updatingRecords = [];
1094
- const enteringRecords = [];
1095
- const len = Math.max(from.matched.length, to.matched.length);
1096
- for (let i = 0; i < len; i++) {
1097
- const recordFrom = from.matched[i];
1098
- if (recordFrom) {
1099
- if (to.matched.find((record) => isSameRouteRecord(record, recordFrom))) updatingRecords.push(recordFrom);
1100
- else leavingRecords.push(recordFrom);
1101
- }
1102
- const recordTo = to.matched[i];
1103
- if (recordTo) {
1104
- if (!from.matched.find((record) => isSameRouteRecord(record, recordTo))) enteringRecords.push(recordTo);
1105
- }
1106
- }
1107
- return [
1108
- leavingRecords,
1109
- updatingRecords,
1110
- enteringRecords
1111
- ];
1112
- }
1113
- /**
1114
- * Copies a route location and removes any problematic properties that cannot be shown in devtools (e.g. Vue instances).
1115
- *
1116
- * @param routeLocation - routeLocation to format
1117
- * @param tooltip - optional tooltip
1118
- * @returns a copy of the routeLocation
1119
- */
1120
- function formatRouteLocation(routeLocation, tooltip) {
1121
- const copy = assign({}, routeLocation, { matched: routeLocation.matched.map((matched) => omit(matched, [
1122
- "instances",
1123
- "children",
1124
- "aliasOf"
1125
- ])) });
1126
- return { _custom: {
1127
- type: null,
1128
- readOnly: true,
1129
- display: routeLocation.fullPath,
1130
- tooltip,
1131
- value: copy
1132
- } };
1133
- }
1134
- function formatDisplay(display) {
1135
- return { _custom: { display } };
1136
- }
1137
- var routerId = 0;
1138
- function addDevtools(app, router, matcher) {
1139
- if (router.__hasDevtools) return;
1140
- router.__hasDevtools = true;
1141
- const id = routerId++;
1142
- setupDevToolsPlugin({
1143
- id: "org.vuejs.router" + (id ? "." + id : ""),
1144
- label: "Vue Router",
1145
- packageName: "vue-router",
1146
- homepage: "https://router.vuejs.org",
1147
- logo: "https://router.vuejs.org/logo.png",
1148
- componentStateTypes: ["Routing"],
1149
- app
1150
- }, (api) => {
1151
- api.on.inspectComponent((payload) => {
1152
- if (payload.instanceData) payload.instanceData.state.push({
1153
- type: "Routing",
1154
- key: "$route",
1155
- editable: false,
1156
- value: formatRouteLocation(router.currentRoute.value, "Current Route")
1157
- });
1158
- });
1159
- api.on.visitComponentTree(({ treeNode: node, componentInstance }) => {
1160
- if (componentInstance.__vrv_devtools) {
1161
- const info = componentInstance.__vrv_devtools;
1162
- node.tags.push({
1163
- label: (info.name ? `${info.name.toString()}: ` : "") + info.path,
1164
- textColor: 0,
1165
- tooltip: "This component is rendered by &lt;router-view&gt;",
1166
- backgroundColor: PINK_500
1167
- });
1168
- }
1169
- if (isArray(componentInstance.__vrl_devtools)) {
1170
- componentInstance.__devtoolsApi = api;
1171
- componentInstance.__vrl_devtools.forEach((devtoolsData) => {
1172
- let label = devtoolsData.route.path;
1173
- let backgroundColor = ORANGE_400;
1174
- let tooltip = "";
1175
- let textColor = 0;
1176
- if (devtoolsData.error) {
1177
- label = devtoolsData.error;
1178
- backgroundColor = RED_100;
1179
- textColor = RED_700;
1180
- } else if (devtoolsData.isExactActive) {
1181
- backgroundColor = LIME_500;
1182
- tooltip = "This is exactly active";
1183
- } else if (devtoolsData.isActive) {
1184
- backgroundColor = BLUE_600;
1185
- tooltip = "This link is active";
1186
- }
1187
- node.tags.push({
1188
- label,
1189
- textColor,
1190
- tooltip,
1191
- backgroundColor
1192
- });
1193
- });
1194
- }
1195
- });
1196
- watch(router.currentRoute, () => {
1197
- refreshRoutesView();
1198
- api.notifyComponentUpdate();
1199
- api.sendInspectorTree(routerInspectorId);
1200
- api.sendInspectorState(routerInspectorId);
1201
- });
1202
- const navigationsLayerId = "router:navigations:" + id;
1203
- api.addTimelineLayer({
1204
- id: navigationsLayerId,
1205
- label: `Router${id ? " " + id : ""} Navigations`,
1206
- color: 4237508
1207
- });
1208
- router.onError((error, to) => {
1209
- api.addTimelineEvent({
1210
- layerId: navigationsLayerId,
1211
- event: {
1212
- title: "Error during Navigation",
1213
- subtitle: to.fullPath,
1214
- logType: "error",
1215
- time: api.now(),
1216
- data: { error },
1217
- groupId: to.meta.__navigationId
1218
- }
1219
- });
1220
- });
1221
- let navigationId = 0;
1222
- router.beforeEach((to, from) => {
1223
- const data = {
1224
- guard: formatDisplay("beforeEach"),
1225
- from: formatRouteLocation(from, "Current Location during this navigation"),
1226
- to: formatRouteLocation(to, "Target location")
1227
- };
1228
- Object.defineProperty(to.meta, "__navigationId", { value: navigationId++ });
1229
- api.addTimelineEvent({
1230
- layerId: navigationsLayerId,
1231
- event: {
1232
- time: api.now(),
1233
- title: "Start of navigation",
1234
- subtitle: to.fullPath,
1235
- data,
1236
- groupId: to.meta.__navigationId
1237
- }
1238
- });
1239
- });
1240
- router.afterEach((to, from, failure) => {
1241
- const data = { guard: formatDisplay("afterEach") };
1242
- if (failure) {
1243
- data.failure = { _custom: {
1244
- type: Error,
1245
- readOnly: true,
1246
- display: failure ? failure.message : "",
1247
- tooltip: "Navigation Failure",
1248
- value: failure
1249
- } };
1250
- data.status = formatDisplay("❌");
1251
- } else data.status = formatDisplay("✅");
1252
- data.from = formatRouteLocation(from, "Current Location during this navigation");
1253
- data.to = formatRouteLocation(to, "Target location");
1254
- api.addTimelineEvent({
1255
- layerId: navigationsLayerId,
1256
- event: {
1257
- title: "End of navigation",
1258
- subtitle: to.fullPath,
1259
- time: api.now(),
1260
- data,
1261
- logType: failure ? "warning" : "default",
1262
- groupId: to.meta.__navigationId
1263
- }
1264
- });
1265
- });
1266
- /**
1267
- * Inspector of Existing routes
1268
- */
1269
- const routerInspectorId = "router-inspector:" + id;
1270
- api.addInspector({
1271
- id: routerInspectorId,
1272
- label: "Routes" + (id ? " " + id : ""),
1273
- icon: "book",
1274
- treeFilterPlaceholder: "Search routes"
1275
- });
1276
- function refreshRoutesView() {
1277
- if (!activeRoutesPayload) return;
1278
- const payload = activeRoutesPayload;
1279
- let routes = matcher.getRoutes().filter((route) => !route.parent || !route.parent.record.components);
1280
- routes.forEach(resetMatchStateOnRouteRecord);
1281
- if (payload.filter) routes = routes.filter((route) => isRouteMatching(route, payload.filter.toLowerCase()));
1282
- routes.forEach((route) => markRouteRecordActive(route, router.currentRoute.value));
1283
- payload.rootNodes = routes.map(formatRouteRecordForInspector);
1284
- }
1285
- let activeRoutesPayload;
1286
- api.on.getInspectorTree((payload) => {
1287
- activeRoutesPayload = payload;
1288
- if (payload.app === app && payload.inspectorId === routerInspectorId) refreshRoutesView();
1289
- });
1290
- /**
1291
- * Display information about the currently selected route record
1292
- */
1293
- api.on.getInspectorState((payload) => {
1294
- if (payload.app === app && payload.inspectorId === routerInspectorId) {
1295
- const route = matcher.getRoutes().find((route) => route.record.__vd_id === payload.nodeId);
1296
- if (route) payload.state = { options: formatRouteRecordMatcherForStateInspector(route) };
1297
- }
1298
- });
1299
- api.sendInspectorTree(routerInspectorId);
1300
- api.sendInspectorState(routerInspectorId);
1301
- });
1302
- }
1303
- function modifierForKey(key) {
1304
- if (key.optional) return key.repeatable ? "*" : "?";
1305
- else return key.repeatable ? "+" : "";
1306
- }
1307
- function formatRouteRecordMatcherForStateInspector(route) {
1308
- const { record } = route;
1309
- const fields = [{
1310
- editable: false,
1311
- key: "path",
1312
- value: record.path
1313
- }];
1314
- if (record.name != null) fields.push({
1315
- editable: false,
1316
- key: "name",
1317
- value: record.name
1318
- });
1319
- fields.push({
1320
- editable: false,
1321
- key: "regexp",
1322
- value: route.re
1323
- });
1324
- if (route.keys.length) fields.push({
1325
- editable: false,
1326
- key: "keys",
1327
- value: { _custom: {
1328
- type: null,
1329
- readOnly: true,
1330
- display: route.keys.map((key) => `${key.name}${modifierForKey(key)}`).join(" "),
1331
- tooltip: "Param keys",
1332
- value: route.keys
1333
- } }
1334
- });
1335
- if (record.redirect != null) fields.push({
1336
- editable: false,
1337
- key: "redirect",
1338
- value: record.redirect
1339
- });
1340
- if (route.alias.length) fields.push({
1341
- editable: false,
1342
- key: "aliases",
1343
- value: route.alias.map((alias) => alias.record.path)
1344
- });
1345
- if (Object.keys(route.record.meta).length) fields.push({
1346
- editable: false,
1347
- key: "meta",
1348
- value: route.record.meta
1349
- });
1350
- fields.push({
1351
- key: "score",
1352
- editable: false,
1353
- value: { _custom: {
1354
- type: null,
1355
- readOnly: true,
1356
- display: route.score.map((score) => score.join(", ")).join(" | "),
1357
- tooltip: "Score used to sort routes",
1358
- value: route.score
1359
- } }
1360
- });
1361
- return fields;
1362
- }
1363
- /**
1364
- * Extracted from tailwind palette
1365
- */
1366
- var PINK_500 = 15485081;
1367
- var BLUE_600 = 2450411;
1368
- var LIME_500 = 8702998;
1369
- var CYAN_400 = 2282478;
1370
- var ORANGE_400 = 16486972;
1371
- var DARK = 6710886;
1372
- var RED_100 = 16704226;
1373
- var RED_700 = 12131356;
1374
- function formatRouteRecordForInspector(route) {
1375
- const tags = [];
1376
- const { record } = route;
1377
- if (record.name != null) tags.push({
1378
- label: String(record.name),
1379
- textColor: 0,
1380
- backgroundColor: CYAN_400
1381
- });
1382
- if (record.aliasOf) tags.push({
1383
- label: "alias",
1384
- textColor: 0,
1385
- backgroundColor: ORANGE_400
1386
- });
1387
- if (route.__vd_match) tags.push({
1388
- label: "matches",
1389
- textColor: 0,
1390
- backgroundColor: PINK_500
1391
- });
1392
- if (route.__vd_exactActive) tags.push({
1393
- label: "exact",
1394
- textColor: 0,
1395
- backgroundColor: LIME_500
1396
- });
1397
- if (route.__vd_active) tags.push({
1398
- label: "active",
1399
- textColor: 0,
1400
- backgroundColor: BLUE_600
1401
- });
1402
- if (record.redirect) tags.push({
1403
- label: typeof record.redirect === "string" ? `redirect: ${record.redirect}` : "redirects",
1404
- textColor: 16777215,
1405
- backgroundColor: DARK
1406
- });
1407
- let id = record.__vd_id;
1408
- if (id == null) {
1409
- id = String(routeRecordId++);
1410
- record.__vd_id = id;
1411
- }
1412
- return {
1413
- id,
1414
- label: record.path,
1415
- tags,
1416
- children: route.children.map(formatRouteRecordForInspector)
1417
- };
1418
- }
1419
- var routeRecordId = 0;
1420
- var EXTRACT_REGEXP_RE = /^\/(.*)\/([a-z]*)$/;
1421
- function markRouteRecordActive(route, currentRoute) {
1422
- const isExactActive = currentRoute.matched.length && isSameRouteRecord(currentRoute.matched[currentRoute.matched.length - 1], route.record);
1423
- route.__vd_exactActive = route.__vd_active = isExactActive;
1424
- if (!isExactActive) route.__vd_active = currentRoute.matched.some((match) => isSameRouteRecord(match, route.record));
1425
- route.children.forEach((childRoute) => markRouteRecordActive(childRoute, currentRoute));
1426
- }
1427
- function resetMatchStateOnRouteRecord(route) {
1428
- route.__vd_match = false;
1429
- route.children.forEach(resetMatchStateOnRouteRecord);
1430
- }
1431
- function isRouteMatching(route, filter) {
1432
- const found = String(route.re).match(EXTRACT_REGEXP_RE);
1433
- route.__vd_match = false;
1434
- if (!found || found.length < 3) return false;
1435
- if (new RegExp(found[1].replace(/\$$/, ""), found[2]).test(filter)) {
1436
- route.children.forEach((child) => isRouteMatching(child, filter));
1437
- if (route.record.path !== "/" || filter === "/") {
1438
- route.__vd_match = route.re.test(filter);
1439
- return true;
1440
- }
1441
- return false;
1442
- }
1443
- const path = route.record.path.toLowerCase();
1444
- const decodedPath = decode(path);
1445
- if (!isAbsolutePath(filter) && (decodedPath.includes(filter) || path.includes(filter))) return true;
1446
- if (decodedPath.startsWith(filter) || path.startsWith(filter)) return true;
1447
- if (route.record.name && String(route.record.name).includes(filter)) return true;
1448
- return route.children.some((child) => isRouteMatching(child, filter));
1449
- }
1450
- function omit(obj, keys) {
1451
- const ret = {};
1452
- for (const key in obj) if (!keys.includes(key)) ret[key] = obj[key];
1453
- return ret;
1454
- }
1455
- //#endregion
1456
- //#region ../../../../node_modules/vue-router/dist/vue-router.js
1457
- /*!
1458
- * vue-router v5.3.1
1459
- * (c) 2026 Eduardo San Martin Morote
1460
- * @license MIT
1461
- */
1462
- var createBaseLocation = () => location.protocol + "//" + location.host;
1463
- /**
1464
- * Creates a normalized history location from a window.location object
1465
- * @param base - The base path
1466
- * @param location - The window.location object
1467
- */
1468
- function createCurrentLocation(base, location) {
1469
- const { pathname, search, hash } = location;
1470
- const hashPos = base.indexOf("#");
1471
- if (hashPos > -1) {
1472
- let slicePos = hash.includes(base.slice(hashPos)) ? base.slice(hashPos).length : 1;
1473
- let pathFromHash = hash.slice(slicePos);
1474
- if (pathFromHash[0] !== "/") pathFromHash = "/" + pathFromHash;
1475
- return stripBase(pathFromHash, "");
1476
- }
1477
- return stripBase(pathname, base) + search + hash;
1478
- }
1479
- function useHistoryListeners(base, historyState, currentLocation, replace) {
1480
- let listeners = [];
1481
- let teardowns = [];
1482
- let pauseState = null;
1483
- const popStateHandler = ({ state }) => {
1484
- const to = createCurrentLocation(base, location);
1485
- const from = currentLocation.value;
1486
- const fromState = historyState.value;
1487
- let delta = 0;
1488
- if (state) {
1489
- currentLocation.value = to;
1490
- historyState.value = state;
1491
- if (pauseState && pauseState === from) {
1492
- pauseState = null;
1493
- return;
1494
- }
1495
- delta = fromState ? state.position - fromState.position : 0;
1496
- } else replace(to);
1497
- listeners.forEach((listener) => {
1498
- listener(currentLocation.value, from, {
1499
- delta,
1500
- type: "pop",
1501
- direction: delta ? delta > 0 ? "forward" : "back" : ""
1502
- });
1503
- });
1504
- };
1505
- function pauseListeners() {
1506
- pauseState = currentLocation.value;
1507
- }
1508
- function listen(callback) {
1509
- listeners.push(callback);
1510
- const teardown = () => {
1511
- const index = listeners.indexOf(callback);
1512
- if (index > -1) listeners.splice(index, 1);
1513
- };
1514
- teardowns.push(teardown);
1515
- return teardown;
1516
- }
1517
- function beforeUnloadListener() {
1518
- const { history } = window;
1519
- if (!history.state) return;
1520
- history.replaceState(assign({}, history.state, { scroll: computeScrollPosition() }), "");
1521
- }
1522
- function destroy() {
1523
- for (const teardown of teardowns) teardown();
1524
- teardowns = [];
1525
- window.removeEventListener("popstate", popStateHandler);
1526
- window.removeEventListener("pagehide", beforeUnloadListener);
1527
- }
1528
- window.addEventListener("popstate", popStateHandler);
1529
- window.addEventListener("pagehide", beforeUnloadListener);
1530
- return {
1531
- pauseListeners,
1532
- listen,
1533
- destroy
1534
- };
1535
- }
1536
- /**
1537
- * Creates a state object
1538
- */
1539
- function buildState(back, current, forward, replaced = false) {
1540
- return {
1541
- back,
1542
- current,
1543
- forward,
1544
- replaced,
1545
- position: window.history.length,
1546
- scroll: null
1547
- };
1548
- }
1549
- function useHistoryStateNavigation(base) {
1550
- const { history, location } = window;
1551
- const currentLocation = { value: createCurrentLocation(base, location) };
1552
- const historyState = { value: history.state };
1553
- if (!historyState.value) changeLocation(currentLocation.value, {
1554
- back: null,
1555
- current: currentLocation.value,
1556
- forward: null,
1557
- position: history.length - 1,
1558
- replaced: true,
1559
- scroll: null
1560
- }, true);
1561
- function changeLocation(to, state, replace) {
1562
- /**
1563
- * if a base tag is provided, and we are on a normal domain, we have to
1564
- * respect the provided `base` attribute because pushState() will use it and
1565
- * potentially erase anything before the `#` like at
1566
- * https://github.com/vuejs/router/issues/685 where a base of
1567
- * `/folder/#` but a base of `/` would erase the `/folder/` section. If
1568
- * there is no host, the `<base>` tag makes no sense and if there isn't a
1569
- * base tag we can just use everything after the `#`.
1570
- */
1571
- const hashIndex = base.indexOf("#");
1572
- const url = hashIndex > -1 ? (location.host && document.querySelector("base") ? base : base.slice(hashIndex)) + to : createBaseLocation() + base + to;
1573
- try {
1574
- history[replace ? "replaceState" : "pushState"](state, "", url);
1575
- historyState.value = state;
1576
- } catch (err) {
1577
- diagnostics.VUE_ROUTER_R0120({ cause: err });
1578
- location[replace ? "replace" : "assign"](url);
1579
- }
1580
- }
1581
- function replace(to, data) {
1582
- changeLocation(to, assign({}, history.state, buildState(historyState.value.back, to, historyState.value.forward, true), data, { position: historyState.value.position }), true);
1583
- currentLocation.value = to;
1584
- }
1585
- function push(to, data) {
1586
- const currentState = assign({}, historyState.value, history.state, {
1587
- forward: to,
1588
- scroll: computeScrollPosition()
1589
- });
1590
- if (!history.state) diagnostics.VUE_ROUTER_R0121();
1591
- changeLocation(currentState.current, currentState, true);
1592
- changeLocation(to, assign({}, buildState(currentLocation.value, to, null), { position: currentState.position + 1 }, data), false);
1593
- currentLocation.value = to;
1594
- }
1595
- return {
1596
- location: currentLocation,
1597
- state: historyState,
1598
- push,
1599
- replace
1600
- };
1601
- }
1602
- /**
1603
- * Creates an HTML5 history. Most common history for single page applications.
1604
- *
1605
- * @param base -
1606
- */
1607
- function createWebHistory(base) {
1608
- base = normalizeBase(base);
1609
- const historyNavigation = useHistoryStateNavigation(base);
1610
- const historyListeners = useHistoryListeners(base, historyNavigation.state, historyNavigation.location, historyNavigation.replace);
1611
- function go(delta, triggerListeners = true) {
1612
- if (!triggerListeners) historyListeners.pauseListeners();
1613
- history.go(delta);
1614
- }
1615
- const routerHistory = assign({
1616
- location: "",
1617
- base,
1618
- go,
1619
- createHref: createHref.bind(null, base)
1620
- }, historyNavigation, historyListeners);
1621
- Object.defineProperty(routerHistory, "location", {
1622
- enumerable: true,
1623
- get: () => historyNavigation.location.value
1624
- });
1625
- Object.defineProperty(routerHistory, "state", {
1626
- enumerable: true,
1627
- get: () => historyNavigation.state.value
1628
- });
1629
- return routerHistory;
1630
- }
1631
- /**
1632
- * Creates a hash history. Useful for web applications with no host (e.g. `file://`) or when configuring a server to
1633
- * handle any URL is not possible.
1634
- *
1635
- * @param base - optional base to provide. Defaults to `location.pathname + location.search` If there is a `<base>` tag
1636
- * in the `head`, its value will be ignored in favor of this parameter **but note it affects all the history.pushState()
1637
- * calls**, meaning that if you use a `<base>` tag, it's `href` value **has to match this parameter** (ignoring anything
1638
- * after the `#`).
1639
- *
1640
- * @example
1641
- * ```js
1642
- * // at https://example.com/folder
1643
- * createWebHashHistory() // gives a url of `https://example.com/folder#`
1644
- * createWebHashHistory('/folder/') // gives a url of `https://example.com/folder/#`
1645
- * // if the `#` is provided in the base, it won't be added by `createWebHashHistory`
1646
- * createWebHashHistory('/folder/#/app/') // gives a url of `https://example.com/folder/#/app/`
1647
- * // you should avoid doing this because it changes the original url and breaks copying urls
1648
- * createWebHashHistory('/other-folder/') // gives a url of `https://example.com/other-folder/#`
1649
- *
1650
- * // at file:///usr/etc/folder/index.html
1651
- * // for locations with no `host`, the base is ignored
1652
- * createWebHashHistory('/iAmIgnored') // gives a url of `file:///usr/etc/folder/index.html#`
1653
- * ```
1654
- */
1655
- function createWebHashHistory(base) {
1656
- base = location.host ? base || location.pathname + location.search : "";
1657
- if (!base.includes("#")) base += "#";
1658
- if (!base.endsWith("#/") && !base.endsWith("#")) diagnostics.VUE_ROUTER_R0110({
1659
- base,
1660
- suggestion: base.replace(/#.*$/, "#")
1661
- });
1662
- return createWebHistory(base);
1663
- }
1664
- /**
1665
- * Creates an in-memory based history. The main purpose of this history is to handle SSR. It starts in a special location that is nowhere.
1666
- * It's up to the user to replace that location with the starter location by either calling `router.push` or `router.replace`.
1667
- *
1668
- * @param base - Base applied to all urls, defaults to '/'
1669
- * @returns a history object that can be passed to the router constructor
1670
- */
1671
- function createMemoryHistory(base = "") {
1672
- let listeners = [];
1673
- let queue = [["", {}]];
1674
- let position = 0;
1675
- base = normalizeBase(base);
1676
- function setLocation(location, state = {}) {
1677
- position++;
1678
- if (position !== queue.length) queue.splice(position);
1679
- queue.push([location, state]);
1680
- }
1681
- function triggerListeners(to, from, { direction, delta }) {
1682
- const info = {
1683
- direction,
1684
- delta,
1685
- type: "pop"
1686
- };
1687
- for (const callback of listeners) callback(to, from, info);
1688
- }
1689
- const routerHistory = {
1690
- location: "",
1691
- state: {},
1692
- base,
1693
- createHref: createHref.bind(null, base),
1694
- replace(to, state) {
1695
- queue.splice(position--, 1);
1696
- setLocation(to, state);
1697
- },
1698
- push(to, state) {
1699
- setLocation(to, state);
1700
- },
1701
- listen(callback) {
1702
- listeners.push(callback);
1703
- return () => {
1704
- const index = listeners.indexOf(callback);
1705
- if (index > -1) listeners.splice(index, 1);
1706
- };
1707
- },
1708
- destroy() {
1709
- listeners = [];
1710
- queue = [["", {}]];
1711
- position = 0;
1712
- },
1713
- go(delta, shouldTrigger = true) {
1714
- const from = this.location;
1715
- const direction = delta < 0 ? "back" : "forward";
1716
- position = Math.max(0, Math.min(position + delta, queue.length - 1));
1717
- if (shouldTrigger) triggerListeners(this.location, from, {
1718
- direction,
1719
- delta
1720
- });
1721
- }
1722
- };
1723
- Object.defineProperty(routerHistory, "location", {
1724
- enumerable: true,
1725
- get: () => queue[position][0]
1726
- });
1727
- Object.defineProperty(routerHistory, "state", {
1728
- enumerable: true,
1729
- get: () => queue[position][1]
1730
- });
1731
- return routerHistory;
1732
- }
1733
- var ROOT_TOKEN = {
1734
- type: 0,
1735
- value: ""
1736
- };
1737
- var VALID_PARAM_RE = /[a-zA-Z0-9_]/;
1738
- function tokenizePath(path) {
1739
- if (!path) return [[]];
1740
- if (path === "/") return [[ROOT_TOKEN]];
1741
- if (!isAbsolutePath(path)) throw new Error(`Route paths should start with a "/": "${path}" should be "/${path}".`);
1742
- function crash(message) {
1743
- throw new Error(`ERR (${state})/"${buffer}": ${message}`);
1744
- }
1745
- let state = 0;
1746
- let previousState = state;
1747
- const tokens = [];
1748
- let segment;
1749
- function finalizeSegment() {
1750
- if (segment) tokens.push(segment);
1751
- segment = [];
1752
- }
1753
- let i = 0;
1754
- let char;
1755
- let buffer = "";
1756
- let customRe = "";
1757
- function consumeBuffer() {
1758
- if (!buffer) return;
1759
- if (state === 0) segment.push({
1760
- type: 0,
1761
- value: buffer
1762
- });
1763
- else if (state === 1 || state === 2 || state === 3) {
1764
- if (segment.length > 1 && (char === "*" || char === "+")) crash(`A repeatable param (${buffer}) must be alone in its segment. eg: '/:ids+.`);
1765
- segment.push({
1766
- type: 1,
1767
- value: buffer,
1768
- regexp: customRe,
1769
- repeatable: char === "*" || char === "+",
1770
- optional: char === "*" || char === "?"
1771
- });
1772
- } else crash("Invalid state to consume buffer");
1773
- buffer = "";
1774
- }
1775
- function addCharToBuffer() {
1776
- buffer += char;
1777
- }
1778
- while (i < path.length) {
1779
- char = path[i++];
1780
- switch (state) {
1781
- case 0:
1782
- if (char === "\\") {
1783
- previousState = state;
1784
- state = 4;
1785
- } else if (char === "/") {
1786
- if (buffer) consumeBuffer();
1787
- finalizeSegment();
1788
- } else if (char === ":") {
1789
- consumeBuffer();
1790
- state = 1;
1791
- } else addCharToBuffer();
1792
- break;
1793
- case 4:
1794
- addCharToBuffer();
1795
- state = previousState;
1796
- break;
1797
- case 1:
1798
- if (char === "(") state = 2;
1799
- else if (VALID_PARAM_RE.test(char)) addCharToBuffer();
1800
- else {
1801
- consumeBuffer();
1802
- state = 0;
1803
- if (char !== "*" && char !== "?" && char !== "+") i--;
1804
- }
1805
- break;
1806
- case 2:
1807
- if (char === ")") {
1808
- if (customRe[customRe.length - 1] == "\\") customRe = customRe.slice(0, -1) + char;
1809
- else state = 3;
1810
- } else customRe += char;
1811
- break;
1812
- case 3:
1813
- consumeBuffer();
1814
- state = 0;
1815
- if (char !== "*" && char !== "?" && char !== "+") i--;
1816
- customRe = "";
1817
- break;
1818
- default: crash("Unknown state");
1819
- }
1820
- }
1821
- if (state === 2) crash(`Unfinished custom RegExp for param "${buffer}"`);
1822
- consumeBuffer();
1823
- finalizeSegment();
1824
- return tokens;
1825
- }
1826
- var BASE_PARAM_PATTERN = "[^/]+?";
1827
- var BASE_PATH_PARSER_OPTIONS = {
1828
- sensitive: false,
1829
- strict: false,
1830
- start: true,
1831
- end: true
1832
- };
1833
- var REGEX_CHARS_RE = /[.+*?^${}()[\]/\\]/g;
1834
- /**
1835
- * Creates a path parser from an array of Segments (a segment is an array of Tokens)
1836
- *
1837
- * @param segments - array of segments returned by tokenizePath
1838
- * @param extraOptions - optional options for the regexp
1839
- * @returns a PathParser
1840
- */
1841
- function tokensToParser(segments, extraOptions) {
1842
- const options = assign({}, BASE_PATH_PARSER_OPTIONS, extraOptions);
1843
- const score = [];
1844
- let pattern = options.start ? "^" : "";
1845
- const keys = [];
1846
- for (const segment of segments) {
1847
- const segmentScores = segment.length ? [] : [90];
1848
- if (options.strict && !segment.length) pattern += "/";
1849
- for (let tokenIndex = 0; tokenIndex < segment.length; tokenIndex++) {
1850
- const token = segment[tokenIndex];
1851
- let subSegmentScore = 40 + (options.sensitive ? .25 : 0);
1852
- if (token.type === 0) {
1853
- if (!tokenIndex) pattern += "/";
1854
- pattern += token.value.replace(REGEX_CHARS_RE, "\\$&");
1855
- subSegmentScore += 40;
1856
- } else if (token.type === 1) {
1857
- const { value, repeatable, optional, regexp } = token;
1858
- keys.push({
1859
- name: value,
1860
- repeatable,
1861
- optional
1862
- });
1863
- const re = regexp ? regexp : BASE_PARAM_PATTERN;
1864
- if (re !== BASE_PARAM_PATTERN) {
1865
- subSegmentScore += 10;
1866
- try {
1867
- new RegExp(`(${re})`);
1868
- } catch (err) {
1869
- throw new Error(`Invalid custom RegExp for param "${value}" (${re}): ` + err.message);
1870
- }
1871
- }
1872
- let subPattern = repeatable ? `((?:${re})(?:/(?:${re}))*)` : `(${re})`;
1873
- if (!tokenIndex) subPattern = optional && segment.length < 2 ? `(?:/${subPattern})` : "/" + subPattern;
1874
- if (optional) subPattern += "?";
1875
- pattern += subPattern;
1876
- subSegmentScore += 20;
1877
- if (optional) subSegmentScore += -8;
1878
- if (repeatable) subSegmentScore += -20;
1879
- if (re === ".*") subSegmentScore += -50;
1880
- }
1881
- segmentScores.push(subSegmentScore);
1882
- }
1883
- score.push(segmentScores);
1884
- }
1885
- if (options.strict && options.end) {
1886
- const i = score.length - 1;
1887
- score[i][score[i].length - 1] += .7000000000000001;
1888
- }
1889
- if (!options.strict) pattern += "/?";
1890
- if (options.end) pattern += "$";
1891
- else if (options.strict && !pattern.endsWith("/")) pattern += "(?:/|$)";
1892
- const re = new RegExp(pattern, options.sensitive ? "" : "i");
1893
- function parse(path) {
1894
- const match = path.match(re);
1895
- const params = {};
1896
- if (!match) return null;
1897
- for (let i = 1; i < match.length; i++) {
1898
- const value = match[i] || "";
1899
- const key = keys[i - 1];
1900
- params[key.name] = value && key.repeatable ? value.split("/") : value;
1901
- }
1902
- return params;
1903
- }
1904
- function stringify(params) {
1905
- let path = "";
1906
- let avoidDuplicatedSlash = false;
1907
- for (const segment of segments) {
1908
- if (!avoidDuplicatedSlash || !path.endsWith("/")) path += "/";
1909
- avoidDuplicatedSlash = false;
1910
- for (const token of segment) if (token.type === 0) path += token.value;
1911
- else if (token.type === 1) {
1912
- const { value, repeatable, optional } = token;
1913
- const param = value in params ? params[value] : "";
1914
- if (isArray(param) && !repeatable) throw new Error(`Provided param "${value}" is an array but it is not repeatable (* or + modifiers)`);
1915
- const text = isArray(param) ? param.join("/") : param;
1916
- if (!text) {
1917
- if (optional) {
1918
- if (segment.length < 2) {
1919
- if (path.endsWith("/")) path = path.slice(0, -1);
1920
- else avoidDuplicatedSlash = true;
1921
- }
1922
- } else throw new Error(`Missing required param "${value}"`);
1923
- }
1924
- path += text;
1925
- }
1926
- }
1927
- return path || "/";
1928
- }
1929
- return {
1930
- re,
1931
- score,
1932
- keys,
1933
- parse,
1934
- stringify
1935
- };
1936
- }
1937
- /**
1938
- * Compares an array of numbers as used in PathParser.score and returns a
1939
- * number. This function can be used to `sort` an array
1940
- *
1941
- * @param a - first array of numbers
1942
- * @param b - second array of numbers
1943
- * @returns 0 if both are equal, < 0 if a should be sorted first, > 0 if b
1944
- * should be sorted first
1945
- */
1946
- function compareScoreArray(a, b) {
1947
- let i = 0;
1948
- while (i < a.length && i < b.length) {
1949
- const diff = b[i] - a[i];
1950
- if (diff) return diff;
1951
- i++;
1952
- }
1953
- if (a.length < b.length) return a.length === 1 && a[0] === 80 ? -1 : 1;
1954
- else if (a.length > b.length) return b.length === 1 && b[0] === 80 ? 1 : -1;
1955
- return 0;
1956
- }
1957
- /**
1958
- * Compare function that can be used with `sort` to sort an array of PathParser
1959
- *
1960
- * @param a - first PathParser
1961
- * @param b - second PathParser
1962
- * @returns 0 if both are equal, < 0 if a should be sorted first, > 0 if b
1963
- */
1964
- function comparePathParserScore(a, b) {
1965
- let i = 0;
1966
- const aScore = a.score;
1967
- const bScore = b.score;
1968
- while (i < aScore.length && i < bScore.length) {
1969
- const comp = compareScoreArray(aScore[i], bScore[i]);
1970
- if (comp) return comp;
1971
- i++;
1972
- }
1973
- if (Math.abs(bScore.length - aScore.length) === 1) {
1974
- if (isLastScoreNegative(aScore)) return 1;
1975
- if (isLastScoreNegative(bScore)) return -1;
1976
- }
1977
- return bScore.length - aScore.length;
1978
- }
1979
- /**
1980
- * This allows detecting splats at the end of a path: /home/:id(.*)*
1981
- *
1982
- * @param score - score to check
1983
- * @returns true if the last entry is negative
1984
- */
1985
- function isLastScoreNegative(score) {
1986
- const last = score[score.length - 1];
1987
- return score.length > 0 && last[last.length - 1] < 0;
1988
- }
1989
- var PATH_PARSER_OPTIONS_DEFAULTS = {
1990
- strict: false,
1991
- end: true,
1992
- sensitive: false
1993
- };
1994
- function createRouteRecordMatcher(record, parent, options) {
1995
- const parser = tokensToParser(tokenizePath(record.path), options);
1996
- {
1997
- const existingKeys = /* @__PURE__ */ new Set();
1998
- for (const key of parser.keys) {
1999
- if (existingKeys.has(key.name)) diagnostics.VUE_ROUTER_R0090({
2000
- name: key.name,
2001
- path: record.path
2002
- });
2003
- existingKeys.add(key.name);
2004
- }
2005
- }
2006
- const matcher = assign(parser, {
2007
- record,
2008
- parent,
2009
- children: [],
2010
- alias: []
2011
- });
2012
- if (parent) {
2013
- if (!matcher.record.aliasOf === !parent.record.aliasOf) parent.children.push(matcher);
2014
- }
2015
- return matcher;
2016
- }
2017
- /**
2018
- * Creates a Router Matcher.
2019
- *
2020
- * @internal
2021
- * @param routes - array of initial routes
2022
- * @param globalOptions - global route options
2023
- */
2024
- function createRouterMatcher(routes, globalOptions) {
2025
- const matchers = [];
2026
- const matcherMap = /* @__PURE__ */ new Map();
2027
- globalOptions = mergeOptions(PATH_PARSER_OPTIONS_DEFAULTS, globalOptions);
2028
- function getRecordMatcher(name) {
2029
- return matcherMap.get(name);
2030
- }
2031
- function addRoute(record, parent, originalRecord) {
2032
- const isRootAdd = !originalRecord;
2033
- const mainNormalizedRecord = normalizeRouteRecord(record);
2034
- checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent);
2035
- mainNormalizedRecord.aliasOf = originalRecord && originalRecord.record;
2036
- const options = mergeOptions(globalOptions, record);
2037
- const normalizedRecords = [mainNormalizedRecord];
2038
- if ("alias" in record) {
2039
- const aliases = typeof record.alias === "string" ? [record.alias] : record.alias;
2040
- for (const alias of aliases) normalizedRecords.push(normalizeRouteRecord(assign({}, mainNormalizedRecord, {
2041
- components: originalRecord ? originalRecord.record.components : mainNormalizedRecord.components,
2042
- path: alias,
2043
- aliasOf: originalRecord ? originalRecord.record : mainNormalizedRecord
2044
- })));
2045
- }
2046
- let matcher;
2047
- let originalMatcher;
2048
- for (const normalizedRecord of normalizedRecords) {
2049
- const { path } = normalizedRecord;
2050
- if (parent && !isAbsolutePath(path)) {
2051
- const parentPath = parent.record.path;
2052
- const connectingSlash = parentPath[parentPath.length - 1] === "/" ? "" : "/";
2053
- normalizedRecord.path = parent.record.path + (path && connectingSlash + path);
2054
- }
2055
- if (normalizedRecord.path === "*") throw new Error("Catch all routes (\"*\") must now be defined using a param with a custom regexp.\nSee more at https://router.vuejs.org/guide/migration/#Removed-star-or-catch-all-routes.");
2056
- matcher = createRouteRecordMatcher(normalizedRecord, parent, options);
2057
- if (parent && isAbsolutePath(path)) checkMissingParamsInAbsolutePath(matcher, parent);
2058
- if (originalRecord) {
2059
- originalRecord.alias.push(matcher);
2060
- checkSameParams(originalRecord, matcher);
2061
- } else {
2062
- originalMatcher = originalMatcher || matcher;
2063
- if (originalMatcher !== matcher) originalMatcher.alias.push(matcher);
2064
- if (isRootAdd && record.name && !isAliasRecord(matcher)) {
2065
- checkSameNameAsAncestor(record, parent);
2066
- removeRoute(record.name);
2067
- }
2068
- }
2069
- if (isMatchable(matcher)) insertMatcher(matcher);
2070
- if (mainNormalizedRecord.children) {
2071
- const children = mainNormalizedRecord.children;
2072
- for (let i = 0; i < children.length; i++) addRoute(children[i], matcher, originalRecord && originalRecord.children[i]);
2073
- }
2074
- originalRecord = originalRecord || matcher;
2075
- }
2076
- return originalMatcher ? () => {
2077
- removeRoute(originalMatcher);
2078
- } : noop;
2079
- }
2080
- function removeRoute(matcherRef) {
2081
- if (isRouteName(matcherRef)) {
2082
- const matcher = matcherMap.get(matcherRef);
2083
- if (matcher) {
2084
- matcherMap.delete(matcherRef);
2085
- matchers.splice(matchers.indexOf(matcher), 1);
2086
- matcher.children.forEach(removeRoute);
2087
- matcher.alias.forEach(removeRoute);
2088
- }
2089
- } else {
2090
- const index = matchers.indexOf(matcherRef);
2091
- if (index > -1) {
2092
- matchers.splice(index, 1);
2093
- if (matcherRef.record.name) matcherMap.delete(matcherRef.record.name);
2094
- matcherRef.children.forEach(removeRoute);
2095
- matcherRef.alias.forEach(removeRoute);
2096
- }
2097
- }
2098
- }
2099
- function getRoutes() {
2100
- return matchers;
2101
- }
2102
- function insertMatcher(matcher) {
2103
- const index = findInsertionIndex(matcher, matchers);
2104
- matchers.splice(index, 0, matcher);
2105
- if (matcher.record.name && !isAliasRecord(matcher)) matcherMap.set(matcher.record.name, matcher);
2106
- }
2107
- function resolve(location, currentLocation) {
2108
- let matcher;
2109
- let params = {};
2110
- let path;
2111
- let name;
2112
- if ("name" in location && location.name) {
2113
- matcher = matcherMap.get(location.name);
2114
- if (!matcher) throw createRouterError(1, { location });
2115
- {
2116
- const invalidParams = Object.keys(location.params || {}).filter((paramName) => !matcher.keys.find((k) => k.name === paramName));
2117
- if (invalidParams.length) {
2118
- const isInherited = !matcher.keys.length && invalidParams.some((name) => name in currentLocation.params);
2119
- diagnostics.VUE_ROUTER_R0100({
2120
- params: invalidParams.join("\", \""),
2121
- inherited: isInherited ? ` If you are using a catch-all route with a named redirect, pass an empty \`params\` object: \`redirect: { name: '...', params: {} }\`.` : ""
2122
- });
2123
- }
2124
- }
2125
- name = matcher.record.name;
2126
- params = assign(pickParams(currentLocation.params, matcher.keys.filter((k) => !k.optional).concat(matcher.parent ? matcher.parent.keys.filter((k) => k.optional) : []).map((k) => k.name)), location.params && pickParams(location.params, matcher.keys.map((k) => k.name)));
2127
- path = matcher.stringify(params);
2128
- } else if (location.path != null) {
2129
- path = location.path;
2130
- if (!isAbsolutePath(path)) diagnostics.VUE_ROUTER_R0101({ path });
2131
- matcher = matchers.find((m) => m.re.test(path));
2132
- if (matcher) {
2133
- params = matcher.parse(path);
2134
- name = matcher.record.name;
2135
- matcher.keys.forEach((key) => {
2136
- if (key.optional && !params[key.name]) delete params[key.name];
2137
- });
2138
- }
2139
- } else {
2140
- matcher = currentLocation.name ? matcherMap.get(currentLocation.name) : matchers.find((m) => m.re.test(currentLocation.path));
2141
- if (!matcher) throw createRouterError(1, {
2142
- location,
2143
- currentLocation
2144
- });
2145
- name = matcher.record.name;
2146
- params = assign({}, currentLocation.params, location.params);
2147
- path = matcher.stringify(params);
2148
- }
2149
- const matched = [];
2150
- let parentMatcher = matcher;
2151
- while (parentMatcher) {
2152
- matched.unshift(parentMatcher.record);
2153
- parentMatcher = parentMatcher.parent;
2154
- }
2155
- return {
2156
- name,
2157
- path,
2158
- params,
2159
- matched,
2160
- meta: mergeMetaFields(matched)
2161
- };
2162
- }
2163
- routes.forEach((route) => addRoute(route));
2164
- function clearRoutes() {
2165
- matchers.length = 0;
2166
- matcherMap.clear();
2167
- }
2168
- return {
2169
- addRoute,
2170
- resolve,
2171
- removeRoute,
2172
- clearRoutes,
2173
- getRoutes,
2174
- getRecordMatcher
2175
- };
2176
- }
2177
- /**
2178
- * Picks an object param to contain only specified keys.
2179
- *
2180
- * @param params - params object to pick from
2181
- * @param keys - keys to pick
2182
- */
2183
- function pickParams(params, keys) {
2184
- const newParams = {};
2185
- for (const key of keys) if (key in params) newParams[key] = params[key];
2186
- return newParams;
2187
- }
2188
- /**
2189
- * Normalizes a RouteRecordRaw. Creates a copy
2190
- *
2191
- * @param record
2192
- * @returns the normalized version
2193
- */
2194
- function normalizeRouteRecord(record) {
2195
- const normalized = {
2196
- path: record.path,
2197
- redirect: record.redirect,
2198
- name: record.name,
2199
- meta: record.meta || {},
2200
- aliasOf: record.aliasOf,
2201
- beforeEnter: record.beforeEnter,
2202
- props: normalizeRecordProps(record),
2203
- children: record.children || [],
2204
- instances: {},
2205
- leaveGuards: /* @__PURE__ */ new Set(),
2206
- updateGuards: /* @__PURE__ */ new Set(),
2207
- enterCallbacks: {},
2208
- components: "components" in record ? record.components || null : record.component && { default: record.component }
2209
- };
2210
- Object.defineProperty(normalized, "mods", { value: {} });
2211
- return normalized;
2212
- }
2213
- /**
2214
- * Normalize the optional `props` in a record to always be an object similar to
2215
- * components. Also accept a boolean for components.
2216
- * @param record
2217
- */
2218
- function normalizeRecordProps(record) {
2219
- const propsObject = {};
2220
- const props = record.props || false;
2221
- if ("component" in record) propsObject.default = props;
2222
- else for (const name in record.components) propsObject[name] = typeof props === "object" ? props[name] : props;
2223
- return propsObject;
2224
- }
2225
- /**
2226
- * Checks if a record or any of its parent is an alias
2227
- * @param record
2228
- */
2229
- function isAliasRecord(record) {
2230
- while (record) {
2231
- if (record.record.aliasOf) return true;
2232
- record = record.parent;
2233
- }
2234
- return false;
2235
- }
2236
- /**
2237
- * Merge meta fields of an array of records
2238
- *
2239
- * @param matched - array of matched records
2240
- */
2241
- function mergeMetaFields(matched) {
2242
- return matched.reduce((meta, record) => assign(meta, record.meta), {});
2243
- }
2244
- function isSameParam(a, b) {
2245
- return a.name === b.name && a.optional === b.optional && a.repeatable === b.repeatable;
2246
- }
2247
- /**
2248
- * Check if a path and its alias have the same required params
2249
- *
2250
- * @param a - original record
2251
- * @param b - alias record
2252
- */
2253
- function checkSameParams(a, b) {
2254
- for (const key of a.keys) if (!key.optional && !b.keys.find(isSameParam.bind(null, key))) {
2255
- diagnostics.VUE_ROUTER_R0102({
2256
- alias: b.record.path,
2257
- original: a.record.path,
2258
- name: key.name
2259
- });
2260
- return;
2261
- }
2262
- for (const key of b.keys) if (!key.optional && !a.keys.find(isSameParam.bind(null, key))) {
2263
- diagnostics.VUE_ROUTER_R0102({
2264
- alias: b.record.path,
2265
- original: a.record.path,
2266
- name: key.name
2267
- });
2268
- return;
2269
- }
2270
- }
2271
- /**
2272
- * A route with a name and a child with an empty path without a name should warn when adding the route
2273
- *
2274
- * @param mainNormalizedRecord - RouteRecordNormalized
2275
- * @param parent - RouteRecordMatcher
2276
- */
2277
- function checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent) {
2278
- if (parent && parent.record.name && !mainNormalizedRecord.name && !mainNormalizedRecord.path && mainNormalizedRecord.children.length === 0) diagnostics.VUE_ROUTER_R0103({ name: String(parent.record.name) });
2279
- }
2280
- function checkSameNameAsAncestor(record, parent) {
2281
- for (let ancestor = parent; ancestor; ancestor = ancestor.parent) if (ancestor.record.name === record.name) throw new Error(`A route named "${String(record.name)}" has been added as a ${parent === ancestor ? "child" : "descendant"} of a route with the same name. Route names must be unique and a nested route cannot use the same name as an ancestor.`);
2282
- }
2283
- function checkMissingParamsInAbsolutePath(record, parent) {
2284
- for (const key of parent.keys) if (!record.keys.find(isSameParam.bind(null, key))) {
2285
- diagnostics.VUE_ROUTER_R0104({
2286
- path: record.record.path,
2287
- name: key.name,
2288
- parent: parent.record.path
2289
- });
2290
- return;
2291
- }
2292
- }
2293
- /**
2294
- * Performs a binary search to find the correct insertion index for a new matcher.
2295
- *
2296
- * Matchers are primarily sorted by their score. If scores are tied then we also consider parent/child relationships,
2297
- * with descendants coming before ancestors. If there's still a tie, new routes are inserted after existing routes.
2298
- *
2299
- * @param matcher - new matcher to be inserted
2300
- * @param matchers - existing matchers
2301
- */
2302
- function findInsertionIndex(matcher, matchers) {
2303
- let lower = 0;
2304
- let upper = matchers.length;
2305
- while (lower !== upper) {
2306
- const mid = lower + upper >> 1;
2307
- if (comparePathParserScore(matcher, matchers[mid]) < 0) upper = mid;
2308
- else lower = mid + 1;
2309
- }
2310
- const insertionAncestor = getInsertionAncestor(matcher);
2311
- if (insertionAncestor) {
2312
- upper = matchers.lastIndexOf(insertionAncestor, upper - 1);
2313
- if (upper < 0) diagnostics.VUE_ROUTER_R0105({
2314
- ancestor: insertionAncestor.record.path,
2315
- record: matcher.record.path
2316
- });
2317
- }
2318
- return upper;
2319
- }
2320
- function getInsertionAncestor(matcher) {
2321
- let ancestor = matcher;
2322
- while (ancestor = ancestor.parent) if (isMatchable(ancestor) && comparePathParserScore(matcher, ancestor) === 0) return ancestor;
2323
- }
2324
- /**
2325
- * Checks if a matcher can be reachable. This means if it's possible to reach it as a route. For example, routes without
2326
- * a component, or name, or redirect, are just used to group other routes.
2327
- * @param matcher
2328
- * @param matcher.record record of the matcher
2329
- * @returns
2330
- */
2331
- function isMatchable({ record }) {
2332
- return !!(record.name || record.components && Object.keys(record.components).length || record.redirect);
2333
- }
2334
- /**
2335
- * Returns the internal behavior of a {@link RouterLink} without the rendering part.
2336
- *
2337
- * @param props - a `to` location and an optional `replace` flag
2338
- */
2339
- function useLink(props) {
2340
- const router = inject(routerKey);
2341
- const currentRoute = inject(routeLocationKey);
2342
- let hasPrevious = false;
2343
- let previousTo = null;
2344
- const route = computed(() => {
2345
- const to = unref(props.to);
2346
- if (!hasPrevious || to !== previousTo) {
2347
- if (!isRouteLocation(to)) diagnostics.VUE_ROUTER_R0050({ to });
2348
- previousTo = to;
2349
- hasPrevious = true;
2350
- }
2351
- return router.resolve(to);
2352
- });
2353
- const activeRecordIndex = computed(() => {
2354
- const { matched } = route.value;
2355
- const { length } = matched;
2356
- const routeMatched = matched[length - 1];
2357
- const currentMatched = currentRoute.matched;
2358
- if (!routeMatched || !currentMatched.length) return -1;
2359
- const index = currentMatched.findIndex(isSameRouteRecord.bind(null, routeMatched));
2360
- if (index > -1) return index;
2361
- const parentRecordPath = getOriginalPath(matched[length - 2]);
2362
- return length > 1 && getOriginalPath(routeMatched) === parentRecordPath && currentMatched[currentMatched.length - 1].path !== parentRecordPath ? currentMatched.findIndex(isSameRouteRecord.bind(null, matched[length - 2])) : index;
2363
- });
2364
- const isActive = computed(() => activeRecordIndex.value > -1 && includesParams(currentRoute.params, route.value.params));
2365
- const isExactActive = computed(() => activeRecordIndex.value > -1 && activeRecordIndex.value === currentRoute.matched.length - 1 && isSameRouteLocationParams(currentRoute.params, route.value.params));
2366
- function navigate(e = {}) {
2367
- if (guardEvent(e)) {
2368
- const p = router[unref(props.replace) ? "replace" : "push"](unref(props.to)).catch(noop);
2369
- if (props.viewTransition && typeof document !== "undefined" && "startViewTransition" in document) document.startViewTransition(() => p);
2370
- return p;
2371
- }
2372
- return Promise.resolve();
2373
- }
2374
- if (isBrowser) {
2375
- const instance = getCurrentInstance();
2376
- if (instance) {
2377
- const linkContextDevtools = {
2378
- route: route.value,
2379
- isActive: isActive.value,
2380
- isExactActive: isExactActive.value,
2381
- error: null
2382
- };
2383
- instance.__vrl_devtools = instance.__vrl_devtools || [];
2384
- instance.__vrl_devtools.push(linkContextDevtools);
2385
- watchEffect(() => {
2386
- linkContextDevtools.route = route.value;
2387
- linkContextDevtools.isActive = isActive.value;
2388
- linkContextDevtools.isExactActive = isExactActive.value;
2389
- linkContextDevtools.error = isRouteLocation(unref(props.to)) ? null : "Invalid \"to\" value";
2390
- }, { flush: "post" });
2391
- }
2392
- }
2393
- /**
2394
- * NOTE: update {@link _RouterLinkI}'s `$slots` type when updating this
2395
- */
2396
- return {
2397
- route,
2398
- href: computed(() => route.value.href),
2399
- isActive,
2400
- isExactActive,
2401
- navigate
2402
- };
2403
- }
2404
- function preferSingleVNode(vnodes) {
2405
- return vnodes.length === 1 ? vnodes[0] : vnodes;
2406
- }
2407
- /**
2408
- * Component to render a link that triggers a navigation on click.
2409
- */
2410
- var RouterLink = /* @__PURE__ */ defineComponent({
2411
- name: "RouterLink",
2412
- compatConfig: { MODE: 3 },
2413
- props: {
2414
- to: {
2415
- type: [String, Object],
2416
- required: true
2417
- },
2418
- replace: Boolean,
2419
- activeClass: String,
2420
- exactActiveClass: String,
2421
- custom: Boolean,
2422
- ariaCurrentValue: {
2423
- type: String,
2424
- default: "page"
2425
- },
2426
- viewTransition: Boolean
2427
- },
2428
- useLink,
2429
- setup(props, { slots }) {
2430
- const link = reactive(useLink(props));
2431
- const { options } = inject(routerKey);
2432
- const elClass = computed(() => ({
2433
- [getLinkClass(props.activeClass, options.linkActiveClass, "router-link-active")]: link.isActive,
2434
- [getLinkClass(props.exactActiveClass, options.linkExactActiveClass, "router-link-exact-active")]: link.isExactActive
2435
- }));
2436
- return () => {
2437
- const children = slots.default && preferSingleVNode(slots.default(link));
2438
- return props.custom ? children : h("a", {
2439
- "aria-current": link.isExactActive ? props.ariaCurrentValue : null,
2440
- href: link.href,
2441
- onClick: link.navigate,
2442
- class: elClass.value
2443
- }, children);
2444
- };
2445
- }
2446
- });
2447
- function guardEvent(e) {
2448
- if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return;
2449
- if (e.defaultPrevented) return;
2450
- if (e.button !== void 0 && e.button !== 0) return;
2451
- if (e.currentTarget && e.currentTarget.getAttribute) {
2452
- const target = e.currentTarget.getAttribute("target");
2453
- if (/\b_blank\b/i.test(target)) return;
2454
- }
2455
- if (e.preventDefault) e.preventDefault();
2456
- return true;
2457
- }
2458
- function includesParams(outer, inner) {
2459
- for (const key in inner) {
2460
- const innerValue = inner[key];
2461
- const outerValue = outer[key];
2462
- if (isArray(innerValue)) {
2463
- if (!isArray(outerValue) || outerValue.length !== innerValue.length || innerValue.some((value, i) => value.valueOf() !== outerValue[i].valueOf())) return false;
2464
- } else if (innerValue !== outerValue) return false;
2465
- }
2466
- return true;
2467
- }
2468
- /**
2469
- * Get the original path value of a record by following its aliasOf
2470
- * @param record
2471
- */
2472
- function getOriginalPath(record) {
2473
- return record ? record.aliasOf ? record.aliasOf.path : record.path : "";
2474
- }
2475
- /**
2476
- * Utility class to get the active class based on defaults.
2477
- * @param propClass
2478
- * @param globalClass
2479
- * @param defaultClass
2480
- */
2481
- var getLinkClass = (propClass, globalClass, defaultClass) => propClass != null ? propClass : globalClass != null ? globalClass : defaultClass;
2482
- var RouterViewImpl = /*#__PURE__*/ defineComponent({
2483
- name: "RouterView",
2484
- inheritAttrs: false,
2485
- props: {
2486
- name: {
2487
- type: String,
2488
- default: "default"
2489
- },
2490
- route: Object
2491
- },
2492
- compatConfig: { MODE: 3 },
2493
- setup(props, { attrs, slots }) {
2494
- warnDeprecatedUsage();
2495
- const injectedRoute = inject(routerViewLocationKey);
2496
- const routeToDisplay = computed(() => props.route || injectedRoute.value);
2497
- const injectedDepth = inject(viewDepthKey, 0);
2498
- const depth = computed(() => {
2499
- let initialDepth = unref(injectedDepth);
2500
- const { matched } = routeToDisplay.value;
2501
- let matchedRoute;
2502
- while ((matchedRoute = matched[initialDepth]) && !matchedRoute.components) initialDepth++;
2503
- return initialDepth;
2504
- });
2505
- const matchedRouteRef = computed(() => routeToDisplay.value.matched[depth.value]);
2506
- provide(viewDepthKey, computed(() => depth.value + 1));
2507
- provide(matchedRouteKey, matchedRouteRef);
2508
- provide(routerViewLocationKey, routeToDisplay);
2509
- const viewRef = ref();
2510
- watch(() => [
2511
- viewRef.value,
2512
- matchedRouteRef.value,
2513
- props.name
2514
- ], ([instance, to, name], [oldInstance, from, _oldName]) => {
2515
- if (to) {
2516
- to.instances[name] = instance;
2517
- if (from && from !== to && instance && instance === oldInstance) {
2518
- if (!to.leaveGuards.size) to.leaveGuards = from.leaveGuards;
2519
- if (!to.updateGuards.size) to.updateGuards = from.updateGuards;
2520
- }
2521
- }
2522
- if (instance && to && (!from || !isSameRouteRecord(to, from) || !oldInstance)) (to.enterCallbacks[name] || []).forEach((callback) => callback(instance));
2523
- }, { flush: "post" });
2524
- return () => {
2525
- const route = routeToDisplay.value;
2526
- const currentName = props.name;
2527
- const matchedRoute = matchedRouteRef.value;
2528
- const ViewComponent = matchedRoute && matchedRoute.components[currentName];
2529
- if (!ViewComponent) return normalizeSlot(slots.default, {
2530
- Component: ViewComponent,
2531
- route
2532
- });
2533
- const routePropsOption = matchedRoute.props[currentName];
2534
- const routeProps = routePropsOption ? routePropsOption === true ? route.params : typeof routePropsOption === "function" ? routePropsOption(route) : routePropsOption : null;
2535
- const onVnodeUnmounted = (vnode) => {
2536
- if (vnode.component.isUnmounted) matchedRoute.instances[currentName] = null;
2537
- };
2538
- const component = h(ViewComponent, assign({}, routeProps, attrs, {
2539
- onVnodeUnmounted,
2540
- ref: viewRef
2541
- }));
2542
- if (isBrowser && component.ref) {
2543
- const info = {
2544
- depth: depth.value,
2545
- name: matchedRoute.name,
2546
- path: matchedRoute.path,
2547
- meta: matchedRoute.meta
2548
- };
2549
- (isArray(component.ref) ? component.ref.map((r) => r.i) : [component.ref.i]).forEach((instance) => {
2550
- if (instance) instance.__vrv_devtools = info;
2551
- });
2552
- }
2553
- return normalizeSlot(slots.default, {
2554
- Component: component,
2555
- route
2556
- }) || component;
2557
- };
2558
- }
2559
- });
2560
- function normalizeSlot(slot, data) {
2561
- if (!slot) return null;
2562
- const slotContent = slot(data);
2563
- return slotContent.length === 1 ? slotContent[0] : slotContent;
2564
- }
2565
- /**
2566
- * Component to display the current route the user is at.
2567
- */
2568
- var RouterView = RouterViewImpl;
2569
- function warnDeprecatedUsage() {
2570
- const instance = getCurrentInstance();
2571
- const parentName = instance.parent && instance.parent.type.name;
2572
- const parentSubTreeType = instance.parent && instance.parent.subTree && instance.parent.subTree.type;
2573
- if (parentName && (parentName === "KeepAlive" || parentName.includes("Transition")) && typeof parentSubTreeType === "object" && parentSubTreeType.name === "RouterView") {
2574
- const comp = parentName === "KeepAlive" ? "keep-alive" : "transition";
2575
- diagnostics.VUE_ROUTER_R0060({ comp });
2576
- }
2577
- }
2578
- /**
2579
- * Creates a Router instance that can be used by a Vue app.
2580
- *
2581
- * @param options - {@link RouterOptions}
2582
- */
2583
- function createRouter(options) {
2584
- const matcher = createRouterMatcher(options.routes, options);
2585
- const parseQuery$1 = options.parseQuery || parseQuery;
2586
- const stringifyQuery$1 = options.stringifyQuery || stringifyQuery;
2587
- const routerHistory = options.history;
2588
- if (!routerHistory) throw new Error("Provide the \"history\" option when calling \"createRouter()\": https://router.vuejs.org/api/interfaces/RouterOptions.html#history");
2589
- const beforeGuards = useCallbacks();
2590
- const beforeResolveGuards = useCallbacks();
2591
- const afterGuards = useCallbacks();
2592
- const currentRoute = shallowRef(START_LOCATION_NORMALIZED);
2593
- const routesVersion = shallowRef(0);
2594
- let pendingLocation = START_LOCATION_NORMALIZED;
2595
- if (isBrowser && options.scrollBehavior && "scrollRestoration" in history) history.scrollRestoration = "manual";
2596
- const normalizeParams = applyToParams.bind(null, (paramValue) => "" + paramValue);
2597
- const encodeParams = applyToParams.bind(null, encodeParam);
2598
- const decodeParams = applyToParams.bind(null, decode);
2599
- function addRoute(parentOrRoute, route) {
2600
- let parent;
2601
- let record;
2602
- if (isRouteName(parentOrRoute)) {
2603
- parent = matcher.getRecordMatcher(parentOrRoute);
2604
- if (!parent) diagnostics.VUE_ROUTER_R0001({ name: String(parentOrRoute) });
2605
- record = route;
2606
- } else record = parentOrRoute;
2607
- const removeRoute = matcher.addRoute(record, parent);
2608
- routesVersion.value++;
2609
- return () => {
2610
- removeRoute();
2611
- routesVersion.value++;
2612
- };
2613
- }
2614
- function removeRoute(name) {
2615
- const recordMatcher = matcher.getRecordMatcher(name);
2616
- if (recordMatcher) {
2617
- matcher.removeRoute(recordMatcher);
2618
- routesVersion.value++;
2619
- } else diagnostics.VUE_ROUTER_R0002({ name: String(name) });
2620
- }
2621
- function clearRoutes() {
2622
- matcher.clearRoutes();
2623
- routesVersion.value++;
2624
- }
2625
- function getRoutes() {
2626
- return matcher.getRoutes().map((routeMatcher) => routeMatcher.record);
2627
- }
2628
- function hasRoute(name) {
2629
- return !!matcher.getRecordMatcher(name);
2630
- }
2631
- function resolve(rawLocation, currentLocation) {
2632
- routesVersion.value;
2633
- if (typeof rawLocation === "string") {
2634
- currentLocation = currentLocation || (rawLocation.startsWith("/") ? START_LOCATION_NORMALIZED : currentRoute.value);
2635
- const locationNormalized = parseURL(parseQuery$1, rawLocation, currentLocation.path);
2636
- const matchedRoute = matcher.resolve({ path: locationNormalized.path }, currentLocation);
2637
- const href = routerHistory.createHref(locationNormalized.fullPath);
2638
- if (href.startsWith("//")) diagnostics.VUE_ROUTER_R0003({
2639
- location: rawLocation,
2640
- href
2641
- });
2642
- else if (!matchedRoute.matched.length) diagnostics.VUE_ROUTER_R0004({ path: rawLocation });
2643
- return assign(locationNormalized, matchedRoute, {
2644
- params: decodeParams(matchedRoute.params),
2645
- redirectedFrom: void 0,
2646
- href
2647
- });
2648
- }
2649
- if (!isRouteLocation(rawLocation)) {
2650
- diagnostics.VUE_ROUTER_R0005({ rawLocation });
2651
- return resolve({});
2652
- }
2653
- currentLocation = assign({}, currentLocation || (rawLocation.path != null && rawLocation.path.startsWith("/") && !("name" in rawLocation && rawLocation.name) ? START_LOCATION_NORMALIZED : currentRoute.value));
2654
- let matcherLocation;
2655
- if (rawLocation.path != null) {
2656
- if ("params" in rawLocation && !("name" in rawLocation) && Object.keys(rawLocation.params).length) diagnostics.VUE_ROUTER_R0006({ path: rawLocation.path });
2657
- matcherLocation = assign({}, rawLocation, { path: parseURL(parseQuery$1, rawLocation.path, currentLocation.path).path });
2658
- } else {
2659
- const targetParams = assign({}, rawLocation.params);
2660
- for (const key in targetParams) if (targetParams[key] == null) delete targetParams[key];
2661
- matcherLocation = assign({}, rawLocation, { params: encodeParams(targetParams) });
2662
- currentLocation.params = encodeParams(currentLocation.params);
2663
- }
2664
- const matchedRoute = matcher.resolve(matcherLocation, currentLocation);
2665
- const hash = rawLocation.hash || "";
2666
- if (hash && !hash.startsWith("#")) diagnostics.VUE_ROUTER_R0007({ hash });
2667
- matchedRoute.params = normalizeParams(decodeParams(matchedRoute.params));
2668
- const fullPath = stringifyURL(stringifyQuery$1, assign({}, rawLocation, {
2669
- hash: encodeHash(hash),
2670
- path: matchedRoute.path
2671
- }));
2672
- const href = routerHistory.createHref(fullPath);
2673
- if (href.startsWith("//")) diagnostics.VUE_ROUTER_R0003({
2674
- location: rawLocation,
2675
- href
2676
- });
2677
- else if (!matchedRoute.matched.length) diagnostics.VUE_ROUTER_R0004({ path: rawLocation.path != null ? rawLocation.path : rawLocation });
2678
- return assign({
2679
- fullPath,
2680
- hash,
2681
- query: stringifyQuery$1 === stringifyQuery ? normalizeQuery(rawLocation.query) : rawLocation.query || {}
2682
- }, matchedRoute, {
2683
- redirectedFrom: void 0,
2684
- href
2685
- });
2686
- }
2687
- function locationAsObject(to) {
2688
- return typeof to === "string" ? parseURL(parseQuery$1, to, currentRoute.value.path) : assign({}, to);
2689
- }
2690
- function checkCanceledNavigation(to, from) {
2691
- if (pendingLocation !== to) return createRouterError(8, {
2692
- from,
2693
- to
2694
- });
2695
- }
2696
- function push(to) {
2697
- return pushWithRedirect(to);
2698
- }
2699
- function replace(to) {
2700
- return push(assign(locationAsObject(to), { replace: true }));
2701
- }
2702
- function handleRedirectRecord(to, from) {
2703
- const lastMatched = to.matched[to.matched.length - 1];
2704
- if (lastMatched && lastMatched.redirect) {
2705
- const { redirect } = lastMatched;
2706
- let newTargetLocation = typeof redirect === "function" ? redirect(to, from) : redirect;
2707
- if (typeof newTargetLocation === "string") {
2708
- newTargetLocation = newTargetLocation.includes("?") || newTargetLocation.includes("#") ? newTargetLocation = locationAsObject(newTargetLocation) : { path: newTargetLocation };
2709
- newTargetLocation.params = {};
2710
- }
2711
- if (newTargetLocation.path == null && !("name" in newTargetLocation)) {
2712
- diagnostics.VUE_ROUTER_R0008({
2713
- target: JSON.stringify(newTargetLocation, null, 2),
2714
- to: to.fullPath
2715
- });
2716
- throw new Error("Invalid redirect");
2717
- }
2718
- return assign({
2719
- query: to.query,
2720
- hash: to.hash,
2721
- params: newTargetLocation.path != null ? {} : to.params
2722
- }, newTargetLocation);
2723
- }
2724
- }
2725
- function pushWithRedirect(to, redirectedFrom) {
2726
- const targetLocation = pendingLocation = resolve(to);
2727
- const from = currentRoute.value;
2728
- const data = to.state;
2729
- const force = to.force;
2730
- const replace = to.replace === true;
2731
- const shouldRedirect = handleRedirectRecord(targetLocation, from);
2732
- if (shouldRedirect) return pushWithRedirect(assign(locationAsObject(shouldRedirect), {
2733
- state: typeof shouldRedirect === "object" ? assign({}, data, shouldRedirect.state) : data,
2734
- force,
2735
- replace
2736
- }), redirectedFrom || targetLocation);
2737
- const toLocation = targetLocation;
2738
- toLocation.redirectedFrom = redirectedFrom;
2739
- let failure;
2740
- if (!force && isSameRouteLocation(stringifyQuery$1, from, targetLocation)) {
2741
- failure = createRouterError(16, {
2742
- to: toLocation,
2743
- from
2744
- });
2745
- handleScroll(from, from, true, false);
2746
- }
2747
- return (failure ? Promise.resolve(failure) : navigate(toLocation, from)).catch((error) => isNavigationFailure(error) ? isNavigationFailure(error, 2) ? error : markAsReady(error) : triggerError(error, toLocation, from)).then((failure) => {
2748
- if (failure) {
2749
- if (isNavigationFailure(failure, 2)) {
2750
- if (isSameRouteLocation(stringifyQuery$1, resolve(failure.to), toLocation) && redirectedFrom && (redirectedFrom._count = redirectedFrom._count ? redirectedFrom._count + 1 : 1) > 30) {
2751
- diagnostics.VUE_ROUTER_R0009({
2752
- from: from.fullPath,
2753
- to: toLocation.fullPath
2754
- });
2755
- return Promise.reject(/* @__PURE__ */ new Error("Infinite redirect in navigation guard"));
2756
- }
2757
- return pushWithRedirect(assign({ replace }, locationAsObject(failure.to), {
2758
- state: typeof failure.to === "object" ? assign({}, data, failure.to.state) : data,
2759
- force
2760
- }), redirectedFrom || toLocation);
2761
- }
2762
- } else failure = finalizeNavigation(toLocation, from, true, replace, data);
2763
- triggerAfterEach(toLocation, from, failure);
2764
- return failure;
2765
- });
2766
- }
2767
- /**
2768
- * Helper to reject and skip all navigation guards if a new navigation happened
2769
- * @param to
2770
- * @param from
2771
- */
2772
- function checkCanceledNavigationAndReject(to, from) {
2773
- const error = checkCanceledNavigation(to, from);
2774
- return error ? Promise.reject(error) : Promise.resolve();
2775
- }
2776
- function runWithContext(fn) {
2777
- const app = installedApps.values().next().value;
2778
- return app && typeof app.runWithContext === "function" ? app.runWithContext(fn) : fn();
2779
- }
2780
- function navigate(to, from) {
2781
- let guards;
2782
- const [leavingRecords, updatingRecords, enteringRecords] = extractChangingRecords(to, from);
2783
- guards = extractComponentsGuards(leavingRecords.reverse(), "beforeRouteLeave", to, from);
2784
- for (const record of leavingRecords) record.leaveGuards.forEach((guard) => {
2785
- guards.push(guardToPromiseFn(guard, to, from));
2786
- });
2787
- const canceledNavigationCheck = checkCanceledNavigationAndReject.bind(null, to, from);
2788
- guards.push(canceledNavigationCheck);
2789
- return runGuardQueue(guards).then(() => {
2790
- guards = [];
2791
- for (const guard of beforeGuards.list()) guards.push(guardToPromiseFn(guard, to, from));
2792
- guards.push(canceledNavigationCheck);
2793
- return runGuardQueue(guards);
2794
- }).then(() => {
2795
- guards = extractComponentsGuards(updatingRecords, "beforeRouteUpdate", to, from);
2796
- for (const record of updatingRecords) record.updateGuards.forEach((guard) => {
2797
- guards.push(guardToPromiseFn(guard, to, from));
2798
- });
2799
- guards.push(canceledNavigationCheck);
2800
- return runGuardQueue(guards);
2801
- }).then(() => {
2802
- guards = [];
2803
- for (const record of enteringRecords) if (record.beforeEnter) {
2804
- if (isArray(record.beforeEnter)) for (const beforeEnter of record.beforeEnter) guards.push(guardToPromiseFn(beforeEnter, to, from));
2805
- else guards.push(guardToPromiseFn(record.beforeEnter, to, from));
2806
- }
2807
- guards.push(canceledNavigationCheck);
2808
- return runGuardQueue(guards);
2809
- }).then(() => {
2810
- to.matched.forEach((record) => record.enterCallbacks = {});
2811
- guards = extractComponentsGuards(enteringRecords, "beforeRouteEnter", to, from, runWithContext);
2812
- guards.push(canceledNavigationCheck);
2813
- return runGuardQueue(guards);
2814
- }).then(() => {
2815
- guards = [];
2816
- for (const guard of beforeResolveGuards.list()) guards.push(guardToPromiseFn(guard, to, from));
2817
- guards.push(canceledNavigationCheck);
2818
- return runGuardQueue(guards);
2819
- }).catch((err) => isNavigationFailure(err, 8) ? err : Promise.reject(err));
2820
- }
2821
- function triggerAfterEach(to, from, failure) {
2822
- afterGuards.list().forEach((guard) => runWithContext(() => guard(to, from, failure)));
2823
- }
2824
- /**
2825
- * - Cleans up any navigation guards
2826
- * - Changes the url if necessary
2827
- * - Calls the scrollBehavior
2828
- */
2829
- function finalizeNavigation(toLocation, from, isPush, replace, data) {
2830
- const error = checkCanceledNavigation(toLocation, from);
2831
- if (error) return error;
2832
- const isFirstNavigation = from === START_LOCATION_NORMALIZED;
2833
- const state = !isBrowser ? {} : history.state;
2834
- if (isPush) {
2835
- if (replace || isFirstNavigation) routerHistory.replace(toLocation.fullPath, assign({ scroll: isFirstNavigation && state && state.scroll }, data));
2836
- else routerHistory.push(toLocation.fullPath, data);
2837
- }
2838
- currentRoute.value = toLocation;
2839
- handleScroll(toLocation, from, isPush, isFirstNavigation);
2840
- markAsReady();
2841
- }
2842
- let removeHistoryListener;
2843
- function setupListeners() {
2844
- if (removeHistoryListener) return;
2845
- removeHistoryListener = routerHistory.listen((to, _from, info) => {
2846
- if (!router.listening) return;
2847
- const toLocation = resolve(to);
2848
- const shouldRedirect = handleRedirectRecord(toLocation, router.currentRoute.value);
2849
- if (shouldRedirect) {
2850
- pushWithRedirect(assign(shouldRedirect, {
2851
- replace: true,
2852
- force: true
2853
- }), toLocation).catch(noop);
2854
- return;
2855
- }
2856
- pendingLocation = toLocation;
2857
- const from = currentRoute.value;
2858
- if (isBrowser && info.delta) saveScrollPosition(getScrollKey(from.fullPath, info.delta));
2859
- navigate(toLocation, from).catch((error) => {
2860
- if (isNavigationFailure(error, 12)) return error;
2861
- if (isNavigationFailure(error, 2)) {
2862
- pushWithRedirect(assign(locationAsObject(error.to), { force: true }), toLocation).then((failure) => {
2863
- if (isNavigationFailure(failure, 20) && !info.delta && info.type === "pop") routerHistory.go(-1, false);
2864
- }).catch(noop);
2865
- return Promise.reject();
2866
- }
2867
- if (info.delta) routerHistory.go(-info.delta, false);
2868
- return triggerError(error, toLocation, from);
2869
- }).then((failure) => {
2870
- failure = failure || finalizeNavigation(toLocation, from, false);
2871
- if (failure) {
2872
- if (info.delta && !isNavigationFailure(failure, 8)) routerHistory.go(-info.delta, false);
2873
- else if (info.type === "pop" && isNavigationFailure(failure, 20)) routerHistory.go(-1, false);
2874
- }
2875
- triggerAfterEach(toLocation, from, failure);
2876
- }).catch(noop);
2877
- });
2878
- }
2879
- let readyHandlers = useCallbacks();
2880
- let errorListeners = useCallbacks();
2881
- let ready;
2882
- /**
2883
- * Trigger errorListeners added via onError and throws the error as well
2884
- *
2885
- * @param error - error to throw
2886
- * @param to - location we were navigating to when the error happened
2887
- * @param from - location we were navigating from when the error happened
2888
- * @returns the error as a rejected promise
2889
- */
2890
- function triggerError(error, to, from) {
2891
- markAsReady(error);
2892
- const list = errorListeners.list();
2893
- if (list.length) list.forEach((handler) => handler(error, to, from));
2894
- else {
2895
- diagnostics.VUE_ROUTER_R0010();
2896
- console.error(error);
2897
- }
2898
- return Promise.reject(error);
2899
- }
2900
- function isReady() {
2901
- if (ready && currentRoute.value !== START_LOCATION_NORMALIZED) return Promise.resolve();
2902
- return new Promise((resolve, reject) => {
2903
- readyHandlers.add([resolve, reject]);
2904
- });
2905
- }
2906
- function markAsReady(err) {
2907
- if (!ready) {
2908
- ready = !err;
2909
- setupListeners();
2910
- readyHandlers.list().forEach(([resolve, reject]) => err ? reject(err) : resolve());
2911
- readyHandlers.reset();
2912
- }
2913
- return err;
2914
- }
2915
- function handleScroll(to, from, isPush, isFirstNavigation) {
2916
- const { scrollBehavior } = options;
2917
- if (!isBrowser || !scrollBehavior) return Promise.resolve();
2918
- const scrollPosition = !isPush && getSavedScrollPosition(getScrollKey(to.fullPath, 0)) || (isFirstNavigation || !isPush) && history.state && history.state.scroll || null;
2919
- return nextTick().then(() => scrollBehavior(to, from, scrollPosition)).then((position) => to === currentRoute.value && position && scrollToPosition(position)).catch((err) => to === currentRoute.value && triggerError(err, to, from));
2920
- }
2921
- const go = (delta) => routerHistory.go(delta);
2922
- let started;
2923
- const installedApps = /* @__PURE__ */ new Set();
2924
- const router = {
2925
- currentRoute,
2926
- listening: true,
2927
- addRoute,
2928
- removeRoute,
2929
- clearRoutes,
2930
- hasRoute,
2931
- getRoutes,
2932
- resolve,
2933
- options,
2934
- push,
2935
- replace,
2936
- go,
2937
- back: () => go(-1),
2938
- forward: () => go(1),
2939
- beforeEach: beforeGuards.add,
2940
- beforeResolve: beforeResolveGuards.add,
2941
- afterEach: afterGuards.add,
2942
- onError: errorListeners.add,
2943
- isReady,
2944
- install(app) {
2945
- app.component("RouterLink", RouterLink);
2946
- app.component("RouterView", RouterView);
2947
- app.config.globalProperties.$router = router;
2948
- Object.defineProperty(app.config.globalProperties, "$route", {
2949
- enumerable: true,
2950
- get: () => unref(currentRoute)
2951
- });
2952
- if (isBrowser && !started && currentRoute.value === START_LOCATION_NORMALIZED) {
2953
- started = true;
2954
- push(routerHistory.location).catch((err) => {
2955
- diagnostics.VUE_ROUTER_R0011({ cause: err });
2956
- });
2957
- }
2958
- const reactiveRoute = {};
2959
- for (const key in START_LOCATION_NORMALIZED) Object.defineProperty(reactiveRoute, key, {
2960
- get: () => currentRoute.value[key],
2961
- enumerable: true
2962
- });
2963
- app.provide(routerKey, router);
2964
- app.provide(routeLocationKey, shallowReactive(reactiveRoute));
2965
- app.provide(routerViewLocationKey, currentRoute);
2966
- const unmountApp = app.unmount;
2967
- installedApps.add(app);
2968
- app.unmount = function() {
2969
- installedApps.delete(app);
2970
- if (installedApps.size < 1) {
2971
- pendingLocation = START_LOCATION_NORMALIZED;
2972
- removeHistoryListener && removeHistoryListener();
2973
- removeHistoryListener = null;
2974
- currentRoute.value = START_LOCATION_NORMALIZED;
2975
- started = false;
2976
- ready = false;
2977
- }
2978
- unmountApp();
2979
- };
2980
- if (isBrowser && true) addDevtools(app, router, matcher);
2981
- }
2982
- };
2983
- function runGuardQueue(guards) {
2984
- return guards.reduce((promise, guard) => promise.then(() => runWithContext(guard)), Promise.resolve());
2985
- }
2986
- return router;
2987
- }
2988
- //#endregion
2989
- export { NavigationFailureType, RouterLink, RouterView, START_LOCATION_NORMALIZED as START_LOCATION, createMemoryHistory, createRouter, createRouterMatcher, createWebHashHistory, createWebHistory, isNavigationFailure, loadRouteLocation, matchedRouteKey, onBeforeRouteLeave, onBeforeRouteUpdate, parseQuery, routeLocationKey, routerKey, routerViewLocationKey, stringifyQuery, useLink, useRoute, useRouter, viewDepthKey };