what-core 0.11.7 → 0.11.8

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.
package/src/render.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // No VDOM diffing — direct DOM manipulation with surgical signal-driven updates.
4
4
 
5
5
  import { effect, untrack, createRoot, _createItemScope, signal, memo, __DEV__ } from './reactive.js';
6
- import { createDOM, disposeTree, getCurrentComponent, getComponentStack, _setSelectValue } from './dom.js';
6
+ import { createDOM, disposeTree, getCurrentComponent, getComponentStack, addHydrationDisposer, addHydratedComponent, _setSelectValue, _isUnsafeAttr, _isEventProp, _installLazyChildren, _handleNavigationSignal } from './dom.js';
7
7
  export { effect, untrack };
8
8
  // Re-export memo for compiled output (branch memoization: the compiler emits
9
9
  // _$memo(() => cond) so conditional branches only re-create DOM when the
@@ -27,6 +27,21 @@ export function _setTextInsertHook(fn) {
27
27
  // Merges children into props and delegates to createDOM which calls createComponent.
28
28
 
29
29
  export function _$createComponent(Component, props, children) {
30
+ // Deferred children (compiled JSX): the compiler passes a zero-arg factory
31
+ // when children contain elements, so their DOM is not built before this
32
+ // component runs. Pass it along marked; createComponent decides how the
33
+ // component sees it. h() and the JSX runtime pass arrays and take the path
34
+ // below unchanged.
35
+ if (typeof children === 'function') {
36
+ const lazy = () => {
37
+ const kids = children();
38
+ return kids.length === 1 ? kids[0] : kids;
39
+ };
40
+ lazy._lazyChildren = true;
41
+ if (!props) props = {};
42
+ Object.defineProperty(props, '_$lazyChildren', { value: lazy, configurable: true });
43
+ return createDOM({ tag: Component, props, children: [], key: null, _vnode: true });
44
+ }
30
45
  if (children && children.length > 0) {
31
46
  const mergedChildren = children.length === 1 ? children[0] : children;
32
47
  // Mutate props in place when possible to avoid object spread allocation.
@@ -41,20 +56,6 @@ export function _$createComponent(Component, props, children) {
41
56
  return createDOM({ tag: Component, props: props || {}, children: children || [], key: null, _vnode: true });
42
57
  }
43
58
 
44
- // --- URL Sanitization for DOM attributes ---
45
- // Rejects javascript:, data:, vbscript: protocols (case-insensitive, trimmed).
46
-
47
- const URL_ATTRS = new Set(['href', 'src', 'action', 'formaction', 'formAction']);
48
-
49
- function isSafeUrl(url) {
50
- if (typeof url !== 'string') return true; // non-string values are not URL-injection risks
51
- const normalized = url.trim().replace(/[\s\x00-\x1f]/g, '').toLowerCase();
52
- if (normalized.startsWith('javascript:')) return false;
53
- if (normalized.startsWith('data:')) return false;
54
- if (normalized.startsWith('vbscript:')) return false;
55
- return true;
56
- }
57
-
58
59
  // --- template(html) ---
59
60
  // Pre-parse HTML string into a <template> element. Returns a factory function
60
61
  // that clones the DOM tree via cloneNode(true) — 2-5x faster than createElement chains.
@@ -176,6 +177,11 @@ export function insert(parent, child, marker) {
176
177
  return child(parent, marker || null);
177
178
  }
178
179
 
180
+ // Deferred component children: realize once, no reactive wrapper.
181
+ if (typeof child === 'function' && child._lazyChildren) {
182
+ return insert(parent, child(), marker);
183
+ }
184
+
179
185
  if (typeof child === 'function') {
180
186
  // Single-evaluation mount: child() is evaluated exactly ONCE at mount,
181
187
  // inside the effect (so signal reads are tracked). The first run decides
@@ -1285,14 +1291,15 @@ export function spread(el, props) {
1285
1291
  for (const key in props) {
1286
1292
  const value = props[key];
1287
1293
 
1288
- if (key.startsWith('on') && key.length > 2) {
1294
+ if (_isEventProp(key)) {
1289
1295
  // Event handler — direct assignment. Use $$name for delegated events.
1296
+ if (typeof value !== 'function') continue;
1290
1297
  const event = key.slice(2).toLowerCase();
1291
1298
  el.addEventListener(event, value);
1292
1299
  continue;
1293
1300
  }
1294
1301
 
1295
- if (typeof value === 'function' && !key.startsWith('on')) {
1302
+ if (typeof value === 'function' && !_isEventProp(key)) {
1296
1303
  // Reactive prop — create micro-effect. The disposer must be registered
1297
1304
  // on el._propEffects so disposeTree() (dom.js) tears it down when the
1298
1305
  // element unmounts; otherwise the effect keeps firing on signal writes
@@ -1347,7 +1354,7 @@ export function setProp(el, key, value) {
1347
1354
  // reactive getters. Wrap in an effect so the prop auto-updates. Track the
1348
1355
  // disposer on el._propEffects so disposeTree() tears it down on unmount —
1349
1356
  // mirrors the pattern in dom.js setProp / spread().
1350
- if (typeof value === 'function' && !key.startsWith('on')) {
1357
+ if (typeof value === 'function' && !_isEventProp(key)) {
1351
1358
  if (!el._propEffects) el._propEffects = {};
1352
1359
  if (el._propEffects[key]) {
1353
1360
  try { el._propEffects[key](); } catch (e) { /* already disposed */ }
@@ -1356,14 +1363,14 @@ export function setProp(el, key, value) {
1356
1363
  return;
1357
1364
  }
1358
1365
 
1359
- // Sanitize URL attributes — reject dangerous protocols
1360
- if (URL_ATTRS.has(key) || URL_ATTRS.has(key.toLowerCase())) {
1361
- if (!isSafeUrl(value)) {
1362
- if (typeof console !== 'undefined') {
1363
- console.warn(`[what] Blocked unsafe URL in "${key}" attribute: ${value}`);
1364
- }
1365
- return;
1366
+ if (_isEventProp(key)) return;
1367
+
1368
+ // Sanitize URL attributes: reject dangerous protocols and srcdoc
1369
+ if (_isUnsafeAttr(key, value)) {
1370
+ if (typeof console !== 'undefined') {
1371
+ console.warn(`[what] Blocked unsafe URL in "${key}" attribute:`, value);
1366
1372
  }
1373
+ return;
1367
1374
  }
1368
1375
 
1369
1376
  const isSvg = _hasSVGElement && el instanceof SVGElement;
@@ -1662,6 +1669,11 @@ function hydrateNode(vnode, parent) {
1662
1669
  return textNode;
1663
1670
  }
1664
1671
 
1672
+ // Deferred component children: realize once, then hydrate the result
1673
+ if (typeof vnode === 'function' && vnode._lazyChildren) {
1674
+ return hydrateNode(vnode(), parent);
1675
+ }
1676
+
1665
1677
  // Reactive function child — attach effect to existing node
1666
1678
  if (typeof vnode === 'function') {
1667
1679
  // Unwrap to get the initial value for hydration
@@ -1669,13 +1681,14 @@ function hydrateNode(vnode, parent) {
1669
1681
  let current = hydrateNode(initialValue, parent);
1670
1682
 
1671
1683
  // Set up reactive effect for future updates (normal rendering path)
1672
- effect(() => {
1684
+ const dispose = effect(() => {
1673
1685
  const value = vnode();
1674
1686
  // After hydration, this runs as normal insert
1675
1687
  if (!_isHydrating) {
1676
1688
  current = reconcileInsert(parent, value, current, null);
1677
1689
  }
1678
1690
  });
1691
+ addHydrationDisposer(current && current.nodeType ? current : parent, dispose);
1679
1692
  return current;
1680
1693
  }
1681
1694
 
@@ -1715,17 +1728,29 @@ function hydrateNode(vnode, parent) {
1715
1728
  componentStack.push(ctx);
1716
1729
 
1717
1730
  let result;
1731
+ let endChildrenPass = null;
1718
1732
  try {
1719
- const propsChildren = children.length === 0 ? undefined
1720
- : children.length === 1 ? children[0] : children;
1721
- result = Component({ ...props, children: propsChildren });
1733
+ // Same children protocol as createComponent: compiled JSX passes a
1734
+ // factory on _$lazyChildren rather than a built children array.
1735
+ const merged = { ...props };
1736
+ if (props._$lazyChildren) {
1737
+ endChildrenPass = _installLazyChildren(Component, merged, props._$lazyChildren);
1738
+ } else {
1739
+ merged.children = children.length === 0 ? props.children
1740
+ : children.length === 1 ? children[0] : children;
1741
+ }
1742
+ result = Component(merged);
1743
+ if (endChildrenPass) endChildrenPass();
1722
1744
  } catch (error) {
1723
1745
  componentStack.pop();
1724
- console.error('[what] Error in component during hydration:', Component.name || 'Anonymous', error);
1746
+ // Same classification as createComponent: a navigation signal carries
1747
+ // its own handler and is not a render failure.
1748
+ if (!_handleNavigationSignal(error)) {
1749
+ console.error('[what] Error in component during hydration:', Component.name || 'Anonymous', error);
1750
+ }
1725
1751
  return null;
1726
1752
  }
1727
1753
 
1728
- componentStack.pop();
1729
1754
  ctx.mounted = true;
1730
1755
 
1731
1756
  // Run onMount callbacks after hydration
@@ -1738,7 +1763,20 @@ function hydrateNode(vnode, parent) {
1738
1763
  });
1739
1764
  }
1740
1765
 
1741
- return hydrateNode(result, parent);
1766
+ // ctx stays on the stack while the result is hydrated so a child's
1767
+ // useContext / error-boundary lookup resolves to this component, matching
1768
+ // createComponent in dom.js.
1769
+ try {
1770
+ const node = hydrateNode(result, parent);
1771
+ // No comment markers exist on this path, so anchor the ctx to the node
1772
+ // the component produced (or to the parent when it produced none) —
1773
+ // otherwise disposeTree can never reach it and the ctx leaks.
1774
+ const first = Array.isArray(node) ? node[0] : node;
1775
+ addHydratedComponent(first && first.nodeType ? first : parent, ctx);
1776
+ return node;
1777
+ } finally {
1778
+ componentStack.pop();
1779
+ }
1742
1780
  }
1743
1781
 
1744
1782
  // Element — claim existing DOM element
@@ -1811,7 +1849,8 @@ function hydrateElementProps(el, props) {
1811
1849
  const value = props[key];
1812
1850
 
1813
1851
  // Event handlers — always attach (they don't exist in SSR HTML)
1814
- if (key.startsWith('on') && key.length > 2) {
1852
+ if (_isEventProp(key)) {
1853
+ if (typeof value !== 'function') continue;
1815
1854
  const event = key.slice(2).toLowerCase();
1816
1855
  el.addEventListener(event, value);
1817
1856
  continue;
@@ -1824,7 +1863,7 @@ function hydrateElementProps(el, props) {
1824
1863
  }
1825
1864
 
1826
1865
  // Reactive props — set up effects
1827
- if (typeof value === 'function' && !key.startsWith('on')) {
1866
+ if (typeof value === 'function' && !_isEventProp(key)) {
1828
1867
  if (key === 'class' || key === 'className') {
1829
1868
  effect(() => { el.className = value() || ''; });
1830
1869
  } else if (key === 'style' && typeof value() === 'object') {
@@ -1 +0,0 @@
1
- import{a as T}from"./chunk-O3SKPRTY.min.js";var u=typeof globalThis<"u"&&typeof globalThis.__WHAT_DEV__=="boolean"?globalThis.__WHAT_DEV__:import.meta&&import.meta.env?!!import.meta.env.DEV:(typeof process<"u"&&process.env,!1),d=null;function Me(e){u&&(d=e)}var _=null,w=null,E=null,P=!1,D=0,b=[],j=!1,q=Symbol("needs_upstream"),B=null;function S(e,t){let n=e,r=new Set,s=null,o=0;function c(f){u&&P&&console.warn("[what] Signal.set() called inside a computed function. This may cause infinite loops. Use effect() instead."+(t?` (signal: ${t})`:""));let l=typeof f=="function"?f(n):f;n===l||n!==n&&l!==l||(n=l,s=null,u&&d&&d.onSignalUpdate(i),r.size>0&&ee(r))}function i(f){if(arguments.length===0){let l=_;return l!==null&&(l!==s||l._epoch!==o)&&(s=l,o=l._epoch,r.add(l),l.deps.push(r)),n}c(f)}return i.set=c,i.peek=()=>n,i.subscribe=f=>v(()=>f(i())),i._signal=!0,u&&(i._subs=r,t&&(i._debugName=t)),u&&d&&d.onSignalCreate(i),i}function Ae(e){let t,n=!0,r=new Set,s=null,o=0,c=U(()=>{let f=P;u&&(P=!0);try{t=e(),n=!1}finally{u&&(P=f)}},!0);c._level=1,c._computed=!0,c._computedSubs=r,r._owner=c,c._markDirty=()=>{n=!0},c._isDirty=()=>n;function i(){let f=_;return f!==null&&(f!==s||f._epoch!==o)&&(s=f,o=f._epoch,r.add(f),f.deps.push(r)),n&&X(c),t}return c._onNotify=()=>{n=!0,s=null,r.size>0&&ee(r)},i._signal=!0,i.peek=()=>(n&&X(c),t),i}function X(e){if(B!==null)throw B.push(e),q;let t=[e];B=t;try{for(;t.length>0;){let n=t[t.length-1];if(!n._isDirty||!n._isDirty()){t.pop();continue}let r=!1,s=n.deps;for(let o=0;o<s.length;o++){let c=s[o]._owner;c&&c._computed&&c._isDirty&&c._isDirty()&&(t.push(c),r=!0)}if(!r)try{let o=n.deps.length;$(n),n.deps.length!==o&&H(n),t.pop()}catch(o){if(o===q)n._markDirty();else throw o}}}finally{B=null}}function H(e){let t=0,n=e.deps;for(let r=0;r<n.length;r++){let s=n[r]._owner;if(s){let o=s._level;o>t&&(t=o)}}e._level=t+1}var ge=()=>{};function v(e,t){let n=U(e);n._level=1;let r=_;_=n;try{let o=n.fn();typeof o=="function"&&(n._cleanup=o)}finally{_=r}if(H(n),t?.stable&&(n._stable=!0),n.deps.length===0&&n._cleanup===null)return n.disposed=!0,u&&d&&d.onEffectDispose(n),ge;let s=()=>Z(n);return w&&w.disposals.push(s),s}function Te(e){D++;try{e()}finally{D--,D===0&&G()}}function U(e,t){let n={fn:e,deps:[],lazy:t||!1,_onNotify:null,disposed:!1,_pending:!1,_stable:!1,_level:0,_computed:!1,_computedSubs:null,_isDirty:null,_markDirty:null,_cleanup:null,_epoch:0};return u&&d&&d.onEffectCreate(n),n}function $(e){if(e.disposed)return;if(e._stable){if(e._cleanup){try{e._cleanup()}catch(s){u&&console.warn("[what] Error in effect cleanup:",s)}e._cleanup=null}let r=_;_=null;try{let s=e.fn();typeof s=="function"&&(e._cleanup=s)}catch(s){d?.onError&&d.onError(s,{type:"effect",effect:e}),u&&console.warn("[what] Error in stable effect:",s)}finally{_=r}u&&d?.onEffectRun&&d.onEffectRun(e);return}let t=e.deps.length===1?e.deps[0]:null;if(Y(e),e._cleanup){try{e._cleanup()}catch(r){u&&d?.onError&&d.onError(r,{type:"effect-cleanup",effect:e}),u&&console.warn("[what] Error in effect cleanup:",r)}e._cleanup=null}let n=_;_=e;try{let r=e.fn();typeof r=="function"&&(e._cleanup=r)}catch(r){throw r===q||u&&d?.onError&&d.onError(r,{type:"effect",effect:e}),r}finally{_=n}t!==null&&e.deps.length===1&&e.deps[0]===t&&!e._cleanup&&!e._pending&&(e._stable=!0),u&&d?.onEffectRun&&d.onEffectRun(e)}function Z(e){if(e.disposed=!0,u&&d&&d.onEffectDispose(e),Y(e),e._cleanup){try{e._cleanup()}catch(t){u&&console.warn("[what] Error in effect cleanup on dispose:",t)}e._cleanup=null}}function Y(e){let t=e.deps;for(let n=0;n<t.length;n++)t[n].delete(e);t.length=0,e._epoch++}var F=0,L=null,M=0;function Q(e){if(!e.disposed){if(e._onNotify)e._onNotify();else if(!e._pending)if(D===0&&e._stable){let t=_;_=null;try{let n=e.fn();if(typeof n=="function"){if(e._cleanup)try{e._cleanup()}catch{}e._cleanup=n}}catch(n){u&&d?.onError&&d.onError(n,{type:"effect",effect:e}),u&&console.warn("[what] Error in stable effect:",n)}finally{_=t}}else{e._pending=!0;let t=e._level,n=b.length;n>0&&b[n-1]._level>t&&(j=!0),b.push(e)}}}function ee(e){if(F===0){F=1;try{for(let t of e)Q(t);if(M>0){let t=0;for(;t<M;){let n=L[t];L[t]=null,t++;for(let r of n)Q(r)}M=0}}finally{F=0}D===0&&b.length>0&&ye()}else L===null&&(L=[]),M>=L.length?L.push(e):L[M]=e,M++}var I=!1;function ye(){I||(I=!0,queueMicrotask(()=>{I=!1,G()}))}var R=!1;function G(){if(!R){R=!0;try{let e=0;for(;b.length>0&&e<25;){let t=b;b=[],t.length>1&&j&&t.sort((n,r)=>n._level-r._level),j=!1;for(let n=0;n<t.length;n++){let r=t[n];if(r._pending=!1,!r.disposed&&!r._onNotify){let s=r.deps.length;try{$(r)}catch(o){if(o===q)throw o;u&&d?.onError&&d.onError(o,{type:"effect",effect:r});try{console.error("[what] Uncaught error in effect during update:",o)}catch{}continue}!r._computed&&r.deps.length!==s&&H(r)}}e++}if(e>=25){if(u){let n=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: ${n.join(", ")}`)}else console.warn("[what] Possible infinite effect loop detected");for(let t=0;t<b.length;t++)b[t]._pending=!1;b.length=0}}finally{R=!1}}}function De(e){let t,n=new Set,r=U(()=>{let o=e();if(!Object.is(t,o)){t=o;for(let c of n)if(!c.disposed){if(c._onNotify)c._onNotify();else if(!c._pending){c._pending=!0;let i=c._level,f=b.length;f>0&&b[f-1]._level>i&&(j=!0),b.push(c)}}}});r._level=1,$(r),H(r),n._owner=r,w&&w.disposals.push(()=>Z(r));function s(){return _&&(n.add(_),_.deps.push(n)),t}return s._signal=!0,s.peek=()=>t,s}function Oe(){if(R){u&&console.warn("[what] flushSync() called during an active flush (e.g., inside a component render or effect). This is a no-op to prevent infinite loops. Move flushSync() to an event handler or onMount callback.");return}if(_){u&&console.warn("[what] flushSync() called during effect execution. This is a no-op to prevent infinite loops. Move flushSync() to an event handler or onMount callback.");return}I=!1,G()}function K(e){let t=_;_=null;try{return e()}finally{_=t}}function Be(){return E}function Pe(e,t){let n=E,r=w;E=e,w=e;try{return t()}finally{E=n,w=r}}function Ie(e){let t=w,n=E,r={disposals:[],owner:E,children:[],_disposed:!1};E&&E.children.push(r),w=r,E=r;try{return e(()=>{if(!r._disposed){r._disposed=!0;for(let o=r.children.length-1;o>=0;o--)J(r.children[o]);r.children.length=0;for(let o=r.disposals.length-1;o>=0;o--)r.disposals[o]();if(r.disposals.length=0,r.owner){let o=r.owner.children.indexOf(r);o>=0&&r.owner.children.splice(o,1)}}})}finally{w=t,E=n}}function J(e){if(!e._disposed){e._disposed=!0;for(let t=e.children.length-1;t>=0;t--)J(e.children[t]);e.children.length=0;for(let t=e.disposals.length-1;t>=0;t--)e.disposals[t]();e.disposals.length=0}}function Re(e){let t=w,n=E,r={disposals:[],owner:null,children:[],_disposed:!1};w=r,E=r;try{return e(()=>{if(!r._disposed){r._disposed=!0;for(let o=r.children.length-1;o>=0;o--)J(r.children[o]);r.children.length=0;for(let o=r.disposals.length-1;o>=0;o--)r.disposals[o]();r.disposals.length=0}})}finally{w=t,E=n}}function je(e){w&&w.disposals.push(e)}if(u&&typeof WeakRef<"u"){let t={signals:new Set,effects:new Set,components:[]};d={__isPreinstallBuffer:!0,onSignalCreate(n){t.signals.size<2e3&&t.signals.add(new WeakRef(n))},onSignalUpdate(){},onEffectCreate(n){t.effects.size<2e3&&t.effects.add(new WeakRef(n))},onEffectDispose(){},onEffectRun(){},onError(){},onComponentMount(n){t.components.length<2e3&&t.components.push(n)},onComponentUnmount(){},__buffer:t}}function qe(){if(!u)return{signals:[],effects:[],components:[]};let e={signals:[],effects:[],components:[]},t=typeof z<"u"?z:null;if(!t)return e;for(let n of t.signals){let r=n.deref?.();r&&e.signals.push(r)}for(let n of t.effects){let r=n.deref?.();r&&e.effects.push(r)}for(let n of t.components)e.components.push(n);return e}var z=null;u&&d?.__isPreinstallBuffer&&(z=d.__buffer);function $e(e,t){let n=function(s){return e(s)};return n.displayName=`Memo(${e.name||"Anonymous"})`,n}var te=null;function ne(e){te=e}function Ge(e){let t=null,n=null,r=null,s=new Set;function o(c){if(r)throw r;if(t)return T(t,c);throw n||(n=e().then(i=>{t=i.default||i,s.forEach(f=>f()),s.clear()}).catch(i=>{r=i})),n}return o.displayName="Lazy",o._lazy=!0,o._onLoad=c=>{t?c():s.add(c)},o}function Ke({fallback:e,children:t}){let n=S(!1),r=new Set;return{tag:"__suspense",props:{boundary:{_suspense:!0,onSuspend(o){n.set(!0),r.add(o),o.finally(()=>{r.delete(o),r.size===0&&n.set(!1)})}},fallback:e,loading:n},children:Array.isArray(t)?t:[t],_vnode:!0}}function Je({fallback:e,children:t,onError:n}){let r=S(null);return{tag:"__errorBoundary",props:{errorState:r,handleError:c=>{if(r.set(c),n)try{n(c)}catch(i){console.error("Error in onError handler:",i)}},fallback:e,reset:()=>r.set(null)},children:Array.isArray(t)?t:[t],_vnode:!0}}function re(e,t){let n=t||te?.();for(;n;){if(n._errorBoundary)return n._errorBoundary(e),!0;n=n._parentCtx}return!1}function Xe({when:e,fallback:t=null,children:n}){return()=>(typeof e=="function"?e():e)?n:t}function Qe({each:e,fallback:t=null,children:n}){let r=Array.isArray(n)?n[0]:n;return typeof r!="function"?(console.warn("[what] For: children must be a render function, e.g. <For each={items}>{(item) => ...}</For>"),t):()=>{let s=typeof e=="function"?e():e;return!s||s.length===0?t:s.map((o,c)=>{let i=r(o,c);return i&&typeof i=="object"&&i.key==null&&(o!=null&&typeof o=="object"?o.id!=null?i.key=o.id:o.key!=null&&(i.key=o.key):(typeof o=="string"||typeof o=="number")&&(i.key=o)),i})}}function Ze({fallback:e=null,children:t}){let n=Array.isArray(t)?t:[t];return()=>{for(let r of n)if(r&&r.tag===oe&&(typeof r.props.when=="function"?r.props.when():r.props.when))return r.children;return e}}function oe({when:e,children:t}){return{tag:oe,props:{when:e},children:t,_vnode:!0}}function Ye({component:e,mode:t,mediaQuery:n,...r}){let s=T("div",{"data-island":e.name||"Island","data-hydrate":t}),o=S(null),c=S(!1);function i(){c()||(c.set(!0),o.set(T(e,r)))}function f(p){switch(t){case"load":queueMicrotask(i);break;case"idle":typeof requestIdleCallback<"u"?requestIdleCallback(i):setTimeout(i,200);break;case"visible":{let a=new IntersectionObserver(h=>{h[0].isIntersecting&&(a.disconnect(),i())});a.observe(p);break}case"interaction":{let a=()=>{p.removeEventListener("click",a),p.removeEventListener("focus",a),p.removeEventListener("mouseenter",a),i()};p.addEventListener("click",a,{once:!0}),p.addEventListener("focus",a,{once:!0}),p.addEventListener("mouseenter",a,{once:!0});break}case"media":{if(!n){i();break}let a=window.matchMedia(n);if(a.matches)queueMicrotask(i);else{let h=()=>{a.matches&&(a.removeEventListener("change",h),i())};a.addEventListener("change",h)}break}default:queueMicrotask(i)}}let l=p=>{p&&f(p)};return T("div",{"data-island":e.name||"Island","data-hydrate":t,ref:l},c()?o():null)}var se=!1;function nt(e,t,n){return se||(se=!0,console.warn("[what] each() is deprecated. Use the <For> component or Array.map() instead.")),!e||e.length===0?[]:e.map((r,s)=>{let o=t(r,s);return n&&o&&typeof o=="object"&&(o.key=n(r,s)),o})}function rt(...e){let t=[];for(let n of e)if(n){if(typeof n=="string")t.push(n);else if(typeof n=="object")for(let[r,s]of Object.entries(n))s&&t.push(r)}return t.join(" ")}function ot(e){return typeof e=="string"?e:Object.entries(e).filter(([,t])=>t!=null&&t!=="").map(([t,n])=>`${Ce(t)}:${n}`).join(";")}function Ce(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function st(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}}function it(e,t){let n=0;return(...r)=>{let s=Date.now();s-n>=t&&(n=s,e(...r))}}var W=null;function ie(e){W=e}function ct(e){if(typeof window>"u")return S(!1);let t=window.matchMedia(e),n=S(t.matches),r=o=>n.set(o.matches);t.addEventListener("change",r);let s=W?.();return s&&(s._cleanupCallbacks=s._cleanupCallbacks||[],s._cleanupCallbacks.push(()=>t.removeEventListener("change",r))),n}function ft(e,t){let n;try{let i=localStorage.getItem(e);n=i!==null?JSON.parse(i):t}catch{n=t}let r=S(n),s=v(()=>{try{localStorage.setItem(e,JSON.stringify(r()))}catch(i){u&&console.warn("[what] localStorage write failed (quota exceeded?):",i)}}),o=null;typeof window<"u"&&(o=i=>{if(i.key===e&&i.newValue!==null)try{r.set(JSON.parse(i.newValue))}catch(f){u&&console.warn("[what] localStorage parse failed:",f)}},window.addEventListener("storage",o));let c=W?.();return c&&(c._cleanupCallbacks=c._cleanupCallbacks||[],c._cleanupCallbacks.push(()=>{s(),o&&window.removeEventListener("storage",o)})),r}function lt({target:e,children:t}){if(typeof document>"u")return null;let n=typeof e=="string"?document.querySelector(e):e;return n?{tag:"__portal",props:{container:n},children:Array.isArray(t)?t:[t],_vnode:!0}:null}function at(e,t){if(typeof document>"u")return;let n=s=>{let o=e.current||e;!o||o.contains(s.target)||t(s)};document.addEventListener("mousedown",n),document.addEventListener("touchstart",n);let r=W?.();r&&(r._cleanupCallbacks=r._cleanupCallbacks||[],r._cleanupCallbacks.push(()=>{document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n)}))}function ut(e,t){return{class:t?`${e}-enter ${e}-enter-active`:`${e}-leave ${e}-leave-active`}}var we=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"]),be="http://www.w3.org/2000/svg",le=new Set,V=new WeakMap;function Ee(e){return!e||typeof e!="object"?!1:typeof Node<"u"&&e instanceof Node?!0:typeof e.nodeType=="number"&&typeof e.nodeName=="string"}function ce(e){return!!e&&typeof e=="object"&&(e._vnode===!0||"tag"in e)}function fe(e){if(!e.disposed){if(e.disposed=!0,e.cleanups)for(let t of e.cleanups)try{t()}catch(n){console.error("[what] cleanup error:",n)}if(e.effects)for(let t of e.effects)try{t()}catch{}if(e.hooks){for(let t of e.hooks)if(t&&typeof t.cleanup=="function")try{t.cleanup()}catch(n){console.error("[what] hook cleanup error:",n)}}if(e._cleanupCallbacks)for(let t of e._cleanupCallbacks)try{t()}catch(n){console.error("[what] onCleanup error:",n)}u&&d?.onComponentUnmount&&d.onComponentUnmount(e),le.delete(e)}}function N(e){if(!e)return;if(e._componentCtx&&fe(e._componentCtx),e.nodeType===8){let n=V.get(e);n&&fe(n)}if(e._dispose)try{e._dispose()}catch{}if(e._propEffects)for(let n in e._propEffects)try{e._propEffects[n]()}catch{}let t=e.childNodes;if(t&&t.length>0)for(let n=0;n<t.length;n++)N(t[n])}function yt(e,t){typeof t=="string"&&(t=document.querySelector(t)),N(t),t.textContent="";let n=k(e,t);return n&&t.appendChild(n),()=>{N(t),t.textContent=""}}function k(e,t,n){if(e==null||e===!1||e===!0)return document.createComment("");if(typeof e=="string"||typeof e=="number")return document.createTextNode(String(e));if(Ee(e))return e;if(typeof e=="function"&&e._mapArray){let r=document.createDocumentFragment(),s=document.createComment("/list-frag");return r.appendChild(s),e(r,s),r}if(typeof e=="function"){let r=document.createComment("fn"),s=document.createComment("/fn"),o=[],c=document.createDocumentFragment();c.appendChild(r),c.appendChild(s);let i=v(()=>{let f=e(),l=f==null||f===!1||f===!0?[]:Array.isArray(f)?f:[f],p=s.parentNode;if(p){for(let a of o)N(a),a.parentNode===p&&p.removeChild(a);o=[];for(let a of l){let h=k(a,p,t?._isSvg);if(h)if(h.nodeType===11){let C=Array.from(h.childNodes);p.insertBefore(h,s);for(let y of C)o.push(y)}else p.insertBefore(h,s),o.push(h)}}});return r._dispose=i,s._dispose=i,c}if(Array.isArray(e)){let r=document.createDocumentFragment();for(let s of e){let o=k(s,t,n);o&&r.appendChild(o)}return r}return ce(e)&&typeof e.tag=="function"?xe(e,t,n):ce(e)&&typeof e.tag=="string"?e.tag==="__errorBoundary"?ue(e,t):e.tag==="__suspense"?pe(e,t):e.tag==="__portal"?de(e,t):ve(e,t,n):document.createTextNode(String(e))}var Se={get(e,t){if(t!=="_sig"&&!(t==="__proto__"||t==="constructor"||t==="prototype"))return e._sig()[t]},has(e,t){return t==="_sig"?!1:t in e._sig()},ownKeys(e){return Reflect.ownKeys(e._sig())},getOwnPropertyDescriptor(e,t){if(t==="_sig")return;let n=e._sig();if(t in n)return{value:n[t],writable:!1,enumerable:!0,configurable:!0}},set(e,t){return!1}},m=[];function ae(){return m[m.length-1]}ne(ae);ie(ae);function Ct(){return m}function xe(e,t,n){let{tag:r,props:s,children:o}=e;if(typeof r=="function"&&(r.prototype?.isReactComponent||r.prototype?.render)){let g=r;r=function(me){return new g(me).render()},r.displayName=g.displayName||g.name||"ClassComponent"}if(r==="__errorBoundary"||e.tag==="__errorBoundary")return ue(e,t);if(r==="__suspense"||e.tag==="__suspense")return pe(e,t);if(r==="__portal"||e.tag==="__portal")return de(e,t);let c=m[m.length-1]||null,i=null;if(c&&(i=c._errorBoundary||null,!i)){let g=c._parentCtx;for(;g;){if(g._errorBoundary){i=g._errorBoundary;break}g=g._parentCtx}}let f={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,Component:r,_parentCtx:c,_errorBoundary:i},l=document.createComment("c:start"),p=document.createComment("c:end");V.set(l,f),f._startComment=l,f._endComment=p;let a=document.createDocumentFragment();a._componentCtx=f,f._wrapper=l,le.add(f),u&&d?.onComponentMount&&d.onComponentMount(f);let h=o.length===0?void 0:o.length===1?o[0]:o,C;h!==void 0?C=s?Object.assign({},s,{children:h}):{children:h}:C=s?Object.assign({},s):{};let y=S(C);f._propsSignal=y;let x=new Proxy({_sig:y},Se);m.push(f);let O;try{O=K(()=>r(x))}catch(g){if(m.pop(),!re(g,f))throw console.error("[what] Uncaught error in component:",r.name||"Anonymous",g),g;return a.appendChild(l),a.appendChild(p),a}m.pop(),f.mounted=!0,f._mountCallbacks&&queueMicrotask(()=>{if(!f.disposed)for(let g of f._mountCallbacks)try{g()}catch(A){console.error("[what] onMount error:",A)}}),a.appendChild(l);let _e=Array.isArray(O)?O:[O];for(let g of _e){let A=k(g,a,n);A&&a.appendChild(A)}return a.appendChild(p),a}function ue(e,t){let{errorState:n,handleError:r,fallback:s,reset:o}=e.props,c=e.children,i=document.createComment("eb:start"),f=document.createComment("eb:end"),l={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,_parentCtx:m[m.length-1]||null,_errorBoundary:r,_startComment:i,_endComment:f};V.set(i,l);let p=document.createDocumentFragment();p._componentCtx=l,p.appendChild(i),p.appendChild(f);let a=v(()=>{let h=n();if(m.push(l),i.parentNode)for(;i.nextSibling&&i.nextSibling!==f;){let y=i.nextSibling;N(y),y.parentNode.removeChild(y)}let C;h?C=typeof s=="function"?[s({error:h,reset:o})]:[s]:C=c,C=Array.isArray(C)?C:[C];for(let y of C){let x=k(y,t);x&&(f.parentNode?f.parentNode.insertBefore(x,f):p.insertBefore(x,f))}m.pop()});return l.effects.push(a),p}function pe(e,t){let{boundary:n,fallback:r,loading:s}=e.props,o=e.children,c=document.createComment("sb:start"),i=document.createComment("sb:end"),f={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,_parentCtx:m[m.length-1]||null,_startComment:c,_endComment:i};V.set(c,f);let l=document.createDocumentFragment();l._componentCtx=f,l.appendChild(c),l.appendChild(i);let p=v(()=>{let h=s()?[r]:o,C=Array.isArray(h)?h:[h];if(m.push(f),c.parentNode)for(;c.nextSibling&&c.nextSibling!==i;){let y=c.nextSibling;N(y),y.parentNode.removeChild(y)}for(let y of C){let x=k(y,t);x&&(i.parentNode?i.parentNode.insertBefore(x,i):l.insertBefore(x,i))}m.pop()});return f.effects.push(p),l}function de(e,t){let{container:n}=e.props,r=e.children;if(!n)return console.warn("[what] Portal: target container not found"),document.createComment("portal:empty");let s={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,_parentCtx:m[m.length-1]||null},o=document.createComment("portal");o._componentCtx=s;let c=[];for(let i of r){let f=k(i,n);f&&(n.appendChild(f),c.push(f))}return s._cleanupCallbacks=[()=>{for(let i of c)N(i),i.parentNode&&i.parentNode.removeChild(i)}],o}function ve(e,t,n){let{tag:r,props:s,children:o}=e,c=n||we.has(r),i=c?document.createElementNS(be,r):document.createElement(r);s&&ke(i,s,{},c);let f=c&&r!=="foreignObject";for(let l=0;l<o.length;l++){let p=k(o[l],i,f);p&&i.appendChild(p)}return i._vnode=e,i}function ke(e,t,n,r){if(t){for(let s in t)if(!(s==="key"||s==="children")){if(s==="ref"){let o=t.ref;typeof o=="function"?o(e):o&&(o.current=e);continue}he(e,s,t[s],r)}}}function Le(e,t){e.value=t,e.value!==String(t)&&queueMicrotask(()=>{e.value=t})}function he(e,t,n,r){if(typeof n=="function"&&!(t.startsWith("on")&&t.length>2)&&t!=="ref"){if(e._propEffects||(e._propEffects={}),e._propEffects[t])try{e._propEffects[t]()}catch{}e._propEffects[t]=v(()=>{let s=n();he(e,t,s,r)});return}if(t.startsWith("on")&&t.length>2){let s=t.slice(2),o=!1;s.endsWith("Capture")&&(s=s.slice(0,-7),o=!0);let c=s.toLowerCase(),i=o?c+"_capture":c,f=e._events?.[i];if(f&&f._original===n||(f&&e.removeEventListener(c,f,o),n==null))return;e._events||(e._events={});let l=a=>(a.nativeEvent||(a.nativeEvent=a),K(()=>l._handler(a)));l._handler=n,l._original=n,e._events[i]=l;let p=n._eventOpts;e.addEventListener(c,l,p||o||void 0);return}if(t==="className"||t==="class"){r?e.setAttribute("class",n||""):e.className=n||"";return}if(t==="style"){if(typeof n=="string")e.style.cssText=n,e._prevStyle=null;else if(typeof n=="object"){let s=e._prevStyle||{};for(let o in s)o in n||(e.style[o]="");for(let o in n)e.style[o]=n[o]??"";e._prevStyle={...n}}return}if(t==="dangerouslySetInnerHTML"){let s=n?.__html??"";u&&typeof s=="string"&&/(<script|onerror\s*=|onload\s*=|javascript:)/i.test(s)&&console.warn("[what] dangerouslySetInnerHTML contains potential XSS vectors. Ensure content is sanitized."),e.innerHTML=s;return}if(t==="innerHTML"){if(n==null)return;if(n&&typeof n=="object"&&"__html"in n){let s=n.__html??"";u&&typeof s=="string"&&/(<script|onerror\s*=|onload\s*=|javascript:)/i.test(s)&&console.warn("[what] dangerouslySetInnerHTML contains potential XSS vectors. Ensure content is sanitized."),e.innerHTML=s}else{u&&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(n==null){if(t in e)try{e[t]=""}catch{}e.removeAttribute(t);return}if(typeof n=="boolean"){n?e.setAttribute(t,""):e.removeAttribute(t);return}if(t.startsWith("data-")||t.startsWith("aria-")){e.setAttribute(t,n);return}if(r){n===!1||n==null?e.removeAttribute(t):e.setAttribute(t,n===!0?"":String(n));return}if(t==="value"&&e.tagName==="SELECT"){Le(e,n);return}t in e?e[t]=n:e.setAttribute(t,n)}export{u as a,Me as b,S as c,Ae as d,v as e,Te as f,De as g,Oe as h,K as i,Be as j,Pe as k,Ie as l,Re as m,je as n,qe as o,$e as p,Ge as q,Ke as r,Je as s,Xe as t,Qe as u,Ze as v,oe as w,Ye as x,nt as y,rt as z,ot as A,st as B,it as C,ct as D,ft as E,lt as F,at as G,ut as H,N as I,yt as J,k as K,ae as L,Ct as M,Le as N};
@@ -1 +0,0 @@
1
- import{I as W,K as et,M as ht,N as ft,a as R,c as tt,e as $,m as q}from"./chunk-5QCEMXNL.min.js";var Z=null;function Zt(t){Z=typeof t=="function"?t:null}function Jt(t,n,e){if(e&&e.length>0){let i=e.length===1?e[0]:e;n?n.children=i:n={children:i}}return et({tag:t,props:n||{},children:e||[],key:null,_vnode:!0})}var gt=new Set(["href","src","action","formaction","formAction"]);function Tt(t){if(typeof t!="string")return!0;let n=t.trim().replace(/[\s\x00-\x1f]/g,"").toLowerCase();return!(n.startsWith("javascript:")||n.startsWith("data:")||n.startsWith("vbscript:"))}var wt={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>"}},Et=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 xt(t){let n=t.match(/^<([a-zA-Z][a-zA-Z0-9]*)/);return n?n[1]:""}function Lt(t){let n=t.trim(),e=xt(n);if(Et.has(e))return St(n);let i=wt[e];if(i){let r=document.createElement("template");r.innerHTML=i.wrap+n+i.unwrap;let y=r.content.firstChild;for(let c=0;c<i.depth;c++)y=y.firstChild;return()=>y.cloneNode(!0)}let o=document.createElement("template");return o.innerHTML=n,()=>o.content.firstChild.cloneNode(!0)}var dt=!1;function Qt(t){return R&&!dt&&(dt=!0,console.warn("[what] template() is a compiler internal. Use JSX instead. Direct calls with user input can lead to XSS vulnerabilities.")),Lt(t)}function St(t){let n=t.trim();if(xt(n)==="svg"){let o=document.createElement("template");return o.innerHTML=n,()=>o.content.firstChild.cloneNode(!0)}let i=document.createElement("template");return i.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg">${n}</svg>`,()=>i.content.firstChild.firstChild.cloneNode(!0)}function Yt(t,n,e){if(typeof n=="function"&&n._mapArray)return n(t,e||null);if(typeof n=="function"){let i=e||null,o=null,r=null,y=!1;return $(()=>{let c=n(),h=typeof c;if(!y){y=!0,h==="string"||h==="number"?(r=document.createTextNode(String(c)),i?t.insertBefore(r,i):t.appendChild(r),Z&&Z(t,String(c)),o=r):o=Q(t,c,null,i);return}if(r!==null&&(h==="string"||h==="number")){let l=String(c);r.data!==l&&(r.data=l),Z&&Z(t,l);return}r=null,o=Q(t,c,o,i)}),o}if(typeof n=="string"||typeof n=="number"){let i=document.createTextNode(String(n));return e?t.insertBefore(i,e):t.appendChild(i),i}return n!=null&&typeof n=="object"&&n.nodeType>0?(e?t.insertBefore(n,e):t.appendChild(n),n):Q(t,n,null,e||null)}function _t(t){return!t||typeof t!="object"?!1:typeof Node<"u"&&t instanceof Node?!0:typeof t.nodeType=="number"&&typeof t.nodeName=="string"}function Mt(t){return!!t&&typeof t=="object"&&(t._vnode===!0||"tag"in t)}var it=typeof SVGElement<"u";function yt(t){return it&&t instanceof SVGElement&&t.tagName!=="foreignObject"}function bt(t){return t==null?[]:Array.isArray(t)?t:[t]}function Ct(t,n,e){if(t==null||typeof t=="boolean")return e;if(Array.isArray(t)){for(let i=0;i<t.length;i++)Ct(t[i],n,e);return e}if(typeof t=="function"){let i=et(t,n,yt(n));if(i&&i.nodeType===11){let o=Array.from(i.childNodes);for(let r=0;r<o.length;r++)e.push(o[r])}else i&&e.push(i);return e}if(typeof t=="string"||typeof t=="number")return e.push(document.createTextNode(String(t))),e;if(_t(t)){if(t.nodeType===11&&t.childNodes.length>0){let i=Array.from(t.childNodes);for(let o=0;o<i.length;o++)e.push(i[o])}else e.push(t);return e}if(Mt(t)){let i=et(t,n,yt(n));if(i&&i.nodeType===11)if(i.childNodes.length===0)e.push(i);else{let o=Array.from(i.childNodes);for(let r=0;r<o.length;r++)e.push(o[r])}else i&&e.push(i);return e}return e.push(document.createTextNode(String(t))),e}function jt(t,n){if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}function Q(t,n,e,i){if(!t||typeof t.insertBefore!="function")return R&&console.warn("[what] reconcileInsert called with invalid parent:",t),e;let o=i||null;if(n==null||typeof n=="boolean"){let l=bt(e);for(let d=0;d<l.length;d++){let s=l[d];s.parentNode===t&&(W(s),t.removeChild(s))}return null}if((typeof n=="string"||typeof n=="number")&&e&&!Array.isArray(e)&&e.nodeType===3){let l=String(n);return e.data!==l&&(e.data=l),e}if(typeof n=="object"&&n!==null&&n.nodeType>0&&n.nodeType!==11&&!Array.isArray(n)){if(n===e)return e;if(e&&!Array.isArray(e)&&e.nodeType>0&&e.nodeType!==11)return e.parentNode===t?(W(e),t.replaceChild(n,e)):o?t.insertBefore(n,o):t.appendChild(n),n}let r=Ct(n,t,[]),y=bt(e);if(jt(y,r))return e;let c=r.length;for(let l=0;l<y.length;l++){let d=y[l];if(d.parentNode!==t)continue;let s=!1;for(let x=0;x<c;x++)if(r[x]===d){s=!0;break}s||(W(d),t.removeChild(d))}let h=o;for(let l=r.length-1;l>=0;l--){let d=r[l];(d.parentNode!==t||d.nextSibling!==h)&&(h&&h.parentNode!==t&&(h=null),h?t.insertBefore(d,h):t.appendChild(d)),h=d}return r.length===0?null:r.length===1?r[0]:r}function It(t,n,e){let i=e?.key,o=e?.raw||!1,r=(y,c)=>{let h=[],l=[],d=[],s=i&&!o?new Map:null,x=document.createComment("/list");return y.insertBefore(x,c||null),$(()=>{let m=t()||[],b=x.parentNode||y;i?Dt(b,x,h,m,l,d,n,i,s):Bt(b,x,h,m,l,d,n),h=m.length>0?m.slice():m}),x};return r._mapArray=!0,r}function Bt(t,n,e,i,o,r,y){let c=i.length,h=e.length;if(c===0){if(h>0){for(let u=0;u<h;u++)r[u]&&r[u]();for(let u=h-1;u>=0;u--){let a=o[u];a&&(W(a),a.parentNode===t&&t.removeChild(a))}o.length=0,r.length=0}return}if(h===0){let u=document.createDocumentFragment();for(let a=0;a<c;a++){let w=i[a],L=q(O=>(r[a]=O,y(w,a)));o[a]=L,u.appendChild(L)}t.insertBefore(u,n);return}let l=0,d=Math.min(h,c);for(;l<d&&e[l]===i[l];)l++;if(l===h&&l===c)return;let s=h-1,x=c-1;for(;s>=l&&x>=l&&e[s]===i[x];)s--,x--;let m=new Array(c),b=new Array(c);for(let u=0;u<l;u++)m[u]=o[u],b[u]=r[u];for(let u=x+1;u<c;u++){let a=s+1+(u-x-1);m[u]=o[a],b[u]=r[a]}let _=x-l+1,T=s-l+1;if(_===0)for(let u=l;u<=s;u++)r[u]?.(),o[u]&&W(o[u]),o[u]?.parentNode&&o[u].parentNode.removeChild(o[u]);else if(T===0){let u=l<c&&m[x+1]?m[x+1]:n,a=document.createDocumentFragment();for(let w=l;w<=x;w++){let L=i[w],O=w;m[w]=q(S=>(b[O]=S,y(L,O))),a.appendChild(m[w])}t.insertBefore(a,u)}else Ht(t,n,e,i,o,r,y,l,s,x,m,b);o.length=c,r.length=c;for(let u=0;u<c;u++)o[u]=m[u],r[u]=b[u]}function Ht(t,n,e,i,o,r,y,c,h,l,d,s){let x=new Map;for(let a=c;a<=h;a++)x.set(e[a],a);let m=l-c+1,b=new Int32Array(m);b.fill(-1);for(let a=c;a<=l;a++){let w=x.get(i[a]);w!==void 0&&(x.delete(i[a]),d[a]=o[w],s[a]=r[w],b[a-c]=w)}for(let[,a]of x)r[a]?.(),o[a]&&W(o[a]),o[a]?.parentNode&&o[a].parentNode.removeChild(o[a]);let _=m-Nt(b,m),T=new Uint8Array(m);if(_>1){let a=new Int32Array(_),w=new Int32Array(_),L=0;for(let S=0;S<m;S++)b[S]!==-1&&(a[L]=b[S],w[L]=S,L++);let O=At(a,_);for(let S=0;S<O.length;S++)T[w[O[S]]]=1}else if(_===1){for(let a=0;a<m;a++)if(b[a]!==-1){T[a]=1;break}}for(let a=c;a<=l;a++)if(!d[a]){let w=i[a],L=a;d[a]=q(O=>(s[L]=O,y(w,L)))}let u=l+1<d.length&&d[l+1]?d[l+1]:n;for(let a=l;a>=c;a--){let w=a-c;(b[w]===-1||!T[w])&&(u&&u.parentNode!==t&&(u=n),t.insertBefore(d[a],u)),u=d[a]}}function Nt(t,n){let e=0;for(let i=0;i<n;i++)t[i]===-1&&e++;return e}function At(t,n){if(n===0)return[];if(n===1)return[0];let e=new Int32Array(n),i=new Int32Array(n),o=1;e[0]=0,i[0]=-1;for(let c=1;c<n;c++)if(t[c]>t[e[o-1]])i[c]=e[o-1],e[o++]=c;else{let h=0,l=o-1;for(;h<l;){let d=h+l>>1;t[e[d]]<t[c]?h=d+1:l=d}e[h]=c,i[c]=h>0?e[h-1]:-1}let r=new Array(o),y=e[o-1];for(let c=o-1;c>=0;c--)r[c]=y,y=i[y];return r}function $t(){return document.createComment("i")}function z(t,n,e,i){let o=n;for(;o&&o!==e;){let r=o.nextSibling;t.insertBefore(o,i),o=r}}function ct(t,n,e){let i=n;for(;i&&i!==e;){let o=i.nextSibling;W(i),t.removeChild(i),i=o}}function lt(t,n,e,i,o,r,y,c,h){let l;if(o){let x=i(n),m=h(n);l=m,o.set(x,{itemSig:m})}else l=n;let d=$t();t.appendChild(d);let s=q(x=>(c[e]=x,r(l,e)));t.appendChild(s),y[e]=d}function Dt(t,n,e,i,o,r,y,c,h){let l=i.length,d=e.length;if(l===0){if(d>0){for(let f=0;f<d;f++)r[f]&&r[f]();o[0]&&ct(t,o[0],n),o.length=0,r.length=0,h&&h.clear()}return}if(d===0){let f=document.createDocumentFragment();for(let C=0;C<l;C++)lt(f,i[C],C,c,h,y,o,r,tt);t.insertBefore(f,n);return}let s=0,x=Math.min(d,l);for(;s<x;){if(e[s]===i[s]){s++;continue}let f=c(e[s]),C=c(i[s]);if(f!==C)break;h&&h.get(f).itemSig.set(i[s]),s++}let m=d-1,b=l-1;for(;m>=s&&b>=s;){if(e[m]===i[b]){m--,b--;continue}let f=c(e[m]),C=c(i[b]);if(f!==C)break;h&&h.get(f).itemSig.set(i[b]),m--,b--}if(s>m&&s>b)return;let _=new Array(l),T=new Array(l);for(let f=0;f<s;f++)_[f]=o[f],T[f]=r[f];for(let f=b+1;f<l;f++){let C=m+1+(f-b-1);_[f]=o[C],T[f]=r[C]}let u=b-s+1,a=m-s+1;if(a===0){let f=b+1<l&&_[b+1]?_[b+1]:n,C=document.createDocumentFragment();for(let E=s;E<=b;E++)lt(C,i[E],E,c,h,y,_,T,tt);t.insertBefore(C,f),X(o,r,_,T,l);return}if(u===0){for(let f=s;f<=m;f++){r[f]?.();let C=G(t,o[f],o,f,n);ct(t,o[f],C),h&&h.delete(c(e[f]))}X(o,r,_,T,l);return}if(u===a&&u>=2&&u<=Math.max(a,200)){let f=0,C=-1,E=-1;for(let p=0;p<u&&f<=4;p++){let A=c(e[s+p]),D=c(i[s+p]);A!==D&&(f===0?C=p:f===1&&(E=p),f++)}if(f===2){let p=s+C,A=s+E,D=c(e[p]),K=c(e[A]),U=c(i[p]),v=c(i[A]);if(D===v&&K===U){for(let g=0;g<s;g++)_[g]=o[g],T[g]=r[g];for(let g=s;g<=b;g++)_[g]=o[g],T[g]=r[g];for(let g=b+1;g<l;g++){let N=m+1+(g-b-1);_[g]=o[N],T[g]=r[N]}let P=_[p];_[p]=_[A],_[A]=P;let B=T[p];if(T[p]=T[A],T[A]=B,h){if(i[p]!==e[p]){let g=c(i[p]),N=h.get(g);N&&N.itemSig.set(i[p])}if(i[A]!==e[A]){let g=c(i[A]),N=h.get(g);N&&N.itemSig.set(i[A])}}let j=A===p+1||p===A+1,H=Math.min(p,A),M=Math.max(p,A);if(j){let g=G(t,o[M],o,M,n);z(t,o[M],g,o[H])}else{let g=G(t,o[A],o,A,n),N=document.createComment("tmp");t.insertBefore(N,o[A]),z(t,o[A],g,o[p]);let F=G(t,o[p],o,p,n);z(t,o[p],F,N),t.removeChild(N)}X(o,r,_,T,l);return}}if(f>=2&&f<=u){let p=C,A=null,D=-1,K=-1,U=!1,v=c(e[s+p]),P=-1;for(let B=p;B<u;B++)if(c(i[s+B])===v){P=B;break}if(P>p){let B=!0;for(let j=p;j<P;j++)if(c(e[s+j+1])!==c(i[s+j])){B=!1;break}if(B){let j=!0;for(let H=P+1;H<u;H++)if(c(e[s+H])!==c(i[s+H])){j=!1;break}j&&(U=!0,D=s+p,K=s+P,A=v)}}if(!U){let B=c(i[s+p]),j=-1;for(let H=p;H<a;H++)if(c(e[s+H])===B){j=H;break}if(j>p){let H=!0;for(let M=p;M<j;M++)if(c(e[s+M])!==c(i[s+M+1])){H=!1;break}if(H){let M=!0;for(let g=j+1;g<u;g++)if(c(e[s+g])!==c(i[s+g])){M=!1;break}M&&(U=!0,D=s+j,K=s+p,A=B)}}}if(U){for(let g=s;g<=m;g++)_[g]=o[g],T[g]=r[g];let B=_[D],j=T[D];if(D<K)for(let g=D;g<K;g++)_[g]=_[g+1],T[g]=T[g+1];else for(let g=D;g>K;g--)_[g]=_[g-1],T[g]=T[g-1];if(_[K]=B,T[K]=j,h)for(let g=s;g<=b;g++){let N=c(i[g]);if(i[g]!==e[g]){let F=h.get(N);F&&F.itemSig.set(i[g])}}let H=G(t,B,o,D,n),M;K+1<l?M=_[K+1]:M=n,(K>=b+1||M&&M.parentNode!==t)&&(M=n),z(t,B,H,M),X(o,r,_,T,l);return}}}let w=new Map;for(let f=s;f<=m;f++)w.set(c(e[f]),f);let L=new Int32Array(u);L.fill(-1);for(let f=s;f<=b;f++){let C=c(i[f]),E=w.get(C);E!==void 0&&(w.delete(C),_[f]=o[E],T[f]=r[E],L[f-s]=E,h&&i[f]!==e[E]&&h.get(C).itemSig.set(i[f]))}let O=[...w.values()].sort((f,C)=>C-f);for(let f of O){r[f]?.();let C=G(t,o[f],o,f,n);ct(t,o[f],C),h&&h.delete(c(e[f]))}for(let f=s;f<=b;f++)if(!_[f]){let C=document.createDocumentFragment();lt(C,i[f],f,c,h,y,_,T,tt),_[f]._frag=C}let S=0,ut=!0,at=-1;for(let f=0;f<u;f++)L[f]!==-1&&(S++,L[f]<=at&&(ut=!1),at=L[f]);let k=new Uint8Array(u);if(ut)for(let f=0;f<u;f++)L[f]!==-1&&(k[f]=1);else if(S>1){let f=new Int32Array(S),C=new Int32Array(S),E=0;for(let A=0;A<u;A++)L[A]!==-1&&(f[E]=L[A],C[E]=A,E++);let p=At(f,S);for(let A=0;A<p.length;A++)k[C[p[A]]]=1}else if(S===1){for(let f=0;f<u;f++)if(L[f]!==-1){k[f]=1;break}}X(o,r,_,T,l);let rt=b+1<l&&o[b+1]?o[b+1]:n;for(let f=b;f>=s;f--){let C=f-s,E=o[f];if(L[C]===-1)E._frag&&(t.insertBefore(E._frag,rt),delete E._frag);else if(!k[C]){let p=G(t,E,o,f,n);z(t,E,p,rt)}rt=E}}function G(t,n,e,i,o){let r=n.nextSibling;for(;r&&r!==o;){if(r.nodeType===8&&r.data==="i")return r;r=r.nextSibling}return o}function X(t,n,e,i,o){t.length=o,n.length=o;for(let r=0;r<o;r++)t[r]=e[r],n[r]=i[r]}function kt(t,n){for(let e in n){let i=n[e];if(e.startsWith("on")&&e.length>2){let o=e.slice(2).toLowerCase();t.addEventListener(o,i);continue}if(typeof i=="function"&&!e.startsWith("on")){if(t._propEffects||(t._propEffects={}),t._propEffects[e])try{t._propEffects[e]()}catch{}e==="class"||e==="className"?t._propEffects[e]=$(()=>{let o=i()||"";it&&t instanceof SVGElement?t.setAttribute("class",o):t.className=o}):e==="style"&&typeof i()=="object"?t._propEffects[e]=$(()=>{ot(t,i())}):t._propEffects[e]=$(()=>{Y(t,e,i())})}else Y(t,e,i)}}function Y(t,n,e){if(n==="ref"){typeof e=="function"?e(t):e&&typeof e=="object"&&(e.current=t);return}if(n==="key")return;if(typeof e=="function"&&!n.startsWith("on")){if(t._propEffects||(t._propEffects={}),t._propEffects[n])try{t._propEffects[n]()}catch{}t._propEffects[n]=$(()=>Y(t,n,e()));return}if((gt.has(n)||gt.has(n.toLowerCase()))&&!Tt(e)){typeof console<"u"&&console.warn(`[what] Blocked unsafe URL in "${n}" attribute: ${e}`);return}let i=it&&t instanceof SVGElement;if(n==="class"||n==="className")i?t.setAttribute("class",e||""):t.className=e||"";else if(n==="dangerouslySetInnerHTML"){let o=e?.__html??"";typeof R<"u"&&R&&typeof o=="string"&&/(<script|onerror\s*=|onload\s*=|javascript:)/i.test(o)&&console.warn("[what] dangerouslySetInnerHTML contains potential XSS vectors. Ensure content is sanitized."),t.innerHTML=o}else if(n==="innerHTML")if(e&&typeof e=="object"&&"__html"in e){let o=e.__html??"";typeof R<"u"&&R&&typeof o=="string"&&/(<script|onerror\s*=|onload\s*=|javascript:)/i.test(o)&&console.warn("[what] dangerouslySetInnerHTML contains potential XSS vectors. Ensure content is sanitized."),t.innerHTML=o}else typeof console<"u"&&e!=null&&e!==""&&console.warn('[what] Plain string innerHTML is not allowed. Use { __html: "..." } or dangerouslySetInnerHTML={{ __html: "..." }} instead.');else if(n==="style")ot(t,e);else if(e==null){if(n in t)try{t[n]=""}catch{}t.removeAttribute(n)}else n.startsWith("data-")||n.startsWith("aria-")?t.setAttribute(n,e):typeof e=="boolean"?e?t.setAttribute(n,""):t.removeAttribute(n):i?t.setAttribute(n,e):n==="value"&&t.tagName==="SELECT"?ft(t,e):n in t?t[n]=e:t.setAttribute(n,e)}function I(t,n,e,i){if(t._propEffects||(t._propEffects={}),t._propEffects[n])try{t._propEffects[n]()}catch{}t._propEffects[n]=$(()=>i(t,e()))}function Kt(t,n){if(typeof n=="function")return I(t,"class",n,Kt);it&&t instanceof SVGElement?t.setAttribute("class",n||""):t.className=n||""}function ot(t,n){if(typeof n=="function")return I(t,"style",n,ot);if(typeof n=="string")t.style.cssText=n,t._lastStyleObj=null;else if(n&&typeof n=="object"){let e=t.style,i=t._lastStyleObj;if(i)for(let o in i)o in n||(e[o]="");for(let o in n)e[o]=n[o]??"";t._lastStyleObj=n}else n==null&&(t.style.cssText="",t._lastStyleObj=null)}function Ot(t,n,e){if(typeof e=="function")return I(t,n,e,(i,o)=>Ot(i,n,o));e==null?t.removeAttribute(n):t.setAttribute(n,e)}function Vt(t,n){if(typeof n=="function")return I(t,"value",n,Vt);if(t.tagName==="SELECT"){ft(t,n);return}let e=n==null?"":String(n);t.value!==e&&(t.value=e)}function Wt(t,n){if(typeof n=="function")return I(t,"checked",n,Wt);t.checked=!!n}var pt=new Set;function vt(t){for(let n of t)pt.has(n)||(pt.add(n),document.addEventListener(n,e=>{let i=e.target,o="$$"+n;for(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return i||document}});i;){let r=i[o];if(r&&(r(e),e.cancelBubble))return;i=i.parentNode}}))}function Ft(t,n,e){return t.addEventListener(n,e),()=>t.removeEventListener(n,e)}function te(t,n){$(()=>{for(let e in n){let i=typeof n[e]=="function"?n[e]():n[e];t.classList.toggle(e,!!i)}})}var nt=!1,V=null;function ee(){return nt}function ne(t,n){nt=!0,V={parent:n,index:0};try{return J(t,n)}finally{nt=!1,V=null}}function mt(t){let n=t.childNodes;for(;V.index<n.length;){let e=n[V.index];if(e.nodeType===8){let i=e.textContent;if(i==="$"||i==="/$"||i==="[]"||i==="/[]"){V.index++;continue}}return V.index++,e}return null}function st(){return typeof process<"u"&&!1}function J(t,n){if(t==null||typeof t=="boolean")return null;if(typeof t=="string"||typeof t=="number"){let i=mt(n),o=String(t);if(i&&i.nodeType===3)return st()&&i.textContent!==o&&(console.warn(`[what] Hydration mismatch: expected text "${o}", got "${i.textContent}"`),i.textContent=o),i;st()&&console.warn(`[what] Hydration mismatch: expected text node "${o}", got ${i?i.nodeName:"nothing"}. Falling back to client render.`);let r=document.createTextNode(o);return i?n.replaceChild(r,i):n.appendChild(r),r}if(typeof t=="function"){let i=t(),o=J(i,n);return $(()=>{let r=t();nt||(o=Q(n,r,o,null))}),o}if(Array.isArray(t)){let i=[];for(let o of t){let r=J(o,n);r&&i.push(r)}return i.length===1?i[0]:i}if(typeof t=="object"&&t._vnode){if(typeof t.tag=="function"){let y=ht(),c=t.tag,h=t.props||{},l=t.children||[],d={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,Component:c,_parentCtx:y[y.length-1]||null,_errorBoundary:null};y.push(d);let s;try{let x=l.length===0?void 0:l.length===1?l[0]:l;s=c({...h,children:x})}catch(x){return y.pop(),console.error("[what] Error in component during hydration:",c.name||"Anonymous",x),null}return y.pop(),d.mounted=!0,d._mountCallbacks&&queueMicrotask(()=>{if(!d.disposed)for(let x of d._mountCallbacks)try{x()}catch(m){console.error("[what] onMount error:",m)}}),J(s,n)}let i=mt(n),o=t.tag.toUpperCase();if(i&&i.nodeType===1&&i.nodeName===o){Pt(i,t.props||{});let y=V;if(V={parent:i,index:0},t.props?.dangerouslySetInnerHTML?.__html==null)for(let h of t.children)J(h,i);return V=y,i}st()&&console.warn(`[what] Hydration mismatch: expected <${t.tag}>, got ${i?i.nodeName:"nothing"}. Falling back to client render.`);let r=document.createElement(t.tag);for(let y in t.props||{})y==="children"||y==="key"||Y(r,y,t.props[y]);for(let y of t.children)Q(r,y,null,null);return i?n.replaceChild(r,i):n.appendChild(r),r}if(_t(t))return t;let e=document.createTextNode(String(t));return n.appendChild(e),e}function Pt(t,n){for(let e in n){if(e==="children"||e==="key"||e==="ref"||e==="dangerouslySetInnerHTML"||e==="innerHTML")continue;let i=n[e];if(e.startsWith("on")&&e.length>2){let o=e.slice(2).toLowerCase();t.addEventListener(o,i);continue}if(e.startsWith("$$")){t[e]=i;continue}if(typeof i=="function"&&!e.startsWith("on")){e==="class"||e==="className"?$(()=>{t.className=i()||""}):e==="style"&&typeof i()=="object"?$(()=>{ot(t,i())}):$(()=>{Y(t,e,i())});continue}}}export{Zt as a,Jt as b,Lt as c,Qt as d,St as e,Yt as f,It as g,kt as h,Y as i,Kt as j,ot as k,Ot as l,Vt as m,Wt as n,vt as o,Ft as p,te as q,ee as r,ne as s};