@krate/runtime 0.5.0-rc.1 → 0.5.0-rc.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,2 +1,2 @@
1
- var __krate_exports=(()=>{var le=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var dt=Object.prototype.hasOwnProperty;var ht=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},pt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ft(t))!dt.call(e,o)&&o!==n&&le(e,o,{get:()=>t[o],enumerable:!(r=ut(t,o))||r.enumerable});return e};var mt=e=>pt(le({},"__esModule",{value:!0}),e);var Zt={};ht(Zt,{compareRouteSpecificity:()=>Ye,destroyRouter:()=>Qt,getHistoryState:()=>St,getNavigationState:()=>Ue,initRouter:()=>ct,invalidatePrefetchCache:()=>ve,krateRouter:()=>Yt,matchRoutePattern:()=>ze,navigate:()=>Xt,pageAssetURLs:()=>He,reinitRouter:()=>Gt,subscribeNavigation:()=>Ie});var me=/\/chunks\/runtime\.[^/]+\.js$/;function ne(){return globalThis.__KRATE_CFG__||{}}function ge(){let e=ne().basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function I(e){let t=ge();if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}function de(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function O(e){if(ne().dev)try{console.warn("[krate router] "+e)}catch{}}function Me(e,t){if(/^(https?:)?\/\//.test(e)||e.startsWith("/"))return new URL(e,t).href;let n=t;if(!n.endsWith("/")){let r=n.lastIndexOf("/");n=r>0?n.slice(0,r+1):"/"}return new URL(e,n).href}function He(e,t,n){let r=new DOMParser().parseFromString(e,"text/html"),o=[],i=new Set,s=c=>{if(!c)return;let a;try{a=Me(c,t)}catch{return}i.has(a)||n.has(a)||me.test(a)||(i.add(a),o.push(a))};return r.querySelectorAll("script[src]").forEach(c=>s(c.getAttribute("src"))),r.querySelectorAll('link[rel="modulepreload"][href], link[rel="preload"][as="script"][href]').forEach(c=>s(c.getAttribute("href"))),o}var _=!1,T=0,k,Re=0,m="",A="",F="idle",W=new Set,S=new Map,R=new Map,gt=30,yt=3e4,L=new Map,vt=50,ue=new Set,kt=128,G=new Map,B=new Map,M=null,$=[],bt="_krate/i",wt=150,Et=200;function he(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function D(){return Re++,Date.now().toString(36)+"-"+Re.toString(36)}function re(e){try{let t=new URL(e,location.href);return t.hash="",t.href}catch{return e}}function x(e){let t=new URL(e,location.href);return de(t.pathname)+t.search}function j(e,t=!1){let n=globalThis.__krateHardNavigate;if(typeof n=="function"){n(e,t);return}t?location.replace(e):location.assign(e)}function J(e,t){return{__krate:e,state:t===void 0?null:t}}function Q(e){if(e&&typeof e=="object"&&typeof e.__krate=="string")return e.__krate}function St(){if(typeof history>"u")return null;let e=history.state;return Q(e)!==void 0?e.state:e}function De(){let e=new URL(location.href);return{url:e.href,pathname:I(e.pathname),search:e.search,hash:e.hash,status:F}}function Ue(){return typeof location>"u"?{url:"",pathname:"/",search:"",hash:"",status:"idle"}:De()}function oe(){if(W.size===0)return;let e=De();for(let t of Array.from(W))try{t(e)}catch(n){console.error(n)}}function H(e){F!==e&&(F=e,oe())}function Ie(e){return W.add(e),()=>{W.delete(e)}}function b(e,t,n=!1){try{let r=new CustomEvent(e,{detail:t,cancelable:n});return window.dispatchEvent(r),!r.defaultPrevented}catch{return!0}}function ye(e){try{let t=globalThis.__krate_onNavigation;typeof t=="function"&&t(e)}catch{}}function z(e){if(e){if(L.delete(e),L.size>=vt){let t=L.keys().next().value;t!==void 0&&L.delete(t)}L.set(e,window.scrollY||0)}}function Ke(){let e=ne().prefetchTTL;return typeof e=="number"&&e>=0?e:yt}function At(e,t){for(S.delete(e);S.size>=gt;){let n=S.keys().next().value;if(n===void 0)break;S.delete(n)}S.set(e,t)}function Lt(e){let t=S.get(e);if(t&&(S.delete(e),!(he()-t.at>Ke())))return t}function ve(e){if(e===void 0){S.clear(),R.clear();return}let t=re(e);S.delete(t),R.delete(t)}function ke(e){return/text\/html|application\/xhtml\+xml/i.test(e)}function V(e){return/^\s*(<!doctype html|<html|<head|<body)/i.test(e)}function Tt(e){if(ue.has(e)||ue.size>=kt)return;ue.add(e);let t=document.createElement("link");t.rel="prefetch",t.as="script",t.href=e,document.head.appendChild(t)}function be(e){let t=re(e),n=S.get(t);if(n&&he()-n.at<=Ke())return Promise.resolve();let r=R.get(t);if(r)return r;let o=fetch(t,{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async i=>{if(!i.ok)return;let s=i.headers.get("content-type")||"",c=i.url||t;if(new URL(c,location.href).origin!==location.origin)return;let a=await i.text();if(!(ke(s)||s===""&&V(a))||R.get(t)!==o)return;At(t,{html:a,url:c,status:i.status,at:he()});let u=new Set;document.querySelectorAll("script[src]").forEach(l=>u.add(l.src));for(let l of He(a,c,u))Tt(l)}).catch(()=>{}).finally(()=>{R.get(t)===o&&R.delete(t)});return R.set(t,o),o}function we(e){if(e.hasAttribute("data-krate-external")||e.hasAttribute("download"))return!1;let t=e.getAttribute("href");if(!t||t.startsWith("javascript:"))return!1;let n;try{n=new URL(t,location.href)}catch{return!1}if(n.origin!==location.origin)return!1;let r=e.getAttribute("target");return!(r&&r!=="_self")}function Ee(e){let t=e.getAttribute("data-prefetch");return e.hasAttribute("data-prefetch")&&t!=="false"&&t!=="0"}function Rt(e){let t=window.requestIdleCallback;typeof t=="function"?t(e,{timeout:1e3}):setTimeout(e,50)}function Z(e){let t=e.target;if(!t||typeof t.closest!="function")return;let n=t.closest("a[data-prefetch]");if(!n||!Ee(n)||!we(n))return;let r=n.getAttribute("href");if(!r)return;let o=new URL(r,location.href).href;if(x(o)===A)return;let i=B.get(n);i&&clearTimeout(i);let s=setTimeout(()=>{B.delete(n),be(o)},Et);B.set(n,s)}function Oe(){M&&document.querySelectorAll("a[data-prefetch]").forEach(e=>{Ee(e)&&M.observe(e)})}function _t(){document.addEventListener("mouseover",Z),document.addEventListener("focusin",Z),typeof IntersectionObserver<"u"&&(M=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let n=t.target,r=n.getAttribute("href");if(r&&we(n)&&Ee(n)){let o=new URL(r,location.href).href;x(o)!==A&&Rt(()=>{be(o)})}M.unobserve(t.target)}},{rootMargin:"200px"}),Oe())}function xt(){let e=typeof HTMLScriptElement<"u"?HTMLScriptElement.supports:void 0;if(!(typeof e!="function"||!e("speculationrules"))&&!document.querySelector('meta[http-equiv="Content-Security-Policy" i]'))try{let t=document.createElement("script");t.type="speculationrules",t.textContent=JSON.stringify({prefetch:[{where:{and:[{href_matches:"/*"},{not:{href_matches:"/__krate/*"}},{not:{href_matches:"/api/*"}}]},eagerness:"moderate"}]}),document.head.appendChild(t)}catch{}}function Be(){if(typeof window<"u"&&window.matchMedia)try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{}return!1}function Fe(){return ne().viewTransitions===!1||Be()?!1:typeof document.startViewTransition=="function"}function w(e){return e.getElementById("root")||e.body}function Pt(){let e=document.querySelector("template[data-krate-loading]");if(e&&e.content&&$.length===0){let t=e.content.cloneNode(!0);$=Array.from(t.childNodes),document.body.appendChild(t)}if(!Fe()&&!Be()){let t=w(document);t.style.transition=`opacity ${wt}ms ease`,t.style.opacity="0"}}function Se(){for(let t of $)t.parentNode&&t.parentNode.removeChild(t);$=[];let e=w(document);e.style.opacity==="0"&&(e.style.opacity="")}function We(e){e.querySelectorAll("[data-view-transition]").forEach(t=>{let n=t.getAttribute("data-view-transition");n&&(t.style.viewTransitionName=n);let r=t.getAttribute("data-view-transition-class");r&&t.style.setProperty("view-transition-class",r)})}var Ct=3e3;function Nt(e,t){let n=[];e.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let l=u.getAttribute("href");if(!l)return;let p=new URL(l,t).href;n.includes(p)||n.push(p)});let r=new Map,o=[];document.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let l=u;l.href&&(n.includes(l.href)&&!r.has(l.href)?r.set(l.href,l):o.push(l))});let i=[],s=[],c=null;n.forEach((u,l)=>{let p=r.get(u)||null;if(!p){let h=document.createElement("link");if(h.rel="stylesheet",h.href=u,s.push(new Promise(g=>{let f=()=>{h.removeEventListener("load",f),h.removeEventListener("error",f),g()};h.addEventListener("load",f),h.addEventListener("error",f)})),i.push({link:h,media:h.getAttribute("media")}),h.media="not all",c)c.after(h);else{let g=n.slice(l+1).map(f=>r.get(f)).find(f=>!!f);g?g.before(h):document.head.appendChild(h)}p=h}c=p});let a=Promise.resolve();if(s.length>0){let u,l=new Promise(p=>{u=setTimeout(p,Ct)});a=Promise.race([Promise.all(s).then(()=>{}),l]).then(()=>clearTimeout(u))}return{ready:a,commit(){for(let{link:u,media:l}of i)l===null?u.removeAttribute("media"):u.setAttribute("media",l);o.forEach(u=>u.remove())},abort(){i.forEach(({link:u})=>u.remove())}}}var _e='meta[name="description"], meta[name="robots"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function Mt(e){document.head.querySelectorAll(_e).forEach(t=>t.remove()),e.head.querySelectorAll(_e).forEach(t=>{document.head.appendChild(document.importNode(t,!0))})}function $e(e,t){let n=new Set;document.querySelectorAll("script[src]:not([data-krate-spa])").forEach(i=>n.add(i.src));let r=[],o=new Set;return e.querySelectorAll("script[src]").forEach(i=>{let s=i.getAttribute("src");if(!s)return;let c=(i.getAttribute("type")||"").toLowerCase();if(c&&c!=="module"&&c!=="text/javascript"&&c!=="application/javascript")return;let a=Me(s,t);!n.has(a)&&!o.has(a)&&(o.add(a),r.push({src:a,module:c==="module"}))}),r}function je(e){return new Promise(t=>{let n=document.createElement("script");n.src=e.src,e.module&&(n.type="module"),me.test(e.src)||n.setAttribute("data-krate-spa",""),n.onload=()=>t(!0),n.onerror=()=>t(!1),document.body.appendChild(n)})}var q=new Set;function Je(e){e.querySelectorAll("script[data-krate-boot]").forEach(t=>{let n=t.textContent||"";if(!n||q.has(n))return;q.add(n);let r=document.createElement("script");r.text=n,document.head.appendChild(r),r.remove()})}function Ht(e){if(!e||e==="#")return null;let t=e.slice(1);try{t=decodeURIComponent(t)}catch{}return document.getElementById(t)||document.getElementsByName(t)[0]||null}function Ae(e){let t=Ht(e);if(!t)return!1;try{t.scrollIntoView({block:"start"})}catch{}return!0}function Dt(e,t){if(t.kind==="pop"){let r=t.restoreKey?L.get(t.restoreKey):void 0;if(r!==void 0){window.scrollTo(0,r);return}}let n=new URL(e,location.href).hash;Ae(n)||t.scroll&&t.kind!=="refresh"&&window.scrollTo(0,0)}var X=null;function Ut(){let e=document.activeElement;if(e&&e!==document.body&&e.isConnected&&e!==X)return;let t=w(document);t.hasAttribute("tabindex")||(t.setAttribute("tabindex","-1"),X=t,t.addEventListener("blur",()=>{X===t&&(t.removeAttribute("tabindex"),X=null)},{once:!0}));try{t.focus({preventScroll:!0})}catch{}}var xe="__krate-route-announcer";function It(){let e=document.getElementById(xe);e||(e=document.createElement("div"),e.id=xe,e.setAttribute("aria-live","assertive"),e.setAttribute("aria-atomic","true"),e.setAttribute("role","status"),e.setAttribute("style","position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0"),document.body.appendChild(e));let t=w(document).querySelector("h1"),n=document.title||(t&&t.textContent?t.textContent.trim():"")||I(location.pathname);e.textContent=n}function ie(){let e=de(I(location.pathname));document.querySelectorAll("a[data-krate-link]").forEach(t=>{let n=t.getAttribute("href"),r="";try{r=n?de(I(new URL(n,location.href).pathname)):""}catch{r=""}let o="";r&&r===e?o="exact":r&&r!=="/"&&e.startsWith(r+"/")&&(o="segment"),o==="exact"?t.setAttribute("aria-current","page"):t.removeAttribute("aria-current"),o?t.setAttribute("data-krate-active",o):t.removeAttribute("data-krate-active")})}function Pe(e){let t=ge()+e;return G.has(t)?Promise.resolve(G.get(t)??null):fetch(t,{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async n=>{let r=n.ok?await n.text():null,o=r&&V(r)?r:null;return G.set(t,o),o}).catch(()=>null)}async function Kt(e,t){let n=re(e.url);if(!e.bypassCache){let p=R.get(n);if(p&&await p,t.aborted)return{ok:!1,aborted:!0};let h=Lt(n);if(h){let g=new URL(e.url,location.href).hash,f=g&&!new URL(h.url,location.href).hash?h.url+g:h.url;return{ok:!0,doc:{html:h.html,url:f,status:h.status}}}}let r;try{r=await fetch(n,{headers:{Accept:"text/html"},credentials:"same-origin",signal:t,cache:e.bypassCache?"no-cache":"default"})}catch(p){return p?.name==="AbortError"||t.aborted?{ok:!1,aborted:!0}:b("krate:navigate-error",{url:e.url,status:0,error:p},!0)?{ok:!1,hard:e.url}:{ok:!1,aborted:!0}}let o=r.url||n;if(new URL(o,location.href).origin!==location.origin)return{ok:!1,hard:o};let i=r.headers.get("content-type")||"",s="";try{s=await r.text()}catch(p){if(p?.name==="AbortError"||t.aborted)return{ok:!1,aborted:!0};s=""}if(t.aborted)return{ok:!1,aborted:!0};let c=ke(i)||i===""&&V(s),a=new URL(e.url,location.href).hash,u=a&&!new URL(o).hash?o+a:o;if(r.ok)return c?{ok:!0,doc:{html:s,url:u,status:r.status}}:{ok:!1,hard:u};if(b("krate:navigate-error",{url:e.url,status:r.status}),c&&V(s))return{ok:!0,doc:{html:s,url:u,status:r.status}};let l=null;return r.status===404||r.status===410?l=await Pe("/404.html"):r.status>=500&&(l=await Pe("/500.html")),t.aborted?{ok:!1,aborted:!0}:l?{ok:!0,doc:{html:l,url:u,status:r.status}}:{ok:!1,hard:u}}async function se(e){let t=location.href;if(e.kind!=="pop"){if(!b("krate:navigate-start",{url:e.url,from:t,kind:e.kind},!0))return}else b("krate:navigate-start",{url:e.url,from:t,kind:e.kind});let n=++T;k&&k.abort();let r=new AbortController;k=r,H("loading"),!e.bypassCache&&S.has(re(e.url))||Pt();let i;try{i=await Kt(e,r.signal)}finally{k===r&&(k=void 0)}if(n===T){if(!i.ok){Se(),H("idle"),"hard"in i&&j(i.hard,e.kind==="replace"||e.kind==="refresh");return}await Ot(i.doc,e,n)}}async function Ot(e,t,n){let r=new DOMParser().parseFromString(e.html,"text/html"),o=e.url,i=w(r),s=w(document);t.kind==="push"&&z(m);let c=Ve(r),a=$t(C,c,location.href,o,r),u=Nt(r,o);if(await u.ready,n!==T){u.abort();return}if(await Bt(()=>{let g=r.querySelector("title");g&&(document.title=g.textContent||"");let f=globalThis;if(a.keep.length>0&&typeof f.krateDisposeExcept=="function"?f.krateDisposeExcept(a.keep):typeof f.disposeAll=="function"&&f.disposeAll(),a.region){let{live:v,next:d}=a.region;ee(v[0],v[1]);let E=U(d[0],d[1]).map(y=>document.importNode(y,!0));for(let y of E)v[1].parentNode.insertBefore(y,v[1]);for(let y of a.slots){ee(y.live[0],y.live[1]);for(let K of U(y.next[0],y.next[1]))y.live[1].parentNode.insertBefore(document.importNode(K,!0),y.live[1])}Ft(s,i)}else{let v=Array.from(i.childNodes).map(d=>document.importNode(d,!0));s.replaceChildren(...v)}C=a.chain,Y.clear(),u.commit(),Mt(r),We(document)}),n!==T)return;Se(),t.kind==="push"?(m=D(),history.pushState(J(m,t.state),"",o)):t.kind==="replace"?(L.delete(m),m=D(),history.replaceState(J(m,t.state),"",o)):t.kind==="refresh"?o!==location.href&&history.replaceState(history.state,"",o):t.restoreKey&&(m=t.restoreKey),A=x(location.href),N=A,Ge(r),jt(r),Dt(o,t),t.kind!=="pop"&&t.kind!=="refresh"&&Ut(),t.kind!=="refresh"&&It(),ie(),b("krate:navigate",{url:location.href,status:e.status}),ye(location.href),H("idle"),document.querySelectorAll("script[data-krate-spa]").forEach(g=>g.remove()),Je(r);let p=$e(r,o);Ne(a.skip);let h=await Promise.all(p.map(je));if(Ne([]),n===T){if(h.some(g=>!g)){b("krate:navigate-error",{url:location.href,status:e.status,error:"script-load"}),j(location.href,!0);return}te(),b("krate:navigate-end",{url:location.href,status:e.status})}}function Bt(e){if(!Fe())return e(),Promise.resolve();let t=!1,n=()=>{t||(t=!0,e())};try{let r=document.startViewTransition(n);r&&r.finished&&typeof r.finished.catch=="function"&&r.finished.catch(()=>{});let o=r&&r.updateCallbackDone;if(o&&typeof o.then=="function")return o.then(()=>n(),()=>n())}catch{}return n(),Promise.resolve()}var C=[];function Ve(e){let t=e.getElementById("__krate_route");if(!t)return[];try{let n=JSON.parse(t.textContent||"{}");return Array.isArray(n.chain)?n.chain:[]}catch{return O("unreadable #__krate_route route info; layouts will be remounted"),[]}}function Ce(e,t){let n=I(new URL(e,location.href).pathname).split("/").filter(Boolean);return(t<0?n:n.slice(0,t)).join("/")}function P(e,t,n="kl:"){let o=(e.ownerDocument||e).createTreeWalker(e,128),i=n+t,s="/"+n+t;for(;o.nextNode();){let c=o.currentNode;if(c.nodeValue===i){for(let a=c.nextSibling;a;a=a.nextSibling)if(a.nodeType===8&&a.nodeValue===s)return[c,a];return null}}return null}function U(e,t){let n=[];for(let r=e.nextSibling;r&&r!==t;r=r.nextSibling)n.push(r);return n}function ee(e,t){let n=globalThis.disposeNode;for(let r of U(e,t))r.parentNode.removeChild(r),typeof n=="function"&&n(r)}function Ft(e,t){let n=":scope > template[data-krate-loading]";e.querySelectorAll(n).forEach(r=>r.remove()),t.querySelectorAll(n).forEach(r=>e.appendChild(document.importNode(r,!0)))}function Ne(e){let t=globalThis.krateKeepScopes;typeof t=="function"&&t(e)}function Wt(e){let t=globalThis.krateScopeFailed;return typeof t=="function"&&!!t(e)}function $t(e,t,n,r,o){let i={keep:[],skip:[],region:null,slots:[],chain:t},s=0;for(;s<e.length&&s<t.length;){let f=e[s],v=t[s];if(f.id!==v.id||f.k!==v.k||f.k!=="layout"&&f.k!=="error"||Ce(n,f.d)!==Ce(r,v.d)||f.k==="error"&&Wt(f.id))break;if(!f.p||!v.p){O(`layout ${v.f||v.id} is remounted on this navigation: ${v.why||f.why||"not persistable"}`);break}s++}if(s===0)return i;if(typeof globalThis.krateDisposeExcept!="function")return O("the runtime has no krateDisposeExcept; layouts are remounted"),i;let c=t[s-1].id,a=P(w(document),c),u=P(w(o),c);if(!a||!u)return O(`layout ${t[s-1].f||c} boundary markers are missing; the whole page is swapped`),i;let l=e.slice(0,s).map(f=>f.id),p=l.slice(),h=[],g=t.slice();for(let f=0;f<s;f++){let v=e[f].s||[],d=[];for(let E of t[f].s||[]){let y=v.find(lt=>lt.key===E.key),K=P(w(document),E.key,"ks:"),ce=P(w(o),E.key,"ks:");if(y&&K&&(E.src!=="page"||!ce)){l.push(y.scope),p.push(y.scope,E.scope),d.push({...E,scope:y.scope,src:y.src});continue}if(K&&ce){h.push({live:K,next:ce}),d.push(E);continue}return O(`slot @${E.n} markers are missing; the whole page is swapped`),i}g[f]={...t[f],s:d}}return{keep:l,skip:p,region:{live:a,next:u},slots:h,chain:g}}var Y=new Map,N="";function pe(e){let t=e.replace(/^\/+|\/+$/g,"");return t?t.split("/").map(n=>n.startsWith("[[...")&&n.endsWith("]]")?{kind:3,text:n.slice(5,-2)}:n.startsWith("[...")&&n.endsWith("]")?{kind:2,text:n.slice(4,-1)}:n.startsWith("[")&&n.endsWith("]")?{kind:1,text:n.slice(1,-1)}:{kind:0,text:n}):[]}function ze(e,t){let n=pe(t),r=e.replace(/^\/+|\/+$/g,""),o=r?r.split("/"):[],i={};for(let s=0;s<n.length;s++){let c=n[s];if(c.kind>=2){if(s!==n.length-1)return null;let a=o.slice(s);return c.kind===2&&a.length===0||a.some(u=>u==="")?null:(i[c.text]=a.map(fe).join("/"),i)}if(s>=o.length)return null;if(c.kind===1){if(!o[s])return null;i[c.text]=fe(o[s])}else if(fe(o[s])!==c.text)return null}return o.length===n.length?i:null}function fe(e){try{return decodeURIComponent(e)}catch{return e}}function Ye(e,t){let n=pe(e),r=pe(t);for(let o=0;o<n.length&&o<r.length;o++){if(n[o].kind!==r[o].kind)return n[o].kind-r[o].kind;if(n[o].kind===0&&n[o].text!==r[o].text)return n[o].text<r[o].text?-1:1}return n.length!==r.length?r.length-n.length:e<t?-1:e>t?1:0}function Le(e){let t=I(new URL(e,location.href).pathname).replace(/^\/+|\/+$/g,""),n=null;for(let r of C)for(let o of r.s||[])for(let i of o.i||[])ze(t,i)&&(!n||Ye(i,n.pattern)<0)&&(n={hit:{entry:r,slot:o,path:t},pattern:i});return n&&!P(w(document),n.hit.slot.key,"ks:")?null:n?n.hit:null}function Xe(e,t){C=C.map(n=>n.s&&n.s.some(r=>r.key===e)?{...n,s:n.s.map(r=>r.key===e?t:r)}:n)}function Ge(e){let t="",n=e.getElementById("__krate_page");if(n)try{let r=JSON.parse(n.textContent||"{}");typeof r.r=="string"&&(t=r.r)}catch{}globalThis.__KRATE_ROUTE__=t;for(let r of Array.from(e.querySelectorAll("script:not([src])"))){let o=/window\.__KRATE_PARAMS__\s*=\s*(\{[\s\S]*?\})\s*;?\s*$/.exec(r.textContent||"");if(o){try{globalThis.__KRATE_PARAMS__=JSON.parse(o[1])}catch{}return}}delete globalThis.__KRATE_PARAMS__}function jt(e){let t=e.getElementById("__krate_error"),n=document.getElementById("__krate_error");if(!t){n&&n.remove();return}let r=document.importNode(t,!0);n?n.replaceWith(r):document.head.appendChild(r)}function Qe(e){let t=globalThis.krateDisposeScopes;typeof t=="function"&&t(e)}async function Te(e,t){let n=location.href;if(e.kind!=="pop"&&!b("krate:navigate-start",{url:e.url,from:n,kind:e.kind,intercept:t.slot.n},!0))return;let r=++T;k&&k.abort();let o=new AbortController;k=o,H("loading");let i=location.origin+ge()+"/"+bt+"/"+t.slot.key+(t.path?"/"+t.path:""),s="",c=!1;try{let d=await fetch(i,{headers:{Accept:"text/html"},credentials:"same-origin",signal:o.signal,cache:e.bypassCache?"no-cache":"default"});s=await d.text(),c=d.ok&&(ke(d.headers.get("content-type")||"")||V(s)),c||b("krate:navigate-error",{url:e.url,status:d.status,intercept:t.slot.n})}catch(d){if(d?.name==="AbortError"||o.signal.aborted)return;b("krate:navigate-error",{url:e.url,status:0,error:d,intercept:t.slot.n})}finally{k===o&&(k=void 0)}if(r!==T)return;let a=c?new DOMParser().parseFromString(s,"text/html"):null,u=a?P(w(a),t.slot.key,"ks:"):null,l=P(w(document),t.slot.key,"ks:"),p=null;try{let d=a&&a.getElementById("__krate_route");p=d&&JSON.parse(d.textContent||"{}").frag||null}catch{p=null}if(!a||!u||!l||!p||p.key!==t.slot.key||!p.scope){try{console.warn(`[krate router] intercepting route for ${e.url} (slot @${t.slot.n}) could not be loaded; navigating to the page`)}catch{}return H("idle"),se({...e})}if(e.kind==="push"&&z(m),t.slot.src!=="intercept"){Y.set(m,{key:t.slot.key,nodes:U(l[0],l[1]),slot:t.slot,path:N});for(let d of U(l[0],l[1]))d.parentNode.removeChild(d)}else Qe([t.slot.scope]),ee(l[0],l[1]);for(let d of U(u[0],u[1]))l[1].parentNode.insertBefore(document.importNode(d,!0),l[1]);let h=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(d=>h.add(d.href)),a.querySelectorAll('link[rel="stylesheet"][href]').forEach(d=>{let E=new URL(d.getAttribute("href"),i).href;if(h.has(E))return;let y=document.createElement("link");y.rel="stylesheet",y.href=E,document.head.appendChild(y)}),Xe(t.slot.key,{...t.slot,scope:p.scope,src:"intercept"}),Je(a);let g={__krate:"",state:e.state===void 0?null:e.state,__kint:{key:t.slot.key,base:N}};e.kind==="push"?(m=D(),g.__krate=m,history.pushState(g,"",e.url)):e.kind==="replace"?(m=D(),g.__krate=m,history.replaceState(g,"",e.url)):e.kind==="pop"&&e.restoreKey&&(m=e.restoreKey),A=x(location.href),Ge(a),ie(),b("krate:navigate",{url:location.href,status:200,intercept:t.slot.n}),ye(location.href),H("idle");let f=$e(a,i),v=await Promise.all(f.map(je));if(r===T){if(v.some(d=>!d)){b("krate:navigate-error",{url:location.href,status:200,error:"script-load",intercept:t.slot.n}),j(location.href,!0);return}te(),b("krate:navigate-end",{url:location.href,status:200,intercept:t.slot.n})}}function Jt(e,t){let n=P(w(document),e.key,"ks:"),r=C.flatMap(i=>i.s||[]).find(i=>i.key===e.key);if(!n||!r||r.src!=="intercept")return!1;Qe([r.scope]),ee(n[0],n[1]);for(let i of e.nodes)n[1].parentNode.insertBefore(i,n[1]);Xe(e.key,e.slot),Y.delete(t),m=t,A=x(location.href);let o=L.get(t);return o!==void 0&&window.scrollTo(0,o),ie(),b("krate:navigate",{url:location.href,status:200}),ye(location.href),oe(),!0}function Vt(e){return x(e)===A}function Ze(){F==="loading"&&(T++,k&&k.abort(),k=void 0,Se(),H("idle"))}function zt(e,t){Ze(),z(m),(e!==location.href||t.state!==void 0)&&(t.kind==="replace"?history.replaceState(J(m||D(),t.state),"",e):(m=D(),history.pushState(J(m,t.state),"",e)));let n=new URL(e).hash;!Ae(n)&&t.scroll&&!n&&window.scrollTo(0,0),oe()}function ae(e){let t;try{t=new URL(e.url,location.href)}catch{return j(e.url),Promise.resolve()}if(t.origin!==location.origin)return j(t.href,e.kind==="replace"),Promise.resolve();if(e.url=t.href,(e.kind==="push"||e.kind==="replace")&&Vt(t.href)&&(t.hash||t.href===location.href))return zt(t.href,e),Promise.resolve();if(e.kind==="push"||e.kind==="replace"){let n=Le(t.href);if(n)return Te(e,n)}return se(e)}function qe(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target;if(!t||typeof t.closest!="function")return;let n=t.closest("a[data-krate-link]");if(!n||!we(n))return;let r=n.getAttribute("href");r&&(e.preventDefault(),ae({url:new URL(r,location.href).href,kind:n.hasAttribute("data-krate-replace")?"replace":"push",scroll:n.getAttribute("data-krate-scroll")!=="false"}))}function et(e){if(e.defaultPrevented)return;let t=e.target;if(!t||t.tagName!=="FORM"||t.hasAttribute("data-krate-reload"))return;let n=e.submitter||null;if((n&&n.getAttribute("formmethod")||t.getAttribute("method")||"get").toLowerCase()!=="get")return;let o=n&&n.getAttribute("formtarget")||t.getAttribute("target");if(o&&o!=="_self")return;let i=n&&n.getAttribute("formaction")||t.getAttribute("action")||"",s;try{s=new URL(i||location.href,location.href)}catch{return}if(s.origin!==location.origin||s.protocol.indexOf("http")!==0)return;let c;try{c=n?new FormData(t,n):new FormData(t)}catch{c=new FormData(t),n&&n.name&&c.append(n.name,n.value)}let a=new URLSearchParams;for(let[u,l]of c.entries()){if(typeof l!="string")return;a.append(u,l)}e.preventDefault(),s.search=a.toString(),s.hash="",ae({url:s.href,kind:"push",scroll:!0})}function tt(e){z(m);let t=Q(e.state),n=location.href;if(x(n)===A){Ze(),m=t||m;let i=t?L.get(t):void 0;i!==void 0?window.scrollTo(0,i):Ae(location.hash),oe();return}let r=t?Y.get(t):void 0;if(r&&t&&r.path===x(n)&&r.path===N&&Jt(r,t))return;let o=e.state&&typeof e.state=="object"?e.state.__kint:null;if(o&&o.base===N){let i=Le(n);if(i&&i.slot.key===o.key){Te({url:n,kind:"pop",scroll:!1,restoreKey:t},i);return}}se({url:n,kind:"pop",scroll:!0,restoreKey:t})}function nt(){ve(),it()}function rt(){z(m);try{history.scrollRestoration="auto"}catch{}}function ot(){try{history.scrollRestoration="manual"}catch{}}function te(){Oe(),ie(),We(document),document.querySelectorAll("script[src]").forEach(e=>{me.test(e.src)||e.setAttribute("data-krate-spa","")})}function it(){if(!_||typeof location>"u")return typeof location<"u"&&location.reload(),Promise.resolve();if(A!==N){let e=Le(location.href);if(e&&e.slot.src==="intercept")return Te({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0},e)}return se({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0})}function st(e,t={}){return _?ae({url:e,kind:"push",scroll:t.scroll!==!1,state:t.state}):(typeof location<"u"&&location.assign(e),Promise.resolve())}function at(e,t={}){return _?ae({url:e,kind:"replace",scroll:t.scroll!==!1,state:t.state}):(typeof location<"u"&&location.replace(e),Promise.resolve())}var Yt={push:st,replace:at,back(){typeof history<"u"&&history.back()},forward(){typeof history<"u"&&history.forward()},refresh:it,prefetch(e){if(!_||typeof location>"u")return Promise.resolve();let t;try{t=new URL(e,location.href)}catch{return Promise.resolve()}return t.origin!==location.origin?Promise.resolve():be(t.href)},subscribe:Ie,getState:Ue,invalidate:ve};function Xt(e,t={}){return _?(t.replace?at(e,t):st(e,t),!1):(typeof location<"u"&&(t.replace?location.replace(e):location.assign(e)),!0)}function ct(){if(!(typeof document>"u")){if(_){te();return}if(_=!0,document.querySelectorAll("script[data-krate-boot]").forEach(e=>q.add(e.textContent||"")),A=x(location.href),C=Ve(document),N=A,m=Q(history.state)||D(),Q(history.state)===void 0)try{history.replaceState(J(m,history.state),"",location.href)}catch{}try{history.scrollRestoration="manual"}catch{}document.addEventListener("click",qe),document.addEventListener("submit",et),window.addEventListener("popstate",tt),window.addEventListener("krate:revalidate",nt),window.addEventListener("pagehide",rt),window.addEventListener("pageshow",ot),_t(),xt(),te()}}function Gt(){ct()}function Qt(){if(_){_=!1,document.removeEventListener("click",qe),document.removeEventListener("submit",et),window.removeEventListener("popstate",tt),window.removeEventListener("krate:revalidate",nt),window.removeEventListener("pagehide",rt),window.removeEventListener("pageshow",ot),document.removeEventListener("mouseover",Z),document.removeEventListener("focusin",Z);for(let e of B.values())clearTimeout(e);B=new Map,M&&(M.disconnect(),M=null),k&&k.abort(),k=void 0,T++,S.clear(),R.clear(),L.clear(),G.clear(),q.clear(),W.clear(),F="idle",$=[],C=[],Y.clear(),N=""}}return mt(Zt);})();
1
+ var __krate_exports=(()=>{var ut=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var he=Object.prototype.hasOwnProperty;var pe=(t,e)=>{for(var n in e)ut(t,n,{get:e[n],enumerable:!0})},me=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of de(e))!he.call(t,o)&&o!==n&&ut(t,o,{get:()=>e[o],enumerable:!(r=fe(e,o))||r.enumerable});return t};var ge=t=>me(ut({},"__esModule",{value:!0}),t);var qe={};pe(qe,{compareRouteSpecificity:()=>Xt,destroyRouter:()=>Ze,getHistoryState:()=>Ae,getNavigationState:()=>It,initRouter:()=>le,invalidatePrefetchCache:()=>kt,krateRouter:()=>Xe,matchRoutePattern:()=>Yt,navigate:()=>Ge,pageAssetURLs:()=>Dt,reinitRouter:()=>Qe,subscribeNavigation:()=>Kt});function I(){let t=globalThis.__KRATE_CFG__,e=t&&t.basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function P(t){let e=I();return e&&t.charCodeAt(0)===47&&t.charCodeAt(1)!==47?e+t:t}var gt=/\/chunks\/runtime\.[^/]+\.js$/;function yt(){return globalThis.__KRATE_CFG__||{}}function O(t){let e=I();if(e&&(t===e||t.startsWith(e+"/"))){let n=t.slice(e.length);return n===""?"/":n}return t}function ht(t){return t.length>1&&t.endsWith("/")?t.slice(0,-1):t}function F(t){if(yt().dev)try{console.warn("[krate router] "+t)}catch{}}function Ht(t,e){if(/^(https?:)?\/\//.test(t)||t.startsWith("/"))return new URL(t,e).href;let n=e;if(!n.endsWith("/")){let r=n.lastIndexOf("/");n=r>0?n.slice(0,r+1):"/"}return new URL(t,n).href}function Dt(t,e,n){let r=new DOMParser().parseFromString(t,"text/html"),o=[],i=new Set,s=c=>{if(!c)return;let a;try{a=Ht(c,e)}catch{return}i.has(a)||n.has(a)||gt.test(a)||(i.add(a),o.push(a))};return r.querySelectorAll("script[src]").forEach(c=>s(c.getAttribute("src"))),r.querySelectorAll('link[rel="modulepreload"][href], link[rel="preload"][as="script"][href]').forEach(c=>s(c.getAttribute("href"))),o}var R=!1,T=0,k,Rt=0,m="",A="",$="idle",j=new Set,S=new Map,_=new Map,ye=30,ve=3e4,L=new Map,ke=50,ft=new Set,be=128,Z=new Map,W=new Map,H=null,J=[],we="_krate/i",Ee=150,Se=200;function pt(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function U(){return Rt++,Date.now().toString(36)+"-"+Rt.toString(36)}function ot(t){try{let e=new URL(t,location.href);return e.hash="",e.href}catch{return t}}function x(t){let e=new URL(t,location.href);return ht(e.pathname)+e.search}function V(t,e=!1){let n=globalThis.__krateHardNavigate;if(typeof n=="function"){n(t,e);return}e?location.replace(t):location.assign(t)}function z(t,e){return{__krate:t,state:e===void 0?null:e}}function q(t){if(t&&typeof t=="object"&&typeof t.__krate=="string")return t.__krate}function Ae(){if(typeof history>"u")return null;let t=history.state;return q(t)!==void 0?t.state:t}function Ut(){let t=new URL(location.href);return{url:t.href,pathname:O(t.pathname),search:t.search,hash:t.hash,status:$}}function It(){return typeof location>"u"?{url:"",pathname:"/",search:"",hash:"",status:"idle"}:Ut()}function it(){if(j.size===0)return;let t=Ut();for(let e of Array.from(j))try{e(t)}catch(n){console.error(n)}}function D(t){$!==t&&($=t,it())}function Kt(t){return j.add(t),()=>{j.delete(t)}}function b(t,e,n=!1){try{let r=new CustomEvent(t,{detail:e,cancelable:n});return window.dispatchEvent(r),!r.defaultPrevented}catch{return!0}}function vt(t){try{let e=globalThis.__krate_onNavigation;typeof e=="function"&&e(t)}catch{}}function X(t){if(t){if(L.delete(t),L.size>=ke){let e=L.keys().next().value;e!==void 0&&L.delete(e)}L.set(t,window.scrollY||0)}}function Ot(){let t=yt().prefetchTTL;return typeof t=="number"&&t>=0?t:ve}function Le(t,e){for(S.delete(t);S.size>=ye;){let n=S.keys().next().value;if(n===void 0)break;S.delete(n)}S.set(t,e)}function Te(t){let e=S.get(t);if(e&&(S.delete(t),!(pt()-e.at>Ot())))return e}function kt(t){if(t===void 0){S.clear(),_.clear();return}let e=ot(t);S.delete(e),_.delete(e)}function bt(t){return/text\/html|application\/xhtml\+xml/i.test(t)}function Y(t){return/^\s*(<!doctype html|<html|<head|<body)/i.test(t)}function _e(t){if(ft.has(t)||ft.size>=be)return;ft.add(t);let e=document.createElement("link");e.rel="prefetch",e.as="script",e.href=t,document.head.appendChild(e)}function wt(t){let e=ot(t),n=S.get(e);if(n&&pt()-n.at<=Ot())return Promise.resolve();let r=_.get(e);if(r)return r;let o=fetch(e,{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async i=>{if(!i.ok)return;let s=i.headers.get("content-type")||"",c=i.url||e;if(new URL(c,location.href).origin!==location.origin)return;let a=await i.text();if(!(bt(s)||s===""&&Y(a))||_.get(e)!==o)return;Le(e,{html:a,url:c,status:i.status,at:pt()});let u=new Set;document.querySelectorAll("script[src]").forEach(l=>u.add(l.src));for(let l of Dt(a,c,u))_e(l)}).catch(()=>{}).finally(()=>{_.get(e)===o&&_.delete(e)});return _.set(e,o),o}function Et(t){if(t.hasAttribute("data-krate-external")||t.hasAttribute("download"))return!1;let e=t.getAttribute("href");if(!e||e.startsWith("javascript:"))return!1;let n;try{n=new URL(e,location.href)}catch{return!1}if(n.origin!==location.origin)return!1;let r=t.getAttribute("target");return!(r&&r!=="_self")}function St(t){let e=t.getAttribute("data-prefetch");return t.hasAttribute("data-prefetch")&&e!=="false"&&e!=="0"}function Re(t){let e=window.requestIdleCallback;typeof e=="function"?e(t,{timeout:1e3}):setTimeout(t,50)}function tt(t){let e=t.target;if(!e||typeof e.closest!="function")return;let n=e.closest("a[data-prefetch]");if(!n||!St(n)||!Et(n))return;let r=n.getAttribute("href");if(!r)return;let o=new URL(r,location.href).href;if(x(o)===A)return;let i=W.get(n);i&&clearTimeout(i);let s=setTimeout(()=>{W.delete(n),wt(o)},Se);W.set(n,s)}function Bt(){H&&document.querySelectorAll("a[data-prefetch]").forEach(t=>{St(t)&&H.observe(t)})}function xe(){document.addEventListener("mouseover",tt),document.addEventListener("focusin",tt),typeof IntersectionObserver<"u"&&(H=new IntersectionObserver(t=>{for(let e of t){if(!e.isIntersecting)continue;let n=e.target,r=n.getAttribute("href");if(r&&Et(n)&&St(n)){let o=new URL(r,location.href).href;x(o)!==A&&Re(()=>{wt(o)})}H.unobserve(e.target)}},{rootMargin:"200px"}),Bt())}function Pe(){let t=typeof HTMLScriptElement<"u"?HTMLScriptElement.supports:void 0;if(!(typeof t!="function"||!t("speculationrules"))&&!document.querySelector('meta[http-equiv="Content-Security-Policy" i]'))try{let e=document.createElement("script");e.type="speculationrules";let n=I();e.textContent=JSON.stringify({prefetch:[{where:{and:[{href_matches:n+"/*"},{not:{href_matches:n+"/__krate/*"}},{not:{href_matches:n+"/api/*"}}]},eagerness:"moderate"}]}),document.head.appendChild(e)}catch{}}function Ft(){if(typeof window<"u"&&window.matchMedia)try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{}return!1}function Wt(){return yt().viewTransitions===!1||Ft()?!1:typeof document.startViewTransition=="function"}function w(t){return t.getElementById("root")||t.body}function Ce(){let t=document.querySelector("template[data-krate-loading]");if(t&&t.content&&J.length===0){let e=t.content.cloneNode(!0);J=Array.from(e.childNodes),document.body.appendChild(e)}if(!Wt()&&!Ft()){let e=w(document);e.style.transition=`opacity ${Ee}ms ease`,e.style.opacity="0"}}function At(){for(let e of J)e.parentNode&&e.parentNode.removeChild(e);J=[];let t=w(document);t.style.opacity==="0"&&(t.style.opacity="")}function $t(t){t.querySelectorAll("[data-view-transition]").forEach(e=>{let n=e.getAttribute("data-view-transition");n&&(e.style.viewTransitionName=n);let r=e.getAttribute("data-view-transition-class");r&&e.style.setProperty("view-transition-class",r)})}var Ne=3e3;function Me(t,e){let n=[];t.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let l=u.getAttribute("href");if(!l)return;let p=new URL(l,e).href;n.includes(p)||n.push(p)});let r=new Map,o=[];document.querySelectorAll('link[rel="stylesheet"]').forEach(u=>{let l=u;l.href&&(n.includes(l.href)&&!r.has(l.href)?r.set(l.href,l):o.push(l))});let i=[],s=[],c=null;n.forEach((u,l)=>{let p=r.get(u)||null;if(!p){let h=document.createElement("link");if(h.rel="stylesheet",h.href=u,s.push(new Promise(g=>{let f=()=>{h.removeEventListener("load",f),h.removeEventListener("error",f),g()};h.addEventListener("load",f),h.addEventListener("error",f)})),i.push({link:h,media:h.getAttribute("media")}),h.media="not all",c)c.after(h);else{let g=n.slice(l+1).map(f=>r.get(f)).find(f=>!!f);g?g.before(h):document.head.appendChild(h)}p=h}c=p});let a=Promise.resolve();if(s.length>0){let u,l=new Promise(p=>{u=setTimeout(p,Ne)});a=Promise.race([Promise.all(s).then(()=>{}),l]).then(()=>clearTimeout(u))}return{ready:a,commit(){for(let{link:u,media:l}of i)l===null?u.removeAttribute("media"):u.setAttribute("media",l);o.forEach(u=>u.remove())},abort(){i.forEach(({link:u})=>u.remove())}}}var xt='meta[name="description"], meta[name="robots"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function He(t){document.head.querySelectorAll(xt).forEach(e=>e.remove()),t.head.querySelectorAll(xt).forEach(e=>{document.head.appendChild(document.importNode(e,!0))})}function jt(t,e){let n=new Set;document.querySelectorAll("script[src]:not([data-krate-spa])").forEach(i=>n.add(i.src));let r=[],o=new Set;return t.querySelectorAll("script[src]").forEach(i=>{let s=i.getAttribute("src");if(!s)return;let c=(i.getAttribute("type")||"").toLowerCase();if(c&&c!=="module"&&c!=="text/javascript"&&c!=="application/javascript")return;let a=Ht(s,e);!n.has(a)&&!o.has(a)&&(o.add(a),r.push({src:a,module:c==="module"}))}),r}function Jt(t){return new Promise(e=>{let n=document.createElement("script");n.src=t.src,t.module&&(n.type="module"),gt.test(t.src)||n.setAttribute("data-krate-spa",""),n.onload=()=>e(!0),n.onerror=()=>e(!1),document.body.appendChild(n)})}var et=new Set;function Vt(t){t.querySelectorAll("script[data-krate-boot]").forEach(e=>{let n=e.textContent||"";if(!n||et.has(n))return;et.add(n);let r=document.createElement("script");r.text=n,document.head.appendChild(r),r.remove()})}function De(t){if(!t||t==="#")return null;let e=t.slice(1);try{e=decodeURIComponent(e)}catch{}return document.getElementById(e)||document.getElementsByName(e)[0]||null}function Lt(t){let e=De(t);if(!e)return!1;try{e.scrollIntoView({block:"start"})}catch{}return!0}function Ue(t,e){if(e.kind==="pop"){let r=e.restoreKey?L.get(e.restoreKey):void 0;if(r!==void 0){window.scrollTo(0,r);return}}let n=new URL(t,location.href).hash;Lt(n)||e.scroll&&e.kind!=="refresh"&&window.scrollTo(0,0)}var Q=null;function Ie(){let t=document.activeElement;if(t&&t!==document.body&&t.isConnected&&t!==Q)return;let e=w(document);e.hasAttribute("tabindex")||(e.setAttribute("tabindex","-1"),Q=e,e.addEventListener("blur",()=>{Q===e&&(e.removeAttribute("tabindex"),Q=null)},{once:!0}));try{e.focus({preventScroll:!0})}catch{}}var Pt="__krate-route-announcer";function Ke(){let t=document.getElementById(Pt);t||(t=document.createElement("div"),t.id=Pt,t.setAttribute("aria-live","assertive"),t.setAttribute("aria-atomic","true"),t.setAttribute("role","status"),t.setAttribute("style","position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0"),document.body.appendChild(t));let e=w(document).querySelector("h1"),n=document.title||(e&&e.textContent?e.textContent.trim():"")||O(location.pathname);t.textContent=n}function st(){let t=ht(O(location.pathname));document.querySelectorAll("a[data-krate-link]").forEach(e=>{let n=e.getAttribute("href"),r="";try{r=n?ht(O(new URL(n,location.href).pathname)):""}catch{r=""}let o="";r&&r===t?o="exact":r&&r!=="/"&&t.startsWith(r+"/")&&(o="segment"),o==="exact"?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current"),o?e.setAttribute("data-krate-active",o):e.removeAttribute("data-krate-active")})}function Ct(t){let e=I()+t;return Z.has(e)?Promise.resolve(Z.get(e)??null):fetch(e,{headers:{Accept:"text/html"},credentials:"same-origin"}).then(async n=>{let r=n.ok?await n.text():null,o=r&&Y(r)?r:null;return Z.set(e,o),o}).catch(()=>null)}async function Oe(t,e){let n=ot(t.url);if(!t.bypassCache){let p=_.get(n);if(p&&await p,e.aborted)return{ok:!1,aborted:!0};let h=Te(n);if(h){let g=new URL(t.url,location.href).hash,f=g&&!new URL(h.url,location.href).hash?h.url+g:h.url;return{ok:!0,doc:{html:h.html,url:f,status:h.status}}}}let r;try{r=await fetch(n,{headers:{Accept:"text/html"},credentials:"same-origin",signal:e,cache:t.bypassCache?"no-cache":"default"})}catch(p){return p?.name==="AbortError"||e.aborted?{ok:!1,aborted:!0}:b("krate:navigate-error",{url:t.url,status:0,error:p},!0)?{ok:!1,hard:t.url}:{ok:!1,aborted:!0}}let o=r.url||n;if(new URL(o,location.href).origin!==location.origin)return{ok:!1,hard:o};let i=r.headers.get("content-type")||"",s="";try{s=await r.text()}catch(p){if(p?.name==="AbortError"||e.aborted)return{ok:!1,aborted:!0};s=""}if(e.aborted)return{ok:!1,aborted:!0};let c=bt(i)||i===""&&Y(s),a=new URL(t.url,location.href).hash,u=a&&!new URL(o).hash?o+a:o;if(r.ok)return c?{ok:!0,doc:{html:s,url:u,status:r.status}}:{ok:!1,hard:u};if(b("krate:navigate-error",{url:t.url,status:r.status}),c&&Y(s))return{ok:!0,doc:{html:s,url:u,status:r.status}};let l=null;return r.status===404||r.status===410?l=await Ct("/404.html"):r.status>=500&&(l=await Ct("/500.html")),e.aborted?{ok:!1,aborted:!0}:l?{ok:!0,doc:{html:l,url:u,status:r.status}}:{ok:!1,hard:u}}async function at(t){let e=location.href;if(t.kind!=="pop"){if(!b("krate:navigate-start",{url:t.url,from:e,kind:t.kind},!0))return}else b("krate:navigate-start",{url:t.url,from:e,kind:t.kind});let n=++T;k&&k.abort();let r=new AbortController;k=r,D("loading"),!t.bypassCache&&S.has(ot(t.url))||Ce();let i;try{i=await Oe(t,r.signal)}finally{k===r&&(k=void 0)}if(n===T){if(!i.ok){At(),D("idle"),"hard"in i&&V(i.hard,t.kind==="replace"||t.kind==="refresh");return}await Be(i.doc,t,n)}}async function Be(t,e,n){let r=new DOMParser().parseFromString(t.html,"text/html"),o=t.url,i=w(r),s=w(document);e.kind==="push"&&X(m);let c=zt(r),a=je(N,c,location.href,o,r),u=Me(r,o);if(await u.ready,n!==T){u.abort();return}if(await Fe(()=>{let g=r.querySelector("title");g&&(document.title=g.textContent||"");let f=globalThis;if(a.keep.length>0&&typeof f.krateDisposeExcept=="function"?f.krateDisposeExcept(a.keep):typeof f.disposeAll=="function"&&f.disposeAll(),a.region){let{live:v,next:d}=a.region;nt(v[0],v[1]);let E=K(d[0],d[1]).map(y=>document.importNode(y,!0));for(let y of E)v[1].parentNode.insertBefore(y,v[1]);for(let y of a.slots){nt(y.live[0],y.live[1]);for(let B of K(y.next[0],y.next[1]))y.live[1].parentNode.insertBefore(document.importNode(B,!0),y.live[1])}We(s,i)}else{let v=Array.from(i.childNodes).map(d=>document.importNode(d,!0));s.replaceChildren(...v)}N=a.chain,G.clear(),u.commit(),He(r),$t(document)}),n!==T)return;At(),e.kind==="push"?(m=U(),history.pushState(z(m,e.state),"",o)):e.kind==="replace"?(L.delete(m),m=U(),history.replaceState(z(m,e.state),"",o)):e.kind==="refresh"?o!==location.href&&history.replaceState(history.state,"",o):e.restoreKey&&(m=e.restoreKey),A=x(location.href),M=A,Qt(r),Je(r),Ue(o,e),e.kind!=="pop"&&e.kind!=="refresh"&&Ie(),e.kind!=="refresh"&&Ke(),st(),b("krate:navigate",{url:location.href,status:t.status}),vt(location.href),D("idle"),document.querySelectorAll("script[data-krate-spa]").forEach(g=>g.remove()),Vt(r);let p=jt(r,o);Mt(a.skip);let h=await Promise.all(p.map(Jt));if(Mt([]),n===T){if(h.some(g=>!g)){b("krate:navigate-error",{url:location.href,status:t.status,error:"script-load"}),V(location.href,!0);return}rt(),b("krate:navigate-end",{url:location.href,status:t.status})}}function Fe(t){if(!Wt())return t(),Promise.resolve();let e=!1,n=()=>{e||(e=!0,t())};try{let r=document.startViewTransition(n);r&&r.finished&&typeof r.finished.catch=="function"&&r.finished.catch(()=>{});let o=r&&r.updateCallbackDone;if(o&&typeof o.then=="function")return o.then(()=>n(),()=>n())}catch{}return n(),Promise.resolve()}var N=[];function zt(t){let e=t.getElementById("__krate_route");if(!e)return[];try{let n=JSON.parse(e.textContent||"{}");return Array.isArray(n.chain)?n.chain:[]}catch{return F("unreadable #__krate_route route info; layouts will be remounted"),[]}}function Nt(t,e){let n=O(new URL(t,location.href).pathname).split("/").filter(Boolean);return(e<0?n:n.slice(0,e)).join("/")}function C(t,e,n="kl:"){let o=(t.ownerDocument||t).createTreeWalker(t,128),i=n+e,s="/"+n+e;for(;o.nextNode();){let c=o.currentNode;if(c.nodeValue===i){for(let a=c.nextSibling;a;a=a.nextSibling)if(a.nodeType===8&&a.nodeValue===s)return[c,a];return null}}return null}function K(t,e){let n=[];for(let r=t.nextSibling;r&&r!==e;r=r.nextSibling)n.push(r);return n}function nt(t,e){let n=globalThis.disposeNode;for(let r of K(t,e))r.parentNode.removeChild(r),typeof n=="function"&&n(r)}function We(t,e){let n=":scope > template[data-krate-loading]";t.querySelectorAll(n).forEach(r=>r.remove()),e.querySelectorAll(n).forEach(r=>t.appendChild(document.importNode(r,!0)))}function Mt(t){let e=globalThis.krateKeepScopes;typeof e=="function"&&e(t)}function $e(t){let e=globalThis.krateScopeFailed;return typeof e=="function"&&!!e(t)}function je(t,e,n,r,o){let i={keep:[],skip:[],region:null,slots:[],chain:e},s=0;for(;s<t.length&&s<e.length;){let f=t[s],v=e[s];if(f.id!==v.id||f.k!==v.k||f.k!=="layout"&&f.k!=="error"||Nt(n,f.d)!==Nt(r,v.d)||f.k==="error"&&$e(f.id))break;if(!f.p||!v.p){F(`layout ${v.f||v.id} is remounted on this navigation: ${v.why||f.why||"not persistable"}`);break}s++}if(s===0)return i;if(typeof globalThis.krateDisposeExcept!="function")return F("the runtime has no krateDisposeExcept; layouts are remounted"),i;let c=e[s-1].id,a=C(w(document),c),u=C(w(o),c);if(!a||!u)return F(`layout ${e[s-1].f||c} boundary markers are missing; the whole page is swapped`),i;let l=t.slice(0,s).map(f=>f.id),p=l.slice(),h=[],g=e.slice();for(let f=0;f<s;f++){let v=t[f].s||[],d=[];for(let E of e[f].s||[]){let y=v.find(ue=>ue.key===E.key),B=C(w(document),E.key,"ks:"),lt=C(w(o),E.key,"ks:");if(y&&B&&(E.src!=="page"||!lt)){l.push(y.scope),p.push(y.scope,E.scope),d.push({...E,scope:y.scope,src:y.src});continue}if(B&&lt){h.push({live:B,next:lt}),d.push(E);continue}return F(`slot @${E.n} markers are missing; the whole page is swapped`),i}g[f]={...e[f],s:d}}return{keep:l,skip:p,region:{live:a,next:u},slots:h,chain:g}}var G=new Map,M="";function mt(t){let e=t.replace(/^\/+|\/+$/g,"");return e?e.split("/").map(n=>n.startsWith("[[...")&&n.endsWith("]]")?{kind:3,text:n.slice(5,-2)}:n.startsWith("[...")&&n.endsWith("]")?{kind:2,text:n.slice(4,-1)}:n.startsWith("[")&&n.endsWith("]")?{kind:1,text:n.slice(1,-1)}:{kind:0,text:n}):[]}function Yt(t,e){let n=mt(e),r=t.replace(/^\/+|\/+$/g,""),o=r?r.split("/"):[],i={};for(let s=0;s<n.length;s++){let c=n[s];if(c.kind>=2){if(s!==n.length-1)return null;let a=o.slice(s);return c.kind===2&&a.length===0||a.some(u=>u==="")?null:(i[c.text]=a.map(dt).join("/"),i)}if(s>=o.length)return null;if(c.kind===1){if(!o[s])return null;i[c.text]=dt(o[s])}else if(dt(o[s])!==c.text)return null}return o.length===n.length?i:null}function dt(t){try{return decodeURIComponent(t)}catch{return t}}function Xt(t,e){let n=mt(t),r=mt(e);for(let o=0;o<n.length&&o<r.length;o++){if(n[o].kind!==r[o].kind)return n[o].kind-r[o].kind;if(n[o].kind===0&&n[o].text!==r[o].text)return n[o].text<r[o].text?-1:1}return n.length!==r.length?r.length-n.length:t<e?-1:t>e?1:0}function Tt(t){let e=O(new URL(t,location.href).pathname).replace(/^\/+|\/+$/g,""),n=null;for(let r of N)for(let o of r.s||[])for(let i of o.i||[])Yt(e,i)&&(!n||Xt(i,n.pattern)<0)&&(n={hit:{entry:r,slot:o,path:e},pattern:i});return n&&!C(w(document),n.hit.slot.key,"ks:")?null:n?n.hit:null}function Gt(t,e){N=N.map(n=>n.s&&n.s.some(r=>r.key===t)?{...n,s:n.s.map(r=>r.key===t?e:r)}:n)}function Qt(t){let e="",n=t.getElementById("__krate_page");if(n)try{let r=JSON.parse(n.textContent||"{}");typeof r.r=="string"&&(e=r.r)}catch{}globalThis.__KRATE_ROUTE__=e;for(let r of Array.from(t.querySelectorAll("script:not([src])"))){let o=/window\.__KRATE_PARAMS__\s*=\s*(\{[\s\S]*?\})\s*;?\s*$/.exec(r.textContent||"");if(o){try{globalThis.__KRATE_PARAMS__=JSON.parse(o[1])}catch{}return}}delete globalThis.__KRATE_PARAMS__}function Je(t){let e=t.getElementById("__krate_error"),n=document.getElementById("__krate_error");if(!e){n&&n.remove();return}let r=document.importNode(e,!0);n?n.replaceWith(r):document.head.appendChild(r)}function Zt(t){let e=globalThis.krateDisposeScopes;typeof e=="function"&&e(t)}async function _t(t,e){let n=location.href;if(t.kind!=="pop"&&!b("krate:navigate-start",{url:t.url,from:n,kind:t.kind,intercept:e.slot.n},!0))return;let r=++T;k&&k.abort();let o=new AbortController;k=o,D("loading");let i=location.origin+I()+"/"+we+"/"+e.slot.key+(e.path?"/"+e.path:""),s="",c=!1;try{let d=await fetch(i,{headers:{Accept:"text/html"},credentials:"same-origin",signal:o.signal,cache:t.bypassCache?"no-cache":"default"});s=await d.text(),c=d.ok&&(bt(d.headers.get("content-type")||"")||Y(s)),c||b("krate:navigate-error",{url:t.url,status:d.status,intercept:e.slot.n})}catch(d){if(d?.name==="AbortError"||o.signal.aborted)return;b("krate:navigate-error",{url:t.url,status:0,error:d,intercept:e.slot.n})}finally{k===o&&(k=void 0)}if(r!==T)return;let a=c?new DOMParser().parseFromString(s,"text/html"):null,u=a?C(w(a),e.slot.key,"ks:"):null,l=C(w(document),e.slot.key,"ks:"),p=null;try{let d=a&&a.getElementById("__krate_route");p=d&&JSON.parse(d.textContent||"{}").frag||null}catch{p=null}if(!a||!u||!l||!p||p.key!==e.slot.key||!p.scope){try{console.warn(`[krate router] intercepting route for ${t.url} (slot @${e.slot.n}) could not be loaded; navigating to the page`)}catch{}return D("idle"),at({...t})}if(t.kind==="push"&&X(m),e.slot.src!=="intercept"){G.set(m,{key:e.slot.key,nodes:K(l[0],l[1]),slot:e.slot,path:M});for(let d of K(l[0],l[1]))d.parentNode.removeChild(d)}else Zt([e.slot.scope]),nt(l[0],l[1]);for(let d of K(u[0],u[1]))l[1].parentNode.insertBefore(document.importNode(d,!0),l[1]);let h=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(d=>h.add(d.href)),a.querySelectorAll('link[rel="stylesheet"][href]').forEach(d=>{let E=new URL(d.getAttribute("href"),i).href;if(h.has(E))return;let y=document.createElement("link");y.rel="stylesheet",y.href=E,document.head.appendChild(y)}),Gt(e.slot.key,{...e.slot,scope:p.scope,src:"intercept"}),Vt(a);let g={__krate:"",state:t.state===void 0?null:t.state,__kint:{key:e.slot.key,base:M}};t.kind==="push"?(m=U(),g.__krate=m,history.pushState(g,"",t.url)):t.kind==="replace"?(m=U(),g.__krate=m,history.replaceState(g,"",t.url)):t.kind==="pop"&&t.restoreKey&&(m=t.restoreKey),A=x(location.href),Qt(a),st(),b("krate:navigate",{url:location.href,status:200,intercept:e.slot.n}),vt(location.href),D("idle");let f=jt(a,i),v=await Promise.all(f.map(Jt));if(r===T){if(v.some(d=>!d)){b("krate:navigate-error",{url:location.href,status:200,error:"script-load",intercept:e.slot.n}),V(location.href,!0);return}rt(),b("krate:navigate-end",{url:location.href,status:200,intercept:e.slot.n})}}function Ve(t,e){let n=C(w(document),t.key,"ks:"),r=N.flatMap(i=>i.s||[]).find(i=>i.key===t.key);if(!n||!r||r.src!=="intercept")return!1;Zt([r.scope]),nt(n[0],n[1]);for(let i of t.nodes)n[1].parentNode.insertBefore(i,n[1]);Gt(t.key,t.slot),G.delete(e),m=e,A=x(location.href);let o=L.get(e);return o!==void 0&&window.scrollTo(0,o),st(),b("krate:navigate",{url:location.href,status:200}),vt(location.href),it(),!0}function ze(t){return x(t)===A}function qt(){$==="loading"&&(T++,k&&k.abort(),k=void 0,At(),D("idle"))}function Ye(t,e){qt(),X(m),(t!==location.href||e.state!==void 0)&&(e.kind==="replace"?history.replaceState(z(m||U(),e.state),"",t):(m=U(),history.pushState(z(m,e.state),"",t)));let n=new URL(t).hash;!Lt(n)&&e.scroll&&!n&&window.scrollTo(0,0),it()}function ct(t){let e;try{e=new URL(t.url,location.href)}catch{return V(t.url),Promise.resolve()}if(e.origin!==location.origin)return V(e.href,t.kind==="replace"),Promise.resolve();if(t.url=e.href,(t.kind==="push"||t.kind==="replace")&&ze(e.href)&&(e.hash||e.href===location.href))return Ye(e.href,t),Promise.resolve();if(t.kind==="push"||t.kind==="replace"){let n=Tt(e.href);if(n)return _t(t,n)}return at(t)}function te(t){if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let e=t.target;if(!e||typeof e.closest!="function")return;let n=e.closest("a[data-krate-link]");if(!n||!Et(n))return;let r=n.getAttribute("href");r&&(t.preventDefault(),ct({url:new URL(r,location.href).href,kind:n.hasAttribute("data-krate-replace")?"replace":"push",scroll:n.getAttribute("data-krate-scroll")!=="false"}))}function ee(t){if(t.defaultPrevented)return;let e=t.target;if(!e||e.tagName!=="FORM"||e.hasAttribute("data-krate-reload"))return;let n=t.submitter||null;if((n&&n.getAttribute("formmethod")||e.getAttribute("method")||"get").toLowerCase()!=="get")return;let o=n&&n.getAttribute("formtarget")||e.getAttribute("target");if(o&&o!=="_self")return;let i=n&&n.getAttribute("formaction")||e.getAttribute("action")||"",s;try{s=new URL(i||location.href,location.href)}catch{return}if(s.origin!==location.origin||s.protocol.indexOf("http")!==0)return;let c;try{c=n?new FormData(e,n):new FormData(e)}catch{c=new FormData(e),n&&n.name&&c.append(n.name,n.value)}let a=new URLSearchParams;for(let[u,l]of c.entries()){if(typeof l!="string")return;a.append(u,l)}t.preventDefault(),s.search=a.toString(),s.hash="",ct({url:s.href,kind:"push",scroll:!0})}function ne(t){X(m);let e=q(t.state),n=location.href;if(x(n)===A){qt(),m=e||m;let i=e?L.get(e):void 0;i!==void 0?window.scrollTo(0,i):Lt(location.hash),it();return}let r=e?G.get(e):void 0;if(r&&e&&r.path===x(n)&&r.path===M&&Ve(r,e))return;let o=t.state&&typeof t.state=="object"?t.state.__kint:null;if(o&&o.base===M){let i=Tt(n);if(i&&i.slot.key===o.key){_t({url:n,kind:"pop",scroll:!1,restoreKey:e},i);return}}at({url:n,kind:"pop",scroll:!0,restoreKey:e})}function re(){kt(),se()}function oe(){X(m);try{history.scrollRestoration="auto"}catch{}}function ie(){try{history.scrollRestoration="manual"}catch{}}function rt(){Bt(),st(),$t(document),document.querySelectorAll("script[src]").forEach(t=>{gt.test(t.src)||t.setAttribute("data-krate-spa","")})}function se(){if(!R||typeof location>"u")return typeof location<"u"&&location.reload(),Promise.resolve();if(A!==M){let t=Tt(location.href);if(t&&t.slot.src==="intercept")return _t({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0},t)}return at({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0})}function ae(t,e={}){return R?ct({url:P(t),kind:"push",scroll:e.scroll!==!1,state:e.state}):(typeof location<"u"&&location.assign(P(t)),Promise.resolve())}function ce(t,e={}){return R?ct({url:P(t),kind:"replace",scroll:e.scroll!==!1,state:e.state}):(typeof location<"u"&&location.replace(P(t)),Promise.resolve())}var Xe={push:ae,replace:ce,back(){typeof history<"u"&&history.back()},forward(){typeof history<"u"&&history.forward()},refresh:se,prefetch(t){if(!R||typeof location>"u")return Promise.resolve();let e;try{e=new URL(P(t),location.href)}catch{return Promise.resolve()}return e.origin!==location.origin?Promise.resolve():wt(e.href)},subscribe:Kt,getState:It,invalidate:kt};function Ge(t,e={}){return R?(e.replace?ce(t,e):ae(t,e),!1):(typeof location<"u"&&(e.replace?location.replace(P(t)):location.assign(P(t))),!0)}function le(){if(!(typeof document>"u")){if(R){rt();return}if(R=!0,document.querySelectorAll("script[data-krate-boot]").forEach(t=>et.add(t.textContent||"")),A=x(location.href),N=zt(document),M=A,m=q(history.state)||U(),q(history.state)===void 0)try{history.replaceState(z(m,history.state),"",location.href)}catch{}try{history.scrollRestoration="manual"}catch{}document.addEventListener("click",te),document.addEventListener("submit",ee),window.addEventListener("popstate",ne),window.addEventListener("krate:revalidate",re),window.addEventListener("pagehide",oe),window.addEventListener("pageshow",ie),xe(),Pe(),rt()}}function Qe(){le()}function Ze(){if(R){R=!1,document.removeEventListener("click",te),document.removeEventListener("submit",ee),window.removeEventListener("popstate",ne),window.removeEventListener("krate:revalidate",re),window.removeEventListener("pagehide",oe),window.removeEventListener("pageshow",ie),document.removeEventListener("mouseover",tt),document.removeEventListener("focusin",tt);for(let t of W.values())clearTimeout(t);W=new Map,H&&(H.disconnect(),H=null),k&&k.abort(),k=void 0,T++,S.clear(),_.clear(),L.clear(),Z.clear(),et.clear(),j.clear(),$="idle",J=[],N=[],G.clear(),M=""}}return ge(qe);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }