elit 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +267 -101
  2. package/dist/build.d.mts +11 -0
  3. package/dist/build.d.ts +11 -0
  4. package/dist/build.js +1 -0
  5. package/dist/build.mjs +1 -0
  6. package/dist/cli.js +2307 -0
  7. package/dist/client.d.mts +9 -0
  8. package/dist/client.d.ts +9 -0
  9. package/dist/client.js +1 -0
  10. package/dist/client.mjs +1 -0
  11. package/dist/dom.d.mts +80 -0
  12. package/dist/dom.d.ts +80 -0
  13. package/dist/dom.js +1 -0
  14. package/dist/dom.mjs +1 -0
  15. package/dist/el.d.mts +227 -0
  16. package/dist/el.d.ts +227 -0
  17. package/dist/el.js +1 -0
  18. package/dist/el.mjs +1 -0
  19. package/dist/hmr.d.mts +38 -0
  20. package/dist/hmr.d.ts +38 -0
  21. package/dist/hmr.js +1 -0
  22. package/dist/hmr.mjs +1 -0
  23. package/dist/index.d.mts +38 -619
  24. package/dist/index.d.ts +38 -619
  25. package/dist/index.js +1 -35
  26. package/dist/index.mjs +1 -35
  27. package/dist/router.d.mts +45 -0
  28. package/dist/router.d.ts +45 -0
  29. package/dist/router.js +1 -0
  30. package/dist/router.mjs +1 -0
  31. package/dist/server.d.mts +3 -0
  32. package/dist/server.d.ts +3 -0
  33. package/dist/server.js +1 -0
  34. package/dist/server.mjs +1 -0
  35. package/dist/state.d.mts +109 -0
  36. package/dist/state.d.ts +109 -0
  37. package/dist/state.js +1 -0
  38. package/dist/state.mjs +1 -0
  39. package/dist/style.d.mts +113 -0
  40. package/dist/style.d.ts +113 -0
  41. package/dist/style.js +1 -0
  42. package/dist/style.mjs +1 -0
  43. package/dist/types-DOAdFFJB.d.mts +330 -0
  44. package/dist/types-DOAdFFJB.d.ts +330 -0
  45. package/dist/types.d.mts +3 -0
  46. package/dist/types.d.ts +3 -0
  47. package/dist/types.js +1 -0
  48. package/dist/types.mjs +0 -0
  49. package/package.json +65 -2
  50. package/dist/index.global.js +0 -35
package/dist/index.js CHANGED
@@ -1,35 +1 @@
1
- 'use strict';var Z=Object.defineProperty;var Q=(i,e)=>{for(var t in e)Z(i,t,{get:e[t],enumerable:true});};var E=class{constructor(){this.elementCache=new WeakMap;this.reactiveNodes=new Map;}createElement(e,t={},r=[]){return {tagName:e,props:t,children:r}}renderToDOM(e,t){if(e==null||e===false)return;if(typeof e!="object"){t.appendChild(document.createTextNode(String(e)));return}let{tagName:r,props:n,children:s}=e,a=r==="svg"||r[0]==="s"&&r[1]==="v"&&r[2]==="g"||t.namespaceURI==="http://www.w3.org/2000/svg",o=a?document.createElementNS("http://www.w3.org/2000/svg",r.replace("svg","").toLowerCase()||r):document.createElement(r);for(let p in n){let d=n[p];if(d==null||d===false)continue;let c=p.charCodeAt(0);if(c===99&&(p.length<6||p[5]==="N")){let h=Array.isArray(d)?d.join(" "):d;a?o.setAttribute("class",h):o.className=h;}else if(c===115&&p.length===5)if(typeof d=="string")o.style.cssText=d;else {let h=o.style;for(let g in d)h[g]=d[g];}else c===111&&p.charCodeAt(1)===110?o[p.toLowerCase()]=d:c===100&&p.length>20?o.innerHTML=d.__html:c===114&&p.length===3?setTimeout(()=>{typeof d=="function"?d(o):d.current=o;},0):o.setAttribute(p,d===true?"":String(d));}let u=s.length;if(!u){t.appendChild(o);return}let l=p=>{for(let d=0;d<u;d++){let c=s[d];if(!(c==null||c===false))if(Array.isArray(c))for(let h=0,g=c.length;h<g;h++){let v=c[h];v!=null&&v!==false&&this.renderToDOM(v,p);}else this.renderToDOM(c,p);}};if(u>30){let p=document.createDocumentFragment();l(p),o.appendChild(p);}else l(o);t.appendChild(o);}render(e,t){let r=typeof e=="string"?document.getElementById(e.replace("#","")):e;if(!r)throw new Error(`Element not found: ${e}`);if(t.children&&t.children.length>500){let n=document.createDocumentFragment();this.renderToDOM(t,n),r.appendChild(n);}else this.renderToDOM(t,r);return r}batchRender(e,t){let r=typeof e=="string"?document.getElementById(e.replace("#","")):e;if(!r)throw new Error(`Element not found: ${e}`);let n=t.length;if(n>3e3){let s=document.createDocumentFragment(),a=0,o=1500,u=()=>{let l=Math.min(a+o,n);for(let p=a;p<l;p++)this.renderToDOM(t[p],s);a=l,a>=n?r.appendChild(s):requestAnimationFrame(u);};u();}else {let s=document.createDocumentFragment();for(let a=0;a<n;a++)this.renderToDOM(t[a],s);r.appendChild(s);}return r}renderChunked(e,t,r=5e3,n){let s=typeof e=="string"?document.getElementById(e.replace("#","")):e;if(!s)throw new Error(`Element not found: ${e}`);let a=t.length,o=0,u=()=>{let l=Math.min(o+r,a),p=document.createDocumentFragment();for(let d=o;d<l;d++)this.renderToDOM(t[d],p);s.appendChild(p),o=l,n&&n(o,a),o<a&&requestAnimationFrame(u);};return requestAnimationFrame(u),s}renderToHead(...e){let t=document.head;if(t)for(let r of e.flat())r&&this.renderToDOM(r,t);return t}addStyle(e){let t=document.createElement("style");return t.textContent=e,document.head.appendChild(t)}addMeta(e){let t=document.createElement("meta");for(let r in e)t.setAttribute(r,e[r]);return document.head.appendChild(t)}addLink(e){let t=document.createElement("link");for(let r in e)t.setAttribute(r,e[r]);return document.head.appendChild(t)}setTitle(e){return document.title=e}createState(e,t={}){let r=e,n=new Set,s=null,{throttle:a=0,deep:o=false}=t,u=()=>n.forEach(p=>p(r)),l=()=>{a>0?s||(s=setTimeout(()=>{s=null,u();},a)):u();};return {get value(){return r},set value(p){(o?JSON.stringify(r)!==JSON.stringify(p):r!==p)&&(r=p,l());},subscribe(p){return n.add(p),()=>n.delete(p)},destroy(){n.clear(),s&&clearTimeout(s);}}}computed(e,t){let r=e.map(s=>s.value),n=this.createState(t(...r));return e.forEach((s,a)=>{s.subscribe(o=>{r[a]=o,n.value=t(...r);});}),n}effect(e){e();}createVirtualList(e,t,r,n=50,s=5){let a=e.clientHeight,o=t.length*n,u=0,l=()=>{let c=Math.max(0,Math.floor(u/n)-s),h=Math.min(t.length,Math.ceil((u+a)/n)+s);return {start:c,end:h}},p=()=>{let{start:c,end:h}=l(),g=document.createElement("div");g.style.cssText=`height:${o}px;position:relative`;for(let v=c;v<h;v++){let m=document.createElement("div");m.style.cssText=`position:absolute;top:${v*n}px;height:${n}px;width:100%`,this.renderToDOM(r(t[v],v),m),g.appendChild(m);}e.innerHTML="",e.appendChild(g);},d=()=>{u=e.scrollTop,requestAnimationFrame(p);};return e.addEventListener("scroll",d),p(),{render:p,destroy:()=>{e.removeEventListener("scroll",d),e.innerHTML="";}}}lazy(e){let t=null,r=false;return async(...n)=>(!t&&!r&&(r=true,t=await e(),r=false),t?t(...n):{tagName:"div",props:{class:"loading"},children:["Loading..."]})}cleanupUnusedElements(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),r=[];for(;t.nextNode();){let n=t.currentNode;n.id&&n.id.startsWith("r")&&!this.elementCache.has(n)&&r.push(n);}return r.forEach(n=>n.remove()),r.length}renderToString(e,t={}){let{pretty:r=false,indent:n=0}=t,s=r?" ".repeat(n):"",a=r?`
2
- `:"",o=this.resolveStateValue(e);if(o=this.unwrapReactive(o),Array.isArray(o))return o.map(g=>this.renderToString(g,t)).join("");if(typeof o!="object"||o===null)return o==null||o===false?"":this.escapeHtml(String(o));let{tagName:u,props:l,children:p}=o,d=this.isSelfClosingTag(u),c=`${s}<${u}`,h=this.propsToAttributes(l);if(h&&(c+=` ${h}`),d)return c+=` />${a}`,c;if(c+=">",l.dangerouslySetInnerHTML)return c+=l.dangerouslySetInnerHTML.__html,c+=`</${u}>${a}`,c;if(p&&p.length>0){let g=p.map(m=>{let y=this.resolveStateValue(m);return this.unwrapReactive(y)}),v=g.some(m=>typeof m=="object"&&m!==null&&!Array.isArray(m)&&"tagName"in m);if(r&&v){c+=a;for(let m of g)if(!(m==null||m===false))if(Array.isArray(m))for(let y of m)y!=null&&y!==false&&(c+=this.renderToString(y,{pretty:r,indent:n+1}));else c+=this.renderToString(m,{pretty:r,indent:n+1});c+=s;}else for(let m of g)if(!(m==null||m===false))if(Array.isArray(m))for(let y of m)y!=null&&y!==false&&(c+=this.renderToString(y,{pretty:false,indent:0}));else c+=this.renderToString(m,{pretty:false,indent:0});}return c+=`</${u}>${a}`,c}resolveStateValue(e){return e&&typeof e=="object"&&"value"in e&&"subscribe"in e?e.value:e}isReactiveWrapper(e){return !e||typeof e!="object"||!e.tagName?false:e.tagName==="span"&&e.props?.id&&typeof e.props.id=="string"&&e.props.id.match(/^r[a-z0-9]{9}$/)}unwrapReactive(e){if(!this.isReactiveWrapper(e))return e;let t=e.children;if(!t||t.length===0)return "";if(t.length===1){let r=t[0];if(r&&typeof r=="object"&&r.tagName==="span"){let n=r.props,s=!n||Object.keys(n).length===0,a=r.children&&r.children.length===1&&typeof r.children[0]=="string";if(s&&a)return r.children[0]}return this.unwrapReactive(r)}return t.map(r=>this.unwrapReactive(r))}escapeHtml(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"};return e.replace(/[&<>"']/g,r=>t[r])}isSelfClosingTag(e){return new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]).has(e.toLowerCase())}propsToAttributes(e){let t=[];for(let r in e){if(r==="children"||r==="dangerouslySetInnerHTML"||r==="ref")continue;let n=e[r];if(n=this.resolveStateValue(n),!(n==null||n===false)&&!(r.startsWith("on")&&typeof n=="function")){if(r==="className"||r==="class"){let s=Array.isArray(n)?n.join(" "):n;s&&t.push(`class="${this.escapeHtml(String(s))}"`);continue}if(r==="style"){let s=this.styleToString(n);s&&t.push(`style="${this.escapeHtml(s)}"`);continue}if(n===true){t.push(r);continue}t.push(`${r}="${this.escapeHtml(String(n))}"`);}}return t.join(" ")}styleToString(e){if(typeof e=="string")return e;if(typeof e=="object"&&e!==null){let t=[];for(let r in e){let n=r.replace(/([A-Z])/g,"-$1").toLowerCase();t.push(`${n}:${e[r]}`);}return t.join(";")}return ""}isState(e){return e&&typeof e=="object"&&"value"in e&&"subscribe"in e&&typeof e.subscribe=="function"}createReactiveChild(e,t){let r=t(e.value);if(typeof window<"u"&&typeof document<"u"){let n={node:null,renderFn:t};this.reactiveNodes.set(e,n),e.subscribe(()=>{if(n.node&&n.node.parentNode){let s=t(e.value);n.node.textContent=String(s??"");}});}return r}jsonToVNode(e){if(this.isState(e))return this.createReactiveChild(e,o=>o);if(e==null||typeof e=="boolean"||typeof e=="string"||typeof e=="number")return e;let{tag:t,attributes:r={},children:n}=e,s={};for(let o in r){let u=r[o];o==="class"?s.className=this.isState(u)?u.value:u:s[o]=this.isState(u)?u.value:u;}let a=[];if(n!=null)if(Array.isArray(n))for(let o of n)if(this.isState(o))a.push(this.createReactiveChild(o,u=>u));else {let u=this.jsonToVNode(o);u!=null&&u!==false&&a.push(u);}else if(this.isState(n))a.push(this.createReactiveChild(n,o=>o));else if(typeof n=="object"&&"tag"in n){let o=this.jsonToVNode(n);o!=null&&o!==false&&a.push(o);}else a.push(n);return {tagName:t,props:s,children:a}}vNodeJsonToVNode(e){if(this.isState(e))return this.createReactiveChild(e,o=>o);if(e==null||typeof e=="boolean"||typeof e=="string"||typeof e=="number")return e;let{tagName:t,props:r={},children:n=[]}=e,s={};for(let o in r){let u=r[o];s[o]=this.isState(u)?u.value:u;}let a=[];for(let o of n)if(this.isState(o))a.push(this.createReactiveChild(o,u=>u));else {let u=this.vNodeJsonToVNode(o);u!=null&&u!==false&&a.push(u);}return {tagName:t,props:s,children:a}}renderJson(e,t){let r=this.jsonToVNode(t);if(!r||typeof r!="object"||!("tagName"in r))throw new Error("Invalid JSON structure");return this.render(e,r)}renderVNode(e,t){let r=this.vNodeJsonToVNode(t);if(!r||typeof r!="object"||!("tagName"in r))throw new Error("Invalid VNode JSON structure");return this.render(e,r)}renderJsonToString(e,t={}){let r=this.jsonToVNode(e);return this.renderToString(r,t)}renderVNodeToString(e,t={}){let r=this.vNodeJsonToVNode(e);return this.renderToString(r,t)}getElementCache(){return this.elementCache}},f=new E;var C=(i,e)=>f.createState(i,e),x=(i,e)=>f.computed(i,e),w=i=>f.effect(i),V=(i,e)=>f.batchRender(i,e),$=(i,e,t,r)=>f.renderChunked(i,e,t,r),k=(i,e,t,r,n)=>f.createVirtualList(i,e,t,r,n),F=i=>f.lazy(i),A=i=>f.cleanupUnusedElements(i),H=(i,e)=>{let t=null;return (...r)=>{t||(t=setTimeout(()=>{t=null,i(...r);},e));}},O=(i,e)=>{let t=null;return (...r)=>{t&&clearTimeout(t),t=setTimeout(()=>i(...r),e);}};var M=class{constructor(e,t,r){this.key=e;this.wsUrl=r;this.ws=null;this.pendingUpdates=[];this.localState=C(t),this.previousValue=t,this.connect();}get value(){return this.localState.value}set value(e){this.previousValue=this.localState.value,this.localState.value=e,this.sendToServer(e);}get state(){return this.localState}onChange(e){return this.localState.subscribe(t=>{let r=this.previousValue;this.previousValue=t,e(t,r);})}update(e){this.value=e(this.value);}connect(){if(typeof window>"u")return;let e=this.wsUrl||`ws://${location.host}`;this.ws=new WebSocket(e),this.ws.addEventListener("open",()=>{for(this.subscribe();this.pendingUpdates.length>0;){let t=this.pendingUpdates.shift();this.sendToServer(t);}}),this.ws.addEventListener("message",t=>{this.handleMessage(t.data);}),this.ws.addEventListener("close",()=>{setTimeout(()=>this.connect(),1e3);}),this.ws.addEventListener("error",t=>{console.error("[SharedState] WebSocket error:",t);});}subscribe(){!this.ws||this.ws.readyState!==WebSocket.OPEN||this.ws.send(JSON.stringify({type:"state:subscribe",key:this.key}));}handleMessage(e){try{let t=JSON.parse(e);if(t.key!==this.key)return;(t.type==="state:init"||t.type==="state:update")&&(this.localState.value=t.value);}catch{}}sendToServer(e){if(this.ws){if(this.ws.readyState!==WebSocket.OPEN){this.pendingUpdates.push(e);return}this.ws.send(JSON.stringify({type:"state:change",key:this.key,value:e}));}}disconnect(){this.ws&&(this.ws.close(),this.ws=null);}destroy(){this.disconnect(),this.localState.destroy();}};function j(i,e,t){return new M(i,e,t)}var P=class{constructor(){this.states=new Map;}create(e,t,r){if(this.states.has(e))return this.states.get(e);let n=new M(e,t,r);return this.states.set(e,n),n}get(e){return this.states.get(e)}delete(e){let t=this.states.get(e);return t?(t.destroy(),this.states.delete(e)):false}clear(){this.states.forEach(e=>e.destroy()),this.states.clear();}},J=new P;var L=(i,e)=>{let t=null,r=null,n=null,s=true,a=e(i.value),o=a&&typeof a=="object"&&"tagName"in a,u=a==null||a===false,l=()=>{if(!r&&!n)return;let d=e(i.value);if(d==null||d===false)s&&r&&(n=document.createComment("reactive"),r.parentNode?.replaceChild(n,r),s=false);else if(!s&&n&&r&&(n.parentNode?.replaceChild(r,n),n=null,s=true),r){let h=document.createDocumentFragment();if(o&&d&&typeof d=="object"&&"tagName"in d){let{props:g,children:v}=d;for(let m in g){let y=g[m];if(m!=="ref")if(m==="class"||m==="className")r.className=Array.isArray(y)?y.join(" "):y||"";else if(m==="style"&&typeof y=="object"){let T=r.style;for(let z in y)T[z]=y[z];}else m.startsWith("on")?r[m.toLowerCase()]=y:y!=null&&y!==false?r.setAttribute(m,String(y===true?"":y)):r.removeAttribute(m);}for(let m of v)f.renderToDOM(m,h);}else f.renderToDOM(d,h);r.textContent="",r.appendChild(h),f.getElementCache().set(r,true);}};i.subscribe(()=>{t&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{l(),t=null;});});let p=d=>{r=d,u&&d.parentNode&&(n=document.createComment("reactive"),d.parentNode.replaceChild(n,d),s=false);};if(o){let d=a;return {tagName:d.tagName,props:{...d.props,ref:p},children:d.children}}return {tagName:"span",props:{ref:p},children:[a]}},D=(i,e,t,r={})=>{let n=null,s=null;return e.subscribe(()=>{n&&cancelAnimationFrame(n),n=requestAnimationFrame(()=>{if(s){let o=document.createDocumentFragment(),u=t(e.value);u==null||u===false?(s.style.display="none",s.textContent=""):(s.style.display="",f.renderToDOM(u,o),s.textContent="",s.appendChild(o)),f.getElementCache().set(s,true);}n=null;});}),{tagName:i,props:{...r,ref:o=>{s=o;}},children:[t(e.value)]}},W=i=>i&&i.value!==void 0?L(i,e=>({tagName:"span",props:{},children:[String(e)]})):String(i),K=i=>({value:i.value,oninput:e=>{i.value=e.target.value;}}),q=i=>({checked:i.value,onchange:e=>{i.value=e.target.checked;}});var N=class{constructor(){this.variables=[];this.rules=[];this.mediaRules=[];this.keyframes=[];this.fontFaces=[];this.imports=[];this.containerRules=[];this.supportsRules=[];this.layerRules=[];this._layerOrder=[];}addVar(e,t){let r={name:e.startsWith("--")?e:`--${e}`,value:t,toString(){return `var(${this.name})`}};return this.variables.push(r),r}var(e,t){let r=typeof e=="string"?e.startsWith("--")?e:`--${e}`:e.name;return t?`var(${r}, ${t})`:`var(${r})`}addTag(e,t){let r={selector:e,styles:t,type:"tag"};return this.rules.push(r),r}addClass(e,t){let n={selector:e.startsWith(".")?e:`.${e}`,styles:t,type:"class"};return this.rules.push(n),n}addId(e,t){let n={selector:e.startsWith("#")?e:`#${e}`,styles:t,type:"id"};return this.rules.push(n),n}addPseudoClass(e,t,r){let n=e.startsWith(":")?e:`:${e}`,a={selector:r?`${r}${n}`:n,styles:t,type:"pseudo-class"};return this.rules.push(a),a}addPseudoElement(e,t,r){let n=e.startsWith("::")?e:`::${e}`,a={selector:r?`${r}${n}`:n,styles:t,type:"pseudo-element"};return this.rules.push(a),a}addAttribute(e,t,r){let n=e.startsWith("[")?e:`[${e}]`,a={selector:r?`${r}${n}`:n,styles:t,type:"attribute"};return this.rules.push(a),a}attrEquals(e,t,r,n){return this.addAttribute(`${e}="${t}"`,r,n)}attrContainsWord(e,t,r,n){return this.addAttribute(`${e}~="${t}"`,r,n)}attrStartsWith(e,t,r,n){return this.addAttribute(`${e}^="${t}"`,r,n)}attrEndsWith(e,t,r,n){return this.addAttribute(`${e}$="${t}"`,r,n)}attrContains(e,t,r,n){return this.addAttribute(`${e}*="${t}"`,r,n)}descendant(e,t,r){let s={selector:`${e} ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}child(e,t,r){let s={selector:`${e} > ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}adjacentSibling(e,t,r){let s={selector:`${e} + ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}generalSibling(e,t,r){let s={selector:`${e} ~ ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}multiple(e,t){let n={selector:e.join(", "),styles:t,type:"custom"};return this.rules.push(n),n}addName(e,t){return {selector:e.startsWith("--")?`&${e}`:`&--${e}`,styles:t,type:"name"}}nesting(e,...t){return e.nested=t,e}keyframe(e,t){let r=Object.entries(t).map(([s,a])=>({step:s==="from"?"from":s==="to"?"to":`${s}%`,styles:a})),n={name:e,steps:r};return this.keyframes.push(n),n}keyframeFromTo(e,t,r){return this.keyframe(e,{from:t,to:r})}fontFace(e){return this.fontFaces.push(e),e}import(e,t){let r=t?`@import url("${e}") ${t};`:`@import url("${e}");`;return this.imports.push(r),r}media(e,t,r){let n=Object.entries(r).map(([a,o])=>({selector:a,styles:o,type:"custom"})),s={type:e,condition:t,rules:n};return this.mediaRules.push(s),s}mediaScreen(e,t){return this.media("screen",e,t)}mediaPrint(e){return this.media("print","",e)}mediaMinWidth(e,t){return this.media("screen",`min-width: ${e}`,t)}mediaMaxWidth(e,t){return this.media("screen",`max-width: ${e}`,t)}mediaDark(e){let r={type:"",condition:"prefers-color-scheme: dark",rules:Object.entries(e).map(([n,s])=>({selector:n,styles:s,type:"custom"}))};return this.mediaRules.push(r),r}mediaLight(e){let r={type:"",condition:"prefers-color-scheme: light",rules:Object.entries(e).map(([n,s])=>({selector:n,styles:s,type:"custom"}))};return this.mediaRules.push(r),r}mediaReducedMotion(e){let r={type:"",condition:"prefers-reduced-motion: reduce",rules:Object.entries(e).map(([n,s])=>({selector:n,styles:s,type:"custom"}))};return this.mediaRules.push(r),r}container(e,t,r){let n=Object.entries(t).map(([a,o])=>({selector:a,styles:o,type:"custom"})),s={name:r,condition:e,rules:n};return this.containerRules.push(s),s}addContainer(e,t){let r={...t,containerName:e};return this.addClass(e,r)}supports(e,t){let r=Object.entries(t).map(([s,a])=>({selector:s,styles:a,type:"custom"})),n={condition:e,rules:r};return this.supportsRules.push(n),n}layerOrder(...e){this._layerOrder=e;}layer(e,t){let r=Object.entries(t).map(([s,a])=>({selector:s,styles:a,type:"custom"})),n={name:e,rules:r};return this.layerRules.push(n),n}add(e){return Object.entries(e).map(([r,n])=>{let s={selector:r,styles:n,type:"custom"};return this.rules.push(s),s})}important(e){return `${e} !important`}toKebabCase(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}stylesToString(e,t=" "){return Object.entries(e).map(([r,n])=>{let s=typeof n=="object"&&n!==null&&"name"in n?`var(${n.name})`:n;return `${t}${this.toKebabCase(r)}: ${s};`}).join(`
3
- `)}renderRule(e,t=""){let r=`${t}${e.selector} {
4
- ${this.stylesToString(e.styles,t+" ")}
5
- `;if(e.nested&&e.nested.length>0)for(let n of e.nested){let s=n.selector.startsWith("&")?n.selector.replace(/&/g,e.selector):`${e.selector} ${n.selector}`;r+=`
6
- ${t}${s} {
7
- ${this.stylesToString(n.styles,t+" ")}
8
- ${t}}
9
- `;}return r+=`${t}}`,r}renderMediaRule(e){let r=`@media ${e.type&&e.condition?`${e.type} and (${e.condition})`:e.type?e.type:`(${e.condition})`} {
10
- `;for(let n of e.rules)r+=this.renderRule(n," ")+`
11
- `;return r+="}",r}renderKeyframes(e){let t=`@keyframes ${e.name} {
12
- `;for(let r of e.steps)t+=` ${r.step} {
13
- ${this.stylesToString(r.styles," ")}
14
- }
15
- `;return t+="}",t}renderFontFace(e){let t=`@font-face {
16
- `;return t+=` font-family: "${e.fontFamily}";
17
- `,t+=` src: ${e.src};
18
- `,e.fontWeight&&(t+=` font-weight: ${e.fontWeight};
19
- `),e.fontStyle&&(t+=` font-style: ${e.fontStyle};
20
- `),e.fontDisplay&&(t+=` font-display: ${e.fontDisplay};
21
- `),e.unicodeRange&&(t+=` unicode-range: ${e.unicodeRange};
22
- `),t+="}",t}renderContainerRule(e){let r=`@container ${e.name?`${e.name} `:""}(${e.condition}) {
23
- `;for(let n of e.rules)r+=this.renderRule(n," ")+`
24
- `;return r+="}",r}renderSupportsRule(e){let t=`@supports (${e.condition}) {
25
- `;for(let r of e.rules)t+=this.renderRule(r," ")+`
26
- `;return t+="}",t}renderLayerRule(e){let t=`@layer ${e.name} {
27
- `;for(let r of e.rules)t+=this.renderRule(r," ")+`
28
- `;return t+="}",t}render(...e){let t=[];if(this.imports.length>0&&t.push(this.imports.join(`
29
- `)),this._layerOrder.length>0&&t.push(`@layer ${this._layerOrder.join(", ")};`),this.variables.length>0){let l=this.variables.map(p=>` ${p.name}: ${p.value};`).join(`
30
- `);t.push(`:root {
31
- ${l}
32
- }`);}for(let l of this.fontFaces)t.push(this.renderFontFace(l));for(let l of this.keyframes)t.push(this.renderKeyframes(l));let r=[...this.rules],n=[...this.mediaRules],s=[],a=[...this.containerRules],o=[...this.supportsRules],u=[...this.layerRules];for(let l of e)l&&(Array.isArray(l)?r.push(...l):"condition"in l&&"rules"in l&&!("name"in l&&"steps"in l)?"type"in l?n.push(l):"name"in l&&typeof l.name=="string"?a.push(l):o.push(l):"name"in l&&"steps"in l?s.push(l):"name"in l&&"rules"in l?u.push(l):r.push(l));for(let l of s)t.push(this.renderKeyframes(l));for(let l of u)t.push(this.renderLayerRule(l));for(let l of r)t.push(this.renderRule(l));for(let l of o)t.push(this.renderSupportsRule(l));for(let l of a)t.push(this.renderContainerRule(l));for(let l of n)t.push(this.renderMediaRule(l));return t.join(`
33
-
34
- `)}inject(e){let t=this.render(),r=document.createElement("style");return e&&(r.id=e),r.textContent=t,document.head.appendChild(r),r}clear(){this.variables=[],this.rules=[],this.mediaRules=[],this.keyframes=[],this.fontFaces=[],this.imports=[],this.containerRules=[],this.supportsRules=[],this.layerRules=[],this._layerOrder=[];}};function I(i,e){let t=i.split("/").filter(Boolean),r=e.split("/").filter(Boolean);if(i.endsWith("*")){let s=i.slice(0,-1);if(e.startsWith(s)||s==="/"||i==="*")return {"*":e.slice(s.length)}}if(t.length!==r.length)return null;let n={};for(let s=0;s<t.length;s++){let a=t[s],o=r[s];if(a.startsWith(":"))n[a.slice(1)]=decodeURIComponent(o);else if(a!==o)return null}return n}function G(i){let{mode:e="history",base:t="",routes:r}=i,n=[],s=c=>{let h={};return new URLSearchParams(c).forEach((v,m)=>{h[m]=v;}),h},a=()=>e==="hash"?window.location.hash.slice(1)||"/":window.location.pathname.replace(t,"")||"/",o=c=>{let[h,g=""]=c.split("?"),[v,m=""]=h.split("#");return {path:v||"/",params:{},query:s(g),hash:m?"#"+m:""}},u=c=>{for(let h of r){let g=I(h.path,c);if(g!==null)return {route:h,params:g}}return null},l=f.createState(o(a())),p=(c,h=false)=>{let g=o(c),v=u(g.path);v&&(g.params=v.params);for(let y of n){let T=y(g,l.value);if(T===false)return;if(typeof T=="string"){p(T,h);return}}if(v?.route.beforeEnter){let y=v.route.beforeEnter(g,l.value);if(y===false)return;if(typeof y=="string"){p(y,h);return}}let m=e==="hash"?"#"+c:t+c;h?window.history.replaceState({path:c},"",m):window.history.pushState({path:c},"",m),l.value=g;},d=()=>{let c=a(),h=o(c),g=u(h.path);g&&(h.params=g.params),l.value=h;};return typeof window<"u"&&window.addEventListener("popstate",d),{currentRoute:l,push:c=>p(c,false),replace:c=>p(c,true),back:()=>window.history.back(),forward:()=>window.history.forward(),go:c=>window.history.go(c),beforeEach:c=>{n.push(c);},destroy:()=>{typeof window<"u"&&window.removeEventListener("popstate",d),l.destroy();}}}function U(i,e){let{routes:t,notFound:r}=e;return ()=>{let n=i.currentRoute.value,s=t.find(a=>I(a.path,n.path)!==null);if(s){let a=I(s.path,n.path)||{},o=s.component({...a,...n.query});return typeof o=="object"&&o!==null&&"tagName"in o?o:{tagName:"span",props:{},children:[o]}}if(r){let a=r(n.params);return typeof a=="object"&&a!==null&&"tagName"in a?a:{tagName:"span",props:{},children:[a]}}return {tagName:"div",props:{},children:["404 - Not Found"]}}}var B=(i,e,...t)=>({tagName:"a",props:{...e,href:e.to,onclick:r=>{r.preventDefault(),i.push(e.to);}},children:t});var b=i=>function(e,...t){if(!arguments.length)return {tagName:i,props:{},children:[]};let r=e&&typeof e=="object"&&"value"in e&&"subscribe"in e,n=e&&typeof e=="object"&&"tagName"in e,s=typeof e!="object"||Array.isArray(e)||e===null||r||n,a=s?{}:e,o=s?[e,...t]:t;if(!o.length)return {tagName:i,props:a,children:[]};let u=[];for(let l=0,p=o.length;l<p;l++){let d=o[l];if(!(d==null||d===false))if(Array.isArray(d))for(let c=0,h=d.length;c<h;c++){let g=d[c];g!=null&&g!==false&&u.push(g);}else u.push(d);}return {tagName:i,props:a,children:u}},X=["html","head","body","title","base","link","meta","style","address","article","aside","footer","header","h1","h2","h3","h4","h5","h6","main","nav","section","blockquote","dd","div","dl","dt","figcaption","figure","hr","li","ol","p","pre","ul","a","abbr","b","bdi","bdo","br","cite","code","data","dfn","em","i","kbd","mark","q","rp","rt","ruby","s","samp","small","span","strong","sub","sup","time","u","wbr","area","audio","img","map","track","video","embed","iframe","object","param","picture","portal","source","canvas","noscript","script","del","ins","caption","col","colgroup","table","tbody","td","tfoot","th","thead","tr","button","datalist","fieldset","form","input","label","legend","meter","optgroup","option","output","progress","select","textarea","details","dialog","menu","summary","slot","template"],Y=["svg","circle","rect","path","line","polyline","polygon","ellipse","g","text","tspan","defs","linearGradient","radialGradient","stop","pattern","mask","clipPath","use","symbol","marker","image","foreignObject","animate","animateTransform","animateMotion","set","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence"],ee=["math","mi","mn","mo","ms","mtext","mrow","mfrac","msqrt","mroot","msub","msup"],R={};X.forEach(i=>{R[i]=b(i);});Y.forEach(i=>{let e="svg"+i.charAt(0).toUpperCase()+i.slice(1);R[e]=b(i);});ee.forEach(i=>{let e="math"+i.charAt(0).toUpperCase()+i.slice(1);R[e]=b(i);});R.varElement=b("var");var {html:te,head:re,body:ne,title:se,base:oe,link:ie,meta:ae,style:le,address:ue,article:ce,aside:de,footer:pe,header:me,h1:he,h2:ge,h3:fe,h4:ye,h5:Se,h6:ve,main:Re,nav:be,section:Te,blockquote:Ce,dd:Me,div:Ne,dl:Ee,dt:Le,figcaption:xe,figure:we,hr:Ve,li:$e,ol:ke,p:Fe,pre:Ae,ul:He,a:Oe,abbr:Pe,b:je,bdi:Je,bdo:De,br:We,cite:Ke,code:qe,data:Ie,dfn:Ge,em:Ue,i:Be,kbd:_e,mark:ze,q:Ze,rp:Qe,rt:Xe,ruby:Ye,s:et,samp:tt,small:rt,span:nt,strong:st,sub:ot,sup:it,time:at,u:lt,wbr:ut,area:ct,audio:dt,img:pt,map:mt,track:ht,video:gt,embed:ft,iframe:yt,object:St,param:vt,picture:Rt,portal:bt,source:Tt,canvas:Ct,noscript:Mt,script:Nt,del:Et,ins:Lt,caption:xt,col:wt,colgroup:Vt,table:$t,tbody:kt,td:Ft,tfoot:At,th:Ht,thead:Ot,tr:Pt,button:jt,datalist:Jt,fieldset:Dt,form:Wt,input:Kt,label:qt,legend:It,meter:Gt,optgroup:Ut,option:Bt,output:_t,progress:zt,select:Zt,textarea:Qt,details:Xt,dialog:Yt,menu:er,summary:tr,slot:rr,template:nr,svgSvg:sr,svgCircle:or,svgRect:ir,svgPath:ar,svgLine:lr,svgPolyline:ur,svgPolygon:cr,svgEllipse:dr,svgG:pr,svgText:mr,svgTspan:hr,svgDefs:gr,svgLinearGradient:fr,svgRadialGradient:yr,svgStop:Sr,svgPattern:vr,svgMask:Rr,svgClipPath:br,svgUse:Tr,svgSymbol:Cr,svgMarker:Mr,svgImage:Nr,svgForeignObject:Er,svgAnimate:Lr,svgAnimateTransform:xr,svgAnimateMotion:wr,svgSet:Vr,svgFilter:$r,svgFeBlend:kr,svgFeColorMatrix:Fr,svgFeComponentTransfer:Ar,svgFeComposite:Hr,svgFeConvolveMatrix:Or,svgFeDiffuseLighting:Pr,svgFeDisplacementMap:jr,svgFeFlood:Jr,svgFeGaussianBlur:Dr,svgFeMorphology:Wr,svgFeOffset:Kr,svgFeSpecularLighting:qr,svgFeTile:Ir,svgFeTurbulence:Gr,mathMath:Ur,mathMi:Br,mathMn:_r,mathMo:zr,mathMs:Zr,mathMtext:Qr,mathMrow:Xr,mathMfrac:Yr,mathMsqrt:en,mathMroot:tn,mathMsub:rn,mathMsup:nn,varElement:sn}=R;var _={};Q(_,{commentNode:()=>mn,createEl:()=>ln,createMathEl:()=>cn,createSvgEl:()=>un,doc:()=>S,el:()=>on,elClass:()=>gn,elId:()=>hn,elName:()=>yn,elTag:()=>fn,els:()=>an,fragment:()=>dn,textNode:()=>pn});var S=document,on=S.querySelector.bind(S),an=S.querySelectorAll.bind(S),ln=S.createElement.bind(S),un=S.createElementNS.bind(S,"http://www.w3.org/2000/svg"),cn=S.createElementNS.bind(S,"http://www.w3.org/1998/Math/MathML"),dn=S.createDocumentFragment.bind(S),pn=S.createTextNode.bind(S),mn=S.createComment.bind(S),hn=S.getElementById.bind(S),gn=S.getElementsByClassName.bind(S),fn=S.getElementsByTagName.bind(S),yn=S.getElementsByName.bind(S);var Sn=(...i)=>f.renderToHead(...i),vn=i=>f.addStyle(i),Rn=i=>f.addMeta(i),bn=i=>f.addLink(i),Tn=i=>f.setTitle(i),Cn=(i,e)=>f.renderToString(i,e),Mn=i=>f.jsonToVNode(i),Nn=(i,e)=>f.renderJson(i,e),En=(i,e)=>f.renderJsonToString(i,e),Ln=i=>f.vNodeJsonToVNode(i),xn=(i,e)=>f.renderVNode(i,e),wn=(i,e)=>f.renderVNodeToString(i,e);typeof window<"u"&&Object.assign(window,{domNode:f,createElementFactory:b,renderToHead:Sn,addStyle:vn,addMeta:Rn,addLink:bn,setTitle:Tn,createState:C,computed:x,effect:w,createSharedState:j,sharedStateManager:J,reactive:L,reactiveAs:D,text:W,bindValue:K,bindChecked:q,batchRender:V,renderChunked:$,createVirtualList:k,lazy:F,cleanupUnused:A,renderToString:Cn,jsonToVNode:Mn,renderJson:Nn,renderJsonToString:En,vNodeJsonToVNode:Ln,renderVNode:xn,renderVNodeToString:wn,throttle:H,debounce:O,CreateStyle:N,createRouter:G,createRouterView:U,routerLink:B,...R,..._});
35
- exports.CreateStyle=N;exports.DomNode=E;exports.SharedState=M;exports.a=Oe;exports.abbr=Pe;exports.addLink=bn;exports.addMeta=Rn;exports.addStyle=vn;exports.address=ue;exports.area=ct;exports.article=ce;exports.aside=de;exports.audio=dt;exports.b=je;exports.base=oe;exports.batchRender=V;exports.bdi=Je;exports.bdo=De;exports.bindChecked=q;exports.bindValue=K;exports.blockquote=Ce;exports.body=ne;exports.br=We;exports.button=jt;exports.canvas=Ct;exports.caption=xt;exports.cite=Ke;exports.cleanupUnused=A;exports.code=qe;exports.col=wt;exports.colgroup=Vt;exports.commentNode=mn;exports.computed=x;exports.createEl=ln;exports.createElementFactory=b;exports.createMathEl=cn;exports.createRouter=G;exports.createRouterView=U;exports.createSharedState=j;exports.createState=C;exports.createSvgEl=un;exports.createVirtualList=k;exports.data=Ie;exports.datalist=Jt;exports.dd=Me;exports.debounce=O;exports.del=Et;exports.details=Xt;exports.dfn=Ge;exports.dialog=Yt;exports.div=Ne;exports.dl=Ee;exports.doc=S;exports.domNode=f;exports.dt=Le;exports.effect=w;exports.el=on;exports.elClass=gn;exports.elId=hn;exports.elName=yn;exports.elTag=fn;exports.elements=R;exports.els=an;exports.em=Ue;exports.embed=ft;exports.fieldset=Dt;exports.figcaption=xe;exports.figure=we;exports.footer=pe;exports.form=Wt;exports.fragment=dn;exports.h1=he;exports.h2=ge;exports.h3=fe;exports.h4=ye;exports.h5=Se;exports.h6=ve;exports.head=re;exports.header=me;exports.hr=Ve;exports.html=te;exports.i=Be;exports.iframe=yt;exports.img=pt;exports.input=Kt;exports.ins=Lt;exports.jsonToVNode=Mn;exports.kbd=_e;exports.label=qt;exports.lazy=F;exports.legend=It;exports.li=$e;exports.link=ie;exports.main=Re;exports.map=mt;exports.mark=ze;exports.mathMath=Ur;exports.mathMfrac=Yr;exports.mathMi=Br;exports.mathMn=_r;exports.mathMo=zr;exports.mathMroot=tn;exports.mathMrow=Xr;exports.mathMs=Zr;exports.mathMsqrt=en;exports.mathMsub=rn;exports.mathMsup=nn;exports.mathMtext=Qr;exports.menu=er;exports.meta=ae;exports.meter=Gt;exports.nav=be;exports.noscript=Mt;exports.object=St;exports.ol=ke;exports.optgroup=Ut;exports.option=Bt;exports.output=_t;exports.p=Fe;exports.param=vt;exports.picture=Rt;exports.portal=bt;exports.pre=Ae;exports.progress=zt;exports.q=Ze;exports.reactive=L;exports.reactiveAs=D;exports.renderChunked=$;exports.renderJson=Nn;exports.renderJsonToString=En;exports.renderToHead=Sn;exports.renderToString=Cn;exports.renderVNode=xn;exports.renderVNodeToString=wn;exports.routerLink=B;exports.rp=Qe;exports.rt=Xe;exports.ruby=Ye;exports.s=et;exports.samp=tt;exports.script=Nt;exports.section=Te;exports.select=Zt;exports.setTitle=Tn;exports.sharedStateManager=J;exports.slot=rr;exports.small=rt;exports.source=Tt;exports.span=nt;exports.strong=st;exports.style=le;exports.sub=ot;exports.summary=tr;exports.sup=it;exports.svgAnimate=Lr;exports.svgAnimateMotion=wr;exports.svgAnimateTransform=xr;exports.svgCircle=or;exports.svgClipPath=br;exports.svgDefs=gr;exports.svgEllipse=dr;exports.svgFeBlend=kr;exports.svgFeColorMatrix=Fr;exports.svgFeComponentTransfer=Ar;exports.svgFeComposite=Hr;exports.svgFeConvolveMatrix=Or;exports.svgFeDiffuseLighting=Pr;exports.svgFeDisplacementMap=jr;exports.svgFeFlood=Jr;exports.svgFeGaussianBlur=Dr;exports.svgFeMorphology=Wr;exports.svgFeOffset=Kr;exports.svgFeSpecularLighting=qr;exports.svgFeTile=Ir;exports.svgFeTurbulence=Gr;exports.svgFilter=$r;exports.svgForeignObject=Er;exports.svgG=pr;exports.svgImage=Nr;exports.svgLine=lr;exports.svgLinearGradient=fr;exports.svgMarker=Mr;exports.svgMask=Rr;exports.svgPath=ar;exports.svgPattern=vr;exports.svgPolygon=cr;exports.svgPolyline=ur;exports.svgRadialGradient=yr;exports.svgRect=ir;exports.svgSet=Vr;exports.svgStop=Sr;exports.svgSvg=sr;exports.svgSymbol=Cr;exports.svgText=mr;exports.svgTspan=hr;exports.svgUse=Tr;exports.table=$t;exports.tbody=kt;exports.td=Ft;exports.template=nr;exports.text=W;exports.textNode=pn;exports.textarea=Qt;exports.tfoot=At;exports.th=Ht;exports.thead=Ot;exports.throttle=H;exports.time=at;exports.title=se;exports.tr=Pt;exports.track=ht;exports.u=lt;exports.ul=He;exports.vNodeJsonToVNode=Ln;exports.varElement=sn;exports.video=gt;exports.wbr=ut;
1
+ "use strict";var e,t=require("http"),r=require("https"),s=require("ws"),o=require("chokidar"),n=require("fs/promises"),i=require("path"),a=require("mime-types"),l=require("esbuild"),p=require("fs"),c=(e=function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')},typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):e),d=class{constructor(){this.elementCache=new WeakMap,this.reactiveNodes=new Map}createElement(e,t={},r=[]){return{tagName:e,props:t,children:r}}renderToDOM(e,t){if(null==e||!1===e)return;if("object"!=typeof e)return void t.appendChild(document.createTextNode(String(e)));let{tagName:r,props:s,children:o}=e,n="svg"===r||"s"===r[0]&&"v"===r[1]&&"g"===r[2]||"http://www.w3.org/2000/svg"===t.namespaceURI,i=n?document.createElementNS("http://www.w3.org/2000/svg",r.replace("svg","").toLowerCase()||r):document.createElement(r);for(let e in s){let t=s[e];if(null==t||!1===t)continue;let r=e.charCodeAt(0);if(99===r&&(e.length<6||"N"===e[5])){let e=Array.isArray(t)?t.join(" "):t;n?i.setAttribute("class",e):i.className=e}else if(115===r&&5===e.length)if("string"==typeof t)i.style.cssText=t;else{let e=i.style;for(let r in t)e[r]=t[r]}else 111===r&&110===e.charCodeAt(1)?i[e.toLowerCase()]=t:100===r&&e.length>20?i.innerHTML=t.__html:114===r&&3===e.length?setTimeout(()=>{"function"==typeof t?t(i):t.current=i},0):i.setAttribute(e,!0===t?"":String(t))}let a=o.length;if(!a)return void t.appendChild(i);let l=e=>{for(let t=0;t<a;t++){let r=o[t];if(null!=r&&!1!==r)if(Array.isArray(r))for(let t=0,s=r.length;t<s;t++){let s=r[t];null!=s&&!1!==s&&this.renderToDOM(s,e)}else this.renderToDOM(r,e)}};if(a>30){let e=document.createDocumentFragment();l(e),i.appendChild(e)}else l(i);t.appendChild(i)}render(e,t){let r="string"==typeof e?document.getElementById(e.replace("#","")):e;if(!r)throw new Error(`Element not found: ${e}`);if(t.children&&t.children.length>500){let e=document.createDocumentFragment();this.renderToDOM(t,e),r.appendChild(e)}else this.renderToDOM(t,r);return r}batchRender(e,t){let r="string"==typeof e?document.getElementById(e.replace("#","")):e;if(!r)throw new Error(`Element not found: ${e}`);let s=t.length;if(s>3e3){let e=document.createDocumentFragment(),o=0,n=1500,i=()=>{let a=Math.min(o+n,s);for(let r=o;r<a;r++)this.renderToDOM(t[r],e);o=a,o>=s?r.appendChild(e):requestAnimationFrame(i)};i()}else{let e=document.createDocumentFragment();for(let r=0;r<s;r++)this.renderToDOM(t[r],e);r.appendChild(e)}return r}renderChunked(e,t,r=5e3,s){let o="string"==typeof e?document.getElementById(e.replace("#","")):e;if(!o)throw new Error(`Element not found: ${e}`);let n=t.length,i=0,a=()=>{let e=Math.min(i+r,n),l=document.createDocumentFragment();for(let r=i;r<e;r++)this.renderToDOM(t[r],l);o.appendChild(l),i=e,s&&s(i,n),i<n&&requestAnimationFrame(a)};return requestAnimationFrame(a),o}renderToHead(...e){let t=document.head;if(t)for(let r of e.flat())r&&this.renderToDOM(r,t);return t}addStyle(e){let t=document.createElement("style");return t.textContent=e,document.head.appendChild(t)}addMeta(e){let t=document.createElement("meta");for(let r in e)t.setAttribute(r,e[r]);return document.head.appendChild(t)}addLink(e){let t=document.createElement("link");for(let r in e)t.setAttribute(r,e[r]);return document.head.appendChild(t)}setTitle(e){return document.title=e}createState(e,t={}){let r=e,s=new Set,o=null,{throttle:n=0,deep:i=!1}=t,a=()=>s.forEach(e=>e(r));return{get value(){return r},set value(e){(i?JSON.stringify(r)!==JSON.stringify(e):r!==e)&&(r=e,n>0?o||(o=setTimeout(()=>{o=null,a()},n)):a())},subscribe:e=>(s.add(e),()=>s.delete(e)),destroy(){s.clear(),o&&clearTimeout(o)}}}computed(e,t){let r=e.map(e=>e.value),s=this.createState(t(...r));return e.forEach((e,o)=>{e.subscribe(e=>{r[o]=e,s.value=t(...r)})}),s}effect(e){e()}createVirtualList(e,t,r,s=50,o=5){let n=e.clientHeight,i=t.length*s,a=0,l=()=>{let{start:l,end:p}={start:Math.max(0,Math.floor(a/s)-o),end:Math.min(t.length,Math.ceil((a+n)/s)+o)},c=document.createElement("div");c.style.cssText=`height:${i}px;position:relative`;for(let e=l;e<p;e++){let o=document.createElement("div");o.style.cssText=`position:absolute;top:${e*s}px;height:${s}px;width:100%`,this.renderToDOM(r(t[e],e),o),c.appendChild(o)}e.innerHTML="",e.appendChild(c)},p=()=>{a=e.scrollTop,requestAnimationFrame(l)};return e.addEventListener("scroll",p),l(),{render:l,destroy:()=>{e.removeEventListener("scroll",p),e.innerHTML=""}}}lazy(e){let t=null,r=!1;return async(...s)=>(!t&&!r&&(r=!0,t=await e(),r=!1),t?t(...s):{tagName:"div",props:{class:"loading"},children:["Loading..."]})}cleanupUnusedElements(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),r=[];for(;t.nextNode();){let e=t.currentNode;e.id&&e.id.startsWith("r")&&!this.elementCache.has(e)&&r.push(e)}return r.forEach(e=>e.remove()),r.length}renderToString(e,t={}){let{pretty:r=!1,indent:s=0}=t,o=r?" ".repeat(s):"",n=r?"\n":"",i=this.resolveStateValue(e);if(i=this.unwrapReactive(i),Array.isArray(i))return i.map(e=>this.renderToString(e,t)).join("");if("object"!=typeof i||null===i)return null==i||!1===i?"":this.escapeHtml(String(i));let{tagName:a,props:l,children:p}=i,c=this.isSelfClosingTag(a),d=`${o}<${a}`,u=this.propsToAttributes(l);if(u&&(d+=` ${u}`),c)return d+=` />${n}`,d;if(d+=">",l.dangerouslySetInnerHTML)return d+=l.dangerouslySetInnerHTML.__html,d+=`</${a}>${n}`,d;if(p&&p.length>0){let e=p.map(e=>{let t=this.resolveStateValue(e);return this.unwrapReactive(t)}),t=e.some(e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"tagName"in e);if(r&&t){d+=n;for(let t of e)if(null!=t&&!1!==t)if(Array.isArray(t))for(let e of t)null!=e&&!1!==e&&(d+=this.renderToString(e,{pretty:r,indent:s+1}));else d+=this.renderToString(t,{pretty:r,indent:s+1});d+=o}else for(let t of e)if(null!=t&&!1!==t)if(Array.isArray(t))for(let e of t)null!=e&&!1!==e&&(d+=this.renderToString(e,{pretty:!1,indent:0}));else d+=this.renderToString(t,{pretty:!1,indent:0})}return d+=`</${a}>${n}`,d}resolveStateValue(e){return e&&"object"==typeof e&&"value"in e&&"subscribe"in e?e.value:e}isReactiveWrapper(e){return!(!e||"object"!=typeof e||!e.tagName)&&("span"===e.tagName&&e.props?.id&&"string"==typeof e.props.id&&e.props.id.match(/^r[a-z0-9]{9}$/))}unwrapReactive(e){if(!this.isReactiveWrapper(e))return e;let t=e.children;if(!t||0===t.length)return"";if(1===t.length){let e=t[0];if(e&&"object"==typeof e&&"span"===e.tagName){let t=e.props,r=!t||0===Object.keys(t).length,s=e.children&&1===e.children.length&&"string"==typeof e.children[0];if(r&&s)return e.children[0]}return this.unwrapReactive(e)}return t.map(e=>this.unwrapReactive(e))}escapeHtml(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"};return e.replace(/[&<>"']/g,e=>t[e])}isSelfClosingTag(e){return new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]).has(e.toLowerCase())}propsToAttributes(e){let t=[];for(let r in e){if("children"===r||"dangerouslySetInnerHTML"===r||"ref"===r)continue;let s=e[r];if(s=this.resolveStateValue(s),null!=s&&!1!==s&&(!r.startsWith("on")||"function"!=typeof s)){if("className"===r||"class"===r){let e=Array.isArray(s)?s.join(" "):s;e&&t.push(`class="${this.escapeHtml(String(e))}"`);continue}if("style"===r){let e=this.styleToString(s);e&&t.push(`style="${this.escapeHtml(e)}"`);continue}if(!0===s){t.push(r);continue}t.push(`${r}="${this.escapeHtml(String(s))}"`)}}return t.join(" ")}styleToString(e){if("string"==typeof e)return e;if("object"==typeof e&&null!==e){let t=[];for(let r in e){let s=r.replace(/([A-Z])/g,"-$1").toLowerCase();t.push(`${s}:${e[r]}`)}return t.join(";")}return""}isState(e){return e&&"object"==typeof e&&"value"in e&&"subscribe"in e&&"function"==typeof e.subscribe}createReactiveChild(e,t){let r=t(e.value);if(typeof window<"u"&&typeof document<"u"){let r={node:null,renderFn:t};this.reactiveNodes.set(e,r),e.subscribe(()=>{if(r.node&&r.node.parentNode){let s=t(e.value);r.node.textContent=String(s??"")}})}return r}jsonToVNode(e){if(this.isState(e))return this.createReactiveChild(e,e=>e);if(null==e||"boolean"==typeof e||"string"==typeof e||"number"==typeof e)return e;let{tag:t,attributes:r={},children:s}=e,o={};for(let e in r){let t=r[e];"class"===e?o.className=this.isState(t)?t.value:t:o[e]=this.isState(t)?t.value:t}let n=[];if(null!=s)if(Array.isArray(s))for(let e of s)if(this.isState(e))n.push(this.createReactiveChild(e,e=>e));else{let t=this.jsonToVNode(e);null!=t&&!1!==t&&n.push(t)}else if(this.isState(s))n.push(this.createReactiveChild(s,e=>e));else if("object"==typeof s&&"tag"in s){let e=this.jsonToVNode(s);null!=e&&!1!==e&&n.push(e)}else n.push(s);return{tagName:t,props:o,children:n}}vNodeJsonToVNode(e){if(this.isState(e))return this.createReactiveChild(e,e=>e);if(null==e||"boolean"==typeof e||"string"==typeof e||"number"==typeof e)return e;let{tagName:t,props:r={},children:s=[]}=e,o={};for(let e in r){let t=r[e];o[e]=this.isState(t)?t.value:t}let n=[];for(let e of s)if(this.isState(e))n.push(this.createReactiveChild(e,e=>e));else{let t=this.vNodeJsonToVNode(e);null!=t&&!1!==t&&n.push(t)}return{tagName:t,props:o,children:n}}renderJson(e,t){let r=this.jsonToVNode(t);if(!r||"object"!=typeof r||!("tagName"in r))throw new Error("Invalid JSON structure");return this.render(e,r)}renderVNode(e,t){let r=this.vNodeJsonToVNode(t);if(!r||"object"!=typeof r||!("tagName"in r))throw new Error("Invalid VNode JSON structure");return this.render(e,r)}renderJsonToString(e,t={}){let r=this.jsonToVNode(e);return this.renderToString(r,t)}renderVNodeToString(e,t={}){let r=this.vNodeJsonToVNode(e);return this.renderToString(r,t)}renderServer(e){if("object"!=typeof e||null===e||!("tagName"in e))throw new Error("renderServer requires a VNode with html tag");if("html"!==e.tagName)throw new Error("renderServer requires a VNode with html tag as root");let t=e,r=null,s=null;for(let e of t.children||[])"object"==typeof e&&null!==e&&"tagName"in e&&("head"===e.tagName&&(r=e),"body"===e.tagName&&(s=e));if(t.props)for(let e in t.props){let r=t.props[e];null!=r&&!1!==r&&document.documentElement.setAttribute(e,String(r))}if(r){document.head.innerHTML="";for(let e of r.children||[])this.renderToDOM(e,document.head)}if(s){if(document.body.innerHTML="",s.props)for(let e in s.props){let t=s.props[e];null!=t&&!1!==t&&document.body.setAttribute(e,String(t))}for(let e of s.children||[])this.renderToDOM(e,document.body)}}renderToHTMLDocument(e,t={}){let{title:r="",meta:s=[],links:o=[],scripts:n=[],styles:i=[],lang:a="en",head:l="",bodyAttrs:p={},pretty:c=!1}=t,d=c?"\n":"",u=c?" ":"",h=c?" ":"",g=`<!DOCTYPE html>${d}<html lang="${a}">${d}${u}<head>${d}${h}<meta charset="UTF-8">${d}${h}<meta name="viewport" content="width=device-width, initial-scale=1.0">${d}`;r&&(g+=`${h}<title>${this.escapeHtml(r)}</title>${d}`);for(let e of s){g+=`${h}<meta`;for(let t in e)g+=` ${t}="${this.escapeHtml(e[t])}"`;g+=`>${d}`}for(let e of o){g+=`${h}<link`;for(let t in e)g+=` ${t}="${this.escapeHtml(e[t])}"`;g+=`>${d}`}for(let e of i)e.href?g+=`${h}<link rel="stylesheet" href="${this.escapeHtml(e.href)}">${d}`:e.content&&(g+=`${h}<style>${e.content}</style>${d}`);l&&(g+=l+d),g+=`${u}</head>${d}${u}<body`;for(let e in p)g+=` ${e}="${this.escapeHtml(p[e])}"`;g+=`>${d}`,g+=this.renderToString(e,{pretty:c,indent:2});for(let e of n)g+=`${h}<script`,e.type&&(g+=` type="${this.escapeHtml(e.type)}"`),e.async&&(g+=" async"),e.defer&&(g+=" defer"),e.src?g+=` src="${this.escapeHtml(e.src)}"><\/script>${d}`:e.content?g+=`>${e.content}<\/script>${d}`:g+=`><\/script>${d}`;return g+=`${u}</body>${d}</html>`,g}getElementCache(){return this.elementCache}},u=new d,h=(e,t)=>u.createState(e,t),g=class{constructor(e,t,r){this.key=e,this.wsUrl=r,this.ws=null,this.pendingUpdates=[],this.localState=h(t),this.previousValue=t,this.connect()}get value(){return this.localState.value}set value(e){this.previousValue=this.localState.value,this.localState.value=e,this.sendToServer(e)}get state(){return this.localState}onChange(e){return this.localState.subscribe(t=>{let r=this.previousValue;this.previousValue=t,e(t,r)})}update(e){this.value=e(this.value)}connect(){if(typeof window>"u")return;let e=this.wsUrl||`ws://${location.host}`;this.ws=new WebSocket(e),this.ws.addEventListener("open",()=>{for(this.subscribe();this.pendingUpdates.length>0;){let e=this.pendingUpdates.shift();this.sendToServer(e)}}),this.ws.addEventListener("message",e=>{this.handleMessage(e.data)}),this.ws.addEventListener("close",()=>{setTimeout(()=>this.connect(),1e3)}),this.ws.addEventListener("error",e=>{console.error("[SharedState] WebSocket error:",e)})}subscribe(){!this.ws||this.ws.readyState!==WebSocket.OPEN||this.ws.send(JSON.stringify({type:"state:subscribe",key:this.key}))}handleMessage(e){try{let t=JSON.parse(e);if(t.key!==this.key)return;("state:init"===t.type||"state:update"===t.type)&&(this.localState.value=t.value)}catch{}}sendToServer(e){if(this.ws){if(this.ws.readyState!==WebSocket.OPEN)return void this.pendingUpdates.push(e);this.ws.send(JSON.stringify({type:"state:change",key:this.key,value:e}))}}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}destroy(){this.disconnect(),this.localState.destroy()}};var m=new class{constructor(){this.states=new Map}create(e,t,r){if(this.states.has(e))return this.states.get(e);let s=new g(e,t,r);return this.states.set(e,s),s}get(e){return this.states.get(e)}delete(e){let t=this.states.get(e);return!!t&&(t.destroy(),this.states.delete(e))}clear(){this.states.forEach(e=>e.destroy()),this.states.clear()}},f=(e,t)=>{let r=null,s=null,o=null,n=!0,i=t(e.value),a=i&&"object"==typeof i&&"tagName"in i,l=null==i||!1===i;e.subscribe(()=>{r&&cancelAnimationFrame(r),r=requestAnimationFrame(()=>{(()=>{if(!s&&!o)return;let r=t(e.value);if(null==r||!1===r)n&&s&&(o=document.createComment("reactive"),s.parentNode?.replaceChild(o,s),n=!1);else if(!n&&o&&s&&(o.parentNode?.replaceChild(s,o),o=null,n=!0),s){let e=document.createDocumentFragment();if(a&&r&&"object"==typeof r&&"tagName"in r){let{props:t,children:o}=r;for(let e in t){let r=t[e];if("ref"!==e)if("class"===e||"className"===e)s.className=Array.isArray(r)?r.join(" "):r||"";else if("style"===e&&"object"==typeof r){let e=s.style;for(let t in r)e[t]=r[t]}else e.startsWith("on")?s[e.toLowerCase()]=r:null!=r&&!1!==r?s.setAttribute(e,String(!0===r?"":r)):s.removeAttribute(e)}for(let t of o)u.renderToDOM(t,e)}else u.renderToDOM(r,e);s.textContent="",s.appendChild(e),u.getElementCache().set(s,!0)}})(),r=null})});let p=e=>{s=e,l&&e.parentNode&&(o=document.createComment("reactive"),e.parentNode.replaceChild(o,e),n=!1)};if(a){let e=i;return{tagName:e.tagName,props:{...e.props,ref:p},children:e.children}}return{tagName:"span",props:{ref:p},children:[i]}},y=e=>function(t,...r){if(!arguments.length)return{tagName:e,props:{},children:[]};let s=t&&"object"==typeof t&&"value"in t&&"subscribe"in t,o=t&&"object"==typeof t&&"tagName"in t,n="object"!=typeof t||Array.isArray(t)||null===t||s||o,i=n?{}:t,a=n?[t,...r]:r;if(!a.length)return{tagName:e,props:i,children:[]};let l=[];for(let e=0,t=a.length;e<t;e++){let t=a[e];if(null!=t&&!1!==t)if(Array.isArray(t))for(let e=0,r=t.length;e<r;e++){let r=t[e];null!=r&&!1!==r&&l.push(r)}else l.push(t)}return{tagName:e,props:i,children:l}},v={};["html","head","body","title","base","link","meta","style","address","article","aside","footer","header","h1","h2","h3","h4","h5","h6","main","nav","section","blockquote","dd","div","dl","dt","figcaption","figure","hr","li","ol","p","pre","ul","a","abbr","b","bdi","bdo","br","cite","code","data","dfn","em","i","kbd","mark","q","rp","rt","ruby","s","samp","small","span","strong","sub","sup","time","u","wbr","area","audio","img","map","track","video","embed","iframe","object","param","picture","portal","source","canvas","noscript","script","del","ins","caption","col","colgroup","table","tbody","td","tfoot","th","thead","tr","button","datalist","fieldset","form","input","label","legend","meter","optgroup","option","output","progress","select","textarea","details","dialog","menu","summary","slot","template"].forEach(e=>{v[e]=y(e)}),["svg","circle","rect","path","line","polyline","polygon","ellipse","g","text","tspan","defs","linearGradient","radialGradient","stop","pattern","mask","clipPath","use","symbol","marker","image","foreignObject","animate","animateTransform","animateMotion","set","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence"].forEach(e=>{let t="svg"+e.charAt(0).toUpperCase()+e.slice(1);v[t]=y(e)}),["math","mi","mn","mo","ms","mtext","mrow","mfrac","msqrt","mroot","msub","msup"].forEach(e=>{let t="math"+e.charAt(0).toUpperCase()+e.slice(1);v[t]=y(e)}),v.varElement=y("var");var{head:x,body:b,title:w,base:$,link:S,meta:E,style:T,address:C,article:N,aside:M,footer:R,header:k,h1:j,h2:F,h3:H,h4:O,h5:A,h6:D,main:P,nav:W,section:L,blockquote:q,dd:B,div:U,dl:I,dt:J,figcaption:V,figure:_,hr:G,li:z,ol:K,p:X,pre:Z,ul:Y,a:Q,abbr:ee,b:te,bdi:re,bdo:se,br:oe,cite:ne,code:ie,data:ae,dfn:le,em:pe,i:ce,kbd:de,mark:ue,q:he,rp:ge,rt:me,ruby:fe,s:ye,samp:ve,small:xe,span:be,strong:we,sub:$e,sup:Se,time:Ee,u:Te,wbr:Ce,area:Ne,audio:Me,img:Re,map:ke,track:je,video:Fe,embed:He,iframe:Oe,object:Ae,param:De,picture:Pe,portal:We,source:Le,canvas:qe,noscript:Be,script:Ue,del:Ie,ins:Je,caption:Ve,col:_e,colgroup:Ge,table:ze,tbody:Ke,td:Xe,tfoot:Ze,th:Ye,thead:Qe,tr:et,button:tt,datalist:rt,fieldset:st,form:ot,input:nt,label:it,legend:at,meter:lt,optgroup:pt,option:ct,output:dt,progress:ut,select:ht,textarea:gt,details:mt,dialog:ft,menu:yt,summary:vt,slot:xt,template:bt,svgSvg:wt,svgCircle:$t,svgRect:St,svgPath:Et,svgLine:Tt,svgPolyline:Ct,svgPolygon:Nt,svgEllipse:Mt,svgG:Rt,svgText:kt,svgTspan:jt,svgDefs:Ft,svgLinearGradient:Ht,svgRadialGradient:Ot,svgStop:At,svgPattern:Dt,svgMask:Pt,svgClipPath:Wt,svgUse:Lt,svgSymbol:qt,svgMarker:Bt,svgImage:Ut,svgForeignObject:It,svgAnimate:Jt,svgAnimateTransform:Vt,svgAnimateMotion:_t,svgSet:Gt,svgFilter:zt,svgFeBlend:Kt,svgFeColorMatrix:Xt,svgFeComponentTransfer:Zt,svgFeComposite:Yt,svgFeConvolveMatrix:Qt,svgFeDiffuseLighting:er,svgFeDisplacementMap:tr,svgFeFlood:rr,svgFeGaussianBlur:sr,svgFeMorphology:or,svgFeOffset:nr,svgFeSpecularLighting:ir,svgFeTile:ar,svgFeTurbulence:lr,mathMath:pr,mathMi:cr,mathMn:dr,mathMo:ur,mathMs:hr,mathMtext:gr,mathMrow:mr,mathMfrac:fr,mathMsqrt:yr,mathMroot:vr,mathMsub:xr,mathMsup:br,varElement:wr}=v,$r=v,Sr=document,Er=Sr.querySelector.bind(Sr),Tr=Sr.querySelectorAll.bind(Sr),Cr=Sr.createElement.bind(Sr),Nr=Sr.createElementNS.bind(Sr,"http://www.w3.org/2000/svg"),Mr=Sr.createElementNS.bind(Sr,"http://www.w3.org/1998/Math/MathML"),Rr=Sr.createDocumentFragment.bind(Sr),kr=Sr.createTextNode.bind(Sr),jr=Sr.createComment.bind(Sr),Fr=Sr.getElementById.bind(Sr),Hr=Sr.getElementsByClassName.bind(Sr),Or=Sr.getElementsByTagName.bind(Sr),Ar=Sr.getElementsByName.bind(Sr);function Dr(e,t){let r=e.split("/").filter(Boolean),s=t.split("/").filter(Boolean);if(e.endsWith("*")){let r=e.slice(0,-1);if(t.startsWith(r)||"/"===r||"*"===e)return{"*":t.slice(r.length)}}if(r.length!==s.length)return null;let o={};for(let e=0;e<r.length;e++){let t=r[e],n=s[e];if(t.startsWith(":"))o[t.slice(1)]=decodeURIComponent(n);else if(t!==n)return null}return o}var Pr=class{constructor(){this.routes=[],this.middlewares=[]}use(e){return this.middlewares.push(e),this}get(e,t){return this.addRoute("GET",e,t)}post(e,t){return this.addRoute("POST",e,t)}put(e,t){return this.addRoute("PUT",e,t)}delete(e,t){return this.addRoute("DELETE",e,t)}patch(e,t){return this.addRoute("PATCH",e,t)}options(e,t){return this.addRoute("OPTIONS",e,t)}addRoute(e,t,r){let{pattern:s,paramNames:o}=this.pathToRegex(t);return this.routes.push({method:e,pattern:s,paramNames:o,handler:r}),this}pathToRegex(e){let t=[],r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\//g,"\\/").replace(/:(\w+)/g,(e,r)=>(t.push(r),"([^\\/]+)"));return{pattern:new RegExp(`^${r}$`),paramNames:t}}parseQuery(e){let t={},r=e.split("?")[1];return r&&new URLSearchParams(r).forEach((e,r)=>t[r]=e),t}async parseBody(e){return new Promise((t,r)=>{let s="";e.on("data",e=>s+=e.toString()),e.on("end",()=>{try{let r=e.headers["content-type"]||"";if(r.includes("application/json"))t(s?JSON.parse(s):{});else if(r.includes("application/x-www-form-urlencoded")){let e={};new URLSearchParams(s).forEach((t,r)=>e[r]=t),t(e)}else t(s)}catch(e){r(e)}}),e.on("error",r)})}async handle(e,t){let r=e.method,s=e.url||"/",o=s.split("?")[0];for(let n of this.routes){if(n.method!==r)continue;let i=o.match(n.pattern);if(!i)continue;let a={};n.paramNames.forEach((e,t)=>{a[e]=i[t+1]});let l=this.parseQuery(s),p={};if(["POST","PUT","PATCH"].includes(r))try{p=await this.parseBody(e)}catch{return t.writeHead(400,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:"Invalid request body"})),!0}let c={req:e,res:t,params:a,query:l,body:p,headers:e.headers},d=0,u=async()=>{if(d<this.middlewares.length){let e=this.middlewares[d++];await e(c,u)}};try{await u(),await n.handler(c)}catch(e){console.error("Route handler error:",e),t.headersSent||(t.writeHead(500,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:"Internal Server Error",message:e instanceof Error?e.message:"Unknown error"})))}return!0}return!1}};function Wr(e){return async(s,o)=>{let n=s.url||"/",i=n.split("?")[0],a=e.find(e=>i.startsWith(e.context));if(!a)return!1;let{target:l,changeOrigin:p,pathRewrite:c,headers:d}=a;try{let e=new URL(l),i="https:"===e.protocol,a=i?r.request:t.request,u=function(e,t){if(!t)return e;for(let[r,s]of Object.entries(t)){let t=new RegExp(r);if(t.test(e))return e.replace(t,s)}return e}(n,c),h={hostname:e.hostname,port:e.port||(i?443:80),path:u,method:s.method,headers:{...s.headers,...d||{}}};p&&(h.headers.host=e.host),delete h.headers.host;let g=a(h,e=>{o.writeHead(e.statusCode||200,e.headers),e.pipe(o)});return g.on("error",e=>{console.error("[Proxy] Error proxying %s to %s:",n,l,e.message),o.headersSent||(o.writeHead(502,{"Content-Type":"application/json"}),o.end(JSON.stringify({error:"Bad Gateway",message:"Proxy error"})))}),s.pipe(g),!0}catch(e){return console.error("[Proxy] Invalid proxy configuration for %s:",i,e),!1}}}var Lr=class{constructor(e,t){this.key=e,this.listeners=new Set,this.changeHandlers=new Set,this.options=t,this._value=t.initial}get value(){return this._value}set value(e){if(this.options.validate&&!this.options.validate(e))throw new Error(`Invalid state value for "${this.key}"`);let t=this._value;this._value=e,this.changeHandlers.forEach(r=>{r(e,t)}),this.broadcast()}update(e){this.value=e(this._value)}subscribe(e){this.listeners.add(e),this.sendTo(e)}unsubscribe(e){this.listeners.delete(e)}onChange(e){return this.changeHandlers.add(e),()=>this.changeHandlers.delete(e)}broadcast(){let e=JSON.stringify({type:"state:update",key:this.key,value:this._value,timestamp:Date.now()});this.listeners.forEach(t=>t.readyState===s.WebSocket.OPEN&&t.send(e))}sendTo(e){e.readyState===s.WebSocket.OPEN&&e.send(JSON.stringify({type:"state:init",key:this.key,value:this._value,timestamp:Date.now()}))}get subscriberCount(){return this.listeners.size}clear(){this.listeners.clear(),this.changeHandlers.clear()}},qr=class{constructor(){this.states=new Map}create(e,t){if(this.states.has(e))return this.states.get(e);let r=new Lr(e,t);return this.states.set(e,r),r}get(e){return this.states.get(e)}has(e){return this.states.has(e)}delete(e){let t=this.states.get(e);return!!t&&(t.clear(),this.states.delete(e))}subscribe(e,t){this.states.get(e)?.subscribe(t)}unsubscribe(e,t){this.states.get(e)?.unsubscribe(t)}unsubscribeAll(e){this.states.forEach(t=>t.unsubscribe(e))}handleStateChange(e,t){let r=this.states.get(e);r&&(r.value=t)}keys(){return Array.from(this.states.keys())}clear(){this.states.forEach(e=>e.clear()),this.states.clear()}},Br={port:3e3,host:"localhost",https:!1,open:!0,watch:["**/*.ts","**/*.js","**/*.html","**/*.css"],ignore:["node_modules/**","dist/**",".git/**","**/*.d.ts"],logging:!0,middleware:[],worker:[]};var Ur=new class{constructor(){this.enabled=!1,this.ws=null,this.acceptCallbacks=[],this.disposeCallbacks=[],this.declined=!1,typeof window>"u"||this.connect()}connect(){let e="https:"===window.location.protocol?"wss:":"ws:",t=window.location.hostname,r=window.location.port||"3000";this.ws=new WebSocket(`${e}//${t}:${r}`),this.ws.onopen=()=>{this.enabled=!0,console.log("[Elit HMR] Connected āœ“")},this.ws.onmessage=e=>{try{let t=JSON.parse(e.data);this.handleMessage(t)}catch(e){console.error("[Elit HMR] Error parsing message:",e)}},this.ws.onclose=()=>{this.enabled=!1,console.log("[Elit HMR] Disconnected - Attempting reconnect..."),setTimeout(()=>this.reload(),1e3)},this.ws.onerror=e=>{console.error("[Elit HMR] WebSocket error:",e)}}handleMessage(e){switch(e.type){case"connected":console.log("[Elit HMR] Ready");break;case"update":if(console.log(`[Elit HMR] Update detected: ${e.path}`),this.declined)return void this.reload();this.disposeCallbacks.forEach(e=>e()),this.disposeCallbacks=[],this.acceptCallbacks.length>0?this.acceptCallbacks.forEach(e=>e()):this.reload();break;case"reload":console.log("[Elit HMR] Full reload requested"),this.reload();break;case"error":console.error("[Elit HMR] Server error:",e.error)}}reload(){window.location.reload()}accept(e){e&&this.acceptCallbacks.push(e),this.declined=!1}decline(){this.declined=!0}dispose(e){this.disposeCallbacks.push(e)}};typeof window<"u"&&(window.__ELIT_HMR__=Ur);var Ir=Ur,Jr={outDir:"dist",minify:!0,sourcemap:!1,target:"es2020",format:"esm",treeshake:!0,logging:!0,external:[]};function Vr(e){if(0===e)return"0 B";let t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["B","KB","MB","GB"][t]}var _r=["elit.config.ts","elit.config.js","elit.config.mjs","elit.config.cjs","elit.config.json"];async function Gr(e){let t=e.split(".").pop();if("json"===t){let t=p.readFileSync(e,"utf-8");return JSON.parse(t)}if("ts"!==t){let{pathToFileURL:t}=await import("url"),r=await import(t(e).href);return r.default||r}try{let{pathToFileURL:t}=await import("url"),r=await import(t(e).href);return r.default||r}catch{throw console.error("TypeScript config files require tsx or ts-node to be installed."),console.error("Install with: npm install -D tsx"),console.error("Or use a .js or .json config file instead."),new Error("Cannot load TypeScript config without tsx/ts-node")}}exports.ApiRouter=Pr,exports.CreateStyle=class{constructor(){this.variables=[],this.rules=[],this.mediaRules=[],this.keyframes=[],this.fontFaces=[],this.imports=[],this.containerRules=[],this.supportsRules=[],this.layerRules=[],this._layerOrder=[]}addVar(e,t){let r={name:e.startsWith("--")?e:`--${e}`,value:t,toString(){return`var(${this.name})`}};return this.variables.push(r),r}var(e,t){let r="string"==typeof e?e.startsWith("--")?e:`--${e}`:e.name;return t?`var(${r}, ${t})`:`var(${r})`}addTag(e,t){let r={selector:e,styles:t,type:"tag"};return this.rules.push(r),r}addClass(e,t){let r={selector:e.startsWith(".")?e:`.${e}`,styles:t,type:"class"};return this.rules.push(r),r}addId(e,t){let r={selector:e.startsWith("#")?e:`#${e}`,styles:t,type:"id"};return this.rules.push(r),r}addPseudoClass(e,t,r){let s=e.startsWith(":")?e:`:${e}`,o={selector:r?`${r}${s}`:s,styles:t,type:"pseudo-class"};return this.rules.push(o),o}addPseudoElement(e,t,r){let s=e.startsWith("::")?e:`::${e}`,o={selector:r?`${r}${s}`:s,styles:t,type:"pseudo-element"};return this.rules.push(o),o}addAttribute(e,t,r){let s=e.startsWith("[")?e:`[${e}]`,o={selector:r?`${r}${s}`:s,styles:t,type:"attribute"};return this.rules.push(o),o}attrEquals(e,t,r,s){return this.addAttribute(`${e}="${t}"`,r,s)}attrContainsWord(e,t,r,s){return this.addAttribute(`${e}~="${t}"`,r,s)}attrStartsWith(e,t,r,s){return this.addAttribute(`${e}^="${t}"`,r,s)}attrEndsWith(e,t,r,s){return this.addAttribute(`${e}$="${t}"`,r,s)}attrContains(e,t,r,s){return this.addAttribute(`${e}*="${t}"`,r,s)}descendant(e,t,r){let s={selector:`${e} ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}child(e,t,r){let s={selector:`${e} > ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}adjacentSibling(e,t,r){let s={selector:`${e} + ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}generalSibling(e,t,r){let s={selector:`${e} ~ ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}multiple(e,t){let r={selector:e.join(", "),styles:t,type:"custom"};return this.rules.push(r),r}addName(e,t){return{selector:e.startsWith("--")?`&${e}`:`&--${e}`,styles:t,type:"name"}}nesting(e,...t){return e.nested=t,e}keyframe(e,t){let r={name:e,steps:Object.entries(t).map(([e,t])=>({step:"from"===e?"from":"to"===e?"to":`${e}%`,styles:t}))};return this.keyframes.push(r),r}keyframeFromTo(e,t,r){return this.keyframe(e,{from:t,to:r})}fontFace(e){return this.fontFaces.push(e),e}import(e,t){let r=t?`@import url("${e}") ${t};`:`@import url("${e}");`;return this.imports.push(r),r}media(e,t,r){let s={type:e,condition:t,rules:Object.entries(r).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.mediaRules.push(s),s}mediaScreen(e,t){return this.media("screen",e,t)}mediaPrint(e){return this.media("print","",e)}mediaMinWidth(e,t){return this.media("screen",`min-width: ${e}`,t)}mediaMaxWidth(e,t){return this.media("screen",`max-width: ${e}`,t)}mediaDark(e){let t={type:"",condition:"prefers-color-scheme: dark",rules:Object.entries(e).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.mediaRules.push(t),t}mediaLight(e){let t={type:"",condition:"prefers-color-scheme: light",rules:Object.entries(e).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.mediaRules.push(t),t}mediaReducedMotion(e){let t={type:"",condition:"prefers-reduced-motion: reduce",rules:Object.entries(e).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.mediaRules.push(t),t}container(e,t,r){let s={name:r,condition:e,rules:Object.entries(t).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.containerRules.push(s),s}addContainer(e,t){let r={...t,containerName:e};return this.addClass(e,r)}supports(e,t){let r={condition:e,rules:Object.entries(t).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.supportsRules.push(r),r}layerOrder(...e){this._layerOrder=e}layer(e,t){let r={name:e,rules:Object.entries(t).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.layerRules.push(r),r}add(e){return Object.entries(e).map(([e,t])=>{let r={selector:e,styles:t,type:"custom"};return this.rules.push(r),r})}important(e){return`${e} !important`}toKebabCase(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}stylesToString(e,t=" "){return Object.entries(e).map(([e,r])=>{let s="object"==typeof r&&null!==r&&"name"in r?`var(${r.name})`:r;return`${t}${this.toKebabCase(e)}: ${s};`}).join("\n")}renderRule(e,t=""){let r=`${t}${e.selector} {\n${this.stylesToString(e.styles,t+" ")}\n`;if(e.nested&&e.nested.length>0)for(let s of e.nested){r+=`\n${t}${s.selector.startsWith("&")?s.selector.replace(/&/g,e.selector):`${e.selector} ${s.selector}`} {\n${this.stylesToString(s.styles,t+" ")}\n${t}}\n`}return r+=`${t}}`,r}renderMediaRule(e){let t=`@media ${e.type&&e.condition?`${e.type} and (${e.condition})`:e.type?e.type:`(${e.condition})`} {\n`;for(let r of e.rules)t+=this.renderRule(r," ")+"\n";return t+="}",t}renderKeyframes(e){let t=`@keyframes ${e.name} {\n`;for(let r of e.steps)t+=` ${r.step} {\n${this.stylesToString(r.styles," ")}\n }\n`;return t+="}",t}renderFontFace(e){let t="@font-face {\n";return t+=` font-family: "${e.fontFamily}";\n`,t+=` src: ${e.src};\n`,e.fontWeight&&(t+=` font-weight: ${e.fontWeight};\n`),e.fontStyle&&(t+=` font-style: ${e.fontStyle};\n`),e.fontDisplay&&(t+=` font-display: ${e.fontDisplay};\n`),e.unicodeRange&&(t+=` unicode-range: ${e.unicodeRange};\n`),t+="}",t}renderContainerRule(e){let t=`@container ${e.name?`${e.name} `:""}(${e.condition}) {\n`;for(let r of e.rules)t+=this.renderRule(r," ")+"\n";return t+="}",t}renderSupportsRule(e){let t=`@supports (${e.condition}) {\n`;for(let r of e.rules)t+=this.renderRule(r," ")+"\n";return t+="}",t}renderLayerRule(e){let t=`@layer ${e.name} {\n`;for(let r of e.rules)t+=this.renderRule(r," ")+"\n";return t+="}",t}render(...e){let t=[];if(this.imports.length>0&&t.push(this.imports.join("\n")),this._layerOrder.length>0&&t.push(`@layer ${this._layerOrder.join(", ")};`),this.variables.length>0){let e=this.variables.map(e=>` ${e.name}: ${e.value};`).join("\n");t.push(`:root {\n${e}\n}`)}for(let e of this.fontFaces)t.push(this.renderFontFace(e));for(let e of this.keyframes)t.push(this.renderKeyframes(e));let r=[...this.rules],s=[...this.mediaRules],o=[],n=[...this.containerRules],i=[...this.supportsRules],a=[...this.layerRules];for(let t of e)t&&(Array.isArray(t)?r.push(...t):!("condition"in t)||!("rules"in t)||"name"in t&&"steps"in t?"name"in t&&"steps"in t?o.push(t):"name"in t&&"rules"in t?a.push(t):r.push(t):"type"in t?s.push(t):"name"in t&&"string"==typeof t.name?n.push(t):i.push(t));for(let e of o)t.push(this.renderKeyframes(e));for(let e of a)t.push(this.renderLayerRule(e));for(let e of r)t.push(this.renderRule(e));for(let e of i)t.push(this.renderSupportsRule(e));for(let e of n)t.push(this.renderContainerRule(e));for(let e of s)t.push(this.renderMediaRule(e));return t.join("\n\n")}inject(e){let t=this.render(),r=document.createElement("style");return e&&(r.id=e),r.textContent=t,document.head.appendChild(r),r}clear(){this.variables=[],this.rules=[],this.mediaRules=[],this.keyframes=[],this.fontFaces=[],this.imports=[],this.containerRules=[],this.supportsRules=[],this.layerRules=[],this._layerOrder=[]}},exports.DomNode=d,exports.ServerRouter=Pr,exports.SharedState=Lr,exports.StateManager=qr,exports.a=Q,exports.abbr=ee,exports.address=C,exports.area=Ne,exports.article=N,exports.aside=M,exports.audio=Me,exports.b=te,exports.base=$,exports.batchRender=(e,t)=>u.batchRender(e,t),exports.bdi=re,exports.bdo=se,exports.bindChecked=e=>({checked:e.value,onchange:t=>{e.value=t.target.checked}}),exports.bindValue=e=>({value:e.value,oninput:t=>{e.value=t.target.value}}),exports.blockquote=q,exports.body=b,exports.bodyLimit=function(e={}){let{limit:t=1048576}=e;return async(e,r)=>{if(parseInt(e.req.headers["content-length"]||"0",10)>t)return e.res.writeHead(413,{"Content-Type":"application/json"}),void e.res.end(JSON.stringify({error:"Request body too large"}));await r()}},exports.br=oe,exports.build=async function(e){let t={...Jr,...e},r=Date.now();if(!t.entry)throw new Error("Entry file is required");let s=i.resolve(t.entry),o=i.resolve(t.outDir),n=t.outFile;if(!n){n=i.basename(t.entry,i.extname(t.entry))+("cjs"===t.format?".cjs":".js")}let a=i.join(o,n);try{p.mkdirSync(o,{recursive:!0})}catch{}t.logging&&(console.log("\nšŸ”Ø Building..."),console.log(` Entry: ${t.entry}`),console.log(` Output: ${a}`),console.log(` Format: ${t.format}`),console.log(` Target: ${t.target}`));let c={name:"browser-only",setup(e){e.onResolve({filter:/^(node:.*|fs|path|http|https|url|os|child_process|net|tls|crypto|stream|util|events|buffer|zlib|readline|process|assert|constants|dns|domain|punycode|querystring|repl|string_decoder|sys|timers|tty|v8|vm)$/},()=>({path:"node-builtin",external:!0,sideEffects:!1})),e.onResolve({filter:/^(chokidar|esbuild|mime-types|open|ws|fs\/promises)$/},()=>({path:"server-dep",external:!0,sideEffects:!1})),e.onLoad({filter:/[\\/](server|config|cli)\.ts$/},()=>({contents:"export {}",loader:"js"}))}};try{let e=t.platform||("cjs"===t.format?"node":"browser"),n="browser"===e?[c]:[],d={};t.env&&(Object.entries(t.env).forEach(([e,t])=>{e.startsWith("VITE_")&&(d[`import.meta.env.${e}`]=JSON.stringify(t))}),t.env.MODE&&(d["import.meta.env.MODE"]=JSON.stringify(t.env.MODE)),d["import.meta.env.DEV"]=JSON.stringify("production"!==t.env.MODE),d["import.meta.env.PROD"]=JSON.stringify("production"===t.env.MODE));let u=await l.build({entryPoints:[s],bundle:!0,outfile:a,format:t.format,target:t.target,minify:t.minify,sourcemap:t.sourcemap,external:t.external,treeShaking:t.treeshake,globalName:t.globalName,platform:e,plugins:n,define:d,logLevel:t.logging?"info":"silent",metafile:!0,...t.minify&&{minifyWhitespace:!0,minifyIdentifiers:!0,minifySyntax:!0,legalComments:"none",mangleProps:/^_/,keepNames:!1}}),h=Date.now()-r,g=p.statSync(a).size;if(t.logging&&(console.log("\nāœ… Build successful!"),console.log(` Time: ${h}ms`),console.log(` Size: ${Vr(g)}`),u.metafile)){let e=Object.keys(u.metafile.inputs).length;console.log(` Files: ${e} input(s)`);let t=Object.keys(u.metafile.outputs);if(t.length>0){let e=u.metafile.outputs[t[0]];if(e&&e.inputs){let t=Object.entries(e.inputs).sort(([,e],[,t])=>t.bytesInOutput-e.bytesInOutput).slice(0,5);t.length>0&&(console.log("\n šŸ“Š Top 5 largest modules:"),t.forEach(([e,t])=>{let r=e.split(/[/\\]/).pop()||e;console.log(` ${r.padEnd(30)} ${Vr(t.bytesInOutput)}`)}))}}}let m={outputPath:a,buildTime:h,size:g};if(t.copy&&t.copy.length>0){t.logging&&console.log("\nšŸ“¦ Copying files...");for(let e of t.copy){let r=i.resolve(e.from),s=i.resolve(o,e.to),n=i.dirname(s);if(p.existsSync(n)||p.mkdirSync(n,{recursive:!0}),p.existsSync(r)){if(e.transform){let o=p.readFileSync(r,"utf-8"),n=e.transform(o,t);p.writeFileSync(s,n)}else p.copyFileSync(r,s);t.logging&&console.log(` āœ“ ${e.from} → ${e.to}`)}else t.logging&&console.warn(` ⚠ File not found: ${e.from}`)}}return t.onBuildEnd&&await t.onBuildEnd(m),t.logging&&console.log(""),m}catch(e){throw t.logging&&(console.error("\nāŒ Build failed:"),console.error(e)),e}},exports.button=tt,exports.cacheControl=function(e={}){let{maxAge:t=3600,public:r=!0}=e;return async(e,s)=>{e.res.setHeader("Cache-Control",`${r?"public":"private"}, max-age=${t}`),await s()}},exports.canvas=qe,exports.caption=Ve,exports.cite=ne,exports.cleanupUnused=e=>u.cleanupUnusedElements(e),exports.code=ie,exports.col=_e,exports.colgroup=Ge,exports.commentNode=jr,exports.compress=function(){return async(e,t)=>{if(!(e.req.headers["accept-encoding"]||"").includes("gzip"))return void await t();let r=e.res.end.bind(e.res),s=[];e.res.write=e=>(s.push(Buffer.from(e)),!0),e.res.end=t=>{t&&s.push(Buffer.from(t));let o=Buffer.concat(s),{gzipSync:n}=c("zlib"),i=n(o);return e.res.setHeader("Content-Encoding","gzip"),e.res.setHeader("Content-Length",i.length),r(i),e.res},await t()}},exports.computed=(e,t)=>u.computed(e,t),exports.cors=function(e={}){let{origin:t="*",methods:r=["GET","POST","PUT","DELETE","PATCH","OPTIONS"],credentials:s=!0,maxAge:o=86400}=e;return async(e,n)=>{let i=e.req.headers.origin||"",a=Array.isArray(t)&&t.includes(i)?i:Array.isArray(t)?"":t;if(a&&e.res.setHeader("Access-Control-Allow-Origin",a),e.res.setHeader("Access-Control-Allow-Methods",r.join(", ")),e.res.setHeader("Access-Control-Allow-Headers","Content-Type, Authorization"),s&&e.res.setHeader("Access-Control-Allow-Credentials","true"),e.res.setHeader("Access-Control-Max-Age",String(o)),"OPTIONS"===e.req.method)return e.res.writeHead(204),void e.res.end();await n()}},exports.createDevServer=function(e){let r={...Br,...e},p=new Set,d=new qr,h=r.clients?.length?r.clients:r.root?[{root:r.root,basePath:r.basePath||"",ssr:r.ssr,proxy:r.proxy}]:null;if(!h)throw new Error('DevServerOptions must include either "clients" array or "root" directory');let g=h.map(e=>{let t=e.basePath||"";if(t){for(;t.startsWith("/");)t=t.slice(1);for(;t.endsWith("/");)t=t.slice(0,-1);t=t?"/"+t:""}return{root:e.root,basePath:t,ssr:e.ssr,proxyHandler:e.proxy?Wr(e.proxy):void 0}}),m=r.proxy?Wr(r.proxy):null,f=t.createServer(async(e,t)=>{let s=e.url||"/",o=g.find(e=>e.basePath&&s.startsWith(e.basePath))||g.find(e=>!e.basePath);if(!o)return t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found");if(o.proxyHandler)try{if(await o.proxyHandler(e,t))return void(r.logging&&console.log(`[Proxy] ${e.method} ${s} -> proxied (client-specific)`))}catch(e){console.error("[Proxy] Error (client-specific):",e)}if(m)try{if(await m(e,t))return void(r.logging&&console.log(`[Proxy] ${e.method} ${s} -> proxied (global)`))}catch(e){console.error("[Proxy] Error (global):",e)}let a=o.basePath?s.slice(o.basePath.length)||"/":s;if(r.api&&a.startsWith("/api")&&await r.api.handle(e,t))return;let l="/"===a?"/index.html":a;if(l=l.split("?")[0],r.logging&&"/src/pages"===l&&console.log("[DEBUG] Request for /src/pages received"),l.includes("\0"))return r.logging&&console.log(`[403] Rejected path with null byte: ${l}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");let p,c=l.startsWith("/dist/"),d=i.normalize(l).replace(/\\/g,"/").replace(/^\/+/,"");if(d.includes(".."))return r.logging&&console.log(`[403] Path traversal attempt: ${l}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");p=d;let u,h=await n.realpath(i.resolve(o.root)),f=c?await n.realpath(i.resolve(o.root,"..")):h;try{if(u=await n.realpath(i.resolve(i.join(f,p))),!u.startsWith(f.endsWith(i.sep)?f:f+i.sep))return r.logging&&console.log(`[403] File access outside of root: ${u}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");r.logging&&"/src/pages"===l&&console.log(`[DEBUG] Initial resolve succeeded: ${u}`)}catch{let e;if(r.logging&&!p.includes(".")&&console.log(`[DEBUG] File not found: ${p}, trying extensions...`),p.endsWith(".js")){let s=p.replace(/\.js$/,".ts");try{let o=await n.realpath(i.resolve(i.join(f,s)));if(!o.startsWith(f.endsWith(i.sep)?f:f+i.sep))return r.logging&&console.log(`[403] Fallback TS path outside of root: ${o}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");e=o}catch{}}if(!e&&!p.includes("."))try{e=await n.realpath(i.resolve(i.join(f,p+".ts"))),r.logging&&console.log(`[DEBUG] Found: ${p}.ts`)}catch{try{e=await n.realpath(i.resolve(i.join(f,p+".js"))),r.logging&&console.log(`[DEBUG] Found: ${p}.js`)}catch{try{e=await n.realpath(i.resolve(i.join(f,p,"index.ts"))),r.logging&&console.log(`[DEBUG] Found: ${p}/index.ts`)}catch{try{e=await n.realpath(i.resolve(i.join(f,p,"index.js"))),r.logging&&console.log(`[DEBUG] Found: ${p}/index.js`)}catch{r.logging&&console.log(`[DEBUG] Not found: all attempts failed for ${p}`)}}}}if(!e)return t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found");u=e}try{if((await n.stat(u)).isDirectory()){let e;r.logging&&console.log(`[DEBUG] Path is directory: ${u}, trying index files...`);try{e=await n.realpath(i.resolve(i.join(u,"index.ts"))),r.logging&&console.log("[DEBUG] Found index.ts in directory")}catch{try{e=await n.realpath(i.resolve(i.join(u,"index.js"))),r.logging&&console.log("[DEBUG] Found index.js in directory")}catch{return r.logging&&console.log("[DEBUG] No index file found in directory"),t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found")}}u=e}}catch{return t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found")}let v=await n.realpath(i.resolve(o.root,"..")),x=u.startsWith(h+i.sep)||u===h,b=c&&(u.startsWith(v+i.sep)||u===v);if(!x&&!b)return r.logging&&console.log(`[403] Path outside allowed directories: ${l}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");try{if((await n.stat(u)).isDirectory())try{let e=await n.realpath(i.resolve(i.join(u,"index.html")));return e.startsWith(h+i.sep)||e===h?(await n.stat(e),y(e,t,o)):(t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden"))}catch{return t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found")}await y(u,t,o)}catch{r.logging&&console.log(`[404] ${l}`),t.writeHead(404,{"Content-Type":"text/plain"}),t.end("404 Not Found")}});async function y(e,t,s){try{let o,p=await n.realpath(i.resolve(s.root)),d=await n.realpath(i.resolve(s.root,".."));try{o=await n.realpath(i.resolve(e))}catch{return e.endsWith("index.html")&&s.ssr?function(e,t){try{if(!t.ssr)return e.writeHead(500,{"Content-Type":"text/plain"}),void e.end("SSR function not configured");let s,o=t.ssr();if("string"==typeof o)s=o;else if("object"==typeof o&&null!==o&&"tagName"in o){let e=o;s="html"===e.tagName?u.renderToString(e):`<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"></head><body>${u.renderToString(e)}</body></html>`}else s=String(o);let n=`<script>(function(){const ws=new WebSocket('ws://${r.host}:${r.port}${t.basePath}');ws.onopen=()=>console.log('[Elit HMR] Connected');ws.onmessage=(e)=>{const d=JSON.parse(e.data);if(d.type==='update'){console.log('[Elit HMR] File updated:',d.path);window.location.reload()}else if(d.type==='reload'){console.log('[Elit HMR] Reloading...');window.location.reload()}else if(d.type==='error')console.error('[Elit HMR] Error:',d.error)};ws.onclose=()=>{console.log('[Elit HMR] Disconnected - Retrying...');setTimeout(()=>window.location.reload(),1000)};ws.onerror=(e)=>console.error('[Elit HMR] WebSocket error:',e)})();<\/script>`;s=s.includes("</body>")?s.replace("</body>",`${n}</body>`):s+n,e.writeHead(200,{"Content-Type":"text/html","Cache-Control":"no-cache, no-store, must-revalidate"}),e.end(s),r.logging&&console.log("[200] SSR rendered")}catch(t){e.writeHead(500,{"Content-Type":"text/plain"}),e.end("500 SSR Error"),r.logging&&console.error("[500] SSR Error:",t)}}(t,s):(t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found"))}let h=o.startsWith(p+i.sep)||o===p,g=o.startsWith(d+i.sep+"dist"+i.sep);if(!h&&!g)return r.logging&&console.log(`[403] Attempted to serve file outside allowed directories: ${e}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");let m=await n.readFile(o),f=i.extname(o),y=a.lookup(o)||"application/octet-stream";if(".ts"===f||".tsx"===f)try{let e=await l.build({stdin:{contents:m.toString(),loader:".tsx"===f?"tsx":"ts",resolveDir:i.resolve(o,".."),sourcefile:o},format:"esm",target:"es2020",write:!1,bundle:!1,sourcemap:"inline"});m=Buffer.from(e.outputFiles[0].text),y="application/javascript"}catch(e){return t.writeHead(500,{"Content-Type":"text/plain"}),t.end(`TypeScript compilation error:\n${e}`),void(r.logging&&console.error("[500] TypeScript compilation error:",e))}if(".html"===f){let e=`<script type="importmap">\n{\n "imports": {\n "elit": "${s.basePath?`${s.basePath}/dist/client.mjs`:"/dist/client.mjs"}"\n }\n}\n<\/script>`,t=`<script>(function(){const ws=new WebSocket('ws://${r.host}:${r.port}${s.basePath}');ws.onopen=()=>console.log('[Elit HMR] Connected');ws.onmessage=(e)=>{const d=JSON.parse(e.data);if(d.type==='update'){console.log('[Elit HMR] File updated:',d.path);window.location.reload()}else if(d.type==='reload'){console.log('[Elit HMR] Reloading...');window.location.reload()}else if(d.type==='error')console.error('[Elit HMR] Error:',d.error)};ws.onclose=()=>{console.log('[Elit HMR] Disconnected - Retrying...');setTimeout(()=>window.location.reload(),1000)};ws.onerror=(e)=>console.error('[Elit HMR] WebSocket error:',e)})();<\/script>`,o=m.toString();if(s.basePath&&"/"!==s.basePath){let e=`<base href="${s.basePath}/">`;o.includes("<base")||(o.includes('<meta name="viewport"')?o=o.replace(/<meta name="viewport"[^>]*>/,t=>`${t}\n ${e}`):o.includes("<head>")&&(o=o.replace("<head>",`<head>\n ${e}`)))}o=o.includes("</head>")?o.replace("</head>",`${e}</head>`):o,o=o.includes("</body>")?o.replace("</body>",`${t}</body>`):o+t,m=Buffer.from(o)}let v={"Content-Type":y,"Cache-Control":".html"===f||".ts"===f||".tsx"===f?"no-cache, no-store, must-revalidate":"public, max-age=31536000, immutable"};if(/^(text\/|application\/(javascript|json|xml))/.test(y)&&m.length>1024){let{gzipSync:e}=c("zlib"),r=e(m);v["Content-Encoding"]="gzip",v["Content-Length"]=r.length,t.writeHead(200,v),t.end(r)}else t.writeHead(200,v),t.end(m);r.logging&&console.log(`[200] ${i.relative(s.root,e)}`)}catch(e){t.writeHead(500,{"Content-Type":"text/plain"}),t.end("500 Internal Server Error"),r.logging&&console.error("[500] Error reading file:",e)}}let v=new s.WebSocketServer({server:f});v.on("connection",e=>{p.add(e);let t={type:"connected",timestamp:Date.now()};e.send(JSON.stringify(t)),r.logging&&console.log("[HMR] Client connected"),e.on("message",t=>{try{let s=JSON.parse(t.toString());"state:subscribe"===s.type?(d.subscribe(s.key,e),r.logging&&console.log(`[State] Client subscribed to "${s.key}"`)):"state:unsubscribe"===s.type?(d.unsubscribe(s.key,e),r.logging&&console.log(`[State] Client unsubscribed from "${s.key}"`)):"state:change"===s.type&&(d.handleStateChange(s.key,s.value),r.logging&&console.log(`[State] Client updated "${s.key}"`))}catch(e){r.logging&&console.error("[WebSocket] Message parse error:",e)}}),e.on("close",()=>{p.delete(e),d.unsubscribeAll(e),r.logging&&console.log("[HMR] Client disconnected")})});let x=g.flatMap(e=>r.watch.map(t=>i.join(e.root,t))),b=o.watch(x,{ignored:r.ignore,ignoreInitial:!0,persistent:!0});b.on("change",e=>{r.logging&&console.log(`[HMR] File changed: ${e}`);let t=JSON.stringify({type:"update",path:e,timestamp:Date.now()});p.forEach(e=>e.readyState===s.WebSocket.OPEN&&e.send(t))}),b.on("add",e=>r.logging&&console.log(`[HMR] File added: ${e}`)),b.on("unlink",e=>r.logging&&console.log(`[HMR] File removed: ${e}`)),f.setMaxListeners(20),f.listen(r.port,r.host,()=>{if(r.logging){if(console.log("\nšŸš€ Elit Dev Server"),console.log(`\n āžœ Local: http://${r.host}:${r.port}`),g.length>1)console.log(" āžœ Clients:"),g.forEach(e=>{let t=`http://${r.host}:${r.port}${e.basePath}`;console.log(` - ${t} → ${e.root}`)});else{let e=g[0];console.log(` āžœ Root: ${e.root}`),e.basePath&&console.log(` āžœ Base: ${e.basePath}`)}console.log("\n[HMR] Watching for file changes...\n")}if(r.open&&g.length>0){let e=g[0],t=`http://${r.host}:${r.port}${e.basePath}`;(async()=>{let{default:e}=await import("open");await e(t)})().catch(()=>{})}});let w=!1,$=g[0],S=`http://${r.host}:${r.port}${$.basePath}`;return{server:f,wss:v,url:S,state:d,close:async()=>{if(!w)return w=!0,r.logging&&console.log("\n[Server] Shutting down..."),await b.close(),v.close(),p.forEach(e=>e.close()),p.clear(),new Promise(e=>{f.close(()=>{r.logging&&console.log("[Server] Closed"),e()})})}}},exports.createEl=Cr,exports.createElementFactory=y,exports.createMathEl=Mr,exports.createRouter=function(e){let{mode:t="history",base:r="",routes:s}=e,o=[],n=e=>{let t={};return new URLSearchParams(e).forEach((e,r)=>{t[r]=e}),t},i=()=>"hash"===t?window.location.hash.slice(1)||"/":window.location.pathname.replace(r,"")||"/",a=e=>{let[t,r=""]=e.split("?"),[s,o=""]=t.split("#");return{path:s||"/",params:{},query:n(r),hash:o?"#"+o:""}},l=e=>{for(let t of s){let r=Dr(t.path,e);if(null!==r)return{route:t,params:r}}return null},p=u.createState(a(i())),c=(e,s=!1)=>{let n=a(e),i=l(n.path);i&&(n.params=i.params);for(let e of o){let t=e(n,p.value);if(!1===t)return;if("string"==typeof t)return void c(t,s)}if(i?.route.beforeEnter){let e=i.route.beforeEnter(n,p.value);if(!1===e)return;if("string"==typeof e)return void c(e,s)}let d="hash"===t?"#"+e:r+e;s?window.history.replaceState({path:e},"",d):window.history.pushState({path:e},"",d),p.value=n},d=()=>{let e=i(),t=a(e),r=l(t.path);r&&(t.params=r.params),p.value=t};return typeof window<"u"&&window.addEventListener("popstate",d),{currentRoute:p,push:e=>c(e,!1),replace:e=>c(e,!0),back:()=>window.history.back(),forward:()=>window.history.forward(),go:e=>window.history.go(e),beforeEach:e=>{o.push(e)},destroy:()=>{typeof window<"u"&&window.removeEventListener("popstate",d),p.destroy()}}},exports.createRouterView=function(e,t){let{routes:r,notFound:s}=t;return()=>{let t=e.currentRoute.value,o=r.find(e=>null!==Dr(e.path,t.path));if(o){let e=Dr(o.path,t.path)||{},r=o.component({...e,...t.query});return"object"==typeof r&&null!==r&&"tagName"in r?r:{tagName:"span",props:{},children:[r]}}if(s){let e=s(t.params);return"object"==typeof e&&null!==e&&"tagName"in e?e:{tagName:"span",props:{},children:[e]}}return{tagName:"div",props:{},children:["404 - Not Found"]}}},exports.createSharedState=function(e,t,r){return new g(e,t,r)},exports.createState=h,exports.createSvgEl=Nr,exports.createVirtualList=(e,t,r,s,o)=>u.createVirtualList(e,t,r,s,o),exports.data=ae,exports.datalist=rt,exports.dd=B,exports.debounce=(e,t)=>{let r=null;return(...s)=>{r&&clearTimeout(r),r=setTimeout(()=>e(...s),t)}},exports.defineConfig=function(e){return e},exports.del=Ie,exports.details=mt,exports.dfn=le,exports.dialog=ft,exports.div=U,exports.dl=I,exports.doc=Sr,exports.dom=u,exports.dt=J,exports.effect=e=>u.effect(e),exports.el=$r,exports.elements=v,exports.em=pe,exports.embed=He,exports.errorHandler=function(){return async(e,t)=>{try{await t()}catch(t){console.error("Error:",t),e.res.headersSent||(e.res.writeHead(500,{"Content-Type":"application/json"}),e.res.end(JSON.stringify({error:"Internal Server Error",message:t instanceof Error?t.message:"Unknown error"})))}}},exports.fieldset=st,exports.figcaption=V,exports.figure=_,exports.footer=R,exports.form=ot,exports.fragment=Rr,exports.getEl=Er,exports.getElClass=Hr,exports.getElId=Fr,exports.getElName=Ar,exports.getElTag=Or,exports.getEls=Tr,exports.h1=j,exports.h2=F,exports.h3=H,exports.h4=O,exports.h5=A,exports.h6=D,exports.head=x,exports.header=k,exports.hmr=Ir,exports.hr=G,exports.html=(e,t,r=200)=>{e.writeHead(r,{"Content-Type":"text/html"}),e.end(t)},exports.i=ce,exports.iframe=Oe,exports.img=Re,exports.input=nt,exports.ins=Je,exports.json=(e,t,r=200)=>{e.writeHead(r,{"Content-Type":"application/json"}),e.end(JSON.stringify(t))},exports.kbd=de,exports.label=it,exports.lazy=e=>u.lazy(e),exports.legend=at,exports.li=z,exports.link=S,exports.loadConfig=async function(e=process.cwd()){for(let t of _r){let r=i.resolve(e,t);if(p.existsSync(r))try{return await Gr(r)}catch(e){throw console.error(`Error loading config file: ${t}`),console.error(e),e}}return null},exports.loadEnv=function(e="development",t=process.cwd()){let r={MODE:e},s=[`.env.${e}.local`,`.env.${e}`,".env.local",".env"];for(let e of s){let s=i.resolve(t,e);if(p.existsSync(s)){let e=p.readFileSync(s,"utf-8").split("\n");for(let t of e){let e=t.trim();if(!e||e.startsWith("#"))continue;let s=e.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);if(s){let[,e,t]=s,o=t.trim();(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),e in r||(r[e]=o)}}}}return r},exports.logger=function(e={}){let{format:t="simple"}=e;return async(e,r)=>{let s=Date.now(),{method:o,url:n}=e.req;await r();let i=Date.now()-s,a=e.res.statusCode;console.log("detailed"===t?`[${(new Date).toISOString()}] ${o} ${n} ${a} - ${i}ms`:`${o} ${n} - ${a} (${i}ms)`)}},exports.main=P,exports.map=ke,exports.mark=ue,exports.mathMath=pr,exports.mathMfrac=fr,exports.mathMi=cr,exports.mathMn=dr,exports.mathMo=ur,exports.mathMroot=vr,exports.mathMrow=mr,exports.mathMs=hr,exports.mathMsqrt=yr,exports.mathMsub=xr,exports.mathMsup=br,exports.mathMtext=gr,exports.menu=yt,exports.mergeConfig=function(e,t){return e?{...e,...Object.fromEntries(Object.entries(t).filter(([e,t])=>void 0!==t))}:t},exports.meta=E,exports.meter=lt,exports.nav=W,exports.noscript=Be,exports.object=Ae,exports.ol=K,exports.optgroup=pt,exports.option=ct,exports.output=dt,exports.p=X,exports.param=De,exports.picture=Pe,exports.portal=We,exports.pre=Z,exports.progress=ut,exports.q=he,exports.rateLimit=function(e={}){let{windowMs:t=6e4,max:r=100,message:s="Too many requests"}=e,o=new Map;return async(e,n)=>{let i=e.req.socket.remoteAddress||"unknown",a=Date.now(),l=o.get(i);if((!l||a>l.resetTime)&&(l={count:0,resetTime:a+t},o.set(i,l)),++l.count>r)return e.res.writeHead(429,{"Content-Type":"application/json"}),void e.res.end(JSON.stringify({error:s}));await n()}},exports.reactive=f,exports.reactiveAs=(e,t,r,s={})=>{let o=null,n=null;return t.subscribe(()=>{o&&cancelAnimationFrame(o),o=requestAnimationFrame(()=>{if(n){let e=document.createDocumentFragment(),s=r(t.value);null==s||!1===s?(n.style.display="none",n.textContent=""):(n.style.display="",u.renderToDOM(s,e),n.textContent="",n.appendChild(e)),u.getElementCache().set(n,!0)}o=null})}),{tagName:e,props:{...s,ref:e=>{n=e}},children:[r(t.value)]}},exports.renderChunked=(e,t,r,s)=>u.renderChunked(e,t,r,s),exports.routerLink=(e,t,...r)=>({tagName:"a",props:{...t,href:t.to,onclick:r=>{r.preventDefault(),e.push(t.to)}},children:r}),exports.rp=ge,exports.rt=me,exports.ruby=fe,exports.s=ye,exports.samp=ve,exports.script=Ue,exports.section=L,exports.security=function(){return async(e,t)=>{e.res.setHeader("X-Content-Type-Options","nosniff"),e.res.setHeader("X-Frame-Options","DENY"),e.res.setHeader("X-XSS-Protection","1; mode=block"),e.res.setHeader("Strict-Transport-Security","max-age=31536000; includeSubDomains"),await t()}},exports.select=ht,exports.sendText=(e,t,r=200)=>{e.writeHead(r,{"Content-Type":"text/plain"}),e.end(t)},exports.sharedStateManager=m,exports.slot=xt,exports.small=xe,exports.source=Le,exports.span=be,exports.status=(e,t,r)=>{e.writeHead(t,{"Content-Type":"application/json"}),e.end(JSON.stringify({status:t,message:r||""}))},exports.strong=we,exports.style=T,exports.sub=$e,exports.summary=vt,exports.sup=Se,exports.svgAnimate=Jt,exports.svgAnimateMotion=_t,exports.svgAnimateTransform=Vt,exports.svgCircle=$t,exports.svgClipPath=Wt,exports.svgDefs=Ft,exports.svgEllipse=Mt,exports.svgFeBlend=Kt,exports.svgFeColorMatrix=Xt,exports.svgFeComponentTransfer=Zt,exports.svgFeComposite=Yt,exports.svgFeConvolveMatrix=Qt,exports.svgFeDiffuseLighting=er,exports.svgFeDisplacementMap=tr,exports.svgFeFlood=rr,exports.svgFeGaussianBlur=sr,exports.svgFeMorphology=or,exports.svgFeOffset=nr,exports.svgFeSpecularLighting=ir,exports.svgFeTile=ar,exports.svgFeTurbulence=lr,exports.svgFilter=zt,exports.svgForeignObject=It,exports.svgG=Rt,exports.svgImage=Ut,exports.svgLine=Tt,exports.svgLinearGradient=Ht,exports.svgMarker=Bt,exports.svgMask=Pt,exports.svgPath=Et,exports.svgPattern=Dt,exports.svgPolygon=Nt,exports.svgPolyline=Ct,exports.svgRadialGradient=Ot,exports.svgRect=St,exports.svgSet=Gt,exports.svgStop=At,exports.svgSvg=wt,exports.svgSymbol=qt,exports.svgText=kt,exports.svgTspan=jt,exports.svgUse=Lt,exports.table=ze,exports.tbody=Ke,exports.td=Xe,exports.template=bt,exports.text=e=>e&&void 0!==e.value?f(e,e=>({tagName:"span",props:{},children:[String(e)]})):String(e),exports.textNode=kr,exports.textarea=gt,exports.tfoot=Ze,exports.th=Ye,exports.thead=Qe,exports.throttle=(e,t)=>{let r=null;return(...s)=>{r||(r=setTimeout(()=>{r=null,e(...s)},t))}},exports.time=Ee,exports.title=w,exports.tr=et,exports.track=je,exports.u=Te,exports.ul=Y,exports.varElement=wr,exports.video=Fe,exports.wbr=Ce;
package/dist/index.mjs CHANGED
@@ -1,35 +1 @@
1
- var Z=Object.defineProperty;var Q=(i,e)=>{for(var t in e)Z(i,t,{get:e[t],enumerable:true});};var E=class{constructor(){this.elementCache=new WeakMap;this.reactiveNodes=new Map;}createElement(e,t={},r=[]){return {tagName:e,props:t,children:r}}renderToDOM(e,t){if(e==null||e===false)return;if(typeof e!="object"){t.appendChild(document.createTextNode(String(e)));return}let{tagName:r,props:n,children:s}=e,a=r==="svg"||r[0]==="s"&&r[1]==="v"&&r[2]==="g"||t.namespaceURI==="http://www.w3.org/2000/svg",o=a?document.createElementNS("http://www.w3.org/2000/svg",r.replace("svg","").toLowerCase()||r):document.createElement(r);for(let p in n){let d=n[p];if(d==null||d===false)continue;let c=p.charCodeAt(0);if(c===99&&(p.length<6||p[5]==="N")){let h=Array.isArray(d)?d.join(" "):d;a?o.setAttribute("class",h):o.className=h;}else if(c===115&&p.length===5)if(typeof d=="string")o.style.cssText=d;else {let h=o.style;for(let g in d)h[g]=d[g];}else c===111&&p.charCodeAt(1)===110?o[p.toLowerCase()]=d:c===100&&p.length>20?o.innerHTML=d.__html:c===114&&p.length===3?setTimeout(()=>{typeof d=="function"?d(o):d.current=o;},0):o.setAttribute(p,d===true?"":String(d));}let u=s.length;if(!u){t.appendChild(o);return}let l=p=>{for(let d=0;d<u;d++){let c=s[d];if(!(c==null||c===false))if(Array.isArray(c))for(let h=0,g=c.length;h<g;h++){let v=c[h];v!=null&&v!==false&&this.renderToDOM(v,p);}else this.renderToDOM(c,p);}};if(u>30){let p=document.createDocumentFragment();l(p),o.appendChild(p);}else l(o);t.appendChild(o);}render(e,t){let r=typeof e=="string"?document.getElementById(e.replace("#","")):e;if(!r)throw new Error(`Element not found: ${e}`);if(t.children&&t.children.length>500){let n=document.createDocumentFragment();this.renderToDOM(t,n),r.appendChild(n);}else this.renderToDOM(t,r);return r}batchRender(e,t){let r=typeof e=="string"?document.getElementById(e.replace("#","")):e;if(!r)throw new Error(`Element not found: ${e}`);let n=t.length;if(n>3e3){let s=document.createDocumentFragment(),a=0,o=1500,u=()=>{let l=Math.min(a+o,n);for(let p=a;p<l;p++)this.renderToDOM(t[p],s);a=l,a>=n?r.appendChild(s):requestAnimationFrame(u);};u();}else {let s=document.createDocumentFragment();for(let a=0;a<n;a++)this.renderToDOM(t[a],s);r.appendChild(s);}return r}renderChunked(e,t,r=5e3,n){let s=typeof e=="string"?document.getElementById(e.replace("#","")):e;if(!s)throw new Error(`Element not found: ${e}`);let a=t.length,o=0,u=()=>{let l=Math.min(o+r,a),p=document.createDocumentFragment();for(let d=o;d<l;d++)this.renderToDOM(t[d],p);s.appendChild(p),o=l,n&&n(o,a),o<a&&requestAnimationFrame(u);};return requestAnimationFrame(u),s}renderToHead(...e){let t=document.head;if(t)for(let r of e.flat())r&&this.renderToDOM(r,t);return t}addStyle(e){let t=document.createElement("style");return t.textContent=e,document.head.appendChild(t)}addMeta(e){let t=document.createElement("meta");for(let r in e)t.setAttribute(r,e[r]);return document.head.appendChild(t)}addLink(e){let t=document.createElement("link");for(let r in e)t.setAttribute(r,e[r]);return document.head.appendChild(t)}setTitle(e){return document.title=e}createState(e,t={}){let r=e,n=new Set,s=null,{throttle:a=0,deep:o=false}=t,u=()=>n.forEach(p=>p(r)),l=()=>{a>0?s||(s=setTimeout(()=>{s=null,u();},a)):u();};return {get value(){return r},set value(p){(o?JSON.stringify(r)!==JSON.stringify(p):r!==p)&&(r=p,l());},subscribe(p){return n.add(p),()=>n.delete(p)},destroy(){n.clear(),s&&clearTimeout(s);}}}computed(e,t){let r=e.map(s=>s.value),n=this.createState(t(...r));return e.forEach((s,a)=>{s.subscribe(o=>{r[a]=o,n.value=t(...r);});}),n}effect(e){e();}createVirtualList(e,t,r,n=50,s=5){let a=e.clientHeight,o=t.length*n,u=0,l=()=>{let c=Math.max(0,Math.floor(u/n)-s),h=Math.min(t.length,Math.ceil((u+a)/n)+s);return {start:c,end:h}},p=()=>{let{start:c,end:h}=l(),g=document.createElement("div");g.style.cssText=`height:${o}px;position:relative`;for(let v=c;v<h;v++){let m=document.createElement("div");m.style.cssText=`position:absolute;top:${v*n}px;height:${n}px;width:100%`,this.renderToDOM(r(t[v],v),m),g.appendChild(m);}e.innerHTML="",e.appendChild(g);},d=()=>{u=e.scrollTop,requestAnimationFrame(p);};return e.addEventListener("scroll",d),p(),{render:p,destroy:()=>{e.removeEventListener("scroll",d),e.innerHTML="";}}}lazy(e){let t=null,r=false;return async(...n)=>(!t&&!r&&(r=true,t=await e(),r=false),t?t(...n):{tagName:"div",props:{class:"loading"},children:["Loading..."]})}cleanupUnusedElements(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),r=[];for(;t.nextNode();){let n=t.currentNode;n.id&&n.id.startsWith("r")&&!this.elementCache.has(n)&&r.push(n);}return r.forEach(n=>n.remove()),r.length}renderToString(e,t={}){let{pretty:r=false,indent:n=0}=t,s=r?" ".repeat(n):"",a=r?`
2
- `:"",o=this.resolveStateValue(e);if(o=this.unwrapReactive(o),Array.isArray(o))return o.map(g=>this.renderToString(g,t)).join("");if(typeof o!="object"||o===null)return o==null||o===false?"":this.escapeHtml(String(o));let{tagName:u,props:l,children:p}=o,d=this.isSelfClosingTag(u),c=`${s}<${u}`,h=this.propsToAttributes(l);if(h&&(c+=` ${h}`),d)return c+=` />${a}`,c;if(c+=">",l.dangerouslySetInnerHTML)return c+=l.dangerouslySetInnerHTML.__html,c+=`</${u}>${a}`,c;if(p&&p.length>0){let g=p.map(m=>{let y=this.resolveStateValue(m);return this.unwrapReactive(y)}),v=g.some(m=>typeof m=="object"&&m!==null&&!Array.isArray(m)&&"tagName"in m);if(r&&v){c+=a;for(let m of g)if(!(m==null||m===false))if(Array.isArray(m))for(let y of m)y!=null&&y!==false&&(c+=this.renderToString(y,{pretty:r,indent:n+1}));else c+=this.renderToString(m,{pretty:r,indent:n+1});c+=s;}else for(let m of g)if(!(m==null||m===false))if(Array.isArray(m))for(let y of m)y!=null&&y!==false&&(c+=this.renderToString(y,{pretty:false,indent:0}));else c+=this.renderToString(m,{pretty:false,indent:0});}return c+=`</${u}>${a}`,c}resolveStateValue(e){return e&&typeof e=="object"&&"value"in e&&"subscribe"in e?e.value:e}isReactiveWrapper(e){return !e||typeof e!="object"||!e.tagName?false:e.tagName==="span"&&e.props?.id&&typeof e.props.id=="string"&&e.props.id.match(/^r[a-z0-9]{9}$/)}unwrapReactive(e){if(!this.isReactiveWrapper(e))return e;let t=e.children;if(!t||t.length===0)return "";if(t.length===1){let r=t[0];if(r&&typeof r=="object"&&r.tagName==="span"){let n=r.props,s=!n||Object.keys(n).length===0,a=r.children&&r.children.length===1&&typeof r.children[0]=="string";if(s&&a)return r.children[0]}return this.unwrapReactive(r)}return t.map(r=>this.unwrapReactive(r))}escapeHtml(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"};return e.replace(/[&<>"']/g,r=>t[r])}isSelfClosingTag(e){return new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]).has(e.toLowerCase())}propsToAttributes(e){let t=[];for(let r in e){if(r==="children"||r==="dangerouslySetInnerHTML"||r==="ref")continue;let n=e[r];if(n=this.resolveStateValue(n),!(n==null||n===false)&&!(r.startsWith("on")&&typeof n=="function")){if(r==="className"||r==="class"){let s=Array.isArray(n)?n.join(" "):n;s&&t.push(`class="${this.escapeHtml(String(s))}"`);continue}if(r==="style"){let s=this.styleToString(n);s&&t.push(`style="${this.escapeHtml(s)}"`);continue}if(n===true){t.push(r);continue}t.push(`${r}="${this.escapeHtml(String(n))}"`);}}return t.join(" ")}styleToString(e){if(typeof e=="string")return e;if(typeof e=="object"&&e!==null){let t=[];for(let r in e){let n=r.replace(/([A-Z])/g,"-$1").toLowerCase();t.push(`${n}:${e[r]}`);}return t.join(";")}return ""}isState(e){return e&&typeof e=="object"&&"value"in e&&"subscribe"in e&&typeof e.subscribe=="function"}createReactiveChild(e,t){let r=t(e.value);if(typeof window<"u"&&typeof document<"u"){let n={node:null,renderFn:t};this.reactiveNodes.set(e,n),e.subscribe(()=>{if(n.node&&n.node.parentNode){let s=t(e.value);n.node.textContent=String(s??"");}});}return r}jsonToVNode(e){if(this.isState(e))return this.createReactiveChild(e,o=>o);if(e==null||typeof e=="boolean"||typeof e=="string"||typeof e=="number")return e;let{tag:t,attributes:r={},children:n}=e,s={};for(let o in r){let u=r[o];o==="class"?s.className=this.isState(u)?u.value:u:s[o]=this.isState(u)?u.value:u;}let a=[];if(n!=null)if(Array.isArray(n))for(let o of n)if(this.isState(o))a.push(this.createReactiveChild(o,u=>u));else {let u=this.jsonToVNode(o);u!=null&&u!==false&&a.push(u);}else if(this.isState(n))a.push(this.createReactiveChild(n,o=>o));else if(typeof n=="object"&&"tag"in n){let o=this.jsonToVNode(n);o!=null&&o!==false&&a.push(o);}else a.push(n);return {tagName:t,props:s,children:a}}vNodeJsonToVNode(e){if(this.isState(e))return this.createReactiveChild(e,o=>o);if(e==null||typeof e=="boolean"||typeof e=="string"||typeof e=="number")return e;let{tagName:t,props:r={},children:n=[]}=e,s={};for(let o in r){let u=r[o];s[o]=this.isState(u)?u.value:u;}let a=[];for(let o of n)if(this.isState(o))a.push(this.createReactiveChild(o,u=>u));else {let u=this.vNodeJsonToVNode(o);u!=null&&u!==false&&a.push(u);}return {tagName:t,props:s,children:a}}renderJson(e,t){let r=this.jsonToVNode(t);if(!r||typeof r!="object"||!("tagName"in r))throw new Error("Invalid JSON structure");return this.render(e,r)}renderVNode(e,t){let r=this.vNodeJsonToVNode(t);if(!r||typeof r!="object"||!("tagName"in r))throw new Error("Invalid VNode JSON structure");return this.render(e,r)}renderJsonToString(e,t={}){let r=this.jsonToVNode(e);return this.renderToString(r,t)}renderVNodeToString(e,t={}){let r=this.vNodeJsonToVNode(e);return this.renderToString(r,t)}getElementCache(){return this.elementCache}},f=new E;var C=(i,e)=>f.createState(i,e),x=(i,e)=>f.computed(i,e),w=i=>f.effect(i),V=(i,e)=>f.batchRender(i,e),$=(i,e,t,r)=>f.renderChunked(i,e,t,r),k=(i,e,t,r,n)=>f.createVirtualList(i,e,t,r,n),F=i=>f.lazy(i),A=i=>f.cleanupUnusedElements(i),H=(i,e)=>{let t=null;return (...r)=>{t||(t=setTimeout(()=>{t=null,i(...r);},e));}},O=(i,e)=>{let t=null;return (...r)=>{t&&clearTimeout(t),t=setTimeout(()=>i(...r),e);}};var M=class{constructor(e,t,r){this.key=e;this.wsUrl=r;this.ws=null;this.pendingUpdates=[];this.localState=C(t),this.previousValue=t,this.connect();}get value(){return this.localState.value}set value(e){this.previousValue=this.localState.value,this.localState.value=e,this.sendToServer(e);}get state(){return this.localState}onChange(e){return this.localState.subscribe(t=>{let r=this.previousValue;this.previousValue=t,e(t,r);})}update(e){this.value=e(this.value);}connect(){if(typeof window>"u")return;let e=this.wsUrl||`ws://${location.host}`;this.ws=new WebSocket(e),this.ws.addEventListener("open",()=>{for(this.subscribe();this.pendingUpdates.length>0;){let t=this.pendingUpdates.shift();this.sendToServer(t);}}),this.ws.addEventListener("message",t=>{this.handleMessage(t.data);}),this.ws.addEventListener("close",()=>{setTimeout(()=>this.connect(),1e3);}),this.ws.addEventListener("error",t=>{console.error("[SharedState] WebSocket error:",t);});}subscribe(){!this.ws||this.ws.readyState!==WebSocket.OPEN||this.ws.send(JSON.stringify({type:"state:subscribe",key:this.key}));}handleMessage(e){try{let t=JSON.parse(e);if(t.key!==this.key)return;(t.type==="state:init"||t.type==="state:update")&&(this.localState.value=t.value);}catch{}}sendToServer(e){if(this.ws){if(this.ws.readyState!==WebSocket.OPEN){this.pendingUpdates.push(e);return}this.ws.send(JSON.stringify({type:"state:change",key:this.key,value:e}));}}disconnect(){this.ws&&(this.ws.close(),this.ws=null);}destroy(){this.disconnect(),this.localState.destroy();}};function j(i,e,t){return new M(i,e,t)}var P=class{constructor(){this.states=new Map;}create(e,t,r){if(this.states.has(e))return this.states.get(e);let n=new M(e,t,r);return this.states.set(e,n),n}get(e){return this.states.get(e)}delete(e){let t=this.states.get(e);return t?(t.destroy(),this.states.delete(e)):false}clear(){this.states.forEach(e=>e.destroy()),this.states.clear();}},J=new P;var L=(i,e)=>{let t=null,r=null,n=null,s=true,a=e(i.value),o=a&&typeof a=="object"&&"tagName"in a,u=a==null||a===false,l=()=>{if(!r&&!n)return;let d=e(i.value);if(d==null||d===false)s&&r&&(n=document.createComment("reactive"),r.parentNode?.replaceChild(n,r),s=false);else if(!s&&n&&r&&(n.parentNode?.replaceChild(r,n),n=null,s=true),r){let h=document.createDocumentFragment();if(o&&d&&typeof d=="object"&&"tagName"in d){let{props:g,children:v}=d;for(let m in g){let y=g[m];if(m!=="ref")if(m==="class"||m==="className")r.className=Array.isArray(y)?y.join(" "):y||"";else if(m==="style"&&typeof y=="object"){let T=r.style;for(let z in y)T[z]=y[z];}else m.startsWith("on")?r[m.toLowerCase()]=y:y!=null&&y!==false?r.setAttribute(m,String(y===true?"":y)):r.removeAttribute(m);}for(let m of v)f.renderToDOM(m,h);}else f.renderToDOM(d,h);r.textContent="",r.appendChild(h),f.getElementCache().set(r,true);}};i.subscribe(()=>{t&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{l(),t=null;});});let p=d=>{r=d,u&&d.parentNode&&(n=document.createComment("reactive"),d.parentNode.replaceChild(n,d),s=false);};if(o){let d=a;return {tagName:d.tagName,props:{...d.props,ref:p},children:d.children}}return {tagName:"span",props:{ref:p},children:[a]}},D=(i,e,t,r={})=>{let n=null,s=null;return e.subscribe(()=>{n&&cancelAnimationFrame(n),n=requestAnimationFrame(()=>{if(s){let o=document.createDocumentFragment(),u=t(e.value);u==null||u===false?(s.style.display="none",s.textContent=""):(s.style.display="",f.renderToDOM(u,o),s.textContent="",s.appendChild(o)),f.getElementCache().set(s,true);}n=null;});}),{tagName:i,props:{...r,ref:o=>{s=o;}},children:[t(e.value)]}},W=i=>i&&i.value!==void 0?L(i,e=>({tagName:"span",props:{},children:[String(e)]})):String(i),K=i=>({value:i.value,oninput:e=>{i.value=e.target.value;}}),q=i=>({checked:i.value,onchange:e=>{i.value=e.target.checked;}});var N=class{constructor(){this.variables=[];this.rules=[];this.mediaRules=[];this.keyframes=[];this.fontFaces=[];this.imports=[];this.containerRules=[];this.supportsRules=[];this.layerRules=[];this._layerOrder=[];}addVar(e,t){let r={name:e.startsWith("--")?e:`--${e}`,value:t,toString(){return `var(${this.name})`}};return this.variables.push(r),r}var(e,t){let r=typeof e=="string"?e.startsWith("--")?e:`--${e}`:e.name;return t?`var(${r}, ${t})`:`var(${r})`}addTag(e,t){let r={selector:e,styles:t,type:"tag"};return this.rules.push(r),r}addClass(e,t){let n={selector:e.startsWith(".")?e:`.${e}`,styles:t,type:"class"};return this.rules.push(n),n}addId(e,t){let n={selector:e.startsWith("#")?e:`#${e}`,styles:t,type:"id"};return this.rules.push(n),n}addPseudoClass(e,t,r){let n=e.startsWith(":")?e:`:${e}`,a={selector:r?`${r}${n}`:n,styles:t,type:"pseudo-class"};return this.rules.push(a),a}addPseudoElement(e,t,r){let n=e.startsWith("::")?e:`::${e}`,a={selector:r?`${r}${n}`:n,styles:t,type:"pseudo-element"};return this.rules.push(a),a}addAttribute(e,t,r){let n=e.startsWith("[")?e:`[${e}]`,a={selector:r?`${r}${n}`:n,styles:t,type:"attribute"};return this.rules.push(a),a}attrEquals(e,t,r,n){return this.addAttribute(`${e}="${t}"`,r,n)}attrContainsWord(e,t,r,n){return this.addAttribute(`${e}~="${t}"`,r,n)}attrStartsWith(e,t,r,n){return this.addAttribute(`${e}^="${t}"`,r,n)}attrEndsWith(e,t,r,n){return this.addAttribute(`${e}$="${t}"`,r,n)}attrContains(e,t,r,n){return this.addAttribute(`${e}*="${t}"`,r,n)}descendant(e,t,r){let s={selector:`${e} ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}child(e,t,r){let s={selector:`${e} > ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}adjacentSibling(e,t,r){let s={selector:`${e} + ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}generalSibling(e,t,r){let s={selector:`${e} ~ ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}multiple(e,t){let n={selector:e.join(", "),styles:t,type:"custom"};return this.rules.push(n),n}addName(e,t){return {selector:e.startsWith("--")?`&${e}`:`&--${e}`,styles:t,type:"name"}}nesting(e,...t){return e.nested=t,e}keyframe(e,t){let r=Object.entries(t).map(([s,a])=>({step:s==="from"?"from":s==="to"?"to":`${s}%`,styles:a})),n={name:e,steps:r};return this.keyframes.push(n),n}keyframeFromTo(e,t,r){return this.keyframe(e,{from:t,to:r})}fontFace(e){return this.fontFaces.push(e),e}import(e,t){let r=t?`@import url("${e}") ${t};`:`@import url("${e}");`;return this.imports.push(r),r}media(e,t,r){let n=Object.entries(r).map(([a,o])=>({selector:a,styles:o,type:"custom"})),s={type:e,condition:t,rules:n};return this.mediaRules.push(s),s}mediaScreen(e,t){return this.media("screen",e,t)}mediaPrint(e){return this.media("print","",e)}mediaMinWidth(e,t){return this.media("screen",`min-width: ${e}`,t)}mediaMaxWidth(e,t){return this.media("screen",`max-width: ${e}`,t)}mediaDark(e){let r={type:"",condition:"prefers-color-scheme: dark",rules:Object.entries(e).map(([n,s])=>({selector:n,styles:s,type:"custom"}))};return this.mediaRules.push(r),r}mediaLight(e){let r={type:"",condition:"prefers-color-scheme: light",rules:Object.entries(e).map(([n,s])=>({selector:n,styles:s,type:"custom"}))};return this.mediaRules.push(r),r}mediaReducedMotion(e){let r={type:"",condition:"prefers-reduced-motion: reduce",rules:Object.entries(e).map(([n,s])=>({selector:n,styles:s,type:"custom"}))};return this.mediaRules.push(r),r}container(e,t,r){let n=Object.entries(t).map(([a,o])=>({selector:a,styles:o,type:"custom"})),s={name:r,condition:e,rules:n};return this.containerRules.push(s),s}addContainer(e,t){let r={...t,containerName:e};return this.addClass(e,r)}supports(e,t){let r=Object.entries(t).map(([s,a])=>({selector:s,styles:a,type:"custom"})),n={condition:e,rules:r};return this.supportsRules.push(n),n}layerOrder(...e){this._layerOrder=e;}layer(e,t){let r=Object.entries(t).map(([s,a])=>({selector:s,styles:a,type:"custom"})),n={name:e,rules:r};return this.layerRules.push(n),n}add(e){return Object.entries(e).map(([r,n])=>{let s={selector:r,styles:n,type:"custom"};return this.rules.push(s),s})}important(e){return `${e} !important`}toKebabCase(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}stylesToString(e,t=" "){return Object.entries(e).map(([r,n])=>{let s=typeof n=="object"&&n!==null&&"name"in n?`var(${n.name})`:n;return `${t}${this.toKebabCase(r)}: ${s};`}).join(`
3
- `)}renderRule(e,t=""){let r=`${t}${e.selector} {
4
- ${this.stylesToString(e.styles,t+" ")}
5
- `;if(e.nested&&e.nested.length>0)for(let n of e.nested){let s=n.selector.startsWith("&")?n.selector.replace(/&/g,e.selector):`${e.selector} ${n.selector}`;r+=`
6
- ${t}${s} {
7
- ${this.stylesToString(n.styles,t+" ")}
8
- ${t}}
9
- `;}return r+=`${t}}`,r}renderMediaRule(e){let r=`@media ${e.type&&e.condition?`${e.type} and (${e.condition})`:e.type?e.type:`(${e.condition})`} {
10
- `;for(let n of e.rules)r+=this.renderRule(n," ")+`
11
- `;return r+="}",r}renderKeyframes(e){let t=`@keyframes ${e.name} {
12
- `;for(let r of e.steps)t+=` ${r.step} {
13
- ${this.stylesToString(r.styles," ")}
14
- }
15
- `;return t+="}",t}renderFontFace(e){let t=`@font-face {
16
- `;return t+=` font-family: "${e.fontFamily}";
17
- `,t+=` src: ${e.src};
18
- `,e.fontWeight&&(t+=` font-weight: ${e.fontWeight};
19
- `),e.fontStyle&&(t+=` font-style: ${e.fontStyle};
20
- `),e.fontDisplay&&(t+=` font-display: ${e.fontDisplay};
21
- `),e.unicodeRange&&(t+=` unicode-range: ${e.unicodeRange};
22
- `),t+="}",t}renderContainerRule(e){let r=`@container ${e.name?`${e.name} `:""}(${e.condition}) {
23
- `;for(let n of e.rules)r+=this.renderRule(n," ")+`
24
- `;return r+="}",r}renderSupportsRule(e){let t=`@supports (${e.condition}) {
25
- `;for(let r of e.rules)t+=this.renderRule(r," ")+`
26
- `;return t+="}",t}renderLayerRule(e){let t=`@layer ${e.name} {
27
- `;for(let r of e.rules)t+=this.renderRule(r," ")+`
28
- `;return t+="}",t}render(...e){let t=[];if(this.imports.length>0&&t.push(this.imports.join(`
29
- `)),this._layerOrder.length>0&&t.push(`@layer ${this._layerOrder.join(", ")};`),this.variables.length>0){let l=this.variables.map(p=>` ${p.name}: ${p.value};`).join(`
30
- `);t.push(`:root {
31
- ${l}
32
- }`);}for(let l of this.fontFaces)t.push(this.renderFontFace(l));for(let l of this.keyframes)t.push(this.renderKeyframes(l));let r=[...this.rules],n=[...this.mediaRules],s=[],a=[...this.containerRules],o=[...this.supportsRules],u=[...this.layerRules];for(let l of e)l&&(Array.isArray(l)?r.push(...l):"condition"in l&&"rules"in l&&!("name"in l&&"steps"in l)?"type"in l?n.push(l):"name"in l&&typeof l.name=="string"?a.push(l):o.push(l):"name"in l&&"steps"in l?s.push(l):"name"in l&&"rules"in l?u.push(l):r.push(l));for(let l of s)t.push(this.renderKeyframes(l));for(let l of u)t.push(this.renderLayerRule(l));for(let l of r)t.push(this.renderRule(l));for(let l of o)t.push(this.renderSupportsRule(l));for(let l of a)t.push(this.renderContainerRule(l));for(let l of n)t.push(this.renderMediaRule(l));return t.join(`
33
-
34
- `)}inject(e){let t=this.render(),r=document.createElement("style");return e&&(r.id=e),r.textContent=t,document.head.appendChild(r),r}clear(){this.variables=[],this.rules=[],this.mediaRules=[],this.keyframes=[],this.fontFaces=[],this.imports=[],this.containerRules=[],this.supportsRules=[],this.layerRules=[],this._layerOrder=[];}};function I(i,e){let t=i.split("/").filter(Boolean),r=e.split("/").filter(Boolean);if(i.endsWith("*")){let s=i.slice(0,-1);if(e.startsWith(s)||s==="/"||i==="*")return {"*":e.slice(s.length)}}if(t.length!==r.length)return null;let n={};for(let s=0;s<t.length;s++){let a=t[s],o=r[s];if(a.startsWith(":"))n[a.slice(1)]=decodeURIComponent(o);else if(a!==o)return null}return n}function G(i){let{mode:e="history",base:t="",routes:r}=i,n=[],s=c=>{let h={};return new URLSearchParams(c).forEach((v,m)=>{h[m]=v;}),h},a=()=>e==="hash"?window.location.hash.slice(1)||"/":window.location.pathname.replace(t,"")||"/",o=c=>{let[h,g=""]=c.split("?"),[v,m=""]=h.split("#");return {path:v||"/",params:{},query:s(g),hash:m?"#"+m:""}},u=c=>{for(let h of r){let g=I(h.path,c);if(g!==null)return {route:h,params:g}}return null},l=f.createState(o(a())),p=(c,h=false)=>{let g=o(c),v=u(g.path);v&&(g.params=v.params);for(let y of n){let T=y(g,l.value);if(T===false)return;if(typeof T=="string"){p(T,h);return}}if(v?.route.beforeEnter){let y=v.route.beforeEnter(g,l.value);if(y===false)return;if(typeof y=="string"){p(y,h);return}}let m=e==="hash"?"#"+c:t+c;h?window.history.replaceState({path:c},"",m):window.history.pushState({path:c},"",m),l.value=g;},d=()=>{let c=a(),h=o(c),g=u(h.path);g&&(h.params=g.params),l.value=h;};return typeof window<"u"&&window.addEventListener("popstate",d),{currentRoute:l,push:c=>p(c,false),replace:c=>p(c,true),back:()=>window.history.back(),forward:()=>window.history.forward(),go:c=>window.history.go(c),beforeEach:c=>{n.push(c);},destroy:()=>{typeof window<"u"&&window.removeEventListener("popstate",d),l.destroy();}}}function U(i,e){let{routes:t,notFound:r}=e;return ()=>{let n=i.currentRoute.value,s=t.find(a=>I(a.path,n.path)!==null);if(s){let a=I(s.path,n.path)||{},o=s.component({...a,...n.query});return typeof o=="object"&&o!==null&&"tagName"in o?o:{tagName:"span",props:{},children:[o]}}if(r){let a=r(n.params);return typeof a=="object"&&a!==null&&"tagName"in a?a:{tagName:"span",props:{},children:[a]}}return {tagName:"div",props:{},children:["404 - Not Found"]}}}var B=(i,e,...t)=>({tagName:"a",props:{...e,href:e.to,onclick:r=>{r.preventDefault(),i.push(e.to);}},children:t});var b=i=>function(e,...t){if(!arguments.length)return {tagName:i,props:{},children:[]};let r=e&&typeof e=="object"&&"value"in e&&"subscribe"in e,n=e&&typeof e=="object"&&"tagName"in e,s=typeof e!="object"||Array.isArray(e)||e===null||r||n,a=s?{}:e,o=s?[e,...t]:t;if(!o.length)return {tagName:i,props:a,children:[]};let u=[];for(let l=0,p=o.length;l<p;l++){let d=o[l];if(!(d==null||d===false))if(Array.isArray(d))for(let c=0,h=d.length;c<h;c++){let g=d[c];g!=null&&g!==false&&u.push(g);}else u.push(d);}return {tagName:i,props:a,children:u}},X=["html","head","body","title","base","link","meta","style","address","article","aside","footer","header","h1","h2","h3","h4","h5","h6","main","nav","section","blockquote","dd","div","dl","dt","figcaption","figure","hr","li","ol","p","pre","ul","a","abbr","b","bdi","bdo","br","cite","code","data","dfn","em","i","kbd","mark","q","rp","rt","ruby","s","samp","small","span","strong","sub","sup","time","u","wbr","area","audio","img","map","track","video","embed","iframe","object","param","picture","portal","source","canvas","noscript","script","del","ins","caption","col","colgroup","table","tbody","td","tfoot","th","thead","tr","button","datalist","fieldset","form","input","label","legend","meter","optgroup","option","output","progress","select","textarea","details","dialog","menu","summary","slot","template"],Y=["svg","circle","rect","path","line","polyline","polygon","ellipse","g","text","tspan","defs","linearGradient","radialGradient","stop","pattern","mask","clipPath","use","symbol","marker","image","foreignObject","animate","animateTransform","animateMotion","set","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence"],ee=["math","mi","mn","mo","ms","mtext","mrow","mfrac","msqrt","mroot","msub","msup"],R={};X.forEach(i=>{R[i]=b(i);});Y.forEach(i=>{let e="svg"+i.charAt(0).toUpperCase()+i.slice(1);R[e]=b(i);});ee.forEach(i=>{let e="math"+i.charAt(0).toUpperCase()+i.slice(1);R[e]=b(i);});R.varElement=b("var");var {html:te,head:re,body:ne,title:se,base:oe,link:ie,meta:ae,style:le,address:ue,article:ce,aside:de,footer:pe,header:me,h1:he,h2:ge,h3:fe,h4:ye,h5:Se,h6:ve,main:Re,nav:be,section:Te,blockquote:Ce,dd:Me,div:Ne,dl:Ee,dt:Le,figcaption:xe,figure:we,hr:Ve,li:$e,ol:ke,p:Fe,pre:Ae,ul:He,a:Oe,abbr:Pe,b:je,bdi:Je,bdo:De,br:We,cite:Ke,code:qe,data:Ie,dfn:Ge,em:Ue,i:Be,kbd:_e,mark:ze,q:Ze,rp:Qe,rt:Xe,ruby:Ye,s:et,samp:tt,small:rt,span:nt,strong:st,sub:ot,sup:it,time:at,u:lt,wbr:ut,area:ct,audio:dt,img:pt,map:mt,track:ht,video:gt,embed:ft,iframe:yt,object:St,param:vt,picture:Rt,portal:bt,source:Tt,canvas:Ct,noscript:Mt,script:Nt,del:Et,ins:Lt,caption:xt,col:wt,colgroup:Vt,table:$t,tbody:kt,td:Ft,tfoot:At,th:Ht,thead:Ot,tr:Pt,button:jt,datalist:Jt,fieldset:Dt,form:Wt,input:Kt,label:qt,legend:It,meter:Gt,optgroup:Ut,option:Bt,output:_t,progress:zt,select:Zt,textarea:Qt,details:Xt,dialog:Yt,menu:er,summary:tr,slot:rr,template:nr,svgSvg:sr,svgCircle:or,svgRect:ir,svgPath:ar,svgLine:lr,svgPolyline:ur,svgPolygon:cr,svgEllipse:dr,svgG:pr,svgText:mr,svgTspan:hr,svgDefs:gr,svgLinearGradient:fr,svgRadialGradient:yr,svgStop:Sr,svgPattern:vr,svgMask:Rr,svgClipPath:br,svgUse:Tr,svgSymbol:Cr,svgMarker:Mr,svgImage:Nr,svgForeignObject:Er,svgAnimate:Lr,svgAnimateTransform:xr,svgAnimateMotion:wr,svgSet:Vr,svgFilter:$r,svgFeBlend:kr,svgFeColorMatrix:Fr,svgFeComponentTransfer:Ar,svgFeComposite:Hr,svgFeConvolveMatrix:Or,svgFeDiffuseLighting:Pr,svgFeDisplacementMap:jr,svgFeFlood:Jr,svgFeGaussianBlur:Dr,svgFeMorphology:Wr,svgFeOffset:Kr,svgFeSpecularLighting:qr,svgFeTile:Ir,svgFeTurbulence:Gr,mathMath:Ur,mathMi:Br,mathMn:_r,mathMo:zr,mathMs:Zr,mathMtext:Qr,mathMrow:Xr,mathMfrac:Yr,mathMsqrt:en,mathMroot:tn,mathMsub:rn,mathMsup:nn,varElement:sn}=R;var _={};Q(_,{commentNode:()=>mn,createEl:()=>ln,createMathEl:()=>cn,createSvgEl:()=>un,doc:()=>S,el:()=>on,elClass:()=>gn,elId:()=>hn,elName:()=>yn,elTag:()=>fn,els:()=>an,fragment:()=>dn,textNode:()=>pn});var S=document,on=S.querySelector.bind(S),an=S.querySelectorAll.bind(S),ln=S.createElement.bind(S),un=S.createElementNS.bind(S,"http://www.w3.org/2000/svg"),cn=S.createElementNS.bind(S,"http://www.w3.org/1998/Math/MathML"),dn=S.createDocumentFragment.bind(S),pn=S.createTextNode.bind(S),mn=S.createComment.bind(S),hn=S.getElementById.bind(S),gn=S.getElementsByClassName.bind(S),fn=S.getElementsByTagName.bind(S),yn=S.getElementsByName.bind(S);var Sn=(...i)=>f.renderToHead(...i),vn=i=>f.addStyle(i),Rn=i=>f.addMeta(i),bn=i=>f.addLink(i),Tn=i=>f.setTitle(i),Cn=(i,e)=>f.renderToString(i,e),Mn=i=>f.jsonToVNode(i),Nn=(i,e)=>f.renderJson(i,e),En=(i,e)=>f.renderJsonToString(i,e),Ln=i=>f.vNodeJsonToVNode(i),xn=(i,e)=>f.renderVNode(i,e),wn=(i,e)=>f.renderVNodeToString(i,e);typeof window<"u"&&Object.assign(window,{domNode:f,createElementFactory:b,renderToHead:Sn,addStyle:vn,addMeta:Rn,addLink:bn,setTitle:Tn,createState:C,computed:x,effect:w,createSharedState:j,sharedStateManager:J,reactive:L,reactiveAs:D,text:W,bindValue:K,bindChecked:q,batchRender:V,renderChunked:$,createVirtualList:k,lazy:F,cleanupUnused:A,renderToString:Cn,jsonToVNode:Mn,renderJson:Nn,renderJsonToString:En,vNodeJsonToVNode:Ln,renderVNode:xn,renderVNodeToString:wn,throttle:H,debounce:O,CreateStyle:N,createRouter:G,createRouterView:U,routerLink:B,...R,..._});
35
- export{N as CreateStyle,E as DomNode,M as SharedState,Oe as a,Pe as abbr,bn as addLink,Rn as addMeta,vn as addStyle,ue as address,ct as area,ce as article,de as aside,dt as audio,je as b,oe as base,V as batchRender,Je as bdi,De as bdo,q as bindChecked,K as bindValue,Ce as blockquote,ne as body,We as br,jt as button,Ct as canvas,xt as caption,Ke as cite,A as cleanupUnused,qe as code,wt as col,Vt as colgroup,mn as commentNode,x as computed,ln as createEl,b as createElementFactory,cn as createMathEl,G as createRouter,U as createRouterView,j as createSharedState,C as createState,un as createSvgEl,k as createVirtualList,Ie as data,Jt as datalist,Me as dd,O as debounce,Et as del,Xt as details,Ge as dfn,Yt as dialog,Ne as div,Ee as dl,S as doc,f as domNode,Le as dt,w as effect,on as el,gn as elClass,hn as elId,yn as elName,fn as elTag,R as elements,an as els,Ue as em,ft as embed,Dt as fieldset,xe as figcaption,we as figure,pe as footer,Wt as form,dn as fragment,he as h1,ge as h2,fe as h3,ye as h4,Se as h5,ve as h6,re as head,me as header,Ve as hr,te as html,Be as i,yt as iframe,pt as img,Kt as input,Lt as ins,Mn as jsonToVNode,_e as kbd,qt as label,F as lazy,It as legend,$e as li,ie as link,Re as main,mt as map,ze as mark,Ur as mathMath,Yr as mathMfrac,Br as mathMi,_r as mathMn,zr as mathMo,tn as mathMroot,Xr as mathMrow,Zr as mathMs,en as mathMsqrt,rn as mathMsub,nn as mathMsup,Qr as mathMtext,er as menu,ae as meta,Gt as meter,be as nav,Mt as noscript,St as object,ke as ol,Ut as optgroup,Bt as option,_t as output,Fe as p,vt as param,Rt as picture,bt as portal,Ae as pre,zt as progress,Ze as q,L as reactive,D as reactiveAs,$ as renderChunked,Nn as renderJson,En as renderJsonToString,Sn as renderToHead,Cn as renderToString,xn as renderVNode,wn as renderVNodeToString,B as routerLink,Qe as rp,Xe as rt,Ye as ruby,et as s,tt as samp,Nt as script,Te as section,Zt as select,Tn as setTitle,J as sharedStateManager,rr as slot,rt as small,Tt as source,nt as span,st as strong,le as style,ot as sub,tr as summary,it as sup,Lr as svgAnimate,wr as svgAnimateMotion,xr as svgAnimateTransform,or as svgCircle,br as svgClipPath,gr as svgDefs,dr as svgEllipse,kr as svgFeBlend,Fr as svgFeColorMatrix,Ar as svgFeComponentTransfer,Hr as svgFeComposite,Or as svgFeConvolveMatrix,Pr as svgFeDiffuseLighting,jr as svgFeDisplacementMap,Jr as svgFeFlood,Dr as svgFeGaussianBlur,Wr as svgFeMorphology,Kr as svgFeOffset,qr as svgFeSpecularLighting,Ir as svgFeTile,Gr as svgFeTurbulence,$r as svgFilter,Er as svgForeignObject,pr as svgG,Nr as svgImage,lr as svgLine,fr as svgLinearGradient,Mr as svgMarker,Rr as svgMask,ar as svgPath,vr as svgPattern,cr as svgPolygon,ur as svgPolyline,yr as svgRadialGradient,ir as svgRect,Vr as svgSet,Sr as svgStop,sr as svgSvg,Cr as svgSymbol,mr as svgText,hr as svgTspan,Tr as svgUse,$t as table,kt as tbody,Ft as td,nr as template,W as text,pn as textNode,Qt as textarea,At as tfoot,Ht as th,Ot as thead,H as throttle,at as time,se as title,Pt as tr,ht as track,lt as u,He as ul,Ln as vNodeJsonToVNode,sn as varElement,gt as video,ut as wbr};
1
+ import{createServer as e,request as t}from"http";import{request as r}from"https";import{WebSocket as s,WebSocketServer as n}from"ws";import{watch as a}from"chokidar";import{realpath as o,stat as i,readFile as l}from"fs/promises";import{normalize as c,resolve as d,join as u,sep as h,extname as p,relative as g,basename as m,dirname as f}from"path";import{lookup as y}from"mime-types";import{build as v}from"esbuild";import{mkdirSync as b,statSync as w,existsSync as $,readFileSync as S,writeFileSync as E,copyFileSync as T}from"fs";var C,N=(C=function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')},typeof require<"u"?require:typeof Proxy<"u"?new Proxy(C,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):C),M=class{constructor(){this.elementCache=new WeakMap,this.reactiveNodes=new Map}createElement(e,t={},r=[]){return{tagName:e,props:t,children:r}}renderToDOM(e,t){if(null==e||!1===e)return;if("object"!=typeof e)return void t.appendChild(document.createTextNode(String(e)));let{tagName:r,props:s,children:n}=e,a="svg"===r||"s"===r[0]&&"v"===r[1]&&"g"===r[2]||"http://www.w3.org/2000/svg"===t.namespaceURI,o=a?document.createElementNS("http://www.w3.org/2000/svg",r.replace("svg","").toLowerCase()||r):document.createElement(r);for(let e in s){let t=s[e];if(null==t||!1===t)continue;let r=e.charCodeAt(0);if(99===r&&(e.length<6||"N"===e[5])){let e=Array.isArray(t)?t.join(" "):t;a?o.setAttribute("class",e):o.className=e}else if(115===r&&5===e.length)if("string"==typeof t)o.style.cssText=t;else{let e=o.style;for(let r in t)e[r]=t[r]}else 111===r&&110===e.charCodeAt(1)?o[e.toLowerCase()]=t:100===r&&e.length>20?o.innerHTML=t.__html:114===r&&3===e.length?setTimeout(()=>{"function"==typeof t?t(o):t.current=o},0):o.setAttribute(e,!0===t?"":String(t))}let i=n.length;if(!i)return void t.appendChild(o);let l=e=>{for(let t=0;t<i;t++){let r=n[t];if(null!=r&&!1!==r)if(Array.isArray(r))for(let t=0,s=r.length;t<s;t++){let s=r[t];null!=s&&!1!==s&&this.renderToDOM(s,e)}else this.renderToDOM(r,e)}};if(i>30){let e=document.createDocumentFragment();l(e),o.appendChild(e)}else l(o);t.appendChild(o)}render(e,t){let r="string"==typeof e?document.getElementById(e.replace("#","")):e;if(!r)throw new Error(`Element not found: ${e}`);if(t.children&&t.children.length>500){let e=document.createDocumentFragment();this.renderToDOM(t,e),r.appendChild(e)}else this.renderToDOM(t,r);return r}batchRender(e,t){let r="string"==typeof e?document.getElementById(e.replace("#","")):e;if(!r)throw new Error(`Element not found: ${e}`);let s=t.length;if(s>3e3){let e=document.createDocumentFragment(),n=0,a=1500,o=()=>{let i=Math.min(n+a,s);for(let r=n;r<i;r++)this.renderToDOM(t[r],e);n=i,n>=s?r.appendChild(e):requestAnimationFrame(o)};o()}else{let e=document.createDocumentFragment();for(let r=0;r<s;r++)this.renderToDOM(t[r],e);r.appendChild(e)}return r}renderChunked(e,t,r=5e3,s){let n="string"==typeof e?document.getElementById(e.replace("#","")):e;if(!n)throw new Error(`Element not found: ${e}`);let a=t.length,o=0,i=()=>{let e=Math.min(o+r,a),l=document.createDocumentFragment();for(let r=o;r<e;r++)this.renderToDOM(t[r],l);n.appendChild(l),o=e,s&&s(o,a),o<a&&requestAnimationFrame(i)};return requestAnimationFrame(i),n}renderToHead(...e){let t=document.head;if(t)for(let r of e.flat())r&&this.renderToDOM(r,t);return t}addStyle(e){let t=document.createElement("style");return t.textContent=e,document.head.appendChild(t)}addMeta(e){let t=document.createElement("meta");for(let r in e)t.setAttribute(r,e[r]);return document.head.appendChild(t)}addLink(e){let t=document.createElement("link");for(let r in e)t.setAttribute(r,e[r]);return document.head.appendChild(t)}setTitle(e){return document.title=e}createState(e,t={}){let r=e,s=new Set,n=null,{throttle:a=0,deep:o=!1}=t,i=()=>s.forEach(e=>e(r));return{get value(){return r},set value(e){(o?JSON.stringify(r)!==JSON.stringify(e):r!==e)&&(r=e,a>0?n||(n=setTimeout(()=>{n=null,i()},a)):i())},subscribe:e=>(s.add(e),()=>s.delete(e)),destroy(){s.clear(),n&&clearTimeout(n)}}}computed(e,t){let r=e.map(e=>e.value),s=this.createState(t(...r));return e.forEach((e,n)=>{e.subscribe(e=>{r[n]=e,s.value=t(...r)})}),s}effect(e){e()}createVirtualList(e,t,r,s=50,n=5){let a=e.clientHeight,o=t.length*s,i=0,l=()=>{let{start:l,end:c}={start:Math.max(0,Math.floor(i/s)-n),end:Math.min(t.length,Math.ceil((i+a)/s)+n)},d=document.createElement("div");d.style.cssText=`height:${o}px;position:relative`;for(let e=l;e<c;e++){let n=document.createElement("div");n.style.cssText=`position:absolute;top:${e*s}px;height:${s}px;width:100%`,this.renderToDOM(r(t[e],e),n),d.appendChild(n)}e.innerHTML="",e.appendChild(d)},c=()=>{i=e.scrollTop,requestAnimationFrame(l)};return e.addEventListener("scroll",c),l(),{render:l,destroy:()=>{e.removeEventListener("scroll",c),e.innerHTML=""}}}lazy(e){let t=null,r=!1;return async(...s)=>(!t&&!r&&(r=!0,t=await e(),r=!1),t?t(...s):{tagName:"div",props:{class:"loading"},children:["Loading..."]})}cleanupUnusedElements(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),r=[];for(;t.nextNode();){let e=t.currentNode;e.id&&e.id.startsWith("r")&&!this.elementCache.has(e)&&r.push(e)}return r.forEach(e=>e.remove()),r.length}renderToString(e,t={}){let{pretty:r=!1,indent:s=0}=t,n=r?" ".repeat(s):"",a=r?"\n":"",o=this.resolveStateValue(e);if(o=this.unwrapReactive(o),Array.isArray(o))return o.map(e=>this.renderToString(e,t)).join("");if("object"!=typeof o||null===o)return null==o||!1===o?"":this.escapeHtml(String(o));let{tagName:i,props:l,children:c}=o,d=this.isSelfClosingTag(i),u=`${n}<${i}`,h=this.propsToAttributes(l);if(h&&(u+=` ${h}`),d)return u+=` />${a}`,u;if(u+=">",l.dangerouslySetInnerHTML)return u+=l.dangerouslySetInnerHTML.__html,u+=`</${i}>${a}`,u;if(c&&c.length>0){let e=c.map(e=>{let t=this.resolveStateValue(e);return this.unwrapReactive(t)}),t=e.some(e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"tagName"in e);if(r&&t){u+=a;for(let t of e)if(null!=t&&!1!==t)if(Array.isArray(t))for(let e of t)null!=e&&!1!==e&&(u+=this.renderToString(e,{pretty:r,indent:s+1}));else u+=this.renderToString(t,{pretty:r,indent:s+1});u+=n}else for(let t of e)if(null!=t&&!1!==t)if(Array.isArray(t))for(let e of t)null!=e&&!1!==e&&(u+=this.renderToString(e,{pretty:!1,indent:0}));else u+=this.renderToString(t,{pretty:!1,indent:0})}return u+=`</${i}>${a}`,u}resolveStateValue(e){return e&&"object"==typeof e&&"value"in e&&"subscribe"in e?e.value:e}isReactiveWrapper(e){return!(!e||"object"!=typeof e||!e.tagName)&&("span"===e.tagName&&e.props?.id&&"string"==typeof e.props.id&&e.props.id.match(/^r[a-z0-9]{9}$/))}unwrapReactive(e){if(!this.isReactiveWrapper(e))return e;let t=e.children;if(!t||0===t.length)return"";if(1===t.length){let e=t[0];if(e&&"object"==typeof e&&"span"===e.tagName){let t=e.props,r=!t||0===Object.keys(t).length,s=e.children&&1===e.children.length&&"string"==typeof e.children[0];if(r&&s)return e.children[0]}return this.unwrapReactive(e)}return t.map(e=>this.unwrapReactive(e))}escapeHtml(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"};return e.replace(/[&<>"']/g,e=>t[e])}isSelfClosingTag(e){return new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]).has(e.toLowerCase())}propsToAttributes(e){let t=[];for(let r in e){if("children"===r||"dangerouslySetInnerHTML"===r||"ref"===r)continue;let s=e[r];if(s=this.resolveStateValue(s),null!=s&&!1!==s&&(!r.startsWith("on")||"function"!=typeof s)){if("className"===r||"class"===r){let e=Array.isArray(s)?s.join(" "):s;e&&t.push(`class="${this.escapeHtml(String(e))}"`);continue}if("style"===r){let e=this.styleToString(s);e&&t.push(`style="${this.escapeHtml(e)}"`);continue}if(!0===s){t.push(r);continue}t.push(`${r}="${this.escapeHtml(String(s))}"`)}}return t.join(" ")}styleToString(e){if("string"==typeof e)return e;if("object"==typeof e&&null!==e){let t=[];for(let r in e){let s=r.replace(/([A-Z])/g,"-$1").toLowerCase();t.push(`${s}:${e[r]}`)}return t.join(";")}return""}isState(e){return e&&"object"==typeof e&&"value"in e&&"subscribe"in e&&"function"==typeof e.subscribe}createReactiveChild(e,t){let r=t(e.value);if(typeof window<"u"&&typeof document<"u"){let r={node:null,renderFn:t};this.reactiveNodes.set(e,r),e.subscribe(()=>{if(r.node&&r.node.parentNode){let s=t(e.value);r.node.textContent=String(s??"")}})}return r}jsonToVNode(e){if(this.isState(e))return this.createReactiveChild(e,e=>e);if(null==e||"boolean"==typeof e||"string"==typeof e||"number"==typeof e)return e;let{tag:t,attributes:r={},children:s}=e,n={};for(let e in r){let t=r[e];"class"===e?n.className=this.isState(t)?t.value:t:n[e]=this.isState(t)?t.value:t}let a=[];if(null!=s)if(Array.isArray(s))for(let e of s)if(this.isState(e))a.push(this.createReactiveChild(e,e=>e));else{let t=this.jsonToVNode(e);null!=t&&!1!==t&&a.push(t)}else if(this.isState(s))a.push(this.createReactiveChild(s,e=>e));else if("object"==typeof s&&"tag"in s){let e=this.jsonToVNode(s);null!=e&&!1!==e&&a.push(e)}else a.push(s);return{tagName:t,props:n,children:a}}vNodeJsonToVNode(e){if(this.isState(e))return this.createReactiveChild(e,e=>e);if(null==e||"boolean"==typeof e||"string"==typeof e||"number"==typeof e)return e;let{tagName:t,props:r={},children:s=[]}=e,n={};for(let e in r){let t=r[e];n[e]=this.isState(t)?t.value:t}let a=[];for(let e of s)if(this.isState(e))a.push(this.createReactiveChild(e,e=>e));else{let t=this.vNodeJsonToVNode(e);null!=t&&!1!==t&&a.push(t)}return{tagName:t,props:n,children:a}}renderJson(e,t){let r=this.jsonToVNode(t);if(!r||"object"!=typeof r||!("tagName"in r))throw new Error("Invalid JSON structure");return this.render(e,r)}renderVNode(e,t){let r=this.vNodeJsonToVNode(t);if(!r||"object"!=typeof r||!("tagName"in r))throw new Error("Invalid VNode JSON structure");return this.render(e,r)}renderJsonToString(e,t={}){let r=this.jsonToVNode(e);return this.renderToString(r,t)}renderVNodeToString(e,t={}){let r=this.vNodeJsonToVNode(e);return this.renderToString(r,t)}renderServer(e){if("object"!=typeof e||null===e||!("tagName"in e))throw new Error("renderServer requires a VNode with html tag");if("html"!==e.tagName)throw new Error("renderServer requires a VNode with html tag as root");let t=e,r=null,s=null;for(let e of t.children||[])"object"==typeof e&&null!==e&&"tagName"in e&&("head"===e.tagName&&(r=e),"body"===e.tagName&&(s=e));if(t.props)for(let e in t.props){let r=t.props[e];null!=r&&!1!==r&&document.documentElement.setAttribute(e,String(r))}if(r){document.head.innerHTML="";for(let e of r.children||[])this.renderToDOM(e,document.head)}if(s){if(document.body.innerHTML="",s.props)for(let e in s.props){let t=s.props[e];null!=t&&!1!==t&&document.body.setAttribute(e,String(t))}for(let e of s.children||[])this.renderToDOM(e,document.body)}}renderToHTMLDocument(e,t={}){let{title:r="",meta:s=[],links:n=[],scripts:a=[],styles:o=[],lang:i="en",head:l="",bodyAttrs:c={},pretty:d=!1}=t,u=d?"\n":"",h=d?" ":"",p=d?" ":"",g=`<!DOCTYPE html>${u}<html lang="${i}">${u}${h}<head>${u}${p}<meta charset="UTF-8">${u}${p}<meta name="viewport" content="width=device-width, initial-scale=1.0">${u}`;r&&(g+=`${p}<title>${this.escapeHtml(r)}</title>${u}`);for(let e of s){g+=`${p}<meta`;for(let t in e)g+=` ${t}="${this.escapeHtml(e[t])}"`;g+=`>${u}`}for(let e of n){g+=`${p}<link`;for(let t in e)g+=` ${t}="${this.escapeHtml(e[t])}"`;g+=`>${u}`}for(let e of o)e.href?g+=`${p}<link rel="stylesheet" href="${this.escapeHtml(e.href)}">${u}`:e.content&&(g+=`${p}<style>${e.content}</style>${u}`);l&&(g+=l+u),g+=`${h}</head>${u}${h}<body`;for(let e in c)g+=` ${e}="${this.escapeHtml(c[e])}"`;g+=`>${u}`,g+=this.renderToString(e,{pretty:d,indent:2});for(let e of a)g+=`${p}<script`,e.type&&(g+=` type="${this.escapeHtml(e.type)}"`),e.async&&(g+=" async"),e.defer&&(g+=" defer"),e.src?g+=` src="${this.escapeHtml(e.src)}"><\/script>${u}`:e.content?g+=`>${e.content}<\/script>${u}`:g+=`><\/script>${u}`;return g+=`${h}</body>${u}</html>`,g}getElementCache(){return this.elementCache}},x=new M,R=(e,t)=>x.createState(e,t),k=(e,t)=>x.computed(e,t),H=e=>x.effect(e),O=(e,t)=>x.batchRender(e,t),F=(e,t,r,s)=>x.renderChunked(e,t,r,s),j=(e,t,r,s,n)=>x.createVirtualList(e,t,r,s,n),A=e=>x.lazy(e),D=e=>x.cleanupUnusedElements(e),P=(e,t)=>{let r=null;return(...s)=>{r||(r=setTimeout(()=>{r=null,e(...s)},t))}},W=(e,t)=>{let r=null;return(...s)=>{r&&clearTimeout(r),r=setTimeout(()=>e(...s),t)}},L=class{constructor(e,t,r){this.key=e,this.wsUrl=r,this.ws=null,this.pendingUpdates=[],this.localState=R(t),this.previousValue=t,this.connect()}get value(){return this.localState.value}set value(e){this.previousValue=this.localState.value,this.localState.value=e,this.sendToServer(e)}get state(){return this.localState}onChange(e){return this.localState.subscribe(t=>{let r=this.previousValue;this.previousValue=t,e(t,r)})}update(e){this.value=e(this.value)}connect(){if(typeof window>"u")return;let e=this.wsUrl||`ws://${location.host}`;this.ws=new WebSocket(e),this.ws.addEventListener("open",()=>{for(this.subscribe();this.pendingUpdates.length>0;){let e=this.pendingUpdates.shift();this.sendToServer(e)}}),this.ws.addEventListener("message",e=>{this.handleMessage(e.data)}),this.ws.addEventListener("close",()=>{setTimeout(()=>this.connect(),1e3)}),this.ws.addEventListener("error",e=>{console.error("[SharedState] WebSocket error:",e)})}subscribe(){!this.ws||this.ws.readyState!==WebSocket.OPEN||this.ws.send(JSON.stringify({type:"state:subscribe",key:this.key}))}handleMessage(e){try{let t=JSON.parse(e);if(t.key!==this.key)return;("state:init"===t.type||"state:update"===t.type)&&(this.localState.value=t.value)}catch{}}sendToServer(e){if(this.ws){if(this.ws.readyState!==WebSocket.OPEN)return void this.pendingUpdates.push(e);this.ws.send(JSON.stringify({type:"state:change",key:this.key,value:e}))}}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}destroy(){this.disconnect(),this.localState.destroy()}};function q(e,t,r){return new L(e,t,r)}var B=new class{constructor(){this.states=new Map}create(e,t,r){if(this.states.has(e))return this.states.get(e);let s=new L(e,t,r);return this.states.set(e,s),s}get(e){return this.states.get(e)}delete(e){let t=this.states.get(e);return!!t&&(t.destroy(),this.states.delete(e))}clear(){this.states.forEach(e=>e.destroy()),this.states.clear()}},U=(e,t)=>{let r=null,s=null,n=null,a=!0,o=t(e.value),i=o&&"object"==typeof o&&"tagName"in o,l=null==o||!1===o;e.subscribe(()=>{r&&cancelAnimationFrame(r),r=requestAnimationFrame(()=>{(()=>{if(!s&&!n)return;let r=t(e.value);if(null==r||!1===r)a&&s&&(n=document.createComment("reactive"),s.parentNode?.replaceChild(n,s),a=!1);else if(!a&&n&&s&&(n.parentNode?.replaceChild(s,n),n=null,a=!0),s){let e=document.createDocumentFragment();if(i&&r&&"object"==typeof r&&"tagName"in r){let{props:t,children:n}=r;for(let e in t){let r=t[e];if("ref"!==e)if("class"===e||"className"===e)s.className=Array.isArray(r)?r.join(" "):r||"";else if("style"===e&&"object"==typeof r){let e=s.style;for(let t in r)e[t]=r[t]}else e.startsWith("on")?s[e.toLowerCase()]=r:null!=r&&!1!==r?s.setAttribute(e,String(!0===r?"":r)):s.removeAttribute(e)}for(let t of n)x.renderToDOM(t,e)}else x.renderToDOM(r,e);s.textContent="",s.appendChild(e),x.getElementCache().set(s,!0)}})(),r=null})});let c=e=>{s=e,l&&e.parentNode&&(n=document.createComment("reactive"),e.parentNode.replaceChild(n,e),a=!1)};if(i){let e=o;return{tagName:e.tagName,props:{...e.props,ref:c},children:e.children}}return{tagName:"span",props:{ref:c},children:[o]}},I=(e,t,r,s={})=>{let n=null,a=null;return t.subscribe(()=>{n&&cancelAnimationFrame(n),n=requestAnimationFrame(()=>{if(a){let e=document.createDocumentFragment(),s=r(t.value);null==s||!1===s?(a.style.display="none",a.textContent=""):(a.style.display="",x.renderToDOM(s,e),a.textContent="",a.appendChild(e)),x.getElementCache().set(a,!0)}n=null})}),{tagName:e,props:{...s,ref:e=>{a=e}},children:[r(t.value)]}},J=e=>e&&void 0!==e.value?U(e,e=>({tagName:"span",props:{},children:[String(e)]})):String(e),V=e=>({value:e.value,oninput:t=>{e.value=t.target.value}}),_=e=>({checked:e.value,onchange:t=>{e.value=t.target.checked}}),G=class{constructor(){this.variables=[],this.rules=[],this.mediaRules=[],this.keyframes=[],this.fontFaces=[],this.imports=[],this.containerRules=[],this.supportsRules=[],this.layerRules=[],this._layerOrder=[]}addVar(e,t){let r={name:e.startsWith("--")?e:`--${e}`,value:t,toString(){return`var(${this.name})`}};return this.variables.push(r),r}var(e,t){let r="string"==typeof e?e.startsWith("--")?e:`--${e}`:e.name;return t?`var(${r}, ${t})`:`var(${r})`}addTag(e,t){let r={selector:e,styles:t,type:"tag"};return this.rules.push(r),r}addClass(e,t){let r={selector:e.startsWith(".")?e:`.${e}`,styles:t,type:"class"};return this.rules.push(r),r}addId(e,t){let r={selector:e.startsWith("#")?e:`#${e}`,styles:t,type:"id"};return this.rules.push(r),r}addPseudoClass(e,t,r){let s=e.startsWith(":")?e:`:${e}`,n={selector:r?`${r}${s}`:s,styles:t,type:"pseudo-class"};return this.rules.push(n),n}addPseudoElement(e,t,r){let s=e.startsWith("::")?e:`::${e}`,n={selector:r?`${r}${s}`:s,styles:t,type:"pseudo-element"};return this.rules.push(n),n}addAttribute(e,t,r){let s=e.startsWith("[")?e:`[${e}]`,n={selector:r?`${r}${s}`:s,styles:t,type:"attribute"};return this.rules.push(n),n}attrEquals(e,t,r,s){return this.addAttribute(`${e}="${t}"`,r,s)}attrContainsWord(e,t,r,s){return this.addAttribute(`${e}~="${t}"`,r,s)}attrStartsWith(e,t,r,s){return this.addAttribute(`${e}^="${t}"`,r,s)}attrEndsWith(e,t,r,s){return this.addAttribute(`${e}$="${t}"`,r,s)}attrContains(e,t,r,s){return this.addAttribute(`${e}*="${t}"`,r,s)}descendant(e,t,r){let s={selector:`${e} ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}child(e,t,r){let s={selector:`${e} > ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}adjacentSibling(e,t,r){let s={selector:`${e} + ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}generalSibling(e,t,r){let s={selector:`${e} ~ ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}multiple(e,t){let r={selector:e.join(", "),styles:t,type:"custom"};return this.rules.push(r),r}addName(e,t){return{selector:e.startsWith("--")?`&${e}`:`&--${e}`,styles:t,type:"name"}}nesting(e,...t){return e.nested=t,e}keyframe(e,t){let r={name:e,steps:Object.entries(t).map(([e,t])=>({step:"from"===e?"from":"to"===e?"to":`${e}%`,styles:t}))};return this.keyframes.push(r),r}keyframeFromTo(e,t,r){return this.keyframe(e,{from:t,to:r})}fontFace(e){return this.fontFaces.push(e),e}import(e,t){let r=t?`@import url("${e}") ${t};`:`@import url("${e}");`;return this.imports.push(r),r}media(e,t,r){let s={type:e,condition:t,rules:Object.entries(r).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.mediaRules.push(s),s}mediaScreen(e,t){return this.media("screen",e,t)}mediaPrint(e){return this.media("print","",e)}mediaMinWidth(e,t){return this.media("screen",`min-width: ${e}`,t)}mediaMaxWidth(e,t){return this.media("screen",`max-width: ${e}`,t)}mediaDark(e){let t={type:"",condition:"prefers-color-scheme: dark",rules:Object.entries(e).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.mediaRules.push(t),t}mediaLight(e){let t={type:"",condition:"prefers-color-scheme: light",rules:Object.entries(e).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.mediaRules.push(t),t}mediaReducedMotion(e){let t={type:"",condition:"prefers-reduced-motion: reduce",rules:Object.entries(e).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.mediaRules.push(t),t}container(e,t,r){let s={name:r,condition:e,rules:Object.entries(t).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.containerRules.push(s),s}addContainer(e,t){let r={...t,containerName:e};return this.addClass(e,r)}supports(e,t){let r={condition:e,rules:Object.entries(t).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.supportsRules.push(r),r}layerOrder(...e){this._layerOrder=e}layer(e,t){let r={name:e,rules:Object.entries(t).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.layerRules.push(r),r}add(e){return Object.entries(e).map(([e,t])=>{let r={selector:e,styles:t,type:"custom"};return this.rules.push(r),r})}important(e){return`${e} !important`}toKebabCase(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}stylesToString(e,t=" "){return Object.entries(e).map(([e,r])=>{let s="object"==typeof r&&null!==r&&"name"in r?`var(${r.name})`:r;return`${t}${this.toKebabCase(e)}: ${s};`}).join("\n")}renderRule(e,t=""){let r=`${t}${e.selector} {\n${this.stylesToString(e.styles,t+" ")}\n`;if(e.nested&&e.nested.length>0)for(let s of e.nested){r+=`\n${t}${s.selector.startsWith("&")?s.selector.replace(/&/g,e.selector):`${e.selector} ${s.selector}`} {\n${this.stylesToString(s.styles,t+" ")}\n${t}}\n`}return r+=`${t}}`,r}renderMediaRule(e){let t=`@media ${e.type&&e.condition?`${e.type} and (${e.condition})`:e.type?e.type:`(${e.condition})`} {\n`;for(let r of e.rules)t+=this.renderRule(r," ")+"\n";return t+="}",t}renderKeyframes(e){let t=`@keyframes ${e.name} {\n`;for(let r of e.steps)t+=` ${r.step} {\n${this.stylesToString(r.styles," ")}\n }\n`;return t+="}",t}renderFontFace(e){let t="@font-face {\n";return t+=` font-family: "${e.fontFamily}";\n`,t+=` src: ${e.src};\n`,e.fontWeight&&(t+=` font-weight: ${e.fontWeight};\n`),e.fontStyle&&(t+=` font-style: ${e.fontStyle};\n`),e.fontDisplay&&(t+=` font-display: ${e.fontDisplay};\n`),e.unicodeRange&&(t+=` unicode-range: ${e.unicodeRange};\n`),t+="}",t}renderContainerRule(e){let t=`@container ${e.name?`${e.name} `:""}(${e.condition}) {\n`;for(let r of e.rules)t+=this.renderRule(r," ")+"\n";return t+="}",t}renderSupportsRule(e){let t=`@supports (${e.condition}) {\n`;for(let r of e.rules)t+=this.renderRule(r," ")+"\n";return t+="}",t}renderLayerRule(e){let t=`@layer ${e.name} {\n`;for(let r of e.rules)t+=this.renderRule(r," ")+"\n";return t+="}",t}render(...e){let t=[];if(this.imports.length>0&&t.push(this.imports.join("\n")),this._layerOrder.length>0&&t.push(`@layer ${this._layerOrder.join(", ")};`),this.variables.length>0){let e=this.variables.map(e=>` ${e.name}: ${e.value};`).join("\n");t.push(`:root {\n${e}\n}`)}for(let e of this.fontFaces)t.push(this.renderFontFace(e));for(let e of this.keyframes)t.push(this.renderKeyframes(e));let r=[...this.rules],s=[...this.mediaRules],n=[],a=[...this.containerRules],o=[...this.supportsRules],i=[...this.layerRules];for(let t of e)t&&(Array.isArray(t)?r.push(...t):!("condition"in t)||!("rules"in t)||"name"in t&&"steps"in t?"name"in t&&"steps"in t?n.push(t):"name"in t&&"rules"in t?i.push(t):r.push(t):"type"in t?s.push(t):"name"in t&&"string"==typeof t.name?a.push(t):o.push(t));for(let e of n)t.push(this.renderKeyframes(e));for(let e of i)t.push(this.renderLayerRule(e));for(let e of r)t.push(this.renderRule(e));for(let e of o)t.push(this.renderSupportsRule(e));for(let e of a)t.push(this.renderContainerRule(e));for(let e of s)t.push(this.renderMediaRule(e));return t.join("\n\n")}inject(e){let t=this.render(),r=document.createElement("style");return e&&(r.id=e),r.textContent=t,document.head.appendChild(r),r}clear(){this.variables=[],this.rules=[],this.mediaRules=[],this.keyframes=[],this.fontFaces=[],this.imports=[],this.containerRules=[],this.supportsRules=[],this.layerRules=[],this._layerOrder=[]}},z=e=>function(t,...r){if(!arguments.length)return{tagName:e,props:{},children:[]};let s=t&&"object"==typeof t&&"value"in t&&"subscribe"in t,n=t&&"object"==typeof t&&"tagName"in t,a="object"!=typeof t||Array.isArray(t)||null===t||s||n,o=a?{}:t,i=a?[t,...r]:r;if(!i.length)return{tagName:e,props:o,children:[]};let l=[];for(let e=0,t=i.length;e<t;e++){let t=i[e];if(null!=t&&!1!==t)if(Array.isArray(t))for(let e=0,r=t.length;e<r;e++){let r=t[e];null!=r&&!1!==r&&l.push(r)}else l.push(t)}return{tagName:e,props:o,children:l}},K={};["html","head","body","title","base","link","meta","style","address","article","aside","footer","header","h1","h2","h3","h4","h5","h6","main","nav","section","blockquote","dd","div","dl","dt","figcaption","figure","hr","li","ol","p","pre","ul","a","abbr","b","bdi","bdo","br","cite","code","data","dfn","em","i","kbd","mark","q","rp","rt","ruby","s","samp","small","span","strong","sub","sup","time","u","wbr","area","audio","img","map","track","video","embed","iframe","object","param","picture","portal","source","canvas","noscript","script","del","ins","caption","col","colgroup","table","tbody","td","tfoot","th","thead","tr","button","datalist","fieldset","form","input","label","legend","meter","optgroup","option","output","progress","select","textarea","details","dialog","menu","summary","slot","template"].forEach(e=>{K[e]=z(e)}),["svg","circle","rect","path","line","polyline","polygon","ellipse","g","text","tspan","defs","linearGradient","radialGradient","stop","pattern","mask","clipPath","use","symbol","marker","image","foreignObject","animate","animateTransform","animateMotion","set","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence"].forEach(e=>{let t="svg"+e.charAt(0).toUpperCase()+e.slice(1);K[t]=z(e)}),["math","mi","mn","mo","ms","mtext","mrow","mfrac","msqrt","mroot","msub","msup"].forEach(e=>{let t="math"+e.charAt(0).toUpperCase()+e.slice(1);K[t]=z(e)}),K.varElement=z("var");var{head:X,body:Z,title:Y,base:Q,link:ee,meta:te,style:re,address:se,article:ne,aside:ae,footer:oe,header:ie,h1:le,h2:ce,h3:de,h4:ue,h5:he,h6:pe,main:ge,nav:me,section:fe,blockquote:ye,dd:ve,div:be,dl:we,dt:$e,figcaption:Se,figure:Ee,hr:Te,li:Ce,ol:Ne,p:Me,pre:xe,ul:Re,a:ke,abbr:He,b:Oe,bdi:Fe,bdo:je,br:Ae,cite:De,code:Pe,data:We,dfn:Le,em:qe,i:Be,kbd:Ue,mark:Ie,q:Je,rp:Ve,rt:_e,ruby:Ge,s:ze,samp:Ke,small:Xe,span:Ze,strong:Ye,sub:Qe,sup:et,time:tt,u:rt,wbr:st,area:nt,audio:at,img:ot,map:it,track:lt,video:ct,embed:dt,iframe:ut,object:ht,param:pt,picture:gt,portal:mt,source:ft,canvas:yt,noscript:vt,script:bt,del:wt,ins:$t,caption:St,col:Et,colgroup:Tt,table:Ct,tbody:Nt,td:Mt,tfoot:xt,th:Rt,thead:kt,tr:Ht,button:Ot,datalist:Ft,fieldset:jt,form:At,input:Dt,label:Pt,legend:Wt,meter:Lt,optgroup:qt,option:Bt,output:Ut,progress:It,select:Jt,textarea:Vt,details:_t,dialog:Gt,menu:zt,summary:Kt,slot:Xt,template:Zt,svgSvg:Yt,svgCircle:Qt,svgRect:er,svgPath:tr,svgLine:rr,svgPolyline:sr,svgPolygon:nr,svgEllipse:ar,svgG:or,svgText:ir,svgTspan:lr,svgDefs:cr,svgLinearGradient:dr,svgRadialGradient:ur,svgStop:hr,svgPattern:pr,svgMask:gr,svgClipPath:mr,svgUse:fr,svgSymbol:yr,svgMarker:vr,svgImage:br,svgForeignObject:wr,svgAnimate:$r,svgAnimateTransform:Sr,svgAnimateMotion:Er,svgSet:Tr,svgFilter:Cr,svgFeBlend:Nr,svgFeColorMatrix:Mr,svgFeComponentTransfer:xr,svgFeComposite:Rr,svgFeConvolveMatrix:kr,svgFeDiffuseLighting:Hr,svgFeDisplacementMap:Or,svgFeFlood:Fr,svgFeGaussianBlur:jr,svgFeMorphology:Ar,svgFeOffset:Dr,svgFeSpecularLighting:Pr,svgFeTile:Wr,svgFeTurbulence:Lr,mathMath:qr,mathMi:Br,mathMn:Ur,mathMo:Ir,mathMs:Jr,mathMtext:Vr,mathMrow:_r,mathMfrac:Gr,mathMsqrt:zr,mathMroot:Kr,mathMsub:Xr,mathMsup:Zr,varElement:Yr}=K,Qr=K,es=document,ts=es.querySelector.bind(es),rs=es.querySelectorAll.bind(es),ss=es.createElement.bind(es),ns=es.createElementNS.bind(es,"http://www.w3.org/2000/svg"),as=es.createElementNS.bind(es,"http://www.w3.org/1998/Math/MathML"),os=es.createDocumentFragment.bind(es),is=es.createTextNode.bind(es),ls=es.createComment.bind(es),cs=es.getElementById.bind(es),ds=es.getElementsByClassName.bind(es),us=es.getElementsByTagName.bind(es),hs=es.getElementsByName.bind(es);function ps(e,t){let r=e.split("/").filter(Boolean),s=t.split("/").filter(Boolean);if(e.endsWith("*")){let r=e.slice(0,-1);if(t.startsWith(r)||"/"===r||"*"===e)return{"*":t.slice(r.length)}}if(r.length!==s.length)return null;let n={};for(let e=0;e<r.length;e++){let t=r[e],a=s[e];if(t.startsWith(":"))n[t.slice(1)]=decodeURIComponent(a);else if(t!==a)return null}return n}function gs(e){let{mode:t="history",base:r="",routes:s}=e,n=[],a=e=>{let t={};return new URLSearchParams(e).forEach((e,r)=>{t[r]=e}),t},o=()=>"hash"===t?window.location.hash.slice(1)||"/":window.location.pathname.replace(r,"")||"/",i=e=>{let[t,r=""]=e.split("?"),[s,n=""]=t.split("#");return{path:s||"/",params:{},query:a(r),hash:n?"#"+n:""}},l=e=>{for(let t of s){let r=ps(t.path,e);if(null!==r)return{route:t,params:r}}return null},c=x.createState(i(o())),d=(e,s=!1)=>{let a=i(e),o=l(a.path);o&&(a.params=o.params);for(let e of n){let t=e(a,c.value);if(!1===t)return;if("string"==typeof t)return void d(t,s)}if(o?.route.beforeEnter){let e=o.route.beforeEnter(a,c.value);if(!1===e)return;if("string"==typeof e)return void d(e,s)}let u="hash"===t?"#"+e:r+e;s?window.history.replaceState({path:e},"",u):window.history.pushState({path:e},"",u),c.value=a},u=()=>{let e=o(),t=i(e),r=l(t.path);r&&(t.params=r.params),c.value=t};return typeof window<"u"&&window.addEventListener("popstate",u),{currentRoute:c,push:e=>d(e,!1),replace:e=>d(e,!0),back:()=>window.history.back(),forward:()=>window.history.forward(),go:e=>window.history.go(e),beforeEach:e=>{n.push(e)},destroy:()=>{typeof window<"u"&&window.removeEventListener("popstate",u),c.destroy()}}}function ms(e,t){let{routes:r,notFound:s}=t;return()=>{let t=e.currentRoute.value,n=r.find(e=>null!==ps(e.path,t.path));if(n){let e=ps(n.path,t.path)||{},r=n.component({...e,...t.query});return"object"==typeof r&&null!==r&&"tagName"in r?r:{tagName:"span",props:{},children:[r]}}if(s){let e=s(t.params);return"object"==typeof e&&null!==e&&"tagName"in e?e:{tagName:"span",props:{},children:[e]}}return{tagName:"div",props:{},children:["404 - Not Found"]}}}var fs=(e,t,...r)=>({tagName:"a",props:{...t,href:t.to,onclick:r=>{r.preventDefault(),e.push(t.to)}},children:r}),ys=class{constructor(){this.routes=[],this.middlewares=[]}use(e){return this.middlewares.push(e),this}get(e,t){return this.addRoute("GET",e,t)}post(e,t){return this.addRoute("POST",e,t)}put(e,t){return this.addRoute("PUT",e,t)}delete(e,t){return this.addRoute("DELETE",e,t)}patch(e,t){return this.addRoute("PATCH",e,t)}options(e,t){return this.addRoute("OPTIONS",e,t)}addRoute(e,t,r){let{pattern:s,paramNames:n}=this.pathToRegex(t);return this.routes.push({method:e,pattern:s,paramNames:n,handler:r}),this}pathToRegex(e){let t=[],r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\//g,"\\/").replace(/:(\w+)/g,(e,r)=>(t.push(r),"([^\\/]+)"));return{pattern:new RegExp(`^${r}$`),paramNames:t}}parseQuery(e){let t={},r=e.split("?")[1];return r&&new URLSearchParams(r).forEach((e,r)=>t[r]=e),t}async parseBody(e){return new Promise((t,r)=>{let s="";e.on("data",e=>s+=e.toString()),e.on("end",()=>{try{let r=e.headers["content-type"]||"";if(r.includes("application/json"))t(s?JSON.parse(s):{});else if(r.includes("application/x-www-form-urlencoded")){let e={};new URLSearchParams(s).forEach((t,r)=>e[r]=t),t(e)}else t(s)}catch(e){r(e)}}),e.on("error",r)})}async handle(e,t){let r=e.method,s=e.url||"/",n=s.split("?")[0];for(let a of this.routes){if(a.method!==r)continue;let o=n.match(a.pattern);if(!o)continue;let i={};a.paramNames.forEach((e,t)=>{i[e]=o[t+1]});let l=this.parseQuery(s),c={};if(["POST","PUT","PATCH"].includes(r))try{c=await this.parseBody(e)}catch{return t.writeHead(400,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:"Invalid request body"})),!0}let d={req:e,res:t,params:i,query:l,body:c,headers:e.headers},u=0,h=async()=>{if(u<this.middlewares.length){let e=this.middlewares[u++];await e(d,h)}};try{await h(),await a.handler(d)}catch(e){console.error("Route handler error:",e),t.headersSent||(t.writeHead(500,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:"Internal Server Error",message:e instanceof Error?e.message:"Unknown error"})))}return!0}return!1}},vs=(e,t,r=200)=>{e.writeHead(r,{"Content-Type":"application/json"}),e.end(JSON.stringify(t))},bs=(e,t,r=200)=>{e.writeHead(r,{"Content-Type":"text/plain"}),e.end(t)},ws=(e,t,r=200)=>{e.writeHead(r,{"Content-Type":"text/html"}),e.end(t)},$s=(e,t,r)=>{e.writeHead(t,{"Content-Type":"application/json"}),e.end(JSON.stringify({status:t,message:r||""}))};function Ss(e={}){let{origin:t="*",methods:r=["GET","POST","PUT","DELETE","PATCH","OPTIONS"],credentials:s=!0,maxAge:n=86400}=e;return async(e,a)=>{let o=e.req.headers.origin||"",i=Array.isArray(t)&&t.includes(o)?o:Array.isArray(t)?"":t;if(i&&e.res.setHeader("Access-Control-Allow-Origin",i),e.res.setHeader("Access-Control-Allow-Methods",r.join(", ")),e.res.setHeader("Access-Control-Allow-Headers","Content-Type, Authorization"),s&&e.res.setHeader("Access-Control-Allow-Credentials","true"),e.res.setHeader("Access-Control-Max-Age",String(n)),"OPTIONS"===e.req.method)return e.res.writeHead(204),void e.res.end();await a()}}function Es(e={}){let{format:t="simple"}=e;return async(e,r)=>{let s=Date.now(),{method:n,url:a}=e.req;await r();let o=Date.now()-s,i=e.res.statusCode;console.log("detailed"===t?`[${(new Date).toISOString()}] ${n} ${a} ${i} - ${o}ms`:`${n} ${a} - ${i} (${o}ms)`)}}function Ts(){return async(e,t)=>{try{await t()}catch(t){console.error("Error:",t),e.res.headersSent||(e.res.writeHead(500,{"Content-Type":"application/json"}),e.res.end(JSON.stringify({error:"Internal Server Error",message:t instanceof Error?t.message:"Unknown error"})))}}}function Cs(e={}){let{windowMs:t=6e4,max:r=100,message:s="Too many requests"}=e,n=new Map;return async(e,a)=>{let o=e.req.socket.remoteAddress||"unknown",i=Date.now(),l=n.get(o);if((!l||i>l.resetTime)&&(l={count:0,resetTime:i+t},n.set(o,l)),++l.count>r)return e.res.writeHead(429,{"Content-Type":"application/json"}),void e.res.end(JSON.stringify({error:s}));await a()}}function Ns(e={}){let{limit:t=1048576}=e;return async(e,r)=>{if(parseInt(e.req.headers["content-length"]||"0",10)>t)return e.res.writeHead(413,{"Content-Type":"application/json"}),void e.res.end(JSON.stringify({error:"Request body too large"}));await r()}}function Ms(e={}){let{maxAge:t=3600,public:r=!0}=e;return async(e,s)=>{e.res.setHeader("Cache-Control",`${r?"public":"private"}, max-age=${t}`),await s()}}function xs(){return async(e,t)=>{if(!(e.req.headers["accept-encoding"]||"").includes("gzip"))return void await t();let r=e.res.end.bind(e.res),s=[];e.res.write=e=>(s.push(Buffer.from(e)),!0),e.res.end=t=>{t&&s.push(Buffer.from(t));let n=Buffer.concat(s),{gzipSync:a}=N("zlib"),o=a(n);return e.res.setHeader("Content-Encoding","gzip"),e.res.setHeader("Content-Length",o.length),r(o),e.res},await t()}}function Rs(){return async(e,t)=>{e.res.setHeader("X-Content-Type-Options","nosniff"),e.res.setHeader("X-Frame-Options","DENY"),e.res.setHeader("X-XSS-Protection","1; mode=block"),e.res.setHeader("Strict-Transport-Security","max-age=31536000; includeSubDomains"),await t()}}function ks(e){return async(s,n)=>{let a=s.url||"/",o=a.split("?")[0],i=e.find(e=>o.startsWith(e.context));if(!i)return!1;let{target:l,changeOrigin:c,pathRewrite:d,headers:u}=i;try{let e=new URL(l),o="https:"===e.protocol,i=o?r:t,h=function(e,t){if(!t)return e;for(let[r,s]of Object.entries(t)){let t=new RegExp(r);if(t.test(e))return e.replace(t,s)}return e}(a,d),p={hostname:e.hostname,port:e.port||(o?443:80),path:h,method:s.method,headers:{...s.headers,...u||{}}};c&&(p.headers.host=e.host),delete p.headers.host;let g=i(p,e=>{n.writeHead(e.statusCode||200,e.headers),e.pipe(n)});return g.on("error",e=>{console.error("[Proxy] Error proxying %s to %s:",a,l,e.message),n.headersSent||(n.writeHead(502,{"Content-Type":"application/json"}),n.end(JSON.stringify({error:"Bad Gateway",message:"Proxy error"})))}),s.pipe(g),!0}catch(e){return console.error("[Proxy] Invalid proxy configuration for %s:",o,e),!1}}}var Hs=class{constructor(e,t){this.key=e,this.listeners=new Set,this.changeHandlers=new Set,this.options=t,this._value=t.initial}get value(){return this._value}set value(e){if(this.options.validate&&!this.options.validate(e))throw new Error(`Invalid state value for "${this.key}"`);let t=this._value;this._value=e,this.changeHandlers.forEach(r=>{r(e,t)}),this.broadcast()}update(e){this.value=e(this._value)}subscribe(e){this.listeners.add(e),this.sendTo(e)}unsubscribe(e){this.listeners.delete(e)}onChange(e){return this.changeHandlers.add(e),()=>this.changeHandlers.delete(e)}broadcast(){let e=JSON.stringify({type:"state:update",key:this.key,value:this._value,timestamp:Date.now()});this.listeners.forEach(t=>t.readyState===s.OPEN&&t.send(e))}sendTo(e){e.readyState===s.OPEN&&e.send(JSON.stringify({type:"state:init",key:this.key,value:this._value,timestamp:Date.now()}))}get subscriberCount(){return this.listeners.size}clear(){this.listeners.clear(),this.changeHandlers.clear()}},Os=class{constructor(){this.states=new Map}create(e,t){if(this.states.has(e))return this.states.get(e);let r=new Hs(e,t);return this.states.set(e,r),r}get(e){return this.states.get(e)}has(e){return this.states.has(e)}delete(e){let t=this.states.get(e);return!!t&&(t.clear(),this.states.delete(e))}subscribe(e,t){this.states.get(e)?.subscribe(t)}unsubscribe(e,t){this.states.get(e)?.unsubscribe(t)}unsubscribeAll(e){this.states.forEach(t=>t.unsubscribe(e))}handleStateChange(e,t){let r=this.states.get(e);r&&(r.value=t)}keys(){return Array.from(this.states.keys())}clear(){this.states.forEach(e=>e.clear()),this.states.clear()}},Fs={port:3e3,host:"localhost",https:!1,open:!0,watch:["**/*.ts","**/*.js","**/*.html","**/*.css"],ignore:["node_modules/**","dist/**",".git/**","**/*.d.ts"],logging:!0,middleware:[],worker:[]};function js(t){let r={...Fs,...t},m=new Set,f=new Os,b=r.clients?.length?r.clients:r.root?[{root:r.root,basePath:r.basePath||"",ssr:r.ssr,proxy:r.proxy}]:null;if(!b)throw new Error('DevServerOptions must include either "clients" array or "root" directory');let w=b.map(e=>{let t=e.basePath||"";if(t){for(;t.startsWith("/");)t=t.slice(1);for(;t.endsWith("/");)t=t.slice(0,-1);t=t?"/"+t:""}return{root:e.root,basePath:t,ssr:e.ssr,proxyHandler:e.proxy?ks(e.proxy):void 0}}),$=r.proxy?ks(r.proxy):null,S=e(async(e,t)=>{let s=e.url||"/",n=w.find(e=>e.basePath&&s.startsWith(e.basePath))||w.find(e=>!e.basePath);if(!n)return t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found");if(n.proxyHandler)try{if(await n.proxyHandler(e,t))return void(r.logging&&console.log(`[Proxy] ${e.method} ${s} -> proxied (client-specific)`))}catch(e){console.error("[Proxy] Error (client-specific):",e)}if($)try{if(await $(e,t))return void(r.logging&&console.log(`[Proxy] ${e.method} ${s} -> proxied (global)`))}catch(e){console.error("[Proxy] Error (global):",e)}let a=n.basePath?s.slice(n.basePath.length)||"/":s;if(r.api&&a.startsWith("/api")&&await r.api.handle(e,t))return;let l="/"===a?"/index.html":a;if(l=l.split("?")[0],r.logging&&"/src/pages"===l&&console.log("[DEBUG] Request for /src/pages received"),l.includes("\0"))return r.logging&&console.log(`[403] Rejected path with null byte: ${l}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");let p,g=l.startsWith("/dist/"),m=c(l).replace(/\\/g,"/").replace(/^\/+/,"");if(m.includes(".."))return r.logging&&console.log(`[403] Path traversal attempt: ${l}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");p=m;let f,y=await o(d(n.root)),v=g?await o(d(n.root,"..")):y;try{if(f=await o(d(u(v,p))),!f.startsWith(v.endsWith(h)?v:v+h))return r.logging&&console.log(`[403] File access outside of root: ${f}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");r.logging&&"/src/pages"===l&&console.log(`[DEBUG] Initial resolve succeeded: ${f}`)}catch{let e;if(r.logging&&!p.includes(".")&&console.log(`[DEBUG] File not found: ${p}, trying extensions...`),p.endsWith(".js")){let s=p.replace(/\.js$/,".ts");try{let n=await o(d(u(v,s)));if(!n.startsWith(v.endsWith(h)?v:v+h))return r.logging&&console.log(`[403] Fallback TS path outside of root: ${n}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");e=n}catch{}}if(!e&&!p.includes("."))try{e=await o(d(u(v,p+".ts"))),r.logging&&console.log(`[DEBUG] Found: ${p}.ts`)}catch{try{e=await o(d(u(v,p+".js"))),r.logging&&console.log(`[DEBUG] Found: ${p}.js`)}catch{try{e=await o(d(u(v,p,"index.ts"))),r.logging&&console.log(`[DEBUG] Found: ${p}/index.ts`)}catch{try{e=await o(d(u(v,p,"index.js"))),r.logging&&console.log(`[DEBUG] Found: ${p}/index.js`)}catch{r.logging&&console.log(`[DEBUG] Not found: all attempts failed for ${p}`)}}}}if(!e)return t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found");f=e}try{if((await i(f)).isDirectory()){let e;r.logging&&console.log(`[DEBUG] Path is directory: ${f}, trying index files...`);try{e=await o(d(u(f,"index.ts"))),r.logging&&console.log("[DEBUG] Found index.ts in directory")}catch{try{e=await o(d(u(f,"index.js"))),r.logging&&console.log("[DEBUG] Found index.js in directory")}catch{return r.logging&&console.log("[DEBUG] No index file found in directory"),t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found")}}f=e}}catch{return t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found")}let b=await o(d(n.root,"..")),S=f.startsWith(y+h)||f===y,T=g&&(f.startsWith(b+h)||f===b);if(!S&&!T)return r.logging&&console.log(`[403] Path outside allowed directories: ${l}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");try{if((await i(f)).isDirectory())try{let e=await o(d(u(f,"index.html")));return e.startsWith(y+h)||e===y?(await i(e),E(e,t,n)):(t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden"))}catch{return t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found")}await E(f,t,n)}catch{r.logging&&console.log(`[404] ${l}`),t.writeHead(404,{"Content-Type":"text/plain"}),t.end("404 Not Found")}});async function E(e,t,s){try{let n,a=await o(d(s.root)),i=await o(d(s.root,".."));try{n=await o(d(e))}catch{return e.endsWith("index.html")&&s.ssr?function(e,t){try{if(!t.ssr)return e.writeHead(500,{"Content-Type":"text/plain"}),void e.end("SSR function not configured");let s,n=t.ssr();if("string"==typeof n)s=n;else if("object"==typeof n&&null!==n&&"tagName"in n){let e=n;s="html"===e.tagName?x.renderToString(e):`<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"></head><body>${x.renderToString(e)}</body></html>`}else s=String(n);let a=`<script>(function(){const ws=new WebSocket('ws://${r.host}:${r.port}${t.basePath}');ws.onopen=()=>console.log('[Elit HMR] Connected');ws.onmessage=(e)=>{const d=JSON.parse(e.data);if(d.type==='update'){console.log('[Elit HMR] File updated:',d.path);window.location.reload()}else if(d.type==='reload'){console.log('[Elit HMR] Reloading...');window.location.reload()}else if(d.type==='error')console.error('[Elit HMR] Error:',d.error)};ws.onclose=()=>{console.log('[Elit HMR] Disconnected - Retrying...');setTimeout(()=>window.location.reload(),1000)};ws.onerror=(e)=>console.error('[Elit HMR] WebSocket error:',e)})();<\/script>`;s=s.includes("</body>")?s.replace("</body>",`${a}</body>`):s+a,e.writeHead(200,{"Content-Type":"text/html","Cache-Control":"no-cache, no-store, must-revalidate"}),e.end(s),r.logging&&console.log("[200] SSR rendered")}catch(t){e.writeHead(500,{"Content-Type":"text/plain"}),e.end("500 SSR Error"),r.logging&&console.error("[500] SSR Error:",t)}}(t,s):(t.writeHead(404,{"Content-Type":"text/plain"}),void t.end("404 Not Found"))}let c=n.startsWith(a+h)||n===a,u=n.startsWith(i+h+"dist"+h);if(!c&&!u)return r.logging&&console.log(`[403] Attempted to serve file outside allowed directories: ${e}`),t.writeHead(403,{"Content-Type":"text/plain"}),void t.end("403 Forbidden");let m=await l(n),f=p(n),b=y(n)||"application/octet-stream";if(".ts"===f||".tsx"===f)try{let e=await v({stdin:{contents:m.toString(),loader:".tsx"===f?"tsx":"ts",resolveDir:d(n,".."),sourcefile:n},format:"esm",target:"es2020",write:!1,bundle:!1,sourcemap:"inline"});m=Buffer.from(e.outputFiles[0].text),b="application/javascript"}catch(e){return t.writeHead(500,{"Content-Type":"text/plain"}),t.end(`TypeScript compilation error:\n${e}`),void(r.logging&&console.error("[500] TypeScript compilation error:",e))}if(".html"===f){let e=`<script type="importmap">\n{\n "imports": {\n "elit": "${s.basePath?`${s.basePath}/dist/client.mjs`:"/dist/client.mjs"}"\n }\n}\n<\/script>`,t=`<script>(function(){const ws=new WebSocket('ws://${r.host}:${r.port}${s.basePath}');ws.onopen=()=>console.log('[Elit HMR] Connected');ws.onmessage=(e)=>{const d=JSON.parse(e.data);if(d.type==='update'){console.log('[Elit HMR] File updated:',d.path);window.location.reload()}else if(d.type==='reload'){console.log('[Elit HMR] Reloading...');window.location.reload()}else if(d.type==='error')console.error('[Elit HMR] Error:',d.error)};ws.onclose=()=>{console.log('[Elit HMR] Disconnected - Retrying...');setTimeout(()=>window.location.reload(),1000)};ws.onerror=(e)=>console.error('[Elit HMR] WebSocket error:',e)})();<\/script>`,n=m.toString();if(s.basePath&&"/"!==s.basePath){let e=`<base href="${s.basePath}/">`;n.includes("<base")||(n.includes('<meta name="viewport"')?n=n.replace(/<meta name="viewport"[^>]*>/,t=>`${t}\n ${e}`):n.includes("<head>")&&(n=n.replace("<head>",`<head>\n ${e}`)))}n=n.includes("</head>")?n.replace("</head>",`${e}</head>`):n,n=n.includes("</body>")?n.replace("</body>",`${t}</body>`):n+t,m=Buffer.from(n)}let w={"Content-Type":b,"Cache-Control":".html"===f||".ts"===f||".tsx"===f?"no-cache, no-store, must-revalidate":"public, max-age=31536000, immutable"};if(/^(text\/|application\/(javascript|json|xml))/.test(b)&&m.length>1024){let{gzipSync:e}=N("zlib"),r=e(m);w["Content-Encoding"]="gzip",w["Content-Length"]=r.length,t.writeHead(200,w),t.end(r)}else t.writeHead(200,w),t.end(m);r.logging&&console.log(`[200] ${g(s.root,e)}`)}catch(e){t.writeHead(500,{"Content-Type":"text/plain"}),t.end("500 Internal Server Error"),r.logging&&console.error("[500] Error reading file:",e)}}let T=new n({server:S});T.on("connection",e=>{m.add(e);let t={type:"connected",timestamp:Date.now()};e.send(JSON.stringify(t)),r.logging&&console.log("[HMR] Client connected"),e.on("message",t=>{try{let s=JSON.parse(t.toString());"state:subscribe"===s.type?(f.subscribe(s.key,e),r.logging&&console.log(`[State] Client subscribed to "${s.key}"`)):"state:unsubscribe"===s.type?(f.unsubscribe(s.key,e),r.logging&&console.log(`[State] Client unsubscribed from "${s.key}"`)):"state:change"===s.type&&(f.handleStateChange(s.key,s.value),r.logging&&console.log(`[State] Client updated "${s.key}"`))}catch(e){r.logging&&console.error("[WebSocket] Message parse error:",e)}}),e.on("close",()=>{m.delete(e),f.unsubscribeAll(e),r.logging&&console.log("[HMR] Client disconnected")})});let C=w.flatMap(e=>r.watch.map(t=>u(e.root,t))),M=a(C,{ignored:r.ignore,ignoreInitial:!0,persistent:!0});M.on("change",e=>{r.logging&&console.log(`[HMR] File changed: ${e}`);let t=JSON.stringify({type:"update",path:e,timestamp:Date.now()});m.forEach(e=>e.readyState===s.OPEN&&e.send(t))}),M.on("add",e=>r.logging&&console.log(`[HMR] File added: ${e}`)),M.on("unlink",e=>r.logging&&console.log(`[HMR] File removed: ${e}`)),S.setMaxListeners(20),S.listen(r.port,r.host,()=>{if(r.logging){if(console.log("\nšŸš€ Elit Dev Server"),console.log(`\n āžœ Local: http://${r.host}:${r.port}`),w.length>1)console.log(" āžœ Clients:"),w.forEach(e=>{let t=`http://${r.host}:${r.port}${e.basePath}`;console.log(` - ${t} → ${e.root}`)});else{let e=w[0];console.log(` āžœ Root: ${e.root}`),e.basePath&&console.log(` āžœ Base: ${e.basePath}`)}console.log("\n[HMR] Watching for file changes...\n")}if(r.open&&w.length>0){let e=w[0],t=`http://${r.host}:${r.port}${e.basePath}`;(async()=>{let{default:e}=await import("open");await e(t)})().catch(()=>{})}});let R=!1,k=w[0],H=`http://${r.host}:${r.port}${k.basePath}`;return{server:S,wss:T,url:H,state:f,close:async()=>{if(!R)return R=!0,r.logging&&console.log("\n[Server] Shutting down..."),await M.close(),T.close(),m.forEach(e=>e.close()),m.clear(),new Promise(e=>{S.close(()=>{r.logging&&console.log("[Server] Closed"),e()})})}}}var As=new class{constructor(){this.enabled=!1,this.ws=null,this.acceptCallbacks=[],this.disposeCallbacks=[],this.declined=!1,typeof window>"u"||this.connect()}connect(){let e="https:"===window.location.protocol?"wss:":"ws:",t=window.location.hostname,r=window.location.port||"3000";this.ws=new WebSocket(`${e}//${t}:${r}`),this.ws.onopen=()=>{this.enabled=!0,console.log("[Elit HMR] Connected āœ“")},this.ws.onmessage=e=>{try{let t=JSON.parse(e.data);this.handleMessage(t)}catch(e){console.error("[Elit HMR] Error parsing message:",e)}},this.ws.onclose=()=>{this.enabled=!1,console.log("[Elit HMR] Disconnected - Attempting reconnect..."),setTimeout(()=>this.reload(),1e3)},this.ws.onerror=e=>{console.error("[Elit HMR] WebSocket error:",e)}}handleMessage(e){switch(e.type){case"connected":console.log("[Elit HMR] Ready");break;case"update":if(console.log(`[Elit HMR] Update detected: ${e.path}`),this.declined)return void this.reload();this.disposeCallbacks.forEach(e=>e()),this.disposeCallbacks=[],this.acceptCallbacks.length>0?this.acceptCallbacks.forEach(e=>e()):this.reload();break;case"reload":console.log("[Elit HMR] Full reload requested"),this.reload();break;case"error":console.error("[Elit HMR] Server error:",e.error)}}reload(){window.location.reload()}accept(e){e&&this.acceptCallbacks.push(e),this.declined=!1}decline(){this.declined=!0}dispose(e){this.disposeCallbacks.push(e)}};typeof window<"u"&&(window.__ELIT_HMR__=As);var Ds=As,Ps={outDir:"dist",minify:!0,sourcemap:!1,target:"es2020",format:"esm",treeshake:!0,logging:!0,external:[]};async function Ws(e){let t={...Ps,...e},r=Date.now();if(!t.entry)throw new Error("Entry file is required");let s=d(t.entry),n=d(t.outDir),a=t.outFile;if(!a){a=m(t.entry,p(t.entry))+("cjs"===t.format?".cjs":".js")}let o=u(n,a);try{b(n,{recursive:!0})}catch{}t.logging&&(console.log("\nšŸ”Ø Building..."),console.log(` Entry: ${t.entry}`),console.log(` Output: ${o}`),console.log(` Format: ${t.format}`),console.log(` Target: ${t.target}`));let i={name:"browser-only",setup(e){e.onResolve({filter:/^(node:.*|fs|path|http|https|url|os|child_process|net|tls|crypto|stream|util|events|buffer|zlib|readline|process|assert|constants|dns|domain|punycode|querystring|repl|string_decoder|sys|timers|tty|v8|vm)$/},()=>({path:"node-builtin",external:!0,sideEffects:!1})),e.onResolve({filter:/^(chokidar|esbuild|mime-types|open|ws|fs\/promises)$/},()=>({path:"server-dep",external:!0,sideEffects:!1})),e.onLoad({filter:/[\\/](server|config|cli)\.ts$/},()=>({contents:"export {}",loader:"js"}))}};try{let e=t.platform||("cjs"===t.format?"node":"browser"),a="browser"===e?[i]:[],l={};t.env&&(Object.entries(t.env).forEach(([e,t])=>{e.startsWith("VITE_")&&(l[`import.meta.env.${e}`]=JSON.stringify(t))}),t.env.MODE&&(l["import.meta.env.MODE"]=JSON.stringify(t.env.MODE)),l["import.meta.env.DEV"]=JSON.stringify("production"!==t.env.MODE),l["import.meta.env.PROD"]=JSON.stringify("production"===t.env.MODE));let c=await v({entryPoints:[s],bundle:!0,outfile:o,format:t.format,target:t.target,minify:t.minify,sourcemap:t.sourcemap,external:t.external,treeShaking:t.treeshake,globalName:t.globalName,platform:e,plugins:a,define:l,logLevel:t.logging?"info":"silent",metafile:!0,...t.minify&&{minifyWhitespace:!0,minifyIdentifiers:!0,minifySyntax:!0,legalComments:"none",mangleProps:/^_/,keepNames:!1}}),u=Date.now()-r,h=w(o).size;if(t.logging&&(console.log("\nāœ… Build successful!"),console.log(` Time: ${u}ms`),console.log(` Size: ${Ls(h)}`),c.metafile)){let e=Object.keys(c.metafile.inputs).length;console.log(` Files: ${e} input(s)`);let t=Object.keys(c.metafile.outputs);if(t.length>0){let e=c.metafile.outputs[t[0]];if(e&&e.inputs){let t=Object.entries(e.inputs).sort(([,e],[,t])=>t.bytesInOutput-e.bytesInOutput).slice(0,5);t.length>0&&(console.log("\n šŸ“Š Top 5 largest modules:"),t.forEach(([e,t])=>{let r=e.split(/[/\\]/).pop()||e;console.log(` ${r.padEnd(30)} ${Ls(t.bytesInOutput)}`)}))}}}let p={outputPath:o,buildTime:u,size:h};if(t.copy&&t.copy.length>0){t.logging&&console.log("\nšŸ“¦ Copying files...");for(let e of t.copy){let r=d(e.from),s=d(n,e.to),a=f(s);if($(a)||b(a,{recursive:!0}),$(r)){if(e.transform){let n=S(r,"utf-8"),a=e.transform(n,t);E(s,a)}else T(r,s);t.logging&&console.log(` āœ“ ${e.from} → ${e.to}`)}else t.logging&&console.warn(` ⚠ File not found: ${e.from}`)}}return t.onBuildEnd&&await t.onBuildEnd(p),t.logging&&console.log(""),p}catch(e){throw t.logging&&(console.error("\nāŒ Build failed:"),console.error(e)),e}}function Ls(e){if(0===e)return"0 B";let t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["B","KB","MB","GB"][t]}function qs(e){return e}var Bs=["elit.config.ts","elit.config.js","elit.config.mjs","elit.config.cjs","elit.config.json"];function Us(e="development",t=process.cwd()){let r={MODE:e},s=[`.env.${e}.local`,`.env.${e}`,".env.local",".env"];for(let e of s){let s=d(t,e);if($(s)){let e=S(s,"utf-8").split("\n");for(let t of e){let e=t.trim();if(!e||e.startsWith("#"))continue;let s=e.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);if(s){let[,e,t]=s,n=t.trim();(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))&&(n=n.slice(1,-1)),e in r||(r[e]=n)}}}}return r}async function Is(e=process.cwd()){for(let t of Bs){let r=d(e,t);if($(r))try{return await Js(r)}catch(e){throw console.error(`Error loading config file: ${t}`),console.error(e),e}}return null}async function Js(e){let t=e.split(".").pop();if("json"===t){let t=S(e,"utf-8");return JSON.parse(t)}if("ts"!==t){let{pathToFileURL:t}=await import("url"),r=await import(t(e).href);return r.default||r}try{let{pathToFileURL:t}=await import("url"),r=await import(t(e).href);return r.default||r}catch{throw console.error("TypeScript config files require tsx or ts-node to be installed."),console.error("Install with: npm install -D tsx"),console.error("Or use a .js or .json config file instead."),new Error("Cannot load TypeScript config without tsx/ts-node")}}function Vs(e,t){return e?{...e,...Object.fromEntries(Object.entries(t).filter(([e,t])=>void 0!==t))}:t}export{ys as ApiRouter,G as CreateStyle,M as DomNode,ys as ServerRouter,Hs as SharedState,Os as StateManager,ke as a,He as abbr,se as address,nt as area,ne as article,ae as aside,at as audio,Oe as b,Q as base,O as batchRender,Fe as bdi,je as bdo,_ as bindChecked,V as bindValue,ye as blockquote,Z as body,Ns as bodyLimit,Ae as br,Ws as build,Ot as button,Ms as cacheControl,yt as canvas,St as caption,De as cite,D as cleanupUnused,Pe as code,Et as col,Tt as colgroup,ls as commentNode,xs as compress,k as computed,Ss as cors,js as createDevServer,ss as createEl,z as createElementFactory,as as createMathEl,gs as createRouter,ms as createRouterView,q as createSharedState,R as createState,ns as createSvgEl,j as createVirtualList,We as data,Ft as datalist,ve as dd,W as debounce,qs as defineConfig,wt as del,_t as details,Le as dfn,Gt as dialog,be as div,we as dl,es as doc,x as dom,$e as dt,H as effect,Qr as el,K as elements,qe as em,dt as embed,Ts as errorHandler,jt as fieldset,Se as figcaption,Ee as figure,oe as footer,At as form,os as fragment,ts as getEl,ds as getElClass,cs as getElId,hs as getElName,us as getElTag,rs as getEls,le as h1,ce as h2,de as h3,ue as h4,he as h5,pe as h6,X as head,ie as header,Ds as hmr,Te as hr,ws as html,Be as i,ut as iframe,ot as img,Dt as input,$t as ins,vs as json,Ue as kbd,Pt as label,A as lazy,Wt as legend,Ce as li,ee as link,Is as loadConfig,Us as loadEnv,Es as logger,ge as main,it as map,Ie as mark,qr as mathMath,Gr as mathMfrac,Br as mathMi,Ur as mathMn,Ir as mathMo,Kr as mathMroot,_r as mathMrow,Jr as mathMs,zr as mathMsqrt,Xr as mathMsub,Zr as mathMsup,Vr as mathMtext,zt as menu,Vs as mergeConfig,te as meta,Lt as meter,me as nav,vt as noscript,ht as object,Ne as ol,qt as optgroup,Bt as option,Ut as output,Me as p,pt as param,gt as picture,mt as portal,xe as pre,It as progress,Je as q,Cs as rateLimit,U as reactive,I as reactiveAs,F as renderChunked,fs as routerLink,Ve as rp,_e as rt,Ge as ruby,ze as s,Ke as samp,bt as script,fe as section,Rs as security,Jt as select,bs as sendText,B as sharedStateManager,Xt as slot,Xe as small,ft as source,Ze as span,$s as status,Ye as strong,re as style,Qe as sub,Kt as summary,et as sup,$r as svgAnimate,Er as svgAnimateMotion,Sr as svgAnimateTransform,Qt as svgCircle,mr as svgClipPath,cr as svgDefs,ar as svgEllipse,Nr as svgFeBlend,Mr as svgFeColorMatrix,xr as svgFeComponentTransfer,Rr as svgFeComposite,kr as svgFeConvolveMatrix,Hr as svgFeDiffuseLighting,Or as svgFeDisplacementMap,Fr as svgFeFlood,jr as svgFeGaussianBlur,Ar as svgFeMorphology,Dr as svgFeOffset,Pr as svgFeSpecularLighting,Wr as svgFeTile,Lr as svgFeTurbulence,Cr as svgFilter,wr as svgForeignObject,or as svgG,br as svgImage,rr as svgLine,dr as svgLinearGradient,vr as svgMarker,gr as svgMask,tr as svgPath,pr as svgPattern,nr as svgPolygon,sr as svgPolyline,ur as svgRadialGradient,er as svgRect,Tr as svgSet,hr as svgStop,Yt as svgSvg,yr as svgSymbol,ir as svgText,lr as svgTspan,fr as svgUse,Ct as table,Nt as tbody,Mt as td,Zt as template,J as text,is as textNode,Vt as textarea,xt as tfoot,Rt as th,kt as thead,P as throttle,tt as time,Y as title,Ht as tr,lt as track,rt as u,Re as ul,Yr as varElement,ct as video,st as wbr};