@maxhealth.tech/prefab 0.2.10 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.d.ts CHANGED
@@ -9,7 +9,7 @@ import type { ComponentJSON } from './core/component.js';
9
9
  import type { Action, ActionJSON } from './actions/types.js';
10
10
  import type { PipeFn } from './rx/pipes.js';
11
11
  /** Package version — injected by build script, updated at release time. */
12
- export declare const VERSION = "0.2.10";
12
+ export declare const VERSION = "0.2.11";
13
13
  export interface Theme {
14
14
  light?: Record<string, string>;
15
15
  dark?: Record<string, string>;
package/dist/app.js CHANGED
@@ -7,7 +7,7 @@
7
7
  import {} from './core/component.js';
8
8
  import { drainAutoState } from './rx/state-collector.js';
9
9
  /** Package version — injected by build script, updated at release time. */
10
- export const VERSION = '0.2.10';
10
+ export const VERSION = '0.2.11';
11
11
  export class PrefabApp {
12
12
  title;
13
13
  view;
package/dist/prefab.css CHANGED
@@ -61,7 +61,7 @@
61
61
  }
62
62
 
63
63
  @media (prefers-color-scheme: dark) {
64
- :root {
64
+ :root:not([data-theme="light"]) {
65
65
  --background: #09090b;
66
66
  --foreground: #fafafa;
67
67
 
@@ -98,6 +98,80 @@
98
98
  }
99
99
  }
100
100
 
101
+ /* Explicit dark override via data-theme attribute */
102
+ [data-theme="dark"] {
103
+ --background: #09090b;
104
+ --foreground: #fafafa;
105
+
106
+ --card: #111113;
107
+ --card-foreground: #fafafa;
108
+
109
+ --popover: #111113;
110
+ --popover-foreground: #fafafa;
111
+
112
+ --primary: #60a5fa;
113
+ --primary-foreground: #09090b;
114
+
115
+ --secondary: #1f2937;
116
+ --secondary-foreground: #f3f4f6;
117
+
118
+ --muted: #1f2937;
119
+ --muted-foreground: #9ca3af;
120
+
121
+ --accent: #1e3a5f;
122
+ --accent-foreground: #93c5fd;
123
+
124
+ --destructive: #f87171;
125
+ --destructive-foreground: #09090b;
126
+
127
+ --success: #4ade80;
128
+ --success-foreground: #09090b;
129
+
130
+ --warning: #fbbf24;
131
+ --warning-foreground: #09090b;
132
+
133
+ --border: #27272a;
134
+ --input: #27272a;
135
+ --ring: #60a5fa;
136
+ }
137
+
138
+ /* Explicit light override via data-theme attribute */
139
+ [data-theme="light"] {
140
+ --background: #ffffff;
141
+ --foreground: #09090b;
142
+
143
+ --card: #ffffff;
144
+ --card-foreground: #09090b;
145
+
146
+ --popover: #ffffff;
147
+ --popover-foreground: #09090b;
148
+
149
+ --primary: #3b82f6;
150
+ --primary-foreground: #ffffff;
151
+
152
+ --secondary: #f3f4f6;
153
+ --secondary-foreground: #1f2937;
154
+
155
+ --muted: #f3f4f6;
156
+ --muted-foreground: #6b7280;
157
+
158
+ --accent: #eff6ff;
159
+ --accent-foreground: #1e40af;
160
+
161
+ --destructive: #ef4444;
162
+ --destructive-foreground: #ffffff;
163
+
164
+ --success: #22c55e;
165
+ --success-foreground: #ffffff;
166
+
167
+ --warning: #f59e0b;
168
+ --warning-foreground: #ffffff;
169
+
170
+ --border: #e5e7eb;
171
+ --input: #e5e7eb;
172
+ --ring: #3b82f6;
173
+ }
174
+
101
175
  /* ═══════════════════════════════════════════════════════════════════════════
102
176
  2. RESET & BASE
103
177
  ═══════════════════════════════════════════════════════════════════════════ */
@@ -34,7 +34,7 @@ export function applyTheme(root, theme) {
34
34
  const props = Object.entries(theme.dark)
35
35
  .map(([key, value]) => ` --${sanitizeCssIdent(key)}: ${sanitizeCssValue(value)};`)
36
36
  .join('\n');
37
- styleEl.textContent = `@media (prefers-color-scheme: dark) {\n :root {\n${props}\n }\n}`;
37
+ styleEl.textContent = `[data-theme="dark"] {\n${props}\n}\n@media (prefers-color-scheme: dark) {\n :root:not([data-theme="light"]) {\n${props}\n }\n}`;
38
38
  }
39
39
  }
40
40
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/renderer/theme.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH;;;GAGG;AACH,oEAAoE;AACpE,SAAS,gBAAgB,CAAC,GAAW;IACnC,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAA;AAC3C,CAAC;AAED,qEAAqE;AACrE,SAAS,gBAAgB,CAAC,KAAa;IACrC,qEAAqE;IACrE,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAA;AAC/E,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAiB,EAAE,KAAmB;IAC/D,IAAI,CAAC,KAAK;QAAE,OAAM;IAElB,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACvD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,gBAAgB,CAAC,GAAG,CAAC,EAAE,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAA;QAC/E,CAAC;IACH,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QACf,uCAAuC;QACvC,MAAM,OAAO,GAAG,mBAAmB,CAAA;QACnC,IAAI,OAAO,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAA4B,CAAA;QACzE,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;YACzC,OAAO,CAAC,EAAE,GAAG,OAAO,CAAA;YACpB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QACpC,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;aACrC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,OAAO,gBAAgB,CAAC,GAAG,CAAC,KAAK,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC;aAClF,IAAI,CAAC,IAAI,CAAC,CAAA;QACb,OAAO,CAAC,WAAW,GAAG,qDAAqD,KAAK,UAAU,CAAA;IAC5F,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAA6C,EAC7C,QAA6C;IAE7C,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO,SAAS,CAAA;IAElE,MAAM,OAAO,GAAG,CAAC,CAAgB,EAAQ,EAAE;QACzC,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxD,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC;gBACzB,CAAC,CAAC,cAAc,EAAE,CAAA;gBAClB,KAAK,QAAQ,CAAC,OAAO,CAAC,CAAA;YACxB,CAAC;QACH,CAAC;IACH,CAAC,CAAA;IAED,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAC7C,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC/D,CAAC;AAED,SAAS,UAAU,CAAC,KAAa,EAAE,CAAgB;IACjD,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;IAC/D,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACnC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IAExC,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAA;IAC/D,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAA;IAClD,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IAE9C,OAAO,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,GAAG,CAAA;AACpC,CAAC"}
1
+ {"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/renderer/theme.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH;;;GAGG;AACH,oEAAoE;AACpE,SAAS,gBAAgB,CAAC,GAAW;IACnC,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAA;AAC3C,CAAC;AAED,qEAAqE;AACrE,SAAS,gBAAgB,CAAC,KAAa;IACrC,qEAAqE;IACrE,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAA;AAC/E,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAiB,EAAE,KAAmB;IAC/D,IAAI,CAAC,KAAK;QAAE,OAAM;IAElB,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACvD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,gBAAgB,CAAC,GAAG,CAAC,EAAE,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAA;QAC/E,CAAC;IACH,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QACf,uCAAuC;QACvC,MAAM,OAAO,GAAG,mBAAmB,CAAA;QACnC,IAAI,OAAO,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAA4B,CAAA;QACzE,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;YACzC,OAAO,CAAC,EAAE,GAAG,OAAO,CAAA;YACpB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QACpC,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;aACrC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,OAAO,gBAAgB,CAAC,GAAG,CAAC,KAAK,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC;aAClF,IAAI,CAAC,IAAI,CAAC,CAAA;QACb,OAAO,CAAC,WAAW,GAAG,0BAA0B,KAAK,oFAAoF,KAAK,UAAU,CAAA;IAC1J,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAA6C,EAC7C,QAA6C;IAE7C,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO,SAAS,CAAA;IAElE,MAAM,OAAO,GAAG,CAAC,CAAgB,EAAQ,EAAE;QACzC,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxD,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC;gBACzB,CAAC,CAAC,cAAc,EAAE,CAAA;gBAClB,KAAK,QAAQ,CAAC,OAAO,CAAC,CAAA;YACxB,CAAC;QACH,CAAC;IACH,CAAC,CAAA;IAED,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAC7C,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC/D,CAAC;AAED,SAAS,UAAU,CAAC,KAAa,EAAE,CAAgB;IACjD,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;IAC/D,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACnC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IAExC,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAA;IAC/D,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAA;IAClD,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IAE9C,OAAO,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,GAAG,CAAA;AACpC,CAAC"}
@@ -81,8 +81,11 @@ container holding the app. Specify either width or maxWidth, and either height o
81
81
  `)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(v)){r.push("<hr />"),_++;continue}let g=/^(#{1,6})\s+(.+)$/.exec(v);if(g){let I=g[1].length;r.push(`<h${I}>${Xu(g[2])}</h${I}>`),_++;continue}if(v.startsWith("> ")||v===">"){let I=[];while(_<u.length&&(u[_].startsWith("> ")||u[_]===">"))I.push(u[_].replace(/^>\s?/,"")),_++;r.push(`<blockquote>${wN(I.join(`
82
82
  `))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(v)){r.push("<ul>");while(_<u.length&&/^[\s]*[-*+]\s+/.test(u[_]))r.push(`<li>${Xu(u[_].replace(/^[\s]*[-*+]\s+/,""))}</li>`),_++;r.push("</ul>");continue}if(/^[\s]*\d+\.\s+/.test(v)){r.push("<ol>");while(_<u.length&&/^[\s]*\d+\.\s+/.test(u[_]))r.push(`<li>${Xu(u[_].replace(/^[\s]*\d+\.\s+/,""))}</li>`),_++;r.push("</ol>");continue}if(v.trim()===""){_++;continue}let U=[];while(_<u.length&&u[_].trim()!==""&&!/^#{1,6}\s/.test(u[_])&&!/^[-*+]\s/.test(u[_])&&!/^\d+\.\s/.test(u[_])&&!u[_].startsWith("> ")&&!u[_].trimStart().startsWith("```")&&!/^(\s*[-*_]\s*){3,}$/.test(u[_]))U.push(u[_]),_++;r.push(`<p>${U.map(Xu).join("<br />")}</p>`)}return r.join(`
83
83
  `)}function n0($,u){let r=document.createElement("kbd");return r.className="pf-kbd",r.textContent=F($.content,u),r}function PN(){W("Card",C0),W("CardHeader",er("pf-card-header")),W("CardTitle",kN("pf-card-title","h3")),W("CardDescription",kN("pf-card-description","p")),W("CardContent",er("pf-card-content")),W("CardFooter",er("pf-card-footer"))}function C0($,u){let r=K("div","pf-card");return r.style.border="1px solid var(--border, #e5e7eb)",r.style.borderRadius="var(--radius, 8px)",r.style.backgroundColor="var(--card, #fff)",r.style.overflow="hidden",y($,r,u),r}function er($){return(u,r)=>{let _=K("div",$);return _.style.padding="16px 24px",y(u,_,r),_}}function kN($,u){return(r,_)=>{let v=document.createElement(u);return v.className=$,v.textContent=F(r.content,_),v}}function JN(){W("DataTable",m0),W("Badge",l0),W("Dot",y0),W("Metric",f0),W("Ring",c0),W("Progress",x0),W("Separator",o0),W("Loader",h0),W("Icon",t0),W("Sparkline",d0)}function m0($,u){let r=K("div","pf-datatable-wrapper"),_=document.createElement("table");_.className="pf-datatable",_.style.width="100%",_.style.borderCollapse="collapse";let v=$.columns??[],g=j$($.rows,u),U=$.rowKey,I=$.selected,D=document.createElement("thead"),b=document.createElement("tr");for(let O of v){let k=document.createElement("th");k.className="pf-datatable-th",k.textContent=O.header??O.key,k.style.padding="8px 12px",k.style.textAlign="left",k.style.borderBottom="2px solid var(--border, #e5e7eb)",b.appendChild(k)}D.appendChild(b),_.appendChild(D);let N=document.createElement("tbody");if(Array.isArray(g)){let O=I!=null?j$(I,u):void 0;for(let k of g){let L=document.createElement("tr");L.className="pf-datatable-row";let j=k;if(U&&O!=null&&j[U]!=null&&String(j[U])===String(O))L.classList.add("pf-datatable-row-selected"),L.style.backgroundColor="var(--primary-bg, #eff6ff)";if($.onRowClick!=null&&U)L.style.cursor="pointer",L.addEventListener("click",()=>{let B={...u.scope,$item:j,$index:g.indexOf(k)},X=O$({...u,scope:B});r$($.onRowClick,X)});for(let B of v){let X=document.createElement("td");X.className="pf-datatable-td";let M;if(B.accessor)M=j$(`{{ $item.${B.accessor} }}`,{...u,scope:{...u.scope,$item:j}});else if(M=j[B.key],B.format&&M!=null)M=j$(`{{ __fmtVal | ${B.format} }}`,{...u,scope:{...u.scope,__fmtVal:M}});X.textContent=M==null?"":String(M),X.style.padding="8px 12px",X.style.borderBottom="1px solid var(--border, #e5e7eb)",L.appendChild(X)}N.appendChild(L)}}if(_.appendChild(N),$.search===!0){let O=document.createElement("input");O.type="text",O.placeholder="Search...",O.className="pf-datatable-search",O.style.marginBottom="8px",O.style.padding="6px 12px",O.style.width="100%",O.style.boxSizing="border-box",O.addEventListener("input",()=>{let k=O.value.toLowerCase(),L=Array.from(N.querySelectorAll("tr"));for(let j of L){let B=j.textContent.toLowerCase();j.style.display=B.includes(k)?"":"none"}}),r.appendChild(O)}return r.appendChild(_),r}function l0($,u){let r=K("span","pf-badge"),_=$.variant??"default";return r.setAttribute("data-variant",_),r.style.alignItems="center",r.style.padding="2px 10px",r.style.borderRadius="9999px",r.style.fontSize="12px",r.style.fontWeight="500",r.textContent=F($.label??$.content,u),p0(r,_),r}function y0($,u){let r=K("span","pf-dot"),_=$.color??"gray";return r.style.display="inline-block",r.style.width="8px",r.style.height="8px",r.style.borderRadius="50%",r.style.backgroundColor=_,r}function f0($,u){let r=K("div","pf-metric"),_=K("div","pf-metric-label");_.textContent=F($.label,u),_.style.fontSize="14px",_.style.color="var(--muted-foreground, #6b7280)",r.appendChild(_);let v=K("div","pf-metric-value");if(v.textContent=F($.value,u),v.style.fontSize="28px",v.style.fontWeight="700",r.appendChild(v),$.delta!=null){let g=K("span","pf-metric-delta");g.textContent=F($.delta,u);let U=$.trend??"",I=$.trendSentiment??"neutral";if(g.style.fontSize="14px",g.style.color=I==="positive"?"green":I==="negative"?"red":"inherit",U==="up")g.textContent="↑ "+g.textContent;else if(U==="down")g.textContent="↓ "+g.textContent;r.appendChild(g)}if($.description!=null){let g=K("div","pf-metric-desc");g.textContent=F($.description,u),g.style.fontSize="12px",g.style.color="var(--muted-foreground, #6b7280)",r.appendChild(g)}return r}function c0($,u){let r=K("div","pf-ring"),_=$.size??80,v=$.thickness??8,g=Number(j$($.value,u)??0),U=Math.max(0,Math.min(100,g)),I=(_-v)/2,D=2*Math.PI*I,b=D*(1-U/100),N=document.createElementNS("http://www.w3.org/2000/svg","svg");N.setAttribute("width",String(_)),N.setAttribute("height",String(_)),N.setAttribute("viewBox",`0 0 ${_} ${_}`);let O=document.createElementNS("http://www.w3.org/2000/svg","circle");O.setAttribute("cx",String(_/2)),O.setAttribute("cy",String(_/2)),O.setAttribute("r",String(I)),O.setAttribute("fill","none"),O.setAttribute("stroke","var(--muted, #e5e7eb)"),O.setAttribute("stroke-width",String(v));let k=document.createElementNS("http://www.w3.org/2000/svg","circle");if(k.setAttribute("cx",String(_/2)),k.setAttribute("cy",String(_/2)),k.setAttribute("r",String(I)),k.setAttribute("fill","none"),k.setAttribute("stroke","var(--primary, #3b82f6)"),k.setAttribute("stroke-width",String(v)),k.setAttribute("stroke-dasharray",String(D)),k.setAttribute("stroke-dashoffset",String(b)),k.setAttribute("stroke-linecap","round"),k.style.transform="rotate(-90deg)",k.style.transformOrigin="center",N.appendChild(O),N.appendChild(k),r.appendChild(N),$.label!=null){let L=K("div","pf-ring-label");L.textContent=F($.label,u),L.style.textAlign="center",L.style.fontSize="12px",r.appendChild(L)}return r}function x0($,u){let r=K("div","pf-progress");r.setAttribute("role","progressbar");let _=Number(j$($.value,u)??0),v=$.max??100,g=v>0?Math.max(0,Math.min(100,_/v*100)):0;r.setAttribute("aria-valuenow",String(_)),r.setAttribute("aria-valuemin","0"),r.setAttribute("aria-valuemax",String(v)),r.style.height="8px",r.style.backgroundColor="var(--muted, #e5e7eb)",r.style.borderRadius="4px",r.style.overflow="hidden";let U=K("div","pf-progress-fill");return U.style.height="100%",U.style.width=`${g}%`,U.style.backgroundColor="var(--primary, #3b82f6)",U.style.borderRadius="4px",U.style.transition="width 0.3s ease",r.appendChild(U),r}function o0($,u){let r=document.createElement("hr");return r.className="pf-separator",r.style.border="none",r.style.borderTop="1px solid var(--border, #e5e7eb)",r.style.margin="8px 0",r}function h0($,u){let r=K("div","pf-loader");return r.textContent="⏳",r.style.display="flex",r.style.justifyContent="center",r.style.padding="16px",r}function t0($,u){let r=K("span","pf-icon");return r.setAttribute("data-icon",F($.name??$.content,u)),r}function d0($,u){let r=K("div","pf-sparkline"),_=$.data??[];if(_.length===0)return r;let v=120,g=32,U=Math.max(..._),I=Math.min(..._),D=U-I||1,b=document.createElementNS("http://www.w3.org/2000/svg","svg");b.setAttribute("width",String(v)),b.setAttribute("height",String(g)),b.setAttribute("viewBox",`0 0 ${v} ${g}`);let N=_.length>1?_.length-1:1,O=_.map((L,j)=>{let B=j/N*v,X=g-(L-I)/D*(g-4)-2;return`${B},${X}`}).join(" "),k=document.createElementNS("http://www.w3.org/2000/svg","polyline");return k.setAttribute("points",O),k.setAttribute("fill","none"),k.setAttribute("stroke","var(--primary, #3b82f6)"),k.setAttribute("stroke-width","1.5"),b.appendChild(k),r.appendChild(b),r}function p0($,u){let r={default:{bg:"var(--primary, #3b82f6)",fg:"#fff"},secondary:{bg:"var(--secondary, #f3f4f6)",fg:"var(--secondary-foreground, #1f2937)"},destructive:{bg:"var(--destructive, #ef4444)",fg:"#fff"},success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"},outline:{bg:"transparent",fg:"inherit"}},_=r[u]??r.default;if($.style.backgroundColor=_.bg,$.style.color=_.fg,u==="outline")$.style.border="1px solid var(--border, #e5e7eb)"}function LN(){W("Form",a0),W("Input",e0),W("Textarea",s0),W("Button",$k),W("ButtonGroup",vk),W("Select",uk),W("SelectOption",rk),W("SelectGroup",Tu("pf-select-group")),W("SelectLabel",K4("pf-select-label")),W("SelectSeparator",WN),W("Checkbox",_k),W("Switch",gk),W("Slider",Uk),W("Radio",Dk),W("RadioGroup",bk),W("Combobox",Nk),W("ComboboxOption",zk),W("ComboboxGroup",Tu("pf-combobox-group")),W("ComboboxLabel",K4("pf-combobox-label")),W("ComboboxSeparator",WN),W("Calendar",Ok),W("DatePicker",wk),W("Field",Tu("pf-field")),W("FieldTitle",K4("pf-field-title")),W("FieldDescription",K4("pf-field-description")),W("FieldContent",Tu("pf-field-content")),W("FieldError",K4("pf-field-error")),W("ChoiceCard",kk)}function a0($,u){let r=document.createElement("form");return r.className="pf-form",r.addEventListener("submit",(_)=>{_.preventDefault();let v=new FormData(r),g={};if(v.forEach((U,I)=>{g[I]=U}),u.store.merge(g),$.onSubmit!=null){let U=O$(u);U.scope={...u.scope,...g},r$($.onSubmit,U)}}),y($,r,u),r}function e0($,u){let r=K("div","pf-input-wrapper");if(r.style.display="flex",r.style.flexDirection="column",r.style.gap="4px",$.label!=null){let g=document.createElement("label");if(g.className="pf-input-label",g.textContent=F($.label,u),$.name!=null)g.htmlFor=$.name;g.style.fontSize="14px",g.style.fontWeight="500",r.appendChild(g)}let _=document.createElement("input");if(_.className="pf-input",_.type=$.inputType??"text",$.name!=null)_.name=$.name;if($.name!=null)_.id=`pf-input-${$.name}`;if($.placeholder!=null)_.placeholder=F($.placeholder,u);if($.required===!0)_.required=!0,_.setAttribute("aria-required","true");if($.error!=null)_.setAttribute("aria-invalid","true");let v=$.name;if(v){let g=u.store.get(v);if(g!=null)_.value=String(g);_.addEventListener("input",()=>{if(u.store.set(v,_.value),$.onChange!=null)r$($.onChange,{...O$(u),scope:{...u.scope,$event:_.value}})})}return sr(_),r.appendChild(_),r}function s0($,u){let r=K("div","pf-textarea-wrapper"),_=document.createElement("textarea");if(_.className="pf-textarea",$.name!=null)_.name=$.name;if($.name!=null)_.id=`pf-textarea-${$.name}`;if($.placeholder!=null)_.placeholder=F($.placeholder,u);if($.rows!=null)_.rows=$.rows;if($.required===!0)_.setAttribute("aria-required","true");let v=$.name;if(v!=null){let g=u.store.get(v);if(g!=null)_.value=String(g);_.addEventListener("input",()=>{if(u.store.set(v,_.value),$.onChange!=null)r$($.onChange,{...O$(u),scope:{...u.scope,$event:_.value}})})}return sr(_),r.appendChild(_),r}function $k($,u){let r=document.createElement("button");r.className="pf-button",r.type=$.submit===!0?"submit":"button",r.textContent=F($.label,u);let _=$.variant??"default";if(r.setAttribute("data-variant",_),Ik(r,_),$.size!=null)r.setAttribute("data-size",$.size);if($.disabled===!0)r.disabled=!0;if($.onClick!=null)r.addEventListener("click",()=>{r$($.onClick,O$(u))});return r}function vk($,u){let r=K("div","pf-button-group");return r.style.display="flex",r.style.gap="8px",y($,r,u),r}function uk($,u){let r=K("div","pf-select-wrapper"),_=document.createElement("select");if(_.className="pf-select",$.name!=null)_.name=$.name;if(sr(_),$.placeholder!=null){let U=document.createElement("option");U.value="",U.textContent=F($.placeholder,u),U.disabled=!0,U.selected=!0,U.hidden=!0,_.appendChild(U)}let v=$.options;if(Array.isArray(v))for(let U of v){let I=document.createElement("option");I.value=U.value??"",I.textContent=U.label??I.value,_.appendChild(I)}if($.children)for(let U of $.children)if(U.type==="SelectOption"){let I=document.createElement("option");I.value=U.value??"",I.textContent=U.label??I.value,_.appendChild(I)}else _.appendChild(D$(U,u));let g=$.name;if(g){let U=u.store.get(g);if(U!=null)_.value=String(U);_.addEventListener("change",()=>{if(u.store.set(g,_.value),$.onChange!=null)r$($.onChange,{...O$(u),scope:{...u.scope,$event:_.value}})})}return r.appendChild(_),r}function rk($,u){return K("span")}function _k($,u){let r=K("label","pf-checkbox-wrapper");r.style.display="flex",r.style.alignItems="center",r.style.gap="8px",r.style.cursor="pointer";let _=document.createElement("input");if(_.type="checkbox",_.className="pf-checkbox",$.name!=null)_.name=$.name;if($.checked===!0)_.checked=!0;let v=$.name;if(v){let g=u.store.get(v);if(typeof g==="boolean")_.checked=g;_.addEventListener("change",()=>{if(u.store.set(v,_.checked),$.onChange!=null)r$($.onChange,{...O$(u),scope:{...u.scope,$event:_.checked}})})}if(r.appendChild(_),$.label!=null){let g=K("span");g.textContent=F($.label,u),r.appendChild(g)}return r}function gk($,u){let r=K("label","pf-switch-wrapper");r.style.display="flex",r.style.alignItems="center",r.style.gap="8px",r.style.cursor="pointer";let _=document.createElement("input");if(_.type="checkbox",_.className="pf-switch",_.setAttribute("role","switch"),$.name!=null)_.name=$.name;let v=$.name;if(v){let g=u.store.get(v);if(typeof g==="boolean")_.checked=g;_.addEventListener("change",()=>{if(u.store.set(v,_.checked),$.onChange!=null)r$($.onChange,{...O$(u),scope:{...u.scope,$event:_.checked}})})}if(r.appendChild(_),$.label!=null){let g=K("span");g.textContent=F($.label,u),r.appendChild(g)}return r}function Uk($,u){let r=K("div","pf-slider-wrapper"),_=document.createElement("input");if(_.type="range",_.className="pf-slider",$.name!=null)_.name=$.name;if($.min!=null)_.min=String($.min);if($.max!=null)_.max=String($.max);if($.step!=null)_.step=String($.step);let v=$.name;if(v){let g=u.store.get(v);if(g!=null)_.value=String(g);_.addEventListener("input",()=>{if(u.store.set(v,Number(_.value)),$.onChange!=null)r$($.onChange,{...O$(u),scope:{...u.scope,$event:Number(_.value)}})})}return r.appendChild(_),r}function sr($){$.style.padding="8px 12px",$.style.border="1px solid var(--border, #d1d5db)",$.style.borderRadius="var(--radius, 6px)",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function Ik($,u){$.style.padding="8px 16px",$.style.borderRadius="var(--radius, 6px)",$.style.fontSize="14px",$.style.fontWeight="500",$.style.cursor="pointer",$.style.border="none";let r={default:{bg:"var(--primary, #3b82f6)",fg:"#fff"},secondary:{bg:"var(--secondary, #f3f4f6)",fg:"var(--secondary-foreground, #1f2937)"},destructive:{bg:"var(--destructive, #ef4444)",fg:"#fff"},outline:{bg:"transparent",fg:"inherit"},ghost:{bg:"transparent",fg:"inherit"},link:{bg:"transparent",fg:"var(--primary, #3b82f6)"}},_=r[u]??r.default;if($.style.backgroundColor=_.bg,$.style.color=_.fg,u==="outline")$.style.border="1px solid var(--border, #d1d5db)"}function Tu($){return(u,r)=>{let _=K("div",$);return y(u,_,r),_}}function K4($){return(u,r)=>{let _=K("span",$);return _.textContent=F(u.content,r),_}}function WN(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.borderTop="1px solid var(--border, #e5e7eb)",$.style.margin="4px 0",$}function Dk($,u){let r=K("label","pf-radio");r.style.display="flex",r.style.alignItems="center",r.style.gap="8px",r.style.cursor="pointer";let _=document.createElement("input");if(_.type="radio",_.value=F($.value,u),r.appendChild(_),$.label!=null){let v=K("span","pf-radio-label");v.textContent=F($.label,u),r.appendChild(v)}return r}function bk($,u){let r=K("fieldset","pf-radio-group");if(r.style.border="none",r.style.padding="0",r.style.display="flex",r.style.flexDirection="column",r.style.gap="8px",$.label!=null){let g=document.createElement("legend");g.textContent=F($.label,u),g.style.fontWeight="500",g.style.marginBottom="4px",r.appendChild(g)}y($,r,u);let _=F($.name,u),v=u.store.get(_);for(let g of Array.from(r.querySelectorAll('input[type="radio"]')))if(g.name=_,v!=null&&g.value===String(v))g.checked=!0;return r.addEventListener("change",(g)=>{let U=g.target;if(U.type==="radio"){if(u.store.set(_,U.value),$.onChange!=null)r$($.onChange,O$(u))}}),r}function Nk($,u){let r=K("div","pf-combobox"),_=document.createElement("input");if(_.className="pf-combobox-input",_.type="text",_.name=F($.name,u),$.placeholder!=null)_.placeholder=F($.placeholder,u);if($.value!==void 0)_.value=F($.value,u);let v=_.name,g=u.store.get(v);if(g!=null)_.value=String(g);_.style.padding="6px 12px",_.style.borderRadius="6px",_.style.border="1px solid var(--border, #d1d5db)",_.style.width="100%",_.style.boxSizing="border-box";let U=K("div","pf-combobox-dropdown");if(U.style.display="none",U.style.position="absolute",U.style.background="var(--popover, #fff)",U.style.border="1px solid var(--border, #d1d5db)",U.style.borderRadius="6px",U.style.maxHeight="200px",U.style.overflowY="auto",U.style.zIndex="50",y($,U,u),_.addEventListener("focus",()=>{U.style.display="block"}),_.addEventListener("blur",()=>{setTimeout(()=>{U.style.display="none"},150)}),$.searchable!==!1)_.addEventListener("input",()=>{let I=_.value.toLowerCase();for(let D of Array.from(U.querySelectorAll(".pf-combobox-option"))){let b=D.textContent.toLowerCase();D.style.display=b.includes(I)?"":"none"}});if($.onChange!=null)r.addEventListener("pf-combobox-select",()=>{r$($.onChange,{...O$(u),scope:{...u.scope,$event:_.value}})});return r.style.position="relative",r.appendChild(_),r.appendChild(U),r}function zk($,u){let r=K("div","pf-combobox-option");return r.style.padding="6px 12px",r.style.cursor="pointer",r.textContent=F($.label??$.value,u),r.dataset.value=F($.value,u),r.addEventListener("mousedown",()=>{let _=r.closest(".pf-combobox"),v=_?.querySelector("input");if(v)v.value=r.dataset.value??"",u.store.set(v.name,v.value),_?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),r}function Ok($,u){let r=K("div","pf-calendar"),_=document.createElement("input");if(_.type="date",_.name=F($.name,u),$.value!==void 0)_.value=F($.value,u);let v=_.name,g=u.store.get(v);if(g!=null)_.value=String(g);if($.minDate!=null)_.min=F($.minDate,u);if($.maxDate!=null)_.max=F($.maxDate,u);return _.style.padding="6px 12px",_.style.borderRadius="6px",_.style.border="1px solid var(--border, #d1d5db)",_.addEventListener("change",()=>{if(u.store.set(_.name,_.value),$.onChange!=null)r$($.onChange,O$(u))}),r.appendChild(_),r}function wk($,u){let r=K("div","pf-datepicker"),_=document.createElement("input");if(_.type="date",_.name=F($.name,u),$.placeholder!=null)_.placeholder=F($.placeholder,u);if($.value!==void 0)_.value=F($.value,u);let v=_.name,g=u.store.get(v);if(g!=null)_.value=String(g);if($.minDate!=null)_.min=F($.minDate,u);if($.maxDate!=null)_.max=F($.maxDate,u);return _.style.padding="6px 12px",_.style.borderRadius="6px",_.style.border="1px solid var(--border, #d1d5db)",_.style.width="100%",_.style.boxSizing="border-box",_.addEventListener("change",()=>{if(u.store.set(_.name,_.value),$.onChange!=null)r$($.onChange,O$(u))}),r.appendChild(_),r}function kk($,u){let r=K("div","pf-choice-card");if(r.style.border="2px solid var(--border, #d1d5db)",r.style.borderRadius="8px",r.style.padding="16px",r.style.cursor="pointer",r.style.transition="border-color 0.2s",r.dataset.value=F($.value,u),$.selected===!0)r.dataset.selected="true",r.style.borderColor="var(--primary, #3b82f6)",r.style.backgroundColor="var(--accent, #eff6ff)";if($.label!=null){let _=K("div","pf-choice-card-label");_.textContent=F($.label,u),_.style.fontWeight="600",r.appendChild(_)}if($.description!=null){let _=K("div","pf-choice-card-description");_.textContent=F($.description,u),_.style.fontSize="14px",_.style.color="var(--muted-foreground, #6b7280)",r.appendChild(_)}if(y($,r,u),$.onClick!=null)r.addEventListener("click",()=>{r$($.onClick,O$(u))});return r}function GN(){W("Tabs",Pk),W("Tab",Jk),W("Accordion",Wk),W("AccordionItem",Lk),W("Dialog",Gk),W("Popover",Kk),W("Tooltip",jk),W("HoverCard",Bk),W("Carousel",Hk)}function Pk($,u){let r=K("div","pf-tabs"),_=K("div","pf-tabs-bar");_.setAttribute("role","tablist"),_.style.display="flex",_.style.gap="4px",_.style.borderBottom="2px solid var(--border, #e5e7eb)",_.style.marginBottom="12px";let v=[],g=[];if($.children)for(let I=0;I<$.children.length;I++){let D=$.children[I],b=`pf-tab-${Math.random().toString(36).slice(2,8)}`,N=`pf-panel-${Math.random().toString(36).slice(2,8)}`,O=document.createElement("button");O.type="button",O.className="pf-tab-trigger",O.textContent=D.title??`Tab ${I+1}`,O.setAttribute("role","tab"),O.setAttribute("aria-selected",I===0?"true":"false"),O.setAttribute("aria-controls",N),O.id=b,O.tabIndex=I===0?0:-1,O.style.padding="8px 16px",O.style.border="none",O.style.background="none",O.style.cursor="pointer",O.style.borderBottom="2px solid transparent",O.style.marginBottom="-2px",O.style.fontSize="14px";let k=K("div","pf-tab-panel");if(k.style.display=I===0?"block":"none",k.setAttribute("role","tabpanel"),k.setAttribute("aria-labelledby",b),k.id=N,k.tabIndex=0,y(D,k,u),O.addEventListener("click",()=>{U(I)}),I===0)O.style.borderBottomColor="var(--primary, #3b82f6)",O.style.fontWeight="600";g.push(O),v.push(k),_.appendChild(O)}function U(I){v.forEach((D)=>D.style.display="none"),g.forEach((D)=>{D.style.borderBottomColor="transparent",D.style.fontWeight="normal",D.setAttribute("aria-selected","false"),D.tabIndex=-1}),v[I].style.display="block",g[I].style.borderBottomColor="var(--primary, #3b82f6)",g[I].style.fontWeight="600",g[I].setAttribute("aria-selected","true"),g[I].tabIndex=0,g[I].focus()}_.addEventListener("keydown",(I)=>{let D=g.indexOf(I.target);if(D<0)return;let b;if(I.key==="ArrowRight")b=(D+1)%g.length;else if(I.key==="ArrowLeft")b=(D-1+g.length)%g.length;else if(I.key==="Home")b=0;else if(I.key==="End")b=g.length-1;else return;I.preventDefault(),U(b)}),r.appendChild(_);for(let I of v)r.appendChild(I);return r}function Jk($,u){let r=K("div","pf-tab");return y($,r,u),r}function Wk($,u){let r=K("div","pf-accordion");return y($,r,u),r}function Lk($,u){let r=K("div","pf-accordion-item");r.style.borderBottom="1px solid var(--border, #e5e7eb)";let _=`pf-acc-${Math.random().toString(36).slice(2,8)}`,v=document.createElement("button");v.type="button",v.className="pf-accordion-trigger",v.textContent=$.title??"",v.setAttribute("aria-expanded","false"),v.setAttribute("aria-controls",_),v.style.width="100%",v.style.textAlign="left",v.style.padding="12px 0",v.style.border="none",v.style.background="none",v.style.cursor="pointer",v.style.fontSize="14px",v.style.fontWeight="500";let g=K("div","pf-accordion-content");return g.id=_,g.setAttribute("role","region"),g.setAttribute("aria-labelledby",v.id),g.style.display="none",g.style.paddingBottom="12px",y($,g,u),v.addEventListener("click",()=>{let U=g.style.display!=="none";g.style.display=U?"none":"block",v.setAttribute("aria-expanded",U?"false":"true")}),r.appendChild(v),r.appendChild(g),r}function Gk($,u){let r=K("div","pf-dialog-wrapper");if($.trigger!=null){let g=D$($.trigger,u);g.addEventListener("click",()=>{_.showModal()}),r.appendChild(g)}let _=document.createElement("dialog");if(_.className="pf-dialog",_.setAttribute("aria-modal","true"),_.style.maxWidth="500px",_.style.width="100%",_.style.border="1px solid var(--border, #e5e7eb)",_.style.borderRadius="var(--radius, 8px)",_.style.padding="24px",$.title!=null){let g=K("h2","pf-dialog-title");g.textContent=F($.title,u),g.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,_.setAttribute("aria-labelledby",g.id),_.appendChild(g)}if($.description!=null){let g=K("p","pf-dialog-desc");g.textContent=F($.description,u),g.style.color="var(--muted-foreground, #6b7280)",_.appendChild(g)}let v=K("div","pf-dialog-body");if(y($,v,u),_.appendChild(v),$.dismissible!==!1)_.addEventListener("click",(g)=>{if(g.target===_)_.close()});return document.addEventListener("prefab:close-overlay",()=>_.close()),r.appendChild(_),r}function Kk($,u){let r=K("div","pf-popover");r.style.position="relative",r.style.display="inline-block";let _=K("div","pf-popover-content");if(_.style.display="none",_.style.position="absolute",_.style.zIndex="50",_.style.padding="12px",_.style.border="1px solid var(--border, #e5e7eb)",_.style.borderRadius="var(--radius, 8px)",_.style.backgroundColor="var(--popover, #fff)",_.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",$.title!=null){let v=K("div","pf-popover-title");v.textContent=F($.title,u),v.style.fontWeight="600",v.style.marginBottom="4px",_.appendChild(v)}return y($,_,u),r.addEventListener("click",(v)=>{if(_.contains(v.target)&&_.style.display!=="none")return;_.style.display=_.style.display==="none"?"block":"none"}),r.appendChild(_),r}function jk($,u){let r=K("div","pf-tooltip");r.style.position="relative",r.style.display="inline-block";let _=`pf-tip-${Math.random().toString(36).slice(2,8)}`,v=K("div","pf-tooltip-content");return v.id=_,v.setAttribute("role","tooltip"),v.textContent=F($.content??"",u),v.style.display="none",v.style.position="absolute",v.style.bottom="100%",v.style.left="50%",v.style.transform="translateX(-50%)",v.style.padding="4px 8px",v.style.borderRadius="4px",v.style.backgroundColor="var(--popover, #1f2937)",v.style.color="#fff",v.style.fontSize="12px",v.style.whiteSpace="nowrap",v.style.zIndex="50",y($,r,u),r.setAttribute("aria-describedby",_),r.addEventListener("mouseenter",()=>{v.style.display="block"}),r.addEventListener("mouseleave",()=>{v.style.display="none"}),r.addEventListener("focus",()=>{v.style.display="block"},!0),r.addEventListener("blur",()=>{v.style.display="none"},!0),r.appendChild(v),r}function Bk($,u){let r=K("div","pf-hover-card");r.style.position="relative",r.style.display="inline-block";let _=K("div","pf-hover-card-content");return _.style.display="none",_.style.position="absolute",_.style.zIndex="50",_.style.padding="16px",_.style.border="1px solid var(--border, #e5e7eb)",_.style.borderRadius="var(--radius, 8px)",_.style.backgroundColor="var(--card, #fff)",_.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",_.style.minWidth="200px",y($,_,u),r.addEventListener("mouseenter",()=>{_.style.display="block"}),r.addEventListener("mouseleave",()=>{_.style.display="none"}),r.appendChild(_),r}function Hk($,u){let r=K("div","pf-carousel");r.style.position="relative",r.style.overflow="hidden",r.setAttribute("role","region"),r.setAttribute("aria-roledescription","carousel"),r.setAttribute("aria-label",F($.label??"Carousel",u));let _=K("div","pf-carousel-track");_.style.display="flex",_.style.transition="transform 0.3s ease",y($,_,u);let v=0,g=$.children?.length??0,U=document.createElement("button");U.type="button",U.textContent="‹",U.className="pf-carousel-prev",U.setAttribute("aria-label","Previous slide"),U.style.position="absolute",U.style.left="4px",U.style.top="50%",U.style.transform="translateY(-50%)",U.style.zIndex="10";let I=document.createElement("button");I.type="button",I.textContent="›",I.className="pf-carousel-next",I.setAttribute("aria-label","Next slide"),I.style.position="absolute",I.style.right="4px",I.style.top="50%",I.style.transform="translateY(-50%)",I.style.zIndex="10";let D=()=>{_.style.transform=`translateX(-${v*100}%)`};return U.addEventListener("click",()=>{if(g===0)return;v=Math.max(0,v-1),D()}),I.addEventListener("click",()=>{if(g===0)return;v=Math.min(g-1,v+1),D()}),r.appendChild(_),r.appendChild(U),r.appendChild(I),r}function KN(){W("ForEach",Vk),W("If",jN),W("Elif",Yk),W("Else",Ak),W("Condition",Sk),W("Define",Fk),W("Use",qk),W("Slot",Ek)}function Vk($,u){let r=document.createDocumentFragment(),_=$.expression;if(!_)return r;let v;if(Q$(_)){let U=Z$(_,u.store,u.scope);v=Array.isArray(U)?U:[]}else{let U=u.store.get(_);v=Array.isArray(U)?U:[]}let g=$.let??{};for(let U=0;U<v.length;U++){let I=v[U],D={...u.scope,$item:I,$index:U,...g},b={...u,scope:D};if($.children)Iv($.children,r,b)}return r}function jN($,u){if(BN($.condition,u)){let _=document.createDocumentFragment();if($.children)Iv($.children,_,u);return _}return document.createDocumentFragment()}function Yk($,u){return jN($,u)}function Ak($,u){let r=document.createDocumentFragment();if($.children)Iv($.children,r,u);return r}function BN($,u){if(!$)return!1;if(Q$($))return Boolean(Z$($,u.store,u.scope));return Boolean(u.store.get($))}function Sk($,u){let r=document.createDocumentFragment(),_=$.cases,v=$.else;if(_){for(let g of _)if(BN(g.when,u)){if(g.children)Iv(g.children,r,u);return r}}if(v)Iv(v,r,u);return r}function Fk($,u){let r=$.name;if(r&&$.children)u.templates=u.templates??{},u.templates[r]=$.children;return document.createDocumentFragment()}function qk($,u){let r=document.createDocumentFragment(),_=$.def??$.name,v=u.templates?.[_];if(!v)return r;let g=$.overrides??{},U={...u.scope,...g},I={...u,scope:U};for(let D of v)r.appendChild(D$(D,I));return r}function Ek($,u){let r=document.createDocumentFragment(),_=$.name??"default",g=u.slots?.[_]??$.children;if(g)for(let U of g)r.appendChild(D$(U,u));return r}function HN(){W("Alert",Xk),W("AlertTitle",ik),W("AlertDescription",Tk)}function Xk($,u){let r=K("div","pf-alert");r.setAttribute("role","alert");let _=$.variant??"default";if(r.setAttribute("data-variant",_),r.style.padding="12px 16px",r.style.borderRadius="var(--radius, 8px)",r.style.border="1px solid var(--border, #e5e7eb)",_==="destructive")r.style.borderColor="var(--destructive, #ef4444)",r.style.color="var(--destructive, #ef4444)";if($.icon!=null){let v=K("span","pf-alert-icon");v.setAttribute("data-icon",$.icon),v.style.marginRight="8px",r.appendChild(v)}return y($,r,u),r}function ik($,u){let r=K("h5","pf-alert-title");return r.textContent=F($.content,u),r.style.fontWeight="600",r.style.marginBottom="4px",r}function Tk($,u){let r=K("p","pf-alert-description");return r.textContent=F($.content,u),r.style.fontSize="14px",r}function VN(){W("Image",Mk),W("Audio",Rk),W("Video",Qk),W("Embed",Zk),W("Svg",Ck),W("DropZone",mk),W("Mermaid",lk)}function Mk($,u){let r=document.createElement("img");if(r.className="pf-image",r.src=F($.src,u),$.alt!=null)r.alt=F($.alt,u);if($.width!=null)r.width=$.width;if($.height!=null)r.height=$.height;return r.style.maxWidth="100%",r}function Rk($,u){let r=document.createElement("audio");return r.className="pf-audio",r.src=F($.src,u),r.controls=!0,r}function Qk($,u){let r=document.createElement("video");if(r.className="pf-video",r.src=F($.src,u),r.controls=!0,$.width!=null)r.width=$.width;if($.height!=null)r.height=$.height;return r.style.maxWidth="100%",r}function Zk($,u){let r=K("div","pf-embed"),_=document.createElement("iframe");return _.src=F($.src,u),_.style.width="100%",_.style.height=$.height!=null?`${$.height}px`:"400px",_.style.border="none",_.setAttribute("sandbox","allow-scripts"),r.appendChild(_),r}var nk=new Set(["svg","g","path","rect","circle","ellipse","line","polyline","polygon","text","tspan","textpath","defs","use","symbol","clippath","mask","pattern","lineargradient","radialgradient","stop","filter","fegaussianblur","feoffset","femerge","femergenode","fecolormatrix","feblend","title","desc"]);function Ck($,u){let r=K("div","pf-svg"),_=F($.content,u);if(!_.includes("<svg"))return r;let g=new DOMParser().parseFromString(_,"image/svg+xml").querySelector("svg");if(!g)return r;return YN(g),r.appendChild(document.importNode(g,!0)),r}function YN($){let u=Array.from($.children);for(let r of u){if(!nk.has(r.tagName.toLowerCase())){r.remove();continue}for(let _ of Array.from(r.attributes)){let v=_.name.toLowerCase();if(v.startsWith("on")||v==="href"&&_.value.trim().toLowerCase().startsWith("javascript:"))r.removeAttribute(_.name)}YN(r)}}function mk($,u){let r=K("div","pf-dropzone");return r.style.border="2px dashed var(--border, #d1d5db)",r.style.borderRadius="var(--radius, 8px)",r.style.padding="32px",r.style.textAlign="center",r.style.cursor="pointer",r.textContent=F($.label??"Drop files here",u),r.addEventListener("dragover",(_)=>{_.preventDefault(),r.style.borderColor="var(--primary, #3b82f6)"}),r.addEventListener("dragleave",()=>{r.style.borderColor="var(--border, #d1d5db)"}),r.addEventListener("drop",(_)=>{_.preventDefault(),r.style.borderColor="var(--border, #d1d5db)"}),r}function lk($,u){let r=K("div","pf-mermaid");r.setAttribute("data-mermaid","true");let _=F($.content,u);if(r.textContent=_,typeof globalThis.mermaid<"u")r.classList.add("mermaid"),r.textContent=_;return r}var Ru=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function Qu($,u){let r=document.createElement("div");return r.className="pf-chart-tooltip",$.appendChild(r),$.addEventListener("mouseleave",()=>{r.classList.remove("pf-visible")}),{wrapper:$,tooltip:r,svgEl:u}}function j4($,u,r,_,v){let{tooltip:g,svgEl:U,wrapper:I}=$;if(v.length===0)return;let D="";if(_)D+=`<div class="pf-chart-tooltip-label">${Mu(_)}</div>`;for(let X of v)D+='<div class="pf-chart-tooltip-row">',D+=`<span class="pf-chart-tooltip-dot" style="background:${Mu(X.color)}"></span>`,D+=`<span>${Mu(X.label)}:</span> <strong>${Mu(String(X.value))}</strong>`,D+="</div>";g.innerHTML=D;let b=U.getBoundingClientRect(),N=I.getBoundingClientRect(),O=U.viewBox.baseVal,k=b.width/(O.width||1),L=b.left-N.left+u*k,j=g.offsetWidth||100,B=L+12;if(B+j>N.width)B=L-j-12;g.style.left=`${Math.max(0,B)}px`,g.style.top="4px",g.classList.add("pf-visible")}function Mu($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function AN($,u,r,_,v,g,U,I){let D=v.plotWidth/r.length;for(let b=0;b<r.length;b++){let N=v.plotLeft+b*D,O=document.createElementNS("http://www.w3.org/2000/svg","rect");O.setAttribute("x",String(N)),O.setAttribute("y",String(v.plotTop)),O.setAttribute("width",String(D)),O.setAttribute("height",String(v.plotHeight)),O.setAttribute("fill","transparent"),O.style.cursor="default";let k=g?r[b][g]:void 0,L=k!=null?I?I(k):String(k):void 0,j=_.map((C,Z)=>({label:C.label??C.dataKey,value:U(r[b][C.dataKey],C,Z),color:C.color??Ru[Z%Ru.length]})),B=N+D/2,X=()=>j4($,B,v.plotTop,L,j),M=()=>$.tooltip.classList.remove("pf-visible");O.addEventListener("mouseenter",X),O.addEventListener("mouseleave",M),O.addEventListener("touchstart",X,{passive:!0}),O.addEventListener("touchend",M,{passive:!0}),u.appendChild(O)}}function SN($,u,r,_,v,g,U,I,D,b){let N=r.length===1?v.plotWidth:v.plotWidth/(r.length-1);for(let O=0;O<r.length;O++){let k=r.length===1?(v.plotLeft+v.plotRight)/2:v.plotLeft+O/(r.length-1)*v.plotWidth,L=r.length===1?v.plotLeft:k-N/2,j=r.length===1?v.plotWidth:N,B=document.createElementNS("http://www.w3.org/2000/svg","rect");B.setAttribute("x",String(Math.max(v.plotLeft,L))),B.setAttribute("y",String(v.plotTop)),B.setAttribute("width",String(Math.min(j,v.plotRight-Math.max(v.plotLeft,L)))),B.setAttribute("height",String(v.plotHeight)),B.setAttribute("fill","transparent"),B.style.cursor="default";let X=g?r[O][g]:void 0,M=X!=null?b?b(X):String(X):void 0,C=_.map((R,z$)=>({label:R.label??R.dataKey,value:U(r[O][R.dataKey],R,z$),color:R.color??Ru[z$%Ru.length]})),Z=()=>{if(j4($,k,v.plotTop,M,C),I)I.setAttribute("x1",String(k)),I.setAttribute("x2",String(k)),I.setAttribute("opacity","1");if(D)for(let R of D){for(let z$ of R)z$.setAttribute("data-visible","false");R[O]?.setAttribute("data-visible","true")}},E=()=>{if($.tooltip.classList.remove("pf-visible"),I)I.setAttribute("opacity","0");if(D)for(let R of D)for(let z$ of R)z$.setAttribute("data-visible","false")};B.addEventListener("mouseenter",Z),B.addEventListener("mouseleave",E),B.addEventListener("touchstart",Z,{passive:!0}),B.addEventListener("touchend",E,{passive:!0}),u.appendChild(B)}}function qN(){W("BarChart",fk),W("LineChart",FN),W("AreaChart",FN),W("PieChart",ck),W("RadarChart",$_),W("ScatterChart",$_),W("RadialChart",$_),W("Histogram",xk)}var vv=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],B4="var(--muted-foreground, #6b7280)",yk="var(--border, #e5e7eb)",v_="10";function EN($,u,r,_=!1){let v=r?44:0,g=$-(_?44:0),U=10,I=u-24;return{plotLeft:v,plotRight:g,plotTop:10,plotBottom:I,plotWidth:g-v,plotHeight:I-10}}function XN($,u=5){if($<=0)return[0];let r=$/u,_=Math.pow(10,Math.floor(Math.log10(r))),v=r/_,g=v<=1.5?_:v<=3?2*_:v<=7?5*_:10*_,U=[];for(let I=0;I<=$+g*0.01;I+=g)U.push(Math.round(I*1000)/1000);return U}function iN($,u,r,_,v){let g=XN(r);for(let U of g){let I=u.plotBottom-(r>0?U/r*u.plotHeight:0),D=document.createElementNS("http://www.w3.org/2000/svg","text");if(D.setAttribute("x",String(u.plotLeft-6)),D.setAttribute("y",String(I+3)),D.setAttribute("text-anchor","end"),D.setAttribute("font-size",v_),D.setAttribute("fill",B4),D.textContent=u_(U,v),$.appendChild(D),_&&U>0){let b=document.createElementNS("http://www.w3.org/2000/svg","line");b.setAttribute("x1",String(u.plotLeft)),b.setAttribute("y1",String(I)),b.setAttribute("x2",String(u.plotRight)),b.setAttribute("y2",String(I)),b.setAttribute("stroke",yk),b.setAttribute("stroke-width","1"),b.setAttribute("stroke-dasharray","4 3"),$.appendChild(b)}}}function TN($,u,r,_){let v=XN(r);for(let g of v){let U=u.plotBottom-(r>0?g/r*u.plotHeight:0),I=document.createElementNS("http://www.w3.org/2000/svg","text");I.setAttribute("x",String(u.plotRight+6)),I.setAttribute("y",String(U+3)),I.setAttribute("text-anchor","start"),I.setAttribute("font-size",v_),I.setAttribute("fill",B4),I.textContent=u_(g,_),$.appendChild(I)}}function MN($,u,r,_,v,g){for(let U=0;U<u.length;U++){let I=document.createElementNS("http://www.w3.org/2000/svg","text");I.setAttribute("x",String(_(U))),I.setAttribute("y",String(v+14)),I.setAttribute("text-anchor","middle"),I.setAttribute("font-size",v_),I.setAttribute("fill",B4);let D=u[U][r];I.textContent=D==null?"":g?g(D):String(D),$.appendChild(I)}}function RN($,u){let r=document.createElementNS("http://www.w3.org/2000/svg","line");r.setAttribute("x1",String(u.plotLeft)),r.setAttribute("y1",String(u.plotBottom)),r.setAttribute("x2",String(u.plotRight)),r.setAttribute("y2",String(u.plotBottom)),r.setAttribute("stroke",B4),r.setAttribute("stroke-width","1"),$.appendChild(r)}function iv($,u,r){if($==null)return"";let _=j$(`{{ __v | ${u} }}`,{...r,scope:{...r.scope,__v:$}});return _==null?String($):String(_)}function u_($,u){if(u==="currency")return`$${$.toLocaleString()}`;if(u==="percent")return`${$}%`;if($>=1e6)return`${($/1e6).toFixed(1)}M`;if($>=1000)return`${($/1000).toFixed(1)}K`;return String($)}function QN($,u,r){return(_,v)=>{if(_===null||_===void 0)return"—";if(v.tooltipFormat)return iv(_,v.tooltipFormat,$);let g=v.yAxisId==="right"?r:u;return u_(Number(_),g)}}function fk($,u){let r=K("div","pf-chart pf-bar-chart"),_=j$($.data,u)??[],v=$.series??[],g=$.height??300;if(_.length===0||v.length===0)return r.textContent="No chart data",r;let U=$.showYAxis!==!1,I=$.showGrid===!0,D=$.showYAxisRight===!0,b=$.showTooltip!==!1,N=$.xAxis,O=$.tooltipXKey,k=$.xAxisFormat,L=$.tooltipXFormat,j=v.filter((h)=>h.yAxisId!=="right"),B=v.filter((h)=>h.yAxisId==="right"),X=D&&B.length>0,M=j.length>0?Math.max(..._.flatMap((h)=>j.map((c)=>Number(h[c.dataKey]??0))),1):1,C=X?Math.max(..._.flatMap((h)=>B.map((c)=>Number(h[c.dataKey]??0))),1):1,Z=400,E=EN(Z,g,U,X),R=Zu(Z,g,"Bar");if(U)iN(R,E,M,I,$.yAxisFormat);if(X)TN(R,E,C,$.yAxisRightFormat);RN(R,E);let z$=E.plotWidth/_.length,x$=z$/(v.length+1);for(let h=0;h<_.length;h++)for(let c=0;c<v.length;c++){let U$=v[c],f$=_[h][U$.dataKey];if(f$===null||f$===void 0)continue;let A$=U$.yAxisId==="right"?C:M,o$=Number(f$),h$=Math.max(0,o$/A$*E.plotHeight),Kv=E.plotLeft+h*z$+c*x$+x$/2,f=document.createElementNS("http://www.w3.org/2000/svg","rect");f.setAttribute("x",String(Kv)),f.setAttribute("y",String(E.plotBottom-h$)),f.setAttribute("width",String(x$*0.8)),f.setAttribute("height",String(h$)),f.setAttribute("fill",U$.color??vv[c%vv.length]),f.setAttribute("rx","2"),R.appendChild(f)}if(N){let h=k?(c)=>iv(c,k,u):void 0;MN(R,_,N,(c)=>{return E.plotLeft+c*z$+z$/2},E.plotBottom,h)}if(b){let h=Qu(r,R),c=QN(u,$.yAxisFormat,$.yAxisRightFormat);AN(h,R,_,v,E,O??N,c,L?(f$)=>iv(f$,L,u):void 0)}return r_(r,v,$.showLegend),r.appendChild(R),r}function FN($,u){let r=K("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),_=j$($.data,u)??[],v=$.series??[],g=$.height??300;if(_.length===0||v.length===0)return r.textContent="No chart data",r;let U=$.showYAxis!==!1,I=$.showGrid===!0,D=$.showYAxisRight===!0,b=$.showTooltip!==!1,N=$.xAxis,O=$.tooltipXKey,k=$.xAxisFormat,L=$.tooltipXFormat,j=v.filter((c)=>c.yAxisId!=="right"),B=v.filter((c)=>c.yAxisId==="right"),X=D&&B.length>0,M=j.length>0?Math.max(..._.flatMap((c)=>j.map((U$)=>Number(c[U$.dataKey]??0))),1):1,C=X?Math.max(..._.flatMap((c)=>B.map((U$)=>Number(c[U$.dataKey]??0))),1):1,Z=400,E=EN(Z,g,U,X),R=Zu(Z,g,$.type==="AreaChart"?"Area":"Line"),z$=$.type==="AreaChart";if(U)iN(R,E,M,I,$.yAxisFormat);if(X)TN(R,E,C,$.yAxisRightFormat);RN(R,E);let x$=[];for(let c=0;c<v.length;c++){let U$=v[c],f$=U$.yAxisId==="right",gv=f$?C:M,A$=U$.color??vv[c%vv.length],o$=_.map((f,I$)=>{let E$=f[U$.dataKey],jv=E$===null||E$===void 0,Vu=_.length===1?(E.plotLeft+E.plotRight)/2:E.plotLeft+I$/(_.length-1)*E.plotWidth,fw=jv?E.plotBottom:E.plotBottom-Number(E$)/gv*E.plotHeight;return{x:Vu,y:fw,isNull:jv}});if(z$){let f=[],I$=()=>{if(f.length<2){f=[];return}let E$=`M ${f[0].x},${E.plotBottom} `+f.map((Vu)=>`L ${Vu.x},${Vu.y}`).join(" ")+` L ${f[f.length-1].x},${E.plotBottom} Z`,jv=document.createElementNS("http://www.w3.org/2000/svg","path");jv.setAttribute("d",E$),jv.setAttribute("fill",A$),jv.setAttribute("opacity","0.15"),R.appendChild(jv),f=[]};for(let E$ of o$){if(E$.isNull){I$();continue}f.push(E$)}I$()}let h$="";for(let f of o$){if(f.isNull)continue;let I$=o$.indexOf(f),E$=I$===0||o$[I$-1].isNull;h$+=`${E$?"M":"L"} ${f.x},${f.y} `}if(h$){let f=document.createElementNS("http://www.w3.org/2000/svg","path");if(f.setAttribute("d",h$.trim()),f.setAttribute("fill","none"),f.setAttribute("stroke",A$),f.setAttribute("stroke-width","2"),f$)f.setAttribute("stroke-dasharray","6 3");R.appendChild(f)}let Kv=[];for(let f of o$){let I$=document.createElementNS("http://www.w3.org/2000/svg","circle");if(I$.setAttribute("cx",String(f.x)),I$.setAttribute("cy",String(f.y)),I$.setAttribute("r","4"),I$.setAttribute("fill",A$),I$.setAttribute("class","pf-data-dot"),I$.setAttribute("data-visible","false"),I$.style.pointerEvents="none",f.isNull)I$.style.display="none";R.appendChild(I$),Kv.push(I$)}x$.push(Kv)}let h=document.createElementNS("http://www.w3.org/2000/svg","line");if(h.setAttribute("class","pf-crosshair"),h.setAttribute("x1",String(E.plotLeft)),h.setAttribute("x2",String(E.plotLeft)),h.setAttribute("y1",String(E.plotTop)),h.setAttribute("y2",String(E.plotBottom)),h.setAttribute("stroke",B4),h.setAttribute("stroke-width","1"),h.setAttribute("stroke-dasharray","3 3"),h.setAttribute("opacity","0"),R.appendChild(h),N){let c=k?(U$)=>iv(U$,k,u):void 0;MN(R,_,N,(U$)=>{return _.length===1?(E.plotLeft+E.plotRight)/2:E.plotLeft+U$/(_.length-1)*E.plotWidth},E.plotBottom,c)}if(b){let c=Qu(r,R),U$=QN(u,$.yAxisFormat,$.yAxisRightFormat);SN(c,R,_,v,E,O??N,U$,h,x$,L?(gv)=>iv(gv,L,u):void 0)}return r_(r,v,$.showLegend),r.appendChild(R),r}function ck($,u){let r=K("div","pf-chart pf-pie-chart"),_=j$($.data,u)??[],v=$.series??[],g=$.height??300,U=Math.min(g,300),I=$.showTooltip!==!1;if(_.length===0||v.length===0)return r.textContent="No chart data",r;let D=Zu(U,U,"Pie"),b=U/2,N=U/2,O=U/2-10,k=v[0].dataKey,L=$.xAxis,j=$.tooltipXKey,B=$.tooltipXFormat,X=_.map((E)=>Number(E[k]??0)),M=X.reduce((E,R)=>E+R,0);if(M===0)return r.textContent="No chart data",r.appendChild(D),r;let C=I?Qu(r,D):void 0,Z=-Math.PI/2;for(let E=0;E<X.length;E++){let R=X[E]/M*2*Math.PI,z$=Z+R,x$=R>Math.PI?1:0,h=b+O*Math.cos(Z),c=N+O*Math.sin(Z),U$=b+O*Math.cos(z$),f$=N+O*Math.sin(z$),gv=vv[E%vv.length],A$=document.createElementNS("http://www.w3.org/2000/svg","path");if(A$.setAttribute("d",`M ${b},${N} L ${h},${c} A ${O},${O} 0 ${x$} 1 ${U$},${f$} Z`),A$.setAttribute("fill",gv),A$.style.cursor="default",C){let o$=j??L,h$=o$?_[E][o$]:void 0,Kv=h$!=null?B?iv(h$,B,u):String(h$):`Slice ${E+1}`,f=`${(X[E]/M*100).toFixed(1)}%`,I$=Z+R/2,E$=b+O*0.6*Math.cos(I$);A$.addEventListener("mouseenter",()=>{j4(C,E$,N,Kv,[{label:v[0].label??k,value:`${X[E]} (${f})`,color:gv}])}),A$.addEventListener("mouseleave",()=>{C.tooltip.classList.remove("pf-visible")}),A$.addEventListener("touchstart",()=>{j4(C,E$,N,Kv,[{label:v[0].label??k,value:`${X[E]} (${f})`,color:gv}])},{passive:!0}),A$.addEventListener("touchend",()=>{C.tooltip.classList.remove("pf-visible")},{passive:!0})}D.appendChild(A$),Z=z$}return r_(r,v,$.showLegend),r.appendChild(D),r}function $_($,u){let r=K("div",`pf-chart pf-${$.type.toLowerCase()}`);return r.textContent=`${$.type} — not yet supported in renderer`,r.style.padding="24px",r.style.textAlign="center",r.style.color="var(--muted-foreground, #6b7280)",r}function Zu($,u,r){let _=document.createElementNS("http://www.w3.org/2000/svg","svg");if(_.setAttribute("width","100%"),_.setAttribute("height",String(u)),_.setAttribute("viewBox",`0 0 ${$} ${u}`),_.setAttribute("role","img"),r)_.setAttribute("aria-label",`${r} chart`);return _.style.overflow="visible",_}function r_($,u,r){if(r===!1||u.length<=1)return;let _=K("div","pf-chart-legend");_.style.display="flex",_.style.gap="12px",_.style.fontSize="12px",_.style.marginBottom="8px";for(let v=0;v<u.length;v++){let g=K("div","pf-chart-legend-item");g.style.display="flex",g.style.alignItems="center",g.style.gap="4px";let U=K("span");U.style.width="8px",U.style.height="8px",U.style.borderRadius="50%",U.style.backgroundColor=u[v].color??vv[v%vv.length];let I=K("span");I.textContent=u[v].label??u[v].dataKey,g.appendChild(U),g.appendChild(I),_.appendChild(g)}$.appendChild(_)}function xk($,u){let r=K("div","pf-chart pf-histogram"),_=j$($.data,u);if(!_||_.length===0)return r.textContent="No data",r;let v=_,g=$.bins??10,U=$.height??200,I=$.color??vv[0],D=Math.min(...v),N=(Math.max(...v)-D)/g||1,O=Array(g).fill(0);for(let M of v){let C=Math.min(Math.floor((M-D)/N),g-1);O[C]++}let k=Math.max(...O),L=300,j=U,B=L/g,X=Zu(L,j,"Histogram");for(let M=0;M<g;M++){let C=k>0?O[M]/k*j:0,Z=document.createElementNS("http://www.w3.org/2000/svg","rect");Z.setAttribute("x",String(M*B)),Z.setAttribute("y",String(j-C)),Z.setAttribute("width",String(B-1)),Z.setAttribute("height",String(C)),Z.setAttribute("fill",I),X.appendChild(Z)}return r.appendChild(X),r}function ZN(){W("Table",ok),W("TableHead",__("thead")),W("TableBody",__("tbody")),W("TableFooter",__("tfoot")),W("TableRow",hk),W("TableHeader",tk),W("TableCell",dk),W("TableCaption",pk),W("ExpandableRow",ak)}function ok($,u){let r=document.createElement("table");return r.className="pf-table",r.style.width="100%",r.style.borderCollapse="collapse",y($,r,u),r}function __($){return(u,r)=>{let _=document.createElement($);return _.className=`pf-${$}`,y(u,_,r),_}}function hk($,u){let r=document.createElement("tr");return r.className="pf-table-row",y($,r,u),r}function tk($,u){let r=document.createElement("th");return r.className="pf-table-header",r.style.textAlign="left",r.style.padding="8px 12px",r.style.borderBottom="2px solid var(--border, #e5e7eb)",r.style.fontWeight="600",r.textContent=F($.content,u),r}function dk($,u){let r=document.createElement("td");if(r.className="pf-table-cell",r.style.padding="8px 12px",r.style.borderBottom="1px solid var(--border, #e5e7eb)",$.colSpan!=null)r.colSpan=$.colSpan;if($.rowSpan!=null)r.rowSpan=$.rowSpan;return y($,r,u),r}function pk($,u){let r=document.createElement("caption");return r.className="pf-table-caption",r.style.padding="8px",r.style.color="var(--muted-foreground, #6b7280)",r.style.fontSize="14px",r.textContent=F($.content,u),r}function ak($,u){let r=K("div","pf-expandable-row"),_=K("div","pf-expandable-row-summary");_.style.cursor="pointer",_.style.display="flex",_.style.alignItems="center",_.style.gap="8px";let v=K("span","pf-expandable-arrow");v.textContent="▶",v.style.transition="transform 0.2s",v.style.fontSize="10px",_.appendChild(v);let g=$.summary;if(g)for(let D of g)_.appendChild(D$(D,u));let U=K("div","pf-expandable-row-detail");U.style.display="none",U.style.paddingLeft="24px",y($,U,u);let I=!1;return _.addEventListener("click",()=>{I=!I,U.style.display=I?"block":"none",v.style.transform=I?"rotate(90deg)":""}),r.appendChild(_),r.appendChild(U),r}var nN=!1;function nu(){if(nN)return;nN=!0,DN(),ON(),PN(),JN(),LN(),GN(),KN(),HN(),VN(),qN(),ZN()}function CN($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function mN($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function lN($,u){if(!u)return;if(u.light)for(let[r,_]of Object.entries(u.light))$.style.setProperty(`--${CN(r)}`,mN(_));if(u.dark){let _=document.getElementById("prefab-dark-theme");if(!_)_=document.createElement("style"),_.id="prefab-dark-theme",document.head.appendChild(_);let v=Object.entries(u.dark).map(([g,U])=>` --${CN(g)}: ${mN(U)};`).join(`
84
- `);_.textContent=`@media (prefers-color-scheme: dark) {
85
- :root {
84
+ `);_.textContent=`[data-theme="dark"] {
85
+ ${v}
86
+ }
87
+ @media (prefers-color-scheme: dark) {
88
+ :root:not([data-theme="light"]) {
86
89
  ${v}
87
90
  }
88
91
  }`}}function yN($,u){if(!$||typeof document>"u")return;let r=(_)=>{for(let[v,g]of Object.entries($))if(ek(v,_))_.preventDefault(),u(g)};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)}function ek($,u){let r=$.toLowerCase().split("+").map((g)=>g.trim()),_=r[r.length-1],v=new Set(r.slice(0,-1));if(v.has("ctrl")!==(u.ctrlKey||u.metaKey))return!1;if(v.has("shift")!==u.shiftKey)return!1;if(v.has("alt")!==u.altKey)return!1;return u.key.toLowerCase()===_}function Cu($){let u=$?.baseUrl??(typeof window<"u"?window.location.origin:""),r={"Content-Type":"application/json",...$?.headers},_=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(v,g){let U=await _(`${u}/mcp/tools/call`,{method:"POST",headers:r,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:v,arguments:g}})});if(!U.ok)throw Error(`MCP tool call failed: ${U.status} ${U.statusText}`);let I=await U.json();if(I.error)throw Error(I.error.message??"MCP tool call returned error");let D=I.result?.content??I.content??[];for(let b of D)if(b.type==="text"&&b.text!==void 0){try{let N=JSON.parse(b.text);if(typeof N==="object"&&N!==null&&"$prefab"in N)return N;return N}catch{}return b.text}return I.result??I},async sendMessage(v){await _(`${u}/mcp/messages`,{method:"POST",headers:r,body:JSON.stringify({message:v})})}}}function mu(){return{callTool($){return console.warn(`[prefab] No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return console.warn("[prefab] No MCP transport: sendMessage ignored",$),Promise.resolve()}}}function UL($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class Hu{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;extApp;constructor($="*"){this.hostOrigin=$}connect(){if(typeof window>"u")return;let $=DL();if($)this.postFn=(r)=>$.postMessage(r);let u=(r)=>{if(this.hostOrigin!=="*"&&r.origin!==this.hostOrigin)return;let _=r.data;if(UL(_)){this.handleJsonRpc(_);return}let v=_;if(!v?.type.startsWith("prefab:"))return;if(v.type==="prefab:tool-call-response"&&v.id){let U=this.pending.get(v.id);if(U){if(this.pending.delete(v.id),v.payload?.error!=null)U.reject(Error(v.payload.error));else U.resolve(v.payload?.result);return}}let g=this.listeners.get(v.type);if(g)for(let U of g)U(v.payload??{})};window.addEventListener("message",u),this.cleanup=()=>window.removeEventListener("message",u)}async initialize($){try{return await Promise.any([this.initPrefab($),this.initJsonRpc($)])}catch{return this.initExtApps($)}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();if(this.protocol==="ext-apps"&&this.extApp)return this.createExtAppsTransport();return this.createPrefabTransport()}requestMode($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:$});else if(this.protocol==="ext-apps"&&this.extApp)this.extApp.requestDisplayMode({mode:$});else this.sendPrefab("prefab:request-mode",{mode:$})}openLink($,u){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:u});else if(this.protocol==="ext-apps"&&this.extApp)this.extApp.openLink({url:$});else this.sendPrefab("prefab:open-link",{url:$,target:u})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else if(this.protocol==="ext-apps"&&this.extApp)this.extApp.updateModelContext({structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}on($,u){if(!this.listeners.has($))this.listeners.set($,new Set);let r=this.listeners.get($);if(r)r.add(u)}off($,u){this.listeners.get($)?.delete(u)}disconnect(){this.cleanup?.(),this.extApp=void 0,this.listeners.clear();for(let[,$]of this.pending)$.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,$]of this.rpcPending)$.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab($){return new Promise((u,r)=>{let _=!1,v=(g)=>{if(_)return;_=!0,this.off("prefab:init-response",v),this.protocol="prefab",u(g)};this.on("prefab:init-response",v),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!_)_=!0,this.off("prefab:init-response",v),r(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,u)=>{let r=`tc-${++this.callIdCounter}`;return new Promise((_,v)=>{this.pending.set(r,{resolve:_,reject:v}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:u},r),setTimeout(()=>{if(this.pending.has(r))this.pending.delete(r),v(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()}}}sendPrefab($,u,r){if(typeof window>"u")return;let _=window.parent!==window?window.parent:window,v={type:$,payload:u,id:r};_.postMessage(v,this.hostOrigin)}handleJsonRpc($){if(!("method"in $)){let _=this.rpcPending.get($.id);if(_)if(this.rpcPending.delete($.id),$.error)_.reject(Error($.error.message));else _.resolve($.result);return}let u=$.method,r=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(u){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:r.arguments??r});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:r.arguments??r});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:r});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",r);break;case"ui/notifications/host-context-changed":{let _={};if(typeof r.theme==="string")_.colorScheme=r.theme;if(typeof r.styles==="object"&&r.styles!==null){let v=r.styles;if(v.variables)_.variables=v.variables}this.dispatch("prefab:theme-update",_);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",r);break}}initJsonRpc($){return new Promise((u,r)=>{let _=++this.rpcIdCounter,v=!1;this.rpcPending.set(_,{resolve:(g)=>{if(v)return;v=!0,this.protocol="jsonrpc";let U=g??{},I=U.hostInfo??{},D=U.hostContext??{},b=U.hostCapabilities??{},N;if(typeof D.theme==="string"||typeof D.styles==="object"){if(N={},typeof D.theme==="string")N.colorScheme=D.theme;if(typeof D.styles==="object"&&D.styles!==null){let O=D.styles;if(O.variables)N.variables=O.variables}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}}),u({hostName:I.name,hostVersion:I.version,capabilities:{toast:!0,navigation:b.openLinks!=null,messaging:!0,displayModes:D.availableDisplayModes??[]},theme:N,toolInput:void 0,meta:D})},reject:(g)=>{if(v)return;v=!0,r(g)}}),this.postJsonRpc({jsonrpc:"2.0",id:_,method:"ui/initialize",params:{protocolVersion:"2026-01-26",capabilities:{},clientInfo:{name:"prefab",version:"0.2"},appCapabilities:{...$.displayModes&&{availableDisplayModes:$.displayModes}}}}),setTimeout(()=>{if(!v)v=!0,this.rpcPending.delete(_),r(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,u)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:u})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})}}}sendRpcRequest($,u){let r=++this.rpcIdCounter;return new Promise((_,v)=>{this.rpcPending.set(r,{resolve:_,reject:v}),this.postJsonRpc({jsonrpc:"2.0",id:r,method:$,params:u}),setTimeout(()=>{if(this.rpcPending.has(r))this.rpcPending.delete(r),v(Error(`JSON-RPC '${$}' timed out`))},30000)})}sendRpcNotification($,u){this.postJsonRpc({jsonrpc:"2.0",method:$,params:u})}postJsonRpc($){if(typeof window>"u")return;if($.id!=null&&typeof $.method==="string")this.sentRpcIds.add($.id);if(this.postFn)this.postFn($);else(window.parent!==window?window.parent:window).postMessage($,this.hostOrigin)}async initExtApps($){let{App:u,PostMessageTransport:r}=await Promise.resolve().then(() => (Zw(),Qw)),v=new r(window.parent,window.parent),g=new u({name:"prefab",version:"0.2"},{...$.displayModes&&{availableDisplayModes:$.displayModes}});this.wireExtAppsEvents(g),await Promise.race([g.connect(v),IL(3000,"ext-apps init timeout")]),this.extApp=g,this.protocol="ext-apps";let U=g.getHostVersion(),I=g.getHostCapabilities(),D=g.getHostContext();return{hostName:U?.name,hostVersion:U?.version,capabilities:{toast:!0,navigation:I?.openLinks!=null,messaging:!0},theme:D?.theme?{colorScheme:D.theme}:void 0,toolInput:void 0,meta:D}}wireExtAppsEvents($){$.addEventListener("toolinput",(u)=>{this.dispatch("prefab:tool-input",{args:u.arguments??{}})}),$.addEventListener("toolinputpartial",(u)=>{this.dispatch("prefab:tool-input-partial",{args:u.arguments??{}})}),$.addEventListener("toolresult",(u)=>{this.dispatch("prefab:tool-result",{result:u})}),$.addEventListener("toolcancelled",()=>{this.dispatch("prefab:tool-cancelled",{})}),$.addEventListener("hostcontextchanged",(u)=>{let r={};if(u.theme)r.colorScheme=u.theme;this.dispatch("prefab:theme-update",r)})}createExtAppsTransport(){let $=this.extApp;if(!$)throw Error("ext-apps not initialized");return{callTool:async(u,r)=>{let v=(await $.callServerTool({name:u,arguments:r})).content.filter((g)=>g.type==="text").map((g)=>g.text);return v.length===1?v[0]:v},sendMessage:async(u)=>{await $.sendMessage({role:"user",content:[{type:"text",text:u}]})}}}dispatch($,u){let r=this.listeners.get($);if(r)for(let _ of r)_(u)}}function IL($,u){return new Promise((r,_)=>setTimeout(()=>_(Error(u)),$))}function hb($,u){if(u.variables)for(let[r,_]of Object.entries(u.variables))$.style.setProperty(r.startsWith("--")?r:`--${r}`,_);if(u.colorScheme&&u.colorScheme!=="auto")$.setAttribute("data-theme",u.colorScheme)}function fr(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function DL(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let u=$.acquireVsCodeApi();if(u!==null&&typeof u==="object"&&"postMessage"in u)return u}catch{return}return}var R$={mount($,u,r){nu();let _=[];if(u.pipes)for(let[O,k]of Object.entries(u.pipes))NL(O,k,_);let v=new G4(u.state),g;if(r?.transport&&"callTool"in r.transport)g=r.transport;else if(r?.transport)g=Cu(r.transport);else g=mu();let U=r?.onToast??zL,I={store:v,scope:{},transport:g,rerender:()=>N(),onToast:U,defs:u.defs};lN($,u.theme);let D=[];if(u.stylesheets)for(let O of u.stylesheets){let k=document.createElement("style");k.textContent=O,k.dataset.prefab="injected",document.head.appendChild(k),D.push(k)}let b;if(u.keyBindings)b=yN(u.keyBindings,async(O)=>{await r$(O,{store:v,transport:g,scope:{},rerender:()=>N(),onToast:U})});function N(){$.innerHTML="";let O=D$(u.view,I);$.appendChild(O)}return N(),{rerender:()=>N(),update(O){v.merge(O.update.state),N()},store:v,destroy(){b?.(),vN();for(let O of D)O.remove();for(let O of _)or(O);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},bL=new Set(["find","dot","length","upper","lower","truncate","join","first","last","abs","round","number","currency","percent","compact","date","time","datetime","pluralize","default","selectattr","rejectattr"]);function NL($,u,r){if(bL.has($)){console.warn(`[prefab] wire pipe "${$}" ignored — shadows built-in`);return}try{let _=Function("return ("+u+")")();if(typeof _!=="function"){console.warn(`[prefab] wire pipe "${$}" — source did not evaluate to a function`);return}xr($,_),r.push($)}catch(_){console.warn(`[prefab] wire pipe "${$}" — failed to hydrate:`,_)}}function zL($){if(typeof document>"u")return;let u=OL(),r=document.createElement("div");r.className="pf-toast",r.setAttribute("data-variant",$.variant??"default"),r.style.padding="12px 16px",r.style.borderRadius="8px",r.style.backgroundColor="var(--card, #fff)",r.style.border="1px solid var(--border, #e5e7eb)",r.style.boxShadow="0 4px 12px rgb(0 0 0 / 0.15)",r.style.marginBottom="8px",r.style.transition="opacity 0.3s ease";let _=document.createElement("div");if(_.textContent=$.message,_.style.fontWeight="500",r.appendChild(_),$.description){let g=document.createElement("div");g.textContent=$.description,g.style.fontSize="14px",g.style.color="var(--muted-foreground, #6b7280)",r.appendChild(g)}u.appendChild(r);let v=$.duration??4000;setTimeout(()=>{r.style.opacity="0",setTimeout(()=>r.remove(),300)},v)}function OL(){let u=document.getElementById("prefab-toast-container");if(!u)u=document.createElement("div"),u.id="prefab-toast-container",u.style.position="fixed",u.style.bottom="16px",u.style.right="16px",u.style.zIndex="9999",u.style.maxWidth="400px",document.body.appendChild(u);return u}if(typeof window<"u"){let $=window;$.PrefabRenderer=R$,$.prefab={app:cr,mount:R$.mount.bind(R$),isPrefabData:R$.isPrefabData.bind(R$),isPrefabUpdate:R$.isPrefabUpdate.bind(R$),Bridge:Hu,isIframe:fr,registerPipe:xr,unregisterPipe:or,listPipes:pb,registerComponent:W};let u=$.__PREFAB_DATA__;if(u!=null){let r=document.getElementById("prefab-root");if(r)R$.mount(r,u)}}async function cr($){nu();let u=$?.mode??"auto",r=u==="bridge"||u==="auto"&&fr(),_,v,g={capabilities:{}};if(r)v=new Hu($?.hostOrigin),v.connect(),g=await v.initialize($?.capabilities??{toolInput:!0}),_=v.createTransport();else if($?.transport)_=Cu($.transport);else _=mu();if(g.theme&&typeof document<"u")hb(document.documentElement,g.theme);let U,I,D,b,N=g.toolInput,O;if(v)v.on("prefab:tool-input",(j)=>{let B=j.args??j;if(U)U(B);else N=B}),v.on("prefab:tool-result",(j)=>{let B=j.result??j;if(I)I(B);else O=B}),v.on("prefab:tool-cancelled",()=>{D?.()}),v.on("prefab:tool-input-partial",(j)=>{b?.(j.args??j)}),v.on("prefab:theme-update",(j)=>{if(typeof document<"u")hb(document.documentElement,j)});function k(j,...B){let X=nw(j),M=new G4,C={store:M,scope:{},transport:_,rerender:()=>Z(),onToast:void 0};function Z(){X.innerHTML="";for(let E of B)X.appendChild(D$(E,C))}return Z(),{rerender:Z,store:M,destroy:()=>{X.innerHTML=""}}}return{callTool:(j,B={})=>_.callTool(j,B),sendMessage:(j)=>_.sendMessage(j),onToolInput:(j)=>{if(U=j,N){let B=N;N=void 0,queueMicrotask(()=>j(B))}},onToolResult:(j)=>{if(I=j,O!==void 0){let B=O;O=void 0,queueMicrotask(()=>j(B))}},onToolCancelled:(j)=>{D=j},onToolInputPartial:(j)=>{b=j},render:k,mount:(j,B,X)=>{let M=nw(j);return R$.mount(M,B,{transport:_,...X})},requestMode:(j)=>v?.requestMode(j),openLink:(j,B)=>{if(v)v.openLink(j,B);else if(typeof window<"u")window.open(j,B??"_blank")},updateContext:(j)=>{if(v)v.updateContext(j)},host:g,capabilities:g.capabilities,theme:g.theme,transport:_,destroy:()=>v?.disconnect()}}function nw($){if(typeof $==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let u=document.querySelector($);if(!u)throw Error(`Element not found: ${$}`);return u}return $}var Cw="#root";function tb($){return R$.isPrefabData($)}function mw($){return R$.isPrefabUpdate($)}function lw($){if(tb($))return $;if($!==null&&typeof $==="object"){let u=$;if(tb(u.structuredContent))return u.structuredContent;if(Array.isArray(u.content))for(let r of u.content){let _=r;if(_.type==="text"&&typeof _.text==="string")try{let v=JSON.parse(_.text);if(tb(v))return v}catch{}}}return null}async function yw(){let $=document.querySelector(Cw);if(!$){console.error(`[prefab:auto] Mount target "${Cw}" not found`);return}let u=$,r=await cr(),_;function v(g){if(_)_.destroy();_=r.mount(u,g)}r.onToolResult((g)=>{let U=lw(g);if(U)v(U);else if(mw(g)&&_)_.update(g)}),r.onToolInput((g)=>{let U=lw(g);if(U)v(U);else if(mw(g)&&_)_.update(g)})}function wL(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{yw().catch(($)=>{console.error("[prefab:auto] Boot failed:",$)})},{once:!0});else queueMicrotask(()=>{yw().catch(($)=>{console.error("[prefab:auto] Boot failed:",$)})})}wL();})();
@@ -81,8 +81,11 @@ container holding the app. Specify either width or maxWidth, and either height o
81
81
  `)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(v)){r.push("<hr />"),g++;continue}let _=/^(#{1,6})\s+(.+)$/.exec(v);if(_){let I=_[1].length;r.push(`<h${I}>${Q4(_[2])}</h${I}>`),g++;continue}if(v.startsWith("> ")||v===">"){let I=[];while(g<u.length&&(u[g].startsWith("> ")||u[g]===">"))I.push(u[g].replace(/^>\s?/,"")),g++;r.push(`<blockquote>${PN(I.join(`
82
82
  `))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(v)){r.push("<ul>");while(g<u.length&&/^[\s]*[-*+]\s+/.test(u[g]))r.push(`<li>${Q4(u[g].replace(/^[\s]*[-*+]\s+/,""))}</li>`),g++;r.push("</ul>");continue}if(/^[\s]*\d+\.\s+/.test(v)){r.push("<ol>");while(g<u.length&&/^[\s]*\d+\.\s+/.test(u[g]))r.push(`<li>${Q4(u[g].replace(/^[\s]*\d+\.\s+/,""))}</li>`),g++;r.push("</ol>");continue}if(v.trim()===""){g++;continue}let U=[];while(g<u.length&&u[g].trim()!==""&&!/^#{1,6}\s/.test(u[g])&&!/^[-*+]\s/.test(u[g])&&!/^\d+\.\s/.test(u[g])&&!u[g].startsWith("> ")&&!u[g].trimStart().startsWith("```")&&!/^(\s*[-*_]\s*){3,}$/.test(u[g]))U.push(u[g]),g++;r.push(`<p>${U.map(Q4).join("<br />")}</p>`)}return r.join(`
83
83
  `)}function CP($,u){let r=document.createElement("kbd");return r.className="pf-kbd",r.textContent=F($.content,u),r}function JN(){W("Card",mP),W("CardHeader",vg("pf-card-header")),W("CardTitle",kN("pf-card-title","h3")),W("CardDescription",kN("pf-card-description","p")),W("CardContent",vg("pf-card-content")),W("CardFooter",vg("pf-card-footer"))}function mP($,u){let r=K("div","pf-card");return r.style.border="1px solid var(--border, #e5e7eb)",r.style.borderRadius="var(--radius, 8px)",r.style.backgroundColor="var(--card, #fff)",r.style.overflow="hidden",y($,r,u),r}function vg($){return(u,r)=>{let g=K("div",$);return g.style.padding="16px 24px",y(u,g,r),g}}function kN($,u){return(r,g)=>{let v=document.createElement(u);return v.className=$,v.textContent=F(r.content,g),v}}function WN(){W("DataTable",lP),W("Badge",yP),W("Dot",fP),W("Metric",cP),W("Ring",xP),W("Progress",oP),W("Separator",hP),W("Loader",tP),W("Icon",dP),W("Sparkline",pP)}function lP($,u){let r=K("div","pf-datatable-wrapper"),g=document.createElement("table");g.className="pf-datatable",g.style.width="100%",g.style.borderCollapse="collapse";let v=$.columns??[],_=j$($.rows,u),U=$.rowKey,I=$.selected,D=document.createElement("thead"),b=document.createElement("tr");for(let O of v){let P=document.createElement("th");P.className="pf-datatable-th",P.textContent=O.header??O.key,P.style.padding="8px 12px",P.style.textAlign="left",P.style.borderBottom="2px solid var(--border, #e5e7eb)",b.appendChild(P)}D.appendChild(b),g.appendChild(D);let N=document.createElement("tbody");if(Array.isArray(_)){let O=I!=null?j$(I,u):void 0;for(let P of _){let L=document.createElement("tr");L.className="pf-datatable-row";let j=P;if(U&&O!=null&&j[U]!=null&&String(j[U])===String(O))L.classList.add("pf-datatable-row-selected"),L.style.backgroundColor="var(--primary-bg, #eff6ff)";if($.onRowClick!=null&&U)L.style.cursor="pointer",L.addEventListener("click",()=>{let B={...u.scope,$item:j,$index:_.indexOf(P)},E=O$({...u,scope:B});r$($.onRowClick,E)});for(let B of v){let E=document.createElement("td");E.className="pf-datatable-td";let M;if(B.accessor)M=j$(`{{ $item.${B.accessor} }}`,{...u,scope:{...u.scope,$item:j}});else if(M=j[B.key],B.format&&M!=null)M=j$(`{{ __fmtVal | ${B.format} }}`,{...u,scope:{...u.scope,__fmtVal:M}});E.textContent=M==null?"":String(M),E.style.padding="8px 12px",E.style.borderBottom="1px solid var(--border, #e5e7eb)",L.appendChild(E)}N.appendChild(L)}}if(g.appendChild(N),$.search===!0){let O=document.createElement("input");O.type="text",O.placeholder="Search...",O.className="pf-datatable-search",O.style.marginBottom="8px",O.style.padding="6px 12px",O.style.width="100%",O.style.boxSizing="border-box",O.addEventListener("input",()=>{let P=O.value.toLowerCase(),L=Array.from(N.querySelectorAll("tr"));for(let j of L){let B=j.textContent.toLowerCase();j.style.display=B.includes(P)?"":"none"}}),r.appendChild(O)}return r.appendChild(g),r}function yP($,u){let r=K("span","pf-badge"),g=$.variant??"default";return r.setAttribute("data-variant",g),r.style.alignItems="center",r.style.padding="2px 10px",r.style.borderRadius="9999px",r.style.fontSize="12px",r.style.fontWeight="500",r.textContent=F($.label??$.content,u),aP(r,g),r}function fP($,u){let r=K("span","pf-dot"),g=$.color??"gray";return r.style.display="inline-block",r.style.width="8px",r.style.height="8px",r.style.borderRadius="50%",r.style.backgroundColor=g,r}function cP($,u){let r=K("div","pf-metric"),g=K("div","pf-metric-label");g.textContent=F($.label,u),g.style.fontSize="14px",g.style.color="var(--muted-foreground, #6b7280)",r.appendChild(g);let v=K("div","pf-metric-value");if(v.textContent=F($.value,u),v.style.fontSize="28px",v.style.fontWeight="700",r.appendChild(v),$.delta!=null){let _=K("span","pf-metric-delta");_.textContent=F($.delta,u);let U=$.trend??"",I=$.trendSentiment??"neutral";if(_.style.fontSize="14px",_.style.color=I==="positive"?"green":I==="negative"?"red":"inherit",U==="up")_.textContent="↑ "+_.textContent;else if(U==="down")_.textContent="↓ "+_.textContent;r.appendChild(_)}if($.description!=null){let _=K("div","pf-metric-desc");_.textContent=F($.description,u),_.style.fontSize="12px",_.style.color="var(--muted-foreground, #6b7280)",r.appendChild(_)}return r}function xP($,u){let r=K("div","pf-ring"),g=$.size??80,v=$.thickness??8,_=Number(j$($.value,u)??0),U=Math.max(0,Math.min(100,_)),I=(g-v)/2,D=2*Math.PI*I,b=D*(1-U/100),N=document.createElementNS("http://www.w3.org/2000/svg","svg");N.setAttribute("width",String(g)),N.setAttribute("height",String(g)),N.setAttribute("viewBox",`0 0 ${g} ${g}`);let O=document.createElementNS("http://www.w3.org/2000/svg","circle");O.setAttribute("cx",String(g/2)),O.setAttribute("cy",String(g/2)),O.setAttribute("r",String(I)),O.setAttribute("fill","none"),O.setAttribute("stroke","var(--muted, #e5e7eb)"),O.setAttribute("stroke-width",String(v));let P=document.createElementNS("http://www.w3.org/2000/svg","circle");if(P.setAttribute("cx",String(g/2)),P.setAttribute("cy",String(g/2)),P.setAttribute("r",String(I)),P.setAttribute("fill","none"),P.setAttribute("stroke","var(--primary, #3b82f6)"),P.setAttribute("stroke-width",String(v)),P.setAttribute("stroke-dasharray",String(D)),P.setAttribute("stroke-dashoffset",String(b)),P.setAttribute("stroke-linecap","round"),P.style.transform="rotate(-90deg)",P.style.transformOrigin="center",N.appendChild(O),N.appendChild(P),r.appendChild(N),$.label!=null){let L=K("div","pf-ring-label");L.textContent=F($.label,u),L.style.textAlign="center",L.style.fontSize="12px",r.appendChild(L)}return r}function oP($,u){let r=K("div","pf-progress");r.setAttribute("role","progressbar");let g=Number(j$($.value,u)??0),v=$.max??100,_=v>0?Math.max(0,Math.min(100,g/v*100)):0;r.setAttribute("aria-valuenow",String(g)),r.setAttribute("aria-valuemin","0"),r.setAttribute("aria-valuemax",String(v)),r.style.height="8px",r.style.backgroundColor="var(--muted, #e5e7eb)",r.style.borderRadius="4px",r.style.overflow="hidden";let U=K("div","pf-progress-fill");return U.style.height="100%",U.style.width=`${_}%`,U.style.backgroundColor="var(--primary, #3b82f6)",U.style.borderRadius="4px",U.style.transition="width 0.3s ease",r.appendChild(U),r}function hP($,u){let r=document.createElement("hr");return r.className="pf-separator",r.style.border="none",r.style.borderTop="1px solid var(--border, #e5e7eb)",r.style.margin="8px 0",r}function tP($,u){let r=K("div","pf-loader");return r.textContent="⏳",r.style.display="flex",r.style.justifyContent="center",r.style.padding="16px",r}function dP($,u){let r=K("span","pf-icon");return r.setAttribute("data-icon",F($.name??$.content,u)),r}function pP($,u){let r=K("div","pf-sparkline"),g=$.data??[];if(g.length===0)return r;let v=120,_=32,U=Math.max(...g),I=Math.min(...g),D=U-I||1,b=document.createElementNS("http://www.w3.org/2000/svg","svg");b.setAttribute("width",String(v)),b.setAttribute("height",String(_)),b.setAttribute("viewBox",`0 0 ${v} ${_}`);let N=g.length>1?g.length-1:1,O=g.map((L,j)=>{let B=j/N*v,E=_-(L-I)/D*(_-4)-2;return`${B},${E}`}).join(" "),P=document.createElementNS("http://www.w3.org/2000/svg","polyline");return P.setAttribute("points",O),P.setAttribute("fill","none"),P.setAttribute("stroke","var(--primary, #3b82f6)"),P.setAttribute("stroke-width","1.5"),b.appendChild(P),r.appendChild(b),r}function aP($,u){let r={default:{bg:"var(--primary, #3b82f6)",fg:"#fff"},secondary:{bg:"var(--secondary, #f3f4f6)",fg:"var(--secondary-foreground, #1f2937)"},destructive:{bg:"var(--destructive, #ef4444)",fg:"#fff"},success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"},outline:{bg:"transparent",fg:"inherit"}},g=r[u]??r.default;if($.style.backgroundColor=g.bg,$.style.color=g.fg,u==="outline")$.style.border="1px solid var(--border, #e5e7eb)"}function GN(){W("Form",eP),W("Input",sP),W("Textarea",$0),W("Button",v0),W("ButtonGroup",u0),W("Select",r0),W("SelectOption",g0),W("SelectGroup",n4("pf-select-group")),W("SelectLabel",Vu("pf-select-label")),W("SelectSeparator",LN),W("Checkbox",_0),W("Switch",U0),W("Slider",I0),W("Radio",b0),W("RadioGroup",N0),W("Combobox",z0),W("ComboboxOption",O0),W("ComboboxGroup",n4("pf-combobox-group")),W("ComboboxLabel",Vu("pf-combobox-label")),W("ComboboxSeparator",LN),W("Calendar",w0),W("DatePicker",P0),W("Field",n4("pf-field")),W("FieldTitle",Vu("pf-field-title")),W("FieldDescription",Vu("pf-field-description")),W("FieldContent",n4("pf-field-content")),W("FieldError",Vu("pf-field-error")),W("ChoiceCard",k0)}function eP($,u){let r=document.createElement("form");return r.className="pf-form",r.addEventListener("submit",(g)=>{g.preventDefault();let v=new FormData(r),_={};if(v.forEach((U,I)=>{_[I]=U}),u.store.merge(_),$.onSubmit!=null){let U=O$(u);U.scope={...u.scope,..._},r$($.onSubmit,U)}}),y($,r,u),r}function sP($,u){let r=K("div","pf-input-wrapper");if(r.style.display="flex",r.style.flexDirection="column",r.style.gap="4px",$.label!=null){let _=document.createElement("label");if(_.className="pf-input-label",_.textContent=F($.label,u),$.name!=null)_.htmlFor=$.name;_.style.fontSize="14px",_.style.fontWeight="500",r.appendChild(_)}let g=document.createElement("input");if(g.className="pf-input",g.type=$.inputType??"text",$.name!=null)g.name=$.name;if($.name!=null)g.id=`pf-input-${$.name}`;if($.placeholder!=null)g.placeholder=F($.placeholder,u);if($.required===!0)g.required=!0,g.setAttribute("aria-required","true");if($.error!=null)g.setAttribute("aria-invalid","true");let v=$.name;if(v){let _=u.store.get(v);if(_!=null)g.value=String(_);g.addEventListener("input",()=>{if(u.store.set(v,g.value),$.onChange!=null)r$($.onChange,{...O$(u),scope:{...u.scope,$event:g.value}})})}return ug(g),r.appendChild(g),r}function $0($,u){let r=K("div","pf-textarea-wrapper"),g=document.createElement("textarea");if(g.className="pf-textarea",$.name!=null)g.name=$.name;if($.name!=null)g.id=`pf-textarea-${$.name}`;if($.placeholder!=null)g.placeholder=F($.placeholder,u);if($.rows!=null)g.rows=$.rows;if($.required===!0)g.setAttribute("aria-required","true");let v=$.name;if(v!=null){let _=u.store.get(v);if(_!=null)g.value=String(_);g.addEventListener("input",()=>{if(u.store.set(v,g.value),$.onChange!=null)r$($.onChange,{...O$(u),scope:{...u.scope,$event:g.value}})})}return ug(g),r.appendChild(g),r}function v0($,u){let r=document.createElement("button");r.className="pf-button",r.type=$.submit===!0?"submit":"button",r.textContent=F($.label,u);let g=$.variant??"default";if(r.setAttribute("data-variant",g),D0(r,g),$.size!=null)r.setAttribute("data-size",$.size);if($.disabled===!0)r.disabled=!0;if($.onClick!=null)r.addEventListener("click",()=>{r$($.onClick,O$(u))});return r}function u0($,u){let r=K("div","pf-button-group");return r.style.display="flex",r.style.gap="8px",y($,r,u),r}function r0($,u){let r=K("div","pf-select-wrapper"),g=document.createElement("select");if(g.className="pf-select",$.name!=null)g.name=$.name;if(ug(g),$.placeholder!=null){let U=document.createElement("option");U.value="",U.textContent=F($.placeholder,u),U.disabled=!0,U.selected=!0,U.hidden=!0,g.appendChild(U)}let v=$.options;if(Array.isArray(v))for(let U of v){let I=document.createElement("option");I.value=U.value??"",I.textContent=U.label??I.value,g.appendChild(I)}if($.children)for(let U of $.children)if(U.type==="SelectOption"){let I=document.createElement("option");I.value=U.value??"",I.textContent=U.label??I.value,g.appendChild(I)}else g.appendChild(D$(U,u));let _=$.name;if(_){let U=u.store.get(_);if(U!=null)g.value=String(U);g.addEventListener("change",()=>{if(u.store.set(_,g.value),$.onChange!=null)r$($.onChange,{...O$(u),scope:{...u.scope,$event:g.value}})})}return r.appendChild(g),r}function g0($,u){return K("span")}function _0($,u){let r=K("label","pf-checkbox-wrapper");r.style.display="flex",r.style.alignItems="center",r.style.gap="8px",r.style.cursor="pointer";let g=document.createElement("input");if(g.type="checkbox",g.className="pf-checkbox",$.name!=null)g.name=$.name;if($.checked===!0)g.checked=!0;let v=$.name;if(v){let _=u.store.get(v);if(typeof _==="boolean")g.checked=_;g.addEventListener("change",()=>{if(u.store.set(v,g.checked),$.onChange!=null)r$($.onChange,{...O$(u),scope:{...u.scope,$event:g.checked}})})}if(r.appendChild(g),$.label!=null){let _=K("span");_.textContent=F($.label,u),r.appendChild(_)}return r}function U0($,u){let r=K("label","pf-switch-wrapper");r.style.display="flex",r.style.alignItems="center",r.style.gap="8px",r.style.cursor="pointer";let g=document.createElement("input");if(g.type="checkbox",g.className="pf-switch",g.setAttribute("role","switch"),$.name!=null)g.name=$.name;let v=$.name;if(v){let _=u.store.get(v);if(typeof _==="boolean")g.checked=_;g.addEventListener("change",()=>{if(u.store.set(v,g.checked),$.onChange!=null)r$($.onChange,{...O$(u),scope:{...u.scope,$event:g.checked}})})}if(r.appendChild(g),$.label!=null){let _=K("span");_.textContent=F($.label,u),r.appendChild(_)}return r}function I0($,u){let r=K("div","pf-slider-wrapper"),g=document.createElement("input");if(g.type="range",g.className="pf-slider",$.name!=null)g.name=$.name;if($.min!=null)g.min=String($.min);if($.max!=null)g.max=String($.max);if($.step!=null)g.step=String($.step);let v=$.name;if(v){let _=u.store.get(v);if(_!=null)g.value=String(_);g.addEventListener("input",()=>{if(u.store.set(v,Number(g.value)),$.onChange!=null)r$($.onChange,{...O$(u),scope:{...u.scope,$event:Number(g.value)}})})}return r.appendChild(g),r}function ug($){$.style.padding="8px 12px",$.style.border="1px solid var(--border, #d1d5db)",$.style.borderRadius="var(--radius, 6px)",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function D0($,u){$.style.padding="8px 16px",$.style.borderRadius="var(--radius, 6px)",$.style.fontSize="14px",$.style.fontWeight="500",$.style.cursor="pointer",$.style.border="none";let r={default:{bg:"var(--primary, #3b82f6)",fg:"#fff"},secondary:{bg:"var(--secondary, #f3f4f6)",fg:"var(--secondary-foreground, #1f2937)"},destructive:{bg:"var(--destructive, #ef4444)",fg:"#fff"},outline:{bg:"transparent",fg:"inherit"},ghost:{bg:"transparent",fg:"inherit"},link:{bg:"transparent",fg:"var(--primary, #3b82f6)"}},g=r[u]??r.default;if($.style.backgroundColor=g.bg,$.style.color=g.fg,u==="outline")$.style.border="1px solid var(--border, #d1d5db)"}function n4($){return(u,r)=>{let g=K("div",$);return y(u,g,r),g}}function Vu($){return(u,r)=>{let g=K("span",$);return g.textContent=F(u.content,r),g}}function LN(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.borderTop="1px solid var(--border, #e5e7eb)",$.style.margin="4px 0",$}function b0($,u){let r=K("label","pf-radio");r.style.display="flex",r.style.alignItems="center",r.style.gap="8px",r.style.cursor="pointer";let g=document.createElement("input");if(g.type="radio",g.value=F($.value,u),r.appendChild(g),$.label!=null){let v=K("span","pf-radio-label");v.textContent=F($.label,u),r.appendChild(v)}return r}function N0($,u){let r=K("fieldset","pf-radio-group");if(r.style.border="none",r.style.padding="0",r.style.display="flex",r.style.flexDirection="column",r.style.gap="8px",$.label!=null){let _=document.createElement("legend");_.textContent=F($.label,u),_.style.fontWeight="500",_.style.marginBottom="4px",r.appendChild(_)}y($,r,u);let g=F($.name,u),v=u.store.get(g);for(let _ of Array.from(r.querySelectorAll('input[type="radio"]')))if(_.name=g,v!=null&&_.value===String(v))_.checked=!0;return r.addEventListener("change",(_)=>{let U=_.target;if(U.type==="radio"){if(u.store.set(g,U.value),$.onChange!=null)r$($.onChange,O$(u))}}),r}function z0($,u){let r=K("div","pf-combobox"),g=document.createElement("input");if(g.className="pf-combobox-input",g.type="text",g.name=F($.name,u),$.placeholder!=null)g.placeholder=F($.placeholder,u);if($.value!==void 0)g.value=F($.value,u);let v=g.name,_=u.store.get(v);if(_!=null)g.value=String(_);g.style.padding="6px 12px",g.style.borderRadius="6px",g.style.border="1px solid var(--border, #d1d5db)",g.style.width="100%",g.style.boxSizing="border-box";let U=K("div","pf-combobox-dropdown");if(U.style.display="none",U.style.position="absolute",U.style.background="var(--popover, #fff)",U.style.border="1px solid var(--border, #d1d5db)",U.style.borderRadius="6px",U.style.maxHeight="200px",U.style.overflowY="auto",U.style.zIndex="50",y($,U,u),g.addEventListener("focus",()=>{U.style.display="block"}),g.addEventListener("blur",()=>{setTimeout(()=>{U.style.display="none"},150)}),$.searchable!==!1)g.addEventListener("input",()=>{let I=g.value.toLowerCase();for(let D of Array.from(U.querySelectorAll(".pf-combobox-option"))){let b=D.textContent.toLowerCase();D.style.display=b.includes(I)?"":"none"}});if($.onChange!=null)r.addEventListener("pf-combobox-select",()=>{r$($.onChange,{...O$(u),scope:{...u.scope,$event:g.value}})});return r.style.position="relative",r.appendChild(g),r.appendChild(U),r}function O0($,u){let r=K("div","pf-combobox-option");return r.style.padding="6px 12px",r.style.cursor="pointer",r.textContent=F($.label??$.value,u),r.dataset.value=F($.value,u),r.addEventListener("mousedown",()=>{let g=r.closest(".pf-combobox"),v=g?.querySelector("input");if(v)v.value=r.dataset.value??"",u.store.set(v.name,v.value),g?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),r}function w0($,u){let r=K("div","pf-calendar"),g=document.createElement("input");if(g.type="date",g.name=F($.name,u),$.value!==void 0)g.value=F($.value,u);let v=g.name,_=u.store.get(v);if(_!=null)g.value=String(_);if($.minDate!=null)g.min=F($.minDate,u);if($.maxDate!=null)g.max=F($.maxDate,u);return g.style.padding="6px 12px",g.style.borderRadius="6px",g.style.border="1px solid var(--border, #d1d5db)",g.addEventListener("change",()=>{if(u.store.set(g.name,g.value),$.onChange!=null)r$($.onChange,O$(u))}),r.appendChild(g),r}function P0($,u){let r=K("div","pf-datepicker"),g=document.createElement("input");if(g.type="date",g.name=F($.name,u),$.placeholder!=null)g.placeholder=F($.placeholder,u);if($.value!==void 0)g.value=F($.value,u);let v=g.name,_=u.store.get(v);if(_!=null)g.value=String(_);if($.minDate!=null)g.min=F($.minDate,u);if($.maxDate!=null)g.max=F($.maxDate,u);return g.style.padding="6px 12px",g.style.borderRadius="6px",g.style.border="1px solid var(--border, #d1d5db)",g.style.width="100%",g.style.boxSizing="border-box",g.addEventListener("change",()=>{if(u.store.set(g.name,g.value),$.onChange!=null)r$($.onChange,O$(u))}),r.appendChild(g),r}function k0($,u){let r=K("div","pf-choice-card");if(r.style.border="2px solid var(--border, #d1d5db)",r.style.borderRadius="8px",r.style.padding="16px",r.style.cursor="pointer",r.style.transition="border-color 0.2s",r.dataset.value=F($.value,u),$.selected===!0)r.dataset.selected="true",r.style.borderColor="var(--primary, #3b82f6)",r.style.backgroundColor="var(--accent, #eff6ff)";if($.label!=null){let g=K("div","pf-choice-card-label");g.textContent=F($.label,u),g.style.fontWeight="600",r.appendChild(g)}if($.description!=null){let g=K("div","pf-choice-card-description");g.textContent=F($.description,u),g.style.fontSize="14px",g.style.color="var(--muted-foreground, #6b7280)",r.appendChild(g)}if(y($,r,u),$.onClick!=null)r.addEventListener("click",()=>{r$($.onClick,O$(u))});return r}function KN(){W("Tabs",J0),W("Tab",W0),W("Accordion",L0),W("AccordionItem",G0),W("Dialog",K0),W("Popover",j0),W("Tooltip",B0),W("HoverCard",H0),W("Carousel",V0)}function J0($,u){let r=K("div","pf-tabs"),g=K("div","pf-tabs-bar");g.setAttribute("role","tablist"),g.style.display="flex",g.style.gap="4px",g.style.borderBottom="2px solid var(--border, #e5e7eb)",g.style.marginBottom="12px";let v=[],_=[];if($.children)for(let I=0;I<$.children.length;I++){let D=$.children[I],b=`pf-tab-${Math.random().toString(36).slice(2,8)}`,N=`pf-panel-${Math.random().toString(36).slice(2,8)}`,O=document.createElement("button");O.type="button",O.className="pf-tab-trigger",O.textContent=D.title??`Tab ${I+1}`,O.setAttribute("role","tab"),O.setAttribute("aria-selected",I===0?"true":"false"),O.setAttribute("aria-controls",N),O.id=b,O.tabIndex=I===0?0:-1,O.style.padding="8px 16px",O.style.border="none",O.style.background="none",O.style.cursor="pointer",O.style.borderBottom="2px solid transparent",O.style.marginBottom="-2px",O.style.fontSize="14px";let P=K("div","pf-tab-panel");if(P.style.display=I===0?"block":"none",P.setAttribute("role","tabpanel"),P.setAttribute("aria-labelledby",b),P.id=N,P.tabIndex=0,y(D,P,u),O.addEventListener("click",()=>{U(I)}),I===0)O.style.borderBottomColor="var(--primary, #3b82f6)",O.style.fontWeight="600";_.push(O),v.push(P),g.appendChild(O)}function U(I){v.forEach((D)=>D.style.display="none"),_.forEach((D)=>{D.style.borderBottomColor="transparent",D.style.fontWeight="normal",D.setAttribute("aria-selected","false"),D.tabIndex=-1}),v[I].style.display="block",_[I].style.borderBottomColor="var(--primary, #3b82f6)",_[I].style.fontWeight="600",_[I].setAttribute("aria-selected","true"),_[I].tabIndex=0,_[I].focus()}g.addEventListener("keydown",(I)=>{let D=_.indexOf(I.target);if(D<0)return;let b;if(I.key==="ArrowRight")b=(D+1)%_.length;else if(I.key==="ArrowLeft")b=(D-1+_.length)%_.length;else if(I.key==="Home")b=0;else if(I.key==="End")b=_.length-1;else return;I.preventDefault(),U(b)}),r.appendChild(g);for(let I of v)r.appendChild(I);return r}function W0($,u){let r=K("div","pf-tab");return y($,r,u),r}function L0($,u){let r=K("div","pf-accordion");return y($,r,u),r}function G0($,u){let r=K("div","pf-accordion-item");r.style.borderBottom="1px solid var(--border, #e5e7eb)";let g=`pf-acc-${Math.random().toString(36).slice(2,8)}`,v=document.createElement("button");v.type="button",v.className="pf-accordion-trigger",v.textContent=$.title??"",v.setAttribute("aria-expanded","false"),v.setAttribute("aria-controls",g),v.style.width="100%",v.style.textAlign="left",v.style.padding="12px 0",v.style.border="none",v.style.background="none",v.style.cursor="pointer",v.style.fontSize="14px",v.style.fontWeight="500";let _=K("div","pf-accordion-content");return _.id=g,_.setAttribute("role","region"),_.setAttribute("aria-labelledby",v.id),_.style.display="none",_.style.paddingBottom="12px",y($,_,u),v.addEventListener("click",()=>{let U=_.style.display!=="none";_.style.display=U?"none":"block",v.setAttribute("aria-expanded",U?"false":"true")}),r.appendChild(v),r.appendChild(_),r}function K0($,u){let r=K("div","pf-dialog-wrapper");if($.trigger!=null){let _=D$($.trigger,u);_.addEventListener("click",()=>{g.showModal()}),r.appendChild(_)}let g=document.createElement("dialog");if(g.className="pf-dialog",g.setAttribute("aria-modal","true"),g.style.maxWidth="500px",g.style.width="100%",g.style.border="1px solid var(--border, #e5e7eb)",g.style.borderRadius="var(--radius, 8px)",g.style.padding="24px",$.title!=null){let _=K("h2","pf-dialog-title");_.textContent=F($.title,u),_.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,g.setAttribute("aria-labelledby",_.id),g.appendChild(_)}if($.description!=null){let _=K("p","pf-dialog-desc");_.textContent=F($.description,u),_.style.color="var(--muted-foreground, #6b7280)",g.appendChild(_)}let v=K("div","pf-dialog-body");if(y($,v,u),g.appendChild(v),$.dismissible!==!1)g.addEventListener("click",(_)=>{if(_.target===g)g.close()});return document.addEventListener("prefab:close-overlay",()=>g.close()),r.appendChild(g),r}function j0($,u){let r=K("div","pf-popover");r.style.position="relative",r.style.display="inline-block";let g=K("div","pf-popover-content");if(g.style.display="none",g.style.position="absolute",g.style.zIndex="50",g.style.padding="12px",g.style.border="1px solid var(--border, #e5e7eb)",g.style.borderRadius="var(--radius, 8px)",g.style.backgroundColor="var(--popover, #fff)",g.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",$.title!=null){let v=K("div","pf-popover-title");v.textContent=F($.title,u),v.style.fontWeight="600",v.style.marginBottom="4px",g.appendChild(v)}return y($,g,u),r.addEventListener("click",(v)=>{if(g.contains(v.target)&&g.style.display!=="none")return;g.style.display=g.style.display==="none"?"block":"none"}),r.appendChild(g),r}function B0($,u){let r=K("div","pf-tooltip");r.style.position="relative",r.style.display="inline-block";let g=`pf-tip-${Math.random().toString(36).slice(2,8)}`,v=K("div","pf-tooltip-content");return v.id=g,v.setAttribute("role","tooltip"),v.textContent=F($.content??"",u),v.style.display="none",v.style.position="absolute",v.style.bottom="100%",v.style.left="50%",v.style.transform="translateX(-50%)",v.style.padding="4px 8px",v.style.borderRadius="4px",v.style.backgroundColor="var(--popover, #1f2937)",v.style.color="#fff",v.style.fontSize="12px",v.style.whiteSpace="nowrap",v.style.zIndex="50",y($,r,u),r.setAttribute("aria-describedby",g),r.addEventListener("mouseenter",()=>{v.style.display="block"}),r.addEventListener("mouseleave",()=>{v.style.display="none"}),r.addEventListener("focus",()=>{v.style.display="block"},!0),r.addEventListener("blur",()=>{v.style.display="none"},!0),r.appendChild(v),r}function H0($,u){let r=K("div","pf-hover-card");r.style.position="relative",r.style.display="inline-block";let g=K("div","pf-hover-card-content");return g.style.display="none",g.style.position="absolute",g.style.zIndex="50",g.style.padding="16px",g.style.border="1px solid var(--border, #e5e7eb)",g.style.borderRadius="var(--radius, 8px)",g.style.backgroundColor="var(--card, #fff)",g.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",g.style.minWidth="200px",y($,g,u),r.addEventListener("mouseenter",()=>{g.style.display="block"}),r.addEventListener("mouseleave",()=>{g.style.display="none"}),r.appendChild(g),r}function V0($,u){let r=K("div","pf-carousel");r.style.position="relative",r.style.overflow="hidden",r.setAttribute("role","region"),r.setAttribute("aria-roledescription","carousel"),r.setAttribute("aria-label",F($.label??"Carousel",u));let g=K("div","pf-carousel-track");g.style.display="flex",g.style.transition="transform 0.3s ease",y($,g,u);let v=0,_=$.children?.length??0,U=document.createElement("button");U.type="button",U.textContent="‹",U.className="pf-carousel-prev",U.setAttribute("aria-label","Previous slide"),U.style.position="absolute",U.style.left="4px",U.style.top="50%",U.style.transform="translateY(-50%)",U.style.zIndex="10";let I=document.createElement("button");I.type="button",I.textContent="›",I.className="pf-carousel-next",I.setAttribute("aria-label","Next slide"),I.style.position="absolute",I.style.right="4px",I.style.top="50%",I.style.transform="translateY(-50%)",I.style.zIndex="10";let D=()=>{g.style.transform=`translateX(-${v*100}%)`};return U.addEventListener("click",()=>{if(_===0)return;v=Math.max(0,v-1),D()}),I.addEventListener("click",()=>{if(_===0)return;v=Math.min(_-1,v+1),D()}),r.appendChild(g),r.appendChild(U),r.appendChild(I),r}function jN(){W("ForEach",Y0),W("If",BN),W("Elif",A0),W("Else",S0),W("Condition",F0),W("Define",i0),W("Use",q0),W("Slot",E0)}function Y0($,u){let r=document.createDocumentFragment(),g=$.expression;if(!g)return r;let v;if(R$(g)){let U=Q$(g,u.store,u.scope);v=Array.isArray(U)?U:[]}else{let U=u.store.get(g);v=Array.isArray(U)?U:[]}let _=$.let??{};for(let U=0;U<v.length;U++){let I=v[U],D={...u.scope,$item:I,$index:U,..._},b={...u,scope:D};if($.children)Iv($.children,r,b)}return r}function BN($,u){if(HN($.condition,u)){let g=document.createDocumentFragment();if($.children)Iv($.children,g,u);return g}return document.createDocumentFragment()}function A0($,u){return BN($,u)}function S0($,u){let r=document.createDocumentFragment();if($.children)Iv($.children,r,u);return r}function HN($,u){if(!$)return!1;if(R$($))return Boolean(Q$($,u.store,u.scope));return Boolean(u.store.get($))}function F0($,u){let r=document.createDocumentFragment(),g=$.cases,v=$.else;if(g){for(let _ of g)if(HN(_.when,u)){if(_.children)Iv(_.children,r,u);return r}}if(v)Iv(v,r,u);return r}function i0($,u){let r=$.name;if(r&&$.children)u.templates=u.templates??{},u.templates[r]=$.children;return document.createDocumentFragment()}function q0($,u){let r=document.createDocumentFragment(),g=$.def??$.name,v=u.templates?.[g];if(!v)return r;let _=$.overrides??{},U={...u.scope,..._},I={...u,scope:U};for(let D of v)r.appendChild(D$(D,I));return r}function E0($,u){let r=document.createDocumentFragment(),g=$.name??"default",_=u.slots?.[g]??$.children;if(_)for(let U of _)r.appendChild(D$(U,u));return r}function VN(){W("Alert",X0),W("AlertTitle",T0),W("AlertDescription",M0)}function X0($,u){let r=K("div","pf-alert");r.setAttribute("role","alert");let g=$.variant??"default";if(r.setAttribute("data-variant",g),r.style.padding="12px 16px",r.style.borderRadius="var(--radius, 8px)",r.style.border="1px solid var(--border, #e5e7eb)",g==="destructive")r.style.borderColor="var(--destructive, #ef4444)",r.style.color="var(--destructive, #ef4444)";if($.icon!=null){let v=K("span","pf-alert-icon");v.setAttribute("data-icon",$.icon),v.style.marginRight="8px",r.appendChild(v)}return y($,r,u),r}function T0($,u){let r=K("h5","pf-alert-title");return r.textContent=F($.content,u),r.style.fontWeight="600",r.style.marginBottom="4px",r}function M0($,u){let r=K("p","pf-alert-description");return r.textContent=F($.content,u),r.style.fontSize="14px",r}function YN(){W("Image",R0),W("Audio",Q0),W("Video",Z0),W("Embed",n0),W("Svg",m0),W("DropZone",l0),W("Mermaid",y0)}function R0($,u){let r=document.createElement("img");if(r.className="pf-image",r.src=F($.src,u),$.alt!=null)r.alt=F($.alt,u);if($.width!=null)r.width=$.width;if($.height!=null)r.height=$.height;return r.style.maxWidth="100%",r}function Q0($,u){let r=document.createElement("audio");return r.className="pf-audio",r.src=F($.src,u),r.controls=!0,r}function Z0($,u){let r=document.createElement("video");if(r.className="pf-video",r.src=F($.src,u),r.controls=!0,$.width!=null)r.width=$.width;if($.height!=null)r.height=$.height;return r.style.maxWidth="100%",r}function n0($,u){let r=K("div","pf-embed"),g=document.createElement("iframe");return g.src=F($.src,u),g.style.width="100%",g.style.height=$.height!=null?`${$.height}px`:"400px",g.style.border="none",g.setAttribute("sandbox","allow-scripts"),r.appendChild(g),r}var C0=new Set(["svg","g","path","rect","circle","ellipse","line","polyline","polygon","text","tspan","textpath","defs","use","symbol","clippath","mask","pattern","lineargradient","radialgradient","stop","filter","fegaussianblur","feoffset","femerge","femergenode","fecolormatrix","feblend","title","desc"]);function m0($,u){let r=K("div","pf-svg"),g=F($.content,u);if(!g.includes("<svg"))return r;let _=new DOMParser().parseFromString(g,"image/svg+xml").querySelector("svg");if(!_)return r;return AN(_),r.appendChild(document.importNode(_,!0)),r}function AN($){let u=Array.from($.children);for(let r of u){if(!C0.has(r.tagName.toLowerCase())){r.remove();continue}for(let g of Array.from(r.attributes)){let v=g.name.toLowerCase();if(v.startsWith("on")||v==="href"&&g.value.trim().toLowerCase().startsWith("javascript:"))r.removeAttribute(g.name)}AN(r)}}function l0($,u){let r=K("div","pf-dropzone");return r.style.border="2px dashed var(--border, #d1d5db)",r.style.borderRadius="var(--radius, 8px)",r.style.padding="32px",r.style.textAlign="center",r.style.cursor="pointer",r.textContent=F($.label??"Drop files here",u),r.addEventListener("dragover",(g)=>{g.preventDefault(),r.style.borderColor="var(--primary, #3b82f6)"}),r.addEventListener("dragleave",()=>{r.style.borderColor="var(--border, #d1d5db)"}),r.addEventListener("drop",(g)=>{g.preventDefault(),r.style.borderColor="var(--border, #d1d5db)"}),r}function y0($,u){let r=K("div","pf-mermaid");r.setAttribute("data-mermaid","true");let g=F($.content,u);if(r.textContent=g,typeof globalThis.mermaid<"u")r.classList.add("mermaid"),r.textContent=g;return r}var m4=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function l4($,u){let r=document.createElement("div");return r.className="pf-chart-tooltip",$.appendChild(r),$.addEventListener("mouseleave",()=>{r.classList.remove("pf-visible")}),{wrapper:$,tooltip:r,svgEl:u}}function Yu($,u,r,g,v){let{tooltip:_,svgEl:U,wrapper:I}=$;if(v.length===0)return;let D="";if(g)D+=`<div class="pf-chart-tooltip-label">${C4(g)}</div>`;for(let E of v)D+='<div class="pf-chart-tooltip-row">',D+=`<span class="pf-chart-tooltip-dot" style="background:${C4(E.color)}"></span>`,D+=`<span>${C4(E.label)}:</span> <strong>${C4(String(E.value))}</strong>`,D+="</div>";_.innerHTML=D;let b=U.getBoundingClientRect(),N=I.getBoundingClientRect(),O=U.viewBox.baseVal,P=b.width/(O.width||1),L=b.left-N.left+u*P,j=_.offsetWidth||100,B=L+12;if(B+j>N.width)B=L-j-12;_.style.left=`${Math.max(0,B)}px`,_.style.top="4px",_.classList.add("pf-visible")}function C4($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function SN($,u,r,g,v,_,U,I){let D=v.plotWidth/r.length;for(let b=0;b<r.length;b++){let N=v.plotLeft+b*D,O=document.createElementNS("http://www.w3.org/2000/svg","rect");O.setAttribute("x",String(N)),O.setAttribute("y",String(v.plotTop)),O.setAttribute("width",String(D)),O.setAttribute("height",String(v.plotHeight)),O.setAttribute("fill","transparent"),O.style.cursor="default";let P=_?r[b][_]:void 0,L=P!=null?I?I(P):String(P):void 0,j=g.map((C,Z)=>({label:C.label??C.dataKey,value:U(r[b][C.dataKey],C,Z),color:C.color??m4[Z%m4.length]})),B=N+D/2,E=()=>Yu($,B,v.plotTop,L,j),M=()=>$.tooltip.classList.remove("pf-visible");O.addEventListener("mouseenter",E),O.addEventListener("mouseleave",M),O.addEventListener("touchstart",E,{passive:!0}),O.addEventListener("touchend",M,{passive:!0}),u.appendChild(O)}}function FN($,u,r,g,v,_,U,I,D,b){let N=r.length===1?v.plotWidth:v.plotWidth/(r.length-1);for(let O=0;O<r.length;O++){let P=r.length===1?(v.plotLeft+v.plotRight)/2:v.plotLeft+O/(r.length-1)*v.plotWidth,L=r.length===1?v.plotLeft:P-N/2,j=r.length===1?v.plotWidth:N,B=document.createElementNS("http://www.w3.org/2000/svg","rect");B.setAttribute("x",String(Math.max(v.plotLeft,L))),B.setAttribute("y",String(v.plotTop)),B.setAttribute("width",String(Math.min(j,v.plotRight-Math.max(v.plotLeft,L)))),B.setAttribute("height",String(v.plotHeight)),B.setAttribute("fill","transparent"),B.style.cursor="default";let E=_?r[O][_]:void 0,M=E!=null?b?b(E):String(E):void 0,C=g.map((R,z$)=>({label:R.label??R.dataKey,value:U(r[O][R.dataKey],R,z$),color:R.color??m4[z$%m4.length]})),Z=()=>{if(Yu($,P,v.plotTop,M,C),I)I.setAttribute("x1",String(P)),I.setAttribute("x2",String(P)),I.setAttribute("opacity","1");if(D)for(let R of D){for(let z$ of R)z$.setAttribute("data-visible","false");R[O]?.setAttribute("data-visible","true")}},q=()=>{if($.tooltip.classList.remove("pf-visible"),I)I.setAttribute("opacity","0");if(D)for(let R of D)for(let z$ of R)z$.setAttribute("data-visible","false")};B.addEventListener("mouseenter",Z),B.addEventListener("mouseleave",q),B.addEventListener("touchstart",Z,{passive:!0}),B.addEventListener("touchend",q,{passive:!0}),u.appendChild(B)}}function qN(){W("BarChart",c0),W("LineChart",iN),W("AreaChart",iN),W("PieChart",x0),W("RadarChart",rg),W("ScatterChart",rg),W("RadialChart",rg),W("Histogram",o0)}var vv=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],Au="var(--muted-foreground, #6b7280)",f0="var(--border, #e5e7eb)",gg="10";function EN($,u,r,g=!1){let v=r?44:0,_=$-(g?44:0),U=10,I=u-24;return{plotLeft:v,plotRight:_,plotTop:10,plotBottom:I,plotWidth:_-v,plotHeight:I-10}}function XN($,u=5){if($<=0)return[0];let r=$/u,g=Math.pow(10,Math.floor(Math.log10(r))),v=r/g,_=v<=1.5?g:v<=3?2*g:v<=7?5*g:10*g,U=[];for(let I=0;I<=$+_*0.01;I+=_)U.push(Math.round(I*1000)/1000);return U}function TN($,u,r,g,v){let _=XN(r);for(let U of _){let I=u.plotBottom-(r>0?U/r*u.plotHeight:0),D=document.createElementNS("http://www.w3.org/2000/svg","text");if(D.setAttribute("x",String(u.plotLeft-6)),D.setAttribute("y",String(I+3)),D.setAttribute("text-anchor","end"),D.setAttribute("font-size",gg),D.setAttribute("fill",Au),D.textContent=_g(U,v),$.appendChild(D),g&&U>0){let b=document.createElementNS("http://www.w3.org/2000/svg","line");b.setAttribute("x1",String(u.plotLeft)),b.setAttribute("y1",String(I)),b.setAttribute("x2",String(u.plotRight)),b.setAttribute("y2",String(I)),b.setAttribute("stroke",f0),b.setAttribute("stroke-width","1"),b.setAttribute("stroke-dasharray","4 3"),$.appendChild(b)}}}function MN($,u,r,g){let v=XN(r);for(let _ of v){let U=u.plotBottom-(r>0?_/r*u.plotHeight:0),I=document.createElementNS("http://www.w3.org/2000/svg","text");I.setAttribute("x",String(u.plotRight+6)),I.setAttribute("y",String(U+3)),I.setAttribute("text-anchor","start"),I.setAttribute("font-size",gg),I.setAttribute("fill",Au),I.textContent=_g(_,g),$.appendChild(I)}}function RN($,u,r,g,v,_){for(let U=0;U<u.length;U++){let I=document.createElementNS("http://www.w3.org/2000/svg","text");I.setAttribute("x",String(g(U))),I.setAttribute("y",String(v+14)),I.setAttribute("text-anchor","middle"),I.setAttribute("font-size",gg),I.setAttribute("fill",Au);let D=u[U][r];I.textContent=D==null?"":_?_(D):String(D),$.appendChild(I)}}function QN($,u){let r=document.createElementNS("http://www.w3.org/2000/svg","line");r.setAttribute("x1",String(u.plotLeft)),r.setAttribute("y1",String(u.plotBottom)),r.setAttribute("x2",String(u.plotRight)),r.setAttribute("y2",String(u.plotBottom)),r.setAttribute("stroke",Au),r.setAttribute("stroke-width","1"),$.appendChild(r)}function Tv($,u,r){if($==null)return"";let g=j$(`{{ __v | ${u} }}`,{...r,scope:{...r.scope,__v:$}});return g==null?String($):String(g)}function _g($,u){if(u==="currency")return`$${$.toLocaleString()}`;if(u==="percent")return`${$}%`;if($>=1e6)return`${($/1e6).toFixed(1)}M`;if($>=1000)return`${($/1000).toFixed(1)}K`;return String($)}function ZN($,u,r){return(g,v)=>{if(g===null||g===void 0)return"—";if(v.tooltipFormat)return Tv(g,v.tooltipFormat,$);let _=v.yAxisId==="right"?r:u;return _g(Number(g),_)}}function c0($,u){let r=K("div","pf-chart pf-bar-chart"),g=j$($.data,u)??[],v=$.series??[],_=$.height??300;if(g.length===0||v.length===0)return r.textContent="No chart data",r;let U=$.showYAxis!==!1,I=$.showGrid===!0,D=$.showYAxisRight===!0,b=$.showTooltip!==!1,N=$.xAxis,O=$.tooltipXKey,P=$.xAxisFormat,L=$.tooltipXFormat,j=v.filter((h)=>h.yAxisId!=="right"),B=v.filter((h)=>h.yAxisId==="right"),E=D&&B.length>0,M=j.length>0?Math.max(...g.flatMap((h)=>j.map((c)=>Number(h[c.dataKey]??0))),1):1,C=E?Math.max(...g.flatMap((h)=>B.map((c)=>Number(h[c.dataKey]??0))),1):1,Z=400,q=EN(Z,_,U,E),R=y4(Z,_,"Bar");if(U)TN(R,q,M,I,$.yAxisFormat);if(E)MN(R,q,C,$.yAxisRightFormat);QN(R,q);let z$=q.plotWidth/g.length,o$=z$/(v.length+1);for(let h=0;h<g.length;h++)for(let c=0;c<v.length;c++){let U$=v[c],y$=g[h][U$.dataKey];if(y$===null||y$===void 0)continue;let A$=U$.yAxisId==="right"?C:M,h$=Number(y$),t$=Math.max(0,h$/A$*q.plotHeight),Kv=q.plotLeft+h*z$+c*o$+o$/2,f=document.createElementNS("http://www.w3.org/2000/svg","rect");f.setAttribute("x",String(Kv)),f.setAttribute("y",String(q.plotBottom-t$)),f.setAttribute("width",String(o$*0.8)),f.setAttribute("height",String(t$)),f.setAttribute("fill",U$.color??vv[c%vv.length]),f.setAttribute("rx","2"),R.appendChild(f)}if(N){let h=P?(c)=>Tv(c,P,u):void 0;RN(R,g,N,(c)=>{return q.plotLeft+c*z$+z$/2},q.plotBottom,h)}if(b){let h=l4(r,R),c=ZN(u,$.yAxisFormat,$.yAxisRightFormat);SN(h,R,g,v,q,O??N,c,L?(y$)=>Tv(y$,L,u):void 0)}return Ug(r,v,$.showLegend),r.appendChild(R),r}function iN($,u){let r=K("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),g=j$($.data,u)??[],v=$.series??[],_=$.height??300;if(g.length===0||v.length===0)return r.textContent="No chart data",r;let U=$.showYAxis!==!1,I=$.showGrid===!0,D=$.showYAxisRight===!0,b=$.showTooltip!==!1,N=$.xAxis,O=$.tooltipXKey,P=$.xAxisFormat,L=$.tooltipXFormat,j=v.filter((c)=>c.yAxisId!=="right"),B=v.filter((c)=>c.yAxisId==="right"),E=D&&B.length>0,M=j.length>0?Math.max(...g.flatMap((c)=>j.map((U$)=>Number(c[U$.dataKey]??0))),1):1,C=E?Math.max(...g.flatMap((c)=>B.map((U$)=>Number(c[U$.dataKey]??0))),1):1,Z=400,q=EN(Z,_,U,E),R=y4(Z,_,$.type==="AreaChart"?"Area":"Line"),z$=$.type==="AreaChart";if(U)TN(R,q,M,I,$.yAxisFormat);if(E)MN(R,q,C,$.yAxisRightFormat);QN(R,q);let o$=[];for(let c=0;c<v.length;c++){let U$=v[c],y$=U$.yAxisId==="right",_v=y$?C:M,A$=U$.color??vv[c%vv.length],h$=g.map((f,I$)=>{let q$=f[U$.dataKey],jv=q$===null||q$===void 0,F4=g.length===1?(q.plotLeft+q.plotRight)/2:q.plotLeft+I$/(g.length-1)*q.plotWidth,mw=jv?q.plotBottom:q.plotBottom-Number(q$)/_v*q.plotHeight;return{x:F4,y:mw,isNull:jv}});if(z$){let f=[],I$=()=>{if(f.length<2){f=[];return}let q$=`M ${f[0].x},${q.plotBottom} `+f.map((F4)=>`L ${F4.x},${F4.y}`).join(" ")+` L ${f[f.length-1].x},${q.plotBottom} Z`,jv=document.createElementNS("http://www.w3.org/2000/svg","path");jv.setAttribute("d",q$),jv.setAttribute("fill",A$),jv.setAttribute("opacity","0.15"),R.appendChild(jv),f=[]};for(let q$ of h$){if(q$.isNull){I$();continue}f.push(q$)}I$()}let t$="";for(let f of h$){if(f.isNull)continue;let I$=h$.indexOf(f),q$=I$===0||h$[I$-1].isNull;t$+=`${q$?"M":"L"} ${f.x},${f.y} `}if(t$){let f=document.createElementNS("http://www.w3.org/2000/svg","path");if(f.setAttribute("d",t$.trim()),f.setAttribute("fill","none"),f.setAttribute("stroke",A$),f.setAttribute("stroke-width","2"),y$)f.setAttribute("stroke-dasharray","6 3");R.appendChild(f)}let Kv=[];for(let f of h$){let I$=document.createElementNS("http://www.w3.org/2000/svg","circle");if(I$.setAttribute("cx",String(f.x)),I$.setAttribute("cy",String(f.y)),I$.setAttribute("r","4"),I$.setAttribute("fill",A$),I$.setAttribute("class","pf-data-dot"),I$.setAttribute("data-visible","false"),I$.style.pointerEvents="none",f.isNull)I$.style.display="none";R.appendChild(I$),Kv.push(I$)}o$.push(Kv)}let h=document.createElementNS("http://www.w3.org/2000/svg","line");if(h.setAttribute("class","pf-crosshair"),h.setAttribute("x1",String(q.plotLeft)),h.setAttribute("x2",String(q.plotLeft)),h.setAttribute("y1",String(q.plotTop)),h.setAttribute("y2",String(q.plotBottom)),h.setAttribute("stroke",Au),h.setAttribute("stroke-width","1"),h.setAttribute("stroke-dasharray","3 3"),h.setAttribute("opacity","0"),R.appendChild(h),N){let c=P?(U$)=>Tv(U$,P,u):void 0;RN(R,g,N,(U$)=>{return g.length===1?(q.plotLeft+q.plotRight)/2:q.plotLeft+U$/(g.length-1)*q.plotWidth},q.plotBottom,c)}if(b){let c=l4(r,R),U$=ZN(u,$.yAxisFormat,$.yAxisRightFormat);FN(c,R,g,v,q,O??N,U$,h,o$,L?(_v)=>Tv(_v,L,u):void 0)}return Ug(r,v,$.showLegend),r.appendChild(R),r}function x0($,u){let r=K("div","pf-chart pf-pie-chart"),g=j$($.data,u)??[],v=$.series??[],_=$.height??300,U=Math.min(_,300),I=$.showTooltip!==!1;if(g.length===0||v.length===0)return r.textContent="No chart data",r;let D=y4(U,U,"Pie"),b=U/2,N=U/2,O=U/2-10,P=v[0].dataKey,L=$.xAxis,j=$.tooltipXKey,B=$.tooltipXFormat,E=g.map((q)=>Number(q[P]??0)),M=E.reduce((q,R)=>q+R,0);if(M===0)return r.textContent="No chart data",r.appendChild(D),r;let C=I?l4(r,D):void 0,Z=-Math.PI/2;for(let q=0;q<E.length;q++){let R=E[q]/M*2*Math.PI,z$=Z+R,o$=R>Math.PI?1:0,h=b+O*Math.cos(Z),c=N+O*Math.sin(Z),U$=b+O*Math.cos(z$),y$=N+O*Math.sin(z$),_v=vv[q%vv.length],A$=document.createElementNS("http://www.w3.org/2000/svg","path");if(A$.setAttribute("d",`M ${b},${N} L ${h},${c} A ${O},${O} 0 ${o$} 1 ${U$},${y$} Z`),A$.setAttribute("fill",_v),A$.style.cursor="default",C){let h$=j??L,t$=h$?g[q][h$]:void 0,Kv=t$!=null?B?Tv(t$,B,u):String(t$):`Slice ${q+1}`,f=`${(E[q]/M*100).toFixed(1)}%`,I$=Z+R/2,q$=b+O*0.6*Math.cos(I$);A$.addEventListener("mouseenter",()=>{Yu(C,q$,N,Kv,[{label:v[0].label??P,value:`${E[q]} (${f})`,color:_v}])}),A$.addEventListener("mouseleave",()=>{C.tooltip.classList.remove("pf-visible")}),A$.addEventListener("touchstart",()=>{Yu(C,q$,N,Kv,[{label:v[0].label??P,value:`${E[q]} (${f})`,color:_v}])},{passive:!0}),A$.addEventListener("touchend",()=>{C.tooltip.classList.remove("pf-visible")},{passive:!0})}D.appendChild(A$),Z=z$}return Ug(r,v,$.showLegend),r.appendChild(D),r}function rg($,u){let r=K("div",`pf-chart pf-${$.type.toLowerCase()}`);return r.textContent=`${$.type} — not yet supported in renderer`,r.style.padding="24px",r.style.textAlign="center",r.style.color="var(--muted-foreground, #6b7280)",r}function y4($,u,r){let g=document.createElementNS("http://www.w3.org/2000/svg","svg");if(g.setAttribute("width","100%"),g.setAttribute("height",String(u)),g.setAttribute("viewBox",`0 0 ${$} ${u}`),g.setAttribute("role","img"),r)g.setAttribute("aria-label",`${r} chart`);return g.style.overflow="visible",g}function Ug($,u,r){if(r===!1||u.length<=1)return;let g=K("div","pf-chart-legend");g.style.display="flex",g.style.gap="12px",g.style.fontSize="12px",g.style.marginBottom="8px";for(let v=0;v<u.length;v++){let _=K("div","pf-chart-legend-item");_.style.display="flex",_.style.alignItems="center",_.style.gap="4px";let U=K("span");U.style.width="8px",U.style.height="8px",U.style.borderRadius="50%",U.style.backgroundColor=u[v].color??vv[v%vv.length];let I=K("span");I.textContent=u[v].label??u[v].dataKey,_.appendChild(U),_.appendChild(I),g.appendChild(_)}$.appendChild(g)}function o0($,u){let r=K("div","pf-chart pf-histogram"),g=j$($.data,u);if(!g||g.length===0)return r.textContent="No data",r;let v=g,_=$.bins??10,U=$.height??200,I=$.color??vv[0],D=Math.min(...v),N=(Math.max(...v)-D)/_||1,O=Array(_).fill(0);for(let M of v){let C=Math.min(Math.floor((M-D)/N),_-1);O[C]++}let P=Math.max(...O),L=300,j=U,B=L/_,E=y4(L,j,"Histogram");for(let M=0;M<_;M++){let C=P>0?O[M]/P*j:0,Z=document.createElementNS("http://www.w3.org/2000/svg","rect");Z.setAttribute("x",String(M*B)),Z.setAttribute("y",String(j-C)),Z.setAttribute("width",String(B-1)),Z.setAttribute("height",String(C)),Z.setAttribute("fill",I),E.appendChild(Z)}return r.appendChild(E),r}function nN(){W("Table",h0),W("TableHead",Ig("thead")),W("TableBody",Ig("tbody")),W("TableFooter",Ig("tfoot")),W("TableRow",t0),W("TableHeader",d0),W("TableCell",p0),W("TableCaption",a0),W("ExpandableRow",e0)}function h0($,u){let r=document.createElement("table");return r.className="pf-table",r.style.width="100%",r.style.borderCollapse="collapse",y($,r,u),r}function Ig($){return(u,r)=>{let g=document.createElement($);return g.className=`pf-${$}`,y(u,g,r),g}}function t0($,u){let r=document.createElement("tr");return r.className="pf-table-row",y($,r,u),r}function d0($,u){let r=document.createElement("th");return r.className="pf-table-header",r.style.textAlign="left",r.style.padding="8px 12px",r.style.borderBottom="2px solid var(--border, #e5e7eb)",r.style.fontWeight="600",r.textContent=F($.content,u),r}function p0($,u){let r=document.createElement("td");if(r.className="pf-table-cell",r.style.padding="8px 12px",r.style.borderBottom="1px solid var(--border, #e5e7eb)",$.colSpan!=null)r.colSpan=$.colSpan;if($.rowSpan!=null)r.rowSpan=$.rowSpan;return y($,r,u),r}function a0($,u){let r=document.createElement("caption");return r.className="pf-table-caption",r.style.padding="8px",r.style.color="var(--muted-foreground, #6b7280)",r.style.fontSize="14px",r.textContent=F($.content,u),r}function e0($,u){let r=K("div","pf-expandable-row"),g=K("div","pf-expandable-row-summary");g.style.cursor="pointer",g.style.display="flex",g.style.alignItems="center",g.style.gap="8px";let v=K("span","pf-expandable-arrow");v.textContent="▶",v.style.transition="transform 0.2s",v.style.fontSize="10px",g.appendChild(v);let _=$.summary;if(_)for(let D of _)g.appendChild(D$(D,u));let U=K("div","pf-expandable-row-detail");U.style.display="none",U.style.paddingLeft="24px",y($,U,u);let I=!1;return g.addEventListener("click",()=>{I=!I,U.style.display=I?"block":"none",v.style.transform=I?"rotate(90deg)":""}),r.appendChild(g),r.appendChild(U),r}var CN=!1;function f4(){if(CN)return;CN=!0,bN(),wN(),JN(),WN(),GN(),KN(),jN(),VN(),YN(),qN(),nN()}function mN($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function lN($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function yN($,u){if(!u)return;if(u.light)for(let[r,g]of Object.entries(u.light))$.style.setProperty(`--${mN(r)}`,lN(g));if(u.dark){let g=document.getElementById("prefab-dark-theme");if(!g)g=document.createElement("style"),g.id="prefab-dark-theme",document.head.appendChild(g);let v=Object.entries(u.dark).map(([_,U])=>` --${mN(_)}: ${lN(U)};`).join(`
84
- `);g.textContent=`@media (prefers-color-scheme: dark) {
85
- :root {
84
+ `);g.textContent=`[data-theme="dark"] {
85
+ ${v}
86
+ }
87
+ @media (prefers-color-scheme: dark) {
88
+ :root:not([data-theme="light"]) {
86
89
  ${v}
87
90
  }
88
91
  }`}}function fN($,u){if(!$||typeof document>"u")return;let r=(g)=>{for(let[v,_]of Object.entries($))if(s0(v,g))g.preventDefault(),u(_)};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)}function s0($,u){let r=$.toLowerCase().split("+").map((_)=>_.trim()),g=r[r.length-1],v=new Set(r.slice(0,-1));if(v.has("ctrl")!==(u.ctrlKey||u.metaKey))return!1;if(v.has("shift")!==u.shiftKey)return!1;if(v.has("alt")!==u.altKey)return!1;return u.key.toLowerCase()===g}function c4($){let u=$?.baseUrl??(typeof window<"u"?window.location.origin:""),r={"Content-Type":"application/json",...$?.headers},g=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(v,_){let U=await g(`${u}/mcp/tools/call`,{method:"POST",headers:r,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:v,arguments:_}})});if(!U.ok)throw Error(`MCP tool call failed: ${U.status} ${U.statusText}`);let I=await U.json();if(I.error)throw Error(I.error.message??"MCP tool call returned error");let D=I.result?.content??I.content??[];for(let b of D)if(b.type==="text"&&b.text!==void 0){try{let N=JSON.parse(b.text);if(typeof N==="object"&&N!==null&&"$prefab"in N)return N;return N}catch{}return b.text}return I.result??I},async sendMessage(v){await g(`${u}/mcp/messages`,{method:"POST",headers:r,body:JSON.stringify({message:v})})}}}function x4(){return{callTool($){return console.warn(`[prefab] No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return console.warn("[prefab] No MCP transport: sendMessage ignored",$),Promise.resolve()}}}function I8($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class qv{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;extApp;constructor($="*"){this.hostOrigin=$}connect(){if(typeof window>"u")return;let $=b8();if($)this.postFn=(r)=>$.postMessage(r);let u=(r)=>{if(this.hostOrigin!=="*"&&r.origin!==this.hostOrigin)return;let g=r.data;if(I8(g)){this.handleJsonRpc(g);return}let v=g;if(!v?.type.startsWith("prefab:"))return;if(v.type==="prefab:tool-call-response"&&v.id){let U=this.pending.get(v.id);if(U){if(this.pending.delete(v.id),v.payload?.error!=null)U.reject(Error(v.payload.error));else U.resolve(v.payload?.result);return}}let _=this.listeners.get(v.type);if(_)for(let U of _)U(v.payload??{})};window.addEventListener("message",u),this.cleanup=()=>window.removeEventListener("message",u)}async initialize($){try{return await Promise.any([this.initPrefab($),this.initJsonRpc($)])}catch{return this.initExtApps($)}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();if(this.protocol==="ext-apps"&&this.extApp)return this.createExtAppsTransport();return this.createPrefabTransport()}requestMode($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:$});else if(this.protocol==="ext-apps"&&this.extApp)this.extApp.requestDisplayMode({mode:$});else this.sendPrefab("prefab:request-mode",{mode:$})}openLink($,u){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:u});else if(this.protocol==="ext-apps"&&this.extApp)this.extApp.openLink({url:$});else this.sendPrefab("prefab:open-link",{url:$,target:u})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else if(this.protocol==="ext-apps"&&this.extApp)this.extApp.updateModelContext({structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}on($,u){if(!this.listeners.has($))this.listeners.set($,new Set);let r=this.listeners.get($);if(r)r.add(u)}off($,u){this.listeners.get($)?.delete(u)}disconnect(){this.cleanup?.(),this.extApp=void 0,this.listeners.clear();for(let[,$]of this.pending)$.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,$]of this.rpcPending)$.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab($){return new Promise((u,r)=>{let g=!1,v=(_)=>{if(g)return;g=!0,this.off("prefab:init-response",v),this.protocol="prefab",u(_)};this.on("prefab:init-response",v),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!g)g=!0,this.off("prefab:init-response",v),r(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,u)=>{let r=`tc-${++this.callIdCounter}`;return new Promise((g,v)=>{this.pending.set(r,{resolve:g,reject:v}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:u},r),setTimeout(()=>{if(this.pending.has(r))this.pending.delete(r),v(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()}}}sendPrefab($,u,r){if(typeof window>"u")return;let g=window.parent!==window?window.parent:window,v={type:$,payload:u,id:r};g.postMessage(v,this.hostOrigin)}handleJsonRpc($){if(!("method"in $)){let g=this.rpcPending.get($.id);if(g)if(this.rpcPending.delete($.id),$.error)g.reject(Error($.error.message));else g.resolve($.result);return}let u=$.method,r=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(u){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:r.arguments??r});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:r.arguments??r});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:r});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",r);break;case"ui/notifications/host-context-changed":{let g={};if(typeof r.theme==="string")g.colorScheme=r.theme;if(typeof r.styles==="object"&&r.styles!==null){let v=r.styles;if(v.variables)g.variables=v.variables}this.dispatch("prefab:theme-update",g);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",r);break}}initJsonRpc($){return new Promise((u,r)=>{let g=++this.rpcIdCounter,v=!1;this.rpcPending.set(g,{resolve:(_)=>{if(v)return;v=!0,this.protocol="jsonrpc";let U=_??{},I=U.hostInfo??{},D=U.hostContext??{},b=U.hostCapabilities??{},N;if(typeof D.theme==="string"||typeof D.styles==="object"){if(N={},typeof D.theme==="string")N.colorScheme=D.theme;if(typeof D.styles==="object"&&D.styles!==null){let O=D.styles;if(O.variables)N.variables=O.variables}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}}),u({hostName:I.name,hostVersion:I.version,capabilities:{toast:!0,navigation:b.openLinks!=null,messaging:!0,displayModes:D.availableDisplayModes??[]},theme:N,toolInput:void 0,meta:D})},reject:(_)=>{if(v)return;v=!0,r(_)}}),this.postJsonRpc({jsonrpc:"2.0",id:g,method:"ui/initialize",params:{protocolVersion:"2026-01-26",capabilities:{},clientInfo:{name:"prefab",version:"0.2"},appCapabilities:{...$.displayModes&&{availableDisplayModes:$.displayModes}}}}),setTimeout(()=>{if(!v)v=!0,this.rpcPending.delete(g),r(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,u)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:u})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})}}}sendRpcRequest($,u){let r=++this.rpcIdCounter;return new Promise((g,v)=>{this.rpcPending.set(r,{resolve:g,reject:v}),this.postJsonRpc({jsonrpc:"2.0",id:r,method:$,params:u}),setTimeout(()=>{if(this.rpcPending.has(r))this.rpcPending.delete(r),v(Error(`JSON-RPC '${$}' timed out`))},30000)})}sendRpcNotification($,u){this.postJsonRpc({jsonrpc:"2.0",method:$,params:u})}postJsonRpc($){if(typeof window>"u")return;if($.id!=null&&typeof $.method==="string")this.sentRpcIds.add($.id);if(this.postFn)this.postFn($);else(window.parent!==window?window.parent:window).postMessage($,this.hostOrigin)}async initExtApps($){let{App:u,PostMessageTransport:r}=await Promise.resolve().then(() => (nw(),Zw)),v=new r(window.parent,window.parent),_=new u({name:"prefab",version:"0.2"},{...$.displayModes&&{availableDisplayModes:$.displayModes}});this.wireExtAppsEvents(_),await Promise.race([_.connect(v),D8(3000,"ext-apps init timeout")]),this.extApp=_,this.protocol="ext-apps";let U=_.getHostVersion(),I=_.getHostCapabilities(),D=_.getHostContext();return{hostName:U?.name,hostVersion:U?.version,capabilities:{toast:!0,navigation:I?.openLinks!=null,messaging:!0},theme:D?.theme?{colorScheme:D.theme}:void 0,toolInput:void 0,meta:D}}wireExtAppsEvents($){$.addEventListener("toolinput",(u)=>{this.dispatch("prefab:tool-input",{args:u.arguments??{}})}),$.addEventListener("toolinputpartial",(u)=>{this.dispatch("prefab:tool-input-partial",{args:u.arguments??{}})}),$.addEventListener("toolresult",(u)=>{this.dispatch("prefab:tool-result",{result:u})}),$.addEventListener("toolcancelled",()=>{this.dispatch("prefab:tool-cancelled",{})}),$.addEventListener("hostcontextchanged",(u)=>{let r={};if(u.theme)r.colorScheme=u.theme;this.dispatch("prefab:theme-update",r)})}createExtAppsTransport(){let $=this.extApp;if(!$)throw Error("ext-apps not initialized");return{callTool:async(u,r)=>{let v=(await $.callServerTool({name:u,arguments:r})).content.filter((_)=>_.type==="text").map((_)=>_.text);return v.length===1?v[0]:v},sendMessage:async(u)=>{await $.sendMessage({role:"user",content:[{type:"text",text:u}]})}}}dispatch($,u){let r=this.listeners.get($);if(r)for(let g of r)g(u)}}function D8($,u){return new Promise((r,g)=>setTimeout(()=>g(Error(u)),$))}function S4($,u){if(u.variables)for(let[r,g]of Object.entries(u.variables))$.style.setProperty(r.startsWith("--")?r:`--${r}`,g);if(u.colorScheme&&u.colorScheme!=="auto")$.setAttribute("data-theme",u.colorScheme)}function Ku(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function b8(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let u=$.acquireVsCodeApi();if(u!==null&&typeof u==="object"&&"postMessage"in u)return u}catch{return}return}async function tr($){f4();let u=$?.mode??"auto",r=u==="bridge"||u==="auto"&&Ku(),g,v,_={capabilities:{}};if(r)v=new qv($?.hostOrigin),v.connect(),_=await v.initialize($?.capabilities??{toolInput:!0}),g=v.createTransport();else if($?.transport)g=c4($.transport);else g=x4();if(_.theme&&typeof document<"u")S4(document.documentElement,_.theme);let U,I,D,b,N=_.toolInput,O;if(v)v.on("prefab:tool-input",(j)=>{let B=j.args??j;if(U)U(B);else N=B}),v.on("prefab:tool-result",(j)=>{let B=j.result??j;if(I)I(B);else O=B}),v.on("prefab:tool-cancelled",()=>{D?.()}),v.on("prefab:tool-input-partial",(j)=>{b?.(j.args??j)}),v.on("prefab:theme-update",(j)=>{if(typeof document<"u")S4(document.documentElement,j)});function P(j,...B){let E=Cw(j),M=new ju,C={store:M,scope:{},transport:g,rerender:()=>Z(),onToast:void 0};function Z(){E.innerHTML="";for(let q of B)E.appendChild(D$(q,C))}return Z(),{rerender:Z,store:M,destroy:()=>{E.innerHTML=""}}}return{callTool:(j,B={})=>g.callTool(j,B),sendMessage:(j)=>g.sendMessage(j),onToolInput:(j)=>{if(U=j,N){let B=N;N=void 0,queueMicrotask(()=>j(B))}},onToolResult:(j)=>{if(I=j,O!==void 0){let B=O;O=void 0,queueMicrotask(()=>j(B))}},onToolCancelled:(j)=>{D=j},onToolInputPartial:(j)=>{b=j},render:P,mount:(j,B,E)=>{let M=Cw(j);return x$.mount(M,B,{transport:g,...E})},requestMode:(j)=>v?.requestMode(j),openLink:(j,B)=>{if(v)v.openLink(j,B);else if(typeof window<"u")window.open(j,B??"_blank")},updateContext:(j)=>{if(v)v.updateContext(j)},host:_,capabilities:_.capabilities,theme:_.theme,transport:g,destroy:()=>v?.disconnect()}}function Cw($){if(typeof $==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let u=document.querySelector($);if(!u)throw Error(`Element not found: ${$}`);return u}return $}var x$={mount($,u,r){f4();let g=[];if(u.pipes)for(let[O,P]of Object.entries(u.pipes))z8(O,P,g);let v=new ju(u.state),_;if(r?.transport&&"callTool"in r.transport)_=r.transport;else if(r?.transport)_=c4(r.transport);else _=x4();let U=r?.onToast??O8,I={store:v,scope:{},transport:_,rerender:()=>N(),onToast:U,defs:u.defs};yN($,u.theme);let D=[];if(u.stylesheets)for(let O of u.stylesheets){let P=document.createElement("style");P.textContent=O,P.dataset.prefab="injected",document.head.appendChild(P),D.push(P)}let b;if(u.keyBindings)b=fN(u.keyBindings,async(O)=>{await r$(O,{store:v,transport:_,scope:{},rerender:()=>N(),onToast:U})});function N(){$.innerHTML="";let O=D$(u.view,I);$.appendChild(O)}return N(),{rerender:()=>N(),update(O){v.merge(O.update.state),N()},store:v,destroy(){b?.(),uN();for(let O of D)O.remove();for(let O of g)Hu(O);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},N8=new Set(["find","dot","length","upper","lower","truncate","join","first","last","abs","round","number","currency","percent","compact","date","time","datetime","pluralize","default","selectattr","rejectattr"]);function z8($,u,r){if(N8.has($)){console.warn(`[prefab] wire pipe "${$}" ignored — shadows built-in`);return}try{let g=Function("return ("+u+")")();if(typeof g!=="function"){console.warn(`[prefab] wire pipe "${$}" — source did not evaluate to a function`);return}Bu($,g),r.push($)}catch(g){console.warn(`[prefab] wire pipe "${$}" — failed to hydrate:`,g)}}function O8($){if(typeof document>"u")return;let u=w8(),r=document.createElement("div");r.className="pf-toast",r.setAttribute("data-variant",$.variant??"default"),r.style.padding="12px 16px",r.style.borderRadius="8px",r.style.backgroundColor="var(--card, #fff)",r.style.border="1px solid var(--border, #e5e7eb)",r.style.boxShadow="0 4px 12px rgb(0 0 0 / 0.15)",r.style.marginBottom="8px",r.style.transition="opacity 0.3s ease";let g=document.createElement("div");if(g.textContent=$.message,g.style.fontWeight="500",r.appendChild(g),$.description){let _=document.createElement("div");_.textContent=$.description,_.style.fontSize="14px",_.style.color="var(--muted-foreground, #6b7280)",r.appendChild(_)}u.appendChild(r);let v=$.duration??4000;setTimeout(()=>{r.style.opacity="0",setTimeout(()=>r.remove(),300)},v)}function w8(){let u=document.getElementById("prefab-toast-container");if(!u)u=document.createElement("div"),u.id="prefab-toast-container",u.style.position="fixed",u.style.bottom="16px",u.style.right="16px",u.style.zIndex="9999",u.style.maxWidth="400px",document.body.appendChild(u);return u}if(typeof window<"u"){let $=window;$.PrefabRenderer=x$,$.prefab={app:tr,mount:x$.mount.bind(x$),isPrefabData:x$.isPrefabData.bind(x$),isPrefabUpdate:x$.isPrefabUpdate.bind(x$),Bridge:qv,isIframe:Ku,registerPipe:Bu,unregisterPipe:Hu,listPipes:i4,registerComponent:W};let u=$.__PREFAB_DATA__;if(u!=null){let r=document.getElementById("prefab-root");if(r)x$.mount(r,u)}}})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maxhealth.tech/prefab",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "TypeScript declarative UI component library for MCP apps. Wire-compatible with Python prefab-ui.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",