@kitbag/router 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/dist/kitbag-router.d.ts +146 -74
- package/dist/kitbag-router.js +916 -840
- package/dist/kitbag-router.umd.cjs +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(y,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],i):(y=typeof globalThis<"u"?globalThis:y||self,i(y["@kitbag/router"]={},y.Vue))})(this,function(y,i){"use strict";var Tn=Object.defineProperty;var In=(y,i,D)=>i in y?Tn(y,i,{enumerable:!0,configurable:!0,writable:!0,value:D}):y[i]=D;var V=(y,i,D)=>(In(y,typeof i!="symbol"?i+"":i,D),D);class D extends Error{constructor(e){super(`Invalid Param "${e}": Router does not support multiple params by the same name. All param names must be unique.`)}}class ot extends Error{constructor(){super("Router not installed")}}class Ht extends Error{constructor(e,n){super(`useRoute called with incorrect route. Given ${e}, expected ${n}`)}}const dt=Symbol();function at(){const t=i.inject(dt);if(!t)throw new ot;return t}class Y extends Error{}function J(t){return typeof t!="string"?!1:/^(https?:\/\/|\/).*/g.test(t)}function Ct(t,e={},n={}){const r=at(),o=i.computed(()=>i.toValue(t)),s=i.computed(()=>i.toValue(e)),a=i.computed(()=>i.toValue(n)),c=i.computed(()=>{if(J(o.value))return o.value;try{return r.resolve(o.value,s.value,a.value)}catch(R){throw R instanceof Y&&console.error(`Failed to resolve route "${o.value.toString()}" in RouterLink.`,R),R}}),u=i.computed(()=>r.find(c.value,a.value)),l=i.computed(()=>!!u.value&&r.route.matches.includes(u.value.matched)),p=i.computed(()=>!!u.value&&r.route.matched===u.value.matched);return{route:u,href:c,isMatch:l,isExactMatch:p,push:R=>r.push(c.value,{},{...a.value,...R}),replace:R=>r.replace(c.value,{},{...a.value,...R})}}const mt=Symbol();function Vt(){const t=i.inject(mt);if(!t)throw new ot;return t}function qt(t,e){return[t,e].filter(n=>!!n).join(".")}const _t=Symbol("isRouterRouteSymbol");function ke(t){return typeof t=="object"&&t!==null&&_t in t}function Ae(t,e){function n(l,p,R){if(typeof l=="object"){const g={...t.params,...l};return e(t.key,g,p)}const S={...t.params,[l]:p};return e(t.key,S,R)}const{matched:r,matches:o,key:s,query:a,params:c}=i.toRefs(t),u=i.reactive({matched:r,matches:o,query:a,params:c,key:s,update:n,[_t]:!0});return new Proxy(u,{get:(l,p,R)=>p==="params"?new Proxy(t.params,{set(S,g,x){return n(g,x),!0}}):Reflect.get(l,p,R)})}function Ot(t,e,{exact:n}={}){if(!ke(t))return!1;if(e===void 0)return!0;const r=xe(t);if(n){const o=r.at(-1);return e===o}return r.includes(e)}function xe(t){return t.matches.map(n=>n.name).reduce((n,r)=>{const o=n.pop(),s=r?[qt(o,r)]:[];return o?[...n,o,...s]:s},[])}function Wt(t,e){const n=at();function r(){if(!t)return;if(!Ot(n.route,t,e))throw new Ht(t,n.route.key)}return i.watch(n.route,r,{immediate:!0,deep:!0}),n.route}const Dt=Symbol();function Rt(){return i.inject(Dt,0)}class st{constructor(){V(this,"onBeforeRouteEnter",new Set);V(this,"onBeforeRouteUpdate",new Set);V(this,"onBeforeRouteLeave",new Set);V(this,"onAfterRouteEnter",new Set);V(this,"onAfterRouteUpdate",new Set);V(this,"onAfterRouteLeave",new Set)}}class Mt extends Error{}class et extends Error{constructor(n){super("Error occurred during a router push operation.");V(this,"to");this.to=n}}class gt extends Error{constructor(n){super(`Routing action rejected: ${n}`);V(this,"type");this.type=n}}function X(t){return Array.isArray(t)?t:[t]}function Le(t,e){const n=new st;return t.matches.forEach((r,o)=>{r.onBeforeRouteEnter&&yt(t,e,o)&&X(r.onBeforeRouteEnter).forEach(s=>n.onBeforeRouteEnter.add(s)),r.onBeforeRouteUpdate&&vt(t,e,o)&&X(r.onBeforeRouteUpdate).forEach(s=>n.onBeforeRouteUpdate.add(s))}),e.matches.forEach((r,o)=>{r.onBeforeRouteLeave&&wt(t,e,o)&&X(r.onBeforeRouteLeave).forEach(s=>n.onBeforeRouteLeave.add(s))}),n}function Be(t,e){const n=new st;return t.matches.forEach((r,o)=>{r.onAfterRouteEnter&&yt(t,e,o)&&X(r.onAfterRouteEnter).forEach(s=>n.onAfterRouteEnter.add(s)),r.onAfterRouteUpdate&&vt(t,e,o)&&X(r.onAfterRouteUpdate).forEach(s=>n.onAfterRouteUpdate.add(s))}),e.matches.forEach((r,o)=>{r.onAfterRouteLeave&&wt(t,e,o)&&X(r.onAfterRouteLeave).forEach(s=>n.onAfterRouteLeave.add(s))}),n}function Ue(){const t=a=>{throw new gt(a)},e=(...a)=>{throw new et(a)},n=(a,c,u)=>{if(J(a)){const R=c??{};throw new et([a,{...R,replace:!0}])}const l=c,p=u??{};throw new et([a,l,{...p,replace:!0}])},r=()=>{throw new Mt};async function o({to:a,from:c,hooks:u}){const{global:l,component:p}=u,R=Le(a,c),S=[...l.onBeforeRouteEnter,...R.onBeforeRouteEnter,...l.onBeforeRouteUpdate,...R.onBeforeRouteUpdate,...p.onBeforeRouteUpdate,...l.onBeforeRouteLeave,...R.onBeforeRouteLeave,...p.onBeforeRouteLeave];try{const g=S.map(x=>x(a,{from:c,reject:t,push:e,replace:n,abort:r}));await Promise.all(g)}catch(g){if(g instanceof et)return{status:"PUSH",to:g.to};if(g instanceof gt)return{status:"REJECT",type:g.type};if(g instanceof Mt)return{status:"ABORT"};throw g}return{status:"SUCCESS"}}async function s({to:a,from:c,hooks:u}){const{global:l,component:p}=u,R=Be(a,c),S=[...p.onAfterRouteLeave,...R.onAfterRouteLeave,...l.onAfterRouteLeave,...p.onAfterRouteUpdate,...R.onAfterRouteUpdate,...l.onAfterRouteUpdate,...p.onAfterRouteEnter,...R.onAfterRouteEnter,...l.onAfterRouteEnter];try{const g=S.map(x=>x(a,{from:c,reject:t,push:e,replace:n}));await Promise.all(g)}catch(g){if(g instanceof et)return{status:"PUSH",to:g.to};if(g instanceof gt)return{status:"REJECT",type:g.type};throw g}return{status:"SUCCESS"}}return{runBeforeRouteHooks:o,runAfterRouteHooks:s}}const yt=(t,e,n)=>{const r=t.matches,o=(e==null?void 0:e.matches)??[];return r.length<n||r[n]!==o[n]},wt=(t,e,n)=>{const r=t.matches,o=(e==null?void 0:e.matches)??[];return r.length<n||r[n]!==o[n]},vt=(t,e,n)=>t.matches[n]===(e==null?void 0:e.matches[n]);function Tt(t){switch(t){case"onBeforeRouteEnter":case"onAfterRouteEnter":return yt;case"onBeforeRouteUpdate":case"onAfterRouteUpdate":return vt;case"onBeforeRouteLeave":case"onAfterRouteLeave":return wt;default:throw new Error(`Switch is not exhaustive for lifecycle: ${t}`)}}class $e{constructor(){V(this,"global",new st);V(this,"component",new st)}addBeforeRouteHook({lifecycle:e,timing:n,depth:r,hook:o}){const s=Tt(e),a=this[n][e],c=(u,l)=>{if(s(u,l.from,r))return o(u,l)};return a.add(c),()=>a.delete(c)}addAfterRouteHook({lifecycle:e,timing:n,depth:r,hook:o}){const s=Tt(e),a=this[n][e],c=(u,l)=>{if(s(u,l.from,r))return o(u,l)};return a.add(c),()=>a.delete(c)}}const It=Symbol();function Ne(){const t=new $e;return{onBeforeRouteEnter:c=>t.addBeforeRouteHook({lifecycle:"onBeforeRouteEnter",hook:c,timing:"global",depth:0}),onBeforeRouteUpdate:c=>t.addBeforeRouteHook({lifecycle:"onBeforeRouteUpdate",hook:c,timing:"global",depth:0}),onBeforeRouteLeave:c=>t.addBeforeRouteHook({lifecycle:"onBeforeRouteLeave",hook:c,timing:"global",depth:0}),onAfterRouteEnter:c=>t.addAfterRouteHook({lifecycle:"onAfterRouteEnter",hook:c,timing:"global",depth:0}),onAfterRouteUpdate:c=>t.addAfterRouteHook({lifecycle:"onAfterRouteUpdate",hook:c,timing:"global",depth:0}),onAfterRouteLeave:c=>t.addAfterRouteHook({lifecycle:"onAfterRouteLeave",hook:c,timing:"global",depth:0}),hooks:t}}function Jt(){const t=i.inject(It);if(!t)throw new ot;return t}function Ft(t){return e=>{const n=Rt(),o=Jt().addBeforeRouteHook({lifecycle:t,hook:e,depth:n,timing:"component"});return i.onUnmounted(o),o}}function Et(t){return e=>{const n=Rt(),o=Jt().addAfterRouteHook({lifecycle:t,hook:e,depth:n,timing:"component"});return i.onUnmounted(o),o}}const je=Ft("onBeforeRouteUpdate"),He=Ft("onBeforeRouteLeave"),Ce=Et("onAfterRouteEnter"),Ve=Et("onAfterRouteUpdate"),qe=Et("onAfterRouteLeave"),_e=["href"],Kt=i.defineComponent({__name:"routerLink",props:{to:{type:[String,Function]},query:{},replace:{type:Boolean}},setup(t){const e=t,n=at(),r=i.computed(()=>J(e.to)?e.to:e.to(n.resolve)),o=i.computed(()=>{const{to:R,...S}=e;return S}),{href:s,isMatch:a,isExactMatch:c}=Ct(r),u=i.computed(()=>({"router-link--match":a.value,"router-link--exact-match":c.value})),l=i.computed(()=>n.isExternal(r.value));function p(R){R.preventDefault(),n.push(s.value,o.value)}return(R,S)=>(i.openBlock(),i.createElementBlock("a",{href:r.value,class:i.normalizeClass(["router-link",u.value]),onClick:p},[i.renderSlot(R.$slots,"default",i.normalizeProps(i.guardReactiveProps({resolved:r.value,isMatch:i.unref(a),isExactMatch:i.unref(c),isExternal:l.value})))],10,_e))}});function nt(...t){const e=t.flatMap(n=>Array.isArray(n)?n:Object.keys(n).map(We));for(const n of e)if(Oe(e,n)>1)throw new D(n)}function Oe(t,e){return t.filter(n=>e===n).length}function We(t){return t.startsWith("?")?t.slice(1):t}function De(t,e){nt(t.params,e.params);const n=`${t.path}${e.path}`;return{path:n,params:{...t.params,...e.params},toString:()=>n}}function Pt(t){return typeof t=="string"&&t.length>0}function Me(t,e){nt(t.params,e.params);const n=[t.query,e.query].filter(Pt).join("&");return{query:n,params:{...t.params,...e.params},toString:()=>n}}function Qt(t){return"parent"in t}function Gt(t){return"component"in t}function zt(t){return"components"in t}function Te(t){return!Gt(t)&&!zt(t)}function Yt(t,e){return{...e,key:qt(t.key,e.key),path:De(t.path,e.path),query:Me(t.query,e.query),matches:[...t.matches,e.matched],host:t.host,depth:t.depth+1}}const bt=i.defineComponent({__name:"routerView",props:{name:{}},setup(t){const{name:e="default"}=t,n=Wt(),r=Vt(),o=Rt();i.provide(Dt,o+1);const s=i.computed(()=>{if(r.value)return r.value.component;const c=n.matches.at(o);if(!c)return null;const l=a(c)[e];return l?typeof l=="function"?i.defineAsyncComponent(l):l:null});function a(c){return zt(c)?c.components:Gt(c)?{default:c.component}:{}}return(c,u)=>i.renderSlot(c.$slots,"default",i.normalizeProps(i.guardReactiveProps({route:i.unref(n),component:s.value,rejection:i.unref(r)})),()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(s.value)))])}});function Ie(t,e){return i.defineComponent({name:"PropsWrapper",expose:[],setup(){const n=e();return"then"in n?()=>i.h(Je(t,n)):()=>i.h(t,n)}})}function Je(t,e){return i.defineComponent({name:"AsyncPropsWrapper",expose:[],async setup(){const n=await e;return()=>i.h(t,n)}})}const W="[",M="]";function Fe(t){return t!==String&&t!==Boolean&&t!==Number&&t!==Date}function Ke(t){return typeof t=="function"&&Fe(t)}function ct(t){return typeof t=="object"&&"get"in t&&typeof t.get=="function"&&"set"in t&&typeof t.set=="function"}function Xt(t){return ct(t)&&t.defaultValue!==void 0}function Qe(t,e){return re(t,e)}function Ge(t,e){return t[e]??String}const $={invalid:t=>{throw new Y(t)}},ze={get:t=>t,set:(t,{invalid:e})=>{if(typeof t!="string")throw e();return t}},Zt={get:(t,{invalid:e})=>{if(t==="true")return!0;if(t==="false")return!1;throw e()},set:(t,{invalid:e})=>{if(typeof t!="boolean")throw e();return t.toString()}},te={get:(t,{invalid:e})=>{const n=Number(t);if(isNaN(n))throw e();return n},set:(t,{invalid:e})=>{if(typeof t!="number")throw e();return t.toString()}},ee={get:(t,{invalid:e})=>{const n=new Date(t);if(isNaN(n.getTime()))throw e();return n},set:(t,{invalid:e})=>{if(typeof t!="object"||!(t instanceof Date))throw e();return t.toISOString()}},ne={get:(t,{invalid:e})=>{try{return JSON.parse(t)}catch{throw e()}},set:(t,{invalid:e})=>{try{return JSON.stringify(t)}catch{throw e()}}};function St(t,e,n=!1){if(t===void 0||!Pt(t)){if(Xt(e))return e.defaultValue;if(n)return;throw new Y}if(e===String)return ze.get(t,$);if(e===Boolean)return Zt.get(t,$);if(e===Number)return te.get(t,$);if(e===Date)return ee.get(t,$);if(e===JSON)return ne.get(t,$);if(Ke(e))return e(t,$);if(ct(e))return e.get(t,$);if(e instanceof RegExp){if(e.test(t))return t;throw new Y}return t}function kt(t,e,n=!1){if(t===void 0){if(n)return"";throw new Y}if(e===Boolean)return Zt.set(t,$);if(e===Number)return te.set(t,$);if(e===Date)return ee.set(t,$);if(e===JSON)return ne.set(t,$);if(ct(e))return e.set(t,$);try{return t.toString()}catch{throw new Y}}function re(t,e){return ct(t)?{...t,defaultValue:e??t.defaultValue}:{get:n=>St(n,t),set:n=>kt(n,t),defaultValue:e}}function T(){return T=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},T.apply(this,arguments)}var U;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(U||(U={}));var Z=process.env.NODE_ENV!=="production"?function(t){return Object.freeze(t)}:function(t){return t};function F(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}var it="beforeunload",Ye="hashchange",oe="popstate";function ae(t){t===void 0&&(t={});var e=t,n=e.window,r=n===void 0?document.defaultView:n,o=r.history;function s(){var d=r.location,f=d.pathname,h=d.search,v=d.hash,P=o.state||{};return[P.idx,Z({pathname:f,search:h,hash:v,state:P.usr||null,key:P.key||"default"})]}var a=null;function c(){if(a)g.call(a),a=null;else{var d=U.Pop,f=s(),h=f[0],v=f[1];if(g.length)if(h!=null){var P=p-h;P&&(a={action:d,location:v,retry:function(){b(P*-1)}},b(P))}else process.env.NODE_ENV!=="production"&&F(!1,"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation.");else _(d)}}r.addEventListener(oe,c);var u=U.Pop,l=s(),p=l[0],R=l[1],S=tt(),g=tt();p==null&&(p=0,o.replaceState(T({},o.state,{idx:p}),""));function x(d){return typeof d=="string"?d:K(d)}function L(d,f){return f===void 0&&(f=null),Z(T({pathname:R.pathname,hash:"",search:""},typeof d=="string"?rt(d):d,{state:f,key:ft()}))}function q(d,f){return[{usr:d.state,key:d.key,idx:f},x(d)]}function N(d,f,h){return!g.length||(g.call({action:d,location:f,retry:h}),!1)}function _(d){u=d;var f=s();p=f[0],R=f[1],S.call({action:u,location:R})}function m(d,f){var h=U.Push,v=L(d,f);function P(){m(d,f)}if(N(h,v,P)){var A=q(v,p+1),B=A[0],j=A[1];try{o.pushState(B,"",j)}catch{r.location.assign(j)}_(h)}}function w(d,f){var h=U.Replace,v=L(d,f);function P(){w(d,f)}if(N(h,v,P)){var A=q(v,p),B=A[0],j=A[1];o.replaceState(B,"",j),_(h)}}function b(d){o.go(d)}var k={get action(){return u},get location(){return R},createHref:x,push:m,replace:w,go:b,back:function(){b(-1)},forward:function(){b(1)},listen:function(f){return S.push(f)},block:function(f){var h=g.push(f);return g.length===1&&r.addEventListener(it,ut),function(){h(),g.length||r.removeEventListener(it,ut)}}};return k}function Xe(t){t===void 0&&(t={});var e=t,n=e.window,r=n===void 0?document.defaultView:n,o=r.history;function s(){var f=rt(r.location.hash.substr(1)),h=f.pathname,v=h===void 0?"/":h,P=f.search,A=P===void 0?"":P,B=f.hash,j=B===void 0?"":B,H=o.state||{};return[H.idx,Z({pathname:v,search:A,hash:j,state:H.usr||null,key:H.key||"default"})]}var a=null;function c(){if(a)g.call(a),a=null;else{var f=U.Pop,h=s(),v=h[0],P=h[1];if(g.length)if(v!=null){var A=p-v;A&&(a={action:f,location:P,retry:function(){k(A*-1)}},k(A))}else process.env.NODE_ENV!=="production"&&F(!1,"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation.");else m(f)}}r.addEventListener(oe,c),r.addEventListener(Ye,function(){var f=s(),h=f[1];K(h)!==K(R)&&c()});var u=U.Pop,l=s(),p=l[0],R=l[1],S=tt(),g=tt();p==null&&(p=0,o.replaceState(T({},o.state,{idx:p}),""));function x(){var f=document.querySelector("base"),h="";if(f&&f.getAttribute("href")){var v=r.location.href,P=v.indexOf("#");h=P===-1?v:v.slice(0,P)}return h}function L(f){return x()+"#"+(typeof f=="string"?f:K(f))}function q(f,h){return h===void 0&&(h=null),Z(T({pathname:R.pathname,hash:"",search:""},typeof f=="string"?rt(f):f,{state:h,key:ft()}))}function N(f,h){return[{usr:f.state,key:f.key,idx:h},L(f)]}function _(f,h,v){return!g.length||(g.call({action:f,location:h,retry:v}),!1)}function m(f){u=f;var h=s();p=h[0],R=h[1],S.call({action:u,location:R})}function w(f,h){var v=U.Push,P=q(f,h);function A(){w(f,h)}if(process.env.NODE_ENV!=="production"&&F(P.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.push("+JSON.stringify(f)+")"),_(v,P,A)){var B=N(P,p+1),j=B[0],H=B[1];try{o.pushState(j,"",H)}catch{r.location.assign(H)}m(v)}}function b(f,h){var v=U.Replace,P=q(f,h);function A(){b(f,h)}if(process.env.NODE_ENV!=="production"&&F(P.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.replace("+JSON.stringify(f)+")"),_(v,P,A)){var B=N(P,p),j=B[0],H=B[1];o.replaceState(j,"",H),m(v)}}function k(f){o.go(f)}var d={get action(){return u},get location(){return R},createHref:L,push:w,replace:b,go:k,back:function(){k(-1)},forward:function(){k(1)},listen:function(h){return S.push(h)},block:function(h){var v=g.push(h);return g.length===1&&r.addEventListener(it,ut),function(){v(),g.length||r.removeEventListener(it,ut)}}};return d}function se(t){t===void 0&&(t={});var e=t,n=e.initialEntries,r=n===void 0?["/"]:n,o=e.initialIndex,s=r.map(function(m){var w=Z(T({pathname:"/",search:"",hash:"",state:null,key:ft()},typeof m=="string"?rt(m):m));return process.env.NODE_ENV!=="production"&&F(w.pathname.charAt(0)==="/","Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: "+JSON.stringify(m)+")"),w}),a=ce(o??s.length-1,0,s.length-1),c=U.Pop,u=s[a],l=tt(),p=tt();function R(m){return typeof m=="string"?m:K(m)}function S(m,w){return w===void 0&&(w=null),Z(T({pathname:u.pathname,search:"",hash:""},typeof m=="string"?rt(m):m,{state:w,key:ft()}))}function g(m,w,b){return!p.length||(p.call({action:m,location:w,retry:b}),!1)}function x(m,w){c=m,u=w,l.call({action:c,location:u})}function L(m,w){var b=U.Push,k=S(m,w);function d(){L(m,w)}process.env.NODE_ENV!=="production"&&F(u.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.push("+JSON.stringify(m)+")"),g(b,k,d)&&(a+=1,s.splice(a,s.length,k),x(b,k))}function q(m,w){var b=U.Replace,k=S(m,w);function d(){q(m,w)}process.env.NODE_ENV!=="production"&&F(u.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.replace("+JSON.stringify(m)+")"),g(b,k,d)&&(s[a]=k,x(b,k))}function N(m){var w=ce(a+m,0,s.length-1),b=U.Pop,k=s[w];function d(){N(m)}g(b,k,d)&&(a=w,x(b,k))}var _={get index(){return a},get action(){return c},get location(){return u},createHref:R,push:L,replace:q,go:N,back:function(){N(-1)},forward:function(){N(1)},listen:function(w){return l.push(w)},block:function(w){return p.push(w)}};return _}function ce(t,e,n){return Math.min(Math.max(t,e),n)}function ut(t){t.preventDefault(),t.returnValue=""}function tt(){var t=[];return{get length(){return t.length},push:function(n){return t.push(n),function(){t=t.filter(function(r){return r!==n})}},call:function(n){t.forEach(function(r){return r&&r(n)})}}}function ft(){return Math.random().toString(36).substr(2,8)}function K(t){var e=t.pathname,n=e===void 0?"/":e,r=t.search,o=r===void 0?"":r,s=t.hash,a=s===void 0?"":s;return o&&o!=="?"&&(n+=o.charAt(0)==="?"?o:"?"+o),a&&a!=="#"&&(n+=a.charAt(0)==="#"?a:"#"+a),n}function rt(t){var e={};if(t){var n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));var r=t.indexOf("?");r>=0&&(e.search=t.substr(r),t=t.substr(0,r)),t&&(e.pathname=t)}return e}function Ze(t,e){const n=i.reactive({...t}),r=a=>{Object.assign(n,{...a})},o=n,s=Ae(o,e);return{currentRoute:o,routerRoute:s,updateRoute:r}}function Q(t){return!t.startsWith("http")?en(t):tn(t)}function tn(t){const{protocol:e,host:n,pathname:r,search:o,searchParams:s,hash:a}=new URL(t,t);return{protocol:e,host:n,pathname:r,search:o,searchParams:s,hash:a}}function en(t){const{pathname:e,search:n,searchParams:r,hash:o}=new URL(t,"https://localhost");return{pathname:e,search:n,searchParams:r,hash:o}}function nn(t){return e=>{const{host:n}=Q(e);return!(n===void 0||n===t)}}function ie(){return typeof window<"u"&&typeof window.document<"u"}function rn({mode:t,listener:e}){const n=on(t),r=(u,l)=>{if(l!=null&&l.replace)return n.replace(u);n.push(u)},o=()=>{const u=K(n.location);return n.replace(u)};let s;return{...n,update:r,refresh:o,startListening:()=>{s==null||s(),s=n.listen(e)},stopListening:()=>{s==null||s()}}}function on(t="auto"){switch(t){case"auto":return ie()?ae():se();case"browser":return ae();case"memory":return se();case"hash":return Xe();default:const e=t;throw new Error(`Switch is not exhaustive for mode: ${e}`)}}function an(t){return i.defineComponent(()=>()=>i.h("h1",t),{name:t,props:[]})}function ue(t){const e=new URLSearchParams(t);return{get:n=>e.get(n),getAll:n=>e.getAll(n)}}const fe=Symbol();function sn({rejections:t}){const e=a=>{const c={...t};return i.markRaw(c[a]??an(a))},n=a=>{const c=i.markRaw(e(a)),u={name:a,component:c,meta:{}};return{matched:u,matches:[u],key:a,query:ue(""),params:{},[fe]:!0}},r=a=>fe in a,o=a=>{if(!a){s.value=null;return}const c=e(a);s.value={type:a,component:c}},s=i.ref(null);return{setRejection:o,rejection:s,getRejectionRoute:n,isRejectionRoute:r}}class cn extends Error{constructor(e){super(`Route disabled: "${e}"`)}}class un extends Error{constructor(e){super(`Route not found: "${e}"`)}}function At(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fn(t,e){const n=Array.from(t.matchAll(e));if(n.length===0)return[t];let r=0;const o=n.reduce((a,c)=>{const u=At(t.slice(r,c.index));u.length&&a.push(u);const[l]=c;return a.push(l),r=c.index+l.length,a},[]),s=t.slice(r);return s&&o.push(s),o}function ln(t){const e=le(t.path.toString());return new RegExp(`^${e}$`,"i")}function hn(t){const e=new URLSearchParams(t.query.toString());return Array.from(e.entries()).filter(([,n])=>!Lt(n)).map(([n,r])=>{const o=le(r);return new RegExp(`${At(n)}=${o}(&|$)`,"i")})}function le(t){return fn(t,new RegExp(pn,"g")).map(e=>e.startsWith(W)?he(e):At(e)).join("")}function he(t){return[dn,mn].reduce((e,n)=>n(e),t)}const pn=`\\${W}\\??([\\w-_]+)\\${M}`,xt=`\\${W}\\?([\\w-_]+)\\${M}`,pe=`\\${W}([\\w-_]+)\\${M}`;function dn(t){return t.replace(new RegExp(xt,"g"),".*")}function Lt(t){return new RegExp(xt,"g").test(t)}function mn(t){return t.replace(new RegExp(pe,"g"),".+")}function lt(t){const[e]=ht(t,new RegExp(xt,"g")),[n]=ht(t,new RegExp(pe,"g"));return e??n}function ht(t,e){return Array.from(t.matchAll(e)).flatMap(([,...r])=>r.map(o=>Pt(o)?o:""))}function de(t,e,n){const r=Re(e,n),[o]=ht(t,r);return o}function me(t,e){if(!e)return t;const{name:n,param:r,value:o}=e,s=Re(t,n);return ht(t,s).reduce((c,u)=>u===void 0?c:c.replace(u,()=>kt(o,r,n.startsWith("?"))),t)}function Re(t,e){const n=[Rn,gn,he].reduce((r,o)=>o(r,e),t);return new RegExp(n,"g")}function Rn(t,e){if(!e.startsWith("?"))return t;const n=new RegExp(`\\${W}\\${e}\\${M}`,"g");return t.replace(n,"(.*)")}function gn(t,e){if(e.startsWith("?"))return t;const n=new RegExp(`\\${W}${e}\\${M}`,"g");return t.replace(n,"(.+)")}function ge(t,...e){return e.reduce((n,r)=>{if(!r)return n;const o=new URLSearchParams(r).toString();return Object.keys(o).length===0?n:n.includes("?")?`${n}&${o}`:`${n}?${o}`},t)}function yn(t,e={}){const{params:n={},query:r}=e,o=wn(t.host,n),s=vn(t.path,n),a=En(t.query,n);return ge(`${o}${s}`,a,r)}function wn(t,e){const n=t.toString();return Object.entries(t.params).reduce((r,[o,s])=>{const a=lt(`${W}${o}${M}`);return a?me(r,{name:o,param:s,value:e[a]}):r},n)}function vn(t,e){const n=t.toString();return Object.entries(t.params).reduce((r,[o,s])=>{const a=lt(`${W}${o}${M}`);return a?me(r,{name:o,param:s,value:e[a]}):r},n)}function En(t,e){const n=t.toString();if(!n)return{};const r=new URLSearchParams(n);return Array.from(r.entries()).reduce((o,[s,a])=>{const c=lt(a);if(!c)return{...o,[s]:a};const l=kt(e[c],t.params[c],Lt(a)),p=e[c]===void 0&&l==="";return Lt(a)&&p?o:{...o,[s]:l}},{})}function Pn(t){return(e,n,r)=>{if(J(e))return ge(e,(n??{}).query);const o=n??{},s=r??{},a=t.find(u=>u.key===e);if(!a)throw new un(String(e));if(a.matched.disabled)throw new cn(String(e));return yn(a,{params:o,query:s.query})}}class bn extends Error{constructor(){super("initialUrl must be set if window.location is unavailable")}}function Sn(t){if(t)return t;if(ie())return window.location.toString();throw new bn}const kn=(t,e)=>{try{ye(t,e)}catch{return!1}return!0},ye=(t,e)=>{const{pathname:n,search:r}=Q(e);return{...An(t.path,n),...xn(t.query,r)}};function An(t,e){const n={},r=decodeURIComponent(e);for(const[o,s]of Object.entries(t.params)){const a=o.startsWith("?"),c=a?o.slice(1):o,u=de(r,t.toString(),o),l=St(u,s,a);n[c]=l}return n}function xn(t,e){const n={},r=new URLSearchParams(e);for(const[o,s]of Object.entries(t.params)){const a=o.startsWith("?"),c=a?o.slice(1):o,u=r.get(c)??void 0,l=St(u,s,a);n[c]=l}return n}const Ln=t=>"name"in t.matched&&!!t.matched.name,Bn=(t,e)=>{const{pathname:n}=Q(e);return ln(t).test(n)},Un=(t,e)=>{const{search:n}=Q(e);return hn(t).every(o=>o.test(n))};function $n(t){const{searchParams:e,pathname:n}=Q(t),r=-1,o=1;return(s,a)=>{const c=ve(s,e),u=we(s,n),l=ve(a,e),p=we(a,n);return s.depth>a.depth?r:s.depth<a.depth?o:c+u>l+p?r:c+u<l+p?o:0}}function we(t,e){const n=Object.keys(t.path.params).filter(o=>o.startsWith("?")).map(o=>o),r=n.filter(o=>de(e,t.path.toString(),o)===void 0);return n.length-r.length}function ve(t,e){const n=new URLSearchParams(t.query.toString()),r=Array.from(n.keys()),o=r.filter(s=>!e.has(s));return r.length-o.length}const Nn=[Ln,Bn,Un,kn];function Bt(t,e){const n=$n(e),r=t.filter(u=>Nn.every(l=>l(u,e))).sort(n);if(r.length===0)return;const[o]=r,{search:s}=Q(e),a=ue(s),c=ye(o,e);return{matched:o.matched,matches:o.matches,key:o.key,query:a,params:c}}function Ut(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function jn(t){return t.every(e=>Array.isArray(e))}function Hn(t,e={}){const n=jn(t)?t.flat():t,r=Pn(n),o=rn({mode:e.historyMode,listener:()=>{const E=K(location);x(E)}}),{runBeforeRouteHooks:s,runAfterRouteHooks:a}=Ue(),{hooks:c,onBeforeRouteEnter:u,onAfterRouteUpdate:l,onBeforeRouteLeave:p,onAfterRouteEnter:R,onBeforeRouteUpdate:S,onAfterRouteLeave:g}=Ne();async function x(E,{replace:C}={}){if(o.stopListening(),A(E))return o.update(E,{replace:C});const O=Bt(n,E)??b("NotFound"),G={...d},z=await s({to:O,from:G,hooks:c});switch(z.status){case"ABORT":return;case"PUSH":o.update(E,{replace:C}),await L(...z.to);return;case"REJECT":o.update(E,{replace:C}),m(z.type),h(O);break;case"SUCCESS":o.update(E,{replace:C}),m(null),h(O);break;default:throw new Error(`Switch is not exhaustive for before hook response status: ${JSON.stringify(z)}`)}const I=await a({to:O,from:G,hooks:c});switch(I.status){case"PUSH":await L(...I.to);break;case"REJECT":m(I.type);break;case"SUCCESS":break;default:const pt=I;throw new Error(`Switch is not exhaustive for after hook response status: ${JSON.stringify(pt)}`)}o.startListening()}const L=(E,C,O)=>{if(J(E)){const pt={...C},Mn=r(E,pt);return x(Mn,{replace:pt.replace})}const G={...O},I=r(E,C??{},G);return x(I,{replace:G.replace})},q=(E,C,O)=>{if(J(E)){const I={...C,replace:!0};return L(E,I)}const G=C??{},z={...O,replace:!0};return L(E,G,z)},N=E=>m(E),_=(E,C={})=>{if(!J(E)){const O=r(E,C);return Bt(n,O)}if(!A(E))return Bt(n,E)},{setRejection:m,rejection:w,getRejectionRoute:b}=sn(e),k=b("NotFound"),{currentRoute:d,routerRoute:f,updateRoute:h}=Ze(k,L);o.startListening();const v=Sn(e.initialUrl),{host:P}=Q(v),A=nn(P),B=x(v,{replace:!0});function j(E){E.component("RouterView",bt),E.component("RouterLink",Kt),E.provide(mt,w),E.provide(It,c),E.provide(dt,H)}const H={route:f,resolve:r,push:L,replace:q,reject:N,find:_,refresh:o.refresh,forward:o.forward,back:o.back,go:o.go,install:j,initialized:B,isExternal:A,onBeforeRouteEnter:u,onAfterRouteUpdate:l,onBeforeRouteLeave:p,onAfterRouteEnter:R,onBeforeRouteUpdate:S,onAfterRouteLeave:g};return H}function $t(t,e){const n=new RegExp(`\\${W}(\\??[\\w-_]+)\\${M}`,"g");return Array.from(t.matchAll(n)).reduce((o,[s,a])=>{const c=lt(s);if(!c)return o;const u=Ge(e,c);return nt([c],o),o[a]=u,o},{})}function Nt(t,e){return{path:t,params:$t(t,e),toString:()=>t}}function jt(t,e){return{query:t,params:$t(t,e),toString:()=>t}}function Ee(t,e){return{host:t,params:$t(t,e),toString:()=>t}}function Pe(t){return t===void 0?"":t}function Cn(t){return Ut(t)&&typeof t.path=="string"}function be(t){return t===void 0?Nt("",{}):Cn(t)?t:Nt(t,{})}function Vn(t){return Ut(t)&&typeof t.query=="string"}function Se(t){return t===void 0?jt("",{}):Vn(t)?t:jt(t,{})}function qn(t){const e=_n(t),n=Pe(t.name),r=be(t.path),o=Se(t.query),s=i.markRaw({meta:{},...e}),a={matched:s,matches:[s],key:n,path:r,query:o,depth:1,disabled:t.disabled??!1,host:Ee("",{})},c=Qt(t)?Yt(t.parent,a):a;return nt(c.path.params,c.query.params),c}function _n(t){return Te(t)?{...t,component:bt}:t}function On(t){return Ut(t)&&typeof t.host=="string"}function Wn(t){return On(t)?t:Ee(t,{})}function Dn(t){const e=Pe(t.name),n=be(t.path),r=Se(t.query),o=Wn(t.host??""),s=i.markRaw({meta:{},...t}),a={matched:s,matches:[s],key:e,host:o,path:n,query:r,depth:1,disabled:t.disabled??!1},c=Qt(t)?Yt(t.parent,a):a;return nt(c.path.params,c.query.params,c.host.params),c}y.DuplicateParamsError=D,y.RouterLink=Kt,y.RouterNotInstalledError=ot,y.RouterView=bt,y.UseRouteInvalidError=Ht,y.component=Ie,y.createExternalRoute=Dn,y.createParam=re,y.createRoute=qn,y.createRouter=Hn,y.isParamWithDefault=Xt,y.isRoute=Ot,y.onAfterRouteEnter=Ce,y.onAfterRouteLeave=Ve,y.onAfterRouteUpdate=qe,y.onBeforeRouteLeave=je,y.onBeforeRouteUpdate=He,y.path=Nt,y.query=jt,y.routerInjectionKey=dt,y.routerRejectionKey=mt,y.useLink=Ct,y.useRejection=Vt,y.useRoute=Wt,y.useRouter=at,y.withDefault=Qe,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(y,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],i):(y=typeof globalThis<"u"?globalThis:y||self,i(y["@kitbag/router"]={},y.Vue))})(this,function(y,i){"use strict";var or=Object.defineProperty;var ar=(y,i,T)=>i in y?or(y,i,{enumerable:!0,configurable:!0,writable:!0,value:T}):y[i]=T;var O=(y,i,T)=>(ar(y,typeof i!="symbol"?i+"":i,T),T);class T extends Error{constructor(e){super(`Invalid Param "${e}": Router does not support multiple params by the same name. All param names must be unique.`)}}class ut extends Error{constructor(){super("Router not installed")}}class _t extends Error{constructor(e,n){super(`useRoute called with incorrect route. Given ${e}, expected ${n}`)}}const wt=Symbol();function it(){const t=i.inject(wt);if(!t)throw new ut;return t}class Y extends Error{}function K(t){return typeof t!="string"?!1:/^(https?:\/\/|\/).*/g.test(t)}function Wt(t,e={},n={}){const r=it(),o=i.computed(()=>i.toValue(t)),a=i.computed(()=>i.toValue(e)),s=i.computed(()=>i.toValue(n)),c=i.computed(()=>{if(K(o.value))return o.value;try{return r.resolve(o.value,a.value,s.value)}catch(l){throw l instanceof Y&&console.error(`Failed to resolve route "${o.value.toString()}" in RouterLink.`,l),l}}),u=i.computed(()=>r.find(c.value,s.value)),h=i.computed(()=>!!u.value&&r.route.matches.includes(u.value.matched)),d=i.computed(()=>!!u.value&&r.route.matched===u.value.matched);return{route:u,href:c,isMatch:h,isExactMatch:d,push:l=>r.push(c.value,{},{...s.value,...l}),replace:l=>r.replace(c.value,{},{...s.value,...l})}}const vt=Symbol();function Dt(){const t=i.inject(vt);if(!t)throw new ut;return t}function Mt(t,e){return[t,e].filter(n=>!!n).join(".")}const Tt=Symbol("isRouterRouteSymbol");function Ce(t){return typeof t=="object"&&t!==null&&Tt in t}function Oe(t,e){function n(d,l,S){if(typeof d=="object"){const A={...t.params,...d};return e(t.key,A,l)}const m={...t.params,[d]:l};return e(t.key,m,S)}const{matched:r,matches:o,key:a,query:s,params:c,state:u}=i.toRefs(t),h=i.reactive({matched:r,matches:o,state:u,query:s,params:c,key:a,update:n,[Tt]:!0});return new Proxy(h,{get:(d,l,S)=>l==="params"?new Proxy(t.params,{set(m,A,x){return n(A,x),!0}}):l==="state"?new Proxy(t.state,{set(m,A,x){return n({},{state:{...t.state,[A]:x}}),!0}}):Reflect.get(d,l,S)})}function It(t,e,{exact:n}={}){if(!Ce(t))return!1;if(e===void 0)return!0;const r=qe(t);if(n){const o=r.at(-1);return e===o}return r.includes(e)}function qe(t){return t.matches.map(n=>n.name).reduce((n,r)=>{const o=n.pop(),a=r?[Mt(o,r)]:[];return o?[...n,o,...a]:a},[])}function Ft(t,e){const n=it();function r(){if(!t)return;if(!It(n.route,t,e))throw new _t(t,n.route.key)}return i.watch(n.route,r,{immediate:!0,deep:!0}),n.route}const Jt=Symbol();function Et(){return i.inject(Jt,0)}class ft{constructor(){O(this,"onBeforeRouteEnter",new Set);O(this,"onBeforeRouteUpdate",new Set);O(this,"onBeforeRouteLeave",new Set);O(this,"onAfterRouteEnter",new Set);O(this,"onAfterRouteUpdate",new Set);O(this,"onAfterRouteLeave",new Set)}}class Kt extends Error{}class rt extends Error{constructor(n){super("Error occurred during a router push operation.");O(this,"to");this.to=n}}class Pt extends Error{constructor(n){super(`Routing action rejected: ${n}`);O(this,"type");this.type=n}}function X(t){return Array.isArray(t)?t:[t]}function _e(t,e){const n=new ft;return t.matches.forEach((r,o)=>{r.onBeforeRouteEnter&&St(t,e,o)&&X(r.onBeforeRouteEnter).forEach(a=>n.onBeforeRouteEnter.add(a)),r.onBeforeRouteUpdate&&kt(t,e,o)&&X(r.onBeforeRouteUpdate).forEach(a=>n.onBeforeRouteUpdate.add(a))}),e.matches.forEach((r,o)=>{r.onBeforeRouteLeave&&bt(t,e,o)&&X(r.onBeforeRouteLeave).forEach(a=>n.onBeforeRouteLeave.add(a))}),n}function We(t,e){const n=new ft;return t.matches.forEach((r,o)=>{r.onAfterRouteEnter&&St(t,e,o)&&X(r.onAfterRouteEnter).forEach(a=>n.onAfterRouteEnter.add(a)),r.onAfterRouteUpdate&&kt(t,e,o)&&X(r.onAfterRouteUpdate).forEach(a=>n.onAfterRouteUpdate.add(a))}),e.matches.forEach((r,o)=>{r.onAfterRouteLeave&&bt(t,e,o)&&X(r.onAfterRouteLeave).forEach(a=>n.onAfterRouteLeave.add(a))}),n}function De(){const t=s=>{throw new Pt(s)},e=(...s)=>{throw new rt(s)},n=(s,c,u)=>{if(K(s)){const l=c??{};throw new rt([s,{...l,replace:!0}])}const h=c,d=u??{};throw new rt([s,h,{...d,replace:!0}])},r=()=>{throw new Kt};async function o({to:s,from:c,hooks:u}){const{global:h,component:d}=u,l=_e(s,c),S=[...h.onBeforeRouteEnter,...l.onBeforeRouteEnter,...h.onBeforeRouteUpdate,...l.onBeforeRouteUpdate,...d.onBeforeRouteUpdate,...h.onBeforeRouteLeave,...l.onBeforeRouteLeave,...d.onBeforeRouteLeave];try{const m=S.map(A=>A(s,{from:c,reject:t,push:e,replace:n,abort:r}));await Promise.all(m)}catch(m){if(m instanceof rt)return{status:"PUSH",to:m.to};if(m instanceof Pt)return{status:"REJECT",type:m.type};if(m instanceof Kt)return{status:"ABORT"};throw m}return{status:"SUCCESS"}}async function a({to:s,from:c,hooks:u}){const{global:h,component:d}=u,l=We(s,c),S=[...d.onAfterRouteLeave,...l.onAfterRouteLeave,...h.onAfterRouteLeave,...d.onAfterRouteUpdate,...l.onAfterRouteUpdate,...h.onAfterRouteUpdate,...d.onAfterRouteEnter,...l.onAfterRouteEnter,...h.onAfterRouteEnter];try{const m=S.map(A=>A(s,{from:c,reject:t,push:e,replace:n}));await Promise.all(m)}catch(m){if(m instanceof rt)return{status:"PUSH",to:m.to};if(m instanceof Pt)return{status:"REJECT",type:m.type};throw m}return{status:"SUCCESS"}}return{runBeforeRouteHooks:o,runAfterRouteHooks:a}}const St=(t,e,n)=>{const r=t.matches,o=(e==null?void 0:e.matches)??[];return r.length<n||r[n]!==o[n]},bt=(t,e,n)=>{const r=t.matches,o=(e==null?void 0:e.matches)??[];return r.length<n||r[n]!==o[n]},kt=(t,e,n)=>t.matches[n]===(e==null?void 0:e.matches[n]);function Qt(t){switch(t){case"onBeforeRouteEnter":case"onAfterRouteEnter":return St;case"onBeforeRouteUpdate":case"onAfterRouteUpdate":return kt;case"onBeforeRouteLeave":case"onAfterRouteLeave":return bt;default:throw new Error(`Switch is not exhaustive for lifecycle: ${t}`)}}class Me{constructor(){O(this,"global",new ft);O(this,"component",new ft)}addBeforeRouteHook({lifecycle:e,timing:n,depth:r,hook:o}){const a=Qt(e),s=this[n][e],c=(u,h)=>{if(a(u,h.from,r))return o(u,h)};return s.add(c),()=>s.delete(c)}addAfterRouteHook({lifecycle:e,timing:n,depth:r,hook:o}){const a=Qt(e),s=this[n][e],c=(u,h)=>{if(a(u,h.from,r))return o(u,h)};return s.add(c),()=>s.delete(c)}}const Gt=Symbol();function Te(){const t=new Me;return{onBeforeRouteEnter:c=>t.addBeforeRouteHook({lifecycle:"onBeforeRouteEnter",hook:c,timing:"global",depth:0}),onBeforeRouteUpdate:c=>t.addBeforeRouteHook({lifecycle:"onBeforeRouteUpdate",hook:c,timing:"global",depth:0}),onBeforeRouteLeave:c=>t.addBeforeRouteHook({lifecycle:"onBeforeRouteLeave",hook:c,timing:"global",depth:0}),onAfterRouteEnter:c=>t.addAfterRouteHook({lifecycle:"onAfterRouteEnter",hook:c,timing:"global",depth:0}),onAfterRouteUpdate:c=>t.addAfterRouteHook({lifecycle:"onAfterRouteUpdate",hook:c,timing:"global",depth:0}),onAfterRouteLeave:c=>t.addAfterRouteHook({lifecycle:"onAfterRouteLeave",hook:c,timing:"global",depth:0}),hooks:t}}function zt(){const t=i.inject(Gt);if(!t)throw new ut;return t}function Yt(t){return e=>{const n=Et(),o=zt().addBeforeRouteHook({lifecycle:t,hook:e,depth:n,timing:"component"});return i.onUnmounted(o),o}}function At(t){return e=>{const n=Et(),o=zt().addAfterRouteHook({lifecycle:t,hook:e,depth:n,timing:"component"});return i.onUnmounted(o),o}}const Ie=Yt("onBeforeRouteUpdate"),Fe=Yt("onBeforeRouteLeave"),Je=At("onAfterRouteEnter"),Ke=At("onAfterRouteUpdate"),Qe=At("onAfterRouteLeave"),Ge=["href"],Xt=i.defineComponent({__name:"routerLink",props:{to:{type:[String,Function]},query:{},replace:{type:Boolean},state:{}},setup(t){const e=t,n=it(),r=i.computed(()=>K(e.to)?e.to:e.to(n.resolve)),o=i.computed(()=>{const{to:l,...S}=e;return S}),{href:a,isMatch:s,isExactMatch:c}=Wt(r),u=i.computed(()=>({"router-link--match":s.value,"router-link--exact-match":c.value})),h=i.computed(()=>n.isExternal(r.value));function d(l){l.preventDefault(),n.push(a.value,o.value)}return(l,S)=>(i.openBlock(),i.createElementBlock("a",{href:r.value,class:i.normalizeClass(["router-link",u.value]),onClick:d},[i.renderSlot(l.$slots,"default",i.normalizeProps(i.guardReactiveProps({resolved:r.value,isMatch:i.unref(s),isExactMatch:i.unref(c),isExternal:h.value})))],10,Ge))}});function Zt(t,e){return i.defineComponent({name:"PropsWrapper",expose:[],setup(){const n=e();return"then"in n?()=>i.h(ze(t,n)):()=>i.h(t,n)}})}function ze(t,e){return i.defineComponent({name:"AsyncPropsWrapper",expose:[],async setup(){const n=await e;return()=>i.h(t,n)}})}class Ye extends Error{constructor(e){super(`Child property on meta for ${e} conflicts with the parent meta.`)}}function Xe(t,e){return Ze(t,e),{...t,...e}}function Ze(t,e){const n=Object.keys(t).find(r=>r in e&&typeof e[r]!=typeof t[r]);if(n)throw new Ye(n)}function Z(...t){const e=t.flatMap(n=>Array.isArray(n)?n:Object.keys(n).map(en));for(const n of e)if(tn(e,n)>1)throw new T(n)}function tn(t,e){return t.filter(n=>e===n).length}function en(t){return t.startsWith("?")?t.slice(1):t}function nn(t,e){Z(t.params,e.params);const n=`${t.path}${e.path}`;return{path:n,params:{...t.params,...e.params},toString:()=>n}}function xt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function rn(t){return t.every(e=>Array.isArray(e))}function lt(t){return typeof t=="string"&&t.length>0}function on(t,e){Z(t.params,e.params);const n=[t.query,e.query].filter(lt).join("&");return{query:n,params:{...t.params,...e.params},toString:()=>n}}function an(t,e){return Z(t,e),{...t,...e}}function sn(t){return"host"in t&&!!t.host}function te(t){return"parent"in t&&!!t.parent}function ee(t){return"component"in t&&!!t.component}function ne(t){return"components"in t&&!!t.components}function cn(t){return"state"in t&&!!t.state}function re(t,e){return{...e,key:Mt(t.key,e.key),path:nn(t.path,e.path),query:on(t.query,e.query),meta:Xe(t.meta,e.meta),state:an(t.state,e.state),matches:[...t.matches,e.matched],host:t.host,depth:t.depth+1}}const oe=i.defineComponent({__name:"routerView",props:{name:{}},setup(t){const{name:e="default"}=t,n=Ft(),r=Dt(),o=Et(),a=i.resolveComponent("RouterView",!0);i.provide(Jt,o+1);const s=i.computed(()=>{if(r.value)return r.value.component;const l=n.matches.at(o);if(!l)return null;const S=c(l),m=h(l);return S?m?Zt(S,()=>m(n.params)):S:null});function c(l){return u(l)[e]}function u(l){return ne(l)?l.components:ee(l)?{default:l.component}:typeof a=="string"?{}:{default:a}}function h(l){return d(l)[e]}function d(l){return ne(l)?l.props??{}:ee(l)?{default:l.props}:{}}return(l,S)=>s.value?i.renderSlot(l.$slots,"default",i.normalizeProps(i.mergeProps({key:0},{route:i.unref(n),component:s.value,rejection:i.unref(r)})),()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(s.value)))]):i.createCommentVNode("",!0)}}),D="[",I="]";function un(t){return t!==String&&t!==Boolean&&t!==Number&&t!==Date}function fn(t){return typeof t=="function"&&un(t)}function ht(t){return typeof t=="object"&&"get"in t&&typeof t.get=="function"&&"set"in t&&typeof t.set=="function"}function ae(t){return ht(t)&&t.defaultValue!==void 0}function ln(t,e){return fe(t,e)}function hn(t,e){return t[e]??String}const H={invalid:t=>{throw new Y(t)}},pn={get:t=>t,set:(t,{invalid:e})=>{if(typeof t!="string")throw e();return t}},se={get:(t,{invalid:e})=>{if(t==="true")return!0;if(t==="false")return!1;throw e()},set:(t,{invalid:e})=>{if(typeof t!="boolean")throw e();return t.toString()}},ce={get:(t,{invalid:e})=>{const n=Number(t);if(isNaN(n))throw e();return n},set:(t,{invalid:e})=>{if(typeof t!="number")throw e();return t.toString()}},ue={get:(t,{invalid:e})=>{const n=new Date(t);if(isNaN(n.getTime()))throw e();return n},set:(t,{invalid:e})=>{if(typeof t!="object"||!(t instanceof Date))throw e();return t.toISOString()}},ie={get:(t,{invalid:e})=>{try{return JSON.parse(t)}catch{throw e()}},set:(t,{invalid:e})=>{try{return JSON.stringify(t)}catch{throw e()}}};function ot(t,e,n=!1){if(t===void 0||!lt(t)){if(ae(e))return e.defaultValue;if(n)return;throw new Y}if(e===String)return pn.get(t,H);if(e===Boolean)return se.get(t,H);if(e===Number)return ce.get(t,H);if(e===Date)return ue.get(t,H);if(e===JSON)return ie.get(t,H);if(fn(e))return e(t,H);if(ht(e))return e.get(t,H);if(e instanceof RegExp){if(e.test(t))return t;throw new Y}return t}function at(t,e,n=!1){if(t===void 0){if(n)return"";throw new Y}if(e===Boolean)return se.set(t,H);if(e===Number)return ce.set(t,H);if(e===Date)return ue.set(t,H);if(e===JSON)return ie.set(t,H);if(ht(e))return e.set(t,H);try{return t.toString()}catch{throw new Y}}function fe(t,e){return ht(t)?{...t,defaultValue:e??t.defaultValue}:{get:n=>ot(n,t),set:n=>at(n,t),defaultValue:e}}function F(){return F=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},F.apply(this,arguments)}var $;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})($||($={}));var tt=process.env.NODE_ENV!=="production"?function(t){return Object.freeze(t)}:function(t){return t};function Q(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}var pt="beforeunload",dn="hashchange",le="popstate";function he(t){t===void 0&&(t={});var e=t,n=e.window,r=n===void 0?document.defaultView:n,o=r.history;function a(){var R=r.location,f=R.pathname,p=R.search,E=R.hash,P=o.state||{};return[P.idx,tt({pathname:f,search:p,hash:E,state:P.usr||null,key:P.key||"default"})]}var s=null;function c(){if(s)m.call(s),s=null;else{var R=$.Pop,f=a(),p=f[0],E=f[1];if(m.length)if(p!=null){var P=d-p;P&&(s={action:R,location:E,retry:function(){b(P*-1)}},b(P))}else process.env.NODE_ENV!=="production"&&Q(!1,"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation.");else q(R)}}r.addEventListener(le,c);var u=$.Pop,h=a(),d=h[0],l=h[1],S=et(),m=et();d==null&&(d=0,o.replaceState(F({},o.state,{idx:d}),""));function A(R){return typeof R=="string"?R:G(R)}function x(R,f){return f===void 0&&(f=null),tt(F({pathname:l.pathname,hash:"",search:""},typeof R=="string"?st(R):R,{state:f,key:mt()}))}function j(R,f){return[{usr:R.state,key:R.key,idx:f},A(R)]}function V(R,f,p){return!m.length||(m.call({action:R,location:f,retry:p}),!1)}function q(R){u=R;var f=a();d=f[0],l=f[1],S.call({action:u,location:l})}function g(R,f){var p=$.Push,E=x(R,f);function P(){g(R,f)}if(V(p,E,P)){var B=j(E,d+1),U=B[0],N=B[1];try{o.pushState(U,"",N)}catch{r.location.assign(N)}q(p)}}function w(R,f){var p=$.Replace,E=x(R,f);function P(){w(R,f)}if(V(p,E,P)){var B=j(E,d),U=B[0],N=B[1];o.replaceState(U,"",N),q(p)}}function b(R){o.go(R)}var k={get action(){return u},get location(){return l},createHref:A,push:g,replace:w,go:b,back:function(){b(-1)},forward:function(){b(1)},listen:function(f){return S.push(f)},block:function(f){var p=m.push(f);return m.length===1&&r.addEventListener(pt,dt),function(){p(),m.length||r.removeEventListener(pt,dt)}}};return k}function mn(t){t===void 0&&(t={});var e=t,n=e.window,r=n===void 0?document.defaultView:n,o=r.history;function a(){var f=st(r.location.hash.substr(1)),p=f.pathname,E=p===void 0?"/":p,P=f.search,B=P===void 0?"":P,U=f.hash,N=U===void 0?"":U,C=o.state||{};return[C.idx,tt({pathname:E,search:B,hash:N,state:C.usr||null,key:C.key||"default"})]}var s=null;function c(){if(s)m.call(s),s=null;else{var f=$.Pop,p=a(),E=p[0],P=p[1];if(m.length)if(E!=null){var B=d-E;B&&(s={action:f,location:P,retry:function(){k(B*-1)}},k(B))}else process.env.NODE_ENV!=="production"&&Q(!1,"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation.");else g(f)}}r.addEventListener(le,c),r.addEventListener(dn,function(){var f=a(),p=f[1];G(p)!==G(l)&&c()});var u=$.Pop,h=a(),d=h[0],l=h[1],S=et(),m=et();d==null&&(d=0,o.replaceState(F({},o.state,{idx:d}),""));function A(){var f=document.querySelector("base"),p="";if(f&&f.getAttribute("href")){var E=r.location.href,P=E.indexOf("#");p=P===-1?E:E.slice(0,P)}return p}function x(f){return A()+"#"+(typeof f=="string"?f:G(f))}function j(f,p){return p===void 0&&(p=null),tt(F({pathname:l.pathname,hash:"",search:""},typeof f=="string"?st(f):f,{state:p,key:mt()}))}function V(f,p){return[{usr:f.state,key:f.key,idx:p},x(f)]}function q(f,p,E){return!m.length||(m.call({action:f,location:p,retry:E}),!1)}function g(f){u=f;var p=a();d=p[0],l=p[1],S.call({action:u,location:l})}function w(f,p){var E=$.Push,P=j(f,p);function B(){w(f,p)}if(process.env.NODE_ENV!=="production"&&Q(P.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.push("+JSON.stringify(f)+")"),q(E,P,B)){var U=V(P,d+1),N=U[0],C=U[1];try{o.pushState(N,"",C)}catch{r.location.assign(C)}g(E)}}function b(f,p){var E=$.Replace,P=j(f,p);function B(){b(f,p)}if(process.env.NODE_ENV!=="production"&&Q(P.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.replace("+JSON.stringify(f)+")"),q(E,P,B)){var U=V(P,d),N=U[0],C=U[1];o.replaceState(N,"",C),g(E)}}function k(f){o.go(f)}var R={get action(){return u},get location(){return l},createHref:x,push:w,replace:b,go:k,back:function(){k(-1)},forward:function(){k(1)},listen:function(p){return S.push(p)},block:function(p){var E=m.push(p);return m.length===1&&r.addEventListener(pt,dt),function(){E(),m.length||r.removeEventListener(pt,dt)}}};return R}function pe(t){t===void 0&&(t={});var e=t,n=e.initialEntries,r=n===void 0?["/"]:n,o=e.initialIndex,a=r.map(function(g){var w=tt(F({pathname:"/",search:"",hash:"",state:null,key:mt()},typeof g=="string"?st(g):g));return process.env.NODE_ENV!=="production"&&Q(w.pathname.charAt(0)==="/","Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: "+JSON.stringify(g)+")"),w}),s=de(o??a.length-1,0,a.length-1),c=$.Pop,u=a[s],h=et(),d=et();function l(g){return typeof g=="string"?g:G(g)}function S(g,w){return w===void 0&&(w=null),tt(F({pathname:u.pathname,search:"",hash:""},typeof g=="string"?st(g):g,{state:w,key:mt()}))}function m(g,w,b){return!d.length||(d.call({action:g,location:w,retry:b}),!1)}function A(g,w){c=g,u=w,h.call({action:c,location:u})}function x(g,w){var b=$.Push,k=S(g,w);function R(){x(g,w)}process.env.NODE_ENV!=="production"&&Q(u.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.push("+JSON.stringify(g)+")"),m(b,k,R)&&(s+=1,a.splice(s,a.length,k),A(b,k))}function j(g,w){var b=$.Replace,k=S(g,w);function R(){j(g,w)}process.env.NODE_ENV!=="production"&&Q(u.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.replace("+JSON.stringify(g)+")"),m(b,k,R)&&(a[s]=k,A(b,k))}function V(g){var w=de(s+g,0,a.length-1),b=$.Pop,k=a[w];function R(){V(g)}m(b,k,R)&&(s=w,A(b,k))}var q={get index(){return s},get action(){return c},get location(){return u},createHref:l,push:x,replace:j,go:V,back:function(){V(-1)},forward:function(){V(1)},listen:function(w){return h.push(w)},block:function(w){return d.push(w)}};return q}function de(t,e,n){return Math.min(Math.max(t,e),n)}function dt(t){t.preventDefault(),t.returnValue=""}function et(){var t=[];return{get length(){return t.length},push:function(n){return t.push(n),function(){t=t.filter(function(r){return r!==n})}},call:function(n){t.forEach(function(r){return r&&r(n)})}}}function mt(){return Math.random().toString(36).substr(2,8)}function G(t){var e=t.pathname,n=e===void 0?"/":e,r=t.search,o=r===void 0?"":r,a=t.hash,s=a===void 0?"":a;return o&&o!=="?"&&(n+=o.charAt(0)==="?"?o:"?"+o),s&&s!=="#"&&(n+=s.charAt(0)==="#"?s:"#"+s),n}function st(t){var e={};if(t){var n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));var r=t.indexOf("?");r>=0&&(e.search=t.substr(r),t=t.substr(0,r)),t&&(e.pathname=t)}return e}function Rn(t,e){const n=i.reactive({...t}),r=s=>{Object.assign(n,{...s})},o=n,a=Oe(o,e);return{currentRoute:o,routerRoute:a,updateRoute:r}}function z(t){return!t.startsWith("http")?yn(t):gn(t)}function gn(t){const{protocol:e,host:n,pathname:r,search:o,searchParams:a,hash:s}=new URL(t,t);return{protocol:e,host:n,pathname:r,search:o,searchParams:a,hash:s}}function yn(t){const{pathname:e,search:n,searchParams:r,hash:o}=new URL(t,"https://localhost");return{pathname:e,search:n,searchParams:r,hash:o}}function wn(t){return e=>{const{host:n}=z(e);return!(n===void 0||n===t)}}function me(){return typeof window<"u"&&typeof window.document<"u"}function vn({mode:t,listener:e}){const n=En(t),r=(u,h)=>{if(h!=null&&h.replace)return n.replace(u,h.state);n.push(u,h==null?void 0:h.state)},o=()=>{const u=G(n.location);return n.replace(u)};let a;return{...n,update:r,refresh:o,startListening:()=>{a==null||a(),a=n.listen(e)},stopListening:()=>{a==null||a()}}}function En(t="auto"){switch(t){case"auto":return me()?he():pe();case"browser":return he();case"memory":return pe();case"hash":return mn();default:const e=t;throw new Error(`Switch is not exhaustive for mode: ${e}`)}}function Pn(t){return i.defineComponent(()=>()=>i.h("h1",t),{name:t,props:[]})}function Re(t){const e=new URLSearchParams(t);return{get:n=>e.get(n),getAll:n=>e.getAll(n)}}const ge=Symbol();function Sn({rejections:t}){const e=s=>{const c={...t};return i.markRaw(c[s]??Pn(s))},n=s=>{const c=i.markRaw(e(s)),u={name:s,component:c,meta:{},state:{}};return{matched:u,matches:[u],key:s,query:Re(""),params:{},state:{},[ge]:!0}},r=s=>ge in s,o=s=>{if(!s){a.value=null;return}const c=e(s);a.value={type:s,component:c}},a=i.ref(null);return{setRejection:o,rejection:a,getRejectionRoute:n,isRejectionRoute:r}}class bn extends Error{constructor(e){super(`Route not found: "${e}"`)}}function Bt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function kn(t,e){const n=Array.from(t.matchAll(e));if(n.length===0)return[t];let r=0;const o=n.reduce((s,c)=>{const u=Bt(t.slice(r,c.index));u.length&&s.push(u);const[h]=c;return s.push(h),r=c.index+h.length,s},[]),a=t.slice(r);return a&&o.push(a),o}function An(t){const e=ye(t.path.toString());return new RegExp(`^${e}$`,"i")}function xn(t){const e=new URLSearchParams(t.query.toString());return Array.from(e.entries()).filter(([,n])=>!Ut(n)).map(([n,r])=>{const o=ye(r);return new RegExp(`${Bt(n)}=${o}(&|$)`,"i")})}function ye(t){return kn(t,new RegExp(Bn,"g")).map(e=>e.startsWith(D)?we(e):Bt(e)).join("")}function we(t){return[Ln,Un].reduce((e,n)=>n(e),t)}const Bn=`\\${D}\\??([\\w-_]+)\\${I}`,Lt=`\\${D}\\?([\\w-_]+)\\${I}`,ve=`\\${D}([\\w-_]+)\\${I}`;function Ln(t){return t.replace(new RegExp(Lt,"g"),".*")}function Ut(t){return new RegExp(Lt,"g").test(t)}function Un(t){return t.replace(new RegExp(ve,"g"),".+")}function Rt(t){const[e]=gt(t,new RegExp(Lt,"g")),[n]=gt(t,new RegExp(ve,"g"));return e??n}function gt(t,e){return Array.from(t.matchAll(e)).flatMap(([,...r])=>r.map(o=>lt(o)?o:""))}function Ee(t,e,n){const r=Se(e,n),[o]=gt(t,r);return o}function Pe(t,e){if(!e)return t;const{name:n,param:r,value:o}=e,a=Se(t,n);return gt(t,a).reduce((c,u)=>u===void 0?c:c.replace(u,()=>at(o,r,n.startsWith("?"))),t)}function Se(t,e){const n=[$n,Nn,we].reduce((r,o)=>o(r,e),t);return new RegExp(n,"g")}function $n(t,e){if(!e.startsWith("?"))return t;const n=new RegExp(`\\${D}\\${e}\\${I}`,"g");return t.replace(n,"(.*)")}function Nn(t,e){if(e.startsWith("?"))return t;const n=new RegExp(`\\${D}${e}\\${I}`,"g");return t.replace(n,"(.+)")}function be(t,...e){return e.reduce((n,r)=>{if(!r)return n;const o=new URLSearchParams(r).toString();return Object.keys(o).length===0?n:n.includes("?")?`${n}&${o}`:`${n}?${o}`},t)}function jn(t,e={}){const{params:n={},query:r}=e,o=Hn(t.host,n),a=Vn(t.path,n),s=Cn(t.query,n);return be(`${o}${a}`,s,r)}function Hn(t,e){const n=t.toString();return Object.entries(t.params).reduce((r,[o,a])=>{const s=Rt(`${D}${o}${I}`);return s?Pe(r,{name:o,param:a,value:e[s]}):r},n)}function Vn(t,e){const n=t.toString();return Object.entries(t.params).reduce((r,[o,a])=>{const s=Rt(`${D}${o}${I}`);return s?Pe(r,{name:o,param:a,value:e[s]}):r},n)}function Cn(t,e){const n=t.toString();if(!n)return{};const r=new URLSearchParams(n);return Array.from(r.entries()).reduce((o,[a,s])=>{const c=Rt(s);if(!c)return{...o,[a]:s};const h=at(e[c],t.params[c],Ut(s)),d=e[c]===void 0&&h==="";return Ut(s)&&d?o:{...o,[a]:h}},{})}function On(t){return(e,n,r)=>{if(K(e))return be(e,(n??{}).query);const o=n??{},a=r??{},s=t.find(u=>u.key===e);if(!s)throw new bn(String(e));return jn(s,{params:o,query:a.query})}}class qn extends Error{constructor(){super("initialUrl must be set if window.location is unavailable")}}function _n(t){if(t)return t;if(me())return window.location.toString();throw new qn}const Wn=(t,e)=>{try{ke(t,e)}catch{return!1}return!0},ke=(t,e)=>{const{pathname:n,search:r}=z(e);return{...Dn(t.path,n),...Mn(t.query,r)}};function Dn(t,e){const n={},r=decodeURIComponent(e);for(const[o,a]of Object.entries(t.params)){const s=o.startsWith("?"),c=s?o.slice(1):o,u=Ee(r,t.toString(),o),h=ot(u,a,s);n[c]=h}return n}function Mn(t,e){const n={},r=new URLSearchParams(e);for(const[o,a]of Object.entries(t.params)){const s=o.startsWith("?"),c=s?o.slice(1):o,u=r.get(c)??void 0,h=ot(u,a,s);n[c]=h}return n}const Tn=t=>"name"in t.matched&&!!t.matched.name,In=(t,e)=>{const{pathname:n}=z(e);return An(t).test(n)},Fn=(t,e)=>{const{search:n}=z(e);return xn(t).every(o=>o.test(n))};function Jn(t){const{searchParams:e,pathname:n}=z(t),r=-1,o=1;return(a,s)=>{const c=xe(a,e),u=Ae(a,n),h=xe(s,e),d=Ae(s,n);return a.depth>s.depth?r:a.depth<s.depth?o:c+u>h+d?r:c+u<h+d?o:0}}function Ae(t,e){const n=Object.keys(t.path.params).filter(o=>o.startsWith("?")).map(o=>o),r=n.filter(o=>Ee(e,t.path.toString(),o)===void 0);return n.length-r.length}function xe(t,e){const n=new URLSearchParams(t.query.toString()),r=Array.from(n.keys()),o=r.filter(a=>!e.has(a));return r.length-o.length}function Be(t){return!!t&&typeof t=="object"}const yt=!0;function Kn(t,e,n){if(Be(t)&&e in t){const r=t[e];if(typeof r=="string")return ot(r,n,yt)}return ot(void 0,n,yt)}function Qn(t,e){const n={};for(const[r,o]of Object.entries(t)){const a=Kn(e,r,o);n[r]=a}return n}function Gn(t,e,n){if(Be(t)&&e in t){const r=t[e];return at(r,n,yt)}return at(void 0,n,yt)}const Le=(t,e)=>{const n={};for(const[r,o]of Object.entries(t)){const a=Gn(e,r,o);n[r]=a}return n},zn=[Tn,In,Fn,Wn];function $t(t,e,n){const r=Jn(e),o=t.filter(c=>zn.every(u=>u(c,e))).sort(r);if(o.length===0)return;const[a]=o,{search:s}=z(e);return{matched:a.matched,matches:a.matches,key:a.key,query:Re(s),params:ke(a,e),state:Qn(a.state,n)}}function Nt(t,e){const n=new RegExp(`\\${D}(\\??[\\w-_]+)\\${I}`,"g");return Array.from(t.matchAll(n)).reduce((o,[a,s])=>{const c=Rt(a);if(!c)return o;const u=hn(e,c);return Z([c],o),o[s]=u,o},{})}function Ue(t,e){return{host:t,params:Nt(t,e),toString:()=>t}}function $e(t){return t===void 0?"":t}function jt(t,e){return{path:t,params:Nt(t,e),toString:()=>t}}function Yn(t){return xt(t)&&typeof t.path=="string"}function Ne(t){return t===void 0?jt("",{}):Yn(t)?t:jt(t,{})}function Ht(t,e){return{query:t,params:Nt(t,e),toString:()=>t}}function Xn(t){return xt(t)&&typeof t.query=="string"}function je(t){return t===void 0?Ht("",{}):Xn(t)?t:Ht(t,{})}function Vt(t){const e=$e(t.name),n=Ne(t.path),r=je(t.query),o=t.meta??{},a=cn(t)?t.state:{},s=i.markRaw({meta:{},state:{},...t}),c={matched:s,matches:[s],key:e,path:n,query:r,meta:o,state:a,depth:1,host:Ue("",{})},u=te(t)?re(t.parent,c):c;return Z(u.path.params,u.query.params),u}function Zn(t,e){if(!lt(e))return t;const n=Vt({path:e});return t.map(r=>Vt({parent:n,...r}))}function tr(t,e={}){const n=rn(t)?t.flat():t,r=Zn(n,e.base),o=On(r),a=vn({mode:e.historyMode,listener:({location:v})=>{const L=G(v);x(L,{state:v.state})}}),{runBeforeRouteHooks:s,runAfterRouteHooks:c}=De(),{hooks:u,onBeforeRouteEnter:h,onAfterRouteUpdate:d,onBeforeRouteLeave:l,onAfterRouteEnter:S,onBeforeRouteUpdate:m,onAfterRouteLeave:A}=Te();async function x(v,L={}){if(a.stopListening(),N(v))return a.update(v,L);const _=$t(r,v,L.state)??k("NotFound"),W={...f},nt=await s({to:_,from:W,hooks:u});switch(nt.status){case"ABORT":return;case"PUSH":a.update(v,L),await j(...nt.to);return;case"REJECT":a.update(v,L),w(nt.type),E(_);break;case"SUCCESS":a.update(v,L),w(null),E(_);break;default:throw new Error(`Switch is not exhaustive for before hook response status: ${JSON.stringify(nt)}`)}const J=await c({to:_,from:W,hooks:u});switch(J.status){case"PUSH":await j(...J.to);break;case"REJECT":w(J.type);break;case"SUCCESS":break;default:const M=J;throw new Error(`Switch is not exhaustive for after hook response status: ${JSON.stringify(M)}`)}a.startListening()}const j=(v,L,_)=>{if(K(v)){const ct={...L},qt=o(v,ct);return x(qt,ct)}const W={..._},J=o(v,L??{},W),M=Ct(v),Ot=Le((M==null?void 0:M.state)??{},W.state);return x(J,{...W,state:Ot})},V=(v,L,_)=>{if(K(v)){const ct={...L,replace:!0},qt=o(v,ct);return x(qt,ct)}const W={..._,replace:!0},J=o(v,L??{},W),M=Ct(v),Ot=Le((M==null?void 0:M.state)??{},W.state);return x(J,{...W,state:Ot})},q=v=>w(v),g=(v,L={})=>{if(!K(v)){const _=o(v,L);return $t(r,_)}if(!N(v))return $t(r,v)},{setRejection:w,rejection:b,getRejectionRoute:k}=Sn(e),R=k("NotFound"),{currentRoute:f,routerRoute:p,updateRoute:E}=Rn(R,j);a.startListening();const P=_n(e.initialUrl),B=a.location.state,{host:U}=z(P),N=wn(U),C=x(P,{replace:!0,state:B});function Ct(v){return r.find(L=>L.key===v)}function rr(v){v.component("RouterView",oe),v.component("RouterLink",Xt),v.provide(vt,b),v.provide(Gt,u),v.provide(wt,Ve)}const Ve={route:p,resolve:o,push:j,replace:V,reject:q,find:g,refresh:a.refresh,forward:a.forward,back:a.back,go:a.go,install:rr,initialized:C,isExternal:N,onBeforeRouteEnter:h,onAfterRouteUpdate:d,onBeforeRouteLeave:l,onAfterRouteEnter:S,onBeforeRouteUpdate:m,onAfterRouteLeave:A};return Ve}function er(t){return xt(t)&&typeof t.host=="string"}function He(t){return er(t)?t:Ue(t,{})}function nr(t){const e=$e(t.name),n=Ne(t.path),r=je(t.query),o=t.meta??{},a=sn(t)?He(t.host):He(""),s=i.markRaw({meta:{},state:{},...t}),c={matched:s,matches:[s],key:e,host:a,path:n,query:r,meta:o,depth:1,state:{}},u=te(t)?re(t.parent,c):c;return Z(u.path.params,u.query.params,u.host.params),u}y.DuplicateParamsError=T,y.RouterLink=Xt,y.RouterNotInstalledError=ut,y.RouterView=oe,y.UseRouteInvalidError=_t,y.component=Zt,y.createExternalRoute=nr,y.createParam=fe,y.createRoute=Vt,y.createRouter=tr,y.isParamWithDefault=ae,y.isRoute=It,y.onAfterRouteEnter=Je,y.onAfterRouteLeave=Ke,y.onAfterRouteUpdate=Qe,y.onBeforeRouteLeave=Ie,y.onBeforeRouteUpdate=Fe,y.path=jt,y.query=Ht,y.routerInjectionKey=wt,y.routerRejectionKey=vt,y.useLink=Wt,y.useRejection=Dt,y.useRoute=Ft,y.useRouter=it,y.withDefault=ln,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
|