what-core 0.6.1 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +2 -0
  2. package/compiler.d.ts +30 -0
  3. package/devtools.d.ts +2 -0
  4. package/dist/compiler.js +1787 -0
  5. package/dist/compiler.js.map +7 -0
  6. package/dist/compiler.min.js +2 -0
  7. package/dist/compiler.min.js.map +7 -0
  8. package/dist/devtools.js +10 -0
  9. package/dist/devtools.js.map +7 -0
  10. package/dist/devtools.min.js +2 -0
  11. package/dist/devtools.min.js.map +7 -0
  12. package/dist/index.js +331 -382
  13. package/dist/index.js.map +4 -4
  14. package/dist/index.min.js +62 -62
  15. package/dist/index.min.js.map +4 -4
  16. package/dist/render.js +263 -21
  17. package/dist/render.js.map +4 -4
  18. package/dist/render.min.js +58 -1
  19. package/dist/render.min.js.map +4 -4
  20. package/dist/testing.js +3 -0
  21. package/dist/testing.js.map +2 -2
  22. package/dist/testing.min.js +1 -1
  23. package/dist/testing.min.js.map +2 -2
  24. package/index.d.ts +176 -1
  25. package/jsx-runtime.d.ts +622 -0
  26. package/package.json +20 -2
  27. package/src/agent-context.js +1 -1
  28. package/src/compiler.js +18 -0
  29. package/src/components.js +73 -27
  30. package/src/devtools.js +4 -0
  31. package/src/dom.js +7 -0
  32. package/src/guardrails.js +3 -4
  33. package/src/hooks.js +0 -11
  34. package/src/index.js +5 -9
  35. package/src/render.js +94 -24
  36. package/dist/a11y.js +0 -440
  37. package/dist/animation.js +0 -548
  38. package/dist/components.js +0 -229
  39. package/dist/data.js +0 -638
  40. package/dist/dom.js +0 -439
  41. package/dist/form.js +0 -509
  42. package/dist/h.js +0 -152
  43. package/dist/head.js +0 -51
  44. package/dist/helpers.js +0 -140
  45. package/dist/hooks.js +0 -210
  46. package/dist/reactive.js +0 -432
  47. package/dist/scheduler.js +0 -246
  48. package/dist/skeleton.js +0 -363
  49. package/dist/store.js +0 -83
  50. package/dist/what.js +0 -117
@@ -1,2 +1,59 @@
1
- var E=!(typeof process<"u"),w=null;var N=null,G=null,I=null,fe=!1,ee=0,B=[],X=!1,Be=new WeakMap,Oe=Symbol("needs_upstream");function V(e,n){let t=e,r=new Set;function o(...i){if(i.length===0)return N&&(r.add(N),N.deps.push(r)),t;E&&fe&&console.warn("[what] Signal.set() called inside a computed function. This may cause infinite loops. Use effect() instead."+(n?` (signal: ${n})`:""));let f=typeof i[0]=="function"?i[0](t):i[0];Object.is(t,f)||(t=f,E&&w&&w.onSignalUpdate(o),r.size>0&&le(r))}return o.set=i=>{E&&fe&&console.warn("[what] Signal.set() called inside a computed function. This may cause infinite loops. Use effect() instead."+(n?` (signal: ${n})`:""));let f=typeof i=="function"?i(t):i;Object.is(t,f)||(t=f,E&&w&&w.onSignalUpdate(o),r.size>0&&le(r))},o.peek=()=>t,o.subscribe=i=>T(()=>i(o())),o._signal=!0,E&&(o._subs=r,n&&(o._debugName=n)),E&&w&&w.onSignalCreate(o),o}function ae(e){let n=0,t=e.deps;for(let r=0;r<t.length;r++){let o=Be.get(t[r]);if(o){let i=o._level;i>n&&(n=i)}}e._level=n+1}function T(e,n){let t=je(e);t._level=1;let r=N;N=t;try{let i=t.fn();typeof i=="function"&&(t._cleanup=i)}finally{N=r}ae(t),n?.stable&&(t._stable=!0);let o=()=>He(t);return G&&G.disposals.push(o),o}function je(e,n){let t={fn:e,deps:[],lazy:n||!1,_onNotify:null,disposed:!1,_pending:!1,_stable:!1,_level:0,_computed:!1,_computedSubs:null,_isDirty:null,_markDirty:null};return E&&w&&w.onEffectCreate(t),t}function ve(e){if(e.disposed)return;if(e._stable){if(e._cleanup){try{e._cleanup()}catch(r){E&&console.warn("[what] Error in effect cleanup:",r)}e._cleanup=null}let t=N;N=null;try{let r=e.fn();typeof r=="function"&&(e._cleanup=r)}catch(r){w?.onError&&w.onError(r,{type:"effect",effect:e}),E&&console.warn("[what] Error in stable effect:",r)}finally{N=t}E&&w?.onEffectRun&&w.onEffectRun(e);return}if(ue(e),e._cleanup){try{e._cleanup()}catch(t){w?.onError&&w.onError(t,{type:"effect-cleanup",effect:e}),E&&console.warn("[what] Error in effect cleanup:",t)}e._cleanup=null}let n=N;N=e;try{let t=e.fn();typeof t=="function"&&(e._cleanup=t)}catch(t){throw t===Oe||w?.onError&&w.onError(t,{type:"effect",effect:e}),t}finally{N=n}E&&w?.onEffectRun&&w.onEffectRun(e)}function He(e){if(e.disposed=!0,E&&w&&w.onEffectDispose(e),ue(e),e._cleanup){try{e._cleanup()}catch(n){E&&console.warn("[what] Error in effect cleanup on dispose:",n)}e._cleanup=null}}function ue(e){let n=e.deps;for(let t=0;t<n.length;t++)n[t].delete(e);n.length=0}var te=0,R=null,U=0;function le(e){if(te===0){te=1;try{for(let n of e)if(!n.disposed){if(n._onNotify)n._onNotify();else if(ee===0&&n._stable){let t=N;N=null;try{let r=n.fn();if(typeof r=="function"){if(n._cleanup)try{n._cleanup()}catch{}n._cleanup=r}}catch(r){w?.onError&&w.onError(r,{type:"effect",effect:n}),E&&console.warn("[what] Error in stable effect:",r)}finally{N=t}}else if(!n._pending){n._pending=!0;let t=n._level,r=B.length;r>0&&B[r-1]._level>t&&(X=!0),B.push(n)}}if(U>0){let n=0;for(;n<U;){let t=R[n];R[n]=null,n++;for(let r of t)if(!r.disposed){if(r._onNotify)r._onNotify();else if(ee===0&&r._stable){let o=N;N=null;try{let i=r.fn();if(typeof i=="function"){if(r._cleanup)try{r._cleanup()}catch{}r._cleanup=i}}catch(i){w?.onError&&w.onError(i,{type:"effect",effect:r}),E&&console.warn("[what] Error in stable effect:",i)}finally{N=o}}else if(!r._pending){r._pending=!0;let o=r._level,i=B.length;i>0&&B[i-1]._level>o&&(X=!0),B.push(r)}}}U=0}}finally{te=0}ee===0&&B.length>0&&$e()}else R===null&&(R=[]),U>=R.length?R.push(e):R[U]=e,U++}var ne=!1;function $e(){ne||(ne=!0,queueMicrotask(()=>{ne=!1,We()}))}var re=!1;function We(){if(!re){re=!0;try{let e=0;for(;B.length>0&&e<25;){let n=B;B=[],n.length>1&&X&&n.sort((t,r)=>t._level-r._level),X=!1;for(let t=0;t<n.length;t++){let r=n[t];if(r._pending=!1,!r.disposed&&!r._onNotify){let o=r.deps.length;ve(r),!r._computed&&r.deps.length!==o&&ae(r)}}e++}if(e>=25){for(let n=0;n<B.length;n++)B[n]._pending=!1;if(B.length=0,E){let t=B.slice(0,3).map(r=>r.fn?.name||r.fn?.toString().slice(0,60)||"(anonymous)");console.warn(`[what] Possible infinite effect loop detected (25 iterations). Likely cause: an effect writes to a signal it also reads, creating a cycle. Use untrack() to read signals without subscribing. Looping effects: ${t.join(", ")}`)}else console.warn("[what] Possible infinite effect loop detected")}}finally{re=!1}}}function oe(e){let n=N;N=null;try{return e()}finally{N=n}}function q(e){let n=G,t=I,r={disposals:[],owner:I,children:[],_disposed:!1};I&&I.children.push(r),G=r,I=r;try{return e(()=>{if(!r._disposed){r._disposed=!0;for(let i=r.children.length-1;i>=0;i--)pe(r.children[i]);r.children.length=0;for(let i=r.disposals.length-1;i>=0;i--)r.disposals[i]();if(r.disposals.length=0,r.owner){let i=r.owner.children.indexOf(r);i>=0&&r.owner.children.splice(i,1)}}})}finally{G=n,I=t}}function pe(e){if(!e._disposed){e._disposed=!0;for(let n=e.children.length-1;n>=0;n--)pe(e.children[n]);e.children.length=0;for(let n=e.disposals.length-1;n>=0;n--)e.disposals[n]();e.disposals.length=0}}var de=null;function he(e){de=e}function me(e,n){let t=n||de?.();for(;t;){if(t._errorBoundary)return t._errorBoundary(e),!0;t=t._parentCtx}return!1}var Re=null;function ge(e){Re=e}var qe=new Set(["svg","path","circle","rect","line","polyline","polygon","ellipse","g","defs","use","symbol","clipPath","mask","pattern","image","text","tspan","textPath","foreignObject","linearGradient","radialGradient","stop","marker","animate","animateTransform","animateMotion","set","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence"]),Ie="http://www.w3.org/2000/svg",Ce=new Set,Z=new WeakMap;function Ue(e){return!e||typeof e!="object"?!1:typeof Node<"u"&&e instanceof Node?!0:typeof e.nodeType=="number"&&typeof e.nodeName=="string"}function ye(e){return!!e&&typeof e=="object"&&(e._vnode===!0||"tag"in e)}function _e(e){if(!e.disposed){if(e.disposed=!0,e.cleanups)for(let n of e.cleanups)try{n()}catch(t){console.error("[what] cleanup error:",t)}if(e.effects)for(let n of e.effects)try{n()}catch{}if(e.hooks){for(let n of e.hooks)if(n&&typeof n.cleanup=="function")try{n.cleanup()}catch(t){console.error("[what] hook cleanup error:",t)}}if(e._cleanupCallbacks)for(let n of e._cleanupCallbacks)try{n()}catch(t){console.error("[what] onCleanup error:",t)}E&&w?.onComponentUnmount&&w.onComponentUnmount(e),Ce.delete(e)}}function v(e){if(!e)return;e._componentCtx&&_e(e._componentCtx);let n=Z.get(e);if(n&&_e(n),e._dispose)try{e._dispose()}catch{}if(e._propEffects)for(let t in e._propEffects)try{e._propEffects[t]()}catch{}if(e.childNodes)for(let t of e.childNodes)v(t)}function j(e,n,t){if(e==null||e===!1||e===!0)return document.createComment("");if(typeof e=="string"||typeof e=="number")return document.createTextNode(String(e));if(Ue(e))return e;if(typeof e=="function"){let r=document.createComment("fn"),o=document.createComment("/fn"),i=[],f=document.createDocumentFragment();f.appendChild(r),f.appendChild(o);let s=T(()=>{let a=e(),c=a==null||a===!1||a===!0?[]:Array.isArray(a)?a:[a],p=o.parentNode;if(p){for(let u of i)v(u),u.parentNode===p&&p.removeChild(u);i=[];for(let u of c){let _=j(u,p,n?._isSvg);if(_)if(_.nodeType===11){let y=Array.from(_.childNodes);p.insertBefore(_,o);for(let g of y)i.push(g)}else p.insertBefore(_,o),i.push(_)}}});return r._dispose=s,o._dispose=s,f}if(Array.isArray(e)){let r=document.createDocumentFragment();for(let o of e){let i=j(o,n,t);i&&r.appendChild(i)}return r}return ye(e)&&typeof e.tag=="function"?Ve(e,n,t):ye(e)?Ke(e,n,t):document.createTextNode(String(e))}var M=[];function we(){return M[M.length-1]}he(we);ge(we);function be(){return M}function Ve(e,n,t){let{tag:r,props:o,children:i}=e;if(typeof r=="function"&&(r.prototype?.isReactComponent||r.prototype?.render)){let h=r;r=function(d){return new h(d).render()},r.displayName=h.displayName||h.name||"ClassComponent"}if(r==="__errorBoundary"||e.tag==="__errorBoundary")return Pe(e,n);if(r==="__suspense"||e.tag==="__suspense")return ze(e,n);if(r==="__portal"||e.tag==="__portal")return Ge(e,n);let f={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,Component:r,_parentCtx:M[M.length-1]||null,_errorBoundary:(()=>{let h=M[M.length-1];for(;h;){if(h._errorBoundary)return h._errorBoundary;h=h._parentCtx}return null})()},s=document.createComment("c:start"),a=document.createComment("c:end");Z.set(s,f),f._startComment=s,f._endComment=a;let c=document.createDocumentFragment();c._componentCtx=f,f._wrapper=s,Ce.add(f),E&&w?.onComponentMount&&w.onComponentMount(f);let p=i.length===0?void 0:i.length===1?i[0]:i,u=V({...o,children:p});f._propsSignal=u;let _=new Proxy({},{get(h,b){return u()[b]},has(h,b){let d=u();return b in d},ownKeys(){let h=u();return Reflect.ownKeys(h)},getOwnPropertyDescriptor(h,b){let d=u();if(b in d)return{value:d[b],writable:!1,enumerable:!0,configurable:!0}}});M.push(f);let y;try{y=r(_)}catch(h){if(M.pop(),!me(h,f))throw console.error("[what] Uncaught error in component:",r.name||"Anonymous",h),h;return c.appendChild(s),c.appendChild(a),c}M.pop(),f.mounted=!0,f._mountCallbacks&&queueMicrotask(()=>{if(!f.disposed)for(let h of f._mountCallbacks)try{h()}catch(b){console.error("[what] onMount error:",b)}}),c.appendChild(s);let g=Array.isArray(y)?y:[y];for(let h of g){let b=j(h,c,t);b&&c.appendChild(b)}return c.appendChild(a),c}function Pe(e,n){let{errorState:t,handleError:r,fallback:o,reset:i}=e.props,f=e.children,s=document.createComment("eb:start"),a=document.createComment("eb:end"),c={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,_parentCtx:M[M.length-1]||null,_errorBoundary:r,_startComment:s,_endComment:a};Z.set(s,c);let p=document.createDocumentFragment();p._componentCtx=c,p.appendChild(s),p.appendChild(a);let u=T(()=>{let _=t();if(M.push(c),s.parentNode)for(;s.nextSibling&&s.nextSibling!==a;){let g=s.nextSibling;v(g),g.parentNode.removeChild(g)}let y;_?y=typeof o=="function"?[o({error:_,reset:i})]:[o]:y=f,y=Array.isArray(y)?y:[y];for(let g of y){let h=j(g,n);h&&(a.parentNode?a.parentNode.insertBefore(h,a):p.insertBefore(h,a))}M.pop()});return c.effects.push(u),p}function ze(e,n){let{boundary:t,fallback:r,loading:o}=e.props,i=e.children,f=document.createComment("sb:start"),s=document.createComment("sb:end"),a={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,_parentCtx:M[M.length-1]||null,_startComment:f,_endComment:s};Z.set(f,a);let c=document.createDocumentFragment();c._componentCtx=a,c.appendChild(f),c.appendChild(s);let p=T(()=>{let _=o()?[r]:i,y=Array.isArray(_)?_:[_];if(M.push(a),f.parentNode)for(;f.nextSibling&&f.nextSibling!==s;){let g=f.nextSibling;v(g),g.parentNode.removeChild(g)}for(let g of y){let h=j(g,n);h&&(s.parentNode?s.parentNode.insertBefore(h,s):c.insertBefore(h,s))}M.pop()});return a.effects.push(p),c}function Ge(e,n){let{container:t}=e.props,r=e.children;if(!t)return console.warn("[what] Portal: target container not found"),document.createComment("portal:empty");let o={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,_parentCtx:M[M.length-1]||null},i=document.createComment("portal");i._componentCtx=o;let f=[];for(let s of r){let a=j(s,t);a&&(t.appendChild(a),f.push(a))}return o._cleanupCallbacks=[()=>{for(let s of f)v(s),s.parentNode&&s.parentNode.removeChild(s)}],i}function Ke(e,n,t){let{tag:r,props:o,children:i}=e,f=t||qe.has(r),s=f?document.createElementNS(Ie,r):document.createElement(r);o&&Je(s,o,{},f);for(let a of i){let c=j(a,s,f&&r!=="foreignObject");c&&s.appendChild(c)}return s._vnode=e,s}function Je(e,n,t,r){n=n||{},t=t||{};for(let o in n)if(!(o==="key"||o==="children")){if(o==="ref"){typeof n.ref=="function"?n.ref(e):n.ref&&(n.ref.current=e);continue}xe(e,o,n[o],r)}}function xe(e,n,t,r){if(typeof t=="function"&&!(n.startsWith("on")&&n.length>2)&&n!=="ref"){if(e._propEffects||(e._propEffects={}),e._propEffects[n])try{e._propEffects[n]()}catch{}e._propEffects[n]=T(()=>{let o=t();xe(e,n,o,r)});return}if(n.startsWith("on")&&n.length>2){let o=n.slice(2),i=!1;o.endsWith("Capture")&&(o=o.slice(0,-7),i=!0);let f=o.toLowerCase(),s=i?f+"_capture":f,a=e._events?.[s];if(a&&a._original===t||(a&&e.removeEventListener(f,a,i),t==null))return;e._events||(e._events={});let c=u=>(u.nativeEvent||(u.nativeEvent=u),oe(()=>t(u)));c._original=t,e._events[s]=c;let p=t._eventOpts;e.addEventListener(f,c,p||i||void 0);return}if(n==="className"||n==="class"){r?e.setAttribute("class",t||""):e.className=t||"";return}if(n==="style"){if(typeof t=="string")e.style.cssText=t,e._prevStyle=null;else if(typeof t=="object"){let o=e._prevStyle||{};for(let i in o)i in t||(e.style[i]="");for(let i in t)e.style[i]=t[i]??"";e._prevStyle={...t}}return}if(n==="dangerouslySetInnerHTML"){e.innerHTML=t?.__html??"";return}if(n==="innerHTML"){if(t==null)return;if(t&&typeof t=="object"&&"__html"in t)e.innerHTML=t.__html??"";else{E&&console.warn("[what] innerHTML received a raw string. This is a security risk (XSS). Use innerHTML={{ __html: trustedString }} or dangerouslySetInnerHTML={{ __html: trustedString }} instead.");return}return}if(typeof t=="boolean"){t?e.setAttribute(n,""):e.removeAttribute(n);return}if(n.startsWith("data-")||n.startsWith("aria-")){e.setAttribute(n,t);return}if(r){t===!1||t==null?e.removeAttribute(n):e.setAttribute(n,t===!0?"":String(t));return}n in e?e[n]=t:e.setAttribute(n,t)}function wt(e,n,t){if(t&&t.length>0){let r=t.length===1?t[0]:t;n=n?{...n,children:r}:{children:r}}return j({tag:e,props:n||{},children:t||[],key:null,_vnode:!0})}var Ee=new Set(["href","src","action","formaction","formAction"]);function Xe(e){if(typeof e!="string")return!0;let n=e.trim().replace(/[\s\x00-\x1f]/g,"").toLowerCase();return!(n.startsWith("javascript:")||n.startsWith("data:")||n.startsWith("vbscript:"))}var Ze={tr:{depth:2,wrap:"<table><tbody>",unwrap:"</tbody></table>"},td:{depth:3,wrap:"<table><tbody><tr>",unwrap:"</tr></tbody></table>"},th:{depth:3,wrap:"<table><tbody><tr>",unwrap:"</tr></tbody></table>"},thead:{depth:1,wrap:"<table>",unwrap:"</table>"},tbody:{depth:1,wrap:"<table>",unwrap:"</table>"},tfoot:{depth:1,wrap:"<table>",unwrap:"</table>"},colgroup:{depth:1,wrap:"<table>",unwrap:"</table>"},col:{depth:1,wrap:"<table>",unwrap:"</table>"},caption:{depth:1,wrap:"<table>",unwrap:"</table>"}},Qe=new Set(["svg","path","circle","rect","line","polyline","polygon","ellipse","g","defs","use","text","tspan","foreignObject","clipPath","mask","pattern","linearGradient","radialGradient","stop","marker","symbol","image","animate","animateTransform","animateMotion","set","filter","feGaussianBlur","feOffset","feMerge","feMergeNode","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feImage","feMorphology","feSpecularLighting","feTile","feTurbulence","feDistantLight","fePointLight","feSpotLight"]);function Me(e){let n=e.match(/^<([a-zA-Z][a-zA-Z0-9]*)/);return n?n[1]:""}function Ye(e){let n=e.trim(),t=Me(n);if(Qe.has(t))return Fe(n);let r=Ze[t];if(r){let i=document.createElement("template");return i.innerHTML=r.wrap+n+r.unwrap,()=>{let f=i.content.firstChild;for(let s=0;s<r.depth;s++)f=f.firstChild;return f.cloneNode(!0)}}let o=document.createElement("template");return o.innerHTML=n,()=>o.content.firstChild.cloneNode(!0)}var Se=!1;function bt(e){return E&&!Se&&(Se=!0,console.warn("[what] template() is a compiler internal. Use JSX instead. Direct calls with user input can lead to XSS vulnerabilities.")),Ye(e)}function Fe(e){let n=e.trim();if(Me(n)==="svg"){let o=document.createElement("template");return o.innerHTML=n,()=>o.content.firstChild.cloneNode(!0)}let r=document.createElement("template");return r.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg">${n}</svg>`,()=>r.content.firstChild.firstChild.cloneNode(!0)}function xt(e,n,t){if(typeof n=="function"){let r=null;return T(()=>{r=Q(e,n(),r,t||null)}),r}return Q(e,n,null,t||null)}function Te(e){return!e||typeof e!="object"?!1:typeof Node<"u"&&e instanceof Node?!0:typeof e.nodeType=="number"&&typeof e.nodeName=="string"}function et(e){return!!e&&typeof e=="object"&&(e._vnode===!0||"tag"in e)}function tt(e){return typeof SVGElement<"u"&&e instanceof SVGElement&&e.tagName.toLowerCase()!=="foreignobject"}function Le(e){return e==null?[]:Array.isArray(e)?e:[e]}function ke(e,n,t){if(e==null||typeof e=="boolean")return t;if(Array.isArray(e)){for(let r=0;r<e.length;r++)ke(e[r],n,t);return t}return typeof e=="string"||typeof e=="number"?(t.push(document.createTextNode(String(e))),t):Te(e)?(t.push(e),t):et(e)?(t.push(j(e,n,tt(n))),t):(t.push(document.createTextNode(String(e))),t)}function nt(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function Q(e,n,t,r){if(!e||typeof e.insertBefore!="function")return E&&console.warn("[what] reconcileInsert called with invalid parent:",e),t;let o=r||null;if(n==null||typeof n=="boolean"){let c=Le(t);for(let p=0;p<c.length;p++){let u=c[p];u.parentNode===e&&(v(u),e.removeChild(u))}return null}if((typeof n=="string"||typeof n=="number")&&t&&!Array.isArray(t)&&t.nodeType===3){let c=String(n);return t.textContent!==c&&(t.textContent=c),t}let i=ke(n,e,[]),f=Le(t);if(nt(f,i))return t;let s=new Set(i);for(let c=0;c<f.length;c++){let p=f[c];!s.has(p)&&p.parentNode===e&&(v(p),e.removeChild(p))}let a=o;for(let c=i.length-1;c>=0;c--){let p=i[c];(p.parentNode!==e||p.nextSibling!==a)&&(a&&a.parentNode!==e&&(a=null),a?e.insertBefore(p,a):e.appendChild(p)),a=p}return i.length===0?null:i.length===1?i[0]:i}function Et(e,n,t){let r=t?.key,o=t?.raw||!1;return(i,f)=>{let s=[],a=[],c=[],p=r&&!o?new Map:null,u=document.createComment("/list");return i.insertBefore(u,f||null),T(()=>{let _=e()||[];r?st(i,u,s,_,a,c,n,r,p):rt(i,u,s,_,a,c,n),s=_.slice()}),u}}function rt(e,n,t,r,o,i,f){let s=r.length,a=t.length;if(s===0){if(a>0){for(let d=0;d<a;d++)i[d]?.(),o[d]?.parentNode===e&&(v(o[d]),e.removeChild(o[d]));o.length=0,i.length=0}return}if(a===0){let d=document.createDocumentFragment();for(let m=0;m<s;m++){let x=r[m],L=q(k=>(i[m]=k,f(x,m)));o[m]=L,d.appendChild(L)}e.insertBefore(d,n);return}let c=0,p=Math.min(a,s);for(;c<p&&t[c]===r[c];)c++;if(c===a&&c===s)return;let u=a-1,_=s-1;for(;u>=c&&_>=c&&t[u]===r[_];)u--,_--;let y=new Array(s),g=new Array(s);for(let d=0;d<c;d++)y[d]=o[d],g[d]=i[d];for(let d=_+1;d<s;d++){let m=u+1+(d-_-1);y[d]=o[m],g[d]=i[m]}let h=_-c+1,b=u-c+1;if(h===0)for(let d=c;d<=u;d++)i[d]?.(),o[d]?.parentNode&&o[d].parentNode.removeChild(o[d]);else if(b===0){let d=c<s&&y[_+1]?y[_+1]:n,m=document.createDocumentFragment();for(let x=c;x<=_;x++){let L=r[x],k=x;y[x]=q(D=>(g[k]=D,f(L,k))),m.appendChild(y[x])}e.insertBefore(m,d)}else ot(e,n,t,r,o,i,f,c,u,_,y,g);o.length=s,i.length=s;for(let d=0;d<s;d++)o[d]=y[d],i[d]=g[d]}function ot(e,n,t,r,o,i,f,s,a,c,p,u){let _=new Map;for(let m=s;m<=a;m++)_.set(t[m],m);let y=c-s+1,g=new Int32Array(y);g.fill(-1);for(let m=s;m<=c;m++){let x=_.get(r[m]);x!==void 0&&(_.delete(r[m]),p[m]=o[x],u[m]=i[x],g[m-s]=x)}for(let[,m]of _)i[m]?.(),o[m]?.parentNode&&o[m].parentNode.removeChild(o[m]);let h=y-it(g,y),b=new Uint8Array(y);if(h>1){let m=new Int32Array(h),x=new Int32Array(h),L=0;for(let D=0;D<y;D++)g[D]!==-1&&(m[L]=g[D],x[L]=D,L++);let k=De(m,h);for(let D=0;D<k.length;D++)b[x[k[D]]]=1}else if(h===1){for(let m=0;m<y;m++)if(g[m]!==-1){b[m]=1;break}}for(let m=s;m<=c;m++)if(!p[m]){let x=r[m],L=m;p[m]=q(k=>(u[L]=k,f(x,L)))}let d=c+1<p.length&&p[c+1]?p[c+1]:n;for(let m=c;m>=s;m--){let x=m-s;(g[x]===-1||!b[x])&&(d&&d.parentNode!==e&&(d=n),e.insertBefore(p[m],d)),d=p[m]}}function it(e,n){let t=0;for(let r=0;r<n;r++)e[r]===-1&&t++;return t}function De(e,n){if(n===0)return[];if(n===1)return[0];let t=new Int32Array(n),r=new Int32Array(n),o=1;t[0]=0,r[0]=-1;for(let s=1;s<n;s++)if(e[s]>e[t[o-1]])r[s]=t[o-1],t[o++]=s;else{let a=0,c=o-1;for(;a<c;){let p=a+c>>1;e[t[p]]<e[s]?a=p+1:c=p}t[a]=s,r[s]=a>0?t[a-1]:-1}let i=new Array(o),f=t[o-1];for(let s=o-1;s>=0;s--)i[s]=f,f=r[f];return i}function st(e,n,t,r,o,i,f,s,a){let c=r.length,p=t.length;if(c===0){if(p>0){for(let l=0;l<p;l++)i[l]?.(),o[l]?.parentNode===e&&(v(o[l]),e.removeChild(o[l]));o.length=0,i.length=0,a&&a.clear()}return}if(p===0){let l=document.createDocumentFragment();for(let C=0;C<c;C++){let S=r[C],O=C,A;if(a){let W=s(S),z=V(S);A=z,a.set(W,{itemSig:z})}else A=S;let H=q(W=>(i[O]=W,f(A,O)));o[C]=H,l.appendChild(H)}e.insertBefore(l,n);return}let u=0,_=Math.min(p,c);for(;u<_;){if(t[u]===r[u]){u++;continue}let l=s(t[u]),C=s(r[u]);if(l!==C)break;a&&a.get(l).itemSig.set(r[u]),u++}let y=p-1,g=c-1;for(;y>=u&&g>=u;){if(t[y]===r[g]){y--,g--;continue}let l=s(t[y]),C=s(r[g]);if(l!==C)break;a&&a.get(l).itemSig.set(r[g]),y--,g--}if(u>y&&u>g)return;let h=new Array(c),b=new Array(c);for(let l=0;l<u;l++)h[l]=o[l],b[l]=i[l];for(let l=g+1;l<c;l++){let C=y+1+(l-g-1);h[l]=o[C],b[l]=i[C]}let d=g-u+1;if(y-u+1===0){let l=g+1<c&&h[g+1]?h[g+1]:n,C=document.createDocumentFragment();for(let S=u;S<=g;S++){let O=r[S],A=S,H;if(a){let W=s(O),z=V(O);H=z,a.set(W,{itemSig:z})}else H=O;h[S]=q(W=>(b[A]=W,f(H,A))),C.appendChild(h[S])}e.insertBefore(C,l),ie(o,i,h,b,c);return}if(d===0){for(let l=u;l<=y;l++)i[l]?.(),o[l]?.parentNode&&e.removeChild(o[l]),a&&a.delete(s(t[l]));ie(o,i,h,b,c);return}let x=new Map;for(let l=u;l<=y;l++)x.set(s(t[l]),l);let L=new Int32Array(d);L.fill(-1);for(let l=u;l<=g;l++){let C=s(r[l]),S=x.get(C);S!==void 0&&(x.delete(C),h[l]=o[S],b[l]=i[S],L[l-u]=S,a&&r[l]!==t[S]&&a.get(C).itemSig.set(r[l]))}for(let[l,C]of x)i[C]?.(),o[C]?.parentNode&&e.removeChild(o[C]),a&&a.delete(l);for(let l=u;l<=g;l++)if(!h[l]){let C=r[l],S=l,O;if(a){let A=s(C),H=V(C);O=H,a.set(A,{itemSig:H})}else O=C;h[l]=q(A=>(b[S]=A,f(O,S)))}let k=0,D=!0,ce=-1;for(let l=0;l<d;l++)L[l]!==-1&&(k++,L[l]<=ce&&(D=!1),ce=L[l]);let J=new Uint8Array(d);if(D)for(let l=0;l<d;l++)L[l]!==-1&&(J[l]=1);else if(k>1){let l=new Int32Array(k),C=new Int32Array(k),S=0;for(let A=0;A<d;A++)L[A]!==-1&&(l[S]=L[A],C[S]=A,S++);let O=De(l,k);for(let A=0;A<O.length;A++)J[C[O[A]]]=1}else if(k===1){for(let l=0;l<d;l++)if(L[l]!==-1){J[l]=1;break}}let P=g+1<h.length&&h[g+1]?h[g+1]:n;for(let l=g;l>=u;l--){let C=l-u;(L[C]===-1||!J[C])&&(P&&P.parentNode!==e&&(P=n),e.insertBefore(h[l],P)),P=h[l]}ie(o,i,h,b,c)}function ie(e,n,t,r,o){e.length=o,n.length=o;for(let i=0;i<o;i++)e[i]=t[i],n[i]=r[i]}function St(e,n){for(let t in n){let r=n[t];if(t.startsWith("on")&&t.length>2){let o=t.slice(2).toLowerCase();e.addEventListener(o,r);continue}typeof r=="function"&&!t.startsWith("on")?t==="class"||t==="className"?T(()=>{e.className=r()||""}):t==="style"&&typeof r()=="object"?T(()=>{let o=r();for(let i in o)e.style[i]=o[i]??""}):T(()=>{Y(e,t,r())}):Y(e,t,r)}}function Y(e,n,t){if(n==="ref"){typeof t=="function"?t(e):t&&typeof t=="object"&&(t.current=e);return}if((Ee.has(n)||Ee.has(n.toLowerCase()))&&!Xe(t)){typeof console<"u"&&console.warn(`[what] Blocked unsafe URL in "${n}" attribute: ${t}`);return}if(n==="class"||n==="className")e.className=t||"";else if(n==="dangerouslySetInnerHTML")e.innerHTML=t?.__html??"";else if(n==="innerHTML")t&&typeof t=="object"&&"__html"in t?e.innerHTML=t.__html??"":typeof console<"u"&&t!=null&&t!==""&&console.warn('[what] Plain string innerHTML is not allowed. Use { __html: "..." } or dangerouslySetInnerHTML={{ __html: "..." }} instead.');else if(n==="style"){if(typeof t=="string")e.style.cssText=t;else if(typeof t=="object")for(let r in t)e.style[r]=t[r]??""}else n.startsWith("data-")||n.startsWith("aria-")?e.setAttribute(n,t):typeof t=="boolean"?t?e.setAttribute(n,""):e.removeAttribute(n):n in e?e[n]=t:e.setAttribute(n,t)}var Ne=new Set;function Lt(e){for(let n of e)Ne.has(n)||(Ne.add(n),document.addEventListener(n,t=>{let r=t.target,o="$$"+n;for(;r;){let i=r[o];if(i&&(i(t),t.cancelBubble))return;r=r.parentNode}}))}function Nt(e,n,t){return e.addEventListener(n,t),()=>e.removeEventListener(n,t)}function At(e,n){T(()=>{for(let t in n){let r=typeof n[t]=="function"?n[t]():n[t];e.classList.toggle(t,!!r)}})}var F=!1,$=null;function Mt(){return F}function Tt(e,n){F=!0,$={parent:n,index:0};try{return K(e,n)}finally{F=!1,$=null}}function Ae(e){let n=e.childNodes;for(;$.index<n.length;){let t=n[$.index];if(t.nodeType===8){let r=t.textContent;if(r==="$"||r==="/$"||r==="[]"||r==="/[]"){$.index++;continue}}return $.index++,t}return null}function se(){return typeof process<"u"&&!1}function K(e,n){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number"){let r=Ae(n),o=String(e);if(r&&r.nodeType===3)return se()&&r.textContent!==o&&(console.warn(`[what] Hydration mismatch: expected text "${o}", got "${r.textContent}"`),r.textContent=o),r;se()&&console.warn(`[what] Hydration mismatch: expected text node "${o}", got ${r?r.nodeName:"nothing"}. Falling back to client render.`);let i=document.createTextNode(o);return r?n.replaceChild(i,r):n.appendChild(i),i}if(typeof e=="function"){let r=e(),o=K(r,n);return T(()=>{let i=e();F||(o=Q(n,i,o,null))}),o}if(Array.isArray(e)){let r=[];for(let o of e){let i=K(o,n);i&&r.push(i)}return r.length===1?r[0]:r}if(typeof e=="object"&&e._vnode){if(typeof e.tag=="function"){let f=be(),s=e.tag,a=e.props||{},c=e.children||[],p={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,Component:s,_parentCtx:f[f.length-1]||null,_errorBoundary:null};f.push(p);let u;try{let _=c.length===0?void 0:c.length===1?c[0]:c;u=s({...a,children:_})}catch(_){return f.pop(),console.error("[what] Error in component during hydration:",s.name||"Anonymous",_),null}return f.pop(),p.mounted=!0,p._mountCallbacks&&queueMicrotask(()=>{if(!p.disposed)for(let _ of p._mountCallbacks)try{_()}catch(y){console.error("[what] onMount error:",y)}}),K(u,n)}let r=Ae(n),o=e.tag.toUpperCase();if(r&&r.nodeType===1&&r.nodeName===o){ct(r,e.props||{});let f=$;if($={parent:r,index:0},e.props?.dangerouslySetInnerHTML?.__html==null)for(let a of e.children)K(a,r);return $=f,r}se()&&console.warn(`[what] Hydration mismatch: expected <${e.tag}>, got ${r?r.nodeName:"nothing"}. Falling back to client render.`);let i=document.createElement(e.tag);for(let f in e.props||{})f==="children"||f==="key"||Y(i,f,e.props[f]);for(let f of e.children)Q(i,f,null,null);return r?n.replaceChild(i,r):n.appendChild(i),i}if(Te(e))return e;let t=document.createTextNode(String(e));return n.appendChild(t),t}function ct(e,n){for(let t in n){if(t==="children"||t==="key"||t==="ref"||t==="dangerouslySetInnerHTML"||t==="innerHTML")continue;let r=n[t];if(t.startsWith("on")&&t.length>2){let o=t.slice(2).toLowerCase();e.addEventListener(o,r);continue}if(t.startsWith("$$")){e[t]=r;continue}if(typeof r=="function"&&!t.startsWith("on")){t==="class"||t==="className"?T(()=>{e.className=r()||""}):t==="style"&&typeof r()=="object"?T(()=>{let o=r();for(let i in o)e.style[i]=o[i]??""}):T(()=>{Y(e,t,r())});continue}}}export{wt as _$createComponent,Ye as _$template,bt as _template,At as classList,Lt as delegateEvents,T as effect,Tt as hydrate,xt as insert,Mt as isHydrating,Et as mapArray,Nt as on,Y as setProp,St as spread,Fe as svgTemplate,bt as template,oe as untrack};
1
+ var b=!(typeof process<"u"),w=null;var L=null,K=null,U=null,de=!1,oe=0,I=[],Y=!1,je=new WeakMap,We=Symbol("needs_upstream");function P(e,n){let t=e,r=new Set;function o(...i){if(i.length===0)return L&&(r.add(L),L.deps.push(r)),t;b&&de&&console.warn("[what] Signal.set() called inside a computed function. This may cause infinite loops. Use effect() instead."+(n?` (signal: ${n})`:""));let l=typeof i[0]=="function"?i[0](t):i[0];Object.is(t,l)||(t=l,b&&w&&w.onSignalUpdate(o),r.size>0&&pe(r))}return o.set=i=>{b&&de&&console.warn("[what] Signal.set() called inside a computed function. This may cause infinite loops. Use effect() instead."+(n?` (signal: ${n})`:""));let l=typeof i=="function"?i(t):i;Object.is(t,l)||(t=l,b&&w&&w.onSignalUpdate(o),r.size>0&&pe(r))},o.peek=()=>t,o.subscribe=i=>A(()=>i(o())),o._signal=!0,b&&(o._subs=r,n&&(o._debugName=n)),b&&w&&w.onSignalCreate(o),o}function he(e){let n=0,t=e.deps;for(let r=0;r<t.length;r++){let o=je.get(t[r]);if(o){let i=o._level;i>n&&(n=i)}}e._level=n+1}function A(e,n){let t=Ge(e);t._level=1;let r=L;L=t;try{let i=t.fn();typeof i=="function"&&(t._cleanup=i)}finally{L=r}he(t),n?.stable&&(t._stable=!0);let o=()=>qe(t);return K&&K.disposals.push(o),o}function Ge(e,n){let t={fn:e,deps:[],lazy:n||!1,_onNotify:null,disposed:!1,_pending:!1,_stable:!1,_level:0,_computed:!1,_computedSubs:null,_isDirty:null,_markDirty:null};return b&&w&&w.onEffectCreate(t),t}function Ue(e){if(e.disposed)return;if(e._stable){if(e._cleanup){try{e._cleanup()}catch(r){b&&console.warn("[what] Error in effect cleanup:",r)}e._cleanup=null}let t=L;L=null;try{let r=e.fn();typeof r=="function"&&(e._cleanup=r)}catch(r){w?.onError&&w.onError(r,{type:"effect",effect:e}),b&&console.warn("[what] Error in stable effect:",r)}finally{L=t}b&&w?.onEffectRun&&w.onEffectRun(e);return}if(me(e),e._cleanup){try{e._cleanup()}catch(t){w?.onError&&w.onError(t,{type:"effect-cleanup",effect:e}),b&&console.warn("[what] Error in effect cleanup:",t)}e._cleanup=null}let n=L;L=e;try{let t=e.fn();typeof t=="function"&&(e._cleanup=t)}catch(t){throw t===We||w?.onError&&w.onError(t,{type:"effect",effect:e}),t}finally{L=n}b&&w?.onEffectRun&&w.onEffectRun(e)}function qe(e){if(e.disposed=!0,b&&w&&w.onEffectDispose(e),me(e),e._cleanup){try{e._cleanup()}catch(n){b&&console.warn("[what] Error in effect cleanup on dispose:",n)}e._cleanup=null}}function me(e){let n=e.deps;for(let t=0;t<n.length;t++)n[t].delete(e);n.length=0}var ie=0,j=null,q=0;function pe(e){if(ie===0){ie=1;try{for(let n of e)if(!n.disposed){if(n._onNotify)n._onNotify();else if(oe===0&&n._stable){let t=L;L=null;try{let r=n.fn();if(typeof r=="function"){if(n._cleanup)try{n._cleanup()}catch{}n._cleanup=r}}catch(r){w?.onError&&w.onError(r,{type:"effect",effect:n}),b&&console.warn("[what] Error in stable effect:",r)}finally{L=t}}else if(!n._pending){n._pending=!0;let t=n._level,r=I.length;r>0&&I[r-1]._level>t&&(Y=!0),I.push(n)}}if(q>0){let n=0;for(;n<q;){let t=j[n];j[n]=null,n++;for(let r of t)if(!r.disposed){if(r._onNotify)r._onNotify();else if(oe===0&&r._stable){let o=L;L=null;try{let i=r.fn();if(typeof i=="function"){if(r._cleanup)try{r._cleanup()}catch{}r._cleanup=i}}catch(i){w?.onError&&w.onError(i,{type:"effect",effect:r}),b&&console.warn("[what] Error in stable effect:",i)}finally{L=o}}else if(!r._pending){r._pending=!0;let o=r._level,i=I.length;i>0&&I[i-1]._level>o&&(Y=!0),I.push(r)}}}q=0}}finally{ie=0}oe===0&&I.length>0&&Pe()}else j===null&&(j=[]),q>=j.length?j.push(e):j[q]=e,q++}var se=!1;function Pe(){se||(se=!0,queueMicrotask(()=>{se=!1,Ve()}))}var ce=!1;function Ve(){if(!ce){ce=!0;try{let e=0;for(;I.length>0&&e<25;){let n=I;I=[],n.length>1&&Y&&n.sort((t,r)=>t._level-r._level),Y=!1;for(let t=0;t<n.length;t++){let r=n[t];if(r._pending=!1,!r.disposed&&!r._onNotify){let o=r.deps.length;Ue(r),!r._computed&&r.deps.length!==o&&he(r)}}e++}if(e>=25){for(let n=0;n<I.length;n++)I[n]._pending=!1;if(I.length=0,b){let t=I.slice(0,3).map(r=>r.fn?.name||r.fn?.toString().slice(0,60)||"(anonymous)");console.warn(`[what] Possible infinite effect loop detected (25 iterations). Likely cause: an effect writes to a signal it also reads, creating a cycle. Use untrack() to read signals without subscribing. Looping effects: ${t.join(", ")}`)}else console.warn("[what] Possible infinite effect loop detected")}}finally{ce=!1}}}function le(e){let n=L;L=null;try{return e()}finally{L=n}}function W(e){let n=K,t=U,r={disposals:[],owner:U,children:[],_disposed:!1};U&&U.children.push(r),K=r,U=r;try{return e(()=>{if(!r._disposed){r._disposed=!0;for(let i=r.children.length-1;i>=0;i--)ge(r.children[i]);r.children.length=0;for(let i=r.disposals.length-1;i>=0;i--)r.disposals[i]();if(r.disposals.length=0,r.owner){let i=r.owner.children.indexOf(r);i>=0&&r.owner.children.splice(i,1)}}})}finally{K=n,U=t}}function ge(e){if(!e._disposed){e._disposed=!0;for(let n=e.children.length-1;n>=0;n--)ge(e.children[n]);e.children.length=0;for(let n=e.disposals.length-1;n>=0;n--)e.disposals[n]();e.disposals.length=0}}var ye=null;function _e(e){ye=e}function we(e,n){let t=n||ye?.();for(;t;){if(t._errorBoundary)return t._errorBoundary(e),!0;t=t._parentCtx}return!1}var ze=null;function Ce(e){ze=e}var Ke=new Set(["svg","path","circle","rect","line","polyline","polygon","ellipse","g","defs","use","symbol","clipPath","mask","pattern","image","text","tspan","textPath","foreignObject","linearGradient","radialGradient","stop","marker","animate","animateTransform","animateMotion","set","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence"]),Fe="http://www.w3.org/2000/svg",xe=new Set,Z=new WeakMap;function Je(e){return!e||typeof e!="object"?!1:typeof Node<"u"&&e instanceof Node?!0:typeof e.nodeType=="number"&&typeof e.nodeName=="string"}function fe(e){return!!e&&typeof e=="object"&&(e._vnode===!0||"tag"in e)}function be(e){if(!e.disposed){if(e.disposed=!0,e.cleanups)for(let n of e.cleanups)try{n()}catch(t){console.error("[what] cleanup error:",t)}if(e.effects)for(let n of e.effects)try{n()}catch{}if(e.hooks){for(let n of e.hooks)if(n&&typeof n.cleanup=="function")try{n.cleanup()}catch(t){console.error("[what] hook cleanup error:",t)}}if(e._cleanupCallbacks)for(let n of e._cleanupCallbacks)try{n()}catch(t){console.error("[what] onCleanup error:",t)}b&&w?.onComponentUnmount&&w.onComponentUnmount(e),xe.delete(e)}}function H(e){if(!e)return;e._componentCtx&&be(e._componentCtx);let n=Z.get(e);if(n&&be(n),e._dispose)try{e._dispose()}catch{}if(e._propEffects)for(let t in e._propEffects)try{e._propEffects[t]()}catch{}if(e.childNodes)for(let t of e.childNodes)H(t)}function D(e,n,t){if(e==null||e===!1||e===!0)return document.createComment("");if(typeof e=="string"||typeof e=="number")return document.createTextNode(String(e));if(Je(e))return e;if(typeof e=="function"){let r=document.createComment("fn"),o=document.createComment("/fn"),i=[],l=document.createDocumentFragment();l.appendChild(r),l.appendChild(o);let s=A(()=>{let f=e(),c=f==null||f===!1||f===!0?[]:Array.isArray(f)?f:[f],p=o.parentNode;if(p){for(let u of i)H(u),u.parentNode===p&&p.removeChild(u);i=[];for(let u of c){let _=D(u,p,n?._isSvg);if(_)if(_.nodeType===11){let y=Array.from(_.childNodes);p.insertBefore(_,o);for(let m of y)i.push(m)}else p.insertBefore(_,o),i.push(_)}}});return r._dispose=s,o._dispose=s,l}if(Array.isArray(e)){let r=document.createDocumentFragment();for(let o of e){let i=D(o,n,t);i&&r.appendChild(i)}return r}return fe(e)&&typeof e.tag=="function"||fe(e)&&(e.tag==="__errorBoundary"||e.tag==="__suspense"||e.tag==="__portal")?Ee(e,n,t):fe(e)?Qe(e,n,t):document.createTextNode(String(e))}var T=[];function Se(){return T[T.length-1]}_e(Se);Ce(Se);function Ne(){return T}function Ee(e,n,t){let{tag:r,props:o,children:i}=e;if(typeof r=="function"&&(r.prototype?.isReactComponent||r.prototype?.render)){let h=r;r=function(d){return new h(d).render()},r.displayName=h.displayName||h.name||"ClassComponent"}if(r==="__errorBoundary"||e.tag==="__errorBoundary")return Xe(e,n);if(r==="__suspense"||e.tag==="__suspense")return Ye(e,n);if(r==="__portal"||e.tag==="__portal")return Ze(e,n);let l={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,Component:r,_parentCtx:T[T.length-1]||null,_errorBoundary:(()=>{let h=T[T.length-1];for(;h;){if(h._errorBoundary)return h._errorBoundary;h=h._parentCtx}return null})()},s=document.createComment("c:start"),f=document.createComment("c:end");Z.set(s,l),l._startComment=s,l._endComment=f;let c=document.createDocumentFragment();c._componentCtx=l,l._wrapper=s,xe.add(l),b&&w?.onComponentMount&&w.onComponentMount(l);let p=i.length===0?void 0:i.length===1?i[0]:i,u=P({...o,children:p});l._propsSignal=u;let _=new Proxy({},{get(h,E){return u()[E]},has(h,E){let d=u();return E in d},ownKeys(){let h=u();return Reflect.ownKeys(h)},getOwnPropertyDescriptor(h,E){let d=u();if(E in d)return{value:d[E],writable:!1,enumerable:!0,configurable:!0}}});T.push(l);let y;try{y=r(_)}catch(h){if(T.pop(),!we(h,l))throw console.error("[what] Uncaught error in component:",r.name||"Anonymous",h),h;return c.appendChild(s),c.appendChild(f),c}T.pop(),l.mounted=!0,l._mountCallbacks&&queueMicrotask(()=>{if(!l.disposed)for(let h of l._mountCallbacks)try{h()}catch(E){console.error("[what] onMount error:",E)}}),c.appendChild(s);let m=Array.isArray(y)?y:[y];for(let h of m){let E=D(h,c,t);E&&c.appendChild(E)}return c.appendChild(f),c}function Xe(e,n){let{errorState:t,handleError:r,fallback:o,reset:i}=e.props,l=e.children,s=document.createComment("eb:start"),f=document.createComment("eb:end"),c={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,_parentCtx:T[T.length-1]||null,_errorBoundary:r,_startComment:s,_endComment:f};Z.set(s,c);let p=document.createDocumentFragment();p._componentCtx=c,p.appendChild(s),p.appendChild(f);let u=A(()=>{let _=t();if(T.push(c),s.parentNode)for(;s.nextSibling&&s.nextSibling!==f;){let m=s.nextSibling;H(m),m.parentNode.removeChild(m)}let y;_?y=typeof o=="function"?[o({error:_,reset:i})]:[o]:y=l,y=Array.isArray(y)?y:[y];for(let m of y){let h=D(m,n);h&&(f.parentNode?f.parentNode.insertBefore(h,f):p.insertBefore(h,f))}T.pop()});return c.effects.push(u),p}function Ye(e,n){let{boundary:t,fallback:r,loading:o}=e.props,i=e.children,l=document.createComment("sb:start"),s=document.createComment("sb:end"),f={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,_parentCtx:T[T.length-1]||null,_startComment:l,_endComment:s};Z.set(l,f);let c=document.createDocumentFragment();c._componentCtx=f,c.appendChild(l),c.appendChild(s);let p=A(()=>{let _=o()?[r]:i,y=Array.isArray(_)?_:[_];if(T.push(f),l.parentNode)for(;l.nextSibling&&l.nextSibling!==s;){let m=l.nextSibling;H(m),m.parentNode.removeChild(m)}for(let m of y){let h=D(m,n);h&&(s.parentNode?s.parentNode.insertBefore(h,s):c.insertBefore(h,s))}T.pop()});return f.effects.push(p),c}function Ze(e,n){let{container:t}=e.props,r=e.children;if(!t)return console.warn("[what] Portal: target container not found"),document.createComment("portal:empty");let o={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,_parentCtx:T[T.length-1]||null},i=document.createComment("portal");i._componentCtx=o;let l=[];for(let s of r){let f=D(s,t);f&&(t.appendChild(f),l.push(f))}return o._cleanupCallbacks=[()=>{for(let s of l)H(s),s.parentNode&&s.parentNode.removeChild(s)}],i}function Qe(e,n,t){let{tag:r,props:o,children:i}=e,l=t||Ke.has(r),s=l?document.createElementNS(Fe,r):document.createElement(r);o&&et(s,o,{},l);for(let f of i){let c=D(f,s,l&&r!=="foreignObject");c&&s.appendChild(c)}return s._vnode=e,s}function et(e,n,t,r){n=n||{},t=t||{};for(let o in n)if(!(o==="key"||o==="children")){if(o==="ref"){typeof n.ref=="function"?n.ref(e):n.ref&&(n.ref.current=e);continue}Le(e,o,n[o],r)}}function Le(e,n,t,r){if(typeof t=="function"&&!(n.startsWith("on")&&n.length>2)&&n!=="ref"){if(e._propEffects||(e._propEffects={}),e._propEffects[n])try{e._propEffects[n]()}catch{}e._propEffects[n]=A(()=>{let o=t();Le(e,n,o,r)});return}if(n.startsWith("on")&&n.length>2){let o=n.slice(2),i=!1;o.endsWith("Capture")&&(o=o.slice(0,-7),i=!0);let l=o.toLowerCase(),s=i?l+"_capture":l,f=e._events?.[s];if(f&&f._original===t||(f&&e.removeEventListener(l,f,i),t==null))return;e._events||(e._events={});let c=u=>(u.nativeEvent||(u.nativeEvent=u),le(()=>t(u)));c._original=t,e._events[s]=c;let p=t._eventOpts;e.addEventListener(l,c,p||i||void 0);return}if(n==="className"||n==="class"){r?e.setAttribute("class",t||""):e.className=t||"";return}if(n==="style"){if(typeof t=="string")e.style.cssText=t,e._prevStyle=null;else if(typeof t=="object"){let o=e._prevStyle||{};for(let i in o)i in t||(e.style[i]="");for(let i in t)e.style[i]=t[i]??"";e._prevStyle={...t}}return}if(n==="dangerouslySetInnerHTML"){e.innerHTML=t?.__html??"";return}if(n==="innerHTML"){if(t==null)return;if(t&&typeof t=="object"&&"__html"in t)e.innerHTML=t.__html??"";else{b&&console.warn("[what] innerHTML received a raw string. This is a security risk (XSS). Use innerHTML={{ __html: trustedString }} or dangerouslySetInnerHTML={{ __html: trustedString }} instead.");return}return}if(typeof t=="boolean"){t?e.setAttribute(n,""):e.removeAttribute(n);return}if(n.startsWith("data-")||n.startsWith("aria-")){e.setAttribute(n,t);return}if(r){t===!1||t==null?e.removeAttribute(n):e.setAttribute(n,t===!0?"":String(t));return}n in e?e[n]=t:e.setAttribute(n,t)}var tt={INFINITE_EFFECT:{code:"ERR_INFINITE_EFFECT",severity:"error",template:'Effect "{{effectName}}" exceeded 25 flush iterations \u2014 likely an infinite loop.',suggestion:"An effect is writing to a signal it also reads, creating a cycle. Use untrack() to read the signal without subscribing, or restructure so the write and read are in separate effects.",codeExample:`// Bad \u2014 reads and writes count, creating a cycle:
2
+ effect(() => { count(count() + 1); });
3
+
4
+ // Good \u2014 use untrack() so the read doesn't subscribe:
5
+ effect(() => { count(untrack(count) + 1); });
6
+
7
+ // Better \u2014 split into separate logic:
8
+ const doubled = computed(() => count() * 2);`},MISSING_SIGNAL_READ:{code:"ERR_MISSING_SIGNAL_READ",severity:"warning",template:'Signal "{{signalName}}" used without calling () \u2014 renders as "[Function]" instead of its value.',suggestion:"Signals are functions. Call them to read: count() not count. In JSX: {count()} not {count}.",codeExample:`// Bad \u2014 signal reference, not value:
9
+ <span>{count}</span> // renders "[Function]"
10
+
11
+ // Good \u2014 call the signal:
12
+ <span>{count()}</span> // renders the actual value`},HYDRATION_MISMATCH:{code:"ERR_HYDRATION_MISMATCH",severity:"error",template:'Hydration mismatch in component "{{component}}": server rendered "{{serverHTML}}" but client expects "{{clientHTML}}".',suggestion:"Ensure server and client render identical initial HTML. Avoid reading browser-only APIs (window, localStorage) during the initial render. Use onMount() for client-only logic.",codeExample:`// Bad \u2014 different on server vs client:
13
+ function App() {
14
+ return <p>{window.innerWidth}</p>;
15
+ }
16
+
17
+ // Good \u2014 use onMount for client-only values:
18
+ function App() {
19
+ const width = signal(0);
20
+ onMount(() => width(window.innerWidth));
21
+ return <p>{width()}</p>;
22
+ }`},ORPHAN_EFFECT:{code:"ERR_ORPHAN_EFFECT",severity:"warning",template:'Effect "{{effectName}}" was created outside a reactive root \u2014 it will never be cleaned up.',suggestion:"Wrap effect creation in createRoot() or create effects inside component functions where they are automatically tracked.",codeExample:`// Bad \u2014 orphaned, leaks memory:
23
+ effect(() => console.log(count()));
24
+
25
+ // Good \u2014 inside a root with cleanup:
26
+ createRoot(dispose => {
27
+ effect(() => console.log(count()));
28
+ // later: dispose() cleans up
29
+ });`},SIGNAL_WRITE_IN_RENDER:{code:"ERR_SIGNAL_WRITE_IN_RENDER",severity:"error",template:'Signal "{{signalName}}" written during render of component "{{component}}". This triggers re-execution.',suggestion:"Move signal writes into event handlers, effects, or onMount(). The component body should only read signals, not write them.",codeExample:`// Bad \u2014 write during render:
30
+ function Counter() {
31
+ count(count() + 1); // triggers infinite loop
32
+ return <span>{count()}</span>;
33
+ }
34
+
35
+ // Good \u2014 write in event handler:
36
+ function Counter() {
37
+ return <button onclick={() => count(c => c + 1)}>{count()}</button>;
38
+ }`},MISSING_CLEANUP:{code:"ERR_MISSING_CLEANUP",severity:"warning",template:'Effect sets up "{{resource}}" but does not return a cleanup function.',suggestion:"Effects that add event listeners, set timers, or open connections should return a cleanup function to prevent memory leaks.",codeExample:`// Bad \u2014 no cleanup:
39
+ effect(() => {
40
+ window.addEventListener('resize', handler);
41
+ });
42
+
43
+ // Good \u2014 return cleanup:
44
+ effect(() => {
45
+ window.addEventListener('resize', handler);
46
+ return () => window.removeEventListener('resize', handler);
47
+ });`},UNSAFE_INNERHTML:{code:"ERR_UNSAFE_INNERHTML",severity:"warning",template:"innerHTML set on element without using the __html safety marker.",suggestion:"Use the html tagged template literal or pass { __html: content } to mark innerHTML as intentional and reviewed.",codeExample:`// Bad \u2014 raw innerHTML (XSS risk):
48
+ <div innerHTML={userInput} />
49
+
50
+ // Good \u2014 explicit opt-in:
51
+ <div innerHTML={{ __html: sanitizedContent }} />
52
+
53
+ // Better \u2014 use the html template literal:
54
+ html\`<div>\${sanitizedContent}</div>\``},MISSING_KEY:{code:"ERR_MISSING_KEY",severity:"warning",template:'List rendered without key prop in component "{{component}}". Items may re-order incorrectly.',suggestion:"Add a unique key prop to each item in a list. Use a stable identifier (like an ID), not the array index.",codeExample:`// Bad \u2014 no key:
55
+ <For each={items()}>{item => <li>{item.name}</li>}</For>
56
+
57
+ // Good \u2014 stable key:
58
+ <For each={items()}>{item => <li key={item.id}>{item.name}</li>}</For>`}},ee=class extends Error{constructor({code:n,message:t,suggestion:r,file:o,line:i,component:l,signal:s,effect:f}){super(t),this.name="WhatError",this.code=n,this.suggestion=r,this.file=o,this.line=i,this.component=l,this.signal=s,this.effect=f}toJSON(){return{code:this.code,message:this.message,suggestion:this.suggestion,file:this.file,line:this.line,component:this.component,signal:this.signal,effect:this.effect}}};function Te(e,n={}){let t=typeof e=="string"?tt[e]:e;if(!t)return new ee({code:"ERR_UNKNOWN",message:`Unknown error: ${e}`,suggestion:"Check the error code and try again."});let r=t.template;for(let[o,i]of Object.entries(n))r=r.replace(new RegExp(`\\{\\{${o}\\}\\}`,"g"),String(i));return r=r.replace(/\{\{[^}]+\}\}/g,"(unknown)"),new ee({code:t.code,message:r,suggestion:t.suggestion,file:n.file,line:n.line,component:n.component,signal:n.signal||n.signalName,effect:n.effect||n.effectName})}var Q=[],Me=200;function Ae(e){b&&(Q.push({...e.toJSON(),timestamp:Date.now()}),Q.length>Me&&(Q=Q.slice(-Me)))}function kt(e,n,t){if(t&&t.length>0){let r=t.length===1?t[0]:t;n=n?{...n,children:r}:{children:r}}return D({tag:e,props:n||{},children:t||[],key:null,_vnode:!0})}var ke=new Set(["href","src","action","formaction","formAction"]);function nt(e){if(typeof e!="string")return!0;let n=e.trim().replace(/[\s\x00-\x1f]/g,"").toLowerCase();return!(n.startsWith("javascript:")||n.startsWith("data:")||n.startsWith("vbscript:"))}var rt={tr:{depth:2,wrap:"<table><tbody>",unwrap:"</tbody></table>"},td:{depth:3,wrap:"<table><tbody><tr>",unwrap:"</tr></tbody></table>"},th:{depth:3,wrap:"<table><tbody><tr>",unwrap:"</tr></tbody></table>"},thead:{depth:1,wrap:"<table>",unwrap:"</table>"},tbody:{depth:1,wrap:"<table>",unwrap:"</table>"},tfoot:{depth:1,wrap:"<table>",unwrap:"</table>"},colgroup:{depth:1,wrap:"<table>",unwrap:"</table>"},col:{depth:1,wrap:"<table>",unwrap:"</table>"},caption:{depth:1,wrap:"<table>",unwrap:"</table>"}},ot=new Set(["svg","path","circle","rect","line","polyline","polygon","ellipse","g","defs","use","text","tspan","foreignObject","clipPath","mask","pattern","linearGradient","radialGradient","stop","marker","symbol","image","animate","animateTransform","animateMotion","set","filter","feGaussianBlur","feOffset","feMerge","feMergeNode","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feImage","feMorphology","feSpecularLighting","feTile","feTurbulence","feDistantLight","fePointLight","feSpotLight"]);function He(e){let n=e.match(/^<([a-zA-Z][a-zA-Z0-9]*)/);return n?n[1]:""}function it(e){let n=e.trim(),t=He(n);if(ot.has(t))return st(n);let r=rt[t];if(r){let i=document.createElement("template");return i.innerHTML=r.wrap+n+r.unwrap,()=>{let l=i.content.firstChild;for(let s=0;s<r.depth;s++)l=l.firstChild;return l.cloneNode(!0)}}let o=document.createElement("template");return o.innerHTML=n,()=>o.content.firstChild.cloneNode(!0)}var Re=!1;function Rt(e){return b&&!Re&&(Re=!0,console.warn("[what] template() is a compiler internal. Use JSX instead. Direct calls with user input can lead to XSS vulnerabilities.")),it(e)}function st(e){let n=e.trim();if(He(n)==="svg"){let o=document.createElement("template");return o.innerHTML=n,()=>o.content.firstChild.cloneNode(!0)}let r=document.createElement("template");return r.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg">${n}</svg>`,()=>r.content.firstChild.firstChild.cloneNode(!0)}function It(e,n,t){if(typeof n=="function"){let r=null;return A(()=>{r=ne(e,n(),r,t||null)}),r}return ne(e,n,null,t||null)}function Be(e){return!e||typeof e!="object"?!1:typeof Node<"u"&&e instanceof Node?!0:typeof e.nodeType=="number"&&typeof e.nodeName=="string"}function ct(e){return!!e&&typeof e=="object"&&(e._vnode===!0||"tag"in e)}function lt(e){return typeof SVGElement<"u"&&e instanceof SVGElement&&e.tagName.toLowerCase()!=="foreignobject"}function Ie(e){return e==null?[]:Array.isArray(e)?e:[e]}function Oe(e,n,t){if(e==null||typeof e=="boolean")return t;if(Array.isArray(e)){for(let r=0;r<e.length;r++)Oe(e[r],n,t);return t}return typeof e=="string"||typeof e=="number"?(t.push(document.createTextNode(String(e))),t):Be(e)?(t.push(e),t):ct(e)?(t.push(D(e,n,lt(n))),t):(t.push(document.createTextNode(String(e))),t)}function ft(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function ne(e,n,t,r){if(!e||typeof e.insertBefore!="function")return b&&console.warn("[what] reconcileInsert called with invalid parent:",e),t;let o=r||null;if(n==null||typeof n=="boolean"){let c=Ie(t);for(let p=0;p<c.length;p++){let u=c[p];u.parentNode===e&&(H(u),e.removeChild(u))}return null}if((typeof n=="string"||typeof n=="number")&&t&&!Array.isArray(t)&&t.nodeType===3){let c=String(n);return t.textContent!==c&&(t.textContent=c),t}let i=Oe(n,e,[]),l=Ie(t);if(ft(l,i))return t;let s=new Set(i);for(let c=0;c<l.length;c++){let p=l[c];!s.has(p)&&p.parentNode===e&&(H(p),e.removeChild(p))}let f=o;for(let c=i.length-1;c>=0;c--){let p=i[c];(p.parentNode!==e||p.nextSibling!==f)&&(f&&f.parentNode!==e&&(f=null),f?e.insertBefore(p,f):e.appendChild(p)),f=p}return i.length===0?null:i.length===1?i[0]:i}function vt(e,n,t){let r=t?.key,o=t?.raw||!1;return(i,l)=>{let s=[],f=[],c=[],p=r&&!o?new Map:null,u=document.createComment("/list");return i.insertBefore(u,l||null),A(()=>{let _=e()||[];r?pt(i,u,s,_,f,c,n,r,p):at(i,u,s,_,f,c,n),s=_.slice()}),u}}function at(e,n,t,r,o,i,l){let s=r.length,f=t.length;if(s===0){if(f>0){for(let d=0;d<f;d++)i[d]?.(),o[d]?.parentNode===e&&(H(o[d]),e.removeChild(o[d]));o.length=0,i.length=0}return}if(f===0){let d=document.createDocumentFragment();for(let g=0;g<s;g++){let x=r[g],N=W(k=>(i[g]=k,l(x,g)));o[g]=N,d.appendChild(N)}e.insertBefore(d,n);return}let c=0,p=Math.min(f,s);for(;c<p&&t[c]===r[c];)c++;if(c===f&&c===s)return;let u=f-1,_=s-1;for(;u>=c&&_>=c&&t[u]===r[_];)u--,_--;let y=new Array(s),m=new Array(s);for(let d=0;d<c;d++)y[d]=o[d],m[d]=i[d];for(let d=_+1;d<s;d++){let g=u+1+(d-_-1);y[d]=o[g],m[d]=i[g]}let h=_-c+1,E=u-c+1;if(h===0)for(let d=c;d<=u;d++)i[d]?.(),o[d]?.parentNode&&o[d].parentNode.removeChild(o[d]);else if(E===0){let d=c<s&&y[_+1]?y[_+1]:n,g=document.createDocumentFragment();for(let x=c;x<=_;x++){let N=r[x],k=x;y[x]=W(R=>(m[k]=R,l(N,k))),g.appendChild(y[x])}e.insertBefore(g,d)}else ut(e,n,t,r,o,i,l,c,u,_,y,m);o.length=s,i.length=s;for(let d=0;d<s;d++)o[d]=y[d],i[d]=m[d]}function ut(e,n,t,r,o,i,l,s,f,c,p,u){let _=new Map;for(let g=s;g<=f;g++)_.set(t[g],g);let y=c-s+1,m=new Int32Array(y);m.fill(-1);for(let g=s;g<=c;g++){let x=_.get(r[g]);x!==void 0&&(_.delete(r[g]),p[g]=o[x],u[g]=i[x],m[g-s]=x)}for(let[,g]of _)i[g]?.(),o[g]?.parentNode&&o[g].parentNode.removeChild(o[g]);let h=y-dt(m,y),E=new Uint8Array(y);if(h>1){let g=new Int32Array(h),x=new Int32Array(h),N=0;for(let R=0;R<y;R++)m[R]!==-1&&(g[N]=m[R],x[N]=R,N++);let k=$e(g,h);for(let R=0;R<k.length;R++)E[x[k[R]]]=1}else if(h===1){for(let g=0;g<y;g++)if(m[g]!==-1){E[g]=1;break}}for(let g=s;g<=c;g++)if(!p[g]){let x=r[g],N=g;p[g]=W(k=>(u[N]=k,l(x,N)))}let d=c+1<p.length&&p[c+1]?p[c+1]:n;for(let g=c;g>=s;g--){let x=g-s;(m[x]===-1||!E[x])&&(d&&d.parentNode!==e&&(d=n),e.insertBefore(p[g],d)),d=p[g]}}function dt(e,n){let t=0;for(let r=0;r<n;r++)e[r]===-1&&t++;return t}function $e(e,n){if(n===0)return[];if(n===1)return[0];let t=new Int32Array(n),r=new Int32Array(n),o=1;t[0]=0,r[0]=-1;for(let s=1;s<n;s++)if(e[s]>e[t[o-1]])r[s]=t[o-1],t[o++]=s;else{let f=0,c=o-1;for(;f<c;){let p=f+c>>1;e[t[p]]<e[s]?f=p+1:c=p}t[f]=s,r[s]=f>0?t[f-1]:-1}let i=new Array(o),l=t[o-1];for(let s=o-1;s>=0;s--)i[s]=l,l=r[l];return i}function pt(e,n,t,r,o,i,l,s,f){let c=r.length,p=t.length;if(c===0){if(p>0){for(let a=0;a<p;a++)i[a]?.(),o[a]?.parentNode===e&&(H(o[a]),e.removeChild(o[a]));o.length=0,i.length=0,f&&f.clear()}return}if(p===0){let a=document.createDocumentFragment();for(let C=0;C<c;C++){let S=r[C],v=C,M;if(f){let $=s(S),z=P(S);M=z,f.set($,{itemSig:z})}else M=S;let B=W($=>(i[v]=$,l(M,v)));o[C]=B,a.appendChild(B)}e.insertBefore(a,n);return}let u=0,_=Math.min(p,c);for(;u<_;){if(t[u]===r[u]){u++;continue}let a=s(t[u]),C=s(r[u]);if(a!==C)break;f&&f.get(a).itemSig.set(r[u]),u++}let y=p-1,m=c-1;for(;y>=u&&m>=u;){if(t[y]===r[m]){y--,m--;continue}let a=s(t[y]),C=s(r[m]);if(a!==C)break;f&&f.get(a).itemSig.set(r[m]),y--,m--}if(u>y&&u>m)return;let h=new Array(c),E=new Array(c);for(let a=0;a<u;a++)h[a]=o[a],E[a]=i[a];for(let a=m+1;a<c;a++){let C=y+1+(a-m-1);h[a]=o[C],E[a]=i[C]}let d=m-u+1;if(y-u+1===0){let a=m+1<c&&h[m+1]?h[m+1]:n,C=document.createDocumentFragment();for(let S=u;S<=m;S++){let v=r[S],M=S,B;if(f){let $=s(v),z=P(v);B=z,f.set($,{itemSig:z})}else B=v;h[S]=W($=>(E[M]=$,l(B,M))),C.appendChild(h[S])}e.insertBefore(C,a),ae(o,i,h,E,c);return}if(d===0){for(let a=u;a<=y;a++)i[a]?.(),o[a]?.parentNode&&e.removeChild(o[a]),f&&f.delete(s(t[a]));ae(o,i,h,E,c);return}let x=new Map;for(let a=u;a<=y;a++)x.set(s(t[a]),a);let N=new Int32Array(d);N.fill(-1);for(let a=u;a<=m;a++){let C=s(r[a]),S=x.get(C);S!==void 0&&(x.delete(C),h[a]=o[S],E[a]=i[S],N[a-u]=S,f&&r[a]!==t[S]&&f.get(C).itemSig.set(r[a]))}for(let[a,C]of x)i[C]?.(),o[C]?.parentNode&&e.removeChild(o[C]),f&&f.delete(a);for(let a=u;a<=m;a++)if(!h[a]){let C=r[a],S=a,v;if(f){let M=s(C),B=P(C);v=B,f.set(M,{itemSig:B})}else v=C;h[a]=W(M=>(E[S]=M,l(v,S)))}let k=0,R=!0,ue=-1;for(let a=0;a<d;a++)N[a]!==-1&&(k++,N[a]<=ue&&(R=!1),ue=N[a]);let X=new Uint8Array(d);if(R)for(let a=0;a<d;a++)N[a]!==-1&&(X[a]=1);else if(k>1){let a=new Int32Array(k),C=new Int32Array(k),S=0;for(let M=0;M<d;M++)N[M]!==-1&&(a[S]=N[M],C[S]=M,S++);let v=$e(a,k);for(let M=0;M<v.length;M++)X[C[v[M]]]=1}else if(k===1){for(let a=0;a<d;a++)if(N[a]!==-1){X[a]=1;break}}let V=m+1<h.length&&h[m+1]?h[m+1]:n;for(let a=m;a>=u;a--){let C=a-u;(N[C]===-1||!X[C])&&(V&&V.parentNode!==e&&(V=n),e.insertBefore(h[a],V)),V=h[a]}ae(o,i,h,E,c)}function ae(e,n,t,r,o){e.length=o,n.length=o;for(let i=0;i<o;i++)e[i]=t[i],n[i]=r[i]}function Dt(e,n){for(let t in n){let r=n[t];if(t.startsWith("on")&&t.length>2){let o=t.slice(2).toLowerCase();e.addEventListener(o,r);continue}typeof r=="function"&&!t.startsWith("on")?t==="class"||t==="className"?A(()=>{e.className=r()||""}):t==="style"&&typeof r()=="object"?A(()=>{let o=r();for(let i in o)e.style[i]=o[i]??""}):A(()=>{J(e,t,r())}):J(e,t,r)}}function J(e,n,t){if(n==="ref"){typeof t=="function"?t(e):t&&typeof t=="object"&&(t.current=e);return}if(n!=="key"){if((ke.has(n)||ke.has(n.toLowerCase()))&&!nt(t)){typeof console<"u"&&console.warn(`[what] Blocked unsafe URL in "${n}" attribute: ${t}`);return}if(n==="class"||n==="className")e.className=t||"";else if(n==="dangerouslySetInnerHTML")e.innerHTML=t?.__html??"";else if(n==="innerHTML")t&&typeof t=="object"&&"__html"in t?e.innerHTML=t.__html??"":typeof console<"u"&&t!=null&&t!==""&&console.warn('[what] Plain string innerHTML is not allowed. Use { __html: "..." } or dangerouslySetInnerHTML={{ __html: "..." }} instead.');else if(n==="style"){if(typeof t=="string")e.style.cssText=t;else if(typeof t=="object")for(let r in t)e.style[r]=t[r]??""}else n.startsWith("data-")||n.startsWith("aria-")?e.setAttribute(n,t):typeof t=="boolean"?t?e.setAttribute(n,""):e.removeAttribute(n):n in e?e[n]=t:e.setAttribute(n,t)}}var ve=new Set;function Ht(e){for(let n of e)ve.has(n)||(ve.add(n),document.addEventListener(n,t=>{let r=t.target,o="$$"+n;for(;r;){let i=r[o];if(i&&(i(t),t.cancelBubble))return;r=r.parentNode}}))}function Bt(e,n,t){return e.addEventListener(n,t),()=>e.removeEventListener(n,t)}function Ot(e,n){A(()=>{for(let t in n){let r=typeof n[t]=="function"?n[t]():n[t];e.classList.toggle(t,!!r)}})}var re=!1,O=null;function $t(){return re}function jt(e,n){re=!0,O={parent:n,index:0},G=0;try{let t=F(e,n);return b&&G>0&&console.warn(`[what] Hydration completed with ${G} mismatch${G===1?"":"es"}. See previous warnings for details. This usually means server and client render different initial HTML.`),t}finally{re=!1,O=null}}function De(e){let n=e.childNodes;for(;O.index<n.length;){let t=n[O.index];if(t.nodeType===8){let r=t.textContent;if(r==="$"||r==="/$"||r==="[]"||r==="/[]"){O.index++;continue}}return O.index++,t}return null}var G=0;function Wt(){return G}function te(e,n,t){if(G++,b){let o=Te("HYDRATION_MISMATCH",{component:t||"unknown",serverHTML:n,clientHTML:e});Ae(o),w?.onHydrationMismatch&&w.onHydrationMismatch({component:t||"unknown",expected:e,actual:n,mismatchCount:G}),w?.onError&&w.onError(o,{type:"hydration",component:t}),console.warn(`[what] Hydration mismatch: expected ${e}, got ${n}`+(t?` (in ${t})`:"")+". Falling back to client render.")}}function F(e,n,t){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number"){let o=De(n),i=String(e);if(o&&o.nodeType===3)return b&&o.textContent!==i&&(te(`text "${i}"`,`text "${o.textContent}"`,t),o.textContent=i),o;te(`text node "${i}"`,o?o.nodeName:"nothing",t);let l=document.createTextNode(i);return o?n.replaceChild(l,o):n.appendChild(l),l}if(typeof e=="function"){let o=e(),i=F(o,n,t);return A(()=>{let l=e();re||(i=ne(n,l,i,null))}),i}if(Array.isArray(e)){let o=[];for(let i of e){let l=F(i,n,t);l&&o.push(l)}return o.length===1?o[0]:o}if(typeof e=="object"&&e._vnode){if(typeof e.tag=="function"){let s=Ne(),f=e.tag,c=f.displayName||f.name||"Anonymous",p=e.props||{},u=e.children||[],_={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,Component:f,_parentCtx:s[s.length-1]||null,_errorBoundary:null};s.push(_);let y;try{let m=u.length===0?void 0:u.length===1?u[0]:u;y=f({...p,children:m})}catch(m){return s.pop(),b&&console.error("[what] Error in component during hydration:",c,m),null}return s.pop(),_.mounted=!0,_._mountCallbacks&&queueMicrotask(()=>{if(!_.disposed)for(let m of _._mountCallbacks)try{m()}catch(h){console.error("[what] onMount error:",h)}}),F(y,n,c)}let o=De(n),i=e.tag.toUpperCase();if(o&&o.nodeType===1&&o.nodeName===i){if(ht(o,e.props||{}),e.props?.ref){let c=e.props.ref;typeof c=="function"?c(o):typeof c=="object"&&c!==null&&(c.current=o)}let s=O;if(O={parent:o,index:0},e.props?.dangerouslySetInnerHTML?.__html==null)for(let c of e.children)F(c,o,t);return O=s,o}te(`<${e.tag}>`,o?o.nodeName:"nothing",t);let l=document.createElement(e.tag);for(let s in e.props||{})s==="children"||s==="key"||J(l,s,e.props[s]);for(let s of e.children)ne(l,s,null,null);return o?n.replaceChild(l,o):n.appendChild(l),l}if(Be(e))return e;let r=document.createTextNode(String(e));return n.appendChild(r),r}function ht(e,n){for(let t in n){if(t==="children"||t==="key"||t==="ref"||t==="dangerouslySetInnerHTML"||t==="innerHTML")continue;let r=n[t];if(t.startsWith("on")&&t.length>2){let o=t.slice(2).toLowerCase();e.addEventListener(o,r);continue}if(t.startsWith("$$")){e[t]=r;continue}if(typeof r=="function"&&!t.startsWith("on")){t==="class"||t==="className"?A(()=>{e.className=r()||""}):t==="style"&&typeof r()=="object"?A(()=>{let o=r();for(let i in o)e.style[i]=o[i]??""}):A(()=>{J(e,t,r())});continue}if(t!=="data-hk"&&b&&typeof r=="string"){let o=t==="className"?"class":t==="htmlFor"?"for":t,i=e.getAttribute(o);i!==null&&i!==r&&(te(`${o}="${r}"`,`${o}="${i}"`,e.tagName.toLowerCase()),J(e,t,r))}}}export{kt as _$createComponent,it as _$template,Rt as _template,Ot as classList,Ht as delegateEvents,A as effect,Wt as getHydrationMismatchCount,jt as hydrate,It as insert,$t as isHydrating,vt as mapArray,Bt as on,J as setProp,Dt as spread,st as svgTemplate,Rt as template,le as untrack};
2
59
  //# sourceMappingURL=render.min.js.map