@maxhealth.tech/prefab 0.3.23 → 0.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/a2ui.min.js +1 -1
  3. package/dist/auto/chart.js +1 -1
  4. package/dist/auto/chart.js.map +1 -1
  5. package/dist/auto/comparison.js +1 -1
  6. package/dist/auto/comparison.js.map +1 -1
  7. package/dist/auto/form.d.ts +1 -1
  8. package/dist/auto/form.d.ts.map +1 -1
  9. package/dist/auto/form.js +15 -2
  10. package/dist/auto/form.js.map +1 -1
  11. package/dist/auto/index.d.ts +2 -10
  12. package/dist/auto/index.d.ts.map +1 -1
  13. package/dist/auto/index.js +5 -61
  14. package/dist/auto/index.js.map +1 -1
  15. package/dist/auto/metrics.js +1 -1
  16. package/dist/auto/metrics.js.map +1 -1
  17. package/dist/auto/progress.d.ts.map +1 -1
  18. package/dist/auto/progress.js +8 -7
  19. package/dist/auto/progress.js.map +1 -1
  20. package/dist/auto/status.d.ts +17 -0
  21. package/dist/auto/status.d.ts.map +1 -0
  22. package/dist/auto/status.js +79 -0
  23. package/dist/auto/status.js.map +1 -0
  24. package/dist/auto/timeline.d.ts.map +1 -1
  25. package/dist/auto/timeline.js +3 -14
  26. package/dist/auto/timeline.js.map +1 -1
  27. package/dist/components/form/index.d.ts +1 -1
  28. package/dist/components/form/index.d.ts.map +1 -1
  29. package/dist/components/form/index.js +7 -1
  30. package/dist/components/form/index.js.map +1 -1
  31. package/dist/components/layout/index.d.ts +7 -1
  32. package/dist/components/layout/index.d.ts.map +1 -1
  33. package/dist/components/layout/index.js +6 -2
  34. package/dist/components/layout/index.js.map +1 -1
  35. package/dist/core/version.d.ts +1 -1
  36. package/dist/core/version.js +1 -1
  37. package/dist/prefab.css +85 -2
  38. package/dist/renderer/cdn.d.ts +5 -0
  39. package/dist/renderer/cdn.d.ts.map +1 -0
  40. package/dist/renderer/cdn.js +19 -0
  41. package/dist/renderer/cdn.js.map +1 -0
  42. package/dist/renderer/components/alert.d.ts.map +1 -1
  43. package/dist/renderer/components/alert.js +2 -1
  44. package/dist/renderer/components/alert.js.map +1 -1
  45. package/dist/renderer/components/charts/helpers.d.ts.map +1 -1
  46. package/dist/renderer/components/charts/helpers.js +21 -6
  47. package/dist/renderer/components/charts/helpers.js.map +1 -1
  48. package/dist/renderer/components/charts/scatter.d.ts.map +1 -1
  49. package/dist/renderer/components/charts/scatter.js +23 -4
  50. package/dist/renderer/components/charts/scatter.js.map +1 -1
  51. package/dist/renderer/components/data.d.ts.map +1 -1
  52. package/dist/renderer/components/data.js +2 -1
  53. package/dist/renderer/components/data.js.map +1 -1
  54. package/dist/renderer/components/form.d.ts.map +1 -1
  55. package/dist/renderer/components/form.js +3 -0
  56. package/dist/renderer/components/form.js.map +1 -1
  57. package/dist/renderer/components/layout.js +28 -7
  58. package/dist/renderer/components/layout.js.map +1 -1
  59. package/dist/renderer/components/media.d.ts.map +1 -1
  60. package/dist/renderer/components/media.js +23 -8
  61. package/dist/renderer/components/media.js.map +1 -1
  62. package/dist/renderer/components/pdf.d.ts +38 -0
  63. package/dist/renderer/components/pdf.d.ts.map +1 -1
  64. package/dist/renderer/components/pdf.js +152 -174
  65. package/dist/renderer/components/pdf.js.map +1 -1
  66. package/dist/renderer/icons.d.ts +5 -0
  67. package/dist/renderer/icons.d.ts.map +1 -0
  68. package/dist/renderer/icons.generated.d.ts +3 -0
  69. package/dist/renderer/icons.generated.d.ts.map +1 -0
  70. package/dist/renderer/icons.generated.js +64 -0
  71. package/dist/renderer/icons.generated.js.map +1 -0
  72. package/dist/renderer/icons.js +23 -0
  73. package/dist/renderer/icons.js.map +1 -0
  74. package/dist/renderer.auto.min.js +9 -9
  75. package/dist/renderer.min.js +9 -9
  76. package/package.json +3 -1
@@ -1,16 +1,16 @@
1
- (()=>{var en={silent:0,error:1,warn:2,info:3,debug:4},tn="warn";function nn(e){tn=e}function dt(e){let t=e?`[prefab:${e}]`:"[prefab]",n=(r,o,i)=>{if(en[r]>en[tn])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 A=dt();function k(e){return e!=null&&typeof e==="object"&&!Array.isArray(e)}function b(e){return typeof e==="string"?e:void 0}function D(e){return typeof e==="number"?e:void 0}function P(e){return k(e)?e:void 0}function z(e){return Array.isArray(e)?e.filter(k):[]}function pt(e){return k(e)?[e]:z(e)}function Kr(e){return typeof e==="string"||typeof e==="number"||typeof e==="boolean"}function rn(e){let t={};if(!k(e))return t;for(let[n,r]of Object.entries(e))if(Kr(r))t[n]=String(r);return t}class He{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor(e){if(e)this.data=structuredClone(e)}get(e){return Wr(this.data,e)}getAll(){return this.data}set(e,t){on(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))on(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 Wr(e,t){let n=t.split("."),r=e;for(let o of n){if(r==null||typeof r!=="object")return;r=Reflect.get(r,o)}return r}var zr=new Set(["__proto__","constructor","prototype"]);function on(e,t,n){let r=t.split(".");if(r.some((i)=>zr.has(i))){A.warn(`Blocked prototype pollution attempt: ${t}`);return}let o=e;for(let i=0;i<r.length-1;i++){let s=r[i],a=o[s];if(k(a))o=a;else{let l={};o[s]=l,o=l}}o[r[r.length-1]]=n}function sn(e){return typeof e==="function"}var ke=new Map;function ut(e,t){if(ke.has(e)&&ke.get(e)!==t)A.warn(`pipe "${e}" re-registered`);ke.set(e,t)}function ft(e){return ke.delete(e)}function an(){return[...ke.keys()]}function je(e){return ke.get(e)}function E(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(E).join(", ");try{return JSON.stringify(e)??""}catch{return""}}function mt(e,t){let n=e instanceof Date?e:typeof e==="string"||typeof e==="number"?new Date(e):void 0;return n&&!Number.isNaN(n.getTime())?t(n):e}var ln=-1,gt=new Map,Gr=/\{\{\s*(.+?)\s*\}\}/g;function q(e){return typeof e==="string"&&e.includes("{{")&&e.includes("}}")}function U(e,t,n){let r=e.trim();if(r.startsWith("{{")&&r.endsWith("}}")&&eo(r,"{{")===1){let o=r.slice(2,-2).trim();return cn(o,t,n)}return e.replace(Gr,(o,i)=>{let s=cn(i.trim(),t,n);return E(s)})}function cn(e,t,n){let[r,...o]=Qr(e),i=G(r.trim(),t,n);for(let s of o)i=qr(s.trim(),i,t,n);return i}function G(e,t,n){let r=Yr(e);if(r>=0){let s=e.slice(0,r).trim(),a=e.slice(r+1),l=Zr(a);if(l>=0){let c=a.slice(0,l).trim(),d=a.slice(l+1).trim(),f=G(s,t,n);return f!==null&&f!==void 0&&f!==!1&&f!==0&&f!==""?G(c,t,n):G(d,t,n)}}let o=Fe(e,"||");if(o>=0){let s=G(e.slice(0,o).trim(),t,n);return s!==null&&s!==void 0&&s!==!1&&s!==0&&s!==""?s:G(e.slice(o+2).trim(),t,n)}let i=Fe(e,"&&");if(i>=0){let s=G(e.slice(0,i).trim(),t,n);if(s===null||s===void 0||s===!1||s===0||s==="")return s;return G(e.slice(i+2).trim(),t,n)}for(let[s,a]of Ur){let l=Fe(e,s);if(l>=0){let c=G(e.slice(0,l).trim(),t,n),d=G(e.slice(l+s.length).trim(),t,n);return a(c,d)}}if(e.startsWith("!")){let s=G(e.slice(1).trim(),t,n);return s===null||s===void 0||s===!1||s===0||s===""}for(let[s,a]of Xr){let l=Fe(e,s);if(l>=0){let c=G(e.slice(0,l).trim(),t,n),d=G(e.slice(l+s.length).trim(),t,n);return a(Number(c),Number(d))}}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),c=n[a];return Ve(c,l)}return n[e]}if(n){let s=e.split(".")[0];if(s in n)return Ve(n[s],e.includes(".")?e.slice(s.length+1):"")}return t.get(e)}var pn=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 qr(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?ht(s):void 0;switch(i){case"find":{if(!Array.isArray(t)||!s)return;let l=dn(s);if(l.length<2)return;let c=String(ht(l[0])),d=l[1].trim(),f;if(d.startsWith("'")&&d.endsWith("'")||d.startsWith('"')&&d.endsWith('"'))f=d.slice(1,-1);else if(n){if(r&&d.startsWith("$")){let h=d.indexOf(".");if(h>=0){let C=d.slice(0,h);if(C in r)f=Ve(r[C],d.slice(h+1))}else if(d in r)f=r[d]}if(f===void 0&&!(r&&d.startsWith("$")))if(r){let h=d.split(".")[0];f=h in r?Ve(r[h],d.includes(".")?d.slice(h.length+1):""):n.get(d)}else f=n.get(d)}else f=d;if(f==null)return;let u=n?.generation??0;if(u!==ln)gt=new Map,ln=u;let g=gt.get(t);if(!g)g=new Map,gt.set(t,g);let y=g.get(c);if(!y){y=new Map;for(let h of t)if(k(h)){let C=h[c];if(C!=null)y.set(E(C),h)}g.set(c,y)}return y.get(E(f))}case"dot":{if(t==null||typeof t!=="object"||typeof a!=="string")return;return Reflect.get(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":return mt(t,(l)=>l.toLocaleDateString());case"time":return mt(t,(l)=>l.toLocaleTimeString());case"datetime":return mt(t,(l)=>l.toLocaleString());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)=>k(l)&&Boolean(l[a])):t;case"rejectattr":return Array.isArray(t)&&typeof a==="string"?t.filter((l)=>{if(!k(l))return!1;let c=l[a];return c==null||c===!1||c===0||c===""}):t;default:{let l=je(i);if(l){let c=s?dn(s).map(ht):[];return l(t,...c)}return t}}}var Ur=[["!==",(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)]],Xr=[[" + ",(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 Fe(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 Yr(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 Zr(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 Qr(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 ht(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 dn(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 Ve(e,t){if(!t)return e;let n=t.split("."),r=e;for(let o of n){if(!k(r)&&!Array.isArray(r))return;r=Reflect.get(r,o)}return r}function eo(e,t){let n=0,r=0;while((r=e.indexOf(t,r))!==-1)n++,r+=t.length;return n}function Be(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function bt(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:Be(n);if(Array.isArray(r))t[o]=r.map((i)=>k(i)?bt(i):i);else if(k(r))t[o]=bt(r);else t[o]=r}return t}async function I(e,t){for(let n of pt(e))await to(n,t)}function j(e,t){e.catch((n)=>A.error(`${t} failed:`,n))}async function _e(e,t,n,r){if(n!=null)A.debug(`${e} failed:`,t),await Pe(n,r,{$error:t});else A.warn(`${e} failed:`,t)}async function to(e,t){let n=bt(e);switch(b(n.action)){case"setState":{no(n,t);return}case"toggleState":{ro(n,t);return}case"appendState":{oo(n,t);return}case"popState":{io(n,t);return}case"showToast":{so(n,t);return}case"closeOverlay":{ao(n,t);return}case"openLink":{lo(n);return}case"setInterval":{po(n,t);return}case"toolCall":case"callTool":return uo(n,t);case"sendMessage":return fo(n,t);case"updateContext":{mo(n,t);return}case"fetch":return go(n,t);case"openFilePicker":{ho(n,t);return}case"callHandler":return bo(n,t);case"requestDisplayMode":{yo(n,t);return}case"subscribe":{xo(n,t);return}case"unsubscribe":{wo(n);return}default:A.warn(`Unknown action: ${E(n.action)}`)}}function We(e,t){let n=b(e.key);if(n===void 0)A.warn(`${t}: missing key`);return n}function no(e,t){let n=We(e,"setState");if(n===void 0)return;let r=e.value;if(q(r))r=U(r,t.store,t.scope);t.store.set(n,r),t.rerender(),Pe(e.onSuccess,t)}function ro(e,t){let n=We(e,"toggleState");if(n===void 0)return;t.store.toggle(n),t.rerender()}function oo(e,t){let n=We(e,"appendState");if(n===void 0)return;let r=e.value??e.item;if(q(r))r=U(r,t.store,t.scope);t.store.append(n,r,D(e.index)),t.rerender()}function io(e,t){let n=We(e,"popState");if(n===void 0)return;let r=q(e.index)?U(e.index,t.store,t.scope):e.index;if(typeof r!=="number"&&typeof r!=="string"){A.warn("popState: missing index");return}t.store.pop(n,r),t.rerender()}function so(e,t){t.onToast?.({message:Ke(e.message,t),description:e.description!=null?Ke(e.description,t):void 0,variant:b(e.variant),duration:D(e.duration)})}function ao(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function lo(e){if(typeof window<"u"){let t=b(e.url);if(!t){A.warn("openLink: missing url");return}if(!Cn(t)){A.warn(`Blocked unsafe URL scheme: ${t}`);return}window.open(t,b(e.target)??"_blank")}}var Je=new Set,co=20,yt=100;function po(e,t){let n=Math.max(D(e.intervalMs)??yt,yt),r=pt(e.onTick);if(typeof globalThis.setInterval!=="function")return;if(r.length===0){A.warn("setInterval: missing onTick");return}if(Je.size>=co){A.warn("Max intervals reached, ignoring new setInterval");return}let o=globalThis.setInterval(()=>j(I(r,t),"interval action"),n);Je.add(o)}function un(){for(let e of Je)globalThis.clearInterval(e);Je.clear()}async function fn(e,t,n){let r=b(e.resultKey);if(r!==void 0)n.store.set(r,t);let o=bn(t);if(o&&n.remount)n.remount(o);else yn(t,n),n.rerender();await Pe(e.onSuccess,n,{$result:t})}async function mn(e,t,n,r,o){let i=vn(P(n.arguments),r);try{if(t===void 0)throw Error(`${e}: missing tool name`);let s=await o.callTool(t,i);await fn(n,s,r)}catch(s){await _e(e,s,n.onError,r)}}async function uo(e,t){if(!t.transport){A.warn("No MCP transport configured for toolCall");return}await mn("toolCall",b(e.tool),e,t,t.transport)}async function fo(e,t){if(!t.transport){A.warn("No MCP transport configured for sendMessage");return}await t.transport.sendMessage(Ke(e.message,t))}function mo(e,t){let n=P(e.context);if(n!=null)t.store.merge(n),t.rerender()}async function go(e,t){let n=Ke(e.url,t);if(!Cn(n)){A.warn(`Blocked unsafe URL in fetch: ${n}`);return}let r=b(e.method)??"GET",o=rn(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());await fn(e,a,t)}catch(s){await _e("fetch",s,e.onError,t)}}function ho(e,t){if(typeof document>"u")return;let n=document.createElement("input");n.type="file";let r=b(e.accept);if(r!==void 0)n.accept=r;if(e.multiple===!0)n.multiple=!0;n.addEventListener("change",()=>{let o=Array.from(n.files??[]),i=b(e.resultKey);if(i!==void 0)t.store.set(i,o);t.rerender(),Pe(e.onSuccess,t,{$result:o})}),n.click()}async function bo(e,t){let n=b(e.handler);if(!t.transport){A.warn(`No transport configured for callHandler: ${n??""}`);return}await mn("callHandler",n,e,t,t.transport)}function yo(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:e.mode}}))}var Z=new Map,Co=50,vo=2000;function xo(e,t){let n=b(e.uri),r=b(e.stateKey);if(!n||!r){A.warn("subscribe: missing uri or stateKey");return}if(Z.has(n))return;if(Z.size>=Co){A.warn("Max subscriptions reached, ignoring new subscribe");return}let o=(f)=>{let u=bn(f);if(u&&t.remount)t.remount(u);else{if(!yn(f,t))t.store.set(r,f);t.rerender()}Pe(e.onData,t,{$data:f})};if(e.push!==!1&&t.transport?.subscribe&&t.transport.capabilities?.subscriptions){let f=t.transport.subscribe(n,o,(u)=>{if(Z.get(n)===f)Z.delete(n);_e("subscribe",u,e.onError,t)});Z.set(n,f);return}let i=b(e.fallbackTool),s=D(e.fallbackInterval)??vo;if(!i){A.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!t.transport){A.warn("No MCP transport configured for subscribe fallback");return}let a=P(e.fallbackArgs)??{},l=Math.max(s,yt),c=t.transport,d=globalThis.setInterval(()=>{(async()=>{try{let f=vn(a,t),u=await c.callTool(i,f);o(u)}catch(f){_e("subscribe",f,e.onError,t)}})()},l);Z.set(n,()=>globalThis.clearInterval(d))}function wo(e){let t=b(e.uri);if(!t){A.warn("unsubscribe: missing uri");return}let n=Z.get(t);if(n)n(),Z.delete(t)}function gn(){for(let[e,t]of Z)try{t()}catch(n){A.warn(`Error cleaning up subscription '${e}':`,n)}Z.clear()}function ko(e){try{return JSON.parse(e)}catch{return}}function hn(e,t){if(!k(e))return null;if(t(e))return e;let n=e.structuredContent;if(k(n)&&t(n))return n;for(let r of z(e.content)){if(r.type!=="text"||typeof r.text!=="string")continue;let o=ko(r.text);if(k(o)&&t(o))return o}return null}function Eo(e){return"$prefab"in e&&"view"in e}function Ro(e){return"$prefab"in e&&k(e.update)&&"state"in e.update}function bn(e){return hn(e,Eo)}function yn(e,t){let n=hn(e,Ro);if(!n)return!1;let{update:r}=n,o=P(r.state);if(o)t.store.merge(o);if(r.actions!=null)j(I(r.actions,t),"update action");return!0}var To=/^\s*(javascript|vbscript|data):/i;function Cn(e){return!To.test(e)}function Ke(e,t){if(q(e)){let n=U(e,t.store,t.scope);return E(n)}return E(e)}function vn(e,t){if(!e)return{};let n={};for(let[r,o]of Object.entries(e))n[r]=q(o)?U(o,t.store,t.scope):o;return n}async function Pe(e,t,n){if(e==null)return;let r={...t.scope,...n};await I(e,{...t,scope:r})}function ze(e,t){return e===void 0||t(e)}function Ct(e){return k(e)||Array.isArray(e)&&e.every(k)}function Ee(e){return k(e)&&typeof e.type==="string"&&ze(e.id,(t)=>typeof t==="string")&&ze(e.cssClass,(t)=>typeof t==="string")&&ze(e.onMount,Ct)&&ze(e.children,(t)=>Array.isArray(t)&&t.every(Ee))}function fe(e){return Array.isArray(e)?e.filter(Ee):[]}function xt(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:Be(n);if(Array.isArray(r))t[o]=r.map((i)=>k(i)?xt(i):i);else if(k(r))t[o]=xt(r);else t[o]=r}return t}function So(e){let{id:t,cssClass:n,onMount:r,children:o,...i}=xt(e),s={...i,type:e.type};if(typeof t==="string")s.id=t;if(typeof n==="string")s.cssClass=n;if(Ct(r))s.onMount=r;if(Array.isArray(o))s.children=fe(o);return s}class wt{callbacks=[];track(e){this.callbacks.push(e)}flush(){for(let e of this.callbacks)try{e()}catch(t){A.warn("destroy callback error:",t)}this.callbacks=[]}get size(){return this.callbacks.length}}function Ao(e){return typeof e==="object"&&"element"in e}var Ge=new Map;function p(e,t){if(Ge.has(e))A.warn(`overriding existing renderer for "${e}"`);Ge.set(e,t)}function kt(){return[...Ge.keys()].sort()}var xn=new Set;function kn(e){xn.clear();for(let t of e)xn.add(t)}function B(e,t){let n=So(e);if(t.defs?.[n.type]){let i={...t.defs[n.type],...n,type:t.defs[n.type].type};return B(i,t)}let r=Ge.get(n.type),o;if(r){let i=r(n,t);if(Ao(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(B(i,t));if(o instanceof HTMLElement){if(n.id)o.id=n.id;if(n.cssClass){let i=v(n.cssClass,t);if(i)o.className=(o.className?o.className+" ":"")+i}if(n.onClick!=null){if(o.addEventListener("click",()=>{j(I(n.onClick,J(t)),"onClick")}),o.tagName!=="BUTTON"&&o.tagName!=="A")o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.addEventListener("keydown",(i)=>{if(i.key==="Enter"||i.key===" ")i.preventDefault(),j(I(n.onClick,J(t)),"onClick")})}}if(n.onMount){let i=n.onMount,s=J(t);queueMicrotask(()=>j(I(i,s),"onMount"))}return o}function M(e,t,n){if(!e.children)return;me(e.children,t,n)}function me(e,t,n){let r=0;while(r<e.length){let o=e[r];if(o.type==="If")r=Mo(e,r,t,n);else if(o.type==="Elif"||o.type==="Else")r++;else t.appendChild(B(o,n)),r++}}function Mo(e,t,n,r){let o=!1,i=t,s=e[i];if(wn(b(s.condition)??"",r))vt(s,n,r),o=!0;i++;while(i<e.length){let a=e[i];if(a.type==="Elif"){if(!o&&wn(b(a.condition)??"",r))vt(a,n,r),o=!0;i++}else if(a.type==="Else"){if(!o)vt(a,n,r);i++;break}else break}return i}function wn(e,t){if(!e)return!1;if(q(e))return Boolean(U(e,t.store,t.scope));return Boolean(t.store.get(e))}function vt(e,t,n){if(!e.children)return;me(e.children,t,n)}function v(e,t){if(q(e)){let n=U(e,t.store,t.scope);return E(n)}return E(e)}function K(e,t){if(q(e))return U(e,t.store,t.scope);return e}function J(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 Et(e,t){return e.textContent=t,e}function An(){p("Column",No),p("Row",Lo),p("Grid",En),p("GridItem",Rn),p("Container",Ho),p("Div",Tn),p("Span",Po),p("Dashboard",En),p("DashboardItem",Rn),p("Pages",Oo),p("Page",Tn),p("Detail",Do),p("MasterDetail",$o)}function No(e,t){let n=m("div","pf-column");n.style.display="flex",n.style.flexDirection="column";let r=qe(e);if(r!=null)n.style.gap=`${r*4}px`;return Mn(n,e),M(e,n,t),n}function Lo(e,t){let n=m("div","pf-row");n.style.display="flex",n.style.flexDirection="row";let r=qe(e);if(r!=null)n.style.gap=`${r*4}px`;if(Mn(n,e),e.wrap===!0)n.style.flexWrap="wrap";return M(e,n,t),n}function En(e,t){let n=m("div","pf-grid");n.style.display="grid",n.style.gridTemplateColumns=`repeat(${Fo(e.columns)}, minmax(0, 1fr))`;let r=qe(e);if(r!=null)n.style.gap=`${r*4}px`;return M(e,n,t),n}function Rn(e,t){let n=m("div","pf-grid-item"),r=D(e.colSpan),o=D(e.rowSpan);if(r!=null)n.style.gridColumn=`span ${r}`;if(o!=null)n.style.gridRow=`span ${o}`;return M(e,n,t),n}function Ho(e,t){let n=m("div","pf-container");n.style.maxWidth=b(e.maxWidth)??"1200px",n.style.margin="0 auto";let r=D(e.padding);if(r!=null)n.style.padding=`${r*4}px`;return M(e,n,t),n}function Tn(e,t){let n=m("div","pf-div");return M(e,n,t),n}function Po(e,t){let n=m("span","pf-span");return M(e,n,t),n}function Oo(e,t){let n=m("div","pf-pages");return M(e,n,t),n}function Do(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)M(e,n,t);else if(Ee(e.empty))n.appendChild(B(e.empty,t));return n}function $o(e,t){let n=m("div","pf-master-detail"),r=qe(e);if(r!=null)n.style.gap=`${r*4}px`;let o=b(e.masterWidth)??"33%",i=e.children??[];if(i.length>0){let s=m("div","pf-master-detail-master");s.style.width=o,s.appendChild(B(i[0],t)),n.appendChild(s)}if(i.length>1){let s=m("div","pf-master-detail-detail");s.appendChild(B(i[1],t)),n.appendChild(s)}return n}var Io=/\bgap-(\d+)\b/;function qe(e){let t=D(e.gap);if(t!=null)return t;if(typeof e.cssClass==="string"){let n=Io.exec(e.cssClass);if(n)return Number(n[1])}return null}var jo=["default","base","xs","sm","md","lg","xl","2xl"],Sn=3;function Fo(e){if(typeof e==="number")return e;if(!k(e))return Sn;let t=jo.map((n)=>e[n]).filter((n)=>typeof n==="number");return t.length>0?t[t.length-1]:Sn}function Mn(e,t){let n=b(t.align),r=b(t.justify);if(n!=null)e.style.alignItems=Vo(n);if(r!=null)e.style.justifyContent=Bo(r)}function Vo(e){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[e]??e}function Bo(e){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[e]??e}var _o={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function Q(e){return e.replace(/[&<>"']/g,(t)=>_o[t]??t)}function Ln(){p("Heading",Jo),p("H1",(e,t)=>Ue(e,t,"h1")),p("H2",(e,t)=>Ue(e,t,"h2")),p("H3",(e,t)=>Ue(e,t,"h3")),p("H4",(e,t)=>Ue(e,t,"h4")),p("Text",Ko),p("P",Wo),p("Lead",(e,t)=>Re(e,t,"p","pf-lead")),p("Large",(e,t)=>Re(e,t,"span","pf-large")),p("Small",(e,t)=>Re(e,t,"small","pf-small")),p("Muted",(e,t)=>Re(e,t,"p","pf-muted")),p("BlockQuote",(e,t)=>Re(e,t,"blockquote","pf-blockquote")),p("Label",(e,t)=>Re(e,t,"label","pf-label")),p("Link",Go),p("Code",qo),p("Markdown",Uo),p("Kbd",Xo)}function Jo(e,t){let n=D(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=v(e.content,t),o}function Ue(e,t,n){let r=document.createElement(n);return r.className=`pf-heading pf-${n}`,r.textContent=v(e.content,t),r}function Ko(e,t){return Et(m("span","pf-text"),v(e.content,t))}function Wo(e,t){return Et(m("p","pf-p"),v(e.content,t))}function Re(e,t,n,r){let o=document.createElement(n);return o.className=r,o.textContent=v(e.content,t),o}var zo=/^\s*(javascript|vbscript|data):/i;function Go(e,t){let n=document.createElement("a");if(n.className="pf-link",n.textContent=v(e.content,t),e.href!=null){let r=v(e.href,t);if(!zo.test(r))n.href=r}if(e.target!=null)n.target=v(e.target,t);return n}function qo(e,t){let n=m("pre","pf-code"),r=m("code");if(r.textContent=v(e.content,t),e.language!=null)r.setAttribute("data-language",E(e.language));return n.appendChild(r),n}function Uo(e,t){let n=m("div","pf-markdown"),r=v(e.content,t);return n.innerHTML=Hn(r),n.setAttribute("data-markdown","true"),n}var Nn=/^\s*(javascript|vbscript|data):/i;function Xe(e){let t=Q(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(Nn.test(i))return Q(o);return`<img src="${i}" alt="${o}" />`}),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,o,i)=>{if(Nn.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 Hn(e){let t=e.replace(/\r\n?/g,`
1
+ (()=>{var sn={silent:0,error:1,warn:2,info:3,debug:4},an="warn";function ln(e){an=e}function mt(e){let t=e?`[prefab:${e}]`:"[prefab]",n=(r,o,i)=>{if(sn[r]>sn[an])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 S=mt();function M(e){return e!=null&&typeof e==="object"&&!Array.isArray(e)}function b(e){return typeof e==="string"?e:void 0}function O(e){return typeof e==="number"?e:void 0}function P(e){return M(e)?e:void 0}function W(e){return Array.isArray(e)?e.filter(M):[]}function ht(e){return M(e)?[e]:W(e)}function no(e){return typeof e==="string"||typeof e==="number"||typeof e==="boolean"}function cn(e){let t={};if(!M(e))return t;for(let[n,r]of Object.entries(e))if(no(r))t[n]=String(r);return t}class Pe{data={};subscribers=new Map;globalSubscribers=new Set;generation=0;constructor(e){if(e)this.data=structuredClone(e)}get(e){return ro(this.data,e)}getAll(){return this.data}set(e,t){dn(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))dn(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 ro(e,t){let n=t.split("."),r=e;for(let o of n){if(r==null||typeof r!=="object")return;r=Reflect.get(r,o)}return r}var oo=new Set(["__proto__","constructor","prototype"]);function dn(e,t,n){let r=t.split(".");if(r.some((i)=>oo.has(i))){S.warn(`Blocked prototype pollution attempt: ${t}`);return}let o=e;for(let i=0;i<r.length-1;i++){let s=r[i],a=o[s];if(M(a))o=a;else{let l={};o[s]=l,o=l}}o[r[r.length-1]]=n}function pn(e){return typeof e==="function"}var ke=new Map;function gt(e,t){if(ke.has(e)&&ke.get(e)!==t)S.warn(`pipe "${e}" re-registered`);ke.set(e,t)}function bt(e){return ke.delete(e)}function un(){return[...ke.keys()]}function ze(e){return ke.get(e)}function T(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(T).join(", ");try{return JSON.stringify(e)??""}catch{return""}}function yt(e,t){let n=e instanceof Date?e:typeof e==="string"||typeof e==="number"?new Date(e):void 0;return n&&!Number.isNaN(n.getTime())?t(n):e}var fn=-1,Ct=new Map,io=/\{\{\s*(.+?)\s*\}\}/g;function q(e){return typeof e==="string"&&e.includes("{{")&&e.includes("}}")}function U(e,t,n){let r=e.trim();if(r.startsWith("{{")&&r.endsWith("}}")&&fo(r,"{{")===1){let o=r.slice(2,-2).trim();return mn(o,t,n)}return e.replace(io,(o,i)=>{let s=mn(i.trim(),t,n);return T(s)})}function mn(e,t,n){let[r,...o]=uo(e),i=G(r.trim(),t,n);for(let s of o)i=so(s.trim(),i,t,n);return i}function G(e,t,n){let r=co(e);if(r>=0){let s=e.slice(0,r).trim(),a=e.slice(r+1),l=po(a);if(l>=0){let c=a.slice(0,l).trim(),d=a.slice(l+1).trim(),u=G(s,t,n);return u!==null&&u!==void 0&&u!==!1&&u!==0&&u!==""?G(c,t,n):G(d,t,n)}}let o=Je(e,"||");if(o>=0){let s=G(e.slice(0,o).trim(),t,n);return s!==null&&s!==void 0&&s!==!1&&s!==0&&s!==""?s:G(e.slice(o+2).trim(),t,n)}let i=Je(e,"&&");if(i>=0){let s=G(e.slice(0,i).trim(),t,n);if(s===null||s===void 0||s===!1||s===0||s==="")return s;return G(e.slice(i+2).trim(),t,n)}for(let[s,a]of ao){let l=Je(e,s);if(l>=0){let c=G(e.slice(0,l).trim(),t,n),d=G(e.slice(l+s.length).trim(),t,n);return a(c,d)}}if(e.startsWith("!")){let s=G(e.slice(1).trim(),t,n);return s===null||s===void 0||s===!1||s===0||s===""}for(let[s,a]of lo){let l=Je(e,s);if(l>=0){let c=G(e.slice(0,l).trim(),t,n),d=G(e.slice(l+s.length).trim(),t,n);return a(Number(c),Number(d))}}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),c=n[a];return Ke(c,l)}return n[e]}if(n){let s=e.split(".")[0];if(s in n)return Ke(n[s],e.includes(".")?e.slice(s.length+1):"")}return t.get(e)}var gn=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 so(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?vt(s):void 0;switch(i){case"find":{if(!Array.isArray(t)||!s)return;let l=hn(s);if(l.length<2)return;let c=String(vt(l[0])),d=l[1].trim(),u;if(d.startsWith("'")&&d.endsWith("'")||d.startsWith('"')&&d.endsWith('"'))u=d.slice(1,-1);else if(n){if(r&&d.startsWith("$")){let g=d.indexOf(".");if(g>=0){let y=d.slice(0,g);if(y in r)u=Ke(r[y],d.slice(g+1))}else if(d in r)u=r[d]}if(u===void 0&&!(r&&d.startsWith("$")))if(r){let g=d.split(".")[0];u=g in r?Ke(r[g],d.includes(".")?d.slice(g.length+1):""):n.get(d)}else u=n.get(d)}else u=d;if(u==null)return;let h=n?.generation??0;if(h!==fn)Ct=new Map,fn=h;let m=Ct.get(t);if(!m)m=new Map,Ct.set(t,m);let v=m.get(c);if(!v){v=new Map;for(let g of t)if(M(g)){let y=g[c];if(y!=null)v.set(T(y),g)}m.set(c,v)}return v.get(T(u))}case"dot":{if(t==null||typeof t!=="object"||typeof a!=="string")return;return Reflect.get(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":return yt(t,(l)=>l.toLocaleDateString());case"time":return yt(t,(l)=>l.toLocaleTimeString());case"datetime":return yt(t,(l)=>l.toLocaleString());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)=>M(l)&&Boolean(l[a])):t;case"rejectattr":return Array.isArray(t)&&typeof a==="string"?t.filter((l)=>{if(!M(l))return!1;let c=l[a];return c==null||c===!1||c===0||c===""}):t;default:{let l=ze(i);if(l){let c=s?hn(s).map(vt):[];return l(t,...c)}return t}}}var ao=[["!==",(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)]],lo=[[" + ",(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 Je(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 co(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 po(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 uo(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 vt(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 hn(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 Ke(e,t){if(!t)return e;let n=t.split("."),r=e;for(let o of n){if(!M(r)&&!Array.isArray(r))return;r=Reflect.get(r,o)}return r}function fo(e,t){let n=0,r=0;while((r=e.indexOf(t,r))!==-1)n++,r+=t.length;return n}function We(e){return e.replace(/_([a-z])/g,(t,n)=>n.toUpperCase())}function xt(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:We(n);if(Array.isArray(r))t[o]=r.map((i)=>M(i)?xt(i):i);else if(M(r))t[o]=xt(r);else t[o]=r}return t}async function I(e,t){for(let n of ht(e))await mo(n,t)}function j(e,t){e.catch((n)=>S.error(`${t} failed:`,n))}async function Ge(e,t,n,r){if(n!=null)S.debug(`${e} failed:`,t),await Oe(n,r,{$error:t});else S.warn(`${e} failed:`,t)}async function mo(e,t){let n=xt(e);switch(b(n.action)){case"setState":{ho(n,t);return}case"toggleState":{go(n,t);return}case"appendState":{bo(n,t);return}case"popState":{yo(n,t);return}case"showToast":{Co(n,t);return}case"closeOverlay":{vo(n,t);return}case"openLink":{xo(n);return}case"setInterval":{ko(n,t);return}case"toolCall":case"callTool":return Mo(n,t);case"sendMessage":return Ro(n,t);case"updateContext":{Eo(n,t);return}case"fetch":return To(n,t);case"openFilePicker":{Ao(n,t);return}case"callHandler":return So(n,t);case"requestDisplayMode":{Lo(n,t);return}case"subscribe":{Po(n,t);return}case"unsubscribe":{Oo(n);return}default:S.warn(`Unknown action: ${T(n.action)}`)}}function Xe(e,t){let n=b(e.key);if(n===void 0)S.warn(`${t}: missing key`);return n}function ho(e,t){let n=Xe(e,"setState");if(n===void 0)return;let r=e.value;if(q(r))r=U(r,t.store,t.scope);t.store.set(n,r),t.rerender(),Oe(e.onSuccess,t)}function go(e,t){let n=Xe(e,"toggleState");if(n===void 0)return;t.store.toggle(n),t.rerender()}function bo(e,t){let n=Xe(e,"appendState");if(n===void 0)return;let r=e.value??e.item;if(q(r))r=U(r,t.store,t.scope);t.store.append(n,r,O(e.index)),t.rerender()}function yo(e,t){let n=Xe(e,"popState");if(n===void 0)return;let r=q(e.index)?U(e.index,t.store,t.scope):e.index;if(typeof r!=="number"&&typeof r!=="string"){S.warn("popState: missing index");return}t.store.pop(n,r),t.rerender()}function Co(e,t){t.onToast?.({message:Ue(e.message,t),description:e.description!=null?Ue(e.description,t):void 0,variant:b(e.variant),duration:O(e.duration)})}function vo(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:close-overlay"))}function xo(e){if(typeof window<"u"){let t=b(e.url);if(!t){S.warn("openLink: missing url");return}if(!Mn(t)){S.warn(`Blocked unsafe URL scheme: ${t}`);return}window.open(t,b(e.target)??"_blank")}}var qe=new Set,wo=20,wt=100;function ko(e,t){let n=Math.max(O(e.intervalMs)??wt,wt),r=ht(e.onTick);if(typeof globalThis.setInterval!=="function")return;if(r.length===0){S.warn("setInterval: missing onTick");return}if(qe.size>=wo){S.warn("Max intervals reached, ignoring new setInterval");return}let o=globalThis.setInterval(()=>j(I(r,t),"interval action"),n);qe.add(o)}function bn(){for(let e of qe)globalThis.clearInterval(e);qe.clear()}async function yn(e,t,n){let r=b(e.resultKey);if(r!==void 0)n.store.set(r,t);let o=wn(t);if(o&&n.remount)n.remount(o);else kn(t,n),n.rerender();await Oe(e.onSuccess,n,{$result:t})}async function Cn(e,t,n,r,o){let i=Rn(P(n.arguments),r);try{if(t===void 0)throw Error(`${e}: missing tool name`);let s=await o.callTool(t,i);await yn(n,s,r)}catch(s){await Ge(e,s,n.onError,r)}}async function Mo(e,t){if(!t.transport){S.warn("No MCP transport configured for toolCall");return}await Cn("toolCall",b(e.tool),e,t,t.transport)}async function Ro(e,t){if(!t.transport){S.warn("No MCP transport configured for sendMessage");return}await t.transport.sendMessage(Ue(e.message,t))}function Eo(e,t){let n=P(e.context);if(n!=null)t.store.merge(n),t.rerender()}async function To(e,t){let n=Ue(e.url,t);if(!Mn(n)){S.warn(`Blocked unsafe URL in fetch: ${n}`);return}let r=b(e.method)??"GET",o=cn(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());await yn(e,a,t)}catch(s){await Ge("fetch",s,e.onError,t)}}function Ao(e,t){if(typeof document>"u")return;let n=document.createElement("input");n.type="file";let r=b(e.accept);if(r!==void 0)n.accept=r;if(e.multiple===!0)n.multiple=!0;n.addEventListener("change",()=>{let o=Array.from(n.files??[]),i=b(e.resultKey);if(i!==void 0)t.store.set(i,o);t.rerender(),Oe(e.onSuccess,t,{$result:o})}),n.click()}async function So(e,t){let n=b(e.handler);if(!t.transport){S.warn(`No transport configured for callHandler: ${n??""}`);return}await Cn("callHandler",n,e,t,t.transport)}function Lo(e,t){if(typeof document<"u")document.dispatchEvent(new CustomEvent("prefab:request-display-mode",{detail:{mode:e.mode}}))}var Y=new Map,No=50,Ho=2000;function Po(e,t){let n=b(e.uri),r=b(e.stateKey);if(!n||!r){S.warn("subscribe: missing uri or stateKey");return}if(Y.has(n))return;if(Y.size>=No){S.warn("Max subscriptions reached, ignoring new subscribe");return}let o=(u)=>{let h=wn(u);if(h&&t.remount)t.remount(h);else{if(!kn(u,t))t.store.set(r,u);t.rerender()}Oe(e.onData,t,{$data:u})};if(e.push!==!1&&t.transport?.subscribe&&t.transport.capabilities?.subscriptions){let u=t.transport.subscribe(n,o,(h)=>{if(Y.get(n)===u)Y.delete(n);Ge("subscribe",h,e.onError,t)});Y.set(n,u);return}let i=b(e.fallbackTool),s=O(e.fallbackInterval)??Ho;if(!i){S.warn("subscribe: host lacks subscriptions and no fallbackTool specified");return}if(!t.transport){S.warn("No MCP transport configured for subscribe fallback");return}let a=P(e.fallbackArgs)??{},l=Math.max(s,wt),c=t.transport,d=globalThis.setInterval(()=>{(async()=>{try{let u=Rn(a,t),h=await c.callTool(i,u);o(h)}catch(u){Ge("subscribe",u,e.onError,t)}})()},l);Y.set(n,()=>globalThis.clearInterval(d))}function Oo(e){let t=b(e.uri);if(!t){S.warn("unsubscribe: missing uri");return}let n=Y.get(t);if(n)n(),Y.delete(t)}function vn(){for(let[e,t]of Y)try{t()}catch(n){S.warn(`Error cleaning up subscription '${e}':`,n)}Y.clear()}function Do(e){try{return JSON.parse(e)}catch{return}}function xn(e,t){if(!M(e))return null;if(t(e))return e;let n=e.structuredContent;if(M(n)&&t(n))return n;for(let r of W(e.content)){if(r.type!=="text"||typeof r.text!=="string")continue;let o=Do(r.text);if(M(o)&&t(o))return o}return null}function $o(e){return"$prefab"in e&&"view"in e}function Fo(e){return"$prefab"in e&&M(e.update)&&"state"in e.update}function wn(e){return xn(e,$o)}function kn(e,t){let n=xn(e,Fo);if(!n)return!1;let{update:r}=n,o=P(r.state);if(o)t.store.merge(o);if(r.actions!=null)j(I(r.actions,t),"update action");return!0}var Io=/^\s*(javascript|vbscript|data):/i;function Mn(e){return!Io.test(e)}function Ue(e,t){if(q(e)){let n=U(e,t.store,t.scope);return T(n)}return T(e)}function Rn(e,t){if(!e)return{};let n={};for(let[r,o]of Object.entries(e))n[r]=q(o)?U(o,t.store,t.scope):o;return n}async function Oe(e,t,n){if(e==null)return;let r={...t.scope,...n};await I(e,{...t,scope:r})}function Ze(e,t){return e===void 0||t(e)}function kt(e){return M(e)||Array.isArray(e)&&e.every(M)}function Me(e){return M(e)&&typeof e.type==="string"&&Ze(e.id,(t)=>typeof t==="string")&&Ze(e.cssClass,(t)=>typeof t==="string")&&Ze(e.onMount,kt)&&Ze(e.children,(t)=>Array.isArray(t)&&t.every(Me))}function me(e){return Array.isArray(e)?e.filter(Me):[]}function Rt(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.startsWith("$")?n:We(n);if(Array.isArray(r))t[o]=r.map((i)=>M(i)?Rt(i):i);else if(M(r))t[o]=Rt(r);else t[o]=r}return t}function jo(e){let{id:t,cssClass:n,onMount:r,children:o,...i}=Rt(e),s={...i,type:e.type};if(typeof t==="string")s.id=t;if(typeof n==="string")s.cssClass=n;if(kt(r))s.onMount=r;if(Array.isArray(o))s.children=me(o);return s}class Et{callbacks=[];track(e){this.callbacks.push(e)}flush(){for(let e of this.callbacks)try{e()}catch(t){S.warn("destroy callback error:",t)}this.callbacks=[]}get size(){return this.callbacks.length}}function Vo(e){return typeof e==="object"&&"element"in e}var Ye=new Map;function p(e,t){if(Ye.has(e))S.warn(`overriding existing renderer for "${e}"`);Ye.set(e,t)}function Tt(){return[...Ye.keys()].sort()}var En=new Set;function An(e){En.clear();for(let t of e)En.add(t)}function B(e,t){let n=jo(e);if(t.defs?.[n.type]){let i={...t.defs[n.type],...n,type:t.defs[n.type].type};return B(i,t)}let r=Ye.get(n.type),o;if(r){let i=r(n,t);if(Vo(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(B(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",()=>{j(I(n.onClick,z(t)),"onClick")}),o.tagName!=="BUTTON"&&o.tagName!=="A")o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.addEventListener("keydown",(i)=>{if(i.key==="Enter"||i.key===" ")i.preventDefault(),j(I(n.onClick,z(t)),"onClick")})}}if(n.onMount){let i=n.onMount,s=z(t);queueMicrotask(()=>j(I(i,s),"onMount"))}return o}function L(e,t,n){if(!e.children)return;he(e.children,t,n)}function he(e,t,n){let r=0;while(r<e.length){let o=e[r];if(o.type==="If")r=Bo(e,r,t,n);else if(o.type==="Elif"||o.type==="Else")r++;else t.appendChild(B(o,n)),r++}}function Bo(e,t,n,r){let o=!1,i=t,s=e[i];if(Tn(b(s.condition)??"",r))Mt(s,n,r),o=!0;i++;while(i<e.length){let a=e[i];if(a.type==="Elif"){if(!o&&Tn(b(a.condition)??"",r))Mt(a,n,r),o=!0;i++}else if(a.type==="Else"){if(!o)Mt(a,n,r);i++;break}else break}return i}function Tn(e,t){if(!e)return!1;if(q(e))return Boolean(U(e,t.store,t.scope));return Boolean(t.store.get(e))}function Mt(e,t,n){if(!e.children)return;he(e.children,t,n)}function C(e,t){if(q(e)){let n=U(e,t.store,t.scope);return T(n)}return T(e)}function J(e,t){if(q(e))return U(e,t.store,t.scope);return e}function z(e){return{store:e.store,transport:e.transport,scope:e.scope,rerender:e.rerender,onToast:e.onToast,remount:e.remount}}function f(e,t){let n=document.createElement(e);if(t)n.className=t;return n}function At(e,t){return e.textContent=t,e}function Dn(){p("Column",_o),p("Row",zo),p("Grid",Sn),p("GridItem",Nn),p("Container",Jo),p("Div",Hn),p("Span",Ko),p("Dashboard",Sn),p("DashboardItem",Nn),p("Pages",Wo),p("Page",Hn),p("Detail",Go),p("MasterDetail",qo)}function _o(e,t){let n=f("div","pf-column");n.style.display="flex",n.style.flexDirection="column";let r=Qe(e);if(r!=null)n.style.gap=`${r*4}px`;return $n(n,e),L(e,n,t),n}function zo(e,t){let n=f("div","pf-row");n.style.display="flex",n.style.flexDirection="row";let r=Qe(e);if(r!=null)n.style.gap=`${r*4}px`;if($n(n,e),e.wrap===!0)n.style.flexWrap="wrap";return L(e,n,t),n}function Sn(e,t){let n=f("div","pf-grid");n.style.display="grid",n.style.gridTemplateColumns=`repeat(${Zo(e.columns)}, minmax(0, 1fr))`;let r=Qe(e);if(r!=null)n.style.gap=`${r*4}px`;let o=O(e.rowHeight);if(o!=null)n.style.gridAutoRows=`minmax(${o}px, auto)`;return L(e,n,t),n}function Ln(e,t){if(e!=null)return t!=null?`${e} / span ${t}`:String(e);return t!=null?`span ${t}`:void 0}function Nn(e,t){let n=f("div","pf-grid-item"),r=Ln(O(e.col),O(e.colSpan)),o=Ln(O(e.row),O(e.rowSpan));if(r!=null)n.style.gridColumn=r;if(o!=null)n.style.gridRow=o;return L(e,n,t),n}function Jo(e,t){let n=f("div","pf-container");n.style.maxWidth=b(e.maxWidth)??"1200px",n.style.margin="0 auto";let r=O(e.padding);if(r!=null)n.style.padding=`${r*4}px`;return L(e,n,t),n}function Hn(e,t){let n=f("div","pf-div");return L(e,n,t),n}function Ko(e,t){let n=f("span","pf-span");return L(e,n,t),n}function Pn(e){return b(e.name)??b(e.value)??b(e.title)}function Wo(e,t){let n=f("div","pf-pages"),r=e.children??[],o=b(e.name),i=o!=null?t.store.get(o):void 0,s=typeof i==="string"?i:b(e.value),a=r.find((l)=>s!=null&&Pn(l)===s)??r.at(0);if(a!=null)n.setAttribute("data-page",Pn(a)??""),n.appendChild(B(a,t));return n}function Go(e,t){let n=f("div","pf-detail"),r=e.of!=null?J(e.of,t):void 0;if(r!=null&&r!==""&&r!==!1&&r!==0)L(e,n,t);else if(Me(e.empty))n.appendChild(B(e.empty,t));return n}function qo(e,t){let n=f("div","pf-master-detail"),r=Qe(e);if(r!=null)n.style.gap=`${r*4}px`;let o=b(e.masterWidth)??"33%",i=e.children??[];if(i.length>0){let s=f("div","pf-master-detail-master");s.style.width=o,s.appendChild(B(i[0],t)),n.appendChild(s)}if(i.length>1){let s=f("div","pf-master-detail-detail");s.appendChild(B(i[1],t)),n.appendChild(s)}return n}var Uo=/\bgap-(\d+)\b/;function Qe(e){let t=O(e.gap);if(t!=null)return t;if(typeof e.cssClass==="string"){let n=Uo.exec(e.cssClass);if(n)return Number(n[1])}return null}var Xo=["default","base","xs","sm","md","lg","xl","2xl"],On=3;function Zo(e){if(typeof e==="number")return e;if(!M(e))return On;let t=Xo.map((n)=>e[n]).filter((n)=>typeof n==="number");return t.length>0?t[t.length-1]:On}function $n(e,t){let n=b(t.align),r=b(t.justify);if(n!=null)e.style.alignItems=Yo(n);if(r!=null)e.style.justifyContent=Qo(r)}function Yo(e){return{start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"}[e]??e}function Qo(e){return{start:"flex-start",end:"flex-end",center:"center",between:"space-between",around:"space-around",evenly:"space-evenly"}[e]??e}var ei={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function Q(e){return e.replace(/[&<>"']/g,(t)=>ei[t]??t)}function In(){p("Heading",ti),p("H1",(e,t)=>et(e,t,"h1")),p("H2",(e,t)=>et(e,t,"h2")),p("H3",(e,t)=>et(e,t,"h3")),p("H4",(e,t)=>et(e,t,"h4")),p("Text",ni),p("P",ri),p("Lead",(e,t)=>Re(e,t,"p","pf-lead")),p("Large",(e,t)=>Re(e,t,"span","pf-large")),p("Small",(e,t)=>Re(e,t,"small","pf-small")),p("Muted",(e,t)=>Re(e,t,"p","pf-muted")),p("BlockQuote",(e,t)=>Re(e,t,"blockquote","pf-blockquote")),p("Label",(e,t)=>Re(e,t,"label","pf-label")),p("Link",ii),p("Code",si),p("Markdown",ai),p("Kbd",li)}function ti(e,t){let n=O(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 et(e,t,n){let r=document.createElement(n);return r.className=`pf-heading pf-${n}`,r.textContent=C(e.content,t),r}function ni(e,t){return At(f("span","pf-text"),C(e.content,t))}function ri(e,t){return At(f("p","pf-p"),C(e.content,t))}function Re(e,t,n,r){let o=document.createElement(n);return o.className=r,o.textContent=C(e.content,t),o}var oi=/^\s*(javascript|vbscript|data):/i;function ii(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(!oi.test(r))n.href=r}if(e.target!=null)n.target=C(e.target,t);return n}function si(e,t){let n=f("pre","pf-code"),r=f("code");if(r.textContent=C(e.content,t),e.language!=null)r.setAttribute("data-language",T(e.language));return n.appendChild(r),n}function ai(e,t){let n=f("div","pf-markdown"),r=C(e.content,t);return n.innerHTML=jn(r),n.setAttribute("data-markdown","true"),n}var Fn=/^\s*(javascript|vbscript|data):/i;function tt(e){let t=Q(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(Fn.test(i))return Q(o);return`<img src="${i}" alt="${o}" />`}),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,o,i)=>{if(Fn.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 jn(e){let t=e.replace(/\r\n?/g,`
2
2
  `).split(`
3
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(Q(t[r])),r++;r++;let c=a?` data-language="${Q(a)}"`:"";n.push(`<pre class="pf-code"><code${c}>${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}>${Xe(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>${Hn(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>${Xe(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>${Xe(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(Xe).join("<br />")}</p>`)}return n.join(`
6
- `)}function Xo(e,t){let n=document.createElement("kbd");return n.className="pf-kbd",n.textContent=v(e.content,t),n}function On(){p("Card",Yo),p("CardHeader",Rt("pf-card-header")),p("CardTitle",Pn("pf-card-title","h3")),p("CardDescription",Pn("pf-card-description","p")),p("CardContent",Rt("pf-card-content")),p("CardFooter",Rt("pf-card-footer"))}function Yo(e,t){let n=m("div","pf-card");return M(e,n,t),n}function Rt(e){return(t,n)=>{let r=m("div",e);return M(t,r,n),r}}function Pn(e,t){return(n,r)=>{let o=document.createElement(t);return o.className=e,o.textContent=v(n.content,r),o}}var _=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],X="var(--muted-foreground, #6b7280)",ge="var(--border, #e5e7eb)",le="11";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 Zo(e,t){let n=e/t,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r;return(o<=1.5?1:o<=3?2:o<=7?5:10)*r}function Dn(e,t=5){if(e<=0)return[0];return Ze(0,e,t)}function Ze(e,t,n=4){let r=t>e?t:e+1,o=Zo(r-e,n),i=Math.floor(e/o)*o,s=[];for(let a=i;a<=r+o*0.01||s.length<2;a+=o)s.push(Math.round(a*1000)/1000);return s}function $n(e,t,n,r,o){let i=Dn(n);for(let s of i){let a=t.plotBottom-(n>0?s/n*t.plotHeight:0),l=N("text",{x:t.plotLeft-6,y:a+3,"text-anchor":"end","font-size":le,fill:X});if(l.textContent=St(s,o),e.appendChild(l),r&&s>0)e.appendChild(N("line",{x1:t.plotLeft,y1:a,x2:t.plotRight,y2:a,stroke:ge,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function In(e,t,n,r){let o=Dn(n);for(let i of o){let s=t.plotBottom-(n>0?i/n*t.plotHeight:0),a=N("text",{x:t.plotRight+6,y:s+3,"text-anchor":"start","font-size":le,fill:X});a.textContent=St(i,r),e.appendChild(a)}}function Tt(e,t,n,r,o,i){for(let s=0;s<t.length;s++){let a=t[s][n],l=N("text",{x:r(s),y:o+14,"text-anchor":"middle","font-size":le,fill:X});l.textContent=a==null?"":i?i(a):E(a),e.appendChild(l)}}function Qe(e,t){e.appendChild(N("line",{x1:t.plotLeft,y1:t.plotBottom,x2:t.plotRight,y2:t.plotBottom,stroke:X,"stroke-width":1}))}function Te(e,t,n){if(e==null)return"";let r=K(`{{ __v | ${t} }}`,{...n,scope:{...n.scope,__v:e}});return E(r??e)}function St(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=b(e.yAxisFormat)??b(e.valueFormat);return t&&t!=="auto"?t:void 0}function Se(e,t,n=String){let r=Oe(e);return(o)=>r?Te(o,r,t):n(o)}function At(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 St(Number(r),i)}}function re(e,t,n){return N("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,role:"img",...n?{"aria-label":`${n} chart`}:{}})}var ae=400,Qo=160;function Ae(e){return(t,n)=>{let r=e(t,n,ae);if(typeof ResizeObserver>"u")return r;let o=ae,i=new ResizeObserver((s)=>{let a=Math.floor(s[0]?.contentRect.width??0);if(a<Qo||Math.abs(a-o)<1||!r.isConnected)return;o=a;let l=e(t,n,a);i.unobserve(r),r.replaceWith(l),r=l,i.observe(r)});return i.observe(r),{element:r,destroy:()=>{i.disconnect()}}}}function N(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 De(e,t){let n=N("text",e);return n.textContent=t,n}function he(e,t,n,r){let o=r*Math.PI/180;return{x:e+n*Math.cos(o),y:t-n*Math.sin(o)}}function Mt(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=he(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 oe(e,t,n){if(!n||t.length<=1)return;let r=m("div","pf-chart-legend");for(let o=0;o<t.length;o++){let i=m("div","pf-chart-legend-item"),s=m("span","pf-chart-legend-dot");s.style.backgroundColor=t[o].color??_[o%_.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 jn(){p("DataTable",ei),p("Badge",ti),p("Dot",ni),p("Metric",ri),p("Ring",oi),p("Progress",ii),p("Separator",si),p("Loader",ai),p("Icon",li),p("Sparkline",ci)}function ei(e,t){let n=m("div","pf-datatable-wrapper"),r=document.createElement("table");r.className="pf-datatable";let o=z(e.columns).map((u)=>({key:E(u.key),header:u.header!=null?E(u.header):void 0,format:b(u.format),accessor:b(u.accessor)})),i=K(e.rows,t),s=b(e.rowKey),a=b(e.selected),l=document.createElement("thead"),c=document.createElement("tr");for(let u of o){let g=document.createElement("th");g.className="pf-datatable-th",g.setAttribute("scope","col"),g.textContent=u.header??u.key,c.appendChild(g)}l.appendChild(c),r.appendChild(l);let d=document.createElement("tbody");if(Array.isArray(i)){let u=a!=null?K(a,t):void 0;for(let g of i){let y=document.createElement("tr");y.className="pf-datatable-row";let h=g,C=k(h)?h:{},T=g===null||typeof g!=="object";if(s&&u!=null&&C[s]!=null&&E(C[s])===E(u))y.classList.add("pf-datatable-row-selected");if(e.onRowClick!=null&&s)y.classList.add("pf-datatable-row-clickable"),y.addEventListener("click",()=>{let w={...t.scope,$item:h,$index:i.indexOf(g)},R=J({...t,scope:w});j(I(e.onRowClick,R),"onRowClick")});for(let w of o){let R=document.createElement("td");R.className="pf-datatable-td";let x;if(w.accessor)x=K(`{{ $item.${w.accessor} }}`,{...t,scope:{...t.scope,$item:h}});else if(x=T?g:C[w.key],w.format&&x!=null)x=K(`{{ __fmtVal | ${w.format} }}`,{...t,scope:{...t.scope,__fmtVal:x}});R.textContent=E(x),y.appendChild(R)}d.appendChild(y)}}if(!Array.isArray(i)||i.length===0){let u=document.createElement("tr"),g=document.createElement("td");g.className="pf-datatable-empty",g.colSpan=Math.max(1,o.length),g.textContent="No results",u.appendChild(g),d.appendChild(u)}if(r.appendChild(d),e.search===!0){let u=document.createElement("input");u.type="text",u.placeholder="Search...",u.className="pf-datatable-search",u.setAttribute("aria-label","Search table"),u.addEventListener("input",()=>{let g=u.value.toLowerCase();for(let y of d.querySelectorAll("tr.pf-datatable-row"))y.style.display=y.textContent.toLowerCase().includes(g)?"":"none"}),n.appendChild(u)}let f=m("div","pf-datatable-scroll");return f.appendChild(r),n.appendChild(f),n}function ti(e,t){let n=m("span","pf-badge"),r=b(e.variant)??"default";return n.setAttribute("data-variant",r),n.textContent=v(e.label??e.content,t),n}function ni(e,t){let n=m("span","pf-dot"),r=b(e.color);if(r!=null)n.style.backgroundColor=r;return n}function ri(e,t){let n=m("div","pf-metric"),r=m("div","pf-metric-label");r.textContent=v(e.label,t),n.appendChild(r);let o=m("div","pf-metric-row"),i=m("div","pf-metric-value");if(i.textContent=v(e.value,t),o.appendChild(i),e.delta!=null){let s=m("span","pf-metric-delta"),a=b(e.trend),l=a==="up"?"↑ ":a==="down"?"↓ ":"";s.textContent=l+v(e.delta,t),s.setAttribute("data-sentiment",b(e.trendSentiment)??"neutral"),o.appendChild(s)}if(n.appendChild(o),e.description!=null){let s=m("div","pf-metric-desc");s.textContent=v(e.description,t),n.appendChild(s)}return n}function oi(e,t){let n=m("div","pf-ring");n.setAttribute("data-variant",b(e.variant)??"default");let r=D(e.size)??80,o=D(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,c=l*(1-s/100),d=N("svg",{width:r,height:r,viewBox:`0 0 ${r} ${r}`}),f={cx:r/2,cy:r/2,r:a,fill:"none","stroke-width":o},u=N("circle",{...f,class:"pf-ring-track",stroke:"var(--muted, #e5e7eb)"}),g=N("circle",{...f,class:"pf-ring-fill",stroke:"var(--primary, #3b82f6)","stroke-dasharray":l,"stroke-dashoffset":c,"stroke-linecap":"round"});if(d.appendChild(u),d.appendChild(g),n.appendChild(d),n.setAttribute("role","img"),n.setAttribute("aria-label",`${String(s)}%`),e.label!=null){let y=m("div","pf-ring-label");y.textContent=v(e.label,t),n.appendChild(y)}return n}function ii(e,t){let n=m("div","pf-progress");n.setAttribute("role","progressbar"),n.setAttribute("data-variant",b(e.variant)??"default");let r=Number(K(e.value,t)??0),o=D(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));let s=m("div","pf-progress-fill");return s.style.width=`${i}%`,n.appendChild(s),n}function si(e,t){let n=document.createElement("hr");if(n.className="pf-separator",e.orientation==="vertical")n.setAttribute("data-orientation","vertical"),n.setAttribute("aria-orientation","vertical");return n}function ai(e,t){let n=m("div","pf-loader");return n.setAttribute("role","status"),n.setAttribute("aria-label","Loading"),n}function li(e,t){let n=m("span","pf-icon");return n.setAttribute("data-icon",v(e.name??e.content,t)),n}function ci(e,t){let n=m("div","pf-sparkline"),r=Array.isArray(e.data)?e.data.filter((u)=>typeof u==="number"&&Number.isFinite(u)):[];if(r.length===0)return n;let o=D(e.width)??120,i=D(e.height)??32,s=Math.max(...r),a=Math.min(...r),l=s-a||1,c=N("svg",{width:o,height:i,viewBox:`0 0 ${o} ${i}`}),d=r.length>1?r.length-1:1,f=r.map((u,g)=>{let y=g/d*o,h=i-(u-a)/l*(i-4)-2;return`${y},${h}`}).join(" ");return c.appendChild(N("polyline",{points:f,fill:"none",stroke:"var(--primary, #3b82f6)","stroke-width":1.5})),n.appendChild(c),n}function Jn(){p("Form",di),p("Input",pi),p("Textarea",be(ui)),p("Button",fi),p("ButtonGroup",Me("pf-button-group")),p("Checkbox",Vn("pf-checkbox")),p("Switch",Vn("pf-switch")),p("Slider",be(mi)),p("Calendar",be(_n("pf-calendar"))),p("DatePicker",be(_n("pf-datepicker"))),p("Field",Me("pf-field")),p("FieldTitle",Ne("pf-field-title")),p("FieldDescription",Ne("pf-field-description")),p("FieldContent",Me("pf-field-content")),p("FieldError",Ne("pf-field-error"))}function di(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),c=l instanceof HTMLSelectElement&&l.multiple||a.length>1;i[s]=c?a:a[0]}if(t.store.merge(i),e.onSubmit!=null){let s=J(t);s.scope={...t.scope,...i},j(I(e.onSubmit,s),"onSubmit")}}),M(e,n,t),n}var Fn=0;function ce(e,t){return Fn+=1,`pf-${e}-${t??"field"}-${String(Fn)}`}function Kn(e,t,n){if(t.label==null)return;let r=document.createElement("label");r.className="pf-input-label",r.textContent=v(t.label,n);let o=e.querySelector("input, select, textarea");if(o){if(!o.id)o.id=ce("control",b(t.name));r.htmlFor=o.id}if(t.required===!0)r.setAttribute("data-required","");e.insertBefore(r,e.firstChild)}function Wn(e,t,n){if(t.error==null||t.error===!1||t.error==="")return;let r=e.querySelector("input, select, textarea");if(r?.setAttribute("aria-invalid","true"),t.error===!0)return;let o=m("p","pf-field-error");o.id=ce("error",b(t.name)),o.textContent=v(t.error,n),r?.setAttribute("aria-describedby",o.id),e.appendChild(o)}function be(e){return(t,n)=>{let r=e(t,n);return r.classList.add("pf-labeled"),Kn(r,t,n),Wn(r,t,n),r}}function ye(e,t){if(t.required!==!0)return;if(e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)e.required=!0;e.setAttribute("aria-required","true")}function Nt(e,t,n,r="input",o=()=>e.value){let i=b(t.name)??(e.name||void 0);if(!i)return;let s=n.store.get(i);if(s!=null)e.value=E(s);e.addEventListener(r,()=>{let a=o();if(n.store.set(i,a),t.onChange!=null)j(I(t.onChange,{...J(n),scope:{...n.scope,$event:a}}),"onChange")})}function pi(e,t){let n=m("div","pf-input-wrapper"),r=document.createElement("input");if(r.className="pf-input",r.type=b(e.inputType)??"text",e.name!=null)r.name=E(e.name);if(r.id=ce("input",b(e.name)),e.placeholder!=null)r.placeholder=v(e.placeholder,t);if(e.disabled===!0)r.disabled=!0;return ye(r,e),Nt(r,e,t),n.appendChild(r),Kn(n,e,t),Wn(n,e,t),n}function ui(e,t){let n=m("div","pf-textarea-wrapper"),r=document.createElement("textarea");if(r.className="pf-textarea",e.name!=null)r.name=E(e.name);if(r.id=ce("textarea",b(e.name)),e.placeholder!=null)r.placeholder=v(e.placeholder,t);if(e.rows!=null)r.rows=Number(e.rows);if(e.disabled===!0)r.disabled=!0;return ye(r,e),Nt(r,e,t),n.appendChild(r),n}function fi(e,t){let n=document.createElement("button");if(n.className="pf-button",n.type=e.submit===!0?"submit":"button",n.textContent=v(e.label,t),n.setAttribute("data-variant",b(e.variant)??"default"),e.size!=null)n.setAttribute("data-size",E(e.size));if(e.disabled===!0)n.disabled=!0;return n}function Vn(e){return(t,n)=>{let r=m("label",`${e}-wrapper`),o=document.createElement("input");if(o.type="checkbox",o.className=e,e==="pf-switch")o.setAttribute("role","switch");if(t.name!=null)o.name=E(t.name);if(t.checked===!0)o.checked=!0;if(t.disabled===!0)o.disabled=!0;let i=b(t.name);if(i){let s=n.store.get(i);if(typeof s==="boolean")o.checked=s;o.addEventListener("change",()=>{if(n.store.set(i,o.checked),t.onChange!=null)j(I(t.onChange,{...J(n),scope:{...n.scope,$event:o.checked}}),"onChange")})}if(r.appendChild(o),t.label!=null){let s=m("span");s.textContent=v(t.label,n),r.appendChild(s)}return r}}function Bn(e){let t=Number(e.min||0),n=Number(e.max||100),r=n>t?(Number(e.value)-t)/(n-t)*100:0;e.style.setProperty("--pf-fill",`${String(Math.round(Math.max(0,Math.min(100,r))*100)/100)}%`)}function mi(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(e.name);if(e.min!=null)r.min=E(e.min);if(e.max!=null)r.max=E(e.max);if(e.step!=null)r.step=E(e.step);if(e.disabled===!0)r.disabled=!0;return Nt(r,e,t,"input",()=>Number(r.value)),Bn(r),r.addEventListener("input",()=>{Bn(r)}),n.appendChild(r),n}function Me(e){return(t,n)=>{let r=m("div",e);return M(t,r,n),r}}function Ne(e){return(t,n)=>{let r=m("span",e);return r.textContent=v(t.content,n),r}}function Lt(){let e=document.createElement("hr");return e.className="pf-separator",e}function _n(e){return(t,n)=>{let r=m("div",e),o=document.createElement("input");if(o.type="date",o.className="pf-input",o.name=v(t.name,n),o.id=ce("date",o.name||void 0),ye(o,t),t.placeholder!=null)o.placeholder=v(t.placeholder,n);if(t.value!==void 0)o.value=v(t.value,n);if(t.minDate!=null)o.min=v(t.minDate,n);if(t.maxDate!=null)o.max=v(t.maxDate,n);if(t.disabled===!0)o.disabled=!0;let i=n.store.get(o.name);if(i!=null)o.value=E(i);return o.addEventListener("change",()=>{if(n.store.set(o.name,o.value),t.onChange!=null)j(I(t.onChange,J(n)),"onChange")}),r.appendChild(o),r}}function zn(){p("Select",be(gi)),p("SelectOption",yi),p("SelectGroup",Me("pf-select-group")),p("SelectLabel",Ne("pf-select-label")),p("SelectSeparator",Lt),p("Radio",Ci),p("RadioGroup",vi),p("Combobox",be(xi)),p("ComboboxOption",wi),p("ComboboxGroup",Me("pf-combobox-group")),p("ComboboxLabel",Ne("pf-combobox-label")),p("ComboboxSeparator",Lt),p("ChoiceCard",ki)}function gi(e,t){let n=m("div","pf-select-wrapper"),r=document.createElement("select");if(r.className="pf-select",e.name!=null)r.name=E(e.name);if(r.id=ce("select",b(e.name)),e.multiple===!0)r.multiple=!0;if(e.disabled===!0)r.disabled=!0;if(ye(r,e),e.placeholder!=null){let i=document.createElement("option");i.value="",i.textContent=v(e.placeholder,t),i.disabled=!0,i.selected=!0,i.hidden=!0,r.appendChild(i)}for(let i of z(e.options)){let s=document.createElement("option");s.value=E(i.value),s.textContent=i.label!=null?E(i.label):s.value,r.appendChild(s)}if(e.children)for(let i of e.children)if(i.type==="SelectOption"){let s=document.createElement("option");s.value=b(i.value)??"",s.textContent=b(i.label)??s.value,r.appendChild(s)}else r.appendChild(B(i,t));let o=b(e.name);if(o){let i=t.store.get(o);if(i!=null)bi(r,i);r.addEventListener("change",()=>{let s=hi(r);if(t.store.set(o,s),e.onChange!=null)j(I(e.onChange,{...J(t),scope:{...t.scope,$event:s}}),"onChange")})}return n.appendChild(r),n}function hi(e){if(!e.multiple)return e.value;return Array.from(e.selectedOptions,(t)=>t.value)}function bi(e,t){if(!e.multiple){e.value=E(t);return}let n=new Set((Array.isArray(t)?t:[t]).map((r)=>E(r)));for(let r of e.options)r.selected=n.has(r.value)}function yi(e,t){return m("span")}function Ci(e,t){let n=m("label","pf-radio"),r=document.createElement("input");if(r.type="radio",r.className="pf-radio-input",e.disabled===!0)r.disabled=!0;if(r.value=v(e.value,t),n.appendChild(r),e.label!=null){let o=m("span","pf-radio-label");o.textContent=v(e.label,t),n.appendChild(o)}return n}function vi(e,t){let n=m("fieldset","pf-radio-group");if(ye(n,e),e.label!=null){let i=document.createElement("legend");if(i.className="pf-radio-legend",i.textContent=v(e.label,t),e.required===!0)i.setAttribute("data-required","");n.appendChild(i)}M(e,n,t);let r=v(e.name,t),o=t.store.get(r);for(let i of n.querySelectorAll('input[type="radio"]')){if(!(i instanceof HTMLInputElement))continue;if(i.name=r,o!=null&&i.value===E(o))i.checked=!0}return n.addEventListener("change",(i)=>{let s=i.target;if(s instanceof HTMLInputElement&&s.type==="radio"){if(t.store.set(r,s.value),e.onChange!=null)j(I(e.onChange,J(t)),"onChange")}}),n}function xi(e,t){let n=m("div","pf-combobox"),r=document.createElement("input");if(r.className="pf-combobox-input",r.type="text",r.name=v(e.name,t),r.id=ce("combobox",r.name||void 0),r.autocomplete="off",r.setAttribute("role","combobox"),r.setAttribute("aria-autocomplete","list"),r.setAttribute("aria-expanded","false"),ye(r,e),e.placeholder!=null)r.placeholder=v(e.placeholder,t);if(e.value!==void 0)r.value=v(e.value,t);if(e.disabled===!0)r.disabled=!0;let o=t.store.get(r.name);if(o!=null)r.value=E(o);let i=m("div","pf-combobox-dropdown");i.id=`${r.id}-list`,i.setAttribute("role","listbox"),i.style.display="none",r.setAttribute("aria-controls",i.id),M(e,i,t);let s=()=>Array.from(i.querySelectorAll(".pf-combobox-option")).filter((c)=>c.style.display!=="none"),a=(c)=>{if(i.style.display=c?"block":"none",r.setAttribute("aria-expanded",c?"true":"false"),!c)for(let d of s())d.setAttribute("aria-selected","false")},l=(c)=>{let d=s();if(d.length===0)return;let f=d.findIndex((g)=>g.getAttribute("aria-selected")==="true"),u=d[(f+c+d.length)%d.length];for(let g of d)g.setAttribute("aria-selected",g===u?"true":"false");u.scrollIntoView({block:"nearest"})};if(r.addEventListener("focus",()=>{a(!0)}),r.addEventListener("blur",()=>{setTimeout(()=>{a(!1)},150)}),r.addEventListener("keydown",(c)=>{if(c.key==="ArrowDown"||c.key==="ArrowUp")c.preventDefault(),a(!0),l(c.key==="ArrowDown"?1:-1);else if(c.key==="Enter"){let d=s().find((f)=>f.getAttribute("aria-selected")==="true");if(d)c.preventDefault(),d.dispatchEvent(new MouseEvent("mousedown")),a(!1)}else if(c.key==="Escape")a(!1)}),e.searchable!==!1)r.addEventListener("input",()=>{let c=r.value.toLowerCase();for(let d of i.querySelectorAll(".pf-combobox-option"))if(d instanceof HTMLElement)d.style.display=d.textContent.toLowerCase().includes(c)?"":"none";a(!0)});if(e.onChange!=null)n.addEventListener("pf-combobox-select",()=>{j(I(e.onChange,{...J(t),scope:{...t.scope,$event:r.value}}),"onChange")});return n.appendChild(r),n.appendChild(i),n}function wi(e,t){let n=m("div","pf-combobox-option");return n.setAttribute("role","option"),n.setAttribute("aria-selected","false"),n.textContent=v(e.label??e.value,t),n.dataset.value=v(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 ki(e,t){let n=m("div","pf-choice-card");n.dataset.value=v(e.value,t);let r=typeof e.selected==="string"?K(e.selected,t):e.selected;if(r===!0||r==="true")n.dataset.selected="true";if(e.onClick!=null)n.setAttribute("aria-pressed",n.dataset.selected==="true"?"true":"false");if(e.label!=null){let o=m("div","pf-choice-card-label");o.textContent=v(e.label,t),n.appendChild(o)}if(e.description!=null){let o=m("div","pf-choice-card-description");o.textContent=v(e.description,t),n.appendChild(o)}return M(e,n,t),n}var de=(e)=>`${e}-${Math.random().toString(36).slice(2,8)}`;function Ht(e,t){if(!Ee(e))return;let n=B(e,t);if(n instanceof HTMLElement)return n;let r=m("span","pf-trigger");return r.style.display="contents",r.appendChild(n),r}function Gn(){p("Tabs",Ei),p("Tab",Ri),p("Accordion",Ti),p("AccordionItem",Si),p("Dialog",Ai),p("Popover",Mi),p("Tooltip",Ni),p("HoverCard",Li),p("Carousel",Hi)}function Ei(e,t){let n=m("div","pf-tabs"),r=m("div","pf-tabs-bar");r.setAttribute("role","tablist");let o=[],i=[],s=e.children??[],a=(()=>{let c=e.defaultTab;if(typeof c==="number")return c>=0&&c<s.length?c:0;if(typeof c==="string"){let d=s.findIndex((f)=>f.title===c);return d>=0?d:0}return 0})();s.forEach((c,d)=>{let f=de("pf-tab"),u=de("pf-panel"),g=document.createElement("button");g.type="button",g.className="pf-tab-trigger",g.textContent=b(c.title)??`Tab ${String(d+1)}`,g.setAttribute("role","tab"),g.setAttribute("aria-controls",u),g.id=f,g.addEventListener("click",()=>{l(d,!0)});let y=m("div","pf-tab-panel");y.setAttribute("role","tabpanel"),y.setAttribute("aria-labelledby",f),y.id=u,y.tabIndex=0,M(c,y,t),i.push(g),o.push(y),r.appendChild(g)});function l(c,d){if(i.forEach((f,u)=>{let g=u===c;f.classList.toggle("pf-tab-active",g),f.setAttribute("aria-selected",g?"true":"false"),f.tabIndex=g?0:-1,o[u].style.display=g?"block":"none"}),d)i[c]?.focus()}if(i.length>0)l(a,!1);r.addEventListener("keydown",(c)=>{let d=i.findIndex((u)=>u===c.target);if(d<0)return;let f;if(c.key==="ArrowRight")f=(d+1)%i.length;else if(c.key==="ArrowLeft")f=(d-1+i.length)%i.length;else if(c.key==="Home")f=0;else if(c.key==="End")f=i.length-1;else return;c.preventDefault(),l(f,!0)}),n.appendChild(r);for(let c of o)n.appendChild(c);return n}function Ri(e,t){let n=m("div","pf-tab");return M(e,n,t),n}function Ti(e,t){let n=m("div","pf-accordion");return M(e,n,t),n}function Si(e,t){let n=m("div","pf-accordion-item"),r=document.createElement("button");r.type="button",r.className="pf-accordion-trigger",r.id=de("pf-acc-trigger"),r.textContent=b(e.title)??"",r.setAttribute("aria-expanded","false");let o=m("div","pf-accordion-content");return o.id=de("pf-acc"),o.setAttribute("role","region"),o.setAttribute("aria-labelledby",r.id),o.style.display="none",r.setAttribute("aria-controls",o.id),M(e,o,t),r.addEventListener("click",()=>{let i=o.style.display!=="none";o.style.display=i?"none":"block",r.setAttribute("aria-expanded",i?"false":"true")}),n.appendChild(r),n.appendChild(o),n}function Ai(e,t){let n=m("div","pf-dialog-wrapper"),r=document.createElement("dialog");r.className="pf-dialog",r.setAttribute("aria-modal","true");let o=e.dismissible!==!1,i=Ht(e.trigger,t);if(i)i.setAttribute("aria-haspopup","dialog"),i.addEventListener("click",()=>{r.showModal()}),n.appendChild(i);if(e.title!=null){let l=m("h2","pf-dialog-title");l.textContent=v(e.title,t),l.id=de("pf-dialog-title"),r.setAttribute("aria-labelledby",l.id),r.appendChild(l)}if(e.description!=null){let l=m("p","pf-dialog-desc");l.textContent=v(e.description,t),l.id=de("pf-dialog-desc"),r.setAttribute("aria-describedby",l.id),r.appendChild(l)}let s=m("div","pf-dialog-body");if(M(e,s,t),r.appendChild(s),o){let l=document.createElement("button");l.type="button",l.className="pf-dialog-close",l.setAttribute("aria-label","Close"),l.textContent="×",l.addEventListener("click",()=>{r.close()}),r.appendChild(l),r.addEventListener("click",(c)=>{if(c.target===r)r.close()})}else r.addEventListener("cancel",(l)=>{l.preventDefault()});let a=()=>{r.close()};return document.addEventListener("prefab:close-overlay",a),n.appendChild(r),{element:n,destroy:()=>{document.removeEventListener("prefab:close-overlay",a)}}}function Mi(e,t){let n=m("div","pf-popover"),r=m("div","pf-popover-content");if(r.id=de("pf-popover"),r.setAttribute("role","dialog"),r.style.display="none",e.title!=null){let c=m("div","pf-popover-title");c.textContent=v(e.title,t),r.appendChild(c)}M(e,r,t);let o=Ht(e.trigger,t),i=()=>r.style.display!=="none",s=(c)=>{r.style.display=c?"block":"none",o?.setAttribute("aria-expanded",c?"true":"false")};if(o)o.setAttribute("aria-haspopup","dialog"),o.setAttribute("aria-controls",r.id),o.setAttribute("aria-expanded","false"),o.addEventListener("click",(c)=>{c.stopPropagation(),s(!i())}),n.appendChild(o);else n.addEventListener("click",(c)=>{if(c.target instanceof Node&&r.contains(c.target)&&i())return;s(!i())});let a=(c)=>{if(i()&&c.target instanceof Node&&!n.contains(c.target))s(!1)},l=(c)=>{if(c.key==="Escape"&&i())s(!1)};return document.addEventListener("click",a),document.addEventListener("keydown",l),n.appendChild(r),{element:n,destroy:()=>{document.removeEventListener("click",a),document.removeEventListener("keydown",l)}}}function Ni(e,t){let n=m("div","pf-tooltip"),r=m("div","pf-tooltip-content");r.id=de("pf-tip"),r.setAttribute("role","tooltip"),r.textContent=v(e.content??"",t),r.style.display="none",M(e,n,t),n.setAttribute("aria-describedby",r.id);let o=()=>{r.style.display="block"},i=()=>{r.style.display="none"};return n.addEventListener("mouseenter",o),n.addEventListener("mouseleave",i),n.addEventListener("focus",o,!0),n.addEventListener("blur",i,!0),n.appendChild(r),n}function Li(e,t){let n=m("div","pf-hover-card"),r=m("div","pf-hover-card-content");r.style.display="none";let o=Ht(e.trigger,t);if(o)n.appendChild(o);return M(e,r,t),n.addEventListener("mouseenter",()=>{r.style.display="block"}),n.addEventListener("mouseleave",()=>{r.style.display="none"}),n.addEventListener("focusin",()=>{r.style.display="block"}),n.addEventListener("focusout",()=>{r.style.display="none"}),n.appendChild(r),n}function Hi(e,t){let n=m("div","pf-carousel");n.setAttribute("role","region"),n.setAttribute("aria-roledescription","carousel"),n.setAttribute("aria-label",v(e.label??"Carousel",t));let r=m("div","pf-carousel-track");M(e,r,t);let o=0,i=e.children?.length??0,s=(d,f,u)=>{let g=document.createElement("button");return g.type="button",g.className=d,g.textContent=f,g.setAttribute("aria-label",u),g},a=s("pf-carousel-prev","‹","Previous slide"),l=s("pf-carousel-next","›","Next slide"),c=()=>{r.style.transform=`translateX(-${String(o*100)}%)`,a.disabled=o<=0,l.disabled=o>=i-1};return a.addEventListener("click",()=>{if(i===0)return;o=Math.max(0,o-1),c()}),l.addEventListener("click",()=>{if(i===0)return;o=Math.min(i-1,o+1),c()}),c(),n.appendChild(r),n.appendChild(a),n.appendChild(l),n}function Pi(e){if(!k(e))return{};return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,fe(n)]))}function qn(){p("ForEach",Oi),p("If",Un),p("Elif",Di),p("Else",$i),p("Condition",Ii),p("Define",ji),p("Use",Fi),p("Slot",Vi)}function Oi(e,t){let n=document.createDocumentFragment(),r=b(e.expression);if(!r)return n;let o;if(q(r)){let s=U(r,t.store,t.scope);o=Array.isArray(s)?s:[]}else{let s=t.store.get(r);o=Array.isArray(s)?s:[]}let i=P(e.let)??{};for(let s=0;s<o.length;s++){let a=o[s],l={...t.scope,$item:a,$index:s,...i},c={...t,scope:l};if(e.children)me(e.children,n,c)}return n}function Un(e,t){if(Xn(b(e.condition)??"",t)){let r=document.createDocumentFragment();if(e.children)me(e.children,r,t);return r}return document.createDocumentFragment()}function Di(e,t){return Un(e,t)}function $i(e,t){let n=document.createDocumentFragment();if(e.children)me(e.children,n,t);return n}function Xn(e,t){if(!e)return!1;if(q(e))return Boolean(U(e,t.store,t.scope));return Boolean(t.store.get(e))}function Ii(e,t){let n=document.createDocumentFragment(),r=z(e.cases).find((o)=>Xn(b(o.when)??"",t));return me(fe(r?r.children:e.else),n,t),n}function ji(e,t){let n=b(e.name);if(n&&e.children)t.templates=t.templates??{},t.templates[n]=e.children;return document.createDocumentFragment()}function Fi(e,t){let n=document.createDocumentFragment(),r=b(e.def??e.name),o=r!=null?t.templates?.[r]:void 0;if(!o)return n;let i=P(e.overrides)??{},s={...t.scope,...i},a={...t.slots??{},...Pi(e.slots)};if(Array.isArray(e.children))a.default=e.children;let l={...t,scope:s,slots:a};for(let c of o)n.appendChild(B(c,l));return n}function Vi(e,t){let n=document.createDocumentFragment(),r=b(e.name)??"default",i=t.slots?.[r]??e.children;if(i)for(let s of i)n.appendChild(B(s,t));return n}function Yn(){p("Alert",Bi),p("AlertTitle",_i),p("AlertDescription",Ji)}function Bi(e,t){let n=m("div","pf-alert");n.setAttribute("role","alert");let r=b(e.variant)??"default";if(n.setAttribute("data-variant",r),e.icon!=null){let o=m("span","pf-alert-icon");o.setAttribute("data-icon",E(e.icon)),n.appendChild(o)}return M(e,n,t),n}function _i(e,t){let n=m("h5","pf-alert-title");return n.textContent=v(e.content,t),n}function Ji(e,t){let n=m("p","pf-alert-description");return n.textContent=v(e.content,t),n}function Zn(){p("Image",Ki),p("Audio",Wi),p("Video",zi),p("Embed",Gi),p("Svg",Ui),p("DropZone",Yi),p("Mermaid",Zi)}function Ki(e,t){let n=document.createElement("img");if(n.className="pf-image",n.src=v(e.src,t),e.alt!=null)n.alt=v(e.alt,t);if(e.width!=null)n.width=Number(e.width);if(e.height!=null)n.height=Number(e.height);return n.loading="lazy",n}function Wi(e,t){let n=document.createElement("audio");return n.className="pf-audio",n.src=v(e.src,t),n.controls=!0,n}function zi(e,t){let n=document.createElement("video");if(n.className="pf-video",n.src=v(e.src,t),n.controls=!0,e.width!=null)n.width=Number(e.width);if(e.height!=null)n.height=Number(e.height);return n}function Gi(e,t){let n=m("div","pf-embed"),r=document.createElement("iframe");return r.src=v(e.src,t),r.style.height=e.height!=null?`${String(Number(e.height))}px`:"400px",r.setAttribute("sandbox","allow-scripts"),n.appendChild(r),n}var qi=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 Ui(e,t){let n=m("div","pf-svg"),r=v(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 Qn(i),n.appendChild(document.importNode(i,!0)),n}function Qn(e){let t=Array.from(e.children);for(let n of t){if(!qi.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)}Qn(n)}}function Xi(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 Yi(e,t){let n=m("div","pf-dropzone");n.textContent=v(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(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)=>Xi(l,b(e.accept)));return e.multiple===!0?a:a.slice(0,1)}function i(s){if(s.length===0)return;let a=b(e.resultKey);if(a!=null)t.store.set(a,s),t.rerender();if(e.onDrop!=null)j(I(e.onDrop,{...J(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 Zi(e,t){let n=m("div","pf-mermaid");n.setAttribute("data-mermaid","true");let r=v(e.content,t);if(n.textContent=r,"mermaid"in globalThis)n.classList.add("mermaid"),n.textContent=r;return n}var Qi="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",es="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",Pt=null,et=null;function ts(e){return k(e)&&typeof e.getDocument==="function"&&k(e.GlobalWorkerOptions)}function Ot(e,t){let n=typeof e==="string"&&e.trim()!==""?Number(e):e;return typeof n==="number"&&Number.isFinite(n)?n:t}function ns(e){return e==="fit-page"||e==="fit-width"?e:Ot(e,0)||"fit-width"}async function rs(){if(Pt)return Pt;if(et)return et;return et=import(Qi).then((e)=>{if(!ts(e))throw Error("PDF.js did not load");let t=e;return t.GlobalWorkerOptions.workerSrc=es,Pt=t,t}),et}function tr(){p("PdfViewer",os)}function os(e,t){let n=m("div","pf-pdf-viewer"),r=e.src!=null?v(e.src,t):void 0,o=b(e.data),i=Ot(e.page,1),s=ns(e.zoom),a=e.toolbar!==!1,l=Ot(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),is(n,c,{src:r,data:o,initialPage:i,zoom:s,showToolbar:a}),n}async function is(e,t,n){try{let r=await rs(),o;if(n.src)o={url:n.src};else if(n.data){let u=atob(n.data),g=new Uint8Array(u.length);for(let y=0;y<u.length;y++)g[y]=u.charCodeAt(y);o={data:g}}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 u=ss(i.numPages,s,{onPrev:()=>{if(s>1)s--,f()},onNext:()=>{if(s<i.numPages)s++,f()},onPageChange:(g)=>{let y=Math.max(1,Math.min(g,i.numPages));if(y!==s)s=y,f()}});a=u.pageInput,l=u.pageCount,e.insertBefore(u.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 d=document.createElement("canvas");d.style.display="block",d.style.boxShadow="var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1))",c.appendChild(d);async function f(){let u=await i.getPage(s),g=c.clientWidth-16,y,h=u.getViewport({scale:1});if(n.zoom==="fit-width")y=g/h.width;else if(n.zoom==="fit-page"){let w=c.clientHeight-16,R=g/h.width,x=w/h.height;y=Math.min(R,x)}else y=typeof n.zoom==="number"?n.zoom:1;let C=u.getViewport({scale:y});d.width=C.width,d.height=C.height,d.style.width=`${C.width}px`,d.style.height=`${C.height}px`;let T=d.getContext("2d");if(!T)return;if(await u.render({canvasContext:T,viewport:C}).promise,a)a.value=String(s);if(l)l.textContent=`/ ${i.numPages}`}await f()}catch(r){t.textContent=`PDF Error: ${r instanceof Error?r.message:String(r)}`,t.style.color="var(--color-text-danger, #dc2626)"}}function ss(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",er(o),o.addEventListener("click",n.onPrev);let i=document.createElement("button");i.textContent="›",i.title="Next page",i.className="pf-pdf-btn",er(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 er(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"}function ie(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 nr(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">${Q(r)}</div>`;for(let C of o)l+='<div class="pf-chart-tooltip-row">',l+=`<span class="pf-chart-tooltip-dot" style="background:${Q(C.color)}"></span>`,l+=`<span>${Q(C.label)}:</span> <strong>${Q(String(C.value))}</strong>`,l+="</div>";i.innerHTML=l;let c=s.getBoundingClientRect(),d=a.getBoundingClientRect(),f=s.viewBox.baseVal,u=c.width/(f.width||1),g=c.left-d.left+t*u,y=i.offsetWidth||100,h=g+12;if(h+y>d.width)h=g-y-12;i.style.left=`${Math.max(0,h)}px`,i.style.top="4px",i.classList.add("pf-visible")}function rr(e){e.tooltip.classList.remove("pf-visible")}function or(e,t,n){e.addEventListener("mouseenter",t),e.addEventListener("mouseleave",n),e.addEventListener("touchstart",t,{passive:!0}),e.addEventListener("touchend",n,{passive:!0})}function Ce(e,t,n,r,o,i){or(e,()=>{nr(t,n,r,o,i)},()=>{rr(t)})}function ir(e,t){let{data:n,series:r,xAxisKey:o,formatValue:i,formatLabel:s}=e,a=o?n[t][o]:void 0,l=a!=null?s?s(a):E(a):void 0,c=r.map((d,f)=>({label:d.label??d.dataKey,value:i(n[t][d.dataKey],d,f),color:d.color??_[f%_.length]}));return{label:l,entries:c}}function sr(e,t,n){let r=N("rect",{x:e,y:n.plotTop,width:t,height:n.plotHeight,fill:"transparent"});return r.style.cursor="default",r}function ar(e,t,n,r,o,i,s,a){let l={data:n,series:r,xAxisKey:i,formatValue:s,formatLabel:a},c=o.plotWidth/n.length;for(let d=0;d<n.length;d++){let f=o.plotLeft+d*c,u=sr(f,c,o),{label:g,entries:y}=ir(l,d);Ce(u,e,f+c/2,o.plotTop,g,y),t.appendChild(u)}}function lr(e,t,n,r,o,i,s,a,l,c){let d={data:n,series:r,xAxisKey:i,formatValue:s,formatLabel:c},f=n.length===1?o.plotWidth:o.plotWidth/(n.length-1);for(let u=0;u<n.length;u++){let g=n.length===1?(o.plotLeft+o.plotRight)/2:o.plotLeft+u/(n.length-1)*o.plotWidth,y=Math.max(o.plotLeft,n.length===1?o.plotLeft:g-f/2),h=sr(y,Math.min(f,o.plotRight-y),o),{label:C,entries:T}=ir(d,u);or(h,()=>{if(nr(e,g,o.plotTop,C,T),a)a.setAttribute("x1",String(g)),a.setAttribute("x2",String(g)),a.setAttribute("opacity","1");if(l)for(let x of l){for(let S of x)S.setAttribute("data-visible","false");x[u]?.setAttribute("data-visible","true")}},()=>{if(rr(e),a)a.setAttribute("opacity","0");if(l)for(let x of l)for(let S of x)S.setAttribute("data-visible","false")}),t.appendChild(h)}}function ve(e,t){return z(K(e.data,t))}function cr(e,t){let n=K(e.data,t);if(!Array.isArray(n))return;let r=n.filter((o)=>typeof o==="number"&&Number.isFinite(o));return r.length>0?r:void 0}function as(e){return e==="left"||e==="right"?e:void 0}function ls(e){if(!k(e)||typeof e.dataKey!=="string")return;let t=b(e.label),n=b(e.color),r=as(e.yAxisId),o=b(e.tooltipFormat);return{dataKey:e.dataKey,...t!==void 0&&{label:t},...n!==void 0&&{color:n},...r!==void 0&&{yAxisId:r},...o!==void 0&&{tooltipFormat:o}}}function xe(e){if(!Array.isArray(e.series))return[];return e.series.flatMap((t)=>{let n=ls(t);return n?[n]:[]})}function pe(e,t){return D(e.height)??t}function $e(e,t){return Math.max(...e.flatMap((n)=>t.map((r)=>Number(n[r.dataKey]??0))),1)}function Dt(e,t){return{valueKey:b(e.dataKey)??t[0]?.dataKey,nameKey:b(e.nameKey)??b(e.tooltipXKey)??b(e.xAxis)}}function $t(e,t){return{rows:ve(e,t),series:xe(e),height:pe(e,300),showYAxis:e.showYAxis!==!1,showGrid:e.showGrid===!0,showYAxisRight:e.showYAxisRight===!0,showTooltip:e.showTooltip!==!1,showLegend:e.showLegend!==!1,xAxisKey:b(e.xAxis),tooltipXKey:b(e.tooltipXKey),xAxisFormat:b(e.xAxisFormat),tooltipXFormat:b(e.tooltipXFormat),yAxisRightFormat:b(e.yAxisRightFormat)}}function dr(e,t,n,r){let o=t.series.filter((f)=>f.yAxisId!=="right"),i=t.series.filter((f)=>f.yAxisId==="right"),s=t.showYAxisRight&&i.length>0,a=o.length>0?$e(t.rows,o):1,l=s?$e(t.rows,i):1,c=Ye(r,t.height,t.showYAxis,s),d=re(r,t.height,n);if(t.showYAxis)$n(d,c,a,t.showGrid,Oe(e));if(s)In(d,c,l,t.yAxisRightFormat);return Qe(d,c),{layout:c,svg:d,leftMax:a,rightMax:l}}function tt(e,t){return e?(n)=>Te(n,e,t):void 0}function pr(e,t,n=ae){let r=m("div","pf-chart pf-bar-chart"),o=$t(e,t),{rows:i,series:s}=o;if(i.length===0||s.length===0)return r.textContent="No chart data",r;let{layout:a,svg:l,leftMax:c,rightMax:d}=dr(e,o,"Bar",n),f=a.plotWidth/i.length,u=f/(s.length+1);for(let g=0;g<i.length;g++)for(let y=0;y<s.length;y++){let h=s[y],C=i[g][h.dataKey];if(C===null||C===void 0)continue;let T=h.yAxisId==="right"?d:c,w=Math.max(0,Number(C)/T*a.plotHeight),R=a.plotLeft+g*f+y*u+u/2;l.appendChild(N("rect",{x:R,y:a.plotBottom-w,width:u*0.8,height:w,fill:h.color??_[y%_.length],rx:2}))}if(o.xAxisKey)Tt(l,i,o.xAxisKey,(g)=>a.plotLeft+g*f+f/2,a.plotBottom,tt(o.xAxisFormat,t));if(o.showTooltip){let g=ie(r,l),y=At(t,Oe(e),o.yAxisRightFormat);ar(g,l,i,s,a,o.tooltipXKey??o.xAxisKey,y,tt(o.tooltipXFormat,t))}return oe(r,s,o.showLegend),r.appendChild(l),r}function cs(e,t,n,r){let o=[],i=()=>{if(o.length<2){o=[];return}let s=`M ${o[0].x},${n} `+o.map((a)=>`L ${a.x},${a.y}`).join(" ")+` L ${o[o.length-1].x},${n} Z`;e.appendChild(N("path",{d:s,fill:r,opacity:0.15})),o=[]};for(let s of t){if(s.isNull){i();continue}o.push(s)}i()}function ds(e,t,n,r){let o="";for(let i of t){if(i.isNull)continue;let s=t.indexOf(i),a=s===0||t[s-1].isNull;o+=`${a?"M":"L"} ${i.x},${i.y} `}if(!o)return;e.appendChild(N("path",{d:o.trim(),fill:"none",stroke:n,"stroke-width":2,...r?{"stroke-dasharray":"6 3"}:{}}))}function ps(e,t,n){let r=[];for(let o of t){let i=N("circle",{cx:o.x,cy:o.y,r:4,fill:n,class:"pf-data-dot","data-visible":"false"});if(i.style.pointerEvents="none",o.isNull)i.style.display="none";e.appendChild(i),r.push(i)}return r}function us(e,t){let n=N("line",{class:"pf-crosshair",x1:t.plotLeft,x2:t.plotLeft,y1:t.plotTop,y2:t.plotBottom,stroke:X,"stroke-width":1,"stroke-dasharray":"3 3",opacity:0});return e.appendChild(n),n}function It(e,t,n=ae){let r=m("div",`pf-chart pf-${e.type.toLowerCase()}-chart`),o=$t(e,t),{rows:i,series:s}=o;if(i.length===0||s.length===0)return r.textContent="No chart data",r;let a=e.type==="AreaChart",{layout:l,svg:c,leftMax:d,rightMax:f}=dr(e,o,a?"Area":"Line",n),u=(h)=>i.length===1?(l.plotLeft+l.plotRight)/2:l.plotLeft+h/(i.length-1)*l.plotWidth,g=[];for(let h=0;h<s.length;h++){let C=s[h],T=C.yAxisId==="right",w=T?f:d,R=C.color??_[h%_.length],x=i.map((S,L)=>{let F=S[C.dataKey],H=F===null||F===void 0,V=H?l.plotBottom:l.plotBottom-Number(F)/w*l.plotHeight;return{x:u(L),y:V,isNull:H}});if(a)cs(c,x,l.plotBottom,R);ds(c,x,R,T),g.push(ps(c,x,R))}let y=us(c,l);if(o.xAxisKey)Tt(c,i,o.xAxisKey,u,l.plotBottom,tt(o.xAxisFormat,t));if(o.showTooltip){let h=ie(r,c),C=At(t,Oe(e),o.yAxisRightFormat);lr(h,c,i,s,l,o.tooltipXKey??o.xAxisKey,C,y,g,tt(o.tooltipXFormat,t))}return oe(r,s,o.showLegend),r.appendChild(c),r}function ur(e,t){let n=m("div","pf-chart pf-pie-chart"),r=ve(e,t),o=xe(e),i=Math.min(pe(e,300),300),s=e.showTooltip!==!1,{valueKey:a,nameKey:l}=Dt(e,o),c=o.length>0?o:a?[{dataKey:a,label:a}]:[];if(r.length===0||!a)return n.textContent="No chart data",n;let d=re(i,i,"Pie"),f=i/2,u=i/2,g=i/2-10,y=b(e.tooltipXFormat),h=Se(e,t),C=r.map((x)=>Number(x[a]??0)),T=C.reduce((x,S)=>x+S,0);if(T===0)return n.textContent="No chart data",n.appendChild(d),n;let w=s?ie(n,d):void 0,R=-Math.PI/2;for(let x=0;x<C.length;x++){let S=C[x]/T*2*Math.PI,L=R+S,F=S>Math.PI?1:0,H=f+g*Math.cos(R),V=u+g*Math.sin(R),ee=f+g*Math.cos(L),te=u+g*Math.sin(L),Y=_[x%_.length],ne=N("path",{d:`M ${f},${u} L ${H},${V} A ${g},${g} 0 ${F} 1 ${ee},${te} Z`,fill:Y});if(ne.style.cursor="default",w){let we=l?r[x][l]:void 0,O=we!=null?y?Te(we,y,t):E(we):`Slice ${x+1}`,ue=`${(C[x]/T*100).toFixed(1)}%`,se=f+g*0.6*Math.cos(R+S/2);Ce(ne,w,se,u,O,[{label:c[0].label??a,value:`${h(C[x])} (${ue})`,color:Y}])}d.appendChild(ne),R=L}return oe(n,c,e.showLegend!==!1),n.appendChild(d),n}function fr(e,t){let n=m("div","pf-chart pf-radial-chart"),r=ve(e,t),o=xe(e),{valueKey:i,nameKey:s}=Dt(e,o);if(r.length===0||!i)return n.textContent="No chart data",n;let a=Math.min(pe(e,300),300),l=a/2,c=a/2,d=a/2-10,f=Math.max(0,Math.min(D(e.innerRadius)??30,d-10)),u=D(e.startAngle)??180,g=D(e.endAngle)??0,y=r.map((L)=>Number(L[i]??0)),h=Math.max(...y,1),C=re(a,a,"Radial"),T=(d-f)/r.length,w=Math.max(2,T*0.7),R=Se(e,t),x=e.showTooltip!==!1?ie(n,C):void 0,S=[];for(let L=0;L<r.length;L++){let F=d-T*L-T/2,H=o[L]?.color??_[L%_.length],V=u+y[L]/h*(g-u),ee=s?r[L][s]:null,te=ee!=null?E(ee):o[L]?.label??i;S.push({dataKey:te||i,label:te||i,color:H}),C.appendChild(N("path",{d:Mt(l,c,F,u,g),fill:"none",stroke:ge,"stroke-width":w,"stroke-linecap":"round"}));let Y=N("path",{d:Mt(l,c,F,u,V),fill:"none",stroke:H,"stroke-width":w,"stroke-linecap":"round"});if(x){let ne=he(l,c,F,(u+V)/2);Ce(Y,x,ne.x,ne.y,te||i,[{label:i,value:R(y[L]),color:H}])}C.appendChild(Y)}return oe(n,S,e.showLegend!==!1),n.appendChild(C),n}function mr(e,t){let n=m("div","pf-chart pf-radar-chart"),r=ve(e,t),o=xe(e),i=b(e.axisKey)??b(e.xAxis);if(r.length===0||o.length===0)return n.textContent="No chart data",n;let s=e.filled!==!1,a=e.showDots===!0,l=e.showGrid!==!1,c=Math.min(pe(e,300),320),d=c/2,f=c/2,u=c/2-24,g=r.length,y=$e(r,o),h=(x)=>90-360*x/g,C=(x)=>x.map((S)=>`${S.x.toFixed(1)},${S.y.toFixed(1)}`).join(" "),T=re(c,c,"Radar");if(l){for(let S=1;S<=4;S++){let L=u*S/4,F=Array.from({length:g},(H,V)=>he(d,f,L,h(V)));T.appendChild(N("polygon",{points:C(F),fill:"none",stroke:ge,"stroke-width":1}))}for(let S=0;S<g;S++){let L=he(d,f,u,h(S));T.appendChild(N("line",{x1:d,y1:f,x2:L.x,y2:L.y,stroke:ge,"stroke-width":1}))}}for(let x=0;x<g;x++){let S=he(d,f,u+12,h(x)),L=i?r[x][i]:null;T.appendChild(De({x:S.x,y:S.y+3,"text-anchor":"middle","font-size":le,fill:X},E(L)))}let w=e.showTooltip!==!1?ie(n,T):void 0,R=Se(e,t);for(let x=0;x<o.length;x++){let S=o[x],L=S.color??_[x%_.length],F=r.map((H,V)=>he(d,f,Number(H[S.dataKey]??0)/y*u,h(V)));if(T.appendChild(N("polygon",{points:C(F),fill:s?L:"none","fill-opacity":s?0.2:0,stroke:L,"stroke-width":2})),!a&&!w)continue;for(let H=0;H<F.length;H++){let V=N("circle",{cx:F[H].x,cy:F[H].y,r:a?3:6,fill:a?L:"transparent","fill-opacity":a?1:0});if(w){let ee=i?r[H][i]:null,te=ee!=null?E(ee):S.label??S.dataKey,Y=[{label:S.label??S.dataKey,value:R(Number(r[H][S.dataKey]??0)),color:L}];Ce(V,w,F[H].x,F[H].y,te,Y)}T.appendChild(V)}}return oe(n,o,e.showLegend!==!1),n.appendChild(T),n}var gr=(e)=>String(Math.round(e*100)/100);function hr(e,t,n=ae){let r=m("div","pf-chart pf-scatter-chart"),o=ve(e,t),i=b(e.xAxis),s=b(e.yAxis),a=b(e.zAxis),l=xe(e),c=pe(e,300);if(o.length===0||!i||!s)return r.textContent="No chart data",r;let d=e.showGrid!==!1,f=l[0]?.color??_[0],u=Se(e,t,gr),g=o.map((O)=>Number(O[i]??0)),y=o.map((O)=>Number(O[s]??0)),h=Ze(Math.min(...g),Math.max(...g),5),C=Ze(Math.min(...y),Math.max(...y),4),T=h[0],w=h[h.length-1]-T||1,R=C[0],x=C[C.length-1]-R||1,S=a?o.map((O)=>Number(O[a]??0)):[],L=a?Math.max(...S,1):1,F=a?18:4,H=Ye(n,c,!0),V=re(n,c,"Scatter"),ee=H.plotLeft+F,te=Math.max(1,H.plotWidth-F*2),Y=(O)=>ee+(O-T)/w*te,ne=(O)=>H.plotBottom-(O-R)/x*H.plotHeight;for(let O=0;O<C.length;O++){let ue=C[O],se=ne(ue);if(V.appendChild(De({x:H.plotLeft-6,y:se+3,"text-anchor":"end","font-size":le,fill:X},u(ue))),d&&O>0)V.appendChild(N("line",{x1:H.plotLeft,y1:se,x2:H.plotRight,y2:se,stroke:ge,"stroke-width":1,"stroke-dasharray":"4 3"}))}Qe(V,H);for(let O of h)V.appendChild(De({x:Y(O),y:H.plotBottom+14,"text-anchor":"middle","font-size":le,fill:X},gr(O)));let we=e.showTooltip!==!1?ie(r,V):void 0;for(let O=0;O<o.length;O++){let ue=Y(g[O]),se=ne(y[O]),Br=a?4+Math.sqrt(S[O]/L)*14:4,Qt=N("circle",{cx:ue,cy:se,r:Br,fill:f,"fill-opacity":a?0.6:0.85});if(we){let _r=[{label:i,value:u(g[O]),color:f},{label:s,value:u(y[O]),color:f},...a?[{label:a,value:u(S[O]),color:f}]:[]],Jr=l[0]?.label??"Point";Ce(Qt,we,ue,se,Jr,_r)}V.appendChild(Qt)}return oe(r,l,e.showLegend!==!1),r.appendChild(V),r}function br(e,t,n=ae){let r=m("div","pf-chart pf-histogram"),o=cr(e,t);if(!o)return r.textContent="No data",r;let i=D(e.bins)??10,s=pe(e,200),a=b(e.color)??_[0],l=Math.min(...o),d=(Math.max(...o)-l)/i||1,f=Array(i).fill(0);for(let h of o){let C=Math.min(Math.floor((h-l)/d),i-1);f[C]++}let u=Math.max(...f),g=n/i,y=re(n,s,"Histogram");for(let h=0;h<i;h++){let C=u>0?f[h]/u*s:0;y.appendChild(N("rect",{x:h*g,y:s-C,width:g-1,height:C,fill:a}))}return r.appendChild(y),r}function yr(){p("BarChart",Ae(pr)),p("LineChart",Ae(It)),p("AreaChart",Ae(It)),p("PieChart",ur),p("RadarChart",mr),p("ScatterChart",Ae(hr)),p("RadialChart",fr),p("Histogram",Ae(br))}function vr(){p("Table",fs),p("TableHead",(e,t)=>jt(e)?nt("thead",e,t):Cr(e,t)),p("TableHeader",(e,t)=>jt(e)?nt("thead",e,t):Cr(e,t)),p("TableBody",(e,t)=>nt("tbody",e,t)),p("TableFooter",(e,t)=>nt("tfoot",e,t)),p("TableRow",ms),p("TableCell",gs),p("TableCaption",hs),p("ExpandableRow",bs)}function jt(e){return(e.children?.length??0)>0}function fs(e,t){let n=document.createElement("table");n.className=e.striped===!0?"pf-table pf-table-striped":"pf-table",M(e,n,t);let r=Array.from(n.children).find((o)=>o.tagName==="CAPTION");if(r&&r!==n.firstChild)n.insertBefore(r,n.firstChild);return n}function nt(e,t,n){let r=document.createElement(e);return r.className=`pf-${e}`,M(t,r,n),r}function ms(e,t){let n=document.createElement("tr");return n.className="pf-table-row",M(e,n,t),n}function Cr(e,t){let n=document.createElement("th");return n.className="pf-table-header",n.setAttribute("scope","col"),n.textContent=v(e.content,t),n}function gs(e,t){let n=document.createElement("td");if(n.className="pf-table-cell",e.colSpan!=null)n.colSpan=Number(e.colSpan);if(e.rowSpan!=null)n.rowSpan=Number(e.rowSpan);if(e.content!=null&&!jt(e))n.textContent=v(e.content,t);else M(e,n,t);return n}function hs(e,t){let n=document.createElement("caption");return n.className="pf-table-caption",n.textContent=v(e.content,t),n}function bs(e,t){let n=m("div","pf-expandable-row"),r=m("div","pf-expandable-row-summary");if(r.setAttribute("role","button"),r.setAttribute("aria-expanded","false"),r.tabIndex=0,r.appendChild(m("span","pf-expandable-arrow")),typeof e.summary==="string"){let a=m("span");a.textContent=v(e.summary,t),r.appendChild(a)}else for(let a of fe(e.summary))r.appendChild(B(a,t));let o=m("div","pf-expandable-row-detail");o.style.display="none",M(e,o,t);let i=!1,s=()=>{i=!i,o.style.display=i?"block":"none",r.setAttribute("aria-expanded",i?"true":"false")};return r.addEventListener("click",s),r.addEventListener("keydown",(a)=>{if(a.key==="Enter"||a.key===" ")a.preventDefault(),s()}),n.appendChild(r),n.appendChild(o),n}var xr=!1;function rt(){if(xr)return;xr=!0;let e=new Set(kt());An(),Ln(),On(),jn(),Jn(),zn(),Gn(),qn(),Yn(),Zn(),tr(),yr(),vr(),kn(kt().filter((t)=>!e.has(t)))}function Vt(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}function Bt(e){return e.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function Ft(e,t=" "){return Object.entries(e).map(([n,r])=>`${t}--${Vt(n)}: ${Bt(r)};`).join(`
7
- `)}function wr(e){if(!e)return"";let t=[];if(e.light&&Object.keys(e.light).length>0)t.push(`:root {
8
- ${Ft(e.light)}
9
- }`);if(e.dark&&Object.keys(e.dark).length>0){let n=Ft(e.dark);t.push(`.dark, [data-theme="dark"] {
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}>${tt(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>${jn(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>${tt(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>${tt(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(tt).join("<br />")}</p>`)}return n.join(`
6
+ `)}function li(e,t){let n=document.createElement("kbd");return n.className="pf-kbd",n.textContent=C(e.content,t),n}function Bn(){p("Card",ci),p("CardHeader",St("pf-card-header")),p("CardTitle",Vn("pf-card-title","h3")),p("CardDescription",Vn("pf-card-description","p")),p("CardContent",St("pf-card-content")),p("CardFooter",St("pf-card-footer"))}function ci(e,t){let n=f("div","pf-card");return L(e,n,t),n}function St(e){return(t,n)=>{let r=f("div",e);return L(t,r,n),r}}function Vn(e,t){return(n,r)=>{let o=document.createElement(t);return o.className=e,o.textContent=C(n.content,r),o}}var _=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899"],X="var(--muted-foreground, #6b7280)",ge="var(--border, #e5e7eb)",ee="11";function De(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 di(e,t){let n=e/t,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r;return(o<=1.5?1:o<=3?2:o<=7?5:10)*r}function _n(e,t=5){if(e<=0)return[0];return $e(0,e,t)}function $e(e,t,n=4){let r=t>e?t:e+1,o=di(r-e,n),i=Math.floor(e/o)*o,s=[];for(let a=i;a<=r+o*0.01||s.length<2;a+=o)s.push(Math.round(a*1000)/1000);return s}function nt(e,t,n,r,o){let i=_n(n);for(let s of i){let a=t.plotBottom-(n>0?s/n*t.plotHeight:0),l=H("text",{x:t.plotLeft-6,y:a+3,"text-anchor":"end","font-size":ee,fill:X});if(l.textContent=Nt(s,o),e.appendChild(l),r&&s>0)e.appendChild(H("line",{x1:t.plotLeft,y1:a,x2:t.plotRight,y2:a,stroke:ge,"stroke-width":1,"stroke-dasharray":"4 3"}))}}function zn(e,t,n,r){let o=_n(n);for(let i of o){let s=t.plotBottom-(n>0?i/n*t.plotHeight:0),a=H("text",{x:t.plotRight+6,y:s+3,"text-anchor":"start","font-size":ee,fill:X});a.textContent=Nt(i,r),e.appendChild(a)}}function Lt(e,t,n,r,o,i){let s=t.map((d)=>{let u=d[n];return u==null?"":i?i(u):T(u)}),a=t.length>1?Math.abs(r(t.length-1)-r(0))/(t.length-1):1/0,l=Math.max(1,...s.map((d)=>d.length))*Number(ee)*0.6+8,c=Math.max(1,Math.ceil(l/a));for(let d=0;d<t.length;d++){if(d%c!==0)continue;let u=H("text",{x:r(d),y:o+14,"text-anchor":"middle","font-size":ee,fill:X});u.textContent=s[d],e.appendChild(u)}}function Fe(e,t){e.appendChild(H("line",{x1:t.plotLeft,y1:t.plotBottom,x2:t.plotRight,y2:t.plotBottom,stroke:X,"stroke-width":1}))}function Ee(e,t,n){if(e==null)return"";let r=J(`{{ __v | ${t} }}`,{...n,scope:{...n.scope,__v:e}});return T(r??e)}function Nt(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 Ie(e){let t=b(e.yAxisFormat)??b(e.valueFormat);return t&&t!=="auto"?t:void 0}function Te(e,t,n=String){let r=Ie(e);return(o)=>r?Ee(o,r,t):n(o)}function Ht(e,t,n){return(r,o)=>{if(r===null||r===void 0)return"—";if(o.tooltipFormat)return Ee(r,o.tooltipFormat,e);let i=o.yAxisId==="right"?n:t;return Nt(Number(r),i)}}function ie(e,t,n){return H("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,role:"img",...n?{"aria-label":`${n} chart`}:{}})}var le=400,pi=160;function Ae(e){return(t,n)=>{let r=e(t,n,le);if(typeof ResizeObserver>"u")return r;let o=le,i=0,s=(l)=>{if(!r.isConnected)return;o=l;let c=e(t,n,l);a.unobserve(r),r.replaceWith(c),r=c,a.observe(r)},a=new ResizeObserver((l)=>{let c=Math.floor(l[0]?.contentRect.width??0);if(c<pi||Math.abs(c-o)<1)return;cancelAnimationFrame(i),i=requestAnimationFrame(()=>{s(c)})});return a.observe(r),{element:r,destroy:()=>{cancelAnimationFrame(i),a.disconnect()}}}}function H(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 Se(e,t){let n=H("text",e);return n.textContent=t,n}function be(e,t,n,r){let o=r*Math.PI/180;return{x:e+n*Math.cos(o),y:t-n*Math.sin(o)}}function Pt(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=be(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 se(e,t,n){if(!n||t.length<=1)return;let r=f("div","pf-chart-legend");for(let o=0;o<t.length;o++){let i=f("div","pf-chart-legend-item"),s=f("span","pf-chart-legend-dot");s.style.backgroundColor=t[o].color??_[o%_.length];let a=f("span");a.textContent=t[o].label??t[o].dataKey,i.appendChild(s),i.appendChild(a),r.appendChild(i)}e.appendChild(r)}var ui=["accountCircle","add","arrowBack","arrowForward","attachFile","calendarToday","call","camera","check","close","delete","download","edit","event","error","fastForward","favorite","favoriteOff","folder","help","home","info","locationOn","lock","lockOpen","mail","menu","moreVert","moreHoriz","notificationsOff","notifications","pause","payment","person","phone","photo","play","print","refresh","rewind","search","send","settings","share","shoppingCart","skipNext","skipPrevious","star","starHalf","starOff","stop","upload","visibility","visibilityOff","volumeDown","volumeMute","volumeOff","volumeUp","warning"],fi=new Map(ui.map((e)=>[Jn(e),e])),mi={alertcircle:"error",alerttriangle:"warning",alertoctagon:"error",xcircle:"error",circlex:"error",circlealert:"error",checkcircle:"check",circlecheck:"check",checkcircle2:"check",infocircle:"info",circleinfo:"info",helpcircle:"help",circlehelp:"help",bell:"notifications",belloff:"notificationsOff",arrowleft:"arrowBack",arrowright:"arrowForward",chevronleft:"arrowBack",chevronright:"arrowForward",x:"close",plus:"add",trash:"delete",trash2:"delete",ellipsisvertical:"moreVert",ellipsis:"moreHoriz",morehorizontal:"moreHoriz",morevertical:"moreVert",pencil:"edit",pen:"edit",squarepen:"edit",user:"person",usercircle:"accountCircle",circleuser:"accountCircle",eye:"visibility",eyeoff:"visibilityOff",mappin:"locationOn",map:"locationOn",image:"photo",images:"photo",file:"folder",files:"folder",calendar:"calendarToday",calendardays:"calendarToday",clock:"event",creditcard:"payment",cart:"shoppingCart",shoppingbag:"shoppingCart",phonecall:"call",mailopen:"mail",inbox:"mail",cog:"settings",gear:"settings",sliders:"settings",rotatecw:"refresh",rotateccw:"refresh",refreshcw:"refresh",heart:"favorite",heartoff:"favoriteOff",volume:"volumeUp",volume1:"volumeDown",volume2:"volumeUp",volumex:"volumeOff",skipforward:"skipNext",skipback:"skipPrevious",paperclip:"attachFile",link:"share",share2:"share",magnifyingglass:"search",searchicon:"search"};function Jn(e){return e.replace(/[\s._-]/g,"").toLowerCase()}function Kn(e){let t=Jn(e);return fi.get(t)??mi[t]}var Ot={accountCircle:'<path d="M18 20a6 6 0 0 0-12 0"/><circle cx="12" cy="10" r="4"/><circle cx="12" cy="12" r="10"/>',add:'<path d="M5 12h14"/><path d="M12 5v14"/>',arrowBack:'<path d="m12 19-7-7 7-7"/><path d="M19 12H5"/>',arrowForward:'<path d="M5 12h14"/><path d="m12 5 7 7-7 7"/>',attachFile:'<path d="M13.234 20.252 21 12.3"/><path d="m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486"/>',calendarToday:'<path d="M8 2v4"/><path d="M16 2v4"/><rect width="18" height="18" x="3" y="4" rx="2"/><path d="M3 10h18"/>',call:'<path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"/>',camera:'<path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"/><circle cx="12" cy="13" r="3"/>',check:'<path d="M20 6 9 17l-5-5"/>',close:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',delete:'<path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" x2="10" y1="11" y2="17"/><line x1="14" x2="14" y1="11" y2="17"/>',download:'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/>',edit:'<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/><path d="m15 5 4 4"/>',event:'<path d="M8 2v4"/><path d="M16 2v4"/><rect width="18" height="18" x="3" y="4" rx="2"/><path d="M3 10h18"/><path d="M8 14h.01"/><path d="M12 14h.01"/><path d="M16 14h.01"/><path d="M8 18h.01"/><path d="M12 18h.01"/><path d="M16 18h.01"/>',error:'<circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/>',fastForward:'<polygon points="13 19 22 12 13 5 13 19"/><polygon points="2 19 11 12 2 5 2 19"/>',favorite:'<path d="M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"/>',favoriteOff:'<line x1="2" y1="2" x2="22" y2="22"/><path d="M16.5 16.5 12 21l-7-7c-1.5-1.45-3-3.2-3-5.5a5.5 5.5 0 0 1 2.14-4.35"/><path d="M8.76 3.1c1.15.22 2.13.78 3.24 1.9 1.5-1.5 2.74-2 4.5-2A5.5 5.5 0 0 1 22 8.5c0 2.12-1.3 3.78-2.67 5.17"/>',folder:'<path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/>',help:'<circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><path d="M12 17h.01"/>',home:'<path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"/><path d="M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>',info:'<circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/>',locationOn:'<path d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"/><circle cx="12" cy="10" r="3"/>',lock:'<rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>',lockOpen:'<rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 9.9-1"/>',mail:'<rect width="20" height="16" x="2" y="4" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/>',menu:'<line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/>',moreVert:'<circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/>',moreHoriz:'<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>',notificationsOff:'<path d="M10.268 21a2 2 0 0 0 3.464 0"/><path d="M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742"/><path d="m2 2 20 20"/><path d="M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05"/>',notifications:'<path d="M10.268 21a2 2 0 0 0 3.464 0"/><path d="M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"/>',pause:'<rect x="14" y="4" width="4" height="16" rx="1"/><rect x="6" y="4" width="4" height="16" rx="1"/>',payment:'<rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" x2="22" y1="10" y2="10"/>',person:'<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/>',phone:'<rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/>',photo:'<rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/>',play:'<polygon points="6 3 20 12 6 21 6 3"/>',print:'<path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><path d="M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6"/><rect x="6" y="14" width="12" height="8" rx="1"/>',refresh:'<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/>',rewind:'<polygon points="11 19 2 12 11 5 11 19"/><polygon points="22 19 13 12 22 5 22 19"/>',search:'<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>',send:'<path d="M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"/><path d="m21.854 2.147-10.94 10.939"/>',settings:'<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>',share:'<circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" x2="15.42" y1="13.51" y2="17.49"/><line x1="15.41" x2="8.59" y1="6.51" y2="10.49"/>',shoppingCart:'<circle cx="8" cy="21" r="1"/><circle cx="19" cy="21" r="1"/><path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"/>',skipNext:'<polygon points="5 4 15 12 5 20 5 4"/><line x1="19" x2="19" y1="5" y2="19"/>',skipPrevious:'<polygon points="19 20 9 12 19 4 19 20"/><line x1="5" x2="5" y1="19" y2="5"/>',star:'<path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"/>',starHalf:'<path d="M12 18.338a2.1 2.1 0 0 0-.987.244L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.12 2.12 0 0 0 1.597-1.16l2.309-4.679A.53.53 0 0 1 12 2"/>',starOff:'<path d="M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43"/><path d="M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91"/><line x1="2" x2="22" y1="2" y2="22"/>',stop:'<rect width="18" height="18" x="3" y="3" rx="2"/>',upload:'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/>',visibility:'<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"/><circle cx="12" cy="12" r="3"/>',visibilityOff:'<path d="M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"/><path d="M14.084 14.158a3 3 0 0 1-4.242-4.242"/><path d="M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"/><path d="m2 2 20 20"/>',volumeDown:'<path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><path d="M16 9a5 5 0 0 1 0 6"/>',volumeMute:'<path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/>',volumeOff:'<path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><line x1="22" x2="16" y1="9" y2="15"/><line x1="16" x2="22" y1="9" y2="15"/>',volumeUp:'<path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><path d="M16 9a5 5 0 0 1 0 6"/><path d="M19.364 18.364a9 9 0 0 0 0-12.728"/>',warning:'<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/>'};var hi='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">';function gi(e){let t=Kn(e);if(t==null||!(t in Ot))return;return`${hi}${Ot[t]}</svg>`}function rt(e,t){e.setAttribute("data-icon",t);let n=gi(t);if(n===void 0){if(t!=="")S.warn(`icon "${t}" has no glyph`);return}e.innerHTML=n}function Wn(){p("DataTable",bi),p("Badge",yi),p("Dot",Ci),p("Metric",vi),p("Ring",xi),p("Progress",wi),p("Separator",ki),p("Loader",Mi),p("Icon",Ri),p("Sparkline",Ei)}function bi(e,t){let n=f("div","pf-datatable-wrapper"),r=document.createElement("table");r.className="pf-datatable";let o=W(e.columns).map((h)=>({key:T(h.key),header:h.header!=null?T(h.header):void 0,format:b(h.format),accessor:b(h.accessor)})),i=J(e.rows,t),s=b(e.rowKey),a=b(e.selected),l=document.createElement("thead"),c=document.createElement("tr");for(let h of o){let m=document.createElement("th");m.className="pf-datatable-th",m.setAttribute("scope","col"),m.textContent=h.header??h.key,c.appendChild(m)}l.appendChild(c),r.appendChild(l);let d=document.createElement("tbody");if(Array.isArray(i)){let h=a!=null?J(a,t):void 0;for(let m of i){let v=document.createElement("tr");v.className="pf-datatable-row";let g=m,y=M(g)?g:{},R=m===null||typeof m!=="object";if(s&&h!=null&&y[s]!=null&&T(y[s])===T(h))v.classList.add("pf-datatable-row-selected");if(e.onRowClick!=null&&s)v.classList.add("pf-datatable-row-clickable"),v.addEventListener("click",()=>{let w={...t.scope,$item:g,$index:i.indexOf(m)},k=z({...t,scope:w});j(I(e.onRowClick,k),"onRowClick")});for(let w of o){let k=document.createElement("td");k.className="pf-datatable-td";let x;if(w.accessor)x=J(`{{ $item.${w.accessor} }}`,{...t,scope:{...t.scope,$item:g}});else if(x=R?m:y[w.key],w.format&&x!=null)x=J(`{{ __fmtVal | ${w.format} }}`,{...t,scope:{...t.scope,__fmtVal:x}});k.textContent=T(x),v.appendChild(k)}d.appendChild(v)}}if(!Array.isArray(i)||i.length===0){let h=document.createElement("tr"),m=document.createElement("td");m.className="pf-datatable-empty",m.colSpan=Math.max(1,o.length),m.textContent="No results",h.appendChild(m),d.appendChild(h)}if(r.appendChild(d),e.search===!0){let h=document.createElement("input");h.type="text",h.placeholder="Search...",h.className="pf-datatable-search",h.setAttribute("aria-label","Search table"),h.addEventListener("input",()=>{let m=h.value.toLowerCase();for(let v of d.querySelectorAll("tr.pf-datatable-row"))v.style.display=v.textContent.toLowerCase().includes(m)?"":"none"}),n.appendChild(h)}let u=f("div","pf-datatable-scroll");return u.appendChild(r),n.appendChild(u),n}function yi(e,t){let n=f("span","pf-badge"),r=b(e.variant)??"default";return n.setAttribute("data-variant",r),n.textContent=C(e.label??e.content,t),n}function Ci(e,t){let n=f("span","pf-dot"),r=b(e.color);if(r!=null)n.style.backgroundColor=r;return n}function vi(e,t){let n=f("div","pf-metric"),r=f("div","pf-metric-label");r.textContent=C(e.label,t),n.appendChild(r);let o=f("div","pf-metric-row"),i=f("div","pf-metric-value");if(i.textContent=C(e.value,t),o.appendChild(i),e.delta!=null){let s=f("span","pf-metric-delta"),a=b(e.trend),l=a==="up"?"↑ ":a==="down"?"↓ ":"";s.textContent=l+C(e.delta,t),s.setAttribute("data-sentiment",b(e.trendSentiment)??"neutral"),o.appendChild(s)}if(n.appendChild(o),e.description!=null){let s=f("div","pf-metric-desc");s.textContent=C(e.description,t),n.appendChild(s)}return n}function xi(e,t){let n=f("div","pf-ring");n.setAttribute("data-variant",b(e.variant)??"default");let r=O(e.size)??80,o=O(e.thickness)??8,i=Number(J(e.value,t)??0),s=Math.max(0,Math.min(100,i)),a=(r-o)/2,l=2*Math.PI*a,c=l*(1-s/100),d=H("svg",{width:r,height:r,viewBox:`0 0 ${r} ${r}`}),u={cx:r/2,cy:r/2,r:a,fill:"none","stroke-width":o},h=H("circle",{...u,class:"pf-ring-track",stroke:"var(--muted, #e5e7eb)"}),m=H("circle",{...u,class:"pf-ring-fill",stroke:"var(--primary, #3b82f6)","stroke-dasharray":l,"stroke-dashoffset":c,"stroke-linecap":"round"});if(d.appendChild(h),d.appendChild(m),n.appendChild(d),n.setAttribute("role","img"),n.setAttribute("aria-label",`${String(s)}%`),e.label!=null){let v=f("div","pf-ring-label");v.textContent=C(e.label,t),n.appendChild(v)}return n}function wi(e,t){let n=f("div","pf-progress");n.setAttribute("role","progressbar"),n.setAttribute("data-variant",b(e.variant)??"default");let r=Number(J(e.value,t)??0),o=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));let s=f("div","pf-progress-fill");return s.style.width=`${i}%`,n.appendChild(s),n}function ki(e,t){let n=document.createElement("hr");if(n.className="pf-separator",e.orientation==="vertical")n.setAttribute("data-orientation","vertical"),n.setAttribute("aria-orientation","vertical");return n}function Mi(e,t){let n=f("div","pf-loader");return n.setAttribute("role","status"),n.setAttribute("aria-label","Loading"),n}function Ri(e,t){let n=f("span","pf-icon");return rt(n,C(e.name??e.content,t)),n}function Ei(e,t){let n=f("div","pf-sparkline"),r=Array.isArray(e.data)?e.data.filter((h)=>typeof h==="number"&&Number.isFinite(h)):[];if(r.length===0)return n;let o=O(e.width)??120,i=O(e.height)??32,s=Math.max(...r),a=Math.min(...r),l=s-a||1,c=H("svg",{width:o,height:i,viewBox:`0 0 ${o} ${i}`}),d=r.length>1?r.length-1:1,u=r.map((h,m)=>{let v=m/d*o,g=i-(h-a)/l*(i-4)-2;return`${v},${g}`}).join(" ");return c.appendChild(H("polyline",{points:u,fill:"none",stroke:"var(--primary, #3b82f6)","stroke-width":1.5})),n.appendChild(c),n}function Zn(){p("Form",Ti),p("Input",Ai),p("Textarea",ye(Si)),p("Button",Li),p("ButtonGroup",Le("pf-button-group")),p("Checkbox",qn("pf-checkbox")),p("Switch",qn("pf-switch")),p("Slider",ye(Ni)),p("Calendar",ye(Xn("pf-calendar"))),p("DatePicker",ye(Xn("pf-datepicker"))),p("Field",Le("pf-field")),p("FieldTitle",Ne("pf-field-title")),p("FieldDescription",Ne("pf-field-description")),p("FieldContent",Le("pf-field-content")),p("FieldError",Ne("pf-field-error"))}function Ti(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),c=l instanceof HTMLSelectElement&&l.multiple||a.length>1;i[s]=c?a:a[0]}for(let s of n.querySelectorAll('input[type="checkbox"][name]'))i[s.name]=s.checked;if(t.store.merge(i),e.onSubmit!=null){let s=z(t);s.scope={...t.scope,...i},j(I(e.onSubmit,s),"onSubmit")}}),L(e,n,t),n}var Gn=0;function ce(e,t){return Gn+=1,`pf-${e}-${t??"field"}-${String(Gn)}`}function Yn(e,t,n){if(t.label==null)return;let r=document.createElement("label");r.className="pf-input-label",r.textContent=C(t.label,n);let o=e.querySelector("input, select, textarea");if(o){if(!o.id)o.id=ce("control",b(t.name));r.htmlFor=o.id}if(t.required===!0)r.setAttribute("data-required","");e.insertBefore(r,e.firstChild)}function Qn(e,t,n){if(t.error==null||t.error===!1||t.error==="")return;let r=e.querySelector("input, select, textarea");if(r?.setAttribute("aria-invalid","true"),t.error===!0)return;let o=f("p","pf-field-error");o.id=ce("error",b(t.name)),o.textContent=C(t.error,n),r?.setAttribute("aria-describedby",o.id),e.appendChild(o)}function ye(e){return(t,n)=>{let r=e(t,n);return r.classList.add("pf-labeled"),Yn(r,t,n),Qn(r,t,n),r}}function Ce(e,t){if(t.required!==!0)return;if(e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)e.required=!0;e.setAttribute("aria-required","true")}function Dt(e,t,n,r="input",o=()=>e.value){let i=b(t.name)??(e.name||void 0);if(!i)return;let s=n.store.get(i);if(s!=null)e.value=T(s);e.addEventListener(r,()=>{let a=o();if(n.store.set(i,a),t.onChange!=null)j(I(t.onChange,{...z(n),scope:{...n.scope,$event:a}}),"onChange")})}function Ai(e,t){let n=f("div","pf-input-wrapper"),r=document.createElement("input");if(r.className="pf-input",r.type=b(e.inputType)??"text",e.name!=null)r.name=T(e.name);if(r.id=ce("input",b(e.name)),e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.disabled===!0)r.disabled=!0;return Ce(r,e),Dt(r,e,t),n.appendChild(r),Yn(n,e,t),Qn(n,e,t),n}function Si(e,t){let n=f("div","pf-textarea-wrapper"),r=document.createElement("textarea");if(r.className="pf-textarea",e.name!=null)r.name=T(e.name);if(r.id=ce("textarea",b(e.name)),e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.rows!=null)r.rows=Number(e.rows);if(e.disabled===!0)r.disabled=!0;return Ce(r,e),Dt(r,e,t),n.appendChild(r),n}function Li(e,t){let n=document.createElement("button");if(n.className="pf-button",n.type=e.submit===!0?"submit":"button",n.textContent=C(e.label,t),n.setAttribute("data-variant",b(e.variant)??"default"),e.size!=null)n.setAttribute("data-size",T(e.size));if(e.disabled===!0)n.disabled=!0;return n}function qn(e){return(t,n)=>{let r=f("label",`${e}-wrapper`),o=document.createElement("input");if(o.type="checkbox",o.className=e,e==="pf-switch")o.setAttribute("role","switch");if(t.name!=null)o.name=T(t.name);if(t.checked===!0)o.checked=!0;if(t.disabled===!0)o.disabled=!0;let i=b(t.name);if(i){let s=n.store.get(i);if(typeof s==="boolean")o.checked=s;o.addEventListener("change",()=>{if(n.store.set(i,o.checked),t.onChange!=null)j(I(t.onChange,{...z(n),scope:{...n.scope,$event:o.checked}}),"onChange")})}if(r.appendChild(o),t.label!=null){let s=f("span");s.textContent=C(t.label,n),r.appendChild(s)}return r}}function Un(e){let t=Number(e.min||0),n=Number(e.max||100),r=n>t?(Number(e.value)-t)/(n-t)*100:0;e.style.setProperty("--pf-fill",`${String(Math.round(Math.max(0,Math.min(100,r))*100)/100)}%`)}function Ni(e,t){let n=f("div","pf-slider-wrapper"),r=document.createElement("input");if(r.type="range",r.className="pf-slider",e.name!=null)r.name=T(e.name);if(e.min!=null)r.min=T(e.min);if(e.max!=null)r.max=T(e.max);if(e.step!=null)r.step=T(e.step);if(e.disabled===!0)r.disabled=!0;return Dt(r,e,t,"input",()=>Number(r.value)),Un(r),r.addEventListener("input",()=>{Un(r)}),n.appendChild(r),n}function Le(e){return(t,n)=>{let r=f("div",e);return L(t,r,n),r}}function Ne(e){return(t,n)=>{let r=f("span",e);return r.textContent=C(t.content,n),r}}function $t(){let e=document.createElement("hr");return e.className="pf-separator",e}function Xn(e){return(t,n)=>{let r=f("div",e),o=document.createElement("input");if(o.type="date",o.className="pf-input",o.name=C(t.name,n),o.id=ce("date",o.name||void 0),Ce(o,t),t.placeholder!=null)o.placeholder=C(t.placeholder,n);if(t.value!==void 0)o.value=C(t.value,n);if(t.minDate!=null)o.min=C(t.minDate,n);if(t.maxDate!=null)o.max=C(t.maxDate,n);if(t.disabled===!0)o.disabled=!0;let i=n.store.get(o.name);if(i!=null)o.value=T(i);return o.addEventListener("change",()=>{if(n.store.set(o.name,o.value),t.onChange!=null)j(I(t.onChange,z(n)),"onChange")}),r.appendChild(o),r}}function er(){p("Select",ye(Hi)),p("SelectOption",Di),p("SelectGroup",Le("pf-select-group")),p("SelectLabel",Ne("pf-select-label")),p("SelectSeparator",$t),p("Radio",$i),p("RadioGroup",Fi),p("Combobox",ye(Ii)),p("ComboboxOption",ji),p("ComboboxGroup",Le("pf-combobox-group")),p("ComboboxLabel",Ne("pf-combobox-label")),p("ComboboxSeparator",$t),p("ChoiceCard",Vi)}function Hi(e,t){let n=f("div","pf-select-wrapper"),r=document.createElement("select");if(r.className="pf-select",e.name!=null)r.name=T(e.name);if(r.id=ce("select",b(e.name)),e.multiple===!0)r.multiple=!0;if(e.disabled===!0)r.disabled=!0;if(Ce(r,e),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)}for(let i of W(e.options)){let s=document.createElement("option");s.value=T(i.value),s.textContent=i.label!=null?T(i.label):s.value,r.appendChild(s)}if(e.children)for(let i of e.children)if(i.type==="SelectOption"){let s=document.createElement("option");s.value=b(i.value)??"",s.textContent=b(i.label)??s.value,r.appendChild(s)}else r.appendChild(B(i,t));let o=b(e.name);if(o){let i=t.store.get(o);if(i!=null)Oi(r,i);r.addEventListener("change",()=>{let s=Pi(r);if(t.store.set(o,s),e.onChange!=null)j(I(e.onChange,{...z(t),scope:{...t.scope,$event:s}}),"onChange")})}return n.appendChild(r),n}function Pi(e){if(!e.multiple)return e.value;return Array.from(e.selectedOptions,(t)=>t.value)}function Oi(e,t){if(!e.multiple){e.value=T(t);return}let n=new Set((Array.isArray(t)?t:[t]).map((r)=>T(r)));for(let r of e.options)r.selected=n.has(r.value)}function Di(e,t){return f("span")}function $i(e,t){let n=f("label","pf-radio"),r=document.createElement("input");if(r.type="radio",r.className="pf-radio-input",e.disabled===!0)r.disabled=!0;if(r.value=C(e.value,t),n.appendChild(r),e.label!=null){let o=f("span","pf-radio-label");o.textContent=C(e.label,t),n.appendChild(o)}return n}function Fi(e,t){let n=f("fieldset","pf-radio-group");if(Ce(n,e),e.label!=null){let i=document.createElement("legend");if(i.className="pf-radio-legend",i.textContent=C(e.label,t),e.required===!0)i.setAttribute("data-required","");n.appendChild(i)}L(e,n,t);let r=C(e.name,t),o=t.store.get(r);for(let i of n.querySelectorAll('input[type="radio"]')){if(!(i instanceof HTMLInputElement))continue;if(i.name=r,o!=null&&i.value===T(o))i.checked=!0}return n.addEventListener("change",(i)=>{let s=i.target;if(s instanceof HTMLInputElement&&s.type==="radio"){if(t.store.set(r,s.value),e.onChange!=null)j(I(e.onChange,z(t)),"onChange")}}),n}function Ii(e,t){let n=f("div","pf-combobox"),r=document.createElement("input");if(r.className="pf-combobox-input",r.type="text",r.name=C(e.name,t),r.id=ce("combobox",r.name||void 0),r.autocomplete="off",r.setAttribute("role","combobox"),r.setAttribute("aria-autocomplete","list"),r.setAttribute("aria-expanded","false"),Ce(r,e),e.placeholder!=null)r.placeholder=C(e.placeholder,t);if(e.value!==void 0)r.value=C(e.value,t);if(e.disabled===!0)r.disabled=!0;let o=t.store.get(r.name);if(o!=null)r.value=T(o);let i=f("div","pf-combobox-dropdown");i.id=`${r.id}-list`,i.setAttribute("role","listbox"),i.style.display="none",r.setAttribute("aria-controls",i.id),L(e,i,t);let s=()=>Array.from(i.querySelectorAll(".pf-combobox-option")).filter((c)=>c.style.display!=="none"),a=(c)=>{if(i.style.display=c?"block":"none",r.setAttribute("aria-expanded",c?"true":"false"),!c)for(let d of s())d.setAttribute("aria-selected","false")},l=(c)=>{let d=s();if(d.length===0)return;let u=d.findIndex((m)=>m.getAttribute("aria-selected")==="true"),h=d[(u+c+d.length)%d.length];for(let m of d)m.setAttribute("aria-selected",m===h?"true":"false");h.scrollIntoView({block:"nearest"})};if(r.addEventListener("focus",()=>{a(!0)}),r.addEventListener("blur",()=>{setTimeout(()=>{a(!1)},150)}),r.addEventListener("keydown",(c)=>{if(c.key==="ArrowDown"||c.key==="ArrowUp")c.preventDefault(),a(!0),l(c.key==="ArrowDown"?1:-1);else if(c.key==="Enter"){let d=s().find((u)=>u.getAttribute("aria-selected")==="true");if(d)c.preventDefault(),d.dispatchEvent(new MouseEvent("mousedown")),a(!1)}else if(c.key==="Escape")a(!1)}),e.searchable!==!1)r.addEventListener("input",()=>{let c=r.value.toLowerCase();for(let d of i.querySelectorAll(".pf-combobox-option"))if(d instanceof HTMLElement)d.style.display=d.textContent.toLowerCase().includes(c)?"":"none";a(!0)});if(e.onChange!=null)n.addEventListener("pf-combobox-select",()=>{j(I(e.onChange,{...z(t),scope:{...t.scope,$event:r.value}}),"onChange")});return n.appendChild(r),n.appendChild(i),n}function ji(e,t){let n=f("div","pf-combobox-option");return n.setAttribute("role","option"),n.setAttribute("aria-selected","false"),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 Vi(e,t){let n=f("div","pf-choice-card");n.dataset.value=C(e.value,t);let r=typeof e.selected==="string"?J(e.selected,t):e.selected;if(r===!0||r==="true")n.dataset.selected="true";if(e.onClick!=null)n.setAttribute("aria-pressed",n.dataset.selected==="true"?"true":"false");if(e.label!=null){let o=f("div","pf-choice-card-label");o.textContent=C(e.label,t),n.appendChild(o)}if(e.description!=null){let o=f("div","pf-choice-card-description");o.textContent=C(e.description,t),n.appendChild(o)}return L(e,n,t),n}var de=(e)=>`${e}-${Math.random().toString(36).slice(2,8)}`;function Ft(e,t){if(!Me(e))return;let n=B(e,t);if(n instanceof HTMLElement)return n;let r=f("span","pf-trigger");return r.style.display="contents",r.appendChild(n),r}function tr(){p("Tabs",Bi),p("Tab",_i),p("Accordion",zi),p("AccordionItem",Ji),p("Dialog",Ki),p("Popover",Wi),p("Tooltip",Gi),p("HoverCard",qi),p("Carousel",Ui)}function Bi(e,t){let n=f("div","pf-tabs"),r=f("div","pf-tabs-bar");r.setAttribute("role","tablist");let o=[],i=[],s=e.children??[],a=(()=>{let c=e.defaultTab;if(typeof c==="number")return c>=0&&c<s.length?c:0;if(typeof c==="string"){let d=s.findIndex((u)=>u.title===c);return d>=0?d:0}return 0})();s.forEach((c,d)=>{let u=de("pf-tab"),h=de("pf-panel"),m=document.createElement("button");m.type="button",m.className="pf-tab-trigger",m.textContent=b(c.title)??`Tab ${String(d+1)}`,m.setAttribute("role","tab"),m.setAttribute("aria-controls",h),m.id=u,m.addEventListener("click",()=>{l(d,!0)});let v=f("div","pf-tab-panel");v.setAttribute("role","tabpanel"),v.setAttribute("aria-labelledby",u),v.id=h,v.tabIndex=0,L(c,v,t),i.push(m),o.push(v),r.appendChild(m)});function l(c,d){if(i.forEach((u,h)=>{let m=h===c;u.classList.toggle("pf-tab-active",m),u.setAttribute("aria-selected",m?"true":"false"),u.tabIndex=m?0:-1,o[h].style.display=m?"block":"none"}),d)i[c]?.focus()}if(i.length>0)l(a,!1);r.addEventListener("keydown",(c)=>{let d=i.findIndex((h)=>h===c.target);if(d<0)return;let u;if(c.key==="ArrowRight")u=(d+1)%i.length;else if(c.key==="ArrowLeft")u=(d-1+i.length)%i.length;else if(c.key==="Home")u=0;else if(c.key==="End")u=i.length-1;else return;c.preventDefault(),l(u,!0)}),n.appendChild(r);for(let c of o)n.appendChild(c);return n}function _i(e,t){let n=f("div","pf-tab");return L(e,n,t),n}function zi(e,t){let n=f("div","pf-accordion");return L(e,n,t),n}function Ji(e,t){let n=f("div","pf-accordion-item"),r=document.createElement("button");r.type="button",r.className="pf-accordion-trigger",r.id=de("pf-acc-trigger"),r.textContent=b(e.title)??"",r.setAttribute("aria-expanded","false");let o=f("div","pf-accordion-content");return o.id=de("pf-acc"),o.setAttribute("role","region"),o.setAttribute("aria-labelledby",r.id),o.style.display="none",r.setAttribute("aria-controls",o.id),L(e,o,t),r.addEventListener("click",()=>{let i=o.style.display!=="none";o.style.display=i?"none":"block",r.setAttribute("aria-expanded",i?"false":"true")}),n.appendChild(r),n.appendChild(o),n}function Ki(e,t){let n=f("div","pf-dialog-wrapper"),r=document.createElement("dialog");r.className="pf-dialog",r.setAttribute("aria-modal","true");let o=e.dismissible!==!1,i=Ft(e.trigger,t);if(i)i.setAttribute("aria-haspopup","dialog"),i.addEventListener("click",()=>{r.showModal()}),n.appendChild(i);if(e.title!=null){let l=f("h2","pf-dialog-title");l.textContent=C(e.title,t),l.id=de("pf-dialog-title"),r.setAttribute("aria-labelledby",l.id),r.appendChild(l)}if(e.description!=null){let l=f("p","pf-dialog-desc");l.textContent=C(e.description,t),l.id=de("pf-dialog-desc"),r.setAttribute("aria-describedby",l.id),r.appendChild(l)}let s=f("div","pf-dialog-body");if(L(e,s,t),r.appendChild(s),o){let l=document.createElement("button");l.type="button",l.className="pf-dialog-close",l.setAttribute("aria-label","Close"),l.textContent="×",l.addEventListener("click",()=>{r.close()}),r.appendChild(l),r.addEventListener("click",(c)=>{if(c.target===r)r.close()})}else r.addEventListener("cancel",(l)=>{l.preventDefault()});let a=()=>{r.close()};return document.addEventListener("prefab:close-overlay",a),n.appendChild(r),{element:n,destroy:()=>{document.removeEventListener("prefab:close-overlay",a)}}}function Wi(e,t){let n=f("div","pf-popover"),r=f("div","pf-popover-content");if(r.id=de("pf-popover"),r.setAttribute("role","dialog"),r.style.display="none",e.title!=null){let c=f("div","pf-popover-title");c.textContent=C(e.title,t),r.appendChild(c)}L(e,r,t);let o=Ft(e.trigger,t),i=()=>r.style.display!=="none",s=(c)=>{r.style.display=c?"block":"none",o?.setAttribute("aria-expanded",c?"true":"false")};if(o)o.setAttribute("aria-haspopup","dialog"),o.setAttribute("aria-controls",r.id),o.setAttribute("aria-expanded","false"),o.addEventListener("click",(c)=>{c.stopPropagation(),s(!i())}),n.appendChild(o);else n.addEventListener("click",(c)=>{if(c.target instanceof Node&&r.contains(c.target)&&i())return;s(!i())});let a=(c)=>{if(i()&&c.target instanceof Node&&!n.contains(c.target))s(!1)},l=(c)=>{if(c.key==="Escape"&&i())s(!1)};return document.addEventListener("click",a),document.addEventListener("keydown",l),n.appendChild(r),{element:n,destroy:()=>{document.removeEventListener("click",a),document.removeEventListener("keydown",l)}}}function Gi(e,t){let n=f("div","pf-tooltip"),r=f("div","pf-tooltip-content");r.id=de("pf-tip"),r.setAttribute("role","tooltip"),r.textContent=C(e.content??"",t),r.style.display="none",L(e,n,t),n.setAttribute("aria-describedby",r.id);let o=()=>{r.style.display="block"},i=()=>{r.style.display="none"};return n.addEventListener("mouseenter",o),n.addEventListener("mouseleave",i),n.addEventListener("focus",o,!0),n.addEventListener("blur",i,!0),n.appendChild(r),n}function qi(e,t){let n=f("div","pf-hover-card"),r=f("div","pf-hover-card-content");r.style.display="none";let o=Ft(e.trigger,t);if(o)n.appendChild(o);return L(e,r,t),n.addEventListener("mouseenter",()=>{r.style.display="block"}),n.addEventListener("mouseleave",()=>{r.style.display="none"}),n.addEventListener("focusin",()=>{r.style.display="block"}),n.addEventListener("focusout",()=>{r.style.display="none"}),n.appendChild(r),n}function Ui(e,t){let n=f("div","pf-carousel");n.setAttribute("role","region"),n.setAttribute("aria-roledescription","carousel"),n.setAttribute("aria-label",C(e.label??"Carousel",t));let r=f("div","pf-carousel-track");L(e,r,t);let o=0,i=e.children?.length??0,s=(d,u,h)=>{let m=document.createElement("button");return m.type="button",m.className=d,m.textContent=u,m.setAttribute("aria-label",h),m},a=s("pf-carousel-prev","‹","Previous slide"),l=s("pf-carousel-next","›","Next slide"),c=()=>{r.style.transform=`translateX(-${String(o*100)}%)`,a.disabled=o<=0,l.disabled=o>=i-1};return a.addEventListener("click",()=>{if(i===0)return;o=Math.max(0,o-1),c()}),l.addEventListener("click",()=>{if(i===0)return;o=Math.min(i-1,o+1),c()}),c(),n.appendChild(r),n.appendChild(a),n.appendChild(l),n}function Xi(e){if(!M(e))return{};return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,me(n)]))}function nr(){p("ForEach",Zi),p("If",rr),p("Elif",Yi),p("Else",Qi),p("Condition",es),p("Define",ts),p("Use",ns),p("Slot",rs)}function Zi(e,t){let n=document.createDocumentFragment(),r=b(e.expression);if(!r)return n;let o;if(q(r)){let s=U(r,t.store,t.scope);o=Array.isArray(s)?s:[]}else{let s=t.store.get(r);o=Array.isArray(s)?s:[]}let i=P(e.let)??{};for(let s=0;s<o.length;s++){let a=o[s],l={...t.scope,$item:a,$index:s,...i},c={...t,scope:l};if(e.children)he(e.children,n,c)}return n}function rr(e,t){if(or(b(e.condition)??"",t)){let r=document.createDocumentFragment();if(e.children)he(e.children,r,t);return r}return document.createDocumentFragment()}function Yi(e,t){return rr(e,t)}function Qi(e,t){let n=document.createDocumentFragment();if(e.children)he(e.children,n,t);return n}function or(e,t){if(!e)return!1;if(q(e))return Boolean(U(e,t.store,t.scope));return Boolean(t.store.get(e))}function es(e,t){let n=document.createDocumentFragment(),r=W(e.cases).find((o)=>or(b(o.when)??"",t));return he(me(r?r.children:e.else),n,t),n}function ts(e,t){let n=b(e.name);if(n&&e.children)t.templates=t.templates??{},t.templates[n]=e.children;return document.createDocumentFragment()}function ns(e,t){let n=document.createDocumentFragment(),r=b(e.def??e.name),o=r!=null?t.templates?.[r]:void 0;if(!o)return n;let i=P(e.overrides)??{},s={...t.scope,...i},a={...t.slots??{},...Xi(e.slots)};if(Array.isArray(e.children))a.default=e.children;let l={...t,scope:s,slots:a};for(let c of o)n.appendChild(B(c,l));return n}function rs(e,t){let n=document.createDocumentFragment(),r=b(e.name)??"default",i=t.slots?.[r]??e.children;if(i)for(let s of i)n.appendChild(B(s,t));return n}function ir(){p("Alert",os),p("AlertTitle",is),p("AlertDescription",ss)}function os(e,t){let n=f("div","pf-alert");n.setAttribute("role","alert");let r=b(e.variant)??"default";if(n.setAttribute("data-variant",r),e.icon!=null){let o=f("span","pf-alert-icon");rt(o,T(e.icon)),n.appendChild(o)}return L(e,n,t),n}function is(e,t){let n=f("h5","pf-alert-title");return n.textContent=C(e.content,t),n}function ss(e,t){let n=f("p","pf-alert-description");return n.textContent=C(e.content,t),n}var It=new Map;function ot(e){let t=It.get(e);if(t)return t;let n=import(e);return It.set(e,n),n.catch(()=>{It.delete(e)}),n}function sr(e){let t=e.closest("[data-theme], .dark, .light");if(t)return t.getAttribute("data-theme")==="dark"||t.classList.contains("dark");return typeof matchMedia==="function"&&matchMedia("(prefers-color-scheme: dark)").matches}function lr(){p("Image",as),p("Audio",ls),p("Video",cs),p("Embed",ds),p("Svg",us),p("DropZone",ms),p("Mermaid",bs)}function as(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=Number(e.width);if(e.height!=null)n.height=Number(e.height);return n.loading="lazy",n}function ls(e,t){let n=document.createElement("audio");return n.className="pf-audio",n.src=C(e.src,t),n.controls=!0,n}function cs(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=Number(e.width);if(e.height!=null)n.height=Number(e.height);return n}function ds(e,t){let n=f("div","pf-embed"),r=document.createElement("iframe");return r.src=C(e.src,t),r.style.height=e.height!=null?`${String(Number(e.height))}px`:"400px",r.setAttribute("sandbox","allow-scripts"),n.appendChild(r),n}var ps=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 us(e,t){let n=f("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 cr(i),n.appendChild(document.importNode(i,!0)),n}function cr(e){let t=Array.from(e.children);for(let n of t){if(!ps.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)}cr(n)}}function fs(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 ms(e,t){let n=f("div","pf-dropzone");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=T(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)=>fs(l,b(e.accept)));return e.multiple===!0?a:a.slice(0,1)}function i(s){if(s.length===0)return;let a=b(e.resultKey);if(a!=null)t.store.set(a,s),t.rerender();if(e.onDrop!=null)j(I(e.onDrop,{...z(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}var hs="https://cdn.jsdelivr.net/npm/mermaid@11.4.1/dist/mermaid.esm.min.mjs",ar=0;function gs(e){return M(e)&&typeof e.initialize==="function"&&typeof e.render==="function"}function bs(e,t){let n=f("div","pf-mermaid");n.setAttribute("data-mermaid","true");let r=C(e.content,t),o=f("pre","pf-mermaid-source");if(o.textContent=r,n.appendChild(o),r.trim()==="")return n;return ot(hs).then(async(i)=>{let s=M(i)?i.default:void 0;if(!gs(s))return;s.initialize({startOnLoad:!1,securityLevel:"strict",theme:sr(n)?"dark":"neutral",fontFamily:"inherit"}),ar+=1;let{svg:a}=await s.render(`pf-mermaid-${String(ar)}`,r);n.innerHTML=a,n.setAttribute("data-state","rendered")}).catch(()=>{n.setAttribute("data-state","source")}),n}var ys="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.min.mjs",Cs="https://cdn.jsdelivr.net/npm/pdfjs-dist@4.9/build/pdf.worker.min.mjs",dr=1.25,ur=0.25,fr=5,pr=32;function vs(e){if(!M(e)||typeof e.getDocument!=="function")return!1;let t=e.GlobalWorkerOptions;return typeof t==="function"||M(t)}function jt(e,t){let n=typeof e==="string"&&e.trim()!==""?Number(e):e;return typeof n==="number"&&Number.isFinite(n)?n:t}function xs(e){return e==="fit-page"||e==="fit-width"?e:jt(e,0)||"fit-width"}async function ws(){let e=await ot(ys);if(!vs(e))throw Error("PDF.js did not load");return e.GlobalWorkerOptions.workerSrc=Cs,e}function mr(){p("PdfViewer",ks)}function ks(e,t){let n=f("div","pf-pdf-viewer");n.style.height=`${jt(e.height,600)}px`;let r=f("div","pf-pdf-message");r.setAttribute("role","status"),r.textContent="Loading PDF…",n.appendChild(r);let o={destroyed:!1,cleanup:()=>{return}};return Rs(n,r,o,{src:e.src!=null?C(e.src,t):void 0,data:b(e.data),initialPage:jt(e.page,1),zoom:xs(e.zoom),showToolbar:e.toolbar!==!1}),{element:n,destroy:()=>{o.destroyed=!0,o.cleanup()}}}function Ms(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}async function Rs(e,t,n,r){try{let v=function(y){let R=Math.max(1,Math.min(y,i.numPages));if(R!==s)s=R,g()};if(!r.src&&!r.data)throw Error("No PDF source provided");let i=await(await ws()).getDocument(r.src?{url:r.src}:{data:Ms(r.data??"")}).promise;if(n.destroyed)return;t.remove();let s=Math.max(1,Math.min(r.initialPage,i.numPages)),a=r.zoom,l=1,c,d=0,u=r.showToolbar?Ts(i.numPages,{onPage:(y)=>{v(y)},onZoom:(y)=>{a=Es(l*y),g()},onFit:()=>{a=a==="fit-page"?"fit-width":"fit-page",g()}}):void 0;if(u)e.appendChild(u.el);let h=f("div","pf-pdf-canvas-container"),m=document.createElement("canvas");m.className="pf-pdf-canvas",h.appendChild(m),e.appendChild(h);async function g(){d+=1;let y=d;c?.cancel();let R=await i.getPage(s);if(n.destroyed||y!==d)return;let w=R.getViewport({scale:1}),k=Math.max(1,h.clientWidth-pr),x=Math.max(1,h.clientHeight-pr);l=a==="fit-width"?k/w.width:a==="fit-page"?Math.min(k/w.width,x/w.height):a;let E=R.getViewport({scale:l}),A=window.devicePixelRatio||1;m.width=Math.floor(E.width*A),m.height=Math.floor(E.height*A),m.style.width=`${Math.floor(E.width)}px`,m.style.height=`${Math.floor(E.height)}px`;let F=m.getContext("2d");if(!F)return;let N=R.render({canvasContext:F,viewport:E,transform:A!==1?[A,0,0,A,0,0]:void 0});c=N;try{await N.promise}catch(V){if(y!==d)return;throw V}u?.update(s,l,a)}if(typeof ResizeObserver<"u"){let y=0,R=new ResizeObserver((w)=>{let k=Math.round(w[0]?.contentRect.width??0);if(typeof a==="number"||k===y)return;y=k,g()});R.observe(h),n.cleanup=()=>{R.disconnect()}}await g()}catch(o){t.textContent=`Could not load PDF: ${o instanceof Error?o.message:String(o)}`,t.setAttribute("data-state","error")}}function Es(e){return Math.min(fr,Math.max(ur,e))}function je(e,t,n){let r=document.createElement("button");return r.type="button",r.className="pf-pdf-btn",r.textContent=e,r.title=t,r.setAttribute("aria-label",t),r.addEventListener("click",n),r}function Ts(e,t){let n=f("div","pf-pdf-toolbar"),r=1,o=je("‹","Previous page",()=>{t.onPage(r-1)}),i=je("›","Next page",()=>{t.onPage(r+1)}),s=document.createElement("input");s.type="text",s.inputMode="numeric",s.className="pf-pdf-page-input",s.setAttribute("aria-label","Page number"),s.addEventListener("change",()=>{let m=parseInt(s.value,10);if(isNaN(m))s.value=String(r);else t.onPage(m)});let a=f("span","pf-pdf-page-count");a.textContent=`/ ${String(e)}`;let l=f("span","pf-pdf-spacer"),c=je("−","Zoom out",()=>{t.onZoom(1/dr)}),d=f("span","pf-pdf-zoom-label"),u=je("+","Zoom in",()=>{t.onZoom(dr)}),h=je("⤢","Fit page / fit width",t.onFit);return n.append(o,s,a,i,l,c,d,u,h),{el:n,update(m,v,g){r=m,s.value=String(m),o.disabled=m<=1,i.disabled=m>=e,d.textContent=`${String(Math.round(v*100))}%`,c.disabled=v<=ur,u.disabled=v>=fr,h.setAttribute("aria-pressed",typeof g==="number"?"false":"true")}}}function te(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 hr(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">${Q(r)}</div>`;for(let y of o)l+='<div class="pf-chart-tooltip-row">',l+=`<span class="pf-chart-tooltip-dot" style="background:${Q(y.color)}"></span>`,l+=`<span>${Q(y.label)}:</span> <strong>${Q(String(y.value))}</strong>`,l+="</div>";i.innerHTML=l;let c=s.getBoundingClientRect(),d=a.getBoundingClientRect(),u=s.viewBox.baseVal,h=c.width/(u.width||1),m=c.left-d.left+t*h,v=i.offsetWidth||100,g=m+12;if(g+v>d.width)g=m-v-12;i.style.left=`${Math.max(0,g)}px`,i.style.top="4px",i.classList.add("pf-visible")}function gr(e){e.tooltip.classList.remove("pf-visible")}function br(e,t,n){e.addEventListener("mouseenter",t),e.addEventListener("mouseleave",n),e.addEventListener("touchstart",t,{passive:!0}),e.addEventListener("touchend",n,{passive:!0})}function pe(e,t,n,r,o,i){br(e,()=>{hr(t,n,r,o,i)},()=>{gr(t)})}function yr(e,t){let{data:n,series:r,xAxisKey:o,formatValue:i,formatLabel:s}=e,a=o?n[t][o]:void 0,l=a!=null?s?s(a):T(a):void 0,c=r.map((d,u)=>({label:d.label??d.dataKey,value:i(n[t][d.dataKey],d,u),color:d.color??_[u%_.length]}));return{label:l,entries:c}}function Cr(e,t,n){let r=H("rect",{x:e,y:n.plotTop,width:t,height:n.plotHeight,fill:"transparent"});return r.style.cursor="default",r}function vr(e,t,n,r,o,i,s,a){let l={data:n,series:r,xAxisKey:i,formatValue:s,formatLabel:a},c=o.plotWidth/n.length;for(let d=0;d<n.length;d++){let u=o.plotLeft+d*c,h=Cr(u,c,o),{label:m,entries:v}=yr(l,d);pe(h,e,u+c/2,o.plotTop,m,v),t.appendChild(h)}}function xr(e,t,n,r,o,i,s,a,l,c){let d={data:n,series:r,xAxisKey:i,formatValue:s,formatLabel:c},u=n.length===1?o.plotWidth:o.plotWidth/(n.length-1);for(let h=0;h<n.length;h++){let m=n.length===1?(o.plotLeft+o.plotRight)/2:o.plotLeft+h/(n.length-1)*o.plotWidth,v=Math.max(o.plotLeft,n.length===1?o.plotLeft:m-u/2),g=Cr(v,Math.min(u,o.plotRight-v),o),{label:y,entries:R}=yr(d,h);br(g,()=>{if(hr(e,m,o.plotTop,y,R),a)a.setAttribute("x1",String(m)),a.setAttribute("x2",String(m)),a.setAttribute("opacity","1");if(l)for(let x of l){for(let E of x)E.setAttribute("data-visible","false");x[h]?.setAttribute("data-visible","true")}},()=>{if(gr(e),a)a.setAttribute("opacity","0");if(l)for(let x of l)for(let E of x)E.setAttribute("data-visible","false")}),t.appendChild(g)}}function ve(e,t){return W(J(e.data,t))}function wr(e,t){let n=J(e.data,t);if(!Array.isArray(n))return;let r=n.filter((o)=>typeof o==="number"&&Number.isFinite(o));return r.length>0?r:void 0}function As(e){return e==="left"||e==="right"?e:void 0}function Ss(e){if(!M(e)||typeof e.dataKey!=="string")return;let t=b(e.label),n=b(e.color),r=As(e.yAxisId),o=b(e.tooltipFormat);return{dataKey:e.dataKey,...t!==void 0&&{label:t},...n!==void 0&&{color:n},...r!==void 0&&{yAxisId:r},...o!==void 0&&{tooltipFormat:o}}}function xe(e){if(!Array.isArray(e.series))return[];return e.series.flatMap((t)=>{let n=Ss(t);return n?[n]:[]})}function ue(e,t){return O(e.height)??t}function Ve(e,t){return Math.max(...e.flatMap((n)=>t.map((r)=>Number(n[r.dataKey]??0))),1)}function Vt(e,t){return{valueKey:b(e.dataKey)??t[0]?.dataKey,nameKey:b(e.nameKey)??b(e.tooltipXKey)??b(e.xAxis)}}function Bt(e,t){return{rows:ve(e,t),series:xe(e),height:ue(e,300),showYAxis:e.showYAxis!==!1,showGrid:e.showGrid===!0,showYAxisRight:e.showYAxisRight===!0,showTooltip:e.showTooltip!==!1,showLegend:e.showLegend!==!1,xAxisKey:b(e.xAxis),tooltipXKey:b(e.tooltipXKey),xAxisFormat:b(e.xAxisFormat),tooltipXFormat:b(e.tooltipXFormat),yAxisRightFormat:b(e.yAxisRightFormat)}}function kr(e,t,n,r){let o=t.series.filter((u)=>u.yAxisId!=="right"),i=t.series.filter((u)=>u.yAxisId==="right"),s=t.showYAxisRight&&i.length>0,a=o.length>0?Ve(t.rows,o):1,l=s?Ve(t.rows,i):1,c=De(r,t.height,t.showYAxis,s),d=ie(r,t.height,n);if(t.showYAxis)nt(d,c,a,t.showGrid,Ie(e));if(s)zn(d,c,l,t.yAxisRightFormat);return Fe(d,c),{layout:c,svg:d,leftMax:a,rightMax:l}}function it(e,t){return e?(n)=>Ee(n,e,t):void 0}function Mr(e,t,n=le){let r=f("div","pf-chart pf-bar-chart"),o=Bt(e,t),{rows:i,series:s}=o;if(i.length===0||s.length===0)return r.textContent="No chart data",r;let{layout:a,svg:l,leftMax:c,rightMax:d}=kr(e,o,"Bar",n),u=a.plotWidth/i.length,h=u/(s.length+1);for(let m=0;m<i.length;m++)for(let v=0;v<s.length;v++){let g=s[v],y=i[m][g.dataKey];if(y===null||y===void 0)continue;let R=g.yAxisId==="right"?d:c,w=Math.max(0,Number(y)/R*a.plotHeight),k=a.plotLeft+m*u+v*h+h/2;l.appendChild(H("rect",{x:k,y:a.plotBottom-w,width:h*0.8,height:w,fill:g.color??_[v%_.length],rx:2}))}if(o.xAxisKey)Lt(l,i,o.xAxisKey,(m)=>a.plotLeft+m*u+u/2,a.plotBottom,it(o.xAxisFormat,t));if(o.showTooltip){let m=te(r,l),v=Ht(t,Ie(e),o.yAxisRightFormat);vr(m,l,i,s,a,o.tooltipXKey??o.xAxisKey,v,it(o.tooltipXFormat,t))}return se(r,s,o.showLegend),r.appendChild(l),r}function Ls(e,t,n,r){let o=[],i=()=>{if(o.length<2){o=[];return}let s=`M ${o[0].x},${n} `+o.map((a)=>`L ${a.x},${a.y}`).join(" ")+` L ${o[o.length-1].x},${n} Z`;e.appendChild(H("path",{d:s,fill:r,opacity:0.15})),o=[]};for(let s of t){if(s.isNull){i();continue}o.push(s)}i()}function Ns(e,t,n,r){let o="";for(let i of t){if(i.isNull)continue;let s=t.indexOf(i),a=s===0||t[s-1].isNull;o+=`${a?"M":"L"} ${i.x},${i.y} `}if(!o)return;e.appendChild(H("path",{d:o.trim(),fill:"none",stroke:n,"stroke-width":2,...r?{"stroke-dasharray":"6 3"}:{}}))}function Hs(e,t,n){let r=[];for(let o of t){let i=H("circle",{cx:o.x,cy:o.y,r:4,fill:n,class:"pf-data-dot","data-visible":"false"});if(i.style.pointerEvents="none",o.isNull)i.style.display="none";e.appendChild(i),r.push(i)}return r}function Ps(e,t){let n=H("line",{class:"pf-crosshair",x1:t.plotLeft,x2:t.plotLeft,y1:t.plotTop,y2:t.plotBottom,stroke:X,"stroke-width":1,"stroke-dasharray":"3 3",opacity:0});return e.appendChild(n),n}function _t(e,t,n=le){let r=f("div",`pf-chart pf-${e.type.toLowerCase()}-chart`),o=Bt(e,t),{rows:i,series:s}=o;if(i.length===0||s.length===0)return r.textContent="No chart data",r;let a=e.type==="AreaChart",{layout:l,svg:c,leftMax:d,rightMax:u}=kr(e,o,a?"Area":"Line",n),h=(g)=>i.length===1?(l.plotLeft+l.plotRight)/2:l.plotLeft+g/(i.length-1)*l.plotWidth,m=[];for(let g=0;g<s.length;g++){let y=s[g],R=y.yAxisId==="right",w=R?u:d,k=y.color??_[g%_.length],x=i.map((E,A)=>{let F=E[y.dataKey],N=F===null||F===void 0,V=N?l.plotBottom:l.plotBottom-Number(F)/w*l.plotHeight;return{x:h(A),y:V,isNull:N}});if(a)Ls(c,x,l.plotBottom,k);Ns(c,x,k,R),m.push(Hs(c,x,k))}let v=Ps(c,l);if(o.xAxisKey)Lt(c,i,o.xAxisKey,h,l.plotBottom,it(o.xAxisFormat,t));if(o.showTooltip){let g=te(r,c),y=Ht(t,Ie(e),o.yAxisRightFormat);xr(g,c,i,s,l,o.tooltipXKey??o.xAxisKey,y,v,m,it(o.tooltipXFormat,t))}return se(r,s,o.showLegend),r.appendChild(c),r}function Rr(e,t){let n=f("div","pf-chart pf-pie-chart"),r=ve(e,t),o=xe(e),i=Math.min(ue(e,300),300),s=e.showTooltip!==!1,{valueKey:a,nameKey:l}=Vt(e,o),c=o.length>0?o:a?[{dataKey:a,label:a}]:[];if(r.length===0||!a)return n.textContent="No chart data",n;let d=ie(i,i,"Pie"),u=i/2,h=i/2,m=i/2-10,v=b(e.tooltipXFormat),g=Te(e,t),y=r.map((x)=>Number(x[a]??0)),R=y.reduce((x,E)=>x+E,0);if(R===0)return n.textContent="No chart data",n.appendChild(d),n;let w=s?te(n,d):void 0,k=-Math.PI/2;for(let x=0;x<y.length;x++){let E=y[x]/R*2*Math.PI,A=k+E,F=E>Math.PI?1:0,N=u+m*Math.cos(k),V=h+m*Math.sin(k),ne=u+m*Math.cos(A),re=h+m*Math.sin(A),Z=_[x%_.length],oe=H("path",{d:`M ${u},${h} L ${N},${V} A ${m},${m} 0 ${F} 1 ${ne},${re} Z`,fill:Z});if(oe.style.cursor="default",w){let we=l?r[x][l]:void 0,D=we!=null?v?Ee(we,v,t):T(we):`Slice ${x+1}`,fe=`${(y[x]/R*100).toFixed(1)}%`,ae=u+m*0.6*Math.cos(k+E/2);pe(oe,w,ae,h,D,[{label:c[0].label??a,value:`${g(y[x])} (${fe})`,color:Z}])}d.appendChild(oe),k=A}return se(n,c,e.showLegend!==!1),n.appendChild(d),n}function Er(e,t){let n=f("div","pf-chart pf-radial-chart"),r=ve(e,t),o=xe(e),{valueKey:i,nameKey:s}=Vt(e,o);if(r.length===0||!i)return n.textContent="No chart data",n;let a=Math.min(ue(e,300),300),l=a/2,c=a/2,d=a/2-10,u=Math.max(0,Math.min(O(e.innerRadius)??30,d-10)),h=O(e.startAngle)??180,m=O(e.endAngle)??0,v=r.map((A)=>Number(A[i]??0)),g=Math.max(...v,1),y=ie(a,a,"Radial"),R=(d-u)/r.length,w=Math.max(2,R*0.7),k=Te(e,t),x=e.showTooltip!==!1?te(n,y):void 0,E=[];for(let A=0;A<r.length;A++){let F=d-R*A-R/2,N=o[A]?.color??_[A%_.length],V=h+v[A]/g*(m-h),ne=s?r[A][s]:null,re=ne!=null?T(ne):o[A]?.label??i;E.push({dataKey:re||i,label:re||i,color:N}),y.appendChild(H("path",{d:Pt(l,c,F,h,m),fill:"none",stroke:ge,"stroke-width":w,"stroke-linecap":"round"}));let Z=H("path",{d:Pt(l,c,F,h,V),fill:"none",stroke:N,"stroke-width":w,"stroke-linecap":"round"});if(x){let oe=be(l,c,F,(h+V)/2);pe(Z,x,oe.x,oe.y,re||i,[{label:i,value:k(v[A]),color:N}])}y.appendChild(Z)}return se(n,E,e.showLegend!==!1),n.appendChild(y),n}function Tr(e,t){let n=f("div","pf-chart pf-radar-chart"),r=ve(e,t),o=xe(e),i=b(e.axisKey)??b(e.xAxis);if(r.length===0||o.length===0)return n.textContent="No chart data",n;let s=e.filled!==!1,a=e.showDots===!0,l=e.showGrid!==!1,c=Math.min(ue(e,300),320),d=c/2,u=c/2,h=c/2-24,m=r.length,v=Ve(r,o),g=(x)=>90-360*x/m,y=(x)=>x.map((E)=>`${E.x.toFixed(1)},${E.y.toFixed(1)}`).join(" "),R=ie(c,c,"Radar");if(l){for(let E=1;E<=4;E++){let A=h*E/4,F=Array.from({length:m},(N,V)=>be(d,u,A,g(V)));R.appendChild(H("polygon",{points:y(F),fill:"none",stroke:ge,"stroke-width":1}))}for(let E=0;E<m;E++){let A=be(d,u,h,g(E));R.appendChild(H("line",{x1:d,y1:u,x2:A.x,y2:A.y,stroke:ge,"stroke-width":1}))}}for(let x=0;x<m;x++){let E=be(d,u,h+12,g(x)),A=i?r[x][i]:null;R.appendChild(Se({x:E.x,y:E.y+3,"text-anchor":"middle","font-size":ee,fill:X},T(A)))}let w=e.showTooltip!==!1?te(n,R):void 0,k=Te(e,t);for(let x=0;x<o.length;x++){let E=o[x],A=E.color??_[x%_.length],F=r.map((N,V)=>be(d,u,Number(N[E.dataKey]??0)/v*h,g(V)));if(R.appendChild(H("polygon",{points:y(F),fill:s?A:"none","fill-opacity":s?0.2:0,stroke:A,"stroke-width":2})),!a&&!w)continue;for(let N=0;N<F.length;N++){let V=H("circle",{cx:F[N].x,cy:F[N].y,r:a?3:6,fill:a?A:"transparent","fill-opacity":a?1:0});if(w){let ne=i?r[N][i]:null,re=ne!=null?T(ne):E.label??E.dataKey,Z=[{label:E.label??E.dataKey,value:k(Number(r[N][E.dataKey]??0)),color:A}];pe(V,w,F[N].x,F[N].y,re,Z)}R.appendChild(V)}}return se(n,o,e.showLegend!==!1),n.appendChild(R),n}var Be=(e)=>String(Math.round(e*100)/100);function Ar(e,t,n=le){let r=f("div","pf-chart pf-scatter-chart"),o=ve(e,t),i=b(e.xAxis),s=b(e.yAxis),a=b(e.zAxis),l=xe(e),c=ue(e,300);if(o.length===0||!i||!s)return r.textContent="No chart data",r;let d=e.showGrid!==!1,u=l[0]?.color??_[0],h=Te(e,t,Be),m=o.map((D)=>Number(D[i]??0)),v=o.map((D)=>Number(D[s]??0)),g=$e(Math.min(...m),Math.max(...m),5),y=$e(Math.min(...v),Math.max(...v),4),R=g[0],w=g[g.length-1]-R||1,k=y[0],x=y[y.length-1]-k||1,E=a?o.map((D)=>Number(D[a]??0)):[],A=a?Math.max(...E,1):1,F=a?18:4,N=De(n,c,!0),V=ie(n,c,"Scatter"),ne=N.plotLeft+F,re=Math.max(1,N.plotWidth-F*2),Z=(D)=>ne+(D-R)/w*re,oe=(D)=>N.plotBottom-(D-k)/x*N.plotHeight;for(let D=0;D<y.length;D++){let fe=y[D],ae=oe(fe);if(V.appendChild(Se({x:N.plotLeft-6,y:ae+3,"text-anchor":"end","font-size":ee,fill:X},h(fe))),d&&D>0)V.appendChild(H("line",{x1:N.plotLeft,y1:ae,x2:N.plotRight,y2:ae,stroke:ge,"stroke-width":1,"stroke-dasharray":"4 3"}))}Fe(V,N);for(let D of g)V.appendChild(Se({x:Z(D),y:N.plotBottom+14,"text-anchor":"middle","font-size":ee,fill:X},Be(D)));let we=e.showTooltip!==!1?te(r,V):void 0;for(let D=0;D<o.length;D++){let fe=Z(m[D]),ae=oe(v[D]),Qr=a?4+Math.sqrt(E[D]/A)*14:4,on=H("circle",{cx:fe,cy:ae,r:Qr,fill:u,"fill-opacity":a?0.6:0.85});if(we){let eo=[{label:i,value:h(m[D]),color:u},{label:s,value:h(v[D]),color:u},...a?[{label:a,value:h(E[D]),color:u}]:[]],to=l[0]?.label??"Point";pe(on,we,fe,ae,to,eo)}V.appendChild(on)}return se(r,l,e.showLegend!==!1),r.appendChild(V),r}function Sr(e,t,n=le){let r=f("div","pf-chart pf-histogram"),o=wr(e,t);if(!o)return r.textContent="No data",r;let i=O(e.bins)??10,s=ue(e,200),a=b(e.color)??_[0],l=Math.min(...o),d=(Math.max(...o)-l)/i||1,u=Array(i).fill(0);for(let x of o){let E=Math.min(Math.floor((x-l)/d),i-1);u[E]++}let h=Math.max(...u),m=e.showYAxis!==!1,v=e.showXAxis!==!1,g=$e(0,Math.max(1,h)).at(-1)??h,y=De(n,s,m),R=ie(n,s,"Histogram");if(m)nt(R,y,g,e.showGrid!==!1);Fe(R,y);let w=e.showTooltip!==!1?te(r,R):void 0,k=y.plotWidth/i;for(let x=0;x<i;x++){let E=g>0?u[x]/g*y.plotHeight:0,A=y.plotLeft+x*k,F=H("rect",{x:A+1,y:y.plotBottom-E,width:Math.max(1,k-2),height:E,fill:a,rx:2});if(w){let N=`${Be(l+x*d)} – ${Be(l+(x+1)*d)}`;pe(F,w,A+k/2,y.plotBottom-E,N,[{label:"Count",value:u[x],color:a}])}R.appendChild(F)}if(v)for(let[x,E]of[[0,l],[i/2,l+i/2*d],[i,l+i*d]])R.appendChild(Se({x:y.plotLeft+x*k,y:y.plotBottom+14,"text-anchor":x===0?"start":x===i?"end":"middle","font-size":ee,fill:X},Be(E)));return r.appendChild(R),r}function Lr(){p("BarChart",Ae(Mr)),p("LineChart",Ae(_t)),p("AreaChart",Ae(_t)),p("PieChart",Rr),p("RadarChart",Tr),p("ScatterChart",Ae(Ar)),p("RadialChart",Er),p("Histogram",Ae(Sr))}function Hr(){p("Table",Os),p("TableHead",(e,t)=>zt(e)?st("thead",e,t):Nr(e,t)),p("TableHeader",(e,t)=>zt(e)?st("thead",e,t):Nr(e,t)),p("TableBody",(e,t)=>st("tbody",e,t)),p("TableFooter",(e,t)=>st("tfoot",e,t)),p("TableRow",Ds),p("TableCell",$s),p("TableCaption",Fs),p("ExpandableRow",Is)}function zt(e){return(e.children?.length??0)>0}function Os(e,t){let n=document.createElement("table");n.className=e.striped===!0?"pf-table pf-table-striped":"pf-table",L(e,n,t);let r=Array.from(n.children).find((o)=>o.tagName==="CAPTION");if(r&&r!==n.firstChild)n.insertBefore(r,n.firstChild);return n}function st(e,t,n){let r=document.createElement(e);return r.className=`pf-${e}`,L(t,r,n),r}function Ds(e,t){let n=document.createElement("tr");return n.className="pf-table-row",L(e,n,t),n}function Nr(e,t){let n=document.createElement("th");return n.className="pf-table-header",n.setAttribute("scope","col"),n.textContent=C(e.content,t),n}function $s(e,t){let n=document.createElement("td");if(n.className="pf-table-cell",e.colSpan!=null)n.colSpan=Number(e.colSpan);if(e.rowSpan!=null)n.rowSpan=Number(e.rowSpan);if(e.content!=null&&!zt(e))n.textContent=C(e.content,t);else L(e,n,t);return n}function Fs(e,t){let n=document.createElement("caption");return n.className="pf-table-caption",n.textContent=C(e.content,t),n}function Is(e,t){let n=f("div","pf-expandable-row"),r=f("div","pf-expandable-row-summary");if(r.setAttribute("role","button"),r.setAttribute("aria-expanded","false"),r.tabIndex=0,r.appendChild(f("span","pf-expandable-arrow")),typeof e.summary==="string"){let a=f("span");a.textContent=C(e.summary,t),r.appendChild(a)}else for(let a of me(e.summary))r.appendChild(B(a,t));let o=f("div","pf-expandable-row-detail");o.style.display="none",L(e,o,t);let i=!1,s=()=>{i=!i,o.style.display=i?"block":"none",r.setAttribute("aria-expanded",i?"true":"false")};return r.addEventListener("click",s),r.addEventListener("keydown",(a)=>{if(a.key==="Enter"||a.key===" ")a.preventDefault(),s()}),n.appendChild(r),n.appendChild(o),n}var Pr=!1;function at(){if(Pr)return;Pr=!0;let e=new Set(Tt());Dn(),In(),Bn(),Wn(),Zn(),er(),tr(),nr(),ir(),lr(),mr(),Lr(),Hr(),An(Tt().filter((t)=>!e.has(t)))}function Kt(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}function Wt(e){return e.replace(/[{}<>;]/g,"").replace(/\b(url|expression)\s*\(/gi,"")}function Jt(e,t=" "){return Object.entries(e).map(([n,r])=>`${t}--${Kt(n)}: ${Wt(r)};`).join(`
7
+ `)}function Or(e){if(!e)return"";let t=[];if(e.light&&Object.keys(e.light).length>0)t.push(`:root {
8
+ ${Jt(e.light)}
9
+ }`);if(e.dark&&Object.keys(e.dark).length>0){let n=Jt(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
- ${Ft(e.dark," ")}
13
+ ${Jt(e.dark," ")}
14
14
  }
15
15
  }`)}return t.join(`
16
- `)}function Le(e,t){e.setAttribute("data-theme",t),e.classList.toggle("dark",t==="dark"),e.classList.toggle("light",t==="light")}function _t(e,t){if(!t)return;if(t.light)for(let[n,r]of Object.entries(t.light))e.style.setProperty(`--${Vt(n)}`,Bt(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=wr({dark:t.dark})}}function Jt(e,t){if(!e||typeof document>"u")return;let n=(r)=>{for(let[o,i]of Object.entries(e))if(ys(o,r))r.preventDefault(),t(i)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}function ys(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 kr='<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>',Er='<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>',Cs=new Set(["top-right","top-left","bottom-right","bottom-left"]);function vs(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 Kt(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"),s.type="button",s.setAttribute("data-position",Cs.has(n)?n:"top-right");function a(d){if(Le(e,d),o)Le(document.documentElement,d);s.innerHTML=d==="dark"?Er:kr;try{localStorage.setItem(r,d)}catch{}}let l=vs(e,r);a(l),s.addEventListener("click",()=>{let d=e.getAttribute("data-theme")??"dark";a(d==="dark"?"light":"dark")}),e.appendChild(s);let c;if(o)c=new MutationObserver((d)=>{for(let f of d)if(f.type==="attributes"&&f.attributeName==="data-theme"){let u=document.documentElement.getAttribute("data-theme");if((u==="light"||u==="dark")&&u!==e.getAttribute("data-theme")){Le(e,u),s.innerHTML=u==="dark"?Er:kr;try{localStorage.setItem(r,u)}catch{}}}}),c.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{c?.disconnect(),s.remove()}}function ot(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(),l=P(a);if(!l)return a;if(Boolean(l.error))throw Error(b(P(l.error)?.message)??"MCP tool call returned error");let d=z(P(l.result)?.content??l.content);for(let f of d)if(f.type==="text"&&typeof f.text==="string"){try{return JSON.parse(f.text)}catch{}return f.text}return l.result??l},async sendMessage(o){await r(`${t}/mcp/messages`,{method:"POST",headers:n,body:JSON.stringify({message:o})})}}}function it(){return{callTool(e){return A.warn(`No MCP transport: callTool('${e}') ignored`),Promise.resolve(null)},sendMessage(e){return A.warn("No MCP transport: sendMessage ignored",e),Promise.resolve()}}}var Rr="0.3.23";var xs=["light","dark","auto"],ws=["inline","fullscreen","pip"];function Tr(e){return k(e)&&typeof e.type==="string"&&(e.id===void 0||typeof e.id==="string")&&(e.payload===void 0||k(e.payload))}function st(e){return typeof e==="boolean"?e:void 0}function Sr(e){let t=P(e.capabilities)??{},n=P(e.theme),r=P(e.toolInput),o=P(e.meta);return{hostName:b(e.hostName),hostVersion:b(e.hostVersion),capabilities:{toast:st(t.toast),clipboard:st(t.clipboard),navigation:st(t.navigation),messaging:st(t.messaging),displayModes:Wt(t.displayModes)},...n&&{theme:ks(n)},...r&&{toolInput:r},...o&&{meta:o}}}function ks(e){let t=b(e.fontCss);return{...at({theme:e.colorScheme,styles:{variables:e.variables}}),...t!=null&&{fontCss:t}}}function Wt(e){let t=Array.isArray(e)?e:[];return ws.filter((n)=>t.includes(n))}function at(e){let t={},n=xs.find((s)=>s===e.theme);if(n)t.colorScheme=n;let r=P(e.styles),o=P(r?.variables);if(o)t.variables=Object.fromEntries(Object.entries(o).filter((s)=>typeof s[1]==="string"));let i=b(P(r?.css)?.fonts);if(i!=null)t.fontCss=i;return t}function Es(e){return k(e)&&e.jsonrpc==="2.0"}class Ie{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=Ts();if(e)this.postFn=(n)=>e.postMessage(n);let t=(n)=>{if(this.hostOrigin!=="*"&&n.origin!==this.hostOrigin)return;let r=n.data;if(Es(r)){this.handleJsonRpc(r);return}if(!Tr(r)||!r.type.startsWith("prefab:"))return;let o=r;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(E(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 Ar;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,n){let r=(o)=>{if(o.uri!==e)return;t(o.contents??o.data??o)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",r),this.sendRpcRequest("resources/subscribe",{uri:e}).catch((o)=>{this.off("prefab:resource-updated",r),n?.(o)});else this.on("prefab:resource-updated",r),this.sendPrefab("prefab:subscribe",{uri:e});return()=>{if(this.off("prefab:resource-updated",r),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:e}).catch(Ar);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",this._hostSupportsSubscriptions=P(i.capabilities)?.subscriptions===!0,t(Sr(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()),updateModelContext:(e)=>(this.sendPrefab("prefab:update-context",{context:e.structuredContent,content:e.content}),Promise.resolve()),subscribe:(e,t,n)=>this.subscribe(e,t,n),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":{this.dispatch("prefab:theme-update",{...at(n)}),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=P(i)??{},a=P(s.hostInfo)??{},l=P(s.hostContext)??{},c=P(s.hostCapabilities)??{},d=typeof l.theme==="string"||k(l.styles)?at(l):void 0;this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let f=P(c.resources);this._hostSupportsSubscriptions=c.subscriptions===!0||f?.subscribe===!0,t({hostName:b(a.name),hostVersion:b(a.version),capabilities:{toast:!0,navigation:c.openLinks!=null,messaging:!0,displayModes:Wt(l.availableDisplayModes)},theme:d,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:Rr},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:async(e)=>{await this.sendRpcRequest("ui/message",{role:"user",content:[{type:"text",text:e}]})},updateModelContext:async(e)=>{await this.sendRpcRequest("ui/update-model-context",{...e})},subscribe:(e,t,n)=>this.subscribe(e,t,n),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((typeof e.id==="number"||typeof e.id==="string")&&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 Ar=()=>{};function zt(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)Rs(t.fontCss)}function Rs(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 lt(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function Ts(){if(typeof window>"u")return;let e=Reflect.get(window,"acquireVsCodeApi");if(typeof e==="function")try{let t=Reflect.apply(e,void 0,[]);if(k(t)&&typeof t.postMessage==="function"){let n=t.postMessage;return{postMessage:(r)=>{Reflect.apply(n,t,[r])}}}}catch{return}return}var Mr=["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 Hr=new Set(Mr);function qt(e,t={}){let n=[],r=t.strict??!1;if(!k(e))return n.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:n};let o=e,i=o.$prefab;if(!k(i))n.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof i.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 Gt(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)As(o.theme,n);if(o.css!==void 0)Lr(o.css,"$.css",n);if(o.stylesheets!==void 0)Lr(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"'});let s=o.defs;if(s!==void 0)if(!k(s))n.push({path:"$.defs",message:"defs must be a plain object"});else for(let[l,c]of Object.entries(s))Gt(c,`$.defs.${l}`,n,r);let a=o.keyBindings;if(a!==void 0)if(!k(a))n.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[l,c]of Object.entries(a))Ut(c,`$.keyBindings.${l}`,n);return{valid:n.length===0,errors:n}}function Gt(e,t,n,r){if(!k(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&&!Hr.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++)Gt(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)Ut(o[s],`${t}.${s}`,n);for(let[s,a]of Object.entries(o)){if(s==="type"||Ss.has(s)||i.includes(s))continue;if(Nr(a)||Array.isArray(a)&&a.some(Nr))n.push({path:`${t}.${s}`,message:`Components under "${s}" are ignored by the renderer; move them into "children"`})}}var Ss=new Set(["children","fallback","trigger","empty","else","summary"]);function Nr(e){return k(e)&&typeof e.type==="string"&&Hr.has(e.type)}function Ut(e,t,n){if(Array.isArray(e)){for(let i=0;i<e.length;i++)Ut(e[i],`${t}[${i}]`,n);return}if(!k(e)){n.push({path:t,message:"Action must be an object or array of objects"});return}let r=e,o=typeof r.action==="string"&&r.action.length>0?r.action:typeof r.type==="string"&&r.type.length>0?r.type:void 0;if(o===void 0){n.push({path:`${t}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if(o.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 Lr(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 As(e,t){if(!k(e)){t.push({path:"$.theme",message:"theme must be a plain object"});return}for(let n of["light","dark"])if(e[n]!==void 0){if(!k(e[n]))t.push({path:`$.theme.${n}`,message:`theme.${n} must be a plain object`})}}var W={mount(e,t,n){if(rt(),e.classList.add("pf-app-root"),n?.validate!==!1)for(let w of qt(t).errors)A.warn(`wire validation ${w.path}: ${w.message}`);let r=t,o={tracked:[],evalBlocked:!1};if(r.pipes)for(let[w,R]of Object.entries(r.pipes))Pr(w,R,o);let i=new He(r.state),s=n?.transport,a;if(!s)a=it();else if("callTool"in s)a=s;else a=ot(s);let l=n?.onToast??Ns,c=new wt;function d(w){if(!W.isPrefabData(w))return;let R=w;if(r=R,R.state)i.merge(R.state);if(R.defs)u.defs=R.defs;if(R.theme)_t(e,R.theme);if(R.mode)Or(e,R.mode);if(R.pipes)for(let[x,S]of Object.entries(R.pipes))Pr(x,S,o);for(let x of g)x.remove();if(g.length=0,g.push(...Dr(R.css,R.stylesheets)),$r(e,R.layout),y?.(),y=void 0,R.keyBindings)y=Jt(R.keyBindings,(x)=>{j(I(x,{store:i,transport:a,scope:{},rerender:()=>T(),remount:d,onToast:l}),"keyBinding")});T(),f(R)}function f(w){if(w.onMount!=null)j(I(w.onMount,u),"onMount")}let u={store:i,scope:{},transport:a,rerender:()=>T(),remount:d,onToast:l,defs:r.defs,destroyRegistry:c};if(_t(e,r.theme),r.mode)Or(e,r.mode);$r(e,r.layout);let g=Dr(r.css,r.stylesheets),y;if(r.keyBindings)y=Jt(r.keyBindings,(w)=>{j(I(w,{store:i,transport:a,scope:{},rerender:()=>T(),remount:d,onToast:l}),"keyBinding")});let h,C=n?.themeToggle??!0;if(C!==!1)h=Kt(e,typeof C==="object"?C:void 0);function T(){c.flush();let w=e.querySelector(".pf-theme-toggle");e.innerHTML="";let R=B(r.view,u);if(e.appendChild(R),w)e.appendChild(w)}return T(),f(r),{rerender:()=>T(),update(w){if(i.merge(w.update.state),T(),w.update.actions!=null)j(I(w.update.actions,u),"update action")},store:i,destroy(){c.flush(),h?.(),y?.(),un(),gn();for(let w of g)w.remove();for(let w of o.tracked)ft(w);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}};function Ms(e){if(e instanceof EvalError)return!0;return e instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test(e.message)}function Pr(e,t,n){if(pn.has(e)){A.warn(`wire pipe "${e}" ignored — shadows built-in`);return}if(je(e)!=null){A.debug(`wire pipe "${e}" — already registered, keeping local implementation`);return}if(n.evalBlocked)return;try{let r=Function("return ("+t+")")();if(!sn(r)){A.warn(`wire pipe "${e}" — source did not evaluate to a function`);return}ut(e,r),n.tracked.push(e)}catch(r){if(Ms(r)){n.evalBlocked=!0,A.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}A.warn(`wire pipe "${e}" — failed to hydrate:`,r)}}function Ns(e){if(typeof document>"u")return;let t=Hs(),n=document.createElement("div"),r=e.variant??"default";n.className=`pf-toast${r!=="default"?` pf-toast--${r}`:""}`,n.setAttribute("data-variant",r),n.setAttribute("role",r==="error"?"alert":"status");let o=document.createElement("div");if(o.className="pf-toast-title",o.textContent=e.message,n.appendChild(o),e.description){let s=document.createElement("div");s.className="pf-toast-description",s.textContent=e.description,n.appendChild(s)}t.appendChild(n);let i=e.duration??4000;setTimeout(()=>{n.classList.add("pf-toast--leaving"),setTimeout(()=>n.remove(),300)},i)}function Or(e,t){if(Le(e,t),typeof document<"u")Le(document.documentElement,t)}function Ls(e){let t=e.trim();if(t.includes("{")||t.includes("}"))return!1;return/^(https?:)?\/\//i.test(t)||t.startsWith("/")||/\.css(\?|#|$)/i.test(t)}function Dr(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(Ls(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 $r(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 Hs(){let t=document.getElementById("prefab-toast-container");if(!t)t=document.createElement("div"),t.id="prefab-toast-container",t.className="pf-toast-region",t.setAttribute("aria-live","polite"),document.body.appendChild(t);return t}if(typeof window<"u"){Object.assign(window,{PrefabRenderer:W}),Object.assign(window,{prefab:{app:ct,mount:W.mount.bind(W),isPrefabData:W.isPrefabData.bind(W),isPrefabUpdate:W.isPrefabUpdate.bind(W),Bridge:Ie,isIframe:lt,registerPipe:ut,unregisterPipe:ft,listPipes:an,registerComponent:p,createThemeToggle:Kt,validateWireFormat:qt,setLogLevel:nn}});let e=Reflect.get(window,"__PREFAB_DATA__");if(W.isPrefabData(e)){let t=document.getElementById("prefab-root");if(t)W.mount(t,e)}}async function ct(e){rt();let t=e?.mode??"auto",n=t==="bridge"||t==="auto"&&lt(),r,o,i={capabilities:{}};if(n)o=new Ie(e?.hostOrigin),o.connect(),i=await o.initialize(e?.capabilities??{toolInput:!0}),r=o.createTransport();else if(e?.transport)r=ot(e.transport);else r=it();if(i.theme&&typeof document<"u")zt(document.documentElement,i.theme);if(typeof document<"u"&&!o)Os();let s,a,l,c,d,f=i.toolInput,u;if(o)o.on("prefab:tool-input",(h)=>{let C=P(h.args)??h;if(s)s(C);else f=C}),o.on("prefab:tool-result",(h)=>{let C=h.result??h;if(a)a(C);else u=C}),o.on("prefab:tool-cancelled",()=>{l?.()}),o.on("prefab:tool-input-partial",(h)=>{c?.(P(h.args)??h)}),o.on("prefab:theme-update",(h)=>{if(typeof document<"u")zt(document.documentElement,h)}),o.on("prefab:host-context-changed",(h)=>{d?.(h)});function g(h,...C){let T=Xt(h),w=new He,R={store:w,scope:{},transport:r,rerender:()=>x(),onToast:void 0};function x(){T.innerHTML="";for(let S of C)T.appendChild(B(S,R))}return x(),{rerender:x,store:w,destroy:()=>{T.innerHTML=""}}}return{callTool:(h,C={})=>r.callTool(h,C),sendMessage:(h)=>r.sendMessage(h),onToolInput:(h)=>{if(s=h,f){let C=f;f=void 0,queueMicrotask(()=>h(C))}},onToolResult:(h)=>{if(a=h,u!==void 0){let C=u;u=void 0,queueMicrotask(()=>h(C))}},onToolCancelled:(h)=>{l=h},onToolInputPartial:(h)=>{c=h},onHostContextChanged:(h)=>{d=h},render:g,mount:(h,C,T)=>{let w=Xt(h);return W.mount(w,C,{transport:r,...T})},requestMode:(h)=>o?.requestMode(h),openLink:(h,C)=>{if(o)o.openLink(h,C);else if(typeof window<"u")window.open(h,C??"_blank")},updateContext:(h)=>{if(o)o.updateContext(h)},setupAutoResize:(h)=>{if(!o)return Ps;let C=typeof h==="string"?Xt(h):h;return o.setupAutoResize(C)},notifyPreferredSize:(h)=>{if(o)o.notifyPreferredSize(h)},host:i,capabilities:i.capabilities,theme:i.theme,transport:r,destroy:()=>o?.disconnect()}}var Ps=()=>{};function Xt(e){if(typeof e==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let t=document.querySelector(e);if(!(t instanceof HTMLElement))throw Error(`Element not found: ${e}`);return t}return e}function Os(){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 Zt=dt("auto"),Ir="#root";function Yt(e){return W.isPrefabData(e)}function jr(e){return W.isPrefabUpdate(e)}function Fr(e){if(Yt(e))return e;if(k(e)){let t=e;if(Yt(t.structuredContent))return t.structuredContent;if(Array.isArray(t.content)){for(let n of t.content)if(k(n)&&n.type==="text"&&typeof n.text==="string")try{let r=JSON.parse(n.text);if(Yt(r))return r}catch{}}}return null}async function Vr(){let e=document.querySelector(Ir);if(!e){Zt.error(`Mount target "${Ir}" not found`);return}let t=e,n=await ct();n.setupAutoResize(t);let r;function o(i){if(r)r.destroy();if(r=n.mount(t,i),i.layout)n.notifyPreferredSize(i.layout)}n.onToolResult((i)=>{let s=Fr(i);if(s)o(s);else if(jr(i)&&r)r.update(i)}),n.onToolInput((i)=>{let s=Fr(i);if(s)o(s);else if(jr(i)&&r)r.update(i)})}function Ds(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{Vr().catch((e)=>{Zt.error("Boot failed:",e)})},{once:!0});else queueMicrotask(()=>{Vr().catch((e)=>{Zt.error("Boot failed:",e)})})}Ds();})();
16
+ `)}function He(e,t){e.setAttribute("data-theme",t),e.classList.toggle("dark",t==="dark"),e.classList.toggle("light",t==="light")}function Gt(e,t){if(!t)return;if(t.light)for(let[n,r]of Object.entries(t.light))e.style.setProperty(`--${Kt(n)}`,Wt(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=Or({dark:t.dark})}}function qt(e,t){if(!e||typeof document>"u")return;let n=(r)=>{for(let[o,i]of Object.entries(e))if(js(o,r))r.preventDefault(),t(i)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)}function js(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 Dr='<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>',$r='<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>',Vs=new Set(["top-right","top-left","bottom-right","bottom-left"]);function Bs(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 Ut(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"),s.type="button",s.setAttribute("data-position",Vs.has(n)?n:"top-right");function a(d){if(He(e,d),o)He(document.documentElement,d);s.innerHTML=d==="dark"?$r:Dr;try{localStorage.setItem(r,d)}catch{}}let l=Bs(e,r);a(l),s.addEventListener("click",()=>{let d=e.getAttribute("data-theme")??"dark";a(d==="dark"?"light":"dark")}),e.appendChild(s);let c;if(o)c=new MutationObserver((d)=>{for(let u of d)if(u.type==="attributes"&&u.attributeName==="data-theme"){let h=document.documentElement.getAttribute("data-theme");if((h==="light"||h==="dark")&&h!==e.getAttribute("data-theme")){He(e,h),s.innerHTML=h==="dark"?$r:Dr;try{localStorage.setItem(r,h)}catch{}}}}),c.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});return()=>{c?.disconnect(),s.remove()}}function lt(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(),l=P(a);if(!l)return a;if(Boolean(l.error))throw Error(b(P(l.error)?.message)??"MCP tool call returned error");let d=W(P(l.result)?.content??l.content);for(let u of d)if(u.type==="text"&&typeof u.text==="string"){try{return JSON.parse(u.text)}catch{}return u.text}return l.result??l},async sendMessage(o){await r(`${t}/mcp/messages`,{method:"POST",headers:n,body:JSON.stringify({message:o})})}}}function ct(){return{callTool(e){return S.warn(`No MCP transport: callTool('${e}') ignored`),Promise.resolve(null)},sendMessage(e){return S.warn("No MCP transport: sendMessage ignored",e),Promise.resolve()}}}var Fr="0.3.24";var _s=["light","dark","auto"],zs=["inline","fullscreen","pip"];function Ir(e){return M(e)&&typeof e.type==="string"&&(e.id===void 0||typeof e.id==="string")&&(e.payload===void 0||M(e.payload))}function dt(e){return typeof e==="boolean"?e:void 0}function jr(e){let t=P(e.capabilities)??{},n=P(e.theme),r=P(e.toolInput),o=P(e.meta);return{hostName:b(e.hostName),hostVersion:b(e.hostVersion),capabilities:{toast:dt(t.toast),clipboard:dt(t.clipboard),navigation:dt(t.navigation),messaging:dt(t.messaging),displayModes:Xt(t.displayModes)},...n&&{theme:Js(n)},...r&&{toolInput:r},...o&&{meta:o}}}function Js(e){let t=b(e.fontCss);return{...pt({theme:e.colorScheme,styles:{variables:e.variables}}),...t!=null&&{fontCss:t}}}function Xt(e){let t=Array.isArray(e)?e:[];return zs.filter((n)=>t.includes(n))}function pt(e){let t={},n=_s.find((s)=>s===e.theme);if(n)t.colorScheme=n;let r=P(e.styles),o=P(r?.variables);if(o)t.variables=Object.fromEntries(Object.entries(o).filter((s)=>typeof s[1]==="string"));let i=b(P(r?.css)?.fonts);if(i!=null)t.fontCss=i;return t}function Ks(e){return M(e)&&e.jsonrpc==="2.0"}class _e{hostOrigin;listeners=new Map;protocol="prefab";cleanup;pending=new Map;callIdCounter=0;rpcPending=new Map;rpcIdCounter=0;sentRpcIds=new Set;postFn;_hostSupportsSubscriptions=!1;constructor(e="*"){this.hostOrigin=e}connect(){if(typeof window>"u")return;let e=Gs();if(e)this.postFn=(n)=>e.postMessage(n);let t=(n)=>{if(this.hostOrigin!=="*"&&n.origin!==this.hostOrigin)return;let r=n.data;if(Ks(r)){this.handleJsonRpc(r);return}if(!Ir(r)||!r.type.startsWith("prefab:"))return;let o=r;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(T(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 Vr;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,n){let r=(o)=>{if(o.uri!==e)return;t(o.contents??o.data??o)};if(this.protocol==="jsonrpc")this.on("prefab:resource-updated",r),this.sendRpcRequest("resources/subscribe",{uri:e}).catch((o)=>{this.off("prefab:resource-updated",r),n?.(o)});else this.on("prefab:resource-updated",r),this.sendPrefab("prefab:subscribe",{uri:e});return()=>{if(this.off("prefab:resource-updated",r),this.protocol==="jsonrpc")this.sendRpcRequest("resources/unsubscribe",{uri:e}).catch(Vr);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",this._hostSupportsSubscriptions=P(i.capabilities)?.subscriptions===!0,t(jr(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()),updateModelContext:(e)=>(this.sendPrefab("prefab:update-context",{context:e.structuredContent,content:e.content}),Promise.resolve()),subscribe:(e,t,n)=>this.subscribe(e,t,n),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":{this.dispatch("prefab:theme-update",{...pt(n)}),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=P(i)??{},a=P(s.hostInfo)??{},l=P(s.hostContext)??{},c=P(s.hostCapabilities)??{},d=typeof l.theme==="string"||M(l.styles)?pt(l):void 0;this.postJsonRpc({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}});let u=P(c.resources);this._hostSupportsSubscriptions=c.subscriptions===!0||u?.subscribe===!0,t({hostName:b(a.name),hostVersion:b(a.version),capabilities:{toast:!0,navigation:c.openLinks!=null,messaging:!0,displayModes:Xt(l.availableDisplayModes)},theme:d,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:Fr},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:async(e)=>{await this.sendRpcRequest("ui/message",{role:"user",content:[{type:"text",text:e}]})},updateModelContext:async(e)=>{await this.sendRpcRequest("ui/update-model-context",{...e})},subscribe:(e,t,n)=>this.subscribe(e,t,n),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((typeof e.id==="number"||typeof e.id==="string")&&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 Vr=()=>{};function Zt(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)Ws(t.fontCss)}function Ws(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 ut(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function Gs(){if(typeof window>"u")return;let e=Reflect.get(window,"acquireVsCodeApi");if(typeof e==="function")try{let t=Reflect.apply(e,void 0,[]);if(M(t)&&typeof t.postMessage==="function"){let n=t.postMessage;return{postMessage:(r)=>{Reflect.apply(n,t,[r])}}}}catch{return}return}var Br=["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 Jr=new Set(Br);function Qt(e,t={}){let n=[],r=t.strict??!1;if(!M(e))return n.push({path:"$",message:"Wire data must be a non-null object"}),{valid:!1,errors:n};let o=e,i=o.$prefab;if(!M(i))n.push({path:"$.$prefab",message:"Missing or invalid $prefab header"});else if(typeof i.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 Yt(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)Us(o.theme,n);if(o.css!==void 0)zr(o.css,"$.css",n);if(o.stylesheets!==void 0)zr(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"'});let s=o.defs;if(s!==void 0)if(!M(s))n.push({path:"$.defs",message:"defs must be a plain object"});else for(let[l,c]of Object.entries(s))Yt(c,`$.defs.${l}`,n,r);let a=o.keyBindings;if(a!==void 0)if(!M(a))n.push({path:"$.keyBindings",message:"keyBindings must be a plain object"});else for(let[l,c]of Object.entries(a))en(c,`$.keyBindings.${l}`,n);return{valid:n.length===0,errors:n}}function Yt(e,t,n,r){if(!M(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&&!Jr.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++)Yt(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)en(o[s],`${t}.${s}`,n);for(let[s,a]of Object.entries(o)){if(s==="type"||qs.has(s)||i.includes(s))continue;if(_r(a)||Array.isArray(a)&&a.some(_r))n.push({path:`${t}.${s}`,message:`Components under "${s}" are ignored by the renderer; move them into "children"`})}}var qs=new Set(["children","fallback","trigger","empty","else","summary"]);function _r(e){return M(e)&&typeof e.type==="string"&&Jr.has(e.type)}function en(e,t,n){if(Array.isArray(e)){for(let i=0;i<e.length;i++)en(e[i],`${t}[${i}]`,n);return}if(!M(e)){n.push({path:t,message:"Action must be an object or array of objects"});return}let r=e,o=typeof r.action==="string"&&r.action.length>0?r.action:typeof r.type==="string"&&r.type.length>0?r.type:void 0;if(o===void 0){n.push({path:`${t}.type`,message:'Action must have a non-empty "type" or "action" string'});return}if(o.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 zr(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 Us(e,t){if(!M(e)){t.push({path:"$.theme",message:"theme must be a plain object"});return}for(let n of["light","dark"])if(e[n]!==void 0){if(!M(e[n]))t.push({path:`$.theme.${n}`,message:`theme.${n} must be a plain object`})}}var K={mount(e,t,n){if(at(),e.classList.add("pf-app-root"),n?.validate!==!1)for(let w of Qt(t).errors)S.warn(`wire validation ${w.path}: ${w.message}`);let r=t,o={tracked:[],evalBlocked:!1};if(r.pipes)for(let[w,k]of Object.entries(r.pipes))Kr(w,k,o);let i=new Pe(r.state),s=n?.transport,a;if(!s)a=ct();else if("callTool"in s)a=s;else a=lt(s);let l=n?.onToast??Zs,c=new Et;function d(w){if(!K.isPrefabData(w))return;let k=w;if(r=k,k.state)i.merge(k.state);if(k.defs)h.defs=k.defs;if(k.theme)Gt(e,k.theme);if(k.mode)Wr(e,k.mode);if(k.pipes)for(let[x,E]of Object.entries(k.pipes))Kr(x,E,o);for(let x of m)x.remove();if(m.length=0,m.push(...Gr(k.css,k.stylesheets)),qr(e,k.layout),v?.(),v=void 0,k.keyBindings)v=qt(k.keyBindings,(x)=>{j(I(x,{store:i,transport:a,scope:{},rerender:()=>R(),remount:d,onToast:l}),"keyBinding")});R(),u(k)}function u(w){if(w.onMount!=null)j(I(w.onMount,h),"onMount")}let h={store:i,scope:{},transport:a,rerender:()=>R(),remount:d,onToast:l,defs:r.defs,destroyRegistry:c};if(Gt(e,r.theme),r.mode)Wr(e,r.mode);qr(e,r.layout);let m=Gr(r.css,r.stylesheets),v;if(r.keyBindings)v=qt(r.keyBindings,(w)=>{j(I(w,{store:i,transport:a,scope:{},rerender:()=>R(),remount:d,onToast:l}),"keyBinding")});let g,y=n?.themeToggle??!0;if(y!==!1)g=Ut(e,typeof y==="object"?y:void 0);function R(){c.flush();let w=e.querySelector(".pf-theme-toggle");e.innerHTML="";let k=B(r.view,h);if(e.appendChild(k),w)e.appendChild(w)}return R(),u(r),{rerender:()=>R(),update(w){if(i.merge(w.update.state),R(),w.update.actions!=null)j(I(w.update.actions,h),"update action")},store:i,destroy(){c.flush(),g?.(),v?.(),bn(),vn();for(let w of m)w.remove();for(let w of o.tracked)bt(w);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}};function Xs(e){if(e instanceof EvalError)return!0;return e instanceof Error&&/unsafe-eval|Content Security Policy|call to Function/i.test(e.message)}function Kr(e,t,n){if(gn.has(e)){S.warn(`wire pipe "${e}" ignored — shadows built-in`);return}if(ze(e)!=null){S.debug(`wire pipe "${e}" — already registered, keeping local implementation`);return}if(n.evalBlocked)return;try{let r=Function("return ("+t+")")();if(!pn(r)){S.warn(`wire pipe "${e}" — source did not evaluate to a function`);return}gt(e,r),n.tracked.push(e)}catch(r){if(Xs(r)){n.evalBlocked=!0,S.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}S.warn(`wire pipe "${e}" — failed to hydrate:`,r)}}function Zs(e){if(typeof document>"u")return;let t=Qs(),n=document.createElement("div"),r=e.variant??"default";n.className=`pf-toast${r!=="default"?` pf-toast--${r}`:""}`,n.setAttribute("data-variant",r),n.setAttribute("role",r==="error"?"alert":"status");let o=document.createElement("div");if(o.className="pf-toast-title",o.textContent=e.message,n.appendChild(o),e.description){let s=document.createElement("div");s.className="pf-toast-description",s.textContent=e.description,n.appendChild(s)}t.appendChild(n);let i=e.duration??4000;setTimeout(()=>{n.classList.add("pf-toast--leaving"),setTimeout(()=>n.remove(),300)},i)}function Wr(e,t){if(He(e,t),typeof document<"u")He(document.documentElement,t)}function Ys(e){let t=e.trim();if(t.includes("{")||t.includes("}"))return!1;return/^(https?:)?\/\//i.test(t)||t.startsWith("/")||/\.css(\?|#|$)/i.test(t)}function Gr(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(Ys(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 qr(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 Qs(){let t=document.getElementById("prefab-toast-container");if(!t)t=document.createElement("div"),t.id="prefab-toast-container",t.className="pf-toast-region",t.setAttribute("aria-live","polite"),document.body.appendChild(t);return t}if(typeof window<"u"){Object.assign(window,{PrefabRenderer:K}),Object.assign(window,{prefab:{app:ft,mount:K.mount.bind(K),isPrefabData:K.isPrefabData.bind(K),isPrefabUpdate:K.isPrefabUpdate.bind(K),Bridge:_e,isIframe:ut,registerPipe:gt,unregisterPipe:bt,listPipes:un,registerComponent:p,createThemeToggle:Ut,validateWireFormat:Qt,setLogLevel:ln}});let e=Reflect.get(window,"__PREFAB_DATA__");if(K.isPrefabData(e)){let t=document.getElementById("prefab-root");if(t)K.mount(t,e)}}async function ft(e){at();let t=e?.mode??"auto",n=t==="bridge"||t==="auto"&&ut(),r,o,i={capabilities:{}};if(n)o=new _e(e?.hostOrigin),o.connect(),i=await o.initialize(e?.capabilities??{toolInput:!0}),r=o.createTransport();else if(e?.transport)r=lt(e.transport);else r=ct();if(i.theme&&typeof document<"u")Zt(document.documentElement,i.theme);if(typeof document<"u"&&!o)ta();let s,a,l,c,d,u=i.toolInput,h;if(o)o.on("prefab:tool-input",(g)=>{let y=P(g.args)??g;if(s)s(y);else u=y}),o.on("prefab:tool-result",(g)=>{let y=g.result??g;if(a)a(y);else h=y}),o.on("prefab:tool-cancelled",()=>{l?.()}),o.on("prefab:tool-input-partial",(g)=>{c?.(P(g.args)??g)}),o.on("prefab:theme-update",(g)=>{if(typeof document<"u")Zt(document.documentElement,g)}),o.on("prefab:host-context-changed",(g)=>{d?.(g)});function m(g,...y){let R=tn(g),w=new Pe,k={store:w,scope:{},transport:r,rerender:()=>x(),onToast:void 0};function x(){R.innerHTML="";for(let E of y)R.appendChild(B(E,k))}return x(),{rerender:x,store:w,destroy:()=>{R.innerHTML=""}}}return{callTool:(g,y={})=>r.callTool(g,y),sendMessage:(g)=>r.sendMessage(g),onToolInput:(g)=>{if(s=g,u){let y=u;u=void 0,queueMicrotask(()=>g(y))}},onToolResult:(g)=>{if(a=g,h!==void 0){let y=h;h=void 0,queueMicrotask(()=>g(y))}},onToolCancelled:(g)=>{l=g},onToolInputPartial:(g)=>{c=g},onHostContextChanged:(g)=>{d=g},render:m,mount:(g,y,R)=>{let w=tn(g);return K.mount(w,y,{transport:r,...R})},requestMode:(g)=>o?.requestMode(g),openLink:(g,y)=>{if(o)o.openLink(g,y);else if(typeof window<"u")window.open(g,y??"_blank")},updateContext:(g)=>{if(o)o.updateContext(g)},setupAutoResize:(g)=>{if(!o)return ea;let y=typeof g==="string"?tn(g):g;return o.setupAutoResize(y)},notifyPreferredSize:(g)=>{if(o)o.notifyPreferredSize(g)},host:i,capabilities:i.capabilities,theme:i.theme,transport:r,destroy:()=>o?.disconnect()}}var ea=()=>{};function tn(e){if(typeof e==="string"){if(typeof document>"u")throw Error("Cannot resolve selector outside browser");let t=document.querySelector(e);if(!(t instanceof HTMLElement))throw Error(`Element not found: ${e}`);return t}return e}function ta(){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 rn=mt("auto"),Ur="#root";function nn(e){return K.isPrefabData(e)}function Xr(e){return K.isPrefabUpdate(e)}function Zr(e){if(nn(e))return e;if(M(e)){let t=e;if(nn(t.structuredContent))return t.structuredContent;if(Array.isArray(t.content)){for(let n of t.content)if(M(n)&&n.type==="text"&&typeof n.text==="string")try{let r=JSON.parse(n.text);if(nn(r))return r}catch{}}}return null}async function Yr(){let e=document.querySelector(Ur);if(!e){rn.error(`Mount target "${Ur}" not found`);return}let t=e,n=await ft();n.setupAutoResize(t);let r;function o(i){if(r)r.destroy();if(r=n.mount(t,i),i.layout)n.notifyPreferredSize(i.layout)}n.onToolResult((i)=>{let s=Zr(i);if(s)o(s);else if(Xr(i)&&r)r.update(i)}),n.onToolInput((i)=>{let s=Zr(i);if(s)o(s);else if(Xr(i)&&r)r.update(i)})}function na(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{Yr().catch((e)=>{rn.error("Boot failed:",e)})},{once:!0});else queueMicrotask(()=>{Yr().catch((e)=>{rn.error("Boot failed:",e)})})}na();})();