vue-router
Version:
> To see what versions are currently supported, please refer to the [Security Policy](./packages/router/SECURITY.md).
6 lines • 25.2 kB
JavaScript
/*!
* vue-router v5.2.0
* (c) 2026 Eduardo San Martin Morote
* @license MIT
*/
import{computed as e,defineComponent as t,h as n,inject as r,nextTick as i,onActivated as a,onDeactivated as o,onUnmounted as s,provide as c,reactive as l,ref as u,shallowReactive as d,shallowRef as f,unref as p,watch as ee}from"vue";const m=typeof document<`u`;function h(e){return typeof e==`object`||`displayName`in e||`props`in e||`__vccOpts`in e}function g(e){return e.__esModule||e[Symbol.toStringTag]===`Module`||e.default&&h(e.default)}const _=Object.assign;function te(e,t){let n={};for(let r in t){let i=t[r];n[r]=y(i)?i.map(e):e(i)}return n}const v=()=>{},y=Array.isArray;function b(e,t){let n={};for(let r in e)n[r]=r in t?t[r]:e[r];return n}const ne=Symbol(``);let re=function(e){return e[e.aborted=4]=`aborted`,e[e.cancelled=8]=`cancelled`,e[e.duplicated=16]=`duplicated`,e}({});function x(e,t){return _(Error(),{type:e,[ne]:!0},t)}function S(e,t){return e instanceof Error&&ne in e&&(t==null||!!(e.type&t))}const C=/#/g,w=/&/g,T=/\//g,E=/=/g,D=/\?/g,ie=/\+/g,ae=/%5B/g,O=/%5D/g,oe=/%5E/g,k=/%60/g,A=/%7B/g,j=/%7C/g,M=/%7D/g,N=/%20/g;function P(e){return e==null?``:encodeURI(``+e).replace(j,`|`).replace(ae,`[`).replace(O,`]`)}function se(e){return P(e).replace(A,`{`).replace(M,`}`).replace(oe,`^`)}function F(e){return P(e).replace(ie,`%2B`).replace(N,`+`).replace(C,`%23`).replace(w,`%26`).replace(k,"`").replace(A,`{`).replace(M,`}`).replace(oe,`^`)}function ce(e){return F(e).replace(E,`%3D`)}function I(e){return P(e).replace(C,`%23`).replace(D,`%3F`)}function le(e){return I(e).replace(T,`%2F`)}function L(e){if(e==null)return null;try{return decodeURIComponent(``+e)}catch(e){}return``+e}const R=/\/$/,ue=e=>e.replace(R,``);function de(e,t,n=`/`){let r,i={},a=``,o=``,s=t.indexOf(`#`),c=t.indexOf(`?`);return c=s>=0&&c>s?-1:c,c>=0&&(r=t.slice(0,c),a=t.slice(c,s>0?s:t.length),i=e(a.slice(1))),s>=0&&(r=r||t.slice(0,s),o=t.slice(s,t.length)),r=W(r==null?t:r,n),{fullPath:r+a+o,path:r,query:i,hash:L(o)}}function fe(e,t){let n=t.query?e(t.query):``;return t.path+(n&&`?`)+n+(t.hash||``)}function z(e,t){return!t||!e.toLowerCase().startsWith(t.toLowerCase())?e:e.slice(t.length)||`/`}function pe(e,t,n){let r=t.matched.length-1,i=n.matched.length-1;return r>-1&&r===i&&B(t.matched[r],n.matched[i])&&V(t.params,n.params)&&e(t.query)===e(n.query)&&t.hash===n.hash}function B(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function V(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var n in e)if(!H(e[n],t[n]))return!1;return!0}function H(e,t){return y(e)?U(e,t):y(t)?U(t,e):(e&&e.valueOf())===(t&&t.valueOf())}function U(e,t){return y(t)?e.length===t.length&&e.every((e,n)=>e===t[n]):e.length===1&&e[0]===t}function W(e,t){if(e.startsWith(`/`))return e;if(!e)return t;let n=t.split(`/`),r=e.split(`/`),i=r[r.length-1];(i===`..`||i===`.`)&&r.push(``);let a=n.length-1,o,s;for(o=0;o<r.length;o++)if(s=r[o],s!==`.`)if(s===`..`)a>1&&a--;else break;return n.slice(0,a).join(`/`)+`/`+r.slice(o).join(`/`)}const G={path:`/`,name:void 0,params:{},query:{},hash:``,fullPath:`/`,matched:[],meta:{},redirectedFrom:void 0};function K(e){if(!e)if(m){let t=document.querySelector(`base`);e=t&&t.getAttribute(`href`)||`/`,e=e.replace(/^\w+:\/\/[^/]+/,``)}else e=`/`;return e[0]!==`/`&&e[0]!==`#`&&(e=`/`+e),ue(e)}const me=/^[^#]+#/;function he(e,t){return e.replace(me,`#`)+t}function ge(e,t){let n=document.documentElement.getBoundingClientRect(),r=e.getBoundingClientRect();return{behavior:t.behavior,left:r.left-n.left-(t.left||0),top:r.top-n.top-(t.top||0)}}const q=()=>({left:window.scrollX,top:window.scrollY});function _e(e){let t;if(`el`in e){let n=e.el,r=typeof n==`string`&&n.startsWith(`#`),i=typeof n==`string`?r?document.getElementById(n.slice(1)):document.querySelector(n):n;if(!i)return;t=ge(i,e)}else t=e;`scrollBehavior`in document.documentElement.style?window.scrollTo(t):window.scrollTo(t.left==null?window.scrollX:t.left,t.top==null?window.scrollY:t.top)}function ve(e,t){return(history.state?history.state.position-t:-1)+e}const ye=new Map;function be(e,t){ye.set(e,t)}function xe(e){let t=ye.get(e);return ye.delete(e),t}let Se=()=>location.protocol+`//`+location.host;function Ce(e,t){let{pathname:n,search:r,hash:i}=t,a=e.indexOf(`#`);if(a>-1){let t=i.includes(e.slice(a))?e.slice(a).length:1,n=i.slice(t);return n[0]!==`/`&&(n=`/`+n),z(n,``)}return z(n,e)+r+i}function we(e,t,n,r){let i=[],a=[],o=null,s=({state:a})=>{let s=Ce(e,location),c=n.value,l=t.value,u=0;if(a){if(n.value=s,t.value=a,o&&o===c){o=null;return}u=l?a.position-l.position:0}else r(s);i.forEach(e=>{e(n.value,c,{delta:u,type:`pop`,direction:u?u>0?`forward`:`back`:``})})};function c(){o=n.value}function l(e){i.push(e);let t=()=>{let t=i.indexOf(e);t>-1&&i.splice(t,1)};return a.push(t),t}function u(){if(document.visibilityState===`hidden`){let{history:e}=window;if(!e.state)return;e.replaceState(_({},e.state,{scroll:q()}),``)}}function d(){for(let e of a)e();a=[],window.removeEventListener(`popstate`,s),window.removeEventListener(`pagehide`,u),document.removeEventListener(`visibilitychange`,u)}return window.addEventListener(`popstate`,s),window.addEventListener(`pagehide`,u),document.addEventListener(`visibilitychange`,u),{pauseListeners:c,listen:l,destroy:d}}function Te(e,t,n,r=!1,i=!1){return{back:e,current:t,forward:n,replaced:r,position:window.history.length,scroll:i?q():null}}function Ee(e){let{history:t,location:n}=window,r={value:Ce(e,n)},i={value:t.state};i.value||a(r.value,{back:null,current:r.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0);function a(r,a,o){let s=e.indexOf(`#`),c=s>-1?(n.host&&document.querySelector(`base`)?e:e.slice(s))+r:Se()+e+r;try{t[o?`replaceState`:`pushState`](a,``,c),i.value=a}catch(e){console.error(e),n[o?`replace`:`assign`](c)}}function o(e,n){a(e,_({},t.state,Te(i.value.back,e,i.value.forward,!0),n,{position:i.value.position}),!0),r.value=e}function s(e,n){let o=_({},i.value,t.state,{forward:e,scroll:q()});a(o.current,o,!0),a(e,_({},Te(r.value,e,null),{position:o.position+1},n),!1),r.value=e}return{location:r,state:i,push:s,replace:o}}function De(e){e=K(e);let t=Ee(e),n=we(e,t.state,t.location,t.replace);function r(e,t=!0){t||n.pauseListeners(),history.go(e)}let i=_({location:``,base:e,go:r,createHref:he.bind(null,e)},t,n);return Object.defineProperty(i,"location",{enumerable:!0,get:()=>t.location.value}),Object.defineProperty(i,"state",{enumerable:!0,get:()=>t.state.value}),i}function Oe(e){return e=location.host?e||location.pathname+location.search:``,e.includes(`#`)||(e+=`#`),De(e)}function ke(e=``){let t=[],n=[[``,{}]],r=0;e=K(e);function i(e,t={}){r++,r!==n.length&&n.splice(r),n.push([e,t])}function a(e,n,{direction:r,delta:i}){let a={direction:r,delta:i,type:`pop`};for(let r of t)r(e,n,a)}let o={location:``,state:{},base:e,createHref:he.bind(null,e),replace(e,t){n.splice(r--,1),i(e,t)},push(e,t){i(e,t)},listen(e){return t.push(e),()=>{let n=t.indexOf(e);n>-1&&t.splice(n,1)}},destroy(){t=[],n=[[``,{}]],r=0},go(e,t=!0){let i=this.location,o=e<0?`back`:`forward`;r=Math.max(0,Math.min(r+e,n.length-1)),t&&a(this.location,i,{direction:o,delta:e})}};return Object.defineProperty(o,"location",{enumerable:!0,get:()=>n[r][0]}),Object.defineProperty(o,"state",{enumerable:!0,get:()=>n[r][1]}),o}function Ae(e){return typeof e==`string`||e&&typeof e==`object`}function je(e){return typeof e==`string`||typeof e==`symbol`}const Me={type:0,value:``},Ne=/[a-zA-Z0-9_]/;function Pe(e){if(!e)return[[]];if(e===`/`)return[[Me]];if(!e.startsWith(`/`))throw Error(`Invalid path "${e}"`);function t(e){throw Error(`ERR (${n})/"${l}": ${e}`)}let n=0,r=n,i=[],a;function o(){a&&i.push(a),a=[]}let s=0,c,l=``,u=``;function d(){l&&(n===0?a.push({type:0,value:l}):n===1||n===2||n===3?(a.length>1&&(c===`*`||c===`+`)&&t(`A repeatable param (${l}) must be alone in its segment. eg: '/:ids+.`),a.push({type:1,value:l,regexp:u,repeatable:c===`*`||c===`+`,optional:c===`*`||c===`?`})):t(`Invalid state to consume buffer`),l=``)}function f(){l+=c}for(;s<e.length;)switch(c=e[s++],n){case 0:c===`\\`?(r=n,n=4):c===`/`?(l&&d(),o()):c===`:`?(d(),n=1):f();break;case 4:f(),n=r;break;case 1:c===`(`?n=2:Ne.test(c)?f():(d(),n=0,c!==`*`&&c!==`?`&&c!==`+`&&s--);break;case 2:c===`)`?u[u.length-1]==`\\`?u=u.slice(0,-1)+c:n=3:u+=c;break;case 3:d(),n=0,c!==`*`&&c!==`?`&&c!==`+`&&s--,u=``;break;default:t(`Unknown state`);break}return n===2&&t(`Unfinished custom RegExp for param "${l}"`),d(),o(),i}const Fe=`[^/]+?`,Ie={sensitive:!1,strict:!1,start:!0,end:!0},Le=/[.+*?^${}()[\]/\\]/g;function Re(e,t){let n=_({},Ie,t),r=[],i=n.start?`^`:``,a=[];for(let t of e){let e=t.length?[]:[90];n.strict&&!t.length&&(i+=`/`);for(let r=0;r<t.length;r++){let o=t[r],s=40+(n.sensitive?.25:0);if(o.type===0)r||(i+=`/`),i+=o.value.replace(Le,`\\$&`),s+=40;else if(o.type===1){let{value:e,repeatable:n,optional:c,regexp:l}=o;a.push({name:e,repeatable:n,optional:c});let u=l||Fe;if(u!==Fe){s+=10;try{RegExp(`(${u})`)}catch(t){throw Error(`Invalid custom RegExp for param "${e}" (${u}): `+t.message)}}let d=n?`((?:${u})(?:/(?:${u}))*)`:`(${u})`;r||(d=c&&t.length<2?`(?:/${d})`:`/`+d),c&&(d+=`?`),i+=d,s+=20,c&&(s+=-8),n&&(s+=-20),u===`.*`&&(s+=-50)}e.push(s)}r.push(e)}if(n.strict&&n.end){let e=r.length-1;r[e][r[e].length-1]+=.7000000000000001}n.strict||(i+=`/?`),n.end?i+=`$`:n.strict&&!i.endsWith(`/`)&&(i+=`(?:/|$)`);let o=new RegExp(i,n.sensitive?``:`i`);function s(e){let t=e.match(o),n={};if(!t)return null;for(let e=1;e<t.length;e++){let r=t[e]||``,i=a[e-1];n[i.name]=r&&i.repeatable?r.split(`/`):r}return n}function c(t){let n=``,r=!1;for(let i of e){(!r||!n.endsWith(`/`))&&(n+=`/`),r=!1;for(let e of i)if(e.type===0)n+=e.value;else if(e.type===1){let{value:a,repeatable:o,optional:s}=e,c=a in t?t[a]:``;if(y(c)&&!o)throw Error(`Provided param "${a}" is an array but it is not repeatable (* or + modifiers)`);let l=y(c)?c.join(`/`):c;if(!l)if(s)i.length<2&&(n.endsWith(`/`)?n=n.slice(0,-1):r=!0);else throw Error(`Missing required param "${a}"`);n+=l}}return n||`/`}return{re:o,score:r,keys:a,parse:s,stringify:c}}function ze(e,t){let n=0;for(;n<e.length&&n<t.length;){let r=t[n]-e[n];if(r)return r;n++}return e.length<t.length?e.length===1&&e[0]===80?-1:1:e.length>t.length?t.length===1&&t[0]===80?1:-1:0}function Be(e,t){let n=0,r=e.score,i=t.score;for(;n<r.length&&n<i.length;){let e=ze(r[n],i[n]);if(e)return e;n++}if(Math.abs(i.length-r.length)===1){if(Ve(r))return 1;if(Ve(i))return-1}return i.length-r.length}function Ve(e){let t=e[e.length-1];return e.length>0&&t[t.length-1]<0}const He={strict:!1,end:!0,sensitive:!1};function Ue(e,t,n){let r=_(Re(Pe(e.path),n),{record:e,parent:t,children:[],alias:[]});return t&&!r.record.aliasOf==!t.record.aliasOf&&t.children.push(r),r}function We(e,t){let n=[],r=new Map;t=b(He,t);function i(e){return r.get(e)}function a(e,n,r){let i=!r,s=Ke(e);s.aliasOf=r&&r.record;let l=b(t,e),u=[s];if(`alias`in e){let t=typeof e.alias==`string`?[e.alias]:e.alias;for(let e of t)u.push(Ke(_({},s,{components:r?r.record.components:s.components,path:e,aliasOf:r?r.record:s})))}let d,f;for(let t of u){let{path:u}=t;if(n&&u[0]!==`/`){let e=n.record.path,r=e[e.length-1]===`/`?``:`/`;t.path=n.record.path+(u&&r+u)}if(d=Ue(t,n,l),r?r.alias.push(d):(f=f||d,f!==d&&f.alias.push(d),i&&e.name&&!Je(d)&&o(e.name)),Qe(d)&&c(d),s.children){let e=s.children;for(let t=0;t<e.length;t++)a(e[t],d,r&&r.children[t])}r=r||d}return f?()=>{o(f)}:v}function o(e){if(je(e)){let t=r.get(e);t&&(r.delete(e),n.splice(n.indexOf(t),1),t.children.forEach(o),t.alias.forEach(o))}else{let t=n.indexOf(e);t>-1&&(n.splice(t,1),e.record.name&&r.delete(e.record.name),e.children.forEach(o),e.alias.forEach(o))}}function s(){return n}function c(e){let t=Xe(e,n);n.splice(t,0,e),e.record.name&&!Je(e)&&r.set(e.record.name,e)}function l(e,t){let i,a={},o,s;if(`name`in e&&e.name){if(i=r.get(e.name),!i)throw x(1,{location:e});s=i.record.name,a=_(Ge(t.params,i.keys.filter(e=>!e.optional).concat(i.parent?i.parent.keys.filter(e=>e.optional):[]).map(e=>e.name)),e.params&&Ge(e.params,i.keys.map(e=>e.name))),o=i.stringify(a)}else if(e.path!=null)o=e.path,i=n.find(e=>e.re.test(o)),i&&(a=i.parse(o),s=i.record.name,i.keys.forEach(e=>{e.optional&&!a[e.name]&&delete a[e.name]}));else{if(i=t.name?r.get(t.name):n.find(e=>e.re.test(t.path)),!i)throw x(1,{location:e,currentLocation:t});s=i.record.name,a=_({},t.params,e.params),o=i.stringify(a)}let c=[],l=i;for(;l;)c.unshift(l.record),l=l.parent;return{name:s,path:o,params:a,matched:c,meta:Ye(c)}}e.forEach(e=>a(e));function u(){n.length=0,r.clear()}return{addRoute:a,resolve:l,removeRoute:o,clearRoutes:u,getRoutes:s,getRecordMatcher:i}}function Ge(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function Ke(e){let t={path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:e.aliasOf,beforeEnter:e.beforeEnter,props:qe(e),children:e.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:`components`in e?e.components||null:e.component&&{default:e.component}};return Object.defineProperty(t,"mods",{value:{}}),t}function qe(e){let t={},n=e.props||!1;if(`component`in e)t.default=n;else for(let r in e.components)t[r]=typeof n==`object`?n[r]:n;return t}function Je(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function Ye(e){return e.reduce((e,t)=>_(e,t.meta),{})}function Xe(e,t){let n=0,r=t.length;for(;n!==r;){let i=n+r>>1;Be(e,t[i])<0?r=i:n=i+1}let i=Ze(e);return i&&(r=t.lastIndexOf(i,r-1)),r}function Ze(e){let t=e;for(;t=t.parent;)if(Qe(t)&&Be(e,t)===0)return t}function Qe({record:e}){return!!(e.name||e.components&&Object.keys(e.components).length||e.redirect)}function $e(e){let t={};if(e===``||e===`?`)return t;let n=(e[0]===`?`?e.slice(1):e).split(`&`);for(let e=0;e<n.length;++e){let r=n[e].replace(ie,` `),i=r.indexOf(`=`),a=L(i<0?r:r.slice(0,i)),o=i<0?null:L(r.slice(i+1));if(a in t){let e=t[a];y(e)||(e=t[a]=[e]),e.push(o)}else t[a]=o}return t}function et(e){let t=``;for(let n in e){let r=e[n];if(n=ce(n),r==null){r!==void 0&&(t+=(t.length?`&`:``)+n);continue}(y(r)?r.map(e=>e&&F(e)):[r&&F(r)]).forEach(e=>{e!==void 0&&(t+=(t.length?`&`:``)+n,e!=null&&(t+=`=`+e))})}return t}function tt(e){let t={};for(let n in e){let r=e[n];r!==void 0&&(t[n]=y(r)?r.map(e=>e==null?null:``+e):r==null?r:``+r)}return t}const J=Symbol(``),nt=Symbol(``),Y=Symbol(``),X=Symbol(``),Z=Symbol(``);function Q(){let e=[];function t(t){return e.push(t),()=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)}}function n(){e=[]}return{add:t,list:()=>e.slice(),reset:n}}function rt(e,t,n){let r=e.value;if(!r)return;let i=r,c=()=>{i[t].delete(n)};s(c),o(c),a(()=>{let r=e.value;r&&(i=r),i[t].add(n)}),i[t].add(n)}function it(e){rt(r(J,{}),`leaveGuards`,e)}function at(e){rt(r(J,{}),`updateGuards`,e)}function $(e,t,n,r,i,a=e=>e()){let o=r&&(r.enterCallbacks[i]=r.enterCallbacks[i]||[]);return()=>new Promise((s,c)=>{let l=e=>{e===!1?c(x(4,{from:n,to:t})):e instanceof Error?c(e):Ae(e)?c(x(2,{from:t,to:e})):(o&&r.enterCallbacks[i]===o&&typeof e==`function`&&o.push(e),s())},u=a(()=>e.call(r&&r.instances[i],t,n,l)),d=Promise.resolve(u);e.length<3&&(d=d.then(l)),d.catch(e=>c(e))})}function ot(e,t,n,r,i=e=>e()){let a=[];for(let o of e)for(let e in o.components){let s=o.components[e];if(!(t!==`beforeRouteEnter`&&!o.instances[e]))if(h(s)){let c=(s.__vccOpts||s)[t];c&&a.push($(c,n,r,o,e,i))}else{let c=s();a.push(()=>c.then(a=>{if(!a)throw Error(`Couldn't resolve component "${e}" at "${o.path}"`);let s=g(a)?a.default:a;o.mods[e]=a,o.components[e]=s;let c=(s.__vccOpts||s)[t];return c&&$(c,n,r,o,e,i)()}))}}return a}function st(e){return e.matched.every(e=>e.redirect)?Promise.reject(Error(`Cannot load a route that redirects.`)):Promise.all(e.matched.map(e=>e.components&&Promise.all(Object.keys(e.components).reduce((t,n)=>{let r=e.components[n];return typeof r==`function`&&!(`displayName`in r)&&t.push(r().then(t=>{if(!t)return Promise.reject(Error(`Couldn't resolve component "${n}" at "${e.path}". Ensure you passed a function that returns a promise.`));let r=g(t)?t.default:t;e.mods[n]=t,e.components[n]=r})),t},[])))).then(()=>e)}function ct(e,t){let n=[],r=[],i=[],a=Math.max(t.matched.length,e.matched.length);for(let o=0;o<a;o++){let a=t.matched[o];a&&(e.matched.find(e=>B(e,a))?r.push(a):n.push(a));let s=e.matched[o];s&&(t.matched.find(e=>B(e,s))||i.push(s))}return[n,r,i]}function lt(t){let n=r(Y),i=r(X),a=e(()=>{let e=p(t.to);return n.resolve(e)}),o=e(()=>{let{matched:e}=a.value,{length:t}=e,n=e[t-1],r=i.matched;if(!n||!r.length)return-1;let o=r.findIndex(B.bind(null,n));if(o>-1)return o;let s=mt(e[t-2]);return t>1&&mt(n)===s&&r[r.length-1].path!==s?r.findIndex(B.bind(null,e[t-2])):o}),s=e(()=>o.value>-1&&pt(i.params,a.value.params)),c=e(()=>o.value>-1&&o.value===i.matched.length-1&&V(i.params,a.value.params));function l(e={}){if(ft(e)){let e=n[p(t.replace)?`replace`:`push`](p(t.to)).catch(v);return t.viewTransition&&typeof document<`u`&&`startViewTransition`in document&&document.startViewTransition(()=>e),e}return Promise.resolve()}return{route:a,href:e(()=>a.value.href),isActive:s,isExactActive:c,navigate:l}}function ut(e){return e.length===1?e[0]:e}const dt=t({name:`RouterLink`,compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:`page`},viewTransition:Boolean},useLink:lt,setup(t,{slots:i}){let a=l(lt(t)),{options:o}=r(Y),s=e(()=>({[ht(t.activeClass,o.linkActiveClass,`router-link-active`)]:a.isActive,[ht(t.exactActiveClass,o.linkExactActiveClass,`router-link-exact-active`)]:a.isExactActive}));return()=>{let e=i.default&&ut(i.default(a));return t.custom?e:n(`a`,{"aria-current":a.isExactActive?t.ariaCurrentValue:null,href:a.href,onClick:a.navigate,class:s.value},e)}}});function ft(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)&&!e.defaultPrevented&&!(e.button!==void 0&&e.button!==0)){if(e.currentTarget&&e.currentTarget.getAttribute){let t=e.currentTarget.getAttribute(`target`);if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function pt(e,t){for(let n in t){let r=t[n],i=e[n];if(typeof r==`string`){if(r!==i)return!1}else if(!y(i)||i.length!==r.length||r.some((e,t)=>e.valueOf()!==i[t].valueOf()))return!1}return!0}function mt(e){return e?e.aliasOf?e.aliasOf.path:e.path:``}const ht=(e,t,n)=>e==null?t==null?n:t:e,gt=t({name:`RouterView`,inheritAttrs:!1,props:{name:{type:String,default:`default`},route:Object},compatConfig:{MODE:3},setup(t,{attrs:i,slots:a}){let o=r(Z),s=e(()=>t.route||o.value),l=r(nt,0),d=e(()=>{let e=p(l),{matched:t}=s.value,n;for(;(n=t[e])&&!n.components;)e++;return e}),f=e(()=>s.value.matched[d.value]);c(nt,e(()=>d.value+1)),c(J,f),c(Z,s);let m=u();return ee(()=>[m.value,f.value,t.name],([e,t,n],[r,i,a])=>{t&&(t.instances[n]=e,i&&i!==t&&e&&e===r&&(t.leaveGuards.size||(t.leaveGuards=i.leaveGuards),t.updateGuards.size||(t.updateGuards=i.updateGuards))),e&&t&&(!i||!B(t,i)||!r)&&(t.enterCallbacks[n]||[]).forEach(t=>t(e))},{flush:`post`}),()=>{let e=s.value,r=t.name,o=f.value,c=o&&o.components[r];if(!c)return _t(a.default,{Component:c,route:e});let l=o.props[r],u=l?l===!0?e.params:typeof l==`function`?l(e):l:null,d=n(c,_({},u,i,{onVnodeUnmounted:e=>{e.component.isUnmounted&&(o.instances[r]=null)},ref:m}));return _t(a.default,{Component:d,route:e})||d}}});function _t(e,t){if(!e)return null;let n=e(t);return n.length===1?n[0]:n}const vt=gt;function yt(e){let t=We(e.routes,e),n=e.parseQuery||$e,r=e.stringifyQuery||et,a=e.history,o=Q(),s=Q(),c=Q(),l=f(G),u=G;m&&e.scrollBehavior&&`scrollRestoration`in history&&(history.scrollRestoration=`manual`);let ee=te.bind(null,e=>``+e),h=te.bind(null,le),g=te.bind(null,L);function b(e,n){let r,i;return je(e)?(r=t.getRecordMatcher(e),i=n):i=e,t.addRoute(i,r)}function ne(e){let n=t.getRecordMatcher(e);n&&t.removeRoute(n)}function re(){return t.getRoutes().map(e=>e.record)}function C(e){return!!t.getRecordMatcher(e)}function w(e,i){if(i=_({},i||l.value),typeof e==`string`){let r=de(n,e,i.path),o=t.resolve({path:r.path},i),s=a.createHref(r.fullPath);return _(r,o,{params:g(o.params),redirectedFrom:void 0,href:s})}let o;if(e.path!=null)o=_({},e,{path:de(n,e.path,i.path).path});else{let t=_({},e.params);for(let e in t)t[e]==null&&delete t[e];o=_({},e,{params:h(t)}),i.params=h(i.params)}let s=t.resolve(o,i),c=e.hash||``;s.params=ee(g(s.params));let u=fe(r,_({},e,{hash:se(c),path:s.path})),d=a.createHref(u);return _({fullPath:u,hash:c,query:r===et?tt(e.query):e.query||{}},s,{redirectedFrom:void 0,href:d})}function T(e){return typeof e==`string`?de(n,e,l.value.path):_({},e)}function E(e,t){if(u!==e)return x(8,{from:t,to:e})}function D(e){return O(e)}function ie(e){return D(_(T(e),{replace:!0}))}function ae(e,t){let n=e.matched[e.matched.length-1];if(n&&n.redirect){let{redirect:r}=n,i=typeof r==`function`?r(e,t):r;return typeof i==`string`&&(i=i.includes(`?`)||i.includes(`#`)?i=T(i):{path:i},i.params={}),_({query:e.query,hash:e.hash,params:i.path==null?e.params:{}},i)}}function O(e,t){let n=u=w(e),i=l.value,a=e.state,o=e.force,s=e.replace===!0,c=ae(n,i);if(c)return O(_(T(c),{state:typeof c==`object`?_({},a,c.state):a,force:o,replace:s}),t||n);let d=n;d.redirectedFrom=t;let f;return!o&&pe(r,i,n)&&(f=x(16,{to:d,from:i}),B(i,i,!0,!1)),(f?Promise.resolve(f):A(d,i)).catch(e=>S(e)?S(e,2)?e:z(e):R(e,d,i)).then(e=>{if(e){if(S(e,2))return O(_({replace:s},T(e.to),{state:typeof e.to==`object`?_({},a,e.to.state):a,force:o}),t||d)}else e=M(d,i,!0,s,a);return j(d,i,e),e})}function oe(e,t){let n=E(e,t);return n?Promise.reject(n):Promise.resolve()}function k(e){let t=U.values().next().value;return t&&typeof t.runWithContext==`function`?t.runWithContext(e):e()}function A(e,t){let n,[r,i,a]=ct(e,t);n=ot(r.reverse(),`beforeRouteLeave`,e,t);for(let i of r)i.leaveGuards.forEach(r=>{n.push($(r,e,t))});let c=oe.bind(null,e,t);return n.push(c),K(n).then(()=>{n=[];for(let r of o.list())n.push($(r,e,t));return n.push(c),K(n)}).then(()=>{n=ot(i,`beforeRouteUpdate`,e,t);for(let r of i)r.updateGuards.forEach(r=>{n.push($(r,e,t))});return n.push(c),K(n)}).then(()=>{n=[];for(let r of a)if(r.beforeEnter)if(y(r.beforeEnter))for(let i of r.beforeEnter)n.push($(i,e,t));else n.push($(r.beforeEnter,e,t));return n.push(c),K(n)}).then(()=>(e.matched.forEach(e=>e.enterCallbacks={}),n=ot(a,`beforeRouteEnter`,e,t,k),n.push(c),K(n))).then(()=>{n=[];for(let r of s.list())n.push($(r,e,t));return n.push(c),K(n)}).catch(e=>S(e,8)?e:Promise.reject(e))}function j(e,t,n){c.list().forEach(r=>k(()=>r(e,t,n)))}function M(e,t,n,r,i){let o=E(e,t);if(o)return o;let s=t===G,c=m?history.state:{};n&&(r||s?a.replace(e.fullPath,_({scroll:s&&c&&c.scroll},i)):a.push(e.fullPath,i)),l.value=e,B(e,t,n,s),z()}let N;function P(){N||(N=a.listen((e,t,n)=>{if(!W.listening)return;let r=w(e),i=ae(r,W.currentRoute.value);if(i){O(_(i,{replace:!0,force:!0}),r).catch(v);return}u=r;let o=l.value;m&&be(ve(o.fullPath,n.delta),q()),A(r,o).catch(e=>S(e,12)?e:S(e,2)?(O(_(T(e.to),{force:!0}),r).then(e=>{S(e,20)&&!n.delta&&n.type===`pop`&&a.go(-1,!1)}).catch(v),Promise.reject()):(n.delta&&a.go(-n.delta,!1),R(e,r,o))).then(e=>{e=e||M(r,o,!1),e&&(n.delta&&!S(e,8)?a.go(-n.delta,!1):n.type===`pop`&&S(e,20)&&a.go(-1,!1)),j(r,o,e)}).catch(v)}))}let F=Q(),ce=Q(),I;function R(e,t,n){z(e);let r=ce.list();return r.length?r.forEach(r=>r(e,t,n)):console.error(e),Promise.reject(e)}function ue(){return I&&l.value!==G?Promise.resolve():new Promise((e,t)=>{F.add([e,t])})}function z(e){return I||(I=!e,P(),F.list().forEach(([t,n])=>e?n(e):t()),F.reset()),e}function B(t,n,r,a){let{scrollBehavior:o}=e;if(!m||!o)return Promise.resolve();let s=!r&&xe(ve(t.fullPath,0))||(a||!r)&&history.state&&history.state.scroll||null;return i().then(()=>o(t,n,s)).then(e=>t===l.value&&e&&_e(e)).catch(e=>t===l.value&&R(e,t,n))}let V=e=>a.go(e),H,U=new Set,W={currentRoute:l,listening:!0,addRoute:b,removeRoute:ne,clearRoutes:t.clearRoutes,hasRoute:C,getRoutes:re,resolve:w,options:e,push:D,replace:ie,go:V,back:()=>V(-1),forward:()=>V(1),beforeEach:o.add,beforeResolve:s.add,afterEach:c.add,onError:ce.add,isReady:ue,install(e){e.component(`RouterLink`,dt),e.component(`RouterView`,vt),e.config.globalProperties.$router=W,Object.defineProperty(e.config.globalProperties,"$route",{enumerable:!0,get:()=>p(l)}),m&&!H&&l.value===G&&(H=!0,D(a.location).catch(e=>{}));let t={};for(let e in G)Object.defineProperty(t,e,{get:()=>l.value[e],enumerable:!0});e.provide(Y,W),e.provide(X,d(t)),e.provide(Z,l);let n=e.unmount;U.add(e),e.unmount=function(){U.delete(e),U.size<1&&(u=G,N&&N(),N=null,l.value=G,H=!1,I=!1),n()}}};function K(e){return e.reduce((e,t)=>e.then(()=>k(t)),Promise.resolve())}return W}function bt(){return r(Y)}function xt(e){return r(X)}export{re as NavigationFailureType,dt as RouterLink,vt as RouterView,G as START_LOCATION,ke as createMemoryHistory,yt as createRouter,We as createRouterMatcher,Oe as createWebHashHistory,De as createWebHistory,S as isNavigationFailure,st as loadRouteLocation,J as matchedRouteKey,it as onBeforeRouteLeave,at as onBeforeRouteUpdate,$e as parseQuery,X as routeLocationKey,Y as routerKey,Z as routerViewLocationKey,et as stringifyQuery,lt as useLink,xt as useRoute,bt as useRouter,nt as viewDepthKey};