@fluixi/dom 1.0.0-alpha.82 → 1.0.0-alpha.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/dist/cdn/dom-client.cjs +1427 -1
  2. package/dist/cdn/dom-client.d.ts +2 -2
  3. package/dist/cdn/dom-client.global.js +2 -1
  4. package/dist/cdn/dom-client.js +3 -3
  5. package/dist/cdn/dom-client.mjs +1430 -1
  6. package/dist/cdn/dom.cjs +3127 -1
  7. package/dist/cdn/dom.d.ts +2 -2
  8. package/dist/cdn/dom.global.js +2 -1
  9. package/dist/cdn/dom.js +4 -4
  10. package/dist/cdn/dom.mjs +3133 -1
  11. package/dist/index.cjs +3155 -1
  12. package/dist/index.js +2 -2
  13. package/dist/index.mjs +3149 -1
  14. package/dist/lib/component/index.cjs +128 -1
  15. package/dist/lib/component/index.mjs +105 -1
  16. package/dist/lib/component/modifiers.cjs +126 -1
  17. package/dist/lib/component/modifiers.d.ts +12 -0
  18. package/dist/lib/component/modifiers.d.ts.map +1 -1
  19. package/dist/lib/component/modifiers.js +12 -84
  20. package/dist/lib/component/modifiers.mjs +105 -1
  21. package/dist/lib/dom/delegate.cjs +60 -1
  22. package/dist/lib/dom/delegate.js +1 -1
  23. package/dist/lib/dom/delegate.mjs +39 -1
  24. package/dist/lib/dom/dynamic-element.cjs +949 -1
  25. package/dist/lib/dom/dynamic-element.d.ts +3 -3
  26. package/dist/lib/dom/dynamic-element.js +3 -3
  27. package/dist/lib/dom/dynamic-element.mjs +928 -1
  28. package/dist/lib/dom/hydration-state.cjs +93 -1
  29. package/dist/lib/dom/hydration-state.d.ts +1 -1
  30. package/dist/lib/dom/hydration-state.js +1 -1
  31. package/dist/lib/dom/hydration-state.mjs +72 -1
  32. package/dist/lib/dom/hydration.cjs +685 -1
  33. package/dist/lib/dom/hydration.js +8 -8
  34. package/dist/lib/dom/hydration.mjs +664 -1
  35. package/dist/lib/dom/index.cjs +2040 -1
  36. package/dist/lib/dom/index.js +1 -1
  37. package/dist/lib/dom/index.mjs +2020 -1
  38. package/dist/lib/dom/integration.cjs +71 -1
  39. package/dist/lib/dom/integration.d.ts.map +1 -1
  40. package/dist/lib/dom/integration.js +15 -6
  41. package/dist/lib/dom/integration.mjs +51 -1
  42. package/dist/lib/dom/island.cjs +790 -1
  43. package/dist/lib/dom/island.d.ts +1 -1
  44. package/dist/lib/dom/island.js +12 -12
  45. package/dist/lib/dom/island.mjs +769 -1
  46. package/dist/lib/dom/runtime.cjs +1432 -1
  47. package/dist/lib/dom/runtime.d.ts +71 -19
  48. package/dist/lib/dom/runtime.d.ts.map +1 -1
  49. package/dist/lib/dom/runtime.js +261 -100
  50. package/dist/lib/dom/runtime.mjs +1414 -1
  51. package/dist/lib/dom/server/fx-data.cjs +53 -1
  52. package/dist/lib/dom/server/fx-data.d.ts +5 -5
  53. package/dist/lib/dom/server/fx-data.js +6 -6
  54. package/dist/lib/dom/server/fx-data.mjs +32 -1
  55. package/dist/lib/dom/server/host.cjs +66 -1
  56. package/dist/lib/dom/server/host.d.ts +14 -2
  57. package/dist/lib/dom/server/host.d.ts.map +1 -1
  58. package/dist/lib/dom/server/host.js +38 -10
  59. package/dist/lib/dom/server/host.mjs +45 -1
  60. package/dist/lib/dom/server/index.cjs +759 -1
  61. package/dist/lib/dom/server/index.d.ts +1 -1
  62. package/dist/lib/dom/server/index.js +1 -1
  63. package/dist/lib/dom/server/index.mjs +743 -1
  64. package/dist/lib/dom/server/nodes.cjs +302 -1
  65. package/dist/lib/dom/server/nodes.d.ts +2 -2
  66. package/dist/lib/dom/server/nodes.d.ts.map +1 -1
  67. package/dist/lib/dom/server/nodes.js +4 -4
  68. package/dist/lib/dom/server/nodes.mjs +279 -1
  69. package/dist/lib/dom/server/parse-template.cjs +395 -1
  70. package/dist/lib/dom/server/parse-template.d.ts +1 -1
  71. package/dist/lib/dom/server/parse-template.js +4 -4
  72. package/dist/lib/dom/server/parse-template.mjs +372 -1
  73. package/dist/lib/dom/server/render.cjs +691 -1
  74. package/dist/lib/dom/server/render.d.ts +9 -1
  75. package/dist/lib/dom/server/render.d.ts.map +1 -1
  76. package/dist/lib/dom/server/render.js +25 -17
  77. package/dist/lib/dom/server/render.mjs +677 -1
  78. package/dist/lib/dom/server/request-context.cjs +110 -1
  79. package/dist/lib/dom/server/request-context.d.ts +29 -9
  80. package/dist/lib/dom/server/request-context.d.ts.map +1 -1
  81. package/dist/lib/dom/server/request-context.js +28 -8
  82. package/dist/lib/dom/server/request-context.mjs +89 -1
  83. package/dist/lib/dom/server/serialize.cjs +187 -1
  84. package/dist/lib/dom/server/serialize.js +3 -3
  85. package/dist/lib/dom/server/serialize.mjs +164 -1
  86. package/dist/lib/dom/server-renderer.cjs +760 -1
  87. package/dist/lib/dom/server-renderer.js +1 -1
  88. package/dist/lib/dom/server-renderer.mjs +745 -1
  89. package/dist/lib/dom/types.cjs +18 -1
  90. package/dist/lib/dom/utils.cjs +381 -1
  91. package/dist/lib/dom/utils.d.ts +1 -88
  92. package/dist/lib/dom/utils.d.ts.map +1 -1
  93. package/dist/lib/dom/utils.js +2 -99
  94. package/dist/lib/dom/utils.mjs +361 -1
  95. package/dist/lib/dom/versions.cjs +60 -1
  96. package/dist/lib/dom/versions.d.ts +3 -3
  97. package/dist/lib/dom/versions.d.ts.map +1 -1
  98. package/dist/lib/dom/versions.js +17 -5
  99. package/dist/lib/dom/versions.mjs +37 -1
  100. package/dist/lib/element/attributes.cjs +19 -1
  101. package/dist/lib/element/attributes.d.ts +7 -7
  102. package/dist/lib/element/attributes.js +1 -1
  103. package/dist/lib/element/attributes.mjs +1 -0
  104. package/dist/lib/element/index.cjs +19 -1
  105. package/dist/lib/element/index.mjs +1 -0
  106. package/dist/lib/element/types.cjs +18 -1
  107. package/dist/lib/element/types.d.ts +4 -5
  108. package/dist/lib/element/types.d.ts.map +1 -1
  109. package/dist/lib/element/types.js +0 -1
  110. package/dist/lib/flow/class-map.cjs +38 -1
  111. package/dist/lib/flow/class-map.d.ts +3 -3
  112. package/dist/lib/flow/class-map.js +3 -3
  113. package/dist/lib/flow/class-map.mjs +17 -1
  114. package/dist/lib/flow/client-only.cjs +57 -1
  115. package/dist/lib/flow/client-only.d.ts +4 -4
  116. package/dist/lib/flow/client-only.js +4 -4
  117. package/dist/lib/flow/client-only.mjs +36 -1
  118. package/dist/lib/flow/dynamic.cjs +53 -1
  119. package/dist/lib/flow/dynamic.d.ts +2 -2
  120. package/dist/lib/flow/dynamic.js +4 -4
  121. package/dist/lib/flow/dynamic.mjs +32 -1
  122. package/dist/lib/flow/error-boundary.cjs +43 -1
  123. package/dist/lib/flow/error-boundary.d.ts +2 -2
  124. package/dist/lib/flow/error-boundary.js +4 -4
  125. package/dist/lib/flow/error-boundary.mjs +22 -1
  126. package/dist/lib/flow/for.cjs +66 -1
  127. package/dist/lib/flow/for.d.ts +9 -9
  128. package/dist/lib/flow/for.d.ts.map +1 -1
  129. package/dist/lib/flow/for.js +2 -2
  130. package/dist/lib/flow/for.mjs +45 -1
  131. package/dist/lib/flow/index-flow.cjs +67 -1
  132. package/dist/lib/flow/index-flow.d.ts +5 -5
  133. package/dist/lib/flow/index-flow.js +4 -4
  134. package/dist/lib/flow/index-flow.mjs +46 -1
  135. package/dist/lib/flow/index.cjs +805 -1
  136. package/dist/lib/flow/index.mjs +792 -1
  137. package/dist/lib/flow/portal.cjs +538 -1
  138. package/dist/lib/flow/portal.mjs +519 -1
  139. package/dist/lib/flow/show.cjs +81 -1
  140. package/dist/lib/flow/show.d.ts +1 -1
  141. package/dist/lib/flow/show.d.ts.map +1 -1
  142. package/dist/lib/flow/show.js +12 -118
  143. package/dist/lib/flow/show.mjs +67 -1
  144. package/dist/lib/flow/style-map.cjs +43 -1
  145. package/dist/lib/flow/style-map.d.ts +3 -3
  146. package/dist/lib/flow/style-map.js +4 -4
  147. package/dist/lib/flow/style-map.mjs +22 -1
  148. package/dist/lib/flow/switch.cjs +91 -1
  149. package/dist/lib/flow/switch.d.ts +3 -3
  150. package/dist/lib/flow/switch.d.ts.map +1 -1
  151. package/dist/lib/flow/switch.js +7 -7
  152. package/dist/lib/flow/switch.mjs +70 -1
  153. package/dist/lib/flow/utils.cjs +44 -1
  154. package/dist/lib/flow/utils.d.ts +1 -1
  155. package/dist/lib/flow/utils.js +1 -1
  156. package/dist/lib/flow/utils.mjs +23 -1
  157. package/dist/lib/html.cjs +32 -1
  158. package/dist/lib/html.d.ts +6 -6
  159. package/dist/lib/html.js +5 -5
  160. package/dist/lib/html.mjs +11 -1
  161. package/dist/lib/index.cjs +3104 -1
  162. package/dist/lib/index.d.ts +0 -1
  163. package/dist/lib/index.d.ts.map +1 -1
  164. package/dist/lib/index.js +2 -3
  165. package/dist/lib/index.mjs +3097 -1
  166. package/dist/lib/shared/types.cjs +18 -1
  167. package/dist/lib/shared/types.d.ts +8 -8
  168. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  169. package/dist/version.generated.cjs +26 -1
  170. package/dist/version.generated.d.ts +1 -1
  171. package/dist/version.generated.js +2 -2
  172. package/dist/version.generated.mjs +5 -1
  173. package/package.json +7 -6
  174. package/dist/lib/jsx/control-flow/flow.cjs +0 -1
  175. package/dist/lib/jsx/control-flow/flow.d.ts +0 -2
  176. package/dist/lib/jsx/control-flow/flow.d.ts.map +0 -1
  177. package/dist/lib/jsx/control-flow/flow.js +0 -627
  178. package/dist/lib/jsx/control-flow/flow.mjs +0 -0
  179. package/dist/lib/jsx/control-flow/for-flow.cjs +0 -1
  180. package/dist/lib/jsx/control-flow/for-flow.d.ts +0 -2
  181. package/dist/lib/jsx/control-flow/for-flow.d.ts.map +0 -1
  182. package/dist/lib/jsx/control-flow/for-flow.js +0 -1
  183. package/dist/lib/jsx/control-flow/for-flow.mjs +0 -0
@@ -1 +1,2040 @@
1
- "use strict";var ee=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var Ke=Object.prototype.hasOwnProperty;var Be=(e,t)=>{for(var n in t)ee(e,n,{get:t[n],enumerable:!0})},Ge=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of We(t))!Ke.call(e,r)&&r!==n&&ee(e,r,{get:()=>t[r],enumerable:!(o=Ve(t,r))||o.enumerable});return e};var Je=e=>Ge(ee({},"__esModule",{value:!0}),e);var xn={};Be(xn,{Island:()=>He,JSX_PROPERTIES:()=>D,SVG_ELEMENTS:()=>Qe,SVG_NAMESPACE:()=>O,VOID_ELEMENTS:()=>Ze,addClass:()=>nt,addDelegatedEventListener:()=>Me,addNativeEventListener:()=>fe,appendChildren:()=>ct,applyElementProp:()=>k,applyProps:()=>Kt,applyUse:()=>ue,bindPair:()=>Zt,captureHydrationCursor:()=>Ae,cleanChildren:()=>w,cloneTemplate:()=>$e,closest:()=>tt,createComponent:()=>nn,createElement:()=>ut,createNativeElement:()=>ae,createPortal:()=>Jt,createTemplate:()=>_e,delegate:()=>mt,delegateEvents:()=>se,escapeHTML:()=>Ut,fnName:()=>Ft,generateID:()=>Lt,getAttribute:()=>st,getGlobal:()=>vt,getLitEventName:()=>Ue,getOffset:()=>yt,getStableElementId:()=>Rt,getStyle:()=>ft,handleRef:()=>ce,hasClass:()=>it,holeContent:()=>Dt,holeEnd:()=>kt,holeScope:()=>Ot,hydrate:()=>Z,hydrateAdvancePast:()=>Le,hydrateIslands:()=>je,initializeIntegration:()=>tn,insert:()=>A,insertExpression:()=>P,intergartionInitialized:()=>on,isAccessor:()=>Yt,isCustomElement:()=>me,isDOMNode:()=>wt,isDelegatedEvent:()=>_t,isDomElement:()=>H,isDomNode:()=>v,isDomText:()=>j,isEventHandler:()=>ze,isFunction:()=>$t,isIntegrationInitialized:()=>rn,isJSXTemplate:()=>Tt,isLitTemplateResult:()=>xe,isNativeElement:()=>Xt,isPromise:()=>L,isReactElement:()=>bt,isSVGElement:()=>zt,isServer:()=>E,isTemplateFactory:()=>Nt,isVisible:()=>dt,iterateFn:()=>Ht,makeArrayFlat:()=>Ie,mergeProps:()=>Bt,observeIntersection:()=>xt,observeResize:()=>ht,query:()=>te,queryAll:()=>et,registerCreateComponent:()=>en,registerGlobal:()=>St,removeAttribute:()=>at,removeChildren:()=>lt,removeClass:()=>ot,removeDelegatedEventListener:()=>ie,render:()=>de,resetIntegration:()=>sn,runHydrationAt:()=>R,runWithoutHydration:()=>Re,scrollIntoView:()=>pt,setAttribute:()=>x,setClassList:()=>$,setClassName:()=>_,setDynamicAttribute:()=>W,setDynamicBoolAttribute:()=>le,setDynamicProperty:()=>K,setProperty:()=>M,setServerMode:()=>Se,setStyle:()=>I,setStyles:()=>ge,shouldSetAsProperty:()=>Ye,splitProps:()=>Gt,spread:()=>Wt,templateNode:()=>It,toAttributeName:()=>Xe,toggleClass:()=>rt,waitForElement:()=>gt});module.exports=Je(xn);function Xe(e){return e.startsWith("aria-")||e.startsWith("data-")?e:/[A-Z]/.test(e)?e.replace(/([A-Z])/g,"-$1").toLowerCase():e}function ze(e){return e.startsWith("@")||e.startsWith("on")&&e.length>2}function Ue(e){return e.startsWith("@")?e.slice(1):e.startsWith("on")?e.slice(2).toLowerCase():e}function Ye(e,t){let n=new Set(["checked","value","selected","disabled","readonly","required","multiple","open","contenteditable","draggable","spellcheck"]),o={input:new Set(["value","checked","indeterminate"]),textarea:new Set(["value"]),select:new Set(["value"]),option:new Set(["selected","value"]),audio:new Set(["volume","currentTime","paused"]),video:new Set(["volume","currentTime","paused"]),img:new Set(["src","srcset"]),iframe:new Set(["src"]),a:new Set(["href"])};return n.has(t)||o[e]&&o[e].has(t)}var Ze=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Qe=new Set(["svg","g","path","circle","rect","line","polyline","polygon","ellipse","text","tspan","use","defs","symbol","mask","clipPath","pattern","linearGradient","radialGradient","stop","filter","feGaussianBlur","feOffset","feMerge","feMergeNode","foreignObject"]),O="http://www.w3.org/2000/svg";function me(e){return e.localName.includes("-")}function k(e,t,n,o=!1){if(n==null){e.removeAttribute(t);return}if(me(e)){e[t]=n;return}x(e,t,n,o)}var D=new Set(["className","value","checked","selected","innerHTML","innerText","textContent","indeterminate","htmlFor"]);function te(e,t=document){return t.querySelector(e)}function et(e,t=document){return Array.from(t.querySelectorAll(e))}function tt(e,t){return e.closest(t)}function nt(e,...t){e.classList.add(...t)}function ot(e,...t){e.classList.remove(...t)}function rt(e,...t){t.forEach(n=>e.classList.toggle(n))}function it(e,t){return e.classList.contains(t)}function x(e,t,n,o=!1){if(n==null||n===!1){e.removeAttribute(t);return}if(n===!0){e.setAttribute(t,"");return}if(typeof n=="object"){e.setAttribute(t,JSON.stringify(n));return}e.setAttribute(t,String(n))}function st(e,t){return e.getAttribute(t)}function at(e,t){e.removeAttribute(t)}function ge(e,t){Object.assign(e.style,t)}function ft(e,t){return window.getComputedStyle(e).getPropertyValue(t)}function ut(e,t={},...n){let o=document.createElement(e);return Object.entries(t).forEach(([r,f])=>{if(r==="class"||r==="className")o.className=f;else if(r==="style"&&typeof f=="object")ge(o,f);else if(r.startsWith("on")&&typeof f=="function"){let s=r.slice(2).toLowerCase();o.addEventListener(s,f)}else x(o,r,f)}),n.forEach(r=>{typeof r=="string"?o.appendChild(document.createTextNode(r)):o.appendChild(r)}),o}function lt(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function ct(e,...t){t.forEach(n=>{typeof n=="string"?e.appendChild(document.createTextNode(n)):e.appendChild(n)})}function dt(e){let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=window.innerHeight&&t.right<=window.innerWidth}function pt(e,t={behavior:"smooth",block:"nearest"}){e.scrollIntoView(t)}function yt(e){let t=e.getBoundingClientRect();return{top:t.top+window.pageYOffset,left:t.left+window.pageXOffset}}function mt(e,t,n,o){let r=f=>{let s=f.target.closest(n);s&&e.contains(s)&&o(f,s)};return e.addEventListener(t,r),()=>{e.removeEventListener(t,r)}}function gt(e,t=5e3){return new Promise((n,o)=>{let r=te(e);if(r){n(r);return}let f=new MutationObserver(()=>{let i=te(e);i&&(f.disconnect(),clearTimeout(s),n(i))});f.observe(document.body,{childList:!0,subtree:!0});let s=setTimeout(()=>{f.disconnect(),o(new Error(`Element ${e} not found within ${t}ms`))},t)})}function xt(e,t,n={}){let o=new IntersectionObserver(r=>{r.forEach(f=>{t(f.isIntersecting)})},n);return o.observe(e),()=>{o.disconnect()}}function ht(e,t){let n=new ResizeObserver(o=>{o.forEach(t)});return n.observe(e),()=>{n.disconnect()}}var Et=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;function bt(e){return typeof e=="object"&&e!==null&&e.$$typeof===Et}function xe(e){return e&&typeof e=="object"&&e.strings&&Array.isArray(e.strings)&&e.values&&Array.isArray(e.values)}function Nt(e){if(typeof e!="function")return!1;try{let t=e();return xe(t)}catch{return!1}}function Tt(e){return typeof e=="object"&&e!==null&&(e.$$typeof==="template"||typeof e.type=="function")}function wt(e){return e instanceof Node}function St(e,t,n="Fluixi"){typeof globalThis<"u"&&(typeof globalThis[n]>"u"&&(globalThis[n]={}),typeof globalThis[n][e]>"u"&&(globalThis[n][e]=t))}function vt(e,t,n="Fluixi"){return typeof globalThis<"u"&&typeof globalThis[n]<"u"&&typeof globalThis[n][e]<"u"?globalThis[n][e]:t}var m=require("@fluixi/reactive/signal");var he="1.0.0-alpha.82";var Ee=require("@fluixi/reactive/version"),h={dom:he,reactive:Ee.VERSION};function be(e){h.core&&e.setAttribute("fluixi",h.core),e.setAttribute("fx-dom",h.dom),e.setAttribute("fx-reactive",h.reactive),typeof globalThis<"u"&&(globalThis.Fluixi=h)}function Ne(){let e=[h.core,h.dom,h.reactive].filter(t=>t!==void 0);new Set(e).size<=1||console.warn(`[fluixi] package versions disagree — core ${h.core??"(absent)"}, dom ${h.dom}, reactive ${h.reactive}. These ship as one release, so a mismatch usually means a stale lockfile or two copies resolved side by side. Reinstall, or check for duplicates with \`pnpm why @fluixi/dom\`.`)}function Te(e){return typeof e!="function"||Object.defineProperty(e,Symbol.for("fluixi-component"),{value:!0,enumerable:!0}),e}function b(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}var c=require("@fluixi/reactive/signal");var E=typeof document>"u";function Se(e){E=e}var ne=Symbol.for("fluixi.server-node"),we=null;function F(){if(!we)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return we}function v(e){return e!=null&&e[ne]===!0?!0:typeof Node<"u"&&e instanceof Node}function H(e){return e!=null&&e[ne]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function j(e){return e!=null&&e[ne]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var l={active:!1,cursor:null,parents:[]},ve=null;function Ce(e){ve=e}function q(){return ve}function oe(e,t){return l.active&&t.parentNode===e}function re(e){let t=l.parents.lastIndexOf(e);t!==-1&&(l.parents.length=t),l.cursor=e.nextSibling}function Ae(){return l.active?l.cursor:null}function R(e,t){if(!e||e.parentNode==null)return t();let n=l.active,o=l.cursor,r=l.parents;l.active=!0,l.cursor=e,l.parents=[];try{return t()}finally{l.active=n,l.cursor=o,l.parents=r}}function Re(e){if(!l.active)return e();let t=l.cursor,n=l.parents;l.active=!1,l.parents=[];try{return e()}finally{l.active=!0,l.cursor=t,l.parents=n}}function Le(e){if(!l.active||e==null)return;let t=Array.isArray(e)?e[e.length-1]:e;t&&typeof t.nodeType=="number"&&re(t)}function Ct(e){let t=[];for(;e&&e.nodeType===1;){let n=e.tagName.toLowerCase();if(e.id){n+=`#${e.id}`,t.unshift(n);break}e.getAttribute("data-id")&&(n+=`[data-id="${e.getAttribute("data-id")}"]`);let o=0,r=e;for(;r=r.previousElementSibling;)r.tagName===e.tagName&&o++;n+=`:nth-of-type(${o+1})`,t.unshift(n),e=e.parentElement}return t.join(">")}function At(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return`el_${Math.abs(t)}`}function Rt(e){return At(Ct(e))}var Lt=()=>"xxyxxxxxxy-4xx8".replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),Pt={};var Pe=new Map,V=new Set,B=new Set(["scroll","focus","blur","load","error","resize","mouseenter","mouseleave","pointerenter","pointerleave","gotpointercapture","lostpointercapture"]);function se(e){if(!E)for(let t of e)V.has(t)||B.has(t)||(V.add(t),document.addEventListener(t,Mt))}function Mt(e){let t=`$$${e.type}`,n=e.composedPath&&e.composedPath()[0]||e.target;for(;n;){let o=n[t];if(o&&!n.disabled&&(o(e),e.cancelBubble))return;n=n.host&&n.host!==n&&n.host instanceof Element?n.host:n.parentNode}}function Me(e,t,n){if(e[`$$${t}`]=n,B.has(t)){let o=`__fx_${t}`;if(!e[o]){let r=f=>{e[`$$${t}`]?.(f)};e.addEventListener(t,r),e[o]=r}return}V.has(t)||se([t])}function ie(e,t){delete e[`$$${t}`];let n=`__fx_${t}`,o=e[n];o&&(e.removeEventListener(t,o),delete e[n])}function _t(e){return!B.has(e)}function $t(e){return typeof e=="function"}function S(e,t=!1){if(E)return F().createText(e);if(l.active&&!t){let n=q()?.hydrateText(e);if(n)return n}return document.createTextNode(e)}function ae(e,t=!1){if(E)return F().createElement(e,t);if(l.active){let n=q()?.hydrateElement(e);if(n)return n}return t?document.createElementNS(O,e):document.createElement(e)}function _e(e,t=!1){let n=Pe.get(e);if(n)return n;let o=document.createElement("template");return t?o.innerHTML=`<svg>${e}</svg>`:o.innerHTML=e,Pe.set(e,o),o}function It(e,t,n=!1,o=!1){if(E){let r=F();return n?r.parseTemplate(e,o):r.createRaw(e)}if(l.active){let r=q()?.hydrateStatic(t);if(r)return r}return $e(_e(e,o),o).firstChild}function Ot(e,t){if(!l.active)return t();let n=R(e.nextSibling,t);if(typeof n=="function"){let o=n;return((...r)=>l.active?R(e.nextSibling,()=>o(...r)):o(...r))}return n}function kt(e){for(let t=e.nextSibling;t;t=t.nextSibling)if(t.nodeType===8&&t.data==="fx/")return t;throw new Error("[fluixi] template hole is missing its closing marker")}function Dt(e,t){let n=[];for(let o=e.nextSibling;o&&o!==t;o=o.nextSibling)n.push(o);return n}function $e(e,t=!1){let n=e.content.cloneNode(!0);return t?n.firstChild:n}function Ie(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Ie(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}function Ft(e){return typeof e!="function"?null:e._name||e.name||"anonymous"}function Ht(e){if((0,m.isSignal)(e)||b(e)||typeof e!="function")return e;let t=e();for(;typeof t=="function"&&!(0,m.isSignal)(t)&&!b(t);)t=t();return t}var T=0,jt=200;function qt(e,t,n,o,r){let f=o,s=new Map;return(0,c.createRenderEffect)(()=>{let i;if(b(e)&&!(0,m.isSignal)(e)){if(!s.has(e)){T++;try{let a=e();s.set(e,a)}finally{T--}}for(i=s.get(e);typeof i=="function"&&(0,m.isSignal)(i);)i=i()}else for(i=e();typeof i=="function"&&(0,m.isSignal)(i);)i=i();{let a=0;for(;typeof i=="function"&&a++<50;)if(b(i)){if(!s.has(i)){let u=i;T++;try{let d=u();s.set(u,d)}finally{T--}}i=s.get(i)}else if((0,m.isSignal)(i))i=i();else if(i=i(),typeof i!="function"||!(0,m.isSignal)(i)&&!b(i))break}T++;try{f=P(t,i,n,f,s),r(f)}finally{T--}})}function A(e,t,n,o){if(T>jt)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;n!==void 0&&!n&&(n=S("",!0),e.appendChild(n));let r=o??null,f=a=>Array.isArray(a)&&a.some(u=>typeof u=="function"),s=a=>typeof a=="function"?a:()=>a;if(typeof t!="function"&&!f(t)){T++;try{r=P(e,t,n,r)}finally{T--}return()=>r}let i=qt(s(t),e,n,r,a=>{r=a});return()=>(i?.(),r)}function P(e,t,n,o,r){if(t==null||typeof t=="boolean")return w(e,o,n);if(typeof t=="function")for(;typeof t=="function";)t=t();if(t==null||typeof t=="boolean")return w(e,o,n);if(L(t)){let s=S("",!0);return Array.isArray(o)?o.length>0?(e.replaceChild(s,o[0]),w(e,o.slice(1),n)):g(e,s,n):o?e.replaceChild(s,o):g(e,s,n),t.then(i=>{s.parentNode===e&&P(e,i,s.nextSibling,s)}).catch(i=>{console.error("Error resolving promise in insertExpression:",i)}),s}let f=typeof t;if(f==="string"||f==="number"){if(f==="number"&&(t=String(t)),Array.isArray(o)){if(o.length===0){let i=S(t);return g(e,i,n),i}if(o.length===1&&o[0].nodeType===3)return o[0].data=t,o;o=w(e,o,n)}if(o&&j(o))return o.data=t,o;let s=S(t);return o&&o.parentNode===e?e.replaceChild(s,o):oe(e,s)||g(e,s,n),s}if(v(t))return oe(e,t)?(re(t),t):Array.isArray(o)?(o.length===0?g(e,t,n):o[0].parentNode===e?(e.replaceChild(t,o[0]),w(e,o.slice(1),n)):g(e,t,n),t):(o?o!==t&&(o.parentNode===e?e.replaceChild(t,o):g(e,t,n)):g(e,t,n),t);if(Array.isArray(t)){let s=[],i=Array.isArray(o)?o:o?[o]:[],a=[];N(t,s,e,n,!0,r,a);let u=Vt(e,i,s,n);for(let d of a){let p=A(e,d.sig,d.marker);(0,c.onCleanup)(()=>{w(e,p()),d.marker.parentNode===e&&e.removeChild(d.marker)})}return u}if(f==="object"&&t!==null&&typeof t=="object"){let s=t;if("type"in s&&"props"in s){let i=s;if(typeof i.type=="function"){let a=i.type(i.props||{});return P(e,a,n,o)}}}return w(e,o,n)}function N(e,t,n,o,r=!0,f,s){for(let i=0;i<e.length;i++){let a=e[i];if(!(a==null||typeof a=="boolean")){for(;typeof a=="function"&&!L(a)&&!(0,m.isSignal)(a)&&!b(a)&&(a=a(),!(a==null||typeof a=="boolean")););if(!(a==null||typeof a=="boolean")){if(typeof a=="function"){let u;for(b(a)&&!(0,m.isSignal)(a)?(f||(f=new Map),f.has(a)||f.set(a,a()),u=f.get(a)):u=a();typeof u=="function"&&!L(u)&&!(0,m.isSignal)(u)&&!b(u);)f||(f=new Map),f.has(u)||f.set(u,u()),u=f.get(u);if(u==null||typeof u=="boolean")continue;if(typeof u=="function"){if((0,m.isSignal)(u)){if(s){let p=S("",!0);t.push(p),s.push({marker:p,sig:u});continue}let d=u();for(;typeof d=="function"&&(0,m.isSignal)(d);)d=d();if(d==null||typeof d=="boolean")continue;Array.isArray(d)?N(d,t,n,o,r,f):N([d],t,n,o,r,f);continue}continue}Array.isArray(u)?N(u,t,n,o,r,f,s):N([u],t,n,o,r,f,s);continue}if(L(a)){let u=S("",!0);t.push(u),a.then(d=>{if(u.parentNode){let p=[];if(N([d],p,u.parentNode,void 0,!1,f),p.length>0){u.parentNode.replaceChild(p[0],u);for(let y=1;y<p.length;y++)u.parentNode?.insertBefore(p[y],p[y-1].nextSibling)}}}).catch(d=>console.error("Error resolving promise in array:",d));continue}if(Array.isArray(a)){N(a,t,n,o,r,f,s);continue}if(v(a)){t.push(a);continue}if(typeof a=="object"&&a!==null&&"type"in a&&"props"in a){let u=a;if(typeof u.type=="function"){let d=u.type(u.props||{});Array.isArray(d)?N(d,t,n,o,!1,f):N([d],t,n,o,!1,f);continue}}if(typeof a=="string"||typeof a=="number"){let u=String(a);if(u.trim()===""&&u!==" ")continue;t.push(S(u));continue}t.push(S(String(a)))}}}}function Vt(e,t,n,o){for(let p=0;p<n.length;p++){let y=n[p].parentNode;y!==null&&y!==e&&y.nodeType!==11&&(n=n.slice(),n[p]=n[p].cloneNode(!0))}let r=n.length,f=t.length,s=r,i=0,a=0,u=f>0?t[f-1].nextSibling??void 0:o,d=null;for(;i<f||a<s;){if(t[i]===n[a]){i++,a++;continue}for(;f>i&&s>a&&t[f-1]===n[s-1];)f--,s--;if(f===i){let p=s<r?a?n[a-1].nextSibling??void 0:n[s-a]:u;for(;a<s;)g(e,n[a++],p)}else if(s===a)for(;i<f;)(!d||!d.has(t[i]))&&t[i].parentNode===e&&e.removeChild(t[i]),i++;else if(t[i]===n[s-1]&&n[a]===t[f-1]){let p=t[--f].nextSibling;g(e,n[a++],t[i++].nextSibling),g(e,n[--s],p),t[f]=t[i-1]}else{if(!d){d=new Map;let y=a;for(;y<s;)d.set(n[y],y++)}let p=d.get(t[i]);if(p!=null)if(a<p&&p<s){let y=i,Q=1;for(;++y<f&&y<s&&!(!d.has(t[y])||d.get(t[y])!==p+Q);)Q++;if(Q>p-a){let qe=t[i];for(;a<p;)g(e,n[a++],qe)}else t[i].parentNode===e?e.replaceChild(n[a++],t[i++]):(g(e,n[a++],u),i++)}else i++;else t[i].parentNode===e&&e.removeChild(t[i]),i++}}return n}function w(e,t,n){if(t)if(Array.isArray(t))for(let o=0;o<t.length;o++)t[o].parentNode===e&&e.removeChild(t[o]);else t.parentNode===e&&e.removeChild(t);return null}function g(e,t,n){l.active&&t.parentNode===e||(n&&n.parentNode===e?e.insertBefore(t,n):e.appendChild(t))}function M(e,t,n){n==null?delete e[t]:e[t]=n}function fe(e,t,n){let o=n,r;return Array.isArray(n)&&(o=n[0],r=n[1]),typeof o!="function"?()=>{}:(e.addEventListener(t,o,r),()=>e.removeEventListener(t,o,r))}function ue(e,t){let n=(o,r)=>{typeof o=="function"&&o(e,r??(()=>{}))};if(typeof t=="function"){n(t);return}if(Array.isArray(t)){if(typeof t[0]=="function"){n(t[0],t[1]);return}for(let o of t)Array.isArray(o)?n(o[0],o[1]):n(o)}}function W(e,t,n,o=!1){return typeof n!="function"?(x(e,t,n,o),()=>{}):(0,c.createRenderEffect)(()=>{let r=typeof n=="function"?n():n;x(e,t,r,o)})}function K(e,t,n){return typeof n!="function"?(M(e,t,n),()=>{}):(0,c.createRenderEffect)(()=>{let o=typeof n=="function"?n():n;M(e,t,o)})}function le(e,t,n){return typeof n!="function"?(x(e,t,!!n),()=>{}):(0,c.createRenderEffect)(()=>{let o=n();x(e,t,!!o)})}function _(e,t){if(t==null){e.removeAttribute("class");return}if(typeof t=="function"){(0,c.createRenderEffect)(()=>_(e,t()));return}if(typeof t=="string"){e.setAttribute("class",t);return}if(Array.isArray(t)){e.setAttribute("class",t.filter(Boolean).join(" "));return}if(typeof t=="object"){let n=Object.keys(t).filter(o=>{let r=t[o];return typeof r=="function"?r():!!r}).join(" ");e.setAttribute("class",n);return}e.setAttribute("class",String(t))}function $(e,t,n){if(!(!t||typeof t!="object"))for(let o in t){let r=t[o],f=o.split(/\s+/).filter(Boolean);if(typeof r=="function"&&n)n.push((0,c.createRenderEffect)(()=>{let s=!!r();for(let i of f)e.classList.toggle(i,s)}));else{let s=!!(typeof r=="function"?r():r);for(let i of f)e.classList.toggle(i,s)}}}function I(e,t){let n=t;for(;typeof n=="function";)n=n();if(n==null){e.removeAttribute("style");return}if(typeof n=="string"){e.style.cssText=n;return}if(typeof n=="object")for(let o in n){let r=n[o];r==null?e.style[o]="":e.style[o]=r}}function Wt(e){let{element:t,props:n,prevProps:o=Pt,isSVG:r=!1,skipChildren:f=!1}=e;if(!t||!H(t))return console.error("[spread] Error: element is not a DOM Element!"),()=>{};if(!n)return console.warn("[spread] Warning: props is undefined!"),()=>{};let s=r||t.namespaceURI===O,i=[];for(let a in n){if(f&&a==="children")continue;let u=n[a],d=o[a];if(u===d)continue;if(a==="ref"){ce(u,t);continue}if(a==="use"){ue(t,u);continue}if(a.startsWith("on:")){i.push(fe(t,a.slice(3),u));continue}if(a.startsWith("prop:")){i.push(K(t,a.slice(5),u));continue}if(a.startsWith("attr:")){i.push(W(t,a.slice(5),u,s));continue}if(a.startsWith("bool:")){i.push(le(t,a.slice(5),u));continue}if(a==="class"||a==="className"){typeof u=="function"?i.push((0,c.createRenderEffect)(()=>_(t,u()))):_(t,u);continue}if(a==="classList"){typeof u=="function"?i.push((0,c.createRenderEffect)(()=>$(t,u()))):$(t,u,i);continue}if(a==="style"){typeof u=="function"?i.push((0,c.createRenderEffect)(()=>I(t,u()))):I(t,u);continue}if(a.startsWith("on")){let y=a.slice(2).toLowerCase();d&&ie(t,y),u&&Me(t,y,u);continue}let p=D.has(a)||!s&&a in t;typeof u=="function"?i.push(p?K(t,a,u):W(t,a,u,s)):i.push((0,c.createRenderEffect)(()=>p?M(t,a,n[a]):x(t,a,n[a],s)))}for(let a in o)if(!(a in n))if(a.startsWith("on")){let u=a.slice(2).toLowerCase();ie(t,u)}else D.has(a)?M(t,a,null):t.removeAttribute(a);return()=>{i.forEach(a=>a())}}function Kt(e,t,n=!1){for(let o in t){let r=t[o];if(o==="ref"){ce(r,e);continue}if(o!=="children"){if(o==="use"){ue(e,r);continue}if(o.startsWith("on:")){fe(e,o.slice(3),r);continue}if(o.startsWith("prop:")){K(e,o.slice(5),r);continue}if(o.startsWith("attr:")){W(e,o.slice(5),r,n);continue}if(o.startsWith("bool:")){le(e,o.slice(5),r);continue}if(o.startsWith("on")&&o.length>2){let f=o.slice(2).toLowerCase();if(typeof r=="function")if(B.has(f)){e[`$$${f}`]=r;let s=`__fx_${f}`;if(!e[s]){let i=a=>{e[`$$${f}`]?.(a)};e.addEventListener(f,i),e[s]=i}}else e[`$$${f}`]=r,V.has(f)||se([f]);continue}if(o==="class"||o==="className"){_(e,r);continue}if(o==="classList"){typeof r=="function"?(0,c.createRenderEffect)(()=>$(e,r())):$(e,r);continue}if(o==="style"){typeof r=="function"?(0,c.createRenderEffect)(()=>I(e,r())):I(e,r);continue}if(o==="innerHTML"){if(typeof r=="function"){let f=(0,c.createEffect)(()=>{let s=r();for(;typeof s=="function";)s=s();e.innerHTML=s});(0,c.onCleanup)(()=>f())}else e.innerHTML=r;continue}if(o==="value"&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA")){if(typeof r=="function"){let f=(0,c.createEffect)(()=>{let s=r();for(;typeof s=="function"&&s.length===0;)s=s();document.activeElement!==e&&(e.value=s??"")});(0,c.onCleanup)(()=>{f()})}else(0,c.createRenderEffect)(()=>{document.activeElement!==e&&(e.value=t[o]??"")});continue}if(o==="checked"&&e.tagName==="INPUT"){if(typeof r=="function"){let f=(0,c.createEffect)(()=>{let s=r();for(;typeof s=="function"&&s.length===0;)s=s();document.activeElement!==e&&(e.checked=s??"")});(0,c.onCleanup)(()=>{f()})}else(0,c.createRenderEffect)(()=>{document.activeElement!==e&&(e.checked=t[o]??"")});continue}if(o==="value"&&e.tagName==="SELECT"){if(typeof r=="function"){let f=!0,s=(0,c.createEffect)(()=>{let i=r();for(;typeof i=="function"&&i.length===0;)i=i();f?(f=!1,queueMicrotask(()=>{e.value=i??""})):e.value=i??""});(0,c.onCleanup)(()=>{s()})}else{let f=!0;(0,c.createRenderEffect)(()=>{let s=t[o];f?(f=!1,queueMicrotask(()=>{e.value=s??""})):e.value=s??""})}continue}if(typeof r=="function"){let f=(0,c.createEffect)(()=>{let s=r();for(;typeof s=="function"&&s.length===0;)s=s();k(e,o,s,n)});(0,c.onCleanup)(()=>{f()})}else(0,c.createRenderEffect)(()=>k(e,o,t[o],n))}}}function Bt(...e){let t=o=>{for(let r=e.length-1;r>=0;r--){let f=e[r];if(f&&o in f&&f[o]!==void 0)return f[o]}},n=o=>{for(let r of e)if(r&&o in r)return!0;return!1};return new Proxy({},{get:(o,r)=>t(r),has:(o,r)=>n(r),ownKeys:()=>{let o=new Set;for(let r of e)if(r)for(let f of Reflect.ownKeys(r))o.add(f);return[...o]},getOwnPropertyDescriptor:(o,r)=>n(r)?{enumerable:!0,configurable:!0,get:()=>t(r)}:void 0})}function Gt(e,...t){let n=new Set;for(let s of t)for(let i of s)n.add(i);let o=s=>({enumerable:!0,configurable:!0,get:()=>e[s]}),r=t.map(s=>{let i=new Set(s);return new Proxy({},{get:(a,u)=>i.has(u)?e[u]:void 0,has:(a,u)=>i.has(u)&&u in e,ownKeys:()=>Array.from(i).filter(a=>a in e),getOwnPropertyDescriptor:(a,u)=>i.has(u)&&u in e?o(u):void 0})}),f=new Proxy({},{get:(s,i)=>n.has(i)?void 0:e[i],has:(s,i)=>!n.has(i)&&i in e,ownKeys:()=>Reflect.ownKeys(e).filter(s=>!n.has(s)),getOwnPropertyDescriptor:(s,i)=>!n.has(i)&&i in e?o(i):void 0});return[...r,f]}function ce(e,t){if(e){if(v(e)){let n=t,o=e;if(!n)return;typeof n=="function"?n(o):typeof n=="object"&&"current"in n&&(n.current=o);return}typeof e=="function"?e(t):typeof e=="object"&&"current"in e&&(e.current=t)}}function Jt(e,t,n){let o=t||document.body,r=(0,c.readChildren)(()=>e),f=[];return(0,c.batch)(()=>{let s=(0,c.createRenderEffect)(()=>{let i=r();Array.isArray(i)?(i.forEach(a=>o.appendChild(a)),f.push(()=>{i.forEach(a=>{a.parentNode===o&&o.removeChild(a)})})):v(i)&&(o.appendChild(i),f.push(()=>{i.parentNode===o&&o.removeChild(i)}))});f.push(s),(0,c.onCleanup)(()=>{f.forEach(i=>i())})}),null}function Xt(e){return typeof e=="string"&&e.toLowerCase()===e}function zt(e){return e==="svg"||e==="path"||e==="circle"||e==="rect"||e==="line"||e==="polygon"||e==="polyline"||e==="ellipse"||e==="g"||e==="defs"||e==="clipPath"||e==="text"}function Ut(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function L(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function Yt(e){return typeof e=="function"&&e.length===0&&(0,m.isSignal)(e)}function de(e,t,n){if(!t)throw new Error("Container element is required");let o,r,f=[];return(0,c.createRoot)(s=>{(0,c.batch)(()=>{l.active||(t.textContent=""),be(t),Ne(),A(t,e)}),r=s}),()=>{r?.(),o?.(),f.forEach(s=>s()),t.textContent=""}}function Zt(e){if(Array.isArray(e))return e;if(typeof e=="function"&&typeof e.set=="function")return[e,e.set];throw new TypeError("[fluixi] bind: needs a signal — either `signal(…)` or the `[get, set]` pair from `createSignal(…)`.")}var G=require("@fluixi/reactive");var Qt="__fx_dom_create_component__",C=globalThis[Qt]??={fn:null};function en(e){C.fn=e}function tn(e={}){let t=e.signalSystem?.createComponent;t&&(C.fn=t)}function nn(e,t){if(C.fn)return C.fn(e,t);let n=typeof e=="function"?(0,G.untrack)(()=>e(t)):e;if(n!=null&&(typeof n=="function"||typeof n=="object")&&!(0,G.isSignal)(n)){try{n.$name=e?.name}catch{}return Te(n)}return n}var on=()=>C.fn!==null,rn=()=>C.fn!==null;function sn(){C.fn=null}var J,an={getStore:()=>J,run(e,t){let n=J;J=e;try{return t()}finally{J=n}}},fn=an;function Oe(){return fn.getStore()}var X=require("@fluixi/reactive/signal");var un="__FX_DATA__";var pe;function ke(){let e=globalThis.__FX_DATA__;if(e)return e;if(pe!==void 0)return pe;let t=null;if(typeof document<"u"){let n=document.getElementById(un)?.textContent;if(n)try{t=JSON.parse(n)}catch{t=null}}return pe=t}function z(){for(;;){for(;l.cursor&&l.cursor.nodeType===3&&l.cursor.data==="";)l.cursor=l.cursor.nextSibling;if(l.cursor!=null||!l.parents.length)return;l.cursor=l.parents.pop().nextSibling}}var ln=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),U=typeof process<"u"&&process.env&&!1;function Y(e,t){let n=t.nodeType===1?`<${t.tagName.toLowerCase()}>`:t.nodeType===3?`text ${JSON.stringify((t.nodeValue??"").slice(0,24))}`:t.nodeType===8?"comment":"node";console.warn(`[fluixi] hydration mismatch: expected ${e} but the server DOM has ${n}. Server and client rendered different markup; recreating this node on the client. Check for non-deterministic render (Date.now(), Math.random(), browser-only branches, untransported data).`)}function cn(e){z();let t=l.cursor;return t&&t.nodeType===1&&t.tagName.toLowerCase()===e.toLowerCase()?(ln.has(e.toLowerCase())?l.cursor=t.nextSibling:(l.parents.push(t),l.cursor=t.firstChild),t):(U&&t&&Y(`<${e}>`,t),null)}function dn(e){z();let t=l.cursor;return t&&t.nodeType===1&&t.tagName.toLowerCase()===e.toLowerCase()?(l.cursor=t.nextSibling,t):(U&&t&&Y(`<${e}> (static)`,t),null)}function pn(e){if(e===""){let n=l.cursor;return n&&n.nodeType===3&&n.data!==""?(l.cursor=n.nextSibling,n.data="",n):null}z();let t=l.cursor;return t&&t.nodeType===3?(l.cursor=t.nextSibling,t.nodeValue!==e&&(t.nodeValue=e),t):(U&&t&&Y(`text ${JSON.stringify(e.slice(0,24))}`,t),null)}function yn(e){z();let t=l.cursor;return t&&t.nodeType===8&&t.data===e?(l.cursor=t.nextSibling,t):(U&&t&&Y(`marker <!--${e.slice(0,24)}-->`,t),null)}var De=!1;function mn(){De||(De=!0,Ce({hydrateElement:cn,hydrateText:pn,hydrateMarker:yn,hydrateStatic:dn}))}function Z(e,t,n){mn(),l.active=!0,l.cursor=t.firstChild,l.parents=[];let o=ke(),r=n?.resourceNamespace,f=0;(0,X.setResourceIdSource)(()=>r?`${r}:r${f++}`:`r${f++}`),(0,X.setServerDataGetter)(o?s=>s in o?{value:o[s]}:void 0:null);try{return de(e,t)}finally{l.active=!1,l.cursor=null,l.parents=[]}}var ye="fluixi-island";function He(e){let{component:t,props:n={},name:o}=e,r=ae(ye),f=o??t.name??"Island";x(r,"name",f),x(r,"props",JSON.stringify(n??{}));let s=E?Oe():void 0;if(s){let i=s.nextIslandNamespace(f);A(r,()=>s.withResourceScope(i,()=>t(n)))}else A(r,()=>t(n));return r}var Fe=!1;function gn(){if(Fe||typeof document>"u")return;Fe=!0;let e=document.createElement("style");e.textContent=`${ye}{display:contents}`,document.head.appendChild(e)}function je(e){if(typeof document>"u")return;gn();let t=document.querySelectorAll(ye),n=new Map;t.forEach(o=>{let r=o.getAttribute("name")??"",f=n.get(r)??0;n.set(r,f+1);let s=e[r];if(!s){typeof process>"u"&&console.warn(`[fluixi] island "${r}" has no component in the registry — left static.`);return}let i={};try{i=JSON.parse(o.getAttribute("props")||"{}")}catch{}Z(()=>s(i),o,{resourceNamespace:`${r}#${f}`})})}
1
+ /*! @fluixi/dom v1.0.0-alpha.84 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/lib/dom/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ Island: () => Island,
25
+ JSX_PROPERTIES: () => JSX_PROPERTIES,
26
+ SVG_ELEMENTS: () => SVG_ELEMENTS,
27
+ SVG_NAMESPACE: () => SVG_NAMESPACE,
28
+ VOID_ELEMENTS: () => VOID_ELEMENTS,
29
+ addClass: () => addClass,
30
+ addDelegatedEventListener: () => addDelegatedEventListener,
31
+ addNativeEventListener: () => addNativeEventListener,
32
+ appendChildren: () => appendChildren,
33
+ applyElementProp: () => applyElementProp,
34
+ applyProps: () => applyProps,
35
+ applyUse: () => applyUse,
36
+ bindPair: () => bindPair,
37
+ captureHydrationCursor: () => captureHydrationCursor,
38
+ cleanChildren: () => cleanChildren,
39
+ cloneTemplate: () => cloneTemplate,
40
+ closest: () => closest,
41
+ createComponent: () => createComponent,
42
+ createElement: () => createElement,
43
+ createNativeElement: () => createNativeElement,
44
+ createPortal: () => createPortal,
45
+ createTemplate: () => createTemplate,
46
+ delegate: () => delegate,
47
+ delegateEvents: () => delegateEvents,
48
+ escapeHTML: () => escapeHTML,
49
+ fnName: () => fnName,
50
+ generateID: () => generateID,
51
+ getAttribute: () => getAttribute,
52
+ getGlobal: () => getGlobal,
53
+ getLitEventName: () => getLitEventName,
54
+ getOffset: () => getOffset,
55
+ getStableElementId: () => getStableElementId,
56
+ getStyle: () => getStyle,
57
+ handleRef: () => handleRef,
58
+ hasClass: () => hasClass,
59
+ holeContent: () => holeContent,
60
+ holeEnd: () => holeEnd,
61
+ holeScope: () => holeScope,
62
+ hydrate: () => hydrate,
63
+ hydrateAdvancePast: () => hydrateAdvancePast,
64
+ hydrateIslands: () => hydrateIslands,
65
+ initializeIntegration: () => initializeIntegration,
66
+ insert: () => insert,
67
+ insertExpression: () => insertExpression,
68
+ intergartionInitialized: () => intergartionInitialized,
69
+ isAccessor: () => isAccessor,
70
+ isCustomElement: () => isCustomElement,
71
+ isDOMNode: () => isDOMNode,
72
+ isDelegatedEvent: () => isDelegatedEvent,
73
+ isDomElement: () => isDomElement,
74
+ isDomNode: () => isDomNode,
75
+ isDomText: () => isDomText,
76
+ isEventHandler: () => isEventHandler,
77
+ isFunction: () => isFunction,
78
+ isIntegrationInitialized: () => isIntegrationInitialized,
79
+ isJSXTemplate: () => isJSXTemplate,
80
+ isLitTemplateResult: () => isLitTemplateResult,
81
+ isNativeElement: () => isNativeElement,
82
+ isPromise: () => isPromise,
83
+ isReactElement: () => isReactElement,
84
+ isSVGElement: () => isSVGElement,
85
+ isServer: () => isServer,
86
+ isTemplateFactory: () => isTemplateFactory,
87
+ isVisible: () => isVisible,
88
+ iterateFn: () => iterateFn,
89
+ makeArrayFlat: () => makeArrayFlat,
90
+ mergeProps: () => mergeProps,
91
+ observeIntersection: () => observeIntersection,
92
+ observeResize: () => observeResize,
93
+ query: () => query,
94
+ queryAll: () => queryAll,
95
+ registerCreateComponent: () => registerCreateComponent,
96
+ registerGlobal: () => registerGlobal,
97
+ removeAttribute: () => removeAttribute,
98
+ removeChildren: () => removeChildren,
99
+ removeClass: () => removeClass,
100
+ removeDelegatedEventListener: () => removeDelegatedEventListener,
101
+ render: () => render,
102
+ resetIntegration: () => resetIntegration,
103
+ runHydrationAt: () => runHydrationAt,
104
+ runWithoutHydration: () => runWithoutHydration,
105
+ scrollIntoView: () => scrollIntoView,
106
+ setAttribute: () => setAttribute,
107
+ setClassList: () => setClassList,
108
+ setClassName: () => setClassName,
109
+ setDynamicAttribute: () => setDynamicAttribute,
110
+ setDynamicBoolAttribute: () => setDynamicBoolAttribute,
111
+ setDynamicProperty: () => setDynamicProperty,
112
+ setProperty: () => setProperty,
113
+ setServerMode: () => setServerMode,
114
+ setStyle: () => setStyle,
115
+ setStyles: () => setStyles,
116
+ shouldSetAsProperty: () => shouldSetAsProperty,
117
+ splitProps: () => splitProps,
118
+ spread: () => spread,
119
+ templateNode: () => templateNode,
120
+ toAttributeName: () => toAttributeName,
121
+ toggleClass: () => toggleClass,
122
+ waitForElement: () => waitForElement
123
+ });
124
+ module.exports = __toCommonJS(index_exports);
125
+
126
+ // src/lib/dom/utils.ts
127
+ function toAttributeName(key) {
128
+ if (key.startsWith("aria-") || key.startsWith("data-")) {
129
+ return key;
130
+ }
131
+ if (/[A-Z]/.test(key)) {
132
+ return key.replace(/([A-Z])/g, "-$1").toLowerCase();
133
+ }
134
+ return key;
135
+ }
136
+ function isEventHandler(key) {
137
+ return key.startsWith("@") || key.startsWith("on") && key.length > 2;
138
+ }
139
+ function getLitEventName(key) {
140
+ if (key.startsWith("@")) {
141
+ return key.slice(1);
142
+ }
143
+ if (key.startsWith("on")) {
144
+ const eventName = key.slice(2);
145
+ return eventName.toLowerCase();
146
+ }
147
+ return key;
148
+ }
149
+ function shouldSetAsProperty(element, key) {
150
+ const propertyAttributes = /* @__PURE__ */ new Set([
151
+ "checked",
152
+ "value",
153
+ "selected",
154
+ "disabled",
155
+ "readonly",
156
+ "required",
157
+ "multiple",
158
+ "open",
159
+ "contenteditable",
160
+ "draggable",
161
+ "spellcheck"
162
+ ]);
163
+ const elementSpecificProps = {
164
+ input: /* @__PURE__ */ new Set(["value", "checked", "indeterminate"]),
165
+ textarea: /* @__PURE__ */ new Set(["value"]),
166
+ select: /* @__PURE__ */ new Set(["value"]),
167
+ option: /* @__PURE__ */ new Set(["selected", "value"]),
168
+ audio: /* @__PURE__ */ new Set(["volume", "currentTime", "paused"]),
169
+ video: /* @__PURE__ */ new Set(["volume", "currentTime", "paused"]),
170
+ img: /* @__PURE__ */ new Set(["src", "srcset"]),
171
+ iframe: /* @__PURE__ */ new Set(["src"]),
172
+ a: /* @__PURE__ */ new Set(["href"])
173
+ };
174
+ return propertyAttributes.has(key) || elementSpecificProps[element] && elementSpecificProps[element].has(key);
175
+ }
176
+ var VOID_ELEMENTS = /* @__PURE__ */ new Set([
177
+ "area",
178
+ "base",
179
+ "br",
180
+ "col",
181
+ "embed",
182
+ "hr",
183
+ "img",
184
+ "input",
185
+ "link",
186
+ "meta",
187
+ "param",
188
+ "source",
189
+ "track",
190
+ "wbr"
191
+ ]);
192
+ var SVG_ELEMENTS = /* @__PURE__ */ new Set([
193
+ "svg",
194
+ "g",
195
+ "path",
196
+ "circle",
197
+ "rect",
198
+ "line",
199
+ "polyline",
200
+ "polygon",
201
+ "ellipse",
202
+ "text",
203
+ "tspan",
204
+ "use",
205
+ "defs",
206
+ "symbol",
207
+ "mask",
208
+ "clipPath",
209
+ "pattern",
210
+ "linearGradient",
211
+ "radialGradient",
212
+ "stop",
213
+ "filter",
214
+ "feGaussianBlur",
215
+ "feOffset",
216
+ "feMerge",
217
+ "feMergeNode",
218
+ "foreignObject"
219
+ ]);
220
+ var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
221
+ function isCustomElement(element) {
222
+ return element.localName.includes("-");
223
+ }
224
+ function applyElementProp(element, name, value, isSVG = false) {
225
+ if (value == null) {
226
+ element.removeAttribute(name);
227
+ return;
228
+ }
229
+ if (isCustomElement(element)) {
230
+ element[name] = value;
231
+ return;
232
+ }
233
+ setAttribute(element, name, value, isSVG);
234
+ }
235
+ var JSX_PROPERTIES = /* @__PURE__ */ new Set([
236
+ "className",
237
+ "value",
238
+ "checked",
239
+ "selected",
240
+ "innerHTML",
241
+ "innerText",
242
+ "textContent",
243
+ "indeterminate",
244
+ "htmlFor"
245
+ ]);
246
+ function query(selector, root = document) {
247
+ return root.querySelector(selector);
248
+ }
249
+ function queryAll(selector, root = document) {
250
+ return Array.from(root.querySelectorAll(selector));
251
+ }
252
+ function closest(element, selector) {
253
+ return element.closest(selector);
254
+ }
255
+ function addClass(element, ...classes) {
256
+ element.classList.add(...classes);
257
+ }
258
+ function removeClass(element, ...classes) {
259
+ element.classList.remove(...classes);
260
+ }
261
+ function toggleClass(element, ...classes) {
262
+ classes.forEach((cls) => element.classList.toggle(cls));
263
+ }
264
+ function hasClass(element, className) {
265
+ return element.classList.contains(className);
266
+ }
267
+ function setAttribute(element, name, value, isSVG = false) {
268
+ if (value == null || value === false) {
269
+ element.removeAttribute(name);
270
+ return;
271
+ }
272
+ if (value === true) {
273
+ element.setAttribute(name, "");
274
+ return;
275
+ }
276
+ if (typeof value === "object") {
277
+ element.setAttribute(name, JSON.stringify(value));
278
+ return;
279
+ }
280
+ element.setAttribute(name, String(value));
281
+ }
282
+ function getAttribute(element, name) {
283
+ return element.getAttribute(name);
284
+ }
285
+ function removeAttribute(element, name) {
286
+ element.removeAttribute(name);
287
+ }
288
+ function setStyles(element, styles) {
289
+ Object.assign(element.style, styles);
290
+ }
291
+ function getStyle(element, property) {
292
+ return window.getComputedStyle(element).getPropertyValue(property);
293
+ }
294
+ function createElement(tagName, attributes = {}, ...children) {
295
+ const element = document.createElement(tagName);
296
+ Object.entries(attributes).forEach(([key, value]) => {
297
+ if (key === "class" || key === "className") {
298
+ element.className = value;
299
+ } else if (key === "style" && typeof value === "object") {
300
+ setStyles(element, value);
301
+ } else if (key.startsWith("on") && typeof value === "function") {
302
+ const event = key.slice(2).toLowerCase();
303
+ element.addEventListener(event, value);
304
+ } else {
305
+ setAttribute(element, key, value);
306
+ }
307
+ });
308
+ children.forEach((child) => {
309
+ if (typeof child === "string") {
310
+ element.appendChild(document.createTextNode(child));
311
+ } else {
312
+ element.appendChild(child);
313
+ }
314
+ });
315
+ return element;
316
+ }
317
+ function removeChildren(element) {
318
+ while (element.firstChild) {
319
+ element.removeChild(element.firstChild);
320
+ }
321
+ }
322
+ function appendChildren(parent, ...children) {
323
+ children.forEach((child) => {
324
+ if (typeof child === "string") {
325
+ parent.appendChild(document.createTextNode(child));
326
+ } else {
327
+ parent.appendChild(child);
328
+ }
329
+ });
330
+ }
331
+ function isVisible(element) {
332
+ const rect = element.getBoundingClientRect();
333
+ return rect.top >= 0 && rect.left >= 0 && rect.bottom <= window.innerHeight && rect.right <= window.innerWidth;
334
+ }
335
+ function scrollIntoView(element, options = { behavior: "smooth", block: "nearest" }) {
336
+ element.scrollIntoView(options);
337
+ }
338
+ function getOffset(element) {
339
+ const rect = element.getBoundingClientRect();
340
+ return {
341
+ top: rect.top + window.pageYOffset,
342
+ left: rect.left + window.pageXOffset
343
+ };
344
+ }
345
+ function delegate(parent, eventName, selector, handler) {
346
+ const listener = (event) => {
347
+ const target = event.target.closest(selector);
348
+ if (target && parent.contains(target)) {
349
+ handler(event, target);
350
+ }
351
+ };
352
+ parent.addEventListener(eventName, listener);
353
+ return () => {
354
+ parent.removeEventListener(eventName, listener);
355
+ };
356
+ }
357
+ function waitForElement(selector, timeout = 5e3) {
358
+ return new Promise((resolve, reject) => {
359
+ const element = query(selector);
360
+ if (element) {
361
+ resolve(element);
362
+ return;
363
+ }
364
+ const observer = new MutationObserver(() => {
365
+ const element2 = query(selector);
366
+ if (element2) {
367
+ observer.disconnect();
368
+ clearTimeout(timeoutId);
369
+ resolve(element2);
370
+ }
371
+ });
372
+ observer.observe(document.body, {
373
+ childList: true,
374
+ subtree: true
375
+ });
376
+ const timeoutId = setTimeout(() => {
377
+ observer.disconnect();
378
+ reject(new Error(`Element ${selector} not found within ${timeout}ms`));
379
+ }, timeout);
380
+ });
381
+ }
382
+ function observeIntersection(element, callback, options = {}) {
383
+ const observer = new IntersectionObserver((entries) => {
384
+ entries.forEach((entry) => {
385
+ callback(entry.isIntersecting);
386
+ });
387
+ }, options);
388
+ observer.observe(element);
389
+ return () => {
390
+ observer.disconnect();
391
+ };
392
+ }
393
+ function observeResize(element, callback) {
394
+ const observer = new ResizeObserver((entries) => {
395
+ entries.forEach(callback);
396
+ });
397
+ observer.observe(element);
398
+ return () => {
399
+ observer.disconnect();
400
+ };
401
+ }
402
+ var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
403
+ function isReactElement(value) {
404
+ return typeof value === "object" && value !== null && value.$$typeof === REACT_ELEMENT_TYPE;
405
+ }
406
+ function isLitTemplateResult(value) {
407
+ return value && typeof value === "object" && value.strings && Array.isArray(value.strings) && value.values && Array.isArray(value.values);
408
+ }
409
+ function isTemplateFactory(value) {
410
+ if (typeof value !== "function") return false;
411
+ try {
412
+ const result = value();
413
+ return isLitTemplateResult(result);
414
+ } catch {
415
+ return false;
416
+ }
417
+ }
418
+ function isJSXTemplate(value) {
419
+ return typeof value === "object" && value !== null && (value.$$typeof === "template" || typeof value.type === "function");
420
+ }
421
+ function isDOMNode(value) {
422
+ return value instanceof Node;
423
+ }
424
+ function registerGlobal(key, value, _Key = "Fluixi") {
425
+ if (typeof globalThis !== "undefined") {
426
+ if (typeof globalThis[_Key] === "undefined") {
427
+ globalThis[_Key] = {};
428
+ }
429
+ if (typeof globalThis[_Key][key] === "undefined") {
430
+ globalThis[_Key][key] = value;
431
+ }
432
+ }
433
+ }
434
+ function getGlobal(key, value, _Key = "Fluixi") {
435
+ if (typeof globalThis !== "undefined") {
436
+ if (typeof globalThis[_Key] !== "undefined") {
437
+ if (typeof globalThis[_Key][key] !== "undefined") {
438
+ return globalThis[_Key][key];
439
+ }
440
+ }
441
+ }
442
+ return value;
443
+ }
444
+
445
+ // src/lib/dom/runtime.ts
446
+ var import_signal2 = require("@fluixi/reactive/signal");
447
+
448
+ // src/version.generated.ts
449
+ var VERSION = "1.0.0-alpha.84";
450
+
451
+ // src/lib/dom/versions.ts
452
+ var import_version = require("@fluixi/reactive/version");
453
+ var import_signal = require("@fluixi/reactive/signal");
454
+ var versions = { dom: VERSION, reactive: import_version.VERSION };
455
+ function stampVersions(container) {
456
+ if (versions.core) container.setAttribute("fluixi", versions.core);
457
+ container.setAttribute("fx-dom", versions.dom);
458
+ container.setAttribute("fx-reactive", versions.reactive);
459
+ if (typeof globalThis !== "undefined") globalThis.Fluixi = versions;
460
+ }
461
+ function warnOnVersionSkew() {
462
+ const builds = (0, import_signal.joinedVersions)();
463
+ if (builds.length > 1) {
464
+ console.warn(
465
+ `[fluixi] ${builds.length} builds of @fluixi/reactive are driving one reactive graph: ${builds.join(", ")}. They share it on purpose, so signals still cross between them, but the oldest one decided what the graph looks like. Build the components on one release, or load them as shared-runtime bundles.`
466
+ );
467
+ }
468
+ const present = [versions.core, versions.dom, versions.reactive].filter(
469
+ (v) => v !== void 0
470
+ );
471
+ if (new Set(present).size <= 1) return;
472
+ console.warn(
473
+ `[fluixi] package versions disagree: core ${versions.core ?? "(absent)"}, dom ${versions.dom}, reactive ${versions.reactive}. These ship as one release, so a mismatch usually means a stale lockfile or two copies resolved side by side. Reinstall, or check for duplicates with \`pnpm why @fluixi/dom\`.`
474
+ );
475
+ }
476
+
477
+ // src/lib/component/modifiers.ts
478
+ function asComponent(value) {
479
+ if (typeof value !== "function") return value;
480
+ Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-component"), { value: true, enumerable: true });
481
+ return value;
482
+ }
483
+ function isComponent(value) {
484
+ return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-component")] === true;
485
+ }
486
+
487
+ // src/lib/dom/runtime.ts
488
+ var import_signal3 = require("@fluixi/reactive/signal");
489
+
490
+ // src/lib/dom/server/host.ts
491
+ var SERVER_NODE = /* @__PURE__ */ Symbol.for("fluixi.server-node");
492
+ var STATE = /* @__PURE__ */ Symbol.for("fluixi.dom.server-host");
493
+ var realm = globalThis;
494
+ var state = realm[STATE] ??= {
495
+ server: typeof document === "undefined",
496
+ nodes: null
497
+ };
498
+ function isServer() {
499
+ return state.server;
500
+ }
501
+ function setServerMode(on) {
502
+ state.server = on;
503
+ }
504
+ function getServerNodes() {
505
+ if (!state.nodes) {
506
+ throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");
507
+ }
508
+ return state.nodes;
509
+ }
510
+ function isDomNode(x) {
511
+ if (x != null && x[SERVER_NODE] === true) return true;
512
+ return typeof Node !== "undefined" && x instanceof Node;
513
+ }
514
+ function isDomElement(x) {
515
+ if (x != null && x[SERVER_NODE] === true) return x.nodeType === 1;
516
+ return typeof Element !== "undefined" && x instanceof Element;
517
+ }
518
+ function isDomText(x) {
519
+ if (x != null && x[SERVER_NODE] === true) return x.nodeType === 3;
520
+ return typeof Text !== "undefined" && x instanceof Text;
521
+ }
522
+
523
+ // src/lib/dom/hydration-state.ts
524
+ var hydration = {
525
+ active: false,
526
+ cursor: null,
527
+ parents: []
528
+ };
529
+ var _walker = null;
530
+ function registerHydrationWalker(walker) {
531
+ _walker = walker;
532
+ }
533
+ function getHydrationWalker() {
534
+ return _walker;
535
+ }
536
+ function isAdopted(parent, node) {
537
+ return hydration.active && node.parentNode === parent;
538
+ }
539
+ function ascendPast(node) {
540
+ const idx = hydration.parents.lastIndexOf(node);
541
+ if (idx !== -1) hydration.parents.length = idx;
542
+ hydration.cursor = node.nextSibling;
543
+ }
544
+ function captureHydrationCursor() {
545
+ return hydration.active ? hydration.cursor : null;
546
+ }
547
+ function runHydrationAt(cursor, fn) {
548
+ if (!cursor || cursor.parentNode == null) return fn();
549
+ const prevActive = hydration.active;
550
+ const prevCursor = hydration.cursor;
551
+ const prevParents = hydration.parents;
552
+ hydration.active = true;
553
+ hydration.cursor = cursor;
554
+ hydration.parents = [];
555
+ try {
556
+ return fn();
557
+ } finally {
558
+ hydration.active = prevActive;
559
+ hydration.cursor = prevCursor;
560
+ hydration.parents = prevParents;
561
+ }
562
+ }
563
+ function runWithoutHydration(fn) {
564
+ if (!hydration.active) return fn();
565
+ const prevCursor = hydration.cursor;
566
+ const prevParents = hydration.parents;
567
+ hydration.active = false;
568
+ hydration.parents = [];
569
+ try {
570
+ return fn();
571
+ } finally {
572
+ hydration.active = true;
573
+ hydration.cursor = prevCursor;
574
+ hydration.parents = prevParents;
575
+ }
576
+ }
577
+ function hydrateAdvancePast(rendered) {
578
+ if (!hydration.active || rendered == null) return;
579
+ const last = Array.isArray(rendered) ? rendered[rendered.length - 1] : rendered;
580
+ if (last && typeof last.nodeType === "number") {
581
+ ascendPast(last);
582
+ }
583
+ }
584
+
585
+ // src/lib/dom/runtime.ts
586
+ function getElementFingerprint(el) {
587
+ const parts = [];
588
+ while (el && el.nodeType === 1) {
589
+ let part = el.tagName.toLowerCase();
590
+ if (el.id) {
591
+ part += `#${el.id}`;
592
+ parts.unshift(part);
593
+ break;
594
+ }
595
+ if (el.getAttribute("data-id")) {
596
+ part += `[data-id="${el.getAttribute("data-id")}"]`;
597
+ }
598
+ let index = 0;
599
+ let sibling = el;
600
+ while (sibling = sibling.previousElementSibling) {
601
+ if (sibling.tagName === el.tagName) index++;
602
+ }
603
+ part += `:nth-of-type(${index + 1})`;
604
+ parts.unshift(part);
605
+ el = el.parentElement;
606
+ }
607
+ return parts.join(">");
608
+ }
609
+ function hashString(str) {
610
+ let hash = 0;
611
+ for (let i = 0; i < str.length; i++) {
612
+ hash = (hash << 5) - hash + str.charCodeAt(i);
613
+ hash |= 0;
614
+ }
615
+ return `el_${Math.abs(hash)}`;
616
+ }
617
+ function getStableElementId(el) {
618
+ return hashString(getElementFingerprint(el));
619
+ }
620
+ var generateID = () => {
621
+ return "xxyxxxxxxy-4xx8".replace(/[xy]/g, function(c) {
622
+ let r = Math.random() * 16 | 0;
623
+ let v = c === "x" ? r : r & 3 | 8;
624
+ return v.toString(16);
625
+ });
626
+ };
627
+ var EMPTY_OBJ = {};
628
+ var HOLE_TAG = "__fx_at";
629
+ var LOC_TAG = "__fx_loc";
630
+ function located(element, at) {
631
+ if (at) element[LOC_TAG] = at;
632
+ return element;
633
+ }
634
+ var templateCache = /* @__PURE__ */ new Map();
635
+ var delegatedSet = /* @__PURE__ */ new Set();
636
+ var NON_DELEGATED = /* @__PURE__ */ new Set(["scroll", "focus", "blur", "load", "error", "resize", "mouseenter", "mouseleave", "pointerenter", "pointerleave", "gotpointercapture", "lostpointercapture"]);
637
+ function delegateEvents(eventNames) {
638
+ if (isServer()) return;
639
+ for (const name of eventNames) {
640
+ if (delegatedSet.has(name) || NON_DELEGATED.has(name)) continue;
641
+ delegatedSet.add(name);
642
+ document.addEventListener(name, delegatedEventHandler);
643
+ }
644
+ }
645
+ function delegatedEventHandler(e) {
646
+ const key = `$$${e.type}`;
647
+ let node = e.composedPath && e.composedPath()[0] || e.target;
648
+ while (node) {
649
+ const handler = node[key];
650
+ if (handler && !node.disabled) {
651
+ handler(e);
652
+ if (e.cancelBubble) return;
653
+ }
654
+ node = node.host && node.host !== node && node.host instanceof Element ? node.host : node.parentNode;
655
+ }
656
+ }
657
+ function addDelegatedEventListener(element, name, handler) {
658
+ element[`$$${name}`] = handler;
659
+ if (NON_DELEGATED.has(name)) {
660
+ const key = `__fx_${name}`;
661
+ if (!element[key]) {
662
+ const forwarder = (e) => {
663
+ element[`$$${name}`]?.(e);
664
+ };
665
+ element.addEventListener(name, forwarder);
666
+ element[key] = forwarder;
667
+ }
668
+ return;
669
+ }
670
+ if (!delegatedSet.has(name)) {
671
+ delegateEvents([name]);
672
+ }
673
+ }
674
+ function removeDelegatedEventListener(element, name) {
675
+ delete element[`$$${name}`];
676
+ const key = `__fx_${name}`;
677
+ const forwarder = element[key];
678
+ if (forwarder) {
679
+ element.removeEventListener(name, forwarder);
680
+ delete element[key];
681
+ }
682
+ }
683
+ function isDelegatedEvent(name) {
684
+ return !NON_DELEGATED.has(name);
685
+ }
686
+ function isFunction(value) {
687
+ return typeof value === "function";
688
+ }
689
+ function createTextNode(value, anchor = false) {
690
+ if (isServer()) return getServerNodes().createText(value);
691
+ if (hydration.active && !anchor) {
692
+ const node = getHydrationWalker()?.hydrateText(value);
693
+ if (node) return node;
694
+ }
695
+ return document.createTextNode(value);
696
+ }
697
+ function createNativeElement(tag, isSVG = false, at) {
698
+ if (isServer()) return getServerNodes().createElement(tag, isSVG);
699
+ if (hydration.active) {
700
+ const node = getHydrationWalker()?.hydrateElement(tag);
701
+ if (node) return at ? located(node, at) : node;
702
+ }
703
+ return located(
704
+ isSVG ? document.createElementNS(SVG_NAMESPACE, tag) : document.createElement(tag),
705
+ at
706
+ );
707
+ }
708
+ function createTemplate(html, isSVG = false) {
709
+ const cached = templateCache.get(html);
710
+ if (cached) return cached;
711
+ const template = document.createElement("template");
712
+ if (isSVG) {
713
+ template.innerHTML = `<svg>${html}</svg>`;
714
+ } else {
715
+ template.innerHTML = html;
716
+ }
717
+ templateCache.set(html, template);
718
+ return template;
719
+ }
720
+ function templateNode(html, tag, holes = false, isSVG = false, at) {
721
+ if (isServer()) {
722
+ const nodes = getServerNodes();
723
+ return holes ? nodes.parseTemplate(html, isSVG) : nodes.createRaw(html);
724
+ }
725
+ if (hydration.active) {
726
+ const node = getHydrationWalker()?.hydrateStatic(tag);
727
+ if (node) return stampPositions(node, at);
728
+ }
729
+ return stampPositions(cloneTemplate(createTemplate(html, isSVG), isSVG).firstChild, at);
730
+ }
731
+ function stampPositions(node, at) {
732
+ const root = node;
733
+ if (!at || typeof root?.querySelectorAll !== "function") return node;
734
+ const all = [root, ...root.querySelectorAll("*")];
735
+ for (let i = 0; i < all.length && i * 2 + 1 < at.pos.length; i++) {
736
+ const line = at.pos[i * 2];
737
+ if (line) all[i][LOC_TAG] = { file: at.file, line, column: at.pos[i * 2 + 1] };
738
+ }
739
+ return node;
740
+ }
741
+ function holeScope(start, produce) {
742
+ if (!hydration.active) return produce();
743
+ const value = runHydrationAt(start.nextSibling, produce);
744
+ if (typeof value === "function") {
745
+ const accessor = value;
746
+ const wrapped = (...args) => hydration.active ? runHydrationAt(start.nextSibling, () => accessor(...args)) : accessor(...args);
747
+ return carryHoleTag(accessor, wrapped);
748
+ }
749
+ return value;
750
+ }
751
+ function carryHoleTag(from, to) {
752
+ const tag = from[HOLE_TAG];
753
+ if (tag !== void 0) to[HOLE_TAG] = tag;
754
+ return to;
755
+ }
756
+ function holeEnd(start) {
757
+ for (let n = start.nextSibling; n; n = n.nextSibling) {
758
+ if (n.nodeType === 8 && n.data === "fx/") return n;
759
+ }
760
+ throw new Error("[fluixi] template hole is missing its closing marker");
761
+ }
762
+ function holeContent(start, end) {
763
+ const nodes = [];
764
+ for (let n = start.nextSibling; n && n !== end; n = n.nextSibling) nodes.push(n);
765
+ return nodes;
766
+ }
767
+ function cloneTemplate(template, isSVG = false) {
768
+ const clone = template.content.cloneNode(true);
769
+ if (isSVG) return clone.firstChild;
770
+ return clone;
771
+ }
772
+ function makeArrayFlat(values) {
773
+ if (!Array.isArray(values)) return values;
774
+ if (values.length === 2 && values[1] === " ") {
775
+ if (Array.isArray(values[0])) return makeArrayFlat(values[0]);
776
+ if (typeof values[0] === "function") return values[0];
777
+ return values[0];
778
+ }
779
+ if (values.length === 1 && typeof values[0] === "function") return values[0];
780
+ return values;
781
+ }
782
+ function fnName(fn) {
783
+ if (typeof fn !== "function") return null;
784
+ return fn._name || fn.name || "anonymous";
785
+ }
786
+ function iterateFn(item) {
787
+ if ((0, import_signal2.isSignal)(item)) return item;
788
+ if (isComponent(item)) return item;
789
+ if (typeof item !== "function") return item;
790
+ let content = item();
791
+ while (typeof content === "function" && !(0, import_signal2.isSignal)(content) && !isComponent(content)) {
792
+ content = content();
793
+ }
794
+ return content;
795
+ }
796
+ var _insertDepth = 0;
797
+ var MAX_INSERT_DEPTH = 200;
798
+ function _createInsertEffect(getAccessor, parent, marker, initialCurrent, setCurrent) {
799
+ let current = initialCurrent;
800
+ const componentCache = /* @__PURE__ */ new Map();
801
+ return (0, import_signal3.createRenderEffect)(() => {
802
+ (0, import_signal3.reportReactiveBinding)(marker ?? parent, "content", void 0, getAccessor);
803
+ let value;
804
+ if (isComponent(getAccessor) && !(0, import_signal2.isSignal)(getAccessor)) {
805
+ if (!componentCache.has(getAccessor)) {
806
+ _insertDepth++;
807
+ try {
808
+ const inst = getAccessor();
809
+ componentCache.set(getAccessor, inst);
810
+ } finally {
811
+ _insertDepth--;
812
+ }
813
+ }
814
+ value = componentCache.get(getAccessor);
815
+ while (typeof value === "function" && (0, import_signal2.isSignal)(value)) value = value();
816
+ } else {
817
+ value = getAccessor();
818
+ while (typeof value === "function" && (0, import_signal2.isSignal)(value)) {
819
+ value = value();
820
+ }
821
+ }
822
+ {
823
+ let chainDepth = 0;
824
+ while (typeof value === "function" && chainDepth++ < 50) {
825
+ if (isComponent(value)) {
826
+ if (!componentCache.has(value)) {
827
+ const thunk = value;
828
+ _insertDepth++;
829
+ try {
830
+ const inst = thunk();
831
+ componentCache.set(thunk, inst);
832
+ } finally {
833
+ _insertDepth--;
834
+ }
835
+ }
836
+ value = componentCache.get(value);
837
+ } else if ((0, import_signal2.isSignal)(value)) {
838
+ value = value();
839
+ } else {
840
+ value = value();
841
+ if (typeof value !== "function" || !(0, import_signal2.isSignal)(value) && !isComponent(value)) break;
842
+ }
843
+ }
844
+ }
845
+ _insertDepth++;
846
+ try {
847
+ current = insertExpression(parent, value, marker, current, componentCache);
848
+ setCurrent(current);
849
+ } finally {
850
+ _insertDepth--;
851
+ }
852
+ });
853
+ }
854
+ function insert(parent, accessor, marker, init) {
855
+ if (_insertDepth > MAX_INSERT_DEPTH) {
856
+ console.error("[insert] Exceeded max call depth, possible infinite loop.");
857
+ return () => null;
858
+ }
859
+ if (marker !== void 0 && !marker) {
860
+ marker = createTextNode("", true);
861
+ parent.appendChild(marker);
862
+ }
863
+ let current = init ?? null;
864
+ const isReactiveArray = (element) => {
865
+ return Array.isArray(element) && element.some((v) => typeof v === "function");
866
+ };
867
+ const normalizeAccessor = (accessor2) => {
868
+ if (typeof accessor2 === "function") return accessor2;
869
+ return () => accessor2;
870
+ };
871
+ if (typeof accessor !== "function" && !isReactiveArray(accessor)) {
872
+ _insertDepth++;
873
+ try {
874
+ current = insertExpression(parent, accessor, marker, current);
875
+ } finally {
876
+ _insertDepth--;
877
+ }
878
+ return () => current;
879
+ }
880
+ const dispose = _createInsertEffect(
881
+ normalizeAccessor(accessor),
882
+ parent,
883
+ marker,
884
+ current,
885
+ (v) => {
886
+ current = v;
887
+ }
888
+ );
889
+ return () => {
890
+ dispose?.();
891
+ return current;
892
+ };
893
+ }
894
+ function insertExpression(parent, value, marker, current, componentCache) {
895
+ if (value == null || typeof value === "boolean") {
896
+ return cleanChildren(parent, current, marker);
897
+ }
898
+ if (typeof value === "function") {
899
+ while (typeof value === "function") {
900
+ value = value();
901
+ }
902
+ }
903
+ if (value == null || typeof value === "boolean") {
904
+ return cleanChildren(parent, current, marker);
905
+ }
906
+ if (isPromise(value)) {
907
+ const placeholder = createTextNode("", true);
908
+ if (Array.isArray(current)) {
909
+ if (current.length > 0) {
910
+ parent.replaceChild(placeholder, current[0]);
911
+ cleanChildren(parent, current.slice(1), marker);
912
+ } else {
913
+ insertBefore(parent, placeholder, marker);
914
+ }
915
+ } else if (current) {
916
+ parent.replaceChild(placeholder, current);
917
+ } else {
918
+ insertBefore(parent, placeholder, marker);
919
+ }
920
+ value.then((resolved) => {
921
+ if (placeholder.parentNode === parent) {
922
+ insertExpression(parent, resolved, placeholder.nextSibling, placeholder);
923
+ }
924
+ }).catch((err) => {
925
+ console.error("Error resolving promise in insertExpression:", err);
926
+ });
927
+ return placeholder;
928
+ }
929
+ const t = typeof value;
930
+ if (t === "string" || t === "number") {
931
+ if (t === "number") value = String(value);
932
+ if (Array.isArray(current)) {
933
+ if (current.length === 0) {
934
+ const node2 = createTextNode(value);
935
+ insertBefore(parent, node2, marker);
936
+ return node2;
937
+ }
938
+ if (current.length === 1 && current[0].nodeType === 3) {
939
+ current[0].data = value;
940
+ return current;
941
+ }
942
+ current = cleanChildren(parent, current, marker);
943
+ }
944
+ if (current && isDomText(current)) {
945
+ current.data = value;
946
+ return current;
947
+ }
948
+ const node = createTextNode(value);
949
+ if (current && current.parentNode === parent) {
950
+ parent.replaceChild(node, current);
951
+ } else if (!isAdopted(parent, node)) {
952
+ insertBefore(parent, node, marker);
953
+ }
954
+ return node;
955
+ }
956
+ if (isDomNode(value)) {
957
+ if (isAdopted(parent, value)) {
958
+ ascendPast(value);
959
+ return value;
960
+ }
961
+ if (Array.isArray(current)) {
962
+ if (current.length === 0) {
963
+ insertBefore(parent, value, marker);
964
+ } else if (current[0].parentNode === parent) {
965
+ parent.replaceChild(value, current[0]);
966
+ cleanChildren(parent, current.slice(1), marker);
967
+ } else {
968
+ insertBefore(parent, value, marker);
969
+ }
970
+ return value;
971
+ }
972
+ if (!current) {
973
+ insertBefore(parent, value, marker);
974
+ } else if (current !== value) {
975
+ if (current.parentNode === parent) {
976
+ parent.replaceChild(value, current);
977
+ } else {
978
+ insertBefore(parent, value, marker);
979
+ }
980
+ }
981
+ return value;
982
+ }
983
+ if (Array.isArray(value)) {
984
+ const array = [];
985
+ const currentArray = Array.isArray(current) ? current : current ? [current] : [];
986
+ const reactiveSlots = [];
987
+ flattenArray(value, array, parent, marker, true, componentCache, reactiveSlots);
988
+ const reconciled = reconcileArrays(parent, currentArray, array, marker);
989
+ for (const slot of reactiveSlots) {
990
+ const disposeSlot = insert(parent, slot.sig, slot.marker);
991
+ (0, import_signal3.onCleanup)(() => {
992
+ cleanChildren(parent, disposeSlot());
993
+ if (slot.marker.parentNode === parent) parent.removeChild(slot.marker);
994
+ });
995
+ }
996
+ return reconciled;
997
+ }
998
+ if (t === "object" && value !== null && typeof value === "object") {
999
+ const objValue = value;
1000
+ if ("type" in objValue && "props" in objValue) {
1001
+ const jsxValue = objValue;
1002
+ if (typeof jsxValue.type === "function") {
1003
+ const result = jsxValue.type(jsxValue.props || {});
1004
+ return insertExpression(parent, result, marker, current);
1005
+ }
1006
+ }
1007
+ }
1008
+ return cleanChildren(parent, current, marker);
1009
+ }
1010
+ function flattenArray(arr, result, parent, marker, track = true, componentCache, reactiveSlots) {
1011
+ for (let i = 0; i < arr.length; i++) {
1012
+ let item = arr[i];
1013
+ if (item == null || typeof item === "boolean") continue;
1014
+ while (typeof item === "function" && !isPromise(item) && !(0, import_signal2.isSignal)(item) && !isComponent(item)) {
1015
+ item = item();
1016
+ if (item == null || typeof item === "boolean") break;
1017
+ }
1018
+ if (item == null || typeof item === "boolean") continue;
1019
+ if (typeof item === "function") {
1020
+ let resolved;
1021
+ if (isComponent(item) && !(0, import_signal2.isSignal)(item)) {
1022
+ if (!componentCache) componentCache = /* @__PURE__ */ new Map();
1023
+ if (!componentCache.has(item)) componentCache.set(item, item());
1024
+ resolved = componentCache.get(item);
1025
+ } else {
1026
+ resolved = item();
1027
+ }
1028
+ while (typeof resolved === "function" && !isPromise(resolved) && !(0, import_signal2.isSignal)(resolved) && !isComponent(resolved)) {
1029
+ if (!componentCache) componentCache = /* @__PURE__ */ new Map();
1030
+ if (!componentCache.has(resolved)) componentCache.set(resolved, resolved());
1031
+ resolved = componentCache.get(resolved);
1032
+ }
1033
+ if (resolved == null || typeof resolved === "boolean") continue;
1034
+ if (typeof resolved === "function") {
1035
+ if ((0, import_signal2.isSignal)(resolved)) {
1036
+ if (reactiveSlots) {
1037
+ const slot = createTextNode("", true);
1038
+ result.push(slot);
1039
+ reactiveSlots.push({ marker: slot, sig: resolved });
1040
+ continue;
1041
+ }
1042
+ let val = resolved();
1043
+ while (typeof val === "function" && (0, import_signal2.isSignal)(val)) val = val();
1044
+ if (val == null || typeof val === "boolean") continue;
1045
+ if (Array.isArray(val)) {
1046
+ flattenArray(val, result, parent, marker, track, componentCache);
1047
+ } else flattenArray([val], result, parent, marker, track, componentCache);
1048
+ continue;
1049
+ }
1050
+ continue;
1051
+ }
1052
+ if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, track, componentCache, reactiveSlots);
1053
+ else flattenArray([resolved], result, parent, marker, track, componentCache, reactiveSlots);
1054
+ continue;
1055
+ }
1056
+ if (isPromise(item)) {
1057
+ const placeholder = createTextNode("", true);
1058
+ result.push(placeholder);
1059
+ item.then((resolved) => {
1060
+ if (placeholder.parentNode) {
1061
+ const tempNodes = [];
1062
+ flattenArray([resolved], tempNodes, placeholder.parentNode, void 0, false, componentCache);
1063
+ if (tempNodes.length > 0) {
1064
+ placeholder.parentNode.replaceChild(tempNodes[0], placeholder);
1065
+ for (let j = 1; j < tempNodes.length; j++) {
1066
+ placeholder.parentNode?.insertBefore(tempNodes[j], tempNodes[j - 1].nextSibling);
1067
+ }
1068
+ }
1069
+ }
1070
+ }).catch((err) => console.error("Error resolving promise in array:", err));
1071
+ continue;
1072
+ }
1073
+ if (Array.isArray(item)) {
1074
+ flattenArray(item, result, parent, marker, track, componentCache, reactiveSlots);
1075
+ continue;
1076
+ }
1077
+ if (isDomNode(item)) {
1078
+ result.push(item);
1079
+ continue;
1080
+ }
1081
+ if (typeof item === "object" && item !== null && "type" in item && "props" in item) {
1082
+ const jsxItem = item;
1083
+ if (typeof jsxItem.type === "function") {
1084
+ const resolved = jsxItem.type(jsxItem.props || {});
1085
+ if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, false, componentCache);
1086
+ else flattenArray([resolved], result, parent, marker, false, componentCache);
1087
+ continue;
1088
+ }
1089
+ }
1090
+ if (typeof item === "string" || typeof item === "number") {
1091
+ const str = String(item);
1092
+ if (str.trim() === "" && str !== " ") continue;
1093
+ result.push(createTextNode(str));
1094
+ continue;
1095
+ }
1096
+ result.push(createTextNode(String(item)));
1097
+ }
1098
+ }
1099
+ function reconcileArrays(parent, a, b, marker) {
1100
+ for (let i = 0; i < b.length; i++) {
1101
+ const owner = b[i].parentNode;
1102
+ if (owner !== null && owner !== parent && owner.nodeType !== 11) {
1103
+ b = b.slice();
1104
+ b[i] = b[i].cloneNode(true);
1105
+ }
1106
+ }
1107
+ let bLength = b.length, aEnd = a.length, bEnd = bLength, aStart = 0, bStart = 0, after = aEnd > 0 ? a[aEnd - 1].nextSibling ?? void 0 : marker, map = null;
1108
+ while (aStart < aEnd || bStart < bEnd) {
1109
+ if (a[aStart] === b[bStart]) {
1110
+ aStart++;
1111
+ bStart++;
1112
+ continue;
1113
+ }
1114
+ while (aEnd > aStart && bEnd > bStart && a[aEnd - 1] === b[bEnd - 1]) {
1115
+ aEnd--;
1116
+ bEnd--;
1117
+ }
1118
+ if (aEnd === aStart) {
1119
+ const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling ?? void 0 : b[bEnd - bStart] : after;
1120
+ while (bStart < bEnd) insertBefore(parent, b[bStart++], node);
1121
+ } else if (bEnd === bStart) {
1122
+ while (aStart < aEnd) {
1123
+ if ((!map || !map.has(a[aStart])) && a[aStart].parentNode === parent)
1124
+ parent.removeChild(a[aStart]);
1125
+ aStart++;
1126
+ }
1127
+ } else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
1128
+ const node = a[--aEnd].nextSibling;
1129
+ insertBefore(parent, b[bStart++], a[aStart++].nextSibling);
1130
+ insertBefore(parent, b[--bEnd], node);
1131
+ a[aEnd] = a[aStart - 1];
1132
+ } else {
1133
+ if (!map) {
1134
+ map = /* @__PURE__ */ new Map();
1135
+ let i = bStart;
1136
+ while (i < bEnd) map.set(b[i], i++);
1137
+ }
1138
+ const index = map.get(a[aStart]);
1139
+ if (index != null) {
1140
+ if (bStart < index && index < bEnd) {
1141
+ let i = aStart, sequence = 1;
1142
+ while (++i < aEnd && i < bEnd) {
1143
+ if (!map.has(a[i]) || map.get(a[i]) !== index + sequence) break;
1144
+ sequence++;
1145
+ }
1146
+ if (sequence > index - bStart) {
1147
+ const node = a[aStart];
1148
+ while (bStart < index) insertBefore(parent, b[bStart++], node);
1149
+ } else {
1150
+ if (a[aStart].parentNode === parent) {
1151
+ parent.replaceChild(b[bStart++], a[aStart++]);
1152
+ } else {
1153
+ insertBefore(parent, b[bStart++], after);
1154
+ aStart++;
1155
+ }
1156
+ }
1157
+ } else {
1158
+ aStart++;
1159
+ }
1160
+ } else {
1161
+ if (a[aStart].parentNode === parent) parent.removeChild(a[aStart]);
1162
+ aStart++;
1163
+ }
1164
+ }
1165
+ }
1166
+ return b;
1167
+ }
1168
+ function cleanChildren(parent, current, marker) {
1169
+ if (current) {
1170
+ if (Array.isArray(current)) {
1171
+ for (let i = 0; i < current.length; i++) {
1172
+ if (current[i].parentNode === parent) parent.removeChild(current[i]);
1173
+ }
1174
+ } else if (current.parentNode === parent) {
1175
+ parent.removeChild(current);
1176
+ }
1177
+ }
1178
+ return null;
1179
+ }
1180
+ function insertBefore(parent, node, marker) {
1181
+ if (hydration.active && node.parentNode === parent) return;
1182
+ if (marker) {
1183
+ if (marker.parentNode === parent) {
1184
+ parent.insertBefore(node, marker);
1185
+ } else {
1186
+ parent.appendChild(node);
1187
+ }
1188
+ } else {
1189
+ parent.appendChild(node);
1190
+ }
1191
+ }
1192
+ function setProperty(element, name, value) {
1193
+ if (value == null) delete element[name];
1194
+ else element[name] = value;
1195
+ }
1196
+ function addNativeEventListener(element, name, value) {
1197
+ let handler = value;
1198
+ let options;
1199
+ if (Array.isArray(value)) {
1200
+ handler = value[0];
1201
+ options = value[1];
1202
+ }
1203
+ if (typeof handler !== "function") return () => {
1204
+ };
1205
+ element.addEventListener(name, handler, options);
1206
+ return () => element.removeEventListener(name, handler, options);
1207
+ }
1208
+ function reportMarked(element, accessor) {
1209
+ if (!accessor || typeof accessor !== "function") return;
1210
+ const written = accessor[HOLE_TAG]?.name;
1211
+ if (!written) return;
1212
+ const colon = written.indexOf(":");
1213
+ if (colon === -1) return;
1214
+ (0, import_signal3.reportReactiveDirective)(element, written.slice(0, colon), written.slice(colon + 1), accessor);
1215
+ }
1216
+ function reportKeys(element, kind, value) {
1217
+ const from = typeof value === "function" ? (0, import_signal3.untrack)(() => value()) : value;
1218
+ if (!from || typeof from !== "object") return;
1219
+ for (const key of Object.keys(from)) (0, import_signal3.reportReactiveDirective)(element, kind, key);
1220
+ }
1221
+ function applyUse(element, value) {
1222
+ const call = (dir, accessor) => {
1223
+ if (typeof dir !== "function") return;
1224
+ (0, import_signal3.reportReactiveDirective)(element, "use", dir.name || "use", accessor);
1225
+ dir(element, accessor ?? (() => void 0));
1226
+ };
1227
+ if (typeof value === "function") {
1228
+ call(value);
1229
+ return;
1230
+ }
1231
+ if (!Array.isArray(value)) return;
1232
+ if (typeof value[0] === "function") {
1233
+ call(value[0], value[1]);
1234
+ return;
1235
+ }
1236
+ for (const pair of value) {
1237
+ if (Array.isArray(pair)) call(pair[0], pair[1]);
1238
+ else call(pair);
1239
+ }
1240
+ }
1241
+ function setDynamicAttribute(element, name, accessor, isSVG = false) {
1242
+ reportMarked(element, accessor);
1243
+ if (typeof accessor !== "function") {
1244
+ setAttribute(element, name, accessor, isSVG);
1245
+ return () => {
1246
+ };
1247
+ }
1248
+ return (0, import_signal3.createRenderEffect)(() => {
1249
+ (0, import_signal3.reportReactiveBinding)(element, "attribute", name, accessor);
1250
+ const value = typeof accessor === "function" ? accessor() : accessor;
1251
+ setAttribute(element, name, value, isSVG);
1252
+ });
1253
+ }
1254
+ function setDynamicProperty(element, name, accessor) {
1255
+ if (typeof accessor !== "function") {
1256
+ setProperty(element, name, accessor);
1257
+ return () => {
1258
+ };
1259
+ }
1260
+ reportMarked(element, accessor);
1261
+ return (0, import_signal3.createRenderEffect)(() => {
1262
+ (0, import_signal3.reportReactiveBinding)(element, "property", name, accessor);
1263
+ const value = typeof accessor === "function" ? accessor() : accessor;
1264
+ setProperty(element, name, value);
1265
+ });
1266
+ }
1267
+ function setDynamicBoolAttribute(element, name, accessor) {
1268
+ if (typeof accessor !== "function") {
1269
+ setAttribute(element, name, !!accessor);
1270
+ return () => {
1271
+ };
1272
+ }
1273
+ return (0, import_signal3.createRenderEffect)(() => {
1274
+ (0, import_signal3.reportReactiveBinding)(element, "attribute", name, accessor);
1275
+ const value = accessor();
1276
+ setAttribute(element, name, !!value);
1277
+ });
1278
+ }
1279
+ function setClassName(element, value) {
1280
+ if (value == null) {
1281
+ element.removeAttribute("class");
1282
+ return;
1283
+ }
1284
+ if (typeof value === "function") {
1285
+ (0, import_signal3.createRenderEffect)(() => {
1286
+ (0, import_signal3.reportReactiveBinding)(element, "attribute", "class", value);
1287
+ setClassName(element, value());
1288
+ });
1289
+ return;
1290
+ }
1291
+ if (typeof value === "string") {
1292
+ element.setAttribute("class", value);
1293
+ return;
1294
+ }
1295
+ if (Array.isArray(value)) {
1296
+ element.setAttribute("class", value.filter(Boolean).join(" "));
1297
+ return;
1298
+ }
1299
+ if (typeof value === "object") {
1300
+ const classes = Object.keys(value).filter((key) => {
1301
+ const v = value[key];
1302
+ return typeof v === "function" ? v() : Boolean(v);
1303
+ }).join(" ");
1304
+ element.setAttribute("class", classes);
1305
+ return;
1306
+ }
1307
+ element.setAttribute("class", String(value));
1308
+ }
1309
+ function setClassList(element, value, disposers) {
1310
+ if (!value || typeof value !== "object") return;
1311
+ for (const name in value) {
1312
+ const cond = value[name];
1313
+ const names = name.split(/\s+/).filter(Boolean);
1314
+ if (typeof cond === "function" && disposers) {
1315
+ disposers.push(
1316
+ (0, import_signal3.createRenderEffect)(() => {
1317
+ const on = !!cond();
1318
+ for (const n of names) element.classList.toggle(n, on);
1319
+ })
1320
+ );
1321
+ } else {
1322
+ const on = !!(typeof cond === "function" ? cond() : cond);
1323
+ for (const n of names) element.classList.toggle(n, on);
1324
+ }
1325
+ }
1326
+ }
1327
+ function setStyle(element, _value) {
1328
+ let value = _value;
1329
+ while (typeof value === "function") value = value();
1330
+ if (value == null) {
1331
+ element.removeAttribute("style");
1332
+ return;
1333
+ }
1334
+ if (typeof value === "string") {
1335
+ element.style.cssText = value;
1336
+ return;
1337
+ }
1338
+ if (typeof value === "object") {
1339
+ for (const key in value) {
1340
+ const styleValue = value[key];
1341
+ if (styleValue == null) element.style[key] = "";
1342
+ else element.style[key] = styleValue;
1343
+ }
1344
+ }
1345
+ }
1346
+ function spread(options) {
1347
+ const {
1348
+ element,
1349
+ props,
1350
+ prevProps = EMPTY_OBJ,
1351
+ isSVG = false,
1352
+ skipChildren = false
1353
+ } = options;
1354
+ if (!element || !isDomElement(element)) {
1355
+ console.error("[spread] Error: element is not a DOM Element!");
1356
+ return () => {
1357
+ };
1358
+ }
1359
+ if (!props) {
1360
+ console.warn("[spread] Warning: props is undefined!");
1361
+ return () => {
1362
+ };
1363
+ }
1364
+ const elementIsSVG = isSVG || element.namespaceURI === SVG_NAMESPACE;
1365
+ const disposers = [];
1366
+ for (const key in props) {
1367
+ if (skipChildren && key === "children") continue;
1368
+ const value = props[key];
1369
+ const prev = prevProps[key];
1370
+ if (value === prev) continue;
1371
+ if (key === "ref") {
1372
+ handleRef(value, element);
1373
+ continue;
1374
+ }
1375
+ if (key === "use") {
1376
+ applyUse(element, value);
1377
+ continue;
1378
+ }
1379
+ if (key.startsWith("on:")) {
1380
+ disposers.push(addNativeEventListener(element, key.slice(3), value));
1381
+ continue;
1382
+ }
1383
+ if (key.startsWith("prop:")) {
1384
+ (0, import_signal3.reportReactiveDirective)(element, "prop", key.slice(5), value);
1385
+ disposers.push(setDynamicProperty(element, key.slice(5), value));
1386
+ continue;
1387
+ }
1388
+ if (key.startsWith("attr:")) {
1389
+ (0, import_signal3.reportReactiveDirective)(element, "attr", key.slice(5), value);
1390
+ disposers.push(setDynamicAttribute(element, key.slice(5), value, elementIsSVG));
1391
+ continue;
1392
+ }
1393
+ if (key.startsWith("bool:")) {
1394
+ (0, import_signal3.reportReactiveDirective)(element, "bool", key.slice(5), value);
1395
+ disposers.push(setDynamicBoolAttribute(element, key.slice(5), value));
1396
+ continue;
1397
+ }
1398
+ if (key === "class" || key === "className") {
1399
+ if (typeof value === "function") {
1400
+ disposers.push(
1401
+ (0, import_signal3.createRenderEffect)(() => {
1402
+ (0, import_signal3.reportReactiveBinding)(element, "attribute", "class", value);
1403
+ setClassName(element, value());
1404
+ })
1405
+ );
1406
+ } else {
1407
+ setClassName(element, value);
1408
+ }
1409
+ continue;
1410
+ }
1411
+ if (key === "classList") {
1412
+ reportKeys(element, "class", value);
1413
+ if (typeof value === "function") {
1414
+ disposers.push(
1415
+ (0, import_signal3.createRenderEffect)(() => {
1416
+ (0, import_signal3.reportReactiveBinding)(element, "attribute", "class", value);
1417
+ setClassList(element, value());
1418
+ })
1419
+ );
1420
+ } else {
1421
+ setClassList(element, value, disposers);
1422
+ }
1423
+ continue;
1424
+ }
1425
+ if (key === "style") {
1426
+ reportKeys(element, "style", value);
1427
+ if (typeof value === "function") {
1428
+ disposers.push(
1429
+ (0, import_signal3.createRenderEffect)(() => {
1430
+ (0, import_signal3.reportReactiveBinding)(element, "attribute", "style", value);
1431
+ setStyle(element, value());
1432
+ })
1433
+ );
1434
+ } else {
1435
+ setStyle(element, value);
1436
+ }
1437
+ continue;
1438
+ }
1439
+ if (key.startsWith("on")) {
1440
+ const eventName = key.slice(2).toLowerCase();
1441
+ if (prev) removeDelegatedEventListener(element, eventName);
1442
+ if (value) addDelegatedEventListener(element, eventName, value);
1443
+ continue;
1444
+ }
1445
+ const asProperty = JSX_PROPERTIES.has(key) || !elementIsSVG && key in element;
1446
+ if (typeof value === "function") {
1447
+ disposers.push(
1448
+ asProperty ? setDynamicProperty(element, key, value) : setDynamicAttribute(element, key, value, elementIsSVG)
1449
+ );
1450
+ } else {
1451
+ disposers.push(
1452
+ (0, import_signal3.createRenderEffect)(
1453
+ () => asProperty ? setProperty(element, key, props[key]) : setAttribute(element, key, props[key], elementIsSVG)
1454
+ )
1455
+ );
1456
+ }
1457
+ }
1458
+ for (const key in prevProps) {
1459
+ if (!(key in props)) {
1460
+ if (key.startsWith("on")) {
1461
+ const eventName = key.slice(2).toLowerCase();
1462
+ removeDelegatedEventListener(element, eventName);
1463
+ } else if (JSX_PROPERTIES.has(key)) {
1464
+ setProperty(element, key, null);
1465
+ } else {
1466
+ element.removeAttribute(key);
1467
+ }
1468
+ }
1469
+ }
1470
+ return () => {
1471
+ disposers.forEach((d) => d());
1472
+ };
1473
+ }
1474
+ function applyProps(element, props, isSVG = false) {
1475
+ for (const key in props) {
1476
+ const val = props[key];
1477
+ if (key === "ref") {
1478
+ handleRef(val, element);
1479
+ continue;
1480
+ }
1481
+ if (key === "children") continue;
1482
+ if (key === "use") {
1483
+ applyUse(element, val);
1484
+ continue;
1485
+ }
1486
+ if (key.startsWith("on:")) {
1487
+ addNativeEventListener(element, key.slice(3), val);
1488
+ continue;
1489
+ }
1490
+ if (key.startsWith("prop:")) {
1491
+ (0, import_signal3.reportReactiveDirective)(element, "prop", key.slice(5), val);
1492
+ setDynamicProperty(element, key.slice(5), val);
1493
+ continue;
1494
+ }
1495
+ if (key.startsWith("attr:")) {
1496
+ (0, import_signal3.reportReactiveDirective)(element, "attr", key.slice(5), val);
1497
+ setDynamicAttribute(element, key.slice(5), val, isSVG);
1498
+ continue;
1499
+ }
1500
+ if (key.startsWith("bool:")) {
1501
+ (0, import_signal3.reportReactiveDirective)(element, "bool", key.slice(5), val);
1502
+ setDynamicBoolAttribute(element, key.slice(5), val);
1503
+ continue;
1504
+ }
1505
+ if (key.startsWith("on") && key.length > 2) {
1506
+ const name = key.slice(2).toLowerCase();
1507
+ if (typeof val === "function") {
1508
+ if (NON_DELEGATED.has(name)) {
1509
+ element[`$$${name}`] = val;
1510
+ const listenerKey = `__fx_${name}`;
1511
+ if (!element[listenerKey]) {
1512
+ const forwarder = (e) => {
1513
+ element[`$$${name}`]?.(e);
1514
+ };
1515
+ element.addEventListener(name, forwarder);
1516
+ element[listenerKey] = forwarder;
1517
+ }
1518
+ } else {
1519
+ element[`$$${name}`] = val;
1520
+ if (!delegatedSet.has(name)) delegateEvents([name]);
1521
+ }
1522
+ }
1523
+ continue;
1524
+ }
1525
+ if (key === "class" || key === "className") {
1526
+ setClassName(element, val);
1527
+ continue;
1528
+ }
1529
+ if (key === "classList") {
1530
+ reportKeys(element, "class", val);
1531
+ if (typeof val === "function")
1532
+ (0, import_signal3.createRenderEffect)(() => {
1533
+ (0, import_signal3.reportReactiveBinding)(element, "attribute", "class", val);
1534
+ setClassList(element, val());
1535
+ });
1536
+ else setClassList(element, val);
1537
+ continue;
1538
+ }
1539
+ if (key === "style") {
1540
+ reportKeys(element, "style", val);
1541
+ if (typeof val === "function")
1542
+ (0, import_signal3.createRenderEffect)(() => {
1543
+ (0, import_signal3.reportReactiveBinding)(element, "attribute", "style", val);
1544
+ setStyle(element, val());
1545
+ });
1546
+ else setStyle(element, val);
1547
+ continue;
1548
+ }
1549
+ if (key === "innerHTML") {
1550
+ if (typeof val === "function") {
1551
+ const dispose = (0, import_signal3.createEffect)(() => {
1552
+ let v = val();
1553
+ while (typeof v === "function") v = v();
1554
+ element.innerHTML = v;
1555
+ });
1556
+ (0, import_signal3.onCleanup)(() => dispose());
1557
+ } else {
1558
+ element.innerHTML = val;
1559
+ }
1560
+ continue;
1561
+ }
1562
+ if (key === "value" && (element.tagName === "INPUT" || element.tagName === "TEXTAREA")) {
1563
+ if (typeof val === "function") {
1564
+ const dispose = (0, import_signal3.createEffect)(() => {
1565
+ let v = val();
1566
+ while (typeof v === "function" && v.length === 0) v = v();
1567
+ if (document.activeElement !== element) {
1568
+ element.value = v ?? "";
1569
+ }
1570
+ });
1571
+ (0, import_signal3.onCleanup)(() => {
1572
+ dispose();
1573
+ });
1574
+ } else {
1575
+ (0, import_signal3.createRenderEffect)(() => {
1576
+ if (document.activeElement !== element) {
1577
+ element.value = props[key] ?? "";
1578
+ }
1579
+ });
1580
+ }
1581
+ continue;
1582
+ }
1583
+ if (key === "checked" && element.tagName === "INPUT") {
1584
+ if (typeof val === "function") {
1585
+ const dispose = (0, import_signal3.createEffect)(() => {
1586
+ let v = val();
1587
+ while (typeof v === "function" && v.length === 0) v = v();
1588
+ if (document.activeElement !== element) {
1589
+ element.checked = v ?? "";
1590
+ }
1591
+ });
1592
+ (0, import_signal3.onCleanup)(() => {
1593
+ dispose();
1594
+ });
1595
+ } else {
1596
+ (0, import_signal3.createRenderEffect)(() => {
1597
+ if (document.activeElement !== element) {
1598
+ element.checked = props[key] ?? "";
1599
+ }
1600
+ });
1601
+ }
1602
+ continue;
1603
+ }
1604
+ if (key === "value" && element.tagName === "SELECT") {
1605
+ if (typeof val === "function") {
1606
+ let firstRun = true;
1607
+ const dispose = (0, import_signal3.createEffect)(() => {
1608
+ let v = val();
1609
+ while (typeof v === "function" && v.length === 0) v = v();
1610
+ if (firstRun) {
1611
+ firstRun = false;
1612
+ queueMicrotask(() => {
1613
+ element.value = v ?? "";
1614
+ });
1615
+ } else {
1616
+ element.value = v ?? "";
1617
+ }
1618
+ });
1619
+ (0, import_signal3.onCleanup)(() => {
1620
+ dispose();
1621
+ });
1622
+ } else {
1623
+ let firstRun = true;
1624
+ (0, import_signal3.createRenderEffect)(() => {
1625
+ const v = props[key];
1626
+ if (firstRun) {
1627
+ firstRun = false;
1628
+ queueMicrotask(() => {
1629
+ element.value = v ?? "";
1630
+ });
1631
+ } else {
1632
+ element.value = v ?? "";
1633
+ }
1634
+ });
1635
+ }
1636
+ continue;
1637
+ }
1638
+ if (typeof val === "function") {
1639
+ const dispose = (0, import_signal3.createEffect)(() => {
1640
+ let v = val();
1641
+ while (typeof v === "function" && v.length === 0) v = v();
1642
+ applyElementProp(element, key, v, isSVG);
1643
+ });
1644
+ (0, import_signal3.onCleanup)(() => {
1645
+ dispose();
1646
+ });
1647
+ } else {
1648
+ (0, import_signal3.createRenderEffect)(() => applyElementProp(element, key, props[key], isSVG));
1649
+ }
1650
+ }
1651
+ }
1652
+ function mergeProps(...sources) {
1653
+ const resolve = (key) => {
1654
+ for (let i = sources.length - 1; i >= 0; i--) {
1655
+ const s = sources[i];
1656
+ if (s && key in s && s[key] !== void 0) return s[key];
1657
+ }
1658
+ return void 0;
1659
+ };
1660
+ const hasKey = (key) => {
1661
+ for (const s of sources) if (s && key in s) return true;
1662
+ return false;
1663
+ };
1664
+ return new Proxy({}, {
1665
+ get: (_, key) => resolve(key),
1666
+ has: (_, key) => hasKey(key),
1667
+ ownKeys: () => {
1668
+ const keys = /* @__PURE__ */ new Set();
1669
+ for (const s of sources) if (s) for (const k of Reflect.ownKeys(s)) keys.add(k);
1670
+ return [...keys];
1671
+ },
1672
+ getOwnPropertyDescriptor: (_, key) => hasKey(key) ? { enumerable: true, configurable: true, get: () => resolve(key) } : void 0
1673
+ });
1674
+ }
1675
+ function splitProps(props, ...keys) {
1676
+ const taken = /* @__PURE__ */ new Set();
1677
+ for (const group of keys) for (const k of group) taken.add(k);
1678
+ const descriptor = (p) => ({
1679
+ enumerable: true,
1680
+ configurable: true,
1681
+ get: () => props[p]
1682
+ });
1683
+ const groups = keys.map((group) => {
1684
+ const keySet = new Set(group);
1685
+ return new Proxy({}, {
1686
+ get: (_, p) => keySet.has(p) ? props[p] : void 0,
1687
+ has: (_, p) => keySet.has(p) && p in props,
1688
+ ownKeys: () => Array.from(keySet).filter((k) => k in props),
1689
+ getOwnPropertyDescriptor: (_, p) => keySet.has(p) && p in props ? descriptor(p) : void 0
1690
+ });
1691
+ });
1692
+ const rest = new Proxy({}, {
1693
+ get: (_, p) => taken.has(p) ? void 0 : props[p],
1694
+ has: (_, p) => !taken.has(p) && p in props,
1695
+ ownKeys: () => Reflect.ownKeys(props).filter((k) => !taken.has(k)),
1696
+ getOwnPropertyDescriptor: (_, p) => !taken.has(p) && p in props ? descriptor(p) : void 0
1697
+ });
1698
+ return [...groups, rest];
1699
+ }
1700
+ function handleRef(ref, element) {
1701
+ if (!ref) return;
1702
+ const held = ref[HOLE_TAG]?.name;
1703
+ (0, import_signal3.reportReactiveDirective)(
1704
+ element,
1705
+ "ref",
1706
+ held || (typeof ref === "function" ? ref.name || "ref" : "ref"),
1707
+ ref
1708
+ );
1709
+ if (isDomNode(ref)) {
1710
+ const actualRef = element;
1711
+ const actualElement = ref;
1712
+ if (!actualRef) return;
1713
+ if (typeof actualRef === "function") actualRef(actualElement);
1714
+ else if (typeof actualRef === "object" && "current" in actualRef) actualRef.current = actualElement;
1715
+ return;
1716
+ }
1717
+ if (typeof ref === "function") ref(element);
1718
+ else if (typeof ref === "object" && "current" in ref) ref.current = element;
1719
+ }
1720
+ function createPortal(children, element, props) {
1721
+ const container = element || document.body;
1722
+ const resolved = (0, import_signal3.readChildren)(() => children);
1723
+ const cleanups = [];
1724
+ (0, import_signal3.batch)(() => {
1725
+ const dispose = (0, import_signal3.createRenderEffect)(() => {
1726
+ const nodes = resolved();
1727
+ if (Array.isArray(nodes)) {
1728
+ nodes.forEach((node) => container.appendChild(node));
1729
+ cleanups.push(() => {
1730
+ nodes.forEach((node) => {
1731
+ if (node.parentNode === container) {
1732
+ container.removeChild(node);
1733
+ }
1734
+ });
1735
+ });
1736
+ } else if (isDomNode(nodes)) {
1737
+ container.appendChild(nodes);
1738
+ cleanups.push(() => {
1739
+ if (nodes.parentNode === container) {
1740
+ container.removeChild(nodes);
1741
+ }
1742
+ });
1743
+ }
1744
+ });
1745
+ cleanups.push(dispose);
1746
+ (0, import_signal3.onCleanup)(() => {
1747
+ cleanups.forEach((fn) => fn());
1748
+ });
1749
+ });
1750
+ return null;
1751
+ }
1752
+ function isNativeElement(tag) {
1753
+ return typeof tag === "string" && tag.toLowerCase() === tag;
1754
+ }
1755
+ function isSVGElement(tag) {
1756
+ return tag === "svg" || tag === "path" || tag === "circle" || tag === "rect" || tag === "line" || tag === "polygon" || tag === "polyline" || tag === "ellipse" || tag === "g" || tag === "defs" || tag === "clipPath" || tag === "text";
1757
+ }
1758
+ function escapeHTML(str) {
1759
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
1760
+ }
1761
+ function isPromise(v) {
1762
+ return v != null && (typeof v === "object" || typeof v === "function") && typeof v.then === "function" || v instanceof Promise;
1763
+ }
1764
+ function isAccessor(value) {
1765
+ return typeof value === "function" && value.length === 0 && (0, import_signal2.isSignal)(value);
1766
+ }
1767
+ function render(element, container, context) {
1768
+ if (!container) {
1769
+ throw new Error("Container element is required");
1770
+ }
1771
+ let rendererDispose;
1772
+ let disposeRoot;
1773
+ const disposers = [];
1774
+ (0, import_signal3.createRoot)((dispose) => {
1775
+ (0, import_signal3.batch)(() => {
1776
+ if (!hydration.active) {
1777
+ container.textContent = "";
1778
+ }
1779
+ stampVersions(container);
1780
+ warnOnVersionSkew();
1781
+ insert(container, element);
1782
+ return;
1783
+ });
1784
+ disposeRoot = dispose;
1785
+ });
1786
+ return () => {
1787
+ disposeRoot?.();
1788
+ rendererDispose?.();
1789
+ disposers.forEach((d) => d());
1790
+ container.textContent = "";
1791
+ };
1792
+ }
1793
+ function bindPair(source) {
1794
+ if (Array.isArray(source)) return source;
1795
+ if (typeof source === "function" && typeof source.set === "function") {
1796
+ return [source, source.set];
1797
+ }
1798
+ throw new TypeError(
1799
+ "[fluixi] bind: needs a signal, either `signal(...)` or the `[get, set]` pair from `createSignal(...)`."
1800
+ );
1801
+ }
1802
+
1803
+ // src/lib/dom/integration.ts
1804
+ var import_reactive = require("@fluixi/reactive");
1805
+ var _slotKey = "__fx_dom_create_component__";
1806
+ var _slot = globalThis[_slotKey] ??= { fn: null };
1807
+ function registerCreateComponent(createComponent2) {
1808
+ _slot.fn = createComponent2;
1809
+ }
1810
+ function initializeIntegration(options = {}) {
1811
+ const cc = options.signalSystem?.createComponent;
1812
+ if (cc) _slot.fn = cc;
1813
+ }
1814
+ function createComponent(Comp, props) {
1815
+ if (_slot.fn) return _slot.fn(Comp, props);
1816
+ if (props) (0, import_reactive.reportReactiveProps)(props);
1817
+ const component = typeof Comp === "function" ? (0, import_reactive.untrack)(() => Comp(props)) : Comp;
1818
+ const nameable = component != null && (typeof component === "function" || typeof component === "object");
1819
+ if (nameable) {
1820
+ try {
1821
+ component["$name"] = Comp?.name;
1822
+ } catch {
1823
+ }
1824
+ }
1825
+ if (nameable && !(0, import_reactive.isSignal)(component)) {
1826
+ return asComponent(component);
1827
+ }
1828
+ return component;
1829
+ }
1830
+ var intergartionInitialized = () => _slot.fn !== null;
1831
+ var isIntegrationInitialized = () => _slot.fn !== null;
1832
+ function resetIntegration() {
1833
+ _slot.fn = null;
1834
+ }
1835
+
1836
+ // src/lib/dom/server/request-context.ts
1837
+ var _current;
1838
+ var syncStore = {
1839
+ getStore: () => _current,
1840
+ run(ctx, fn) {
1841
+ const prev = _current;
1842
+ _current = ctx;
1843
+ try {
1844
+ return fn();
1845
+ } finally {
1846
+ _current = prev;
1847
+ }
1848
+ }
1849
+ };
1850
+ var _store = syncStore;
1851
+ function getRequestContext() {
1852
+ return _store.getStore();
1853
+ }
1854
+
1855
+ // src/lib/dom/hydration.ts
1856
+ var import_signal4 = require("@fluixi/reactive/signal");
1857
+
1858
+ // src/lib/dom/server/fx-data.ts
1859
+ var FX_DATA_ID = "__FX_DATA__";
1860
+ var _scriptCache;
1861
+ function getServerData() {
1862
+ const g = globalThis.__FX_DATA__;
1863
+ if (g) return g;
1864
+ if (_scriptCache !== void 0) return _scriptCache;
1865
+ let parsed = null;
1866
+ if (typeof document !== "undefined") {
1867
+ const text = document.getElementById(FX_DATA_ID)?.textContent;
1868
+ if (text) {
1869
+ try {
1870
+ parsed = JSON.parse(text);
1871
+ } catch {
1872
+ parsed = null;
1873
+ }
1874
+ }
1875
+ }
1876
+ return _scriptCache = parsed;
1877
+ }
1878
+
1879
+ // src/lib/dom/hydration.ts
1880
+ function recoverCursor() {
1881
+ for (; ; ) {
1882
+ while (hydration.cursor && hydration.cursor.nodeType === 3 && hydration.cursor.data === "") {
1883
+ hydration.cursor = hydration.cursor.nextSibling;
1884
+ }
1885
+ if (hydration.cursor != null || !hydration.parents.length) return;
1886
+ hydration.cursor = hydration.parents.pop().nextSibling;
1887
+ }
1888
+ }
1889
+ var VOID_ELEMENTS2 = /* @__PURE__ */ new Set([
1890
+ "area",
1891
+ "base",
1892
+ "br",
1893
+ "col",
1894
+ "embed",
1895
+ "hr",
1896
+ "img",
1897
+ "input",
1898
+ "link",
1899
+ "meta",
1900
+ "param",
1901
+ "source",
1902
+ "track",
1903
+ "wbr"
1904
+ ]);
1905
+ var DEV = typeof process !== "undefined" && process.env && false;
1906
+ function warnMismatch(expected, found) {
1907
+ const f = found.nodeType === 1 ? `<${found.tagName.toLowerCase()}>` : found.nodeType === 3 ? `text ${JSON.stringify((found.nodeValue ?? "").slice(0, 24))}` : found.nodeType === 8 ? "comment" : "node";
1908
+ console.warn(
1909
+ `[fluixi] hydration mismatch: expected ${expected} but the server DOM has ${f}. Server and client rendered different markup; recreating this node on the client. Check for non-deterministic render (Date.now(), Math.random(), browser-only branches, untransported data).`
1910
+ );
1911
+ }
1912
+ function hydrateElement(tag) {
1913
+ recoverCursor();
1914
+ const c = hydration.cursor;
1915
+ if (c && c.nodeType === 1 && c.tagName.toLowerCase() === tag.toLowerCase()) {
1916
+ if (VOID_ELEMENTS2.has(tag.toLowerCase())) {
1917
+ hydration.cursor = c.nextSibling;
1918
+ } else {
1919
+ hydration.parents.push(c);
1920
+ hydration.cursor = c.firstChild;
1921
+ }
1922
+ return c;
1923
+ }
1924
+ if (DEV && c) warnMismatch(`<${tag}>`, c);
1925
+ return null;
1926
+ }
1927
+ function hydrateStatic(tag) {
1928
+ recoverCursor();
1929
+ const c = hydration.cursor;
1930
+ if (c && c.nodeType === 1 && c.tagName.toLowerCase() === tag.toLowerCase()) {
1931
+ hydration.cursor = c.nextSibling;
1932
+ return c;
1933
+ }
1934
+ if (DEV && c) warnMismatch(`<${tag}> (static)`, c);
1935
+ return null;
1936
+ }
1937
+ function hydrateText(value) {
1938
+ if (value === "") {
1939
+ const c2 = hydration.cursor;
1940
+ if (c2 && c2.nodeType === 3 && c2.data !== "") {
1941
+ hydration.cursor = c2.nextSibling;
1942
+ c2.data = "";
1943
+ return c2;
1944
+ }
1945
+ return null;
1946
+ }
1947
+ recoverCursor();
1948
+ const c = hydration.cursor;
1949
+ if (c && c.nodeType === 3) {
1950
+ hydration.cursor = c.nextSibling;
1951
+ if (c.nodeValue !== value) c.nodeValue = value;
1952
+ return c;
1953
+ }
1954
+ if (DEV && c) warnMismatch(`text ${JSON.stringify(value.slice(0, 24))}`, c);
1955
+ return null;
1956
+ }
1957
+ function hydrateMarker(value) {
1958
+ recoverCursor();
1959
+ const c = hydration.cursor;
1960
+ if (c && c.nodeType === 8 && c.data === value) {
1961
+ hydration.cursor = c.nextSibling;
1962
+ return c;
1963
+ }
1964
+ if (DEV && c) warnMismatch(`marker <!--${value.slice(0, 24)}-->`, c);
1965
+ return null;
1966
+ }
1967
+ var _walkerRegistered = false;
1968
+ function ensureWalker() {
1969
+ if (_walkerRegistered) return;
1970
+ _walkerRegistered = true;
1971
+ registerHydrationWalker({ hydrateElement, hydrateText, hydrateMarker, hydrateStatic });
1972
+ }
1973
+ function hydrate(element, container, options) {
1974
+ ensureWalker();
1975
+ hydration.active = true;
1976
+ hydration.cursor = container.firstChild;
1977
+ hydration.parents = [];
1978
+ const data = getServerData();
1979
+ const ns = options?.resourceNamespace;
1980
+ let rid = 0;
1981
+ (0, import_signal4.setResourceIdSource)(() => ns ? `${ns}:r${rid++}` : `r${rid++}`);
1982
+ (0, import_signal4.setServerDataGetter)(data ? (id) => id in data ? { value: data[id] } : void 0 : null);
1983
+ try {
1984
+ return render(element, container);
1985
+ } finally {
1986
+ hydration.active = false;
1987
+ hydration.cursor = null;
1988
+ hydration.parents = [];
1989
+ }
1990
+ }
1991
+
1992
+ // src/lib/dom/island.ts
1993
+ var TAG = "fluixi-island";
1994
+ function Island(props) {
1995
+ const { component, props: cprops = {}, name } = props;
1996
+ const el = createNativeElement(TAG);
1997
+ const islandName = name ?? component.name ?? "Island";
1998
+ setAttribute(el, "name", islandName);
1999
+ setAttribute(el, "props", JSON.stringify(cprops ?? {}));
2000
+ const ctx = isServer() ? getRequestContext() : void 0;
2001
+ if (ctx) {
2002
+ const ns = ctx.nextIslandNamespace(islandName);
2003
+ insert(el, () => ctx.withResourceScope(ns, () => component(cprops)));
2004
+ } else {
2005
+ insert(el, () => component(cprops));
2006
+ }
2007
+ return el;
2008
+ }
2009
+ var _styleInjected = false;
2010
+ function ensureDisplayContents() {
2011
+ if (_styleInjected || typeof document === "undefined") return;
2012
+ _styleInjected = true;
2013
+ const style = document.createElement("style");
2014
+ style.textContent = `${TAG}{display:contents}`;
2015
+ document.head.appendChild(style);
2016
+ }
2017
+ function hydrateIslands(registry) {
2018
+ if (typeof document === "undefined") return;
2019
+ ensureDisplayContents();
2020
+ const els = document.querySelectorAll(TAG);
2021
+ const counts = /* @__PURE__ */ new Map();
2022
+ els.forEach((el) => {
2023
+ const name = el.getAttribute("name") ?? "";
2024
+ const occ = counts.get(name) ?? 0;
2025
+ counts.set(name, occ + 1);
2026
+ const Comp = registry[name];
2027
+ if (!Comp) {
2028
+ if (typeof process === "undefined" || false) {
2029
+ console.warn(`[fluixi] island "${name}" has no component in the registry, left static.`);
2030
+ }
2031
+ return;
2032
+ }
2033
+ let props = {};
2034
+ try {
2035
+ props = JSON.parse(el.getAttribute("props") || "{}");
2036
+ } catch {
2037
+ }
2038
+ hydrate(() => Comp(props), el, { resourceNamespace: `${name}#${occ}` });
2039
+ });
2040
+ }