@kitbag/router 0.14.1 → 0.15.0
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/dist/kitbag-router.d.ts +21 -16
- package/dist/kitbag-router.js +687 -670
- package/dist/kitbag-router.umd.cjs +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(k,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],u):(k=typeof globalThis<"u"?globalThis:k||self,u(k["@kitbag/router"]={},k.Vue))})(this,function(k,u){"use strict";var Or=Object.defineProperty;var Fr=(k,u,N)=>u in k?Or(k,u,{enumerable:!0,configurable:!0,writable:!0,value:N}):k[u]=N;var O=(k,u,N)=>Fr(k,typeof u!="symbol"?u+"":u,N);function N(e){return typeof e!="string"?!1:/^(https?:\/\/|\/).*/g.test(e)}function ke(e){return N(e)?e:`/${e}`}class Ge extends Error{constructor(t){super(`Invalid Param "${t}": Router does not support multiple params by the same name. All param names must be unique.`)}}class Ke extends Error{constructor(t){super(`Child property on meta for ${t} conflicts with the parent meta.`)}}class ee extends Error{constructor(){super("Router not installed")}}class Ye extends Error{constructor(t,n){super(`useRoute called with incorrect route. Given ${t}, expected ${n}`)}}const Xe=Symbol();function le(){const e=u.inject(Xe);if(!e)throw new ee;return e}function se(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function rn(e){return e.every(t=>Array.isArray(t))}function F(e){return typeof e=="string"&&e.length>0}function he(e){return{value:F(e)?e.replace(/^#*/,""):void 0}}function on(e,t){return he(`${e.value??""}${t.value??""}`)}function an(e,t){return sn(e,t),{...e,...t}}function sn(e,t){const n=Object.keys(e).find(r=>r in t&&typeof t[r]!=typeof e[r]);if(n)throw new Ke(n)}function te(e){return Array.isArray(e)?e:[e]}function Ze(e,t){return e.filter(n=>t===n).length}function ne(...e){const t=e.flatMap(n=>Array.isArray(n)?n:Object.keys(n).map(cn));for(const n of t)if(Ze(t,n)>1)throw new Ge(n)}function cn(e){return e.startsWith("?")?e.slice(1):e}function un(e,t){return ne(e.params,t.params),{value:`${e.value}${t.value}`,params:{...e.params,...t.params}}}function fn(e,t){return ne(e.params,t.params),{value:[e.value,t.value].filter(F).join("&"),params:{...e.params,...t.params}}}function ln(e,t){return ne(e,t),{...e,...t}}function hn(e){return"host"in e&&!!e.host}function et(e){return"parent"in e&&!!e.parent}function Ae(e){return"component"in e&&!!e.component}function xe(e){return"components"in e&&!!e.components}function pn(e){return"state"in e&&!!e.state}function tt(e,t){return{...t,path:un(e.path,t.path),query:fn(e.query,t.query),meta:an(e.meta,t.meta),state:ln(e.state,t.state),hash:on(e.hash,t.hash),matches:[...e.matches,t.matched],host:e.host,depth:e.depth+1}}function Ue(){return typeof window<"u"&&typeof window.document<"u"}class ce extends Error{}const J="[",Q="]";function dn(e){return e!==String&&e!==Boolean&&e!==Number&&e!==Date}function mn(e){return typeof e=="function"&&dn(e)}function pe(e){return typeof e=="object"&&"get"in e&&typeof e.get=="function"&&"set"in e&&typeof e.set=="function"}function yn(e){return pe(e)&&e.defaultValue!==void 0}function gn(e,t){return st(e,t)}function Rn(e,t){return e[t]??String}const q={invalid:e=>{throw new ce(e)}},wn={get:e=>e,set:(e,{invalid:t})=>{if(typeof e!="string")throw t();return e}},nt={get:(e,{invalid:t})=>{if(e==="true")return!0;if(e==="false")return!1;throw t()},set:(e,{invalid:t})=>{if(typeof e!="boolean")throw t();return e.toString()}},rt={get:(e,{invalid:t})=>{const n=Number(e);if(isNaN(n))throw t();return n},set:(e,{invalid:t})=>{if(typeof e!="number")throw t();return e.toString()}},ot={get:(e,{invalid:t})=>{const n=new Date(e);if(isNaN(n.getTime()))throw t();return n},set:(e,{invalid:t})=>{if(typeof e!="object"||!(e instanceof Date))throw t();return e.toISOString()}},at={get:(e,{invalid:t})=>{try{return JSON.parse(e)}catch{throw t()}},set:(e,{invalid:t})=>{try{return JSON.stringify(e)}catch{throw t()}}};function ue(e,t,n=!1){if(e===void 0||!F(e)){if(yn(t))return t.defaultValue;if(n)return;throw new ce}if(t===String)return wn.get(e,q);if(t===Boolean)return nt.get(e,q);if(t===Number)return rt.get(e,q);if(t===Date)return ot.get(e,q);if(t===JSON)return at.get(e,q);if(mn(t))return t(e,q);if(pe(t))return t.get(e,q);if(t instanceof RegExp){if(t.test(e))return e;throw new ce}return e}function ie(e,t,n=!1){if(e===void 0){if(n)return"";throw new ce}if(t===Boolean)return nt.set(e,q);if(t===Number)return rt.set(e,q);if(t===Date)return ot.set(e,q);if(t===JSON)return at.set(e,q);if(pe(t))return t.set(e,q);try{return e.toString()}catch{throw new ce}}function st(e,t){return pe(e)?{...e,defaultValue:t??e.defaultValue}:{get:n=>ue(n,e),set:n=>ie(n,e),defaultValue:t}}function z(){return z=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},z.apply(null,arguments)}var H;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(H||(H={}));var re=process.env.NODE_ENV!=="production"?function(e){return Object.freeze(e)}:function(e){return e};function Y(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}var de="beforeunload",vn="hashchange",ct="popstate";function ut(e){e===void 0&&(e={});var t=e,n=t.window,r=n===void 0?document.defaultView:n,o=r.history;function a(){var R=r.location,h=R.pathname,g=R.search,A=R.hash,x=o.state||{};return[x.idx,re({pathname:h,search:g,hash:A,state:x.usr||null,key:x.key||"default"})]}var s=null;function c(){if(s)d.call(s),s=null;else{var R=H.Pop,h=a(),g=h[0],A=h[1];if(d.length)if(g!=null){var x=l-g;x&&(s={action:R,location:A,retry:function(){L(x*-1)}},L(x))}else process.env.NODE_ENV!=="production"&&Y(!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 U(R)}}r.addEventListener(ct,c);var f=H.Pop,i=a(),l=i[0],m=i[1],E=oe(),d=oe();l==null&&(l=0,o.replaceState(z({},o.state,{idx:l}),""));function p(R){return typeof R=="string"?R:X(R)}function w(R,h){return h===void 0&&(h=null),re(z({pathname:m.pathname,hash:"",search:""},typeof R=="string"?fe(R):R,{state:h,key:ye()}))}function v(R,h){return[{usr:R.state,key:R.key,idx:h},p(R)]}function b(R,h,g){return!d.length||(d.call({action:R,location:h,retry:g}),!1)}function U(R){f=R;var h=a();l=h[0],m=h[1],E.call({action:f,location:m})}function y(R,h){var g=H.Push,A=w(R,h);function x(){y(R,h)}if(b(g,A,x)){var V=v(A,l+1),j=V[0],$=V[1];try{o.pushState(j,"",$)}catch{r.location.assign($)}U(g)}}function P(R,h){var g=H.Replace,A=w(R,h);function x(){P(R,h)}if(b(g,A,x)){var V=v(A,l),j=V[0],$=V[1];o.replaceState(j,"",$),U(g)}}function L(R){o.go(R)}var C={get action(){return f},get location(){return m},createHref:p,push:y,replace:P,go:L,back:function(){L(-1)},forward:function(){L(1)},listen:function(h){return E.push(h)},block:function(h){var g=d.push(h);return d.length===1&&r.addEventListener(de,me),function(){g(),d.length||r.removeEventListener(de,me)}}};return C}function Pn(e){e===void 0&&(e={});var t=e,n=t.window,r=n===void 0?document.defaultView:n,o=r.history;function a(){var h=fe(r.location.hash.substr(1)),g=h.pathname,A=g===void 0?"/":g,x=h.search,V=x===void 0?"":x,j=h.hash,$=j===void 0?"":j,T=o.state||{};return[T.idx,re({pathname:A,search:V,hash:$,state:T.usr||null,key:T.key||"default"})]}var s=null;function c(){if(s)d.call(s),s=null;else{var h=H.Pop,g=a(),A=g[0],x=g[1];if(d.length)if(A!=null){var V=l-A;V&&(s={action:h,location:x,retry:function(){C(V*-1)}},C(V))}else process.env.NODE_ENV!=="production"&&Y(!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 y(h)}}r.addEventListener(ct,c),r.addEventListener(vn,function(){var h=a(),g=h[1];X(g)!==X(m)&&c()});var f=H.Pop,i=a(),l=i[0],m=i[1],E=oe(),d=oe();l==null&&(l=0,o.replaceState(z({},o.state,{idx:l}),""));function p(){var h=document.querySelector("base"),g="";if(h&&h.getAttribute("href")){var A=r.location.href,x=A.indexOf("#");g=x===-1?A:A.slice(0,x)}return g}function w(h){return p()+"#"+(typeof h=="string"?h:X(h))}function v(h,g){return g===void 0&&(g=null),re(z({pathname:m.pathname,hash:"",search:""},typeof h=="string"?fe(h):h,{state:g,key:ye()}))}function b(h,g){return[{usr:h.state,key:h.key,idx:g},w(h)]}function U(h,g,A){return!d.length||(d.call({action:h,location:g,retry:A}),!1)}function y(h){f=h;var g=a();l=g[0],m=g[1],E.call({action:f,location:m})}function P(h,g){var A=H.Push,x=v(h,g);function V(){P(h,g)}if(process.env.NODE_ENV!=="production"&&Y(x.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.push("+JSON.stringify(h)+")"),U(A,x,V)){var j=b(x,l+1),$=j[0],T=j[1];try{o.pushState($,"",T)}catch{r.location.assign(T)}y(A)}}function L(h,g){var A=H.Replace,x=v(h,g);function V(){L(h,g)}if(process.env.NODE_ENV!=="production"&&Y(x.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.replace("+JSON.stringify(h)+")"),U(A,x,V)){var j=b(x,l),$=j[0],T=j[1];o.replaceState($,"",T),y(A)}}function C(h){o.go(h)}var R={get action(){return f},get location(){return m},createHref:w,push:P,replace:L,go:C,back:function(){C(-1)},forward:function(){C(1)},listen:function(g){return E.push(g)},block:function(g){var A=d.push(g);return d.length===1&&r.addEventListener(de,me),function(){A(),d.length||r.removeEventListener(de,me)}}};return R}function it(e){e===void 0&&(e={});var t=e,n=t.initialEntries,r=n===void 0?["/"]:n,o=t.initialIndex,a=r.map(function(y){var P=re(z({pathname:"/",search:"",hash:"",state:null,key:ye()},typeof y=="string"?fe(y):y));return process.env.NODE_ENV!=="production"&&Y(P.pathname.charAt(0)==="/","Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: "+JSON.stringify(y)+")"),P}),s=ft(o??a.length-1,0,a.length-1),c=H.Pop,f=a[s],i=oe(),l=oe();function m(y){return typeof y=="string"?y:X(y)}function E(y,P){return P===void 0&&(P=null),re(z({pathname:f.pathname,search:"",hash:""},typeof y=="string"?fe(y):y,{state:P,key:ye()}))}function d(y,P,L){return!l.length||(l.call({action:y,location:P,retry:L}),!1)}function p(y,P){c=y,f=P,i.call({action:c,location:f})}function w(y,P){var L=H.Push,C=E(y,P);function R(){w(y,P)}process.env.NODE_ENV!=="production"&&Y(f.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.push("+JSON.stringify(y)+")"),d(L,C,R)&&(s+=1,a.splice(s,a.length,C),p(L,C))}function v(y,P){var L=H.Replace,C=E(y,P);function R(){v(y,P)}process.env.NODE_ENV!=="production"&&Y(f.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.replace("+JSON.stringify(y)+")"),d(L,C,R)&&(a[s]=C,p(L,C))}function b(y){var P=ft(s+y,0,a.length-1),L=H.Pop,C=a[P];function R(){b(y)}d(L,C,R)&&(s=P,p(L,C))}var U={get index(){return s},get action(){return c},get location(){return f},createHref:m,push:w,replace:v,go:b,back:function(){b(-1)},forward:function(){b(1)},listen:function(P){return i.push(P)},block:function(P){return l.push(P)}};return U}function ft(e,t,n){return Math.min(Math.max(e,t),n)}function me(e){e.preventDefault(),e.returnValue=""}function oe(){var e=[];return{get length(){return e.length},push:function(n){return e.push(n),function(){e=e.filter(function(r){return r!==n})}},call:function(n){e.forEach(function(r){return r&&r(n)})}}}function ye(){return Math.random().toString(36).substr(2,8)}function X(e){var t=e.pathname,n=t===void 0?"/":t,r=e.search,o=r===void 0?"":r,a=e.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 fe(e){var t={};if(e){var n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));var r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}const lt=Symbol();function En(){const e=u.inject(lt);if(!e)throw new ee;return e}const ht=Symbol("isRouterRouteSymbol");function bn(e){return typeof e=="object"&&e!==null&&ht in e}function Sn(e,t){function n(v,b,U){if(typeof v=="object"){const P={...e.params,...v};return t(e.name,P,b)}const y={...e.params,[v]:b};return t(e.name,y,U)}const r=(...v)=>{const b=new URLSearchParams(e.query);b.set(...v),n({},{query:b})},o=(...v)=>{const b=new URLSearchParams(e.query);b.append(...v),n({},{query:b})},a=(...v)=>{const b=new URLSearchParams(e.query);b.delete(...v),n({},{query:b})},{id:s,matched:c,matches:f,name:i,hash:l,href:m}=u.toRefs(e),E=u.computed({get(){return new Proxy(e.params,{set(v,b,U){return n(b,U),!0}})},set(v){n(v)}}),d=u.computed({get(){return new Proxy(e.query,{get(v,b,U){switch(b){case"append":return o;case"set":return r;case"delete":return a;default:return Reflect.get(v,b,U)}}})},set(v){n({},{query:v})}}),p=u.computed({get(){return new Proxy(e.state,{set(v,b,U){return n({},{state:{...e.state,[b]:U}}),!0}})},set(v){n({},{state:v})}});return u.reactive({id:s,matched:c,matches:f,state:p,query:d,hash:l,params:E,name:i,href:m,update:n,[ht]:!0})}const pt=Symbol();function kn(e,t){const n=u.reactive({...e}),r=s=>{Object.assign(n,{[pt]:!1,...s})},o=n,a=Sn(o,t);return{currentRoute:o,routerRoute:a,updateRoute:r}}function _(e){return!e.startsWith("http")?xn(e):An(e)}function An(e){const{protocol:t,host:n,pathname:r,search:o,searchParams:a,hash:s}=new URL(e,e);return{protocol:t,host:n,pathname:r,search:o,searchParams:a,hash:s}}function xn(e){const{pathname:t,search:n,searchParams:r,hash:o}=new URL(e,"https://localhost");return{pathname:t,search:n,searchParams:r,hash:o}}function Un(e){return t=>{const{host:n}=_(t);return!(n===void 0||n===e)}}function Ln({mode:e,listener:t}){const n=Cn(e),r=(f,i)=>{if(i!=null&&i.replace){n.replace(f,i.state);return}n.push(f,i==null?void 0:i.state)},o=()=>{const f=X(n.location);n.replace(f)};let a;return{...n,update:r,refresh:o,startListening:()=>{a==null||a(),a=n.listen(t)},stopListening:()=>{a==null||a()}}}function Cn(e="auto"){switch(e){case"auto":return Ue()?ut():it();case"browser":return ut();case"memory":return it();case"hash":return Pn();default:const t=e;throw new Error(`Switch is not exhaustive for mode: ${t}`)}}class ge{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 dt extends Error{constructor(){super("Uncaught CallbackContextAbortError");O(this,"response");this.response={status:"ABORT"}}}class ae extends Error{constructor(n){super("Uncaught CallbackContextPushError");O(this,"response");this.response={status:"PUSH",to:n}}}class Re extends Error{constructor(n){super("Uncaught CallbackContextRejectionError");O(this,"response");this.response={status:"REJECT",type:n}}}function Bn(e,t){const n=new ge;return e.matches.forEach((r,o)=>{r.onBeforeRouteEnter&&Le(e,t,o)&&te(r.onBeforeRouteEnter).forEach(a=>n.onBeforeRouteEnter.add(a)),r.onBeforeRouteUpdate&&Be(e,t,o)&&te(r.onBeforeRouteUpdate).forEach(a=>n.onBeforeRouteUpdate.add(a))}),t.matches.forEach((r,o)=>{r.onBeforeRouteLeave&&Ce(e,t,o)&&te(r.onBeforeRouteLeave).forEach(a=>n.onBeforeRouteLeave.add(a))}),n}function Vn(e,t){const n=new ge;return e.matches.forEach((r,o)=>{r.onAfterRouteEnter&&Le(e,t,o)&&te(r.onAfterRouteEnter).forEach(a=>n.onAfterRouteEnter.add(a)),r.onAfterRouteUpdate&&Be(e,t,o)&&te(r.onAfterRouteUpdate).forEach(a=>n.onAfterRouteUpdate.add(a))}),t.matches.forEach((r,o)=>{r.onAfterRouteLeave&&Ce(e,t,o)&&te(r.onAfterRouteLeave).forEach(a=>n.onAfterRouteLeave.add(a))}),n}function mt(){return{reject:o=>{throw new Re(o)},push:(...o)=>{throw new ae(o)},replace:(o,a,s)=>{if(N(o)){const i=a??{};throw new ae([o,{...i,replace:!0}])}const c=a,f=s??{};throw new ae([o,c,{...f,replace:!0}])},abort:()=>{throw new dt}}}function Nn(){const{reject:e,push:t,replace:n,abort:r}=mt();async function o({to:s,from:c,hooks:f}){const{global:i,component:l}=f,m=Bn(s,c),E=[...i.onBeforeRouteEnter,...m.onBeforeRouteEnter,...i.onBeforeRouteUpdate,...m.onBeforeRouteUpdate,...l.onBeforeRouteUpdate,...i.onBeforeRouteLeave,...m.onBeforeRouteLeave,...l.onBeforeRouteLeave];try{const d=E.map(p=>p(s,{from:c,reject:e,push:t,replace:n,abort:r}));await Promise.all(d)}catch(d){if(d instanceof ae||d instanceof Re||d instanceof dt)return d.response;throw d}return{status:"SUCCESS"}}async function a({to:s,from:c,hooks:f}){const{global:i,component:l}=f,m=Vn(s,c),E=[...l.onAfterRouteLeave,...m.onAfterRouteLeave,...i.onAfterRouteLeave,...l.onAfterRouteUpdate,...m.onAfterRouteUpdate,...i.onAfterRouteUpdate,...l.onAfterRouteEnter,...m.onAfterRouteEnter,...i.onAfterRouteEnter];try{const d=E.map(p=>p(s,{from:c,reject:e,push:t,replace:n}));await Promise.all(d)}catch(d){if(d instanceof ae||d instanceof Re)return d.response;throw d}return{status:"SUCCESS"}}return{runBeforeRouteHooks:o,runAfterRouteHooks:a}}const Le=(e,t,n)=>{var a;const r=e.matches,o=(t==null?void 0:t.matches)??[];return r.length<n||r[n].id!==((a=o[n])==null?void 0:a.id)},Ce=(e,t,n)=>{var a;const r=e.matches,o=(t==null?void 0:t.matches)??[];return r.length<n||r[n].id!==((a=o[n])==null?void 0:a.id)},Be=(e,t,n)=>{var r;return e.matches[n].id===((r=t==null?void 0:t.matches[n])==null?void 0:r.id)};function yt(e){switch(e){case"onBeforeRouteEnter":case"onAfterRouteEnter":return Le;case"onBeforeRouteUpdate":case"onAfterRouteUpdate":return Be;case"onBeforeRouteLeave":case"onAfterRouteLeave":return Ce;default:throw new Error(`Switch is not exhaustive for lifecycle: ${e}`)}}function jn(){const e={global:new ge,component:new ge};function t({lifecycle:r,timing:o,depth:a,hook:s}){const c=yt(r),f=e[o][r],i=(l,m)=>{if(c(l,m.from,a))return s(l,m)};return f.add(i),()=>f.delete(i)}function n({lifecycle:r,timing:o,depth:a,hook:s}){const c=yt(r),f=e[o][r],i=(l,m)=>{if(c(l,m.from,a))return s(l,m)};return f.add(i),()=>f.delete(i)}return{...e,addBeforeRouteHook:t,addAfterRouteHook:n}}const gt=Symbol();function Hn(){const e=jn();return{onBeforeRouteEnter:c=>e.addBeforeRouteHook({lifecycle:"onBeforeRouteEnter",hook:c,timing:"global",depth:0}),onBeforeRouteUpdate:c=>e.addBeforeRouteHook({lifecycle:"onBeforeRouteUpdate",hook:c,timing:"global",depth:0}),onBeforeRouteLeave:c=>e.addBeforeRouteHook({lifecycle:"onBeforeRouteLeave",hook:c,timing:"global",depth:0}),onAfterRouteEnter:c=>e.addAfterRouteHook({lifecycle:"onAfterRouteEnter",hook:c,timing:"global",depth:0}),onAfterRouteUpdate:c=>e.addAfterRouteHook({lifecycle:"onAfterRouteUpdate",hook:c,timing:"global",depth:0}),onAfterRouteLeave:c=>e.addAfterRouteHook({lifecycle:"onAfterRouteLeave",hook:c,timing:"global",depth:0}),hooks:e}}function $n(e){return u.defineComponent(()=>()=>u.h("h1",e),{name:e,props:[]})}function Ve(e){const t=new URLSearchParams(e);return{get:(...n)=>t.get(...n),getAll:(...n)=>t.getAll(...n),set:(...n)=>{t.set(...n)},append:(...n)=>{t.append(...n)},delete:(...n)=>{t.delete(...n)},toString:(...n)=>t.toString(...n),forEach:(...n)=>{t.forEach(...n)},entries:(...n)=>t.entries(...n),keys:(...n)=>t.keys(...n),values:(...n)=>t.values(...n),has:(...n)=>t.has(...n),size:t.size,sort:()=>{t.sort()},[Symbol.iterator]:()=>t[Symbol.iterator]()}}function Rt(){let e=0;return()=>(++e).toString()}const Ne=Rt();function qn({rejections:e}){const t=a=>{const s={...e};return u.markRaw(s[a]??$n(a))},n=a=>{const s=u.markRaw(t(a)),c={id:Ne(),component:s,meta:{},state:{}};return{id:c.id,matched:c,matches:[c],name:a,query:Ve(""),params:{},state:{},href:"/",hash:"",[pt]:!0}},r=a=>{if(!a){o.value=null;return}const s=t(a);o.value={type:a,component:s}},o=u.ref(null);return{setRejection:r,rejection:o,getRejectionRoute:n}}class _n extends Error{constructor(){super("initialUrl must be set if window.location is unavailable")}}function Mn(e){if(e)return e;if(Ue())return window.location.toString();throw new _n}function je(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Tn(e,t){const n=Array.from(e.matchAll(t));if(n.length===0)return[e];let r=0;const o=n.reduce((s,c)=>{const f=je(e.slice(r,c.index));f.length&&s.push(f);const[i]=c;return s.push(i),r=c.index+i.length,s},[]),a=e.slice(r);return a&&o.push(a),o}function Dn(e){const t=wt(e.path.value);return new RegExp(`^${t}$`,"i")}function In(e){const t=new URLSearchParams(e.query.value);return Array.from(t.entries()).filter(([,n])=>!$e(n)).map(([n,r])=>{const o=wt(r);return new RegExp(`${je(n)}=${o}(&|$)`,"i")})}function wt(e){return Tn(e,new RegExp(Wn,"g")).map(t=>t.startsWith(J)?vt(t):je(t)).join("")}function vt(e){return[On,Fn].reduce((t,n)=>n(t),e)}const Wn=`\\${J}\\??([\\w-_]+)\\${Q}`,He=`\\${J}\\?([\\w-_]+)\\${Q}`,Pt=`\\${J}([\\w-_]+)\\${Q}`;function On(e){return e.replace(new RegExp(He,"g"),".*")}function $e(e){return new RegExp(He,"g").test(e)}function Fn(e){return e.replace(new RegExp(Pt,"g"),".+")}function we(e){const[t]=ve(e,new RegExp(He,"g")),[n]=ve(e,new RegExp(Pt,"g"));return t??n}function ve(e,t){return Array.from(e.matchAll(t)).flatMap(([,...r])=>r.map(o=>F(o)?o:""))}function qe(e,t){const n=new RegExp(`\\${J}(\\??[\\w-_]+)\\${Q}`,"g");return Array.from(e.matchAll(n)).reduce((o,[a,s])=>{const c=we(a);if(!c)return o;const f=Rn(t,c);return ne([c],o),o[s]=f,o},{})}function Pe(e,t){return{value:e,params:qe(e,t)}}function Jn(e,t){return F(t)?e.map(n=>{const r=`${t}${n.path.value}`;return{...n,path:Pe(r,n.path.params)}}):e}function Et(e){return!!e&&typeof e=="object"}const Ee=!0;function Qn(e,t,n){if(Et(e)&&t in e){const r=e[t];return typeof r=="string"?ue(r,n,Ee):r}return ue(void 0,n,Ee)}function bt(e,t){const n={};for(const[r,o]of Object.entries(e)){const a=Qn(t,r,o);n[r]=a}return n}function zn(e,t,n){if(Et(e)&&t in e){const r=e[t];return ie(r,n,Ee)}return ie(void 0,n,Ee)}const Gn=(e,t)=>{const n={};for(const[r,o]of Object.entries(e)){const a=zn(t,r,o);n[r]=a}return n};class Kn extends Error{constructor(t){super(`Invalid Name "${t}": Router does not support multiple routes with the same name. All name names must be unique.`)}}function Yn(e){const t=e.map(({name:n})=>n);for(const n of t)if(Ze(t,n)>1)throw new Kn(n)}function Xn(){const e=u.reactive(new Map),t=Ue()?s():null,n=c=>{e.set(c,!1),t==null||t.observe(c)},r=c=>{e.delete(c),t==null||t.unobserve(c)},o=()=>{t==null||t.disconnect()},a=c=>e.get(c)??!1;function s(){return new IntersectionObserver(c=>{c.forEach(f=>{e.set(f.target,f.isIntersecting)})})}return{observe:n,unobserve:r,disconnect:o,isElementVisible:a}}const St=Symbol("visibilityObserver");function Zn(e){const t=u.inject(St);if(!t)throw new ee;return u.watch(e,(r,o)=>{r&&t.observe(r),o&&t.unobserve(o)},{immediate:!0}),{isElementVisible:u.computed(()=>e.value?t.isElementVisible(e.value):!1)}}class er extends Error{constructor(t){super(`Route not found: "${t}"`)}}function kt(e,t,n){const r=xt(t,n),[o]=ve(e,r);return o}function At(e,t){if(!t)return e;const{name:n,param:r,value:o}=t,a=xt(e,n);return ve(e,a).reduce((c,f)=>f===void 0?c:c.replace(f,()=>ie(o,r,n.startsWith("?"))),e)}function xt(e,t){const n=[tr,nr,vt].reduce((r,o)=>o(r,t),e);return new RegExp(n,"g")}function tr(e,t){if(!t.startsWith("?"))return e;const n=new RegExp(`\\${J}\\${t}\\${Q}`,"g");return e.replace(n,"(.*)")}function nr(e,t){if(t.startsWith("?"))return e;const n=new RegExp(`\\${J}${t}\\${Q}`,"g");return e.replace(n,"(.+)")}function Ut({protocol:e,host:t,pathname:n,search:r,searchParams:o,hash:a}){const s=new URL("https://localhost");e&&(s.protocol=e),t&&(s.host=t),n&&(s.pathname=n),o?s.search=new URLSearchParams(o).toString():r&&(s.search=r),a&&(s.hash=a);const c=s.toString().replace(/^https:\/\/localhost\/*/,"/");return ke(c)}function _e(...e){const t=new URLSearchParams;for(const n of e){const r=new URLSearchParams(n);for(const[o,a]of r.entries())t.append(o,a)}return t}function rr(e,t={}){const{params:n={},query:r}=t,o=sr(e.query,n),a=_e(o,r),s=ar(e.path,n),c=he(e.hash.value??t.hash).value,f=or(e.host,n),{protocol:i,host:l}=_(f);return Ut({protocol:i,host:l,pathname:s,searchParams:a,hash:c})}function or(e,t){const n=e.value&&!e.value.startsWith("http")?`https://${e.value}`:e.value;return Object.entries(e.params).reduce((r,[o,a])=>{const s=we(`${J}${o}${Q}`);return s?At(r,{name:o,param:a,value:t[s]}):r},n)}function ar(e,t){return Object.entries(e.params).reduce((n,[r,o])=>{const a=we(`${J}${r}${Q}`);return a?At(n,{name:r,param:o,value:t[a]}):n},e.value)}function sr(e,t){const n=new URLSearchParams(e.value);if(!e.value)return n;for(const[r,o]of Array.from(n.entries())){const a=we(o);if(!a)continue;const c=ie(t[a],e.params[a],$e(o)),f=t[a]===void 0&&c==="";$e(o)&&f?n.delete(r,o):n.set(r,c)}return n}const cr=(e,t)=>{try{Me(e,t)}catch{return!1}return!0},Me=(e,t)=>{const{pathname:n,search:r}=_(t);return{...ur(e.path,n),...ir(e.query,r)}};function ur(e,t){const n={},r=decodeURIComponent(t);for(const[o,a]of Object.entries(e.params)){const s=o.startsWith("?"),c=s?o.slice(1):o,f=kt(r,e.value,o),i=ue(f,a,s);n[c]=i}return n}function ir(e,t){const n={},r=new URLSearchParams(t);for(const[o,a]of Object.entries(e.params)){const s=o.startsWith("?"),c=s?o.slice(1):o,f=r.get(c)??void 0,i=ue(f,a,s);n[c]=i}return n}function fr(e,t={},n={}){const r=rr(e,{params:t,query:n.query,hash:n.hash}),{search:o,hash:a}=_(r);return{id:e.id,matched:e.matched,matches:e.matches,name:e.name,query:Ve(o),params:Me(e,r),state:bt(e.state,n.state),hash:a,href:r}}const lr=e=>"name"in e.matched&&!!e.matched.name,hr=(e,t)=>{const{pathname:n}=_(t);return Dn(e).test(n)},pr=(e,t)=>{const{search:n}=_(t);return In(e).every(o=>o.test(n))},Te=(e,t)=>{const{hash:n}=_(t),{value:r}=e.hash;return r===void 0||`#${r.toLowerCase()}`===n.toLowerCase()};function dr(e){const{searchParams:t,pathname:n}=_(e),r=-1,o=1;return(a,s)=>{const c=Ct(a,t),f=Lt(a,n),i=Ct(s,t),l=Lt(s,n);return a.depth>s.depth?r:a.depth<s.depth?o:c+f>i+l?r:c+f<i+l?o:Te(a,e)?r:Te(s,e)?o:0}}function Lt(e,t){const n=Object.keys(e.path.params).filter(o=>o.startsWith("?")).map(o=>o),r=n.filter(o=>kt(t,e.path.value,o)===void 0);return n.length-r.length}function Ct(e,t){const n=new URLSearchParams(t),r=new URLSearchParams(e.query.value),o=Array.from(r.keys()),a=o.filter(s=>!n.has(s));return o.length-a.length}const mr=[lr,hr,pr,Te,cr];function yr(e,t){const n=dr(t);return e.filter(r=>mr.every(o=>o(r,t))).sort(n)}function gr(e,t,n){const r=yr(e,t);if(!r.length)return;const[o]=r,{searchParams:a,hash:s}=_(t);return{id:o.id,matched:o.matched,matches:o.matches,name:o.name,query:Ve(a),params:Me(o,t),state:bt(o.state,n),hash:s,href:ke(t)}}function Bt(e,t){const n=typeof e=="string"?_(e):e,r=typeof t=="string"?_(t):t,o=n.searchParams??new URLSearchParams(n.search),a=r.searchParams??new URLSearchParams(r.search);return Ut({protocol:F(r.protocol)?r.protocol:n.protocol,host:F(r.host)?r.host:n.host,pathname:F(r.pathname)?r.pathname:n.pathname,searchParams:_e(a,o),hash:F(r.hash)?r.hash:n.hash})}function Rr(e,t){const n=rn(e)?e.flat():e,r=Jn(n,t==null?void 0:t.base);Yn(r);const o=Rt(),a=Ar(),s=Xn(),c=Ln({mode:t==null?void 0:t.historyMode,listener:({location:S})=>{const B=X(S);U(B,{state:S.state,replace:!0})}}),{runBeforeRouteHooks:f,runAfterRouteHooks:i}=Nn(),{hooks:l,onBeforeRouteEnter:m,onAfterRouteUpdate:E,onBeforeRouteLeave:d,onAfterRouteEnter:p,onBeforeRouteUpdate:w,onAfterRouteLeave:v}=Hn();function b(S,B={}){return gr(r,S,B)}async function U(S,B={}){const G=o();if(c.stopListening(),Zt(S)){c.update(S,B);return}const D=b(S,B)??g("NotFound"),M={...x},K=await f({to:D,from:M,hooks:l});switch(K.status){case"ABORT":return;case"PUSH":c.update(S,B),await P(...K.to);return;case"REJECT":c.update(S,B),R(K.type);break;case"SUCCESS":c.update(S,B),R(null);break;default:throw new Error(`Switch is not exhaustive for before hook response status: ${JSON.stringify(K)}`)}const Qe=G;a.setProps(D).then(W=>{if(Qe===G)switch(W.status){case"SUCCESS":break;case"PUSH":P(...W.to);break;case"REJECT":R(W.type);break;default:const ze=W;throw new Error(`Switch is not exhaustive for prop store response status: ${JSON.stringify(ze)}`)}}),j(D);const I=await i({to:D,from:M,hooks:l});switch(I.status){case"PUSH":await P(...I.to);break;case"REJECT":R(I.type);break;case"SUCCESS":break;default:const W=I;throw new Error(`Switch is not exhaustive for after hook response status: ${JSON.stringify(W)}`)}c.startListening()}const y=(S,B={},G={})=>{const D=r.find(M=>M.name===S);if(!D)throw new er(String(S));return fr(D,B,G)},P=(S,B,G)=>{if(N(S)){const I={...B},W=Bt(S,{searchParams:I.query,hash:I.hash});return U(W,I)}if(typeof S=="string"){const I={...G},W={...B},ze=y(S,W,I),{replace:Ir,state:Wr}=I;return P(ze,{replace:Ir,state:Wr})}const{replace:D,...M}={...B},K=Gn({...S.matched.state},{...S.state,...M.state}),Qe=Bt(S.href,{searchParams:M.query,hash:M.hash});return U(Qe,{replace:D,state:K})},L=(S,B,G)=>{if(N(S)){const M={...B,replace:!0};return P(S,M)}if(typeof S=="string"){const M={...G,replace:!0},K={...B};return P(S,K,M)}const D={...B,replace:!0};return P(S,D)},C=S=>{R(S)},{setRejection:R,rejection:h,getRejectionRoute:g}=qn(t??{}),A=g("NotFound"),{currentRoute:x,routerRoute:V,updateRoute:j}=kn(A,P);c.startListening();const $=Mn(t==null?void 0:t.initialUrl),T=c.location.state,{host:Xt}=_($),Zt=Un(Xt);let en=!1;async function tn(){en||(await U($,{replace:!0,state:T}),en=!0)}function Dr(S){S.component("RouterView",zt),S.component("RouterLink",Ft),S.provide(lt,h),S.provide(gt,l),S.provide(Dt,a),S.provide(St,s),S.provide(Xe,nn),tn()}const nn={route:V,resolve:y,find:b,push:P,replace:L,reject:C,refresh:c.refresh,forward:c.forward,back:c.back,go:c.go,install:Dr,isExternal:Zt,onBeforeRouteEnter:m,onAfterRouteUpdate:E,onBeforeRouteLeave:d,onAfterRouteEnter:p,onBeforeRouteUpdate:w,onAfterRouteLeave:v,prefetch:t==null?void 0:t.prefetch,start:tn};return nn}function De(e,t){return{value:e,params:qe(e,t)}}function Vt(e,t){return{value:e,params:qe(e,t)}}function wr(e){return se(e)&&typeof e.hash=="string"}function Nt(e){return e===void 0?he():wr(e)?e:he(e)}function jt(e){return e===void 0?"":e}function vr(e){return se(e)&&typeof e.value=="string"}function Ht(e){return e===void 0?Pe("",{}):vr(e)?e:Pe(e,{})}function Pr(e){return se(e)&&typeof e.value=="string"}function $t(e){return e===void 0?De("",{}):Pr(e)?e:De(e,{})}function Z(e){const t=Ne(),n=jt(e.name),r=Ht(e.path),o=$t(e.query),a=Nt(e.hash),s=e.meta??{},c=pn(e)?e.state:{},f=u.markRaw({id:t,meta:{},state:{},...e}),i={id:t,matched:f,matches:[f],name:n,path:r,query:o,hash:a,meta:s,state:c,depth:1,host:Vt("",{}),prefetch:e.prefetch},l=et(e)?tt(e.parent,i):i;return ne(l.path.params,l.query.params),l}const be={template:"<div>This is component</div>"},Ie=Z({name:"parentA",path:"/parentA/[paramA]"}),qt=Z({parent:Ie,name:"parentA.childA",path:"/[?paramB]"}),Er=Z({parent:Ie,name:"parentA.childB",path:"/[paramD]",component:be}),br=Z({parent:qt,name:"parentA.childA.grandChildA",path:"/[paramC]",component:be});Z({name:"parentB",path:"/parentB",component:be}),Z({name:"parentC",path:"/",component:be});const Sr="lazy",kr={components:!0,props:!1};function Se(e){return["eager","lazy"].includes(e)}function _t({routerPrefetch:e,routePrefetch:t,linkPrefetch:n},r){const o=We(n,r),a=We(t,r),s=We(e,r),c=[o,a,s,kr[r],Sr].reduce((f,i)=>Se(f)?f:f===!0&&Se(i)?i:f===!0&&!Se(i)?f:f===void 0?i:f,void 0);return Se(c)?c:!1}function We(e,t){return se(e)?e[t]:e}function Mt(e){return typeof e=="object"&&e!==null&&"then"in e}function Tt(e){try{const t=e();return Mt(t)?t.catch(n=>n):t}catch(t){return t}}const Dt=Symbol();function Ar(){const e=u.reactive(new Map),{push:t,replace:n,reject:r}=mt(),o=(m,E,d)=>E.matches.filter(p=>_t({...d,routePrefetch:p.prefetch},"props")===m).flatMap(p=>i(p)).reduce((p,{id:w,name:v,props:b})=>{if(!b)return p;const U=f(w,v,E),y=Tt(()=>b(E,{push:t,replace:n,reject:r}));return p[U]=y,p},{}),a=m=>{Object.entries(m).forEach(([E,d])=>{e.set(E,d)})},s=async m=>{const E=m.matches.flatMap(i),d=[],p=[];for(const{id:w,name:v,props:b}of E){if(!b)continue;const U=f(w,v,m);if(d.push(U),!e.has(U)){const y=Tt(()=>b(m,{push:t,replace:n,reject:r}));e.set(U,y)}p.push((async()=>{const y=await e.get(U);if(y instanceof Error)throw y})())}l(d);try{return await Promise.all(p),{status:"SUCCESS"}}catch(w){if(w instanceof ae||w instanceof Re)return w.response;throw w}},c=(m,E,d)=>{const p=f(m,E,d);return e.get(p)};function f(m,E,d){return[m,E,d.id,JSON.stringify(d.params)].join("-")}function i(m){return xe(m)?Object.entries(m.props??{}).map(([E,d])=>({id:m.id,name:E,props:d})):Ae(m)?[{id:m.id,name:"default",props:m.props}]:[]}function l(m){for(const E in e.keys())m.includes(E)||e.delete(E)}return{getPrefetchProps:o,setPrefetchProps:a,getProps:c,setProps:s}}function It(){const e=u.inject(Dt);if(!e)throw new ee;return e}const xr=u.defineAsyncComponent(()=>new Promise(e=>{e({default:{template:"foo"}})}));function Wt(e){return e.name===xr.name&&"__asyncLoader"in e}function Ur(e){const t=new Map,n=u.ref(),{getPrefetchProps:r,setPrefetchProps:o}=It(),{isElementVisible:a}=Zn(n),s=()=>{const f=Array.from(t.values()).reduce((i,l)=>(Object.assign(i,l),i),{});o(f)};u.watch(()=>u.toValue(e),({route:f,...i})=>{t.clear(),f&&c("eager",f,i)},{immediate:!0}),u.watch(a,f=>{const{route:i,...l}=u.toValue(e);!i||!f||c("lazy",i,l)},{immediate:!0});function c(f,i,l){Lr(f,i,l),t.has(f)||t.set(f,r(f,i,l))}return{element:n,commit:s}}function Lr(e,t,n){t.matches.forEach(r=>{_t({...n,routePrefetch:r.prefetch},"components")===e&&(Ae(r)&&Wt(r.component)&&r.component.__asyncLoader(),xe(r)&&Object.values(r.components).forEach(a=>{Wt(a)&&a.__asyncLoader()}))})}function Oe(e,t,{exact:n}={}){return bn(e)?t===void 0?!0:n?e.matched.name===t:e.matches.map(r=>r.name).includes(t):!1}function Ot(e,t={},n={}){const r=le(),o=u.computed(()=>{const p=u.toValue(e);return typeof p!="string"?p:N(p)?r.find(p,u.toValue(n)):r.resolve(p,u.toValue(t),u.toValue(n))}),a=u.computed(()=>{if(o.value)return o.value.href;const p=u.toValue(e);if(N(p))return p;console.error(new Error("Failed to resolve route in RouterLink."))}),s=u.computed(()=>Oe(r.route)&&r.route.matches.some(p=>{var w;return p.id===((w=o.value)==null?void 0:w.id)})),c=u.computed(()=>{var p;return r.route.id===((p=o.value)==null?void 0:p.id)}),f=u.computed(()=>!!a.value&&r.isExternal(a.value)),i=u.computed(()=>{const p=u.toValue(e);return typeof p!="string"||N(p)?u.toValue(t):u.toValue(n)}),{element:l,commit:m}=Ur(()=>({route:o.value,routerPrefetch:r.prefetch,linkPrefetch:i.value.prefetch})),E=p=>{m();const w={replace:(p==null?void 0:p.replace)??i.value.replace,query:_e(i.value.query,p==null?void 0:p.query),hash:(p==null?void 0:p.hash)??i.value.hash,state:{...i.value.state,...p==null?void 0:p.state}},v=u.toValue(e);return N(v)||typeof v=="object"?r.push(v,w):r.push(v,u.toValue(t),w)};return{element:l,route:o,href:a,isMatch:s,isExactMatch:c,isExternal:f,push:E,replace:p=>E({...p,replace:!0})}}const Cr=["href"],Ft=u.defineComponent({__name:"routerLink",props:{to:{},prefetch:{type:[Boolean,String,Object],default:void 0},query:{},hash:{},replace:{type:Boolean},state:{}},setup(e){const t=e,n=le(),r=u.computed(()=>E(t.to)),o=u.computed(()=>d(t.to)),a=u.computed(()=>{const{to:w,...v}=t;return v}),{element:s,isMatch:c,isExactMatch:f,isExternal:i,push:l}=Ot(()=>typeof t.to=="function"?t.to(n.resolve):t.to,a),m=u.computed(()=>({"router-link--match":c.value,"router-link--exact-match":f.value}));function E(w){if(typeof w=="function"){const v=w(n.resolve);return E(v)}return N(w)?n.find(w):w}function d(w){if(typeof w=="function"){const v=w(n.resolve);return d(v)}return N(w)?w:w==null?void 0:w.href}function p(w){w.preventDefault(),l()}return(w,v)=>(u.openBlock(),u.createElementBlock("a",{ref_key:"element",ref:s,href:o.value,class:u.normalizeClass(["router-link",m.value]),onClick:p},[u.renderSlot(w.$slots,"default",u.normalizeProps(u.guardReactiveProps({route:r.value,isMatch:u.unref(c),isExactMatch:u.unref(f),isExternal:u.unref(i)})))],10,Cr))}});function Jt(e,t){const n=le();function r(){if(!e)return;if(!Oe(n.route,e,t))throw new Ye(e,n.route.name)}return u.watch(n.route,r,{immediate:!0,deep:!0}),n.route}const Qt=Symbol();function Fe(){return u.inject(Qt,0)}function Br(e,t){return u.defineComponent({name:"PropsWrapper",expose:[],setup(){const n=t(),r=u.getCurrentInstance();return()=>n instanceof Error?"":Mt(n)?r!=null&&r.suspense?u.h(Nr(e,n)):u.h(Vr(e,n)):u.h(e,n)}})}function Vr(e,t){return u.defineComponent({name:"AsyncPropsWrapper",expose:[],setup(){const n=u.ref();return(async()=>n.value=await t)(),()=>n.value instanceof Error?"":n.value?u.h(e,n.value):""}})}function Nr(e,t){return u.defineComponent({name:"SuspenseAsyncPropsWrapper",expose:[],async setup(){const n=await t;return()=>u.h(e,n)}})}const zt=u.defineComponent({__name:"routerView",props:{name:{default:"default"}},setup(e){const t=Jt(),n=En(),r=Fe(),{getProps:o}=It(),a=u.resolveComponent("RouterView",!0);u.provide(Qt,r+1);const s=u.computed(()=>{if(n.value)return n.value.component;const i=t.matches.at(r);if(!i)return null;const l=c(i),m=o(i.id,e.name,t);return l?m?Br(l,()=>m):l:null});function c(i){return f(i)[e.name]}function f(i){return xe(i)?i.components:Ae(i)?{default:i.component}:typeof a=="string"?{}:{default:a}}return(i,l)=>s.value?u.renderSlot(i.$slots,"default",u.normalizeProps(u.mergeProps({key:0},{route:u.unref(t),component:s.value,rejection:u.unref(n)})),()=>[(u.openBlock(),u.createBlock(u.resolveDynamicComponent(s.value)))]):u.createCommentVNode("",!0)}});function Gt(){const e=u.inject(gt);if(!e)throw new ee;return e}function Kt(e){return t=>{const n=Fe(),o=Gt().addBeforeRouteHook({lifecycle:e,hook:t,depth:n,timing:"component"});return u.onUnmounted(o),o}}function Je(e){return t=>{const n=Fe(),o=Gt().addAfterRouteHook({lifecycle:e,hook:t,depth:n,timing:"component"});return u.onUnmounted(o),o}}const jr=Kt("onBeforeRouteUpdate"),Hr=Kt("onBeforeRouteLeave"),$r=Je("onAfterRouteEnter"),qr=Je("onAfterRouteUpdate"),_r=Je("onAfterRouteLeave");function Mr(e){return se(e)&&typeof e.value=="string"}function Yt(e){return Mr(e)?e:Vt(e,{})}function Tr(e){const t=Ne(),n=jt(e.name),r=Ht(e.path),o=$t(e.query),a=Nt(e.hash),s=e.meta??{},c=hn(e)?Yt(e.host):Yt(""),f=u.markRaw({id:t,meta:{},state:{},...e}),i={id:t,matched:f,matches:[f],name:n,host:c,path:r,query:o,hash:a,meta:s,depth:1,state:{}},l=et(e)?tt(e.parent,i):i;return ne(l.path.params,l.query.params,l.host.params),l}k.DuplicateParamsError=Ge,k.MetaPropertyConflict=Ke,k.RouterLink=Ft,k.RouterNotInstalledError=ee,k.RouterView=zt,k.UseRouteInvalidError=Ye,k.asUrl=ke,k.createExternalRoute=Tr,k.createParam=st,k.createRoute=Z,k.createRouter=Rr,k.isRoute=Oe,k.isUrl=N,k.onAfterRouteEnter=$r,k.onAfterRouteLeave=qr,k.onAfterRouteUpdate=_r,k.onBeforeRouteLeave=jr,k.onBeforeRouteUpdate=Hr,k.path=Pe,k.query=De,k.useLink=Ot,k.useRoute=Jt,k.useRouter=le,k.withDefault=gn,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(k,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],i):(k=typeof globalThis<"u"?globalThis:k||self,i(k["@kitbag/router"]={},k.Vue))})(this,function(k,i){"use strict";var Qr=Object.defineProperty;var zr=(k,i,N)=>i in k?Qr(k,i,{enumerable:!0,configurable:!0,writable:!0,value:N}):k[i]=N;var W=(k,i,N)=>zr(k,typeof i!="symbol"?i+"":i,N);function N(e){return typeof e!="string"?!1:/^(https?:\/\/|\/).*/g.test(e)}function ke(e){return N(e)?e:`/${e}`}class Ke extends Error{constructor(t){super(`Invalid Param "${t}": Router does not support multiple params by the same name. All param names must be unique.`)}}class Ye extends Error{constructor(t){super(`Child property on meta for ${t} conflicts with the parent meta.`)}}class ee extends Error{constructor(){super("Router not installed")}}class Xe extends Error{constructor(t,n){super(`useRoute called with incorrect route. Given ${t}, expected ${n}`)}}const Ze=Symbol();function le(){const e=i.inject(Ze);if(!e)throw new ee;return e}function se(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function sn(e){return e.every(t=>Array.isArray(t))}function F(e){return typeof e=="string"&&e.length>0}function he(e){return{value:F(e)?e.replace(/^#*/,""):void 0}}function cn(e,t){return he(`${e.value??""}${t.value??""}`)}function un(e,t){return fn(e,t),{...e,...t}}function fn(e,t){const n=Object.keys(e).find(r=>r in t&&typeof t[r]!=typeof e[r]);if(n)throw new Ye(n)}function te(e){return Array.isArray(e)?e:[e]}function et(e,t){return e.filter(n=>t===n).length}function ne(...e){const t=e.flatMap(n=>Array.isArray(n)?n:Object.keys(n).map(ln));for(const n of t)if(et(t,n)>1)throw new Ke(n)}function ln(e){return e.startsWith("?")?e.slice(1):e}function hn(e,t){return ne(e.params,t.params),{value:`${e.value}${t.value}`,params:{...e.params,...t.params}}}function pn(e,t){return ne(e.params,t.params),{value:[e.value,t.value].filter(F).join("&"),params:{...e.params,...t.params}}}function dn(e,t){return ne(e,t),{...e,...t}}function mn(e){return"host"in e&&!!e.host}function tt(e){return"parent"in e&&!!e.parent}function Ae(e){return"component"in e&&!!e.component}function xe(e){return"components"in e&&!!e.components}function yn(e){return"state"in e&&!!e.state}function nt(e,t){return{...t,path:hn(e.path,t.path),query:pn(e.query,t.query),meta:un(e.meta,t.meta),state:dn(e.state,t.state),hash:cn(e.hash,t.hash),matches:[...e.matches,t.matched],host:e.host,depth:e.depth+1}}function Ue(){return typeof window<"u"&&typeof window.document<"u"}class ce extends Error{}const J="[",Q="]";function gn(e){return e!==String&&e!==Boolean&&e!==Number&&e!==Date}function Rn(e){return typeof e=="function"&&gn(e)}function pe(e){return typeof e=="object"&&"get"in e&&typeof e.get=="function"&&"set"in e&&typeof e.set=="function"}function wn(e){return pe(e)&&e.defaultValue!==void 0}function vn(e,t){return ct(e,t)}function Pn(e,t){return e[t]??String}const q={invalid:e=>{throw new ce(e)}},En={get:e=>e,set:(e,{invalid:t})=>{if(typeof e!="string")throw t();return e}},rt={get:(e,{invalid:t})=>{if(e==="true")return!0;if(e==="false")return!1;throw t()},set:(e,{invalid:t})=>{if(typeof e!="boolean")throw t();return e.toString()}},ot={get:(e,{invalid:t})=>{const n=Number(e);if(isNaN(n))throw t();return n},set:(e,{invalid:t})=>{if(typeof e!="number")throw t();return e.toString()}},at={get:(e,{invalid:t})=>{const n=new Date(e);if(isNaN(n.getTime()))throw t();return n},set:(e,{invalid:t})=>{if(typeof e!="object"||!(e instanceof Date))throw t();return e.toISOString()}},st={get:(e,{invalid:t})=>{try{return JSON.parse(e)}catch{throw t()}},set:(e,{invalid:t})=>{try{return JSON.stringify(e)}catch{throw t()}}};function ie(e,t,n=!1){if(e===void 0||!F(e)){if(wn(t))return t.defaultValue;if(n)return;throw new ce}if(t===String)return En.get(e,q);if(t===Boolean)return rt.get(e,q);if(t===Number)return ot.get(e,q);if(t===Date)return at.get(e,q);if(t===JSON)return st.get(e,q);if(Rn(t))return t(e,q);if(pe(t))return t.get(e,q);if(t instanceof RegExp){if(t.test(e))return e;throw new ce}return e}function ue(e,t,n=!1){if(e===void 0){if(n)return"";throw new ce}if(t===Boolean)return rt.set(e,q);if(t===Number)return ot.set(e,q);if(t===Date)return at.set(e,q);if(t===JSON)return st.set(e,q);if(pe(t))return t.set(e,q);try{return e.toString()}catch{throw new ce}}function ct(e,t){return pe(e)?{...e,defaultValue:t??e.defaultValue}:{get:n=>ie(n,e),set:n=>ue(n,e),defaultValue:t}}function z(){return z=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},z.apply(this,arguments)}var H;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(H||(H={}));var re=process.env.NODE_ENV!=="production"?function(e){return Object.freeze(e)}:function(e){return e};function Y(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}var de="beforeunload",bn="hashchange",it="popstate";function ut(e){e===void 0&&(e={});var t=e,n=t.window,r=n===void 0?document.defaultView:n,o=r.history;function a(){var R=r.location,h=R.pathname,g=R.search,A=R.hash,U=o.state||{};return[U.idx,re({pathname:h,search:g,hash:A,state:U.usr||null,key:U.key||"default"})]}var s=null;function c(){if(s)m.call(s),s=null;else{var R=H.Pop,h=a(),g=h[0],A=h[1];if(m.length)if(g!=null){var U=l-g;U&&(s={action:R,location:A,retry:function(){L(U*-1)}},L(U))}else process.env.NODE_ENV!=="production"&&Y(!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 x(R)}}r.addEventListener(it,c);var f=H.Pop,u=a(),l=u[0],p=u[1],E=oe(),m=oe();l==null&&(l=0,o.replaceState(z({},o.state,{idx:l}),""));function d(R){return typeof R=="string"?R:X(R)}function w(R,h){return h===void 0&&(h=null),re(z({pathname:p.pathname,hash:"",search:""},typeof R=="string"?fe(R):R,{state:h,key:ye()}))}function v(R,h){return[{usr:R.state,key:R.key,idx:h},d(R)]}function b(R,h,g){return!m.length||(m.call({action:R,location:h,retry:g}),!1)}function x(R){f=R;var h=a();l=h[0],p=h[1],E.call({action:f,location:p})}function y(R,h){var g=H.Push,A=w(R,h);function U(){y(R,h)}if(b(g,A,U)){var V=v(A,l+1),j=V[0],$=V[1];try{o.pushState(j,"",$)}catch{r.location.assign($)}x(g)}}function P(R,h){var g=H.Replace,A=w(R,h);function U(){P(R,h)}if(b(g,A,U)){var V=v(A,l),j=V[0],$=V[1];o.replaceState(j,"",$),x(g)}}function L(R){o.go(R)}var C={get action(){return f},get location(){return p},createHref:d,push:y,replace:P,go:L,back:function(){L(-1)},forward:function(){L(1)},listen:function(h){return E.push(h)},block:function(h){var g=m.push(h);return m.length===1&&r.addEventListener(de,me),function(){g(),m.length||r.removeEventListener(de,me)}}};return C}function Sn(e){e===void 0&&(e={});var t=e,n=t.window,r=n===void 0?document.defaultView:n,o=r.history;function a(){var h=fe(r.location.hash.substr(1)),g=h.pathname,A=g===void 0?"/":g,U=h.search,V=U===void 0?"":U,j=h.hash,$=j===void 0?"":j,T=o.state||{};return[T.idx,re({pathname:A,search:V,hash:$,state:T.usr||null,key:T.key||"default"})]}var s=null;function c(){if(s)m.call(s),s=null;else{var h=H.Pop,g=a(),A=g[0],U=g[1];if(m.length)if(A!=null){var V=l-A;V&&(s={action:h,location:U,retry:function(){C(V*-1)}},C(V))}else process.env.NODE_ENV!=="production"&&Y(!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 y(h)}}r.addEventListener(it,c),r.addEventListener(bn,function(){var h=a(),g=h[1];X(g)!==X(p)&&c()});var f=H.Pop,u=a(),l=u[0],p=u[1],E=oe(),m=oe();l==null&&(l=0,o.replaceState(z({},o.state,{idx:l}),""));function d(){var h=document.querySelector("base"),g="";if(h&&h.getAttribute("href")){var A=r.location.href,U=A.indexOf("#");g=U===-1?A:A.slice(0,U)}return g}function w(h){return d()+"#"+(typeof h=="string"?h:X(h))}function v(h,g){return g===void 0&&(g=null),re(z({pathname:p.pathname,hash:"",search:""},typeof h=="string"?fe(h):h,{state:g,key:ye()}))}function b(h,g){return[{usr:h.state,key:h.key,idx:g},w(h)]}function x(h,g,A){return!m.length||(m.call({action:h,location:g,retry:A}),!1)}function y(h){f=h;var g=a();l=g[0],p=g[1],E.call({action:f,location:p})}function P(h,g){var A=H.Push,U=v(h,g);function V(){P(h,g)}if(process.env.NODE_ENV!=="production"&&Y(U.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.push("+JSON.stringify(h)+")"),x(A,U,V)){var j=b(U,l+1),$=j[0],T=j[1];try{o.pushState($,"",T)}catch{r.location.assign(T)}y(A)}}function L(h,g){var A=H.Replace,U=v(h,g);function V(){L(h,g)}if(process.env.NODE_ENV!=="production"&&Y(U.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.replace("+JSON.stringify(h)+")"),x(A,U,V)){var j=b(U,l),$=j[0],T=j[1];o.replaceState($,"",T),y(A)}}function C(h){o.go(h)}var R={get action(){return f},get location(){return p},createHref:w,push:P,replace:L,go:C,back:function(){C(-1)},forward:function(){C(1)},listen:function(g){return E.push(g)},block:function(g){var A=m.push(g);return m.length===1&&r.addEventListener(de,me),function(){A(),m.length||r.removeEventListener(de,me)}}};return R}function ft(e){e===void 0&&(e={});var t=e,n=t.initialEntries,r=n===void 0?["/"]:n,o=t.initialIndex,a=r.map(function(y){var P=re(z({pathname:"/",search:"",hash:"",state:null,key:ye()},typeof y=="string"?fe(y):y));return process.env.NODE_ENV!=="production"&&Y(P.pathname.charAt(0)==="/","Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: "+JSON.stringify(y)+")"),P}),s=lt(o??a.length-1,0,a.length-1),c=H.Pop,f=a[s],u=oe(),l=oe();function p(y){return typeof y=="string"?y:X(y)}function E(y,P){return P===void 0&&(P=null),re(z({pathname:f.pathname,search:"",hash:""},typeof y=="string"?fe(y):y,{state:P,key:ye()}))}function m(y,P,L){return!l.length||(l.call({action:y,location:P,retry:L}),!1)}function d(y,P){c=y,f=P,u.call({action:c,location:f})}function w(y,P){var L=H.Push,C=E(y,P);function R(){w(y,P)}process.env.NODE_ENV!=="production"&&Y(f.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.push("+JSON.stringify(y)+")"),m(L,C,R)&&(s+=1,a.splice(s,a.length,C),d(L,C))}function v(y,P){var L=H.Replace,C=E(y,P);function R(){v(y,P)}process.env.NODE_ENV!=="production"&&Y(f.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.replace("+JSON.stringify(y)+")"),m(L,C,R)&&(a[s]=C,d(L,C))}function b(y){var P=lt(s+y,0,a.length-1),L=H.Pop,C=a[P];function R(){b(y)}m(L,C,R)&&(s=P,d(L,C))}var x={get index(){return s},get action(){return c},get location(){return f},createHref:p,push:w,replace:v,go:b,back:function(){b(-1)},forward:function(){b(1)},listen:function(P){return u.push(P)},block:function(P){return l.push(P)}};return x}function lt(e,t,n){return Math.min(Math.max(e,t),n)}function me(e){e.preventDefault(),e.returnValue=""}function oe(){var e=[];return{get length(){return e.length},push:function(n){return e.push(n),function(){e=e.filter(function(r){return r!==n})}},call:function(n){e.forEach(function(r){return r&&r(n)})}}}function ye(){return Math.random().toString(36).substr(2,8)}function X(e){var t=e.pathname,n=t===void 0?"/":t,r=e.search,o=r===void 0?"":r,a=e.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 fe(e){var t={};if(e){var n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));var r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}const ht=Symbol();function kn(){const e=i.inject(ht);if(!e)throw new ee;return e}const pt=Symbol("isRouterRouteSymbol");function An(e){return typeof e=="object"&&e!==null&&pt in e}function xn(e,t){function n(v,b,x){if(typeof v=="object"){const P={...e.params,...v};return t(e.name,P,b)}const y={...e.params,[v]:b};return t(e.name,y,x)}const r=(...v)=>{const b=new URLSearchParams(e.query);b.set(...v),n({},{query:b})},o=(...v)=>{const b=new URLSearchParams(e.query);b.append(...v),n({},{query:b})},a=(...v)=>{const b=new URLSearchParams(e.query);b.delete(...v),n({},{query:b})},{id:s,matched:c,matches:f,name:u,hash:l,href:p}=i.toRefs(e),E=i.computed({get(){return new Proxy(e.params,{set(v,b,x){return n(b,x),!0}})},set(v){n(v)}}),m=i.computed({get(){return new Proxy(e.query,{get(v,b,x){switch(b){case"append":return o;case"set":return r;case"delete":return a;default:return Reflect.get(v,b,x)}}})},set(v){n({},{query:v})}}),d=i.computed({get(){return new Proxy(e.state,{set(v,b,x){return n({},{state:{...e.state,[b]:x}}),!0}})},set(v){n({},{state:v})}});return i.reactive({id:s,matched:c,matches:f,state:d,query:m,hash:l,params:E,name:u,href:p,update:n,[pt]:!0})}const dt=Symbol();function Un(e,t){const n=i.reactive({...e}),r=s=>{Object.assign(n,{[dt]:!1,...s})},o=n,a=xn(o,t);return{currentRoute:o,routerRoute:a,updateRoute:r}}function _(e){return!e.startsWith("http")?Cn(e):Ln(e)}function Ln(e){const{protocol:t,host:n,pathname:r,search:o,searchParams:a,hash:s}=new URL(e,e);return{protocol:t,host:n,pathname:r,search:o,searchParams:a,hash:s}}function Cn(e){const{pathname:t,search:n,searchParams:r,hash:o}=new URL(e,"https://localhost");return{pathname:t,search:n,searchParams:r,hash:o}}function Bn(e){return t=>{const{host:n}=_(t);return!(n===void 0||n===e)}}function Vn({mode:e,listener:t}){const n=Nn(e),r=(f,u)=>{if(u!=null&&u.replace){n.replace(f,u.state);return}n.push(f,u==null?void 0:u.state)},o=()=>{const f=X(n.location);n.replace(f)};let a;return{...n,update:r,refresh:o,startListening:()=>{a==null||a(),a=n.listen(t)},stopListening:()=>{a==null||a()}}}function Nn(e="auto"){switch(e){case"auto":return Ue()?ut():ft();case"browser":return ut();case"memory":return ft();case"hash":return Sn();default:const t=e;throw new Error(`Switch is not exhaustive for mode: ${t}`)}}class ge{constructor(){W(this,"onBeforeRouteEnter",new Set);W(this,"onBeforeRouteUpdate",new Set);W(this,"onBeforeRouteLeave",new Set);W(this,"onAfterRouteEnter",new Set);W(this,"onAfterRouteUpdate",new Set);W(this,"onAfterRouteLeave",new Set)}}class mt extends Error{constructor(){super("Uncaught CallbackContextAbortError");W(this,"response");this.response={status:"ABORT"}}}class ae extends Error{constructor(n){super("Uncaught CallbackContextPushError");W(this,"response");this.response={status:"PUSH",to:n}}}class Re extends Error{constructor(n){super("Uncaught CallbackContextRejectionError");W(this,"response");this.response={status:"REJECT",type:n}}}function jn(e,t){const n=new ge;return e.matches.forEach((r,o)=>{r.onBeforeRouteEnter&&Le(e,t,o)&&te(r.onBeforeRouteEnter).forEach(a=>n.onBeforeRouteEnter.add(a)),r.onBeforeRouteUpdate&&Be(e,t,o)&&te(r.onBeforeRouteUpdate).forEach(a=>n.onBeforeRouteUpdate.add(a))}),t.matches.forEach((r,o)=>{r.onBeforeRouteLeave&&Ce(e,t,o)&&te(r.onBeforeRouteLeave).forEach(a=>n.onBeforeRouteLeave.add(a))}),n}function Hn(e,t){const n=new ge;return e.matches.forEach((r,o)=>{r.onAfterRouteEnter&&Le(e,t,o)&&te(r.onAfterRouteEnter).forEach(a=>n.onAfterRouteEnter.add(a)),r.onAfterRouteUpdate&&Be(e,t,o)&&te(r.onAfterRouteUpdate).forEach(a=>n.onAfterRouteUpdate.add(a))}),t.matches.forEach((r,o)=>{r.onAfterRouteLeave&&Ce(e,t,o)&&te(r.onAfterRouteLeave).forEach(a=>n.onAfterRouteLeave.add(a))}),n}function yt(){return{reject:o=>{throw new Re(o)},push:(...o)=>{throw new ae(o)},replace:(o,a,s)=>{if(N(o)){const u=a??{};throw new ae([o,{...u,replace:!0}])}const c=a,f=s??{};throw new ae([o,c,{...f,replace:!0}])},abort:()=>{throw new mt}}}function $n(){const{reject:e,push:t,replace:n,abort:r}=yt();async function o({to:s,from:c,hooks:f}){const{global:u,component:l}=f,p=jn(s,c),E=[...u.onBeforeRouteEnter,...p.onBeforeRouteEnter,...u.onBeforeRouteUpdate,...p.onBeforeRouteUpdate,...l.onBeforeRouteUpdate,...u.onBeforeRouteLeave,...p.onBeforeRouteLeave,...l.onBeforeRouteLeave];try{const m=E.map(d=>d(s,{from:c,reject:e,push:t,replace:n,abort:r}));await Promise.all(m)}catch(m){if(m instanceof ae||m instanceof Re||m instanceof mt)return m.response;throw m}return{status:"SUCCESS"}}async function a({to:s,from:c,hooks:f}){const{global:u,component:l}=f,p=Hn(s,c),E=[...l.onAfterRouteLeave,...p.onAfterRouteLeave,...u.onAfterRouteLeave,...l.onAfterRouteUpdate,...p.onAfterRouteUpdate,...u.onAfterRouteUpdate,...l.onAfterRouteEnter,...p.onAfterRouteEnter,...u.onAfterRouteEnter];try{const m=E.map(d=>d(s,{from:c,reject:e,push:t,replace:n}));await Promise.all(m)}catch(m){if(m instanceof ae||m instanceof Re)return m.response;throw m}return{status:"SUCCESS"}}return{runBeforeRouteHooks:o,runAfterRouteHooks:a}}const Le=(e,t,n)=>{var a;const r=e.matches,o=(t==null?void 0:t.matches)??[];return r.length<n||r[n].id!==((a=o[n])==null?void 0:a.id)},Ce=(e,t,n)=>{var a;const r=e.matches,o=(t==null?void 0:t.matches)??[];return r.length<n||r[n].id!==((a=o[n])==null?void 0:a.id)},Be=(e,t,n)=>{var r;return e.matches[n].id===((r=t==null?void 0:t.matches[n])==null?void 0:r.id)};function gt(e){switch(e){case"onBeforeRouteEnter":case"onAfterRouteEnter":return Le;case"onBeforeRouteUpdate":case"onAfterRouteUpdate":return Be;case"onBeforeRouteLeave":case"onAfterRouteLeave":return Ce;default:throw new Error(`Switch is not exhaustive for lifecycle: ${e}`)}}function qn(){const e={global:new ge,component:new ge};function t({lifecycle:r,timing:o,depth:a,hook:s}){const c=gt(r),f=e[o][r],u=(l,p)=>{if(c(l,p.from,a))return s(l,p)};return f.add(u),()=>f.delete(u)}function n({lifecycle:r,timing:o,depth:a,hook:s}){const c=gt(r),f=e[o][r],u=(l,p)=>{if(c(l,p.from,a))return s(l,p)};return f.add(u),()=>f.delete(u)}return{...e,addBeforeRouteHook:t,addAfterRouteHook:n}}const Rt=Symbol();function _n(){const e=qn();return{onBeforeRouteEnter:c=>e.addBeforeRouteHook({lifecycle:"onBeforeRouteEnter",hook:c,timing:"global",depth:0}),onBeforeRouteUpdate:c=>e.addBeforeRouteHook({lifecycle:"onBeforeRouteUpdate",hook:c,timing:"global",depth:0}),onBeforeRouteLeave:c=>e.addBeforeRouteHook({lifecycle:"onBeforeRouteLeave",hook:c,timing:"global",depth:0}),onAfterRouteEnter:c=>e.addAfterRouteHook({lifecycle:"onAfterRouteEnter",hook:c,timing:"global",depth:0}),onAfterRouteUpdate:c=>e.addAfterRouteHook({lifecycle:"onAfterRouteUpdate",hook:c,timing:"global",depth:0}),onAfterRouteLeave:c=>e.addAfterRouteHook({lifecycle:"onAfterRouteLeave",hook:c,timing:"global",depth:0}),hooks:e}}function Mn(e){return i.defineComponent(()=>()=>i.h("h1",e),{name:e,props:[]})}function Ve(e){const t=new URLSearchParams(e);return{get:(...n)=>t.get(...n),getAll:(...n)=>t.getAll(...n),set:(...n)=>{t.set(...n)},append:(...n)=>{t.append(...n)},delete:(...n)=>{t.delete(...n)},toString:(...n)=>t.toString(...n),forEach:(...n)=>{t.forEach(...n)},entries:(...n)=>t.entries(...n),keys:(...n)=>t.keys(...n),values:(...n)=>t.values(...n),has:(...n)=>t.has(...n),size:t.size,sort:()=>{t.sort()},[Symbol.iterator]:()=>t[Symbol.iterator]()}}function wt(){let e=0;return()=>(++e).toString()}const Ne=wt();function Tn({rejections:e}){const t=a=>{const s={...e};return i.markRaw(s[a]??Mn(a))},n=a=>{const s=i.markRaw(t(a)),c={id:Ne(),component:s,meta:{},state:{}};return{id:c.id,matched:c,matches:[c],name:a,query:Ve(""),params:{},state:{},href:"/",hash:"",[dt]:!0}},r=a=>{if(!a){o.value=null;return}const s=t(a);o.value={type:a,component:s}},o=i.ref(null);return{setRejection:r,rejection:o,getRejectionRoute:n}}class Dn extends Error{constructor(){super("initialUrl must be set if window.location is unavailable")}}function In(e){if(e)return e;if(Ue())return window.location.toString();throw new Dn}function je(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function On(e,t){const n=Array.from(e.matchAll(t));if(n.length===0)return[e];let r=0;const o=n.reduce((s,c)=>{const f=je(e.slice(r,c.index));f.length&&s.push(f);const[u]=c;return s.push(u),r=c.index+u.length,s},[]),a=e.slice(r);return a&&o.push(a),o}function Wn(e){const t=vt(e.path.value);return new RegExp(`^${t}$`,"i")}function Fn(e){const t=new URLSearchParams(e.query.value);return Array.from(t.entries()).filter(([,n])=>!$e(n)).map(([n,r])=>{const o=vt(r);return new RegExp(`${je(n)}=${o}(&|$)`,"i")})}function vt(e){return On(e,new RegExp(Jn,"g")).map(t=>t.startsWith(J)?Pt(t):je(t)).join("")}function Pt(e){return[Qn,zn].reduce((t,n)=>n(t),e)}const Jn=`\\${J}\\??([\\w-_]+)\\${Q}`,He=`\\${J}\\?([\\w-_]+)\\${Q}`,Et=`\\${J}([\\w-_]+)\\${Q}`;function Qn(e){return e.replace(new RegExp(He,"g"),".*")}function $e(e){return new RegExp(He,"g").test(e)}function zn(e){return e.replace(new RegExp(Et,"g"),".+")}function we(e){const[t]=ve(e,new RegExp(He,"g")),[n]=ve(e,new RegExp(Et,"g"));return t??n}function ve(e,t){return Array.from(e.matchAll(t)).flatMap(([,...r])=>r.map(o=>F(o)?o:""))}function qe(e,t){const n=new RegExp(`\\${J}(\\??[\\w-_]+)\\${Q}`,"g");return Array.from(e.matchAll(n)).reduce((o,[a,s])=>{const c=we(a);if(!c)return o;const f=Pn(t,c);return ne([c],o),o[s]=f,o},{})}function Pe(e,t){return{value:e,params:qe(e,t)}}function Gn(e,t){return F(t)?e.map(n=>{const r=`${t}${n.path.value}`;return{...n,path:Pe(r,n.path.params)}}):e}function bt(e){return!!e&&typeof e=="object"}const Ee=!0;function Kn(e,t,n){if(bt(e)&&t in e){const r=e[t];return typeof r=="string"?ie(r,n,Ee):r}return ie(void 0,n,Ee)}function St(e,t){const n={};for(const[r,o]of Object.entries(e)){const a=Kn(t,r,o);n[r]=a}return n}function Yn(e,t,n){if(bt(e)&&t in e){const r=e[t];return ue(r,n,Ee)}return ue(void 0,n,Ee)}const kt=(e,t)=>{const n={};for(const[r,o]of Object.entries(e)){const a=Yn(t,r,o);n[r]=a}return n};class Xn extends Error{constructor(t){super(`Invalid Name "${t}": Router does not support multiple routes with the same name. All name names must be unique.`)}}function Zn(e){const t=e.map(({name:n})=>n);for(const n of t)if(et(t,n)>1)throw new Xn(n)}function er(){const e=i.reactive(new Map),t=Ue()?s():null,n=c=>{e.set(c,!1),t==null||t.observe(c)},r=c=>{e.delete(c),t==null||t.unobserve(c)},o=()=>{t==null||t.disconnect()},a=c=>e.get(c)??!1;function s(){return new IntersectionObserver(c=>{c.forEach(f=>{e.set(f.target,f.isIntersecting)})})}return{observe:n,unobserve:r,disconnect:o,isElementVisible:a}}const At=Symbol("visibilityObserver");function tr(e){const t=i.inject(At);if(!t)throw new ee;return i.watch(e,(r,o)=>{r&&t.observe(r),o&&t.unobserve(o)},{immediate:!0}),i.onUnmounted(()=>{e.value&&t.unobserve(e.value)}),{isElementVisible:i.computed(()=>e.value?t.isElementVisible(e.value):!1)}}class nr extends Error{constructor(t){super(`Route not found: "${t}"`)}}function xt(e,t,n){const r=Lt(t,n),[o]=ve(e,r);return o}function Ut(e,t){if(!t)return e;const{name:n,param:r,value:o}=t,a=Lt(e,n);return ve(e,a).reduce((c,f)=>f===void 0?c:c.replace(f,()=>ue(o,r,n.startsWith("?"))),e)}function Lt(e,t){const n=[rr,or,Pt].reduce((r,o)=>o(r,t),e);return new RegExp(n,"g")}function rr(e,t){if(!t.startsWith("?"))return e;const n=new RegExp(`\\${J}\\${t}\\${Q}`,"g");return e.replace(n,"(.*)")}function or(e,t){if(t.startsWith("?"))return e;const n=new RegExp(`\\${J}${t}\\${Q}`,"g");return e.replace(n,"(.+)")}function Ct({protocol:e,host:t,pathname:n,search:r,searchParams:o,hash:a}){const s=new URL("https://localhost");e&&(s.protocol=e),t&&(s.host=t),n&&(s.pathname=n),o?s.search=new URLSearchParams(o).toString():r&&(s.search=r),a&&(s.hash=a);const c=s.toString().replace(/^https:\/\/localhost\/*/,"/");return ke(c)}function _e(...e){const t=new URLSearchParams;for(const n of e){const r=new URLSearchParams(n);for(const[o,a]of r.entries())t.append(o,a)}return t}function ar(e,t={}){const{params:n={},query:r}=t,o=ir(e.query,n),a=_e(o,r),s=cr(e.path,n),c=he(e.hash.value??t.hash).value,f=sr(e.host,n),{protocol:u,host:l}=_(f);return Ct({protocol:u,host:l,pathname:s,searchParams:a,hash:c})}function sr(e,t){const n=e.value&&!e.value.startsWith("http")?`https://${e.value}`:e.value;return Object.entries(e.params).reduce((r,[o,a])=>{const s=we(`${J}${o}${Q}`);return s?Ut(r,{name:o,param:a,value:t[s]}):r},n)}function cr(e,t){return Object.entries(e.params).reduce((n,[r,o])=>{const a=we(`${J}${r}${Q}`);return a?Ut(n,{name:r,param:o,value:t[a]}):n},e.value)}function ir(e,t){const n=new URLSearchParams(e.value);if(!e.value)return n;for(const[r,o]of Array.from(n.entries())){const a=we(o);if(!a)continue;const c=ue(t[a],e.params[a],$e(o)),f=t[a]===void 0&&c==="";$e(o)&&f?n.delete(r,o):n.set(r,c)}return n}const ur=(e,t)=>{try{Me(e,t)}catch{return!1}return!0},Me=(e,t)=>{const{pathname:n,search:r}=_(t);return{...fr(e.path,n),...lr(e.query,r)}};function fr(e,t){const n={},r=decodeURIComponent(t);for(const[o,a]of Object.entries(e.params)){const s=o.startsWith("?"),c=s?o.slice(1):o,f=xt(r,e.value,o),u=ie(f,a,s);n[c]=u}return n}function lr(e,t){const n={},r=new URLSearchParams(t);for(const[o,a]of Object.entries(e.params)){const s=o.startsWith("?"),c=s?o.slice(1):o,f=r.get(c)??void 0,u=ie(f,a,s);n[c]=u}return n}function hr(e,t={},n={}){const r=ar(e,{params:t,query:n.query,hash:n.hash}),{search:o,hash:a}=_(r);return{id:e.id,matched:e.matched,matches:e.matches,name:e.name,query:Ve(o),params:Me(e,r),state:St(e.state,n.state),hash:a,href:r}}const pr=e=>"name"in e.matched&&!!e.matched.name,dr=(e,t)=>{const{pathname:n}=_(t);return Wn(e).test(n)},mr=(e,t)=>{const{search:n}=_(t);return Fn(e).every(o=>o.test(n))},Te=(e,t)=>{const{hash:n}=_(t),{value:r}=e.hash;return r===void 0||`#${r.toLowerCase()}`===n.toLowerCase()};function yr(e){const{searchParams:t,pathname:n}=_(e),r=-1,o=1;return(a,s)=>{const c=Vt(a,t),f=Bt(a,n),u=Vt(s,t),l=Bt(s,n);return a.depth>s.depth?r:a.depth<s.depth?o:c+f>u+l?r:c+f<u+l?o:Te(a,e)?r:Te(s,e)?o:0}}function Bt(e,t){const n=Object.keys(e.path.params).filter(o=>o.startsWith("?")).map(o=>o),r=n.filter(o=>xt(t,e.path.value,o)===void 0);return n.length-r.length}function Vt(e,t){const n=new URLSearchParams(t),r=new URLSearchParams(e.query.value),o=Array.from(r.keys()),a=o.filter(s=>!n.has(s));return o.length-a.length}const gr=[pr,dr,mr,Te,ur];function Rr(e,t){const n=yr(t);return e.filter(r=>gr.every(o=>o(r,t))).sort(n)}function wr(e,t,n){const r=Rr(e,t);if(!r.length)return;const[o]=r,{searchParams:a,hash:s}=_(t);return{id:o.id,matched:o.matched,matches:o.matches,name:o.name,query:Ve(a),params:Me(o,t),state:St(o.state,n),hash:s,href:ke(t)}}function Nt(e,t){const n=typeof e=="string"?_(e):e,r=typeof t=="string"?_(t):t,o=n.searchParams??new URLSearchParams(n.search),a=r.searchParams??new URLSearchParams(r.search);return Ct({protocol:F(r.protocol)?r.protocol:n.protocol,host:F(r.host)?r.host:n.host,pathname:F(r.pathname)?r.pathname:n.pathname,searchParams:_e(a,o),hash:F(r.hash)?r.hash:n.hash})}function vr(e,t){const n=sn(e)?e.flat():e,r=Gn(n,t==null?void 0:t.base);Zn(r);const o=wt(),a=Ur(),s=er(),c=Vn({mode:t==null?void 0:t.historyMode,listener:({location:S})=>{const B=X(S);x(B,{state:S.state,replace:!0})}}),{runBeforeRouteHooks:f,runAfterRouteHooks:u}=$n(),{hooks:l,onBeforeRouteEnter:p,onAfterRouteUpdate:E,onBeforeRouteLeave:m,onAfterRouteEnter:d,onBeforeRouteUpdate:w,onAfterRouteLeave:v}=_n();function b(S,B={}){return wr(r,S,B.state)}async function x(S,B={}){const G=o();if(c.stopListening(),nn(S)){c.update(S,B);return}const D=b(S,B)??g("NotFound"),M={...U},K=await f({to:D,from:M,hooks:l});switch(K.status){case"ABORT":return;case"PUSH":c.update(S,B),await P(...K.to);return;case"REJECT":c.update(S,B),R(K.type);break;case"SUCCESS":c.update(S,B),R(null);break;default:throw new Error(`Switch is not exhaustive for before hook response status: ${JSON.stringify(K)}`)}const Qe=G;a.setProps(D).then(I=>{if(Qe===G)switch(I.status){case"SUCCESS":break;case"PUSH":P(...I.to);break;case"REJECT":R(I.type);break;default:const ze=I;throw new Error(`Switch is not exhaustive for prop store response status: ${JSON.stringify(ze)}`)}}),j(D);const O=await u({to:D,from:M,hooks:l});switch(O.status){case"PUSH":await P(...O.to);break;case"REJECT":R(O.type);break;case"SUCCESS":break;default:const I=O;throw new Error(`Switch is not exhaustive for after hook response status: ${JSON.stringify(I)}`)}c.startListening()}const y=(S,B={},G={})=>{const D=r.find(M=>M.name===S);if(!D)throw new nr(String(S));return hr(D,B,G)},P=(S,B,G)=>{if(N(S)){const O={...B},I=Nt(S,{searchParams:O.query,hash:O.hash});return x(I,O)}if(typeof S=="string"){const{replace:O,...I}={...G},ze={...B},Ge=y(S,ze,I),Jr=kt({...Ge.matched.state},{...Ge.state,...I.state});return x(Ge.href,{replace:O,state:Jr})}const{replace:D,...M}={...B},K=kt({...S.matched.state},{...S.state,...M.state}),Qe=Nt(S.href,{searchParams:M.query,hash:M.hash});return x(Qe,{replace:D,state:K})},L=(S,B,G)=>{if(N(S)){const M={...B,replace:!0};return P(S,M)}if(typeof S=="string"){const M={...G,replace:!0},K={...B};return P(S,K,M)}const D={...B,replace:!0};return P(S,D)},C=S=>{R(S)},{setRejection:R,rejection:h,getRejectionRoute:g}=Tn(t??{}),A=g("NotFound"),{currentRoute:U,routerRoute:V,updateRoute:j}=Un(A,P);c.startListening();const $=In(t==null?void 0:t.initialUrl),T=c.location.state,{host:tn}=_($),nn=Bn(tn);let rn=!1;const{promise:Or,resolve:Wr}=Promise.withResolvers();async function on(){if(rn)return Or;rn=!0,await x($,{replace:!0,state:T}),Wr()}function Fr(S){S.component("RouterView",Yt),S.component("RouterLink",zt),S.provide(ht,h),S.provide(Rt,l),S.provide(Ot,a),S.provide(At,s),S.provide(Ze,an),on()}const an={route:V,resolve:y,find:b,push:P,replace:L,reject:C,refresh:c.refresh,forward:c.forward,back:c.back,go:c.go,install:Fr,isExternal:nn,onBeforeRouteEnter:p,onAfterRouteUpdate:E,onBeforeRouteLeave:m,onAfterRouteEnter:d,onBeforeRouteUpdate:w,onAfterRouteLeave:v,prefetch:t==null?void 0:t.prefetch,start:on};return an}function De(e,t){return{value:e,params:qe(e,t)}}function jt(e,t){return{value:e,params:qe(e,t)}}function Pr(e){return se(e)&&typeof e.hash=="string"}function Ht(e){return e===void 0?he():Pr(e)?e:he(e)}function $t(e){return e===void 0?"":e}function Er(e){return se(e)&&typeof e.value=="string"}function qt(e){return e===void 0?Pe("",{}):Er(e)?e:Pe(e,{})}function br(e){return se(e)&&typeof e.value=="string"}function _t(e){return e===void 0?De("",{}):br(e)?e:De(e,{})}function Z(e){const t=Ne(),n=$t(e.name),r=qt(e.path),o=_t(e.query),a=Ht(e.hash),s=e.meta??{},c=yn(e)?e.state:{},f=i.markRaw({id:t,meta:{},state:{},...e}),u={id:t,matched:f,matches:[f],name:n,path:r,query:o,hash:a,meta:s,state:c,depth:1,host:jt("",{}),prefetch:e.prefetch},l=tt(e)?nt(e.parent,u):u;return ne(l.path.params,l.query.params),l}const be={template:"<div>This is component</div>"},Ie=Z({name:"parentA",path:"/parentA/[paramA]"}),Mt=Z({parent:Ie,name:"parentA.childA",path:"/[?paramB]"}),Sr=Z({parent:Ie,name:"parentA.childB",path:"/[paramD]",component:be}),kr=Z({parent:Mt,name:"parentA.childA.grandChildA",path:"/[paramC]",component:be});Z({name:"parentB",path:"/parentB",component:be}),Z({name:"parentC",path:"/",component:be});const Ar="lazy",xr={components:!0,props:!1};function Se(e){return["eager","lazy","intent"].includes(e)}function Tt({routerPrefetch:e,routePrefetch:t,linkPrefetch:n},r){const o=Oe(n,r),a=Oe(t,r),s=Oe(e,r),c=[o,a,s,xr[r],Ar].reduce((f,u)=>Se(f)?f:f===!0&&Se(u)?u:f===!0&&!Se(u)?f:f===void 0?u:f,void 0);return Se(c)?c:!1}function Oe(e,t){return se(e)?e[t]:e}function Dt(e){return typeof e=="object"&&e!==null&&"then"in e}function It(e){try{const t=e();return Dt(t)?t.catch(n=>n):t}catch(t){return t}}const Ot=Symbol();function Ur(){const e=i.reactive(new Map),{push:t,replace:n,reject:r}=yt(),o=(p,E,m)=>E.matches.filter(d=>Tt({...m,routePrefetch:d.prefetch},"props")===p).flatMap(d=>u(d)).reduce((d,{id:w,name:v,props:b})=>{if(!b)return d;const x=f(w,v,E),y=It(()=>b(E,{push:t,replace:n,reject:r}));return d[x]=y,d},{}),a=p=>{Object.entries(p).forEach(([E,m])=>{e.set(E,m)})},s=async p=>{const E=p.matches.flatMap(u),m=[],d=[];for(const{id:w,name:v,props:b}of E){if(!b)continue;const x=f(w,v,p);if(m.push(x),!e.has(x)){const y=It(()=>b(p,{push:t,replace:n,reject:r}));e.set(x,y)}d.push((async()=>{const y=await e.get(x);if(y instanceof Error)throw y})())}l(m);try{return await Promise.all(d),{status:"SUCCESS"}}catch(w){if(w instanceof ae||w instanceof Re)return w.response;throw w}},c=(p,E,m)=>{const d=f(p,E,m);return e.get(d)};function f(p,E,m){return[p,E,m.id,JSON.stringify(m.params)].join("-")}function u(p){return xe(p)?Object.entries(p.props??{}).map(([E,m])=>({id:p.id,name:E,props:m})):Ae(p)?[{id:p.id,name:"default",props:p.props}]:[]}function l(p){for(const E in e.keys())p.includes(E)||e.delete(E)}return{getPrefetchProps:o,setPrefetchProps:a,getProps:c,setProps:s}}function Wt(){const e=i.inject(Ot);if(!e)throw new ee;return e}const Lr=i.defineAsyncComponent(()=>new Promise(e=>{e({default:{template:"foo"}})}));function Ft(e){return e.name===Lr.name&&"__asyncLoader"in e}function Jt(e,t,n){i.watch(e,(r,o)=>{r&&r.addEventListener(t,n),o&&o.removeEventListener(t,n)},{immediate:!0}),i.onUnmounted(()=>{e.value&&e.value.removeEventListener(t,n)})}function Cr(e){const t=new Map,n=i.ref(),{getPrefetchProps:r,setPrefetchProps:o}=Wt(),{isElementVisible:a}=tr(n),s=()=>{const u=Array.from(t.values()).reduce((l,p)=>(Object.assign(l,p),l),{});o(u)};i.watch(()=>i.toValue(e),({route:u,...l})=>{t.clear(),u&&f("eager",u,l)},{immediate:!0}),i.watch(a,u=>{const{route:l,...p}=i.toValue(e);!l||!u||f("lazy",l,p)},{immediate:!0}),Jt(n,"focusin",c),Jt(n,"mouseover",c);function c(){const{route:u,...l}=i.toValue(e);u&&f("intent",u,l)}function f(u,l,p){Br(u,l,p),t.has(u)||t.set(u,r(u,l,p))}return{element:n,commit:s}}function Br(e,t,n){t.matches.forEach(r=>{Tt({...n,routePrefetch:r.prefetch},"components")===e&&(Ae(r)&&Ft(r.component)&&r.component.__asyncLoader(),xe(r)&&Object.values(r.components).forEach(a=>{Ft(a)&&a.__asyncLoader()}))})}function We(e,t,{exact:n}={}){return An(e)?t===void 0?!0:n?e.matched.name===t:e.matches.map(r=>r.name).includes(t):!1}function Qt(e,t={},n={}){const r=le(),o=i.computed(()=>{const d=i.toValue(e);return typeof d!="string"?d:N(d)?r.find(d,i.toValue(n)):r.resolve(d,i.toValue(t),i.toValue(n))}),a=i.computed(()=>{if(o.value)return o.value.href;const d=i.toValue(e);if(N(d))return d;console.error(new Error("Failed to resolve route in RouterLink."))}),s=i.computed(()=>We(r.route)&&r.route.matches.some(d=>{var w;return d.id===((w=o.value)==null?void 0:w.id)})),c=i.computed(()=>{var d;return r.route.id===((d=o.value)==null?void 0:d.id)}),f=i.computed(()=>!!a.value&&r.isExternal(a.value)),u=i.computed(()=>{const d=i.toValue(e);return typeof d!="string"||N(d)?i.toValue(t):i.toValue(n)}),{element:l,commit:p}=Cr(()=>({route:o.value,routerPrefetch:r.prefetch,linkPrefetch:u.value.prefetch})),E=d=>{p();const w={replace:(d==null?void 0:d.replace)??u.value.replace,query:_e(u.value.query,d==null?void 0:d.query),hash:(d==null?void 0:d.hash)??u.value.hash,state:{...u.value.state,...d==null?void 0:d.state}},v=i.toValue(e);return N(v)||typeof v=="object"?r.push(v,w):r.push(v,i.toValue(t),w)};return{element:l,route:o,href:a,isMatch:s,isExactMatch:c,isExternal:f,push:E,replace:d=>E({...d,replace:!0})}}const Vr=["href"],zt=i.defineComponent({__name:"routerLink",props:{to:{},prefetch:{type:[Boolean,String,Object],default:void 0},query:{},hash:{},replace:{type:Boolean},state:{}},setup(e){const t=e,n=le(),r=i.computed(()=>E(t.to)),o=i.computed(()=>m(t.to)),a=i.computed(()=>{const{to:w,...v}=t;return v}),{element:s,isMatch:c,isExactMatch:f,isExternal:u,push:l}=Qt(()=>typeof t.to=="function"?t.to(n.resolve):t.to,a),p=i.computed(()=>({"router-link--match":c.value,"router-link--exact-match":f.value}));function E(w){if(typeof w=="function"){const v=w(n.resolve);return E(v)}return N(w)?n.find(w):w}function m(w){if(typeof w=="function"){const v=w(n.resolve);return m(v)}return N(w)?w:w==null?void 0:w.href}function d(w){w.preventDefault(),l()}return(w,v)=>(i.openBlock(),i.createElementBlock("a",{ref_key:"element",ref:s,href:o.value,class:i.normalizeClass(["router-link",p.value]),onClick:d},[i.renderSlot(w.$slots,"default",i.normalizeProps(i.guardReactiveProps({route:r.value,isMatch:i.unref(c),isExactMatch:i.unref(f),isExternal:i.unref(u)})))],10,Vr))}});function Gt(e,t){const n=le();function r(){if(!e)return;if(!We(n.route,e,t))throw new Xe(e,n.route.name)}return i.watch(n.route,r,{immediate:!0,deep:!0}),n.route}const Kt=Symbol();function Fe(){return i.inject(Kt,0)}function Nr(e,t){return i.defineComponent({name:"PropsWrapper",expose:[],setup(){const n=t(),r=i.getCurrentInstance();return()=>n instanceof Error?"":Dt(n)?r!=null&&r.suspense?i.h(Hr(e,n)):i.h(jr(e,n)):i.h(e,n)}})}function jr(e,t){return i.defineComponent({name:"AsyncPropsWrapper",expose:[],setup(){const n=i.ref();return(async()=>n.value=await t)(),()=>n.value instanceof Error?"":n.value?i.h(e,n.value):""}})}function Hr(e,t){return i.defineComponent({name:"SuspenseAsyncPropsWrapper",expose:[],async setup(){const n=await t;return()=>i.h(e,n)}})}const Yt=i.defineComponent({__name:"routerView",props:{name:{default:"default"}},setup(e){const t=Gt(),n=kn(),r=Fe(),{getProps:o}=Wt(),a=i.resolveComponent("RouterView",!0);i.provide(Kt,r+1);const s=i.computed(()=>{if(n.value)return n.value.component;const u=t.matches.at(r);if(!u)return null;const l=c(u),p=o(u.id,e.name,t);return l?p?Nr(l,()=>p):l:null});function c(u){return f(u)[e.name]}function f(u){return xe(u)?u.components:Ae(u)?{default:u.component}:typeof a=="string"?{}:{default:a}}return(u,l)=>s.value?i.renderSlot(u.$slots,"default",i.normalizeProps(i.mergeProps({key:0},{route:i.unref(t),component:s.value,rejection:i.unref(n)})),()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(s.value)))]):i.createCommentVNode("",!0)}});function Xt(){const e=i.inject(Rt);if(!e)throw new ee;return e}function Zt(e){return t=>{const n=Fe(),o=Xt().addBeforeRouteHook({lifecycle:e,hook:t,depth:n,timing:"component"});return i.onUnmounted(o),o}}function Je(e){return t=>{const n=Fe(),o=Xt().addAfterRouteHook({lifecycle:e,hook:t,depth:n,timing:"component"});return i.onUnmounted(o),o}}const $r=Zt("onBeforeRouteUpdate"),qr=Zt("onBeforeRouteLeave"),_r=Je("onAfterRouteEnter"),Mr=Je("onAfterRouteUpdate"),Tr=Je("onAfterRouteLeave");function Dr(e){return se(e)&&typeof e.value=="string"}function en(e){return Dr(e)?e:jt(e,{})}function Ir(e){const t=Ne(),n=$t(e.name),r=qt(e.path),o=_t(e.query),a=Ht(e.hash),s=e.meta??{},c=mn(e)?en(e.host):en(""),f=i.markRaw({id:t,meta:{},state:{},...e}),u={id:t,matched:f,matches:[f],name:n,host:c,path:r,query:o,hash:a,meta:s,depth:1,state:{}},l=tt(e)?nt(e.parent,u):u;return ne(l.path.params,l.query.params,l.host.params),l}k.DuplicateParamsError=Ke,k.MetaPropertyConflict=Ye,k.RouterLink=zt,k.RouterNotInstalledError=ee,k.RouterView=Yt,k.UseRouteInvalidError=Xe,k.asUrl=ke,k.createExternalRoute=Ir,k.createParam=ct,k.createRoute=Z,k.createRouter=vr,k.isRoute=We,k.isUrl=N,k.onAfterRouteEnter=_r,k.onAfterRouteLeave=Mr,k.onAfterRouteUpdate=Tr,k.onBeforeRouteLeave=$r,k.onBeforeRouteUpdate=qr,k.path=Pe,k.query=De,k.useLink=Qt,k.useRoute=Gt,k.useRouter=le,k.withDefault=vn,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitbag/router",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.15.0",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/kitbagjs/router/issues"
|
|
7
7
|
},
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"docs:dev": "vitepress dev docs",
|
|
17
17
|
"docs:build": "vitepress build docs",
|
|
18
18
|
"docs:preview": "vitepress preview docs",
|
|
19
|
-
"docs:generate": "typedoc && sleep 5 && node ./scripts/api.js"
|
|
19
|
+
"docs:generate": "vite build && typedoc && sleep 5 && node ./scripts/api.js"
|
|
20
20
|
},
|
|
21
21
|
"type": "module",
|
|
22
22
|
"files": [
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
37
37
|
"@vue/test-utils": "^2.4.6",
|
|
38
38
|
"eslint": "^9.17.0",
|
|
39
|
-
"globals": "^15.
|
|
39
|
+
"globals": "^15.14.0",
|
|
40
40
|
"happy-dom": "^15.11.7",
|
|
41
41
|
"typedoc": "^0.27.5",
|
|
42
|
-
"typedoc-plugin-markdown": "^4.3.
|
|
42
|
+
"typedoc-plugin-markdown": "^4.3.3",
|
|
43
43
|
"typedoc-vitepress-theme": "^1.1.1",
|
|
44
44
|
"typescript": "^5.6.3",
|
|
45
|
-
"vite": "^6.0.
|
|
46
|
-
"vite-plugin-dts": "^4.
|
|
45
|
+
"vite": "^6.0.5",
|
|
46
|
+
"vite-plugin-dts": "^4.4.0",
|
|
47
47
|
"vitepress": "^1.5.0",
|
|
48
48
|
"vitest": "^2.1.6",
|
|
49
49
|
"vue-tsc": "^2.1.10"
|