@maxhealth.tech/prefab 0.3.11 → 0.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -3
- package/dist/a2ui/catalog.js +1 -1
- package/dist/a2ui/catalog.js.map +1 -1
- package/dist/a2ui.min.js +1 -1
- package/dist/auto/comparison.d.ts.map +1 -1
- package/dist/auto/comparison.js +1 -7
- package/dist/auto/comparison.js.map +1 -1
- package/dist/auto/form.d.ts.map +1 -1
- package/dist/auto/form.js +8 -9
- package/dist/auto/form.js.map +1 -1
- package/dist/auto/index.d.ts +2 -0
- package/dist/auto/index.d.ts.map +1 -1
- package/dist/auto/index.js +5 -11
- package/dist/auto/index.js.map +1 -1
- package/dist/auto/schema.d.ts +84 -0
- package/dist/auto/schema.d.ts.map +1 -0
- package/dist/auto/schema.js +227 -0
- package/dist/auto/schema.js.map +1 -0
- package/dist/components/form/index.d.ts +7 -3
- package/dist/components/form/index.d.ts.map +1 -1
- package/dist/components/form/index.js +8 -3
- package/dist/components/form/index.js.map +1 -1
- package/dist/core/component.d.ts +11 -1
- package/dist/core/component.d.ts.map +1 -1
- package/dist/core/component.js +4 -1
- package/dist/core/component.js.map +1 -1
- package/dist/core/humanize.d.ts +20 -0
- package/dist/core/humanize.d.ts.map +1 -0
- package/dist/core/humanize.js +28 -0
- package/dist/core/humanize.js.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/renderer/components/choice.d.ts +10 -0
- package/dist/renderer/components/choice.d.ts.map +1 -0
- package/dist/renderer/components/choice.js +261 -0
- package/dist/renderer/components/choice.js.map +1 -0
- package/dist/renderer/components/form.d.ts +24 -1
- package/dist/renderer/components/form.d.ts.map +1 -1
- package/dist/renderer/components/form.js +36 -239
- package/dist/renderer/components/form.js.map +1 -1
- package/dist/renderer/components/index.d.ts.map +1 -1
- package/dist/renderer/components/index.js +2 -0
- package/dist/renderer/components/index.js.map +1 -1
- package/dist/renderer.auto.min.js +10 -10
- package/dist/renderer.min.js +10 -10
- package/package.json +1 -1
package/dist/renderer.min.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
(()=>{var{defineProperty:nt,getOwnPropertyNames:Fn,getOwnPropertyDescriptor:Bn}=Object,Jn=Object.prototype.hasOwnProperty;function zn(e){return this[e]}var _n=(e)=>{var t=(Ht??=new WeakMap).get(e),n;if(t)return t;if(t=nt({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var r of Fn(e))if(!Jn.call(t,r))nt(t,r,{get:zn.bind(e,r),enumerable:!(n=Bn(e,r))||n.enumerable})}return Ht.set(e,t),t},Ht;var Vn=(e)=>e;function Wn(e,t){this[e]=Vn.bind(null,t)}var Kn=(e,t)=>{for(var n in t)nt(e,n,{get:t[n],enumerable:!0,configurable:!0,set:Wn.bind(t,n)})};var Ns={};Kn(Ns,{Bridge:()=>me,DestroyRegistry:()=>Se,PrefabRenderer:()=>ne,app:()=>tt,applyHostTheme:()=>Ne,createLogger:()=>ot,createThemeToggle:()=>Te,getLogLevel:()=>$t,isIframe:()=>Ce,isValidWireFormat:()=>Pn,listPipes:()=>Le,log:()=>P,registerComponent:()=>p,registerPipe:()=>xe,setLogLevel:()=>Me,unregisterPipe:()=>ke,validateWireFormat:()=>ve});var Pt={silent:0,error:1,warn:2,info:3,debug:4},rt="warn";function Me(e){rt=e}function $t(){return rt}function ot(e){let t=e?`[prefab:${e}]`:"[prefab]",n=(r,o,s)=>{if(Pt[r]>Pt[rt])return;console[r](`${t} ${o}`,...s)};return{error:(r,...o)=>n("error",r,o),warn:(r,...o)=>n("warn",r,o),info:(r,...o)=>n("info",r,o),debug:(r,...o)=>n("debug",r,o)}}var P=ot();class we{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor(e){if(e)this.data=structuredClone(e)}get(e){return Gn(this.data,e)}getAll(){return this.data}set(e,t){Ot(this.data,e,t),this.notify(e)}toggle(e){let t=this.get(e),n=t==null||t===!1||t===0||t==="";this.set(e,n)}append(e,t,n){let r=this.get(e);if(!Array.isArray(r)){this.set(e,[t]);return}if(n!==void 0)r.splice(n,0,t);else r.push(t);this.notify(e)}pop(e,t){let n=this.get(e);if(!Array.isArray(n))return;if(typeof t==="number")n.splice(t,1);else{let r=n.indexOf(t);if(r>=0)n.splice(r,1)}this.notify(e)}merge(e){for(let[t,n]of Object.entries(e))Ot(this.data,t,n);for(let t of Object.keys(e))this.notify(t)}subscribe(e,t){if(!this.subscribers.has(e))this.subscribers.set(e,new Set);return this.subscribers.get(e)?.add(t),()=>this.subscribers.get(e)?.delete(t)}subscribeAll(e){return this.globalSubscribers.add(e),()=>this.globalSubscribers.delete(e)}notify(e){this.generation++;let t=e.split(".");for(let n=1;n<=t.length;n++){let r=t.slice(0,n).join("."),o=this.subscribers.get(r);if(o)o.forEach((s)=>s())}this.globalSubscribers.forEach((n)=>n())}}function Gn(e,t){let n=t.split("."),r=e;for(let o of n){if(r==null||typeof r!=="object")return;r=r[o]}return r}var qn=new Set(["__proto__","constructor","prototype"]);function Ot(e,t,n){let r=t.split(".");if(r.some((s)=>qn.has(s))){P.warn(`Blocked prototype pollution attempt: ${t}`);return}let o=e;for(let s=0;s<r.length-1;s++){let i=r[s];if(o[i]==null||typeof o[i]!=="object")o[i]={};o=o[i]}o[r[r.length-1]]=n}var ge=new Map;function xe(e,t){if(ge.has(e)&&ge.get(e)!==t)P.warn(`pipe "${e}" re-registered`);ge.set(e,t)}function ke(e){return ge.delete(e)}function Le(){return[...ge.keys()]}function He(e){return ge.get(e)}function O(e){if(e==null)return"";if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean"||typeof e==="bigint")return String(e);if(typeof e==="symbol")return e.description??"";if(typeof e==="function")return e.name;if(e instanceof Date)return Number.isNaN(e.getTime())?"":e.toISOString();if(Array.isArray(e))return e.map(O).join(", ");try{return JSON.stringify(e)??""}catch{return""}}var Dt=-1,st=new Map,Un=/\{\{\s*(.+?)\s*\}\}/g;function Z(e){return typeof e==="string"&&e.includes("{{")&&e.includes("}}")}function Q(e,t,n){let r=e.trim();if(r.startsWith("{{")&&r.endsWith("}}")&&nr(r,"{{")===1){let o=r.slice(2,-2).trim();return jt(o,t,n)}return e.replace(Un,(o,s)=>{let i=jt(s.trim(),t,n);return O(i)})}function jt(e,t,n){let[r,...o]=tr(e),s=Y(r.trim(),t,n);for(let i of o)s=Xn(i.trim(),s,t,n);return s}function Y(e,t,n){let r=Qn(e);if(r>=0){let i=e.slice(0,r).trim(),a=e.slice(r+1),l=er(a);if(l>=0){let c=a.slice(0,l).trim(),u=a.slice(l+1).trim(),d=Y(i,t,n);return d!==null&&d!==void 0&&d!==!1&&d!==0&&d!==""?Y(c,t,n):Y(u,t,n)}}let o=Pe(e,"||");if(o>=0){let i=Y(e.slice(0,o).trim(),t,n);return i!==null&&i!==void 0&&i!==!1&&i!==0&&i!==""?i:Y(e.slice(o+2).trim(),t,n)}let s=Pe(e,"&&");if(s>=0){let i=Y(e.slice(0,s).trim(),t,n);if(i===null||i===void 0||i===!1||i===0||i==="")return i;return Y(e.slice(s+2).trim(),t,n)}for(let[i,a]of Yn){let l=Pe(e,i);if(l>=0){let c=Y(e.slice(0,l).trim(),t,n),u=Y(e.slice(l+i.length).trim(),t,n);return a(c,u)}}if(e.startsWith("!")){let i=Y(e.slice(1).trim(),t,n);return i===null||i===void 0||i===!1||i===0||i===""}for(let[i,a]of Zn){let l=Pe(e,i);if(l>=0){let c=Y(e.slice(0,l).trim(),t,n),u=Y(e.slice(l+i.length).trim(),t,n);return a(Number(c),Number(u))}}if(e==="true")return!0;if(e==="false")return!1;if(e==="null"||e==="undefined")return null;if(/^-?\d+(\.\d+)?$/.test(e))return Number(e);if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);if(n&&e.startsWith("$")){let i=e.indexOf(".");if(i>=0){let a=e.slice(0,i),l=e.slice(i+1),c=n[a];return $e(c,l)}return n[e]}if(n){let i=e.split(".")[0];if(i in n)return $e(n[i],e.includes(".")?e.slice(i.length+1):"")}return t.get(e)}function Xn(e,t,n,r){let o=e.indexOf(":"),s=o>=0?e.slice(0,o).trim():e,i=o>=0?e.slice(o+1).trim():void 0,a=i?it(i):void 0;switch(s){case"find":{if(!Array.isArray(t)||!i)return;let l=It(i);if(l.length<2)return;let c=it(l[0]),u=l[1].trim(),d;if(u.startsWith("'")&&u.endsWith("'")||u.startsWith('"')&&u.endsWith('"'))d=u.slice(1,-1);else if(n){if(r&&u.startsWith("$")){let f=u.indexOf(".");if(f>=0){let b=u.slice(0,f);if(b in r)d=$e(r[b],u.slice(f+1))}else if(u in r)d=r[u]}if(d===void 0&&!(r&&u.startsWith("$")))if(r){let f=u.split(".")[0];d=f in r?$e(r[f],u.includes(".")?u.slice(f.length+1):""):n.get(u)}else d=n.get(u)}else d=u;if(d==null)return;let g=n?.generation??0;if(g!==Dt)st=new Map,Dt=g;let h=st.get(t);if(!h)h=new Map,st.set(t,h);let y=h.get(c);if(!y){y=new Map;for(let f of t)if(f!=null&&typeof f==="object"){let b=f[c];if(b!=null)y.set(O(b),f)}h.set(c,y)}return y.get(O(d))}case"dot":{if(t==null||typeof t!=="object"||typeof a!=="string")return;return t[a]}case"length":return Array.isArray(t)?t.length:typeof t==="string"?t.length:0;case"upper":return typeof t==="string"?t.toUpperCase():t;case"lower":return typeof t==="string"?t.toLowerCase():t;case"truncate":if(typeof t==="string"&&typeof a==="number")return t.slice(0,a);return t;case"join":return Array.isArray(t)?t.join(typeof a==="string"?a:", "):t;case"first":return Array.isArray(t)?t[0]:t;case"last":return Array.isArray(t)?t[t.length-1]:t;case"abs":return Math.abs(Number(t));case"round":return typeof a==="number"?Number(Number(t).toFixed(a)):Math.round(Number(t));case"number":return typeof a==="number"?Number(Number(t).toFixed(a)):Number(t);case"currency":{let l=typeof a==="string"?a:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:l}).format(Number(t))}catch{return t}}case"percent":return typeof a==="number"?`${(Number(t)*100).toFixed(a)}%`:`${Math.round(Number(t)*100)}%`;case"compact":{let l=typeof a==="number"?a:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:l}).format(Number(t))}catch{return t}}case"date":try{return new Date(t).toLocaleDateString()}catch{return t}case"time":try{return new Date(t).toLocaleTimeString()}catch{return t}case"datetime":try{return new Date(t).toLocaleString()}catch{return t}case"pluralize":{let l=Number(t),c=typeof a==="string"?a:"";return l===1?c:`${c}s`}case"default":return t==null||t===""?a:t;case"selectattr":return Array.isArray(t)&&typeof a==="string"?t.filter((l)=>l!=null&&typeof l==="object"&&Boolean(l[a])):t;case"rejectattr":return Array.isArray(t)&&typeof a==="string"?t.filter((l)=>{if(l==null||typeof l!=="object")return!1;let c=l[a];return c==null||c===!1||c===0||c===""}):t;default:{let l=He(s);if(l){let c=i?It(i).map(it):[];return l(t,...c)}return t}}}var Yn=[["!==",(e,t)=>e!==t],["===",(e,t)=>e===t],["!=",(e,t)=>e!=t],["==",(e,t)=>e==t],[">=",(e,t)=>Number(e)>=Number(t)],["<=",(e,t)=>Number(e)<=Number(t)],[">",(e,t)=>Number(e)>Number(t)],["<",(e,t)=>Number(e)<Number(t)]],Zn=[[" + ",(e,t)=>e+t],[" - ",(e,t)=>e-t],[" * ",(e,t)=>e*t],[" / ",(e,t)=>t!==0?e/t:0],[" % ",(e,t)=>t!==0?e%t:0]];function Pe(e,t){let n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n&&e.slice(r,r+t.length)===t)return r}return-1}function Qn(e){let t=0,n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n){if(o==="(")t++;else if(o===")")t--;else if(o==="?"&&t===0)return r}}return-1}function er(e){let t=0,n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n){if(o==="?"||o==="(")t++;else if(o===")")t--;else if(o===":"&&t===0)return r}}return-1}function tr(e){let t=[],n="",r=null;for(let o=0;o<e.length;o++){let s=e[o];if(s==="'"||s==='"')r=r===s?null:r??s;if(s==="|"&&!r)if(e[o+1]==="|")n+="||",o++;else t.push(n),n="";else n+=s}return t.push(n),t}function it(e){let t=e.replace(/^['"]|['"]$/g,"");if(t==="true")return!0;if(t==="false")return!1;let n=Number(t);return isNaN(n)?t:n}function It(e){let t=[],n="",r=null;for(let o of e){if(o==="'"||o==='"')r=r===o?null:r??o;if(o===","&&!r)t.push(n),n="";else n+=o}return t.push(n),t}function $e(e,t){if(!t)return e;let n=t.split("."),r=e;for(let o of n){if(r==null||typeof r!=="object")return;r=r[o]}return r}function nr(e,t){let n=0,r=0;while((r=e.indexOf(t,r))!==-1)n++,r+=t.length;return n}function Oe(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function lt(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:Oe(n);if(Array.isArray(r))t[o]=r.map((s)=>s!=null&&typeof s==="object"&&!Array.isArray(s)?lt(s):s);else if(r!=null&&typeof r==="object"&&!Array.isArray(r))t[o]=lt(r);else t[o]=r}return t}async function j(e,t){let n=Array.isArray(e)?e:[e];for(let r of n)await rr(r,t)}function F(e,t){e.catch((n)=>P.error(`${t} failed:`,n))}async function Ie(e,t,n,r){if(n!=null)P.debug(`${e} failed:`,t),await de(n,r,{$error:t});else P.warn(`${e} failed:`,t)}async function rr(e,t){let n=lt(e),r=n.action;switch(r){case"setState":{or(n,t);return}case"toggleState":{sr(n,t);return}case"appendState":{ir(n,t);return}case"popState":{ar(n,t);return}case"showToast":{lr(n,t);return}case"closeOverlay":{dr(n,t);return}case"openLink":{cr(n);return}case"setInterval":{ur(n,t);return}case"toolCall":case"callTool":return fr(n,t);case"sendMessage":return mr(n,t);case"updateContext":{gr(n,t);return}case"fetch":return hr(n,t);case"openFilePicker":{br(n,t);return}case"callHandler":return yr(n,t);case"requestDisplayMode":{Cr(n,t);return}case"subscribe":{xr(n,t);return}case"unsubscribe":{kr(n);return}default:P.warn(`Unknown action: ${r}`)}}function or(e,t){let{key:n,value:r}=e;if(Z(r))r=Q(r,t.store,t.scope);t.store.set(n,r),t.rerender(),de(e.onSuccess,t)}function sr(e,t){t.store.toggle(e.key),t.rerender()}function ir(e,t){let n=e.value??e.item;if(Z(n))n=Q(n,t.store,t.scope);t.store.append(e.key,n,e.index),t.rerender()}function ar(e,t){t.store.pop(e.key,e.index),t.rerender()}function lr(e,t){t.onToast?.({message:je(e.message,t),description:e.description!=null?je(e.description,t):void 0,variant:e.variant,duration:e.duration})}function dr(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function cr(e){if(typeof window<"u"){let t=e.url;if(!t){P.warn("openLink: missing url");return}if(!zt(t)){P.warn(`Blocked unsafe URL scheme: ${t}`);return}window.open(t,e.target??"_blank")}}var De=new Set,pr=20,Ft=100;function ur(e,t){let n=Math.max(e.intervalMs,Ft),r=e.onTick;if(typeof globalThis.setInterval!=="function")return;if(De.size>=pr){P.warn("Max intervals reached, ignoring new setInterval");return}let o=globalThis.setInterval(()=>F(j(r,t),"interval action"),n);De.add(o)}function Bt(){for(let e of De)globalThis.clearInterval(e);De.clear()}async function fr(e,t){if(!t.transport){P.warn("No MCP transport configured for toolCall");return}let n=e.tool,r=dt(e.arguments,t);try{let o=await t.transport.callTool(n,r);if(e.resultKey!=null)t.store.set(e.resultKey,o);let s=Fe(o);if(s&&t.remount)t.remount(s);else Be(o,t),t.rerender();await de(e.onSuccess,t,{$result:o})}catch(o){await Ie("toolCall",o,e.onError,t)}}async function mr(e,t){if(!t.transport){P.warn("No MCP transport configured for sendMessage");return}await t.transport.sendMessage(je(e.message,t))}function gr(e,t){let n=e.context;if(n!=null)t.store.merge(n),t.rerender()}async function hr(e,t){let n=je(e.url,t);if(!zt(n)){P.warn(`Blocked unsafe URL in fetch: ${n}`);return}let r=e.method??"GET",o=e.headers,s=e.body!==void 0?JSON.stringify(e.body):void 0;try{let i=await globalThis.fetch(n,{method:r,headers:{"Content-Type":"application/json",...o},...s&&{body:s}}),a=await i.json().catch(()=>i.text());if(e.resultKey!=null)t.store.set(e.resultKey,a);let l=Fe(a);if(l&&t.remount)t.remount(l);else Be(a,t),t.rerender();await de(e.onSuccess,t,{$result:a})}catch(i){await Ie("fetch",i,e.onError,t)}}function br(e,t){if(typeof document>"u")return;let n=document.createElement("input");if(n.type="file",e.accept!=null)n.accept=e.accept;if(e.multiple===!0)n.multiple=!0;n.addEventListener("change",()=>{let r=Array.from(n.files??[]);if(e.resultKey!=null)t.store.set(e.resultKey,r);t.rerender(),de(e.onSuccess,t,{$result:r})}),n.click()}async function yr(e,t){let n=e.handler,r=dt(e.arguments,t);if(!t.transport){P.warn(`No transport configured for callHandler: ${n}`);return}try{let o=await t.transport.callTool(n,r);if(e.resultKey!=null)t.store.set(e.resultKey,o);let s=Fe(o);if(s&&t.remount)t.remount(s);else Be(o,t),t.rerender();await de(e.onSuccess,t,{$result:o})}catch(o){await Ie("callHandler",o,e.onError,t)}}function Cr(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:e.mode}}))}var se=new Map,vr=50,wr=2000;function xr(e,t){let{uri:n,stateKey:r}=e;if(!n||!r){P.warn("subscribe: missing uri or stateKey");return}if(se.has(n))return;if(se.size>=vr){P.warn("Max subscriptions reached, ignoring new subscribe");return}let o=(d)=>{let g=Fe(d);if(g&&t.remount)t.remount(g);else{if(!Be(d,t))t.store.set(r,d);t.rerender()}de(e.onData,t,{$data:d})};if(t.transport?.subscribe&&t.transport.capabilities?.subscriptions){let d=t.transport.subscribe(n,o);se.set(n,d);return}let s=e.fallbackTool,i=e.fallbackInterval??wr;if(!s){P.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!t.transport){P.warn("No MCP transport configured for subscribe fallback");return}let a=e.fallbackArgs??{},l=Math.max(i,Ft),c=t.transport,u=globalThis.setInterval(()=>{(async()=>{try{let d=dt(a,t),g=await c.callTool(s,d);o(g)}catch(d){Ie("subscribe",d,e.onError,t)}})()},l);se.set(n,()=>globalThis.clearInterval(u))}function kr(e){let t=e.uri;if(!t){P.warn("unsubscribe: missing uri");return}let n=se.get(t);if(n)n(),se.delete(t)}function Jt(){for(let[e,t]of se)try{t()}catch(n){P.warn(`Error cleaning up subscription '${e}':`,n)}se.clear()}function Fe(e){if(e==null||typeof e!=="object")return null;let t=e;if("$prefab"in t&&"view"in t)return t;if("structuredContent"in t){let n=t.structuredContent;if(n!=null&&typeof n==="object"){let r=n;if("$prefab"in r&&"view"in r)return r}}if("content"in t&&Array.isArray(t.content)){for(let n of t.content)if(n.type==="text"&&typeof n.text==="string")try{let r=JSON.parse(n.text);if(r!=null&&typeof r==="object"){let o=r;if("$prefab"in o&&"view"in o)return o}}catch{}}return null}function Sr(e){if(e==null||typeof e!=="object")return null;let t=e;if(at(t))return t;if("structuredContent"in t){let n=t.structuredContent;if(n!=null&&typeof n==="object"&&at(n))return n}if("content"in t&&Array.isArray(t.content)){for(let n of t.content)if(n.type==="text"&&typeof n.text==="string")try{let r=JSON.parse(n.text);if(r!=null&&typeof r==="object"&&at(r))return r}catch{}}return null}function at(e){if(!("$prefab"in e)||!("update"in e))return!1;let t=e.update;return t!=null&&typeof t==="object"&&"state"in t}function Be(e,t){let n=Sr(e);if(!n)return!1;let r=n.update;if(t.store.merge(r.state),r.actions!=null)F(j(r.actions,t),"update action");return!0}var Er=/^\s*(javascript|vbscript|data):/i;function zt(e){return!Er.test(e)}function je(e,t){if(Z(e)){let n=Q(e,t.store,t.scope);return O(n)}return O(e)}function dt(e,t){if(!e)return{};let n={};for(let[r,o]of Object.entries(e))n[r]=Z(o)?Q(o,t.store,t.scope):o;return n}async function de(e,t,n){if(e==null)return;let r={...t.scope,...n};await j(e,{...t,scope:r})}function pt(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:Oe(n);if(Array.isArray(r))t[o]=r.map((s)=>s!=null&&typeof s==="object"&&!Array.isArray(s)?pt(s):s);else if(r!=null&&typeof r==="object"&&!Array.isArray(r))t[o]=pt(r);else t[o]=r}return t}class Se{callbacks=[];track(e){this.callbacks.push(e)}flush(){for(let e of this.callbacks)try{e()}catch(t){P.warn("destroy callback error:",t)}this.callbacks=[]}get size(){return this.callbacks.length}}function Ar(e){return typeof e==="object"&&"element"in e}var Je=new Map;function p(e,t){if(Je.has(e))P.warn(`overriding existing renderer for "${e}"`);Je.set(e,t)}function ut(){return[...Je.keys()].sort()}var _t=new Set;function Wt(e){_t.clear();for(let t of e)_t.add(t)}function J(e,t){let n=pt(e);if(t.defs?.[n.type]){let s={...t.defs[n.type],...n,type:t.defs[n.type].type};return J(s,t)}let r=Je.get(n.type),o;if(r){let s=r(n,t);if(Ar(s))o=s.element,t.destroyRegistry?.track(s.destroy);else o=s}else if(o=document.createElement("div"),o.setAttribute("data-prefab-type",n.type),n.children)for(let s of n.children)o.appendChild(J(s,t));if(o instanceof HTMLElement){if(n.id)o.id=n.id;if(n.cssClass){let s=C(n.cssClass,t);if(s)o.className=(o.className?o.className+" ":"")+s}if(n.onClick!=null){if(o.addEventListener("click",()=>{F(j(n.onClick,W(t)),"onClick")}),o.tagName!=="BUTTON"&&o.tagName!=="A")o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.addEventListener("keydown",(s)=>{let i=s.key;if(i==="Enter"||i===" ")s.preventDefault(),F(j(n.onClick,W(t)),"onClick")})}}if(n.onMount){let s=n.onMount,i=W(t);queueMicrotask(()=>F(j(s,i),"onMount"))}return o}function H(e,t,n){if(!e.children)return;ie(e.children,t,n)}function ie(e,t,n){let r=0;while(r<e.length){let o=e[r];if(o.type==="If")r=Rr(e,r,t,n);else if(o.type==="Elif"||o.type==="Else")r++;else t.appendChild(J(o,n)),r++}}function Rr(e,t,n,r){let o=!1,s=t,i=e[s];if(Vt(i.condition,r))ct(i,n,r),o=!0;s++;while(s<e.length){let a=e[s];if(a.type==="Elif"){if(!o&&Vt(a.condition,r))ct(a,n,r),o=!0;s++}else if(a.type==="Else"){if(!o)ct(a,n,r);s++;break}else break}return s}function Vt(e,t){if(!e)return!1;if(Z(e))return Boolean(Q(e,t.store,t.scope));return Boolean(t.store.get(e))}function ct(e,t,n){if(!e.children)return;ie(e.children,t,n)}function C(e,t){if(Z(e)){let n=Q(e,t.store,t.scope);return O(n)}return O(e)}function K(e,t){if(Z(e))return Q(e,t.store,t.scope);return e}function W(e){return{store:e.store,transport:e.transport,scope:e.scope,rerender:e.rerender,onToast:e.onToast,remount:e.remount}}function m(e,t){let n=document.createElement(e);if(t)n.className=t;return n}function ft(e,t){return e.textContent=t,e}function Ut(){p("Column",Tr),p("Row",Nr),p("Grid",Kt),p("GridItem",Gt),p("Container",Mr),p("Div",qt),p("Span",Lr),p("Dashboard",Kt),p("DashboardItem",Gt),p("Pages",Hr),p("Page",qt),p("Detail",Pr),p("MasterDetail",$r)}function Tr(e,t){let n=m("div","pf-column");n.style.display="flex",n.style.flexDirection="column";let r=ze(e);if(r!=null)n.style.gap=`${r*4}px`;if(e.align!=null)n.style.alignItems=Xt(e.align);if(e.justify!=null)n.style.justifyContent=Yt(e.justify);return H(e,n,t),n}function Nr(e,t){let n=m("div","pf-row");n.style.display="flex",n.style.flexDirection="row";let r=ze(e);if(r!=null)n.style.gap=`${r*4}px`;if(e.align!=null)n.style.alignItems=Xt(e.align);if(e.justify!=null)n.style.justifyContent=Yt(e.justify);if(e.wrap===!0)n.style.flexWrap="wrap";return H(e,n,t),n}function Kt(e,t){let n=m("div","pf-grid");n.style.display="grid";let r=e.columns??3;n.style.gridTemplateColumns=`repeat(${r}, 1fr)`;let o=ze(e);if(o!=null)n.style.gap=`${o*4}px`;return H(e,n,t),n}function Gt(e,t){let n=m("div","pf-grid-item");if(e.colSpan!=null)n.style.gridColumn=`span ${e.colSpan}`;if(e.rowSpan!=null)n.style.gridRow=`span ${e.rowSpan}`;return H(e,n,t),n}function Mr(e,t){let n=m("div","pf-container");if(n.style.maxWidth=e.maxWidth??"1200px",n.style.margin="0 auto",e.padding!=null)n.style.padding=`${e.padding*4}px`;return H(e,n,t),n}function qt(e,t){let n=m("div","pf-div");return H(e,n,t),n}function Lr(e,t){let n=m("span","pf-span");return H(e,n,t),n}function Hr(e,t){let n=m("div","pf-pages");return H(e,n,t),n}function Pr(e,t){let n=m("div","pf-detail"),r=e.of!=null?K(e.of,t):void 0;if(r!=null&&r!==""&&r!==!1&&r!==0)H(e,n,t);else if(e.empty!=null){let o=e.empty;n.appendChild(J(o,t))}return n}function $r(e,t){let n=m("div","pf-master-detail");n.style.display="flex",n.style.flexDirection="row";let r=ze(e);if(r!=null)n.style.gap=`${r*4}px`;let o=e.masterWidth??"33%",s=e.children??[];if(s.length>0){let i=m("div","pf-master-detail-master");i.style.width=o,i.style.flexShrink="0",i.style.overflow="auto",i.appendChild(J(s[0],t)),n.appendChild(i)}if(s.length>1){let i=m("div","pf-master-detail-detail");i.style.flex="1",i.style.overflow="auto",i.appendChild(J(s[1],t)),n.appendChild(i)}return n}var Or=/\bgap-(\d+)\b/;function ze(e){if(e.gap!=null)return e.gap;if(typeof e.cssClass==="string"){let t=Or.exec(e.cssClass);if(t)return Number(t[1])}return null}function Xt(e){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[e]??e}function Yt(e){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[e]??e}var Dr={"&":"&","<":"<",">":">",'"':""","'":"'"};function Ee(e){return e.replace(/[&<>"']/g,(t)=>Dr[t]??t)}function Qt(){p("Heading",jr),p("H1",(e,t)=>_e(e,t,"h1")),p("H2",(e,t)=>_e(e,t,"h2")),p("H3",(e,t)=>_e(e,t,"h3")),p("H4",(e,t)=>_e(e,t,"h4")),p("Text",Ir),p("P",Fr),p("Lead",(e,t)=>he(e,t,"p","pf-lead")),p("Large",(e,t)=>he(e,t,"span","pf-large")),p("Small",(e,t)=>he(e,t,"small","pf-small")),p("Muted",(e,t)=>he(e,t,"p","pf-muted")),p("BlockQuote",(e,t)=>he(e,t,"blockquote","pf-blockquote")),p("Label",(e,t)=>he(e,t,"label","pf-label")),p("Link",Jr),p("Code",zr),p("Markdown",_r),p("Kbd",Vr)}function jr(e,t){let n=e.level??2,r=`h${Math.min(Math.max(n,1),6)}`,o=document.createElement(r);return o.className=`pf-heading pf-${r}`,o.textContent=C(e.content,t),o}function _e(e,t,n){let r=document.createElement(n);return r.className=`pf-heading pf-${n}`,r.textContent=C(e.content,t),r}function Ir(e,t){return ft(m("span","pf-text"),C(e.content,t))}function Fr(e,t){return ft(m("p","pf-p"),C(e.content,t))}function he(e,t,n,r){let o=document.createElement(n);return o.className=r,o.textContent=C(e.content,t),o}var Br=/^\s*(javascript|vbscript|data):/i;function Jr(e,t){let n=document.createElement("a");if(n.className="pf-link",n.textContent=C(e.content,t),e.href!=null){let r=C(e.href,t);if(!Br.test(r))n.href=r}if(e.target!=null)n.target=C(e.target,t);return n}function zr(e,t){let n=m("pre","pf-code"),r=m("code");if(r.textContent=C(e.content,t),e.language!=null)r.setAttribute("data-language",e.language);return n.appendChild(r),n}function _r(e,t){let n=m("div","pf-markdown"),r=C(e.content,t);return n.innerHTML=en(r),n.setAttribute("data-markdown","true"),n}var Zt=/^\s*(javascript|vbscript|data):/i;function Ve(e){let t=Ee(e),n=[];return t=t.replace(/`([^`]+)`/g,(r,o)=>(n.push(`<code>${o}</code>`),`CODE${n.length-1}`)),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(r,o,s)=>{if(Zt.test(s))return Ee(o);return`<img src="${s}" alt="${o}" />`}),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,o,s)=>{if(Zt.test(s))return o;return`<a href="${s}">${o}</a>`}),t=t.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),t=t.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),t=t.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),t=t.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),t=t.replace(/\*(.+?)\*/g,"<em>$1</em>"),t=t.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),t=t.replace(/~~(.+?)~~/g,"<del>$1</del>"),t=t.replace(/\uFDD0CODE(\d+)\uFDD0/g,(r,o)=>n[parseInt(o)]),t}function en(e){let t=e.replace(/\r\n?/g,`
|
|
1
|
+
(()=>{var{defineProperty:ot,getOwnPropertyNames:Jn,getOwnPropertyDescriptor:Vn}=Object,zn=Object.prototype.hasOwnProperty;function _n(e){return this[e]}var Wn=(e)=>{var t=($t??=new WeakMap).get(e),n;if(t)return t;if(t=ot({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var r of Jn(e))if(!zn.call(t,r))ot(t,r,{get:_n.bind(e,r),enumerable:!(n=Vn(e,r))||n.enumerable})}return $t.set(e,t),t},$t;var Kn=(e)=>e;function Gn(e,t){this[e]=Kn.bind(null,t)}var qn=(e,t)=>{for(var n in t)ot(e,n,{get:t[n],enumerable:!0,configurable:!0,set:Gn.bind(t,n)})};var Pi={};qn(Pi,{Bridge:()=>ge,DestroyRegistry:()=>Re,PrefabRenderer:()=>ne,app:()=>rt,applyHostTheme:()=>Le,createLogger:()=>st,createThemeToggle:()=>Me,getLogLevel:()=>Dt,isIframe:()=>xe,isValidWireFormat:()=>On,listPipes:()=>Pe,log:()=>O,registerComponent:()=>p,registerPipe:()=>Ae,setLogLevel:()=>He,unregisterPipe:()=>Ee,validateWireFormat:()=>ke});var Ot={silent:0,error:1,warn:2,info:3,debug:4},it="warn";function He(e){it=e}function Dt(){return it}function st(e){let t=e?`[prefab:${e}]`:"[prefab]",n=(r,o,i)=>{if(Ot[r]>Ot[it])return;console[r](`${t} ${o}`,...i)};return{error:(r,...o)=>n("error",r,o),warn:(r,...o)=>n("warn",r,o),info:(r,...o)=>n("info",r,o),debug:(r,...o)=>n("debug",r,o)}}var O=st();class Se{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor(e){if(e)this.data=structuredClone(e)}get(e){return Un(this.data,e)}getAll(){return this.data}set(e,t){jt(this.data,e,t),this.notify(e)}toggle(e){let t=this.get(e),n=t==null||t===!1||t===0||t==="";this.set(e,n)}append(e,t,n){let r=this.get(e);if(!Array.isArray(r)){this.set(e,[t]);return}if(n!==void 0)r.splice(n,0,t);else r.push(t);this.notify(e)}pop(e,t){let n=this.get(e);if(!Array.isArray(n))return;if(typeof t==="number")n.splice(t,1);else{let r=n.indexOf(t);if(r>=0)n.splice(r,1)}this.notify(e)}merge(e){for(let[t,n]of Object.entries(e))jt(this.data,t,n);for(let t of Object.keys(e))this.notify(t)}subscribe(e,t){if(!this.subscribers.has(e))this.subscribers.set(e,new Set);return this.subscribers.get(e)?.add(t),()=>this.subscribers.get(e)?.delete(t)}subscribeAll(e){return this.globalSubscribers.add(e),()=>this.globalSubscribers.delete(e)}notify(e){this.generation++;let t=e.split(".");for(let n=1;n<=t.length;n++){let r=t.slice(0,n).join("."),o=this.subscribers.get(r);if(o)o.forEach((i)=>i())}this.globalSubscribers.forEach((n)=>n())}}function Un(e,t){let n=t.split("."),r=e;for(let o of n){if(r==null||typeof r!=="object")return;r=r[o]}return r}var Xn=new Set(["__proto__","constructor","prototype"]);function jt(e,t,n){let r=t.split(".");if(r.some((i)=>Xn.has(i))){O.warn(`Blocked prototype pollution attempt: ${t}`);return}let o=e;for(let i=0;i<r.length-1;i++){let s=r[i];if(o[s]==null||typeof o[s]!=="object")o[s]={};o=o[s]}o[r[r.length-1]]=n}var he=new Map;function Ae(e,t){if(he.has(e)&&he.get(e)!==t)O.warn(`pipe "${e}" re-registered`);he.set(e,t)}function Ee(e){return he.delete(e)}function Pe(){return[...he.keys()]}function $e(e){return he.get(e)}function L(e){if(e==null)return"";if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean"||typeof e==="bigint")return String(e);if(typeof e==="symbol")return e.description??"";if(typeof e==="function")return e.name;if(e instanceof Date)return Number.isNaN(e.getTime())?"":e.toISOString();if(Array.isArray(e))return e.map(L).join(", ");try{return JSON.stringify(e)??""}catch{return""}}var It=-1,at=new Map,Yn=/\{\{\s*(.+?)\s*\}\}/g;function Z(e){return typeof e==="string"&&e.includes("{{")&&e.includes("}}")}function Q(e,t,n){let r=e.trim();if(r.startsWith("{{")&&r.endsWith("}}")&&or(r,"{{")===1){let o=r.slice(2,-2).trim();return Ft(o,t,n)}return e.replace(Yn,(o,i)=>{let s=Ft(i.trim(),t,n);return L(s)})}function Ft(e,t,n){let[r,...o]=rr(e),i=Y(r.trim(),t,n);for(let s of o)i=Zn(s.trim(),i,t,n);return i}function Y(e,t,n){let r=tr(e);if(r>=0){let s=e.slice(0,r).trim(),a=e.slice(r+1),l=nr(a);if(l>=0){let d=a.slice(0,l).trim(),u=a.slice(l+1).trim(),c=Y(s,t,n);return c!==null&&c!==void 0&&c!==!1&&c!==0&&c!==""?Y(d,t,n):Y(u,t,n)}}let o=Oe(e,"||");if(o>=0){let s=Y(e.slice(0,o).trim(),t,n);return s!==null&&s!==void 0&&s!==!1&&s!==0&&s!==""?s:Y(e.slice(o+2).trim(),t,n)}let i=Oe(e,"&&");if(i>=0){let s=Y(e.slice(0,i).trim(),t,n);if(s===null||s===void 0||s===!1||s===0||s==="")return s;return Y(e.slice(i+2).trim(),t,n)}for(let[s,a]of Qn){let l=Oe(e,s);if(l>=0){let d=Y(e.slice(0,l).trim(),t,n),u=Y(e.slice(l+s.length).trim(),t,n);return a(d,u)}}if(e.startsWith("!")){let s=Y(e.slice(1).trim(),t,n);return s===null||s===void 0||s===!1||s===0||s===""}for(let[s,a]of er){let l=Oe(e,s);if(l>=0){let d=Y(e.slice(0,l).trim(),t,n),u=Y(e.slice(l+s.length).trim(),t,n);return a(Number(d),Number(u))}}if(e==="true")return!0;if(e==="false")return!1;if(e==="null"||e==="undefined")return null;if(/^-?\d+(\.\d+)?$/.test(e))return Number(e);if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);if(n&&e.startsWith("$")){let s=e.indexOf(".");if(s>=0){let a=e.slice(0,s),l=e.slice(s+1),d=n[a];return De(d,l)}return n[e]}if(n){let s=e.split(".")[0];if(s in n)return De(n[s],e.includes(".")?e.slice(s.length+1):"")}return t.get(e)}function Zn(e,t,n,r){let o=e.indexOf(":"),i=o>=0?e.slice(0,o).trim():e,s=o>=0?e.slice(o+1).trim():void 0,a=s?lt(s):void 0;switch(i){case"find":{if(!Array.isArray(t)||!s)return;let l=Bt(s);if(l.length<2)return;let d=lt(l[0]),u=l[1].trim(),c;if(u.startsWith("'")&&u.endsWith("'")||u.startsWith('"')&&u.endsWith('"'))c=u.slice(1,-1);else if(n){if(r&&u.startsWith("$")){let f=u.indexOf(".");if(f>=0){let b=u.slice(0,f);if(b in r)c=De(r[b],u.slice(f+1))}else if(u in r)c=r[u]}if(c===void 0&&!(r&&u.startsWith("$")))if(r){let f=u.split(".")[0];c=f in r?De(r[f],u.includes(".")?u.slice(f.length+1):""):n.get(u)}else c=n.get(u)}else c=u;if(c==null)return;let g=n?.generation??0;if(g!==It)at=new Map,It=g;let h=at.get(t);if(!h)h=new Map,at.set(t,h);let y=h.get(d);if(!y){y=new Map;for(let f of t)if(f!=null&&typeof f==="object"){let b=f[d];if(b!=null)y.set(L(b),f)}h.set(d,y)}return y.get(L(c))}case"dot":{if(t==null||typeof t!=="object"||typeof a!=="string")return;return t[a]}case"length":return Array.isArray(t)?t.length:typeof t==="string"?t.length:0;case"upper":return typeof t==="string"?t.toUpperCase():t;case"lower":return typeof t==="string"?t.toLowerCase():t;case"truncate":if(typeof t==="string"&&typeof a==="number")return t.slice(0,a);return t;case"join":return Array.isArray(t)?t.join(typeof a==="string"?a:", "):t;case"first":return Array.isArray(t)?t[0]:t;case"last":return Array.isArray(t)?t[t.length-1]:t;case"abs":return Math.abs(Number(t));case"round":return typeof a==="number"?Number(Number(t).toFixed(a)):Math.round(Number(t));case"number":return typeof a==="number"?Number(Number(t).toFixed(a)):Number(t);case"currency":{let l=typeof a==="string"?a:"USD";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:l}).format(Number(t))}catch{return t}}case"percent":return typeof a==="number"?`${(Number(t)*100).toFixed(a)}%`:`${Math.round(Number(t)*100)}%`;case"compact":{let l=typeof a==="number"?a:1;try{return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:l}).format(Number(t))}catch{return t}}case"date":try{return new Date(t).toLocaleDateString()}catch{return t}case"time":try{return new Date(t).toLocaleTimeString()}catch{return t}case"datetime":try{return new Date(t).toLocaleString()}catch{return t}case"pluralize":{let l=Number(t),d=typeof a==="string"?a:"";return l===1?d:`${d}s`}case"default":return t==null||t===""?a:t;case"selectattr":return Array.isArray(t)&&typeof a==="string"?t.filter((l)=>l!=null&&typeof l==="object"&&Boolean(l[a])):t;case"rejectattr":return Array.isArray(t)&&typeof a==="string"?t.filter((l)=>{if(l==null||typeof l!=="object")return!1;let d=l[a];return d==null||d===!1||d===0||d===""}):t;default:{let l=$e(i);if(l){let d=s?Bt(s).map(lt):[];return l(t,...d)}return t}}}var Qn=[["!==",(e,t)=>e!==t],["===",(e,t)=>e===t],["!=",(e,t)=>e!=t],["==",(e,t)=>e==t],[">=",(e,t)=>Number(e)>=Number(t)],["<=",(e,t)=>Number(e)<=Number(t)],[">",(e,t)=>Number(e)>Number(t)],["<",(e,t)=>Number(e)<Number(t)]],er=[[" + ",(e,t)=>e+t],[" - ",(e,t)=>e-t],[" * ",(e,t)=>e*t],[" / ",(e,t)=>t!==0?e/t:0],[" % ",(e,t)=>t!==0?e%t:0]];function Oe(e,t){let n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n&&e.slice(r,r+t.length)===t)return r}return-1}function tr(e){let t=0,n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n){if(o==="(")t++;else if(o===")")t--;else if(o==="?"&&t===0)return r}}return-1}function nr(e){let t=0,n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="'"||o==='"')n=n===o?null:n??o;if(!n){if(o==="?"||o==="(")t++;else if(o===")")t--;else if(o===":"&&t===0)return r}}return-1}function rr(e){let t=[],n="",r=null;for(let o=0;o<e.length;o++){let i=e[o];if(i==="'"||i==='"')r=r===i?null:r??i;if(i==="|"&&!r)if(e[o+1]==="|")n+="||",o++;else t.push(n),n="";else n+=i}return t.push(n),t}function lt(e){let t=e.replace(/^['"]|['"]$/g,"");if(t==="true")return!0;if(t==="false")return!1;let n=Number(t);return isNaN(n)?t:n}function Bt(e){let t=[],n="",r=null;for(let o of e){if(o==="'"||o==='"')r=r===o?null:r??o;if(o===","&&!r)t.push(n),n="";else n+=o}return t.push(n),t}function De(e,t){if(!t)return e;let n=t.split("."),r=e;for(let o of n){if(r==null||typeof r!=="object")return;r=r[o]}return r}function or(e,t){let n=0,r=0;while((r=e.indexOf(t,r))!==-1)n++,r+=t.length;return n}function je(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function ct(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:je(n);if(Array.isArray(r))t[o]=r.map((i)=>i!=null&&typeof i==="object"&&!Array.isArray(i)?ct(i):i);else if(r!=null&&typeof r==="object"&&!Array.isArray(r))t[o]=ct(r);else t[o]=r}return t}async function j(e,t){let n=Array.isArray(e)?e:[e];for(let r of n)await ir(r,t)}function I(e,t){e.catch((n)=>O.error(`${t} failed:`,n))}async function Be(e,t,n,r){if(n!=null)O.debug(`${e} failed:`,t),await ce(n,r,{$error:t});else O.warn(`${e} failed:`,t)}async function ir(e,t){let n=ct(e),r=n.action;switch(r){case"setState":{sr(n,t);return}case"toggleState":{ar(n,t);return}case"appendState":{lr(n,t);return}case"popState":{dr(n,t);return}case"showToast":{cr(n,t);return}case"closeOverlay":{pr(n,t);return}case"openLink":{ur(n);return}case"setInterval":{mr(n,t);return}case"toolCall":case"callTool":return gr(n,t);case"sendMessage":return hr(n,t);case"updateContext":{br(n,t);return}case"fetch":return yr(n,t);case"openFilePicker":{Cr(n,t);return}case"callHandler":return vr(n,t);case"requestDisplayMode":{wr(n,t);return}case"subscribe":{Sr(n,t);return}case"unsubscribe":{Ar(n);return}default:O.warn(`Unknown action: ${r}`)}}function sr(e,t){let{key:n,value:r}=e;if(Z(r))r=Q(r,t.store,t.scope);t.store.set(n,r),t.rerender(),ce(e.onSuccess,t)}function ar(e,t){t.store.toggle(e.key),t.rerender()}function lr(e,t){let n=e.value??e.item;if(Z(n))n=Q(n,t.store,t.scope);t.store.append(e.key,n,e.index),t.rerender()}function dr(e,t){t.store.pop(e.key,e.index),t.rerender()}function cr(e,t){t.onToast?.({message:Fe(e.message,t),description:e.description!=null?Fe(e.description,t):void 0,variant:e.variant,duration:e.duration})}function pr(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function ur(e){if(typeof window<"u"){let t=e.url;if(!t){O.warn("openLink: missing url");return}if(!_t(t)){O.warn(`Blocked unsafe URL scheme: ${t}`);return}window.open(t,e.target??"_blank")}}var Ie=new Set,fr=20,Jt=100;function mr(e,t){let n=Math.max(e.intervalMs,Jt),r=e.onTick;if(typeof globalThis.setInterval!=="function")return;if(Ie.size>=fr){O.warn("Max intervals reached, ignoring new setInterval");return}let o=globalThis.setInterval(()=>I(j(r,t),"interval action"),n);Ie.add(o)}function Vt(){for(let e of Ie)globalThis.clearInterval(e);Ie.clear()}async function gr(e,t){if(!t.transport){O.warn("No MCP transport configured for toolCall");return}let n=e.tool,r=pt(e.arguments,t);try{let o=await t.transport.callTool(n,r);if(e.resultKey!=null)t.store.set(e.resultKey,o);let i=Je(o);if(i&&t.remount)t.remount(i);else Ve(o,t),t.rerender();await ce(e.onSuccess,t,{$result:o})}catch(o){await Be("toolCall",o,e.onError,t)}}async function hr(e,t){if(!t.transport){O.warn("No MCP transport configured for sendMessage");return}await t.transport.sendMessage(Fe(e.message,t))}function br(e,t){let n=e.context;if(n!=null)t.store.merge(n),t.rerender()}async function yr(e,t){let n=Fe(e.url,t);if(!_t(n)){O.warn(`Blocked unsafe URL in fetch: ${n}`);return}let r=e.method??"GET",o=e.headers,i=e.body!==void 0?JSON.stringify(e.body):void 0;try{let s=await globalThis.fetch(n,{method:r,headers:{"Content-Type":"application/json",...o},...i&&{body:i}}),a=await s.json().catch(()=>s.text());if(e.resultKey!=null)t.store.set(e.resultKey,a);let l=Je(a);if(l&&t.remount)t.remount(l);else Ve(a,t),t.rerender();await ce(e.onSuccess,t,{$result:a})}catch(s){await Be("fetch",s,e.onError,t)}}function Cr(e,t){if(typeof document>"u")return;let n=document.createElement("input");if(n.type="file",e.accept!=null)n.accept=e.accept;if(e.multiple===!0)n.multiple=!0;n.addEventListener("change",()=>{let r=Array.from(n.files??[]);if(e.resultKey!=null)t.store.set(e.resultKey,r);t.rerender(),ce(e.onSuccess,t,{$result:r})}),n.click()}async function vr(e,t){let n=e.handler,r=pt(e.arguments,t);if(!t.transport){O.warn(`No transport configured for callHandler: ${n}`);return}try{let o=await t.transport.callTool(n,r);if(e.resultKey!=null)t.store.set(e.resultKey,o);let i=Je(o);if(i&&t.remount)t.remount(i);else Ve(o,t),t.rerender();await ce(e.onSuccess,t,{$result:o})}catch(o){await Be("callHandler",o,e.onError,t)}}function wr(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:e.mode}}))}var ie=new Map,xr=50,kr=2000;function Sr(e,t){let{uri:n,stateKey:r}=e;if(!n||!r){O.warn("subscribe: missing uri or stateKey");return}if(ie.has(n))return;if(ie.size>=xr){O.warn("Max subscriptions reached, ignoring new subscribe");return}let o=(c)=>{let g=Je(c);if(g&&t.remount)t.remount(g);else{if(!Ve(c,t))t.store.set(r,c);t.rerender()}ce(e.onData,t,{$data:c})};if(t.transport?.subscribe&&t.transport.capabilities?.subscriptions){let c=t.transport.subscribe(n,o);ie.set(n,c);return}let i=e.fallbackTool,s=e.fallbackInterval??kr;if(!i){O.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!t.transport){O.warn("No MCP transport configured for subscribe fallback");return}let a=e.fallbackArgs??{},l=Math.max(s,Jt),d=t.transport,u=globalThis.setInterval(()=>{(async()=>{try{let c=pt(a,t),g=await d.callTool(i,c);o(g)}catch(c){Be("subscribe",c,e.onError,t)}})()},l);ie.set(n,()=>globalThis.clearInterval(u))}function Ar(e){let t=e.uri;if(!t){O.warn("unsubscribe: missing uri");return}let n=ie.get(t);if(n)n(),ie.delete(t)}function zt(){for(let[e,t]of ie)try{t()}catch(n){O.warn(`Error cleaning up subscription '${e}':`,n)}ie.clear()}function Je(e){if(e==null||typeof e!=="object")return null;let t=e;if("$prefab"in t&&"view"in t)return t;if("structuredContent"in t){let n=t.structuredContent;if(n!=null&&typeof n==="object"){let r=n;if("$prefab"in r&&"view"in r)return r}}if("content"in t&&Array.isArray(t.content)){for(let n of t.content)if(n.type==="text"&&typeof n.text==="string")try{let r=JSON.parse(n.text);if(r!=null&&typeof r==="object"){let o=r;if("$prefab"in o&&"view"in o)return o}}catch{}}return null}function Er(e){if(e==null||typeof e!=="object")return null;let t=e;if(dt(t))return t;if("structuredContent"in t){let n=t.structuredContent;if(n!=null&&typeof n==="object"&&dt(n))return n}if("content"in t&&Array.isArray(t.content)){for(let n of t.content)if(n.type==="text"&&typeof n.text==="string")try{let r=JSON.parse(n.text);if(r!=null&&typeof r==="object"&&dt(r))return r}catch{}}return null}function dt(e){if(!("$prefab"in e)||!("update"in e))return!1;let t=e.update;return t!=null&&typeof t==="object"&&"state"in t}function Ve(e,t){let n=Er(e);if(!n)return!1;let r=n.update;if(t.store.merge(r.state),r.actions!=null)I(j(r.actions,t),"update action");return!0}var Rr=/^\s*(javascript|vbscript|data):/i;function _t(e){return!Rr.test(e)}function Fe(e,t){if(Z(e)){let n=Q(e,t.store,t.scope);return L(n)}return L(e)}function pt(e,t){if(!e)return{};let n={};for(let[r,o]of Object.entries(e))n[r]=Z(o)?Q(o,t.store,t.scope):o;return n}async function ce(e,t,n){if(e==null)return;let r={...t.scope,...n};await j(e,{...t,scope:r})}function ft(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:je(n);if(Array.isArray(r))t[o]=r.map((i)=>i!=null&&typeof i==="object"&&!Array.isArray(i)?ft(i):i);else if(r!=null&&typeof r==="object"&&!Array.isArray(r))t[o]=ft(r);else t[o]=r}return t}class Re{callbacks=[];track(e){this.callbacks.push(e)}flush(){for(let e of this.callbacks)try{e()}catch(t){O.warn("destroy callback error:",t)}this.callbacks=[]}get size(){return this.callbacks.length}}function Tr(e){return typeof e==="object"&&"element"in e}var ze=new Map;function p(e,t){if(ze.has(e))O.warn(`overriding existing renderer for "${e}"`);ze.set(e,t)}function mt(){return[...ze.keys()].sort()}var Wt=new Set;function Gt(e){Wt.clear();for(let t of e)Wt.add(t)}function J(e,t){let n=ft(e);if(t.defs?.[n.type]){let i={...t.defs[n.type],...n,type:t.defs[n.type].type};return J(i,t)}let r=ze.get(n.type),o;if(r){let i=r(n,t);if(Tr(i))o=i.element,t.destroyRegistry?.track(i.destroy);else o=i}else if(o=document.createElement("div"),o.setAttribute("data-prefab-type",n.type),n.children)for(let i of n.children)o.appendChild(J(i,t));if(o instanceof HTMLElement){if(n.id)o.id=n.id;if(n.cssClass){let i=C(n.cssClass,t);if(i)o.className=(o.className?o.className+" ":"")+i}if(n.onClick!=null){if(o.addEventListener("click",()=>{I(j(n.onClick,W(t)),"onClick")}),o.tagName!=="BUTTON"&&o.tagName!=="A")o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.addEventListener("keydown",(i)=>{let s=i.key;if(s==="Enter"||s===" ")i.preventDefault(),I(j(n.onClick,W(t)),"onClick")})}}if(n.onMount){let i=n.onMount,s=W(t);queueMicrotask(()=>I(j(i,s),"onMount"))}return o}function H(e,t,n){if(!e.children)return;se(e.children,t,n)}function se(e,t,n){let r=0;while(r<e.length){let o=e[r];if(o.type==="If")r=Nr(e,r,t,n);else if(o.type==="Elif"||o.type==="Else")r++;else t.appendChild(J(o,n)),r++}}function Nr(e,t,n,r){let o=!1,i=t,s=e[i];if(Kt(s.condition,r))ut(s,n,r),o=!0;i++;while(i<e.length){let a=e[i];if(a.type==="Elif"){if(!o&&Kt(a.condition,r))ut(a,n,r),o=!0;i++}else if(a.type==="Else"){if(!o)ut(a,n,r);i++;break}else break}return i}function Kt(e,t){if(!e)return!1;if(Z(e))return Boolean(Q(e,t.store,t.scope));return Boolean(t.store.get(e))}function ut(e,t,n){if(!e.children)return;se(e.children,t,n)}function C(e,t){if(Z(e)){let n=Q(e,t.store,t.scope);return L(n)}return L(e)}function K(e,t){if(Z(e))return Q(e,t.store,t.scope);return e}function W(e){return{store:e.store,transport:e.transport,scope:e.scope,rerender:e.rerender,onToast:e.onToast,remount:e.remount}}function m(e,t){let n=document.createElement(e);if(t)n.className=t;return n}function gt(e,t){return e.textContent=t,e}function Yt(){p("Column",Mr),p("Row",Lr),p("Grid",qt),p("GridItem",Ut),p("Container",Hr),p("Div",Xt),p("Span",Pr),p("Dashboard",qt),p("DashboardItem",Ut),p("Pages",$r),p("Page",Xt),p("Detail",Or),p("MasterDetail",Dr)}function Mr(e,t){let n=m("div","pf-column");n.style.display="flex",n.style.flexDirection="column";let r=_e(e);if(r!=null)n.style.gap=`${r*4}px`;if(e.align!=null)n.style.alignItems=Zt(e.align);if(e.justify!=null)n.style.justifyContent=Qt(e.justify);return H(e,n,t),n}function Lr(e,t){let n=m("div","pf-row");n.style.display="flex",n.style.flexDirection="row";let r=_e(e);if(r!=null)n.style.gap=`${r*4}px`;if(e.align!=null)n.style.alignItems=Zt(e.align);if(e.justify!=null)n.style.justifyContent=Qt(e.justify);if(e.wrap===!0)n.style.flexWrap="wrap";return H(e,n,t),n}function qt(e,t){let n=m("div","pf-grid");n.style.display="grid";let r=e.columns??3;n.style.gridTemplateColumns=`repeat(${r}, 1fr)`;let o=_e(e);if(o!=null)n.style.gap=`${o*4}px`;return H(e,n,t),n}function Ut(e,t){let n=m("div","pf-grid-item");if(e.colSpan!=null)n.style.gridColumn=`span ${e.colSpan}`;if(e.rowSpan!=null)n.style.gridRow=`span ${e.rowSpan}`;return H(e,n,t),n}function Hr(e,t){let n=m("div","pf-container");if(n.style.maxWidth=e.maxWidth??"1200px",n.style.margin="0 auto",e.padding!=null)n.style.padding=`${e.padding*4}px`;return H(e,n,t),n}function Xt(e,t){let n=m("div","pf-div");return H(e,n,t),n}function Pr(e,t){let n=m("span","pf-span");return H(e,n,t),n}function $r(e,t){let n=m("div","pf-pages");return H(e,n,t),n}function Or(e,t){let n=m("div","pf-detail"),r=e.of!=null?K(e.of,t):void 0;if(r!=null&&r!==""&&r!==!1&&r!==0)H(e,n,t);else if(e.empty!=null){let o=e.empty;n.appendChild(J(o,t))}return n}function Dr(e,t){let n=m("div","pf-master-detail");n.style.display="flex",n.style.flexDirection="row";let r=_e(e);if(r!=null)n.style.gap=`${r*4}px`;let o=e.masterWidth??"33%",i=e.children??[];if(i.length>0){let s=m("div","pf-master-detail-master");s.style.width=o,s.style.flexShrink="0",s.style.overflow="auto",s.appendChild(J(i[0],t)),n.appendChild(s)}if(i.length>1){let s=m("div","pf-master-detail-detail");s.style.flex="1",s.style.overflow="auto",s.appendChild(J(i[1],t)),n.appendChild(s)}return n}var jr=/\bgap-(\d+)\b/;function _e(e){if(e.gap!=null)return e.gap;if(typeof e.cssClass==="string"){let t=jr.exec(e.cssClass);if(t)return Number(t[1])}return null}function Zt(e){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[e]??e}function Qt(e){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[e]??e}var Ir={"&":"&","<":"<",">":">",'"':""","'":"'"};function Te(e){return e.replace(/[&<>"']/g,(t)=>Ir[t]??t)}function tn(){p("Heading",Fr),p("H1",(e,t)=>We(e,t,"h1")),p("H2",(e,t)=>We(e,t,"h2")),p("H3",(e,t)=>We(e,t,"h3")),p("H4",(e,t)=>We(e,t,"h4")),p("Text",Br),p("P",Jr),p("Lead",(e,t)=>be(e,t,"p","pf-lead")),p("Large",(e,t)=>be(e,t,"span","pf-large")),p("Small",(e,t)=>be(e,t,"small","pf-small")),p("Muted",(e,t)=>be(e,t,"p","pf-muted")),p("BlockQuote",(e,t)=>be(e,t,"blockquote","pf-blockquote")),p("Label",(e,t)=>be(e,t,"label","pf-label")),p("Link",zr),p("Code",_r),p("Markdown",Wr),p("Kbd",Kr)}function Fr(e,t){let n=e.level??2,r=`h${Math.min(Math.max(n,1),6)}`,o=document.createElement(r);return o.className=`pf-heading pf-${r}`,o.textContent=C(e.content,t),o}function We(e,t,n){let r=document.createElement(n);return r.className=`pf-heading pf-${n}`,r.textContent=C(e.content,t),r}function Br(e,t){return gt(m("span","pf-text"),C(e.content,t))}function Jr(e,t){return gt(m("p","pf-p"),C(e.content,t))}function be(e,t,n,r){let o=document.createElement(n);return o.className=r,o.textContent=C(e.content,t),o}var Vr=/^\s*(javascript|vbscript|data):/i;function zr(e,t){let n=document.createElement("a");if(n.className="pf-link",n.textContent=C(e.content,t),e.href!=null){let r=C(e.href,t);if(!Vr.test(r))n.href=r}if(e.target!=null)n.target=C(e.target,t);return n}function _r(e,t){let n=m("pre","pf-code"),r=m("code");if(r.textContent=C(e.content,t),e.language!=null)r.setAttribute("data-language",e.language);return n.appendChild(r),n}function Wr(e,t){let n=m("div","pf-markdown"),r=C(e.content,t);return n.innerHTML=nn(r),n.setAttribute("data-markdown","true"),n}var en=/^\s*(javascript|vbscript|data):/i;function Ke(e){let t=Te(e),n=[];return t=t.replace(/`([^`]+)`/g,(r,o)=>(n.push(`<code>${o}</code>`),`CODE${n.length-1}`)),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(r,o,i)=>{if(en.test(i))return Te(o);return`<img src="${i}" alt="${o}" />`}),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,o,i)=>{if(en.test(i))return o;return`<a href="${i}">${o}</a>`}),t=t.replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>"),t=t.replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>"),t=t.replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>"),t=t.replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>"),t=t.replace(/\*(.+?)\*/g,"<em>$1</em>"),t=t.replace(/(?<!\w)_(.+?)_(?!\w)/g,"<em>$1</em>"),t=t.replace(/~~(.+?)~~/g,"<del>$1</del>"),t=t.replace(/\uFDD0CODE(\d+)\uFDD0/g,(r,o)=>n[parseInt(o)]),t}function nn(e){let t=e.replace(/\r\n?/g,`
|
|
2
2
|
`).split(`
|
|
3
|
-
`),n=[],r=0;while(r<t.length){let o=t[r];if(o.trimStart().startsWith("```")){let a=o.trimStart().slice(3).trim(),l=[];r++;while(r<t.length&&!t[r].trimStart().startsWith("```"))l.push(
|
|
4
|
-
`)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(o)){n.push("<hr />"),r++;continue}let
|
|
5
|
-
`))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(o)){n.push("<ul>");while(r<t.length&&/^[\s]*[-*+]\s+/.test(t[r]))n.push(`<li>${
|
|
6
|
-
`)}function Vr(e,t){let n=document.createElement("kbd");return n.className="pf-kbd",n.textContent=C(e.content,t),n}function nn(){p("Card",Wr),p("CardHeader",mt("pf-card-header")),p("CardTitle",tn("pf-card-title","h3")),p("CardDescription",tn("pf-card-description","p")),p("CardContent",mt("pf-card-content")),p("CardFooter",mt("pf-card-footer"))}function Wr(e,t){let n=m("div","pf-card");return n.style.overflow="hidden",H(e,n,t),n}function mt(e){return(t,n)=>{let r=m("div",e);return r.style.padding="16px 24px",H(t,r,n),r}}function tn(e,t){return(n,r)=>{let o=document.createElement(t);return o.className=e,o.textContent=C(n.content,r),o}}function rn(){p("DataTable",Kr),p("Badge",Gr),p("Dot",qr),p("Metric",Ur),p("Ring",Xr),p("Progress",Yr),p("Separator",Zr),p("Loader",Qr),p("Icon",eo),p("Sparkline",to)}function Kr(e,t){let n=m("div","pf-datatable-wrapper"),r=document.createElement("table");r.className="pf-datatable",r.style.width="100%",r.style.borderCollapse="collapse";let o=e.columns??[],s=K(e.rows,t),i=e.rowKey,a=e.selected,l=document.createElement("thead"),c=document.createElement("tr");for(let d of o){let g=document.createElement("th");g.className="pf-datatable-th",g.textContent=d.header??d.key,g.style.padding="8px 12px",g.style.textAlign="left",c.appendChild(g)}l.appendChild(c),r.appendChild(l);let u=document.createElement("tbody");if(Array.isArray(s)){let d=a!=null?K(a,t):void 0;for(let g of s){let h=document.createElement("tr");h.className="pf-datatable-row";let y=g,f=g===null||typeof g!=="object";if(i&&d!=null&&y[i]!=null&&O(y[i])===O(d))h.classList.add("pf-datatable-row-selected");if(e.onRowClick!=null&&i)h.style.cursor="pointer",h.addEventListener("click",()=>{let b={...t.scope,$item:y,$index:s.indexOf(g)},w=W({...t,scope:b});F(j(e.onRowClick,w),"onRowClick")});for(let b of o){let w=document.createElement("td");w.className="pf-datatable-td";let S;if(b.accessor)S=K(`{{ $item.${b.accessor} }}`,{...t,scope:{...t.scope,$item:y}});else if(S=f?g:y[b.key],b.format&&S!=null)S=K(`{{ __fmtVal | ${b.format} }}`,{...t,scope:{...t.scope,__fmtVal:S}});w.textContent=O(S),w.style.padding="8px 12px",h.appendChild(w)}u.appendChild(h)}}if(r.appendChild(u),e.search===!0){let d=document.createElement("input");d.type="text",d.placeholder="Search...",d.className="pf-datatable-search",d.style.marginBottom="8px",d.style.padding="6px 12px",d.style.width="100%",d.style.boxSizing="border-box",d.addEventListener("input",()=>{let g=d.value.toLowerCase(),h=Array.from(u.querySelectorAll("tr"));for(let y of h){let f=(y.textContent??"").toLowerCase();y.style.display=f.includes(g)?"":"none"}}),n.appendChild(d)}return n.appendChild(r),n}function Gr(e,t){let n=m("span","pf-badge"),r=e.variant??"default";return n.setAttribute("data-variant",r),n.style.alignItems="center",n.style.padding="2px 10px",n.style.borderRadius="9999px",n.style.fontSize="12px",n.style.fontWeight="500",n.textContent=C(e.label??e.content,t),no(n,r),n}function qr(e,t){let n=m("span","pf-dot"),r=e.color??"gray";return n.style.display="inline-block",n.style.width="8px",n.style.height="8px",n.style.borderRadius="50%",n.style.backgroundColor=r,n}function Ur(e,t){let n=m("div","pf-metric"),r=m("div","pf-metric-label");r.textContent=C(e.label,t),r.style.fontSize="14px",n.appendChild(r);let o=m("div","pf-metric-value");if(o.textContent=C(e.value,t),o.style.fontSize="28px",o.style.fontWeight="700",n.appendChild(o),e.delta!=null){let s=m("span","pf-metric-delta");s.textContent=C(e.delta,t);let i=e.trend??"",a=e.trendSentiment??"neutral";if(s.style.fontSize="14px",s.style.color=a==="positive"?"green":a==="negative"?"red":"inherit",i==="up")s.textContent="↑ "+s.textContent;else if(i==="down")s.textContent="↓ "+s.textContent;n.appendChild(s)}if(e.description!=null){let s=m("div","pf-metric-desc");s.textContent=C(e.description,t),s.style.fontSize="12px",n.appendChild(s)}return n}function Xr(e,t){let n=m("div","pf-ring"),r=e.size??80,o=e.thickness??8,s=Number(K(e.value,t)??0),i=Math.max(0,Math.min(100,s)),a=(r-o)/2,l=2*Math.PI*a,c=l*(1-i/100),u=document.createElementNS("http://www.w3.org/2000/svg","svg");u.setAttribute("width",String(r)),u.setAttribute("height",String(r)),u.setAttribute("viewBox",`0 0 ${r} ${r}`);let d=document.createElementNS("http://www.w3.org/2000/svg","circle");d.setAttribute("cx",String(r/2)),d.setAttribute("cy",String(r/2)),d.setAttribute("r",String(a)),d.setAttribute("fill","none"),d.setAttribute("stroke","var(--muted, #e5e7eb)"),d.setAttribute("stroke-width",String(o));let g=document.createElementNS("http://www.w3.org/2000/svg","circle");if(g.setAttribute("cx",String(r/2)),g.setAttribute("cy",String(r/2)),g.setAttribute("r",String(a)),g.setAttribute("fill","none"),g.setAttribute("stroke","var(--primary, #3b82f6)"),g.setAttribute("stroke-width",String(o)),g.setAttribute("stroke-dasharray",String(l)),g.setAttribute("stroke-dashoffset",String(c)),g.setAttribute("stroke-linecap","round"),g.style.transform="rotate(-90deg)",g.style.transformOrigin="center",u.appendChild(d),u.appendChild(g),n.appendChild(u),e.label!=null){let h=m("div","pf-ring-label");h.textContent=C(e.label,t),h.style.textAlign="center",h.style.fontSize="12px",n.appendChild(h)}return n}function Yr(e,t){let n=m("div","pf-progress");n.setAttribute("role","progressbar");let r=Number(K(e.value,t)??0),o=e.max??100,s=o>0?Math.max(0,Math.min(100,r/o*100)):0;n.setAttribute("aria-valuenow",String(r)),n.setAttribute("aria-valuemin","0"),n.setAttribute("aria-valuemax",String(o)),n.style.height="8px",n.style.borderRadius="4px",n.style.overflow="hidden";let i=m("div","pf-progress-fill");return i.style.height="100%",i.style.width=`${s}%`,i.style.borderRadius="4px",i.style.transition="width 0.3s ease",n.appendChild(i),n}function Zr(e,t){let n=document.createElement("hr");return n.className="pf-separator",n.style.border="none",n.style.margin="8px 0",n}function Qr(e,t){let n=m("div","pf-loader");return n.textContent="⏳",n.style.display="flex",n.style.justifyContent="center",n.style.padding="16px",n}function eo(e,t){let n=m("span","pf-icon");return n.setAttribute("data-icon",C(e.name??e.content,t)),n}function to(e,t){let n=m("div","pf-sparkline"),r=e.data??[];if(r.length===0)return n;let o=e.width??120,s=e.height??32,i=Math.max(...r),a=Math.min(...r),l=i-a||1,c=document.createElementNS("http://www.w3.org/2000/svg","svg");c.setAttribute("width",String(o)),c.setAttribute("height",String(s)),c.setAttribute("viewBox",`0 0 ${o} ${s}`);let u=r.length>1?r.length-1:1,d=r.map((h,y)=>{let f=y/u*o,b=s-(h-a)/l*(s-4)-2;return`${f},${b}`}).join(" "),g=document.createElementNS("http://www.w3.org/2000/svg","polyline");return g.setAttribute("points",d),g.setAttribute("fill","none"),g.setAttribute("stroke","var(--primary, #3b82f6)"),g.setAttribute("stroke-width","1.5"),c.appendChild(g),n.appendChild(c),n}function no(e,t){let r={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[t];if(r)e.style.backgroundColor=r.bg,e.style.color=r.fg}function sn(){p("Form",ro),p("Input",oo),p("Textarea",Ae(so)),p("Button",io),p("ButtonGroup",ao),p("Select",Ae(lo)),p("SelectOption",co),p("SelectGroup",We("pf-select-group")),p("SelectLabel",Re("pf-select-label")),p("SelectSeparator",on),p("Checkbox",po),p("Switch",uo),p("Slider",Ae(fo)),p("Radio",go),p("RadioGroup",ho),p("Combobox",Ae(bo)),p("ComboboxOption",yo),p("ComboboxGroup",We("pf-combobox-group")),p("ComboboxLabel",Re("pf-combobox-label")),p("ComboboxSeparator",on),p("Calendar",Co),p("DatePicker",Ae(vo)),p("Field",We("pf-field")),p("FieldTitle",Re("pf-field-title")),p("FieldDescription",Re("pf-field-description")),p("FieldContent",We("pf-field-content")),p("FieldError",Re("pf-field-error")),p("ChoiceCard",wo)}function ro(e,t){let n=document.createElement("form");return n.className="pf-form",n.addEventListener("submit",(r)=>{r.preventDefault();let o=new FormData(n),s={};if(o.forEach((i,a)=>{s[a]=i}),t.store.merge(s),e.onSubmit!=null){let i=W(t);i.scope={...t.scope,...s},F(j(e.onSubmit,i),"onSubmit")}}),H(e,n,t),n}function an(e,t,n){if(t.label==null)return;let r=document.createElement("label");if(r.className="pf-input-label",r.textContent=C(t.label,n),t.name!=null)r.htmlFor=t.name;r.style.fontSize="14px",r.style.fontWeight="500",e.insertBefore(r,e.firstChild)}function Ae(e){return(t,n)=>{let r=e(t,n);return r.style.display="flex",r.style.flexDirection="column",r.style.gap="4px",an(r,t,n),r}}function oo(e,t){let n=m("div","pf-input-wrapper");n.style.display="flex",n.style.flexDirection="column",n.style.gap="4px",an(n,e,t);let r=document.createElement("input");if(r.className="pf-input",r.type=e.inputType??"text",e.name!=null)r.name=e.name;if(e.name!=null)r.id=`pf-input-${e.name}`;if(e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.required===!0)r.required=!0,r.setAttribute("aria-required","true");if(e.error!=null)r.setAttribute("aria-invalid","true");let o=e.name;if(o){let s=t.store.get(o);if(s!=null)r.value=O(s);r.addEventListener("input",()=>{if(t.store.set(o,r.value),e.onChange!=null)F(j(e.onChange,{...W(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return gt(r),n.appendChild(r),n}function so(e,t){let n=m("div","pf-textarea-wrapper"),r=document.createElement("textarea");if(r.className="pf-textarea",e.name!=null)r.name=e.name;if(e.name!=null)r.id=`pf-textarea-${e.name}`;if(e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.rows!=null)r.rows=e.rows;if(e.required===!0)r.setAttribute("aria-required","true");let o=e.name;if(o!=null){let s=t.store.get(o);if(s!=null)r.value=O(s);r.addEventListener("input",()=>{if(t.store.set(o,r.value),e.onChange!=null)F(j(e.onChange,{...W(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return gt(r),n.appendChild(r),n}function io(e,t){let n=document.createElement("button");n.className="pf-button",n.type=e.submit===!0?"submit":"button",n.textContent=C(e.label,t);let r=e.variant??"default";if(n.setAttribute("data-variant",r),mo(n,r),e.size!=null)n.setAttribute("data-size",e.size);if(e.disabled===!0)n.disabled=!0;return n}function ao(e,t){let n=m("div","pf-button-group");return n.style.display="flex",n.style.gap="8px",H(e,n,t),n}function lo(e,t){let n=m("div","pf-select-wrapper"),r=document.createElement("select");if(r.className="pf-select",e.name!=null)r.name=e.name;if(gt(r),e.placeholder!=null){let i=document.createElement("option");i.value="",i.textContent=C(e.placeholder,t),i.disabled=!0,i.selected=!0,i.hidden=!0,r.appendChild(i)}let o=e.options;if(Array.isArray(o))for(let i of o){let a=document.createElement("option");a.value=i.value??"",a.textContent=i.label??a.value,r.appendChild(a)}if(e.children)for(let i of e.children)if(i.type==="SelectOption"){let a=document.createElement("option");a.value=i.value??"",a.textContent=i.label??a.value,r.appendChild(a)}else r.appendChild(J(i,t));let s=e.name;if(s){let i=t.store.get(s);if(i!=null)r.value=O(i);r.addEventListener("change",()=>{if(t.store.set(s,r.value),e.onChange!=null)F(j(e.onChange,{...W(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return n.appendChild(r),n}function co(e,t){return m("span")}function po(e,t){let n=m("label","pf-checkbox-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="checkbox",r.className="pf-checkbox",e.name!=null)r.name=e.name;if(e.checked===!0)r.checked=!0;let o=e.name;if(o){let s=t.store.get(o);if(typeof s==="boolean")r.checked=s;r.addEventListener("change",()=>{if(t.store.set(o,r.checked),e.onChange!=null)F(j(e.onChange,{...W(t),scope:{...t.scope,$event:r.checked}}),"onChange")})}if(n.appendChild(r),e.label!=null){let s=m("span");s.textContent=C(e.label,t),n.appendChild(s)}return n}function uo(e,t){let n=m("label","pf-switch-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="checkbox",r.className="pf-switch",r.setAttribute("role","switch"),e.name!=null)r.name=e.name;let o=e.name;if(o){let s=t.store.get(o);if(typeof s==="boolean")r.checked=s;r.addEventListener("change",()=>{if(t.store.set(o,r.checked),e.onChange!=null)F(j(e.onChange,{...W(t),scope:{...t.scope,$event:r.checked}}),"onChange")})}if(n.appendChild(r),e.label!=null){let s=m("span");s.textContent=C(e.label,t),n.appendChild(s)}return n}function fo(e,t){let n=m("div","pf-slider-wrapper"),r=document.createElement("input");if(r.type="range",r.className="pf-slider",e.name!=null)r.name=e.name;if(e.min!=null)r.min=O(e.min);if(e.max!=null)r.max=O(e.max);if(e.step!=null)r.step=O(e.step);let o=e.name;if(o){let s=t.store.get(o);if(s!=null)r.value=O(s);r.addEventListener("input",()=>{if(t.store.set(o,Number(r.value)),e.onChange!=null)F(j(e.onChange,{...W(t),scope:{...t.scope,$event:Number(r.value)}}),"onChange")})}return n.appendChild(r),n}function gt(e){e.style.padding="8px 12px",e.style.fontSize="14px",e.style.width="100%",e.style.boxSizing="border-box"}function mo(e,t){if(e.style.padding="8px 16px",e.style.fontSize="14px",e.style.fontWeight="500",e.style.cursor="pointer",e.style.border="none",t==="ghost")e.style.backgroundColor="transparent",e.style.color="inherit"}function We(e){return(t,n)=>{let r=m("div",e);return H(t,r,n),r}}function Re(e){return(t,n)=>{let r=m("span",e);return r.textContent=C(t.content,n),r}}function on(){let e=document.createElement("hr");return e.className="pf-separator",e.style.border="none",e.style.margin="4px 0",e}function go(e,t){let n=m("label","pf-radio");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="radio",r.value=C(e.value,t),n.appendChild(r),e.label!=null){let o=m("span","pf-radio-label");o.textContent=C(e.label,t),n.appendChild(o)}return n}function ho(e,t){let n=m("fieldset","pf-radio-group");if(n.style.border="none",n.style.padding="0",n.style.display="flex",n.style.flexDirection="column",n.style.gap="8px",e.label!=null){let s=document.createElement("legend");s.textContent=C(e.label,t),s.style.fontWeight="500",s.style.marginBottom="4px",n.appendChild(s)}H(e,n,t);let r=C(e.name,t),o=t.store.get(r);for(let s of Array.from(n.querySelectorAll('input[type="radio"]')))if(s.name=r,o!=null&&s.value===O(o))s.checked=!0;return n.addEventListener("change",(s)=>{let i=s.target;if(i.type==="radio"){if(t.store.set(r,i.value),e.onChange!=null)F(j(e.onChange,W(t)),"onChange")}}),n}function bo(e,t){let n=m("div","pf-combobox"),r=document.createElement("input");if(r.className="pf-combobox-input",r.type="text",r.name=C(e.name,t),e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.value!==void 0)r.value=C(e.value,t);let o=r.name,s=t.store.get(o);if(s!=null)r.value=O(s);r.style.padding="6px 12px",r.style.borderRadius="6px",r.style.width="100%",r.style.boxSizing="border-box";let i=m("div","pf-combobox-dropdown");if(i.style.display="none",i.style.position="absolute",i.style.borderRadius="6px",i.style.maxHeight="200px",i.style.overflowY="auto",i.style.zIndex="50",H(e,i,t),r.addEventListener("focus",()=>{i.style.display="block"}),r.addEventListener("blur",()=>{setTimeout(()=>{i.style.display="none"},150)}),e.searchable!==!1)r.addEventListener("input",()=>{let a=r.value.toLowerCase();for(let l of Array.from(i.querySelectorAll(".pf-combobox-option"))){let c=(l.textContent??"").toLowerCase();l.style.display=c.includes(a)?"":"none"}});if(e.onChange!=null)n.addEventListener("pf-combobox-select",()=>{F(j(e.onChange,{...W(t),scope:{...t.scope,$event:r.value}}),"onChange")});return n.style.position="relative",n.appendChild(r),n.appendChild(i),n}function yo(e,t){let n=m("div","pf-combobox-option");return n.style.padding="6px 12px",n.style.cursor="pointer",n.textContent=C(e.label??e.value,t),n.dataset.value=C(e.value,t),n.addEventListener("mousedown",()=>{let r=n.closest(".pf-combobox"),o=r?.querySelector("input");if(o)o.value=n.dataset.value??"",t.store.set(o.name,o.value),r?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),n}function Co(e,t){let n=m("div","pf-calendar"),r=document.createElement("input");if(r.type="date",r.name=C(e.name,t),e.value!==void 0)r.value=C(e.value,t);let o=r.name,s=t.store.get(o);if(s!=null)r.value=O(s);if(e.minDate!=null)r.min=C(e.minDate,t);if(e.maxDate!=null)r.max=C(e.maxDate,t);return r.style.padding="6px 12px",r.style.borderRadius="6px",r.addEventListener("change",()=>{if(t.store.set(r.name,r.value),e.onChange!=null)F(j(e.onChange,W(t)),"onChange")}),n.appendChild(r),n}function vo(e,t){let n=m("div","pf-datepicker"),r=document.createElement("input");if(r.type="date",r.name=C(e.name,t),e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.value!==void 0)r.value=C(e.value,t);let o=r.name,s=t.store.get(o);if(s!=null)r.value=O(s);if(e.minDate!=null)r.min=C(e.minDate,t);if(e.maxDate!=null)r.max=C(e.maxDate,t);return r.style.padding="6px 12px",r.style.borderRadius="6px",r.style.width="100%",r.style.boxSizing="border-box",r.addEventListener("change",()=>{if(t.store.set(r.name,r.value),e.onChange!=null)F(j(e.onChange,W(t)),"onChange")}),n.appendChild(r),n}function wo(e,t){let n=m("div","pf-choice-card");if(n.style.padding="16px",n.style.cursor="pointer",n.style.transition="border-color 0.2s",n.dataset.value=C(e.value,t),e.selected===!0)n.dataset.selected="true";if(e.label!=null){let r=m("div","pf-choice-card-label");r.textContent=C(e.label,t),r.style.fontWeight="600",n.appendChild(r)}if(e.description!=null){let r=m("div","pf-choice-card-description");r.textContent=C(e.description,t),r.style.fontSize="14px",n.appendChild(r)}return H(e,n,t),n}function ln(){p("Tabs",xo),p("Tab",ko),p("Accordion",So),p("AccordionItem",Eo),p("Dialog",Ao),p("Popover",Ro),p("Tooltip",To),p("HoverCard",No),p("Carousel",Mo)}function xo(e,t){let n=m("div","pf-tabs"),r=m("div","pf-tabs-bar");r.setAttribute("role","tablist"),r.style.display="flex",r.style.gap="4px",r.style.marginBottom="12px";let o=[],s=[],i=e.children??[],a=(()=>{let c=e.defaultTab;if(typeof c==="number")return c>=0&&c<i.length?c:0;if(typeof c==="string"){let u=i.findIndex((d)=>d.title===c);return u>=0?u:0}return 0})();if(e.children)for(let c=0;c<e.children.length;c++){let u=e.children[c],d=`pf-tab-${Math.random().toString(36).slice(2,8)}`,g=`pf-panel-${Math.random().toString(36).slice(2,8)}`,h=document.createElement("button");h.type="button",h.className="pf-tab-trigger",h.textContent=u.title??`Tab ${c+1}`,h.setAttribute("role","tab"),h.setAttribute("aria-selected",c===a?"true":"false"),h.setAttribute("aria-controls",g),h.id=d,h.tabIndex=c===a?0:-1,h.style.padding="8px 16px",h.style.border="none",h.style.background="none",h.style.cursor="pointer",h.style.borderBottom="2px solid transparent",h.style.marginBottom="-2px",h.style.fontSize="14px";let y=m("div","pf-tab-panel");if(y.style.display=c===a?"block":"none",y.setAttribute("role","tabpanel"),y.setAttribute("aria-labelledby",d),y.id=g,y.tabIndex=0,H(u,y,t),h.addEventListener("click",()=>{l(c)}),c===a)h.classList.add("pf-tab-active"),h.style.fontWeight="600";s.push(h),o.push(y),r.appendChild(h)}function l(c){o.forEach((u)=>u.style.display="none"),s.forEach((u)=>{u.style.borderBottomColor="transparent",u.style.fontWeight="normal",u.classList.remove("pf-tab-active"),u.setAttribute("aria-selected","false"),u.tabIndex=-1}),o[c].style.display="block",s[c].classList.add("pf-tab-active"),s[c].style.fontWeight="600",s[c].setAttribute("aria-selected","true"),s[c].tabIndex=0,s[c].focus()}r.addEventListener("keydown",(c)=>{let u=s.indexOf(c.target);if(u<0)return;let d;if(c.key==="ArrowRight")d=(u+1)%s.length;else if(c.key==="ArrowLeft")d=(u-1+s.length)%s.length;else if(c.key==="Home")d=0;else if(c.key==="End")d=s.length-1;else return;c.preventDefault(),l(d)}),n.appendChild(r);for(let c of o)n.appendChild(c);return n}function ko(e,t){let n=m("div","pf-tab");return H(e,n,t),n}function So(e,t){let n=m("div","pf-accordion");return H(e,n,t),n}function Eo(e,t){let n=m("div","pf-accordion-item"),r=`pf-acc-${Math.random().toString(36).slice(2,8)}`,o=document.createElement("button");o.type="button",o.className="pf-accordion-trigger",o.textContent=e.title??"",o.setAttribute("aria-expanded","false"),o.setAttribute("aria-controls",r),o.style.width="100%",o.style.textAlign="left",o.style.padding="12px 0",o.style.border="none",o.style.background="none",o.style.cursor="pointer",o.style.fontSize="14px",o.style.fontWeight="500";let s=m("div","pf-accordion-content");return s.id=r,s.setAttribute("role","region"),s.setAttribute("aria-labelledby",o.id),s.style.display="none",s.style.paddingBottom="12px",H(e,s,t),o.addEventListener("click",()=>{let i=s.style.display!=="none";s.style.display=i?"none":"block",o.setAttribute("aria-expanded",i?"false":"true")}),n.appendChild(o),n.appendChild(s),n}function Ao(e,t){let n=m("div","pf-dialog-wrapper");if(e.trigger!=null){let s=J(e.trigger,t);s.addEventListener("click",()=>{r.showModal()}),n.appendChild(s)}let r=document.createElement("dialog");if(r.className="pf-dialog",r.setAttribute("aria-modal","true"),r.style.maxWidth="500px",r.style.width="100%",r.style.padding="24px",e.title!=null){let s=m("h2","pf-dialog-title");s.textContent=C(e.title,t),s.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,r.setAttribute("aria-labelledby",s.id),r.appendChild(s)}if(e.description!=null){let s=m("p","pf-dialog-desc");s.textContent=C(e.description,t),r.appendChild(s)}let o=m("div","pf-dialog-body");if(H(e,o,t),r.appendChild(o),e.dismissible!==!1)r.addEventListener("click",(s)=>{if(s.target===r)r.close()});return document.addEventListener("prefab:close-overlay",()=>r.close()),n.appendChild(r),n}function Ro(e,t){let n=m("div","pf-popover");n.style.position="relative",n.style.display="inline-block";let r=m("div","pf-popover-content");if(r.style.display="none",r.style.position="absolute",r.style.zIndex="50",r.style.padding="12px",r.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",e.title!=null){let s=m("div","pf-popover-title");s.textContent=C(e.title,t),s.style.fontWeight="600",s.style.marginBottom="4px",r.appendChild(s)}H(e,r,t);let o=()=>{r.style.display=r.style.display==="none"?"block":"none"};if(e.trigger!=null){let s=J(e.trigger,t);s.addEventListener("click",(i)=>{i.stopPropagation(),o()}),n.appendChild(s)}else n.addEventListener("click",(s)=>{if(r.contains(s.target)&&r.style.display!=="none")return;o()});return n.appendChild(r),n}function To(e,t){let n=m("div","pf-tooltip");n.style.position="relative",n.style.display="inline-block";let r=`pf-tip-${Math.random().toString(36).slice(2,8)}`,o=m("div","pf-tooltip-content");return o.id=r,o.setAttribute("role","tooltip"),o.textContent=C(e.content??"",t),o.style.display="none",o.style.position="absolute",o.style.bottom="100%",o.style.left="50%",o.style.transform="translateX(-50%)",o.style.padding="4px 8px",o.style.borderRadius="4px",o.style.color="#fff",o.style.fontSize="12px",o.style.whiteSpace="nowrap",o.style.zIndex="50",H(e,n,t),n.setAttribute("aria-describedby",r),n.addEventListener("mouseenter",()=>{o.style.display="block"}),n.addEventListener("mouseleave",()=>{o.style.display="none"}),n.addEventListener("focus",()=>{o.style.display="block"},!0),n.addEventListener("blur",()=>{o.style.display="none"},!0),n.appendChild(o),n}function No(e,t){let n=m("div","pf-hover-card");n.style.position="relative",n.style.display="inline-block";let r=m("div","pf-hover-card-content");if(r.style.display="none",r.style.position="absolute",r.style.zIndex="50",r.style.padding="16px",r.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",r.style.minWidth="200px",e.trigger!=null)n.appendChild(J(e.trigger,t));return H(e,r,t),n.addEventListener("mouseenter",()=>{r.style.display="block"}),n.addEventListener("mouseleave",()=>{r.style.display="none"}),n.appendChild(r),n}function Mo(e,t){let n=m("div","pf-carousel");n.style.position="relative",n.style.overflow="hidden",n.setAttribute("role","region"),n.setAttribute("aria-roledescription","carousel"),n.setAttribute("aria-label",C(e.label??"Carousel",t));let r=m("div","pf-carousel-track");r.style.display="flex",r.style.transition="transform 0.3s ease",H(e,r,t);let o=0,s=e.children?.length??0,i=document.createElement("button");i.type="button",i.textContent="‹",i.className="pf-carousel-prev",i.setAttribute("aria-label","Previous slide"),i.style.position="absolute",i.style.left="4px",i.style.top="50%",i.style.transform="translateY(-50%)",i.style.zIndex="10";let a=document.createElement("button");a.type="button",a.textContent="›",a.className="pf-carousel-next",a.setAttribute("aria-label","Next slide"),a.style.position="absolute",a.style.right="4px",a.style.top="50%",a.style.transform="translateY(-50%)",a.style.zIndex="10";let l=()=>{r.style.transform=`translateX(-${o*100}%)`};return i.addEventListener("click",()=>{if(s===0)return;o=Math.max(0,o-1),l()}),a.addEventListener("click",()=>{if(s===0)return;o=Math.min(s-1,o+1),l()}),n.appendChild(r),n.appendChild(i),n.appendChild(a),n}function dn(){p("ForEach",Lo),p("If",cn),p("Elif",Ho),p("Else",Po),p("Condition",$o),p("Define",Oo),p("Use",Do),p("Slot",jo)}function Lo(e,t){let n=document.createDocumentFragment(),r=e.expression;if(!r)return n;let o;if(Z(r)){let i=Q(r,t.store,t.scope);o=Array.isArray(i)?i:[]}else{let i=t.store.get(r);o=Array.isArray(i)?i:[]}let s=e.let??{};for(let i=0;i<o.length;i++){let a=o[i],l={...t.scope,$item:a,$index:i,...s},c={...t,scope:l};if(e.children)ie(e.children,n,c)}return n}function cn(e,t){if(pn(e.condition,t)){let r=document.createDocumentFragment();if(e.children)ie(e.children,r,t);return r}return document.createDocumentFragment()}function Ho(e,t){return cn(e,t)}function Po(e,t){let n=document.createDocumentFragment();if(e.children)ie(e.children,n,t);return n}function pn(e,t){if(!e)return!1;if(Z(e))return Boolean(Q(e,t.store,t.scope));return Boolean(t.store.get(e))}function $o(e,t){let n=document.createDocumentFragment(),r=e.cases,o=e.else;if(r){for(let s of r)if(pn(s.when,t)){if(s.children)ie(s.children,n,t);return n}}if(o)ie(o,n,t);return n}function Oo(e,t){let n=e.name;if(n&&e.children)t.templates=t.templates??{},t.templates[n]=e.children;return document.createDocumentFragment()}function Do(e,t){let n=document.createDocumentFragment(),r=e.def??e.name,o=t.templates?.[r];if(!o)return n;let s=e.overrides??{},i={...t.scope,...s},a={...t.slots??{},...e.slots??{}};if(Array.isArray(e.children))a.default=e.children;let l={...t,scope:i,slots:a};for(let c of o)n.appendChild(J(c,l));return n}function jo(e,t){let n=document.createDocumentFragment(),r=e.name??"default",s=t.slots?.[r]??e.children;if(s)for(let i of s)n.appendChild(J(i,t));return n}function un(){p("Alert",Io),p("AlertTitle",Fo),p("AlertDescription",Bo)}function Io(e,t){let n=m("div","pf-alert");n.setAttribute("role","alert");let r=e.variant??"default";if(n.setAttribute("data-variant",r),n.style.padding="12px 16px",e.icon!=null){let o=m("span","pf-alert-icon");o.setAttribute("data-icon",e.icon),o.style.marginRight="8px",n.appendChild(o)}return H(e,n,t),n}function Fo(e,t){let n=m("h5","pf-alert-title");return n.textContent=C(e.content,t),n.style.fontWeight="600",n.style.marginBottom="4px",n}function Bo(e,t){let n=m("p","pf-alert-description");return n.textContent=C(e.content,t),n.style.fontSize="14px",n}function fn(){p("Image",Jo),p("Audio",zo),p("Video",_o),p("Embed",Vo),p("Svg",Ko),p("DropZone",qo),p("Mermaid",Uo)}function Jo(e,t){let n=document.createElement("img");if(n.className="pf-image",n.src=C(e.src,t),e.alt!=null)n.alt=C(e.alt,t);if(e.width!=null)n.width=e.width;if(e.height!=null)n.height=e.height;return n.style.maxWidth="100%",n}function zo(e,t){let n=document.createElement("audio");return n.className="pf-audio",n.src=C(e.src,t),n.controls=!0,n}function _o(e,t){let n=document.createElement("video");if(n.className="pf-video",n.src=C(e.src,t),n.controls=!0,e.width!=null)n.width=e.width;if(e.height!=null)n.height=e.height;return n.style.maxWidth="100%",n}function Vo(e,t){let n=m("div","pf-embed"),r=document.createElement("iframe");return r.src=C(e.src,t),r.style.width="100%",r.style.height=e.height!=null?`${e.height}px`:"400px",r.style.border="none",r.setAttribute("sandbox","allow-scripts"),n.appendChild(r),n}var Wo=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 Ko(e,t){let n=m("div","pf-svg"),r=C(e.content,t);if(!r.includes("<svg"))return n;if(!/<svg[^>]*\sxmlns\s*=/.test(r))r=r.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"');let s=new DOMParser().parseFromString(r,"image/svg+xml").querySelector("svg");if(!s)return n;return mn(s),n.appendChild(document.importNode(s,!0)),n}function mn(e){let t=Array.from(e.children);for(let n of t){if(!Wo.has(n.tagName.toLowerCase())){n.remove();continue}for(let r of Array.from(n.attributes)){let o=r.name.toLowerCase();if(o.startsWith("on")||o==="href"&&r.value.trim().toLowerCase().startsWith("javascript:"))n.removeAttribute(r.name)}mn(n)}}function Go(e,t){let n=(t??"").split(",").map((s)=>s.trim().toLowerCase()).filter(Boolean);if(n.length===0)return!0;let r=e.name.toLowerCase(),o=e.type.toLowerCase();return n.some((s)=>{if(s.startsWith("."))return r.endsWith(s);if(s.endsWith("/*"))return o.startsWith(s.slice(0,-1));return o===s})}function qo(e,t){let n=m("div","pf-dropzone");n.style.padding="32px",n.style.textAlign="center",n.style.cursor="pointer",n.textContent=C(e.label??"Drop files here",t);let r=document.createElement("input");if(r.type="file",r.style.display="none",e.accept!=null)r.accept=e.accept;if(e.multiple===!0)r.multiple=!0;n.appendChild(r),n.setAttribute("role","button"),n.tabIndex=0;function o(i){let a=Array.from(i??[]).filter((l)=>Go(l,e.accept));return e.multiple===!0?a:a.slice(0,1)}function s(i){if(i.length===0)return;if(e.resultKey!=null)t.store.set(e.resultKey,i),t.rerender();if(e.onDrop!=null)F(j(e.onDrop,{...W(t),scope:{...t.scope,$result:i}}),"onDrop")}return r.addEventListener("change",()=>{s(o(r.files)),r.value=""}),n.addEventListener("click",()=>r.click()),n.addEventListener("keydown",(i)=>{if(i.key==="Enter"||i.key===" ")i.preventDefault(),r.click()}),n.addEventListener("dragover",(i)=>{i.preventDefault(),n.classList.add("pf-dropzone-active")}),n.addEventListener("dragleave",()=>{n.classList.remove("pf-dropzone-active")}),n.addEventListener("drop",(i)=>{i.preventDefault(),n.classList.remove("pf-dropzone-active"),s(o(i.dataTransfer?.files??null))}),n}function Uo(e,t){let n=m("div","pf-mermaid");n.setAttribute("data-mermaid","true");let r=C(e.content,t);if(n.textContent=r,typeof globalThis.mermaid<"u")n.classList.add("mermaid"),n.textContent=r;return n}var Xo="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",Yo="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",ht=null,Ke=null;async function Zo(){if(ht)return ht;if(Ke)return Ke;return Ke=import(Xo).then((e)=>{let t=e;return t.GlobalWorkerOptions.workerSrc=Yo,ht=t,t}),Ke}function hn(){p("PdfViewer",Qo)}function Qo(e,t){let n=m("div","pf-pdf-viewer"),r=e.src!=null?C(e.src,t):void 0,o=e.data,s=e.page!=null?e.page:1,i=e.zoom!=null?e.zoom:"fit-width",a=e.toolbar!==!1,l=e.height!=null?e.height:600;n.style.height=`${l}px`,n.style.display="flex",n.style.flexDirection="column",n.style.overflow="hidden",n.style.border="1px solid var(--color-border-primary, #e5e7eb)",n.style.borderRadius="var(--border-radius-md, 0.375rem)",n.style.background="var(--color-background-secondary, #f9fafb)";let c=m("div","pf-pdf-loading");return c.textContent="Loading PDF…",c.style.display="flex",c.style.alignItems="center",c.style.justifyContent="center",c.style.flex="1",c.style.color="var(--color-text-secondary, #6b7280)",n.appendChild(c),es(n,c,{src:r,data:o,initialPage:s,zoom:i,showToolbar:a}),n}async function es(e,t,n){try{let r=await Zo(),o;if(n.src)o={url:n.src};else if(n.data){let g=atob(n.data),h=new Uint8Array(g.length);for(let y=0;y<g.length;y++)h[y]=g.charCodeAt(y);o={data:h}}else{t.textContent="Error: No PDF source provided";return}let s=await r.getDocument(o).promise;t.remove();let i=Math.max(1,Math.min(n.initialPage,s.numPages)),a=null,l=null;if(n.showToolbar){let g=ts(s.numPages,i,{onPrev:()=>{if(i>1)i--,d()},onNext:()=>{if(i<s.numPages)i++,d()},onPageChange:(h)=>{let y=Math.max(1,Math.min(h,s.numPages));if(y!==i)i=y,d()}});a=g.pageInput,l=g.pageCount,e.insertBefore(g.el,e.firstChild)}let c=m("div","pf-pdf-canvas-container");c.style.flex="1",c.style.overflow="auto",c.style.display="flex",c.style.justifyContent="center",c.style.padding="8px",e.appendChild(c);let u=document.createElement("canvas");u.style.display="block",u.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",c.appendChild(u);async function d(){let g=await s.getPage(i),h=c.clientWidth-16,y,f=g.getViewport({scale:1});if(n.zoom==="fit-width")y=h/f.width;else if(n.zoom==="fit-page"){let S=c.clientHeight-16,N=h/f.width,k=S/f.height;y=Math.min(N,k)}else y=typeof n.zoom==="number"?n.zoom:1;let b=g.getViewport({scale:y});u.width=b.width,u.height=b.height,u.style.width=`${b.width}px`,u.style.height=`${b.height}px`;let w=u.getContext("2d");if(!w)return;if(await g.render({canvasContext:w,viewport:b}).promise,a)a.value=String(i);if(l)l.textContent=`/ ${s.numPages}`}await d()}catch(r){t.textContent=`PDF Error: ${r instanceof Error?r.message:String(r)}`,t.style.color="var(--color-text-danger, #dc2626)"}}function ts(e,t,n){let r=m("div","pf-pdf-toolbar");r.style.display="flex",r.style.alignItems="center",r.style.gap="8px",r.style.padding="6px 12px",r.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",r.style.background="var(--color-background-primary, #fff)",r.style.flexShrink="0",r.style.fontSize="13px";let o=document.createElement("button");o.textContent="‹",o.title="Previous page",o.className="pf-pdf-btn",gn(o),o.addEventListener("click",n.onPrev);let s=document.createElement("button");s.textContent="›",s.title="Next page",s.className="pf-pdf-btn",gn(s),s.addEventListener("click",n.onNext);let i=document.createElement("input");i.type="number",i.min="1",i.max=String(e),i.value=String(t),i.style.width="48px",i.style.textAlign="center",i.style.border="1px solid var(--color-border-primary, #e5e7eb)",i.style.borderRadius="4px",i.style.padding="2px 4px",i.style.fontSize="13px",i.addEventListener("change",()=>{let l=parseInt(i.value,10);if(!isNaN(l))n.onPageChange(l)});let a=document.createElement("span");return a.textContent=`/ ${e}`,a.style.color="var(--color-text-secondary, #6b7280)",r.appendChild(o),r.appendChild(i),r.appendChild(a),r.appendChild(s),{el:r,pageInput:i,pageCount:a}}function gn(e){e.style.border="1px solid var(--color-border-primary, #e5e7eb)",e.style.borderRadius="4px",e.style.background="var(--color-background-primary, #fff)",e.style.cursor="pointer",e.style.padding="2px 8px",e.style.fontSize="16px",e.style.lineHeight="1"}var qe=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function ce(e,t){let n=document.createElement("div");return n.className="pf-chart-tooltip",e.appendChild(n),e.addEventListener("mouseleave",()=>{n.classList.remove("pf-visible")}),{wrapper:e,tooltip:n,svgEl:t}}function ee(e,t,n,r,o){let{tooltip:s,svgEl:i,wrapper:a}=e;if(o.length===0)return;let l="";if(r)l+=`<div class="pf-chart-tooltip-label">${Ge(r)}</div>`;for(let b of o)l+='<div class="pf-chart-tooltip-row">',l+=`<span class="pf-chart-tooltip-dot" style="background:${Ge(b.color)}"></span>`,l+=`<span>${Ge(b.label)}:</span> <strong>${Ge(String(b.value))}</strong>`,l+="</div>";s.innerHTML=l;let c=i.getBoundingClientRect(),u=a.getBoundingClientRect(),d=i.viewBox.baseVal,g=c.width/(d.width||1),h=c.left-u.left+t*g,y=s.offsetWidth||100,f=h+12;if(f+y>u.width)f=h-y-12;s.style.left=`${Math.max(0,f)}px`,s.style.top="4px",s.classList.add("pf-visible")}function Ge(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function bn(e,t,n,r,o,s,i,a){let l=o.plotWidth/n.length;for(let c=0;c<n.length;c++){let u=o.plotLeft+c*l,d=document.createElementNS("http://www.w3.org/2000/svg","rect");d.setAttribute("x",String(u)),d.setAttribute("y",String(o.plotTop)),d.setAttribute("width",String(l)),d.setAttribute("height",String(o.plotHeight)),d.setAttribute("fill","transparent"),d.style.cursor="default";let g=s?n[c][s]:void 0,h=g!=null?a?a(g):O(g):void 0,y=r.map((S,N)=>({label:S.label??S.dataKey,value:i(n[c][S.dataKey],S,N),color:S.color??qe[N%qe.length]})),f=u+l/2,b=()=>ee(e,f,o.plotTop,h,y),w=()=>e.tooltip.classList.remove("pf-visible");d.addEventListener("mouseenter",b),d.addEventListener("mouseleave",w),d.addEventListener("touchstart",b,{passive:!0}),d.addEventListener("touchend",w,{passive:!0}),t.appendChild(d)}}function yn(e,t,n,r,o,s,i,a,l,c){let u=n.length===1?o.plotWidth:o.plotWidth/(n.length-1);for(let d=0;d<n.length;d++){let g=n.length===1?(o.plotLeft+o.plotRight)/2:o.plotLeft+d/(n.length-1)*o.plotWidth,h=n.length===1?o.plotLeft:g-u/2,y=n.length===1?o.plotWidth:u,f=document.createElementNS("http://www.w3.org/2000/svg","rect");f.setAttribute("x",String(Math.max(o.plotLeft,h))),f.setAttribute("y",String(o.plotTop)),f.setAttribute("width",String(Math.min(y,o.plotRight-Math.max(o.plotLeft,h)))),f.setAttribute("height",String(o.plotHeight)),f.setAttribute("fill","transparent"),f.style.cursor="default";let b=s?n[d][s]:void 0,w=b!=null?c?c(b):O(b):void 0,S=r.map((R,L)=>({label:R.label??R.dataKey,value:i(n[d][R.dataKey],R,L),color:R.color??qe[L%qe.length]})),N=()=>{if(ee(e,g,o.plotTop,w,S),a)a.setAttribute("x1",String(g)),a.setAttribute("x2",String(g)),a.setAttribute("opacity","1");if(l)for(let R of l){for(let L of R)L.setAttribute("data-visible","false");R[d]?.setAttribute("data-visible","true")}},k=()=>{if(e.tooltip.classList.remove("pf-visible"),a)a.setAttribute("opacity","0");if(l)for(let R of l)for(let L of R)L.setAttribute("data-visible","false")};f.addEventListener("mouseenter",N),f.addEventListener("mouseleave",k),f.addEventListener("touchstart",N,{passive:!0}),f.addEventListener("touchend",k,{passive:!0}),t.appendChild(f)}}var q=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],re="var(--muted-foreground, #6b7280)",be="var(--border, #e5e7eb)",pe="10";function Ue(e,t,n,r=!1){let o=n?44:0,s=e-(r?44:0),i=10,a=t-24;return{plotLeft:o,plotRight:s,plotTop:10,plotBottom:a,plotWidth:s-o,plotHeight:a-10}}function Cn(e,t=5){if(e<=0)return[0];let n=e/t,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r,s=o<=1.5?r:o<=3?2*r:o<=7?5*r:10*r,i=[];for(let a=0;a<=e+s*0.01;a+=s)i.push(Math.round(a*1000)/1000);return i}function bt(e,t,n,r,o){let s=Cn(n);for(let i of s){let a=t.plotBottom-(n>0?i/n*t.plotHeight:0),l=U("text",{x:t.plotLeft-6,y:a+3,"text-anchor":"end","font-size":pe,fill:re});if(l.textContent=vt(i,o),e.appendChild(l),r&&i>0)e.appendChild(U("line",{x1:t.plotLeft,y1:a,x2:t.plotRight,y2:a,stroke:be,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function yt(e,t,n,r){let o=Cn(n);for(let s of o){let i=t.plotBottom-(n>0?s/n*t.plotHeight:0),a=U("text",{x:t.plotRight+6,y:i+3,"text-anchor":"start","font-size":pe,fill:re});a.textContent=vt(s,r),e.appendChild(a)}}function Ct(e,t,n,r,o,s){for(let i=0;i<t.length;i++){let a=t[i][n],l=U("text",{x:r(i),y:o+14,"text-anchor":"middle","font-size":pe,fill:re});l.textContent=a==null?"":s?s(a):O(a),e.appendChild(l)}}function Xe(e,t){e.appendChild(U("line",{x1:t.plotLeft,y1:t.plotBottom,x2:t.plotRight,y2:t.plotBottom,stroke:re,"stroke-width":1}))}function te(e,t,n){if(e==null)return"";let r=K(`{{ __v | ${t} }}`,{...n,scope:{...n.scope,__v:e}});return O(r??e)}function vt(e,t){if(t==="currency")return`$${e.toLocaleString()}`;if(t==="percent")return`${e}%`;if(e>=1e6)return`${(e/1e6).toFixed(1)}M`;if(e>=1000)return`${(e/1000).toFixed(1)}K`;return String(e)}function oe(e){let t=e.yAxisFormat??e.valueFormat;return t&&t!=="auto"?t:void 0}function wt(e,t,n){return(r,o)=>{if(r===null||r===void 0)return"—";if(o.tooltipFormat)return te(r,o.tooltipFormat,e);let s=o.yAxisId==="right"?n:t;return vt(Number(r),s)}}function ae(e,t,n){let r=document.createElementNS("http://www.w3.org/2000/svg","svg");if(r.setAttribute("width","100%"),r.setAttribute("height",String(t)),r.setAttribute("viewBox",`0 0 ${e} ${t}`),r.setAttribute("role","img"),n)r.setAttribute("aria-label",`${n} chart`);return r.style.overflow="visible",r}function U(e,t){let n=document.createElementNS("http://www.w3.org/2000/svg",e);for(let[r,o]of Object.entries(t))n.setAttribute(r,String(o));return n}function Ye(e,t){let n=U("text",e);return n.textContent=t,n}function ue(e,t,n,r){let o=r*Math.PI/180;return{x:e+n*Math.cos(o),y:t-n*Math.sin(o)}}function xt(e,t,n,r,o){let s=Math.max(2,Math.ceil(Math.abs(o-r)/4)),i=[];for(let a=0;a<=s;a++){let l=ue(e,t,n,r+(o-r)*a/s);i.push(`${a===0?"M":"L"} ${l.x.toFixed(2)} ${l.y.toFixed(2)}`)}return i.join(" ")}function fe(e,t,n){if(n===!1||t.length<=1)return;let r=m("div","pf-chart-legend");r.style.display="flex",r.style.gap="12px",r.style.fontSize="12px",r.style.marginBottom="8px";for(let o=0;o<t.length;o++){let s=m("div","pf-chart-legend-item");s.style.display="flex",s.style.alignItems="center",s.style.gap="4px";let i=m("span");i.style.width="8px",i.style.height="8px",i.style.borderRadius="50%",i.style.backgroundColor=t[o].color??q[o%q.length];let a=m("span");a.textContent=t[o].label??t[o].dataKey,s.appendChild(i),s.appendChild(a),r.appendChild(s)}e.appendChild(r)}function wn(){p("BarChart",ns),p("LineChart",vn),p("AreaChart",vn),p("PieChart",rs),p("RadarChart",is),p("ScatterChart",os),p("RadialChart",ss),p("Histogram",as)}function ns(e,t){let n=m("div","pf-chart pf-bar-chart"),r=K(e.data,t)??[],o=e.series??[],s=e.height??300;if(r.length===0||o.length===0)return n.textContent="No chart data",n;let i=e.showYAxis!==!1,a=e.showGrid===!0,l=e.showYAxisRight===!0,c=e.showTooltip!==!1,u=e.xAxis,d=e.tooltipXKey,g=e.xAxisFormat,h=e.tooltipXFormat,y=o.filter((x)=>x.yAxisId!=="right"),f=o.filter((x)=>x.yAxisId==="right"),b=l&&f.length>0,w=y.length>0?Math.max(...r.flatMap((x)=>y.map((v)=>Number(x[v.dataKey]??0))),1):1,S=b?Math.max(...r.flatMap((x)=>f.map((v)=>Number(x[v.dataKey]??0))),1):1,N=400,k=Ue(N,s,i,b),R=ae(N,s,"Bar");if(i)bt(R,k,w,a,oe(e));if(b)yt(R,k,S,e.yAxisRightFormat);Xe(R,k);let L=k.plotWidth/r.length,M=L/(o.length+1);for(let x=0;x<r.length;x++)for(let v=0;v<o.length;v++){let T=o[v],D=r[x][T.dataKey];if(D===null||D===void 0)continue;let G=T.yAxisId==="right"?S:w,B=Number(D),E=Math.max(0,B/G*k.plotHeight),_=k.plotLeft+x*L+v*M+M/2,A=document.createElementNS("http://www.w3.org/2000/svg","rect");A.setAttribute("x",String(_)),A.setAttribute("y",String(k.plotBottom-E)),A.setAttribute("width",String(M*0.8)),A.setAttribute("height",String(E)),A.setAttribute("fill",T.color??q[v%q.length]),A.setAttribute("rx","2"),R.appendChild(A)}if(u){let x=g?(v)=>te(v,g,t):void 0;Ct(R,r,u,(v)=>k.plotLeft+v*L+L/2,k.plotBottom,x)}if(c){let x=ce(n,R),v=wt(t,oe(e),e.yAxisRightFormat);bn(x,R,r,o,k,d??u,v,h?(D)=>te(D,h,t):void 0)}return fe(n,o,e.showLegend),n.appendChild(R),n}function vn(e,t){let n=m("div",`pf-chart pf-${e.type.toLowerCase()}-chart`),r=K(e.data,t)??[],o=e.series??[],s=e.height??300;if(r.length===0||o.length===0)return n.textContent="No chart data",n;let i=e.showYAxis!==!1,a=e.showGrid===!0,l=e.showYAxisRight===!0,c=e.showTooltip!==!1,u=e.xAxis,d=e.tooltipXKey,g=e.xAxisFormat,h=e.tooltipXFormat,y=o.filter((v)=>v.yAxisId!=="right"),f=o.filter((v)=>v.yAxisId==="right"),b=l&&f.length>0,w=y.length>0?Math.max(...r.flatMap((v)=>y.map((T)=>Number(v[T.dataKey]??0))),1):1,S=b?Math.max(...r.flatMap((v)=>f.map((T)=>Number(v[T.dataKey]??0))),1):1,N=400,k=Ue(N,s,i,b),R=ae(N,s,e.type==="AreaChart"?"Area":"Line"),L=e.type==="AreaChart";if(i)bt(R,k,w,a,oe(e));if(b)yt(R,k,S,e.yAxisRightFormat);Xe(R,k);let M=[];for(let v=0;v<o.length;v++){let T=o[v],D=T.yAxisId==="right",z=D?S:w,G=T.color??q[v%q.length],B=r.map((A,I)=>{let V=A[T.dataKey],X=V===null||V===void 0,le=r.length===1?(k.plotLeft+k.plotRight)/2:k.plotLeft+I/(r.length-1)*k.plotWidth,In=X?k.plotBottom:k.plotBottom-Number(V)/z*k.plotHeight;return{x:le,y:In,isNull:X}});if(L){let A=[],I=()=>{if(A.length<2){A=[];return}let V=`M ${A[0].x},${k.plotBottom} `+A.map((le)=>`L ${le.x},${le.y}`).join(" ")+` L ${A[A.length-1].x},${k.plotBottom} Z`,X=document.createElementNS("http://www.w3.org/2000/svg","path");X.setAttribute("d",V),X.setAttribute("fill",G),X.setAttribute("opacity","0.15"),R.appendChild(X),A=[]};for(let V of B){if(V.isNull){I();continue}A.push(V)}I()}let E="";for(let A of B){if(A.isNull)continue;let I=B.indexOf(A),V=I===0||B[I-1].isNull;E+=`${V?"M":"L"} ${A.x},${A.y} `}if(E){let A=document.createElementNS("http://www.w3.org/2000/svg","path");if(A.setAttribute("d",E.trim()),A.setAttribute("fill","none"),A.setAttribute("stroke",G),A.setAttribute("stroke-width","2"),D)A.setAttribute("stroke-dasharray","6 3");R.appendChild(A)}let _=[];for(let A of B){let I=document.createElementNS("http://www.w3.org/2000/svg","circle");if(I.setAttribute("cx",String(A.x)),I.setAttribute("cy",String(A.y)),I.setAttribute("r","4"),I.setAttribute("fill",G),I.setAttribute("class","pf-data-dot"),I.setAttribute("data-visible","false"),I.style.pointerEvents="none",A.isNull)I.style.display="none";R.appendChild(I),_.push(I)}M.push(_)}let x=document.createElementNS("http://www.w3.org/2000/svg","line");if(x.setAttribute("class","pf-crosshair"),x.setAttribute("x1",String(k.plotLeft)),x.setAttribute("x2",String(k.plotLeft)),x.setAttribute("y1",String(k.plotTop)),x.setAttribute("y2",String(k.plotBottom)),x.setAttribute("stroke",re),x.setAttribute("stroke-width","1"),x.setAttribute("stroke-dasharray","3 3"),x.setAttribute("opacity","0"),R.appendChild(x),u){let v=g?(T)=>te(T,g,t):void 0;Ct(R,r,u,(T)=>r.length===1?(k.plotLeft+k.plotRight)/2:k.plotLeft+T/(r.length-1)*k.plotWidth,k.plotBottom,v)}if(c){let v=ce(n,R),T=wt(t,oe(e),e.yAxisRightFormat);yn(v,R,r,o,k,d??u,T,x,M,h?(z)=>te(z,h,t):void 0)}return fe(n,o,e.showLegend),n.appendChild(R),n}function rs(e,t){let n=m("div","pf-chart pf-pie-chart"),r=K(e.data,t)??[],o=e.series??[],s=e.height??300,i=Math.min(s,300),a=e.showTooltip!==!1,l=e.dataKey??o[0]?.dataKey,c=e.nameKey??e.tooltipXKey??e.xAxis,u=o.length>0?o:l?[{dataKey:l,label:l}]:[];if(r.length===0||!l)return n.textContent="No chart data",n;let d=ae(i,i,"Pie"),g=i/2,h=i/2,y=i/2-10,f=e.tooltipXFormat,b=oe(e),w=(L)=>b?te(L,b,t):String(L),S=r.map((L)=>Number(L[l]??0)),N=S.reduce((L,M)=>L+M,0);if(N===0)return n.textContent="No chart data",n.appendChild(d),n;let k=a?ce(n,d):void 0,R=-Math.PI/2;for(let L=0;L<S.length;L++){let M=S[L]/N*2*Math.PI,x=R+M,v=M>Math.PI?1:0,T=g+y*Math.cos(R),D=h+y*Math.sin(R),z=g+y*Math.cos(x),G=h+y*Math.sin(x),B=q[L%q.length],E=document.createElementNS("http://www.w3.org/2000/svg","path");if(E.setAttribute("d",`M ${g},${h} L ${T},${D} A ${y},${y} 0 ${v} 1 ${z},${G} Z`),E.setAttribute("fill",B),E.style.cursor="default",k){let _=c?r[L][c]:void 0,A=_!=null?f?te(_,f,t):O(_):`Slice ${L+1}`,I=`${(S[L]/N*100).toFixed(1)}%`,V=R+M/2,X=g+y*0.6*Math.cos(V);E.addEventListener("mouseenter",()=>{ee(k,X,h,A,[{label:u[0].label??l,value:`${w(S[L])} (${I})`,color:B}])}),E.addEventListener("mouseleave",()=>{k.tooltip.classList.remove("pf-visible")}),E.addEventListener("touchstart",()=>{ee(k,X,h,A,[{label:u[0].label??l,value:`${w(S[L])} (${I})`,color:B}])},{passive:!0}),E.addEventListener("touchend",()=>{k.tooltip.classList.remove("pf-visible")},{passive:!0})}d.appendChild(E),R=x}return fe(n,u,e.showLegend),n.appendChild(d),n}function os(e,t){let n=m("div","pf-chart pf-scatter-chart"),r=K(e.data,t)??[],o=e.xAxis,s=e.yAxis,i=e.zAxis,a=e.series??[],l=e.height??300;if(r.length===0||!o||!s)return n.textContent="No chart data",n;let c=e.showGrid!==!1,u=e.showTooltip!==!1,d=a[0]?.color??q[0],g=oe(e),h=(E)=>g?te(E,g,t):String(Math.round(E*100)/100),y=r.map((E)=>Number(E[o]??0)),f=r.map((E)=>Number(E[s]??0)),b=Math.min(...y),w=Math.max(...y),S=Math.min(...f),N=Math.max(...f),k=w-b||1,R=N-S||1,L=i?r.map((E)=>Number(E[i]??0)):[],M=i?Math.max(...L,1):1,x=400,v=Ue(x,l,!0),T=ae(x,l,"Scatter"),D=(E)=>v.plotLeft+(E-b)/k*v.plotWidth,z=(E)=>v.plotBottom-(E-S)/R*v.plotHeight,G=4;for(let E=0;E<=G;E++){let _=S+R*E/G,A=z(_);if(T.appendChild(Ye({x:v.plotLeft-6,y:A+3,"text-anchor":"end","font-size":pe,fill:re},h(_))),c&&E>0)T.appendChild(U("line",{x1:v.plotLeft,y1:A,x2:v.plotRight,y2:A,stroke:be,"stroke-width":1,"stroke-dasharray":"4 3"}))}Xe(T,v);for(let E of[b,(b+w)/2,w])T.appendChild(Ye({x:D(E),y:v.plotBottom+14,"text-anchor":"middle","font-size":pe,fill:re},String(Math.round(E*100)/100)));let B=u?ce(n,T):void 0;for(let E=0;E<r.length;E++){let _=D(y[E]),A=z(f[E]),I=i?4+Math.sqrt(L[E]/M)*14:4,V=U("circle",{cx:_,cy:A,r:I,fill:d,"fill-opacity":i?0.6:0.85});if(B){let X=[{label:o,value:h(y[E]),color:d},{label:s,value:h(f[E]),color:d},...i?[{label:i,value:h(L[E]),color:d}]:[]],le=a[0]?.label??"Point";V.addEventListener("mouseenter",()=>ee(B,_,A,le,X)),V.addEventListener("mouseleave",()=>B.tooltip.classList.remove("pf-visible")),V.addEventListener("touchstart",()=>ee(B,_,A,le,X),{passive:!0}),V.addEventListener("touchend",()=>B.tooltip.classList.remove("pf-visible"),{passive:!0})}T.appendChild(V)}return fe(n,a,e.showLegend),n.appendChild(T),n}function ss(e,t){let n=m("div","pf-chart pf-radial-chart"),r=K(e.data,t)??[],o=e.series??[],s=e.dataKey??o[0]?.dataKey,i=e.nameKey??e.tooltipXKey??e.xAxis,a=e.height??300;if(r.length===0||!s)return n.textContent="No chart data",n;let l=Math.min(a,300),c=l/2,u=l/2,d=l/2-10,g=Math.max(0,Math.min(e.innerRadius??30,d-10)),h=e.startAngle??180,y=e.endAngle??0,f=e.showTooltip!==!1,b=r.map((v)=>Number(v[s]??0)),w=Math.max(...b,1),S=ae(l,l,"Radial"),N=(d-g)/r.length,k=Math.max(2,N*0.7),R=oe(e),L=(v)=>R?te(v,R,t):String(v),M=f?ce(n,S):void 0,x=[];for(let v=0;v<r.length;v++){let T=d-N*v-N/2,D=o[v]?.color??q[v%q.length],z=b[v]/w,G=h+z*(y-h),B=i?r[v][i]:null,E=B!=null?O(B):o[v]?.label??s;x.push({dataKey:E||s,label:E||s,color:D}),S.appendChild(U("path",{d:xt(c,u,T,h,y),fill:"none",stroke:be,"stroke-width":k,"stroke-linecap":"round"}));let _=U("path",{d:xt(c,u,T,h,G),fill:"none",stroke:D,"stroke-width":k,"stroke-linecap":"round"});if(M){let A=ue(c,u,T,(h+G)/2),I=[{label:s,value:L(b[v]),color:D}],V=E||s;_.addEventListener("mouseenter",()=>ee(M,A.x,A.y,V,I)),_.addEventListener("mouseleave",()=>M.tooltip.classList.remove("pf-visible")),_.addEventListener("touchstart",()=>ee(M,A.x,A.y,V,I),{passive:!0}),_.addEventListener("touchend",()=>M.tooltip.classList.remove("pf-visible"),{passive:!0})}S.appendChild(_)}return fe(n,x,e.showLegend),n.appendChild(S),n}function is(e,t){let n=m("div","pf-chart pf-radar-chart"),r=K(e.data,t)??[],o=e.series??[],s=e.axisKey??e.xAxis,i=e.height??300;if(r.length===0||o.length===0)return n.textContent="No chart data",n;let a=e.filled!==!1,l=e.showDots===!0,c=e.showGrid!==!1,u=e.showTooltip!==!1,d=Math.min(i,320),g=d/2,h=d/2,y=d/2-24,f=r.length,b=Math.max(...r.flatMap((M)=>o.map((x)=>Number(M[x.dataKey]??0))),1),w=(M)=>90-360*M/f,S=(M)=>M.map((x)=>`${x.x.toFixed(1)},${x.y.toFixed(1)}`).join(" "),N=ae(d,d,"Radar");if(c){for(let x=1;x<=4;x++){let v=y*x/4,T=Array.from({length:f},(D,z)=>ue(g,h,v,w(z)));N.appendChild(U("polygon",{points:S(T),fill:"none",stroke:be,"stroke-width":1}))}for(let x=0;x<f;x++){let v=ue(g,h,y,w(x));N.appendChild(U("line",{x1:g,y1:h,x2:v.x,y2:v.y,stroke:be,"stroke-width":1}))}}for(let M=0;M<f;M++){let x=ue(g,h,y+12,w(M)),v=s?r[M][s]:null;N.appendChild(Ye({x:x.x,y:x.y+3,"text-anchor":"middle","font-size":pe,fill:re},v!=null?String(v):""))}let k=u?ce(n,N):void 0,R=oe(e),L=(M)=>R?te(M,R,t):String(M);for(let M=0;M<o.length;M++){let x=o[M],v=x.color??q[M%q.length],T=r.map((D,z)=>ue(g,h,Number(D[x.dataKey]??0)/b*y,w(z)));if(N.appendChild(U("polygon",{points:S(T),fill:a?v:"none","fill-opacity":a?0.2:0,stroke:v,"stroke-width":2})),l||k)for(let D=0;D<T.length;D++){let z=U("circle",{cx:T[D].x,cy:T[D].y,r:l?3:6,fill:l?v:"transparent","fill-opacity":l?1:0});if(k){let G=s?r[D][s]:null,B=G!=null?O(G):x.label??x.dataKey,E=[{label:x.label??x.dataKey,value:L(Number(r[D][x.dataKey]??0)),color:v}];z.addEventListener("mouseenter",()=>ee(k,T[D].x,T[D].y,B,E)),z.addEventListener("mouseleave",()=>k.tooltip.classList.remove("pf-visible")),z.addEventListener("touchstart",()=>ee(k,T[D].x,T[D].y,B,E),{passive:!0}),z.addEventListener("touchend",()=>k.tooltip.classList.remove("pf-visible"),{passive:!0})}N.appendChild(z)}}return fe(n,o,e.showLegend),n.appendChild(N),n}function as(e,t){let n=m("div","pf-chart pf-histogram"),r=K(e.data,t);if(!r||r.length===0)return n.textContent="No data",n;let o=r,s=e.bins??10,i=e.height??200,a=e.color??q[0],l=Math.min(...o),u=(Math.max(...o)-l)/s||1,d=Array(s).fill(0);for(let w of o){let S=Math.min(Math.floor((w-l)/u),s-1);d[S]++}let g=Math.max(...d),h=300,y=i,f=h/s,b=ae(h,y,"Histogram");for(let w=0;w<s;w++){let S=g>0?d[w]/g*y:0,N=document.createElementNS("http://www.w3.org/2000/svg","rect");N.setAttribute("x",String(w*f)),N.setAttribute("y",String(y-S)),N.setAttribute("width",String(f-1)),N.setAttribute("height",String(S)),N.setAttribute("fill",a),b.appendChild(N)}return n.appendChild(b),n}function xn(){p("Table",ls),p("TableHead",kt("thead")),p("TableBody",kt("tbody")),p("TableFooter",kt("tfoot")),p("TableRow",ds),p("TableHeader",cs),p("TableCell",ps),p("TableCaption",us),p("ExpandableRow",fs)}function ls(e,t){let n=document.createElement("table");return n.className=e.striped===!0?"pf-table pf-table-striped":"pf-table",n.style.width="100%",n.style.borderCollapse="collapse",H(e,n,t),n}function kt(e){return(t,n)=>{let r=document.createElement(e);return r.className=`pf-${e}`,H(t,r,n),r}}function ds(e,t){let n=document.createElement("tr");return n.className="pf-table-row",H(e,n,t),n}function cs(e,t){let n=document.createElement("th");return n.className="pf-table-header",n.style.textAlign="left",n.style.padding="8px 12px",n.style.fontWeight="600",n.textContent=C(e.content,t),n}function ps(e,t){let n=document.createElement("td");if(n.className="pf-table-cell",n.style.padding="8px 12px",e.colSpan!=null)n.colSpan=e.colSpan;if(e.rowSpan!=null)n.rowSpan=e.rowSpan;return H(e,n,t),n}function us(e,t){let n=document.createElement("caption");return n.className="pf-table-caption",n.style.padding="8px",n.style.fontSize="14px",n.textContent=C(e.content,t),n}function fs(e,t){let n=m("div","pf-expandable-row"),r=m("div","pf-expandable-row-summary");r.style.cursor="pointer",r.style.display="flex",r.style.alignItems="center",r.style.gap="8px";let o=m("span","pf-expandable-arrow");o.textContent="▶",o.style.transition="transform 0.2s",o.style.fontSize="10px",r.appendChild(o);let s=e.summary;if(s)for(let l of s)r.appendChild(J(l,t));let i=m("div","pf-expandable-row-detail");i.style.display="none",i.style.paddingLeft="24px",H(e,i,t);let a=!1;return r.addEventListener("click",()=>{a=!a,i.style.display=a?"block":"none",o.style.transform=a?"rotate(90deg)":""}),n.appendChild(r),n.appendChild(i),n}var kn=!1;function Ze(){if(kn)return;kn=!0;let e=new Set(ut());Ut(),Qt(),nn(),rn(),sn(),ln(),dn(),un(),fn(),hn(),wn(),xn(),Wt(ut().filter((t)=>!e.has(t)))}function Et(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}function At(e){return e.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function St(e,t=" "){return Object.entries(e).map(([n,r])=>`${t}--${Et(n)}: ${At(r)};`).join(`
|
|
7
|
-
`)}function
|
|
8
|
-
${
|
|
9
|
-
}`);if(e.dark&&Object.keys(e.dark).length>0){let n=
|
|
3
|
+
`),n=[],r=0;while(r<t.length){let o=t[r];if(o.trimStart().startsWith("```")){let a=o.trimStart().slice(3).trim(),l=[];r++;while(r<t.length&&!t[r].trimStart().startsWith("```"))l.push(Te(t[r])),r++;r++;let d=a?` data-language="${Te(a)}"`:"";n.push(`<pre class="pf-code"><code${d}>${l.join(`
|
|
4
|
+
`)}</code></pre>`);continue}if(/^(\s*[-*_]\s*){3,}$/.test(o)){n.push("<hr />"),r++;continue}let i=/^(#{1,6})\s+(.+)$/.exec(o);if(i){let a=i[1].length;n.push(`<h${a}>${Ke(i[2])}</h${a}>`),r++;continue}if(o.startsWith("> ")||o===">"){let a=[];while(r<t.length&&(t[r].startsWith("> ")||t[r]===">"))a.push(t[r].replace(/^>\s?/,"")),r++;n.push(`<blockquote>${nn(a.join(`
|
|
5
|
+
`))}</blockquote>`);continue}if(/^[\s]*[-*+]\s+/.test(o)){n.push("<ul>");while(r<t.length&&/^[\s]*[-*+]\s+/.test(t[r]))n.push(`<li>${Ke(t[r].replace(/^[\s]*[-*+]\s+/,""))}</li>`),r++;n.push("</ul>");continue}if(/^[\s]*\d+\.\s+/.test(o)){n.push("<ol>");while(r<t.length&&/^[\s]*\d+\.\s+/.test(t[r]))n.push(`<li>${Ke(t[r].replace(/^[\s]*\d+\.\s+/,""))}</li>`),r++;n.push("</ol>");continue}if(o.trim()===""){r++;continue}let s=[];while(r<t.length&&t[r].trim()!==""&&!/^#{1,6}\s/.test(t[r])&&!/^[-*+]\s/.test(t[r])&&!/^\d+\.\s/.test(t[r])&&!t[r].startsWith("> ")&&!t[r].trimStart().startsWith("```")&&!/^(\s*[-*_]\s*){3,}$/.test(t[r]))s.push(t[r]),r++;n.push(`<p>${s.map(Ke).join("<br />")}</p>`)}return n.join(`
|
|
6
|
+
`)}function Kr(e,t){let n=document.createElement("kbd");return n.className="pf-kbd",n.textContent=C(e.content,t),n}function on(){p("Card",Gr),p("CardHeader",ht("pf-card-header")),p("CardTitle",rn("pf-card-title","h3")),p("CardDescription",rn("pf-card-description","p")),p("CardContent",ht("pf-card-content")),p("CardFooter",ht("pf-card-footer"))}function Gr(e,t){let n=m("div","pf-card");return n.style.overflow="hidden",H(e,n,t),n}function ht(e){return(t,n)=>{let r=m("div",e);return r.style.padding="16px 24px",H(t,r,n),r}}function rn(e,t){return(n,r)=>{let o=document.createElement(t);return o.className=e,o.textContent=C(n.content,r),o}}function sn(){p("DataTable",qr),p("Badge",Ur),p("Dot",Xr),p("Metric",Yr),p("Ring",Zr),p("Progress",Qr),p("Separator",eo),p("Loader",to),p("Icon",no),p("Sparkline",ro)}function qr(e,t){let n=m("div","pf-datatable-wrapper"),r=document.createElement("table");r.className="pf-datatable",r.style.width="100%",r.style.borderCollapse="collapse";let o=e.columns??[],i=K(e.rows,t),s=e.rowKey,a=e.selected,l=document.createElement("thead"),d=document.createElement("tr");for(let c of o){let g=document.createElement("th");g.className="pf-datatable-th",g.textContent=c.header??c.key,g.style.padding="8px 12px",g.style.textAlign="left",d.appendChild(g)}l.appendChild(d),r.appendChild(l);let u=document.createElement("tbody");if(Array.isArray(i)){let c=a!=null?K(a,t):void 0;for(let g of i){let h=document.createElement("tr");h.className="pf-datatable-row";let y=g,f=g===null||typeof g!=="object";if(s&&c!=null&&y[s]!=null&&L(y[s])===L(c))h.classList.add("pf-datatable-row-selected");if(e.onRowClick!=null&&s)h.style.cursor="pointer",h.addEventListener("click",()=>{let b={...t.scope,$item:y,$index:i.indexOf(g)},w=W({...t,scope:b});I(j(e.onRowClick,w),"onRowClick")});for(let b of o){let w=document.createElement("td");w.className="pf-datatable-td";let S;if(b.accessor)S=K(`{{ $item.${b.accessor} }}`,{...t,scope:{...t.scope,$item:y}});else if(S=f?g:y[b.key],b.format&&S!=null)S=K(`{{ __fmtVal | ${b.format} }}`,{...t,scope:{...t.scope,__fmtVal:S}});w.textContent=L(S),w.style.padding="8px 12px",h.appendChild(w)}u.appendChild(h)}}if(r.appendChild(u),e.search===!0){let c=document.createElement("input");c.type="text",c.placeholder="Search...",c.className="pf-datatable-search",c.style.marginBottom="8px",c.style.padding="6px 12px",c.style.width="100%",c.style.boxSizing="border-box",c.addEventListener("input",()=>{let g=c.value.toLowerCase(),h=Array.from(u.querySelectorAll("tr"));for(let y of h){let f=(y.textContent??"").toLowerCase();y.style.display=f.includes(g)?"":"none"}}),n.appendChild(c)}return n.appendChild(r),n}function Ur(e,t){let n=m("span","pf-badge"),r=e.variant??"default";return n.setAttribute("data-variant",r),n.style.alignItems="center",n.style.padding="2px 10px",n.style.borderRadius="9999px",n.style.fontSize="12px",n.style.fontWeight="500",n.textContent=C(e.label??e.content,t),oo(n,r),n}function Xr(e,t){let n=m("span","pf-dot"),r=e.color??"gray";return n.style.display="inline-block",n.style.width="8px",n.style.height="8px",n.style.borderRadius="50%",n.style.backgroundColor=r,n}function Yr(e,t){let n=m("div","pf-metric"),r=m("div","pf-metric-label");r.textContent=C(e.label,t),r.style.fontSize="14px",n.appendChild(r);let o=m("div","pf-metric-value");if(o.textContent=C(e.value,t),o.style.fontSize="28px",o.style.fontWeight="700",n.appendChild(o),e.delta!=null){let i=m("span","pf-metric-delta");i.textContent=C(e.delta,t);let s=e.trend??"",a=e.trendSentiment??"neutral";if(i.style.fontSize="14px",i.style.color=a==="positive"?"green":a==="negative"?"red":"inherit",s==="up")i.textContent="↑ "+i.textContent;else if(s==="down")i.textContent="↓ "+i.textContent;n.appendChild(i)}if(e.description!=null){let i=m("div","pf-metric-desc");i.textContent=C(e.description,t),i.style.fontSize="12px",n.appendChild(i)}return n}function Zr(e,t){let n=m("div","pf-ring"),r=e.size??80,o=e.thickness??8,i=Number(K(e.value,t)??0),s=Math.max(0,Math.min(100,i)),a=(r-o)/2,l=2*Math.PI*a,d=l*(1-s/100),u=document.createElementNS("http://www.w3.org/2000/svg","svg");u.setAttribute("width",String(r)),u.setAttribute("height",String(r)),u.setAttribute("viewBox",`0 0 ${r} ${r}`);let c=document.createElementNS("http://www.w3.org/2000/svg","circle");c.setAttribute("cx",String(r/2)),c.setAttribute("cy",String(r/2)),c.setAttribute("r",String(a)),c.setAttribute("fill","none"),c.setAttribute("stroke","var(--muted, #e5e7eb)"),c.setAttribute("stroke-width",String(o));let g=document.createElementNS("http://www.w3.org/2000/svg","circle");if(g.setAttribute("cx",String(r/2)),g.setAttribute("cy",String(r/2)),g.setAttribute("r",String(a)),g.setAttribute("fill","none"),g.setAttribute("stroke","var(--primary, #3b82f6)"),g.setAttribute("stroke-width",String(o)),g.setAttribute("stroke-dasharray",String(l)),g.setAttribute("stroke-dashoffset",String(d)),g.setAttribute("stroke-linecap","round"),g.style.transform="rotate(-90deg)",g.style.transformOrigin="center",u.appendChild(c),u.appendChild(g),n.appendChild(u),e.label!=null){let h=m("div","pf-ring-label");h.textContent=C(e.label,t),h.style.textAlign="center",h.style.fontSize="12px",n.appendChild(h)}return n}function Qr(e,t){let n=m("div","pf-progress");n.setAttribute("role","progressbar");let r=Number(K(e.value,t)??0),o=e.max??100,i=o>0?Math.max(0,Math.min(100,r/o*100)):0;n.setAttribute("aria-valuenow",String(r)),n.setAttribute("aria-valuemin","0"),n.setAttribute("aria-valuemax",String(o)),n.style.height="8px",n.style.borderRadius="4px",n.style.overflow="hidden";let s=m("div","pf-progress-fill");return s.style.height="100%",s.style.width=`${i}%`,s.style.borderRadius="4px",s.style.transition="width 0.3s ease",n.appendChild(s),n}function eo(e,t){let n=document.createElement("hr");return n.className="pf-separator",n.style.border="none",n.style.margin="8px 0",n}function to(e,t){let n=m("div","pf-loader");return n.textContent="⏳",n.style.display="flex",n.style.justifyContent="center",n.style.padding="16px",n}function no(e,t){let n=m("span","pf-icon");return n.setAttribute("data-icon",C(e.name??e.content,t)),n}function ro(e,t){let n=m("div","pf-sparkline"),r=e.data??[];if(r.length===0)return n;let o=e.width??120,i=e.height??32,s=Math.max(...r),a=Math.min(...r),l=s-a||1,d=document.createElementNS("http://www.w3.org/2000/svg","svg");d.setAttribute("width",String(o)),d.setAttribute("height",String(i)),d.setAttribute("viewBox",`0 0 ${o} ${i}`);let u=r.length>1?r.length-1:1,c=r.map((h,y)=>{let f=y/u*o,b=i-(h-a)/l*(i-4)-2;return`${f},${b}`}).join(" "),g=document.createElementNS("http://www.w3.org/2000/svg","polyline");return g.setAttribute("points",c),g.setAttribute("fill","none"),g.setAttribute("stroke","var(--primary, #3b82f6)"),g.setAttribute("stroke-width","1.5"),d.appendChild(g),n.appendChild(d),n}function oo(e,t){let r={success:{bg:"#10b981",fg:"#fff"},warning:{bg:"#f59e0b",fg:"#fff"},info:{bg:"#3b82f6",fg:"#fff"}}[t];if(r)e.style.backgroundColor=r.bg,e.style.color=r.fg}function an(){p("Form",io),p("Input",so),p("Textarea",ye(ao)),p("Button",lo),p("ButtonGroup",co),p("Checkbox",po),p("Switch",uo),p("Slider",ye(fo)),p("Calendar",go),p("DatePicker",ye(ho)),p("Field",Ne("pf-field")),p("FieldTitle",Ce("pf-field-title")),p("FieldDescription",Ce("pf-field-description")),p("FieldContent",Ne("pf-field-content")),p("FieldError",Ce("pf-field-error"))}function io(e,t){let n=document.createElement("form");return n.className="pf-form",n.addEventListener("submit",(r)=>{r.preventDefault();let o=new FormData(n),i={};for(let s of new Set(o.keys())){let a=o.getAll(s),l=n.elements.namedItem(s),d=l instanceof HTMLSelectElement&&l.multiple||a.length>1;i[s]=d?a:a[0]}if(t.store.merge(i),e.onSubmit!=null){let s=W(t);s.scope={...t.scope,...i},I(j(e.onSubmit,s),"onSubmit")}}),H(e,n,t),n}function ln(e,t,n){if(t.label==null)return;let r=document.createElement("label");if(r.className="pf-input-label",r.textContent=C(t.label,n),t.name!=null)r.htmlFor=t.name;r.style.fontSize="14px",r.style.fontWeight="500",e.insertBefore(r,e.firstChild)}function ye(e){return(t,n)=>{let r=e(t,n);return r.style.display="flex",r.style.flexDirection="column",r.style.gap="4px",ln(r,t,n),r}}function ae(e,t){if(t.required!==!0)return;if("required"in e)e.required=!0;e.setAttribute("aria-required","true")}function so(e,t){let n=m("div","pf-input-wrapper");n.style.display="flex",n.style.flexDirection="column",n.style.gap="4px",ln(n,e,t);let r=document.createElement("input");if(r.className="pf-input",r.type=e.inputType??"text",e.name!=null)r.name=e.name;if(e.name!=null)r.id=`pf-input-${e.name}`;if(e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(ae(r,e),e.error!=null)r.setAttribute("aria-invalid","true");let o=e.name;if(o){let i=t.store.get(o);if(i!=null)r.value=L(i);r.addEventListener("input",()=>{if(t.store.set(o,r.value),e.onChange!=null)I(j(e.onChange,{...W(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return Ge(r),n.appendChild(r),n}function ao(e,t){let n=m("div","pf-textarea-wrapper"),r=document.createElement("textarea");if(r.className="pf-textarea",e.name!=null)r.name=e.name;if(e.name!=null)r.id=`pf-textarea-${e.name}`;if(e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.rows!=null)r.rows=e.rows;ae(r,e);let o=e.name;if(o!=null){let i=t.store.get(o);if(i!=null)r.value=L(i);r.addEventListener("input",()=>{if(t.store.set(o,r.value),e.onChange!=null)I(j(e.onChange,{...W(t),scope:{...t.scope,$event:r.value}}),"onChange")})}return Ge(r),n.appendChild(r),n}function lo(e,t){let n=document.createElement("button");n.className="pf-button",n.type=e.submit===!0?"submit":"button",n.textContent=C(e.label,t);let r=e.variant??"default";if(n.setAttribute("data-variant",r),mo(n,r),e.size!=null)n.setAttribute("data-size",e.size);if(e.disabled===!0)n.disabled=!0;return n}function co(e,t){let n=m("div","pf-button-group");return n.style.display="flex",n.style.gap="8px",H(e,n,t),n}function po(e,t){let n=m("label","pf-checkbox-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="checkbox",r.className="pf-checkbox",e.name!=null)r.name=e.name;if(e.checked===!0)r.checked=!0;let o=e.name;if(o){let i=t.store.get(o);if(typeof i==="boolean")r.checked=i;r.addEventListener("change",()=>{if(t.store.set(o,r.checked),e.onChange!=null)I(j(e.onChange,{...W(t),scope:{...t.scope,$event:r.checked}}),"onChange")})}if(n.appendChild(r),e.label!=null){let i=m("span");i.textContent=C(e.label,t),n.appendChild(i)}return n}function uo(e,t){let n=m("label","pf-switch-wrapper");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="checkbox",r.className="pf-switch",r.setAttribute("role","switch"),e.name!=null)r.name=e.name;let o=e.name;if(o){let i=t.store.get(o);if(typeof i==="boolean")r.checked=i;r.addEventListener("change",()=>{if(t.store.set(o,r.checked),e.onChange!=null)I(j(e.onChange,{...W(t),scope:{...t.scope,$event:r.checked}}),"onChange")})}if(n.appendChild(r),e.label!=null){let i=m("span");i.textContent=C(e.label,t),n.appendChild(i)}return n}function fo(e,t){let n=m("div","pf-slider-wrapper"),r=document.createElement("input");if(r.type="range",r.className="pf-slider",e.name!=null)r.name=e.name;if(e.min!=null)r.min=L(e.min);if(e.max!=null)r.max=L(e.max);if(e.step!=null)r.step=L(e.step);let o=e.name;if(o){let i=t.store.get(o);if(i!=null)r.value=L(i);r.addEventListener("input",()=>{if(t.store.set(o,Number(r.value)),e.onChange!=null)I(j(e.onChange,{...W(t),scope:{...t.scope,$event:Number(r.value)}}),"onChange")})}return n.appendChild(r),n}function Ge(e){e.style.padding="8px 12px",e.style.fontSize="14px",e.style.width="100%",e.style.boxSizing="border-box"}function mo(e,t){if(e.style.padding="8px 16px",e.style.fontSize="14px",e.style.fontWeight="500",e.style.cursor="pointer",e.style.border="none",t==="ghost")e.style.backgroundColor="transparent",e.style.color="inherit"}function Ne(e){return(t,n)=>{let r=m("div",e);return H(t,r,n),r}}function Ce(e){return(t,n)=>{let r=m("span",e);return r.textContent=C(t.content,n),r}}function bt(){let e=document.createElement("hr");return e.className="pf-separator",e.style.border="none",e.style.margin="4px 0",e}function go(e,t){let n=m("div","pf-calendar"),r=document.createElement("input");if(r.type="date",r.name=C(e.name,t),ae(r,e),e.value!==void 0)r.value=C(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=L(i);if(e.minDate!=null)r.min=C(e.minDate,t);if(e.maxDate!=null)r.max=C(e.maxDate,t);return r.style.padding="6px 12px",r.style.borderRadius="6px",r.addEventListener("change",()=>{if(t.store.set(r.name,r.value),e.onChange!=null)I(j(e.onChange,W(t)),"onChange")}),n.appendChild(r),n}function ho(e,t){let n=m("div","pf-datepicker"),r=document.createElement("input");if(r.type="date",r.name=C(e.name,t),ae(r,e),e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.value!==void 0)r.value=C(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=L(i);if(e.minDate!=null)r.min=C(e.minDate,t);if(e.maxDate!=null)r.max=C(e.maxDate,t);return r.style.padding="6px 12px",r.style.borderRadius="6px",r.style.width="100%",r.style.boxSizing="border-box",r.addEventListener("change",()=>{if(t.store.set(r.name,r.value),e.onChange!=null)I(j(e.onChange,W(t)),"onChange")}),n.appendChild(r),n}function dn(){p("Select",ye(bo)),p("SelectOption",vo),p("SelectGroup",Ne("pf-select-group")),p("SelectLabel",Ce("pf-select-label")),p("SelectSeparator",bt),p("Radio",wo),p("RadioGroup",xo),p("Combobox",ye(ko)),p("ComboboxOption",So),p("ComboboxGroup",Ne("pf-combobox-group")),p("ComboboxLabel",Ce("pf-combobox-label")),p("ComboboxSeparator",bt),p("ChoiceCard",Ao)}function bo(e,t){let n=m("div","pf-select-wrapper"),r=document.createElement("select");if(r.className="pf-select",e.name!=null)r.name=e.name;if(e.multiple===!0)r.multiple=!0;if(ae(r,e),Ge(r),e.placeholder!=null){let s=document.createElement("option");s.value="",s.textContent=C(e.placeholder,t),s.disabled=!0,s.selected=!0,s.hidden=!0,r.appendChild(s)}let o=e.options;if(Array.isArray(o))for(let s of o){let a=document.createElement("option");a.value=s.value??"",a.textContent=s.label??a.value,r.appendChild(a)}if(e.children)for(let s of e.children)if(s.type==="SelectOption"){let a=document.createElement("option");a.value=s.value??"",a.textContent=s.label??a.value,r.appendChild(a)}else r.appendChild(J(s,t));let i=e.name;if(i){let s=t.store.get(i);if(s!=null)Co(r,s);r.addEventListener("change",()=>{let a=yo(r);if(t.store.set(i,a),e.onChange!=null)I(j(e.onChange,{...W(t),scope:{...t.scope,$event:a}}),"onChange")})}return n.appendChild(r),n}function yo(e){if(!e.multiple)return e.value;return Array.from(e.selectedOptions,(t)=>t.value)}function Co(e,t){if(!e.multiple){e.value=L(t);return}let n=new Set((Array.isArray(t)?t:[t]).map((r)=>L(r)));for(let r of e.options)r.selected=n.has(r.value)}function vo(e,t){return m("span")}function wo(e,t){let n=m("label","pf-radio");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.cursor="pointer";let r=document.createElement("input");if(r.type="radio",r.value=C(e.value,t),n.appendChild(r),e.label!=null){let o=m("span","pf-radio-label");o.textContent=C(e.label,t),n.appendChild(o)}return n}function xo(e,t){let n=m("fieldset","pf-radio-group");if(ae(n,e),n.style.border="none",n.style.padding="0",n.style.display="flex",n.style.flexDirection="column",n.style.gap="8px",e.label!=null){let i=document.createElement("legend");i.textContent=C(e.label,t),i.style.fontWeight="500",i.style.marginBottom="4px",n.appendChild(i)}H(e,n,t);let r=C(e.name,t),o=t.store.get(r);for(let i of Array.from(n.querySelectorAll('input[type="radio"]')))if(i.name=r,o!=null&&i.value===L(o))i.checked=!0;return n.addEventListener("change",(i)=>{let s=i.target;if(s.type==="radio"){if(t.store.set(r,s.value),e.onChange!=null)I(j(e.onChange,W(t)),"onChange")}}),n}function ko(e,t){let n=m("div","pf-combobox"),r=document.createElement("input");if(r.className="pf-combobox-input",r.type="text",r.name=C(e.name,t),ae(r,e),e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.value!==void 0)r.value=C(e.value,t);let o=r.name,i=t.store.get(o);if(i!=null)r.value=L(i);r.style.padding="6px 12px",r.style.borderRadius="6px",r.style.width="100%",r.style.boxSizing="border-box";let s=m("div","pf-combobox-dropdown");if(s.style.display="none",s.style.position="absolute",s.style.borderRadius="6px",s.style.maxHeight="200px",s.style.overflowY="auto",s.style.zIndex="50",H(e,s,t),r.addEventListener("focus",()=>{s.style.display="block"}),r.addEventListener("blur",()=>{setTimeout(()=>{s.style.display="none"},150)}),e.searchable!==!1)r.addEventListener("input",()=>{let a=r.value.toLowerCase();for(let l of Array.from(s.querySelectorAll(".pf-combobox-option"))){let d=(l.textContent??"").toLowerCase();l.style.display=d.includes(a)?"":"none"}});if(e.onChange!=null)n.addEventListener("pf-combobox-select",()=>{I(j(e.onChange,{...W(t),scope:{...t.scope,$event:r.value}}),"onChange")});return n.style.position="relative",n.appendChild(r),n.appendChild(s),n}function So(e,t){let n=m("div","pf-combobox-option");return n.style.padding="6px 12px",n.style.cursor="pointer",n.textContent=C(e.label??e.value,t),n.dataset.value=C(e.value,t),n.addEventListener("mousedown",()=>{let r=n.closest(".pf-combobox"),o=r?.querySelector("input");if(o)o.value=n.dataset.value??"",t.store.set(o.name,o.value),r?.dispatchEvent(new CustomEvent("pf-combobox-select",{bubbles:!1}))}),n}function Ao(e,t){let n=m("div","pf-choice-card");if(n.style.padding="16px",n.style.cursor="pointer",n.style.transition="border-color 0.2s",n.dataset.value=C(e.value,t),e.selected===!0)n.dataset.selected="true";if(e.label!=null){let r=m("div","pf-choice-card-label");r.textContent=C(e.label,t),r.style.fontWeight="600",n.appendChild(r)}if(e.description!=null){let r=m("div","pf-choice-card-description");r.textContent=C(e.description,t),r.style.fontSize="14px",n.appendChild(r)}return H(e,n,t),n}function cn(){p("Tabs",Eo),p("Tab",Ro),p("Accordion",To),p("AccordionItem",No),p("Dialog",Mo),p("Popover",Lo),p("Tooltip",Ho),p("HoverCard",Po),p("Carousel",$o)}function Eo(e,t){let n=m("div","pf-tabs"),r=m("div","pf-tabs-bar");r.setAttribute("role","tablist"),r.style.display="flex",r.style.gap="4px",r.style.marginBottom="12px";let o=[],i=[],s=e.children??[],a=(()=>{let d=e.defaultTab;if(typeof d==="number")return d>=0&&d<s.length?d:0;if(typeof d==="string"){let u=s.findIndex((c)=>c.title===d);return u>=0?u:0}return 0})();if(e.children)for(let d=0;d<e.children.length;d++){let u=e.children[d],c=`pf-tab-${Math.random().toString(36).slice(2,8)}`,g=`pf-panel-${Math.random().toString(36).slice(2,8)}`,h=document.createElement("button");h.type="button",h.className="pf-tab-trigger",h.textContent=u.title??`Tab ${d+1}`,h.setAttribute("role","tab"),h.setAttribute("aria-selected",d===a?"true":"false"),h.setAttribute("aria-controls",g),h.id=c,h.tabIndex=d===a?0:-1,h.style.padding="8px 16px",h.style.border="none",h.style.background="none",h.style.cursor="pointer",h.style.borderBottom="2px solid transparent",h.style.marginBottom="-2px",h.style.fontSize="14px";let y=m("div","pf-tab-panel");if(y.style.display=d===a?"block":"none",y.setAttribute("role","tabpanel"),y.setAttribute("aria-labelledby",c),y.id=g,y.tabIndex=0,H(u,y,t),h.addEventListener("click",()=>{l(d)}),d===a)h.classList.add("pf-tab-active"),h.style.fontWeight="600";i.push(h),o.push(y),r.appendChild(h)}function l(d){o.forEach((u)=>u.style.display="none"),i.forEach((u)=>{u.style.borderBottomColor="transparent",u.style.fontWeight="normal",u.classList.remove("pf-tab-active"),u.setAttribute("aria-selected","false"),u.tabIndex=-1}),o[d].style.display="block",i[d].classList.add("pf-tab-active"),i[d].style.fontWeight="600",i[d].setAttribute("aria-selected","true"),i[d].tabIndex=0,i[d].focus()}r.addEventListener("keydown",(d)=>{let u=i.indexOf(d.target);if(u<0)return;let c;if(d.key==="ArrowRight")c=(u+1)%i.length;else if(d.key==="ArrowLeft")c=(u-1+i.length)%i.length;else if(d.key==="Home")c=0;else if(d.key==="End")c=i.length-1;else return;d.preventDefault(),l(c)}),n.appendChild(r);for(let d of o)n.appendChild(d);return n}function Ro(e,t){let n=m("div","pf-tab");return H(e,n,t),n}function To(e,t){let n=m("div","pf-accordion");return H(e,n,t),n}function No(e,t){let n=m("div","pf-accordion-item"),r=`pf-acc-${Math.random().toString(36).slice(2,8)}`,o=document.createElement("button");o.type="button",o.className="pf-accordion-trigger",o.textContent=e.title??"",o.setAttribute("aria-expanded","false"),o.setAttribute("aria-controls",r),o.style.width="100%",o.style.textAlign="left",o.style.padding="12px 0",o.style.border="none",o.style.background="none",o.style.cursor="pointer",o.style.fontSize="14px",o.style.fontWeight="500";let i=m("div","pf-accordion-content");return i.id=r,i.setAttribute("role","region"),i.setAttribute("aria-labelledby",o.id),i.style.display="none",i.style.paddingBottom="12px",H(e,i,t),o.addEventListener("click",()=>{let s=i.style.display!=="none";i.style.display=s?"none":"block",o.setAttribute("aria-expanded",s?"false":"true")}),n.appendChild(o),n.appendChild(i),n}function Mo(e,t){let n=m("div","pf-dialog-wrapper");if(e.trigger!=null){let i=J(e.trigger,t);i.addEventListener("click",()=>{r.showModal()}),n.appendChild(i)}let r=document.createElement("dialog");if(r.className="pf-dialog",r.setAttribute("aria-modal","true"),r.style.maxWidth="500px",r.style.width="100%",r.style.padding="24px",e.title!=null){let i=m("h2","pf-dialog-title");i.textContent=C(e.title,t),i.id=`pf-dialog-title-${Math.random().toString(36).slice(2,8)}`,r.setAttribute("aria-labelledby",i.id),r.appendChild(i)}if(e.description!=null){let i=m("p","pf-dialog-desc");i.textContent=C(e.description,t),r.appendChild(i)}let o=m("div","pf-dialog-body");if(H(e,o,t),r.appendChild(o),e.dismissible!==!1)r.addEventListener("click",(i)=>{if(i.target===r)r.close()});return document.addEventListener("prefab:close-overlay",()=>r.close()),n.appendChild(r),n}function Lo(e,t){let n=m("div","pf-popover");n.style.position="relative",n.style.display="inline-block";let r=m("div","pf-popover-content");if(r.style.display="none",r.style.position="absolute",r.style.zIndex="50",r.style.padding="12px",r.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",e.title!=null){let i=m("div","pf-popover-title");i.textContent=C(e.title,t),i.style.fontWeight="600",i.style.marginBottom="4px",r.appendChild(i)}H(e,r,t);let o=()=>{r.style.display=r.style.display==="none"?"block":"none"};if(e.trigger!=null){let i=J(e.trigger,t);i.addEventListener("click",(s)=>{s.stopPropagation(),o()}),n.appendChild(i)}else n.addEventListener("click",(i)=>{if(r.contains(i.target)&&r.style.display!=="none")return;o()});return n.appendChild(r),n}function Ho(e,t){let n=m("div","pf-tooltip");n.style.position="relative",n.style.display="inline-block";let r=`pf-tip-${Math.random().toString(36).slice(2,8)}`,o=m("div","pf-tooltip-content");return o.id=r,o.setAttribute("role","tooltip"),o.textContent=C(e.content??"",t),o.style.display="none",o.style.position="absolute",o.style.bottom="100%",o.style.left="50%",o.style.transform="translateX(-50%)",o.style.padding="4px 8px",o.style.borderRadius="4px",o.style.color="#fff",o.style.fontSize="12px",o.style.whiteSpace="nowrap",o.style.zIndex="50",H(e,n,t),n.setAttribute("aria-describedby",r),n.addEventListener("mouseenter",()=>{o.style.display="block"}),n.addEventListener("mouseleave",()=>{o.style.display="none"}),n.addEventListener("focus",()=>{o.style.display="block"},!0),n.addEventListener("blur",()=>{o.style.display="none"},!0),n.appendChild(o),n}function Po(e,t){let n=m("div","pf-hover-card");n.style.position="relative",n.style.display="inline-block";let r=m("div","pf-hover-card-content");if(r.style.display="none",r.style.position="absolute",r.style.zIndex="50",r.style.padding="16px",r.style.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1)",r.style.minWidth="200px",e.trigger!=null)n.appendChild(J(e.trigger,t));return H(e,r,t),n.addEventListener("mouseenter",()=>{r.style.display="block"}),n.addEventListener("mouseleave",()=>{r.style.display="none"}),n.appendChild(r),n}function $o(e,t){let n=m("div","pf-carousel");n.style.position="relative",n.style.overflow="hidden",n.setAttribute("role","region"),n.setAttribute("aria-roledescription","carousel"),n.setAttribute("aria-label",C(e.label??"Carousel",t));let r=m("div","pf-carousel-track");r.style.display="flex",r.style.transition="transform 0.3s ease",H(e,r,t);let o=0,i=e.children?.length??0,s=document.createElement("button");s.type="button",s.textContent="‹",s.className="pf-carousel-prev",s.setAttribute("aria-label","Previous slide"),s.style.position="absolute",s.style.left="4px",s.style.top="50%",s.style.transform="translateY(-50%)",s.style.zIndex="10";let a=document.createElement("button");a.type="button",a.textContent="›",a.className="pf-carousel-next",a.setAttribute("aria-label","Next slide"),a.style.position="absolute",a.style.right="4px",a.style.top="50%",a.style.transform="translateY(-50%)",a.style.zIndex="10";let l=()=>{r.style.transform=`translateX(-${o*100}%)`};return s.addEventListener("click",()=>{if(i===0)return;o=Math.max(0,o-1),l()}),a.addEventListener("click",()=>{if(i===0)return;o=Math.min(i-1,o+1),l()}),n.appendChild(r),n.appendChild(s),n.appendChild(a),n}function pn(){p("ForEach",Oo),p("If",un),p("Elif",Do),p("Else",jo),p("Condition",Io),p("Define",Fo),p("Use",Bo),p("Slot",Jo)}function Oo(e,t){let n=document.createDocumentFragment(),r=e.expression;if(!r)return n;let o;if(Z(r)){let s=Q(r,t.store,t.scope);o=Array.isArray(s)?s:[]}else{let s=t.store.get(r);o=Array.isArray(s)?s:[]}let i=e.let??{};for(let s=0;s<o.length;s++){let a=o[s],l={...t.scope,$item:a,$index:s,...i},d={...t,scope:l};if(e.children)se(e.children,n,d)}return n}function un(e,t){if(fn(e.condition,t)){let r=document.createDocumentFragment();if(e.children)se(e.children,r,t);return r}return document.createDocumentFragment()}function Do(e,t){return un(e,t)}function jo(e,t){let n=document.createDocumentFragment();if(e.children)se(e.children,n,t);return n}function fn(e,t){if(!e)return!1;if(Z(e))return Boolean(Q(e,t.store,t.scope));return Boolean(t.store.get(e))}function Io(e,t){let n=document.createDocumentFragment(),r=e.cases,o=e.else;if(r){for(let i of r)if(fn(i.when,t)){if(i.children)se(i.children,n,t);return n}}if(o)se(o,n,t);return n}function Fo(e,t){let n=e.name;if(n&&e.children)t.templates=t.templates??{},t.templates[n]=e.children;return document.createDocumentFragment()}function Bo(e,t){let n=document.createDocumentFragment(),r=e.def??e.name,o=t.templates?.[r];if(!o)return n;let i=e.overrides??{},s={...t.scope,...i},a={...t.slots??{},...e.slots??{}};if(Array.isArray(e.children))a.default=e.children;let l={...t,scope:s,slots:a};for(let d of o)n.appendChild(J(d,l));return n}function Jo(e,t){let n=document.createDocumentFragment(),r=e.name??"default",i=t.slots?.[r]??e.children;if(i)for(let s of i)n.appendChild(J(s,t));return n}function mn(){p("Alert",Vo),p("AlertTitle",zo),p("AlertDescription",_o)}function Vo(e,t){let n=m("div","pf-alert");n.setAttribute("role","alert");let r=e.variant??"default";if(n.setAttribute("data-variant",r),n.style.padding="12px 16px",e.icon!=null){let o=m("span","pf-alert-icon");o.setAttribute("data-icon",e.icon),o.style.marginRight="8px",n.appendChild(o)}return H(e,n,t),n}function zo(e,t){let n=m("h5","pf-alert-title");return n.textContent=C(e.content,t),n.style.fontWeight="600",n.style.marginBottom="4px",n}function _o(e,t){let n=m("p","pf-alert-description");return n.textContent=C(e.content,t),n.style.fontSize="14px",n}function gn(){p("Image",Wo),p("Audio",Ko),p("Video",Go),p("Embed",qo),p("Svg",Xo),p("DropZone",Zo),p("Mermaid",Qo)}function Wo(e,t){let n=document.createElement("img");if(n.className="pf-image",n.src=C(e.src,t),e.alt!=null)n.alt=C(e.alt,t);if(e.width!=null)n.width=e.width;if(e.height!=null)n.height=e.height;return n.style.maxWidth="100%",n}function Ko(e,t){let n=document.createElement("audio");return n.className="pf-audio",n.src=C(e.src,t),n.controls=!0,n}function Go(e,t){let n=document.createElement("video");if(n.className="pf-video",n.src=C(e.src,t),n.controls=!0,e.width!=null)n.width=e.width;if(e.height!=null)n.height=e.height;return n.style.maxWidth="100%",n}function qo(e,t){let n=m("div","pf-embed"),r=document.createElement("iframe");return r.src=C(e.src,t),r.style.width="100%",r.style.height=e.height!=null?`${e.height}px`:"400px",r.style.border="none",r.setAttribute("sandbox","allow-scripts"),n.appendChild(r),n}var Uo=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 Xo(e,t){let n=m("div","pf-svg"),r=C(e.content,t);if(!r.includes("<svg"))return n;if(!/<svg[^>]*\sxmlns\s*=/.test(r))r=r.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"');let i=new DOMParser().parseFromString(r,"image/svg+xml").querySelector("svg");if(!i)return n;return hn(i),n.appendChild(document.importNode(i,!0)),n}function hn(e){let t=Array.from(e.children);for(let n of t){if(!Uo.has(n.tagName.toLowerCase())){n.remove();continue}for(let r of Array.from(n.attributes)){let o=r.name.toLowerCase();if(o.startsWith("on")||o==="href"&&r.value.trim().toLowerCase().startsWith("javascript:"))n.removeAttribute(r.name)}hn(n)}}function Yo(e,t){let n=(t??"").split(",").map((i)=>i.trim().toLowerCase()).filter(Boolean);if(n.length===0)return!0;let r=e.name.toLowerCase(),o=e.type.toLowerCase();return n.some((i)=>{if(i.startsWith("."))return r.endsWith(i);if(i.endsWith("/*"))return o.startsWith(i.slice(0,-1));return o===i})}function Zo(e,t){let n=m("div","pf-dropzone");n.style.padding="32px",n.style.textAlign="center",n.style.cursor="pointer",n.textContent=C(e.label??"Drop files here",t);let r=document.createElement("input");if(r.type="file",r.style.display="none",e.accept!=null)r.accept=e.accept;if(e.multiple===!0)r.multiple=!0;n.appendChild(r),n.setAttribute("role","button"),n.tabIndex=0;function o(s){let a=Array.from(s??[]).filter((l)=>Yo(l,e.accept));return e.multiple===!0?a:a.slice(0,1)}function i(s){if(s.length===0)return;if(e.resultKey!=null)t.store.set(e.resultKey,s),t.rerender();if(e.onDrop!=null)I(j(e.onDrop,{...W(t),scope:{...t.scope,$result:s}}),"onDrop")}return r.addEventListener("change",()=>{i(o(r.files)),r.value=""}),n.addEventListener("click",()=>r.click()),n.addEventListener("keydown",(s)=>{if(s.key==="Enter"||s.key===" ")s.preventDefault(),r.click()}),n.addEventListener("dragover",(s)=>{s.preventDefault(),n.classList.add("pf-dropzone-active")}),n.addEventListener("dragleave",()=>{n.classList.remove("pf-dropzone-active")}),n.addEventListener("drop",(s)=>{s.preventDefault(),n.classList.remove("pf-dropzone-active"),i(o(s.dataTransfer?.files??null))}),n}function Qo(e,t){let n=m("div","pf-mermaid");n.setAttribute("data-mermaid","true");let r=C(e.content,t);if(n.textContent=r,typeof globalThis.mermaid<"u")n.classList.add("mermaid"),n.textContent=r;return n}var ei="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",ti="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",yt=null,qe=null;async function ni(){if(yt)return yt;if(qe)return qe;return qe=import(ei).then((e)=>{let t=e;return t.GlobalWorkerOptions.workerSrc=ti,yt=t,t}),qe}function yn(){p("PdfViewer",ri)}function ri(e,t){let n=m("div","pf-pdf-viewer"),r=e.src!=null?C(e.src,t):void 0,o=e.data,i=e.page!=null?e.page:1,s=e.zoom!=null?e.zoom:"fit-width",a=e.toolbar!==!1,l=e.height!=null?e.height:600;n.style.height=`${l}px`,n.style.display="flex",n.style.flexDirection="column",n.style.overflow="hidden",n.style.border="1px solid var(--color-border-primary, #e5e7eb)",n.style.borderRadius="var(--border-radius-md, 0.375rem)",n.style.background="var(--color-background-secondary, #f9fafb)";let d=m("div","pf-pdf-loading");return d.textContent="Loading PDF…",d.style.display="flex",d.style.alignItems="center",d.style.justifyContent="center",d.style.flex="1",d.style.color="var(--color-text-secondary, #6b7280)",n.appendChild(d),oi(n,d,{src:r,data:o,initialPage:i,zoom:s,showToolbar:a}),n}async function oi(e,t,n){try{let r=await ni(),o;if(n.src)o={url:n.src};else if(n.data){let g=atob(n.data),h=new Uint8Array(g.length);for(let y=0;y<g.length;y++)h[y]=g.charCodeAt(y);o={data:h}}else{t.textContent="Error: No PDF source provided";return}let i=await r.getDocument(o).promise;t.remove();let s=Math.max(1,Math.min(n.initialPage,i.numPages)),a=null,l=null;if(n.showToolbar){let g=ii(i.numPages,s,{onPrev:()=>{if(s>1)s--,c()},onNext:()=>{if(s<i.numPages)s++,c()},onPageChange:(h)=>{let y=Math.max(1,Math.min(h,i.numPages));if(y!==s)s=y,c()}});a=g.pageInput,l=g.pageCount,e.insertBefore(g.el,e.firstChild)}let d=m("div","pf-pdf-canvas-container");d.style.flex="1",d.style.overflow="auto",d.style.display="flex",d.style.justifyContent="center",d.style.padding="8px",e.appendChild(d);let u=document.createElement("canvas");u.style.display="block",u.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",d.appendChild(u);async function c(){let g=await i.getPage(s),h=d.clientWidth-16,y,f=g.getViewport({scale:1});if(n.zoom==="fit-width")y=h/f.width;else if(n.zoom==="fit-page"){let S=d.clientHeight-16,N=h/f.width,k=S/f.height;y=Math.min(N,k)}else y=typeof n.zoom==="number"?n.zoom:1;let b=g.getViewport({scale:y});u.width=b.width,u.height=b.height,u.style.width=`${b.width}px`,u.style.height=`${b.height}px`;let w=u.getContext("2d");if(!w)return;if(await g.render({canvasContext:w,viewport:b}).promise,a)a.value=String(s);if(l)l.textContent=`/ ${i.numPages}`}await c()}catch(r){t.textContent=`PDF Error: ${r instanceof Error?r.message:String(r)}`,t.style.color="var(--color-text-danger, #dc2626)"}}function ii(e,t,n){let r=m("div","pf-pdf-toolbar");r.style.display="flex",r.style.alignItems="center",r.style.gap="8px",r.style.padding="6px 12px",r.style.borderBottom="1px solid var(--color-border-primary, #e5e7eb)",r.style.background="var(--color-background-primary, #fff)",r.style.flexShrink="0",r.style.fontSize="13px";let o=document.createElement("button");o.textContent="‹",o.title="Previous page",o.className="pf-pdf-btn",bn(o),o.addEventListener("click",n.onPrev);let i=document.createElement("button");i.textContent="›",i.title="Next page",i.className="pf-pdf-btn",bn(i),i.addEventListener("click",n.onNext);let s=document.createElement("input");s.type="number",s.min="1",s.max=String(e),s.value=String(t),s.style.width="48px",s.style.textAlign="center",s.style.border="1px solid var(--color-border-primary, #e5e7eb)",s.style.borderRadius="4px",s.style.padding="2px 4px",s.style.fontSize="13px",s.addEventListener("change",()=>{let l=parseInt(s.value,10);if(!isNaN(l))n.onPageChange(l)});let a=document.createElement("span");return a.textContent=`/ ${e}`,a.style.color="var(--color-text-secondary, #6b7280)",r.appendChild(o),r.appendChild(s),r.appendChild(a),r.appendChild(i),{el:r,pageInput:s,pageCount:a}}function bn(e){e.style.border="1px solid var(--color-border-primary, #e5e7eb)",e.style.borderRadius="4px",e.style.background="var(--color-background-primary, #fff)",e.style.cursor="pointer",e.style.padding="2px 8px",e.style.fontSize="16px",e.style.lineHeight="1"}var Xe=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"];function pe(e,t){let n=document.createElement("div");return n.className="pf-chart-tooltip",e.appendChild(n),e.addEventListener("mouseleave",()=>{n.classList.remove("pf-visible")}),{wrapper:e,tooltip:n,svgEl:t}}function ee(e,t,n,r,o){let{tooltip:i,svgEl:s,wrapper:a}=e;if(o.length===0)return;let l="";if(r)l+=`<div class="pf-chart-tooltip-label">${Ue(r)}</div>`;for(let b of o)l+='<div class="pf-chart-tooltip-row">',l+=`<span class="pf-chart-tooltip-dot" style="background:${Ue(b.color)}"></span>`,l+=`<span>${Ue(b.label)}:</span> <strong>${Ue(String(b.value))}</strong>`,l+="</div>";i.innerHTML=l;let d=s.getBoundingClientRect(),u=a.getBoundingClientRect(),c=s.viewBox.baseVal,g=d.width/(c.width||1),h=d.left-u.left+t*g,y=i.offsetWidth||100,f=h+12;if(f+y>u.width)f=h-y-12;i.style.left=`${Math.max(0,f)}px`,i.style.top="4px",i.classList.add("pf-visible")}function Ue(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Cn(e,t,n,r,o,i,s,a){let l=o.plotWidth/n.length;for(let d=0;d<n.length;d++){let u=o.plotLeft+d*l,c=document.createElementNS("http://www.w3.org/2000/svg","rect");c.setAttribute("x",String(u)),c.setAttribute("y",String(o.plotTop)),c.setAttribute("width",String(l)),c.setAttribute("height",String(o.plotHeight)),c.setAttribute("fill","transparent"),c.style.cursor="default";let g=i?n[d][i]:void 0,h=g!=null?a?a(g):L(g):void 0,y=r.map((S,N)=>({label:S.label??S.dataKey,value:s(n[d][S.dataKey],S,N),color:S.color??Xe[N%Xe.length]})),f=u+l/2,b=()=>ee(e,f,o.plotTop,h,y),w=()=>e.tooltip.classList.remove("pf-visible");c.addEventListener("mouseenter",b),c.addEventListener("mouseleave",w),c.addEventListener("touchstart",b,{passive:!0}),c.addEventListener("touchend",w,{passive:!0}),t.appendChild(c)}}function vn(e,t,n,r,o,i,s,a,l,d){let u=n.length===1?o.plotWidth:o.plotWidth/(n.length-1);for(let c=0;c<n.length;c++){let g=n.length===1?(o.plotLeft+o.plotRight)/2:o.plotLeft+c/(n.length-1)*o.plotWidth,h=n.length===1?o.plotLeft:g-u/2,y=n.length===1?o.plotWidth:u,f=document.createElementNS("http://www.w3.org/2000/svg","rect");f.setAttribute("x",String(Math.max(o.plotLeft,h))),f.setAttribute("y",String(o.plotTop)),f.setAttribute("width",String(Math.min(y,o.plotRight-Math.max(o.plotLeft,h)))),f.setAttribute("height",String(o.plotHeight)),f.setAttribute("fill","transparent"),f.style.cursor="default";let b=i?n[c][i]:void 0,w=b!=null?d?d(b):L(b):void 0,S=r.map((R,P)=>({label:R.label??R.dataKey,value:s(n[c][R.dataKey],R,P),color:R.color??Xe[P%Xe.length]})),N=()=>{if(ee(e,g,o.plotTop,w,S),a)a.setAttribute("x1",String(g)),a.setAttribute("x2",String(g)),a.setAttribute("opacity","1");if(l)for(let R of l){for(let P of R)P.setAttribute("data-visible","false");R[c]?.setAttribute("data-visible","true")}},k=()=>{if(e.tooltip.classList.remove("pf-visible"),a)a.setAttribute("opacity","0");if(l)for(let R of l)for(let P of R)P.setAttribute("data-visible","false")};f.addEventListener("mouseenter",N),f.addEventListener("mouseleave",k),f.addEventListener("touchstart",N,{passive:!0}),f.addEventListener("touchend",k,{passive:!0}),t.appendChild(f)}}var q=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],re="var(--muted-foreground, #6b7280)",ve="var(--border, #e5e7eb)",ue="10";function Ye(e,t,n,r=!1){let o=n?44:0,i=e-(r?44:0),s=10,a=t-24;return{plotLeft:o,plotRight:i,plotTop:10,plotBottom:a,plotWidth:i-o,plotHeight:a-10}}function wn(e,t=5){if(e<=0)return[0];let n=e/t,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r,i=o<=1.5?r:o<=3?2*r:o<=7?5*r:10*r,s=[];for(let a=0;a<=e+i*0.01;a+=i)s.push(Math.round(a*1000)/1000);return s}function Ct(e,t,n,r,o){let i=wn(n);for(let s of i){let a=t.plotBottom-(n>0?s/n*t.plotHeight:0),l=U("text",{x:t.plotLeft-6,y:a+3,"text-anchor":"end","font-size":ue,fill:re});if(l.textContent=xt(s,o),e.appendChild(l),r&&s>0)e.appendChild(U("line",{x1:t.plotLeft,y1:a,x2:t.plotRight,y2:a,stroke:ve,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function vt(e,t,n,r){let o=wn(n);for(let i of o){let s=t.plotBottom-(n>0?i/n*t.plotHeight:0),a=U("text",{x:t.plotRight+6,y:s+3,"text-anchor":"start","font-size":ue,fill:re});a.textContent=xt(i,r),e.appendChild(a)}}function wt(e,t,n,r,o,i){for(let s=0;s<t.length;s++){let a=t[s][n],l=U("text",{x:r(s),y:o+14,"text-anchor":"middle","font-size":ue,fill:re});l.textContent=a==null?"":i?i(a):L(a),e.appendChild(l)}}function Ze(e,t){e.appendChild(U("line",{x1:t.plotLeft,y1:t.plotBottom,x2:t.plotRight,y2:t.plotBottom,stroke:re,"stroke-width":1}))}function te(e,t,n){if(e==null)return"";let r=K(`{{ __v | ${t} }}`,{...n,scope:{...n.scope,__v:e}});return L(r??e)}function xt(e,t){if(t==="currency")return`$${e.toLocaleString()}`;if(t==="percent")return`${e}%`;if(e>=1e6)return`${(e/1e6).toFixed(1)}M`;if(e>=1000)return`${(e/1000).toFixed(1)}K`;return String(e)}function oe(e){let t=e.yAxisFormat??e.valueFormat;return t&&t!=="auto"?t:void 0}function kt(e,t,n){return(r,o)=>{if(r===null||r===void 0)return"—";if(o.tooltipFormat)return te(r,o.tooltipFormat,e);let i=o.yAxisId==="right"?n:t;return xt(Number(r),i)}}function le(e,t,n){let r=document.createElementNS("http://www.w3.org/2000/svg","svg");if(r.setAttribute("width","100%"),r.setAttribute("height",String(t)),r.setAttribute("viewBox",`0 0 ${e} ${t}`),r.setAttribute("role","img"),n)r.setAttribute("aria-label",`${n} chart`);return r.style.overflow="visible",r}function U(e,t){let n=document.createElementNS("http://www.w3.org/2000/svg",e);for(let[r,o]of Object.entries(t))n.setAttribute(r,String(o));return n}function Qe(e,t){let n=U("text",e);return n.textContent=t,n}function fe(e,t,n,r){let o=r*Math.PI/180;return{x:e+n*Math.cos(o),y:t-n*Math.sin(o)}}function St(e,t,n,r,o){let i=Math.max(2,Math.ceil(Math.abs(o-r)/4)),s=[];for(let a=0;a<=i;a++){let l=fe(e,t,n,r+(o-r)*a/i);s.push(`${a===0?"M":"L"} ${l.x.toFixed(2)} ${l.y.toFixed(2)}`)}return s.join(" ")}function me(e,t,n){if(n===!1||t.length<=1)return;let r=m("div","pf-chart-legend");r.style.display="flex",r.style.gap="12px",r.style.fontSize="12px",r.style.marginBottom="8px";for(let o=0;o<t.length;o++){let i=m("div","pf-chart-legend-item");i.style.display="flex",i.style.alignItems="center",i.style.gap="4px";let s=m("span");s.style.width="8px",s.style.height="8px",s.style.borderRadius="50%",s.style.backgroundColor=t[o].color??q[o%q.length];let a=m("span");a.textContent=t[o].label??t[o].dataKey,i.appendChild(s),i.appendChild(a),r.appendChild(i)}e.appendChild(r)}function kn(){p("BarChart",si),p("LineChart",xn),p("AreaChart",xn),p("PieChart",ai),p("RadarChart",ci),p("ScatterChart",li),p("RadialChart",di),p("Histogram",pi)}function si(e,t){let n=m("div","pf-chart pf-bar-chart"),r=K(e.data,t)??[],o=e.series??[],i=e.height??300;if(r.length===0||o.length===0)return n.textContent="No chart data",n;let s=e.showYAxis!==!1,a=e.showGrid===!0,l=e.showYAxisRight===!0,d=e.showTooltip!==!1,u=e.xAxis,c=e.tooltipXKey,g=e.xAxisFormat,h=e.tooltipXFormat,y=o.filter((x)=>x.yAxisId!=="right"),f=o.filter((x)=>x.yAxisId==="right"),b=l&&f.length>0,w=y.length>0?Math.max(...r.flatMap((x)=>y.map((v)=>Number(x[v.dataKey]??0))),1):1,S=b?Math.max(...r.flatMap((x)=>f.map((v)=>Number(x[v.dataKey]??0))),1):1,N=400,k=Ye(N,i,s,b),R=le(N,i,"Bar");if(s)Ct(R,k,w,a,oe(e));if(b)vt(R,k,S,e.yAxisRightFormat);Ze(R,k);let P=k.plotWidth/r.length,M=P/(o.length+1);for(let x=0;x<r.length;x++)for(let v=0;v<o.length;v++){let T=o[v],D=r[x][T.dataKey];if(D===null||D===void 0)continue;let G=T.yAxisId==="right"?S:w,B=Number(D),A=Math.max(0,B/G*k.plotHeight),z=k.plotLeft+x*P+v*M+M/2,E=document.createElementNS("http://www.w3.org/2000/svg","rect");E.setAttribute("x",String(z)),E.setAttribute("y",String(k.plotBottom-A)),E.setAttribute("width",String(M*0.8)),E.setAttribute("height",String(A)),E.setAttribute("fill",T.color??q[v%q.length]),E.setAttribute("rx","2"),R.appendChild(E)}if(u){let x=g?(v)=>te(v,g,t):void 0;wt(R,r,u,(v)=>k.plotLeft+v*P+P/2,k.plotBottom,x)}if(d){let x=pe(n,R),v=kt(t,oe(e),e.yAxisRightFormat);Cn(x,R,r,o,k,c??u,v,h?(D)=>te(D,h,t):void 0)}return me(n,o,e.showLegend),n.appendChild(R),n}function xn(e,t){let n=m("div",`pf-chart pf-${e.type.toLowerCase()}-chart`),r=K(e.data,t)??[],o=e.series??[],i=e.height??300;if(r.length===0||o.length===0)return n.textContent="No chart data",n;let s=e.showYAxis!==!1,a=e.showGrid===!0,l=e.showYAxisRight===!0,d=e.showTooltip!==!1,u=e.xAxis,c=e.tooltipXKey,g=e.xAxisFormat,h=e.tooltipXFormat,y=o.filter((v)=>v.yAxisId!=="right"),f=o.filter((v)=>v.yAxisId==="right"),b=l&&f.length>0,w=y.length>0?Math.max(...r.flatMap((v)=>y.map((T)=>Number(v[T.dataKey]??0))),1):1,S=b?Math.max(...r.flatMap((v)=>f.map((T)=>Number(v[T.dataKey]??0))),1):1,N=400,k=Ye(N,i,s,b),R=le(N,i,e.type==="AreaChart"?"Area":"Line"),P=e.type==="AreaChart";if(s)Ct(R,k,w,a,oe(e));if(b)vt(R,k,S,e.yAxisRightFormat);Ze(R,k);let M=[];for(let v=0;v<o.length;v++){let T=o[v],D=T.yAxisId==="right",V=D?S:w,G=T.color??q[v%q.length],B=r.map((E,F)=>{let _=E[T.dataKey],X=_===null||_===void 0,de=r.length===1?(k.plotLeft+k.plotRight)/2:k.plotLeft+F/(r.length-1)*k.plotWidth,Bn=X?k.plotBottom:k.plotBottom-Number(_)/V*k.plotHeight;return{x:de,y:Bn,isNull:X}});if(P){let E=[],F=()=>{if(E.length<2){E=[];return}let _=`M ${E[0].x},${k.plotBottom} `+E.map((de)=>`L ${de.x},${de.y}`).join(" ")+` L ${E[E.length-1].x},${k.plotBottom} Z`,X=document.createElementNS("http://www.w3.org/2000/svg","path");X.setAttribute("d",_),X.setAttribute("fill",G),X.setAttribute("opacity","0.15"),R.appendChild(X),E=[]};for(let _ of B){if(_.isNull){F();continue}E.push(_)}F()}let A="";for(let E of B){if(E.isNull)continue;let F=B.indexOf(E),_=F===0||B[F-1].isNull;A+=`${_?"M":"L"} ${E.x},${E.y} `}if(A){let E=document.createElementNS("http://www.w3.org/2000/svg","path");if(E.setAttribute("d",A.trim()),E.setAttribute("fill","none"),E.setAttribute("stroke",G),E.setAttribute("stroke-width","2"),D)E.setAttribute("stroke-dasharray","6 3");R.appendChild(E)}let z=[];for(let E of B){let F=document.createElementNS("http://www.w3.org/2000/svg","circle");if(F.setAttribute("cx",String(E.x)),F.setAttribute("cy",String(E.y)),F.setAttribute("r","4"),F.setAttribute("fill",G),F.setAttribute("class","pf-data-dot"),F.setAttribute("data-visible","false"),F.style.pointerEvents="none",E.isNull)F.style.display="none";R.appendChild(F),z.push(F)}M.push(z)}let x=document.createElementNS("http://www.w3.org/2000/svg","line");if(x.setAttribute("class","pf-crosshair"),x.setAttribute("x1",String(k.plotLeft)),x.setAttribute("x2",String(k.plotLeft)),x.setAttribute("y1",String(k.plotTop)),x.setAttribute("y2",String(k.plotBottom)),x.setAttribute("stroke",re),x.setAttribute("stroke-width","1"),x.setAttribute("stroke-dasharray","3 3"),x.setAttribute("opacity","0"),R.appendChild(x),u){let v=g?(T)=>te(T,g,t):void 0;wt(R,r,u,(T)=>r.length===1?(k.plotLeft+k.plotRight)/2:k.plotLeft+T/(r.length-1)*k.plotWidth,k.plotBottom,v)}if(d){let v=pe(n,R),T=kt(t,oe(e),e.yAxisRightFormat);vn(v,R,r,o,k,c??u,T,x,M,h?(V)=>te(V,h,t):void 0)}return me(n,o,e.showLegend),n.appendChild(R),n}function ai(e,t){let n=m("div","pf-chart pf-pie-chart"),r=K(e.data,t)??[],o=e.series??[],i=e.height??300,s=Math.min(i,300),a=e.showTooltip!==!1,l=e.dataKey??o[0]?.dataKey,d=e.nameKey??e.tooltipXKey??e.xAxis,u=o.length>0?o:l?[{dataKey:l,label:l}]:[];if(r.length===0||!l)return n.textContent="No chart data",n;let c=le(s,s,"Pie"),g=s/2,h=s/2,y=s/2-10,f=e.tooltipXFormat,b=oe(e),w=(P)=>b?te(P,b,t):String(P),S=r.map((P)=>Number(P[l]??0)),N=S.reduce((P,M)=>P+M,0);if(N===0)return n.textContent="No chart data",n.appendChild(c),n;let k=a?pe(n,c):void 0,R=-Math.PI/2;for(let P=0;P<S.length;P++){let M=S[P]/N*2*Math.PI,x=R+M,v=M>Math.PI?1:0,T=g+y*Math.cos(R),D=h+y*Math.sin(R),V=g+y*Math.cos(x),G=h+y*Math.sin(x),B=q[P%q.length],A=document.createElementNS("http://www.w3.org/2000/svg","path");if(A.setAttribute("d",`M ${g},${h} L ${T},${D} A ${y},${y} 0 ${v} 1 ${V},${G} Z`),A.setAttribute("fill",B),A.style.cursor="default",k){let z=d?r[P][d]:void 0,E=z!=null?f?te(z,f,t):L(z):`Slice ${P+1}`,F=`${(S[P]/N*100).toFixed(1)}%`,_=R+M/2,X=g+y*0.6*Math.cos(_);A.addEventListener("mouseenter",()=>{ee(k,X,h,E,[{label:u[0].label??l,value:`${w(S[P])} (${F})`,color:B}])}),A.addEventListener("mouseleave",()=>{k.tooltip.classList.remove("pf-visible")}),A.addEventListener("touchstart",()=>{ee(k,X,h,E,[{label:u[0].label??l,value:`${w(S[P])} (${F})`,color:B}])},{passive:!0}),A.addEventListener("touchend",()=>{k.tooltip.classList.remove("pf-visible")},{passive:!0})}c.appendChild(A),R=x}return me(n,u,e.showLegend),n.appendChild(c),n}function li(e,t){let n=m("div","pf-chart pf-scatter-chart"),r=K(e.data,t)??[],o=e.xAxis,i=e.yAxis,s=e.zAxis,a=e.series??[],l=e.height??300;if(r.length===0||!o||!i)return n.textContent="No chart data",n;let d=e.showGrid!==!1,u=e.showTooltip!==!1,c=a[0]?.color??q[0],g=oe(e),h=(A)=>g?te(A,g,t):String(Math.round(A*100)/100),y=r.map((A)=>Number(A[o]??0)),f=r.map((A)=>Number(A[i]??0)),b=Math.min(...y),w=Math.max(...y),S=Math.min(...f),N=Math.max(...f),k=w-b||1,R=N-S||1,P=s?r.map((A)=>Number(A[s]??0)):[],M=s?Math.max(...P,1):1,x=400,v=Ye(x,l,!0),T=le(x,l,"Scatter"),D=(A)=>v.plotLeft+(A-b)/k*v.plotWidth,V=(A)=>v.plotBottom-(A-S)/R*v.plotHeight,G=4;for(let A=0;A<=G;A++){let z=S+R*A/G,E=V(z);if(T.appendChild(Qe({x:v.plotLeft-6,y:E+3,"text-anchor":"end","font-size":ue,fill:re},h(z))),d&&A>0)T.appendChild(U("line",{x1:v.plotLeft,y1:E,x2:v.plotRight,y2:E,stroke:ve,"stroke-width":1,"stroke-dasharray":"4 3"}))}Ze(T,v);for(let A of[b,(b+w)/2,w])T.appendChild(Qe({x:D(A),y:v.plotBottom+14,"text-anchor":"middle","font-size":ue,fill:re},String(Math.round(A*100)/100)));let B=u?pe(n,T):void 0;for(let A=0;A<r.length;A++){let z=D(y[A]),E=V(f[A]),F=s?4+Math.sqrt(P[A]/M)*14:4,_=U("circle",{cx:z,cy:E,r:F,fill:c,"fill-opacity":s?0.6:0.85});if(B){let X=[{label:o,value:h(y[A]),color:c},{label:i,value:h(f[A]),color:c},...s?[{label:s,value:h(P[A]),color:c}]:[]],de=a[0]?.label??"Point";_.addEventListener("mouseenter",()=>ee(B,z,E,de,X)),_.addEventListener("mouseleave",()=>B.tooltip.classList.remove("pf-visible")),_.addEventListener("touchstart",()=>ee(B,z,E,de,X),{passive:!0}),_.addEventListener("touchend",()=>B.tooltip.classList.remove("pf-visible"),{passive:!0})}T.appendChild(_)}return me(n,a,e.showLegend),n.appendChild(T),n}function di(e,t){let n=m("div","pf-chart pf-radial-chart"),r=K(e.data,t)??[],o=e.series??[],i=e.dataKey??o[0]?.dataKey,s=e.nameKey??e.tooltipXKey??e.xAxis,a=e.height??300;if(r.length===0||!i)return n.textContent="No chart data",n;let l=Math.min(a,300),d=l/2,u=l/2,c=l/2-10,g=Math.max(0,Math.min(e.innerRadius??30,c-10)),h=e.startAngle??180,y=e.endAngle??0,f=e.showTooltip!==!1,b=r.map((v)=>Number(v[i]??0)),w=Math.max(...b,1),S=le(l,l,"Radial"),N=(c-g)/r.length,k=Math.max(2,N*0.7),R=oe(e),P=(v)=>R?te(v,R,t):String(v),M=f?pe(n,S):void 0,x=[];for(let v=0;v<r.length;v++){let T=c-N*v-N/2,D=o[v]?.color??q[v%q.length],V=b[v]/w,G=h+V*(y-h),B=s?r[v][s]:null,A=B!=null?L(B):o[v]?.label??i;x.push({dataKey:A||i,label:A||i,color:D}),S.appendChild(U("path",{d:St(d,u,T,h,y),fill:"none",stroke:ve,"stroke-width":k,"stroke-linecap":"round"}));let z=U("path",{d:St(d,u,T,h,G),fill:"none",stroke:D,"stroke-width":k,"stroke-linecap":"round"});if(M){let E=fe(d,u,T,(h+G)/2),F=[{label:i,value:P(b[v]),color:D}],_=A||i;z.addEventListener("mouseenter",()=>ee(M,E.x,E.y,_,F)),z.addEventListener("mouseleave",()=>M.tooltip.classList.remove("pf-visible")),z.addEventListener("touchstart",()=>ee(M,E.x,E.y,_,F),{passive:!0}),z.addEventListener("touchend",()=>M.tooltip.classList.remove("pf-visible"),{passive:!0})}S.appendChild(z)}return me(n,x,e.showLegend),n.appendChild(S),n}function ci(e,t){let n=m("div","pf-chart pf-radar-chart"),r=K(e.data,t)??[],o=e.series??[],i=e.axisKey??e.xAxis,s=e.height??300;if(r.length===0||o.length===0)return n.textContent="No chart data",n;let a=e.filled!==!1,l=e.showDots===!0,d=e.showGrid!==!1,u=e.showTooltip!==!1,c=Math.min(s,320),g=c/2,h=c/2,y=c/2-24,f=r.length,b=Math.max(...r.flatMap((M)=>o.map((x)=>Number(M[x.dataKey]??0))),1),w=(M)=>90-360*M/f,S=(M)=>M.map((x)=>`${x.x.toFixed(1)},${x.y.toFixed(1)}`).join(" "),N=le(c,c,"Radar");if(d){for(let x=1;x<=4;x++){let v=y*x/4,T=Array.from({length:f},(D,V)=>fe(g,h,v,w(V)));N.appendChild(U("polygon",{points:S(T),fill:"none",stroke:ve,"stroke-width":1}))}for(let x=0;x<f;x++){let v=fe(g,h,y,w(x));N.appendChild(U("line",{x1:g,y1:h,x2:v.x,y2:v.y,stroke:ve,"stroke-width":1}))}}for(let M=0;M<f;M++){let x=fe(g,h,y+12,w(M)),v=i?r[M][i]:null;N.appendChild(Qe({x:x.x,y:x.y+3,"text-anchor":"middle","font-size":ue,fill:re},v!=null?String(v):""))}let k=u?pe(n,N):void 0,R=oe(e),P=(M)=>R?te(M,R,t):String(M);for(let M=0;M<o.length;M++){let x=o[M],v=x.color??q[M%q.length],T=r.map((D,V)=>fe(g,h,Number(D[x.dataKey]??0)/b*y,w(V)));if(N.appendChild(U("polygon",{points:S(T),fill:a?v:"none","fill-opacity":a?0.2:0,stroke:v,"stroke-width":2})),l||k)for(let D=0;D<T.length;D++){let V=U("circle",{cx:T[D].x,cy:T[D].y,r:l?3:6,fill:l?v:"transparent","fill-opacity":l?1:0});if(k){let G=i?r[D][i]:null,B=G!=null?L(G):x.label??x.dataKey,A=[{label:x.label??x.dataKey,value:P(Number(r[D][x.dataKey]??0)),color:v}];V.addEventListener("mouseenter",()=>ee(k,T[D].x,T[D].y,B,A)),V.addEventListener("mouseleave",()=>k.tooltip.classList.remove("pf-visible")),V.addEventListener("touchstart",()=>ee(k,T[D].x,T[D].y,B,A),{passive:!0}),V.addEventListener("touchend",()=>k.tooltip.classList.remove("pf-visible"),{passive:!0})}N.appendChild(V)}}return me(n,o,e.showLegend),n.appendChild(N),n}function pi(e,t){let n=m("div","pf-chart pf-histogram"),r=K(e.data,t);if(!r||r.length===0)return n.textContent="No data",n;let o=r,i=e.bins??10,s=e.height??200,a=e.color??q[0],l=Math.min(...o),u=(Math.max(...o)-l)/i||1,c=Array(i).fill(0);for(let w of o){let S=Math.min(Math.floor((w-l)/u),i-1);c[S]++}let g=Math.max(...c),h=300,y=s,f=h/i,b=le(h,y,"Histogram");for(let w=0;w<i;w++){let S=g>0?c[w]/g*y:0,N=document.createElementNS("http://www.w3.org/2000/svg","rect");N.setAttribute("x",String(w*f)),N.setAttribute("y",String(y-S)),N.setAttribute("width",String(f-1)),N.setAttribute("height",String(S)),N.setAttribute("fill",a),b.appendChild(N)}return n.appendChild(b),n}function Sn(){p("Table",ui),p("TableHead",At("thead")),p("TableBody",At("tbody")),p("TableFooter",At("tfoot")),p("TableRow",fi),p("TableHeader",mi),p("TableCell",gi),p("TableCaption",hi),p("ExpandableRow",bi)}function ui(e,t){let n=document.createElement("table");return n.className=e.striped===!0?"pf-table pf-table-striped":"pf-table",n.style.width="100%",n.style.borderCollapse="collapse",H(e,n,t),n}function At(e){return(t,n)=>{let r=document.createElement(e);return r.className=`pf-${e}`,H(t,r,n),r}}function fi(e,t){let n=document.createElement("tr");return n.className="pf-table-row",H(e,n,t),n}function mi(e,t){let n=document.createElement("th");return n.className="pf-table-header",n.style.textAlign="left",n.style.padding="8px 12px",n.style.fontWeight="600",n.textContent=C(e.content,t),n}function gi(e,t){let n=document.createElement("td");if(n.className="pf-table-cell",n.style.padding="8px 12px",e.colSpan!=null)n.colSpan=e.colSpan;if(e.rowSpan!=null)n.rowSpan=e.rowSpan;return H(e,n,t),n}function hi(e,t){let n=document.createElement("caption");return n.className="pf-table-caption",n.style.padding="8px",n.style.fontSize="14px",n.textContent=C(e.content,t),n}function bi(e,t){let n=m("div","pf-expandable-row"),r=m("div","pf-expandable-row-summary");r.style.cursor="pointer",r.style.display="flex",r.style.alignItems="center",r.style.gap="8px";let o=m("span","pf-expandable-arrow");o.textContent="▶",o.style.transition="transform 0.2s",o.style.fontSize="10px",r.appendChild(o);let i=e.summary;if(i)for(let l of i)r.appendChild(J(l,t));let s=m("div","pf-expandable-row-detail");s.style.display="none",s.style.paddingLeft="24px",H(e,s,t);let a=!1;return r.addEventListener("click",()=>{a=!a,s.style.display=a?"block":"none",o.style.transform=a?"rotate(90deg)":""}),n.appendChild(r),n.appendChild(s),n}var An=!1;function et(){if(An)return;An=!0;let e=new Set(mt());Yt(),tn(),on(),sn(),an(),dn(),cn(),pn(),mn(),gn(),yn(),kn(),Sn(),Gt(mt().filter((t)=>!e.has(t)))}function Rt(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}function Tt(e){return e.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function Et(e,t=" "){return Object.entries(e).map(([n,r])=>`${t}--${Rt(n)}: ${Tt(r)};`).join(`
|
|
7
|
+
`)}function En(e){if(!e)return"";let t=[];if(e.light&&Object.keys(e.light).length>0)t.push(`:root {
|
|
8
|
+
${Et(e.light)}
|
|
9
|
+
}`);if(e.dark&&Object.keys(e.dark).length>0){let n=Et(e.dark);t.push(`.dark, [data-theme="dark"] {
|
|
10
10
|
${n}
|
|
11
11
|
}`),t.push(`@media (prefers-color-scheme: dark) {
|
|
12
12
|
:root:not([data-theme="light"]):not(.light) {
|
|
13
|
-
${
|
|
13
|
+
${Et(e.dark," ")}
|
|
14
14
|
}
|
|
15
15
|
}`)}return t.join(`
|
|
16
|
-
`)}function ye(e,t){e.setAttribute("data-theme",t),e.classList.toggle("dark",t==="dark"),e.classList.toggle("light",t==="light")}function Rt(e,t){if(!t)return;if(t.light)for(let[n,r]of Object.entries(t.light))e.style.setProperty(`--${Et(n)}`,At(r));if(t.dark){let r=document.getElementById("prefab-dark-theme");if(!r)r=document.createElement("style"),r.id="prefab-dark-theme",document.head.appendChild(r);r.textContent=Sn({dark:t.dark})}}function Tt(e,t){if(!e||typeof document>"u")return;let n=(r)=>{for(let[o,s]of Object.entries(e))if(ms(o,r))r.preventDefault(),t(s)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}function ms(e,t){let n=e.toLowerCase().split("+").map((s)=>s.trim()),r=n[n.length-1],o=new Set(n.slice(0,-1));if(o.has("ctrl")!==(t.ctrlKey||t.metaKey))return!1;if(o.has("shift")!==t.shiftKey)return!1;if(o.has("alt")!==t.altKey)return!1;return t.key.toLowerCase()===r}var En='<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>',An='<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>',Rn={"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 gs(e,t){try{let r=localStorage.getItem(t);if(r==="light"||r==="dark")return r}catch{}let n=e.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(n==="light"||n==="dark")return n;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function Te(e,t){if(typeof document>"u")return()=>{};let n=t?.position??"top-right",r=t?.storageKey??"prefab-theme",o=t?.syncDocument??!0,s=getComputedStyle(e).position;if(s==="static"||s==="")e.style.position="relative";let i=document.createElement("button");i.className="pf-theme-toggle",i.setAttribute("aria-label","Toggle theme"),i.setAttribute("title","Toggle light/dark"),Object.assign(i.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 a=Rn[n]??Rn["top-right"];for(let d of a.split(";")){let[g,h]=d.split(":").map((y)=>y.trim());if(g&&h)i.style.setProperty(g,h)}i.addEventListener("mouseenter",()=>{i.style.opacity="1"}),i.addEventListener("mouseleave",()=>{i.style.opacity="0.7"});function l(d){if(ye(e,d),o)ye(document.documentElement,d);i.innerHTML=d==="dark"?An:En;try{localStorage.setItem(r,d)}catch{}}let c=gs(e,r);l(c),i.addEventListener("click",()=>{let d=e.getAttribute("data-theme")??"dark";l(d==="dark"?"light":"dark")}),e.appendChild(i);let u;if(o)u=new MutationObserver((d)=>{for(let g of d)if(g.type==="attributes"&&g.attributeName==="data-theme"){let h=document.documentElement.getAttribute("data-theme");if((h==="light"||h==="dark")&&h!==e.getAttribute("data-theme")){ye(e,h),i.innerHTML=h==="dark"?An:En;try{localStorage.setItem(r,h)}catch{}}}}),u.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{u?.disconnect(),i.remove()}}function Qe(e){let t=e?.baseUrl??(typeof window<"u"?window.location.origin:""),n={"Content-Type":"application/json",...e?.headers},r=e?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(o,s){let i=await r(`${t}/mcp/tools/call`,{method:"POST",headers:n,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:o,arguments:s}})});if(!i.ok)throw Error(`MCP tool call failed: ${i.status} ${i.statusText}`);let a=await i.json();if(a.error)throw Error(a.error.message??"MCP tool call returned error");let l=a.result?.content??a.content??[];for(let c of l)if(c.type==="text"&&c.text!==void 0){try{let u=JSON.parse(c.text);if(typeof u==="object"&&u!==null&&"$prefab"in u)return u;return u}catch{}return c.text}return a.result??a},async sendMessage(o){await r(`${t}/mcp/messages`,{method:"POST",headers:n,body:JSON.stringify({message:o})})}}}function et(){return{callTool(e){return P.warn(`No MCP transport: callTool('${e}') ignored`),Promise.resolve(null)},sendMessage(e){return P.warn("No MCP transport: sendMessage ignored",e),Promise.resolve()}}}var Tn="0.3.11";function hs(e){return e!==null&&typeof e==="object"&&e.jsonrpc==="2.0"}class me{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;_hostSupportsSubscriptions=!1;constructor(e="*"){this.hostOrigin=e}connect(){if(typeof window>"u")return;let e=Cs();if(e)this.postFn=(n)=>e.postMessage(n);let t=(n)=>{if(this.hostOrigin!=="*"&&n.origin!==this.hostOrigin)return;let r=n.data;if(hs(r)){this.handleJsonRpc(r);return}let o=r;if(!o?.type.startsWith("prefab:"))return;if(o.type==="prefab:tool-call-response"&&o.id){let i=this.pending.get(o.id);if(i){if(this.pending.delete(o.id),o.payload?.error!=null)i.reject(Error(o.payload.error));else i.resolve(o.payload?.result);return}}let s=this.listeners.get(o.type);if(s)for(let i of s)i(o.payload??{})};window.addEventListener("message",t),this.cleanup=()=>window.removeEventListener("message",t)}async initialize(e){try{return await Promise.any([this.initPrefab(e),this.initJsonRpc(e)])}catch(t){let n=t instanceof AggregateError?t.errors.map((r)=>r.message).join("; "):String(t);throw Error(`Bridge init failed — no host responded. Tried: ${n}`,{cause:t})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode(e){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:e});else this.sendPrefab("prefab:request-mode",{mode:e})}openLink(e,t){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:e,target:t});else this.sendPrefab("prefab:open-link",{url:e,target:t})}updateContext(e){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:e});else this.sendPrefab("prefab:update-context",{context:e})}setupAutoResize(e){if(typeof ResizeObserver>"u")return bs;let t=-1,n=-1,r=(i,a)=>{if(i===t&&a===n)return;if(t=i,n=a,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:i,height:a});else this.sendPrefab("prefab:size-changed",{width:i,height:a})},o=new ResizeObserver((i)=>{for(let a of i)if(a.borderBoxSize.length){let l=a.borderBoxSize[0];r(Math.ceil(l.inlineSize),Math.ceil(l.blockSize))}else{let l=a.target.getBoundingClientRect();r(Math.ceil(l.width),Math.ceil(l.height))}});o.observe(e);let s=e.getBoundingClientRect();return r(Math.ceil(s.width),Math.ceil(s.height)),()=>o.disconnect()}notifyPreferredSize(e){if(this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/preferred-size",e);else this.sendPrefab("prefab:preferred-size",e)}subscribe(e,t){let n=(r)=>{if(r.uri!==e)return;t(r.contents??r.data??r)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",n),this.sendRpcRequest("resources/subscribe",{uri:e});else this.on("prefab:resource-updated",n),this.sendPrefab("prefab:subscribe",{uri:e});return()=>{if(this.off("prefab:resource-updated",n),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:e});else this.sendPrefab("prefab:unsubscribe",{uri:e})}}get supportsSubscriptions(){return this._hostSupportsSubscriptions}on(e,t){if(!this.listeners.has(e))this.listeners.set(e,new Set);let n=this.listeners.get(e);if(n)n.add(t)}off(e,t){this.listeners.get(e)?.delete(t)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,e]of this.pending)e.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,e]of this.rpcPending)e.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab(e){return new Promise((t,n)=>{let r=!1,o=(s)=>{if(r)return;r=!0,this.off("prefab:init-response",o),this.protocol="prefab";let i=s.capabilities;this._hostSupportsSubscriptions=i?.subscriptions===!0,t(s)};this.on("prefab:init-response",o),this.sendPrefab("prefab:init",{capabilities:e}),setTimeout(()=>{if(!r)r=!0,this.off("prefab:init-response",o),n(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:(e,t)=>{let n=`tc-${++this.callIdCounter}`;return new Promise((r,o)=>{this.pending.set(n,{resolve:r,reject:o}),this.sendPrefab("prefab:tool-call",{tool:e,arguments:t},n),setTimeout(()=>{if(this.pending.has(n))this.pending.delete(n),o(Error(`Tool call '${e}' timed out`))},30000)})},sendMessage:(e)=>(this.sendPrefab("prefab:send-message",{message:e}),Promise.resolve()),subscribe:(e,t)=>this.subscribe(e,t),capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendPrefab(e,t,n){if(typeof window>"u")return;let r=window.parent!==window?window.parent:window,o={type:e,payload:t,id:n};r.postMessage(o,this.hostOrigin)}handleJsonRpc(e){if(!("method"in e)){let r=this.rpcPending.get(e.id);if(r)if(this.rpcPending.delete(e.id),e.error)r.reject(Error(e.error.message));else r.resolve(e.result);return}let t=e.method,n=e.params??{};if(e.id!=null&&this.sentRpcIds.delete(e.id))return;if(e.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:e.id,result:{}});switch(t){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:n.arguments??n});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:n.arguments??n});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:n});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",n);break;case"ui/notifications/host-context-changed":{let r={};if(typeof n.theme==="string")r.colorScheme=n.theme;if(typeof n.styles==="object"&&n.styles!==null){let o=n.styles;if(o.variables)r.variables=o.variables;if(typeof o.css?.fonts==="string")r.fontCss=o.css.fonts}this.dispatch("prefab:theme-update",r),this.dispatch("prefab:host-context-changed",n);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",n);break;case"ui/notifications/resource-updated":case"notifications/resources/updated":this.dispatch("prefab:resource-updated",n);break}}initJsonRpc(e){return new Promise((t,n)=>{let r=++this.rpcIdCounter,o=!1;this.rpcPending.set(r,{resolve:(s)=>{if(o)return;o=!0,this.protocol="jsonrpc";let i=s??{},a=i.hostInfo??{},l=i.hostContext??{},c=i.hostCapabilities??{},u;if(typeof l.theme==="string"||typeof l.styles==="object"){if(u={},typeof l.theme==="string")u.colorScheme=l.theme;if(typeof l.styles==="object"&&l.styles!==null){let g=l.styles;if(g.variables)u.variables=g.variables;if(typeof g.css?.fonts==="string")u.fontCss=g.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let d=c.resources;this._hostSupportsSubscriptions=c.subscriptions===!0||d?.subscribe===!0,t({hostName:a.name,hostVersion:a.version,capabilities:{toast:!0,navigation:c.openLinks!=null,messaging:!0,displayModes:l.availableDisplayModes??[]},theme:u,toolInput:void 0,meta:l})},reject:(s)=>{if(o)return;o=!0,n(s)}}),this.postJsonRpc({jsonrpc:"2.0",id:r,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:Tn},appCapabilities:{...e.displayModes&&{availableDisplayModes:e.displayModes}}}}),setTimeout(()=>{if(!o)o=!0,this.rpcPending.delete(r),n(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:(e,t)=>this.sendRpcRequest("tools/call",{name:e,arguments:t}),sendMessage:(e)=>this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:e}}),subscribe:(e,t)=>this.subscribe(e,t),capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendRpcRequest(e,t){let n=++this.rpcIdCounter;return new Promise((r,o)=>{this.rpcPending.set(n,{resolve:r,reject:o}),this.postJsonRpc({jsonrpc:"2.0",id:n,method:e,params:t}),setTimeout(()=>{if(this.rpcPending.has(n))this.rpcPending.delete(n),o(Error(`JSON-RPC '${e}' timed out`))},30000)})}sendRpcNotification(e,t){this.postJsonRpc({jsonrpc:"2.0",method:e,params:t})}postJsonRpc(e){if(typeof window>"u")return;if(e.id!=null&&typeof e.method==="string")this.sentRpcIds.add(e.id);if(this.postFn)this.postFn(e);else(window.parent!==window?window.parent:window).postMessage(e,this.hostOrigin)}dispatch(e,t){let n=this.listeners.get(e);if(n)for(let r of n)r(t)}}var bs=()=>{};function Ne(e,t){if(t.variables)for(let[n,r]of Object.entries(t.variables))e.style.setProperty(n.startsWith("--")?n:`--${n}`,r);if(t.colorScheme&&t.colorScheme!=="auto")e.setAttribute("data-theme",t.colorScheme);if(t.fontCss)ys(t.fontCss)}function ys(e){if(document.getElementById("__prefab-host-fonts"))return;let n=document.createElement("style");n.id="__prefab-host-fonts",n.textContent=e,document.head.appendChild(n)}function Ce(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function Cs(){if(typeof window>"u")return;let e=window;if(typeof e.acquireVsCodeApi==="function")try{let t=e.acquireVsCodeApi();if(t!==null&&typeof t==="object"&&"postMessage"in t)return t}catch{return}return}async function tt(e){Ze();let t=e?.mode??"auto",n=t==="bridge"||t==="auto"&&Ce(),r,o,s={capabilities:{}};if(n)o=new me(e?.hostOrigin),o.connect(),s=await o.initialize(e?.capabilities??{toolInput:!0}),r=o.createTransport();else if(e?.transport)r=Qe(e.transport);else r=et();if(s.theme&&typeof document<"u")Ne(document.documentElement,s.theme);if(typeof document<"u"&&!o)ws();let i,a,l,c,u,d=s.toolInput,g;if(o)o.on("prefab:tool-input",(f)=>{let b=f.args??f;if(i)i(b);else d=b}),o.on("prefab:tool-result",(f)=>{let b=f.result??f;if(a)a(b);else g=b}),o.on("prefab:tool-cancelled",()=>{l?.()}),o.on("prefab:tool-input-partial",(f)=>{c?.(f.args??f)}),o.on("prefab:theme-update",(f)=>{if(typeof document<"u")Ne(document.documentElement,f)}),o.on("prefab:host-context-changed",(f)=>{u?.(f)});function h(f,...b){let w=Nt(f),S=new we,N={store:S,scope:{},transport:r,rerender:()=>k(),onToast:void 0};function k(){w.innerHTML="";for(let R of b)w.appendChild(J(R,N))}return k(),{rerender:k,store:S,destroy:()=>{w.innerHTML=""}}}return{callTool:(f,b={})=>r.callTool(f,b),sendMessage:(f)=>r.sendMessage(f),onToolInput:(f)=>{if(i=f,d){let b=d;d=void 0,queueMicrotask(()=>f(b))}},onToolResult:(f)=>{if(a=f,g!==void 0){let b=g;g=void 0,queueMicrotask(()=>f(b))}},onToolCancelled:(f)=>{l=f},onToolInputPartial:(f)=>{c=f},onHostContextChanged:(f)=>{u=f},render:h,mount:(f,b,w)=>{let S=Nt(f);return ne.mount(S,b,{transport:r,...w})},requestMode:(f)=>o?.requestMode(f),openLink:(f,b)=>{if(o)o.openLink(f,b);else if(typeof window<"u")window.open(f,b??"_blank")},updateContext:(f)=>{if(o)o.updateContext(f)},setupAutoResize:(f)=>{if(!o)return vs;let b=typeof f==="string"?Nt(f):f;return o.setupAutoResize(b)},notifyPreferredSize:(f)=>{if(o)o.notifyPreferredSize(f)},host:s,capabilities:s.capabilities,theme:s.theme,transport:r,destroy:()=>o?.disconnect()}}var vs=()=>{};function Nt(e){if(typeof e==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let t=document.querySelector(e);if(!t)throw Error(`Element not found: ${e}`);return t}return e}function ws(){function e(){let n=document.body.getAttribute("data-vscode-theme-kind");if(!n)return;let r=n.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",r)}e(),new MutationObserver(e).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var Nn=["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 Hn=new Set(Nn);function ve(e,t={}){let n=[],r=t.strict??!1;if(e==null||typeof e!=="object")return n.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:n};let o=e;if(o.$prefab==null||typeof o.$prefab!=="object")n.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof o.$prefab.version!=="string")n.push({path:"$.$prefab.version",message:"version must be a string"});if(o.view==null)n.push({path:"$.view",message:'Missing required "view" field'});else Mt(o.view,"$.view",n,r);if(o.state!==void 0){if(o.state===null||typeof o.state!=="object"||Array.isArray(o.state))n.push({path:"$.state",message:"state must be a plain object"})}if(o.theme!==void 0)ks(o.theme,n);if(o.css!==void 0)Ln(o.css,"$.css",n);if(o.stylesheets!==void 0)Ln(o.stylesheets,"$.stylesheets",n);if(o.mode!==void 0&&o.mode!=="light"&&o.mode!=="dark")n.push({path:"$.mode",message:'mode must be "light" or "dark"'});if(o.defs!==void 0)if(o.defs===null||typeof o.defs!=="object"||Array.isArray(o.defs))n.push({path:"$.defs",message:"defs must be a plain object"});else for(let[s,i]of Object.entries(o.defs))Mt(i,`$.defs.${s}`,n,r);if(o.keyBindings!==void 0)if(o.keyBindings===null||typeof o.keyBindings!=="object"||Array.isArray(o.keyBindings))n.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[s,i]of Object.entries(o.keyBindings))Lt(i,`$.keyBindings.${s}`,n);return{valid:n.length===0,errors:n}}function Pn(e){return ve(e).valid}function Mt(e,t,n,r){if(e==null||typeof e!=="object"||Array.isArray(e)){n.push({path:t,message:"Component must be a plain object"});return}let o=e;if(typeof o.type!=="string"||o.type.length===0){n.push({path:`${t}.type`,message:'Component must have a non-empty "type" string'});return}if(r&&!Hn.has(o.type))n.push({path:`${t}.type`,message:`Unknown component type: "${o.type}"`});if(o.children!==void 0)if(!Array.isArray(o.children))n.push({path:`${t}.children`,message:"children must be an array"});else for(let i=0;i<o.children.length;i++)Mt(o.children[i],`${t}.children[${i}]`,n,r);let s=["onClick","on_click","onChange","on_change","onSubmit","on_submit","onMount","on_mount","onClose","on_close"];for(let i of s)if(o[i]!==void 0)Lt(o[i],`${t}.${i}`,n);for(let[i,a]of Object.entries(o)){if(i==="type"||xs.has(i)||s.includes(i))continue;if(Mn(a)||Array.isArray(a)&&a.some(Mn))n.push({path:`${t}.${i}`,message:`Components under "${i}" are ignored by the renderer; move them into "children"`})}}var xs=new Set(["children","fallback","trigger","empty","else","summary"]);function Mn(e){if(e==null||typeof e!=="object"||Array.isArray(e))return!1;let t=e.type;return typeof t==="string"&&Hn.has(t)}function Lt(e,t,n){if(Array.isArray(e)){for(let a=0;a<e.length;a++)Lt(e[a],`${t}[${a}]`,n);return}if(e==null||typeof e!=="object"){n.push({path:t,message:"Action must be an object or array of objects"});return}let r=e,o=typeof r.type==="string"&&r.type.length>0,s=typeof r.action==="string"&&r.action.length>0;if(!o&&!s){n.push({path:`${t}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if((s?r.action:r.type).toLowerCase()==="showtoast"){if(typeof r.message!=="string"||r.message.length===0)n.push({path:`${t}.message`,message:'showToast requires a non-empty "message" string'})}}function Ln(e,t,n){if(!Array.isArray(e)){n.push({path:t,message:`${t} must be an array of strings`});return}for(let r=0;r<e.length;r++)if(typeof e[r]!=="string")n.push({path:`${t}[${r}]`,message:"must be a string"})}function ks(e,t){if(e===null||typeof e!=="object"||Array.isArray(e)){t.push({path:"$.theme",message:"theme must be a plain object"});return}let n=e;for(let r of["light","dark"])if(n[r]!==void 0){if(n[r]===null||typeof n[r]!=="object"||Array.isArray(n[r]))t.push({path:`$.theme.${r}`,message:`theme.${r} must be a plain object`})}}var ne={mount(e,t,n){if(Ze(),n?.validate!==!1)for(let b of ve(t).errors)P.warn(`wire validation ${b.path}: ${b.message}`);let r=t,o={tracked:[],evalBlocked:!1};if(r.pipes)for(let[b,w]of Object.entries(r.pipes))$n(b,w,o);let s=new we(r.state),i;if(n?.transport&&"callTool"in n.transport)i=n.transport;else if(n?.transport)i=Qe(n.transport);else i=et();let a=n?.onToast??As,l=new Se;function c(b){let w=b;if(r=w,w.state)s.merge(w.state);if(w.defs)u.defs=w.defs;if(w.theme)Rt(e,w.theme);if(w.mode)On(e,w.mode);if(w.pipes)for(let[S,N]of Object.entries(w.pipes))$n(S,N,o);for(let S of d)S.remove();if(d.length=0,d.push(...Dn(w.css,w.stylesheets)),jn(e,w.layout),g?.(),g=void 0,w.keyBindings)g=Tt(w.keyBindings,(S)=>{F(j(S,{store:s,transport:i,scope:{},rerender:()=>f(),remount:c,onToast:a}),"keyBinding")});f()}let u={store:s,scope:{},transport:i,rerender:()=>f(),remount:c,onToast:a,defs:r.defs,destroyRegistry:l};if(Rt(e,r.theme),r.mode)On(e,r.mode);jn(e,r.layout);let d=Dn(r.css,r.stylesheets),g;if(r.keyBindings)g=Tt(r.keyBindings,(b)=>{F(j(b,{store:s,transport:i,scope:{},rerender:()=>f(),remount:c,onToast:a}),"keyBinding")});let h,y=n?.themeToggle??!0;if(y!==!1)h=Te(e,typeof y==="object"?y:void 0);function f(){l.flush();let b=e.querySelector(".pf-theme-toggle");e.innerHTML="";let w=J(r.view,u);if(e.appendChild(w),b)e.appendChild(b)}return f(),{rerender:()=>f(),update(b){if(s.merge(b.update.state),f(),b.update.actions!=null)F(j(b.update.actions,u),"update action")},store:s,destroy(){l.flush(),h?.(),g?.(),Bt(),Jt();for(let b of d)b.remove();for(let b of o.tracked)ke(b);e.innerHTML=""}}},isPrefabData(e){return e!=null&&typeof e==="object"&&"$prefab"in e},isPrefabUpdate(e){return e!=null&&typeof e==="object"&&"$prefab"in e&&"update"in e}},Ss=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 Es(e){if(e instanceof EvalError)return!0;return e instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test(e.message)}function $n(e,t,n){if(Ss.has(e)){P.warn(`wire pipe "${e}" ignored — shadows built-in`);return}if(He(e)!=null){P.debug(`wire pipe "${e}" — already registered, keeping local implementation`);return}if(n.evalBlocked)return;try{let r=Function("return ("+t+")")();if(typeof r!=="function"){P.warn(`wire pipe "${e}" — source did not evaluate to a function`);return}xe(e,r),n.tracked.push(e)}catch(r){if(Es(r)){n.evalBlocked=!0,P.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}P.warn(`wire pipe "${e}" — failed to hydrate:`,r)}}function As(e){if(typeof document>"u")return;let t=Ts(),n=document.createElement("div"),r=e.variant??"default";n.className=`pf-toast${r!=="default"?` pf-toast--${r}`:""}`,n.setAttribute("data-variant",r),n.style.marginBottom="8px",n.style.transition="opacity 0.3s ease";let o=document.createElement("div");if(o.textContent=e.message,o.style.fontWeight="500",n.appendChild(o),e.description){let i=document.createElement("div");i.textContent=e.description,i.style.fontSize="14px",i.style.color="var(--muted-foreground, #6b7280)",n.appendChild(i)}t.appendChild(n);let s=e.duration??4000;setTimeout(()=>{n.style.opacity="0",setTimeout(()=>n.remove(),300)},s)}function On(e,t){if(ye(e,t),typeof document<"u")ye(document.documentElement,t)}function Rs(e){let t=e.trim();if(t.includes("{")||t.includes("}"))return!1;return/^(https?:)?\/\//i.test(t)||t.startsWith("/")||/\.css(\?|#|$)/i.test(t)}function Dn(e,t){let n=[];if(typeof document>"u")return n;for(let r of e??[]){let o=document.createElement("style");o.textContent=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}for(let r of t??[])if(Rs(r)){let o=document.createElement("link");o.rel="stylesheet",o.href=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}else{let o=document.createElement("style");o.textContent=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}return n}function jn(e,t){if(e.style.height="",e.style.minHeight="",e.style.maxHeight="",e.style.overflow="",!t)return;if(t.preferredHeight!=null)e.style.height=`${t.preferredHeight}px`;if(t.minHeight!=null)e.style.minHeight=`${t.minHeight}px`;if(t.maxHeight!=null)e.style.maxHeight=`${t.maxHeight}px`,e.style.overflow="auto"}function Ts(){let t=document.getElementById("prefab-toast-container");if(!t)t=document.createElement("div"),t.id="prefab-toast-container",t.style.position="fixed",t.style.bottom="16px",t.style.right="16px",t.style.zIndex="9999",t.style.maxWidth="400px",document.body.appendChild(t);return t}if(typeof window<"u"){let e=window;e.PrefabRenderer=ne,e.prefab={app:tt,mount:ne.mount.bind(ne),isPrefabData:ne.isPrefabData.bind(ne),isPrefabUpdate:ne.isPrefabUpdate.bind(ne),Bridge:me,isIframe:Ce,registerPipe:xe,unregisterPipe:ke,listPipes:Le,registerComponent:p,createThemeToggle:Te,validateWireFormat:ve,setLogLevel:Me};let t=e.__PREFAB_DATA__;if(t!=null){let n=document.getElementById("prefab-root");if(n)ne.mount(n,t)}}})();
|
|
16
|
+
`)}function we(e,t){e.setAttribute("data-theme",t),e.classList.toggle("dark",t==="dark"),e.classList.toggle("light",t==="light")}function Nt(e,t){if(!t)return;if(t.light)for(let[n,r]of Object.entries(t.light))e.style.setProperty(`--${Rt(n)}`,Tt(r));if(t.dark){let r=document.getElementById("prefab-dark-theme");if(!r)r=document.createElement("style"),r.id="prefab-dark-theme",document.head.appendChild(r);r.textContent=En({dark:t.dark})}}function Mt(e,t){if(!e||typeof document>"u")return;let n=(r)=>{for(let[o,i]of Object.entries(e))if(yi(o,r))r.preventDefault(),t(i)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}function yi(e,t){let n=e.toLowerCase().split("+").map((i)=>i.trim()),r=n[n.length-1],o=new Set(n.slice(0,-1));if(o.has("ctrl")!==(t.ctrlKey||t.metaKey))return!1;if(o.has("shift")!==t.shiftKey)return!1;if(o.has("alt")!==t.altKey)return!1;return t.key.toLowerCase()===r}var Rn='<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>',Tn='<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>',Nn={"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 Ci(e,t){try{let r=localStorage.getItem(t);if(r==="light"||r==="dark")return r}catch{}let n=e.getAttribute("data-theme")??document.documentElement.getAttribute("data-theme");if(n==="light"||n==="dark")return n;if(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches)return"light";return"dark"}function Me(e,t){if(typeof document>"u")return()=>{};let n=t?.position??"top-right",r=t?.storageKey??"prefab-theme",o=t?.syncDocument??!0,i=getComputedStyle(e).position;if(i==="static"||i==="")e.style.position="relative";let s=document.createElement("button");s.className="pf-theme-toggle",s.setAttribute("aria-label","Toggle theme"),s.setAttribute("title","Toggle light/dark"),Object.assign(s.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 a=Nn[n]??Nn["top-right"];for(let c of a.split(";")){let[g,h]=c.split(":").map((y)=>y.trim());if(g&&h)s.style.setProperty(g,h)}s.addEventListener("mouseenter",()=>{s.style.opacity="1"}),s.addEventListener("mouseleave",()=>{s.style.opacity="0.7"});function l(c){if(we(e,c),o)we(document.documentElement,c);s.innerHTML=c==="dark"?Tn:Rn;try{localStorage.setItem(r,c)}catch{}}let d=Ci(e,r);l(d),s.addEventListener("click",()=>{let c=e.getAttribute("data-theme")??"dark";l(c==="dark"?"light":"dark")}),e.appendChild(s);let u;if(o)u=new MutationObserver((c)=>{for(let g of c)if(g.type==="attributes"&&g.attributeName==="data-theme"){let h=document.documentElement.getAttribute("data-theme");if((h==="light"||h==="dark")&&h!==e.getAttribute("data-theme")){we(e,h),s.innerHTML=h==="dark"?Tn:Rn;try{localStorage.setItem(r,h)}catch{}}}}),u.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{u?.disconnect(),s.remove()}}function tt(e){let t=e?.baseUrl??(typeof window<"u"?window.location.origin:""),n={"Content-Type":"application/json",...e?.headers},r=e?.fetch??globalThis.fetch.bind(globalThis);return{async callTool(o,i){let s=await r(`${t}/mcp/tools/call`,{method:"POST",headers:n,body:JSON.stringify({jsonrpc:"2.0",method:"tools/call",params:{name:o,arguments:i}})});if(!s.ok)throw Error(`MCP tool call failed: ${s.status} ${s.statusText}`);let a=await s.json();if(a.error)throw Error(a.error.message??"MCP tool call returned error");let l=a.result?.content??a.content??[];for(let d of l)if(d.type==="text"&&d.text!==void 0){try{let u=JSON.parse(d.text);if(typeof u==="object"&&u!==null&&"$prefab"in u)return u;return u}catch{}return d.text}return a.result??a},async sendMessage(o){await r(`${t}/mcp/messages`,{method:"POST",headers:n,body:JSON.stringify({message:o})})}}}function nt(){return{callTool(e){return O.warn(`No MCP transport: callTool('${e}') ignored`),Promise.resolve(null)},sendMessage(e){return O.warn("No MCP transport: sendMessage ignored",e),Promise.resolve()}}}var Mn="0.3.13";function vi(e){return e!==null&&typeof e==="object"&&e.jsonrpc==="2.0"}class ge{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;_hostSupportsSubscriptions=!1;constructor(e="*"){this.hostOrigin=e}connect(){if(typeof window>"u")return;let e=ki();if(e)this.postFn=(n)=>e.postMessage(n);let t=(n)=>{if(this.hostOrigin!=="*"&&n.origin!==this.hostOrigin)return;let r=n.data;if(vi(r)){this.handleJsonRpc(r);return}let o=r;if(!o?.type.startsWith("prefab:"))return;if(o.type==="prefab:tool-call-response"&&o.id){let s=this.pending.get(o.id);if(s){if(this.pending.delete(o.id),o.payload?.error!=null)s.reject(Error(o.payload.error));else s.resolve(o.payload?.result);return}}let i=this.listeners.get(o.type);if(i)for(let s of i)s(o.payload??{})};window.addEventListener("message",t),this.cleanup=()=>window.removeEventListener("message",t)}async initialize(e){try{return await Promise.any([this.initPrefab(e),this.initJsonRpc(e)])}catch(t){let n=t instanceof AggregateError?t.errors.map((r)=>r.message).join("; "):String(t);throw Error(`Bridge init failed — no host responded. Tried: ${n}`,{cause:t})}}createTransport(){if(this.protocol==="jsonrpc")return this.createJsonRpcTransport();return this.createPrefabTransport()}requestMode(e){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/request-display-mode",{mode:e});else this.sendPrefab("prefab:request-mode",{mode:e})}openLink(e,t){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/open-link",{url:e,target:t});else this.sendPrefab("prefab:open-link",{url:e,target:t})}updateContext(e){if(this.protocol==="jsonrpc")this.sendRpcRequest("ui/update-model-context",{structuredContent:e});else this.sendPrefab("prefab:update-context",{context:e})}setupAutoResize(e){if(typeof ResizeObserver>"u")return wi;let t=-1,n=-1,r=(s,a)=>{if(s===t&&a===n)return;if(t=s,n=a,this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/size-changed",{width:s,height:a});else this.sendPrefab("prefab:size-changed",{width:s,height:a})},o=new ResizeObserver((s)=>{for(let a of s)if(a.borderBoxSize.length){let l=a.borderBoxSize[0];r(Math.ceil(l.inlineSize),Math.ceil(l.blockSize))}else{let l=a.target.getBoundingClientRect();r(Math.ceil(l.width),Math.ceil(l.height))}});o.observe(e);let i=e.getBoundingClientRect();return r(Math.ceil(i.width),Math.ceil(i.height)),()=>o.disconnect()}notifyPreferredSize(e){if(this.protocol==="jsonrpc")this.sendRpcNotification("ui/notifications/preferred-size",e);else this.sendPrefab("prefab:preferred-size",e)}subscribe(e,t){let n=(r)=>{if(r.uri!==e)return;t(r.contents??r.data??r)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",n),this.sendRpcRequest("resources/subscribe",{uri:e});else this.on("prefab:resource-updated",n),this.sendPrefab("prefab:subscribe",{uri:e});return()=>{if(this.off("prefab:resource-updated",n),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:e});else this.sendPrefab("prefab:unsubscribe",{uri:e})}}get supportsSubscriptions(){return this._hostSupportsSubscriptions}on(e,t){if(!this.listeners.has(e))this.listeners.set(e,new Set);let n=this.listeners.get(e);if(n)n.add(t)}off(e,t){this.listeners.get(e)?.delete(t)}disconnect(){this.cleanup?.(),this.listeners.clear();for(let[,e]of this.pending)e.reject(Error("Bridge disconnected"));this.pending.clear();for(let[,e]of this.rpcPending)e.reject(Error("Bridge disconnected"));this.rpcPending.clear(),this.sentRpcIds.clear()}get activeProtocol(){return this.protocol}initPrefab(e){return new Promise((t,n)=>{let r=!1,o=(i)=>{if(r)return;r=!0,this.off("prefab:init-response",o),this.protocol="prefab";let s=i.capabilities;this._hostSupportsSubscriptions=s?.subscriptions===!0,t(i)};this.on("prefab:init-response",o),this.sendPrefab("prefab:init",{capabilities:e}),setTimeout(()=>{if(!r)r=!0,this.off("prefab:init-response",o),n(Error("prefab:init timeout"))},2000)})}createPrefabTransport(){return{callTool:(e,t)=>{let n=`tc-${++this.callIdCounter}`;return new Promise((r,o)=>{this.pending.set(n,{resolve:r,reject:o}),this.sendPrefab("prefab:tool-call",{tool:e,arguments:t},n),setTimeout(()=>{if(this.pending.has(n))this.pending.delete(n),o(Error(`Tool call '${e}' timed out`))},30000)})},sendMessage:(e)=>(this.sendPrefab("prefab:send-message",{message:e}),Promise.resolve()),subscribe:(e,t)=>this.subscribe(e,t),capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendPrefab(e,t,n){if(typeof window>"u")return;let r=window.parent!==window?window.parent:window,o={type:e,payload:t,id:n};r.postMessage(o,this.hostOrigin)}handleJsonRpc(e){if(!("method"in e)){let r=this.rpcPending.get(e.id);if(r)if(this.rpcPending.delete(e.id),e.error)r.reject(Error(e.error.message));else r.resolve(e.result);return}let t=e.method,n=e.params??{};if(e.id!=null&&this.sentRpcIds.delete(e.id))return;if(e.id!=null)this.postJsonRpc({jsonrpc:"2.0",id:e.id,result:{}});switch(t){case"ui/notifications/tool-input":this.dispatch("prefab:tool-input",{args:n.arguments??n});break;case"ui/notifications/tool-input-partial":this.dispatch("prefab:tool-input-partial",{args:n.arguments??n});break;case"ui/notifications/tool-result":this.dispatch("prefab:tool-result",{result:n});break;case"ui/notifications/tool-cancelled":this.dispatch("prefab:tool-cancelled",n);break;case"ui/notifications/host-context-changed":{let r={};if(typeof n.theme==="string")r.colorScheme=n.theme;if(typeof n.styles==="object"&&n.styles!==null){let o=n.styles;if(o.variables)r.variables=o.variables;if(typeof o.css?.fonts==="string")r.fontCss=o.css.fonts}this.dispatch("prefab:theme-update",r),this.dispatch("prefab:host-context-changed",n);break}case"ui/resource-teardown":this.dispatch("prefab:teardown",n);break;case"ui/notifications/resource-updated":case"notifications/resources/updated":this.dispatch("prefab:resource-updated",n);break}}initJsonRpc(e){return new Promise((t,n)=>{let r=++this.rpcIdCounter,o=!1;this.rpcPending.set(r,{resolve:(i)=>{if(o)return;o=!0,this.protocol="jsonrpc";let s=i??{},a=s.hostInfo??{},l=s.hostContext??{},d=s.hostCapabilities??{},u;if(typeof l.theme==="string"||typeof l.styles==="object"){if(u={},typeof l.theme==="string")u.colorScheme=l.theme;if(typeof l.styles==="object"&&l.styles!==null){let g=l.styles;if(g.variables)u.variables=g.variables;if(typeof g.css?.fonts==="string")u.fontCss=g.css.fonts}}this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let c=d.resources;this._hostSupportsSubscriptions=d.subscriptions===!0||c?.subscribe===!0,t({hostName:a.name,hostVersion:a.version,capabilities:{toast:!0,navigation:d.openLinks!=null,messaging:!0,displayModes:l.availableDisplayModes??[]},theme:u,toolInput:void 0,meta:l})},reject:(i)=>{if(o)return;o=!0,n(i)}}),this.postJsonRpc({jsonrpc:"2.0",id:r,method:"ui/initialize",params:{protocolVersion:"2026-01-26",appInfo:{name:"prefab",version:Mn},appCapabilities:{...e.displayModes&&{availableDisplayModes:e.displayModes}}}}),setTimeout(()=>{if(!o)o=!0,this.rpcPending.delete(r),n(Error("ui/initialize timeout"))},2000)})}createJsonRpcTransport(){return{callTool:(e,t)=>this.sendRpcRequest("tools/call",{name:e,arguments:t}),sendMessage:(e)=>this.sendRpcRequest("ui/message",{role:"user",content:{type:"text",text:e}}),subscribe:(e,t)=>this.subscribe(e,t),capabilities:{subscriptions:this._hostSupportsSubscriptions}}}sendRpcRequest(e,t){let n=++this.rpcIdCounter;return new Promise((r,o)=>{this.rpcPending.set(n,{resolve:r,reject:o}),this.postJsonRpc({jsonrpc:"2.0",id:n,method:e,params:t}),setTimeout(()=>{if(this.rpcPending.has(n))this.rpcPending.delete(n),o(Error(`JSON-RPC '${e}' timed out`))},30000)})}sendRpcNotification(e,t){this.postJsonRpc({jsonrpc:"2.0",method:e,params:t})}postJsonRpc(e){if(typeof window>"u")return;if(e.id!=null&&typeof e.method==="string")this.sentRpcIds.add(e.id);if(this.postFn)this.postFn(e);else(window.parent!==window?window.parent:window).postMessage(e,this.hostOrigin)}dispatch(e,t){let n=this.listeners.get(e);if(n)for(let r of n)r(t)}}var wi=()=>{};function Le(e,t){if(t.variables)for(let[n,r]of Object.entries(t.variables))e.style.setProperty(n.startsWith("--")?n:`--${n}`,r);if(t.colorScheme&&t.colorScheme!=="auto")e.setAttribute("data-theme",t.colorScheme);if(t.fontCss)xi(t.fontCss)}function xi(e){if(document.getElementById("__prefab-host-fonts"))return;let n=document.createElement("style");n.id="__prefab-host-fonts",n.textContent=e,document.head.appendChild(n)}function xe(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function ki(){if(typeof window>"u")return;let e=window;if(typeof e.acquireVsCodeApi==="function")try{let t=e.acquireVsCodeApi();if(t!==null&&typeof t==="object"&&"postMessage"in t)return t}catch{return}return}async function rt(e){et();let t=e?.mode??"auto",n=t==="bridge"||t==="auto"&&xe(),r,o,i={capabilities:{}};if(n)o=new ge(e?.hostOrigin),o.connect(),i=await o.initialize(e?.capabilities??{toolInput:!0}),r=o.createTransport();else if(e?.transport)r=tt(e.transport);else r=nt();if(i.theme&&typeof document<"u")Le(document.documentElement,i.theme);if(typeof document<"u"&&!o)Ai();let s,a,l,d,u,c=i.toolInput,g;if(o)o.on("prefab:tool-input",(f)=>{let b=f.args??f;if(s)s(b);else c=b}),o.on("prefab:tool-result",(f)=>{let b=f.result??f;if(a)a(b);else g=b}),o.on("prefab:tool-cancelled",()=>{l?.()}),o.on("prefab:tool-input-partial",(f)=>{d?.(f.args??f)}),o.on("prefab:theme-update",(f)=>{if(typeof document<"u")Le(document.documentElement,f)}),o.on("prefab:host-context-changed",(f)=>{u?.(f)});function h(f,...b){let w=Lt(f),S=new Se,N={store:S,scope:{},transport:r,rerender:()=>k(),onToast:void 0};function k(){w.innerHTML="";for(let R of b)w.appendChild(J(R,N))}return k(),{rerender:k,store:S,destroy:()=>{w.innerHTML=""}}}return{callTool:(f,b={})=>r.callTool(f,b),sendMessage:(f)=>r.sendMessage(f),onToolInput:(f)=>{if(s=f,c){let b=c;c=void 0,queueMicrotask(()=>f(b))}},onToolResult:(f)=>{if(a=f,g!==void 0){let b=g;g=void 0,queueMicrotask(()=>f(b))}},onToolCancelled:(f)=>{l=f},onToolInputPartial:(f)=>{d=f},onHostContextChanged:(f)=>{u=f},render:h,mount:(f,b,w)=>{let S=Lt(f);return ne.mount(S,b,{transport:r,...w})},requestMode:(f)=>o?.requestMode(f),openLink:(f,b)=>{if(o)o.openLink(f,b);else if(typeof window<"u")window.open(f,b??"_blank")},updateContext:(f)=>{if(o)o.updateContext(f)},setupAutoResize:(f)=>{if(!o)return Si;let b=typeof f==="string"?Lt(f):f;return o.setupAutoResize(b)},notifyPreferredSize:(f)=>{if(o)o.notifyPreferredSize(f)},host:i,capabilities:i.capabilities,theme:i.theme,transport:r,destroy:()=>o?.disconnect()}}var Si=()=>{};function Lt(e){if(typeof e==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let t=document.querySelector(e);if(!t)throw Error(`Element not found: ${e}`);return t}return e}function Ai(){function e(){let n=document.body.getAttribute("data-vscode-theme-kind");if(!n)return;let r=n.includes("light")?"light":"dark";document.documentElement.setAttribute("data-theme",r)}e(),new MutationObserver(e).observe(document.body,{attributes:!0,attributeFilter:["data-vscode-theme-kind"]})}var Ln=["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 $n=new Set(Ln);function ke(e,t={}){let n=[],r=t.strict??!1;if(e==null||typeof e!=="object")return n.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:n};let o=e;if(o.$prefab==null||typeof o.$prefab!=="object")n.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof o.$prefab.version!=="string")n.push({path:"$.$prefab.version",message:"version must be a string"});if(o.view==null)n.push({path:"$.view",message:'Missing required "view" field'});else Ht(o.view,"$.view",n,r);if(o.state!==void 0){if(o.state===null||typeof o.state!=="object"||Array.isArray(o.state))n.push({path:"$.state",message:"state must be a plain object"})}if(o.theme!==void 0)Ri(o.theme,n);if(o.css!==void 0)Pn(o.css,"$.css",n);if(o.stylesheets!==void 0)Pn(o.stylesheets,"$.stylesheets",n);if(o.mode!==void 0&&o.mode!=="light"&&o.mode!=="dark")n.push({path:"$.mode",message:'mode must be "light" or "dark"'});if(o.defs!==void 0)if(o.defs===null||typeof o.defs!=="object"||Array.isArray(o.defs))n.push({path:"$.defs",message:"defs must be a plain object"});else for(let[i,s]of Object.entries(o.defs))Ht(s,`$.defs.${i}`,n,r);if(o.keyBindings!==void 0)if(o.keyBindings===null||typeof o.keyBindings!=="object"||Array.isArray(o.keyBindings))n.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[i,s]of Object.entries(o.keyBindings))Pt(s,`$.keyBindings.${i}`,n);return{valid:n.length===0,errors:n}}function On(e){return ke(e).valid}function Ht(e,t,n,r){if(e==null||typeof e!=="object"||Array.isArray(e)){n.push({path:t,message:"Component must be a plain object"});return}let o=e;if(typeof o.type!=="string"||o.type.length===0){n.push({path:`${t}.type`,message:'Component must have a non-empty "type" string'});return}if(r&&!$n.has(o.type))n.push({path:`${t}.type`,message:`Unknown component type: "${o.type}"`});if(o.children!==void 0)if(!Array.isArray(o.children))n.push({path:`${t}.children`,message:"children must be an array"});else for(let s=0;s<o.children.length;s++)Ht(o.children[s],`${t}.children[${s}]`,n,r);let i=["onClick","on_click","onChange","on_change","onSubmit","on_submit","onMount","on_mount","onClose","on_close"];for(let s of i)if(o[s]!==void 0)Pt(o[s],`${t}.${s}`,n);for(let[s,a]of Object.entries(o)){if(s==="type"||Ei.has(s)||i.includes(s))continue;if(Hn(a)||Array.isArray(a)&&a.some(Hn))n.push({path:`${t}.${s}`,message:`Components under "${s}" are ignored by the renderer; move them into "children"`})}}var Ei=new Set(["children","fallback","trigger","empty","else","summary"]);function Hn(e){if(e==null||typeof e!=="object"||Array.isArray(e))return!1;let t=e.type;return typeof t==="string"&&$n.has(t)}function Pt(e,t,n){if(Array.isArray(e)){for(let a=0;a<e.length;a++)Pt(e[a],`${t}[${a}]`,n);return}if(e==null||typeof e!=="object"){n.push({path:t,message:"Action must be an object or array of objects"});return}let r=e,o=typeof r.type==="string"&&r.type.length>0,i=typeof r.action==="string"&&r.action.length>0;if(!o&&!i){n.push({path:`${t}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if((i?r.action:r.type).toLowerCase()==="showtoast"){if(typeof r.message!=="string"||r.message.length===0)n.push({path:`${t}.message`,message:'showToast requires a non-empty "message" string'})}}function Pn(e,t,n){if(!Array.isArray(e)){n.push({path:t,message:`${t} must be an array of strings`});return}for(let r=0;r<e.length;r++)if(typeof e[r]!=="string")n.push({path:`${t}[${r}]`,message:"must be a string"})}function Ri(e,t){if(e===null||typeof e!=="object"||Array.isArray(e)){t.push({path:"$.theme",message:"theme must be a plain object"});return}let n=e;for(let r of["light","dark"])if(n[r]!==void 0){if(n[r]===null||typeof n[r]!=="object"||Array.isArray(n[r]))t.push({path:`$.theme.${r}`,message:`theme.${r} must be a plain object`})}}var ne={mount(e,t,n){if(et(),n?.validate!==!1)for(let b of ke(t).errors)O.warn(`wire validation ${b.path}: ${b.message}`);let r=t,o={tracked:[],evalBlocked:!1};if(r.pipes)for(let[b,w]of Object.entries(r.pipes))Dn(b,w,o);let i=new Se(r.state),s;if(n?.transport&&"callTool"in n.transport)s=n.transport;else if(n?.transport)s=tt(n.transport);else s=nt();let a=n?.onToast??Mi,l=new Re;function d(b){let w=b;if(r=w,w.state)i.merge(w.state);if(w.defs)u.defs=w.defs;if(w.theme)Nt(e,w.theme);if(w.mode)jn(e,w.mode);if(w.pipes)for(let[S,N]of Object.entries(w.pipes))Dn(S,N,o);for(let S of c)S.remove();if(c.length=0,c.push(...In(w.css,w.stylesheets)),Fn(e,w.layout),g?.(),g=void 0,w.keyBindings)g=Mt(w.keyBindings,(S)=>{I(j(S,{store:i,transport:s,scope:{},rerender:()=>f(),remount:d,onToast:a}),"keyBinding")});f()}let u={store:i,scope:{},transport:s,rerender:()=>f(),remount:d,onToast:a,defs:r.defs,destroyRegistry:l};if(Nt(e,r.theme),r.mode)jn(e,r.mode);Fn(e,r.layout);let c=In(r.css,r.stylesheets),g;if(r.keyBindings)g=Mt(r.keyBindings,(b)=>{I(j(b,{store:i,transport:s,scope:{},rerender:()=>f(),remount:d,onToast:a}),"keyBinding")});let h,y=n?.themeToggle??!0;if(y!==!1)h=Me(e,typeof y==="object"?y:void 0);function f(){l.flush();let b=e.querySelector(".pf-theme-toggle");e.innerHTML="";let w=J(r.view,u);if(e.appendChild(w),b)e.appendChild(b)}return f(),{rerender:()=>f(),update(b){if(i.merge(b.update.state),f(),b.update.actions!=null)I(j(b.update.actions,u),"update action")},store:i,destroy(){l.flush(),h?.(),g?.(),Vt(),zt();for(let b of c)b.remove();for(let b of o.tracked)Ee(b);e.innerHTML=""}}},isPrefabData(e){return e!=null&&typeof e==="object"&&"$prefab"in e},isPrefabUpdate(e){return e!=null&&typeof e==="object"&&"$prefab"in e&&"update"in e}},Ti=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 Ni(e){if(e instanceof EvalError)return!0;return e instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test(e.message)}function Dn(e,t,n){if(Ti.has(e)){O.warn(`wire pipe "${e}" ignored — shadows built-in`);return}if($e(e)!=null){O.debug(`wire pipe "${e}" — already registered, keeping local implementation`);return}if(n.evalBlocked)return;try{let r=Function("return ("+t+")")();if(typeof r!=="function"){O.warn(`wire pipe "${e}" — source did not evaluate to a function`);return}Ae(e,r),n.tracked.push(e)}catch(r){if(Ni(r)){n.evalBlocked=!0,O.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}O.warn(`wire pipe "${e}" — failed to hydrate:`,r)}}function Mi(e){if(typeof document>"u")return;let t=Hi(),n=document.createElement("div"),r=e.variant??"default";n.className=`pf-toast${r!=="default"?` pf-toast--${r}`:""}`,n.setAttribute("data-variant",r),n.style.marginBottom="8px",n.style.transition="opacity 0.3s ease";let o=document.createElement("div");if(o.textContent=e.message,o.style.fontWeight="500",n.appendChild(o),e.description){let s=document.createElement("div");s.textContent=e.description,s.style.fontSize="14px",s.style.color="var(--muted-foreground, #6b7280)",n.appendChild(s)}t.appendChild(n);let i=e.duration??4000;setTimeout(()=>{n.style.opacity="0",setTimeout(()=>n.remove(),300)},i)}function jn(e,t){if(we(e,t),typeof document<"u")we(document.documentElement,t)}function Li(e){let t=e.trim();if(t.includes("{")||t.includes("}"))return!1;return/^(https?:)?\/\//i.test(t)||t.startsWith("/")||/\.css(\?|#|$)/i.test(t)}function In(e,t){let n=[];if(typeof document>"u")return n;for(let r of e??[]){let o=document.createElement("style");o.textContent=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}for(let r of t??[])if(Li(r)){let o=document.createElement("link");o.rel="stylesheet",o.href=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}else{let o=document.createElement("style");o.textContent=r,o.dataset.prefab="injected",document.head.appendChild(o),n.push(o)}return n}function Fn(e,t){if(e.style.height="",e.style.minHeight="",e.style.maxHeight="",e.style.overflow="",!t)return;if(t.preferredHeight!=null)e.style.height=`${t.preferredHeight}px`;if(t.minHeight!=null)e.style.minHeight=`${t.minHeight}px`;if(t.maxHeight!=null)e.style.maxHeight=`${t.maxHeight}px`,e.style.overflow="auto"}function Hi(){let t=document.getElementById("prefab-toast-container");if(!t)t=document.createElement("div"),t.id="prefab-toast-container",t.style.position="fixed",t.style.bottom="16px",t.style.right="16px",t.style.zIndex="9999",t.style.maxWidth="400px",document.body.appendChild(t);return t}if(typeof window<"u"){let e=window;e.PrefabRenderer=ne,e.prefab={app:rt,mount:ne.mount.bind(ne),isPrefabData:ne.isPrefabData.bind(ne),isPrefabUpdate:ne.isPrefabUpdate.bind(ne),Bridge:ge,isIframe:xe,registerPipe:Ae,unregisterPipe:Ee,listPipes:Pe,registerComponent:p,createThemeToggle:Me,validateWireFormat:ke,setLogLevel:He};let t=e.__PREFAB_DATA__;if(t!=null){let n=document.getElementById("prefab-root");if(n)ne.mount(n,t)}}})();
|