@krate/runtime 0.4.0 → 0.5.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ var __krate_exports=(()=>{var w=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var ae=Object.prototype.hasOwnProperty;var fe=(e,t)=>{for(var n in t)w(e,n,{get:t[n],enumerable:!0})},ue=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ce(t))!ae.call(e,r)&&r!==n&&w(e,r,{get:()=>t[r],enumerable:!(o=ie(t,r))||o.enumerable});return e};var le=e=>ue(w({},"__esModule",{value:!0}),e);var Qe={};fe(Qe,{Slot:()=>Ue,clearNodes:()=>X,clearPersisted:()=>Te,cloneElement:()=>Ge,clsx:()=>W,cn:()=>Be,createCSSChoice:()=>me,createCSSFlags:()=>he,createCSSGroup:()=>ke,createCSSRange:()=>ve,createCSSStack:()=>Ce,createCSSToggle:()=>be,createContext:()=>N,createEffect:()=>g,createMemo:()=>Pe,createReducer:()=>Ee,createResource:()=>ze,createScope:()=>pe,createScopeFlags:()=>ge,createSignal:()=>f,cva:()=>De,disposeAll:()=>xe,disposeNode:()=>R,forwardRef:()=>Oe,h:()=>Me,hydrate:()=>Ve,initRouter:()=>Fe,insert:()=>je,mount:()=>Ie,navigate:()=>He,onCleanup:()=>C,onMount:()=>Ae,readDurableState:()=>O,readPersisted:()=>K,reinitRouter:()=>qe,resetContexts:()=>A,resolvePersist:()=>_,subscribePersist:()=>j,twMerge:()=>B,useRef:()=>_e,writePersisted:()=>L});var de=0,S=new Map;function A(){for(let[e,t]of S)if(t.length>0){let n=t[0];S.set(e,[n])}}function pe(){return N({})}function ge(){return N({})}function N(e){let t=de++;S.set(t,[e]);let n=()=>{let o=S.get(t);return o&&o.length>0?o[o.length-1]:e};return{id:t,defaultValue:e,Provider:o=>{let r=S.get(t)||[e];r.push(o.value),S.set(t,r);let s=document.createElement("div");if(s.style.display="contents",o.children)for(let a of o.children)a instanceof Node?s.appendChild(a):a!=null&&s.appendChild(document.createTextNode(String(a)));return r.pop(),r.length===0&&r.push(e),s},useContext:n,use:n}}function Se(){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 P=Se();function U(){return typeof window<"u"}function E(e){if(e&&typeof e=="object")return e;if(!U())return P;try{return e==="session"?window.sessionStorage:e==="memory"?P:window.localStorage}catch{return P}}function _(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??(o=>JSON.stringify(o)),deserialize:t.deserialize??(o=>JSON.parse(o)),sync:t.sync??n==="local"}}function O(e,t){let o=globalThis.__KRATE_STATE__;if(!o||!Object.prototype.hasOwnProperty.call(o,e))return{found:!1};let r=o[e];if(typeof r=="string")try{return{found:!0,value:t(r)}}catch{return{found:!0,value:r}}return{found:!0,value:r}}function K(e){let t=E(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 L(e,t){let n=E(e.store);try{n.setItem(e.key,e.serialize(t))}catch{}}function Te(e){let t=E(e.store);try{t.removeItem(e.key)}catch{}}var b=new Map,J=!1;function ye(){J||!U()||(J=!0,window.addEventListener("storage",e=>{if(e.key===null)return;let t=b.get(e.key);if(t)for(let n of t)n(e.newValue)}))}function j(e,t){if(!e.sync)return()=>{};let n=b.get(e.key)??new Set;return n.add(t),b.set(e.key,n),ye(),()=>{n.delete(t),n.size===0&&b.delete(e.key)}}var l=[],$=[],M=!1,T=new Set,I=[],V=[],h=!1;function G(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function z(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 xe(){for(let n of T)z(n);T.clear();for(let n of I)try{n()}catch{}I.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{}}V.length=0,h=!1,A()}function me(e,t){return v(f(e))}function be(e,t){return v(f(e))}function he(e,t){let n={};for(let s of e){let[a]=f(!1);n[s]=a}let r=[n,(s,a)=>{}];return r.trigger=s=>({"data-krate-scope":"trigger",value:s}),r.panel=s=>({"data-krate-scope":"panel",value:s}),r.close=()=>({"data-krate-scope":"close"}),r}function ke(e,t){return v(f(e))}function ve(e,t){return v(f(e))}function v(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 Ce(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:o=>{},pop:()=>{},clear:()=>{}}]}function f(e,t){let n=e,o=null;if(t?.persist){o=_(t.persist);let i=O(o.key,o.deserialize);if(i.found)n=i.value;else{let c=K(o);c.found&&(n=c.value)}}let r=new Set,s=()=>{let i=l[l.length-1];return i&&!i.disposed&&(r.add(i),i.sources.add(r)),n},a=()=>{let i=Array.from(r);for(let c of i){if(c.disposed){r.delete(c);continue}if(c.running){c.rerun=!0;continue}c.queued||(c.queued=!0,V.push(c))}Re()},d=i=>{let c=typeof i=="function"?i(n):i;c!==n&&(n=c,o&&L(o,n),a())};if(o&&o.sync){let i=o,c=j(i,y=>{if(y!==null)try{let x=i.deserialize(y);x!==n&&(n=x,a())}catch{}});C(c)}return[s,d]}function Re(){h||(h=!0,queueMicrotask(we))}function we(){h=!1;let e=V.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,k(t),t.rerun&&!t.disposed&&(t.rerun=!1,k(t)))}function k(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,l.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{l.pop(),e.running=!1}}function g(e){let t=G(e);return T.add(t),k(t),()=>{z(t),T.delete(t)}}function C(e){let t=l[l.length-1];t?t.cleanups.push(e):I.push(e)}function Ae(e){$.push(e),M||(M=!0,queueMicrotask(Ne))}function Ne(){M=!1;let e=$.splice(0);for(let t of e)t()}function Pe(e){let[t,n]=f(void 0),o=G(()=>{let s=e();n(s)});T.add(o),k(o);let r=l[l.length-1];return r&&r.cleanups.push(()=>{o.disposed||(z(o),T.delete(o))}),t}function Ee(e,t){let[n,o]=f(t);return[n,s=>o(a=>e(a,s))]}function _e(e){return{current:e}}function Oe(e){return t=>e(t,t.ref||(()=>{}))}var Ke={doubleclick:"dblclick",focus:"focusin",blur:"focusout",change:"input"},F=new WeakMap;function Z(e,t){let n=F.get(e);n||(n=[],F.set(e,n)),n.push(t)}function R(e){let t=F.get(e);if(t){for(let n of t)n();t.length=0}for(let n=0;n<e.childNodes.length;n++)R(e.childNodes[n])}function Le(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function X(e,t){let n=e.parentNode;if(!n)return;let o=e.nextSibling;for(;o&&o!==t;){let r=o.nextSibling;R(o),n.removeChild(o),o=r}}function je(e,t,n){let o=Le(n);o?(X(n,o),q(e,t,o)):q(e,t,null)}function q(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 o of t)q(e,o,n)}}function Q(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 o=t.slice(2).toLowerCase(),r=Ke[o]||o,s=`__krate_${r}`,a=e[s];a&&e.removeEventListener(r,a),e.addEventListener(r,n),e[s]=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 Y(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)Y(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),Z(n,g(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function Me(e,t,...n){if(typeof e=="function")return e({...t||{},children:n});let o=document.createElement(e);if(t)for(let[r,s]of Object.entries(t))typeof s=="function"&&!r.startsWith("on")?Z(o,g(()=>Q(o,r,s()))):Q(o,r,s);for(let r of n)Y(o,r);return o}function ee(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function Ie(e,t){let n=ee(t),o=!1;g(()=>{o||(o=!0,n.appendChild(e()))})}function Ve(e,t){let n=ee(t);if(n.childNodes.length===0){n.appendChild(e());return}let o=e();o&&R(o)}function ze(e,t){let[n,o]=f(void 0),[r,s]=f(!0),[a,d]=f(void 0),[i,c]=f("unresolved"),[y,x]=f(0),p,oe=()=>typeof e=="function"?e():e,re=async()=>{p&&p.abort(),p=new AbortController;let u=p,se=oe();c(y()>0?"refreshing":"loading"),s(!0),d(void 0);try{let m=await t(se,{signal:u.signal});u.signal.aborted||(o(()=>m),c("ready"))}catch(m){m?.name!=="AbortError"&&!u.signal.aborted&&(d(m),c("error"))}finally{u.signal.aborted||s(!1)}};g(()=>{typeof e=="function"&&e.length===0&&e(),y(),re(),C(()=>{p&&(p.abort(),p=void 0)})});let D=function(){return n()};return Object.defineProperties(D,{loading:{get:()=>r()},error:{get:()=>a()},state:{get:()=>i()}}),[D,{mutate:u=>{o(u)},refetch:()=>{x(u=>u+1)}}]}function Fe(){}function qe(){}function He(e,t={}){return typeof location>"u"||(t.replace?location.replace(e):location.assign(e)),!0}function H(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)H(n,t);return}if(typeof e=="object")for(let n of Object.keys(e))e[n]&&t.push(n)}}function W(...e){let t=[];for(let n of e)H(n,t);return t.join(" ")}function B(...e){let t=[];for(let r of e)H(r,t);let n=new Map,o=[];for(let r of t){let s=We(r);n.has(s)||o.push(s),n.set(s,r)}return o.map(r=>n.get(r)).join(" ")}function We(e){let t=e,n="",o=t.lastIndexOf(":");o>=0&&(n=t.slice(0,o+1),t=t.slice(o+1));let r=t.indexOf("-"),s=r>=0?t.slice(0,r):t,a=r>=0?t.slice(r+1,r+2):"";return n+s+(a&&/[0-9]/.test(a)?"-"+a:"")}function Be(...e){return B(W(...e))}function De(e,t){let n=t?.variants??{},o=t?.defaultVariants??{};return r=>{let s={};for(let i of Object.keys(n)){let c=r?.[i]??o[i];c!=null&&(s[i]=String(c))}let a=[e];for(let i of Object.keys(n)){let c=s[i];c&&n[i][c]&&a.push(n[i][c])}for(let i of t?.compoundVariants??[])if(Je(i,s,o)){let c=i.class;typeof c=="string"&&a.push(c)}let d=r?.class??r?.className;return typeof d=="string"&&a.push(d),B(W(a))}}function Je(e,t,n){for(let o of Object.keys(e)){if(o==="class")continue;let r=e[o],s=t[o]??n[o]??void 0;if(Array.isArray(r)){if(!r.includes(s))return!1}else if(r!==s)return!1}return!0}function Ue(e){let t=te(e?.children);return t?(ne(t,e),t):null}function te(e){if(e==null)return null;if(Array.isArray(e)){for(let t of e){let n=te(t);if(n)return n}return null}return e instanceof Node?e:null}function ne(e,t){if(e instanceof Element)for(let n of Object.keys(t)){if(n==="children"||n==="ref")continue;let o=t[n];if(!(o==null||o===!1)){if(n==="class"||n==="className"){let r=e.getAttribute("class"),s=r?r+" "+String(o):String(o);e.setAttribute("class",s);continue}if(n==="style"&&typeof o=="object"){for(let[r,s]of Object.entries(o))e.style.setProperty($e(r),String(s));continue}if(n.startsWith("on")&&typeof o=="function"){e[n]=o;continue}if(o===!0){e.setAttribute(n,"");continue}e.setAttribute(n,String(o))}}}function $e(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function Ge(e,t,...n){if(!(e instanceof Node))return e;if(t&&ne(e,t),n.length>0&&e instanceof Element){e.textContent="";for(let o of n)o instanceof Node?e.appendChild(o):o!=null&&e.appendChild(document.createTextNode(String(o)))}return e}return le(Qe);})();
2
+ for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
@@ -1,2 +1,2 @@
1
- var __krate_exports=(()=>{var G=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var ft=(e,t)=>{for(var n in t)G(e,n,{get:t[n],enumerable:!0})},dt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of lt(t))!ut.call(e,i)&&i!==n&&G(e,i,{get:()=>t[i],enumerable:!(r=at(t,i))||r.enumerable});return e};var pt=e=>dt(G({},"__esModule",{value:!0}),e);var rn={};ft(rn,{Slot:()=>en,clearNodes:()=>Ie,clearPersisted:()=>St,cloneElement:()=>nn,clsx:()=>ye,cn:()=>Gt,conditional:()=>zt,createCSSChoice:()=>bt,createCSSFlags:()=>Et,createCSSGroup:()=>wt,createCSSRange:()=>kt,createCSSStack:()=>Ct,createCSSToggle:()=>xt,createContext:()=>Z,createEffect:()=>N,createMemo:()=>Pt,createReducer:()=>Mt,createResource:()=>Dt,createScope:()=>ht,createScopeFlags:()=>mt,createSignal:()=>b,cva:()=>Qt,disposeAll:()=>vt,disposeNode:()=>k,forwardRef:()=>Ot,h:()=>Vt,hydrate:()=>jt,initRouter:()=>We,insert:()=>It,mount:()=>qt,navigate:()=>Yt,onCleanup:()=>U,onMount:()=>Rt,readDurableState:()=>re,readPersisted:()=>oe,reconcile:()=>Ft,reconcileTrees:()=>Ut,reinitRouter:()=>Jt,resetContexts:()=>Q,resolvePersist:()=>ne,subscribePersist:()=>se,twMerge:()=>Se,useRef:()=>_t,writePersisted:()=>ie});var gt=0,_=new Map;function Q(){for(let[e,t]of _)if(t.length>0){let n=t[0];_.set(e,[n])}}function ht(){return Z({})}function mt(){return Z({})}function Z(e){let t=gt++;_.set(t,[e]);let n=()=>{let r=_.get(t);return r&&r.length>0?r[r.length-1]:e};return{id:t,defaultValue:e,Provider:r=>{let i=_.get(t)||[e];i.push(r.value),_.set(t,i);let c=document.createElement("div");if(c.style.display="contents",r.children)for(let a of r.children)a instanceof Node?c.appendChild(a):a!=null&&c.appendChild(document.createTextNode(String(a)));return i.pop(),i.length===0&&i.push(e),c},useContext:n,use:n}}function yt(){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 ee=yt();function Me(){return typeof window<"u"}function te(e){if(e&&typeof e=="object")return e;if(!Me())return ee;try{return e==="session"?window.sessionStorage:e==="memory"?ee:window.localStorage}catch{return ee}}function ne(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 re(e,t){let r=globalThis.__KRATE_STATE__;if(!r||!Object.prototype.hasOwnProperty.call(r,e))return{found:!1};let i=r[e];if(typeof i=="string")try{return{found:!0,value:t(i)}}catch{return{found:!0,value:i}}return{found:!0,value:i}}function oe(e){let t=te(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 ie(e,t){let n=te(e.store);try{n.setItem(e.key,e.serialize(t))}catch{}}function St(e){let t=te(e.store);try{t.removeItem(e.key)}catch{}}var j=new Map,Pe=!1;function Tt(){Pe||!Me()||(Pe=!0,window.addEventListener("storage",e=>{if(e.key===null)return;let t=j.get(e.key);if(t)for(let n of t)n(e.newValue)}))}function se(e,t){if(!e.sync)return()=>{};let n=j.get(e.key)??new Set;return n.add(t),j.set(e.key,n),Tt(),()=>{n.delete(t),n.size===0&&j.delete(e.key)}}var L=[],_e=[],ce=!1,O=new Set,ae=[],le=[],D=!1;function Oe(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function ue(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 vt(){for(let e of O)ue(e);O.clear();for(let e of ae)try{e()}catch{}ae.length=0,le.length=0,D=!1,Q()}function bt(e,t){return z(b(e))}function xt(e,t){return z(b(e))}function Et(e,t){let n={};for(let c of e){let[a]=b(!1);n[c]=a}let i=[n,(c,a)=>{}];return i.trigger=c=>({"data-krate-scope":"trigger",value:c}),i.panel=c=>({"data-krate-scope":"panel",value:c}),i.close=()=>({"data-krate-scope":"close"}),i}function wt(e,t){return z(b(e))}function kt(e,t){return z(b(e))}function z(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 Ct(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:r=>{},pop:()=>{},clear:()=>{}}]}function b(e,t){let n=e,r=null;if(t?.persist){r=ne(t.persist);let f=re(r.key,r.deserialize);if(f.found)n=f.value;else{let l=oe(r);l.found&&(n=l.value)}}let i=new Set,c=()=>{let f=L[L.length-1];return f&&!f.disposed&&(i.add(f),f.sources.add(i)),n},a=()=>{let f=Array.from(i);for(let l of f){if(l.disposed){i.delete(l);continue}if(l.running){l.rerun=!0;continue}l.queued||(l.queued=!0,le.push(l))}Nt()},S=f=>{let l=typeof f=="function"?f(n):f;l!==n&&(n=l,r&&ie(r,n),a())};if(r&&r.sync){let f=r,l=se(f,h=>{if(h!==null)try{let g=f.deserialize(h);g!==n&&(n=g,a())}catch{}});U(l)}return[c,S]}function Nt(){D||(D=!0,queueMicrotask(At))}function At(){D=!1;let e=le.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,L.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{L.pop(),e.running=!1}}function N(e){let t=Oe(e);return O.add(t),F(t),()=>{ue(t),O.delete(t)}}function U(e){let t=L[L.length-1];t?t.cleanups.push(e):ae.push(e)}function Rt(e){_e.push(e),ce||(ce=!0,queueMicrotask(Lt))}function Lt(){ce=!1;let e=_e.splice(0);for(let t of e)t()}function Pt(e){let[t,n]=b(void 0),r=Oe(()=>{let c=e();n(c)});O.add(r),F(r);let i=L[L.length-1];return i&&i.cleanups.push(()=>{r.disposed||(ue(r),O.delete(r))}),t}function Mt(e,t){let[n,r]=b(t);return[n,c=>r(a=>e(a,c))]}function _t(e){return{current:e}}function Ot(e){return t=>e(t,t.ref||(()=>{}))}var Ht={doubleclick:"dblclick",focus:"focusin",blur:"focusout",change:"input"},fe=new WeakMap;function Ke(e,t){let n=fe.get(e);n||(n=[],fe.set(e,n)),n.push(t)}function k(e){let t=fe.get(e);if(t){for(let n of t)n();t.length=0}for(let n=0;n<e.childNodes.length;n++)k(e.childNodes[n])}function Kt(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function Ie(e,t){let n=e.parentNode;if(!n)return;let r=e.nextSibling;for(;r&&r!==t;){let i=r.nextSibling;k(r),n.removeChild(r),r=i}}function It(e,t,n){let r=Kt(n);r?(Ie(n,r),de(e,t,r)):de(e,t,null)}function de(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)de(e,r,n)}}function He(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 r=t.slice(2).toLowerCase(),i=Ht[r]||r,c=`__krate_${i}`,a=e[c];a&&e.removeEventListener(i,a),e.addEventListener(i,n),e[c]=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 Ve(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)Ve(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),Ke(n,N(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function Vt(e,t,...n){if(typeof e=="function")return e({...t||{},children:n});let r=document.createElement(e);if(t)for(let[i,c]of Object.entries(t))typeof c=="function"&&!i.startsWith("on")?Ke(r,N(()=>He(r,i,c()))):He(r,i,c);for(let i of n)Ve(r,i);return r}function qe(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function qt(e,t){let n=qe(t),r=!1;N(()=>{r||(r=!0,n.appendChild(e()))})}function jt(e,t){let n=qe(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&k(r)}function Dt(e,t){let[n,r]=b(void 0),[i,c]=b(!0),[a,S]=b(void 0),[f,l]=b("unresolved"),[h,g]=b(0),p,v=()=>typeof e=="function"?e():e,T=async()=>{p&&p.abort(),p=new AbortController;let C=p,V=v();l(h()>0?"refreshing":"loading"),c(!0),S(void 0);try{let A=await t(V,{signal:C.signal});C.signal.aborted||(r(()=>A),l("ready"))}catch(A){A?.name!=="AbortError"&&!C.signal.aborted&&(S(A),l("error"))}finally{C.signal.aborted||c(!1)}};N(()=>{typeof e=="function"&&e.length===0&&e(),h(),T(),U(()=>{p&&(p.abort(),p=void 0)})});let x=function(){return n()};return Object.defineProperties(x,{loading:{get:()=>i()},error:{get:()=>a()},state:{get:()=>f()}}),[x,{mutate:C=>{r(C)},refetch:()=>{g(C=>C+1)}}]}function Ft(e,t,n,r,i,c){let a=[],S=t.nextSibling;for(;S&&S!==n;)a.push(S),S=S.nextSibling;if(c){let f=new Map;for(let h of a){let g=h.__k;g!=null&&!f.has(g)&&f.set(g,h)}let l=[];for(let h=0;h<r.length;h++){let g=c(r[h]),p=f.get(g);p?f.delete(g):(p=i(r[h],h),p.__k=g),l.push(p)}for(let h of f.values())h.parentNode===e&&(k(h),e.removeChild(h));for(let h=0;h<l.length;h++){let g=h===0?t:l[h-1];l[h]!==g.nextSibling&&e.insertBefore(l[h],g.nextSibling)}}else{let f=Math.max(a.length,r.length);for(let l=0;l<f;l++)if(l<r.length){let h=i(r[l],l);l<a.length?a[l]!==h&&(k(a[l]),e.replaceChild(h,a[l])):e.insertBefore(h,n)}else l<a.length&&a[l].parentNode===e&&(k(a[l]),e.removeChild(a[l]))}}function zt(e,t,n,r,i,c){let a=null;N(()=>{let f=r()?i():c?c():null;a?f?(k(a),e.replaceChild(f,a)):(k(a),e.removeChild(a)):f&&e.insertBefore(f,n),a=f})}function H(e){if(e.nodeType===Node.COMMENT_NODE){let t=e.nodeValue||"";return t.indexOf("k:")===0?t:null}if(e.nodeType===Node.ELEMENT_NODE){let t=e,n=t.getAttribute("data-k");if(n)return n;let r=t.getAttribute("id");if(r)return"#"+r}return null}function je(e,t){let n=new Set;for(let r=0;r<t.attributes.length;r++){let i=t.attributes[r].name,c=t.attributes[r].value;n.add(i),e.getAttribute(i)!==c&&e.setAttribute(i,c)}for(let r=0;r<e.attributes.length;r++){let i=e.attributes[r].name;n.has(i)||e.removeAttribute(i)}}function pe(e,t){let n=document.importNode(t,!0);return e.parentNode&&(k(e),e.parentNode.replaceChild(n,e)),n}function De(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!0}function ge(e,t){if(!De(e,t))return pe(e,t);if(e.nodeType===Node.TEXT_NODE)return e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e;if(e.nodeType===Node.COMMENT_NODE)return e.nodeValue!==t.nodeValue?pe(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,r=t;return H(n)!==H(r)?pe(n,r):(je(n,r),Fe(n,r),n)}function Fe(e,t){let n=Array.from(e.childNodes),r=Array.from(t.childNodes);if(n.length===r.length){let g=!0;for(let p=0;p<r.length;p++)if(H(n[p])!==H(r[p])){g=!1;break}if(g){for(let p=0;p<r.length;p++)ge(n[p],r[p]);return}}let i=new Map,c=[];n.forEach((g,p)=>{let v=H(g);v!=null?i.has(v)||i.set(v,p):c.push(p)});let a=new Set,S=0,f=null,l=0,h=()=>{for(;l<c.length&&a.has(c[l]);)l++;return l<c.length?c[l]:-1};for(let g of r){let p=H(g),v;if(p!=null&&i.has(p)){let T=i.get(p);i.delete(p),a.add(T);let x=n[T];T<S?e.insertBefore(x,f):S=T,v=ge(x,g)}else if(p==null){let T=h();if(T>=0&&De(n[T],g)){a.add(T);let x=n[T];x.parentNode===e&&x.nextSibling!==f&&e.insertBefore(x,f),v=ge(x,g)}else v=document.importNode(g,!0),e.insertBefore(v,f)}else v=document.importNode(g,!0),e.insertBefore(v,f);f=v.nextSibling}n.forEach((g,p)=>{!a.has(p)&&g.parentNode===e&&(k(g),e.removeChild(g))})}function Ut(e,t){if(e.nodeType!==Node.ELEMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return;let n=e,r=t;if(n.tagName!==r.tagName){let i=document.importNode(t,!0);n.parentNode&&n.parentNode.replaceChild(i,n);return}je(n,r),Fe(n,r)}var he=!1,K,W=null,B=0,P=new Map,Bt=30,I=new Map,Wt=50,ze=/\/chunks\/runtime\.[^/]+\.js$/;function Be(){return globalThis.__KRATE_CFG__||{}}function $t(){let e=Be().basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function Ue(e){let t=$t();if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}var $=null;function Yt(e,t={}){return $?($(e,t),!1):(typeof location<"u"&&(location.href=e),!0)}function We(){if(typeof document>"u"||he)return;he=!0;let e="#root, main, .docs-content",t=150,n=200,r=null,i=null,c=new Map,a=null;function S(o){for(let s of e.split(", ")){let u=o.querySelector(s.trim());if(u)return u}return o.body}function f(o){if(o.hasAttribute("data-krate-external"))return!1;let s=o.getAttribute("href");return!(!s||s.startsWith("#")||s.startsWith("javascript:")||o.origin!==location.origin||o.target==="_blank")}function l(o){P.has(o)||fetch(o,{headers:{Accept:"text/html"}}).then(s=>s.ok?s.text():null).then(s=>{if(s){if(P.size>=Bt){let u=P.keys().next().value;u!==void 0&&P.delete(u)}P.set(o,s)}}).catch(()=>{})}function h(){document.addEventListener("mouseover",v),document.addEventListener("focusin",v),typeof IntersectionObserver<"u"&&(a=new IntersectionObserver(o=>{for(let s of o)if(s.isIntersecting){let u=s.target,d=u.getAttribute("href");if(d&&f(u)){let m=new URL(d,location.origin).href;l(m)}a.unobserve(s.target)}},{rootMargin:"200px"}),g())}function g(){a&&document.querySelectorAll("a[data-prefetch]").forEach(o=>{a.observe(o)})}function p(){document.removeEventListener("mouseover",v),document.removeEventListener("focusin",v);for(let o of c.values())clearTimeout(o);c.clear(),a&&(a.disconnect(),a=null)}function v(o){let s=o.target.closest("a[data-prefetch]");if(!s||!f(s))return;let u=s.getAttribute("href");if(!u)return;let d=new URL(u,location.origin).href;if(P.has(d))return;let m=c.get(s);m&&clearTimeout(m);let y=setTimeout(()=>{c.delete(s),l(d)},n);c.set(s,y)}let T=null;function x(){if(A())return;let o=S(document),s=document.querySelector("template[data-krate-loading]");s&&s.content&&o&&(T=s.content.cloneNode(!0),document.body.appendChild(T)),o&&(o.style.transition=`opacity ${t}ms ease`,o.style.opacity="0")}function Y(){if(A())return;T&&T.parentNode&&T.parentNode.removeChild(T),T=null;let o=S(document);o&&(o.style.opacity="1")}function C(o){try{let s=globalThis.__krate_onNavigation;typeof s=="function"&&s(o)}catch{}}function V(o,s){try{window.dispatchEvent(new CustomEvent(o,{detail:{url:s}}))}catch{}}function A(){if(Be().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 Je(o){let s=o.querySelectorAll('link[rel="stylesheet"]'),u=new Set;s.forEach(m=>{let y=m.getAttribute("href");y&&u.add(new URL(y,location.origin).href)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(m=>{let y=m.href;y&&!u.has(y)&&m.remove()});let d=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(m=>d.add(m.href)),s.forEach(m=>{let y=m.getAttribute("href");if(!y)return;let E=new URL(y,location.origin).href;if(!d.has(E)){let R=document.createElement("link");R.rel="stylesheet",R.href=E,document.head.appendChild(R)}})}function Te(o){o.querySelectorAll("[data-view-transition]").forEach(s=>{let u=s.getAttribute("data-view-transition");u&&(s.style.viewTransitionName=u)})}function Xe(){let o=S(document);if(o){o.hasAttribute("tabindex")||o.setAttribute("tabindex","-1");try{o.focus({preventScroll:!0})}catch{try{o.focus()}catch{}}}}function Ge(){let o=HTMLScriptElement.supports;if(!(typeof o!="function"||!o("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 ve(o){return o.getElementById("root")||o.body}let be='meta[name="description"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function Qe(o){document.head.querySelectorAll(be).forEach(s=>s.remove()),o.head.querySelectorAll(be).forEach(s=>{document.head.appendChild(document.importNode(s,!0))})}function xe(o,s,u,d={}){let{replace:m=!1,scroll:y=!0,restoreScroll:E=!1}=d,M=new DOMParser().parseFromString(o,"text/html"),Re=ve(M),Le=ve(document);if(!Re||!Le){location.href=s;return}V("krate:navigate-start",s);let X=()=>{let w=M.querySelector("title");w&&(document.title=w.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll();let q=Array.from(Re.childNodes).map(ct=>document.importNode(ct,!0));Le.replaceChildren(...q),Je(M),Qe(M),Te(document)};if(A())try{let w=document.startViewTransition(X);w&&w.finished&&typeof w.finished.catch=="function"&&w.finished.catch(()=>{})}catch{X()}else X();et(u,s).then(()=>{try{nt(),g()}catch(w){try{let q=globalThis.__krate_onHydrationError;typeof q=="function"&&q(w)}catch{}location.href=s}}),Y();let st=location.pathname+location.search;if(m)history.replaceState({},"",s);else{if(!E){if(I.size>=Wt){let w=I.keys().next().value;w!==void 0&&I.delete(w)}I.set(st,window.scrollY)}history.pushState({},"",s)}Ee(s,{restoreScroll:E,scroll:y}),E||Xe(),we(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:s}})),V("krate:navigate-end",s),C(s)}function Ze(o){let s=o.indexOf("#");if(s<0||s===o.length-1)return!1;let u=o.slice(s);try{let d=document.querySelector(u);if(d)return d.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch{return!1}return!1}function Ee(o,s){if(s.restoreScroll){let u=I.get(o);if(u!==void 0){window.scrollTo(0,u);return}}Ze(o)||s.scroll&&window.scrollTo(0,0)}function we(){let o=Ue(location.pathname);document.querySelectorAll("a[data-krate-link]").forEach(s=>{let u=s.getAttribute("href");if(!u){s.removeAttribute("aria-current");return}let d=u;try{d=Ue(new URL(u,location.origin).pathname)}catch{return}d===o||o==="/"&&(d===""||d==="/")||d!=="/"&&d.length>1&&o.startsWith(d)?s.setAttribute("aria-current","page"):s.removeAttribute("aria-current")})}function et(o,s){return o.length===0?Promise.resolve():Promise.all(o.map(u=>{let d=u.getAttribute("src");return d?tt(d,s):Promise.resolve()})).then(()=>{})}function tt(o,s){return new Promise(u=>{let d=document.createElement("script"),m=ke(o,s);d.src=m,ze.test(m)||d.setAttribute("data-krate-spa",""),d.onload=()=>u(),d.onerror=()=>u(),document.body.appendChild(d)})}function ke(o,s){if(/^(https?:)?\/\//.test(o)||o.startsWith("/"))return new URL(o,s).href;let u=s;if(!u.endsWith("/")){let d=u.lastIndexOf("/");u=d>0?u.slice(0,d+1):"/"}return new URL(o,u).href}function nt(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function rt(o,s){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",s),C(s),document.open(),document.write(o),document.close()}function ot(){return r!==null?Promise.resolve(r):fetch("/404.html",{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>(r=o,o)).catch(()=>null)}function it(){return i!==null?Promise.resolve(i):fetch("/500.html",{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>(i=o,o)).catch(()=>null)}function Ce(o,s){document.querySelectorAll("script[data-krate-spa]").forEach(m=>m.remove());let u=[],d=new Set;return document.querySelectorAll("script[src]").forEach(m=>{d.add(m.src)}),o.querySelectorAll("script[src]").forEach(m=>{let y=m.getAttribute("src");y&&!d.has(ke(y,s))&&u.push(m)}),u}function J(o,s={}){let u=++B,d=P.get(o);if(d){let E=new DOMParser().parseFromString(d,"text/html");xe(d,o,Ce(E,o),s);return}x(),K&&K.abort(),K=new AbortController;let m=K.signal;fetch(o,{headers:{Accept:"text/html"},signal:m}).then(y=>{if(u===B)return y.ok?y.text().then(E=>{if(u!==B)return;let M=new DOMParser().parseFromString(E,"text/html");xe(E,o,Ce(M,o),s)}):(y.status>=500?it():ot()).then(R=>{u===B&&(R?rt(R,o):location.href=o)})}).catch(y=>{y?.name!=="AbortError"&&(Y(),location.href=o)}).finally(()=>{K&&!m.aborted&&(K=void 0)})}let Ne=o=>{if(o.defaultPrevented||o.button!==0||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey)return;let s=o.target.closest("a[data-krate-link]");if(!s||!f(s))return;o.preventDefault();let u=s.getAttribute("href");if(!u)return;let d=new URL(u,location.origin).href,m=s.hasAttribute("data-krate-replace"),y=s.getAttribute("data-krate-scroll")!=="false";if(u===location.pathname+location.search+location.hash){m&&history.replaceState({},"",u),Ee(d,{scroll:y});return}J(d,{replace:m,scroll:y})},Ae=()=>{J(location.href,{restoreScroll:!0})};document.addEventListener("click",Ne),window.addEventListener("popstate",Ae),h(),Ge(),we(),Te(document),$=(o,s={})=>{let u=!0;try{u=new URL(o,location.href).origin===location.origin}catch{u=!1}if(!u){location.href=o;return}J(new URL(o,location.href).href,s)},document.querySelectorAll("script[src]").forEach(o=>{ze.test(o.src)||o.setAttribute("data-krate-spa","")}),W=()=>{document.removeEventListener("click",Ne),window.removeEventListener("popstate",Ae),p(),$=null}}function Jt(){W&&(W(),W=null),he=!1,We()}function me(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)me(n,t);return}if(typeof e=="object")for(let n of Object.keys(e))e[n]&&t.push(n)}}function ye(...e){let t=[];for(let n of e)me(n,t);return t.join(" ")}function Se(...e){let t=[];for(let i of e)me(i,t);let n=new Map,r=[];for(let i of t){let c=Xt(i);n.has(c)||r.push(c),n.set(c,i)}return r.map(i=>n.get(i)).join(" ")}function Xt(e){let t=e,n="",r=t.lastIndexOf(":");r>=0&&(n=t.slice(0,r+1),t=t.slice(r+1));let i=t.indexOf("-"),c=i>=0?t.slice(0,i):t,a=i>=0?t.slice(i+1,i+2):"";return n+c+(a&&/[0-9]/.test(a)?"-"+a:"")}function Gt(...e){return Se(ye(...e))}function Qt(e,t){let n=t?.variants??{},r=t?.defaultVariants??{};return i=>{let c={};for(let f of Object.keys(n)){let l=i?.[f]??r[f];l!=null&&(c[f]=String(l))}let a=[e];for(let f of Object.keys(n)){let l=c[f];l&&n[f][l]&&a.push(n[f][l])}for(let f of t?.compoundVariants??[])if(Zt(f,c,r)){let l=f.class;typeof l=="string"&&a.push(l)}let S=i?.class??i?.className;return typeof S=="string"&&a.push(S),Se(ye(a))}}function Zt(e,t,n){for(let r of Object.keys(e)){if(r==="class")continue;let i=e[r],c=t[r]??n[r]??void 0;if(Array.isArray(i)){if(!i.includes(c))return!1}else if(i!==c)return!1}return!0}function en(e){let t=$e(e?.children);return t?(Ye(t,e),t):null}function $e(e){if(e==null)return null;if(Array.isArray(e)){for(let t of e){let n=$e(t);if(n)return n}return null}return e instanceof Node?e:null}function Ye(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 i=e.getAttribute("class"),c=i?i+" "+String(r):String(r);e.setAttribute("class",c);continue}if(n==="style"&&typeof r=="object"){for(let[i,c]of Object.entries(r))e.style.setProperty(tn(i),String(c));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 tn(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function nn(e,t,...n){if(!(e instanceof Node))return e;if(t&&Ye(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}return pt(rn);})();
1
+ var __krate_exports=(()=>{var G=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var lt=Object.prototype.hasOwnProperty;var ut=(e,t)=>{for(var n in t)G(e,n,{get:t[n],enumerable:!0})},ft=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of at(t))!lt.call(e,i)&&i!==n&&G(e,i,{get:()=>t[i],enumerable:!(o=ct(t,i))||o.enumerable});return e};var dt=e=>ft(G({},"__esModule",{value:!0}),e);var en={};ut(en,{Slot:()=>Gt,clearNodes:()=>je,clearPersisted:()=>St,cloneElement:()=>Zt,clsx:()=>ye,cn:()=>Yt,createCSSChoice:()=>vt,createCSSFlags:()=>wt,createCSSGroup:()=>xt,createCSSRange:()=>kt,createCSSStack:()=>Et,createCSSToggle:()=>bt,createContext:()=>Z,createEffect:()=>E,createMemo:()=>Pt,createReducer:()=>Nt,createResource:()=>Vt,createScope:()=>gt,createScopeFlags:()=>ht,createSignal:()=>S,cva:()=>Jt,disposeAll:()=>Tt,disposeNode:()=>z,forwardRef:()=>Mt,h:()=>It,hydrate:()=>jt,initRouter:()=>We,insert:()=>Kt,mount:()=>qt,navigate:()=>Wt,onCleanup:()=>F,onMount:()=>Rt,pageAssetURLs:()=>Ue,readDurableState:()=>re,readPersisted:()=>oe,reinitRouter:()=>Bt,resetContexts:()=>Q,resolvePersist:()=>ne,subscribePersist:()=>ie,twMerge:()=>Te,useRef:()=>_t,writePersisted:()=>se});var pt=0,L=new Map;function Q(){for(let[e,t]of L)if(t.length>0){let n=t[0];L.set(e,[n])}}function gt(){return Z({})}function ht(){return Z({})}function Z(e){let t=pt++;L.set(t,[e]);let n=()=>{let o=L.get(t);return o&&o.length>0?o[o.length-1]:e};return{id:t,defaultValue:e,Provider:o=>{let i=L.get(t)||[e];i.push(o.value),L.set(t,i);let c=document.createElement("div");if(c.style.display="contents",o.children)for(let f of o.children)f instanceof Node?c.appendChild(f):f!=null&&c.appendChild(document.createTextNode(String(f)));return i.pop(),i.length===0&&i.push(e),c},useContext:n,use:n}}function mt(){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 ee=mt();function He(){return typeof window<"u"}function te(e){if(e&&typeof e=="object")return e;if(!He())return ee;try{return e==="session"?window.sessionStorage:e==="memory"?ee:window.localStorage}catch{return ee}}function ne(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??(o=>JSON.stringify(o)),deserialize:t.deserialize??(o=>JSON.parse(o)),sync:t.sync??n==="local"}}function re(e,t){let o=globalThis.__KRATE_STATE__;if(!o||!Object.prototype.hasOwnProperty.call(o,e))return{found:!1};let i=o[e];if(typeof i=="string")try{return{found:!0,value:t(i)}}catch{return{found:!0,value:i}}return{found:!0,value:i}}function oe(e){let t=te(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 se(e,t){let n=te(e.store);try{n.setItem(e.key,e.serialize(t))}catch{}}function St(e){let t=te(e.store);try{t.removeItem(e.key)}catch{}}var I=new Map,Me=!1;function yt(){Me||!He()||(Me=!0,window.addEventListener("storage",e=>{if(e.key===null)return;let t=I.get(e.key);if(t)for(let n of t)n(e.newValue)}))}function ie(e,t){if(!e.sync)return()=>{};let n=I.get(e.key)??new Set;return n.add(t),I.set(e.key,n),yt(),()=>{n.delete(t),n.size===0&&I.delete(e.key)}}var x=[],Oe=[],ce=!1,P=new Set,ae=[],le=[],q=!1;function Ke(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function ue(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 Tt(){for(let n of P)ue(n);P.clear();for(let n of ae)try{n()}catch{}ae.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{}}le.length=0,q=!1,Q()}function vt(e,t){return V(S(e))}function bt(e,t){return V(S(e))}function wt(e,t){let n={};for(let c of e){let[f]=S(!1);n[c]=f}let i=[n,(c,f)=>{}];return i.trigger=c=>({"data-krate-scope":"trigger",value:c}),i.panel=c=>({"data-krate-scope":"panel",value:c}),i.close=()=>({"data-krate-scope":"close"}),i}function xt(e,t){return V(S(e))}function kt(e,t){return V(S(e))}function V(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 Et(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:o=>{},pop:()=>{},clear:()=>{}}]}function S(e,t){let n=e,o=null;if(t?.persist){o=ne(t.persist);let u=re(o.key,o.deserialize);if(u.found)n=u.value;else{let p=oe(o);p.found&&(n=p.value)}}let i=new Set,c=()=>{let u=x[x.length-1];return u&&!u.disposed&&(i.add(u),u.sources.add(i)),n},f=()=>{let u=Array.from(i);for(let p of u){if(p.disposed){i.delete(p);continue}if(p.running){p.rerun=!0;continue}p.queued||(p.queued=!0,le.push(p))}At()},h=u=>{let p=typeof u=="function"?u(n):u;p!==n&&(n=p,o&&se(o,n),f())};if(o&&o.sync){let u=o,p=ie(u,b=>{if(b!==null)try{let C=u.deserialize(b);C!==n&&(n=C,f())}catch{}});F(p)}return[c,h]}function At(){q||(q=!0,queueMicrotask(Ct))}function Ct(){q=!1;let e=le.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,j(t),t.rerun&&!t.disposed&&(t.rerun=!1,j(t)))}function j(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,x.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{x.pop(),e.running=!1}}function E(e){let t=Ke(e);return P.add(t),j(t),()=>{ue(t),P.delete(t)}}function F(e){let t=x[x.length-1];t?t.cleanups.push(e):ae.push(e)}function Rt(e){Oe.push(e),ce||(ce=!0,queueMicrotask(Lt))}function Lt(){ce=!1;let e=Oe.splice(0);for(let t of e)t()}function Pt(e){let[t,n]=S(void 0),o=Ke(()=>{let c=e();n(c)});P.add(o),j(o);let i=x[x.length-1];return i&&i.cleanups.push(()=>{o.disposed||(ue(o),P.delete(o))}),t}function Nt(e,t){let[n,o]=S(t);return[n,c=>o(f=>e(f,c))]}function _t(e){return{current:e}}function Mt(e){return t=>e(t,t.ref||(()=>{}))}var Ht={doubleclick:"dblclick",focus:"focusin",blur:"focusout",change:"input"},fe=new WeakMap;function qe(e,t){let n=fe.get(e);n||(n=[],fe.set(e,n)),n.push(t)}function z(e){let t=fe.get(e);if(t){for(let n of t)n();t.length=0}for(let n=0;n<e.childNodes.length;n++)z(e.childNodes[n])}function Ot(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function je(e,t){let n=e.parentNode;if(!n)return;let o=e.nextSibling;for(;o&&o!==t;){let i=o.nextSibling;z(o),n.removeChild(o),o=i}}function Kt(e,t,n){let o=Ot(n);o?(je(n,o),de(e,t,o)):de(e,t,null)}function de(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 o of t)de(e,o,n)}}function Ie(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 o=t.slice(2).toLowerCase(),i=Ht[o]||o,c=`__krate_${i}`,f=e[c];f&&e.removeEventListener(i,f),e.addEventListener(i,n),e[c]=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 Ve(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)Ve(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),qe(n,E(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function It(e,t,...n){if(typeof e=="function")return e({...t||{},children:n});let o=document.createElement(e);if(t)for(let[i,c]of Object.entries(t))typeof c=="function"&&!i.startsWith("on")?qe(o,E(()=>Ie(o,i,c()))):Ie(o,i,c);for(let i of n)Ve(o,i);return o}function Fe(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function qt(e,t){let n=Fe(t),o=!1;E(()=>{o||(o=!0,n.appendChild(e()))})}function jt(e,t){let n=Fe(t);if(n.childNodes.length===0){n.appendChild(e());return}let o=e();o&&z(o)}function Vt(e,t){let[n,o]=S(void 0),[i,c]=S(!0),[f,h]=S(void 0),[u,p]=S("unresolved"),[b,C]=S(0),v,B=()=>typeof e=="function"?e():e,H=async()=>{v&&v.abort(),v=new AbortController;let m=v,$=B();p(b()>0?"refreshing":"loading"),c(!0),h(void 0);try{let k=await t($,{signal:m.signal});m.signal.aborted||(o(()=>k),p("ready"))}catch(k){k?.name!=="AbortError"&&!m.signal.aborted&&(h(k),p("error"))}finally{m.signal.aborted||c(!1)}};E(()=>{typeof e=="function"&&e.length===0&&e(),b(),H(),F(()=>{v&&(v.abort(),v=void 0)})});let O=function(){return n()};return Object.defineProperties(O,{loading:{get:()=>i()},error:{get:()=>f()},state:{get:()=>u()}}),[O,{mutate:m=>{o(m)},refetch:()=>{C(m=>m+1)}}]}var ge=!1,N,U=null,D=0,A=new Map,Ft=30,M=new Map,zt=50,he=/\/chunks\/runtime\.[^/]+\.js$/;function De(){return globalThis.__KRATE_CFG__||{}}function Dt(){let e=De().basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function ze(e){let t=Dt();if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}var W=null;function me(e,t){if(/^(https?:)?\/\//.test(e)||e.startsWith("/"))return new URL(e,t).href;let n=t;if(!n.endsWith("/")){let o=n.lastIndexOf("/");n=o>0?n.slice(0,o+1):"/"}return new URL(e,n).href}var pe=new Set,Ut=128;function Ue(e,t,n){let o=new DOMParser().parseFromString(e,"text/html"),i=[],c=new Set,f=h=>{if(!h)return;let u;try{u=me(h,t)}catch{return}c.has(u)||n.has(u)||he.test(u)||(c.add(u),i.push(u))};return o.querySelectorAll("script[src]").forEach(h=>f(h.getAttribute("src"))),o.querySelectorAll('link[rel="modulepreload"][href], link[rel="preload"][as="script"][href]').forEach(h=>f(h.getAttribute("href"))),i}function Wt(e,t={}){return W?(W(e,t),!1):(typeof location<"u"&&(location.href=e),!0)}function We(){if(typeof document>"u"||ge)return;ge=!0;let e="#root, main, .docs-content",t=150,n=200,o=null,i=null,c=new Map,f=null;function h(r){for(let s of e.split(", ")){let a=r.querySelector(s.trim());if(a)return a}return r.body}function u(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 p(r){let s=window.requestIdleCallback;typeof s=="function"?s(r,{timeout:1e3}):setTimeout(r,50)}function b(r){let s=r.getAttribute("data-prefetch");return r.hasAttribute("data-prefetch")&&s!=="false"&&s!=="0"}function C(r){if(pe.has(r)||pe.size>=Ut)return;pe.add(r);let s=document.createElement("link");s.rel="prefetch",s.as="script",s.href=r,document.head.appendChild(s)}function v(r){A.has(r)||fetch(r,{headers:{Accept:"text/html"}}).then(s=>s.ok?s.text():null).then(s=>{if(!s)return;if(A.size>=Ft){let l=A.keys().next().value;l!==void 0&&A.delete(l)}A.set(r,s);let a=new Set;document.querySelectorAll("script[src]").forEach(l=>a.add(l.src));for(let l of Ue(s,r,a))C(l)}).catch(()=>{})}function B(){document.addEventListener("mouseover",_),document.addEventListener("focusin",_),typeof IntersectionObserver<"u"&&(f=new IntersectionObserver(r=>{for(let s of r)if(s.isIntersecting){let a=s.target,l=a.getAttribute("href");if(l&&u(a)&&b(a)){let d=new URL(l,location.origin).href;p(()=>v(d))}f.unobserve(s.target)}},{rootMargin:"200px"}),H())}function H(){f&&document.querySelectorAll("a[data-prefetch]").forEach(r=>{b(r)&&f.observe(r)})}function O(){document.removeEventListener("mouseover",_),document.removeEventListener("focusin",_);for(let r of c.values())clearTimeout(r);c.clear(),f&&(f.disconnect(),f=null)}function _(r){let s=r.target.closest("a[data-prefetch]");if(!s||!b(s)||!u(s))return;let a=s.getAttribute("href");if(!a)return;let l=new URL(a,location.origin).href;if(A.has(l))return;let d=c.get(s);d&&clearTimeout(d);let g=setTimeout(()=>{c.delete(s),v(l)},n);c.set(s,g)}let m=null;function $(){if(Y())return;let r=h(document),s=document.querySelector("template[data-krate-loading]");s&&s.content&&r&&(m=s.content.cloneNode(!0),document.body.appendChild(m)),r&&(r.style.transition=`opacity ${t}ms ease`,r.style.opacity="0")}function k(){if(Y())return;m&&m.parentNode&&m.parentNode.removeChild(m),m=null;let r=h(document);r&&(r.style.opacity="1")}function ve(r){try{let s=globalThis.__krate_onNavigation;typeof s=="function"&&s(r)}catch{}}function be(r,s){try{window.dispatchEvent(new CustomEvent(r,{detail:{url:s}}))}catch{}}function Y(){if(De().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"]'),a=new Set;s.forEach(d=>{let g=d.getAttribute("href");g&&a.add(new URL(g,location.origin).href)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(d=>{let g=d.href;g&&!a.has(g)&&d.remove()});let l=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(d=>l.add(d.href)),s.forEach(d=>{let g=d.getAttribute("href");if(!g)return;let y=new URL(g,location.origin).href;if(!l.has(y)){let w=document.createElement("link");w.rel="stylesheet",w.href=y,document.head.appendChild(w)}})}function we(r){r.querySelectorAll("[data-view-transition]").forEach(s=>{let a=s.getAttribute("data-view-transition");a&&(s.style.viewTransitionName=a)})}function Je(){let r=h(document);if(r){r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1");try{r.focus({preventScroll:!0})}catch{try{r.focus()}catch{}}}}function Xe(){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 xe(r){return r.getElementById("root")||r.body}let ke='meta[name="description"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function Ge(r){document.head.querySelectorAll(ke).forEach(s=>s.remove()),r.head.querySelectorAll(ke).forEach(s=>{document.head.appendChild(document.importNode(s,!0))})}function Ee(r,s,a,l={}){let{replace:d=!1,scroll:g=!0,restoreScroll:y=!1}=l,R=new DOMParser().parseFromString(r,"text/html"),Ne=xe(R),_e=xe(document);if(!Ne||!_e){location.href=s;return}be("krate:navigate-start",s);let X=()=>{let T=R.querySelector("title");T&&(document.title=T.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll();let K=Array.from(Ne.childNodes).map(it=>document.importNode(it,!0));_e.replaceChildren(...K),Ye(R),Ge(R),we(document)};if(Y())try{let T=document.startViewTransition(X);T&&T.finished&&typeof T.finished.catch=="function"&&T.finished.catch(()=>{})}catch{X()}else X();Ze(a,s).then(()=>{try{tt(),H()}catch(T){try{let K=globalThis.__krate_onHydrationError;typeof K=="function"&&K(T)}catch{}location.href=s}}),k();let st=location.pathname+location.search;if(d)history.replaceState({},"",s);else{if(!y){if(M.size>=zt){let T=M.keys().next().value;T!==void 0&&M.delete(T)}M.set(st,window.scrollY)}history.pushState({},"",s)}Ae(s,{restoreScroll:y,scroll:g}),y||Je(),Ce(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:s}})),be("krate:navigate-end",s),ve(s)}function Qe(r){let s=r.indexOf("#");if(s<0||s===r.length-1)return!1;let a=r.slice(s);try{let l=document.querySelector(a);if(l)return l.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch{return!1}return!1}function Ae(r,s){if(s.restoreScroll){let a=M.get(r);if(a!==void 0){window.scrollTo(0,a);return}}Qe(r)||s.scroll&&window.scrollTo(0,0)}function Ce(){let r=ze(location.pathname);document.querySelectorAll("a[data-krate-link]").forEach(s=>{let a=s.getAttribute("href");if(!a){s.removeAttribute("aria-current");return}let l=a;try{l=ze(new URL(a,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 Ze(r,s){return r.length===0?Promise.resolve():Promise.all(r.map(a=>{let l=a.getAttribute("src");return l?et(l,s):Promise.resolve()})).then(()=>{})}function et(r,s){return new Promise(a=>{let l=document.createElement("script"),d=me(r,s);l.src=d,he.test(d)||l.setAttribute("data-krate-spa",""),l.onload=()=>a(),l.onerror=()=>a(),document.body.appendChild(l)})}function tt(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function nt(r,s){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",s),ve(s),document.open(),document.write(r),document.close()}function rt(){return o!==null?Promise.resolve(o):fetch("/404.html",{headers:{Accept:"text/html"}}).then(r=>r.ok?r.text():null).then(r=>(o=r,r)).catch(()=>null)}function ot(){return i!==null?Promise.resolve(i):fetch("/500.html",{headers:{Accept:"text/html"}}).then(r=>r.ok?r.text():null).then(r=>(i=r,r)).catch(()=>null)}function Re(r,s){document.querySelectorAll("script[data-krate-spa]").forEach(d=>d.remove());let a=[],l=new Set;return document.querySelectorAll("script[src]").forEach(d=>{l.add(d.src)}),r.querySelectorAll("script[src]").forEach(d=>{let g=d.getAttribute("src");g&&!l.has(me(g,s))&&a.push(d)}),a}function J(r,s={}){let a=++D,l=A.get(r);if(l){let y=new DOMParser().parseFromString(l,"text/html");Ee(l,r,Re(y,r),s);return}$(),N&&N.abort(),N=new AbortController;let d=N.signal;fetch(r,{headers:{Accept:"text/html"},signal:d}).then(g=>{if(a===D)return g.ok?g.text().then(y=>{if(a!==D)return;let R=new DOMParser().parseFromString(y,"text/html");Ee(y,r,Re(R,r),s)}):(g.status>=500?ot():rt()).then(w=>{a===D&&(w?nt(w,r):location.href=r)})}).catch(g=>{g?.name!=="AbortError"&&(k(),location.href=r)}).finally(()=>{N&&!d.aborted&&(N=void 0)})}let Le=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||!u(s))return;r.preventDefault();let a=s.getAttribute("href");if(!a)return;let l=new URL(a,location.origin).href,d=s.hasAttribute("data-krate-replace"),g=s.getAttribute("data-krate-scroll")!=="false";if(a===location.pathname+location.search+location.hash){d&&history.replaceState({},"",a),Ae(l,{scroll:g});return}J(l,{replace:d,scroll:g})},Pe=()=>{J(location.href,{restoreScroll:!0})};document.addEventListener("click",Le),window.addEventListener("popstate",Pe),B(),Xe(),Ce(),we(document),W=(r,s={})=>{let a=!0;try{a=new URL(r,location.href).origin===location.origin}catch{a=!1}if(!a){location.href=r;return}J(new URL(r,location.href).href,s)},document.querySelectorAll("script[src]").forEach(r=>{he.test(r.src)||r.setAttribute("data-krate-spa","")}),U=()=>{document.removeEventListener("click",Le),window.removeEventListener("popstate",Pe),O(),W=null}}function Bt(){U&&(U(),U=null),ge=!1,We()}function Se(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)Se(n,t);return}if(typeof e=="object")for(let n of Object.keys(e))e[n]&&t.push(n)}}function ye(...e){let t=[];for(let n of e)Se(n,t);return t.join(" ")}function Te(...e){let t=[];for(let i of e)Se(i,t);let n=new Map,o=[];for(let i of t){let c=$t(i);n.has(c)||o.push(c),n.set(c,i)}return o.map(i=>n.get(i)).join(" ")}function $t(e){let t=e,n="",o=t.lastIndexOf(":");o>=0&&(n=t.slice(0,o+1),t=t.slice(o+1));let i=t.indexOf("-"),c=i>=0?t.slice(0,i):t,f=i>=0?t.slice(i+1,i+2):"";return n+c+(f&&/[0-9]/.test(f)?"-"+f:"")}function Yt(...e){return Te(ye(...e))}function Jt(e,t){let n=t?.variants??{},o=t?.defaultVariants??{};return i=>{let c={};for(let u of Object.keys(n)){let p=i?.[u]??o[u];p!=null&&(c[u]=String(p))}let f=[e];for(let u of Object.keys(n)){let p=c[u];p&&n[u][p]&&f.push(n[u][p])}for(let u of t?.compoundVariants??[])if(Xt(u,c,o)){let p=u.class;typeof p=="string"&&f.push(p)}let h=i?.class??i?.className;return typeof h=="string"&&f.push(h),Te(ye(f))}}function Xt(e,t,n){for(let o of Object.keys(e)){if(o==="class")continue;let i=e[o],c=t[o]??n[o]??void 0;if(Array.isArray(i)){if(!i.includes(c))return!1}else if(i!==c)return!1}return!0}function Gt(e){let t=Be(e?.children);return t?($e(t,e),t):null}function Be(e){if(e==null)return null;if(Array.isArray(e)){for(let t of e){let n=Be(t);if(n)return n}return null}return e instanceof Node?e:null}function $e(e,t){if(e instanceof Element)for(let n of Object.keys(t)){if(n==="children"||n==="ref")continue;let o=t[n];if(!(o==null||o===!1)){if(n==="class"||n==="className"){let i=e.getAttribute("class"),c=i?i+" "+String(o):String(o);e.setAttribute("class",c);continue}if(n==="style"&&typeof o=="object"){for(let[i,c]of Object.entries(o))e.style.setProperty(Qt(i),String(c));continue}if(n.startsWith("on")&&typeof o=="function"){e[n]=o;continue}if(o===!0){e.setAttribute(n,"");continue}e.setAttribute(n,String(o))}}}function Qt(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function Zt(e,t,...n){if(!(e instanceof Node))return e;if(t&&$e(e,t),n.length>0&&e instanceof Element){e.textContent="";for(let o of n)o instanceof Node?e.appendChild(o):o!=null&&e.appendChild(document.createTextNode(String(o)))}return e}return dt(en);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
@@ -1,2 +1,2 @@
1
- var __krate_exports=(()=>{var Q=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var gt=Object.prototype.hasOwnProperty;var ft=(e,t)=>{for(var n in t)Q(e,n,{get:t[n],enumerable:!0})},bt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of dt(t))!gt.call(e,s)&&s!==n&&Q(e,s,{get:()=>t[s],enumerable:!(r=ct(t,s))||r.enumerable});return e};var mt=e=>bt(Q({},"__esModule",{value:!0}),e);var an={};ft(an,{Fragment:()=>zt,Slot:()=>rn,clearNodes:()=>Ke,clearPersisted:()=>Et,cloneElement:()=>on,clsx:()=>Te,cn:()=>en,conditional:()=>Wt,createCSSChoice:()=>Ht,createCSSFlags:()=>Lt,createCSSGroup:()=>St,createCSSRange:()=>xt,createCSSStack:()=>kt,createCSSToggle:()=>Mt,createContext:()=>ee,createEffect:()=>x,createMemo:()=>Rt,createReducer:()=>Ot,createResource:()=>qt,createScope:()=>ht,createScopeFlags:()=>Tt,createSignal:()=>y,cva:()=>tn,disposeAll:()=>At,disposeNode:()=>L,forwardRef:()=>_t,h:()=>U,hydrate:()=>Ft,initRouter:()=>Ge,insert:()=>Bt,jsx:()=>Fe,jsxs:()=>jt,mount:()=>Vt,navigate:()=>$t,onCleanup:()=>j,onMount:()=>Pt,readDurableState:()=>ie,readPersisted:()=>se,reconcile:()=>Ut,reconcileTrees:()=>Xt,reinitRouter:()=>Qt,resetContexts:()=>Z,resolvePersist:()=>re,subscribePersist:()=>ae,twMerge:()=>ve,useRef:()=>It,writePersisted:()=>oe});var pt=0,R=new Map;function Z(){for(let[e,t]of R)if(t.length>0){let n=t[0];R.set(e,[n])}}function ht(){return ee({})}function Tt(){return ee({})}function ee(e){let t=pt++;R.set(t,[e]);let n=()=>{let r=R.get(t);return r&&r.length>0?r[r.length-1]:e};return{id:t,defaultValue:e,Provider:r=>{let s=R.get(t)||[e];s.push(r.value),R.set(t,s);let a=document.createElement("div");if(a.style.display="contents",r.children)for(let u of r.children)u instanceof Node?a.appendChild(u):u!=null&&a.appendChild(document.createTextNode(String(u)));return s.pop(),s.length===0&&s.push(e),a},useContext:n,use:n}}function vt(){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=vt();function Re(){return typeof window<"u"}function ne(e){if(e&&typeof e=="object")return e;if(!Re())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??(r=>JSON.stringify(r)),deserialize:t.deserialize??(r=>JSON.parse(r)),sync:t.sync??n==="local"}}function ie(e,t){let r=globalThis.__KRATE_STATE__;if(!r||!Object.prototype.hasOwnProperty.call(r,e))return{found:!1};let s=r[e];if(typeof s=="string")try{return{found:!0,value:t(s)}}catch{return{found:!0,value:s}}return{found:!0,value:s}}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 Et(e){let t=ne(e.store);try{t.removeItem(e.key)}catch{}}var V=new Map,Ne=!1;function yt(){Ne||!Re()||(Ne=!0,window.addEventListener("storage",e=>{if(e.key===null)return;let t=V.get(e.key);if(t)for(let n of t)n(e.newValue)}))}function ae(e,t){if(!e.sync)return()=>{};let n=V.get(e.key)??new Set;return n.add(t),V.set(e.key,n),yt(),()=>{n.delete(t),n.size===0&&V.delete(e.key)}}var C=[],Oe=[],ue=!1,O=new Set,le=[],ce=[],F=!1;function Ie(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 At(){for(let e of O)de(e);O.clear();for(let e of le)try{e()}catch{}le.length=0,ce.length=0,F=!1,Z()}function Ht(e,t){return z(y(e))}function Mt(e,t){return z(y(e))}function Lt(e,t){let n={};for(let a of e){let[u]=y(!1);n[a]=u}let s=[n,(a,u)=>{}];return s.trigger=a=>({"data-krate-scope":"trigger",value:a}),s.panel=a=>({"data-krate-scope":"panel",value:a}),s.close=()=>({"data-krate-scope":"close"}),s}function St(e,t){return z(y(e))}function xt(e,t){return z(y(e))}function z(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 kt(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:r=>{},pop:()=>{},clear:()=>{}}]}function y(e,t){let n=e,r=null;if(t?.persist){r=re(t.persist);let d=ie(r.key,r.deserialize);if(d.found)n=d.value;else{let l=se(r);l.found&&(n=l.value)}}let s=new Set,a=()=>{let d=C[C.length-1];return d&&!d.disposed&&(s.add(d),d.sources.add(s)),n},u=()=>{let d=Array.from(s);for(let l of d){if(l.disposed){s.delete(l);continue}if(l.running){l.rerun=!0;continue}l.queued||(l.queued=!0,ce.push(l))}wt()},T=d=>{let l=typeof d=="function"?d(n):d;l!==n&&(n=l,r&&oe(r,n),u())};if(r&&r.sync){let d=r,l=ae(d,m=>{if(m!==null)try{let b=d.deserialize(m);b!==n&&(n=b,u())}catch{}});j(l)}return[a,T]}function wt(){F||(F=!0,queueMicrotask(Ct))}function Ct(){F=!1;let e=ce.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,q(t),t.rerun&&!t.disposed&&(t.rerun=!1,q(t)))}function q(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,C.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{C.pop(),e.running=!1}}function x(e){let t=Ie(e);return O.add(t),q(t),()=>{de(t),O.delete(t)}}function j(e){let t=C[C.length-1];t?t.cleanups.push(e):le.push(e)}function Pt(e){Oe.push(e),ue||(ue=!0,queueMicrotask(Nt))}function Nt(){ue=!1;let e=Oe.splice(0);for(let t of e)t()}function Rt(e){let[t,n]=y(void 0),r=Ie(()=>{let a=e();n(a)});O.add(r),q(r);let s=C[C.length-1];return s&&s.cleanups.push(()=>{r.disposed||(de(r),O.delete(r))}),t}function Ot(e,t){let[n,r]=y(t);return[n,a=>r(u=>e(u,a))]}function It(e){return{current:e}}function _t(e){return t=>e(t,t.ref||(()=>{}))}var Dt={doubleclick:"dblclick",focus:"focusin",blur:"focusout",change:"input"},ge=new WeakMap;function De(e,t){let n=ge.get(e);n||(n=[],ge.set(e,n)),n.push(t)}function L(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++)L(e.childNodes[n])}function Kt(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function Ke(e,t){let n=e.parentNode;if(!n)return;let r=e.nextSibling;for(;r&&r!==t;){let s=r.nextSibling;L(r),n.removeChild(r),r=s}}function Bt(e,t,n){let r=Kt(n);r?(Ke(n,r),fe(e,t,r)):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 r of t)fe(e,r,n)}}function _e(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 r=t.slice(2).toLowerCase(),s=Dt[r]||r,a=`__krate_${s}`,u=e[a];u&&e.removeEventListener(s,u),e.addEventListener(s,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),De(n,x(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function U(e,t,...n){if(typeof e=="function")return e({...t||{},children:n});let r=document.createElement(e);if(t)for(let[s,a]of Object.entries(t))typeof a=="function"&&!s.startsWith("on")?De(r,x(()=>_e(r,s,a()))):_e(r,s,a);for(let s of n)Be(r,s);return r}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 Vt(e,t){let n=Ve(t),r=!1;x(()=>{r||(r=!0,n.appendChild(e()))})}function Ft(e,t){let n=Ve(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&L(r)}function qt(e,t){let[n,r]=y(void 0),[s,a]=y(!0),[u,T]=y(void 0),[d,l]=y("unresolved"),[m,b]=y(0),f,E=()=>typeof e=="function"?e():e,v=async()=>{f&&f.abort(),f=new AbortController;let S=f,K=E();l(m()>0?"refreshing":"loading"),a(!0),T(void 0);try{let k=await t(K,{signal:S.signal});S.signal.aborted||(r(()=>k),l("ready"))}catch(k){k?.name!=="AbortError"&&!S.signal.aborted&&(T(k),l("error"))}finally{S.signal.aborted||a(!1)}};x(()=>{typeof e=="function"&&e.length===0&&e(),m(),v(),j(()=>{f&&(f.abort(),f=void 0)})});let A=function(){return n()};return Object.defineProperties(A,{loading:{get:()=>s()},error:{get:()=>u()},state:{get:()=>d()}}),[A,{mutate:S=>{r(S)},refetch:()=>{b(S=>S+1)}}]}function zt(e){let t=document.createDocumentFragment(),n=e.children;if(n){let r=Array.isArray(n)?n:[n];for(let s of r)s instanceof Node?t.appendChild(s):t.appendChild(document.createTextNode(String(s)))}return t}function Fe(e,t,n){let r=e;if(!t)return U(r,null);let{children:s,...a}=t,u=s!==void 0?Array.isArray(s)?s:[s]:[];return U(r,Object.keys(a).length>0?a:null,...u)}function jt(e,t,n){return Fe(e,t,n)}function Ut(e,t,n,r,s,a){let u=[],T=t.nextSibling;for(;T&&T!==n;)u.push(T),T=T.nextSibling;if(a){let d=new Map;for(let m of u){let b=m.__k;b!=null&&!d.has(b)&&d.set(b,m)}let l=[];for(let m=0;m<r.length;m++){let b=a(r[m]),f=d.get(b);f?d.delete(b):(f=s(r[m],m),f.__k=b),l.push(f)}for(let m of d.values())m.parentNode===e&&(L(m),e.removeChild(m));for(let m=0;m<l.length;m++){let b=m===0?t:l[m-1];l[m]!==b.nextSibling&&e.insertBefore(l[m],b.nextSibling)}}else{let d=Math.max(u.length,r.length);for(let l=0;l<d;l++)if(l<r.length){let m=s(r[l],l);l<u.length?u[l]!==m&&(L(u[l]),e.replaceChild(m,u[l])):e.insertBefore(m,n)}else l<u.length&&u[l].parentNode===e&&(L(u[l]),e.removeChild(u[l]))}}function Wt(e,t,n,r,s,a){let u=null;x(()=>{let d=r()?s():a?a():null;u?d?(L(u),e.replaceChild(d,u)):(L(u),e.removeChild(u)):d&&e.insertBefore(d,n),u=d})}function I(e){if(e.nodeType===Node.COMMENT_NODE){let t=e.nodeValue||"";return t.indexOf("k:")===0?t:null}if(e.nodeType===Node.ELEMENT_NODE){let t=e,n=t.getAttribute("data-k");if(n)return n;let r=t.getAttribute("id");if(r)return"#"+r}return null}function qe(e,t){let n=new Set;for(let r=0;r<t.attributes.length;r++){let s=t.attributes[r].name,a=t.attributes[r].value;n.add(s),e.getAttribute(s)!==a&&e.setAttribute(s,a)}for(let r=0;r<e.attributes.length;r++){let s=e.attributes[r].name;n.has(s)||e.removeAttribute(s)}}function be(e,t){let n=document.importNode(t,!0);return e.parentNode&&(L(e),e.parentNode.replaceChild(n,e)),n}function ze(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!0}function me(e,t){if(!ze(e,t))return be(e,t);if(e.nodeType===Node.TEXT_NODE)return e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e;if(e.nodeType===Node.COMMENT_NODE)return e.nodeValue!==t.nodeValue?be(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,r=t;return I(n)!==I(r)?be(n,r):(qe(n,r),je(n,r),n)}function je(e,t){let n=Array.from(e.childNodes),r=Array.from(t.childNodes);if(n.length===r.length){let b=!0;for(let f=0;f<r.length;f++)if(I(n[f])!==I(r[f])){b=!1;break}if(b){for(let f=0;f<r.length;f++)me(n[f],r[f]);return}}let s=new Map,a=[];n.forEach((b,f)=>{let E=I(b);E!=null?s.has(E)||s.set(E,f):a.push(f)});let u=new Set,T=0,d=null,l=0,m=()=>{for(;l<a.length&&u.has(a[l]);)l++;return l<a.length?a[l]:-1};for(let b of r){let f=I(b),E;if(f!=null&&s.has(f)){let v=s.get(f);s.delete(f),u.add(v);let A=n[v];v<T?e.insertBefore(A,d):T=v,E=me(A,b)}else if(f==null){let v=m();if(v>=0&&ze(n[v],b)){u.add(v);let A=n[v];A.parentNode===e&&A.nextSibling!==d&&e.insertBefore(A,d),E=me(A,b)}else E=document.importNode(b,!0),e.insertBefore(E,d)}else E=document.importNode(b,!0),e.insertBefore(E,d);d=E.nextSibling}n.forEach((b,f)=>{!u.has(f)&&b.parentNode===e&&(L(b),e.removeChild(b))})}function Xt(e,t){if(e.nodeType!==Node.ELEMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return;let n=e,r=t;if(n.tagName!==r.tagName){let s=document.importNode(t,!0);n.parentNode&&n.parentNode.replaceChild(s,n);return}qe(n,r),je(n,r)}var pe=!1,_,X=null,W=0,P=new Map,Gt=30,D=new Map,Jt=50,Ue=/\/chunks\/runtime\.[^/]+\.js$/;function Xe(){return globalThis.__KRATE_CFG__||{}}function Yt(){let e=Xe().basePath||"";return!e||e==="/"?"":"/"+e.replace(/^\/+|\/+$/g,"")}function We(e){let t=Yt();if(t&&(e===t||e.startsWith(t+"/"))){let n=e.slice(t.length);return n===""?"/":n}return e}var G=null;function $t(e,t={}){return G?(G(e,t),!1):(typeof location<"u"&&(location.href=e),!0)}function Ge(){if(typeof document>"u"||pe)return;pe=!0;let e="#root, main, .docs-content",t=150,n=200,r=null,s=null,a=new Map,u=null;function T(i){for(let o of e.split(", ")){let c=i.querySelector(o.trim());if(c)return c}return i.body}function d(i){if(i.hasAttribute("data-krate-external"))return!1;let o=i.getAttribute("href");return!(!o||o.startsWith("#")||o.startsWith("javascript:")||i.origin!==location.origin||i.target==="_blank")}function l(i){P.has(i)||fetch(i,{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>{if(o){if(P.size>=Gt){let c=P.keys().next().value;c!==void 0&&P.delete(c)}P.set(i,o)}}).catch(()=>{})}function m(){document.addEventListener("mouseover",E),document.addEventListener("focusin",E),typeof IntersectionObserver<"u"&&(u=new IntersectionObserver(i=>{for(let o of i)if(o.isIntersecting){let c=o.target,g=c.getAttribute("href");if(g&&d(c)){let p=new URL(g,location.origin).href;l(p)}u.unobserve(o.target)}},{rootMargin:"200px"}),b())}function b(){u&&document.querySelectorAll("a[data-prefetch]").forEach(i=>{u.observe(i)})}function f(){document.removeEventListener("mouseover",E),document.removeEventListener("focusin",E);for(let i of a.values())clearTimeout(i);a.clear(),u&&(u.disconnect(),u=null)}function E(i){let o=i.target.closest("a[data-prefetch]");if(!o||!d(o))return;let c=o.getAttribute("href");if(!c)return;let g=new URL(c,location.origin).href;if(P.has(g))return;let p=a.get(o);p&&clearTimeout(p);let h=setTimeout(()=>{a.delete(o),l(g)},n);a.set(o,h)}let v=null;function A(){if(k())return;let i=T(document),o=document.querySelector("template[data-krate-loading]");o&&o.content&&i&&(v=o.content.cloneNode(!0),document.body.appendChild(v)),i&&(i.style.transition=`opacity ${t}ms ease`,i.style.opacity="0")}function J(){if(k())return;v&&v.parentNode&&v.parentNode.removeChild(v),v=null;let i=T(document);i&&(i.style.opacity="1")}function S(i){try{let o=globalThis.__krate_onNavigation;typeof o=="function"&&o(i)}catch{}}function K(i,o){try{window.dispatchEvent(new CustomEvent(i,{detail:{url:o}}))}catch{}}function k(){if(Xe().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 $e(i){let o=i.querySelectorAll('link[rel="stylesheet"]'),c=new Set;o.forEach(p=>{let h=p.getAttribute("href");h&&c.add(new URL(h,location.origin).href)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(p=>{let h=p.href;h&&!c.has(h)&&p.remove()});let g=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(p=>g.add(p.href)),o.forEach(p=>{let h=p.getAttribute("href");if(!h)return;let H=new URL(h,location.origin).href;if(!g.has(H)){let w=document.createElement("link");w.rel="stylesheet",w.href=H,document.head.appendChild(w)}})}function Ee(i){i.querySelectorAll("[data-view-transition]").forEach(o=>{let c=o.getAttribute("data-view-transition");c&&(o.style.viewTransitionName=c)})}function Qe(){let i=T(document);if(i){i.hasAttribute("tabindex")||i.setAttribute("tabindex","-1");try{i.focus({preventScroll:!0})}catch{try{i.focus()}catch{}}}}function Ze(){let i=HTMLScriptElement.supports;if(!(typeof i!="function"||!i("speculationrules")))try{let o=document.createElement("script");o.type="speculationrules",o.textContent=JSON.stringify({prefetch:[{where:{and:[{href_matches:"/*"},{not:{href_matches:"/__krate/*"}},{not:{href_matches:"/api/*"}}]},eagerness:"moderate"}]}),document.head.appendChild(o)}catch{}}function ye(i){return i.getElementById("root")||i.body}let Ae='meta[name="description"], meta[property^="og:"], meta[name^="twitter:"], link[rel="canonical"], script[type="application/ld+json"]';function et(i){document.head.querySelectorAll(Ae).forEach(o=>o.remove()),i.head.querySelectorAll(Ae).forEach(o=>{document.head.appendChild(document.importNode(o,!0))})}function He(i,o,c,g={}){let{replace:p=!1,scroll:h=!0,restoreScroll:H=!1}=g,N=new DOMParser().parseFromString(i,"text/html"),Ce=ye(N),Pe=ye(document);if(!Ce||!Pe){location.href=o;return}K("krate:navigate-start",o);let $=()=>{let M=N.querySelector("title");M&&(document.title=M.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll();let B=Array.from(Ce.childNodes).map(lt=>document.importNode(lt,!0));Pe.replaceChildren(...B),$e(N),et(N),Ee(document)};if(k())try{let M=document.startViewTransition($);M&&M.finished&&typeof M.finished.catch=="function"&&M.finished.catch(()=>{})}catch{$()}else $();nt(c,o).then(()=>{try{it(),b()}catch(M){try{let B=globalThis.__krate_onHydrationError;typeof B=="function"&&B(M)}catch{}location.href=o}}),J();let ut=location.pathname+location.search;if(p)history.replaceState({},"",o);else{if(!H){if(D.size>=Jt){let M=D.keys().next().value;M!==void 0&&D.delete(M)}D.set(ut,window.scrollY)}history.pushState({},"",o)}Me(o,{restoreScroll:H,scroll:h}),H||Qe(),Le(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:o}})),K("krate:navigate-end",o),S(o)}function tt(i){let o=i.indexOf("#");if(o<0||o===i.length-1)return!1;let c=i.slice(o);try{let g=document.querySelector(c);if(g)return g.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch{return!1}return!1}function Me(i,o){if(o.restoreScroll){let c=D.get(i);if(c!==void 0){window.scrollTo(0,c);return}}tt(i)||o.scroll&&window.scrollTo(0,0)}function Le(){let i=We(location.pathname);document.querySelectorAll("a[data-krate-link]").forEach(o=>{let c=o.getAttribute("href");if(!c){o.removeAttribute("aria-current");return}let g=c;try{g=We(new URL(c,location.origin).pathname)}catch{return}g===i||i==="/"&&(g===""||g==="/")||g!=="/"&&g.length>1&&i.startsWith(g)?o.setAttribute("aria-current","page"):o.removeAttribute("aria-current")})}function nt(i,o){return i.length===0?Promise.resolve():Promise.all(i.map(c=>{let g=c.getAttribute("src");return g?rt(g,o):Promise.resolve()})).then(()=>{})}function rt(i,o){return new Promise(c=>{let g=document.createElement("script"),p=Se(i,o);g.src=p,Ue.test(p)||g.setAttribute("data-krate-spa",""),g.onload=()=>c(),g.onerror=()=>c(),document.body.appendChild(g)})}function Se(i,o){if(/^(https?:)?\/\//.test(i)||i.startsWith("/"))return new URL(i,o).href;let c=o;if(!c.endsWith("/")){let g=c.lastIndexOf("/");c=g>0?c.slice(0,g+1):"/"}return new URL(i,c).href}function it(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function st(i,o){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",o),S(o),document.open(),document.write(i),document.close()}function ot(){return r!==null?Promise.resolve(r):fetch("/404.html",{headers:{Accept:"text/html"}}).then(i=>i.ok?i.text():null).then(i=>(r=i,i)).catch(()=>null)}function at(){return s!==null?Promise.resolve(s):fetch("/500.html",{headers:{Accept:"text/html"}}).then(i=>i.ok?i.text():null).then(i=>(s=i,i)).catch(()=>null)}function xe(i,o){document.querySelectorAll("script[data-krate-spa]").forEach(p=>p.remove());let c=[],g=new Set;return document.querySelectorAll("script[src]").forEach(p=>{g.add(p.src)}),i.querySelectorAll("script[src]").forEach(p=>{let h=p.getAttribute("src");h&&!g.has(Se(h,o))&&c.push(p)}),c}function Y(i,o={}){let c=++W,g=P.get(i);if(g){let H=new DOMParser().parseFromString(g,"text/html");He(g,i,xe(H,i),o);return}A(),_&&_.abort(),_=new AbortController;let p=_.signal;fetch(i,{headers:{Accept:"text/html"},signal:p}).then(h=>{if(c===W)return h.ok?h.text().then(H=>{if(c!==W)return;let N=new DOMParser().parseFromString(H,"text/html");He(H,i,xe(N,i),o)}):(h.status>=500?at():ot()).then(w=>{c===W&&(w?st(w,i):location.href=i)})}).catch(h=>{h?.name!=="AbortError"&&(J(),location.href=i)}).finally(()=>{_&&!p.aborted&&(_=void 0)})}let ke=i=>{if(i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey)return;let o=i.target.closest("a[data-krate-link]");if(!o||!d(o))return;i.preventDefault();let c=o.getAttribute("href");if(!c)return;let g=new URL(c,location.origin).href,p=o.hasAttribute("data-krate-replace"),h=o.getAttribute("data-krate-scroll")!=="false";if(c===location.pathname+location.search+location.hash){p&&history.replaceState({},"",c),Me(g,{scroll:h});return}Y(g,{replace:p,scroll:h})},we=()=>{Y(location.href,{restoreScroll:!0})};document.addEventListener("click",ke),window.addEventListener("popstate",we),m(),Ze(),Le(),Ee(document),G=(i,o={})=>{let c=!0;try{c=new URL(i,location.href).origin===location.origin}catch{c=!1}if(!c){location.href=i;return}Y(new URL(i,location.href).href,o)},document.querySelectorAll("script[src]").forEach(i=>{Ue.test(i.src)||i.setAttribute("data-krate-spa","")}),X=()=>{document.removeEventListener("click",ke),window.removeEventListener("popstate",we),f(),G=null}}function Qt(){X&&(X(),X=null),pe=!1,Ge()}function he(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)he(n,t);return}if(typeof e=="object")for(let n of Object.keys(e))e[n]&&t.push(n)}}function Te(...e){let t=[];for(let n of e)he(n,t);return t.join(" ")}function ve(...e){let t=[];for(let s of e)he(s,t);let n=new Map,r=[];for(let s of t){let a=Zt(s);n.has(a)||r.push(a),n.set(a,s)}return r.map(s=>n.get(s)).join(" ")}function Zt(e){let t=e,n="",r=t.lastIndexOf(":");r>=0&&(n=t.slice(0,r+1),t=t.slice(r+1));let s=t.indexOf("-"),a=s>=0?t.slice(0,s):t,u=s>=0?t.slice(s+1,s+2):"";return n+a+(u&&/[0-9]/.test(u)?"-"+u:"")}function en(...e){return ve(Te(...e))}function tn(e,t){let n=t?.variants??{},r=t?.defaultVariants??{};return s=>{let a={};for(let d of Object.keys(n)){let l=s?.[d]??r[d];l!=null&&(a[d]=String(l))}let u=[e];for(let d of Object.keys(n)){let l=a[d];l&&n[d][l]&&u.push(n[d][l])}for(let d of t?.compoundVariants??[])if(nn(d,a,r)){let l=d.class;typeof l=="string"&&u.push(l)}let T=s?.class??s?.className;return typeof T=="string"&&u.push(T),ve(Te(u))}}function nn(e,t,n){for(let r of Object.keys(e)){if(r==="class")continue;let s=e[r],a=t[r]??n[r]??void 0;if(Array.isArray(s)){if(!s.includes(a))return!1}else if(s!==a)return!1}return!0}function rn(e){let t=Je(e?.children);return t?(Ye(t,e),t):null}function Je(e){if(e==null)return null;if(Array.isArray(e)){for(let t of e){let n=Je(t);if(n)return n}return null}return e instanceof Node?e:null}function Ye(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 s=e.getAttribute("class"),a=s?s+" "+String(r):String(r);e.setAttribute("class",a);continue}if(n==="style"&&typeof r=="object"){for(let[s,a]of Object.entries(r))e.style.setProperty(sn(s),String(a));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 sn(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function on(e,t,...n){if(!(e instanceof Node))return e;if(t&&Ye(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}return mt(an);})();
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);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
@@ -0,0 +1 @@
1
+ export { jsx, jsxs, jsxDEV, Fragment } from './react.js';
@@ -0,0 +1,3 @@
1
+ // React automatic-JSX-runtime shim: `react/jsx-runtime` and
2
+ // `react/jsx-dev-runtime` resolve here for compiled React code.
3
+ export { jsx, jsxs, jsxDEV, Fragment } from './react.js';
@@ -0,0 +1,100 @@
1
+ /**
2
+ * React compatibility runtime.
3
+ *
4
+ * Compiled React libraries (for example `@radix-ui/react-*`) and React source
5
+ * that the compiler could not lower statically resolve to this module. It
6
+ * implements the React API surface on top of Krate's DOM factory, signals, and
7
+ * context so that code can execute without shipping React.
8
+ *
9
+ * Krate components run once and update through signals, so hooks here are
10
+ * signal-backed rather than re-render based. Pure APIs (`createElement`,
11
+ * `Children`, `cloneElement`, `isValidElement`, `createRef`, `createContext`)
12
+ * behave as expected; scheduling APIs (`useTransition`, `startTransition`,
13
+ * `useDeferredValue`) are best-effort. Class components are intentionally
14
+ * minimal.
15
+ */
16
+ import { h, type Component } from './dom.js';
17
+ import { jsx as krateJsx } from './jsx-runtime.js';
18
+ /** React's `Fragment` marker; `createElement(Fragment, ...)` yields a fragment. */
19
+ export declare const Fragment: unique symbol;
20
+ export type ReactChild = unknown;
21
+ /**
22
+ * `React.createElement(type, config, ...children)`. Returns a Krate DOM node
23
+ * (elements) or the result of the component function, matching `h`.
24
+ */
25
+ export declare function createElement(type: unknown, config?: Record<string, unknown> | null, ...children: unknown[]): Node;
26
+ export declare const jsx: typeof krateJsx;
27
+ export declare const jsxs: typeof krateJsx;
28
+ export declare function jsxDEV(type: unknown, props: Record<string, unknown> | null, _key?: unknown, _isStatic?: boolean, _source?: unknown, _self?: unknown): Node;
29
+ /** `React.Children` helpers over arrays and single values. */
30
+ export declare const Children: {
31
+ map(children: unknown, fn: (child: unknown, index: number) => unknown): unknown[];
32
+ forEach(children: unknown, fn: (child: unknown, index: number) => void): void;
33
+ count(children: unknown): number;
34
+ toArray(children: unknown): unknown[];
35
+ only(children: unknown): unknown;
36
+ };
37
+ export declare function cloneElement(element: Node, props?: Record<string, unknown> | null, ...children: unknown[]): Node;
38
+ export declare function isValidElement(value: unknown): boolean;
39
+ export interface RefObject<T> {
40
+ current: T | null;
41
+ }
42
+ export declare function createRef<T = unknown>(): RefObject<T>;
43
+ export declare function forwardRef(render: unknown): unknown;
44
+ export declare function memo<P>(component: Component<P>, _compare?: unknown): Component<P>;
45
+ export declare function lazy(loader: unknown): unknown;
46
+ export declare const StrictMode: symbol;
47
+ export declare const Profiler: symbol;
48
+ export declare const Suspense: symbol;
49
+ export interface ReactContext<T> {
50
+ readonly _id: number;
51
+ readonly defaultValue: T;
52
+ readonly Provider: (props: {
53
+ value: T;
54
+ children?: unknown;
55
+ }) => Node;
56
+ readonly Consumer: (props: {
57
+ children: (value: T) => unknown;
58
+ }) => unknown;
59
+ useContext(): T;
60
+ use(): T;
61
+ }
62
+ export declare function createContext<T>(defaultValue: T): ReactContext<T>;
63
+ export declare function useContext<T>(ctx: ReactContext<T>): T;
64
+ export declare function useState<T>(initial: T | (() => T)): [() => T, (value: T | ((prev: T) => T)) => void];
65
+ export declare function useReducer<S, A>(reducer: (state: S, action: A) => S, initial: S): [() => S, (action: A) => void];
66
+ export declare function useMemo<T>(factory: () => T, _deps?: unknown[]): T;
67
+ export declare function useCallback<T extends (...args: never[]) => unknown>(fn: T, _deps?: unknown[]): T;
68
+ export declare function useRef<T = unknown>(initial?: T): RefObject<T>;
69
+ export declare function useEffect(effect: () => void | (() => void), _deps?: unknown[]): void;
70
+ export declare const useLayoutEffect: typeof useEffect;
71
+ export declare const useInsertionEffect: typeof useEffect;
72
+ export declare function useImperativeHandle<T>(ref: RefObject<T> | ((v: T) => void) | null, create: () => T): void;
73
+ export declare function useDebugValue(_value?: unknown): void;
74
+ export declare function useSyncExternalStore<T>(subscribe: (onChange: () => void) => () => void, getSnapshot: () => T): () => T;
75
+ export declare function useTransition(): [() => boolean, (fn: () => void) => void];
76
+ export declare function useOptimistic<T>(initial: T, update?: (state: T, action: T) => T): [() => T, (action: T) => void];
77
+ export declare function useActionState<State, Payload>(action: (prev: State, payload: Payload) => State | Promise<State>, initial: State): [() => State, (payload: Payload) => Promise<void>, () => boolean];
78
+ export declare function useFormStatus(): {
79
+ pending: boolean;
80
+ data: FormData | null;
81
+ method: string | null;
82
+ action: string | null;
83
+ };
84
+ export declare function useDeferredValue<T>(value: T): T;
85
+ export declare function startTransition(fn: () => void): void;
86
+ export declare function use<T>(value: T | ReactContext<T>): T;
87
+ export declare function flushSync<T>(fn: () => T): T;
88
+ export declare function createPortal(children: unknown, container: Element | DocumentFragment): Element | DocumentFragment;
89
+ /** Minimal class base so compiled code that `extends React.Component` resolves. */
90
+ export declare class ComponentBase {
91
+ props: Record<string, unknown>;
92
+ state: Record<string, unknown>;
93
+ constructor(props?: Record<string, unknown>);
94
+ setState(update: unknown): void;
95
+ render(): Node | null;
96
+ }
97
+ export declare const reactCompat: {
98
+ h: typeof h;
99
+ Fragment: symbol;
100
+ };
package/dist/react.js ADDED
@@ -0,0 +1,255 @@
1
+ /**
2
+ * React compatibility runtime.
3
+ *
4
+ * Compiled React libraries (for example `@radix-ui/react-*`) and React source
5
+ * that the compiler could not lower statically resolve to this module. It
6
+ * implements the React API surface on top of Krate's DOM factory, signals, and
7
+ * context so that code can execute without shipping React.
8
+ *
9
+ * Krate components run once and update through signals, so hooks here are
10
+ * signal-backed rather than re-render based. Pure APIs (`createElement`,
11
+ * `Children`, `cloneElement`, `isValidElement`, `createRef`, `createContext`)
12
+ * behave as expected; scheduling APIs (`useTransition`, `startTransition`,
13
+ * `useDeferredValue`) are best-effort. Class components are intentionally
14
+ * minimal.
15
+ */
16
+ import { h } from './dom.js';
17
+ import { createSignal, createEffect } from './signal.js';
18
+ import { createContext as krateCreateContext } from './context.js';
19
+ import { cloneElement as krateCloneElement } from './class-helpers.js';
20
+ import { jsx as krateJsx } from './jsx-runtime.js';
21
+ /** React's `Fragment` marker; `createElement(Fragment, ...)` yields a fragment. */
22
+ export const Fragment = Symbol.for('krate.react.fragment');
23
+ function fragmentChildren(children) {
24
+ const frag = document.createDocumentFragment();
25
+ for (const child of children) {
26
+ if (child == null || child === false || child === true)
27
+ continue;
28
+ if (child instanceof Node)
29
+ frag.appendChild(child);
30
+ else if (Array.isArray(child))
31
+ frag.appendChild(fragmentChildren(child));
32
+ else
33
+ frag.appendChild(document.createTextNode(String(child)));
34
+ }
35
+ return frag;
36
+ }
37
+ /**
38
+ * `React.createElement(type, config, ...children)`. Returns a Krate DOM node
39
+ * (elements) or the result of the component function, matching `h`.
40
+ */
41
+ export function createElement(type, config, ...children) {
42
+ if (type === Fragment)
43
+ return fragmentChildren(children);
44
+ const props = config ? { ...config } : {};
45
+ if (children.length === 1)
46
+ props.children = children[0];
47
+ else if (children.length > 1)
48
+ props.children = children;
49
+ return krateJsx(type, props);
50
+ }
51
+ export const jsx = krateJsx;
52
+ export const jsxs = krateJsx;
53
+ export function jsxDEV(type, props, _key, _isStatic, _source, _self) {
54
+ return krateJsx(type, props);
55
+ }
56
+ /** `React.Children` helpers over arrays and single values. */
57
+ export const Children = {
58
+ map(children, fn) {
59
+ return toArray(children).map((child, i) => fn(child, i));
60
+ },
61
+ forEach(children, fn) {
62
+ toArray(children).forEach((child, i) => fn(child, i));
63
+ },
64
+ count(children) {
65
+ return toArray(children).length;
66
+ },
67
+ toArray(children) {
68
+ return toArray(children);
69
+ },
70
+ only(children) {
71
+ const list = toArray(children);
72
+ if (list.length !== 1) {
73
+ throw new Error(`React.Children.only expected a single child, got ${list.length}`);
74
+ }
75
+ return list[0];
76
+ },
77
+ };
78
+ function toArray(children) {
79
+ if (children == null || children === false || children === true)
80
+ return [];
81
+ if (Array.isArray(children)) {
82
+ const out = [];
83
+ for (const child of children)
84
+ out.push(...toArray(child));
85
+ return out;
86
+ }
87
+ return [children];
88
+ }
89
+ export function cloneElement(element, props, ...children) {
90
+ return krateCloneElement(element, props, ...children);
91
+ }
92
+ export function isValidElement(value) {
93
+ return value instanceof Node || (typeof value === 'object' && value !== null);
94
+ }
95
+ export function createRef() {
96
+ return { current: null };
97
+ }
98
+ export function forwardRef(render) {
99
+ // Krate binds refs at compile time; render is returned unchanged.
100
+ return render;
101
+ }
102
+ export function memo(component, _compare) {
103
+ return component;
104
+ }
105
+ export function lazy(loader) {
106
+ // A synchronous passthrough: Krate cannot await a dynamic import at render
107
+ // time. Dynamic/lazy components require the SSR/islands path.
108
+ return loader;
109
+ }
110
+ export const StrictMode = Fragment;
111
+ export const Profiler = Fragment;
112
+ export const Suspense = Fragment;
113
+ export function createContext(defaultValue) {
114
+ const ctx = krateCreateContext(defaultValue);
115
+ return {
116
+ _id: ctx.id,
117
+ defaultValue,
118
+ Provider: (props) => ctx.Provider(props),
119
+ Consumer: (props) => props.children(ctx.useContext()),
120
+ useContext: ctx.useContext,
121
+ use: ctx.useContext,
122
+ };
123
+ }
124
+ export function useContext(ctx) {
125
+ return ctx.useContext();
126
+ }
127
+ // --- hooks ---
128
+ export function useState(initial) {
129
+ const value = typeof initial === 'function' ? initial() : initial;
130
+ return createSignal(value);
131
+ }
132
+ export function useReducer(reducer, initial) {
133
+ const [get, set] = createSignal(initial);
134
+ const dispatch = (action) => set((prev) => reducer(prev, action));
135
+ return [get, dispatch];
136
+ }
137
+ export function useMemo(factory, _deps) {
138
+ return factory();
139
+ }
140
+ export function useCallback(fn, _deps) {
141
+ return fn;
142
+ }
143
+ export function useRef(initial) {
144
+ return { current: initial ?? null };
145
+ }
146
+ export function useEffect(effect, _deps) {
147
+ createEffect(effect);
148
+ }
149
+ export const useLayoutEffect = useEffect;
150
+ export const useInsertionEffect = useEffect;
151
+ export function useImperativeHandle(ref, create) {
152
+ if (!ref)
153
+ return;
154
+ const value = create();
155
+ if (typeof ref === 'function')
156
+ ref(value);
157
+ else
158
+ ref.current = value;
159
+ }
160
+ export function useDebugValue(_value) {
161
+ // no-op
162
+ }
163
+ export function useSyncExternalStore(subscribe, getSnapshot) {
164
+ const [get, set] = createSignal(getSnapshot());
165
+ createEffect(() => {
166
+ const unsubscribe = subscribe(() => set(getSnapshot()));
167
+ return () => unsubscribe();
168
+ });
169
+ return get;
170
+ }
171
+ export function useTransition() {
172
+ const [pending, setPending] = createSignal(false);
173
+ const start = (fn) => {
174
+ setPending(true);
175
+ try {
176
+ fn();
177
+ }
178
+ finally {
179
+ setPending(false);
180
+ }
181
+ };
182
+ return [pending, start];
183
+ }
184
+ export function useOptimistic(initial, update) {
185
+ const [state, setState] = createSignal(initial);
186
+ const add = (action) => {
187
+ setState((prev) => (update ? update(prev, action) : action));
188
+ };
189
+ return [state, add];
190
+ }
191
+ export function useActionState(action, initial) {
192
+ const [state, setState] = createSignal(initial);
193
+ const [pending, setPending] = createSignal(false);
194
+ const dispatch = async (payload) => {
195
+ setPending(true);
196
+ try {
197
+ setState(await action(state(), payload));
198
+ }
199
+ finally {
200
+ setPending(false);
201
+ }
202
+ };
203
+ return [state, dispatch, pending];
204
+ }
205
+ export function useFormStatus() {
206
+ return { pending: false, data: null, method: null, action: null };
207
+ }
208
+ export function useDeferredValue(value) {
209
+ return value;
210
+ }
211
+ export function startTransition(fn) {
212
+ fn();
213
+ }
214
+ export function use(value) {
215
+ const ctx = value;
216
+ if (ctx && typeof ctx.useContext === 'function')
217
+ return ctx.useContext();
218
+ return value;
219
+ }
220
+ export function flushSync(fn) {
221
+ return fn();
222
+ }
223
+ export function createPortal(children, container) {
224
+ if (children instanceof Node)
225
+ container.appendChild(children);
226
+ else if (Array.isArray(children)) {
227
+ for (const child of children) {
228
+ if (child instanceof Node)
229
+ container.appendChild(child);
230
+ else if (child != null)
231
+ container.appendChild(document.createTextNode(String(child)));
232
+ }
233
+ }
234
+ else if (children != null) {
235
+ container.appendChild(document.createTextNode(String(children)));
236
+ }
237
+ return container;
238
+ }
239
+ /** Minimal class base so compiled code that `extends React.Component` resolves. */
240
+ export class ComponentBase {
241
+ constructor(props) {
242
+ this.props = props ?? {};
243
+ this.state = {};
244
+ }
245
+ setState(update) {
246
+ const next = typeof update === 'function'
247
+ ? update(this.state, this.props)
248
+ : update;
249
+ this.state = { ...this.state, ...next };
250
+ }
251
+ render() {
252
+ return null;
253
+ }
254
+ }
255
+ export const reactCompat = { h, Fragment };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,50 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { Children, Fragment, cloneElement, createContext, createElement, createRef, isValidElement, useContext, useOptimistic, useFormStatus, } from './react.js';
3
+ describe('react compat runtime', () => {
4
+ it('createElement builds DOM elements with props and children', () => {
5
+ const el = createElement('div', { class: 'x', id: 'a' }, 'hi');
6
+ expect(el.tagName).toBe('DIV');
7
+ expect(el.getAttribute('class')).toBe('x');
8
+ expect(el.getAttribute('id')).toBe('a');
9
+ expect(el.textContent).toBe('hi');
10
+ });
11
+ it('createElement(Fragment) flattens children', () => {
12
+ const frag = createElement(Fragment, null, createElement('a', null), createElement('b', null));
13
+ expect(frag.childNodes.length).toBe(2);
14
+ });
15
+ it('Children helpers flatten and map', () => {
16
+ expect(Children.map([1, 2, 3], (n) => n * 2)).toEqual([2, 4, 6]);
17
+ expect(Children.count([1, [2, 3]])).toBe(3);
18
+ expect(Children.toArray([1, [2, 3]])).toEqual([1, 2, 3]);
19
+ expect(() => Children.only([1, 2])).toThrow();
20
+ });
21
+ it('cloneElement applies props and replaces children', () => {
22
+ const el = createElement('span', { id: 'a' }, 'old');
23
+ const cloned = cloneElement(el, { id: 'b' }, 'new');
24
+ expect(cloned.getAttribute('id')).toBe('b');
25
+ expect(cloned.textContent).toBe('new');
26
+ });
27
+ it('isValidElement distinguishes elements', () => {
28
+ expect(isValidElement(createElement('div', null))).toBe(true);
29
+ expect(isValidElement(null)).toBe(false);
30
+ });
31
+ it('createRef starts empty', () => {
32
+ expect(createRef().current).toBeNull();
33
+ });
34
+ it('createContext falls back to its default', () => {
35
+ const Ctx = createContext('fallback');
36
+ expect(useContext(Ctx)).toBe('fallback');
37
+ expect(Ctx.defaultValue).toBe('fallback');
38
+ });
39
+ });
40
+ describe('react 19 compat shims', () => {
41
+ it('useOptimistic updates its getter', () => {
42
+ const [state, add] = useOptimistic(1);
43
+ expect(state()).toBe(1);
44
+ add(2);
45
+ expect(state()).toBe(2);
46
+ });
47
+ it('useFormStatus exposes an idle status', () => {
48
+ expect(useFormStatus()).toEqual({ pending: false, data: null, method: null, action: null });
49
+ });
50
+ });
package/dist/reconcile.js CHANGED
@@ -51,39 +51,55 @@ export function reconcile(parent, startMarker, endMarker, items, mapFn, keyFn) {
51
51
  parent.removeChild(child);
52
52
  }
53
53
  }
54
- // Reorder: insert nodes in the correct order before endMarker.
55
- for (let i = 0; i < newNodes.length; i++) {
54
+ // Place nodes in order. Newly created nodes (not yet attached) are gathered
55
+ // into consecutive runs and inserted as a single DocumentFragment, so a
56
+ // block of new items costs one DOM mutation instead of one per node. Reused
57
+ // nodes are moved individually only when they are out of position.
58
+ let i = 0;
59
+ while (i < newNodes.length) {
56
60
  const prevNode = i === 0 ? startMarker : newNodes[i - 1];
57
- if (newNodes[i] !== prevNode.nextSibling) {
58
- parent.insertBefore(newNodes[i], prevNode.nextSibling);
61
+ if (newNodes[i].parentNode !== parent) {
62
+ const frag = document.createDocumentFragment();
63
+ const ref = prevNode.nextSibling;
64
+ do {
65
+ frag.appendChild(newNodes[i]);
66
+ i++;
67
+ } while (i < newNodes.length && newNodes[i].parentNode !== parent);
68
+ parent.insertBefore(frag, ref);
69
+ }
70
+ else {
71
+ if (newNodes[i] !== prevNode.nextSibling) {
72
+ parent.insertBefore(newNodes[i], prevNode.nextSibling);
73
+ }
74
+ i++;
59
75
  }
60
76
  }
61
77
  }
62
78
  else {
63
- // Unkeyed: simple index-based reconciliation
64
- const maxLen = Math.max(existing.length, items.length);
65
- for (let i = 0; i < maxLen; i++) {
66
- if (i < items.length) {
67
- const newNode = mapFn(items[i], i);
68
- if (i < existing.length) {
69
- // Replace existing node
70
- if (existing[i] !== newNode) {
71
- disposeNode(existing[i]);
72
- parent.replaceChild(newNode, existing[i]);
73
- }
74
- }
75
- else {
76
- // Append new node before endMarker
77
- parent.insertBefore(newNode, endMarker);
78
- }
79
+ // Unkeyed: index-based reconciliation. Existing nodes are replaced in
80
+ // place, excess nodes are dropped, and the new tail is appended as a single
81
+ // DocumentFragment insert.
82
+ const existingLen = existing.length;
83
+ const replacementLen = Math.min(existingLen, items.length);
84
+ for (let i = 0; i < replacementLen; i++) {
85
+ const newNode = mapFn(items[i], i);
86
+ if (existing[i] !== newNode) {
87
+ disposeNode(existing[i]);
88
+ parent.replaceChild(newNode, existing[i]);
79
89
  }
80
- else if (i < existing.length) {
81
- // Remove excess existing nodes
82
- if (existing[i].parentNode === parent) {
83
- disposeNode(existing[i]);
84
- parent.removeChild(existing[i]);
85
- }
90
+ }
91
+ for (let i = items.length; i < existingLen; i++) {
92
+ if (existing[i].parentNode === parent) {
93
+ disposeNode(existing[i]);
94
+ parent.removeChild(existing[i]);
95
+ }
96
+ }
97
+ if (items.length > existingLen) {
98
+ const frag = document.createDocumentFragment();
99
+ for (let i = existingLen; i < items.length; i++) {
100
+ frag.appendChild(mapFn(items[i], i));
86
101
  }
102
+ parent.insertBefore(frag, endMarker);
87
103
  }
88
104
  }
89
105
  }
@@ -44,4 +44,67 @@ describe('reconcile', () => {
44
44
  reconcile(parent, start, end, [4, 2], map, (n) => n);
45
45
  expect(texts(parent, start, end)).toEqual(['4', '2']);
46
46
  });
47
+ it('reuses existing DOM nodes when reordering keys (no node thrash)', () => {
48
+ const parent = document.createElement('div');
49
+ const { start, end } = markers(parent);
50
+ let created = 0;
51
+ const map = (n) => {
52
+ created++;
53
+ return span(String(n));
54
+ };
55
+ reconcile(parent, start, end, [1, 2, 3, 4, 5], map, (n) => n);
56
+ expect(created).toBe(5);
57
+ // Full reversal: every key still exists, so no node should be recreated.
58
+ reconcile(parent, start, end, [5, 4, 3, 2, 1], map, (n) => n);
59
+ expect(created).toBe(5);
60
+ expect(texts(parent, start, end)).toEqual(['5', '4', '3', '2', '1']);
61
+ });
62
+ it('preserves the same node object for a persistent key', () => {
63
+ const parent = document.createElement('div');
64
+ const { start, end } = markers(parent);
65
+ reconcile(parent, start, end, ['a', 'b'], span, (s) => s);
66
+ const aNode = start.nextSibling; // the 'a' span
67
+ reconcile(parent, start, end, ['x', 'a', 'b'], span, (s) => s); // prepend
68
+ expect(texts(parent, start, end)).toEqual(['x', 'a', 'b']);
69
+ expect(start.nextSibling.nextSibling).toBe(aNode);
70
+ });
71
+ it('inserts a block of new keyed items in order', () => {
72
+ const parent = document.createElement('div');
73
+ const { start, end } = markers(parent);
74
+ reconcile(parent, start, end, ['3', '4', '5'], span, (s) => s);
75
+ reconcile(parent, start, end, ['1', '2', '3', '4', '5', '6'], span, (s) => s);
76
+ expect(texts(parent, start, end)).toEqual(['1', '2', '3', '4', '5', '6']);
77
+ });
78
+ it('handles a large keyed reorder without thrash', () => {
79
+ const parent = document.createElement('div');
80
+ const { start, end } = markers(parent);
81
+ const n = 1000;
82
+ const range = Array.from({ length: n }, (_, i) => i);
83
+ let created = 0;
84
+ const map = (v) => {
85
+ created++;
86
+ return span(String(v));
87
+ };
88
+ reconcile(parent, start, end, range, map, (v) => v);
89
+ expect(created).toBe(n);
90
+ // Rotate by half: all keys persist, order changes.
91
+ const rotated = range.slice(n / 2).concat(range.slice(0, n / 2));
92
+ reconcile(parent, start, end, rotated, map, (v) => v);
93
+ expect(created).toBe(n); // nothing recreated
94
+ const got = texts(parent, start, end);
95
+ expect(got.length).toBe(n);
96
+ expect(got[0]).toBe(String(n / 2));
97
+ expect(got[n - 1]).toBe(String(n / 2 - 1));
98
+ });
99
+ it('appends a large unkeyed tail in order', () => {
100
+ const parent = document.createElement('div');
101
+ const { start, end } = markers(parent);
102
+ reconcile(parent, start, end, ['a', 'b'], span);
103
+ const big = Array.from({ length: 500 }, (_, i) => 'v' + i);
104
+ reconcile(parent, start, end, ['a', 'b'].concat(big), span);
105
+ const got = texts(parent, start, end);
106
+ expect(got.length).toBe(502);
107
+ expect(got[0]).toBe('a');
108
+ expect(got[501]).toBe('v499');
109
+ });
47
110
  });
@@ -0,0 +1,8 @@
1
+ export interface NavigateOptions {
2
+ replace?: boolean;
3
+ scroll?: boolean;
4
+ state?: unknown;
5
+ }
6
+ export declare function initRouter(): void;
7
+ export declare function reinitRouter(): void;
8
+ export declare function navigate(url: string, opts?: NavigateOptions): boolean;
@@ -0,0 +1,11 @@
1
+ export function initRouter() { }
2
+ export function reinitRouter() { }
3
+ export function navigate(url, opts = {}) {
4
+ if (typeof location === 'undefined')
5
+ return true;
6
+ if (opts.replace)
7
+ location.replace(url);
8
+ else
9
+ location.assign(url);
10
+ return true;
11
+ }
package/dist/router.d.ts CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * The per-page hydration chunk(s) a prefetched document will need, as absolute
3
+ * URLs, excluding the shared runtime chunk and anything already loaded. Prefetching
4
+ * these warms the route's JS in addition to its HTML, so an SPA navigation does
5
+ * not stall waiting on the chunk after the HTML swap.
6
+ */
7
+ export declare function pageAssetURLs(html: string, baseUrl: string, loaded: Set<string>): string[];
1
8
  export interface NavigateOptions {
2
9
  replace?: boolean;
3
10
  scroll?: boolean;
package/dist/router.js CHANGED
@@ -38,6 +38,55 @@ function stripBase(pathname) {
38
38
  }
39
39
  // Set during initRouter so the exported `navigate()` can drive the SPA router.
40
40
  let navigateImpl = null;
41
+ // Resolve an asset URL against the navigated-to page (not the current one), so
42
+ // relative srcs like "index.a1b2c3.js" load from the new page's directory.
43
+ function resolveSrc(src, baseUrl) {
44
+ if (/^(https?:)?\/\//.test(src) || src.startsWith('/')) {
45
+ return new URL(src, baseUrl).href;
46
+ }
47
+ // Relative path: resolve against the base page's directory, accounting for
48
+ // both "/about" and "/about/" style targets.
49
+ let base = baseUrl;
50
+ if (!base.endsWith('/')) {
51
+ const idx = base.lastIndexOf('/');
52
+ base = idx > 0 ? base.slice(0, idx + 1) : '/';
53
+ }
54
+ return new URL(src, base).href;
55
+ }
56
+ /** Bounded set of asset URLs already emitted as `<link rel="prefetch">`. */
57
+ const prefetchedAssets = new Set();
58
+ const PREFETCHED_ASSETS_MAX = 128;
59
+ /**
60
+ * The per-page hydration chunk(s) a prefetched document will need, as absolute
61
+ * URLs, excluding the shared runtime chunk and anything already loaded. Prefetching
62
+ * these warms the route's JS in addition to its HTML, so an SPA navigation does
63
+ * not stall waiting on the chunk after the HTML swap.
64
+ */
65
+ export function pageAssetURLs(html, baseUrl, loaded) {
66
+ const doc = new DOMParser().parseFromString(html, 'text/html');
67
+ const out = [];
68
+ const seen = new Set();
69
+ const consider = (src) => {
70
+ if (!src)
71
+ return;
72
+ let abs;
73
+ try {
74
+ abs = resolveSrc(src, baseUrl);
75
+ }
76
+ catch {
77
+ return;
78
+ }
79
+ if (seen.has(abs) || loaded.has(abs) || RUNTIME_CHUNK_RE.test(abs))
80
+ return;
81
+ seen.add(abs);
82
+ out.push(abs);
83
+ };
84
+ doc.querySelectorAll('script[src]').forEach((s) => consider(s.getAttribute('src')));
85
+ doc
86
+ .querySelectorAll('link[rel="modulepreload"][href], link[rel="preload"][as="script"][href]')
87
+ .forEach((l) => consider(l.getAttribute('href')));
88
+ return out;
89
+ }
41
90
  /**
42
91
  * Programmatic SPA navigation. Falls back to a full page load when the router
43
92
  * has not initialized (e.g. before hydration). Returns false when handled
@@ -94,25 +143,50 @@ export function initRouter() {
94
143
  return false;
95
144
  return true;
96
145
  }
146
+ // Above-the-fold/viewport prefetch is deferred to idle time so it never
147
+ // competes with first paint; hover/focus keeps the 200ms intent debounce.
148
+ function idle(fn) {
149
+ const ric = window.requestIdleCallback;
150
+ if (typeof ric === 'function')
151
+ ric(fn, { timeout: 1000 });
152
+ else
153
+ setTimeout(fn, 50);
154
+ }
155
+ // Prefetch only links that opted in and did not opt out (prefetch={false}).
156
+ function shouldPrefetch(a) {
157
+ const v = a.getAttribute('data-prefetch');
158
+ return a.hasAttribute('data-prefetch') && v !== 'false' && v !== '0';
159
+ }
160
+ function prefetchAsset(url) {
161
+ if (prefetchedAssets.has(url) || prefetchedAssets.size >= PREFETCHED_ASSETS_MAX)
162
+ return;
163
+ prefetchedAssets.add(url);
164
+ const link = document.createElement('link');
165
+ link.rel = 'prefetch';
166
+ link.as = 'script';
167
+ link.href = url;
168
+ document.head.appendChild(link);
169
+ }
97
170
  function prefetchPage(url) {
98
171
  if (prefetchCache.has(url))
99
172
  return;
100
173
  fetch(url, { headers: { Accept: 'text/html' } })
101
- .then((res) => {
102
- if (res.ok)
103
- return res.text();
104
- return null;
105
- })
174
+ .then((res) => (res.ok ? res.text() : null))
106
175
  .then((html) => {
107
- if (html) {
108
- // Bounded LRU: evict the oldest entry when the cache is full.
109
- if (prefetchCache.size >= PREFETCH_CACHE_MAX) {
110
- const oldest = prefetchCache.keys().next().value;
111
- if (oldest !== undefined)
112
- prefetchCache.delete(oldest);
113
- }
114
- prefetchCache.set(url, html);
176
+ if (!html)
177
+ return;
178
+ // Bounded LRU: evict the oldest entry when the cache is full.
179
+ if (prefetchCache.size >= PREFETCH_CACHE_MAX) {
180
+ const oldest = prefetchCache.keys().next().value;
181
+ if (oldest !== undefined)
182
+ prefetchCache.delete(oldest);
115
183
  }
184
+ prefetchCache.set(url, html);
185
+ // Warm the route's hydration chunk(s) too, not just its HTML.
186
+ const loaded = new Set();
187
+ document.querySelectorAll('script[src]').forEach((s) => loaded.add(s.src));
188
+ for (const asset of pageAssetURLs(html, url, loaded))
189
+ prefetchAsset(asset);
116
190
  })
117
191
  .catch(() => { });
118
192
  }
@@ -127,9 +201,9 @@ export function initRouter() {
127
201
  if (entry.isIntersecting) {
128
202
  const a = entry.target;
129
203
  const href = a.getAttribute('href');
130
- if (href && isLocalLink(a)) {
204
+ if (href && isLocalLink(a) && shouldPrefetch(a)) {
131
205
  const url = new URL(href, location.origin).href;
132
- prefetchPage(url);
206
+ idle(() => prefetchPage(url));
133
207
  }
134
208
  prefetchObserver.unobserve(entry.target);
135
209
  }
@@ -142,7 +216,8 @@ export function initRouter() {
142
216
  if (!prefetchObserver)
143
217
  return;
144
218
  document.querySelectorAll('a[data-prefetch]').forEach((a) => {
145
- prefetchObserver.observe(a);
219
+ if (shouldPrefetch(a))
220
+ prefetchObserver.observe(a);
146
221
  });
147
222
  }
148
223
  function cleanupPrefetch() {
@@ -159,7 +234,7 @@ export function initRouter() {
159
234
  }
160
235
  function prefetchHoverHandler(e) {
161
236
  const a = e.target.closest('a[data-prefetch]');
162
- if (!a || !isLocalLink(a))
237
+ if (!a || !shouldPrefetch(a) || !isLocalLink(a))
163
238
  return;
164
239
  const href = a.getAttribute('href');
165
240
  if (!href)
@@ -522,21 +597,8 @@ export function initRouter() {
522
597
  document.body.appendChild(s);
523
598
  });
524
599
  }
525
- // Resolve a script URL against the navigated-to page (not the current one),
526
- // so relative srcs like "index.a1b2c3.js" load from the new page's directory.
527
- function resolveSrc(src, baseUrl) {
528
- if (/^(https?:)?\/\//.test(src) || src.startsWith('/')) {
529
- return new URL(src, baseUrl).href;
530
- }
531
- // Relative path: resolve against the base page's directory, accounting for
532
- // both "/about" and "/about/" style targets.
533
- let base = baseUrl;
534
- if (!base.endsWith('/')) {
535
- const idx = base.lastIndexOf('/');
536
- base = idx > 0 ? base.slice(0, idx + 1) : '/';
537
- }
538
- return new URL(src, base).href;
539
- }
600
+ // Resolve a script URL against the navigated-to page (see module-level
601
+ // resolveSrc), kept as a local alias for readability at call sites.
540
602
  function rehydrate() {
541
603
  if (typeof globalThis.__krate_hydrate === 'function') {
542
604
  globalThis.__krate_hydrate();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { pageAssetURLs } from './router';
3
+ const HTML = `<!doctype html><html><head>
4
+ <link rel="modulepreload" href="/chunks/runtime.abc123.js">
5
+ <link rel="modulepreload" href="index.1234.js">
6
+ <link rel="preload" as="script" href="/assets/extra-5678.js">
7
+ </head><body>
8
+ <script src="/chunks/runtime.abc123.js"></script>
9
+ <script src="index.1234.js"></script>
10
+ <script src="/api/track.js"></script>
11
+ </body></html>`;
12
+ describe('pageAssetURLs', () => {
13
+ it('extracts page scripts, excluding the shared runtime chunk', () => {
14
+ const urls = pageAssetURLs(HTML, 'https://example.com/about/', new Set());
15
+ expect(urls).toContain('https://example.com/about/index.1234.js');
16
+ expect(urls).toContain('https://example.com/api/track.js');
17
+ expect(urls).not.toContain('https://example.com/chunks/runtime.abc123.js');
18
+ });
19
+ it('dedupes across script and modulepreload tags', () => {
20
+ const urls = pageAssetURLs(HTML, 'https://example.com/about/', new Set());
21
+ expect(urls.filter((u) => u.endsWith('/index.1234.js')).length).toBe(1);
22
+ });
23
+ it('picks up preload/modulepreload-only assets', () => {
24
+ const urls = pageAssetURLs(HTML, 'https://example.com/about/', new Set());
25
+ expect(urls).toContain('https://example.com/assets/extra-5678.js');
26
+ });
27
+ it('skips already-loaded assets', () => {
28
+ const loaded = new Set(['https://example.com/about/index.1234.js']);
29
+ const urls = pageAssetURLs(HTML, 'https://example.com/about/', loaded);
30
+ expect(urls).not.toContain('https://example.com/about/index.1234.js');
31
+ });
32
+ it('resolves relative srcs against the target page directory', () => {
33
+ const urls = pageAssetURLs(HTML, 'https://example.com/about', new Set());
34
+ expect(urls).toContain('https://example.com/index.1234.js');
35
+ });
36
+ });
package/dist/signal.js CHANGED
@@ -46,6 +46,20 @@ export function disposeAll() {
46
46
  }
47
47
  }
48
48
  rootCleanups.length = 0;
49
+ // Unmount external Preact islands mounted by the page before the DOM swap.
50
+ const g = globalThis;
51
+ const islands = g.__krate_island_cleanups;
52
+ if (Array.isArray(islands)) {
53
+ g.__krate_island_cleanups = [];
54
+ for (const cleanup of islands) {
55
+ try {
56
+ cleanup();
57
+ }
58
+ catch {
59
+ // Island unmount errors must not prevent the SPA swap.
60
+ }
61
+ }
62
+ }
49
63
  pending.length = 0;
50
64
  flushScheduled = false;
51
65
  // Reset every context stack to its default so provider values from the page
package/dist/slot.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { Slot as KrateSlot } from './class-helpers.js';
2
+ export declare const Slot: typeof KrateSlot;
3
+ export declare const Root: typeof KrateSlot;
4
+ /** Radix's `Slottable` marker: the wrapped children are rendered in place. */
5
+ export declare function Slottable(props: {
6
+ children?: unknown;
7
+ }): unknown;
8
+ export default Slot;
package/dist/slot.js ADDED
@@ -0,0 +1,11 @@
1
+ // Krate-native replacement for `@radix-ui/react-slot` (used by shadcn's
2
+ // `asChild` pattern). The compiler aliases the Radix package here so copied
3
+ // shadcn source compiles without React or a compiled package dependency.
4
+ import { Slot as KrateSlot } from './class-helpers.js';
5
+ export const Slot = KrateSlot;
6
+ export const Root = KrateSlot;
7
+ /** Radix's `Slottable` marker: the wrapped children are rendered in place. */
8
+ export function Slottable(props) {
9
+ return props?.children;
10
+ }
11
+ export default Slot;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krate/runtime",
3
- "version": "0.4.0",
3
+ "version": "0.5.0-alpha.2",
4
4
  "description": "Client-side runtime for Krate — signals, hydration, SPA router, resources, and context.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -49,6 +49,18 @@
49
49
  "./jsx-types": {
50
50
  "types": "./dist/jsx-types.d.ts",
51
51
  "default": "./dist/jsx-types.js"
52
+ },
53
+ "./react": {
54
+ "types": "./dist/react.d.ts",
55
+ "default": "./dist/react.js"
56
+ },
57
+ "./react/jsx-runtime": {
58
+ "types": "./dist/react-jsx-runtime.d.ts",
59
+ "default": "./dist/react-jsx-runtime.js"
60
+ },
61
+ "./slot": {
62
+ "types": "./dist/slot.d.ts",
63
+ "default": "./dist/slot.js"
52
64
  }
53
65
  },
54
66
  "files": [