wyt-cli 1.0.2 → 1.0.3

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 (64) hide show
  1. package/bin/commands/create.js +230 -56
  2. package/bin/dist/default/index.html +13 -0
  3. package/bin/dist/default/package.json +28 -0
  4. package/bin/dist/default/src/App.vue +20 -0
  5. package/bin/dist/default/src/api/index.js +15 -0
  6. package/bin/dist/default/src/component/TestComponent.vue +5 -0
  7. package/bin/dist/default/src/main.js +20 -0
  8. package/bin/dist/default/src/router/index.js +23 -0
  9. package/bin/dist/default/src/style.css +20 -0
  10. package/bin/dist/default/src/views/Home.vue +8 -0
  11. package/bin/dist/default/src/views/NotFound.vue +13 -0
  12. package/bin/dist/default/vite.config.js +51 -0
  13. package/bin/lib/const.js +1 -1
  14. package/bin/lib/logger.js +37 -0
  15. package/bin/lib/utils.js +19 -5
  16. package/bin/main.js +30 -15
  17. package/bin/templates/default/index.html +13 -0
  18. package/bin/templates/default/node_modules/.bin/sass +17 -0
  19. package/bin/templates/default/node_modules/.bin/sass.CMD +12 -0
  20. package/bin/templates/default/node_modules/.bin/sass.ps1 +41 -0
  21. package/bin/templates/default/node_modules/.bin/vite +17 -0
  22. package/bin/templates/default/node_modules/.bin/vite.CMD +12 -0
  23. package/bin/templates/default/node_modules/.bin/vite.ps1 +41 -0
  24. package/bin/templates/default/node_modules/.vite/deps/@element-plus_icons-vue.js +592 -0
  25. package/bin/templates/default/node_modules/.vite/deps/@element-plus_icons-vue.js.map +7 -0
  26. package/bin/templates/default/node_modules/.vite/deps/_metadata.json +73 -0
  27. package/bin/templates/default/node_modules/.vite/deps/axios.js +2520 -0
  28. package/bin/templates/default/node_modules/.vite/deps/axios.js.map +7 -0
  29. package/bin/templates/default/node_modules/.vite/deps/chunk-AW3DCZT7.js +162 -0
  30. package/bin/templates/default/node_modules/.vite/deps/chunk-AW3DCZT7.js.map +7 -0
  31. package/bin/templates/default/node_modules/.vite/deps/chunk-G3PMV62Z.js +35 -0
  32. package/bin/templates/default/node_modules/.vite/deps/chunk-G3PMV62Z.js.map +7 -0
  33. package/bin/templates/default/node_modules/.vite/deps/chunk-GQX4HV27.js +5482 -0
  34. package/bin/templates/default/node_modules/.vite/deps/chunk-GQX4HV27.js.map +7 -0
  35. package/bin/templates/default/node_modules/.vite/deps/chunk-MAX6BVKX.js +12621 -0
  36. package/bin/templates/default/node_modules/.vite/deps/chunk-MAX6BVKX.js.map +7 -0
  37. package/bin/templates/default/node_modules/.vite/deps/chunk-USB5I3PS.js +25 -0
  38. package/bin/templates/default/node_modules/.vite/deps/chunk-USB5I3PS.js.map +7 -0
  39. package/bin/templates/default/node_modules/.vite/deps/element-plus.js +65145 -0
  40. package/bin/templates/default/node_modules/.vite/deps/element-plus.js.map +7 -0
  41. package/bin/templates/default/node_modules/.vite/deps/element-plus_dist_locale_zh-cn__mjs.js +190 -0
  42. package/bin/templates/default/node_modules/.vite/deps/element-plus_dist_locale_zh-cn__mjs.js.map +7 -0
  43. package/bin/templates/default/node_modules/.vite/deps/package.json +3 -0
  44. package/bin/templates/default/node_modules/.vite/deps/pinia.js +1547 -0
  45. package/bin/templates/default/node_modules/.vite/deps/pinia.js.map +7 -0
  46. package/bin/templates/default/node_modules/.vite/deps/print-js.js +898 -0
  47. package/bin/templates/default/node_modules/.vite/deps/print-js.js.map +7 -0
  48. package/bin/templates/default/node_modules/.vite/deps/vue-router.js +2782 -0
  49. package/bin/templates/default/node_modules/.vite/deps/vue-router.js.map +7 -0
  50. package/bin/templates/default/node_modules/.vite/deps/vue.js +343 -0
  51. package/bin/templates/default/node_modules/.vite/deps/vue.js.map +7 -0
  52. package/bin/templates/default/package.json +27 -7
  53. package/bin/templates/default/src/App.vue +20 -0
  54. package/bin/templates/default/src/api/index.js +15 -0
  55. package/bin/templates/default/src/component/TestComponent.vue +5 -0
  56. package/bin/templates/default/src/main.js +20 -0
  57. package/bin/templates/default/src/router/index.js +23 -0
  58. package/bin/templates/default/src/style.css +20 -0
  59. package/bin/templates/default/src/views/Home.vue +8 -0
  60. package/bin/templates/default/src/views/NotFound.vue +13 -0
  61. package/bin/templates/default/vite.config.js +51 -0
  62. package/package.json +31 -28
  63. package/bin/templates/default/main.js +0 -1
  64. package/bin/templates/default/package-lock.json +0 -0
@@ -0,0 +1,2782 @@
1
+ import {
2
+ setupDevtoolsPlugin
3
+ } from "./chunk-AW3DCZT7.js";
4
+ import {
5
+ computed,
6
+ defineComponent,
7
+ getCurrentInstance,
8
+ h,
9
+ inject,
10
+ nextTick,
11
+ onActivated,
12
+ onDeactivated,
13
+ onUnmounted,
14
+ provide,
15
+ reactive,
16
+ ref,
17
+ shallowReactive,
18
+ shallowRef,
19
+ unref,
20
+ watch,
21
+ watchEffect
22
+ } from "./chunk-MAX6BVKX.js";
23
+ import "./chunk-G3PMV62Z.js";
24
+
25
+ // ../../node_modules/.pnpm/vue-router@4.5.1_vue@3.5.16/node_modules/vue-router/dist/vue-router.mjs
26
+ var isBrowser = typeof document !== "undefined";
27
+ function isRouteComponent(component) {
28
+ return typeof component === "object" || "displayName" in component || "props" in component || "__vccOpts" in component;
29
+ }
30
+ function isESModule(obj) {
31
+ return obj.__esModule || obj[Symbol.toStringTag] === "Module" || // support CF with dynamic imports that do not
32
+ // add the Module string tag
33
+ obj.default && isRouteComponent(obj.default);
34
+ }
35
+ var assign = Object.assign;
36
+ function applyToParams(fn, params) {
37
+ const newParams = {};
38
+ for (const key in params) {
39
+ const value = params[key];
40
+ newParams[key] = isArray(value) ? value.map(fn) : fn(value);
41
+ }
42
+ return newParams;
43
+ }
44
+ var noop = () => {
45
+ };
46
+ var isArray = Array.isArray;
47
+ function warn(msg) {
48
+ const args = Array.from(arguments).slice(1);
49
+ console.warn.apply(console, ["[Vue Router warn]: " + msg].concat(args));
50
+ }
51
+ var HASH_RE = /#/g;
52
+ var AMPERSAND_RE = /&/g;
53
+ var SLASH_RE = /\//g;
54
+ var EQUAL_RE = /=/g;
55
+ var IM_RE = /\?/g;
56
+ var PLUS_RE = /\+/g;
57
+ var ENC_BRACKET_OPEN_RE = /%5B/g;
58
+ var ENC_BRACKET_CLOSE_RE = /%5D/g;
59
+ var ENC_CARET_RE = /%5E/g;
60
+ var ENC_BACKTICK_RE = /%60/g;
61
+ var ENC_CURLY_OPEN_RE = /%7B/g;
62
+ var ENC_PIPE_RE = /%7C/g;
63
+ var ENC_CURLY_CLOSE_RE = /%7D/g;
64
+ var ENC_SPACE_RE = /%20/g;
65
+ function commonEncode(text) {
66
+ return encodeURI("" + text).replace(ENC_PIPE_RE, "|").replace(ENC_BRACKET_OPEN_RE, "[").replace(ENC_BRACKET_CLOSE_RE, "]");
67
+ }
68
+ function encodeHash(text) {
69
+ return commonEncode(text).replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
70
+ }
71
+ function encodeQueryValue(text) {
72
+ 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, "^");
73
+ }
74
+ function encodeQueryKey(text) {
75
+ return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
76
+ }
77
+ function encodePath(text) {
78
+ return commonEncode(text).replace(HASH_RE, "%23").replace(IM_RE, "%3F");
79
+ }
80
+ function encodeParam(text) {
81
+ return text == null ? "" : encodePath(text).replace(SLASH_RE, "%2F");
82
+ }
83
+ function decode(text) {
84
+ try {
85
+ return decodeURIComponent("" + text);
86
+ } catch (err) {
87
+ warn(`Error decoding "${text}". Using original value`);
88
+ }
89
+ return "" + text;
90
+ }
91
+ var TRAILING_SLASH_RE = /\/$/;
92
+ var removeTrailingSlash = (path) => path.replace(TRAILING_SLASH_RE, "");
93
+ function parseURL(parseQuery2, location2, currentLocation = "/") {
94
+ let path, query = {}, searchString = "", hash = "";
95
+ const hashPos = location2.indexOf("#");
96
+ let searchPos = location2.indexOf("?");
97
+ if (hashPos < searchPos && hashPos >= 0) {
98
+ searchPos = -1;
99
+ }
100
+ if (searchPos > -1) {
101
+ path = location2.slice(0, searchPos);
102
+ searchString = location2.slice(searchPos + 1, hashPos > -1 ? hashPos : location2.length);
103
+ query = parseQuery2(searchString);
104
+ }
105
+ if (hashPos > -1) {
106
+ path = path || location2.slice(0, hashPos);
107
+ hash = location2.slice(hashPos, location2.length);
108
+ }
109
+ path = resolveRelativePath(path != null ? path : location2, currentLocation);
110
+ return {
111
+ fullPath: path + (searchString && "?") + searchString + hash,
112
+ path,
113
+ query,
114
+ hash: decode(hash)
115
+ };
116
+ }
117
+ function stringifyURL(stringifyQuery2, location2) {
118
+ const query = location2.query ? stringifyQuery2(location2.query) : "";
119
+ return location2.path + (query && "?") + query + (location2.hash || "");
120
+ }
121
+ function stripBase(pathname, base) {
122
+ if (!base || !pathname.toLowerCase().startsWith(base.toLowerCase()))
123
+ return pathname;
124
+ return pathname.slice(base.length) || "/";
125
+ }
126
+ function isSameRouteLocation(stringifyQuery2, a, b) {
127
+ const aLastIndex = a.matched.length - 1;
128
+ const bLastIndex = b.matched.length - 1;
129
+ return aLastIndex > -1 && aLastIndex === bLastIndex && isSameRouteRecord(a.matched[aLastIndex], b.matched[bLastIndex]) && isSameRouteLocationParams(a.params, b.params) && stringifyQuery2(a.query) === stringifyQuery2(b.query) && a.hash === b.hash;
130
+ }
131
+ function isSameRouteRecord(a, b) {
132
+ return (a.aliasOf || a) === (b.aliasOf || b);
133
+ }
134
+ function isSameRouteLocationParams(a, b) {
135
+ if (Object.keys(a).length !== Object.keys(b).length)
136
+ return false;
137
+ for (const key in a) {
138
+ if (!isSameRouteLocationParamsValue(a[key], b[key]))
139
+ return false;
140
+ }
141
+ return true;
142
+ }
143
+ function isSameRouteLocationParamsValue(a, b) {
144
+ return isArray(a) ? isEquivalentArray(a, b) : isArray(b) ? isEquivalentArray(b, a) : a === b;
145
+ }
146
+ function isEquivalentArray(a, b) {
147
+ return isArray(b) ? a.length === b.length && a.every((value, i) => value === b[i]) : a.length === 1 && a[0] === b;
148
+ }
149
+ function resolveRelativePath(to, from) {
150
+ if (to.startsWith("/"))
151
+ return to;
152
+ if (!from.startsWith("/")) {
153
+ warn(`Cannot resolve a relative location without an absolute path. Trying to resolve "${to}" from "${from}". It should look like "/${from}".`);
154
+ return to;
155
+ }
156
+ if (!to)
157
+ return from;
158
+ const fromSegments = from.split("/");
159
+ const toSegments = to.split("/");
160
+ const lastToSegment = toSegments[toSegments.length - 1];
161
+ if (lastToSegment === ".." || lastToSegment === ".") {
162
+ toSegments.push("");
163
+ }
164
+ let position = fromSegments.length - 1;
165
+ let toPosition;
166
+ let segment;
167
+ for (toPosition = 0; toPosition < toSegments.length; toPosition++) {
168
+ segment = toSegments[toPosition];
169
+ if (segment === ".")
170
+ continue;
171
+ if (segment === "..") {
172
+ if (position > 1)
173
+ position--;
174
+ } else
175
+ break;
176
+ }
177
+ return fromSegments.slice(0, position).join("/") + "/" + toSegments.slice(toPosition).join("/");
178
+ }
179
+ var START_LOCATION_NORMALIZED = {
180
+ path: "/",
181
+ // TODO: could we use a symbol in the future?
182
+ name: void 0,
183
+ params: {},
184
+ query: {},
185
+ hash: "",
186
+ fullPath: "/",
187
+ matched: [],
188
+ meta: {},
189
+ redirectedFrom: void 0
190
+ };
191
+ var NavigationType;
192
+ (function(NavigationType2) {
193
+ NavigationType2["pop"] = "pop";
194
+ NavigationType2["push"] = "push";
195
+ })(NavigationType || (NavigationType = {}));
196
+ var NavigationDirection;
197
+ (function(NavigationDirection2) {
198
+ NavigationDirection2["back"] = "back";
199
+ NavigationDirection2["forward"] = "forward";
200
+ NavigationDirection2["unknown"] = "";
201
+ })(NavigationDirection || (NavigationDirection = {}));
202
+ var START = "";
203
+ function normalizeBase(base) {
204
+ if (!base) {
205
+ if (isBrowser) {
206
+ const baseEl = document.querySelector("base");
207
+ base = baseEl && baseEl.getAttribute("href") || "/";
208
+ base = base.replace(/^\w+:\/\/[^\/]+/, "");
209
+ } else {
210
+ base = "/";
211
+ }
212
+ }
213
+ if (base[0] !== "/" && base[0] !== "#")
214
+ base = "/" + base;
215
+ return removeTrailingSlash(base);
216
+ }
217
+ var BEFORE_HASH_RE = /^[^#]+#/;
218
+ function createHref(base, location2) {
219
+ return base.replace(BEFORE_HASH_RE, "#") + location2;
220
+ }
221
+ function getElementPosition(el, offset) {
222
+ const docRect = document.documentElement.getBoundingClientRect();
223
+ const elRect = el.getBoundingClientRect();
224
+ return {
225
+ behavior: offset.behavior,
226
+ left: elRect.left - docRect.left - (offset.left || 0),
227
+ top: elRect.top - docRect.top - (offset.top || 0)
228
+ };
229
+ }
230
+ var computeScrollPosition = () => ({
231
+ left: window.scrollX,
232
+ top: window.scrollY
233
+ });
234
+ function scrollToPosition(position) {
235
+ let scrollToOptions;
236
+ if ("el" in position) {
237
+ const positionEl = position.el;
238
+ const isIdSelector = typeof positionEl === "string" && positionEl.startsWith("#");
239
+ if (typeof position.el === "string") {
240
+ if (!isIdSelector || !document.getElementById(position.el.slice(1))) {
241
+ try {
242
+ const foundEl = document.querySelector(position.el);
243
+ if (isIdSelector && foundEl) {
244
+ warn(`The selector "${position.el}" should be passed as "el: document.querySelector('${position.el}')" because it starts with "#".`);
245
+ return;
246
+ }
247
+ } catch (err) {
248
+ warn(`The selector "${position.el}" is invalid. If you are using an id selector, make sure to escape it. You can find more information about escaping characters in selectors at https://mathiasbynens.be/notes/css-escapes or use CSS.escape (https://developer.mozilla.org/en-US/docs/Web/API/CSS/escape).`);
249
+ return;
250
+ }
251
+ }
252
+ }
253
+ const el = typeof positionEl === "string" ? isIdSelector ? document.getElementById(positionEl.slice(1)) : document.querySelector(positionEl) : positionEl;
254
+ if (!el) {
255
+ warn(`Couldn't find element using selector "${position.el}" returned by scrollBehavior.`);
256
+ return;
257
+ }
258
+ scrollToOptions = getElementPosition(el, position);
259
+ } else {
260
+ scrollToOptions = position;
261
+ }
262
+ if ("scrollBehavior" in document.documentElement.style)
263
+ window.scrollTo(scrollToOptions);
264
+ else {
265
+ window.scrollTo(scrollToOptions.left != null ? scrollToOptions.left : window.scrollX, scrollToOptions.top != null ? scrollToOptions.top : window.scrollY);
266
+ }
267
+ }
268
+ function getScrollKey(path, delta) {
269
+ const position = history.state ? history.state.position - delta : -1;
270
+ return position + path;
271
+ }
272
+ var scrollPositions = /* @__PURE__ */ new Map();
273
+ function saveScrollPosition(key, scrollPosition) {
274
+ scrollPositions.set(key, scrollPosition);
275
+ }
276
+ function getSavedScrollPosition(key) {
277
+ const scroll = scrollPositions.get(key);
278
+ scrollPositions.delete(key);
279
+ return scroll;
280
+ }
281
+ var createBaseLocation = () => location.protocol + "//" + location.host;
282
+ function createCurrentLocation(base, location2) {
283
+ const { pathname, search, hash } = location2;
284
+ const hashPos = base.indexOf("#");
285
+ if (hashPos > -1) {
286
+ let slicePos = hash.includes(base.slice(hashPos)) ? base.slice(hashPos).length : 1;
287
+ let pathFromHash = hash.slice(slicePos);
288
+ if (pathFromHash[0] !== "/")
289
+ pathFromHash = "/" + pathFromHash;
290
+ return stripBase(pathFromHash, "");
291
+ }
292
+ const path = stripBase(pathname, base);
293
+ return path + search + hash;
294
+ }
295
+ function useHistoryListeners(base, historyState, currentLocation, replace) {
296
+ let listeners = [];
297
+ let teardowns = [];
298
+ let pauseState = null;
299
+ const popStateHandler = ({ state }) => {
300
+ const to = createCurrentLocation(base, location);
301
+ const from = currentLocation.value;
302
+ const fromState = historyState.value;
303
+ let delta = 0;
304
+ if (state) {
305
+ currentLocation.value = to;
306
+ historyState.value = state;
307
+ if (pauseState && pauseState === from) {
308
+ pauseState = null;
309
+ return;
310
+ }
311
+ delta = fromState ? state.position - fromState.position : 0;
312
+ } else {
313
+ replace(to);
314
+ }
315
+ listeners.forEach((listener) => {
316
+ listener(currentLocation.value, from, {
317
+ delta,
318
+ type: NavigationType.pop,
319
+ direction: delta ? delta > 0 ? NavigationDirection.forward : NavigationDirection.back : NavigationDirection.unknown
320
+ });
321
+ });
322
+ };
323
+ function pauseListeners() {
324
+ pauseState = currentLocation.value;
325
+ }
326
+ function listen(callback) {
327
+ listeners.push(callback);
328
+ const teardown = () => {
329
+ const index = listeners.indexOf(callback);
330
+ if (index > -1)
331
+ listeners.splice(index, 1);
332
+ };
333
+ teardowns.push(teardown);
334
+ return teardown;
335
+ }
336
+ function beforeUnloadListener() {
337
+ const { history: history2 } = window;
338
+ if (!history2.state)
339
+ return;
340
+ history2.replaceState(assign({}, history2.state, { scroll: computeScrollPosition() }), "");
341
+ }
342
+ function destroy() {
343
+ for (const teardown of teardowns)
344
+ teardown();
345
+ teardowns = [];
346
+ window.removeEventListener("popstate", popStateHandler);
347
+ window.removeEventListener("beforeunload", beforeUnloadListener);
348
+ }
349
+ window.addEventListener("popstate", popStateHandler);
350
+ window.addEventListener("beforeunload", beforeUnloadListener, {
351
+ passive: true
352
+ });
353
+ return {
354
+ pauseListeners,
355
+ listen,
356
+ destroy
357
+ };
358
+ }
359
+ function buildState(back, current, forward, replaced = false, computeScroll = false) {
360
+ return {
361
+ back,
362
+ current,
363
+ forward,
364
+ replaced,
365
+ position: window.history.length,
366
+ scroll: computeScroll ? computeScrollPosition() : null
367
+ };
368
+ }
369
+ function useHistoryStateNavigation(base) {
370
+ const { history: history2, location: location2 } = window;
371
+ const currentLocation = {
372
+ value: createCurrentLocation(base, location2)
373
+ };
374
+ const historyState = { value: history2.state };
375
+ if (!historyState.value) {
376
+ changeLocation(currentLocation.value, {
377
+ back: null,
378
+ current: currentLocation.value,
379
+ forward: null,
380
+ // the length is off by one, we need to decrease it
381
+ position: history2.length - 1,
382
+ replaced: true,
383
+ // don't add a scroll as the user may have an anchor, and we want
384
+ // scrollBehavior to be triggered without a saved position
385
+ scroll: null
386
+ }, true);
387
+ }
388
+ function changeLocation(to, state, replace2) {
389
+ const hashIndex = base.indexOf("#");
390
+ const url = hashIndex > -1 ? (location2.host && document.querySelector("base") ? base : base.slice(hashIndex)) + to : createBaseLocation() + base + to;
391
+ try {
392
+ history2[replace2 ? "replaceState" : "pushState"](state, "", url);
393
+ historyState.value = state;
394
+ } catch (err) {
395
+ if (true) {
396
+ warn("Error with push/replace State", err);
397
+ } else {
398
+ console.error(err);
399
+ }
400
+ location2[replace2 ? "replace" : "assign"](url);
401
+ }
402
+ }
403
+ function replace(to, data) {
404
+ const state = assign({}, history2.state, buildState(
405
+ historyState.value.back,
406
+ // keep back and forward entries but override current position
407
+ to,
408
+ historyState.value.forward,
409
+ true
410
+ ), data, { position: historyState.value.position });
411
+ changeLocation(to, state, true);
412
+ currentLocation.value = to;
413
+ }
414
+ function push(to, data) {
415
+ const currentState = assign(
416
+ {},
417
+ // use current history state to gracefully handle a wrong call to
418
+ // history.replaceState
419
+ // https://github.com/vuejs/router/issues/366
420
+ historyState.value,
421
+ history2.state,
422
+ {
423
+ forward: to,
424
+ scroll: computeScrollPosition()
425
+ }
426
+ );
427
+ if (!history2.state) {
428
+ warn(`history.state seems to have been manually replaced without preserving the necessary values. Make sure to preserve existing history state if you are manually calling history.replaceState:
429
+
430
+ history.replaceState(history.state, '', url)
431
+
432
+ You can find more information at https://router.vuejs.org/guide/migration/#Usage-of-history-state`);
433
+ }
434
+ changeLocation(currentState.current, currentState, true);
435
+ const state = assign({}, buildState(currentLocation.value, to, null), { position: currentState.position + 1 }, data);
436
+ changeLocation(to, state, false);
437
+ currentLocation.value = to;
438
+ }
439
+ return {
440
+ location: currentLocation,
441
+ state: historyState,
442
+ push,
443
+ replace
444
+ };
445
+ }
446
+ function createWebHistory(base) {
447
+ base = normalizeBase(base);
448
+ const historyNavigation = useHistoryStateNavigation(base);
449
+ const historyListeners = useHistoryListeners(base, historyNavigation.state, historyNavigation.location, historyNavigation.replace);
450
+ function go(delta, triggerListeners = true) {
451
+ if (!triggerListeners)
452
+ historyListeners.pauseListeners();
453
+ history.go(delta);
454
+ }
455
+ const routerHistory = assign({
456
+ // it's overridden right after
457
+ location: "",
458
+ base,
459
+ go,
460
+ createHref: createHref.bind(null, base)
461
+ }, historyNavigation, historyListeners);
462
+ Object.defineProperty(routerHistory, "location", {
463
+ enumerable: true,
464
+ get: () => historyNavigation.location.value
465
+ });
466
+ Object.defineProperty(routerHistory, "state", {
467
+ enumerable: true,
468
+ get: () => historyNavigation.state.value
469
+ });
470
+ return routerHistory;
471
+ }
472
+ function createMemoryHistory(base = "") {
473
+ let listeners = [];
474
+ let queue = [[START, {}]];
475
+ let position = 0;
476
+ base = normalizeBase(base);
477
+ function setLocation(location2, state = {}) {
478
+ position++;
479
+ if (position !== queue.length) {
480
+ queue.splice(position);
481
+ }
482
+ queue.push([location2, state]);
483
+ }
484
+ function triggerListeners(to, from, { direction, delta }) {
485
+ const info = {
486
+ direction,
487
+ delta,
488
+ type: NavigationType.pop
489
+ };
490
+ for (const callback of listeners) {
491
+ callback(to, from, info);
492
+ }
493
+ }
494
+ const routerHistory = {
495
+ // rewritten by Object.defineProperty
496
+ location: START,
497
+ // rewritten by Object.defineProperty
498
+ state: {},
499
+ base,
500
+ createHref: createHref.bind(null, base),
501
+ replace(to, state) {
502
+ queue.splice(position--, 1);
503
+ setLocation(to, state);
504
+ },
505
+ push(to, state) {
506
+ setLocation(to, state);
507
+ },
508
+ listen(callback) {
509
+ listeners.push(callback);
510
+ return () => {
511
+ const index = listeners.indexOf(callback);
512
+ if (index > -1)
513
+ listeners.splice(index, 1);
514
+ };
515
+ },
516
+ destroy() {
517
+ listeners = [];
518
+ queue = [[START, {}]];
519
+ position = 0;
520
+ },
521
+ go(delta, shouldTrigger = true) {
522
+ const from = this.location;
523
+ const direction = (
524
+ // we are considering delta === 0 going forward, but in abstract mode
525
+ // using 0 for the delta doesn't make sense like it does in html5 where
526
+ // it reloads the page
527
+ delta < 0 ? NavigationDirection.back : NavigationDirection.forward
528
+ );
529
+ position = Math.max(0, Math.min(position + delta, queue.length - 1));
530
+ if (shouldTrigger) {
531
+ triggerListeners(this.location, from, {
532
+ direction,
533
+ delta
534
+ });
535
+ }
536
+ }
537
+ };
538
+ Object.defineProperty(routerHistory, "location", {
539
+ enumerable: true,
540
+ get: () => queue[position][0]
541
+ });
542
+ Object.defineProperty(routerHistory, "state", {
543
+ enumerable: true,
544
+ get: () => queue[position][1]
545
+ });
546
+ return routerHistory;
547
+ }
548
+ function createWebHashHistory(base) {
549
+ base = location.host ? base || location.pathname + location.search : "";
550
+ if (!base.includes("#"))
551
+ base += "#";
552
+ if (!base.endsWith("#/") && !base.endsWith("#")) {
553
+ warn(`A hash base must end with a "#":
554
+ "${base}" should be "${base.replace(/#.*$/, "#")}".`);
555
+ }
556
+ return createWebHistory(base);
557
+ }
558
+ function isRouteLocation(route) {
559
+ return typeof route === "string" || route && typeof route === "object";
560
+ }
561
+ function isRouteName(name) {
562
+ return typeof name === "string" || typeof name === "symbol";
563
+ }
564
+ var NavigationFailureSymbol = Symbol(true ? "navigation failure" : "");
565
+ var NavigationFailureType;
566
+ (function(NavigationFailureType2) {
567
+ NavigationFailureType2[NavigationFailureType2["aborted"] = 4] = "aborted";
568
+ NavigationFailureType2[NavigationFailureType2["cancelled"] = 8] = "cancelled";
569
+ NavigationFailureType2[NavigationFailureType2["duplicated"] = 16] = "duplicated";
570
+ })(NavigationFailureType || (NavigationFailureType = {}));
571
+ var ErrorTypeMessages = {
572
+ [
573
+ 1
574
+ /* ErrorTypes.MATCHER_NOT_FOUND */
575
+ ]({ location: location2, currentLocation }) {
576
+ return `No match for
577
+ ${JSON.stringify(location2)}${currentLocation ? "\nwhile being at\n" + JSON.stringify(currentLocation) : ""}`;
578
+ },
579
+ [
580
+ 2
581
+ /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
582
+ ]({ from, to }) {
583
+ return `Redirected from "${from.fullPath}" to "${stringifyRoute(to)}" via a navigation guard.`;
584
+ },
585
+ [
586
+ 4
587
+ /* ErrorTypes.NAVIGATION_ABORTED */
588
+ ]({ from, to }) {
589
+ return `Navigation aborted from "${from.fullPath}" to "${to.fullPath}" via a navigation guard.`;
590
+ },
591
+ [
592
+ 8
593
+ /* ErrorTypes.NAVIGATION_CANCELLED */
594
+ ]({ from, to }) {
595
+ return `Navigation cancelled from "${from.fullPath}" to "${to.fullPath}" with a new navigation.`;
596
+ },
597
+ [
598
+ 16
599
+ /* ErrorTypes.NAVIGATION_DUPLICATED */
600
+ ]({ from, to }) {
601
+ return `Avoided redundant navigation to current location: "${from.fullPath}".`;
602
+ }
603
+ };
604
+ function createRouterError(type, params) {
605
+ if (true) {
606
+ return assign(new Error(ErrorTypeMessages[type](params)), {
607
+ type,
608
+ [NavigationFailureSymbol]: true
609
+ }, params);
610
+ } else {
611
+ return assign(new Error(), {
612
+ type,
613
+ [NavigationFailureSymbol]: true
614
+ }, params);
615
+ }
616
+ }
617
+ function isNavigationFailure(error, type) {
618
+ return error instanceof Error && NavigationFailureSymbol in error && (type == null || !!(error.type & type));
619
+ }
620
+ var propertiesToLog = ["params", "query", "hash"];
621
+ function stringifyRoute(to) {
622
+ if (typeof to === "string")
623
+ return to;
624
+ if (to.path != null)
625
+ return to.path;
626
+ const location2 = {};
627
+ for (const key of propertiesToLog) {
628
+ if (key in to)
629
+ location2[key] = to[key];
630
+ }
631
+ return JSON.stringify(location2, null, 2);
632
+ }
633
+ var BASE_PARAM_PATTERN = "[^/]+?";
634
+ var BASE_PATH_PARSER_OPTIONS = {
635
+ sensitive: false,
636
+ strict: false,
637
+ start: true,
638
+ end: true
639
+ };
640
+ var REGEX_CHARS_RE = /[.+*?^${}()[\]/\\]/g;
641
+ function tokensToParser(segments, extraOptions) {
642
+ const options = assign({}, BASE_PATH_PARSER_OPTIONS, extraOptions);
643
+ const score = [];
644
+ let pattern = options.start ? "^" : "";
645
+ const keys = [];
646
+ for (const segment of segments) {
647
+ const segmentScores = segment.length ? [] : [
648
+ 90
649
+ /* PathScore.Root */
650
+ ];
651
+ if (options.strict && !segment.length)
652
+ pattern += "/";
653
+ for (let tokenIndex = 0; tokenIndex < segment.length; tokenIndex++) {
654
+ const token = segment[tokenIndex];
655
+ let subSegmentScore = 40 + (options.sensitive ? 0.25 : 0);
656
+ if (token.type === 0) {
657
+ if (!tokenIndex)
658
+ pattern += "/";
659
+ pattern += token.value.replace(REGEX_CHARS_RE, "\\$&");
660
+ subSegmentScore += 40;
661
+ } else if (token.type === 1) {
662
+ const { value, repeatable, optional, regexp } = token;
663
+ keys.push({
664
+ name: value,
665
+ repeatable,
666
+ optional
667
+ });
668
+ const re2 = regexp ? regexp : BASE_PARAM_PATTERN;
669
+ if (re2 !== BASE_PARAM_PATTERN) {
670
+ subSegmentScore += 10;
671
+ try {
672
+ new RegExp(`(${re2})`);
673
+ } catch (err) {
674
+ throw new Error(`Invalid custom RegExp for param "${value}" (${re2}): ` + err.message);
675
+ }
676
+ }
677
+ let subPattern = repeatable ? `((?:${re2})(?:/(?:${re2}))*)` : `(${re2})`;
678
+ if (!tokenIndex)
679
+ subPattern = // avoid an optional / if there are more segments e.g. /:p?-static
680
+ // or /:p?-:p2
681
+ optional && segment.length < 2 ? `(?:/${subPattern})` : "/" + subPattern;
682
+ if (optional)
683
+ subPattern += "?";
684
+ pattern += subPattern;
685
+ subSegmentScore += 20;
686
+ if (optional)
687
+ subSegmentScore += -8;
688
+ if (repeatable)
689
+ subSegmentScore += -20;
690
+ if (re2 === ".*")
691
+ subSegmentScore += -50;
692
+ }
693
+ segmentScores.push(subSegmentScore);
694
+ }
695
+ score.push(segmentScores);
696
+ }
697
+ if (options.strict && options.end) {
698
+ const i = score.length - 1;
699
+ score[i][score[i].length - 1] += 0.7000000000000001;
700
+ }
701
+ if (!options.strict)
702
+ pattern += "/?";
703
+ if (options.end)
704
+ pattern += "$";
705
+ else if (options.strict && !pattern.endsWith("/"))
706
+ pattern += "(?:/|$)";
707
+ const re = new RegExp(pattern, options.sensitive ? "" : "i");
708
+ function parse(path) {
709
+ const match = path.match(re);
710
+ const params = {};
711
+ if (!match)
712
+ return null;
713
+ for (let i = 1; i < match.length; i++) {
714
+ const value = match[i] || "";
715
+ const key = keys[i - 1];
716
+ params[key.name] = value && key.repeatable ? value.split("/") : value;
717
+ }
718
+ return params;
719
+ }
720
+ function stringify(params) {
721
+ let path = "";
722
+ let avoidDuplicatedSlash = false;
723
+ for (const segment of segments) {
724
+ if (!avoidDuplicatedSlash || !path.endsWith("/"))
725
+ path += "/";
726
+ avoidDuplicatedSlash = false;
727
+ for (const token of segment) {
728
+ if (token.type === 0) {
729
+ path += token.value;
730
+ } else if (token.type === 1) {
731
+ const { value, repeatable, optional } = token;
732
+ const param = value in params ? params[value] : "";
733
+ if (isArray(param) && !repeatable) {
734
+ throw new Error(`Provided param "${value}" is an array but it is not repeatable (* or + modifiers)`);
735
+ }
736
+ const text = isArray(param) ? param.join("/") : param;
737
+ if (!text) {
738
+ if (optional) {
739
+ if (segment.length < 2) {
740
+ if (path.endsWith("/"))
741
+ path = path.slice(0, -1);
742
+ else
743
+ avoidDuplicatedSlash = true;
744
+ }
745
+ } else
746
+ throw new Error(`Missing required param "${value}"`);
747
+ }
748
+ path += text;
749
+ }
750
+ }
751
+ }
752
+ return path || "/";
753
+ }
754
+ return {
755
+ re,
756
+ score,
757
+ keys,
758
+ parse,
759
+ stringify
760
+ };
761
+ }
762
+ function compareScoreArray(a, b) {
763
+ let i = 0;
764
+ while (i < a.length && i < b.length) {
765
+ const diff = b[i] - a[i];
766
+ if (diff)
767
+ return diff;
768
+ i++;
769
+ }
770
+ if (a.length < b.length) {
771
+ return a.length === 1 && a[0] === 40 + 40 ? -1 : 1;
772
+ } else if (a.length > b.length) {
773
+ return b.length === 1 && b[0] === 40 + 40 ? 1 : -1;
774
+ }
775
+ return 0;
776
+ }
777
+ function comparePathParserScore(a, b) {
778
+ let i = 0;
779
+ const aScore = a.score;
780
+ const bScore = b.score;
781
+ while (i < aScore.length && i < bScore.length) {
782
+ const comp = compareScoreArray(aScore[i], bScore[i]);
783
+ if (comp)
784
+ return comp;
785
+ i++;
786
+ }
787
+ if (Math.abs(bScore.length - aScore.length) === 1) {
788
+ if (isLastScoreNegative(aScore))
789
+ return 1;
790
+ if (isLastScoreNegative(bScore))
791
+ return -1;
792
+ }
793
+ return bScore.length - aScore.length;
794
+ }
795
+ function isLastScoreNegative(score) {
796
+ const last = score[score.length - 1];
797
+ return score.length > 0 && last[last.length - 1] < 0;
798
+ }
799
+ var ROOT_TOKEN = {
800
+ type: 0,
801
+ value: ""
802
+ };
803
+ var VALID_PARAM_RE = /[a-zA-Z0-9_]/;
804
+ function tokenizePath(path) {
805
+ if (!path)
806
+ return [[]];
807
+ if (path === "/")
808
+ return [[ROOT_TOKEN]];
809
+ if (!path.startsWith("/")) {
810
+ throw new Error(true ? `Route paths should start with a "/": "${path}" should be "/${path}".` : `Invalid path "${path}"`);
811
+ }
812
+ function crash(message) {
813
+ throw new Error(`ERR (${state})/"${buffer}": ${message}`);
814
+ }
815
+ let state = 0;
816
+ let previousState = state;
817
+ const tokens = [];
818
+ let segment;
819
+ function finalizeSegment() {
820
+ if (segment)
821
+ tokens.push(segment);
822
+ segment = [];
823
+ }
824
+ let i = 0;
825
+ let char;
826
+ let buffer = "";
827
+ let customRe = "";
828
+ function consumeBuffer() {
829
+ if (!buffer)
830
+ return;
831
+ if (state === 0) {
832
+ segment.push({
833
+ type: 0,
834
+ value: buffer
835
+ });
836
+ } else if (state === 1 || state === 2 || state === 3) {
837
+ if (segment.length > 1 && (char === "*" || char === "+"))
838
+ crash(`A repeatable param (${buffer}) must be alone in its segment. eg: '/:ids+.`);
839
+ segment.push({
840
+ type: 1,
841
+ value: buffer,
842
+ regexp: customRe,
843
+ repeatable: char === "*" || char === "+",
844
+ optional: char === "*" || char === "?"
845
+ });
846
+ } else {
847
+ crash("Invalid state to consume buffer");
848
+ }
849
+ buffer = "";
850
+ }
851
+ function addCharToBuffer() {
852
+ buffer += char;
853
+ }
854
+ while (i < path.length) {
855
+ char = path[i++];
856
+ if (char === "\\" && state !== 2) {
857
+ previousState = state;
858
+ state = 4;
859
+ continue;
860
+ }
861
+ switch (state) {
862
+ case 0:
863
+ if (char === "/") {
864
+ if (buffer) {
865
+ consumeBuffer();
866
+ }
867
+ finalizeSegment();
868
+ } else if (char === ":") {
869
+ consumeBuffer();
870
+ state = 1;
871
+ } else {
872
+ addCharToBuffer();
873
+ }
874
+ break;
875
+ case 4:
876
+ addCharToBuffer();
877
+ state = previousState;
878
+ break;
879
+ case 1:
880
+ if (char === "(") {
881
+ state = 2;
882
+ } else if (VALID_PARAM_RE.test(char)) {
883
+ addCharToBuffer();
884
+ } else {
885
+ consumeBuffer();
886
+ state = 0;
887
+ if (char !== "*" && char !== "?" && char !== "+")
888
+ i--;
889
+ }
890
+ break;
891
+ case 2:
892
+ if (char === ")") {
893
+ if (customRe[customRe.length - 1] == "\\")
894
+ customRe = customRe.slice(0, -1) + char;
895
+ else
896
+ state = 3;
897
+ } else {
898
+ customRe += char;
899
+ }
900
+ break;
901
+ case 3:
902
+ consumeBuffer();
903
+ state = 0;
904
+ if (char !== "*" && char !== "?" && char !== "+")
905
+ i--;
906
+ customRe = "";
907
+ break;
908
+ default:
909
+ crash("Unknown state");
910
+ break;
911
+ }
912
+ }
913
+ if (state === 2)
914
+ crash(`Unfinished custom RegExp for param "${buffer}"`);
915
+ consumeBuffer();
916
+ finalizeSegment();
917
+ return tokens;
918
+ }
919
+ function createRouteRecordMatcher(record, parent, options) {
920
+ const parser = tokensToParser(tokenizePath(record.path), options);
921
+ if (true) {
922
+ const existingKeys = /* @__PURE__ */ new Set();
923
+ for (const key of parser.keys) {
924
+ if (existingKeys.has(key.name))
925
+ warn(`Found duplicated params with name "${key.name}" for path "${record.path}". Only the last one will be available on "$route.params".`);
926
+ existingKeys.add(key.name);
927
+ }
928
+ }
929
+ const matcher = assign(parser, {
930
+ record,
931
+ parent,
932
+ // these needs to be populated by the parent
933
+ children: [],
934
+ alias: []
935
+ });
936
+ if (parent) {
937
+ if (!matcher.record.aliasOf === !parent.record.aliasOf)
938
+ parent.children.push(matcher);
939
+ }
940
+ return matcher;
941
+ }
942
+ function createRouterMatcher(routes, globalOptions) {
943
+ const matchers = [];
944
+ const matcherMap = /* @__PURE__ */ new Map();
945
+ globalOptions = mergeOptions({ strict: false, end: true, sensitive: false }, globalOptions);
946
+ function getRecordMatcher(name) {
947
+ return matcherMap.get(name);
948
+ }
949
+ function addRoute(record, parent, originalRecord) {
950
+ const isRootAdd = !originalRecord;
951
+ const mainNormalizedRecord = normalizeRouteRecord(record);
952
+ if (true) {
953
+ checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent);
954
+ }
955
+ mainNormalizedRecord.aliasOf = originalRecord && originalRecord.record;
956
+ const options = mergeOptions(globalOptions, record);
957
+ const normalizedRecords = [mainNormalizedRecord];
958
+ if ("alias" in record) {
959
+ const aliases = typeof record.alias === "string" ? [record.alias] : record.alias;
960
+ for (const alias of aliases) {
961
+ normalizedRecords.push(
962
+ // we need to normalize again to ensure the `mods` property
963
+ // being non enumerable
964
+ normalizeRouteRecord(assign({}, mainNormalizedRecord, {
965
+ // this allows us to hold a copy of the `components` option
966
+ // so that async components cache is hold on the original record
967
+ components: originalRecord ? originalRecord.record.components : mainNormalizedRecord.components,
968
+ path: alias,
969
+ // we might be the child of an alias
970
+ aliasOf: originalRecord ? originalRecord.record : mainNormalizedRecord
971
+ // the aliases are always of the same kind as the original since they
972
+ // are defined on the same record
973
+ }))
974
+ );
975
+ }
976
+ }
977
+ let matcher;
978
+ let originalMatcher;
979
+ for (const normalizedRecord of normalizedRecords) {
980
+ const { path } = normalizedRecord;
981
+ if (parent && path[0] !== "/") {
982
+ const parentPath = parent.record.path;
983
+ const connectingSlash = parentPath[parentPath.length - 1] === "/" ? "" : "/";
984
+ normalizedRecord.path = parent.record.path + (path && connectingSlash + path);
985
+ }
986
+ if (normalizedRecord.path === "*") {
987
+ 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.');
988
+ }
989
+ matcher = createRouteRecordMatcher(normalizedRecord, parent, options);
990
+ if (parent && path[0] === "/")
991
+ checkMissingParamsInAbsolutePath(matcher, parent);
992
+ if (originalRecord) {
993
+ originalRecord.alias.push(matcher);
994
+ if (true) {
995
+ checkSameParams(originalRecord, matcher);
996
+ }
997
+ } else {
998
+ originalMatcher = originalMatcher || matcher;
999
+ if (originalMatcher !== matcher)
1000
+ originalMatcher.alias.push(matcher);
1001
+ if (isRootAdd && record.name && !isAliasRecord(matcher)) {
1002
+ if (true) {
1003
+ checkSameNameAsAncestor(record, parent);
1004
+ }
1005
+ removeRoute(record.name);
1006
+ }
1007
+ }
1008
+ if (isMatchable(matcher)) {
1009
+ insertMatcher(matcher);
1010
+ }
1011
+ if (mainNormalizedRecord.children) {
1012
+ const children = mainNormalizedRecord.children;
1013
+ for (let i = 0; i < children.length; i++) {
1014
+ addRoute(children[i], matcher, originalRecord && originalRecord.children[i]);
1015
+ }
1016
+ }
1017
+ originalRecord = originalRecord || matcher;
1018
+ }
1019
+ return originalMatcher ? () => {
1020
+ removeRoute(originalMatcher);
1021
+ } : noop;
1022
+ }
1023
+ function removeRoute(matcherRef) {
1024
+ if (isRouteName(matcherRef)) {
1025
+ const matcher = matcherMap.get(matcherRef);
1026
+ if (matcher) {
1027
+ matcherMap.delete(matcherRef);
1028
+ matchers.splice(matchers.indexOf(matcher), 1);
1029
+ matcher.children.forEach(removeRoute);
1030
+ matcher.alias.forEach(removeRoute);
1031
+ }
1032
+ } else {
1033
+ const index = matchers.indexOf(matcherRef);
1034
+ if (index > -1) {
1035
+ matchers.splice(index, 1);
1036
+ if (matcherRef.record.name)
1037
+ matcherMap.delete(matcherRef.record.name);
1038
+ matcherRef.children.forEach(removeRoute);
1039
+ matcherRef.alias.forEach(removeRoute);
1040
+ }
1041
+ }
1042
+ }
1043
+ function getRoutes() {
1044
+ return matchers;
1045
+ }
1046
+ function insertMatcher(matcher) {
1047
+ const index = findInsertionIndex(matcher, matchers);
1048
+ matchers.splice(index, 0, matcher);
1049
+ if (matcher.record.name && !isAliasRecord(matcher))
1050
+ matcherMap.set(matcher.record.name, matcher);
1051
+ }
1052
+ function resolve(location2, currentLocation) {
1053
+ let matcher;
1054
+ let params = {};
1055
+ let path;
1056
+ let name;
1057
+ if ("name" in location2 && location2.name) {
1058
+ matcher = matcherMap.get(location2.name);
1059
+ if (!matcher)
1060
+ throw createRouterError(1, {
1061
+ location: location2
1062
+ });
1063
+ if (true) {
1064
+ const invalidParams = Object.keys(location2.params || {}).filter((paramName) => !matcher.keys.find((k) => k.name === paramName));
1065
+ if (invalidParams.length) {
1066
+ warn(`Discarded invalid param(s) "${invalidParams.join('", "')}" when navigating. See https://github.com/vuejs/router/blob/main/packages/router/CHANGELOG.md#414-2022-08-22 for more details.`);
1067
+ }
1068
+ }
1069
+ name = matcher.record.name;
1070
+ params = assign(
1071
+ // paramsFromLocation is a new object
1072
+ paramsFromLocation(
1073
+ currentLocation.params,
1074
+ // only keep params that exist in the resolved location
1075
+ // only keep optional params coming from a parent record
1076
+ matcher.keys.filter((k) => !k.optional).concat(matcher.parent ? matcher.parent.keys.filter((k) => k.optional) : []).map((k) => k.name)
1077
+ ),
1078
+ // discard any existing params in the current location that do not exist here
1079
+ // #1497 this ensures better active/exact matching
1080
+ location2.params && paramsFromLocation(location2.params, matcher.keys.map((k) => k.name))
1081
+ );
1082
+ path = matcher.stringify(params);
1083
+ } else if (location2.path != null) {
1084
+ path = location2.path;
1085
+ if (!path.startsWith("/")) {
1086
+ warn(`The Matcher cannot resolve relative paths but received "${path}". Unless you directly called \`matcher.resolve("${path}")\`, this is probably a bug in vue-router. Please open an issue at https://github.com/vuejs/router/issues/new/choose.`);
1087
+ }
1088
+ matcher = matchers.find((m) => m.re.test(path));
1089
+ if (matcher) {
1090
+ params = matcher.parse(path);
1091
+ name = matcher.record.name;
1092
+ }
1093
+ } else {
1094
+ matcher = currentLocation.name ? matcherMap.get(currentLocation.name) : matchers.find((m) => m.re.test(currentLocation.path));
1095
+ if (!matcher)
1096
+ throw createRouterError(1, {
1097
+ location: location2,
1098
+ currentLocation
1099
+ });
1100
+ name = matcher.record.name;
1101
+ params = assign({}, currentLocation.params, location2.params);
1102
+ path = matcher.stringify(params);
1103
+ }
1104
+ const matched = [];
1105
+ let parentMatcher = matcher;
1106
+ while (parentMatcher) {
1107
+ matched.unshift(parentMatcher.record);
1108
+ parentMatcher = parentMatcher.parent;
1109
+ }
1110
+ return {
1111
+ name,
1112
+ path,
1113
+ params,
1114
+ matched,
1115
+ meta: mergeMetaFields(matched)
1116
+ };
1117
+ }
1118
+ routes.forEach((route) => addRoute(route));
1119
+ function clearRoutes() {
1120
+ matchers.length = 0;
1121
+ matcherMap.clear();
1122
+ }
1123
+ return {
1124
+ addRoute,
1125
+ resolve,
1126
+ removeRoute,
1127
+ clearRoutes,
1128
+ getRoutes,
1129
+ getRecordMatcher
1130
+ };
1131
+ }
1132
+ function paramsFromLocation(params, keys) {
1133
+ const newParams = {};
1134
+ for (const key of keys) {
1135
+ if (key in params)
1136
+ newParams[key] = params[key];
1137
+ }
1138
+ return newParams;
1139
+ }
1140
+ function normalizeRouteRecord(record) {
1141
+ const normalized = {
1142
+ path: record.path,
1143
+ redirect: record.redirect,
1144
+ name: record.name,
1145
+ meta: record.meta || {},
1146
+ aliasOf: record.aliasOf,
1147
+ beforeEnter: record.beforeEnter,
1148
+ props: normalizeRecordProps(record),
1149
+ children: record.children || [],
1150
+ instances: {},
1151
+ leaveGuards: /* @__PURE__ */ new Set(),
1152
+ updateGuards: /* @__PURE__ */ new Set(),
1153
+ enterCallbacks: {},
1154
+ // must be declared afterwards
1155
+ // mods: {},
1156
+ components: "components" in record ? record.components || null : record.component && { default: record.component }
1157
+ };
1158
+ Object.defineProperty(normalized, "mods", {
1159
+ value: {}
1160
+ });
1161
+ return normalized;
1162
+ }
1163
+ function normalizeRecordProps(record) {
1164
+ const propsObject = {};
1165
+ const props = record.props || false;
1166
+ if ("component" in record) {
1167
+ propsObject.default = props;
1168
+ } else {
1169
+ for (const name in record.components)
1170
+ propsObject[name] = typeof props === "object" ? props[name] : props;
1171
+ }
1172
+ return propsObject;
1173
+ }
1174
+ function isAliasRecord(record) {
1175
+ while (record) {
1176
+ if (record.record.aliasOf)
1177
+ return true;
1178
+ record = record.parent;
1179
+ }
1180
+ return false;
1181
+ }
1182
+ function mergeMetaFields(matched) {
1183
+ return matched.reduce((meta, record) => assign(meta, record.meta), {});
1184
+ }
1185
+ function mergeOptions(defaults, partialOptions) {
1186
+ const options = {};
1187
+ for (const key in defaults) {
1188
+ options[key] = key in partialOptions ? partialOptions[key] : defaults[key];
1189
+ }
1190
+ return options;
1191
+ }
1192
+ function isSameParam(a, b) {
1193
+ return a.name === b.name && a.optional === b.optional && a.repeatable === b.repeatable;
1194
+ }
1195
+ function checkSameParams(a, b) {
1196
+ for (const key of a.keys) {
1197
+ if (!key.optional && !b.keys.find(isSameParam.bind(null, key)))
1198
+ return warn(`Alias "${b.record.path}" and the original record: "${a.record.path}" must have the exact same param named "${key.name}"`);
1199
+ }
1200
+ for (const key of b.keys) {
1201
+ if (!key.optional && !a.keys.find(isSameParam.bind(null, key)))
1202
+ return warn(`Alias "${b.record.path}" and the original record: "${a.record.path}" must have the exact same param named "${key.name}"`);
1203
+ }
1204
+ }
1205
+ function checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent) {
1206
+ if (parent && parent.record.name && !mainNormalizedRecord.name && !mainNormalizedRecord.path) {
1207
+ warn(`The route named "${String(parent.record.name)}" has a child without a name and an empty path. Using that name won't render the empty path child so you probably want to move the name to the child instead. If this is intentional, add a name to the child route to remove the warning.`);
1208
+ }
1209
+ }
1210
+ function checkSameNameAsAncestor(record, parent) {
1211
+ for (let ancestor = parent; ancestor; ancestor = ancestor.parent) {
1212
+ if (ancestor.record.name === record.name) {
1213
+ 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.`);
1214
+ }
1215
+ }
1216
+ }
1217
+ function checkMissingParamsInAbsolutePath(record, parent) {
1218
+ for (const key of parent.keys) {
1219
+ if (!record.keys.find(isSameParam.bind(null, key)))
1220
+ return warn(`Absolute path "${record.record.path}" must have the exact same param named "${key.name}" as its parent "${parent.record.path}".`);
1221
+ }
1222
+ }
1223
+ function findInsertionIndex(matcher, matchers) {
1224
+ let lower = 0;
1225
+ let upper = matchers.length;
1226
+ while (lower !== upper) {
1227
+ const mid = lower + upper >> 1;
1228
+ const sortOrder = comparePathParserScore(matcher, matchers[mid]);
1229
+ if (sortOrder < 0) {
1230
+ upper = mid;
1231
+ } else {
1232
+ lower = mid + 1;
1233
+ }
1234
+ }
1235
+ const insertionAncestor = getInsertionAncestor(matcher);
1236
+ if (insertionAncestor) {
1237
+ upper = matchers.lastIndexOf(insertionAncestor, upper - 1);
1238
+ if (upper < 0) {
1239
+ warn(`Finding ancestor route "${insertionAncestor.record.path}" failed for "${matcher.record.path}"`);
1240
+ }
1241
+ }
1242
+ return upper;
1243
+ }
1244
+ function getInsertionAncestor(matcher) {
1245
+ let ancestor = matcher;
1246
+ while (ancestor = ancestor.parent) {
1247
+ if (isMatchable(ancestor) && comparePathParserScore(matcher, ancestor) === 0) {
1248
+ return ancestor;
1249
+ }
1250
+ }
1251
+ return;
1252
+ }
1253
+ function isMatchable({ record }) {
1254
+ return !!(record.name || record.components && Object.keys(record.components).length || record.redirect);
1255
+ }
1256
+ function parseQuery(search) {
1257
+ const query = {};
1258
+ if (search === "" || search === "?")
1259
+ return query;
1260
+ const hasLeadingIM = search[0] === "?";
1261
+ const searchParams = (hasLeadingIM ? search.slice(1) : search).split("&");
1262
+ for (let i = 0; i < searchParams.length; ++i) {
1263
+ const searchParam = searchParams[i].replace(PLUS_RE, " ");
1264
+ const eqPos = searchParam.indexOf("=");
1265
+ const key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos));
1266
+ const value = eqPos < 0 ? null : decode(searchParam.slice(eqPos + 1));
1267
+ if (key in query) {
1268
+ let currentValue = query[key];
1269
+ if (!isArray(currentValue)) {
1270
+ currentValue = query[key] = [currentValue];
1271
+ }
1272
+ currentValue.push(value);
1273
+ } else {
1274
+ query[key] = value;
1275
+ }
1276
+ }
1277
+ return query;
1278
+ }
1279
+ function stringifyQuery(query) {
1280
+ let search = "";
1281
+ for (let key in query) {
1282
+ const value = query[key];
1283
+ key = encodeQueryKey(key);
1284
+ if (value == null) {
1285
+ if (value !== void 0) {
1286
+ search += (search.length ? "&" : "") + key;
1287
+ }
1288
+ continue;
1289
+ }
1290
+ const values = isArray(value) ? value.map((v) => v && encodeQueryValue(v)) : [value && encodeQueryValue(value)];
1291
+ values.forEach((value2) => {
1292
+ if (value2 !== void 0) {
1293
+ search += (search.length ? "&" : "") + key;
1294
+ if (value2 != null)
1295
+ search += "=" + value2;
1296
+ }
1297
+ });
1298
+ }
1299
+ return search;
1300
+ }
1301
+ function normalizeQuery(query) {
1302
+ const normalizedQuery = {};
1303
+ for (const key in query) {
1304
+ const value = query[key];
1305
+ if (value !== void 0) {
1306
+ normalizedQuery[key] = isArray(value) ? value.map((v) => v == null ? null : "" + v) : value == null ? value : "" + value;
1307
+ }
1308
+ }
1309
+ return normalizedQuery;
1310
+ }
1311
+ var matchedRouteKey = Symbol(true ? "router view location matched" : "");
1312
+ var viewDepthKey = Symbol(true ? "router view depth" : "");
1313
+ var routerKey = Symbol(true ? "router" : "");
1314
+ var routeLocationKey = Symbol(true ? "route location" : "");
1315
+ var routerViewLocationKey = Symbol(true ? "router view location" : "");
1316
+ function useCallbacks() {
1317
+ let handlers = [];
1318
+ function add(handler) {
1319
+ handlers.push(handler);
1320
+ return () => {
1321
+ const i = handlers.indexOf(handler);
1322
+ if (i > -1)
1323
+ handlers.splice(i, 1);
1324
+ };
1325
+ }
1326
+ function reset() {
1327
+ handlers = [];
1328
+ }
1329
+ return {
1330
+ add,
1331
+ list: () => handlers.slice(),
1332
+ reset
1333
+ };
1334
+ }
1335
+ function registerGuard(record, name, guard) {
1336
+ const removeFromList = () => {
1337
+ record[name].delete(guard);
1338
+ };
1339
+ onUnmounted(removeFromList);
1340
+ onDeactivated(removeFromList);
1341
+ onActivated(() => {
1342
+ record[name].add(guard);
1343
+ });
1344
+ record[name].add(guard);
1345
+ }
1346
+ function onBeforeRouteLeave(leaveGuard) {
1347
+ if (!getCurrentInstance()) {
1348
+ warn("getCurrentInstance() returned null. onBeforeRouteLeave() must be called at the top of a setup function");
1349
+ return;
1350
+ }
1351
+ const activeRecord = inject(
1352
+ matchedRouteKey,
1353
+ // to avoid warning
1354
+ {}
1355
+ ).value;
1356
+ if (!activeRecord) {
1357
+ warn("No active route record was found when calling `onBeforeRouteLeave()`. Make sure you call this function inside a component child of <router-view>. Maybe you called it inside of App.vue?");
1358
+ return;
1359
+ }
1360
+ registerGuard(activeRecord, "leaveGuards", leaveGuard);
1361
+ }
1362
+ function onBeforeRouteUpdate(updateGuard) {
1363
+ if (!getCurrentInstance()) {
1364
+ warn("getCurrentInstance() returned null. onBeforeRouteUpdate() must be called at the top of a setup function");
1365
+ return;
1366
+ }
1367
+ const activeRecord = inject(
1368
+ matchedRouteKey,
1369
+ // to avoid warning
1370
+ {}
1371
+ ).value;
1372
+ if (!activeRecord) {
1373
+ warn("No active route record was found when calling `onBeforeRouteUpdate()`. Make sure you call this function inside a component child of <router-view>. Maybe you called it inside of App.vue?");
1374
+ return;
1375
+ }
1376
+ registerGuard(activeRecord, "updateGuards", updateGuard);
1377
+ }
1378
+ function guardToPromiseFn(guard, to, from, record, name, runWithContext = (fn) => fn()) {
1379
+ const enterCallbackArray = record && // name is defined if record is because of the function overload
1380
+ (record.enterCallbacks[name] = record.enterCallbacks[name] || []);
1381
+ return () => new Promise((resolve, reject) => {
1382
+ const next = (valid) => {
1383
+ if (valid === false) {
1384
+ reject(createRouterError(4, {
1385
+ from,
1386
+ to
1387
+ }));
1388
+ } else if (valid instanceof Error) {
1389
+ reject(valid);
1390
+ } else if (isRouteLocation(valid)) {
1391
+ reject(createRouterError(2, {
1392
+ from: to,
1393
+ to: valid
1394
+ }));
1395
+ } else {
1396
+ if (enterCallbackArray && // since enterCallbackArray is truthy, both record and name also are
1397
+ record.enterCallbacks[name] === enterCallbackArray && typeof valid === "function") {
1398
+ enterCallbackArray.push(valid);
1399
+ }
1400
+ resolve();
1401
+ }
1402
+ };
1403
+ const guardReturn = runWithContext(() => guard.call(record && record.instances[name], to, from, true ? canOnlyBeCalledOnce(next, to, from) : next));
1404
+ let guardCall = Promise.resolve(guardReturn);
1405
+ if (guard.length < 3)
1406
+ guardCall = guardCall.then(next);
1407
+ if (guard.length > 2) {
1408
+ const message = `The "next" callback was never called inside of ${guard.name ? '"' + guard.name + '"' : ""}:
1409
+ ${guard.toString()}
1410
+ . If you are returning a value instead of calling "next", make sure to remove the "next" parameter from your function.`;
1411
+ if (typeof guardReturn === "object" && "then" in guardReturn) {
1412
+ guardCall = guardCall.then((resolvedValue) => {
1413
+ if (!next._called) {
1414
+ warn(message);
1415
+ return Promise.reject(new Error("Invalid navigation guard"));
1416
+ }
1417
+ return resolvedValue;
1418
+ });
1419
+ } else if (guardReturn !== void 0) {
1420
+ if (!next._called) {
1421
+ warn(message);
1422
+ reject(new Error("Invalid navigation guard"));
1423
+ return;
1424
+ }
1425
+ }
1426
+ }
1427
+ guardCall.catch((err) => reject(err));
1428
+ });
1429
+ }
1430
+ function canOnlyBeCalledOnce(next, to, from) {
1431
+ let called = 0;
1432
+ return function() {
1433
+ if (called++ === 1)
1434
+ warn(`The "next" callback was called more than once in one navigation guard when going from "${from.fullPath}" to "${to.fullPath}". It should be called exactly one time in each navigation guard. This will fail in production.`);
1435
+ next._called = true;
1436
+ if (called === 1)
1437
+ next.apply(null, arguments);
1438
+ };
1439
+ }
1440
+ function extractComponentsGuards(matched, guardType, to, from, runWithContext = (fn) => fn()) {
1441
+ const guards = [];
1442
+ for (const record of matched) {
1443
+ if (!record.components && !record.children.length) {
1444
+ warn(`Record with path "${record.path}" is either missing a "component(s)" or "children" property.`);
1445
+ }
1446
+ for (const name in record.components) {
1447
+ let rawComponent = record.components[name];
1448
+ if (true) {
1449
+ if (!rawComponent || typeof rawComponent !== "object" && typeof rawComponent !== "function") {
1450
+ warn(`Component "${name}" in record with path "${record.path}" is not a valid component. Received "${String(rawComponent)}".`);
1451
+ throw new Error("Invalid route component");
1452
+ } else if ("then" in rawComponent) {
1453
+ warn(`Component "${name}" in record with path "${record.path}" is a Promise instead of a function that returns a Promise. Did you write "import('./MyPage.vue')" instead of "() => import('./MyPage.vue')" ? This will break in production if not fixed.`);
1454
+ const promise = rawComponent;
1455
+ rawComponent = () => promise;
1456
+ } else if (rawComponent.__asyncLoader && // warn only once per component
1457
+ !rawComponent.__warnedDefineAsync) {
1458
+ rawComponent.__warnedDefineAsync = true;
1459
+ warn(`Component "${name}" in record with path "${record.path}" is defined using "defineAsyncComponent()". Write "() => import('./MyPage.vue')" instead of "defineAsyncComponent(() => import('./MyPage.vue'))".`);
1460
+ }
1461
+ }
1462
+ if (guardType !== "beforeRouteEnter" && !record.instances[name])
1463
+ continue;
1464
+ if (isRouteComponent(rawComponent)) {
1465
+ const options = rawComponent.__vccOpts || rawComponent;
1466
+ const guard = options[guardType];
1467
+ guard && guards.push(guardToPromiseFn(guard, to, from, record, name, runWithContext));
1468
+ } else {
1469
+ let componentPromise = rawComponent();
1470
+ if (!("catch" in componentPromise)) {
1471
+ warn(`Component "${name}" in record with path "${record.path}" is a function that does not return a Promise. If you were passing a functional component, make sure to add a "displayName" to the component. This will break in production if not fixed.`);
1472
+ componentPromise = Promise.resolve(componentPromise);
1473
+ }
1474
+ guards.push(() => componentPromise.then((resolved) => {
1475
+ if (!resolved)
1476
+ throw new Error(`Couldn't resolve component "${name}" at "${record.path}"`);
1477
+ const resolvedComponent = isESModule(resolved) ? resolved.default : resolved;
1478
+ record.mods[name] = resolved;
1479
+ record.components[name] = resolvedComponent;
1480
+ const options = resolvedComponent.__vccOpts || resolvedComponent;
1481
+ const guard = options[guardType];
1482
+ return guard && guardToPromiseFn(guard, to, from, record, name, runWithContext)();
1483
+ }));
1484
+ }
1485
+ }
1486
+ }
1487
+ return guards;
1488
+ }
1489
+ function loadRouteLocation(route) {
1490
+ return route.matched.every((record) => record.redirect) ? Promise.reject(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) => {
1491
+ const rawComponent = record.components[name];
1492
+ if (typeof rawComponent === "function" && !("displayName" in rawComponent)) {
1493
+ promises.push(rawComponent().then((resolved) => {
1494
+ if (!resolved)
1495
+ return Promise.reject(new Error(`Couldn't resolve component "${name}" at "${record.path}". Ensure you passed a function that returns a promise.`));
1496
+ const resolvedComponent = isESModule(resolved) ? resolved.default : resolved;
1497
+ record.mods[name] = resolved;
1498
+ record.components[name] = resolvedComponent;
1499
+ return;
1500
+ }));
1501
+ }
1502
+ return promises;
1503
+ }, [])))).then(() => route);
1504
+ }
1505
+ function useLink(props) {
1506
+ const router = inject(routerKey);
1507
+ const currentRoute = inject(routeLocationKey);
1508
+ let hasPrevious = false;
1509
+ let previousTo = null;
1510
+ const route = computed(() => {
1511
+ const to = unref(props.to);
1512
+ if (!hasPrevious || to !== previousTo) {
1513
+ if (!isRouteLocation(to)) {
1514
+ if (hasPrevious) {
1515
+ warn(`Invalid value for prop "to" in useLink()
1516
+ - to:`, to, `
1517
+ - previous to:`, previousTo, `
1518
+ - props:`, props);
1519
+ } else {
1520
+ warn(`Invalid value for prop "to" in useLink()
1521
+ - to:`, to, `
1522
+ - props:`, props);
1523
+ }
1524
+ }
1525
+ previousTo = to;
1526
+ hasPrevious = true;
1527
+ }
1528
+ return router.resolve(to);
1529
+ });
1530
+ const activeRecordIndex = computed(() => {
1531
+ const { matched } = route.value;
1532
+ const { length } = matched;
1533
+ const routeMatched = matched[length - 1];
1534
+ const currentMatched = currentRoute.matched;
1535
+ if (!routeMatched || !currentMatched.length)
1536
+ return -1;
1537
+ const index = currentMatched.findIndex(isSameRouteRecord.bind(null, routeMatched));
1538
+ if (index > -1)
1539
+ return index;
1540
+ const parentRecordPath = getOriginalPath(matched[length - 2]);
1541
+ return (
1542
+ // we are dealing with nested routes
1543
+ length > 1 && // if the parent and matched route have the same path, this link is
1544
+ // referring to the empty child. Or we currently are on a different
1545
+ // child of the same parent
1546
+ getOriginalPath(routeMatched) === parentRecordPath && // avoid comparing the child with its parent
1547
+ currentMatched[currentMatched.length - 1].path !== parentRecordPath ? currentMatched.findIndex(isSameRouteRecord.bind(null, matched[length - 2])) : index
1548
+ );
1549
+ });
1550
+ const isActive = computed(() => activeRecordIndex.value > -1 && includesParams(currentRoute.params, route.value.params));
1551
+ const isExactActive = computed(() => activeRecordIndex.value > -1 && activeRecordIndex.value === currentRoute.matched.length - 1 && isSameRouteLocationParams(currentRoute.params, route.value.params));
1552
+ function navigate(e = {}) {
1553
+ if (guardEvent(e)) {
1554
+ const p = router[unref(props.replace) ? "replace" : "push"](
1555
+ unref(props.to)
1556
+ // avoid uncaught errors are they are logged anyway
1557
+ ).catch(noop);
1558
+ if (props.viewTransition && typeof document !== "undefined" && "startViewTransition" in document) {
1559
+ document.startViewTransition(() => p);
1560
+ }
1561
+ return p;
1562
+ }
1563
+ return Promise.resolve();
1564
+ }
1565
+ if (isBrowser) {
1566
+ const instance = getCurrentInstance();
1567
+ if (instance) {
1568
+ const linkContextDevtools = {
1569
+ route: route.value,
1570
+ isActive: isActive.value,
1571
+ isExactActive: isExactActive.value,
1572
+ error: null
1573
+ };
1574
+ instance.__vrl_devtools = instance.__vrl_devtools || [];
1575
+ instance.__vrl_devtools.push(linkContextDevtools);
1576
+ watchEffect(() => {
1577
+ linkContextDevtools.route = route.value;
1578
+ linkContextDevtools.isActive = isActive.value;
1579
+ linkContextDevtools.isExactActive = isExactActive.value;
1580
+ linkContextDevtools.error = isRouteLocation(unref(props.to)) ? null : 'Invalid "to" value';
1581
+ }, { flush: "post" });
1582
+ }
1583
+ }
1584
+ return {
1585
+ route,
1586
+ href: computed(() => route.value.href),
1587
+ isActive,
1588
+ isExactActive,
1589
+ navigate
1590
+ };
1591
+ }
1592
+ function preferSingleVNode(vnodes) {
1593
+ return vnodes.length === 1 ? vnodes[0] : vnodes;
1594
+ }
1595
+ var RouterLinkImpl = defineComponent({
1596
+ name: "RouterLink",
1597
+ compatConfig: { MODE: 3 },
1598
+ props: {
1599
+ to: {
1600
+ type: [String, Object],
1601
+ required: true
1602
+ },
1603
+ replace: Boolean,
1604
+ activeClass: String,
1605
+ // inactiveClass: String,
1606
+ exactActiveClass: String,
1607
+ custom: Boolean,
1608
+ ariaCurrentValue: {
1609
+ type: String,
1610
+ default: "page"
1611
+ },
1612
+ viewTransition: Boolean
1613
+ },
1614
+ useLink,
1615
+ setup(props, { slots }) {
1616
+ const link = reactive(useLink(props));
1617
+ const { options } = inject(routerKey);
1618
+ const elClass = computed(() => ({
1619
+ [getLinkClass(props.activeClass, options.linkActiveClass, "router-link-active")]: link.isActive,
1620
+ // [getLinkClass(
1621
+ // props.inactiveClass,
1622
+ // options.linkInactiveClass,
1623
+ // 'router-link-inactive'
1624
+ // )]: !link.isExactActive,
1625
+ [getLinkClass(props.exactActiveClass, options.linkExactActiveClass, "router-link-exact-active")]: link.isExactActive
1626
+ }));
1627
+ return () => {
1628
+ const children = slots.default && preferSingleVNode(slots.default(link));
1629
+ return props.custom ? children : h("a", {
1630
+ "aria-current": link.isExactActive ? props.ariaCurrentValue : null,
1631
+ href: link.href,
1632
+ // this would override user added attrs but Vue will still add
1633
+ // the listener, so we end up triggering both
1634
+ onClick: link.navigate,
1635
+ class: elClass.value
1636
+ }, children);
1637
+ };
1638
+ }
1639
+ });
1640
+ var RouterLink = RouterLinkImpl;
1641
+ function guardEvent(e) {
1642
+ if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)
1643
+ return;
1644
+ if (e.defaultPrevented)
1645
+ return;
1646
+ if (e.button !== void 0 && e.button !== 0)
1647
+ return;
1648
+ if (e.currentTarget && e.currentTarget.getAttribute) {
1649
+ const target = e.currentTarget.getAttribute("target");
1650
+ if (/\b_blank\b/i.test(target))
1651
+ return;
1652
+ }
1653
+ if (e.preventDefault)
1654
+ e.preventDefault();
1655
+ return true;
1656
+ }
1657
+ function includesParams(outer, inner) {
1658
+ for (const key in inner) {
1659
+ const innerValue = inner[key];
1660
+ const outerValue = outer[key];
1661
+ if (typeof innerValue === "string") {
1662
+ if (innerValue !== outerValue)
1663
+ return false;
1664
+ } else {
1665
+ if (!isArray(outerValue) || outerValue.length !== innerValue.length || innerValue.some((value, i) => value !== outerValue[i]))
1666
+ return false;
1667
+ }
1668
+ }
1669
+ return true;
1670
+ }
1671
+ function getOriginalPath(record) {
1672
+ return record ? record.aliasOf ? record.aliasOf.path : record.path : "";
1673
+ }
1674
+ var getLinkClass = (propClass, globalClass, defaultClass) => propClass != null ? propClass : globalClass != null ? globalClass : defaultClass;
1675
+ var RouterViewImpl = defineComponent({
1676
+ name: "RouterView",
1677
+ // #674 we manually inherit them
1678
+ inheritAttrs: false,
1679
+ props: {
1680
+ name: {
1681
+ type: String,
1682
+ default: "default"
1683
+ },
1684
+ route: Object
1685
+ },
1686
+ // Better compat for @vue/compat users
1687
+ // https://github.com/vuejs/router/issues/1315
1688
+ compatConfig: { MODE: 3 },
1689
+ setup(props, { attrs, slots }) {
1690
+ warnDeprecatedUsage();
1691
+ const injectedRoute = inject(routerViewLocationKey);
1692
+ const routeToDisplay = computed(() => props.route || injectedRoute.value);
1693
+ const injectedDepth = inject(viewDepthKey, 0);
1694
+ const depth = computed(() => {
1695
+ let initialDepth = unref(injectedDepth);
1696
+ const { matched } = routeToDisplay.value;
1697
+ let matchedRoute;
1698
+ while ((matchedRoute = matched[initialDepth]) && !matchedRoute.components) {
1699
+ initialDepth++;
1700
+ }
1701
+ return initialDepth;
1702
+ });
1703
+ const matchedRouteRef = computed(() => routeToDisplay.value.matched[depth.value]);
1704
+ provide(viewDepthKey, computed(() => depth.value + 1));
1705
+ provide(matchedRouteKey, matchedRouteRef);
1706
+ provide(routerViewLocationKey, routeToDisplay);
1707
+ const viewRef = ref();
1708
+ watch(() => [viewRef.value, matchedRouteRef.value, props.name], ([instance, to, name], [oldInstance, from, oldName]) => {
1709
+ if (to) {
1710
+ to.instances[name] = instance;
1711
+ if (from && from !== to && instance && instance === oldInstance) {
1712
+ if (!to.leaveGuards.size) {
1713
+ to.leaveGuards = from.leaveGuards;
1714
+ }
1715
+ if (!to.updateGuards.size) {
1716
+ to.updateGuards = from.updateGuards;
1717
+ }
1718
+ }
1719
+ }
1720
+ if (instance && to && // if there is no instance but to and from are the same this might be
1721
+ // the first visit
1722
+ (!from || !isSameRouteRecord(to, from) || !oldInstance)) {
1723
+ (to.enterCallbacks[name] || []).forEach((callback) => callback(instance));
1724
+ }
1725
+ }, { flush: "post" });
1726
+ return () => {
1727
+ const route = routeToDisplay.value;
1728
+ const currentName = props.name;
1729
+ const matchedRoute = matchedRouteRef.value;
1730
+ const ViewComponent = matchedRoute && matchedRoute.components[currentName];
1731
+ if (!ViewComponent) {
1732
+ return normalizeSlot(slots.default, { Component: ViewComponent, route });
1733
+ }
1734
+ const routePropsOption = matchedRoute.props[currentName];
1735
+ const routeProps = routePropsOption ? routePropsOption === true ? route.params : typeof routePropsOption === "function" ? routePropsOption(route) : routePropsOption : null;
1736
+ const onVnodeUnmounted = (vnode) => {
1737
+ if (vnode.component.isUnmounted) {
1738
+ matchedRoute.instances[currentName] = null;
1739
+ }
1740
+ };
1741
+ const component = h(ViewComponent, assign({}, routeProps, attrs, {
1742
+ onVnodeUnmounted,
1743
+ ref: viewRef
1744
+ }));
1745
+ if (isBrowser && component.ref) {
1746
+ const info = {
1747
+ depth: depth.value,
1748
+ name: matchedRoute.name,
1749
+ path: matchedRoute.path,
1750
+ meta: matchedRoute.meta
1751
+ };
1752
+ const internalInstances = isArray(component.ref) ? component.ref.map((r) => r.i) : [component.ref.i];
1753
+ internalInstances.forEach((instance) => {
1754
+ instance.__vrv_devtools = info;
1755
+ });
1756
+ }
1757
+ return (
1758
+ // pass the vnode to the slot as a prop.
1759
+ // h and <component :is="..."> both accept vnodes
1760
+ normalizeSlot(slots.default, { Component: component, route }) || component
1761
+ );
1762
+ };
1763
+ }
1764
+ });
1765
+ function normalizeSlot(slot, data) {
1766
+ if (!slot)
1767
+ return null;
1768
+ const slotContent = slot(data);
1769
+ return slotContent.length === 1 ? slotContent[0] : slotContent;
1770
+ }
1771
+ var RouterView = RouterViewImpl;
1772
+ function warnDeprecatedUsage() {
1773
+ const instance = getCurrentInstance();
1774
+ const parentName = instance.parent && instance.parent.type.name;
1775
+ const parentSubTreeType = instance.parent && instance.parent.subTree && instance.parent.subTree.type;
1776
+ if (parentName && (parentName === "KeepAlive" || parentName.includes("Transition")) && typeof parentSubTreeType === "object" && parentSubTreeType.name === "RouterView") {
1777
+ const comp = parentName === "KeepAlive" ? "keep-alive" : "transition";
1778
+ warn(`<router-view> can no longer be used directly inside <transition> or <keep-alive>.
1779
+ Use slot props instead:
1780
+
1781
+ <router-view v-slot="{ Component }">
1782
+ <${comp}>
1783
+ <component :is="Component" />
1784
+ </${comp}>
1785
+ </router-view>`);
1786
+ }
1787
+ }
1788
+ function formatRouteLocation(routeLocation, tooltip) {
1789
+ const copy = assign({}, routeLocation, {
1790
+ // remove variables that can contain vue instances
1791
+ matched: routeLocation.matched.map((matched) => omit(matched, ["instances", "children", "aliasOf"]))
1792
+ });
1793
+ return {
1794
+ _custom: {
1795
+ type: null,
1796
+ readOnly: true,
1797
+ display: routeLocation.fullPath,
1798
+ tooltip,
1799
+ value: copy
1800
+ }
1801
+ };
1802
+ }
1803
+ function formatDisplay(display) {
1804
+ return {
1805
+ _custom: {
1806
+ display
1807
+ }
1808
+ };
1809
+ }
1810
+ var routerId = 0;
1811
+ function addDevtools(app, router, matcher) {
1812
+ if (router.__hasDevtools)
1813
+ return;
1814
+ router.__hasDevtools = true;
1815
+ const id = routerId++;
1816
+ setupDevtoolsPlugin({
1817
+ id: "org.vuejs.router" + (id ? "." + id : ""),
1818
+ label: "Vue Router",
1819
+ packageName: "vue-router",
1820
+ homepage: "https://router.vuejs.org",
1821
+ logo: "https://router.vuejs.org/logo.png",
1822
+ componentStateTypes: ["Routing"],
1823
+ app
1824
+ }, (api) => {
1825
+ if (typeof api.now !== "function") {
1826
+ console.warn("[Vue Router]: You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.");
1827
+ }
1828
+ api.on.inspectComponent((payload, ctx) => {
1829
+ if (payload.instanceData) {
1830
+ payload.instanceData.state.push({
1831
+ type: "Routing",
1832
+ key: "$route",
1833
+ editable: false,
1834
+ value: formatRouteLocation(router.currentRoute.value, "Current Route")
1835
+ });
1836
+ }
1837
+ });
1838
+ api.on.visitComponentTree(({ treeNode: node, componentInstance }) => {
1839
+ if (componentInstance.__vrv_devtools) {
1840
+ const info = componentInstance.__vrv_devtools;
1841
+ node.tags.push({
1842
+ label: (info.name ? `${info.name.toString()}: ` : "") + info.path,
1843
+ textColor: 0,
1844
+ tooltip: "This component is rendered by &lt;router-view&gt;",
1845
+ backgroundColor: PINK_500
1846
+ });
1847
+ }
1848
+ if (isArray(componentInstance.__vrl_devtools)) {
1849
+ componentInstance.__devtoolsApi = api;
1850
+ componentInstance.__vrl_devtools.forEach((devtoolsData) => {
1851
+ let label = devtoolsData.route.path;
1852
+ let backgroundColor = ORANGE_400;
1853
+ let tooltip = "";
1854
+ let textColor = 0;
1855
+ if (devtoolsData.error) {
1856
+ label = devtoolsData.error;
1857
+ backgroundColor = RED_100;
1858
+ textColor = RED_700;
1859
+ } else if (devtoolsData.isExactActive) {
1860
+ backgroundColor = LIME_500;
1861
+ tooltip = "This is exactly active";
1862
+ } else if (devtoolsData.isActive) {
1863
+ backgroundColor = BLUE_600;
1864
+ tooltip = "This link is active";
1865
+ }
1866
+ node.tags.push({
1867
+ label,
1868
+ textColor,
1869
+ tooltip,
1870
+ backgroundColor
1871
+ });
1872
+ });
1873
+ }
1874
+ });
1875
+ watch(router.currentRoute, () => {
1876
+ refreshRoutesView();
1877
+ api.notifyComponentUpdate();
1878
+ api.sendInspectorTree(routerInspectorId);
1879
+ api.sendInspectorState(routerInspectorId);
1880
+ });
1881
+ const navigationsLayerId = "router:navigations:" + id;
1882
+ api.addTimelineLayer({
1883
+ id: navigationsLayerId,
1884
+ label: `Router${id ? " " + id : ""} Navigations`,
1885
+ color: 4237508
1886
+ });
1887
+ router.onError((error, to) => {
1888
+ api.addTimelineEvent({
1889
+ layerId: navigationsLayerId,
1890
+ event: {
1891
+ title: "Error during Navigation",
1892
+ subtitle: to.fullPath,
1893
+ logType: "error",
1894
+ time: api.now(),
1895
+ data: { error },
1896
+ groupId: to.meta.__navigationId
1897
+ }
1898
+ });
1899
+ });
1900
+ let navigationId = 0;
1901
+ router.beforeEach((to, from) => {
1902
+ const data = {
1903
+ guard: formatDisplay("beforeEach"),
1904
+ from: formatRouteLocation(from, "Current Location during this navigation"),
1905
+ to: formatRouteLocation(to, "Target location")
1906
+ };
1907
+ Object.defineProperty(to.meta, "__navigationId", {
1908
+ value: navigationId++
1909
+ });
1910
+ api.addTimelineEvent({
1911
+ layerId: navigationsLayerId,
1912
+ event: {
1913
+ time: api.now(),
1914
+ title: "Start of navigation",
1915
+ subtitle: to.fullPath,
1916
+ data,
1917
+ groupId: to.meta.__navigationId
1918
+ }
1919
+ });
1920
+ });
1921
+ router.afterEach((to, from, failure) => {
1922
+ const data = {
1923
+ guard: formatDisplay("afterEach")
1924
+ };
1925
+ if (failure) {
1926
+ data.failure = {
1927
+ _custom: {
1928
+ type: Error,
1929
+ readOnly: true,
1930
+ display: failure ? failure.message : "",
1931
+ tooltip: "Navigation Failure",
1932
+ value: failure
1933
+ }
1934
+ };
1935
+ data.status = formatDisplay("❌");
1936
+ } else {
1937
+ data.status = formatDisplay("✅");
1938
+ }
1939
+ data.from = formatRouteLocation(from, "Current Location during this navigation");
1940
+ data.to = formatRouteLocation(to, "Target location");
1941
+ api.addTimelineEvent({
1942
+ layerId: navigationsLayerId,
1943
+ event: {
1944
+ title: "End of navigation",
1945
+ subtitle: to.fullPath,
1946
+ time: api.now(),
1947
+ data,
1948
+ logType: failure ? "warning" : "default",
1949
+ groupId: to.meta.__navigationId
1950
+ }
1951
+ });
1952
+ });
1953
+ const routerInspectorId = "router-inspector:" + id;
1954
+ api.addInspector({
1955
+ id: routerInspectorId,
1956
+ label: "Routes" + (id ? " " + id : ""),
1957
+ icon: "book",
1958
+ treeFilterPlaceholder: "Search routes"
1959
+ });
1960
+ function refreshRoutesView() {
1961
+ if (!activeRoutesPayload)
1962
+ return;
1963
+ const payload = activeRoutesPayload;
1964
+ let routes = matcher.getRoutes().filter((route) => !route.parent || // these routes have a parent with no component which will not appear in the view
1965
+ // therefore we still need to include them
1966
+ !route.parent.record.components);
1967
+ routes.forEach(resetMatchStateOnRouteRecord);
1968
+ if (payload.filter) {
1969
+ routes = routes.filter((route) => (
1970
+ // save matches state based on the payload
1971
+ isRouteMatching(route, payload.filter.toLowerCase())
1972
+ ));
1973
+ }
1974
+ routes.forEach((route) => markRouteRecordActive(route, router.currentRoute.value));
1975
+ payload.rootNodes = routes.map(formatRouteRecordForInspector);
1976
+ }
1977
+ let activeRoutesPayload;
1978
+ api.on.getInspectorTree((payload) => {
1979
+ activeRoutesPayload = payload;
1980
+ if (payload.app === app && payload.inspectorId === routerInspectorId) {
1981
+ refreshRoutesView();
1982
+ }
1983
+ });
1984
+ api.on.getInspectorState((payload) => {
1985
+ if (payload.app === app && payload.inspectorId === routerInspectorId) {
1986
+ const routes = matcher.getRoutes();
1987
+ const route = routes.find((route2) => route2.record.__vd_id === payload.nodeId);
1988
+ if (route) {
1989
+ payload.state = {
1990
+ options: formatRouteRecordMatcherForStateInspector(route)
1991
+ };
1992
+ }
1993
+ }
1994
+ });
1995
+ api.sendInspectorTree(routerInspectorId);
1996
+ api.sendInspectorState(routerInspectorId);
1997
+ });
1998
+ }
1999
+ function modifierForKey(key) {
2000
+ if (key.optional) {
2001
+ return key.repeatable ? "*" : "?";
2002
+ } else {
2003
+ return key.repeatable ? "+" : "";
2004
+ }
2005
+ }
2006
+ function formatRouteRecordMatcherForStateInspector(route) {
2007
+ const { record } = route;
2008
+ const fields = [
2009
+ { editable: false, key: "path", value: record.path }
2010
+ ];
2011
+ if (record.name != null) {
2012
+ fields.push({
2013
+ editable: false,
2014
+ key: "name",
2015
+ value: record.name
2016
+ });
2017
+ }
2018
+ fields.push({ editable: false, key: "regexp", value: route.re });
2019
+ if (route.keys.length) {
2020
+ fields.push({
2021
+ editable: false,
2022
+ key: "keys",
2023
+ value: {
2024
+ _custom: {
2025
+ type: null,
2026
+ readOnly: true,
2027
+ display: route.keys.map((key) => `${key.name}${modifierForKey(key)}`).join(" "),
2028
+ tooltip: "Param keys",
2029
+ value: route.keys
2030
+ }
2031
+ }
2032
+ });
2033
+ }
2034
+ if (record.redirect != null) {
2035
+ fields.push({
2036
+ editable: false,
2037
+ key: "redirect",
2038
+ value: record.redirect
2039
+ });
2040
+ }
2041
+ if (route.alias.length) {
2042
+ fields.push({
2043
+ editable: false,
2044
+ key: "aliases",
2045
+ value: route.alias.map((alias) => alias.record.path)
2046
+ });
2047
+ }
2048
+ if (Object.keys(route.record.meta).length) {
2049
+ fields.push({
2050
+ editable: false,
2051
+ key: "meta",
2052
+ value: route.record.meta
2053
+ });
2054
+ }
2055
+ fields.push({
2056
+ key: "score",
2057
+ editable: false,
2058
+ value: {
2059
+ _custom: {
2060
+ type: null,
2061
+ readOnly: true,
2062
+ display: route.score.map((score) => score.join(", ")).join(" | "),
2063
+ tooltip: "Score used to sort routes",
2064
+ value: route.score
2065
+ }
2066
+ }
2067
+ });
2068
+ return fields;
2069
+ }
2070
+ var PINK_500 = 15485081;
2071
+ var BLUE_600 = 2450411;
2072
+ var LIME_500 = 8702998;
2073
+ var CYAN_400 = 2282478;
2074
+ var ORANGE_400 = 16486972;
2075
+ var DARK = 6710886;
2076
+ var RED_100 = 16704226;
2077
+ var RED_700 = 12131356;
2078
+ function formatRouteRecordForInspector(route) {
2079
+ const tags = [];
2080
+ const { record } = route;
2081
+ if (record.name != null) {
2082
+ tags.push({
2083
+ label: String(record.name),
2084
+ textColor: 0,
2085
+ backgroundColor: CYAN_400
2086
+ });
2087
+ }
2088
+ if (record.aliasOf) {
2089
+ tags.push({
2090
+ label: "alias",
2091
+ textColor: 0,
2092
+ backgroundColor: ORANGE_400
2093
+ });
2094
+ }
2095
+ if (route.__vd_match) {
2096
+ tags.push({
2097
+ label: "matches",
2098
+ textColor: 0,
2099
+ backgroundColor: PINK_500
2100
+ });
2101
+ }
2102
+ if (route.__vd_exactActive) {
2103
+ tags.push({
2104
+ label: "exact",
2105
+ textColor: 0,
2106
+ backgroundColor: LIME_500
2107
+ });
2108
+ }
2109
+ if (route.__vd_active) {
2110
+ tags.push({
2111
+ label: "active",
2112
+ textColor: 0,
2113
+ backgroundColor: BLUE_600
2114
+ });
2115
+ }
2116
+ if (record.redirect) {
2117
+ tags.push({
2118
+ label: typeof record.redirect === "string" ? `redirect: ${record.redirect}` : "redirects",
2119
+ textColor: 16777215,
2120
+ backgroundColor: DARK
2121
+ });
2122
+ }
2123
+ let id = record.__vd_id;
2124
+ if (id == null) {
2125
+ id = String(routeRecordId++);
2126
+ record.__vd_id = id;
2127
+ }
2128
+ return {
2129
+ id,
2130
+ label: record.path,
2131
+ tags,
2132
+ children: route.children.map(formatRouteRecordForInspector)
2133
+ };
2134
+ }
2135
+ var routeRecordId = 0;
2136
+ var EXTRACT_REGEXP_RE = /^\/(.*)\/([a-z]*)$/;
2137
+ function markRouteRecordActive(route, currentRoute) {
2138
+ const isExactActive = currentRoute.matched.length && isSameRouteRecord(currentRoute.matched[currentRoute.matched.length - 1], route.record);
2139
+ route.__vd_exactActive = route.__vd_active = isExactActive;
2140
+ if (!isExactActive) {
2141
+ route.__vd_active = currentRoute.matched.some((match) => isSameRouteRecord(match, route.record));
2142
+ }
2143
+ route.children.forEach((childRoute) => markRouteRecordActive(childRoute, currentRoute));
2144
+ }
2145
+ function resetMatchStateOnRouteRecord(route) {
2146
+ route.__vd_match = false;
2147
+ route.children.forEach(resetMatchStateOnRouteRecord);
2148
+ }
2149
+ function isRouteMatching(route, filter) {
2150
+ const found = String(route.re).match(EXTRACT_REGEXP_RE);
2151
+ route.__vd_match = false;
2152
+ if (!found || found.length < 3) {
2153
+ return false;
2154
+ }
2155
+ const nonEndingRE = new RegExp(found[1].replace(/\$$/, ""), found[2]);
2156
+ if (nonEndingRE.test(filter)) {
2157
+ route.children.forEach((child) => isRouteMatching(child, filter));
2158
+ if (route.record.path !== "/" || filter === "/") {
2159
+ route.__vd_match = route.re.test(filter);
2160
+ return true;
2161
+ }
2162
+ return false;
2163
+ }
2164
+ const path = route.record.path.toLowerCase();
2165
+ const decodedPath = decode(path);
2166
+ if (!filter.startsWith("/") && (decodedPath.includes(filter) || path.includes(filter)))
2167
+ return true;
2168
+ if (decodedPath.startsWith(filter) || path.startsWith(filter))
2169
+ return true;
2170
+ if (route.record.name && String(route.record.name).includes(filter))
2171
+ return true;
2172
+ return route.children.some((child) => isRouteMatching(child, filter));
2173
+ }
2174
+ function omit(obj, keys) {
2175
+ const ret = {};
2176
+ for (const key in obj) {
2177
+ if (!keys.includes(key)) {
2178
+ ret[key] = obj[key];
2179
+ }
2180
+ }
2181
+ return ret;
2182
+ }
2183
+ function createRouter(options) {
2184
+ const matcher = createRouterMatcher(options.routes, options);
2185
+ const parseQuery$1 = options.parseQuery || parseQuery;
2186
+ const stringifyQuery$1 = options.stringifyQuery || stringifyQuery;
2187
+ const routerHistory = options.history;
2188
+ if (!routerHistory)
2189
+ throw new Error('Provide the "history" option when calling "createRouter()": https://router.vuejs.org/api/interfaces/RouterOptions.html#history');
2190
+ const beforeGuards = useCallbacks();
2191
+ const beforeResolveGuards = useCallbacks();
2192
+ const afterGuards = useCallbacks();
2193
+ const currentRoute = shallowRef(START_LOCATION_NORMALIZED);
2194
+ let pendingLocation = START_LOCATION_NORMALIZED;
2195
+ if (isBrowser && options.scrollBehavior && "scrollRestoration" in history) {
2196
+ history.scrollRestoration = "manual";
2197
+ }
2198
+ const normalizeParams = applyToParams.bind(null, (paramValue) => "" + paramValue);
2199
+ const encodeParams = applyToParams.bind(null, encodeParam);
2200
+ const decodeParams = (
2201
+ // @ts-expect-error: intentionally avoid the type check
2202
+ applyToParams.bind(null, decode)
2203
+ );
2204
+ function addRoute(parentOrRoute, route) {
2205
+ let parent;
2206
+ let record;
2207
+ if (isRouteName(parentOrRoute)) {
2208
+ parent = matcher.getRecordMatcher(parentOrRoute);
2209
+ if (!parent) {
2210
+ warn(`Parent route "${String(parentOrRoute)}" not found when adding child route`, route);
2211
+ }
2212
+ record = route;
2213
+ } else {
2214
+ record = parentOrRoute;
2215
+ }
2216
+ return matcher.addRoute(record, parent);
2217
+ }
2218
+ function removeRoute(name) {
2219
+ const recordMatcher = matcher.getRecordMatcher(name);
2220
+ if (recordMatcher) {
2221
+ matcher.removeRoute(recordMatcher);
2222
+ } else if (true) {
2223
+ warn(`Cannot remove non-existent route "${String(name)}"`);
2224
+ }
2225
+ }
2226
+ function getRoutes() {
2227
+ return matcher.getRoutes().map((routeMatcher) => routeMatcher.record);
2228
+ }
2229
+ function hasRoute(name) {
2230
+ return !!matcher.getRecordMatcher(name);
2231
+ }
2232
+ function resolve(rawLocation, currentLocation) {
2233
+ currentLocation = assign({}, currentLocation || currentRoute.value);
2234
+ if (typeof rawLocation === "string") {
2235
+ const locationNormalized = parseURL(parseQuery$1, rawLocation, currentLocation.path);
2236
+ const matchedRoute2 = matcher.resolve({ path: locationNormalized.path }, currentLocation);
2237
+ const href2 = routerHistory.createHref(locationNormalized.fullPath);
2238
+ if (true) {
2239
+ if (href2.startsWith("//"))
2240
+ warn(`Location "${rawLocation}" resolved to "${href2}". A resolved location cannot start with multiple slashes.`);
2241
+ else if (!matchedRoute2.matched.length) {
2242
+ warn(`No match found for location with path "${rawLocation}"`);
2243
+ }
2244
+ }
2245
+ return assign(locationNormalized, matchedRoute2, {
2246
+ params: decodeParams(matchedRoute2.params),
2247
+ hash: decode(locationNormalized.hash),
2248
+ redirectedFrom: void 0,
2249
+ href: href2
2250
+ });
2251
+ }
2252
+ if (!isRouteLocation(rawLocation)) {
2253
+ warn(`router.resolve() was passed an invalid location. This will fail in production.
2254
+ - Location:`, rawLocation);
2255
+ return resolve({});
2256
+ }
2257
+ let matcherLocation;
2258
+ if (rawLocation.path != null) {
2259
+ if ("params" in rawLocation && !("name" in rawLocation) && // @ts-expect-error: the type is never
2260
+ Object.keys(rawLocation.params).length) {
2261
+ warn(`Path "${rawLocation.path}" was passed with params but they will be ignored. Use a named route alongside params instead.`);
2262
+ }
2263
+ matcherLocation = assign({}, rawLocation, {
2264
+ path: parseURL(parseQuery$1, rawLocation.path, currentLocation.path).path
2265
+ });
2266
+ } else {
2267
+ const targetParams = assign({}, rawLocation.params);
2268
+ for (const key in targetParams) {
2269
+ if (targetParams[key] == null) {
2270
+ delete targetParams[key];
2271
+ }
2272
+ }
2273
+ matcherLocation = assign({}, rawLocation, {
2274
+ params: encodeParams(targetParams)
2275
+ });
2276
+ currentLocation.params = encodeParams(currentLocation.params);
2277
+ }
2278
+ const matchedRoute = matcher.resolve(matcherLocation, currentLocation);
2279
+ const hash = rawLocation.hash || "";
2280
+ if (hash && !hash.startsWith("#")) {
2281
+ warn(`A \`hash\` should always start with the character "#". Replace "${hash}" with "#${hash}".`);
2282
+ }
2283
+ matchedRoute.params = normalizeParams(decodeParams(matchedRoute.params));
2284
+ const fullPath = stringifyURL(stringifyQuery$1, assign({}, rawLocation, {
2285
+ hash: encodeHash(hash),
2286
+ path: matchedRoute.path
2287
+ }));
2288
+ const href = routerHistory.createHref(fullPath);
2289
+ if (true) {
2290
+ if (href.startsWith("//")) {
2291
+ warn(`Location "${rawLocation}" resolved to "${href}". A resolved location cannot start with multiple slashes.`);
2292
+ } else if (!matchedRoute.matched.length) {
2293
+ warn(`No match found for location with path "${rawLocation.path != null ? rawLocation.path : rawLocation}"`);
2294
+ }
2295
+ }
2296
+ return assign({
2297
+ fullPath,
2298
+ // keep the hash encoded so fullPath is effectively path + encodedQuery +
2299
+ // hash
2300
+ hash,
2301
+ query: (
2302
+ // if the user is using a custom query lib like qs, we might have
2303
+ // nested objects, so we keep the query as is, meaning it can contain
2304
+ // numbers at `$route.query`, but at the point, the user will have to
2305
+ // use their own type anyway.
2306
+ // https://github.com/vuejs/router/issues/328#issuecomment-649481567
2307
+ stringifyQuery$1 === stringifyQuery ? normalizeQuery(rawLocation.query) : rawLocation.query || {}
2308
+ )
2309
+ }, matchedRoute, {
2310
+ redirectedFrom: void 0,
2311
+ href
2312
+ });
2313
+ }
2314
+ function locationAsObject(to) {
2315
+ return typeof to === "string" ? parseURL(parseQuery$1, to, currentRoute.value.path) : assign({}, to);
2316
+ }
2317
+ function checkCanceledNavigation(to, from) {
2318
+ if (pendingLocation !== to) {
2319
+ return createRouterError(8, {
2320
+ from,
2321
+ to
2322
+ });
2323
+ }
2324
+ }
2325
+ function push(to) {
2326
+ return pushWithRedirect(to);
2327
+ }
2328
+ function replace(to) {
2329
+ return push(assign(locationAsObject(to), { replace: true }));
2330
+ }
2331
+ function handleRedirectRecord(to) {
2332
+ const lastMatched = to.matched[to.matched.length - 1];
2333
+ if (lastMatched && lastMatched.redirect) {
2334
+ const { redirect } = lastMatched;
2335
+ let newTargetLocation = typeof redirect === "function" ? redirect(to) : redirect;
2336
+ if (typeof newTargetLocation === "string") {
2337
+ newTargetLocation = newTargetLocation.includes("?") || newTargetLocation.includes("#") ? newTargetLocation = locationAsObject(newTargetLocation) : (
2338
+ // force empty params
2339
+ { path: newTargetLocation }
2340
+ );
2341
+ newTargetLocation.params = {};
2342
+ }
2343
+ if (newTargetLocation.path == null && !("name" in newTargetLocation)) {
2344
+ warn(`Invalid redirect found:
2345
+ ${JSON.stringify(newTargetLocation, null, 2)}
2346
+ when navigating to "${to.fullPath}". A redirect must contain a name or path. This will break in production.`);
2347
+ throw new Error("Invalid redirect");
2348
+ }
2349
+ return assign({
2350
+ query: to.query,
2351
+ hash: to.hash,
2352
+ // avoid transferring params if the redirect has a path
2353
+ params: newTargetLocation.path != null ? {} : to.params
2354
+ }, newTargetLocation);
2355
+ }
2356
+ }
2357
+ function pushWithRedirect(to, redirectedFrom) {
2358
+ const targetLocation = pendingLocation = resolve(to);
2359
+ const from = currentRoute.value;
2360
+ const data = to.state;
2361
+ const force = to.force;
2362
+ const replace2 = to.replace === true;
2363
+ const shouldRedirect = handleRedirectRecord(targetLocation);
2364
+ if (shouldRedirect)
2365
+ return pushWithRedirect(
2366
+ assign(locationAsObject(shouldRedirect), {
2367
+ state: typeof shouldRedirect === "object" ? assign({}, data, shouldRedirect.state) : data,
2368
+ force,
2369
+ replace: replace2
2370
+ }),
2371
+ // keep original redirectedFrom if it exists
2372
+ redirectedFrom || targetLocation
2373
+ );
2374
+ const toLocation = targetLocation;
2375
+ toLocation.redirectedFrom = redirectedFrom;
2376
+ let failure;
2377
+ if (!force && isSameRouteLocation(stringifyQuery$1, from, targetLocation)) {
2378
+ failure = createRouterError(16, { to: toLocation, from });
2379
+ handleScroll(
2380
+ from,
2381
+ from,
2382
+ // this is a push, the only way for it to be triggered from a
2383
+ // history.listen is with a redirect, which makes it become a push
2384
+ true,
2385
+ // This cannot be the first navigation because the initial location
2386
+ // cannot be manually navigated to
2387
+ false
2388
+ );
2389
+ }
2390
+ return (failure ? Promise.resolve(failure) : navigate(toLocation, from)).catch((error) => isNavigationFailure(error) ? (
2391
+ // navigation redirects still mark the router as ready
2392
+ isNavigationFailure(
2393
+ error,
2394
+ 2
2395
+ /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
2396
+ ) ? error : markAsReady(error)
2397
+ ) : (
2398
+ // reject any unknown error
2399
+ triggerError(error, toLocation, from)
2400
+ )).then((failure2) => {
2401
+ if (failure2) {
2402
+ if (isNavigationFailure(
2403
+ failure2,
2404
+ 2
2405
+ /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
2406
+ )) {
2407
+ if (// we are redirecting to the same location we were already at
2408
+ isSameRouteLocation(stringifyQuery$1, resolve(failure2.to), toLocation) && // and we have done it a couple of times
2409
+ redirectedFrom && // @ts-expect-error: added only in dev
2410
+ (redirectedFrom._count = redirectedFrom._count ? (
2411
+ // @ts-expect-error
2412
+ redirectedFrom._count + 1
2413
+ ) : 1) > 30) {
2414
+ warn(`Detected a possibly infinite redirection in a navigation guard when going from "${from.fullPath}" to "${toLocation.fullPath}". Aborting to avoid a Stack Overflow.
2415
+ Are you always returning a new location within a navigation guard? That would lead to this error. Only return when redirecting or aborting, that should fix this. This might break in production if not fixed.`);
2416
+ return Promise.reject(new Error("Infinite redirect in navigation guard"));
2417
+ }
2418
+ return pushWithRedirect(
2419
+ // keep options
2420
+ assign({
2421
+ // preserve an existing replacement but allow the redirect to override it
2422
+ replace: replace2
2423
+ }, locationAsObject(failure2.to), {
2424
+ state: typeof failure2.to === "object" ? assign({}, data, failure2.to.state) : data,
2425
+ force
2426
+ }),
2427
+ // preserve the original redirectedFrom if any
2428
+ redirectedFrom || toLocation
2429
+ );
2430
+ }
2431
+ } else {
2432
+ failure2 = finalizeNavigation(toLocation, from, true, replace2, data);
2433
+ }
2434
+ triggerAfterEach(toLocation, from, failure2);
2435
+ return failure2;
2436
+ });
2437
+ }
2438
+ function checkCanceledNavigationAndReject(to, from) {
2439
+ const error = checkCanceledNavigation(to, from);
2440
+ return error ? Promise.reject(error) : Promise.resolve();
2441
+ }
2442
+ function runWithContext(fn) {
2443
+ const app = installedApps.values().next().value;
2444
+ return app && typeof app.runWithContext === "function" ? app.runWithContext(fn) : fn();
2445
+ }
2446
+ function navigate(to, from) {
2447
+ let guards;
2448
+ const [leavingRecords, updatingRecords, enteringRecords] = extractChangingRecords(to, from);
2449
+ guards = extractComponentsGuards(leavingRecords.reverse(), "beforeRouteLeave", to, from);
2450
+ for (const record of leavingRecords) {
2451
+ record.leaveGuards.forEach((guard) => {
2452
+ guards.push(guardToPromiseFn(guard, to, from));
2453
+ });
2454
+ }
2455
+ const canceledNavigationCheck = checkCanceledNavigationAndReject.bind(null, to, from);
2456
+ guards.push(canceledNavigationCheck);
2457
+ return runGuardQueue(guards).then(() => {
2458
+ guards = [];
2459
+ for (const guard of beforeGuards.list()) {
2460
+ guards.push(guardToPromiseFn(guard, to, from));
2461
+ }
2462
+ guards.push(canceledNavigationCheck);
2463
+ return runGuardQueue(guards);
2464
+ }).then(() => {
2465
+ guards = extractComponentsGuards(updatingRecords, "beforeRouteUpdate", to, from);
2466
+ for (const record of updatingRecords) {
2467
+ record.updateGuards.forEach((guard) => {
2468
+ guards.push(guardToPromiseFn(guard, to, from));
2469
+ });
2470
+ }
2471
+ guards.push(canceledNavigationCheck);
2472
+ return runGuardQueue(guards);
2473
+ }).then(() => {
2474
+ guards = [];
2475
+ for (const record of enteringRecords) {
2476
+ if (record.beforeEnter) {
2477
+ if (isArray(record.beforeEnter)) {
2478
+ for (const beforeEnter of record.beforeEnter)
2479
+ guards.push(guardToPromiseFn(beforeEnter, to, from));
2480
+ } else {
2481
+ guards.push(guardToPromiseFn(record.beforeEnter, to, from));
2482
+ }
2483
+ }
2484
+ }
2485
+ guards.push(canceledNavigationCheck);
2486
+ return runGuardQueue(guards);
2487
+ }).then(() => {
2488
+ to.matched.forEach((record) => record.enterCallbacks = {});
2489
+ guards = extractComponentsGuards(enteringRecords, "beforeRouteEnter", to, from, runWithContext);
2490
+ guards.push(canceledNavigationCheck);
2491
+ return runGuardQueue(guards);
2492
+ }).then(() => {
2493
+ guards = [];
2494
+ for (const guard of beforeResolveGuards.list()) {
2495
+ guards.push(guardToPromiseFn(guard, to, from));
2496
+ }
2497
+ guards.push(canceledNavigationCheck);
2498
+ return runGuardQueue(guards);
2499
+ }).catch((err) => isNavigationFailure(
2500
+ err,
2501
+ 8
2502
+ /* ErrorTypes.NAVIGATION_CANCELLED */
2503
+ ) ? err : Promise.reject(err));
2504
+ }
2505
+ function triggerAfterEach(to, from, failure) {
2506
+ afterGuards.list().forEach((guard) => runWithContext(() => guard(to, from, failure)));
2507
+ }
2508
+ function finalizeNavigation(toLocation, from, isPush, replace2, data) {
2509
+ const error = checkCanceledNavigation(toLocation, from);
2510
+ if (error)
2511
+ return error;
2512
+ const isFirstNavigation = from === START_LOCATION_NORMALIZED;
2513
+ const state = !isBrowser ? {} : history.state;
2514
+ if (isPush) {
2515
+ if (replace2 || isFirstNavigation)
2516
+ routerHistory.replace(toLocation.fullPath, assign({
2517
+ scroll: isFirstNavigation && state && state.scroll
2518
+ }, data));
2519
+ else
2520
+ routerHistory.push(toLocation.fullPath, data);
2521
+ }
2522
+ currentRoute.value = toLocation;
2523
+ handleScroll(toLocation, from, isPush, isFirstNavigation);
2524
+ markAsReady();
2525
+ }
2526
+ let removeHistoryListener;
2527
+ function setupListeners() {
2528
+ if (removeHistoryListener)
2529
+ return;
2530
+ removeHistoryListener = routerHistory.listen((to, _from, info) => {
2531
+ if (!router.listening)
2532
+ return;
2533
+ const toLocation = resolve(to);
2534
+ const shouldRedirect = handleRedirectRecord(toLocation);
2535
+ if (shouldRedirect) {
2536
+ pushWithRedirect(assign(shouldRedirect, { replace: true, force: true }), toLocation).catch(noop);
2537
+ return;
2538
+ }
2539
+ pendingLocation = toLocation;
2540
+ const from = currentRoute.value;
2541
+ if (isBrowser) {
2542
+ saveScrollPosition(getScrollKey(from.fullPath, info.delta), computeScrollPosition());
2543
+ }
2544
+ navigate(toLocation, from).catch((error) => {
2545
+ if (isNavigationFailure(
2546
+ error,
2547
+ 4 | 8
2548
+ /* ErrorTypes.NAVIGATION_CANCELLED */
2549
+ )) {
2550
+ return error;
2551
+ }
2552
+ if (isNavigationFailure(
2553
+ error,
2554
+ 2
2555
+ /* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
2556
+ )) {
2557
+ pushWithRedirect(
2558
+ assign(locationAsObject(error.to), {
2559
+ force: true
2560
+ }),
2561
+ toLocation
2562
+ // avoid an uncaught rejection, let push call triggerError
2563
+ ).then((failure) => {
2564
+ if (isNavigationFailure(
2565
+ failure,
2566
+ 4 | 16
2567
+ /* ErrorTypes.NAVIGATION_DUPLICATED */
2568
+ ) && !info.delta && info.type === NavigationType.pop) {
2569
+ routerHistory.go(-1, false);
2570
+ }
2571
+ }).catch(noop);
2572
+ return Promise.reject();
2573
+ }
2574
+ if (info.delta) {
2575
+ routerHistory.go(-info.delta, false);
2576
+ }
2577
+ return triggerError(error, toLocation, from);
2578
+ }).then((failure) => {
2579
+ failure = failure || finalizeNavigation(
2580
+ // after navigation, all matched components are resolved
2581
+ toLocation,
2582
+ from,
2583
+ false
2584
+ );
2585
+ if (failure) {
2586
+ if (info.delta && // a new navigation has been triggered, so we do not want to revert, that will change the current history
2587
+ // entry while a different route is displayed
2588
+ !isNavigationFailure(
2589
+ failure,
2590
+ 8
2591
+ /* ErrorTypes.NAVIGATION_CANCELLED */
2592
+ )) {
2593
+ routerHistory.go(-info.delta, false);
2594
+ } else if (info.type === NavigationType.pop && isNavigationFailure(
2595
+ failure,
2596
+ 4 | 16
2597
+ /* ErrorTypes.NAVIGATION_DUPLICATED */
2598
+ )) {
2599
+ routerHistory.go(-1, false);
2600
+ }
2601
+ }
2602
+ triggerAfterEach(toLocation, from, failure);
2603
+ }).catch(noop);
2604
+ });
2605
+ }
2606
+ let readyHandlers = useCallbacks();
2607
+ let errorListeners = useCallbacks();
2608
+ let ready;
2609
+ function triggerError(error, to, from) {
2610
+ markAsReady(error);
2611
+ const list = errorListeners.list();
2612
+ if (list.length) {
2613
+ list.forEach((handler) => handler(error, to, from));
2614
+ } else {
2615
+ if (true) {
2616
+ warn("uncaught error during route navigation:");
2617
+ }
2618
+ console.error(error);
2619
+ }
2620
+ return Promise.reject(error);
2621
+ }
2622
+ function isReady() {
2623
+ if (ready && currentRoute.value !== START_LOCATION_NORMALIZED)
2624
+ return Promise.resolve();
2625
+ return new Promise((resolve2, reject) => {
2626
+ readyHandlers.add([resolve2, reject]);
2627
+ });
2628
+ }
2629
+ function markAsReady(err) {
2630
+ if (!ready) {
2631
+ ready = !err;
2632
+ setupListeners();
2633
+ readyHandlers.list().forEach(([resolve2, reject]) => err ? reject(err) : resolve2());
2634
+ readyHandlers.reset();
2635
+ }
2636
+ return err;
2637
+ }
2638
+ function handleScroll(to, from, isPush, isFirstNavigation) {
2639
+ const { scrollBehavior } = options;
2640
+ if (!isBrowser || !scrollBehavior)
2641
+ return Promise.resolve();
2642
+ const scrollPosition = !isPush && getSavedScrollPosition(getScrollKey(to.fullPath, 0)) || (isFirstNavigation || !isPush) && history.state && history.state.scroll || null;
2643
+ return nextTick().then(() => scrollBehavior(to, from, scrollPosition)).then((position) => position && scrollToPosition(position)).catch((err) => triggerError(err, to, from));
2644
+ }
2645
+ const go = (delta) => routerHistory.go(delta);
2646
+ let started;
2647
+ const installedApps = /* @__PURE__ */ new Set();
2648
+ const router = {
2649
+ currentRoute,
2650
+ listening: true,
2651
+ addRoute,
2652
+ removeRoute,
2653
+ clearRoutes: matcher.clearRoutes,
2654
+ hasRoute,
2655
+ getRoutes,
2656
+ resolve,
2657
+ options,
2658
+ push,
2659
+ replace,
2660
+ go,
2661
+ back: () => go(-1),
2662
+ forward: () => go(1),
2663
+ beforeEach: beforeGuards.add,
2664
+ beforeResolve: beforeResolveGuards.add,
2665
+ afterEach: afterGuards.add,
2666
+ onError: errorListeners.add,
2667
+ isReady,
2668
+ install(app) {
2669
+ const router2 = this;
2670
+ app.component("RouterLink", RouterLink);
2671
+ app.component("RouterView", RouterView);
2672
+ app.config.globalProperties.$router = router2;
2673
+ Object.defineProperty(app.config.globalProperties, "$route", {
2674
+ enumerable: true,
2675
+ get: () => unref(currentRoute)
2676
+ });
2677
+ if (isBrowser && // used for the initial navigation client side to avoid pushing
2678
+ // multiple times when the router is used in multiple apps
2679
+ !started && currentRoute.value === START_LOCATION_NORMALIZED) {
2680
+ started = true;
2681
+ push(routerHistory.location).catch((err) => {
2682
+ if (true)
2683
+ warn("Unexpected error when starting the router:", err);
2684
+ });
2685
+ }
2686
+ const reactiveRoute = {};
2687
+ for (const key in START_LOCATION_NORMALIZED) {
2688
+ Object.defineProperty(reactiveRoute, key, {
2689
+ get: () => currentRoute.value[key],
2690
+ enumerable: true
2691
+ });
2692
+ }
2693
+ app.provide(routerKey, router2);
2694
+ app.provide(routeLocationKey, shallowReactive(reactiveRoute));
2695
+ app.provide(routerViewLocationKey, currentRoute);
2696
+ const unmountApp = app.unmount;
2697
+ installedApps.add(app);
2698
+ app.unmount = function() {
2699
+ installedApps.delete(app);
2700
+ if (installedApps.size < 1) {
2701
+ pendingLocation = START_LOCATION_NORMALIZED;
2702
+ removeHistoryListener && removeHistoryListener();
2703
+ removeHistoryListener = null;
2704
+ currentRoute.value = START_LOCATION_NORMALIZED;
2705
+ started = false;
2706
+ ready = false;
2707
+ }
2708
+ unmountApp();
2709
+ };
2710
+ if (isBrowser) {
2711
+ addDevtools(app, router2, matcher);
2712
+ }
2713
+ }
2714
+ };
2715
+ function runGuardQueue(guards) {
2716
+ return guards.reduce((promise, guard) => promise.then(() => runWithContext(guard)), Promise.resolve());
2717
+ }
2718
+ return router;
2719
+ }
2720
+ function extractChangingRecords(to, from) {
2721
+ const leavingRecords = [];
2722
+ const updatingRecords = [];
2723
+ const enteringRecords = [];
2724
+ const len = Math.max(from.matched.length, to.matched.length);
2725
+ for (let i = 0; i < len; i++) {
2726
+ const recordFrom = from.matched[i];
2727
+ if (recordFrom) {
2728
+ if (to.matched.find((record) => isSameRouteRecord(record, recordFrom)))
2729
+ updatingRecords.push(recordFrom);
2730
+ else
2731
+ leavingRecords.push(recordFrom);
2732
+ }
2733
+ const recordTo = to.matched[i];
2734
+ if (recordTo) {
2735
+ if (!from.matched.find((record) => isSameRouteRecord(record, recordTo))) {
2736
+ enteringRecords.push(recordTo);
2737
+ }
2738
+ }
2739
+ }
2740
+ return [leavingRecords, updatingRecords, enteringRecords];
2741
+ }
2742
+ function useRouter() {
2743
+ return inject(routerKey);
2744
+ }
2745
+ function useRoute(_name) {
2746
+ return inject(routeLocationKey);
2747
+ }
2748
+ export {
2749
+ NavigationFailureType,
2750
+ RouterLink,
2751
+ RouterView,
2752
+ START_LOCATION_NORMALIZED as START_LOCATION,
2753
+ createMemoryHistory,
2754
+ createRouter,
2755
+ createRouterMatcher,
2756
+ createWebHashHistory,
2757
+ createWebHistory,
2758
+ isNavigationFailure,
2759
+ loadRouteLocation,
2760
+ matchedRouteKey,
2761
+ onBeforeRouteLeave,
2762
+ onBeforeRouteUpdate,
2763
+ parseQuery,
2764
+ routeLocationKey,
2765
+ routerKey,
2766
+ routerViewLocationKey,
2767
+ stringifyQuery,
2768
+ useLink,
2769
+ useRoute,
2770
+ useRouter,
2771
+ viewDepthKey
2772
+ };
2773
+ /*! Bundled license information:
2774
+
2775
+ vue-router/dist/vue-router.mjs:
2776
+ (*!
2777
+ * vue-router v4.5.1
2778
+ * (c) 2025 Eduardo San Martin Morote
2779
+ * @license MIT
2780
+ *)
2781
+ */
2782
+ //# sourceMappingURL=vue-router.js.map