@krate/runtime 0.5.0-alpha.2 → 0.5.0-alpha.4

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.
Files changed (105) hide show
  1. package/dist/action-context.d.ts +56 -0
  2. package/dist/action-context.js +73 -0
  3. package/dist/action-context.test.d.ts +1 -0
  4. package/dist/action-context.test.js +47 -0
  5. package/dist/actions.d.ts +120 -0
  6. package/dist/actions.js +550 -0
  7. package/dist/actions.test.d.ts +1 -0
  8. package/dist/actions.test.js +417 -0
  9. package/dist/boundary.d.ts +121 -0
  10. package/dist/boundary.js +429 -0
  11. package/dist/cache-scope.d.ts +118 -0
  12. package/dist/cache-scope.js +311 -0
  13. package/dist/cache.d.ts +55 -0
  14. package/dist/cache.js +155 -0
  15. package/dist/cache.test.d.ts +1 -0
  16. package/dist/cache.test.js +217 -0
  17. package/dist/class-component.d.ts +66 -0
  18. package/dist/class-component.js +633 -0
  19. package/dist/class-component.test.d.ts +1 -0
  20. package/dist/class-component.test.js +411 -0
  21. package/dist/context.d.ts +13 -0
  22. package/dist/context.js +58 -32
  23. package/dist/context.test.d.ts +1 -0
  24. package/dist/context.test.js +57 -0
  25. package/dist/derived.test.d.ts +1 -0
  26. package/dist/derived.test.js +140 -0
  27. package/dist/discrete.test.d.ts +1 -0
  28. package/dist/discrete.test.js +100 -0
  29. package/dist/dom.d.ts +55 -0
  30. package/dist/dom.js +414 -63
  31. package/dist/effects.d.ts +88 -0
  32. package/dist/effects.js +790 -0
  33. package/dist/effects.test.d.ts +1 -0
  34. package/dist/effects.test.js +485 -0
  35. package/dist/events.d.ts +58 -0
  36. package/dist/events.js +503 -0
  37. package/dist/events.test.d.ts +1 -0
  38. package/dist/events.test.js +447 -0
  39. package/dist/index.d.ts +14 -4
  40. package/dist/index.js +9 -3
  41. package/dist/jsx-types.d.ts +2 -0
  42. package/dist/krate-hydrate-lite.js +7 -1
  43. package/dist/krate-hydrate.js +7 -1
  44. package/dist/krate-runtime.js +7 -1
  45. package/dist/krate-suspense.js +2 -0
  46. package/dist/lanes.test.d.ts +1 -0
  47. package/dist/lanes.test.js +59 -0
  48. package/dist/list.d.ts +20 -0
  49. package/dist/list.js +466 -0
  50. package/dist/list.test.d.ts +1 -0
  51. package/dist/list.test.js +344 -0
  52. package/dist/optimistic-lanes.test.d.ts +1 -0
  53. package/dist/optimistic-lanes.test.js +45 -0
  54. package/dist/portal.d.ts +47 -0
  55. package/dist/portal.js +189 -0
  56. package/dist/portal.test.d.ts +1 -0
  57. package/dist/portal.test.js +99 -0
  58. package/dist/react-effects.test.d.ts +1 -0
  59. package/dist/react-effects.test.js +96 -0
  60. package/dist/react-suspense.test.d.ts +1 -0
  61. package/dist/react-suspense.test.js +194 -0
  62. package/dist/react.d.ts +132 -32
  63. package/dist/react.js +335 -81
  64. package/dist/react.test.js +12 -2
  65. package/dist/reconcile.js +13 -0
  66. package/dist/refs.d.ts +33 -0
  67. package/dist/refs.js +142 -0
  68. package/dist/refs.test.d.ts +1 -0
  69. package/dist/refs.test.js +257 -0
  70. package/dist/request-context.d.ts +62 -0
  71. package/dist/request-context.js +107 -0
  72. package/dist/resource.js +20 -1
  73. package/dist/router-layout.test.d.ts +1 -0
  74. package/dist/router-layout.test.js +179 -0
  75. package/dist/router-lite.d.ts +25 -0
  76. package/dist/router-lite.js +73 -0
  77. package/dist/router-nav.test.d.ts +1 -0
  78. package/dist/router-nav.test.js +399 -0
  79. package/dist/router-slots.test.d.ts +1 -0
  80. package/dist/router-slots.test.js +144 -0
  81. package/dist/router.d.ts +66 -2
  82. package/dist/router.js +1535 -650
  83. package/dist/server-async.test.d.ts +1 -0
  84. package/dist/server-async.test.js +174 -0
  85. package/dist/server-renderer.js +494 -119
  86. package/dist/server.d.ts +27 -1
  87. package/dist/server.js +187 -1
  88. package/dist/server.test.js +20 -0
  89. package/dist/signal-lanes.test.d.ts +1 -0
  90. package/dist/signal-lanes.test.js +32 -0
  91. package/dist/signal.d.ts +186 -1
  92. package/dist/signal.js +896 -66
  93. package/dist/slots.d.ts +22 -0
  94. package/dist/slots.js +134 -0
  95. package/dist/slots.test.d.ts +1 -0
  96. package/dist/slots.test.js +169 -0
  97. package/dist/snapshots.test.d.ts +1 -0
  98. package/dist/snapshots.test.js +208 -0
  99. package/dist/suspense-actions.test.d.ts +1 -0
  100. package/dist/suspense-actions.test.js +72 -0
  101. package/dist/suspense.d.ts +220 -0
  102. package/dist/suspense.js +901 -0
  103. package/dist/suspense.test.d.ts +1 -0
  104. package/dist/suspense.test.js +518 -0
  105. package/package.json +5 -1
@@ -1,2 +1,8 @@
1
- var __krate_exports=(()=>{var Q=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var dt=Object.prototype.hasOwnProperty;var gt=(e,t)=>{for(var n in t)Q(e,n,{get:t[n],enumerable:!0})},ft=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ct(t))!dt.call(e,o)&&o!==n&&Q(e,o,{get:()=>t[o],enumerable:!(i=lt(t,o))||i.enumerable});return e};var bt=e=>ft(Q({},"__esModule",{value:!0}),e);var rn={};gt(rn,{Fragment:()=>Vt,Slot:()=>en,clearNodes:()=>qe,clearPersisted:()=>vt,cloneElement:()=>nn,clsx:()=>ve,cn:()=>$t,createCSSChoice:()=>Et,createCSSFlags:()=>Mt,createCSSGroup:()=>Lt,createCSSRange:()=>St,createCSSStack:()=>xt,createCSSToggle:()=>yt,createContext:()=>ee,createEffect:()=>L,createMemo:()=>Rt,createReducer:()=>Ot,createResource:()=>Bt,createScope:()=>pt,createScopeFlags:()=>ht,createSignal:()=>h,cva:()=>Qt,disposeAll:()=>Ht,disposeNode:()=>V,forwardRef:()=>_t,h:()=>z,hydrate:()=>qt,initRouter:()=>Xe,insert:()=>Kt,jsx:()=>ze,jsxs:()=>zt,mount:()=>Ft,navigate:()=>Gt,onCleanup:()=>B,onMount:()=>Ct,pageAssetURLs:()=>We,readDurableState:()=>ie,readPersisted:()=>se,reinitRouter:()=>Jt,resetContexts:()=>Z,resolvePersist:()=>re,subscribePersist:()=>ae,twMerge:()=>Ae,useRef:()=>Nt,writePersisted:()=>oe});var mt=0,w=new Map;function Z(){for(let[e,t]of w)if(t.length>0){let n=t[0];w.set(e,[n])}}function pt(){return ee({})}function ht(){return ee({})}function ee(e){let t=mt++;w.set(t,[e]);let n=()=>{let i=w.get(t);return i&&i.length>0?i[i.length-1]:e};return{id:t,defaultValue:e,Provider:i=>{let o=w.get(t)||[e];o.push(i.value),w.set(t,o);let a=document.createElement("div");if(a.style.display="contents",i.children)for(let d of i.children)d instanceof Node?a.appendChild(d):d!=null&&a.appendChild(document.createTextNode(String(d)));return o.pop(),o.length===0&&o.push(e),a},useContext:n,use:n}}function Tt(){let e=new Map;return{getItem:t=>e.has(t)?e.get(t):null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}var te=Tt();function _e(){return typeof window<"u"}function ne(e){if(e&&typeof e=="object")return e;if(!_e())return te;try{return e==="session"?window.sessionStorage:e==="memory"?te:window.localStorage}catch{return te}}function re(e){let t=typeof e=="string"?{key:e}:e;if(!t.key)throw new Error("[krate] createSignal persist requires a key");let n=t.store??"local";return{key:t.key,store:n,serialize:t.serialize??(i=>JSON.stringify(i)),deserialize:t.deserialize??(i=>JSON.parse(i)),sync:t.sync??n==="local"}}function ie(e,t){let i=globalThis.__KRATE_STATE__;if(!i||!Object.prototype.hasOwnProperty.call(i,e))return{found:!1};let o=i[e];if(typeof o=="string")try{return{found:!0,value:t(o)}}catch{return{found:!0,value:o}}return{found:!0,value:o}}function se(e){let t=ne(e.store),n;try{n=t.getItem(e.key)}catch{return{found:!1}}if(n==null)return{found:!1};try{return{found:!0,value:e.deserialize(n)}}catch{return{found:!1}}}function oe(e,t){let n=ne(e.store);try{n.setItem(e.key,e.serialize(t))}catch{}}function vt(e){let t=ne(e.store);try{t.removeItem(e.key)}catch{}}var D=new Map,Ne=!1;function At(){Ne||!_e()||(Ne=!0,window.addEventListener("storage",e=>{if(e.key===null)return;let t=D.get(e.key);if(t)for(let n of t)n(e.newValue)}))}function ae(e,t){if(!e.sync)return()=>{};let n=D.get(e.key)??new Set;return n.add(t),D.set(e.key,n),At(),()=>{n.delete(t),n.size===0&&D.delete(e.key)}}var y=[],Ie=[],ue=!1,C=new Set,le=[],ce=[],K=!1;function De(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function de(e){if(!e.disposed){e.disposed=!0;for(let t of e.sources)t.delete(e);e.sources.clear();for(let t of e.cleanups)t();e.cleanups.length=0}}function Ht(){for(let n of C)de(n);C.clear();for(let n of le)try{n()}catch{}le.length=0;let e=globalThis,t=e.__krate_island_cleanups;if(Array.isArray(t)){e.__krate_island_cleanups=[];for(let n of t)try{n()}catch{}}ce.length=0,K=!1,Z()}function Et(e,t){return q(h(e))}function yt(e,t){return q(h(e))}function Mt(e,t){let n={};for(let a of e){let[d]=h(!1);n[a]=d}let o=[n,(a,d)=>{}];return o.trigger=a=>({"data-krate-scope":"trigger",value:a}),o.panel=a=>({"data-krate-scope":"panel",value:a}),o.close=()=>({"data-krate-scope":"close"}),o}function Lt(e,t){return q(h(e))}function St(e,t){return q(h(e))}function q(e){let t=e;return t.trigger=n=>({"data-krate-scope":"trigger",value:n}),t.panel=n=>({"data-krate-scope":"panel",value:n}),t.close=()=>({"data-krate-scope":"close"}),t.current=()=>e[0](),t}function xt(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:i=>{},pop:()=>{},clear:()=>{}}]}function h(e,t){let n=e,i=null;if(t?.persist){i=re(t.persist);let c=ie(i.key,i.deserialize);if(c.found)n=c.value;else{let f=se(i);f.found&&(n=f.value)}}let o=new Set,a=()=>{let c=y[y.length-1];return c&&!c.disposed&&(o.add(c),c.sources.add(o)),n},d=()=>{let c=Array.from(o);for(let f of c){if(f.disposed){o.delete(f);continue}if(f.running){f.rerun=!0;continue}f.queued||(f.queued=!0,ce.push(f))}kt()},m=c=>{let f=typeof c=="function"?c(n):c;f!==n&&(n=f,i&&oe(i,n),d())};if(i&&i.sync){let c=i,f=ae(c,H=>{if(H!==null)try{let x=c.deserialize(H);x!==n&&(n=x,d())}catch{}});B(f)}return[a,m]}function kt(){K||(K=!0,queueMicrotask(wt))}function wt(){K=!1;let e=ce.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,F(t),t.rerun&&!t.disposed&&(t.rerun=!1,F(t)))}function F(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,y.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{y.pop(),e.running=!1}}function L(e){let t=De(e);return C.add(t),F(t),()=>{de(t),C.delete(t)}}function B(e){let t=y[y.length-1];t?t.cleanups.push(e):le.push(e)}function Ct(e){Ie.push(e),ue||(ue=!0,queueMicrotask(Pt))}function Pt(){ue=!1;let e=Ie.splice(0);for(let t of e)t()}function Rt(e){let[t,n]=h(void 0),i=De(()=>{let a=e();n(a)});C.add(i),F(i);let o=y[y.length-1];return o&&o.cleanups.push(()=>{i.disposed||(de(i),C.delete(i))}),t}function Ot(e,t){let[n,i]=h(t);return[n,a=>i(d=>e(d,a))]}function Nt(e){return{current:e}}function _t(e){return t=>e(t,t.ref||(()=>{}))}var It={doubleclick:"dblclick",focus:"focusin",blur:"focusout",change:"input"},ge=new WeakMap;function Fe(e,t){let n=ge.get(e);n||(n=[],ge.set(e,n)),n.push(t)}function V(e){let t=ge.get(e);if(t){for(let n of t)n();t.length=0}for(let n=0;n<e.childNodes.length;n++)V(e.childNodes[n])}function Dt(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function qe(e,t){let n=e.parentNode;if(!n)return;let i=e.nextSibling;for(;i&&i!==t;){let o=i.nextSibling;V(i),n.removeChild(i),i=o}}function Kt(e,t,n){let i=Dt(n);i?(qe(n,i),fe(e,t,i)):fe(e,t,null)}function fe(e,t,n){if(!(t==null||t===!1||t===!0)){if(typeof t=="string"||typeof t=="number")e.insertBefore(document.createTextNode(String(t)),n);else if(t instanceof Node)e.insertBefore(t,n);else if(Array.isArray(t))for(let i of t)fe(e,i,n)}}function Ke(e,t,n){if(t==="class"||t==="className")n===!1||n===null||n===void 0?e.className="":e.className=String(n);else if(t==="style")typeof n=="string"?e.setAttribute("style",n):n&&typeof n=="object"&&Object.assign(e.style,n);else if(t.startsWith("on")&&typeof n=="function"){let i=t.slice(2).toLowerCase(),o=It[i]||i,a=`__krate_${o}`,d=e[a];d&&e.removeEventListener(o,d),e.addEventListener(o,n),e[a]=n}else t==="value"||t==="checked"||t==="selected"?t==="value"?e.value=n==null||n===!1?"":n:e[t]=!!n:t==="ref"?typeof n=="function"?n(e):n&&typeof n=="object"&&"current"in n&&(n.current=e):t==="key"||n!=null&&n!==!1&&e.setAttribute(t,String(n))}function Be(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)Be(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),Fe(n,L(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function z(e,t,...n){if(typeof e=="function")return e({...t||{},children:n});let i=document.createElement(e);if(t)for(let[o,a]of Object.entries(t))typeof a=="function"&&!o.startsWith("on")?Fe(i,L(()=>Ke(i,o,a()))):Ke(i,o,a);for(let o of n)Be(i,o);return i}function Ve(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function Ft(e,t){let n=Ve(t),i=!1;L(()=>{i||(i=!0,n.appendChild(e()))})}function qt(e,t){let n=Ve(t);if(n.childNodes.length===0){n.appendChild(e());return}let i=e();i&&V(i)}function Bt(e,t){let[n,i]=h(void 0),[o,a]=h(!0),[d,m]=h(void 0),[c,f]=h("unresolved"),[H,x]=h(0),A,X=()=>typeof e=="function"?e():e,N=async()=>{A&&A.abort(),A=new AbortController;let p=A,G=X();f(H()>0?"refreshing":"loading"),a(!0),m(void 0);try{let M=await t(G,{signal:p.signal});p.signal.aborted||(i(()=>M),f("ready"))}catch(M){M?.name!=="AbortError"&&!p.signal.aborted&&(m(M),f("error"))}finally{p.signal.aborted||a(!1)}};L(()=>{typeof e=="function"&&e.length===0&&e(),H(),N(),B(()=>{A&&(A.abort(),A=void 0)})});let _=function(){return n()};return Object.defineProperties(_,{loading:{get:()=>o()},error:{get:()=>d()},state:{get:()=>c()}}),[_,{mutate:p=>{i(p)},refetch:()=>{x(p=>p+1)}}]}function Vt(e){let t=document.createDocumentFragment(),n=e.children;if(n){let i=Array.isArray(n)?n:[n];for(let o of i)o instanceof Node?t.appendChild(o):t.appendChild(document.createTextNode(String(o)))}return t}function ze(e,t,n){let i=e;if(!t)return z(i,null);let{children:o,...a}=t,d=o!==void 0?Array.isArray(o)?o:[o]:[];return z(i,Object.keys(a).length>0?a:null,...d)}function zt(e,t,n){return ze(e,t,n)}var me=!1,P,U=null,j=0,S=new Map,jt=30,O=new Map,Ut=50,pe=/\/chunks\/runtime\.[^/]+\.js$/;function Ue(){return globalThis.__KRATE_CFG__||{}}function Wt(){let e=Ue().basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function je(e){let t=Wt();if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}var W=null;function he(e,t){if(/^(https?:)?\/\//.test(e)||e.startsWith("/"))return new URL(e,t).href;let n=t;if(!n.endsWith("/")){let i=n.lastIndexOf("/");n=i>0?n.slice(0,i+1):"/"}return new URL(e,n).href}var be=new Set,Xt=128;function We(e,t,n){let i=new DOMParser().parseFromString(e,"text/html"),o=[],a=new Set,d=m=>{if(!m)return;let c;try{c=he(m,t)}catch{return}a.has(c)||n.has(c)||pe.test(c)||(a.add(c),o.push(c))};return i.querySelectorAll("script[src]").forEach(m=>d(m.getAttribute("src"))),i.querySelectorAll('link[rel="modulepreload"][href], link[rel="preload"][as="script"][href]').forEach(m=>d(m.getAttribute("href"))),o}function Gt(e,t={}){return W?(W(e,t),!1):(typeof location<"u"&&(location.href=e),!0)}function Xe(){if(typeof document>"u"||me)return;me=!0;let e="#root, main, .docs-content",t=150,n=200,i=null,o=null,a=new Map,d=null;function m(r){for(let s of e.split(", ")){let u=r.querySelector(s.trim());if(u)return u}return r.body}function c(r){if(r.hasAttribute("data-krate-external"))return!1;let s=r.getAttribute("href");return!(!s||s.startsWith("#")||s.startsWith("javascript:")||r.origin!==location.origin||r.target==="_blank")}function f(r){let s=window.requestIdleCallback;typeof s=="function"?s(r,{timeout:1e3}):setTimeout(r,50)}function H(r){let s=r.getAttribute("data-prefetch");return r.hasAttribute("data-prefetch")&&s!=="false"&&s!=="0"}function x(r){if(be.has(r)||be.size>=Xt)return;be.add(r);let s=document.createElement("link");s.rel="prefetch",s.as="script",s.href=r,document.head.appendChild(s)}function A(r){S.has(r)||fetch(r,{headers:{Accept:"text/html"}}).then(s=>s.ok?s.text():null).then(s=>{if(!s)return;if(S.size>=jt){let l=S.keys().next().value;l!==void 0&&S.delete(l)}S.set(r,s);let u=new Set;document.querySelectorAll("script[src]").forEach(l=>u.add(l.src));for(let l of We(s,r,u))x(l)}).catch(()=>{})}function X(){document.addEventListener("mouseover",R),document.addEventListener("focusin",R),typeof IntersectionObserver<"u"&&(d=new IntersectionObserver(r=>{for(let s of r)if(s.isIntersecting){let u=s.target,l=u.getAttribute("href");if(l&&c(u)&&H(u)){let g=new URL(l,location.origin).href;f(()=>A(g))}d.unobserve(s.target)}},{rootMargin:"200px"}),N())}function N(){d&&document.querySelectorAll("a[data-prefetch]").forEach(r=>{H(r)&&d.observe(r)})}function _(){document.removeEventListener("mouseover",R),document.removeEventListener("focusin",R);for(let r of a.values())clearTimeout(r);a.clear(),d&&(d.disconnect(),d=null)}function R(r){let s=r.target.closest("a[data-prefetch]");if(!s||!H(s)||!c(s))return;let u=s.getAttribute("href");if(!u)return;let l=new URL(u,location.origin).href;if(S.has(l))return;let g=a.get(s);g&&clearTimeout(g);let b=setTimeout(()=>{a.delete(s),A(l)},n);a.set(s,b)}let p=null;function G(){if(J())return;let r=m(document),s=document.querySelector("template[data-krate-loading]");s&&s.content&&r&&(p=s.content.cloneNode(!0),document.body.appendChild(p)),r&&(r.style.transition=`opacity ${t}ms ease`,r.style.opacity="0")}function M(){if(J())return;p&&p.parentNode&&p.parentNode.removeChild(p),p=null;let r=m(document);r&&(r.style.opacity="1")}function He(r){try{let s=globalThis.__krate_onNavigation;typeof s=="function"&&s(r)}catch{}}function Ee(r,s){try{window.dispatchEvent(new CustomEvent(r,{detail:{url:s}}))}catch{}}function J(){if(Ue().viewTransitions===!1)return!1;if(typeof window<"u"&&window.matchMedia)try{if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return!1}catch{}return typeof document.startViewTransition=="function"}function Ye(r){let s=r.querySelectorAll('link[rel="stylesheet"]'),u=new Set;s.forEach(g=>{let b=g.getAttribute("href");b&&u.add(new URL(b,location.origin).href)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(g=>{let b=g.href;b&&!u.has(b)&&g.remove()});let l=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(g=>l.add(g.href)),s.forEach(g=>{let b=g.getAttribute("href");if(!b)return;let T=new URL(b,location.origin).href;if(!l.has(T)){let E=document.createElement("link");E.rel="stylesheet",E.href=T,document.head.appendChild(E)}})}function ye(r){r.querySelectorAll("[data-view-transition]").forEach(s=>{let u=s.getAttribute("data-view-transition");u&&(s.style.viewTransitionName=u)})}function $e(){let r=m(document);if(r){r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1");try{r.focus({preventScroll:!0})}catch{try{r.focus()}catch{}}}}function Qe(){let r=HTMLScriptElement.supports;if(!(typeof r!="function"||!r("speculationrules")))try{let s=document.createElement("script");s.type="speculationrules",s.textContent=JSON.stringify({prefetch:[{where:{and:[{href_matches:"/*"},{not:{href_matches:"/__krate/*"}},{not:{href_matches:"/api/*"}}]},eagerness:"moderate"}]}),document.head.appendChild(s)}catch{}}function Me(r){return r.getElementById("root")||r.body}let Le='meta[name="description"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function Ze(r){document.head.querySelectorAll(Le).forEach(s=>s.remove()),r.head.querySelectorAll(Le).forEach(s=>{document.head.appendChild(document.importNode(s,!0))})}function Se(r,s,u,l={}){let{replace:g=!1,scroll:b=!0,restoreScroll:T=!1}=l,k=new DOMParser().parseFromString(r,"text/html"),Re=Me(k),Oe=Me(document);if(!Re||!Oe){location.href=s;return}Ee("krate:navigate-start",s);let $=()=>{let v=k.querySelector("title");v&&(document.title=v.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll();let I=Array.from(Re.childNodes).map(ut=>document.importNode(ut,!0));Oe.replaceChildren(...I),Ye(k),Ze(k),ye(document)};if(J())try{let v=document.startViewTransition($);v&&v.finished&&typeof v.finished.catch=="function"&&v.finished.catch(()=>{})}catch{$()}else $();tt(u,s).then(()=>{try{rt(),N()}catch(v){try{let I=globalThis.__krate_onHydrationError;typeof I=="function"&&I(v)}catch{}location.href=s}}),M();let at=location.pathname+location.search;if(g)history.replaceState({},"",s);else{if(!T){if(O.size>=Ut){let v=O.keys().next().value;v!==void 0&&O.delete(v)}O.set(at,window.scrollY)}history.pushState({},"",s)}xe(s,{restoreScroll:T,scroll:b}),T||$e(),ke(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:s}})),Ee("krate:navigate-end",s),He(s)}function et(r){let s=r.indexOf("#");if(s<0||s===r.length-1)return!1;let u=r.slice(s);try{let l=document.querySelector(u);if(l)return l.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch{return!1}return!1}function xe(r,s){if(s.restoreScroll){let u=O.get(r);if(u!==void 0){window.scrollTo(0,u);return}}et(r)||s.scroll&&window.scrollTo(0,0)}function ke(){let r=je(location.pathname);document.querySelectorAll("a[data-krate-link]").forEach(s=>{let u=s.getAttribute("href");if(!u){s.removeAttribute("aria-current");return}let l=u;try{l=je(new URL(u,location.origin).pathname)}catch{return}l===r||r==="/"&&(l===""||l==="/")||l!=="/"&&l.length>1&&r.startsWith(l)?s.setAttribute("aria-current","page"):s.removeAttribute("aria-current")})}function tt(r,s){return r.length===0?Promise.resolve():Promise.all(r.map(u=>{let l=u.getAttribute("src");return l?nt(l,s):Promise.resolve()})).then(()=>{})}function nt(r,s){return new Promise(u=>{let l=document.createElement("script"),g=he(r,s);l.src=g,pe.test(g)||l.setAttribute("data-krate-spa",""),l.onload=()=>u(),l.onerror=()=>u(),document.body.appendChild(l)})}function rt(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function it(r,s){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",s),He(s),document.open(),document.write(r),document.close()}function st(){return i!==null?Promise.resolve(i):fetch("/404.html",{headers:{Accept:"text/html"}}).then(r=>r.ok?r.text():null).then(r=>(i=r,r)).catch(()=>null)}function ot(){return o!==null?Promise.resolve(o):fetch("/500.html",{headers:{Accept:"text/html"}}).then(r=>r.ok?r.text():null).then(r=>(o=r,r)).catch(()=>null)}function we(r,s){document.querySelectorAll("script[data-krate-spa]").forEach(g=>g.remove());let u=[],l=new Set;return document.querySelectorAll("script[src]").forEach(g=>{l.add(g.src)}),r.querySelectorAll("script[src]").forEach(g=>{let b=g.getAttribute("src");b&&!l.has(he(b,s))&&u.push(g)}),u}function Y(r,s={}){let u=++j,l=S.get(r);if(l){let T=new DOMParser().parseFromString(l,"text/html");Se(l,r,we(T,r),s);return}G(),P&&P.abort(),P=new AbortController;let g=P.signal;fetch(r,{headers:{Accept:"text/html"},signal:g}).then(b=>{if(u===j)return b.ok?b.text().then(T=>{if(u!==j)return;let k=new DOMParser().parseFromString(T,"text/html");Se(T,r,we(k,r),s)}):(b.status>=500?ot():st()).then(E=>{u===j&&(E?it(E,r):location.href=r)})}).catch(b=>{b?.name!=="AbortError"&&(M(),location.href=r)}).finally(()=>{P&&!g.aborted&&(P=void 0)})}let Ce=r=>{if(r.defaultPrevented||r.button!==0||r.metaKey||r.ctrlKey||r.shiftKey||r.altKey)return;let s=r.target.closest("a[data-krate-link]");if(!s||!c(s))return;r.preventDefault();let u=s.getAttribute("href");if(!u)return;let l=new URL(u,location.origin).href,g=s.hasAttribute("data-krate-replace"),b=s.getAttribute("data-krate-scroll")!=="false";if(u===location.pathname+location.search+location.hash){g&&history.replaceState({},"",u),xe(l,{scroll:b});return}Y(l,{replace:g,scroll:b})},Pe=()=>{Y(location.href,{restoreScroll:!0})};document.addEventListener("click",Ce),window.addEventListener("popstate",Pe),X(),Qe(),ke(),ye(document),W=(r,s={})=>{let u=!0;try{u=new URL(r,location.href).origin===location.origin}catch{u=!1}if(!u){location.href=r;return}Y(new URL(r,location.href).href,s)},document.querySelectorAll("script[src]").forEach(r=>{pe.test(r.src)||r.setAttribute("data-krate-spa","")}),U=()=>{document.removeEventListener("click",Ce),window.removeEventListener("popstate",Pe),_(),W=null}}function Jt(){U&&(U(),U=null),me=!1,Xe()}function Te(e,t){if(!(e==null||e===!1||e===!0||e==="")){if(typeof e=="string"||typeof e=="number"){t.push(String(e));return}if(Array.isArray(e)){for(let n of e)Te(n,t);return}if(typeof e=="object")for(let n of Object.keys(e))e[n]&&t.push(n)}}function ve(...e){let t=[];for(let n of e)Te(n,t);return t.join(" ")}function Ae(...e){let t=[];for(let o of e)Te(o,t);let n=new Map,i=[];for(let o of t){let a=Yt(o);n.has(a)||i.push(a),n.set(a,o)}return i.map(o=>n.get(o)).join(" ")}function Yt(e){let t=e,n="",i=t.lastIndexOf(":");i>=0&&(n=t.slice(0,i+1),t=t.slice(i+1));let o=t.indexOf("-"),a=o>=0?t.slice(0,o):t,d=o>=0?t.slice(o+1,o+2):"";return n+a+(d&&/[0-9]/.test(d)?"-"+d:"")}function $t(...e){return Ae(ve(...e))}function Qt(e,t){let n=t?.variants??{},i=t?.defaultVariants??{};return o=>{let a={};for(let c of Object.keys(n)){let f=o?.[c]??i[c];f!=null&&(a[c]=String(f))}let d=[e];for(let c of Object.keys(n)){let f=a[c];f&&n[c][f]&&d.push(n[c][f])}for(let c of t?.compoundVariants??[])if(Zt(c,a,i)){let f=c.class;typeof f=="string"&&d.push(f)}let m=o?.class??o?.className;return typeof m=="string"&&d.push(m),Ae(ve(d))}}function Zt(e,t,n){for(let i of Object.keys(e)){if(i==="class")continue;let o=e[i],a=t[i]??n[i]??void 0;if(Array.isArray(o)){if(!o.includes(a))return!1}else if(o!==a)return!1}return!0}function en(e){let t=Ge(e?.children);return t?(Je(t,e),t):null}function Ge(e){if(e==null)return null;if(Array.isArray(e)){for(let t of e){let n=Ge(t);if(n)return n}return null}return e instanceof Node?e:null}function Je(e,t){if(e instanceof Element)for(let n of Object.keys(t)){if(n==="children"||n==="ref")continue;let i=t[n];if(!(i==null||i===!1)){if(n==="class"||n==="className"){let o=e.getAttribute("class"),a=o?o+" "+String(i):String(i);e.setAttribute("class",a);continue}if(n==="style"&&typeof i=="object"){for(let[o,a]of Object.entries(i))e.style.setProperty(tn(o),String(a));continue}if(n.startsWith("on")&&typeof i=="function"){e[n]=i;continue}if(i===!0){e.setAttribute(n,"");continue}e.setAttribute(n,String(i))}}}function tn(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function nn(e,t,...n){if(!(e instanceof Node))return e;if(t&&Je(e,t),n.length>0&&e instanceof Element){e.textContent="";for(let i of n)i instanceof Node?e.appendChild(i):i!=null&&e.appendChild(document.createTextNode(String(i)))}return e}return bt(rn);})();
1
+ var __krate_exports=(()=>{var En=Object.defineProperty;var Ls=Object.getOwnPropertyDescriptor;var Ms=Object.getOwnPropertyNames;var Rs=Object.prototype.hasOwnProperty;var Os=(e,t)=>{for(var n in t)En(e,n,{get:t[n],enumerable:!0})},Ps=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ms(t))!Rs.call(e,o)&&o!==n&&En(e,o,{get:()=>t[o],enumerable:!(r=Ls(t,o))||r.enumerable});return e};var _s=e=>Ps(En({},"__esModule",{value:!0}),e);var ec={};Os(ec,{ACTION_ARGS_FIELD:()=>oo,BLOCKED_URL:()=>ai,Fragment:()=>Hu,KRATE_CONTEXT:()=>fo,ServerActionError:()=>bt,Slot:()=>fl,__krateAction:()=>Kl,__krateActionState:()=>Yl,__krateAssignRef:()=>Wl,__krateBeginAction:()=>ao,__krateBindFormAction:()=>Gl,__krateClass:()=>ys,__krateClassError:()=>_l,__krateCondPost:()=>El,__krateCondPre:()=>Tl,__krateFormStatusMount:()=>Vl,__krateOnError:()=>Sl,__krateOptimistic:()=>Zl,__krateOwn:()=>kl,__krateOwner:()=>wl,adoptValue:()=>Fe,afterFlush:()=>Gs,appendChild:()=>he,callServerAction:()=>so,clearBetween:()=>xr,clearNodes:()=>di,clearPersisted:()=>js,cloneElement:()=>gl,clsx:()=>Gr,cn:()=>ll,compareRouteSpecificity:()=>Xi,componentStack:()=>fs,createCSSChoice:()=>Ys,createCSSFlags:()=>ea,createCSSGroup:()=>ta,createCSSRange:()=>na,createCSSStack:()=>ra,createCSSToggle:()=>Zs,createCallbackDeps:()=>xa,createContext:()=>xn,createEffect:()=>S,createEffectDeps:()=>wa,createMemo:()=>ca,createMemoDeps:()=>Uo,createOwner:()=>hl,createReducer:()=>da,createResource:()=>Au,createRoot:()=>Zn,createScope:()=>Is,createScopeFlags:()=>Fs,createSignal:()=>H,cva:()=>cl,destroyRouter:()=>al,disposeAll:()=>To,disposeNode:()=>B,flushPassive:()=>Pe,forwardRef:()=>pa,getFormStatus:()=>zl,getHistoryState:()=>Iu,getNavigationState:()=>Di,getOwner:()=>mn,h:()=>Yt,handleError:()=>q,hydrate:()=>pu,inCommitPhaseError:()=>eo,initRouter:()=>us,insert:()=>ru,insertAt:()=>Z,installActionForms:()=>Cs,invalidatePrefetchCache:()=>Dr,isActionPending:()=>Ul,isDerivedGetter:()=>xo,isServerAction:()=>Il,isSignalGetter:()=>sa,jsx:()=>Ci,jsxs:()=>Cu,krateApplyStyle:()=>fi,krateAttachRef:()=>nt,krateBindList:()=>Su,krateBindRef:()=>tu,krateCommitSnapshot:()=>bo,krateCommitting:()=>Ae,krateCondActivity:()=>ka,krateCondDetached:()=>Ja,krateCondReset:()=>Qa,krateCondSwap:()=>Ya,krateControl:()=>zt,krateCurrentScope:()=>ae,krateDepsOf:()=>Aa,krateDerived:()=>oa,krateDisposeExcept:()=>Js,krateDisposeOwner:()=>Ye,krateDisposeScopes:()=>Qs,krateEnterScope:()=>Bs,krateEpoch:()=>Ht,krateEventName:()=>hr,krateEventRoot:()=>Bt,krateFlushSync:()=>Rt,krateForgetOwner:()=>or,krateGetOwner:()=>He,krateHook:()=>ia,krateHookState:()=>Us,krateIsDiscrete:()=>qs,krateKeepScopes:()=>Ws,krateLeaveScope:()=>Vs,krateList:()=>xu,krateMount:()=>va,krateMountFields:()=>Wt,krateMountPortals:()=>Ga,krateOn:()=>Vt,krateOnAfterFlush:()=>Wn,krateOnBeforeFlush:()=>Vn,krateOnDispose:()=>zn,krateOnHookError:()=>ir,krateOnLayoutCommit:()=>sr,krateOnSettle:()=>Qn,krateOnUnmount:()=>ma,krateOwner:()=>ba,krateOwnerId:()=>ha,kratePendingFlush:()=>qn,kratePortalFind:()=>$a,kratePortalMount:()=>vr,kratePortalReset:()=>Xa,kratePortalScan:()=>oi,kratePortalTarget:()=>Wa,kratePortalUnmount:()=>$t,kratePortalsEnter:()=>wr,kratePortalsIn:()=>kr,kratePortalsLeave:()=>Tr,kratePruneSnapshots:()=>Dn,krateReadAt:()=>Ct,krateRefsEnter:()=>jt,krateRefsFlush:()=>lr,krateRefsHold:()=>Vo,krateRefsLeave:()=>Dt,krateRenderPhase:()=>Fn,krateRequestFlush:()=>Mt,krateRouter:()=>ol,krateRunEvent:()=>xe,krateSanitizeAttr:()=>Er,krateScopeOfId:()=>Gn,krateSetControl:()=>pe,krateSetOwner:()=>I,krateSetRef:()=>Ft,krateSlotReplaced:()=>ya,krateSynthetic:()=>Ut,krateTagOwner:()=>Je,krateTakeSyncLane:()=>Un,krateTrackNode:()=>Xt,krateTransitionWrites:()=>ce,krateUnmount:()=>Y,krateWithOwner:()=>et,longestIncreasingSubsequence:()=>Ai,matchRoutePattern:()=>$i,mount:()=>fu,mountClassElement:()=>Pl,mountOwner:()=>Yr,navigate:()=>il,onCleanup:()=>P,onMount:()=>ua,onOwnerCleanup:()=>hn,pageAssetURLs:()=>Ii,readDurableState:()=>Ln,readPersisted:()=>Mn,reinitRouter:()=>sl,remountChildren:()=>vn,removeRest:()=>Qt,reportActionError:()=>lo,requestFormReset:()=>ql,resetContexts:()=>yt,resolvePersist:()=>Cn,runActionTransition:()=>uo,runAfterFlush:()=>Ze,runWithOwner:()=>Ve,sameValue:()=>Xs,setActionTransitionRunner:()=>Bl,setBoundary:()=>Qr,setOwnerHooks:()=>In,submitFormAction:()=>Hs,subscribeNavigation:()=>ji,subscribePersist:()=>On,trackEffect:()=>_,twMerge:()=>$r,unmountChildren:()=>Zr,unmountOwner:()=>bn,untrack:()=>E,useRef:()=>fa,withDOM:()=>me,withVNodes:()=>Jt,writePersisted:()=>Rn});var Ns=0,fo=Symbol.for("krate.context");function Sn(e){if(e instanceof Node)return e;let t=document.createDocumentFragment();if(Array.isArray(e))for(let n of e)t.appendChild(Sn(n));else e!=null&&e!==!1&&e!==!0&&t.appendChild(document.createTextNode(String(e)));return t}var we=new Map;function yt(){for(let[e,t]of we)if(t.length>0){let n=t[0];we.set(e,[n])}}function Is(){return xn({})}function Fs(){return xn({})}function xn(e){let t=Ns++;we.set(t,[e]);let n=()=>{let s=we.get(t);return s&&s.length>0?s[s.length-1]:e},r=s=>{let a=we.get(t)||[e];a.push(s.value),we.set(t,a);let u=document.createElement("div");u.style.display="contents";let l=s.children;if(l)for(let c of Array.isArray(l)?l:[l])c instanceof Node?u.appendChild(c):c!=null&&u.appendChild(document.createTextNode(String(c)));return a.pop(),a.length===0&&a.push(e),u},o=s=>{let a=s.children;return Array.isArray(a)&&(a=a.find(u=>typeof u=="function")),Sn(typeof a=="function"?a(n()):null)},i=(s=>r(s));return i.$$typeof=fo,i.id=t,i.defaultValue=e,i.Provider=r,i.Consumer=o,i.useContext=n,i.use=n,i}function Ds(){let e=new Map;return{getItem:t=>e.has(t)?e.get(t):null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}var An=Ds();function go(){return typeof window<"u"}function Hn(e){if(e&&typeof e=="object")return e;if(!go())return An;try{return e==="session"?window.sessionStorage:e==="memory"?An:window.localStorage}catch{return An}}function Cn(e){let t=typeof e=="string"?{key:e}:e;if(!t.key)throw new Error("[krate] createSignal persist requires a key");let n=t.store??"local";return{key:t.key,store:n,serialize:t.serialize??(r=>JSON.stringify(r)),deserialize:t.deserialize??(r=>JSON.parse(r)),sync:t.sync??n==="local"}}function Ln(e,t){let r=globalThis.__KRATE_STATE__;if(!r||!Object.prototype.hasOwnProperty.call(r,e))return{found:!1};let o=r[e];if(typeof o=="string")try{return{found:!0,value:t(o)}}catch{return{found:!0,value:o}}return{found:!0,value:o}}function Mn(e){let t=Hn(e.store),n;try{n=t.getItem(e.key)}catch{return{found:!1}}if(n==null)return{found:!1};try{return{found:!0,value:e.deserialize(n)}}catch{return{found:!1}}}function Rn(e,t){let n=Hn(e.store);try{n.setItem(e.key,e.serialize(t))}catch{}}function js(e){let t=Hn(e.store);try{t.removeItem(e.key)}catch{}}var kt=new Map,po=!1;function Ks(){po||!go()||(po=!0,window.addEventListener("storage",e=>{if(e.key===null)return;let t=kt.get(e.key);if(t)for(let n of t)n(e.newValue)}))}function On(e,t){if(!e.sync)return()=>{};let n=kt.get(e.key)??new Set;return n.add(t),kt.set(e.key,n),Ks(),()=>{n.delete(t),n.size===0&&kt.delete(e.key)}}var Us={react:!0},T=[],mo=[],_n=!1,L=null;function In(e){L=e}var Et=[],K=new Set,qe=[],Te=null,ho=new Set,se=new Map;function Bs(e){return ho.has(e)?!1:(Te=e,A=null,!0)}function Vs(){Te=null,A=null}function ae(){let e=T[T.length-1];return e?e.scope:Te!==null?Te:A!==null&&se.has(A)?se.get(A)??null:null}function Ws(e){ho=new Set(e)}function Je(e,t){e!==null&&!se.has(e)&&se.set(e,t)}var j=[],St=!1;function Qe(e){let t=ae(),n={fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1,owner:A,boundaryOwner:L?L.current():null,scope:t};if(A!==null){Je(A,t);let r=ue.get(A);r||ue.set(A,r=new Set),r.add(n)}return n}var ue=new Map,Ee=new Map;function Ye(e){let t=ue.get(e);if(ue.delete(e),t)for(let r of t)Ce(r),K.delete(r);let n=Ee.get(e);if(Ee.delete(e),se.delete(e),n)for(let r of n)try{r()}catch{}}var le=0,M=null,wt=0,Se=new Set,Ge=new Set;function Fn(e){le++;let t=M;M=null;try{return e()}finally{M=t,le--}}function bo(){wt++;for(let e of Se)e.commit(wt);return Se.clear(),wt}function Ht(){return wt}function Ct(e,t){let n=M;M=e;try{return t()}finally{M=n}}function Dn(e){for(let t of Ge)t.prune(e)||Ge.delete(t)}var jn=new Set("auxclick beforeinput blur cancel change click close compositionend compositionstart compositionupdate contextmenu copy cut dblclick dragend dragstart drop focusin focusout input invalid keydown keypress keyup mousedown mouseup paste pause play pointercancel pointerdown pointerup ratechange reset resize seeked select submit touchcancel touchend touchstart volumechange focus".split(" ")),Kn=0,$e=!1,Tt=0;function zs(){if(Tt>0)return!0;let e=typeof window<"u"?window.event:void 0;return!!e&&jn.has(e.type)}var xt=0;function ce(e){xt++;try{return e()}finally{xt--}}function qs(e){return jn.has(e)}function xe(e,t,n){if(!jn.has(e)){n();return}Tt++;try{n()}finally{Tt--,t&&Tt===0&&Nn===0&&Kn===0&&(j.length>0||$e)&&Rt()}}function Ae(e){Kn+=e?1:-1}function Un(){let e=$e;return $e=!1,e}function vo(){return T[T.length-1]||null}var A=null;function He(){return A}function I(e){let t=A;return A=e,t}var yo=[],ko=[],Bn=[];function Vn(e){yo.push(e)}function Wn(e){ko.push(e)}function zn(e){Bn.push(e)}function qn(){return j.length>0}function E(e){T.push(null);try{return e()}finally{T.pop()}}function Gs(e){Et.push(e),Xn()}function $s(){if(Et.length===0)return;let e=Et.splice(0);for(let t of e)t()}function Xs(e,t){return Object.is(e,t)}function Ce(e){if(!e.disposed){e.disposed=!0,e.owner!==null&&ue.get(e.owner)?.delete(e);for(let t of e.sources)t.delete(e);e.sources.clear();for(let t of e.cleanups)t();e.cleanups.length=0}}function Js(e){if(e.length===0){To();return}let t=new Set(e);wo(n=>!(n!=null&&t.has(n)),!0)}function Qs(e){if(e.length===0)return;let t=new Set(e);wo(n=>n!=null&&t.has(n),!1)}function Gn(e){if(e.charCodeAt(0)!==95)return null;let t=e.indexOf("_",1);return t>0?e.slice(0,t+1):null}function wo(e,t){for(let s of Bn)try{s(e)}catch{}for(let s of Array.from(K))e(s.scope)&&(Ce(s),K.delete(s));let n=[];for(let s of qe.splice(0)){if(!e(s.scope)){n.push(s);continue}try{s.fn()}catch{}}qe.push(...n);let r=new Set([...Ee.keys(),...ue.keys()]);for(let s of r)e(se.get(s)??null)&&Ye(s);if(!t)return;let o=globalThis,i=o.__krate_island_cleanups;if(Array.isArray(i)){o.__krate_island_cleanups=[];for(let s of i)try{s()}catch{}}Te=null,yt()}function To(){Te=null;for(let n of Bn)try{n(null)}catch{}for(let n of K)Ce(n);K.clear();for(let n of qe)try{n.fn()}catch{}qe.length=0;for(let n of Array.from(Ee.keys()))Ye(n);ue.clear(),se.clear(),Se.clear(),Ge.clear(),M=null;let e=globalThis,t=e.__krate_island_cleanups;if(Array.isArray(t)){e.__krate_island_cleanups=[];for(let n of t)try{n()}catch{}}j.length=0,Et.length=0,St=!1,ie=0,Xe++,$e=!1,yt()}function Ys(e,t){return Lt(H(e))}function Zs(e,t){return Lt(H(e))}function ea(e,t){let n={};for(let i of e){let[s]=H(!1);n[i]=s}let o=[n,(i,s)=>{}];return o.trigger=i=>({"data-krate-scope":"trigger",value:i}),o.panel=i=>({"data-krate-scope":"panel",value:i}),o.close=()=>({"data-krate-scope":"close"}),o}function ta(e,t){return Lt(H(e))}function na(e,t){return Lt(H(e))}function Lt(e){let t=e;return t.trigger=n=>({"data-krate-scope":"trigger",value:n}),t.panel=n=>({"data-krate-scope":"panel",value:n}),t.close=()=>({"data-krate-scope":"close"}),t.current=()=>e[0](),t}function ra(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:r=>{},pop:()=>{},clear:()=>{}}]}function H(e,t){let n=e,r=null;if(t?.persist){r=Cn(t.persist);let f=Ln(r.key,r.deserialize);if(f.found)n=f.value;else{let m=Mn(r);m.found&&(n=m.value)}}let o=new Set,i=!!t?.react,s=n,a=null,u=i?{commit(f){Object.is(s,n)||(a||(a=[[0,s]]),a.push([f,n]),s=n,Ge.add(u))},prune(f){if(!a)return!1;for(;a.length>1&&a[1][0]<=f;)a.shift();return a.length===1?(a=null,!1):!0}}:null,l=f=>{if(!a)return s;for(let m=a.length-1;m>=0;m--)if(a[m][0]<=f)return a[m][1];return a[0][1]},c=()=>{let f=T[T.length-1];if(f&&!f.disposed&&(o.add(f),f.sources.add(o)),i){if(M!==null)return l(M);if(le===0)return s}return n},g=(f=!1)=>Eo(o,f),d=f=>{let m=typeof f=="function"?f(n):f;Object.is(m,n)||(n=m,r&&Rn(r,n),u&&Se.add(u),g(i))};if(r&&r.sync){let f=r,m=On(f,k=>{if(k!==null)try{let v=f.deserialize(k);Object.is(v,n)||(n=v,g())}catch{}});P(m)}return $n.add(c),[c,d]}function Eo(e,t=!1){let n=Array.from(e);for(let r of n){if(r.disposed){e.delete(r);continue}if(r.mark){r.mark(t);continue}if(r.running){r.rerun=!0;continue}r.queued||(r.queued=!0,j.push(r))}Xn(t)}var So=new WeakSet;function oa(e,t){let n,r=!0,o=new Set,i=Qe(()=>{});i.mark=u=>{r||(r=!0,Eo(o,u))},K.add(i);let s=()=>{let u=T[T.length-1];if(u&&!u.disposed&&(o.add(u),u.sources.add(o)),(le===0||M!==null)&&(Se.size>0||M!==null&&Ge.size>0))return E(e);if(r&&!i.disposed){for(let l of i.sources)l.delete(i);i.sources.clear(),r=!1,T.push(i);try{t&&t(),n=e()}catch(l){throw r=!0,l}finally{T.pop()}}else if(i.disposed)return E(e);return n},a=T[T.length-1];return a&&a.cleanups.push(()=>{Ce(i),K.delete(i)}),So.add(s),$n.add(s),s}function xo(e){return typeof e=="function"&&So.has(e)}function ia(e){return xo(e)?e:()=>e}var $n=new WeakSet;function sa(e){return typeof e=="function"&&$n.has(e)}var ie=0,Xe=0;function Xn(e=!1){let t=xt===0&&zs();t&&($e=!0);let r=!(e||xt>0)||t||Kn>0||le>0||typeof setTimeout!="function";if(ie===1||!r&&ie===2)return;St=!0;let o=++Xe,i=()=>{o===Xe&&Jn()};r?(ie=1,queueMicrotask(i)):(ie=2,setTimeout(i,0))}var Nn=0;function Jn(){Nn++;try{aa()}finally{Nn--}}function aa(){St=!1,ie=0,Xe++;for(let e of yo)e();for(let e=0;j.length>0&&e<100;e++){let t=j.splice(0);for(let n of t)n.disposed||(n.queued=!1,n.rerun=!1,At(n),n.rerun&&!n.disposed&&(n.rerun=!1,At(n)))}if(j.length===0&&(ie=0,St=!1,Xe++),j.length===0){for(let e of Ao)e();if(j.length>0&&Pn<50){Pn++;try{Jn()}finally{Pn--}return}Ze()}}var Ao=[],Pn=0;function Qn(e){Ao.push(e)}function Mt(){Xn()}function Ze(){Se.size>0&&bo(),typeof document<"u"&&document.activeElement;for(let e of ko)e();$s()}function Rt(){if(j.length===0){Ze();return}let e=0;for(;j.length>0&&e++<100;)Jn()}function At(e){e.running=!0;let t=!1,n=A;A=e.owner,le++;let r=M;M=null;try{for(let i of e.cleanups.splice(0))i();T.push(e),t=!0;let o=e.fn();typeof o=="function"&&e.cleanups.push(o)}catch(o){if(!(e.boundaryOwner&&L&&L.error(e.boundaryOwner,o)))throw o}finally{M=r,le--,A=n,t&&T.pop(),e.running=!1}}function S(e){let t=Qe(e);K.add(t);let n=T[T.length-1],r=()=>{Ce(t),K.delete(t)};return t.boundaryOwner&&L&&L.cleanup(t.boundaryOwner,r),At(t),n&&n.root&&Yn(n,r),r}function P(e){let t=vo();if(t){Yn(t,e);return}let n=L?L.current():null;if(n&&L)L.cleanup(n,e);else if(A!==null){Je(A,ae());let r=Ee.get(A);r||Ee.set(A,r=[]),r.push(e)}else qe.push({fn:e,scope:ae()})}function Yn(e,t){if(e.dead){t();return}e.cleanups.push(t)}function Zn(e){let t=Qe(()=>{});t.disposed=!0,t.root=!0;let n=()=>{if(t.dead)return;t.dead=!0;let r=t.cleanups.splice(0);for(let o of r)try{o()}catch(i){console.error(i)}};T.push(t);try{return e(n)}finally{T.pop()}}function ua(e){mo.push({fn:e,owner:T[T.length-1],boundary:L?L.current():null}),_n||(_n=!0,queueMicrotask(la))}function la(){_n=!1;let e=mo.splice(0);for(let{fn:t,owner:n,boundary:r}of e){let o=()=>{if(!n){t();return}if(n.dead||!n.root&&n.disposed)return;let i=Qe(()=>{});i.disposed=!0,T.push(i);try{t()}finally{T.pop()}for(let s of i.cleanups)Yn(n,s)};r&&L?L.run(r,o):o()}}function ca(e){let[t,n]=H(void 0),r=Qe(()=>{let s=e();n(s)});K.add(r),At(r);let o=vo(),i=()=>{r.disposed||(Ce(r),K.delete(r))};return o?o.cleanups.push(i):r.boundaryOwner&&L&&L.cleanup(r.boundaryOwner,i),t}function da(e,t,n,r){n&&typeof n=="object"&&(r=n,n=void 0);let o=typeof n=="function"?n(t):t,[i,s]=H(o,r);return[i,u=>s(l=>e(l,u))]}function fa(e){return{current:e}}function pa(e){return t=>e(t,t.ref||(()=>{}))}var C=Pt(null,null),F=new Map,U=new Map,fe=new Set,W=new Set,ga=0,Ot=!1,J=null,Q=[],de=[],Le=[],Me=new Map,Lo=[];function Pt(e,t){let n=t&&t.parent!==null?t.scope:t?ae():null,r={id:e,parent:t,children:[],hooks:[],disposed:!1,shown:!0,conds:[],slot:null,record:null,scope:n};return t&&Je(r,n),r}function ma(e){Lo.push(e)}function ha(e){return _t(e).id}function _t(e){return e&&typeof e=="object"&&"hooks"in e?e:C}function Re(e){for(let t=e;t;t=t.parent)if(t.disposed||!t.shown)return!1;return!0}function Mo(e){for(let[t,n]of e.conds){let r=U.get(t);if(r!==void 0&&r!==n)return!1}return!0}function ba(e,t,n,r){if(e==null){I(null);return}let o=F.get(e);if(!o){let i=t!=null&&F.get(t)||C;o=Pt(e,i);for(let s=i;s;s=s.parent)s.disposed&&(o.disposed=!0);i.children.push(o),F.set(e,o);for(let[s,a,u]of n||[])o.conds.push([s,a]),U.has(s)||U.set(s,u?a:a==="c"?"a":"c");o.shown=Mo(o),r&&(o.slot=r,fe.has(r)&&(o.disposed=!0))}I(o)}function et(e){let t=_t(He()),n=Pt(null,t);t.children.push(n);let r=I(n);try{return{value:e(),owner:n}}finally{I(r)}}function Y(e){let t=_t(e);if(t===C||t.disposed)return;let n=Re(t),r=[];if(Nt(t,n,r),t.parent){let o=t.parent.children,i=o.indexOf(t);i>=0&&o.splice(i,1)}r.length&&(Q.push(...r),ar())}function Nt(e,t,n){e.disposed=!0;for(let r of e.hooks){if(r.stop(),W.delete(r),!t){r.mounted&&(r.mounted=!1,r.cleanup=null,rr(r.epoch));continue}if(r.phase==="passive"){let o=_e(r);o&&n.push(o)}else Oe(r)}for(let r of Lo)r(e,e.id);Ye(e),e.record&&e.record.owner===e&&(e.record.owner=null);for(let r of e.children.slice())Nt(r,t&&r.shown,n)}function or(e){let t=F.get(e);t&&(Y(t),F.delete(e))}function va(e,t,n,r,o){let i={id:e,parentId:t,conds:[],slot:r||null,fn:o,owner:null};for(let[s,a,u]of n||[])i.conds.push([s,a]),U.has(s)||U.set(s,u?a:a==="c"?"a":"c");Le.push(i),er(i)&&Oo(i)}function Ro(e){if(e.parentId==null)return C;let t=F.get(e.parentId);if(!t)return C;for(let n=t;n;n=n.parent)if(n.disposed)return null;return t}function er(e){if(e.slot&&fe.has(e.slot))return!1;for(let[t,n]of e.conds){let r=U.get(t);if(r!==void 0&&r!==n)return!1}return Ro(e)!==null}function Oo(e){let t=Ro(e)||C,n=Pt(e.id,t);n.record=e,n.slot=e.slot,t.children.push(n),F.set(e.id,n),e.owner=n;let r=I(n);try{E(e.fn)}finally{I(r)}}function ya(e){if(!fe.has(e)){fe.add(e);for(let t of Array.from(F.values()))t.slot===e&&Y(t)}}function ka(e,t){if(U.get(e)===t)return;U.set(e,t);for(let o of Le)o.owner&&!o.owner.disposed&&!er(o)&&Y(o.owner);for(let o of Le)!o.owner&&er(o)&&Oo(o);let n=[];for(let o of F.values())!o.record&&o.conds.some(([i])=>i===e)&&n.push(o);let r=[];for(let o of n){let i=Mo(o);if(i===o.shown)continue;let s=Re(o);o.shown=i;let a=Re(o);s&&!a?Po(o,r):!s&&a&&_o(o)}r.length&&(Q.push(...r),r=[],ar()),Do()}function Po(e,t){for(let n of e.hooks)if(W.delete(n),n.phase==="passive"){let r=_e(n);r&&t.push(r)}else Oe(n);for(let n of e.children)n.shown&&!n.disposed&&Po(n,t)}function _o(e){for(let t of e.hooks)Fo(t);for(let t of e.children)t.shown&&!t.disposed&&_o(t)}function No(e,t){if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function Io(e){if(e!=null)return Array.isArray(e)?e:Array.from(e)}function Fo(e){e.dirty=!0,W.add(e),Do()}function Do(){Ot||(Ot=!0,queueMicrotask(()=>{qn()||(Pe(),Ze())}))}function wa(e,t,n="passive"){let r=_t(He()),o={owner:r,phase:n,fn:e,deps:t||null,prev:void 0,hasPrev:!1,cleanup:null,mounted:!1,epoch:0,dirty:!1,seq:ga++,stop:()=>{},scope:r===C?ae():r.scope};r.hooks.push(o),!r.disposed&&(o.stop=S(()=>{let i=o.deps?Io(o.deps()):[];o.hasPrev&&No(o.prev,i)||(o.prev=i,o.hasPrev=!0,Re(o.owner)&&Fo(o))}))}function tr(e,t){if(e.owner.disposed)return;let n;try{n=Ct(t,()=>E(e.fn))}catch(r){jo(r,e.owner);return}e.cleanup=typeof n=="function"?n:null,e.mounted=!0,e.epoch=t,Me.set(t,(Me.get(t)||0)+1)}var nr=null;function ir(e){nr=e}function jo(e,t){let n=null;for(let r=t;r&&n===null;r=r.parent)n=r.id;if(!(nr&&nr(e,n)))throw e}function Ta(e,t){try{E(e)}catch(n){jo(n,t)}}function _e(e){if(!e.mounted)return null;e.mounted=!1;let t=e.epoch,n=e.cleanup;return e.cleanup=null,n?()=>{try{Ct(t,()=>E(n))}finally{rr(t)}}:(rr(t),null)}function rr(e){let t=(Me.get(e)||1)-1;t>0?Me.set(e,t):Me.delete(e)}function Oe(e){let t=_e(e);t&&Ta(t,e.owner)}function Ho(){let e=Ht();for(let t of Me.keys())t<e&&(e=t);Dn(e)}function Ea(e){let t=new Map,n=0,r=o=>{for(let i of o.children)r(i);t.set(o,n++)};for(let o of C.children)r(o);return t.set(C,n++),Array.from(e).sort((o,i)=>{let s=t.get(o.owner)??n,a=t.get(i.owner)??n;return s!==a?s-a:o.seq-i.seq})}var Ko=[];function sr(e){Ko.push(e)}function Co(){for(let e of Ko)e()}function Sa(){Ot=!1;let e=Ht(),t=Un();if(W.size===0){Co(),t&&Pe(),Ho();return}let n=Ea(W).filter(r=>Re(r.owner));W.clear();for(let r of n)r.dirty=!1;Ae(!0);try{let r=0;for(;r<n.length;){let i=n[r].owner,s=r;for(;s<n.length&&n[s].owner===i;)s++;for(let a=r;a<s;a++)n[a].phase==="insertion"&&(Oe(n[a]),tr(n[a],e));for(let a=r;a<s;a++)n[a].phase==="layout"&&Oe(n[a]);r=s}for(let i of n)i.phase==="layout"&&tr(i,e);Co();let o=!1;for(let i of n){if(i.phase!=="passive")continue;let s=_e(i);s&&Q.push(s),de.push([i,e]),o=!0}o&&ar(),t&&Pe()}finally{Ae(!1)}Ho()}function ar(){J===null&&(J=setTimeout(Pe,0))}function Pe(){for(J!==null&&(clearTimeout(J),J=null);Q.length||de.length;){let e=Q,t=de;Q=[],de=[],Ae(!0);try{for(let n of e)n();for(let[n,r]of t)Re(n.owner)&&tr(n,r)}finally{Ae(!1)}}}function Uo(e,t){let n,r=!1,o;return()=>{let i=Io(t())||[];return(!r||!No(n,i))&&(n=i,r=!0,o=E(e)),o}}function xa(e,t){let n=!0;return Uo(()=>{if(n)return n=!1,e;let r=e;return function(...o){return r.apply(this,o)}},t)}function Aa(e){if(e&&typeof e=="object"){let t=Object.getPrototypeOf(e);if(t===Object.prototype||t===null){let n=[];for(let r of Object.keys(e))r!=="children"&&n.push(e[r]);return n}}return[e]}function Ha(e){let t=[];for(let o of C.children.slice()){if(!e(o.scope))continue;Nt(o,o.shown,t);let i=C.children.indexOf(o);i>=0&&C.children.splice(i,1)}let n=[];for(let o of C.hooks){if(!e(o.scope)){n.push(o);continue}if(o.stop(),W.delete(o),o.phase==="passive"){let i=_e(o);i&&t.push(i)}else Oe(o)}C.hooks=n;for(let[o,i]of Array.from(F))(i.disposed||e(i.scope))&&F.delete(o);let r=o=>!e(Gn(o));for(let o of Array.from(U.keys()))r(o)||U.delete(o);for(let o of Array.from(fe))r(o)||fe.delete(o);for(let o=Le.length-1;o>=0;o--)r(Le[o].id)||Le.splice(o,1);for(let o of Array.from(W))o.owner.disposed&&W.delete(o);de=de.filter(([o])=>!o.owner.disposed&&!(o.owner===C&&e(o.scope)));for(let o of t)try{E(o)}catch{}I(null)}function Ca(e){if(e){Ha(e);return}let t=[];for(let r of C.children.slice())Nt(r,r.shown,t);for(let r of C.hooks)if(r.stop(),r.phase==="passive"){let o=_e(r);o&&t.push(o)}else Oe(r);C.children.length=0,C.hooks.length=0,F.clear(),U.clear(),fe.clear(),W.clear(),de=[];let n=Q.concat(t);Q=[],J!==null&&(clearTimeout(J),J=null);for(let r of n)try{E(r)}catch{}Ot=!1,I(null)}Vn(Pe);Wn(Sa);zn(Ca);var tt=new Set;function Bo(e){let t,n=!1;if(S(()=>{try{e()}catch(r){t=r,n=!0}})(),n)throw t}function It(e){if(e.on)return;e.on=!0;let t=e.ref;Bo(()=>{if(typeof t=="function"){let n=t(e.el);e.undo=typeof n=="function"?n:()=>t(null)}else if(t&&typeof t=="object")t.current=e.el,e.undo=()=>{t.current=null};else if(e.assign){let n=e.assign;n(e.el),e.undo=()=>n(null)}else e.undo=null})}function ur(e){if(!e.on)return;e.on=!1;let t=e.undo;e.undo=null,t&&Bo(t)}function Ft(e,t){let n={el:t,ref:e,on:!1,undo:null};return It(n),()=>ur(n)}var Ne=null;function Vo(){Ne||(Ne=[],queueMicrotask(lr))}function lr(){let e=Ne;if(Ne=null,!!e)for(let t of e)tt.has(t)&&t.el.isConnected&&It(t)}function nt(e,t,n,r){let o={el:e,ref:t,assign:n,on:!1,undo:null};return tt.add(o),r==="defer"&&Ne?Ne.push(o):(r==="now"||e.isConnected)&&It(o),()=>{tt.delete(o),ur(o)}}function Dt(e){for(let t of tt)t.on&&e.contains(t.el)&&ur(t)}function jt(){for(let e of tt)!e.on&&e.el.isConnected&&It(e)}var La={doubleclick:"dblclick",focus:"focusin",blur:"focusout"},Ma={dblclick:"doubleclick",focusin:"focus",focusout:"blur"},Ra={focusin:"focus",focusout:"blur"},Oa=new Set("scroll scrollend load error abort cancel close invalid toggle beforetoggle mouseenter mouseleave pointerenter pointerleave canplay canplaythrough durationchange emptied encrypted ended loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" ")),$o={change:["change","input","click"],beforeinput:["beforeinput","compositionend"]},Pa={preventDefault(){this.defaultPrevented=!0,this.nativeEvent.preventDefault()},stopPropagation(){this._s=!0,this.nativeEvent.stopPropagation()},isDefaultPrevented(){return this.defaultPrevented},isPropagationStopped(){return!!this._s},persist(){},isPersistent(){return!0}},_a={get(e,t){if(t in e)return e[t];let n=e.nativeEvent,r=n[t];return typeof r=="function"?r.bind(n):r}};function Ut(e,t,n){let r=Object.create(Pa),o=n===void 0?e.target:n;return o&&o.nodeType===3&&(o=o.parentNode),r.type=t||Ra[e.type]||e.type,r.target=o,r.currentTarget=null,r.nativeEvent=e,r.defaultPrevented=e.defaultPrevented,new Proxy(r,_a)}var cr,Kt=!1;function Xo(e,t){try{e(t)}catch(n){Kt||(Kt=!0,cr=n)}}function Jo(){if(Kt){let e=cr;throw Kt=!1,cr=void 0,e}}function mr(e,t,n,r,o){let i=[],s=[];for(let l=n;l;l=l.__kpp||l.parentNode){let c=l.__kh;if(!c)continue;let g;r&1&&(g=c[t+"$"])&&i.unshift(l,g),r&2&&(g=c[t])&&s.push(l,g)}if(!i.length&&!s.length)return null;let a=Ut(e,o,n),u=i.concat(s);for(let l=0;l<u.length&&!a._s;l+=2)a.currentTarget=u[l],Xo(u[l+1],a);return a.currentTarget=null,a}var Wo=new WeakMap,dr=new Set,Qo=new Set;function Na(){return typeof document>"u"?null:document.getElementById("root")||document.body}function fr(e,t){let n=Wo.get(e);n||(n=new Set,Wo.set(e,n)),!n.has(t)&&(n.add(t),e.addEventListener(t,Ia,!0),e.addEventListener(t,Fa,!1))}function pr(e){Qo.add(e);let t=Na();t&&(dr.add(t),fr(t,e));for(let n of dr)n!==t&&n.isConnected&&fr(n,e)}function Bt(e){dr.add(e);for(let t of Qo)fr(e,t)}function Ia(e){Yo(e,!0)}function Fa(e){Yo(e,!1)}function Yo(e,t){let n=t?"__kdc":"__kdb",r=e;if(r[n])return;r[n]=1;let o=e.type,i=e.target;xe(o,!t,()=>{o!=="change"&&o!=="beforeinput"&&mr(e,Ma[o]||o,i,t?1:2),t||(o==="change"||o==="input"||o==="click"?Ba(e):(o==="beforeinput"||o==="compositionend")&&Va(e))}),Jo()}function Da(e){Zo(this,e,!1)}function ja(e){Zo(this,e,!0)}function Zo(e,t,n){let r=e.__kh,o=r&&r[t.type+(n?"$":"")];if(!o)return;let i=Ut(t);i.currentTarget=e,xe(t.type,!0,()=>Xo(o,i)),i.currentTarget=null,Jo()}function hr(e){let t=e.slice(2),n=!1;return t.length>7&&t.slice(-7)==="Capture"&&!/^(Got|Lost)PointerCapture$/.test(t)&&(t=t.slice(0,-7),n=!0),[t.toLowerCase(),n]}function Vt(e,t,n){let[r,o]=hr(t),i=e,s=i.__kh||(i.__kh={}),a=r+(o?"$":"");if(typeof n!="function"){s[a]=void 0;return}if(s[a]=n,Oa.has(r)){let l=i.__kd||(i.__kd={});l[a]||(l[a]=1,e.addEventListener(r,o?ja:Da,o));return}let u=$o[r];if(u){for(let l of u)pr(l);r==="change"&&ni(e)}else pr(La[r]||r)}function Wt(e){let t=e.querySelectorAll("input[value]");for(let n=0;n<t.length;n++){let r=t[n];if(!ei.has(r.type||"text")||!r.value||r.ownerDocument.activeElement===r)continue;let o=r.value;r.value="",r.value=o}}var ei=new Set("color date datetime datetime-local email month number password range search tel text time url week".split(" "));function br(e){return e.tagName==="INPUT"&&(e.type==="checkbox"||e.type==="radio")}function ti(e){return br(e)?String(e.checked):String(e.value)}function ni(e){e.__kv===void 0&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA")&&(e.__kv=ti(e))}function gr(e){let t=ti(e);return e.__kv===t?!1:(e.__kv=t,!0)}function Ka(e){if(!e.name||!e.ownerDocument)return[e];let t=[],n=e.ownerDocument.getElementsByName(e.name);for(let r=0;r<n.length;r++){let o=n[r];o.tagName==="INPUT"&&o.type==="radio"&&o.form===e.form&&t.push(o)}return t}function Ua(e){let t=e.target;if(!t||!t.tagName)return null;let n=e.type,r=t.tagName;return r==="SELECT"||r==="INPUT"&&t.type==="file"?n==="change"?t:null:br(t)?n==="click"&&gr(t)?t:null:(r==="TEXTAREA"||r==="INPUT"&&ei.has(t.type||"text"))&&n!=="click"&&gr(t)?t:null}function Ba(e){let t=Ua(e);if(t)if(mr(e,"change",t,3,"change"),t.type==="radio")for(let n of Ka(t))gr(n),Go(n);else Go(t)}function Va(e){let t=e;e.type==="beforeinput"&&(t.isComposing||typeof t.data!="string"||t.data==="")||e.type==="compositionend"&&!t.data||mr(e,"beforeinput",e.target,3,"beforeinput")}function zo(e,t){e.__kw||(e.__kw=1,console.error(t))}function qo(e,t,n){let r=e.options;if(e.multiple){let s=new Set((Array.isArray(t)?t:[t]).map(String));for(let a=0;a<r.length;a++){let u=s.has(r[a].value);n?r[a].defaultSelected=u:r[a].selected!==u&&(r[a].selected=u)}return}let o=String(t),i=null;for(let s=0;s<r.length;s++){if(r[s].value===o){n?r[s].defaultSelected=!0:r[s].selected=!0;return}!i&&!r[s].disabled&&(i=r[s])}i&&!n&&(i.selected=!0)}function pe(e,t,n){let r=e;switch(t){case"value":{if(n==null)return;if(r.tagName==="SELECT"){qo(r,n,!1);return}let o=String(n);r.value!==o&&(r.value=o),r.type!=="file"&&!(r.type==="number"&&r.ownerDocument&&r.ownerDocument.activeElement===r)&&r.defaultValue!==o&&(r.defaultValue=o),br(r)||(r.__kv=o);return}case"checked":{if(n==null)return;let o=!!n;r.checked!==o&&(r.checked=o),r.__kv=String(o);return}case"defaultValue":r.tagName==="SELECT"?qo(r,n,!0):r.defaultValue=n==null?"":String(n);return;case"defaultChecked":r.defaultChecked=!!n;return;default:r[t]=!!n}}function Go(e){let t=e.__kc;t&&(Rt(),t.value&&pe(e,"value",t.value()),t.checked&&pe(e,"checked",t.checked()))}function zt(e,t,n){let r=e,o=t==="value"||t==="checked";if(o){(r.__kc||(r.__kc={}))[t]=n;for(let a of $o.change)pr(a);ni(r)}let i,s=!1;return S(()=>{let a=n();if(o){let u=a!=null;a===null&&t==="value"?zo(r,"`value` prop on `"+r.tagName.toLowerCase()+"` should not be null. Use an empty string to clear it or `undefined` for an uncontrolled field."):i!==void 0&&i!==u&&zo(r,"A component is changing "+(i?"a controlled":"an uncontrolled")+" input to be "+(u?"controlled":"uncontrolled")+". Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://react.dev/link/controlled-components"),i=u}pe(r,t,a),!s&&t==="value"&&r.tagName==="TEXTAREA"&&r.ownerDocument.activeElement!==r&&r.setSelectionRange(0,0),s=!0})}var ri="template[data-krate-portal]",qt=new Map,Gt=new Set;function Wa(e,t){qt.set(e,t)}function za(e){return!!e&&typeof e=="object"&&(e.nodeType===1||e.nodeType===11)}function qa(e){let t=e.getAttribute("data-krate-portal")||"",n=qt.get(t);if(n){let o=null;try{o=n()}catch{o=null}return za(o)?o:null}let r=e.getAttribute("data-krate-portal-target");if(!r||r==="body")return document.body;try{return document.querySelector(r)}catch{return null}}function vr(e){if(e.__kpn||!e.isConnected)return;let t=qa(e);if(!t)return;let n=Array.from(e.content.childNodes),r=document.createDocumentFragment();for(let i of n)i.__kpp=e,r.appendChild(i);t.appendChild(r),e.__kpn=n,Gt.add(e);let o=document.getElementById("root");t.nodeType===1&&!(o&&o.contains(t))&&Bt(t),e.__kpd||(e.__kpd=!0,Xt(e,()=>$t(e,!0)))}function $t(e,t){let n=e.__kpn;if(n){e.__kpn=void 0,Gt.delete(e);for(let r of n)t?r.parentNode&&r.parentNode.removeChild(r):e.content.appendChild(r),r.__kpp=void 0}}function yr(e){let t=[];return e.matches?.(ri)&&t.push(e),e.querySelectorAll(ri).forEach(n=>t.push(n)),t}function Ga(e){if(!(typeof document>"u"))for(let t of yr(e||document))vr(t)}function kr(e){return yr(e)}function wr(e){for(let t of e)vr(t)}function Tr(e){for(let t of yr(e))$t(t)}function oi(e,t){let n=e.slice(),r=new Set;for(;n.length;)n.shift().querySelectorAll("template").forEach(i=>{if(r.has(i))return;r.add(i);let s=i;s.hasAttribute("data-krate-portal")&&t(s.content),n.push(s.content)})}function $a(e,t){for(let r of Gt)for(let o of r.__kpn||[]){if(o.nodeType!==1)continue;let i=o;if(i.matches(e))return i;let s=i.querySelector(e);if(s)return s}let n=null;return oi(t,r=>{n||(n=r.querySelector(e))}),n}function Xa(){let e=new Set;for(let t of Array.from(Gt))t.isConnected?e.add(t.getAttribute("data-krate-portal")||""):$t(t,!0);for(let t of Array.from(qt.keys()))e.has(t)||qt.delete(t)}var Ie=new Set,si=new WeakMap;function Ja(){return Array.from(Ie)}function Qa(){let e=new Set,t=!0;for(;t;){t=!1;for(let n of Ie){if(e.has(n))continue;let r=si.get(n);if(!r)continue;let o=r.getRootNode();(r.isConnected||e.has(o))&&(e.add(n),t=!0)}}for(let n of Array.from(Ie))e.has(n)||Ie.delete(n)}function ii(e){let t="/"+(e.nodeValue||"");for(let n=e.nextSibling;n;n=n.nextSibling)if(n.nodeType===8&&n.nodeValue===t)return n;return null}function Ya(e,t,n){let r=e,o=t?"c":"a",i=r.__krateCond;if(!i){let f=n?n.getAttribute("data-kb"):null;i={shown:f==="c"?"a":f==="a"?"c":o,other:null,tpl:n,end:ii(e)},r.__krateCond=i}if(i.shown===o)return;let s=e.parentNode;if(!s)return;(!i.end||i.end.parentNode!==s)&&(i.end=ii(e));let a=i.end,u=document.createDocumentFragment(),l=e.nextSibling;for(;l&&l!==a;){let f=l.nextSibling;u.appendChild(l),l=f}Dt(u),Tr(u);let c=i.other;c||(c=document.createDocumentFragment(),i.tpl&&c.appendChild(i.tpl.content)),Ie.delete(c);let g=c.querySelector("[autofocus]");Wt(c);let d=kr(c);s.insertBefore(c,a),wr(d),i.other=u,Ie.add(u),si.set(u,e),i.shown=o,jt(),g&&(g.removeAttribute("autofocus"),g.focus())}var Za={href:!0,src:!0,action:!0,formaction:!0,"xlink:href":!0},eu=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i,ai="javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')";function Er(e,t){return Za[e.toLowerCase()]&&eu.test(t)?ai:t}var rt=new WeakMap;function _(e,t){Xt(e,t)}function Xt(e,t){let n=rt.get(e);n||(n=[],rt.set(e,n)),n.push(t)}function ci(e,t){let n=()=>Y(t);if(typeof DocumentFragment<"u"&&e instanceof DocumentFragment)for(let r=0;r<e.childNodes.length;r++)_(e.childNodes[r],n);else if(typeof Node<"u"&&e instanceof Node)_(e,n);else if(Array.isArray(e))for(let r of e)ci(r,t)}function tu(e,t,n){let r=!0,o=S(()=>{let i=nt(e,t?t():void 0,n,r?"defer":void 0);r=!1,P(i)});return _(e,o),o}function B(e){let t=rt.get(e);if(t){for(let n of t)n();t.length=0}for(let n=0;n<e.childNodes.length;n++)B(e.childNodes[n])}function nu(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function di(e,t){let n=e.parentNode;if(!n)return;let r=e.nextSibling;for(;r&&r!==t;){let o=r.nextSibling;B(r),n.removeChild(r),r=o}}function ru(e,t,n){let r=nu(n);r?(di(n,r),Sr(e,t,r)):Sr(e,t,null)}function Sr(e,t,n){if(!(t==null||t===!1||t===!0)){if(typeof t=="string"||typeof t=="number")e.insertBefore(document.createTextNode(String(t)),n);else if(t instanceof Node)e.insertBefore(t,n);else if(Array.isArray(t))for(let r of t)Sr(e,r,n)}}var ou={htmlFor:"for"},iu=new Set(["animation-iteration-count","aspect-ratio","border-image-outset","border-image-slice","border-image-width","box-flex","box-flex-group","box-ordinal-group","column-count","columns","flex","flex-grow","flex-positive","flex-shrink","flex-negative","flex-order","grid-area","grid-row","grid-row-end","grid-row-span","grid-row-start","grid-column","grid-column-end","grid-column-span","grid-column-start","font-weight","line-clamp","line-height","opacity","order","orphans","scale","tab-size","widows","z-index","zoom","fill-opacity","flood-opacity","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-miterlimit","stroke-opacity","stroke-width"]);function su(e){if(e.startsWith("--"))return e;let t=e.replace(/[A-Z]/g,n=>"-"+n.toLowerCase());return t.startsWith("ms-")?"-"+t:t}var ui=new WeakMap;function fi(e,t){let n=e.style;if(!n)return;let r=new Set;for(let i of Object.keys(t)){let s=t[i];if(s==null||typeof s=="boolean"||s==="")continue;let a=su(i),u=a.replace(/^-(webkit|moz|ms|o)-/,""),l=typeof s=="number"&&s!==0&&!a.startsWith("--")&&!iu.has(u)?s+"px":String(s);n.setProperty(a,l),r.add(a)}let o=ui.get(e);if(o)for(let i of o)r.has(i)||n.removeProperty(i);ui.set(e,r)}function li(e,t,n){if(t==="class"||t==="className"){let r=n===!1||n===null||n===void 0?"":String(n);if(e.getAttribute("class")!==r){if(r===""&&!e.hasAttribute("class")&&typeof n!="string")return;e.setAttribute("class",r)}}else if(t==="style")typeof n=="string"?e.getAttribute("style")!==n&&e.setAttribute("style",n):n&&typeof n=="object"?fi(e,n):(n==null||n===!1)&&e.removeAttribute("style");else if(t.startsWith("on")&&typeof n=="function")Vt(e,t,n);else if(t==="value"||t==="checked"||t==="selected"||t==="defaultValue"||t==="defaultChecked")pe(e,t,n);else if(t==="ref"){let r=nt(e,n,void 0,"now");_(e,r),P(r)}else if(!(t==="key"||t==="children"||t==="dangerouslySetInnerHTML")){let r=ou[t]||t,o=/^(aria|data)-/.test(r);if(n==null||n===!1&&!o)e.hasAttribute(r)&&e.removeAttribute(r);else{let i=n===!0&&!o?"":Er(r,String(n));e.getAttribute(r)!==i&&e.setAttribute(r,i)}}}function pi(e,t){for(let r in t){let o=t[r];typeof o=="function"&&(r==="value"||r==="checked")?_(e,zt(e,r,o)):typeof o=="function"&&!r.startsWith("on")&&r!=="ref"?_(e,S(()=>li(e,r,o()))):li(e,r,o)}let n=t.dangerouslySetInnerHTML;if(n&&typeof n=="object"&&n.__html!=null){let r=String(n.__html);e.innerHTML!==r&&(e.innerHTML=r)}}var ge=0;function Jt(e){let t=ge;ge=t+1;try{return e()}finally{ge=t}}function me(e){let t=ge;ge=0;try{return e()}finally{ge=t}}function gi(e){return!!e&&typeof e=="object"&&e.__kv===1}function mi(e){return!!e&&typeof e=="object"&&e.__ka===1}function hi(e,t,n){let r=document.createElement(e);if(t&&pi(r,t),!t||!t.dangerouslySetInnerHTML)for(let o of n)he(r,o);return r}function bi(e){return me(()=>hi(e.tag,e.props,e.children))}function Ar(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"}function Hr(e){return e==null||typeof e=="boolean"?"":String(e)}function he(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)he(e,n);return}if(typeof t=="function"){lu(e,t,null);return}if(gi(t)){e.appendChild(bi(t));return}if(mi(t)){e.appendChild(t.mount());return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function au(e,t){let n=rt.get(e);if(n){rt.delete(e);for(let r of n)_(t,r)}}function xr(e,t){let n=e.parentNode;if(!n)return;let r=e.nextSibling;for(;r&&r!==t;){let o=r.nextSibling;B(r),n.removeChild(r),r=o}}function uu(e){if(!e.text)return;let t=e.text,n=t.parentNode;e.start=document.createComment(""),e.end=document.createComment(""),n.insertBefore(e.start,t),n.insertBefore(e.end,t.nextSibling),au(t,e.start),n.removeChild(t),e.text=null}function vi(e,t){if(Ar(t)){let r=Hr(t);if(e.text){e.text.data!==r&&(e.text.data=r);return}xr(e.start,e.end),r!==""&&e.end.parentNode.insertBefore(document.createTextNode(r),e.end);return}uu(e),xr(e.start,e.end);let n=document.createDocumentFragment();he(n,t),e.end.parentNode.insertBefore(n,e.end)}function lu(e,t,n){let r={text:null,start:null,end:null},o=!0,i=S(()=>{let s=t();if(!o){vi(r,s);return}if(o=!1,Ar(s)){r.text=document.createTextNode(Hr(s)),e.insertBefore(r.text,n);return}r.start=document.createComment(""),r.end=document.createComment(""),e.insertBefore(r.start,n);let a=document.createDocumentFragment();he(a,s),e.insertBefore(a,n),e.insertBefore(r.end,n)});_(r.text||r.start,i)}function yi(e){for(;e.next&&e.next.nodeType===8;)e.next=e.next.nextSibling}function Z(e,t){e.parent.insertBefore(t,e.next)}function ki(e,t){yi(e);let n=e.next;if(t!==""&&n&&n.nodeType===3){let o=n;return o.data.length>t.length&&o.data.startsWith(t)?o.splitText(t.length):o.data!==t&&(o.data=t),e.next=o.nextSibling,o}let r=document.createTextNode(t);return Z(e,r),r}function Qt(e,t){let n=e.next;for(;n&&n!==t;){let r=n.nextSibling;B(n),e.parent.removeChild(n),n=r}e.next=t}function cu(e,t){yi(t);let n=t.next;if(n&&n.nodeType===1&&n.localName.toLowerCase()===e.tag.toLowerCase()){t.next=n.nextSibling;let r=n;if(e.props&&pi(r,e.props),!e.props||!e.props.dangerouslySetInnerHTML){let o={parent:r,next:r.firstChild};for(let i of e.children)Fe(i,o);Qt(o,null)}return}Z(t,bi(e))}function du(e,t){let n={text:null,start:null,end:null},r=!0,o=S(()=>{if(!r){vi(n,e());return}r=!1;let i=Jt(e);if(Ar(i)){n.text=ki(t,Hr(i));return}n.start=document.createComment(""),Z(t,n.start),Fe(i,t),n.end=document.createComment(""),Z(t,n.end)});_(n.text||n.start,o)}function Fe(e,t){if(!(e==null||typeof e=="boolean")){if(Array.isArray(e)){for(let n of e)Fe(n,t);return}if(typeof e=="function"){du(e,t);return}if(gi(e)){cu(e,t);return}if(mi(e)){e.adopt(t);return}if(e instanceof Node){Z(t,e);return}ki(t,String(e))}}function Yt(e,t,...n){if(typeof e=="function"){let r=t||{};(n.length>0||!("children"in r))&&(r.children=n);let{value:o,owner:i}=et(()=>e(r));return ci(o,i),o}return ge>0?{__kv:1,tag:e,props:t,children:n}:hi(e,t,n)}function wi(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function fu(e,t){let n=wi(t),r=!1;S(()=>{r||(r=!0,n.appendChild(e()))})}function pu(e,t){let n=wi(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&B(r)}function gu(e,t,n){if(!e)return String(n);let r=e(t,n);return r==null?String(n):"$"+String(r)}function mu(e){try{return decodeURIComponent(e)}catch{return e}}function hu(e){let t=e.map(n=>n.charAt(0)==="$"?n.slice(1):n);console.error("Encountered two children with the same key, `"+t.join("`, `")+"`. Keys should be unique so that components maintain their identity across updates. Krate keeps the first occurrence on its existing row and renders each duplicate as its own row.")}function bu(){return[document.createComment(""),document.createComment("")]}function Ti(e,t,n,r,o){Zn(i=>{_(t.start,i);let{value:s,owner:a}=et(()=>{if(!e.accessor)return e.render(n,r);let[u,l]=H(n),[c,g]=H(r);return t.setItem=l,t.setIndex=g,e.render(u,c)});P(()=>Y(a)),o(s)})}function Ei(e,t,n,r){let[o,i]=bu(),s={key:t,item:n,index:r,start:o,end:i,setItem:null,setIndex:null,live:!0},a=document.createDocumentFragment();return a.appendChild(o),me(()=>Ti(e,s,n,r,u=>he(a,u))),a.appendChild(i),a.__row=s,a}function vu(e,t,n,r){t.item=n,t.index=r,t.live=!0;let o=t.start.parentNode;try{Jt(()=>Ti(e,t,n,r,i=>{let s={parent:o,next:t.start.nextSibling};me(()=>Fe(i,s)),Qt(s,t.end)}))}catch(i){console.error(i),Si(t.start,t.end,!1),B(t.start);let s=Ei(e,t.key,n,r),a=s.__row;o.insertBefore(s,t.start),o.removeChild(t.start),o.removeChild(t.end),Object.assign(t,a)}}function Si(e,t,n){let r=e.parentNode;if(!r)return;let o=e.nextSibling;for(;o&&o!==t;){let i=o.nextSibling;B(o),r.removeChild(o),o=i}n&&(B(e),r.removeChild(e),t.parentNode===r&&r.removeChild(t))}function xi(e){Si(e.start,e.end,!0)}function yu(e,t){let n=t.parentNode;if(e.end.nextSibling===t)return;let r=e.start;for(;r;){let o=r===e.end?null:r.nextSibling;n.insertBefore(r,t),r=o}}function Ai(e){let t=e.length,n=new Int32Array(t),r=[];for(let s=0;s<t;s++){let a=e[s];if(a<0)continue;let u=0,l=r.length;for(;u<l;){let c=u+l>>1;e[r[c]]<a?u=c+1:l=c}n[s]=u>0?r[u-1]:-1,r[u]=s}let o=new Array(r.length),i=r.length?r[r.length-1]:-1;for(let s=r.length-1;s>=0;s--)o[s]=i,i=n[i];return o}function ku(e){return e==null?[]:Array.isArray(e)?e:typeof e[Symbol.iterator]=="function"?Array.from(e):[]}function wu(e){if(typeof document>"u")return null;let t=document.activeElement;if(!t||t===document.body||!e||!e.contains(t))return null;let n=null;try{let r=t;typeof r.selectionStart=="number"&&(n=[r.selectionStart,r.selectionEnd,r.selectionDirection])}catch{n=null}return()=>{if(!(document.activeElement===t||!t.isConnected)&&(t.focus({preventScroll:!0}),n))try{t.setSelectionRange(n[0],n[1],n[2]||void 0)}catch{}}}function Tu(e,t){let{end:n,keyFn:r}=e,o=n.parentNode,i=e.rows,s=t.length,a=new Array(s),u=new Map,l=null;for(let p=0;p<s;p++){let b=gu(r,t[p],p),y=u.get(b);y!==void 0?((l||(l=[])).push(b),u.set(b,y+1),b=b+"\0"+y):u.set(b,1),a[p]=b}l&&hu(l);let c=new Map;for(let p=0;p<i.length;p++)c.set(i[p].key,p);for(let p=0;p<s&&p<i.length;p++){let b=i[p];!b.live&&!u.has(b.key)&&!c.has(a[p])&&(c.delete(b.key),b.key=a[p],c.set(b.key,p))}let g=wu(o),d=new Array(s),f=new Int32Array(s).fill(-1),m=new Uint8Array(i.length);for(let p=0;p<s;p++){let b=c.get(a[p]);if(b===void 0)continue;let y=i[b],Tn=t[p];y.live&&!e.accessor&&(y.item!==Tn||e.usesIndex&&y.index!==p)||(m[b]=1,f[p]=b,d[p]=y)}for(let p=0;p<i.length;p++)m[p]||xi(i[p]);for(let p=0;p<s;p++){let b=d[p];if(!b)continue;let y=t[p];if(!b.live){vu(e,b,y,p);continue}b.item!==y&&(b.item=y,b.setItem&&b.setItem(()=>y)),b.index!==p&&(b.index=p,b.setIndex&&b.setIndex(p))}let k=new Array(s),v=null;for(let p=0;p<s;p++){if(d[p]){v=null;continue}let b=Ei(e,a[p],t[p],p);d[p]=b.__row,v?(v.appendChild(b),k[p-1]=null):v=b,k[p]=v}let h=new Uint8Array(s);for(let p of Ai(f))h[p]=1;let x=n;for(let p=s-1;p>=0;p--){let b=d[p],y=k[p];y?o.insertBefore(y,x):f[p]>=0&&!h[p]&&yu(b,x),x=b.start}e.rows=d,g&&g()}function Eu(e){let{start:t,end:n}=e,r=t.parentNode,o=(t.nodeValue||"").slice(2),i="k:"+o+":",s=[],a=t.nextSibling;for(;a&&a!==n;){let l=a.nodeType===8&&a.nodeValue||"";if(o&&l.indexOf(i)===0){let g="/"+l,d=a.nextSibling;for(;d&&d!==n&&!(d.nodeType===8&&d.nodeValue===g);)d=d.nextSibling;if(d&&d!==n){s.push({key:mu(l.slice(i.length)),item:void 0,index:s.length,start:a,end:d,setItem:null,setIndex:null,live:!1}),a=d.nextSibling;continue}}let c=a.nextSibling;B(a),r.removeChild(a),a=c}let u=new Set;e.rows=s.filter(l=>u.has(l.key)?(xi(l),!1):(u.add(l.key),!0))}function Cr(e,t,n){let r=!0,o=S(()=>{let i=ku(t());E(()=>{r&&(r=!1,n&&Eu(e)),Tu(e,i)})});_(e.start,o)}function Lr(e,t,n,r,o){return{start:e,end:t,rows:[],keyFn:n,render:r,accessor:o===1,usesIndex:r.length>1}}function Su(e,t,n,r,o){let i="/"+(e.nodeValue||""),s=e.nextSibling;for(;s&&!(s.nodeType===8&&s.nodeValue===i);)s=s.nextSibling;s||(s=document.createComment(i),e.parentNode.insertBefore(s,e.nextSibling)),Cr(Lr(e,s,n,r,o),t,!0)}function xu(e,t,n,r){return{__ka:1,mount(){let o=document.createDocumentFragment(),i=document.createComment(""),s=document.createComment("");return o.appendChild(i),o.appendChild(s),Cr(Lr(i,s,t,n,r),e,!1),o},adopt(o){let i=o.next;for(;i&&i.nodeType===8&&(i.nodeValue||"").indexOf("/k:")===0;)i=i.nextSibling;if(i&&i.nodeType===8&&(i.nodeValue||"").indexOf("k:")===0){let s="/"+i.nodeValue,a=i.nextSibling;for(;a&&!(a.nodeType===8&&a.nodeValue===s);)a=a.nextSibling;if(a){o.next=a.nextSibling,me(()=>Cr(Lr(i,a,t,n,r),e,!0));return}}Z(o,me(()=>this.mount()))}}}function Hi(){return globalThis.__krateSuspenseHook}function Au(e,t){let[n,r]=H(void 0),[o,i]=H(!0),[s,a]=H(void 0),[u,l]=H("unresolved"),[c,g]=H(0),d,f=Hi()?.current()??null,m=null,k=null,v=()=>typeof e=="function"?e():e,h=()=>{let y=x();return m=y,y.then(()=>{m===y&&(m=null)}),y},x=async()=>{d&&d.abort(),d=new AbortController;let y=d,Tn=v();l(c()>0?"refreshing":"loading"),i(!0),a(void 0);try{let vt=await t(Tn,{signal:y.signal});y.signal.aborted||(r(()=>vt),l("ready"))}catch(vt){vt?.name!=="AbortError"&&!y.signal.aborted&&(a(vt),l("error"))}finally{y.signal.aborted||i(!1)}};S(()=>{typeof e=="function"&&e.length===0&&e(),c(),h(),P(()=>{d&&(d.abort(),d=void 0)})});let p=function(){return f&&m&&k!==m&&(k=m,Hi()?.suspend(f,m)),n()};return Object.defineProperties(p,{loading:{get:()=>o()},error:{get:()=>s()},state:{get:()=>u()}}),[p,{mutate:y=>{r(y)},refetch:()=>{g(y=>y+1)}}]}function Hu(e){let t=document.createDocumentFragment(),n=e.children;if(n){let r=Array.isArray(n)?n:[n];for(let o of r)o instanceof Node?t.appendChild(o):t.appendChild(document.createTextNode(String(o)))}return t}function Ci(e,t,n){let r=e;if(!t)return Yt(r,null);let{children:o,...i}=t,s=o!==void 0?Array.isArray(o)?o:[o]:[];return Yt(r,Object.keys(i).length>0?i:null,...s)}function Cu(e,t,n){return Ci(e,t,n)}var Nr=/\/chunks\/runtime\.[^/]+\.js$/;function an(){return globalThis.__KRATE_CFG__||{}}function Ir(){let e=an().basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function Ke(e){let t=Ir();if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}function Or(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function ot(e){if(an().dev)try{console.warn("[krate router] "+e)}catch{}}function Ni(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 Ii(e,t,n){let r=new DOMParser().parseFromString(e,"text/html"),o=[],i=new Set,s=a=>{if(!a)return;let u;try{u=Ni(a,t)}catch{return}i.has(u)||n.has(u)||Nr.test(u)||(i.add(u),o.push(u))};return r.querySelectorAll("script[src]").forEach(a=>s(a.getAttribute("src"))),r.querySelectorAll('link[rel="modulepreload"][href], link[rel="preload"][as="script"][href]').forEach(a=>s(a.getAttribute("href"))),o}var G=!1,te=0,N,Li=0,w="",V="",tn="idle",at=new Set,D=new Map,it=new Map,Lu=30,Mu=3e4,z=new Map,Ru=50,Mr=new Set,Ou=128,en=new Map,st=new Map,be=null,ut=[],Pu="_krate/i",_u=150,Nu=200;function Pr(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function ve(){return Li++,Date.now().toString(36)+"-"+Li.toString(36)}function un(e){try{let t=new URL(e,location.href);return t.hash="",t.href}catch{return e}}function $(e){let t=new URL(e,location.href);return Or(t.pathname)+t.search}function lt(e,t=!1){let n=globalThis.__krateHardNavigate;if(typeof n=="function"){n(e,t);return}t?location.replace(e):location.assign(e)}function ct(e,t){return{__krate:e,state:t===void 0?null:t}}function nn(e){if(e&&typeof e=="object"&&typeof e.__krate=="string")return e.__krate}function Iu(){if(typeof history>"u")return null;let e=history.state;return nn(e)!==void 0?e.state:e}function Fi(){let e=new URL(location.href);return{url:e.href,pathname:Ke(e.pathname),search:e.search,hash:e.hash,status:tn}}function Di(){return typeof location>"u"?{url:"",pathname:"/",search:"",hash:"",status:"idle"}:Fi()}function ln(){if(at.size===0)return;let e=Fi();for(let t of Array.from(at))try{t(e)}catch(n){console.error(n)}}function De(e){tn!==e&&(tn=e,ln())}function ji(e){return at.add(e),()=>{at.delete(e)}}function R(e,t,n=!1){try{let r=new CustomEvent(e,{detail:t,cancelable:n});return window.dispatchEvent(r),!r.defaultPrevented}catch{return!0}}function Fr(e){try{let t=globalThis.__krate_onNavigation;typeof t=="function"&&t(e)}catch{}}function ft(e){if(e){if(z.delete(e),z.size>=Ru){let t=z.keys().next().value;t!==void 0&&z.delete(t)}z.set(e,window.scrollY||0)}}function Ki(){let e=an().prefetchTTL;return typeof e=="number"&&e>=0?e:Mu}function Fu(e,t){for(D.delete(e);D.size>=Lu;){let n=D.keys().next().value;if(n===void 0)break;D.delete(n)}D.set(e,t)}function Du(e){let t=D.get(e);if(t&&(D.delete(e),!(Pr()-t.at>Ki())))return t}function Dr(e){if(e===void 0){D.clear();return}D.delete(un(e))}function jr(e){return/text\/html|application\/xhtml\+xml/i.test(e)}function dt(e){return/^\s*(<!doctype html|<html|<head|<body)/i.test(e)}function ju(e){if(Mr.has(e)||Mr.size>=Ou)return;Mr.add(e);let t=document.createElement("link");t.rel="prefetch",t.as="script",t.href=e,document.head.appendChild(t)}function Kr(e){let t=un(e),n=D.get(t);if(n&&Pr()-n.at<=Ki())return Promise.resolve();let r=it.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")||"",a=i.url||t;if(new URL(a,location.href).origin!==location.origin)return;let u=await i.text();if(!(jr(s)||s===""&&dt(u)))return;Fu(t,{html:u,url:a,status:i.status,at:Pr()});let l=new Set;document.querySelectorAll("script[src]").forEach(c=>l.add(c.src));for(let c of Ii(u,a,l))ju(c)}).catch(()=>{}).finally(()=>{it.delete(t)});return it.set(t,o),o}function Ur(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 Br(e){let t=e.getAttribute("data-prefetch");return e.hasAttribute("data-prefetch")&&t!=="false"&&t!=="0"}function Ku(e){let t=window.requestIdleCallback;typeof t=="function"?t(e,{timeout:1e3}):setTimeout(e,50)}function rn(e){let t=e.target;if(!t||typeof t.closest!="function")return;let n=t.closest("a[data-prefetch]");if(!n||!Br(n)||!Ur(n))return;let r=n.getAttribute("href");if(!r)return;let o=new URL(r,location.href).href;if($(o)===V)return;let i=st.get(n);i&&clearTimeout(i);let s=setTimeout(()=>{st.delete(n),Kr(o)},Nu);st.set(n,s)}function Ui(){be&&document.querySelectorAll("a[data-prefetch]").forEach(e=>{Br(e)&&be.observe(e)})}function Uu(){document.addEventListener("mouseover",rn),document.addEventListener("focusin",rn),typeof IntersectionObserver<"u"&&(be=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let n=t.target,r=n.getAttribute("href");if(r&&Ur(n)&&Br(n)){let o=new URL(r,location.href).href;$(o)!==V&&Ku(()=>{Kr(o)})}be.unobserve(t.target)}},{rootMargin:"200px"}),Ui())}function Bu(){let e=typeof HTMLScriptElement<"u"?HTMLScriptElement.supports:void 0;if(!(typeof e!="function"||!e("speculationrules")))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 Bi(){if(an().viewTransitions===!1)return!1;if(typeof window<"u"&&window.matchMedia)try{if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return!1}catch{}return typeof document.startViewTransition=="function"}function O(e){return e.getElementById("root")||e.body}function Vu(){let e=document.querySelector("template[data-krate-loading]");if(e&&e.content&&ut.length===0){let t=e.content.cloneNode(!0);ut=Array.from(t.childNodes),document.body.appendChild(t)}if(!Bi()){let t=O(document);t.style.transition=`opacity ${_u}ms ease`,t.style.opacity="0"}}function Vi(){for(let t of ut)t.parentNode&&t.parentNode.removeChild(t);ut=[];let e=O(document);e.style.opacity==="0"&&(e.style.opacity="")}function Wi(e){e.querySelectorAll("[data-view-transition]").forEach(t=>{let n=t.getAttribute("data-view-transition");n&&(t.style.viewTransitionName=n)})}function Wu(e,t){let n=e.querySelectorAll('link[rel="stylesheet"]'),r=new Set;n.forEach(i=>{let s=i.getAttribute("href");s&&r.add(new URL(s,t).href)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(i=>{let s=i.href;s&&!r.has(s)&&i.remove()});let o=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(i=>o.add(i.href)),n.forEach(i=>{let s=i.getAttribute("href");if(!s)return;let a=new URL(s,t).href;if(!o.has(a)){let u=document.createElement("link");u.rel="stylesheet",u.href=a,document.head.appendChild(u)}})}var Mi='meta[name="description"], meta[name="robots"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function zu(e){document.head.querySelectorAll(Mi).forEach(t=>t.remove()),e.head.querySelectorAll(Mi).forEach(t=>{document.head.appendChild(document.importNode(t,!0))})}function zi(e,t){let n=new Set;document.querySelectorAll("script[src]:not([data-krate-spa])").forEach(o=>n.add(o.src));let r=[];return e.querySelectorAll("script[src]").forEach(o=>{let i=o.getAttribute("src");if(!i)return;let s=(o.getAttribute("type")||"").toLowerCase();if(s&&s!=="module"&&s!=="text/javascript"&&s!=="application/javascript")return;let a=Ni(i,t);!n.has(a)&&!r.includes(a)&&r.push(a)}),r}function qi(e){return new Promise(t=>{let n=document.createElement("script");n.src=e,Nr.test(e)||n.setAttribute("data-krate-spa",""),n.onload=()=>t(!0),n.onerror=()=>t(!1),document.body.appendChild(n)})}function qu(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 Vr(e){let t=qu(e);if(!t)return!1;try{t.scrollIntoView({block:"start"})}catch{}return!0}function Gu(e,t){if(t.kind==="pop"){let r=t.restoreKey?z.get(t.restoreKey):void 0;if(r!==void 0){window.scrollTo(0,r);return}}let n=new URL(e,location.href).hash;Vr(n)||t.scroll&&t.kind!=="refresh"&&window.scrollTo(0,0)}var Zt=null;function $u(){let e=document.activeElement;if(e&&e!==document.body&&e.isConnected&&e!==Zt)return;let t=O(document);t.hasAttribute("tabindex")||(t.setAttribute("tabindex","-1"),Zt=t,t.addEventListener("blur",()=>{Zt===t&&(t.removeAttribute("tabindex"),Zt=null)},{once:!0}));try{t.focus({preventScroll:!0})}catch{}}var Ri="__krate-route-announcer";function Xu(){let e=document.getElementById(Ri);e||(e=document.createElement("div"),e.id=Ri,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=O(document).querySelector("h1"),n=document.title||(t&&t.textContent?t.textContent.trim():"")||Ke(location.pathname);e.textContent=n}function cn(){let e=Or(Ke(location.pathname));document.querySelectorAll("a[data-krate-link]").forEach(t=>{let n=t.getAttribute("href"),r="";try{r=n?Or(Ke(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 Oi(e){let t=Ir()+e;return en.has(t)?Promise.resolve(en.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&&dt(r)?r:null;return en.set(t,o),o}).catch(()=>null)}async function Ju(e,t){let n=un(e.url);if(!e.bypassCache){let g=it.get(n);if(g&&await g,t.aborted)return{ok:!1,aborted:!0};let d=Du(n);if(d)return{ok:!0,doc:{html:d.html,url:d.url,status:d.status}}}let r;try{r=await fetch(n,{headers:{Accept:"text/html"},credentials:"same-origin",signal:t,cache:e.bypassCache?"no-cache":"default"})}catch(g){return g?.name==="AbortError"||t.aborted?{ok:!1,aborted:!0}:R("krate:navigate-error",{url:e.url,status:0,error:g},!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(g){if(g?.name==="AbortError"||t.aborted)return{ok:!1,aborted:!0};s=""}if(t.aborted)return{ok:!1,aborted:!0};let a=jr(i)||i===""&&dt(s),u=new URL(e.url,location.href).hash,l=u&&!new URL(o).hash?o+u:o;if(r.ok)return a?{ok:!0,doc:{html:s,url:l,status:r.status}}:{ok:!1,hard:l};if(R("krate:navigate-error",{url:e.url,status:r.status}),a&&dt(s))return{ok:!0,doc:{html:s,url:l,status:r.status}};let c=null;return r.status===404||r.status===410?c=await Oi("/404.html"):r.status>=500&&(c=await Oi("/500.html")),t.aborted?{ok:!1,aborted:!0}:c?{ok:!0,doc:{html:c,url:l,status:r.status}}:{ok:!1,hard:l}}async function dn(e){let t=location.href;if(e.kind!=="pop"){if(!R("krate:navigate-start",{url:e.url,from:t,kind:e.kind},!0))return}else R("krate:navigate-start",{url:e.url,from:t,kind:e.kind});let n=++te;N&&N.abort();let r=new AbortController;N=r,De("loading"),!e.bypassCache&&D.has(un(e.url))||Vu();let i;try{i=await Ju(e,r.signal)}finally{N===r&&(N=void 0)}if(n===te){if(!i.ok){Vi(),De("idle"),"hard"in i&&lt(i.hard,e.kind==="replace"||e.kind==="refresh");return}await Qu(i.doc,e,n)}}async function Qu(e,t,n){let r=new DOMParser().parseFromString(e.html,"text/html"),o=e.url,i=O(r),s=O(document);t.kind==="push"&&ft(w);let a=Gi(r),u=el(ne,a,location.href,o,r);if(await Yu(()=>{let d=r.querySelector("title");d&&(document.title=d.textContent||"");let f=globalThis;if(u.keep.length>0&&typeof f.krateDisposeExcept=="function"?f.krateDisposeExcept(u.keep):typeof f.disposeAll=="function"&&f.disposeAll(),u.region){let{live:m,next:k}=u.region;on(m[0],m[1]);let v=je(k[0],k[1]).map(h=>document.importNode(h,!0));for(let h of v)m[1].parentNode.insertBefore(h,m[1]);for(let h of u.slots){on(h.live[0],h.live[1]);for(let x of je(h.next[0],h.next[1]))h.live[1].parentNode.insertBefore(document.importNode(x,!0),h.live[1])}Zu(s,i)}else{let m=Array.from(i.childNodes).map(k=>document.importNode(k,!0));s.replaceChildren(...m)}ne=u.chain,pt.clear(),Wu(r,o),zu(r),Wi(document)}),n!==te)return;Vi(),t.kind==="push"?(w=ve(),history.pushState(ct(w,t.state),"",o)):t.kind==="replace"?(z.delete(w),w=ve(),history.replaceState(ct(w,t.state),"",o)):t.kind==="refresh"?o!==location.href&&history.replaceState(history.state,"",o):t.restoreKey&&(w=t.restoreKey),V=$(location.href),re=V,Qi(r),Gu(o,t),t.kind!=="pop"&&t.kind!=="refresh"&&$u(),t.kind!=="refresh"&&Xu(),cn(),R("krate:navigate",{url:location.href,status:e.status}),Fr(location.href),De("idle"),document.querySelectorAll("script[data-krate-spa]").forEach(d=>d.remove());let c=zi(r,o);_i(u.skip);let g=await Promise.all(c.map(qi));if(_i([]),n===te){if(g.some(d=>!d)){R("krate:navigate-error",{url:location.href,status:e.status,error:"script-load"}),lt(location.href,!0);return}sn(),R("krate:navigate-end",{url:location.href,status:e.status})}}function Yu(e){if(!Bi())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 ne=[];function Gi(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 ot("unreadable #__krate_route route info; layouts will be remounted"),[]}}function Pi(e,t){let n=Ke(new URL(e,location.href).pathname).split("/").filter(Boolean);return(t<0?n:n.slice(0,t)).join("/")}function ee(e,t,n="kl:"){let o=(e.ownerDocument||e).createTreeWalker(e,128),i=n+t,s="/"+n+t;for(;o.nextNode();){let a=o.currentNode;if(a.nodeValue===i){for(let u=a.nextSibling;u;u=u.nextSibling)if(u.nodeType===8&&u.nodeValue===s)return[a,u];return null}}return null}function je(e,t){let n=[];for(let r=e.nextSibling;r&&r!==t;r=r.nextSibling)n.push(r);return n}function on(e,t){let n=globalThis.disposeNode;for(let r of je(e,t))r.parentNode.removeChild(r),typeof n=="function"&&n(r)}function Zu(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 _i(e){let t=globalThis.krateKeepScopes;typeof t=="function"&&t(e)}function el(e,t,n,r,o){let i={keep:[],skip:[],region:null,slots:[],chain:t},s=0;for(;s<e.length&&s<t.length;){let m=e[s],k=t[s];if(m.id!==k.id||m.k!=="layout"||k.k!=="layout"||Pi(n,m.d)!==Pi(r,k.d))break;if(!m.p||!k.p){ot(`layout ${k.f||k.id} is remounted on this navigation: ${k.why||m.why||"not persistable"}`);break}s++}if(s===0)return i;if(typeof globalThis.krateDisposeExcept!="function")return ot("the runtime has no krateDisposeExcept; layouts are remounted"),i;let a=t[s-1].id,u=ee(O(document),a),l=ee(O(o),a);if(!u||!l)return ot(`layout ${t[s-1].f||a} boundary markers are missing; the whole page is swapped`),i;let c=e.slice(0,s).map(m=>m.id),g=c.slice(),d=[],f=t.slice();for(let m=0;m<s;m++){let k=e[m].s||[],v=[];for(let h of t[m].s||[]){let x=k.find(y=>y.key===h.key),p=ee(O(document),h.key,"ks:"),b=ee(O(o),h.key,"ks:");if(x&&p&&(h.src!=="page"||!b)){c.push(x.scope),g.push(x.scope,h.scope),v.push({...h,scope:x.scope,src:x.src});continue}if(p&&b){d.push({live:p,next:b}),v.push(h);continue}return ot(`slot @${h.n} markers are missing; the whole page is swapped`),i}f[m]={...t[m],s:v}}return{keep:c,skip:g,region:{live:u,next:l},slots:d,chain:f}}var pt=new Map,re="";function _r(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 $i(e,t){let n=_r(t),r=e.replace(/^\/+|\/+$/g,""),o=r?r.split("/"):[],i={};for(let s=0;s<n.length;s++){let a=n[s];if(a.kind>=2){if(s!==n.length-1)return null;let u=o.slice(s);return a.kind===2&&u.length===0||u.some(l=>l==="")?null:(i[a.text]=u.map(Rr).join("/"),i)}if(s>=o.length)return null;if(a.kind===1){if(!o[s])return null;i[a.text]=Rr(o[s])}else if(Rr(o[s])!==a.text)return null}return o.length===n.length?i:null}function Rr(e){try{return decodeURIComponent(e)}catch{return e}}function Xi(e,t){let n=_r(e),r=_r(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 Wr(e){let t=Ke(new URL(e,location.href).pathname).replace(/^\/+|\/+$/g,""),n=null;for(let r of ne)for(let o of r.s||[])for(let i of o.i||[])$i(t,i)&&(!n||Xi(i,n.pattern)<0)&&(n={hit:{entry:r,slot:o,path:t},pattern:i});return n&&!ee(O(document),n.hit.slot.key,"ks:")?null:n?n.hit:null}function Ji(e,t){ne=ne.map(n=>n.s&&n.s.some(r=>r.key===e)?{...n,s:n.s.map(r=>r.key===e?t:r)}:n)}function Qi(e){for(let t of Array.from(e.querySelectorAll("script:not([src])"))){let n=/window\.__KRATE_PARAMS__\s*=\s*(\{[\s\S]*?\})\s*;?\s*$/.exec(t.textContent||"");if(n){try{globalThis.__KRATE_PARAMS__=JSON.parse(n[1])}catch{}return}}delete globalThis.__KRATE_PARAMS__}function Yi(e){let t=globalThis.krateDisposeScopes;typeof t=="function"&&t(e)}async function zr(e,t){let n=location.href;if(e.kind!=="pop"&&!R("krate:navigate-start",{url:e.url,from:n,kind:e.kind,intercept:t.slot.n},!0))return;let r=++te;N&&N.abort();let o=new AbortController;N=o,De("loading");let i=location.origin+Ir()+"/"+Pu+"/"+t.slot.key+(t.path?"/"+t.path:""),s="",a=!1;try{let v=await fetch(i,{headers:{Accept:"text/html"},credentials:"same-origin",signal:o.signal,cache:e.bypassCache?"no-cache":"default"});s=await v.text(),a=v.ok&&(jr(v.headers.get("content-type")||"")||dt(s)),a||R("krate:navigate-error",{url:e.url,status:v.status,intercept:t.slot.n})}catch(v){if(v?.name==="AbortError"||o.signal.aborted)return;R("krate:navigate-error",{url:e.url,status:0,error:v,intercept:t.slot.n})}finally{N===o&&(N=void 0)}if(r!==te)return;let u=a?new DOMParser().parseFromString(s,"text/html"):null,l=u?ee(O(u),t.slot.key,"ks:"):null,c=ee(O(document),t.slot.key,"ks:"),g=null;try{let v=u&&u.getElementById("__krate_route");g=v&&JSON.parse(v.textContent||"{}").frag||null}catch{g=null}if(!u||!l||!c||!g||g.key!==t.slot.key||!g.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 De("idle"),dn({...e})}if(e.kind==="push"&&ft(w),t.slot.src!=="intercept"){pt.set(w,{key:t.slot.key,nodes:je(c[0],c[1]),slot:t.slot,path:re});for(let v of je(c[0],c[1]))v.parentNode.removeChild(v)}else Yi([t.slot.scope]),on(c[0],c[1]);for(let v of je(l[0],l[1]))c[1].parentNode.insertBefore(document.importNode(v,!0),c[1]);let d=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(v=>d.add(v.href)),u.querySelectorAll('link[rel="stylesheet"][href]').forEach(v=>{let h=new URL(v.getAttribute("href"),i).href;if(d.has(h))return;let x=document.createElement("link");x.rel="stylesheet",x.href=h,document.head.appendChild(x)}),Ji(t.slot.key,{...t.slot,scope:g.scope,src:"intercept"});let f={__krate:"",state:e.state===void 0?null:e.state,__kint:{key:t.slot.key,base:re}};e.kind==="push"?(w=ve(),f.__krate=w,history.pushState(f,"",e.url)):e.kind==="replace"?(w=ve(),f.__krate=w,history.replaceState(f,"",e.url)):e.kind==="pop"&&e.restoreKey&&(w=e.restoreKey),V=$(location.href),Qi(u),cn(),R("krate:navigate",{url:location.href,status:200,intercept:t.slot.n}),Fr(location.href),De("idle");let m=zi(u,i),k=await Promise.all(m.map(qi));if(r===te){if(k.some(v=>!v)){R("krate:navigate-error",{url:location.href,status:200,error:"script-load",intercept:t.slot.n}),lt(location.href,!0);return}sn(),R("krate:navigate-end",{url:location.href,status:200,intercept:t.slot.n})}}function tl(e,t){let n=ee(O(document),e.key,"ks:"),r=ne.flatMap(i=>i.s||[]).find(i=>i.key===e.key);if(!n||!r||r.src!=="intercept")return!1;Yi([r.scope]),on(n[0],n[1]);for(let i of e.nodes)n[1].parentNode.insertBefore(i,n[1]);Ji(e.key,e.slot),pt.delete(t),w=t,V=$(location.href);let o=z.get(t);return o!==void 0&&window.scrollTo(0,o),cn(),R("krate:navigate",{url:location.href,status:200}),Fr(location.href),ln(),!0}function nl(e){return $(e)===V}function rl(e,t){ft(w),(e!==location.href||t.state!==void 0)&&(t.kind==="replace"?history.replaceState(ct(w||ve(),t.state),"",e):(w=ve(),history.pushState(ct(w,t.state),"",e)));let n=new URL(e).hash;!Vr(n)&&t.scroll&&!n&&window.scrollTo(0,0),ln()}function fn(e){let t;try{t=new URL(e.url,location.href)}catch{return lt(e.url),Promise.resolve()}if(t.origin!==location.origin)return lt(t.href,e.kind==="replace"),Promise.resolve();if(e.url=t.href,(e.kind==="push"||e.kind==="replace")&&nl(t.href)&&(t.hash||t.href===location.href))return rl(t.href,e),Promise.resolve();if(e.kind==="push"||e.kind==="replace"){let n=Wr(t.href);if(n)return zr(e,n)}return dn(e)}function Zi(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||!Ur(n))return;let r=n.getAttribute("href");r&&(e.preventDefault(),fn({url:new URL(r,location.href).href,kind:n.hasAttribute("data-krate-replace")?"replace":"push",scroll:n.getAttribute("data-krate-scroll")!=="false"}))}function es(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 a;try{a=n?new FormData(t,n):new FormData(t)}catch{a=new FormData(t),n&&n.name&&a.append(n.name,n.value)}let u=new URLSearchParams;for(let[l,c]of a.entries()){if(typeof c!="string")return;u.append(l,c)}e.preventDefault(),s.search=u.toString(),s.hash="",fn({url:s.href,kind:"push",scroll:!0})}function ts(e){ft(w);let t=nn(e.state),n=location.href;if($(n)===V){w=t||w;let i=t?z.get(t):void 0;i!==void 0?window.scrollTo(0,i):Vr(location.hash),ln();return}let r=t?pt.get(t):void 0;if(r&&t&&r.path===$(n)&&r.path===re&&tl(r,t))return;let o=e.state&&typeof e.state=="object"?e.state.__kint:null;if(o&&o.base===re){let i=Wr(n);if(i&&i.slot.key===o.key){zr({url:n,kind:"pop",scroll:!1,restoreKey:t},i);return}}dn({url:n,kind:"pop",scroll:!0,restoreKey:t})}function ns(){Dr(),is()}function rs(){ft(w);try{history.scrollRestoration="auto"}catch{}}function os(){try{history.scrollRestoration="manual"}catch{}}function sn(){Ui(),cn(),Wi(document),document.querySelectorAll("script[src]").forEach(e=>{Nr.test(e.src)||e.setAttribute("data-krate-spa","")})}function is(){if(!G||typeof location>"u")return typeof location<"u"&&location.reload(),Promise.resolve();if(V!==re){let e=Wr(location.href);if(e&&e.slot.src==="intercept")return zr({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0},e)}return dn({url:location.href,kind:"refresh",scroll:!1,bypassCache:!0})}function ss(e,t={}){return G?fn({url:e,kind:"push",scroll:t.scroll!==!1,state:t.state}):(typeof location<"u"&&location.assign(e),Promise.resolve())}function as(e,t={}){return G?fn({url:e,kind:"replace",scroll:t.scroll!==!1,state:t.state}):(typeof location<"u"&&location.replace(e),Promise.resolve())}var ol={push:ss,replace:as,back(){typeof history<"u"&&history.back()},forward(){typeof history<"u"&&history.forward()},refresh:is,prefetch(e){if(!G||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():Kr(t.href)},subscribe:ji,getState:Di,invalidate:Dr};function il(e,t={}){return G?(t.replace?as(e,t):ss(e,t),!1):(typeof location<"u"&&(t.replace?location.replace(e):location.assign(e)),!0)}function us(){if(!(typeof document>"u")){if(G){sn();return}if(G=!0,V=$(location.href),ne=Gi(document),re=V,w=nn(history.state)||ve(),nn(history.state)===void 0)try{history.replaceState(ct(w,history.state),"",location.href)}catch{}try{history.scrollRestoration="manual"}catch{}document.addEventListener("click",Zi),document.addEventListener("submit",es),window.addEventListener("popstate",ts),window.addEventListener("krate:revalidate",ns),window.addEventListener("pagehide",rs),window.addEventListener("pageshow",os),Uu(),Bu(),sn()}}function sl(){us()}function al(){if(G){G=!1,document.removeEventListener("click",Zi),document.removeEventListener("submit",es),window.removeEventListener("popstate",ts),window.removeEventListener("krate:revalidate",ns),window.removeEventListener("pagehide",rs),window.removeEventListener("pageshow",os),document.removeEventListener("mouseover",rn),document.removeEventListener("focusin",rn);for(let e of st.values())clearTimeout(e);st=new Map,be&&(be.disconnect(),be=null),N&&N.abort(),N=void 0,te++,D.clear(),it.clear(),z.clear(),en.clear(),at.clear(),tn="idle",ut=[],ne=[],pt.clear(),re=""}}function qr(e,t){if(!(e==null||e===!1||e===!0||e==="")){if(typeof e=="string"||typeof e=="number"){t.push(String(e));return}if(Array.isArray(e)){for(let n of e)qr(n,t);return}if(typeof e=="object")for(let n of Object.keys(e))e[n]&&t.push(n)}}function Gr(...e){let t=[];for(let n of e)qr(n,t);return t.join(" ")}function $r(...e){let t=[];for(let o of e)qr(o,t);let n=new Map,r=[];for(let o of t){let i=ul(o);n.has(i)||r.push(i),n.set(i,o)}return r.map(o=>n.get(o)).join(" ")}function ul(e){let t=e,n="",r=t.lastIndexOf(":");r>=0&&(n=t.slice(0,r+1),t=t.slice(r+1));let o=t.indexOf("-"),i=o>=0?t.slice(0,o):t,s=o>=0?t.slice(o+1,o+2):"";return n+i+(s&&/[0-9]/.test(s)?"-"+s:"")}function ll(...e){return $r(Gr(...e))}function cl(e,t){let n=t?.variants??{},r=t?.defaultVariants??{};return o=>{let i={};for(let u of Object.keys(n)){let l=o?.[u]??r[u];l!=null&&(i[u]=String(l))}let s=[e];for(let u of Object.keys(n)){let l=i[u];l&&n[u][l]&&s.push(n[u][l])}for(let u of t?.compoundVariants??[])if(dl(u,i,r)){let l=u.class;typeof l=="string"&&s.push(l)}let a=o?.class??o?.className;return typeof a=="string"&&s.push(a),$r(Gr(s))}}function dl(e,t,n){for(let r of Object.keys(e)){if(r==="class")continue;let o=e[r],i=t[r]??n[r]??void 0;if(Array.isArray(o)){if(!o.includes(i))return!1}else if(o!==i)return!1}return!0}function fl(e){let t=ls(e?.children);return t?(cs(t,e),t):null}function ls(e){if(e==null)return null;if(Array.isArray(e)){for(let t of e){let n=ls(t);if(n)return n}return null}return e instanceof Node?e:null}function cs(e,t){if(e instanceof Element)for(let n of Object.keys(t)){if(n==="children"||n==="ref")continue;let r=t[n];if(!(r==null||r===!1)){if(n==="class"||n==="className"){let o=e.getAttribute("class"),i=o?o+" "+String(r):String(r);e.setAttribute("class",i);continue}if(n==="style"&&typeof r=="object"){for(let[o,i]of Object.entries(r))e.style.setProperty(pl(o),String(i));continue}if(n.startsWith("on")&&typeof r=="function"){e[n]=r;continue}if(r===!0){e.setAttribute(n,"");continue}e.setAttribute(n,String(r))}}}function pl(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function gl(e,t,...n){if(!(e instanceof Node))return e;if(t&&cs(e,t),n.length>0&&e instanceof Element){e.textContent="";for(let r of n)r instanceof Node?e.appendChild(r):r!=null&&e.appendChild(document.createTextNode(String(r)))}return e}var X=null,ml=0,oe=new Map,gt=new Map,mt=new Map,Xr=!1,pn=0,gn=[];function ds(e,t,n,r,o,i,s){let a={id:e,name:t,parent:n,creator:r,children:[],order:ml++,state:"dormant",boundary:null,blocked:!1,inError:!1,cond:o,branch:i,setup:s,data:{},cleanups:[]};return n&&n.children.push(a),a}function mn(){return X}function hl(e,t=X){let n=ds("",e,t||null,t||null,"","",null);return n.state=t&&t.state!=="mounted"?"dormant":"mounted",t||ms(),n}function Ve(e,t){if(!e)return t();let n=e;if(n.state!=="mounted")return;let r=X;X=n;try{return E(t)}catch(o){q(o,n);return}finally{X=r}}function hn(e,t){let n=e;if(n.state!=="mounted"){vl(t,n);return}n.cleanups.push(t)}function Qr(e,t){e.boundary=t}function fs(e){let t="";for(let n=e;n;n=n.parent)t+=`
2
+ at `+n.name;return t}function q(e,t=X){if(!t)throw e;let n={componentStack:fs(t)};for(let r=t.parent;r;r=r.parent){if(r.state!=="mounted"||!r.boundary)continue;let o=!1;try{o=r.boundary(e,n,t)}catch(i){q(i,r);return}if(o)return}bl(e,n,t)}function bl(e,t,n){let r=globalThis;try{let o=String(e?.stack||e?.message||e);Array.isArray(r.__krateErrs)&&r.__krateErrs.push(o)}catch{}typeof console<"u"&&(console.error(e),console.error("The above error occurred in the <"+n.name+"> component:"+t.componentStack+`
3
+
4
+ Add an error boundary (a class component with static getDerivedStateFromError) to recover from it.`)),n.blocked=!0,bn(n)}function vl(e,t){try{e()}catch(n){t&&t.parent?q(n,t):ps(n)}}function ps(e){typeof console<"u"&&console.error(e)}function bn(e){ye(e,"dormant")}function Yr(e){let t=e;t.state==="dormant"&&(t.blocked=!1,Ue(t)&&Be(t))}function Zr(e){for(let t of e.children)ye(t,"dormant")}function vn(e){if(e.state==="mounted")for(let t of e.children.slice())t.blocked=!1,t.state==="dormant"&&Ue(t)&&Be(t)}function ye(e,t){if(e.state==="mounted"){e.state=t;let n=[];for(let r of e.cleanups.splice(0))try{r()}catch(o){n.push(o)}if(e.id)try{or(e.id)}catch(r){n.push(r)}for(let r of e.children)ye(r,t);for(let r of n)e.parent?q(r,e):ps(r);return}if(t==="disposed"&&e.state!=="disposed"){e.state="disposed";for(let n of e.children)ye(n,t)}}function gs(e){if(!e.cond)return!0;let t=gt.get(e.cond);return t===void 0||t===e.branch}function Ue(e){return e.blocked||!gs(e)?!1:!e.parent||e.parent.state==="mounted"}function Be(e){if(e.state!=="dormant")return;e.state="mounted",pn++;let t=He();try{e.setup&&Ve(e,e.setup)}finally{I(t),pn--}if(e.state==="mounted")for(let n of e.children.slice())n.state==="dormant"&&Ue(n)&&Be(n);if(pn===0&&gn.length>0){let n=gn.splice(0).sort((r,o)=>r.order-o.order);for(let r of n)r.state==="dormant"&&Ue(r)&&Be(r)}}function ms(){Xr||(Xr=!0,P(yl))}function yl(){let e=[];for(let t of oe.values())t.parent||e.push(t);for(let t of e)ye(t,"disposed");oe.clear(),gt.clear(),mt.clear(),gn.length=0,Xr=!1}function kl(e,t,n){let r=t||{},o=oe.get(e);o&&ye(o,"disposed");let i=r.p&&oe.get(r.p)||null,s=r.k&&oe.get(r.k)||null,a=ds(e,r.n||e,i,s,r.c||"",r.b||"",n);if(oe.set(e,a),ms(),a.cond){let u=mt.get(a.cond);u||(u=[],mt.set(a.cond,u)),u.push(a)}i&&i.inError&&gs(a)&&(a.blocked=!0),Ue(a)&&Be(a)}function wl(e){return oe.get(e)||null}function Tl(e,t){let n=gt.get(e);if(n===void 0||n===(t?"c":"a"))return;let o=mt.get(e);if(o)for(let i of o)i.branch===n&&i.state==="mounted"&&ye(i,"dormant")}function El(e,t){let n=t?"c":"a",r=gt.get(e);if(gt.set(e,n),r===n)return;let o=mt.get(e);if(o)for(let i of o)i.branch!==n||i.state!=="dormant"||!Ue(i)||(pn>0?gn.push(i):Be(i))}function Sl(e,t){return!X||t&&t.isConnected===!1?!1:(q(e,X),!0)}ir((e,t)=>{let n=t?oe.get(t):void 0;if(!n)return!1;if(n.state==="mounted"){Jr++;try{q(e,n)}finally{Jr--}}return!0});var Jr=0;function eo(){return Jr>0}In({current:()=>X,run:(e,t)=>{Ve(e,t)},cleanup:(e,t)=>hn(e,t),error:(e,t)=>{let n=e;return n.state==="mounted"&&q(t,n),!0}});var xl=0,hs=Symbol.for("krate.class.rawProps"),no=class{constructor(t,n,r,o){this.seq=xl++;this.rawGetters=[];this.queue=[];this.forced=!1;this.parentRender=!1;this.mounted=!1;this.disposed=!1;this.catching=!1;this.detachRef=null;this.errorCommitPending=!1;this.spec=o||{},this.owner=mn(),this.raw=t&&typeof t=="object"?t:{},this.getState=n,this.setStateSignal=r;let s=this.raw[hs];if(!s){s=[];for(let d of Object.keys(this.raw)){let f=Object.getOwnPropertyDescriptor(this.raw,d);if(f&&f.get){let m=f.get,k=this.raw;s.push([d,()=>m.call(k)])}}try{Object.defineProperty(this.raw,hs,{value:s,enumerable:!1,configurable:!0})}catch{}}this.rawGetters.push(...s),this.props=this.readProps(),this.key=this.readKey(),this.state=E(n)||{},this.context=this.readContext();let[a,u]=H(this.props);this.setRendered=u,this.gateProps(a);let l=this,c={get props(){return l.props},get state(){return l.state},set state(d){l.state=d},get context(){return l.context},setState(d,f){l.enqueue({partial:d,callback:f})},forceUpdate(d){l.forced=!0,l.enqueue({partial:null,callback:d})}};if(this.inst=c,this.owner&&(this.owner.data.classController=this,hn(this.owner,()=>this.unmount()),(this.spec.getDerivedStateFromError||this.spec.componentDidCatch)&&Qr(this.owner,(d,f)=>this.catchError(d,f))),this.spec.setContext&&this.spec.setContext(this.context),this.rawGetters.length>0||this.spec.context){let d=!0;S(()=>{for(let[,f]of this.rawGetters)f();if(this.trackContext(),d){d=!1;return}this.disposed||(ke.add(this),bs())})}We(this,()=>{let d=this.spec.expose?E(this.spec.expose):null;if(d)for(let m of Object.keys(d))m in this.inst||(this.inst[m]=d[m]);this.mounted=!0,this.spec.componentDidMount&&this.spec.componentDidMount.call(this.inst);let f=E(()=>this.raw.ref);f&&(this.detachRef=Ft(f,this.inst))});let g=this.spec.buildError;if(g&&this.spec.componentDidCatch){let d=new Error(g.message||"Error");g.name&&(d.name=g.name),this.owner&&(this.owner.inError=!0),We(this,()=>{this.spec.componentDidCatch.call(this.inst,d,{componentStack:`
5
+ at `+(this.spec.name||"Component")+" (build)"})})}else g&&this.owner&&(this.owner.inError=!0)}readProps(){let t={};E(()=>{for(let r of Object.keys(this.raw)){if(r.startsWith("__krate")||r==="ref"||r==="key")continue;let o=this.rawGetters.find(i=>i[0]===r);t[r]=o?o[1]():this.raw[r]}});let n=this.spec.defaultProps;if(n)for(let r of Object.keys(n))t[r]===void 0&&(t[r]=n[r]);return t}readContext(){return E(()=>this.trackContext())}trackContext(){let t=this.spec.context;if(!t)return;let n=t();if(typeof n=="function"){for(let r of Object.keys(this.raw))if(r.startsWith("__krate_ctx_")&&this.raw[r]===n)return n()}return n}gateProps(t){let n=new Set;for(let[o]of this.rawGetters)n.add(o);let r=this.spec.defaultProps;if(r)for(let o of Object.keys(r))this.raw[o]===void 0&&n.add(o);for(let o of n)if(!(o.startsWith("__krate")||o==="ref"||o==="key"))try{Object.defineProperty(this.raw,o,{get:()=>t()[o],enumerable:!0,configurable:!0})}catch{}}enqueue(t){this.disposed||(this.queue.push(t),ke.add(this),bs())}markParentRender(){this.disposed||!this.mounted||(this.parentRender=!0,ke.add(this))}performUpdate(){if(!(this.disposed||this.owner&&this.owner.state!=="mounted"))if(this.owner)Ve(this.owner,()=>this.update());else try{this.update()}catch(t){console.error(t)}}readKey(){let t=this.rawGetters.find(n=>n[0]==="__krate_key");return E(()=>t?t[1]():this.raw.__krate_key)}update(){let t=this.spec,n=this.inst;if(!Object.is(this.readKey(),this.key)&&this.owner){let h=this.owner;bn(h),h.inError=!1,Yr(h),vn(h);return}let r=this.readProps(),o=this.readContext(),i=!to(r,this.props)||o!==this.context,s=this.queue;this.queue=[];let a=this.forced;this.forced=!1;let u=this.parentRender;if(this.parentRender=!1,s.length===0&&!a&&!i&&!u)return;let l=!t.getDerivedStateFromProps&&!t.getSnapshotBeforeUpdate;l&&(i||u)&&t.componentWillReceiveProps&&(t.componentWillReceiveProps.call(n,r,o),s.push(...this.queue),this.queue=[]);let c=this.props,g=this.state,d=g,f=[];for(let h of s){let x=typeof h.partial=="function"?h.partial.call(n,d,r):h.partial;x!=null&&typeof x=="object"&&(d={...d,...x}),typeof h.callback=="function"&&f.push(h.callback)}if(t.getDerivedStateFromProps){let h=t.getDerivedStateFromProps(r,d);h!=null&&(d={...d,...h})}let m=!0;if(a||(t.shouldComponentUpdate?m=!!t.shouldComponentUpdate.call(n,r,d,o):t.pure&&(m=!to(c,r)||!to(g,d))),m&&l&&t.componentWillUpdate&&t.componentWillUpdate.call(n,r,d,o),this.props=r,this.state=d,this.context=o,!m){for(let h of f)We(this,()=>h.call(n));return}let k=t.getSnapshotBeforeUpdate?t.getSnapshotBeforeUpdate.call(n,c,g):void 0;this.setRendered(r),t.setContext&&t.setContext(o),this.setStateSignal(a&&d===g?{...d}:d),a&&d===g&&(this.state=E(this.getState)),this.owner&&this.owner.inError&&!this.errorCommitPending&&this.owner&&(this.owner.inError=!1,ht.add(this.owner)),We(this,()=>{t.componentDidUpdate&&t.componentDidUpdate.call(n,c,g,k)});for(let h of f)We(this,()=>h.call(n));this.cascade()}cascade(){let t=this.owner;if(!t)return;let n=o=>{for(let i=o?o.creator:null;i;i=i.creator){if(i===t)return!0;if(i.data.classController)return!1}return!1},r=o=>{for(let i of o.children){if(i.state!=="mounted")continue;let s=i.data.classController;s&&n(i)&&s.markParentRender(),r(i)}};r(t)}catchError(t,n){let r=this.spec,o=this.owner;if(this.disposed||!o||o.state!=="mounted")return!1;if(this.catching)return!0;this.catching=!0;try{typeof console<"u"&&(console.error(t),console.error("The above error occurred in the <"+(n.componentStack.match(/at (\S+)/)?.[1]||"Unknown")+"> component:"+n.componentStack+`
6
+
7
+ React will try to recreate this component tree from scratch using the error boundary you provided, `+(r.name||"Component")+".")),o.inError=!0;let i=o.children.filter(c=>c.state==="mounted");Zr(o);for(let c of i)c.blocked=!0;let s=this.state;if(r.getDerivedStateFromError){this.mounted&&!ro&&!eo()&&r.getDerivedStateFromError(t);let c=r.getDerivedStateFromError(t);c!=null&&(s={...s,...c})}else typeof console<"u"&&console.error((r.name||"Component")+": Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.");let a=this.props,u=this.state,l=this.mounted;this.state=s,this.errorCommitPending=!0,this.setStateSignal(s),We(this,()=>{this.errorCommitPending=!1,l&&s!==u&&r.componentDidUpdate&&r.componentDidUpdate.call(this.inst,a,u,void 0),r.componentDidCatch&&r.componentDidCatch.call(this.inst,t,n)})}finally{this.catching=!1}return!0}unmount(){if(this.disposed)return;this.disposed=!0,ke.delete(this);let t=this.detachRef;this.detachRef=null,t&&t(),this.mounted&&this.spec.componentWillUnmount&&this.spec.componentWillUnmount.call(this.inst),this.mounted=!1}runLifecycle(t){if(!this.disposed)if(this.owner)Ve(this.owner,t);else try{t()}catch(n){console.error(n)}}};function to(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}var ke=new Set,ht=new Set,yn=[],Al=0,kn=!1;function bs(){Mt()}function We(e,t){yn.push({c:e,fn:t,n:Al++}),kn||(kn=!0,Mt())}function Hl(e,t){return e.owner&&t.owner?e.owner.order-t.owner.order:e.seq-t.seq}function vs(e,t){for(let n=t.parent;n;n=n.parent)if(n===e)return!0;return!1}function Cl(e,t){let n=e.c.owner,r=t.c.owner;return n&&r&&n!==r?vs(n,r)?1:vs(r,n)?-1:n.order-r.order:n===r?e.n-t.n:e.c.seq-t.c.seq||e.n-t.n}function Ll(){for(let e=0;ke.size>0&&e<1e3;e++){let t=Array.from(ke).sort(Hl);ke.clear(),Fn(()=>{for(let n of t)n.performUpdate()})}}var ro=!1;function Ml(){kn=!1,ro=!0;try{Rl()}finally{ro=!1}}function Rl(){if(ht.size>0){let e=Array.from(ht).sort((t,n)=>t.order-n.order);ht.clear();for(let t of e)vn(t)}if(yn.length>0){let e=yn.splice(0).sort(Cl);for(let t of e)t.c.runLifecycle(t.fn)}}Qn(Ll);sr(()=>{(kn||yn.length>0||ht.size>0)&&Ml()});function ys(e,t,n,r){return new no(e,t,n,r).inst}var Ol=["shouldComponentUpdate","getSnapshotBeforeUpdate","componentDidMount","componentDidUpdate","componentWillUnmount","componentDidCatch","componentWillReceiveProps","componentWillUpdate"];function Pl(e,t,n){let r=new e(t),[o,i]=H(r.state||{}),s={name:e.displayName||e.name,pure:!!e.prototype.isPureReactComponent,defaultProps:e.defaultProps||null,getDerivedStateFromProps:e.getDerivedStateFromProps,getDerivedStateFromError:e.getDerivedStateFromError};for(let l of Ol){let c=r[l]??r["UNSAFE_"+l];typeof c=="function"&&(s[l]=(...g)=>c.apply(r,g))}let a=ys(t,o,i,s);Object.defineProperty(r,"props",{get:()=>a.props,configurable:!0}),Object.defineProperty(r,"state",{get:()=>a.state,set:l=>{a.state=l},configurable:!0}),r.setState=a.setState,r.forceUpdate=a.forceUpdate;let u=document.createElement("div");return u.style.display="contents",S(()=>{o();let l=E(()=>n(r.render()));u.replaceChildren(l)}),u}function _l(e){q(e,mn())}var oo="__krate_args",bt=class extends Error{constructor(t,n,r){super(t),this.name="ServerActionError",this.status=n,r&&(this.digest=r)}};function Nl(){let e=globalThis.__KRATE_CFG__;return e&&e.basePath?e.basePath:""}function Il(e){return typeof e=="function"&&typeof e.$$krateAction=="string"}function Fl(e){let t=globalThis.navigate;typeof t=="function"?t(e):typeof location<"u"&&location.assign(e)}function Dl(e){if(typeof window>"u"||typeof CustomEvent>"u")return;let t={paths:e&&Array.isArray(e.paths)?e.paths:[],tags:e&&Array.isArray(e.tags)?e.tags:[]};window.dispatchEvent(new CustomEvent("krate:revalidate",{detail:t}))}function jl(e,t,n){let r=e?e.error:void 0;if(r&&typeof r=="object")return new bt(r.message||"Server action failed",t,r.digest);let o=e&&(e.details||(typeof r=="string"?r:""))||n||"Server action failed";return new bt(o,t)}async function so(e,t){let n={accept:"application/json","x-krate-action":"fetch"};typeof location<"u"&&(n["x-krate-return"]=location.pathname+location.search);let r,o=t[t.length-1];if(typeof FormData<"u"&&o instanceof FormData){let a=new FormData;o.forEach((l,c)=>{c!==oo&&a.append(c,l)});let u=t.slice(0,-1);u.length>0&&a.set(oo,JSON.stringify(u)),r=a}else n["content-type"]="application/json",r=JSON.stringify({args:t});let i=await fetch(e,{method:"POST",credentials:"same-origin",headers:n,body:r}),s=null;try{s=await i.json()}catch{s=null}if(!i.ok||!s||s.ok===!1)throw jl(s,i.status,i.statusText);return s.revalidated&&Dl(s.revalidation),typeof s.redirect=="string"&&s.redirect&&Fl(s.redirect),s.result}function Ts(e,t){let n=Nl()+"/__krate/action/"+e,r=function(...o){return so(n,t.concat(o))};return Object.defineProperty(r,"actionUrl",{value:n}),Object.defineProperty(r,"$$krateAction",{value:e}),Object.defineProperty(r,"$$krateBound",{value:t}),Object.defineProperty(r,"bind",{value:(o,...i)=>Ts(e,t.concat(i))}),r.toString=()=>n,r}function Kl(e){return Ts(e,[])}var ze=0,io=new Set;function ao(){ze++;let e=!1;return()=>{e||(e=!0,ze--,ze===0&&ce(()=>{for(let t of Array.from(io))t()}))}}function Ul(){return ze>0}var Es=e=>{let t=ao(),n;try{n=e()}catch(r){return t(),Promise.reject(r)}return Promise.resolve(n).finally(t)},Ss=Es;function Bl(e){Ss=e||Es}function uo(e){return Ss(e)}function lo(e,t){let n=globalThis;if(typeof n.__krateActionError=="function")try{if(n.__krateActionError(e,t)===!0)return}catch{}let r=t||(typeof document<"u"?document:null),o=!1;if(r&&typeof CustomEvent<"u"){let i=new CustomEvent("krate:action-error",{bubbles:!0,cancelable:!0,detail:{error:e}});o=!r.dispatchEvent(i)}o||console.error("krate server action:",e)}var co=Object.freeze({pending:!1,data:null,method:null,action:null}),wn=new WeakMap;function xs(e){let t=wn.get(e);return t||(t={status:co,subs:new Set,running:0,resetRequested:!1},wn.set(e,t)),t}function ks(e,t){e.status=t;for(let n of Array.from(e.subs))n(t)}function Vl(e,t){let n=null;for(let i=e?e.parentElement:null;i;i=i.parentElement)if(i.tagName==="FORM"){n=i;break}if(!n)return()=>{};let r=xs(n),o=i=>{t.status&&t.status(i),t.pending&&t.pending(i.pending),t.data&&t.data(i.data),t.method&&t.method(i.method),t.action&&t.action(i.action)};return r.subs.add(o),o(r.status),()=>{r.subs.delete(o)}}function Wl(e,t){typeof e=="function"?e(t):e&&typeof e=="object"&&(e.current=t)}function zl(e){return wn.get(e)?.status||co}function As(e){let t=Array.from(e.querySelectorAll("[data-kattr-value],[data-kattr-checked]")).map(n=>({el:n,value:n.value,checked:n.checked}));e.reset();for(let n of t)n.el.hasAttribute("data-kattr-value")&&(n.el.value=n.value),n.el.hasAttribute("data-kattr-checked")&&(n.el.checked=n.checked)}function ql(e){let t=wn.get(e);if(t&&t.running>0){t.resetRequested=!0;return}As(e)}function Gl(e,t){e.__krateFormAction=t,e.tagName==="FORM"?(e.removeAttribute("action"),e.removeAttribute("method")):(e.removeAttribute("formaction"),e.removeAttribute("formmethod")),e.removeAttribute("data-krate-action")}function ws(e){if(!e)return null;let t=e.__krateFormAction;if(typeof t!="function")return null;try{return t()}catch{return null}}function $l(e,t){if(t&&t!==e){let r=ws(t);if(typeof r=="function")return{fn:r};if(t.hasAttribute("data-krate-action"))return{url:t.formAction||e.action};if(t.hasAttribute("formaction"))return null}let n=ws(e);return typeof n=="function"?{fn:n}:e.hasAttribute("data-krate-action")?{url:e.action}:null}function Xl(e,t){let n;try{n=t?new FormData(e,t):new FormData(e)}catch{n=new FormData(e);let r=t;r&&r.name&&n.append(r.name,r.value)}return n}function Jl(e){let t=e.indexOf("?");return t<0?e:e.slice(0,t)}async function Hs(e,t,n,r=null,o){let i=xs(e),s=(r&&r.getAttribute("formmethod")||e.getAttribute("method")||"get").toLowerCase();i.running++,ks(i,{pending:!0,data:n,method:s,action:t||o||null}),e.setAttribute("data-krate-action-pending","1");let a=!1;try{await uo(async()=>{let u=t;if(u&&typeof u.__krateRun=="function"){a=await u.__krateRun(n);return}typeof u=="function"?await u(n):o&&await so(Jl(o),[n]),a=!0})}catch(u){lo(u,e)}finally{i.running--,i.running===0&&(e.removeAttribute("data-krate-action-pending"),ce(()=>ks(i,co)),(a||i.resetRequested)&&(i.resetRequested=!1,a&&e.hasAttribute("data-krate-reload")?location.reload():As(e)))}return a}function Ql(e){let t=e.target;if(!t||t.tagName!=="FORM"||e.defaultPrevented)return;let n=e.submitter||null,r=$l(t,n);if(!r)return;e.preventDefault();let o=Xl(t,n);xe("submit",!0,()=>{Hs(t,r.fn,o,n,r.url)})}function Cs(e=typeof document<"u"?document:void 0){if(!e)return;let t=e.defaultView;!t||t.__krateActionBound||(t.__krateActionBound=!0,e.addEventListener("submit",Ql,!1))}function Yl(e,t,n,r){let o=[],i=!1,s=async()=>{for(i=!0;o.length>0;){let l=o.shift(),c=!1;try{let g=await uo(()=>e(t(),l.payload));ce(()=>n(g)),c=!0}catch(g){let d=o.splice(0);for(let f of d)f.end(),f.done(!1);lo(g)}finally{ce(()=>{l.end(),l.done(c)})}}i=!1,ce(()=>r(!1))},a=l=>new Promise(c=>{o.push({payload:l,end:ao(),done:c}),r(!0),i||s()}),u=(l=>{a(l)});return u.__krateRun=a,u}function Zl(e,t,n){let r=[],o=s=>{let a=s;for(let u of r)a=n?n(a,u):u;return a};S(()=>{t(o(e()))});let i=()=>{r.length!==0&&(r=[],t(e()))};return io.add(i),P(()=>{io.delete(i)}),s=>{r.push(s),t(o(e())),ze===0&&queueMicrotask(()=>{ze===0&&i()})}}typeof document<"u"&&Cs(document);return _s(ec);})();
2
8
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
@@ -0,0 +1,2 @@
1
+ var __krate_exports=(()=>{var O=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var he=Object.prototype.hasOwnProperty;var Te=(e,n)=>{for(var t in n)O(e,t,{get:n[t],enumerable:!0})},we=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of pe(n))!he.call(e,r)&&r!==t&&O(e,r,{get:()=>n[r],enumerable:!(o=fe(n,r))||o.enumerable});return e};var ve=e=>we(O({},"__esModule",{value:!0}),e);var De={};Te(De,{SuspenseSignal:()=>g,__krateBoundary:()=>Be,__krateLazy:()=>Re,__krateLazyPayload:()=>Ne,__krateLazyRun:()=>Me,__krateRead:()=>Oe,__krateTransitionStarter:()=>te,__krateUse:()=>Ce,boundarySlotId:()=>le,connectActionTransitions:()=>ne,connectErrorBoundaries:()=>be,createBoundary:()=>se,createDeferredValue:()=>ce,createExternalStore:()=>de,currentBoundary:()=>ue,getBoundary:()=>q,isInTransition:()=>Z,isSuspenseSignal:()=>D,isThenable:()=>_,noteFallbackShown:()=>m,readValue:()=>Q,registerBoundary:()=>Ae,reportSuspenseError:()=>y,resetBoundaries:()=>Ee,runAsyncTransition:()=>C,setFallbackThrottle:()=>Pe,setLazyChunkImporter:()=>je,setSuspenseErrorHandler:()=>ge,startTransition:()=>xe,suspendOn:()=>$,trackThenable:()=>z,useDeferredValue:()=>Ve,useSyncExternalStore:()=>ze,useTransition:()=>Se,withReplayScope:()=>ke});var w=(...e)=>window.createSignal(...e),R=(...e)=>window.createEffect(...e),F=(...e)=>window.onCleanup(...e),G=(...e)=>window.krateGetOwner(...e),L=(...e)=>window.krateSetOwner(...e);var W=new WeakSet;function _(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function z(e){return W.has(e)||(W.add(e),e.status==="fulfilled"||e.status==="rejected")||(e.status="pending",e.then(n=>{e.status==="pending"&&(e.status="fulfilled",e.value=n)},n=>{e.status==="pending"&&(e.status="rejected",e.reason=n)})),e}var g=class{constructor(n){this.thenable=n}};function D(e){return e instanceof g}function A(){}var ye=Symbol.for("krate.context"),S=null;function E(e,n){let t=S;S=e;try{return n()}finally{S=t}}function ke(e,n){return e.i=0,E(e,n)}function Q(e){let n=e;if(n&&(typeof n=="object"||typeof n=="function")&&typeof n.useContext=="function"&&(n.$$typeof===ye||!_(e)))return n.useContext();if(!_(e))return e;let t=e,o=S;if(o){let r=o.i++,i=o.list[r];i!==void 0&&i!==t?(t.then(A,A),t=i):o.list[r]=t}if(z(t),t.status==="fulfilled")return t.value;throw t.status==="rejected"?t.reason:new g(t)}var N=null;function ge(e){N=e}var j=null;function be(e){j=e}function Y(){if(j)return j;let e=globalThis;return typeof e.getOwner=="function"&&typeof e.handleError=="function"?{getOwner:e.getOwner,handleError:e.handleError}:null}function I(){let e=Y();return e?e.getOwner():null}function y(e,n,t){if(N&&N(e,n)===!0)return;let o=t?Y():null;if(o){o.handleError(e,t);return}let r=globalThis;typeof r.__krateReportError=="function"&&r.__krateReportError(e,n?n.anchor:null)===!0||console.error("[krate] uncaught error in suspended work:",e)}var M=class{constructor(){this.count=0;this.error=void 0;this.failed=!1;this.settled=!1;this.signal=null;this.pending=()=>(this.signal||(this.signal=w(!this.settled)),this.signal[0]());this.promise=new Promise((n,t)=>{this.resolve=n,this.reject=t}),this.promise.catch(A)}add(){this.count++}release(){--this.count>0||(this.settled=!0,this.signal?.[1](!1),this.failed?this.reject(this.error):this.resolve())}wait(n){this.add();let t=()=>this.release();n.then(t,t)}},k=null;function Z(){return B()!==null}function C(e,n){let t=n?.report!==!1,o=new M,r=me();o.promise.then(r,r),o.add();let i=k;k=o;let l;try{l=e()}catch(s){return o.failed=!0,o.error=s,k=i,o.release(),t&&y(s,null),o}return k=i,_(l)&&(o.add(),l.then(()=>o.release(),s=>{o.failed=!0,o.error=s,o.release(),t&&y(s,null)})),P=o,queueMicrotask(()=>{P===o&&(P=null),o.release()}),o}var ee=null;function me(){let e=ee??globalThis.__krateBeginAction;return typeof e=="function"?e():A}function ne(e){let n=e??globalThis;e?.__krateBeginAction&&(ee=e.__krateBeginAction),typeof n.setActionTransitionRunner=="function"&&n.setActionTransitionRunner(t=>{let o,r=!1,i,l=C(()=>{try{o=t()}catch(s){throw r=!0,i=s,s}return o},{report:!1});return r?Promise.reject(i):Promise.resolve(o).then(s=>l.promise.then(()=>s))})}var P=null;function B(){return k??P}function xe(e){C(e)}function te(e){let n=0;return t=>{n++,e(!0);let o=C(t),r=()=>{--n===0&&e(!1)};o.promise.then(r,r)}}function Se(){let[e,n]=w(!1);return[e,te(n)]}var oe=300,re=-1/0;function ie(){return typeof performance<"u"?performance.now():Date.now()}function m(){re=ie()}function Pe(e){oe=e}var H=class{constructor(n,t,o,r){this.pending=new Set;this.holds=0;this.scheduled=!1;this.throttle=null;this.id=n,this.anchor=t,this.content=o,this.apply=r}get pendingCount(){return this.pending.size}showingContent(){return this.content}suspend(n,t=!1){if(t&&this.content){B()?.wait(n);return}if(this.pending.has(n))return;this.pending.add(n),this.update();let o=()=>{this.pending.delete(n),this.schedule()};n.then(o,o)}hold(){this.holds++}release(){this.holds>0&&this.holds--,this.schedule()}schedule(){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{queueMicrotask(()=>{this.scheduled=!1,this.update()})}))}update(){let n=this.pending.size===0&&this.holds===0;if(n!==this.content){if(n){let t=re+oe-ie();if(t>0){this.throttle===null&&(this.throttle=setTimeout(()=>{this.throttle=null,this.update()},t));return}}else m();this.content=n,this.apply(n),n&&V&&V(this)}}},V=null;function se(e,n,t){return new H(e,t?.anchor??null,t?.initialContent??!0,n)}var b=new Map;function le(e){return"s"+e}function q(e){let n=le(e),t=globalThis,o=typeof t.findSlot=="function"?t.findSlot(n):null,r=b.get(e);if(r&&(o===null||r.anchor===o))return r;let i=typeof document<"u"?document.querySelector('template[data-kc="'+n+'"]'):null,l=!i||i.getAttribute("data-kb")!=="c",s=globalThis.krateCondActivity,c=o&&o.nodeType===8?_e(o,i,l):null,p=se(e,h=>{c&&(s&&!h&&s(n,"a"),c(h),s&&h&&s(n,"c"))},{anchor:o,initialContent:l});return!l&&o&&o.isConnected&&m(),b.set(e,p),p}V=e=>{for(let n of b.values())if(n!==e&&!n.showingContent()&&n.anchor&&n.anchor.isConnected){m();return}};function _e(e,n,t){let o="/"+(e.nodeValue||""),r=()=>{for(let d=e.nextSibling;d;d=d.nextSibling)if(d.nodeType===8&&d.nodeValue===o)return d;return null},i=()=>{let d=[],u=r();for(let a=e.nextSibling;a&&a!==u;a=a.nextSibling)d.push(a);return d},l=t?i():[],s=t?[]:i(),c=!1,f=()=>!n||c?[]:(c=!0,Array.from(n.content.childNodes)),p=new Map,h=d=>{let u=e.parentNode;if(!u)return;let a=r();for(let T of d)u.insertBefore(T,a)},x=d=>{for(let u of d)u.parentNode?.removeChild(u)};return d=>{if(d){if(x(s),l.length===0){l=f(),h(l),K();return}for(let u of l){let a=p.get(u);a!==void 0&&(typeof a=="string"?u.nodeValue=a:a[0]===""?u.style.removeProperty("display"):u.style.setProperty("display",a[0],a[1]))}p.clear();return}for(let u of l)if(!p.has(u))if(u.nodeType===1&&u.style){let a=u.style;p.set(u,[a.getPropertyValue("display"),a.getPropertyPriority("display")]),a.setProperty("display","none","important")}else u.nodeType===3&&(p.set(u,u.nodeValue||""),u.nodeValue="");s.length===0&&(s=f()),h(s),K()}}function K(){let e=globalThis.krateRefsEnter;typeof e=="function"&&e()}function Ae(e){b.set(e.id,e)}function Ee(){b.clear()}function $(e,n){let t=B()!==null;e?e.suspend(n,t):t&&B()?.wait(n)}var v=null;function ue(){return v?v.boundary:null}function Be(e,n){let t=e?q(e):null,o={boundary:t,scope:{list:[],i:0},disposers:[]},r=I();t?.hold();let i=()=>{o.scope.i=0;let l=v;v=o;let s=G();try{E(o.scope,n),v=l,L(s),t?.release()}catch(c){v=l,L(s);for(let f of o.disposers.splice(0))f();if(D(c)){c.thenable.then(i,i);return}t?.release(),y(c,t,r)}};i()}function Ce(e){let n=v,t=n?n.boundary:null,o=I(),r=n?n.scope:{list:[],i:0},i=r.i,l=E(r,e),s=r.list.slice(i,r.i),[c,f]=w(l),[p,h]=w(0),x=()=>h(a=>a+1),d=!0,u=R(()=>{p();let a=d?{list:s,i:0}:null;d=!1;try{let T=E(a,e);f(()=>T)}catch(T){if(D(T)){T.thenable.then(x,x),$(t,T.thenable);return}y(T,t,o)}});return n&&n.disposers.push(u),c}function Oe(e){return Q(e)}var U=new Map;function Re(e,n){let t=n?q(n):null,o=I();t?.hold();let r=U.get(e);if(!r){let i=t?t.anchor:null;r=i&&!i.isConnected?Le(i).then(()=>(m(),J(e))):J(e),U.set(e,r)}return r.then(()=>t?.release(),i=>{t?.release(),y(i,t,o)}),r}function Le(e){return e.isConnected||typeof MutationObserver>"u"?Promise.resolve():new Promise(n=>{let t=new MutationObserver(()=>{e.isConnected&&(t.disconnect(),n())});t.observe(document.documentElement,{childList:!0,subtree:!0})})}var X=new WeakMap;function Ne(e){let n=X.get(e);return n||(n=Promise.resolve().then(()=>e()).then(t=>{if(typeof(t&&typeof t=="object"?t.default:void 0)!="function")throw new Error("lazy: the loader did not resolve to a module with a component as its default export (resolve to { default: Component })");return t}),z(n),X.set(e,n)),n}var ae=e=>import(e);function je(e){ae=e}function J(e){try{return Promise.resolve(ae(e))}catch(n){return Promise.reject(n)}}function Me(e){e()}function He(e){setTimeout(e,0)}function ce(e,...n){let t=n.length>0,o,r,i=!1,[l,s]=w(void 0),c=()=>{i=!1,Object.is(o,r)||(r=o,s(()=>o))},f=!0;return R(()=>{if(o=e(),!(f&&(f=!1,r=t?n[0]:o,s(()=>r),!t||Object.is(r,o)))&&!Object.is(o,r)){if(Z()){c();return}i||(i=!0,He(c))}}),l}function Ve(e,...n){return typeof e=="function"?ce(e,...n):e}function de(e,n,t){let o=n();Object.is(o,n())||console.error("[krate] The result of getSnapshot should be cached to avoid an infinite loop");let[r,i]=w(o),l=()=>{let c=n();Object.is(c,o)||(o=c,i(()=>c))},s=e(l);return l(),F(()=>{typeof s=="function"&&s()}),r}function ze(e,n,t){return de(e,n,t)}ne();globalThis.__krateSuspenseHook={current:ue,suspend:(e,n)=>$(e,n)};return ve(De);})();
2
+ for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,59 @@
1
+ import { describe, it, expect, beforeEach } from 'vitest';
2
+ import { createSignal, createEffect, disposeAll, krateHookState } from './signal';
3
+ import { createEffectDeps } from './effects';
4
+ const tick = () => new Promise((r) => setTimeout(r, 0));
5
+ async function settle() {
6
+ for (let i = 0; i < 4; i++)
7
+ await tick();
8
+ }
9
+ describe('mixed update lanes', () => {
10
+ beforeEach(() => disposeAll());
11
+ it('keeps a promise-driven React state write when a plain signal is written in a later microtask', async () => {
12
+ const [user, setUser] = createSignal('nobody', krateHookState);
13
+ const [flag, setFlag] = createSignal(false);
14
+ const text = [];
15
+ const effects = [];
16
+ createEffect(() => void text.push(user() + '/' + flag()));
17
+ createEffectDeps(() => void effects.push('user ' + user()), () => [user()]);
18
+ await settle();
19
+ text.length = 0;
20
+ effects.length = 0;
21
+ await Promise.resolve().then(() => {
22
+ setUser('grace');
23
+ queueMicrotask(() => setFlag(true));
24
+ });
25
+ await settle();
26
+ expect(user()).toBe('grace');
27
+ expect(text[text.length - 1]).toBe('grace/true');
28
+ expect(effects).toEqual(['user grace']);
29
+ });
30
+ it('keeps the React state write when the plain write comes first', async () => {
31
+ const [user, setUser] = createSignal('nobody', krateHookState);
32
+ const [flag, setFlag] = createSignal(false);
33
+ const seen = [];
34
+ createEffect(() => void seen.push(user() + '/' + flag()));
35
+ await settle();
36
+ await Promise.resolve().then(() => {
37
+ setFlag(true);
38
+ setUser('grace');
39
+ });
40
+ await settle();
41
+ expect(seen[seen.length - 1]).toBe('grace/true');
42
+ expect(user()).toBe('grace');
43
+ });
44
+ it('commits a React write made while a microtask flush is already queued', async () => {
45
+ const [user, setUser] = createSignal('nobody', krateHookState);
46
+ const [flag, setFlag] = createSignal(0);
47
+ const seen = [];
48
+ createEffect(() => void seen.push(user() + '/' + flag()));
49
+ createEffectDeps(() => void seen.push('effect ' + user()), () => [user()]);
50
+ await settle();
51
+ seen.length = 0;
52
+ setFlag(1);
53
+ await Promise.resolve();
54
+ setUser('grace');
55
+ await settle();
56
+ expect(seen).toContain('effect grace');
57
+ expect(user()).toBe('grace');
58
+ });
59
+ });
package/dist/list.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import { type KrateAdoptable } from './dom.js';
2
+ type KeyFn = ((item: unknown, index: number) => unknown) | null;
3
+ type RenderFn = (item: unknown, index: unknown) => unknown;
4
+ /**
5
+ * Indices (into `seq`) of a longest strictly increasing subsequence of the
6
+ * non-negative entries. O(n log n).
7
+ */
8
+ export declare function longestIncreasingSubsequence(seq: ArrayLike<number>): number[];
9
+ /**
10
+ * Bind a server-rendered list: `start` is its `<!--k:ID-->` marker. Rows are
11
+ * adopted by key and then reconciled whenever `getItems` changes.
12
+ */
13
+ export declare function krateBindList(start: Comment, getItems: () => unknown, keyFn: KeyFn, render: RenderFn, mode: number): void;
14
+ /**
15
+ * A list nested in rendered JSX (a `.map()` inside a row or component). It
16
+ * mounts as a fragment with its own markers, or adopts a server-rendered list
17
+ * at the hydration cursor.
18
+ */
19
+ export declare function krateList(getItems: () => unknown, keyFn: KeyFn, render: RenderFn, mode: number): KrateAdoptable;
20
+ export {};