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