@maxhealth.tech/prefab 0.2.26 → 0.2.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/actions/client.js +12 -12
  3. package/dist/actions/client.js.map +1 -1
  4. package/dist/actions/index.d.ts +2 -0
  5. package/dist/actions/index.d.ts.map +1 -1
  6. package/dist/actions/index.js +1 -0
  7. package/dist/actions/index.js.map +1 -1
  8. package/dist/actions/mcp.js +3 -3
  9. package/dist/actions/mcp.js.map +1 -1
  10. package/dist/actions/subscribe.d.ts +57 -0
  11. package/dist/actions/subscribe.d.ts.map +1 -0
  12. package/dist/actions/subscribe.js +68 -0
  13. package/dist/actions/subscribe.js.map +1 -0
  14. package/dist/app.d.ts +1 -1
  15. package/dist/app.js +2 -2
  16. package/dist/app.js.map +1 -1
  17. package/dist/auto/index.d.ts.map +1 -1
  18. package/dist/auto/index.js +1 -2
  19. package/dist/auto/index.js.map +1 -1
  20. package/dist/components/charts/index.d.ts.map +1 -1
  21. package/dist/components/charts/index.js +10 -1
  22. package/dist/components/charts/index.js.map +1 -1
  23. package/dist/components/pdf/index.d.ts +47 -0
  24. package/dist/components/pdf/index.d.ts.map +1 -0
  25. package/dist/components/pdf/index.js +49 -0
  26. package/dist/components/pdf/index.js.map +1 -0
  27. package/dist/core/component.d.ts +2 -0
  28. package/dist/core/component.d.ts.map +1 -1
  29. package/dist/core/component.js +8 -4
  30. package/dist/core/component.js.map +1 -1
  31. package/dist/core/index.d.ts +1 -1
  32. package/dist/core/index.d.ts.map +1 -1
  33. package/dist/core/index.js +1 -1
  34. package/dist/core/index.js.map +1 -1
  35. package/dist/core/validate.js +9 -2
  36. package/dist/core/validate.js.map +1 -1
  37. package/dist/index.d.ts +4 -0
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +3 -0
  40. package/dist/index.js.map +1 -1
  41. package/dist/mcp/display.d.ts +9 -2
  42. package/dist/mcp/display.d.ts.map +1 -1
  43. package/dist/mcp/display.js +4 -26
  44. package/dist/mcp/display.js.map +1 -1
  45. package/dist/renderer/actions.d.ts +8 -0
  46. package/dist/renderer/actions.d.ts.map +1 -1
  47. package/dist/renderer/actions.js +118 -1
  48. package/dist/renderer/actions.js.map +1 -1
  49. package/dist/renderer/bridge.d.ts +12 -0
  50. package/dist/renderer/bridge.d.ts.map +1 -1
  51. package/dist/renderer/bridge.js +57 -0
  52. package/dist/renderer/bridge.js.map +1 -1
  53. package/dist/renderer/components/index.d.ts.map +1 -1
  54. package/dist/renderer/components/index.js +2 -0
  55. package/dist/renderer/components/index.js.map +1 -1
  56. package/dist/renderer/components/pdf.d.ts +12 -0
  57. package/dist/renderer/components/pdf.d.ts.map +1 -0
  58. package/dist/renderer/components/pdf.js +217 -0
  59. package/dist/renderer/components/pdf.js.map +1 -0
  60. package/dist/renderer/engine.d.ts +6 -0
  61. package/dist/renderer/engine.d.ts.map +1 -1
  62. package/dist/renderer/engine.js +40 -13
  63. package/dist/renderer/engine.js.map +1 -1
  64. package/dist/renderer/index.d.ts.map +1 -1
  65. package/dist/renderer/index.js +2 -1
  66. package/dist/renderer/index.js.map +1 -1
  67. package/dist/renderer.auto.min.js +8 -8
  68. package/dist/renderer.min.js +6 -6
  69. package/package.json +7 -2
@@ -1,9 +1,9 @@
1
- (()=>{var{defineProperty:S0,getOwnPropertyNames:c1,getOwnPropertyDescriptor:l1}=Object,s1=Object.prototype.hasOwnProperty;function i1($){return this[$]}var d1=($)=>{var J=(s0??=new WeakMap).get($),Z;if(J)return J;if(J=S0({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var q of c1($))if(!s1.call(J,q))S0(J,q,{get:i1.bind($,q),enumerable:!(Z=l1($,q))||Z.enumerable})}return s0.set($,J),J},s0;var r1=($)=>$;function n1($,J){this[$]=r1.bind(null,J)}var a1=($,J)=>{for(var Z in J)S0($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:n1.bind(J,Z)})};var E2={};a1(E2,{unregisterPipe:()=>Q0,registerPipe:()=>U0,registerComponent:()=>M,listPipes:()=>X0,isIframe:()=>Z0,createThemeToggle:()=>_0,applyHostTheme:()=>B0,app:()=>f0,PrefabRenderer:()=>p,DestroyRegistry:()=>Y0,Bridge:()=>t});class q0{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return o1(this.data,$)}getAll(){return this.data}set($,J){i0(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($))i0(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 o1($,J){let Z=J.split("."),q=$;for(let U of Z){if(q==null||typeof q!=="object")return;q=q[U]}return q}var t1=new Set(["__proto__","constructor","prototype"]);function i0($,J,Z){let q=J.split(".");if(q.some((Q)=>t1.has(Q))){console.warn(`[prefab] Blocked prototype pollution attempt: ${J}`);return}let U=$;for(let Q=0;Q<q.length-1;Q++){let Y=q[Q];if(U[Y]==null||typeof U[Y]!=="object")U[Y]={};U=U[Y]}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 X0(){return[...e.keys()]}function d0($){return e.get($)}var r0=-1,w0=new Map,e1=/\{\{\s*(.+?)\s*\}\}/g;function g($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function u($,J,Z){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&Y4(q,"{{")===1){let U=q.slice(2,-2).trim();return n0(U,J,Z)}return $.replace(e1,(U,Q)=>{let Y=n0(Q.trim(),J,Z);return Y==null?"":String(Y)})}function n0($,J,Z){let[q,...U]=Q4($),Q=h(q.trim(),J,Z);for(let Y of U)Q=$4(Y.trim(),Q,J,Z);return Q}function h($,J,Z){let q=q4($);if(q>=0){let Y=$.slice(0,q).trim(),W=$.slice(q+1),H=U4(W);if(H>=0){let X=W.slice(0,H).trim(),G=W.slice(H+1).trim(),_=h(Y,J,Z);return _!==null&&_!==void 0&&_!==!1&&_!==0&&_!==""?h(X,J,Z):h(G,J,Z)}}let U=G0($,"||");if(U>=0){let Y=h($.slice(0,U).trim(),J,Z);return Y!==null&&Y!==void 0&&Y!==!1&&Y!==0&&Y!==""?Y:h($.slice(U+2).trim(),J,Z)}let Q=G0($,"&&");if(Q>=0){let Y=h($.slice(0,Q).trim(),J,Z);if(Y===null||Y===void 0||Y===!1||Y===0||Y==="")return Y;return h($.slice(Q+2).trim(),J,Z)}for(let[Y,W]of J4){let H=G0($,Y);if(H>=0){let X=h($.slice(0,H).trim(),J,Z),G=h($.slice(H+Y.length).trim(),J,Z);return W(X,G)}}if($.startsWith("!")){let Y=h($.slice(1).trim(),J,Z);return Y===null||Y===void 0||Y===!1||Y===0||Y===""}for(let[Y,W]of Z4){let H=G0($,Y);if(H>=0){let X=h($.slice(0,H).trim(),J,Z),G=h($.slice(H+Y.length).trim(),J,Z);return W(Number(X),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 Y=$.indexOf(".");if(Y>=0){let W=$.slice(0,Y),H=$.slice(Y+1),X=Z[W];return E0(X,H)}return Z[$]}if(Z){let Y=$.split(".")[0];if(Y in Z)return E0(Z[Y],$.includes(".")?$.slice(Y.length+1):"")}return J.get($)}function $4($,J,Z,q){let U=$.indexOf(":"),Q=U>=0?$.slice(0,U).trim():$,Y=U>=0?$.slice(U+1).trim():void 0,W=Y?C0(Y):void 0;switch(Q){case"find":{if(!Array.isArray(J)||!Y)return;let H=a0(Y);if(H.length<2)return;let X=C0(H[0]),G=H[1].trim(),_;if(G.startsWith("'")&&G.endsWith("'")||G.startsWith('"')&&G.endsWith('"'))_=G.slice(1,-1);else if(Z){if(q&&G.startsWith("$")){let E=G.indexOf(".");if(E>=0){let L=G.slice(0,E);if(L in q)_=E0(q[L],G.slice(E+1))}else if(G in q)_=q[G]}if(_===void 0&&!(q&&G.startsWith("$")))if(q){let E=G.split(".")[0];_=E in q?E0(q[E],G.includes(".")?G.slice(E.length+1):""):Z.get(G)}else _=Z.get(G)}else _=G;if(_==null)return;let z=Z?.generation??0;if(z!==r0)w0=new Map,r0=z;let D=w0.get(J);if(!D)D=new Map,w0.set(J,D);let N=D.get(X);if(!N){N=new Map;for(let E of J)if(E!=null&&typeof E==="object"){let L=E[X];if(L!=null)N.set(String(L),E)}D.set(X,N)}return N.get(String(_))}case"dot":{if(J==null||typeof J!=="object"||typeof W!=="string")return;return J[W]}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 W==="number")return J.slice(0,W);return J;case"join":return Array.isArray(J)?J.join(typeof W==="string"?W:", "):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 W==="number"?Number(Number(J).toFixed(W)):Math.round(Number(J));case"number":return typeof W==="number"?Number(Number(J).toFixed(W)):Number(J);case"currency":{let H=typeof W==="string"?W:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:H}).format(Number(J))}catch{return J}}case"percent":return typeof W==="number"?`${(Number(J)*100).toFixed(W)}%`:`${Math.round(Number(J)*100)}%`;case"compact":{let H=typeof W==="number"?W:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:H}).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 H=Number(J),X=typeof W==="string"?W:"";return H===1?X:`${X}s`}case"default":return J==null||J===""?W:J;case"selectattr":return Array.isArray(J)&&typeof W==="string"?J.filter((H)=>H!=null&&typeof H==="object"&&Boolean(H[W])):J;case"rejectattr":return Array.isArray(J)&&typeof W==="string"?J.filter((H)=>{if(H==null||typeof H!=="object")return!1;let X=H[W];return X==null||X===!1||X===0||X===""}):J;default:{let H=d0(Q);if(H){let X=Y?a0(Y).map(C0):[];return H(J,...X)}return J}}}var J4=[["!==",($,J)=>$!==J],["===",($,J)=>$===J],["!=",($,J)=>$!=J],["==",($,J)=>$==J],[">=",($,J)=>Number($)>=Number(J)],["<=",($,J)=>Number($)<=Number(J)],[">",($,J)=>Number($)>Number(J)],["<",($,J)=>Number($)<Number(J)]],Z4=[[" + ",($,J)=>$+J],[" - ",($,J)=>$-J],[" * ",($,J)=>$*J],[" / ",($,J)=>J!==0?$/J:0],[" % ",($,J)=>J!==0?$%J:0]];function G0($,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 q4($){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 U4($){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 Q4($){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 C0($){let J=$.replace(/^['"]|['"]$/g,"");if(J==="true")return!0;if(J==="false")return!1;let Z=Number(J);return isNaN(Z)?J:Z}function a0($){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 E0($,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 Y4($,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 W4(q,J)}async function W4($,J){let Z=$.action;switch(Z){case"setState":{H4($,J);return}case"toggleState":{M4($,J);return}case"appendState":{_4($,J);return}case"popState":{B4($,J);return}case"showToast":{N4($,J);return}case"closeOverlay":{X4($,J);return}case"openLink":{G4($);return}case"setInterval":{K4($,J);return}case"toolCall":case"callTool":return D4($,J);case"sendMessage":return F4($,J);case"updateContext":{L4($,J);return}case"fetch":return j4($,J);case"openFilePicker":{P4($,J);return}case"callHandler":return O4($,J);case"requestDisplayMode":{T4($,J);return}default:console.warn(`[prefab] Unknown action: ${Z}`)}}function H4($,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 M4($,J){J.store.toggle($.key),J.rerender()}function _4($,J){let Z=$.value??$.item;if(g(Z))Z=u(Z,J.store,J.scope);J.store.append($.key,Z,$.index),J.rerender()}function B4($,J){J.store.pop($.key,$.index),J.rerender()}function N4($,J){J.onToast?.({message:K0($.message,J),description:$.description!=null?K0($.description,J):void 0,variant:$.variant,duration:$.duration})}function X4($,J){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function G4($){if(typeof window<"u"){let J=$.url;if(!J){console.warn("[prefab] openLink: missing url");return}if(!t0(J)){console.warn(`[prefab] Blocked unsafe URL scheme: ${J}`);return}window.open(J,$.target??"_blank")}}var z0=new Set,E4=20,z4=100;function K4($,J){let Z=Math.max($.intervalMs,z4),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(z0.size>=E4){console.warn("[prefab] Max intervals reached, ignoring new setInterval");return}let U=globalThis.setInterval(()=>void k(q,J),Z);z0.add(U)}function o0(){for(let $ of z0)globalThis.clearInterval($);z0.clear()}async function D4($,J){if(!J.transport){console.warn("[prefab] No MCP transport configured for toolCall");return}let Z=$.tool,q=e0($.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 F4($,J){if(!J.transport){console.warn("[prefab] No MCP transport configured for sendMessage");return}await J.transport.sendMessage(K0($.message,J))}function L4($,J){let Z=$.context;if(Z!=null)J.store.merge(Z),J.rerender()}async function j4($,J){let Z=K0($.url,J);if(!t0(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 Y=await globalThis.fetch(Z,{method:q,headers:{"Content-Type":"application/json",...U},...Q&&{body:Q}}),W=await Y.json().catch(()=>Y.text());if($.resultKey!=null)J.store.set($.resultKey,W);J.rerender(),await r($.onSuccess,J,{$result:W})}catch(Y){await r($.onError,J,{$error:Y})}}function P4($,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 O4($,J){let Z=$.handler,q=e0($.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 T4($,J){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var V4=/^\s*(javascript|vbscript|data):/i;function t0($){return!V4.test($)}function K0($,J){if(g($)){let Z=u($,J.store,J.scope);return Z==null?"":String(Z)}return $==null?"":String($)}function e0($,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})}class Y0{callbacks=[];track($){this.callbacks.push($)}flush(){for(let $ of this.callbacks)try{$()}catch(J){console.warn("[prefab] destroy callback error:",J)}this.callbacks=[]}get size(){return this.callbacks.length}}function I4($){return typeof $==="object"&&"element"in $}var y0=new Map;function M($,J){if(y0.has($))console.warn(`[prefab] overriding existing renderer for "${$}"`);y0.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=y0.get($.type),q;if(Z){let U=Z($,J);if(I4(U))q=U.element,J.destroyRegistry?.track(U.destroy);else q=U}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=R4($,q,J,Z);else if(U.type==="Elif"||U.type==="Else")q++;else J.appendChild(w(U,Z)),q++}}function R4($,J,Z,q){let U=!1,Q=J,Y=$[Q];if($1(Y.condition,q))b0(Y,Z,q),U=!0;Q++;while(Q<$.length){let W=$[Q];if(W.type==="Elif"){if(!U&&$1(W.condition,q))b0(W,Z,q),U=!0;Q++}else if(W.type==="Else"){if(!U)b0(W,Z,q);Q++;break}else break}return Q}function $1($,J){if(!$)return!1;if(g($))return Boolean(u($,J.store,J.scope));return Boolean(J.store.get($))}function b0($,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 m0($,J){return $.textContent=J,$}function U1(){M("Column",A4),M("Row",k4),M("Grid",J1),M("GridItem",Z1),M("Container",f4),M("Div",q1),M("Span",S4),M("Dashboard",J1),M("DashboardItem",Z1),M("Pages",w4),M("Page",q1),M("Detail",C4),M("MasterDetail",b4)}function A4($,J){let Z=B("div","pf-column");Z.style.display="flex",Z.style.flexDirection="column";let q=D0($);if(q!=null)Z.style.gap=`${q*4}px`;if($.align!=null)Z.style.alignItems=Q1($.align);if($.justify!=null)Z.style.justifyContent=Y1($.justify);return j($,Z,J),Z}function k4($,J){let Z=B("div","pf-row");Z.style.display="flex",Z.style.flexDirection="row";let q=D0($);if(q!=null)Z.style.gap=`${q*4}px`;if($.align!=null)Z.style.alignItems=Q1($.align);if($.justify!=null)Z.style.justifyContent=Y1($.justify);if($.wrap===!0)Z.style.flexWrap="wrap";return j($,Z,J),Z}function J1($,J){let Z=B("div","pf-grid");Z.style.display="grid";let q=$.columns??3;Z.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let U=D0($);if(U!=null)Z.style.gap=`${U*4}px`;return j($,Z,J),Z}function Z1($,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 f4($,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 q1($,J){let Z=B("div","pf-div");return j($,Z,J),Z}function S4($,J){let Z=B("span","pf-span");return j($,Z,J),Z}function w4($,J){let Z=B("div","pf-pages");return j($,Z,J),Z}function C4($,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 b4($,J){let Z=B("div","pf-master-detail");Z.style.display="flex",Z.style.flexDirection="row";let q=D0($);if(q!=null)Z.style.gap=`${q*4}px`;let U=$.masterWidth??"33%",Q=$.children??[];if(Q.length>0){let Y=B("div","pf-master-detail-master");Y.style.width=U,Y.style.flexShrink="0",Y.style.overflow="auto",Y.appendChild(w(Q[0],J)),Z.appendChild(Y)}if(Q.length>1){let Y=B("div","pf-master-detail-detail");Y.style.flex="1",Y.style.overflow="auto",Y.appendChild(w(Q[1],J)),Z.appendChild(Y)}return Z}var y4=/\bgap-(\d+)\b/;function D0($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let J=y4.exec($.cssClass);if(J)return Number(J[1])}return null}function Q1($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function Y1($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}function H1(){M("Heading",m4),M("H1",($,J)=>F0($,J,"h1")),M("H2",($,J)=>F0($,J,"h2")),M("H3",($,J)=>F0($,J,"h3")),M("H4",($,J)=>F0($,J,"h4")),M("Text",v4),M("P",h4),M("Lead",($,J)=>$0($,J,"p","pf-lead")),M("Large",($,J)=>$0($,J,"span","pf-large")),M("Small",($,J)=>$0($,J,"small","pf-small")),M("Muted",($,J)=>$0($,J,"p","pf-muted")),M("BlockQuote",($,J)=>$0($,J,"blockquote","pf-blockquote")),M("Label",($,J)=>$0($,J,"label","pf-label")),M("Link",u4),M("Code",x4),M("Markdown",p4),M("Kbd",c4)}function m4($,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 F0($,J,Z){let q=document.createElement(Z);return q.className=`pf-heading pf-${Z}`,q.textContent=K($.content,J),q}function v4($,J){return m0(B("span","pf-text"),K($.content,J))}function h4($,J){return m0(B("p","pf-p"),K($.content,J))}function $0($,J,Z,q){let U=document.createElement(Z);return U.className=q,U.textContent=K($.content,J),U}var g4=/^\s*(javascript|vbscript|data):/i;function u4($,J){let Z=document.createElement("a");if(Z.className="pf-link",Z.textContent=K($.content,J),$.href!=null){let q=K($.href,J);if(!g4.test(q))Z.href=q}if($.target!=null)Z.target=K($.target,J);return Z}function x4($,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 p4($,J){let Z=B("div","pf-markdown"),q=K($.content,J);return Z.innerHTML=M1(q),Z.setAttribute("data-markdown","true"),Z}var W1=/^\s*(javascript|vbscript|data):/i;function j0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function L0($){let J=j0($),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(W1.test(Q))return j0(U);return`<img src="${Q}" alt="${U}" />`}),J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,U,Q)=>{if(W1.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 M1($){let J=$.replace(/\r\n?/g,`
1
+ (()=>{var{defineProperty:y0,getOwnPropertyNames:e1,getOwnPropertyDescriptor:$4}=Object,Z4=Object.prototype.hasOwnProperty;function J4($){return this[$]}var q4=($)=>{var Z=(t0??=new WeakMap).get($),J;if(Z)return Z;if(Z=y0({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var q of e1($))if(!Z4.call(Z,q))y0(Z,q,{get:J4.bind($,q),enumerable:!(J=$4($,q))||J.enumerable})}return t0.set($,Z),Z},t0;var U4=($)=>$;function Q4($,Z){this[$]=U4.bind(null,Z)}var Y4=($,Z)=>{for(var J in Z)y0($,J,{get:Z[J],enumerable:!0,configurable:!0,set:Q4.bind(Z,J)})};var y2={};Y4(y2,{unregisterPipe:()=>Y0,registerPipe:()=>Q0,registerComponent:()=>G,listPipes:()=>N0,isIframe:()=>q0,createThemeToggle:()=>X0,applyHostTheme:()=>_0,app:()=>C0,PrefabRenderer:()=>p,DestroyRegistry:()=>W0,Bridge:()=>e});class U0{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return W4(this.data,$)}getAll(){return this.data}set($,Z){e0(this.data,$,Z),this.notify($)}toggle($){let Z=this.get($),J=Z==null||Z===!1||Z===0||Z==="";this.set($,J)}append($,Z,J){let q=this.get($);if(!Array.isArray(q)){this.set($,[Z]);return}if(J!==void 0)q.splice(J,0,Z);else q.push(Z);this.notify($)}pop($,Z){let J=this.get($);if(!Array.isArray(J))return;if(typeof Z==="number")J.splice(Z,1);else{let q=J.indexOf(Z);if(q>=0)J.splice(q,1)}this.notify($)}merge($){for(let[Z,J]of Object.entries($))e0(this.data,Z,J);for(let Z of Object.keys($))this.notify(Z)}subscribe($,Z){if(!this.subscribers.has($))this.subscribers.set($,new Set);return this.subscribers.get($)?.add(Z),()=>this.subscribers.get($)?.delete(Z)}subscribeAll($){return this.globalSubscribers.add($),()=>this.globalSubscribers.delete($)}notify($){this.generation++;let Z=$.split(".");for(let J=1;J<=Z.length;J++){let q=Z.slice(0,J).join("."),U=this.subscribers.get(q);if(U)U.forEach((Q)=>Q())}this.globalSubscribers.forEach((J)=>J())}}function W4($,Z){let J=Z.split("."),q=$;for(let U of J){if(q==null||typeof q!=="object")return;q=q[U]}return q}var H4=new Set(["__proto__","constructor","prototype"]);function e0($,Z,J){let q=Z.split(".");if(q.some((Q)=>H4.has(Q))){console.warn(`[prefab] Blocked prototype pollution attempt: ${Z}`);return}let U=$;for(let Q=0;Q<q.length-1;Q++){let Y=q[Q];if(U[Y]==null||typeof U[Y]!=="object")U[Y]={};U=U[Y]}U[q[q.length-1]]=J}var $0=new Map;function Q0($,Z){if($0.has($)&&$0.get($)!==Z)console.warn(`[prefab] pipe "${$}" re-registered`);$0.set($,Z)}function Y0($){return $0.delete($)}function N0(){return[...$0.keys()]}function $1($){return $0.get($)}var Z1=-1,b0=new Map,M4=/\{\{\s*(.+?)\s*\}\}/g;function g($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function u($,Z,J){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&K4(q,"{{")===1){let U=q.slice(2,-2).trim();return J1(U,Z,J)}return $.replace(M4,(U,Q)=>{let Y=J1(Q.trim(),Z,J);return Y==null?"":String(Y)})}function J1($,Z,J){let[q,...U]=B4($),Q=v(q.trim(),Z,J);for(let Y of U)Q=G4(Y.trim(),Q,Z,J);return Q}function v($,Z,J){let q=E4($);if(q>=0){let Y=$.slice(0,q).trim(),W=$.slice(q+1),H=N4(W);if(H>=0){let X=W.slice(0,H).trim(),N=W.slice(H+1).trim(),M=v(Y,Z,J);return M!==null&&M!==void 0&&M!==!1&&M!==0&&M!==""?v(X,Z,J):v(N,Z,J)}}let U=B0($,"||");if(U>=0){let Y=v($.slice(0,U).trim(),Z,J);return Y!==null&&Y!==void 0&&Y!==!1&&Y!==0&&Y!==""?Y:v($.slice(U+2).trim(),Z,J)}let Q=B0($,"&&");if(Q>=0){let Y=v($.slice(0,Q).trim(),Z,J);if(Y===null||Y===void 0||Y===!1||Y===0||Y==="")return Y;return v($.slice(Q+2).trim(),Z,J)}for(let[Y,W]of X4){let H=B0($,Y);if(H>=0){let X=v($.slice(0,H).trim(),Z,J),N=v($.slice(H+Y.length).trim(),Z,J);return W(X,N)}}if($.startsWith("!")){let Y=v($.slice(1).trim(),Z,J);return Y===null||Y===void 0||Y===!1||Y===0||Y===""}for(let[Y,W]of _4){let H=B0($,Y);if(H>=0){let X=v($.slice(0,H).trim(),Z,J),N=v($.slice(H+Y.length).trim(),Z,J);return W(Number(X),Number(N))}}if($==="true")return!0;if($==="false")return!1;if($==="null"||$==="undefined")return null;if(/^-?\d+(\.\d+)?$/.test($))return Number($);if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);if(J&&$.startsWith("$")){let Y=$.indexOf(".");if(Y>=0){let W=$.slice(0,Y),H=$.slice(Y+1),X=J[W];return K0(X,H)}return J[$]}if(J){let Y=$.split(".")[0];if(Y in J)return K0(J[Y],$.includes(".")?$.slice(Y.length+1):"")}return Z.get($)}function G4($,Z,J,q){let U=$.indexOf(":"),Q=U>=0?$.slice(0,U).trim():$,Y=U>=0?$.slice(U+1).trim():void 0,W=Y?m0(Y):void 0;switch(Q){case"find":{if(!Array.isArray(Z)||!Y)return;let H=q1(Y);if(H.length<2)return;let X=m0(H[0]),N=H[1].trim(),M;if(N.startsWith("'")&&N.endsWith("'")||N.startsWith('"')&&N.endsWith('"'))M=N.slice(1,-1);else if(J){if(q&&N.startsWith("$")){let K=N.indexOf(".");if(K>=0){let D=N.slice(0,K);if(D in q)M=K0(q[D],N.slice(K+1))}else if(N in q)M=q[N]}if(M===void 0&&!(q&&N.startsWith("$")))if(q){let K=N.split(".")[0];M=K in q?K0(q[K],N.includes(".")?N.slice(K.length+1):""):J.get(N)}else M=J.get(N)}else M=N;if(M==null)return;let B=J?.generation??0;if(B!==Z1)b0=new Map,Z1=B;let z=b0.get(Z);if(!z)z=new Map,b0.set(Z,z);let E=z.get(X);if(!E){E=new Map;for(let K of Z)if(K!=null&&typeof K==="object"){let D=K[X];if(D!=null)E.set(String(D),K)}z.set(X,E)}return E.get(String(M))}case"dot":{if(Z==null||typeof Z!=="object"||typeof W!=="string")return;return Z[W]}case"length":return Array.isArray(Z)?Z.length:typeof Z==="string"?Z.length:0;case"upper":return typeof Z==="string"?Z.toUpperCase():Z;case"lower":return typeof Z==="string"?Z.toLowerCase():Z;case"truncate":if(typeof Z==="string"&&typeof W==="number")return Z.slice(0,W);return Z;case"join":return Array.isArray(Z)?Z.join(typeof W==="string"?W:", "):Z;case"first":return Array.isArray(Z)?Z[0]:Z;case"last":return Array.isArray(Z)?Z[Z.length-1]:Z;case"abs":return Math.abs(Number(Z));case"round":return typeof W==="number"?Number(Number(Z).toFixed(W)):Math.round(Number(Z));case"number":return typeof W==="number"?Number(Number(Z).toFixed(W)):Number(Z);case"currency":{let H=typeof W==="string"?W:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:H}).format(Number(Z))}catch{return Z}}case"percent":return typeof W==="number"?`${(Number(Z)*100).toFixed(W)}%`:`${Math.round(Number(Z)*100)}%`;case"compact":{let H=typeof W==="number"?W:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:H}).format(Number(Z))}catch{return Z}}case"date":try{return new Date(Z).toLocaleDateString()}catch{return Z}case"time":try{return new Date(Z).toLocaleTimeString()}catch{return Z}case"datetime":try{return new Date(Z).toLocaleString()}catch{return Z}case"pluralize":{let H=Number(Z),X=typeof W==="string"?W:"";return H===1?X:`${X}s`}case"default":return Z==null||Z===""?W:Z;case"selectattr":return Array.isArray(Z)&&typeof W==="string"?Z.filter((H)=>H!=null&&typeof H==="object"&&Boolean(H[W])):Z;case"rejectattr":return Array.isArray(Z)&&typeof W==="string"?Z.filter((H)=>{if(H==null||typeof H!=="object")return!1;let X=H[W];return X==null||X===!1||X===0||X===""}):Z;default:{let H=$1(Q);if(H){let X=Y?q1(Y).map(m0):[];return H(Z,...X)}return Z}}}var X4=[["!==",($,Z)=>$!==Z],["===",($,Z)=>$===Z],["!=",($,Z)=>$!=Z],["==",($,Z)=>$==Z],[">=",($,Z)=>Number($)>=Number(Z)],["<=",($,Z)=>Number($)<=Number(Z)],[">",($,Z)=>Number($)>Number(Z)],["<",($,Z)=>Number($)<Number(Z)]],_4=[[" + ",($,Z)=>$+Z],[" - ",($,Z)=>$-Z],[" * ",($,Z)=>$*Z],[" / ",($,Z)=>Z!==0?$/Z:0],[" % ",($,Z)=>Z!==0?$%Z:0]];function B0($,Z){let J=null;for(let q=0;q<$.length;q++){let U=$[q];if(U==="'"||U==='"')J=J===U?null:J??U;if(!J&&$.slice(q,q+Z.length)===Z)return q}return-1}function E4($){let Z=0,J=null;for(let q=0;q<$.length;q++){let U=$[q];if(U==="'"||U==='"')J=J===U?null:J??U;if(!J){if(U==="(")Z++;else if(U===")")Z--;else if(U==="?"&&Z===0)return q}}return-1}function N4($){let Z=0,J=null;for(let q=0;q<$.length;q++){let U=$[q];if(U==="'"||U==='"')J=J===U?null:J??U;if(!J){if(U==="?"||U==="(")Z++;else if(U===")")Z--;else if(U===":"&&Z===0)return q}}return-1}function B4($){let Z=[],J="",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]==="|")J+="||",U++;else Z.push(J),J="";else J+=Q}return Z.push(J),Z}function m0($){let Z=$.replace(/^['"]|['"]$/g,"");if(Z==="true")return!0;if(Z==="false")return!1;let J=Number(Z);return isNaN(J)?Z:J}function q1($){let Z=[],J="",q=null;for(let U of $){if(U==="'"||U==='"')q=q===U?null:q??U;if(U===","&&!q)Z.push(J),J="";else J+=U}return Z.push(J),Z}function K0($,Z){if(!Z)return $;let J=Z.split("."),q=$;for(let U of J){if(q==null||typeof q!=="object")return;q=q[U]}return q}function K4($,Z){let J=0,q=0;while((q=$.indexOf(Z,q))!==-1)J++,q+=Z.length;return J}function F0($){return $.replace(/_([a-z])/g,(Z,J)=>J.toUpperCase())}function h0($){let Z={};for(let[J,q]of Object.entries($)){let U=J.startsWith("$")?J:F0(J);if(Array.isArray(q))Z[U]=q.map((Q)=>Q!=null&&typeof Q==="object"&&!Array.isArray(Q)?h0(Q):Q);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[U]=h0(q);else Z[U]=q}return Z}async function k($,Z){let J=Array.isArray($)?$:[$];for(let q of J)await F4(q,Z)}async function F4($,Z){let J=h0($),q=J.action;switch(q){case"setState":{z4(J,Z);return}case"toggleState":{D4(J,Z);return}case"appendState":{L4(J,Z);return}case"popState":{j4(J,Z);return}case"showToast":{O4(J,Z);return}case"closeOverlay":{T4(J,Z);return}case"openLink":{V4(J);return}case"setInterval":{R4(J,Z);return}case"toolCall":case"callTool":return I4(J,Z);case"sendMessage":return A4(J,Z);case"updateContext":{k4(J,Z);return}case"fetch":return f4(J,Z);case"openFilePicker":{S4(J,Z);return}case"callHandler":return w4(J,Z);case"requestDisplayMode":{C4(J,Z);return}case"subscribe":{m4(J,Z);return}case"unsubscribe":{h4(J);return}default:console.warn(`[prefab] Unknown action: ${q}`)}}function z4($,Z){let{key:J,value:q}=$;if(g(q))q=u(q,Z.store,Z.scope);Z.store.set(J,q),Z.rerender(),d($.onSuccess,Z)}function D4($,Z){Z.store.toggle($.key),Z.rerender()}function L4($,Z){let J=$.value??$.item;if(g(J))J=u(J,Z.store,Z.scope);Z.store.append($.key,J,$.index),Z.rerender()}function j4($,Z){Z.store.pop($.key,$.index),Z.rerender()}function O4($,Z){Z.onToast?.({message:D0($.message,Z),description:$.description!=null?D0($.description,Z):void 0,variant:$.variant,duration:$.duration})}function T4($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function V4($){if(typeof window<"u"){let Z=$.url;if(!Z){console.warn("[prefab] openLink: missing url");return}if(!W1(Z)){console.warn(`[prefab] Blocked unsafe URL scheme: ${Z}`);return}window.open(Z,$.target??"_blank")}}var z0=new Set,P4=20,U1=100;function R4($,Z){let J=Math.max($.intervalMs,U1),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(z0.size>=P4){console.warn("[prefab] Max intervals reached, ignoring new setInterval");return}let U=globalThis.setInterval(()=>void k(q,Z),J);z0.add(U)}function Q1(){for(let $ of z0)globalThis.clearInterval($);z0.clear()}async function I4($,Z){if(!Z.transport){console.warn("[prefab] No MCP transport configured for toolCall");return}let J=$.tool,q=v0($.arguments,Z);try{let U=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,U);Z.rerender(),await d($.onSuccess,Z,{$result:U})}catch(U){await d($.onError,Z,{$error:U})}}async function A4($,Z){if(!Z.transport){console.warn("[prefab] No MCP transport configured for sendMessage");return}await Z.transport.sendMessage(D0($.message,Z))}function k4($,Z){let J=$.context;if(J!=null)Z.store.merge(J),Z.rerender()}async function f4($,Z){let J=D0($.url,Z);if(!W1(J)){console.warn(`[prefab] Blocked unsafe URL in fetch: ${J}`);return}let q=$.method??"GET",U=$.headers,Q=$.body!==void 0?JSON.stringify($.body):void 0;try{let Y=await globalThis.fetch(J,{method:q,headers:{"Content-Type":"application/json",...U},...Q&&{body:Q}}),W=await Y.json().catch(()=>Y.text());if($.resultKey!=null)Z.store.set($.resultKey,W);Z.rerender(),await d($.onSuccess,Z,{$result:W})}catch(Y){await d($.onError,Z,{$error:Y})}}function S4($,Z){if(typeof document>"u")return;let J=document.createElement("input");if(J.type="file",$.accept!=null)J.accept=$.accept;if($.multiple===!0)J.multiple=!0;J.addEventListener("change",()=>{let q=Array.from(J.files??[]);if($.resultKey!=null)Z.store.set($.resultKey,q);Z.rerender(),d($.onSuccess,Z,{$result:q})}),J.click()}async function w4($,Z){let J=$.handler,q=v0($.arguments,Z);if(!Z.transport){console.warn(`[prefab] No transport configured for callHandler: ${J}`);return}try{let U=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,U);Z.rerender(),await d($.onSuccess,Z,{$result:U})}catch(U){await d($.onError,Z,{$error:U})}}function C4($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var n=new Map,y4=50,b4=2000;function m4($,Z){let{uri:J,stateKey:q}=$;if(!J||!q){console.warn("[prefab] subscribe: missing uri or stateKey");return}if(n.has(J))return;if(n.size>=y4){console.warn("[prefab] Max subscriptions reached, ignoring new subscribe");return}let U=(M)=>{Z.store.set(q,M),Z.rerender(),d($.onData,Z,{$data:M})};if(Z.transport?.subscribe&&Z.transport.capabilities?.subscriptions){let M=Z.transport.subscribe(J,U);n.set(J,M);return}let Q=$.fallbackTool,Y=$.fallbackInterval??b4;if(!Q){console.warn("[prefab] subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!Z.transport){console.warn("[prefab] No MCP transport configured for subscribe fallback");return}let W=$.fallbackArgs??{},H=Math.max(Y,U1),X=Z.transport,N=globalThis.setInterval(()=>{(async()=>{try{let M=v0(W,Z),B=await X.callTool(Q,M);U(B)}catch(M){d($.onError,Z,{$error:M})}})()},H);n.set(J,()=>globalThis.clearInterval(N))}function h4($){let Z=$.uri;if(!Z){console.warn("[prefab] unsubscribe: missing uri");return}let J=n.get(Z);if(J)J(),n.delete(Z)}function Y1(){for(let[$,Z]of n)try{Z()}catch(J){console.warn(`[prefab] Error cleaning up subscription '${$}':`,J)}n.clear()}var v4=/^\s*(javascript|vbscript|data):/i;function W1($){return!v4.test($)}function D0($,Z){if(g($)){let J=u($,Z.store,Z.scope);return J==null?"":String(J)}return $==null?"":String($)}function v0($,Z){if(!$)return{};let J={};for(let[q,U]of Object.entries($))J[q]=g(U)?u(U,Z.store,Z.scope):U;return J}async function d($,Z,J){if($==null)return;let q={...Z.scope,...J};await k($,{...Z,scope:q})}function u0($){let Z={};for(let[J,q]of Object.entries($)){let U=J.startsWith("$")?J:F0(J);if(Array.isArray(q))Z[U]=q.map((Q)=>Q!=null&&typeof Q==="object"&&!Array.isArray(Q)?u0(Q):Q);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[U]=u0(q);else Z[U]=q}return Z}class W0{callbacks=[];track($){this.callbacks.push($)}flush(){for(let $ of this.callbacks)try{$()}catch(Z){console.warn("[prefab] destroy callback error:",Z)}this.callbacks=[]}get size(){return this.callbacks.length}}function g4($){return typeof $==="object"&&"element"in $}var x0=new Map;function G($,Z){if(x0.has($))console.warn(`[prefab] overriding existing renderer for "${$}"`);x0.set($,Z)}function w($,Z){let J=u0($);if(Z.defs?.[J.type]){let Q={...Z.defs[J.type],...J,type:Z.defs[J.type].type};return w(Q,Z)}let q=x0.get(J.type),U;if(q){let Q=q(J,Z);if(g4(Q))U=Q.element,Z.destroyRegistry?.track(Q.destroy);else U=Q}else if(U=document.createElement("div"),U.setAttribute("data-prefab-type",J.type),J.children)for(let Q of J.children)U.appendChild(w(Q,Z));if(U instanceof HTMLElement){if(J.id)U.id=J.id;if(J.cssClass){let Q=F(J.cssClass,Z);if(Q)U.className=(U.className?U.className+" ":"")+Q}}if(J.onMount){let Q=J.onMount,Y=y(Z);queueMicrotask(()=>void k(Q,Y))}return U}function j($,Z,J){if(!$.children)return;a($.children,Z,J)}function a($,Z,J){let q=0;while(q<$.length){let U=$[q];if(U.type==="If")q=u4($,q,Z,J);else if(U.type==="Elif"||U.type==="Else")q++;else Z.appendChild(w(U,J)),q++}}function u4($,Z,J,q){let U=!1,Q=Z,Y=$[Q];if(H1(Y.condition,q))g0(Y,J,q),U=!0;Q++;while(Q<$.length){let W=$[Q];if(W.type==="Elif"){if(!U&&H1(W.condition,q))g0(W,J,q),U=!0;Q++}else if(W.type==="Else"){if(!U)g0(W,J,q);Q++;break}else break}return Q}function H1($,Z){if(!$)return!1;if(g($))return Boolean(u($,Z.store,Z.scope));return Boolean(Z.store.get($))}function g0($,Z,J){if(!$.children)return;a($.children,Z,J)}function F($,Z){if(g($)){let J=u($,Z.store,Z.scope);return J==null?"":String(J)}return $==null?"":String($)}function b($,Z){if(g($))return u($,Z.store,Z.scope);return $}function y($){return{store:$.store,transport:$.transport,scope:$.scope,rerender:$.rerender,onToast:$.onToast}}function _($,Z){let J=document.createElement($);if(Z)J.className=Z;return J}function p0($,Z){return $.textContent=Z,$}function _1(){G("Column",x4),G("Row",p4),G("Grid",M1),G("GridItem",G1),G("Container",c4),G("Div",X1),G("Span",l4),G("Dashboard",M1),G("DashboardItem",G1),G("Pages",d4),G("Page",X1),G("Detail",s4),G("MasterDetail",i4)}function x4($,Z){let J=_("div","pf-column");J.style.display="flex",J.style.flexDirection="column";let q=L0($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=E1($.align);if($.justify!=null)J.style.justifyContent=N1($.justify);return j($,J,Z),J}function p4($,Z){let J=_("div","pf-row");J.style.display="flex",J.style.flexDirection="row";let q=L0($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=E1($.align);if($.justify!=null)J.style.justifyContent=N1($.justify);if($.wrap===!0)J.style.flexWrap="wrap";return j($,J,Z),J}function M1($,Z){let J=_("div","pf-grid");J.style.display="grid";let q=$.columns??3;J.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let U=L0($);if(U!=null)J.style.gap=`${U*4}px`;return j($,J,Z),J}function G1($,Z){let J=_("div","pf-grid-item");if($.colSpan!=null)J.style.gridColumn=`span ${$.colSpan}`;if($.rowSpan!=null)J.style.gridRow=`span ${$.rowSpan}`;return j($,J,Z),J}function c4($,Z){let J=_("div","pf-container");if(J.style.maxWidth=$.maxWidth??"1200px",J.style.margin="0 auto",$.padding!=null)J.style.padding=`${$.padding*4}px`;return j($,J,Z),J}function X1($,Z){let J=_("div","pf-div");return j($,J,Z),J}function l4($,Z){let J=_("span","pf-span");return j($,J,Z),J}function d4($,Z){let J=_("div","pf-pages");return j($,J,Z),J}function s4($,Z){let J=_("div","pf-detail"),q=$.of!=null?b($.of,Z):void 0;if(q!=null&&q!==""&&q!==!1&&q!==0)j($,J,Z);else if($.empty!=null){let U=$.empty;J.appendChild(w(U,Z))}return J}function i4($,Z){let J=_("div","pf-master-detail");J.style.display="flex",J.style.flexDirection="row";let q=L0($);if(q!=null)J.style.gap=`${q*4}px`;let U=$.masterWidth??"33%",Q=$.children??[];if(Q.length>0){let Y=_("div","pf-master-detail-master");Y.style.width=U,Y.style.flexShrink="0",Y.style.overflow="auto",Y.appendChild(w(Q[0],Z)),J.appendChild(Y)}if(Q.length>1){let Y=_("div","pf-master-detail-detail");Y.style.flex="1",Y.style.overflow="auto",Y.appendChild(w(Q[1],Z)),J.appendChild(Y)}return J}var r4=/\bgap-(\d+)\b/;function L0($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let Z=r4.exec($.cssClass);if(Z)return Number(Z[1])}return null}function E1($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function N1($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}function K1(){G("Heading",n4),G("H1",($,Z)=>j0($,Z,"h1")),G("H2",($,Z)=>j0($,Z,"h2")),G("H3",($,Z)=>j0($,Z,"h3")),G("H4",($,Z)=>j0($,Z,"h4")),G("Text",a4),G("P",o4),G("Lead",($,Z)=>Z0($,Z,"p","pf-lead")),G("Large",($,Z)=>Z0($,Z,"span","pf-large")),G("Small",($,Z)=>Z0($,Z,"small","pf-small")),G("Muted",($,Z)=>Z0($,Z,"p","pf-muted")),G("BlockQuote",($,Z)=>Z0($,Z,"blockquote","pf-blockquote")),G("Label",($,Z)=>Z0($,Z,"label","pf-label")),G("Link",e4),G("Code",$8),G("Markdown",Z8),G("Kbd",J8)}function n4($,Z){let J=$.level??2,q=`h${Math.min(Math.max(J,1),6)}`,U=document.createElement(q);return U.className=`pf-heading pf-${q}`,U.textContent=F($.content,Z),U}function j0($,Z,J){let q=document.createElement(J);return q.className=`pf-heading pf-${J}`,q.textContent=F($.content,Z),q}function a4($,Z){return p0(_("span","pf-text"),F($.content,Z))}function o4($,Z){return p0(_("p","pf-p"),F($.content,Z))}function Z0($,Z,J,q){let U=document.createElement(J);return U.className=q,U.textContent=F($.content,Z),U}var t4=/^\s*(javascript|vbscript|data):/i;function e4($,Z){let J=document.createElement("a");if(J.className="pf-link",J.textContent=F($.content,Z),$.href!=null){let q=F($.href,Z);if(!t4.test(q))J.href=q}if($.target!=null)J.target=F($.target,Z);return J}function $8($,Z){let J=_("pre","pf-code"),q=_("code");if(q.textContent=F($.content,Z),$.language!=null)q.setAttribute("data-language",$.language);return J.appendChild(q),J}function Z8($,Z){let J=_("div","pf-markdown"),q=F($.content,Z);return J.innerHTML=F1(q),J.setAttribute("data-markdown","true"),J}var B1=/^\s*(javascript|vbscript|data):/i;function T0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function O0($){let Z=T0($),J=[];return Z=Z.replace(/`([^`]+)`/g,(q,U)=>{return J.push(`<code>${U}</code>`),`﷐CODE${J.length-1}﷐`}),Z=Z.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(q,U,Q)=>{if(B1.test(Q))return T0(U);return`<img src="${Q}" alt="${U}" />`}),Z=Z.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,U,Q)=>{if(B1.test(Q))return U;return`<a href="${Q}">${U}</a>`}),Z=Z.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),Z=Z.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),Z=Z.replace(/\*(.+?)\*/g,"<em>$1</em>"),Z=Z.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),Z=Z.replace(/~~(.+?)~~/g,"<del>$1</del>"),Z=Z.replace(/\uFDD0CODE(\d+)\uFDD0/g,(q,U)=>J[parseInt(U)]),Z}function F1($){let Z=$.replace(/\r\n?/g,`
2
2
  `).split(`
3
- `),Z=[],q=0;while(q<J.length){let U=J[q];if(U.trimStart().startsWith("```")){let W=U.trimStart().slice(3).trim(),H=[];q++;while(q<J.length&&!J[q].trimStart().startsWith("```"))H.push(j0(J[q])),q++;q++;let X=W?` data-language="${j0(W)}"`:"";Z.push(`<pre class="pf-code"><code${X}>${H.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 W=Q[1].length;Z.push(`<h${W}>${L0(Q[2])}</h${W}>`),q++;continue}if(U.startsWith("> ")||U===">"){let W=[];while(q<J.length&&(J[q].startsWith("> ")||J[q]===">"))W.push(J[q].replace(/^>\s?/,"")),q++;Z.push(`<blockquote>${M1(W.join(`
5
- `))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(U)){Z.push("<ul>");while(q<J.length&&/^[\s]*[-*+]\s+/.test(J[q]))Z.push(`<li>${L0(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>${L0(J[q].replace(/^[\s]*\d+\.\s+/,""))}</li>`),q++;Z.push("</ol>");continue}if(U.trim()===""){q++;continue}let Y=[];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]))Y.push(J[q]),q++;Z.push(`<p>${Y.map(L0).join("<br />")}</p>`)}return Z.join(`
6
- `)}function c4($,J){let Z=document.createElement("kbd");return Z.className="pf-kbd",Z.textContent=K($.content,J),Z}function B1(){M("Card",l4),M("CardHeader",v0("pf-card-header")),M("CardTitle",_1("pf-card-title","h3")),M("CardDescription",_1("pf-card-description","p")),M("CardContent",v0("pf-card-content")),M("CardFooter",v0("pf-card-footer"))}function l4($,J){let Z=B("div","pf-card");return Z.style.overflow="hidden",j($,Z,J),Z}function v0($){return(J,Z)=>{let q=B("div",$);return q.style.padding="16px 24px",j(J,q,Z),q}}function _1($,J){return(Z,q)=>{let U=document.createElement(J);return U.className=$,U.textContent=K(Z.content,q),U}}function N1(){M("DataTable",s4),M("Badge",i4),M("Dot",d4),M("Metric",r4),M("Ring",n4),M("Progress",a4),M("Separator",o4),M("Loader",t4),M("Icon",e4),M("Sparkline",$8)}function s4($,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),Y=$.rowKey,W=$.selected,H=document.createElement("thead"),X=document.createElement("tr");for(let _ of U){let z=document.createElement("th");z.className="pf-datatable-th",z.textContent=_.header??_.key,z.style.padding="8px 12px",z.style.textAlign="left",X.appendChild(z)}H.appendChild(X),q.appendChild(H);let G=document.createElement("tbody");if(Array.isArray(Q)){let _=W!=null?y(W,J):void 0;for(let z of Q){let D=document.createElement("tr");D.className="pf-datatable-row";let N=z;if(Y&&_!=null&&N[Y]!=null&&String(N[Y])===String(_))D.classList.add("pf-datatable-row-selected");if($.onRowClick!=null&&Y)D.style.cursor="pointer",D.addEventListener("click",()=>{let E={...J.scope,$item:N,$index:Q.indexOf(z)},L=b({...J,scope:E});k($.onRowClick,L)});for(let E of U){let L=document.createElement("td");L.className="pf-datatable-td";let T;if(E.accessor)T=y(`{{ $item.${E.accessor} }}`,{...J,scope:{...J.scope,$item:N}});else if(T=N[E.key],E.format&&T!=null)T=y(`{{ __fmtVal | ${E.format} }}`,{...J,scope:{...J.scope,__fmtVal:T}});L.textContent=T==null?"":String(T),L.style.padding="8px 12px",D.appendChild(L)}G.appendChild(D)}}if(q.appendChild(G),$.search===!0){let _=document.createElement("input");_.type="text",_.placeholder="Search...",_.className="pf-datatable-search",_.style.marginBottom="8px",_.style.padding="6px 12px",_.style.width="100%",_.style.boxSizing="border-box",_.addEventListener("input",()=>{let z=_.value.toLowerCase(),D=Array.from(G.querySelectorAll("tr"));for(let N of D){let E=(N.textContent??"").toLowerCase();N.style.display=E.includes(z)?"":"none"}}),Z.appendChild(_)}return Z.appendChild(q),Z}function i4($,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),J8(Z,q),Z}function d4($,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 r4($,J){let Z=B("div","pf-metric"),q=B("div","pf-metric-label");q.textContent=K($.label,J),q.style.fontSize="14px",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 Y=$.trend??"",W=$.trendSentiment??"neutral";if(Q.style.fontSize="14px",Q.style.color=W==="positive"?"green":W==="negative"?"red":"inherit",Y==="up")Q.textContent="↑ "+Q.textContent;else if(Y==="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",Z.appendChild(Q)}return Z}function n4($,J){let Z=B("div","pf-ring"),q=$.size??80,U=$.thickness??8,Q=Number(y($.value,J)??0),Y=Math.max(0,Math.min(100,Q)),W=(q-U)/2,H=2*Math.PI*W,X=H*(1-Y/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 _=document.createElementNS("http://www.w3.org/2000/svg","circle");_.setAttribute("cx",String(q/2)),_.setAttribute("cy",String(q/2)),_.setAttribute("r",String(W)),_.setAttribute("fill","none"),_.setAttribute("stroke","var(--muted, #e5e7eb)"),_.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(W)),z.setAttribute("fill","none"),z.setAttribute("stroke","var(--primary, #3b82f6)"),z.setAttribute("stroke-width",String(U)),z.setAttribute("stroke-dasharray",String(H)),z.setAttribute("stroke-dashoffset",String(X)),z.setAttribute("stroke-linecap","round"),z.style.transform="rotate(-90deg)",z.style.transformOrigin="center",G.appendChild(_),G.appendChild(z),Z.appendChild(G),$.label!=null){let D=B("div","pf-ring-label");D.textContent=K($.label,J),D.style.textAlign="center",D.style.fontSize="12px",Z.appendChild(D)}return Z}function a4($,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.borderRadius="4px",Z.style.overflow="hidden";let Y=B("div","pf-progress-fill");return Y.style.height="100%",Y.style.width=`${Q}%`,Y.style.borderRadius="4px",Y.style.transition="width 0.3s ease",Z.appendChild(Y),Z}function o4($,J){let Z=document.createElement("hr");return Z.className="pf-separator",Z.style.border="none",Z.style.margin="8px 0",Z}function t4($,J){let Z=B("div","pf-loader");return Z.textContent="⏳",Z.style.display="flex",Z.style.justifyContent="center",Z.style.padding="16px",Z}function e4($,J){let Z=B("span","pf-icon");return Z.setAttribute("data-icon",K($.name??$.content,J)),Z}function $8($,J){let Z=B("div","pf-sparkline"),q=$.data??[];if(q.length===0)return Z;let U=120,Q=32,Y=Math.max(...q),W=Math.min(...q),H=Y-W||1,X=document.createElementNS("http://www.w3.org/2000/svg","svg");X.setAttribute("width",String(U)),X.setAttribute("height",String(Q)),X.setAttribute("viewBox",`0 0 ${U} ${Q}`);let G=q.length>1?q.length-1:1,_=q.map((D,N)=>{let E=N/G*U,L=Q-(D-W)/H*(Q-4)-2;return`${E},${L}`}).join(" "),z=document.createElementNS("http://www.w3.org/2000/svg","polyline");return z.setAttribute("points",_),z.setAttribute("fill","none"),z.setAttribute("stroke","var(--primary, #3b82f6)"),z.setAttribute("stroke-width","1.5"),X.appendChild(z),Z.appendChild(X),Z}function J8($,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 G1(){M("Form",Z8),M("Input",q8),M("Textarea",U8),M("Button",Q8),M("ButtonGroup",Y8),M("Select",W8),M("SelectOption",H8),M("SelectGroup",P0("pf-select-group")),M("SelectLabel",W0("pf-select-label")),M("SelectSeparator",X1),M("Checkbox",M8),M("Switch",_8),M("Slider",B8),M("Radio",X8),M("RadioGroup",G8),M("Combobox",E8),M("ComboboxOption",z8),M("ComboboxGroup",P0("pf-combobox-group")),M("ComboboxLabel",W0("pf-combobox-label")),M("ComboboxSeparator",X1),M("Calendar",K8),M("DatePicker",D8),M("Field",P0("pf-field")),M("FieldTitle",W0("pf-field-title")),M("FieldDescription",W0("pf-field-description")),M("FieldContent",P0("pf-field-content")),M("FieldError",W0("pf-field-error")),M("ChoiceCard",F8)}function Z8($,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((Y,W)=>{Q[W]=Y}),J.store.merge(Q),$.onSubmit!=null){let Y=b(J);Y.scope={...J.scope,...Q},k($.onSubmit,Y)}}),j($,Z,J),Z}function q8($,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 h0(q),Z.appendChild(q),Z}function U8($,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 h0(q),Z.appendChild(q),Z}function Q8($,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),N8(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 Y8($,J){let Z=B("div","pf-button-group");return Z.style.display="flex",Z.style.gap="8px",j($,Z,J),Z}function W8($,J){let Z=B("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(h0(q),$.placeholder!=null){let Y=document.createElement("option");Y.value="",Y.textContent=K($.placeholder,J),Y.disabled=!0,Y.selected=!0,Y.hidden=!0,q.appendChild(Y)}let U=$.options;if(Array.isArray(U))for(let Y of U){let W=document.createElement("option");W.value=Y.value??"",W.textContent=Y.label??W.value,q.appendChild(W)}if($.children)for(let Y of $.children)if(Y.type==="SelectOption"){let W=document.createElement("option");W.value=Y.value??"",W.textContent=Y.label??W.value,q.appendChild(W)}else q.appendChild(w(Y,J));let Q=$.name;if(Q){let Y=J.store.get(Q);if(Y!=null)q.value=String(Y);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 H8($,J){return B("span")}function M8($,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 _8($,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 B8($,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 h0($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function N8($,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 P0($){return(J,Z)=>{let q=B("div",$);return j(J,q,Z),q}}function W0($){return(J,Z)=>{let q=B("span",$);return q.textContent=K(J.content,Z),q}}function X1(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function X8($,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 G8($,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 Y=Q.target;if(Y.type==="radio"){if(J.store.set(q,Y.value),$.onChange!=null)k($.onChange,b(J))}}),Z}function E8($,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.width="100%",q.style.boxSizing="border-box";let Y=B("div","pf-combobox-dropdown");if(Y.style.display="none",Y.style.position="absolute",Y.style.borderRadius="6px",Y.style.maxHeight="200px",Y.style.overflowY="auto",Y.style.zIndex="50",j($,Y,J),q.addEventListener("focus",()=>{Y.style.display="block"}),q.addEventListener("blur",()=>{setTimeout(()=>{Y.style.display="none"},150)}),$.searchable!==!1)q.addEventListener("input",()=>{let W=q.value.toLowerCase();for(let H of Array.from(Y.querySelectorAll(".pf-combobox-option"))){let X=(H.textContent??"").toLowerCase();H.style.display=X.includes(W)?"":"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(Y),Z}function z8($,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 K8($,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.addEventListener("change",()=>{if(J.store.set(q.name,q.value),$.onChange!=null)k($.onChange,b(J))}),Z.appendChild(q),Z}function D8($,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.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 F8($,J){let Z=B("div","pf-choice-card");if(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";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",Z.appendChild(q)}if(j($,Z,J),$.onClick!=null)Z.addEventListener("click",()=>{k($.onClick,b(J))});return Z}function E1(){M("Tabs",L8),M("Tab",j8),M("Accordion",P8),M("AccordionItem",O8),M("Dialog",T8),M("Popover",V8),M("Tooltip",I8),M("HoverCard",R8),M("Carousel",A8)}function L8($,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.marginBottom="12px";let U=[],Q=[];if($.children)for(let W=0;W<$.children.length;W++){let H=$.children[W],X=`pf-tab-${Math.random().toString(36).slice(2,8)}`,G=`pf-panel-${Math.random().toString(36).slice(2,8)}`,_=document.createElement("button");_.type="button",_.className="pf-tab-trigger",_.textContent=H.title??`Tab ${W+1}`,_.setAttribute("role","tab"),_.setAttribute("aria-selected",W===0?"true":"false"),_.setAttribute("aria-controls",G),_.id=X,_.tabIndex=W===0?0:-1,_.style.padding="8px 16px",_.style.border="none",_.style.background="none",_.style.cursor="pointer",_.style.borderBottom="2px solid transparent",_.style.marginBottom="-2px",_.style.fontSize="14px";let z=B("div","pf-tab-panel");if(z.style.display=W===0?"block":"none",z.setAttribute("role","tabpanel"),z.setAttribute("aria-labelledby",X),z.id=G,z.tabIndex=0,j(H,z,J),_.addEventListener("click",()=>{Y(W)}),W===0)_.classList.add("pf-tab-active"),_.style.fontWeight="600";Q.push(_),U.push(z),q.appendChild(_)}function Y(W){U.forEach((H)=>H.style.display="none"),Q.forEach((H)=>{H.style.borderBottomColor="transparent",H.style.fontWeight="normal",H.classList.remove("pf-tab-active"),H.setAttribute("aria-selected","false"),H.tabIndex=-1}),U[W].style.display="block",Q[W].classList.add("pf-tab-active"),Q[W].style.fontWeight="600",Q[W].setAttribute("aria-selected","true"),Q[W].tabIndex=0,Q[W].focus()}q.addEventListener("keydown",(W)=>{let H=Q.indexOf(W.target);if(H<0)return;let X;if(W.key==="ArrowRight")X=(H+1)%Q.length;else if(W.key==="ArrowLeft")X=(H-1+Q.length)%Q.length;else if(W.key==="Home")X=0;else if(W.key==="End")X=Q.length-1;else return;W.preventDefault(),Y(X)}),Z.appendChild(q);for(let W of U)Z.appendChild(W);return Z}function j8($,J){let Z=B("div","pf-tab");return j($,Z,J),Z}function P8($,J){let Z=B("div","pf-accordion");return j($,Z,J),Z}function O8($,J){let Z=B("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=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 Y=Q.style.display!=="none";Q.style.display=Y?"none":"block",U.setAttribute("aria-expanded",Y?"false":"true")}),Z.appendChild(U),Z.appendChild(Q),Z}function T8($,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.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.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 V8($,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.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 I8($,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.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 R8($,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.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 A8($,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,Y=document.createElement("button");Y.type="button",Y.textContent="‹",Y.className="pf-carousel-prev",Y.setAttribute("aria-label","Previous slide"),Y.style.position="absolute",Y.style.left="4px",Y.style.top="50%",Y.style.transform="translateY(-50%)",Y.style.zIndex="10";let W=document.createElement("button");W.type="button",W.textContent="›",W.className="pf-carousel-next",W.setAttribute("aria-label","Next slide"),W.style.position="absolute",W.style.right="4px",W.style.top="50%",W.style.transform="translateY(-50%)",W.style.zIndex="10";let H=()=>{q.style.transform=`translateX(-${U*100}%)`};return Y.addEventListener("click",()=>{if(Q===0)return;U=Math.max(0,U-1),H()}),W.addEventListener("click",()=>{if(Q===0)return;U=Math.min(Q-1,U+1),H()}),Z.appendChild(q),Z.appendChild(Y),Z.appendChild(W),Z}function z1(){M("ForEach",k8),M("If",K1),M("Elif",f8),M("Else",S8),M("Condition",w8),M("Define",C8),M("Use",b8),M("Slot",y8)}function k8($,J){let Z=document.createDocumentFragment(),q=$.expression;if(!q)return Z;let U;if(g(q)){let Y=u(q,J.store,J.scope);U=Array.isArray(Y)?Y:[]}else{let Y=J.store.get(q);U=Array.isArray(Y)?Y:[]}let Q=$.let??{};for(let Y=0;Y<U.length;Y++){let W=U[Y],H={...J.scope,$item:W,$index:Y,...Q},X={...J,scope:H};if($.children)n($.children,Z,X)}return Z}function K1($,J){if(D1($.condition,J)){let q=document.createDocumentFragment();if($.children)n($.children,q,J);return q}return document.createDocumentFragment()}function f8($,J){return K1($,J)}function S8($,J){let Z=document.createDocumentFragment();if($.children)n($.children,Z,J);return Z}function D1($,J){if(!$)return!1;if(g($))return Boolean(u($,J.store,J.scope));return Boolean(J.store.get($))}function w8($,J){let Z=document.createDocumentFragment(),q=$.cases,U=$.else;if(q){for(let Q of q)if(D1(Q.when,J)){if(Q.children)n(Q.children,Z,J);return Z}}if(U)n(U,Z,J);return Z}function C8($,J){let Z=$.name;if(Z&&$.children)J.templates=J.templates??{},J.templates[Z]=$.children;return document.createDocumentFragment()}function b8($,J){let Z=document.createDocumentFragment(),q=$.def??$.name,U=J.templates?.[q];if(!U)return Z;let Q=$.overrides??{},Y={...J.scope,...Q},W={...J,scope:Y};for(let H of U)Z.appendChild(w(H,W));return Z}function y8($,J){let Z=document.createDocumentFragment(),q=$.name??"default",Q=J.slots?.[q]??$.children;if(Q)for(let Y of Q)Z.appendChild(w(Y,J));return Z}function F1(){M("Alert",m8),M("AlertTitle",v8),M("AlertDescription",h8)}function m8($,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",$.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 v8($,J){let Z=B("h5","pf-alert-title");return Z.textContent=K($.content,J),Z.style.fontWeight="600",Z.style.marginBottom="4px",Z}function h8($,J){let Z=B("p","pf-alert-description");return Z.textContent=K($.content,J),Z.style.fontSize="14px",Z}function L1(){M("Image",g8),M("Audio",u8),M("Video",x8),M("Embed",p8),M("Svg",l8),M("DropZone",s8),M("Mermaid",i8)}function g8($,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 u8($,J){let Z=document.createElement("audio");return Z.className="pf-audio",Z.src=K($.src,J),Z.controls=!0,Z}function x8($,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 p8($,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 c8=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 l8($,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 j1(Q),Z.appendChild(document.importNode(Q,!0)),Z}function j1($){let J=Array.from($.children);for(let Z of J){if(!c8.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)}j1(Z)}}function s8($,J){let Z=B("div","pf-dropzone");return 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.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 i8($,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 T0=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function V0($,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 H0($,J,Z,q,U){let{tooltip:Q,svgEl:Y,wrapper:W}=$;if(U.length===0)return;let H="";if(q)H+=`<div class="pf-chart-tooltip-label">${O0(q)}</div>`;for(let L of U)H+='<div class="pf-chart-tooltip-row">',H+=`<span class="pf-chart-tooltip-dot" style="background:${O0(L.color)}"></span>`,H+=`<span>${O0(L.label)}:</span> <strong>${O0(String(L.value))}</strong>`,H+="</div>";Q.innerHTML=H;let X=Y.getBoundingClientRect(),G=W.getBoundingClientRect(),_=Y.viewBox.baseVal,z=X.width/(_.width||1),D=X.left-G.left+J*z,N=Q.offsetWidth||100,E=D+12;if(E+N>G.width)E=D-N-12;Q.style.left=`${Math.max(0,E)}px`,Q.style.top="4px",Q.classList.add("pf-visible")}function O0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function P1($,J,Z,q,U,Q,Y,W){let H=U.plotWidth/Z.length;for(let X=0;X<Z.length;X++){let G=U.plotLeft+X*H,_=document.createElementNS("http://www.w3.org/2000/svg","rect");_.setAttribute("x",String(G)),_.setAttribute("y",String(U.plotTop)),_.setAttribute("width",String(H)),_.setAttribute("height",String(U.plotHeight)),_.setAttribute("fill","transparent"),_.style.cursor="default";let z=Q?Z[X][Q]:void 0,D=z!=null?W?W(z):String(z):void 0,N=q.map((A,R)=>({label:A.label??A.dataKey,value:Y(Z[X][A.dataKey],A,R),color:A.color??T0[R%T0.length]})),E=G+H/2,L=()=>H0($,E,U.plotTop,D,N),T=()=>$.tooltip.classList.remove("pf-visible");_.addEventListener("mouseenter",L),_.addEventListener("mouseleave",T),_.addEventListener("touchstart",L,{passive:!0}),_.addEventListener("touchend",T,{passive:!0}),J.appendChild(_)}}function O1($,J,Z,q,U,Q,Y,W,H,X){let G=Z.length===1?U.plotWidth:U.plotWidth/(Z.length-1);for(let _=0;_<Z.length;_++){let z=Z.length===1?(U.plotLeft+U.plotRight)/2:U.plotLeft+_/(Z.length-1)*U.plotWidth,D=Z.length===1?U.plotLeft:z-G/2,N=Z.length===1?U.plotWidth:G,E=document.createElementNS("http://www.w3.org/2000/svg","rect");E.setAttribute("x",String(Math.max(U.plotLeft,D))),E.setAttribute("y",String(U.plotTop)),E.setAttribute("width",String(Math.min(N,U.plotRight-Math.max(U.plotLeft,D)))),E.setAttribute("height",String(U.plotHeight)),E.setAttribute("fill","transparent"),E.style.cursor="default";let L=Q?Z[_][Q]:void 0,T=L!=null?X?X(L):String(L):void 0,A=q.map((P,C)=>({label:P.label??P.dataKey,value:Y(Z[_][P.dataKey],P,C),color:P.color??T0[C%T0.length]})),R=()=>{if(H0($,z,U.plotTop,T,A),W)W.setAttribute("x1",String(z)),W.setAttribute("x2",String(z)),W.setAttribute("opacity","1");if(H)for(let P of H){for(let C of P)C.setAttribute("data-visible","false");P[_]?.setAttribute("data-visible","true")}},F=()=>{if($.tooltip.classList.remove("pf-visible"),W)W.setAttribute("opacity","0");if(H)for(let P of H)for(let C of P)C.setAttribute("data-visible","false")};E.addEventListener("mouseenter",R),E.addEventListener("mouseleave",F),E.addEventListener("touchstart",R,{passive:!0}),E.addEventListener("touchend",F,{passive:!0}),J.appendChild(E)}}function V1(){M("BarChart",r8),M("LineChart",T1),M("AreaChart",T1),M("PieChart",n8),M("RadarChart",g0),M("ScatterChart",g0),M("RadialChart",g0),M("Histogram",a8)}var s=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],M0="var(--muted-foreground, #6b7280)",d8="var(--border, #e5e7eb)",u0="10";function I1($,J,Z,q=!1){let U=Z?44:0,Q=$-(q?44:0),Y=10,W=J-24;return{plotLeft:U,plotRight:Q,plotTop:10,plotBottom:W,plotWidth:Q-U,plotHeight:W-10}}function R1($,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,Y=[];for(let W=0;W<=$+Q*0.01;W+=Q)Y.push(Math.round(W*1000)/1000);return Y}function A1($,J,Z,q,U){let Q=R1(Z);for(let Y of Q){let W=J.plotBottom-(Z>0?Y/Z*J.plotHeight:0),H=document.createElementNS("http://www.w3.org/2000/svg","text");if(H.setAttribute("x",String(J.plotLeft-6)),H.setAttribute("y",String(W+3)),H.setAttribute("text-anchor","end"),H.setAttribute("font-size",u0),H.setAttribute("fill",M0),H.textContent=x0(Y,U),$.appendChild(H),q&&Y>0){let X=document.createElementNS("http://www.w3.org/2000/svg","line");X.setAttribute("x1",String(J.plotLeft)),X.setAttribute("y1",String(W)),X.setAttribute("x2",String(J.plotRight)),X.setAttribute("y2",String(W)),X.setAttribute("stroke",d8),X.setAttribute("stroke-width","1"),X.setAttribute("stroke-dasharray","4 3"),$.appendChild(X)}}}function k1($,J,Z,q){let U=R1(Z);for(let Q of U){let Y=J.plotBottom-(Z>0?Q/Z*J.plotHeight:0),W=document.createElementNS("http://www.w3.org/2000/svg","text");W.setAttribute("x",String(J.plotRight+6)),W.setAttribute("y",String(Y+3)),W.setAttribute("text-anchor","start"),W.setAttribute("font-size",u0),W.setAttribute("fill",M0),W.textContent=x0(Q,q),$.appendChild(W)}}function f1($,J,Z,q,U,Q){for(let Y=0;Y<J.length;Y++){let W=document.createElementNS("http://www.w3.org/2000/svg","text");W.setAttribute("x",String(q(Y))),W.setAttribute("y",String(U+14)),W.setAttribute("text-anchor","middle"),W.setAttribute("font-size",u0),W.setAttribute("fill",M0);let H=J[Y][Z];W.textContent=H==null?"":Q?Q(H):String(H),$.appendChild(W)}}function S1($,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",M0),Z.setAttribute("stroke-width","1"),$.appendChild(Z)}function J0($,J,Z){if($==null)return"";let q=y(`{{ __v | ${J} }}`,{...Z,scope:{...Z.scope,__v:$}});return q==null?String($):String(q)}function x0($,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 w1($,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 x0(Number(q),Q)}}function r8($,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 Y=$.showYAxis!==!1,W=$.showGrid===!0,H=$.showYAxisRight===!0,X=$.showTooltip!==!1,G=$.xAxis,_=$.tooltipXKey,z=$.xAxisFormat,D=$.tooltipXFormat,N=U.filter((I)=>I.yAxisId!=="right"),E=U.filter((I)=>I.yAxisId==="right"),L=H&&E.length>0,T=N.length>0?Math.max(...q.flatMap((I)=>N.map((V)=>Number(I[V.dataKey]??0))),1):1,A=L?Math.max(...q.flatMap((I)=>E.map((V)=>Number(I[V.dataKey]??0))),1):1,R=400,F=I1(R,Q,Y,L),P=I0(R,Q,"Bar");if(Y)A1(P,F,T,W,$.yAxisFormat);if(L)k1(P,F,A,$.yAxisRightFormat);S1(P,F);let C=F.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:T,c=Number(x),l=Math.max(0,c/m*F.plotHeight),a=F.plotLeft+I*C+V*i+i/2,O=document.createElementNS("http://www.w3.org/2000/svg","rect");O.setAttribute("x",String(a)),O.setAttribute("y",String(F.plotBottom-l)),O.setAttribute("width",String(i*0.8)),O.setAttribute("height",String(l)),O.setAttribute("fill",f.color??s[V%s.length]),O.setAttribute("rx","2"),P.appendChild(O)}if(G){let I=z?(V)=>J0(V,z,J):void 0;f1(P,q,G,(V)=>{return F.plotLeft+V*C+C/2},F.plotBottom,I)}if(X){let I=V0(Z,P),V=w1(J,$.yAxisFormat,$.yAxisRightFormat);P1(I,P,q,U,F,_??G,V,D?(x)=>J0(x,D,J):void 0)}return p0(Z,U,$.showLegend),Z.appendChild(P),Z}function T1($,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 Y=$.showYAxis!==!1,W=$.showGrid===!0,H=$.showYAxisRight===!0,X=$.showTooltip!==!1,G=$.xAxis,_=$.tooltipXKey,z=$.xAxisFormat,D=$.tooltipXFormat,N=U.filter((V)=>V.yAxisId!=="right"),E=U.filter((V)=>V.yAxisId==="right"),L=H&&E.length>0,T=N.length>0?Math.max(...q.flatMap((V)=>N.map((f)=>Number(V[f.dataKey]??0))),1):1,A=L?Math.max(...q.flatMap((V)=>E.map((f)=>Number(V[f.dataKey]??0))),1):1,R=400,F=I1(R,Q,Y,L),P=I0(R,Q,$.type==="AreaChart"?"Area":"Line"),C=$.type==="AreaChart";if(Y)A1(P,F,T,W,$.yAxisFormat);if(L)k1(P,F,A,$.yAxisRightFormat);S1(P,F);let i=[];for(let V=0;V<U.length;V++){let f=U[V],x=f.yAxisId==="right",d=x?A:T,m=f.color??s[V%s.length],c=q.map((O,S)=>{let v=O[f.dataKey],o=v===null||v===void 0,N0=q.length===1?(F.plotLeft+F.plotRight)/2:F.plotLeft+S/(q.length-1)*F.plotWidth,p1=o?F.plotBottom:F.plotBottom-Number(v)/d*F.plotHeight;return{x:N0,y:p1,isNull:o}});if(C){let O=[],S=()=>{if(O.length<2){O=[];return}let v=`M ${O[0].x},${F.plotBottom} `+O.map((N0)=>`L ${N0.x},${N0.y}`).join(" ")+` L ${O[O.length-1].x},${F.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"),P.appendChild(o),O=[]};for(let v of c){if(v.isNull){S();continue}O.push(v)}S()}let l="";for(let O of c){if(O.isNull)continue;let S=c.indexOf(O),v=S===0||c[S-1].isNull;l+=`${v?"M":"L"} ${O.x},${O.y} `}if(l){let O=document.createElementNS("http://www.w3.org/2000/svg","path");if(O.setAttribute("d",l.trim()),O.setAttribute("fill","none"),O.setAttribute("stroke",m),O.setAttribute("stroke-width","2"),x)O.setAttribute("stroke-dasharray","6 3");P.appendChild(O)}let a=[];for(let O of c){let S=document.createElementNS("http://www.w3.org/2000/svg","circle");if(S.setAttribute("cx",String(O.x)),S.setAttribute("cy",String(O.y)),S.setAttribute("r","4"),S.setAttribute("fill",m),S.setAttribute("class","pf-data-dot"),S.setAttribute("data-visible","false"),S.style.pointerEvents="none",O.isNull)S.style.display="none";P.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(F.plotLeft)),I.setAttribute("x2",String(F.plotLeft)),I.setAttribute("y1",String(F.plotTop)),I.setAttribute("y2",String(F.plotBottom)),I.setAttribute("stroke",M0),I.setAttribute("stroke-width","1"),I.setAttribute("stroke-dasharray","3 3"),I.setAttribute("opacity","0"),P.appendChild(I),G){let V=z?(f)=>J0(f,z,J):void 0;f1(P,q,G,(f)=>{return q.length===1?(F.plotLeft+F.plotRight)/2:F.plotLeft+f/(q.length-1)*F.plotWidth},F.plotBottom,V)}if(X){let V=V0(Z,P),f=w1(J,$.yAxisFormat,$.yAxisRightFormat);O1(V,P,q,U,F,_??G,f,I,i,D?(d)=>J0(d,D,J):void 0)}return p0(Z,U,$.showLegend),Z.appendChild(P),Z}function n8($,J){let Z=B("div","pf-chart pf-pie-chart"),q=y($.data,J)??[],U=$.series??[],Q=$.height??300,Y=Math.min(Q,300),W=$.showTooltip!==!1;if(q.length===0||U.length===0)return Z.textContent="No chart data",Z;let H=I0(Y,Y,"Pie"),X=Y/2,G=Y/2,_=Y/2-10,z=U[0].dataKey,D=$.xAxis,N=$.tooltipXKey,E=$.tooltipXFormat,L=q.map((F)=>Number(F[z]??0)),T=L.reduce((F,P)=>F+P,0);if(T===0)return Z.textContent="No chart data",Z.appendChild(H),Z;let A=W?V0(Z,H):void 0,R=-Math.PI/2;for(let F=0;F<L.length;F++){let P=L[F]/T*2*Math.PI,C=R+P,i=P>Math.PI?1:0,I=X+_*Math.cos(R),V=G+_*Math.sin(R),f=X+_*Math.cos(C),x=G+_*Math.sin(C),d=s[F%s.length],m=document.createElementNS("http://www.w3.org/2000/svg","path");if(m.setAttribute("d",`M ${X},${G} L ${I},${V} A ${_},${_} 0 ${i} 1 ${f},${x} Z`),m.setAttribute("fill",d),m.style.cursor="default",A){let c=N??D,l=c?q[F][c]:void 0,a=l!=null?E?J0(l,E,J):String(l):`Slice ${F+1}`,O=`${(L[F]/T*100).toFixed(1)}%`,S=R+P/2,v=X+_*0.6*Math.cos(S);m.addEventListener("mouseenter",()=>{H0(A,v,G,a,[{label:U[0].label??z,value:`${L[F]} (${O})`,color:d}])}),m.addEventListener("mouseleave",()=>{A.tooltip.classList.remove("pf-visible")}),m.addEventListener("touchstart",()=>{H0(A,v,G,a,[{label:U[0].label??z,value:`${L[F]} (${O})`,color:d}])},{passive:!0}),m.addEventListener("touchend",()=>{A.tooltip.classList.remove("pf-visible")},{passive:!0})}H.appendChild(m),R=C}return p0(Z,U,$.showLegend),Z.appendChild(H),Z}function g0($,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}function I0($,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 p0($,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 Y=B("span");Y.style.width="8px",Y.style.height="8px",Y.style.borderRadius="50%",Y.style.backgroundColor=J[U].color??s[U%s.length];let W=B("span");W.textContent=J[U].label??J[U].dataKey,Q.appendChild(Y),Q.appendChild(W),q.appendChild(Q)}$.appendChild(q)}function a8($,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,Y=$.height??200,W=$.color??s[0],H=Math.min(...U),G=(Math.max(...U)-H)/Q||1,_=Array(Q).fill(0);for(let T of U){let A=Math.min(Math.floor((T-H)/G),Q-1);_[A]++}let z=Math.max(..._),D=300,N=Y,E=D/Q,L=I0(D,N,"Histogram");for(let T=0;T<Q;T++){let A=z>0?_[T]/z*N:0,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(T*E)),R.setAttribute("y",String(N-A)),R.setAttribute("width",String(E-1)),R.setAttribute("height",String(A)),R.setAttribute("fill",W),L.appendChild(R)}return Z.appendChild(L),Z}function C1(){M("Table",o8),M("TableHead",c0("thead")),M("TableBody",c0("tbody")),M("TableFooter",c0("tfoot")),M("TableRow",t8),M("TableHeader",e8),M("TableCell",$2),M("TableCaption",J2),M("ExpandableRow",Z2)}function o8($,J){let Z=document.createElement("table");return Z.className="pf-table",Z.style.width="100%",Z.style.borderCollapse="collapse",j($,Z,J),Z}function c0($){return(J,Z)=>{let q=document.createElement($);return q.className=`pf-${$}`,j(J,q,Z),q}}function t8($,J){let Z=document.createElement("tr");return Z.className="pf-table-row",j($,Z,J),Z}function e8($,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=K($.content,J),Z}function $2($,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 J2($,J){let Z=document.createElement("caption");return Z.className="pf-table-caption",Z.style.padding="8px",Z.style.fontSize="14px",Z.textContent=K($.content,J),Z}function Z2($,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 H of Q)q.appendChild(w(H,J));let Y=B("div","pf-expandable-row-detail");Y.style.display="none",Y.style.paddingLeft="24px",j($,Y,J);let W=!1;return q.addEventListener("click",()=>{W=!W,Y.style.display=W?"block":"none",U.style.transform=W?"rotate(90deg)":""}),Z.appendChild(q),Z.appendChild(Y),Z}var b1=!1;function R0(){if(b1)return;b1=!0,U1(),H1(),B1(),N1(),G1(),E1(),z1(),F1(),L1(),V1(),C1()}function y1($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function m1($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function u1($,J){if(!J)return;if(J.light)for(let[Z,q]of Object.entries(J.light))$.style.setProperty(`--${y1(Z)}`,m1(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,Y])=>` --${y1(Q)}: ${m1(Y)};`).join(`
3
+ `),J=[],q=0;while(q<Z.length){let U=Z[q];if(U.trimStart().startsWith("```")){let W=U.trimStart().slice(3).trim(),H=[];q++;while(q<Z.length&&!Z[q].trimStart().startsWith("```"))H.push(T0(Z[q])),q++;q++;let X=W?` data-language="${T0(W)}"`:"";J.push(`<pre class="pf-code"><code${X}>${H.join(`
4
+ `)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(U)){J.push("<hr />"),q++;continue}let Q=/^(#{1,6})\s+(.+)$/.exec(U);if(Q){let W=Q[1].length;J.push(`<h${W}>${O0(Q[2])}</h${W}>`),q++;continue}if(U.startsWith("> ")||U===">"){let W=[];while(q<Z.length&&(Z[q].startsWith("> ")||Z[q]===">"))W.push(Z[q].replace(/^>\s?/,"")),q++;J.push(`<blockquote>${F1(W.join(`
5
+ `))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(U)){J.push("<ul>");while(q<Z.length&&/^[\s]*[-*+]\s+/.test(Z[q]))J.push(`<li>${O0(Z[q].replace(/^[\s]*[-*+]\s+/,""))}</li>`),q++;J.push("</ul>");continue}if(/^[\s]*\d+\.\s+/.test(U)){J.push("<ol>");while(q<Z.length&&/^[\s]*\d+\.\s+/.test(Z[q]))J.push(`<li>${O0(Z[q].replace(/^[\s]*\d+\.\s+/,""))}</li>`),q++;J.push("</ol>");continue}if(U.trim()===""){q++;continue}let Y=[];while(q<Z.length&&Z[q].trim()!==""&&!/^#{1,6}\s/.test(Z[q])&&!/^[-*+]\s/.test(Z[q])&&!/^\d+\.\s/.test(Z[q])&&!Z[q].startsWith("> ")&&!Z[q].trimStart().startsWith("```")&&!/^(\s*[-*_]\s*){3,}$/.test(Z[q]))Y.push(Z[q]),q++;J.push(`<p>${Y.map(O0).join("<br />")}</p>`)}return J.join(`
6
+ `)}function J8($,Z){let J=document.createElement("kbd");return J.className="pf-kbd",J.textContent=F($.content,Z),J}function D1(){G("Card",q8),G("CardHeader",c0("pf-card-header")),G("CardTitle",z1("pf-card-title","h3")),G("CardDescription",z1("pf-card-description","p")),G("CardContent",c0("pf-card-content")),G("CardFooter",c0("pf-card-footer"))}function q8($,Z){let J=_("div","pf-card");return J.style.overflow="hidden",j($,J,Z),J}function c0($){return(Z,J)=>{let q=_("div",$);return q.style.padding="16px 24px",j(Z,q,J),q}}function z1($,Z){return(J,q)=>{let U=document.createElement(Z);return U.className=$,U.textContent=F(J.content,q),U}}function L1(){G("DataTable",U8),G("Badge",Q8),G("Dot",Y8),G("Metric",W8),G("Ring",H8),G("Progress",M8),G("Separator",G8),G("Loader",X8),G("Icon",_8),G("Sparkline",E8)}function U8($,Z){let J=_("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,Z),Y=$.rowKey,W=$.selected,H=document.createElement("thead"),X=document.createElement("tr");for(let M of U){let B=document.createElement("th");B.className="pf-datatable-th",B.textContent=M.header??M.key,B.style.padding="8px 12px",B.style.textAlign="left",X.appendChild(B)}H.appendChild(X),q.appendChild(H);let N=document.createElement("tbody");if(Array.isArray(Q)){let M=W!=null?b(W,Z):void 0;for(let B of Q){let z=document.createElement("tr");z.className="pf-datatable-row";let E=B;if(Y&&M!=null&&E[Y]!=null&&String(E[Y])===String(M))z.classList.add("pf-datatable-row-selected");if($.onRowClick!=null&&Y)z.style.cursor="pointer",z.addEventListener("click",()=>{let K={...Z.scope,$item:E,$index:Q.indexOf(B)},D=y({...Z,scope:K});k($.onRowClick,D)});for(let K of U){let D=document.createElement("td");D.className="pf-datatable-td";let O;if(K.accessor)O=b(`{{ $item.${K.accessor} }}`,{...Z,scope:{...Z.scope,$item:E}});else if(O=E[K.key],K.format&&O!=null)O=b(`{{ __fmtVal | ${K.format} }}`,{...Z,scope:{...Z.scope,__fmtVal:O}});D.textContent=O==null?"":String(O),D.style.padding="8px 12px",z.appendChild(D)}N.appendChild(z)}}if(q.appendChild(N),$.search===!0){let M=document.createElement("input");M.type="text",M.placeholder="Search...",M.className="pf-datatable-search",M.style.marginBottom="8px",M.style.padding="6px 12px",M.style.width="100%",M.style.boxSizing="border-box",M.addEventListener("input",()=>{let B=M.value.toLowerCase(),z=Array.from(N.querySelectorAll("tr"));for(let E of z){let K=(E.textContent??"").toLowerCase();E.style.display=K.includes(B)?"":"none"}}),J.appendChild(M)}return J.appendChild(q),J}function Q8($,Z){let J=_("span","pf-badge"),q=$.variant??"default";return J.setAttribute("data-variant",q),J.style.alignItems="center",J.style.padding="2px 10px",J.style.borderRadius="9999px",J.style.fontSize="12px",J.style.fontWeight="500",J.textContent=F($.label??$.content,Z),N8(J,q),J}function Y8($,Z){let J=_("span","pf-dot"),q=$.color??"gray";return J.style.display="inline-block",J.style.width="8px",J.style.height="8px",J.style.borderRadius="50%",J.style.backgroundColor=q,J}function W8($,Z){let J=_("div","pf-metric"),q=_("div","pf-metric-label");q.textContent=F($.label,Z),q.style.fontSize="14px",J.appendChild(q);let U=_("div","pf-metric-value");if(U.textContent=F($.value,Z),U.style.fontSize="28px",U.style.fontWeight="700",J.appendChild(U),$.delta!=null){let Q=_("span","pf-metric-delta");Q.textContent=F($.delta,Z);let Y=$.trend??"",W=$.trendSentiment??"neutral";if(Q.style.fontSize="14px",Q.style.color=W==="positive"?"green":W==="negative"?"red":"inherit",Y==="up")Q.textContent="↑ "+Q.textContent;else if(Y==="down")Q.textContent="↓ "+Q.textContent;J.appendChild(Q)}if($.description!=null){let Q=_("div","pf-metric-desc");Q.textContent=F($.description,Z),Q.style.fontSize="12px",J.appendChild(Q)}return J}function H8($,Z){let J=_("div","pf-ring"),q=$.size??80,U=$.thickness??8,Q=Number(b($.value,Z)??0),Y=Math.max(0,Math.min(100,Q)),W=(q-U)/2,H=2*Math.PI*W,X=H*(1-Y/100),N=document.createElementNS("http://www.w3.org/2000/svg","svg");N.setAttribute("width",String(q)),N.setAttribute("height",String(q)),N.setAttribute("viewBox",`0 0 ${q} ${q}`);let M=document.createElementNS("http://www.w3.org/2000/svg","circle");M.setAttribute("cx",String(q/2)),M.setAttribute("cy",String(q/2)),M.setAttribute("r",String(W)),M.setAttribute("fill","none"),M.setAttribute("stroke","var(--muted, #e5e7eb)"),M.setAttribute("stroke-width",String(U));let B=document.createElementNS("http://www.w3.org/2000/svg","circle");if(B.setAttribute("cx",String(q/2)),B.setAttribute("cy",String(q/2)),B.setAttribute("r",String(W)),B.setAttribute("fill","none"),B.setAttribute("stroke","var(--primary, #3b82f6)"),B.setAttribute("stroke-width",String(U)),B.setAttribute("stroke-dasharray",String(H)),B.setAttribute("stroke-dashoffset",String(X)),B.setAttribute("stroke-linecap","round"),B.style.transform="rotate(-90deg)",B.style.transformOrigin="center",N.appendChild(M),N.appendChild(B),J.appendChild(N),$.label!=null){let z=_("div","pf-ring-label");z.textContent=F($.label,Z),z.style.textAlign="center",z.style.fontSize="12px",J.appendChild(z)}return J}function M8($,Z){let J=_("div","pf-progress");J.setAttribute("role","progressbar");let q=Number(b($.value,Z)??0),U=$.max??100,Q=U>0?Math.max(0,Math.min(100,q/U*100)):0;J.setAttribute("aria-valuenow",String(q)),J.setAttribute("aria-valuemin","0"),J.setAttribute("aria-valuemax",String(U)),J.style.height="8px",J.style.borderRadius="4px",J.style.overflow="hidden";let Y=_("div","pf-progress-fill");return Y.style.height="100%",Y.style.width=`${Q}%`,Y.style.borderRadius="4px",Y.style.transition="width 0.3s ease",J.appendChild(Y),J}function G8($,Z){let J=document.createElement("hr");return J.className="pf-separator",J.style.border="none",J.style.margin="8px 0",J}function X8($,Z){let J=_("div","pf-loader");return J.textContent="⏳",J.style.display="flex",J.style.justifyContent="center",J.style.padding="16px",J}function _8($,Z){let J=_("span","pf-icon");return J.setAttribute("data-icon",F($.name??$.content,Z)),J}function E8($,Z){let J=_("div","pf-sparkline"),q=$.data??[];if(q.length===0)return J;let U=120,Q=32,Y=Math.max(...q),W=Math.min(...q),H=Y-W||1,X=document.createElementNS("http://www.w3.org/2000/svg","svg");X.setAttribute("width",String(U)),X.setAttribute("height",String(Q)),X.setAttribute("viewBox",`0 0 ${U} ${Q}`);let N=q.length>1?q.length-1:1,M=q.map((z,E)=>{let K=E/N*U,D=Q-(z-W)/H*(Q-4)-2;return`${K},${D}`}).join(" "),B=document.createElementNS("http://www.w3.org/2000/svg","polyline");return B.setAttribute("points",M),B.setAttribute("fill","none"),B.setAttribute("stroke","var(--primary, #3b82f6)"),B.setAttribute("stroke-width","1.5"),X.appendChild(B),J.appendChild(X),J}function N8($,Z){let q={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[Z];if(q)$.style.backgroundColor=q.bg,$.style.color=q.fg}function O1(){G("Form",B8),G("Input",K8),G("Textarea",F8),G("Button",z8),G("ButtonGroup",D8),G("Select",L8),G("SelectOption",j8),G("SelectGroup",V0("pf-select-group")),G("SelectLabel",H0("pf-select-label")),G("SelectSeparator",j1),G("Checkbox",O8),G("Switch",T8),G("Slider",V8),G("Radio",R8),G("RadioGroup",I8),G("Combobox",A8),G("ComboboxOption",k8),G("ComboboxGroup",V0("pf-combobox-group")),G("ComboboxLabel",H0("pf-combobox-label")),G("ComboboxSeparator",j1),G("Calendar",f8),G("DatePicker",S8),G("Field",V0("pf-field")),G("FieldTitle",H0("pf-field-title")),G("FieldDescription",H0("pf-field-description")),G("FieldContent",V0("pf-field-content")),G("FieldError",H0("pf-field-error")),G("ChoiceCard",w8)}function B8($,Z){let J=document.createElement("form");return J.className="pf-form",J.addEventListener("submit",(q)=>{q.preventDefault();let U=new FormData(J),Q={};if(U.forEach((Y,W)=>{Q[W]=Y}),Z.store.merge(Q),$.onSubmit!=null){let Y=y(Z);Y.scope={...Z.scope,...Q},k($.onSubmit,Y)}}),j($,J,Z),J}function K8($,Z){let J=_("div","pf-input-wrapper");if(J.style.display="flex",J.style.flexDirection="column",J.style.gap="4px",$.label!=null){let Q=document.createElement("label");if(Q.className="pf-input-label",Q.textContent=F($.label,Z),$.name!=null)Q.htmlFor=$.name;Q.style.fontSize="14px",Q.style.fontWeight="500",J.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=F($.placeholder,Z);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=Z.store.get(U);if(Q!=null)q.value=String(Q);q.addEventListener("input",()=>{if(Z.store.set(U,q.value),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.value}})})}return l0(q),J.appendChild(q),J}function F8($,Z){let J=_("div","pf-textarea-wrapper"),q=document.createElement("textarea");if(q.className="pf-textarea",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-textarea-${$.name}`;if($.placeholder!=null)q.placeholder=F($.placeholder,Z);if($.rows!=null)q.rows=$.rows;if($.required===!0)q.setAttribute("aria-required","true");let U=$.name;if(U!=null){let Q=Z.store.get(U);if(Q!=null)q.value=String(Q);q.addEventListener("input",()=>{if(Z.store.set(U,q.value),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.value}})})}return l0(q),J.appendChild(q),J}function z8($,Z){let J=document.createElement("button");J.className="pf-button",J.type=$.submit===!0?"submit":"button",J.textContent=F($.label,Z);let q=$.variant??"default";if(J.setAttribute("data-variant",q),P8(J,q),$.size!=null)J.setAttribute("data-size",$.size);if($.disabled===!0)J.disabled=!0;if($.onClick!=null)J.addEventListener("click",()=>{k($.onClick,y(Z))});return J}function D8($,Z){let J=_("div","pf-button-group");return J.style.display="flex",J.style.gap="8px",j($,J,Z),J}function L8($,Z){let J=_("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(l0(q),$.placeholder!=null){let Y=document.createElement("option");Y.value="",Y.textContent=F($.placeholder,Z),Y.disabled=!0,Y.selected=!0,Y.hidden=!0,q.appendChild(Y)}let U=$.options;if(Array.isArray(U))for(let Y of U){let W=document.createElement("option");W.value=Y.value??"",W.textContent=Y.label??W.value,q.appendChild(W)}if($.children)for(let Y of $.children)if(Y.type==="SelectOption"){let W=document.createElement("option");W.value=Y.value??"",W.textContent=Y.label??W.value,q.appendChild(W)}else q.appendChild(w(Y,Z));let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=String(Y);q.addEventListener("change",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.value}})})}return J.appendChild(q),J}function j8($,Z){return _("span")}function O8($,Z){let J=_("label","pf-checkbox-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-checkbox",$.name!=null)q.name=$.name;if($.checked===!0)q.checked=!0;let U=$.name;if(U){let Q=Z.store.get(U);if(typeof Q==="boolean")q.checked=Q;q.addEventListener("change",()=>{if(Z.store.set(U,q.checked),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.checked}})})}if(J.appendChild(q),$.label!=null){let Q=_("span");Q.textContent=F($.label,Z),J.appendChild(Q)}return J}function T8($,Z){let J=_("label","pf-switch-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-switch",q.setAttribute("role","switch"),$.name!=null)q.name=$.name;let U=$.name;if(U){let Q=Z.store.get(U);if(typeof Q==="boolean")q.checked=Q;q.addEventListener("change",()=>{if(Z.store.set(U,q.checked),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.checked}})})}if(J.appendChild(q),$.label!=null){let Q=_("span");Q.textContent=F($.label,Z),J.appendChild(Q)}return J}function V8($,Z){let J=_("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=Z.store.get(U);if(Q!=null)q.value=String(Q);q.addEventListener("input",()=>{if(Z.store.set(U,Number(q.value)),$.onChange!=null)k($.onChange,{...y(Z),scope:{...Z.scope,$event:Number(q.value)}})})}return J.appendChild(q),J}function l0($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function P8($,Z){if($.style.padding="8px 16px",$.style.fontSize="14px",$.style.fontWeight="500",$.style.cursor="pointer",$.style.border="none",Z==="ghost")$.style.backgroundColor="transparent",$.style.color="inherit"}function V0($){return(Z,J)=>{let q=_("div",$);return j(Z,q,J),q}}function H0($){return(Z,J)=>{let q=_("span",$);return q.textContent=F(Z.content,J),q}}function j1(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function R8($,Z){let J=_("label","pf-radio");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="radio",q.value=F($.value,Z),J.appendChild(q),$.label!=null){let U=_("span","pf-radio-label");U.textContent=F($.label,Z),J.appendChild(U)}return J}function I8($,Z){let J=_("fieldset","pf-radio-group");if(J.style.border="none",J.style.padding="0",J.style.display="flex",J.style.flexDirection="column",J.style.gap="8px",$.label!=null){let Q=document.createElement("legend");Q.textContent=F($.label,Z),Q.style.fontWeight="500",Q.style.marginBottom="4px",J.appendChild(Q)}j($,J,Z);let q=F($.name,Z),U=Z.store.get(q);for(let Q of Array.from(J.querySelectorAll('input[type="radio"]')))if(Q.name=q,U!=null&&Q.value===String(U))Q.checked=!0;return J.addEventListener("change",(Q)=>{let Y=Q.target;if(Y.type==="radio"){if(Z.store.set(q,Y.value),$.onChange!=null)k($.onChange,y(Z))}}),J}function A8($,Z){let J=_("div","pf-combobox"),q=document.createElement("input");if(q.className="pf-combobox-input",q.type="text",q.name=F($.name,Z),$.placeholder!=null)q.placeholder=F($.placeholder,Z);if($.value!==void 0)q.value=F($.value,Z);let U=q.name,Q=Z.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 Y=_("div","pf-combobox-dropdown");if(Y.style.display="none",Y.style.position="absolute",Y.style.borderRadius="6px",Y.style.maxHeight="200px",Y.style.overflowY="auto",Y.style.zIndex="50",j($,Y,Z),q.addEventListener("focus",()=>{Y.style.display="block"}),q.addEventListener("blur",()=>{setTimeout(()=>{Y.style.display="none"},150)}),$.searchable!==!1)q.addEventListener("input",()=>{let W=q.value.toLowerCase();for(let H of Array.from(Y.querySelectorAll(".pf-combobox-option"))){let X=(H.textContent??"").toLowerCase();H.style.display=X.includes(W)?"":"none"}});if($.onChange!=null)J.addEventListener("pf-combobox-select",()=>{k($.onChange,{...y(Z),scope:{...Z.scope,$event:q.value}})});return J.style.position="relative",J.appendChild(q),J.appendChild(Y),J}function k8($,Z){let J=_("div","pf-combobox-option");return J.style.padding="6px 12px",J.style.cursor="pointer",J.textContent=F($.label??$.value,Z),J.dataset.value=F($.value,Z),J.addEventListener("mousedown",()=>{let q=J.closest(".pf-combobox"),U=q?.querySelector("input");if(U)U.value=J.dataset.value??"",Z.store.set(U.name,U.value),q?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),J}function f8($,Z){let J=_("div","pf-calendar"),q=document.createElement("input");if(q.type="date",q.name=F($.name,Z),$.value!==void 0)q.value=F($.value,Z);let U=q.name,Q=Z.store.get(U);if(Q!=null)q.value=String(Q);if($.minDate!=null)q.min=F($.minDate,Z);if($.maxDate!=null)q.max=F($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)k($.onChange,y(Z))}),J.appendChild(q),J}function S8($,Z){let J=_("div","pf-datepicker"),q=document.createElement("input");if(q.type="date",q.name=F($.name,Z),$.placeholder!=null)q.placeholder=F($.placeholder,Z);if($.value!==void 0)q.value=F($.value,Z);let U=q.name,Q=Z.store.get(U);if(Q!=null)q.value=String(Q);if($.minDate!=null)q.min=F($.minDate,Z);if($.maxDate!=null)q.max=F($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)k($.onChange,y(Z))}),J.appendChild(q),J}function w8($,Z){let J=_("div","pf-choice-card");if(J.style.padding="16px",J.style.cursor="pointer",J.style.transition="border-color 0.2s",J.dataset.value=F($.value,Z),$.selected===!0)J.dataset.selected="true";if($.label!=null){let q=_("div","pf-choice-card-label");q.textContent=F($.label,Z),q.style.fontWeight="600",J.appendChild(q)}if($.description!=null){let q=_("div","pf-choice-card-description");q.textContent=F($.description,Z),q.style.fontSize="14px",J.appendChild(q)}if(j($,J,Z),$.onClick!=null)J.addEventListener("click",()=>{k($.onClick,y(Z))});return J}function T1(){G("Tabs",C8),G("Tab",y8),G("Accordion",b8),G("AccordionItem",m8),G("Dialog",h8),G("Popover",v8),G("Tooltip",g8),G("HoverCard",u8),G("Carousel",x8)}function C8($,Z){let J=_("div","pf-tabs"),q=_("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 W=0;W<$.children.length;W++){let H=$.children[W],X=`pf-tab-${Math.random().toString(36).slice(2,8)}`,N=`pf-panel-${Math.random().toString(36).slice(2,8)}`,M=document.createElement("button");M.type="button",M.className="pf-tab-trigger",M.textContent=H.title??`Tab ${W+1}`,M.setAttribute("role","tab"),M.setAttribute("aria-selected",W===0?"true":"false"),M.setAttribute("aria-controls",N),M.id=X,M.tabIndex=W===0?0:-1,M.style.padding="8px 16px",M.style.border="none",M.style.background="none",M.style.cursor="pointer",M.style.borderBottom="2px solid transparent",M.style.marginBottom="-2px",M.style.fontSize="14px";let B=_("div","pf-tab-panel");if(B.style.display=W===0?"block":"none",B.setAttribute("role","tabpanel"),B.setAttribute("aria-labelledby",X),B.id=N,B.tabIndex=0,j(H,B,Z),M.addEventListener("click",()=>{Y(W)}),W===0)M.classList.add("pf-tab-active"),M.style.fontWeight="600";Q.push(M),U.push(B),q.appendChild(M)}function Y(W){U.forEach((H)=>H.style.display="none"),Q.forEach((H)=>{H.style.borderBottomColor="transparent",H.style.fontWeight="normal",H.classList.remove("pf-tab-active"),H.setAttribute("aria-selected","false"),H.tabIndex=-1}),U[W].style.display="block",Q[W].classList.add("pf-tab-active"),Q[W].style.fontWeight="600",Q[W].setAttribute("aria-selected","true"),Q[W].tabIndex=0,Q[W].focus()}q.addEventListener("keydown",(W)=>{let H=Q.indexOf(W.target);if(H<0)return;let X;if(W.key==="ArrowRight")X=(H+1)%Q.length;else if(W.key==="ArrowLeft")X=(H-1+Q.length)%Q.length;else if(W.key==="Home")X=0;else if(W.key==="End")X=Q.length-1;else return;W.preventDefault(),Y(X)}),J.appendChild(q);for(let W of U)J.appendChild(W);return J}function y8($,Z){let J=_("div","pf-tab");return j($,J,Z),J}function b8($,Z){let J=_("div","pf-accordion");return j($,J,Z),J}function m8($,Z){let J=_("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=_("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,Z),U.addEventListener("click",()=>{let Y=Q.style.display!=="none";Q.style.display=Y?"none":"block",U.setAttribute("aria-expanded",Y?"false":"true")}),J.appendChild(U),J.appendChild(Q),J}function h8($,Z){let J=_("div","pf-dialog-wrapper");if($.trigger!=null){let Q=w($.trigger,Z);Q.addEventListener("click",()=>{q.showModal()}),J.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=_("h2","pf-dialog-title");Q.textContent=F($.title,Z),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=_("p","pf-dialog-desc");Q.textContent=F($.description,Z),q.appendChild(Q)}let U=_("div","pf-dialog-body");if(j($,U,Z),q.appendChild(U),$.dismissible!==!1)q.addEventListener("click",(Q)=>{if(Q.target===q)q.close()});return document.addEventListener("prefab:close-overlay",()=>q.close()),J.appendChild(q),J}function v8($,Z){let J=_("div","pf-popover");J.style.position="relative",J.style.display="inline-block";let q=_("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=_("div","pf-popover-title");U.textContent=F($.title,Z),U.style.fontWeight="600",U.style.marginBottom="4px",q.appendChild(U)}return j($,q,Z),J.addEventListener("click",(U)=>{if(q.contains(U.target)&&q.style.display!=="none")return;q.style.display=q.style.display==="none"?"block":"none"}),J.appendChild(q),J}function g8($,Z){let J=_("div","pf-tooltip");J.style.position="relative",J.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,U=_("div","pf-tooltip-content");return U.id=q,U.setAttribute("role","tooltip"),U.textContent=F($.content??"",Z),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($,J,Z),J.setAttribute("aria-describedby",q),J.addEventListener("mouseenter",()=>{U.style.display="block"}),J.addEventListener("mouseleave",()=>{U.style.display="none"}),J.addEventListener("focus",()=>{U.style.display="block"},!0),J.addEventListener("blur",()=>{U.style.display="none"},!0),J.appendChild(U),J}function u8($,Z){let J=_("div","pf-hover-card");J.style.position="relative",J.style.display="inline-block";let q=_("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,Z),J.addEventListener("mouseenter",()=>{q.style.display="block"}),J.addEventListener("mouseleave",()=>{q.style.display="none"}),J.appendChild(q),J}function x8($,Z){let J=_("div","pf-carousel");J.style.position="relative",J.style.overflow="hidden",J.setAttribute("role","region"),J.setAttribute("aria-roledescription","carousel"),J.setAttribute("aria-label",F($.label??"Carousel",Z));let q=_("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",j($,q,Z);let U=0,Q=$.children?.length??0,Y=document.createElement("button");Y.type="button",Y.textContent="‹",Y.className="pf-carousel-prev",Y.setAttribute("aria-label","Previous slide"),Y.style.position="absolute",Y.style.left="4px",Y.style.top="50%",Y.style.transform="translateY(-50%)",Y.style.zIndex="10";let W=document.createElement("button");W.type="button",W.textContent="›",W.className="pf-carousel-next",W.setAttribute("aria-label","Next slide"),W.style.position="absolute",W.style.right="4px",W.style.top="50%",W.style.transform="translateY(-50%)",W.style.zIndex="10";let H=()=>{q.style.transform=`translateX(-${U*100}%)`};return Y.addEventListener("click",()=>{if(Q===0)return;U=Math.max(0,U-1),H()}),W.addEventListener("click",()=>{if(Q===0)return;U=Math.min(Q-1,U+1),H()}),J.appendChild(q),J.appendChild(Y),J.appendChild(W),J}function V1(){G("ForEach",p8),G("If",P1),G("Elif",c8),G("Else",l8),G("Condition",d8),G("Define",s8),G("Use",i8),G("Slot",r8)}function p8($,Z){let J=document.createDocumentFragment(),q=$.expression;if(!q)return J;let U;if(g(q)){let Y=u(q,Z.store,Z.scope);U=Array.isArray(Y)?Y:[]}else{let Y=Z.store.get(q);U=Array.isArray(Y)?Y:[]}let Q=$.let??{};for(let Y=0;Y<U.length;Y++){let W=U[Y],H={...Z.scope,$item:W,$index:Y,...Q},X={...Z,scope:H};if($.children)a($.children,J,X)}return J}function P1($,Z){if(R1($.condition,Z)){let q=document.createDocumentFragment();if($.children)a($.children,q,Z);return q}return document.createDocumentFragment()}function c8($,Z){return P1($,Z)}function l8($,Z){let J=document.createDocumentFragment();if($.children)a($.children,J,Z);return J}function R1($,Z){if(!$)return!1;if(g($))return Boolean(u($,Z.store,Z.scope));return Boolean(Z.store.get($))}function d8($,Z){let J=document.createDocumentFragment(),q=$.cases,U=$.else;if(q){for(let Q of q)if(R1(Q.when,Z)){if(Q.children)a(Q.children,J,Z);return J}}if(U)a(U,J,Z);return J}function s8($,Z){let J=$.name;if(J&&$.children)Z.templates=Z.templates??{},Z.templates[J]=$.children;return document.createDocumentFragment()}function i8($,Z){let J=document.createDocumentFragment(),q=$.def??$.name,U=Z.templates?.[q];if(!U)return J;let Q=$.overrides??{},Y={...Z.scope,...Q},W={...Z,scope:Y};for(let H of U)J.appendChild(w(H,W));return J}function r8($,Z){let J=document.createDocumentFragment(),q=$.name??"default",Q=Z.slots?.[q]??$.children;if(Q)for(let Y of Q)J.appendChild(w(Y,Z));return J}function I1(){G("Alert",n8),G("AlertTitle",a8),G("AlertDescription",o8)}function n8($,Z){let J=_("div","pf-alert");J.setAttribute("role","alert");let q=$.variant??"default";if(J.setAttribute("data-variant",q),J.style.padding="12px 16px",$.icon!=null){let U=_("span","pf-alert-icon");U.setAttribute("data-icon",$.icon),U.style.marginRight="8px",J.appendChild(U)}return j($,J,Z),J}function a8($,Z){let J=_("h5","pf-alert-title");return J.textContent=F($.content,Z),J.style.fontWeight="600",J.style.marginBottom="4px",J}function o8($,Z){let J=_("p","pf-alert-description");return J.textContent=F($.content,Z),J.style.fontSize="14px",J}function A1(){G("Image",t8),G("Audio",e8),G("Video",$2),G("Embed",Z2),G("Svg",q2),G("DropZone",U2),G("Mermaid",Q2)}function t8($,Z){let J=document.createElement("img");if(J.className="pf-image",J.src=F($.src,Z),$.alt!=null)J.alt=F($.alt,Z);if($.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function e8($,Z){let J=document.createElement("audio");return J.className="pf-audio",J.src=F($.src,Z),J.controls=!0,J}function $2($,Z){let J=document.createElement("video");if(J.className="pf-video",J.src=F($.src,Z),J.controls=!0,$.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function Z2($,Z){let J=_("div","pf-embed"),q=document.createElement("iframe");return q.src=F($.src,Z),q.style.width="100%",q.style.height=$.height!=null?`${$.height}px`:"400px",q.style.border="none",q.setAttribute("sandbox","allow-scripts"),J.appendChild(q),J}var J2=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 q2($,Z){let J=_("div","pf-svg"),q=F($.content,Z);if(!q.includes("<svg"))return J;let Q=new DOMParser().parseFromString(q,"image/svg+xml").querySelector("svg");if(!Q)return J;return k1(Q),J.appendChild(document.importNode(Q,!0)),J}function k1($){let Z=Array.from($.children);for(let J of Z){if(!J2.has(J.tagName.toLowerCase())){J.remove();continue}for(let q of Array.from(J.attributes)){let U=q.name.toLowerCase();if(U.startsWith("on")||U==="href"&&q.value.trim().toLowerCase().startsWith("javascript:"))J.removeAttribute(q.name)}k1(J)}}function U2($,Z){let J=_("div","pf-dropzone");return J.style.padding="32px",J.style.textAlign="center",J.style.cursor="pointer",J.textContent=F($.label??"Drop files here",Z),J.addEventListener("dragover",(q)=>{q.preventDefault(),J.classList.add("pf-dropzone-active")}),J.addEventListener("dragleave",()=>{J.classList.remove("pf-dropzone-active")}),J.addEventListener("drop",(q)=>{q.preventDefault(),J.classList.remove("pf-dropzone-active")}),J}function Q2($,Z){let J=_("div","pf-mermaid");J.setAttribute("data-mermaid","true");let q=F($.content,Z);if(J.textContent=q,typeof globalThis.mermaid<"u")J.classList.add("mermaid"),J.textContent=q;return J}var Y2="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",W2="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",d0=null,P0=null;async function H2(){if(d0)return d0;if(P0)return P0;return P0=import(Y2).then(($)=>{let Z=$;return Z.GlobalWorkerOptions.workerSrc=W2,d0=Z,Z}),P0}function S1(){G("PdfViewer",M2)}function M2($,Z){let J=_("div","pf-pdf-viewer"),q=$.src!=null?F($.src,Z):void 0,U=$.data,Q=$.page!=null?$.page:1,Y=$.zoom!=null?$.zoom:"fit-width",W=$.toolbar!==!1,H=$.height!=null?$.height:600;J.style.height=`${H}px`,J.style.display="flex",J.style.flexDirection="column",J.style.overflow="hidden",J.style.border="1px solid var(--color-border-primary, #e5e7eb)",J.style.borderRadius="var(--border-radius-md, 0.375rem)",J.style.background="var(--color-background-secondary, #f9fafb)";let X=_("div","pf-pdf-loading");return X.textContent="Loading PDF…",X.style.display="flex",X.style.alignItems="center",X.style.justifyContent="center",X.style.flex="1",X.style.color="var(--color-text-secondary, #6b7280)",J.appendChild(X),G2(J,X,{src:q,data:U,initialPage:Q,zoom:Y,showToolbar:W}),J}async function G2($,Z,J){try{let q=await H2(),U;if(J.src)U={url:J.src};else if(J.data){let B=atob(J.data),z=new Uint8Array(B.length);for(let E=0;E<B.length;E++)z[E]=B.charCodeAt(E);U={data:z}}else{Z.textContent="Error: No PDF source provided";return}let Q=await q.getDocument(U).promise;Z.remove();let Y=Math.max(1,Math.min(J.initialPage,Q.numPages)),W=null,H=null;if(J.showToolbar){let B=X2(Q.numPages,Y,{onPrev:()=>{if(Y>1)Y--,M()},onNext:()=>{if(Y<Q.numPages)Y++,M()},onPageChange:(z)=>{let E=Math.max(1,Math.min(z,Q.numPages));if(E!==Y)Y=E,M()}});W=B.pageInput,H=B.pageCount,$.insertBefore(B.el,$.firstChild)}let X=_("div","pf-pdf-canvas-container");X.style.flex="1",X.style.overflow="auto",X.style.display="flex",X.style.justifyContent="center",X.style.padding="8px",$.appendChild(X);let N=document.createElement("canvas");N.style.display="block",N.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",X.appendChild(N);async function M(){let B=await Q.getPage(Y),z=X.clientWidth-16,E,K=B.getViewport({scale:1});if(J.zoom==="fit-width")E=z/K.width;else if(J.zoom==="fit-page"){let A=X.clientHeight-16,R=z/K.width,L=A/K.height;E=Math.min(R,L)}else E=typeof J.zoom==="number"?J.zoom:1;let D=B.getViewport({scale:E});N.width=D.width,N.height=D.height,N.style.width=`${D.width}px`,N.style.height=`${D.height}px`;let O=N.getContext("2d");if(!O)return;if(await B.render({canvasContext:O,viewport:D}).promise,W)W.value=String(Y);if(H)H.textContent=`/ ${Q.numPages}`}await M()}catch(q){Z.textContent=`PDF Error: ${q instanceof Error?q.message:String(q)}`,Z.style.color="var(--color-text-danger, #dc2626)"}}function X2($,Z,J){let q=_("div","pf-pdf-toolbar");q.style.display="flex",q.style.alignItems="center",q.style.gap="8px",q.style.padding="6px 12px",q.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",q.style.background="var(--color-background-primary, #fff)",q.style.flexShrink="0",q.style.fontSize="13px";let U=document.createElement("button");U.textContent="‹",U.title="Previous page",U.className="pf-pdf-btn",f1(U),U.addEventListener("click",J.onPrev);let Q=document.createElement("button");Q.textContent="›",Q.title="Next page",Q.className="pf-pdf-btn",f1(Q),Q.addEventListener("click",J.onNext);let Y=document.createElement("input");Y.type="number",Y.min="1",Y.max=String($),Y.value=String(Z),Y.style.width="48px",Y.style.textAlign="center",Y.style.border="1px solid var(--color-border-primary, #e5e7eb)",Y.style.borderRadius="4px",Y.style.padding="2px 4px",Y.style.fontSize="13px",Y.addEventListener("change",()=>{let H=parseInt(Y.value,10);if(!isNaN(H))J.onPageChange(H)});let W=document.createElement("span");return W.textContent=`/ ${$}`,W.style.color="var(--color-text-secondary, #6b7280)",q.appendChild(U),q.appendChild(Y),q.appendChild(W),q.appendChild(Q),{el:q,pageInput:Y,pageCount:W}}function f1($){$.style.border="1px solid var(--color-border-primary, #e5e7eb)",$.style.borderRadius="4px",$.style.background="var(--color-background-primary, #fff)",$.style.cursor="pointer",$.style.padding="2px 8px",$.style.fontSize="16px",$.style.lineHeight="1"}var I0=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function A0($,Z){let J=document.createElement("div");return J.className="pf-chart-tooltip",$.appendChild(J),$.addEventListener("mouseleave",()=>{J.classList.remove("pf-visible")}),{wrapper:$,tooltip:J,svgEl:Z}}function M0($,Z,J,q,U){let{tooltip:Q,svgEl:Y,wrapper:W}=$;if(U.length===0)return;let H="";if(q)H+=`<div class="pf-chart-tooltip-label">${R0(q)}</div>`;for(let D of U)H+='<div class="pf-chart-tooltip-row">',H+=`<span class="pf-chart-tooltip-dot" style="background:${R0(D.color)}"></span>`,H+=`<span>${R0(D.label)}:</span> <strong>${R0(String(D.value))}</strong>`,H+="</div>";Q.innerHTML=H;let X=Y.getBoundingClientRect(),N=W.getBoundingClientRect(),M=Y.viewBox.baseVal,B=X.width/(M.width||1),z=X.left-N.left+Z*B,E=Q.offsetWidth||100,K=z+12;if(K+E>N.width)K=z-E-12;Q.style.left=`${Math.max(0,K)}px`,Q.style.top="4px",Q.classList.add("pf-visible")}function R0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function w1($,Z,J,q,U,Q,Y,W){let H=U.plotWidth/J.length;for(let X=0;X<J.length;X++){let N=U.plotLeft+X*H,M=document.createElementNS("http://www.w3.org/2000/svg","rect");M.setAttribute("x",String(N)),M.setAttribute("y",String(U.plotTop)),M.setAttribute("width",String(H)),M.setAttribute("height",String(U.plotHeight)),M.setAttribute("fill","transparent"),M.style.cursor="default";let B=Q?J[X][Q]:void 0,z=B!=null?W?W(B):String(B):void 0,E=q.map((A,R)=>({label:A.label??A.dataKey,value:Y(J[X][A.dataKey],A,R),color:A.color??I0[R%I0.length]})),K=N+H/2,D=()=>M0($,K,U.plotTop,z,E),O=()=>$.tooltip.classList.remove("pf-visible");M.addEventListener("mouseenter",D),M.addEventListener("mouseleave",O),M.addEventListener("touchstart",D,{passive:!0}),M.addEventListener("touchend",O,{passive:!0}),Z.appendChild(M)}}function C1($,Z,J,q,U,Q,Y,W,H,X){let N=J.length===1?U.plotWidth:U.plotWidth/(J.length-1);for(let M=0;M<J.length;M++){let B=J.length===1?(U.plotLeft+U.plotRight)/2:U.plotLeft+M/(J.length-1)*U.plotWidth,z=J.length===1?U.plotLeft:B-N/2,E=J.length===1?U.plotWidth:N,K=document.createElementNS("http://www.w3.org/2000/svg","rect");K.setAttribute("x",String(Math.max(U.plotLeft,z))),K.setAttribute("y",String(U.plotTop)),K.setAttribute("width",String(Math.min(E,U.plotRight-Math.max(U.plotLeft,z)))),K.setAttribute("height",String(U.plotHeight)),K.setAttribute("fill","transparent"),K.style.cursor="default";let D=Q?J[M][Q]:void 0,O=D!=null?X?X(D):String(D):void 0,A=q.map((T,C)=>({label:T.label??T.dataKey,value:Y(J[M][T.dataKey],T,C),color:T.color??I0[C%I0.length]})),R=()=>{if(M0($,B,U.plotTop,O,A),W)W.setAttribute("x1",String(B)),W.setAttribute("x2",String(B)),W.setAttribute("opacity","1");if(H)for(let T of H){for(let C of T)C.setAttribute("data-visible","false");T[M]?.setAttribute("data-visible","true")}},L=()=>{if($.tooltip.classList.remove("pf-visible"),W)W.setAttribute("opacity","0");if(H)for(let T of H)for(let C of T)C.setAttribute("data-visible","false")};K.addEventListener("mouseenter",R),K.addEventListener("mouseleave",L),K.addEventListener("touchstart",R,{passive:!0}),K.addEventListener("touchend",L,{passive:!0}),Z.appendChild(K)}}function b1(){G("BarChart",E2),G("LineChart",y1),G("AreaChart",y1),G("PieChart",N2),G("RadarChart",s0),G("ScatterChart",s0),G("RadialChart",s0),G("Histogram",B2)}var s=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],G0="var(--muted-foreground, #6b7280)",_2="var(--border, #e5e7eb)",i0="10";function m1($,Z,J,q=!1){let U=J?44:0,Q=$-(q?44:0),Y=10,W=Z-24;return{plotLeft:U,plotRight:Q,plotTop:10,plotBottom:W,plotWidth:Q-U,plotHeight:W-10}}function h1($,Z=5){if($<=0)return[0];let J=$/Z,q=Math.pow(10,Math.floor(Math.log10(J))),U=J/q,Q=U<=1.5?q:U<=3?2*q:U<=7?5*q:10*q,Y=[];for(let W=0;W<=$+Q*0.01;W+=Q)Y.push(Math.round(W*1000)/1000);return Y}function v1($,Z,J,q,U){let Q=h1(J);for(let Y of Q){let W=Z.plotBottom-(J>0?Y/J*Z.plotHeight:0),H=document.createElementNS("http://www.w3.org/2000/svg","text");if(H.setAttribute("x",String(Z.plotLeft-6)),H.setAttribute("y",String(W+3)),H.setAttribute("text-anchor","end"),H.setAttribute("font-size",i0),H.setAttribute("fill",G0),H.textContent=r0(Y,U),$.appendChild(H),q&&Y>0){let X=document.createElementNS("http://www.w3.org/2000/svg","line");X.setAttribute("x1",String(Z.plotLeft)),X.setAttribute("y1",String(W)),X.setAttribute("x2",String(Z.plotRight)),X.setAttribute("y2",String(W)),X.setAttribute("stroke",_2),X.setAttribute("stroke-width","1"),X.setAttribute("stroke-dasharray","4 3"),$.appendChild(X)}}}function g1($,Z,J,q){let U=h1(J);for(let Q of U){let Y=Z.plotBottom-(J>0?Q/J*Z.plotHeight:0),W=document.createElementNS("http://www.w3.org/2000/svg","text");W.setAttribute("x",String(Z.plotRight+6)),W.setAttribute("y",String(Y+3)),W.setAttribute("text-anchor","start"),W.setAttribute("font-size",i0),W.setAttribute("fill",G0),W.textContent=r0(Q,q),$.appendChild(W)}}function u1($,Z,J,q,U,Q){for(let Y=0;Y<Z.length;Y++){let W=document.createElementNS("http://www.w3.org/2000/svg","text");W.setAttribute("x",String(q(Y))),W.setAttribute("y",String(U+14)),W.setAttribute("text-anchor","middle"),W.setAttribute("font-size",i0),W.setAttribute("fill",G0);let H=Z[Y][J];W.textContent=H==null?"":Q?Q(H):String(H),$.appendChild(W)}}function x1($,Z){let J=document.createElementNS("http://www.w3.org/2000/svg","line");J.setAttribute("x1",String(Z.plotLeft)),J.setAttribute("y1",String(Z.plotBottom)),J.setAttribute("x2",String(Z.plotRight)),J.setAttribute("y2",String(Z.plotBottom)),J.setAttribute("stroke",G0),J.setAttribute("stroke-width","1"),$.appendChild(J)}function J0($,Z,J){if($==null)return"";let q=b(`{{ __v | ${Z} }}`,{...J,scope:{...J.scope,__v:$}});return q==null?String($):String(q)}function r0($,Z){if(Z==="currency")return`$${$.toLocaleString()}`;if(Z==="percent")return`${$}%`;if($>=1e6)return`${($/1e6).toFixed(1)}M`;if($>=1000)return`${($/1000).toFixed(1)}K`;return String($)}function p1($,Z,J){return(q,U)=>{if(q===null||q===void 0)return"—";if(U.tooltipFormat)return J0(q,U.tooltipFormat,$);let Q=U.yAxisId==="right"?J:Z;return r0(Number(q),Q)}}function E2($,Z){let J=_("div","pf-chart pf-bar-chart"),q=b($.data,Z)??[],U=$.series??[],Q=$.height??300;if(q.length===0||U.length===0)return J.textContent="No chart data",J;let Y=$.showYAxis!==!1,W=$.showGrid===!0,H=$.showYAxisRight===!0,X=$.showTooltip!==!1,N=$.xAxis,M=$.tooltipXKey,B=$.xAxisFormat,z=$.tooltipXFormat,E=U.filter((I)=>I.yAxisId!=="right"),K=U.filter((I)=>I.yAxisId==="right"),D=H&&K.length>0,O=E.length>0?Math.max(...q.flatMap((I)=>E.map((P)=>Number(I[P.dataKey]??0))),1):1,A=D?Math.max(...q.flatMap((I)=>K.map((P)=>Number(I[P.dataKey]??0))),1):1,R=400,L=m1(R,Q,Y,D),T=k0(R,Q,"Bar");if(Y)v1(T,L,O,W,$.yAxisFormat);if(D)g1(T,L,A,$.yAxisRightFormat);x1(T,L);let C=L.plotWidth/q.length,i=C/(U.length+1);for(let I=0;I<q.length;I++)for(let P=0;P<U.length;P++){let f=U[P],x=q[I][f.dataKey];if(x===null||x===void 0)continue;let m=f.yAxisId==="right"?A:O,c=Number(x),l=Math.max(0,c/m*L.plotHeight),o=L.plotLeft+I*C+P*i+i/2,V=document.createElementNS("http://www.w3.org/2000/svg","rect");V.setAttribute("x",String(o)),V.setAttribute("y",String(L.plotBottom-l)),V.setAttribute("width",String(i*0.8)),V.setAttribute("height",String(l)),V.setAttribute("fill",f.color??s[P%s.length]),V.setAttribute("rx","2"),T.appendChild(V)}if(N){let I=B?(P)=>J0(P,B,Z):void 0;u1(T,q,N,(P)=>{return L.plotLeft+P*C+C/2},L.plotBottom,I)}if(X){let I=A0(J,T),P=p1(Z,$.yAxisFormat,$.yAxisRightFormat);w1(I,T,q,U,L,M??N,P,z?(x)=>J0(x,z,Z):void 0)}return n0(J,U,$.showLegend),J.appendChild(T),J}function y1($,Z){let J=_("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),q=b($.data,Z)??[],U=$.series??[],Q=$.height??300;if(q.length===0||U.length===0)return J.textContent="No chart data",J;let Y=$.showYAxis!==!1,W=$.showGrid===!0,H=$.showYAxisRight===!0,X=$.showTooltip!==!1,N=$.xAxis,M=$.tooltipXKey,B=$.xAxisFormat,z=$.tooltipXFormat,E=U.filter((P)=>P.yAxisId!=="right"),K=U.filter((P)=>P.yAxisId==="right"),D=H&&K.length>0,O=E.length>0?Math.max(...q.flatMap((P)=>E.map((f)=>Number(P[f.dataKey]??0))),1):1,A=D?Math.max(...q.flatMap((P)=>K.map((f)=>Number(P[f.dataKey]??0))),1):1,R=400,L=m1(R,Q,Y,D),T=k0(R,Q,$.type==="AreaChart"?"Area":"Line"),C=$.type==="AreaChart";if(Y)v1(T,L,O,W,$.yAxisFormat);if(D)g1(T,L,A,$.yAxisRightFormat);x1(T,L);let i=[];for(let P=0;P<U.length;P++){let f=U[P],x=f.yAxisId==="right",r=x?A:O,m=f.color??s[P%s.length],c=q.map((V,S)=>{let h=V[f.dataKey],t=h===null||h===void 0,E0=q.length===1?(L.plotLeft+L.plotRight)/2:L.plotLeft+S/(q.length-1)*L.plotWidth,t1=t?L.plotBottom:L.plotBottom-Number(h)/r*L.plotHeight;return{x:E0,y:t1,isNull:t}});if(C){let V=[],S=()=>{if(V.length<2){V=[];return}let h=`M ${V[0].x},${L.plotBottom} `+V.map((E0)=>`L ${E0.x},${E0.y}`).join(" ")+` L ${V[V.length-1].x},${L.plotBottom} Z`,t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d",h),t.setAttribute("fill",m),t.setAttribute("opacity","0.15"),T.appendChild(t),V=[]};for(let h of c){if(h.isNull){S();continue}V.push(h)}S()}let l="";for(let V of c){if(V.isNull)continue;let S=c.indexOf(V),h=S===0||c[S-1].isNull;l+=`${h?"M":"L"} ${V.x},${V.y} `}if(l){let V=document.createElementNS("http://www.w3.org/2000/svg","path");if(V.setAttribute("d",l.trim()),V.setAttribute("fill","none"),V.setAttribute("stroke",m),V.setAttribute("stroke-width","2"),x)V.setAttribute("stroke-dasharray","6 3");T.appendChild(V)}let o=[];for(let V of c){let S=document.createElementNS("http://www.w3.org/2000/svg","circle");if(S.setAttribute("cx",String(V.x)),S.setAttribute("cy",String(V.y)),S.setAttribute("r","4"),S.setAttribute("fill",m),S.setAttribute("class","pf-data-dot"),S.setAttribute("data-visible","false"),S.style.pointerEvents="none",V.isNull)S.style.display="none";T.appendChild(S),o.push(S)}i.push(o)}let I=document.createElementNS("http://www.w3.org/2000/svg","line");if(I.setAttribute("class","pf-crosshair"),I.setAttribute("x1",String(L.plotLeft)),I.setAttribute("x2",String(L.plotLeft)),I.setAttribute("y1",String(L.plotTop)),I.setAttribute("y2",String(L.plotBottom)),I.setAttribute("stroke",G0),I.setAttribute("stroke-width","1"),I.setAttribute("stroke-dasharray","3 3"),I.setAttribute("opacity","0"),T.appendChild(I),N){let P=B?(f)=>J0(f,B,Z):void 0;u1(T,q,N,(f)=>{return q.length===1?(L.plotLeft+L.plotRight)/2:L.plotLeft+f/(q.length-1)*L.plotWidth},L.plotBottom,P)}if(X){let P=A0(J,T),f=p1(Z,$.yAxisFormat,$.yAxisRightFormat);C1(P,T,q,U,L,M??N,f,I,i,z?(r)=>J0(r,z,Z):void 0)}return n0(J,U,$.showLegend),J.appendChild(T),J}function N2($,Z){let J=_("div","pf-chart pf-pie-chart"),q=b($.data,Z)??[],U=$.series??[],Q=$.height??300,Y=Math.min(Q,300),W=$.showTooltip!==!1;if(q.length===0||U.length===0)return J.textContent="No chart data",J;let H=k0(Y,Y,"Pie"),X=Y/2,N=Y/2,M=Y/2-10,B=U[0].dataKey,z=$.xAxis,E=$.tooltipXKey,K=$.tooltipXFormat,D=q.map((L)=>Number(L[B]??0)),O=D.reduce((L,T)=>L+T,0);if(O===0)return J.textContent="No chart data",J.appendChild(H),J;let A=W?A0(J,H):void 0,R=-Math.PI/2;for(let L=0;L<D.length;L++){let T=D[L]/O*2*Math.PI,C=R+T,i=T>Math.PI?1:0,I=X+M*Math.cos(R),P=N+M*Math.sin(R),f=X+M*Math.cos(C),x=N+M*Math.sin(C),r=s[L%s.length],m=document.createElementNS("http://www.w3.org/2000/svg","path");if(m.setAttribute("d",`M ${X},${N} L ${I},${P} A ${M},${M} 0 ${i} 1 ${f},${x} Z`),m.setAttribute("fill",r),m.style.cursor="default",A){let c=E??z,l=c?q[L][c]:void 0,o=l!=null?K?J0(l,K,Z):String(l):`Slice ${L+1}`,V=`${(D[L]/O*100).toFixed(1)}%`,S=R+T/2,h=X+M*0.6*Math.cos(S);m.addEventListener("mouseenter",()=>{M0(A,h,N,o,[{label:U[0].label??B,value:`${D[L]} (${V})`,color:r}])}),m.addEventListener("mouseleave",()=>{A.tooltip.classList.remove("pf-visible")}),m.addEventListener("touchstart",()=>{M0(A,h,N,o,[{label:U[0].label??B,value:`${D[L]} (${V})`,color:r}])},{passive:!0}),m.addEventListener("touchend",()=>{A.tooltip.classList.remove("pf-visible")},{passive:!0})}H.appendChild(m),R=C}return n0(J,U,$.showLegend),J.appendChild(H),J}function s0($,Z){let J=_("div",`pf-chart pf-${$.type.toLowerCase()}`);return J.textContent=`${$.type} — not yet supported in renderer`,J.style.padding="24px",J.style.textAlign="center",J}function k0($,Z,J){let q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(q.setAttribute("width","100%"),q.setAttribute("height",String(Z)),q.setAttribute("viewBox",`0 0 ${$} ${Z}`),q.setAttribute("role","img"),J)q.setAttribute("aria-label",`${J} chart`);return q.style.overflow="visible",q}function n0($,Z,J){if(J===!1||Z.length<=1)return;let q=_("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<Z.length;U++){let Q=_("div","pf-chart-legend-item");Q.style.display="flex",Q.style.alignItems="center",Q.style.gap="4px";let Y=_("span");Y.style.width="8px",Y.style.height="8px",Y.style.borderRadius="50%",Y.style.backgroundColor=Z[U].color??s[U%s.length];let W=_("span");W.textContent=Z[U].label??Z[U].dataKey,Q.appendChild(Y),Q.appendChild(W),q.appendChild(Q)}$.appendChild(q)}function B2($,Z){let J=_("div","pf-chart pf-histogram"),q=b($.data,Z);if(!q||q.length===0)return J.textContent="No data",J;let U=q,Q=$.bins??10,Y=$.height??200,W=$.color??s[0],H=Math.min(...U),N=(Math.max(...U)-H)/Q||1,M=Array(Q).fill(0);for(let O of U){let A=Math.min(Math.floor((O-H)/N),Q-1);M[A]++}let B=Math.max(...M),z=300,E=Y,K=z/Q,D=k0(z,E,"Histogram");for(let O=0;O<Q;O++){let A=B>0?M[O]/B*E:0,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(O*K)),R.setAttribute("y",String(E-A)),R.setAttribute("width",String(K-1)),R.setAttribute("height",String(A)),R.setAttribute("fill",W),D.appendChild(R)}return J.appendChild(D),J}function c1(){G("Table",K2),G("TableHead",a0("thead")),G("TableBody",a0("tbody")),G("TableFooter",a0("tfoot")),G("TableRow",F2),G("TableHeader",z2),G("TableCell",D2),G("TableCaption",L2),G("ExpandableRow",j2)}function K2($,Z){let J=document.createElement("table");return J.className="pf-table",J.style.width="100%",J.style.borderCollapse="collapse",j($,J,Z),J}function a0($){return(Z,J)=>{let q=document.createElement($);return q.className=`pf-${$}`,j(Z,q,J),q}}function F2($,Z){let J=document.createElement("tr");return J.className="pf-table-row",j($,J,Z),J}function z2($,Z){let J=document.createElement("th");return J.className="pf-table-header",J.style.textAlign="left",J.style.padding="8px 12px",J.style.fontWeight="600",J.textContent=F($.content,Z),J}function D2($,Z){let J=document.createElement("td");if(J.className="pf-table-cell",J.style.padding="8px 12px",$.colSpan!=null)J.colSpan=$.colSpan;if($.rowSpan!=null)J.rowSpan=$.rowSpan;return j($,J,Z),J}function L2($,Z){let J=document.createElement("caption");return J.className="pf-table-caption",J.style.padding="8px",J.style.fontSize="14px",J.textContent=F($.content,Z),J}function j2($,Z){let J=_("div","pf-expandable-row"),q=_("div","pf-expandable-row-summary");q.style.cursor="pointer",q.style.display="flex",q.style.alignItems="center",q.style.gap="8px";let U=_("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 H of Q)q.appendChild(w(H,Z));let Y=_("div","pf-expandable-row-detail");Y.style.display="none",Y.style.paddingLeft="24px",j($,Y,Z);let W=!1;return q.addEventListener("click",()=>{W=!W,Y.style.display=W?"block":"none",U.style.transform=W?"rotate(90deg)":""}),J.appendChild(q),J.appendChild(Y),J}var l1=!1;function f0(){if(l1)return;l1=!0,_1(),K1(),D1(),L1(),O1(),T1(),V1(),I1(),A1(),S1(),b1(),c1()}function d1($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function s1($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function a1($,Z){if(!Z)return;if(Z.light)for(let[J,q]of Object.entries(Z.light))$.style.setProperty(`--${d1(J)}`,s1(q));if(Z.dark){let q=document.getElementById("prefab-dark-theme");if(!q)q=document.createElement("style"),q.id="prefab-dark-theme",document.head.appendChild(q);let U=Object.entries(Z.dark).map(([Q,Y])=>` --${d1(Q)}: ${s1(Y)};`).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 x1($,J){if(!$||typeof document>"u")return;let Z=(q)=>{for(let[U,Q]of Object.entries($))if(q2(U,q))q.preventDefault(),J(Q)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)}function q2($,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}var v1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"/></svg>',h1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"/></svg>',g1={"top-right":"top: 8px; right: 8px;","top-left":"top: 8px; left: 8px;","bottom-right":"bottom: 8px; right: 8px;","bottom-left":"bottom: 8px; left: 8px;"};function U2($,J){try{let q=localStorage.getItem(J);if(q==="light"||q==="dark")return q}catch{}let Z=$.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(Z==="light"||Z==="dark")return Z;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function _0($,J){if(typeof document>"u")return()=>{};let Z=J?.position??"top-right",q=J?.storageKey??"prefab-theme",U=J?.syncDocument??!0,Q=getComputedStyle($).position;if(Q==="static"||Q==="")$.style.position="relative";let Y=document.createElement("button");Y.className="pf-theme-toggle",Y.setAttribute("aria-label","Toggle theme"),Y.setAttribute("title","Toggle light/dark"),Object.assign(Y.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let W=g1[Z]??g1["top-right"];for(let _ of W.split(";")){let[z,D]=_.split(":").map((N)=>N.trim());if(z&&D)Y.style.setProperty(z,D)}Y.addEventListener("mouseenter",()=>{Y.style.opacity="1"}),Y.addEventListener("mouseleave",()=>{Y.style.opacity="0.7"});function H(_){if($.setAttribute("data-theme",_),U)document.documentElement.setAttribute("data-theme",_);Y.innerHTML=_==="dark"?h1:v1;try{localStorage.setItem(q,_)}catch{}}let X=U2($,q);H(X),Y.addEventListener("click",()=>{let _=$.getAttribute("data-theme")??"dark";H(_==="dark"?"light":"dark")}),$.appendChild(Y);let G;if(U)G=new MutationObserver((_)=>{for(let z of _)if(z.type==="attributes"&&z.attributeName==="data-theme"){let D=document.documentElement.getAttribute("data-theme");if((D==="light"||D==="dark")&&D!==$.getAttribute("data-theme")){$.setAttribute("data-theme",D),Y.innerHTML=D==="dark"?h1:v1;try{localStorage.setItem(q,D)}catch{}}}}),G.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{G?.disconnect(),Y.remove()}}function A0($){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 Y=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(!Y.ok)throw Error(`MCP tool call failed: ${Y.status} ${Y.statusText}`);let W=await Y.json();if(W.error)throw Error(W.error.message??"MCP tool call returned error");let H=W.result?.content??W.content??[];for(let X of H)if(X.type==="text"&&X.text!==void 0){try{let G=JSON.parse(X.text);if(typeof G==="object"&&G!==null&&"$prefab"in G)return G;return G}catch{}return X.text}return W.result??W},async sendMessage(U){await q(`${J}/mcp/messages`,{method:"POST",headers:Z,body:JSON.stringify({message:U})})}}}function k0(){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 Q2($){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 $=H2();if($)this.postFn=(Z)=>$.postMessage(Z);let J=(Z)=>{if(this.hostOrigin!=="*"&&Z.origin!==this.hostOrigin)return;let q=Z.data;if(Q2(q)){this.handleJsonRpc(q);return}let U=q;if(!U?.type.startsWith("prefab:"))return;if(U.type==="prefab:tool-call-response"&&U.id){let Y=this.pending.get(U.id);if(Y){if(this.pending.delete(U.id),U.payload?.error!=null)Y.reject(Error(U.payload.error));else Y.resolve(U.payload?.result);return}}let Q=this.listeners.get(U.type);if(Q)for(let Y of Q)Y(U.payload??{})};window.addEventListener("message",J),this.cleanup=()=>window.removeEventListener("message",J)}async initialize($){try{return await Promise.any([this.initPrefab($),this.initJsonRpc($)])}catch(J){let Z=J instanceof AggregateError?J.errors.map((q)=>q.message).join("; "):String(J);throw Error(`Bridge init failed — no host responded. Tried: ${Z}`,{cause:J})}}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:$})}setupAutoResize($){if(typeof ResizeObserver>"u")return Y2;let J=-1,Z=-1,q=(Y,W)=>{if(Y===J&&W===Z)return;if(J=Y,Z=W,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:Y,height:W});else this.sendPrefab("prefab:size-changed",{width:Y,height:W})},U=new ResizeObserver((Y)=>{for(let W of Y)if(W.borderBoxSize.length){let H=W.borderBoxSize[0];q(Math.ceil(H.inlineSize),Math.ceil(H.blockSize))}else{let H=W.target.getBoundingClientRect();q(Math.ceil(H.width),Math.ceil(H.height))}});U.observe($);let Q=$.getBoundingClientRect();return q(Math.ceil(Q.width),Math.ceil(Q.height)),()=>U.disconnect()}notifyPreferredSize($){if(this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/preferred-size",$);else this.sendPrefab("prefab:preferred-size",$)}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;if(typeof U.css?.fonts==="string")q.fontCss=U.css.fonts}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 Y=Q??{},W=Y.hostInfo??{},H=Y.hostContext??{},X=Y.hostCapabilities??{},G;if(typeof H.theme==="string"||typeof H.styles==="object"){if(G={},typeof H.theme==="string")G.colorScheme=H.theme;if(typeof H.styles==="object"&&H.styles!==null){let _=H.styles;if(_.variables)G.variables=_.variables;if(typeof _.css?.fonts==="string")G.fontCss=_.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}}),J({hostName:W.name,hostVersion:W.version,capabilities:{toast:!0,navigation:X.openLinks!=null,messaging:!0,displayModes:H.availableDisplayModes??[]},theme:G,toolInput:void 0,meta:H})},reject:(Q)=>{if(U)return;U=!0,Z(Q)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{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)})}sendRpcNotification($,J){this.postJsonRpc({jsonrpc:"2.0",method:$,params:J})}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)}}var Y2=()=>{};function B0($,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);if(J.fontCss)W2(J.fontCss)}function W2($){if(document.getElementById("__prefab-host-fonts"))return;let Z=document.createElement("style");Z.id="__prefab-host-fonts",Z.textContent=$,document.head.appendChild(Z)}function Z0(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function H2(){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 f0($){R0();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=A0($.transport);else q=k0();if(Q.theme&&typeof document<"u")B0(document.documentElement,Q.theme);if(typeof document<"u"&&!U)_2();let Y,W,H,X,G=Q.toolInput,_;if(U)U.on("prefab:tool-input",(N)=>{let E=N.args??N;if(Y)Y(E);else G=E}),U.on("prefab:tool-result",(N)=>{let E=N.result??N;if(W)W(E);else _=E}),U.on("prefab:tool-cancelled",()=>{H?.()}),U.on("prefab:tool-input-partial",(N)=>{X?.(N.args??N)}),U.on("prefab:theme-update",(N)=>{if(typeof document<"u")B0(document.documentElement,N)});function z(N,...E){let L=l0(N),T=new q0,A={store:T,scope:{},transport:q,rerender:()=>R(),onToast:void 0};function R(){L.innerHTML="";for(let F of E)L.appendChild(w(F,A))}return R(),{rerender:R,store:T,destroy:()=>{L.innerHTML=""}}}return{callTool:(N,E={})=>q.callTool(N,E),sendMessage:(N)=>q.sendMessage(N),onToolInput:(N)=>{if(Y=N,G){let E=G;G=void 0,queueMicrotask(()=>N(E))}},onToolResult:(N)=>{if(W=N,_!==void 0){let E=_;_=void 0,queueMicrotask(()=>N(E))}},onToolCancelled:(N)=>{H=N},onToolInputPartial:(N)=>{X=N},render:z,mount:(N,E,L)=>{let T=l0(N);return p.mount(T,E,{transport:q,...L})},requestMode:(N)=>U?.requestMode(N),openLink:(N,E)=>{if(U)U.openLink(N,E);else if(typeof window<"u")window.open(N,E??"_blank")},updateContext:(N)=>{if(U)U.updateContext(N)},setupAutoResize:(N)=>{if(!U)return M2;let E=typeof N==="string"?l0(N):N;return U.setupAutoResize(E)},notifyPreferredSize:(N)=>{if(U)U.notifyPreferredSize(N)},host:Q,capabilities:Q.capabilities,theme:Q.theme,transport:q,destroy:()=>U?.disconnect()}}var M2=()=>{};function l0($){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 $}function _2(){function $(){let Z=document.body.getAttribute("data-vscode-theme-kind");if(!Z)return;let q=Z.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",q)}$(),new MutationObserver($).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var p={mount($,J,Z){R0();let q=[];if(J.pipes)for(let[N,E]of Object.entries(J.pipes))N2(N,E,q);let U=new q0(J.state),Q;if(Z?.transport&&"callTool"in Z.transport)Q=Z.transport;else if(Z?.transport)Q=A0(Z.transport);else Q=k0();let Y=Z?.onToast??X2,W=new Y0,H={store:U,scope:{},transport:Q,rerender:()=>D(),onToast:Y,defs:J.defs,destroyRegistry:W};if(u1($,J.theme),J.layout){if(J.layout.preferredHeight!=null)$.style.height=`${J.layout.preferredHeight}px`;if(J.layout.minHeight!=null)$.style.minHeight=`${J.layout.minHeight}px`;if(J.layout.maxHeight!=null)$.style.maxHeight=`${J.layout.maxHeight}px`,$.style.overflow="auto"}let X=[];if(J.stylesheets)for(let N of J.stylesheets){let E=document.createElement("style");E.textContent=N,E.dataset.prefab="injected",document.head.appendChild(E),X.push(E)}let G;if(J.keyBindings)G=x1(J.keyBindings,async(N)=>{await k(N,{store:U,transport:Q,scope:{},rerender:()=>D(),onToast:Y})});let _,z=Z?.themeToggle??!0;if(z!==!1)_=_0($,typeof z==="object"?z:void 0);function D(){W.flush();let N=$.querySelector(".pf-theme-toggle");$.innerHTML="";let E=w(J.view,H);if($.appendChild(E),N)$.appendChild(N)}return D(),{rerender:()=>D(),update(N){U.merge(N.update.state),D()},store:U,destroy(){W.flush(),_?.(),G?.(),o0();for(let N of X)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 $}},B2=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 N2($,J,Z){if(B2.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 X2($){if(typeof document>"u")return;let J=G2(),Z=document.createElement("div"),q=$.variant??"default";Z.className=`pf-toast${q!=="default"?` pf-toast--${q}`:""}`,Z.setAttribute("data-variant",q),Z.style.marginBottom="8px",Z.style.transition="opacity 0.3s ease";let U=document.createElement("div");if(U.textContent=$.message,U.style.fontWeight="500",Z.appendChild(U),$.description){let Y=document.createElement("div");Y.textContent=$.description,Y.style.fontSize="14px",Y.style.color="var(--muted-foreground, #6b7280)",Z.appendChild(Y)}J.appendChild(Z);let Q=$.duration??4000;setTimeout(()=>{Z.style.opacity="0",setTimeout(()=>Z.remove(),300)},Q)}function G2(){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:f0,mount:p.mount.bind(p),isPrefabData:p.isPrefabData.bind(p),isPrefabUpdate:p.isPrefabUpdate.bind(p),Bridge:t,isIframe:Z0,registerPipe:U0,unregisterPipe:Q0,listPipes:X0,registerComponent:M,createThemeToggle:_0};let J=$.__PREFAB_DATA__;if(J!=null){let Z=document.getElementById("prefab-root");if(Z)p.mount(Z,J)}}})();
14
+ }`}}function o1($,Z){if(!$||typeof document>"u")return;let J=(q)=>{for(let[U,Q]of Object.entries($))if(O2(U,q))q.preventDefault(),Z(Q)};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)}function O2($,Z){let J=$.toLowerCase().split("+").map((Q)=>Q.trim()),q=J[J.length-1],U=new Set(J.slice(0,-1));if(U.has("ctrl")!==(Z.ctrlKey||Z.metaKey))return!1;if(U.has("shift")!==Z.shiftKey)return!1;if(U.has("alt")!==Z.altKey)return!1;return Z.key.toLowerCase()===q}var i1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"/></svg>',r1='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"/></svg>',n1={"top-right":"top: 8px; right: 8px;","top-left":"top: 8px; left: 8px;","bottom-right":"bottom: 8px; right: 8px;","bottom-left":"bottom: 8px; left: 8px;"};function T2($,Z){try{let q=localStorage.getItem(Z);if(q==="light"||q==="dark")return q}catch{}let J=$.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(J==="light"||J==="dark")return J;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function X0($,Z){if(typeof document>"u")return()=>{};let J=Z?.position??"top-right",q=Z?.storageKey??"prefab-theme",U=Z?.syncDocument??!0,Q=getComputedStyle($).position;if(Q==="static"||Q==="")$.style.position="relative";let Y=document.createElement("button");Y.className="pf-theme-toggle",Y.setAttribute("aria-label","Toggle theme"),Y.setAttribute("title","Toggle light/dark"),Object.assign(Y.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let W=n1[J]??n1["top-right"];for(let M of W.split(";")){let[B,z]=M.split(":").map((E)=>E.trim());if(B&&z)Y.style.setProperty(B,z)}Y.addEventListener("mouseenter",()=>{Y.style.opacity="1"}),Y.addEventListener("mouseleave",()=>{Y.style.opacity="0.7"});function H(M){if($.setAttribute("data-theme",M),U)document.documentElement.setAttribute("data-theme",M);Y.innerHTML=M==="dark"?r1:i1;try{localStorage.setItem(q,M)}catch{}}let X=T2($,q);H(X),Y.addEventListener("click",()=>{let M=$.getAttribute("data-theme")??"dark";H(M==="dark"?"light":"dark")}),$.appendChild(Y);let N;if(U)N=new MutationObserver((M)=>{for(let B of M)if(B.type==="attributes"&&B.attributeName==="data-theme"){let z=document.documentElement.getAttribute("data-theme");if((z==="light"||z==="dark")&&z!==$.getAttribute("data-theme")){$.setAttribute("data-theme",z),Y.innerHTML=z==="dark"?r1:i1;try{localStorage.setItem(q,z)}catch{}}}}),N.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{N?.disconnect(),Y.remove()}}function S0($){let Z=$?.baseUrl??(typeof window<"u"?window.location.origin:""),J={"Content-Type":"application/json",...$?.headers},q=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(U,Q){let Y=await q(`${Z}/mcp/tools/call`,{method:"POST",headers:J,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:U,arguments:Q}})});if(!Y.ok)throw Error(`MCP tool call failed: ${Y.status} ${Y.statusText}`);let W=await Y.json();if(W.error)throw Error(W.error.message??"MCP tool call returned error");let H=W.result?.content??W.content??[];for(let X of H)if(X.type==="text"&&X.text!==void 0){try{let N=JSON.parse(X.text);if(typeof N==="object"&&N!==null&&"$prefab"in N)return N;return N}catch{}return X.text}return W.result??W},async sendMessage(U){await q(`${Z}/mcp/messages`,{method:"POST",headers:J,body:JSON.stringify({message:U})})}}}function w0(){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 V2($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class e{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;_hostSupportsSubscriptions=!1;constructor($="*"){this.hostOrigin=$}connect(){if(typeof window>"u")return;let $=I2();if($)this.postFn=(J)=>$.postMessage(J);let Z=(J)=>{if(this.hostOrigin!=="*"&&J.origin!==this.hostOrigin)return;let q=J.data;if(V2(q)){this.handleJsonRpc(q);return}let U=q;if(!U?.type.startsWith("prefab:"))return;if(U.type==="prefab:tool-call-response"&&U.id){let Y=this.pending.get(U.id);if(Y){if(this.pending.delete(U.id),U.payload?.error!=null)Y.reject(Error(U.payload.error));else Y.resolve(U.payload?.result);return}}let Q=this.listeners.get(U.type);if(Q)for(let Y of Q)Y(U.payload??{})};window.addEventListener("message",Z),this.cleanup=()=>window.removeEventListener("message",Z)}async initialize($){try{return await Promise.any([this.initPrefab($),this.initJsonRpc($)])}catch(Z){let J=Z instanceof AggregateError?Z.errors.map((q)=>q.message).join("; "):String(Z);throw Error(`Bridge init failed — no host responded. Tried: ${J}`,{cause:Z})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:$});else this.sendPrefab("prefab:request-mode",{mode:$})}openLink($,Z){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:Z});else this.sendPrefab("prefab:open-link",{url:$,target:Z})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}setupAutoResize($){if(typeof ResizeObserver>"u")return P2;let Z=-1,J=-1,q=(Y,W)=>{if(Y===Z&&W===J)return;if(Z=Y,J=W,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:Y,height:W});else this.sendPrefab("prefab:size-changed",{width:Y,height:W})},U=new ResizeObserver((Y)=>{for(let W of Y)if(W.borderBoxSize.length){let H=W.borderBoxSize[0];q(Math.ceil(H.inlineSize),Math.ceil(H.blockSize))}else{let H=W.target.getBoundingClientRect();q(Math.ceil(H.width),Math.ceil(H.height))}});U.observe($);let Q=$.getBoundingClientRect();return q(Math.ceil(Q.width),Math.ceil(Q.height)),()=>U.disconnect()}notifyPreferredSize($){if(this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/preferred-size",$);else this.sendPrefab("prefab:preferred-size",$)}subscribe($,Z){let J=(q)=>{if(q.uri!==$)return;Z(q.contents??q.data??q)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",J),this.sendRpcRequest("resources/subscribe",{uri:$});else this.on("prefab:resource-updated",J),this.sendPrefab("prefab:subscribe",{uri:$});return()=>{if(this.off("prefab:resource-updated",J),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:$});else this.sendPrefab("prefab:unsubscribe",{uri:$})}}get supportsSubscriptions(){return this._hostSupportsSubscriptions}on($,Z){if(!this.listeners.has($))this.listeners.set($,new Set);let J=this.listeners.get($);if(J)J.add(Z)}off($,Z){this.listeners.get($)?.delete(Z)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,$]of this.pending)$.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,$]of this.rpcPending)$.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab($){return new Promise((Z,J)=>{let q=!1,U=(Q)=>{if(q)return;q=!0,this.off("prefab:init-response",U),this.protocol="prefab";let Y=Q.capabilities;this._hostSupportsSubscriptions=Y?.subscriptions===!0,Z(Q)};this.on("prefab:init-response",U),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!q)q=!0,this.off("prefab:init-response",U),J(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,Z)=>{let J=`tc-${++this.callIdCounter}`;return new Promise((q,U)=>{this.pending.set(J,{resolve:q,reject:U}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:Z},J),setTimeout(()=>{if(this.pending.has(J))this.pending.delete(J),U(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()},subscribe:($,Z)=>{return this.subscribe($,Z)},capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendPrefab($,Z,J){if(typeof window>"u")return;let q=window.parent!==window?window.parent:window,U={type:$,payload:Z,id:J};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 Z=$.method,J=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(Z){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:J.arguments??J});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:J.arguments??J});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:J});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",J);break;case"ui/notifications/host-context-changed":{let q={};if(typeof J.theme==="string")q.colorScheme=J.theme;if(typeof J.styles==="object"&&J.styles!==null){let U=J.styles;if(U.variables)q.variables=U.variables;if(typeof U.css?.fonts==="string")q.fontCss=U.css.fonts}this.dispatch("prefab:theme-update",q);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",J);break;case"ui/notifications/resource-updated":case"notifications/resources/updated":this.dispatch("prefab:resource-updated",J);break}}initJsonRpc($){return new Promise((Z,J)=>{let q=++this.rpcIdCounter,U=!1;this.rpcPending.set(q,{resolve:(Q)=>{if(U)return;U=!0,this.protocol="jsonrpc";let Y=Q??{},W=Y.hostInfo??{},H=Y.hostContext??{},X=Y.hostCapabilities??{},N;if(typeof H.theme==="string"||typeof H.styles==="object"){if(N={},typeof H.theme==="string")N.colorScheme=H.theme;if(typeof H.styles==="object"&&H.styles!==null){let B=H.styles;if(B.variables)N.variables=B.variables;if(typeof B.css?.fonts==="string")N.fontCss=B.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let M=X.resources;this._hostSupportsSubscriptions=X.subscriptions===!0||M?.subscribe===!0,Z({hostName:W.name,hostVersion:W.version,capabilities:{toast:!0,navigation:X.openLinks!=null,messaging:!0,displayModes:H.availableDisplayModes??[]},theme:N,toolInput:void 0,meta:H})},reject:(Q)=>{if(U)return;U=!0,J(Q)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:"0.2"},appCapabilities:{...$.displayModes&&{availableDisplayModes:$.displayModes}}}}),setTimeout(()=>{if(!U)U=!0,this.rpcPending.delete(q),J(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,Z)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:Z})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})},subscribe:($,Z)=>{return this.subscribe($,Z)},capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendRpcRequest($,Z){let J=++this.rpcIdCounter;return new Promise((q,U)=>{this.rpcPending.set(J,{resolve:q,reject:U}),this.postJsonRpc({jsonrpc:"2.0",id:J,method:$,params:Z}),setTimeout(()=>{if(this.rpcPending.has(J))this.rpcPending.delete(J),U(Error(`JSON-RPC '${$}' timed out`))},30000)})}sendRpcNotification($,Z){this.postJsonRpc({jsonrpc:"2.0",method:$,params:Z})}postJsonRpc($){if(typeof window>"u")return;if($.id!=null&&typeof $.method==="string")this.sentRpcIds.add($.id);if(this.postFn)this.postFn($);else(window.parent!==window?window.parent:window).postMessage($,this.hostOrigin)}dispatch($,Z){let J=this.listeners.get($);if(J)for(let q of J)q(Z)}}var P2=()=>{};function _0($,Z){if(Z.variables)for(let[J,q]of Object.entries(Z.variables))$.style.setProperty(J.startsWith("--")?J:`--${J}`,q);if(Z.colorScheme&&Z.colorScheme!=="auto")$.setAttribute("data-theme",Z.colorScheme);if(Z.fontCss)R2(Z.fontCss)}function R2($){if(document.getElementById("__prefab-host-fonts"))return;let J=document.createElement("style");J.id="__prefab-host-fonts",J.textContent=$,document.head.appendChild(J)}function q0(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function I2(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let Z=$.acquireVsCodeApi();if(Z!==null&&typeof Z==="object"&&"postMessage"in Z)return Z}catch{return}return}async function C0($){f0();let Z=$?.mode??"auto",J=Z==="bridge"||Z==="auto"&&q0(),q,U,Q={capabilities:{}};if(J)U=new e($?.hostOrigin),U.connect(),Q=await U.initialize($?.capabilities??{toolInput:!0}),q=U.createTransport();else if($?.transport)q=S0($.transport);else q=w0();if(Q.theme&&typeof document<"u")_0(document.documentElement,Q.theme);if(typeof document<"u"&&!U)k2();let Y,W,H,X,N=Q.toolInput,M;if(U)U.on("prefab:tool-input",(E)=>{let K=E.args??E;if(Y)Y(K);else N=K}),U.on("prefab:tool-result",(E)=>{let K=E.result??E;if(W)W(K);else M=K}),U.on("prefab:tool-cancelled",()=>{H?.()}),U.on("prefab:tool-input-partial",(E)=>{X?.(E.args??E)}),U.on("prefab:theme-update",(E)=>{if(typeof document<"u")_0(document.documentElement,E)});function B(E,...K){let D=o0(E),O=new U0,A={store:O,scope:{},transport:q,rerender:()=>R(),onToast:void 0};function R(){D.innerHTML="";for(let L of K)D.appendChild(w(L,A))}return R(),{rerender:R,store:O,destroy:()=>{D.innerHTML=""}}}return{callTool:(E,K={})=>q.callTool(E,K),sendMessage:(E)=>q.sendMessage(E),onToolInput:(E)=>{if(Y=E,N){let K=N;N=void 0,queueMicrotask(()=>E(K))}},onToolResult:(E)=>{if(W=E,M!==void 0){let K=M;M=void 0,queueMicrotask(()=>E(K))}},onToolCancelled:(E)=>{H=E},onToolInputPartial:(E)=>{X=E},render:B,mount:(E,K,D)=>{let O=o0(E);return p.mount(O,K,{transport:q,...D})},requestMode:(E)=>U?.requestMode(E),openLink:(E,K)=>{if(U)U.openLink(E,K);else if(typeof window<"u")window.open(E,K??"_blank")},updateContext:(E)=>{if(U)U.updateContext(E)},setupAutoResize:(E)=>{if(!U)return A2;let K=typeof E==="string"?o0(E):E;return U.setupAutoResize(K)},notifyPreferredSize:(E)=>{if(U)U.notifyPreferredSize(E)},host:Q,capabilities:Q.capabilities,theme:Q.theme,transport:q,destroy:()=>U?.disconnect()}}var A2=()=>{};function o0($){if(typeof $==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let Z=document.querySelector($);if(!Z)throw Error(`Element not found: ${$}`);return Z}return $}function k2(){function $(){let J=document.body.getAttribute("data-vscode-theme-kind");if(!J)return;let q=J.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",q)}$(),new MutationObserver($).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var p={mount($,Z,J){f0();let q=[];if(Z.pipes)for(let[E,K]of Object.entries(Z.pipes))S2(E,K,q);let U=new U0(Z.state),Q;if(J?.transport&&"callTool"in J.transport)Q=J.transport;else if(J?.transport)Q=S0(J.transport);else Q=w0();let Y=J?.onToast??w2,W=new W0,H={store:U,scope:{},transport:Q,rerender:()=>z(),onToast:Y,defs:Z.defs,destroyRegistry:W};if(a1($,Z.theme),Z.layout){if(Z.layout.preferredHeight!=null)$.style.height=`${Z.layout.preferredHeight}px`;if(Z.layout.minHeight!=null)$.style.minHeight=`${Z.layout.minHeight}px`;if(Z.layout.maxHeight!=null)$.style.maxHeight=`${Z.layout.maxHeight}px`,$.style.overflow="auto"}let X=[];if(Z.stylesheets)for(let E of Z.stylesheets){let K=document.createElement("style");K.textContent=E,K.dataset.prefab="injected",document.head.appendChild(K),X.push(K)}let N;if(Z.keyBindings)N=o1(Z.keyBindings,async(E)=>{await k(E,{store:U,transport:Q,scope:{},rerender:()=>z(),onToast:Y})});let M,B=J?.themeToggle??!0;if(B!==!1)M=X0($,typeof B==="object"?B:void 0);function z(){W.flush();let E=$.querySelector(".pf-theme-toggle");$.innerHTML="";let K=w(Z.view,H);if($.appendChild(K),E)$.appendChild(E)}return z(),{rerender:()=>z(),update(E){U.merge(E.update.state),z()},store:U,destroy(){W.flush(),M?.(),N?.(),Q1(),Y1();for(let E of X)E.remove();for(let E of q)Y0(E);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},f2=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 S2($,Z,J){if(f2.has($)){console.warn(`[prefab] wire pipe "${$}" ignored — shadows built-in`);return}try{let q=Function("return ("+Z+")")();if(typeof q!=="function"){console.warn(`[prefab] wire pipe "${$}" — source did not evaluate to a function`);return}Q0($,q),J.push($)}catch(q){console.warn(`[prefab] wire pipe "${$}" — failed to hydrate:`,q)}}function w2($){if(typeof document>"u")return;let Z=C2(),J=document.createElement("div"),q=$.variant??"default";J.className=`pf-toast${q!=="default"?` pf-toast--${q}`:""}`,J.setAttribute("data-variant",q),J.style.marginBottom="8px",J.style.transition="opacity 0.3s ease";let U=document.createElement("div");if(U.textContent=$.message,U.style.fontWeight="500",J.appendChild(U),$.description){let Y=document.createElement("div");Y.textContent=$.description,Y.style.fontSize="14px",Y.style.color="var(--muted-foreground, #6b7280)",J.appendChild(Y)}Z.appendChild(J);let Q=$.duration??4000;setTimeout(()=>{J.style.opacity="0",setTimeout(()=>J.remove(),300)},Q)}function C2(){let Z=document.getElementById("prefab-toast-container");if(!Z)Z=document.createElement("div"),Z.id="prefab-toast-container",Z.style.position="fixed",Z.style.bottom="16px",Z.style.right="16px",Z.style.zIndex="9999",Z.style.maxWidth="400px",document.body.appendChild(Z);return Z}if(typeof window<"u"){let $=window;$.PrefabRenderer=p,$.prefab={app:C0,mount:p.mount.bind(p),isPrefabData:p.isPrefabData.bind(p),isPrefabUpdate:p.isPrefabUpdate.bind(p),Bridge:e,isIframe:q0,registerPipe:Q0,unregisterPipe:Y0,listPipes:N0,registerComponent:G,createThemeToggle:X0};let Z=$.__PREFAB_DATA__;if(Z!=null){let J=document.getElementById("prefab-root");if(J)p.mount(J,Z)}}})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maxhealth.tech/prefab",
3
- "version": "0.2.26",
3
+ "version": "0.2.28",
4
4
  "description": "TypeScript declarative UI component library for MCP apps. Wire-compatible with Python prefab-ui.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -35,6 +35,10 @@
35
35
  "import": "./dist/auto/index.js",
36
36
  "types": "./dist/auto/index.d.ts"
37
37
  },
38
+ "./pdf": {
39
+ "import": "./dist/components/pdf/index.js",
40
+ "types": "./dist/components/pdf/index.d.ts"
41
+ },
38
42
  "./prefab.css": "./dist/prefab.css"
39
43
  },
40
44
  "sideEffects": false,
@@ -82,7 +86,8 @@
82
86
  "jiti": "^2.6.1",
83
87
  "typescript": "^6.0.3",
84
88
  "typescript-eslint": "^8.58.2",
85
- "vitepress": "1.6.4"
89
+ "vitepress": "1.6.4",
90
+ "vitepress-plugin-llms": "^1.12.2"
86
91
  },
87
92
  "dependencies": {}
88
93
  }