@mateosuarezdev/flash 0.0.11 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -8,4 +8,4 @@
8
8
  * See LICENSE file for full terms.
9
9
  */
10
10
 
11
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./jsx-dev-runtime-C5Q23IsT.cjs"),L=require("./server-context-BPTFSl-d.cjs");var z=Symbol.for("preact-signals");function E(){if(y>1)y--;else{for(var t,e=!1;S!==void 0;){var n=S;for(S=void 0,A++;n!==void 0;){var i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&K(n))try{n.c()}catch(r){e||(t=r,e=!0)}n=i}}if(A=0,y--,e)throw t}}function R(t){if(y>0)return t();y++;try{return t()}finally{E()}}var c=void 0;function H(t){var e=c;c=void 0;try{return t()}finally{c=e}}var S=void 0,y=0,A=0,w=0;function I(t){if(c!==void 0){var e=t.n;if(e===void 0||e.t!==c)return e={i:0,S:t,p:c.s,n:void 0,t:c,e:void 0,x:void 0,r:e},c.s!==void 0&&(c.s.n=e),c.s=e,t.n=e,32&c.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=c.s,e.n=void 0,c.s.n=e,c.s=e),e}}function u(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}u.prototype.brand=z;u.prototype.h=function(){return!0};u.prototype.S=function(t){var e=this,n=this.t;n!==t&&t.e===void 0&&(t.x=n,this.t=t,n!==void 0?n.e=t:H(function(){var i;(i=e.W)==null||i.call(e)}))};u.prototype.U=function(t){var e=this;if(this.t!==void 0){var n=t.e,i=t.x;n!==void 0&&(n.x=i,t.e=void 0),i!==void 0&&(i.e=n,t.x=void 0),t===this.t&&(this.t=i,i===void 0&&H(function(){var r;(r=e.Z)==null||r.call(e)}))}};u.prototype.subscribe=function(t){var e=this;return g(function(){var n=e.value,i=c;c=void 0;try{t(n)}finally{c=i}},{name:"sub"})};u.prototype.valueOf=function(){return this.value};u.prototype.toString=function(){return this.value+""};u.prototype.toJSON=function(){return this.value};u.prototype.peek=function(){var t=c;c=void 0;try{return this.value}finally{c=t}};Object.defineProperty(u.prototype,"value",{get:function(){var t=I(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(A>100)throw new Error("Cycle detected");this.v=t,this.i++,w++,y++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{E()}}}});function q(t,e){return new u(t,e)}function K(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function V(t){for(var e=t.s;e!==void 0;e=e.n){var n=e.S.n;if(n!==void 0&&(e.r=n),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function G(t){for(var e=t.s,n=void 0;e!==void 0;){var i=e.p;e.i===-1?(e.S.U(e),i!==void 0&&(i.n=e.n),e.n!==void 0&&(e.n.p=i)):n=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=i}t.s=n}function m(t,e){u.call(this,void 0),this.x=t,this.s=void 0,this.g=w-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}m.prototype=new u;m.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===w))return!0;if(this.g=w,this.f|=1,this.i>0&&!K(this))return this.f&=-2,!0;var t=c;try{V(this),c=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return c=t,G(this),this.f&=-2,!0};m.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}u.prototype.S.call(this,t)};m.prototype.U=function(t){if(this.t!==void 0&&(u.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};m.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(m.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=I(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function Z(t,e){return new m(t,e)}function j(t){var e=t.u;if(t.u=void 0,typeof e=="function"){y++;var n=c;c=void 0;try{e()}catch(i){throw t.f&=-2,t.f|=8,x(t),i}finally{c=n,E()}}}function x(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,j(t)}function J(t){if(c!==this)throw new Error("Out-of-order effect");G(this),c=t,this.f&=-2,8&this.f&&x(this),E()}function b(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}b.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{t()}};b.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,j(this),V(this),y++;var t=c;return c=this,J.bind(this,t)};b.prototype.N=function(){2&this.f||(this.f|=2,this.o=S,S=this)};b.prototype.d=function(){this.f|=8,1&this.f||x(this)};b.prototype.dispose=function(){this.d()};function g(t,e){var n=new b(t,e);try{n.c()}catch(r){throw n.d(),r}var i=n.d.bind(n);return i[Symbol.dispose]=i,i}function Q(t){return t instanceof u?t.peek():t}function ee(t){return t instanceof u?t.value:t}function te(t,e){typeof e=="function"?t.value=e():t.value=e}function ne(t){return t instanceof u?()=>t.value:t}function ie(t,e,n=!1){const i=[];for(const[r,s]of Object.entries(e))if(s!=null&&!(r==="children"||r==="key"||r==="autoanimate"||r==="innerHTML")){if(typeof s=="function"&&r!=="ref"&&!r.startsWith("on")&&r!=="viewTransitionName"){const o=g(()=>{const a=s();D(t,r,a,n)});i.push(o);continue}D(t,r,s,n)}return()=>i.forEach(r=>r())}function D(t,e,n,i){if(e==="ref"&&typeof n=="function"){n(t);return}if(e.startsWith("on")&&typeof n=="function"){const r=e.slice(2).toLowerCase();t.addEventListener(r,n);return}if(e==="class"||e==="className"){const r=typeof n=="string"?n:Array.isArray(n)?n.filter(Boolean).join(" "):typeof n=="object"?Object.entries(n).filter(([s,o])=>o).map(([s])=>s).join(" "):"";i?t.setAttribute("class",r):t.className=r;return}if(e==="style"){typeof n=="string"?t.setAttribute("style",n):typeof n=="object"&&n&&Object.assign(t.style,n);return}if(e==="viewTransitionName"){t.style.viewTransitionName=n;return}if(!i&&typeof n=="boolean"){n?t.setAttribute(e,""):t.removeAttribute(e);return}t.setAttribute(e,String(n))}function re(t,e){const n=document.createTextNode(String(e));t.appendChild(n)}function X(t){return{type:"reactive",kind:"ReactiveVNode",fn:t,_id:d.newVNodeId(),_dispose:null,_currentChild:null,_currentDom:null,_placeholder:null,_parent:null,_renderedChildren:[]}}function k(t,e){if(!t&&t!==0)return{vnode:null,dom:null};if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")return{vnode:null,dom:document.createTextNode(String(t))};if(t instanceof Node)return{vnode:null,dom:t};if(typeof t=="object"&&"type"in t){const n=t;n.type!=="reactive"&&(n._parent=e),e._renderedChildren.push(n);const i=_(n);return{vnode:n,dom:i}}return{vnode:null,dom:null}}class M{_cancelled=!1;_cancelCallbacks=[];get cancelled(){return this._cancelled}cancel(){this._cancelled||(this._cancelled=!0,this._cancelCallbacks.forEach(e=>{try{e()}catch(n){console.error("Cancel callback error:",n)}}),this._cancelCallbacks=[])}onCancel(e){this._cancelled?e():this._cancelCallbacks.push(e)}throwIfCancelled(){if(this._cancelled)throw new Error("Operation cancelled")}}async function Y(t,e){if(!t)return;const n=t,i=e||new M;if("_onBeforeExitCallbacks"in n&&n._onBeforeExitCallbacks.length>0)for(const r of n._onBeforeExitCallbacks)try{if(i.cancelled)break;await r(i)}catch(s){console.error("onBeforeExit error:",s)}if("_onUnmountCallbacks"in n&&n._onUnmountCallbacks.length>0&&n._onUnmountCallbacks.forEach(r=>{try{r()}catch(s){console.error("onUnmount error:",s)}}),n.type==="reactive"){const r=n;r._dispose&&(r._dispose(),r._dispose=null)}"_renderedChildren"in n&&n._renderedChildren.forEach(r=>{U(r)})}function U(t){if(!t)return;const e=t,n=new M;if(n.cancel(),"_onBeforeExitCallbacks"in e&&e._onBeforeExitCallbacks.length>0&&e._onBeforeExitCallbacks.forEach(i=>{try{const r=i(n);r instanceof Promise&&r.catch(s=>console.error("onBeforeExit error:",s))}catch(r){console.error("onBeforeExit error:",r)}}),"_onUnmountCallbacks"in e&&e._onUnmountCallbacks.length>0&&e._onUnmountCallbacks.forEach(i=>{try{i()}catch(r){console.error("onUnmount error:",r)}}),e.type==="reactive"){const i=e;i._dispose&&(i._dispose(),i._dispose=null)}"_renderedChildren"in e&&e._renderedChildren.forEach(i=>{U(i)})}let se=0;const p=new WeakMap;async function O(t,e,n){const i=t._placeholder;if(!i?.parentNode)return;const r=t._currentChild,s=t._currentDom;if(oe(r,e)){const f=p.get(t);f&&(f.token.cancel(),p.delete(t)),r&&"_lifecycleState"in r&&(r._lifecycleState="mounted");return}if(s instanceof Text&&n instanceof Text){s.nodeValue!==n.nodeValue&&(s.nodeValue=n.nodeValue),t._currentDom=s,t._currentChild=e,e&&"_lifecycleState"in e&&(e._lifecycleState="mounted"),p.delete(t);return}const o=++se,a=p.get(t);a&&a.token.cancel();const l=new M;if(p.set(t,{id:o,token:l}),r&&"_lifecycleState"in r&&(r._lifecycleState="exiting"),r)try{await Y(r,l)}catch(f){console.error(`ReactiveVNode ${t._id}: Unmount threw:`,f)}const h=p.get(t);if(!(!h||h.id!==o)){if(l.cancelled){p.delete(t);return}r&&"_lifecycleState"in r&&(r._lifecycleState="exited"),s&&s.remove(),n&&i.parentNode.insertBefore(n,i.nextSibling),e&&"_lifecycleState"in e&&(e._lifecycleState="mounted"),t._currentChild=e,t._currentDom=n,p.delete(t)}}function oe(t,e){if(!t||!e||typeof t!="object"||typeof e!="object"||!("type"in t)||!("type"in e))return!1;if(typeof t.type=="function"&&typeof e.type=="function"){if(t.type!==e.type)return!1}else if(typeof t.type=="string"&&typeof e.type=="string"){if(t.type!==e.type)return!1}else return!1;const n="props"in t?t.props?.key:void 0,i="props"in e?e.props?.key:void 0;return n!==i?!1:"_lifecycleState"in t&&t._lifecycleState==="exiting"}function ae(t,e){const n=t._listState;n?ce(t,e,n):le(t,e)}function le(t,e){const n=t._placeholder;if(!n?.parentNode)return;const i=[];for(let r=0;r<e.length;r++){const s=e[r],o=P(s,r),{vnode:a,dom:l}=k(s,t);l&&n.parentNode.appendChild(l),i.push({key:o,vnode:a,dom:l})}t._listState={items:i}}function ce(t,e,n){const i=t._placeholder;if(!i?.parentNode)return;const r=new Map;for(const a of n.items)r.set(a.key,a);const s=new Set,o=[];for(let a=0;a<e.length;a++){const l=e[a],h=P(l,a);s.add(h);const f=r.get(h);f?(o.push(f),r.delete(h)):ue(t,l,o)}r.size>0&&fe(r),de(i,o),t._listState={items:o}}function ue(t,e,n){const i=P(e,n.length),{vnode:r,dom:s}=k(e,t);n.push({key:i,vnode:r,dom:s})}function fe(t){for(const[e,n]of t)n.vnode&&Y(n.vnode),n.dom?.parentNode&&n.dom.parentNode.removeChild(n.dom)}function de(t,e){const n=t.parentNode;if(!n)return;let i=t;for(const r of e)r.dom&&(i.nextSibling!==r.dom&&n.insertBefore(r.dom,i.nextSibling),i=r.dom)}function P(t,e){return t&&typeof t=="object"&&"key"in t?t.key??e:e}function $(t,e,n=null,i=!1){if(!e)return;(Array.isArray(e)?e:[e]).forEach(s=>{if(s){if(Array.isArray(s)&&$(t,s,n,i),typeof s=="string"||typeof s=="number")re(t,s);else if(typeof s=="function"){const o=X(s);o._parent=n,n&&n._renderedChildren.push(o);const a=document.createComment("reactive");t.appendChild(a),o._placeholder=a;const l=g(()=>{const h=s();if(Array.isArray(h))ae(o,h);else{const{vnode:f,dom:T}=k(h,o);O(o,f,T)}});o._dispose=l}else if(s instanceof Node)t.append(s);else if(s&&typeof s=="object"&&"type"in s){const o=s;"type"in o&&o.type!=="reactive"&&(o._parent=n),n&&n._renderedChildren.push(o);const a=_(o,i);a&&t.append(a)}}})}const he="http://www.w3.org/2000/svg";function B(t,e=!1){if(t._dom)return t._dom;const n=e||t.type==="svg",i=n?document.createElementNS(he,t.type):document.createElement(t.type),r=ie(i,t.props,n);return t._onUnmountCallbacks.push(r),t.props.innerHTML!==void 0?i.innerHTML=typeof t.props.innerHTML=="object"?JSON.stringify(t.props.innerHTML):t.props.innerHTML:t.props.children&&$(i,t.props.children,t,n),t._dom=i,t._lifecycleState="mounted",t._onMountCallbacks.length>0&&t._onMountCallbacks.forEach(s=>s()),i}function _(t,e=!1){if("type"in t&&t.type==="reactive")return t._placeholder;if(typeof t.type=="string")return B(t,e);const n=t;d.setCurrentVNode(n);const i=n.type(n.props);if(d.setCurrentVNode(null),!i)return null;let r=null;if(typeof i=="string"||typeof i=="number"||typeof i=="boolean")r=document.createTextNode(String(i));else if(i instanceof Node)n._element=i,r=i;else if(i&&typeof i=="object"&&"type"in i){const s=i;"type"in s&&s.type!=="reactive"&&(s._parent=n,n._renderedChildren.push(s));const o=_(s,e);o&&(n._element=o),r=o}return r&&n._onMountCallbacks.length>0&&n._onMountCallbacks.forEach(s=>{s()}),r&&(n._lifecycleState="mounted"),r}function pe(t,e){const n=t instanceof Node?t:_(t);n&&e.append(n)}function ye(t){return document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null)}function me(t,e="self"){const n=ye(t);return e==="children"&&n.firstChild(),{walker:n,isSVG:!1}}function be(t,e,n,i){if(e==="class"||e==="className"){const r=typeof n=="string"?n:Array.isArray(n)?n.filter(Boolean).join(" "):typeof n=="object"?Object.entries(n).filter(([s,o])=>o).map(([s])=>s).join(" "):"";i?t.setAttribute("class",r):t.className=r;return}if(e==="style"){typeof n=="string"?t.setAttribute("style",n):typeof n=="object"&&n&&Object.assign(t.style,n);return}if(e==="viewTransitionName"){t.style.viewTransitionName=n;return}if(!i&&typeof n=="boolean"){n?t.setAttribute(e,""):t.removeAttribute(e);return}t.setAttribute(e,String(n))}function ge(t,e,n=!1,i){const r=[];for(const[s,o]of Object.entries(e))if(o!=null&&!(s==="children"||s==="key"||s==="autoanimate")){if(s==="ref"&&typeof o=="function"){i&&console.log("→ Attaching ref"),o(t);continue}if(s.startsWith("on")&&typeof o=="function"){const a=s.slice(2).toLowerCase();i&&console.log(`→ Attaching event: ${a}`),t.addEventListener(a,o);continue}if(typeof o=="function"&&s!=="ref"&&s!=="viewTransitionName"){i&&console.log(`→ Reactive prop: ${s}`);const a=g(()=>{const l=o();be(t,s,l,n)});r.push(a);continue}}return()=>r.forEach(s=>s())}function ve(t,e,n=null,i){if(!e)return;const r=Array.isArray(e)?e:[e];if(!i.walker.firstChild()&&r.length>0){console.warn("Hydration mismatch: VNode has children but DOM is empty");return}for(const o of r)!o&&o!==0||_e(o,t,n,i);i.walker.parentNode()}function _e(t,e,n,i){if(!(!t&&t!==0)){if(typeof t=="string"||typeof t=="number"||typeof t=="boolean"){const r=i.walker.currentNode;r.nodeType===Node.TEXT_NODE?(i.debug&&console.log("→ Hydrated text node"),i.walker.nextSibling()):console.warn(`Hydration mismatch: expected text node but found ${r.nodeName}`);return}if(typeof t=="function"){i.debug&&console.log("→ Hydrating reactive child");const r=X(t);r._parent=n,n&&n._renderedChildren.push(r);const s=i.walker.currentNode,o=t();if(o&&typeof o=="object"&&"type"in o){const f=o;v(f,i),r._currentChild=f,r._currentDom=f._dom??f._element}else(typeof o=="string"||typeof o=="number"||typeof o=="boolean")&&(r._currentDom=s),i.walker.nextSibling();const a=document.createComment("reactive");r._currentDom?.parentNode&&r._currentDom.parentNode.insertBefore(a,r._currentDom),r._placeholder=a;let l=!0;const h=g(()=>{const f=t();if(l){l=!1;return}const{vnode:T,dom:W}=k(f,r);O(r,T,W)});r._dispose=h;return}if(t instanceof Node){i.walker.nextSibling();return}if(t&&typeof t=="object"&&"type"in t){const r=t;"type"in r&&r.type!=="reactive"&&r.type!=="suspended"&&(r._parent=n),n&&n._renderedChildren.push(r),v(r,i)}}}function Se(t,e){const n=e.walker.currentNode;if(n.nodeType!==Node.ELEMENT_NODE)return console.warn(`Hydration mismatch: expected element <${t.type}> but found ${n.nodeName}`),F(t,n,e);const i=n,r=i.tagName.toLowerCase();if(r!==t.type.toLowerCase())return console.warn(`Hydration mismatch: expected <${t.type}> but found <${r}>`),F(t,n,e);const s=e.isSVG||t.type==="svg",o=e.isSVG;e.isSVG=s,t._dom=i,e.debug&&console.log(`→ Attached existing <${t.type}> DOM`);const a=ge(i,t.props,s,e.debug);return t._onUnmountCallbacks.push(a),t.props.children&&ve(i,t.props.children,t,e),t._lifecycleState="mounted",t._onMountCallbacks.length>0&&t._onMountCallbacks.forEach(l=>l()),e.isSVG=o,e.walker.nextSibling(),i}function F(t,e,n){n.debug&&console.log(`→ Fallback: rendering <${t.type}> fresh`);const i=e.parentNode,r=e.nextSibling;i?.removeChild(e);const s=B(t,n.isSVG);return i&&(r?i.insertBefore(s,r):i.appendChild(s)),n.walker.nextSibling(),s}function v(t,e){if("type"in t&&t.type==="reactive")return e.debug&&console.log(`Hydrating ReactiveVNode #${t._id}`),Ce(t,e);if("type"in t&&t.type==="suspended")return e.debug&&console.log(`Hydrating SuspendedVNode: ${t._componentName}`),we(t,e);if(typeof t.type=="string")return e.debug&&console.log(`Hydrating <${t.type}>`),Se(t,e);const n=t.type.name||"Anonymous";return e.debug&&console.log(`Hydrating Component: ${n}`),ke(t,e)}function ke(t,e){d.setCurrentVNode(t);const n=t.type(t.props);if(d.setCurrentVNode(null),!n)return null;if(typeof n=="object"&&"type"in n&&n.type==="suspended")return v(n,e);let i=null;if(typeof n=="string"||typeof n=="number"||typeof n=="boolean"){const r=e.walker.currentNode;r.nodeType===Node.TEXT_NODE&&(t._element=r,i=r,e.walker.nextSibling())}else if(n instanceof Node)t._element=n,i=n,e.walker.nextSibling();else if(n&&typeof n=="object"&&"type"in n){const r=n;"type"in r&&r.type!=="reactive"&&(r._parent=t,t._renderedChildren.push(r));const s=v(r,e);s&&(t._element=s),i=s}return i&&t._onMountCallbacks.length>0&&(e.debug&&console.log(`→ Firing ${t._onMountCallbacks.length} onMount callback(s)`),t._onMountCallbacks.forEach(r=>r())),i&&(t._lifecycleState="mounted"),i}function Ce(t,e){const n=t.fn(),i=e.walker.currentNode,r=document.createComment("reactive");if(i.parentNode?.insertBefore(r,i),t._placeholder=r,n&&typeof n=="object"&&"type"in n){const a=n;v(a,e),t._currentChild=a,t._currentDom=a._dom??a._element}else(typeof n=="string"||typeof n=="number"||typeof n=="boolean")&&(t._currentDom=i),e.walker.nextSibling();let s=!0;const o=g(()=>{const a=t.fn();if(s){s=!1,e.debug&&console.log("→ Reactive effect setup (skipping initial)");return}const{vnode:l,dom:h}=k(a,t);O(t,l,h)});return t._dispose=o,t._currentDom}function we(t,e){const n=e.walker.currentNode;if(n.nodeType===Node.ELEMENT_NODE&&n.hasAttribute("data-suspended")){const r=n;return r.getAttribute("data-suspended-state")==="resolved"?(t._state="resolved",e.walker.firstChild(),t.promise.then(o=>{t._state="resolved"}).catch(o=>{t._state="error";const a=typeof t.errorFallback=="function"?t.errorFallback(o):t.errorFallback;r.innerHTML="";const l=C(a,e.isSVG);l&&r.appendChild(l)}),e.walker.parentNode(),e.walker.nextSibling(),r):(t._state="pending",t.promise.then(o=>{t._state="resolved",r.innerHTML="";const a=C(o,e.isSVG);a&&r.appendChild(a)}).catch(o=>{t._state="error";const a=typeof t.errorFallback=="function"?t.errorFallback(o):t.errorFallback;r.innerHTML="";const l=C(a,e.isSVG);l&&r.appendChild(l)}),e.walker.nextSibling(),r)}console.warn("Hydration mismatch: expected suspended container");const i=_(t,e.isSVG);return e.walker.nextSibling(),i}function C(t,e){return!t&&t!==0?null:typeof t=="string"||typeof t=="number"||typeof t=="boolean"?document.createTextNode(String(t)):t instanceof Node?t:typeof t=="object"&&"type"in t?_(t,e):typeof t=="function"?C(t(),e):null}function Ee(t,e,n="self"){const i=me(e,n);v(t,i)}function Te(t,e="Loading...",n="Error"){return i=>({type:"suspended",kind:"SuspendedVNode",promise:t(i),fallback:e,errorFallback:n,_id:d.newVNodeId(),_componentName:t.name||"AsyncComponent",_parent:null,_renderedChildren:[],_currentChild:null,_state:"pending"})}function Ne(t){const e=Symbol("context");return{_id:e,_defaultValue:t,provide(n){if(typeof document>"u"){L.provideServerContext(e,n);return}const i=d.getCurrentVNode();if(!i)throw new Error("context.provide() called outside of component render");i._contextMap||(i._contextMap=new Map),i._contextMap.set(e,n)}}}function Ae(t){if(typeof document>"u")return L.consumeServerContext(t._id,t._defaultValue);const e=d.getCurrentVNode();if(!e)throw new Error("useContext called outside of component render");let n=e;for(;n;){if(n.kind==="VNode"&&n._contextMap?.has(t._id))return n._contextMap.get(t._id);n=n._parent}return t._defaultValue}function xe(t){if(!(typeof document>"u")){if(d.currentVNode===null)throw new Error("onMount must be called inside a component during render");d.currentVNode._onMountCallbacks.push(t)}}function Me(t){if(!(typeof document>"u")){if(d.currentVNode===null)throw new Error("onUnmount must be called inside a component during render");d.currentVNode._onUnmountCallbacks.push(t)}}function Oe(t){if(!(typeof document>"u")){if(d.currentVNode===null)throw new Error("onBeforeExit must be called inside a component during render");d.currentVNode._onBeforeExitCallbacks.push(t)}}function Pe(t){if(!(typeof document>"u"))try{t()}catch(e){console.error(e)}}class De{readCallbacks=new Set;updateCallbacks=new Set;renderCallbacks=new Set;readKeepAlive=new Set;updateKeepAlive=new Set;renderKeepAlive=new Set;isProcessing=!1;frameScheduled=!1;frameId=null;lastTimestamp=0;currentDelta=0;trackFPS;fpsHistorySize;fpsHistory=[];constructor(e={}){this.trackFPS=e.trackFPS??!1,this.fpsHistorySize=e.fpsHistorySize??60}read(e,n=!1){return n?this.readKeepAlive.add(e):this.readCallbacks.add(e),this.scheduleFrame(),e}update(e,n=!1){return n?this.updateKeepAlive.add(e):this.updateCallbacks.add(e),this.scheduleFrame(),e}render(e,n=!1){return n?this.renderKeepAlive.add(e):this.renderCallbacks.add(e),this.scheduleFrame(),e}chain(e){let n,i;"read"in e&&this.readCallbacks.add(r=>{n=e.read(r)}),"update"in e?(this.updateCallbacks.add(r=>{i=e.update(n,r)}),this.renderCallbacks.add(r=>{e.render(i,r)})):this.renderCallbacks.add(r=>{e.render(n,r)}),this.scheduleFrame()}cancel(e){this.readCallbacks.delete(e),this.updateCallbacks.delete(e),this.renderCallbacks.delete(e),this.readKeepAlive.delete(e),this.updateKeepAlive.delete(e),this.renderKeepAlive.delete(e)}cancelAll(){this.frameId!==null&&(cancelAnimationFrame(this.frameId),this.frameId=null),this.readCallbacks.clear(),this.updateCallbacks.clear(),this.renderCallbacks.clear(),this.readKeepAlive.clear(),this.updateKeepAlive.clear(),this.renderKeepAlive.clear(),this.isProcessing=!1,this.frameScheduled=!1,this.lastTimestamp=0,this.currentDelta=0,this.trackFPS&&(this.fpsHistory=[])}get data(){return{timestamp:this.lastTimestamp,delta:this.currentDelta||16.67}}get isRunning(){return this.isProcessing||this.readKeepAlive.size>0||this.updateKeepAlive.size>0||this.renderKeepAlive.size>0}get fps(){return this.trackFPS?this.currentDelta>0?1e3/this.currentDelta:0:(console.warn("FPS tracking is disabled. Enable with { trackFPS: true }"),0)}get averageFps(){if(!this.trackFPS)return console.warn("FPS tracking is disabled. Enable with { trackFPS: true }"),0;if(this.fpsHistory.length===0)return 0;const e=this.fpsHistory.reduce((n,i)=>n+i,0);return Math.round(e/this.fpsHistory.length)}get refreshRate(){return this.trackFPS?Math.round(this.averageFps):(console.warn("FPS tracking is disabled. Enable with { trackFPS: true }"),0)}scheduleFrame(){this.frameScheduled||this.isProcessing||(this.frameScheduled=!0,this.frameId=requestAnimationFrame(e=>{this.processFrame(e)}))}processFrame(e){this.isProcessing=!0,this.frameScheduled=!1,this.lastTimestamp===0?this.currentDelta=16.67:this.currentDelta=e-this.lastTimestamp,this.lastTimestamp=e,this.trackFPS&&this.currentDelta>0&&(this.fpsHistory.push(1e3/this.currentDelta),this.fpsHistory.length>this.fpsHistorySize&&this.fpsHistory.shift());const n=this.data;this.executeCallbacks(this.readCallbacks,n),this.executeCallbacks(this.readKeepAlive,n),this.executeCallbacks(this.updateCallbacks,n),this.executeCallbacks(this.updateKeepAlive,n),this.executeCallbacks(this.renderCallbacks,n),this.executeCallbacks(this.renderKeepAlive,n),this.isProcessing=!1,this.hasKeepAliveCallbacks()&&this.scheduleFrame()}executeCallbacks(e,n){e.forEach(i=>{try{i(n)}catch(r){console.error("Frame callback error:",r)}}),this.isKeepAliveSet(e)||e.clear()}hasKeepAliveCallbacks(){return this.readKeepAlive.size>0||this.updateKeepAlive.size>0||this.renderKeepAlive.size>0}isKeepAliveSet(e){return e===this.readKeepAlive||e===this.updateKeepAlive||e===this.renderKeepAlive}}class Fe{gestureId=0;activeGestures=new Map;disabledGestures=new Map;capturedId;gestureWithPriority=new Map;maxPriority=-1/0;newId(){return++this.gestureId}canStart(e){if(this.capturedId!==void 0)return!1;const n=this.disabledGestures.get(e);return!(n&&n.size>0)}start(e,n,i){return this.canStart(n)?(this.activeGestures.set(e,n),this.gestureWithPriority.set(e,i),this.maxPriority=Math.max(this.maxPriority,i),!0):!1}capture(e,n,i){return!this.activeGestures.has(e)&&!this.start(e,n,i)?!1:i>=this.maxPriority?(this.capturedId=e,this.activeGestures.forEach((r,s)=>{s!==e&&this.release(s)}),!0):(this.release(e),!1)}release(e){const n=this.activeGestures.get(e);this.activeGestures.delete(e);const i=this.gestureWithPriority.get(e);if(this.gestureWithPriority.delete(e),this.capturedId===e&&(this.capturedId=void 0),i===this.maxPriority&&(this.maxPriority=-1/0,this.gestureWithPriority.forEach(r=>{this.maxPriority=Math.max(this.maxPriority,r)})),n){const r=this.disabledGestures.get(n);r&&(r.delete(e),r.size===0&&this.disabledGestures.delete(n))}}disableGesture(e,n){let i=this.disabledGestures.get(e);i||(i=new Set,this.disabledGestures.set(e,i)),i.add(n)}enableGesture(e,n){const i=this.disabledGestures.get(e);i&&(i.delete(n),i.size===0&&this.disabledGestures.delete(e))}createGesture(e,n){const i=this.newId(),r=n.name||"gesture-"+i,s=n.priority??0;return new Le(this,i,e,r,s,n)}}class Le{el;options;details;minTouches;maxTouches;threshold;direction;lastMoveTime=0;prevX=0;prevY=0;initialDistance=0;initialAngle=0;boundOnStart;boundOnMove;boundOnEnd;passive;hasPassedThreshold=!1;controller;id;name;priority;useThreshold;constructor(e,n,i,r,s,o){this.controller=e,this.id=n,this.el=i,this.options=o,this.name=r,this.priority=s*1e3+n,this.minTouches=o.minTouches??1,this.maxTouches=o.maxTouches??1/0,this.passive=o.passive??!0,this.threshold=o.threshold??0,this.direction=o.direction??"all",this.useThreshold=this.threshold>0,this.details={type:this.name,isTracking:!1,startX:0,startY:0,currentX:0,currentY:0,deltaX:0,deltaY:0,velocityX:0,velocityY:0,touchCount:0,scale:1,rotation:0},this.boundOnStart=this.onStart.bind(this),this.boundOnMove=this.onMove.bind(this),this.boundOnEnd=this.onEnd.bind(this)}getDistance(e){if(e.length<2)return 0;const n=e[0].clientX-e[1].clientX,i=e[0].clientY-e[1].clientY;return Math.sqrt(n*n+i*i)}getAngle(e){if(e.length<2)return 0;const n=e[1].clientX-e[0].clientX,i=e[1].clientY-e[0].clientY;return Math.atan2(i,n)*180/Math.PI}getCenter(e){if("touches"in e){if(e.touches.length===0)return{x:0,y:0};let n=0,i=0;for(let r=0;r<e.touches.length;r++)n+=e.touches[r].clientX,i+=e.touches[r].clientY;return{x:n/e.touches.length,y:i/e.touches.length}}else return{x:e.clientX,y:e.clientY}}canStart(e){const i="touches"in e?e.touches.length:1;return i>=this.minTouches&&i<=this.maxTouches&&this.controller.canStart(this.name)}checkThreshold(){if(!this.useThreshold)return!0;const{deltaX:e,deltaY:n}=this.details;return this.direction==="x"?Math.abs(e)>=this.threshold:this.direction==="y"?Math.abs(n)>=this.threshold:Math.sqrt(e*e+n*n)>=this.threshold}onStart(e){if(!this.canStart(e))return;const n="touches"in e,i=this.getCenter(e);this.details.startX=i.x,this.details.startY=i.y,this.details.currentX=i.x,this.details.currentY=i.y,this.details.touchCount=n?e.touches.length:1,this.details.event=e,n&&e.touches.length>=2?(this.initialDistance=this.getDistance(e.touches),this.initialAngle=this.getAngle(e.touches)):(this.initialDistance=0,this.initialAngle=0),!(this.options.canStart&&!this.options.canStart(this.details))&&(this.passive||e.preventDefault(),this.details.isTracking=!0,this.details.deltaX=0,this.details.deltaY=0,this.details.velocityX=0,this.details.velocityY=0,this.details.scale=1,this.details.rotation=0,this.hasPassedThreshold=!this.useThreshold,this.lastMoveTime=Date.now(),this.prevX=i.x,this.prevY=i.y,this.controller.start(this.id,this.name,this.priority),this.useThreshold||this.tryCapture())}onMove(e){if(!this.details.isTracking)return;this.passive||e.preventDefault();const n="touches"in e,i=this.getCenter(e),r=Date.now(),s=r-this.lastMoveTime;if(this.details.currentX=i.x,this.details.currentY=i.y,this.details.deltaX=this.details.currentX-this.details.startX,this.details.deltaY=this.details.currentY-this.details.startY,this.details.touchCount=n?e.touches.length:1,this.details.event=e,n&&e.touches.length>=2){const o=this.getDistance(e.touches),a=this.getAngle(e.touches);this.initialDistance>0&&(this.details.scale=o/this.initialDistance);let l=a-this.initialAngle;l>180&&(l-=360),l<-180&&(l+=360),this.details.rotation=l}else this.details.scale=1,this.details.rotation=0;if(s>0&&(this.details.velocityX=(this.details.currentX-this.prevX)/s,this.details.velocityY=(this.details.currentY-this.prevY)/s),this.prevX=this.details.currentX,this.prevY=this.details.currentY,this.lastMoveTime=r,!this.hasPassedThreshold&&this.checkThreshold()){this.hasPassedThreshold=!0,this.tryCapture();return}this.hasPassedThreshold&&this.options.onMove&&this.options.onMove(this.details)}tryCapture(){this.controller.capture(this.id,this.name,this.priority)&&this.options.onStart&&this.options.onStart(this.details)}onEnd(e){if(!this.details.isTracking)return;this.passive||e.preventDefault();const n="touches"in e;this.details.touchCount=n?e.touches.length:0,this.details.event=e,this.controller.release(this.id),this.details.isTracking=!1,this.hasPassedThreshold=!this.useThreshold,this.options.onEnd&&this.options.onEnd(this.details)}init(){if(!this.el)return;const e={passive:this.passive},n={passive:this.passive},i={passive:this.passive};this.el.addEventListener("touchstart",this.boundOnStart,e),document.addEventListener("touchmove",this.boundOnMove,n),document.addEventListener("touchend",this.boundOnEnd,i),document.addEventListener("touchcancel",this.boundOnEnd,i),this.el.addEventListener("mousedown",this.boundOnStart,e),document.addEventListener("mousemove",this.boundOnMove,n),document.addEventListener("mouseup",this.boundOnEnd,i),document.addEventListener("mouseleave",this.boundOnEnd,i)}destroy(){this.el&&(this.el.removeEventListener("touchstart",this.boundOnStart),document.removeEventListener("touchmove",this.boundOnMove),document.removeEventListener("touchend",this.boundOnEnd),document.removeEventListener("touchcancel",this.boundOnEnd),this.el.removeEventListener("mousedown",this.boundOnStart),document.removeEventListener("mousemove",this.boundOnMove),document.removeEventListener("mouseup",this.boundOnEnd),document.removeEventListener("mouseleave",this.boundOnEnd),this.controller.release(this.id))}}let N;function He(){return N||(N=new Fe),N}function Ie(t,e){return He().createGesture(t,e)}function Ke(t){typeof document>"u"||(document.startViewTransition?document.startViewTransition(t):t())}let Ve=0;function Ge(t,e=[],n={duration:500,namePrefix:"vt"}){if(!document.startViewTransition){t();return}const i=e.map((s,o)=>`${n.namePrefix}-${++Ve}-${o}`);e.forEach((s,o)=>{s.style.viewTransitionName=i[o]}),document.startViewTransition(()=>{t()}).finished.finally(()=>{e.forEach(s=>{s.style.viewTransitionName=""})}),document.documentElement.style.setProperty("--vt-duration",`${n.duration}ms`)}exports.Fragment=d.Fragment;exports.Computed=m;exports.Effect=b;exports.FrameScheduler=De;exports.Signal=u;exports.batch=R;exports.computed=Z;exports.createContext=Ne;exports.createGesture=Ie;exports.effect=g;exports.get=ee;exports.hydrate=Ee;exports.link=ne;exports.onBeforeExit=Oe;exports.onLoad=Pe;exports.onMount=xe;exports.onUnmount=Me;exports.peek=Q;exports.render=pe;exports.set=te;exports.signal=q;exports.startViewTransition=Ke;exports.suspend=Te;exports.useContext=Ae;exports.withViewTransition=Ge;
11
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./jsx-dev-runtime-C5Q23IsT.cjs"),L=require("./server-context-C7Uxb3AS.cjs");var z=Symbol.for("preact-signals");function E(){if(y>1)y--;else{for(var t,e=!1;S!==void 0;){var n=S;for(S=void 0,A++;n!==void 0;){var i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&K(n))try{n.c()}catch(r){e||(t=r,e=!0)}n=i}}if(A=0,y--,e)throw t}}function R(t){if(y>0)return t();y++;try{return t()}finally{E()}}var c=void 0;function H(t){var e=c;c=void 0;try{return t()}finally{c=e}}var S=void 0,y=0,A=0,w=0;function I(t){if(c!==void 0){var e=t.n;if(e===void 0||e.t!==c)return e={i:0,S:t,p:c.s,n:void 0,t:c,e:void 0,x:void 0,r:e},c.s!==void 0&&(c.s.n=e),c.s=e,t.n=e,32&c.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=c.s,e.n=void 0,c.s.n=e,c.s=e),e}}function u(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}u.prototype.brand=z;u.prototype.h=function(){return!0};u.prototype.S=function(t){var e=this,n=this.t;n!==t&&t.e===void 0&&(t.x=n,this.t=t,n!==void 0?n.e=t:H(function(){var i;(i=e.W)==null||i.call(e)}))};u.prototype.U=function(t){var e=this;if(this.t!==void 0){var n=t.e,i=t.x;n!==void 0&&(n.x=i,t.e=void 0),i!==void 0&&(i.e=n,t.x=void 0),t===this.t&&(this.t=i,i===void 0&&H(function(){var r;(r=e.Z)==null||r.call(e)}))}};u.prototype.subscribe=function(t){var e=this;return g(function(){var n=e.value,i=c;c=void 0;try{t(n)}finally{c=i}},{name:"sub"})};u.prototype.valueOf=function(){return this.value};u.prototype.toString=function(){return this.value+""};u.prototype.toJSON=function(){return this.value};u.prototype.peek=function(){var t=c;c=void 0;try{return this.value}finally{c=t}};Object.defineProperty(u.prototype,"value",{get:function(){var t=I(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(A>100)throw new Error("Cycle detected");this.v=t,this.i++,w++,y++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{E()}}}});function q(t,e){return new u(t,e)}function K(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function V(t){for(var e=t.s;e!==void 0;e=e.n){var n=e.S.n;if(n!==void 0&&(e.r=n),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function G(t){for(var e=t.s,n=void 0;e!==void 0;){var i=e.p;e.i===-1?(e.S.U(e),i!==void 0&&(i.n=e.n),e.n!==void 0&&(e.n.p=i)):n=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=i}t.s=n}function m(t,e){u.call(this,void 0),this.x=t,this.s=void 0,this.g=w-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}m.prototype=new u;m.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===w))return!0;if(this.g=w,this.f|=1,this.i>0&&!K(this))return this.f&=-2,!0;var t=c;try{V(this),c=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return c=t,G(this),this.f&=-2,!0};m.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}u.prototype.S.call(this,t)};m.prototype.U=function(t){if(this.t!==void 0&&(u.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};m.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(m.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=I(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function Z(t,e){return new m(t,e)}function j(t){var e=t.u;if(t.u=void 0,typeof e=="function"){y++;var n=c;c=void 0;try{e()}catch(i){throw t.f&=-2,t.f|=8,x(t),i}finally{c=n,E()}}}function x(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,j(t)}function J(t){if(c!==this)throw new Error("Out-of-order effect");G(this),c=t,this.f&=-2,8&this.f&&x(this),E()}function b(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}b.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{t()}};b.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,j(this),V(this),y++;var t=c;return c=this,J.bind(this,t)};b.prototype.N=function(){2&this.f||(this.f|=2,this.o=S,S=this)};b.prototype.d=function(){this.f|=8,1&this.f||x(this)};b.prototype.dispose=function(){this.d()};function g(t,e){var n=new b(t,e);try{n.c()}catch(r){throw n.d(),r}var i=n.d.bind(n);return i[Symbol.dispose]=i,i}function Q(t){return t instanceof u?t.peek():t}function ee(t){return t instanceof u?t.value:t}function te(t,e){typeof e=="function"?t.value=e():t.value=e}function ne(t){return t instanceof u?()=>t.value:t}function ie(t,e,n=!1){const i=[];for(const[r,s]of Object.entries(e))if(s!=null&&!(r==="children"||r==="key"||r==="autoanimate"||r==="innerHTML")){if(typeof s=="function"&&r!=="ref"&&!r.startsWith("on")&&r!=="viewTransitionName"){const o=g(()=>{const a=s();D(t,r,a,n)});i.push(o);continue}D(t,r,s,n)}return()=>i.forEach(r=>r())}function D(t,e,n,i){if(e==="ref"&&typeof n=="function"){n(t);return}if(e.startsWith("on")&&typeof n=="function"){const r=e.slice(2).toLowerCase();t.addEventListener(r,n);return}if(e==="class"||e==="className"){const r=typeof n=="string"?n:Array.isArray(n)?n.filter(Boolean).join(" "):typeof n=="object"?Object.entries(n).filter(([s,o])=>o).map(([s])=>s).join(" "):"";i?t.setAttribute("class",r):t.className=r;return}if(e==="style"){typeof n=="string"?t.setAttribute("style",n):typeof n=="object"&&n&&Object.assign(t.style,n);return}if(e==="viewTransitionName"){t.style.viewTransitionName=n;return}if(!i&&typeof n=="boolean"){n?t.setAttribute(e,""):t.removeAttribute(e);return}t.setAttribute(e,String(n))}function re(t,e){const n=document.createTextNode(String(e));t.appendChild(n)}function X(t){return{type:"reactive",kind:"ReactiveVNode",fn:t,_id:d.newVNodeId(),_dispose:null,_currentChild:null,_currentDom:null,_placeholder:null,_parent:null,_renderedChildren:[]}}function k(t,e){if(!t&&t!==0)return{vnode:null,dom:null};if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")return{vnode:null,dom:document.createTextNode(String(t))};if(t instanceof Node)return{vnode:null,dom:t};if(typeof t=="object"&&"type"in t){const n=t;n.type!=="reactive"&&(n._parent=e),e._renderedChildren.push(n);const i=_(n);return{vnode:n,dom:i}}return{vnode:null,dom:null}}class M{_cancelled=!1;_cancelCallbacks=[];get cancelled(){return this._cancelled}cancel(){this._cancelled||(this._cancelled=!0,this._cancelCallbacks.forEach(e=>{try{e()}catch(n){console.error("Cancel callback error:",n)}}),this._cancelCallbacks=[])}onCancel(e){this._cancelled?e():this._cancelCallbacks.push(e)}throwIfCancelled(){if(this._cancelled)throw new Error("Operation cancelled")}}async function Y(t,e){if(!t)return;const n=t,i=e||new M;if("_onBeforeExitCallbacks"in n&&n._onBeforeExitCallbacks.length>0)for(const r of n._onBeforeExitCallbacks)try{if(i.cancelled)break;await r(i)}catch(s){console.error("onBeforeExit error:",s)}if("_onUnmountCallbacks"in n&&n._onUnmountCallbacks.length>0&&n._onUnmountCallbacks.forEach(r=>{try{r()}catch(s){console.error("onUnmount error:",s)}}),n.type==="reactive"){const r=n;r._dispose&&(r._dispose(),r._dispose=null)}"_renderedChildren"in n&&n._renderedChildren.forEach(r=>{U(r)})}function U(t){if(!t)return;const e=t,n=new M;if(n.cancel(),"_onBeforeExitCallbacks"in e&&e._onBeforeExitCallbacks.length>0&&e._onBeforeExitCallbacks.forEach(i=>{try{const r=i(n);r instanceof Promise&&r.catch(s=>console.error("onBeforeExit error:",s))}catch(r){console.error("onBeforeExit error:",r)}}),"_onUnmountCallbacks"in e&&e._onUnmountCallbacks.length>0&&e._onUnmountCallbacks.forEach(i=>{try{i()}catch(r){console.error("onUnmount error:",r)}}),e.type==="reactive"){const i=e;i._dispose&&(i._dispose(),i._dispose=null)}"_renderedChildren"in e&&e._renderedChildren.forEach(i=>{U(i)})}let se=0;const p=new WeakMap;async function O(t,e,n){const i=t._placeholder;if(!i?.parentNode)return;const r=t._currentChild,s=t._currentDom;if(oe(r,e)){const f=p.get(t);f&&(f.token.cancel(),p.delete(t)),r&&"_lifecycleState"in r&&(r._lifecycleState="mounted");return}if(s instanceof Text&&n instanceof Text){s.nodeValue!==n.nodeValue&&(s.nodeValue=n.nodeValue),t._currentDom=s,t._currentChild=e,e&&"_lifecycleState"in e&&(e._lifecycleState="mounted"),p.delete(t);return}const o=++se,a=p.get(t);a&&a.token.cancel();const l=new M;if(p.set(t,{id:o,token:l}),r&&"_lifecycleState"in r&&(r._lifecycleState="exiting"),r)try{await Y(r,l)}catch(f){console.error(`ReactiveVNode ${t._id}: Unmount threw:`,f)}const h=p.get(t);if(!(!h||h.id!==o)){if(l.cancelled){p.delete(t);return}r&&"_lifecycleState"in r&&(r._lifecycleState="exited"),s&&s.remove(),n&&i.parentNode.insertBefore(n,i.nextSibling),e&&"_lifecycleState"in e&&(e._lifecycleState="mounted"),t._currentChild=e,t._currentDom=n,p.delete(t)}}function oe(t,e){if(!t||!e||typeof t!="object"||typeof e!="object"||!("type"in t)||!("type"in e))return!1;if(typeof t.type=="function"&&typeof e.type=="function"){if(t.type!==e.type)return!1}else if(typeof t.type=="string"&&typeof e.type=="string"){if(t.type!==e.type)return!1}else return!1;const n="props"in t?t.props?.key:void 0,i="props"in e?e.props?.key:void 0;return n!==i?!1:"_lifecycleState"in t&&t._lifecycleState==="exiting"}function ae(t,e){const n=t._listState;n?ce(t,e,n):le(t,e)}function le(t,e){const n=t._placeholder;if(!n?.parentNode)return;const i=[];for(let r=0;r<e.length;r++){const s=e[r],o=P(s,r),{vnode:a,dom:l}=k(s,t);l&&n.parentNode.appendChild(l),i.push({key:o,vnode:a,dom:l})}t._listState={items:i}}function ce(t,e,n){const i=t._placeholder;if(!i?.parentNode)return;const r=new Map;for(const a of n.items)r.set(a.key,a);const s=new Set,o=[];for(let a=0;a<e.length;a++){const l=e[a],h=P(l,a);s.add(h);const f=r.get(h);f?(o.push(f),r.delete(h)):ue(t,l,o)}r.size>0&&fe(r),de(i,o),t._listState={items:o}}function ue(t,e,n){const i=P(e,n.length),{vnode:r,dom:s}=k(e,t);n.push({key:i,vnode:r,dom:s})}function fe(t){for(const[e,n]of t)n.vnode&&Y(n.vnode),n.dom?.parentNode&&n.dom.parentNode.removeChild(n.dom)}function de(t,e){const n=t.parentNode;if(!n)return;let i=t;for(const r of e)r.dom&&(i.nextSibling!==r.dom&&n.insertBefore(r.dom,i.nextSibling),i=r.dom)}function P(t,e){return t&&typeof t=="object"&&"key"in t?t.key??e:e}function $(t,e,n=null,i=!1){if(!e)return;(Array.isArray(e)?e:[e]).forEach(s=>{if(s){if(Array.isArray(s)&&$(t,s,n,i),typeof s=="string"||typeof s=="number")re(t,s);else if(typeof s=="function"){const o=X(s);o._parent=n,n&&n._renderedChildren.push(o);const a=document.createComment("reactive");t.appendChild(a),o._placeholder=a;const l=g(()=>{const h=s();if(Array.isArray(h))ae(o,h);else{const{vnode:f,dom:T}=k(h,o);O(o,f,T)}});o._dispose=l}else if(s instanceof Node)t.append(s);else if(s&&typeof s=="object"&&"type"in s){const o=s;"type"in o&&o.type!=="reactive"&&(o._parent=n),n&&n._renderedChildren.push(o);const a=_(o,i);a&&t.append(a)}}})}const he="http://www.w3.org/2000/svg";function B(t,e=!1){if(t._dom)return t._dom;const n=e||t.type==="svg",i=n?document.createElementNS(he,t.type):document.createElement(t.type),r=ie(i,t.props,n);return t._onUnmountCallbacks.push(r),t.props.innerHTML!==void 0?i.innerHTML=typeof t.props.innerHTML=="object"?JSON.stringify(t.props.innerHTML):t.props.innerHTML:t.props.children&&$(i,t.props.children,t,n),t._dom=i,t._lifecycleState="mounted",t._onMountCallbacks.length>0&&t._onMountCallbacks.forEach(s=>s()),i}function _(t,e=!1){if("type"in t&&t.type==="reactive")return t._placeholder;if(typeof t.type=="string")return B(t,e);const n=t;d.setCurrentVNode(n);const i=n.type(n.props);if(d.setCurrentVNode(null),!i)return null;let r=null;if(typeof i=="string"||typeof i=="number"||typeof i=="boolean")r=document.createTextNode(String(i));else if(i instanceof Node)n._element=i,r=i;else if(i&&typeof i=="object"&&"type"in i){const s=i;"type"in s&&s.type!=="reactive"&&(s._parent=n,n._renderedChildren.push(s));const o=_(s,e);o&&(n._element=o),r=o}return r&&n._onMountCallbacks.length>0&&n._onMountCallbacks.forEach(s=>{s()}),r&&(n._lifecycleState="mounted"),r}function pe(t,e){const n=t instanceof Node?t:_(t);n&&e.append(n)}function ye(t){return document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null)}function me(t,e="self"){const n=ye(t);return e==="children"&&n.firstChild(),{walker:n,isSVG:!1}}function be(t,e,n,i){if(e==="class"||e==="className"){const r=typeof n=="string"?n:Array.isArray(n)?n.filter(Boolean).join(" "):typeof n=="object"?Object.entries(n).filter(([s,o])=>o).map(([s])=>s).join(" "):"";i?t.setAttribute("class",r):t.className=r;return}if(e==="style"){typeof n=="string"?t.setAttribute("style",n):typeof n=="object"&&n&&Object.assign(t.style,n);return}if(e==="viewTransitionName"){t.style.viewTransitionName=n;return}if(!i&&typeof n=="boolean"){n?t.setAttribute(e,""):t.removeAttribute(e);return}t.setAttribute(e,String(n))}function ge(t,e,n=!1,i){const r=[];for(const[s,o]of Object.entries(e))if(o!=null&&!(s==="children"||s==="key"||s==="autoanimate")){if(s==="ref"&&typeof o=="function"){i&&console.log("→ Attaching ref"),o(t);continue}if(s.startsWith("on")&&typeof o=="function"){const a=s.slice(2).toLowerCase();i&&console.log(`→ Attaching event: ${a}`),t.addEventListener(a,o);continue}if(typeof o=="function"&&s!=="ref"&&s!=="viewTransitionName"){i&&console.log(`→ Reactive prop: ${s}`);const a=g(()=>{const l=o();be(t,s,l,n)});r.push(a);continue}}return()=>r.forEach(s=>s())}function ve(t,e,n=null,i){if(!e)return;const r=Array.isArray(e)?e:[e];if(!i.walker.firstChild()&&r.length>0){console.warn("Hydration mismatch: VNode has children but DOM is empty");return}for(const o of r)!o&&o!==0||_e(o,t,n,i);i.walker.parentNode()}function _e(t,e,n,i){if(!(!t&&t!==0)){if(typeof t=="string"||typeof t=="number"||typeof t=="boolean"){const r=i.walker.currentNode;r.nodeType===Node.TEXT_NODE?(i.debug&&console.log("→ Hydrated text node"),i.walker.nextSibling()):console.warn(`Hydration mismatch: expected text node but found ${r.nodeName}`);return}if(typeof t=="function"){i.debug&&console.log("→ Hydrating reactive child");const r=X(t);r._parent=n,n&&n._renderedChildren.push(r);const s=i.walker.currentNode,o=t();if(o&&typeof o=="object"&&"type"in o){const f=o;v(f,i),r._currentChild=f,r._currentDom=f._dom??f._element}else(typeof o=="string"||typeof o=="number"||typeof o=="boolean")&&(r._currentDom=s),i.walker.nextSibling();const a=document.createComment("reactive");r._currentDom?.parentNode&&r._currentDom.parentNode.insertBefore(a,r._currentDom),r._placeholder=a;let l=!0;const h=g(()=>{const f=t();if(l){l=!1;return}const{vnode:T,dom:W}=k(f,r);O(r,T,W)});r._dispose=h;return}if(t instanceof Node){i.walker.nextSibling();return}if(t&&typeof t=="object"&&"type"in t){const r=t;"type"in r&&r.type!=="reactive"&&r.type!=="suspended"&&(r._parent=n),n&&n._renderedChildren.push(r),v(r,i)}}}function Se(t,e){const n=e.walker.currentNode;if(n.nodeType!==Node.ELEMENT_NODE)return console.warn(`Hydration mismatch: expected element <${t.type}> but found ${n.nodeName}`),F(t,n,e);const i=n,r=i.tagName.toLowerCase();if(r!==t.type.toLowerCase())return console.warn(`Hydration mismatch: expected <${t.type}> but found <${r}>`),F(t,n,e);const s=e.isSVG||t.type==="svg",o=e.isSVG;e.isSVG=s,t._dom=i,e.debug&&console.log(`→ Attached existing <${t.type}> DOM`);const a=ge(i,t.props,s,e.debug);return t._onUnmountCallbacks.push(a),t.props.children&&ve(i,t.props.children,t,e),t._lifecycleState="mounted",t._onMountCallbacks.length>0&&t._onMountCallbacks.forEach(l=>l()),e.isSVG=o,e.walker.nextSibling(),i}function F(t,e,n){n.debug&&console.log(`→ Fallback: rendering <${t.type}> fresh`);const i=e.parentNode,r=e.nextSibling;i?.removeChild(e);const s=B(t,n.isSVG);return i&&(r?i.insertBefore(s,r):i.appendChild(s)),n.walker.nextSibling(),s}function v(t,e){if("type"in t&&t.type==="reactive")return e.debug&&console.log(`Hydrating ReactiveVNode #${t._id}`),Ce(t,e);if("type"in t&&t.type==="suspended")return e.debug&&console.log(`Hydrating SuspendedVNode: ${t._componentName}`),we(t,e);if(typeof t.type=="string")return e.debug&&console.log(`Hydrating <${t.type}>`),Se(t,e);const n=t.type.name||"Anonymous";return e.debug&&console.log(`Hydrating Component: ${n}`),ke(t,e)}function ke(t,e){d.setCurrentVNode(t);const n=t.type(t.props);if(d.setCurrentVNode(null),!n)return null;if(typeof n=="object"&&"type"in n&&n.type==="suspended")return v(n,e);let i=null;if(typeof n=="string"||typeof n=="number"||typeof n=="boolean"){const r=e.walker.currentNode;r.nodeType===Node.TEXT_NODE&&(t._element=r,i=r,e.walker.nextSibling())}else if(n instanceof Node)t._element=n,i=n,e.walker.nextSibling();else if(n&&typeof n=="object"&&"type"in n){const r=n;"type"in r&&r.type!=="reactive"&&(r._parent=t,t._renderedChildren.push(r));const s=v(r,e);s&&(t._element=s),i=s}return i&&t._onMountCallbacks.length>0&&(e.debug&&console.log(`→ Firing ${t._onMountCallbacks.length} onMount callback(s)`),t._onMountCallbacks.forEach(r=>r())),i&&(t._lifecycleState="mounted"),i}function Ce(t,e){const n=t.fn(),i=e.walker.currentNode,r=document.createComment("reactive");if(i.parentNode?.insertBefore(r,i),t._placeholder=r,n&&typeof n=="object"&&"type"in n){const a=n;v(a,e),t._currentChild=a,t._currentDom=a._dom??a._element}else(typeof n=="string"||typeof n=="number"||typeof n=="boolean")&&(t._currentDom=i),e.walker.nextSibling();let s=!0;const o=g(()=>{const a=t.fn();if(s){s=!1,e.debug&&console.log("→ Reactive effect setup (skipping initial)");return}const{vnode:l,dom:h}=k(a,t);O(t,l,h)});return t._dispose=o,t._currentDom}function we(t,e){const n=e.walker.currentNode;if(n.nodeType===Node.ELEMENT_NODE&&n.hasAttribute("data-suspended")){const r=n;return r.getAttribute("data-suspended-state")==="resolved"?(t._state="resolved",e.walker.firstChild(),t.promise.then(o=>{t._state="resolved"}).catch(o=>{t._state="error";const a=typeof t.errorFallback=="function"?t.errorFallback(o):t.errorFallback;r.innerHTML="";const l=C(a,e.isSVG);l&&r.appendChild(l)}),e.walker.parentNode(),e.walker.nextSibling(),r):(t._state="pending",t.promise.then(o=>{t._state="resolved",r.innerHTML="";const a=C(o,e.isSVG);a&&r.appendChild(a)}).catch(o=>{t._state="error";const a=typeof t.errorFallback=="function"?t.errorFallback(o):t.errorFallback;r.innerHTML="";const l=C(a,e.isSVG);l&&r.appendChild(l)}),e.walker.nextSibling(),r)}console.warn("Hydration mismatch: expected suspended container");const i=_(t,e.isSVG);return e.walker.nextSibling(),i}function C(t,e){return!t&&t!==0?null:typeof t=="string"||typeof t=="number"||typeof t=="boolean"?document.createTextNode(String(t)):t instanceof Node?t:typeof t=="object"&&"type"in t?_(t,e):typeof t=="function"?C(t(),e):null}function Ee(t,e,n="self"){const i=me(e,n);v(t,i)}function Te(t,e="Loading...",n="Error"){return i=>({type:"suspended",kind:"SuspendedVNode",promise:t(i),fallback:e,errorFallback:n,_id:d.newVNodeId(),_componentName:t.name||"AsyncComponent",_parent:null,_renderedChildren:[],_currentChild:null,_state:"pending"})}function Ne(t){const e=Symbol("context");return{_id:e,_defaultValue:t,provide(n){if(typeof document>"u"){L.provideServerContext(e,n);return}const i=d.getCurrentVNode();if(!i)throw new Error("context.provide() called outside of component render");i._contextMap||(i._contextMap=new Map),i._contextMap.set(e,n)}}}function Ae(t){if(typeof document>"u")return L.consumeServerContext(t._id,t._defaultValue);const e=d.getCurrentVNode();if(!e)throw new Error("useContext called outside of component render");let n=e;for(;n;){if(n.kind==="VNode"&&n._contextMap?.has(t._id))return n._contextMap.get(t._id);n=n._parent}return t._defaultValue}function xe(t){if(!(typeof document>"u")){if(d.currentVNode===null)throw new Error("onMount must be called inside a component during render");d.currentVNode._onMountCallbacks.push(t)}}function Me(t){if(!(typeof document>"u")){if(d.currentVNode===null)throw new Error("onUnmount must be called inside a component during render");d.currentVNode._onUnmountCallbacks.push(t)}}function Oe(t){if(!(typeof document>"u")){if(d.currentVNode===null)throw new Error("onBeforeExit must be called inside a component during render");d.currentVNode._onBeforeExitCallbacks.push(t)}}function Pe(t){if(!(typeof document>"u"))try{t()}catch(e){console.error(e)}}class De{readCallbacks=new Set;updateCallbacks=new Set;renderCallbacks=new Set;readKeepAlive=new Set;updateKeepAlive=new Set;renderKeepAlive=new Set;isProcessing=!1;frameScheduled=!1;frameId=null;lastTimestamp=0;currentDelta=0;trackFPS;fpsHistorySize;fpsHistory=[];constructor(e={}){this.trackFPS=e.trackFPS??!1,this.fpsHistorySize=e.fpsHistorySize??60}read(e,n=!1){return n?this.readKeepAlive.add(e):this.readCallbacks.add(e),this.scheduleFrame(),e}update(e,n=!1){return n?this.updateKeepAlive.add(e):this.updateCallbacks.add(e),this.scheduleFrame(),e}render(e,n=!1){return n?this.renderKeepAlive.add(e):this.renderCallbacks.add(e),this.scheduleFrame(),e}chain(e){let n,i;"read"in e&&this.readCallbacks.add(r=>{n=e.read(r)}),"update"in e?(this.updateCallbacks.add(r=>{i=e.update(n,r)}),this.renderCallbacks.add(r=>{e.render(i,r)})):this.renderCallbacks.add(r=>{e.render(n,r)}),this.scheduleFrame()}cancel(e){this.readCallbacks.delete(e),this.updateCallbacks.delete(e),this.renderCallbacks.delete(e),this.readKeepAlive.delete(e),this.updateKeepAlive.delete(e),this.renderKeepAlive.delete(e)}cancelAll(){this.frameId!==null&&(cancelAnimationFrame(this.frameId),this.frameId=null),this.readCallbacks.clear(),this.updateCallbacks.clear(),this.renderCallbacks.clear(),this.readKeepAlive.clear(),this.updateKeepAlive.clear(),this.renderKeepAlive.clear(),this.isProcessing=!1,this.frameScheduled=!1,this.lastTimestamp=0,this.currentDelta=0,this.trackFPS&&(this.fpsHistory=[])}get data(){return{timestamp:this.lastTimestamp,delta:this.currentDelta||16.67}}get isRunning(){return this.isProcessing||this.readKeepAlive.size>0||this.updateKeepAlive.size>0||this.renderKeepAlive.size>0}get fps(){return this.trackFPS?this.currentDelta>0?1e3/this.currentDelta:0:(console.warn("FPS tracking is disabled. Enable with { trackFPS: true }"),0)}get averageFps(){if(!this.trackFPS)return console.warn("FPS tracking is disabled. Enable with { trackFPS: true }"),0;if(this.fpsHistory.length===0)return 0;const e=this.fpsHistory.reduce((n,i)=>n+i,0);return Math.round(e/this.fpsHistory.length)}get refreshRate(){return this.trackFPS?Math.round(this.averageFps):(console.warn("FPS tracking is disabled. Enable with { trackFPS: true }"),0)}scheduleFrame(){this.frameScheduled||this.isProcessing||(this.frameScheduled=!0,this.frameId=requestAnimationFrame(e=>{this.processFrame(e)}))}processFrame(e){this.isProcessing=!0,this.frameScheduled=!1,this.lastTimestamp===0?this.currentDelta=16.67:this.currentDelta=e-this.lastTimestamp,this.lastTimestamp=e,this.trackFPS&&this.currentDelta>0&&(this.fpsHistory.push(1e3/this.currentDelta),this.fpsHistory.length>this.fpsHistorySize&&this.fpsHistory.shift());const n=this.data;this.executeCallbacks(this.readCallbacks,n),this.executeCallbacks(this.readKeepAlive,n),this.executeCallbacks(this.updateCallbacks,n),this.executeCallbacks(this.updateKeepAlive,n),this.executeCallbacks(this.renderCallbacks,n),this.executeCallbacks(this.renderKeepAlive,n),this.isProcessing=!1,this.hasKeepAliveCallbacks()&&this.scheduleFrame()}executeCallbacks(e,n){e.forEach(i=>{try{i(n)}catch(r){console.error("Frame callback error:",r)}}),this.isKeepAliveSet(e)||e.clear()}hasKeepAliveCallbacks(){return this.readKeepAlive.size>0||this.updateKeepAlive.size>0||this.renderKeepAlive.size>0}isKeepAliveSet(e){return e===this.readKeepAlive||e===this.updateKeepAlive||e===this.renderKeepAlive}}class Fe{gestureId=0;activeGestures=new Map;disabledGestures=new Map;capturedId;gestureWithPriority=new Map;maxPriority=-1/0;newId(){return++this.gestureId}canStart(e){if(this.capturedId!==void 0)return!1;const n=this.disabledGestures.get(e);return!(n&&n.size>0)}start(e,n,i){return this.canStart(n)?(this.activeGestures.set(e,n),this.gestureWithPriority.set(e,i),this.maxPriority=Math.max(this.maxPriority,i),!0):!1}capture(e,n,i){return!this.activeGestures.has(e)&&!this.start(e,n,i)?!1:i>=this.maxPriority?(this.capturedId=e,this.activeGestures.forEach((r,s)=>{s!==e&&this.release(s)}),!0):(this.release(e),!1)}release(e){const n=this.activeGestures.get(e);this.activeGestures.delete(e);const i=this.gestureWithPriority.get(e);if(this.gestureWithPriority.delete(e),this.capturedId===e&&(this.capturedId=void 0),i===this.maxPriority&&(this.maxPriority=-1/0,this.gestureWithPriority.forEach(r=>{this.maxPriority=Math.max(this.maxPriority,r)})),n){const r=this.disabledGestures.get(n);r&&(r.delete(e),r.size===0&&this.disabledGestures.delete(n))}}disableGesture(e,n){let i=this.disabledGestures.get(e);i||(i=new Set,this.disabledGestures.set(e,i)),i.add(n)}enableGesture(e,n){const i=this.disabledGestures.get(e);i&&(i.delete(n),i.size===0&&this.disabledGestures.delete(e))}createGesture(e,n){const i=this.newId(),r=n.name||"gesture-"+i,s=n.priority??0;return new Le(this,i,e,r,s,n)}}class Le{el;options;details;minTouches;maxTouches;threshold;direction;lastMoveTime=0;prevX=0;prevY=0;initialDistance=0;initialAngle=0;boundOnStart;boundOnMove;boundOnEnd;passive;hasPassedThreshold=!1;controller;id;name;priority;useThreshold;constructor(e,n,i,r,s,o){this.controller=e,this.id=n,this.el=i,this.options=o,this.name=r,this.priority=s*1e3+n,this.minTouches=o.minTouches??1,this.maxTouches=o.maxTouches??1/0,this.passive=o.passive??!0,this.threshold=o.threshold??0,this.direction=o.direction??"all",this.useThreshold=this.threshold>0,this.details={type:this.name,isTracking:!1,startX:0,startY:0,currentX:0,currentY:0,deltaX:0,deltaY:0,velocityX:0,velocityY:0,touchCount:0,scale:1,rotation:0},this.boundOnStart=this.onStart.bind(this),this.boundOnMove=this.onMove.bind(this),this.boundOnEnd=this.onEnd.bind(this)}getDistance(e){if(e.length<2)return 0;const n=e[0].clientX-e[1].clientX,i=e[0].clientY-e[1].clientY;return Math.sqrt(n*n+i*i)}getAngle(e){if(e.length<2)return 0;const n=e[1].clientX-e[0].clientX,i=e[1].clientY-e[0].clientY;return Math.atan2(i,n)*180/Math.PI}getCenter(e){if("touches"in e){if(e.touches.length===0)return{x:0,y:0};let n=0,i=0;for(let r=0;r<e.touches.length;r++)n+=e.touches[r].clientX,i+=e.touches[r].clientY;return{x:n/e.touches.length,y:i/e.touches.length}}else return{x:e.clientX,y:e.clientY}}canStart(e){const i="touches"in e?e.touches.length:1;return i>=this.minTouches&&i<=this.maxTouches&&this.controller.canStart(this.name)}checkThreshold(){if(!this.useThreshold)return!0;const{deltaX:e,deltaY:n}=this.details;return this.direction==="x"?Math.abs(e)>=this.threshold:this.direction==="y"?Math.abs(n)>=this.threshold:Math.sqrt(e*e+n*n)>=this.threshold}onStart(e){if(!this.canStart(e))return;const n="touches"in e,i=this.getCenter(e);this.details.startX=i.x,this.details.startY=i.y,this.details.currentX=i.x,this.details.currentY=i.y,this.details.touchCount=n?e.touches.length:1,this.details.event=e,n&&e.touches.length>=2?(this.initialDistance=this.getDistance(e.touches),this.initialAngle=this.getAngle(e.touches)):(this.initialDistance=0,this.initialAngle=0),!(this.options.canStart&&!this.options.canStart(this.details))&&(this.passive||e.preventDefault(),this.details.isTracking=!0,this.details.deltaX=0,this.details.deltaY=0,this.details.velocityX=0,this.details.velocityY=0,this.details.scale=1,this.details.rotation=0,this.hasPassedThreshold=!this.useThreshold,this.lastMoveTime=Date.now(),this.prevX=i.x,this.prevY=i.y,this.controller.start(this.id,this.name,this.priority),this.useThreshold||this.tryCapture())}onMove(e){if(!this.details.isTracking)return;this.passive||e.preventDefault();const n="touches"in e,i=this.getCenter(e),r=Date.now(),s=r-this.lastMoveTime;if(this.details.currentX=i.x,this.details.currentY=i.y,this.details.deltaX=this.details.currentX-this.details.startX,this.details.deltaY=this.details.currentY-this.details.startY,this.details.touchCount=n?e.touches.length:1,this.details.event=e,n&&e.touches.length>=2){const o=this.getDistance(e.touches),a=this.getAngle(e.touches);this.initialDistance>0&&(this.details.scale=o/this.initialDistance);let l=a-this.initialAngle;l>180&&(l-=360),l<-180&&(l+=360),this.details.rotation=l}else this.details.scale=1,this.details.rotation=0;if(s>0&&(this.details.velocityX=(this.details.currentX-this.prevX)/s,this.details.velocityY=(this.details.currentY-this.prevY)/s),this.prevX=this.details.currentX,this.prevY=this.details.currentY,this.lastMoveTime=r,!this.hasPassedThreshold&&this.checkThreshold()){this.hasPassedThreshold=!0,this.tryCapture();return}this.hasPassedThreshold&&this.options.onMove&&this.options.onMove(this.details)}tryCapture(){this.controller.capture(this.id,this.name,this.priority)&&this.options.onStart&&this.options.onStart(this.details)}onEnd(e){if(!this.details.isTracking)return;this.passive||e.preventDefault();const n="touches"in e;this.details.touchCount=n?e.touches.length:0,this.details.event=e,this.controller.release(this.id),this.details.isTracking=!1,this.hasPassedThreshold=!this.useThreshold,this.options.onEnd&&this.options.onEnd(this.details)}init(){if(!this.el)return;const e={passive:this.passive},n={passive:this.passive},i={passive:this.passive};this.el.addEventListener("touchstart",this.boundOnStart,e),document.addEventListener("touchmove",this.boundOnMove,n),document.addEventListener("touchend",this.boundOnEnd,i),document.addEventListener("touchcancel",this.boundOnEnd,i),this.el.addEventListener("mousedown",this.boundOnStart,e),document.addEventListener("mousemove",this.boundOnMove,n),document.addEventListener("mouseup",this.boundOnEnd,i),document.addEventListener("mouseleave",this.boundOnEnd,i)}destroy(){this.el&&(this.el.removeEventListener("touchstart",this.boundOnStart),document.removeEventListener("touchmove",this.boundOnMove),document.removeEventListener("touchend",this.boundOnEnd),document.removeEventListener("touchcancel",this.boundOnEnd),this.el.removeEventListener("mousedown",this.boundOnStart),document.removeEventListener("mousemove",this.boundOnMove),document.removeEventListener("mouseup",this.boundOnEnd),document.removeEventListener("mouseleave",this.boundOnEnd),this.controller.release(this.id))}}let N;function He(){return N||(N=new Fe),N}function Ie(t,e){return He().createGesture(t,e)}function Ke(t){typeof document>"u"||(document.startViewTransition?document.startViewTransition(t):t())}let Ve=0;function Ge(t,e=[],n={duration:500,namePrefix:"vt"}){if(!document.startViewTransition){t();return}const i=e.map((s,o)=>`${n.namePrefix}-${++Ve}-${o}`);e.forEach((s,o)=>{s.style.viewTransitionName=i[o]}),document.startViewTransition(()=>{t()}).finished.finally(()=>{e.forEach(s=>{s.style.viewTransitionName=""})}),document.documentElement.style.setProperty("--vt-duration",`${n.duration}ms`)}exports.Fragment=d.Fragment;exports.Computed=m;exports.Effect=b;exports.FrameScheduler=De;exports.Signal=u;exports.batch=R;exports.computed=Z;exports.createContext=Ne;exports.createGesture=Ie;exports.effect=g;exports.get=ee;exports.hydrate=Ee;exports.link=ne;exports.onBeforeExit=Oe;exports.onLoad=Pe;exports.onMount=xe;exports.onUnmount=Me;exports.peek=Q;exports.render=pe;exports.set=te;exports.signal=q;exports.startViewTransition=Ke;exports.suspend=Te;exports.useContext=Ae;exports.withViewTransition=Ge;
package/dist/index.d.ts CHANGED
@@ -450,27 +450,28 @@ export declare function link<T>(toBind: HybridSignal<T> | HybridReactive<T>): Hy
450
450
  export declare function onBeforeExit(callback: (token: CancelToken) => void | Promise<void>): void;
451
451
 
452
452
  /**
453
- * This code will run after page loads
454
- * on client side only, way before any flash
455
- * runtime related code, use it for a pure
456
- * vanilla workflow or to enhance instant
457
- * hydration experiences, letting flash
458
- * hydrate later, inside here, flash refs
459
- * will not exist, but html parsed dom will
453
+ * Hook for vanilla JavaScript that runs after the page loads.
460
454
  *
461
- * You can also use it to opt out of flash for client side
462
- * and add pure standard vanilla interactivity
463
- * so you get JSX server rendered HTML Templating with
464
- * all it's advantages, and fine grained per page bundle
465
- * with vanilla js integrations
455
+ * Code inside onLoad runs as pure vanilla JS on the client side only.
456
+ * This lets you opt out of Flash's client-side runtime while keeping
457
+ * JSX for server-side templating.
458
+ *
459
+ * ⚠️ Don't use this with Flash runtime features.
460
+ * If you need them, use onMount, onUnmount
461
+ * or onBeforeExit instead to manage lifecycle patterns.
462
+ *
463
+ * Pattern: JSX for server-rendered HTML + vanilla JS for interactivity
466
464
  *
467
465
  * @example
468
- * onPageLoad(() => {
469
- * const el = document.getElementById("element-id")
466
+ * export function ContactPage() {
467
+ * onLoad(() => {
468
+ * // This becomes standalone vanilla JS
469
+ * const form = document.getElementById("contact-form");
470
+ * form.addEventListener("submit", handleSubmit);
471
+ * });
470
472
  *
471
- * someVanillaOnlyScripting(el)
472
- * fancyCriticalEnterAnimation(el)
473
- * })
473
+ * return <form id="contact-form">...</form>;
474
+ * }
474
475
  */
475
476
  export declare function onLoad(cb: VoidFunction): void;
476
477
 
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  import { n as H, s as w, g as I, c as m } from "./jsx-dev-runtime-dAReTOgq.js";
12
12
  import { F as Re } from "./jsx-dev-runtime-dAReTOgq.js";
13
- import { p as q, a as Z } from "./server-context-BA2xc7wp.js";
13
+ import { p as q, b as Z } from "./server-context-CJbtcTMO.js";
14
14
  var J = Symbol.for("preact-signals");
15
15
  function T() {
16
16
  if (p > 1)
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license
3
+ * Flash
4
+ * Copyright (c) 2025 Mateo Suarez. All rights reserved.
5
+ *
6
+ * Free to use in your own personal or commercial applications and projects.
7
+ * Unauthorized copying, modification, or distribution is strictly prohibited.
8
+ * See LICENSE file for full terms.
9
+ */
10
+
11
+ "use strict";const n=new Map;let d=0,r=null;function c(){const e=d++;return n.set(e,null),r=e,e}function l(e){n.delete(e),r===e&&(r=null)}function o(){return r===null?null:n.get(r)??null}function i(e){if(r===null)throw new Error("No active render context");n.set(r,e)}function a(){if(r===null)throw new Error("createServerVNode called outside of render context");return{_parent:o(),_renderId:r}}function s(e,u){const t=o();if(!t)throw new Error("provideServerContext called outside of component render");t._contextMap||(t._contextMap=new Map),t._contextMap.set(e,u)}function x(e,u){let t=o();for(;t;){if(t._contextMap?.has(e))return t._contextMap.get(e);t=t._parent}return u}exports.consumeServerContext=x;exports.createServerVNode=a;exports.endRenderContext=l;exports.getCurrentServerVNode=o;exports.provideServerContext=s;exports.setCurrentServerVNode=i;exports.startRenderContext=c;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @license
3
+ * Flash
4
+ * Copyright (c) 2025 Mateo Suarez. All rights reserved.
5
+ *
6
+ * Free to use in your own personal or commercial applications and projects.
7
+ * Unauthorized copying, modification, or distribution is strictly prohibited.
8
+ * See LICENSE file for full terms.
9
+ */
10
+
11
+ const r = /* @__PURE__ */ new Map();
12
+ let u = 0, n = null;
13
+ function a() {
14
+ const e = u++;
15
+ return r.set(e, null), n = e, e;
16
+ }
17
+ function l(e) {
18
+ r.delete(e), n === e && (n = null);
19
+ }
20
+ function c() {
21
+ return n === null ? null : r.get(n) ?? null;
22
+ }
23
+ function d(e) {
24
+ if (n === null)
25
+ throw new Error("No active render context");
26
+ r.set(n, e);
27
+ }
28
+ function s() {
29
+ if (n === null)
30
+ throw new Error("createServerVNode called outside of render context");
31
+ return {
32
+ _parent: c(),
33
+ _renderId: n
34
+ };
35
+ }
36
+ function i(e, o) {
37
+ const t = c();
38
+ if (!t)
39
+ throw new Error("provideServerContext called outside of component render");
40
+ t._contextMap || (t._contextMap = /* @__PURE__ */ new Map()), t._contextMap.set(e, o);
41
+ }
42
+ function f(e, o) {
43
+ let t = c();
44
+ for (; t; ) {
45
+ if (t._contextMap?.has(e))
46
+ return t._contextMap.get(e);
47
+ t = t._parent;
48
+ }
49
+ return o;
50
+ }
51
+ export {
52
+ d as a,
53
+ f as b,
54
+ s as c,
55
+ l as e,
56
+ c as g,
57
+ i as p,
58
+ a as s
59
+ };
package/dist/server.cjs CHANGED
@@ -8,20 +8,20 @@
8
8
  * See LICENSE file for full terms.
9
9
  */
10
10
 
11
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./server-context-BPTFSl-d.cjs"),$=require("node:fs/promises"),g=require("node:path");function N(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function b(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const C=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);function H(t){return/^on[A-Z]/.test(t)}function j(t){return Object.entries(t).map(([r,o])=>`${r.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}:${o}`).join(";")}function E(t,r=!0){const o=Object.entries(t).filter(([e,n])=>!(n==null||r&&e==="children"||e==="innerHTML"||H(e))).map(([e,n])=>(e==="className"&&(e="class"),e==="style"&&typeof n=="object"&&(n=j(n)),typeof n=="boolean"?n?e:"":`${e}="${b(String(n))}"`)).filter(Boolean).join(" ");return o?` ${o}`:""}function v(t){return t?Array.isArray(t)?t:[t]:[]}function T(t){return t&&typeof t.then=="function"}function S(t,r){return`<div id="${t}" data-server-component="suspended" data-component-name="${r}">Loading...</div>`}const d=new Map;let y=0;function w(t){return d.clear(),y=0,u.resetServerContext(),c(t)}async function D(t){d.clear(),y=0,u.resetServerContext();let r=c(t);for(;d.size>0;){console.log(`🔄 Resolving ${d.size} async components in parallel...`);const o=Array.from(d.entries());d.clear();const e=await Promise.allSettled(o.map(([n,{promise:a}])=>a));for(let n=0;n<o.length;n++){const a=o[n];if(!a)continue;const[l,{componentName:s,errorFallback:i,parentNode:f}]=a,m=e[n];if(!m)continue;const h=S(l,s);if(m.status==="fulfilled")try{console.log(`✅ Resolved: ${s} (${l})`),u.setCurrentServerVNode(f);const p=c(m.value);r=r.replace(h,p)}catch(p){console.error(`❌ Error rendering ${s}:`,p),u.setCurrentServerVNode(f);const A=i?c(typeof i=="function"?i(p):i):`<div class="error">Error rendering ${s}</div>`;r=r.replace(h,A)}else{console.error(`❌ Error resolving ${s}:`,m.reason),u.setCurrentServerVNode(f);const p=i?c(typeof i=="function"?i(m.reason):i):`<div class="error">Error loading ${s}</div>`;r=r.replace(h,p)}}}return console.log("✅ All async components resolved!"),r}async function*x(t){for(d.clear(),y=0,u.resetServerContext(),yield c(t);d.size>0;){const o=Array.from(d.entries());d.clear();const e=o.map(async([n,{promise:a,parentNode:l}])=>{try{const s=await a;u.setCurrentServerVNode(l);const i=c(s);return`<script>
11
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./server-context-C7Uxb3AS.cjs"),S=require("node:fs/promises"),g=require("node:path");function N(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function b(r){return r.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const H=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);function j(r){return/^on[A-Z]/.test(r)}function E(r){return Object.entries(r).map(([t,n])=>`${t.replace(/[A-Z]/g,o=>`-${o.toLowerCase()}`)}:${n}`).join(";")}function T(r,t=!0){const n=Object.entries(r).filter(([e,o])=>!(o==null||t&&e==="children"||e==="innerHTML"||j(e))).map(([e,o])=>(e==="className"&&(e="class"),e==="style"&&typeof o=="object"&&(o=E(o)),typeof o=="boolean"?o?e:"":`${e}="${b(String(o))}"`)).filter(Boolean).join(" ");return n?` ${n}`:""}function A(r){return r?Array.isArray(r)?r:[r]:[]}function w(r){return r&&typeof r.then=="function"}function v(r,t){return`<div id="${r}" data-server-component="suspended" data-component-name="${t}">Loading...</div>`}const p=new Map;let y=0;function D(r){p.clear(),y=0;const t=l.startRenderContext();try{return a(r)}finally{l.endRenderContext(t)}}async function x(r){p.clear(),y=0;const t=l.startRenderContext();try{let n=a(r);for(;p.size>0;){console.log(`🔄 Resolving ${p.size} async components in parallel...`);const e=Array.from(p.entries());p.clear();const o=await Promise.allSettled(e.map(([s,{promise:i}])=>i));for(let s=0;s<e.length;s++){const i=e[s];if(!i)continue;const[u,{componentName:c,errorFallback:d,parentNode:h}]=i,m=o[s];if(!m)continue;const $=v(u,c);if(m.status==="fulfilled")try{console.log(`✅ Resolved: ${c} (${u})`),l.setCurrentServerVNode(h);const f=a(m.value);n=n.replace($,f)}catch(f){console.error(`❌ Error rendering ${c}:`,f),l.setCurrentServerVNode(h);const C=d?a(typeof d=="function"?d(f):d):`<div class="error">Error rendering ${c}</div>`;n=n.replace($,C)}else{console.error(`❌ Error resolving ${c}:`,m.reason),l.setCurrentServerVNode(h);const f=d?a(typeof d=="function"?d(m.reason):d):`<div class="error">Error loading ${c}</div>`;n=n.replace($,f)}}}return console.log("✅ All async components resolved!"),n}finally{l.endRenderContext(t)}}async function*P(r){p.clear(),y=0;const t=l.startRenderContext();try{for(yield a(r);p.size>0;){const e=Array.from(p.entries());p.clear();const o=e.map(async([s,{promise:i,parentNode:u}])=>{try{const c=await i;l.setCurrentServerVNode(u);const d=a(c);return`<script>
12
12
  (function() {
13
- const el = document.getElementById('${n}');
13
+ const el = document.getElementById('${s}');
14
14
  if (el) {
15
- el.outerHTML = \`${i.replace(/`/g,"\\`").replace(/\$/g,"\\$")}\`;
15
+ el.outerHTML = \`${d.replace(/`/g,"\\`").replace(/\$/g,"\\$")}\`;
16
16
  }
17
17
  })();
18
18
  <\/script>`}catch{return`<script>
19
19
  (function() {
20
- const el = document.getElementById('${n}');
20
+ const el = document.getElementById('${s}');
21
21
  if (el) {
22
22
  el.innerHTML = '<div class="error">Error loading component</div>';
23
23
  }
24
24
  })();
25
- <\/script>`}});for(const n of e)yield await n}}function c(t){if(typeof t=="function"){const e=t();return Array.isArray(e)?`<!--reactive-list-->${e.map(a=>c(a)).join("")}`:c(e)}if(typeof t=="string")return N(t);if(typeof t=="number")return String(t);if(Array.isArray(t))return t.map(e=>c(e)).join("");if(!t||typeof t!="object")return"";const{type:r,props:o}=t;if(r===Symbol.for("jsx.fragment"))return v(o.children).map(n=>c(n)).join("");if(typeof r=="string"&&r==="suspended"){const e=t,n=`async-${y++}`;return console.log(`⏳ Suspending: ${e._componentName} (${n})`),d.set(n,{id:n,promise:e.promise,componentName:e._componentName,errorFallback:e.errorFallback,parentNode:u.getCurrentServerVNode()}),S(n,e._componentName)}if(typeof r=="function"){const e=u.createServerVNode(),n=u.getCurrentServerVNode();u.setCurrentServerVNode(e);const a=r(o);if(T(a)){const s=`async-${y++}`,i=r.name||"AsyncComponent";return console.warn(`⚠️ DEPRECATED: Direct async component "${i}" detected. Please use suspend() HOF instead for better type safety and custom fallbacks.
26
- Example: const ${i} = suspend(async (props) => { ... }, <Loading />, <Error />);`),console.log(`⏳ Suspending: ${i} (${s})`),d.set(s,{id:s,promise:a,componentName:i,parentNode:e}),u.setCurrentServerVNode(n),S(s,i)}const l=c(a);return u.setCurrentServerVNode(n),l}if(typeof r=="string"){const e=E(o);if(C.has(r))return`<${r}${e} />`;if(o.innerHTML!==void 0){const l=typeof o.innerHTML=="object"?JSON.stringify(o.innerHTML):o.innerHTML;return`<${r}${e}>${l}</${r}>`}const a=v(o.children).map(l=>{if(Array.isArray(l))return l.map(s=>c(s)).join("");if(typeof l=="function"){const s=l();return Array.isArray(s)?`<!--reactive-list-->${s.map(f=>c(f)).join("")}`:`<!--reactive-->${c(s)}`}return c(l)}).join("");return r==="html"?`<!DOCTYPE html>
27
- <html${e}>${a}</html>`:`<${r}${e}>${a}</${r}>`}return""}class P{cacheDir;useDirectoryStructure;constructor(r={}){this.cacheDir=r.cacheDir||"./cache/html",this.useDirectoryStructure=r.useDirectoryStructure??!1}async save(r,o){const e=this.getFilepath(r);return await $.mkdir(g.dirname(e),{recursive:!0}),await Bun.write(e,o),console.log(`✅ Pre-rendered: ${r} → ${e}`),e}async load(r){const o=this.getFilepath(r),e=Bun.file(o);return await e.exists()?e:null}async clear(){await $.rm(this.cacheDir,{recursive:!0,force:!0}),await $.mkdir(this.cacheDir,{recursive:!0}),console.log("🗑️ Cache cleared")}async exists(r){const o=this.getFilepath(r);return await Bun.file(o).exists()}getFilepath(r){const o=r.replace(/^\/+|\/+$/g,"");if(this.useDirectoryStructure)return o===""?g.join(this.cacheDir,"index.html"):g.join(this.cacheDir,o,"index.html");{const e=o===""?"index.html":`${o.replace(/\//g,"-")}.html`;return g.join(this.cacheDir,e)}}}exports.PreRenderer=P;exports.renderToStream=x;exports.renderToString=w;exports.renderToStringAsync=D;
25
+ <\/script>`}});for(const s of o)yield await s}}finally{l.endRenderContext(t)}}function a(r){if(typeof r=="function"){const e=r();return Array.isArray(e)?`<!--reactive-list-->${e.map(s=>a(s)).join("")}`:a(e)}if(typeof r=="string")return N(r);if(typeof r=="number")return String(r);if(Array.isArray(r))return r.map(e=>a(e)).join("");if(!r||typeof r!="object")return"";const{type:t,props:n}=r;if(t===Symbol.for("jsx.fragment"))return A(n.children).map(o=>a(o)).join("");if(typeof t=="string"&&t==="suspended"){const e=r,o=`async-${y++}`;return console.log(`⏳ Suspending: ${e._componentName} (${o})`),p.set(o,{id:o,promise:e.promise,componentName:e._componentName,errorFallback:e.errorFallback,parentNode:l.getCurrentServerVNode()}),v(o,e._componentName)}if(typeof t=="function"){const e=l.createServerVNode(),o=l.getCurrentServerVNode();l.setCurrentServerVNode(e);const s=t(n);if(w(s)){const u=`async-${y++}`,c=t.name||"AsyncComponent";return console.warn(`⚠️ DEPRECATED: Direct async component "${c}" detected. Please use suspend() HOF instead for better type safety and custom fallbacks.
26
+ Example: const ${c} = suspend(async (props) => { ... }, <Loading />, <Error />);`),console.log(`⏳ Suspending: ${c} (${u})`),p.set(u,{id:u,promise:s,componentName:c,parentNode:e}),l.setCurrentServerVNode(o),v(u,c)}const i=a(s);return l.setCurrentServerVNode(o),i}if(typeof t=="string"){const e=T(n);if(H.has(t))return`<${t}${e} />`;if(n.innerHTML!==void 0){const i=typeof n.innerHTML=="object"?JSON.stringify(n.innerHTML):n.innerHTML;return`<${t}${e}>${i}</${t}>`}const s=A(n.children).map(i=>{if(Array.isArray(i))return i.map(u=>a(u)).join("");if(typeof i=="function"){const u=i();return Array.isArray(u)?`<!--reactive-list-->${u.map(d=>a(d)).join("")}`:`<!--reactive-->${a(u)}`}return a(i)}).join("");return t==="html"?`<!DOCTYPE html>
27
+ <html${e}>${s}</html>`:`<${t}${e}>${s}</${t}>`}return""}class V{cacheDir;useDirectoryStructure;constructor(t={}){this.cacheDir=t.cacheDir||"./cache/html",this.useDirectoryStructure=t.useDirectoryStructure??!1}async save(t,n){const e=this.getFilepath(t);return await S.mkdir(g.dirname(e),{recursive:!0}),await Bun.write(e,n),console.log(`✅ Pre-rendered: ${t} → ${e}`),e}async load(t){const n=this.getFilepath(t),e=Bun.file(n);return await e.exists()?e:null}async clear(){await S.rm(this.cacheDir,{recursive:!0,force:!0}),await S.mkdir(this.cacheDir,{recursive:!0}),console.log("🗑️ Cache cleared")}async exists(t){const n=this.getFilepath(t);return await Bun.file(n).exists()}getFilepath(t){const n=t.replace(/^\/+|\/+$/g,"");if(this.useDirectoryStructure)return n===""?g.join(this.cacheDir,"index.html"):g.join(this.cacheDir,n,"index.html");{const e=n===""?"index.html":`${n.replace(/\//g,"-")}.html`;return g.join(this.cacheDir,e)}}}exports.PreRenderer=V;exports.renderToStream=P;exports.renderToString=D;exports.renderToStringAsync=x;
package/dist/server.js CHANGED
@@ -8,16 +8,16 @@
8
8
  * See LICENSE file for full terms.
9
9
  */
10
10
 
11
- import { s as p, g as v, c as E, r as S } from "./server-context-BA2xc7wp.js";
12
- import { mkdir as A, rm as N } from "node:fs/promises";
13
- import { dirname as w, join as h } from "node:path";
14
- function D(t) {
15
- return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
11
+ import { s as v, e as A, a as f, g as b, c as w } from "./server-context-CJbtcTMO.js";
12
+ import { mkdir as H, rm as D } from "node:fs/promises";
13
+ import { dirname as j, join as $ } from "node:path";
14
+ function T(r) {
15
+ return r.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
16
16
  }
17
- function j(t) {
18
- return t.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
17
+ function C(r) {
18
+ return r.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
19
19
  }
20
- const T = /* @__PURE__ */ new Set([
20
+ const x = /* @__PURE__ */ new Set([
21
21
  "area",
22
22
  "base",
23
23
  "br",
@@ -32,208 +32,225 @@ const T = /* @__PURE__ */ new Set([
32
32
  "track",
33
33
  "wbr"
34
34
  ]);
35
- function C(t) {
36
- return /^on[A-Z]/.test(t);
35
+ function L(r) {
36
+ return /^on[A-Z]/.test(r);
37
37
  }
38
- function L(t) {
39
- return Object.entries(t).map(([r, o]) => `${r.replace(/[A-Z]/g, (n) => `-${n.toLowerCase()}`)}:${o}`).join(";");
38
+ function P(r) {
39
+ return Object.entries(r).map(([t, n]) => `${t.replace(/[A-Z]/g, (o) => `-${o.toLowerCase()}`)}:${n}`).join(";");
40
40
  }
41
- function x(t, r = !0) {
42
- const o = Object.entries(t).filter(([e, n]) => !(n == null || r && e === "children" || e === "innerHTML" || C(e))).map(([e, n]) => (e === "className" && (e = "class"), e === "style" && typeof n == "object" && (n = L(n)), typeof n == "boolean" ? n ? e : "" : `${e}="${j(String(n))}"`)).filter(Boolean).join(" ");
43
- return o ? ` ${o}` : "";
41
+ function I(r, t = !0) {
42
+ const n = Object.entries(r).filter(([e, o]) => !(o == null || t && e === "children" || e === "innerHTML" || L(e))).map(([e, o]) => (e === "className" && (e = "class"), e === "style" && typeof o == "object" && (o = P(o)), typeof o == "boolean" ? o ? e : "" : `${e}="${C(String(o))}"`)).filter(Boolean).join(" ");
43
+ return n ? ` ${n}` : "";
44
44
  }
45
- function b(t) {
46
- return t ? Array.isArray(t) ? t : [t] : [];
45
+ function E(r) {
46
+ return r ? Array.isArray(r) ? r : [r] : [];
47
47
  }
48
- function P(t) {
49
- return t && typeof t.then == "function";
48
+ function M(r) {
49
+ return r && typeof r.then == "function";
50
50
  }
51
- function $(t, r) {
52
- return `<div id="${t}" data-server-component="suspended" data-component-name="${r}">Loading...</div>`;
51
+ function S(r, t) {
52
+ return `<div id="${r}" data-server-component="suspended" data-component-name="${t}">Loading...</div>`;
53
53
  }
54
- const u = /* @__PURE__ */ new Map();
54
+ const p = /* @__PURE__ */ new Map();
55
55
  let y = 0;
56
- function B(t) {
57
- return u.clear(), y = 0, S(), c(t);
56
+ function O(r) {
57
+ p.clear(), y = 0;
58
+ const t = v();
59
+ try {
60
+ return a(r);
61
+ } finally {
62
+ A(t);
63
+ }
58
64
  }
59
- async function I(t) {
60
- u.clear(), y = 0, S();
61
- let r = c(t);
62
- for (; u.size > 0; ) {
63
- console.log(
64
- `🔄 Resolving ${u.size} async components in parallel...`
65
- );
66
- const o = Array.from(u.entries());
67
- u.clear();
68
- const e = await Promise.allSettled(
69
- o.map(([n, { promise: a }]) => a)
70
- );
71
- for (let n = 0; n < o.length; n++) {
72
- const a = o[n];
73
- if (!a) continue;
74
- const [l, { componentName: i, errorFallback: s, parentNode: d }] = a, m = e[n];
75
- if (!m) continue;
76
- const g = $(l, i);
77
- if (m.status === "fulfilled")
78
- try {
79
- console.log(`✅ Resolved: ${i} (${l})`), p(d);
80
- const f = c(m.value);
81
- r = r.replace(g, f);
82
- } catch (f) {
83
- console.error(`❌ Error rendering ${i}:`, f), p(d);
84
- const H = s ? c(
85
- typeof s == "function" ? s(f) : s
86
- ) : `<div class="error">Error rendering ${i}</div>`;
87
- r = r.replace(g, H);
65
+ async function R(r) {
66
+ p.clear(), y = 0;
67
+ const t = v();
68
+ try {
69
+ let n = a(r);
70
+ for (; p.size > 0; ) {
71
+ console.log(
72
+ `🔄 Resolving ${p.size} async components in parallel...`
73
+ );
74
+ const e = Array.from(p.entries());
75
+ p.clear();
76
+ const o = await Promise.allSettled(
77
+ e.map(([i, { promise: s }]) => s)
78
+ );
79
+ for (let i = 0; i < e.length; i++) {
80
+ const s = e[i];
81
+ if (!s) continue;
82
+ const [l, { componentName: c, errorFallback: u, parentNode: g }] = s, m = o[i];
83
+ if (!m) continue;
84
+ const h = S(l, c);
85
+ if (m.status === "fulfilled")
86
+ try {
87
+ console.log(`✅ Resolved: ${c} (${l})`), f(g);
88
+ const d = a(m.value);
89
+ n = n.replace(h, d);
90
+ } catch (d) {
91
+ console.error(`❌ Error rendering ${c}:`, d), f(g);
92
+ const N = u ? a(
93
+ typeof u == "function" ? u(d) : u
94
+ ) : `<div class="error">Error rendering ${c}</div>`;
95
+ n = n.replace(h, N);
96
+ }
97
+ else {
98
+ console.error(`❌ Error resolving ${c}:`, m.reason), f(g);
99
+ const d = u ? a(
100
+ typeof u == "function" ? u(m.reason) : u
101
+ ) : `<div class="error">Error loading ${c}</div>`;
102
+ n = n.replace(h, d);
88
103
  }
89
- else {
90
- console.error(`❌ Error resolving ${i}:`, m.reason), p(d);
91
- const f = s ? c(
92
- typeof s == "function" ? s(m.reason) : s
93
- ) : `<div class="error">Error loading ${i}</div>`;
94
- r = r.replace(g, f);
95
104
  }
96
105
  }
106
+ return console.log("✅ All async components resolved!"), n;
107
+ } finally {
108
+ A(t);
97
109
  }
98
- return console.log("✅ All async components resolved!"), r;
99
110
  }
100
- async function* O(t) {
101
- for (u.clear(), y = 0, S(), yield c(t); u.size > 0; ) {
102
- const o = Array.from(u.entries());
103
- u.clear();
104
- const e = o.map(
105
- async ([n, { promise: a, parentNode: l }]) => {
106
- try {
107
- const i = await a;
108
- p(l);
109
- const s = c(i);
110
- return `<script>
111
+ async function* V(r) {
112
+ p.clear(), y = 0;
113
+ const t = v();
114
+ try {
115
+ for (yield a(r); p.size > 0; ) {
116
+ const e = Array.from(p.entries());
117
+ p.clear();
118
+ const o = e.map(
119
+ async ([i, { promise: s, parentNode: l }]) => {
120
+ try {
121
+ const c = await s;
122
+ f(l);
123
+ const u = a(c);
124
+ return `<script>
111
125
  (function() {
112
- const el = document.getElementById('${n}');
126
+ const el = document.getElementById('${i}');
113
127
  if (el) {
114
- el.outerHTML = \`${s.replace(/`/g, "\\`").replace(/\$/g, "\\$")}\`;
128
+ el.outerHTML = \`${u.replace(/`/g, "\\`").replace(/\$/g, "\\$")}\`;
115
129
  }
116
130
  })();
117
131
  <\/script>`;
118
- } catch {
119
- return `<script>
132
+ } catch {
133
+ return `<script>
120
134
  (function() {
121
- const el = document.getElementById('${n}');
135
+ const el = document.getElementById('${i}');
122
136
  if (el) {
123
137
  el.innerHTML = '<div class="error">Error loading component</div>';
124
138
  }
125
139
  })();
126
140
  <\/script>`;
141
+ }
127
142
  }
128
- }
129
- );
130
- for (const n of e)
131
- yield await n;
143
+ );
144
+ for (const i of o)
145
+ yield await i;
146
+ }
147
+ } finally {
148
+ A(t);
132
149
  }
133
150
  }
134
- function c(t) {
135
- if (typeof t == "function") {
136
- const e = t();
137
- return Array.isArray(e) ? `<!--reactive-list-->${e.map((a) => c(a)).join("")}` : c(e);
151
+ function a(r) {
152
+ if (typeof r == "function") {
153
+ const e = r();
154
+ return Array.isArray(e) ? `<!--reactive-list-->${e.map((i) => a(i)).join("")}` : a(e);
138
155
  }
139
- if (typeof t == "string")
140
- return D(t);
141
- if (typeof t == "number")
142
- return String(t);
143
- if (Array.isArray(t))
144
- return t.map((e) => c(e)).join("");
145
- if (!t || typeof t != "object")
156
+ if (typeof r == "string")
157
+ return T(r);
158
+ if (typeof r == "number")
159
+ return String(r);
160
+ if (Array.isArray(r))
161
+ return r.map((e) => a(e)).join("");
162
+ if (!r || typeof r != "object")
146
163
  return "";
147
- const { type: r, props: o } = t;
148
- if (r === Symbol.for("jsx.fragment"))
149
- return b(o.children).map((n) => c(n)).join("");
150
- if (typeof r == "string" && r === "suspended") {
151
- const e = t, n = `async-${y++}`;
164
+ const { type: t, props: n } = r;
165
+ if (t === Symbol.for("jsx.fragment"))
166
+ return E(n.children).map((o) => a(o)).join("");
167
+ if (typeof t == "string" && t === "suspended") {
168
+ const e = r, o = `async-${y++}`;
152
169
  return console.log(
153
- `⏳ Suspending: ${e._componentName} (${n})`
154
- ), u.set(n, {
155
- id: n,
170
+ `⏳ Suspending: ${e._componentName} (${o})`
171
+ ), p.set(o, {
172
+ id: o,
156
173
  promise: e.promise,
157
174
  componentName: e._componentName,
158
175
  errorFallback: e.errorFallback,
159
- parentNode: v()
160
- }), $(n, e._componentName);
176
+ parentNode: b()
177
+ }), S(o, e._componentName);
161
178
  }
162
- if (typeof r == "function") {
163
- const e = E(), n = v();
164
- p(e);
165
- const a = r(o);
166
- if (P(a)) {
167
- const i = `async-${y++}`, s = r.name || "AsyncComponent";
179
+ if (typeof t == "function") {
180
+ const e = w(), o = b();
181
+ f(e);
182
+ const i = t(n);
183
+ if (M(i)) {
184
+ const l = `async-${y++}`, c = t.name || "AsyncComponent";
168
185
  return console.warn(
169
- `⚠️ DEPRECATED: Direct async component "${s}" detected. Please use suspend() HOF instead for better type safety and custom fallbacks.
170
- Example: const ${s} = suspend(async (props) => { ... }, <Loading />, <Error />);`
171
- ), console.log(`⏳ Suspending: ${s} (${i})`), u.set(i, {
172
- id: i,
173
- promise: a,
174
- componentName: s,
186
+ `⚠️ DEPRECATED: Direct async component "${c}" detected. Please use suspend() HOF instead for better type safety and custom fallbacks.
187
+ Example: const ${c} = suspend(async (props) => { ... }, <Loading />, <Error />);`
188
+ ), console.log(`⏳ Suspending: ${c} (${l})`), p.set(l, {
189
+ id: l,
190
+ promise: i,
191
+ componentName: c,
175
192
  parentNode: e
176
- }), p(n), $(i, s);
193
+ }), f(o), S(l, c);
177
194
  }
178
- const l = c(a);
179
- return p(n), l;
195
+ const s = a(i);
196
+ return f(o), s;
180
197
  }
181
- if (typeof r == "string") {
182
- const e = x(o);
183
- if (T.has(r))
184
- return `<${r}${e} />`;
185
- if (o.innerHTML !== void 0) {
186
- const l = typeof o.innerHTML == "object" ? JSON.stringify(o.innerHTML) : o.innerHTML;
187
- return `<${r}${e}>${l}</${r}>`;
198
+ if (typeof t == "string") {
199
+ const e = I(n);
200
+ if (x.has(t))
201
+ return `<${t}${e} />`;
202
+ if (n.innerHTML !== void 0) {
203
+ const s = typeof n.innerHTML == "object" ? JSON.stringify(n.innerHTML) : n.innerHTML;
204
+ return `<${t}${e}>${s}</${t}>`;
188
205
  }
189
- const a = b(o.children).map((l) => {
190
- if (Array.isArray(l))
191
- return l.map((i) => c(i)).join("");
192
- if (typeof l == "function") {
193
- const i = l();
194
- return Array.isArray(i) ? `<!--reactive-list-->${i.map((d) => c(d)).join("")}` : `<!--reactive-->${c(i)}`;
206
+ const i = E(n.children).map((s) => {
207
+ if (Array.isArray(s))
208
+ return s.map((l) => a(l)).join("");
209
+ if (typeof s == "function") {
210
+ const l = s();
211
+ return Array.isArray(l) ? `<!--reactive-list-->${l.map((u) => a(u)).join("")}` : `<!--reactive-->${a(l)}`;
195
212
  }
196
- return c(l);
213
+ return a(s);
197
214
  }).join("");
198
- return r === "html" ? `<!DOCTYPE html>
199
- <html${e}>${a}</html>` : `<${r}${e}>${a}</${r}>`;
215
+ return t === "html" ? `<!DOCTYPE html>
216
+ <html${e}>${i}</html>` : `<${t}${e}>${i}</${t}>`;
200
217
  }
201
218
  return "";
202
219
  }
203
- class V {
220
+ class _ {
204
221
  cacheDir;
205
222
  useDirectoryStructure;
206
- constructor(r = {}) {
207
- this.cacheDir = r.cacheDir || "./cache/html", this.useDirectoryStructure = r.useDirectoryStructure ?? !1;
223
+ constructor(t = {}) {
224
+ this.cacheDir = t.cacheDir || "./cache/html", this.useDirectoryStructure = t.useDirectoryStructure ?? !1;
208
225
  }
209
- async save(r, o) {
210
- const e = this.getFilepath(r);
211
- return await A(w(e), { recursive: !0 }), await Bun.write(e, o), console.log(`✅ Pre-rendered: ${r} → ${e}`), e;
226
+ async save(t, n) {
227
+ const e = this.getFilepath(t);
228
+ return await H(j(e), { recursive: !0 }), await Bun.write(e, n), console.log(`✅ Pre-rendered: ${t} → ${e}`), e;
212
229
  }
213
- async load(r) {
214
- const o = this.getFilepath(r), e = Bun.file(o);
230
+ async load(t) {
231
+ const n = this.getFilepath(t), e = Bun.file(n);
215
232
  return await e.exists() ? e : null;
216
233
  }
217
234
  async clear() {
218
- await N(this.cacheDir, { recursive: !0, force: !0 }), await A(this.cacheDir, { recursive: !0 }), console.log("🗑️ Cache cleared");
235
+ await D(this.cacheDir, { recursive: !0, force: !0 }), await H(this.cacheDir, { recursive: !0 }), console.log("🗑️ Cache cleared");
219
236
  }
220
- async exists(r) {
221
- const o = this.getFilepath(r);
222
- return await Bun.file(o).exists();
237
+ async exists(t) {
238
+ const n = this.getFilepath(t);
239
+ return await Bun.file(n).exists();
223
240
  }
224
- getFilepath(r) {
225
- const o = r.replace(/^\/+|\/+$/g, "");
241
+ getFilepath(t) {
242
+ const n = t.replace(/^\/+|\/+$/g, "");
226
243
  if (this.useDirectoryStructure)
227
- return o === "" ? h(this.cacheDir, "index.html") : h(this.cacheDir, o, "index.html");
244
+ return n === "" ? $(this.cacheDir, "index.html") : $(this.cacheDir, n, "index.html");
228
245
  {
229
- const e = o === "" ? "index.html" : `${o.replace(/\//g, "-")}.html`;
230
- return h(this.cacheDir, e);
246
+ const e = n === "" ? "index.html" : `${n.replace(/\//g, "-")}.html`;
247
+ return $(this.cacheDir, e);
231
248
  }
232
249
  }
233
250
  }
234
251
  export {
235
- V as PreRenderer,
236
- O as renderToStream,
237
- B as renderToString,
238
- I as renderToStringAsync
252
+ _ as PreRenderer,
253
+ V as renderToStream,
254
+ O as renderToString,
255
+ R as renderToStringAsync
239
256
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mateosuarezdev/flash",
3
- "version": "0.0.11",
3
+ "version": "0.0.14",
4
4
  "description": "Custom jsx runtime",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -1,47 +0,0 @@
1
- /**
2
- * @license
3
- * Flash
4
- * Copyright (c) 2025 Mateo Suarez. All rights reserved.
5
- *
6
- * Free to use in your own personal or commercial applications and projects.
7
- * Unauthorized copying, modification, or distribution is strictly prohibited.
8
- * See LICENSE file for full terms.
9
- */
10
-
11
- let e = null;
12
- function o() {
13
- return e;
14
- }
15
- function a(r) {
16
- e = r;
17
- }
18
- function c() {
19
- return {
20
- _parent: e
21
- };
22
- }
23
- function u() {
24
- e = null;
25
- }
26
- function p(r, n) {
27
- if (!e)
28
- throw new Error("provideServerContext called outside of component render");
29
- e._contextMap || (e._contextMap = /* @__PURE__ */ new Map()), e._contextMap.set(r, n);
30
- }
31
- function s(r, n) {
32
- let t = e;
33
- for (; t; ) {
34
- if (t._contextMap?.has(r))
35
- return t._contextMap.get(r);
36
- t = t._parent;
37
- }
38
- return n;
39
- }
40
- export {
41
- s as a,
42
- c,
43
- o as g,
44
- p,
45
- u as r,
46
- a as s
47
- };
@@ -1,11 +0,0 @@
1
- /**
2
- * @license
3
- * Flash
4
- * Copyright (c) 2025 Mateo Suarez. All rights reserved.
5
- *
6
- * Free to use in your own personal or commercial applications and projects.
7
- * Unauthorized copying, modification, or distribution is strictly prohibited.
8
- * See LICENSE file for full terms.
9
- */
10
-
11
- "use strict";let e=null;function o(){return e}function u(r){e=r}function c(){return{_parent:e}}function v(){e=null}function i(r,n){if(!e)throw new Error("provideServerContext called outside of component render");e._contextMap||(e._contextMap=new Map),e._contextMap.set(r,n)}function S(r,n){let t=e;for(;t;){if(t._contextMap?.has(r))return t._contextMap.get(r);t=t._parent}return n}exports.consumeServerContext=S;exports.createServerVNode=c;exports.getCurrentServerVNode=o;exports.provideServerContext=i;exports.resetServerContext=v;exports.setCurrentServerVNode=u;