@maxhealth.tech/prefab 0.3.7 → 0.3.9

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 (72) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +7 -5
  3. package/dist/app.d.ts +19 -2
  4. package/dist/app.d.ts.map +1 -1
  5. package/dist/app.js +1 -8
  6. package/dist/app.js.map +1 -1
  7. package/dist/components/charts/index.d.ts +4 -0
  8. package/dist/components/charts/index.d.ts.map +1 -1
  9. package/dist/components/charts/index.js +2 -0
  10. package/dist/components/charts/index.js.map +1 -1
  11. package/dist/components/form/index.d.ts +1 -6
  12. package/dist/components/form/index.d.ts.map +1 -1
  13. package/dist/components/form/index.js +7 -37
  14. package/dist/components/form/index.js.map +1 -1
  15. package/dist/components/interactive/index.d.ts +5 -1
  16. package/dist/components/interactive/index.d.ts.map +1 -1
  17. package/dist/components/interactive/index.js +5 -2
  18. package/dist/components/interactive/index.js.map +1 -1
  19. package/dist/components/media/index.d.ts +20 -2
  20. package/dist/components/media/index.d.ts.map +1 -1
  21. package/dist/components/media/index.js +13 -1
  22. package/dist/components/media/index.js.map +1 -1
  23. package/dist/components/table/index.d.ts +5 -1
  24. package/dist/components/table/index.d.ts.map +1 -1
  25. package/dist/components/table/index.js +5 -2
  26. package/dist/components/table/index.js.map +1 -1
  27. package/dist/core/component-types.d.ts +15 -0
  28. package/dist/core/component-types.d.ts.map +1 -0
  29. package/dist/core/component-types.js +135 -0
  30. package/dist/core/component-types.js.map +1 -0
  31. package/dist/core/component.d.ts +11 -0
  32. package/dist/core/component.d.ts.map +1 -1
  33. package/dist/core/component.js +22 -9
  34. package/dist/core/component.js.map +1 -1
  35. package/dist/core/escape.d.ts +21 -0
  36. package/dist/core/escape.d.ts.map +1 -0
  37. package/dist/core/escape.js +30 -0
  38. package/dist/core/escape.js.map +1 -0
  39. package/dist/core/validate.d.ts.map +1 -1
  40. package/dist/core/validate.js +6 -36
  41. package/dist/core/validate.js.map +1 -1
  42. package/dist/core/version.d.ts +1 -1
  43. package/dist/core/version.js +1 -1
  44. package/dist/mcp/display.d.ts +11 -2
  45. package/dist/mcp/display.d.ts.map +1 -1
  46. package/dist/mcp/display.js.map +1 -1
  47. package/dist/mcp/resource.d.ts.map +1 -1
  48. package/dist/mcp/resource.js +3 -9
  49. package/dist/mcp/resource.js.map +1 -1
  50. package/dist/prefab.css +4 -0
  51. package/dist/renderer/components/data.js +2 -2
  52. package/dist/renderer/components/data.js.map +1 -1
  53. package/dist/renderer/components/form.js +41 -15
  54. package/dist/renderer/components/form.js.map +1 -1
  55. package/dist/renderer/components/interactive.js +17 -4
  56. package/dist/renderer/components/interactive.js.map +1 -1
  57. package/dist/renderer/components/media.d.ts +7 -0
  58. package/dist/renderer/components/media.d.ts.map +1 -1
  59. package/dist/renderer/components/media.js +63 -2
  60. package/dist/renderer/components/media.js.map +1 -1
  61. package/dist/renderer/components/table.js +1 -1
  62. package/dist/renderer/components/table.js.map +1 -1
  63. package/dist/renderer/components/typography.d.ts.map +1 -1
  64. package/dist/renderer/components/typography.js +1 -8
  65. package/dist/renderer/components/typography.js.map +1 -1
  66. package/dist/renderer/engine.d.ts +8 -0
  67. package/dist/renderer/engine.d.ts.map +1 -1
  68. package/dist/renderer/engine.js +10 -0
  69. package/dist/renderer/engine.js.map +1 -1
  70. package/dist/renderer.auto.min.js +10 -10
  71. package/dist/renderer.min.js +7 -7
  72. package/package.json +7 -1
@@ -1,16 +1,16 @@
1
- (()=>{var j0={silent:0,error:1,warn:2,info:3,debug:4},k0="warn";function A0($){k0=$}function l1($){let Z=$?`[prefab:${$}]`:"[prefab]",J=(q,Q,Y)=>{if(j0[q]>j0[k0])return;console[q](`${Z} ${Q}`,...Y)};return{error:(q,...Q)=>J("error",q,Q),warn:(q,...Q)=>J("warn",q,Q),info:(q,...Q)=>J("info",q,Q),debug:(q,...Q)=>J("debug",q,Q)}}var b=l1();class K1{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return C8(this.data,$)}getAll(){return this.data}set($,Z){S0(this.data,$,Z),this.notify($)}toggle($){let Z=this.get($),J=Z==null||Z===!1||Z===0||Z==="";this.set($,J)}append($,Z,J){let q=this.get($);if(!Array.isArray(q)){this.set($,[Z]);return}if(J!==void 0)q.splice(J,0,Z);else q.push(Z);this.notify($)}pop($,Z){let J=this.get($);if(!Array.isArray(J))return;if(typeof Z==="number")J.splice(Z,1);else{let q=J.indexOf(Z);if(q>=0)J.splice(q,1)}this.notify($)}merge($){for(let[Z,J]of Object.entries($))S0(this.data,Z,J);for(let Z of Object.keys($))this.notify(Z)}subscribe($,Z){if(!this.subscribers.has($))this.subscribers.set($,new Set);return this.subscribers.get($)?.add(Z),()=>this.subscribers.get($)?.delete(Z)}subscribeAll($){return this.globalSubscribers.add($),()=>this.globalSubscribers.delete($)}notify($){this.generation++;let Z=$.split(".");for(let J=1;J<=Z.length;J++){let q=Z.slice(0,J).join("."),Q=this.subscribers.get(q);if(Q)Q.forEach((Y)=>Y())}this.globalSubscribers.forEach((J)=>J())}}function C8($,Z){let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}var b8=new Set(["__proto__","constructor","prototype"]);function S0($,Z,J){let q=Z.split(".");if(q.some((Y)=>b8.has(Y))){b.warn(`Blocked prototype pollution attempt: ${Z}`);return}let Q=$;for(let Y=0;Y<q.length-1;Y++){let U=q[Y];if(Q[U]==null||typeof Q[U]!=="object")Q[U]={};Q=Q[U]}Q[q[q.length-1]]=J}var _1=new Map;function i1($,Z){if(_1.has($)&&_1.get($)!==Z)b.warn(`pipe "${$}" re-registered`);_1.set($,Z)}function s1($){return _1.delete($)}function f0(){return[..._1.keys()]}function D1($){return _1.get($)}function C($){if($==null)return"";if(typeof $==="string")return $;if(typeof $==="number"||typeof $==="boolean"||typeof $==="bigint")return String($);if(typeof $==="symbol")return $.description??"";if(typeof $==="function")return $.name;if($ instanceof Date)return Number.isNaN($.getTime())?"":$.toISOString();if(Array.isArray($))return $.map(C).join(", ");try{return JSON.stringify($)??""}catch{return""}}var w0=-1,n1=new Map,y8=/\{\{\s*(.+?)\s*\}\}/g;function t($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function e($,Z,J){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&p8(q,"{{")===1){let Q=q.slice(2,-2).trim();return C0(Q,Z,J)}return $.replace(y8,(Q,Y)=>{let U=C0(Y.trim(),Z,J);return C(U)})}function C0($,Z,J){let[q,...Q]=x8($),Y=a(q.trim(),Z,J);for(let U of Q)Y=m8(U.trim(),Y,Z,J);return Y}function a($,Z,J){let q=g8($);if(q>=0){let U=$.slice(0,q).trim(),H=$.slice(q+1),W=u8(H);if(W>=0){let _=H.slice(0,W).trim(),z=H.slice(W+1).trim(),X=a(U,Z,J);return X!==null&&X!==void 0&&X!==!1&&X!==0&&X!==""?a(_,Z,J):a(z,Z,J)}}let Q=O1($,"||");if(Q>=0){let U=a($.slice(0,Q).trim(),Z,J);return U!==null&&U!==void 0&&U!==!1&&U!==0&&U!==""?U:a($.slice(Q+2).trim(),Z,J)}let Y=O1($,"&&");if(Y>=0){let U=a($.slice(0,Y).trim(),Z,J);if(U===null||U===void 0||U===!1||U===0||U==="")return U;return a($.slice(Y+2).trim(),Z,J)}for(let[U,H]of h8){let W=O1($,U);if(W>=0){let _=a($.slice(0,W).trim(),Z,J),z=a($.slice(W+U.length).trim(),Z,J);return H(_,z)}}if($.startsWith("!")){let U=a($.slice(1).trim(),Z,J);return U===null||U===void 0||U===!1||U===0||U===""}for(let[U,H]of v8){let W=O1($,U);if(W>=0){let _=a($.slice(0,W).trim(),Z,J),z=a($.slice(W+U.length).trim(),Z,J);return H(Number(_),Number(z))}}if($==="true")return!0;if($==="false")return!1;if($==="null"||$==="undefined")return null;if(/^-?\d+(\.\d+)?$/.test($))return Number($);if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);if(J&&$.startsWith("$")){let U=$.indexOf(".");if(U>=0){let H=$.slice(0,U),W=$.slice(U+1),_=J[H];return T1(_,W)}return J[$]}if(J){let U=$.split(".")[0];if(U in J)return T1(J[U],$.includes(".")?$.slice(U.length+1):"")}return Z.get($)}function m8($,Z,J,q){let Q=$.indexOf(":"),Y=Q>=0?$.slice(0,Q).trim():$,U=Q>=0?$.slice(Q+1).trim():void 0,H=U?r1(U):void 0;switch(Y){case"find":{if(!Array.isArray(Z)||!U)return;let W=b0(U);if(W.length<2)return;let _=r1(W[0]),z=W[1].trim(),X;if(z.startsWith("'")&&z.endsWith("'")||z.startsWith('"')&&z.endsWith('"'))X=z.slice(1,-1);else if(J){if(q&&z.startsWith("$")){let M=z.indexOf(".");if(M>=0){let E=z.slice(0,M);if(E in q)X=T1(q[E],z.slice(M+1))}else if(z in q)X=q[z]}if(X===void 0&&!(q&&z.startsWith("$")))if(q){let M=z.split(".")[0];X=M in q?T1(q[M],z.includes(".")?z.slice(M.length+1):""):J.get(z)}else X=J.get(z)}else X=z;if(X==null)return;let B=J?.generation??0;if(B!==w0)n1=new Map,w0=B;let K=n1.get(Z);if(!K)K=new Map,n1.set(Z,K);let L=K.get(_);if(!L){L=new Map;for(let M of Z)if(M!=null&&typeof M==="object"){let E=M[_];if(E!=null)L.set(C(E),M)}K.set(_,L)}return L.get(C(X))}case"dot":{if(Z==null||typeof Z!=="object"||typeof H!=="string")return;return Z[H]}case"length":return Array.isArray(Z)?Z.length:typeof Z==="string"?Z.length:0;case"upper":return typeof Z==="string"?Z.toUpperCase():Z;case"lower":return typeof Z==="string"?Z.toLowerCase():Z;case"truncate":if(typeof Z==="string"&&typeof H==="number")return Z.slice(0,H);return Z;case"join":return Array.isArray(Z)?Z.join(typeof H==="string"?H:", "):Z;case"first":return Array.isArray(Z)?Z[0]:Z;case"last":return Array.isArray(Z)?Z[Z.length-1]:Z;case"abs":return Math.abs(Number(Z));case"round":return typeof H==="number"?Number(Number(Z).toFixed(H)):Math.round(Number(Z));case"number":return typeof H==="number"?Number(Number(Z).toFixed(H)):Number(Z);case"currency":{let W=typeof H==="string"?H:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:W}).format(Number(Z))}catch{return Z}}case"percent":return typeof H==="number"?`${(Number(Z)*100).toFixed(H)}%`:`${Math.round(Number(Z)*100)}%`;case"compact":{let W=typeof H==="number"?H:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:W}).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 W=Number(Z),_=typeof H==="string"?H:"";return W===1?_:`${_}s`}case"default":return Z==null||Z===""?H:Z;case"selectattr":return Array.isArray(Z)&&typeof H==="string"?Z.filter((W)=>W!=null&&typeof W==="object"&&Boolean(W[H])):Z;case"rejectattr":return Array.isArray(Z)&&typeof H==="string"?Z.filter((W)=>{if(W==null||typeof W!=="object")return!1;let _=W[H];return _==null||_===!1||_===0||_===""}):Z;default:{let W=D1(Y);if(W){let _=U?b0(U).map(r1):[];return W(Z,..._)}return Z}}}var h8=[["!==",($,Z)=>$!==Z],["===",($,Z)=>$===Z],["!=",($,Z)=>$!=Z],["==",($,Z)=>$==Z],[">=",($,Z)=>Number($)>=Number(Z)],["<=",($,Z)=>Number($)<=Number(Z)],[">",($,Z)=>Number($)>Number(Z)],["<",($,Z)=>Number($)<Number(Z)]],v8=[[" + ",($,Z)=>$+Z],[" - ",($,Z)=>$-Z],[" * ",($,Z)=>$*Z],[" / ",($,Z)=>Z!==0?$/Z:0],[" % ",($,Z)=>Z!==0?$%Z:0]];function O1($,Z){let J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J&&$.slice(q,q+Z.length)===Z)return q}return-1}function g8($){let Z=0,J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J){if(Q==="(")Z++;else if(Q===")")Z--;else if(Q==="?"&&Z===0)return q}}return-1}function u8($){let Z=0,J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J){if(Q==="?"||Q==="(")Z++;else if(Q===")")Z--;else if(Q===":"&&Z===0)return q}}return-1}function x8($){let Z=[],J="",q=null;for(let Q=0;Q<$.length;Q++){let Y=$[Q];if(Y==="'"||Y==='"')q=q===Y?null:q??Y;if(Y==="|"&&!q)if($[Q+1]==="|")J+="||",Q++;else Z.push(J),J="";else J+=Y}return Z.push(J),Z}function r1($){let Z=$.replace(/^['"]|['"]$/g,"");if(Z==="true")return!0;if(Z==="false")return!1;let J=Number(Z);return isNaN(J)?Z:J}function b0($){let Z=[],J="",q=null;for(let Q of $){if(Q==="'"||Q==='"')q=q===Q?null:q??Q;if(Q===","&&!q)Z.push(J),J="";else J+=Q}return Z.push(J),Z}function T1($,Z){if(!Z)return $;let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}function p8($,Z){let J=0,q=0;while((q=$.indexOf(Z,q))!==-1)J++,q+=Z.length;return J}function I1($){return $.replace(/_([a-z])/g,(Z,J)=>J.toUpperCase())}function o1($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:I1(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?o1(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=o1(q);else Z[Q]=q}return Z}async function h($,Z){let J=Array.isArray($)?$:[$];for(let q of J)await c8(q,Z)}function v($,Z){$.catch((J)=>b.error(`${Z} failed:`,J))}async function R1($,Z,J,q){if(J!=null)b.debug(`${$} failed:`,Z),await W1(J,q,{$error:Z});else b.warn(`${$} failed:`,Z)}async function c8($,Z){let J=o1($),q=J.action;switch(q){case"setState":{d8(J,Z);return}case"toggleState":{l8(J,Z);return}case"appendState":{i8(J,Z);return}case"popState":{s8(J,Z);return}case"showToast":{n8(J,Z);return}case"closeOverlay":{r8(J,Z);return}case"openLink":{a8(J);return}case"setInterval":{t8(J,Z);return}case"toolCall":case"callTool":return e8(J,Z);case"sendMessage":return $4(J,Z);case"updateContext":{Z4(J,Z);return}case"fetch":return J4(J,Z);case"openFilePicker":{q4(J,Z);return}case"callHandler":return Q4(J,Z);case"requestDisplayMode":{Y4(J,Z);return}case"subscribe":{W4(J,Z);return}case"unsubscribe":{X4(J);return}default:b.warn(`Unknown action: ${q}`)}}function d8($,Z){let{key:J,value:q}=$;if(t(q))q=e(q,Z.store,Z.scope);Z.store.set(J,q),Z.rerender(),W1($.onSuccess,Z)}function l8($,Z){Z.store.toggle($.key),Z.rerender()}function i8($,Z){let J=$.value??$.item;if(t(J))J=e(J,Z.store,Z.scope);Z.store.append($.key,J,$.index),Z.rerender()}function s8($,Z){Z.store.pop($.key,$.index),Z.rerender()}function n8($,Z){Z.onToast?.({message:P1($.message,Z),description:$.description!=null?P1($.description,Z):void 0,variant:$.variant,duration:$.duration})}function r8($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function a8($){if(typeof window<"u"){let Z=$.url;if(!Z){b.warn("openLink: missing url");return}if(!v0(Z)){b.warn(`Blocked unsafe URL scheme: ${Z}`);return}window.open(Z,$.target??"_blank")}}var V1=new Set,o8=20,y0=100;function t8($,Z){let J=Math.max($.intervalMs,y0),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(V1.size>=o8){b.warn("Max intervals reached, ignoring new setInterval");return}let Q=globalThis.setInterval(()=>v(h(q,Z),"interval action"),J);V1.add(Q)}function m0(){for(let $ of V1)globalThis.clearInterval($);V1.clear()}async function e8($,Z){if(!Z.transport){b.warn("No MCP transport configured for toolCall");return}let J=$.tool,q=t1($.arguments,Z);try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=j1(Q);if(Y&&Z.remount)Z.remount(Y);else k1(Q,Z),Z.rerender();await W1($.onSuccess,Z,{$result:Q})}catch(Q){await R1("toolCall",Q,$.onError,Z)}}async function $4($,Z){if(!Z.transport){b.warn("No MCP transport configured for sendMessage");return}await Z.transport.sendMessage(P1($.message,Z))}function Z4($,Z){let J=$.context;if(J!=null)Z.store.merge(J),Z.rerender()}async function J4($,Z){let J=P1($.url,Z);if(!v0(J)){b.warn(`Blocked unsafe URL in fetch: ${J}`);return}let q=$.method??"GET",Q=$.headers,Y=$.body!==void 0?JSON.stringify($.body):void 0;try{let U=await globalThis.fetch(J,{method:q,headers:{"Content-Type":"application/json",...Q},...Y&&{body:Y}}),H=await U.json().catch(()=>U.text());if($.resultKey!=null)Z.store.set($.resultKey,H);let W=j1(H);if(W&&Z.remount)Z.remount(W);else k1(H,Z),Z.rerender();await W1($.onSuccess,Z,{$result:H})}catch(U){await R1("fetch",U,$.onError,Z)}}function q4($,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(),W1($.onSuccess,Z,{$result:q})}),J.click()}async function Q4($,Z){let J=$.handler,q=t1($.arguments,Z);if(!Z.transport){b.warn(`No transport configured for callHandler: ${J}`);return}try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=j1(Q);if(Y&&Z.remount)Z.remount(Y);else k1(Q,Z),Z.rerender();await W1($.onSuccess,Z,{$result:Q})}catch(Q){await R1("callHandler",Q,$.onError,Z)}}function Y4($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var Q1=new Map,U4=50,H4=2000;function W4($,Z){let{uri:J,stateKey:q}=$;if(!J||!q){b.warn("subscribe: missing uri or stateKey");return}if(Q1.has(J))return;if(Q1.size>=U4){b.warn("Max subscriptions reached, ignoring new subscribe");return}let Q=(X)=>{let B=j1(X);if(B&&Z.remount)Z.remount(B);else{if(!k1(X,Z))Z.store.set(q,X);Z.rerender()}W1($.onData,Z,{$data:X})};if(Z.transport?.subscribe&&Z.transport.capabilities?.subscriptions){let X=Z.transport.subscribe(J,Q);Q1.set(J,X);return}let Y=$.fallbackTool,U=$.fallbackInterval??H4;if(!Y){b.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!Z.transport){b.warn("No MCP transport configured for subscribe fallback");return}let H=$.fallbackArgs??{},W=Math.max(U,y0),_=Z.transport,z=globalThis.setInterval(()=>{(async()=>{try{let X=t1(H,Z),B=await _.callTool(Y,X);Q(B)}catch(X){R1("subscribe",X,$.onError,Z)}})()},W);Q1.set(J,()=>globalThis.clearInterval(z))}function X4($){let Z=$.uri;if(!Z){b.warn("unsubscribe: missing uri");return}let J=Q1.get(Z);if(J)J(),Q1.delete(Z)}function h0(){for(let[$,Z]of Q1)try{Z()}catch(J){b.warn(`Error cleaning up subscription '${$}':`,J)}Q1.clear()}function j1($){if($==null||typeof $!=="object")return null;let Z=$;if("$prefab"in Z&&"view"in Z)return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"){let q=J;if("$prefab"in q&&"view"in q)return q}}if("content"in Z&&Array.isArray(Z.content)){for(let J of Z.content)if(J.type==="text"&&typeof J.text==="string")try{let q=JSON.parse(J.text);if(q!=null&&typeof q==="object"){let Q=q;if("$prefab"in Q&&"view"in Q)return Q}}catch{}}return null}function G4($){if($==null||typeof $!=="object")return null;let Z=$;if(a1(Z))return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"&&a1(J))return J}if("content"in Z&&Array.isArray(Z.content)){for(let J of Z.content)if(J.type==="text"&&typeof J.text==="string")try{let q=JSON.parse(J.text);if(q!=null&&typeof q==="object"&&a1(q))return q}catch{}}return null}function a1($){if(!("$prefab"in $)||!("update"in $))return!1;let Z=$.update;return Z!=null&&typeof Z==="object"&&"state"in Z}function k1($,Z){let J=G4($);if(!J)return!1;let q=J.update;if(Z.store.merge(q.state),q.actions!=null)v(h(q.actions,Z),"update action");return!0}var B4=/^\s*(javascript|vbscript|data):/i;function v0($){return!B4.test($)}function P1($,Z){if(t($)){let J=e($,Z.store,Z.scope);return C(J)}return C($)}function t1($,Z){if(!$)return{};let J={};for(let[q,Q]of Object.entries($))J[q]=t(Q)?e(Q,Z.store,Z.scope):Q;return J}async function W1($,Z,J){if($==null)return;let q={...Z.scope,...J};await h($,{...Z,scope:q})}function $0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:I1(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?$0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=$0(q);else Z[Q]=q}return Z}class J0{callbacks=[];track($){this.callbacks.push($)}flush(){for(let $ of this.callbacks)try{$()}catch(Z){b.warn("destroy callback error:",Z)}this.callbacks=[]}get size(){return this.callbacks.length}}function M4($){return typeof $==="object"&&"element"in $}var Z0=new Map;function G($,Z){if(Z0.has($))b.warn(`overriding existing renderer for "${$}"`);Z0.set($,Z)}function u($,Z){let J=$0($);if(Z.defs?.[J.type]){let Y={...Z.defs[J.type],...J,type:Z.defs[J.type].type};return u(Y,Z)}let q=Z0.get(J.type),Q;if(q){let Y=q(J,Z);if(M4(Y))Q=Y.element,Z.destroyRegistry?.track(Y.destroy);else Q=Y}else if(Q=document.createElement("div"),Q.setAttribute("data-prefab-type",J.type),J.children)for(let Y of J.children)Q.appendChild(u(Y,Z));if(Q instanceof HTMLElement){if(J.id)Q.id=J.id;if(J.cssClass){let Y=F(J.cssClass,Z);if(Y)Q.className=(Q.className?Q.className+" ":"")+Y}if(J.onClick!=null){if(Q.addEventListener("click",()=>{v(h(J.onClick,l(Z)),"onClick")}),Q.tagName!=="BUTTON"&&Q.tagName!=="A")Q.setAttribute("role","button"),Q.setAttribute("tabindex","0"),Q.addEventListener("keydown",(Y)=>{let U=Y.key;if(U==="Enter"||U===" ")Y.preventDefault(),v(h(J.onClick,l(Z)),"onClick")})}}if(J.onMount){let Y=J.onMount,U=l(Z);queueMicrotask(()=>v(h(Y,U),"onMount"))}return Q}function w($,Z,J){if(!$.children)return;Y1($.children,Z,J)}function Y1($,Z,J){let q=0;while(q<$.length){let Q=$[q];if(Q.type==="If")q=_4($,q,Z,J);else if(Q.type==="Elif"||Q.type==="Else")q++;else Z.appendChild(u(Q,J)),q++}}function _4($,Z,J,q){let Q=!1,Y=Z,U=$[Y];if(g0(U.condition,q))e1(U,J,q),Q=!0;Y++;while(Y<$.length){let H=$[Y];if(H.type==="Elif"){if(!Q&&g0(H.condition,q))e1(H,J,q),Q=!0;Y++}else if(H.type==="Else"){if(!Q)e1(H,J,q);Y++;break}else break}return Y}function g0($,Z){if(!$)return!1;if(t($))return Boolean(e($,Z.store,Z.scope));return Boolean(Z.store.get($))}function e1($,Z,J){if(!$.children)return;Y1($.children,Z,J)}function F($,Z){if(t($)){let J=e($,Z.store,Z.scope);return C(J)}return C($)}function d($,Z){if(t($))return e($,Z.store,Z.scope);return $}function l($){return{store:$.store,transport:$.transport,scope:$.scope,rerender:$.rerender,onToast:$.onToast,remount:$.remount}}function N($,Z){let J=document.createElement($);if(Z)J.className=Z;return J}function q0($,Z){return $.textContent=Z,$}function c0(){G("Column",N4),G("Row",z4),G("Grid",u0),G("GridItem",x0),G("Container",E4),G("Div",p0),G("Span",K4),G("Dashboard",u0),G("DashboardItem",x0),G("Pages",F4),G("Page",p0),G("Detail",L4),G("MasterDetail",D4)}function N4($,Z){let J=N("div","pf-column");J.style.display="flex",J.style.flexDirection="column";let q=A1($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=d0($.align);if($.justify!=null)J.style.justifyContent=l0($.justify);return w($,J,Z),J}function z4($,Z){let J=N("div","pf-row");J.style.display="flex",J.style.flexDirection="row";let q=A1($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=d0($.align);if($.justify!=null)J.style.justifyContent=l0($.justify);if($.wrap===!0)J.style.flexWrap="wrap";return w($,J,Z),J}function u0($,Z){let J=N("div","pf-grid");J.style.display="grid";let q=$.columns??3;J.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let Q=A1($);if(Q!=null)J.style.gap=`${Q*4}px`;return w($,J,Z),J}function x0($,Z){let J=N("div","pf-grid-item");if($.colSpan!=null)J.style.gridColumn=`span ${$.colSpan}`;if($.rowSpan!=null)J.style.gridRow=`span ${$.rowSpan}`;return w($,J,Z),J}function E4($,Z){let J=N("div","pf-container");if(J.style.maxWidth=$.maxWidth??"1200px",J.style.margin="0 auto",$.padding!=null)J.style.padding=`${$.padding*4}px`;return w($,J,Z),J}function p0($,Z){let J=N("div","pf-div");return w($,J,Z),J}function K4($,Z){let J=N("span","pf-span");return w($,J,Z),J}function F4($,Z){let J=N("div","pf-pages");return w($,J,Z),J}function L4($,Z){let J=N("div","pf-detail"),q=$.of!=null?d($.of,Z):void 0;if(q!=null&&q!==""&&q!==!1&&q!==0)w($,J,Z);else if($.empty!=null){let Q=$.empty;J.appendChild(u(Q,Z))}return J}function D4($,Z){let J=N("div","pf-master-detail");J.style.display="flex",J.style.flexDirection="row";let q=A1($);if(q!=null)J.style.gap=`${q*4}px`;let Q=$.masterWidth??"33%",Y=$.children??[];if(Y.length>0){let U=N("div","pf-master-detail-master");U.style.width=Q,U.style.flexShrink="0",U.style.overflow="auto",U.appendChild(u(Y[0],Z)),J.appendChild(U)}if(Y.length>1){let U=N("div","pf-master-detail-detail");U.style.flex="1",U.style.overflow="auto",U.appendChild(u(Y[1],Z)),J.appendChild(U)}return J}var O4=/\bgap-(\d+)\b/;function A1($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let Z=O4.exec($.cssClass);if(Z)return Number(Z[1])}return null}function d0($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function l0($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}function s0(){G("Heading",T4),G("H1",($,Z)=>S1($,Z,"h1")),G("H2",($,Z)=>S1($,Z,"h2")),G("H3",($,Z)=>S1($,Z,"h3")),G("H4",($,Z)=>S1($,Z,"h4")),G("Text",I4),G("P",V4),G("Lead",($,Z)=>N1($,Z,"p","pf-lead")),G("Large",($,Z)=>N1($,Z,"span","pf-large")),G("Small",($,Z)=>N1($,Z,"small","pf-small")),G("Muted",($,Z)=>N1($,Z,"p","pf-muted")),G("BlockQuote",($,Z)=>N1($,Z,"blockquote","pf-blockquote")),G("Label",($,Z)=>N1($,Z,"label","pf-label")),G("Link",R4),G("Code",j4),G("Markdown",k4),G("Kbd",A4)}function T4($,Z){let J=$.level??2,q=`h${Math.min(Math.max(J,1),6)}`,Q=document.createElement(q);return Q.className=`pf-heading pf-${q}`,Q.textContent=F($.content,Z),Q}function S1($,Z,J){let q=document.createElement(J);return q.className=`pf-heading pf-${J}`,q.textContent=F($.content,Z),q}function I4($,Z){return q0(N("span","pf-text"),F($.content,Z))}function V4($,Z){return q0(N("p","pf-p"),F($.content,Z))}function N1($,Z,J,q){let Q=document.createElement(J);return Q.className=q,Q.textContent=F($.content,Z),Q}var P4=/^\s*(javascript|vbscript|data):/i;function R4($,Z){let J=document.createElement("a");if(J.className="pf-link",J.textContent=F($.content,Z),$.href!=null){let q=F($.href,Z);if(!P4.test(q))J.href=q}if($.target!=null)J.target=F($.target,Z);return J}function j4($,Z){let J=N("pre","pf-code"),q=N("code");if(q.textContent=F($.content,Z),$.language!=null)q.setAttribute("data-language",$.language);return J.appendChild(q),J}function k4($,Z){let J=N("div","pf-markdown"),q=F($.content,Z);return J.innerHTML=n0(q),J.setAttribute("data-markdown","true"),J}var i0=/^\s*(javascript|vbscript|data):/i;function w1($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function f1($){let Z=w1($),J=[];return Z=Z.replace(/`([^`]+)`/g,(q,Q)=>{return J.push(`<code>${Q}</code>`),`﷐CODE${J.length-1}﷐`}),Z=Z.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(i0.test(Y))return w1(Q);return`<img src="${Y}" alt="${Q}" />`}),Z=Z.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(i0.test(Y))return Q;return`<a href="${Y}">${Q}</a>`}),Z=Z.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),Z=Z.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),Z=Z.replace(/\*(.+?)\*/g,"<em>$1</em>"),Z=Z.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),Z=Z.replace(/~~(.+?)~~/g,"<del>$1</del>"),Z=Z.replace(/\uFDD0CODE(\d+)\uFDD0/g,(q,Q)=>J[parseInt(Q)]),Z}function n0($){let Z=$.replace(/\r\n?/g,`
1
+ (()=>{var k0={silent:0,error:1,warn:2,info:3,debug:4},A0="warn";function S0($){A0=$}function i1($){let Z=$?`[prefab:${$}]`:"[prefab]",J=(q,Q,Y)=>{if(k0[q]>k0[A0])return;console[q](`${Z} ${Q}`,...Y)};return{error:(q,...Q)=>J("error",q,Q),warn:(q,...Q)=>J("warn",q,Q),info:(q,...Q)=>J("info",q,Q),debug:(q,...Q)=>J("debug",q,Q)}}var b=i1();class K1{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return m4(this.data,$)}getAll(){return this.data}set($,Z){f0(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($))f0(this.data,Z,J);for(let Z of Object.keys($))this.notify(Z)}subscribe($,Z){if(!this.subscribers.has($))this.subscribers.set($,new Set);return this.subscribers.get($)?.add(Z),()=>this.subscribers.get($)?.delete(Z)}subscribeAll($){return this.globalSubscribers.add($),()=>this.globalSubscribers.delete($)}notify($){this.generation++;let Z=$.split(".");for(let J=1;J<=Z.length;J++){let q=Z.slice(0,J).join("."),Q=this.subscribers.get(q);if(Q)Q.forEach((Y)=>Y())}this.globalSubscribers.forEach((J)=>J())}}function m4($,Z){let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}var h4=new Set(["__proto__","constructor","prototype"]);function f0($,Z,J){let q=Z.split(".");if(q.some((Y)=>h4.has(Y))){b.warn(`Blocked prototype pollution attempt: ${Z}`);return}let Q=$;for(let Y=0;Y<q.length-1;Y++){let U=q[Y];if(Q[U]==null||typeof Q[U]!=="object")Q[U]={};Q=Q[U]}Q[q[q.length-1]]=J}var _1=new Map;function s1($,Z){if(_1.has($)&&_1.get($)!==Z)b.warn(`pipe "${$}" re-registered`);_1.set($,Z)}function n1($){return _1.delete($)}function C0(){return[..._1.keys()]}function O1($){return _1.get($)}function w($){if($==null)return"";if(typeof $==="string")return $;if(typeof $==="number"||typeof $==="boolean"||typeof $==="bigint")return String($);if(typeof $==="symbol")return $.description??"";if(typeof $==="function")return $.name;if($ instanceof Date)return Number.isNaN($.getTime())?"":$.toISOString();if(Array.isArray($))return $.map(w).join(", ");try{return JSON.stringify($)??""}catch{return""}}var w0=-1,r1=new Map,v4=/\{\{\s*(.+?)\s*\}\}/g;function t($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function e($,Z,J){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&l4(q,"{{")===1){let Q=q.slice(2,-2).trim();return b0(Q,Z,J)}return $.replace(v4,(Q,Y)=>{let U=b0(Y.trim(),Z,J);return w(U)})}function b0($,Z,J){let[q,...Q]=d4($),Y=a(q.trim(),Z,J);for(let U of Q)Y=g4(U.trim(),Y,Z,J);return Y}function a($,Z,J){let q=c4($);if(q>=0){let U=$.slice(0,q).trim(),H=$.slice(q+1),G=p4(H);if(G>=0){let X=H.slice(0,G).trim(),M=H.slice(G+1).trim(),W=a(U,Z,J);return W!==null&&W!==void 0&&W!==!1&&W!==0&&W!==""?a(X,Z,J):a(M,Z,J)}}let Q=I1($,"||");if(Q>=0){let U=a($.slice(0,Q).trim(),Z,J);return U!==null&&U!==void 0&&U!==!1&&U!==0&&U!==""?U:a($.slice(Q+2).trim(),Z,J)}let Y=I1($,"&&");if(Y>=0){let U=a($.slice(0,Y).trim(),Z,J);if(U===null||U===void 0||U===!1||U===0||U==="")return U;return a($.slice(Y+2).trim(),Z,J)}for(let[U,H]of u4){let G=I1($,U);if(G>=0){let X=a($.slice(0,G).trim(),Z,J),M=a($.slice(G+U.length).trim(),Z,J);return H(X,M)}}if($.startsWith("!")){let U=a($.slice(1).trim(),Z,J);return U===null||U===void 0||U===!1||U===0||U===""}for(let[U,H]of x4){let G=I1($,U);if(G>=0){let X=a($.slice(0,G).trim(),Z,J),M=a($.slice(G+U.length).trim(),Z,J);return H(Number(X),Number(M))}}if($==="true")return!0;if($==="false")return!1;if($==="null"||$==="undefined")return null;if(/^-?\d+(\.\d+)?$/.test($))return Number($);if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);if(J&&$.startsWith("$")){let U=$.indexOf(".");if(U>=0){let H=$.slice(0,U),G=$.slice(U+1),X=J[H];return V1(X,G)}return J[$]}if(J){let U=$.split(".")[0];if(U in J)return V1(J[U],$.includes(".")?$.slice(U.length+1):"")}return Z.get($)}function g4($,Z,J,q){let Q=$.indexOf(":"),Y=Q>=0?$.slice(0,Q).trim():$,U=Q>=0?$.slice(Q+1).trim():void 0,H=U?a1(U):void 0;switch(Y){case"find":{if(!Array.isArray(Z)||!U)return;let G=y0(U);if(G.length<2)return;let X=a1(G[0]),M=G[1].trim(),W;if(M.startsWith("'")&&M.endsWith("'")||M.startsWith('"')&&M.endsWith('"'))W=M.slice(1,-1);else if(J){if(q&&M.startsWith("$")){let _=M.indexOf(".");if(_>=0){let K=M.slice(0,_);if(K in q)W=V1(q[K],M.slice(_+1))}else if(M in q)W=q[M]}if(W===void 0&&!(q&&M.startsWith("$")))if(q){let _=M.split(".")[0];W=_ in q?V1(q[_],M.includes(".")?M.slice(_.length+1):""):J.get(M)}else W=J.get(M)}else W=M;if(W==null)return;let z=J?.generation??0;if(z!==w0)r1=new Map,w0=z;let E=r1.get(Z);if(!E)E=new Map,r1.set(Z,E);let F=E.get(X);if(!F){F=new Map;for(let _ of Z)if(_!=null&&typeof _==="object"){let K=_[X];if(K!=null)F.set(w(K),_)}E.set(X,F)}return F.get(w(W))}case"dot":{if(Z==null||typeof Z!=="object"||typeof H!=="string")return;return Z[H]}case"length":return Array.isArray(Z)?Z.length:typeof Z==="string"?Z.length:0;case"upper":return typeof Z==="string"?Z.toUpperCase():Z;case"lower":return typeof Z==="string"?Z.toLowerCase():Z;case"truncate":if(typeof Z==="string"&&typeof H==="number")return Z.slice(0,H);return Z;case"join":return Array.isArray(Z)?Z.join(typeof H==="string"?H:", "):Z;case"first":return Array.isArray(Z)?Z[0]:Z;case"last":return Array.isArray(Z)?Z[Z.length-1]:Z;case"abs":return Math.abs(Number(Z));case"round":return typeof H==="number"?Number(Number(Z).toFixed(H)):Math.round(Number(Z));case"number":return typeof H==="number"?Number(Number(Z).toFixed(H)):Number(Z);case"currency":{let G=typeof H==="string"?H:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:G}).format(Number(Z))}catch{return Z}}case"percent":return typeof H==="number"?`${(Number(Z)*100).toFixed(H)}%`:`${Math.round(Number(Z)*100)}%`;case"compact":{let G=typeof H==="number"?H:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:G}).format(Number(Z))}catch{return Z}}case"date":try{return new Date(Z).toLocaleDateString()}catch{return Z}case"time":try{return new Date(Z).toLocaleTimeString()}catch{return Z}case"datetime":try{return new Date(Z).toLocaleString()}catch{return Z}case"pluralize":{let G=Number(Z),X=typeof H==="string"?H:"";return G===1?X:`${X}s`}case"default":return Z==null||Z===""?H:Z;case"selectattr":return Array.isArray(Z)&&typeof H==="string"?Z.filter((G)=>G!=null&&typeof G==="object"&&Boolean(G[H])):Z;case"rejectattr":return Array.isArray(Z)&&typeof H==="string"?Z.filter((G)=>{if(G==null||typeof G!=="object")return!1;let X=G[H];return X==null||X===!1||X===0||X===""}):Z;default:{let G=O1(Y);if(G){let X=U?y0(U).map(a1):[];return G(Z,...X)}return Z}}}var u4=[["!==",($,Z)=>$!==Z],["===",($,Z)=>$===Z],["!=",($,Z)=>$!=Z],["==",($,Z)=>$==Z],[">=",($,Z)=>Number($)>=Number(Z)],["<=",($,Z)=>Number($)<=Number(Z)],[">",($,Z)=>Number($)>Number(Z)],["<",($,Z)=>Number($)<Number(Z)]],x4=[[" + ",($,Z)=>$+Z],[" - ",($,Z)=>$-Z],[" * ",($,Z)=>$*Z],[" / ",($,Z)=>Z!==0?$/Z:0],[" % ",($,Z)=>Z!==0?$%Z:0]];function I1($,Z){let J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J&&$.slice(q,q+Z.length)===Z)return q}return-1}function c4($){let Z=0,J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J){if(Q==="(")Z++;else if(Q===")")Z--;else if(Q==="?"&&Z===0)return q}}return-1}function p4($){let Z=0,J=null;for(let q=0;q<$.length;q++){let Q=$[q];if(Q==="'"||Q==='"')J=J===Q?null:J??Q;if(!J){if(Q==="?"||Q==="(")Z++;else if(Q===")")Z--;else if(Q===":"&&Z===0)return q}}return-1}function d4($){let Z=[],J="",q=null;for(let Q=0;Q<$.length;Q++){let Y=$[Q];if(Y==="'"||Y==='"')q=q===Y?null:q??Y;if(Y==="|"&&!q)if($[Q+1]==="|")J+="||",Q++;else Z.push(J),J="";else J+=Y}return Z.push(J),Z}function a1($){let Z=$.replace(/^['"]|['"]$/g,"");if(Z==="true")return!0;if(Z==="false")return!1;let J=Number(Z);return isNaN(J)?Z:J}function y0($){let Z=[],J="",q=null;for(let Q of $){if(Q==="'"||Q==='"')q=q===Q?null:q??Q;if(Q===","&&!q)Z.push(J),J="";else J+=Q}return Z.push(J),Z}function V1($,Z){if(!Z)return $;let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}function l4($,Z){let J=0,q=0;while((q=$.indexOf(Z,q))!==-1)J++,q+=Z.length;return J}function P1($){return $.replace(/_([a-z])/g,(Z,J)=>J.toUpperCase())}function t1($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:P1(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?t1(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=t1(q);else Z[Q]=q}return Z}async function m($,Z){let J=Array.isArray($)?$:[$];for(let q of J)await i4(q,Z)}function v($,Z){$.catch((J)=>b.error(`${Z} failed:`,J))}async function k1($,Z,J,q){if(J!=null)b.debug(`${$} failed:`,Z),await G1(J,q,{$error:Z});else b.warn(`${$} failed:`,Z)}async function i4($,Z){let J=t1($),q=J.action;switch(q){case"setState":{s4(J,Z);return}case"toggleState":{n4(J,Z);return}case"appendState":{r4(J,Z);return}case"popState":{a4(J,Z);return}case"showToast":{o4(J,Z);return}case"closeOverlay":{t4(J,Z);return}case"openLink":{e4(J);return}case"setInterval":{Z8(J,Z);return}case"toolCall":case"callTool":return J8(J,Z);case"sendMessage":return q8(J,Z);case"updateContext":{Q8(J,Z);return}case"fetch":return Y8(J,Z);case"openFilePicker":{U8(J,Z);return}case"callHandler":return H8(J,Z);case"requestDisplayMode":{G8(J,Z);return}case"subscribe":{B8(J,Z);return}case"unsubscribe":{M8(J);return}default:b.warn(`Unknown action: ${q}`)}}function s4($,Z){let{key:J,value:q}=$;if(t(q))q=e(q,Z.store,Z.scope);Z.store.set(J,q),Z.rerender(),G1($.onSuccess,Z)}function n4($,Z){Z.store.toggle($.key),Z.rerender()}function r4($,Z){let J=$.value??$.item;if(t(J))J=e(J,Z.store,Z.scope);Z.store.append($.key,J,$.index),Z.rerender()}function a4($,Z){Z.store.pop($.key,$.index),Z.rerender()}function o4($,Z){Z.onToast?.({message:j1($.message,Z),description:$.description!=null?j1($.description,Z):void 0,variant:$.variant,duration:$.duration})}function t4($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function e4($){if(typeof window<"u"){let Z=$.url;if(!Z){b.warn("openLink: missing url");return}if(!g0(Z)){b.warn(`Blocked unsafe URL scheme: ${Z}`);return}window.open(Z,$.target??"_blank")}}var R1=new Set,$8=20,m0=100;function Z8($,Z){let J=Math.max($.intervalMs,m0),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(R1.size>=$8){b.warn("Max intervals reached, ignoring new setInterval");return}let Q=globalThis.setInterval(()=>v(m(q,Z),"interval action"),J);R1.add(Q)}function h0(){for(let $ of R1)globalThis.clearInterval($);R1.clear()}async function J8($,Z){if(!Z.transport){b.warn("No MCP transport configured for toolCall");return}let J=$.tool,q=e1($.arguments,Z);try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=A1(Q);if(Y&&Z.remount)Z.remount(Y);else S1(Q,Z),Z.rerender();await G1($.onSuccess,Z,{$result:Q})}catch(Q){await k1("toolCall",Q,$.onError,Z)}}async function q8($,Z){if(!Z.transport){b.warn("No MCP transport configured for sendMessage");return}await Z.transport.sendMessage(j1($.message,Z))}function Q8($,Z){let J=$.context;if(J!=null)Z.store.merge(J),Z.rerender()}async function Y8($,Z){let J=j1($.url,Z);if(!g0(J)){b.warn(`Blocked unsafe URL in fetch: ${J}`);return}let q=$.method??"GET",Q=$.headers,Y=$.body!==void 0?JSON.stringify($.body):void 0;try{let U=await globalThis.fetch(J,{method:q,headers:{"Content-Type":"application/json",...Q},...Y&&{body:Y}}),H=await U.json().catch(()=>U.text());if($.resultKey!=null)Z.store.set($.resultKey,H);let G=A1(H);if(G&&Z.remount)Z.remount(G);else S1(H,Z),Z.rerender();await G1($.onSuccess,Z,{$result:H})}catch(U){await k1("fetch",U,$.onError,Z)}}function U8($,Z){if(typeof document>"u")return;let J=document.createElement("input");if(J.type="file",$.accept!=null)J.accept=$.accept;if($.multiple===!0)J.multiple=!0;J.addEventListener("change",()=>{let q=Array.from(J.files??[]);if($.resultKey!=null)Z.store.set($.resultKey,q);Z.rerender(),G1($.onSuccess,Z,{$result:q})}),J.click()}async function H8($,Z){let J=$.handler,q=e1($.arguments,Z);if(!Z.transport){b.warn(`No transport configured for callHandler: ${J}`);return}try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=A1(Q);if(Y&&Z.remount)Z.remount(Y);else S1(Q,Z),Z.rerender();await G1($.onSuccess,Z,{$result:Q})}catch(Q){await k1("callHandler",Q,$.onError,Z)}}function G8($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var Q1=new Map,W8=50,X8=2000;function B8($,Z){let{uri:J,stateKey:q}=$;if(!J||!q){b.warn("subscribe: missing uri or stateKey");return}if(Q1.has(J))return;if(Q1.size>=W8){b.warn("Max subscriptions reached, ignoring new subscribe");return}let Q=(W)=>{let z=A1(W);if(z&&Z.remount)Z.remount(z);else{if(!S1(W,Z))Z.store.set(q,W);Z.rerender()}G1($.onData,Z,{$data:W})};if(Z.transport?.subscribe&&Z.transport.capabilities?.subscriptions){let W=Z.transport.subscribe(J,Q);Q1.set(J,W);return}let Y=$.fallbackTool,U=$.fallbackInterval??X8;if(!Y){b.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!Z.transport){b.warn("No MCP transport configured for subscribe fallback");return}let H=$.fallbackArgs??{},G=Math.max(U,m0),X=Z.transport,M=globalThis.setInterval(()=>{(async()=>{try{let W=e1(H,Z),z=await X.callTool(Y,W);Q(z)}catch(W){k1("subscribe",W,$.onError,Z)}})()},G);Q1.set(J,()=>globalThis.clearInterval(M))}function M8($){let Z=$.uri;if(!Z){b.warn("unsubscribe: missing uri");return}let J=Q1.get(Z);if(J)J(),Q1.delete(Z)}function v0(){for(let[$,Z]of Q1)try{Z()}catch(J){b.warn(`Error cleaning up subscription '${$}':`,J)}Q1.clear()}function A1($){if($==null||typeof $!=="object")return null;let Z=$;if("$prefab"in Z&&"view"in Z)return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"){let q=J;if("$prefab"in q&&"view"in q)return q}}if("content"in Z&&Array.isArray(Z.content)){for(let J of Z.content)if(J.type==="text"&&typeof J.text==="string")try{let q=JSON.parse(J.text);if(q!=null&&typeof q==="object"){let Q=q;if("$prefab"in Q&&"view"in Q)return Q}}catch{}}return null}function _8($){if($==null||typeof $!=="object")return null;let Z=$;if(o1(Z))return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"&&o1(J))return J}if("content"in Z&&Array.isArray(Z.content)){for(let J of Z.content)if(J.type==="text"&&typeof J.text==="string")try{let q=JSON.parse(J.text);if(q!=null&&typeof q==="object"&&o1(q))return q}catch{}}return null}function o1($){if(!("$prefab"in $)||!("update"in $))return!1;let Z=$.update;return Z!=null&&typeof Z==="object"&&"state"in Z}function S1($,Z){let J=_8($);if(!J)return!1;let q=J.update;if(Z.store.merge(q.state),q.actions!=null)v(m(q.actions,Z),"update action");return!0}var N8=/^\s*(javascript|vbscript|data):/i;function g0($){return!N8.test($)}function j1($,Z){if(t($)){let J=e($,Z.store,Z.scope);return w(J)}return w($)}function e1($,Z){if(!$)return{};let J={};for(let[q,Q]of Object.entries($))J[q]=t(Q)?e(Q,Z.store,Z.scope):Q;return J}async function G1($,Z,J){if($==null)return;let q={...Z.scope,...J};await m($,{...Z,scope:q})}function Z0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:P1(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?Z0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=Z0(q);else Z[Q]=q}return Z}class q0{callbacks=[];track($){this.callbacks.push($)}flush(){for(let $ of this.callbacks)try{$()}catch(Z){b.warn("destroy callback error:",Z)}this.callbacks=[]}get size(){return this.callbacks.length}}function z8($){return typeof $==="object"&&"element"in $}var J0=new Map;function B($,Z){if(J0.has($))b.warn(`overriding existing renderer for "${$}"`);J0.set($,Z)}function u($,Z){let J=Z0($);if(Z.defs?.[J.type]){let Y={...Z.defs[J.type],...J,type:Z.defs[J.type].type};return u(Y,Z)}let q=J0.get(J.type),Q;if(q){let Y=q(J,Z);if(z8(Y))Q=Y.element,Z.destroyRegistry?.track(Y.destroy);else Q=Y}else if(Q=document.createElement("div"),Q.setAttribute("data-prefab-type",J.type),J.children)for(let Y of J.children)Q.appendChild(u(Y,Z));if(Q instanceof HTMLElement){if(J.id)Q.id=J.id;if(J.cssClass){let Y=D(J.cssClass,Z);if(Y)Q.className=(Q.className?Q.className+" ":"")+Y}if(J.onClick!=null){if(Q.addEventListener("click",()=>{v(m(J.onClick,d(Z)),"onClick")}),Q.tagName!=="BUTTON"&&Q.tagName!=="A")Q.setAttribute("role","button"),Q.setAttribute("tabindex","0"),Q.addEventListener("keydown",(Y)=>{let U=Y.key;if(U==="Enter"||U===" ")Y.preventDefault(),v(m(J.onClick,d(Z)),"onClick")})}}if(J.onMount){let Y=J.onMount,U=d(Z);queueMicrotask(()=>v(m(Y,U),"onMount"))}return Q}function C($,Z,J){if(!$.children)return;Y1($.children,Z,J)}function Y1($,Z,J){let q=0;while(q<$.length){let Q=$[q];if(Q.type==="If")q=E8($,q,Z,J);else if(Q.type==="Elif"||Q.type==="Else")q++;else Z.appendChild(u(Q,J)),q++}}function E8($,Z,J,q){let Q=!1,Y=Z,U=$[Y];if(u0(U.condition,q))$0(U,J,q),Q=!0;Y++;while(Y<$.length){let H=$[Y];if(H.type==="Elif"){if(!Q&&u0(H.condition,q))$0(H,J,q),Q=!0;Y++}else if(H.type==="Else"){if(!Q)$0(H,J,q);Y++;break}else break}return Y}function u0($,Z){if(!$)return!1;if(t($))return Boolean(e($,Z.store,Z.scope));return Boolean(Z.store.get($))}function $0($,Z,J){if(!$.children)return;Y1($.children,Z,J)}function D($,Z){if(t($)){let J=e($,Z.store,Z.scope);return w(J)}return w($)}function l($,Z){if(t($))return e($,Z.store,Z.scope);return $}function d($){return{store:$.store,transport:$.transport,scope:$.scope,rerender:$.rerender,onToast:$.onToast,remount:$.remount}}function N($,Z){let J=document.createElement($);if(Z)J.className=Z;return J}function Q0($,Z){return $.textContent=Z,$}function d0(){B("Column",K8),B("Row",F8),B("Grid",x0),B("GridItem",c0),B("Container",D8),B("Div",p0),B("Span",L8),B("Dashboard",x0),B("DashboardItem",c0),B("Pages",T8),B("Page",p0),B("Detail",O8),B("MasterDetail",I8)}function K8($,Z){let J=N("div","pf-column");J.style.display="flex",J.style.flexDirection="column";let q=f1($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=l0($.align);if($.justify!=null)J.style.justifyContent=i0($.justify);return C($,J,Z),J}function F8($,Z){let J=N("div","pf-row");J.style.display="flex",J.style.flexDirection="row";let q=f1($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=l0($.align);if($.justify!=null)J.style.justifyContent=i0($.justify);if($.wrap===!0)J.style.flexWrap="wrap";return C($,J,Z),J}function x0($,Z){let J=N("div","pf-grid");J.style.display="grid";let q=$.columns??3;J.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let Q=f1($);if(Q!=null)J.style.gap=`${Q*4}px`;return C($,J,Z),J}function c0($,Z){let J=N("div","pf-grid-item");if($.colSpan!=null)J.style.gridColumn=`span ${$.colSpan}`;if($.rowSpan!=null)J.style.gridRow=`span ${$.rowSpan}`;return C($,J,Z),J}function D8($,Z){let J=N("div","pf-container");if(J.style.maxWidth=$.maxWidth??"1200px",J.style.margin="0 auto",$.padding!=null)J.style.padding=`${$.padding*4}px`;return C($,J,Z),J}function p0($,Z){let J=N("div","pf-div");return C($,J,Z),J}function L8($,Z){let J=N("span","pf-span");return C($,J,Z),J}function T8($,Z){let J=N("div","pf-pages");return C($,J,Z),J}function O8($,Z){let J=N("div","pf-detail"),q=$.of!=null?l($.of,Z):void 0;if(q!=null&&q!==""&&q!==!1&&q!==0)C($,J,Z);else if($.empty!=null){let Q=$.empty;J.appendChild(u(Q,Z))}return J}function I8($,Z){let J=N("div","pf-master-detail");J.style.display="flex",J.style.flexDirection="row";let q=f1($);if(q!=null)J.style.gap=`${q*4}px`;let Q=$.masterWidth??"33%",Y=$.children??[];if(Y.length>0){let U=N("div","pf-master-detail-master");U.style.width=Q,U.style.flexShrink="0",U.style.overflow="auto",U.appendChild(u(Y[0],Z)),J.appendChild(U)}if(Y.length>1){let U=N("div","pf-master-detail-detail");U.style.flex="1",U.style.overflow="auto",U.appendChild(u(Y[1],Z)),J.appendChild(U)}return J}var V8=/\bgap-(\d+)\b/;function f1($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let Z=V8.exec($.cssClass);if(Z)return Number(Z[1])}return null}function l0($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function i0($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}var P8={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function F1($){return $.replace(/[&<>"']/g,(Z)=>P8[Z]??Z)}function n0(){B("Heading",R8),B("H1",($,Z)=>C1($,Z,"h1")),B("H2",($,Z)=>C1($,Z,"h2")),B("H3",($,Z)=>C1($,Z,"h3")),B("H4",($,Z)=>C1($,Z,"h4")),B("Text",j8),B("P",k8),B("Lead",($,Z)=>N1($,Z,"p","pf-lead")),B("Large",($,Z)=>N1($,Z,"span","pf-large")),B("Small",($,Z)=>N1($,Z,"small","pf-small")),B("Muted",($,Z)=>N1($,Z,"p","pf-muted")),B("BlockQuote",($,Z)=>N1($,Z,"blockquote","pf-blockquote")),B("Label",($,Z)=>N1($,Z,"label","pf-label")),B("Link",S8),B("Code",f8),B("Markdown",C8),B("Kbd",w8)}function R8($,Z){let J=$.level??2,q=`h${Math.min(Math.max(J,1),6)}`,Q=document.createElement(q);return Q.className=`pf-heading pf-${q}`,Q.textContent=D($.content,Z),Q}function C1($,Z,J){let q=document.createElement(J);return q.className=`pf-heading pf-${J}`,q.textContent=D($.content,Z),q}function j8($,Z){return Q0(N("span","pf-text"),D($.content,Z))}function k8($,Z){return Q0(N("p","pf-p"),D($.content,Z))}function N1($,Z,J,q){let Q=document.createElement(J);return Q.className=q,Q.textContent=D($.content,Z),Q}var A8=/^\s*(javascript|vbscript|data):/i;function S8($,Z){let J=document.createElement("a");if(J.className="pf-link",J.textContent=D($.content,Z),$.href!=null){let q=D($.href,Z);if(!A8.test(q))J.href=q}if($.target!=null)J.target=D($.target,Z);return J}function f8($,Z){let J=N("pre","pf-code"),q=N("code");if(q.textContent=D($.content,Z),$.language!=null)q.setAttribute("data-language",$.language);return J.appendChild(q),J}function C8($,Z){let J=N("div","pf-markdown"),q=D($.content,Z);return J.innerHTML=r0(q),J.setAttribute("data-markdown","true"),J}var s0=/^\s*(javascript|vbscript|data):/i;function w1($){let Z=F1($),J=[];return Z=Z.replace(/`([^`]+)`/g,(q,Q)=>{return J.push(`<code>${Q}</code>`),`﷐CODE${J.length-1}﷐`}),Z=Z.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(s0.test(Y))return F1(Q);return`<img src="${Y}" alt="${Q}" />`}),Z=Z.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(s0.test(Y))return Q;return`<a href="${Y}">${Q}</a>`}),Z=Z.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),Z=Z.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),Z=Z.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),Z=Z.replace(/\*(.+?)\*/g,"<em>$1</em>"),Z=Z.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),Z=Z.replace(/~~(.+?)~~/g,"<del>$1</del>"),Z=Z.replace(/\uFDD0CODE(\d+)\uFDD0/g,(q,Q)=>J[parseInt(Q)]),Z}function r0($){let Z=$.replace(/\r\n?/g,`
2
2
  `).split(`
3
- `),J=[],q=0;while(q<Z.length){let Q=Z[q];if(Q.trimStart().startsWith("```")){let H=Q.trimStart().slice(3).trim(),W=[];q++;while(q<Z.length&&!Z[q].trimStart().startsWith("```"))W.push(w1(Z[q])),q++;q++;let _=H?` data-language="${w1(H)}"`:"";J.push(`<pre class="pf-code"><code${_}>${W.join(`
4
- `)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(Q)){J.push("<hr />"),q++;continue}let Y=/^(#{1,6})\s+(.+)$/.exec(Q);if(Y){let H=Y[1].length;J.push(`<h${H}>${f1(Y[2])}</h${H}>`),q++;continue}if(Q.startsWith("> ")||Q===">"){let H=[];while(q<Z.length&&(Z[q].startsWith("> ")||Z[q]===">"))H.push(Z[q].replace(/^>\s?/,"")),q++;J.push(`<blockquote>${n0(H.join(`
5
- `))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(Q)){J.push("<ul>");while(q<Z.length&&/^[\s]*[-*+]\s+/.test(Z[q]))J.push(`<li>${f1(Z[q].replace(/^[\s]*[-*+]\s+/,""))}</li>`),q++;J.push("</ul>");continue}if(/^[\s]*\d+\.\s+/.test(Q)){J.push("<ol>");while(q<Z.length&&/^[\s]*\d+\.\s+/.test(Z[q]))J.push(`<li>${f1(Z[q].replace(/^[\s]*\d+\.\s+/,""))}</li>`),q++;J.push("</ol>");continue}if(Q.trim()===""){q++;continue}let U=[];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]))U.push(Z[q]),q++;J.push(`<p>${U.map(f1).join("<br />")}</p>`)}return J.join(`
6
- `)}function A4($,Z){let J=document.createElement("kbd");return J.className="pf-kbd",J.textContent=F($.content,Z),J}function a0(){G("Card",S4),G("CardHeader",Q0("pf-card-header")),G("CardTitle",r0("pf-card-title","h3")),G("CardDescription",r0("pf-card-description","p")),G("CardContent",Q0("pf-card-content")),G("CardFooter",Q0("pf-card-footer"))}function S4($,Z){let J=N("div","pf-card");return J.style.overflow="hidden",w($,J,Z),J}function Q0($){return(Z,J)=>{let q=N("div",$);return q.style.padding="16px 24px",w(Z,q,J),q}}function r0($,Z){return(J,q)=>{let Q=document.createElement(Z);return Q.className=$,Q.textContent=F(J.content,q),Q}}function o0(){G("DataTable",f4),G("Badge",w4),G("Dot",C4),G("Metric",b4),G("Ring",y4),G("Progress",m4),G("Separator",h4),G("Loader",v4),G("Icon",g4),G("Sparkline",u4)}function f4($,Z){let J=N("div","pf-datatable-wrapper"),q=document.createElement("table");q.className="pf-datatable",q.style.width="100%",q.style.borderCollapse="collapse";let Q=$.columns??[],Y=d($.rows,Z),U=$.rowKey,H=$.selected,W=document.createElement("thead"),_=document.createElement("tr");for(let X of Q){let B=document.createElement("th");B.className="pf-datatable-th",B.textContent=X.header??X.key,B.style.padding="8px 12px",B.style.textAlign="left",_.appendChild(B)}W.appendChild(_),q.appendChild(W);let z=document.createElement("tbody");if(Array.isArray(Y)){let X=H!=null?d(H,Z):void 0;for(let B of Y){let K=document.createElement("tr");K.className="pf-datatable-row";let L=B,M=B===null||typeof B!=="object";if(U&&X!=null&&L[U]!=null&&C(L[U])===C(X))K.classList.add("pf-datatable-row-selected");if($.onRowClick!=null&&U)K.style.cursor="pointer",K.addEventListener("click",()=>{let E={...Z.scope,$item:L,$index:Y.indexOf(B)},O=l({...Z,scope:E});v(h($.onRowClick,O),"onRowClick")});for(let E of Q){let O=document.createElement("td");O.className="pf-datatable-td";let V;if(E.accessor)V=d(`{{ $item.${E.accessor} }}`,{...Z,scope:{...Z.scope,$item:L}});else if(V=M?B:L[E.key],E.format&&V!=null)V=d(`{{ __fmtVal | ${E.format} }}`,{...Z,scope:{...Z.scope,__fmtVal:V}});O.textContent=C(V),O.style.padding="8px 12px",K.appendChild(O)}z.appendChild(K)}}if(q.appendChild(z),$.search===!0){let X=document.createElement("input");X.type="text",X.placeholder="Search...",X.className="pf-datatable-search",X.style.marginBottom="8px",X.style.padding="6px 12px",X.style.width="100%",X.style.boxSizing="border-box",X.addEventListener("input",()=>{let B=X.value.toLowerCase(),K=Array.from(z.querySelectorAll("tr"));for(let L of K){let M=(L.textContent??"").toLowerCase();L.style.display=M.includes(B)?"":"none"}}),J.appendChild(X)}return J.appendChild(q),J}function w4($,Z){let J=N("span","pf-badge"),q=$.variant??"default";return J.setAttribute("data-variant",q),J.style.alignItems="center",J.style.padding="2px 10px",J.style.borderRadius="9999px",J.style.fontSize="12px",J.style.fontWeight="500",J.textContent=F($.label??$.content,Z),x4(J,q),J}function C4($,Z){let J=N("span","pf-dot"),q=$.color??"gray";return J.style.display="inline-block",J.style.width="8px",J.style.height="8px",J.style.borderRadius="50%",J.style.backgroundColor=q,J}function b4($,Z){let J=N("div","pf-metric"),q=N("div","pf-metric-label");q.textContent=F($.label,Z),q.style.fontSize="14px",J.appendChild(q);let Q=N("div","pf-metric-value");if(Q.textContent=F($.value,Z),Q.style.fontSize="28px",Q.style.fontWeight="700",J.appendChild(Q),$.delta!=null){let Y=N("span","pf-metric-delta");Y.textContent=F($.delta,Z);let U=$.trend??"",H=$.trendSentiment??"neutral";if(Y.style.fontSize="14px",Y.style.color=H==="positive"?"green":H==="negative"?"red":"inherit",U==="up")Y.textContent="↑ "+Y.textContent;else if(U==="down")Y.textContent="↓ "+Y.textContent;J.appendChild(Y)}if($.description!=null){let Y=N("div","pf-metric-desc");Y.textContent=F($.description,Z),Y.style.fontSize="12px",J.appendChild(Y)}return J}function y4($,Z){let J=N("div","pf-ring"),q=$.size??80,Q=$.thickness??8,Y=Number(d($.value,Z)??0),U=Math.max(0,Math.min(100,Y)),H=(q-Q)/2,W=2*Math.PI*H,_=W*(1-U/100),z=document.createElementNS("http://www.w3.org/2000/svg","svg");z.setAttribute("width",String(q)),z.setAttribute("height",String(q)),z.setAttribute("viewBox",`0 0 ${q} ${q}`);let X=document.createElementNS("http://www.w3.org/2000/svg","circle");X.setAttribute("cx",String(q/2)),X.setAttribute("cy",String(q/2)),X.setAttribute("r",String(H)),X.setAttribute("fill","none"),X.setAttribute("stroke","var(--muted, #e5e7eb)"),X.setAttribute("stroke-width",String(Q));let B=document.createElementNS("http://www.w3.org/2000/svg","circle");if(B.setAttribute("cx",String(q/2)),B.setAttribute("cy",String(q/2)),B.setAttribute("r",String(H)),B.setAttribute("fill","none"),B.setAttribute("stroke","var(--primary, #3b82f6)"),B.setAttribute("stroke-width",String(Q)),B.setAttribute("stroke-dasharray",String(W)),B.setAttribute("stroke-dashoffset",String(_)),B.setAttribute("stroke-linecap","round"),B.style.transform="rotate(-90deg)",B.style.transformOrigin="center",z.appendChild(X),z.appendChild(B),J.appendChild(z),$.label!=null){let K=N("div","pf-ring-label");K.textContent=F($.label,Z),K.style.textAlign="center",K.style.fontSize="12px",J.appendChild(K)}return J}function m4($,Z){let J=N("div","pf-progress");J.setAttribute("role","progressbar");let q=Number(d($.value,Z)??0),Q=$.max??100,Y=Q>0?Math.max(0,Math.min(100,q/Q*100)):0;J.setAttribute("aria-valuenow",String(q)),J.setAttribute("aria-valuemin","0"),J.setAttribute("aria-valuemax",String(Q)),J.style.height="8px",J.style.borderRadius="4px",J.style.overflow="hidden";let U=N("div","pf-progress-fill");return U.style.height="100%",U.style.width=`${Y}%`,U.style.borderRadius="4px",U.style.transition="width 0.3s ease",J.appendChild(U),J}function h4($,Z){let J=document.createElement("hr");return J.className="pf-separator",J.style.border="none",J.style.margin="8px 0",J}function v4($,Z){let J=N("div","pf-loader");return J.textContent="⏳",J.style.display="flex",J.style.justifyContent="center",J.style.padding="16px",J}function g4($,Z){let J=N("span","pf-icon");return J.setAttribute("data-icon",F($.name??$.content,Z)),J}function u4($,Z){let J=N("div","pf-sparkline"),q=$.data??[];if(q.length===0)return J;let Q=120,Y=32,U=Math.max(...q),H=Math.min(...q),W=U-H||1,_=document.createElementNS("http://www.w3.org/2000/svg","svg");_.setAttribute("width",String(Q)),_.setAttribute("height",String(Y)),_.setAttribute("viewBox",`0 0 ${Q} ${Y}`);let z=q.length>1?q.length-1:1,X=q.map((K,L)=>{let M=L/z*Q,E=Y-(K-H)/W*(Y-4)-2;return`${M},${E}`}).join(" "),B=document.createElementNS("http://www.w3.org/2000/svg","polyline");return B.setAttribute("points",X),B.setAttribute("fill","none"),B.setAttribute("stroke","var(--primary, #3b82f6)"),B.setAttribute("stroke-width","1.5"),_.appendChild(B),J.appendChild(_),J}function x4($,Z){let q={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[Z];if(q)$.style.backgroundColor=q.bg,$.style.color=q.fg}function e0(){G("Form",p4),G("Input",c4),G("Textarea",d4),G("Button",l4),G("ButtonGroup",i4),G("Select",s4),G("SelectOption",n4),G("SelectGroup",C1("pf-select-group")),G("SelectLabel",F1("pf-select-label")),G("SelectSeparator",t0),G("Checkbox",r4),G("Switch",a4),G("Slider",o4),G("Radio",e4),G("RadioGroup",$6),G("Combobox",Z6),G("ComboboxOption",J6),G("ComboboxGroup",C1("pf-combobox-group")),G("ComboboxLabel",F1("pf-combobox-label")),G("ComboboxSeparator",t0),G("Calendar",q6),G("DatePicker",Q6),G("Field",C1("pf-field")),G("FieldTitle",F1("pf-field-title")),G("FieldDescription",F1("pf-field-description")),G("FieldContent",C1("pf-field-content")),G("FieldError",F1("pf-field-error")),G("ChoiceCard",Y6)}function p4($,Z){let J=document.createElement("form");return J.className="pf-form",J.addEventListener("submit",(q)=>{q.preventDefault();let Q=new FormData(J),Y={};if(Q.forEach((U,H)=>{Y[H]=U}),Z.store.merge(Y),$.onSubmit!=null){let U=l(Z);U.scope={...Z.scope,...Y},v(h($.onSubmit,U),"onSubmit")}}),w($,J,Z),J}function c4($,Z){let J=N("div","pf-input-wrapper");if(J.style.display="flex",J.style.flexDirection="column",J.style.gap="4px",$.label!=null){let Y=document.createElement("label");if(Y.className="pf-input-label",Y.textContent=F($.label,Z),$.name!=null)Y.htmlFor=$.name;Y.style.fontSize="14px",Y.style.fontWeight="500",J.appendChild(Y)}let q=document.createElement("input");if(q.className="pf-input",q.type=$.inputType??"text",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-input-${$.name}`;if($.placeholder!=null)q.placeholder=F($.placeholder,Z);if($.required===!0)q.required=!0,q.setAttribute("aria-required","true");if($.error!=null)q.setAttribute("aria-invalid","true");let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=C(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return Y0(q),J.appendChild(q),J}function d4($,Z){let J=N("div","pf-textarea-wrapper"),q=document.createElement("textarea");if(q.className="pf-textarea",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-textarea-${$.name}`;if($.placeholder!=null)q.placeholder=F($.placeholder,Z);if($.rows!=null)q.rows=$.rows;if($.required===!0)q.setAttribute("aria-required","true");let Q=$.name;if(Q!=null){let Y=Z.store.get(Q);if(Y!=null)q.value=C(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return Y0(q),J.appendChild(q),J}function l4($,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),t4(J,q),$.size!=null)J.setAttribute("data-size",$.size);if($.disabled===!0)J.disabled=!0;return J}function i4($,Z){let J=N("div","pf-button-group");return J.style.display="flex",J.style.gap="8px",w($,J,Z),J}function s4($,Z){let J=N("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(Y0(q),$.placeholder!=null){let U=document.createElement("option");U.value="",U.textContent=F($.placeholder,Z),U.disabled=!0,U.selected=!0,U.hidden=!0,q.appendChild(U)}let Q=$.options;if(Array.isArray(Q))for(let U of Q){let H=document.createElement("option");H.value=U.value??"",H.textContent=U.label??H.value,q.appendChild(H)}if($.children)for(let U of $.children)if(U.type==="SelectOption"){let H=document.createElement("option");H.value=U.value??"",H.textContent=U.label??H.value,q.appendChild(H)}else q.appendChild(u(U,Z));let Y=$.name;if(Y){let U=Z.store.get(Y);if(U!=null)q.value=C(U);q.addEventListener("change",()=>{if(Z.store.set(Y,q.value),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return J.appendChild(q),J}function n4($,Z){return N("span")}function r4($,Z){let J=N("label","pf-checkbox-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-checkbox",$.name!=null)q.name=$.name;if($.checked===!0)q.checked=!0;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.checked}}),"onChange")})}if(J.appendChild(q),$.label!=null){let Y=N("span");Y.textContent=F($.label,Z),J.appendChild(Y)}return J}function a4($,Z){let J=N("label","pf-switch-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-switch",q.setAttribute("role","switch"),$.name!=null)q.name=$.name;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.checked}}),"onChange")})}if(J.appendChild(q),$.label!=null){let Y=N("span");Y.textContent=F($.label,Z),J.appendChild(Y)}return J}function o4($,Z){let J=N("div","pf-slider-wrapper"),q=document.createElement("input");if(q.type="range",q.className="pf-slider",$.name!=null)q.name=$.name;if($.min!=null)q.min=C($.min);if($.max!=null)q.max=C($.max);if($.step!=null)q.step=C($.step);let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=C(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,Number(q.value)),$.onChange!=null)v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:Number(q.value)}}),"onChange")})}return J.appendChild(q),J}function Y0($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function t4($,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 C1($){return(Z,J)=>{let q=N("div",$);return w(Z,q,J),q}}function F1($){return(Z,J)=>{let q=N("span",$);return q.textContent=F(Z.content,J),q}}function t0(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function e4($,Z){let J=N("label","pf-radio");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="radio",q.value=F($.value,Z),J.appendChild(q),$.label!=null){let Q=N("span","pf-radio-label");Q.textContent=F($.label,Z),J.appendChild(Q)}return J}function $6($,Z){let J=N("fieldset","pf-radio-group");if(J.style.border="none",J.style.padding="0",J.style.display="flex",J.style.flexDirection="column",J.style.gap="8px",$.label!=null){let Y=document.createElement("legend");Y.textContent=F($.label,Z),Y.style.fontWeight="500",Y.style.marginBottom="4px",J.appendChild(Y)}w($,J,Z);let q=F($.name,Z),Q=Z.store.get(q);for(let Y of Array.from(J.querySelectorAll('input[type="radio"]')))if(Y.name=q,Q!=null&&Y.value===C(Q))Y.checked=!0;return J.addEventListener("change",(Y)=>{let U=Y.target;if(U.type==="radio"){if(Z.store.set(q,U.value),$.onChange!=null)v(h($.onChange,l(Z)),"onChange")}}),J}function Z6($,Z){let J=N("div","pf-combobox"),q=document.createElement("input");if(q.className="pf-combobox-input",q.type="text",q.name=F($.name,Z),$.placeholder!=null)q.placeholder=F($.placeholder,Z);if($.value!==void 0)q.value=F($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=C(Y);q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box";let U=N("div","pf-combobox-dropdown");if(U.style.display="none",U.style.position="absolute",U.style.borderRadius="6px",U.style.maxHeight="200px",U.style.overflowY="auto",U.style.zIndex="50",w($,U,Z),q.addEventListener("focus",()=>{U.style.display="block"}),q.addEventListener("blur",()=>{setTimeout(()=>{U.style.display="none"},150)}),$.searchable!==!1)q.addEventListener("input",()=>{let H=q.value.toLowerCase();for(let W of Array.from(U.querySelectorAll(".pf-combobox-option"))){let _=(W.textContent??"").toLowerCase();W.style.display=_.includes(H)?"":"none"}});if($.onChange!=null)J.addEventListener("pf-combobox-select",()=>{v(h($.onChange,{...l(Z),scope:{...Z.scope,$event:q.value}}),"onChange")});return J.style.position="relative",J.appendChild(q),J.appendChild(U),J}function J6($,Z){let J=N("div","pf-combobox-option");return J.style.padding="6px 12px",J.style.cursor="pointer",J.textContent=F($.label??$.value,Z),J.dataset.value=F($.value,Z),J.addEventListener("mousedown",()=>{let q=J.closest(".pf-combobox"),Q=q?.querySelector("input");if(Q)Q.value=J.dataset.value??"",Z.store.set(Q.name,Q.value),q?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),J}function q6($,Z){let J=N("div","pf-calendar"),q=document.createElement("input");if(q.type="date",q.name=F($.name,Z),$.value!==void 0)q.value=F($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=C(Y);if($.minDate!=null)q.min=F($.minDate,Z);if($.maxDate!=null)q.max=F($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)v(h($.onChange,l(Z)),"onChange")}),J.appendChild(q),J}function Q6($,Z){let J=N("div","pf-datepicker"),q=document.createElement("input");if(q.type="date",q.name=F($.name,Z),$.placeholder!=null)q.placeholder=F($.placeholder,Z);if($.value!==void 0)q.value=F($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=C(Y);if($.minDate!=null)q.min=F($.minDate,Z);if($.maxDate!=null)q.max=F($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)v(h($.onChange,l(Z)),"onChange")}),J.appendChild(q),J}function Y6($,Z){let J=N("div","pf-choice-card");if(J.style.padding="16px",J.style.cursor="pointer",J.style.transition="border-color 0.2s",J.dataset.value=F($.value,Z),$.selected===!0)J.dataset.selected="true";if($.label!=null){let q=N("div","pf-choice-card-label");q.textContent=F($.label,Z),q.style.fontWeight="600",J.appendChild(q)}if($.description!=null){let q=N("div","pf-choice-card-description");q.textContent=F($.description,Z),q.style.fontSize="14px",J.appendChild(q)}return w($,J,Z),J}function $8(){G("Tabs",U6),G("Tab",H6),G("Accordion",W6),G("AccordionItem",X6),G("Dialog",G6),G("Popover",B6),G("Tooltip",M6),G("HoverCard",_6),G("Carousel",N6)}function U6($,Z){let J=N("div","pf-tabs"),q=N("div","pf-tabs-bar");q.setAttribute("role","tablist"),q.style.display="flex",q.style.gap="4px",q.style.marginBottom="12px";let Q=[],Y=[];if($.children)for(let H=0;H<$.children.length;H++){let W=$.children[H],_=`pf-tab-${Math.random().toString(36).slice(2,8)}`,z=`pf-panel-${Math.random().toString(36).slice(2,8)}`,X=document.createElement("button");X.type="button",X.className="pf-tab-trigger",X.textContent=W.title??`Tab ${H+1}`,X.setAttribute("role","tab"),X.setAttribute("aria-selected",H===0?"true":"false"),X.setAttribute("aria-controls",z),X.id=_,X.tabIndex=H===0?0:-1,X.style.padding="8px 16px",X.style.border="none",X.style.background="none",X.style.cursor="pointer",X.style.borderBottom="2px solid transparent",X.style.marginBottom="-2px",X.style.fontSize="14px";let B=N("div","pf-tab-panel");if(B.style.display=H===0?"block":"none",B.setAttribute("role","tabpanel"),B.setAttribute("aria-labelledby",_),B.id=z,B.tabIndex=0,w(W,B,Z),X.addEventListener("click",()=>{U(H)}),H===0)X.classList.add("pf-tab-active"),X.style.fontWeight="600";Y.push(X),Q.push(B),q.appendChild(X)}function U(H){Q.forEach((W)=>W.style.display="none"),Y.forEach((W)=>{W.style.borderBottomColor="transparent",W.style.fontWeight="normal",W.classList.remove("pf-tab-active"),W.setAttribute("aria-selected","false"),W.tabIndex=-1}),Q[H].style.display="block",Y[H].classList.add("pf-tab-active"),Y[H].style.fontWeight="600",Y[H].setAttribute("aria-selected","true"),Y[H].tabIndex=0,Y[H].focus()}q.addEventListener("keydown",(H)=>{let W=Y.indexOf(H.target);if(W<0)return;let _;if(H.key==="ArrowRight")_=(W+1)%Y.length;else if(H.key==="ArrowLeft")_=(W-1+Y.length)%Y.length;else if(H.key==="Home")_=0;else if(H.key==="End")_=Y.length-1;else return;H.preventDefault(),U(_)}),J.appendChild(q);for(let H of Q)J.appendChild(H);return J}function H6($,Z){let J=N("div","pf-tab");return w($,J,Z),J}function W6($,Z){let J=N("div","pf-accordion");return w($,J,Z),J}function X6($,Z){let J=N("div","pf-accordion-item"),q=`pf-acc-${Math.random().toString(36).slice(2,8)}`,Q=document.createElement("button");Q.type="button",Q.className="pf-accordion-trigger",Q.textContent=$.title??"",Q.setAttribute("aria-expanded","false"),Q.setAttribute("aria-controls",q),Q.style.width="100%",Q.style.textAlign="left",Q.style.padding="12px 0",Q.style.border="none",Q.style.background="none",Q.style.cursor="pointer",Q.style.fontSize="14px",Q.style.fontWeight="500";let Y=N("div","pf-accordion-content");return Y.id=q,Y.setAttribute("role","region"),Y.setAttribute("aria-labelledby",Q.id),Y.style.display="none",Y.style.paddingBottom="12px",w($,Y,Z),Q.addEventListener("click",()=>{let U=Y.style.display!=="none";Y.style.display=U?"none":"block",Q.setAttribute("aria-expanded",U?"false":"true")}),J.appendChild(Q),J.appendChild(Y),J}function G6($,Z){let J=N("div","pf-dialog-wrapper");if($.trigger!=null){let Y=u($.trigger,Z);Y.addEventListener("click",()=>{q.showModal()}),J.appendChild(Y)}let q=document.createElement("dialog");if(q.className="pf-dialog",q.setAttribute("aria-modal","true"),q.style.maxWidth="500px",q.style.width="100%",q.style.padding="24px",$.title!=null){let Y=N("h2","pf-dialog-title");Y.textContent=F($.title,Z),Y.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,q.setAttribute("aria-labelledby",Y.id),q.appendChild(Y)}if($.description!=null){let Y=N("p","pf-dialog-desc");Y.textContent=F($.description,Z),q.appendChild(Y)}let Q=N("div","pf-dialog-body");if(w($,Q,Z),q.appendChild(Q),$.dismissible!==!1)q.addEventListener("click",(Y)=>{if(Y.target===q)q.close()});return document.addEventListener("prefab:close-overlay",()=>q.close()),J.appendChild(q),J}function B6($,Z){let J=N("div","pf-popover");J.style.position="relative",J.style.display="inline-block";let q=N("div","pf-popover-content");if(q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="12px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",$.title!=null){let Y=N("div","pf-popover-title");Y.textContent=F($.title,Z),Y.style.fontWeight="600",Y.style.marginBottom="4px",q.appendChild(Y)}w($,q,Z);let Q=()=>{q.style.display=q.style.display==="none"?"block":"none"};if($.trigger!=null){let Y=u($.trigger,Z);Y.addEventListener("click",(U)=>{U.stopPropagation(),Q()}),J.appendChild(Y)}else J.addEventListener("click",(Y)=>{if(q.contains(Y.target)&&q.style.display!=="none")return;Q()});return J.appendChild(q),J}function M6($,Z){let J=N("div","pf-tooltip");J.style.position="relative",J.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,Q=N("div","pf-tooltip-content");return Q.id=q,Q.setAttribute("role","tooltip"),Q.textContent=F($.content??"",Z),Q.style.display="none",Q.style.position="absolute",Q.style.bottom="100%",Q.style.left="50%",Q.style.transform="translateX(-50%)",Q.style.padding="4px 8px",Q.style.borderRadius="4px",Q.style.color="#fff",Q.style.fontSize="12px",Q.style.whiteSpace="nowrap",Q.style.zIndex="50",w($,J,Z),J.setAttribute("aria-describedby",q),J.addEventListener("mouseenter",()=>{Q.style.display="block"}),J.addEventListener("mouseleave",()=>{Q.style.display="none"}),J.addEventListener("focus",()=>{Q.style.display="block"},!0),J.addEventListener("blur",()=>{Q.style.display="none"},!0),J.appendChild(Q),J}function _6($,Z){let J=N("div","pf-hover-card");J.style.position="relative",J.style.display="inline-block";let q=N("div","pf-hover-card-content");if(q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="16px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",q.style.minWidth="200px",$.trigger!=null)J.appendChild(u($.trigger,Z));return w($,q,Z),J.addEventListener("mouseenter",()=>{q.style.display="block"}),J.addEventListener("mouseleave",()=>{q.style.display="none"}),J.appendChild(q),J}function N6($,Z){let J=N("div","pf-carousel");J.style.position="relative",J.style.overflow="hidden",J.setAttribute("role","region"),J.setAttribute("aria-roledescription","carousel"),J.setAttribute("aria-label",F($.label??"Carousel",Z));let q=N("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",w($,q,Z);let Q=0,Y=$.children?.length??0,U=document.createElement("button");U.type="button",U.textContent="‹",U.className="pf-carousel-prev",U.setAttribute("aria-label","Previous slide"),U.style.position="absolute",U.style.left="4px",U.style.top="50%",U.style.transform="translateY(-50%)",U.style.zIndex="10";let H=document.createElement("button");H.type="button",H.textContent="›",H.className="pf-carousel-next",H.setAttribute("aria-label","Next slide"),H.style.position="absolute",H.style.right="4px",H.style.top="50%",H.style.transform="translateY(-50%)",H.style.zIndex="10";let W=()=>{q.style.transform=`translateX(-${Q*100}%)`};return U.addEventListener("click",()=>{if(Y===0)return;Q=Math.max(0,Q-1),W()}),H.addEventListener("click",()=>{if(Y===0)return;Q=Math.min(Y-1,Q+1),W()}),J.appendChild(q),J.appendChild(U),J.appendChild(H),J}function Z8(){G("ForEach",z6),G("If",J8),G("Elif",E6),G("Else",K6),G("Condition",F6),G("Define",L6),G("Use",D6),G("Slot",O6)}function z6($,Z){let J=document.createDocumentFragment(),q=$.expression;if(!q)return J;let Q;if(t(q)){let U=e(q,Z.store,Z.scope);Q=Array.isArray(U)?U:[]}else{let U=Z.store.get(q);Q=Array.isArray(U)?U:[]}let Y=$.let??{};for(let U=0;U<Q.length;U++){let H=Q[U],W={...Z.scope,$item:H,$index:U,...Y},_={...Z,scope:W};if($.children)Y1($.children,J,_)}return J}function J8($,Z){if(q8($.condition,Z)){let q=document.createDocumentFragment();if($.children)Y1($.children,q,Z);return q}return document.createDocumentFragment()}function E6($,Z){return J8($,Z)}function K6($,Z){let J=document.createDocumentFragment();if($.children)Y1($.children,J,Z);return J}function q8($,Z){if(!$)return!1;if(t($))return Boolean(e($,Z.store,Z.scope));return Boolean(Z.store.get($))}function F6($,Z){let J=document.createDocumentFragment(),q=$.cases,Q=$.else;if(q){for(let Y of q)if(q8(Y.when,Z)){if(Y.children)Y1(Y.children,J,Z);return J}}if(Q)Y1(Q,J,Z);return J}function L6($,Z){let J=$.name;if(J&&$.children)Z.templates=Z.templates??{},Z.templates[J]=$.children;return document.createDocumentFragment()}function D6($,Z){let J=document.createDocumentFragment(),q=$.def??$.name,Q=Z.templates?.[q];if(!Q)return J;let Y=$.overrides??{},U={...Z.scope,...Y},H={...Z.slots??{},...$.slots??{}};if(Array.isArray($.children))H.default=$.children;let W={...Z,scope:U,slots:H};for(let _ of Q)J.appendChild(u(_,W));return J}function O6($,Z){let J=document.createDocumentFragment(),q=$.name??"default",Y=Z.slots?.[q]??$.children;if(Y)for(let U of Y)J.appendChild(u(U,Z));return J}function Q8(){G("Alert",T6),G("AlertTitle",I6),G("AlertDescription",V6)}function T6($,Z){let J=N("div","pf-alert");J.setAttribute("role","alert");let q=$.variant??"default";if(J.setAttribute("data-variant",q),J.style.padding="12px 16px",$.icon!=null){let Q=N("span","pf-alert-icon");Q.setAttribute("data-icon",$.icon),Q.style.marginRight="8px",J.appendChild(Q)}return w($,J,Z),J}function I6($,Z){let J=N("h5","pf-alert-title");return J.textContent=F($.content,Z),J.style.fontWeight="600",J.style.marginBottom="4px",J}function V6($,Z){let J=N("p","pf-alert-description");return J.textContent=F($.content,Z),J.style.fontSize="14px",J}function Y8(){G("Image",P6),G("Audio",R6),G("Video",j6),G("Embed",k6),G("Svg",S6),G("DropZone",f6),G("Mermaid",w6)}function P6($,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 R6($,Z){let J=document.createElement("audio");return J.className="pf-audio",J.src=F($.src,Z),J.controls=!0,J}function j6($,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 k6($,Z){let J=N("div","pf-embed"),q=document.createElement("iframe");return q.src=F($.src,Z),q.style.width="100%",q.style.height=$.height!=null?`${$.height}px`:"400px",q.style.border="none",q.setAttribute("sandbox","allow-scripts"),J.appendChild(q),J}var A6=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 S6($,Z){let J=N("div","pf-svg"),q=F($.content,Z);if(!q.includes("<svg"))return J;if(!/<svg[^>]*\sxmlns\s*=/.test(q))q=q.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"');let Y=new DOMParser().parseFromString(q,"image/svg+xml").querySelector("svg");if(!Y)return J;return U8(Y),J.appendChild(document.importNode(Y,!0)),J}function U8($){let Z=Array.from($.children);for(let J of Z){if(!A6.has(J.tagName.toLowerCase())){J.remove();continue}for(let q of Array.from(J.attributes)){let Q=q.name.toLowerCase();if(Q.startsWith("on")||Q==="href"&&q.value.trim().toLowerCase().startsWith("javascript:"))J.removeAttribute(q.name)}U8(J)}}function f6($,Z){let J=N("div","pf-dropzone");return J.style.padding="32px",J.style.textAlign="center",J.style.cursor="pointer",J.textContent=F($.label??"Drop files here",Z),J.addEventListener("dragover",(q)=>{q.preventDefault(),J.classList.add("pf-dropzone-active")}),J.addEventListener("dragleave",()=>{J.classList.remove("pf-dropzone-active")}),J.addEventListener("drop",(q)=>{q.preventDefault(),J.classList.remove("pf-dropzone-active")}),J}function w6($,Z){let J=N("div","pf-mermaid");J.setAttribute("data-mermaid","true");let q=F($.content,Z);if(J.textContent=q,typeof globalThis.mermaid<"u")J.classList.add("mermaid"),J.textContent=q;return J}var C6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",b6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",U0=null,b1=null;async function y6(){if(U0)return U0;if(b1)return b1;return b1=import(C6).then(($)=>{let Z=$;return Z.GlobalWorkerOptions.workerSrc=b6,U0=Z,Z}),b1}function W8(){G("PdfViewer",m6)}function m6($,Z){let J=N("div","pf-pdf-viewer"),q=$.src!=null?F($.src,Z):void 0,Q=$.data,Y=$.page!=null?$.page:1,U=$.zoom!=null?$.zoom:"fit-width",H=$.toolbar!==!1,W=$.height!=null?$.height:600;J.style.height=`${W}px`,J.style.display="flex",J.style.flexDirection="column",J.style.overflow="hidden",J.style.border="1px solid var(--color-border-primary, #e5e7eb)",J.style.borderRadius="var(--border-radius-md, 0.375rem)",J.style.background="var(--color-background-secondary, #f9fafb)";let _=N("div","pf-pdf-loading");return _.textContent="Loading PDF…",_.style.display="flex",_.style.alignItems="center",_.style.justifyContent="center",_.style.flex="1",_.style.color="var(--color-text-secondary, #6b7280)",J.appendChild(_),h6(J,_,{src:q,data:Q,initialPage:Y,zoom:U,showToolbar:H}),J}async function h6($,Z,J){try{let q=await y6(),Q;if(J.src)Q={url:J.src};else if(J.data){let B=atob(J.data),K=new Uint8Array(B.length);for(let L=0;L<B.length;L++)K[L]=B.charCodeAt(L);Q={data:K}}else{Z.textContent="Error: No PDF source provided";return}let Y=await q.getDocument(Q).promise;Z.remove();let U=Math.max(1,Math.min(J.initialPage,Y.numPages)),H=null,W=null;if(J.showToolbar){let B=v6(Y.numPages,U,{onPrev:()=>{if(U>1)U--,X()},onNext:()=>{if(U<Y.numPages)U++,X()},onPageChange:(K)=>{let L=Math.max(1,Math.min(K,Y.numPages));if(L!==U)U=L,X()}});H=B.pageInput,W=B.pageCount,$.insertBefore(B.el,$.firstChild)}let _=N("div","pf-pdf-canvas-container");_.style.flex="1",_.style.overflow="auto",_.style.display="flex",_.style.justifyContent="center",_.style.padding="8px",$.appendChild(_);let z=document.createElement("canvas");z.style.display="block",z.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",_.appendChild(z);async function X(){let B=await Y.getPage(U),K=_.clientWidth-16,L,M=B.getViewport({scale:1});if(J.zoom==="fit-width")L=K/M.width;else if(J.zoom==="fit-page"){let V=_.clientHeight-16,A=K/M.width,I=V/M.height;L=Math.min(A,I)}else L=typeof J.zoom==="number"?J.zoom:1;let E=B.getViewport({scale:L});z.width=E.width,z.height=E.height,z.style.width=`${E.width}px`,z.style.height=`${E.height}px`;let O=z.getContext("2d");if(!O)return;if(await B.render({canvasContext:O,viewport:E}).promise,H)H.value=String(U);if(W)W.textContent=`/ ${Y.numPages}`}await X()}catch(q){Z.textContent=`PDF Error: ${q instanceof Error?q.message:String(q)}`,Z.style.color="var(--color-text-danger, #dc2626)"}}function v6($,Z,J){let q=N("div","pf-pdf-toolbar");q.style.display="flex",q.style.alignItems="center",q.style.gap="8px",q.style.padding="6px 12px",q.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",q.style.background="var(--color-background-primary, #fff)",q.style.flexShrink="0",q.style.fontSize="13px";let Q=document.createElement("button");Q.textContent="‹",Q.title="Previous page",Q.className="pf-pdf-btn",H8(Q),Q.addEventListener("click",J.onPrev);let Y=document.createElement("button");Y.textContent="›",Y.title="Next page",Y.className="pf-pdf-btn",H8(Y),Y.addEventListener("click",J.onNext);let U=document.createElement("input");U.type="number",U.min="1",U.max=String($),U.value=String(Z),U.style.width="48px",U.style.textAlign="center",U.style.border="1px solid var(--color-border-primary, #e5e7eb)",U.style.borderRadius="4px",U.style.padding="2px 4px",U.style.fontSize="13px",U.addEventListener("change",()=>{let W=parseInt(U.value,10);if(!isNaN(W))J.onPageChange(W)});let H=document.createElement("span");return H.textContent=`/ ${$}`,H.style.color="var(--color-text-secondary, #6b7280)",q.appendChild(Q),q.appendChild(U),q.appendChild(H),q.appendChild(Y),{el:q,pageInput:U,pageCount:H}}function H8($){$.style.border="1px solid var(--color-border-primary, #e5e7eb)",$.style.borderRadius="4px",$.style.background="var(--color-background-primary, #fff)",$.style.cursor="pointer",$.style.padding="2px 8px",$.style.fontSize="16px",$.style.lineHeight="1"}var m1=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function X1($,Z){let J=document.createElement("div");return J.className="pf-chart-tooltip",$.appendChild(J),$.addEventListener("mouseleave",()=>{J.classList.remove("pf-visible")}),{wrapper:$,tooltip:J,svgEl:Z}}function $1($,Z,J,q,Q){let{tooltip:Y,svgEl:U,wrapper:H}=$;if(Q.length===0)return;let W="";if(q)W+=`<div class="pf-chart-tooltip-label">${y1(q)}</div>`;for(let E of Q)W+='<div class="pf-chart-tooltip-row">',W+=`<span class="pf-chart-tooltip-dot" style="background:${y1(E.color)}"></span>`,W+=`<span>${y1(E.label)}:</span> <strong>${y1(String(E.value))}</strong>`,W+="</div>";Y.innerHTML=W;let _=U.getBoundingClientRect(),z=H.getBoundingClientRect(),X=U.viewBox.baseVal,B=_.width/(X.width||1),K=_.left-z.left+Z*B,L=Y.offsetWidth||100,M=K+12;if(M+L>z.width)M=K-L-12;Y.style.left=`${Math.max(0,M)}px`,Y.style.top="4px",Y.classList.add("pf-visible")}function y1($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function X8($,Z,J,q,Q,Y,U,H){let W=Q.plotWidth/J.length;for(let _=0;_<J.length;_++){let z=Q.plotLeft+_*W,X=document.createElementNS("http://www.w3.org/2000/svg","rect");X.setAttribute("x",String(z)),X.setAttribute("y",String(Q.plotTop)),X.setAttribute("width",String(W)),X.setAttribute("height",String(Q.plotHeight)),X.setAttribute("fill","transparent"),X.style.cursor="default";let B=Y?J[_][Y]:void 0,K=B!=null?H?H(B):C(B):void 0,L=q.map((V,A)=>({label:V.label??V.dataKey,value:U(J[_][V.dataKey],V,A),color:V.color??m1[A%m1.length]})),M=z+W/2,E=()=>$1($,M,Q.plotTop,K,L),O=()=>$.tooltip.classList.remove("pf-visible");X.addEventListener("mouseenter",E),X.addEventListener("mouseleave",O),X.addEventListener("touchstart",E,{passive:!0}),X.addEventListener("touchend",O,{passive:!0}),Z.appendChild(X)}}function G8($,Z,J,q,Q,Y,U,H,W,_){let z=J.length===1?Q.plotWidth:Q.plotWidth/(J.length-1);for(let X=0;X<J.length;X++){let B=J.length===1?(Q.plotLeft+Q.plotRight)/2:Q.plotLeft+X/(J.length-1)*Q.plotWidth,K=J.length===1?Q.plotLeft:B-z/2,L=J.length===1?Q.plotWidth:z,M=document.createElementNS("http://www.w3.org/2000/svg","rect");M.setAttribute("x",String(Math.max(Q.plotLeft,K))),M.setAttribute("y",String(Q.plotTop)),M.setAttribute("width",String(Math.min(L,Q.plotRight-Math.max(Q.plotLeft,K)))),M.setAttribute("height",String(Q.plotHeight)),M.setAttribute("fill","transparent"),M.style.cursor="default";let E=Y?J[X][Y]:void 0,O=E!=null?_?_(E):C(E):void 0,V=q.map((j,f)=>({label:j.label??j.dataKey,value:U(J[X][j.dataKey],j,f),color:j.color??m1[f%m1.length]})),A=()=>{if($1($,B,Q.plotTop,O,V),H)H.setAttribute("x1",String(B)),H.setAttribute("x2",String(B)),H.setAttribute("opacity","1");if(W)for(let j of W){for(let f of j)f.setAttribute("data-visible","false");j[X]?.setAttribute("data-visible","true")}},I=()=>{if($.tooltip.classList.remove("pf-visible"),H)H.setAttribute("opacity","0");if(W)for(let j of W)for(let f of j)f.setAttribute("data-visible","false")};M.addEventListener("mouseenter",A),M.addEventListener("mouseleave",I),M.addEventListener("touchstart",A,{passive:!0}),M.addEventListener("touchend",I,{passive:!0}),Z.appendChild(M)}}var s=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],J1="var(--muted-foreground, #6b7280)",z1="var(--border, #e5e7eb)",G1="10";function h1($,Z,J,q=!1){let Q=J?44:0,Y=$-(q?44:0),U=10,H=Z-24;return{plotLeft:Q,plotRight:Y,plotTop:10,plotBottom:H,plotWidth:Y-Q,plotHeight:H-10}}function B8($,Z=5){if($<=0)return[0];let J=$/Z,q=Math.pow(10,Math.floor(Math.log10(J))),Q=J/q,Y=Q<=1.5?q:Q<=3?2*q:Q<=7?5*q:10*q,U=[];for(let H=0;H<=$+Y*0.01;H+=Y)U.push(Math.round(H*1000)/1000);return U}function H0($,Z,J,q,Q){let Y=B8(J);for(let U of Y){let H=Z.plotBottom-(J>0?U/J*Z.plotHeight:0),W=n("text",{x:Z.plotLeft-6,y:H+3,"text-anchor":"end","font-size":G1,fill:J1});if(W.textContent=G0(U,Q),$.appendChild(W),q&&U>0)$.appendChild(n("line",{x1:Z.plotLeft,y1:H,x2:Z.plotRight,y2:H,stroke:z1,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function W0($,Z,J,q){let Q=B8(J);for(let Y of Q){let U=Z.plotBottom-(J>0?Y/J*Z.plotHeight:0),H=n("text",{x:Z.plotRight+6,y:U+3,"text-anchor":"start","font-size":G1,fill:J1});H.textContent=G0(Y,q),$.appendChild(H)}}function X0($,Z,J,q,Q,Y){for(let U=0;U<Z.length;U++){let H=Z[U][J],W=n("text",{x:q(U),y:Q+14,"text-anchor":"middle","font-size":G1,fill:J1});W.textContent=H==null?"":Y?Y(H):C(H),$.appendChild(W)}}function v1($,Z){$.appendChild(n("line",{x1:Z.plotLeft,y1:Z.plotBottom,x2:Z.plotRight,y2:Z.plotBottom,stroke:J1,"stroke-width":1}))}function Z1($,Z,J){if($==null)return"";let q=d(`{{ __v | ${Z} }}`,{...J,scope:{...J.scope,__v:$}});return C(q??$)}function G0($,Z){if(Z==="currency")return`$${$.toLocaleString()}`;if(Z==="percent")return`${$}%`;if($>=1e6)return`${($/1e6).toFixed(1)}M`;if($>=1000)return`${($/1000).toFixed(1)}K`;return String($)}function q1($){let Z=$.yAxisFormat??$.valueFormat;return Z&&Z!=="auto"?Z:void 0}function B0($,Z,J){return(q,Q)=>{if(q===null||q===void 0)return"—";if(Q.tooltipFormat)return Z1(q,Q.tooltipFormat,$);let Y=Q.yAxisId==="right"?J:Z;return G0(Number(q),Y)}}function U1($,Z,J){let q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(q.setAttribute("width","100%"),q.setAttribute("height",String(Z)),q.setAttribute("viewBox",`0 0 ${$} ${Z}`),q.setAttribute("role","img"),J)q.setAttribute("aria-label",`${J} chart`);return q.style.overflow="visible",q}function n($,Z){let J=document.createElementNS("http://www.w3.org/2000/svg",$);for(let[q,Q]of Object.entries(Z))J.setAttribute(q,String(Q));return J}function g1($,Z){let J=n("text",$);return J.textContent=Z,J}function B1($,Z,J,q){let Q=q*Math.PI/180;return{x:$+J*Math.cos(Q),y:Z-J*Math.sin(Q)}}function M0($,Z,J,q,Q){let Y=Math.max(2,Math.ceil(Math.abs(Q-q)/4)),U=[];for(let H=0;H<=Y;H++){let W=B1($,Z,J,q+(Q-q)*H/Y);U.push(`${H===0?"M":"L"} ${W.x.toFixed(2)} ${W.y.toFixed(2)}`)}return U.join(" ")}function M1($,Z,J){if(J===!1||Z.length<=1)return;let q=N("div","pf-chart-legend");q.style.display="flex",q.style.gap="12px",q.style.fontSize="12px",q.style.marginBottom="8px";for(let Q=0;Q<Z.length;Q++){let Y=N("div","pf-chart-legend-item");Y.style.display="flex",Y.style.alignItems="center",Y.style.gap="4px";let U=N("span");U.style.width="8px",U.style.height="8px",U.style.borderRadius="50%",U.style.backgroundColor=Z[Q].color??s[Q%s.length];let H=N("span");H.textContent=Z[Q].label??Z[Q].dataKey,Y.appendChild(U),Y.appendChild(H),q.appendChild(Y)}$.appendChild(q)}function _8(){G("BarChart",g6),G("LineChart",M8),G("AreaChart",M8),G("PieChart",u6),G("RadarChart",c6),G("ScatterChart",x6),G("RadialChart",p6),G("Histogram",d6)}function g6($,Z){let J=N("div","pf-chart pf-bar-chart"),q=d($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,H=$.showGrid===!0,W=$.showYAxisRight===!0,_=$.showTooltip!==!1,z=$.xAxis,X=$.tooltipXKey,B=$.xAxisFormat,K=$.tooltipXFormat,L=Q.filter((T)=>T.yAxisId!=="right"),M=Q.filter((T)=>T.yAxisId==="right"),E=W&&M.length>0,O=L.length>0?Math.max(...q.flatMap((T)=>L.map((D)=>Number(T[D.dataKey]??0))),1):1,V=E?Math.max(...q.flatMap((T)=>M.map((D)=>Number(T[D.dataKey]??0))),1):1,A=400,I=h1(A,Y,U,E),j=U1(A,Y,"Bar");if(U)H0(j,I,O,H,q1($));if(E)W0(j,I,V,$.yAxisRightFormat);v1(j,I);let f=I.plotWidth/q.length,S=f/(Q.length+1);for(let T=0;T<q.length;T++)for(let D=0;D<Q.length;D++){let k=Q[D],y=q[T][k.dataKey];if(y===null||y===void 0)continue;let i=k.yAxisId==="right"?V:O,g=Number(y),P=Math.max(0,g/i*I.plotHeight),p=I.plotLeft+T*f+D*S+S/2,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(p)),R.setAttribute("y",String(I.plotBottom-P)),R.setAttribute("width",String(S*0.8)),R.setAttribute("height",String(P)),R.setAttribute("fill",k.color??s[D%s.length]),R.setAttribute("rx","2"),j.appendChild(R)}if(z){let T=B?(D)=>Z1(D,B,Z):void 0;X0(j,q,z,(D)=>{return I.plotLeft+D*f+f/2},I.plotBottom,T)}if(_){let T=X1(J,j),D=B0(Z,q1($),$.yAxisRightFormat);X8(T,j,q,Q,I,X??z,D,K?(y)=>Z1(y,K,Z):void 0)}return M1(J,Q,$.showLegend),J.appendChild(j),J}function M8($,Z){let J=N("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),q=d($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,H=$.showGrid===!0,W=$.showYAxisRight===!0,_=$.showTooltip!==!1,z=$.xAxis,X=$.tooltipXKey,B=$.xAxisFormat,K=$.tooltipXFormat,L=Q.filter((D)=>D.yAxisId!=="right"),M=Q.filter((D)=>D.yAxisId==="right"),E=W&&M.length>0,O=L.length>0?Math.max(...q.flatMap((D)=>L.map((k)=>Number(D[k.dataKey]??0))),1):1,V=E?Math.max(...q.flatMap((D)=>M.map((k)=>Number(D[k.dataKey]??0))),1):1,A=400,I=h1(A,Y,U,E),j=U1(A,Y,$.type==="AreaChart"?"Area":"Line"),f=$.type==="AreaChart";if(U)H0(j,I,O,H,q1($));if(E)W0(j,I,V,$.yAxisRightFormat);v1(j,I);let S=[];for(let D=0;D<Q.length;D++){let k=Q[D],y=k.yAxisId==="right",x=y?V:O,i=k.color??s[D%s.length],g=q.map((R,m)=>{let c=R[k.dataKey],r=c===null||c===void 0,H1=q.length===1?(I.plotLeft+I.plotRight)/2:I.plotLeft+m/(q.length-1)*I.plotWidth,w8=r?I.plotBottom:I.plotBottom-Number(c)/x*I.plotHeight;return{x:H1,y:w8,isNull:r}});if(f){let R=[],m=()=>{if(R.length<2){R=[];return}let c=`M ${R[0].x},${I.plotBottom} `+R.map((H1)=>`L ${H1.x},${H1.y}`).join(" ")+` L ${R[R.length-1].x},${I.plotBottom} Z`,r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",c),r.setAttribute("fill",i),r.setAttribute("opacity","0.15"),j.appendChild(r),R=[]};for(let c of g){if(c.isNull){m();continue}R.push(c)}m()}let P="";for(let R of g){if(R.isNull)continue;let m=g.indexOf(R),c=m===0||g[m-1].isNull;P+=`${c?"M":"L"} ${R.x},${R.y} `}if(P){let R=document.createElementNS("http://www.w3.org/2000/svg","path");if(R.setAttribute("d",P.trim()),R.setAttribute("fill","none"),R.setAttribute("stroke",i),R.setAttribute("stroke-width","2"),y)R.setAttribute("stroke-dasharray","6 3");j.appendChild(R)}let p=[];for(let R of g){let m=document.createElementNS("http://www.w3.org/2000/svg","circle");if(m.setAttribute("cx",String(R.x)),m.setAttribute("cy",String(R.y)),m.setAttribute("r","4"),m.setAttribute("fill",i),m.setAttribute("class","pf-data-dot"),m.setAttribute("data-visible","false"),m.style.pointerEvents="none",R.isNull)m.style.display="none";j.appendChild(m),p.push(m)}S.push(p)}let T=document.createElementNS("http://www.w3.org/2000/svg","line");if(T.setAttribute("class","pf-crosshair"),T.setAttribute("x1",String(I.plotLeft)),T.setAttribute("x2",String(I.plotLeft)),T.setAttribute("y1",String(I.plotTop)),T.setAttribute("y2",String(I.plotBottom)),T.setAttribute("stroke",J1),T.setAttribute("stroke-width","1"),T.setAttribute("stroke-dasharray","3 3"),T.setAttribute("opacity","0"),j.appendChild(T),z){let D=B?(k)=>Z1(k,B,Z):void 0;X0(j,q,z,(k)=>{return q.length===1?(I.plotLeft+I.plotRight)/2:I.plotLeft+k/(q.length-1)*I.plotWidth},I.plotBottom,D)}if(_){let D=X1(J,j),k=B0(Z,q1($),$.yAxisRightFormat);G8(D,j,q,Q,I,X??z,k,T,S,K?(x)=>Z1(x,K,Z):void 0)}return M1(J,Q,$.showLegend),J.appendChild(j),J}function u6($,Z){let J=N("div","pf-chart pf-pie-chart"),q=d($.data,Z)??[],Q=$.series??[],Y=$.height??300,U=Math.min(Y,300),H=$.showTooltip!==!1,W=$.dataKey??Q[0]?.dataKey,_=$.nameKey??$.tooltipXKey??$.xAxis,z=Q.length>0?Q:W?[{dataKey:W,label:W}]:[];if(q.length===0||!W)return J.textContent="No chart data",J;let X=U1(U,U,"Pie"),B=U/2,K=U/2,L=U/2-10,M=$.tooltipXFormat,E=q1($),O=(f)=>E?Z1(f,E,Z):String(f),V=q.map((f)=>Number(f[W]??0)),A=V.reduce((f,S)=>f+S,0);if(A===0)return J.textContent="No chart data",J.appendChild(X),J;let I=H?X1(J,X):void 0,j=-Math.PI/2;for(let f=0;f<V.length;f++){let S=V[f]/A*2*Math.PI,T=j+S,D=S>Math.PI?1:0,k=B+L*Math.cos(j),y=K+L*Math.sin(j),x=B+L*Math.cos(T),i=K+L*Math.sin(T),g=s[f%s.length],P=document.createElementNS("http://www.w3.org/2000/svg","path");if(P.setAttribute("d",`M ${B},${K} L ${k},${y} A ${L},${L} 0 ${D} 1 ${x},${i} Z`),P.setAttribute("fill",g),P.style.cursor="default",I){let p=_?q[f][_]:void 0,R=p!=null?M?Z1(p,M,Z):C(p):`Slice ${f+1}`,m=`${(V[f]/A*100).toFixed(1)}%`,c=j+S/2,r=B+L*0.6*Math.cos(c);P.addEventListener("mouseenter",()=>{$1(I,r,K,R,[{label:z[0].label??W,value:`${O(V[f])} (${m})`,color:g}])}),P.addEventListener("mouseleave",()=>{I.tooltip.classList.remove("pf-visible")}),P.addEventListener("touchstart",()=>{$1(I,r,K,R,[{label:z[0].label??W,value:`${O(V[f])} (${m})`,color:g}])},{passive:!0}),P.addEventListener("touchend",()=>{I.tooltip.classList.remove("pf-visible")},{passive:!0})}X.appendChild(P),j=T}return M1(J,z,$.showLegend),J.appendChild(X),J}function x6($,Z){let J=N("div","pf-chart pf-scatter-chart"),q=d($.data,Z)??[],Q=$.xAxis,Y=$.yAxis,U=$.zAxis,H=$.series??[],W=$.height??300;if(q.length===0||!Q||!Y)return J.textContent="No chart data",J;let _=$.showGrid!==!1,z=$.showTooltip!==!1,X=H[0]?.color??s[0],B=q1($),K=(P)=>B?Z1(P,B,Z):String(Math.round(P*100)/100),L=q.map((P)=>Number(P[Q]??0)),M=q.map((P)=>Number(P[Y]??0)),E=Math.min(...L),O=Math.max(...L),V=Math.min(...M),A=Math.max(...M),I=O-E||1,j=A-V||1,f=U?q.map((P)=>Number(P[U]??0)):[],S=U?Math.max(...f,1):1,T=400,D=h1(T,W,!0),k=U1(T,W,"Scatter"),y=(P)=>D.plotLeft+(P-E)/I*D.plotWidth,x=(P)=>D.plotBottom-(P-V)/j*D.plotHeight,i=4;for(let P=0;P<=i;P++){let p=V+j*P/i,R=x(p);if(k.appendChild(g1({x:D.plotLeft-6,y:R+3,"text-anchor":"end","font-size":G1,fill:J1},K(p))),_&&P>0)k.appendChild(n("line",{x1:D.plotLeft,y1:R,x2:D.plotRight,y2:R,stroke:z1,"stroke-width":1,"stroke-dasharray":"4 3"}))}v1(k,D);for(let P of[E,(E+O)/2,O])k.appendChild(g1({x:y(P),y:D.plotBottom+14,"text-anchor":"middle","font-size":G1,fill:J1},String(Math.round(P*100)/100)));let g=z?X1(J,k):void 0;for(let P=0;P<q.length;P++){let p=y(L[P]),R=x(M[P]),m=U?4+Math.sqrt(f[P]/S)*14:4,c=n("circle",{cx:p,cy:R,r:m,fill:X,"fill-opacity":U?0.6:0.85});if(g){let r=[{label:Q,value:K(L[P]),color:X},{label:Y,value:K(M[P]),color:X},...U?[{label:U,value:K(f[P]),color:X}]:[]],H1=H[0]?.label??"Point";c.addEventListener("mouseenter",()=>$1(g,p,R,H1,r)),c.addEventListener("mouseleave",()=>g.tooltip.classList.remove("pf-visible")),c.addEventListener("touchstart",()=>$1(g,p,R,H1,r),{passive:!0}),c.addEventListener("touchend",()=>g.tooltip.classList.remove("pf-visible"),{passive:!0})}k.appendChild(c)}return M1(J,H,$.showLegend),J.appendChild(k),J}function p6($,Z){let J=N("div","pf-chart pf-radial-chart"),q=d($.data,Z)??[],Q=$.series??[],Y=$.dataKey??Q[0]?.dataKey,U=$.nameKey??$.tooltipXKey??$.xAxis,H=$.height??300;if(q.length===0||!Y)return J.textContent="No chart data",J;let W=Math.min(H,300),_=W/2,z=W/2,X=W/2-10,B=Math.max(0,Math.min($.innerRadius??30,X-10)),K=$.startAngle??180,L=$.endAngle??0,M=$.showTooltip!==!1,E=q.map((D)=>Number(D[Y]??0)),O=Math.max(...E,1),V=U1(W,W,"Radial"),A=(X-B)/q.length,I=Math.max(2,A*0.7),j=q1($),f=(D)=>j?Z1(D,j,Z):String(D),S=M?X1(J,V):void 0,T=[];for(let D=0;D<q.length;D++){let k=X-A*D-A/2,y=Q[D]?.color??s[D%s.length],x=E[D]/O,i=K+x*(L-K),g=U?q[D][U]:null,P=g!=null?C(g):Q[D]?.label??Y;T.push({dataKey:P||Y,label:P||Y,color:y}),V.appendChild(n("path",{d:M0(_,z,k,K,L),fill:"none",stroke:z1,"stroke-width":I,"stroke-linecap":"round"}));let p=n("path",{d:M0(_,z,k,K,i),fill:"none",stroke:y,"stroke-width":I,"stroke-linecap":"round"});if(S){let R=B1(_,z,k,(K+i)/2),m=[{label:Y,value:f(E[D]),color:y}],c=P||Y;p.addEventListener("mouseenter",()=>$1(S,R.x,R.y,c,m)),p.addEventListener("mouseleave",()=>S.tooltip.classList.remove("pf-visible")),p.addEventListener("touchstart",()=>$1(S,R.x,R.y,c,m),{passive:!0}),p.addEventListener("touchend",()=>S.tooltip.classList.remove("pf-visible"),{passive:!0})}V.appendChild(p)}return M1(J,T,$.showLegend),J.appendChild(V),J}function c6($,Z){let J=N("div","pf-chart pf-radar-chart"),q=d($.data,Z)??[],Q=$.series??[],Y=$.axisKey??$.xAxis,U=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let H=$.filled!==!1,W=$.showDots===!0,_=$.showGrid!==!1,z=$.showTooltip!==!1,X=Math.min(U,320),B=X/2,K=X/2,L=X/2-24,M=q.length,E=Math.max(...q.flatMap((S)=>Q.map((T)=>Number(S[T.dataKey]??0))),1),O=(S)=>90-360*S/M,V=(S)=>S.map((T)=>`${T.x.toFixed(1)},${T.y.toFixed(1)}`).join(" "),A=U1(X,X,"Radar");if(_){for(let T=1;T<=4;T++){let D=L*T/4,k=Array.from({length:M},(y,x)=>B1(B,K,D,O(x)));A.appendChild(n("polygon",{points:V(k),fill:"none",stroke:z1,"stroke-width":1}))}for(let T=0;T<M;T++){let D=B1(B,K,L,O(T));A.appendChild(n("line",{x1:B,y1:K,x2:D.x,y2:D.y,stroke:z1,"stroke-width":1}))}}for(let S=0;S<M;S++){let T=B1(B,K,L+12,O(S)),D=Y?q[S][Y]:null;A.appendChild(g1({x:T.x,y:T.y+3,"text-anchor":"middle","font-size":G1,fill:J1},D!=null?String(D):""))}let I=z?X1(J,A):void 0,j=q1($),f=(S)=>j?Z1(S,j,Z):String(S);for(let S=0;S<Q.length;S++){let T=Q[S],D=T.color??s[S%s.length],k=q.map((y,x)=>B1(B,K,Number(y[T.dataKey]??0)/E*L,O(x)));if(A.appendChild(n("polygon",{points:V(k),fill:H?D:"none","fill-opacity":H?0.2:0,stroke:D,"stroke-width":2})),W||I)for(let y=0;y<k.length;y++){let x=n("circle",{cx:k[y].x,cy:k[y].y,r:W?3:6,fill:W?D:"transparent","fill-opacity":W?1:0});if(I){let i=Y?q[y][Y]:null,g=i!=null?C(i):T.label??T.dataKey,P=[{label:T.label??T.dataKey,value:f(Number(q[y][T.dataKey]??0)),color:D}];x.addEventListener("mouseenter",()=>$1(I,k[y].x,k[y].y,g,P)),x.addEventListener("mouseleave",()=>I.tooltip.classList.remove("pf-visible")),x.addEventListener("touchstart",()=>$1(I,k[y].x,k[y].y,g,P),{passive:!0}),x.addEventListener("touchend",()=>I.tooltip.classList.remove("pf-visible"),{passive:!0})}A.appendChild(x)}}return M1(J,Q,$.showLegend),J.appendChild(A),J}function d6($,Z){let J=N("div","pf-chart pf-histogram"),q=d($.data,Z);if(!q||q.length===0)return J.textContent="No data",J;let Q=q,Y=$.bins??10,U=$.height??200,H=$.color??s[0],W=Math.min(...Q),z=(Math.max(...Q)-W)/Y||1,X=Array(Y).fill(0);for(let O of Q){let V=Math.min(Math.floor((O-W)/z),Y-1);X[V]++}let B=Math.max(...X),K=300,L=U,M=K/Y,E=U1(K,L,"Histogram");for(let O=0;O<Y;O++){let V=B>0?X[O]/B*L:0,A=document.createElementNS("http://www.w3.org/2000/svg","rect");A.setAttribute("x",String(O*M)),A.setAttribute("y",String(L-V)),A.setAttribute("width",String(M-1)),A.setAttribute("height",String(V)),A.setAttribute("fill",H),E.appendChild(A)}return J.appendChild(E),J}function N8(){G("Table",l6),G("TableHead",_0("thead")),G("TableBody",_0("tbody")),G("TableFooter",_0("tfoot")),G("TableRow",i6),G("TableHeader",s6),G("TableCell",n6),G("TableCaption",r6),G("ExpandableRow",a6)}function l6($,Z){let J=document.createElement("table");return J.className="pf-table",J.style.width="100%",J.style.borderCollapse="collapse",w($,J,Z),J}function _0($){return(Z,J)=>{let q=document.createElement($);return q.className=`pf-${$}`,w(Z,q,J),q}}function i6($,Z){let J=document.createElement("tr");return J.className="pf-table-row",w($,J,Z),J}function s6($,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 n6($,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 w($,J,Z),J}function r6($,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 a6($,Z){let J=N("div","pf-expandable-row"),q=N("div","pf-expandable-row-summary");q.style.cursor="pointer",q.style.display="flex",q.style.alignItems="center",q.style.gap="8px";let Q=N("span","pf-expandable-arrow");Q.textContent="▶",Q.style.transition="transform 0.2s",Q.style.fontSize="10px",q.appendChild(Q);let Y=$.summary;if(Y)for(let W of Y)q.appendChild(u(W,Z));let U=N("div","pf-expandable-row-detail");U.style.display="none",U.style.paddingLeft="24px",w($,U,Z);let H=!1;return q.addEventListener("click",()=>{H=!H,U.style.display=H?"block":"none",Q.style.transform=H?"rotate(90deg)":""}),J.appendChild(q),J.appendChild(U),J}var z8=!1;function u1(){if(z8)return;z8=!0,c0(),s0(),a0(),o0(),e0(),$8(),Z8(),Q8(),Y8(),W8(),_8(),N8()}function z0($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function E0($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function N0($,Z=" "){return Object.entries($).map(([J,q])=>`${Z}--${z0(J)}: ${E0(q)};`).join(`
7
- `)}function E8($){if(!$)return"";let Z=[];if($.light&&Object.keys($.light).length>0)Z.push(`:root {
8
- ${N0($.light)}
9
- }`);if($.dark&&Object.keys($.dark).length>0){let J=N0($.dark);Z.push(`.dark, [data-theme="dark"] {
3
+ `),J=[],q=0;while(q<Z.length){let Q=Z[q];if(Q.trimStart().startsWith("```")){let H=Q.trimStart().slice(3).trim(),G=[];q++;while(q<Z.length&&!Z[q].trimStart().startsWith("```"))G.push(F1(Z[q])),q++;q++;let X=H?` data-language="${F1(H)}"`:"";J.push(`<pre class="pf-code"><code${X}>${G.join(`
4
+ `)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(Q)){J.push("<hr />"),q++;continue}let Y=/^(#{1,6})\s+(.+)$/.exec(Q);if(Y){let H=Y[1].length;J.push(`<h${H}>${w1(Y[2])}</h${H}>`),q++;continue}if(Q.startsWith("> ")||Q===">"){let H=[];while(q<Z.length&&(Z[q].startsWith("> ")||Z[q]===">"))H.push(Z[q].replace(/^>\s?/,"")),q++;J.push(`<blockquote>${r0(H.join(`
5
+ `))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(Q)){J.push("<ul>");while(q<Z.length&&/^[\s]*[-*+]\s+/.test(Z[q]))J.push(`<li>${w1(Z[q].replace(/^[\s]*[-*+]\s+/,""))}</li>`),q++;J.push("</ul>");continue}if(/^[\s]*\d+\.\s+/.test(Q)){J.push("<ol>");while(q<Z.length&&/^[\s]*\d+\.\s+/.test(Z[q]))J.push(`<li>${w1(Z[q].replace(/^[\s]*\d+\.\s+/,""))}</li>`),q++;J.push("</ol>");continue}if(Q.trim()===""){q++;continue}let U=[];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]))U.push(Z[q]),q++;J.push(`<p>${U.map(w1).join("<br />")}</p>`)}return J.join(`
6
+ `)}function w8($,Z){let J=document.createElement("kbd");return J.className="pf-kbd",J.textContent=D($.content,Z),J}function o0(){B("Card",b8),B("CardHeader",Y0("pf-card-header")),B("CardTitle",a0("pf-card-title","h3")),B("CardDescription",a0("pf-card-description","p")),B("CardContent",Y0("pf-card-content")),B("CardFooter",Y0("pf-card-footer"))}function b8($,Z){let J=N("div","pf-card");return J.style.overflow="hidden",C($,J,Z),J}function Y0($){return(Z,J)=>{let q=N("div",$);return q.style.padding="16px 24px",C(Z,q,J),q}}function a0($,Z){return(J,q)=>{let Q=document.createElement(Z);return Q.className=$,Q.textContent=D(J.content,q),Q}}function t0(){B("DataTable",y8),B("Badge",m8),B("Dot",h8),B("Metric",v8),B("Ring",g8),B("Progress",u8),B("Separator",x8),B("Loader",c8),B("Icon",p8),B("Sparkline",d8)}function y8($,Z){let J=N("div","pf-datatable-wrapper"),q=document.createElement("table");q.className="pf-datatable",q.style.width="100%",q.style.borderCollapse="collapse";let Q=$.columns??[],Y=l($.rows,Z),U=$.rowKey,H=$.selected,G=document.createElement("thead"),X=document.createElement("tr");for(let W of Q){let z=document.createElement("th");z.className="pf-datatable-th",z.textContent=W.header??W.key,z.style.padding="8px 12px",z.style.textAlign="left",X.appendChild(z)}G.appendChild(X),q.appendChild(G);let M=document.createElement("tbody");if(Array.isArray(Y)){let W=H!=null?l(H,Z):void 0;for(let z of Y){let E=document.createElement("tr");E.className="pf-datatable-row";let F=z,_=z===null||typeof z!=="object";if(U&&W!=null&&F[U]!=null&&w(F[U])===w(W))E.classList.add("pf-datatable-row-selected");if($.onRowClick!=null&&U)E.style.cursor="pointer",E.addEventListener("click",()=>{let K={...Z.scope,$item:F,$index:Y.indexOf(z)},T=d({...Z,scope:K});v(m($.onRowClick,T),"onRowClick")});for(let K of Q){let T=document.createElement("td");T.className="pf-datatable-td";let V;if(K.accessor)V=l(`{{ $item.${K.accessor} }}`,{...Z,scope:{...Z.scope,$item:F}});else if(V=_?z:F[K.key],K.format&&V!=null)V=l(`{{ __fmtVal | ${K.format} }}`,{...Z,scope:{...Z.scope,__fmtVal:V}});T.textContent=w(V),T.style.padding="8px 12px",E.appendChild(T)}M.appendChild(E)}}if(q.appendChild(M),$.search===!0){let W=document.createElement("input");W.type="text",W.placeholder="Search...",W.className="pf-datatable-search",W.style.marginBottom="8px",W.style.padding="6px 12px",W.style.width="100%",W.style.boxSizing="border-box",W.addEventListener("input",()=>{let z=W.value.toLowerCase(),E=Array.from(M.querySelectorAll("tr"));for(let F of E){let _=(F.textContent??"").toLowerCase();F.style.display=_.includes(z)?"":"none"}}),J.appendChild(W)}return J.appendChild(q),J}function m8($,Z){let J=N("span","pf-badge"),q=$.variant??"default";return J.setAttribute("data-variant",q),J.style.alignItems="center",J.style.padding="2px 10px",J.style.borderRadius="9999px",J.style.fontSize="12px",J.style.fontWeight="500",J.textContent=D($.label??$.content,Z),l8(J,q),J}function h8($,Z){let J=N("span","pf-dot"),q=$.color??"gray";return J.style.display="inline-block",J.style.width="8px",J.style.height="8px",J.style.borderRadius="50%",J.style.backgroundColor=q,J}function v8($,Z){let J=N("div","pf-metric"),q=N("div","pf-metric-label");q.textContent=D($.label,Z),q.style.fontSize="14px",J.appendChild(q);let Q=N("div","pf-metric-value");if(Q.textContent=D($.value,Z),Q.style.fontSize="28px",Q.style.fontWeight="700",J.appendChild(Q),$.delta!=null){let Y=N("span","pf-metric-delta");Y.textContent=D($.delta,Z);let U=$.trend??"",H=$.trendSentiment??"neutral";if(Y.style.fontSize="14px",Y.style.color=H==="positive"?"green":H==="negative"?"red":"inherit",U==="up")Y.textContent="↑ "+Y.textContent;else if(U==="down")Y.textContent="↓ "+Y.textContent;J.appendChild(Y)}if($.description!=null){let Y=N("div","pf-metric-desc");Y.textContent=D($.description,Z),Y.style.fontSize="12px",J.appendChild(Y)}return J}function g8($,Z){let J=N("div","pf-ring"),q=$.size??80,Q=$.thickness??8,Y=Number(l($.value,Z)??0),U=Math.max(0,Math.min(100,Y)),H=(q-Q)/2,G=2*Math.PI*H,X=G*(1-U/100),M=document.createElementNS("http://www.w3.org/2000/svg","svg");M.setAttribute("width",String(q)),M.setAttribute("height",String(q)),M.setAttribute("viewBox",`0 0 ${q} ${q}`);let W=document.createElementNS("http://www.w3.org/2000/svg","circle");W.setAttribute("cx",String(q/2)),W.setAttribute("cy",String(q/2)),W.setAttribute("r",String(H)),W.setAttribute("fill","none"),W.setAttribute("stroke","var(--muted, #e5e7eb)"),W.setAttribute("stroke-width",String(Q));let 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(H)),z.setAttribute("fill","none"),z.setAttribute("stroke","var(--primary, #3b82f6)"),z.setAttribute("stroke-width",String(Q)),z.setAttribute("stroke-dasharray",String(G)),z.setAttribute("stroke-dashoffset",String(X)),z.setAttribute("stroke-linecap","round"),z.style.transform="rotate(-90deg)",z.style.transformOrigin="center",M.appendChild(W),M.appendChild(z),J.appendChild(M),$.label!=null){let E=N("div","pf-ring-label");E.textContent=D($.label,Z),E.style.textAlign="center",E.style.fontSize="12px",J.appendChild(E)}return J}function u8($,Z){let J=N("div","pf-progress");J.setAttribute("role","progressbar");let q=Number(l($.value,Z)??0),Q=$.max??100,Y=Q>0?Math.max(0,Math.min(100,q/Q*100)):0;J.setAttribute("aria-valuenow",String(q)),J.setAttribute("aria-valuemin","0"),J.setAttribute("aria-valuemax",String(Q)),J.style.height="8px",J.style.borderRadius="4px",J.style.overflow="hidden";let U=N("div","pf-progress-fill");return U.style.height="100%",U.style.width=`${Y}%`,U.style.borderRadius="4px",U.style.transition="width 0.3s ease",J.appendChild(U),J}function x8($,Z){let J=document.createElement("hr");return J.className="pf-separator",J.style.border="none",J.style.margin="8px 0",J}function c8($,Z){let J=N("div","pf-loader");return J.textContent="⏳",J.style.display="flex",J.style.justifyContent="center",J.style.padding="16px",J}function p8($,Z){let J=N("span","pf-icon");return J.setAttribute("data-icon",D($.name??$.content,Z)),J}function d8($,Z){let J=N("div","pf-sparkline"),q=$.data??[];if(q.length===0)return J;let Q=$.width??120,Y=$.height??32,U=Math.max(...q),H=Math.min(...q),G=U-H||1,X=document.createElementNS("http://www.w3.org/2000/svg","svg");X.setAttribute("width",String(Q)),X.setAttribute("height",String(Y)),X.setAttribute("viewBox",`0 0 ${Q} ${Y}`);let M=q.length>1?q.length-1:1,W=q.map((E,F)=>{let _=F/M*Q,K=Y-(E-H)/G*(Y-4)-2;return`${_},${K}`}).join(" "),z=document.createElementNS("http://www.w3.org/2000/svg","polyline");return z.setAttribute("points",W),z.setAttribute("fill","none"),z.setAttribute("stroke","var(--primary, #3b82f6)"),z.setAttribute("stroke-width","1.5"),X.appendChild(z),J.appendChild(X),J}function l8($,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 $4(){B("Form",i8),B("Input",s8),B("Textarea",D1(n8)),B("Button",r8),B("ButtonGroup",a8),B("Select",D1(o8)),B("SelectOption",t8),B("SelectGroup",b1("pf-select-group")),B("SelectLabel",L1("pf-select-label")),B("SelectSeparator",e0),B("Checkbox",e8),B("Switch",$6),B("Slider",D1(Z6)),B("Radio",q6),B("RadioGroup",Q6),B("Combobox",D1(Y6)),B("ComboboxOption",U6),B("ComboboxGroup",b1("pf-combobox-group")),B("ComboboxLabel",L1("pf-combobox-label")),B("ComboboxSeparator",e0),B("Calendar",H6),B("DatePicker",D1(G6)),B("Field",b1("pf-field")),B("FieldTitle",L1("pf-field-title")),B("FieldDescription",L1("pf-field-description")),B("FieldContent",b1("pf-field-content")),B("FieldError",L1("pf-field-error")),B("ChoiceCard",W6)}function i8($,Z){let J=document.createElement("form");return J.className="pf-form",J.addEventListener("submit",(q)=>{q.preventDefault();let Q=new FormData(J),Y={};if(Q.forEach((U,H)=>{Y[H]=U}),Z.store.merge(Y),$.onSubmit!=null){let U=d(Z);U.scope={...Z.scope,...Y},v(m($.onSubmit,U),"onSubmit")}}),C($,J,Z),J}function Z4($,Z,J){if(Z.label==null)return;let q=document.createElement("label");if(q.className="pf-input-label",q.textContent=D(Z.label,J),Z.name!=null)q.htmlFor=Z.name;q.style.fontSize="14px",q.style.fontWeight="500",$.insertBefore(q,$.firstChild)}function D1($){return(Z,J)=>{let q=$(Z,J);return q.style.display="flex",q.style.flexDirection="column",q.style.gap="4px",Z4(q,Z,J),q}}function s8($,Z){let J=N("div","pf-input-wrapper");J.style.display="flex",J.style.flexDirection="column",J.style.gap="4px",Z4(J,$,Z);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=D($.placeholder,Z);if($.required===!0)q.required=!0,q.setAttribute("aria-required","true");if($.error!=null)q.setAttribute("aria-invalid","true");let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=w(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)v(m($.onChange,{...d(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return U0(q),J.appendChild(q),J}function n8($,Z){let J=N("div","pf-textarea-wrapper"),q=document.createElement("textarea");if(q.className="pf-textarea",$.name!=null)q.name=$.name;if($.name!=null)q.id=`pf-textarea-${$.name}`;if($.placeholder!=null)q.placeholder=D($.placeholder,Z);if($.rows!=null)q.rows=$.rows;if($.required===!0)q.setAttribute("aria-required","true");let Q=$.name;if(Q!=null){let Y=Z.store.get(Q);if(Y!=null)q.value=w(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,q.value),$.onChange!=null)v(m($.onChange,{...d(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return U0(q),J.appendChild(q),J}function r8($,Z){let J=document.createElement("button");J.className="pf-button",J.type=$.submit===!0?"submit":"button",J.textContent=D($.label,Z);let q=$.variant??"default";if(J.setAttribute("data-variant",q),J6(J,q),$.size!=null)J.setAttribute("data-size",$.size);if($.disabled===!0)J.disabled=!0;return J}function a8($,Z){let J=N("div","pf-button-group");return J.style.display="flex",J.style.gap="8px",C($,J,Z),J}function o8($,Z){let J=N("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(U0(q),$.placeholder!=null){let U=document.createElement("option");U.value="",U.textContent=D($.placeholder,Z),U.disabled=!0,U.selected=!0,U.hidden=!0,q.appendChild(U)}let Q=$.options;if(Array.isArray(Q))for(let U of Q){let H=document.createElement("option");H.value=U.value??"",H.textContent=U.label??H.value,q.appendChild(H)}if($.children)for(let U of $.children)if(U.type==="SelectOption"){let H=document.createElement("option");H.value=U.value??"",H.textContent=U.label??H.value,q.appendChild(H)}else q.appendChild(u(U,Z));let Y=$.name;if(Y){let U=Z.store.get(Y);if(U!=null)q.value=w(U);q.addEventListener("change",()=>{if(Z.store.set(Y,q.value),$.onChange!=null)v(m($.onChange,{...d(Z),scope:{...Z.scope,$event:q.value}}),"onChange")})}return J.appendChild(q),J}function t8($,Z){return N("span")}function e8($,Z){let J=N("label","pf-checkbox-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-checkbox",$.name!=null)q.name=$.name;if($.checked===!0)q.checked=!0;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)v(m($.onChange,{...d(Z),scope:{...Z.scope,$event:q.checked}}),"onChange")})}if(J.appendChild(q),$.label!=null){let Y=N("span");Y.textContent=D($.label,Z),J.appendChild(Y)}return J}function $6($,Z){let J=N("label","pf-switch-wrapper");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="checkbox",q.className="pf-switch",q.setAttribute("role","switch"),$.name!=null)q.name=$.name;let Q=$.name;if(Q){let Y=Z.store.get(Q);if(typeof Y==="boolean")q.checked=Y;q.addEventListener("change",()=>{if(Z.store.set(Q,q.checked),$.onChange!=null)v(m($.onChange,{...d(Z),scope:{...Z.scope,$event:q.checked}}),"onChange")})}if(J.appendChild(q),$.label!=null){let Y=N("span");Y.textContent=D($.label,Z),J.appendChild(Y)}return J}function Z6($,Z){let J=N("div","pf-slider-wrapper"),q=document.createElement("input");if(q.type="range",q.className="pf-slider",$.name!=null)q.name=$.name;if($.min!=null)q.min=w($.min);if($.max!=null)q.max=w($.max);if($.step!=null)q.step=w($.step);let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=w(Y);q.addEventListener("input",()=>{if(Z.store.set(Q,Number(q.value)),$.onChange!=null)v(m($.onChange,{...d(Z),scope:{...Z.scope,$event:Number(q.value)}}),"onChange")})}return J.appendChild(q),J}function U0($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function J6($,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 b1($){return(Z,J)=>{let q=N("div",$);return C(Z,q,J),q}}function L1($){return(Z,J)=>{let q=N("span",$);return q.textContent=D(Z.content,J),q}}function e0(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function q6($,Z){let J=N("label","pf-radio");J.style.display="flex",J.style.alignItems="center",J.style.gap="8px",J.style.cursor="pointer";let q=document.createElement("input");if(q.type="radio",q.value=D($.value,Z),J.appendChild(q),$.label!=null){let Q=N("span","pf-radio-label");Q.textContent=D($.label,Z),J.appendChild(Q)}return J}function Q6($,Z){let J=N("fieldset","pf-radio-group");if(J.style.border="none",J.style.padding="0",J.style.display="flex",J.style.flexDirection="column",J.style.gap="8px",$.label!=null){let Y=document.createElement("legend");Y.textContent=D($.label,Z),Y.style.fontWeight="500",Y.style.marginBottom="4px",J.appendChild(Y)}C($,J,Z);let q=D($.name,Z),Q=Z.store.get(q);for(let Y of Array.from(J.querySelectorAll('input[type="radio"]')))if(Y.name=q,Q!=null&&Y.value===w(Q))Y.checked=!0;return J.addEventListener("change",(Y)=>{let U=Y.target;if(U.type==="radio"){if(Z.store.set(q,U.value),$.onChange!=null)v(m($.onChange,d(Z)),"onChange")}}),J}function Y6($,Z){let J=N("div","pf-combobox"),q=document.createElement("input");if(q.className="pf-combobox-input",q.type="text",q.name=D($.name,Z),$.placeholder!=null)q.placeholder=D($.placeholder,Z);if($.value!==void 0)q.value=D($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=w(Y);q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box";let U=N("div","pf-combobox-dropdown");if(U.style.display="none",U.style.position="absolute",U.style.borderRadius="6px",U.style.maxHeight="200px",U.style.overflowY="auto",U.style.zIndex="50",C($,U,Z),q.addEventListener("focus",()=>{U.style.display="block"}),q.addEventListener("blur",()=>{setTimeout(()=>{U.style.display="none"},150)}),$.searchable!==!1)q.addEventListener("input",()=>{let H=q.value.toLowerCase();for(let G of Array.from(U.querySelectorAll(".pf-combobox-option"))){let X=(G.textContent??"").toLowerCase();G.style.display=X.includes(H)?"":"none"}});if($.onChange!=null)J.addEventListener("pf-combobox-select",()=>{v(m($.onChange,{...d(Z),scope:{...Z.scope,$event:q.value}}),"onChange")});return J.style.position="relative",J.appendChild(q),J.appendChild(U),J}function U6($,Z){let J=N("div","pf-combobox-option");return J.style.padding="6px 12px",J.style.cursor="pointer",J.textContent=D($.label??$.value,Z),J.dataset.value=D($.value,Z),J.addEventListener("mousedown",()=>{let q=J.closest(".pf-combobox"),Q=q?.querySelector("input");if(Q)Q.value=J.dataset.value??"",Z.store.set(Q.name,Q.value),q?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),J}function H6($,Z){let J=N("div","pf-calendar"),q=document.createElement("input");if(q.type="date",q.name=D($.name,Z),$.value!==void 0)q.value=D($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=w(Y);if($.minDate!=null)q.min=D($.minDate,Z);if($.maxDate!=null)q.max=D($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)v(m($.onChange,d(Z)),"onChange")}),J.appendChild(q),J}function G6($,Z){let J=N("div","pf-datepicker"),q=document.createElement("input");if(q.type="date",q.name=D($.name,Z),$.placeholder!=null)q.placeholder=D($.placeholder,Z);if($.value!==void 0)q.value=D($.value,Z);let Q=q.name,Y=Z.store.get(Q);if(Y!=null)q.value=w(Y);if($.minDate!=null)q.min=D($.minDate,Z);if($.maxDate!=null)q.max=D($.maxDate,Z);return q.style.padding="6px 12px",q.style.borderRadius="6px",q.style.width="100%",q.style.boxSizing="border-box",q.addEventListener("change",()=>{if(Z.store.set(q.name,q.value),$.onChange!=null)v(m($.onChange,d(Z)),"onChange")}),J.appendChild(q),J}function W6($,Z){let J=N("div","pf-choice-card");if(J.style.padding="16px",J.style.cursor="pointer",J.style.transition="border-color 0.2s",J.dataset.value=D($.value,Z),$.selected===!0)J.dataset.selected="true";if($.label!=null){let q=N("div","pf-choice-card-label");q.textContent=D($.label,Z),q.style.fontWeight="600",J.appendChild(q)}if($.description!=null){let q=N("div","pf-choice-card-description");q.textContent=D($.description,Z),q.style.fontSize="14px",J.appendChild(q)}return C($,J,Z),J}function J4(){B("Tabs",X6),B("Tab",B6),B("Accordion",M6),B("AccordionItem",_6),B("Dialog",N6),B("Popover",z6),B("Tooltip",E6),B("HoverCard",K6),B("Carousel",F6)}function X6($,Z){let J=N("div","pf-tabs"),q=N("div","pf-tabs-bar");q.setAttribute("role","tablist"),q.style.display="flex",q.style.gap="4px",q.style.marginBottom="12px";let Q=[],Y=[],U=$.children??[],H=(()=>{let X=$.defaultTab;if(typeof X==="number")return X>=0&&X<U.length?X:0;if(typeof X==="string"){let M=U.findIndex((W)=>W.title===X);return M>=0?M:0}return 0})();if($.children)for(let X=0;X<$.children.length;X++){let M=$.children[X],W=`pf-tab-${Math.random().toString(36).slice(2,8)}`,z=`pf-panel-${Math.random().toString(36).slice(2,8)}`,E=document.createElement("button");E.type="button",E.className="pf-tab-trigger",E.textContent=M.title??`Tab ${X+1}`,E.setAttribute("role","tab"),E.setAttribute("aria-selected",X===H?"true":"false"),E.setAttribute("aria-controls",z),E.id=W,E.tabIndex=X===H?0:-1,E.style.padding="8px 16px",E.style.border="none",E.style.background="none",E.style.cursor="pointer",E.style.borderBottom="2px solid transparent",E.style.marginBottom="-2px",E.style.fontSize="14px";let F=N("div","pf-tab-panel");if(F.style.display=X===H?"block":"none",F.setAttribute("role","tabpanel"),F.setAttribute("aria-labelledby",W),F.id=z,F.tabIndex=0,C(M,F,Z),E.addEventListener("click",()=>{G(X)}),X===H)E.classList.add("pf-tab-active"),E.style.fontWeight="600";Y.push(E),Q.push(F),q.appendChild(E)}function G(X){Q.forEach((M)=>M.style.display="none"),Y.forEach((M)=>{M.style.borderBottomColor="transparent",M.style.fontWeight="normal",M.classList.remove("pf-tab-active"),M.setAttribute("aria-selected","false"),M.tabIndex=-1}),Q[X].style.display="block",Y[X].classList.add("pf-tab-active"),Y[X].style.fontWeight="600",Y[X].setAttribute("aria-selected","true"),Y[X].tabIndex=0,Y[X].focus()}q.addEventListener("keydown",(X)=>{let M=Y.indexOf(X.target);if(M<0)return;let W;if(X.key==="ArrowRight")W=(M+1)%Y.length;else if(X.key==="ArrowLeft")W=(M-1+Y.length)%Y.length;else if(X.key==="Home")W=0;else if(X.key==="End")W=Y.length-1;else return;X.preventDefault(),G(W)}),J.appendChild(q);for(let X of Q)J.appendChild(X);return J}function B6($,Z){let J=N("div","pf-tab");return C($,J,Z),J}function M6($,Z){let J=N("div","pf-accordion");return C($,J,Z),J}function _6($,Z){let J=N("div","pf-accordion-item"),q=`pf-acc-${Math.random().toString(36).slice(2,8)}`,Q=document.createElement("button");Q.type="button",Q.className="pf-accordion-trigger",Q.textContent=$.title??"",Q.setAttribute("aria-expanded","false"),Q.setAttribute("aria-controls",q),Q.style.width="100%",Q.style.textAlign="left",Q.style.padding="12px 0",Q.style.border="none",Q.style.background="none",Q.style.cursor="pointer",Q.style.fontSize="14px",Q.style.fontWeight="500";let Y=N("div","pf-accordion-content");return Y.id=q,Y.setAttribute("role","region"),Y.setAttribute("aria-labelledby",Q.id),Y.style.display="none",Y.style.paddingBottom="12px",C($,Y,Z),Q.addEventListener("click",()=>{let U=Y.style.display!=="none";Y.style.display=U?"none":"block",Q.setAttribute("aria-expanded",U?"false":"true")}),J.appendChild(Q),J.appendChild(Y),J}function N6($,Z){let J=N("div","pf-dialog-wrapper");if($.trigger!=null){let Y=u($.trigger,Z);Y.addEventListener("click",()=>{q.showModal()}),J.appendChild(Y)}let q=document.createElement("dialog");if(q.className="pf-dialog",q.setAttribute("aria-modal","true"),q.style.maxWidth="500px",q.style.width="100%",q.style.padding="24px",$.title!=null){let Y=N("h2","pf-dialog-title");Y.textContent=D($.title,Z),Y.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,q.setAttribute("aria-labelledby",Y.id),q.appendChild(Y)}if($.description!=null){let Y=N("p","pf-dialog-desc");Y.textContent=D($.description,Z),q.appendChild(Y)}let Q=N("div","pf-dialog-body");if(C($,Q,Z),q.appendChild(Q),$.dismissible!==!1)q.addEventListener("click",(Y)=>{if(Y.target===q)q.close()});return document.addEventListener("prefab:close-overlay",()=>q.close()),J.appendChild(q),J}function z6($,Z){let J=N("div","pf-popover");J.style.position="relative",J.style.display="inline-block";let q=N("div","pf-popover-content");if(q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="12px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",$.title!=null){let Y=N("div","pf-popover-title");Y.textContent=D($.title,Z),Y.style.fontWeight="600",Y.style.marginBottom="4px",q.appendChild(Y)}C($,q,Z);let Q=()=>{q.style.display=q.style.display==="none"?"block":"none"};if($.trigger!=null){let Y=u($.trigger,Z);Y.addEventListener("click",(U)=>{U.stopPropagation(),Q()}),J.appendChild(Y)}else J.addEventListener("click",(Y)=>{if(q.contains(Y.target)&&q.style.display!=="none")return;Q()});return J.appendChild(q),J}function E6($,Z){let J=N("div","pf-tooltip");J.style.position="relative",J.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,Q=N("div","pf-tooltip-content");return Q.id=q,Q.setAttribute("role","tooltip"),Q.textContent=D($.content??"",Z),Q.style.display="none",Q.style.position="absolute",Q.style.bottom="100%",Q.style.left="50%",Q.style.transform="translateX(-50%)",Q.style.padding="4px 8px",Q.style.borderRadius="4px",Q.style.color="#fff",Q.style.fontSize="12px",Q.style.whiteSpace="nowrap",Q.style.zIndex="50",C($,J,Z),J.setAttribute("aria-describedby",q),J.addEventListener("mouseenter",()=>{Q.style.display="block"}),J.addEventListener("mouseleave",()=>{Q.style.display="none"}),J.addEventListener("focus",()=>{Q.style.display="block"},!0),J.addEventListener("blur",()=>{Q.style.display="none"},!0),J.appendChild(Q),J}function K6($,Z){let J=N("div","pf-hover-card");J.style.position="relative",J.style.display="inline-block";let q=N("div","pf-hover-card-content");if(q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="16px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",q.style.minWidth="200px",$.trigger!=null)J.appendChild(u($.trigger,Z));return C($,q,Z),J.addEventListener("mouseenter",()=>{q.style.display="block"}),J.addEventListener("mouseleave",()=>{q.style.display="none"}),J.appendChild(q),J}function F6($,Z){let J=N("div","pf-carousel");J.style.position="relative",J.style.overflow="hidden",J.setAttribute("role","region"),J.setAttribute("aria-roledescription","carousel"),J.setAttribute("aria-label",D($.label??"Carousel",Z));let q=N("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",C($,q,Z);let Q=0,Y=$.children?.length??0,U=document.createElement("button");U.type="button",U.textContent="‹",U.className="pf-carousel-prev",U.setAttribute("aria-label","Previous slide"),U.style.position="absolute",U.style.left="4px",U.style.top="50%",U.style.transform="translateY(-50%)",U.style.zIndex="10";let H=document.createElement("button");H.type="button",H.textContent="›",H.className="pf-carousel-next",H.setAttribute("aria-label","Next slide"),H.style.position="absolute",H.style.right="4px",H.style.top="50%",H.style.transform="translateY(-50%)",H.style.zIndex="10";let G=()=>{q.style.transform=`translateX(-${Q*100}%)`};return U.addEventListener("click",()=>{if(Y===0)return;Q=Math.max(0,Q-1),G()}),H.addEventListener("click",()=>{if(Y===0)return;Q=Math.min(Y-1,Q+1),G()}),J.appendChild(q),J.appendChild(U),J.appendChild(H),J}function q4(){B("ForEach",D6),B("If",Q4),B("Elif",L6),B("Else",T6),B("Condition",O6),B("Define",I6),B("Use",V6),B("Slot",P6)}function D6($,Z){let J=document.createDocumentFragment(),q=$.expression;if(!q)return J;let Q;if(t(q)){let U=e(q,Z.store,Z.scope);Q=Array.isArray(U)?U:[]}else{let U=Z.store.get(q);Q=Array.isArray(U)?U:[]}let Y=$.let??{};for(let U=0;U<Q.length;U++){let H=Q[U],G={...Z.scope,$item:H,$index:U,...Y},X={...Z,scope:G};if($.children)Y1($.children,J,X)}return J}function Q4($,Z){if(Y4($.condition,Z)){let q=document.createDocumentFragment();if($.children)Y1($.children,q,Z);return q}return document.createDocumentFragment()}function L6($,Z){return Q4($,Z)}function T6($,Z){let J=document.createDocumentFragment();if($.children)Y1($.children,J,Z);return J}function Y4($,Z){if(!$)return!1;if(t($))return Boolean(e($,Z.store,Z.scope));return Boolean(Z.store.get($))}function O6($,Z){let J=document.createDocumentFragment(),q=$.cases,Q=$.else;if(q){for(let Y of q)if(Y4(Y.when,Z)){if(Y.children)Y1(Y.children,J,Z);return J}}if(Q)Y1(Q,J,Z);return J}function I6($,Z){let J=$.name;if(J&&$.children)Z.templates=Z.templates??{},Z.templates[J]=$.children;return document.createDocumentFragment()}function V6($,Z){let J=document.createDocumentFragment(),q=$.def??$.name,Q=Z.templates?.[q];if(!Q)return J;let Y=$.overrides??{},U={...Z.scope,...Y},H={...Z.slots??{},...$.slots??{}};if(Array.isArray($.children))H.default=$.children;let G={...Z,scope:U,slots:H};for(let X of Q)J.appendChild(u(X,G));return J}function P6($,Z){let J=document.createDocumentFragment(),q=$.name??"default",Y=Z.slots?.[q]??$.children;if(Y)for(let U of Y)J.appendChild(u(U,Z));return J}function U4(){B("Alert",R6),B("AlertTitle",j6),B("AlertDescription",k6)}function R6($,Z){let J=N("div","pf-alert");J.setAttribute("role","alert");let q=$.variant??"default";if(J.setAttribute("data-variant",q),J.style.padding="12px 16px",$.icon!=null){let Q=N("span","pf-alert-icon");Q.setAttribute("data-icon",$.icon),Q.style.marginRight="8px",J.appendChild(Q)}return C($,J,Z),J}function j6($,Z){let J=N("h5","pf-alert-title");return J.textContent=D($.content,Z),J.style.fontWeight="600",J.style.marginBottom="4px",J}function k6($,Z){let J=N("p","pf-alert-description");return J.textContent=D($.content,Z),J.style.fontSize="14px",J}function H4(){B("Image",A6),B("Audio",S6),B("Video",f6),B("Embed",C6),B("Svg",b6),B("DropZone",m6),B("Mermaid",h6)}function A6($,Z){let J=document.createElement("img");if(J.className="pf-image",J.src=D($.src,Z),$.alt!=null)J.alt=D($.alt,Z);if($.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function S6($,Z){let J=document.createElement("audio");return J.className="pf-audio",J.src=D($.src,Z),J.controls=!0,J}function f6($,Z){let J=document.createElement("video");if(J.className="pf-video",J.src=D($.src,Z),J.controls=!0,$.width!=null)J.width=$.width;if($.height!=null)J.height=$.height;return J.style.maxWidth="100%",J}function C6($,Z){let J=N("div","pf-embed"),q=document.createElement("iframe");return q.src=D($.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 w6=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 b6($,Z){let J=N("div","pf-svg"),q=D($.content,Z);if(!q.includes("<svg"))return J;if(!/<svg[^>]*\sxmlns\s*=/.test(q))q=q.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"');let Y=new DOMParser().parseFromString(q,"image/svg+xml").querySelector("svg");if(!Y)return J;return G4(Y),J.appendChild(document.importNode(Y,!0)),J}function G4($){let Z=Array.from($.children);for(let J of Z){if(!w6.has(J.tagName.toLowerCase())){J.remove();continue}for(let q of Array.from(J.attributes)){let Q=q.name.toLowerCase();if(Q.startsWith("on")||Q==="href"&&q.value.trim().toLowerCase().startsWith("javascript:"))J.removeAttribute(q.name)}G4(J)}}function y6($,Z){let J=(Z??"").split(",").map((Y)=>Y.trim().toLowerCase()).filter(Boolean);if(J.length===0)return!0;let q=$.name.toLowerCase(),Q=$.type.toLowerCase();return J.some((Y)=>{if(Y.startsWith("."))return q.endsWith(Y);if(Y.endsWith("/*"))return Q.startsWith(Y.slice(0,-1));return Q===Y})}function m6($,Z){let J=N("div","pf-dropzone");J.style.padding="32px",J.style.textAlign="center",J.style.cursor="pointer",J.textContent=D($.label??"Drop files here",Z);let q=document.createElement("input");if(q.type="file",q.style.display="none",$.accept!=null)q.accept=$.accept;if($.multiple===!0)q.multiple=!0;J.appendChild(q),J.setAttribute("role","button"),J.tabIndex=0;function Q(U){let H=Array.from(U??[]).filter((G)=>y6(G,$.accept));return $.multiple===!0?H:H.slice(0,1)}function Y(U){if(U.length===0)return;if($.resultKey!=null)Z.store.set($.resultKey,U),Z.rerender();if($.onDrop!=null)v(m($.onDrop,{...d(Z),scope:{...Z.scope,$result:U}}),"onDrop")}return q.addEventListener("change",()=>{Y(Q(q.files)),q.value=""}),J.addEventListener("click",()=>q.click()),J.addEventListener("keydown",(U)=>{if(U.key==="Enter"||U.key===" ")U.preventDefault(),q.click()}),J.addEventListener("dragover",(U)=>{U.preventDefault(),J.classList.add("pf-dropzone-active")}),J.addEventListener("dragleave",()=>{J.classList.remove("pf-dropzone-active")}),J.addEventListener("drop",(U)=>{U.preventDefault(),J.classList.remove("pf-dropzone-active"),Y(Q(U.dataTransfer?.files??null))}),J}function h6($,Z){let J=N("div","pf-mermaid");J.setAttribute("data-mermaid","true");let q=D($.content,Z);if(J.textContent=q,typeof globalThis.mermaid<"u")J.classList.add("mermaid"),J.textContent=q;return J}var v6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",g6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",H0=null,y1=null;async function u6(){if(H0)return H0;if(y1)return y1;return y1=import(v6).then(($)=>{let Z=$;return Z.GlobalWorkerOptions.workerSrc=g6,H0=Z,Z}),y1}function X4(){B("PdfViewer",x6)}function x6($,Z){let J=N("div","pf-pdf-viewer"),q=$.src!=null?D($.src,Z):void 0,Q=$.data,Y=$.page!=null?$.page:1,U=$.zoom!=null?$.zoom:"fit-width",H=$.toolbar!==!1,G=$.height!=null?$.height:600;J.style.height=`${G}px`,J.style.display="flex",J.style.flexDirection="column",J.style.overflow="hidden",J.style.border="1px solid var(--color-border-primary, #e5e7eb)",J.style.borderRadius="var(--border-radius-md, 0.375rem)",J.style.background="var(--color-background-secondary, #f9fafb)";let X=N("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),c6(J,X,{src:q,data:Q,initialPage:Y,zoom:U,showToolbar:H}),J}async function c6($,Z,J){try{let q=await u6(),Q;if(J.src)Q={url:J.src};else if(J.data){let z=atob(J.data),E=new Uint8Array(z.length);for(let F=0;F<z.length;F++)E[F]=z.charCodeAt(F);Q={data:E}}else{Z.textContent="Error: No PDF source provided";return}let Y=await q.getDocument(Q).promise;Z.remove();let U=Math.max(1,Math.min(J.initialPage,Y.numPages)),H=null,G=null;if(J.showToolbar){let z=p6(Y.numPages,U,{onPrev:()=>{if(U>1)U--,W()},onNext:()=>{if(U<Y.numPages)U++,W()},onPageChange:(E)=>{let F=Math.max(1,Math.min(E,Y.numPages));if(F!==U)U=F,W()}});H=z.pageInput,G=z.pageCount,$.insertBefore(z.el,$.firstChild)}let X=N("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 M=document.createElement("canvas");M.style.display="block",M.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",X.appendChild(M);async function W(){let z=await Y.getPage(U),E=X.clientWidth-16,F,_=z.getViewport({scale:1});if(J.zoom==="fit-width")F=E/_.width;else if(J.zoom==="fit-page"){let V=X.clientHeight-16,A=E/_.width,I=V/_.height;F=Math.min(A,I)}else F=typeof J.zoom==="number"?J.zoom:1;let K=z.getViewport({scale:F});M.width=K.width,M.height=K.height,M.style.width=`${K.width}px`,M.style.height=`${K.height}px`;let T=M.getContext("2d");if(!T)return;if(await z.render({canvasContext:T,viewport:K}).promise,H)H.value=String(U);if(G)G.textContent=`/ ${Y.numPages}`}await W()}catch(q){Z.textContent=`PDF Error: ${q instanceof Error?q.message:String(q)}`,Z.style.color="var(--color-text-danger, #dc2626)"}}function p6($,Z,J){let q=N("div","pf-pdf-toolbar");q.style.display="flex",q.style.alignItems="center",q.style.gap="8px",q.style.padding="6px 12px",q.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",q.style.background="var(--color-background-primary, #fff)",q.style.flexShrink="0",q.style.fontSize="13px";let Q=document.createElement("button");Q.textContent="‹",Q.title="Previous page",Q.className="pf-pdf-btn",W4(Q),Q.addEventListener("click",J.onPrev);let Y=document.createElement("button");Y.textContent="›",Y.title="Next page",Y.className="pf-pdf-btn",W4(Y),Y.addEventListener("click",J.onNext);let U=document.createElement("input");U.type="number",U.min="1",U.max=String($),U.value=String(Z),U.style.width="48px",U.style.textAlign="center",U.style.border="1px solid var(--color-border-primary, #e5e7eb)",U.style.borderRadius="4px",U.style.padding="2px 4px",U.style.fontSize="13px",U.addEventListener("change",()=>{let G=parseInt(U.value,10);if(!isNaN(G))J.onPageChange(G)});let H=document.createElement("span");return H.textContent=`/ ${$}`,H.style.color="var(--color-text-secondary, #6b7280)",q.appendChild(Q),q.appendChild(U),q.appendChild(H),q.appendChild(Y),{el:q,pageInput:U,pageCount:H}}function W4($){$.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 h1=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function W1($,Z){let J=document.createElement("div");return J.className="pf-chart-tooltip",$.appendChild(J),$.addEventListener("mouseleave",()=>{J.classList.remove("pf-visible")}),{wrapper:$,tooltip:J,svgEl:Z}}function $1($,Z,J,q,Q){let{tooltip:Y,svgEl:U,wrapper:H}=$;if(Q.length===0)return;let G="";if(q)G+=`<div class="pf-chart-tooltip-label">${m1(q)}</div>`;for(let K of Q)G+='<div class="pf-chart-tooltip-row">',G+=`<span class="pf-chart-tooltip-dot" style="background:${m1(K.color)}"></span>`,G+=`<span>${m1(K.label)}:</span> <strong>${m1(String(K.value))}</strong>`,G+="</div>";Y.innerHTML=G;let X=U.getBoundingClientRect(),M=H.getBoundingClientRect(),W=U.viewBox.baseVal,z=X.width/(W.width||1),E=X.left-M.left+Z*z,F=Y.offsetWidth||100,_=E+12;if(_+F>M.width)_=E-F-12;Y.style.left=`${Math.max(0,_)}px`,Y.style.top="4px",Y.classList.add("pf-visible")}function m1($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function B4($,Z,J,q,Q,Y,U,H){let G=Q.plotWidth/J.length;for(let X=0;X<J.length;X++){let M=Q.plotLeft+X*G,W=document.createElementNS("http://www.w3.org/2000/svg","rect");W.setAttribute("x",String(M)),W.setAttribute("y",String(Q.plotTop)),W.setAttribute("width",String(G)),W.setAttribute("height",String(Q.plotHeight)),W.setAttribute("fill","transparent"),W.style.cursor="default";let z=Y?J[X][Y]:void 0,E=z!=null?H?H(z):w(z):void 0,F=q.map((V,A)=>({label:V.label??V.dataKey,value:U(J[X][V.dataKey],V,A),color:V.color??h1[A%h1.length]})),_=M+G/2,K=()=>$1($,_,Q.plotTop,E,F),T=()=>$.tooltip.classList.remove("pf-visible");W.addEventListener("mouseenter",K),W.addEventListener("mouseleave",T),W.addEventListener("touchstart",K,{passive:!0}),W.addEventListener("touchend",T,{passive:!0}),Z.appendChild(W)}}function M4($,Z,J,q,Q,Y,U,H,G,X){let M=J.length===1?Q.plotWidth:Q.plotWidth/(J.length-1);for(let W=0;W<J.length;W++){let z=J.length===1?(Q.plotLeft+Q.plotRight)/2:Q.plotLeft+W/(J.length-1)*Q.plotWidth,E=J.length===1?Q.plotLeft:z-M/2,F=J.length===1?Q.plotWidth:M,_=document.createElementNS("http://www.w3.org/2000/svg","rect");_.setAttribute("x",String(Math.max(Q.plotLeft,E))),_.setAttribute("y",String(Q.plotTop)),_.setAttribute("width",String(Math.min(F,Q.plotRight-Math.max(Q.plotLeft,E)))),_.setAttribute("height",String(Q.plotHeight)),_.setAttribute("fill","transparent"),_.style.cursor="default";let K=Y?J[W][Y]:void 0,T=K!=null?X?X(K):w(K):void 0,V=q.map((j,f)=>({label:j.label??j.dataKey,value:U(J[W][j.dataKey],j,f),color:j.color??h1[f%h1.length]})),A=()=>{if($1($,z,Q.plotTop,T,V),H)H.setAttribute("x1",String(z)),H.setAttribute("x2",String(z)),H.setAttribute("opacity","1");if(G)for(let j of G){for(let f of j)f.setAttribute("data-visible","false");j[W]?.setAttribute("data-visible","true")}},I=()=>{if($.tooltip.classList.remove("pf-visible"),H)H.setAttribute("opacity","0");if(G)for(let j of G)for(let f of j)f.setAttribute("data-visible","false")};_.addEventListener("mouseenter",A),_.addEventListener("mouseleave",I),_.addEventListener("touchstart",A,{passive:!0}),_.addEventListener("touchend",I,{passive:!0}),Z.appendChild(_)}}var s=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],J1="var(--muted-foreground, #6b7280)",z1="var(--border, #e5e7eb)",X1="10";function v1($,Z,J,q=!1){let Q=J?44:0,Y=$-(q?44:0),U=10,H=Z-24;return{plotLeft:Q,plotRight:Y,plotTop:10,plotBottom:H,plotWidth:Y-Q,plotHeight:H-10}}function _4($,Z=5){if($<=0)return[0];let J=$/Z,q=Math.pow(10,Math.floor(Math.log10(J))),Q=J/q,Y=Q<=1.5?q:Q<=3?2*q:Q<=7?5*q:10*q,U=[];for(let H=0;H<=$+Y*0.01;H+=Y)U.push(Math.round(H*1000)/1000);return U}function G0($,Z,J,q,Q){let Y=_4(J);for(let U of Y){let H=Z.plotBottom-(J>0?U/J*Z.plotHeight:0),G=n("text",{x:Z.plotLeft-6,y:H+3,"text-anchor":"end","font-size":X1,fill:J1});if(G.textContent=B0(U,Q),$.appendChild(G),q&&U>0)$.appendChild(n("line",{x1:Z.plotLeft,y1:H,x2:Z.plotRight,y2:H,stroke:z1,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function W0($,Z,J,q){let Q=_4(J);for(let Y of Q){let U=Z.plotBottom-(J>0?Y/J*Z.plotHeight:0),H=n("text",{x:Z.plotRight+6,y:U+3,"text-anchor":"start","font-size":X1,fill:J1});H.textContent=B0(Y,q),$.appendChild(H)}}function X0($,Z,J,q,Q,Y){for(let U=0;U<Z.length;U++){let H=Z[U][J],G=n("text",{x:q(U),y:Q+14,"text-anchor":"middle","font-size":X1,fill:J1});G.textContent=H==null?"":Y?Y(H):w(H),$.appendChild(G)}}function g1($,Z){$.appendChild(n("line",{x1:Z.plotLeft,y1:Z.plotBottom,x2:Z.plotRight,y2:Z.plotBottom,stroke:J1,"stroke-width":1}))}function Z1($,Z,J){if($==null)return"";let q=l(`{{ __v | ${Z} }}`,{...J,scope:{...J.scope,__v:$}});return w(q??$)}function B0($,Z){if(Z==="currency")return`$${$.toLocaleString()}`;if(Z==="percent")return`${$}%`;if($>=1e6)return`${($/1e6).toFixed(1)}M`;if($>=1000)return`${($/1000).toFixed(1)}K`;return String($)}function q1($){let Z=$.yAxisFormat??$.valueFormat;return Z&&Z!=="auto"?Z:void 0}function M0($,Z,J){return(q,Q)=>{if(q===null||q===void 0)return"—";if(Q.tooltipFormat)return Z1(q,Q.tooltipFormat,$);let Y=Q.yAxisId==="right"?J:Z;return B0(Number(q),Y)}}function U1($,Z,J){let q=document.createElementNS("http://www.w3.org/2000/svg","svg");if(q.setAttribute("width","100%"),q.setAttribute("height",String(Z)),q.setAttribute("viewBox",`0 0 ${$} ${Z}`),q.setAttribute("role","img"),J)q.setAttribute("aria-label",`${J} chart`);return q.style.overflow="visible",q}function n($,Z){let J=document.createElementNS("http://www.w3.org/2000/svg",$);for(let[q,Q]of Object.entries(Z))J.setAttribute(q,String(Q));return J}function u1($,Z){let J=n("text",$);return J.textContent=Z,J}function B1($,Z,J,q){let Q=q*Math.PI/180;return{x:$+J*Math.cos(Q),y:Z-J*Math.sin(Q)}}function _0($,Z,J,q,Q){let Y=Math.max(2,Math.ceil(Math.abs(Q-q)/4)),U=[];for(let H=0;H<=Y;H++){let G=B1($,Z,J,q+(Q-q)*H/Y);U.push(`${H===0?"M":"L"} ${G.x.toFixed(2)} ${G.y.toFixed(2)}`)}return U.join(" ")}function M1($,Z,J){if(J===!1||Z.length<=1)return;let q=N("div","pf-chart-legend");q.style.display="flex",q.style.gap="12px",q.style.fontSize="12px",q.style.marginBottom="8px";for(let Q=0;Q<Z.length;Q++){let Y=N("div","pf-chart-legend-item");Y.style.display="flex",Y.style.alignItems="center",Y.style.gap="4px";let U=N("span");U.style.width="8px",U.style.height="8px",U.style.borderRadius="50%",U.style.backgroundColor=Z[Q].color??s[Q%s.length];let H=N("span");H.textContent=Z[Q].label??Z[Q].dataKey,Y.appendChild(U),Y.appendChild(H),q.appendChild(Y)}$.appendChild(q)}function z4(){B("BarChart",d6),B("LineChart",N4),B("AreaChart",N4),B("PieChart",l6),B("RadarChart",n6),B("ScatterChart",i6),B("RadialChart",s6),B("Histogram",r6)}function d6($,Z){let J=N("div","pf-chart pf-bar-chart"),q=l($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,H=$.showGrid===!0,G=$.showYAxisRight===!0,X=$.showTooltip!==!1,M=$.xAxis,W=$.tooltipXKey,z=$.xAxisFormat,E=$.tooltipXFormat,F=Q.filter((O)=>O.yAxisId!=="right"),_=Q.filter((O)=>O.yAxisId==="right"),K=G&&_.length>0,T=F.length>0?Math.max(...q.flatMap((O)=>F.map((L)=>Number(O[L.dataKey]??0))),1):1,V=K?Math.max(...q.flatMap((O)=>_.map((L)=>Number(O[L.dataKey]??0))),1):1,A=400,I=v1(A,Y,U,K),j=U1(A,Y,"Bar");if(U)G0(j,I,T,H,q1($));if(K)W0(j,I,V,$.yAxisRightFormat);g1(j,I);let f=I.plotWidth/q.length,S=f/(Q.length+1);for(let O=0;O<q.length;O++)for(let L=0;L<Q.length;L++){let k=Q[L],y=q[O][k.dataKey];if(y===null||y===void 0)continue;let i=k.yAxisId==="right"?V:T,g=Number(y),P=Math.max(0,g/i*I.plotHeight),c=I.plotLeft+O*f+L*S+S/2,R=document.createElementNS("http://www.w3.org/2000/svg","rect");R.setAttribute("x",String(c)),R.setAttribute("y",String(I.plotBottom-P)),R.setAttribute("width",String(S*0.8)),R.setAttribute("height",String(P)),R.setAttribute("fill",k.color??s[L%s.length]),R.setAttribute("rx","2"),j.appendChild(R)}if(M){let O=z?(L)=>Z1(L,z,Z):void 0;X0(j,q,M,(L)=>{return I.plotLeft+L*f+f/2},I.plotBottom,O)}if(X){let O=W1(J,j),L=M0(Z,q1($),$.yAxisRightFormat);B4(O,j,q,Q,I,W??M,L,E?(y)=>Z1(y,E,Z):void 0)}return M1(J,Q,$.showLegend),J.appendChild(j),J}function N4($,Z){let J=N("div",`pf-chart pf-${$.type.toLowerCase()}-chart`),q=l($.data,Z)??[],Q=$.series??[],Y=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let U=$.showYAxis!==!1,H=$.showGrid===!0,G=$.showYAxisRight===!0,X=$.showTooltip!==!1,M=$.xAxis,W=$.tooltipXKey,z=$.xAxisFormat,E=$.tooltipXFormat,F=Q.filter((L)=>L.yAxisId!=="right"),_=Q.filter((L)=>L.yAxisId==="right"),K=G&&_.length>0,T=F.length>0?Math.max(...q.flatMap((L)=>F.map((k)=>Number(L[k.dataKey]??0))),1):1,V=K?Math.max(...q.flatMap((L)=>_.map((k)=>Number(L[k.dataKey]??0))),1):1,A=400,I=v1(A,Y,U,K),j=U1(A,Y,$.type==="AreaChart"?"Area":"Line"),f=$.type==="AreaChart";if(U)G0(j,I,T,H,q1($));if(K)W0(j,I,V,$.yAxisRightFormat);g1(j,I);let S=[];for(let L=0;L<Q.length;L++){let k=Q[L],y=k.yAxisId==="right",x=y?V:T,i=k.color??s[L%s.length],g=q.map((R,h)=>{let p=R[k.dataKey],r=p===null||p===void 0,H1=q.length===1?(I.plotLeft+I.plotRight)/2:I.plotLeft+h/(q.length-1)*I.plotWidth,y4=r?I.plotBottom:I.plotBottom-Number(p)/x*I.plotHeight;return{x:H1,y:y4,isNull:r}});if(f){let R=[],h=()=>{if(R.length<2){R=[];return}let p=`M ${R[0].x},${I.plotBottom} `+R.map((H1)=>`L ${H1.x},${H1.y}`).join(" ")+` L ${R[R.length-1].x},${I.plotBottom} Z`,r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",p),r.setAttribute("fill",i),r.setAttribute("opacity","0.15"),j.appendChild(r),R=[]};for(let p of g){if(p.isNull){h();continue}R.push(p)}h()}let P="";for(let R of g){if(R.isNull)continue;let h=g.indexOf(R),p=h===0||g[h-1].isNull;P+=`${p?"M":"L"} ${R.x},${R.y} `}if(P){let R=document.createElementNS("http://www.w3.org/2000/svg","path");if(R.setAttribute("d",P.trim()),R.setAttribute("fill","none"),R.setAttribute("stroke",i),R.setAttribute("stroke-width","2"),y)R.setAttribute("stroke-dasharray","6 3");j.appendChild(R)}let c=[];for(let R of g){let h=document.createElementNS("http://www.w3.org/2000/svg","circle");if(h.setAttribute("cx",String(R.x)),h.setAttribute("cy",String(R.y)),h.setAttribute("r","4"),h.setAttribute("fill",i),h.setAttribute("class","pf-data-dot"),h.setAttribute("data-visible","false"),h.style.pointerEvents="none",R.isNull)h.style.display="none";j.appendChild(h),c.push(h)}S.push(c)}let O=document.createElementNS("http://www.w3.org/2000/svg","line");if(O.setAttribute("class","pf-crosshair"),O.setAttribute("x1",String(I.plotLeft)),O.setAttribute("x2",String(I.plotLeft)),O.setAttribute("y1",String(I.plotTop)),O.setAttribute("y2",String(I.plotBottom)),O.setAttribute("stroke",J1),O.setAttribute("stroke-width","1"),O.setAttribute("stroke-dasharray","3 3"),O.setAttribute("opacity","0"),j.appendChild(O),M){let L=z?(k)=>Z1(k,z,Z):void 0;X0(j,q,M,(k)=>{return q.length===1?(I.plotLeft+I.plotRight)/2:I.plotLeft+k/(q.length-1)*I.plotWidth},I.plotBottom,L)}if(X){let L=W1(J,j),k=M0(Z,q1($),$.yAxisRightFormat);M4(L,j,q,Q,I,W??M,k,O,S,E?(x)=>Z1(x,E,Z):void 0)}return M1(J,Q,$.showLegend),J.appendChild(j),J}function l6($,Z){let J=N("div","pf-chart pf-pie-chart"),q=l($.data,Z)??[],Q=$.series??[],Y=$.height??300,U=Math.min(Y,300),H=$.showTooltip!==!1,G=$.dataKey??Q[0]?.dataKey,X=$.nameKey??$.tooltipXKey??$.xAxis,M=Q.length>0?Q:G?[{dataKey:G,label:G}]:[];if(q.length===0||!G)return J.textContent="No chart data",J;let W=U1(U,U,"Pie"),z=U/2,E=U/2,F=U/2-10,_=$.tooltipXFormat,K=q1($),T=(f)=>K?Z1(f,K,Z):String(f),V=q.map((f)=>Number(f[G]??0)),A=V.reduce((f,S)=>f+S,0);if(A===0)return J.textContent="No chart data",J.appendChild(W),J;let I=H?W1(J,W):void 0,j=-Math.PI/2;for(let f=0;f<V.length;f++){let S=V[f]/A*2*Math.PI,O=j+S,L=S>Math.PI?1:0,k=z+F*Math.cos(j),y=E+F*Math.sin(j),x=z+F*Math.cos(O),i=E+F*Math.sin(O),g=s[f%s.length],P=document.createElementNS("http://www.w3.org/2000/svg","path");if(P.setAttribute("d",`M ${z},${E} L ${k},${y} A ${F},${F} 0 ${L} 1 ${x},${i} Z`),P.setAttribute("fill",g),P.style.cursor="default",I){let c=X?q[f][X]:void 0,R=c!=null?_?Z1(c,_,Z):w(c):`Slice ${f+1}`,h=`${(V[f]/A*100).toFixed(1)}%`,p=j+S/2,r=z+F*0.6*Math.cos(p);P.addEventListener("mouseenter",()=>{$1(I,r,E,R,[{label:M[0].label??G,value:`${T(V[f])} (${h})`,color:g}])}),P.addEventListener("mouseleave",()=>{I.tooltip.classList.remove("pf-visible")}),P.addEventListener("touchstart",()=>{$1(I,r,E,R,[{label:M[0].label??G,value:`${T(V[f])} (${h})`,color:g}])},{passive:!0}),P.addEventListener("touchend",()=>{I.tooltip.classList.remove("pf-visible")},{passive:!0})}W.appendChild(P),j=O}return M1(J,M,$.showLegend),J.appendChild(W),J}function i6($,Z){let J=N("div","pf-chart pf-scatter-chart"),q=l($.data,Z)??[],Q=$.xAxis,Y=$.yAxis,U=$.zAxis,H=$.series??[],G=$.height??300;if(q.length===0||!Q||!Y)return J.textContent="No chart data",J;let X=$.showGrid!==!1,M=$.showTooltip!==!1,W=H[0]?.color??s[0],z=q1($),E=(P)=>z?Z1(P,z,Z):String(Math.round(P*100)/100),F=q.map((P)=>Number(P[Q]??0)),_=q.map((P)=>Number(P[Y]??0)),K=Math.min(...F),T=Math.max(...F),V=Math.min(..._),A=Math.max(..._),I=T-K||1,j=A-V||1,f=U?q.map((P)=>Number(P[U]??0)):[],S=U?Math.max(...f,1):1,O=400,L=v1(O,G,!0),k=U1(O,G,"Scatter"),y=(P)=>L.plotLeft+(P-K)/I*L.plotWidth,x=(P)=>L.plotBottom-(P-V)/j*L.plotHeight,i=4;for(let P=0;P<=i;P++){let c=V+j*P/i,R=x(c);if(k.appendChild(u1({x:L.plotLeft-6,y:R+3,"text-anchor":"end","font-size":X1,fill:J1},E(c))),X&&P>0)k.appendChild(n("line",{x1:L.plotLeft,y1:R,x2:L.plotRight,y2:R,stroke:z1,"stroke-width":1,"stroke-dasharray":"4 3"}))}g1(k,L);for(let P of[K,(K+T)/2,T])k.appendChild(u1({x:y(P),y:L.plotBottom+14,"text-anchor":"middle","font-size":X1,fill:J1},String(Math.round(P*100)/100)));let g=M?W1(J,k):void 0;for(let P=0;P<q.length;P++){let c=y(F[P]),R=x(_[P]),h=U?4+Math.sqrt(f[P]/S)*14:4,p=n("circle",{cx:c,cy:R,r:h,fill:W,"fill-opacity":U?0.6:0.85});if(g){let r=[{label:Q,value:E(F[P]),color:W},{label:Y,value:E(_[P]),color:W},...U?[{label:U,value:E(f[P]),color:W}]:[]],H1=H[0]?.label??"Point";p.addEventListener("mouseenter",()=>$1(g,c,R,H1,r)),p.addEventListener("mouseleave",()=>g.tooltip.classList.remove("pf-visible")),p.addEventListener("touchstart",()=>$1(g,c,R,H1,r),{passive:!0}),p.addEventListener("touchend",()=>g.tooltip.classList.remove("pf-visible"),{passive:!0})}k.appendChild(p)}return M1(J,H,$.showLegend),J.appendChild(k),J}function s6($,Z){let J=N("div","pf-chart pf-radial-chart"),q=l($.data,Z)??[],Q=$.series??[],Y=$.dataKey??Q[0]?.dataKey,U=$.nameKey??$.tooltipXKey??$.xAxis,H=$.height??300;if(q.length===0||!Y)return J.textContent="No chart data",J;let G=Math.min(H,300),X=G/2,M=G/2,W=G/2-10,z=Math.max(0,Math.min($.innerRadius??30,W-10)),E=$.startAngle??180,F=$.endAngle??0,_=$.showTooltip!==!1,K=q.map((L)=>Number(L[Y]??0)),T=Math.max(...K,1),V=U1(G,G,"Radial"),A=(W-z)/q.length,I=Math.max(2,A*0.7),j=q1($),f=(L)=>j?Z1(L,j,Z):String(L),S=_?W1(J,V):void 0,O=[];for(let L=0;L<q.length;L++){let k=W-A*L-A/2,y=Q[L]?.color??s[L%s.length],x=K[L]/T,i=E+x*(F-E),g=U?q[L][U]:null,P=g!=null?w(g):Q[L]?.label??Y;O.push({dataKey:P||Y,label:P||Y,color:y}),V.appendChild(n("path",{d:_0(X,M,k,E,F),fill:"none",stroke:z1,"stroke-width":I,"stroke-linecap":"round"}));let c=n("path",{d:_0(X,M,k,E,i),fill:"none",stroke:y,"stroke-width":I,"stroke-linecap":"round"});if(S){let R=B1(X,M,k,(E+i)/2),h=[{label:Y,value:f(K[L]),color:y}],p=P||Y;c.addEventListener("mouseenter",()=>$1(S,R.x,R.y,p,h)),c.addEventListener("mouseleave",()=>S.tooltip.classList.remove("pf-visible")),c.addEventListener("touchstart",()=>$1(S,R.x,R.y,p,h),{passive:!0}),c.addEventListener("touchend",()=>S.tooltip.classList.remove("pf-visible"),{passive:!0})}V.appendChild(c)}return M1(J,O,$.showLegend),J.appendChild(V),J}function n6($,Z){let J=N("div","pf-chart pf-radar-chart"),q=l($.data,Z)??[],Q=$.series??[],Y=$.axisKey??$.xAxis,U=$.height??300;if(q.length===0||Q.length===0)return J.textContent="No chart data",J;let H=$.filled!==!1,G=$.showDots===!0,X=$.showGrid!==!1,M=$.showTooltip!==!1,W=Math.min(U,320),z=W/2,E=W/2,F=W/2-24,_=q.length,K=Math.max(...q.flatMap((S)=>Q.map((O)=>Number(S[O.dataKey]??0))),1),T=(S)=>90-360*S/_,V=(S)=>S.map((O)=>`${O.x.toFixed(1)},${O.y.toFixed(1)}`).join(" "),A=U1(W,W,"Radar");if(X){for(let O=1;O<=4;O++){let L=F*O/4,k=Array.from({length:_},(y,x)=>B1(z,E,L,T(x)));A.appendChild(n("polygon",{points:V(k),fill:"none",stroke:z1,"stroke-width":1}))}for(let O=0;O<_;O++){let L=B1(z,E,F,T(O));A.appendChild(n("line",{x1:z,y1:E,x2:L.x,y2:L.y,stroke:z1,"stroke-width":1}))}}for(let S=0;S<_;S++){let O=B1(z,E,F+12,T(S)),L=Y?q[S][Y]:null;A.appendChild(u1({x:O.x,y:O.y+3,"text-anchor":"middle","font-size":X1,fill:J1},L!=null?String(L):""))}let I=M?W1(J,A):void 0,j=q1($),f=(S)=>j?Z1(S,j,Z):String(S);for(let S=0;S<Q.length;S++){let O=Q[S],L=O.color??s[S%s.length],k=q.map((y,x)=>B1(z,E,Number(y[O.dataKey]??0)/K*F,T(x)));if(A.appendChild(n("polygon",{points:V(k),fill:H?L:"none","fill-opacity":H?0.2:0,stroke:L,"stroke-width":2})),G||I)for(let y=0;y<k.length;y++){let x=n("circle",{cx:k[y].x,cy:k[y].y,r:G?3:6,fill:G?L:"transparent","fill-opacity":G?1:0});if(I){let i=Y?q[y][Y]:null,g=i!=null?w(i):O.label??O.dataKey,P=[{label:O.label??O.dataKey,value:f(Number(q[y][O.dataKey]??0)),color:L}];x.addEventListener("mouseenter",()=>$1(I,k[y].x,k[y].y,g,P)),x.addEventListener("mouseleave",()=>I.tooltip.classList.remove("pf-visible")),x.addEventListener("touchstart",()=>$1(I,k[y].x,k[y].y,g,P),{passive:!0}),x.addEventListener("touchend",()=>I.tooltip.classList.remove("pf-visible"),{passive:!0})}A.appendChild(x)}}return M1(J,Q,$.showLegend),J.appendChild(A),J}function r6($,Z){let J=N("div","pf-chart pf-histogram"),q=l($.data,Z);if(!q||q.length===0)return J.textContent="No data",J;let Q=q,Y=$.bins??10,U=$.height??200,H=$.color??s[0],G=Math.min(...Q),M=(Math.max(...Q)-G)/Y||1,W=Array(Y).fill(0);for(let T of Q){let V=Math.min(Math.floor((T-G)/M),Y-1);W[V]++}let z=Math.max(...W),E=300,F=U,_=E/Y,K=U1(E,F,"Histogram");for(let T=0;T<Y;T++){let V=z>0?W[T]/z*F:0,A=document.createElementNS("http://www.w3.org/2000/svg","rect");A.setAttribute("x",String(T*_)),A.setAttribute("y",String(F-V)),A.setAttribute("width",String(_-1)),A.setAttribute("height",String(V)),A.setAttribute("fill",H),K.appendChild(A)}return J.appendChild(K),J}function E4(){B("Table",a6),B("TableHead",N0("thead")),B("TableBody",N0("tbody")),B("TableFooter",N0("tfoot")),B("TableRow",o6),B("TableHeader",t6),B("TableCell",e6),B("TableCaption",$5),B("ExpandableRow",Z5)}function a6($,Z){let J=document.createElement("table");return J.className=$.striped===!0?"pf-table pf-table-striped":"pf-table",J.style.width="100%",J.style.borderCollapse="collapse",C($,J,Z),J}function N0($){return(Z,J)=>{let q=document.createElement($);return q.className=`pf-${$}`,C(Z,q,J),q}}function o6($,Z){let J=document.createElement("tr");return J.className="pf-table-row",C($,J,Z),J}function t6($,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=D($.content,Z),J}function e6($,Z){let J=document.createElement("td");if(J.className="pf-table-cell",J.style.padding="8px 12px",$.colSpan!=null)J.colSpan=$.colSpan;if($.rowSpan!=null)J.rowSpan=$.rowSpan;return C($,J,Z),J}function $5($,Z){let J=document.createElement("caption");return J.className="pf-table-caption",J.style.padding="8px",J.style.fontSize="14px",J.textContent=D($.content,Z),J}function Z5($,Z){let J=N("div","pf-expandable-row"),q=N("div","pf-expandable-row-summary");q.style.cursor="pointer",q.style.display="flex",q.style.alignItems="center",q.style.gap="8px";let Q=N("span","pf-expandable-arrow");Q.textContent="▶",Q.style.transition="transform 0.2s",Q.style.fontSize="10px",q.appendChild(Q);let Y=$.summary;if(Y)for(let G of Y)q.appendChild(u(G,Z));let U=N("div","pf-expandable-row-detail");U.style.display="none",U.style.paddingLeft="24px",C($,U,Z);let H=!1;return q.addEventListener("click",()=>{H=!H,U.style.display=H?"block":"none",Q.style.transform=H?"rotate(90deg)":""}),J.appendChild(q),J.appendChild(U),J}var K4=!1;function x1(){if(K4)return;K4=!0,d0(),n0(),o0(),t0(),$4(),J4(),q4(),U4(),H4(),X4(),z4(),E4()}function E0($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function K0($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function z0($,Z=" "){return Object.entries($).map(([J,q])=>`${Z}--${E0(J)}: ${K0(q)};`).join(`
7
+ `)}function F4($){if(!$)return"";let Z=[];if($.light&&Object.keys($.light).length>0)Z.push(`:root {
8
+ ${z0($.light)}
9
+ }`);if($.dark&&Object.keys($.dark).length>0){let J=z0($.dark);Z.push(`.dark, [data-theme="dark"] {
10
10
  ${J}
11
11
  }`),Z.push(`@media (prefers-color-scheme: dark) {
12
12
  :root:not([data-theme="light"]):not(.light) {
13
- ${N0($.dark," ")}
13
+ ${z0($.dark," ")}
14
14
  }
15
15
  }`)}return Z.join(`
16
- `)}function E1($,Z){$.setAttribute("data-theme",Z),$.classList.toggle("dark",Z==="dark"),$.classList.toggle("light",Z==="light")}function K0($,Z){if(!Z)return;if(Z.light)for(let[J,q]of Object.entries(Z.light))$.style.setProperty(`--${z0(J)}`,E0(q));if(Z.dark){let q=document.getElementById("prefab-dark-theme");if(!q)q=document.createElement("style"),q.id="prefab-dark-theme",document.head.appendChild(q);q.textContent=E8({dark:Z.dark})}}function F0($,Z){if(!$||typeof document>"u")return;let J=(q)=>{for(let[Q,Y]of Object.entries($))if(o6(Q,q))q.preventDefault(),Z(Y)};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)}function o6($,Z){let J=$.toLowerCase().split("+").map((Y)=>Y.trim()),q=J[J.length-1],Q=new Set(J.slice(0,-1));if(Q.has("ctrl")!==(Z.ctrlKey||Z.metaKey))return!1;if(Q.has("shift")!==Z.shiftKey)return!1;if(Q.has("alt")!==Z.altKey)return!1;return Z.key.toLowerCase()===q}var K8='<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>',F8='<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>',L8={"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 t6($,Z){try{let q=localStorage.getItem(Z);if(q==="light"||q==="dark")return q}catch{}let J=$.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(J==="light"||J==="dark")return J;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function L0($,Z){if(typeof document>"u")return()=>{};let J=Z?.position??"top-right",q=Z?.storageKey??"prefab-theme",Q=Z?.syncDocument??!0,Y=getComputedStyle($).position;if(Y==="static"||Y==="")$.style.position="relative";let U=document.createElement("button");U.className="pf-theme-toggle",U.setAttribute("aria-label","Toggle theme"),U.setAttribute("title","Toggle light/dark"),Object.assign(U.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let H=L8[J]??L8["top-right"];for(let X of H.split(";")){let[B,K]=X.split(":").map((L)=>L.trim());if(B&&K)U.style.setProperty(B,K)}U.addEventListener("mouseenter",()=>{U.style.opacity="1"}),U.addEventListener("mouseleave",()=>{U.style.opacity="0.7"});function W(X){if(E1($,X),Q)E1(document.documentElement,X);U.innerHTML=X==="dark"?F8:K8;try{localStorage.setItem(q,X)}catch{}}let _=t6($,q);W(_),U.addEventListener("click",()=>{let X=$.getAttribute("data-theme")??"dark";W(X==="dark"?"light":"dark")}),$.appendChild(U);let z;if(Q)z=new MutationObserver((X)=>{for(let B of X)if(B.type==="attributes"&&B.attributeName==="data-theme"){let K=document.documentElement.getAttribute("data-theme");if((K==="light"||K==="dark")&&K!==$.getAttribute("data-theme")){E1($,K),U.innerHTML=K==="dark"?F8:K8;try{localStorage.setItem(q,K)}catch{}}}}),z.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{z?.disconnect(),U.remove()}}function x1($){let Z=$?.baseUrl??(typeof window<"u"?window.location.origin:""),J={"Content-Type":"application/json",...$?.headers},q=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(Q,Y){let U=await q(`${Z}/mcp/tools/call`,{method:"POST",headers:J,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:Q,arguments:Y}})});if(!U.ok)throw Error(`MCP tool call failed: ${U.status} ${U.statusText}`);let H=await U.json();if(H.error)throw Error(H.error.message??"MCP tool call returned error");let W=H.result?.content??H.content??[];for(let _ of W)if(_.type==="text"&&_.text!==void 0){try{let z=JSON.parse(_.text);if(typeof z==="object"&&z!==null&&"$prefab"in z)return z;return z}catch{}return _.text}return H.result??H},async sendMessage(Q){await q(`${Z}/mcp/messages`,{method:"POST",headers:J,body:JSON.stringify({message:Q})})}}}function p1(){return{callTool($){return b.warn(`No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return b.warn("No MCP transport: sendMessage ignored",$),Promise.resolve()}}}var D8="0.3.7";function e6($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class L1{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 $=J5();if($)this.postFn=(J)=>$.postMessage(J);let Z=(J)=>{if(this.hostOrigin!=="*"&&J.origin!==this.hostOrigin)return;let q=J.data;if(e6(q)){this.handleJsonRpc(q);return}let Q=q;if(!Q?.type.startsWith("prefab:"))return;if(Q.type==="prefab:tool-call-response"&&Q.id){let U=this.pending.get(Q.id);if(U){if(this.pending.delete(Q.id),Q.payload?.error!=null)U.reject(Error(Q.payload.error));else U.resolve(Q.payload?.result);return}}let Y=this.listeners.get(Q.type);if(Y)for(let U of Y)U(Q.payload??{})};window.addEventListener("message",Z),this.cleanup=()=>window.removeEventListener("message",Z)}async initialize($){try{return await Promise.any([this.initPrefab($),this.initJsonRpc($)])}catch(Z){let J=Z instanceof AggregateError?Z.errors.map((q)=>q.message).join("; "):String(Z);throw Error(`Bridge init failed — no host responded. Tried: ${J}`,{cause:Z})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:$});else this.sendPrefab("prefab:request-mode",{mode:$})}openLink($,Z){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:Z});else this.sendPrefab("prefab:open-link",{url:$,target:Z})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}setupAutoResize($){if(typeof ResizeObserver>"u")return $5;let Z=-1,J=-1,q=(U,H)=>{if(U===Z&&H===J)return;if(Z=U,J=H,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:U,height:H});else this.sendPrefab("prefab:size-changed",{width:U,height:H})},Q=new ResizeObserver((U)=>{for(let H of U)if(H.borderBoxSize.length){let W=H.borderBoxSize[0];q(Math.ceil(W.inlineSize),Math.ceil(W.blockSize))}else{let W=H.target.getBoundingClientRect();q(Math.ceil(W.width),Math.ceil(W.height))}});Q.observe($);let Y=$.getBoundingClientRect();return q(Math.ceil(Y.width),Math.ceil(Y.height)),()=>Q.disconnect()}notifyPreferredSize($){if(this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/preferred-size",$);else this.sendPrefab("prefab:preferred-size",$)}subscribe($,Z){let J=(q)=>{if(q.uri!==$)return;Z(q.contents??q.data??q)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",J),this.sendRpcRequest("resources/subscribe",{uri:$});else this.on("prefab:resource-updated",J),this.sendPrefab("prefab:subscribe",{uri:$});return()=>{if(this.off("prefab:resource-updated",J),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:$});else this.sendPrefab("prefab:unsubscribe",{uri:$})}}get supportsSubscriptions(){return this._hostSupportsSubscriptions}on($,Z){if(!this.listeners.has($))this.listeners.set($,new Set);let J=this.listeners.get($);if(J)J.add(Z)}off($,Z){this.listeners.get($)?.delete(Z)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,$]of this.pending)$.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,$]of this.rpcPending)$.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab($){return new Promise((Z,J)=>{let q=!1,Q=(Y)=>{if(q)return;q=!0,this.off("prefab:init-response",Q),this.protocol="prefab";let U=Y.capabilities;this._hostSupportsSubscriptions=U?.subscriptions===!0,Z(Y)};this.on("prefab:init-response",Q),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!q)q=!0,this.off("prefab:init-response",Q),J(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,Z)=>{let J=`tc-${++this.callIdCounter}`;return new Promise((q,Q)=>{this.pending.set(J,{resolve:q,reject:Q}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:Z},J),setTimeout(()=>{if(this.pending.has(J))this.pending.delete(J),Q(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()},subscribe:($,Z)=>{return this.subscribe($,Z)},capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendPrefab($,Z,J){if(typeof window>"u")return;let q=window.parent!==window?window.parent:window,Q={type:$,payload:Z,id:J};q.postMessage(Q,this.hostOrigin)}handleJsonRpc($){if(!("method"in $)){let q=this.rpcPending.get($.id);if(q)if(this.rpcPending.delete($.id),$.error)q.reject(Error($.error.message));else q.resolve($.result);return}let Z=$.method,J=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(Z){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:J.arguments??J});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:J.arguments??J});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:J});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",J);break;case"ui/notifications/host-context-changed":{let q={};if(typeof J.theme==="string")q.colorScheme=J.theme;if(typeof J.styles==="object"&&J.styles!==null){let Q=J.styles;if(Q.variables)q.variables=Q.variables;if(typeof Q.css?.fonts==="string")q.fontCss=Q.css.fonts}this.dispatch("prefab:theme-update",q),this.dispatch("prefab:host-context-changed",J);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",J);break;case"ui/notifications/resource-updated":case"notifications/resources/updated":this.dispatch("prefab:resource-updated",J);break}}initJsonRpc($){return new Promise((Z,J)=>{let q=++this.rpcIdCounter,Q=!1;this.rpcPending.set(q,{resolve:(Y)=>{if(Q)return;Q=!0,this.protocol="jsonrpc";let U=Y??{},H=U.hostInfo??{},W=U.hostContext??{},_=U.hostCapabilities??{},z;if(typeof W.theme==="string"||typeof W.styles==="object"){if(z={},typeof W.theme==="string")z.colorScheme=W.theme;if(typeof W.styles==="object"&&W.styles!==null){let B=W.styles;if(B.variables)z.variables=B.variables;if(typeof B.css?.fonts==="string")z.fontCss=B.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let X=_.resources;this._hostSupportsSubscriptions=_.subscriptions===!0||X?.subscribe===!0,Z({hostName:H.name,hostVersion:H.version,capabilities:{toast:!0,navigation:_.openLinks!=null,messaging:!0,displayModes:W.availableDisplayModes??[]},theme:z,toolInput:void 0,meta:W})},reject:(Y)=>{if(Q)return;Q=!0,J(Y)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:D8},appCapabilities:{...$.displayModes&&{availableDisplayModes:$.displayModes}}}}),setTimeout(()=>{if(!Q)Q=!0,this.rpcPending.delete(q),J(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,Z)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:Z})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})},subscribe:($,Z)=>{return this.subscribe($,Z)},capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendRpcRequest($,Z){let J=++this.rpcIdCounter;return new Promise((q,Q)=>{this.rpcPending.set(J,{resolve:q,reject:Q}),this.postJsonRpc({jsonrpc:"2.0",id:J,method:$,params:Z}),setTimeout(()=>{if(this.rpcPending.has(J))this.rpcPending.delete(J),Q(Error(`JSON-RPC '${$}' timed out`))},30000)})}sendRpcNotification($,Z){this.postJsonRpc({jsonrpc:"2.0",method:$,params:Z})}postJsonRpc($){if(typeof window>"u")return;if($.id!=null&&typeof $.method==="string")this.sentRpcIds.add($.id);if(this.postFn)this.postFn($);else(window.parent!==window?window.parent:window).postMessage($,this.hostOrigin)}dispatch($,Z){let J=this.listeners.get($);if(J)for(let q of J)q(Z)}}var $5=()=>{};function D0($,Z){if(Z.variables)for(let[J,q]of Object.entries(Z.variables))$.style.setProperty(J.startsWith("--")?J:`--${J}`,q);if(Z.colorScheme&&Z.colorScheme!=="auto")$.setAttribute("data-theme",Z.colorScheme);if(Z.fontCss)Z5(Z.fontCss)}function Z5($){if(document.getElementById("__prefab-host-fonts"))return;let J=document.createElement("style");J.id="__prefab-host-fonts",J.textContent=$,document.head.appendChild(J)}function c1(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function J5(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let Z=$.acquireVsCodeApi();if(Z!==null&&typeof Z==="object"&&"postMessage"in Z)return Z}catch{return}return}var I8=new Set(["Column","Row","Grid","GridItem","Container","Div","Span","Dashboard","DashboardItem","Pages","Page","Heading","H1","H2","H3","H4","Text","P","Lead","Large","Small","Muted","BlockQuote","Label","Link","Code","Markdown","Kbd","Card","CardHeader","CardTitle","CardDescription","CardContent","CardFooter","DataTable","Badge","Dot","Metric","Ring","Progress","Separator","Loader","Icon","Table","TableHead","TableBody","TableFooter","TableRow","TableHeader","TableCell","TableCaption","ExpandableRow","Form","Input","Textarea","Button","ButtonGroup","Select","SelectOption","SelectGroup","SelectLabel","SelectSeparator","Checkbox","Switch","Slider","Radio","RadioGroup","Combobox","ComboboxOption","ComboboxGroup","ComboboxLabel","ComboboxSeparator","Calendar","DatePicker","Field","FieldTitle","FieldDescription","FieldContent","FieldError","ChoiceCard","Tabs","Tab","Accordion","AccordionItem","Dialog","Popover","Tooltip","HoverCard","Carousel","ForEach","If","Elif","Else","Define","Use","Slot","Alert","AlertTitle","AlertDescription","Image","Audio","Video","Embed","Svg","DropZone","Mermaid","BarChart","LineChart","AreaChart","PieChart","RadarChart","ScatterChart","Sparkline","RadialChart","Histogram"]);function T0($,Z={}){let J=[],q=Z.strict??!1;if($==null||typeof $!=="object")return J.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:J};let Q=$;if(Q.$prefab==null||typeof Q.$prefab!=="object")J.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof Q.$prefab.version!=="string")J.push({path:"$.$prefab.version",message:"version must be a string"});if(Q.view==null)J.push({path:"$.view",message:'Missing required "view" field'});else O0(Q.view,"$.view",J,q);if(Q.state!==void 0){if(Q.state===null||typeof Q.state!=="object"||Array.isArray(Q.state))J.push({path:"$.state",message:"state must be a plain object"})}if(Q.theme!==void 0)Q5(Q.theme,J);if(Q.css!==void 0)T8(Q.css,"$.css",J);if(Q.stylesheets!==void 0)T8(Q.stylesheets,"$.stylesheets",J);if(Q.mode!==void 0&&Q.mode!=="light"&&Q.mode!=="dark")J.push({path:"$.mode",message:'mode must be "light" or "dark"'});if(Q.defs!==void 0)if(Q.defs===null||typeof Q.defs!=="object"||Array.isArray(Q.defs))J.push({path:"$.defs",message:"defs must be a plain object"});else for(let[Y,U]of Object.entries(Q.defs))O0(U,`$.defs.${Y}`,J,q);if(Q.keyBindings!==void 0)if(Q.keyBindings===null||typeof Q.keyBindings!=="object"||Array.isArray(Q.keyBindings))J.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[Y,U]of Object.entries(Q.keyBindings))I0(U,`$.keyBindings.${Y}`,J);return{valid:J.length===0,errors:J}}function O0($,Z,J,q){if($==null||typeof $!=="object"||Array.isArray($)){J.push({path:Z,message:"Component must be a plain object"});return}let Q=$;if(typeof Q.type!=="string"||Q.type.length===0){J.push({path:`${Z}.type`,message:'Component must have a non-empty "type" string'});return}if(q&&!I8.has(Q.type))J.push({path:`${Z}.type`,message:`Unknown component type: "${Q.type}"`});if(Q.children!==void 0)if(!Array.isArray(Q.children))J.push({path:`${Z}.children`,message:"children must be an array"});else for(let U=0;U<Q.children.length;U++)O0(Q.children[U],`${Z}.children[${U}]`,J,q);let Y=["onClick","on_click","onChange","on_change","onSubmit","on_submit","onMount","on_mount","onClose","on_close"];for(let U of Y)if(Q[U]!==void 0)I0(Q[U],`${Z}.${U}`,J);for(let[U,H]of Object.entries(Q)){if(U==="type"||q5.has(U)||Y.includes(U))continue;if(O8(H)||Array.isArray(H)&&H.some(O8))J.push({path:`${Z}.${U}`,message:`Components under "${U}" are ignored by the renderer; move them into "children"`})}}var q5=new Set(["children","fallback","trigger","empty","else","summary"]);function O8($){if($==null||typeof $!=="object"||Array.isArray($))return!1;let Z=$.type;return typeof Z==="string"&&I8.has(Z)}function I0($,Z,J){if(Array.isArray($)){for(let H=0;H<$.length;H++)I0($[H],`${Z}[${H}]`,J);return}if($==null||typeof $!=="object"){J.push({path:Z,message:"Action must be an object or array of objects"});return}let q=$,Q=typeof q.type==="string"&&q.type.length>0,Y=typeof q.action==="string"&&q.action.length>0;if(!Q&&!Y){J.push({path:`${Z}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if((Y?q.action:q.type).toLowerCase()==="showtoast"){if(typeof q.message!=="string"||q.message.length===0)J.push({path:`${Z}.message`,message:'showToast requires a non-empty "message" string'})}}function T8($,Z,J){if(!Array.isArray($)){J.push({path:Z,message:`${Z} must be an array of strings`});return}for(let q=0;q<$.length;q++)if(typeof $[q]!=="string")J.push({path:`${Z}[${q}]`,message:"must be a string"})}function Q5($,Z){if($===null||typeof $!=="object"||Array.isArray($)){Z.push({path:"$.theme",message:"theme must be a plain object"});return}let J=$;for(let q of["light","dark"])if(J[q]!==void 0){if(J[q]===null||typeof J[q]!=="object"||Array.isArray(J[q]))Z.push({path:`$.theme.${q}`,message:`theme.${q} must be a plain object`})}}var o={mount($,Z,J){if(u1(),J?.validate!==!1)for(let E of T0(Z).errors)b.warn(`wire validation ${E.path}: ${E.message}`);let q=Z,Q={tracked:[],evalBlocked:!1};if(q.pipes)for(let[E,O]of Object.entries(q.pipes))V8(E,O,Q);let Y=new K1(q.state),U;if(J?.transport&&"callTool"in J.transport)U=J.transport;else if(J?.transport)U=x1(J.transport);else U=p1();let H=J?.onToast??H5,W=new J0;function _(E){let O=E;if(q=O,O.state)Y.merge(O.state);if(O.defs)z.defs=O.defs;if(O.theme)K0($,O.theme);if(O.mode)P8($,O.mode);if(O.pipes)for(let[V,A]of Object.entries(O.pipes))V8(V,A,Q);for(let V of X)V.remove();if(X.length=0,X.push(...R8(O.css,O.stylesheets)),j8($,O.layout),B?.(),B=void 0,O.keyBindings)B=F0(O.keyBindings,(V)=>{v(h(V,{store:Y,transport:U,scope:{},rerender:()=>M(),remount:_,onToast:H}),"keyBinding")});M()}let z={store:Y,scope:{},transport:U,rerender:()=>M(),remount:_,onToast:H,defs:q.defs,destroyRegistry:W};if(K0($,q.theme),q.mode)P8($,q.mode);j8($,q.layout);let X=R8(q.css,q.stylesheets),B;if(q.keyBindings)B=F0(q.keyBindings,(E)=>{v(h(E,{store:Y,transport:U,scope:{},rerender:()=>M(),remount:_,onToast:H}),"keyBinding")});let K,L=J?.themeToggle??!0;if(L!==!1)K=L0($,typeof L==="object"?L:void 0);function M(){W.flush();let E=$.querySelector(".pf-theme-toggle");$.innerHTML="";let O=u(q.view,z);if($.appendChild(O),E)$.appendChild(E)}return M(),{rerender:()=>M(),update(E){if(Y.merge(E.update.state),M(),E.update.actions!=null)v(h(E.update.actions,z),"update action")},store:Y,destroy(){W.flush(),K?.(),B?.(),m0(),h0();for(let E of X)E.remove();for(let E of Q.tracked)s1(E);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},Y5=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 U5($){if($ instanceof EvalError)return!0;return $ instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test($.message)}function V8($,Z,J){if(Y5.has($)){b.warn(`wire pipe "${$}" ignored — shadows built-in`);return}if(D1($)!=null){b.debug(`wire pipe "${$}" — already registered, keeping local implementation`);return}if(J.evalBlocked)return;try{let q=Function("return ("+Z+")")();if(typeof q!=="function"){b.warn(`wire pipe "${$}" — source did not evaluate to a function`);return}i1($,q),J.tracked.push($)}catch(q){if(U5(q)){J.evalBlocked=!0,b.warn("wire pipes cannot be hydrated — this host's CSP forbids eval. Pre-register them with "+"prefab.registerPipe() from a companion script (rendererHtml({ scripts })) and they are used as-is.");return}b.warn(`wire pipe "${$}" — failed to hydrate:`,q)}}function H5($){if(typeof document>"u")return;let Z=X5(),J=document.createElement("div"),q=$.variant??"default";J.className=`pf-toast${q!=="default"?` pf-toast--${q}`:""}`,J.setAttribute("data-variant",q),J.style.marginBottom="8px",J.style.transition="opacity 0.3s ease";let Q=document.createElement("div");if(Q.textContent=$.message,Q.style.fontWeight="500",J.appendChild(Q),$.description){let U=document.createElement("div");U.textContent=$.description,U.style.fontSize="14px",U.style.color="var(--muted-foreground, #6b7280)",J.appendChild(U)}Z.appendChild(J);let Y=$.duration??4000;setTimeout(()=>{J.style.opacity="0",setTimeout(()=>J.remove(),300)},Y)}function P8($,Z){if(E1($,Z),typeof document<"u")E1(document.documentElement,Z)}function W5($){let Z=$.trim();if(Z.includes("{")||Z.includes("}"))return!1;return/^(https?:)?\/\//i.test(Z)||Z.startsWith("/")||/\.css(\?|#|$)/i.test(Z)}function R8($,Z){let J=[];if(typeof document>"u")return J;for(let q of $??[]){let Q=document.createElement("style");Q.textContent=q,Q.dataset.prefab="injected",document.head.appendChild(Q),J.push(Q)}for(let q of Z??[])if(W5(q)){let Q=document.createElement("link");Q.rel="stylesheet",Q.href=q,Q.dataset.prefab="injected",document.head.appendChild(Q),J.push(Q)}else{let Q=document.createElement("style");Q.textContent=q,Q.dataset.prefab="injected",document.head.appendChild(Q),J.push(Q)}return J}function j8($,Z){if($.style.height="",$.style.minHeight="",$.style.maxHeight="",$.style.overflow="",!Z)return;if(Z.preferredHeight!=null)$.style.height=`${Z.preferredHeight}px`;if(Z.minHeight!=null)$.style.minHeight=`${Z.minHeight}px`;if(Z.maxHeight!=null)$.style.maxHeight=`${Z.maxHeight}px`,$.style.overflow="auto"}function X5(){let Z=document.getElementById("prefab-toast-container");if(!Z)Z=document.createElement("div"),Z.id="prefab-toast-container",Z.style.position="fixed",Z.style.bottom="16px",Z.style.right="16px",Z.style.zIndex="9999",Z.style.maxWidth="400px",document.body.appendChild(Z);return Z}if(typeof window<"u"){let $=window;$.PrefabRenderer=o,$.prefab={app:d1,mount:o.mount.bind(o),isPrefabData:o.isPrefabData.bind(o),isPrefabUpdate:o.isPrefabUpdate.bind(o),Bridge:L1,isIframe:c1,registerPipe:i1,unregisterPipe:s1,listPipes:f0,registerComponent:G,createThemeToggle:L0,validateWireFormat:T0,setLogLevel:A0};let Z=$.__PREFAB_DATA__;if(Z!=null){let J=document.getElementById("prefab-root");if(J)o.mount(J,Z)}}async function d1($){u1();let Z=$?.mode??"auto",J=Z==="bridge"||Z==="auto"&&c1(),q,Q,Y={capabilities:{}};if(J)Q=new L1($?.hostOrigin),Q.connect(),Y=await Q.initialize($?.capabilities??{toolInput:!0}),q=Q.createTransport();else if($?.transport)q=x1($.transport);else q=p1();if(Y.theme&&typeof document<"u")D0(document.documentElement,Y.theme);if(typeof document<"u"&&!Q)B5();let U,H,W,_,z,X=Y.toolInput,B;if(Q)Q.on("prefab:tool-input",(M)=>{let E=M.args??M;if(U)U(E);else X=E}),Q.on("prefab:tool-result",(M)=>{let E=M.result??M;if(H)H(E);else B=E}),Q.on("prefab:tool-cancelled",()=>{W?.()}),Q.on("prefab:tool-input-partial",(M)=>{_?.(M.args??M)}),Q.on("prefab:theme-update",(M)=>{if(typeof document<"u")D0(document.documentElement,M)}),Q.on("prefab:host-context-changed",(M)=>{z?.(M)});function K(M,...E){let O=V0(M),V=new K1,A={store:V,scope:{},transport:q,rerender:()=>I(),onToast:void 0};function I(){O.innerHTML="";for(let j of E)O.appendChild(u(j,A))}return I(),{rerender:I,store:V,destroy:()=>{O.innerHTML=""}}}return{callTool:(M,E={})=>q.callTool(M,E),sendMessage:(M)=>q.sendMessage(M),onToolInput:(M)=>{if(U=M,X){let E=X;X=void 0,queueMicrotask(()=>M(E))}},onToolResult:(M)=>{if(H=M,B!==void 0){let E=B;B=void 0,queueMicrotask(()=>M(E))}},onToolCancelled:(M)=>{W=M},onToolInputPartial:(M)=>{_=M},onHostContextChanged:(M)=>{z=M},render:K,mount:(M,E,O)=>{let V=V0(M);return o.mount(V,E,{transport:q,...O})},requestMode:(M)=>Q?.requestMode(M),openLink:(M,E)=>{if(Q)Q.openLink(M,E);else if(typeof window<"u")window.open(M,E??"_blank")},updateContext:(M)=>{if(Q)Q.updateContext(M)},setupAutoResize:(M)=>{if(!Q)return G5;let E=typeof M==="string"?V0(M):M;return Q.setupAutoResize(E)},notifyPreferredSize:(M)=>{if(Q)Q.notifyPreferredSize(M)},host:Y,capabilities:Y.capabilities,theme:Y.theme,transport:q,destroy:()=>Q?.disconnect()}}var G5=()=>{};function V0($){if(typeof $==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let Z=document.querySelector($);if(!Z)throw Error(`Element not found: ${$}`);return Z}return $}function B5(){function $(){let J=document.body.getAttribute("data-vscode-theme-kind");if(!J)return;let q=J.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",q)}$(),new MutationObserver($).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var R0=l1("auto"),k8="#root";function P0($){return o.isPrefabData($)}function A8($){return o.isPrefabUpdate($)}function S8($){if(P0($))return $;if($!==null&&typeof $==="object"){let Z=$;if(P0(Z.structuredContent))return Z.structuredContent;if(Array.isArray(Z.content))for(let J of Z.content){let q=J;if(q.type==="text"&&typeof q.text==="string")try{let Q=JSON.parse(q.text);if(P0(Q))return Q}catch{}}}return null}async function f8(){let $=document.querySelector(k8);if(!$){R0.error(`Mount target "${k8}" not found`);return}let Z=$,J=await d1();J.setupAutoResize(Z);let q;function Q(Y){if(q)q.destroy();if(q=J.mount(Z,Y),Y.layout)J.notifyPreferredSize(Y.layout)}J.onToolResult((Y)=>{let U=S8(Y);if(U)Q(U);else if(A8(Y)&&q)q.update(Y)}),J.onToolInput((Y)=>{let U=S8(Y);if(U)Q(U);else if(A8(Y)&&q)q.update(Y)})}function M5(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{f8().catch(($)=>{R0.error("Boot failed:",$)})},{once:!0});else queueMicrotask(()=>{f8().catch(($)=>{R0.error("Boot failed:",$)})})}M5();})();
16
+ `)}function E1($,Z){$.setAttribute("data-theme",Z),$.classList.toggle("dark",Z==="dark"),$.classList.toggle("light",Z==="light")}function F0($,Z){if(!Z)return;if(Z.light)for(let[J,q]of Object.entries(Z.light))$.style.setProperty(`--${E0(J)}`,K0(q));if(Z.dark){let q=document.getElementById("prefab-dark-theme");if(!q)q=document.createElement("style"),q.id="prefab-dark-theme",document.head.appendChild(q);q.textContent=F4({dark:Z.dark})}}function D0($,Z){if(!$||typeof document>"u")return;let J=(q)=>{for(let[Q,Y]of Object.entries($))if(J5(Q,q))q.preventDefault(),Z(Y)};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)}function J5($,Z){let J=$.toLowerCase().split("+").map((Y)=>Y.trim()),q=J[J.length-1],Q=new Set(J.slice(0,-1));if(Q.has("ctrl")!==(Z.ctrlKey||Z.metaKey))return!1;if(Q.has("shift")!==Z.shiftKey)return!1;if(Q.has("alt")!==Z.altKey)return!1;return Z.key.toLowerCase()===q}var D4='<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>',L4='<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>',T4={"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 q5($,Z){try{let q=localStorage.getItem(Z);if(q==="light"||q==="dark")return q}catch{}let J=$.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(J==="light"||J==="dark")return J;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function L0($,Z){if(typeof document>"u")return()=>{};let J=Z?.position??"top-right",q=Z?.storageKey??"prefab-theme",Q=Z?.syncDocument??!0,Y=getComputedStyle($).position;if(Y==="static"||Y==="")$.style.position="relative";let U=document.createElement("button");U.className="pf-theme-toggle",U.setAttribute("aria-label","Toggle theme"),U.setAttribute("title","Toggle light/dark"),Object.assign(U.style,{position:"absolute",zIndex:"100",width:"28px",height:"28px",border:"1px solid var(--border, #e5e7eb)",borderRadius:"6px",background:"var(--card, rgba(255,255,255,0.8))",color:"var(--foreground, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",opacity:"0.7",transition:"opacity 0.15s, border-color 0.15s"});let H=T4[J]??T4["top-right"];for(let W of H.split(";")){let[z,E]=W.split(":").map((F)=>F.trim());if(z&&E)U.style.setProperty(z,E)}U.addEventListener("mouseenter",()=>{U.style.opacity="1"}),U.addEventListener("mouseleave",()=>{U.style.opacity="0.7"});function G(W){if(E1($,W),Q)E1(document.documentElement,W);U.innerHTML=W==="dark"?L4:D4;try{localStorage.setItem(q,W)}catch{}}let X=q5($,q);G(X),U.addEventListener("click",()=>{let W=$.getAttribute("data-theme")??"dark";G(W==="dark"?"light":"dark")}),$.appendChild(U);let M;if(Q)M=new MutationObserver((W)=>{for(let z of W)if(z.type==="attributes"&&z.attributeName==="data-theme"){let E=document.documentElement.getAttribute("data-theme");if((E==="light"||E==="dark")&&E!==$.getAttribute("data-theme")){E1($,E),U.innerHTML=E==="dark"?L4:D4;try{localStorage.setItem(q,E)}catch{}}}}),M.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{M?.disconnect(),U.remove()}}function c1($){let Z=$?.baseUrl??(typeof window<"u"?window.location.origin:""),J={"Content-Type":"application/json",...$?.headers},q=$?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(Q,Y){let U=await q(`${Z}/mcp/tools/call`,{method:"POST",headers:J,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:Q,arguments:Y}})});if(!U.ok)throw Error(`MCP tool call failed: ${U.status} ${U.statusText}`);let H=await U.json();if(H.error)throw Error(H.error.message??"MCP tool call returned error");let G=H.result?.content??H.content??[];for(let X of G)if(X.type==="text"&&X.text!==void 0){try{let M=JSON.parse(X.text);if(typeof M==="object"&&M!==null&&"$prefab"in M)return M;return M}catch{}return X.text}return H.result??H},async sendMessage(Q){await q(`${Z}/mcp/messages`,{method:"POST",headers:J,body:JSON.stringify({message:Q})})}}}function p1(){return{callTool($){return b.warn(`No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return b.warn("No MCP transport: sendMessage ignored",$),Promise.resolve()}}}var O4="0.3.9";function Q5($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class T1{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 $=H5();if($)this.postFn=(J)=>$.postMessage(J);let Z=(J)=>{if(this.hostOrigin!=="*"&&J.origin!==this.hostOrigin)return;let q=J.data;if(Q5(q)){this.handleJsonRpc(q);return}let Q=q;if(!Q?.type.startsWith("prefab:"))return;if(Q.type==="prefab:tool-call-response"&&Q.id){let U=this.pending.get(Q.id);if(U){if(this.pending.delete(Q.id),Q.payload?.error!=null)U.reject(Error(Q.payload.error));else U.resolve(Q.payload?.result);return}}let Y=this.listeners.get(Q.type);if(Y)for(let U of Y)U(Q.payload??{})};window.addEventListener("message",Z),this.cleanup=()=>window.removeEventListener("message",Z)}async initialize($){try{return await Promise.any([this.initPrefab($),this.initJsonRpc($)])}catch(Z){let J=Z instanceof AggregateError?Z.errors.map((q)=>q.message).join("; "):String(Z);throw Error(`Bridge init failed — no host responded. Tried: ${J}`,{cause:Z})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:$});else this.sendPrefab("prefab:request-mode",{mode:$})}openLink($,Z){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:$,target:Z});else this.sendPrefab("prefab:open-link",{url:$,target:Z})}updateContext($){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:$});else this.sendPrefab("prefab:update-context",{context:$})}setupAutoResize($){if(typeof ResizeObserver>"u")return Y5;let Z=-1,J=-1,q=(U,H)=>{if(U===Z&&H===J)return;if(Z=U,J=H,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:U,height:H});else this.sendPrefab("prefab:size-changed",{width:U,height:H})},Q=new ResizeObserver((U)=>{for(let H of U)if(H.borderBoxSize.length){let G=H.borderBoxSize[0];q(Math.ceil(G.inlineSize),Math.ceil(G.blockSize))}else{let G=H.target.getBoundingClientRect();q(Math.ceil(G.width),Math.ceil(G.height))}});Q.observe($);let Y=$.getBoundingClientRect();return q(Math.ceil(Y.width),Math.ceil(Y.height)),()=>Q.disconnect()}notifyPreferredSize($){if(this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/preferred-size",$);else this.sendPrefab("prefab:preferred-size",$)}subscribe($,Z){let J=(q)=>{if(q.uri!==$)return;Z(q.contents??q.data??q)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",J),this.sendRpcRequest("resources/subscribe",{uri:$});else this.on("prefab:resource-updated",J),this.sendPrefab("prefab:subscribe",{uri:$});return()=>{if(this.off("prefab:resource-updated",J),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:$});else this.sendPrefab("prefab:unsubscribe",{uri:$})}}get supportsSubscriptions(){return this._hostSupportsSubscriptions}on($,Z){if(!this.listeners.has($))this.listeners.set($,new Set);let J=this.listeners.get($);if(J)J.add(Z)}off($,Z){this.listeners.get($)?.delete(Z)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,$]of this.pending)$.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,$]of this.rpcPending)$.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab($){return new Promise((Z,J)=>{let q=!1,Q=(Y)=>{if(q)return;q=!0,this.off("prefab:init-response",Q),this.protocol="prefab";let U=Y.capabilities;this._hostSupportsSubscriptions=U?.subscriptions===!0,Z(Y)};this.on("prefab:init-response",Q),this.sendPrefab("prefab:init",{capabilities:$}),setTimeout(()=>{if(!q)q=!0,this.off("prefab:init-response",Q),J(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:($,Z)=>{let J=`tc-${++this.callIdCounter}`;return new Promise((q,Q)=>{this.pending.set(J,{resolve:q,reject:Q}),this.sendPrefab("prefab:tool-call",{tool:$,arguments:Z},J),setTimeout(()=>{if(this.pending.has(J))this.pending.delete(J),Q(Error(`Tool call '${$}' timed out`))},30000)})},sendMessage:($)=>{return this.sendPrefab("prefab:send-message",{message:$}),Promise.resolve()},subscribe:($,Z)=>{return this.subscribe($,Z)},capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendPrefab($,Z,J){if(typeof window>"u")return;let q=window.parent!==window?window.parent:window,Q={type:$,payload:Z,id:J};q.postMessage(Q,this.hostOrigin)}handleJsonRpc($){if(!("method"in $)){let q=this.rpcPending.get($.id);if(q)if(this.rpcPending.delete($.id),$.error)q.reject(Error($.error.message));else q.resolve($.result);return}let Z=$.method,J=$.params??{};if($.id!=null&&this.sentRpcIds.delete($.id))return;if($.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:$.id,result:{}});switch(Z){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:J.arguments??J});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:J.arguments??J});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:J});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",J);break;case"ui/notifications/host-context-changed":{let q={};if(typeof J.theme==="string")q.colorScheme=J.theme;if(typeof J.styles==="object"&&J.styles!==null){let Q=J.styles;if(Q.variables)q.variables=Q.variables;if(typeof Q.css?.fonts==="string")q.fontCss=Q.css.fonts}this.dispatch("prefab:theme-update",q),this.dispatch("prefab:host-context-changed",J);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",J);break;case"ui/notifications/resource-updated":case"notifications/resources/updated":this.dispatch("prefab:resource-updated",J);break}}initJsonRpc($){return new Promise((Z,J)=>{let q=++this.rpcIdCounter,Q=!1;this.rpcPending.set(q,{resolve:(Y)=>{if(Q)return;Q=!0,this.protocol="jsonrpc";let U=Y??{},H=U.hostInfo??{},G=U.hostContext??{},X=U.hostCapabilities??{},M;if(typeof G.theme==="string"||typeof G.styles==="object"){if(M={},typeof G.theme==="string")M.colorScheme=G.theme;if(typeof G.styles==="object"&&G.styles!==null){let z=G.styles;if(z.variables)M.variables=z.variables;if(typeof z.css?.fonts==="string")M.fontCss=z.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let W=X.resources;this._hostSupportsSubscriptions=X.subscriptions===!0||W?.subscribe===!0,Z({hostName:H.name,hostVersion:H.version,capabilities:{toast:!0,navigation:X.openLinks!=null,messaging:!0,displayModes:G.availableDisplayModes??[]},theme:M,toolInput:void 0,meta:G})},reject:(Y)=>{if(Q)return;Q=!0,J(Y)}}),this.postJsonRpc({jsonrpc:"2.0",id:q,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:O4},appCapabilities:{...$.displayModes&&{availableDisplayModes:$.displayModes}}}}),setTimeout(()=>{if(!Q)Q=!0,this.rpcPending.delete(q),J(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:($,Z)=>{return this.sendRpcRequest("tools/call",{name:$,arguments:Z})},sendMessage:($)=>{return this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:$}})},subscribe:($,Z)=>{return this.subscribe($,Z)},capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendRpcRequest($,Z){let J=++this.rpcIdCounter;return new Promise((q,Q)=>{this.rpcPending.set(J,{resolve:q,reject:Q}),this.postJsonRpc({jsonrpc:"2.0",id:J,method:$,params:Z}),setTimeout(()=>{if(this.rpcPending.has(J))this.rpcPending.delete(J),Q(Error(`JSON-RPC '${$}' timed out`))},30000)})}sendRpcNotification($,Z){this.postJsonRpc({jsonrpc:"2.0",method:$,params:Z})}postJsonRpc($){if(typeof window>"u")return;if($.id!=null&&typeof $.method==="string")this.sentRpcIds.add($.id);if(this.postFn)this.postFn($);else(window.parent!==window?window.parent:window).postMessage($,this.hostOrigin)}dispatch($,Z){let J=this.listeners.get($);if(J)for(let q of J)q(Z)}}var Y5=()=>{};function T0($,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)U5(Z.fontCss)}function U5($){if(document.getElementById("__prefab-host-fonts"))return;let J=document.createElement("style");J.id="__prefab-host-fonts",J.textContent=$,document.head.appendChild(J)}function d1(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function H5(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let Z=$.acquireVsCodeApi();if(Z!==null&&typeof Z==="object"&&"postMessage"in Z)return Z}catch{return}return}var I4=["Accordion","AccordionItem","Alert","AlertDescription","AlertTitle","AreaChart","Audio","Badge","BarChart","BlockQuote","Button","ButtonGroup","Calendar","Card","CardContent","CardDescription","CardFooter","CardHeader","CardTitle","Carousel","Checkbox","ChoiceCard","Code","Column","Combobox","ComboboxGroup","ComboboxLabel","ComboboxOption","ComboboxSeparator","Condition","Container","Dashboard","DashboardItem","DataTable","DatePicker","Define","Detail","Dialog","Div","Dot","DropZone","Elif","Else","Embed","ExpandableRow","Field","FieldContent","FieldDescription","FieldError","FieldTitle","ForEach","Form","Grid","GridItem","H1","H2","H3","H4","Heading","Histogram","HoverCard","Icon","If","Image","Input","Kbd","Label","Large","Lead","LineChart","Link","Loader","Markdown","MasterDetail","Mermaid","Metric","Muted","P","Page","Pages","PdfViewer","PieChart","Popover","Progress","RadarChart","RadialChart","Radio","RadioGroup","Ring","Row","ScatterChart","Select","SelectGroup","SelectLabel","SelectOption","SelectSeparator","Separator","Slider","Slot","Small","Span","Sparkline","Svg","Switch","Tab","Table","TableBody","TableCaption","TableCell","TableFooter","TableHead","TableHeader","TableRow","Tabs","Text","Textarea","Tooltip","Use","Video"];var R4=new Set(I4);function I0($,Z={}){let J=[],q=Z.strict??!1;if($==null||typeof $!=="object")return J.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:J};let Q=$;if(Q.$prefab==null||typeof Q.$prefab!=="object")J.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof Q.$prefab.version!=="string")J.push({path:"$.$prefab.version",message:"version must be a string"});if(Q.view==null)J.push({path:"$.view",message:'Missing required "view" field'});else O0(Q.view,"$.view",J,q);if(Q.state!==void 0){if(Q.state===null||typeof Q.state!=="object"||Array.isArray(Q.state))J.push({path:"$.state",message:"state must be a plain object"})}if(Q.theme!==void 0)W5(Q.theme,J);if(Q.css!==void 0)P4(Q.css,"$.css",J);if(Q.stylesheets!==void 0)P4(Q.stylesheets,"$.stylesheets",J);if(Q.mode!==void 0&&Q.mode!=="light"&&Q.mode!=="dark")J.push({path:"$.mode",message:'mode must be "light" or "dark"'});if(Q.defs!==void 0)if(Q.defs===null||typeof Q.defs!=="object"||Array.isArray(Q.defs))J.push({path:"$.defs",message:"defs must be a plain object"});else for(let[Y,U]of Object.entries(Q.defs))O0(U,`$.defs.${Y}`,J,q);if(Q.keyBindings!==void 0)if(Q.keyBindings===null||typeof Q.keyBindings!=="object"||Array.isArray(Q.keyBindings))J.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[Y,U]of Object.entries(Q.keyBindings))V0(U,`$.keyBindings.${Y}`,J);return{valid:J.length===0,errors:J}}function O0($,Z,J,q){if($==null||typeof $!=="object"||Array.isArray($)){J.push({path:Z,message:"Component must be a plain object"});return}let Q=$;if(typeof Q.type!=="string"||Q.type.length===0){J.push({path:`${Z}.type`,message:'Component must have a non-empty "type" string'});return}if(q&&!R4.has(Q.type))J.push({path:`${Z}.type`,message:`Unknown component type: "${Q.type}"`});if(Q.children!==void 0)if(!Array.isArray(Q.children))J.push({path:`${Z}.children`,message:"children must be an array"});else for(let U=0;U<Q.children.length;U++)O0(Q.children[U],`${Z}.children[${U}]`,J,q);let Y=["onClick","on_click","onChange","on_change","onSubmit","on_submit","onMount","on_mount","onClose","on_close"];for(let U of Y)if(Q[U]!==void 0)V0(Q[U],`${Z}.${U}`,J);for(let[U,H]of Object.entries(Q)){if(U==="type"||G5.has(U)||Y.includes(U))continue;if(V4(H)||Array.isArray(H)&&H.some(V4))J.push({path:`${Z}.${U}`,message:`Components under "${U}" are ignored by the renderer; move them into "children"`})}}var G5=new Set(["children","fallback","trigger","empty","else","summary"]);function V4($){if($==null||typeof $!=="object"||Array.isArray($))return!1;let Z=$.type;return typeof Z==="string"&&R4.has(Z)}function V0($,Z,J){if(Array.isArray($)){for(let H=0;H<$.length;H++)V0($[H],`${Z}[${H}]`,J);return}if($==null||typeof $!=="object"){J.push({path:Z,message:"Action must be an object or array of objects"});return}let q=$,Q=typeof q.type==="string"&&q.type.length>0,Y=typeof q.action==="string"&&q.action.length>0;if(!Q&&!Y){J.push({path:`${Z}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if((Y?q.action:q.type).toLowerCase()==="showtoast"){if(typeof q.message!=="string"||q.message.length===0)J.push({path:`${Z}.message`,message:'showToast requires a non-empty "message" string'})}}function P4($,Z,J){if(!Array.isArray($)){J.push({path:Z,message:`${Z} must be an array of strings`});return}for(let q=0;q<$.length;q++)if(typeof $[q]!=="string")J.push({path:`${Z}[${q}]`,message:"must be a string"})}function W5($,Z){if($===null||typeof $!=="object"||Array.isArray($)){Z.push({path:"$.theme",message:"theme must be a plain object"});return}let J=$;for(let q of["light","dark"])if(J[q]!==void 0){if(J[q]===null||typeof J[q]!=="object"||Array.isArray(J[q]))Z.push({path:`$.theme.${q}`,message:`theme.${q} must be a plain object`})}}var o={mount($,Z,J){if(x1(),J?.validate!==!1)for(let K of I0(Z).errors)b.warn(`wire validation ${K.path}: ${K.message}`);let q=Z,Q={tracked:[],evalBlocked:!1};if(q.pipes)for(let[K,T]of Object.entries(q.pipes))j4(K,T,Q);let Y=new K1(q.state),U;if(J?.transport&&"callTool"in J.transport)U=J.transport;else if(J?.transport)U=c1(J.transport);else U=p1();let H=J?.onToast??M5,G=new q0;function X(K){let T=K;if(q=T,T.state)Y.merge(T.state);if(T.defs)M.defs=T.defs;if(T.theme)F0($,T.theme);if(T.mode)k4($,T.mode);if(T.pipes)for(let[V,A]of Object.entries(T.pipes))j4(V,A,Q);for(let V of W)V.remove();if(W.length=0,W.push(...A4(T.css,T.stylesheets)),S4($,T.layout),z?.(),z=void 0,T.keyBindings)z=D0(T.keyBindings,(V)=>{v(m(V,{store:Y,transport:U,scope:{},rerender:()=>_(),remount:X,onToast:H}),"keyBinding")});_()}let M={store:Y,scope:{},transport:U,rerender:()=>_(),remount:X,onToast:H,defs:q.defs,destroyRegistry:G};if(F0($,q.theme),q.mode)k4($,q.mode);S4($,q.layout);let W=A4(q.css,q.stylesheets),z;if(q.keyBindings)z=D0(q.keyBindings,(K)=>{v(m(K,{store:Y,transport:U,scope:{},rerender:()=>_(),remount:X,onToast:H}),"keyBinding")});let E,F=J?.themeToggle??!0;if(F!==!1)E=L0($,typeof F==="object"?F:void 0);function _(){G.flush();let K=$.querySelector(".pf-theme-toggle");$.innerHTML="";let T=u(q.view,M);if($.appendChild(T),K)$.appendChild(K)}return _(),{rerender:()=>_(),update(K){if(Y.merge(K.update.state),_(),K.update.actions!=null)v(m(K.update.actions,M),"update action")},store:Y,destroy(){G.flush(),E?.(),z?.(),h0(),v0();for(let K of W)K.remove();for(let K of Q.tracked)n1(K);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},X5=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 B5($){if($ instanceof EvalError)return!0;return $ instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test($.message)}function j4($,Z,J){if(X5.has($)){b.warn(`wire pipe "${$}" ignored — shadows built-in`);return}if(O1($)!=null){b.debug(`wire pipe "${$}" — already registered, keeping local implementation`);return}if(J.evalBlocked)return;try{let q=Function("return ("+Z+")")();if(typeof q!=="function"){b.warn(`wire pipe "${$}" — source did not evaluate to a function`);return}s1($,q),J.tracked.push($)}catch(q){if(B5(q)){J.evalBlocked=!0,b.warn("wire pipes cannot be hydrated — this host's CSP forbids eval. Pre-register them with "+"prefab.registerPipe() from a companion script (rendererHtml({ scripts })) and they are used as-is.");return}b.warn(`wire pipe "${$}" — failed to hydrate:`,q)}}function M5($){if(typeof document>"u")return;let Z=N5(),J=document.createElement("div"),q=$.variant??"default";J.className=`pf-toast${q!=="default"?` pf-toast--${q}`:""}`,J.setAttribute("data-variant",q),J.style.marginBottom="8px",J.style.transition="opacity 0.3s ease";let Q=document.createElement("div");if(Q.textContent=$.message,Q.style.fontWeight="500",J.appendChild(Q),$.description){let U=document.createElement("div");U.textContent=$.description,U.style.fontSize="14px",U.style.color="var(--muted-foreground, #6b7280)",J.appendChild(U)}Z.appendChild(J);let Y=$.duration??4000;setTimeout(()=>{J.style.opacity="0",setTimeout(()=>J.remove(),300)},Y)}function k4($,Z){if(E1($,Z),typeof document<"u")E1(document.documentElement,Z)}function _5($){let Z=$.trim();if(Z.includes("{")||Z.includes("}"))return!1;return/^(https?:)?\/\//i.test(Z)||Z.startsWith("/")||/\.css(\?|#|$)/i.test(Z)}function A4($,Z){let J=[];if(typeof document>"u")return J;for(let q of $??[]){let Q=document.createElement("style");Q.textContent=q,Q.dataset.prefab="injected",document.head.appendChild(Q),J.push(Q)}for(let q of Z??[])if(_5(q)){let Q=document.createElement("link");Q.rel="stylesheet",Q.href=q,Q.dataset.prefab="injected",document.head.appendChild(Q),J.push(Q)}else{let Q=document.createElement("style");Q.textContent=q,Q.dataset.prefab="injected",document.head.appendChild(Q),J.push(Q)}return J}function S4($,Z){if($.style.height="",$.style.minHeight="",$.style.maxHeight="",$.style.overflow="",!Z)return;if(Z.preferredHeight!=null)$.style.height=`${Z.preferredHeight}px`;if(Z.minHeight!=null)$.style.minHeight=`${Z.minHeight}px`;if(Z.maxHeight!=null)$.style.maxHeight=`${Z.maxHeight}px`,$.style.overflow="auto"}function N5(){let Z=document.getElementById("prefab-toast-container");if(!Z)Z=document.createElement("div"),Z.id="prefab-toast-container",Z.style.position="fixed",Z.style.bottom="16px",Z.style.right="16px",Z.style.zIndex="9999",Z.style.maxWidth="400px",document.body.appendChild(Z);return Z}if(typeof window<"u"){let $=window;$.PrefabRenderer=o,$.prefab={app:l1,mount:o.mount.bind(o),isPrefabData:o.isPrefabData.bind(o),isPrefabUpdate:o.isPrefabUpdate.bind(o),Bridge:T1,isIframe:d1,registerPipe:s1,unregisterPipe:n1,listPipes:C0,registerComponent:B,createThemeToggle:L0,validateWireFormat:I0,setLogLevel:S0};let Z=$.__PREFAB_DATA__;if(Z!=null){let J=document.getElementById("prefab-root");if(J)o.mount(J,Z)}}async function l1($){x1();let Z=$?.mode??"auto",J=Z==="bridge"||Z==="auto"&&d1(),q,Q,Y={capabilities:{}};if(J)Q=new T1($?.hostOrigin),Q.connect(),Y=await Q.initialize($?.capabilities??{toolInput:!0}),q=Q.createTransport();else if($?.transport)q=c1($.transport);else q=p1();if(Y.theme&&typeof document<"u")T0(document.documentElement,Y.theme);if(typeof document<"u"&&!Q)E5();let U,H,G,X,M,W=Y.toolInput,z;if(Q)Q.on("prefab:tool-input",(_)=>{let K=_.args??_;if(U)U(K);else W=K}),Q.on("prefab:tool-result",(_)=>{let K=_.result??_;if(H)H(K);else z=K}),Q.on("prefab:tool-cancelled",()=>{G?.()}),Q.on("prefab:tool-input-partial",(_)=>{X?.(_.args??_)}),Q.on("prefab:theme-update",(_)=>{if(typeof document<"u")T0(document.documentElement,_)}),Q.on("prefab:host-context-changed",(_)=>{M?.(_)});function E(_,...K){let T=P0(_),V=new K1,A={store:V,scope:{},transport:q,rerender:()=>I(),onToast:void 0};function I(){T.innerHTML="";for(let j of K)T.appendChild(u(j,A))}return I(),{rerender:I,store:V,destroy:()=>{T.innerHTML=""}}}return{callTool:(_,K={})=>q.callTool(_,K),sendMessage:(_)=>q.sendMessage(_),onToolInput:(_)=>{if(U=_,W){let K=W;W=void 0,queueMicrotask(()=>_(K))}},onToolResult:(_)=>{if(H=_,z!==void 0){let K=z;z=void 0,queueMicrotask(()=>_(K))}},onToolCancelled:(_)=>{G=_},onToolInputPartial:(_)=>{X=_},onHostContextChanged:(_)=>{M=_},render:E,mount:(_,K,T)=>{let V=P0(_);return o.mount(V,K,{transport:q,...T})},requestMode:(_)=>Q?.requestMode(_),openLink:(_,K)=>{if(Q)Q.openLink(_,K);else if(typeof window<"u")window.open(_,K??"_blank")},updateContext:(_)=>{if(Q)Q.updateContext(_)},setupAutoResize:(_)=>{if(!Q)return z5;let K=typeof _==="string"?P0(_):_;return Q.setupAutoResize(K)},notifyPreferredSize:(_)=>{if(Q)Q.notifyPreferredSize(_)},host:Y,capabilities:Y.capabilities,theme:Y.theme,transport:q,destroy:()=>Q?.disconnect()}}var z5=()=>{};function P0($){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 E5(){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 j0=i1("auto"),f4="#root";function R0($){return o.isPrefabData($)}function C4($){return o.isPrefabUpdate($)}function w4($){if(R0($))return $;if($!==null&&typeof $==="object"){let Z=$;if(R0(Z.structuredContent))return Z.structuredContent;if(Array.isArray(Z.content))for(let J of Z.content){let q=J;if(q.type==="text"&&typeof q.text==="string")try{let Q=JSON.parse(q.text);if(R0(Q))return Q}catch{}}}return null}async function b4(){let $=document.querySelector(f4);if(!$){j0.error(`Mount target "${f4}" not found`);return}let Z=$,J=await l1();J.setupAutoResize(Z);let q;function Q(Y){if(q)q.destroy();if(q=J.mount(Z,Y),Y.layout)J.notifyPreferredSize(Y.layout)}J.onToolResult((Y)=>{let U=w4(Y);if(U)Q(U);else if(C4(Y)&&q)q.update(Y)}),J.onToolInput((Y)=>{let U=w4(Y);if(U)Q(U);else if(C4(Y)&&q)q.update(Y)})}function K5(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{b4().catch(($)=>{j0.error("Boot failed:",$)})},{once:!0});else queueMicrotask(()=>{b4().catch(($)=>{j0.error("Boot failed:",$)})})}K5();})();