@maxhealth.tech/prefab 0.2.12 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/app.d.ts +1 -1
- package/dist/app.js +1 -1
- package/dist/renderer/components/alert.js +0 -6
- package/dist/renderer/components/alert.js.map +1 -1
- package/dist/renderer/components/card.js +0 -3
- package/dist/renderer/components/card.js.map +1 -1
- package/dist/renderer/components/charts.js +2 -3
- package/dist/renderer/components/charts.js.map +1 -1
- package/dist/renderer/components/data.js +9 -21
- package/dist/renderer/components/data.js.map +1 -1
- package/dist/renderer/components/form.js +7 -27
- package/dist/renderer/components/form.js.map +1 -1
- package/dist/renderer/components/interactive.js +3 -14
- package/dist/renderer/components/interactive.js.map +1 -1
- package/dist/renderer/components/media.js +3 -5
- package/dist/renderer/components/media.js.map +1 -1
- package/dist/renderer/components/table.js +0 -3
- package/dist/renderer/components/table.js.map +1 -1
- package/dist/renderer.auto.min.js +6 -6
- package/dist/renderer.min.js +6 -6
- package/package.json +1 -1
package/dist/renderer.min.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(()=>{var{defineProperty:k4,getOwnPropertyNames:h1,getOwnPropertyDescriptor:g1}=Object,u1=Object.prototype.hasOwnProperty;function x1($){return this[$]}var p1=($)=>{var J=(p4??=new WeakMap).get($),Z;if(J)return J;if(J=k4({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var q of h1($))if(!u1.call(J,q))k4(J,q,{get:x1.bind($,q),enumerable:!(Z=g1($,q))||Z.enumerable})}return p4.set($,J),J},p4;var c1=($)=>$;function s1($,J){this[$]=c1.bind(null,J)}var l1=($,J)=>{for(var Z in J)k4($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:s1.bind(J,Z)})};var U2={};l1(U2,{unregisterPipe:()=>Q4,registerPipe:()=>U4,registerComponent:()=>_,listPipes:()=>B4,isIframe:()=>Z4,applyHostTheme:()=>M4,app:()=>A4,PrefabRenderer:()=>p,Bridge:()=>t});class q4{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return d1(this.data,$)}getAll(){return this.data}set($,J){c4(this.data,$,J),this.notify($)}toggle($){let J=this.get($),Z=J==null||J===!1||J===0||J==="";this.set($,Z)}append($,J,Z){let q=this.get($);if(!Array.isArray(q)){this.set($,[J]);return}if(Z!==void 0)q.splice(Z,0,J);else q.push(J);this.notify($)}pop($,J){let Z=this.get($);if(!Array.isArray(Z))return;if(typeof J==="number")Z.splice(J,1);else{let q=Z.indexOf(J);if(q>=0)Z.splice(q,1)}this.notify($)}merge($){for(let[J,Z]of Object.entries($))c4(this.data,J,Z);for(let J of Object.keys($))this.notify(J)}subscribe($,J){if(!this.subscribers.has($))this.subscribers.set($,new Set);return this.subscribers.get($)?.add(J),()=>this.subscribers.get($)?.delete(J)}subscribeAll($){return this.globalSubscribers.add($),()=>this.globalSubscribers.delete($)}notify($){this.generation++;let J=$.split(".");for(let Z=1;Z<=J.length;Z++){let q=J.slice(0,Z).join("."),U=this.subscribers.get(q);if(U)U.forEach((Q)=>Q())}this.globalSubscribers.forEach((Z)=>Z())}}function d1($,J){let Z=J.split("."),q=$;for(let U of Z){if(q==null||typeof q!=="object")return;q=q[U]}return q}var i1=new Set(["__proto__","constructor","prototype"]);function c4($,J,Z){let q=J.split(".");if(q.some((Q)=>i1.has(Q))){console.warn(`[prefab] Blocked prototype pollution attempt: ${J}`);return}let U=$;for(let Q=0;Q<q.length-1;Q++){let W=q[Q];if(U[W]==null||typeof U[W]!=="object")U[W]={};U=U[W]}U[q[q.length-1]]=Z}var e=new Map;function U4($,J){if(e.has($)&&e.get($)!==J)console.warn(`[prefab] pipe "${$}" re-registered`);e.set($,J)}function Q4($){return e.delete($)}function B4(){return[...e.keys()]}function s4($){return e.get($)}var l4=-1,f4=new Map,r1=/\{\{\s*(.+?)\s*\}\}/g;function g($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function u($,J,Z){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&J0(q,"{{")===1){let U=q.slice(2,-2).trim();return d4(U,J,Z)}return $.replace(r1,(U,Q)=>{let W=d4(Q.trim(),J,Z);return W==null?"":String(W)})}function d4($,J,Z){let[q,...U]=$0($),Q=h(q.trim(),J,Z);for(let W of U)Q=n1(W.trim(),Q,J,Z);return Q}function h($,J,Z){let q=t1($);if(q>=0){let W=$.slice(0,q).trim(),Y=$.slice(q+1),M=e1(Y);if(M>=0){let H=Y.slice(0,M).trim(),G=Y.slice(M+1).trim(),N=h(W,J,Z);return N!==null&&N!==void 0&&N!==!1&&N!==0&&N!==""?h(H,J,Z):h(G,J,Z)}}let U=H4($,"||");if(U>=0){let W=h($.slice(0,U).trim(),J,Z);return W!==null&&W!==void 0&&W!==!1&&W!==0&&W!==""?W:h($.slice(U+2).trim(),J,Z)}let Q=H4($,"&&");if(Q>=0){let W=h($.slice(0,Q).trim(),J,Z);if(W===null||W===void 0||W===!1||W===0||W==="")return W;return h($.slice(Q+2).trim(),J,Z)}for(let[W,Y]of a1){let M=H4($,W);if(M>=0){let H=h($.slice(0,M).trim(),J,Z),G=h($.slice(M+W.length).trim(),J,Z);return Y(H,G)}}if($.startsWith("!")){let W=h($.slice(1).trim(),J,Z);return W===null||W===void 0||W===!1||W===0||W===""}for(let[W,Y]of o1){let M=H4($,W);if(M>=0){let H=h($.slice(0,M).trim(),J,Z),G=h($.slice(M+W.length).trim(),J,Z);return Y(Number(H),Number(G))}}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(Z&&$.startsWith("$")){let W=$.indexOf(".");if(W>=0){let Y=$.slice(0,W),M=$.slice(W+1),H=Z[Y];return G4(H,M)}return Z[$]}if(Z){let W=$.split(".")[0];if(W in Z)return G4(Z[W],$.includes(".")?$.slice(W.length+1):"")}return J.get($)}function n1($,J,Z,q){let U=$.indexOf(":"),Q=U>=0?$.slice(0,U).trim():$,W=U>=0?$.slice(U+1).trim():void 0,Y=W?S4(W):void 0;switch(Q){case"find":{if(!Array.isArray(J)||!W)return;let M=i4(W);if(M.length<2)return;let H=S4(M[0]),G=M[1].trim(),N;if(G.startsWith("'")&&G.endsWith("'")||G.startsWith('"')&&G.endsWith('"'))N=G.slice(1,-1);else if(Z){if(q&&G.startsWith("$")){let z=G.indexOf(".");if(z>=0){let F=G.slice(0,z);if(F in q)N=G4(q[F],G.slice(z+1))}else if(G in q)N=q[G]}if(N===void 0&&!(q&&G.startsWith("$")))if(q){let z=G.split(".")[0];N=z in q?G4(q[z],G.includes(".")?G.slice(z.length+1):""):Z.get(G)}else N=Z.get(G)}else N=G;if(N==null)return;let X=Z?.generation??0;if(X!==l4)f4=new Map,l4=X;let T=f4.get(J);if(!T)T=new Map,f4.set(J,T);let D=T.get(H);if(!D){D=new Map;for(let z of J)if(z!=null&&typeof z==="object"){let F=z[H];if(F!=null)D.set(String(F),z)}T.set(H,D)}return D.get(String(N))}case"dot":{if(J==null||typeof J!=="object"||typeof Y!=="string")return;return J[Y]}case"length":return Array.isArray(J)?J.length:typeof J==="string"?J.length:0;case"upper":return typeof J==="string"?J.toUpperCase():J;case"lower":return typeof J==="string"?J.toLowerCase():J;case"truncate":if(typeof J==="string"&&typeof Y==="number")return J.slice(0,Y);return J;case"join":return Array.isArray(J)?J.join(typeof Y==="string"?Y:", "):J;case"first":return Array.isArray(J)?J[0]:J;case"last":return Array.isArray(J)?J[J.length-1]:J;case"abs":return Math.abs(Number(J));case"round":return typeof Y==="number"?Number(Number(J).toFixed(Y)):Math.round(Number(J));case"number":return typeof Y==="number"?Number(Number(J).toFixed(Y)):Number(J);case"currency":{let M=typeof Y==="string"?Y:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:M}).format(Number(J))}catch{return J}}case"percent":return typeof Y==="number"?`${(Number(J)*100).toFixed(Y)}%`:`${Math.round(Number(J)*100)}%`;case"compact":{let M=typeof Y==="number"?Y:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:M}).format(Number(J))}catch{return J}}case"date":try{return new Date(J).toLocaleDateString()}catch{return J}case"time":try{return new Date(J).toLocaleTimeString()}catch{return J}case"datetime":try{return new Date(J).toLocaleString()}catch{return J}case"pluralize":{let M=Number(J),H=typeof Y==="string"?Y:"";return M===1?H:`${H}s`}case"default":return J==null||J===""?Y:J;case"selectattr":return Array.isArray(J)&&typeof Y==="string"?J.filter((M)=>M!=null&&typeof M==="object"&&Boolean(M[Y])):J;case"rejectattr":return Array.isArray(J)&&typeof Y==="string"?J.filter((M)=>{if(M==null||typeof M!=="object")return!1;let H=M[Y];return H==null||H===!1||H===0||H===""}):J;default:{let M=s4(Q);if(M){let H=W?i4(W).map(S4):[];return M(J,...H)}return J}}}var a1=[["!==",($,J)=>$!==J],["===",($,J)=>$===J],["!=",($,J)=>$!=J],["==",($,J)=>$==J],[">=",($,J)=>Number($)>=Number(J)],["<=",($,J)=>Number($)<=Number(J)],[">",($,J)=>Number($)>Number(J)],["<",($,J)=>Number($)<Number(J)]],o1=[[" + ",($,J)=>$+J],[" - ",($,J)=>$-J],[" * ",($,J)=>$*J],[" / ",($,J)=>J!==0?$/J:0],[" % ",($,J)=>J!==0?$%J:0]];function H4($,J){let Z=null;for(let q=0;q<$.length;q++){let U=$[q];if(U==="'"||U==='"')Z=Z===U?null:Z??U;if(!Z&&$.slice(q,q+J.length)===J)return q}return-1}function t1($){let J=0,Z=null;for(let q=0;q<$.length;q++){let U=$[q];if(U==="'"||U==='"')Z=Z===U?null:Z??U;if(!Z){if(U==="(")J++;else if(U===")")J--;else if(U==="?"&&J===0)return q}}return-1}function e1($){let J=0,Z=null;for(let q=0;q<$.length;q++){let U=$[q];if(U==="'"||U==='"')Z=Z===U?null:Z??U;if(!Z){if(U==="?"||U==="(")J++;else if(U===")")J--;else if(U===":"&&J===0)return q}}return-1}function $0($){let J=[],Z="",q=null;for(let U=0;U<$.length;U++){let Q=$[U];if(Q==="'"||Q==='"')q=q===Q?null:q??Q;if(Q==="|"&&!q)if($[U+1]==="|")Z+="||",U++;else J.push(Z),Z="";else Z+=Q}return J.push(Z),J}function S4($){let J=$.replace(/^['"]|['"]$/g,"");if(J==="true")return!0;if(J==="false")return!1;let Z=Number(J);return isNaN(Z)?J:Z}function i4($){let J=[],Z="",q=null;for(let U of $){if(U==="'"||U==='"')q=q===U?null:q??U;if(U===","&&!q)J.push(Z),Z="";else Z+=U}return J.push(Z),J}function G4($,J){if(!J)return $;let Z=J.split("."),q=$;for(let U of Z){if(q==null||typeof q!=="object")return;q=q[U]}return q}function J0($,J){let Z=0,q=0;while((q=$.indexOf(J,q))!==-1)Z++,q+=J.length;return Z}async function k($,J){let Z=Array.isArray($)?$:[$];for(let q of Z)await Z0(q,J)}async function Z0($,J){let Z=$.action;switch(Z){case"setState":{q0($,J);return}case"toggleState":{U0($,J);return}case"appendState":{Q0($,J);return}case"popState":{W0($,J);return}case"showToast":{Y0($,J);return}case"closeOverlay":{_0($,J);return}case"openLink":{M0($);return}case"setInterval":{H0($,J);return}case"toolCall":case"callTool":return G0($,J);case"sendMessage":return X0($,J);case"updateContext":{K0($,J);return}case"fetch":return z0($,J);case"openFilePicker":{D0($,J);return}case"callHandler":return E0($,J);case"requestDisplayMode":{F0($,J);return}default:console.warn(`[prefab] Unknown action: ${Z}`)}}function q0($,J){let{key:Z,value:q}=$;if(g(q))q=u(q,J.store,J.scope);J.store.set(Z,q),J.rerender(),r($.onSuccess,J)}function U0($,J){J.store.toggle($.key),J.rerender()}function Q0($,J){let Z=$.value;if(g(Z))Z=u(Z,J.store,J.scope);J.store.append($.key,Z,$.index),J.rerender()}function W0($,J){J.store.pop($.key,$.index),J.rerender()}function Y0($,J){J.onToast?.({message:K4($.message,J),description:$.description!=null?K4($.description,J):void 0,variant:$.variant,duration:$.duration})}function _0($,J){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function M0($){if(typeof window<"u"){let J=$.url;if(!J){console.warn("[prefab] openLink: missing url");return}if(!n4(J)){console.warn(`[prefab] Blocked unsafe URL scheme: ${J}`);return}window.open(J,$.target??"_blank")}}var X4=new Set,N0=20,B0=100;function H0($,J){let Z=Math.max($.intervalMs,B0),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(X4.size>=N0){console.warn("[prefab] Max intervals reached, ignoring new setInterval");return}let U=globalThis.setInterval(()=>void k(q,J),Z);X4.add(U)}function r4(){for(let $ of X4)globalThis.clearInterval($);X4.clear()}async function G0($,J){if(!J.transport){console.warn("[prefab] No MCP transport configured for toolCall");return}let Z=$.tool,q=a4($.arguments,J);try{let U=await J.transport.callTool(Z,q);if($.resultKey!=null)J.store.set($.resultKey,U);J.rerender(),await r($.onSuccess,J,{$result:U})}catch(U){await r($.onError,J,{$error:U})}}async function X0($,J){if(!J.transport){console.warn("[prefab] No MCP transport configured for sendMessage");return}await J.transport.sendMessage(K4($.message,J))}function K0($,J){let Z=$.context;if(Z!=null)J.store.merge(Z),J.rerender()}async function z0($,J){let Z=K4($.url,J);if(!n4(Z)){console.warn(`[prefab] Blocked unsafe URL in fetch: ${Z}`);return}let q=$.method??"GET",U=$.headers,Q=$.body!==void 0?JSON.stringify($.body):void 0;try{let W=await globalThis.fetch(Z,{method:q,headers:{"Content-Type":"application/json",...U},...Q&&{body:Q}}),Y=await W.json().catch(()=>W.text());if($.resultKey!=null)J.store.set($.resultKey,Y);J.rerender(),await r($.onSuccess,J,{$result:Y})}catch(W){await r($.onError,J,{$error:W})}}function D0($,J){if(typeof document>"u")return;let Z=document.createElement("input");if(Z.type="file",$.accept!=null)Z.accept=$.accept;if($.multiple===!0)Z.multiple=!0;Z.addEventListener("change",()=>{let q=Array.from(Z.files??[]);if($.resultKey!=null)J.store.set($.resultKey,q);J.rerender(),r($.onSuccess,J,{$result:q})}),Z.click()}async function E0($,J){let Z=$.handler,q=a4($.arguments,J);if(!J.transport){console.warn(`[prefab] No transport configured for callHandler: ${Z}`);return}try{let U=await J.transport.callTool(Z,q);if($.resultKey!=null)J.store.set($.resultKey,U);J.rerender(),await r($.onSuccess,J,{$result:U})}catch(U){await r($.onError,J,{$error:U})}}function F0($,J){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var T0=/^\s*(javascript|vbscript|data):/i;function n4($){return!T0.test($)}function K4($,J){if(g($)){let Z=u($,J.store,J.scope);return Z==null?"":String(Z)}return $==null?"":String($)}function a4($,J){if(!$)return{};let Z={};for(let[q,U]of Object.entries($))Z[q]=g(U)?u(U,J.store,J.scope):U;return Z}async function r($,J,Z){if($==null)return;let q={...J.scope,...Z};await k($,{...J,scope:q})}var C4=new Map;function _($,J){if(C4.has($))console.warn(`[prefab] overriding existing renderer for "${$}"`);C4.set($,J)}function w($,J){if(J.defs?.[$.type]){let U={...J.defs[$.type],...$,type:J.defs[$.type].type};return w(U,J)}let Z=C4.get($.type),q;if(Z)q=Z($,J);else if(q=document.createElement("div"),q.setAttribute("data-prefab-type",$.type),$.children)for(let U of $.children)q.appendChild(w(U,J));if(q instanceof HTMLElement){if($.id)q.id=$.id;if($.cssClass){let U=K($.cssClass,J);if(U)q.className=(q.className?q.className+" ":"")+U}}if($.onMount){let U=$.onMount,Q=b(J);queueMicrotask(()=>void k(U,Q))}return q}function j($,J,Z){if(!$.children)return;n($.children,J,Z)}function n($,J,Z){let q=0;while(q<$.length){let U=$[q];if(U.type==="If")q=j0($,q,J,Z);else if(U.type==="Elif"||U.type==="Else")q++;else J.appendChild(w(U,Z)),q++}}function j0($,J,Z,q){let U=!1,Q=J,W=$[Q];if(o4(W.condition,q))w4(W,Z,q),U=!0;Q++;while(Q<$.length){let Y=$[Q];if(Y.type==="Elif"){if(!U&&o4(Y.condition,q))w4(Y,Z,q),U=!0;Q++}else if(Y.type==="Else"){if(!U)w4(Y,Z,q);Q++;break}else break}return Q}function o4($,J){if(!$)return!1;if(g($))return Boolean(u($,J.store,J.scope));return Boolean(J.store.get($))}function w4($,J,Z){if(!$.children)return;n($.children,J,Z)}function K($,J){if(g($)){let Z=u($,J.store,J.scope);return Z==null?"":String(Z)}return $==null?"":String($)}function y($,J){if(g($))return u($,J.store,J.scope);return $}function b($){return{store:$.store,transport:$.transport,scope:$.scope,rerender:$.rerender,onToast:$.onToast}}function B($,J){let Z=document.createElement($);if(J)Z.className=J;return Z}function b4($,J){return $.textContent=J,$}function J1(){_("Column",L0),_("Row",P0),_("Grid",t4),_("GridItem",e4),_("Container",O0),_("Div",$1),_("Span",V0),_("Dashboard",t4),_("DashboardItem",e4),_("Pages",I0),_("Page",$1),_("Detail",R0),_("MasterDetail",A0)}function L0($,J){let Z=B("div","pf-column");Z.style.display="flex",Z.style.flexDirection="column";let q=z4($);if(q!=null)Z.style.gap=`${q*4}px`;if($.align!=null)Z.style.alignItems=Z1($.align);if($.justify!=null)Z.style.justifyContent=q1($.justify);return j($,Z,J),Z}function P0($,J){let Z=B("div","pf-row");Z.style.display="flex",Z.style.flexDirection="row";let q=z4($);if(q!=null)Z.style.gap=`${q*4}px`;if($.align!=null)Z.style.alignItems=Z1($.align);if($.justify!=null)Z.style.justifyContent=q1($.justify);if($.wrap===!0)Z.style.flexWrap="wrap";return j($,Z,J),Z}function t4($,J){let Z=B("div","pf-grid");Z.style.display="grid";let q=$.columns??3;Z.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let U=z4($);if(U!=null)Z.style.gap=`${U*4}px`;return j($,Z,J),Z}function e4($,J){let Z=B("div","pf-grid-item");if($.colSpan!=null)Z.style.gridColumn=`span ${$.colSpan}`;if($.rowSpan!=null)Z.style.gridRow=`span ${$.rowSpan}`;return j($,Z,J),Z}function O0($,J){let Z=B("div","pf-container");if(Z.style.maxWidth=$.maxWidth??"1200px",Z.style.margin="0 auto",$.padding!=null)Z.style.padding=`${$.padding*4}px`;return j($,Z,J),Z}function $1($,J){let Z=B("div","pf-div");return j($,Z,J),Z}function V0($,J){let Z=B("span","pf-span");return j($,Z,J),Z}function I0($,J){let Z=B("div","pf-pages");return j($,Z,J),Z}function R0($,J){let Z=B("div","pf-detail"),q=$.of!=null?y($.of,J):void 0;if(q!=null&&q!==""&&q!==!1&&q!==0)j($,Z,J);else if($.empty!=null){let U=$.empty;Z.appendChild(w(U,J))}return Z}function A0($,J){let Z=B("div","pf-master-detail");Z.style.display="flex",Z.style.flexDirection="row";let q=z4($);if(q!=null)Z.style.gap=`${q*4}px`;let U=$.masterWidth??"33%",Q=$.children??[];if(Q.length>0){let W=B("div","pf-master-detail-master");W.style.width=U,W.style.flexShrink="0",W.style.overflow="auto",W.appendChild(w(Q[0],J)),Z.appendChild(W)}if(Q.length>1){let W=B("div","pf-master-detail-detail");W.style.flex="1",W.style.overflow="auto",W.appendChild(w(Q[1],J)),Z.appendChild(W)}return Z}var k0=/\bgap-(\d+)\b/;function z4($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let J=k0.exec($.cssClass);if(J)return Number(J[1])}return null}function Z1($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function q1($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}function Q1(){_("Heading",f0),_("H1",($,J)=>D4($,J,"h1")),_("H2",($,J)=>D4($,J,"h2")),_("H3",($,J)=>D4($,J,"h3")),_("H4",($,J)=>D4($,J,"h4")),_("Text",S0),_("P",w0),_("Lead",($,J)=>$4($,J,"p","pf-lead")),_("Large",($,J)=>$4($,J,"span","pf-large")),_("Small",($,J)=>$4($,J,"small","pf-small")),_("Muted",($,J)=>$4($,J,"p","pf-muted")),_("BlockQuote",($,J)=>$4($,J,"blockquote","pf-blockquote")),_("Label",($,J)=>$4($,J,"label","pf-label")),_("Link",b0),_("Code",y0),_("Markdown",m0),_("Kbd",v0)}function f0($,J){let Z=$.level??2,q=`h${Math.min(Math.max(Z,1),6)}`,U=document.createElement(q);return U.className=`pf-heading pf-${q}`,U.textContent=K($.content,J),U}function D4($,J,Z){let q=document.createElement(Z);return q.className=`pf-heading pf-${Z}`,q.textContent=K($.content,J),q}function S0($,J){return b4(B("span","pf-text"),K($.content,J))}function w0($,J){return b4(B("p","pf-p"),K($.content,J))}function $4($,J,Z,q){let U=document.createElement(Z);return U.className=q,U.textContent=K($.content,J),U}var C0=/^\s*(javascript|vbscript|data):/i;function b0($,J){let Z=document.createElement("a");if(Z.className="pf-link",Z.textContent=K($.content,J),$.href!=null){let q=K($.href,J);if(!C0.test(q))Z.href=q}if($.target!=null)Z.target=K($.target,J);return Z}function y0($,J){let Z=B("pre","pf-code"),q=B("code");if(q.textContent=K($.content,J),$.language!=null)q.setAttribute("data-language",$.language);return Z.appendChild(q),Z}function m0($,J){let Z=B("div","pf-markdown"),q=K($.content,J);return Z.innerHTML=W1(q),Z.setAttribute("data-markdown","true"),Z}var U1=/^\s*(javascript|vbscript|data):/i;function F4($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function E4($){let J=F4($),Z=[];return J=J.replace(/`([^`]+)`/g,(q,U)=>{return Z.push(`<code>${U}</code>`),`CODE${Z.length-1}`}),J=J.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(q,U,Q)=>{if(U1.test(Q))return F4(U);return`<img src="${Q}" alt="${U}" />`}),J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,U,Q)=>{if(U1.test(Q))return U;return`<a href="${Q}">${U}</a>`}),J=J.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),J=J.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),J=J.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),J=J.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),J=J.replace(/\*(.+?)\*/g,"<em>$1</em>"),J=J.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),J=J.replace(/~~(.+?)~~/g,"<del>$1</del>"),J=J.replace(/\uFDD0CODE(\d+)\uFDD0/g,(q,U)=>Z[parseInt(U)]),J}function W1($){let J=$.replace(/\r\n?/g,`
|
|
1
|
+
(()=>{var{defineProperty:k0,getOwnPropertyNames:h1,getOwnPropertyDescriptor:g1}=Object,u1=Object.prototype.hasOwnProperty;function x1($){return this[$]}var p1=($)=>{var J=(p0??=new WeakMap).get($),Z;if(J)return J;if(J=k0({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var q of h1($))if(!u1.call(J,q))k0(J,q,{get:x1.bind($,q),enumerable:!(Z=g1($,q))||Z.enumerable})}return p0.set($,J),J},p0;var c1=($)=>$;function s1($,J){this[$]=c1.bind(null,J)}var l1=($,J)=>{for(var Z in J)k0($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:s1.bind(J,Z)})};var U2={};l1(U2,{unregisterPipe:()=>Q0,registerPipe:()=>U0,registerComponent:()=>_,listPipes:()=>H0,isIframe:()=>Z0,applyHostTheme:()=>M0,app:()=>A0,PrefabRenderer:()=>p,Bridge:()=>t});class q0{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return i1(this.data,$)}getAll(){return this.data}set($,J){c0(this.data,$,J),this.notify($)}toggle($){let J=this.get($),Z=J==null||J===!1||J===0||J==="";this.set($,Z)}append($,J,Z){let q=this.get($);if(!Array.isArray(q)){this.set($,[J]);return}if(Z!==void 0)q.splice(Z,0,J);else q.push(J);this.notify($)}pop($,J){let Z=this.get($);if(!Array.isArray(Z))return;if(typeof J==="number")Z.splice(J,1);else{let q=Z.indexOf(J);if(q>=0)Z.splice(q,1)}this.notify($)}merge($){for(let[J,Z]of Object.entries($))c0(this.data,J,Z);for(let J of Object.keys($))this.notify(J)}subscribe($,J){if(!this.subscribers.has($))this.subscribers.set($,new Set);return this.subscribers.get($)?.add(J),()=>this.subscribers.get($)?.delete(J)}subscribeAll($){return this.globalSubscribers.add($),()=>this.globalSubscribers.delete($)}notify($){this.generation++;let J=$.split(".");for(let Z=1;Z<=J.length;Z++){let q=J.slice(0,Z).join("."),U=this.subscribers.get(q);if(U)U.forEach((Q)=>Q())}this.globalSubscribers.forEach((Z)=>Z())}}function i1($,J){let Z=J.split("."),q=$;for(let U of Z){if(q==null||typeof q!=="object")return;q=q[U]}return q}var d1=new Set(["__proto__","constructor","prototype"]);function c0($,J,Z){let q=J.split(".");if(q.some((Q)=>d1.has(Q))){console.warn(`[prefab] Blocked prototype pollution attempt: ${J}`);return}let U=$;for(let Q=0;Q<q.length-1;Q++){let W=q[Q];if(U[W]==null||typeof U[W]!=="object")U[W]={};U=U[W]}U[q[q.length-1]]=Z}var e=new Map;function U0($,J){if(e.has($)&&e.get($)!==J)console.warn(`[prefab] pipe "${$}" re-registered`);e.set($,J)}function Q0($){return e.delete($)}function H0(){return[...e.keys()]}function s0($){return e.get($)}var l0=-1,f0=new Map,r1=/\{\{\s*(.+?)\s*\}\}/g;function g($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function u($,J,Z){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&J4(q,"{{")===1){let U=q.slice(2,-2).trim();return i0(U,J,Z)}return $.replace(r1,(U,Q)=>{let W=i0(Q.trim(),J,Z);return W==null?"":String(W)})}function i0($,J,Z){let[q,...U]=$4($),Q=h(q.trim(),J,Z);for(let W of U)Q=n1(W.trim(),Q,J,Z);return Q}function h($,J,Z){let q=t1($);if(q>=0){let W=$.slice(0,q).trim(),Y=$.slice(q+1),M=e1(Y);if(M>=0){let B=Y.slice(0,M).trim(),G=Y.slice(M+1).trim(),N=h(W,J,Z);return N!==null&&N!==void 0&&N!==!1&&N!==0&&N!==""?h(B,J,Z):h(G,J,Z)}}let U=B0($,"||");if(U>=0){let W=h($.slice(0,U).trim(),J,Z);return W!==null&&W!==void 0&&W!==!1&&W!==0&&W!==""?W:h($.slice(U+2).trim(),J,Z)}let Q=B0($,"&&");if(Q>=0){let W=h($.slice(0,Q).trim(),J,Z);if(W===null||W===void 0||W===!1||W===0||W==="")return W;return h($.slice(Q+2).trim(),J,Z)}for(let[W,Y]of a1){let M=B0($,W);if(M>=0){let B=h($.slice(0,M).trim(),J,Z),G=h($.slice(M+W.length).trim(),J,Z);return Y(B,G)}}if($.startsWith("!")){let W=h($.slice(1).trim(),J,Z);return W===null||W===void 0||W===!1||W===0||W===""}for(let[W,Y]of o1){let M=B0($,W);if(M>=0){let B=h($.slice(0,M).trim(),J,Z),G=h($.slice(M+W.length).trim(),J,Z);return Y(Number(B),Number(G))}}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(Z&&$.startsWith("$")){let W=$.indexOf(".");if(W>=0){let Y=$.slice(0,W),M=$.slice(W+1),B=Z[Y];return G0(B,M)}return Z[$]}if(Z){let W=$.split(".")[0];if(W in Z)return G0(Z[W],$.includes(".")?$.slice(W.length+1):"")}return J.get($)}function n1($,J,Z,q){let U=$.indexOf(":"),Q=U>=0?$.slice(0,U).trim():$,W=U>=0?$.slice(U+1).trim():void 0,Y=W?S0(W):void 0;switch(Q){case"find":{if(!Array.isArray(J)||!W)return;let M=d0(W);if(M.length<2)return;let B=S0(M[0]),G=M[1].trim(),N;if(G.startsWith("'")&&G.endsWith("'")||G.startsWith('"')&&G.endsWith('"'))N=G.slice(1,-1);else if(Z){if(q&&G.startsWith("$")){let K=G.indexOf(".");if(K>=0){let F=G.slice(0,K);if(F in q)N=G0(q[F],G.slice(K+1))}else if(G in q)N=q[G]}if(N===void 0&&!(q&&G.startsWith("$")))if(q){let K=G.split(".")[0];N=K in q?G0(q[K],G.includes(".")?G.slice(K.length+1):""):Z.get(G)}else N=Z.get(G)}else N=G;if(N==null)return;let z=Z?.generation??0;if(z!==l0)f0=new Map,l0=z;let T=f0.get(J);if(!T)T=new Map,f0.set(J,T);let D=T.get(B);if(!D){D=new Map;for(let K of J)if(K!=null&&typeof K==="object"){let F=K[B];if(F!=null)D.set(String(F),K)}T.set(B,D)}return D.get(String(N))}case"dot":{if(J==null||typeof J!=="object"||typeof Y!=="string")return;return J[Y]}case"length":return Array.isArray(J)?J.length:typeof J==="string"?J.length:0;case"upper":return typeof J==="string"?J.toUpperCase():J;case"lower":return typeof J==="string"?J.toLowerCase():J;case"truncate":if(typeof J==="string"&&typeof Y==="number")return J.slice(0,Y);return J;case"join":return Array.isArray(J)?J.join(typeof Y==="string"?Y:", "):J;case"first":return Array.isArray(J)?J[0]:J;case"last":return Array.isArray(J)?J[J.length-1]:J;case"abs":return Math.abs(Number(J));case"round":return typeof Y==="number"?Number(Number(J).toFixed(Y)):Math.round(Number(J));case"number":return typeof Y==="number"?Number(Number(J).toFixed(Y)):Number(J);case"currency":{let M=typeof Y==="string"?Y:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:M}).format(Number(J))}catch{return J}}case"percent":return typeof Y==="number"?`${(Number(J)*100).toFixed(Y)}%`:`${Math.round(Number(J)*100)}%`;case"compact":{let M=typeof Y==="number"?Y:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:M}).format(Number(J))}catch{return J}}case"date":try{return new Date(J).toLocaleDateString()}catch{return J}case"time":try{return new Date(J).toLocaleTimeString()}catch{return J}case"datetime":try{return new Date(J).toLocaleString()}catch{return J}case"pluralize":{let M=Number(J),B=typeof Y==="string"?Y:"";return M===1?B:`${B}s`}case"default":return J==null||J===""?Y:J;case"selectattr":return Array.isArray(J)&&typeof Y==="string"?J.filter((M)=>M!=null&&typeof M==="object"&&Boolean(M[Y])):J;case"rejectattr":return Array.isArray(J)&&typeof Y==="string"?J.filter((M)=>{if(M==null||typeof M!=="object")return!1;let B=M[Y];return B==null||B===!1||B===0||B===""}):J;default:{let M=s0(Q);if(M){let B=W?d0(W).map(S0):[];return M(J,...B)}return J}}}var a1=[["!==",($,J)=>$!==J],["===",($,J)=>$===J],["!=",($,J)=>$!=J],["==",($,J)=>$==J],[">=",($,J)=>Number($)>=Number(J)],["<=",($,J)=>Number($)<=Number(J)],[">",($,J)=>Number($)>Number(J)],["<",($,J)=>Number($)<Number(J)]],o1=[[" + ",($,J)=>$+J],[" - ",($,J)=>$-J],[" * ",($,J)=>$*J],[" / ",($,J)=>J!==0?$/J:0],[" % ",($,J)=>J!==0?$%J:0]];function B0($,J){let Z=null;for(let q=0;q<$.length;q++){let U=$[q];if(U==="'"||U==='"')Z=Z===U?null:Z??U;if(!Z&&$.slice(q,q+J.length)===J)return q}return-1}function t1($){let J=0,Z=null;for(let q=0;q<$.length;q++){let U=$[q];if(U==="'"||U==='"')Z=Z===U?null:Z??U;if(!Z){if(U==="(")J++;else if(U===")")J--;else if(U==="?"&&J===0)return q}}return-1}function e1($){let J=0,Z=null;for(let q=0;q<$.length;q++){let U=$[q];if(U==="'"||U==='"')Z=Z===U?null:Z??U;if(!Z){if(U==="?"||U==="(")J++;else if(U===")")J--;else if(U===":"&&J===0)return q}}return-1}function $4($){let J=[],Z="",q=null;for(let U=0;U<$.length;U++){let Q=$[U];if(Q==="'"||Q==='"')q=q===Q?null:q??Q;if(Q==="|"&&!q)if($[U+1]==="|")Z+="||",U++;else J.push(Z),Z="";else Z+=Q}return J.push(Z),J}function S0($){let J=$.replace(/^['"]|['"]$/g,"");if(J==="true")return!0;if(J==="false")return!1;let Z=Number(J);return isNaN(Z)?J:Z}function d0($){let J=[],Z="",q=null;for(let U of $){if(U==="'"||U==='"')q=q===U?null:q??U;if(U===","&&!q)J.push(Z),Z="";else Z+=U}return J.push(Z),J}function G0($,J){if(!J)return $;let Z=J.split("."),q=$;for(let U of Z){if(q==null||typeof q!=="object")return;q=q[U]}return q}function J4($,J){let Z=0,q=0;while((q=$.indexOf(J,q))!==-1)Z++,q+=J.length;return Z}async function k($,J){let Z=Array.isArray($)?$:[$];for(let q of Z)await Z4(q,J)}async function Z4($,J){let Z=$.action;switch(Z){case"setState":{q4($,J);return}case"toggleState":{U4($,J);return}case"appendState":{Q4($,J);return}case"popState":{W4($,J);return}case"showToast":{Y4($,J);return}case"closeOverlay":{_4($,J);return}case"openLink":{M4($);return}case"setInterval":{B4($,J);return}case"toolCall":case"callTool":return G4($,J);case"sendMessage":return X4($,J);case"updateContext":{K4($,J);return}case"fetch":return z4($,J);case"openFilePicker":{D4($,J);return}case"callHandler":return E4($,J);case"requestDisplayMode":{F4($,J);return}default:console.warn(`[prefab] Unknown action: ${Z}`)}}function q4($,J){let{key:Z,value:q}=$;if(g(q))q=u(q,J.store,J.scope);J.store.set(Z,q),J.rerender(),r($.onSuccess,J)}function U4($,J){J.store.toggle($.key),J.rerender()}function Q4($,J){let Z=$.value;if(g(Z))Z=u(Z,J.store,J.scope);J.store.append($.key,Z,$.index),J.rerender()}function W4($,J){J.store.pop($.key,$.index),J.rerender()}function Y4($,J){J.onToast?.({message:K0($.message,J),description:$.description!=null?K0($.description,J):void 0,variant:$.variant,duration:$.duration})}function _4($,J){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function M4($){if(typeof window<"u"){let J=$.url;if(!J){console.warn("[prefab] openLink: missing url");return}if(!n0(J)){console.warn(`[prefab] Blocked unsafe URL scheme: ${J}`);return}window.open(J,$.target??"_blank")}}var X0=new Set,N4=20,H4=100;function B4($,J){let Z=Math.max($.intervalMs,H4),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(X0.size>=N4){console.warn("[prefab] Max intervals reached, ignoring new setInterval");return}let U=globalThis.setInterval(()=>void k(q,J),Z);X0.add(U)}function r0(){for(let $ of X0)globalThis.clearInterval($);X0.clear()}async function G4($,J){if(!J.transport){console.warn("[prefab] No MCP transport configured for toolCall");return}let Z=$.tool,q=a0($.arguments,J);try{let U=await J.transport.callTool(Z,q);if($.resultKey!=null)J.store.set($.resultKey,U);J.rerender(),await r($.onSuccess,J,{$result:U})}catch(U){await r($.onError,J,{$error:U})}}async function X4($,J){if(!J.transport){console.warn("[prefab] No MCP transport configured for sendMessage");return}await J.transport.sendMessage(K0($.message,J))}function K4($,J){let Z=$.context;if(Z!=null)J.store.merge(Z),J.rerender()}async function z4($,J){let Z=K0($.url,J);if(!n0(Z)){console.warn(`[prefab] Blocked unsafe URL in fetch: ${Z}`);return}let q=$.method??"GET",U=$.headers,Q=$.body!==void 0?JSON.stringify($.body):void 0;try{let W=await globalThis.fetch(Z,{method:q,headers:{"Content-Type":"application/json",...U},...Q&&{body:Q}}),Y=await W.json().catch(()=>W.text());if($.resultKey!=null)J.store.set($.resultKey,Y);J.rerender(),await r($.onSuccess,J,{$result:Y})}catch(W){await r($.onError,J,{$error:W})}}function D4($,J){if(typeof document>"u")return;let Z=document.createElement("input");if(Z.type="file",$.accept!=null)Z.accept=$.accept;if($.multiple===!0)Z.multiple=!0;Z.addEventListener("change",()=>{let q=Array.from(Z.files??[]);if($.resultKey!=null)J.store.set($.resultKey,q);J.rerender(),r($.onSuccess,J,{$result:q})}),Z.click()}async function E4($,J){let Z=$.handler,q=a0($.arguments,J);if(!J.transport){console.warn(`[prefab] No transport configured for callHandler: ${Z}`);return}try{let U=await J.transport.callTool(Z,q);if($.resultKey!=null)J.store.set($.resultKey,U);J.rerender(),await r($.onSuccess,J,{$result:U})}catch(U){await r($.onError,J,{$error:U})}}function F4($,J){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var T4=/^\s*(javascript|vbscript|data):/i;function n0($){return!T4.test($)}function K0($,J){if(g($)){let Z=u($,J.store,J.scope);return Z==null?"":String(Z)}return $==null?"":String($)}function a0($,J){if(!$)return{};let Z={};for(let[q,U]of Object.entries($))Z[q]=g(U)?u(U,J.store,J.scope):U;return Z}async function r($,J,Z){if($==null)return;let q={...J.scope,...Z};await k($,{...J,scope:q})}var C0=new Map;function _($,J){if(C0.has($))console.warn(`[prefab] overriding existing renderer for "${$}"`);C0.set($,J)}function w($,J){if(J.defs?.[$.type]){let U={...J.defs[$.type],...$,type:J.defs[$.type].type};return w(U,J)}let Z=C0.get($.type),q;if(Z)q=Z($,J);else if(q=document.createElement("div"),q.setAttribute("data-prefab-type",$.type),$.children)for(let U of $.children)q.appendChild(w(U,J));if(q instanceof HTMLElement){if($.id)q.id=$.id;if($.cssClass){let U=X($.cssClass,J);if(U)q.className=(q.className?q.className+" ":"")+U}}if($.onMount){let U=$.onMount,Q=y(J);queueMicrotask(()=>void k(U,Q))}return q}function j($,J,Z){if(!$.children)return;n($.children,J,Z)}function n($,J,Z){let q=0;while(q<$.length){let U=$[q];if(U.type==="If")q=j4($,q,J,Z);else if(U.type==="Elif"||U.type==="Else")q++;else J.appendChild(w(U,Z)),q++}}function j4($,J,Z,q){let U=!1,Q=J,W=$[Q];if(o0(W.condition,q))w0(W,Z,q),U=!0;Q++;while(Q<$.length){let Y=$[Q];if(Y.type==="Elif"){if(!U&&o0(Y.condition,q))w0(Y,Z,q),U=!0;Q++}else if(Y.type==="Else"){if(!U)w0(Y,Z,q);Q++;break}else break}return Q}function o0($,J){if(!$)return!1;if(g($))return Boolean(u($,J.store,J.scope));return Boolean(J.store.get($))}function w0($,J,Z){if(!$.children)return;n($.children,J,Z)}function X($,J){if(g($)){let Z=u($,J.store,J.scope);return Z==null?"":String(Z)}return $==null?"":String($)}function b($,J){if(g($))return u($,J.store,J.scope);return $}function y($){return{store:$.store,transport:$.transport,scope:$.scope,rerender:$.rerender,onToast:$.onToast}}function H($,J){let Z=document.createElement($);if(J)Z.className=J;return Z}function y0($,J){return $.textContent=J,$}function J1(){_("Column",L4),_("Row",P4),_("Grid",t0),_("GridItem",e0),_("Container",O4),_("Div",$1),_("Span",V4),_("Dashboard",t0),_("DashboardItem",e0),_("Pages",I4),_("Page",$1),_("Detail",R4),_("MasterDetail",A4)}function L4($,J){let Z=H("div","pf-column");Z.style.display="flex",Z.style.flexDirection="column";let q=z0($);if(q!=null)Z.style.gap=`${q*4}px`;if($.align!=null)Z.style.alignItems=Z1($.align);if($.justify!=null)Z.style.justifyContent=q1($.justify);return j($,Z,J),Z}function P4($,J){let Z=H("div","pf-row");Z.style.display="flex",Z.style.flexDirection="row";let q=z0($);if(q!=null)Z.style.gap=`${q*4}px`;if($.align!=null)Z.style.alignItems=Z1($.align);if($.justify!=null)Z.style.justifyContent=q1($.justify);if($.wrap===!0)Z.style.flexWrap="wrap";return j($,Z,J),Z}function t0($,J){let Z=H("div","pf-grid");Z.style.display="grid";let q=$.columns??3;Z.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let U=z0($);if(U!=null)Z.style.gap=`${U*4}px`;return j($,Z,J),Z}function e0($,J){let Z=H("div","pf-grid-item");if($.colSpan!=null)Z.style.gridColumn=`span ${$.colSpan}`;if($.rowSpan!=null)Z.style.gridRow=`span ${$.rowSpan}`;return j($,Z,J),Z}function O4($,J){let Z=H("div","pf-container");if(Z.style.maxWidth=$.maxWidth??"1200px",Z.style.margin="0 auto",$.padding!=null)Z.style.padding=`${$.padding*4}px`;return j($,Z,J),Z}function $1($,J){let Z=H("div","pf-div");return j($,Z,J),Z}function V4($,J){let Z=H("span","pf-span");return j($,Z,J),Z}function I4($,J){let Z=H("div","pf-pages");return j($,Z,J),Z}function R4($,J){let Z=H("div","pf-detail"),q=$.of!=null?b($.of,J):void 0;if(q!=null&&q!==""&&q!==!1&&q!==0)j($,Z,J);else if($.empty!=null){let U=$.empty;Z.appendChild(w(U,J))}return Z}function A4($,J){let Z=H("div","pf-master-detail");Z.style.display="flex",Z.style.flexDirection="row";let q=z0($);if(q!=null)Z.style.gap=`${q*4}px`;let U=$.masterWidth??"33%",Q=$.children??[];if(Q.length>0){let W=H("div","pf-master-detail-master");W.style.width=U,W.style.flexShrink="0",W.style.overflow="auto",W.appendChild(w(Q[0],J)),Z.appendChild(W)}if(Q.length>1){let W=H("div","pf-master-detail-detail");W.style.flex="1",W.style.overflow="auto",W.appendChild(w(Q[1],J)),Z.appendChild(W)}return Z}var k4=/\bgap-(\d+)\b/;function z0($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let J=k4.exec($.cssClass);if(J)return Number(J[1])}return null}function Z1($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function q1($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}function Q1(){_("Heading",f4),_("H1",($,J)=>D0($,J,"h1")),_("H2",($,J)=>D0($,J,"h2")),_("H3",($,J)=>D0($,J,"h3")),_("H4",($,J)=>D0($,J,"h4")),_("Text",S4),_("P",w4),_("Lead",($,J)=>$0($,J,"p","pf-lead")),_("Large",($,J)=>$0($,J,"span","pf-large")),_("Small",($,J)=>$0($,J,"small","pf-small")),_("Muted",($,J)=>$0($,J,"p","pf-muted")),_("BlockQuote",($,J)=>$0($,J,"blockquote","pf-blockquote")),_("Label",($,J)=>$0($,J,"label","pf-label")),_("Link",y4),_("Code",b4),_("Markdown",m4),_("Kbd",v4)}function f4($,J){let Z=$.level??2,q=`h${Math.min(Math.max(Z,1),6)}`,U=document.createElement(q);return U.className=`pf-heading pf-${q}`,U.textContent=X($.content,J),U}function D0($,J,Z){let q=document.createElement(Z);return q.className=`pf-heading pf-${Z}`,q.textContent=X($.content,J),q}function S4($,J){return y0(H("span","pf-text"),X($.content,J))}function w4($,J){return y0(H("p","pf-p"),X($.content,J))}function $0($,J,Z,q){let U=document.createElement(Z);return U.className=q,U.textContent=X($.content,J),U}var C4=/^\s*(javascript|vbscript|data):/i;function y4($,J){let Z=document.createElement("a");if(Z.className="pf-link",Z.textContent=X($.content,J),$.href!=null){let q=X($.href,J);if(!C4.test(q))Z.href=q}if($.target!=null)Z.target=X($.target,J);return Z}function b4($,J){let Z=H("pre","pf-code"),q=H("code");if(q.textContent=X($.content,J),$.language!=null)q.setAttribute("data-language",$.language);return Z.appendChild(q),Z}function m4($,J){let Z=H("div","pf-markdown"),q=X($.content,J);return Z.innerHTML=W1(q),Z.setAttribute("data-markdown","true"),Z}var U1=/^\s*(javascript|vbscript|data):/i;function F0($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function E0($){let J=F0($),Z=[];return J=J.replace(/`([^`]+)`/g,(q,U)=>{return Z.push(`<code>${U}</code>`),`CODE${Z.length-1}`}),J=J.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(q,U,Q)=>{if(U1.test(Q))return F0(U);return`<img src="${Q}" alt="${U}" />`}),J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,U,Q)=>{if(U1.test(Q))return U;return`<a href="${Q}">${U}</a>`}),J=J.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),J=J.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),J=J.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),J=J.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),J=J.replace(/\*(.+?)\*/g,"<em>$1</em>"),J=J.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),J=J.replace(/~~(.+?)~~/g,"<del>$1</del>"),J=J.replace(/\uFDD0CODE(\d+)\uFDD0/g,(q,U)=>Z[parseInt(U)]),J}function W1($){let J=$.replace(/\r\n?/g,`
|
|
2
2
|
`).split(`
|
|
3
|
-
`),Z=[],q=0;while(q<J.length){let U=J[q];if(U.trimStart().startsWith("```")){let Y=U.trimStart().slice(3).trim(),M=[];q++;while(q<J.length&&!J[q].trimStart().startsWith("```"))M.push(
|
|
4
|
-
`)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(U)){Z.push("<hr />"),q++;continue}let Q=/^(#{1,6})\s+(.+)$/.exec(U);if(Q){let Y=Q[1].length;Z.push(`<h${Y}>${
|
|
5
|
-
`))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(U)){Z.push("<ul>");while(q<J.length&&/^[\s]*[-*+]\s+/.test(J[q]))Z.push(`<li>${
|
|
6
|
-
`)}function v0($,J){let Z=document.createElement("kbd");return Z.className="pf-kbd",Z.textContent=K($.content,J),Z}function _1(){_("Card",h0),_("CardHeader",y4("pf-card-header")),_("CardTitle",Y1("pf-card-title","h3")),_("CardDescription",Y1("pf-card-description","p")),_("CardContent",y4("pf-card-content")),_("CardFooter",y4("pf-card-footer"))}function h0($,J){let Z=B("div","pf-card");return Z.style.border="1px solid var(--border, #e5e7eb)",Z.style.borderRadius="var(--radius, 8px)",Z.style.backgroundColor="var(--card, #fff)",Z.style.overflow="hidden",j($,Z,J),Z}function y4($){return(J,Z)=>{let q=B("div",$);return q.style.padding="16px 24px",j(J,q,Z),q}}function Y1($,J){return(Z,q)=>{let U=document.createElement(J);return U.className=$,U.textContent=K(Z.content,q),U}}function M1(){_("DataTable",g0),_("Badge",u0),_("Dot",x0),_("Metric",p0),_("Ring",c0),_("Progress",s0),_("Separator",l0),_("Loader",d0),_("Icon",i0),_("Sparkline",r0)}function g0($,J){let Z=B("div","pf-datatable-wrapper"),q=document.createElement("table");q.className="pf-datatable",q.style.width="100%",q.style.borderCollapse="collapse";let U=$.columns??[],Q=y($.rows,J),W=$.rowKey,Y=$.selected,M=document.createElement("thead"),H=document.createElement("tr");for(let N of U){let X=document.createElement("th");X.className="pf-datatable-th",X.textContent=N.header??N.key,X.style.padding="8px 12px",X.style.textAlign="left",X.style.borderBottom="2px solid var(--border, #e5e7eb)",H.appendChild(X)}M.appendChild(H),q.appendChild(M);let G=document.createElement("tbody");if(Array.isArray(Q)){let N=Y!=null?y(Y,J):void 0;for(let X of Q){let T=document.createElement("tr");T.className="pf-datatable-row";let D=X;if(W&&N!=null&&D[W]!=null&&String(D[W])===String(N))T.classList.add("pf-datatable-row-selected"),T.style.backgroundColor="var(--primary-bg, #eff6ff)";if($.onRowClick!=null&&W)T.style.cursor="pointer",T.addEventListener("click",()=>{let z={...J.scope,$item:D,$index:Q.indexOf(X)},F=b({...J,scope:z});k($.onRowClick,F)});for(let z of U){let F=document.createElement("td");F.className="pf-datatable-td";let O;if(z.accessor)O=y(`{{ $item.${z.accessor} }}`,{...J,scope:{...J.scope,$item:D}});else if(O=D[z.key],z.format&&O!=null)O=y(`{{ __fmtVal | ${z.format} }}`,{...J,scope:{...J.scope,__fmtVal:O}});F.textContent=O==null?"":String(O),F.style.padding="8px 12px",F.style.borderBottom="1px solid var(--border, #e5e7eb)",T.appendChild(F)}G.appendChild(T)}}if(q.appendChild(G),$.search===!0){let N=document.createElement("input");N.type="text",N.placeholder="Search...",N.className="pf-datatable-search",N.style.marginBottom="8px",N.style.padding="6px 12px",N.style.width="100%",N.style.boxSizing="border-box",N.addEventListener("input",()=>{let X=N.value.toLowerCase(),T=Array.from(G.querySelectorAll("tr"));for(let D of T){let z=D.textContent.toLowerCase();D.style.display=z.includes(X)?"":"none"}}),Z.appendChild(N)}return Z.appendChild(q),Z}function u0($,J){let Z=B("span","pf-badge"),q=$.variant??"default";return Z.setAttribute("data-variant",q),Z.style.alignItems="center",Z.style.padding="2px 10px",Z.style.borderRadius="9999px",Z.style.fontSize="12px",Z.style.fontWeight="500",Z.textContent=K($.label??$.content,J),n0(Z,q),Z}function x0($,J){let Z=B("span","pf-dot"),q=$.color??"gray";return Z.style.display="inline-block",Z.style.width="8px",Z.style.height="8px",Z.style.borderRadius="50%",Z.style.backgroundColor=q,Z}function p0($,J){let Z=B("div","pf-metric"),q=B("div","pf-metric-label");q.textContent=K($.label,J),q.style.fontSize="14px",q.style.color="var(--muted-foreground, #6b7280)",Z.appendChild(q);let U=B("div","pf-metric-value");if(U.textContent=K($.value,J),U.style.fontSize="28px",U.style.fontWeight="700",Z.appendChild(U),$.delta!=null){let Q=B("span","pf-metric-delta");Q.textContent=K($.delta,J);let W=$.trend??"",Y=$.trendSentiment??"neutral";if(Q.style.fontSize="14px",Q.style.color=Y==="positive"?"green":Y==="negative"?"red":"inherit",W==="up")Q.textContent="↑ "+Q.textContent;else if(W==="down")Q.textContent="↓ "+Q.textContent;Z.appendChild(Q)}if($.description!=null){let Q=B("div","pf-metric-desc");Q.textContent=K($.description,J),Q.style.fontSize="12px",Q.style.color="var(--muted-foreground, #6b7280)",Z.appendChild(Q)}return Z}function c0($,J){let Z=B("div","pf-ring"),q=$.size??80,U=$.thickness??8,Q=Number(y($.value,J)??0),W=Math.max(0,Math.min(100,Q)),Y=(q-U)/2,M=2*Math.PI*Y,H=M*(1-W/100),G=document.createElementNS("http://www.w3.org/2000/svg","svg");G.setAttribute("width",String(q)),G.setAttribute("height",String(q)),G.setAttribute("viewBox",`0 0 ${q} ${q}`);let N=document.createElementNS("http://www.w3.org/2000/svg","circle");N.setAttribute("cx",String(q/2)),N.setAttribute("cy",String(q/2)),N.setAttribute("r",String(Y)),N.setAttribute("fill","none"),N.setAttribute("stroke","var(--muted, #e5e7eb)"),N.setAttribute("stroke-width",String(U));let X=document.createElementNS("http://www.w3.org/2000/svg","circle");if(X.setAttribute("cx",String(q/2)),X.setAttribute("cy",String(q/2)),X.setAttribute("r",String(Y)),X.setAttribute("fill","none"),X.setAttribute("stroke","var(--primary, #3b82f6)"),X.setAttribute("stroke-width",String(U)),X.setAttribute("stroke-dasharray",String(M)),X.setAttribute("stroke-dashoffset",String(H)),X.setAttribute("stroke-linecap","round"),X.style.transform="rotate(-90deg)",X.style.transformOrigin="center",G.appendChild(N),G.appendChild(X),Z.appendChild(G),$.label!=null){let T=B("div","pf-ring-label");T.textContent=K($.label,J),T.style.textAlign="center",T.style.fontSize="12px",Z.appendChild(T)}return Z}function s0($,J){let Z=B("div","pf-progress");Z.setAttribute("role","progressbar");let q=Number(y($.value,J)??0),U=$.max??100,Q=U>0?Math.max(0,Math.min(100,q/U*100)):0;Z.setAttribute("aria-valuenow",String(q)),Z.setAttribute("aria-valuemin","0"),Z.setAttribute("aria-valuemax",String(U)),Z.style.height="8px",Z.style.backgroundColor="var(--muted, #e5e7eb)",Z.style.borderRadius="4px",Z.style.overflow="hidden";let W=B("div","pf-progress-fill");return W.style.height="100%",W.style.width=`${Q}%`,W.style.backgroundColor="var(--primary, #3b82f6)",W.style.borderRadius="4px",W.style.transition="width 0.3s ease",Z.appendChild(W),Z}function l0($,J){let Z=document.createElement("hr");return Z.className="pf-separator",Z.style.border="none",Z.style.borderTop="1px solid var(--border, #e5e7eb)",Z.style.margin="8px 0",Z}function d0($,J){let Z=B("div","pf-loader");return Z.textContent="⏳",Z.style.display="flex",Z.style.justifyContent="center",Z.style.padding="16px",Z}function i0($,J){let Z=B("span","pf-icon");return Z.setAttribute("data-icon",K($.name??$.content,J)),Z}function r0($,J){let Z=B("div","pf-sparkline"),q=$.data??[];if(q.length===0)return Z;let U=120,Q=32,W=Math.max(...q),Y=Math.min(...q),M=W-Y||1,H=document.createElementNS("http://www.w3.org/2000/svg","svg");H.setAttribute("width",String(U)),H.setAttribute("height",String(Q)),H.setAttribute("viewBox",`0 0 ${U} ${Q}`);let G=q.length>1?q.length-1:1,N=q.map((T,D)=>{let z=D/G*U,F=Q-(T-Y)/M*(Q-4)-2;return`${z},${F}`}).join(" "),X=document.createElementNS("http://www.w3.org/2000/svg","polyline");return X.setAttribute("points",N),X.setAttribute("fill","none"),X.setAttribute("stroke","var(--primary, #3b82f6)"),X.setAttribute("stroke-width","1.5"),H.appendChild(X),Z.appendChild(H),Z}function n0($,J){let Z={default:{bg:"var(--primary, #3b82f6)",fg:"#fff"},secondary:{bg:"var(--secondary, #f3f4f6)",fg:"var(--secondary-foreground, #1f2937)"},destructive:{bg:"var(--destructive, #ef4444)",fg:"#fff"},success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"},outline:{bg:"transparent",fg:"inherit"}},q=Z[J]??Z.default;if($.style.backgroundColor=q.bg,$.style.color=q.fg,J==="outline")$.style.border="1px solid var(--border, #e5e7eb)"}function B1(){_("Form",a0),_("Input",o0),_("Textarea",t0),_("Button",e0),_("ButtonGroup",$8),_("Select",J8),_("SelectOption",Z8),_("SelectGroup",T4("pf-select-group")),_("SelectLabel",W4("pf-select-label")),_("SelectSeparator",N1),_("Checkbox",q8),_("Switch",U8),_("Slider",Q8),_("Radio",Y8),_("RadioGroup",_8),_("Combobox",M8),_("ComboboxOption",N8),_("ComboboxGroup",T4("pf-combobox-group")),_("ComboboxLabel",W4("pf-combobox-label")),_("ComboboxSeparator",N1),_("Calendar",B8),_("DatePicker",H8),_("Field",T4("pf-field")),_("FieldTitle",W4("pf-field-title")),_("FieldDescription",W4("pf-field-description")),_("FieldContent",T4("pf-field-content")),_("FieldError",W4("pf-field-error")),_("ChoiceCard",G8)}function a0($,J){let Z=document.createElement("form");return Z.className="pf-form",Z.addEventListener("submit",(q)=>{q.preventDefault();let U=new FormData(Z),Q={};if(U.forEach((W,Y)=>{Q[Y]=W}),J.store.merge(Q),$.onSubmit!=null){let W=b(J);W.scope={...J.scope,...Q},k($.onSubmit,W)}}),j($,Z,J),Z}function o0($,J){let Z=B("div","pf-input-wrapper");if(Z.style.display="flex",Z.style.flexDirection="column",Z.style.gap="4px",$.label!=null){let Q=document.createElement("label");if(Q.className="pf-input-label",Q.textContent=K($.label,J),$.name!=null)Q.htmlFor=$.name;Q.style.fontSize="14px",Q.style.fontWeight="500",Z.appendChild(Q)}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=K($.placeholder,J);if($.required===!0)q.required=!0,q.setAttribute("aria-required","true");if($.error!=null)q.setAttribute("aria-invalid","true");let U=$.name;if(U){let Q=J.store.get(U);if(Q!=null)q.value=String(Q);q.addEventListener("input",()=>{if(J.store.set(U,q.value),$.onChange!=null)k($.onChange,{...b(J),scope:{...J.scope,$event:q.value}})})}return m4(q),Z.appendChild(q),Z}function t0($,J){let Z=B("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=K($.placeholder,J);if($.rows!=null)q.rows=$.rows;if($.required===!0)q.setAttribute("aria-required","true");let U=$.name;if(U!=null){let Q=J.store.get(U);if(Q!=null)q.value=String(Q);q.addEventListener("input",()=>{if(J.store.set(U,q.value),$.onChange!=null)k($.onChange,{...b(J),scope:{...J.scope,$event:q.value}})})}return m4(q),Z.appendChild(q),Z}function e0($,J){let Z=document.createElement("button");Z.className="pf-button",Z.type=$.submit===!0?"submit":"button",Z.textContent=K($.label,J);let q=$.variant??"default";if(Z.setAttribute("data-variant",q),W8(Z,q),$.size!=null)Z.setAttribute("data-size",$.size);if($.disabled===!0)Z.disabled=!0;if($.onClick!=null)Z.addEventListener("click",()=>{k($.onClick,b(J))});return Z}function $8($,J){let Z=B("div","pf-button-group");return Z.style.display="flex",Z.style.gap="8px",j($,Z,J),Z}function J8($,J){let Z=B("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(m4(q),$.placeholder!=null){let W=document.createElement("option");W.value="",W.textContent=K($.placeholder,J),W.disabled=!0,W.selected=!0,W.hidden=!0,q.appendChild(W)}let U=$.options;if(Array.isArray(U))for(let W of U){let Y=document.createElement("option");Y.value=W.value??"",Y.textContent=W.label??Y.value,q.appendChild(Y)}if($.children)for(let W of $.children)if(W.type==="SelectOption"){let Y=document.createElement("option");Y.value=W.value??"",Y.textContent=W.label??Y.value,q.appendChild(Y)}else q.appendChild(w(W,J));let Q=$.name;if(Q){let W=J.store.get(Q);if(W!=null)q.value=String(W);q.addEventListener("change",()=>{if(J.store.set(Q,q.value),$.onChange!=null)k($.onChange,{...b(J),scope:{...J.scope,$event:q.value}})})}return Z.appendChild(q),Z}function Z8($,J){return B("span")}function q8($,J){let Z=B("label","pf-checkbox-wrapper");Z.style.display="flex",Z.style.alignItems="center",Z.style.gap="8px",Z.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 U=$.name;if(U){let Q=J.store.get(U);if(typeof Q==="boolean")q.checked=Q;q.addEventListener("change",()=>{if(J.store.set(U,q.checked),$.onChange!=null)k($.onChange,{...b(J),scope:{...J.scope,$event:q.checked}})})}if(Z.appendChild(q),$.label!=null){let Q=B("span");Q.textContent=K($.label,J),Z.appendChild(Q)}return Z}function U8($,J){let Z=B("label","pf-switch-wrapper");Z.style.display="flex",Z.style.alignItems="center",Z.style.gap="8px",Z.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 U=$.name;if(U){let Q=J.store.get(U);if(typeof Q==="boolean")q.checked=Q;q.addEventListener("change",()=>{if(J.store.set(U,q.checked),$.onChange!=null)k($.onChange,{...b(J),scope:{...J.scope,$event:q.checked}})})}if(Z.appendChild(q),$.label!=null){let Q=B("span");Q.textContent=K($.label,J),Z.appendChild(Q)}return Z}function Q8($,J){let Z=B("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=String($.min);if($.max!=null)q.max=String($.max);if($.step!=null)q.step=String($.step);let U=$.name;if(U){let Q=J.store.get(U);if(Q!=null)q.value=String(Q);q.addEventListener("input",()=>{if(J.store.set(U,Number(q.value)),$.onChange!=null)k($.onChange,{...b(J),scope:{...J.scope,$event:Number(q.value)}})})}return Z.appendChild(q),Z}function m4($){$.style.padding="8px 12px",$.style.border="1px solid var(--border, #d1d5db)",$.style.borderRadius="var(--radius, 6px)",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function W8($,J){$.style.padding="8px 16px",$.style.borderRadius="var(--radius, 6px)",$.style.fontSize="14px",$.style.fontWeight="500",$.style.cursor="pointer",$.style.border="none";let Z={default:{bg:"var(--primary, #3b82f6)",fg:"#fff"},secondary:{bg:"var(--secondary, #f3f4f6)",fg:"var(--secondary-foreground, #1f2937)"},destructive:{bg:"var(--destructive, #ef4444)",fg:"#fff"},outline:{bg:"transparent",fg:"inherit"},ghost:{bg:"transparent",fg:"inherit"},link:{bg:"transparent",fg:"var(--primary, #3b82f6)"}},q=Z[J]??Z.default;if($.style.backgroundColor=q.bg,$.style.color=q.fg,J==="outline")$.style.border="1px solid var(--border, #d1d5db)"}function T4($){return(J,Z)=>{let q=B("div",$);return j(J,q,Z),q}}function W4($){return(J,Z)=>{let q=B("span",$);return q.textContent=K(J.content,Z),q}}function N1(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.borderTop="1px solid var(--border, #e5e7eb)",$.style.margin="4px 0",$}function Y8($,J){let Z=B("label","pf-radio");Z.style.display="flex",Z.style.alignItems="center",Z.style.gap="8px",Z.style.cursor="pointer";let q=document.createElement("input");if(q.type="radio",q.value=K($.value,J),Z.appendChild(q),$.label!=null){let U=B("span","pf-radio-label");U.textContent=K($.label,J),Z.appendChild(U)}return Z}function _8($,J){let Z=B("fieldset","pf-radio-group");if(Z.style.border="none",Z.style.padding="0",Z.style.display="flex",Z.style.flexDirection="column",Z.style.gap="8px",$.label!=null){let Q=document.createElement("legend");Q.textContent=K($.label,J),Q.style.fontWeight="500",Q.style.marginBottom="4px",Z.appendChild(Q)}j($,Z,J);let q=K($.name,J),U=J.store.get(q);for(let Q of Array.from(Z.querySelectorAll('input[type="radio"]')))if(Q.name=q,U!=null&&Q.value===String(U))Q.checked=!0;return Z.addEventListener("change",(Q)=>{let W=Q.target;if(W.type==="radio"){if(J.store.set(q,W.value),$.onChange!=null)k($.onChange,b(J))}}),Z}function M8($,J){let Z=B("div","pf-combobox"),q=document.createElement("input");if(q.className="pf-combobox-input",q.type="text",q.name=K($.name,J),$.placeholder!=null)q.placeholder=K($.placeholder,J);if($.value!==void 0)q.value=K($.value,J);let U=q.name,Q=J.store.get(U);if(Q!=null)q.value=String(Q);q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.border="1px solid var(--border, #d1d5db)",q.style.width="100%",q.style.boxSizing="border-box";let W=B("div","pf-combobox-dropdown");if(W.style.display="none",W.style.position="absolute",W.style.background="var(--popover, #fff)",W.style.border="1px solid var(--border, #d1d5db)",W.style.borderRadius="6px",W.style.maxHeight="200px",W.style.overflowY="auto",W.style.zIndex="50",j($,W,J),q.addEventListener("focus",()=>{W.style.display="block"}),q.addEventListener("blur",()=>{setTimeout(()=>{W.style.display="none"},150)}),$.searchable!==!1)q.addEventListener("input",()=>{let Y=q.value.toLowerCase();for(let M of Array.from(W.querySelectorAll(".pf-combobox-option"))){let H=M.textContent.toLowerCase();M.style.display=H.includes(Y)?"":"none"}});if($.onChange!=null)Z.addEventListener("pf-combobox-select",()=>{k($.onChange,{...b(J),scope:{...J.scope,$event:q.value}})});return Z.style.position="relative",Z.appendChild(q),Z.appendChild(W),Z}function N8($,J){let Z=B("div","pf-combobox-option");return Z.style.padding="6px 12px",Z.style.cursor="pointer",Z.textContent=K($.label??$.value,J),Z.dataset.value=K($.value,J),Z.addEventListener("mousedown",()=>{let q=Z.closest(".pf-combobox"),U=q?.querySelector("input");if(U)U.value=Z.dataset.value??"",J.store.set(U.name,U.value),q?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),Z}function B8($,J){let Z=B("div","pf-calendar"),q=document.createElement("input");if(q.type="date",q.name=K($.name,J),$.value!==void 0)q.value=K($.value,J);let U=q.name,Q=J.store.get(U);if(Q!=null)q.value=String(Q);if($.minDate!=null)q.min=K($.minDate,J);if($.maxDate!=null)q.max=K($.maxDate,J);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.border="1px solid var(--border, #d1d5db)",q.addEventListener("change",()=>{if(J.store.set(q.name,q.value),$.onChange!=null)k($.onChange,b(J))}),Z.appendChild(q),Z}function H8($,J){let Z=B("div","pf-datepicker"),q=document.createElement("input");if(q.type="date",q.name=K($.name,J),$.placeholder!=null)q.placeholder=K($.placeholder,J);if($.value!==void 0)q.value=K($.value,J);let U=q.name,Q=J.store.get(U);if(Q!=null)q.value=String(Q);if($.minDate!=null)q.min=K($.minDate,J);if($.maxDate!=null)q.max=K($.maxDate,J);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.border="1px solid var(--border, #d1d5db)",q.style.width="100%",q.style.boxSizing="border-box",q.addEventListener("change",()=>{if(J.store.set(q.name,q.value),$.onChange!=null)k($.onChange,b(J))}),Z.appendChild(q),Z}function G8($,J){let Z=B("div","pf-choice-card");if(Z.style.border="2px solid var(--border, #d1d5db)",Z.style.borderRadius="8px",Z.style.padding="16px",Z.style.cursor="pointer",Z.style.transition="border-color 0.2s",Z.dataset.value=K($.value,J),$.selected===!0)Z.dataset.selected="true",Z.style.borderColor="var(--primary, #3b82f6)",Z.style.backgroundColor="var(--accent, #eff6ff)";if($.label!=null){let q=B("div","pf-choice-card-label");q.textContent=K($.label,J),q.style.fontWeight="600",Z.appendChild(q)}if($.description!=null){let q=B("div","pf-choice-card-description");q.textContent=K($.description,J),q.style.fontSize="14px",q.style.color="var(--muted-foreground, #6b7280)",Z.appendChild(q)}if(j($,Z,J),$.onClick!=null)Z.addEventListener("click",()=>{k($.onClick,b(J))});return Z}function H1(){_("Tabs",X8),_("Tab",K8),_("Accordion",z8),_("AccordionItem",D8),_("Dialog",E8),_("Popover",F8),_("Tooltip",T8),_("HoverCard",j8),_("Carousel",L8)}function X8($,J){let Z=B("div","pf-tabs"),q=B("div","pf-tabs-bar");q.setAttribute("role","tablist"),q.style.display="flex",q.style.gap="4px",q.style.borderBottom="2px solid var(--border, #e5e7eb)",q.style.marginBottom="12px";let U=[],Q=[];if($.children)for(let Y=0;Y<$.children.length;Y++){let M=$.children[Y],H=`pf-tab-${Math.random().toString(36).slice(2,8)}`,G=`pf-panel-${Math.random().toString(36).slice(2,8)}`,N=document.createElement("button");N.type="button",N.className="pf-tab-trigger",N.textContent=M.title??`Tab ${Y+1}`,N.setAttribute("role","tab"),N.setAttribute("aria-selected",Y===0?"true":"false"),N.setAttribute("aria-controls",G),N.id=H,N.tabIndex=Y===0?0:-1,N.style.padding="8px 16px",N.style.border="none",N.style.background="none",N.style.cursor="pointer",N.style.borderBottom="2px solid transparent",N.style.marginBottom="-2px",N.style.fontSize="14px";let X=B("div","pf-tab-panel");if(X.style.display=Y===0?"block":"none",X.setAttribute("role","tabpanel"),X.setAttribute("aria-labelledby",H),X.id=G,X.tabIndex=0,j(M,X,J),N.addEventListener("click",()=>{W(Y)}),Y===0)N.style.borderBottomColor="var(--primary, #3b82f6)",N.style.fontWeight="600";Q.push(N),U.push(X),q.appendChild(N)}function W(Y){U.forEach((M)=>M.style.display="none"),Q.forEach((M)=>{M.style.borderBottomColor="transparent",M.style.fontWeight="normal",M.setAttribute("aria-selected","false"),M.tabIndex=-1}),U[Y].style.display="block",Q[Y].style.borderBottomColor="var(--primary, #3b82f6)",Q[Y].style.fontWeight="600",Q[Y].setAttribute("aria-selected","true"),Q[Y].tabIndex=0,Q[Y].focus()}q.addEventListener("keydown",(Y)=>{let M=Q.indexOf(Y.target);if(M<0)return;let H;if(Y.key==="ArrowRight")H=(M+1)%Q.length;else if(Y.key==="ArrowLeft")H=(M-1+Q.length)%Q.length;else if(Y.key==="Home")H=0;else if(Y.key==="End")H=Q.length-1;else return;Y.preventDefault(),W(H)}),Z.appendChild(q);for(let Y of U)Z.appendChild(Y);return Z}function K8($,J){let Z=B("div","pf-tab");return j($,Z,J),Z}function z8($,J){let Z=B("div","pf-accordion");return j($,Z,J),Z}function D8($,J){let Z=B("div","pf-accordion-item");Z.style.borderBottom="1px solid var(--border, #e5e7eb)";let q=`pf-acc-${Math.random().toString(36).slice(2,8)}`,U=document.createElement("button");U.type="button",U.className="pf-accordion-trigger",U.textContent=$.title??"",U.setAttribute("aria-expanded","false"),U.setAttribute("aria-controls",q),U.style.width="100%",U.style.textAlign="left",U.style.padding="12px 0",U.style.border="none",U.style.background="none",U.style.cursor="pointer",U.style.fontSize="14px",U.style.fontWeight="500";let Q=B("div","pf-accordion-content");return Q.id=q,Q.setAttribute("role","region"),Q.setAttribute("aria-labelledby",U.id),Q.style.display="none",Q.style.paddingBottom="12px",j($,Q,J),U.addEventListener("click",()=>{let W=Q.style.display!=="none";Q.style.display=W?"none":"block",U.setAttribute("aria-expanded",W?"false":"true")}),Z.appendChild(U),Z.appendChild(Q),Z}function E8($,J){let Z=B("div","pf-dialog-wrapper");if($.trigger!=null){let Q=w($.trigger,J);Q.addEventListener("click",()=>{q.showModal()}),Z.appendChild(Q)}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.border="1px solid var(--border, #e5e7eb)",q.style.borderRadius="var(--radius, 8px)",q.style.padding="24px",$.title!=null){let Q=B("h2","pf-dialog-title");Q.textContent=K($.title,J),Q.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,q.setAttribute("aria-labelledby",Q.id),q.appendChild(Q)}if($.description!=null){let Q=B("p","pf-dialog-desc");Q.textContent=K($.description,J),Q.style.color="var(--muted-foreground, #6b7280)",q.appendChild(Q)}let U=B("div","pf-dialog-body");if(j($,U,J),q.appendChild(U),$.dismissible!==!1)q.addEventListener("click",(Q)=>{if(Q.target===q)q.close()});return document.addEventListener("prefab:close-overlay",()=>q.close()),Z.appendChild(q),Z}function F8($,J){let Z=B("div","pf-popover");Z.style.position="relative",Z.style.display="inline-block";let q=B("div","pf-popover-content");if(q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="12px",q.style.border="1px solid var(--border, #e5e7eb)",q.style.borderRadius="var(--radius, 8px)",q.style.backgroundColor="var(--popover, #fff)",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",$.title!=null){let U=B("div","pf-popover-title");U.textContent=K($.title,J),U.style.fontWeight="600",U.style.marginBottom="4px",q.appendChild(U)}return j($,q,J),Z.addEventListener("click",(U)=>{if(q.contains(U.target)&&q.style.display!=="none")return;q.style.display=q.style.display==="none"?"block":"none"}),Z.appendChild(q),Z}function T8($,J){let Z=B("div","pf-tooltip");Z.style.position="relative",Z.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,U=B("div","pf-tooltip-content");return U.id=q,U.setAttribute("role","tooltip"),U.textContent=K($.content??"",J),U.style.display="none",U.style.position="absolute",U.style.bottom="100%",U.style.left="50%",U.style.transform="translateX(-50%)",U.style.padding="4px 8px",U.style.borderRadius="4px",U.style.backgroundColor="var(--popover, #1f2937)",U.style.color="#fff",U.style.fontSize="12px",U.style.whiteSpace="nowrap",U.style.zIndex="50",j($,Z,J),Z.setAttribute("aria-describedby",q),Z.addEventListener("mouseenter",()=>{U.style.display="block"}),Z.addEventListener("mouseleave",()=>{U.style.display="none"}),Z.addEventListener("focus",()=>{U.style.display="block"},!0),Z.addEventListener("blur",()=>{U.style.display="none"},!0),Z.appendChild(U),Z}function j8($,J){let Z=B("div","pf-hover-card");Z.style.position="relative",Z.style.display="inline-block";let q=B("div","pf-hover-card-content");return q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="16px",q.style.border="1px solid var(--border, #e5e7eb)",q.style.borderRadius="var(--radius, 8px)",q.style.backgroundColor="var(--card, #fff)",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",q.style.minWidth="200px",j($,q,J),Z.addEventListener("mouseenter",()=>{q.style.display="block"}),Z.addEventListener("mouseleave",()=>{q.style.display="none"}),Z.appendChild(q),Z}function L8($,J){let Z=B("div","pf-carousel");Z.style.position="relative",Z.style.overflow="hidden",Z.setAttribute("role","region"),Z.setAttribute("aria-roledescription","carousel"),Z.setAttribute("aria-label",K($.label??"Carousel",J));let q=B("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",j($,q,J);let U=0,Q=$.children?.length??0,W=document.createElement("button");W.type="button",W.textContent="‹",W.className="pf-carousel-prev",W.setAttribute("aria-label","Previous slide"),W.style.position="absolute",W.style.left="4px",W.style.top="50%",W.style.transform="translateY(-50%)",W.style.zIndex="10";let Y=document.createElement("button");Y.type="button",Y.textContent="›",Y.className="pf-carousel-next",Y.setAttribute("aria-label","Next slide"),Y.style.position="absolute",Y.style.right="4px",Y.style.top="50%",Y.style.transform="translateY(-50%)",Y.style.zIndex="10";let M=()=>{q.style.transform=`translateX(-${U*100}%)`};return W.addEventListener("click",()=>{if(Q===0)return;U=Math.max(0,U-1),M()}),Y.addEventListener("click",()=>{if(Q===0)return;U=Math.min(Q-1,U+1),M()}),Z.appendChild(q),Z.appendChild(W),Z.appendChild(Y),Z}function G1(){_("ForEach",P8),_("If",X1),_("Elif",O8),_("Else",V8),_("Condition",I8),_("Define",R8),_("Use",A8),_("Slot",k8)}function P8($,J){let Z=document.createDocumentFragment(),q=$.expression;if(!q)return Z;let U;if(g(q)){let W=u(q,J.store,J.scope);U=Array.isArray(W)?W:[]}else{let W=J.store.get(q);U=Array.isArray(W)?W:[]}let Q=$.let??{};for(let W=0;W<U.length;W++){let Y=U[W],M={...J.scope,$item:Y,$index:W,...Q},H={...J,scope:M};if($.children)n($.children,Z,H)}return Z}function X1($,J){if(K1($.condition,J)){let q=document.createDocumentFragment();if($.children)n($.children,q,J);return q}return document.createDocumentFragment()}function O8($,J){return X1($,J)}function V8($,J){let Z=document.createDocumentFragment();if($.children)n($.children,Z,J);return Z}function K1($,J){if(!$)return!1;if(g($))return Boolean(u($,J.store,J.scope));return Boolean(J.store.get($))}function I8($,J){let Z=document.createDocumentFragment(),q=$.cases,U=$.else;if(q){for(let Q of q)if(K1(Q.when,J)){if(Q.children)n(Q.children,Z,J);return Z}}if(U)n(U,Z,J);return Z}function R8($,J){let Z=$.name;if(Z&&$.children)J.templates=J.templates??{},J.templates[Z]=$.children;return document.createDocumentFragment()}function A8($,J){let Z=document.createDocumentFragment(),q=$.def??$.name,U=J.templates?.[q];if(!U)return Z;let Q=$.overrides??{},W={...J.scope,...Q},Y={...J,scope:W};for(let M of U)Z.appendChild(w(M,Y));return Z}function k8($,J){let Z=document.createDocumentFragment(),q=$.name??"default",Q=J.slots?.[q]??$.children;if(Q)for(let W of Q)Z.appendChild(w(W,J));return Z}function z1(){_("Alert",f8),_("AlertTitle",S8),_("AlertDescription",w8)}function f8($,J){let Z=B("div","pf-alert");Z.setAttribute("role","alert");let q=$.variant??"default";if(Z.setAttribute("data-variant",q),Z.style.padding="12px 16px",Z.style.borderRadius="var(--radius, 8px)",Z.style.border="1px solid var(--border, #e5e7eb)",q==="destructive")Z.style.borderColor="var(--destructive, #ef4444)",Z.style.color="var(--destructive, #ef4444)";if($.icon!=null){let U=B("span","pf-alert-icon");U.setAttribute("data-icon",$.icon),U.style.marginRight="8px",Z.appendChild(U)}return j($,Z,J),Z}function S8($,J){let Z=B("h5","pf-alert-title");return Z.textContent=K($.content,J),Z.style.fontWeight="600",Z.style.marginBottom="4px",Z}function w8($,J){let Z=B("p","pf-alert-description");return Z.textContent=K($.content,J),Z.style.fontSize="14px",Z}function D1(){_("Image",C8),_("Audio",b8),_("Video",y8),_("Embed",m8),_("Svg",h8),_("DropZone",g8),_("Mermaid",u8)}function C8($,J){let Z=document.createElement("img");if(Z.className="pf-image",Z.src=K($.src,J),$.alt!=null)Z.alt=K($.alt,J);if($.width!=null)Z.width=$.width;if($.height!=null)Z.height=$.height;return Z.style.maxWidth="100%",Z}function b8($,J){let Z=document.createElement("audio");return Z.className="pf-audio",Z.src=K($.src,J),Z.controls=!0,Z}function y8($,J){let Z=document.createElement("video");if(Z.className="pf-video",Z.src=K($.src,J),Z.controls=!0,$.width!=null)Z.width=$.width;if($.height!=null)Z.height=$.height;return Z.style.maxWidth="100%",Z}function m8($,J){let Z=B("div","pf-embed"),q=document.createElement("iframe");return q.src=K($.src,J),q.style.width="100%",q.style.height=$.height!=null?`${$.height}px`:"400px",q.style.border="none",q.setAttribute("sandbox","allow-scripts"),Z.appendChild(q),Z}var v8=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 h8($,J){let Z=B("div","pf-svg"),q=K($.content,J);if(!q.includes("<svg"))return Z;let Q=new DOMParser().parseFromString(q,"image/svg+xml").querySelector("svg");if(!Q)return Z;return E1(Q),Z.appendChild(document.importNode(Q,!0)),Z}function E1($){let J=Array.from($.children);for(let Z of J){if(!v8.has(Z.tagName.toLowerCase())){Z.remove();continue}for(let q of Array.from(Z.attributes)){let U=q.name.toLowerCase();if(U.startsWith("on")||U==="href"&&q.value.trim().toLowerCase().startsWith("javascript:"))Z.removeAttribute(q.name)}E1(Z)}}function g8($,J){let Z=B("div","pf-dropzone");return Z.style.border="2px dashed var(--border, #d1d5db)",Z.style.borderRadius="var(--radius, 8px)",Z.style.padding="32px",Z.style.textAlign="center",Z.style.cursor="pointer",Z.textContent=K($.label??"Drop files here",J),Z.addEventListener("dragover",(q)=>{q.preventDefault(),Z.style.borderColor="var(--primary, #3b82f6)"}),Z.addEventListener("dragleave",()=>{Z.style.borderColor="var(--border, #d1d5db)"}),Z.addEventListener("drop",(q)=>{q.preventDefault(),Z.style.borderColor="var(--border, #d1d5db)"}),Z}function u8($,J){let Z=B("div","pf-mermaid");Z.setAttribute("data-mermaid","true");let q=K($.content,J);if(Z.textContent=q,typeof globalThis.mermaid<"u")Z.classList.add("mermaid"),Z.textContent=q;return Z}var L4=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function P4($,J){let Z=document.createElement("div");return Z.className="pf-chart-tooltip",$.appendChild(Z),$.addEventListener("mouseleave",()=>{Z.classList.remove("pf-visible")}),{wrapper:$,tooltip:Z,svgEl:J}}function Y4($,J,Z,q,U){let{tooltip:Q,svgEl:W,wrapper:Y}=$;if(U.length===0)return;let M="";if(q)M+=`<div class="pf-chart-tooltip-label">${j4(q)}</div>`;for(let F of U)M+='<div class="pf-chart-tooltip-row">',M+=`<span class="pf-chart-tooltip-dot" style="background:${j4(F.color)}"></span>`,M+=`<span>${j4(F.label)}:</span> <strong>${j4(String(F.value))}</strong>`,M+="</div>";Q.innerHTML=M;let H=W.getBoundingClientRect(),G=Y.getBoundingClientRect(),N=W.viewBox.baseVal,X=H.width/(N.width||1),T=H.left-G.left+J*X,D=Q.offsetWidth||100,z=T+12;if(z+D>G.width)z=T-D-12;Q.style.left=`${Math.max(0,z)}px`,Q.style.top="4px",Q.classList.add("pf-visible")}function j4($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function F1($,J,Z,q,U,Q,W,Y){let M=U.plotWidth/Z.length;for(let H=0;H<Z.length;H++){let G=U.plotLeft+H*M,N=document.createElementNS("http://www.w3.org/2000/svg","rect");N.setAttribute("x",String(G)),N.setAttribute("y",String(U.plotTop)),N.setAttribute("width",String(M)),N.setAttribute("height",String(U.plotHeight)),N.setAttribute("fill","transparent"),N.style.cursor="default";let X=Q?Z[H][Q]:void 0,T=X!=null?Y?Y(X):String(X):void 0,D=q.map((A,R)=>({label:A.label??A.dataKey,value:W(Z[H][A.dataKey],A,R),color:A.color??L4[R%L4.length]})),z=G+M/2,F=()=>Y4($,z,U.plotTop,T,D),O=()=>$.tooltip.classList.remove("pf-visible");N.addEventListener("mouseenter",F),N.addEventListener("mouseleave",O),N.addEventListener("touchstart",F,{passive:!0}),N.addEventListener("touchend",O,{passive:!0}),J.appendChild(N)}}function T1($,J,Z,q,U,Q,W,Y,M,H){let G=Z.length===1?U.plotWidth:U.plotWidth/(Z.length-1);for(let N=0;N<Z.length;N++){let X=Z.length===1?(U.plotLeft+U.plotRight)/2:U.plotLeft+N/(Z.length-1)*U.plotWidth,T=Z.length===1?U.plotLeft:X-G/2,D=Z.length===1?U.plotWidth:G,z=document.createElementNS("http://www.w3.org/2000/svg","rect");z.setAttribute("x",String(Math.max(U.plotLeft,T))),z.setAttribute("y",String(U.plotTop)),z.setAttribute("width",String(Math.min(D,U.plotRight-Math.max(U.plotLeft,T)))),z.setAttribute("height",String(U.plotHeight)),z.setAttribute("fill","transparent"),z.style.cursor="default";let F=Q?Z[N][Q]:void 0,O=F!=null?H?H(F):String(F):void 0,A=q.map((L,C)=>({label:L.label??L.dataKey,value:W(Z[N][L.dataKey],L,C),color:L.color??L4[C%L4.length]})),R=()=>{if(Y4($,X,U.plotTop,O,A),Y)Y.setAttribute("x1",String(X)),Y.setAttribute("x2",String(X)),Y.setAttribute("opacity","1");if(M)for(let L of M){for(let C of L)C.setAttribute("data-visible","false");L[N]?.setAttribute("data-visible","true")}},E=()=>{if($.tooltip.classList.remove("pf-visible"),Y)Y.setAttribute("opacity","0");if(M)for(let L of M)for(let C of L)C.setAttribute("data-visible","false")};z.addEventListener("mouseenter",R),z.addEventListener("mouseleave",E),z.addEventListener("touchstart",R,{passive:!0}),z.addEventListener("touchend",E,{passive:!0}),J.appendChild(z)}}function L1(){_("BarChart",p8),_("LineChart",j1),_("AreaChart",j1),_("PieChart",c8),_("RadarChart",v4),_("ScatterChart",v4),_("RadialChart",v4),_("Histogram",s8)}var l=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],_4="var(--muted-foreground, #6b7280)",x8="var(--border, #e5e7eb)",h4="10";function P1($,J,Z,q=!1){let U=Z?44:0,Q=$-(q?44:0),W=10,Y=J-24;return{plotLeft:U,plotRight:Q,plotTop:10,plotBottom:Y,plotWidth:Q-U,plotHeight:Y-10}}function O1($,J=5){if($<=0)return[0];let Z=$/J,q=Math.pow(10,Math.floor(Math.log10(Z))),U=Z/q,Q=U<=1.5?q:U<=3?2*q:U<=7?5*q:10*q,W=[];for(let Y=0;Y<=$+Q*0.01;Y+=Q)W.push(Math.round(Y*1000)/1000);return W}function V1($,J,Z,q,U){let Q=O1(Z);for(let W of Q){let Y=J.plotBottom-(Z>0?W/Z*J.plotHeight:0),M=document.createElementNS("http://www.w3.org/2000/svg","text");if(M.setAttribute("x",String(J.plotLeft-6)),M.setAttribute("y",String(Y+3)),M.setAttribute("text-anchor","end"),M.setAttribute("font-size",h4),M.setAttribute("fill",_4),M.textContent=g4(W,U),$.appendChild(M),q&&W>0){let H=document.createElementNS("http://www.w3.org/2000/svg","line");H.setAttribute("x1",String(J.plotLeft)),H.setAttribute("y1",String(Y)),H.setAttribute("x2",String(J.plotRight)),H.setAttribute("y2",String(Y)),H.setAttribute("stroke",x8),H.setAttribute("stroke-width","1"),H.setAttribute("stroke-dasharray","4 3"),$.appendChild(H)}}}function I1($,J,Z,q){let U=O1(Z);for(let Q of U){let W=J.plotBottom-(Z>0?Q/Z*J.plotHeight:0),Y=document.createElementNS("http://www.w3.org/2000/svg","text");Y.setAttribute("x",String(J.plotRight+6)),Y.setAttribute("y",String(W+3)),Y.setAttribute("text-anchor","start"),Y.setAttribute("font-size",h4),Y.setAttribute("fill",_4),Y.textContent=g4(Q,q),$.appendChild(Y)}}function R1($,J,Z,q,U,Q){for(let W=0;W<J.length;W++){let Y=document.createElementNS("http://www.w3.org/2000/svg","text");Y.setAttribute("x",String(q(W))),Y.setAttribute("y",String(U+14)),Y.setAttribute("text-anchor","middle"),Y.setAttribute("font-size",h4),Y.setAttribute("fill",_4);let M=J[W][Z];Y.textContent=M==null?"":Q?Q(M):String(M),$.appendChild(Y)}}function A1($,J){let Z=document.createElementNS("http://www.w3.org/2000/svg","line");Z.setAttribute("x1",String(J.plotLeft)),Z.setAttribute("y1",String(J.plotBottom)),Z.setAttribute("x2",String(J.plotRight)),Z.setAttribute("y2",String(J.plotBottom)),Z.setAttribute("stroke",_4),Z.setAttribute("stroke-width","1"),$.appendChild(Z)}function J4($,J,Z){if($==null)return"";let q=y(`{{ __v | ${J} }}`,{...Z,scope:{...Z.scope,__v:$}});return q==null?String($):String(q)}function g4($,J){if(J==="currency")return`$${$.toLocaleString()}`;if(J==="percent")return`${$}%`;if($>=1e6)return`${($/1e6).toFixed(1)}M`;if($>=1000)return`${($/1000).toFixed(1)}K`;return String($)}function k1($,J,Z){return(q,U)=>{if(q===null||q===void 0)return"—";if(U.tooltipFormat)return J4(q,U.tooltipFormat,$);let Q=U.yAxisId==="right"?Z:J;return g4(Number(q),Q)}}function p8($,J){let Z=B("div","pf-chart pf-bar-chart"),q=y($.data,J)??[],U=$.series??[],Q=$.height??300;if(q.length===0||U.length===0)return Z.textContent="No chart data",Z;let W=$.showYAxis!==!1,Y=$.showGrid===!0,M=$.showYAxisRight===!0,H=$.showTooltip!==!1,G=$.xAxis,N=$.tooltipXKey,X=$.xAxisFormat,T=$.tooltipXFormat,D=U.filter((I)=>I.yAxisId!=="right"),z=U.filter((I)=>I.yAxisId==="right"),F=M&&z.length>0,O=D.length>0?Math.max(...q.flatMap((I)=>D.map((V)=>Number(I[V.dataKey]??0))),1):1,A=F?Math.max(...q.flatMap((I)=>z.map((V)=>Number(I[V.dataKey]??0))),1):1,R=400,E=P1(R,Q,W,F),L=O4(R,Q,"Bar");if(W)V1(L,E,O,Y,$.yAxisFormat);if(F)I1(L,E,A,$.yAxisRightFormat);A1(L,E);let C=E.plotWidth/q.length,d=C/(U.length+1);for(let I=0;I<q.length;I++)for(let V=0;V<U.length;V++){let f=U[V],x=q[I][f.dataKey];if(x===null||x===void 0)continue;let m=f.yAxisId==="right"?A:O,c=Number(x),s=Math.max(0,c/m*E.plotHeight),a=E.plotLeft+I*C+V*d+d/2,P=document.createElementNS("http://www.w3.org/2000/svg","rect");P.setAttribute("x",String(a)),P.setAttribute("y",String(E.plotBottom-s)),P.setAttribute("width",String(d*0.8)),P.setAttribute("height",String(s)),P.setAttribute("fill",f.color??l[V%l.length]),P.setAttribute("rx","2"),L.appendChild(P)}if(G){let I=X?(V)=>J4(V,X,J):void 0;R1(L,q,G,(V)=>{return E.plotLeft+V*C+C/2},E.plotBottom,I)}if(H){let I=P4(Z,L),V=k1(J,$.yAxisFormat,$.yAxisRightFormat);F1(I,L,q,U,E,N??G,V,T?(x)=>J4(x,T,J):void 0)}return u4(Z,U,$.showLegend),Z.appendChild(L),Z}function j1($,J){let Z=B("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),q=y($.data,J)??[],U=$.series??[],Q=$.height??300;if(q.length===0||U.length===0)return Z.textContent="No chart data",Z;let W=$.showYAxis!==!1,Y=$.showGrid===!0,M=$.showYAxisRight===!0,H=$.showTooltip!==!1,G=$.xAxis,N=$.tooltipXKey,X=$.xAxisFormat,T=$.tooltipXFormat,D=U.filter((V)=>V.yAxisId!=="right"),z=U.filter((V)=>V.yAxisId==="right"),F=M&&z.length>0,O=D.length>0?Math.max(...q.flatMap((V)=>D.map((f)=>Number(V[f.dataKey]??0))),1):1,A=F?Math.max(...q.flatMap((V)=>z.map((f)=>Number(V[f.dataKey]??0))),1):1,R=400,E=P1(R,Q,W,F),L=O4(R,Q,$.type==="AreaChart"?"Area":"Line"),C=$.type==="AreaChart";if(W)V1(L,E,O,Y,$.yAxisFormat);if(F)I1(L,E,A,$.yAxisRightFormat);A1(L,E);let d=[];for(let V=0;V<U.length;V++){let f=U[V],x=f.yAxisId==="right",i=x?A:O,m=f.color??l[V%l.length],c=q.map((P,S)=>{let v=P[f.dataKey],o=v===null||v===void 0,N4=q.length===1?(E.plotLeft+E.plotRight)/2:E.plotLeft+S/(q.length-1)*E.plotWidth,v1=o?E.plotBottom:E.plotBottom-Number(v)/i*E.plotHeight;return{x:N4,y:v1,isNull:o}});if(C){let P=[],S=()=>{if(P.length<2){P=[];return}let v=`M ${P[0].x},${E.plotBottom} `+P.map((N4)=>`L ${N4.x},${N4.y}`).join(" ")+` L ${P[P.length-1].x},${E.plotBottom} Z`,o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("d",v),o.setAttribute("fill",m),o.setAttribute("opacity","0.15"),L.appendChild(o),P=[]};for(let v of c){if(v.isNull){S();continue}P.push(v)}S()}let s="";for(let P of c){if(P.isNull)continue;let S=c.indexOf(P),v=S===0||c[S-1].isNull;s+=`${v?"M":"L"} ${P.x},${P.y} `}if(s){let P=document.createElementNS("http://www.w3.org/2000/svg","path");if(P.setAttribute("d",s.trim()),P.setAttribute("fill","none"),P.setAttribute("stroke",m),P.setAttribute("stroke-width","2"),x)P.setAttribute("stroke-dasharray","6 3");L.appendChild(P)}let a=[];for(let P of c){let S=document.createElementNS("http://www.w3.org/2000/svg","circle");if(S.setAttribute("cx",String(P.x)),S.setAttribute("cy",String(P.y)),S.setAttribute("r","4"),S.setAttribute("fill",m),S.setAttribute("class","pf-data-dot"),S.setAttribute("data-visible","false"),S.style.pointerEvents="none",P.isNull)S.style.display="none";L.appendChild(S),a.push(S)}d.push(a)}let I=document.createElementNS("http://www.w3.org/2000/svg","line");if(I.setAttribute("class","pf-crosshair"),I.setAttribute("x1",String(E.plotLeft)),I.setAttribute("x2",String(E.plotLeft)),I.setAttribute("y1",String(E.plotTop)),I.setAttribute("y2",String(E.plotBottom)),I.setAttribute("stroke",_4),I.setAttribute("stroke-width","1"),I.setAttribute("stroke-dasharray","3 3"),I.setAttribute("opacity","0"),L.appendChild(I),G){let V=X?(f)=>J4(f,X,J):void 0;R1(L,q,G,(f)=>{return q.length===1?(E.plotLeft+E.plotRight)/2:E.plotLeft+f/(q.length-1)*E.plotWidth},E.plotBottom,V)}if(H){let V=P4(Z,L),f=k1(J,$.yAxisFormat,$.yAxisRightFormat);T1(V,L,q,U,E,N??G,f,I,d,T?(i)=>J4(i,T,J):void 0)}return u4(Z,U,$.showLegend),Z.appendChild(L),Z}function c8($,J){let Z=B("div","pf-chart pf-pie-chart"),q=y($.data,J)??[],U=$.series??[],Q=$.height??300,W=Math.min(Q,300),Y=$.showTooltip!==!1;if(q.length===0||U.length===0)return Z.textContent="No chart data",Z;let M=O4(W,W,"Pie"),H=W/2,G=W/2,N=W/2-10,X=U[0].dataKey,T=$.xAxis,D=$.tooltipXKey,z=$.tooltipXFormat,F=q.map((E)=>Number(E[X]??0)),O=F.reduce((E,L)=>E+L,0);if(O===0)return Z.textContent="No chart data",Z.appendChild(M),Z;let A=Y?P4(Z,M):void 0,R=-Math.PI/2;for(let E=0;E<F.length;E++){let L=F[E]/O*2*Math.PI,C=R+L,d=L>Math.PI?1:0,I=H+N*Math.cos(R),V=G+N*Math.sin(R),f=H+N*Math.cos(C),x=G+N*Math.sin(C),i=l[E%l.length],m=document.createElementNS("http://www.w3.org/2000/svg","path");if(m.setAttribute("d",`M ${H},${G} L ${I},${V} A ${N},${N} 0 ${d} 1 ${f},${x} Z`),m.setAttribute("fill",i),m.style.cursor="default",A){let c=D??T,s=c?q[E][c]:void 0,a=s!=null?z?J4(s,z,J):String(s):`Slice ${E+1}`,P=`${(F[E]/O*100).toFixed(1)}%`,S=R+L/2,v=H+N*0.6*Math.cos(S);m.addEventListener("mouseenter",()=>{Y4(A,v,G,a,[{label:U[0].label??X,value:`${F[E]} (${P})`,color:i}])}),m.addEventListener("mouseleave",()=>{A.tooltip.classList.remove("pf-visible")}),m.addEventListener("touchstart",()=>{Y4(A,v,G,a,[{label:U[0].label??X,value:`${F[E]} (${P})`,color:i}])},{passive:!0}),m.addEventListener("touchend",()=>{A.tooltip.classList.remove("pf-visible")},{passive:!0})}M.appendChild(m),R=C}return u4(Z,U,$.showLegend),Z.appendChild(M),Z}function v4($,J){let Z=B("div",`pf-chart pf-${$.type.toLowerCase()}`);return Z.textContent=`${$.type} — not yet supported in renderer`,Z.style.padding="24px",Z.style.textAlign="center",Z.style.color="var(--muted-foreground, #6b7280)",Z}function O4($,J,Z){let q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(q.setAttribute("width","100%"),q.setAttribute("height",String(J)),q.setAttribute("viewBox",`0 0 ${$} ${J}`),q.setAttribute("role","img"),Z)q.setAttribute("aria-label",`${Z} chart`);return q.style.overflow="visible",q}function u4($,J,Z){if(Z===!1||J.length<=1)return;let q=B("div","pf-chart-legend");q.style.display="flex",q.style.gap="12px",q.style.fontSize="12px",q.style.marginBottom="8px";for(let U=0;U<J.length;U++){let Q=B("div","pf-chart-legend-item");Q.style.display="flex",Q.style.alignItems="center",Q.style.gap="4px";let W=B("span");W.style.width="8px",W.style.height="8px",W.style.borderRadius="50%",W.style.backgroundColor=J[U].color??l[U%l.length];let Y=B("span");Y.textContent=J[U].label??J[U].dataKey,Q.appendChild(W),Q.appendChild(Y),q.appendChild(Q)}$.appendChild(q)}function s8($,J){let Z=B("div","pf-chart pf-histogram"),q=y($.data,J);if(!q||q.length===0)return Z.textContent="No data",Z;let U=q,Q=$.bins??10,W=$.height??200,Y=$.color??l[0],M=Math.min(...U),G=(Math.max(...U)-M)/Q||1,N=Array(Q).fill(0);for(let O of U){let A=Math.min(Math.floor((O-M)/G),Q-1);N[A]++}let X=Math.max(...N),T=300,D=W,z=T/Q,F=O4(T,D,"Histogram");for(let O=0;O<Q;O++){let A=X>0?N[O]/X*D:0,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(O*z)),R.setAttribute("y",String(D-A)),R.setAttribute("width",String(z-1)),R.setAttribute("height",String(A)),R.setAttribute("fill",Y),F.appendChild(R)}return Z.appendChild(F),Z}function f1(){_("Table",l8),_("TableHead",x4("thead")),_("TableBody",x4("tbody")),_("TableFooter",x4("tfoot")),_("TableRow",d8),_("TableHeader",i8),_("TableCell",r8),_("TableCaption",n8),_("ExpandableRow",a8)}function l8($,J){let Z=document.createElement("table");return Z.className="pf-table",Z.style.width="100%",Z.style.borderCollapse="collapse",j($,Z,J),Z}function x4($){return(J,Z)=>{let q=document.createElement($);return q.className=`pf-${$}`,j(J,q,Z),q}}function d8($,J){let Z=document.createElement("tr");return Z.className="pf-table-row",j($,Z,J),Z}function i8($,J){let Z=document.createElement("th");return Z.className="pf-table-header",Z.style.textAlign="left",Z.style.padding="8px 12px",Z.style.borderBottom="2px solid var(--border, #e5e7eb)",Z.style.fontWeight="600",Z.textContent=K($.content,J),Z}function r8($,J){let Z=document.createElement("td");if(Z.className="pf-table-cell",Z.style.padding="8px 12px",Z.style.borderBottom="1px solid var(--border, #e5e7eb)",$.colSpan!=null)Z.colSpan=$.colSpan;if($.rowSpan!=null)Z.rowSpan=$.rowSpan;return j($,Z,J),Z}function n8($,J){let Z=document.createElement("caption");return Z.className="pf-table-caption",Z.style.padding="8px",Z.style.color="var(--muted-foreground, #6b7280)",Z.style.fontSize="14px",Z.textContent=K($.content,J),Z}function a8($,J){let Z=B("div","pf-expandable-row"),q=B("div","pf-expandable-row-summary");q.style.cursor="pointer",q.style.display="flex",q.style.alignItems="center",q.style.gap="8px";let U=B("span","pf-expandable-arrow");U.textContent="▶",U.style.transition="transform 0.2s",U.style.fontSize="10px",q.appendChild(U);let Q=$.summary;if(Q)for(let M of Q)q.appendChild(w(M,J));let W=B("div","pf-expandable-row-detail");W.style.display="none",W.style.paddingLeft="24px",j($,W,J);let Y=!1;return q.addEventListener("click",()=>{Y=!Y,W.style.display=Y?"block":"none",U.style.transform=Y?"rotate(90deg)":""}),Z.appendChild(q),Z.appendChild(W),Z}var S1=!1;function V4(){if(S1)return;S1=!0,J1(),Q1(),_1(),M1(),B1(),H1(),G1(),z1(),D1(),L1(),f1()}function w1($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function C1($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function b1($,J){if(!J)return;if(J.light)for(let[Z,q]of Object.entries(J.light))$.style.setProperty(`--${w1(Z)}`,C1(q));if(J.dark){let q=document.getElementById("prefab-dark-theme");if(!q)q=document.createElement("style"),q.id="prefab-dark-theme",document.head.appendChild(q);let U=Object.entries(J.dark).map(([Q,W])=>` --${w1(Q)}: ${C1(W)};`).join(`
|
|
3
|
+
`),Z=[],q=0;while(q<J.length){let U=J[q];if(U.trimStart().startsWith("```")){let Y=U.trimStart().slice(3).trim(),M=[];q++;while(q<J.length&&!J[q].trimStart().startsWith("```"))M.push(F0(J[q])),q++;q++;let B=Y?` data-language="${F0(Y)}"`:"";Z.push(`<pre class="pf-code"><code${B}>${M.join(`
|
|
4
|
+
`)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(U)){Z.push("<hr />"),q++;continue}let Q=/^(#{1,6})\s+(.+)$/.exec(U);if(Q){let Y=Q[1].length;Z.push(`<h${Y}>${E0(Q[2])}</h${Y}>`),q++;continue}if(U.startsWith("> ")||U===">"){let Y=[];while(q<J.length&&(J[q].startsWith("> ")||J[q]===">"))Y.push(J[q].replace(/^>\s?/,"")),q++;Z.push(`<blockquote>${W1(Y.join(`
|
|
5
|
+
`))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(U)){Z.push("<ul>");while(q<J.length&&/^[\s]*[-*+]\s+/.test(J[q]))Z.push(`<li>${E0(J[q].replace(/^[\s]*[-*+]\s+/,""))}</li>`),q++;Z.push("</ul>");continue}if(/^[\s]*\d+\.\s+/.test(U)){Z.push("<ol>");while(q<J.length&&/^[\s]*\d+\.\s+/.test(J[q]))Z.push(`<li>${E0(J[q].replace(/^[\s]*\d+\.\s+/,""))}</li>`),q++;Z.push("</ol>");continue}if(U.trim()===""){q++;continue}let W=[];while(q<J.length&&J[q].trim()!==""&&!/^#{1,6}\s/.test(J[q])&&!/^[-*+]\s/.test(J[q])&&!/^\d+\.\s/.test(J[q])&&!J[q].startsWith("> ")&&!J[q].trimStart().startsWith("```")&&!/^(\s*[-*_]\s*){3,}$/.test(J[q]))W.push(J[q]),q++;Z.push(`<p>${W.map(E0).join("<br />")}</p>`)}return Z.join(`
|
|
6
|
+
`)}function v4($,J){let Z=document.createElement("kbd");return Z.className="pf-kbd",Z.textContent=X($.content,J),Z}function _1(){_("Card",h4),_("CardHeader",b0("pf-card-header")),_("CardTitle",Y1("pf-card-title","h3")),_("CardDescription",Y1("pf-card-description","p")),_("CardContent",b0("pf-card-content")),_("CardFooter",b0("pf-card-footer"))}function h4($,J){let Z=H("div","pf-card");return Z.style.overflow="hidden",j($,Z,J),Z}function b0($){return(J,Z)=>{let q=H("div",$);return q.style.padding="16px 24px",j(J,q,Z),q}}function Y1($,J){return(Z,q)=>{let U=document.createElement(J);return U.className=$,U.textContent=X(Z.content,q),U}}function M1(){_("DataTable",g4),_("Badge",u4),_("Dot",x4),_("Metric",p4),_("Ring",c4),_("Progress",s4),_("Separator",l4),_("Loader",i4),_("Icon",d4),_("Sparkline",r4)}function g4($,J){let Z=H("div","pf-datatable-wrapper"),q=document.createElement("table");q.className="pf-datatable",q.style.width="100%",q.style.borderCollapse="collapse";let U=$.columns??[],Q=b($.rows,J),W=$.rowKey,Y=$.selected,M=document.createElement("thead"),B=document.createElement("tr");for(let N of U){let z=document.createElement("th");z.className="pf-datatable-th",z.textContent=N.header??N.key,z.style.padding="8px 12px",z.style.textAlign="left",B.appendChild(z)}M.appendChild(B),q.appendChild(M);let G=document.createElement("tbody");if(Array.isArray(Q)){let N=Y!=null?b(Y,J):void 0;for(let z of Q){let T=document.createElement("tr");T.className="pf-datatable-row";let D=z;if(W&&N!=null&&D[W]!=null&&String(D[W])===String(N))T.classList.add("pf-datatable-row-selected");if($.onRowClick!=null&&W)T.style.cursor="pointer",T.addEventListener("click",()=>{let K={...J.scope,$item:D,$index:Q.indexOf(z)},F=y({...J,scope:K});k($.onRowClick,F)});for(let K of U){let F=document.createElement("td");F.className="pf-datatable-td";let O;if(K.accessor)O=b(`{{ $item.${K.accessor} }}`,{...J,scope:{...J.scope,$item:D}});else if(O=D[K.key],K.format&&O!=null)O=b(`{{ __fmtVal | ${K.format} }}`,{...J,scope:{...J.scope,__fmtVal:O}});F.textContent=O==null?"":String(O),F.style.padding="8px 12px",T.appendChild(F)}G.appendChild(T)}}if(q.appendChild(G),$.search===!0){let N=document.createElement("input");N.type="text",N.placeholder="Search...",N.className="pf-datatable-search",N.style.marginBottom="8px",N.style.padding="6px 12px",N.style.width="100%",N.style.boxSizing="border-box",N.addEventListener("input",()=>{let z=N.value.toLowerCase(),T=Array.from(G.querySelectorAll("tr"));for(let D of T){let K=D.textContent.toLowerCase();D.style.display=K.includes(z)?"":"none"}}),Z.appendChild(N)}return Z.appendChild(q),Z}function u4($,J){let Z=H("span","pf-badge"),q=$.variant??"default";return Z.setAttribute("data-variant",q),Z.style.alignItems="center",Z.style.padding="2px 10px",Z.style.borderRadius="9999px",Z.style.fontSize="12px",Z.style.fontWeight="500",Z.textContent=X($.label??$.content,J),n4(Z,q),Z}function x4($,J){let Z=H("span","pf-dot"),q=$.color??"gray";return Z.style.display="inline-block",Z.style.width="8px",Z.style.height="8px",Z.style.borderRadius="50%",Z.style.backgroundColor=q,Z}function p4($,J){let Z=H("div","pf-metric"),q=H("div","pf-metric-label");q.textContent=X($.label,J),q.style.fontSize="14px",Z.appendChild(q);let U=H("div","pf-metric-value");if(U.textContent=X($.value,J),U.style.fontSize="28px",U.style.fontWeight="700",Z.appendChild(U),$.delta!=null){let Q=H("span","pf-metric-delta");Q.textContent=X($.delta,J);let W=$.trend??"",Y=$.trendSentiment??"neutral";if(Q.style.fontSize="14px",Q.style.color=Y==="positive"?"green":Y==="negative"?"red":"inherit",W==="up")Q.textContent="↑ "+Q.textContent;else if(W==="down")Q.textContent="↓ "+Q.textContent;Z.appendChild(Q)}if($.description!=null){let Q=H("div","pf-metric-desc");Q.textContent=X($.description,J),Q.style.fontSize="12px",Z.appendChild(Q)}return Z}function c4($,J){let Z=H("div","pf-ring"),q=$.size??80,U=$.thickness??8,Q=Number(b($.value,J)??0),W=Math.max(0,Math.min(100,Q)),Y=(q-U)/2,M=2*Math.PI*Y,B=M*(1-W/100),G=document.createElementNS("http://www.w3.org/2000/svg","svg");G.setAttribute("width",String(q)),G.setAttribute("height",String(q)),G.setAttribute("viewBox",`0 0 ${q} ${q}`);let N=document.createElementNS("http://www.w3.org/2000/svg","circle");N.setAttribute("cx",String(q/2)),N.setAttribute("cy",String(q/2)),N.setAttribute("r",String(Y)),N.setAttribute("fill","none"),N.setAttribute("stroke-width",String(U));let z=document.createElementNS("http://www.w3.org/2000/svg","circle");if(z.setAttribute("cx",String(q/2)),z.setAttribute("cy",String(q/2)),z.setAttribute("r",String(Y)),z.setAttribute("fill","none"),z.setAttribute("stroke-width",String(U)),z.setAttribute("stroke-dasharray",String(M)),z.setAttribute("stroke-dashoffset",String(B)),z.setAttribute("stroke-linecap","round"),z.style.transform="rotate(-90deg)",z.style.transformOrigin="center",G.appendChild(N),G.appendChild(z),Z.appendChild(G),$.label!=null){let T=H("div","pf-ring-label");T.textContent=X($.label,J),T.style.textAlign="center",T.style.fontSize="12px",Z.appendChild(T)}return Z}function s4($,J){let Z=H("div","pf-progress");Z.setAttribute("role","progressbar");let q=Number(b($.value,J)??0),U=$.max??100,Q=U>0?Math.max(0,Math.min(100,q/U*100)):0;Z.setAttribute("aria-valuenow",String(q)),Z.setAttribute("aria-valuemin","0"),Z.setAttribute("aria-valuemax",String(U)),Z.style.height="8px",Z.style.borderRadius="4px",Z.style.overflow="hidden";let W=H("div","pf-progress-fill");return W.style.height="100%",W.style.width=`${Q}%`,W.style.borderRadius="4px",W.style.transition="width 0.3s ease",Z.appendChild(W),Z}function l4($,J){let Z=document.createElement("hr");return Z.className="pf-separator",Z.style.border="none",Z.style.margin="8px 0",Z}function i4($,J){let Z=H("div","pf-loader");return Z.textContent="⏳",Z.style.display="flex",Z.style.justifyContent="center",Z.style.padding="16px",Z}function d4($,J){let Z=H("span","pf-icon");return Z.setAttribute("data-icon",X($.name??$.content,J)),Z}function r4($,J){let Z=H("div","pf-sparkline"),q=$.data??[];if(q.length===0)return Z;let U=120,Q=32,W=Math.max(...q),Y=Math.min(...q),M=W-Y||1,B=document.createElementNS("http://www.w3.org/2000/svg","svg");B.setAttribute("width",String(U)),B.setAttribute("height",String(Q)),B.setAttribute("viewBox",`0 0 ${U} ${Q}`);let G=q.length>1?q.length-1:1,N=q.map((T,D)=>{let K=D/G*U,F=Q-(T-Y)/M*(Q-4)-2;return`${K},${F}`}).join(" "),z=document.createElementNS("http://www.w3.org/2000/svg","polyline");return z.setAttribute("points",N),z.setAttribute("fill","none"),z.setAttribute("stroke-width","1.5"),B.appendChild(z),Z.appendChild(B),Z}function n4($,J){let q={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[J];if(q)$.style.backgroundColor=q.bg,$.style.color=q.fg}function H1(){_("Form",a4),_("Input",o4),_("Textarea",t4),_("Button",e4),_("ButtonGroup",$8),_("Select",J8),_("SelectOption",Z8),_("SelectGroup",T0("pf-select-group")),_("SelectLabel",W0("pf-select-label")),_("SelectSeparator",N1),_("Checkbox",q8),_("Switch",U8),_("Slider",Q8),_("Radio",Y8),_("RadioGroup",_8),_("Combobox",M8),_("ComboboxOption",N8),_("ComboboxGroup",T0("pf-combobox-group")),_("ComboboxLabel",W0("pf-combobox-label")),_("ComboboxSeparator",N1),_("Calendar",H8),_("DatePicker",B8),_("Field",T0("pf-field")),_("FieldTitle",W0("pf-field-title")),_("FieldDescription",W0("pf-field-description")),_("FieldContent",T0("pf-field-content")),_("FieldError",W0("pf-field-error")),_("ChoiceCard",G8)}function a4($,J){let Z=document.createElement("form");return Z.className="pf-form",Z.addEventListener("submit",(q)=>{q.preventDefault();let U=new FormData(Z),Q={};if(U.forEach((W,Y)=>{Q[Y]=W}),J.store.merge(Q),$.onSubmit!=null){let W=y(J);W.scope={...J.scope,...Q},k($.onSubmit,W)}}),j($,Z,J),Z}function o4($,J){let Z=H("div","pf-input-wrapper");if(Z.style.display="flex",Z.style.flexDirection="column",Z.style.gap="4px",$.label!=null){let Q=document.createElement("label");if(Q.className="pf-input-label",Q.textContent=X($.label,J),$.name!=null)Q.htmlFor=$.name;Q.style.fontSize="14px",Q.style.fontWeight="500",Z.appendChild(Q)}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=X($.placeholder,J);if($.required===!0)q.required=!0,q.setAttribute("aria-required","true");if($.error!=null)q.setAttribute("aria-invalid","true");let U=$.name;if(U){let Q=J.store.get(U);if(Q!=null)q.value=String(Q);q.addEventListener("input",()=>{if(J.store.set(U,q.value),$.onChange!=null)k($.onChange,{...y(J),scope:{...J.scope,$event:q.value}})})}return m0(q),Z.appendChild(q),Z}function t4($,J){let Z=H("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=X($.placeholder,J);if($.rows!=null)q.rows=$.rows;if($.required===!0)q.setAttribute("aria-required","true");let U=$.name;if(U!=null){let Q=J.store.get(U);if(Q!=null)q.value=String(Q);q.addEventListener("input",()=>{if(J.store.set(U,q.value),$.onChange!=null)k($.onChange,{...y(J),scope:{...J.scope,$event:q.value}})})}return m0(q),Z.appendChild(q),Z}function e4($,J){let Z=document.createElement("button");Z.className="pf-button",Z.type=$.submit===!0?"submit":"button",Z.textContent=X($.label,J);let q=$.variant??"default";if(Z.setAttribute("data-variant",q),W8(Z,q),$.size!=null)Z.setAttribute("data-size",$.size);if($.disabled===!0)Z.disabled=!0;if($.onClick!=null)Z.addEventListener("click",()=>{k($.onClick,y(J))});return Z}function $8($,J){let Z=H("div","pf-button-group");return Z.style.display="flex",Z.style.gap="8px",j($,Z,J),Z}function J8($,J){let Z=H("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(m0(q),$.placeholder!=null){let W=document.createElement("option");W.value="",W.textContent=X($.placeholder,J),W.disabled=!0,W.selected=!0,W.hidden=!0,q.appendChild(W)}let U=$.options;if(Array.isArray(U))for(let W of U){let Y=document.createElement("option");Y.value=W.value??"",Y.textContent=W.label??Y.value,q.appendChild(Y)}if($.children)for(let W of $.children)if(W.type==="SelectOption"){let Y=document.createElement("option");Y.value=W.value??"",Y.textContent=W.label??Y.value,q.appendChild(Y)}else q.appendChild(w(W,J));let Q=$.name;if(Q){let W=J.store.get(Q);if(W!=null)q.value=String(W);q.addEventListener("change",()=>{if(J.store.set(Q,q.value),$.onChange!=null)k($.onChange,{...y(J),scope:{...J.scope,$event:q.value}})})}return Z.appendChild(q),Z}function Z8($,J){return H("span")}function q8($,J){let Z=H("label","pf-checkbox-wrapper");Z.style.display="flex",Z.style.alignItems="center",Z.style.gap="8px",Z.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 U=$.name;if(U){let Q=J.store.get(U);if(typeof Q==="boolean")q.checked=Q;q.addEventListener("change",()=>{if(J.store.set(U,q.checked),$.onChange!=null)k($.onChange,{...y(J),scope:{...J.scope,$event:q.checked}})})}if(Z.appendChild(q),$.label!=null){let Q=H("span");Q.textContent=X($.label,J),Z.appendChild(Q)}return Z}function U8($,J){let Z=H("label","pf-switch-wrapper");Z.style.display="flex",Z.style.alignItems="center",Z.style.gap="8px",Z.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 U=$.name;if(U){let Q=J.store.get(U);if(typeof Q==="boolean")q.checked=Q;q.addEventListener("change",()=>{if(J.store.set(U,q.checked),$.onChange!=null)k($.onChange,{...y(J),scope:{...J.scope,$event:q.checked}})})}if(Z.appendChild(q),$.label!=null){let Q=H("span");Q.textContent=X($.label,J),Z.appendChild(Q)}return Z}function Q8($,J){let Z=H("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=String($.min);if($.max!=null)q.max=String($.max);if($.step!=null)q.step=String($.step);let U=$.name;if(U){let Q=J.store.get(U);if(Q!=null)q.value=String(Q);q.addEventListener("input",()=>{if(J.store.set(U,Number(q.value)),$.onChange!=null)k($.onChange,{...y(J),scope:{...J.scope,$event:Number(q.value)}})})}return Z.appendChild(q),Z}function m0($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function W8($,J){if($.style.padding="8px 16px",$.style.fontSize="14px",$.style.fontWeight="500",$.style.cursor="pointer",$.style.border="none",J==="ghost")$.style.backgroundColor="transparent",$.style.color="inherit"}function T0($){return(J,Z)=>{let q=H("div",$);return j(J,q,Z),q}}function W0($){return(J,Z)=>{let q=H("span",$);return q.textContent=X(J.content,Z),q}}function N1(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function Y8($,J){let Z=H("label","pf-radio");Z.style.display="flex",Z.style.alignItems="center",Z.style.gap="8px",Z.style.cursor="pointer";let q=document.createElement("input");if(q.type="radio",q.value=X($.value,J),Z.appendChild(q),$.label!=null){let U=H("span","pf-radio-label");U.textContent=X($.label,J),Z.appendChild(U)}return Z}function _8($,J){let Z=H("fieldset","pf-radio-group");if(Z.style.border="none",Z.style.padding="0",Z.style.display="flex",Z.style.flexDirection="column",Z.style.gap="8px",$.label!=null){let Q=document.createElement("legend");Q.textContent=X($.label,J),Q.style.fontWeight="500",Q.style.marginBottom="4px",Z.appendChild(Q)}j($,Z,J);let q=X($.name,J),U=J.store.get(q);for(let Q of Array.from(Z.querySelectorAll('input[type="radio"]')))if(Q.name=q,U!=null&&Q.value===String(U))Q.checked=!0;return Z.addEventListener("change",(Q)=>{let W=Q.target;if(W.type==="radio"){if(J.store.set(q,W.value),$.onChange!=null)k($.onChange,y(J))}}),Z}function M8($,J){let Z=H("div","pf-combobox"),q=document.createElement("input");if(q.className="pf-combobox-input",q.type="text",q.name=X($.name,J),$.placeholder!=null)q.placeholder=X($.placeholder,J);if($.value!==void 0)q.value=X($.value,J);let U=q.name,Q=J.store.get(U);if(Q!=null)q.value=String(Q);q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box";let W=H("div","pf-combobox-dropdown");if(W.style.display="none",W.style.position="absolute",W.style.borderRadius="6px",W.style.maxHeight="200px",W.style.overflowY="auto",W.style.zIndex="50",j($,W,J),q.addEventListener("focus",()=>{W.style.display="block"}),q.addEventListener("blur",()=>{setTimeout(()=>{W.style.display="none"},150)}),$.searchable!==!1)q.addEventListener("input",()=>{let Y=q.value.toLowerCase();for(let M of Array.from(W.querySelectorAll(".pf-combobox-option"))){let B=M.textContent.toLowerCase();M.style.display=B.includes(Y)?"":"none"}});if($.onChange!=null)Z.addEventListener("pf-combobox-select",()=>{k($.onChange,{...y(J),scope:{...J.scope,$event:q.value}})});return Z.style.position="relative",Z.appendChild(q),Z.appendChild(W),Z}function N8($,J){let Z=H("div","pf-combobox-option");return Z.style.padding="6px 12px",Z.style.cursor="pointer",Z.textContent=X($.label??$.value,J),Z.dataset.value=X($.value,J),Z.addEventListener("mousedown",()=>{let q=Z.closest(".pf-combobox"),U=q?.querySelector("input");if(U)U.value=Z.dataset.value??"",J.store.set(U.name,U.value),q?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),Z}function H8($,J){let Z=H("div","pf-calendar"),q=document.createElement("input");if(q.type="date",q.name=X($.name,J),$.value!==void 0)q.value=X($.value,J);let U=q.name,Q=J.store.get(U);if(Q!=null)q.value=String(Q);if($.minDate!=null)q.min=X($.minDate,J);if($.maxDate!=null)q.max=X($.maxDate,J);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.addEventListener("change",()=>{if(J.store.set(q.name,q.value),$.onChange!=null)k($.onChange,y(J))}),Z.appendChild(q),Z}function B8($,J){let Z=H("div","pf-datepicker"),q=document.createElement("input");if(q.type="date",q.name=X($.name,J),$.placeholder!=null)q.placeholder=X($.placeholder,J);if($.value!==void 0)q.value=X($.value,J);let U=q.name,Q=J.store.get(U);if(Q!=null)q.value=String(Q);if($.minDate!=null)q.min=X($.minDate,J);if($.maxDate!=null)q.max=X($.maxDate,J);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box",q.addEventListener("change",()=>{if(J.store.set(q.name,q.value),$.onChange!=null)k($.onChange,y(J))}),Z.appendChild(q),Z}function G8($,J){let Z=H("div","pf-choice-card");if(Z.style.padding="16px",Z.style.cursor="pointer",Z.style.transition="border-color 0.2s",Z.dataset.value=X($.value,J),$.selected===!0)Z.dataset.selected="true";if($.label!=null){let q=H("div","pf-choice-card-label");q.textContent=X($.label,J),q.style.fontWeight="600",Z.appendChild(q)}if($.description!=null){let q=H("div","pf-choice-card-description");q.textContent=X($.description,J),q.style.fontSize="14px",Z.appendChild(q)}if(j($,Z,J),$.onClick!=null)Z.addEventListener("click",()=>{k($.onClick,y(J))});return Z}function B1(){_("Tabs",X8),_("Tab",K8),_("Accordion",z8),_("AccordionItem",D8),_("Dialog",E8),_("Popover",F8),_("Tooltip",T8),_("HoverCard",j8),_("Carousel",L8)}function X8($,J){let Z=H("div","pf-tabs"),q=H("div","pf-tabs-bar");q.setAttribute("role","tablist"),q.style.display="flex",q.style.gap="4px",q.style.marginBottom="12px";let U=[],Q=[];if($.children)for(let Y=0;Y<$.children.length;Y++){let M=$.children[Y],B=`pf-tab-${Math.random().toString(36).slice(2,8)}`,G=`pf-panel-${Math.random().toString(36).slice(2,8)}`,N=document.createElement("button");N.type="button",N.className="pf-tab-trigger",N.textContent=M.title??`Tab ${Y+1}`,N.setAttribute("role","tab"),N.setAttribute("aria-selected",Y===0?"true":"false"),N.setAttribute("aria-controls",G),N.id=B,N.tabIndex=Y===0?0:-1,N.style.padding="8px 16px",N.style.border="none",N.style.background="none",N.style.cursor="pointer",N.style.borderBottom="2px solid transparent",N.style.marginBottom="-2px",N.style.fontSize="14px";let z=H("div","pf-tab-panel");if(z.style.display=Y===0?"block":"none",z.setAttribute("role","tabpanel"),z.setAttribute("aria-labelledby",B),z.id=G,z.tabIndex=0,j(M,z,J),N.addEventListener("click",()=>{W(Y)}),Y===0)N.classList.add("pf-tab-active"),N.style.fontWeight="600";Q.push(N),U.push(z),q.appendChild(N)}function W(Y){U.forEach((M)=>M.style.display="none"),Q.forEach((M)=>{M.style.borderBottomColor="transparent",M.style.fontWeight="normal",M.classList.remove("pf-tab-active"),M.setAttribute("aria-selected","false"),M.tabIndex=-1}),U[Y].style.display="block",Q[Y].classList.add("pf-tab-active"),Q[Y].style.fontWeight="600",Q[Y].setAttribute("aria-selected","true"),Q[Y].tabIndex=0,Q[Y].focus()}q.addEventListener("keydown",(Y)=>{let M=Q.indexOf(Y.target);if(M<0)return;let B;if(Y.key==="ArrowRight")B=(M+1)%Q.length;else if(Y.key==="ArrowLeft")B=(M-1+Q.length)%Q.length;else if(Y.key==="Home")B=0;else if(Y.key==="End")B=Q.length-1;else return;Y.preventDefault(),W(B)}),Z.appendChild(q);for(let Y of U)Z.appendChild(Y);return Z}function K8($,J){let Z=H("div","pf-tab");return j($,Z,J),Z}function z8($,J){let Z=H("div","pf-accordion");return j($,Z,J),Z}function D8($,J){let Z=H("div","pf-accordion-item"),q=`pf-acc-${Math.random().toString(36).slice(2,8)}`,U=document.createElement("button");U.type="button",U.className="pf-accordion-trigger",U.textContent=$.title??"",U.setAttribute("aria-expanded","false"),U.setAttribute("aria-controls",q),U.style.width="100%",U.style.textAlign="left",U.style.padding="12px 0",U.style.border="none",U.style.background="none",U.style.cursor="pointer",U.style.fontSize="14px",U.style.fontWeight="500";let Q=H("div","pf-accordion-content");return Q.id=q,Q.setAttribute("role","region"),Q.setAttribute("aria-labelledby",U.id),Q.style.display="none",Q.style.paddingBottom="12px",j($,Q,J),U.addEventListener("click",()=>{let W=Q.style.display!=="none";Q.style.display=W?"none":"block",U.setAttribute("aria-expanded",W?"false":"true")}),Z.appendChild(U),Z.appendChild(Q),Z}function E8($,J){let Z=H("div","pf-dialog-wrapper");if($.trigger!=null){let Q=w($.trigger,J);Q.addEventListener("click",()=>{q.showModal()}),Z.appendChild(Q)}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 Q=H("h2","pf-dialog-title");Q.textContent=X($.title,J),Q.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,q.setAttribute("aria-labelledby",Q.id),q.appendChild(Q)}if($.description!=null){let Q=H("p","pf-dialog-desc");Q.textContent=X($.description,J),q.appendChild(Q)}let U=H("div","pf-dialog-body");if(j($,U,J),q.appendChild(U),$.dismissible!==!1)q.addEventListener("click",(Q)=>{if(Q.target===q)q.close()});return document.addEventListener("prefab:close-overlay",()=>q.close()),Z.appendChild(q),Z}function F8($,J){let Z=H("div","pf-popover");Z.style.position="relative",Z.style.display="inline-block";let q=H("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 U=H("div","pf-popover-title");U.textContent=X($.title,J),U.style.fontWeight="600",U.style.marginBottom="4px",q.appendChild(U)}return j($,q,J),Z.addEventListener("click",(U)=>{if(q.contains(U.target)&&q.style.display!=="none")return;q.style.display=q.style.display==="none"?"block":"none"}),Z.appendChild(q),Z}function T8($,J){let Z=H("div","pf-tooltip");Z.style.position="relative",Z.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,U=H("div","pf-tooltip-content");return U.id=q,U.setAttribute("role","tooltip"),U.textContent=X($.content??"",J),U.style.display="none",U.style.position="absolute",U.style.bottom="100%",U.style.left="50%",U.style.transform="translateX(-50%)",U.style.padding="4px 8px",U.style.borderRadius="4px",U.style.color="#fff",U.style.fontSize="12px",U.style.whiteSpace="nowrap",U.style.zIndex="50",j($,Z,J),Z.setAttribute("aria-describedby",q),Z.addEventListener("mouseenter",()=>{U.style.display="block"}),Z.addEventListener("mouseleave",()=>{U.style.display="none"}),Z.addEventListener("focus",()=>{U.style.display="block"},!0),Z.addEventListener("blur",()=>{U.style.display="none"},!0),Z.appendChild(U),Z}function j8($,J){let Z=H("div","pf-hover-card");Z.style.position="relative",Z.style.display="inline-block";let q=H("div","pf-hover-card-content");return 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",j($,q,J),Z.addEventListener("mouseenter",()=>{q.style.display="block"}),Z.addEventListener("mouseleave",()=>{q.style.display="none"}),Z.appendChild(q),Z}function L8($,J){let Z=H("div","pf-carousel");Z.style.position="relative",Z.style.overflow="hidden",Z.setAttribute("role","region"),Z.setAttribute("aria-roledescription","carousel"),Z.setAttribute("aria-label",X($.label??"Carousel",J));let q=H("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",j($,q,J);let U=0,Q=$.children?.length??0,W=document.createElement("button");W.type="button",W.textContent="‹",W.className="pf-carousel-prev",W.setAttribute("aria-label","Previous slide"),W.style.position="absolute",W.style.left="4px",W.style.top="50%",W.style.transform="translateY(-50%)",W.style.zIndex="10";let Y=document.createElement("button");Y.type="button",Y.textContent="›",Y.className="pf-carousel-next",Y.setAttribute("aria-label","Next slide"),Y.style.position="absolute",Y.style.right="4px",Y.style.top="50%",Y.style.transform="translateY(-50%)",Y.style.zIndex="10";let M=()=>{q.style.transform=`translateX(-${U*100}%)`};return W.addEventListener("click",()=>{if(Q===0)return;U=Math.max(0,U-1),M()}),Y.addEventListener("click",()=>{if(Q===0)return;U=Math.min(Q-1,U+1),M()}),Z.appendChild(q),Z.appendChild(W),Z.appendChild(Y),Z}function G1(){_("ForEach",P8),_("If",X1),_("Elif",O8),_("Else",V8),_("Condition",I8),_("Define",R8),_("Use",A8),_("Slot",k8)}function P8($,J){let Z=document.createDocumentFragment(),q=$.expression;if(!q)return Z;let U;if(g(q)){let W=u(q,J.store,J.scope);U=Array.isArray(W)?W:[]}else{let W=J.store.get(q);U=Array.isArray(W)?W:[]}let Q=$.let??{};for(let W=0;W<U.length;W++){let Y=U[W],M={...J.scope,$item:Y,$index:W,...Q},B={...J,scope:M};if($.children)n($.children,Z,B)}return Z}function X1($,J){if(K1($.condition,J)){let q=document.createDocumentFragment();if($.children)n($.children,q,J);return q}return document.createDocumentFragment()}function O8($,J){return X1($,J)}function V8($,J){let Z=document.createDocumentFragment();if($.children)n($.children,Z,J);return Z}function K1($,J){if(!$)return!1;if(g($))return Boolean(u($,J.store,J.scope));return Boolean(J.store.get($))}function I8($,J){let Z=document.createDocumentFragment(),q=$.cases,U=$.else;if(q){for(let Q of q)if(K1(Q.when,J)){if(Q.children)n(Q.children,Z,J);return Z}}if(U)n(U,Z,J);return Z}function R8($,J){let Z=$.name;if(Z&&$.children)J.templates=J.templates??{},J.templates[Z]=$.children;return document.createDocumentFragment()}function A8($,J){let Z=document.createDocumentFragment(),q=$.def??$.name,U=J.templates?.[q];if(!U)return Z;let Q=$.overrides??{},W={...J.scope,...Q},Y={...J,scope:W};for(let M of U)Z.appendChild(w(M,Y));return Z}function k8($,J){let Z=document.createDocumentFragment(),q=$.name??"default",Q=J.slots?.[q]??$.children;if(Q)for(let W of Q)Z.appendChild(w(W,J));return Z}function z1(){_("Alert",f8),_("AlertTitle",S8),_("AlertDescription",w8)}function f8($,J){let Z=H("div","pf-alert");Z.setAttribute("role","alert");let q=$.variant??"default";if(Z.setAttribute("data-variant",q),Z.style.padding="12px 16px",$.icon!=null){let U=H("span","pf-alert-icon");U.setAttribute("data-icon",$.icon),U.style.marginRight="8px",Z.appendChild(U)}return j($,Z,J),Z}function S8($,J){let Z=H("h5","pf-alert-title");return Z.textContent=X($.content,J),Z.style.fontWeight="600",Z.style.marginBottom="4px",Z}function w8($,J){let Z=H("p","pf-alert-description");return Z.textContent=X($.content,J),Z.style.fontSize="14px",Z}function D1(){_("Image",C8),_("Audio",y8),_("Video",b8),_("Embed",m8),_("Svg",h8),_("DropZone",g8),_("Mermaid",u8)}function C8($,J){let Z=document.createElement("img");if(Z.className="pf-image",Z.src=X($.src,J),$.alt!=null)Z.alt=X($.alt,J);if($.width!=null)Z.width=$.width;if($.height!=null)Z.height=$.height;return Z.style.maxWidth="100%",Z}function y8($,J){let Z=document.createElement("audio");return Z.className="pf-audio",Z.src=X($.src,J),Z.controls=!0,Z}function b8($,J){let Z=document.createElement("video");if(Z.className="pf-video",Z.src=X($.src,J),Z.controls=!0,$.width!=null)Z.width=$.width;if($.height!=null)Z.height=$.height;return Z.style.maxWidth="100%",Z}function m8($,J){let Z=H("div","pf-embed"),q=document.createElement("iframe");return q.src=X($.src,J),q.style.width="100%",q.style.height=$.height!=null?`${$.height}px`:"400px",q.style.border="none",q.setAttribute("sandbox","allow-scripts"),Z.appendChild(q),Z}var v8=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 h8($,J){let Z=H("div","pf-svg"),q=X($.content,J);if(!q.includes("<svg"))return Z;let Q=new DOMParser().parseFromString(q,"image/svg+xml").querySelector("svg");if(!Q)return Z;return E1(Q),Z.appendChild(document.importNode(Q,!0)),Z}function E1($){let J=Array.from($.children);for(let Z of J){if(!v8.has(Z.tagName.toLowerCase())){Z.remove();continue}for(let q of Array.from(Z.attributes)){let U=q.name.toLowerCase();if(U.startsWith("on")||U==="href"&&q.value.trim().toLowerCase().startsWith("javascript:"))Z.removeAttribute(q.name)}E1(Z)}}function g8($,J){let Z=H("div","pf-dropzone");return Z.style.padding="32px",Z.style.textAlign="center",Z.style.cursor="pointer",Z.textContent=X($.label??"Drop files here",J),Z.addEventListener("dragover",(q)=>{q.preventDefault(),Z.classList.add("pf-dropzone-active")}),Z.addEventListener("dragleave",()=>{Z.classList.remove("pf-dropzone-active")}),Z.addEventListener("drop",(q)=>{q.preventDefault(),Z.classList.remove("pf-dropzone-active")}),Z}function u8($,J){let Z=H("div","pf-mermaid");Z.setAttribute("data-mermaid","true");let q=X($.content,J);if(Z.textContent=q,typeof globalThis.mermaid<"u")Z.classList.add("mermaid"),Z.textContent=q;return Z}var L0=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function P0($,J){let Z=document.createElement("div");return Z.className="pf-chart-tooltip",$.appendChild(Z),$.addEventListener("mouseleave",()=>{Z.classList.remove("pf-visible")}),{wrapper:$,tooltip:Z,svgEl:J}}function Y0($,J,Z,q,U){let{tooltip:Q,svgEl:W,wrapper:Y}=$;if(U.length===0)return;let M="";if(q)M+=`<div class="pf-chart-tooltip-label">${j0(q)}</div>`;for(let F of U)M+='<div class="pf-chart-tooltip-row">',M+=`<span class="pf-chart-tooltip-dot" style="background:${j0(F.color)}"></span>`,M+=`<span>${j0(F.label)}:</span> <strong>${j0(String(F.value))}</strong>`,M+="</div>";Q.innerHTML=M;let B=W.getBoundingClientRect(),G=Y.getBoundingClientRect(),N=W.viewBox.baseVal,z=B.width/(N.width||1),T=B.left-G.left+J*z,D=Q.offsetWidth||100,K=T+12;if(K+D>G.width)K=T-D-12;Q.style.left=`${Math.max(0,K)}px`,Q.style.top="4px",Q.classList.add("pf-visible")}function j0($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function F1($,J,Z,q,U,Q,W,Y){let M=U.plotWidth/Z.length;for(let B=0;B<Z.length;B++){let G=U.plotLeft+B*M,N=document.createElementNS("http://www.w3.org/2000/svg","rect");N.setAttribute("x",String(G)),N.setAttribute("y",String(U.plotTop)),N.setAttribute("width",String(M)),N.setAttribute("height",String(U.plotHeight)),N.setAttribute("fill","transparent"),N.style.cursor="default";let z=Q?Z[B][Q]:void 0,T=z!=null?Y?Y(z):String(z):void 0,D=q.map((A,R)=>({label:A.label??A.dataKey,value:W(Z[B][A.dataKey],A,R),color:A.color??L0[R%L0.length]})),K=G+M/2,F=()=>Y0($,K,U.plotTop,T,D),O=()=>$.tooltip.classList.remove("pf-visible");N.addEventListener("mouseenter",F),N.addEventListener("mouseleave",O),N.addEventListener("touchstart",F,{passive:!0}),N.addEventListener("touchend",O,{passive:!0}),J.appendChild(N)}}function T1($,J,Z,q,U,Q,W,Y,M,B){let G=Z.length===1?U.plotWidth:U.plotWidth/(Z.length-1);for(let N=0;N<Z.length;N++){let z=Z.length===1?(U.plotLeft+U.plotRight)/2:U.plotLeft+N/(Z.length-1)*U.plotWidth,T=Z.length===1?U.plotLeft:z-G/2,D=Z.length===1?U.plotWidth:G,K=document.createElementNS("http://www.w3.org/2000/svg","rect");K.setAttribute("x",String(Math.max(U.plotLeft,T))),K.setAttribute("y",String(U.plotTop)),K.setAttribute("width",String(Math.min(D,U.plotRight-Math.max(U.plotLeft,T)))),K.setAttribute("height",String(U.plotHeight)),K.setAttribute("fill","transparent"),K.style.cursor="default";let F=Q?Z[N][Q]:void 0,O=F!=null?B?B(F):String(F):void 0,A=q.map((L,C)=>({label:L.label??L.dataKey,value:W(Z[N][L.dataKey],L,C),color:L.color??L0[C%L0.length]})),R=()=>{if(Y0($,z,U.plotTop,O,A),Y)Y.setAttribute("x1",String(z)),Y.setAttribute("x2",String(z)),Y.setAttribute("opacity","1");if(M)for(let L of M){for(let C of L)C.setAttribute("data-visible","false");L[N]?.setAttribute("data-visible","true")}},E=()=>{if($.tooltip.classList.remove("pf-visible"),Y)Y.setAttribute("opacity","0");if(M)for(let L of M)for(let C of L)C.setAttribute("data-visible","false")};K.addEventListener("mouseenter",R),K.addEventListener("mouseleave",E),K.addEventListener("touchstart",R,{passive:!0}),K.addEventListener("touchend",E,{passive:!0}),J.appendChild(K)}}function L1(){_("BarChart",p8),_("LineChart",j1),_("AreaChart",j1),_("PieChart",c8),_("RadarChart",v0),_("ScatterChart",v0),_("RadialChart",v0),_("Histogram",s8)}var l=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],_0="#6b7280",x8="#e5e7eb",h0="10";function P1($,J,Z,q=!1){let U=Z?44:0,Q=$-(q?44:0),W=10,Y=J-24;return{plotLeft:U,plotRight:Q,plotTop:10,plotBottom:Y,plotWidth:Q-U,plotHeight:Y-10}}function O1($,J=5){if($<=0)return[0];let Z=$/J,q=Math.pow(10,Math.floor(Math.log10(Z))),U=Z/q,Q=U<=1.5?q:U<=3?2*q:U<=7?5*q:10*q,W=[];for(let Y=0;Y<=$+Q*0.01;Y+=Q)W.push(Math.round(Y*1000)/1000);return W}function V1($,J,Z,q,U){let Q=O1(Z);for(let W of Q){let Y=J.plotBottom-(Z>0?W/Z*J.plotHeight:0),M=document.createElementNS("http://www.w3.org/2000/svg","text");if(M.setAttribute("x",String(J.plotLeft-6)),M.setAttribute("y",String(Y+3)),M.setAttribute("text-anchor","end"),M.setAttribute("font-size",h0),M.setAttribute("fill",_0),M.textContent=g0(W,U),$.appendChild(M),q&&W>0){let B=document.createElementNS("http://www.w3.org/2000/svg","line");B.setAttribute("x1",String(J.plotLeft)),B.setAttribute("y1",String(Y)),B.setAttribute("x2",String(J.plotRight)),B.setAttribute("y2",String(Y)),B.setAttribute("stroke",x8),B.setAttribute("stroke-width","1"),B.setAttribute("stroke-dasharray","4 3"),$.appendChild(B)}}}function I1($,J,Z,q){let U=O1(Z);for(let Q of U){let W=J.plotBottom-(Z>0?Q/Z*J.plotHeight:0),Y=document.createElementNS("http://www.w3.org/2000/svg","text");Y.setAttribute("x",String(J.plotRight+6)),Y.setAttribute("y",String(W+3)),Y.setAttribute("text-anchor","start"),Y.setAttribute("font-size",h0),Y.setAttribute("fill",_0),Y.textContent=g0(Q,q),$.appendChild(Y)}}function R1($,J,Z,q,U,Q){for(let W=0;W<J.length;W++){let Y=document.createElementNS("http://www.w3.org/2000/svg","text");Y.setAttribute("x",String(q(W))),Y.setAttribute("y",String(U+14)),Y.setAttribute("text-anchor","middle"),Y.setAttribute("font-size",h0),Y.setAttribute("fill",_0);let M=J[W][Z];Y.textContent=M==null?"":Q?Q(M):String(M),$.appendChild(Y)}}function A1($,J){let Z=document.createElementNS("http://www.w3.org/2000/svg","line");Z.setAttribute("x1",String(J.plotLeft)),Z.setAttribute("y1",String(J.plotBottom)),Z.setAttribute("x2",String(J.plotRight)),Z.setAttribute("y2",String(J.plotBottom)),Z.setAttribute("stroke",_0),Z.setAttribute("stroke-width","1"),$.appendChild(Z)}function J0($,J,Z){if($==null)return"";let q=b(`{{ __v | ${J} }}`,{...Z,scope:{...Z.scope,__v:$}});return q==null?String($):String(q)}function g0($,J){if(J==="currency")return`$${$.toLocaleString()}`;if(J==="percent")return`${$}%`;if($>=1e6)return`${($/1e6).toFixed(1)}M`;if($>=1000)return`${($/1000).toFixed(1)}K`;return String($)}function k1($,J,Z){return(q,U)=>{if(q===null||q===void 0)return"—";if(U.tooltipFormat)return J0(q,U.tooltipFormat,$);let Q=U.yAxisId==="right"?Z:J;return g0(Number(q),Q)}}function p8($,J){let Z=H("div","pf-chart pf-bar-chart"),q=b($.data,J)??[],U=$.series??[],Q=$.height??300;if(q.length===0||U.length===0)return Z.textContent="No chart data",Z;let W=$.showYAxis!==!1,Y=$.showGrid===!0,M=$.showYAxisRight===!0,B=$.showTooltip!==!1,G=$.xAxis,N=$.tooltipXKey,z=$.xAxisFormat,T=$.tooltipXFormat,D=U.filter((I)=>I.yAxisId!=="right"),K=U.filter((I)=>I.yAxisId==="right"),F=M&&K.length>0,O=D.length>0?Math.max(...q.flatMap((I)=>D.map((V)=>Number(I[V.dataKey]??0))),1):1,A=F?Math.max(...q.flatMap((I)=>K.map((V)=>Number(I[V.dataKey]??0))),1):1,R=400,E=P1(R,Q,W,F),L=O0(R,Q,"Bar");if(W)V1(L,E,O,Y,$.yAxisFormat);if(F)I1(L,E,A,$.yAxisRightFormat);A1(L,E);let C=E.plotWidth/q.length,i=C/(U.length+1);for(let I=0;I<q.length;I++)for(let V=0;V<U.length;V++){let f=U[V],x=q[I][f.dataKey];if(x===null||x===void 0)continue;let m=f.yAxisId==="right"?A:O,c=Number(x),s=Math.max(0,c/m*E.plotHeight),a=E.plotLeft+I*C+V*i+i/2,P=document.createElementNS("http://www.w3.org/2000/svg","rect");P.setAttribute("x",String(a)),P.setAttribute("y",String(E.plotBottom-s)),P.setAttribute("width",String(i*0.8)),P.setAttribute("height",String(s)),P.setAttribute("fill",f.color??l[V%l.length]),P.setAttribute("rx","2"),L.appendChild(P)}if(G){let I=z?(V)=>J0(V,z,J):void 0;R1(L,q,G,(V)=>{return E.plotLeft+V*C+C/2},E.plotBottom,I)}if(B){let I=P0(Z,L),V=k1(J,$.yAxisFormat,$.yAxisRightFormat);F1(I,L,q,U,E,N??G,V,T?(x)=>J0(x,T,J):void 0)}return u0(Z,U,$.showLegend),Z.appendChild(L),Z}function j1($,J){let Z=H("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),q=b($.data,J)??[],U=$.series??[],Q=$.height??300;if(q.length===0||U.length===0)return Z.textContent="No chart data",Z;let W=$.showYAxis!==!1,Y=$.showGrid===!0,M=$.showYAxisRight===!0,B=$.showTooltip!==!1,G=$.xAxis,N=$.tooltipXKey,z=$.xAxisFormat,T=$.tooltipXFormat,D=U.filter((V)=>V.yAxisId!=="right"),K=U.filter((V)=>V.yAxisId==="right"),F=M&&K.length>0,O=D.length>0?Math.max(...q.flatMap((V)=>D.map((f)=>Number(V[f.dataKey]??0))),1):1,A=F?Math.max(...q.flatMap((V)=>K.map((f)=>Number(V[f.dataKey]??0))),1):1,R=400,E=P1(R,Q,W,F),L=O0(R,Q,$.type==="AreaChart"?"Area":"Line"),C=$.type==="AreaChart";if(W)V1(L,E,O,Y,$.yAxisFormat);if(F)I1(L,E,A,$.yAxisRightFormat);A1(L,E);let i=[];for(let V=0;V<U.length;V++){let f=U[V],x=f.yAxisId==="right",d=x?A:O,m=f.color??l[V%l.length],c=q.map((P,S)=>{let v=P[f.dataKey],o=v===null||v===void 0,N0=q.length===1?(E.plotLeft+E.plotRight)/2:E.plotLeft+S/(q.length-1)*E.plotWidth,v1=o?E.plotBottom:E.plotBottom-Number(v)/d*E.plotHeight;return{x:N0,y:v1,isNull:o}});if(C){let P=[],S=()=>{if(P.length<2){P=[];return}let v=`M ${P[0].x},${E.plotBottom} `+P.map((N0)=>`L ${N0.x},${N0.y}`).join(" ")+` L ${P[P.length-1].x},${E.plotBottom} Z`,o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("d",v),o.setAttribute("fill",m),o.setAttribute("opacity","0.15"),L.appendChild(o),P=[]};for(let v of c){if(v.isNull){S();continue}P.push(v)}S()}let s="";for(let P of c){if(P.isNull)continue;let S=c.indexOf(P),v=S===0||c[S-1].isNull;s+=`${v?"M":"L"} ${P.x},${P.y} `}if(s){let P=document.createElementNS("http://www.w3.org/2000/svg","path");if(P.setAttribute("d",s.trim()),P.setAttribute("fill","none"),P.setAttribute("stroke",m),P.setAttribute("stroke-width","2"),x)P.setAttribute("stroke-dasharray","6 3");L.appendChild(P)}let a=[];for(let P of c){let S=document.createElementNS("http://www.w3.org/2000/svg","circle");if(S.setAttribute("cx",String(P.x)),S.setAttribute("cy",String(P.y)),S.setAttribute("r","4"),S.setAttribute("fill",m),S.setAttribute("class","pf-data-dot"),S.setAttribute("data-visible","false"),S.style.pointerEvents="none",P.isNull)S.style.display="none";L.appendChild(S),a.push(S)}i.push(a)}let I=document.createElementNS("http://www.w3.org/2000/svg","line");if(I.setAttribute("class","pf-crosshair"),I.setAttribute("x1",String(E.plotLeft)),I.setAttribute("x2",String(E.plotLeft)),I.setAttribute("y1",String(E.plotTop)),I.setAttribute("y2",String(E.plotBottom)),I.setAttribute("stroke",_0),I.setAttribute("stroke-width","1"),I.setAttribute("stroke-dasharray","3 3"),I.setAttribute("opacity","0"),L.appendChild(I),G){let V=z?(f)=>J0(f,z,J):void 0;R1(L,q,G,(f)=>{return q.length===1?(E.plotLeft+E.plotRight)/2:E.plotLeft+f/(q.length-1)*E.plotWidth},E.plotBottom,V)}if(B){let V=P0(Z,L),f=k1(J,$.yAxisFormat,$.yAxisRightFormat);T1(V,L,q,U,E,N??G,f,I,i,T?(d)=>J0(d,T,J):void 0)}return u0(Z,U,$.showLegend),Z.appendChild(L),Z}function c8($,J){let Z=H("div","pf-chart pf-pie-chart"),q=b($.data,J)??[],U=$.series??[],Q=$.height??300,W=Math.min(Q,300),Y=$.showTooltip!==!1;if(q.length===0||U.length===0)return Z.textContent="No chart data",Z;let M=O0(W,W,"Pie"),B=W/2,G=W/2,N=W/2-10,z=U[0].dataKey,T=$.xAxis,D=$.tooltipXKey,K=$.tooltipXFormat,F=q.map((E)=>Number(E[z]??0)),O=F.reduce((E,L)=>E+L,0);if(O===0)return Z.textContent="No chart data",Z.appendChild(M),Z;let A=Y?P0(Z,M):void 0,R=-Math.PI/2;for(let E=0;E<F.length;E++){let L=F[E]/O*2*Math.PI,C=R+L,i=L>Math.PI?1:0,I=B+N*Math.cos(R),V=G+N*Math.sin(R),f=B+N*Math.cos(C),x=G+N*Math.sin(C),d=l[E%l.length],m=document.createElementNS("http://www.w3.org/2000/svg","path");if(m.setAttribute("d",`M ${B},${G} L ${I},${V} A ${N},${N} 0 ${i} 1 ${f},${x} Z`),m.setAttribute("fill",d),m.style.cursor="default",A){let c=D??T,s=c?q[E][c]:void 0,a=s!=null?K?J0(s,K,J):String(s):`Slice ${E+1}`,P=`${(F[E]/O*100).toFixed(1)}%`,S=R+L/2,v=B+N*0.6*Math.cos(S);m.addEventListener("mouseenter",()=>{Y0(A,v,G,a,[{label:U[0].label??z,value:`${F[E]} (${P})`,color:d}])}),m.addEventListener("mouseleave",()=>{A.tooltip.classList.remove("pf-visible")}),m.addEventListener("touchstart",()=>{Y0(A,v,G,a,[{label:U[0].label??z,value:`${F[E]} (${P})`,color:d}])},{passive:!0}),m.addEventListener("touchend",()=>{A.tooltip.classList.remove("pf-visible")},{passive:!0})}M.appendChild(m),R=C}return u0(Z,U,$.showLegend),Z.appendChild(M),Z}function v0($,J){let Z=H("div",`pf-chart pf-${$.type.toLowerCase()}`);return Z.textContent=`${$.type} — not yet supported in renderer`,Z.style.padding="24px",Z.style.textAlign="center",Z}function O0($,J,Z){let q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(q.setAttribute("width","100%"),q.setAttribute("height",String(J)),q.setAttribute("viewBox",`0 0 ${$} ${J}`),q.setAttribute("role","img"),Z)q.setAttribute("aria-label",`${Z} chart`);return q.style.overflow="visible",q}function u0($,J,Z){if(Z===!1||J.length<=1)return;let q=H("div","pf-chart-legend");q.style.display="flex",q.style.gap="12px",q.style.fontSize="12px",q.style.marginBottom="8px";for(let U=0;U<J.length;U++){let Q=H("div","pf-chart-legend-item");Q.style.display="flex",Q.style.alignItems="center",Q.style.gap="4px";let W=H("span");W.style.width="8px",W.style.height="8px",W.style.borderRadius="50%",W.style.backgroundColor=J[U].color??l[U%l.length];let Y=H("span");Y.textContent=J[U].label??J[U].dataKey,Q.appendChild(W),Q.appendChild(Y),q.appendChild(Q)}$.appendChild(q)}function s8($,J){let Z=H("div","pf-chart pf-histogram"),q=b($.data,J);if(!q||q.length===0)return Z.textContent="No data",Z;let U=q,Q=$.bins??10,W=$.height??200,Y=$.color??l[0],M=Math.min(...U),G=(Math.max(...U)-M)/Q||1,N=Array(Q).fill(0);for(let O of U){let A=Math.min(Math.floor((O-M)/G),Q-1);N[A]++}let z=Math.max(...N),T=300,D=W,K=T/Q,F=O0(T,D,"Histogram");for(let O=0;O<Q;O++){let A=z>0?N[O]/z*D:0,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(O*K)),R.setAttribute("y",String(D-A)),R.setAttribute("width",String(K-1)),R.setAttribute("height",String(A)),R.setAttribute("fill",Y),F.appendChild(R)}return Z.appendChild(F),Z}function f1(){_("Table",l8),_("TableHead",x0("thead")),_("TableBody",x0("tbody")),_("TableFooter",x0("tfoot")),_("TableRow",i8),_("TableHeader",d8),_("TableCell",r8),_("TableCaption",n8),_("ExpandableRow",a8)}function l8($,J){let Z=document.createElement("table");return Z.className="pf-table",Z.style.width="100%",Z.style.borderCollapse="collapse",j($,Z,J),Z}function x0($){return(J,Z)=>{let q=document.createElement($);return q.className=`pf-${$}`,j(J,q,Z),q}}function i8($,J){let Z=document.createElement("tr");return Z.className="pf-table-row",j($,Z,J),Z}function d8($,J){let Z=document.createElement("th");return Z.className="pf-table-header",Z.style.textAlign="left",Z.style.padding="8px 12px",Z.style.fontWeight="600",Z.textContent=X($.content,J),Z}function r8($,J){let Z=document.createElement("td");if(Z.className="pf-table-cell",Z.style.padding="8px 12px",$.colSpan!=null)Z.colSpan=$.colSpan;if($.rowSpan!=null)Z.rowSpan=$.rowSpan;return j($,Z,J),Z}function n8($,J){let Z=document.createElement("caption");return Z.className="pf-table-caption",Z.style.padding="8px",Z.style.fontSize="14px",Z.textContent=X($.content,J),Z}function a8($,J){let Z=H("div","pf-expandable-row"),q=H("div","pf-expandable-row-summary");q.style.cursor="pointer",q.style.display="flex",q.style.alignItems="center",q.style.gap="8px";let U=H("span","pf-expandable-arrow");U.textContent="▶",U.style.transition="transform 0.2s",U.style.fontSize="10px",q.appendChild(U);let Q=$.summary;if(Q)for(let M of Q)q.appendChild(w(M,J));let W=H("div","pf-expandable-row-detail");W.style.display="none",W.style.paddingLeft="24px",j($,W,J);let Y=!1;return q.addEventListener("click",()=>{Y=!Y,W.style.display=Y?"block":"none",U.style.transform=Y?"rotate(90deg)":""}),Z.appendChild(q),Z.appendChild(W),Z}var S1=!1;function V0(){if(S1)return;S1=!0,J1(),Q1(),_1(),M1(),H1(),B1(),G1(),z1(),D1(),L1(),f1()}function w1($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function C1($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function y1($,J){if(!J)return;if(J.light)for(let[Z,q]of Object.entries(J.light))$.style.setProperty(`--${w1(Z)}`,C1(q));if(J.dark){let q=document.getElementById("prefab-dark-theme");if(!q)q=document.createElement("style"),q.id="prefab-dark-theme",document.head.appendChild(q);let U=Object.entries(J.dark).map(([Q,W])=>` --${w1(Q)}: ${C1(W)};`).join(`
|
|
7
7
|
`);q.textContent=`[data-theme="dark"] {
|
|
8
8
|
${U}
|
|
9
9
|
}
|
|
@@ -11,4 +11,4 @@ ${U}
|
|
|
11
11
|
:root:not([data-theme="light"]) {
|
|
12
12
|
${U}
|
|
13
13
|
}
|
|
14
|
-
}`}}function y1($,J){if(!$||typeof document>"u")return;let Z=(q)=>{for(let[U,Q]of Object.entries($))if(o8(U,q))q.preventDefault(),J(Q)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)}function o8($,J){let Z=$.toLowerCase().split("+").map((Q)=>Q.trim()),q=Z[Z.length-1],U=new Set(Z.slice(0,-1));if(U.has("ctrl")!==(J.ctrlKey||J.metaKey))return!1;if(U.has("shift")!==J.shiftKey)return!1;if(U.has("alt")!==J.altKey)return!1;return J.key.toLowerCase()===q}function I4($){let J=$?.baseUrl??(typeof window<"u"?window.location.origin:""),Z={"Content-Type":"application/json",...$?.headers},q=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(U,Q){let W=await q(`${J}/mcp/tools/call`,{method:"POST",headers:Z,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:U,arguments:Q}})});if(!W.ok)throw Error(`MCP tool call failed: ${W.status} ${W.statusText}`);let Y=await W.json();if(Y.error)throw Error(Y.error.message??"MCP tool call returned error");let M=Y.result?.content??Y.content??[];for(let H of M)if(H.type==="text"&&H.text!==void 0){try{let G=JSON.parse(H.text);if(typeof G==="object"&&G!==null&&"$prefab"in G)return G;return G}catch{}return H.text}return Y.result??Y},async sendMessage(U){await q(`${J}/mcp/messages`,{method:"POST",headers:Z,body:JSON.stringify({message:U})})}}}function R4(){return{callTool($){return console.warn(`[prefab] No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return console.warn("[prefab] No MCP transport: sendMessage ignored",$),Promise.resolve()}}}function t8($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class t{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;constructor($="*"){this.hostOrigin=$}connect(){if(typeof window>"u")return;let $=e8();if($)this.postFn=(Z)=>$.postMessage(Z);let J=(Z)=>{if(this.hostOrigin!=="*"&&Z.origin!==this.hostOrigin)return;let q=Z.data;if(t8(q)){this.handleJsonRpc(q);return}let U=q;if(!U?.type.startsWith("prefab:"))return;if(U.type==="prefab:tool-call-response"&&U.id){let W=this.pending.get(U.id);if(W){if(this.pending.delete(U.id),U.payload?.error!=null)W.reject(Error(U.payload.error));else W.resolve(U.payload?.result);return}}let Q=this.listeners.get(U.type);if(Q)for(let W of Q)W(U.payload??{})};window.addEventListener("message",J),this.cleanup=()=>window.removeEventListener("message",J)}async initialize($){return Promise.any([this.initPrefab($),this.initJsonRpc($)])}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($,J){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:J});else this.sendPrefab("prefab:open-link",{url:$,target:J})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}on($,J){if(!this.listeners.has($))this.listeners.set($,new Set);let Z=this.listeners.get($);if(Z)Z.add(J)}off($,J){this.listeners.get($)?.delete(J)}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((J,Z)=>{let q=!1,U=(Q)=>{if(q)return;q=!0,this.off("prefab:init-response",U),this.protocol="prefab",J(Q)};this.on("prefab:init-response",U),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!q)q=!0,this.off("prefab:init-response",U),Z(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,J)=>{let Z=`tc-${++this.callIdCounter}`;return new Promise((q,U)=>{this.pending.set(Z,{resolve:q,reject:U}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:J},Z),setTimeout(()=>{if(this.pending.has(Z))this.pending.delete(Z),U(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()}}}sendPrefab($,J,Z){if(typeof window>"u")return;let q=window.parent!==window?window.parent:window,U={type:$,payload:J,id:Z};q.postMessage(U,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 J=$.method,Z=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(J){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:Z.arguments??Z});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:Z.arguments??Z});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:Z});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",Z);break;case"ui/notifications/host-context-changed":{let q={};if(typeof Z.theme==="string")q.colorScheme=Z.theme;if(typeof Z.styles==="object"&&Z.styles!==null){let U=Z.styles;if(U.variables)q.variables=U.variables}this.dispatch("prefab:theme-update",q);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",Z);break}}initJsonRpc($){return new Promise((J,Z)=>{let q=++this.rpcIdCounter,U=!1;this.rpcPending.set(q,{resolve:(Q)=>{if(U)return;U=!0,this.protocol="jsonrpc";let W=Q??{},Y=W.hostInfo??{},M=W.hostContext??{},H=W.hostCapabilities??{},G;if(typeof M.theme==="string"||typeof M.styles==="object"){if(G={},typeof M.theme==="string")G.colorScheme=M.theme;if(typeof M.styles==="object"&&M.styles!==null){let N=M.styles;if(N.variables)G.variables=N.variables}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}}),J({hostName:Y.name,hostVersion:Y.version,capabilities:{toast:!0,navigation:H.openLinks!=null,messaging:!0,displayModes:M.availableDisplayModes??[]},theme:G,toolInput:void 0,meta:M})},reject:(Q)=>{if(U)return;U=!0,Z(Q)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",capabilities:{},clientInfo:{name:"prefab",version:"0.2"},appCapabilities:{...$.displayModes&&{availableDisplayModes:$.displayModes}}}}),setTimeout(()=>{if(!U)U=!0,this.rpcPending.delete(q),Z(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,J)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:J})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})}}}sendRpcRequest($,J){let Z=++this.rpcIdCounter;return new Promise((q,U)=>{this.rpcPending.set(Z,{resolve:q,reject:U}),this.postJsonRpc({jsonrpc:"2.0",id:Z,method:$,params:J}),setTimeout(()=>{if(this.rpcPending.has(Z))this.rpcPending.delete(Z),U(Error(`JSON-RPC '${$}' timed out`))},30000)})}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($,J){let Z=this.listeners.get($);if(Z)for(let q of Z)q(J)}}function M4($,J){if(J.variables)for(let[Z,q]of Object.entries(J.variables))$.style.setProperty(Z.startsWith("--")?Z:`--${Z}`,q);if(J.colorScheme&&J.colorScheme!=="auto")$.setAttribute("data-theme",J.colorScheme)}function Z4(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function e8(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let J=$.acquireVsCodeApi();if(J!==null&&typeof J==="object"&&"postMessage"in J)return J}catch{return}return}async function A4($){V4();let J=$?.mode??"auto",Z=J==="bridge"||J==="auto"&&Z4(),q,U,Q={capabilities:{}};if(Z)U=new t($?.hostOrigin),U.connect(),Q=await U.initialize($?.capabilities??{toolInput:!0}),q=U.createTransport();else if($?.transport)q=I4($.transport);else q=R4();if(Q.theme&&typeof document<"u")M4(document.documentElement,Q.theme);let W,Y,M,H,G=Q.toolInput,N;if(U)U.on("prefab:tool-input",(D)=>{let z=D.args??D;if(W)W(z);else G=z}),U.on("prefab:tool-result",(D)=>{let z=D.result??D;if(Y)Y(z);else N=z}),U.on("prefab:tool-cancelled",()=>{M?.()}),U.on("prefab:tool-input-partial",(D)=>{H?.(D.args??D)}),U.on("prefab:theme-update",(D)=>{if(typeof document<"u")M4(document.documentElement,D)});function X(D,...z){let F=m1(D),O=new q4,A={store:O,scope:{},transport:q,rerender:()=>R(),onToast:void 0};function R(){F.innerHTML="";for(let E of z)F.appendChild(w(E,A))}return R(),{rerender:R,store:O,destroy:()=>{F.innerHTML=""}}}return{callTool:(D,z={})=>q.callTool(D,z),sendMessage:(D)=>q.sendMessage(D),onToolInput:(D)=>{if(W=D,G){let z=G;G=void 0,queueMicrotask(()=>D(z))}},onToolResult:(D)=>{if(Y=D,N!==void 0){let z=N;N=void 0,queueMicrotask(()=>D(z))}},onToolCancelled:(D)=>{M=D},onToolInputPartial:(D)=>{H=D},render:X,mount:(D,z,F)=>{let O=m1(D);return p.mount(O,z,{transport:q,...F})},requestMode:(D)=>U?.requestMode(D),openLink:(D,z)=>{if(U)U.openLink(D,z);else if(typeof window<"u")window.open(D,z??"_blank")},updateContext:(D)=>{if(U)U.updateContext(D)},host:Q,capabilities:Q.capabilities,theme:Q.theme,transport:q,destroy:()=>U?.disconnect()}}function m1($){if(typeof $==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let J=document.querySelector($);if(!J)throw Error(`Element not found: ${$}`);return J}return $}var p={mount($,J,Z){V4();let q=[];if(J.pipes)for(let[N,X]of Object.entries(J.pipes))J2(N,X,q);let U=new q4(J.state),Q;if(Z?.transport&&"callTool"in Z.transport)Q=Z.transport;else if(Z?.transport)Q=I4(Z.transport);else Q=R4();let W=Z?.onToast??Z2,Y={store:U,scope:{},transport:Q,rerender:()=>G(),onToast:W,defs:J.defs};b1($,J.theme);let M=[];if(J.stylesheets)for(let N of J.stylesheets){let X=document.createElement("style");X.textContent=N,X.dataset.prefab="injected",document.head.appendChild(X),M.push(X)}let H;if(J.keyBindings)H=y1(J.keyBindings,async(N)=>{await k(N,{store:U,transport:Q,scope:{},rerender:()=>G(),onToast:W})});function G(){$.innerHTML="";let N=w(J.view,Y);$.appendChild(N)}return G(),{rerender:()=>G(),update(N){U.merge(N.update.state),G()},store:U,destroy(){H?.(),r4();for(let N of M)N.remove();for(let N of q)Q4(N);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},$2=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 J2($,J,Z){if($2.has($)){console.warn(`[prefab] wire pipe "${$}" ignored — shadows built-in`);return}try{let q=Function("return ("+J+")")();if(typeof q!=="function"){console.warn(`[prefab] wire pipe "${$}" — source did not evaluate to a function`);return}U4($,q),Z.push($)}catch(q){console.warn(`[prefab] wire pipe "${$}" — failed to hydrate:`,q)}}function Z2($){if(typeof document>"u")return;let J=q2(),Z=document.createElement("div");Z.className="pf-toast",Z.setAttribute("data-variant",$.variant??"default"),Z.style.padding="12px 16px",Z.style.borderRadius="8px",Z.style.backgroundColor="var(--card, #fff)",Z.style.border="1px solid var(--border, #e5e7eb)",Z.style.boxShadow="0 4px 12px rgb(0 0 0 / 0.15)",Z.style.marginBottom="8px",Z.style.transition="opacity 0.3s ease";let q=document.createElement("div");if(q.textContent=$.message,q.style.fontWeight="500",Z.appendChild(q),$.description){let Q=document.createElement("div");Q.textContent=$.description,Q.style.fontSize="14px",Q.style.color="var(--muted-foreground, #6b7280)",Z.appendChild(Q)}J.appendChild(Z);let U=$.duration??4000;setTimeout(()=>{Z.style.opacity="0",setTimeout(()=>Z.remove(),300)},U)}function q2(){let J=document.getElementById("prefab-toast-container");if(!J)J=document.createElement("div"),J.id="prefab-toast-container",J.style.position="fixed",J.style.bottom="16px",J.style.right="16px",J.style.zIndex="9999",J.style.maxWidth="400px",document.body.appendChild(J);return J}if(typeof window<"u"){let $=window;$.PrefabRenderer=p,$.prefab={app:A4,mount:p.mount.bind(p),isPrefabData:p.isPrefabData.bind(p),isPrefabUpdate:p.isPrefabUpdate.bind(p),Bridge:t,isIframe:Z4,registerPipe:U4,unregisterPipe:Q4,listPipes:B4,registerComponent:_};let J=$.__PREFAB_DATA__;if(J!=null){let Z=document.getElementById("prefab-root");if(Z)p.mount(Z,J)}}})();
|
|
14
|
+
}`}}function b1($,J){if(!$||typeof document>"u")return;let Z=(q)=>{for(let[U,Q]of Object.entries($))if(o8(U,q))q.preventDefault(),J(Q)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)}function o8($,J){let Z=$.toLowerCase().split("+").map((Q)=>Q.trim()),q=Z[Z.length-1],U=new Set(Z.slice(0,-1));if(U.has("ctrl")!==(J.ctrlKey||J.metaKey))return!1;if(U.has("shift")!==J.shiftKey)return!1;if(U.has("alt")!==J.altKey)return!1;return J.key.toLowerCase()===q}function I0($){let J=$?.baseUrl??(typeof window<"u"?window.location.origin:""),Z={"Content-Type":"application/json",...$?.headers},q=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(U,Q){let W=await q(`${J}/mcp/tools/call`,{method:"POST",headers:Z,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:U,arguments:Q}})});if(!W.ok)throw Error(`MCP tool call failed: ${W.status} ${W.statusText}`);let Y=await W.json();if(Y.error)throw Error(Y.error.message??"MCP tool call returned error");let M=Y.result?.content??Y.content??[];for(let B of M)if(B.type==="text"&&B.text!==void 0){try{let G=JSON.parse(B.text);if(typeof G==="object"&&G!==null&&"$prefab"in G)return G;return G}catch{}return B.text}return Y.result??Y},async sendMessage(U){await q(`${J}/mcp/messages`,{method:"POST",headers:Z,body:JSON.stringify({message:U})})}}}function R0(){return{callTool($){return console.warn(`[prefab] No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return console.warn("[prefab] No MCP transport: sendMessage ignored",$),Promise.resolve()}}}function t8($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class t{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;constructor($="*"){this.hostOrigin=$}connect(){if(typeof window>"u")return;let $=e8();if($)this.postFn=(Z)=>$.postMessage(Z);let J=(Z)=>{if(this.hostOrigin!=="*"&&Z.origin!==this.hostOrigin)return;let q=Z.data;if(t8(q)){this.handleJsonRpc(q);return}let U=q;if(!U?.type.startsWith("prefab:"))return;if(U.type==="prefab:tool-call-response"&&U.id){let W=this.pending.get(U.id);if(W){if(this.pending.delete(U.id),U.payload?.error!=null)W.reject(Error(U.payload.error));else W.resolve(U.payload?.result);return}}let Q=this.listeners.get(U.type);if(Q)for(let W of Q)W(U.payload??{})};window.addEventListener("message",J),this.cleanup=()=>window.removeEventListener("message",J)}async initialize($){return Promise.any([this.initPrefab($),this.initJsonRpc($)])}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($,J){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:J});else this.sendPrefab("prefab:open-link",{url:$,target:J})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}on($,J){if(!this.listeners.has($))this.listeners.set($,new Set);let Z=this.listeners.get($);if(Z)Z.add(J)}off($,J){this.listeners.get($)?.delete(J)}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((J,Z)=>{let q=!1,U=(Q)=>{if(q)return;q=!0,this.off("prefab:init-response",U),this.protocol="prefab",J(Q)};this.on("prefab:init-response",U),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!q)q=!0,this.off("prefab:init-response",U),Z(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,J)=>{let Z=`tc-${++this.callIdCounter}`;return new Promise((q,U)=>{this.pending.set(Z,{resolve:q,reject:U}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:J},Z),setTimeout(()=>{if(this.pending.has(Z))this.pending.delete(Z),U(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()}}}sendPrefab($,J,Z){if(typeof window>"u")return;let q=window.parent!==window?window.parent:window,U={type:$,payload:J,id:Z};q.postMessage(U,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 J=$.method,Z=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(J){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:Z.arguments??Z});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:Z.arguments??Z});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:Z});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",Z);break;case"ui/notifications/host-context-changed":{let q={};if(typeof Z.theme==="string")q.colorScheme=Z.theme;if(typeof Z.styles==="object"&&Z.styles!==null){let U=Z.styles;if(U.variables)q.variables=U.variables}this.dispatch("prefab:theme-update",q);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",Z);break}}initJsonRpc($){return new Promise((J,Z)=>{let q=++this.rpcIdCounter,U=!1;this.rpcPending.set(q,{resolve:(Q)=>{if(U)return;U=!0,this.protocol="jsonrpc";let W=Q??{},Y=W.hostInfo??{},M=W.hostContext??{},B=W.hostCapabilities??{},G;if(typeof M.theme==="string"||typeof M.styles==="object"){if(G={},typeof M.theme==="string")G.colorScheme=M.theme;if(typeof M.styles==="object"&&M.styles!==null){let N=M.styles;if(N.variables)G.variables=N.variables}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}}),J({hostName:Y.name,hostVersion:Y.version,capabilities:{toast:!0,navigation:B.openLinks!=null,messaging:!0,displayModes:M.availableDisplayModes??[]},theme:G,toolInput:void 0,meta:M})},reject:(Q)=>{if(U)return;U=!0,Z(Q)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",capabilities:{},clientInfo:{name:"prefab",version:"0.2"},appCapabilities:{...$.displayModes&&{availableDisplayModes:$.displayModes}}}}),setTimeout(()=>{if(!U)U=!0,this.rpcPending.delete(q),Z(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,J)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:J})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})}}}sendRpcRequest($,J){let Z=++this.rpcIdCounter;return new Promise((q,U)=>{this.rpcPending.set(Z,{resolve:q,reject:U}),this.postJsonRpc({jsonrpc:"2.0",id:Z,method:$,params:J}),setTimeout(()=>{if(this.rpcPending.has(Z))this.rpcPending.delete(Z),U(Error(`JSON-RPC '${$}' timed out`))},30000)})}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($,J){let Z=this.listeners.get($);if(Z)for(let q of Z)q(J)}}function M0($,J){if(J.variables)for(let[Z,q]of Object.entries(J.variables))$.style.setProperty(Z.startsWith("--")?Z:`--${Z}`,q);if(J.colorScheme&&J.colorScheme!=="auto")$.setAttribute("data-theme",J.colorScheme)}function Z0(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function e8(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let J=$.acquireVsCodeApi();if(J!==null&&typeof J==="object"&&"postMessage"in J)return J}catch{return}return}async function A0($){V0();let J=$?.mode??"auto",Z=J==="bridge"||J==="auto"&&Z0(),q,U,Q={capabilities:{}};if(Z)U=new t($?.hostOrigin),U.connect(),Q=await U.initialize($?.capabilities??{toolInput:!0}),q=U.createTransport();else if($?.transport)q=I0($.transport);else q=R0();if(Q.theme&&typeof document<"u")M0(document.documentElement,Q.theme);let W,Y,M,B,G=Q.toolInput,N;if(U)U.on("prefab:tool-input",(D)=>{let K=D.args??D;if(W)W(K);else G=K}),U.on("prefab:tool-result",(D)=>{let K=D.result??D;if(Y)Y(K);else N=K}),U.on("prefab:tool-cancelled",()=>{M?.()}),U.on("prefab:tool-input-partial",(D)=>{B?.(D.args??D)}),U.on("prefab:theme-update",(D)=>{if(typeof document<"u")M0(document.documentElement,D)});function z(D,...K){let F=m1(D),O=new q0,A={store:O,scope:{},transport:q,rerender:()=>R(),onToast:void 0};function R(){F.innerHTML="";for(let E of K)F.appendChild(w(E,A))}return R(),{rerender:R,store:O,destroy:()=>{F.innerHTML=""}}}return{callTool:(D,K={})=>q.callTool(D,K),sendMessage:(D)=>q.sendMessage(D),onToolInput:(D)=>{if(W=D,G){let K=G;G=void 0,queueMicrotask(()=>D(K))}},onToolResult:(D)=>{if(Y=D,N!==void 0){let K=N;N=void 0,queueMicrotask(()=>D(K))}},onToolCancelled:(D)=>{M=D},onToolInputPartial:(D)=>{B=D},render:z,mount:(D,K,F)=>{let O=m1(D);return p.mount(O,K,{transport:q,...F})},requestMode:(D)=>U?.requestMode(D),openLink:(D,K)=>{if(U)U.openLink(D,K);else if(typeof window<"u")window.open(D,K??"_blank")},updateContext:(D)=>{if(U)U.updateContext(D)},host:Q,capabilities:Q.capabilities,theme:Q.theme,transport:q,destroy:()=>U?.disconnect()}}function m1($){if(typeof $==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let J=document.querySelector($);if(!J)throw Error(`Element not found: ${$}`);return J}return $}var p={mount($,J,Z){V0();let q=[];if(J.pipes)for(let[N,z]of Object.entries(J.pipes))J2(N,z,q);let U=new q0(J.state),Q;if(Z?.transport&&"callTool"in Z.transport)Q=Z.transport;else if(Z?.transport)Q=I0(Z.transport);else Q=R0();let W=Z?.onToast??Z2,Y={store:U,scope:{},transport:Q,rerender:()=>G(),onToast:W,defs:J.defs};y1($,J.theme);let M=[];if(J.stylesheets)for(let N of J.stylesheets){let z=document.createElement("style");z.textContent=N,z.dataset.prefab="injected",document.head.appendChild(z),M.push(z)}let B;if(J.keyBindings)B=b1(J.keyBindings,async(N)=>{await k(N,{store:U,transport:Q,scope:{},rerender:()=>G(),onToast:W})});function G(){$.innerHTML="";let N=w(J.view,Y);$.appendChild(N)}return G(),{rerender:()=>G(),update(N){U.merge(N.update.state),G()},store:U,destroy(){B?.(),r0();for(let N of M)N.remove();for(let N of q)Q0(N);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},$2=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 J2($,J,Z){if($2.has($)){console.warn(`[prefab] wire pipe "${$}" ignored — shadows built-in`);return}try{let q=Function("return ("+J+")")();if(typeof q!=="function"){console.warn(`[prefab] wire pipe "${$}" — source did not evaluate to a function`);return}U0($,q),Z.push($)}catch(q){console.warn(`[prefab] wire pipe "${$}" — failed to hydrate:`,q)}}function Z2($){if(typeof document>"u")return;let J=q2(),Z=document.createElement("div");Z.className="pf-toast",Z.setAttribute("data-variant",$.variant??"default"),Z.style.padding="12px 16px",Z.style.borderRadius="8px",Z.style.backgroundColor="var(--card, #fff)",Z.style.border="1px solid var(--border, #e5e7eb)",Z.style.boxShadow="0 4px 12px rgb(0 0 0 / 0.15)",Z.style.marginBottom="8px",Z.style.transition="opacity 0.3s ease";let q=document.createElement("div");if(q.textContent=$.message,q.style.fontWeight="500",Z.appendChild(q),$.description){let Q=document.createElement("div");Q.textContent=$.description,Q.style.fontSize="14px",Q.style.color="var(--muted-foreground, #6b7280)",Z.appendChild(Q)}J.appendChild(Z);let U=$.duration??4000;setTimeout(()=>{Z.style.opacity="0",setTimeout(()=>Z.remove(),300)},U)}function q2(){let J=document.getElementById("prefab-toast-container");if(!J)J=document.createElement("div"),J.id="prefab-toast-container",J.style.position="fixed",J.style.bottom="16px",J.style.right="16px",J.style.zIndex="9999",J.style.maxWidth="400px",document.body.appendChild(J);return J}if(typeof window<"u"){let $=window;$.PrefabRenderer=p,$.prefab={app:A0,mount:p.mount.bind(p),isPrefabData:p.isPrefabData.bind(p),isPrefabUpdate:p.isPrefabUpdate.bind(p),Bridge:t,isIframe:Z0,registerPipe:U0,unregisterPipe:Q0,listPipes:H0,registerComponent:_};let J=$.__PREFAB_DATA__;if(J!=null){let Z=document.getElementById("prefab-root");if(Z)p.mount(Z,J)}}})();
|
package/package.json
CHANGED