what-core 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var L=!(typeof process<"u"),w=null;var A=null,G=null,I=null,se=!1,F=0,O=[],X=!1,De=new WeakMap,Oe=Symbol("needs_upstream");function V(e,n){let t=e,r=new Set;function o(...i){if(i.length===0)return A&&(r.add(A),A.deps.push(r)),t;L&&se&&console.warn("[what] Signal.set() called inside a computed function. This may cause infinite loops. Use effect() instead."+(n?` (signal: ${n})`:""));let c=typeof i[0]=="function"?i[0](t):i[0];Object.is(t,c)||(t=c,L&&w&&w.onSignalUpdate(o),r.size>0&&ce(r))}return o.set=i=>{L&&se&&console.warn("[what] Signal.set() called inside a computed function. This may cause infinite loops. Use effect() instead."+(n?` (signal: ${n})`:""));let c=typeof i=="function"?i(t):i;Object.is(t,c)||(t=c,L&&w&&w.onSignalUpdate(o),r.size>0&&ce(r))},o.peek=()=>t,o.subscribe=i=>T(()=>i(o())),o._signal=!0,L&&(o._subs=r,n&&(o._debugName=n)),L&&w&&w.onSignalCreate(o),o}function fe(e){let n=0,t=e.deps;for(let r=0;r<t.length;r++){let o=De.get(t[r]);if(o){let i=o._level;i>n&&(n=i)}}e._level=n+1}function T(e,n){let t=Be(e);t._level=1;let r=A;A=t;try{let i=t.fn();typeof i=="function"&&(t._cleanup=i)}finally{A=r}fe(t),n?.stable&&(t._stable=!0);let o=()=>He(t);return G&&G.disposals.push(o),o}function Be(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 L&&w&&w.onEffectCreate(t),t}function je(e){if(e.disposed)return;if(e._stable){if(e._cleanup){try{e._cleanup()}catch(r){L&&console.warn("[what] Error in effect cleanup:",r)}e._cleanup=null}let t=A;A=null;try{let r=e.fn();typeof r=="function"&&(e._cleanup=r)}catch(r){w?.onError&&w.onError(r,{type:"effect",effect:e}),L&&console.warn("[what] Error in stable effect:",r)}finally{A=t}L&&w?.onEffectRun&&w.onEffectRun(e);return}if(le(e),e._cleanup){try{e._cleanup()}catch(t){w?.onError&&w.onError(t,{type:"effect-cleanup",effect:e}),L&&console.warn("[what] Error in effect cleanup:",t)}e._cleanup=null}let n=A;A=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{A=n}L&&w?.onEffectRun&&w.onEffectRun(e)}function He(e){if(e.disposed=!0,L&&w&&w.onEffectDispose(e),le(e),e._cleanup){try{e._cleanup()}catch(n){L&&console.warn("[what] Error in effect cleanup on dispose:",n)}e._cleanup=null}}function le(e){let n=e.deps;for(let t=0;t<n.length;t++)n[t].delete(e);n.length=0}var ee=0,R=null,U=0;function ce(e){if(ee===0){ee=1;try{for(let n of e)if(!n.disposed){if(n._onNotify)n._onNotify();else if(F===0&&n._stable){let t=A;A=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}),L&&console.warn("[what] Error in stable effect:",r)}finally{A=t}}else if(!n._pending){n._pending=!0;let t=n._level,r=O.length;r>0&&O[r-1]._level>t&&(X=!0),O.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(F===0&&r._stable){let o=A;A=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}),L&&console.warn("[what] Error in stable effect:",i)}finally{A=o}}else if(!r._pending){r._pending=!0;let o=r._level,i=O.length;i>0&&O[i-1]._level>o&&(X=!0),O.push(r)}}}U=0}}finally{ee=0}F===0&&O.length>0&&$e()}else R===null&&(R=[]),U>=R.length?R.push(e):R[U]=e,U++}var te=!1;function $e(){te||(te=!0,queueMicrotask(()=>{te=!1,ve()}))}function ve(){let e=0;for(;O.length>0&&e<25;){let n=O;O=[],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;je(r),!r._computed&&r.deps.length!==o&&fe(r)}}e++}if(e>=25){if(L){let t=O.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");for(let n=0;n<O.length;n++)O[n]._pending=!1;O.length=0}}function ne(e){let n=A;A=null;try{return e()}finally{A=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--)ae(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 ae(e){if(!e._disposed){e._disposed=!0;for(let n=e.children.length-1;n>=0;n--)ae(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 ue=null;function pe(e){ue=e}function de(e,n){let t=n||ue?.();for(;t;){if(t._errorBoundary)return t._errorBoundary(e),!0;t=t._parentCtx}return!1}var We=null;function he(e){We=e}var Re=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"]),qe="http://www.w3.org/2000/svg",ye=new Set,_e=new WeakMap;function Ie(e){return!e||typeof e!="object"?!1:typeof Node<"u"&&e instanceof Node?!0:typeof e.nodeType=="number"&&typeof e.nodeName=="string"}function me(e){return!!e&&typeof e=="object"&&(e._vnode===!0||"tag"in e)}function ge(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)}L&&w?.onComponentUnmount&&w.onComponentUnmount(e),ye.delete(e)}}function H(e){if(!e)return;e._componentCtx&&ge(e._componentCtx);let n=_e.get(e);if(n&&ge(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 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(Ie(e))return e;if(typeof e=="function"){let r=document.createComment("fn"),o=document.createComment("/fn"),i=[],c=document.createDocumentFragment();c.appendChild(r),c.appendChild(o);let s=T(()=>{let a=e(),l=a==null||a===!1||a===!0?[]:Array.isArray(a)?a:[a],p=o.parentNode;if(p){for(let u of i)H(u),u.parentNode===p&&p.removeChild(u);i=[];for(let u of l){let y=j(u,p,n?._isSvg);if(y)if(y.nodeType===11){let g=Array.from(y.childNodes);p.insertBefore(y,o);for(let _ of g)i.push(_)}else p.insertBefore(y,o),i.push(y)}}});return r._dispose=s,o._dispose=s,c}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 me(e)&&typeof e.tag=="function"?Ue(e,n,t):me(e)?Ge(e,n,t):document.createTextNode(String(e))}var M=[];function Ce(){return M[M.length-1]}pe(Ce);he(Ce);function we(){return M}function Ue(e,n,t){let{tag:r,props:o,children:i}=e;if(typeof r=="function"&&(r.prototype?.isReactComponent||r.prototype?.render)){let m=r;r=function(d){return new m(d).render()},r.displayName=m.displayName||m.name||"ClassComponent"}if(r==="__errorBoundary"||e.tag==="__errorBoundary")return Ve(e,n);if(r==="__suspense"||e.tag==="__suspense")return Pe(e,n);if(r==="__portal"||e.tag==="__portal")return ze(e,n);let c={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,Component:r,_parentCtx:M[M.length-1]||null,_errorBoundary:(()=>{let m=M[M.length-1];for(;m;){if(m._errorBoundary)return m._errorBoundary;m=m._parentCtx}return null})()},s=document.createComment("c:start"),a=document.createComment("c:end");_e.set(s,c),c._startComment=s,c._endComment=a;let l=document.createDocumentFragment();l._componentCtx=c,c._wrapper=s,ye.add(c),L&&w?.onComponentMount&&w.onComponentMount(c);let p=i.length===0?void 0:i.length===1?i[0]:i,u=V({...o,children:p});c._propsSignal=u;let y=new Proxy({},{get(m,b){return u()[b]},has(m,b){let d=u();return b in d},ownKeys(){let m=u();return Reflect.ownKeys(m)},getOwnPropertyDescriptor(m,b){let d=u();if(b in d)return{value:d[b],writable:!1,enumerable:!0,configurable:!0}}});M.push(c);let g;try{g=r(y)}catch(m){if(M.pop(),!de(m,c))throw console.error("[what] Uncaught error in component:",r.name||"Anonymous",m),m;return l.appendChild(s),l.appendChild(a),l}M.pop(),c.mounted=!0,c._mountCallbacks&&queueMicrotask(()=>{if(!c.disposed)for(let m of c._mountCallbacks)try{m()}catch(b){console.error("[what] onMount error:",b)}}),l.appendChild(s);let _=Array.isArray(g)?g:[g];for(let m of _){let b=j(m,l,t);b&&l.appendChild(b)}return l.appendChild(a),l}function Ve(e,n){let{errorState:t,handleError:r,fallback:o,reset:i}=e.props,c=e.children,s=document.createElement("span");s.style.display="contents";let a={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,_parentCtx:M[M.length-1]||null,_errorBoundary:r};s._componentCtx=a;let l=T(()=>{let p=t();for(M.push(a);s.firstChild;)H(s.firstChild),s.removeChild(s.firstChild);let u;p?u=typeof o=="function"?[o({error:p,reset:i})]:[o]:u=c,u=Array.isArray(u)?u:[u];for(let y of u){let g=j(y,s);g&&s.appendChild(g)}M.pop()});return a.effects.push(l),s}function Pe(e,n){let{boundary:t,fallback:r,loading:o}=e.props,i=e.children,c=document.createElement("span");c.style.display="contents";let s={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,_parentCtx:M[M.length-1]||null};c._componentCtx=s;let a=T(()=>{let p=o()?[r]:i,u=Array.isArray(p)?p:[p];for(M.push(s);c.firstChild;)H(c.firstChild),c.removeChild(c.firstChild);for(let y of u){let g=j(y,c);g&&c.appendChild(g)}M.pop()});return s.effects.push(a),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:M[M.length-1]||null},i=document.createComment("portal");i._componentCtx=o;let c=[];for(let s of r){let a=j(s,t);a&&(t.appendChild(a),c.push(a))}return o._cleanupCallbacks=[()=>{for(let s of c)H(s),s.parentNode&&s.parentNode.removeChild(s)}],i}function Ge(e,n,t){let{tag:r,props:o,children:i}=e,c=t||Re.has(r),s=c?document.createElementNS(qe,r):document.createElement(r);o&&Ke(s,o,{},c);for(let a of i){let l=j(a,s,c&&r!=="foreignObject");l&&s.appendChild(l)}return s._vnode=e,s}function Ke(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}be(e,o,n[o],r)}}function be(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();be(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 c=o.toLowerCase(),s=i?c+"_capture":c,a=e._events?.[s];if(a&&a._original===t||(a&&e.removeEventListener(c,a,i),t==null))return;e._events||(e._events={});let l=u=>(u.nativeEvent||(u.nativeEvent=u),ne(()=>t(u)));l._original=t,e._events[s]=l;let p=t._eventOpts;e.addEventListener(c,l,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{L&&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 Ct(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 xe=new Set(["href","src","action","formaction","formAction"]);function Je(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 Xe={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>"}},Ze=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 Ne(e){let n=e.match(/^<([a-zA-Z][a-zA-Z0-9]*)/);return n?n[1]:""}function Qe(e){let n=e.trim(),t=Ne(n);if(Ze.has(t))return Ye(n);let r=Xe[t];if(r){let i=document.createElement("template");return i.innerHTML=r.wrap+n+r.unwrap,()=>{let c=i.content.firstChild;for(let s=0;s<r.depth;s++)c=c.firstChild;return c.cloneNode(!0)}}let o=document.createElement("template");return o.innerHTML=n,()=>o.content.firstChild.cloneNode(!0)}var Ee=!1;function wt(e){return L&&!Ee&&(Ee=!0,console.warn("[what] template() is a compiler internal. Use JSX instead. Direct calls with user input can lead to XSS vulnerabilities.")),Qe(e)}function Ye(e){let n=e.trim();if(Ne(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 bt(e,n,t){if(typeof n=="function"){let r=null;return T(()=>{r=Z(e,n(),r,t||null)}),r}return Z(e,n,null,t||null)}function Me(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 et(e){return typeof SVGElement<"u"&&e instanceof SVGElement&&e.tagName.toLowerCase()!=="foreignobject"}function Le(e){return e==null?[]:Array.isArray(e)?e:[e]}function Te(e,n,t){if(e==null||typeof e=="boolean")return t;if(Array.isArray(e)){for(let r=0;r<e.length;r++)Te(e[r],n,t);return t}return typeof e=="string"||typeof e=="number"?(t.push(document.createTextNode(String(e))),t):Me(e)?(t.push(e),t):Fe(e)?(t.push(j(e,n,et(n))),t):(t.push(document.createTextNode(String(e))),t)}function tt(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 Z(e,n,t,r){let o=r||null;if(n==null||typeof n=="boolean"){let l=Le(t);for(let p=0;p<l.length;p++){let u=l[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 l=String(n);return t.textContent!==l&&(t.textContent=l),t}let i=Te(n,e,[]),c=Le(t);if(tt(c,i))return t;let s=new Set(i);for(let l=0;l<c.length;l++){let p=c[l];!s.has(p)&&p.parentNode===e&&(H(p),e.removeChild(p))}let a=o;for(let l=i.length-1;l>=0;l--){let p=i[l];(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 xt(e,n,t){let r=t?.key,o=t?.raw||!1;return(i,c)=>{let s=[],a=[],l=[],p=r&&!o?new Map:null,u=document.createComment("/list");return i.insertBefore(u,c||null),T(()=>{let y=e()||[];r?it(i,u,s,y,a,l,n,r,p):nt(i,u,s,y,a,l,n),s=y.slice()}),u}}function nt(e,n,t,r,o,i,c){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&&(H(o[d]),e.removeChild(o[d]));o.length=0,i.length=0}return}if(a===0){let d=document.createDocumentFragment();for(let h=0;h<s;h++){let x=r[h],S=q(k=>(i[h]=k,c(x,h)));o[h]=S,d.appendChild(S)}e.insertBefore(d,n);return}let l=0,p=Math.min(a,s);for(;l<p&&t[l]===r[l];)l++;if(l===a&&l===s)return;let u=a-1,y=s-1;for(;u>=l&&y>=l&&t[u]===r[y];)u--,y--;let g=new Array(s),_=new Array(s);for(let d=0;d<l;d++)g[d]=o[d],_[d]=i[d];for(let d=y+1;d<s;d++){let h=u+1+(d-y-1);g[d]=o[h],_[d]=i[h]}let m=y-l+1,b=u-l+1;if(m===0)for(let d=l;d<=u;d++)i[d]?.(),o[d]?.parentNode&&o[d].parentNode.removeChild(o[d]);else if(b===0){let d=l<s&&g[y+1]?g[y+1]:n,h=document.createDocumentFragment();for(let x=l;x<=y;x++){let S=r[x],k=x;g[x]=q(D=>(_[k]=D,c(S,k))),h.appendChild(g[x])}e.insertBefore(h,d)}else rt(e,n,t,r,o,i,c,l,u,y,g,_);o.length=s,i.length=s;for(let d=0;d<s;d++)o[d]=g[d],i[d]=_[d]}function rt(e,n,t,r,o,i,c,s,a,l,p,u){let y=new Map;for(let h=s;h<=a;h++)y.set(t[h],h);let g=l-s+1,_=new Int32Array(g);_.fill(-1);for(let h=s;h<=l;h++){let x=y.get(r[h]);x!==void 0&&(y.delete(r[h]),p[h]=o[x],u[h]=i[x],_[h-s]=x)}for(let[,h]of y)i[h]?.(),o[h]?.parentNode&&o[h].parentNode.removeChild(o[h]);let m=g-ot(_,g),b=new Uint8Array(g);if(m>1){let h=new Int32Array(m),x=new Int32Array(m),S=0;for(let D=0;D<g;D++)_[D]!==-1&&(h[S]=_[D],x[S]=D,S++);let k=ke(h,m);for(let D=0;D<k.length;D++)b[x[k[D]]]=1}else if(m===1){for(let h=0;h<g;h++)if(_[h]!==-1){b[h]=1;break}}for(let h=s;h<=l;h++)if(!p[h]){let x=r[h],S=h;p[h]=q(k=>(u[S]=k,c(x,S)))}let d=l+1<p.length&&p[l+1]?p[l+1]:n;for(let h=l;h>=s;h--){let x=h-s;(_[x]===-1||!b[x])&&(d&&d.parentNode!==e&&(d=n),e.insertBefore(p[h],d)),d=p[h]}}function ot(e,n){let t=0;for(let r=0;r<n;r++)e[r]===-1&&t++;return t}function ke(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,l=o-1;for(;a<l;){let p=a+l>>1;e[t[p]]<e[s]?a=p+1:l=p}t[a]=s,r[s]=a>0?t[a-1]:-1}let i=new Array(o),c=t[o-1];for(let s=o-1;s>=0;s--)i[s]=c,c=r[c];return i}function it(e,n,t,r,o,i,c,s,a){let l=r.length,p=t.length;if(l===0){if(p>0){for(let f=0;f<p;f++)i[f]?.(),o[f]?.parentNode===e&&(H(o[f]),e.removeChild(o[f]));o.length=0,i.length=0,a&&a.clear()}return}if(p===0){let f=document.createDocumentFragment();for(let C=0;C<l;C++){let E=r[C],B=C,N;if(a){let W=s(E),z=V(E);N=z,a.set(W,{itemSig:z})}else N=E;let $=q(W=>(i[B]=W,c(N,B)));o[C]=$,f.appendChild($)}e.insertBefore(f,n);return}let u=0,y=Math.min(p,l);for(;u<y;){if(t[u]===r[u]){u++;continue}let f=s(t[u]),C=s(r[u]);if(f!==C)break;a&&a.get(f).itemSig.set(r[u]),u++}let g=p-1,_=l-1;for(;g>=u&&_>=u;){if(t[g]===r[_]){g--,_--;continue}let f=s(t[g]),C=s(r[_]);if(f!==C)break;a&&a.get(f).itemSig.set(r[_]),g--,_--}if(u>g&&u>_)return;let m=new Array(l),b=new Array(l);for(let f=0;f<u;f++)m[f]=o[f],b[f]=i[f];for(let f=_+1;f<l;f++){let C=g+1+(f-_-1);m[f]=o[C],b[f]=i[C]}let d=_-u+1;if(g-u+1===0){let f=_+1<l&&m[_+1]?m[_+1]:n,C=document.createDocumentFragment();for(let E=u;E<=_;E++){let B=r[E],N=E,$;if(a){let W=s(B),z=V(B);$=z,a.set(W,{itemSig:z})}else $=B;m[E]=q(W=>(b[N]=W,c($,N))),C.appendChild(m[E])}e.insertBefore(C,f),re(o,i,m,b,l);return}if(d===0){for(let f=u;f<=g;f++)i[f]?.(),o[f]?.parentNode&&e.removeChild(o[f]),a&&a.delete(s(t[f]));re(o,i,m,b,l);return}let x=new Map;for(let f=u;f<=g;f++)x.set(s(t[f]),f);let S=new Int32Array(d);S.fill(-1);for(let f=u;f<=_;f++){let C=s(r[f]),E=x.get(C);E!==void 0&&(x.delete(C),m[f]=o[E],b[f]=i[E],S[f-u]=E,a&&r[f]!==t[E]&&a.get(C).itemSig.set(r[f]))}for(let[f,C]of x)i[C]?.(),o[C]?.parentNode&&e.removeChild(o[C]),a&&a.delete(f);for(let f=u;f<=_;f++)if(!m[f]){let C=r[f],E=f,B;if(a){let N=s(C),$=V(C);B=$,a.set(N,{itemSig:$})}else B=C;m[f]=q(N=>(b[E]=N,c(B,E)))}let k=0,D=!0,ie=-1;for(let f=0;f<d;f++)S[f]!==-1&&(k++,S[f]<=ie&&(D=!1),ie=S[f]);let J=new Uint8Array(d);if(D)for(let f=0;f<d;f++)S[f]!==-1&&(J[f]=1);else if(k>1){let f=new Int32Array(k),C=new Int32Array(k),E=0;for(let N=0;N<d;N++)S[N]!==-1&&(f[E]=S[N],C[E]=N,E++);let B=ke(f,k);for(let N=0;N<B.length;N++)J[C[B[N]]]=1}else if(k===1){for(let f=0;f<d;f++)if(S[f]!==-1){J[f]=1;break}}let P=_+1<m.length&&m[_+1]?m[_+1]:n;for(let f=_;f>=u;f--){let C=f-u;(S[C]===-1||!J[C])&&(P&&P.parentNode!==e&&(P=n),e.insertBefore(m[f],P)),P=m[f]}re(o,i,m,b,l)}function re(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 Et(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(()=>{Q(e,t,r())}):Q(e,t,r)}}function Q(e,n,t){if((xe.has(n)||xe.has(n.toLowerCase()))&&!Je(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 Se=new Set;function Lt(e){for(let n of e)Se.has(n)||(Se.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 St(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 Y=!1,v=null;function Nt(){return Y}function Mt(e,n){Y=!0,v={parent:n,index:0};try{return K(e,n)}finally{Y=!1,v=null}}function Ae(e){let n=e.childNodes;for(;v.index<n.length;){let t=n[v.index];if(t.nodeType===8){let r=t.textContent;if(r==="$"||r==="/$"||r==="[]"||r==="/[]"){v.index++;continue}}return v.index++,t}return null}function oe(){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 oe()&&r.textContent!==o&&(console.warn(`[what] Hydration mismatch: expected text "${o}", got "${r.textContent}"`),r.textContent=o),r;oe()&&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();Y||(o=Z(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 c=we(),s=e.tag,a=e.props||{},l=e.children||[],p={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,Component:s,_parentCtx:c[c.length-1]||null,_errorBoundary:null};c.push(p);let u;try{let y=l.length===0?void 0:l.length===1?l[0]:l;u=s({...a,children:y})}catch(y){return c.pop(),console.error("[what] Error in component during hydration:",s.name||"Anonymous",y),null}return c.pop(),p.mounted=!0,p._mountCallbacks&&queueMicrotask(()=>{if(!p.disposed)for(let y of p._mountCallbacks)try{y()}catch(g){console.error("[what] onMount error:",g)}}),K(u,n)}let r=Ae(n),o=e.tag.toUpperCase();if(r&&r.nodeType===1&&r.nodeName===o){st(r,e.props||{});let c=v;if(v={parent:r,index:0},e.props?.dangerouslySetInnerHTML?.__html==null)for(let a of e.children)K(a,r);return v=c,r}oe()&&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 c in e.props||{})c==="children"||c==="key"||Q(i,c,e.props[c]);for(let c of e.children)Z(i,c,null,null);return r?n.replaceChild(i,r):n.appendChild(i),i}if(Me(e))return e;let t=document.createTextNode(String(e));return n.appendChild(t),t}function st(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(()=>{Q(e,t,r())});continue}}}export{Ct as _$createComponent,Qe as _$template,wt as _template,At as classList,Lt as delegateEvents,T as effect,Mt as hydrate,bt as insert,Nt as isHydrating,xt as mapArray,St as on,Q as setProp,Et as spread,Ye as svgTemplate,wt as template,ne as untrack};
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};
2
2
  //# sourceMappingURL=render.min.js.map