@jasonshimmy/custom-elements-runtime 0.0.10-beta.0 → 0.0.10-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,10 +12,10 @@ Build modern components with strict TypeScript, zero dependencies, and a clean f
12
12
  ## ✨ Why You'll Love It
13
13
 
14
14
  - ⚡ **Blazing Fast:** Minimal runtime, instant updates, zero dependencies.
15
+ - 🎨 **JIT CSS:** On-demand, utility-first styling directly in your HTML.
15
16
  - 🧑‍💻 **TypeScript First:** Strict types, intellisense, and safety everywhere.
16
17
  - 🧩 **Functional API:** No classes, no boilerplate—just pure functions.
17
18
  - 🛠️ **SSR & HMR Ready:** Universal rendering and instant hot reloads.
18
- - 🎨 **Style Utilities:** Scoped CSS, dynamic styles, and theming built-in.
19
19
  - 🔌 **Extensible:** Directives, event bus, store, and more for advanced use cases.
20
20
  - 🏆 **Developer Friendly:** Clean docs, examples, and a welcoming community.
21
21
 
@@ -83,7 +83,7 @@ Explore the full documentation for every runtime feature:
83
83
 
84
84
  ## 🎨 Styling
85
85
  - [Style](./docs/style.md)
86
- - [Style Utils](./docs/style-utils.md)
86
+ - [Deep Dive: JIT CSS](./docs/jit-css.md)
87
87
 
88
88
  ## ⚡ Performance & Architecture
89
89
  - [Virtual DOM](./docs/virtual-dom.md)
@@ -1,2 +1,19 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Y(n){let e=new Proxy(n,{set:(o,l,f)=>(o[l]=f,i(),!0)});const t=[];function s(o){t.push(o),o(e)}function r(){return e}function i(){t.forEach(o=>o(e))}return{subscribe:s,getState:r}}class j extends EventTarget{handlers={};static instance;eventCounters=new Map;static getInstance(){return j.instance||(j.instance=new j),j.instance}emit(e,t){const s=Date.now(),r=this.eventCounters.get(e);if(!r||s-r.window>1e3)this.eventCounters.set(e,{count:1,window:s});else if(r.count++,r.count>50&&(console.error(`Event storm detected for "${e}": ${r.count} events in 1 second. Throttling...`),r.count>100)){console.warn(`Blocking further "${e}" events to prevent infinite loop`);return}this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1,cancelable:!0}));const i=this.handlers[e];i&&i.forEach(o=>{try{o(t)}catch(l){console.error(`Error in global event handler for "${e}":`,l)}})}on(e,t){return this.handlers[e]||(this.handlers[e]=new Set),this.handlers[e].add(t),()=>this.off(e,t)}off(e,t){const s=this.handlers[e];s&&s.delete(t)}offAll(e){delete this.handlers[e]}listen(e,t,s){return this.addEventListener(e,t,s),()=>this.removeEventListener(e,t)}once(e,t){return new Promise(s=>{const r=this.on(e,i=>{r(),t(i),s(i)})})}getActiveEvents(){return Object.keys(this.handlers).filter(e=>this.handlers[e]&&this.handlers[e].size>0)}clear(){this.handlers={}}getHandlerCount(e){return this.handlers[e]?.size||0}getEventStats(){const e={};for(const[t,s]of this.eventCounters.entries())e[t]={count:s.count,handlersCount:this.getHandlerCount(t)};return e}resetEventCounters(){this.eventCounters.clear()}}const Q=j.getInstance();function R(n,e={},t,s){const r=s??e.key;return{tag:n,key:r,props:e,children:t}}function z(n){return!!n&&typeof n=="object"&&(n.type==="AnchorBlock"||n.tag==="#anchor")}function M(n){return typeof n=="object"&&n!==null&&"tag"in n&&!z(n)}function G(n,e){return n.key!=null?n:{...n,key:e}}function ee(n,e=[],t={}){const s={},r={},i={},o=/([:@#]?)([a-zA-Z0-9-:\.]+)=("([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)')/g;let l;for(;l=o.exec(n);){const f=l[1],c=l[2],h=(l[4]||l[6])??"",d=h.match(/^{{(\d+)}}$/);let a=d?e[Number(d[1])]??null:h;if(d||(a==="true"?a=!0:a==="false"?a=!1:a==="null"?a=null:isNaN(Number(a))||(a=Number(a))),f===":")typeof a=="boolean"?r[c]=a:a!=null&&(s[c]=a);else if(f==="@"){const _="on"+c.charAt(0).toUpperCase()+c.slice(1);s[_]=typeof a=="function"?a:typeof t[a]=="function"?t[a]:void 0}else if(f==="#"){const[_,...b]=c.split("."),T=[...b];let k=a,u=[...T];if(_==="model"&&typeof k=="string"&&k.includes(".")){const y=["trim","number","lazy"],m=k.split(".");let g=k;const p=[];for(let x=m.length-1;x>0&&y.includes(m[x]);x--)p.unshift(m[x]),g=m.slice(0,x).join(".");k=g,u.push(...p)}i[_]={value:k,modifiers:u}}else r[c]=a}return{props:s,attrs:r,directives:i}}function te(n,e,t){function s(u,y){return R("#text",{},u,y)}let r="";for(let u=0;u<n.length;u++)r+=n[u],u<e.length&&(r+=`{{${u}}}`);const i=/<\/?([a-zA-Z0-9-]+)([^>]*)\/?>|{{(\d+)}}|([^<]+)/g,o=[];let l=null,f,c=[],h=null,d={},a,_=0,b=[];function T(u){!u||typeof u!="object"||z(u)||(u.props||u.attrs?(u.props&&(d.props||(d.props={}),Object.assign(d.props,u.props)),u.attrs&&(d.attrs||(d.attrs={}),Object.keys(u.attrs).forEach(y=>{if(y==="style"&&d.attrs.style){const m=d.attrs.style.replace(/;?\s*$/,""),g=u.attrs.style.replace(/^;?\s*/,"");d.attrs.style=m+"; "+g}else if(y==="class"&&d.attrs.class){const m=d.attrs.class.trim().split(/\s+/).filter(Boolean),g=u.attrs.class.trim().split(/\s+/).filter(Boolean),p=[...new Set([...m,...g])];d.attrs.class=p.join(" ")}else d.attrs[y]=u.attrs[y]}))):(d.props||(d.props={}),Object.assign(d.props,u)))}function k(u,y){const m=h?c:b;if(z(u)){const g=u.key??y;let p=u.children;m.push({...u,key:g,children:p});return}if(M(u)){m.push(G(u,void 0));return}if(Array.isArray(u)){if(u.length===0)return;for(let g=0;g<u.length;g++){const p=u[g];z(p)||M(p)||Array.isArray(p)?k(p,`${y}-${g}`):p!==null&&typeof p=="object"?T(p):m.push(s(String(p),`${y}-${g}`))}return}if(u!==null&&typeof u=="object"){T(u);return}m.push(s(String(u),y))}for(;f=i.exec(r);)if(f[1]){const u=f[1],y=f[0][1]==="/",m=f[0][f[0].length-2]==="/",{props:g,attrs:p,directives:x}=ee(f[2]||"",e,t),S={props:{},attrs:{}};for(const A in g)S.props[A]=g[A];for(const A in p)S.attrs[A]=p[A];for(const[A,E]of Object.entries(x))if(A==="bind")if(typeof E.value=="object"&&E.value!==null)for(const[w,v]of Object.entries(E.value))typeof v=="boolean"?S.attrs[w]=v:v!=null&&(S.attrs[w]=String(v));else E.value!=null&&(S.attrs[A]=String(E.value));else if(A==="show"){const w=!!E.value;S.attrs.style=(S.attrs.style||"")+(w?"":"; display: none !important")}else if(A==="class"){const w=E.value;let v=[];if(typeof w=="string")v=w.split(/\s+/).filter(Boolean);else if(Array.isArray(w)){for(const N of w)if(typeof N=="string")v.push(...N.split(/\s+/).filter(Boolean));else if(N&&typeof N=="object")for(const[O,P]of Object.entries(N))P&&v.push(...O.split(/\s+/).filter(Boolean))}else if(w&&typeof w=="object")for(const[N,O]of Object.entries(w))O&&v.push(...N.split(/\s+/).filter(Boolean));const B=S.attrs.class||"",D=[...new Set([...B.split(/\s+/).filter(Boolean),...v])];S.attrs.class=D.join(" ")}else if(A==="style"){const w=E.value;let v="";if(typeof w=="string")v=w;else if(w&&typeof w=="object"){const D=[];for(const[N,O]of Object.entries(w))if(O!=null&&O!==""){const P=N.replace(/[A-Z]/g,X=>`-${X.toLowerCase()}`),Z=["width","height","top","right","bottom","left","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","font-size","line-height","border-width","border-radius","min-width","max-width","min-height","max-height"];let q=String(O);typeof O=="number"&&Z.includes(P)&&(q=`${O}px`),D.push(`${P}: ${q}`)}v=D.join("; ")+(D.length>0?";":"")}const B=S.attrs.style||"";S.attrs.style=B+(B&&!B.endsWith(";")?"; ":"")+v}const C={};for(const[A,E]of Object.entries(x))["bind","show","class","style"].includes(A)||(C[A]=E);if(Object.keys(C).length>0&&(S.directives=C),y){const A=R(h,d,c.length===1&&M(c[0])&&c[0].tag==="#text"?typeof c[0].children=="string"?c[0].children:"":c.length?c:void 0,a),E=o.pop();E?(h=E.tag,d=E.props,a=E.key,c=E.children,c.push(A)):l=A}else m?(h?c:b).push(R(u,S,void 0,void 0)):(h&&o.push({tag:h,props:d,children:c,key:a}),h=u,d=S,c=[])}else if(typeof f[3]<"u"){const u=Number(f[3]),y=e[u],m=`interp-${u}`;k(y,m)}else if(f[4]){const u=f[4],y=h?c:b,m=u.split(/({{\d+}})/);for(const g of m){if(!g)continue;const p=g.match(/^{{(\d+)}}$/);if(p){const x=Number(p[1]),S=e[x],C=`interp-${x}`;k(S,C)}else{const x=`text-${_++}`;y.push(s(g,x))}}}if(l)return M(l)&&Array.isArray(l.children)&&(l.children=l.children.filter(u=>M(u)?u.tag!=="#text"||typeof u.children=="string"&&u.children.trim()!=="":!0)),l;if(b.length>0){const u=b.filter(y=>M(y)?y.tag!=="#text"||typeof y.children=="string"&&y.children.trim()!=="":!0);return u.length===1?u[0]:u}return R("div",{},"","fallback-root")}function ne(n,...e){const t=e[e.length-1],s=typeof t=="object"&&t&&!Array.isArray(t)?t:void 0;return te(n,e,s)}function se(n,e){return H(n?e:[],"when-block")}function re(n,e){return n.map((t,s)=>{const r=typeof t=="object"?t?.key??t?.id??`idx-${s}`:String(t);return H(e(t,s),`each-${r}`)})}function ie(){const n=[];return{when(e,t){return n.push([e,t]),this},otherwise(e){return n.push([!0,e]),this},done(){return oe(...n)}}}function oe(...n){for(let e=0;e<n.length;e++){const[t,s]=n[e];if(t)return[H(s,`whenChain-branch-${e}`)]}return[H([],"whenChain-empty")]}function H(n,e){const t=n?Array.isArray(n)?n.filter(Boolean):[n].filter(Boolean):[];return{tag:"#anchor",key:e,children:t}}function L(n,e){return e.split(".").reduce((t,s)=>t?.[s],n)}function U(n,e,t){const s=e.split("."),r=s.pop();if(!r)return;const i=s.reduce((o,l)=>(l in o||(o[l]={}),o[l]),n);i[r]=t}function ce(n,e,t,s,r,i,o){if(!i)return;const l=e.includes("lazy"),f=e.includes("trim"),c=e.includes("number"),h=()=>{const k=i._state||i;return L(k,n)},d=h();let a="text";const _=s?.type;if(o instanceof HTMLInputElement?a=_||o.type||"text":o instanceof HTMLSelectElement?a="select":o instanceof HTMLTextAreaElement&&(a="textarea"),a==="checkbox")if(Array.isArray(d)){const k=o?.getAttribute("value")||s?.value||"",u=d.includes(k);o&&o.checked!==u&&(t.checked=u)}else{const k=o?.getAttribute("true-value")||!0,u=d===k;o&&o.checked!==u&&(t.checked=u)}else if(a==="radio"){const k=s?.value||"",u=d===k;o&&o.checked!==u&&(t.checked=u)}else if(a==="select")if(o&&o.hasAttribute("multiple")){const k=o,u=Array.isArray(d)?d:[];setTimeout(()=>{Array.from(k.options).forEach(y=>{const m=u.includes(y.value);y.selected!==m&&(y.selected=m)})},0)}else setTimeout(()=>{o instanceof HTMLSelectElement&&o.value!==String(d)&&(o.value=String(d))},0);else{const k=String(d??"");(!o||o.value!==k)&&(t.value=d)}const b=l||a==="checkbox"||a==="radio"||a==="select"?"change":"input",T=k=>{if(k.isComposing||r._isComposing||k.isTrusted===!1)return;const u=k.target;if(u._modelUpdating)return;const y=h();let m=u.value;if(a==="checkbox")if(Array.isArray(y)){const S=u.getAttribute("value")||"",C=[...y];if(u.checked)C.includes(S)||C.push(S);else{const A=C.indexOf(S);A>-1&&C.splice(A,1)}m=C}else{const S=u.getAttribute("true-value")||!0,C=u.getAttribute("false-value")||!1;m=u.checked?S:C}else if(a==="radio")m=u.getAttribute("value")||u.value;else if(a==="select"&&u.multiple){const S=u;m=Array.from(S.selectedOptions).map(C=>C.value)}else if(f&&(m=m.trim()),c){const S=Number(m);isNaN(S)||(m=S)}const g=i._state||i,p=L(g,n);if(Array.isArray(m)&&Array.isArray(p)?JSON.stringify([...m].sort())!==JSON.stringify([...p].sort()):m!==p){const S=k.target;S._modelUpdating=!0,U(g,n,m),setTimeout(()=>{S._modelUpdating=!1},0),i._requestRender&&i._requestRender()}};if(r[b]=T,a==="text"||a==="textarea"){const k=()=>{r._isComposing=!0},u=y=>{r._isComposing=!1;const m=y.target;setTimeout(()=>{if(m){let g=m.value;if(f&&(g=g.trim()),c){const C=Number(g);isNaN(C)||(g=C)}const p=i._state||i,x=L(p,n);(Array.isArray(g)&&Array.isArray(x)?JSON.stringify([...g].sort())!==JSON.stringify([...x].sort()):g!==x)&&(m&&(m._modelUpdating=!0,setTimeout(()=>{m._modelUpdating=!1},0)),U(p,n,g),i._requestRender&&i._requestRender())}},0)};r.compositionstart=k,r.compositionend=u}}function le(n,e,t,s){if(s)try{const r=JSON.parse(n);if(typeof r=="object")for(const[i,o]of Object.entries(r))e[i]=o}catch{const r=L(s,n);t[n]=r}}function ae(n,e,t){if(!t)return;const s=L(t,n),r=e.style||"",i=s?"":"none";if(r){const o=r.split(";").filter(Boolean),l=o.findIndex(f=>f.trim().startsWith("display:"));l>=0?o[l]=`display: ${i}`:o.push(`display: ${i}`),e.style=o.join("; ")}else e.style=`display: ${i}`}function ue(n,e,t){if(!t)return;const s=L(t,n);let r=[];typeof s=="string"?r=[s]:Array.isArray(s)?r=s.filter(Boolean):typeof s=="object"&&(r=Object.entries(s).filter(([,l])=>!!l).map(([l])=>l));const i=e.class||"",o=i?`${i} ${r.join(" ")}`.trim():r.join(" ");o&&(e.class=o)}function fe(n,e,t){let s;if(typeof n=="string"){if(!t)return;s=L(t,n)}else s=n;let r="";if(typeof s=="string")r=s;else if(s&&typeof s=="object"){const o=[];for(const[l,f]of Object.entries(s))if(f!=null&&f!==""){const c=l.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`),h=["width","height","top","right","bottom","left","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","font-size","line-height","border-width","border-radius","min-width","max-width","min-height","max-height"];let d=String(f);typeof f=="number"&&h.includes(c)&&(d=`${f}px`),o.push(`${c}: ${d}`)}r=o.join("; ")+(o.length>0?";":"")}const i=e.style||"";e.style=i+(i&&!i.endsWith(";")?"; ":"")+r}function F(n,e,t,s){const r={},i={...s||{}},o={};for(const[l,f]of Object.entries(n)){const{value:c,modifiers:h}=f;switch(l){case"model":ce(typeof c=="string"?c:String(c),h,r,i,o,e,t);break;case"bind":le(c,r,i,e);break;case"show":ae(c,i,e);break;case"class":ue(c,i,e);break;case"style":fe(c,i,e);break}}return{props:r,attrs:i,listeners:o}}function W(n,e){if(Array.isArray(n)){const i=new Set;return n.map(o=>{if(!o||typeof o!="object")return o;let l=o.props?.key??o.key;if(!l){const d=o.tag||"node",a=o.props?.attrs?.id??o.props?.attrs?.name??o.props?.attrs?.["data-key"]??"";l=a?`${e}:${d}:${a}`:`${e}:${d}`}let f=l,c=1;for(;i.has(f);)f=`${l}#${c++}`;i.add(f);let h=o.children;return Array.isArray(h)&&(h=W(h,f)),{...o,key:f,children:h}})}const t=n;let s=t.props?.key??t.key??e,r=t.children;return Array.isArray(r)&&(r=W(r,s)),{...t,key:s,children:r}}function he(n,e,t,s){const r=t.directives??{},i=F(r,s,n,t.attrs),o={...e.props,...t.props,...i.props},l={...e.attrs,...t.attrs,...i.attrs},f=e.props??{},c=o;for(const a in{...f,...c}){const _=f[a],b=c[a];_!==b&&(a==="value"&&(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement)?n.value!==b&&(n.value=b??""):a==="checked"&&n instanceof HTMLInputElement?n.checked=!!b:a.startsWith("on")&&typeof b=="function"?(typeof _=="function"&&n.removeEventListener(a.slice(2).toLowerCase(),_),n.addEventListener(a.slice(2).toLowerCase(),b)):b==null||b===!1?n.removeAttribute(a):n.setAttribute(a,String(b)))}for(const[a,_]of Object.entries(i.listeners||{}))n.addEventListener(a,_);const h=e.attrs??{},d=l;for(const a in{...h,...d}){const _=h[a],b=d[a];_!==b&&(b==null||b===!1?n.removeAttribute(a):n.setAttribute(a,String(b)))}}function $(n,e){if(typeof n=="string")return document.createTextNode(n);if(n.tag==="#text"){const c=document.createTextNode(typeof n.children=="string"?n.children:"");return n.key!=null&&(c.key=n.key),c}if(n.tag==="#anchor"){const c=n,h=Array.isArray(c.children)?c.children:[],d=document.createTextNode(""),a=document.createTextNode("");c.key!=null&&(d.key=`${c.key}:start`,a.key=`${c.key}:end`),c._startNode=d,c._endNode=a;const _=document.createDocumentFragment();_.appendChild(d);for(const b of h)_.appendChild($(b,e));return _.appendChild(a),_}const t=document.createElement(n.tag);n.key!=null&&(t.key=n.key);const{props:s={},attrs:r={},directives:i={}}=n.props??{},o=F(i,e,t,r),l={...s,...o.props},f={...r,...o.attrs};for(const c in f){const h=f[c];typeof h=="boolean"?h&&t.setAttribute(c,""):h!=null&&t.setAttribute(c,String(h))}for(const c in l){const h=l[c];if(c==="value"&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement))t.value=h??"";else if(c==="checked"&&t instanceof HTMLInputElement)t.checked=!!h;else if(c.startsWith("on")&&typeof h=="function")t.addEventListener(c.slice(2).toLowerCase(),h);else{if(c.startsWith("on")&&h===void 0)continue;h==null||h===!1?t.removeAttribute(c):t.setAttribute(c,String(h))}}for(const[c,h]of Object.entries(o.listeners||{}))t.addEventListener(c,h);if(Array.isArray(n.children))for(const c of n.children)t.appendChild($(c,e));else typeof n.children=="string"&&(t.textContent=n.children);return t}function de(n,e,t,s){if(typeof t=="string"){n.textContent!==t&&(n.textContent=t);return}if(!Array.isArray(t))return;const r=Array.from(n.childNodes),i=Array.isArray(e)?e:[],o=new Map;for(const a of i)a&&a.key!=null&&o.set(a.key,a);const l=new Map;for(const a of r){const _=a.key;_!=null&&l.set(_,a)}const f=new Set;let c=n.firstChild;function h(a,_){let b=a;for(;b&&(f.add(b),b!==_);)b=b.nextSibling}function d(a,_,b,T){const k=[];let u=a.nextSibling;for(;u&&u!==_;)k.push(u),u=u.nextSibling;const y=Array.isArray(b)?b:[];if(T.some(g=>g&&g.key!=null)||y.some(g=>g&&g.key!=null)){const g=new Map,p=new Map;for(const C of y)C&&C.key!=null&&g.set(C.key,C);for(const C of k){const A=C.key;A!=null&&p.set(A,C)}const x=new Set;let S=a.nextSibling;for(const C of T){let A;if(C.key!=null&&p.has(C.key)){const E=g.get(C.key);A=V(p.get(C.key),E,C,s),x.add(A),A!==S&&n.contains(A)&&n.insertBefore(A,S)}else A=$(C,s),n.insertBefore(A,S),x.add(A);S=A.nextSibling}for(const C of k)!x.has(C)&&n.contains(C)&&n.removeChild(C)}else{const g=Math.min(y.length,T.length);for(let p=0;p<g;p++){const x=y[p],S=T[p],C=V(k[p],x,S,s);C!==k[p]&&(n.insertBefore(C,k[p]),n.removeChild(k[p]))}for(let p=g;p<T.length;p++)n.insertBefore($(T[p],s),_);for(let p=g;p<k.length;p++)n.removeChild(k[p])}}for(const a of t){let _;if(a.tag==="#anchor"){const b=a.key,T=`${b}:start`,k=`${b}:end`;let u=l.get(T),y=l.get(k);const m=Array.isArray(a.children)?a.children:[];if(u||(u=document.createTextNode(""),u.key=T),y||(y=document.createTextNode(""),y.key=k),a._startNode=u,a._endNode=y,!n.contains(u)||!n.contains(y)){n.insertBefore(u,c);for(const g of m)n.insertBefore($(g,s),c);n.insertBefore(y,c)}else d(u,y,o.get(b)?.children,m);h(u,y),c=y.nextSibling;continue}if(a.key!=null&&l.has(a.key)){const b=o.get(a.key);_=V(l.get(a.key),b,a,s),f.add(_),_!==c&&n.contains(_)&&(c&&!n.contains(c)&&(c=null),n.insertBefore(_,c))}else _=$(a,s),c&&!n.contains(c)&&(c=null),n.insertBefore(_,c),f.add(_);c=_.nextSibling}for(const a of r)!f.has(a)&&n.contains(a)&&n.removeChild(a)}function V(n,e,t,s){if(e===t)return n;if(typeof t=="string"){if(n.nodeType===Node.TEXT_NODE)return n.textContent!==t&&(n.textContent=t),n;{const i=document.createTextNode(t);return n.parentNode?.replaceChild(i,n),i}}if(t&&typeof t!="string"&&t.tag==="#anchor"){const i=t,o=Array.isArray(i.children)?i.children:[],l=i._startNode??document.createTextNode(""),f=i._endNode??document.createTextNode("");i.key!=null&&(l.key=`${i.key}:start`,f.key=`${i.key}:end`),i._startNode=l,i._endNode=f;const c=document.createDocumentFragment();c.appendChild(l);for(const h of o)c.appendChild($(h,s));return c.appendChild(f),n.parentNode?.replaceChild(c,n),l}if(!t){const i=document.createComment("removed");return n.parentNode?.replaceChild(i,n),i}if(!e||typeof e=="string"){const i=$(t,s);return n.parentNode?.replaceChild(i,n),i}if(t.tag==="#anchor"){const i=Array.isArray(t.children)?t.children:[],o=t._startNode??document.createTextNode(""),l=t._endNode??document.createTextNode("");t.key!=null&&(o.key=`${t.key}:start`,l.key=`${t.key}:end`),t._startNode=o,t._endNode=l;const f=document.createDocumentFragment();f.appendChild(o);for(const c of i)f.appendChild($(c,s));return f.appendChild(l),n.parentNode?.replaceChild(f,n),o}if(typeof e!="string"&&typeof t!="string"&&e.tag===t.tag&&e.key===t.key){const i=n;return he(i,e.props||{},t.props||{},s),de(i,e.children,t.children,s),i}const r=$(t,s);return n.parentNode?.replaceChild(r,n),r}function pe(n,e,t){const s=c=>c.key==null?{...c,key:"__root__"}:c;let r=Array.isArray(e)?{tag:"div",key:"__root__",children:e}:s(e);r=W(r,String(r.key??"root"));const i=n._prevVNode??null,o=n._prevDom??n.firstChild??null;let l;i&&o?typeof i!="string"&&typeof r!="string"&&i.tag===r.tag&&i.key===r.key?l=V(o,i,r,t):(l=$(r,t),n.replaceChild(l,o)):(l=$(r,t),n.firstChild?n.replaceChild(l,n.firstChild):n.appendChild(l));const f=[];for(let c=0;c<n.childNodes.length;c++){const h=n.childNodes[c];h!==l&&h.nodeName!=="STYLE"&&f.push(h)}f.forEach(c=>n.removeChild(c)),n._prevVNode=r,n._prevDom=l}class ye{cache=new Map;maxSize;accessOrder=new Map;accessCounter=0;constructor(e=100){this.maxSize=e}set(e,t,s=[]){this.cache.size>=this.maxSize&&this.evictOldest(),this.cache.set(e,{css:t,timestamp:Date.now(),dependencies:s}),this.accessOrder.set(e,++this.accessCounter)}get(e){const t=this.cache.get(e);return t?(this.accessOrder.set(e,++this.accessCounter),t.css):null}has(e){return this.cache.has(e)}invalidate(e){const t=[];for(const[s,r]of this.cache)r.dependencies.includes(e)&&t.push(s);t.forEach(s=>{this.cache.delete(s),this.accessOrder.delete(s)})}clear(){this.cache.clear(),this.accessOrder.clear(),this.accessCounter=0}evictOldest(){let e="",t=1/0;for(const[s,r]of this.accessOrder)r<t&&(t=r,e=s);e&&(this.cache.delete(e),this.accessOrder.delete(e))}getStats(){return{size:this.cache.size,maxSize:this.maxSize,hitRate:this.accessCounter>0?this.cache.size/this.accessCounter:0}}}function ge(n){return n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,>+~])\s*/g,"$1").replace(/;}/g,"}").trim()}function me(n){try{return JSON.stringify(n,(e,t)=>{if(typeof t=="function")return t.toString();if(typeof t=="object"&&t!==null){if(t.__hashed)return"[Circular]";t.__hashed=!0;const s={...t};return delete s.__hashed,s}return t})}catch{return n.map(e=>String(e)).join("|")}}function _e(n){const e=n.split("}").filter(r=>r.trim()),t=new Set,s=[];for(const r of e){const i=r.trim().replace(/\s+/g," ");i&&!t.has(i)&&(t.add(i),s.push(r+"}"))}return s.join("").replace(/}$/,"")}function be(n,e){let t=null;const s=((...r)=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{n(...r),t=null},e)});return s.cancel=()=>{t!==null&&(clearTimeout(t),t=null)},s}class ke{metrics=new Map;startTimer(e){const t=performance.now();return()=>{const s=performance.now()-t;return this.recordMetric(e,s),s}}recordMetric(e,t){this.metrics.has(e)||this.metrics.set(e,[]);const s=this.metrics.get(e);s.push(t),s.length>100&&s.shift()}getStats(e){if(e){const s=this.metrics.get(e)||[];return s.length===0?null:{operation:e,count:s.length,average:s.reduce((r,i)=>r+i,0)/s.length,min:Math.min(...s),max:Math.max(...s)}}const t={};for(const[s,r]of this.metrics)r.length>0&&(t[s]={count:r.length,average:r.reduce((i,o)=>i+o,0)/r.length,min:Math.min(...r),max:Math.max(...r)});return t}reset(e){e?this.metrics.delete(e):this.metrics.clear()}}const Ce=new ke,Se=new Map;function K(n){return n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function I(n){return typeof n=="string"?n.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e]):n}function Ae(n){return n.replace(/url\s*\(\s*['"]?javascript:[^)]*\)/gi,"").replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi,"").replace(/expression\s*\([^)]*\)/gi,"")}function xe(n,...e){let t="";for(let s=0;s<n.length;s++)t+=n[s],s<e.length&&(t+=e[s]);return t}function Ee(n,e,t){let s=K(n);s.includes("-")||(s=`cer-${s}`);let r;typeof e=="function"?r={...t,render:e}:r=e,typeof r.onError!="function"&&(r.onError=(i,o)=>{console.error(`[${s}] Error:`,i,o)}),Se.set(s,r),typeof window<"u"&&!customElements.get(s)&&customElements.define(s,J(r))}function J(n){if(!n.render)throw new Error("Component must have a render function");return typeof window>"u"?class{constructor(){}}:class extends HTMLElement{context;_listeners=[];_watchers=new Map;_renderTimeoutId=null;_mounted=!1;_hasError=!1;_initializing=!0;_styleElement=null;_styleCache=new ye(100);_lastStyleHash="";_styleDependencies=new Set;_styleUpdateDebounced;_cfg;_lastRenderTime=0;_renderCount=0;_templateLoading=!1;_templateError=null;constructor(){super(),this.attachShadow({mode:"open"}),this._cfg=n;const e={debounceMs:16,...n.styleOptimizations};this._styleUpdateDebounced=be(t=>this._applyStyle(t),e.debounceMs),this.context=this._initContext(n),Object.keys(n).forEach(t=>{const s=n[t];typeof s=="function"&&!t.startsWith("on")&&(this.context[t]=(...r)=>s(...r,this.context))}),this._applyProps(n),this._applyComputed(n),this._initializing=!1,this._initWatchers(n),this._render(n)}connectedCallback(){this._runLogicWithinErrorBoundary(n,()=>{n.onConnected&&!this._mounted&&(n.onConnected(this.context),this._mounted=!0)})}disconnectedCallback(){this._runLogicWithinErrorBoundary(n,()=>{n.onDisconnected&&n.onDisconnected(this.context),this._listeners.forEach(e=>e()),this._listeners=[],this._watchers.clear(),this._styleCache.clear(),this._styleDependencies.clear(),this._styleElement=null,this._lastStyleHash="",this._styleUpdateDebounced.cancel(),this._templateLoading=!1,this._templateError=null,this._mounted=!1})}attributeChangedCallback(e,t,s){this._runLogicWithinErrorBoundary(n,()=>{this._applyProps(n),n.onAttributeChanged&&n.onAttributeChanged(e,t,s,this.context)})}static get observedAttributes(){return n.props?Object.keys(n.props).map(K):[]}_applyComputed(e){this._runLogicWithinErrorBoundary(n,()=>{e.computed&&Object.entries(e.computed).forEach(([t,s])=>{Object.defineProperty(this.context,t,{get:()=>{const r=s(this.context);return I(r)},enumerable:!0})})})}_render(e){this._runLogicWithinErrorBoundary(e,()=>{if(!this.shadowRoot)return;if(this._styleDependencies.clear(),this._templateLoading&&e.loadingTemplate){this._renderOutput(e.loadingTemplate(this.context));return}if(this._templateError&&e.errorTemplate){this._renderOutput(e.errorTemplate(this._templateError,this.context));return}const t=e.render(this.context);if(t instanceof Promise){this._templateLoading=!0,t.then(s=>(this._templateLoading=!1,this._templateError=null,this._renderOutput(s),s)).catch(s=>{if(this._templateLoading=!1,this._templateError=s,e.errorTemplate){const r=e.errorTemplate(s,this.context);return this._renderOutput(r),r}throw s}),e.loadingTemplate&&this._renderOutput(e.loadingTemplate(this.context));return}this._renderOutput(t),this._applyStyle(e)})}_renderOutput(e){if(!this.shadowRoot)return;const t=new Proxy(this.context,{get:(s,r)=>r==="_requestRender"?()=>this._requestRender():r==="context"?s:typeof r=="string"&&r.includes(".")?r.split(".").reduce((i,o)=>i?.[o],s):s[r],set:(s,r,i)=>{if(typeof r=="string"&&r.includes(".")){const o=r.split("."),l=o.pop();if(!l)return!1;const f=o.reduce((c,h)=>(h in c||(c[h]={}),c[h]),s);return f[l]=i,!0}return s[r]=i,!0}});pe(this.shadowRoot,Array.isArray(e)?e:[e],t),this._requestStyleUpdate()}_requestRender(){if(this._renderTimeoutId!==null&&clearTimeout(this._renderTimeoutId),Date.now()-this._lastRenderTime<16){if(this._renderCount++,this._renderCount>10){console.warn(`[${this.tagName}] Potential infinite render loop detected. Skipping render.`),this._renderTimeoutId=null;return}}else this._renderCount=0;this._renderTimeoutId=setTimeout(()=>{this._lastRenderTime=Date.now(),this._render(this._cfg),this._renderTimeoutId=null},0)}_requestStyleUpdate(){this._styleUpdateDebounced(this._cfg)}_applyStyle(e){this._runLogicWithinErrorBoundary(e,()=>{if(!this.shadowRoot)return;const t=Ce.startTimer("applyStyle");try{if(this._styleElement||(this._styleElement=this.shadowRoot.querySelector("style"),this._styleElement||typeof document<"u"&&(this._styleElement=document.createElement("style"),this.shadowRoot.prepend(this._styleElement))),!e.style){this._styleElement.textContent="";return}const s={enableCaching:!0,enableMinification:!1,enableDeduplication:!0,cacheSize:100,debounceMs:16,...e.styleOptimizations};let r;typeof e.style=="string"?r={css:e.style,cache:s.enableCaching}:typeof e.style=="function"?r={css:e.style,cache:s.enableCaching}:r={cache:s.enableCaching,...e.style};const i=r.dependencies||[],o=r.cache!==!1&&s.enableCaching;let l="";if(o&&i.length>0){const h=i.map(d=>this.context[d]);if(l=me(h),this._lastStyleHash===l&&this._styleCache.has(l)){const d=this._styleCache.get(l);this._styleElement.textContent!==d&&(this._styleElement.textContent=d);return}}(!o||i.length===0)&&(l="no-deps-"+Date.now());const f=typeof r.css=="function"?r.css(this.context):r.css;let c=Ae(f);s.enableMinification&&(c=ge(c)),s.enableDeduplication&&(c=_e(c)),o&&i.length>0&&(this._styleCache.set(l,c,i.map(String)),this._lastStyleHash=l),this._styleElement.textContent!==c&&(this._styleElement.textContent=c)}finally{t()}})}_runLogicWithinErrorBoundary(e,t){this._hasError&&(this._hasError=!1);try{t()}catch(s){this._hasError=!0,e.onError&&e.onError(s,this.context),e.errorFallback&&this.shadowRoot&&(this.shadowRoot.innerHTML=e.errorFallback(s,this.context))}}_initContext(e){try{let t=function(r,i=""){return Array.isArray(r)?new Proxy(r,{get(o,l,f){const c=Reflect.get(o,l,f);return typeof c=="function"&&typeof l=="string"&&["push","pop","shift","unshift","splice","sort","reverse"].includes(l)?function(...d){const a=c.apply(o,d);if(!s._initializing){const _=i||"root";s._triggerWatchers(_,o),s._render(e)}return a}:c},set(o,l,f){if(o[l]=f,!s._initializing){const c=i?`${i}.${String(l)}`:String(l);s._styleDependencies.add(String(l)),s._styleCache.invalidate(String(l)),s._triggerWatchers(c,f);const h=e.style;let d=!1;if(h&&typeof h=="object"&&"dependencies"in h){const a=h.dependencies||[];d=a.includes(String(l))&&a.every(_=>!s._styleDependencies.has(String(_))||_===l)}d?s._requestStyleUpdate():s._render(e)}return!0},deleteProperty(o,l){if(delete o[l],!s._initializing){const f=i?`${i}.${String(l)}`:String(l);s._styleDependencies.add(String(l)),s._triggerWatchers(f,void 0),s._render(e)}return!0}}):r&&typeof r=="object"?(Object.keys(r).forEach(o=>{const l=i?`${i}.${o}`:o;r[o]=t(r[o],l)}),new Proxy(r,{set(o,l,f){const c=i?`${i}.${String(l)}`:String(l);return o[l]=t(f,c),s._initializing||(s._triggerWatchers(c,o[l]),s._render(e)),!0},get(o,l,f){return Reflect.get(o,l,f)}})):r};const s=this;return t({...e.state})}catch{return{}}}_initWatchers(e){if(e.watch)for(const[t,s]of Object.entries(e.watch)){let r,i={};if(Array.isArray(s)?(r=s[0],i=s[1]||{}):r=s,this._watchers.set(t,{callback:r,options:i,oldValue:this._getNestedValue(t)}),i.immediate)try{const o=this._getNestedValue(t);r(o,void 0,this.context)}catch(o){console.error(`Error in immediate watcher for "${t}":`,o)}}}_getNestedValue(e){return e.split(".").reduce((t,s)=>t?.[s],this.context)}_triggerWatchers(e,t){const s=(i,o)=>{if(i===o)return!0;if(typeof i!=typeof o||typeof i!="object"||i===null||o===null)return!1;if(Array.isArray(i)&&Array.isArray(o))return i.length!==o.length?!1:i.every((c,h)=>s(c,o[h]));const l=Object.keys(i),f=Object.keys(o);return l.length!==f.length?!1:l.every(c=>s(i[c],o[c]))},r=this._watchers.get(e);if(r&&!s(t,r.oldValue))try{r.callback(t,r.oldValue,this.context),r.oldValue=t}catch(i){console.error(`Error in watcher for "${e}":`,i)}for(const[i,o]of this._watchers.entries())if(o.options.deep&&e.startsWith(i+"."))try{const l=this._getNestedValue(i);s(l,o.oldValue)||(o.callback(l,o.oldValue,this.context),o.oldValue=l)}catch(l){console.error(`Error in deep watcher for "${i}":`,l)}}_applyProps(e){try{let t=function(s,r){return r===Boolean?s==="true":r===Number?Number(s):s};if(!e.props)return;Object.entries(e.props).forEach(([s,r])=>{const i=this.getAttribute(K(s));i!==null?this.context[s]=I(t(i,r.type)):"default"in r&&r.default!==void 0&&(this.context[s]=I(r.default))})}catch(t){this._hasError=!0,e.onError&&e.onError(t,this.context),e.errorFallback&&this.shadowRoot&&(this.shadowRoot.innerHTML=e.errorFallback(t,this.context))}}}}exports.component=Ee;exports.createElementClass=J;exports.createStore=Y;exports.css=xe;exports.each=re;exports.eventBus=Q;exports.html=ne;exports.match=ie;exports.when=se;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function se(e){let t=new Proxy(e,{set:(o,c,d)=>(o[c]=d,s(),!0)});const r=[];function n(o){r.push(o),o(t)}function i(){return t}function s(){r.forEach(o=>o(t))}return{subscribe:n,getState:i}}class R extends EventTarget{handlers={};static instance;eventCounters=new Map;static getInstance(){return R.instance||(R.instance=new R),R.instance}emit(t,r){const n=Date.now(),i=this.eventCounters.get(t);if(!i||n-i.window>1e3)this.eventCounters.set(t,{count:1,window:n});else if(i.count++,i.count>50&&(console.error(`Event storm detected for "${t}": ${i.count} events in 1 second. Throttling...`),i.count>100)){console.warn(`Blocking further "${t}" events to prevent infinite loop`);return}this.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!1,cancelable:!0}));const s=this.handlers[t];s&&s.forEach(o=>{try{o(r)}catch(c){console.error(`Error in global event handler for "${t}":`,c)}})}on(t,r){return this.handlers[t]||(this.handlers[t]=new Set),this.handlers[t].add(r),()=>this.off(t,r)}off(t,r){const n=this.handlers[t];n&&n.delete(r)}offAll(t){delete this.handlers[t]}listen(t,r,n){return this.addEventListener(t,r,n),()=>this.removeEventListener(t,r)}once(t,r){return new Promise(n=>{const i=this.on(t,s=>{i(),r(s),n(s)})})}getActiveEvents(){return Object.keys(this.handlers).filter(t=>this.handlers[t]&&this.handlers[t].size>0)}clear(){this.handlers={}}getHandlerCount(t){return this.handlers[t]?.size||0}getEventStats(){const t={};for(const[r,n]of this.eventCounters.entries())t[r]={count:n.count,handlersCount:this.getHandlerCount(r)};return t}resetEventCounters(){this.eventCounters.clear()}}const ae=R.getInstance();function P(e,t={},r,n){const i=n??t.key;return{tag:e,key:i,props:t,children:r}}function V(e){return!!e&&typeof e=="object"&&(e.type==="AnchorBlock"||e.tag==="#anchor")}function z(e){return typeof e=="object"&&e!==null&&"tag"in e&&!V(e)}function le(e,t){return e.key!=null?e:{...e,key:t}}function ce(e,t=[],r={}){const n={},i={},s={},o=/([:@#]?)([a-zA-Z0-9-:\.]+)=("([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)')/g;let c;for(;c=o.exec(e);){const d=c[1],a=c[2],u=(c[4]||c[6])??"",y=u.match(/^{{(\d+)}}$/);let f=y?t[Number(y[1])]??null:u;if(y||(f==="true"?f=!0:f==="false"?f=!1:f==="null"?f=null:isNaN(Number(f))||(f=Number(f))),d===":")typeof f=="boolean"?i[a]=f:f!=null&&(n[a]=f);else if(d==="@"){const w="on"+a.charAt(0).toUpperCase()+a.slice(1);n[w]=typeof f=="function"?f:typeof r[f]=="function"?r[f]:void 0}else if(d==="#"){const[w,...p]=a.split("."),S=[...p];let g=f,l=[...S];if(w==="model"&&typeof g=="string"&&g.includes(".")){const b=["trim","number","lazy"],m=g.split(".");let h=g;const x=[];for(let C=m.length-1;C>0&&b.includes(m[C]);C--)x.unshift(m[C]),h=m.slice(0,C).join(".");g=h,l.push(...x)}s[w]={value:g,modifiers:l}}else i[a]=f}return{props:n,attrs:i,directives:s}}function fe(e,t,r){function n(l,b){return P("#text",{},l,b)}let i="";for(let l=0;l<e.length;l++)i+=e[l],l<t.length&&(i+=`{{${l}}}`);const s=/<\/?([a-zA-Z0-9-]+)([^>]*)\/?>|{{(\d+)}}|([^<]+)/g,o=[];let c=null,d,a=[],u=null,y={},f,w=0,p=[];function S(l){!l||typeof l!="object"||V(l)||(l.props||l.attrs?(l.props&&(y.props||(y.props={}),Object.assign(y.props,l.props)),l.attrs&&(y.attrs||(y.attrs={}),Object.keys(l.attrs).forEach(b=>{if(b==="style"&&y.attrs.style){const m=y.attrs.style.replace(/;?\s*$/,""),h=l.attrs.style.replace(/^;?\s*/,"");y.attrs.style=m+"; "+h}else if(b==="class"&&y.attrs.class){const m=y.attrs.class.trim().split(/\s+/).filter(Boolean),h=l.attrs.class.trim().split(/\s+/).filter(Boolean),x=[...new Set([...m,...h])];y.attrs.class=x.join(" ")}else y.attrs[b]=l.attrs[b]}))):(y.props||(y.props={}),Object.assign(y.props,l)))}function g(l,b){const m=u?a:p;if(V(l)){const h=l.key??b;let x=l.children;m.push({...l,key:h,children:x});return}if(z(l)){m.push(le(l,void 0));return}if(Array.isArray(l)){if(l.length===0)return;for(let h=0;h<l.length;h++){const x=l[h];V(x)||z(x)||Array.isArray(x)?g(x,`${b}-${h}`):x!==null&&typeof x=="object"?S(x):m.push(n(String(x),`${b}-${h}`))}return}if(l!==null&&typeof l=="object"){S(l);return}m.push(n(String(l),b))}for(;d=s.exec(i);)if(d[1]){const l=d[1],b=d[0][1]==="/",m=d[0][d[0].length-2]==="/",{props:h,attrs:x,directives:C}=ce(d[2]||"",t,r),k={props:{},attrs:{}};for(const _ in h)k.props[_]=h[_];for(const _ in x)k.attrs[_]=x[_];for(const[_,$]of Object.entries(C))if(_==="bind")if(typeof $.value=="object"&&$.value!==null)for(const[A,E]of Object.entries($.value))typeof E=="boolean"?k.attrs[A]=E:E!=null&&(k.attrs[A]=String(E));else $.value!=null&&(k.attrs[_]=String($.value));else if(_==="show"){const A=!!$.value;k.attrs.style=(k.attrs.style||"")+(A?"":"; display: none !important")}else if(_==="class"){const A=$.value;let E=[];if(typeof A=="string")E=A.split(/\s+/).filter(Boolean);else if(Array.isArray(A)){for(const L of A)if(typeof L=="string")E.push(...L.split(/\s+/).filter(Boolean));else if(L&&typeof L=="object")for(const[N,M]of Object.entries(L))M&&E.push(...N.split(/\s+/).filter(Boolean))}else if(A&&typeof A=="object")for(const[L,N]of Object.entries(A))N&&E.push(...L.split(/\s+/).filter(Boolean));const B=k.attrs.class||"",O=[...new Set([...B.split(/\s+/).filter(Boolean),...E])];k.attrs.class=O.join(" ")}else if(_==="style"){const A=$.value;let E="";if(typeof A=="string")E=A;else if(A&&typeof A=="object"){const O=[];for(const[L,N]of Object.entries(A))if(N!=null&&N!==""){const M=L.replace(/[A-Z]/g,oe=>`-${oe.toLowerCase()}`),ie=["width","height","top","right","bottom","left","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","font-size","line-height","border-width","border-radius","min-width","max-width","min-height","max-height"];let Q=String(N);typeof N=="number"&&ie.includes(M)&&(Q=`${N}px`),O.push(`${M}: ${Q}`)}E=O.join("; ")+(O.length>0?";":"")}const B=k.attrs.style||"";k.attrs.style=B+(B&&!B.endsWith(";")?"; ":"")+E}const v={};for(const[_,$]of Object.entries(C))["bind","show","class","style"].includes(_)||(v[_]=$);if(Object.keys(v).length>0&&(k.directives=v),b){const _=P(u,y,a.length===1&&z(a[0])&&a[0].tag==="#text"?typeof a[0].children=="string"?a[0].children:"":a.length?a:void 0,f),$=o.pop();$?(u=$.tag,y=$.props,f=$.key,a=$.children,a.push(_)):c=_}else m?(u?a:p).push(P(l,k,void 0,void 0)):(u&&o.push({tag:u,props:y,children:a,key:f}),u=l,y=k,a=[])}else if(typeof d[3]<"u"){const l=Number(d[3]),b=t[l],m=`interp-${l}`;g(b,m)}else if(d[4]){const l=d[4],b=u?a:p,m=l.split(/({{\d+}})/);for(const h of m){if(!h)continue;const x=h.match(/^{{(\d+)}}$/);if(x){const C=Number(x[1]),k=t[C],v=`interp-${C}`;g(k,v)}else{const C=`text-${w++}`;b.push(n(h,C))}}}if(c)return z(c)&&Array.isArray(c.children)&&(c.children=c.children.filter(l=>z(l)?l.tag!=="#text"||typeof l.children=="string"&&l.children.trim()!=="":!0)),c;if(p.length>0){const l=p.filter(b=>z(b)?b.tag!=="#text"||typeof b.children=="string"&&b.children.trim()!=="":!0);return l.length===1?l[0]:l}return P("div",{},"","fallback-root")}function de(e,...t){const r=t[t.length-1],n=typeof r=="object"&&r&&!Array.isArray(r)?r:void 0;return fe(e,t,n)}function ue(e,t){return H(e?t:[],"when-block")}function he(e,t){return e.map((r,n)=>{const i=typeof r=="object"?r?.key??r?.id??`idx-${n}`:String(r);return H(t(r,n),`each-${i}`)})}function pe(){const e=[];return{when(t,r){return e.push([t,r]),this},otherwise(t){return e.push([!0,t]),this},done(){return ge(...e)}}}function ge(...e){for(let t=0;t<e.length;t++){const[r,n]=e[t];if(r)return[H(n,`whenChain-branch-${t}`)]}return[H([],"whenChain-empty")]}function H(e,t){const r=e?Array.isArray(e)?e.filter(Boolean):[e].filter(Boolean):[];return{tag:"#anchor",key:t,children:r}}function j(e,t){return t.split(".").reduce((r,n)=>r?.[n],e)}function X(e,t,r){const n=t.split("."),i=n.pop();if(!i)return;const s=n.reduce((o,c)=>(c in o||(o[c]={}),o[c]),e);s[i]=r}function me(e,t,r,n,i,s,o){if(!s)return;const c=t.includes("lazy"),d=t.includes("trim"),a=t.includes("number"),u=()=>{const g=s._state||s;return j(g,e)},y=u();let f="text";const w=n?.type;if(o instanceof HTMLInputElement?f=w||o.type||"text":o instanceof HTMLSelectElement?f="select":o instanceof HTMLTextAreaElement&&(f="textarea"),f==="checkbox")if(Array.isArray(y)){const g=o?.getAttribute("value")||n?.value||"",l=y.includes(g);o&&o.checked!==l&&(r.checked=l)}else{const g=o?.getAttribute("true-value")||!0,l=y===g;o&&o.checked!==l&&(r.checked=l)}else if(f==="radio"){const g=n?.value||"",l=y===g;o&&o.checked!==l&&(r.checked=l)}else if(f==="select")if(o&&o.hasAttribute("multiple")){const g=o,l=Array.isArray(y)?y:[];setTimeout(()=>{Array.from(g.options).forEach(b=>{const m=l.includes(b.value);b.selected!==m&&(b.selected=m)})},0)}else setTimeout(()=>{o instanceof HTMLSelectElement&&o.value!==String(y)&&(o.value=String(y))},0);else{const g=String(y??"");(!o||o.value!==g)&&(r.value=y)}const p=c||f==="checkbox"||f==="radio"||f==="select"?"change":"input",S=g=>{if(g.isComposing||i._isComposing||g.isTrusted===!1)return;const l=g.target;if(l._modelUpdating)return;const b=u();let m=l.value;if(f==="checkbox")if(Array.isArray(b)){const k=l.getAttribute("value")||"",v=[...b];if(l.checked)v.includes(k)||v.push(k);else{const _=v.indexOf(k);_>-1&&v.splice(_,1)}m=v}else{const k=l.getAttribute("true-value")||!0,v=l.getAttribute("false-value")||!1;m=l.checked?k:v}else if(f==="radio")m=l.getAttribute("value")||l.value;else if(f==="select"&&l.multiple){const k=l;m=Array.from(k.selectedOptions).map(v=>v.value)}else if(d&&(m=m.trim()),a){const k=Number(m);isNaN(k)||(m=k)}const h=s._state||s,x=j(h,e);if(Array.isArray(m)&&Array.isArray(x)?JSON.stringify([...m].sort())!==JSON.stringify([...x].sort()):m!==x){const k=g.target;k._modelUpdating=!0,X(h,e,m),setTimeout(()=>{k._modelUpdating=!1},0),s._requestRender&&s._requestRender()}};if(i[p]=S,f==="text"||f==="textarea"){const g=()=>{i._isComposing=!0},l=b=>{i._isComposing=!1;const m=b.target;setTimeout(()=>{if(m){let h=m.value;if(d&&(h=h.trim()),a){const v=Number(h);isNaN(v)||(h=v)}const x=s._state||s,C=j(x,e);(Array.isArray(h)&&Array.isArray(C)?JSON.stringify([...h].sort())!==JSON.stringify([...C].sort()):h!==C)&&(m&&(m._modelUpdating=!0,setTimeout(()=>{m._modelUpdating=!1},0)),X(x,e,h),s._requestRender&&s._requestRender())}},0)};i.compositionstart=g,i.compositionend=l}}function ye(e,t,r,n){if(n)try{const i=JSON.parse(e);if(typeof i=="object")for(const[s,o]of Object.entries(i))t[s]=o}catch{const i=j(n,e);r[e]=i}}function be(e,t,r){if(!r)return;const n=j(r,e),i=t.style||"",s=n?"":"none";if(i){const o=i.split(";").filter(Boolean),c=o.findIndex(d=>d.trim().startsWith("display:"));c>=0?o[c]=`display: ${s}`:o.push(`display: ${s}`),t.style=o.join("; ")}else t.style=`display: ${s}`}function xe(e,t,r){if(!r)return;const n=j(r,e);let i=[];typeof n=="string"?i=[n]:Array.isArray(n)?i=n.filter(Boolean):typeof n=="object"&&(i=Object.entries(n).filter(([,c])=>!!c).map(([c])=>c));const s=t.class||"",o=s?`${s} ${i.join(" ")}`.trim():i.join(" ");o&&(t.class=o)}function ve(e,t,r){let n;if(typeof e=="string"){if(!r)return;n=j(r,e)}else n=e;let i="";if(typeof n=="string")i=n;else if(n&&typeof n=="object"){const o=[];for(const[c,d]of Object.entries(n))if(d!=null&&d!==""){const a=c.replace(/[A-Z]/g,f=>`-${f.toLowerCase()}`),u=["width","height","top","right","bottom","left","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","font-size","line-height","border-width","border-radius","min-width","max-width","min-height","max-height"];let y=String(d);typeof d=="number"&&u.includes(a)&&(y=`${d}px`),o.push(`${a}: ${y}`)}i=o.join("; ")+(o.length>0?";":"")}const s=t.style||"";t.style=s+(s&&!s.endsWith(";")?"; ":"")+i}function re(e,t,r,n){const i={},s={...n||{}},o={};for(const[c,d]of Object.entries(e)){const{value:a,modifiers:u}=d;switch(c){case"model":me(typeof a=="string"?a:String(a),u,i,s,o,t,r);break;case"bind":ye(a,i,s,t);break;case"show":be(a,s,t);break;case"class":xe(a,s,t);break;case"style":ve(a,s,t);break}}return{props:i,attrs:s,listeners:o}}function J(e,t){if(Array.isArray(e)){const s=new Set;return e.map(o=>{if(!o||typeof o!="object")return o;let c=o.props?.key??o.key;if(!c){const y=o.tag||"node",f=o.props?.attrs?.id??o.props?.attrs?.name??o.props?.attrs?.["data-key"]??"";c=f?`${t}:${y}:${f}`:`${t}:${y}`}let d=c,a=1;for(;s.has(d);)d=`${c}#${a++}`;s.add(d);let u=o.children;return Array.isArray(u)&&(u=J(u,d)),{...o,key:d,children:u}})}const r=e;let n=r.props?.key??r.key??t,i=r.children;return Array.isArray(i)&&(i=J(i,n)),{...r,key:n,children:i}}function we(e,t,r,n){const i=r.directives??{},s=re(i,n,e,r.attrs),o={...t.props,...r.props,...s.props},c={...t.attrs,...r.attrs,...s.attrs},d=t.props??{},a=o;for(const f in{...d,...a}){const w=d[f],p=a[f];w!==p&&(f==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value!==p&&(e.value=p??""):f==="checked"&&e instanceof HTMLInputElement?e.checked=!!p:f.startsWith("on")&&typeof p=="function"?(typeof w=="function"&&e.removeEventListener(f.slice(2).toLowerCase(),w),e.addEventListener(f.slice(2).toLowerCase(),p)):p==null||p===!1?e.removeAttribute(f):e.setAttribute(f,String(p)))}for(const[f,w]of Object.entries(s.listeners||{}))e.addEventListener(f,w);const u=t.attrs??{},y=c;for(const f in{...u,...y}){const w=u[f],p=y[f];w!==p&&(p==null||p===!1?e.removeAttribute(f):e.setAttribute(f,String(p)))}}function T(e,t){if(typeof e=="string")return document.createTextNode(e);if(e.tag==="#text"){const a=document.createTextNode(typeof e.children=="string"?e.children:"");return e.key!=null&&(a.key=e.key),a}if(e.tag==="#anchor"){const a=e,u=Array.isArray(a.children)?a.children:[],y=document.createTextNode(""),f=document.createTextNode("");a.key!=null&&(y.key=`${a.key}:start`,f.key=`${a.key}:end`),a._startNode=y,a._endNode=f;const w=document.createDocumentFragment();w.appendChild(y);for(const p of u)w.appendChild(T(p,t));return w.appendChild(f),w}const r=document.createElement(e.tag);e.key!=null&&(r.key=e.key);const{props:n={},attrs:i={},directives:s={}}=e.props??{},o=re(s,t,r,i),c={...n,...o.props},d={...i,...o.attrs};for(const a in d){const u=d[a];typeof u=="boolean"?u&&r.setAttribute(a,""):u!=null&&r.setAttribute(a,String(u))}for(const a in c){const u=c[a];if(a==="value"&&(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement))r.value=u??"";else if(a==="checked"&&r instanceof HTMLInputElement)r.checked=!!u;else if(a.startsWith("on")&&typeof u=="function")r.addEventListener(a.slice(2).toLowerCase(),u);else{if(a.startsWith("on")&&u===void 0)continue;u==null||u===!1?r.removeAttribute(a):r.setAttribute(a,String(u))}}for(const[a,u]of Object.entries(o.listeners||{}))r.addEventListener(a,u);if(Array.isArray(e.children))for(const a of e.children)r.appendChild(T(a,t));else typeof e.children=="string"&&(r.textContent=e.children);return r}function ke(e,t,r,n){if(typeof r=="string"){e.textContent!==r&&(e.textContent=r);return}if(!Array.isArray(r))return;const i=Array.from(e.childNodes),s=Array.isArray(t)?t:[],o=new Map;for(const f of s)f&&f.key!=null&&o.set(f.key,f);const c=new Map;for(const f of i){const w=f.key;w!=null&&c.set(w,f)}const d=new Set;let a=e.firstChild;function u(f,w){let p=f;for(;p&&(d.add(p),p!==w);)p=p.nextSibling}function y(f,w,p,S){const g=[];let l=f.nextSibling;for(;l&&l!==w;)g.push(l),l=l.nextSibling;const b=Array.isArray(p)?p:[];if(S.some(h=>h&&h.key!=null)||b.some(h=>h&&h.key!=null)){const h=new Map,x=new Map;for(const v of b)v&&v.key!=null&&h.set(v.key,v);for(const v of g){const _=v.key;_!=null&&x.set(_,v)}const C=new Set;let k=f.nextSibling;for(const v of S){let _;if(v.key!=null&&x.has(v.key)){const $=h.get(v.key);_=I(x.get(v.key),$,v,n),C.add(_),_!==k&&e.contains(_)&&e.insertBefore(_,k)}else _=T(v,n),e.insertBefore(_,k),C.add(_);k=_.nextSibling}for(const v of g)!C.has(v)&&e.contains(v)&&e.removeChild(v)}else{const h=Math.min(b.length,S.length);for(let x=0;x<h;x++){const C=b[x],k=S[x],v=I(g[x],C,k,n);v!==g[x]&&(e.insertBefore(v,g[x]),e.removeChild(g[x]))}for(let x=h;x<S.length;x++)e.insertBefore(T(S[x],n),w);for(let x=h;x<g.length;x++)e.removeChild(g[x])}}for(const f of r){let w;if(f.tag==="#anchor"){const p=f.key,S=`${p}:start`,g=`${p}:end`;let l=c.get(S),b=c.get(g);const m=Array.isArray(f.children)?f.children:[];if(l||(l=document.createTextNode(""),l.key=S),b||(b=document.createTextNode(""),b.key=g),f._startNode=l,f._endNode=b,!e.contains(l)||!e.contains(b)){e.insertBefore(l,a);for(const h of m)e.insertBefore(T(h,n),a);e.insertBefore(b,a)}else y(l,b,o.get(p)?.children,m);u(l,b),a=b.nextSibling;continue}if(f.key!=null&&c.has(f.key)){const p=o.get(f.key);w=I(c.get(f.key),p,f,n),d.add(w),w!==a&&e.contains(w)&&(a&&!e.contains(a)&&(a=null),e.insertBefore(w,a))}else w=T(f,n),a&&!e.contains(a)&&(a=null),e.insertBefore(w,a),d.add(w);a=w.nextSibling}for(const f of i)!d.has(f)&&e.contains(f)&&e.removeChild(f)}function I(e,t,r,n){if(t===r)return e;if(typeof r=="string"){if(e.nodeType===Node.TEXT_NODE)return e.textContent!==r&&(e.textContent=r),e;{const s=document.createTextNode(r);return e.parentNode?.replaceChild(s,e),s}}if(r&&typeof r!="string"&&r.tag==="#anchor"){const s=r,o=Array.isArray(s.children)?s.children:[],c=s._startNode??document.createTextNode(""),d=s._endNode??document.createTextNode("");s.key!=null&&(c.key=`${s.key}:start`,d.key=`${s.key}:end`),s._startNode=c,s._endNode=d;const a=document.createDocumentFragment();a.appendChild(c);for(const u of o)a.appendChild(T(u,n));return a.appendChild(d),e.parentNode?.replaceChild(a,e),c}if(!r){const s=document.createComment("removed");return e.parentNode?.replaceChild(s,e),s}if(!t||typeof t=="string"){const s=T(r,n);return e.parentNode?.replaceChild(s,e),s}if(r.tag==="#anchor"){const s=Array.isArray(r.children)?r.children:[],o=r._startNode??document.createTextNode(""),c=r._endNode??document.createTextNode("");r.key!=null&&(o.key=`${r.key}:start`,c.key=`${r.key}:end`),r._startNode=o,r._endNode=c;const d=document.createDocumentFragment();d.appendChild(o);for(const a of s)d.appendChild(T(a,n));return d.appendChild(c),e.parentNode?.replaceChild(d,e),o}if(typeof t!="string"&&typeof r!="string"&&t.tag===r.tag&&t.key===r.key){const s=e;return we(s,t.props||{},r.props||{},n),ke(s,t.children,r.children,n),s}const i=T(r,n);return e.parentNode?.replaceChild(i,e),i}function _e(e,t,r){const n=a=>a.key==null?{...a,key:"__root__"}:a;let i=Array.isArray(t)?{tag:"div",key:"__root__",children:t}:n(t);i=J(i,String(i.key??"root"));const s=e._prevVNode??null,o=e._prevDom??e.firstChild??null;let c;s&&o?typeof s!="string"&&typeof i!="string"&&s.tag===i.tag&&s.key===i.key?c=I(o,s,i,r):(c=T(i,r),e.replaceChild(c,o)):(c=T(i,r),e.firstChild?e.replaceChild(c,e.firstChild):e.appendChild(c));const d=[];for(let a=0;a<e.childNodes.length;a++){const u=e.childNodes[a];u!==c&&u.nodeName!=="STYLE"&&d.push(u)}d.forEach(a=>e.removeChild(a)),e._prevVNode=i,e._prevDom=c}function $e(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,>+~])\s*/g,"$1").replace(/;}/g,"}").trim()}const Se=`
2
+ :host {
3
+ box-sizing:border-box;
4
+ line-height:1.5;
5
+ font-family:ui-sans-serif,system-ui,sans-serif;
6
+ -webkit-text-size-adjust:100%;
7
+ text-size-adjust:100%;
8
+ }
9
+ *,::before,::after {
10
+ box-sizing:inherit;
11
+ margin:0;
12
+ padding:0;
13
+ border:0 solid currentColor;
14
+ }
15
+ `,Ce={gray:{50:"var(--color-gray-50, #f9fafb)",100:"var(--color-gray-100, #f3f4f6)",200:"var(--color-gray-200, #e5e7eb)",300:"var(--color-gray-300, #d1d5db)",400:"var(--color-gray-400, #9ca3af)",500:"var(--color-gray-500, #6b7280)",600:"var(--color-gray-600, #4b5563)",700:"var(--color-gray-700, #374151)",800:"var(--color-gray-800, #1f2937)",900:"var(--color-gray-900, #111827)"},slate:{50:"var(--color-slate-50, #f8fafc)",100:"var(--color-slate-100, #f1f5f9)",200:"var(--color-slate-200, #e2e8f0)",300:"var(--color-slate-300, #cbd5e1)",400:"var(--color-slate-400, #94a3b8)",500:"var(--color-slate-500, #64748b)",600:"var(--color-slate-600, #475569)",700:"var(--color-slate-700, #334155)",800:"var(--color-slate-800, #1e293b)",900:"var(--color-slate-900, #0f172a)"},zinc:{50:"var(--color-zinc-50, #fafafa)",100:"var(--color-zinc-100, #f4f4f5)",200:"var(--color-zinc-200, #e4e4e7)",300:"var(--color-zinc-300, #d4d4d8)",400:"var(--color-zinc-400, #a1a1aa)",500:"var(--color-zinc-500, #71717a)",600:"var(--color-zinc-600, #52525b)",700:"var(--color-zinc-700, #3f3f46)",800:"var(--color-zinc-800, #27272a)",900:"var(--color-zinc-900, #18181b)"},red:{50:"var(--color-red-50, #fef2f2)",100:"var(--color-red-100, #fee2e2)",200:"var(--color-red-200, #fecaca)",300:"var(--color-red-300, #fca5a5)",400:"var(--color-red-400, #f87171)",500:"var(--color-red-500, #ef4444)",600:"var(--color-red-600, #dc2626)",700:"var(--color-red-700, #b91c1c)",800:"var(--color-red-800, #991b1b)",900:"var(--color-red-900, #7f1d1d)"},blue:{50:"var(--color-blue-50, #eff6ff)",100:"var(--color-blue-100, #dbeafe)",200:"var(--color-blue-200, #bfdbfe)",300:"var(--color-blue-300, #93c5fd)",400:"var(--color-blue-400, #60a5fa)",500:"var(--color-blue-500, #3b82f6)",600:"var(--color-blue-600, #2563eb)",700:"var(--color-blue-700, #1d4ed8)",800:"var(--color-blue-800, #1e40af)",900:"var(--color-blue-900, #1e3a8a)"},green:{50:"var(--color-green-50, #f0fdf4)",100:"var(--color-green-100, #dcfce7)",200:"var(--color-green-200, #bbf7d0)",300:"var(--color-green-300, #86efac)",400:"var(--color-green-400, #4ade80)",500:"var(--color-green-500, #22c55e)",600:"var(--color-green-600, #16a34a)",700:"var(--color-green-700, #15803d)",800:"var(--color-green-800, #166534)",900:"var(--color-green-900, #14532d)"},amber:{50:"var(--color-amber-50, #fffbeb)",100:"var(--color-amber-100, #fef3c7)",200:"var(--color-amber-200, #fde68a)",300:"var(--color-amber-300, #fcd34d)",400:"var(--color-amber-400, #fbbf24)",500:"var(--color-amber-500, #f59e0b)",600:"var(--color-amber-600, #d97706)",700:"var(--color-amber-700, #b45309)",800:"var(--color-amber-800, #92400e)",900:"var(--color-amber-900, #78350f)"},indigo:{50:"var(--color-indigo-50, #eef2ff)",100:"var(--color-indigo-100, #e0e7ff)",200:"var(--color-indigo-200, #c7d2fe)",300:"var(--color-indigo-300, #a5b4fc)",400:"var(--color-indigo-400, #818cf8)",500:"var(--color-indigo-500, #6366f1)",600:"var(--color-indigo-600, #4f46e5)",700:"var(--color-indigo-700, #4338ca)",800:"var(--color-indigo-800, #3730a3)",900:"var(--color-indigo-900, #312e81)"},emerald:{50:"var(--color-emerald-50, #ecfdf5)",100:"var(--color-emerald-100, #d1fae5)",200:"var(--color-emerald-200, #a7f3d0)",300:"var(--color-emerald-300, #6ee7b7)",400:"var(--color-emerald-400, #34d399)",500:"var(--color-emerald-500, #10b981)",600:"var(--color-emerald-600, #059669)",700:"var(--color-emerald-700, #047857)",800:"var(--color-emerald-800, #065f46)",900:"var(--color-emerald-900, #064e3b)"},rose:{50:"var(--color-rose-50, #fff1f2)",100:"var(--color-rose-100, #ffe4e6)",200:"var(--color-rose-200, #fecdd3)",300:"var(--color-rose-300, #fda4af)",400:"var(--color-rose-400, #fb7185)",500:"var(--color-rose-500, #f43f5e)",600:"var(--color-rose-600, #e11d48)",700:"var(--color-rose-700, #be123c)",800:"var(--color-rose-800, #9f1239)",900:"var(--color-rose-900, #881337)"},white:{DEFAULT:"var(--color-white, #ffffff)"},black:{DEFAULT:"var(--color-black, #000000)"}},W={block:"display:block;",inline:"display:inline;","inline-block":"display:inline-block;",flex:"display:flex;","inline-flex":"display:inline-flex;",grid:"display:grid;",hidden:"display:none;","sr-only":"position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0;","not-sr-only":"position:static;width:auto;height:auto;padding:0;margin:0;overflow:visible;clip:auto;white-space:normal;","grid-cols-1":"grid-template-columns:repeat(1,minmax(0,1fr));","grid-cols-2":"grid-template-columns:repeat(2,minmax(0,1fr));","grid-cols-3":"grid-template-columns:repeat(3,minmax(0,1fr));","grid-cols-4":"grid-template-columns:repeat(4,minmax(0,1fr));","grid-cols-5":"grid-template-columns:repeat(5,minmax(0,1fr));","grid-cols-6":"grid-template-columns:repeat(6,minmax(0,1fr));","grid-cols-12":"grid-template-columns:repeat(12,minmax(0,1fr));","grid-rows-1":"grid-template-rows:repeat(1,minmax(0,1fr));","grid-rows-2":"grid-template-rows:repeat(2,minmax(0,1fr));","grid-rows-3":"grid-template-rows:repeat(3,minmax(0,1fr));","grid-rows-4":"grid-template-rows:repeat(4,minmax(0,1fr));","grid-rows-6":"grid-template-rows:repeat(6,minmax(0,1fr));","grid-rows-12":"grid-template-rows:repeat(12,minmax(0,1fr));","col-span-1":"grid-column:span 1 / span 1;","col-span-2":"grid-column:span 2 / span 2;","col-span-3":"grid-column:span 3 / span 3;","col-span-4":"grid-column:span 4 / span 4;","col-span-5":"grid-column:span 5 / span 5;","col-span-6":"grid-column:span 6 / span 6;","col-span-12":"grid-column:span 12 / span 12;","row-span-1":"grid-row:span 1 / span 1;","row-span-2":"grid-row:span 2 / span 2;","row-span-3":"grid-row:span 3 / span 3;","row-span-4":"grid-row:span 4 / span 4;","row-span-6":"grid-row:span 6 / span 6;","row-span-12":"grid-row:span 12 / span 12;",absolute:"position:absolute;",relative:"position:relative;",fixed:"position:fixed;",sticky:"position:sticky;","font-bold":"font-weight:700;","font-semibold":"font-weight:600;","font-medium":"font-weight:500;","font-light":"font-weight:300;",underline:"text-decoration-line:underline;",overline:"text-decoration-line:overline;","line-through":"text-decoration-line:line-through;","no-underline":"text-decoration-line:none;",italic:"font-style:italic;","not-italic":"font-style:normal;",uppercase:"text-transform:uppercase;",lowercase:"text-transform:lowercase;",capitalize:"text-transform:capitalize;","normal-case":"text-transform:none;","text-left":"text-align:left;","text-center":"text-align:center;","text-right":"text-align:right;","text-xs":"font-size:0.75rem;line-height:calc(1 / 0.75)","text-sm":"font-size:0.875rem;line-height:calc(1.25 / 0.875)","text-base":"font-size:1rem;line-height:calc(1.5 / 1)","text-lg":"font-size:1.125rem;line-height:calc(1.75 / 1.125)","text-xl":"font-size:1.25rem;line-height:calc(1.75 / 1.25)","text-2xl":"font-size:1.5rem;line-height:calc(2 / 1.5)","text-3xl":"font-size:1.875rem;line-height:calc(2.25 / 1.875)","text-4xl":"font-size:2.25rem;line-height:calc(2.5 / 2.25)","text-5xl":"font-size:3rem;line-height:1","text-6xl":"font-size:3.75rem;line-height:1","text-7xl":"font-size:4.5rem;line-height:1","text-8xl":"font-size:6rem;line-height:1",border:"border-width:1px;","rounded-none":"border-radius:0;","rounded-xs":"border-radius:0.125rem;","rounded-sm":"border-radius:0.25rem;","rounded-md":"border-radius:0.375rem;","rounded-lg":"border-radius:0.5rem;","rounded-full":"border-radius:9999px;","ring-0":"box-shadow:none;","ring-1":"box-shadow:0 0 0 1px rgba(59,130,246,0.5);","ring-2":"box-shadow:0 0 0 2px rgba(59,130,246,0.5);","ring-4":"box-shadow:0 0 0 4px rgba(59,130,246,0.5);","ring-8":"box-shadow:0 0 0 8px rgba(59,130,246,0.5);","shadow-none":"box-shadow:0 0 #0000;","shadow-xs":"box-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05);","shadow-sm":"box-shadow:0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);","shadow-md":"box-shadow:0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);","shadow-lg":"box-shadow:0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);","shadow-xl":"box-shadow:0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);","shadow-2xl":"box-shadow:0 25px 50px -12px rgb(0 0 0 / 0.25);",transition:"transition-property:all;transition-duration:150ms;transition-timing-function:cubic-bezier(0.4,0,0.2,1);",truncate:"overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",visible:"visibility:visible;",invisible:"visibility:hidden;",grow:"flex-grow:1;",shrink:"flex-shrink:1;","grow-0":"flex-grow:0;","shrink-0":"flex-shrink:0;","font-sans":"font-family:ui-sans-serif,system-ui,sans-serif;","font-serif":"font-family:ui-serif,Georgia,serif;","font-mono":"font-family:ui-monospace,SFMono-Regular,monospace;","line-clamp-1":"display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical;overflow:hidden;","line-clamp-2":"display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;","line-clamp-3":"display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;","line-clamp-4":"display:-webkit-box;-webkit-line-clamp:4;-webkit-box-orient:vertical;overflow:hidden;","transition-colors":"transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;","transition-opacity":"transition-property:opacity;","transition-transform":"transition-property:transform;"},Ae="0.25rem",Y={m:["margin"],mx:["margin-inline"],my:["margin-block"],mt:["margin-top"],mr:["margin-right"],mb:["margin-bottom"],ml:["margin-left"],p:["padding"],px:["padding-inline"],py:["padding-block"],pt:["padding-top"],pr:["padding-right"],pb:["padding-bottom"],pl:["padding-left"],inset:["inset"],"inset-x":["inset-inline"],"inset-y":["inset-block"],top:["top"],bottom:["bottom"],left:["left"],right:["right"],gap:["gap"],"gap-x":["column-gap"],"gap-y":["row-gap"]},Ee={before:(e,t)=>`${e}::before{${t}}`,after:(e,t)=>`${e}::after{${t}}`,hover:(e,t)=>`${e}:hover{${t}}`,focus:(e,t)=>`${e}:focus{${t}}`,active:(e,t)=>`${e}:active{${t}}`,disabled:(e,t)=>`${e}:disabled{${t}}`,visited:(e,t)=>`${e}:visited{${t}}`,checked:(e,t)=>`${e}:checked{${t}}`,first:(e,t)=>`${e}:first-child{${t}}`,last:(e,t)=>`${e}:last-child{${t}}`,odd:(e,t)=>`${e}:nth-child(odd){${t}}`,even:(e,t)=>`${e}:nth-child(even){${t}}`,"focus-within":(e,t)=>`${e}:focus-within{${t}}`,"focus-visible":(e,t)=>`${e}:focus-visible{${t}}`,"group-hover":(e,t)=>`.group:hover ${e}{${t}}`,"group-focus":(e,t)=>`.group:focus ${e}{${t}}`,"group-active":(e,t)=>`.group:active ${e}{${t}}`,"group-disabled":(e,t)=>`.group:disabled ${e}{${t}}`,"peer-hover":(e,t)=>`.peer:hover ~ ${e}{${t}}`,"peer-focus":(e,t)=>`.peer:focus ~ ${e}{${t}}`,"peer-checked":(e,t)=>`.peer:checked ~ ${e}{${t}}`,"peer-disabled":(e,t)=>`.peer:disabled ~ ${e}{${t}}`},G={sm:"(min-width:640px)",md:"(min-width:768px)",lg:"(min-width:1024px)",xl:"(min-width:1280px)","2xl":"(min-width:1536px)",dark:"(prefers-color-scheme: dark)"},K=["sm","md","lg","xl","2xl"];function F(e){const t=e.startsWith("-"),n=(t?e.slice(1):e).split("-");if(n.length<2)return null;const i=n.slice(0,-1).join("-"),s=n[n.length-1],o=parseFloat(s);if(Number.isNaN(o)||!Y[i])return null;const c=t?"-":"";return Y[i].map(d=>`${d}:calc(${c}${Ae} * ${o});`).join("")}function ee(e){const t=e.replace("#",""),r=parseInt(t,16),n=r>>16&255,i=r>>8&255,s=r&255;return`${n} ${i} ${s}`}function Te(e){const t=/^(bg|text|border|shadow|outline|caret|accent)-([a-z]+)-?(\d{2,3}|DEFAULT)?$/.exec(e);if(!t)return null;const[,r,n,i="DEFAULT"]=t,s=Ce[n]?.[i];return s?`${{bg:"background-color",text:"color",border:"border-color",shadow:"box-shadow",outline:"outline-color",caret:"caret-color",accent:"accent-color"}[r]}:${s};`:null}function Le(e){const[t,r]=e.split("/");if(!r)return{base:t};const n=parseInt(r,10);return isNaN(n)||n<0||n>100?{base:t}:{base:t,opacity:n/100}}function U(e){const{base:t,opacity:r}=Le(e),n=Te(t);if(n){if(r!==void 0){const s=/#([0-9a-f]{6})/i.exec(n);if(s){const o=ee(s[0]);return n.replace(/#([0-9a-f]{6})/i,`rgb(${o} / ${r})`)}}return n}const i=D(t);if(i&&r!==void 0){const s=/#([0-9a-f]{6})/i.exec(i);if(s){const o=ee(s[0]);return i.replace(/#([0-9a-f]{6})/i,`rgb(${o} / ${r})`)}}return i}function D(e){const t=e.indexOf("-["),r=e.endsWith("]");if(t>0&&r){const n=e.slice(0,t);let i=e.slice(t+2,-1);i=i.replace(/_/g," ");const o={bg:"background-color",text:"color",p:"padding",px:"padding-inline",py:"padding-block",m:"margin",mx:"margin-inline",my:"margin-block",w:"width",h:"height","min-w":"min-width","max-w":"max-width","min-h":"min-height","max-h":"max-height","border-t":"border-top","border-b":"border-bottom","border-l":"border-left","border-r":"border-right","border-x":"border-inline","border-y":"border-block",shadow:"box-shadow",duration:"transition-duration",list:"list-style",break:"word-break",flex:"flex-direction",items:"align-items",justify:"justify-content",whitespace:"white-space",select:"user-select",content:"align-content",self:"align-self",basis:"flex-basis",tracking:"letter-spacing",scroll:"scroll-behavior",delay:"transition-delay",weight:"font-weight",leading:"line-height",z:"z-index"}[n]??n.replace(/_/g,"-");if(o&&i)return`${o}:${i};`}return null}function Ne(e){return e.replace(/([!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}function je(e){const t=/class\s*=\s*["']([^"']+)["']/g,r=[];let n;for(;n=t.exec(e);){let i="",s=!1;for(const o of n[1])o==="["&&(s=!0),o==="]"&&(s=!1),o===" "&&!s?(i&&r.push(i),i=""):i+=o;i&&r.push(i)}return r.filter(Boolean)}const te=new Map,ze=16;function Re(e){const t=Date.now(),r=te.get(e);if(r&&t-r.timestamp<ze)return r.css;const n=je(e),i=new Set(n),s=[],o=[],c=[],d=[],a={};function u(p,S=!1){const g=(S?"dark|":"")+p;if(g in a)return a[g];const l=f(p,S);return a[g]=l,l}function y(p){const S=p.some(l=>K.includes(l)),g=p.includes("dark");return p.length===0?1:!S&&!g?2:S&&!g?3:4}function f(p,S=!1){const g=p.split(":"),l=g.find($=>W[$]||F($)||U($)||D($));if(!l)return null;const b=W[l]??F(l)??U(l)??D(l);if(!b)return null;let m=`.${Ne(p)}`,h=b;const x=g.indexOf(l);let C=x>=0?g.slice(0,x):[];S&&(C=C.filter($=>$!=="dark"));const k=C.filter($=>K.includes($)),v=k.length?k[k.length-1]:null;for(const $ of C){if(K.includes($))continue;const A=Ee[$];typeof A=="function"&&(m=A(m,h).replace(/\{.*$/,""))}let _=`${m}{${h}}`;return S&&v?_=`@media (prefers-color-scheme: dark) and ${G[v]}{${_}}`:S?_=`@media (prefers-color-scheme: dark){${_}}`:v&&(_=`@media ${G[v]}{${_}}`),_}for(const p of i){const S=p.split(":"),g=S.find(h=>W[h]||F(h)||U(h)||D(h));if(!g)continue;const l=S.indexOf(g),b=l>=0?S.slice(0,l):[],m=y(b);if(m===4){const h=u(p,!0);h&&d.push(h)}else{const h=u(p);h&&(m===1?s.push(h):m===2?o.push(h):m===3&&c.push(h))}}const w=[...s,...o,...c,...d].join("");return te.set(e,{css:w,timestamp:t}),w}const Be=new Map;function Z(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function q(e){return typeof e=="string"?e.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t]):e}function Oe(e){return e.replace(/url\s*\(\s*['"]?javascript:[^)]*\)/gi,"").replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi,"").replace(/expression\s*\([^)]*\)/gi,"")}function Me(e,...t){let r="";for(let n=0;n<e.length;n++)r+=e[n],n<t.length&&(r+=t[n]);return r}function Pe(e,t,r){let n=Z(e);n.includes("-")||(n=`cer-${n}`);let i;typeof t=="function"?i={...r,render:t}:i=t,typeof i.onError!="function"&&(i.onError=(s,o)=>{console.error(`[${n}] Error:`,s,o)}),Be.set(n,i),typeof window<"u"&&!customElements.get(n)&&customElements.define(n,ne(i))}function ne(e){if(!e.render)throw new Error("Component must have a render function");return typeof window>"u"?class{constructor(){}}:class extends HTMLElement{context;_listeners=[];_watchers=new Map;_renderTimeoutId=null;_mounted=!1;_hasError=!1;_initializing=!0;_styleSheet=null;_lastHtmlStringForJitCSS="";_cfg;_lastRenderTime=0;_renderCount=0;_templateLoading=!1;_templateError=null;constructor(){super(),this.attachShadow({mode:"open"}),this._cfg=e,this.context=this._initContext(e),Object.keys(e).forEach(t=>{const r=e[t];typeof r=="function"&&!t.startsWith("on")&&(this.context[t]=(...n)=>r(...n,this.context))}),this._applyProps(e),this._applyComputed(e),this._initializing=!1,this._initWatchers(e),this._render(e)}connectedCallback(){this._runLogicWithinErrorBoundary(e,()=>{e.onConnected&&!this._mounted&&(e.onConnected(this.context),this._mounted=!0)})}disconnectedCallback(){this._runLogicWithinErrorBoundary(e,()=>{e.onDisconnected&&e.onDisconnected(this.context),this._listeners.forEach(t=>t()),this._listeners=[],this._watchers.clear(),this._templateLoading=!1,this._templateError=null,this._mounted=!1})}attributeChangedCallback(t,r,n){this._runLogicWithinErrorBoundary(e,()=>{this._applyProps(e),e.onAttributeChanged&&e.onAttributeChanged(t,r,n,this.context)})}static get observedAttributes(){return e.props?Object.keys(e.props).map(Z):[]}_applyComputed(t){this._runLogicWithinErrorBoundary(e,()=>{t.computed&&Object.entries(t.computed).forEach(([r,n])=>{Object.defineProperty(this.context,r,{get:()=>{const i=n(this.context);return q(i)},enumerable:!0})})})}_render(t){this._runLogicWithinErrorBoundary(t,()=>{if(!this.shadowRoot)return;if(this._templateLoading&&t.loadingTemplate){this._renderOutput(t.loadingTemplate(this.context));return}if(this._templateError&&t.errorTemplate){this._renderOutput(t.errorTemplate(this._templateError,this.context));return}const r=t.render(this.context);if(r instanceof Promise){this._templateLoading=!0,r.then(n=>(this._templateLoading=!1,this._templateError=null,this._renderOutput(n),n)).catch(n=>{if(this._templateLoading=!1,this._templateError=n,t.errorTemplate){const i=t.errorTemplate(n,this.context);return this._renderOutput(i),i}throw n}),t.loadingTemplate&&this._renderOutput(t.loadingTemplate(this.context));return}this._renderOutput(r),this._applyStyle(t)})}_renderOutput(t){if(!this.shadowRoot)return;const r=new Proxy(this.context,{get:(n,i)=>i==="_requestRender"?()=>this._requestRender():i==="context"?n:typeof i=="string"&&i.includes(".")?i.split(".").reduce((s,o)=>s?.[o],n):n[i],set:(n,i,s)=>{if(typeof i=="string"&&i.includes(".")){const o=i.split("."),c=o.pop();if(!c)return!1;const d=o.reduce((a,u)=>(u in a||(a[u]={}),a[u]),n);return d[c]=s,!0}return n[i]=s,!0}});_e(this.shadowRoot,Array.isArray(t)?t:[t],r),this._lastHtmlStringForJitCSS=this.shadowRoot.innerHTML}_requestRender(){if(this._renderTimeoutId!==null&&clearTimeout(this._renderTimeoutId),Date.now()-this._lastRenderTime<16){if(this._renderCount++,this._renderCount>10){console.warn(`[${this.tagName}] Potential infinite render loop detected. Skipping render.`),this._renderTimeoutId=null;return}}else this._renderCount=0;this._renderTimeoutId=setTimeout(()=>{this._lastRenderTime=Date.now(),this._render(this._cfg),this._renderTimeoutId=null},0)}_applyStyle(t){this._runLogicWithinErrorBoundary(t,()=>{if(!this.shadowRoot)return;const r=Re(this._lastHtmlStringForJitCSS);if(!t.style&&(!r||r.trim()==="")){this._styleSheet=null;return}let n="";t.style&&(typeof t.style=="string"?n=t.style:typeof t.style=="function"&&(n=t.style(this.context)));let i=Oe(`${Se}
16
+ ${n}
17
+ ${r}
18
+ `);t.minifyCSS&&(i=$e(i)),this._styleSheet||(this._styleSheet=new CSSStyleSheet),this._styleSheet.replaceSync(i),this.shadowRoot.adoptedStyleSheets=[this._styleSheet]})}_runLogicWithinErrorBoundary(t,r){this._hasError&&(this._hasError=!1);try{r()}catch(n){this._hasError=!0,t.onError&&t.onError(n,this.context),t.errorFallback&&this.shadowRoot&&(this.shadowRoot.innerHTML=t.errorFallback(n,this.context))}}_initContext(t){try{let r=function(i,s=""){return Array.isArray(i)?new Proxy(i,{get(o,c,d){const a=Reflect.get(o,c,d);return typeof a=="function"&&typeof c=="string"&&["push","pop","shift","unshift","splice","sort","reverse"].includes(c)?function(...y){const f=a.apply(o,y);if(!n._initializing){const w=s||"root";n._triggerWatchers(w,o),n._render(t)}return f}:a},set(o,c,d){if(o[c]=d,!n._initializing){const a=s?`${s}.${String(c)}`:String(c);n._triggerWatchers(a,d),n._render(t)}return!0},deleteProperty(o,c){if(delete o[c],!n._initializing){const d=s?`${s}.${String(c)}`:String(c);n._triggerWatchers(d,void 0),n._render(t)}return!0}}):i&&typeof i=="object"?(Object.keys(i).forEach(o=>{const c=s?`${s}.${o}`:o;i[o]=r(i[o],c)}),new Proxy(i,{set(o,c,d){const a=s?`${s}.${String(c)}`:String(c);return o[c]=r(d,a),n._initializing||(n._triggerWatchers(a,o[c]),n._render(t)),!0},get(o,c,d){return Reflect.get(o,c,d)}})):i};const n=this;return r({...t.state})}catch{return{}}}_initWatchers(t){if(t.watch)for(const[r,n]of Object.entries(t.watch)){let i,s={};if(Array.isArray(n)?(i=n[0],s=n[1]||{}):i=n,this._watchers.set(r,{callback:i,options:s,oldValue:this._getNestedValue(r)}),s.immediate)try{const o=this._getNestedValue(r);i(o,void 0,this.context)}catch(o){console.error(`Error in immediate watcher for "${r}":`,o)}}}_getNestedValue(t){return t.split(".").reduce((r,n)=>r?.[n],this.context)}_triggerWatchers(t,r){const n=(s,o)=>{if(s===o)return!0;if(typeof s!=typeof o||typeof s!="object"||s===null||o===null)return!1;if(Array.isArray(s)&&Array.isArray(o))return s.length!==o.length?!1:s.every((a,u)=>n(a,o[u]));const c=Object.keys(s),d=Object.keys(o);return c.length!==d.length?!1:c.every(a=>n(s[a],o[a]))},i=this._watchers.get(t);if(i&&!n(r,i.oldValue))try{i.callback(r,i.oldValue,this.context),i.oldValue=r}catch(s){console.error(`Error in watcher for "${t}":`,s)}for(const[s,o]of this._watchers.entries())if(o.options.deep&&t.startsWith(s+"."))try{const c=this._getNestedValue(s);n(c,o.oldValue)||(o.callback(c,o.oldValue,this.context),o.oldValue=c)}catch(c){console.error(`Error in deep watcher for "${s}":`,c)}}_applyProps(t){try{let r=function(n,i){return i===Boolean?n==="true":i===Number?Number(n):n};if(!t.props)return;Object.entries(t.props).forEach(([n,i])=>{const s=this.getAttribute(Z(n));s!==null?this.context[n]=q(r(s,i.type)):"default"in i&&i.default!==void 0&&(this.context[n]=q(i.default))})}catch(r){this._hasError=!0,t.onError&&t.onError(r,this.context),t.errorFallback&&this.shadowRoot&&(this.shadowRoot.innerHTML=t.errorFallback(r,this.context))}}}}exports.component=Pe;exports.createElementClass=ne;exports.createStore=se;exports.css=Me;exports.each=he;exports.eventBus=ae;exports.html=de;exports.match=pe;exports.when=ue;
2
19
  //# sourceMappingURL=custom-elements-runtime.cjs.js.map