@maxhealth.tech/prefab 0.3.8 → 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.
- package/CHANGELOG.md +17 -0
- package/README.md +3 -1
- package/dist/components/charts/index.d.ts +4 -0
- package/dist/components/charts/index.d.ts.map +1 -1
- package/dist/components/charts/index.js +2 -0
- package/dist/components/charts/index.js.map +1 -1
- package/dist/components/form/index.d.ts +1 -6
- package/dist/components/form/index.d.ts.map +1 -1
- package/dist/components/form/index.js +7 -37
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/interactive/index.d.ts +5 -1
- package/dist/components/interactive/index.d.ts.map +1 -1
- package/dist/components/interactive/index.js +5 -2
- package/dist/components/interactive/index.js.map +1 -1
- package/dist/components/media/index.d.ts +20 -2
- package/dist/components/media/index.d.ts.map +1 -1
- package/dist/components/media/index.js +13 -1
- package/dist/components/media/index.js.map +1 -1
- package/dist/components/table/index.d.ts +5 -1
- package/dist/components/table/index.d.ts.map +1 -1
- package/dist/components/table/index.js +5 -2
- package/dist/components/table/index.js.map +1 -1
- package/dist/core/component.d.ts +11 -0
- package/dist/core/component.d.ts.map +1 -1
- package/dist/core/component.js +22 -9
- package/dist/core/component.js.map +1 -1
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.js +1 -1
- package/dist/prefab.css +4 -0
- package/dist/renderer/components/data.js +2 -2
- package/dist/renderer/components/data.js.map +1 -1
- package/dist/renderer/components/form.js +41 -15
- package/dist/renderer/components/form.js.map +1 -1
- package/dist/renderer/components/interactive.js +17 -4
- package/dist/renderer/components/interactive.js.map +1 -1
- package/dist/renderer/components/media.d.ts +7 -0
- package/dist/renderer/components/media.d.ts.map +1 -1
- package/dist/renderer/components/media.js +63 -2
- package/dist/renderer/components/media.js.map +1 -1
- package/dist/renderer/components/table.js +1 -1
- package/dist/renderer/components/table.js.map +1 -1
- package/dist/renderer.auto.min.js +10 -10
- package/dist/renderer.min.js +10 -10
- package/package.json +1 -1
package/dist/renderer.min.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
(()=>{var{defineProperty:e1,getOwnPropertyNames:C4,getOwnPropertyDescriptor:w4}=Object,b4=Object.prototype.hasOwnProperty;function y4($){return this[$]}var m4=($)=>{var Z=(A0??=new WeakMap).get($),J;if(Z)return Z;if(Z=e1({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var q of C4($))if(!b4.call(Z,q))e1(Z,q,{get:y4.bind($,q),enumerable:!(J=w4($,q))||J.enumerable})}return A0.set($,Z),Z},A0;var h4=($)=>$;function v4($,Z){this[$]=h4.bind(null,Z)}var g4=($,Z)=>{for(var J in Z)e1($,J,{get:Z[J],enumerable:!0,configurable:!0,set:v4.bind(Z,J)})};var D5={};g4(D5,{validateWireFormat:()=>L1,unregisterPipe:()=>O1,setLogLevel:()=>k1,registerPipe:()=>T1,registerComponent:()=>X,log:()=>w,listPipes:()=>A1,isValidWireFormat:()=>V4,isIframe:()=>F1,getLogLevel:()=>f0,createThemeToggle:()=>V1,createLogger:()=>Z0,applyHostTheme:()=>j1,app:()=>t1,PrefabRenderer:()=>Z1,DestroyRegistry:()=>I1,Bridge:()=>_1});var S0={silent:0,error:1,warn:2,info:3,debug:4},$0="warn";function k1($){$0=$}function f0(){return $0}function Z0($){let Z=$?`[prefab:${$}]`:"[prefab]",J=(q,Q,Y)=>{if(S0[q]>S0[$0])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 w=Z0();class D1{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return u4(this.data,$)}getAll(){return this.data}set($,Z){C0(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($))C0(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 u4($,Z){let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}var x4=new Set(["__proto__","constructor","prototype"]);function C0($,Z,J){let q=Z.split(".");if(q.some((Y)=>x4.has(Y))){w.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 N1=new Map;function T1($,Z){if(N1.has($)&&N1.get($)!==Z)w.warn(`pipe "${$}" re-registered`);N1.set($,Z)}function O1($){return N1.delete($)}function A1(){return[...N1.keys()]}function S1($){return N1.get($)}function b($){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(b).join(", ");try{return JSON.stringify($)??""}catch{return""}}var w0=-1,J0=new Map,p4=/\{\{\s*(.+?)\s*\}\}/g;function o($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function t($,Z,J){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&r4(q,"{{")===1){let Q=q.slice(2,-2).trim();return b0(Q,Z,J)}return $.replace(p4,(Q,Y)=>{let U=b0(Y.trim(),Z,J);return b(U)})}function b0($,Z,J){let[q,...Q]=n4($),Y=a(q.trim(),Z,J);for(let U of Q)Y=c4(U.trim(),Y,Z,J);return Y}function a($,Z,J){let q=i4($);if(q>=0){let U=$.slice(0,q).trim(),H=$.slice(q+1),W=s4(H);if(W>=0){let _=H.slice(0,W).trim(),E=H.slice(W+1).trim(),G=a(U,Z,J);return G!==null&&G!==void 0&&G!==!1&&G!==0&&G!==""?a(_,Z,J):a(E,Z,J)}}let Q=f1($,"||");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=f1($,"&&");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 d4){let W=f1($,U);if(W>=0){let _=a($.slice(0,W).trim(),Z,J),E=a($.slice(W+U.length).trim(),Z,J);return H(_,E)}}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 l4){let W=f1($,U);if(W>=0){let _=a($.slice(0,W).trim(),Z,J),E=a($.slice(W+U.length).trim(),Z,J);return H(Number(_),Number(E))}}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 C1(_,W)}return J[$]}if(J){let U=$.split(".")[0];if(U in J)return C1(J[U],$.includes(".")?$.slice(U.length+1):"")}return Z.get($)}function c4($,Z,J,q){let Q=$.indexOf(":"),Y=Q>=0?$.slice(0,Q).trim():$,U=Q>=0?$.slice(Q+1).trim():void 0,H=U?q0(U):void 0;switch(Y){case"find":{if(!Array.isArray(Z)||!U)return;let W=y0(U);if(W.length<2)return;let _=q0(W[0]),E=W[1].trim(),G;if(E.startsWith("'")&&E.endsWith("'")||E.startsWith('"')&&E.endsWith('"'))G=E.slice(1,-1);else if(J){if(q&&E.startsWith("$")){let M=E.indexOf(".");if(M>=0){let z=E.slice(0,M);if(z in q)G=C1(q[z],E.slice(M+1))}else if(E in q)G=q[E]}if(G===void 0&&!(q&&E.startsWith("$")))if(q){let M=E.split(".")[0];G=M in q?C1(q[M],E.includes(".")?E.slice(M.length+1):""):J.get(E)}else G=J.get(E)}else G=E;if(G==null)return;let B=J?.generation??0;if(B!==w0)J0=new Map,w0=B;let K=J0.get(Z);if(!K)K=new Map,J0.set(Z,K);let L=K.get(_);if(!L){L=new Map;for(let M of Z)if(M!=null&&typeof M==="object"){let z=M[_];if(z!=null)L.set(b(z),M)}K.set(_,L)}return L.get(b(G))}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=S1(Y);if(W){let _=U?y0(U).map(q0):[];return W(Z,..._)}return Z}}}var d4=[["!==",($,Z)=>$!==Z],["===",($,Z)=>$===Z],["!=",($,Z)=>$!=Z],["==",($,Z)=>$==Z],[">=",($,Z)=>Number($)>=Number(Z)],["<=",($,Z)=>Number($)<=Number(Z)],[">",($,Z)=>Number($)>Number(Z)],["<",($,Z)=>Number($)<Number(Z)]],l4=[[" + ",($,Z)=>$+Z],[" - ",($,Z)=>$-Z],[" * ",($,Z)=>$*Z],[" / ",($,Z)=>Z!==0?$/Z:0],[" % ",($,Z)=>Z!==0?$%Z:0]];function f1($,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 i4($){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 s4($){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 n4($){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 q0($){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 C1($,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 r4($,Z){let J=0,q=0;while((q=$.indexOf(Z,q))!==-1)J++,q+=Z.length;return J}function w1($){return $.replace(/_([a-z])/g,(Z,J)=>J.toUpperCase())}function Y0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:w1(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?Y0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=Y0(q);else Z[Q]=q}return Z}async function h($,Z){let J=Array.isArray($)?$:[$];for(let q of J)await a4(q,Z)}function v($,Z){$.catch((J)=>w.error(`${Z} failed:`,J))}async function m1($,Z,J,q){if(J!=null)w.debug(`${$} failed:`,Z),await W1(J,q,{$error:Z});else w.warn(`${$} failed:`,Z)}async function a4($,Z){let J=Y0($),q=J.action;switch(q){case"setState":{o4(J,Z);return}case"toggleState":{t4(J,Z);return}case"appendState":{e4(J,Z);return}case"popState":{$8(J,Z);return}case"showToast":{Z8(J,Z);return}case"closeOverlay":{J8(J,Z);return}case"openLink":{q8(J);return}case"setInterval":{Y8(J,Z);return}case"toolCall":case"callTool":return U8(J,Z);case"sendMessage":return H8(J,Z);case"updateContext":{W8(J,Z);return}case"fetch":return G8(J,Z);case"openFilePicker":{X8(J,Z);return}case"callHandler":return B8(J,Z);case"requestDisplayMode":{M8(J,Z);return}case"subscribe":{E8(J,Z);return}case"unsubscribe":{z8(J);return}default:w.warn(`Unknown action: ${q}`)}}function o4($,Z){let{key:J,value:q}=$;if(o(q))q=t(q,Z.store,Z.scope);Z.store.set(J,q),Z.rerender(),W1($.onSuccess,Z)}function t4($,Z){Z.store.toggle($.key),Z.rerender()}function e4($,Z){let J=$.value??$.item;if(o(J))J=t(J,Z.store,Z.scope);Z.store.append($.key,J,$.index),Z.rerender()}function $8($,Z){Z.store.pop($.key,$.index),Z.rerender()}function Z8($,Z){Z.onToast?.({message:y1($.message,Z),description:$.description!=null?y1($.description,Z):void 0,variant:$.variant,duration:$.duration})}function J8($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function q8($){if(typeof window<"u"){let Z=$.url;if(!Z){w.warn("openLink: missing url");return}if(!g0(Z)){w.warn(`Blocked unsafe URL scheme: ${Z}`);return}window.open(Z,$.target??"_blank")}}var b1=new Set,Q8=20,m0=100;function Y8($,Z){let J=Math.max($.intervalMs,m0),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(b1.size>=Q8){w.warn("Max intervals reached, ignoring new setInterval");return}let Q=globalThis.setInterval(()=>v(h(q,Z),"interval action"),J);b1.add(Q)}function h0(){for(let $ of b1)globalThis.clearInterval($);b1.clear()}async function U8($,Z){if(!Z.transport){w.warn("No MCP transport configured for toolCall");return}let J=$.tool,q=U0($.arguments,Z);try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=h1(Q);if(Y&&Z.remount)Z.remount(Y);else v1(Q,Z),Z.rerender();await W1($.onSuccess,Z,{$result:Q})}catch(Q){await m1("toolCall",Q,$.onError,Z)}}async function H8($,Z){if(!Z.transport){w.warn("No MCP transport configured for sendMessage");return}await Z.transport.sendMessage(y1($.message,Z))}function W8($,Z){let J=$.context;if(J!=null)Z.store.merge(J),Z.rerender()}async function G8($,Z){let J=y1($.url,Z);if(!g0(J)){w.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=h1(H);if(W&&Z.remount)Z.remount(W);else v1(H,Z),Z.rerender();await W1($.onSuccess,Z,{$result:H})}catch(U){await m1("fetch",U,$.onError,Z)}}function X8($,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 B8($,Z){let J=$.handler,q=U0($.arguments,Z);if(!Z.transport){w.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=h1(Q);if(Y&&Z.remount)Z.remount(Y);else v1(Q,Z),Z.rerender();await W1($.onSuccess,Z,{$result:Q})}catch(Q){await m1("callHandler",Q,$.onError,Z)}}function M8($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var Q1=new Map,_8=50,N8=2000;function E8($,Z){let{uri:J,stateKey:q}=$;if(!J||!q){w.warn("subscribe: missing uri or stateKey");return}if(Q1.has(J))return;if(Q1.size>=_8){w.warn("Max subscriptions reached, ignoring new subscribe");return}let Q=(G)=>{let B=h1(G);if(B&&Z.remount)Z.remount(B);else{if(!v1(G,Z))Z.store.set(q,G);Z.rerender()}W1($.onData,Z,{$data:G})};if(Z.transport?.subscribe&&Z.transport.capabilities?.subscriptions){let G=Z.transport.subscribe(J,Q);Q1.set(J,G);return}let Y=$.fallbackTool,U=$.fallbackInterval??N8;if(!Y){w.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!Z.transport){w.warn("No MCP transport configured for subscribe fallback");return}let H=$.fallbackArgs??{},W=Math.max(U,m0),_=Z.transport,E=globalThis.setInterval(()=>{(async()=>{try{let G=U0(H,Z),B=await _.callTool(Y,G);Q(B)}catch(G){m1("subscribe",G,$.onError,Z)}})()},W);Q1.set(J,()=>globalThis.clearInterval(E))}function z8($){let Z=$.uri;if(!Z){w.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){w.warn(`Error cleaning up subscription '${$}':`,J)}Q1.clear()}function h1($){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 K8($){if($==null||typeof $!=="object")return null;let Z=$;if(Q0(Z))return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"&&Q0(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"&&Q0(q))return q}catch{}}return null}function Q0($){if(!("$prefab"in $)||!("update"in $))return!1;let Z=$.update;return Z!=null&&typeof Z==="object"&&"state"in Z}function v1($,Z){let J=K8($);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 F8=/^\s*(javascript|vbscript|data):/i;function g0($){return!F8.test($)}function y1($,Z){if(o($)){let J=t($,Z.store,Z.scope);return b(J)}return b($)}function U0($,Z){if(!$)return{};let J={};for(let[q,Q]of Object.entries($))J[q]=o(Q)?t(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 W0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:w1(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?W0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=W0(q);else Z[Q]=q}return Z}class I1{callbacks=[];track($){this.callbacks.push($)}flush(){for(let $ of this.callbacks)try{$()}catch(Z){w.warn("destroy callback error:",Z)}this.callbacks=[]}get size(){return this.callbacks.length}}function L8($){return typeof $==="object"&&"element"in $}var G0=new Map;function X($,Z){if(G0.has($))w.warn(`overriding existing renderer for "${$}"`);G0.set($,Z)}function u($,Z){let J=W0($);if(Z.defs?.[J.type]){let Y={...Z.defs[J.type],...J,type:Z.defs[J.type].type};return u(Y,Z)}let q=G0.get(J.type),Q;if(q){let Y=q(J,Z);if(L8(Y))Q=Y.element,Z.destroyRegistry?.track(Y.destroy);else Q=Y}else if(Q=document.createElement("div"),Q.setAttribute("data-prefab-type",J.type),J.children)for(let Y of J.children)Q.appendChild(u(Y,Z));if(Q instanceof HTMLElement){if(J.id)Q.id=J.id;if(J.cssClass){let Y=F(J.cssClass,Z);if(Y)Q.className=(Q.className?Q.className+" ":"")+Y}if(J.onClick!=null){if(Q.addEventListener("click",()=>{v(h(J.onClick,l(Z)),"onClick")}),Q.tagName!=="BUTTON"&&Q.tagName!=="A")Q.setAttribute("role","button"),Q.setAttribute("tabindex","0"),Q.addEventListener("keydown",(Y)=>{let U=Y.key;if(U==="Enter"||U===" ")Y.preventDefault(),v(h(J.onClick,l(Z)),"onClick")})}}if(J.onMount){let Y=J.onMount,U=l(Z);queueMicrotask(()=>v(h(Y,U),"onMount"))}return Q}function C($,Z,J){if(!$.children)return;Y1($.children,Z,J)}function Y1($,Z,J){let q=0;while(q<$.length){let Q=$[q];if(Q.type==="If")q=D8($,q,Z,J);else if(Q.type==="Elif"||Q.type==="Else")q++;else Z.appendChild(u(Q,J)),q++}}function D8($,Z,J,q){let Q=!1,Y=Z,U=$[Y];if(u0(U.condition,q))H0(U,J,q),Q=!0;Y++;while(Y<$.length){let H=$[Y];if(H.type==="Elif"){if(!Q&&u0(H.condition,q))H0(H,J,q),Q=!0;Y++}else if(H.type==="Else"){if(!Q)H0(H,J,q);Y++;break}else break}return Y}function u0($,Z){if(!$)return!1;if(o($))return Boolean(t($,Z.store,Z.scope));return Boolean(Z.store.get($))}function H0($,Z,J){if(!$.children)return;Y1($.children,Z,J)}function F($,Z){if(o($)){let J=t($,Z.store,Z.scope);return b(J)}return b($)}function d($,Z){if(o($))return t($,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 X0($,Z){return $.textContent=Z,$}function d0(){X("Column",T8),X("Row",O8),X("Grid",x0),X("GridItem",p0),X("Container",I8),X("Div",c0),X("Span",P8),X("Dashboard",x0),X("DashboardItem",p0),X("Pages",R8),X("Page",c0),X("Detail",V8),X("MasterDetail",j8)}function T8($,Z){let J=N("div","pf-column");J.style.display="flex",J.style.flexDirection="column";let q=g1($);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 O8($,Z){let J=N("div","pf-row");J.style.display="flex",J.style.flexDirection="row";let q=g1($);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=g1($);if(Q!=null)J.style.gap=`${Q*4}px`;return C($,J,Z),J}function p0($,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 I8($,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 c0($,Z){let J=N("div","pf-div");return C($,J,Z),J}function P8($,Z){let J=N("span","pf-span");return C($,J,Z),J}function R8($,Z){let J=N("div","pf-pages");return C($,J,Z),J}function V8($,Z){let J=N("div","pf-detail"),q=$.of!=null?d($.of,Z):void 0;if(q!=null&&q!==""&&q!==!1&&q!==0)C($,J,Z);else if($.empty!=null){let Q=$.empty;J.appendChild(u(Q,Z))}return J}function j8($,Z){let J=N("div","pf-master-detail");J.style.display="flex",J.style.flexDirection="row";let q=g1($);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 k8=/\bgap-(\d+)\b/;function g1($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let Z=k8.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 A8={"&":"&","<":"<",">":">",'"':""","'":"'"};function P1($){return $.replace(/[&<>"']/g,(Z)=>A8[Z]??Z)}function n0(){X("Heading",S8),X("H1",($,Z)=>u1($,Z,"h1")),X("H2",($,Z)=>u1($,Z,"h2")),X("H3",($,Z)=>u1($,Z,"h3")),X("H4",($,Z)=>u1($,Z,"h4")),X("Text",f8),X("P",C8),X("Lead",($,Z)=>E1($,Z,"p","pf-lead")),X("Large",($,Z)=>E1($,Z,"span","pf-large")),X("Small",($,Z)=>E1($,Z,"small","pf-small")),X("Muted",($,Z)=>E1($,Z,"p","pf-muted")),X("BlockQuote",($,Z)=>E1($,Z,"blockquote","pf-blockquote")),X("Label",($,Z)=>E1($,Z,"label","pf-label")),X("Link",b8),X("Code",y8),X("Markdown",m8),X("Kbd",h8)}function S8($,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 u1($,Z,J){let q=document.createElement(J);return q.className=`pf-heading pf-${J}`,q.textContent=F($.content,Z),q}function f8($,Z){return X0(N("span","pf-text"),F($.content,Z))}function C8($,Z){return X0(N("p","pf-p"),F($.content,Z))}function E1($,Z,J,q){let Q=document.createElement(J);return Q.className=q,Q.textContent=F($.content,Z),Q}var w8=/^\s*(javascript|vbscript|data):/i;function b8($,Z){let J=document.createElement("a");if(J.className="pf-link",J.textContent=F($.content,Z),$.href!=null){let q=F($.href,Z);if(!w8.test(q))J.href=q}if($.target!=null)J.target=F($.target,Z);return J}function y8($,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 m8($,Z){let J=N("div","pf-markdown"),q=F($.content,Z);return J.innerHTML=r0(q),J.setAttribute("data-markdown","true"),J}var s0=/^\s*(javascript|vbscript|data):/i;function x1($){let Z=P1($),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 P1(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,`
|
|
1
|
+
(()=>{var{defineProperty:$0,getOwnPropertyNames:b4,getOwnPropertyDescriptor:y4}=Object,m4=Object.prototype.hasOwnProperty;function h4($){return this[$]}var v4=($)=>{var Z=(S0??=new WeakMap).get($),J;if(Z)return Z;if(Z=$0({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var q of b4($))if(!m4.call(Z,q))$0(Z,q,{get:h4.bind($,q),enumerable:!(J=y4($,q))||J.enumerable})}return S0.set($,Z),Z},S0;var g4=($)=>$;function u4($,Z){this[$]=g4.bind(null,Z)}var x4=($,Z)=>{for(var J in Z)$0($,J,{get:Z[J],enumerable:!0,configurable:!0,set:u4.bind(Z,J)})};var I5={};x4(I5,{validateWireFormat:()=>D1,unregisterPipe:()=>O1,setLogLevel:()=>A1,registerPipe:()=>T1,registerComponent:()=>B,log:()=>w,listPipes:()=>S1,isValidWireFormat:()=>k4,isIframe:()=>F1,getLogLevel:()=>C0,createThemeToggle:()=>j1,createLogger:()=>J0,applyHostTheme:()=>k1,app:()=>e1,PrefabRenderer:()=>Z1,DestroyRegistry:()=>I1,Bridge:()=>_1});var f0={silent:0,error:1,warn:2,info:3,debug:4},Z0="warn";function A1($){Z0=$}function C0(){return Z0}function J0($){let Z=$?`[prefab:${$}]`:"[prefab]",J=(q,Q,Y)=>{if(f0[q]>f0[Z0])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 w=J0();class L1{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor($){if($)this.data=structuredClone($)}get($){return c4(this.data,$)}getAll(){return this.data}set($,Z){w0(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($))w0(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 c4($,Z){let J=Z.split("."),q=$;for(let Q of J){if(q==null||typeof q!=="object")return;q=q[Q]}return q}var p4=new Set(["__proto__","constructor","prototype"]);function w0($,Z,J){let q=Z.split(".");if(q.some((Y)=>p4.has(Y))){w.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 N1=new Map;function T1($,Z){if(N1.has($)&&N1.get($)!==Z)w.warn(`pipe "${$}" re-registered`);N1.set($,Z)}function O1($){return N1.delete($)}function S1(){return[...N1.keys()]}function f1($){return N1.get($)}function b($){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(b).join(", ");try{return JSON.stringify($)??""}catch{return""}}var b0=-1,q0=new Map,d4=/\{\{\s*(.+?)\s*\}\}/g;function o($){return typeof $==="string"&&$.includes("{{")&&$.includes("}}")}function t($,Z,J){let q=$.trim();if(q.startsWith("{{")&&q.endsWith("}}")&&o4(q,"{{")===1){let Q=q.slice(2,-2).trim();return y0(Q,Z,J)}return $.replace(d4,(Q,Y)=>{let U=y0(Y.trim(),Z,J);return b(U)})}function y0($,Z,J){let[q,...Q]=a4($),Y=a(q.trim(),Z,J);for(let U of Q)Y=l4(U.trim(),Y,Z,J);return Y}function a($,Z,J){let q=n4($);if(q>=0){let U=$.slice(0,q).trim(),H=$.slice(q+1),W=r4(H);if(W>=0){let X=H.slice(0,W).trim(),M=H.slice(W+1).trim(),G=a(U,Z,J);return G!==null&&G!==void 0&&G!==!1&&G!==0&&G!==""?a(X,Z,J):a(M,Z,J)}}let Q=C1($,"||");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=C1($,"&&");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 i4){let W=C1($,U);if(W>=0){let X=a($.slice(0,W).trim(),Z,J),M=a($.slice(W+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 s4){let W=C1($,U);if(W>=0){let X=a($.slice(0,W).trim(),Z,J),M=a($.slice(W+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),W=$.slice(U+1),X=J[H];return w1(X,W)}return J[$]}if(J){let U=$.split(".")[0];if(U in J)return w1(J[U],$.includes(".")?$.slice(U.length+1):"")}return Z.get($)}function l4($,Z,J,q){let Q=$.indexOf(":"),Y=Q>=0?$.slice(0,Q).trim():$,U=Q>=0?$.slice(Q+1).trim():void 0,H=U?Q0(U):void 0;switch(Y){case"find":{if(!Array.isArray(Z)||!U)return;let W=m0(U);if(W.length<2)return;let X=Q0(W[0]),M=W[1].trim(),G;if(M.startsWith("'")&&M.endsWith("'")||M.startsWith('"')&&M.endsWith('"'))G=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)G=w1(q[K],M.slice(_+1))}else if(M in q)G=q[M]}if(G===void 0&&!(q&&M.startsWith("$")))if(q){let _=M.split(".")[0];G=_ in q?w1(q[_],M.includes(".")?M.slice(_.length+1):""):J.get(M)}else G=J.get(M)}else G=M;if(G==null)return;let E=J?.generation??0;if(E!==b0)q0=new Map,b0=E;let z=q0.get(Z);if(!z)z=new Map,q0.set(Z,z);let F=z.get(X);if(!F){F=new Map;for(let _ of Z)if(_!=null&&typeof _==="object"){let K=_[X];if(K!=null)F.set(b(K),_)}z.set(X,F)}return F.get(b(G))}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),X=typeof H==="string"?H:"";return W===1?X:`${X}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 X=W[H];return X==null||X===!1||X===0||X===""}):Z;default:{let W=f1(Y);if(W){let X=U?m0(U).map(Q0):[];return W(Z,...X)}return Z}}}var i4=[["!==",($,Z)=>$!==Z],["===",($,Z)=>$===Z],["!=",($,Z)=>$!=Z],["==",($,Z)=>$==Z],[">=",($,Z)=>Number($)>=Number(Z)],["<=",($,Z)=>Number($)<=Number(Z)],[">",($,Z)=>Number($)>Number(Z)],["<",($,Z)=>Number($)<Number(Z)]],s4=[[" + ",($,Z)=>$+Z],[" - ",($,Z)=>$-Z],[" * ",($,Z)=>$*Z],[" / ",($,Z)=>Z!==0?$/Z:0],[" % ",($,Z)=>Z!==0?$%Z:0]];function C1($,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 n4($){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 r4($){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 a4($){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 Q0($){let Z=$.replace(/^['"]|['"]$/g,"");if(Z==="true")return!0;if(Z==="false")return!1;let J=Number(Z);return isNaN(J)?Z:J}function m0($){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 w1($,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 o4($,Z){let J=0,q=0;while((q=$.indexOf(Z,q))!==-1)J++,q+=Z.length;return J}function b1($){return $.replace(/_([a-z])/g,(Z,J)=>J.toUpperCase())}function U0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:b1(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?U0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=U0(q);else Z[Q]=q}return Z}async function m($,Z){let J=Array.isArray($)?$:[$];for(let q of J)await t4(q,Z)}function v($,Z){$.catch((J)=>w.error(`${Z} failed:`,J))}async function h1($,Z,J,q){if(J!=null)w.debug(`${$} failed:`,Z),await W1(J,q,{$error:Z});else w.warn(`${$} failed:`,Z)}async function t4($,Z){let J=U0($),q=J.action;switch(q){case"setState":{e4(J,Z);return}case"toggleState":{$8(J,Z);return}case"appendState":{Z8(J,Z);return}case"popState":{J8(J,Z);return}case"showToast":{q8(J,Z);return}case"closeOverlay":{Q8(J,Z);return}case"openLink":{Y8(J);return}case"setInterval":{H8(J,Z);return}case"toolCall":case"callTool":return W8(J,Z);case"sendMessage":return G8(J,Z);case"updateContext":{X8(J,Z);return}case"fetch":return B8(J,Z);case"openFilePicker":{M8(J,Z);return}case"callHandler":return _8(J,Z);case"requestDisplayMode":{N8(J,Z);return}case"subscribe":{K8(J,Z);return}case"unsubscribe":{F8(J);return}default:w.warn(`Unknown action: ${q}`)}}function e4($,Z){let{key:J,value:q}=$;if(o(q))q=t(q,Z.store,Z.scope);Z.store.set(J,q),Z.rerender(),W1($.onSuccess,Z)}function $8($,Z){Z.store.toggle($.key),Z.rerender()}function Z8($,Z){let J=$.value??$.item;if(o(J))J=t(J,Z.store,Z.scope);Z.store.append($.key,J,$.index),Z.rerender()}function J8($,Z){Z.store.pop($.key,$.index),Z.rerender()}function q8($,Z){Z.onToast?.({message:m1($.message,Z),description:$.description!=null?m1($.description,Z):void 0,variant:$.variant,duration:$.duration})}function Q8($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function Y8($){if(typeof window<"u"){let Z=$.url;if(!Z){w.warn("openLink: missing url");return}if(!u0(Z)){w.warn(`Blocked unsafe URL scheme: ${Z}`);return}window.open(Z,$.target??"_blank")}}var y1=new Set,U8=20,h0=100;function H8($,Z){let J=Math.max($.intervalMs,h0),q=$.onTick;if(typeof globalThis.setInterval!=="function")return;if(y1.size>=U8){w.warn("Max intervals reached, ignoring new setInterval");return}let Q=globalThis.setInterval(()=>v(m(q,Z),"interval action"),J);y1.add(Q)}function v0(){for(let $ of y1)globalThis.clearInterval($);y1.clear()}async function W8($,Z){if(!Z.transport){w.warn("No MCP transport configured for toolCall");return}let J=$.tool,q=H0($.arguments,Z);try{let Q=await Z.transport.callTool(J,q);if($.resultKey!=null)Z.store.set($.resultKey,Q);let Y=v1(Q);if(Y&&Z.remount)Z.remount(Y);else g1(Q,Z),Z.rerender();await W1($.onSuccess,Z,{$result:Q})}catch(Q){await h1("toolCall",Q,$.onError,Z)}}async function G8($,Z){if(!Z.transport){w.warn("No MCP transport configured for sendMessage");return}await Z.transport.sendMessage(m1($.message,Z))}function X8($,Z){let J=$.context;if(J!=null)Z.store.merge(J),Z.rerender()}async function B8($,Z){let J=m1($.url,Z);if(!u0(J)){w.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=v1(H);if(W&&Z.remount)Z.remount(W);else g1(H,Z),Z.rerender();await W1($.onSuccess,Z,{$result:H})}catch(U){await h1("fetch",U,$.onError,Z)}}function M8($,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 _8($,Z){let J=$.handler,q=H0($.arguments,Z);if(!Z.transport){w.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=v1(Q);if(Y&&Z.remount)Z.remount(Y);else g1(Q,Z),Z.rerender();await W1($.onSuccess,Z,{$result:Q})}catch(Q){await h1("callHandler",Q,$.onError,Z)}}function N8($,Z){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:$.mode}}))}var Q1=new Map,E8=50,z8=2000;function K8($,Z){let{uri:J,stateKey:q}=$;if(!J||!q){w.warn("subscribe: missing uri or stateKey");return}if(Q1.has(J))return;if(Q1.size>=E8){w.warn("Max subscriptions reached, ignoring new subscribe");return}let Q=(G)=>{let E=v1(G);if(E&&Z.remount)Z.remount(E);else{if(!g1(G,Z))Z.store.set(q,G);Z.rerender()}W1($.onData,Z,{$data:G})};if(Z.transport?.subscribe&&Z.transport.capabilities?.subscriptions){let G=Z.transport.subscribe(J,Q);Q1.set(J,G);return}let Y=$.fallbackTool,U=$.fallbackInterval??z8;if(!Y){w.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!Z.transport){w.warn("No MCP transport configured for subscribe fallback");return}let H=$.fallbackArgs??{},W=Math.max(U,h0),X=Z.transport,M=globalThis.setInterval(()=>{(async()=>{try{let G=H0(H,Z),E=await X.callTool(Y,G);Q(E)}catch(G){h1("subscribe",G,$.onError,Z)}})()},W);Q1.set(J,()=>globalThis.clearInterval(M))}function F8($){let Z=$.uri;if(!Z){w.warn("unsubscribe: missing uri");return}let J=Q1.get(Z);if(J)J(),Q1.delete(Z)}function g0(){for(let[$,Z]of Q1)try{Z()}catch(J){w.warn(`Error cleaning up subscription '${$}':`,J)}Q1.clear()}function v1($){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 D8($){if($==null||typeof $!=="object")return null;let Z=$;if(Y0(Z))return Z;if("structuredContent"in Z){let J=Z.structuredContent;if(J!=null&&typeof J==="object"&&Y0(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"&&Y0(q))return q}catch{}}return null}function Y0($){if(!("$prefab"in $)||!("update"in $))return!1;let Z=$.update;return Z!=null&&typeof Z==="object"&&"state"in Z}function g1($,Z){let J=D8($);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 L8=/^\s*(javascript|vbscript|data):/i;function u0($){return!L8.test($)}function m1($,Z){if(o($)){let J=t($,Z.store,Z.scope);return b(J)}return b($)}function H0($,Z){if(!$)return{};let J={};for(let[q,Q]of Object.entries($))J[q]=o(Q)?t(Q,Z.store,Z.scope):Q;return J}async function W1($,Z,J){if($==null)return;let q={...Z.scope,...J};await m($,{...Z,scope:q})}function G0($){let Z={};for(let[J,q]of Object.entries($)){let Q=J.startsWith("$")?J:b1(J);if(Array.isArray(q))Z[Q]=q.map((Y)=>Y!=null&&typeof Y==="object"&&!Array.isArray(Y)?G0(Y):Y);else if(q!=null&&typeof q==="object"&&!Array.isArray(q))Z[Q]=G0(q);else Z[Q]=q}return Z}class I1{callbacks=[];track($){this.callbacks.push($)}flush(){for(let $ of this.callbacks)try{$()}catch(Z){w.warn("destroy callback error:",Z)}this.callbacks=[]}get size(){return this.callbacks.length}}function T8($){return typeof $==="object"&&"element"in $}var X0=new Map;function B($,Z){if(X0.has($))w.warn(`overriding existing renderer for "${$}"`);X0.set($,Z)}function u($,Z){let J=G0($);if(Z.defs?.[J.type]){let Y={...Z.defs[J.type],...J,type:Z.defs[J.type].type};return u(Y,Z)}let q=X0.get(J.type),Q;if(q){let Y=q(J,Z);if(T8(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=O8($,q,Z,J);else if(Q.type==="Elif"||Q.type==="Else")q++;else Z.appendChild(u(Q,J)),q++}}function O8($,Z,J,q){let Q=!1,Y=Z,U=$[Y];if(x0(U.condition,q))W0(U,J,q),Q=!0;Y++;while(Y<$.length){let H=$[Y];if(H.type==="Elif"){if(!Q&&x0(H.condition,q))W0(H,J,q),Q=!0;Y++}else if(H.type==="Else"){if(!Q)W0(H,J,q);Y++;break}else break}return Y}function x0($,Z){if(!$)return!1;if(o($))return Boolean(t($,Z.store,Z.scope));return Boolean(Z.store.get($))}function W0($,Z,J){if(!$.children)return;Y1($.children,Z,J)}function D($,Z){if(o($)){let J=t($,Z.store,Z.scope);return b(J)}return b($)}function l($,Z){if(o($))return t($,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 B0($,Z){return $.textContent=Z,$}function l0(){B("Column",I8),B("Row",P8),B("Grid",c0),B("GridItem",p0),B("Container",R8),B("Div",d0),B("Span",V8),B("Dashboard",c0),B("DashboardItem",p0),B("Pages",j8),B("Page",d0),B("Detail",k8),B("MasterDetail",A8)}function I8($,Z){let J=N("div","pf-column");J.style.display="flex",J.style.flexDirection="column";let q=u1($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=i0($.align);if($.justify!=null)J.style.justifyContent=s0($.justify);return C($,J,Z),J}function P8($,Z){let J=N("div","pf-row");J.style.display="flex",J.style.flexDirection="row";let q=u1($);if(q!=null)J.style.gap=`${q*4}px`;if($.align!=null)J.style.alignItems=i0($.align);if($.justify!=null)J.style.justifyContent=s0($.justify);if($.wrap===!0)J.style.flexWrap="wrap";return C($,J,Z),J}function c0($,Z){let J=N("div","pf-grid");J.style.display="grid";let q=$.columns??3;J.style.gridTemplateColumns=`repeat(${q}, 1fr)`;let Q=u1($);if(Q!=null)J.style.gap=`${Q*4}px`;return C($,J,Z),J}function p0($,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 R8($,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 d0($,Z){let J=N("div","pf-div");return C($,J,Z),J}function V8($,Z){let J=N("span","pf-span");return C($,J,Z),J}function j8($,Z){let J=N("div","pf-pages");return C($,J,Z),J}function k8($,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 A8($,Z){let J=N("div","pf-master-detail");J.style.display="flex",J.style.flexDirection="row";let q=u1($);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 S8=/\bgap-(\d+)\b/;function u1($){if($.gap!=null)return $.gap;if(typeof $.cssClass==="string"){let Z=S8.exec($.cssClass);if(Z)return Number(Z[1])}return null}function i0($){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[$]??$}function s0($){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[$]??$}var f8={"&":"&","<":"<",">":">",'"':""","'":"'"};function P1($){return $.replace(/[&<>"']/g,(Z)=>f8[Z]??Z)}function r0(){B("Heading",C8),B("H1",($,Z)=>x1($,Z,"h1")),B("H2",($,Z)=>x1($,Z,"h2")),B("H3",($,Z)=>x1($,Z,"h3")),B("H4",($,Z)=>x1($,Z,"h4")),B("Text",w8),B("P",b8),B("Lead",($,Z)=>E1($,Z,"p","pf-lead")),B("Large",($,Z)=>E1($,Z,"span","pf-large")),B("Small",($,Z)=>E1($,Z,"small","pf-small")),B("Muted",($,Z)=>E1($,Z,"p","pf-muted")),B("BlockQuote",($,Z)=>E1($,Z,"blockquote","pf-blockquote")),B("Label",($,Z)=>E1($,Z,"label","pf-label")),B("Link",m8),B("Code",h8),B("Markdown",v8),B("Kbd",g8)}function C8($,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 x1($,Z,J){let q=document.createElement(J);return q.className=`pf-heading pf-${J}`,q.textContent=D($.content,Z),q}function w8($,Z){return B0(N("span","pf-text"),D($.content,Z))}function b8($,Z){return B0(N("p","pf-p"),D($.content,Z))}function E1($,Z,J,q){let Q=document.createElement(J);return Q.className=q,Q.textContent=D($.content,Z),Q}var y8=/^\s*(javascript|vbscript|data):/i;function m8($,Z){let J=document.createElement("a");if(J.className="pf-link",J.textContent=D($.content,Z),$.href!=null){let q=D($.href,Z);if(!y8.test(q))J.href=q}if($.target!=null)J.target=D($.target,Z);return J}function h8($,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 v8($,Z){let J=N("div","pf-markdown"),q=D($.content,Z);return J.innerHTML=a0(q),J.setAttribute("data-markdown","true"),J}var n0=/^\s*(javascript|vbscript|data):/i;function c1($){let Z=P1($),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(n0.test(Y))return P1(Q);return`<img src="${Y}" alt="${Q}" />`}),Z=Z.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(q,Q,Y)=>{if(n0.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 a0($){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(P1(Z[q])),q++;q++;let
|
|
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}>${
|
|
5
|
-
`))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(Q)){J.push("<ul>");while(q<Z.length&&/^[\s]*[-*+]\s+/.test(Z[q]))J.push(`<li>${
|
|
6
|
-
`)}function h8($,Z){let J=document.createElement("kbd");return J.className="pf-kbd",J.textContent=F($.content,Z),J}function o0(){X("Card",v8),X("CardHeader",B0("pf-card-header")),X("CardTitle",a0("pf-card-title","h3")),X("CardDescription",a0("pf-card-description","p")),X("CardContent",B0("pf-card-content")),X("CardFooter",B0("pf-card-footer"))}function v8($,Z){let J=N("div","pf-card");return J.style.overflow="hidden",C($,J,Z),J}function B0($){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=F(J.content,q),Q}}function t0(){X("DataTable",g8),X("Badge",u8),X("Dot",x8),X("Metric",p8),X("Ring",c8),X("Progress",d8),X("Separator",l8),X("Loader",i8),X("Icon",s8),X("Sparkline",n8)}function g8($,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 G of Q){let B=document.createElement("th");B.className="pf-datatable-th",B.textContent=G.header??G.key,B.style.padding="8px 12px",B.style.textAlign="left",_.appendChild(B)}W.appendChild(_),q.appendChild(W);let E=document.createElement("tbody");if(Array.isArray(Y)){let G=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&&G!=null&&L[U]!=null&&b(L[U])===b(G))K.classList.add("pf-datatable-row-selected");if($.onRowClick!=null&&U)K.style.cursor="pointer",K.addEventListener("click",()=>{let z={...Z.scope,$item:L,$index:Y.indexOf(B)},T=l({...Z,scope:z});v(h($.onRowClick,T),"onRowClick")});for(let z of Q){let T=document.createElement("td");T.className="pf-datatable-td";let P;if(z.accessor)P=d(`{{ $item.${z.accessor} }}`,{...Z,scope:{...Z.scope,$item:L}});else if(P=M?B:L[z.key],z.format&&P!=null)P=d(`{{ __fmtVal | ${z.format} }}`,{...Z,scope:{...Z.scope,__fmtVal:P}});T.textContent=b(P),T.style.padding="8px 12px",K.appendChild(T)}E.appendChild(K)}}if(q.appendChild(E),$.search===!0){let G=document.createElement("input");G.type="text",G.placeholder="Search...",G.className="pf-datatable-search",G.style.marginBottom="8px",G.style.padding="6px 12px",G.style.width="100%",G.style.boxSizing="border-box",G.addEventListener("input",()=>{let B=G.value.toLowerCase(),K=Array.from(E.querySelectorAll("tr"));for(let L of K){let M=(L.textContent??"").toLowerCase();L.style.display=M.includes(B)?"":"none"}}),J.appendChild(G)}return J.appendChild(q),J}function u8($,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),r8(J,q),J}function x8($,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 p8($,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 c8($,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),E=document.createElementNS("http://www.w3.org/2000/svg","svg");E.setAttribute("width",String(q)),E.setAttribute("height",String(q)),E.setAttribute("viewBox",`0 0 ${q} ${q}`);let G=document.createElementNS("http://www.w3.org/2000/svg","circle");G.setAttribute("cx",String(q/2)),G.setAttribute("cy",String(q/2)),G.setAttribute("r",String(H)),G.setAttribute("fill","none"),G.setAttribute("stroke","var(--muted, #e5e7eb)"),G.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",E.appendChild(G),E.appendChild(B),J.appendChild(E),$.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 d8($,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 l8($,Z){let J=document.createElement("hr");return J.className="pf-separator",J.style.border="none",J.style.margin="8px 0",J}function i8($,Z){let J=N("div","pf-loader");return J.textContent="⏳",J.style.display="flex",J.style.justifyContent="center",J.style.padding="16px",J}function s8($,Z){let J=N("span","pf-icon");return J.setAttribute("data-icon",F($.name??$.content,Z)),J}function n8($,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 E=q.length>1?q.length-1:1,G=q.map((K,L)=>{let M=L/E*Q,z=Y-(K-H)/W*(Y-4)-2;return`${M},${z}`}).join(" "),B=document.createElementNS("http://www.w3.org/2000/svg","polyline");return B.setAttribute("points",G),B.setAttribute("fill","none"),B.setAttribute("stroke","var(--primary, #3b82f6)"),B.setAttribute("stroke-width","1.5"),_.appendChild(B),J.appendChild(_),J}function r8($,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(){X("Form",a8),X("Input",o8),X("Textarea",t8),X("Button",e8),X("ButtonGroup",$6),X("Select",Z6),X("SelectOption",J6),X("SelectGroup",p1("pf-select-group")),X("SelectLabel",R1("pf-select-label")),X("SelectSeparator",e0),X("Checkbox",q6),X("Switch",Q6),X("Slider",Y6),X("Radio",H6),X("RadioGroup",W6),X("Combobox",G6),X("ComboboxOption",X6),X("ComboboxGroup",p1("pf-combobox-group")),X("ComboboxLabel",R1("pf-combobox-label")),X("ComboboxSeparator",e0),X("Calendar",B6),X("DatePicker",M6),X("Field",p1("pf-field")),X("FieldTitle",R1("pf-field-title")),X("FieldDescription",R1("pf-field-description")),X("FieldContent",p1("pf-field-content")),X("FieldError",R1("pf-field-error")),X("ChoiceCard",_6)}function a8($,Z){let J=document.createElement("form");return J.className="pf-form",J.addEventListener("submit",(q)=>{q.preventDefault();let Q=new FormData(J),Y={};if(Q.forEach((U,H)=>{Y[H]=U}),Z.store.merge(Y),$.onSubmit!=null){let U=l(Z);U.scope={...Z.scope,...Y},v(h($.onSubmit,U),"onSubmit")}}),C($,J,Z),J}function o8($,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=b(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 M0(q),J.appendChild(q),J}function t8($,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=b(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 M0(q),J.appendChild(q),J}function e8($,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),U6(J,q),$.size!=null)J.setAttribute("data-size",$.size);if($.disabled===!0)J.disabled=!0;return J}function $6($,Z){let J=N("div","pf-button-group");return J.style.display="flex",J.style.gap="8px",C($,J,Z),J}function Z6($,Z){let J=N("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(M0(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=b(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 J6($,Z){return N("span")}function q6($,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 Q6($,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 Y6($,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=b($.min);if($.max!=null)q.max=b($.max);if($.step!=null)q.step=b($.step);let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=b(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 M0($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function U6($,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 p1($){return(Z,J)=>{let q=N("div",$);return C(Z,q,J),q}}function R1($){return(Z,J)=>{let q=N("span",$);return q.textContent=F(Z.content,J),q}}function e0(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function H6($,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 W6($,Z){let J=N("fieldset","pf-radio-group");if(J.style.border="none",J.style.padding="0",J.style.display="flex",J.style.flexDirection="column",J.style.gap="8px",$.label!=null){let Y=document.createElement("legend");Y.textContent=F($.label,Z),Y.style.fontWeight="500",Y.style.marginBottom="4px",J.appendChild(Y)}C($,J,Z);let q=F($.name,Z),Q=Z.store.get(q);for(let Y of Array.from(J.querySelectorAll('input[type="radio"]')))if(Y.name=q,Q!=null&&Y.value===b(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 G6($,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=b(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 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 X6($,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 B6($,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=b(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 M6($,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=b(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 _6($,Z){let J=N("div","pf-choice-card");if(J.style.padding="16px",J.style.cursor="pointer",J.style.transition="border-color 0.2s",J.dataset.value=F($.value,Z),$.selected===!0)J.dataset.selected="true";if($.label!=null){let q=N("div","pf-choice-card-label");q.textContent=F($.label,Z),q.style.fontWeight="600",J.appendChild(q)}if($.description!=null){let q=N("div","pf-choice-card-description");q.textContent=F($.description,Z),q.style.fontSize="14px",J.appendChild(q)}return C($,J,Z),J}function Z4(){X("Tabs",N6),X("Tab",E6),X("Accordion",z6),X("AccordionItem",K6),X("Dialog",F6),X("Popover",L6),X("Tooltip",D6),X("HoverCard",T6),X("Carousel",O6)}function N6($,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)}`,E=`pf-panel-${Math.random().toString(36).slice(2,8)}`,G=document.createElement("button");G.type="button",G.className="pf-tab-trigger",G.textContent=W.title??`Tab ${H+1}`,G.setAttribute("role","tab"),G.setAttribute("aria-selected",H===0?"true":"false"),G.setAttribute("aria-controls",E),G.id=_,G.tabIndex=H===0?0:-1,G.style.padding="8px 16px",G.style.border="none",G.style.background="none",G.style.cursor="pointer",G.style.borderBottom="2px solid transparent",G.style.marginBottom="-2px",G.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=E,B.tabIndex=0,C(W,B,Z),G.addEventListener("click",()=>{U(H)}),H===0)G.classList.add("pf-tab-active"),G.style.fontWeight="600";Y.push(G),Q.push(B),q.appendChild(G)}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 E6($,Z){let J=N("div","pf-tab");return C($,J,Z),J}function z6($,Z){let J=N("div","pf-accordion");return C($,J,Z),J}function K6($,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 F6($,Z){let J=N("div","pf-dialog-wrapper");if($.trigger!=null){let Y=u($.trigger,Z);Y.addEventListener("click",()=>{q.showModal()}),J.appendChild(Y)}let q=document.createElement("dialog");if(q.className="pf-dialog",q.setAttribute("aria-modal","true"),q.style.maxWidth="500px",q.style.width="100%",q.style.padding="24px",$.title!=null){let Y=N("h2","pf-dialog-title");Y.textContent=F($.title,Z),Y.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,q.setAttribute("aria-labelledby",Y.id),q.appendChild(Y)}if($.description!=null){let Y=N("p","pf-dialog-desc");Y.textContent=F($.description,Z),q.appendChild(Y)}let Q=N("div","pf-dialog-body");if(C($,Q,Z),q.appendChild(Q),$.dismissible!==!1)q.addEventListener("click",(Y)=>{if(Y.target===q)q.close()});return document.addEventListener("prefab:close-overlay",()=>q.close()),J.appendChild(q),J}function L6($,Z){let J=N("div","pf-popover");J.style.position="relative",J.style.display="inline-block";let q=N("div","pf-popover-content");if(q.style.display="none",q.style.position="absolute",q.style.zIndex="50",q.style.padding="12px",q.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",$.title!=null){let Y=N("div","pf-popover-title");Y.textContent=F($.title,Z),Y.style.fontWeight="600",Y.style.marginBottom="4px",q.appendChild(Y)}C($,q,Z);let Q=()=>{q.style.display=q.style.display==="none"?"block":"none"};if($.trigger!=null){let Y=u($.trigger,Z);Y.addEventListener("click",(U)=>{U.stopPropagation(),Q()}),J.appendChild(Y)}else J.addEventListener("click",(Y)=>{if(q.contains(Y.target)&&q.style.display!=="none")return;Q()});return J.appendChild(q),J}function D6($,Z){let J=N("div","pf-tooltip");J.style.position="relative",J.style.display="inline-block";let q=`pf-tip-${Math.random().toString(36).slice(2,8)}`,Q=N("div","pf-tooltip-content");return Q.id=q,Q.setAttribute("role","tooltip"),Q.textContent=F($.content??"",Z),Q.style.display="none",Q.style.position="absolute",Q.style.bottom="100%",Q.style.left="50%",Q.style.transform="translateX(-50%)",Q.style.padding="4px 8px",Q.style.borderRadius="4px",Q.style.color="#fff",Q.style.fontSize="12px",Q.style.whiteSpace="nowrap",Q.style.zIndex="50",C($,J,Z),J.setAttribute("aria-describedby",q),J.addEventListener("mouseenter",()=>{Q.style.display="block"}),J.addEventListener("mouseleave",()=>{Q.style.display="none"}),J.addEventListener("focus",()=>{Q.style.display="block"},!0),J.addEventListener("blur",()=>{Q.style.display="none"},!0),J.appendChild(Q),J}function T6($,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 O6($,Z){let J=N("div","pf-carousel");J.style.position="relative",J.style.overflow="hidden",J.setAttribute("role","region"),J.setAttribute("aria-roledescription","carousel"),J.setAttribute("aria-label",F($.label??"Carousel",Z));let q=N("div","pf-carousel-track");q.style.display="flex",q.style.transition="transform 0.3s ease",C($,q,Z);let Q=0,Y=$.children?.length??0,U=document.createElement("button");U.type="button",U.textContent="‹",U.className="pf-carousel-prev",U.setAttribute("aria-label","Previous slide"),U.style.position="absolute",U.style.left="4px",U.style.top="50%",U.style.transform="translateY(-50%)",U.style.zIndex="10";let H=document.createElement("button");H.type="button",H.textContent="›",H.className="pf-carousel-next",H.setAttribute("aria-label","Next slide"),H.style.position="absolute",H.style.right="4px",H.style.top="50%",H.style.transform="translateY(-50%)",H.style.zIndex="10";let 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 J4(){X("ForEach",I6),X("If",q4),X("Elif",P6),X("Else",R6),X("Condition",V6),X("Define",j6),X("Use",k6),X("Slot",A6)}function I6($,Z){let J=document.createDocumentFragment(),q=$.expression;if(!q)return J;let Q;if(o(q)){let U=t(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 q4($,Z){if(Q4($.condition,Z)){let q=document.createDocumentFragment();if($.children)Y1($.children,q,Z);return q}return document.createDocumentFragment()}function P6($,Z){return q4($,Z)}function R6($,Z){let J=document.createDocumentFragment();if($.children)Y1($.children,J,Z);return J}function Q4($,Z){if(!$)return!1;if(o($))return Boolean(t($,Z.store,Z.scope));return Boolean(Z.store.get($))}function V6($,Z){let J=document.createDocumentFragment(),q=$.cases,Q=$.else;if(q){for(let Y of q)if(Q4(Y.when,Z)){if(Y.children)Y1(Y.children,J,Z);return J}}if(Q)Y1(Q,J,Z);return J}function j6($,Z){let J=$.name;if(J&&$.children)Z.templates=Z.templates??{},Z.templates[J]=$.children;return document.createDocumentFragment()}function k6($,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 A6($,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 Y4(){X("Alert",S6),X("AlertTitle",f6),X("AlertDescription",C6)}function S6($,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 f6($,Z){let J=N("h5","pf-alert-title");return J.textContent=F($.content,Z),J.style.fontWeight="600",J.style.marginBottom="4px",J}function C6($,Z){let J=N("p","pf-alert-description");return J.textContent=F($.content,Z),J.style.fontSize="14px",J}function U4(){X("Image",w6),X("Audio",b6),X("Video",y6),X("Embed",m6),X("Svg",v6),X("DropZone",g6),X("Mermaid",u6)}function w6($,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 b6($,Z){let J=document.createElement("audio");return J.className="pf-audio",J.src=F($.src,Z),J.controls=!0,J}function y6($,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 m6($,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 h6=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 v6($,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 H4(Y),J.appendChild(document.importNode(Y,!0)),J}function H4($){let Z=Array.from($.children);for(let J of Z){if(!h6.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)}H4(J)}}function g6($,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 u6($,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 x6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",p6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",_0=null,c1=null;async function c6(){if(_0)return _0;if(c1)return c1;return c1=import(x6).then(($)=>{let Z=$;return Z.GlobalWorkerOptions.workerSrc=p6,_0=Z,Z}),c1}function G4(){X("PdfViewer",d6)}function d6($,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(_),l6(J,_,{src:q,data:Q,initialPage:Y,zoom:U,showToolbar:H}),J}async function l6($,Z,J){try{let q=await c6(),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=i6(Y.numPages,U,{onPrev:()=>{if(U>1)U--,G()},onNext:()=>{if(U<Y.numPages)U++,G()},onPageChange:(K)=>{let L=Math.max(1,Math.min(K,Y.numPages));if(L!==U)U=L,G()}});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 E=document.createElement("canvas");E.style.display="block",E.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",_.appendChild(E);async function G(){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 P=_.clientHeight-16,A=K/M.width,I=P/M.height;L=Math.min(A,I)}else L=typeof J.zoom==="number"?J.zoom:1;let z=B.getViewport({scale:L});E.width=z.width,E.height=z.height,E.style.width=`${z.width}px`,E.style.height=`${z.height}px`;let T=E.getContext("2d");if(!T)return;if(await B.render({canvasContext:T,viewport:z}).promise,H)H.value=String(U);if(W)W.textContent=`/ ${Y.numPages}`}await G()}catch(q){Z.textContent=`PDF Error: ${q instanceof Error?q.message:String(q)}`,Z.style.color="var(--color-text-danger, #dc2626)"}}function i6($,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 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 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 l1=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function G1($,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 e($,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">${d1(q)}</div>`;for(let z of Q)W+='<div class="pf-chart-tooltip-row">',W+=`<span class="pf-chart-tooltip-dot" style="background:${d1(z.color)}"></span>`,W+=`<span>${d1(z.label)}:</span> <strong>${d1(String(z.value))}</strong>`,W+="</div>";Y.innerHTML=W;let _=U.getBoundingClientRect(),E=H.getBoundingClientRect(),G=U.viewBox.baseVal,B=_.width/(G.width||1),K=_.left-E.left+Z*B,L=Y.offsetWidth||100,M=K+12;if(M+L>E.width)M=K-L-12;Y.style.left=`${Math.max(0,M)}px`,Y.style.top="4px",Y.classList.add("pf-visible")}function d1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function X4($,Z,J,q,Q,Y,U,H){let W=Q.plotWidth/J.length;for(let _=0;_<J.length;_++){let E=Q.plotLeft+_*W,G=document.createElementNS("http://www.w3.org/2000/svg","rect");G.setAttribute("x",String(E)),G.setAttribute("y",String(Q.plotTop)),G.setAttribute("width",String(W)),G.setAttribute("height",String(Q.plotHeight)),G.setAttribute("fill","transparent"),G.style.cursor="default";let B=Y?J[_][Y]:void 0,K=B!=null?H?H(B):b(B):void 0,L=q.map((P,A)=>({label:P.label??P.dataKey,value:U(J[_][P.dataKey],P,A),color:P.color??l1[A%l1.length]})),M=E+W/2,z=()=>e($,M,Q.plotTop,K,L),T=()=>$.tooltip.classList.remove("pf-visible");G.addEventListener("mouseenter",z),G.addEventListener("mouseleave",T),G.addEventListener("touchstart",z,{passive:!0}),G.addEventListener("touchend",T,{passive:!0}),Z.appendChild(G)}}function B4($,Z,J,q,Q,Y,U,H,W,_){let E=J.length===1?Q.plotWidth:Q.plotWidth/(J.length-1);for(let G=0;G<J.length;G++){let B=J.length===1?(Q.plotLeft+Q.plotRight)/2:Q.plotLeft+G/(J.length-1)*Q.plotWidth,K=J.length===1?Q.plotLeft:B-E/2,L=J.length===1?Q.plotWidth:E,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 z=Y?J[G][Y]:void 0,T=z!=null?_?_(z):b(z):void 0,P=q.map((j,f)=>({label:j.label??j.dataKey,value:U(J[G][j.dataKey],j,f),color:j.color??l1[f%l1.length]})),A=()=>{if(e($,B,Q.plotTop,T,P),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[G]?.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)",X1="10";function i1($,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 M4($,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 N0($,Z,J,q,Q){let Y=M4(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":X1,fill:J1});if(W.textContent=K0(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 E0($,Z,J,q){let Q=M4(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=K0(Y,q),$.appendChild(H)}}function z0($,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":X1,fill:J1});W.textContent=H==null?"":Y?Y(H):b(H),$.appendChild(W)}}function s1($,Z){$.appendChild(n("line",{x1:Z.plotLeft,y1:Z.plotBottom,x2:Z.plotRight,y2:Z.plotBottom,stroke:J1,"stroke-width":1}))}function $1($,Z,J){if($==null)return"";let q=d(`{{ __v | ${Z} }}`,{...J,scope:{...J.scope,__v:$}});return b(q??$)}function K0($,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 F0($,Z,J){return(q,Q)=>{if(q===null||q===void 0)return"—";if(Q.tooltipFormat)return $1(q,Q.tooltipFormat,$);let Y=Q.yAxisId==="right"?J:Z;return K0(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 n1($,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 L0($,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 N4(){X("BarChart",s6),X("LineChart",_4),X("AreaChart",_4),X("PieChart",n6),X("RadarChart",o6),X("ScatterChart",r6),X("RadialChart",a6),X("Histogram",t6)}function s6($,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,E=$.xAxis,G=$.tooltipXKey,B=$.xAxisFormat,K=$.tooltipXFormat,L=Q.filter((O)=>O.yAxisId!=="right"),M=Q.filter((O)=>O.yAxisId==="right"),z=W&&M.length>0,T=L.length>0?Math.max(...q.flatMap((O)=>L.map((D)=>Number(O[D.dataKey]??0))),1):1,P=z?Math.max(...q.flatMap((O)=>M.map((D)=>Number(O[D.dataKey]??0))),1):1,A=400,I=i1(A,Y,U,z),j=U1(A,Y,"Bar");if(U)N0(j,I,T,H,q1($));if(z)E0(j,I,P,$.yAxisRightFormat);s1(j,I);let f=I.plotWidth/q.length,S=f/(Q.length+1);for(let O=0;O<q.length;O++)for(let D=0;D<Q.length;D++){let k=Q[D],y=q[O][k.dataKey];if(y===null||y===void 0)continue;let i=k.yAxisId==="right"?P:T,g=Number(y),R=Math.max(0,g/i*I.plotHeight),p=I.plotLeft+O*f+D*S+S/2,V=document.createElementNS("http://www.w3.org/2000/svg","rect");V.setAttribute("x",String(p)),V.setAttribute("y",String(I.plotBottom-R)),V.setAttribute("width",String(S*0.8)),V.setAttribute("height",String(R)),V.setAttribute("fill",k.color??s[D%s.length]),V.setAttribute("rx","2"),j.appendChild(V)}if(E){let O=B?(D)=>$1(D,B,Z):void 0;z0(j,q,E,(D)=>{return I.plotLeft+D*f+f/2},I.plotBottom,O)}if(_){let O=G1(J,j),D=F0(Z,q1($),$.yAxisRightFormat);X4(O,j,q,Q,I,G??E,D,K?(y)=>$1(y,K,Z):void 0)}return M1(J,Q,$.showLegend),J.appendChild(j),J}function _4($,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,E=$.xAxis,G=$.tooltipXKey,B=$.xAxisFormat,K=$.tooltipXFormat,L=Q.filter((D)=>D.yAxisId!=="right"),M=Q.filter((D)=>D.yAxisId==="right"),z=W&&M.length>0,T=L.length>0?Math.max(...q.flatMap((D)=>L.map((k)=>Number(D[k.dataKey]??0))),1):1,P=z?Math.max(...q.flatMap((D)=>M.map((k)=>Number(D[k.dataKey]??0))),1):1,A=400,I=i1(A,Y,U,z),j=U1(A,Y,$.type==="AreaChart"?"Area":"Line"),f=$.type==="AreaChart";if(U)N0(j,I,T,H,q1($));if(z)E0(j,I,P,$.yAxisRightFormat);s1(j,I);let S=[];for(let D=0;D<Q.length;D++){let k=Q[D],y=k.yAxisId==="right",x=y?P:T,i=k.color??s[D%s.length],g=q.map((V,m)=>{let c=V[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,f4=r?I.plotBottom:I.plotBottom-Number(c)/x*I.plotHeight;return{x:H1,y:f4,isNull:r}});if(f){let V=[],m=()=>{if(V.length<2){V=[];return}let c=`M ${V[0].x},${I.plotBottom} `+V.map((H1)=>`L ${H1.x},${H1.y}`).join(" ")+` L ${V[V.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),V=[]};for(let c of g){if(c.isNull){m();continue}V.push(c)}m()}let R="";for(let V of g){if(V.isNull)continue;let m=g.indexOf(V),c=m===0||g[m-1].isNull;R+=`${c?"M":"L"} ${V.x},${V.y} `}if(R){let V=document.createElementNS("http://www.w3.org/2000/svg","path");if(V.setAttribute("d",R.trim()),V.setAttribute("fill","none"),V.setAttribute("stroke",i),V.setAttribute("stroke-width","2"),y)V.setAttribute("stroke-dasharray","6 3");j.appendChild(V)}let p=[];for(let V of g){let m=document.createElementNS("http://www.w3.org/2000/svg","circle");if(m.setAttribute("cx",String(V.x)),m.setAttribute("cy",String(V.y)),m.setAttribute("r","4"),m.setAttribute("fill",i),m.setAttribute("class","pf-data-dot"),m.setAttribute("data-visible","false"),m.style.pointerEvents="none",V.isNull)m.style.display="none";j.appendChild(m),p.push(m)}S.push(p)}let O=document.createElementNS("http://www.w3.org/2000/svg","line");if(O.setAttribute("class","pf-crosshair"),O.setAttribute("x1",String(I.plotLeft)),O.setAttribute("x2",String(I.plotLeft)),O.setAttribute("y1",String(I.plotTop)),O.setAttribute("y2",String(I.plotBottom)),O.setAttribute("stroke",J1),O.setAttribute("stroke-width","1"),O.setAttribute("stroke-dasharray","3 3"),O.setAttribute("opacity","0"),j.appendChild(O),E){let D=B?(k)=>$1(k,B,Z):void 0;z0(j,q,E,(k)=>{return q.length===1?(I.plotLeft+I.plotRight)/2:I.plotLeft+k/(q.length-1)*I.plotWidth},I.plotBottom,D)}if(_){let D=G1(J,j),k=F0(Z,q1($),$.yAxisRightFormat);B4(D,j,q,Q,I,G??E,k,O,S,K?(x)=>$1(x,K,Z):void 0)}return M1(J,Q,$.showLegend),J.appendChild(j),J}function n6($,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,E=Q.length>0?Q:W?[{dataKey:W,label:W}]:[];if(q.length===0||!W)return J.textContent="No chart data",J;let G=U1(U,U,"Pie"),B=U/2,K=U/2,L=U/2-10,M=$.tooltipXFormat,z=q1($),T=(f)=>z?$1(f,z,Z):String(f),P=q.map((f)=>Number(f[W]??0)),A=P.reduce((f,S)=>f+S,0);if(A===0)return J.textContent="No chart data",J.appendChild(G),J;let I=H?G1(J,G):void 0,j=-Math.PI/2;for(let f=0;f<P.length;f++){let S=P[f]/A*2*Math.PI,O=j+S,D=S>Math.PI?1:0,k=B+L*Math.cos(j),y=K+L*Math.sin(j),x=B+L*Math.cos(O),i=K+L*Math.sin(O),g=s[f%s.length],R=document.createElementNS("http://www.w3.org/2000/svg","path");if(R.setAttribute("d",`M ${B},${K} L ${k},${y} A ${L},${L} 0 ${D} 1 ${x},${i} Z`),R.setAttribute("fill",g),R.style.cursor="default",I){let p=_?q[f][_]:void 0,V=p!=null?M?$1(p,M,Z):b(p):`Slice ${f+1}`,m=`${(P[f]/A*100).toFixed(1)}%`,c=j+S/2,r=B+L*0.6*Math.cos(c);R.addEventListener("mouseenter",()=>{e(I,r,K,V,[{label:E[0].label??W,value:`${T(P[f])} (${m})`,color:g}])}),R.addEventListener("mouseleave",()=>{I.tooltip.classList.remove("pf-visible")}),R.addEventListener("touchstart",()=>{e(I,r,K,V,[{label:E[0].label??W,value:`${T(P[f])} (${m})`,color:g}])},{passive:!0}),R.addEventListener("touchend",()=>{I.tooltip.classList.remove("pf-visible")},{passive:!0})}G.appendChild(R),j=O}return M1(J,E,$.showLegend),J.appendChild(G),J}function r6($,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,E=$.showTooltip!==!1,G=H[0]?.color??s[0],B=q1($),K=(R)=>B?$1(R,B,Z):String(Math.round(R*100)/100),L=q.map((R)=>Number(R[Q]??0)),M=q.map((R)=>Number(R[Y]??0)),z=Math.min(...L),T=Math.max(...L),P=Math.min(...M),A=Math.max(...M),I=T-z||1,j=A-P||1,f=U?q.map((R)=>Number(R[U]??0)):[],S=U?Math.max(...f,1):1,O=400,D=i1(O,W,!0),k=U1(O,W,"Scatter"),y=(R)=>D.plotLeft+(R-z)/I*D.plotWidth,x=(R)=>D.plotBottom-(R-P)/j*D.plotHeight,i=4;for(let R=0;R<=i;R++){let p=P+j*R/i,V=x(p);if(k.appendChild(n1({x:D.plotLeft-6,y:V+3,"text-anchor":"end","font-size":X1,fill:J1},K(p))),_&&R>0)k.appendChild(n("line",{x1:D.plotLeft,y1:V,x2:D.plotRight,y2:V,stroke:z1,"stroke-width":1,"stroke-dasharray":"4 3"}))}s1(k,D);for(let R of[z,(z+T)/2,T])k.appendChild(n1({x:y(R),y:D.plotBottom+14,"text-anchor":"middle","font-size":X1,fill:J1},String(Math.round(R*100)/100)));let g=E?G1(J,k):void 0;for(let R=0;R<q.length;R++){let p=y(L[R]),V=x(M[R]),m=U?4+Math.sqrt(f[R]/S)*14:4,c=n("circle",{cx:p,cy:V,r:m,fill:G,"fill-opacity":U?0.6:0.85});if(g){let r=[{label:Q,value:K(L[R]),color:G},{label:Y,value:K(M[R]),color:G},...U?[{label:U,value:K(f[R]),color:G}]:[]],H1=H[0]?.label??"Point";c.addEventListener("mouseenter",()=>e(g,p,V,H1,r)),c.addEventListener("mouseleave",()=>g.tooltip.classList.remove("pf-visible")),c.addEventListener("touchstart",()=>e(g,p,V,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 a6($,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,E=W/2,G=W/2-10,B=Math.max(0,Math.min($.innerRadius??30,G-10)),K=$.startAngle??180,L=$.endAngle??0,M=$.showTooltip!==!1,z=q.map((D)=>Number(D[Y]??0)),T=Math.max(...z,1),P=U1(W,W,"Radial"),A=(G-B)/q.length,I=Math.max(2,A*0.7),j=q1($),f=(D)=>j?$1(D,j,Z):String(D),S=M?G1(J,P):void 0,O=[];for(let D=0;D<q.length;D++){let k=G-A*D-A/2,y=Q[D]?.color??s[D%s.length],x=z[D]/T,i=K+x*(L-K),g=U?q[D][U]:null,R=g!=null?b(g):Q[D]?.label??Y;O.push({dataKey:R||Y,label:R||Y,color:y}),P.appendChild(n("path",{d:L0(_,E,k,K,L),fill:"none",stroke:z1,"stroke-width":I,"stroke-linecap":"round"}));let p=n("path",{d:L0(_,E,k,K,i),fill:"none",stroke:y,"stroke-width":I,"stroke-linecap":"round"});if(S){let V=B1(_,E,k,(K+i)/2),m=[{label:Y,value:f(z[D]),color:y}],c=R||Y;p.addEventListener("mouseenter",()=>e(S,V.x,V.y,c,m)),p.addEventListener("mouseleave",()=>S.tooltip.classList.remove("pf-visible")),p.addEventListener("touchstart",()=>e(S,V.x,V.y,c,m),{passive:!0}),p.addEventListener("touchend",()=>S.tooltip.classList.remove("pf-visible"),{passive:!0})}P.appendChild(p)}return M1(J,O,$.showLegend),J.appendChild(P),J}function o6($,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,E=$.showTooltip!==!1,G=Math.min(U,320),B=G/2,K=G/2,L=G/2-24,M=q.length,z=Math.max(...q.flatMap((S)=>Q.map((O)=>Number(S[O.dataKey]??0))),1),T=(S)=>90-360*S/M,P=(S)=>S.map((O)=>`${O.x.toFixed(1)},${O.y.toFixed(1)}`).join(" "),A=U1(G,G,"Radar");if(_){for(let O=1;O<=4;O++){let D=L*O/4,k=Array.from({length:M},(y,x)=>B1(B,K,D,T(x)));A.appendChild(n("polygon",{points:P(k),fill:"none",stroke:z1,"stroke-width":1}))}for(let O=0;O<M;O++){let D=B1(B,K,L,T(O));A.appendChild(n("line",{x1:B,y1:K,x2:D.x,y2:D.y,stroke:z1,"stroke-width":1}))}}for(let S=0;S<M;S++){let O=B1(B,K,L+12,T(S)),D=Y?q[S][Y]:null;A.appendChild(n1({x:O.x,y:O.y+3,"text-anchor":"middle","font-size":X1,fill:J1},D!=null?String(D):""))}let I=E?G1(J,A):void 0,j=q1($),f=(S)=>j?$1(S,j,Z):String(S);for(let S=0;S<Q.length;S++){let O=Q[S],D=O.color??s[S%s.length],k=q.map((y,x)=>B1(B,K,Number(y[O.dataKey]??0)/z*L,T(x)));if(A.appendChild(n("polygon",{points:P(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?b(i):O.label??O.dataKey,R=[{label:O.label??O.dataKey,value:f(Number(q[y][O.dataKey]??0)),color:D}];x.addEventListener("mouseenter",()=>e(I,k[y].x,k[y].y,g,R)),x.addEventListener("mouseleave",()=>I.tooltip.classList.remove("pf-visible")),x.addEventListener("touchstart",()=>e(I,k[y].x,k[y].y,g,R),{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 t6($,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),E=(Math.max(...Q)-W)/Y||1,G=Array(Y).fill(0);for(let T of Q){let P=Math.min(Math.floor((T-W)/E),Y-1);G[P]++}let B=Math.max(...G),K=300,L=U,M=K/Y,z=U1(K,L,"Histogram");for(let T=0;T<Y;T++){let P=B>0?G[T]/B*L:0,A=document.createElementNS("http://www.w3.org/2000/svg","rect");A.setAttribute("x",String(T*M)),A.setAttribute("y",String(L-P)),A.setAttribute("width",String(M-1)),A.setAttribute("height",String(P)),A.setAttribute("fill",H),z.appendChild(A)}return J.appendChild(z),J}function E4(){X("Table",e6),X("TableHead",D0("thead")),X("TableBody",D0("tbody")),X("TableFooter",D0("tfoot")),X("TableRow",$5),X("TableHeader",Z5),X("TableCell",J5),X("TableCaption",q5),X("ExpandableRow",Q5)}function e6($,Z){let J=document.createElement("table");return J.className="pf-table",J.style.width="100%",J.style.borderCollapse="collapse",C($,J,Z),J}function D0($){return(Z,J)=>{let q=document.createElement($);return q.className=`pf-${$}`,C(Z,q,J),q}}function $5($,Z){let J=document.createElement("tr");return J.className="pf-table-row",C($,J,Z),J}function Z5($,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 J5($,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 q5($,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 Q5($,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",C($,U,Z);let H=!1;return q.addEventListener("click",()=>{H=!H,U.style.display=H?"block":"none",Q.style.transform=H?"rotate(90deg)":""}),J.appendChild(q),J.appendChild(U),J}var z4=!1;function r1(){if(z4)return;z4=!0,d0(),n0(),o0(),t0(),$4(),Z4(),J4(),Y4(),U4(),G4(),N4(),E4()}function O0($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function I0($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function T0($,Z=" "){return Object.entries($).map(([J,q])=>`${Z}--${O0(J)}: ${I0(q)};`).join(`
|
|
7
|
-
`)}function
|
|
8
|
-
${
|
|
9
|
-
}`);if($.dark&&Object.keys($.dark).length>0){let J=
|
|
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(P1(Z[q])),q++;q++;let X=H?` data-language="${P1(H)}"`:"";J.push(`<pre class="pf-code"><code${X}>${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}>${c1(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>${a0(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>${c1(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>${c1(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(c1).join("<br />")}</p>`)}return J.join(`
|
|
6
|
+
`)}function g8($,Z){let J=document.createElement("kbd");return J.className="pf-kbd",J.textContent=D($.content,Z),J}function t0(){B("Card",u8),B("CardHeader",M0("pf-card-header")),B("CardTitle",o0("pf-card-title","h3")),B("CardDescription",o0("pf-card-description","p")),B("CardContent",M0("pf-card-content")),B("CardFooter",M0("pf-card-footer"))}function u8($,Z){let J=N("div","pf-card");return J.style.overflow="hidden",C($,J,Z),J}function M0($){return(Z,J)=>{let q=N("div",$);return q.style.padding="16px 24px",C(Z,q,J),q}}function o0($,Z){return(J,q)=>{let Q=document.createElement(Z);return Q.className=$,Q.textContent=D(J.content,q),Q}}function e0(){B("DataTable",x8),B("Badge",c8),B("Dot",p8),B("Metric",d8),B("Ring",l8),B("Progress",i8),B("Separator",s8),B("Loader",n8),B("Icon",r8),B("Sparkline",a8)}function x8($,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,W=document.createElement("thead"),X=document.createElement("tr");for(let G of Q){let E=document.createElement("th");E.className="pf-datatable-th",E.textContent=G.header??G.key,E.style.padding="8px 12px",E.style.textAlign="left",X.appendChild(E)}W.appendChild(X),q.appendChild(W);let M=document.createElement("tbody");if(Array.isArray(Y)){let G=H!=null?l(H,Z):void 0;for(let E of Y){let z=document.createElement("tr");z.className="pf-datatable-row";let F=E,_=E===null||typeof E!=="object";if(U&&G!=null&&F[U]!=null&&b(F[U])===b(G))z.classList.add("pf-datatable-row-selected");if($.onRowClick!=null&&U)z.style.cursor="pointer",z.addEventListener("click",()=>{let K={...Z.scope,$item:F,$index:Y.indexOf(E)},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 P;if(K.accessor)P=l(`{{ $item.${K.accessor} }}`,{...Z,scope:{...Z.scope,$item:F}});else if(P=_?E:F[K.key],K.format&&P!=null)P=l(`{{ __fmtVal | ${K.format} }}`,{...Z,scope:{...Z.scope,__fmtVal:P}});T.textContent=b(P),T.style.padding="8px 12px",z.appendChild(T)}M.appendChild(z)}}if(q.appendChild(M),$.search===!0){let G=document.createElement("input");G.type="text",G.placeholder="Search...",G.className="pf-datatable-search",G.style.marginBottom="8px",G.style.padding="6px 12px",G.style.width="100%",G.style.boxSizing="border-box",G.addEventListener("input",()=>{let E=G.value.toLowerCase(),z=Array.from(M.querySelectorAll("tr"));for(let F of z){let _=(F.textContent??"").toLowerCase();F.style.display=_.includes(E)?"":"none"}}),J.appendChild(G)}return J.appendChild(q),J}function c8($,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),o8(J,q),J}function p8($,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 d8($,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 l8($,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,W=2*Math.PI*H,X=W*(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 G=document.createElementNS("http://www.w3.org/2000/svg","circle");G.setAttribute("cx",String(q/2)),G.setAttribute("cy",String(q/2)),G.setAttribute("r",String(H)),G.setAttribute("fill","none"),G.setAttribute("stroke","var(--muted, #e5e7eb)"),G.setAttribute("stroke-width",String(Q));let E=document.createElementNS("http://www.w3.org/2000/svg","circle");if(E.setAttribute("cx",String(q/2)),E.setAttribute("cy",String(q/2)),E.setAttribute("r",String(H)),E.setAttribute("fill","none"),E.setAttribute("stroke","var(--primary, #3b82f6)"),E.setAttribute("stroke-width",String(Q)),E.setAttribute("stroke-dasharray",String(W)),E.setAttribute("stroke-dashoffset",String(X)),E.setAttribute("stroke-linecap","round"),E.style.transform="rotate(-90deg)",E.style.transformOrigin="center",M.appendChild(G),M.appendChild(E),J.appendChild(M),$.label!=null){let z=N("div","pf-ring-label");z.textContent=D($.label,Z),z.style.textAlign="center",z.style.fontSize="12px",J.appendChild(z)}return J}function i8($,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 s8($,Z){let J=document.createElement("hr");return J.className="pf-separator",J.style.border="none",J.style.margin="8px 0",J}function n8($,Z){let J=N("div","pf-loader");return J.textContent="⏳",J.style.display="flex",J.style.justifyContent="center",J.style.padding="16px",J}function r8($,Z){let J=N("span","pf-icon");return J.setAttribute("data-icon",D($.name??$.content,Z)),J}function a8($,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),W=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,G=q.map((z,F)=>{let _=F/M*Q,K=Y-(z-H)/W*(Y-4)-2;return`${_},${K}`}).join(" "),E=document.createElementNS("http://www.w3.org/2000/svg","polyline");return E.setAttribute("points",G),E.setAttribute("fill","none"),E.setAttribute("stroke","var(--primary, #3b82f6)"),E.setAttribute("stroke-width","1.5"),X.appendChild(E),J.appendChild(X),J}function o8($,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 Z4(){B("Form",t8),B("Input",e8),B("Textarea",R1($6)),B("Button",Z6),B("ButtonGroup",J6),B("Select",R1(q6)),B("SelectOption",Q6),B("SelectGroup",p1("pf-select-group")),B("SelectLabel",V1("pf-select-label")),B("SelectSeparator",$4),B("Checkbox",Y6),B("Switch",U6),B("Slider",R1(H6)),B("Radio",G6),B("RadioGroup",X6),B("Combobox",R1(B6)),B("ComboboxOption",M6),B("ComboboxGroup",p1("pf-combobox-group")),B("ComboboxLabel",V1("pf-combobox-label")),B("ComboboxSeparator",$4),B("Calendar",_6),B("DatePicker",R1(N6)),B("Field",p1("pf-field")),B("FieldTitle",V1("pf-field-title")),B("FieldDescription",V1("pf-field-description")),B("FieldContent",p1("pf-field-content")),B("FieldError",V1("pf-field-error")),B("ChoiceCard",E6)}function t8($,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 J4($,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 R1($){return(Z,J)=>{let q=$(Z,J);return q.style.display="flex",q.style.flexDirection="column",q.style.gap="4px",J4(q,Z,J),q}}function e8($,Z){let J=N("div","pf-input-wrapper");J.style.display="flex",J.style.flexDirection="column",J.style.gap="4px",J4(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=b(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 _0(q),J.appendChild(q),J}function $6($,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=b(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 _0(q),J.appendChild(q),J}function Z6($,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),W6(J,q),$.size!=null)J.setAttribute("data-size",$.size);if($.disabled===!0)J.disabled=!0;return J}function J6($,Z){let J=N("div","pf-button-group");return J.style.display="flex",J.style.gap="8px",C($,J,Z),J}function q6($,Z){let J=N("div","pf-select-wrapper"),q=document.createElement("select");if(q.className="pf-select",$.name!=null)q.name=$.name;if(_0(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=b(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 Q6($,Z){return N("span")}function Y6($,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 U6($,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 H6($,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=b($.min);if($.max!=null)q.max=b($.max);if($.step!=null)q.step=b($.step);let Q=$.name;if(Q){let Y=Z.store.get(Q);if(Y!=null)q.value=b(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 _0($){$.style.padding="8px 12px",$.style.fontSize="14px",$.style.width="100%",$.style.boxSizing="border-box"}function W6($,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 p1($){return(Z,J)=>{let q=N("div",$);return C(Z,q,J),q}}function V1($){return(Z,J)=>{let q=N("span",$);return q.textContent=D(Z.content,J),q}}function $4(){let $=document.createElement("hr");return $.className="pf-separator",$.style.border="none",$.style.margin="4px 0",$}function G6($,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 X6($,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===b(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 B6($,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=b(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 W of Array.from(U.querySelectorAll(".pf-combobox-option"))){let X=(W.textContent??"").toLowerCase();W.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 M6($,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 _6($,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=b(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 N6($,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=b(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 E6($,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 q4(){B("Tabs",z6),B("Tab",K6),B("Accordion",F6),B("AccordionItem",D6),B("Dialog",L6),B("Popover",T6),B("Tooltip",O6),B("HoverCard",I6),B("Carousel",P6)}function z6($,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((G)=>G.title===X);return M>=0?M:0}return 0})();if($.children)for(let X=0;X<$.children.length;X++){let M=$.children[X],G=`pf-tab-${Math.random().toString(36).slice(2,8)}`,E=`pf-panel-${Math.random().toString(36).slice(2,8)}`,z=document.createElement("button");z.type="button",z.className="pf-tab-trigger",z.textContent=M.title??`Tab ${X+1}`,z.setAttribute("role","tab"),z.setAttribute("aria-selected",X===H?"true":"false"),z.setAttribute("aria-controls",E),z.id=G,z.tabIndex=X===H?0:-1,z.style.padding="8px 16px",z.style.border="none",z.style.background="none",z.style.cursor="pointer",z.style.borderBottom="2px solid transparent",z.style.marginBottom="-2px",z.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",G),F.id=E,F.tabIndex=0,C(M,F,Z),z.addEventListener("click",()=>{W(X)}),X===H)z.classList.add("pf-tab-active"),z.style.fontWeight="600";Y.push(z),Q.push(F),q.appendChild(z)}function W(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 G;if(X.key==="ArrowRight")G=(M+1)%Y.length;else if(X.key==="ArrowLeft")G=(M-1+Y.length)%Y.length;else if(X.key==="Home")G=0;else if(X.key==="End")G=Y.length-1;else return;X.preventDefault(),W(G)}),J.appendChild(q);for(let X of Q)J.appendChild(X);return J}function K6($,Z){let J=N("div","pf-tab");return C($,J,Z),J}function F6($,Z){let J=N("div","pf-accordion");return C($,J,Z),J}function D6($,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 L6($,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 T6($,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 O6($,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 I6($,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 P6($,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 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 Q4(){B("ForEach",R6),B("If",Y4),B("Elif",V6),B("Else",j6),B("Condition",k6),B("Define",A6),B("Use",S6),B("Slot",f6)}function R6($,Z){let J=document.createDocumentFragment(),q=$.expression;if(!q)return J;let Q;if(o(q)){let U=t(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},X={...Z,scope:W};if($.children)Y1($.children,J,X)}return J}function Y4($,Z){if(U4($.condition,Z)){let q=document.createDocumentFragment();if($.children)Y1($.children,q,Z);return q}return document.createDocumentFragment()}function V6($,Z){return Y4($,Z)}function j6($,Z){let J=document.createDocumentFragment();if($.children)Y1($.children,J,Z);return J}function U4($,Z){if(!$)return!1;if(o($))return Boolean(t($,Z.store,Z.scope));return Boolean(Z.store.get($))}function k6($,Z){let J=document.createDocumentFragment(),q=$.cases,Q=$.else;if(q){for(let Y of q)if(U4(Y.when,Z)){if(Y.children)Y1(Y.children,J,Z);return J}}if(Q)Y1(Q,J,Z);return J}function A6($,Z){let J=$.name;if(J&&$.children)Z.templates=Z.templates??{},Z.templates[J]=$.children;return document.createDocumentFragment()}function S6($,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 X of Q)J.appendChild(u(X,W));return J}function f6($,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 H4(){B("Alert",C6),B("AlertTitle",w6),B("AlertDescription",b6)}function C6($,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 w6($,Z){let J=N("h5","pf-alert-title");return J.textContent=D($.content,Z),J.style.fontWeight="600",J.style.marginBottom="4px",J}function b6($,Z){let J=N("p","pf-alert-description");return J.textContent=D($.content,Z),J.style.fontSize="14px",J}function W4(){B("Image",y6),B("Audio",m6),B("Video",h6),B("Embed",v6),B("Svg",u6),B("DropZone",c6),B("Mermaid",p6)}function y6($,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 m6($,Z){let J=document.createElement("audio");return J.className="pf-audio",J.src=D($.src,Z),J.controls=!0,J}function h6($,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 v6($,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 g6=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 u6($,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(!g6.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 x6($,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 c6($,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((W)=>x6(W,$.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 p6($,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 d6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",l6="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",N0=null,d1=null;async function i6(){if(N0)return N0;if(d1)return d1;return d1=import(d6).then(($)=>{let Z=$;return Z.GlobalWorkerOptions.workerSrc=l6,N0=Z,Z}),d1}function B4(){B("PdfViewer",s6)}function s6($,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,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 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),n6(J,X,{src:q,data:Q,initialPage:Y,zoom:U,showToolbar:H}),J}async function n6($,Z,J){try{let q=await i6(),Q;if(J.src)Q={url:J.src};else if(J.data){let E=atob(J.data),z=new Uint8Array(E.length);for(let F=0;F<E.length;F++)z[F]=E.charCodeAt(F);Q={data:z}}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 E=r6(Y.numPages,U,{onPrev:()=>{if(U>1)U--,G()},onNext:()=>{if(U<Y.numPages)U++,G()},onPageChange:(z)=>{let F=Math.max(1,Math.min(z,Y.numPages));if(F!==U)U=F,G()}});H=E.pageInput,W=E.pageCount,$.insertBefore(E.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 G(){let E=await Y.getPage(U),z=X.clientWidth-16,F,_=E.getViewport({scale:1});if(J.zoom==="fit-width")F=z/_.width;else if(J.zoom==="fit-page"){let P=X.clientHeight-16,A=z/_.width,I=P/_.height;F=Math.min(A,I)}else F=typeof J.zoom==="number"?J.zoom:1;let K=E.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 E.render({canvasContext:T,viewport:K}).promise,H)H.value=String(U);if(W)W.textContent=`/ ${Y.numPages}`}await G()}catch(q){Z.textContent=`PDF Error: ${q instanceof Error?q.message:String(q)}`,Z.style.color="var(--color-text-danger, #dc2626)"}}function r6($,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",X4(Q),Q.addEventListener("click",J.onPrev);let Y=document.createElement("button");Y.textContent="›",Y.title="Next page",Y.className="pf-pdf-btn",X4(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 X4($){$.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 i1=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function G1($,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 e($,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">${l1(q)}</div>`;for(let K of Q)W+='<div class="pf-chart-tooltip-row">',W+=`<span class="pf-chart-tooltip-dot" style="background:${l1(K.color)}"></span>`,W+=`<span>${l1(K.label)}:</span> <strong>${l1(String(K.value))}</strong>`,W+="</div>";Y.innerHTML=W;let X=U.getBoundingClientRect(),M=H.getBoundingClientRect(),G=U.viewBox.baseVal,E=X.width/(G.width||1),z=X.left-M.left+Z*E,F=Y.offsetWidth||100,_=z+12;if(_+F>M.width)_=z-F-12;Y.style.left=`${Math.max(0,_)}px`,Y.style.top="4px",Y.classList.add("pf-visible")}function l1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function M4($,Z,J,q,Q,Y,U,H){let W=Q.plotWidth/J.length;for(let X=0;X<J.length;X++){let M=Q.plotLeft+X*W,G=document.createElementNS("http://www.w3.org/2000/svg","rect");G.setAttribute("x",String(M)),G.setAttribute("y",String(Q.plotTop)),G.setAttribute("width",String(W)),G.setAttribute("height",String(Q.plotHeight)),G.setAttribute("fill","transparent"),G.style.cursor="default";let E=Y?J[X][Y]:void 0,z=E!=null?H?H(E):b(E):void 0,F=q.map((P,A)=>({label:P.label??P.dataKey,value:U(J[X][P.dataKey],P,A),color:P.color??i1[A%i1.length]})),_=M+W/2,K=()=>e($,_,Q.plotTop,z,F),T=()=>$.tooltip.classList.remove("pf-visible");G.addEventListener("mouseenter",K),G.addEventListener("mouseleave",T),G.addEventListener("touchstart",K,{passive:!0}),G.addEventListener("touchend",T,{passive:!0}),Z.appendChild(G)}}function _4($,Z,J,q,Q,Y,U,H,W,X){let M=J.length===1?Q.plotWidth:Q.plotWidth/(J.length-1);for(let G=0;G<J.length;G++){let E=J.length===1?(Q.plotLeft+Q.plotRight)/2:Q.plotLeft+G/(J.length-1)*Q.plotWidth,z=J.length===1?Q.plotLeft:E-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,z))),_.setAttribute("y",String(Q.plotTop)),_.setAttribute("width",String(Math.min(F,Q.plotRight-Math.max(Q.plotLeft,z)))),_.setAttribute("height",String(Q.plotHeight)),_.setAttribute("fill","transparent"),_.style.cursor="default";let K=Y?J[G][Y]:void 0,T=K!=null?X?X(K):b(K):void 0,P=q.map((j,f)=>({label:j.label??j.dataKey,value:U(J[G][j.dataKey],j,f),color:j.color??i1[f%i1.length]})),A=()=>{if(e($,E,Q.plotTop,T,P),H)H.setAttribute("x1",String(E)),H.setAttribute("x2",String(E)),H.setAttribute("opacity","1");if(W)for(let j of W){for(let f of j)f.setAttribute("data-visible","false");j[G]?.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")};_.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 s1($,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 N4($,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 E0($,Z,J,q,Q){let Y=N4(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":X1,fill:J1});if(W.textContent=F0(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 z0($,Z,J,q){let Q=N4(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=F0(Y,q),$.appendChild(H)}}function K0($,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":X1,fill:J1});W.textContent=H==null?"":Y?Y(H):b(H),$.appendChild(W)}}function n1($,Z){$.appendChild(n("line",{x1:Z.plotLeft,y1:Z.plotBottom,x2:Z.plotRight,y2:Z.plotBottom,stroke:J1,"stroke-width":1}))}function $1($,Z,J){if($==null)return"";let q=l(`{{ __v | ${Z} }}`,{...J,scope:{...J.scope,__v:$}});return b(q??$)}function F0($,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 D0($,Z,J){return(q,Q)=>{if(q===null||q===void 0)return"—";if(Q.tooltipFormat)return $1(q,Q.tooltipFormat,$);let Y=Q.yAxisId==="right"?J:Z;return F0(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 r1($,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 L0($,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 z4(){B("BarChart",a6),B("LineChart",E4),B("AreaChart",E4),B("PieChart",o6),B("RadarChart",$5),B("ScatterChart",t6),B("RadialChart",e6),B("Histogram",Z5)}function a6($,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,W=$.showYAxisRight===!0,X=$.showTooltip!==!1,M=$.xAxis,G=$.tooltipXKey,E=$.xAxisFormat,z=$.tooltipXFormat,F=Q.filter((O)=>O.yAxisId!=="right"),_=Q.filter((O)=>O.yAxisId==="right"),K=W&&_.length>0,T=F.length>0?Math.max(...q.flatMap((O)=>F.map((L)=>Number(O[L.dataKey]??0))),1):1,P=K?Math.max(...q.flatMap((O)=>_.map((L)=>Number(O[L.dataKey]??0))),1):1,A=400,I=s1(A,Y,U,K),j=U1(A,Y,"Bar");if(U)E0(j,I,T,H,q1($));if(K)z0(j,I,P,$.yAxisRightFormat);n1(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"?P:T,g=Number(y),R=Math.max(0,g/i*I.plotHeight),c=I.plotLeft+O*f+L*S+S/2,V=document.createElementNS("http://www.w3.org/2000/svg","rect");V.setAttribute("x",String(c)),V.setAttribute("y",String(I.plotBottom-R)),V.setAttribute("width",String(S*0.8)),V.setAttribute("height",String(R)),V.setAttribute("fill",k.color??s[L%s.length]),V.setAttribute("rx","2"),j.appendChild(V)}if(M){let O=E?(L)=>$1(L,E,Z):void 0;K0(j,q,M,(L)=>{return I.plotLeft+L*f+f/2},I.plotBottom,O)}if(X){let O=G1(J,j),L=D0(Z,q1($),$.yAxisRightFormat);M4(O,j,q,Q,I,G??M,L,z?(y)=>$1(y,z,Z):void 0)}return M1(J,Q,$.showLegend),J.appendChild(j),J}function E4($,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,W=$.showYAxisRight===!0,X=$.showTooltip!==!1,M=$.xAxis,G=$.tooltipXKey,E=$.xAxisFormat,z=$.tooltipXFormat,F=Q.filter((L)=>L.yAxisId!=="right"),_=Q.filter((L)=>L.yAxisId==="right"),K=W&&_.length>0,T=F.length>0?Math.max(...q.flatMap((L)=>F.map((k)=>Number(L[k.dataKey]??0))),1):1,P=K?Math.max(...q.flatMap((L)=>_.map((k)=>Number(L[k.dataKey]??0))),1):1,A=400,I=s1(A,Y,U,K),j=U1(A,Y,$.type==="AreaChart"?"Area":"Line"),f=$.type==="AreaChart";if(U)E0(j,I,T,H,q1($));if(K)z0(j,I,P,$.yAxisRightFormat);n1(j,I);let S=[];for(let L=0;L<Q.length;L++){let k=Q[L],y=k.yAxisId==="right",x=y?P:T,i=k.color??s[L%s.length],g=q.map((V,h)=>{let p=V[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,w4=r?I.plotBottom:I.plotBottom-Number(p)/x*I.plotHeight;return{x:H1,y:w4,isNull:r}});if(f){let V=[],h=()=>{if(V.length<2){V=[];return}let p=`M ${V[0].x},${I.plotBottom} `+V.map((H1)=>`L ${H1.x},${H1.y}`).join(" ")+` L ${V[V.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),V=[]};for(let p of g){if(p.isNull){h();continue}V.push(p)}h()}let R="";for(let V of g){if(V.isNull)continue;let h=g.indexOf(V),p=h===0||g[h-1].isNull;R+=`${p?"M":"L"} ${V.x},${V.y} `}if(R){let V=document.createElementNS("http://www.w3.org/2000/svg","path");if(V.setAttribute("d",R.trim()),V.setAttribute("fill","none"),V.setAttribute("stroke",i),V.setAttribute("stroke-width","2"),y)V.setAttribute("stroke-dasharray","6 3");j.appendChild(V)}let c=[];for(let V of g){let h=document.createElementNS("http://www.w3.org/2000/svg","circle");if(h.setAttribute("cx",String(V.x)),h.setAttribute("cy",String(V.y)),h.setAttribute("r","4"),h.setAttribute("fill",i),h.setAttribute("class","pf-data-dot"),h.setAttribute("data-visible","false"),h.style.pointerEvents="none",V.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=E?(k)=>$1(k,E,Z):void 0;K0(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=G1(J,j),k=D0(Z,q1($),$.yAxisRightFormat);_4(L,j,q,Q,I,G??M,k,O,S,z?(x)=>$1(x,z,Z):void 0)}return M1(J,Q,$.showLegend),J.appendChild(j),J}function o6($,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,W=$.dataKey??Q[0]?.dataKey,X=$.nameKey??$.tooltipXKey??$.xAxis,M=Q.length>0?Q:W?[{dataKey:W,label:W}]:[];if(q.length===0||!W)return J.textContent="No chart data",J;let G=U1(U,U,"Pie"),E=U/2,z=U/2,F=U/2-10,_=$.tooltipXFormat,K=q1($),T=(f)=>K?$1(f,K,Z):String(f),P=q.map((f)=>Number(f[W]??0)),A=P.reduce((f,S)=>f+S,0);if(A===0)return J.textContent="No chart data",J.appendChild(G),J;let I=H?G1(J,G):void 0,j=-Math.PI/2;for(let f=0;f<P.length;f++){let S=P[f]/A*2*Math.PI,O=j+S,L=S>Math.PI?1:0,k=E+F*Math.cos(j),y=z+F*Math.sin(j),x=E+F*Math.cos(O),i=z+F*Math.sin(O),g=s[f%s.length],R=document.createElementNS("http://www.w3.org/2000/svg","path");if(R.setAttribute("d",`M ${E},${z} L ${k},${y} A ${F},${F} 0 ${L} 1 ${x},${i} Z`),R.setAttribute("fill",g),R.style.cursor="default",I){let c=X?q[f][X]:void 0,V=c!=null?_?$1(c,_,Z):b(c):`Slice ${f+1}`,h=`${(P[f]/A*100).toFixed(1)}%`,p=j+S/2,r=E+F*0.6*Math.cos(p);R.addEventListener("mouseenter",()=>{e(I,r,z,V,[{label:M[0].label??W,value:`${T(P[f])} (${h})`,color:g}])}),R.addEventListener("mouseleave",()=>{I.tooltip.classList.remove("pf-visible")}),R.addEventListener("touchstart",()=>{e(I,r,z,V,[{label:M[0].label??W,value:`${T(P[f])} (${h})`,color:g}])},{passive:!0}),R.addEventListener("touchend",()=>{I.tooltip.classList.remove("pf-visible")},{passive:!0})}G.appendChild(R),j=O}return M1(J,M,$.showLegend),J.appendChild(G),J}function t6($,Z){let J=N("div","pf-chart pf-scatter-chart"),q=l($.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 X=$.showGrid!==!1,M=$.showTooltip!==!1,G=H[0]?.color??s[0],E=q1($),z=(R)=>E?$1(R,E,Z):String(Math.round(R*100)/100),F=q.map((R)=>Number(R[Q]??0)),_=q.map((R)=>Number(R[Y]??0)),K=Math.min(...F),T=Math.max(...F),P=Math.min(..._),A=Math.max(..._),I=T-K||1,j=A-P||1,f=U?q.map((R)=>Number(R[U]??0)):[],S=U?Math.max(...f,1):1,O=400,L=s1(O,W,!0),k=U1(O,W,"Scatter"),y=(R)=>L.plotLeft+(R-K)/I*L.plotWidth,x=(R)=>L.plotBottom-(R-P)/j*L.plotHeight,i=4;for(let R=0;R<=i;R++){let c=P+j*R/i,V=x(c);if(k.appendChild(r1({x:L.plotLeft-6,y:V+3,"text-anchor":"end","font-size":X1,fill:J1},z(c))),X&&R>0)k.appendChild(n("line",{x1:L.plotLeft,y1:V,x2:L.plotRight,y2:V,stroke:z1,"stroke-width":1,"stroke-dasharray":"4 3"}))}n1(k,L);for(let R of[K,(K+T)/2,T])k.appendChild(r1({x:y(R),y:L.plotBottom+14,"text-anchor":"middle","font-size":X1,fill:J1},String(Math.round(R*100)/100)));let g=M?G1(J,k):void 0;for(let R=0;R<q.length;R++){let c=y(F[R]),V=x(_[R]),h=U?4+Math.sqrt(f[R]/S)*14:4,p=n("circle",{cx:c,cy:V,r:h,fill:G,"fill-opacity":U?0.6:0.85});if(g){let r=[{label:Q,value:z(F[R]),color:G},{label:Y,value:z(_[R]),color:G},...U?[{label:U,value:z(f[R]),color:G}]:[]],H1=H[0]?.label??"Point";p.addEventListener("mouseenter",()=>e(g,c,V,H1,r)),p.addEventListener("mouseleave",()=>g.tooltip.classList.remove("pf-visible")),p.addEventListener("touchstart",()=>e(g,c,V,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 e6($,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 W=Math.min(H,300),X=W/2,M=W/2,G=W/2-10,E=Math.max(0,Math.min($.innerRadius??30,G-10)),z=$.startAngle??180,F=$.endAngle??0,_=$.showTooltip!==!1,K=q.map((L)=>Number(L[Y]??0)),T=Math.max(...K,1),P=U1(W,W,"Radial"),A=(G-E)/q.length,I=Math.max(2,A*0.7),j=q1($),f=(L)=>j?$1(L,j,Z):String(L),S=_?G1(J,P):void 0,O=[];for(let L=0;L<q.length;L++){let k=G-A*L-A/2,y=Q[L]?.color??s[L%s.length],x=K[L]/T,i=z+x*(F-z),g=U?q[L][U]:null,R=g!=null?b(g):Q[L]?.label??Y;O.push({dataKey:R||Y,label:R||Y,color:y}),P.appendChild(n("path",{d:L0(X,M,k,z,F),fill:"none",stroke:z1,"stroke-width":I,"stroke-linecap":"round"}));let c=n("path",{d:L0(X,M,k,z,i),fill:"none",stroke:y,"stroke-width":I,"stroke-linecap":"round"});if(S){let V=B1(X,M,k,(z+i)/2),h=[{label:Y,value:f(K[L]),color:y}],p=R||Y;c.addEventListener("mouseenter",()=>e(S,V.x,V.y,p,h)),c.addEventListener("mouseleave",()=>S.tooltip.classList.remove("pf-visible")),c.addEventListener("touchstart",()=>e(S,V.x,V.y,p,h),{passive:!0}),c.addEventListener("touchend",()=>S.tooltip.classList.remove("pf-visible"),{passive:!0})}P.appendChild(c)}return M1(J,O,$.showLegend),J.appendChild(P),J}function $5($,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,W=$.showDots===!0,X=$.showGrid!==!1,M=$.showTooltip!==!1,G=Math.min(U,320),E=G/2,z=G/2,F=G/2-24,_=q.length,K=Math.max(...q.flatMap((S)=>Q.map((O)=>Number(S[O.dataKey]??0))),1),T=(S)=>90-360*S/_,P=(S)=>S.map((O)=>`${O.x.toFixed(1)},${O.y.toFixed(1)}`).join(" "),A=U1(G,G,"Radar");if(X){for(let O=1;O<=4;O++){let L=F*O/4,k=Array.from({length:_},(y,x)=>B1(E,z,L,T(x)));A.appendChild(n("polygon",{points:P(k),fill:"none",stroke:z1,"stroke-width":1}))}for(let O=0;O<_;O++){let L=B1(E,z,F,T(O));A.appendChild(n("line",{x1:E,y1:z,x2:L.x,y2:L.y,stroke:z1,"stroke-width":1}))}}for(let S=0;S<_;S++){let O=B1(E,z,F+12,T(S)),L=Y?q[S][Y]:null;A.appendChild(r1({x:O.x,y:O.y+3,"text-anchor":"middle","font-size":X1,fill:J1},L!=null?String(L):""))}let I=M?G1(J,A):void 0,j=q1($),f=(S)=>j?$1(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(E,z,Number(y[O.dataKey]??0)/K*F,T(x)));if(A.appendChild(n("polygon",{points:P(k),fill:H?L:"none","fill-opacity":H?0.2:0,stroke:L,"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?L:"transparent","fill-opacity":W?1:0});if(I){let i=Y?q[y][Y]:null,g=i!=null?b(i):O.label??O.dataKey,R=[{label:O.label??O.dataKey,value:f(Number(q[y][O.dataKey]??0)),color:L}];x.addEventListener("mouseenter",()=>e(I,k[y].x,k[y].y,g,R)),x.addEventListener("mouseleave",()=>I.tooltip.classList.remove("pf-visible")),x.addEventListener("touchstart",()=>e(I,k[y].x,k[y].y,g,R),{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 Z5($,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],W=Math.min(...Q),M=(Math.max(...Q)-W)/Y||1,G=Array(Y).fill(0);for(let T of Q){let P=Math.min(Math.floor((T-W)/M),Y-1);G[P]++}let E=Math.max(...G),z=300,F=U,_=z/Y,K=U1(z,F,"Histogram");for(let T=0;T<Y;T++){let P=E>0?G[T]/E*F:0,A=document.createElementNS("http://www.w3.org/2000/svg","rect");A.setAttribute("x",String(T*_)),A.setAttribute("y",String(F-P)),A.setAttribute("width",String(_-1)),A.setAttribute("height",String(P)),A.setAttribute("fill",H),K.appendChild(A)}return J.appendChild(K),J}function K4(){B("Table",J5),B("TableHead",T0("thead")),B("TableBody",T0("tbody")),B("TableFooter",T0("tfoot")),B("TableRow",q5),B("TableHeader",Q5),B("TableCell",Y5),B("TableCaption",U5),B("ExpandableRow",H5)}function J5($,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 T0($){return(Z,J)=>{let q=document.createElement($);return q.className=`pf-${$}`,C(Z,q,J),q}}function q5($,Z){let J=document.createElement("tr");return J.className="pf-table-row",C($,J,Z),J}function Q5($,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 Y5($,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 U5($,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 H5($,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",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 F4=!1;function a1(){if(F4)return;F4=!0,l0(),r0(),t0(),e0(),Z4(),q4(),Q4(),H4(),W4(),B4(),z4(),K4()}function I0($){return $.replace(/[^a-zA-Z0-9_-]/g,"")}function P0($){return $.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function O0($,Z=" "){return Object.entries($).map(([J,q])=>`${Z}--${I0(J)}: ${P0(q)};`).join(`
|
|
7
|
+
`)}function D4($){if(!$)return"";let Z=[];if($.light&&Object.keys($.light).length>0)Z.push(`:root {
|
|
8
|
+
${O0($.light)}
|
|
9
|
+
}`);if($.dark&&Object.keys($.dark).length>0){let J=O0($.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
|
-
${
|
|
13
|
+
${O0($.dark," ")}
|
|
14
14
|
}
|
|
15
15
|
}`)}return Z.join(`
|
|
16
|
-
`)}function K1($,Z){$.setAttribute("data-theme",Z),$.classList.toggle("dark",Z==="dark"),$.classList.toggle("light",Z==="light")}function P0($,Z){if(!Z)return;if(Z.light)for(let[J,q]of Object.entries(Z.light))$.style.setProperty(`--${O0(J)}`,I0(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=K4({dark:Z.dark})}}function R0($,Z){if(!$||typeof document>"u")return;let J=(q)=>{for(let[Q,Y]of Object.entries($))if(Y5(Q,q))q.preventDefault(),Z(Y)};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)}function Y5($,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 F4='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="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>',D4={"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 U5($,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 V1($,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=D4[J]??D4["top-right"];for(let G of H.split(";")){let[B,K]=G.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(G){if(K1($,G),Q)K1(document.documentElement,G);U.innerHTML=G==="dark"?L4:F4;try{localStorage.setItem(q,G)}catch{}}let _=U5($,q);W(_),U.addEventListener("click",()=>{let G=$.getAttribute("data-theme")??"dark";W(G==="dark"?"light":"dark")}),$.appendChild(U);let E;if(Q)E=new MutationObserver((G)=>{for(let B of G)if(B.type==="attributes"&&B.attributeName==="data-theme"){let K=document.documentElement.getAttribute("data-theme");if((K==="light"||K==="dark")&&K!==$.getAttribute("data-theme")){K1($,K),U.innerHTML=K==="dark"?L4:F4;try{localStorage.setItem(q,K)}catch{}}}}),E.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{E?.disconnect(),U.remove()}}function a1($){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 E=JSON.parse(_.text);if(typeof E==="object"&&E!==null&&"$prefab"in E)return E;return E}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 o1(){return{callTool($){return w.warn(`No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return w.warn("No MCP transport: sendMessage ignored",$),Promise.resolve()}}}var T4="0.3.8";function H5($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class _1{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 $=X5();if($)this.postFn=(J)=>$.postMessage(J);let Z=(J)=>{if(this.hostOrigin!=="*"&&J.origin!==this.hostOrigin)return;let q=J.data;if(H5(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 W5;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??{},E;if(typeof W.theme==="string"||typeof W.styles==="object"){if(E={},typeof W.theme==="string")E.colorScheme=W.theme;if(typeof W.styles==="object"&&W.styles!==null){let B=W.styles;if(B.variables)E.variables=B.variables;if(typeof B.css?.fonts==="string")E.fontCss=B.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let G=_.resources;this._hostSupportsSubscriptions=_.subscriptions===!0||G?.subscribe===!0,Z({hostName:H.name,hostVersion:H.version,capabilities:{toast:!0,navigation:_.openLinks!=null,messaging:!0,displayModes:W.availableDisplayModes??[]},theme:E,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:T4},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 W5=()=>{};function j1($,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)G5(Z.fontCss)}function G5($){if(document.getElementById("__prefab-host-fonts"))return;let J=document.createElement("style");J.id="__prefab-host-fonts",J.textContent=$,document.head.appendChild(J)}function F1(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function X5(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let Z=$.acquireVsCodeApi();if(Z!==null&&typeof Z==="object"&&"postMessage"in Z)return Z}catch{return}return}async function t1($){r1();let Z=$?.mode??"auto",J=Z==="bridge"||Z==="auto"&&F1(),q,Q,Y={capabilities:{}};if(J)Q=new _1($?.hostOrigin),Q.connect(),Y=await Q.initialize($?.capabilities??{toolInput:!0}),q=Q.createTransport();else if($?.transport)q=a1($.transport);else q=o1();if(Y.theme&&typeof document<"u")j1(document.documentElement,Y.theme);if(typeof document<"u"&&!Q)M5();let U,H,W,_,E,G=Y.toolInput,B;if(Q)Q.on("prefab:tool-input",(M)=>{let z=M.args??M;if(U)U(z);else G=z}),Q.on("prefab:tool-result",(M)=>{let z=M.result??M;if(H)H(z);else B=z}),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")j1(document.documentElement,M)}),Q.on("prefab:host-context-changed",(M)=>{E?.(M)});function K(M,...z){let T=V0(M),P=new D1,A={store:P,scope:{},transport:q,rerender:()=>I(),onToast:void 0};function I(){T.innerHTML="";for(let j of z)T.appendChild(u(j,A))}return I(),{rerender:I,store:P,destroy:()=>{T.innerHTML=""}}}return{callTool:(M,z={})=>q.callTool(M,z),sendMessage:(M)=>q.sendMessage(M),onToolInput:(M)=>{if(U=M,G){let z=G;G=void 0,queueMicrotask(()=>M(z))}},onToolResult:(M)=>{if(H=M,B!==void 0){let z=B;B=void 0,queueMicrotask(()=>M(z))}},onToolCancelled:(M)=>{W=M},onToolInputPartial:(M)=>{_=M},onHostContextChanged:(M)=>{E=M},render:K,mount:(M,z,T)=>{let P=V0(M);return Z1.mount(P,z,{transport:q,...T})},requestMode:(M)=>Q?.requestMode(M),openLink:(M,z)=>{if(Q)Q.openLink(M,z);else if(typeof window<"u")window.open(M,z??"_blank")},updateContext:(M)=>{if(Q)Q.updateContext(M)},setupAutoResize:(M)=>{if(!Q)return B5;let z=typeof M==="string"?V0(M):M;return Q.setupAutoResize(z)},notifyPreferredSize:(M)=>{if(Q)Q.notifyPreferredSize(M)},host:Y,capabilities:Y.capabilities,theme:Y.theme,transport:q,destroy:()=>Q?.disconnect()}}var B5=()=>{};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 M5(){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 O4=["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(O4);function L1($,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 j0(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)N5(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))j0(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))k0(U,`$.keyBindings.${Y}`,J);return{valid:J.length===0,errors:J}}function V4($){return L1($).valid}function j0($,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++)j0(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)k0(Q[U],`${Z}.${U}`,J);for(let[U,H]of Object.entries(Q)){if(U==="type"||_5.has(U)||Y.includes(U))continue;if(I4(H)||Array.isArray(H)&&H.some(I4))J.push({path:`${Z}.${U}`,message:`Components under "${U}" are ignored by the renderer; move them into "children"`})}}var _5=new Set(["children","fallback","trigger","empty","else","summary"]);function I4($){if($==null||typeof $!=="object"||Array.isArray($))return!1;let Z=$.type;return typeof Z==="string"&&R4.has(Z)}function k0($,Z,J){if(Array.isArray($)){for(let H=0;H<$.length;H++)k0($[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 N5($,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 Z1={mount($,Z,J){if(r1(),J?.validate!==!1)for(let z of L1(Z).errors)w.warn(`wire validation ${z.path}: ${z.message}`);let q=Z,Q={tracked:[],evalBlocked:!1};if(q.pipes)for(let[z,T]of Object.entries(q.pipes))j4(z,T,Q);let Y=new D1(q.state),U;if(J?.transport&&"callTool"in J.transport)U=J.transport;else if(J?.transport)U=a1(J.transport);else U=o1();let H=J?.onToast??K5,W=new I1;function _(z){let T=z;if(q=T,T.state)Y.merge(T.state);if(T.defs)E.defs=T.defs;if(T.theme)P0($,T.theme);if(T.mode)k4($,T.mode);if(T.pipes)for(let[P,A]of Object.entries(T.pipes))j4(P,A,Q);for(let P of G)P.remove();if(G.length=0,G.push(...A4(T.css,T.stylesheets)),S4($,T.layout),B?.(),B=void 0,T.keyBindings)B=R0(T.keyBindings,(P)=>{v(h(P,{store:Y,transport:U,scope:{},rerender:()=>M(),remount:_,onToast:H}),"keyBinding")});M()}let E={store:Y,scope:{},transport:U,rerender:()=>M(),remount:_,onToast:H,defs:q.defs,destroyRegistry:W};if(P0($,q.theme),q.mode)k4($,q.mode);S4($,q.layout);let G=A4(q.css,q.stylesheets),B;if(q.keyBindings)B=R0(q.keyBindings,(z)=>{v(h(z,{store:Y,transport:U,scope:{},rerender:()=>M(),remount:_,onToast:H}),"keyBinding")});let K,L=J?.themeToggle??!0;if(L!==!1)K=V1($,typeof L==="object"?L:void 0);function M(){W.flush();let z=$.querySelector(".pf-theme-toggle");$.innerHTML="";let T=u(q.view,E);if($.appendChild(T),z)$.appendChild(z)}return M(),{rerender:()=>M(),update(z){if(Y.merge(z.update.state),M(),z.update.actions!=null)v(h(z.update.actions,E),"update action")},store:Y,destroy(){W.flush(),K?.(),B?.(),h0(),v0();for(let z of G)z.remove();for(let z of Q.tracked)O1(z);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},E5=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 z5($){if($ instanceof EvalError)return!0;return $ instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test($.message)}function j4($,Z,J){if(E5.has($)){w.warn(`wire pipe "${$}" ignored — shadows built-in`);return}if(S1($)!=null){w.debug(`wire pipe "${$}" — already registered, keeping local implementation`);return}if(J.evalBlocked)return;try{let q=Function("return ("+Z+")")();if(typeof q!=="function"){w.warn(`wire pipe "${$}" — source did not evaluate to a function`);return}T1($,q),J.tracked.push($)}catch(q){if(z5(q)){J.evalBlocked=!0,w.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}w.warn(`wire pipe "${$}" — failed to hydrate:`,q)}}function K5($){if(typeof document>"u")return;let Z=L5(),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(K1($,Z),typeof document<"u")K1(document.documentElement,Z)}function F5($){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(F5(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 L5(){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=Z1,$.prefab={app:t1,mount:Z1.mount.bind(Z1),isPrefabData:Z1.isPrefabData.bind(Z1),isPrefabUpdate:Z1.isPrefabUpdate.bind(Z1),Bridge:_1,isIframe:F1,registerPipe:T1,unregisterPipe:O1,listPipes:A1,registerComponent:X,createThemeToggle:V1,validateWireFormat:L1,setLogLevel:k1};let Z=$.__PREFAB_DATA__;if(Z!=null){let J=document.getElementById("prefab-root");if(J)Z1.mount(J,Z)}}})();
|
|
16
|
+
`)}function K1($,Z){$.setAttribute("data-theme",Z),$.classList.toggle("dark",Z==="dark"),$.classList.toggle("light",Z==="light")}function R0($,Z){if(!Z)return;if(Z.light)for(let[J,q]of Object.entries(Z.light))$.style.setProperty(`--${I0(J)}`,P0(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=D4({dark:Z.dark})}}function V0($,Z){if(!$||typeof document>"u")return;let J=(q)=>{for(let[Q,Y]of Object.entries($))if(W5(Q,q))q.preventDefault(),Z(Y)};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)}function W5($,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 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="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>',T4='<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>',O4={"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 G5($,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 j1($,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=O4[J]??O4["top-right"];for(let G of H.split(";")){let[E,z]=G.split(":").map((F)=>F.trim());if(E&&z)U.style.setProperty(E,z)}U.addEventListener("mouseenter",()=>{U.style.opacity="1"}),U.addEventListener("mouseleave",()=>{U.style.opacity="0.7"});function W(G){if(K1($,G),Q)K1(document.documentElement,G);U.innerHTML=G==="dark"?T4:L4;try{localStorage.setItem(q,G)}catch{}}let X=G5($,q);W(X),U.addEventListener("click",()=>{let G=$.getAttribute("data-theme")??"dark";W(G==="dark"?"light":"dark")}),$.appendChild(U);let M;if(Q)M=new MutationObserver((G)=>{for(let E of G)if(E.type==="attributes"&&E.attributeName==="data-theme"){let z=document.documentElement.getAttribute("data-theme");if((z==="light"||z==="dark")&&z!==$.getAttribute("data-theme")){K1($,z),U.innerHTML=z==="dark"?T4:L4;try{localStorage.setItem(q,z)}catch{}}}}),M.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{M?.disconnect(),U.remove()}}function o1($){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 X of W)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 t1(){return{callTool($){return w.warn(`No MCP transport: callTool('${$}') ignored`),Promise.resolve(null)},sendMessage($){return w.warn("No MCP transport: sendMessage ignored",$),Promise.resolve()}}}var I4="0.3.9";function X5($){return $!==null&&typeof $==="object"&&$.jsonrpc==="2.0"}class _1{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 $=_5();if($)this.postFn=(J)=>$.postMessage(J);let Z=(J)=>{if(this.hostOrigin!=="*"&&J.origin!==this.hostOrigin)return;let q=J.data;if(X5(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 B5;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??{},X=U.hostCapabilities??{},M;if(typeof W.theme==="string"||typeof W.styles==="object"){if(M={},typeof W.theme==="string")M.colorScheme=W.theme;if(typeof W.styles==="object"&&W.styles!==null){let E=W.styles;if(E.variables)M.variables=E.variables;if(typeof E.css?.fonts==="string")M.fontCss=E.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let G=X.resources;this._hostSupportsSubscriptions=X.subscriptions===!0||G?.subscribe===!0,Z({hostName:H.name,hostVersion:H.version,capabilities:{toast:!0,navigation:X.openLinks!=null,messaging:!0,displayModes:W.availableDisplayModes??[]},theme:M,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:I4},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 B5=()=>{};function k1($,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)M5(Z.fontCss)}function M5($){if(document.getElementById("__prefab-host-fonts"))return;let J=document.createElement("style");J.id="__prefab-host-fonts",J.textContent=$,document.head.appendChild(J)}function F1(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function _5(){if(typeof window>"u")return;let $=window;if(typeof $.acquireVsCodeApi==="function")try{let Z=$.acquireVsCodeApi();if(Z!==null&&typeof Z==="object"&&"postMessage"in Z)return Z}catch{return}return}async function e1($){a1();let Z=$?.mode??"auto",J=Z==="bridge"||Z==="auto"&&F1(),q,Q,Y={capabilities:{}};if(J)Q=new _1($?.hostOrigin),Q.connect(),Y=await Q.initialize($?.capabilities??{toolInput:!0}),q=Q.createTransport();else if($?.transport)q=o1($.transport);else q=t1();if(Y.theme&&typeof document<"u")k1(document.documentElement,Y.theme);if(typeof document<"u"&&!Q)E5();let U,H,W,X,M,G=Y.toolInput,E;if(Q)Q.on("prefab:tool-input",(_)=>{let K=_.args??_;if(U)U(K);else G=K}),Q.on("prefab:tool-result",(_)=>{let K=_.result??_;if(H)H(K);else E=K}),Q.on("prefab:tool-cancelled",()=>{W?.()}),Q.on("prefab:tool-input-partial",(_)=>{X?.(_.args??_)}),Q.on("prefab:theme-update",(_)=>{if(typeof document<"u")k1(document.documentElement,_)}),Q.on("prefab:host-context-changed",(_)=>{M?.(_)});function z(_,...K){let T=j0(_),P=new L1,A={store:P,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:P,destroy:()=>{T.innerHTML=""}}}return{callTool:(_,K={})=>q.callTool(_,K),sendMessage:(_)=>q.sendMessage(_),onToolInput:(_)=>{if(U=_,G){let K=G;G=void 0,queueMicrotask(()=>_(K))}},onToolResult:(_)=>{if(H=_,E!==void 0){let K=E;E=void 0,queueMicrotask(()=>_(K))}},onToolCancelled:(_)=>{W=_},onToolInputPartial:(_)=>{X=_},onHostContextChanged:(_)=>{M=_},render:z,mount:(_,K,T)=>{let P=j0(_);return Z1.mount(P,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 N5;let K=typeof _==="string"?j0(_):_;return Q.setupAutoResize(K)},notifyPreferredSize:(_)=>{if(Q)Q.notifyPreferredSize(_)},host:Y,capabilities:Y.capabilities,theme:Y.theme,transport:q,destroy:()=>Q?.disconnect()}}var N5=()=>{};function j0($){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 P4=["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 j4=new Set(P4);function D1($,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 k0(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)K5(Q.theme,J);if(Q.css!==void 0)V4(Q.css,"$.css",J);if(Q.stylesheets!==void 0)V4(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))k0(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))A0(U,`$.keyBindings.${Y}`,J);return{valid:J.length===0,errors:J}}function k4($){return D1($).valid}function k0($,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&&!j4.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++)k0(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)A0(Q[U],`${Z}.${U}`,J);for(let[U,H]of Object.entries(Q)){if(U==="type"||z5.has(U)||Y.includes(U))continue;if(R4(H)||Array.isArray(H)&&H.some(R4))J.push({path:`${Z}.${U}`,message:`Components under "${U}" are ignored by the renderer; move them into "children"`})}}var z5=new Set(["children","fallback","trigger","empty","else","summary"]);function R4($){if($==null||typeof $!=="object"||Array.isArray($))return!1;let Z=$.type;return typeof Z==="string"&&j4.has(Z)}function A0($,Z,J){if(Array.isArray($)){for(let H=0;H<$.length;H++)A0($[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 V4($,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 K5($,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 Z1={mount($,Z,J){if(a1(),J?.validate!==!1)for(let K of D1(Z).errors)w.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))A4(K,T,Q);let Y=new L1(q.state),U;if(J?.transport&&"callTool"in J.transport)U=J.transport;else if(J?.transport)U=o1(J.transport);else U=t1();let H=J?.onToast??L5,W=new I1;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)R0($,T.theme);if(T.mode)S4($,T.mode);if(T.pipes)for(let[P,A]of Object.entries(T.pipes))A4(P,A,Q);for(let P of G)P.remove();if(G.length=0,G.push(...f4(T.css,T.stylesheets)),C4($,T.layout),E?.(),E=void 0,T.keyBindings)E=V0(T.keyBindings,(P)=>{v(m(P,{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:W};if(R0($,q.theme),q.mode)S4($,q.mode);C4($,q.layout);let G=f4(q.css,q.stylesheets),E;if(q.keyBindings)E=V0(q.keyBindings,(K)=>{v(m(K,{store:Y,transport:U,scope:{},rerender:()=>_(),remount:X,onToast:H}),"keyBinding")});let z,F=J?.themeToggle??!0;if(F!==!1)z=j1($,typeof F==="object"?F:void 0);function _(){W.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(){W.flush(),z?.(),E?.(),v0(),g0();for(let K of G)K.remove();for(let K of Q.tracked)O1(K);$.innerHTML=""}}},isPrefabData($){return $!=null&&typeof $==="object"&&"$prefab"in $},isPrefabUpdate($){return $!=null&&typeof $==="object"&&"$prefab"in $&&"update"in $}},F5=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 D5($){if($ instanceof EvalError)return!0;return $ instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test($.message)}function A4($,Z,J){if(F5.has($)){w.warn(`wire pipe "${$}" ignored — shadows built-in`);return}if(f1($)!=null){w.debug(`wire pipe "${$}" — already registered, keeping local implementation`);return}if(J.evalBlocked)return;try{let q=Function("return ("+Z+")")();if(typeof q!=="function"){w.warn(`wire pipe "${$}" — source did not evaluate to a function`);return}T1($,q),J.tracked.push($)}catch(q){if(D5(q)){J.evalBlocked=!0,w.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}w.warn(`wire pipe "${$}" — failed to hydrate:`,q)}}function L5($){if(typeof document>"u")return;let Z=O5(),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 S4($,Z){if(K1($,Z),typeof document<"u")K1(document.documentElement,Z)}function T5($){let Z=$.trim();if(Z.includes("{")||Z.includes("}"))return!1;return/^(https?:)?\/\//i.test(Z)||Z.startsWith("/")||/\.css(\?|#|$)/i.test(Z)}function f4($,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(T5(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 C4($,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 O5(){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=Z1,$.prefab={app:e1,mount:Z1.mount.bind(Z1),isPrefabData:Z1.isPrefabData.bind(Z1),isPrefabUpdate:Z1.isPrefabUpdate.bind(Z1),Bridge:_1,isIframe:F1,registerPipe:T1,unregisterPipe:O1,listPipes:S1,registerComponent:B,createThemeToggle:j1,validateWireFormat:D1,setLogLevel:A1};let Z=$.__PREFAB_DATA__;if(Z!=null){let J=document.getElementById("prefab-root");if(J)Z1.mount(J,Z)}}})();
|