@maxhealth.tech/prefab 0.3.8 → 0.3.10
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/CHANGELOG.md +44 -0
- package/README.md +79 -11
- package/dist/a2ui/browser.d.ts +46 -0
- package/dist/a2ui/browser.d.ts.map +1 -0
- package/dist/a2ui/browser.js +58 -0
- package/dist/a2ui/browser.js.map +1 -0
- package/dist/a2ui/catalog.d.ts +51 -0
- package/dist/a2ui/catalog.d.ts.map +1 -0
- package/dist/a2ui/catalog.js +465 -0
- package/dist/a2ui/catalog.js.map +1 -0
- package/dist/a2ui/emit.d.ts +59 -0
- package/dist/a2ui/emit.d.ts.map +1 -0
- package/dist/a2ui/emit.js +269 -0
- package/dist/a2ui/emit.js.map +1 -0
- package/dist/a2ui/expr.d.ts +58 -0
- package/dist/a2ui/expr.d.ts.map +1 -0
- package/dist/a2ui/expr.js +81 -0
- package/dist/a2ui/expr.js.map +1 -0
- package/dist/a2ui/icons.d.ts +30 -0
- package/dist/a2ui/icons.d.ts.map +1 -0
- package/dist/a2ui/icons.js +87 -0
- package/dist/a2ui/icons.js.map +1 -0
- package/dist/a2ui/index.d.ts +27 -0
- package/dist/a2ui/index.d.ts.map +1 -0
- package/dist/a2ui/index.js +23 -0
- package/dist/a2ui/index.js.map +1 -0
- package/dist/a2ui/table.d.ts +31 -0
- package/dist/a2ui/table.d.ts.map +1 -0
- package/dist/a2ui/table.js +155 -0
- package/dist/a2ui/table.js.map +1 -0
- package/dist/a2ui/types.d.ts +174 -0
- package/dist/a2ui/types.d.ts.map +1 -0
- package/dist/a2ui/types.js +35 -0
- package/dist/a2ui/types.js.map +1 -0
- package/dist/a2ui.min.js +1 -0
- package/dist/app.d.ts +17 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +19 -0
- package/dist/app.js.map +1 -1
- package/dist/auto/form.d.ts +25 -0
- package/dist/auto/form.d.ts.map +1 -1
- package/dist/auto/form.js +21 -8
- package/dist/auto/form.js.map +1 -1
- package/dist/components/charts/index.d.ts +4 -0
- package/dist/components/charts/index.d.ts.map +1 -1
- package/dist/components/charts/index.js +2 -0
- package/dist/components/charts/index.js.map +1 -1
- package/dist/components/form/index.d.ts +1 -6
- package/dist/components/form/index.d.ts.map +1 -1
- package/dist/components/form/index.js +7 -37
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/interactive/index.d.ts +5 -1
- package/dist/components/interactive/index.d.ts.map +1 -1
- package/dist/components/interactive/index.js +5 -2
- package/dist/components/interactive/index.js.map +1 -1
- package/dist/components/media/index.d.ts +20 -2
- package/dist/components/media/index.d.ts.map +1 -1
- package/dist/components/media/index.js +13 -1
- package/dist/components/media/index.js.map +1 -1
- package/dist/components/table/index.d.ts +5 -1
- package/dist/components/table/index.d.ts.map +1 -1
- package/dist/components/table/index.js +5 -2
- package/dist/components/table/index.js.map +1 -1
- package/dist/core/component.d.ts +11 -0
- package/dist/core/component.d.ts.map +1 -1
- package/dist/core/component.js +22 -9
- package/dist/core/component.js.map +1 -1
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.d.ts.map +1 -1
- package/dist/core/version.js +1 -1
- package/dist/core/version.js.map +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/a2ui.d.ts +91 -0
- package/dist/mcp/a2ui.d.ts.map +1 -0
- package/dist/mcp/a2ui.js +134 -0
- package/dist/mcp/a2ui.js.map +1 -0
- package/dist/mcp/display.d.ts +28 -6
- package/dist/mcp/display.d.ts.map +1 -1
- package/dist/mcp/display.js +10 -9
- package/dist/mcp/display.js.map +1 -1
- package/dist/mcp/index.d.ts +7 -2
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +3 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/input-required.d.ts +79 -0
- package/dist/mcp/input-required.d.ts.map +1 -0
- package/dist/mcp/input-required.js +231 -0
- package/dist/mcp/input-required.js.map +1 -0
- package/dist/mcp/resource.d.ts +10 -0
- package/dist/mcp/resource.d.ts.map +1 -1
- package/dist/mcp/resource.js +12 -4
- package/dist/mcp/resource.js.map +1 -1
- package/dist/mcp/result.d.ts +7 -5
- package/dist/mcp/result.d.ts.map +1 -1
- package/dist/mcp/result.js +5 -3
- package/dist/mcp/result.js.map +1 -1
- package/dist/mcp/types.d.ts +117 -0
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/prefab.css +4 -0
- package/dist/renderer/components/data.js +2 -2
- package/dist/renderer/components/data.js.map +1 -1
- package/dist/renderer/components/form.js +41 -15
- package/dist/renderer/components/form.js.map +1 -1
- package/dist/renderer/components/index.d.ts.map +1 -1
- package/dist/renderer/components/index.js +6 -0
- package/dist/renderer/components/index.js.map +1 -1
- package/dist/renderer/components/interactive.js +17 -4
- package/dist/renderer/components/interactive.js.map +1 -1
- package/dist/renderer/components/media.d.ts +7 -0
- package/dist/renderer/components/media.d.ts.map +1 -1
- package/dist/renderer/components/media.js +63 -2
- package/dist/renderer/components/media.js.map +1 -1
- package/dist/renderer/components/table.js +1 -1
- package/dist/renderer/components/table.js.map +1 -1
- package/dist/renderer/engine.d.ts +4 -0
- package/dist/renderer/engine.d.ts.map +1 -1
- package/dist/renderer/engine.js +24 -0
- package/dist/renderer/engine.js.map +1 -1
- package/dist/renderer.auto.min.js +13 -13
- package/dist/renderer.min.js +13 -13
- package/package.json +13 -3
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
(()=>{var j0={silent:0,error:1,warn:2,info:3,debug:4},k0="warn";function A0($){k0=$}function l1($){let Z=$?`[prefab:${$}]`:"[prefab]",J=(q,Q,Y)=>{if(j0[q]>j0[k0])return;console[q](`${Z} ${Q}`,...Y)};return{error:(q,...Q)=>J("error",q,Q),warn:(q,...Q)=>J("warn",q,Q),info:(q,...Q)=>J("info",q,Q),debug:(q,...Q)=>J("debug",q,Q)}}var b=l1();class K1{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return b4(this.data,$)}getAll(){return this.data}set($,Z){S0(this.data,$,Z),this.notify($)}toggle($){let Z=this.get($),J=Z==null||Z===!1||Z===0||Z==="";this.set($,J)}append($,Z,J){let q=this.get($);if(!Array.isArray(q)){this.set($,[Z]);return}if(J!==void 0)q.splice(J,0,Z);else q.push(Z);this.notify($)}pop($,Z){let J=this.get($);if(!Array.isArray(J))return;if(typeof Z==="number")J.splice(Z,1);else{let q=J.indexOf(Z);if(q>=0)J.splice(q,1)}this.notify($)}merge($){for(let[Z,J]of Object.entries($))S0(this.data,Z,J);for(let Z of Object.keys($))this.notify(Z)}subscribe($,Z){if(!this.subscribers.has($))this.subscribers.set($,new Set);return this.subscribers.get($)?.add(Z),()=>this.subscribers.get($)?.delete(Z)}subscribeAll($){return this.globalSubscribers.add($),()=>this.globalSubscribers.delete($)}notify($){this.generation++;let Z=$.split(".");for(let J=1;J<=Z.length;J++){let q=Z.slice(0,J).join("."),Q=this.subscribers.get(q);if(Q)Q.forEach((Y)=>Y())}this.globalSubscribers.forEach((J)=>J())}}function b4($,Z){let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}var y4=new Set(["__proto__","constructor","prototype"]);function S0($,Z,J){let q=Z.split(".");if(q.some((Y)=>y4.has(Y))){b.warn(`Blocked prototype pollution attempt: ${Z}`);return}let Q=$;for(let Y=0;Y<q.length-1;Y++){let U=q[Y];if(Q[U]==null||typeof Q[U]!=="object")Q[U]={};Q=Q[U]}Q[q[q.length-1]]=J}var _1=new Map;function i1($,Z){if(_1.has($)&&_1.get($)!==Z)b.warn(`pipe "${$}" re-registered`);_1.set($,Z)}function s1($){return _1.delete($)}function f0(){return[..._1.keys()]}function T1($){return _1.get($)}function w($){if($==null)return"";if(typeof $==="string")return $;if(typeof $==="number"||typeof $==="boolean"||typeof $==="bigint")return String($);if(typeof $==="symbol")return $.description??"";if(typeof $==="function")return $.name;if($ instanceof Date)return Number.isNaN($.getTime())?"":$.toISOString();if(Array.isArray($))return $.map(w).join(", ");try{return JSON.stringify($)??""}catch{return""}}var C0=-1,n1=new Map,m4=/\{\{\s*(.+?)\s*\}\}/g;function t($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function e($,Z,J){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&c4(q,"{{")===1){let Q=q.slice(2,-2).trim();return w0(Q,Z,J)}return $.replace(m4,(Q,Y)=>{let U=w0(Y.trim(),Z,J);return w(U)})}function w0($,Z,J){let[q,...Q]=p4($),Y=a(q.trim(),Z,J);for(let U of Q)Y=h4(U.trim(),Y,Z,J);return Y}function a($,Z,J){let q=u4($);if(q>=0){let U=$.slice(0,q).trim(),H=$.slice(q+1),G=x4(H);if(G>=0){let _=H.slice(0,G).trim(),z=H.slice(G+1).trim(),W=a(U,Z,J);return W!==null&&W!==void 0&&W!==!1&&W!==0&&W!==""?a(_,Z,J):a(z,Z,J)}}let Q=O1($,"||");if(Q>=0){let U=a($.slice(0,Q).trim(),Z,J);return U!==null&&U!==void 0&&U!==!1&&U!==0&&U!==""?U:a($.slice(Q+2).trim(),Z,J)}let Y=O1($,"&&");if(Y>=0){let U=a($.slice(0,Y).trim(),Z,J);if(U===null||U===void 0||U===!1||U===0||U==="")return U;return a($.slice(Y+2).trim(),Z,J)}for(let[U,H]of v4){let G=O1($,U);if(G>=0){let _=a($.slice(0,G).trim(),Z,J),z=a($.slice(G+U.length).trim(),Z,J);return H(_,z)}}if($.startsWith("!")){let U=a($.slice(1).trim(),Z,J);return U===null||U===void 0||U===!1||U===0||U===""}for(let[U,H]of g4){let G=O1($,U);if(G>=0){let _=a($.slice(0,G).trim(),Z,J),z=a($.slice(G+U.length).trim(),Z,J);return H(Number(_),Number(z))}}if($==="true")return!0;if($==="false")return!1;if($==="null"||$==="undefined")return null;if(/^-?\d+(\.\d+)?$/.test($))return Number($);if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);if(J&&$.startsWith("$")){let U=$.indexOf(".");if(U>=0){let H=$.slice(0,U),G=$.slice(U+1),_=J[H];return I1(_,G)}return J[$]}if(J){let U=$.split(".")[0];if(U in J)return I1(J[U],$.includes(".")?$.slice(U.length+1):"")}return Z.get($)}function h4($,Z,J,q){let Q=$.indexOf(":"),Y=Q>=0?$.slice(0,Q).trim():$,U=Q>=0?$.slice(Q+1).trim():void 0,H=U?r1(U):void 0;switch(Y){case"find":{if(!Array.isArray(Z)||!U)return;let G=b0(U);if(G.length<2)return;let _=r1(G[0]),z=G[1].trim(),W;if(z.startsWith("'")&&z.endsWith("'")||z.startsWith('"')&&z.endsWith('"'))W=z.slice(1,-1);else if(J){if(q&&z.startsWith("$")){let M=z.indexOf(".");if(M>=0){let E=z.slice(0,M);if(E in q)W=I1(q[E],z.slice(M+1))}else if(z in q)W=q[z]}if(W===void 0&&!(q&&z.startsWith("$")))if(q){let M=z.split(".")[0];W=M in q?I1(q[M],z.includes(".")?z.slice(M.length+1):""):J.get(z)}else W=J.get(z)}else W=z;if(W==null)return;let B=J?.generation??0;if(B!==C0)n1=new Map,C0=B;let K=n1.get(Z);if(!K)K=new Map,n1.set(Z,K);let L=K.get(_);if(!L){L=new Map;for(let M of Z)if(M!=null&&typeof M==="object"){let E=M[_];if(E!=null)L.set(w(E),M)}K.set(_,L)}return L.get(w(W))}case"dot":{if(Z==null||typeof Z!=="object"||typeof H!=="string")return;return Z[H]}case"length":return Array.isArray(Z)?Z.length:typeof Z==="string"?Z.length:0;case"upper":return typeof Z==="string"?Z.toUpperCase():Z;case"lower":return typeof Z==="string"?Z.toLowerCase():Z;case"truncate":if(typeof Z==="string"&&typeof H==="number")return Z.slice(0,H);return Z;case"join":return Array.isArray(Z)?Z.join(typeof H==="string"?H:", "):Z;case"first":return Array.isArray(Z)?Z[0]:Z;case"last":return Array.isArray(Z)?Z[Z.length-1]:Z;case"abs":return Math.abs(Number(Z));case"round":return typeof H==="number"?Number(Number(Z).toFixed(H)):Math.round(Number(Z));case"number":return typeof H==="number"?Number(Number(Z).toFixed(H)):Number(Z);case"currency":{let G=typeof H==="string"?H:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:G}).format(Number(Z))}catch{return Z}}case"percent":return typeof H==="number"?`${(Number(Z)*100).toFixed(H)}%`:`${Math.round(Number(Z)*100)}%`;case"compact":{let G=typeof H==="number"?H:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:G}).format(Number(Z))}catch{return Z}}case"date":try{return new Date(Z).toLocaleDateString()}catch{return Z}case"time":try{return new Date(Z).toLocaleTimeString()}catch{return Z}case"datetime":try{return new Date(Z).toLocaleString()}catch{return Z}case"pluralize":{let G=Number(Z),_=typeof H==="string"?H:"";return G===1?_:`${_}s`}case"default":return Z==null||Z===""?H:Z;case"selectattr":return Array.isArray(Z)&&typeof H==="string"?Z.filter((G)=>G!=null&&typeof G==="object"&&Boolean(G[H])):Z;case"rejectattr":return Array.isArray(Z)&&typeof H==="string"?Z.filter((G)=>{if(G==null||typeof G!=="object")return!1;let _=G[H];return _==null||_===!1||_===0||_===""}):Z;default:{let G=T1(Y);if(G){let _=U?b0(U).map(r1):[];return G(Z,..._)}return Z}}}var v4=[["!==",($,Z)=>$!==Z],["===",($,Z)=>$===Z],["!=",($,Z)=>$!=Z],["==",($,Z)=>$==Z],[">=",($,Z)=>Number($)>=Number(Z)],["<=",($,Z)=>Number($)<=Number(Z)],[">",($,Z)=>Number($)>Number(Z)],["<",($,Z)=>Number($)<Number(Z)]],g4=[[" + ",($,Z)=>$+Z],[" - ",($,Z)=>$-Z],[" * ",($,Z)=>$*Z],[" / ",($,Z)=>Z!==0?$/Z:0],[" % ",($,Z)=>Z!==0?$%Z:0]];function O1($,Z){let J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J&&$.slice(q,q+Z.length)===Z)return q}return-1}function u4($){let Z=0,J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J){if(Q==="(")Z++;else if(Q===")")Z--;else if(Q==="?"&&Z===0)return q}}return-1}function x4($){let Z=0,J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J){if(Q==="?"||Q==="(")Z++;else if(Q===")")Z--;else if(Q===":"&&Z===0)return q}}return-1}function p4($){let Z=[],J="",q=null;for(let Q=0;Q<$.length;Q++){let Y=$[Q];if(Y==="'"||Y==='"')q=q===Y?null:q??Y;if(Y==="|"&&!q)if($[Q+1]==="|")J+="||",Q++;else Z.push(J),J="";else J+=Y}return Z.push(J),Z}function r1($){let Z=$.replace(/^['"]|['"]$/g,"");if(Z==="true")return!0;if(Z==="false")return!1;let J=Number(Z);return isNaN(J)?Z:J}function b0($){let Z=[],J="",q=null;for(let Q of $){if(Q==="'"||Q==='"')q=q===Q?null:q??Q;if(Q===","&&!q)Z.push(J),J="";else J+=Q}return Z.push(J),Z}function I1($,Z){if(!Z)return $;let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}function c4($,Z){let J=0,q=0;while((q=$.indexOf(Z,q))!==-1)J++,q+=Z.length;return J}function V1($){return $.replace(/_([a-z])/g,(Z,J)=>J.toUpperCase())}function o1($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:V1(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?o1(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=o1(q);else Z[Q]=q}return Z}async function h($,Z){let J=Array.isArray($)?$:[$];for(let q of J)await d4(q,Z)}function v($,Z){$.catch((J)=>b.error(`${Z} failed:`,J))}async function j1($,Z,J,q){if(J!=null)b.debug(`${$} failed:`,Z),await G1(J,q,{$error:Z});else b.warn(`${$} failed:`,Z)}async function d4($,Z){let J=o1($),q=J.action;switch(q){case"setState":{l4(J,Z);return}case"toggleState":{i4(J,Z);return}case"appendState":{s4(J,Z);return}case"popState":{n4(J,Z);return}case"showToast":{r4(J,Z);return}case"closeOverlay":{a4(J,Z);return}case"openLink":{o4(J);return}case"setInterval":{e4(J,Z);return}case"toolCall":case"callTool":return $8(J,Z);case"sendMessage":return Z8(J,Z);case"updateContext":{J8(J,Z);return}case"fetch":return q8(J,Z);case"openFilePicker":{Q8(J,Z);return}case"callHandler":return Y8(J,Z);case"requestDisplayMode":{U8(J,Z);return}case"subscribe":{W8(J,Z);return}case"unsubscribe":{X8(J);return}default:b.warn(`Unknown action: ${q}`)}}function l4($,Z){let{key:J,value:q}=$;if(t(q))q=e(q,Z.store,Z.scope);Z.store.set(J,q),Z.rerender(),G1($.onSuccess,Z)}function i4($,Z){Z.store.toggle($.key),Z.rerender()}function s4($,Z){let J=$.value??$.item;if(t(J))J=e(J,Z.store,Z.scope);Z.store.append($.key,J,$.index),Z.rerender()}function n4($,Z){Z.store.pop($.key,$.index),Z.rerender()}function r4($,Z){Z.onToast?.({message:R1($.message,Z),description:$.description!=null?R1($.description,Z):void 0,variant:$.variant,duration:$.duration})}function a4($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function o4($){if(typeof window<"u"){let Z=$.url;if(!Z){b.warn("openLink: missing url");return}if(!v0(Z)){b.warn(`Blocked unsafe URL scheme: ${Z}`);return}window.open(Z,$.target??"_blank")}}var P1=new Set,t4=20,y0=100;function e4($,Z){let J=Math.max($.intervalMs,y0),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(P1.size>=t4){b.warn("Max intervals reached, ignoring new setInterval");return}let Q=globalThis.setInterval(()=>v(h(q,Z),"interval action"),J);P1.add(Q)}function m0(){for(let $ of P1)globalThis.clearInterval($);P1.clear()}async function $8($,Z){if(!Z.transport){b.warn("No MCP transport configured for toolCall");return}let J=$.tool,q=t1($.arguments,Z);try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=k1(Q);if(Y&&Z.remount)Z.remount(Y);else A1(Q,Z),Z.rerender();await G1($.onSuccess,Z,{$result:Q})}catch(Q){await j1("toolCall",Q,$.onError,Z)}}async function Z8($,Z){if(!Z.transport){b.warn("No MCP transport configured for sendMessage");return}await Z.transport.sendMessage(R1($.message,Z))}function J8($,Z){let J=$.context;if(J!=null)Z.store.merge(J),Z.rerender()}async function q8($,Z){let J=R1($.url,Z);if(!v0(J)){b.warn(`Blocked unsafe URL in fetch: ${J}`);return}let q=$.method??"GET",Q=$.headers,Y=$.body!==void 0?JSON.stringify($.body):void 0;try{let U=await globalThis.fetch(J,{method:q,headers:{"Content-Type":"application/json",...Q},...Y&&{body:Y}}),H=await U.json().catch(()=>U.text());if($.resultKey!=null)Z.store.set($.resultKey,H);let G=k1(H);if(G&&Z.remount)Z.remount(G);else A1(H,Z),Z.rerender();await G1($.onSuccess,Z,{$result:H})}catch(U){await j1("fetch",U,$.onError,Z)}}function Q8($,Z){if(typeof document>"u")return;let J=document.createElement("input");if(J.type="file",$.accept!=null)J.accept=$.accept;if($.multiple===!0)J.multiple=!0;J.addEventListener("change",()=>{let q=Array.from(J.files??[]);if($.resultKey!=null)Z.store.set($.resultKey,q);Z.rerender(),G1($.onSuccess,Z,{$result:q})}),J.click()}async function Y8($,Z){let J=$.handler,q=t1($.arguments,Z);if(!Z.transport){b.warn(`No transport configured for callHandler: ${J}`);return}try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=k1(Q);if(Y&&Z.remount)Z.remount(Y);else A1(Q,Z),Z.rerender();await G1($.onSuccess,Z,{$result:Q})}catch(Q){await j1("callHandler",Q,$.onError,Z)}}function U8($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var Q1=new Map,H8=50,G8=2000;function W8($,Z){let{uri:J,stateKey:q}=$;if(!J||!q){b.warn("subscribe: missing uri or stateKey");return}if(Q1.has(J))return;if(Q1.size>=H8){b.warn("Max subscriptions reached, ignoring new subscribe");return}let Q=(W)=>{let B=k1(W);if(B&&Z.remount)Z.remount(B);else{if(!A1(W,Z))Z.store.set(q,W);Z.rerender()}G1($.onData,Z,{$data:W})};if(Z.transport?.subscribe&&Z.transport.capabilities?.subscriptions){let W=Z.transport.subscribe(J,Q);Q1.set(J,W);return}let Y=$.fallbackTool,U=$.fallbackInterval??G8;if(!Y){b.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!Z.transport){b.warn("No MCP transport configured for subscribe fallback");return}let H=$.fallbackArgs??{},G=Math.max(U,y0),_=Z.transport,z=globalThis.setInterval(()=>{(async()=>{try{let W=t1(H,Z),B=await _.callTool(Y,W);Q(B)}catch(W){j1("subscribe",W,$.onError,Z)}})()},G);Q1.set(J,()=>globalThis.clearInterval(z))}function X8($){let Z=$.uri;if(!Z){b.warn("unsubscribe: missing uri");return}let J=Q1.get(Z);if(J)J(),Q1.delete(Z)}function h0(){for(let[$,Z]of Q1)try{Z()}catch(J){b.warn(`Error cleaning up subscription '${$}':`,J)}Q1.clear()}function k1($){if($==null||typeof $!=="object")return null;let Z=$;if("$prefab"in Z&&"view"in Z)return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"){let q=J;if("$prefab"in q&&"view"in q)return q}}if("content"in Z&&Array.isArray(Z.content)){for(let J of Z.content)if(J.type==="text"&&typeof J.text==="string")try{let q=JSON.parse(J.text);if(q!=null&&typeof q==="object"){let Q=q;if("$prefab"in Q&&"view"in Q)return Q}}catch{}}return null}function B8($){if($==null||typeof $!=="object")return null;let Z=$;if(a1(Z))return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"&&a1(J))return J}if("content"in Z&&Array.isArray(Z.content)){for(let J of Z.content)if(J.type==="text"&&typeof J.text==="string")try{let q=JSON.parse(J.text);if(q!=null&&typeof q==="object"&&a1(q))return q}catch{}}return null}function a1($){if(!("$prefab"in $)||!("update"in $))return!1;let Z=$.update;return Z!=null&&typeof Z==="object"&&"state"in Z}function A1($,Z){let J=B8($);if(!J)return!1;let q=J.update;if(Z.store.merge(q.state),q.actions!=null)v(h(q.actions,Z),"update action");return!0}var M8=/^\s*(javascript|vbscript|data):/i;function v0($){return!M8.test($)}function R1($,Z){if(t($)){let J=e($,Z.store,Z.scope);return w(J)}return w($)}function t1($,Z){if(!$)return{};let J={};for(let[q,Q]of Object.entries($))J[q]=t(Q)?e(Q,Z.store,Z.scope):Q;return J}async function G1($,Z,J){if($==null)return;let q={...Z.scope,...J};await h($,{...Z,scope:q})}function $0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:V1(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?$0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=$0(q);else Z[Q]=q}return Z}class J0{callbacks=[];track($){this.callbacks.push($)}flush(){for(let $ of this.callbacks)try{$()}catch(Z){b.warn("destroy callback error:",Z)}this.callbacks=[]}get size(){return this.callbacks.length}}function _8($){return typeof $==="object"&&"element"in $}var Z0=new Map;function X($,Z){if(Z0.has($))b.warn(`overriding existing renderer for "${$}"`);Z0.set($,Z)}function u($,Z){let J=$0($);if(Z.defs?.[J.type]){let Y={...Z.defs[J.type],...J,type:Z.defs[J.type].type};return u(Y,Z)}let q=Z0.get(J.type),Q;if(q){let Y=q(J,Z);if(_8(Y))Q=Y.element,Z.destroyRegistry?.track(Y.destroy);else Q=Y}else if(Q=document.createElement("div"),Q.setAttribute("data-prefab-type",J.type),J.children)for(let Y of J.children)Q.appendChild(u(Y,Z));if(Q instanceof HTMLElement){if(J.id)Q.id=J.id;if(J.cssClass){let Y=F(J.cssClass,Z);if(Y)Q.className=(Q.className?Q.className+" ":"")+Y}if(J.onClick!=null){if(Q.addEventListener("click",()=>{v(h(J.onClick,l(Z)),"onClick")}),Q.tagName!=="BUTTON"&&Q.tagName!=="A")Q.setAttribute("role","button"),Q.setAttribute("tabindex","0"),Q.addEventListener("keydown",(Y)=>{let U=Y.key;if(U==="Enter"||U===" ")Y.preventDefault(),v(h(J.onClick,l(Z)),"onClick")})}}if(J.onMount){let Y=J.onMount,U=l(Z);queueMicrotask(()=>v(h(Y,U),"onMount"))}return Q}function C($,Z,J){if(!$.children)return;Y1($.children,Z,J)}function Y1($,Z,J){let q=0;while(q<$.length){let Q=$[q];if(Q.type==="If")q=N8($,q,Z,J);else if(Q.type==="Elif"||Q.type==="Else")q++;else Z.appendChild(u(Q,J)),q++}}function N8($,Z,J,q){let Q=!1,Y=Z,U=$[Y];if(g0(U.condition,q))e1(U,J,q),Q=!0;Y++;while(Y<$.length){let H=$[Y];if(H.type==="Elif"){if(!Q&&g0(H.condition,q))e1(H,J,q),Q=!0;Y++}else if(H.type==="Else"){if(!Q)e1(H,J,q);Y++;break}else break}return Y}function g0($,Z){if(!$)return!1;if(t($))return Boolean(e($,Z.store,Z.scope));return Boolean(Z.store.get($))}function e1($,Z,J){if(!$.children)return;Y1($.children,Z,J)}function F($,Z){if(t($)){let J=e($,Z.store,Z.scope);return w(J)}return w($)}function d($,Z){if(t($))return e($,Z.store,Z.scope);return $}function l($){return{store:$.store,transport:$.transport,scope:$.scope,rerender:$.rerender,onToast:$.onToast,remount:$.remount}}function N($,Z){let J=document.createElement($);if(Z)J.className=Z;return J}function q0($,Z){return $.textContent=Z,$}function c0(){X("Column",z8),X("Row",E8),X("Grid",u0),X("GridItem",x0),X("Container",K8),X("Div",p0),X("Span",F8),X("Dashboard",u0),X("DashboardItem",x0),X("Pages",L8),X("Page",p0),X("Detail",D8),X("MasterDetail",T8)}function z8($,Z){let J=N("div","pf-column");J.style.display="flex",J.style.flexDirection="column";let q=S1($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=d0($.align);if($.justify!=null)J.style.justifyContent=l0($.justify);return C($,J,Z),J}function E8($,Z){let J=N("div","pf-row");J.style.display="flex",J.style.flexDirection="row";let q=S1($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=d0($.align);if($.justify!=null)J.style.justifyContent=l0($.justify);if($.wrap===!0)J.style.flexWrap="wrap";return C($,J,Z),J}function u0($,Z){let J=N("div","pf-grid");J.style.display="grid";let q=$.columns??3;J.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let Q=S1($);if(Q!=null)J.style.gap=`${Q*4}px`;return C($,J,Z),J}function x0($,Z){let J=N("div","pf-grid-item");if($.colSpan!=null)J.style.gridColumn=`span ${$.colSpan}`;if($.rowSpan!=null)J.style.gridRow=`span ${$.rowSpan}`;return C($,J,Z),J}function K8($,Z){let J=N("div","pf-container");if(J.style.maxWidth=$.maxWidth??"1200px",J.style.margin="0 auto",$.padding!=null)J.style.padding=`${$.padding*4}px`;return C($,J,Z),J}function p0($,Z){let J=N("div","pf-div");return C($,J,Z),J}function F8($,Z){let J=N("span","pf-span");return C($,J,Z),J}function L8($,Z){let J=N("div","pf-pages");return C($,J,Z),J}function D8($,Z){let J=N("div","pf-detail"),q=$.of!=null?d($.of,Z):void 0;if(q!=null&&q!==""&&q!==!1&&q!==0)C($,J,Z);else if($.empty!=null){let Q=$.empty;J.appendChild(u(Q,Z))}return J}function T8($,Z){let J=N("div","pf-master-detail");J.style.display="flex",J.style.flexDirection="row";let q=S1($);if(q!=null)J.style.gap=`${q*4}px`;let Q=$.masterWidth??"33%",Y=$.children??[];if(Y.length>0){let U=N("div","pf-master-detail-master");U.style.width=Q,U.style.flexShrink="0",U.style.overflow="auto",U.appendChild(u(Y[0],Z)),J.appendChild(U)}if(Y.length>1){let U=N("div","pf-master-detail-detail");U.style.flex="1",U.style.overflow="auto",U.appendChild(u(Y[1],Z)),J.appendChild(U)}return J}var O8=/\bgap-(\d+)\b/;function S1($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let Z=O8.exec($.cssClass);if(Z)return Number(Z[1])}return null}function d0($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function l0($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}var I8={"&":"&","<":"<",">":">",'"':""","'":"'"};function F1($){return $.replace(/[&<>"']/g,(Z)=>I8[Z]??Z)}function s0(){X("Heading",V8),X("H1",($,Z)=>f1($,Z,"h1")),X("H2",($,Z)=>f1($,Z,"h2")),X("H3",($,Z)=>f1($,Z,"h3")),X("H4",($,Z)=>f1($,Z,"h4")),X("Text",P8),X("P",R8),X("Lead",($,Z)=>N1($,Z,"p","pf-lead")),X("Large",($,Z)=>N1($,Z,"span","pf-large")),X("Small",($,Z)=>N1($,Z,"small","pf-small")),X("Muted",($,Z)=>N1($,Z,"p","pf-muted")),X("BlockQuote",($,Z)=>N1($,Z,"blockquote","pf-blockquote")),X("Label",($,Z)=>N1($,Z,"label","pf-label")),X("Link",k8),X("Code",A8),X("Markdown",S8),X("Kbd",f8)}function V8($,Z){let J=$.level??2,q=`h${Math.min(Math.max(J,1),6)}`,Q=document.createElement(q);return Q.className=`pf-heading pf-${q}`,Q.textContent=F($.content,Z),Q}function f1($,Z,J){let q=document.createElement(J);return q.className=`pf-heading pf-${J}`,q.textContent=F($.content,Z),q}function P8($,Z){return q0(N("span","pf-text"),F($.content,Z))}function R8($,Z){return q0(N("p","pf-p"),F($.content,Z))}function N1($,Z,J,q){let Q=document.createElement(J);return Q.className=q,Q.textContent=F($.content,Z),Q}var j8=/^\s*(javascript|vbscript|data):/i;function k8($,Z){let J=document.createElement("a");if(J.className="pf-link",J.textContent=F($.content,Z),$.href!=null){let q=F($.href,Z);if(!j8.test(q))J.href=q}if($.target!=null)J.target=F($.target,Z);return J}function A8($,Z){let J=N("pre","pf-code"),q=N("code");if(q.textContent=F($.content,Z),$.language!=null)q.setAttribute("data-language",$.language);return J.appendChild(q),J}function S8($,Z){let J=N("div","pf-markdown"),q=F($.content,Z);return J.innerHTML=n0(q),J.setAttribute("data-markdown","true"),J}var i0=/^\s*(javascript|vbscript|data):/i;function C1($){let Z=F1($),J=[];return Z=Z.replace(/`([^`]+)`/g,(q,Q)=>{return J.push(`<code>${Q}</code>`),`CODE${J.length-1}`}),Z=Z.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(i0.test(Y))return F1(Q);return`<img src="${Y}" alt="${Q}" />`}),Z=Z.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(i0.test(Y))return Q;return`<a href="${Y}">${Q}</a>`}),Z=Z.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),Z=Z.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),Z=Z.replace(/\*(.+?)\*/g,"<em>$1</em>"),Z=Z.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),Z=Z.replace(/~~(.+?)~~/g,"<del>$1</del>"),Z=Z.replace(/\uFDD0CODE(\d+)\uFDD0/g,(q,Q)=>J[parseInt(Q)]),Z}function n0($){let Z=$.replace(/\r\n?/g,`
|
|
1
|
+
(()=>{var Mt={silent:0,error:1,warn:2,info:3,debug:4},Lt="warn";function Ht(e){Lt=e}function qe(e){let t=e?`[prefab:${e}]`:"[prefab]",n=(r,o,i)=>{if(Mt[r]>Mt[Lt])return;console[r](`${t} ${o}`,...i)};return{error:(r,...o)=>n("error",r,o),warn:(r,...o)=>n("warn",r,o),info:(r,...o)=>n("info",r,o),debug:(r,...o)=>n("debug",r,o)}}var O=qe();class ye{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor(e){if(e)this.data=structuredClone(e)}get(e){return Jn(this.data,e)}getAll(){return this.data}set(e,t){Pt(this.data,e,t),this.notify(e)}toggle(e){let t=this.get(e),n=t==null||t===!1||t===0||t==="";this.set(e,n)}append(e,t,n){let r=this.get(e);if(!Array.isArray(r)){this.set(e,[t]);return}if(n!==void 0)r.splice(n,0,t);else r.push(t);this.notify(e)}pop(e,t){let n=this.get(e);if(!Array.isArray(n))return;if(typeof t==="number")n.splice(t,1);else{let r=n.indexOf(t);if(r>=0)n.splice(r,1)}this.notify(e)}merge(e){for(let[t,n]of Object.entries(e))Pt(this.data,t,n);for(let t of Object.keys(e))this.notify(t)}subscribe(e,t){if(!this.subscribers.has(e))this.subscribers.set(e,new Set);return this.subscribers.get(e)?.add(t),()=>this.subscribers.get(e)?.delete(t)}subscribeAll(e){return this.globalSubscribers.add(e),()=>this.globalSubscribers.delete(e)}notify(e){this.generation++;let t=e.split(".");for(let n=1;n<=t.length;n++){let r=t.slice(0,n).join("."),o=this.subscribers.get(r);if(o)o.forEach((i)=>i())}this.globalSubscribers.forEach((n)=>n())}}function Jn(e,t){let n=t.split("."),r=e;for(let o of n){if(r==null||typeof r!=="object")return;r=r[o]}return r}var zn=new Set(["__proto__","constructor","prototype"]);function Pt(e,t,n){let r=t.split(".");if(r.some((i)=>zn.has(i))){O.warn(`Blocked prototype pollution attempt: ${t}`);return}let o=e;for(let i=0;i<r.length-1;i++){let s=r[i];if(o[s]==null||typeof o[s]!=="object")o[s]={};o=o[s]}o[r[r.length-1]]=n}var me=new Map;function Ue(e,t){if(me.has(e)&&me.get(e)!==t)O.warn(`pipe "${e}" re-registered`);me.set(e,t)}function Xe(e){return me.delete(e)}function $t(){return[...me.keys()]}function ke(e){return me.get(e)}function P(e){if(e==null)return"";if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean"||typeof e==="bigint")return String(e);if(typeof e==="symbol")return e.description??"";if(typeof e==="function")return e.name;if(e instanceof Date)return Number.isNaN(e.getTime())?"":e.toISOString();if(Array.isArray(e))return e.map(P).join(", ");try{return JSON.stringify(e)??""}catch{return""}}var Ot=-1,Ye=new Map,Wn=/\{\{\s*(.+?)\s*\}\}/g;function Q(e){return typeof e==="string"&&e.includes("{{")&&e.includes("}}")}function ee(e,t,n){let r=e.trim();if(r.startsWith("{{")&&r.endsWith("}}")&&Xn(r,"{{")===1){let o=r.slice(2,-2).trim();return Dt(o,t,n)}return e.replace(Wn,(o,i)=>{let s=Dt(i.trim(),t,n);return P(s)})}function Dt(e,t,n){let[r,...o]=Un(e),i=Y(r.trim(),t,n);for(let s of o)i=_n(s.trim(),i,t,n);return i}function Y(e,t,n){let r=Gn(e);if(r>=0){let s=e.slice(0,r).trim(),a=e.slice(r+1),l=qn(a);if(l>=0){let c=a.slice(0,l).trim(),u=a.slice(l+1).trim(),d=Y(s,t,n);return d!==null&&d!==void 0&&d!==!1&&d!==0&&d!==""?Y(c,t,n):Y(u,t,n)}}let o=Se(e,"||");if(o>=0){let s=Y(e.slice(0,o).trim(),t,n);return s!==null&&s!==void 0&&s!==!1&&s!==0&&s!==""?s:Y(e.slice(o+2).trim(),t,n)}let i=Se(e,"&&");if(i>=0){let s=Y(e.slice(0,i).trim(),t,n);if(s===null||s===void 0||s===!1||s===0||s==="")return s;return Y(e.slice(i+2).trim(),t,n)}for(let[s,a]of Vn){let l=Se(e,s);if(l>=0){let c=Y(e.slice(0,l).trim(),t,n),u=Y(e.slice(l+s.length).trim(),t,n);return a(c,u)}}if(e.startsWith("!")){let s=Y(e.slice(1).trim(),t,n);return s===null||s===void 0||s===!1||s===0||s===""}for(let[s,a]of Kn){let l=Se(e,s);if(l>=0){let c=Y(e.slice(0,l).trim(),t,n),u=Y(e.slice(l+s.length).trim(),t,n);return a(Number(c),Number(u))}}if(e==="true")return!0;if(e==="false")return!1;if(e==="null"||e==="undefined")return null;if(/^-?\d+(\.\d+)?$/.test(e))return Number(e);if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);if(n&&e.startsWith("$")){let s=e.indexOf(".");if(s>=0){let a=e.slice(0,s),l=e.slice(s+1),c=n[a];return Ee(c,l)}return n[e]}if(n){let s=e.split(".")[0];if(s in n)return Ee(n[s],e.includes(".")?e.slice(s.length+1):"")}return t.get(e)}function _n(e,t,n,r){let o=e.indexOf(":"),i=o>=0?e.slice(0,o).trim():e,s=o>=0?e.slice(o+1).trim():void 0,a=s?Ze(s):void 0;switch(i){case"find":{if(!Array.isArray(t)||!s)return;let l=jt(s);if(l.length<2)return;let c=Ze(l[0]),u=l[1].trim(),d;if(u.startsWith("'")&&u.endsWith("'")||u.startsWith('"')&&u.endsWith('"'))d=u.slice(1,-1);else if(n){if(r&&u.startsWith("$")){let f=u.indexOf(".");if(f>=0){let b=u.slice(0,f);if(b in r)d=Ee(r[b],u.slice(f+1))}else if(u in r)d=r[u]}if(d===void 0&&!(r&&u.startsWith("$")))if(r){let f=u.split(".")[0];d=f in r?Ee(r[f],u.includes(".")?u.slice(f.length+1):""):n.get(u)}else d=n.get(u)}else d=u;if(d==null)return;let g=n?.generation??0;if(g!==Ot)Ye=new Map,Ot=g;let h=Ye.get(t);if(!h)h=new Map,Ye.set(t,h);let y=h.get(c);if(!y){y=new Map;for(let f of t)if(f!=null&&typeof f==="object"){let b=f[c];if(b!=null)y.set(P(b),f)}h.set(c,y)}return y.get(P(d))}case"dot":{if(t==null||typeof t!=="object"||typeof a!=="string")return;return t[a]}case"length":return Array.isArray(t)?t.length:typeof t==="string"?t.length:0;case"upper":return typeof t==="string"?t.toUpperCase():t;case"lower":return typeof t==="string"?t.toLowerCase():t;case"truncate":if(typeof t==="string"&&typeof a==="number")return t.slice(0,a);return t;case"join":return Array.isArray(t)?t.join(typeof a==="string"?a:", "):t;case"first":return Array.isArray(t)?t[0]:t;case"last":return Array.isArray(t)?t[t.length-1]:t;case"abs":return Math.abs(Number(t));case"round":return typeof a==="number"?Number(Number(t).toFixed(a)):Math.round(Number(t));case"number":return typeof a==="number"?Number(Number(t).toFixed(a)):Number(t);case"currency":{let l=typeof a==="string"?a:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:l}).format(Number(t))}catch{return t}}case"percent":return typeof a==="number"?`${(Number(t)*100).toFixed(a)}%`:`${Math.round(Number(t)*100)}%`;case"compact":{let l=typeof a==="number"?a:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:l}).format(Number(t))}catch{return t}}case"date":try{return new Date(t).toLocaleDateString()}catch{return t}case"time":try{return new Date(t).toLocaleTimeString()}catch{return t}case"datetime":try{return new Date(t).toLocaleString()}catch{return t}case"pluralize":{let l=Number(t),c=typeof a==="string"?a:"";return l===1?c:`${c}s`}case"default":return t==null||t===""?a:t;case"selectattr":return Array.isArray(t)&&typeof a==="string"?t.filter((l)=>l!=null&&typeof l==="object"&&Boolean(l[a])):t;case"rejectattr":return Array.isArray(t)&&typeof a==="string"?t.filter((l)=>{if(l==null||typeof l!=="object")return!1;let c=l[a];return c==null||c===!1||c===0||c===""}):t;default:{let l=ke(i);if(l){let c=s?jt(s).map(Ze):[];return l(t,...c)}return t}}}var Vn=[["!==",(e,t)=>e!==t],["===",(e,t)=>e===t],["!=",(e,t)=>e!=t],["==",(e,t)=>e==t],[">=",(e,t)=>Number(e)>=Number(t)],["<=",(e,t)=>Number(e)<=Number(t)],[">",(e,t)=>Number(e)>Number(t)],["<",(e,t)=>Number(e)<Number(t)]],Kn=[[" + ",(e,t)=>e+t],[" - ",(e,t)=>e-t],[" * ",(e,t)=>e*t],[" / ",(e,t)=>t!==0?e/t:0],[" % ",(e,t)=>t!==0?e%t:0]];function Se(e,t){let n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n&&e.slice(r,r+t.length)===t)return r}return-1}function Gn(e){let t=0,n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n){if(o==="(")t++;else if(o===")")t--;else if(o==="?"&&t===0)return r}}return-1}function qn(e){let t=0,n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n){if(o==="?"||o==="(")t++;else if(o===")")t--;else if(o===":"&&t===0)return r}}return-1}function Un(e){let t=[],n="",r=null;for(let o=0;o<e.length;o++){let i=e[o];if(i==="'"||i==='"')r=r===i?null:r??i;if(i==="|"&&!r)if(e[o+1]==="|")n+="||",o++;else t.push(n),n="";else n+=i}return t.push(n),t}function Ze(e){let t=e.replace(/^['"]|['"]$/g,"");if(t==="true")return!0;if(t==="false")return!1;let n=Number(t);return isNaN(n)?t:n}function jt(e){let t=[],n="",r=null;for(let o of e){if(o==="'"||o==='"')r=r===o?null:r??o;if(o===","&&!r)t.push(n),n="";else n+=o}return t.push(n),t}function Ee(e,t){if(!t)return e;let n=t.split("."),r=e;for(let o of n){if(r==null||typeof r!=="object")return;r=r[o]}return r}function Xn(e,t){let n=0,r=0;while((r=e.indexOf(t,r))!==-1)n++,r+=t.length;return n}function Ae(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function et(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:Ae(n);if(Array.isArray(r))t[o]=r.map((i)=>i!=null&&typeof i==="object"&&!Array.isArray(i)?et(i):i);else if(r!=null&&typeof r==="object"&&!Array.isArray(r))t[o]=et(r);else t[o]=r}return t}async function j(e,t){let n=Array.isArray(e)?e:[e];for(let r of n)await Yn(r,t)}function F(e,t){e.catch((n)=>O.error(`${t} failed:`,n))}async function Ne(e,t,n,r){if(n!=null)O.debug(`${e} failed:`,t),await de(n,r,{$error:t});else O.warn(`${e} failed:`,t)}async function Yn(e,t){let n=et(e),r=n.action;switch(r){case"setState":{Zn(n,t);return}case"toggleState":{Qn(n,t);return}case"appendState":{er(n,t);return}case"popState":{tr(n,t);return}case"showToast":{nr(n,t);return}case"closeOverlay":{rr(n,t);return}case"openLink":{or(n);return}case"setInterval":{sr(n,t);return}case"toolCall":case"callTool":return ar(n,t);case"sendMessage":return lr(n,t);case"updateContext":{dr(n,t);return}case"fetch":return cr(n,t);case"openFilePicker":{pr(n,t);return}case"callHandler":return ur(n,t);case"requestDisplayMode":{fr(n,t);return}case"subscribe":{hr(n,t);return}case"unsubscribe":{br(n);return}default:O.warn(`Unknown action: ${r}`)}}function Zn(e,t){let{key:n,value:r}=e;if(Q(r))r=ee(r,t.store,t.scope);t.store.set(n,r),t.rerender(),de(e.onSuccess,t)}function Qn(e,t){t.store.toggle(e.key),t.rerender()}function er(e,t){let n=e.value??e.item;if(Q(n))n=ee(n,t.store,t.scope);t.store.append(e.key,n,e.index),t.rerender()}function tr(e,t){t.store.pop(e.key,e.index),t.rerender()}function nr(e,t){t.onToast?.({message:Te(e.message,t),description:e.description!=null?Te(e.description,t):void 0,variant:e.variant,duration:e.duration})}function rr(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function or(e){if(typeof window<"u"){let t=e.url;if(!t){O.warn("openLink: missing url");return}if(!Jt(t)){O.warn(`Blocked unsafe URL scheme: ${t}`);return}window.open(t,e.target??"_blank")}}var Re=new Set,ir=20,It=100;function sr(e,t){let n=Math.max(e.intervalMs,It),r=e.onTick;if(typeof globalThis.setInterval!=="function")return;if(Re.size>=ir){O.warn("Max intervals reached, ignoring new setInterval");return}let o=globalThis.setInterval(()=>F(j(r,t),"interval action"),n);Re.add(o)}function Ft(){for(let e of Re)globalThis.clearInterval(e);Re.clear()}async function ar(e,t){if(!t.transport){O.warn("No MCP transport configured for toolCall");return}let n=e.tool,r=tt(e.arguments,t);try{let o=await t.transport.callTool(n,r);if(e.resultKey!=null)t.store.set(e.resultKey,o);let i=Me(o);if(i&&t.remount)t.remount(i);else Le(o,t),t.rerender();await de(e.onSuccess,t,{$result:o})}catch(o){await Ne("toolCall",o,e.onError,t)}}async function lr(e,t){if(!t.transport){O.warn("No MCP transport configured for sendMessage");return}await t.transport.sendMessage(Te(e.message,t))}function dr(e,t){let n=e.context;if(n!=null)t.store.merge(n),t.rerender()}async function cr(e,t){let n=Te(e.url,t);if(!Jt(n)){O.warn(`Blocked unsafe URL in fetch: ${n}`);return}let r=e.method??"GET",o=e.headers,i=e.body!==void 0?JSON.stringify(e.body):void 0;try{let s=await globalThis.fetch(n,{method:r,headers:{"Content-Type":"application/json",...o},...i&&{body:i}}),a=await s.json().catch(()=>s.text());if(e.resultKey!=null)t.store.set(e.resultKey,a);let l=Me(a);if(l&&t.remount)t.remount(l);else Le(a,t),t.rerender();await de(e.onSuccess,t,{$result:a})}catch(s){await Ne("fetch",s,e.onError,t)}}function pr(e,t){if(typeof document>"u")return;let n=document.createElement("input");if(n.type="file",e.accept!=null)n.accept=e.accept;if(e.multiple===!0)n.multiple=!0;n.addEventListener("change",()=>{let r=Array.from(n.files??[]);if(e.resultKey!=null)t.store.set(e.resultKey,r);t.rerender(),de(e.onSuccess,t,{$result:r})}),n.click()}async function ur(e,t){let n=e.handler,r=tt(e.arguments,t);if(!t.transport){O.warn(`No transport configured for callHandler: ${n}`);return}try{let o=await t.transport.callTool(n,r);if(e.resultKey!=null)t.store.set(e.resultKey,o);let i=Me(o);if(i&&t.remount)t.remount(i);else Le(o,t),t.rerender();await de(e.onSuccess,t,{$result:o})}catch(o){await Ne("callHandler",o,e.onError,t)}}function fr(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:e.mode}}))}var ie=new Map,mr=50,gr=2000;function hr(e,t){let{uri:n,stateKey:r}=e;if(!n||!r){O.warn("subscribe: missing uri or stateKey");return}if(ie.has(n))return;if(ie.size>=mr){O.warn("Max subscriptions reached, ignoring new subscribe");return}let o=(d)=>{let g=Me(d);if(g&&t.remount)t.remount(g);else{if(!Le(d,t))t.store.set(r,d);t.rerender()}de(e.onData,t,{$data:d})};if(t.transport?.subscribe&&t.transport.capabilities?.subscriptions){let d=t.transport.subscribe(n,o);ie.set(n,d);return}let i=e.fallbackTool,s=e.fallbackInterval??gr;if(!i){O.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!t.transport){O.warn("No MCP transport configured for subscribe fallback");return}let a=e.fallbackArgs??{},l=Math.max(s,It),c=t.transport,u=globalThis.setInterval(()=>{(async()=>{try{let d=tt(a,t),g=await c.callTool(i,d);o(g)}catch(d){Ne("subscribe",d,e.onError,t)}})()},l);ie.set(n,()=>globalThis.clearInterval(u))}function br(e){let t=e.uri;if(!t){O.warn("unsubscribe: missing uri");return}let n=ie.get(t);if(n)n(),ie.delete(t)}function Bt(){for(let[e,t]of ie)try{t()}catch(n){O.warn(`Error cleaning up subscription '${e}':`,n)}ie.clear()}function Me(e){if(e==null||typeof e!=="object")return null;let t=e;if("$prefab"in t&&"view"in t)return t;if("structuredContent"in t){let n=t.structuredContent;if(n!=null&&typeof n==="object"){let r=n;if("$prefab"in r&&"view"in r)return r}}if("content"in t&&Array.isArray(t.content)){for(let n of t.content)if(n.type==="text"&&typeof n.text==="string")try{let r=JSON.parse(n.text);if(r!=null&&typeof r==="object"){let o=r;if("$prefab"in o&&"view"in o)return o}}catch{}}return null}function yr(e){if(e==null||typeof e!=="object")return null;let t=e;if(Qe(t))return t;if("structuredContent"in t){let n=t.structuredContent;if(n!=null&&typeof n==="object"&&Qe(n))return n}if("content"in t&&Array.isArray(t.content)){for(let n of t.content)if(n.type==="text"&&typeof n.text==="string")try{let r=JSON.parse(n.text);if(r!=null&&typeof r==="object"&&Qe(r))return r}catch{}}return null}function Qe(e){if(!("$prefab"in e)||!("update"in e))return!1;let t=e.update;return t!=null&&typeof t==="object"&&"state"in t}function Le(e,t){let n=yr(e);if(!n)return!1;let r=n.update;if(t.store.merge(r.state),r.actions!=null)F(j(r.actions,t),"update action");return!0}var Cr=/^\s*(javascript|vbscript|data):/i;function Jt(e){return!Cr.test(e)}function Te(e,t){if(Q(e)){let n=ee(e,t.store,t.scope);return P(n)}return P(e)}function tt(e,t){if(!e)return{};let n={};for(let[r,o]of Object.entries(e))n[r]=Q(o)?ee(o,t.store,t.scope):o;return n}async function de(e,t,n){if(e==null)return;let r={...t.scope,...n};await j(e,{...t,scope:r})}function rt(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:Ae(n);if(Array.isArray(r))t[o]=r.map((i)=>i!=null&&typeof i==="object"&&!Array.isArray(i)?rt(i):i);else if(r!=null&&typeof r==="object"&&!Array.isArray(r))t[o]=rt(r);else t[o]=r}return t}class ot{callbacks=[];track(e){this.callbacks.push(e)}flush(){for(let e of this.callbacks)try{e()}catch(t){O.warn("destroy callback error:",t)}this.callbacks=[]}get size(){return this.callbacks.length}}function vr(e){return typeof e==="object"&&"element"in e}var He=new Map;function p(e,t){if(He.has(e))O.warn(`overriding existing renderer for "${e}"`);He.set(e,t)}function it(){return[...He.keys()].sort()}var zt=new Set;function _t(e){zt.clear();for(let t of e)zt.add(t)}function J(e,t){let n=rt(e);if(t.defs?.[n.type]){let i={...t.defs[n.type],...n,type:t.defs[n.type].type};return J(i,t)}let r=He.get(n.type),o;if(r){let i=r(n,t);if(vr(i))o=i.element,t.destroyRegistry?.track(i.destroy);else o=i}else if(o=document.createElement("div"),o.setAttribute("data-prefab-type",n.type),n.children)for(let i of n.children)o.appendChild(J(i,t));if(o instanceof HTMLElement){if(n.id)o.id=n.id;if(n.cssClass){let i=C(n.cssClass,t);if(i)o.className=(o.className?o.className+" ":"")+i}if(n.onClick!=null){if(o.addEventListener("click",()=>{F(j(n.onClick,V(t)),"onClick")}),o.tagName!=="BUTTON"&&o.tagName!=="A")o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.addEventListener("keydown",(i)=>{let s=i.key;if(s==="Enter"||s===" ")i.preventDefault(),F(j(n.onClick,V(t)),"onClick")})}}if(n.onMount){let i=n.onMount,s=V(t);queueMicrotask(()=>F(j(i,s),"onMount"))}return o}function H(e,t,n){if(!e.children)return;se(e.children,t,n)}function se(e,t,n){let r=0;while(r<e.length){let o=e[r];if(o.type==="If")r=wr(e,r,t,n);else if(o.type==="Elif"||o.type==="Else")r++;else t.appendChild(J(o,n)),r++}}function wr(e,t,n,r){let o=!1,i=t,s=e[i];if(Wt(s.condition,r))nt(s,n,r),o=!0;i++;while(i<e.length){let a=e[i];if(a.type==="Elif"){if(!o&&Wt(a.condition,r))nt(a,n,r),o=!0;i++}else if(a.type==="Else"){if(!o)nt(a,n,r);i++;break}else break}return i}function Wt(e,t){if(!e)return!1;if(Q(e))return Boolean(ee(e,t.store,t.scope));return Boolean(t.store.get(e))}function nt(e,t,n){if(!e.children)return;se(e.children,t,n)}function C(e,t){if(Q(e)){let n=ee(e,t.store,t.scope);return P(n)}return P(e)}function K(e,t){if(Q(e))return ee(e,t.store,t.scope);return e}function V(e){return{store:e.store,transport:e.transport,scope:e.scope,rerender:e.rerender,onToast:e.onToast,remount:e.remount}}function m(e,t){let n=document.createElement(e);if(t)n.className=t;return n}function st(e,t){return e.textContent=t,e}function qt(){p("Column",xr),p("Row",kr),p("Grid",Vt),p("GridItem",Kt),p("Container",Sr),p("Div",Gt),p("Span",Er),p("Dashboard",Vt),p("DashboardItem",Kt),p("Pages",Ar),p("Page",Gt),p("Detail",Rr),p("MasterDetail",Tr)}function xr(e,t){let n=m("div","pf-column");n.style.display="flex",n.style.flexDirection="column";let r=Pe(e);if(r!=null)n.style.gap=`${r*4}px`;if(e.align!=null)n.style.alignItems=Ut(e.align);if(e.justify!=null)n.style.justifyContent=Xt(e.justify);return H(e,n,t),n}function kr(e,t){let n=m("div","pf-row");n.style.display="flex",n.style.flexDirection="row";let r=Pe(e);if(r!=null)n.style.gap=`${r*4}px`;if(e.align!=null)n.style.alignItems=Ut(e.align);if(e.justify!=null)n.style.justifyContent=Xt(e.justify);if(e.wrap===!0)n.style.flexWrap="wrap";return H(e,n,t),n}function Vt(e,t){let n=m("div","pf-grid");n.style.display="grid";let r=e.columns??3;n.style.gridTemplateColumns=`repeat(${r}, 1fr)`;let o=Pe(e);if(o!=null)n.style.gap=`${o*4}px`;return H(e,n,t),n}function Kt(e,t){let n=m("div","pf-grid-item");if(e.colSpan!=null)n.style.gridColumn=`span ${e.colSpan}`;if(e.rowSpan!=null)n.style.gridRow=`span ${e.rowSpan}`;return H(e,n,t),n}function Sr(e,t){let n=m("div","pf-container");if(n.style.maxWidth=e.maxWidth??"1200px",n.style.margin="0 auto",e.padding!=null)n.style.padding=`${e.padding*4}px`;return H(e,n,t),n}function Gt(e,t){let n=m("div","pf-div");return H(e,n,t),n}function Er(e,t){let n=m("span","pf-span");return H(e,n,t),n}function Ar(e,t){let n=m("div","pf-pages");return H(e,n,t),n}function Rr(e,t){let n=m("div","pf-detail"),r=e.of!=null?K(e.of,t):void 0;if(r!=null&&r!==""&&r!==!1&&r!==0)H(e,n,t);else if(e.empty!=null){let o=e.empty;n.appendChild(J(o,t))}return n}function Tr(e,t){let n=m("div","pf-master-detail");n.style.display="flex",n.style.flexDirection="row";let r=Pe(e);if(r!=null)n.style.gap=`${r*4}px`;let o=e.masterWidth??"33%",i=e.children??[];if(i.length>0){let s=m("div","pf-master-detail-master");s.style.width=o,s.style.flexShrink="0",s.style.overflow="auto",s.appendChild(J(i[0],t)),n.appendChild(s)}if(i.length>1){let s=m("div","pf-master-detail-detail");s.style.flex="1",s.style.overflow="auto",s.appendChild(J(i[1],t)),n.appendChild(s)}return n}var Nr=/\bgap-(\d+)\b/;function Pe(e){if(e.gap!=null)return e.gap;if(typeof e.cssClass==="string"){let t=Nr.exec(e.cssClass);if(t)return Number(t[1])}return null}function Ut(e){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[e]??e}function Xt(e){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[e]??e}var Mr={"&":"&","<":"<",">":">",'"':""","'":"'"};function Ce(e){return e.replace(/[&<>"']/g,(t)=>Mr[t]??t)}function Zt(){p("Heading",Lr),p("H1",(e,t)=>$e(e,t,"h1")),p("H2",(e,t)=>$e(e,t,"h2")),p("H3",(e,t)=>$e(e,t,"h3")),p("H4",(e,t)=>$e(e,t,"h4")),p("Text",Hr),p("P",Pr),p("Lead",(e,t)=>ge(e,t,"p","pf-lead")),p("Large",(e,t)=>ge(e,t,"span","pf-large")),p("Small",(e,t)=>ge(e,t,"small","pf-small")),p("Muted",(e,t)=>ge(e,t,"p","pf-muted")),p("BlockQuote",(e,t)=>ge(e,t,"blockquote","pf-blockquote")),p("Label",(e,t)=>ge(e,t,"label","pf-label")),p("Link",Or),p("Code",Dr),p("Markdown",jr),p("Kbd",Ir)}function Lr(e,t){let n=e.level??2,r=`h${Math.min(Math.max(n,1),6)}`,o=document.createElement(r);return o.className=`pf-heading pf-${r}`,o.textContent=C(e.content,t),o}function $e(e,t,n){let r=document.createElement(n);return r.className=`pf-heading pf-${n}`,r.textContent=C(e.content,t),r}function Hr(e,t){return st(m("span","pf-text"),C(e.content,t))}function Pr(e,t){return st(m("p","pf-p"),C(e.content,t))}function ge(e,t,n,r){let o=document.createElement(n);return o.className=r,o.textContent=C(e.content,t),o}var $r=/^\s*(javascript|vbscript|data):/i;function Or(e,t){let n=document.createElement("a");if(n.className="pf-link",n.textContent=C(e.content,t),e.href!=null){let r=C(e.href,t);if(!$r.test(r))n.href=r}if(e.target!=null)n.target=C(e.target,t);return n}function Dr(e,t){let n=m("pre","pf-code"),r=m("code");if(r.textContent=C(e.content,t),e.language!=null)r.setAttribute("data-language",e.language);return n.appendChild(r),n}function jr(e,t){let n=m("div","pf-markdown"),r=C(e.content,t);return n.innerHTML=Qt(r),n.setAttribute("data-markdown","true"),n}var Yt=/^\s*(javascript|vbscript|data):/i;function Oe(e){let t=Ce(e),n=[];return t=t.replace(/`([^`]+)`/g,(r,o)=>(n.push(`<code>${o}</code>`),`CODE${n.length-1}`)),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(r,o,i)=>{if(Yt.test(i))return Ce(o);return`<img src="${i}" alt="${o}" />`}),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,o,i)=>{if(Yt.test(i))return o;return`<a href="${i}">${o}</a>`}),t=t.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),t=t.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),t=t.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),t=t.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),t=t.replace(/\*(.+?)\*/g,"<em>$1</em>"),t=t.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),t=t.replace(/~~(.+?)~~/g,"<del>$1</del>"),t=t.replace(/\uFDD0CODE(\d+)\uFDD0/g,(r,o)=>n[parseInt(o)]),t}function Qt(e){let t=e.replace(/\r\n?/g,`
|
|
2
2
|
`).split(`
|
|
3
|
-
`),
|
|
4
|
-
`)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(
|
|
5
|
-
`))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(
|
|
6
|
-
`)}function f8($,Z){let J=document.createElement("kbd");return J.className="pf-kbd",J.textContent=F($.content,Z),J}function a0(){X("Card",C8),X("CardHeader",Q0("pf-card-header")),X("CardTitle",r0("pf-card-title","h3")),X("CardDescription",r0("pf-card-description","p")),X("CardContent",Q0("pf-card-content")),X("CardFooter",Q0("pf-card-footer"))}function C8($,Z){let J=N("div","pf-card");return J.style.overflow="hidden",C($,J,Z),J}function Q0($){return(Z,J)=>{let q=N("div",$);return q.style.padding="16px 24px",C(Z,q,J),q}}function r0($,Z){return(J,q)=>{let Q=document.createElement(Z);return Q.className=$,Q.textContent=F(J.content,q),Q}}function o0(){X("DataTable",w8),X("Badge",b8),X("Dot",y8),X("Metric",m8),X("Ring",h8),X("Progress",v8),X("Separator",g8),X("Loader",u8),X("Icon",x8),X("Sparkline",p8)}function w8($,Z){let J=N("div","pf-datatable-wrapper"),q=document.createElement("table");q.className="pf-datatable",q.style.width="100%",q.style.borderCollapse="collapse";let Q=$.columns??[],Y=d($.rows,Z),U=$.rowKey,H=$.selected,G=document.createElement("thead"),_=document.createElement("tr");for(let W of Q){let B=document.createElement("th");B.className="pf-datatable-th",B.textContent=W.header??W.key,B.style.padding="8px 12px",B.style.textAlign="left",_.appendChild(B)}G.appendChild(_),q.appendChild(G);let z=document.createElement("tbody");if(Array.isArray(Y)){let W=H!=null?d(H,Z):void 0;for(let B of Y){let K=document.createElement("tr");K.className="pf-datatable-row";let L=B,M=B===null||typeof B!=="object";if(U&&W!=null&&L[U]!=null&&w(L[U])===w(W))K.classList.add("pf-datatable-row-selected");if($.onRowClick!=null&&U)K.style.cursor="pointer",K.addEventListener("click",()=>{let E={...Z.scope,$item:L,$index:Y.indexOf(B)},T=l({...Z,scope:E});v(h($.onRowClick,T),"onRowClick")});for(let E of Q){let T=document.createElement("td");T.className="pf-datatable-td";let V;if(E.accessor)V=d(`{{ $item.${E.accessor} }}`,{...Z,scope:{...Z.scope,$item:L}});else if(V=M?B:L[E.key],E.format&&V!=null)V=d(`{{ __fmtVal | ${E.format} }}`,{...Z,scope:{...Z.scope,__fmtVal:V}});T.textContent=w(V),T.style.padding="8px 12px",K.appendChild(T)}z.appendChild(K)}}if(q.appendChild(z),$.search===!0){let W=document.createElement("input");W.type="text",W.placeholder="Search...",W.className="pf-datatable-search",W.style.marginBottom="8px",W.style.padding="6px 12px",W.style.width="100%",W.style.boxSizing="border-box",W.addEventListener("input",()=>{let B=W.value.toLowerCase(),K=Array.from(z.querySelectorAll("tr"));for(let L of K){let M=(L.textContent??"").toLowerCase();L.style.display=M.includes(B)?"":"none"}}),J.appendChild(W)}return J.appendChild(q),J}function b8($,Z){let J=N("span","pf-badge"),q=$.variant??"default";return J.setAttribute("data-variant",q),J.style.alignItems="center",J.style.padding="2px 10px",J.style.borderRadius="9999px",J.style.fontSize="12px",J.style.fontWeight="500",J.textContent=F($.label??$.content,Z),c8(J,q),J}function y8($,Z){let J=N("span","pf-dot"),q=$.color??"gray";return J.style.display="inline-block",J.style.width="8px",J.style.height="8px",J.style.borderRadius="50%",J.style.backgroundColor=q,J}function m8($,Z){let J=N("div","pf-metric"),q=N("div","pf-metric-label");q.textContent=F($.label,Z),q.style.fontSize="14px",J.appendChild(q);let Q=N("div","pf-metric-value");if(Q.textContent=F($.value,Z),Q.style.fontSize="28px",Q.style.fontWeight="700",J.appendChild(Q),$.delta!=null){let Y=N("span","pf-metric-delta");Y.textContent=F($.delta,Z);let U=$.trend??"",H=$.trendSentiment??"neutral";if(Y.style.fontSize="14px",Y.style.color=H==="positive"?"green":H==="negative"?"red":"inherit",U==="up")Y.textContent="↑ "+Y.textContent;else if(U==="down")Y.textContent="↓ "+Y.textContent;J.appendChild(Y)}if($.description!=null){let Y=N("div","pf-metric-desc");Y.textContent=F($.description,Z),Y.style.fontSize="12px",J.appendChild(Y)}return J}function h8($,Z){let J=N("div","pf-ring"),q=$.size??80,Q=$.thickness??8,Y=Number(d($.value,Z)??0),U=Math.max(0,Math.min(100,Y)),H=(q-Q)/2,G=2*Math.PI*H,_=G*(1-U/100),z=document.createElementNS("http://www.w3.org/2000/svg","svg");z.setAttribute("width",String(q)),z.setAttribute("height",String(q)),z.setAttribute("viewBox",`0 0 ${q} ${q}`);let W=document.createElementNS("http://www.w3.org/2000/svg","circle");W.setAttribute("cx",String(q/2)),W.setAttribute("cy",String(q/2)),W.setAttribute("r",String(H)),W.setAttribute("fill","none"),W.setAttribute("stroke","var(--muted, #e5e7eb)"),W.setAttribute("stroke-width",String(Q));let B=document.createElementNS("http://www.w3.org/2000/svg","circle");if(B.setAttribute("cx",String(q/2)),B.setAttribute("cy",String(q/2)),B.setAttribute("r",String(H)),B.setAttribute("fill","none"),B.setAttribute("stroke","var(--primary, #3b82f6)"),B.setAttribute("stroke-width",String(Q)),B.setAttribute("stroke-dasharray",String(G)),B.setAttribute("stroke-dashoffset",String(_)),B.setAttribute("stroke-linecap","round"),B.style.transform="rotate(-90deg)",B.style.transformOrigin="center",z.appendChild(W),z.appendChild(B),J.appendChild(z),$.label!=null){let K=N("div","pf-ring-label");K.textContent=F($.label,Z),K.style.textAlign="center",K.style.fontSize="12px",J.appendChild(K)}return J}function v8($,Z){let J=N("div","pf-progress");J.setAttribute("role","progressbar");let q=Number(d($.value,Z)??0),Q=$.max??100,Y=Q>0?Math.max(0,Math.min(100,q/Q*100)):0;J.setAttribute("aria-valuenow",String(q)),J.setAttribute("aria-valuemin","0"),J.setAttribute("aria-valuemax",String(Q)),J.style.height="8px",J.style.borderRadius="4px",J.style.overflow="hidden";let U=N("div","pf-progress-fill");return U.style.height="100%",U.style.width=`${Y}%`,U.style.borderRadius="4px",U.style.transition="width 0.3s ease",J.appendChild(U),J}function g8($,Z){let J=document.createElement("hr");return J.className="pf-separator",J.style.border="none",J.style.margin="8px 0",J}function u8($,Z){let J=N("div","pf-loader");return J.textContent="⏳",J.style.display="flex",J.style.justifyContent="center",J.style.padding="16px",J}function x8($,Z){let J=N("span","pf-icon");return J.setAttribute("data-icon",F($.name??$.content,Z)),J}function p8($,Z){let J=N("div","pf-sparkline"),q=$.data??[];if(q.length===0)return J;let Q=120,Y=32,U=Math.max(...q),H=Math.min(...q),G=U-H||1,_=document.createElementNS("http://www.w3.org/2000/svg","svg");_.setAttribute("width",String(Q)),_.setAttribute("height",String(Y)),_.setAttribute("viewBox",`0 0 ${Q} ${Y}`);let z=q.length>1?q.length-1:1,W=q.map((K,L)=>{let M=L/z*Q,E=Y-(K-H)/G*(Y-4)-2;return`${M},${E}`}).join(" "),B=document.createElementNS("http://www.w3.org/2000/svg","polyline");return B.setAttribute("points",W),B.setAttribute("fill","none"),B.setAttribute("stroke","var(--primary, #3b82f6)"),B.setAttribute("stroke-width","1.5"),_.appendChild(B),J.appendChild(_),J}function c8($,Z){let q={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[Z];if(q)$.style.backgroundColor=q.bg,$.style.color=q.fg}function e0(){X("Form",d8),X("Input",l8),X("Textarea",i8),X("Button",s8),X("ButtonGroup",n8),X("Select",r8),X("SelectOption",a8),X("SelectGroup",w1("pf-select-group")),X("SelectLabel",L1("pf-select-label")),X("SelectSeparator",t0),X("Checkbox",o8),X("Switch",t8),X("Slider",e8),X("Radio",Z6),X("RadioGroup",J6),X("Combobox",q6),X("ComboboxOption",Q6),X("ComboboxGroup",w1("pf-combobox-group")),X("ComboboxLabel",L1("pf-combobox-label")),X("ComboboxSeparator",t0),X("Calendar",Y6),X("DatePicker",U6),X("Field",w1("pf-field")),X("FieldTitle",L1("pf-field-title")),X("FieldDescription",L1("pf-field-description")),X("FieldContent",w1("pf-field-content")),X("FieldError",L1("pf-field-error")),X("ChoiceCard",H6)}function d8($,Z){let J=document.createElement("form");return J.className="pf-form",J.addEventListener("submit",(q)=>{q.preventDefault();let Q=new FormData(J),Y={};if(Q.forEach((U,H)=>{Y[H]=U}),Z.store.merge(Y),$.onSubmit!=null){let U=l(Z);U.scope={...Z.scope,...Y},v(h($.onSubmit,U),"onSubmit")}}),C($,J,Z),J}function l8($,Z){let J=N("div","pf-input-wrapper");if(J.style.display="flex",J.style.flexDirection="column",J.style.gap="4px",$.label!=null){let Y=document.createElement("label");if(Y.className="pf-input-label",Y.textContent=F($.label,Z),$.name!=null)Y.htmlFor=$.name;Y.style.fontSize="14px",Y.style.fontWeight="500",J.appendChild(Y)}let q=document.createElement("input");if(q.className="pf-input",q.type=$.inputType??"text",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-input-${$.name}`;if($.placeholder!=null)q.placeholder=F($.placeholder,Z);if($.required===!0)q.required=!0,q.setAttribute("aria-required","true");if($.error!=null)q.setAttribute("aria-invalid","true");let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=w(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return Y0(q),J.appendChild(q),J}function i8($,Z){let J=N("div","pf-textarea-wrapper"),q=document.createElement("textarea");if(q.className="pf-textarea",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-textarea-${$.name}`;if($.placeholder!=null)q.placeholder=F($.placeholder,Z);if($.rows!=null)q.rows=$.rows;if($.required===!0)q.setAttribute("aria-required","true");let Q=$.name;if(Q!=null){let Y=Z.store.get(Q);if(Y!=null)q.value=w(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return Y0(q),J.appendChild(q),J}function s8($,Z){let J=document.createElement("button");J.className="pf-button",J.type=$.submit===!0?"submit":"button",J.textContent=F($.label,Z);let q=$.variant??"default";if(J.setAttribute("data-variant",q),$6(J,q),$.size!=null)J.setAttribute("data-size",$.size);if($.disabled===!0)J.disabled=!0;return J}function n8($,Z){let J=N("div","pf-button-group");return J.style.display="flex",J.style.gap="8px",C($,J,Z),J}function r8($,Z){let J=N("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(Y0(q),$.placeholder!=null){let U=document.createElement("option");U.value="",U.textContent=F($.placeholder,Z),U.disabled=!0,U.selected=!0,U.hidden=!0,q.appendChild(U)}let Q=$.options;if(Array.isArray(Q))for(let U of Q){let H=document.createElement("option");H.value=U.value??"",H.textContent=U.label??H.value,q.appendChild(H)}if($.children)for(let U of $.children)if(U.type==="SelectOption"){let H=document.createElement("option");H.value=U.value??"",H.textContent=U.label??H.value,q.appendChild(H)}else q.appendChild(u(U,Z));let Y=$.name;if(Y){let U=Z.store.get(Y);if(U!=null)q.value=w(U);q.addEventListener("change",()=>{if(Z.store.set(Y,q.value),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return J.appendChild(q),J}function a8($,Z){return N("span")}function o8($,Z){let J=N("label","pf-checkbox-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-checkbox",$.name!=null)q.name=$.name;if($.checked===!0)q.checked=!0;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.checked}}),"onChange")})}if(J.appendChild(q),$.label!=null){let Y=N("span");Y.textContent=F($.label,Z),J.appendChild(Y)}return J}function t8($,Z){let J=N("label","pf-switch-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-switch",q.setAttribute("role","switch"),$.name!=null)q.name=$.name;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.checked}}),"onChange")})}if(J.appendChild(q),$.label!=null){let Y=N("span");Y.textContent=F($.label,Z),J.appendChild(Y)}return J}function e8($,Z){let J=N("div","pf-slider-wrapper"),q=document.createElement("input");if(q.type="range",q.className="pf-slider",$.name!=null)q.name=$.name;if($.min!=null)q.min=w($.min);if($.max!=null)q.max=w($.max);if($.step!=null)q.step=w($.step);let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=w(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,Number(q.value)),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:Number(q.value)}}),"onChange")})}return J.appendChild(q),J}function Y0($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function $6($,Z){if($.style.padding="8px 16px",$.style.fontSize="14px",$.style.fontWeight="500",$.style.cursor="pointer",$.style.border="none",Z==="ghost")$.style.backgroundColor="transparent",$.style.color="inherit"}function w1($){return(Z,J)=>{let q=N("div",$);return C(Z,q,J),q}}function L1($){return(Z,J)=>{let q=N("span",$);return q.textContent=F(Z.content,J),q}}function t0(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function Z6($,Z){let J=N("label","pf-radio");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="radio",q.value=F($.value,Z),J.appendChild(q),$.label!=null){let Q=N("span","pf-radio-label");Q.textContent=F($.label,Z),J.appendChild(Q)}return J}function J6($,Z){let J=N("fieldset","pf-radio-group");if(J.style.border="none",J.style.padding="0",J.style.display="flex",J.style.flexDirection="column",J.style.gap="8px",$.label!=null){let Y=document.createElement("legend");Y.textContent=F($.label,Z),Y.style.fontWeight="500",Y.style.marginBottom="4px",J.appendChild(Y)}C($,J,Z);let q=F($.name,Z),Q=Z.store.get(q);for(let Y of Array.from(J.querySelectorAll('input[type="radio"]')))if(Y.name=q,Q!=null&&Y.value===w(Q))Y.checked=!0;return J.addEventListener("change",(Y)=>{let U=Y.target;if(U.type==="radio"){if(Z.store.set(q,U.value),$.onChange!=null)v(h($.onChange,l(Z)),"onChange")}}),J}function q6($,Z){let J=N("div","pf-combobox"),q=document.createElement("input");if(q.className="pf-combobox-input",q.type="text",q.name=F($.name,Z),$.placeholder!=null)q.placeholder=F($.placeholder,Z);if($.value!==void 0)q.value=F($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=w(Y);q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box";let U=N("div","pf-combobox-dropdown");if(U.style.display="none",U.style.position="absolute",U.style.borderRadius="6px",U.style.maxHeight="200px",U.style.overflowY="auto",U.style.zIndex="50",C($,U,Z),q.addEventListener("focus",()=>{U.style.display="block"}),q.addEventListener("blur",()=>{setTimeout(()=>{U.style.display="none"},150)}),$.searchable!==!1)q.addEventListener("input",()=>{let H=q.value.toLowerCase();for(let G of Array.from(U.querySelectorAll(".pf-combobox-option"))){let _=(G.textContent??"").toLowerCase();G.style.display=_.includes(H)?"":"none"}});if($.onChange!=null)J.addEventListener("pf-combobox-select",()=>{v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.value}}),"onChange")});return J.style.position="relative",J.appendChild(q),J.appendChild(U),J}function Q6($,Z){let J=N("div","pf-combobox-option");return J.style.padding="6px 12px",J.style.cursor="pointer",J.textContent=F($.label??$.value,Z),J.dataset.value=F($.value,Z),J.addEventListener("mousedown",()=>{let q=J.closest(".pf-combobox"),Q=q?.querySelector("input");if(Q)Q.value=J.dataset.value??"",Z.store.set(Q.name,Q.value),q?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),J}function Y6($,Z){let J=N("div","pf-calendar"),q=document.createElement("input");if(q.type="date",q.name=F($.name,Z),$.value!==void 0)q.value=F($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=w(Y);if($.minDate!=null)q.min=F($.minDate,Z);if($.maxDate!=null)q.max=F($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)v(h($.onChange,l(Z)),"onChange")}),J.appendChild(q),J}function U6($,Z){let J=N("div","pf-datepicker"),q=document.createElement("input");if(q.type="date",q.name=F($.name,Z),$.placeholder!=null)q.placeholder=F($.placeholder,Z);if($.value!==void 0)q.value=F($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=w(Y);if($.minDate!=null)q.min=F($.minDate,Z);if($.maxDate!=null)q.max=F($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)v(h($.onChange,l(Z)),"onChange")}),J.appendChild(q),J}function H6($,Z){let J=N("div","pf-choice-card");if(J.style.padding="16px",J.style.cursor="pointer",J.style.transition="border-color 0.2s",J.dataset.value=F($.value,Z),$.selected===!0)J.dataset.selected="true";if($.label!=null){let q=N("div","pf-choice-card-label");q.textContent=F($.label,Z),q.style.fontWeight="600",J.appendChild(q)}if($.description!=null){let q=N("div","pf-choice-card-description");q.textContent=F($.description,Z),q.style.fontSize="14px",J.appendChild(q)}return C($,J,Z),J}function $4(){X("Tabs",G6),X("Tab",W6),X("Accordion",X6),X("AccordionItem",B6),X("Dialog",M6),X("Popover",_6),X("Tooltip",N6),X("HoverCard",z6),X("Carousel",E6)}function G6($,Z){let J=N("div","pf-tabs"),q=N("div","pf-tabs-bar");q.setAttribute("role","tablist"),q.style.display="flex",q.style.gap="4px",q.style.marginBottom="12px";let Q=[],Y=[];if($.children)for(let H=0;H<$.children.length;H++){let G=$.children[H],_=`pf-tab-${Math.random().toString(36).slice(2,8)}`,z=`pf-panel-${Math.random().toString(36).slice(2,8)}`,W=document.createElement("button");W.type="button",W.className="pf-tab-trigger",W.textContent=G.title??`Tab ${H+1}`,W.setAttribute("role","tab"),W.setAttribute("aria-selected",H===0?"true":"false"),W.setAttribute("aria-controls",z),W.id=_,W.tabIndex=H===0?0:-1,W.style.padding="8px 16px",W.style.border="none",W.style.background="none",W.style.cursor="pointer",W.style.borderBottom="2px solid transparent",W.style.marginBottom="-2px",W.style.fontSize="14px";let B=N("div","pf-tab-panel");if(B.style.display=H===0?"block":"none",B.setAttribute("role","tabpanel"),B.setAttribute("aria-labelledby",_),B.id=z,B.tabIndex=0,C(G,B,Z),W.addEventListener("click",()=>{U(H)}),H===0)W.classList.add("pf-tab-active"),W.style.fontWeight="600";Y.push(W),Q.push(B),q.appendChild(W)}function U(H){Q.forEach((G)=>G.style.display="none"),Y.forEach((G)=>{G.style.borderBottomColor="transparent",G.style.fontWeight="normal",G.classList.remove("pf-tab-active"),G.setAttribute("aria-selected","false"),G.tabIndex=-1}),Q[H].style.display="block",Y[H].classList.add("pf-tab-active"),Y[H].style.fontWeight="600",Y[H].setAttribute("aria-selected","true"),Y[H].tabIndex=0,Y[H].focus()}q.addEventListener("keydown",(H)=>{let G=Y.indexOf(H.target);if(G<0)return;let _;if(H.key==="ArrowRight")_=(G+1)%Y.length;else if(H.key==="ArrowLeft")_=(G-1+Y.length)%Y.length;else if(H.key==="Home")_=0;else if(H.key==="End")_=Y.length-1;else return;H.preventDefault(),U(_)}),J.appendChild(q);for(let H of Q)J.appendChild(H);return J}function W6($,Z){let J=N("div","pf-tab");return C($,J,Z),J}function X6($,Z){let J=N("div","pf-accordion");return C($,J,Z),J}function B6($,Z){let J=N("div","pf-accordion-item"),q=`pf-acc-${Math.random().toString(36).slice(2,8)}`,Q=document.createElement("button");Q.type="button",Q.className="pf-accordion-trigger",Q.textContent=$.title??"",Q.setAttribute("aria-expanded","false"),Q.setAttribute("aria-controls",q),Q.style.width="100%",Q.style.textAlign="left",Q.style.padding="12px 0",Q.style.border="none",Q.style.background="none",Q.style.cursor="pointer",Q.style.fontSize="14px",Q.style.fontWeight="500";let Y=N("div","pf-accordion-content");return Y.id=q,Y.setAttribute("role","region"),Y.setAttribute("aria-labelledby",Q.id),Y.style.display="none",Y.style.paddingBottom="12px",C($,Y,Z),Q.addEventListener("click",()=>{let U=Y.style.display!=="none";Y.style.display=U?"none":"block",Q.setAttribute("aria-expanded",U?"false":"true")}),J.appendChild(Q),J.appendChild(Y),J}function M6($,Z){let J=N("div","pf-dialog-wrapper");if($.trigger!=null){let Y=u($.trigger,Z);Y.addEventListener("click",()=>{q.showModal()}),J.appendChild(Y)}let q=document.createElement("dialog");if(q.className="pf-dialog",q.setAttribute("aria-modal","true"),q.style.maxWidth="500px",q.style.width="100%",q.style.padding="24px",$.title!=null){let Y=N("h2","pf-dialog-title");Y.textContent=F($.title,Z),Y.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,q.setAttribute("aria-labelledby",Y.id),q.appendChild(Y)}if($.description!=null){let Y=N("p","pf-dialog-desc");Y.textContent=F($.description,Z),q.appendChild(Y)}let Q=N("div","pf-dialog-body");if(C($,Q,Z),q.appendChild(Q),$.dismissible!==!1)q.addEventListener("click",(Y)=>{if(Y.target===q)q.close()});return document.addEventListener("prefab:close-overlay",()=>q.close()),J.appendChild(q),J}function _6($,Z){let J=N("div","pf-popover");J.style.position="relative",J.style.display="inline-block";let q=N("div","pf-popover-content");if(q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="12px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",$.title!=null){let Y=N("div","pf-popover-title");Y.textContent=F($.title,Z),Y.style.fontWeight="600",Y.style.marginBottom="4px",q.appendChild(Y)}C($,q,Z);let Q=()=>{q.style.display=q.style.display==="none"?"block":"none"};if($.trigger!=null){let Y=u($.trigger,Z);Y.addEventListener("click",(U)=>{U.stopPropagation(),Q()}),J.appendChild(Y)}else J.addEventListener("click",(Y)=>{if(q.contains(Y.target)&&q.style.display!=="none")return;Q()});return J.appendChild(q),J}function N6($,Z){let J=N("div","pf-tooltip");J.style.position="relative",J.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,Q=N("div","pf-tooltip-content");return Q.id=q,Q.setAttribute("role","tooltip"),Q.textContent=F($.content??"",Z),Q.style.display="none",Q.style.position="absolute",Q.style.bottom="100%",Q.style.left="50%",Q.style.transform="translateX(-50%)",Q.style.padding="4px 8px",Q.style.borderRadius="4px",Q.style.color="#fff",Q.style.fontSize="12px",Q.style.whiteSpace="nowrap",Q.style.zIndex="50",C($,J,Z),J.setAttribute("aria-describedby",q),J.addEventListener("mouseenter",()=>{Q.style.display="block"}),J.addEventListener("mouseleave",()=>{Q.style.display="none"}),J.addEventListener("focus",()=>{Q.style.display="block"},!0),J.addEventListener("blur",()=>{Q.style.display="none"},!0),J.appendChild(Q),J}function z6($,Z){let J=N("div","pf-hover-card");J.style.position="relative",J.style.display="inline-block";let q=N("div","pf-hover-card-content");if(q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="16px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",q.style.minWidth="200px",$.trigger!=null)J.appendChild(u($.trigger,Z));return C($,q,Z),J.addEventListener("mouseenter",()=>{q.style.display="block"}),J.addEventListener("mouseleave",()=>{q.style.display="none"}),J.appendChild(q),J}function E6($,Z){let J=N("div","pf-carousel");J.style.position="relative",J.style.overflow="hidden",J.setAttribute("role","region"),J.setAttribute("aria-roledescription","carousel"),J.setAttribute("aria-label",F($.label??"Carousel",Z));let q=N("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",C($,q,Z);let Q=0,Y=$.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 H=document.createElement("button");H.type="button",H.textContent="›",H.className="pf-carousel-next",H.setAttribute("aria-label","Next slide"),H.style.position="absolute",H.style.right="4px",H.style.top="50%",H.style.transform="translateY(-50%)",H.style.zIndex="10";let G=()=>{q.style.transform=`translateX(-${Q*100}%)`};return U.addEventListener("click",()=>{if(Y===0)return;Q=Math.max(0,Q-1),G()}),H.addEventListener("click",()=>{if(Y===0)return;Q=Math.min(Y-1,Q+1),G()}),J.appendChild(q),J.appendChild(U),J.appendChild(H),J}function Z4(){X("ForEach",K6),X("If",J4),X("Elif",F6),X("Else",L6),X("Condition",D6),X("Define",T6),X("Use",O6),X("Slot",I6)}function K6($,Z){let J=document.createDocumentFragment(),q=$.expression;if(!q)return J;let Q;if(t(q)){let U=e(q,Z.store,Z.scope);Q=Array.isArray(U)?U:[]}else{let U=Z.store.get(q);Q=Array.isArray(U)?U:[]}let Y=$.let??{};for(let U=0;U<Q.length;U++){let H=Q[U],G={...Z.scope,$item:H,$index:U,...Y},_={...Z,scope:G};if($.children)Y1($.children,J,_)}return J}function J4($,Z){if(q4($.condition,Z)){let q=document.createDocumentFragment();if($.children)Y1($.children,q,Z);return q}return document.createDocumentFragment()}function F6($,Z){return J4($,Z)}function L6($,Z){let J=document.createDocumentFragment();if($.children)Y1($.children,J,Z);return J}function q4($,Z){if(!$)return!1;if(t($))return Boolean(e($,Z.store,Z.scope));return Boolean(Z.store.get($))}function D6($,Z){let J=document.createDocumentFragment(),q=$.cases,Q=$.else;if(q){for(let Y of q)if(q4(Y.when,Z)){if(Y.children)Y1(Y.children,J,Z);return J}}if(Q)Y1(Q,J,Z);return J}function T6($,Z){let J=$.name;if(J&&$.children)Z.templates=Z.templates??{},Z.templates[J]=$.children;return document.createDocumentFragment()}function O6($,Z){let J=document.createDocumentFragment(),q=$.def??$.name,Q=Z.templates?.[q];if(!Q)return J;let Y=$.overrides??{},U={...Z.scope,...Y},H={...Z.slots??{},...$.slots??{}};if(Array.isArray($.children))H.default=$.children;let G={...Z,scope:U,slots:H};for(let _ of Q)J.appendChild(u(_,G));return J}function I6($,Z){let J=document.createDocumentFragment(),q=$.name??"default",Y=Z.slots?.[q]??$.children;if(Y)for(let U of Y)J.appendChild(u(U,Z));return J}function Q4(){X("Alert",V6),X("AlertTitle",P6),X("AlertDescription",R6)}function V6($,Z){let J=N("div","pf-alert");J.setAttribute("role","alert");let q=$.variant??"default";if(J.setAttribute("data-variant",q),J.style.padding="12px 16px",$.icon!=null){let Q=N("span","pf-alert-icon");Q.setAttribute("data-icon",$.icon),Q.style.marginRight="8px",J.appendChild(Q)}return C($,J,Z),J}function P6($,Z){let J=N("h5","pf-alert-title");return J.textContent=F($.content,Z),J.style.fontWeight="600",J.style.marginBottom="4px",J}function R6($,Z){let J=N("p","pf-alert-description");return J.textContent=F($.content,Z),J.style.fontSize="14px",J}function Y4(){X("Image",j6),X("Audio",k6),X("Video",A6),X("Embed",S6),X("Svg",C6),X("DropZone",w6),X("Mermaid",b6)}function j6($,Z){let J=document.createElement("img");if(J.className="pf-image",J.src=F($.src,Z),$.alt!=null)J.alt=F($.alt,Z);if($.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function k6($,Z){let J=document.createElement("audio");return J.className="pf-audio",J.src=F($.src,Z),J.controls=!0,J}function A6($,Z){let J=document.createElement("video");if(J.className="pf-video",J.src=F($.src,Z),J.controls=!0,$.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function S6($,Z){let J=N("div","pf-embed"),q=document.createElement("iframe");return q.src=F($.src,Z),q.style.width="100%",q.style.height=$.height!=null?`${$.height}px`:"400px",q.style.border="none",q.setAttribute("sandbox","allow-scripts"),J.appendChild(q),J}var f6=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 C6($,Z){let J=N("div","pf-svg"),q=F($.content,Z);if(!q.includes("<svg"))return J;if(!/<svg[^>]*\sxmlns\s*=/.test(q))q=q.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"');let Y=new DOMParser().parseFromString(q,"image/svg+xml").querySelector("svg");if(!Y)return J;return U4(Y),J.appendChild(document.importNode(Y,!0)),J}function U4($){let Z=Array.from($.children);for(let J of Z){if(!f6.has(J.tagName.toLowerCase())){J.remove();continue}for(let q of Array.from(J.attributes)){let Q=q.name.toLowerCase();if(Q.startsWith("on")||Q==="href"&&q.value.trim().toLowerCase().startsWith("javascript:"))J.removeAttribute(q.name)}U4(J)}}function w6($,Z){let J=N("div","pf-dropzone");return J.style.padding="32px",J.style.textAlign="center",J.style.cursor="pointer",J.textContent=F($.label??"Drop files here",Z),J.addEventListener("dragover",(q)=>{q.preventDefault(),J.classList.add("pf-dropzone-active")}),J.addEventListener("dragleave",()=>{J.classList.remove("pf-dropzone-active")}),J.addEventListener("drop",(q)=>{q.preventDefault(),J.classList.remove("pf-dropzone-active")}),J}function b6($,Z){let J=N("div","pf-mermaid");J.setAttribute("data-mermaid","true");let q=F($.content,Z);if(J.textContent=q,typeof globalThis.mermaid<"u")J.classList.add("mermaid"),J.textContent=q;return J}var y6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",m6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",U0=null,b1=null;async function h6(){if(U0)return U0;if(b1)return b1;return b1=import(y6).then(($)=>{let Z=$;return Z.GlobalWorkerOptions.workerSrc=m6,U0=Z,Z}),b1}function G4(){X("PdfViewer",v6)}function v6($,Z){let J=N("div","pf-pdf-viewer"),q=$.src!=null?F($.src,Z):void 0,Q=$.data,Y=$.page!=null?$.page:1,U=$.zoom!=null?$.zoom:"fit-width",H=$.toolbar!==!1,G=$.height!=null?$.height:600;J.style.height=`${G}px`,J.style.display="flex",J.style.flexDirection="column",J.style.overflow="hidden",J.style.border="1px solid var(--color-border-primary, #e5e7eb)",J.style.borderRadius="var(--border-radius-md, 0.375rem)",J.style.background="var(--color-background-secondary, #f9fafb)";let _=N("div","pf-pdf-loading");return _.textContent="Loading PDF…",_.style.display="flex",_.style.alignItems="center",_.style.justifyContent="center",_.style.flex="1",_.style.color="var(--color-text-secondary, #6b7280)",J.appendChild(_),g6(J,_,{src:q,data:Q,initialPage:Y,zoom:U,showToolbar:H}),J}async function g6($,Z,J){try{let q=await h6(),Q;if(J.src)Q={url:J.src};else if(J.data){let B=atob(J.data),K=new Uint8Array(B.length);for(let L=0;L<B.length;L++)K[L]=B.charCodeAt(L);Q={data:K}}else{Z.textContent="Error: No PDF source provided";return}let Y=await q.getDocument(Q).promise;Z.remove();let U=Math.max(1,Math.min(J.initialPage,Y.numPages)),H=null,G=null;if(J.showToolbar){let B=u6(Y.numPages,U,{onPrev:()=>{if(U>1)U--,W()},onNext:()=>{if(U<Y.numPages)U++,W()},onPageChange:(K)=>{let L=Math.max(1,Math.min(K,Y.numPages));if(L!==U)U=L,W()}});H=B.pageInput,G=B.pageCount,$.insertBefore(B.el,$.firstChild)}let _=N("div","pf-pdf-canvas-container");_.style.flex="1",_.style.overflow="auto",_.style.display="flex",_.style.justifyContent="center",_.style.padding="8px",$.appendChild(_);let z=document.createElement("canvas");z.style.display="block",z.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",_.appendChild(z);async function W(){let B=await Y.getPage(U),K=_.clientWidth-16,L,M=B.getViewport({scale:1});if(J.zoom==="fit-width")L=K/M.width;else if(J.zoom==="fit-page"){let V=_.clientHeight-16,A=K/M.width,I=V/M.height;L=Math.min(A,I)}else L=typeof J.zoom==="number"?J.zoom:1;let E=B.getViewport({scale:L});z.width=E.width,z.height=E.height,z.style.width=`${E.width}px`,z.style.height=`${E.height}px`;let T=z.getContext("2d");if(!T)return;if(await B.render({canvasContext:T,viewport:E}).promise,H)H.value=String(U);if(G)G.textContent=`/ ${Y.numPages}`}await W()}catch(q){Z.textContent=`PDF Error: ${q instanceof Error?q.message:String(q)}`,Z.style.color="var(--color-text-danger, #dc2626)"}}function u6($,Z,J){let q=N("div","pf-pdf-toolbar");q.style.display="flex",q.style.alignItems="center",q.style.gap="8px",q.style.padding="6px 12px",q.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",q.style.background="var(--color-background-primary, #fff)",q.style.flexShrink="0",q.style.fontSize="13px";let Q=document.createElement("button");Q.textContent="‹",Q.title="Previous page",Q.className="pf-pdf-btn",H4(Q),Q.addEventListener("click",J.onPrev);let Y=document.createElement("button");Y.textContent="›",Y.title="Next page",Y.className="pf-pdf-btn",H4(Y),Y.addEventListener("click",J.onNext);let U=document.createElement("input");U.type="number",U.min="1",U.max=String($),U.value=String(Z),U.style.width="48px",U.style.textAlign="center",U.style.border="1px solid var(--color-border-primary, #e5e7eb)",U.style.borderRadius="4px",U.style.padding="2px 4px",U.style.fontSize="13px",U.addEventListener("change",()=>{let G=parseInt(U.value,10);if(!isNaN(G))J.onPageChange(G)});let H=document.createElement("span");return H.textContent=`/ ${$}`,H.style.color="var(--color-text-secondary, #6b7280)",q.appendChild(Q),q.appendChild(U),q.appendChild(H),q.appendChild(Y),{el:q,pageInput:U,pageCount:H}}function H4($){$.style.border="1px solid var(--color-border-primary, #e5e7eb)",$.style.borderRadius="4px",$.style.background="var(--color-background-primary, #fff)",$.style.cursor="pointer",$.style.padding="2px 8px",$.style.fontSize="16px",$.style.lineHeight="1"}var m1=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function W1($,Z){let J=document.createElement("div");return J.className="pf-chart-tooltip",$.appendChild(J),$.addEventListener("mouseleave",()=>{J.classList.remove("pf-visible")}),{wrapper:$,tooltip:J,svgEl:Z}}function $1($,Z,J,q,Q){let{tooltip:Y,svgEl:U,wrapper:H}=$;if(Q.length===0)return;let G="";if(q)G+=`<div class="pf-chart-tooltip-label">${y1(q)}</div>`;for(let E of Q)G+='<div class="pf-chart-tooltip-row">',G+=`<span class="pf-chart-tooltip-dot" style="background:${y1(E.color)}"></span>`,G+=`<span>${y1(E.label)}:</span> <strong>${y1(String(E.value))}</strong>`,G+="</div>";Y.innerHTML=G;let _=U.getBoundingClientRect(),z=H.getBoundingClientRect(),W=U.viewBox.baseVal,B=_.width/(W.width||1),K=_.left-z.left+Z*B,L=Y.offsetWidth||100,M=K+12;if(M+L>z.width)M=K-L-12;Y.style.left=`${Math.max(0,M)}px`,Y.style.top="4px",Y.classList.add("pf-visible")}function y1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function W4($,Z,J,q,Q,Y,U,H){let G=Q.plotWidth/J.length;for(let _=0;_<J.length;_++){let z=Q.plotLeft+_*G,W=document.createElementNS("http://www.w3.org/2000/svg","rect");W.setAttribute("x",String(z)),W.setAttribute("y",String(Q.plotTop)),W.setAttribute("width",String(G)),W.setAttribute("height",String(Q.plotHeight)),W.setAttribute("fill","transparent"),W.style.cursor="default";let B=Y?J[_][Y]:void 0,K=B!=null?H?H(B):w(B):void 0,L=q.map((V,A)=>({label:V.label??V.dataKey,value:U(J[_][V.dataKey],V,A),color:V.color??m1[A%m1.length]})),M=z+G/2,E=()=>$1($,M,Q.plotTop,K,L),T=()=>$.tooltip.classList.remove("pf-visible");W.addEventListener("mouseenter",E),W.addEventListener("mouseleave",T),W.addEventListener("touchstart",E,{passive:!0}),W.addEventListener("touchend",T,{passive:!0}),Z.appendChild(W)}}function X4($,Z,J,q,Q,Y,U,H,G,_){let z=J.length===1?Q.plotWidth:Q.plotWidth/(J.length-1);for(let W=0;W<J.length;W++){let B=J.length===1?(Q.plotLeft+Q.plotRight)/2:Q.plotLeft+W/(J.length-1)*Q.plotWidth,K=J.length===1?Q.plotLeft:B-z/2,L=J.length===1?Q.plotWidth:z,M=document.createElementNS("http://www.w3.org/2000/svg","rect");M.setAttribute("x",String(Math.max(Q.plotLeft,K))),M.setAttribute("y",String(Q.plotTop)),M.setAttribute("width",String(Math.min(L,Q.plotRight-Math.max(Q.plotLeft,K)))),M.setAttribute("height",String(Q.plotHeight)),M.setAttribute("fill","transparent"),M.style.cursor="default";let E=Y?J[W][Y]:void 0,T=E!=null?_?_(E):w(E):void 0,V=q.map((j,f)=>({label:j.label??j.dataKey,value:U(J[W][j.dataKey],j,f),color:j.color??m1[f%m1.length]})),A=()=>{if($1($,B,Q.plotTop,T,V),H)H.setAttribute("x1",String(B)),H.setAttribute("x2",String(B)),H.setAttribute("opacity","1");if(G)for(let j of G){for(let f of j)f.setAttribute("data-visible","false");j[W]?.setAttribute("data-visible","true")}},I=()=>{if($.tooltip.classList.remove("pf-visible"),H)H.setAttribute("opacity","0");if(G)for(let j of G)for(let f of j)f.setAttribute("data-visible","false")};M.addEventListener("mouseenter",A),M.addEventListener("mouseleave",I),M.addEventListener("touchstart",A,{passive:!0}),M.addEventListener("touchend",I,{passive:!0}),Z.appendChild(M)}}var s=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],J1="var(--muted-foreground, #6b7280)",z1="var(--border, #e5e7eb)",X1="10";function h1($,Z,J,q=!1){let Q=J?44:0,Y=$-(q?44:0),U=10,H=Z-24;return{plotLeft:Q,plotRight:Y,plotTop:10,plotBottom:H,plotWidth:Y-Q,plotHeight:H-10}}function B4($,Z=5){if($<=0)return[0];let J=$/Z,q=Math.pow(10,Math.floor(Math.log10(J))),Q=J/q,Y=Q<=1.5?q:Q<=3?2*q:Q<=7?5*q:10*q,U=[];for(let H=0;H<=$+Y*0.01;H+=Y)U.push(Math.round(H*1000)/1000);return U}function H0($,Z,J,q,Q){let Y=B4(J);for(let U of Y){let H=Z.plotBottom-(J>0?U/J*Z.plotHeight:0),G=n("text",{x:Z.plotLeft-6,y:H+3,"text-anchor":"end","font-size":X1,fill:J1});if(G.textContent=X0(U,Q),$.appendChild(G),q&&U>0)$.appendChild(n("line",{x1:Z.plotLeft,y1:H,x2:Z.plotRight,y2:H,stroke:z1,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function G0($,Z,J,q){let Q=B4(J);for(let Y of Q){let U=Z.plotBottom-(J>0?Y/J*Z.plotHeight:0),H=n("text",{x:Z.plotRight+6,y:U+3,"text-anchor":"start","font-size":X1,fill:J1});H.textContent=X0(Y,q),$.appendChild(H)}}function W0($,Z,J,q,Q,Y){for(let U=0;U<Z.length;U++){let H=Z[U][J],G=n("text",{x:q(U),y:Q+14,"text-anchor":"middle","font-size":X1,fill:J1});G.textContent=H==null?"":Y?Y(H):w(H),$.appendChild(G)}}function v1($,Z){$.appendChild(n("line",{x1:Z.plotLeft,y1:Z.plotBottom,x2:Z.plotRight,y2:Z.plotBottom,stroke:J1,"stroke-width":1}))}function Z1($,Z,J){if($==null)return"";let q=d(`{{ __v | ${Z} }}`,{...J,scope:{...J.scope,__v:$}});return w(q??$)}function X0($,Z){if(Z==="currency")return`$${$.toLocaleString()}`;if(Z==="percent")return`${$}%`;if($>=1e6)return`${($/1e6).toFixed(1)}M`;if($>=1000)return`${($/1000).toFixed(1)}K`;return String($)}function q1($){let Z=$.yAxisFormat??$.valueFormat;return Z&&Z!=="auto"?Z:void 0}function B0($,Z,J){return(q,Q)=>{if(q===null||q===void 0)return"—";if(Q.tooltipFormat)return Z1(q,Q.tooltipFormat,$);let Y=Q.yAxisId==="right"?J:Z;return X0(Number(q),Y)}}function U1($,Z,J){let q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(q.setAttribute("width","100%"),q.setAttribute("height",String(Z)),q.setAttribute("viewBox",`0 0 ${$} ${Z}`),q.setAttribute("role","img"),J)q.setAttribute("aria-label",`${J} chart`);return q.style.overflow="visible",q}function n($,Z){let J=document.createElementNS("http://www.w3.org/2000/svg",$);for(let[q,Q]of Object.entries(Z))J.setAttribute(q,String(Q));return J}function g1($,Z){let J=n("text",$);return J.textContent=Z,J}function B1($,Z,J,q){let Q=q*Math.PI/180;return{x:$+J*Math.cos(Q),y:Z-J*Math.sin(Q)}}function M0($,Z,J,q,Q){let Y=Math.max(2,Math.ceil(Math.abs(Q-q)/4)),U=[];for(let H=0;H<=Y;H++){let G=B1($,Z,J,q+(Q-q)*H/Y);U.push(`${H===0?"M":"L"} ${G.x.toFixed(2)} ${G.y.toFixed(2)}`)}return U.join(" ")}function M1($,Z,J){if(J===!1||Z.length<=1)return;let q=N("div","pf-chart-legend");q.style.display="flex",q.style.gap="12px",q.style.fontSize="12px",q.style.marginBottom="8px";for(let Q=0;Q<Z.length;Q++){let Y=N("div","pf-chart-legend-item");Y.style.display="flex",Y.style.alignItems="center",Y.style.gap="4px";let U=N("span");U.style.width="8px",U.style.height="8px",U.style.borderRadius="50%",U.style.backgroundColor=Z[Q].color??s[Q%s.length];let H=N("span");H.textContent=Z[Q].label??Z[Q].dataKey,Y.appendChild(U),Y.appendChild(H),q.appendChild(Y)}$.appendChild(q)}function _4(){X("BarChart",x6),X("LineChart",M4),X("AreaChart",M4),X("PieChart",p6),X("RadarChart",l6),X("ScatterChart",c6),X("RadialChart",d6),X("Histogram",i6)}function x6($,Z){let J=N("div","pf-chart pf-bar-chart"),q=d($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,H=$.showGrid===!0,G=$.showYAxisRight===!0,_=$.showTooltip!==!1,z=$.xAxis,W=$.tooltipXKey,B=$.xAxisFormat,K=$.tooltipXFormat,L=Q.filter((O)=>O.yAxisId!=="right"),M=Q.filter((O)=>O.yAxisId==="right"),E=G&&M.length>0,T=L.length>0?Math.max(...q.flatMap((O)=>L.map((D)=>Number(O[D.dataKey]??0))),1):1,V=E?Math.max(...q.flatMap((O)=>M.map((D)=>Number(O[D.dataKey]??0))),1):1,A=400,I=h1(A,Y,U,E),j=U1(A,Y,"Bar");if(U)H0(j,I,T,H,q1($));if(E)G0(j,I,V,$.yAxisRightFormat);v1(j,I);let f=I.plotWidth/q.length,S=f/(Q.length+1);for(let O=0;O<q.length;O++)for(let D=0;D<Q.length;D++){let k=Q[D],y=q[O][k.dataKey];if(y===null||y===void 0)continue;let i=k.yAxisId==="right"?V:T,g=Number(y),P=Math.max(0,g/i*I.plotHeight),p=I.plotLeft+O*f+D*S+S/2,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(p)),R.setAttribute("y",String(I.plotBottom-P)),R.setAttribute("width",String(S*0.8)),R.setAttribute("height",String(P)),R.setAttribute("fill",k.color??s[D%s.length]),R.setAttribute("rx","2"),j.appendChild(R)}if(z){let O=B?(D)=>Z1(D,B,Z):void 0;W0(j,q,z,(D)=>{return I.plotLeft+D*f+f/2},I.plotBottom,O)}if(_){let O=W1(J,j),D=B0(Z,q1($),$.yAxisRightFormat);W4(O,j,q,Q,I,W??z,D,K?(y)=>Z1(y,K,Z):void 0)}return M1(J,Q,$.showLegend),J.appendChild(j),J}function M4($,Z){let J=N("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),q=d($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,H=$.showGrid===!0,G=$.showYAxisRight===!0,_=$.showTooltip!==!1,z=$.xAxis,W=$.tooltipXKey,B=$.xAxisFormat,K=$.tooltipXFormat,L=Q.filter((D)=>D.yAxisId!=="right"),M=Q.filter((D)=>D.yAxisId==="right"),E=G&&M.length>0,T=L.length>0?Math.max(...q.flatMap((D)=>L.map((k)=>Number(D[k.dataKey]??0))),1):1,V=E?Math.max(...q.flatMap((D)=>M.map((k)=>Number(D[k.dataKey]??0))),1):1,A=400,I=h1(A,Y,U,E),j=U1(A,Y,$.type==="AreaChart"?"Area":"Line"),f=$.type==="AreaChart";if(U)H0(j,I,T,H,q1($));if(E)G0(j,I,V,$.yAxisRightFormat);v1(j,I);let S=[];for(let D=0;D<Q.length;D++){let k=Q[D],y=k.yAxisId==="right",x=y?V:T,i=k.color??s[D%s.length],g=q.map((R,m)=>{let c=R[k.dataKey],r=c===null||c===void 0,H1=q.length===1?(I.plotLeft+I.plotRight)/2:I.plotLeft+m/(q.length-1)*I.plotWidth,w4=r?I.plotBottom:I.plotBottom-Number(c)/x*I.plotHeight;return{x:H1,y:w4,isNull:r}});if(f){let R=[],m=()=>{if(R.length<2){R=[];return}let c=`M ${R[0].x},${I.plotBottom} `+R.map((H1)=>`L ${H1.x},${H1.y}`).join(" ")+` L ${R[R.length-1].x},${I.plotBottom} Z`,r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",c),r.setAttribute("fill",i),r.setAttribute("opacity","0.15"),j.appendChild(r),R=[]};for(let c of g){if(c.isNull){m();continue}R.push(c)}m()}let P="";for(let R of g){if(R.isNull)continue;let m=g.indexOf(R),c=m===0||g[m-1].isNull;P+=`${c?"M":"L"} ${R.x},${R.y} `}if(P){let R=document.createElementNS("http://www.w3.org/2000/svg","path");if(R.setAttribute("d",P.trim()),R.setAttribute("fill","none"),R.setAttribute("stroke",i),R.setAttribute("stroke-width","2"),y)R.setAttribute("stroke-dasharray","6 3");j.appendChild(R)}let p=[];for(let R of g){let m=document.createElementNS("http://www.w3.org/2000/svg","circle");if(m.setAttribute("cx",String(R.x)),m.setAttribute("cy",String(R.y)),m.setAttribute("r","4"),m.setAttribute("fill",i),m.setAttribute("class","pf-data-dot"),m.setAttribute("data-visible","false"),m.style.pointerEvents="none",R.isNull)m.style.display="none";j.appendChild(m),p.push(m)}S.push(p)}let O=document.createElementNS("http://www.w3.org/2000/svg","line");if(O.setAttribute("class","pf-crosshair"),O.setAttribute("x1",String(I.plotLeft)),O.setAttribute("x2",String(I.plotLeft)),O.setAttribute("y1",String(I.plotTop)),O.setAttribute("y2",String(I.plotBottom)),O.setAttribute("stroke",J1),O.setAttribute("stroke-width","1"),O.setAttribute("stroke-dasharray","3 3"),O.setAttribute("opacity","0"),j.appendChild(O),z){let D=B?(k)=>Z1(k,B,Z):void 0;W0(j,q,z,(k)=>{return q.length===1?(I.plotLeft+I.plotRight)/2:I.plotLeft+k/(q.length-1)*I.plotWidth},I.plotBottom,D)}if(_){let D=W1(J,j),k=B0(Z,q1($),$.yAxisRightFormat);X4(D,j,q,Q,I,W??z,k,O,S,K?(x)=>Z1(x,K,Z):void 0)}return M1(J,Q,$.showLegend),J.appendChild(j),J}function p6($,Z){let J=N("div","pf-chart pf-pie-chart"),q=d($.data,Z)??[],Q=$.series??[],Y=$.height??300,U=Math.min(Y,300),H=$.showTooltip!==!1,G=$.dataKey??Q[0]?.dataKey,_=$.nameKey??$.tooltipXKey??$.xAxis,z=Q.length>0?Q:G?[{dataKey:G,label:G}]:[];if(q.length===0||!G)return J.textContent="No chart data",J;let W=U1(U,U,"Pie"),B=U/2,K=U/2,L=U/2-10,M=$.tooltipXFormat,E=q1($),T=(f)=>E?Z1(f,E,Z):String(f),V=q.map((f)=>Number(f[G]??0)),A=V.reduce((f,S)=>f+S,0);if(A===0)return J.textContent="No chart data",J.appendChild(W),J;let I=H?W1(J,W):void 0,j=-Math.PI/2;for(let f=0;f<V.length;f++){let S=V[f]/A*2*Math.PI,O=j+S,D=S>Math.PI?1:0,k=B+L*Math.cos(j),y=K+L*Math.sin(j),x=B+L*Math.cos(O),i=K+L*Math.sin(O),g=s[f%s.length],P=document.createElementNS("http://www.w3.org/2000/svg","path");if(P.setAttribute("d",`M ${B},${K} L ${k},${y} A ${L},${L} 0 ${D} 1 ${x},${i} Z`),P.setAttribute("fill",g),P.style.cursor="default",I){let p=_?q[f][_]:void 0,R=p!=null?M?Z1(p,M,Z):w(p):`Slice ${f+1}`,m=`${(V[f]/A*100).toFixed(1)}%`,c=j+S/2,r=B+L*0.6*Math.cos(c);P.addEventListener("mouseenter",()=>{$1(I,r,K,R,[{label:z[0].label??G,value:`${T(V[f])} (${m})`,color:g}])}),P.addEventListener("mouseleave",()=>{I.tooltip.classList.remove("pf-visible")}),P.addEventListener("touchstart",()=>{$1(I,r,K,R,[{label:z[0].label??G,value:`${T(V[f])} (${m})`,color:g}])},{passive:!0}),P.addEventListener("touchend",()=>{I.tooltip.classList.remove("pf-visible")},{passive:!0})}W.appendChild(P),j=O}return M1(J,z,$.showLegend),J.appendChild(W),J}function c6($,Z){let J=N("div","pf-chart pf-scatter-chart"),q=d($.data,Z)??[],Q=$.xAxis,Y=$.yAxis,U=$.zAxis,H=$.series??[],G=$.height??300;if(q.length===0||!Q||!Y)return J.textContent="No chart data",J;let _=$.showGrid!==!1,z=$.showTooltip!==!1,W=H[0]?.color??s[0],B=q1($),K=(P)=>B?Z1(P,B,Z):String(Math.round(P*100)/100),L=q.map((P)=>Number(P[Q]??0)),M=q.map((P)=>Number(P[Y]??0)),E=Math.min(...L),T=Math.max(...L),V=Math.min(...M),A=Math.max(...M),I=T-E||1,j=A-V||1,f=U?q.map((P)=>Number(P[U]??0)):[],S=U?Math.max(...f,1):1,O=400,D=h1(O,G,!0),k=U1(O,G,"Scatter"),y=(P)=>D.plotLeft+(P-E)/I*D.plotWidth,x=(P)=>D.plotBottom-(P-V)/j*D.plotHeight,i=4;for(let P=0;P<=i;P++){let p=V+j*P/i,R=x(p);if(k.appendChild(g1({x:D.plotLeft-6,y:R+3,"text-anchor":"end","font-size":X1,fill:J1},K(p))),_&&P>0)k.appendChild(n("line",{x1:D.plotLeft,y1:R,x2:D.plotRight,y2:R,stroke:z1,"stroke-width":1,"stroke-dasharray":"4 3"}))}v1(k,D);for(let P of[E,(E+T)/2,T])k.appendChild(g1({x:y(P),y:D.plotBottom+14,"text-anchor":"middle","font-size":X1,fill:J1},String(Math.round(P*100)/100)));let g=z?W1(J,k):void 0;for(let P=0;P<q.length;P++){let p=y(L[P]),R=x(M[P]),m=U?4+Math.sqrt(f[P]/S)*14:4,c=n("circle",{cx:p,cy:R,r:m,fill:W,"fill-opacity":U?0.6:0.85});if(g){let r=[{label:Q,value:K(L[P]),color:W},{label:Y,value:K(M[P]),color:W},...U?[{label:U,value:K(f[P]),color:W}]:[]],H1=H[0]?.label??"Point";c.addEventListener("mouseenter",()=>$1(g,p,R,H1,r)),c.addEventListener("mouseleave",()=>g.tooltip.classList.remove("pf-visible")),c.addEventListener("touchstart",()=>$1(g,p,R,H1,r),{passive:!0}),c.addEventListener("touchend",()=>g.tooltip.classList.remove("pf-visible"),{passive:!0})}k.appendChild(c)}return M1(J,H,$.showLegend),J.appendChild(k),J}function d6($,Z){let J=N("div","pf-chart pf-radial-chart"),q=d($.data,Z)??[],Q=$.series??[],Y=$.dataKey??Q[0]?.dataKey,U=$.nameKey??$.tooltipXKey??$.xAxis,H=$.height??300;if(q.length===0||!Y)return J.textContent="No chart data",J;let G=Math.min(H,300),_=G/2,z=G/2,W=G/2-10,B=Math.max(0,Math.min($.innerRadius??30,W-10)),K=$.startAngle??180,L=$.endAngle??0,M=$.showTooltip!==!1,E=q.map((D)=>Number(D[Y]??0)),T=Math.max(...E,1),V=U1(G,G,"Radial"),A=(W-B)/q.length,I=Math.max(2,A*0.7),j=q1($),f=(D)=>j?Z1(D,j,Z):String(D),S=M?W1(J,V):void 0,O=[];for(let D=0;D<q.length;D++){let k=W-A*D-A/2,y=Q[D]?.color??s[D%s.length],x=E[D]/T,i=K+x*(L-K),g=U?q[D][U]:null,P=g!=null?w(g):Q[D]?.label??Y;O.push({dataKey:P||Y,label:P||Y,color:y}),V.appendChild(n("path",{d:M0(_,z,k,K,L),fill:"none",stroke:z1,"stroke-width":I,"stroke-linecap":"round"}));let p=n("path",{d:M0(_,z,k,K,i),fill:"none",stroke:y,"stroke-width":I,"stroke-linecap":"round"});if(S){let R=B1(_,z,k,(K+i)/2),m=[{label:Y,value:f(E[D]),color:y}],c=P||Y;p.addEventListener("mouseenter",()=>$1(S,R.x,R.y,c,m)),p.addEventListener("mouseleave",()=>S.tooltip.classList.remove("pf-visible")),p.addEventListener("touchstart",()=>$1(S,R.x,R.y,c,m),{passive:!0}),p.addEventListener("touchend",()=>S.tooltip.classList.remove("pf-visible"),{passive:!0})}V.appendChild(p)}return M1(J,O,$.showLegend),J.appendChild(V),J}function l6($,Z){let J=N("div","pf-chart pf-radar-chart"),q=d($.data,Z)??[],Q=$.series??[],Y=$.axisKey??$.xAxis,U=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let H=$.filled!==!1,G=$.showDots===!0,_=$.showGrid!==!1,z=$.showTooltip!==!1,W=Math.min(U,320),B=W/2,K=W/2,L=W/2-24,M=q.length,E=Math.max(...q.flatMap((S)=>Q.map((O)=>Number(S[O.dataKey]??0))),1),T=(S)=>90-360*S/M,V=(S)=>S.map((O)=>`${O.x.toFixed(1)},${O.y.toFixed(1)}`).join(" "),A=U1(W,W,"Radar");if(_){for(let O=1;O<=4;O++){let D=L*O/4,k=Array.from({length:M},(y,x)=>B1(B,K,D,T(x)));A.appendChild(n("polygon",{points:V(k),fill:"none",stroke:z1,"stroke-width":1}))}for(let O=0;O<M;O++){let D=B1(B,K,L,T(O));A.appendChild(n("line",{x1:B,y1:K,x2:D.x,y2:D.y,stroke:z1,"stroke-width":1}))}}for(let S=0;S<M;S++){let O=B1(B,K,L+12,T(S)),D=Y?q[S][Y]:null;A.appendChild(g1({x:O.x,y:O.y+3,"text-anchor":"middle","font-size":X1,fill:J1},D!=null?String(D):""))}let I=z?W1(J,A):void 0,j=q1($),f=(S)=>j?Z1(S,j,Z):String(S);for(let S=0;S<Q.length;S++){let O=Q[S],D=O.color??s[S%s.length],k=q.map((y,x)=>B1(B,K,Number(y[O.dataKey]??0)/E*L,T(x)));if(A.appendChild(n("polygon",{points:V(k),fill:H?D:"none","fill-opacity":H?0.2:0,stroke:D,"stroke-width":2})),G||I)for(let y=0;y<k.length;y++){let x=n("circle",{cx:k[y].x,cy:k[y].y,r:G?3:6,fill:G?D:"transparent","fill-opacity":G?1:0});if(I){let i=Y?q[y][Y]:null,g=i!=null?w(i):O.label??O.dataKey,P=[{label:O.label??O.dataKey,value:f(Number(q[y][O.dataKey]??0)),color:D}];x.addEventListener("mouseenter",()=>$1(I,k[y].x,k[y].y,g,P)),x.addEventListener("mouseleave",()=>I.tooltip.classList.remove("pf-visible")),x.addEventListener("touchstart",()=>$1(I,k[y].x,k[y].y,g,P),{passive:!0}),x.addEventListener("touchend",()=>I.tooltip.classList.remove("pf-visible"),{passive:!0})}A.appendChild(x)}}return M1(J,Q,$.showLegend),J.appendChild(A),J}function i6($,Z){let J=N("div","pf-chart pf-histogram"),q=d($.data,Z);if(!q||q.length===0)return J.textContent="No data",J;let Q=q,Y=$.bins??10,U=$.height??200,H=$.color??s[0],G=Math.min(...Q),z=(Math.max(...Q)-G)/Y||1,W=Array(Y).fill(0);for(let T of Q){let V=Math.min(Math.floor((T-G)/z),Y-1);W[V]++}let B=Math.max(...W),K=300,L=U,M=K/Y,E=U1(K,L,"Histogram");for(let T=0;T<Y;T++){let V=B>0?W[T]/B*L:0,A=document.createElementNS("http://www.w3.org/2000/svg","rect");A.setAttribute("x",String(T*M)),A.setAttribute("y",String(L-V)),A.setAttribute("width",String(M-1)),A.setAttribute("height",String(V)),A.setAttribute("fill",H),E.appendChild(A)}return J.appendChild(E),J}function N4(){X("Table",s6),X("TableHead",_0("thead")),X("TableBody",_0("tbody")),X("TableFooter",_0("tfoot")),X("TableRow",n6),X("TableHeader",r6),X("TableCell",a6),X("TableCaption",o6),X("ExpandableRow",t6)}function s6($,Z){let J=document.createElement("table");return J.className="pf-table",J.style.width="100%",J.style.borderCollapse="collapse",C($,J,Z),J}function _0($){return(Z,J)=>{let q=document.createElement($);return q.className=`pf-${$}`,C(Z,q,J),q}}function n6($,Z){let J=document.createElement("tr");return J.className="pf-table-row",C($,J,Z),J}function r6($,Z){let J=document.createElement("th");return J.className="pf-table-header",J.style.textAlign="left",J.style.padding="8px 12px",J.style.fontWeight="600",J.textContent=F($.content,Z),J}function a6($,Z){let J=document.createElement("td");if(J.className="pf-table-cell",J.style.padding="8px 12px",$.colSpan!=null)J.colSpan=$.colSpan;if($.rowSpan!=null)J.rowSpan=$.rowSpan;return C($,J,Z),J}function o6($,Z){let J=document.createElement("caption");return J.className="pf-table-caption",J.style.padding="8px",J.style.fontSize="14px",J.textContent=F($.content,Z),J}function t6($,Z){let J=N("div","pf-expandable-row"),q=N("div","pf-expandable-row-summary");q.style.cursor="pointer",q.style.display="flex",q.style.alignItems="center",q.style.gap="8px";let Q=N("span","pf-expandable-arrow");Q.textContent="▶",Q.style.transition="transform 0.2s",Q.style.fontSize="10px",q.appendChild(Q);let Y=$.summary;if(Y)for(let G of Y)q.appendChild(u(G,Z));let U=N("div","pf-expandable-row-detail");U.style.display="none",U.style.paddingLeft="24px",C($,U,Z);let H=!1;return q.addEventListener("click",()=>{H=!H,U.style.display=H?"block":"none",Q.style.transform=H?"rotate(90deg)":""}),J.appendChild(q),J.appendChild(U),J}var z4=!1;function u1(){if(z4)return;z4=!0,c0(),s0(),a0(),o0(),e0(),$4(),Z4(),Q4(),Y4(),G4(),_4(),N4()}function z0($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function E0($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function N0($,Z=" "){return Object.entries($).map(([J,q])=>`${Z}--${z0(J)}: ${E0(q)};`).join(`
|
|
7
|
-
`)}function
|
|
8
|
-
${
|
|
9
|
-
}`);if(
|
|
10
|
-
${
|
|
11
|
-
}`),
|
|
3
|
+
`),n=[],r=0;while(r<t.length){let o=t[r];if(o.trimStart().startsWith("```")){let a=o.trimStart().slice(3).trim(),l=[];r++;while(r<t.length&&!t[r].trimStart().startsWith("```"))l.push(Ce(t[r])),r++;r++;let c=a?` data-language="${Ce(a)}"`:"";n.push(`<pre class="pf-code"><code${c}>${l.join(`
|
|
4
|
+
`)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(o)){n.push("<hr />"),r++;continue}let i=/^(#{1,6})\s+(.+)$/.exec(o);if(i){let a=i[1].length;n.push(`<h${a}>${Oe(i[2])}</h${a}>`),r++;continue}if(o.startsWith("> ")||o===">"){let a=[];while(r<t.length&&(t[r].startsWith("> ")||t[r]===">"))a.push(t[r].replace(/^>\s?/,"")),r++;n.push(`<blockquote>${Qt(a.join(`
|
|
5
|
+
`))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(o)){n.push("<ul>");while(r<t.length&&/^[\s]*[-*+]\s+/.test(t[r]))n.push(`<li>${Oe(t[r].replace(/^[\s]*[-*+]\s+/,""))}</li>`),r++;n.push("</ul>");continue}if(/^[\s]*\d+\.\s+/.test(o)){n.push("<ol>");while(r<t.length&&/^[\s]*\d+\.\s+/.test(t[r]))n.push(`<li>${Oe(t[r].replace(/^[\s]*\d+\.\s+/,""))}</li>`),r++;n.push("</ol>");continue}if(o.trim()===""){r++;continue}let s=[];while(r<t.length&&t[r].trim()!==""&&!/^#{1,6}\s/.test(t[r])&&!/^[-*+]\s/.test(t[r])&&!/^\d+\.\s/.test(t[r])&&!t[r].startsWith("> ")&&!t[r].trimStart().startsWith("```")&&!/^(\s*[-*_]\s*){3,}$/.test(t[r]))s.push(t[r]),r++;n.push(`<p>${s.map(Oe).join("<br />")}</p>`)}return n.join(`
|
|
6
|
+
`)}function Ir(e,t){let n=document.createElement("kbd");return n.className="pf-kbd",n.textContent=C(e.content,t),n}function tn(){p("Card",Fr),p("CardHeader",at("pf-card-header")),p("CardTitle",en("pf-card-title","h3")),p("CardDescription",en("pf-card-description","p")),p("CardContent",at("pf-card-content")),p("CardFooter",at("pf-card-footer"))}function Fr(e,t){let n=m("div","pf-card");return n.style.overflow="hidden",H(e,n,t),n}function at(e){return(t,n)=>{let r=m("div",e);return r.style.padding="16px 24px",H(t,r,n),r}}function en(e,t){return(n,r)=>{let o=document.createElement(t);return o.className=e,o.textContent=C(n.content,r),o}}function nn(){p("DataTable",Br),p("Badge",Jr),p("Dot",zr),p("Metric",Wr),p("Ring",_r),p("Progress",Vr),p("Separator",Kr),p("Loader",Gr),p("Icon",qr),p("Sparkline",Ur)}function Br(e,t){let n=m("div","pf-datatable-wrapper"),r=document.createElement("table");r.className="pf-datatable",r.style.width="100%",r.style.borderCollapse="collapse";let o=e.columns??[],i=K(e.rows,t),s=e.rowKey,a=e.selected,l=document.createElement("thead"),c=document.createElement("tr");for(let d of o){let g=document.createElement("th");g.className="pf-datatable-th",g.textContent=d.header??d.key,g.style.padding="8px 12px",g.style.textAlign="left",c.appendChild(g)}l.appendChild(c),r.appendChild(l);let u=document.createElement("tbody");if(Array.isArray(i)){let d=a!=null?K(a,t):void 0;for(let g of i){let h=document.createElement("tr");h.className="pf-datatable-row";let y=g,f=g===null||typeof g!=="object";if(s&&d!=null&&y[s]!=null&&P(y[s])===P(d))h.classList.add("pf-datatable-row-selected");if(e.onRowClick!=null&&s)h.style.cursor="pointer",h.addEventListener("click",()=>{let b={...t.scope,$item:y,$index:i.indexOf(g)},w=V({...t,scope:b});F(j(e.onRowClick,w),"onRowClick")});for(let b of o){let w=document.createElement("td");w.className="pf-datatable-td";let S;if(b.accessor)S=K(`{{ $item.${b.accessor} }}`,{...t,scope:{...t.scope,$item:y}});else if(S=f?g:y[b.key],b.format&&S!=null)S=K(`{{ __fmtVal | ${b.format} }}`,{...t,scope:{...t.scope,__fmtVal:S}});w.textContent=P(S),w.style.padding="8px 12px",h.appendChild(w)}u.appendChild(h)}}if(r.appendChild(u),e.search===!0){let d=document.createElement("input");d.type="text",d.placeholder="Search...",d.className="pf-datatable-search",d.style.marginBottom="8px",d.style.padding="6px 12px",d.style.width="100%",d.style.boxSizing="border-box",d.addEventListener("input",()=>{let g=d.value.toLowerCase(),h=Array.from(u.querySelectorAll("tr"));for(let y of h){let f=(y.textContent??"").toLowerCase();y.style.display=f.includes(g)?"":"none"}}),n.appendChild(d)}return n.appendChild(r),n}function Jr(e,t){let n=m("span","pf-badge"),r=e.variant??"default";return n.setAttribute("data-variant",r),n.style.alignItems="center",n.style.padding="2px 10px",n.style.borderRadius="9999px",n.style.fontSize="12px",n.style.fontWeight="500",n.textContent=C(e.label??e.content,t),Xr(n,r),n}function zr(e,t){let n=m("span","pf-dot"),r=e.color??"gray";return n.style.display="inline-block",n.style.width="8px",n.style.height="8px",n.style.borderRadius="50%",n.style.backgroundColor=r,n}function Wr(e,t){let n=m("div","pf-metric"),r=m("div","pf-metric-label");r.textContent=C(e.label,t),r.style.fontSize="14px",n.appendChild(r);let o=m("div","pf-metric-value");if(o.textContent=C(e.value,t),o.style.fontSize="28px",o.style.fontWeight="700",n.appendChild(o),e.delta!=null){let i=m("span","pf-metric-delta");i.textContent=C(e.delta,t);let s=e.trend??"",a=e.trendSentiment??"neutral";if(i.style.fontSize="14px",i.style.color=a==="positive"?"green":a==="negative"?"red":"inherit",s==="up")i.textContent="↑ "+i.textContent;else if(s==="down")i.textContent="↓ "+i.textContent;n.appendChild(i)}if(e.description!=null){let i=m("div","pf-metric-desc");i.textContent=C(e.description,t),i.style.fontSize="12px",n.appendChild(i)}return n}function _r(e,t){let n=m("div","pf-ring"),r=e.size??80,o=e.thickness??8,i=Number(K(e.value,t)??0),s=Math.max(0,Math.min(100,i)),a=(r-o)/2,l=2*Math.PI*a,c=l*(1-s/100),u=document.createElementNS("http://www.w3.org/2000/svg","svg");u.setAttribute("width",String(r)),u.setAttribute("height",String(r)),u.setAttribute("viewBox",`0 0 ${r} ${r}`);let d=document.createElementNS("http://www.w3.org/2000/svg","circle");d.setAttribute("cx",String(r/2)),d.setAttribute("cy",String(r/2)),d.setAttribute("r",String(a)),d.setAttribute("fill","none"),d.setAttribute("stroke","var(--muted, #e5e7eb)"),d.setAttribute("stroke-width",String(o));let g=document.createElementNS("http://www.w3.org/2000/svg","circle");if(g.setAttribute("cx",String(r/2)),g.setAttribute("cy",String(r/2)),g.setAttribute("r",String(a)),g.setAttribute("fill","none"),g.setAttribute("stroke","var(--primary, #3b82f6)"),g.setAttribute("stroke-width",String(o)),g.setAttribute("stroke-dasharray",String(l)),g.setAttribute("stroke-dashoffset",String(c)),g.setAttribute("stroke-linecap","round"),g.style.transform="rotate(-90deg)",g.style.transformOrigin="center",u.appendChild(d),u.appendChild(g),n.appendChild(u),e.label!=null){let h=m("div","pf-ring-label");h.textContent=C(e.label,t),h.style.textAlign="center",h.style.fontSize="12px",n.appendChild(h)}return n}function Vr(e,t){let n=m("div","pf-progress");n.setAttribute("role","progressbar");let r=Number(K(e.value,t)??0),o=e.max??100,i=o>0?Math.max(0,Math.min(100,r/o*100)):0;n.setAttribute("aria-valuenow",String(r)),n.setAttribute("aria-valuemin","0"),n.setAttribute("aria-valuemax",String(o)),n.style.height="8px",n.style.borderRadius="4px",n.style.overflow="hidden";let s=m("div","pf-progress-fill");return s.style.height="100%",s.style.width=`${i}%`,s.style.borderRadius="4px",s.style.transition="width 0.3s ease",n.appendChild(s),n}function Kr(e,t){let n=document.createElement("hr");return n.className="pf-separator",n.style.border="none",n.style.margin="8px 0",n}function Gr(e,t){let n=m("div","pf-loader");return n.textContent="⏳",n.style.display="flex",n.style.justifyContent="center",n.style.padding="16px",n}function qr(e,t){let n=m("span","pf-icon");return n.setAttribute("data-icon",C(e.name??e.content,t)),n}function Ur(e,t){let n=m("div","pf-sparkline"),r=e.data??[];if(r.length===0)return n;let o=e.width??120,i=e.height??32,s=Math.max(...r),a=Math.min(...r),l=s-a||1,c=document.createElementNS("http://www.w3.org/2000/svg","svg");c.setAttribute("width",String(o)),c.setAttribute("height",String(i)),c.setAttribute("viewBox",`0 0 ${o} ${i}`);let u=r.length>1?r.length-1:1,d=r.map((h,y)=>{let f=y/u*o,b=i-(h-a)/l*(i-4)-2;return`${f},${b}`}).join(" "),g=document.createElementNS("http://www.w3.org/2000/svg","polyline");return g.setAttribute("points",d),g.setAttribute("fill","none"),g.setAttribute("stroke","var(--primary, #3b82f6)"),g.setAttribute("stroke-width","1.5"),c.appendChild(g),n.appendChild(c),n}function Xr(e,t){let r={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[t];if(r)e.style.backgroundColor=r.bg,e.style.color=r.fg}function on(){p("Form",Yr),p("Input",Zr),p("Textarea",ve(Qr)),p("Button",eo),p("ButtonGroup",to),p("Select",ve(no)),p("SelectOption",ro),p("SelectGroup",De("pf-select-group")),p("SelectLabel",we("pf-select-label")),p("SelectSeparator",rn),p("Checkbox",oo),p("Switch",io),p("Slider",ve(so)),p("Radio",lo),p("RadioGroup",co),p("Combobox",ve(po)),p("ComboboxOption",uo),p("ComboboxGroup",De("pf-combobox-group")),p("ComboboxLabel",we("pf-combobox-label")),p("ComboboxSeparator",rn),p("Calendar",fo),p("DatePicker",ve(mo)),p("Field",De("pf-field")),p("FieldTitle",we("pf-field-title")),p("FieldDescription",we("pf-field-description")),p("FieldContent",De("pf-field-content")),p("FieldError",we("pf-field-error")),p("ChoiceCard",go)}function Yr(e,t){let n=document.createElement("form");return n.className="pf-form",n.addEventListener("submit",(r)=>{r.preventDefault();let o=new FormData(n),i={};if(o.forEach((s,a)=>{i[a]=s}),t.store.merge(i),e.onSubmit!=null){let s=V(t);s.scope={...t.scope,...i},F(j(e.onSubmit,s),"onSubmit")}}),H(e,n,t),n}function sn(e,t,n){if(t.label==null)return;let r=document.createElement("label");if(r.className="pf-input-label",r.textContent=C(t.label,n),t.name!=null)r.htmlFor=t.name;r.style.fontSize="14px",r.style.fontWeight="500",e.insertBefore(r,e.firstChild)}function ve(e){return(t,n)=>{let r=e(t,n);return r.style.display="flex",r.style.flexDirection="column",r.style.gap="4px",sn(r,t,n),r}}function Zr(e,t){let n=m("div","pf-input-wrapper");n.style.display="flex",n.style.flexDirection="column",n.style.gap="4px",sn(n,e,t);let r=document.createElement("input");if(r.className="pf-input",r.type=e.inputType??"text",e.name!=null)r.name=e.name;if(e.name!=null)r.id=`pf-input-${e.name}`;if(e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.required===!0)r.required=!0,r.setAttribute("aria-required","true");if(e.error!=null)r.setAttribute("aria-invalid","true");let o=e.name;if(o){let i=t.store.get(o);if(i!=null)r.value=P(i);r.addEventListener("input",()=>{if(t.store.set(o,r.value),e.onChange!=null)F(j(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return lt(r),n.appendChild(r),n}function Qr(e,t){let n=m("div","pf-textarea-wrapper"),r=document.createElement("textarea");if(r.className="pf-textarea",e.name!=null)r.name=e.name;if(e.name!=null)r.id=`pf-textarea-${e.name}`;if(e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.rows!=null)r.rows=e.rows;if(e.required===!0)r.setAttribute("aria-required","true");let o=e.name;if(o!=null){let i=t.store.get(o);if(i!=null)r.value=P(i);r.addEventListener("input",()=>{if(t.store.set(o,r.value),e.onChange!=null)F(j(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return lt(r),n.appendChild(r),n}function eo(e,t){let n=document.createElement("button");n.className="pf-button",n.type=e.submit===!0?"submit":"button",n.textContent=C(e.label,t);let r=e.variant??"default";if(n.setAttribute("data-variant",r),ao(n,r),e.size!=null)n.setAttribute("data-size",e.size);if(e.disabled===!0)n.disabled=!0;return n}function to(e,t){let n=m("div","pf-button-group");return n.style.display="flex",n.style.gap="8px",H(e,n,t),n}function no(e,t){let n=m("div","pf-select-wrapper"),r=document.createElement("select");if(r.className="pf-select",e.name!=null)r.name=e.name;if(lt(r),e.placeholder!=null){let s=document.createElement("option");s.value="",s.textContent=C(e.placeholder,t),s.disabled=!0,s.selected=!0,s.hidden=!0,r.appendChild(s)}let o=e.options;if(Array.isArray(o))for(let s of o){let a=document.createElement("option");a.value=s.value??"",a.textContent=s.label??a.value,r.appendChild(a)}if(e.children)for(let s of e.children)if(s.type==="SelectOption"){let a=document.createElement("option");a.value=s.value??"",a.textContent=s.label??a.value,r.appendChild(a)}else r.appendChild(J(s,t));let i=e.name;if(i){let s=t.store.get(i);if(s!=null)r.value=P(s);r.addEventListener("change",()=>{if(t.store.set(i,r.value),e.onChange!=null)F(j(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return n.appendChild(r),n}function ro(e,t){return m("span")}function oo(e,t){let n=m("label","pf-checkbox-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="checkbox",r.className="pf-checkbox",e.name!=null)r.name=e.name;if(e.checked===!0)r.checked=!0;let o=e.name;if(o){let i=t.store.get(o);if(typeof i==="boolean")r.checked=i;r.addEventListener("change",()=>{if(t.store.set(o,r.checked),e.onChange!=null)F(j(e.onChange,{...V(t),scope:{...t.scope,$event:r.checked}}),"onChange")})}if(n.appendChild(r),e.label!=null){let i=m("span");i.textContent=C(e.label,t),n.appendChild(i)}return n}function io(e,t){let n=m("label","pf-switch-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="checkbox",r.className="pf-switch",r.setAttribute("role","switch"),e.name!=null)r.name=e.name;let o=e.name;if(o){let i=t.store.get(o);if(typeof i==="boolean")r.checked=i;r.addEventListener("change",()=>{if(t.store.set(o,r.checked),e.onChange!=null)F(j(e.onChange,{...V(t),scope:{...t.scope,$event:r.checked}}),"onChange")})}if(n.appendChild(r),e.label!=null){let i=m("span");i.textContent=C(e.label,t),n.appendChild(i)}return n}function so(e,t){let n=m("div","pf-slider-wrapper"),r=document.createElement("input");if(r.type="range",r.className="pf-slider",e.name!=null)r.name=e.name;if(e.min!=null)r.min=P(e.min);if(e.max!=null)r.max=P(e.max);if(e.step!=null)r.step=P(e.step);let o=e.name;if(o){let i=t.store.get(o);if(i!=null)r.value=P(i);r.addEventListener("input",()=>{if(t.store.set(o,Number(r.value)),e.onChange!=null)F(j(e.onChange,{...V(t),scope:{...t.scope,$event:Number(r.value)}}),"onChange")})}return n.appendChild(r),n}function lt(e){e.style.padding="8px 12px",e.style.fontSize="14px",e.style.width="100%",e.style.boxSizing="border-box"}function ao(e,t){if(e.style.padding="8px 16px",e.style.fontSize="14px",e.style.fontWeight="500",e.style.cursor="pointer",e.style.border="none",t==="ghost")e.style.backgroundColor="transparent",e.style.color="inherit"}function De(e){return(t,n)=>{let r=m("div",e);return H(t,r,n),r}}function we(e){return(t,n)=>{let r=m("span",e);return r.textContent=C(t.content,n),r}}function rn(){let e=document.createElement("hr");return e.className="pf-separator",e.style.border="none",e.style.margin="4px 0",e}function lo(e,t){let n=m("label","pf-radio");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="radio",r.value=C(e.value,t),n.appendChild(r),e.label!=null){let o=m("span","pf-radio-label");o.textContent=C(e.label,t),n.appendChild(o)}return n}function co(e,t){let n=m("fieldset","pf-radio-group");if(n.style.border="none",n.style.padding="0",n.style.display="flex",n.style.flexDirection="column",n.style.gap="8px",e.label!=null){let i=document.createElement("legend");i.textContent=C(e.label,t),i.style.fontWeight="500",i.style.marginBottom="4px",n.appendChild(i)}H(e,n,t);let r=C(e.name,t),o=t.store.get(r);for(let i of Array.from(n.querySelectorAll('input[type="radio"]')))if(i.name=r,o!=null&&i.value===P(o))i.checked=!0;return n.addEventListener("change",(i)=>{let s=i.target;if(s.type==="radio"){if(t.store.set(r,s.value),e.onChange!=null)F(j(e.onChange,V(t)),"onChange")}}),n}function po(e,t){let n=m("div","pf-combobox"),r=document.createElement("input");if(r.className="pf-combobox-input",r.type="text",r.name=C(e.name,t),e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.value!==void 0)r.value=C(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=P(i);r.style.padding="6px 12px",r.style.borderRadius="6px",r.style.width="100%",r.style.boxSizing="border-box";let s=m("div","pf-combobox-dropdown");if(s.style.display="none",s.style.position="absolute",s.style.borderRadius="6px",s.style.maxHeight="200px",s.style.overflowY="auto",s.style.zIndex="50",H(e,s,t),r.addEventListener("focus",()=>{s.style.display="block"}),r.addEventListener("blur",()=>{setTimeout(()=>{s.style.display="none"},150)}),e.searchable!==!1)r.addEventListener("input",()=>{let a=r.value.toLowerCase();for(let l of Array.from(s.querySelectorAll(".pf-combobox-option"))){let c=(l.textContent??"").toLowerCase();l.style.display=c.includes(a)?"":"none"}});if(e.onChange!=null)n.addEventListener("pf-combobox-select",()=>{F(j(e.onChange,{...V(t),scope:{...t.scope,$event:r.value}}),"onChange")});return n.style.position="relative",n.appendChild(r),n.appendChild(s),n}function uo(e,t){let n=m("div","pf-combobox-option");return n.style.padding="6px 12px",n.style.cursor="pointer",n.textContent=C(e.label??e.value,t),n.dataset.value=C(e.value,t),n.addEventListener("mousedown",()=>{let r=n.closest(".pf-combobox"),o=r?.querySelector("input");if(o)o.value=n.dataset.value??"",t.store.set(o.name,o.value),r?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),n}function fo(e,t){let n=m("div","pf-calendar"),r=document.createElement("input");if(r.type="date",r.name=C(e.name,t),e.value!==void 0)r.value=C(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=P(i);if(e.minDate!=null)r.min=C(e.minDate,t);if(e.maxDate!=null)r.max=C(e.maxDate,t);return r.style.padding="6px 12px",r.style.borderRadius="6px",r.addEventListener("change",()=>{if(t.store.set(r.name,r.value),e.onChange!=null)F(j(e.onChange,V(t)),"onChange")}),n.appendChild(r),n}function mo(e,t){let n=m("div","pf-datepicker"),r=document.createElement("input");if(r.type="date",r.name=C(e.name,t),e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.value!==void 0)r.value=C(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=P(i);if(e.minDate!=null)r.min=C(e.minDate,t);if(e.maxDate!=null)r.max=C(e.maxDate,t);return r.style.padding="6px 12px",r.style.borderRadius="6px",r.style.width="100%",r.style.boxSizing="border-box",r.addEventListener("change",()=>{if(t.store.set(r.name,r.value),e.onChange!=null)F(j(e.onChange,V(t)),"onChange")}),n.appendChild(r),n}function go(e,t){let n=m("div","pf-choice-card");if(n.style.padding="16px",n.style.cursor="pointer",n.style.transition="border-color 0.2s",n.dataset.value=C(e.value,t),e.selected===!0)n.dataset.selected="true";if(e.label!=null){let r=m("div","pf-choice-card-label");r.textContent=C(e.label,t),r.style.fontWeight="600",n.appendChild(r)}if(e.description!=null){let r=m("div","pf-choice-card-description");r.textContent=C(e.description,t),r.style.fontSize="14px",n.appendChild(r)}return H(e,n,t),n}function an(){p("Tabs",ho),p("Tab",bo),p("Accordion",yo),p("AccordionItem",Co),p("Dialog",vo),p("Popover",wo),p("Tooltip",xo),p("HoverCard",ko),p("Carousel",So)}function ho(e,t){let n=m("div","pf-tabs"),r=m("div","pf-tabs-bar");r.setAttribute("role","tablist"),r.style.display="flex",r.style.gap="4px",r.style.marginBottom="12px";let o=[],i=[],s=e.children??[],a=(()=>{let c=e.defaultTab;if(typeof c==="number")return c>=0&&c<s.length?c:0;if(typeof c==="string"){let u=s.findIndex((d)=>d.title===c);return u>=0?u:0}return 0})();if(e.children)for(let c=0;c<e.children.length;c++){let u=e.children[c],d=`pf-tab-${Math.random().toString(36).slice(2,8)}`,g=`pf-panel-${Math.random().toString(36).slice(2,8)}`,h=document.createElement("button");h.type="button",h.className="pf-tab-trigger",h.textContent=u.title??`Tab ${c+1}`,h.setAttribute("role","tab"),h.setAttribute("aria-selected",c===a?"true":"false"),h.setAttribute("aria-controls",g),h.id=d,h.tabIndex=c===a?0:-1,h.style.padding="8px 16px",h.style.border="none",h.style.background="none",h.style.cursor="pointer",h.style.borderBottom="2px solid transparent",h.style.marginBottom="-2px",h.style.fontSize="14px";let y=m("div","pf-tab-panel");if(y.style.display=c===a?"block":"none",y.setAttribute("role","tabpanel"),y.setAttribute("aria-labelledby",d),y.id=g,y.tabIndex=0,H(u,y,t),h.addEventListener("click",()=>{l(c)}),c===a)h.classList.add("pf-tab-active"),h.style.fontWeight="600";i.push(h),o.push(y),r.appendChild(h)}function l(c){o.forEach((u)=>u.style.display="none"),i.forEach((u)=>{u.style.borderBottomColor="transparent",u.style.fontWeight="normal",u.classList.remove("pf-tab-active"),u.setAttribute("aria-selected","false"),u.tabIndex=-1}),o[c].style.display="block",i[c].classList.add("pf-tab-active"),i[c].style.fontWeight="600",i[c].setAttribute("aria-selected","true"),i[c].tabIndex=0,i[c].focus()}r.addEventListener("keydown",(c)=>{let u=i.indexOf(c.target);if(u<0)return;let d;if(c.key==="ArrowRight")d=(u+1)%i.length;else if(c.key==="ArrowLeft")d=(u-1+i.length)%i.length;else if(c.key==="Home")d=0;else if(c.key==="End")d=i.length-1;else return;c.preventDefault(),l(d)}),n.appendChild(r);for(let c of o)n.appendChild(c);return n}function bo(e,t){let n=m("div","pf-tab");return H(e,n,t),n}function yo(e,t){let n=m("div","pf-accordion");return H(e,n,t),n}function Co(e,t){let n=m("div","pf-accordion-item"),r=`pf-acc-${Math.random().toString(36).slice(2,8)}`,o=document.createElement("button");o.type="button",o.className="pf-accordion-trigger",o.textContent=e.title??"",o.setAttribute("aria-expanded","false"),o.setAttribute("aria-controls",r),o.style.width="100%",o.style.textAlign="left",o.style.padding="12px 0",o.style.border="none",o.style.background="none",o.style.cursor="pointer",o.style.fontSize="14px",o.style.fontWeight="500";let i=m("div","pf-accordion-content");return i.id=r,i.setAttribute("role","region"),i.setAttribute("aria-labelledby",o.id),i.style.display="none",i.style.paddingBottom="12px",H(e,i,t),o.addEventListener("click",()=>{let s=i.style.display!=="none";i.style.display=s?"none":"block",o.setAttribute("aria-expanded",s?"false":"true")}),n.appendChild(o),n.appendChild(i),n}function vo(e,t){let n=m("div","pf-dialog-wrapper");if(e.trigger!=null){let i=J(e.trigger,t);i.addEventListener("click",()=>{r.showModal()}),n.appendChild(i)}let r=document.createElement("dialog");if(r.className="pf-dialog",r.setAttribute("aria-modal","true"),r.style.maxWidth="500px",r.style.width="100%",r.style.padding="24px",e.title!=null){let i=m("h2","pf-dialog-title");i.textContent=C(e.title,t),i.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,r.setAttribute("aria-labelledby",i.id),r.appendChild(i)}if(e.description!=null){let i=m("p","pf-dialog-desc");i.textContent=C(e.description,t),r.appendChild(i)}let o=m("div","pf-dialog-body");if(H(e,o,t),r.appendChild(o),e.dismissible!==!1)r.addEventListener("click",(i)=>{if(i.target===r)r.close()});return document.addEventListener("prefab:close-overlay",()=>r.close()),n.appendChild(r),n}function wo(e,t){let n=m("div","pf-popover");n.style.position="relative",n.style.display="inline-block";let r=m("div","pf-popover-content");if(r.style.display="none",r.style.position="absolute",r.style.zIndex="50",r.style.padding="12px",r.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",e.title!=null){let i=m("div","pf-popover-title");i.textContent=C(e.title,t),i.style.fontWeight="600",i.style.marginBottom="4px",r.appendChild(i)}H(e,r,t);let o=()=>{r.style.display=r.style.display==="none"?"block":"none"};if(e.trigger!=null){let i=J(e.trigger,t);i.addEventListener("click",(s)=>{s.stopPropagation(),o()}),n.appendChild(i)}else n.addEventListener("click",(i)=>{if(r.contains(i.target)&&r.style.display!=="none")return;o()});return n.appendChild(r),n}function xo(e,t){let n=m("div","pf-tooltip");n.style.position="relative",n.style.display="inline-block";let r=`pf-tip-${Math.random().toString(36).slice(2,8)}`,o=m("div","pf-tooltip-content");return o.id=r,o.setAttribute("role","tooltip"),o.textContent=C(e.content??"",t),o.style.display="none",o.style.position="absolute",o.style.bottom="100%",o.style.left="50%",o.style.transform="translateX(-50%)",o.style.padding="4px 8px",o.style.borderRadius="4px",o.style.color="#fff",o.style.fontSize="12px",o.style.whiteSpace="nowrap",o.style.zIndex="50",H(e,n,t),n.setAttribute("aria-describedby",r),n.addEventListener("mouseenter",()=>{o.style.display="block"}),n.addEventListener("mouseleave",()=>{o.style.display="none"}),n.addEventListener("focus",()=>{o.style.display="block"},!0),n.addEventListener("blur",()=>{o.style.display="none"},!0),n.appendChild(o),n}function ko(e,t){let n=m("div","pf-hover-card");n.style.position="relative",n.style.display="inline-block";let r=m("div","pf-hover-card-content");if(r.style.display="none",r.style.position="absolute",r.style.zIndex="50",r.style.padding="16px",r.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",r.style.minWidth="200px",e.trigger!=null)n.appendChild(J(e.trigger,t));return H(e,r,t),n.addEventListener("mouseenter",()=>{r.style.display="block"}),n.addEventListener("mouseleave",()=>{r.style.display="none"}),n.appendChild(r),n}function So(e,t){let n=m("div","pf-carousel");n.style.position="relative",n.style.overflow="hidden",n.setAttribute("role","region"),n.setAttribute("aria-roledescription","carousel"),n.setAttribute("aria-label",C(e.label??"Carousel",t));let r=m("div","pf-carousel-track");r.style.display="flex",r.style.transition="transform 0.3s ease",H(e,r,t);let o=0,i=e.children?.length??0,s=document.createElement("button");s.type="button",s.textContent="‹",s.className="pf-carousel-prev",s.setAttribute("aria-label","Previous slide"),s.style.position="absolute",s.style.left="4px",s.style.top="50%",s.style.transform="translateY(-50%)",s.style.zIndex="10";let a=document.createElement("button");a.type="button",a.textContent="›",a.className="pf-carousel-next",a.setAttribute("aria-label","Next slide"),a.style.position="absolute",a.style.right="4px",a.style.top="50%",a.style.transform="translateY(-50%)",a.style.zIndex="10";let l=()=>{r.style.transform=`translateX(-${o*100}%)`};return s.addEventListener("click",()=>{if(i===0)return;o=Math.max(0,o-1),l()}),a.addEventListener("click",()=>{if(i===0)return;o=Math.min(i-1,o+1),l()}),n.appendChild(r),n.appendChild(s),n.appendChild(a),n}function ln(){p("ForEach",Eo),p("If",dn),p("Elif",Ao),p("Else",Ro),p("Condition",To),p("Define",No),p("Use",Mo),p("Slot",Lo)}function Eo(e,t){let n=document.createDocumentFragment(),r=e.expression;if(!r)return n;let o;if(Q(r)){let s=ee(r,t.store,t.scope);o=Array.isArray(s)?s:[]}else{let s=t.store.get(r);o=Array.isArray(s)?s:[]}let i=e.let??{};for(let s=0;s<o.length;s++){let a=o[s],l={...t.scope,$item:a,$index:s,...i},c={...t,scope:l};if(e.children)se(e.children,n,c)}return n}function dn(e,t){if(cn(e.condition,t)){let r=document.createDocumentFragment();if(e.children)se(e.children,r,t);return r}return document.createDocumentFragment()}function Ao(e,t){return dn(e,t)}function Ro(e,t){let n=document.createDocumentFragment();if(e.children)se(e.children,n,t);return n}function cn(e,t){if(!e)return!1;if(Q(e))return Boolean(ee(e,t.store,t.scope));return Boolean(t.store.get(e))}function To(e,t){let n=document.createDocumentFragment(),r=e.cases,o=e.else;if(r){for(let i of r)if(cn(i.when,t)){if(i.children)se(i.children,n,t);return n}}if(o)se(o,n,t);return n}function No(e,t){let n=e.name;if(n&&e.children)t.templates=t.templates??{},t.templates[n]=e.children;return document.createDocumentFragment()}function Mo(e,t){let n=document.createDocumentFragment(),r=e.def??e.name,o=t.templates?.[r];if(!o)return n;let i=e.overrides??{},s={...t.scope,...i},a={...t.slots??{},...e.slots??{}};if(Array.isArray(e.children))a.default=e.children;let l={...t,scope:s,slots:a};for(let c of o)n.appendChild(J(c,l));return n}function Lo(e,t){let n=document.createDocumentFragment(),r=e.name??"default",i=t.slots?.[r]??e.children;if(i)for(let s of i)n.appendChild(J(s,t));return n}function pn(){p("Alert",Ho),p("AlertTitle",Po),p("AlertDescription",$o)}function Ho(e,t){let n=m("div","pf-alert");n.setAttribute("role","alert");let r=e.variant??"default";if(n.setAttribute("data-variant",r),n.style.padding="12px 16px",e.icon!=null){let o=m("span","pf-alert-icon");o.setAttribute("data-icon",e.icon),o.style.marginRight="8px",n.appendChild(o)}return H(e,n,t),n}function Po(e,t){let n=m("h5","pf-alert-title");return n.textContent=C(e.content,t),n.style.fontWeight="600",n.style.marginBottom="4px",n}function $o(e,t){let n=m("p","pf-alert-description");return n.textContent=C(e.content,t),n.style.fontSize="14px",n}function un(){p("Image",Oo),p("Audio",Do),p("Video",jo),p("Embed",Io),p("Svg",Bo),p("DropZone",zo),p("Mermaid",Wo)}function Oo(e,t){let n=document.createElement("img");if(n.className="pf-image",n.src=C(e.src,t),e.alt!=null)n.alt=C(e.alt,t);if(e.width!=null)n.width=e.width;if(e.height!=null)n.height=e.height;return n.style.maxWidth="100%",n}function Do(e,t){let n=document.createElement("audio");return n.className="pf-audio",n.src=C(e.src,t),n.controls=!0,n}function jo(e,t){let n=document.createElement("video");if(n.className="pf-video",n.src=C(e.src,t),n.controls=!0,e.width!=null)n.width=e.width;if(e.height!=null)n.height=e.height;return n.style.maxWidth="100%",n}function Io(e,t){let n=m("div","pf-embed"),r=document.createElement("iframe");return r.src=C(e.src,t),r.style.width="100%",r.style.height=e.height!=null?`${e.height}px`:"400px",r.style.border="none",r.setAttribute("sandbox","allow-scripts"),n.appendChild(r),n}var Fo=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 Bo(e,t){let n=m("div","pf-svg"),r=C(e.content,t);if(!r.includes("<svg"))return n;if(!/<svg[^>]*\sxmlns\s*=/.test(r))r=r.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"');let i=new DOMParser().parseFromString(r,"image/svg+xml").querySelector("svg");if(!i)return n;return fn(i),n.appendChild(document.importNode(i,!0)),n}function fn(e){let t=Array.from(e.children);for(let n of t){if(!Fo.has(n.tagName.toLowerCase())){n.remove();continue}for(let r of Array.from(n.attributes)){let o=r.name.toLowerCase();if(o.startsWith("on")||o==="href"&&r.value.trim().toLowerCase().startsWith("javascript:"))n.removeAttribute(r.name)}fn(n)}}function Jo(e,t){let n=(t??"").split(",").map((i)=>i.trim().toLowerCase()).filter(Boolean);if(n.length===0)return!0;let r=e.name.toLowerCase(),o=e.type.toLowerCase();return n.some((i)=>{if(i.startsWith("."))return r.endsWith(i);if(i.endsWith("/*"))return o.startsWith(i.slice(0,-1));return o===i})}function zo(e,t){let n=m("div","pf-dropzone");n.style.padding="32px",n.style.textAlign="center",n.style.cursor="pointer",n.textContent=C(e.label??"Drop files here",t);let r=document.createElement("input");if(r.type="file",r.style.display="none",e.accept!=null)r.accept=e.accept;if(e.multiple===!0)r.multiple=!0;n.appendChild(r),n.setAttribute("role","button"),n.tabIndex=0;function o(s){let a=Array.from(s??[]).filter((l)=>Jo(l,e.accept));return e.multiple===!0?a:a.slice(0,1)}function i(s){if(s.length===0)return;if(e.resultKey!=null)t.store.set(e.resultKey,s),t.rerender();if(e.onDrop!=null)F(j(e.onDrop,{...V(t),scope:{...t.scope,$result:s}}),"onDrop")}return r.addEventListener("change",()=>{i(o(r.files)),r.value=""}),n.addEventListener("click",()=>r.click()),n.addEventListener("keydown",(s)=>{if(s.key==="Enter"||s.key===" ")s.preventDefault(),r.click()}),n.addEventListener("dragover",(s)=>{s.preventDefault(),n.classList.add("pf-dropzone-active")}),n.addEventListener("dragleave",()=>{n.classList.remove("pf-dropzone-active")}),n.addEventListener("drop",(s)=>{s.preventDefault(),n.classList.remove("pf-dropzone-active"),i(o(s.dataTransfer?.files??null))}),n}function Wo(e,t){let n=m("div","pf-mermaid");n.setAttribute("data-mermaid","true");let r=C(e.content,t);if(n.textContent=r,typeof globalThis.mermaid<"u")n.classList.add("mermaid"),n.textContent=r;return n}var _o="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",Vo="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",dt=null,je=null;async function Ko(){if(dt)return dt;if(je)return je;return je=import(_o).then((e)=>{let t=e;return t.GlobalWorkerOptions.workerSrc=Vo,dt=t,t}),je}function gn(){p("PdfViewer",Go)}function Go(e,t){let n=m("div","pf-pdf-viewer"),r=e.src!=null?C(e.src,t):void 0,o=e.data,i=e.page!=null?e.page:1,s=e.zoom!=null?e.zoom:"fit-width",a=e.toolbar!==!1,l=e.height!=null?e.height:600;n.style.height=`${l}px`,n.style.display="flex",n.style.flexDirection="column",n.style.overflow="hidden",n.style.border="1px solid var(--color-border-primary, #e5e7eb)",n.style.borderRadius="var(--border-radius-md, 0.375rem)",n.style.background="var(--color-background-secondary, #f9fafb)";let c=m("div","pf-pdf-loading");return c.textContent="Loading PDF…",c.style.display="flex",c.style.alignItems="center",c.style.justifyContent="center",c.style.flex="1",c.style.color="var(--color-text-secondary, #6b7280)",n.appendChild(c),qo(n,c,{src:r,data:o,initialPage:i,zoom:s,showToolbar:a}),n}async function qo(e,t,n){try{let r=await Ko(),o;if(n.src)o={url:n.src};else if(n.data){let g=atob(n.data),h=new Uint8Array(g.length);for(let y=0;y<g.length;y++)h[y]=g.charCodeAt(y);o={data:h}}else{t.textContent="Error: No PDF source provided";return}let i=await r.getDocument(o).promise;t.remove();let s=Math.max(1,Math.min(n.initialPage,i.numPages)),a=null,l=null;if(n.showToolbar){let g=Uo(i.numPages,s,{onPrev:()=>{if(s>1)s--,d()},onNext:()=>{if(s<i.numPages)s++,d()},onPageChange:(h)=>{let y=Math.max(1,Math.min(h,i.numPages));if(y!==s)s=y,d()}});a=g.pageInput,l=g.pageCount,e.insertBefore(g.el,e.firstChild)}let c=m("div","pf-pdf-canvas-container");c.style.flex="1",c.style.overflow="auto",c.style.display="flex",c.style.justifyContent="center",c.style.padding="8px",e.appendChild(c);let u=document.createElement("canvas");u.style.display="block",u.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",c.appendChild(u);async function d(){let g=await i.getPage(s),h=c.clientWidth-16,y,f=g.getViewport({scale:1});if(n.zoom==="fit-width")y=h/f.width;else if(n.zoom==="fit-page"){let S=c.clientHeight-16,N=h/f.width,k=S/f.height;y=Math.min(N,k)}else y=typeof n.zoom==="number"?n.zoom:1;let b=g.getViewport({scale:y});u.width=b.width,u.height=b.height,u.style.width=`${b.width}px`,u.style.height=`${b.height}px`;let w=u.getContext("2d");if(!w)return;if(await g.render({canvasContext:w,viewport:b}).promise,a)a.value=String(s);if(l)l.textContent=`/ ${i.numPages}`}await d()}catch(r){t.textContent=`PDF Error: ${r instanceof Error?r.message:String(r)}`,t.style.color="var(--color-text-danger, #dc2626)"}}function Uo(e,t,n){let r=m("div","pf-pdf-toolbar");r.style.display="flex",r.style.alignItems="center",r.style.gap="8px",r.style.padding="6px 12px",r.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",r.style.background="var(--color-background-primary, #fff)",r.style.flexShrink="0",r.style.fontSize="13px";let o=document.createElement("button");o.textContent="‹",o.title="Previous page",o.className="pf-pdf-btn",mn(o),o.addEventListener("click",n.onPrev);let i=document.createElement("button");i.textContent="›",i.title="Next page",i.className="pf-pdf-btn",mn(i),i.addEventListener("click",n.onNext);let s=document.createElement("input");s.type="number",s.min="1",s.max=String(e),s.value=String(t),s.style.width="48px",s.style.textAlign="center",s.style.border="1px solid var(--color-border-primary, #e5e7eb)",s.style.borderRadius="4px",s.style.padding="2px 4px",s.style.fontSize="13px",s.addEventListener("change",()=>{let l=parseInt(s.value,10);if(!isNaN(l))n.onPageChange(l)});let a=document.createElement("span");return a.textContent=`/ ${e}`,a.style.color="var(--color-text-secondary, #6b7280)",r.appendChild(o),r.appendChild(s),r.appendChild(a),r.appendChild(i),{el:r,pageInput:s,pageCount:a}}function mn(e){e.style.border="1px solid var(--color-border-primary, #e5e7eb)",e.style.borderRadius="4px",e.style.background="var(--color-background-primary, #fff)",e.style.cursor="pointer",e.style.padding="2px 8px",e.style.fontSize="16px",e.style.lineHeight="1"}var Fe=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function ce(e,t){let n=document.createElement("div");return n.className="pf-chart-tooltip",e.appendChild(n),e.addEventListener("mouseleave",()=>{n.classList.remove("pf-visible")}),{wrapper:e,tooltip:n,svgEl:t}}function te(e,t,n,r,o){let{tooltip:i,svgEl:s,wrapper:a}=e;if(o.length===0)return;let l="";if(r)l+=`<div class="pf-chart-tooltip-label">${Ie(r)}</div>`;for(let b of o)l+='<div class="pf-chart-tooltip-row">',l+=`<span class="pf-chart-tooltip-dot" style="background:${Ie(b.color)}"></span>`,l+=`<span>${Ie(b.label)}:</span> <strong>${Ie(String(b.value))}</strong>`,l+="</div>";i.innerHTML=l;let c=s.getBoundingClientRect(),u=a.getBoundingClientRect(),d=s.viewBox.baseVal,g=c.width/(d.width||1),h=c.left-u.left+t*g,y=i.offsetWidth||100,f=h+12;if(f+y>u.width)f=h-y-12;i.style.left=`${Math.max(0,f)}px`,i.style.top="4px",i.classList.add("pf-visible")}function Ie(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function hn(e,t,n,r,o,i,s,a){let l=o.plotWidth/n.length;for(let c=0;c<n.length;c++){let u=o.plotLeft+c*l,d=document.createElementNS("http://www.w3.org/2000/svg","rect");d.setAttribute("x",String(u)),d.setAttribute("y",String(o.plotTop)),d.setAttribute("width",String(l)),d.setAttribute("height",String(o.plotHeight)),d.setAttribute("fill","transparent"),d.style.cursor="default";let g=i?n[c][i]:void 0,h=g!=null?a?a(g):P(g):void 0,y=r.map((S,N)=>({label:S.label??S.dataKey,value:s(n[c][S.dataKey],S,N),color:S.color??Fe[N%Fe.length]})),f=u+l/2,b=()=>te(e,f,o.plotTop,h,y),w=()=>e.tooltip.classList.remove("pf-visible");d.addEventListener("mouseenter",b),d.addEventListener("mouseleave",w),d.addEventListener("touchstart",b,{passive:!0}),d.addEventListener("touchend",w,{passive:!0}),t.appendChild(d)}}function bn(e,t,n,r,o,i,s,a,l,c){let u=n.length===1?o.plotWidth:o.plotWidth/(n.length-1);for(let d=0;d<n.length;d++){let g=n.length===1?(o.plotLeft+o.plotRight)/2:o.plotLeft+d/(n.length-1)*o.plotWidth,h=n.length===1?o.plotLeft:g-u/2,y=n.length===1?o.plotWidth:u,f=document.createElementNS("http://www.w3.org/2000/svg","rect");f.setAttribute("x",String(Math.max(o.plotLeft,h))),f.setAttribute("y",String(o.plotTop)),f.setAttribute("width",String(Math.min(y,o.plotRight-Math.max(o.plotLeft,h)))),f.setAttribute("height",String(o.plotHeight)),f.setAttribute("fill","transparent"),f.style.cursor="default";let b=i?n[d][i]:void 0,w=b!=null?c?c(b):P(b):void 0,S=r.map((R,L)=>({label:R.label??R.dataKey,value:s(n[d][R.dataKey],R,L),color:R.color??Fe[L%Fe.length]})),N=()=>{if(te(e,g,o.plotTop,w,S),a)a.setAttribute("x1",String(g)),a.setAttribute("x2",String(g)),a.setAttribute("opacity","1");if(l)for(let R of l){for(let L of R)L.setAttribute("data-visible","false");R[d]?.setAttribute("data-visible","true")}},k=()=>{if(e.tooltip.classList.remove("pf-visible"),a)a.setAttribute("opacity","0");if(l)for(let R of l)for(let L of R)L.setAttribute("data-visible","false")};f.addEventListener("mouseenter",N),f.addEventListener("mouseleave",k),f.addEventListener("touchstart",N,{passive:!0}),f.addEventListener("touchend",k,{passive:!0}),t.appendChild(f)}}var q=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],re="var(--muted-foreground, #6b7280)",he="var(--border, #e5e7eb)",pe="10";function Be(e,t,n,r=!1){let o=n?44:0,i=e-(r?44:0),s=10,a=t-24;return{plotLeft:o,plotRight:i,plotTop:10,plotBottom:a,plotWidth:i-o,plotHeight:a-10}}function yn(e,t=5){if(e<=0)return[0];let n=e/t,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r,i=o<=1.5?r:o<=3?2*r:o<=7?5*r:10*r,s=[];for(let a=0;a<=e+i*0.01;a+=i)s.push(Math.round(a*1000)/1000);return s}function ct(e,t,n,r,o){let i=yn(n);for(let s of i){let a=t.plotBottom-(n>0?s/n*t.plotHeight:0),l=U("text",{x:t.plotLeft-6,y:a+3,"text-anchor":"end","font-size":pe,fill:re});if(l.textContent=ft(s,o),e.appendChild(l),r&&s>0)e.appendChild(U("line",{x1:t.plotLeft,y1:a,x2:t.plotRight,y2:a,stroke:he,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function pt(e,t,n,r){let o=yn(n);for(let i of o){let s=t.plotBottom-(n>0?i/n*t.plotHeight:0),a=U("text",{x:t.plotRight+6,y:s+3,"text-anchor":"start","font-size":pe,fill:re});a.textContent=ft(i,r),e.appendChild(a)}}function ut(e,t,n,r,o,i){for(let s=0;s<t.length;s++){let a=t[s][n],l=U("text",{x:r(s),y:o+14,"text-anchor":"middle","font-size":pe,fill:re});l.textContent=a==null?"":i?i(a):P(a),e.appendChild(l)}}function Je(e,t){e.appendChild(U("line",{x1:t.plotLeft,y1:t.plotBottom,x2:t.plotRight,y2:t.plotBottom,stroke:re,"stroke-width":1}))}function ne(e,t,n){if(e==null)return"";let r=K(`{{ __v | ${t} }}`,{...n,scope:{...n.scope,__v:e}});return P(r??e)}function ft(e,t){if(t==="currency")return`$${e.toLocaleString()}`;if(t==="percent")return`${e}%`;if(e>=1e6)return`${(e/1e6).toFixed(1)}M`;if(e>=1000)return`${(e/1000).toFixed(1)}K`;return String(e)}function oe(e){let t=e.yAxisFormat??e.valueFormat;return t&&t!=="auto"?t:void 0}function mt(e,t,n){return(r,o)=>{if(r===null||r===void 0)return"—";if(o.tooltipFormat)return ne(r,o.tooltipFormat,e);let i=o.yAxisId==="right"?n:t;return ft(Number(r),i)}}function ae(e,t,n){let r=document.createElementNS("http://www.w3.org/2000/svg","svg");if(r.setAttribute("width","100%"),r.setAttribute("height",String(t)),r.setAttribute("viewBox",`0 0 ${e} ${t}`),r.setAttribute("role","img"),n)r.setAttribute("aria-label",`${n} chart`);return r.style.overflow="visible",r}function U(e,t){let n=document.createElementNS("http://www.w3.org/2000/svg",e);for(let[r,o]of Object.entries(t))n.setAttribute(r,String(o));return n}function ze(e,t){let n=U("text",e);return n.textContent=t,n}function ue(e,t,n,r){let o=r*Math.PI/180;return{x:e+n*Math.cos(o),y:t-n*Math.sin(o)}}function gt(e,t,n,r,o){let i=Math.max(2,Math.ceil(Math.abs(o-r)/4)),s=[];for(let a=0;a<=i;a++){let l=ue(e,t,n,r+(o-r)*a/i);s.push(`${a===0?"M":"L"} ${l.x.toFixed(2)} ${l.y.toFixed(2)}`)}return s.join(" ")}function fe(e,t,n){if(n===!1||t.length<=1)return;let r=m("div","pf-chart-legend");r.style.display="flex",r.style.gap="12px",r.style.fontSize="12px",r.style.marginBottom="8px";for(let o=0;o<t.length;o++){let i=m("div","pf-chart-legend-item");i.style.display="flex",i.style.alignItems="center",i.style.gap="4px";let s=m("span");s.style.width="8px",s.style.height="8px",s.style.borderRadius="50%",s.style.backgroundColor=t[o].color??q[o%q.length];let a=m("span");a.textContent=t[o].label??t[o].dataKey,i.appendChild(s),i.appendChild(a),r.appendChild(i)}e.appendChild(r)}function vn(){p("BarChart",Xo),p("LineChart",Cn),p("AreaChart",Cn),p("PieChart",Yo),p("RadarChart",ei),p("ScatterChart",Zo),p("RadialChart",Qo),p("Histogram",ti)}function Xo(e,t){let n=m("div","pf-chart pf-bar-chart"),r=K(e.data,t)??[],o=e.series??[],i=e.height??300;if(r.length===0||o.length===0)return n.textContent="No chart data",n;let s=e.showYAxis!==!1,a=e.showGrid===!0,l=e.showYAxisRight===!0,c=e.showTooltip!==!1,u=e.xAxis,d=e.tooltipXKey,g=e.xAxisFormat,h=e.tooltipXFormat,y=o.filter((x)=>x.yAxisId!=="right"),f=o.filter((x)=>x.yAxisId==="right"),b=l&&f.length>0,w=y.length>0?Math.max(...r.flatMap((x)=>y.map((v)=>Number(x[v.dataKey]??0))),1):1,S=b?Math.max(...r.flatMap((x)=>f.map((v)=>Number(x[v.dataKey]??0))),1):1,N=400,k=Be(N,i,s,b),R=ae(N,i,"Bar");if(s)ct(R,k,w,a,oe(e));if(b)pt(R,k,S,e.yAxisRightFormat);Je(R,k);let L=k.plotWidth/r.length,M=L/(o.length+1);for(let x=0;x<r.length;x++)for(let v=0;v<o.length;v++){let T=o[v],D=r[x][T.dataKey];if(D===null||D===void 0)continue;let G=T.yAxisId==="right"?S:w,B=Number(D),E=Math.max(0,B/G*k.plotHeight),W=k.plotLeft+x*L+v*M+M/2,A=document.createElementNS("http://www.w3.org/2000/svg","rect");A.setAttribute("x",String(W)),A.setAttribute("y",String(k.plotBottom-E)),A.setAttribute("width",String(M*0.8)),A.setAttribute("height",String(E)),A.setAttribute("fill",T.color??q[v%q.length]),A.setAttribute("rx","2"),R.appendChild(A)}if(u){let x=g?(v)=>ne(v,g,t):void 0;ut(R,r,u,(v)=>k.plotLeft+v*L+L/2,k.plotBottom,x)}if(c){let x=ce(n,R),v=mt(t,oe(e),e.yAxisRightFormat);hn(x,R,r,o,k,d??u,v,h?(D)=>ne(D,h,t):void 0)}return fe(n,o,e.showLegend),n.appendChild(R),n}function Cn(e,t){let n=m("div",`pf-chart pf-${e.type.toLowerCase()}-chart`),r=K(e.data,t)??[],o=e.series??[],i=e.height??300;if(r.length===0||o.length===0)return n.textContent="No chart data",n;let s=e.showYAxis!==!1,a=e.showGrid===!0,l=e.showYAxisRight===!0,c=e.showTooltip!==!1,u=e.xAxis,d=e.tooltipXKey,g=e.xAxisFormat,h=e.tooltipXFormat,y=o.filter((v)=>v.yAxisId!=="right"),f=o.filter((v)=>v.yAxisId==="right"),b=l&&f.length>0,w=y.length>0?Math.max(...r.flatMap((v)=>y.map((T)=>Number(v[T.dataKey]??0))),1):1,S=b?Math.max(...r.flatMap((v)=>f.map((T)=>Number(v[T.dataKey]??0))),1):1,N=400,k=Be(N,i,s,b),R=ae(N,i,e.type==="AreaChart"?"Area":"Line"),L=e.type==="AreaChart";if(s)ct(R,k,w,a,oe(e));if(b)pt(R,k,S,e.yAxisRightFormat);Je(R,k);let M=[];for(let v=0;v<o.length;v++){let T=o[v],D=T.yAxisId==="right",z=D?S:w,G=T.color??q[v%q.length],B=r.map((A,I)=>{let _=A[T.dataKey],X=_===null||_===void 0,le=r.length===1?(k.plotLeft+k.plotRight)/2:k.plotLeft+I/(r.length-1)*k.plotWidth,Bn=X?k.plotBottom:k.plotBottom-Number(_)/z*k.plotHeight;return{x:le,y:Bn,isNull:X}});if(L){let A=[],I=()=>{if(A.length<2){A=[];return}let _=`M ${A[0].x},${k.plotBottom} `+A.map((le)=>`L ${le.x},${le.y}`).join(" ")+` L ${A[A.length-1].x},${k.plotBottom} Z`,X=document.createElementNS("http://www.w3.org/2000/svg","path");X.setAttribute("d",_),X.setAttribute("fill",G),X.setAttribute("opacity","0.15"),R.appendChild(X),A=[]};for(let _ of B){if(_.isNull){I();continue}A.push(_)}I()}let E="";for(let A of B){if(A.isNull)continue;let I=B.indexOf(A),_=I===0||B[I-1].isNull;E+=`${_?"M":"L"} ${A.x},${A.y} `}if(E){let A=document.createElementNS("http://www.w3.org/2000/svg","path");if(A.setAttribute("d",E.trim()),A.setAttribute("fill","none"),A.setAttribute("stroke",G),A.setAttribute("stroke-width","2"),D)A.setAttribute("stroke-dasharray","6 3");R.appendChild(A)}let W=[];for(let A of B){let I=document.createElementNS("http://www.w3.org/2000/svg","circle");if(I.setAttribute("cx",String(A.x)),I.setAttribute("cy",String(A.y)),I.setAttribute("r","4"),I.setAttribute("fill",G),I.setAttribute("class","pf-data-dot"),I.setAttribute("data-visible","false"),I.style.pointerEvents="none",A.isNull)I.style.display="none";R.appendChild(I),W.push(I)}M.push(W)}let x=document.createElementNS("http://www.w3.org/2000/svg","line");if(x.setAttribute("class","pf-crosshair"),x.setAttribute("x1",String(k.plotLeft)),x.setAttribute("x2",String(k.plotLeft)),x.setAttribute("y1",String(k.plotTop)),x.setAttribute("y2",String(k.plotBottom)),x.setAttribute("stroke",re),x.setAttribute("stroke-width","1"),x.setAttribute("stroke-dasharray","3 3"),x.setAttribute("opacity","0"),R.appendChild(x),u){let v=g?(T)=>ne(T,g,t):void 0;ut(R,r,u,(T)=>r.length===1?(k.plotLeft+k.plotRight)/2:k.plotLeft+T/(r.length-1)*k.plotWidth,k.plotBottom,v)}if(c){let v=ce(n,R),T=mt(t,oe(e),e.yAxisRightFormat);bn(v,R,r,o,k,d??u,T,x,M,h?(z)=>ne(z,h,t):void 0)}return fe(n,o,e.showLegend),n.appendChild(R),n}function Yo(e,t){let n=m("div","pf-chart pf-pie-chart"),r=K(e.data,t)??[],o=e.series??[],i=e.height??300,s=Math.min(i,300),a=e.showTooltip!==!1,l=e.dataKey??o[0]?.dataKey,c=e.nameKey??e.tooltipXKey??e.xAxis,u=o.length>0?o:l?[{dataKey:l,label:l}]:[];if(r.length===0||!l)return n.textContent="No chart data",n;let d=ae(s,s,"Pie"),g=s/2,h=s/2,y=s/2-10,f=e.tooltipXFormat,b=oe(e),w=(L)=>b?ne(L,b,t):String(L),S=r.map((L)=>Number(L[l]??0)),N=S.reduce((L,M)=>L+M,0);if(N===0)return n.textContent="No chart data",n.appendChild(d),n;let k=a?ce(n,d):void 0,R=-Math.PI/2;for(let L=0;L<S.length;L++){let M=S[L]/N*2*Math.PI,x=R+M,v=M>Math.PI?1:0,T=g+y*Math.cos(R),D=h+y*Math.sin(R),z=g+y*Math.cos(x),G=h+y*Math.sin(x),B=q[L%q.length],E=document.createElementNS("http://www.w3.org/2000/svg","path");if(E.setAttribute("d",`M ${g},${h} L ${T},${D} A ${y},${y} 0 ${v} 1 ${z},${G} Z`),E.setAttribute("fill",B),E.style.cursor="default",k){let W=c?r[L][c]:void 0,A=W!=null?f?ne(W,f,t):P(W):`Slice ${L+1}`,I=`${(S[L]/N*100).toFixed(1)}%`,_=R+M/2,X=g+y*0.6*Math.cos(_);E.addEventListener("mouseenter",()=>{te(k,X,h,A,[{label:u[0].label??l,value:`${w(S[L])} (${I})`,color:B}])}),E.addEventListener("mouseleave",()=>{k.tooltip.classList.remove("pf-visible")}),E.addEventListener("touchstart",()=>{te(k,X,h,A,[{label:u[0].label??l,value:`${w(S[L])} (${I})`,color:B}])},{passive:!0}),E.addEventListener("touchend",()=>{k.tooltip.classList.remove("pf-visible")},{passive:!0})}d.appendChild(E),R=x}return fe(n,u,e.showLegend),n.appendChild(d),n}function Zo(e,t){let n=m("div","pf-chart pf-scatter-chart"),r=K(e.data,t)??[],o=e.xAxis,i=e.yAxis,s=e.zAxis,a=e.series??[],l=e.height??300;if(r.length===0||!o||!i)return n.textContent="No chart data",n;let c=e.showGrid!==!1,u=e.showTooltip!==!1,d=a[0]?.color??q[0],g=oe(e),h=(E)=>g?ne(E,g,t):String(Math.round(E*100)/100),y=r.map((E)=>Number(E[o]??0)),f=r.map((E)=>Number(E[i]??0)),b=Math.min(...y),w=Math.max(...y),S=Math.min(...f),N=Math.max(...f),k=w-b||1,R=N-S||1,L=s?r.map((E)=>Number(E[s]??0)):[],M=s?Math.max(...L,1):1,x=400,v=Be(x,l,!0),T=ae(x,l,"Scatter"),D=(E)=>v.plotLeft+(E-b)/k*v.plotWidth,z=(E)=>v.plotBottom-(E-S)/R*v.plotHeight,G=4;for(let E=0;E<=G;E++){let W=S+R*E/G,A=z(W);if(T.appendChild(ze({x:v.plotLeft-6,y:A+3,"text-anchor":"end","font-size":pe,fill:re},h(W))),c&&E>0)T.appendChild(U("line",{x1:v.plotLeft,y1:A,x2:v.plotRight,y2:A,stroke:he,"stroke-width":1,"stroke-dasharray":"4 3"}))}Je(T,v);for(let E of[b,(b+w)/2,w])T.appendChild(ze({x:D(E),y:v.plotBottom+14,"text-anchor":"middle","font-size":pe,fill:re},String(Math.round(E*100)/100)));let B=u?ce(n,T):void 0;for(let E=0;E<r.length;E++){let W=D(y[E]),A=z(f[E]),I=s?4+Math.sqrt(L[E]/M)*14:4,_=U("circle",{cx:W,cy:A,r:I,fill:d,"fill-opacity":s?0.6:0.85});if(B){let X=[{label:o,value:h(y[E]),color:d},{label:i,value:h(f[E]),color:d},...s?[{label:s,value:h(L[E]),color:d}]:[]],le=a[0]?.label??"Point";_.addEventListener("mouseenter",()=>te(B,W,A,le,X)),_.addEventListener("mouseleave",()=>B.tooltip.classList.remove("pf-visible")),_.addEventListener("touchstart",()=>te(B,W,A,le,X),{passive:!0}),_.addEventListener("touchend",()=>B.tooltip.classList.remove("pf-visible"),{passive:!0})}T.appendChild(_)}return fe(n,a,e.showLegend),n.appendChild(T),n}function Qo(e,t){let n=m("div","pf-chart pf-radial-chart"),r=K(e.data,t)??[],o=e.series??[],i=e.dataKey??o[0]?.dataKey,s=e.nameKey??e.tooltipXKey??e.xAxis,a=e.height??300;if(r.length===0||!i)return n.textContent="No chart data",n;let l=Math.min(a,300),c=l/2,u=l/2,d=l/2-10,g=Math.max(0,Math.min(e.innerRadius??30,d-10)),h=e.startAngle??180,y=e.endAngle??0,f=e.showTooltip!==!1,b=r.map((v)=>Number(v[i]??0)),w=Math.max(...b,1),S=ae(l,l,"Radial"),N=(d-g)/r.length,k=Math.max(2,N*0.7),R=oe(e),L=(v)=>R?ne(v,R,t):String(v),M=f?ce(n,S):void 0,x=[];for(let v=0;v<r.length;v++){let T=d-N*v-N/2,D=o[v]?.color??q[v%q.length],z=b[v]/w,G=h+z*(y-h),B=s?r[v][s]:null,E=B!=null?P(B):o[v]?.label??i;x.push({dataKey:E||i,label:E||i,color:D}),S.appendChild(U("path",{d:gt(c,u,T,h,y),fill:"none",stroke:he,"stroke-width":k,"stroke-linecap":"round"}));let W=U("path",{d:gt(c,u,T,h,G),fill:"none",stroke:D,"stroke-width":k,"stroke-linecap":"round"});if(M){let A=ue(c,u,T,(h+G)/2),I=[{label:i,value:L(b[v]),color:D}],_=E||i;W.addEventListener("mouseenter",()=>te(M,A.x,A.y,_,I)),W.addEventListener("mouseleave",()=>M.tooltip.classList.remove("pf-visible")),W.addEventListener("touchstart",()=>te(M,A.x,A.y,_,I),{passive:!0}),W.addEventListener("touchend",()=>M.tooltip.classList.remove("pf-visible"),{passive:!0})}S.appendChild(W)}return fe(n,x,e.showLegend),n.appendChild(S),n}function ei(e,t){let n=m("div","pf-chart pf-radar-chart"),r=K(e.data,t)??[],o=e.series??[],i=e.axisKey??e.xAxis,s=e.height??300;if(r.length===0||o.length===0)return n.textContent="No chart data",n;let a=e.filled!==!1,l=e.showDots===!0,c=e.showGrid!==!1,u=e.showTooltip!==!1,d=Math.min(s,320),g=d/2,h=d/2,y=d/2-24,f=r.length,b=Math.max(...r.flatMap((M)=>o.map((x)=>Number(M[x.dataKey]??0))),1),w=(M)=>90-360*M/f,S=(M)=>M.map((x)=>`${x.x.toFixed(1)},${x.y.toFixed(1)}`).join(" "),N=ae(d,d,"Radar");if(c){for(let x=1;x<=4;x++){let v=y*x/4,T=Array.from({length:f},(D,z)=>ue(g,h,v,w(z)));N.appendChild(U("polygon",{points:S(T),fill:"none",stroke:he,"stroke-width":1}))}for(let x=0;x<f;x++){let v=ue(g,h,y,w(x));N.appendChild(U("line",{x1:g,y1:h,x2:v.x,y2:v.y,stroke:he,"stroke-width":1}))}}for(let M=0;M<f;M++){let x=ue(g,h,y+12,w(M)),v=i?r[M][i]:null;N.appendChild(ze({x:x.x,y:x.y+3,"text-anchor":"middle","font-size":pe,fill:re},v!=null?String(v):""))}let k=u?ce(n,N):void 0,R=oe(e),L=(M)=>R?ne(M,R,t):String(M);for(let M=0;M<o.length;M++){let x=o[M],v=x.color??q[M%q.length],T=r.map((D,z)=>ue(g,h,Number(D[x.dataKey]??0)/b*y,w(z)));if(N.appendChild(U("polygon",{points:S(T),fill:a?v:"none","fill-opacity":a?0.2:0,stroke:v,"stroke-width":2})),l||k)for(let D=0;D<T.length;D++){let z=U("circle",{cx:T[D].x,cy:T[D].y,r:l?3:6,fill:l?v:"transparent","fill-opacity":l?1:0});if(k){let G=i?r[D][i]:null,B=G!=null?P(G):x.label??x.dataKey,E=[{label:x.label??x.dataKey,value:L(Number(r[D][x.dataKey]??0)),color:v}];z.addEventListener("mouseenter",()=>te(k,T[D].x,T[D].y,B,E)),z.addEventListener("mouseleave",()=>k.tooltip.classList.remove("pf-visible")),z.addEventListener("touchstart",()=>te(k,T[D].x,T[D].y,B,E),{passive:!0}),z.addEventListener("touchend",()=>k.tooltip.classList.remove("pf-visible"),{passive:!0})}N.appendChild(z)}}return fe(n,o,e.showLegend),n.appendChild(N),n}function ti(e,t){let n=m("div","pf-chart pf-histogram"),r=K(e.data,t);if(!r||r.length===0)return n.textContent="No data",n;let o=r,i=e.bins??10,s=e.height??200,a=e.color??q[0],l=Math.min(...o),u=(Math.max(...o)-l)/i||1,d=Array(i).fill(0);for(let w of o){let S=Math.min(Math.floor((w-l)/u),i-1);d[S]++}let g=Math.max(...d),h=300,y=s,f=h/i,b=ae(h,y,"Histogram");for(let w=0;w<i;w++){let S=g>0?d[w]/g*y:0,N=document.createElementNS("http://www.w3.org/2000/svg","rect");N.setAttribute("x",String(w*f)),N.setAttribute("y",String(y-S)),N.setAttribute("width",String(f-1)),N.setAttribute("height",String(S)),N.setAttribute("fill",a),b.appendChild(N)}return n.appendChild(b),n}function wn(){p("Table",ni),p("TableHead",ht("thead")),p("TableBody",ht("tbody")),p("TableFooter",ht("tfoot")),p("TableRow",ri),p("TableHeader",oi),p("TableCell",ii),p("TableCaption",si),p("ExpandableRow",ai)}function ni(e,t){let n=document.createElement("table");return n.className=e.striped===!0?"pf-table pf-table-striped":"pf-table",n.style.width="100%",n.style.borderCollapse="collapse",H(e,n,t),n}function ht(e){return(t,n)=>{let r=document.createElement(e);return r.className=`pf-${e}`,H(t,r,n),r}}function ri(e,t){let n=document.createElement("tr");return n.className="pf-table-row",H(e,n,t),n}function oi(e,t){let n=document.createElement("th");return n.className="pf-table-header",n.style.textAlign="left",n.style.padding="8px 12px",n.style.fontWeight="600",n.textContent=C(e.content,t),n}function ii(e,t){let n=document.createElement("td");if(n.className="pf-table-cell",n.style.padding="8px 12px",e.colSpan!=null)n.colSpan=e.colSpan;if(e.rowSpan!=null)n.rowSpan=e.rowSpan;return H(e,n,t),n}function si(e,t){let n=document.createElement("caption");return n.className="pf-table-caption",n.style.padding="8px",n.style.fontSize="14px",n.textContent=C(e.content,t),n}function ai(e,t){let n=m("div","pf-expandable-row"),r=m("div","pf-expandable-row-summary");r.style.cursor="pointer",r.style.display="flex",r.style.alignItems="center",r.style.gap="8px";let o=m("span","pf-expandable-arrow");o.textContent="▶",o.style.transition="transform 0.2s",o.style.fontSize="10px",r.appendChild(o);let i=e.summary;if(i)for(let l of i)r.appendChild(J(l,t));let s=m("div","pf-expandable-row-detail");s.style.display="none",s.style.paddingLeft="24px",H(e,s,t);let a=!1;return r.addEventListener("click",()=>{a=!a,s.style.display=a?"block":"none",o.style.transform=a?"rotate(90deg)":""}),n.appendChild(r),n.appendChild(s),n}var xn=!1;function We(){if(xn)return;xn=!0;let e=new Set(it());qt(),Zt(),tn(),nn(),on(),an(),ln(),pn(),un(),gn(),vn(),wn(),_t(it().filter((t)=>!e.has(t)))}function yt(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}function Ct(e){return e.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function bt(e,t=" "){return Object.entries(e).map(([n,r])=>`${t}--${yt(n)}: ${Ct(r)};`).join(`
|
|
7
|
+
`)}function kn(e){if(!e)return"";let t=[];if(e.light&&Object.keys(e.light).length>0)t.push(`:root {
|
|
8
|
+
${bt(e.light)}
|
|
9
|
+
}`);if(e.dark&&Object.keys(e.dark).length>0){let n=bt(e.dark);t.push(`.dark, [data-theme="dark"] {
|
|
10
|
+
${n}
|
|
11
|
+
}`),t.push(`@media (prefers-color-scheme: dark) {
|
|
12
12
|
:root:not([data-theme="light"]):not(.light) {
|
|
13
|
-
${
|
|
13
|
+
${bt(e.dark," ")}
|
|
14
14
|
}
|
|
15
|
-
}`)}return
|
|
16
|
-
`)}function E1($,Z){$.setAttribute("data-theme",Z),$.classList.toggle("dark",Z==="dark"),$.classList.toggle("light",Z==="light")}function K0($,Z){if(!Z)return;if(Z.light)for(let[J,q]of Object.entries(Z.light))$.style.setProperty(`--${z0(J)}`,E0(q));if(Z.dark){let q=document.getElementById("prefab-dark-theme");if(!q)q=document.createElement("style"),q.id="prefab-dark-theme",document.head.appendChild(q);q.textContent=E4({dark:Z.dark})}}function F0($,Z){if(!$||typeof document>"u")return;let J=(q)=>{for(let[Q,Y]of Object.entries($))if(e6(Q,q))q.preventDefault(),Z(Y)};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)}function e6($,Z){let J=$.toLowerCase().split("+").map((Y)=>Y.trim()),q=J[J.length-1],Q=new Set(J.slice(0,-1));if(Q.has("ctrl")!==(Z.ctrlKey||Z.metaKey))return!1;if(Q.has("shift")!==Z.shiftKey)return!1;if(Q.has("alt")!==Z.altKey)return!1;return Z.key.toLowerCase()===q}var K4='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"/></svg>',F4='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"/></svg>',L4={"top-right":"top: 8px; right: 8px;","top-left":"top: 8px; left: 8px;","bottom-right":"bottom: 8px; right: 8px;","bottom-left":"bottom: 8px; left: 8px;"};function $5($,Z){try{let q=localStorage.getItem(Z);if(q==="light"||q==="dark")return q}catch{}let J=$.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(J==="light"||J==="dark")return J;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function L0($,Z){if(typeof document>"u")return()=>{};let J=Z?.position??"top-right",q=Z?.storageKey??"prefab-theme",Q=Z?.syncDocument??!0,Y=getComputedStyle($).position;if(Y==="static"||Y==="")$.style.position="relative";let U=document.createElement("button");U.className="pf-theme-toggle",U.setAttribute("aria-label","Toggle theme"),U.setAttribute("title","Toggle light/dark"),Object.assign(U.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let H=L4[J]??L4["top-right"];for(let W of H.split(";")){let[B,K]=W.split(":").map((L)=>L.trim());if(B&&K)U.style.setProperty(B,K)}U.addEventListener("mouseenter",()=>{U.style.opacity="1"}),U.addEventListener("mouseleave",()=>{U.style.opacity="0.7"});function G(W){if(E1($,W),Q)E1(document.documentElement,W);U.innerHTML=W==="dark"?F4:K4;try{localStorage.setItem(q,W)}catch{}}let _=$5($,q);G(_),U.addEventListener("click",()=>{let W=$.getAttribute("data-theme")??"dark";G(W==="dark"?"light":"dark")}),$.appendChild(U);let z;if(Q)z=new MutationObserver((W)=>{for(let B of W)if(B.type==="attributes"&&B.attributeName==="data-theme"){let K=document.documentElement.getAttribute("data-theme");if((K==="light"||K==="dark")&&K!==$.getAttribute("data-theme")){E1($,K),U.innerHTML=K==="dark"?F4:K4;try{localStorage.setItem(q,K)}catch{}}}}),z.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{z?.disconnect(),U.remove()}}function x1($){let Z=$?.baseUrl??(typeof window<"u"?window.location.origin:""),J={"Content-Type":"application/json",...$?.headers},q=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(Q,Y){let U=await q(`${Z}/mcp/tools/call`,{method:"POST",headers:J,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:Q,arguments:Y}})});if(!U.ok)throw Error(`MCP tool call failed: ${U.status} ${U.statusText}`);let H=await U.json();if(H.error)throw Error(H.error.message??"MCP tool call returned error");let G=H.result?.content??H.content??[];for(let _ of G)if(_.type==="text"&&_.text!==void 0){try{let z=JSON.parse(_.text);if(typeof z==="object"&&z!==null&&"$prefab"in z)return z;return z}catch{}return _.text}return H.result??H},async sendMessage(Q){await q(`${Z}/mcp/messages`,{method:"POST",headers:J,body:JSON.stringify({message:Q})})}}}function p1(){return{callTool($){return b.warn(`No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return b.warn("No MCP transport: sendMessage ignored",$),Promise.resolve()}}}var D4="0.3.8";function Z5($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class D1{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;_hostSupportsSubscriptions=!1;constructor($="*"){this.hostOrigin=$}connect(){if(typeof window>"u")return;let $=Q5();if($)this.postFn=(J)=>$.postMessage(J);let Z=(J)=>{if(this.hostOrigin!=="*"&&J.origin!==this.hostOrigin)return;let q=J.data;if(Z5(q)){this.handleJsonRpc(q);return}let Q=q;if(!Q?.type.startsWith("prefab:"))return;if(Q.type==="prefab:tool-call-response"&&Q.id){let U=this.pending.get(Q.id);if(U){if(this.pending.delete(Q.id),Q.payload?.error!=null)U.reject(Error(Q.payload.error));else U.resolve(Q.payload?.result);return}}let Y=this.listeners.get(Q.type);if(Y)for(let U of Y)U(Q.payload??{})};window.addEventListener("message",Z),this.cleanup=()=>window.removeEventListener("message",Z)}async initialize($){try{return await Promise.any([this.initPrefab($),this.initJsonRpc($)])}catch(Z){let J=Z instanceof AggregateError?Z.errors.map((q)=>q.message).join("; "):String(Z);throw Error(`Bridge init failed — no host responded. Tried: ${J}`,{cause:Z})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:$});else this.sendPrefab("prefab:request-mode",{mode:$})}openLink($,Z){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:Z});else this.sendPrefab("prefab:open-link",{url:$,target:Z})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}setupAutoResize($){if(typeof ResizeObserver>"u")return J5;let Z=-1,J=-1,q=(U,H)=>{if(U===Z&&H===J)return;if(Z=U,J=H,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:U,height:H});else this.sendPrefab("prefab:size-changed",{width:U,height:H})},Q=new ResizeObserver((U)=>{for(let H of U)if(H.borderBoxSize.length){let G=H.borderBoxSize[0];q(Math.ceil(G.inlineSize),Math.ceil(G.blockSize))}else{let G=H.target.getBoundingClientRect();q(Math.ceil(G.width),Math.ceil(G.height))}});Q.observe($);let Y=$.getBoundingClientRect();return q(Math.ceil(Y.width),Math.ceil(Y.height)),()=>Q.disconnect()}notifyPreferredSize($){if(this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/preferred-size",$);else this.sendPrefab("prefab:preferred-size",$)}subscribe($,Z){let J=(q)=>{if(q.uri!==$)return;Z(q.contents??q.data??q)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",J),this.sendRpcRequest("resources/subscribe",{uri:$});else this.on("prefab:resource-updated",J),this.sendPrefab("prefab:subscribe",{uri:$});return()=>{if(this.off("prefab:resource-updated",J),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:$});else this.sendPrefab("prefab:unsubscribe",{uri:$})}}get supportsSubscriptions(){return this._hostSupportsSubscriptions}on($,Z){if(!this.listeners.has($))this.listeners.set($,new Set);let J=this.listeners.get($);if(J)J.add(Z)}off($,Z){this.listeners.get($)?.delete(Z)}disconnect(){this.cleanup?.(),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((Z,J)=>{let q=!1,Q=(Y)=>{if(q)return;q=!0,this.off("prefab:init-response",Q),this.protocol="prefab";let U=Y.capabilities;this._hostSupportsSubscriptions=U?.subscriptions===!0,Z(Y)};this.on("prefab:init-response",Q),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!q)q=!0,this.off("prefab:init-response",Q),J(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,Z)=>{let J=`tc-${++this.callIdCounter}`;return new Promise((q,Q)=>{this.pending.set(J,{resolve:q,reject:Q}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:Z},J),setTimeout(()=>{if(this.pending.has(J))this.pending.delete(J),Q(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()},subscribe:($,Z)=>{return this.subscribe($,Z)},capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendPrefab($,Z,J){if(typeof window>"u")return;let q=window.parent!==window?window.parent:window,Q={type:$,payload:Z,id:J};q.postMessage(Q,this.hostOrigin)}handleJsonRpc($){if(!("method"in $)){let q=this.rpcPending.get($.id);if(q)if(this.rpcPending.delete($.id),$.error)q.reject(Error($.error.message));else q.resolve($.result);return}let Z=$.method,J=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(Z){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:J.arguments??J});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:J.arguments??J});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:J});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",J);break;case"ui/notifications/host-context-changed":{let q={};if(typeof J.theme==="string")q.colorScheme=J.theme;if(typeof J.styles==="object"&&J.styles!==null){let Q=J.styles;if(Q.variables)q.variables=Q.variables;if(typeof Q.css?.fonts==="string")q.fontCss=Q.css.fonts}this.dispatch("prefab:theme-update",q),this.dispatch("prefab:host-context-changed",J);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",J);break;case"ui/notifications/resource-updated":case"notifications/resources/updated":this.dispatch("prefab:resource-updated",J);break}}initJsonRpc($){return new Promise((Z,J)=>{let q=++this.rpcIdCounter,Q=!1;this.rpcPending.set(q,{resolve:(Y)=>{if(Q)return;Q=!0,this.protocol="jsonrpc";let U=Y??{},H=U.hostInfo??{},G=U.hostContext??{},_=U.hostCapabilities??{},z;if(typeof G.theme==="string"||typeof G.styles==="object"){if(z={},typeof G.theme==="string")z.colorScheme=G.theme;if(typeof G.styles==="object"&&G.styles!==null){let B=G.styles;if(B.variables)z.variables=B.variables;if(typeof B.css?.fonts==="string")z.fontCss=B.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let W=_.resources;this._hostSupportsSubscriptions=_.subscriptions===!0||W?.subscribe===!0,Z({hostName:H.name,hostVersion:H.version,capabilities:{toast:!0,navigation:_.openLinks!=null,messaging:!0,displayModes:G.availableDisplayModes??[]},theme:z,toolInput:void 0,meta:G})},reject:(Y)=>{if(Q)return;Q=!0,J(Y)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:D4},appCapabilities:{...$.displayModes&&{availableDisplayModes:$.displayModes}}}}),setTimeout(()=>{if(!Q)Q=!0,this.rpcPending.delete(q),J(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,Z)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:Z})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})},subscribe:($,Z)=>{return this.subscribe($,Z)},capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendRpcRequest($,Z){let J=++this.rpcIdCounter;return new Promise((q,Q)=>{this.rpcPending.set(J,{resolve:q,reject:Q}),this.postJsonRpc({jsonrpc:"2.0",id:J,method:$,params:Z}),setTimeout(()=>{if(this.rpcPending.has(J))this.rpcPending.delete(J),Q(Error(`JSON-RPC '${$}' timed out`))},30000)})}sendRpcNotification($,Z){this.postJsonRpc({jsonrpc:"2.0",method:$,params:Z})}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)}dispatch($,Z){let J=this.listeners.get($);if(J)for(let q of J)q(Z)}}var J5=()=>{};function D0($,Z){if(Z.variables)for(let[J,q]of Object.entries(Z.variables))$.style.setProperty(J.startsWith("--")?J:`--${J}`,q);if(Z.colorScheme&&Z.colorScheme!=="auto")$.setAttribute("data-theme",Z.colorScheme);if(Z.fontCss)q5(Z.fontCss)}function q5($){if(document.getElementById("__prefab-host-fonts"))return;let J=document.createElement("style");J.id="__prefab-host-fonts",J.textContent=$,document.head.appendChild(J)}function c1(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function Q5(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let Z=$.acquireVsCodeApi();if(Z!==null&&typeof Z==="object"&&"postMessage"in Z)return Z}catch{return}return}var T4=["Accordion","AccordionItem","Alert","AlertDescription","AlertTitle","AreaChart","Audio","Badge","BarChart","BlockQuote","Button","ButtonGroup","Calendar","Card","CardContent","CardDescription","CardFooter","CardHeader","CardTitle","Carousel","Checkbox","ChoiceCard","Code","Column","Combobox","ComboboxGroup","ComboboxLabel","ComboboxOption","ComboboxSeparator","Condition","Container","Dashboard","DashboardItem","DataTable","DatePicker","Define","Detail","Dialog","Div","Dot","DropZone","Elif","Else","Embed","ExpandableRow","Field","FieldContent","FieldDescription","FieldError","FieldTitle","ForEach","Form","Grid","GridItem","H1","H2","H3","H4","Heading","Histogram","HoverCard","Icon","If","Image","Input","Kbd","Label","Large","Lead","LineChart","Link","Loader","Markdown","MasterDetail","Mermaid","Metric","Muted","P","Page","Pages","PdfViewer","PieChart","Popover","Progress","RadarChart","RadialChart","Radio","RadioGroup","Ring","Row","ScatterChart","Select","SelectGroup","SelectLabel","SelectOption","SelectSeparator","Separator","Slider","Slot","Small","Span","Sparkline","Svg","Switch","Tab","Table","TableBody","TableCaption","TableCell","TableFooter","TableHead","TableHeader","TableRow","Tabs","Text","Textarea","Tooltip","Use","Video"];var V4=new Set(T4);function O0($,Z={}){let J=[],q=Z.strict??!1;if($==null||typeof $!=="object")return J.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:J};let Q=$;if(Q.$prefab==null||typeof Q.$prefab!=="object")J.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof Q.$prefab.version!=="string")J.push({path:"$.$prefab.version",message:"version must be a string"});if(Q.view==null)J.push({path:"$.view",message:'Missing required "view" field'});else T0(Q.view,"$.view",J,q);if(Q.state!==void 0){if(Q.state===null||typeof Q.state!=="object"||Array.isArray(Q.state))J.push({path:"$.state",message:"state must be a plain object"})}if(Q.theme!==void 0)U5(Q.theme,J);if(Q.css!==void 0)I4(Q.css,"$.css",J);if(Q.stylesheets!==void 0)I4(Q.stylesheets,"$.stylesheets",J);if(Q.mode!==void 0&&Q.mode!=="light"&&Q.mode!=="dark")J.push({path:"$.mode",message:'mode must be "light" or "dark"'});if(Q.defs!==void 0)if(Q.defs===null||typeof Q.defs!=="object"||Array.isArray(Q.defs))J.push({path:"$.defs",message:"defs must be a plain object"});else for(let[Y,U]of Object.entries(Q.defs))T0(U,`$.defs.${Y}`,J,q);if(Q.keyBindings!==void 0)if(Q.keyBindings===null||typeof Q.keyBindings!=="object"||Array.isArray(Q.keyBindings))J.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[Y,U]of Object.entries(Q.keyBindings))I0(U,`$.keyBindings.${Y}`,J);return{valid:J.length===0,errors:J}}function T0($,Z,J,q){if($==null||typeof $!=="object"||Array.isArray($)){J.push({path:Z,message:"Component must be a plain object"});return}let Q=$;if(typeof Q.type!=="string"||Q.type.length===0){J.push({path:`${Z}.type`,message:'Component must have a non-empty "type" string'});return}if(q&&!V4.has(Q.type))J.push({path:`${Z}.type`,message:`Unknown component type: "${Q.type}"`});if(Q.children!==void 0)if(!Array.isArray(Q.children))J.push({path:`${Z}.children`,message:"children must be an array"});else for(let U=0;U<Q.children.length;U++)T0(Q.children[U],`${Z}.children[${U}]`,J,q);let Y=["onClick","on_click","onChange","on_change","onSubmit","on_submit","onMount","on_mount","onClose","on_close"];for(let U of Y)if(Q[U]!==void 0)I0(Q[U],`${Z}.${U}`,J);for(let[U,H]of Object.entries(Q)){if(U==="type"||Y5.has(U)||Y.includes(U))continue;if(O4(H)||Array.isArray(H)&&H.some(O4))J.push({path:`${Z}.${U}`,message:`Components under "${U}" are ignored by the renderer; move them into "children"`})}}var Y5=new Set(["children","fallback","trigger","empty","else","summary"]);function O4($){if($==null||typeof $!=="object"||Array.isArray($))return!1;let Z=$.type;return typeof Z==="string"&&V4.has(Z)}function I0($,Z,J){if(Array.isArray($)){for(let H=0;H<$.length;H++)I0($[H],`${Z}[${H}]`,J);return}if($==null||typeof $!=="object"){J.push({path:Z,message:"Action must be an object or array of objects"});return}let q=$,Q=typeof q.type==="string"&&q.type.length>0,Y=typeof q.action==="string"&&q.action.length>0;if(!Q&&!Y){J.push({path:`${Z}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if((Y?q.action:q.type).toLowerCase()==="showtoast"){if(typeof q.message!=="string"||q.message.length===0)J.push({path:`${Z}.message`,message:'showToast requires a non-empty "message" string'})}}function I4($,Z,J){if(!Array.isArray($)){J.push({path:Z,message:`${Z} must be an array of strings`});return}for(let q=0;q<$.length;q++)if(typeof $[q]!=="string")J.push({path:`${Z}[${q}]`,message:"must be a string"})}function U5($,Z){if($===null||typeof $!=="object"||Array.isArray($)){Z.push({path:"$.theme",message:"theme must be a plain object"});return}let J=$;for(let q of["light","dark"])if(J[q]!==void 0){if(J[q]===null||typeof J[q]!=="object"||Array.isArray(J[q]))Z.push({path:`$.theme.${q}`,message:`theme.${q} must be a plain object`})}}var o={mount($,Z,J){if(u1(),J?.validate!==!1)for(let E of O0(Z).errors)b.warn(`wire validation ${E.path}: ${E.message}`);let q=Z,Q={tracked:[],evalBlocked:!1};if(q.pipes)for(let[E,T]of Object.entries(q.pipes))P4(E,T,Q);let Y=new K1(q.state),U;if(J?.transport&&"callTool"in J.transport)U=J.transport;else if(J?.transport)U=x1(J.transport);else U=p1();let H=J?.onToast??W5,G=new J0;function _(E){let T=E;if(q=T,T.state)Y.merge(T.state);if(T.defs)z.defs=T.defs;if(T.theme)K0($,T.theme);if(T.mode)R4($,T.mode);if(T.pipes)for(let[V,A]of Object.entries(T.pipes))P4(V,A,Q);for(let V of W)V.remove();if(W.length=0,W.push(...j4(T.css,T.stylesheets)),k4($,T.layout),B?.(),B=void 0,T.keyBindings)B=F0(T.keyBindings,(V)=>{v(h(V,{store:Y,transport:U,scope:{},rerender:()=>M(),remount:_,onToast:H}),"keyBinding")});M()}let z={store:Y,scope:{},transport:U,rerender:()=>M(),remount:_,onToast:H,defs:q.defs,destroyRegistry:G};if(K0($,q.theme),q.mode)R4($,q.mode);k4($,q.layout);let W=j4(q.css,q.stylesheets),B;if(q.keyBindings)B=F0(q.keyBindings,(E)=>{v(h(E,{store:Y,transport:U,scope:{},rerender:()=>M(),remount:_,onToast:H}),"keyBinding")});let K,L=J?.themeToggle??!0;if(L!==!1)K=L0($,typeof L==="object"?L:void 0);function M(){G.flush();let E=$.querySelector(".pf-theme-toggle");$.innerHTML="";let T=u(q.view,z);if($.appendChild(T),E)$.appendChild(E)}return M(),{rerender:()=>M(),update(E){if(Y.merge(E.update.state),M(),E.update.actions!=null)v(h(E.update.actions,z),"update action")},store:Y,destroy(){G.flush(),K?.(),B?.(),m0(),h0();for(let E of W)E.remove();for(let E of Q.tracked)s1(E);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},H5=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 G5($){if($ instanceof EvalError)return!0;return $ instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test($.message)}function P4($,Z,J){if(H5.has($)){b.warn(`wire pipe "${$}" ignored — shadows built-in`);return}if(T1($)!=null){b.debug(`wire pipe "${$}" — already registered, keeping local implementation`);return}if(J.evalBlocked)return;try{let q=Function("return ("+Z+")")();if(typeof q!=="function"){b.warn(`wire pipe "${$}" — source did not evaluate to a function`);return}i1($,q),J.tracked.push($)}catch(q){if(G5(q)){J.evalBlocked=!0,b.warn("wire pipes cannot be hydrated — this host's CSP forbids eval. Pre-register them with "+"prefab.registerPipe() from a companion script (rendererHtml({ scripts })) and they are used as-is.");return}b.warn(`wire pipe "${$}" — failed to hydrate:`,q)}}function W5($){if(typeof document>"u")return;let Z=B5(),J=document.createElement("div"),q=$.variant??"default";J.className=`pf-toast${q!=="default"?` pf-toast--${q}`:""}`,J.setAttribute("data-variant",q),J.style.marginBottom="8px",J.style.transition="opacity 0.3s ease";let Q=document.createElement("div");if(Q.textContent=$.message,Q.style.fontWeight="500",J.appendChild(Q),$.description){let U=document.createElement("div");U.textContent=$.description,U.style.fontSize="14px",U.style.color="var(--muted-foreground, #6b7280)",J.appendChild(U)}Z.appendChild(J);let Y=$.duration??4000;setTimeout(()=>{J.style.opacity="0",setTimeout(()=>J.remove(),300)},Y)}function R4($,Z){if(E1($,Z),typeof document<"u")E1(document.documentElement,Z)}function X5($){let Z=$.trim();if(Z.includes("{")||Z.includes("}"))return!1;return/^(https?:)?\/\//i.test(Z)||Z.startsWith("/")||/\.css(\?|#|$)/i.test(Z)}function j4($,Z){let J=[];if(typeof document>"u")return J;for(let q of $??[]){let Q=document.createElement("style");Q.textContent=q,Q.dataset.prefab="injected",document.head.appendChild(Q),J.push(Q)}for(let q of Z??[])if(X5(q)){let Q=document.createElement("link");Q.rel="stylesheet",Q.href=q,Q.dataset.prefab="injected",document.head.appendChild(Q),J.push(Q)}else{let Q=document.createElement("style");Q.textContent=q,Q.dataset.prefab="injected",document.head.appendChild(Q),J.push(Q)}return J}function k4($,Z){if($.style.height="",$.style.minHeight="",$.style.maxHeight="",$.style.overflow="",!Z)return;if(Z.preferredHeight!=null)$.style.height=`${Z.preferredHeight}px`;if(Z.minHeight!=null)$.style.minHeight=`${Z.minHeight}px`;if(Z.maxHeight!=null)$.style.maxHeight=`${Z.maxHeight}px`,$.style.overflow="auto"}function B5(){let Z=document.getElementById("prefab-toast-container");if(!Z)Z=document.createElement("div"),Z.id="prefab-toast-container",Z.style.position="fixed",Z.style.bottom="16px",Z.style.right="16px",Z.style.zIndex="9999",Z.style.maxWidth="400px",document.body.appendChild(Z);return Z}if(typeof window<"u"){let $=window;$.PrefabRenderer=o,$.prefab={app:d1,mount:o.mount.bind(o),isPrefabData:o.isPrefabData.bind(o),isPrefabUpdate:o.isPrefabUpdate.bind(o),Bridge:D1,isIframe:c1,registerPipe:i1,unregisterPipe:s1,listPipes:f0,registerComponent:X,createThemeToggle:L0,validateWireFormat:O0,setLogLevel:A0};let Z=$.__PREFAB_DATA__;if(Z!=null){let J=document.getElementById("prefab-root");if(J)o.mount(J,Z)}}async function d1($){u1();let Z=$?.mode??"auto",J=Z==="bridge"||Z==="auto"&&c1(),q,Q,Y={capabilities:{}};if(J)Q=new D1($?.hostOrigin),Q.connect(),Y=await Q.initialize($?.capabilities??{toolInput:!0}),q=Q.createTransport();else if($?.transport)q=x1($.transport);else q=p1();if(Y.theme&&typeof document<"u")D0(document.documentElement,Y.theme);if(typeof document<"u"&&!Q)_5();let U,H,G,_,z,W=Y.toolInput,B;if(Q)Q.on("prefab:tool-input",(M)=>{let E=M.args??M;if(U)U(E);else W=E}),Q.on("prefab:tool-result",(M)=>{let E=M.result??M;if(H)H(E);else B=E}),Q.on("prefab:tool-cancelled",()=>{G?.()}),Q.on("prefab:tool-input-partial",(M)=>{_?.(M.args??M)}),Q.on("prefab:theme-update",(M)=>{if(typeof document<"u")D0(document.documentElement,M)}),Q.on("prefab:host-context-changed",(M)=>{z?.(M)});function K(M,...E){let T=V0(M),V=new K1,A={store:V,scope:{},transport:q,rerender:()=>I(),onToast:void 0};function I(){T.innerHTML="";for(let j of E)T.appendChild(u(j,A))}return I(),{rerender:I,store:V,destroy:()=>{T.innerHTML=""}}}return{callTool:(M,E={})=>q.callTool(M,E),sendMessage:(M)=>q.sendMessage(M),onToolInput:(M)=>{if(U=M,W){let E=W;W=void 0,queueMicrotask(()=>M(E))}},onToolResult:(M)=>{if(H=M,B!==void 0){let E=B;B=void 0,queueMicrotask(()=>M(E))}},onToolCancelled:(M)=>{G=M},onToolInputPartial:(M)=>{_=M},onHostContextChanged:(M)=>{z=M},render:K,mount:(M,E,T)=>{let V=V0(M);return o.mount(V,E,{transport:q,...T})},requestMode:(M)=>Q?.requestMode(M),openLink:(M,E)=>{if(Q)Q.openLink(M,E);else if(typeof window<"u")window.open(M,E??"_blank")},updateContext:(M)=>{if(Q)Q.updateContext(M)},setupAutoResize:(M)=>{if(!Q)return M5;let E=typeof M==="string"?V0(M):M;return Q.setupAutoResize(E)},notifyPreferredSize:(M)=>{if(Q)Q.notifyPreferredSize(M)},host:Y,capabilities:Y.capabilities,theme:Y.theme,transport:q,destroy:()=>Q?.disconnect()}}var M5=()=>{};function V0($){if(typeof $==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let Z=document.querySelector($);if(!Z)throw Error(`Element not found: ${$}`);return Z}return $}function _5(){function $(){let J=document.body.getAttribute("data-vscode-theme-kind");if(!J)return;let q=J.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",q)}$(),new MutationObserver($).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var R0=l1("auto"),A4="#root";function P0($){return o.isPrefabData($)}function S4($){return o.isPrefabUpdate($)}function f4($){if(P0($))return $;if($!==null&&typeof $==="object"){let Z=$;if(P0(Z.structuredContent))return Z.structuredContent;if(Array.isArray(Z.content))for(let J of Z.content){let q=J;if(q.type==="text"&&typeof q.text==="string")try{let Q=JSON.parse(q.text);if(P0(Q))return Q}catch{}}}return null}async function C4(){let $=document.querySelector(A4);if(!$){R0.error(`Mount target "${A4}" not found`);return}let Z=$,J=await d1();J.setupAutoResize(Z);let q;function Q(Y){if(q)q.destroy();if(q=J.mount(Z,Y),Y.layout)J.notifyPreferredSize(Y.layout)}J.onToolResult((Y)=>{let U=f4(Y);if(U)Q(U);else if(S4(Y)&&q)q.update(Y)}),J.onToolInput((Y)=>{let U=f4(Y);if(U)Q(U);else if(S4(Y)&&q)q.update(Y)})}function N5(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{C4().catch(($)=>{R0.error("Boot failed:",$)})},{once:!0});else queueMicrotask(()=>{C4().catch(($)=>{R0.error("Boot failed:",$)})})}N5();})();
|
|
15
|
+
}`)}return t.join(`
|
|
16
|
+
`)}function be(e,t){e.setAttribute("data-theme",t),e.classList.toggle("dark",t==="dark"),e.classList.toggle("light",t==="light")}function vt(e,t){if(!t)return;if(t.light)for(let[n,r]of Object.entries(t.light))e.style.setProperty(`--${yt(n)}`,Ct(r));if(t.dark){let r=document.getElementById("prefab-dark-theme");if(!r)r=document.createElement("style"),r.id="prefab-dark-theme",document.head.appendChild(r);r.textContent=kn({dark:t.dark})}}function wt(e,t){if(!e||typeof document>"u")return;let n=(r)=>{for(let[o,i]of Object.entries(e))if(li(o,r))r.preventDefault(),t(i)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}function li(e,t){let n=e.toLowerCase().split("+").map((i)=>i.trim()),r=n[n.length-1],o=new Set(n.slice(0,-1));if(o.has("ctrl")!==(t.ctrlKey||t.metaKey))return!1;if(o.has("shift")!==t.shiftKey)return!1;if(o.has("alt")!==t.altKey)return!1;return t.key.toLowerCase()===r}var Sn='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"/></svg>',En='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"/></svg>',An={"top-right":"top: 8px; right: 8px;","top-left":"top: 8px; left: 8px;","bottom-right":"bottom: 8px; right: 8px;","bottom-left":"bottom: 8px; left: 8px;"};function di(e,t){try{let r=localStorage.getItem(t);if(r==="light"||r==="dark")return r}catch{}let n=e.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(n==="light"||n==="dark")return n;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function xt(e,t){if(typeof document>"u")return()=>{};let n=t?.position??"top-right",r=t?.storageKey??"prefab-theme",o=t?.syncDocument??!0,i=getComputedStyle(e).position;if(i==="static"||i==="")e.style.position="relative";let s=document.createElement("button");s.className="pf-theme-toggle",s.setAttribute("aria-label","Toggle theme"),s.setAttribute("title","Toggle light/dark"),Object.assign(s.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let a=An[n]??An["top-right"];for(let d of a.split(";")){let[g,h]=d.split(":").map((y)=>y.trim());if(g&&h)s.style.setProperty(g,h)}s.addEventListener("mouseenter",()=>{s.style.opacity="1"}),s.addEventListener("mouseleave",()=>{s.style.opacity="0.7"});function l(d){if(be(e,d),o)be(document.documentElement,d);s.innerHTML=d==="dark"?En:Sn;try{localStorage.setItem(r,d)}catch{}}let c=di(e,r);l(c),s.addEventListener("click",()=>{let d=e.getAttribute("data-theme")??"dark";l(d==="dark"?"light":"dark")}),e.appendChild(s);let u;if(o)u=new MutationObserver((d)=>{for(let g of d)if(g.type==="attributes"&&g.attributeName==="data-theme"){let h=document.documentElement.getAttribute("data-theme");if((h==="light"||h==="dark")&&h!==e.getAttribute("data-theme")){be(e,h),s.innerHTML=h==="dark"?En:Sn;try{localStorage.setItem(r,h)}catch{}}}}),u.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{u?.disconnect(),s.remove()}}function _e(e){let t=e?.baseUrl??(typeof window<"u"?window.location.origin:""),n={"Content-Type":"application/json",...e?.headers},r=e?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(o,i){let s=await r(`${t}/mcp/tools/call`,{method:"POST",headers:n,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:o,arguments:i}})});if(!s.ok)throw Error(`MCP tool call failed: ${s.status} ${s.statusText}`);let a=await s.json();if(a.error)throw Error(a.error.message??"MCP tool call returned error");let l=a.result?.content??a.content??[];for(let c of l)if(c.type==="text"&&c.text!==void 0){try{let u=JSON.parse(c.text);if(typeof u==="object"&&u!==null&&"$prefab"in u)return u;return u}catch{}return c.text}return a.result??a},async sendMessage(o){await r(`${t}/mcp/messages`,{method:"POST",headers:n,body:JSON.stringify({message:o})})}}}function Ve(){return{callTool(e){return O.warn(`No MCP transport: callTool('${e}') ignored`),Promise.resolve(null)},sendMessage(e){return O.warn("No MCP transport: sendMessage ignored",e),Promise.resolve()}}}var Rn="0.3.10";function ci(e){return e!==null&&typeof e==="object"&&e.jsonrpc==="2.0"}class xe{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;_hostSupportsSubscriptions=!1;constructor(e="*"){this.hostOrigin=e}connect(){if(typeof window>"u")return;let e=fi();if(e)this.postFn=(n)=>e.postMessage(n);let t=(n)=>{if(this.hostOrigin!=="*"&&n.origin!==this.hostOrigin)return;let r=n.data;if(ci(r)){this.handleJsonRpc(r);return}let o=r;if(!o?.type.startsWith("prefab:"))return;if(o.type==="prefab:tool-call-response"&&o.id){let s=this.pending.get(o.id);if(s){if(this.pending.delete(o.id),o.payload?.error!=null)s.reject(Error(o.payload.error));else s.resolve(o.payload?.result);return}}let i=this.listeners.get(o.type);if(i)for(let s of i)s(o.payload??{})};window.addEventListener("message",t),this.cleanup=()=>window.removeEventListener("message",t)}async initialize(e){try{return await Promise.any([this.initPrefab(e),this.initJsonRpc(e)])}catch(t){let n=t instanceof AggregateError?t.errors.map((r)=>r.message).join("; "):String(t);throw Error(`Bridge init failed — no host responded. Tried: ${n}`,{cause:t})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode(e){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:e});else this.sendPrefab("prefab:request-mode",{mode:e})}openLink(e,t){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:e,target:t});else this.sendPrefab("prefab:open-link",{url:e,target:t})}updateContext(e){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:e});else this.sendPrefab("prefab:update-context",{context:e})}setupAutoResize(e){if(typeof ResizeObserver>"u")return pi;let t=-1,n=-1,r=(s,a)=>{if(s===t&&a===n)return;if(t=s,n=a,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:s,height:a});else this.sendPrefab("prefab:size-changed",{width:s,height:a})},o=new ResizeObserver((s)=>{for(let a of s)if(a.borderBoxSize.length){let l=a.borderBoxSize[0];r(Math.ceil(l.inlineSize),Math.ceil(l.blockSize))}else{let l=a.target.getBoundingClientRect();r(Math.ceil(l.width),Math.ceil(l.height))}});o.observe(e);let i=e.getBoundingClientRect();return r(Math.ceil(i.width),Math.ceil(i.height)),()=>o.disconnect()}notifyPreferredSize(e){if(this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/preferred-size",e);else this.sendPrefab("prefab:preferred-size",e)}subscribe(e,t){let n=(r)=>{if(r.uri!==e)return;t(r.contents??r.data??r)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",n),this.sendRpcRequest("resources/subscribe",{uri:e});else this.on("prefab:resource-updated",n),this.sendPrefab("prefab:subscribe",{uri:e});return()=>{if(this.off("prefab:resource-updated",n),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:e});else this.sendPrefab("prefab:unsubscribe",{uri:e})}}get supportsSubscriptions(){return this._hostSupportsSubscriptions}on(e,t){if(!this.listeners.has(e))this.listeners.set(e,new Set);let n=this.listeners.get(e);if(n)n.add(t)}off(e,t){this.listeners.get(e)?.delete(t)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,e]of this.pending)e.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,e]of this.rpcPending)e.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab(e){return new Promise((t,n)=>{let r=!1,o=(i)=>{if(r)return;r=!0,this.off("prefab:init-response",o),this.protocol="prefab";let s=i.capabilities;this._hostSupportsSubscriptions=s?.subscriptions===!0,t(i)};this.on("prefab:init-response",o),this.sendPrefab("prefab:init",{capabilities:e}),setTimeout(()=>{if(!r)r=!0,this.off("prefab:init-response",o),n(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:(e,t)=>{let n=`tc-${++this.callIdCounter}`;return new Promise((r,o)=>{this.pending.set(n,{resolve:r,reject:o}),this.sendPrefab("prefab:tool-call",{tool:e,arguments:t},n),setTimeout(()=>{if(this.pending.has(n))this.pending.delete(n),o(Error(`Tool call '${e}' timed out`))},30000)})},sendMessage:(e)=>(this.sendPrefab("prefab:send-message",{message:e}),Promise.resolve()),subscribe:(e,t)=>this.subscribe(e,t),capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendPrefab(e,t,n){if(typeof window>"u")return;let r=window.parent!==window?window.parent:window,o={type:e,payload:t,id:n};r.postMessage(o,this.hostOrigin)}handleJsonRpc(e){if(!("method"in e)){let r=this.rpcPending.get(e.id);if(r)if(this.rpcPending.delete(e.id),e.error)r.reject(Error(e.error.message));else r.resolve(e.result);return}let t=e.method,n=e.params??{};if(e.id!=null&&this.sentRpcIds.delete(e.id))return;if(e.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:e.id,result:{}});switch(t){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:n.arguments??n});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:n.arguments??n});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:n});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",n);break;case"ui/notifications/host-context-changed":{let r={};if(typeof n.theme==="string")r.colorScheme=n.theme;if(typeof n.styles==="object"&&n.styles!==null){let o=n.styles;if(o.variables)r.variables=o.variables;if(typeof o.css?.fonts==="string")r.fontCss=o.css.fonts}this.dispatch("prefab:theme-update",r),this.dispatch("prefab:host-context-changed",n);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",n);break;case"ui/notifications/resource-updated":case"notifications/resources/updated":this.dispatch("prefab:resource-updated",n);break}}initJsonRpc(e){return new Promise((t,n)=>{let r=++this.rpcIdCounter,o=!1;this.rpcPending.set(r,{resolve:(i)=>{if(o)return;o=!0,this.protocol="jsonrpc";let s=i??{},a=s.hostInfo??{},l=s.hostContext??{},c=s.hostCapabilities??{},u;if(typeof l.theme==="string"||typeof l.styles==="object"){if(u={},typeof l.theme==="string")u.colorScheme=l.theme;if(typeof l.styles==="object"&&l.styles!==null){let g=l.styles;if(g.variables)u.variables=g.variables;if(typeof g.css?.fonts==="string")u.fontCss=g.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let d=c.resources;this._hostSupportsSubscriptions=c.subscriptions===!0||d?.subscribe===!0,t({hostName:a.name,hostVersion:a.version,capabilities:{toast:!0,navigation:c.openLinks!=null,messaging:!0,displayModes:l.availableDisplayModes??[]},theme:u,toolInput:void 0,meta:l})},reject:(i)=>{if(o)return;o=!0,n(i)}}),this.postJsonRpc({jsonrpc:"2.0",id:r,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:Rn},appCapabilities:{...e.displayModes&&{availableDisplayModes:e.displayModes}}}}),setTimeout(()=>{if(!o)o=!0,this.rpcPending.delete(r),n(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:(e,t)=>this.sendRpcRequest("tools/call",{name:e,arguments:t}),sendMessage:(e)=>this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:e}}),subscribe:(e,t)=>this.subscribe(e,t),capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendRpcRequest(e,t){let n=++this.rpcIdCounter;return new Promise((r,o)=>{this.rpcPending.set(n,{resolve:r,reject:o}),this.postJsonRpc({jsonrpc:"2.0",id:n,method:e,params:t}),setTimeout(()=>{if(this.rpcPending.has(n))this.rpcPending.delete(n),o(Error(`JSON-RPC '${e}' timed out`))},30000)})}sendRpcNotification(e,t){this.postJsonRpc({jsonrpc:"2.0",method:e,params:t})}postJsonRpc(e){if(typeof window>"u")return;if(e.id!=null&&typeof e.method==="string")this.sentRpcIds.add(e.id);if(this.postFn)this.postFn(e);else(window.parent!==window?window.parent:window).postMessage(e,this.hostOrigin)}dispatch(e,t){let n=this.listeners.get(e);if(n)for(let r of n)r(t)}}var pi=()=>{};function kt(e,t){if(t.variables)for(let[n,r]of Object.entries(t.variables))e.style.setProperty(n.startsWith("--")?n:`--${n}`,r);if(t.colorScheme&&t.colorScheme!=="auto")e.setAttribute("data-theme",t.colorScheme);if(t.fontCss)ui(t.fontCss)}function ui(e){if(document.getElementById("__prefab-host-fonts"))return;let n=document.createElement("style");n.id="__prefab-host-fonts",n.textContent=e,document.head.appendChild(n)}function Ke(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function fi(){if(typeof window>"u")return;let e=window;if(typeof e.acquireVsCodeApi==="function")try{let t=e.acquireVsCodeApi();if(t!==null&&typeof t==="object"&&"postMessage"in t)return t}catch{return}return}var Tn=["Accordion","AccordionItem","Alert","AlertDescription","AlertTitle","AreaChart","Audio","Badge","BarChart","BlockQuote","Button","ButtonGroup","Calendar","Card","CardContent","CardDescription","CardFooter","CardHeader","CardTitle","Carousel","Checkbox","ChoiceCard","Code","Column","Combobox","ComboboxGroup","ComboboxLabel","ComboboxOption","ComboboxSeparator","Condition","Container","Dashboard","DashboardItem","DataTable","DatePicker","Define","Detail","Dialog","Div","Dot","DropZone","Elif","Else","Embed","ExpandableRow","Field","FieldContent","FieldDescription","FieldError","FieldTitle","ForEach","Form","Grid","GridItem","H1","H2","H3","H4","Heading","Histogram","HoverCard","Icon","If","Image","Input","Kbd","Label","Large","Lead","LineChart","Link","Loader","Markdown","MasterDetail","Mermaid","Metric","Muted","P","Page","Pages","PdfViewer","PieChart","Popover","Progress","RadarChart","RadialChart","Radio","RadioGroup","Ring","Row","ScatterChart","Select","SelectGroup","SelectLabel","SelectOption","SelectSeparator","Separator","Slider","Slot","Small","Span","Sparkline","Svg","Switch","Tab","Table","TableBody","TableCaption","TableCell","TableFooter","TableHead","TableHeader","TableRow","Tabs","Text","Textarea","Tooltip","Use","Video"];var Ln=new Set(Tn);function Et(e,t={}){let n=[],r=t.strict??!1;if(e==null||typeof e!=="object")return n.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:n};let o=e;if(o.$prefab==null||typeof o.$prefab!=="object")n.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof o.$prefab.version!=="string")n.push({path:"$.$prefab.version",message:"version must be a string"});if(o.view==null)n.push({path:"$.view",message:'Missing required "view" field'});else St(o.view,"$.view",n,r);if(o.state!==void 0){if(o.state===null||typeof o.state!=="object"||Array.isArray(o.state))n.push({path:"$.state",message:"state must be a plain object"})}if(o.theme!==void 0)gi(o.theme,n);if(o.css!==void 0)Mn(o.css,"$.css",n);if(o.stylesheets!==void 0)Mn(o.stylesheets,"$.stylesheets",n);if(o.mode!==void 0&&o.mode!=="light"&&o.mode!=="dark")n.push({path:"$.mode",message:'mode must be "light" or "dark"'});if(o.defs!==void 0)if(o.defs===null||typeof o.defs!=="object"||Array.isArray(o.defs))n.push({path:"$.defs",message:"defs must be a plain object"});else for(let[i,s]of Object.entries(o.defs))St(s,`$.defs.${i}`,n,r);if(o.keyBindings!==void 0)if(o.keyBindings===null||typeof o.keyBindings!=="object"||Array.isArray(o.keyBindings))n.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[i,s]of Object.entries(o.keyBindings))At(s,`$.keyBindings.${i}`,n);return{valid:n.length===0,errors:n}}function St(e,t,n,r){if(e==null||typeof e!=="object"||Array.isArray(e)){n.push({path:t,message:"Component must be a plain object"});return}let o=e;if(typeof o.type!=="string"||o.type.length===0){n.push({path:`${t}.type`,message:'Component must have a non-empty "type" string'});return}if(r&&!Ln.has(o.type))n.push({path:`${t}.type`,message:`Unknown component type: "${o.type}"`});if(o.children!==void 0)if(!Array.isArray(o.children))n.push({path:`${t}.children`,message:"children must be an array"});else for(let s=0;s<o.children.length;s++)St(o.children[s],`${t}.children[${s}]`,n,r);let i=["onClick","on_click","onChange","on_change","onSubmit","on_submit","onMount","on_mount","onClose","on_close"];for(let s of i)if(o[s]!==void 0)At(o[s],`${t}.${s}`,n);for(let[s,a]of Object.entries(o)){if(s==="type"||mi.has(s)||i.includes(s))continue;if(Nn(a)||Array.isArray(a)&&a.some(Nn))n.push({path:`${t}.${s}`,message:`Components under "${s}" are ignored by the renderer; move them into "children"`})}}var mi=new Set(["children","fallback","trigger","empty","else","summary"]);function Nn(e){if(e==null||typeof e!=="object"||Array.isArray(e))return!1;let t=e.type;return typeof t==="string"&&Ln.has(t)}function At(e,t,n){if(Array.isArray(e)){for(let a=0;a<e.length;a++)At(e[a],`${t}[${a}]`,n);return}if(e==null||typeof e!=="object"){n.push({path:t,message:"Action must be an object or array of objects"});return}let r=e,o=typeof r.type==="string"&&r.type.length>0,i=typeof r.action==="string"&&r.action.length>0;if(!o&&!i){n.push({path:`${t}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if((i?r.action:r.type).toLowerCase()==="showtoast"){if(typeof r.message!=="string"||r.message.length===0)n.push({path:`${t}.message`,message:'showToast requires a non-empty "message" string'})}}function Mn(e,t,n){if(!Array.isArray(e)){n.push({path:t,message:`${t} must be an array of strings`});return}for(let r=0;r<e.length;r++)if(typeof e[r]!=="string")n.push({path:`${t}[${r}]`,message:"must be a string"})}function gi(e,t){if(e===null||typeof e!=="object"||Array.isArray(e)){t.push({path:"$.theme",message:"theme must be a plain object"});return}let n=e;for(let r of["light","dark"])if(n[r]!==void 0){if(n[r]===null||typeof n[r]!=="object"||Array.isArray(n[r]))t.push({path:`$.theme.${r}`,message:`theme.${r} must be a plain object`})}}var Z={mount(e,t,n){if(We(),n?.validate!==!1)for(let b of Et(t).errors)O.warn(`wire validation ${b.path}: ${b.message}`);let r=t,o={tracked:[],evalBlocked:!1};if(r.pipes)for(let[b,w]of Object.entries(r.pipes))Hn(b,w,o);let i=new ye(r.state),s;if(n?.transport&&"callTool"in n.transport)s=n.transport;else if(n?.transport)s=_e(n.transport);else s=Ve();let a=n?.onToast??yi,l=new ot;function c(b){let w=b;if(r=w,w.state)i.merge(w.state);if(w.defs)u.defs=w.defs;if(w.theme)vt(e,w.theme);if(w.mode)Pn(e,w.mode);if(w.pipes)for(let[S,N]of Object.entries(w.pipes))Hn(S,N,o);for(let S of d)S.remove();if(d.length=0,d.push(...$n(w.css,w.stylesheets)),On(e,w.layout),g?.(),g=void 0,w.keyBindings)g=wt(w.keyBindings,(S)=>{F(j(S,{store:i,transport:s,scope:{},rerender:()=>f(),remount:c,onToast:a}),"keyBinding")});f()}let u={store:i,scope:{},transport:s,rerender:()=>f(),remount:c,onToast:a,defs:r.defs,destroyRegistry:l};if(vt(e,r.theme),r.mode)Pn(e,r.mode);On(e,r.layout);let d=$n(r.css,r.stylesheets),g;if(r.keyBindings)g=wt(r.keyBindings,(b)=>{F(j(b,{store:i,transport:s,scope:{},rerender:()=>f(),remount:c,onToast:a}),"keyBinding")});let h,y=n?.themeToggle??!0;if(y!==!1)h=xt(e,typeof y==="object"?y:void 0);function f(){l.flush();let b=e.querySelector(".pf-theme-toggle");e.innerHTML="";let w=J(r.view,u);if(e.appendChild(w),b)e.appendChild(b)}return f(),{rerender:()=>f(),update(b){if(i.merge(b.update.state),f(),b.update.actions!=null)F(j(b.update.actions,u),"update action")},store:i,destroy(){l.flush(),h?.(),g?.(),Ft(),Bt();for(let b of d)b.remove();for(let b of o.tracked)Xe(b);e.innerHTML=""}}},isPrefabData(e){return e!=null&&typeof e==="object"&&"$prefab"in e},isPrefabUpdate(e){return e!=null&&typeof e==="object"&&"$prefab"in e&&"update"in e}},hi=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 bi(e){if(e instanceof EvalError)return!0;return e instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test(e.message)}function Hn(e,t,n){if(hi.has(e)){O.warn(`wire pipe "${e}" ignored — shadows built-in`);return}if(ke(e)!=null){O.debug(`wire pipe "${e}" — already registered, keeping local implementation`);return}if(n.evalBlocked)return;try{let r=Function("return ("+t+")")();if(typeof r!=="function"){O.warn(`wire pipe "${e}" — source did not evaluate to a function`);return}Ue(e,r),n.tracked.push(e)}catch(r){if(bi(r)){n.evalBlocked=!0,O.warn("wire pipes cannot be hydrated — this host's CSP forbids eval. Pre-register them with "+"prefab.registerPipe() from a companion script (rendererHtml({ scripts })) and they are used as-is.");return}O.warn(`wire pipe "${e}" — failed to hydrate:`,r)}}function yi(e){if(typeof document>"u")return;let t=vi(),n=document.createElement("div"),r=e.variant??"default";n.className=`pf-toast${r!=="default"?` pf-toast--${r}`:""}`,n.setAttribute("data-variant",r),n.style.marginBottom="8px",n.style.transition="opacity 0.3s ease";let o=document.createElement("div");if(o.textContent=e.message,o.style.fontWeight="500",n.appendChild(o),e.description){let s=document.createElement("div");s.textContent=e.description,s.style.fontSize="14px",s.style.color="var(--muted-foreground, #6b7280)",n.appendChild(s)}t.appendChild(n);let i=e.duration??4000;setTimeout(()=>{n.style.opacity="0",setTimeout(()=>n.remove(),300)},i)}function Pn(e,t){if(be(e,t),typeof document<"u")be(document.documentElement,t)}function Ci(e){let t=e.trim();if(t.includes("{")||t.includes("}"))return!1;return/^(https?:)?\/\//i.test(t)||t.startsWith("/")||/\.css(\?|#|$)/i.test(t)}function $n(e,t){let n=[];if(typeof document>"u")return n;for(let r of e??[]){let o=document.createElement("style");o.textContent=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}for(let r of t??[])if(Ci(r)){let o=document.createElement("link");o.rel="stylesheet",o.href=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}else{let o=document.createElement("style");o.textContent=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}return n}function On(e,t){if(e.style.height="",e.style.minHeight="",e.style.maxHeight="",e.style.overflow="",!t)return;if(t.preferredHeight!=null)e.style.height=`${t.preferredHeight}px`;if(t.minHeight!=null)e.style.minHeight=`${t.minHeight}px`;if(t.maxHeight!=null)e.style.maxHeight=`${t.maxHeight}px`,e.style.overflow="auto"}function vi(){let t=document.getElementById("prefab-toast-container");if(!t)t=document.createElement("div"),t.id="prefab-toast-container",t.style.position="fixed",t.style.bottom="16px",t.style.right="16px",t.style.zIndex="9999",t.style.maxWidth="400px",document.body.appendChild(t);return t}if(typeof window<"u"){let e=window;e.PrefabRenderer=Z,e.prefab={app:Ge,mount:Z.mount.bind(Z),isPrefabData:Z.isPrefabData.bind(Z),isPrefabUpdate:Z.isPrefabUpdate.bind(Z),Bridge:xe,isIframe:Ke,registerPipe:Ue,unregisterPipe:Xe,listPipes:$t,registerComponent:p,createThemeToggle:xt,validateWireFormat:Et,setLogLevel:Ht};let t=e.__PREFAB_DATA__;if(t!=null){let n=document.getElementById("prefab-root");if(n)Z.mount(n,t)}}async function Ge(e){We();let t=e?.mode??"auto",n=t==="bridge"||t==="auto"&&Ke(),r,o,i={capabilities:{}};if(n)o=new xe(e?.hostOrigin),o.connect(),i=await o.initialize(e?.capabilities??{toolInput:!0}),r=o.createTransport();else if(e?.transport)r=_e(e.transport);else r=Ve();if(i.theme&&typeof document<"u")kt(document.documentElement,i.theme);if(typeof document<"u"&&!o)xi();let s,a,l,c,u,d=i.toolInput,g;if(o)o.on("prefab:tool-input",(f)=>{let b=f.args??f;if(s)s(b);else d=b}),o.on("prefab:tool-result",(f)=>{let b=f.result??f;if(a)a(b);else g=b}),o.on("prefab:tool-cancelled",()=>{l?.()}),o.on("prefab:tool-input-partial",(f)=>{c?.(f.args??f)}),o.on("prefab:theme-update",(f)=>{if(typeof document<"u")kt(document.documentElement,f)}),o.on("prefab:host-context-changed",(f)=>{u?.(f)});function h(f,...b){let w=Rt(f),S=new ye,N={store:S,scope:{},transport:r,rerender:()=>k(),onToast:void 0};function k(){w.innerHTML="";for(let R of b)w.appendChild(J(R,N))}return k(),{rerender:k,store:S,destroy:()=>{w.innerHTML=""}}}return{callTool:(f,b={})=>r.callTool(f,b),sendMessage:(f)=>r.sendMessage(f),onToolInput:(f)=>{if(s=f,d){let b=d;d=void 0,queueMicrotask(()=>f(b))}},onToolResult:(f)=>{if(a=f,g!==void 0){let b=g;g=void 0,queueMicrotask(()=>f(b))}},onToolCancelled:(f)=>{l=f},onToolInputPartial:(f)=>{c=f},onHostContextChanged:(f)=>{u=f},render:h,mount:(f,b,w)=>{let S=Rt(f);return Z.mount(S,b,{transport:r,...w})},requestMode:(f)=>o?.requestMode(f),openLink:(f,b)=>{if(o)o.openLink(f,b);else if(typeof window<"u")window.open(f,b??"_blank")},updateContext:(f)=>{if(o)o.updateContext(f)},setupAutoResize:(f)=>{if(!o)return wi;let b=typeof f==="string"?Rt(f):f;return o.setupAutoResize(b)},notifyPreferredSize:(f)=>{if(o)o.notifyPreferredSize(f)},host:i,capabilities:i.capabilities,theme:i.theme,transport:r,destroy:()=>o?.disconnect()}}var wi=()=>{};function Rt(e){if(typeof e==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let t=document.querySelector(e);if(!t)throw Error(`Element not found: ${e}`);return t}return e}function xi(){function e(){let n=document.body.getAttribute("data-vscode-theme-kind");if(!n)return;let r=n.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",r)}e(),new MutationObserver(e).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var Nt=qe("auto"),Dn="#root";function Tt(e){return Z.isPrefabData(e)}function jn(e){return Z.isPrefabUpdate(e)}function In(e){if(Tt(e))return e;if(e!==null&&typeof e==="object"){let t=e;if(Tt(t.structuredContent))return t.structuredContent;if(Array.isArray(t.content))for(let n of t.content){let r=n;if(r.type==="text"&&typeof r.text==="string")try{let o=JSON.parse(r.text);if(Tt(o))return o}catch{}}}return null}async function Fn(){let e=document.querySelector(Dn);if(!e){Nt.error(`Mount target "${Dn}" not found`);return}let t=e,n=await Ge();n.setupAutoResize(t);let r;function o(i){if(r)r.destroy();if(r=n.mount(t,i),i.layout)n.notifyPreferredSize(i.layout)}n.onToolResult((i)=>{let s=In(i);if(s)o(s);else if(jn(i)&&r)r.update(i)}),n.onToolInput((i)=>{let s=In(i);if(s)o(s);else if(jn(i)&&r)r.update(i)})}function ki(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{Fn().catch((e)=>{Nt.error("Boot failed:",e)})},{once:!0});else queueMicrotask(()=>{Fn().catch((e)=>{Nt.error("Boot failed:",e)})})}ki();})();
|