vue-router.js 98 KB

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