@kitbag/router 0.15.1 → 0.15.2

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