@kitbag/router 0.17.1 → 0.17.3
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 +58 -112
- package/dist/kitbag-router.js +1773 -1622
- package/dist/kitbag-router.umd.cjs +3 -3
- package/package.json +12 -6
|
@@ -1,4 +1,4 @@
|
|
|
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 so=Object.defineProperty;var co=(A,c,N)=>c in A?so(A,c,{enumerable:!0,configurable:!0,writable:!0,value:N}):A[c]=N;var F=(A,c,N)=>co(A,typeof c!="symbol"?c+"":c,N);function N(e){return typeof e!="string"?!1:/^(https?:\/\/|\/).*/g.test(e)}function Ce(e){return N(e)?e:`/${e}`}class Ze 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 et extends Error{constructor(t){super(`Child property on meta for ${t} conflicts with the parent meta.`)}}class X extends Error{constructor(){super("Router not installed")}}class tt extends Error{constructor(t,r){super(`useRoute called with incorrect route. Given ${t}, expected ${r}`)}}const rt=Symbol();function ye(){const e=c.inject(rt);if(!e)throw new X;return e}function le(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 lr(e,t){return ge(`${e.value??""}${t.value??""}`)}function hr(e,t){return dr(e,t),{...e,...t}}function dr(e,t){const r=Object.keys(e).find(n=>n in t&&typeof t[n]!=typeof e[n]);if(r)throw new et(r)}function ae(e){return Array.isArray(e)?e:[e]}function nt(e,t){return e.filter(r=>t===r).length}function se(...e){const t=e.flatMap(r=>Array.isArray(r)?r:Object.keys(r).map(pr));for(const r of t)if(nt(t,r)>1)throw new Ze(r)}function pr(e){return e.startsWith("?")?e.slice(1):e}function mr(e,t){return se(e.params,t.params),{value:`${e.value}${t.value}`,params:{...e.params,...t.params}}}function Rr(e,t){return se(e.params,t.params),{value:[e.value,t.value].filter(W).join("&"),params:{...e.params,...t.params}}}function yr(e,t){return se(e,t),{...e,...t}}function gr(e){return"host"in e&&!!e.host}function ot(e){return"parent"in e&&!!e.parent}function at(e){return"component"in e&&!!e.component}function st(e){return"props"in e&&typeof e.props=="function"}function ct(e){return"components"in e&&!!e.components}function ut(e){return"props"in e&&typeof e.props=="object"}function wr(e){return"state"in e&&!!e.state}function it(e,t){return{...t,path:mr(e.path,t.path),query:Rr(e.query,t.query),meta:hr(e.meta,t.meta),state:yr(e.state,t.state),hash:lr(e.hash,t.hash),matches:[...e.matches,t.matched],host:e.host,depth:e.depth+1}}function xe(){return typeof window<"u"&&typeof window.document<"u"}class J extends Error{}const G="[",z="]";function Er(e){return e!==String&&e!==Boolean&&e!==Number&&e!==Date}function vr(e){return typeof e=="function"&&Er(e)}function we(e){return typeof e=="object"&&"get"in e&&typeof e.get=="function"&&"set"in e&&typeof e.set=="function"}function ft(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Pr(e){return we(e)&&e.defaultValue!==void 0}function br(e,t){return pt(e,t)}function Sr(e,t){return e[t]??String}const j={invalid:e=>{throw new J(e)}},lt={get:e=>e,set:(e,{invalid:t})=>{if(typeof e!="string")throw t();return e}},Be={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()}},Ve={get:(e,{invalid:t})=>{const r=Number(e);if(isNaN(r))throw t();return r},set:(e,{invalid:t})=>{if(typeof e!="number")throw t();return e.toString()}},ht={get:(e,{invalid:t})=>{const r=new Date(e);if(isNaN(r.getTime()))throw t();return r},set:(e,{invalid:t})=>{if(typeof e!="object"||!(e instanceof Date))throw t();return e.toISOString()}},dt={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 Ar(e,t){switch(typeof t){case"string":return lt.get(e,j)===t;case"number":return Ve.get(e,j)===t;case"boolean":return Be.get(e,j)===t;default:return!1}}function Z(e,t,r=!1){if(e===void 0||!W(e)){if(Pr(t))return t.defaultValue;if(r)return;throw new J}if(t===String)return lt.get(e,j);if(t===Boolean)return Be.get(e,j);if(t===Number)return Ve.get(e,j);if(t===Date)return ht.get(e,j);if(t===JSON)return dt.get(e,j);if(vr(t))return t(e,j);if(we(t))return t.get(e,j);if(t instanceof RegExp){if(t.test(e))return e;throw new J}if(ft(t)){if(Ar(e,t))return t;throw new J}return e}function kr(e,t,r=!1){try{return Z(e,t,r)}catch(n){if(n instanceof J)return;throw n}}function Ur(e,t,r=!1){try{return ee(e,t,r)}catch(n){if(n instanceof J)return;throw n}}function ee(e,t,r=!1){if(e===void 0){if(r)return"";throw new J}if(t===Boolean)return Be.set(e,j);if(t===Number)return Ve.set(e,j);if(t===Date)return ht.set(e,j);if(t===JSON)return dt.set(e,j);if(we(t))return t.set(e,j);if(ft(t)){if(t!==e)throw new J;return e.toString()}try{return e.toString()}catch{throw new J}}function pt(e,t){return we(e)?{...e,defaultValue:t??e.defaultValue}:{get:r=>Z(r,e),set:r=>ee(r,e),defaultValue:t}}function K(){return K=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},K.apply(null,arguments)}var H;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(H||(H={}));var ce=process.env.NODE_ENV!=="production"?function(e){return Object.freeze(e)}:function(e){return e};function te(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}var Ee="beforeunload",Lr="hashchange",mt="popstate";function Rt(e){e===void 0&&(e={});var t=e,r=t.window,n=r===void 0?document.defaultView:r,o=n.history;function a(){var m=n.location,h=m.pathname,v=m.search,U=m.hash,C=o.state||{};return[C.idx,ce({pathname:h,search:v,hash:U,state:C.usr||null,key:C.key||"default"})]}var s=null;function f(){if(s)y.call(s),s=null;else{var m=H.Pop,h=a(),v=h[0],U=h[1];if(y.length)if(v!=null){var C=R-v;C&&(s={action:m,location:U,retry:function(){S(C*-1)}},S(C))}else process.env.NODE_ENV!=="production"&&te(!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 k(m)}}n.addEventListener(mt,f);var l=H.Pop,i=a(),R=i[0],P=i[1],x=ue(),y=ue();R==null&&(R=0,o.replaceState(K({},o.state,{idx:R}),""));function p(m){return typeof m=="string"?m:re(m)}function g(m,h){return h===void 0&&(h=null),ce(K({pathname:P.pathname,hash:"",search:""},typeof m=="string"?he(m):m,{state:h,key:Pe()}))}function u(m,h){return[{usr:m.state,key:m.key,idx:h},p(m)]}function d(m,h,v){return!y.length||(y.call({action:m,location:h,retry:v}),!1)}function k(m){l=m;var h=a();R=h[0],P=h[1],x.call({action:l,location:P})}function w(m,h){var v=H.Push,U=g(m,h);function C(){w(m,h)}if(d(v,U,C)){var V=u(U,R+1),$=V[0],_=V[1];try{o.pushState($,"",_)}catch{n.location.assign(_)}k(v)}}function E(m,h){var v=H.Replace,U=g(m,h);function C(){E(m,h)}if(d(v,U,C)){var V=u(U,R),$=V[0],_=V[1];o.replaceState($,"",_),k(v)}}function S(m){o.go(m)}var L={get action(){return l},get location(){return P},createHref:p,push:w,replace:E,go:S,back:function(){S(-1)},forward:function(){S(1)},listen:function(h){return x.push(h)},block:function(h){var v=y.push(h);return y.length===1&&n.addEventListener(Ee,ve),function(){v(),y.length||n.removeEventListener(Ee,ve)}}};return L}function Cr(e){e===void 0&&(e={});var t=e,r=t.window,n=r===void 0?document.defaultView:r,o=n.history;function a(){var h=he(n.location.hash.substr(1)),v=h.pathname,U=v===void 0?"/":v,C=h.search,V=C===void 0?"":C,$=h.hash,_=$===void 0?"":$,I=o.state||{};return[I.idx,ce({pathname:U,search:V,hash:_,state:I.usr||null,key:I.key||"default"})]}var s=null;function f(){if(s)y.call(s),s=null;else{var h=H.Pop,v=a(),U=v[0],C=v[1];if(y.length)if(U!=null){var V=R-U;V&&(s={action:h,location:C,retry:function(){L(V*-1)}},L(V))}else process.env.NODE_ENV!=="production"&&te(!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 w(h)}}n.addEventListener(mt,f),n.addEventListener(Lr,function(){var h=a(),v=h[1];re(v)!==re(P)&&f()});var l=H.Pop,i=a(),R=i[0],P=i[1],x=ue(),y=ue();R==null&&(R=0,o.replaceState(K({},o.state,{idx:R}),""));function p(){var h=document.querySelector("base"),v="";if(h&&h.getAttribute("href")){var U=n.location.href,C=U.indexOf("#");v=C===-1?U:U.slice(0,C)}return v}function g(h){return p()+"#"+(typeof h=="string"?h:re(h))}function u(h,v){return v===void 0&&(v=null),ce(K({pathname:P.pathname,hash:"",search:""},typeof h=="string"?he(h):h,{state:v,key:Pe()}))}function d(h,v){return[{usr:h.state,key:h.key,idx:v},g(h)]}function k(h,v,U){return!y.length||(y.call({action:h,location:v,retry:U}),!1)}function w(h){l=h;var v=a();R=v[0],P=v[1],x.call({action:l,location:P})}function E(h,v){var U=H.Push,C=u(h,v);function V(){E(h,v)}if(process.env.NODE_ENV!=="production"&&te(C.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.push("+JSON.stringify(h)+")"),k(U,C,V)){var $=d(C,R+1),_=$[0],I=$[1];try{o.pushState(_,"",I)}catch{n.location.assign(I)}w(U)}}function S(h,v){var U=H.Replace,C=u(h,v);function V(){S(h,v)}if(process.env.NODE_ENV!=="production"&&te(C.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.replace("+JSON.stringify(h)+")"),k(U,C,V)){var $=d(C,R),_=$[0],I=$[1];o.replaceState(_,"",I),w(U)}}function L(h){o.go(h)}var m={get action(){return l},get location(){return P},createHref:g,push:E,replace:S,go:L,back:function(){L(-1)},forward:function(){L(1)},listen:function(v){return x.push(v)},block:function(v){var U=y.push(v);return y.length===1&&n.addEventListener(Ee,ve),function(){U(),y.length||n.removeEventListener(Ee,ve)}}};return m}function yt(e){e===void 0&&(e={});var t=e,r=t.initialEntries,n=r===void 0?["/"]:r,o=t.initialIndex,a=n.map(function(w){var E=ce(K({pathname:"/",search:"",hash:"",state:null,key:Pe()},typeof w=="string"?he(w):w));return process.env.NODE_ENV!=="production"&&te(E.pathname.charAt(0)==="/","Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: "+JSON.stringify(w)+")"),E}),s=gt(o??a.length-1,0,a.length-1),f=H.Pop,l=a[s],i=ue(),R=ue();function P(w){return typeof w=="string"?w:re(w)}function x(w,E){return E===void 0&&(E=null),ce(K({pathname:l.pathname,search:"",hash:""},typeof w=="string"?he(w):w,{state:E,key:Pe()}))}function y(w,E,S){return!R.length||(R.call({action:w,location:E,retry:S}),!1)}function p(w,E){f=w,l=E,i.call({action:f,location:l})}function g(w,E){var S=H.Push,L=x(w,E);function m(){g(w,E)}process.env.NODE_ENV!=="production"&&te(l.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.push("+JSON.stringify(w)+")"),y(S,L,m)&&(s+=1,a.splice(s,a.length,L),p(S,L))}function u(w,E){var S=H.Replace,L=x(w,E);function m(){u(w,E)}process.env.NODE_ENV!=="production"&&te(l.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.replace("+JSON.stringify(w)+")"),y(S,L,m)&&(a[s]=L,p(S,L))}function d(w){var E=gt(s+w,0,a.length-1),S=H.Pop,L=a[E];function m(){d(w)}y(S,L,m)&&(s=E,p(S,L))}var k={get index(){return s},get action(){return f},get location(){return l},createHref:P,push:g,replace:u,go:d,back:function(){d(-1)},forward:function(){d(1)},listen:function(E){return i.push(E)},block:function(E){return R.push(E)}};return k}function gt(e,t,r){return Math.min(Math.max(e,t),r)}function ve(e){e.preventDefault(),e.returnValue=""}function ue(){var e=[];return{get length(){return e.length},push:function(r){return e.push(r),function(){e=e.filter(function(n){return n!==r})}},call:function(r){e.forEach(function(n){return n&&n(r)})}}}function Pe(){return Math.random().toString(36).substr(2,8)}function re(e){var t=e.pathname,r=t===void 0?"/":t,n=e.search,o=n===void 0?"":n,a=e.hash,s=a===void 0?"":a;return o&&o!=="?"&&(r+=o.charAt(0)==="?"?o:"?"+o),s&&s!=="#"&&(r+=s.charAt(0)==="#"?s:"#"+s),r}function he(e){var t={};if(e){var r=e.indexOf("#");r>=0&&(t.hash=e.substr(r),e=e.substr(0,r));var n=e.indexOf("?");n>=0&&(t.search=e.substr(n),e=e.substr(0,n)),e&&(t.pathname=e)}return t}const wt=Symbol();function xr(){const e=c.inject(wt);if(!e)throw new X;return e}const Et=Symbol("isRouterRouteSymbol");function Br(e){return typeof e=="object"&&e!==null&&Et in e}function Vr(e,t){function r(u,d,k){if(typeof u=="object"){const E={...e.params,...u};return t(e.name,E,d)}const w={...e.params,[u]:d};return t(e.name,w,k)}const n=(...u)=>{const d=new URLSearchParams(e.query);d.set(...u),r({},{query:d})},o=(...u)=>{const d=new URLSearchParams(e.query);d.append(...u),r({},{query:d})},a=(...u)=>{const d=new URLSearchParams(e.query);d.delete(...u),r({},{query:d})},{id:s,matched:f,matches:l,name:i,hash:R,href:P}=c.toRefs(e),x=c.computed({get(){return new Proxy(e.params,{set(u,d,k){return r(d,k),!0}})},set(u){r(u)}}),y=c.computed({get(){return new Proxy(e.query,{get(u,d,k){switch(d){case"append":return o;case"set":return n;case"delete":return a;default:return Reflect.get(u,d,k)}}})},set(u){r({},{query:u})}}),p=c.computed({get(){return new Proxy(e.state,{set(u,d,k){return r({},{state:{...e.state,[d]:k}}),!0}})},set(u){r({},{state:u})}});return c.reactive({id:s,matched:f,matches:l,state:p,query:y,hash:R,params:x,name:i,href:P,update:r,[Et]:!0})}const vt=Symbol();function Nr(e,t){const r=c.reactive({...e}),n=s=>{Object.assign(r,{[vt]:!1,...s})},o=r,a=Vr(o,t);return{currentRoute:o,routerRoute:a,updateRoute:n}}function q(e){return!e.startsWith("http")?$r(e):jr(e)}function jr(e){const{protocol:t,host:r,pathname:n,search:o,searchParams:a,hash:s}=new URL(e,e);return{protocol:t,host:r,pathname:n,search:o,searchParams:a,hash:s}}function $r(e){const{pathname:t,search:r,searchParams:n,hash:o}=new URL(e,"https://localhost");return{pathname:t,search:r,searchParams:n,hash:o}}function Hr(e){return t=>{const{host:r}=q(t);return!(r===void 0||r===e)}}function _r({mode:e,listener:t}){const r=qr(e),n=(l,i)=>{if(i!=null&&i.replace){r.replace(l,i.state);return}r.push(l,i==null?void 0:i.state)},o=()=>{const l=re(r.location);r.replace(l)};let a;return{...r,update:n,refresh:o,startListening:()=>{a==null||a(),a=r.listen(t)},stopListening:()=>{a==null||a()}}}function qr(e="auto"){switch(e){case"auto":return xe()?Rt():yt();case"browser":return Rt();case"memory":return yt();case"hash":return Cr();default:const t=e;throw new Error(`Switch is not exhaustive for mode: ${t}`)}}class Pt extends Error{constructor(){super("Uncaught CallbackContextAbortError");F(this,"response");this.response={status:"ABORT"}}}class ie extends Error{constructor(r){super("Uncaught CallbackContextPushError");F(this,"response");this.response={status:"PUSH",to:r}}}class be extends Error{constructor(r){super("Uncaught CallbackContextRejectionError");F(this,"response");this.response={status:"REJECT",type:r}}}function bt(){return{reject:o=>{throw new be(o)},push:(...o)=>{throw new ie(o)},replace:(o,a,s)=>{if(N(o)){const i=a??{};throw new ie([o,{...i,replace:!0}])}const f=a,l=s??{};throw new ie([o,f,{...l,replace:!0}])},abort:()=>{throw new Pt}}}class ne{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,r)=>{var a,s;const n=e.matches,o=(t==null?void 0:t.matches)??[];return((a=n.at(r))==null?void 0:a.id)!==((s=o.at(r))==null?void 0:s.id)},pe=(e,t,r)=>{var a,s;const n=e.matches,o=(t==null?void 0:t.matches)??[];return((a=n.at(r))==null?void 0:a.id)!==((s=o.at(r))==null?void 0:s.id)},me=(e,t,r)=>{var n,o;return((n=e.matches.at(r))==null?void 0:n.id)===((o=t==null?void 0:t.matches.at(r))==null?void 0:o.id)};function St(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 Or(e,t){const r=new ne;return e.matches.forEach((n,o)=>{n.onBeforeRouteEnter&&de(e,t,o)&&ae(n.onBeforeRouteEnter).forEach(a=>r.onBeforeRouteEnter.add(a)),n.onBeforeRouteUpdate&&me(e,t,o)&&ae(n.onBeforeRouteUpdate).forEach(a=>r.onBeforeRouteUpdate.add(a))}),t==null||t.matches.forEach((n,o)=>{n.onBeforeRouteLeave&&pe(e,t,o)&&ae(n.onBeforeRouteLeave).forEach(a=>r.onBeforeRouteLeave.add(a))}),r}function Ir(e,t){const r=new ne;return e.matches.forEach((n,o)=>{n.onAfterRouteEnter&&de(e,t,o)&&ae(n.onAfterRouteEnter).forEach(a=>r.onAfterRouteEnter.add(a)),n.onAfterRouteUpdate&&me(e,t,o)&&ae(n.onAfterRouteUpdate).forEach(a=>r.onAfterRouteUpdate.add(a))}),t==null||t.matches.forEach((n,o)=>{n.onAfterRouteLeave&&pe(e,t,o)&&ae(n.onAfterRouteLeave).forEach(a=>r.onAfterRouteLeave.add(a))}),r}function Mr(e,t,r){const n=new ne;return e.matches.forEach((o,a)=>{de(e,t,a)&&r.onBeforeRouteEnter.forEach(s=>n.onBeforeRouteEnter.add(s)),me(e,t,a)&&r.onBeforeRouteUpdate.forEach(s=>n.onBeforeRouteUpdate.add(s))}),t==null||t.matches.forEach((o,a)=>{pe(e,t,a)&&r.onBeforeRouteLeave.forEach(s=>n.onBeforeRouteLeave.add(s))}),n}function Tr(e,t,r){const n=new ne;return e.matches.forEach((o,a)=>{de(e,t,a)&&r.onAfterRouteEnter.forEach(s=>n.onAfterRouteEnter.add(s)),me(e,t,a)&&r.onAfterRouteUpdate.forEach(s=>n.onAfterRouteUpdate.add(s))}),t==null||t.matches.forEach((o,a)=>{pe(e,t,a)&&r.onAfterRouteLeave.forEach(s=>n.onAfterRouteLeave.add(s))}),n}const At=Symbol();function Dr(){const e={global:new ne,component:new ne},{reject:t,push:r,replace:n,abort:o}=bt(),a=u=>(e.global.onBeforeRouteEnter.add(u),()=>e.global.onBeforeRouteEnter.delete(u)),s=u=>(e.global.onBeforeRouteUpdate.add(u),()=>e.global.onBeforeRouteUpdate.delete(u)),f=u=>(e.global.onBeforeRouteLeave.add(u),()=>e.global.onBeforeRouteLeave.delete(u)),l=u=>(e.global.onAfterRouteEnter.add(u),()=>e.global.onAfterRouteEnter.delete(u)),i=u=>(e.global.onAfterRouteUpdate.add(u),()=>e.global.onAfterRouteUpdate.delete(u)),R=u=>(e.global.onAfterRouteLeave.add(u),()=>e.global.onAfterRouteLeave.delete(u));async function P({to:u,from:d}){const{global:k,component:w}=e,E=Or(u,d),S=Mr(u,d,k),L=[...S.onBeforeRouteEnter,...E.onBeforeRouteEnter,...S.onBeforeRouteUpdate,...E.onBeforeRouteUpdate,...w.onBeforeRouteUpdate,...S.onBeforeRouteLeave,...E.onBeforeRouteLeave,...w.onBeforeRouteLeave];try{const m=L.map(h=>h(u,{from:d,reject:t,push:r,replace:n,abort:o}));await Promise.all(m)}catch(m){if(m instanceof ie||m instanceof be||m instanceof Pt)return m.response;throw m}return{status:"SUCCESS"}}async function x({to:u,from:d}){const{global:k,component:w}=e,E=Ir(u,d),S=Tr(u,d,k),L=[...w.onAfterRouteLeave,...E.onAfterRouteLeave,...S.onAfterRouteLeave,...w.onAfterRouteUpdate,...E.onAfterRouteUpdate,...S.onAfterRouteUpdate,...w.onAfterRouteEnter,...E.onAfterRouteEnter,...S.onAfterRouteEnter];try{const m=L.map(h=>h(u,{from:d,reject:t,push:r,replace:n}));await Promise.all(m)}catch(m){if(m instanceof ie||m instanceof be)return m.response;throw m}return{status:"SUCCESS"}}return{runBeforeRouteHooks:P,runAfterRouteHooks:x,addComponentBeforeRouteHook:({lifecycle:u,depth:d,hook:k})=>{const w=St(u),E=e.component[u],S=(L,m)=>{if(w(L,m.from,d))return k(L,m)};return E.add(S),()=>E.delete(S)},addComponentAfterRouteHook:({lifecycle:u,depth:d,hook:k})=>{const w=St(u),E=e.component[u],S=(L,m)=>{if(w(L,m.from,d))return k(L,m)};return E.add(S),()=>E.delete(S)},addGlobalRouteHooks:u=>{u.onBeforeRouteEnter.forEach(d=>a(d)),u.onBeforeRouteUpdate.forEach(d=>s(d)),u.onBeforeRouteLeave.forEach(d=>f(d)),u.onAfterRouteEnter.forEach(d=>l(d)),u.onAfterRouteUpdate.forEach(d=>i(d)),u.onAfterRouteLeave.forEach(d=>R(d))},onBeforeRouteEnter:a,onBeforeRouteUpdate:s,onBeforeRouteLeave:f,onAfterRouteEnter:l,onAfterRouteUpdate:i,onAfterRouteLeave:R}}function Fr(e){return c.defineComponent(()=>()=>c.h("h1",e),{name:e,props:[]})}function Ne(e){const t=new URLSearchParams(e);return{get:(...r)=>t.get(...r),getAll:(...r)=>t.getAll(...r),set:(...r)=>{t.set(...r)},append:(...r)=>{t.append(...r)},delete:(...r)=>{t.delete(...r)},toString:(...r)=>t.toString(...r),forEach:(...r)=>{t.forEach(...r)},entries:(...r)=>t.entries(...r),keys:(...r)=>t.keys(...r),values:(...r)=>t.values(...r),has:(...r)=>t.has(...r),size:t.size,sort:()=>{t.sort()},[Symbol.iterator]:()=>t[Symbol.iterator]()}}function je(){let e=0;return()=>(++e).toString()}const Wr=je()();function Jr(e){return e===Wr}const $e=je();function Gr(e){const t=a=>c.markRaw(e[a]??Fr(a)),r=a=>{const s=c.markRaw(t(a)),f={id:$e(),component:s,meta:{},state:{}};return{id:f.id,matched:f,matches:[f],name:a,query:Ne(""),params:{},state:{},href:"/",hash:"",[vt]:!0}},n=a=>{if(!a){o.value=null;return}const s=t(a);o.value={type:a,component:s}},o=c.ref(null);return{setRejection:n,rejection:o,getRejectionRoute:r}}class Qr extends Error{constructor(){super("initialUrl must be set if window.location is unavailable")}}function zr(e){if(e)return e;if(xe())return window.location.toString();throw new Qr}function kt(e){return!!e&&typeof e=="object"}const Se=!0;function Kr(e,t,r){if(kt(e)&&t in e){const n=e[t];return typeof n=="string"?Z(n,r,Se):n}return Z(void 0,r,Se)}function Ut(e,t){const r={};for(const[n,o]of Object.entries(e)){const a=Kr(t,n,o);r[n]=a}return r}function Yr(e,t,r){if(kt(e)&&t in e){const n=e[t];return ee(n,r,Se)}return ee(void 0,r,Se)}const Lt=(e,t)=>{const r={};for(const[n,o]of Object.entries(e)){const a=Yr(t,n,o);r[n]=a}return r};function Xr(){const e=c.reactive(new Map),t=xe()?s():null,r=f=>{e.set(f,!1),t==null||t.observe(f)},n=f=>{e.delete(f),t==null||t.unobserve(f)},o=()=>{t==null||t.disconnect()},a=f=>e.get(f)??!1;function s(){return new IntersectionObserver(f=>{f.forEach(l=>{e.set(l.target,l.isIntersecting)})})}return{observe:r,unobserve:n,disconnect:o,isElementVisible:a}}const Ct=Symbol("visibilityObserver");function Zr(e){const t=c.inject(Ct);if(!t)throw new X;return c.watch(e,(n,o)=>{n&&t.observe(n),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 en extends Error{constructor(t){super(`Route not found: "${t}"`)}}function He(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tn(e,t){const r=Array.from(e.matchAll(t));if(r.length===0)return[e];let n=0;const o=r.reduce((s,f)=>{const l=He(e.slice(n,f.index));l.length&&s.push(l);const[i]=f;return s.push(i),n=f.index+i.length,s},[]),a=e.slice(n);return a&&o.push(a),o}function rn(e){const t=xt(e.path.value);return new RegExp(`^${t}$`,"i")}function nn(e){const t=new URLSearchParams(e.query.value);return Array.from(t.entries()).filter(([,r])=>!qe(r)).map(([r,n])=>{const o=xt(n);return new RegExp(`${He(r)}=${o}(&|$)`,"i")})}function xt(e){return tn(e,new RegExp(on,"g")).map(t=>t.startsWith(G)?Bt(t):He(t)).join("")}function Bt(e){return[an,sn].reduce((t,r)=>r(t),e)}const on=`\\${G}\\??([\\w-_]+)\\${z}`,_e=`\\${G}\\?([\\w-_]+)\\${z}`,Vt=`\\${G}([\\w-_]+)\\${z}`;function an(e){return e.replace(new RegExp(_e,"g"),".*")}function qe(e){return new RegExp(_e,"g").test(e)}function sn(e){return e.replace(new RegExp(Vt,"g"),".+")}function Re(e){const[t]=Ae(e,new RegExp(_e,"g")),[r]=Ae(e,new RegExp(Vt,"g"));return t??r}function Ae(e,t){return Array.from(e.matchAll(t)).flatMap(([,...n])=>n.map(o=>W(o)?o:""))}function Nt(e,t,r){const n=$t(t,r),[o]=Ae(e,n);return o}function jt(e,t){if(!t)return e;const{name:r,param:n,value:o}=t,a=$t(e,r);return Ae(e,a).reduce((f,l)=>l===void 0?f:f.replace(l,()=>ee(o,n,r.startsWith("?"))),e)}function $t(e,t){const r=[cn,un,Bt].reduce((n,o)=>o(n,t),e);return new RegExp(r,"g")}function cn(e,t){if(!t.startsWith("?"))return e;const r=new RegExp(`\\${G}\\${t}\\${z}`,"g");return e.replace(r,"(.*)")}function un(e,t){if(t.startsWith("?"))return e;const r=new RegExp(`\\${G}${t}\\${z}`,"g");return e.replace(r,"(.+)")}function Ht({protocol:e,host:t,pathname:r,search:n,searchParams:o,hash:a}){const s=new URL("https://localhost");e&&(s.protocol=e),t&&(s.host=t),r&&(s.pathname=r),o?s.search=new URLSearchParams(o).toString():n&&(s.search=n),a&&(s.hash=a);const f=s.toString().replace(/^https:\/\/localhost\/*/,"/");return Ce(f)}function Oe(...e){const t=new URLSearchParams;for(const r of e){const n=new URLSearchParams(r);for(const[o,a]of n.entries())t.append(o,a)}return t}function fn(e,t={}){const{params:r={},query:n}=t,o=dn(e.query,r),a=Oe(o,n),s=hn(e.path,r),f=ge(e.hash.value??t.hash).value,l=ln(e.host,r),{protocol:i,host:R}=q(l);return Ht({protocol:i,host:R,pathname:s,searchParams:a,hash:f})}function ln(e,t){const r=e.value&&!e.value.startsWith("http")?`https://${e.value}`:e.value;return Object.entries(e.params).reduce((n,[o,a])=>{const s=Re(`${G}${o}${z}`);return s?jt(n,{name:o,param:a,value:t[s]}):n},r)}function hn(e,t){return Object.entries(e.params).reduce((r,[n,o])=>{const a=Re(`${G}${n}${z}`);return a?jt(r,{name:n,param:o,value:t[a]}):r},e.value)}function dn(e,t){const r=new URLSearchParams(e.value);if(!e.value)return r;for(const[n,o]of Array.from(r.entries())){const a=Re(o);if(!a)continue;const f=qe(o),l=f?`?${a}`:a,i=ee(t[a],e.params[l],f),R=t[a]===void 0&&i==="";f&&R?r.delete(n,o):r.set(n,i)}return r}const pn=(e,t)=>{try{Ie(e,t)}catch{return!1}return!0},Ie=(e,t)=>{const{pathname:r,search:n}=q(t);return{...mn(e.path,r),...Rn(e.query,n)}};function mn(e,t){const r={},n=decodeURIComponent(t);for(const[o,a]of Object.entries(e.params)){const s=o.startsWith("?"),f=s?o.slice(1):o,l=Nt(n,e.value,o),i=Z(l,a,s);r[f]=i}return r}function Rn(e,t){const r={},n=new URLSearchParams(e.value),o=new URLSearchParams(t);for(const[a,s]of Array.from(n.entries())){const f=Re(s);if(!f)continue;const i=qe(s),R=i?`?${f}`:f,P=o.get(a)??void 0,x=Z(P,e.params[R],i);r[f]=x}return r}function yn(e,t={},r={}){const n=fn(e,{params:t,query:r.query,hash:r.hash}),{search:o,hash:a}=q(n);return{id:e.id,matched:e.matched,matches:e.matches,name:e.name,query:Ne(o),params:Ie(e,n),state:Ut(e.state,r.state),hash:a,href:n}}const gn=e=>"name"in e.matched&&!!e.matched.name,wn=(e,t)=>{const{pathname:r}=q(t);return rn(e).test(r)},En=(e,t)=>{const{search:r}=q(t);return nn(e).every(o=>o.test(r))},Me=(e,t)=>{const{hash:r}=q(t),{value:n}=e.hash;return n===void 0||`#${n.toLowerCase()}`===r.toLowerCase()};function vn(e){const{searchParams:t,pathname:r}=q(e),n=-1,o=1;return(a,s)=>{const f=qt(a,t),l=_t(a,r),i=qt(s,t),R=_t(s,r);return a.depth>s.depth?n:a.depth<s.depth?o:f+l>i+R?n:f+l<i+R?o:Me(a,e)?n:Me(s,e)?o:0}}function _t(e,t){const r=Object.keys(e.path.params).filter(o=>o.startsWith("?")).map(o=>o),n=r.filter(o=>Nt(t,e.path.value,o)===void 0);return r.length-n.length}function qt(e,t){const r=new URLSearchParams(t),n=new URLSearchParams(e.query.value),o=Array.from(n.keys()),a=o.filter(s=>!r.has(s));return o.length-a.length}const Pn=[gn,wn,En,Me,pn];function bn(e,t){const r=vn(t);return e.filter(n=>Pn.every(o=>o(n,t))).sort(r)}function Sn(e,t,r){const n=bn(e,t);if(!n.length)return;const[o]=n,{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:Ut(o.state,r),hash:s,href:Ce(t)}}function Ot(e,t){const r=typeof e=="string"?q(e):e,n=typeof t=="string"?q(t):t,o=r.searchParams??new URLSearchParams(r.search),a=n.searchParams??new URLSearchParams(n.search);return Ht({protocol:W(n.protocol)?n.protocol:r.protocol,host:W(n.host)?n.host:r.host,pathname:W(n.pathname)?n.pathname:r.pathname,searchParams:Oe(a,o),hash:W(n.hash)?n.hash:r.hash})}function Te(e,t){const r=new RegExp(`\\${G}(\\??[\\w-_]+)\\${z}`,"g");return Array.from(e.matchAll(r)).reduce((o,[a,s])=>{const f=Re(a);if(!f)return o;const l=Sr(t,f);return se([f],o),o[s]=l,o},{})}function ke(e,t){return{value:e,params:Te(e,t)}}function An(e,t){return W(t)?e.map(r=>{const n=`${t}${r.path.value}`;return{...r,path:ke(n,r.path.params)}}):e}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 Un(e){const t=e.map(({name:r})=>r);for(const r of t)if(nt(t,r)>1)throw new kn(r)}function Ln(e,t=[],r){const n=[...e,...t.map(o=>o.routes)].flat();return Un(n),An(n,r)}function Cn(e={},t=[]){const r=new ne;return fe("onBeforeRouteEnter",e,t).forEach(n=>r.onBeforeRouteEnter.add(n)),fe("onBeforeRouteUpdate",e,t).forEach(n=>r.onBeforeRouteUpdate.add(n)),fe("onBeforeRouteLeave",e,t).forEach(n=>r.onBeforeRouteLeave.add(n)),fe("onAfterRouteEnter",e,t).forEach(n=>r.onAfterRouteEnter.add(n)),fe("onAfterRouteUpdate",e,t).forEach(n=>r.onAfterRouteUpdate.add(n)),fe("onAfterRouteLeave",e,t).forEach(n=>r.onAfterRouteLeave.add(n)),r}function fe(e,t,r){return[t[e],...r.map(o=>o[e])].flat().filter(o=>o!==void 0)}function It(e){return typeof e=="object"&&e!==null&&"then"in e}function De(e,t,{exact:r}={}){return Br(e)?t===void 0?!0:r?e.matched.name===t:e.matches.map(n=>n.name).includes(t):!1}function Fe(e,t){const r=ye();function n(){if(!e)return;if(!De(r.route,e,t))throw new tt(e,r.route.name)}return c.watch(r.route,n,{immediate:!0,deep:!0}),r.route}function xn(e,t,r){return c.defineComponent({name:"PropsWrapper",expose:[],setup(){const n=c.getCurrentInstance(),o=er(),a=Fe();return()=>{const s=o.getProps(e.id,t,a);return s instanceof Error?"":It(s)?n!=null&&n.suspense?c.h(Vn,{component:r,props:s}):c.h(Bn,{component:r,props:s}):c.h(r,s)}}})}const Bn=c.defineComponent(e=>{const t=c.ref();return c.watch(()=>e.props,async r=>{t.value=await r},{immediate:!0,deep:!0}),()=>t.value instanceof Error?"":t.value?c.h(e.component,t.value):""},{props:["component","props"]}),Vn=c.defineComponent(async e=>{const t=c.ref();return t.value=await e.props,c.watch(()=>t.value,async r=>{t.value=await r},{deep:!0}),()=>t.value instanceof Error?"":t.value?c.h(e.component,t.value):""},{props:["component","props"]}),Mt=Symbol();function We(){return c.inject(Mt,0)}function Nn(){const e=c.inject(Tt);if(!e)throw new X;return e}const Je=c.defineComponent({__name:"routerView",props:{name:{default:"default"}},setup(e){const t=Fe(),r=xr(),n=We(),{getRouteComponents:o}=Nn();c.provide(Mt,n+1);const a=c.computed(()=>{if(r.value)return r.value.component;const s=t.matches.at(n);return s?o(s)[e.name]:null});return(s,f)=>a.value?c.renderSlot(s.$slots,"default",c.normalizeProps(c.mergeProps({key:0},{route:c.unref(t),component:a.value,rejection:c.unref(r)})),()=>[(c.openBlock(),c.createBlock(c.resolveDynamicComponent(a.value)))]):c.createCommentVNode("",!0)}}),Tt=Symbol();function jn(){const e=new Map;return{getRouteComponents:r=>{const n=e.get(r.id);if(n)return n;const o=$n(r);return e.set(r.id,o),o}}}function $n(e){return ct(e)?Dt(e,e.components):at(e)?Dt(e,{default:e.component}):{default:Je}}function Dt(e,t){return Object.fromEntries(Object.entries(t).map(([r,n])=>[r,xn(e,r,n)]))}function Hn(e,t,r=[]){const n=Ln(e,r,t==null?void 0:t.base),o=Dr();o.addGlobalRouteHooks(Cn(t,r));const a=je(),s=Gn(),f=jn(),l=Xr(),i=_r({mode:t==null?void 0:t.historyMode,listener:({location:b})=>{const B=re(b);P(B,{state:b.state,replace:!0})}});function R(b,B={}){return Sn(n,b,B.state)}async function P(b,B={}){const Q=a();if(i.stopListening(),U(b)){i.update(b,B);return}const M=R(b,B)??k("NotFound"),O=ir(Q),Y=await o.runBeforeRouteHooks({to:M,from:O});switch(Y.status){case"ABORT":return;case"PUSH":i.update(b,B),await y(...Y.to);return;case"REJECT":i.update(b,B),u(Y.type);break;case"SUCCESS":i.update(b,B),u(null);break;default:throw new Error(`Switch is not exhaustive for before hook response status: ${JSON.stringify(Y)}`)}const Ke=Q;s.setProps(M).then(T=>{if(Ke===Q)switch(T.status){case"SUCCESS":break;case"PUSH":y(...T.to);break;case"REJECT":u(T.type);break;default:const Ye=T;throw new Error(`Switch is not exhaustive for prop store response status: ${JSON.stringify(Ye)}`)}}),L(M);const D=await o.runAfterRouteHooks({to:M,from:O});switch(D.status){case"PUSH":await y(...D.to);break;case"REJECT":u(D.type);break;case"SUCCESS":break;default:const T=D;throw new Error(`Switch is not exhaustive for after hook response status: ${JSON.stringify(T)}`)}i.startListening()}const x=(b,B={},Q={})=>{const M=n.find(O=>O.name===b);if(!M)throw new en(String(b));return yn(M,B,Q)},y=(b,B,Q)=>{if(N(b)){const D={...B},T=Ot(b,{searchParams:D.query,hash:D.hash});return P(T,D)}if(typeof b=="string"){const{replace:D,...T}={...Q},Ye={...B},Xe=x(b,Ye,T),ao=Lt({...Xe.matched.state},{...Xe.state,...T.state});return P(Xe.href,{replace:D,state:ao})}const{replace:M,...O}={...B},Y=Lt({...b.matched.state},{...b.state,...O.state}),Ke=Ot(b.href,{searchParams:O.query,hash:O.hash});return P(Ke,{replace:M,state:Y})},p=(b,B,Q)=>{if(N(b)){const O={...B,replace:!0};return y(b,O)}if(typeof b=="string"){const O={...Q,replace:!0},Y={...B};return y(b,Y,O)}const M={...B,replace:!0};return y(b,M)},g=b=>{u(b)},{setRejection:u,rejection:d,getRejectionRoute:k}=Gr({...r.reduce((b,B)=>({...b,...B.rejections}),{}),...t==null?void 0:t.rejections}),w=k("NotFound"),{currentRoute:E,routerRoute:S,updateRoute:L}=Nr(w,y),m=zr(t==null?void 0:t.initialUrl),h=i.location.state,{host:v}=q(m),U=Hr(v);let C=!1;const{promise:V,resolve:$}=Promise.withResolvers();async function _(){if(C)return V;C=!0,await P(m,{replace:!0,state:h}),i.startListening(),$()}function I(){i.stopListening()}function ir(b){return Jr(b)?null:{...E}}function oo(b){b.component("RouterView",Je),b.component("RouterLink",or),b.provide(wt,d),b.provide(At,o),b.provide(Zt,s),b.provide(Tt,f),b.provide(Ct,l),b.provide(rt,fr),_()}const fr={route:S,resolve:x,find:R,push:y,replace:p,reject:g,refresh:i.refresh,forward:i.forward,back:i.back,go:i.go,install:oo,isExternal:U,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:_,stop:I};return fr}function Ge(e,t){return{value:e,params:Te(e,t)}}function _n(e){return{routes:e.routes??[],rejections:e.rejections??{},...e}}function Ft(...e){return{get:(t,{invalid:r})=>{for(const n of e){const o=kr(t,n);if(o!==void 0)return o}throw r(`Value ${t} does not satisfy any of the possible values`)},set:(t,{invalid:r})=>{for(const n of e){const o=Ur(t,n);if(o!==void 0)return o}throw r(`Value ${t} does not satisfy any of the possible values`)}}}function qn(...e){const t=Ft(...e);return{get:(r,n)=>r.split(",").map(o=>t.get(o,n)),set:(r,n)=>{if(!Array.isArray(r))throw n.invalid("Expected an array");return r.map(o=>t.set(o,n)).join(",")}}}function On(...e){return{get:t=>{const r=t.split(",");return e.map((n,o)=>Z(r.at(o),n))},set:(t,{invalid:r})=>{if(!Array.isArray(t))throw r("Expected a tuple");if(t.length!==e.length)throw r(`Expected tuple with ${e.length} values but received ${t.length} values`);return e.map((n,o)=>ee(t.at(o),n)).join(",")}}}function Wt(e,t){return{value:e,params:Te(e,t)}}function In(e){return le(e)&&typeof e.hash=="string"}function Jt(e){return e===void 0?ge():In(e)?e:ge(e)}function Gt(e){return e===void 0?"":e}function Mn(e){return le(e)&&typeof e.value=="string"}function Qt(e){return e===void 0?ke("",{}):Mn(e)?e:ke(e,{})}function Tn(e){return le(e)&&typeof e.value=="string"}function zt(e){return e===void 0?Ge("",{}):Tn(e)?e:Ge(e,{})}function oe(e,t){const r=$e(),n=Gt(e.name),o=Qt(e.path),a=zt(e.query),s=Jt(e.hash),f=e.meta??{},l=wr(e)?e.state:{},i=c.markRaw({id:r,meta:{},state:{},...e,props:t}),R={id:r,matched:i,matches:[i],name:n,path:o,query:a,hash:s,meta:f,state:l,depth:1,host:Wt("",{}),prefetch:e.prefetch},P=ot(e)?it(e.parent,R):R;return se(P.path.params,P.query.params),P}const Ue={template:"<div>This is component</div>"},Qe=oe({name:"parentA",path:"/parentA/[paramA]"}),Kt=oe({parent:Qe,name:"parentA.childA",path:"/childA/[?paramB]"}),Dn=oe({parent:Qe,name:"parentA.childB",path:"/childB/[paramD]",component:Ue}),Fn=oe({parent:Kt,name:"parentA.childA.grandChildA",path:"/[paramC]",component:Ue});oe({name:"parentB",path:"/parentB",component:Ue}),oe({name:"parentC",path:"/",component:Ue});const Wn="lazy",Jn={components:!0,props:!1};function Le(e){return["eager","lazy","intent"].includes(e)}function Yt({routerPrefetch:e,routePrefetch:t,linkPrefetch:r},n){const o=ze(r,n),a=ze(t,n),s=ze(e,n),f=[o,a,s,Jn[n],Wn].reduce((l,i)=>Le(l)?l:l===!0&&Le(i)?i:l===!0&&!Le(i)?l:l===void 0?i:l,void 0);return Le(f)?f:!1}function ze(e,t){return le(e)?e[t]:e}function Xt(e){try{const t=e();return It(t)?t.catch(r=>r):t}catch(t){return t}}const Zt=Symbol();function Gn(){const e=c.reactive(new Map),{push:t,replace:r,reject:n}=bt(),o=(y,p,g)=>p.matches.filter(u=>Yt({...g,routePrefetch:u.prefetch},"props")===y).flatMap(u=>P(u)).reduce((u,{id:d,name:k,props:w})=>{if(!w)return u;const E=R(d,k,p),S=Xt(()=>w(p,{push:t,replace:r,reject:n,parent:l(p,!0)}));return u[E]=S,u},{}),a=y=>{Object.entries(y).forEach(([p,g])=>{e.set(p,g)})},s=async y=>{const p=y.matches.flatMap(P),g=[],u=[];for(const{id:d,name:k,props:w}of p){if(!w)continue;const E=R(d,k,y);if(g.push(E),!e.has(E)){const S=Xt(()=>w(y,{push:t,replace:r,reject:n,parent:l(y)}));e.set(E,S)}u.push((async()=>{const S=await e.get(E);if(S instanceof Error)throw S})())}x(g);try{return await Promise.all(u),{status:"SUCCESS"}}catch(d){if(d instanceof ie||d instanceof be)return d.response;throw d}},f=(y,p,g)=>{const u=R(y,p,g);return e.get(u)};function l(y,p=!1){const g=y.matches.at(-2);if(g)return st(g)?{name:g.name??"",get props(){return i(g,"default",y,p)}}:ut(g)?{name:g.name??"",props:new Proxy({},{get(u,d){return typeof d!="string"?Reflect.get(u,d):i(g,d,y,p)}})}:{name:g.name??"",props:void 0}}function i(y,p,g,u=!1){const d=f(y.id,p,g);if(u&&!d){const k=y.name??"unknown",w=g.name||"unknown";console.warn(`
|
|
2
|
-
Unable to access parent props "${
|
|
1
|
+
(function(k,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],c):(k=typeof globalThis<"u"?globalThis:k||self,c(k["@kitbag/router"]={},k.Vue))})(this,function(k,c){"use strict";var fo=Object.defineProperty;var lo=(k,c,Z)=>c in k?fo(k,c,{enumerable:!0,configurable:!0,writable:!0,value:Z}):k[c]=Z;var W=(k,c,Z)=>lo(k,typeof c!="symbol"?c+"":c,Z);function Z(e){return typeof e!="string"?!1:/^(https?:\/\/|\/).*/g.test(e)}function Ve(e){return Z(e)?e:`/${e}`}class nt 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 ot 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 at extends Error{constructor(t,r){super(`useRoute called with incorrect route. Given ${t}, expected ${r}`)}}const st=Symbol();function Ee(){const e=c.inject(st);if(!e)throw new ee;return e}function ce(e){return Array.isArray(e)?e:[e]}function ct(e,t){return e.filter(r=>t===r).length}function ie(...e){const t=e.flatMap(r=>Array.isArray(r)?r:Object.keys(r).map(yr));for(const r of t)if(ct(t,r)>1)throw new nt(r)}function yr(e){return e.startsWith("?")?e.slice(1):e}class G extends Error{}const z="[",K="]";function gr(e){return e!==String&&e!==Boolean&&e!==Number&&e!==Date}function Rr(e){return typeof e=="function"&&gr(e)}function be(e){return typeof e=="object"&&"get"in e&&typeof e.get=="function"&&"set"in e&&typeof e.set=="function"}function it(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function ut(e,t){return be(e)?{...e,defaultValue:t??e.defaultValue}:{get:r=>le(r,e),set:r=>te(r,e),defaultValue:t}}function wr(e){return be(e)&&e.defaultValue!==void 0}function Er(e,t){return ut(e,t)}function ft(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function M(e){return typeof e=="string"&&e.length>0}let b=null;async function br(){const{ZodSchema:e,ZodString:t,ZodBoolean:r,ZodDate:n,ZodNumber:o,ZodLiteral:a,ZodObject:s,ZodEnum:f,ZodNativeEnum:l,ZodArray:u,ZodTuple:y,ZodUnion:S,ZodDiscriminatedUnion:x,ZodRecord:g,ZodMap:h,ZodSet:R,ZodIntersection:i,ZodPromise:d,ZodFunction:U}=await import("zod");return{ZodSchema:e,ZodString:t,ZodBoolean:r,ZodDate:n,ZodNumber:o,ZodLiteral:a,ZodObject:s,ZodEnum:f,ZodNativeEnum:l,ZodArray:u,ZodTuple:y,ZodUnion:S,ZodDiscriminatedUnion:x,ZodRecord:g,ZodMap:h,ZodSet:R,ZodIntersection:i,ZodPromise:d,ZodFunction:U}}function Pr(e){return Object.values(e).some(t=>Object.values(t.host.params).some(r=>je(r))||Object.values(t.path.params).some(r=>je(r))||Object.values(t.query.params).some(r=>je(r)))}function je(e){return typeof e=="object"&&"parse"in e&&typeof e.parse=="function"}async function Sr(){try{b=await br()}catch{throw new Error("Failed to initialize Zod")}}function lt(e){return b?e instanceof b.ZodSchema:!1}function dt(e){return{get:(t,{invalid:r})=>{try{return Ze(t,e)}catch{throw r()}},set:(t,{invalid:r})=>{try{return $e(t,e)}catch{throw r()}}}}const vr=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;function ue(e,t){if(typeof t=="string"&&vr.test(t)){const r=new Date(t);return isNaN(r.getTime())?t:r}return t}function fe(e){for(const t of e)try{return t()}catch{continue}throw new Error("All functions failed")}function Pe(e,t){return b!=null&&b.ZodString&&e instanceof b.ZodString?1:b!=null&&b.ZodString&&t instanceof b.ZodString?-1:0}function Ze(e,t){if(!b)throw new Error("Zod is not initialized");if(t instanceof b.ZodString)return t.parse(e);if(t instanceof b.ZodBoolean)return t.parse(!!e);if(t instanceof b.ZodDate)return t.parse(new Date(e));if(t instanceof b.ZodNumber)return t.parse(Number(e));if(t instanceof b.ZodLiteral)return fe([()=>t.parse(Number(e)),()=>t.parse(!!e),()=>t.parse(e)]);if(t instanceof b.ZodObject)return t.parse(JSON.parse(e,ue));if(t instanceof b.ZodEnum)return t.parse(e);if(t instanceof b.ZodNativeEnum)return fe([()=>t.parse(Number(e)),()=>t.parse(e)]);if(t instanceof b.ZodArray||t instanceof b.ZodTuple)return t.parse(JSON.parse(e,ue));if(t instanceof b.ZodUnion){const r=Array.from(t._def.options).sort(Pe).map(n=>()=>Ze(e,n));return fe(r)}if(t instanceof b.ZodDiscriminatedUnion){const r=Array.from(t.options).sort(Pe).map(n=>()=>Ze(e,n));return fe(r)}if(t instanceof b.ZodRecord)return t.parse(JSON.parse(e,ue));if(t instanceof b.ZodMap)return t.parse(new Map(JSON.parse(e,ue)));if(t instanceof b.ZodSet)return t.parse(new Set(JSON.parse(e,ue)));if(t instanceof b.ZodIntersection)throw new Error("Intersection schemas are not supported");if(t instanceof b.ZodPromise)throw new Error("Promise schemas are not supported");if(t instanceof b.ZodFunction)throw new Error("Function schemas are not supported");return t.parse(e)}function $e(e,t){if(!b)throw new Error("Zod is not initialized");if(t instanceof b.ZodString)return t.parse(e);if(t instanceof b.ZodBoolean)return t.parse(e).toString();if(t instanceof b.ZodDate)return t.parse(e).toISOString();if(t instanceof b.ZodNumber)return t.parse(Number(e)).toString();if(t instanceof b.ZodLiteral)return t.parse(e).toString();if(t instanceof b.ZodObject)return JSON.stringify(t.parse(e));if(t instanceof b.ZodEnum)return t.parse(e);if(t instanceof b.ZodNativeEnum)return t.parse(e).toString();if(t instanceof b.ZodArray||t instanceof b.ZodTuple)return JSON.stringify(t.parse(e));if(t instanceof b.ZodUnion){const r=Array.from(t._def.options).sort(Pe).map(n=>()=>$e(e,n));return fe(r)}if(t instanceof b.ZodDiscriminatedUnion){const r=Array.from(t.options).sort(Pe).map(n=>()=>$e(e,n));return fe(r)}if(t instanceof b.ZodRecord)return JSON.stringify(t.parse(e));if(t instanceof b.ZodMap){const r=t.parse(e);return JSON.stringify(Array.from(r.entries()))}if(t instanceof b.ZodSet){const r=t.parse(e);return JSON.stringify(Array.from(r.values()))}if(t instanceof b.ZodIntersection)throw new Error("Intersection schemas are not supported");if(t instanceof b.ZodPromise)throw new Error("Promise schemas are not supported");if(t instanceof b.ZodFunction)throw new Error("Function schemas are not supported");return JSON.stringify(t.parse(e))}function Ar(e,t){return e[t]??String}const j={invalid:e=>{throw new G(e)}},ht={get:e=>e,set:(e,{invalid:t})=>{if(typeof e!="string")throw t();return e}},Oe={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()}},qe={get:(e,{invalid:t})=>{const r=Number(e);if(isNaN(r))throw t();return r},set:(e,{invalid:t})=>{if(typeof e!="number")throw t();return e.toString()}},pt={get:(e,{invalid:t})=>{const r=new Date(e);if(isNaN(r.getTime()))throw t();return r},set:(e,{invalid:t})=>{if(typeof e!="object"||!(e instanceof Date))throw t();return e.toISOString()}},mt={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 kr(e,t){switch(typeof t){case"string":return ht.get(e,j)===t;case"number":return qe.get(e,j)===t;case"boolean":return Oe.get(e,j)===t;default:return!1}}function le(e,t,r=!1){if(e===void 0||!M(e)){if(wr(t))return t.defaultValue;if(r)return;throw new G}if(t===String)return ht.get(e,j);if(t===Boolean)return Oe.get(e,j);if(t===Number)return qe.get(e,j);if(t===Date)return pt.get(e,j);if(t===JSON)return mt.get(e,j);if(Rr(t))return t(e,j);if(be(t))return t.get(e,j);if(t instanceof RegExp){if(t.test(e))return e;throw new G}if(it(t)){if(kr(e,t))return t;throw new G}return lt(t)?dt(t).get(e,j):e}function Ur(e,t,r=!1){try{return le(e,t,r)}catch(n){if(n instanceof G)return;throw n}}function Lr(e,t,r=!1){try{return te(e,t,r)}catch(n){if(n instanceof G)return;throw n}}function te(e,t,r=!1){if(e===void 0){if(r)return"";throw new G}if(t===Boolean)return Oe.set(e,j);if(t===Number)return qe.set(e,j);if(t===Date)return pt.set(e,j);if(t===JSON)return mt.set(e,j);if(be(t))return t.set(e,j);if(it(t)){if(t!==e)throw new G;return e.toString()}if(lt(t))return dt(t).set(e,j);try{return e.toString()}catch{throw new G}}function _e(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Br(e,t){const r=Array.from(e.matchAll(t));if(r.length===0)return[e];let n=0;const o=r.reduce((s,f)=>{const l=_e(e.slice(n,f.index));l.length&&s.push(l);const[u]=f;return s.push(u),n=f.index+u.length,s},[]),a=e.slice(n);return a&&o.push(a),o}function Cr(e){const t=yt(e.path.value);return new RegExp(`^${t}$`,"i")}function xr(e){const t=new URLSearchParams(e.query.value);return Array.from(t.entries()).filter(([,r])=>!wt(r)).map(([r,n])=>{const o=yt(n);return new RegExp(`${_e(r)}=${o}(&|$)`,"i")})}function yt(e){return Br(e,new RegExp(Nr,"g")).map(t=>t.startsWith(z)?gt(t):_e(t)).join("")}function gt(e){return[Vr,jr].reduce((t,r)=>r(t),e)}const Nr=`\\${z}\\??([\\w-_]+)\\${K}`,He=`\\${z}\\?([\\w-_]+)\\${K}`,Rt=`\\${z}([\\w-_]+)\\${K}`;function Vr(e){return e.replace(new RegExp(He,"g"),".*")}function wt(e){return new RegExp(He,"g").test(e)}function jr(e){return e.replace(new RegExp(Rt,"g"),".+")}function Se(e){const[t]=ve(e,new RegExp(He,"g")),[r]=ve(e,new RegExp(Rt,"g"));return t??r}function ve(e,t){return Array.from(e.matchAll(t)).flatMap(([,...n])=>n.map(o=>M(o)?o:""))}function Zr(e="",t={}){if(!M(e))return{};const r=new RegExp(`\\${z}(\\??[\\w-_]+)\\${K}`,"g");return Array.from(e.matchAll(r)).reduce((o,[a,s])=>{const f=Se(a);if(!f)return o;const l=Ar(t,f);return ie([f],o),o[s]=l,o},{})}function $r(e){return ft(e)&&typeof e.value=="string"}function re(e){return e===void 0?F():$r(e)?e:F(e,{})}function F(e,t){return{value:e??"",params:Zr(e,t)}}function Et(e,t){ie(e.params,t.params);const r=`${e.value}${t.value}`;return F(r,{...e.params,...t.params})}function Or(e,t){return Et(e,t)}function qr(e,t){return _r(e,t),{...e,...t}}function _r(e,t){const r=Object.keys(e).find(n=>n in t&&typeof t[n]!=typeof e[n]);if(r)throw new ot(r)}function Hr(e,t){ie(e.params,t.params);const r=[e.value,t.value].filter(M).join("&");return F(r,{...e.params,...t.params})}function Ir(e,t){return ie(e,t),{...e,...t}}function bt(e){return"parent"in e&&!!e.parent}function Pt(e){return"component"in e&&!!e.component}function St(e){return"props"in e&&typeof e.props=="function"}function vt(e){return"components"in e&&!!e.components}function At(e){return"props"in e&&typeof e.props=="object"}function kt(e,t){return{...t,path:Et(e.path,t.path),query:Hr(e.query,t.query),meta:qr(e.meta,t.meta),state:Ir(e.state,t.state),hash:Or(e.hash,t.hash),matches:[...e.matches,t.matched],host:e.host,depth:e.depth+1}}function Ie(){return typeof window<"u"&&typeof window.document<"u"}function De(e){const t=new URLSearchParams(e);return{get:(...r)=>t.get(...r),getAll:(...r)=>t.getAll(...r),set:(...r)=>{t.set(...r)},append:(...r)=>{t.append(...r)},delete:(...r)=>{t.delete(...r)},toString:(...r)=>t.toString(...r),forEach:(...r)=>{t.forEach(...r)},entries:(...r)=>t.entries(...r),keys:(...r)=>t.keys(...r),values:(...r)=>t.values(...r),has:(...r)=>t.has(...r),size:t.size,sort:()=>{t.sort()},[Symbol.iterator]:()=>t[Symbol.iterator]()}}function Te(){let e=0;return()=>(++e).toString()}const Dr=Te()();function Tr(e){return e===Dr}const Me=Te();function Ut(e){return e===void 0?"":e}function ne(e,t){const r=Me(),n=Ut(e.name),o=re(e.path),a=re(e.query),s=re(e.hash),f=e.meta??{},l=e.state??{},u=c.markRaw({id:r,meta:f,state:l,...e,props:t}),y={id:r,matched:u,matches:[u],name:n,path:o,query:a,hash:s,meta:f,state:l,depth:1,host:F(),prefetch:e.prefetch},S=bt(e)?kt(e.parent,y):y;return ie(S.path.params,S.query.params,S.hash.params),S}const Ae={template:"<div>This is component</div>"},Fe=ne({name:"parentA",path:"/parentA/[paramA]"}),Lt=ne({parent:Fe,name:"parentA.childA",path:"/childA/[?paramB]"}),Mr=ne({parent:Fe,name:"parentA.childB",path:"/childB/[paramD]",component:Ae}),Fr=ne({parent:Lt,name:"parentA.childA.grandChildA",path:"/[paramC]",component:Ae});ne({name:"parentB",path:"/parentB",component:Ae}),ne({name:"parentC",path:"/",component:Ae});const Jr="lazy",Wr={components:!0,props:!1};function ke(e){return["eager","lazy","intent"].includes(e)}function Bt({routerPrefetch:e,routePrefetch:t,linkPrefetch:r},n){const o=Je(r,n),a=Je(t,n),s=Je(e,n),f=[o,a,s,Wr[n],Jr].reduce((l,u)=>ke(l)?l:l===!0&&ke(u)?u:l===!0&&!ke(u)?l:l===void 0?u:l,void 0);return ke(f)?f:!1}function Je(e,t){return ft(e)?e[t]:e}class Ct extends Error{constructor(){super("Uncaught CallbackContextAbortError");W(this,"response");this.response={status:"ABORT"}}}class de extends Error{constructor(r){super("Uncaught CallbackContextPushError");W(this,"response");this.response={status:"PUSH",to:r}}}class Ue extends Error{constructor(r){super("Uncaught CallbackContextRejectionError");W(this,"response");this.response={status:"REJECT",type:r}}}function xt(){return{reject:o=>{throw new Ue(o)},push:(...o)=>{throw new de(o)},replace:(o,a,s)=>{if(Z(o)){const u=a??{};throw new de([o,{...u,replace:!0}])}const f=a,l=s??{};throw new de([o,f,{...l,replace:!0}])},abort:()=>{throw new Ct}}}function Nt(e){return typeof e=="object"&&e!==null&&"then"in e}function Vt(e){try{const t=e();return Nt(t)?t.catch(r=>r):t}catch(t){return t}}const jt=Symbol();function Gr(){const e=c.reactive(new Map),{push:t,replace:r,reject:n}=xt(),o=(g,h,R)=>h.matches.filter(i=>Bt({...R,routePrefetch:i.prefetch},"props")===g).flatMap(i=>S(i)).reduce((i,{id:d,name:U,props:w})=>{if(!w)return i;const E=y(d,U,h),A=Vt(()=>w(h,{push:t,replace:r,reject:n,parent:l(h,!0)}));return i[E]=A,i},{}),a=g=>{Object.entries(g).forEach(([h,R])=>{e.set(h,R)})},s=async g=>{const h=g.matches.flatMap(S),R=[],i=[];for(const{id:d,name:U,props:w}of h){if(!w)continue;const E=y(d,U,g);if(R.push(E),!e.has(E)){const A=Vt(()=>w(g,{push:t,replace:r,reject:n,parent:l(g)}));e.set(E,A)}i.push((async()=>{const A=await e.get(E);if(A instanceof Error)throw A})())}x(R);try{return await Promise.all(i),{status:"SUCCESS"}}catch(d){if(d instanceof de||d instanceof Ue)return d.response;throw d}},f=(g,h,R)=>{const i=y(g,h,R);return e.get(i)};function l(g,h=!1){const R=g.matches.at(-2);if(R)return St(R)?{name:R.name??"",get props(){return u(R,"default",g,h)}}:At(R)?{name:R.name??"",props:new Proxy({},{get(i,d){return typeof d!="string"?Reflect.get(i,d):u(R,d,g,h)}})}:{name:R.name??"",props:void 0}}function u(g,h,R,i=!1){const d=f(g.id,h,R);if(i&&!d){const U=g.name??"unknown",w=R.name||"unknown";console.warn(`
|
|
2
|
+
Unable to access parent props "${h}" from route "${U}" while prefetching props for route "${w}".
|
|
3
3
|
This may occur if the parent route's props were not also prefetched.
|
|
4
|
-
`)}return d}function R(y,p,g){return[y,p,g.id,JSON.stringify(g.params)].join("-")}function P(y){return st(y)?[{id:y.id,name:"default",props:y.props}]:ut(y)?Object.entries(y.props).map(([p,g])=>({id:y.id,name:p,props:g})):[]}function x(y){for(const p of e.keys())y.includes(p)||e.delete(p)}return{getPrefetchProps:o,setPrefetchProps:a,getProps:f,setProps:s}}function er(){const e=c.inject(Zt);if(!e)throw new X;return e}const Qn=c.defineAsyncComponent(()=>new Promise(e=>{e({default:{template:"foo"}})}));function tr(e){return e.name===Qn.name&&"__asyncLoader"in e}function rr(e,t,r){c.watch(e,(n,o)=>{n&&n.addEventListener(t,r),o&&o.removeEventListener(t,r)},{immediate:!0}),c.onUnmounted(()=>{e.value&&e.value.removeEventListener(t,r)})}function zn(e){const t=new Map,r=c.ref(),{getPrefetchProps:n,setPrefetchProps:o}=er(),{isElementVisible:a}=Zr(r),s=()=>{const i=Array.from(t.values()).reduce((R,P)=>(Object.assign(R,P),R),{});o(i)};c.watch(()=>c.toValue(e),({route:i,...R})=>{t.clear(),i&&l("eager",i,R)},{immediate:!0}),c.watch(a,i=>{const{route:R,...P}=c.toValue(e);!R||!i||l("lazy",R,P)},{immediate:!0}),rr(r,"focusin",f),rr(r,"mouseover",f);function f(){const{route:i,...R}=c.toValue(e);i&&l("intent",i,R)}function l(i,R,P){Kn(i,R,P),t.has(i)||t.set(i,n(i,R,P))}return{element:r,commit:s}}function Kn(e,t,r){t.matches.forEach(n=>{Yt({...r,routePrefetch:n.prefetch},"components")===e&&(at(n)&&tr(n.component)&&n.component.__asyncLoader(),ct(n)&&Object.values(n.components).forEach(a=>{tr(a)&&a.__asyncLoader()}))})}function nr(e,t={},r={}){const n=ye(),o=c.computed(()=>{const p=c.toValue(e);return typeof p!="string"?p:N(p)?n.find(p,c.toValue(r)):n.resolve(p,c.toValue(t),c.toValue(r))}),a=c.computed(()=>{if(o.value)return o.value.href;const p=c.toValue(e);if(N(p))return p;console.error(new Error("Failed to resolve route in RouterLink."))}),s=c.computed(()=>De(n.route)&&n.route.matches.some(p=>{var g;return p.id===((g=o.value)==null?void 0:g.id)})),f=c.computed(()=>{var p;return n.route.id===((p=o.value)==null?void 0:p.id)}),l=c.computed(()=>!!a.value&&n.isExternal(a.value)),i=c.computed(()=>{const p=c.toValue(e);return typeof p!="string"||N(p)?c.toValue(t):c.toValue(r)}),{element:R,commit:P}=zn(()=>({route:o.value,routerPrefetch:n.prefetch,linkPrefetch:i.value.prefetch})),x=p=>{P();const g={replace:(p==null?void 0:p.replace)??i.value.replace,query:Oe(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}},u=c.toValue(e);return N(u)||typeof u=="object"?n.push(u,g):n.push(u,c.toValue(t),g)};return{element:R,route:o,href:a,isMatch:s,isExactMatch:f,isExternal:l,push:x,replace:p=>x({...p,replace:!0})}}const Yn=["href"],or=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,r=ye(),n=c.computed(()=>x(t.to)),o=c.computed(()=>y(t.to)),a=c.computed(()=>{const{to:g,...u}=t;return u}),{element:s,isMatch:f,isExactMatch:l,isExternal:i,push:R}=nr(()=>typeof t.to=="function"?t.to(r.resolve):t.to,a),P=c.computed(()=>({"router-link--match":f.value,"router-link--exact-match":l.value}));function x(g){if(typeof g=="function"){const u=g(r.resolve);return x(u)}return N(g)?r.find(g):g}function y(g){if(typeof g=="function"){const u=g(r.resolve);return y(u)}return N(g)?g:g==null?void 0:g.href}function p(g){g.preventDefault(),R()}return(g,u)=>(c.openBlock(),c.createElementBlock("a",{ref_key:"element",ref:s,href:o.value,class:c.normalizeClass(["router-link",P.value]),onClick:p},[c.renderSlot(g.$slots,"default",c.normalizeProps(c.guardReactiveProps({route:n.value,isMatch:c.unref(f),isExactMatch:c.unref(l),isExternal:c.unref(i)})))],10,Yn))}});function ar(){const e=c.inject(At);if(!e)throw new X;return e}function sr(e){return t=>{const r=We(),o=ar().addComponentBeforeRouteHook({lifecycle:e,hook:t,depth:r-1});return c.onUnmounted(o),o}}function cr(e){return t=>{const r=We(),o=ar().addComponentAfterRouteHook({lifecycle:e,hook:t,depth:r-1});return c.onUnmounted(o),o}}const Xn=sr("onBeforeRouteLeave"),Zn=sr("onBeforeRouteUpdate"),eo=cr("onAfterRouteLeave"),to=cr("onAfterRouteUpdate");function ro(e){return le(e)&&typeof e.value=="string"}function ur(e){return ro(e)?e:Wt(e,{})}function no(e){const t=$e(),r=Gt(e.name),n=Qt(e.path),o=zt(e.query),a=Jt(e.hash),s=e.meta??{},f=gr(e)?ur(e.host):ur(""),l=c.markRaw({id:t,meta:{},state:{},...e}),i={id:t,matched:l,matches:[l],name:r,host:f,path:n,query:o,hash:a,meta:s,depth:1,state:{}},R=ot(e)?it(e.parent,i):i;return se(R.path.params,R.query.params,R.host.params),R}A.DuplicateParamsError=Ze,A.MetaPropertyConflict=et,A.RouterLink=or,A.RouterNotInstalledError=X,A.RouterView=Je,A.UseRouteInvalidError=tt,A.arrayOf=qn,A.asUrl=Ce,A.createExternalRoute=no,A.createParam=pt,A.createRoute=oe,A.createRouter=Hn,A.createRouterPlugin=_n,A.isRoute=De,A.isUrl=N,A.onAfterRouteLeave=eo,A.onAfterRouteUpdate=to,A.onBeforeRouteLeave=Xn,A.onBeforeRouteUpdate=Zn,A.path=ke,A.query=Ge,A.tupleOf=On,A.unionOf=Ft,A.useLink=nr,A.useRoute=Fe,A.useRouter=ye,A.withDefault=br,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|
|
4
|
+
`)}return d}function y(g,h,R){return[g,h,R.id,JSON.stringify(R.params)].join("-")}function S(g){return St(g)?[{id:g.id,name:"default",props:g.props}]:At(g)?Object.entries(g.props).map(([h,R])=>({id:g.id,name:h,props:R})):[]}function x(g){for(const h of e.keys())g.includes(h)||e.delete(h)}return{getPrefetchProps:o,setPrefetchProps:a,getProps:f,setProps:s}}function Zt(){const e=c.inject(jt);if(!e)throw new ee;return e}const zr=c.defineAsyncComponent(()=>new Promise(e=>{e({default:{template:"foo"}})}));function $t(e){return e.name===zr.name&&"__asyncLoader"in e}const Ot=Symbol("visibilityObserver");function Qr(e){const t=c.inject(Ot);if(!t)throw new ee;return c.watch(e,(n,o)=>{n&&t.observe(n),o&&t.unobserve(o)},{immediate:!0}),c.onUnmounted(()=>{e.value&&t.unobserve(e.value)}),{isElementVisible:c.computed(()=>e.value?t.isElementVisible(e.value):!1)}}function qt(e,t,r){c.watch(e,(n,o)=>{n&&n.addEventListener(t,r),o&&o.removeEventListener(t,r)},{immediate:!0}),c.onUnmounted(()=>{e.value&&e.value.removeEventListener(t,r)})}function Kr(e){const t=new Map,r=c.ref(),{getPrefetchProps:n,setPrefetchProps:o}=Zt(),{isElementVisible:a}=Qr(r),s=()=>{const u=Array.from(t.values()).reduce((y,S)=>(Object.assign(y,S),y),{});o(u)};c.watch(()=>c.toValue(e),({route:u,...y})=>{t.clear(),u&&l("eager",u,y)},{immediate:!0}),c.watch(a,u=>{const{route:y,...S}=c.toValue(e);!y||!u||l("lazy",y,S)},{immediate:!0}),qt(r,"focusin",f),qt(r,"mouseover",f);function f(){const{route:u,...y}=c.toValue(e);u&&l("intent",u,y)}function l(u,y,S){Yr(u,y,S),t.has(u)||t.set(u,n(u,y,S))}return{element:r,commit:s}}function Yr(e,t,r){t.matches.forEach(n=>{Bt({...r,routePrefetch:n.prefetch},"components")===e&&(Pt(n)&&$t(n.component)&&n.component.__asyncLoader(),vt(n)&&Object.values(n.components).forEach(a=>{$t(a)&&a.__asyncLoader()}))})}const _t=Symbol("isRouterRouteSymbol");function Xr(e){return typeof e=="object"&&e!==null&&_t in e}function en(e,t){function r(i,d,U){if(typeof i=="object"){const E={...e.params,...i};return t(e.name,E,d)}const w={...e.params,[i]:d};return t(e.name,w,U)}const n=(...i)=>{const d=new URLSearchParams(e.query);d.set(...i),r({},{query:d})},o=(...i)=>{const d=new URLSearchParams(e.query);d.append(...i),r({},{query:d})},a=(...i)=>{const d=new URLSearchParams(e.query);d.delete(...i),r({},{query:d})},{id:s,matched:f,matches:l,name:u,hash:y,href:S}=c.toRefs(e),x=c.computed({get(){return new Proxy(e.params,{set(i,d,U){return r(d,U),!0}})},set(i){r(i)}}),g=c.computed({get(){return new Proxy(e.query,{get(i,d,U){switch(d){case"append":return o;case"set":return n;case"delete":return a;default:return Reflect.get(i,d,U)}}})},set(i){r({},{query:i})}}),h=c.computed({get(){return new Proxy(e.state,{set(i,d,U){return r({},{state:{...e.state,[d]:U}}),!0}})},set(i){r({},{state:i})}});return c.reactive({id:s,matched:f,matches:l,state:h,query:g,hash:y,params:x,name:u,href:S,update:r,[_t]:!0})}function We(e,t,{exact:r}={}){return Xr(e)?t===void 0?!0:r?e.matched.name===t:e.matches.map(n=>n.name).includes(t):!1}function Ge(...e){const t=new URLSearchParams;for(const r of e){const n=new URLSearchParams(r);for(const[o,a]of n.entries())t.append(o,a)}return t}function Ht(e,t={},r={}){const n=Ee(),o=c.computed(()=>{const h=c.toValue(e);return typeof h!="string"?h:Z(h)?n.find(h,c.toValue(r)):n.resolve(h,c.toValue(t),c.toValue(r))}),a=c.computed(()=>{if(o.value)return o.value.href;const h=c.toValue(e);if(Z(h))return h;console.error(new Error("Failed to resolve route in RouterLink."))}),s=c.computed(()=>We(n.route)&&n.route.matches.some(h=>{var R;return h.id===((R=o.value)==null?void 0:R.id)})),f=c.computed(()=>{var h;return n.route.id===((h=o.value)==null?void 0:h.id)}),l=c.computed(()=>!!a.value&&n.isExternal(a.value)),u=c.computed(()=>{const h=c.toValue(e);return typeof h!="string"||Z(h)?c.toValue(t):c.toValue(r)}),{element:y,commit:S}=Kr(()=>({route:o.value,routerPrefetch:n.prefetch,linkPrefetch:u.value.prefetch})),x=h=>{S();const R={replace:(h==null?void 0:h.replace)??u.value.replace,query:Ge(u.value.query,h==null?void 0:h.query),hash:(h==null?void 0:h.hash)??u.value.hash,state:{...u.value.state,...h==null?void 0:h.state}},i=c.toValue(e);return Z(i)||typeof i=="object"?n.push(i,R):n.push(i,c.toValue(t),R)};return{element:y,route:o,href:a,isMatch:s,isExactMatch:f,isExternal:l,push:x,replace:h=>x({...h,replace:!0})}}const tn=["href"],It=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,r=Ee(),n=c.computed(()=>x(t.to)),o=c.computed(()=>g(t.to)),a=c.computed(()=>{const{to:R,...i}=t;return i}),{element:s,isMatch:f,isExactMatch:l,isExternal:u,push:y}=Ht(()=>typeof t.to=="function"?t.to(r.resolve):t.to,a),S=c.computed(()=>({"router-link--match":f.value,"router-link--exact-match":l.value}));function x(R){if(typeof R=="function"){const i=R(r.resolve);return x(i)}return Z(R)?r.find(R):R}function g(R){if(typeof R=="function"){const i=R(r.resolve);return g(i)}return Z(R)?R:R==null?void 0:R.href}function h(R){R.preventDefault(),y()}return(R,i)=>(c.openBlock(),c.createElementBlock("a",{ref_key:"element",ref:s,href:o.value,class:c.normalizeClass(["router-link",S.value]),onClick:h},[c.renderSlot(R.$slots,"default",c.normalizeProps(c.guardReactiveProps({route:n.value,isMatch:c.unref(f),isExactMatch:c.unref(l),isExternal:c.unref(u)})))],10,tn))}}),Dt=Symbol();function rn(){const e=c.inject(Dt);if(!e)throw new ee;return e}function ze(e,t){const r=Ee();function n(){if(!e)return;if(!We(r.route,e,t))throw new at(e,r.route.name)}return c.watch(r.route,n,{immediate:!0,deep:!0}),r.route}const Tt=Symbol();function Qe(){return c.inject(Tt,0)}function nn(e,t,r){return c.defineComponent({name:"PropsWrapper",expose:[],setup(){const n=c.getCurrentInstance(),o=Zt(),a=ze();return()=>{const s=o.getProps(e.id,t,a);return s instanceof Error?"":Nt(s)?n!=null&&n.suspense?c.h(an,{component:r,props:s}):c.h(on,{component:r,props:s}):c.h(r,s)}}})}const on=c.defineComponent(e=>{const t=c.ref();return c.watch(()=>e.props,async r=>{t.value=await r},{immediate:!0,deep:!0}),()=>t.value instanceof Error?"":t.value?c.h(e.component,t.value):""},{props:["component","props"]}),an=c.defineComponent(async e=>{const t=c.ref();return t.value=await e.props,c.watch(()=>t.value,async r=>{t.value=await r},{deep:!0}),()=>t.value instanceof Error?"":t.value?c.h(e.component,t.value):""},{props:["component","props"]}),Mt=Symbol();function sn(){const e=new Map;return{getRouteComponents:r=>{const n=e.get(r.id);if(n)return n;const o=cn(r);return e.set(r.id,o),o}}}function cn(e){return vt(e)?Ft(e,e.components):Pt(e)?Ft(e,{default:e.component}):{default:Ke}}function Ft(e,t){return Object.fromEntries(Object.entries(t).map(([r,n])=>[r,nn(e,r,n)]))}function un(){const e=c.inject(Mt);if(!e)throw new ee;return e}const Ke=c.defineComponent({__name:"routerView",props:{name:{default:"default"}},setup(e){const t=ze(),r=rn(),n=Qe(),{getRouteComponents:o}=un();c.provide(Tt,n+1);const a=c.computed(()=>{if(r.value)return r.value.component;const s=t.matches.at(n);return s?o(s)[e.name]:null});return(s,f)=>a.value?c.renderSlot(s.$slots,"default",c.normalizeProps(c.mergeProps({key:0},{route:c.unref(t),component:a.value,rejection:c.unref(r)})),()=>[(c.openBlock(),c.createBlock(c.resolveDynamicComponent(a.value)))]):c.createCommentVNode("",!0)}});class oe{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)}}const ye=(e,t,r)=>{var a,s;const n=e.matches,o=(t==null?void 0:t.matches)??[];return((a=n.at(r))==null?void 0:a.id)!==((s=o.at(r))==null?void 0:s.id)},ge=(e,t,r)=>{var a,s;const n=e.matches,o=(t==null?void 0:t.matches)??[];return((a=n.at(r))==null?void 0:a.id)!==((s=o.at(r))==null?void 0:s.id)},Re=(e,t,r)=>{var n,o;return((n=e.matches.at(r))==null?void 0:n.id)===((o=t==null?void 0:t.matches.at(r))==null?void 0:o.id)};function Jt(e){switch(e){case"onBeforeRouteEnter":case"onAfterRouteEnter":return ye;case"onBeforeRouteUpdate":case"onAfterRouteUpdate":return Re;case"onBeforeRouteLeave":case"onAfterRouteLeave":return ge;default:throw new Error(`Switch is not exhaustive for lifecycle: ${e}`)}}function fn(e,t){const r=new oe;return e.matches.forEach((n,o)=>{n.onBeforeRouteEnter&&ye(e,t,o)&&ce(n.onBeforeRouteEnter).forEach(a=>r.onBeforeRouteEnter.add(a)),n.onBeforeRouteUpdate&&Re(e,t,o)&&ce(n.onBeforeRouteUpdate).forEach(a=>r.onBeforeRouteUpdate.add(a))}),t==null||t.matches.forEach((n,o)=>{n.onBeforeRouteLeave&&ge(e,t,o)&&ce(n.onBeforeRouteLeave).forEach(a=>r.onBeforeRouteLeave.add(a))}),r}function ln(e,t){const r=new oe;return e.matches.forEach((n,o)=>{n.onAfterRouteEnter&&ye(e,t,o)&&ce(n.onAfterRouteEnter).forEach(a=>r.onAfterRouteEnter.add(a)),n.onAfterRouteUpdate&&Re(e,t,o)&&ce(n.onAfterRouteUpdate).forEach(a=>r.onAfterRouteUpdate.add(a))}),t==null||t.matches.forEach((n,o)=>{n.onAfterRouteLeave&&ge(e,t,o)&&ce(n.onAfterRouteLeave).forEach(a=>r.onAfterRouteLeave.add(a))}),r}function dn(e,t,r){const n=new oe;return e.matches.forEach((o,a)=>{ye(e,t,a)&&r.onBeforeRouteEnter.forEach(s=>n.onBeforeRouteEnter.add(s)),Re(e,t,a)&&r.onBeforeRouteUpdate.forEach(s=>n.onBeforeRouteUpdate.add(s))}),t==null||t.matches.forEach((o,a)=>{ge(e,t,a)&&r.onBeforeRouteLeave.forEach(s=>n.onBeforeRouteLeave.add(s))}),n}function hn(e,t,r){const n=new oe;return e.matches.forEach((o,a)=>{ye(e,t,a)&&r.onAfterRouteEnter.forEach(s=>n.onAfterRouteEnter.add(s)),Re(e,t,a)&&r.onAfterRouteUpdate.forEach(s=>n.onAfterRouteUpdate.add(s))}),t==null||t.matches.forEach((o,a)=>{ge(e,t,a)&&r.onAfterRouteLeave.forEach(s=>n.onAfterRouteLeave.add(s))}),n}const Wt=Symbol();function pn(){const e={global:new oe,component:new oe},{reject:t,push:r,replace:n,abort:o}=xt(),a=i=>(e.global.onBeforeRouteEnter.add(i),()=>e.global.onBeforeRouteEnter.delete(i)),s=i=>(e.global.onBeforeRouteUpdate.add(i),()=>e.global.onBeforeRouteUpdate.delete(i)),f=i=>(e.global.onBeforeRouteLeave.add(i),()=>e.global.onBeforeRouteLeave.delete(i)),l=i=>(e.global.onAfterRouteEnter.add(i),()=>e.global.onAfterRouteEnter.delete(i)),u=i=>(e.global.onAfterRouteUpdate.add(i),()=>e.global.onAfterRouteUpdate.delete(i)),y=i=>(e.global.onAfterRouteLeave.add(i),()=>e.global.onAfterRouteLeave.delete(i));async function S({to:i,from:d}){const{global:U,component:w}=e,E=fn(i,d),A=dn(i,d,U),B=[...A.onBeforeRouteEnter,...E.onBeforeRouteEnter,...A.onBeforeRouteUpdate,...E.onBeforeRouteUpdate,...w.onBeforeRouteUpdate,...A.onBeforeRouteLeave,...E.onBeforeRouteLeave,...w.onBeforeRouteLeave];try{const m=B.map(p=>p(i,{from:d,reject:t,push:r,replace:n,abort:o}));await Promise.all(m)}catch(m){if(m instanceof de||m instanceof Ue||m instanceof Ct)return m.response;throw m}return{status:"SUCCESS"}}async function x({to:i,from:d}){const{global:U,component:w}=e,E=ln(i,d),A=hn(i,d,U),B=[...w.onAfterRouteLeave,...E.onAfterRouteLeave,...A.onAfterRouteLeave,...w.onAfterRouteUpdate,...E.onAfterRouteUpdate,...A.onAfterRouteUpdate,...w.onAfterRouteEnter,...E.onAfterRouteEnter,...A.onAfterRouteEnter];try{const m=B.map(p=>p(i,{from:d,reject:t,push:r,replace:n}));await Promise.all(m)}catch(m){if(m instanceof de||m instanceof Ue)return m.response;throw m}return{status:"SUCCESS"}}return{runBeforeRouteHooks:S,runAfterRouteHooks:x,addComponentBeforeRouteHook:({lifecycle:i,depth:d,hook:U})=>{const w=Jt(i),E=e.component[i],A=(B,m)=>{if(w(B,m.from,d))return U(B,m)};return E.add(A),()=>E.delete(A)},addComponentAfterRouteHook:({lifecycle:i,depth:d,hook:U})=>{const w=Jt(i),E=e.component[i],A=(B,m)=>{if(w(B,m.from,d))return U(B,m)};return E.add(A),()=>E.delete(A)},addGlobalRouteHooks:i=>{i.onBeforeRouteEnter.forEach(d=>a(d)),i.onBeforeRouteUpdate.forEach(d=>s(d)),i.onBeforeRouteLeave.forEach(d=>f(d)),i.onAfterRouteEnter.forEach(d=>l(d)),i.onAfterRouteUpdate.forEach(d=>u(d)),i.onAfterRouteLeave.forEach(d=>y(d))},onBeforeRouteEnter:a,onBeforeRouteUpdate:s,onBeforeRouteLeave:f,onAfterRouteEnter:l,onAfterRouteUpdate:u,onAfterRouteLeave:y}}function Gt(){const e=c.inject(Wt);if(!e)throw new ee;return e}function zt(e){return t=>{const r=Qe(),o=Gt().addComponentBeforeRouteHook({lifecycle:e,hook:t,depth:r-1});return c.onUnmounted(o),o}}function Qt(e){return t=>{const r=Qe(),o=Gt().addComponentAfterRouteHook({lifecycle:e,hook:t,depth:r-1});return c.onUnmounted(o),o}}const mn=zt("onBeforeRouteLeave"),yn=zt("onBeforeRouteUpdate"),gn=Qt("onAfterRouteLeave"),Rn=Qt("onAfterRouteUpdate");function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Y.apply(null,arguments)}var O;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(O||(O={}));var he=process.env.NODE_ENV!=="production"?function(e){return Object.freeze(e)}:function(e){return e};function ae(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}var Le="beforeunload",wn="hashchange",Kt="popstate";function Yt(e){e===void 0&&(e={});var t=e,r=t.window,n=r===void 0?document.defaultView:r,o=n.history;function a(){var m=n.location,p=m.pathname,P=m.search,L=m.hash,C=o.state||{};return[C.idx,he({pathname:p,search:P,hash:L,state:C.usr||null,key:C.key||"default"})]}var s=null;function f(){if(s)g.call(s),s=null;else{var m=O.Pop,p=a(),P=p[0],L=p[1];if(g.length)if(P!=null){var C=y-P;C&&(s={action:m,location:L,retry:function(){A(C*-1)}},A(C))}else process.env.NODE_ENV!=="production"&&ae(!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(m)}}n.addEventListener(Kt,f);var l=O.Pop,u=a(),y=u[0],S=u[1],x=pe(),g=pe();y==null&&(y=0,o.replaceState(Y({},o.state,{idx:y}),""));function h(m){return typeof m=="string"?m:se(m)}function R(m,p){return p===void 0&&(p=null),he(Y({pathname:S.pathname,hash:"",search:""},typeof m=="string"?we(m):m,{state:p,key:Ce()}))}function i(m,p){return[{usr:m.state,key:m.key,idx:p},h(m)]}function d(m,p,P){return!g.length||(g.call({action:m,location:p,retry:P}),!1)}function U(m){l=m;var p=a();y=p[0],S=p[1],x.call({action:l,location:S})}function w(m,p){var P=O.Push,L=R(m,p);function C(){w(m,p)}if(d(P,L,C)){var V=i(L,y+1),$=V[0],q=V[1];try{o.pushState($,"",q)}catch{n.location.assign(q)}U(P)}}function E(m,p){var P=O.Replace,L=R(m,p);function C(){E(m,p)}if(d(P,L,C)){var V=i(L,y),$=V[0],q=V[1];o.replaceState($,"",q),U(P)}}function A(m){o.go(m)}var B={get action(){return l},get location(){return S},createHref:h,push:w,replace:E,go:A,back:function(){A(-1)},forward:function(){A(1)},listen:function(p){return x.push(p)},block:function(p){var P=g.push(p);return g.length===1&&n.addEventListener(Le,Be),function(){P(),g.length||n.removeEventListener(Le,Be)}}};return B}function En(e){e===void 0&&(e={});var t=e,r=t.window,n=r===void 0?document.defaultView:r,o=n.history;function a(){var p=we(n.location.hash.substr(1)),P=p.pathname,L=P===void 0?"/":P,C=p.search,V=C===void 0?"":C,$=p.hash,q=$===void 0?"":$,I=o.state||{};return[I.idx,he({pathname:L,search:V,hash:q,state:I.usr||null,key:I.key||"default"})]}var s=null;function f(){if(s)g.call(s),s=null;else{var p=O.Pop,P=a(),L=P[0],C=P[1];if(g.length)if(L!=null){var V=y-L;V&&(s={action:p,location:C,retry:function(){B(V*-1)}},B(V))}else process.env.NODE_ENV!=="production"&&ae(!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 w(p)}}n.addEventListener(Kt,f),n.addEventListener(wn,function(){var p=a(),P=p[1];se(P)!==se(S)&&f()});var l=O.Pop,u=a(),y=u[0],S=u[1],x=pe(),g=pe();y==null&&(y=0,o.replaceState(Y({},o.state,{idx:y}),""));function h(){var p=document.querySelector("base"),P="";if(p&&p.getAttribute("href")){var L=n.location.href,C=L.indexOf("#");P=C===-1?L:L.slice(0,C)}return P}function R(p){return h()+"#"+(typeof p=="string"?p:se(p))}function i(p,P){return P===void 0&&(P=null),he(Y({pathname:S.pathname,hash:"",search:""},typeof p=="string"?we(p):p,{state:P,key:Ce()}))}function d(p,P){return[{usr:p.state,key:p.key,idx:P},R(p)]}function U(p,P,L){return!g.length||(g.call({action:p,location:P,retry:L}),!1)}function w(p){l=p;var P=a();y=P[0],S=P[1],x.call({action:l,location:S})}function E(p,P){var L=O.Push,C=i(p,P);function V(){E(p,P)}if(process.env.NODE_ENV!=="production"&&ae(C.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.push("+JSON.stringify(p)+")"),U(L,C,V)){var $=d(C,y+1),q=$[0],I=$[1];try{o.pushState(q,"",I)}catch{n.location.assign(I)}w(L)}}function A(p,P){var L=O.Replace,C=i(p,P);function V(){A(p,P)}if(process.env.NODE_ENV!=="production"&&ae(C.pathname.charAt(0)==="/","Relative pathnames are not supported in hash history.replace("+JSON.stringify(p)+")"),U(L,C,V)){var $=d(C,y),q=$[0],I=$[1];o.replaceState(q,"",I),w(L)}}function B(p){o.go(p)}var m={get action(){return l},get location(){return S},createHref:R,push:E,replace:A,go:B,back:function(){B(-1)},forward:function(){B(1)},listen:function(P){return x.push(P)},block:function(P){var L=g.push(P);return g.length===1&&n.addEventListener(Le,Be),function(){L(),g.length||n.removeEventListener(Le,Be)}}};return m}function Xt(e){e===void 0&&(e={});var t=e,r=t.initialEntries,n=r===void 0?["/"]:r,o=t.initialIndex,a=n.map(function(w){var E=he(Y({pathname:"/",search:"",hash:"",state:null,key:Ce()},typeof w=="string"?we(w):w));return process.env.NODE_ENV!=="production"&&ae(E.pathname.charAt(0)==="/","Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: "+JSON.stringify(w)+")"),E}),s=er(o??a.length-1,0,a.length-1),f=O.Pop,l=a[s],u=pe(),y=pe();function S(w){return typeof w=="string"?w:se(w)}function x(w,E){return E===void 0&&(E=null),he(Y({pathname:l.pathname,search:"",hash:""},typeof w=="string"?we(w):w,{state:E,key:Ce()}))}function g(w,E,A){return!y.length||(y.call({action:w,location:E,retry:A}),!1)}function h(w,E){f=w,l=E,u.call({action:f,location:l})}function R(w,E){var A=O.Push,B=x(w,E);function m(){R(w,E)}process.env.NODE_ENV!=="production"&&ae(l.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.push("+JSON.stringify(w)+")"),g(A,B,m)&&(s+=1,a.splice(s,a.length,B),h(A,B))}function i(w,E){var A=O.Replace,B=x(w,E);function m(){i(w,E)}process.env.NODE_ENV!=="production"&&ae(l.pathname.charAt(0)==="/","Relative pathnames are not supported in memory history.replace("+JSON.stringify(w)+")"),g(A,B,m)&&(a[s]=B,h(A,B))}function d(w){var E=er(s+w,0,a.length-1),A=O.Pop,B=a[E];function m(){d(w)}g(A,B,m)&&(s=E,h(A,B))}var U={get index(){return s},get action(){return f},get location(){return l},createHref:S,push:R,replace:i,go:d,back:function(){d(-1)},forward:function(){d(1)},listen:function(E){return u.push(E)},block:function(E){return y.push(E)}};return U}function er(e,t,r){return Math.min(Math.max(e,t),r)}function Be(e){e.preventDefault(),e.returnValue=""}function pe(){var e=[];return{get length(){return e.length},push:function(r){return e.push(r),function(){e=e.filter(function(n){return n!==r})}},call:function(r){e.forEach(function(n){return n&&n(r)})}}}function Ce(){return Math.random().toString(36).substr(2,8)}function se(e){var t=e.pathname,r=t===void 0?"/":t,n=e.search,o=n===void 0?"":n,a=e.hash,s=a===void 0?"":a;return o&&o!=="?"&&(r+=o.charAt(0)==="?"?o:"?"+o),s&&s!=="#"&&(r+=s.charAt(0)==="#"?s:"#"+s),r}function we(e){var t={};if(e){var r=e.indexOf("#");r>=0&&(t.hash=e.substr(r),e=e.substr(0,r));var n=e.indexOf("?");n>=0&&(t.search=e.substr(n),e=e.substr(0,n)),e&&(t.pathname=e)}return t}const tr=Symbol();function bn(e,t){const r=c.reactive({...e}),n=s=>{Object.assign(r,{[tr]:!1,...s})},o=r,a=en(o,t);return{currentRoute:o,routerRoute:a,updateRoute:n}}function _(e){return!e.startsWith("http")?Sn(e):Pn(e)}function Pn(e){const{protocol:t,host:r,pathname:n,search:o,searchParams:a,hash:s}=new URL(e,e);return{protocol:t,host:r,pathname:n,search:o,searchParams:a,hash:s}}function Sn(e){const{pathname:t,search:r,searchParams:n,hash:o}=new URL(e,"https://localhost");return{pathname:t,search:r,searchParams:n,hash:o}}function vn(e){return t=>{const{host:r}=_(t);return!(r===void 0||r===e)}}function An({mode:e,listener:t}){const r=kn(e),n=(l,u)=>{if(u!=null&&u.replace){r.replace(l,u.state);return}r.push(l,u==null?void 0:u.state)},o=()=>{const l=se(r.location);r.replace(l)};let a;return{...r,update:n,refresh:o,startListening:()=>{a==null||a(),a=r.listen(t)},stopListening:()=>{a==null||a()}}}function kn(e="auto"){switch(e){case"auto":return Ie()?Yt():Xt();case"browser":return Yt();case"memory":return Xt();case"hash":return En();default:const t=e;throw new Error(`Switch is not exhaustive for mode: ${t}`)}}function Un(e){return c.defineComponent(()=>()=>c.h("h1",e),{name:e,props:[]})}function Ln(e){const t=a=>c.markRaw(e[a]??Un(a)),r=a=>{const s=c.markRaw(t(a)),f={id:Me(),component:s,meta:{},state:{}};return{id:f.id,matched:f,matches:[f],name:a,query:De(""),params:{},state:{},href:"/",hash:"",[tr]:!0}},n=a=>{if(!a){o.value=null;return}const s=t(a);o.value={type:a,component:s}},o=c.ref(null);return{setRejection:n,rejection:o,getRejectionRoute:r}}class Bn extends Error{constructor(){super("initialUrl must be set if window.location is unavailable")}}function Cn(e){if(e)return e;if(Ie())return window.location.toString();throw new Bn}function rr(e){return!!e&&typeof e=="object"}const xe=!0;function xn(e,t,r){if(rr(e)&&t in e){const n=e[t];return typeof n=="string"?le(n,r,xe):n}return le(void 0,r,xe)}function nr(e,t){const r={};for(const[n,o]of Object.entries(e)){const a=xn(t,n,o);r[n]=a}return r}function Nn(e,t,r){if(rr(e)&&t in e){const n=e[t];return te(n,r,xe)}return te(void 0,r,xe)}const or=(e,t)=>{const r={};for(const[n,o]of Object.entries(e)){const a=Nn(t,n,o);r[n]=a}return r};function Vn(){const e=c.reactive(new Map),t=Ie()?s():null,r=f=>{e.set(f,!1),t==null||t.observe(f)},n=f=>{e.delete(f),t==null||t.unobserve(f)},o=()=>{t==null||t.disconnect()},a=f=>e.get(f)??!1;function s(){return new IntersectionObserver(f=>{f.forEach(l=>{e.set(l.target,l.isIntersecting)})})}return{observe:r,unobserve:n,disconnect:o,isElementVisible:a}}class jn extends Error{constructor(t){super(`Route not found: "${t}"`)}}function ar(e,t,r){const n=cr(t,r),[o]=ve(e,n);return o}function sr(e,t){if(!t)return e;const{name:r,param:n,value:o}=t,a=cr(e,r);return ve(e,a).reduce((f,l)=>l===void 0?f:f.replace(l,()=>te(o,n,r.startsWith("?"))),e)}function cr(e,t){const r=[Zn,$n,gt].reduce((n,o)=>o(n,t),e);return new RegExp(r,"g")}function Zn(e,t){if(!t.startsWith("?"))return e;const r=new RegExp(`\\${z}\\${t}\\${K}`,"g");return e.replace(r,"(.*)")}function $n(e,t){if(t.startsWith("?"))return e;const r=new RegExp(`\\${z}${t}\\${K}`,"g");return e.replace(r,"(.+)")}function ir({protocol:e,host:t,pathname:r,search:n,searchParams:o,hash:a}){const s=new URL("https://localhost");e&&(s.protocol=e),t&&(s.host=t),r&&(s.pathname=r),o?s.search=new URLSearchParams(o).toString():n&&(s.search=n),a&&(s.hash=a);const f=s.toString().replace(/^https:\/\/localhost\/*/,"/");return Ve(f)}function On(e,t={}){const{params:r={},query:n}=t,o=_n(e.query,r),a=Ge(o,n),s=ur(e.path,r),f=e.hash.value?ur(e.hash,r):t.hash,l=qn(e.host,r),{protocol:u,host:y}=_(l);return ir({protocol:u,host:y,pathname:s,searchParams:a,hash:f})}function qn(e,t){const r=e.value&&!e.value.startsWith("http")?`https://${e.value}`:e.value;return Object.entries(e.params).reduce((n,[o,a])=>{const s=Se(`${z}${o}${K}`);return s?sr(n,{name:o,param:a,value:t[s]}):n},r)}function ur(e,t){return Object.entries(e.params).reduce((r,[n,o])=>{const a=Se(`${z}${n}${K}`);return a?sr(r,{name:n,param:o,value:t[a]}):r},e.value)}function _n(e,t){const r=new URLSearchParams(e.value);if(!e.value)return r;for(const[n,o]of Array.from(r.entries())){const a=Se(o);if(!a)continue;const f=wt(o),l=f?`?${a}`:a,u=te(t[a],e.params[l],f),y=t[a]===void 0&&u==="";f&&y?r.delete(n,o):r.set(n,u)}return r}const Hn=(e,t)=>{try{Ye(e,t)}catch{return!1}return!0},Ye=(e,t)=>{const{protocol:r,host:n,pathname:o,search:a,hash:s}=_(t);return{...Ne(e.host,`${r}//${n}`),...Ne(e.path,o),...Ne(e.query,a),...Ne(e.hash,s)}};function Ne(e,t){const r={},n=decodeURIComponent(t);for(const[o,a]of Object.entries(e.params)){const s=o.startsWith("?"),f=s?o.slice(1):o,l=ar(n,e.value,o),u=le(l,a,s);r[f]=u}return r}function In(e,t={},r={}){const n=On(e,{params:t,query:r.query,hash:r.hash}),{search:o,hash:a}=_(n);return{id:e.id,matched:e.matched,matches:e.matches,name:e.name,query:De(o),params:Ye(e,n),state:nr(e.state,r.state),hash:a,href:n}}const Dn=e=>"name"in e.matched&&!!e.matched.name,Tn=(e,t)=>{const{pathname:r}=_(t);return Cr(e).test(r)},Mn=(e,t)=>{const{search:r}=_(t);return xr(e).every(o=>o.test(r))},Xe=(e,t)=>{const{hash:r}=_(t),{value:n}=e.hash;return M(n)?`#${n.replace(/^#*/,"")}`.toLowerCase()===r.toLowerCase():!0};function Fn(e){const{searchParams:t,pathname:r}=_(e),n=-1,o=1;return(a,s)=>{const f=lr(a,t),l=fr(a,r),u=lr(s,t),y=fr(s,r);return a.depth>s.depth?n:a.depth<s.depth?o:f+l>u+y?n:f+l<u+y?o:Xe(a,e)?n:Xe(s,e)?o:0}}function fr(e,t){const r=Object.keys(e.path.params).filter(o=>o.startsWith("?")).map(o=>o),n=r.filter(o=>ar(t,e.path.value,o)===void 0);return r.length-n.length}function lr(e,t){const r=new URLSearchParams(t),n=new URLSearchParams(e.query.value),o=Array.from(n.keys()),a=o.filter(s=>!r.has(s));return o.length-a.length}const Jn=[Dn,Tn,Mn,Xe,Hn];function Wn(e,t){const r=Fn(t);return e.filter(n=>Jn.every(o=>o(n,t))).sort(r)}function Gn(e,t,r){const n=Wn(e,t);if(!n.length)return;const[o]=n,{searchParams:a,hash:s}=_(t);return{id:o.id,matched:o.matched,matches:o.matches,name:o.name,query:De(a),params:Ye(o,t),state:nr(o.state,r),hash:s,href:Ve(t)}}function dr(e,t){const r=typeof e=="string"?_(e):e,n=typeof t=="string"?_(t):t,o=r.searchParams??new URLSearchParams(r.search),a=n.searchParams??new URLSearchParams(n.search);return ir({protocol:M(n.protocol)?n.protocol:r.protocol,host:M(n.host)?n.host:r.host,pathname:M(n.pathname)?n.pathname:r.pathname,searchParams:Ge(a,o),hash:M(n.hash)?n.hash:r.hash})}function zn(e,t){return M(t)?e.map(r=>{const n=`${t}${r.path}`;return{...r,path:F(n,r.path.params)}}):e}class Qn 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 Kn(e){const t=e.map(({name:r})=>r);for(const r of t)if(ct(t,r)>1)throw new Qn(r)}function Yn(e,t=[],r){const n=[...e,...t.map(o=>o.routes)].flat();return Kn(n),zn(n,r)}function Xn(e={},t=[]){const r=new oe;return me("onBeforeRouteEnter",e,t).forEach(n=>r.onBeforeRouteEnter.add(n)),me("onBeforeRouteUpdate",e,t).forEach(n=>r.onBeforeRouteUpdate.add(n)),me("onBeforeRouteLeave",e,t).forEach(n=>r.onBeforeRouteLeave.add(n)),me("onAfterRouteEnter",e,t).forEach(n=>r.onAfterRouteEnter.add(n)),me("onAfterRouteUpdate",e,t).forEach(n=>r.onAfterRouteUpdate.add(n)),me("onAfterRouteLeave",e,t).forEach(n=>r.onAfterRouteLeave.add(n)),r}function me(e,t,r){return[t[e],...r.map(o=>o[e])].flat().filter(o=>o!==void 0)}function eo(e,t,r=[]){const n=Yn(e,r,t==null?void 0:t.base),o=pn();o.addGlobalRouteHooks(Xn(t,r));const a=Te(),s=Gr(),f=sn(),l=Vn(),u=An({mode:t==null?void 0:t.historyMode,listener:({location:v})=>{const N=se(v);S(N,{state:v.state,replace:!0})}});function y(v,N={}){return Gn(n,v,N.state)}async function S(v,N={}){const Q=a();if(u.stopListening(),L(v)){u.update(v,N);return}const D=y(v,N)??U("NotFound"),H=pr(Q),X=await o.runBeforeRouteHooks({to:D,from:H});switch(X.status){case"ABORT":return;case"PUSH":u.update(v,N),await g(...X.to);return;case"REJECT":u.update(v,N),i(X.type);break;case"SUCCESS":u.update(v,N),i(null);break;default:throw new Error(`Switch is not exhaustive for before hook response status: ${JSON.stringify(X)}`)}const et=Q;s.setProps(D).then(T=>{if(et===Q)switch(T.status){case"SUCCESS":break;case"PUSH":g(...T.to);break;case"REJECT":i(T.type);break;default:const tt=T;throw new Error(`Switch is not exhaustive for prop store response status: ${JSON.stringify(tt)}`)}}),B(D);const J=await o.runAfterRouteHooks({to:D,from:H});switch(J.status){case"PUSH":await g(...J.to);break;case"REJECT":i(J.type);break;case"SUCCESS":break;default:const T=J;throw new Error(`Switch is not exhaustive for after hook response status: ${JSON.stringify(T)}`)}u.startListening()}const x=(v,N={},Q={})=>{const D=n.find(H=>H.name===v);if(!D)throw new jn(String(v));return In(D,N,Q)},g=(v,N,Q)=>{if(Z(v)){const J={...N},T=dr(v,{searchParams:J.query,hash:J.hash});return S(T,J)}if(typeof v=="string"){const{replace:J,...T}={...Q},tt={...N},rt=x(v,tt,T),uo=or({...rt.matched.state},{...rt.state,...T.state});return S(rt.href,{replace:J,state:uo})}const{replace:D,...H}={...N},X=or({...v.matched.state},{...v.state,...H.state}),et=dr(v.href,{searchParams:H.query,hash:H.hash});return S(et,{replace:D,state:X})},h=(v,N,Q)=>{if(Z(v)){const H={...N,replace:!0};return g(v,H)}if(typeof v=="string"){const H={...Q,replace:!0},X={...N};return g(v,X,H)}const D={...N,replace:!0};return g(v,D)},R=v=>{i(v)},{setRejection:i,rejection:d,getRejectionRoute:U}=Ln({...r.reduce((v,N)=>({...v,...N.rejections}),{}),...t==null?void 0:t.rejections}),w=U("NotFound"),{currentRoute:E,routerRoute:A,updateRoute:B}=bn(w,g),m=Cn(t==null?void 0:t.initialUrl),p=u.location.state,{host:P}=_(m),L=vn(P);let C=!1;const{promise:V,resolve:$}=Promise.withResolvers();async function q(){if(C)return V;Pr(n)&&await Sr(),C=!0,await S(m,{replace:!0,state:p}),u.startListening(),$()}function I(){u.stopListening()}function pr(v){return Tr(v)?null:{...E}}function io(v){v.component("RouterView",Ke),v.component("RouterLink",It),v.provide(Dt,d),v.provide(Wt,o),v.provide(jt,s),v.provide(Mt,f),v.provide(Ot,l),v.provide(st,mr),q()}const mr={route:A,resolve:x,find:y,push:g,replace:h,reject:R,refresh:u.refresh,forward:u.forward,back:u.back,go:u.go,install:io,isExternal:L,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:q,stop:I};return mr}function to(e){return{routes:e.routes??[],rejections:e.rejections??{},...e}}function hr(...e){return{get:(t,{invalid:r})=>{for(const n of e){const o=Ur(t,n);if(o!==void 0)return o}throw r(`Value ${t} does not satisfy any of the possible values`)},set:(t,{invalid:r})=>{for(const n of e){const o=Lr(t,n);if(o!==void 0)return o}throw r(`Value ${t} does not satisfy any of the possible values`)}}}function ro(...e){const t=hr(...e);return{get:(r,n)=>r.split(",").map(o=>t.get(o,n)),set:(r,n)=>{if(!Array.isArray(r))throw n.invalid("Expected an array");return r.map(o=>t.set(o,n)).join(",")}}}function no(...e){return{get:t=>{const r=t.split(",");return e.map((n,o)=>le(r.at(o),n))},set:(t,{invalid:r})=>{if(!Array.isArray(t))throw r("Expected a tuple");if(t.length!==e.length)throw r(`Expected tuple with ${e.length} values but received ${t.length} values`);return e.map((n,o)=>te(t.at(o),n)).join(",")}}}const oo=F,ao=F,so=F;function co(e){const t=Me(),r=Ut(e.name),n=re(e.path),o=re(e.query),a=re(e.hash),s=e.meta??{},f=re(e.host),l=c.markRaw({id:t,meta:{},state:{},...e}),u={id:t,matched:l,matches:[l],name:r,host:f,path:n,query:o,hash:a,meta:s,depth:1,state:{}},y=bt(e)?kt(e.parent,u):u;return ie(y.path.params,y.query.params,y.host.params,y.hash.params),y}k.DuplicateParamsError=nt,k.MetaPropertyConflict=ot,k.RouterLink=It,k.RouterNotInstalledError=ee,k.RouterView=Ke,k.UseRouteInvalidError=at,k.arrayOf=ro,k.asUrl=Ve,k.createExternalRoute=co,k.createParam=ut,k.createRoute=ne,k.createRouter=eo,k.createRouterPlugin=to,k.host=ao,k.isRoute=We,k.isUrl=Z,k.onAfterRouteLeave=gn,k.onAfterRouteUpdate=Rn,k.onBeforeRouteLeave=mn,k.onBeforeRouteUpdate=yn,k.path=oo,k.query=so,k.tupleOf=no,k.unionOf=hr,k.useLink=Ht,k.useRoute=ze,k.useRouter=Ee,k.withDefault=Er,k.withParams=F,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.17.
|
|
4
|
+
"version": "0.17.3",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/kitbagjs/router/issues"
|
|
7
7
|
},
|
|
@@ -43,21 +43,27 @@
|
|
|
43
43
|
"@kitbag/eslint-config": "1.0.2",
|
|
44
44
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
45
45
|
"@vue/test-utils": "^2.4.6",
|
|
46
|
-
"eslint": "^9.
|
|
46
|
+
"eslint": "^9.19.0",
|
|
47
47
|
"globals": "^15.14.0",
|
|
48
|
-
"happy-dom": "^16.
|
|
48
|
+
"happy-dom": "^16.7.3",
|
|
49
49
|
"typedoc": "^0.27.6",
|
|
50
50
|
"typedoc-plugin-markdown": "^4.4.1",
|
|
51
51
|
"typedoc-vitepress-theme": "^1.1.2",
|
|
52
52
|
"typescript": "^5.7.3",
|
|
53
|
-
"vite": "^6.0.
|
|
53
|
+
"vite": "^6.0.11",
|
|
54
54
|
"vite-plugin-dts": "^4.5.0",
|
|
55
|
-
"vitepress": "^1.
|
|
55
|
+
"vitepress": "^1.6.3",
|
|
56
56
|
"vitest": "^2.1.6",
|
|
57
57
|
"vue-tsc": "^2.2.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"vue": "^3.5.0"
|
|
60
|
+
"vue": "^3.5.0",
|
|
61
|
+
"zod": "^3.24.1"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"zod": {
|
|
65
|
+
"optional": true
|
|
66
|
+
}
|
|
61
67
|
},
|
|
62
68
|
"dependencies": {
|
|
63
69
|
"history": "^5.3.0"
|