@blueking/ai-ui-sdk 0.3.0-beta.4 → 0.3.0-beta.6

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