@runtypelabs/persona 4.25.0 → 4.26.0

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 (236) hide show
  1. package/dist/animations/glyph-cycle.d.cts +1 -1
  2. package/dist/animations/glyph-cycle.d.ts +1 -1
  3. package/dist/animations/{types-Db61aI9J.d.cts → types-BwKTZhg9.d.cts} +14 -0
  4. package/dist/animations/{types-Db61aI9J.d.ts → types-BwKTZhg9.d.ts} +14 -0
  5. package/dist/animations/wipe.d.cts +1 -1
  6. package/dist/animations/wipe.d.ts +1 -1
  7. package/dist/animations-extra.d.cts +14 -0
  8. package/dist/animations-extra.d.ts +14 -0
  9. package/dist/approval-ui-QAKWNFNM.js +1 -0
  10. package/dist/approval-ui.cjs +2 -2
  11. package/dist/approval-ui.d.cts +180 -8
  12. package/dist/approval-ui.d.ts +180 -8
  13. package/dist/approval-ui.js +2 -2
  14. package/dist/{artifacts-ui-IGB5YKLO.js → artifacts-ui-NJGMM27I.js} +1 -1
  15. package/dist/artifacts-ui.cjs +4 -4
  16. package/dist/artifacts-ui.d.cts +180 -8
  17. package/dist/artifacts-ui.d.ts +180 -8
  18. package/dist/artifacts-ui.js +5 -5
  19. package/dist/chunk-2ANTRKTV.js +1 -0
  20. package/dist/chunk-4HPTPUC6.js +1 -0
  21. package/dist/chunk-6V3MNEKB.js +1 -0
  22. package/dist/chunk-HGUCGM3K.js +9 -0
  23. package/dist/chunk-IO5VVUKP.js +3 -0
  24. package/dist/chunk-J4J3Y2P2.js +1 -0
  25. package/dist/chunk-K6HKIP5K.js +1 -0
  26. package/dist/chunk-K7NA7G7J.js +1 -0
  27. package/dist/chunk-MXUTS3LB.js +1 -0
  28. package/dist/chunk-PDPVORUF.js +1 -0
  29. package/dist/chunk-QPPJUSZH.js +1 -0
  30. package/dist/chunk-QRKGQPU7.js +1 -0
  31. package/dist/chunk-S6PBWE75.js +1 -0
  32. package/dist/chunk-T7QM7YMF.js +1 -0
  33. package/dist/chunk-TR2H475E.js +1 -0
  34. package/dist/chunk-UPO4GUFC.js +1 -0
  35. package/dist/chunk-ZC66NAIR.js +1 -0
  36. package/dist/client-history-YPEG45Q4.js +1 -0
  37. package/dist/client-history.js +1 -0
  38. package/dist/client-stream-42FOI3EC.js +4 -0
  39. package/dist/client-stream.js +5 -0
  40. package/dist/codegen.cjs +1 -1
  41. package/dist/codegen.js +1 -1
  42. package/dist/context-mentions-E7HJYWO6.js +161 -0
  43. package/dist/{context-mentions-inline-I2RDEBAK.js → context-mentions-inline-QVESLW55.js} +1 -1
  44. package/dist/context-mentions.cjs +7 -7
  45. package/dist/context-mentions.d.cts +180 -8
  46. package/dist/context-mentions.d.ts +180 -8
  47. package/dist/context-mentions.js +8 -8
  48. package/dist/event-stream-view-FOIJHFQO.js +1 -0
  49. package/dist/event-stream-view.cjs +1 -1
  50. package/dist/event-stream-view.d.cts +183 -31
  51. package/dist/event-stream-view.d.ts +183 -31
  52. package/dist/event-stream-view.js +1 -1
  53. package/dist/forms-ui.d.cts +221 -667
  54. package/dist/forms-ui.d.ts +221 -667
  55. package/dist/history-shell-QDQ44PSE.js +3 -0
  56. package/dist/history-shell.js +3 -0
  57. package/dist/{history-view-BD6OXLNA.js → history-view-NCFBI5GR.js} +2 -2
  58. package/dist/history-view.cjs +2 -2
  59. package/dist/history-view.d.cts +35 -1
  60. package/dist/history-view.d.ts +35 -1
  61. package/dist/history-view.js +2 -2
  62. package/dist/index.cjs +80 -74
  63. package/dist/index.cjs.map +1 -1
  64. package/dist/index.d.cts +227 -738
  65. package/dist/index.d.ts +227 -738
  66. package/dist/index.global.js +3 -215
  67. package/dist/index.global.js.map +1 -1
  68. package/dist/index.js +81 -75
  69. package/dist/index.js.map +1 -1
  70. package/dist/install.global.js +1 -1
  71. package/dist/install.global.js.map +1 -1
  72. package/dist/launcher.global.js +3 -67
  73. package/dist/launcher.global.js.map +1 -1
  74. package/dist/markdown-parsers.js +22 -22
  75. package/dist/runtype-tts-entry-NFBVWR7N.js +1 -0
  76. package/dist/runtype-tts.js +1 -1
  77. package/dist/session-actions-ISSKSI66.js +1 -0
  78. package/dist/session-actions.js +1 -0
  79. package/dist/session-reconnect.d.cts +180 -8
  80. package/dist/session-reconnect.d.ts +180 -8
  81. package/dist/smart-dom-reader.cjs +13 -13
  82. package/dist/smart-dom-reader.d.cts +180 -8
  83. package/dist/smart-dom-reader.d.ts +180 -8
  84. package/dist/smart-dom-reader.js +11 -11
  85. package/dist/theme-editor-preview.cjs +116 -98
  86. package/dist/theme-editor-preview.d.cts +182 -8
  87. package/dist/theme-editor-preview.d.ts +182 -8
  88. package/dist/theme-editor-preview.js +49 -54
  89. package/dist/theme-editor.cjs +2 -2
  90. package/dist/theme-editor.d.cts +181 -23
  91. package/dist/theme-editor.d.ts +181 -23
  92. package/dist/theme-editor.js +2 -2
  93. package/dist/theme-reference.d.cts +14 -0
  94. package/dist/theme-reference.d.ts +14 -0
  95. package/dist/ui-extras-entry-WAYFKVNW.js +3 -0
  96. package/dist/ui-extras.js +72 -0
  97. package/dist/voice-runtime-UOQOFAFY.js +17 -0
  98. package/dist/voice-runtime.cjs +17 -1
  99. package/dist/voice-runtime.d.cts +11650 -232
  100. package/dist/voice-runtime.d.ts +11650 -232
  101. package/dist/voice-runtime.js +17 -1
  102. package/dist/voice-worklet-player.cjs +19 -4
  103. package/dist/voice-worklet-player.d.cts +9 -10
  104. package/dist/voice-worklet-player.d.ts +9 -10
  105. package/dist/voice-worklet-player.js +19 -4
  106. package/dist/webmcp-polyfill.js +1 -1
  107. package/dist/webmcp-runtime-V6ZWW3PI.js +6 -0
  108. package/dist/webmcp-runtime.cjs +2 -2
  109. package/dist/webmcp-runtime.d.cts +1 -33
  110. package/dist/webmcp-runtime.d.ts +1 -33
  111. package/dist/webmcp-runtime.js +2 -2
  112. package/dist/widget.css +1 -1
  113. package/package.json +11 -5
  114. package/src/approval-paused-tool-settle.test.ts +221 -0
  115. package/src/client-approve.test.ts +311 -0
  116. package/src/client-history-eager.ts +9 -0
  117. package/src/client-history-loader.ts +23 -0
  118. package/src/client-history.ts +579 -0
  119. package/src/client-resume.ts +177 -0
  120. package/src/client-stream-eager.ts +12 -0
  121. package/src/client-stream-loader.ts +25 -0
  122. package/src/client-stream.ts +1880 -0
  123. package/src/client.test.ts +31 -1
  124. package/src/client.ts +293 -2607
  125. package/src/components/approval-actions.test.ts +27 -0
  126. package/src/components/approval-actions.ts +27 -3
  127. package/src/components/message-bubble.test.ts +19 -0
  128. package/src/components/message-bubble.ts +2 -0
  129. package/src/components/registry.ts +6 -6
  130. package/src/components/tool-bubble.test.ts +9 -0
  131. package/src/components/tool-bubble.ts +1 -0
  132. package/src/history-shell-bundle.test.ts +54 -0
  133. package/src/history-shell-eager.ts +12 -0
  134. package/src/history-shell-loader.ts +27 -0
  135. package/src/history-shell.ts +2362 -0
  136. package/src/history-view-loader.ts +2 -0
  137. package/src/history-view.ts +3 -0
  138. package/src/index-core.ts +6 -0
  139. package/src/index-global.ts +90 -248
  140. package/src/index.ts +13 -0
  141. package/src/install.ts +6 -4
  142. package/src/internal/runtype-history-provider.test.ts +1 -0
  143. package/src/internal/runtype-history-provider.ts +28 -13
  144. package/src/plugins/registry.ts +8 -8
  145. package/src/session-actions-chunk.test.ts +55 -0
  146. package/src/session-actions-eager.ts +11 -0
  147. package/src/session-actions-loader.ts +37 -0
  148. package/src/session-actions.ts +909 -0
  149. package/src/session-history.test.ts +3 -1
  150. package/src/session.ts +852 -1536
  151. package/src/session.voice.test.ts +1170 -5
  152. package/src/styles/widget.css +58 -0
  153. package/src/theme-editor/state.ts +91 -91
  154. package/src/types.ts +198 -5
  155. package/src/ui-ask-user-sheet.ts +382 -0
  156. package/src/ui-extras-eager.ts +10 -0
  157. package/src/ui-extras-entry.ts +9 -0
  158. package/src/ui-extras-loader.ts +26 -0
  159. package/src/ui.artifact-rail-resize.test.ts +2 -1
  160. package/src/ui.ask-user-chunk.test.ts +93 -0
  161. package/src/ui.history-chunk.test.ts +2 -1
  162. package/src/ui.history-config-provider.test.ts +2 -1
  163. package/src/ui.history-confirm-fallback.test.ts +142 -0
  164. package/src/ui.history-controller.test.ts +2 -1
  165. package/src/ui.history-lifecycle.test.ts +2 -1
  166. package/src/ui.history-render-hooks.test.ts +2 -1
  167. package/src/ui.history-shell.test.ts +2 -1
  168. package/src/ui.rail-overlay.test.ts +2 -1
  169. package/src/ui.rail-resize.test.ts +2 -1
  170. package/src/ui.rail-trigger-pending.test.ts +2 -1
  171. package/src/ui.ts +340 -2770
  172. package/src/utils/attachment-manager.ts +67 -67
  173. package/src/utils/constants.ts +3 -0
  174. package/src/utils/context-mention-controller.ts +323 -323
  175. package/src/utils/context-mention-manager.ts +40 -40
  176. package/src/utils/context-mention-orchestrator.ts +28 -0
  177. package/src/utils/event-stream-buffer.ts +50 -50
  178. package/src/utils/event-stream-store.ts +43 -43
  179. package/src/utils/throughput-tracker.ts +34 -34
  180. package/src/utils/virtual-scroller.ts +67 -67
  181. package/src/utils/visitor-store.test.ts +50 -0
  182. package/src/utils/visitor-store.ts +23 -5
  183. package/src/voice/__fixtures__/voice-wire/README.md +1 -0
  184. package/src/voice/__fixtures__/voice-wire/client/cancel.json +3 -0
  185. package/src/voice/__fixtures__/voice-wire/client/context.json +4 -0
  186. package/src/voice/__fixtures__/voice-wire/client/delegation_result.json +6 -0
  187. package/src/voice/__fixtures__/voice-wire/client/delegation_update.json +6 -0
  188. package/src/voice/__fixtures__/voice-wire/client/ping.json +3 -0
  189. package/src/voice/__fixtures__/voice-wire/client/playback_progress.json +5 -0
  190. package/src/voice/__fixtures__/voice-wire/client/start.json +3 -0
  191. package/src/voice/__fixtures__/voice-wire/server/artifact.json +11 -0
  192. package/src/voice/__fixtures__/voice-wire/server/attached.json +4 -0
  193. package/src/voice/__fixtures__/voice-wire/server/audio_clear.json +4 -0
  194. package/src/voice/__fixtures__/voice-wire/server/audio_end.json +3 -0
  195. package/src/voice/__fixtures__/voice-wire/server/delegation_cancelled.json +5 -0
  196. package/src/voice/__fixtures__/voice-wire/server/delegation_completed.json +8 -0
  197. package/src/voice/__fixtures__/voice-wire/server/delegation_started.json +15 -0
  198. package/src/voice/__fixtures__/voice-wire/server/error.json +6 -0
  199. package/src/voice/__fixtures__/voice-wire/server/metrics.json +10 -0
  200. package/src/voice/__fixtures__/voice-wire/server/pong.json +3 -0
  201. package/src/voice/__fixtures__/voice-wire/server/session_config.json +16 -0
  202. package/src/voice/__fixtures__/voice-wire/server/transcript_final.json +7 -0
  203. package/src/voice/__fixtures__/voice-wire/server/transcript_interim.json +4 -0
  204. package/src/voice/__fixtures__/voice-wire/server/transcript_partial.json +6 -0
  205. package/src/voice/__fixtures__/voice-wire/server/transcript_update.json +10 -0
  206. package/src/voice/__fixtures__/voice-wire/server/warning.json +5 -0
  207. package/src/voice/audio-playback-manager.test.ts +57 -0
  208. package/src/voice/audio-playback-manager.ts +120 -98
  209. package/src/voice/browser-voice-provider.ts +37 -37
  210. package/src/voice/fallback-speech-engine.ts +22 -16
  211. package/src/voice/keyed-voice-transcript.ts +314 -0
  212. package/src/voice/mic-state-styles.ts +182 -0
  213. package/src/voice/read-aloud-controller.ts +46 -44
  214. package/src/voice/runtype-speech-engine.ts +35 -33
  215. package/src/voice/runtype-voice-provider.ts +670 -189
  216. package/src/voice/session-voice-wiring.ts +266 -0
  217. package/src/voice/voice-delegation.test.ts +71 -0
  218. package/src/voice/voice-delegation.ts +364 -0
  219. package/src/voice/voice-turn-tracker.ts +6 -6
  220. package/src/voice/voice.test.ts +981 -8
  221. package/src/voice/worklet-playback-engine.test.ts +81 -0
  222. package/src/voice/worklet-playback-engine.ts +21 -3
  223. package/src/voice-runtime-loader.ts +4 -1
  224. package/src/voice-runtime.ts +7 -0
  225. package/src/webmcp-runtime-entry.ts +41 -39
  226. package/dist/approval-ui-3NMYNXBD.js +0 -1
  227. package/dist/chunk-5EIIHQLQ.js +0 -1
  228. package/dist/chunk-7CO4T5KB.js +0 -1
  229. package/dist/chunk-EFJBUH5F.js +0 -1
  230. package/dist/chunk-R2TMIMDI.js +0 -3
  231. package/dist/chunk-UTVLOTWB.js +0 -9
  232. package/dist/context-mentions-45MODWOY.js +0 -161
  233. package/dist/event-stream-view-GL3ADRY2.js +0 -1
  234. package/dist/runtype-tts-entry-UJAEF7NZ.js +0 -1
  235. package/dist/voice-runtime-7DA7MJH4.js +0 -1
  236. package/dist/webmcp-runtime-JI7T4QYF.js +0 -6
@@ -1,10 +1,10 @@
1
- var C=(e,t)=>{let a=document.createElement(e);return t&&(a.className=t),a};var ua=()=>document.createDocumentFragment();var Fe=(...e)=>e.filter(Boolean).join(" ");function re(e){let t=String(e).split(/[\\/]/);return t[t.length-1]??""}function ma(e){let t=re(e),a=t.lastIndexOf(".");return a<=0?"":t.slice(a+1).toLowerCase()}function He(e){if(typeof e!="string")return"";let t=e.indexOf(`
1
+ var C=(e,t)=>{let a=document.createElement(e);return t&&(a.className=t),a};var pa=()=>document.createDocumentFragment();var Fe=(...e)=>e.filter(Boolean).join(" ");function re(e){let t=String(e).split(/[\\/]/);return t[t.length-1]??""}function ma(e){let t=re(e),a=t.lastIndexOf(".");return a<=0?"":t.slice(a+1).toLowerCase()}function He(e){if(typeof e!="string")return"";let t=e.indexOf(`
2
2
  `);if(t===-1||!e.slice(0,t).startsWith("```"))return e;let o=e.slice(t+1),r=o.lastIndexOf(`
3
- `);return(r===-1?o:o.slice(0,r)).split("`\u200B``").join("```")}function ue(e){let t=ma(e.path);if(t)return t==="html"||t==="htm"?"html":t==="svg"?"svg":t==="md"||t==="mdx"?"markdown":"other";let a=(e.mimeType||"").toLowerCase();return a.includes("html")?"html":a.includes("svg")?"svg":a.includes("markdown")?"markdown":"other"}function de(e){switch(ue(e)){case"html":return"HTML";case"svg":return"SVG";case"markdown":return"Markdown";default:{let t=ma(e.path);return t?t.toUpperCase():"File"}}}function Oe(e){let t=e.markdown??"";return e.file?{filename:re(e.file.path)||"artifact",mime:e.file.mimeType||"application/octet-stream",content:He(t)}:{filename:`${e.title||"artifact"}.md`,mime:"text/markdown",content:t}}function Ie(e){let t=new Blob([e.content],{type:e.mime}),a=URL.createObjectURL(t),o=document.createElement("a");o.href=a,o.download=e.filename,o.click(),URL.revokeObjectURL(a)}var ne=(e,t=24,a="currentColor",o=2)=>{if(!Array.isArray(e))return null;let r=document.createElementNS("http://www.w3.org/2000/svg","svg");return r.setAttribute("width",String(t)),r.setAttribute("height",String(t)),r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("fill","none"),r.setAttribute("stroke",a),r.setAttribute("stroke-width",String(o)),r.setAttribute("stroke-linecap","round"),r.setAttribute("stroke-linejoin","round"),r.setAttribute("aria-hidden","true"),e.forEach(s=>{if(!Array.isArray(s)||s.length<2)return;let n=s[0],f=s[1];if(!f)return;let h=document.createElementNS("http://www.w3.org/2000/svg",n);Object.entries(f).forEach(([u,i])=>{u!=="stroke"&&h.setAttribute(u,String(i))}),r.appendChild(h)}),r};var qe=e=>{let{fallbackImport:t,resetOnSetLoader:a=!1}=e,o=null,r=null,s=null;return{setLoader:i=>{o=i,a&&(r=null,s=null)},load:()=>r?Promise.resolve(r):s||(s=(o??t)().then(d=>(r=d,d)).catch(d=>{throw s=null,d}),s),provide:i=>{r=i},getSync:()=>r}};var{setLoader:Ja,load:Qa}=qe({fallbackImport:()=>import("@runtypelabs/persona/icons-extra")}),ca=Ja,xa=Qa;var st=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"}]];var nt=[["path",{d:"M12 5v14"}],["path",{d:"m19 12-7 7-7-7"}]];var lt=[["path",{d:"m12 19-7-7 7-7"}],["path",{d:"M19 12H5"}]];var ft=[["path",{d:"M5 12h14"}],["path",{d:"m12 5 7 7-7 7"}]];var it=[["path",{d:"M7 7h10v10"}],["path",{d:"M7 17 17 7"}]];var dt=[["path",{d:"m5 12 7-7 7 7"}],["path",{d:"M12 19V5"}]];var pt=[["circle",{cx:"12",cy:"12",r:"4"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"}]];var ut=[["path",{d:"M12 8V4H8"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}],["path",{d:"M2 14h2"}],["path",{d:"M20 14h2"}],["path",{d:"M15 13v2"}],["path",{d:"M9 13v2"}]];var Ae=[["path",{d:"M20 6 9 17l-5-5"}]];var ve=[["path",{d:"m6 9 6 6 6-6"}]];var mt=[["path",{d:"m15 18-6-6 6-6"}]];var ct=[["path",{d:"m9 18 6-6-6-6"}]];var xt=[["path",{d:"m18 15-6-6-6 6"}]];var gt=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4"}],["path",{d:"M21 14H11"}],["path",{d:"m15 10-4 4 4 4"}]];var ht=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}]];var Ue=[["path",{d:"m18 16 4-4-4-4"}],["path",{d:"m6 8-4 4 4 4"}],["path",{d:"m14.5 4-5 16"}]];var Ct=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"}]];var yt=[["path",{d:"M12 15V3"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}],["path",{d:"m7 10 5 5 5-5"}]];var Ne=[["circle",{cx:"12",cy:"12",r:"1"}],["circle",{cx:"12",cy:"5",r:"1"}],["circle",{cx:"12",cy:"19",r:"1"}]];var Ve=[["circle",{cx:"12",cy:"12",r:"1"}],["circle",{cx:"19",cy:"12",r:"1"}],["circle",{cx:"5",cy:"12",r:"1"}]];var bt=[["path",{d:"M15 3h6v6"}],["path",{d:"M10 14 21 3"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}]];var wt=[["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"}]];var St=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 12.5 8 15l2 2.5"}],["path",{d:"m14 12.5 2 2.5-2 2.5"}]];var At=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M8 13h2"}],["path",{d:"M14 13h2"}],["path",{d:"M8 17h2"}],["path",{d:"M14 17h2"}]];var ke=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 9H8"}],["path",{d:"M16 13H8"}],["path",{d:"M16 17H8"}]];var vt=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}]];var kt=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}],["path",{d:"M3 3v5h5"}],["path",{d:"M12 7v5l4 2"}]];var Mt=[["path",{d:"M16 5h6"}],["path",{d:"M19 2v6"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"}],["circle",{cx:"9",cy:"9",r:"2"}]];var ze=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56"}]];var Lt=[["path",{d:"M12 2v4"}],["path",{d:"m16.2 7.8 2.9-2.9"}],["path",{d:"M18 12h4"}],["path",{d:"m16.2 16.2 2.9 2.9"}],["path",{d:"M12 18v4"}],["path",{d:"m4.9 19.1 2.9-2.9"}],["path",{d:"M2 12h4"}],["path",{d:"m4.9 4.9 2.9 2.9"}]];var Me=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3"}]];var Pt=[["path",{d:"M4 5h16"}],["path",{d:"M4 12h16"}],["path",{d:"M4 19h16"}]];var Tt=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"}]];var Rt=[["path",{d:"M12 19v3"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3"}]];var Le=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3"}]];var Bt=[["path",{d:"M5 12h14"}]];var We=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}],["path",{d:"M9 3v18"}]];var Et=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551"}]];var Dt=[["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"}]];var Ft=[["path",{d:"M5 12h14"}],["path",{d:"M12 5v14"}]];var Ht=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"}]];var Ot=[["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"}]];var It=[["path",{d:"m21 21-4.34-4.34"}],["circle",{cx:"11",cy:"11",r:"8"}]];var qt=[["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"}]];var Ut=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"M12 8v4"}],["path",{d:"M12 16h.01"}]];var Nt=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"m9 12 2 2 4-4"}]];var Ge=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"m14.5 9.5-5 5"}],["path",{d:"m9.5 9.5 5 5"}]];var Vt=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}]];var zt=[["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"}]];var Wt=[["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"}],["path",{d:"M17 14V2"}]];var Gt=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"}],["path",{d:"M7 10v12"}]];var _t=[["path",{d:"M10 11v6"}],["path",{d:"M14 11v6"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];var jt=[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];var Xt=[["path",{d:"M12 3v12"}],["path",{d:"m17 8-5-5-5 5"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}]];var Kt=[["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"}]];var Zt=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];var Ya={activity:st,"arrow-down":nt,"arrow-up":dt,"arrow-up-right":it,bot:ut,"chevron-down":ve,"chevron-up":xt,"chevron-right":ct,"chevron-left":mt,check:Ae,clipboard:ht,"clipboard-copy":gt,"code-xml":Ue,copy:Ct,file:vt,"file-code":St,"file-spreadsheet":At,"file-text":ke,"image-plus":Mt,loader:Lt,"loader-circle":ze,mic:Rt,paperclip:Et,quote:Ht,"refresh-cw":Ot,search:It,send:qt,"shield-alert":Ut,"shield-check":Nt,"shield-x":Ge,square:Vt,"thumbs-down":Wt,"thumbs-up":Gt,upload:Xt,"volume-2":Kt,x:Zt,"at-sign":pt,"arrow-left":lt,"arrow-right":ft,"external-link":bt,ellipsis:Ve,"ellipsis-vertical":Ne,menu:Pt,"panel-left":We,plus:Ft,minus:Bt,pencil:Dt,trash:jt,"trash-2":_t,download:yt,maximize:Me,minimize:Le,"message-square":Tt,star:zt,eye:wt,history:kt},er=["user","mail","phone","calendar","clock","building","map-pin","lock","key","credit-card","hash","globe","link","circle-check","circle-x","triangle-alert","info","ban","shield","house","pen-line","save","share","funnel","settings","rotate-cw","shopping-cart","shopping-bag","package","truck","tag","gift","receipt","wallet","store","dollar-sign","percent","play","pause","volume-x","camera","image","film","headphones","message-circle","bell","heart","eye-off","bookmark","calendar-days","timer","folder","folder-open","files","chart-column","sparkles","zap","sun","moon","flag","lightbulb","monitor","smartphone"],_e=new Map(Object.entries(Ya)),he=new Set,ga=!1,ha=new Set,tr=e=>{let t=[...ha];e&&ha.clear();for(let a of t)try{a()}catch{}};var ar=()=>{let e=0;for(let t of[...he]){let a=_e.get(t.name);if(!a)continue;he.delete(t),e++;let o=ne(a,t.size,t.color,t.strokeWidth);if(o)for(t.el.removeAttribute("data-persona-icon-pending");o.firstChild;)t.el.appendChild(o.firstChild)}return e};var $t=!1,rr=()=>{xa().then(e=>{if(!ga){for(let[t,a]of Object.entries(e.EXTRA_LUCIDE_ICONS))_e.has(t)||_e.set(t,a);ga=!0,ar(),tr(!0)}}).catch(e=>{$t=!0,console.warn("[Persona] Failed to load the icons-extra chunk",e)})},or=(e,t,a)=>{let o=document.createElementNS("http://www.w3.org/2000/svg","svg");return o.setAttribute("width",String(e)),o.setAttribute("height",String(e)),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("fill","none"),o.setAttribute("stroke",t),o.setAttribute("stroke-width",String(a)),o.setAttribute("stroke-linecap","round"),o.setAttribute("stroke-linejoin","round"),o.setAttribute("aria-hidden","true"),o.setAttribute("data-persona-icon-pending","true"),o},Pe=(e,t=24,a="currentColor",o=2)=>{let r=_e.get(e);if(r)return ne(r,t,a,o);if(er.includes(e)){$t&&($t=!1);let s=or(t,a,o);if(he.size>=500){let n=he.values().next().value;n&&he.delete(n)}return he.add({el:s,name:e,size:t,color:a,strokeWidth:o}),rr(),s}return console.warn(`Lucide icon "${e}" is not in the Persona registry. Register it via registerIcons(), or add it to packages/widget/src/utils/icons.ts (see docs/icon-registry-shortlist.md).`),null};var sr=1e5,Ca=sr+1;function ya(e){let{items:t,onSelect:a,anchor:o,position:r="bottom-left",portal:s,onOpenChange:n}=e,f=C("div","persona-dropdown-menu persona-hidden");f.setAttribute("role","menu"),f.setAttribute("data-persona-theme-zone","dropdown"),s?(f.style.position="fixed",f.style.zIndex=String(Ca)):(f.style.position="absolute",f.style.top="100%",f.style.marginTop="4px",r==="bottom-right"?f.style.right="0":f.style.left="0");for(let m of t){if(m.dividerBefore){let M=document.createElement("hr");f.appendChild(M)}let c=document.createElement("button");if(c.type="button",c.setAttribute("role","menuitem"),c.setAttribute("data-dropdown-item-id",m.id),m.destructive&&c.setAttribute("data-destructive",""),m.icon){let M=Pe(m.icon,16,"currentColor",1.5);M&&c.appendChild(M)}let v=document.createElement("span");v.textContent=m.label,c.appendChild(v),c.addEventListener("click",M=>{M.stopPropagation(),d(),a(m.id)}),f.appendChild(c)}let h=null;function u(){if(!s)return;let m=o.getBoundingClientRect();f.style.top=`${m.bottom+4}px`,r==="bottom-right"?(f.style.right=`${window.innerWidth-m.right}px`,f.style.left="auto"):(f.style.left=`${m.left}px`,f.style.right="auto")}function i(){let m=f.classList.contains("persona-hidden");u(),f.classList.remove("persona-hidden"),m&&n?.(!0),requestAnimationFrame(()=>{let c=v=>{!f.contains(v.target)&&!o.contains(v.target)&&d()};document.addEventListener("click",c,!0),h=()=>document.removeEventListener("click",c,!0)})}function d(){let m=!f.classList.contains("persona-hidden");f.classList.add("persona-hidden"),h?.(),h=null,m&&n?.(!1)}function x(){f.classList.contains("persona-hidden")?i():d()}function p(){d(),f.remove()}return s&&s.appendChild(f),{element:f,show:i,hide:d,toggle:x,destroy:p}}function V(e){let{icon:t,label:a,size:o,strokeWidth:r,className:s,chromeless:n,onClick:f,aria:h}=e,u=C("button",Fe(!n&&"persona-icon-btn",s));u.type="button",u.setAttribute("aria-label",a),u.title=a;let i=Pe(t,o??16,"currentColor",r??2);if(i&&u.appendChild(i),f&&u.addEventListener("click",f),h)for(let[d,x]of Object.entries(h))u.setAttribute(d,x);return u}function me(e){let{icon:t,label:a,variant:o="default",size:r="sm",iconSize:s,className:n,onClick:f,aria:h}=e,u="persona-label-btn";o!=="default"&&(u+=" persona-label-btn--"+o),u+=" persona-label-btn--"+r,n&&(u+=" "+n);let i=C("button",u);if(i.type="button",i.setAttribute("aria-label",a),t){let x=Pe(t,s??14,"currentColor",2);x&&i.appendChild(x)}let d=C("span");if(d.textContent=a,i.appendChild(d),f&&i.addEventListener("click",f),h)for(let[x,p]of Object.entries(h))i.setAttribute(x,p);return i}function je(e){let{items:t,selectedId:a,onSelect:o,className:r}=e,s=C("div","persona-toggle-group"+(r?" "+r:""));s.setAttribute("role","group");let n=a,f=[];function h(){for(let i of f)i.btn.setAttribute("aria-pressed",i.id===n?"true":"false")}for(let i of t){let d;i.icon?d=V({icon:i.icon,label:i.label,className:i.className,onClick:()=>{n=i.id,h(),o(i.id)}}):(d=C("button","persona-icon-btn"+(i.className?" "+i.className:"")),d.type="button",d.setAttribute("aria-label",i.label),d.title=i.label,d.textContent=i.label,d.addEventListener("click",()=>{n=i.id,h(),o(i.id)})),d.setAttribute("aria-pressed",i.id===n?"true":"false"),f.push({id:i.id,btn:d}),s.appendChild(d)}function u(i){n=i,h()}return{element:s,setSelected:u}}function ba(e){let{label:t,icon:a,iconSize:o,iconOnly:r,menuItems:s,onSelect:n,onPrimary:f,position:h="bottom-left",portal:u,chevronLabel:i="More options",chevronIconSize:d,className:x,primaryClassName:p,chevronClassName:m}=e,c=C("div","persona-split-btn"+(x?" "+x:"")),v={label:t,className:"persona-split-btn-primary"+(p?" "+p:""),onClick:f},M=r&&a?V({...v,icon:a,size:o??14}):me({...v,icon:a,iconSize:o??14}),S=V({icon:"chevron-down",label:i,size:d??14,className:"persona-split-btn-chevron"+(m?" "+m:""),aria:{"aria-haspopup":"true","aria-expanded":"false"}});c.append(M,S);let b=null,L=()=>{if(b)return b;let I=(typeof u=="function"?u():u)??void 0;return b=ya({items:s,onSelect:n,anchor:c,position:h,portal:I,onOpenChange:j=>{S.setAttribute("aria-expanded",j?"true":"false")}}),I||c.appendChild(b.element),b};return c.isConnected?L():requestAnimationFrame(()=>{b||L()}),S.addEventListener("click",I=>{I.stopPropagation(),L().toggle()}),{element:c,primaryButton:M,chevronButton:S,openMenu:()=>L().show(),closeMenu:()=>b?.hide(),toggleMenu:()=>L().toggle(),destroy:()=>{b?.destroy(),c.remove()}}}var Xe="persona-artifact-custom-action-btn";function Ce(e,t){let a=t?.documentChrome??!1,o;if(typeof e.icon=="function"){if(e.showLabel){let r="persona-label-btn persona-label-btn--sm "+Xe+(a?" persona-artifact-doc-copy-btn":"");o=C("button",r)}else{let r="persona-icon-btn "+Xe+(a?" persona-artifact-doc-icon-btn":"");o=C("button",r)}o.type="button",o.setAttribute("aria-label",e.label),o.title=e.label;try{let r=e.icon();r&&o.appendChild(r)}catch{}if(e.showLabel){let r=C("span");r.textContent=e.label,o.appendChild(r)}}else e.showLabel||!e.icon?o=me({icon:e.icon,label:e.label,className:Xe+(a?" persona-artifact-doc-copy-btn":"")}):o=V({icon:e.icon,label:e.label,className:Xe+(a?" persona-artifact-doc-icon-btn":"")});return t?.onClick&&o.addEventListener("click",t.onClick),o}function Te(e){if(!e)return null;let t={artifactId:e.id,title:e.title??"",artifactType:e.artifactType};return e.artifactType==="markdown"?(t.markdown=e.markdown??"",e.file&&(t.file=e.file)):t.jsonPayload=JSON.stringify({component:e.component,props:e.props},null,2),t}var Jt="http://www.w3.org/2000/svg";function wa(e){let t=document.createElementNS(Jt,"svg");t.setAttribute("class",Fe("persona-spinner",e)),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("aria-hidden","true"),t.setAttribute("focusable","false");let a=document.createElementNS(Jt,"circle");a.setAttribute("class","persona-spinner-track"),a.setAttribute("cx","12"),a.setAttribute("cy","12"),a.setAttribute("r","9");let o=document.createElementNS(Jt,"circle");return o.setAttribute("class","persona-spinner-arc"),o.setAttribute("cx","12"),o.setAttribute("cy","12"),o.setAttribute("r","9"),t.appendChild(a),t.appendChild(o),t}var Sa=(e,t,a)=>{let o=a;for(let r of t){let s=C("span","persona-tool-char");s.style.setProperty("--char-index",String(o)),s.textContent=r===" "?"\xA0":r,e.appendChild(s),o++}return o};function Aa(e,t,a){let o=a?.loadingAnimation??"shimmer",r=a?.loadingAnimationDuration??2e3;if(o==="none"){e.textContent=t;return}if(o==="pulse"){e.setAttribute("data-preserve-animation","true"),e.classList.add("persona-tool-loading-pulse"),e.style.setProperty("--persona-tool-anim-duration",`${r}ms`),e.textContent=t;return}e.setAttribute("data-preserve-animation","true"),e.classList.add(`persona-tool-loading-${o}`),e.style.setProperty("--persona-tool-anim-duration",`${r}ms`),o==="shimmer-color"&&(a?.loadingAnimationColor&&e.style.setProperty("--persona-tool-anim-color",a.loadingAnimationColor),a?.loadingAnimationSecondaryColor&&e.style.setProperty("--persona-tool-anim-secondary-color",a.loadingAnimationSecondaryColor)),Sa(e,t,0)}var Qt="persona-artifact-status-label",va="persona-artifact-status-detail",ka="data-artifact-status-label",Yt=new Map,Ma=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();function ye(e){e&&Yt.delete(e)}function nr(e){let t=e.artifactType==="markdown"?e.file:void 0;return t?de(t):e.artifactType==="component"?"Component":"Document"}function be(e,t,a){let o=nr(e),r=`Generating ${o.toLowerCase()}...`,s=t?.statusLabel;if(typeof s=="string")return{label:s};if(typeof s!="function")return{label:r};let n=e.id,f=Yt.get(n);e.status!=="complete"&&f===void 0&&(f=Ma(),Yt.set(n,f));let h=f===void 0?0:Math.max(0,Ma()-f),u=e.artifactType==="component",i=!u&&typeof e.markdown=="string"?e.markdown:"",d=u?0:i.length,x=u||i===""?0:i.split(`
4
- `).length,p=e.artifactType==="markdown"?e.file:void 0,m={artifactId:n,artifactType:e.artifactType,title:e.title,typeLabel:o,file:p,chars:d,lines:x,elapsedMs:h,content:()=>u?"":i,surface:a};try{let c=s(m);return typeof c=="string"?{label:c}:c&&typeof c=="object"&&typeof c.label=="string"?{label:c.label,detail:typeof c.detail=="string"?c.detail:void 0}:{label:r}}catch{return{label:r}}}function lr(e){e.className=Qt,e.removeAttribute("data-preserve-animation"),e.style.removeProperty("--persona-tool-anim-duration"),e.style.removeProperty("--persona-tool-anim-color"),e.style.removeProperty("--persona-tool-anim-secondary-color"),e.replaceChildren()}function ce(e,t,a){let o=e.querySelector(`:scope > .${Qt}`);o||(o=C("span",Qt),e.appendChild(o)),o.getAttribute(ka)!==t.label&&(lr(o),Aa(o,t.label,a),o.setAttribute(ka,t.label));let r=e.querySelector(`:scope > .${va}`),s=t.detail;s?(r||(r=C("span",va),e.appendChild(r)),r.textContent!==s&&(r.textContent=s)):r&&r.remove()}var fr={keyword:"persona-code-token-keyword",string:"persona-code-token-string",comment:"persona-code-token-comment",number:"persona-code-token-number",tag:"persona-code-token-tag",attr:"persona-code-token-attr",property:"persona-code-token-property"},ir=15e4,Ke={html:"html",htm:"html",xhtml:"html",xml:"html",svg:"html",css:"css",js:"js",jsx:"js",mjs:"js",cjs:"js",ts:"js",tsx:"js",mts:"js",cts:"js",javascript:"js",typescript:"js",ecmascript:"js",json:"json",jsonc:"json",json5:"json"};function dr(e,t){let a=(e||"").trim().toLowerCase();if(a&&Ke[a])return Ke[a];if(t){let o=t.lastIndexOf(".");if(o>=0){let r=t.slice(o+1).toLowerCase();if(Ke[r])return Ke[r]}}return null}function Ze(e,t){let a=[],o=0,r=0,s=n=>{n>r&&a.push({type:"plain",value:e.slice(r,n)})};for(;o<e.length;){let n=!1;for(let f of t){f.re.lastIndex=o;let h=f.re.exec(e);if(h&&h.index===o&&h[0].length>0){s(o);let u=f.map?f.map(h[0]):f.type;a.push({type:u,value:h[0]}),o+=h[0].length,r=o,n=!0;break}}n||(o+=1)}return s(e.length),a}var pr=new Set(["abstract","any","as","async","await","boolean","break","case","catch","class","const","continue","debugger","declare","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","implements","import","in","instanceof","interface","keyof","let","namespace","never","new","null","number","object","of","private","protected","public","readonly","return","satisfies","set","static","string","super","switch","symbol","this","throw","true","try","type","typeof","undefined","unknown","var","void","while","yield"]),ur=[{type:"comment",re:/\/\/[^\n]*/y},{type:"comment",re:/\/\*[\s\S]*?\*\//y},{type:"string",re:/`(?:\\[\s\S]|[^\\`])*`/y},{type:"string",re:/"(?:\\.|[^"\\\n])*"/y},{type:"string",re:/'(?:\\.|[^'\\\n])*'/y},{type:"number",re:/0[xX][0-9a-fA-F]+|(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/y},{type:"plain",re:/[A-Za-z_$][\w$]*/y,map:e=>pr.has(e)?"keyword":"plain"}];function La(e){return Ze(e,ur)}var mr=[{type:"string",re:/"(?:\\.|[^"\\])*"/y},{type:"number",re:/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/y},{type:"plain",re:/[A-Za-z_]\w*/y,map:e=>e==="true"||e==="false"||e==="null"?"keyword":"plain"}];function cr(e){let t=Ze(e,mr);for(let a=0;a<t.length;a+=1){if(t[a].type!=="string")continue;let o=a+1;for(;o<t.length&&t[o].value.trim()==="";)o+=1;let r=t[o];r&&r.value.replace(/^\s*/,"").startsWith(":")&&(t[a].type="property")}return t}var xr=[{type:"comment",re:/\/\*[\s\S]*?\*\//y},{type:"string",re:/"(?:\\.|[^"\\\n])*"/y},{type:"string",re:/'(?:\\.|[^'\\\n])*'/y},{type:"keyword",re:/@[A-Za-z-]+/y},{type:"number",re:/#[0-9a-fA-F]{3,8}\b/y},{type:"number",re:/-?(?:\d+\.?\d*|\.\d+)(?:[a-z%]+)?/y},{type:"plain",re:/[A-Za-z_-][\w-]*/y}];function Pa(e){let t=Ze(e,xr),a="";for(let o=0;o<t.length;o+=1){let r=t[o];if(r.type==="plain"&&/^[A-Za-z_-][\w-]*$/.test(r.value)){let n=o+1;for(;n<t.length&&t[n].value.trim()==="";)n+=1;let f=t[n];f&&f.value.replace(/^\s*/,"").startsWith(":")&&(a===""||a==="{"||a==="}"||a===";"||a===",")&&(r.type="property")}let s=r.value.replace(/\s+$/,"");s&&(a=s[s.length-1])}return t}var gr=[{type:"tag",re:/<\/?\s*[A-Za-z][\w:-]*/y},{type:"string",re:/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'/y},{type:"attr",re:/[A-Za-z_:@][\w:.-]*(?=\s*=)/y},{type:"attr",re:/[A-Za-z_:@][\w:.-]*/y},{type:"tag",re:/\/?>/y}];function hr(e){let t=[],a=(s,n)=>{n&&t.push({type:s,value:n})},o=e.length,r=0;for(;r<o;){if(e.startsWith("<!--",r)){let n=e.indexOf("-->",r+4),f=n===-1?o:n+3;a("comment",e.slice(r,f)),r=f;continue}if(e[r]==="<"&&e[r+1]==="!"){let n=e.indexOf(">",r),f=n===-1?o:n+1;a("tag",e.slice(r,f)),r=f;continue}if(e[r]==="<"&&/[A-Za-z/]/.test(e[r+1]||"")){let n=e.indexOf(">",r),f=n===-1?o:n+1,h=e.slice(r,f);for(let i of Ze(h,gr))t.push(i);r=f;let u=/^<\s*(script|style)\b/i.exec(h);if(u&&!/\/>\s*$/.test(h)){let i=u[1].toLowerCase(),x=new RegExp("</\\s*"+i+"\\s*>","i").exec(e.slice(r)),p=x?r+x.index:o,m=e.slice(r,p),c=i==="script"?La(m):Pa(m);for(let v of c)t.push(v);r=p}continue}let s=e.indexOf("<",r);if(s===r)a("plain",e[r]),r+=1;else{let n=s===-1?o:s;a("plain",e.slice(r,n)),r=n}}return t}function Cr(e,t){switch(t){case"html":return hr(e);case"css":return Pa(e);case"js":return La(e);case"json":return cr(e)}}function yr(e){let t=ua(),a=C("span","persona-code-line"),o=(r,s)=>{if(!s)return;let n=fr[r];if(n){let f=C("span",n);f.textContent=s,a.appendChild(f)}else a.appendChild(document.createTextNode(s))};for(let r of e){let s=r.value.split(`
3
+ `);return(r===-1?o:o.slice(0,r)).split("`\u200B``").join("```")}function pe(e){let t=ma(e.path);if(t)return t==="html"||t==="htm"?"html":t==="svg"?"svg":t==="md"||t==="mdx"?"markdown":"other";let a=(e.mimeType||"").toLowerCase();return a.includes("html")?"html":a.includes("svg")?"svg":a.includes("markdown")?"markdown":"other"}function de(e){switch(pe(e)){case"html":return"HTML";case"svg":return"SVG";case"markdown":return"Markdown";default:{let t=ma(e.path);return t?t.toUpperCase():"File"}}}function Oe(e){let t=e.markdown??"";return e.file?{filename:re(e.file.path)||"artifact",mime:e.file.mimeType||"application/octet-stream",content:He(t)}:{filename:`${e.title||"artifact"}.md`,mime:"text/markdown",content:t}}function Ie(e){let t=new Blob([e.content],{type:e.mime}),a=URL.createObjectURL(t),o=document.createElement("a");o.href=a,o.download=e.filename,o.click(),URL.revokeObjectURL(a)}var ne=(e,t=24,a="currentColor",o=2)=>{if(!Array.isArray(e))return null;let r=document.createElementNS("http://www.w3.org/2000/svg","svg");return r.setAttribute("width",String(t)),r.setAttribute("height",String(t)),r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("fill","none"),r.setAttribute("stroke",a),r.setAttribute("stroke-width",String(o)),r.setAttribute("stroke-linecap","round"),r.setAttribute("stroke-linejoin","round"),r.setAttribute("aria-hidden","true"),e.forEach(s=>{if(!Array.isArray(s)||s.length<2)return;let n=s[0],f=s[1];if(!f)return;let h=document.createElementNS("http://www.w3.org/2000/svg",n);Object.entries(f).forEach(([p,i])=>{p!=="stroke"&&h.setAttribute(p,String(i))}),r.appendChild(h)}),r};var qe=e=>{let{fallbackImport:t,resetOnSetLoader:a=!1}=e,o=null,r=null,s=null;return{setLoader:i=>{o=i,a&&(r=null,s=null)},load:()=>r?Promise.resolve(r):s||(s=(o??t)().then(d=>(r=d,d)).catch(d=>{throw s=null,d}),s),provide:i=>{r=i},getSync:()=>r}};var{setLoader:Ja,load:Qa}=qe({fallbackImport:()=>import("@runtypelabs/persona/icons-extra")}),ca=Ja,xa=Qa;var st=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"}]];var nt=[["path",{d:"M12 5v14"}],["path",{d:"m19 12-7 7-7-7"}]];var lt=[["path",{d:"m12 19-7-7 7-7"}],["path",{d:"M19 12H5"}]];var ft=[["path",{d:"M5 12h14"}],["path",{d:"m12 5 7 7-7 7"}]];var it=[["path",{d:"M7 7h10v10"}],["path",{d:"M7 17 17 7"}]];var dt=[["path",{d:"m5 12 7-7 7 7"}],["path",{d:"M12 19V5"}]];var ut=[["circle",{cx:"12",cy:"12",r:"4"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"}]];var pt=[["path",{d:"M12 8V4H8"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}],["path",{d:"M2 14h2"}],["path",{d:"M20 14h2"}],["path",{d:"M15 13v2"}],["path",{d:"M9 13v2"}]];var Ae=[["path",{d:"M20 6 9 17l-5-5"}]];var ve=[["path",{d:"m6 9 6 6 6-6"}]];var mt=[["path",{d:"m15 18-6-6 6-6"}]];var ct=[["path",{d:"m9 18 6-6-6-6"}]];var xt=[["path",{d:"m18 15-6-6-6 6"}]];var gt=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4"}],["path",{d:"M21 14H11"}],["path",{d:"m15 10-4 4 4 4"}]];var ht=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}]];var Ue=[["path",{d:"m18 16 4-4-4-4"}],["path",{d:"m6 8-4 4 4 4"}],["path",{d:"m14.5 4-5 16"}]];var Ct=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"}]];var yt=[["path",{d:"M12 15V3"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}],["path",{d:"m7 10 5 5 5-5"}]];var Ne=[["circle",{cx:"12",cy:"12",r:"1"}],["circle",{cx:"12",cy:"5",r:"1"}],["circle",{cx:"12",cy:"19",r:"1"}]];var Ve=[["circle",{cx:"12",cy:"12",r:"1"}],["circle",{cx:"19",cy:"12",r:"1"}],["circle",{cx:"5",cy:"12",r:"1"}]];var bt=[["path",{d:"M15 3h6v6"}],["path",{d:"M10 14 21 3"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}]];var wt=[["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"}]];var St=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 12.5 8 15l2 2.5"}],["path",{d:"m14 12.5 2 2.5-2 2.5"}]];var At=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M8 13h2"}],["path",{d:"M14 13h2"}],["path",{d:"M8 17h2"}],["path",{d:"M14 17h2"}]];var ke=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 9H8"}],["path",{d:"M16 13H8"}],["path",{d:"M16 17H8"}]];var vt=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}]];var kt=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}],["path",{d:"M3 3v5h5"}],["path",{d:"M12 7v5l4 2"}]];var Mt=[["path",{d:"M16 5h6"}],["path",{d:"M19 2v6"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"}],["circle",{cx:"9",cy:"9",r:"2"}]];var ze=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56"}]];var Lt=[["path",{d:"M12 2v4"}],["path",{d:"m16.2 7.8 2.9-2.9"}],["path",{d:"M18 12h4"}],["path",{d:"m16.2 16.2 2.9 2.9"}],["path",{d:"M12 18v4"}],["path",{d:"m4.9 19.1 2.9-2.9"}],["path",{d:"M2 12h4"}],["path",{d:"m4.9 4.9 2.9 2.9"}]];var Me=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3"}]];var Pt=[["path",{d:"M4 5h16"}],["path",{d:"M4 12h16"}],["path",{d:"M4 19h16"}]];var Tt=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"}]];var Rt=[["path",{d:"M12 19v3"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3"}]];var Le=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3"}]];var Et=[["path",{d:"M5 12h14"}]];var We=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}],["path",{d:"M9 3v18"}]];var Bt=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551"}]];var Dt=[["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"}]];var Ft=[["path",{d:"M5 12h14"}],["path",{d:"M12 5v14"}]];var Ht=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"}]];var Ot=[["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"}]];var It=[["path",{d:"m21 21-4.34-4.34"}],["circle",{cx:"11",cy:"11",r:"8"}]];var qt=[["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"}]];var Ut=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"M12 8v4"}],["path",{d:"M12 16h.01"}]];var Nt=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"m9 12 2 2 4-4"}]];var Ge=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}],["path",{d:"m14.5 9.5-5 5"}],["path",{d:"m9.5 9.5 5 5"}]];var Vt=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}]];var zt=[["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"}]];var Wt=[["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"}],["path",{d:"M17 14V2"}]];var Gt=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"}],["path",{d:"M7 10v12"}]];var _t=[["path",{d:"M10 11v6"}],["path",{d:"M14 11v6"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];var jt=[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];var Xt=[["path",{d:"M12 3v12"}],["path",{d:"m17 8-5-5-5 5"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}]];var Kt=[["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"}]];var Zt=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];var Ya={activity:st,"arrow-down":nt,"arrow-up":dt,"arrow-up-right":it,bot:pt,"chevron-down":ve,"chevron-up":xt,"chevron-right":ct,"chevron-left":mt,check:Ae,clipboard:ht,"clipboard-copy":gt,"code-xml":Ue,copy:Ct,file:vt,"file-code":St,"file-spreadsheet":At,"file-text":ke,"image-plus":Mt,loader:Lt,"loader-circle":ze,mic:Rt,paperclip:Bt,quote:Ht,"refresh-cw":Ot,search:It,send:qt,"shield-alert":Ut,"shield-check":Nt,"shield-x":Ge,square:Vt,"thumbs-down":Wt,"thumbs-up":Gt,upload:Xt,"volume-2":Kt,x:Zt,"at-sign":ut,"arrow-left":lt,"arrow-right":ft,"external-link":bt,ellipsis:Ve,"ellipsis-vertical":Ne,menu:Pt,"panel-left":We,plus:Ft,minus:Et,pencil:Dt,trash:jt,"trash-2":_t,download:yt,maximize:Me,minimize:Le,"message-square":Tt,star:zt,eye:wt,history:kt},er=["user","mail","phone","calendar","clock","building","map-pin","lock","key","credit-card","hash","globe","link","circle-check","circle-x","triangle-alert","info","ban","shield","house","pen-line","save","share","funnel","settings","rotate-cw","shopping-cart","shopping-bag","package","truck","tag","gift","receipt","wallet","store","dollar-sign","percent","play","pause","volume-x","camera","image","film","headphones","message-circle","bell","heart","eye-off","bookmark","calendar-days","timer","folder","folder-open","files","chart-column","sparkles","zap","sun","moon","flag","lightbulb","monitor","smartphone"],_e=new Map(Object.entries(Ya)),he=new Set,ga=!1,ha=new Set,tr=e=>{let t=[...ha];e&&ha.clear();for(let a of t)try{a()}catch{}};var ar=()=>{let e=0;for(let t of[...he]){let a=_e.get(t.name);if(!a)continue;he.delete(t),e++;let o=ne(a,t.size,t.color,t.strokeWidth);if(o)for(t.el.removeAttribute("data-persona-icon-pending");o.firstChild;)t.el.appendChild(o.firstChild)}return e};var $t=!1,rr=()=>{xa().then(e=>{if(!ga){for(let[t,a]of Object.entries(e.EXTRA_LUCIDE_ICONS))_e.has(t)||_e.set(t,a);ga=!0,ar(),tr(!0)}}).catch(e=>{$t=!0,console.warn("[Persona] Failed to load the icons-extra chunk",e)})},or=(e,t,a)=>{let o=document.createElementNS("http://www.w3.org/2000/svg","svg");return o.setAttribute("width",String(e)),o.setAttribute("height",String(e)),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("fill","none"),o.setAttribute("stroke",t),o.setAttribute("stroke-width",String(a)),o.setAttribute("stroke-linecap","round"),o.setAttribute("stroke-linejoin","round"),o.setAttribute("aria-hidden","true"),o.setAttribute("data-persona-icon-pending","true"),o},Pe=(e,t=24,a="currentColor",o=2)=>{let r=_e.get(e);if(r)return ne(r,t,a,o);if(er.includes(e)){$t&&($t=!1);let s=or(t,a,o);if(he.size>=500){let n=he.values().next().value;n&&he.delete(n)}return he.add({el:s,name:e,size:t,color:a,strokeWidth:o}),rr(),s}return console.warn(`Lucide icon "${e}" is not in the Persona registry. Register it via registerIcons(), or add it to packages/widget/src/utils/icons.ts (see docs/icon-registry-shortlist.md).`),null};var sr=1e5,Ca=sr+1;function ya(e){let{items:t,onSelect:a,anchor:o,position:r="bottom-left",portal:s,onOpenChange:n}=e,f=C("div","persona-dropdown-menu persona-hidden");f.setAttribute("role","menu"),f.setAttribute("data-persona-theme-zone","dropdown"),s?(f.style.position="fixed",f.style.zIndex=String(Ca)):(f.style.position="absolute",f.style.top="100%",f.style.marginTop="4px",r==="bottom-right"?f.style.right="0":f.style.left="0");for(let m of t){if(m.dividerBefore){let M=document.createElement("hr");f.appendChild(M)}let c=document.createElement("button");if(c.type="button",c.setAttribute("role","menuitem"),c.setAttribute("data-dropdown-item-id",m.id),m.destructive&&c.setAttribute("data-destructive",""),m.icon){let M=Pe(m.icon,16,"currentColor",1.5);M&&c.appendChild(M)}let v=document.createElement("span");v.textContent=m.label,c.appendChild(v),c.addEventListener("click",M=>{M.stopPropagation(),d(),a(m.id)}),f.appendChild(c)}let h=null;function p(){if(!s)return;let m=o.getBoundingClientRect();f.style.top=`${m.bottom+4}px`,r==="bottom-right"?(f.style.right=`${window.innerWidth-m.right}px`,f.style.left="auto"):(f.style.left=`${m.left}px`,f.style.right="auto")}function i(){let m=f.classList.contains("persona-hidden");p(),f.classList.remove("persona-hidden"),m&&n?.(!0),requestAnimationFrame(()=>{let c=v=>{!f.contains(v.target)&&!o.contains(v.target)&&d()};document.addEventListener("click",c,!0),h=()=>document.removeEventListener("click",c,!0)})}function d(){let m=!f.classList.contains("persona-hidden");f.classList.add("persona-hidden"),h?.(),h=null,m&&n?.(!1)}function x(){f.classList.contains("persona-hidden")?i():d()}function u(){d(),f.remove()}return s&&s.appendChild(f),{element:f,show:i,hide:d,toggle:x,destroy:u}}function V(e){let{icon:t,label:a,size:o,strokeWidth:r,className:s,chromeless:n,onClick:f,aria:h}=e,p=C("button",Fe(!n&&"persona-icon-btn",s));p.type="button",p.setAttribute("aria-label",a),p.title=a;let i=Pe(t,o??16,"currentColor",r??2);if(i&&p.appendChild(i),f&&p.addEventListener("click",f),h)for(let[d,x]of Object.entries(h))p.setAttribute(d,x);return p}function me(e){let{icon:t,label:a,variant:o="default",size:r="sm",iconSize:s,className:n,onClick:f,aria:h}=e,p="persona-label-btn";o!=="default"&&(p+=" persona-label-btn--"+o),p+=" persona-label-btn--"+r,n&&(p+=" "+n);let i=C("button",p);if(i.type="button",i.setAttribute("aria-label",a),t){let x=Pe(t,s??14,"currentColor",2);x&&i.appendChild(x)}let d=C("span");if(d.textContent=a,i.appendChild(d),f&&i.addEventListener("click",f),h)for(let[x,u]of Object.entries(h))i.setAttribute(x,u);return i}function je(e){let{items:t,selectedId:a,onSelect:o,className:r}=e,s=C("div","persona-toggle-group"+(r?" "+r:""));s.setAttribute("role","group");let n=a,f=[];function h(){for(let i of f)i.btn.setAttribute("aria-pressed",i.id===n?"true":"false")}for(let i of t){let d;i.icon?d=V({icon:i.icon,label:i.label,className:i.className,onClick:()=>{n=i.id,h(),o(i.id)}}):(d=C("button","persona-icon-btn"+(i.className?" "+i.className:"")),d.type="button",d.setAttribute("aria-label",i.label),d.title=i.label,d.textContent=i.label,d.addEventListener("click",()=>{n=i.id,h(),o(i.id)})),d.setAttribute("aria-pressed",i.id===n?"true":"false"),f.push({id:i.id,btn:d}),s.appendChild(d)}function p(i){n=i,h()}return{element:s,setSelected:p}}function ba(e){let{label:t,icon:a,iconSize:o,iconOnly:r,menuItems:s,onSelect:n,onPrimary:f,position:h="bottom-left",portal:p,chevronLabel:i="More options",chevronIconSize:d,className:x,primaryClassName:u,chevronClassName:m}=e,c=C("div","persona-split-btn"+(x?" "+x:"")),v={label:t,className:"persona-split-btn-primary"+(u?" "+u:""),onClick:f},M=r&&a?V({...v,icon:a,size:o??14}):me({...v,icon:a,iconSize:o??14}),S=V({icon:"chevron-down",label:i,size:d??14,className:"persona-split-btn-chevron"+(m?" "+m:""),aria:{"aria-haspopup":"true","aria-expanded":"false"}});c.append(M,S);let b=null,L=()=>{if(b)return b;let I=(typeof p=="function"?p():p)??void 0;return b=ya({items:s,onSelect:n,anchor:c,position:h,portal:I,onOpenChange:j=>{S.setAttribute("aria-expanded",j?"true":"false")}}),I||c.appendChild(b.element),b};return c.isConnected?L():requestAnimationFrame(()=>{b||L()}),S.addEventListener("click",I=>{I.stopPropagation(),L().toggle()}),{element:c,primaryButton:M,chevronButton:S,openMenu:()=>L().show(),closeMenu:()=>b?.hide(),toggleMenu:()=>L().toggle(),destroy:()=>{b?.destroy(),c.remove()}}}var Xe="persona-artifact-custom-action-btn";function Ce(e,t){let a=t?.documentChrome??!1,o;if(typeof e.icon=="function"){if(e.showLabel){let r="persona-label-btn persona-label-btn--sm "+Xe+(a?" persona-artifact-doc-copy-btn":"");o=C("button",r)}else{let r="persona-icon-btn "+Xe+(a?" persona-artifact-doc-icon-btn":"");o=C("button",r)}o.type="button",o.setAttribute("aria-label",e.label),o.title=e.label;try{let r=e.icon();r&&o.appendChild(r)}catch{}if(e.showLabel){let r=C("span");r.textContent=e.label,o.appendChild(r)}}else e.showLabel||!e.icon?o=me({icon:e.icon,label:e.label,className:Xe+(a?" persona-artifact-doc-copy-btn":"")}):o=V({icon:e.icon,label:e.label,className:Xe+(a?" persona-artifact-doc-icon-btn":"")});return t?.onClick&&o.addEventListener("click",t.onClick),o}function Te(e){if(!e)return null;let t={artifactId:e.id,title:e.title??"",artifactType:e.artifactType};return e.artifactType==="markdown"?(t.markdown=e.markdown??"",e.file&&(t.file=e.file)):t.jsonPayload=JSON.stringify({component:e.component,props:e.props},null,2),t}var Jt="http://www.w3.org/2000/svg";function wa(e){let t=document.createElementNS(Jt,"svg");t.setAttribute("class",Fe("persona-spinner",e)),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("aria-hidden","true"),t.setAttribute("focusable","false");let a=document.createElementNS(Jt,"circle");a.setAttribute("class","persona-spinner-track"),a.setAttribute("cx","12"),a.setAttribute("cy","12"),a.setAttribute("r","9");let o=document.createElementNS(Jt,"circle");return o.setAttribute("class","persona-spinner-arc"),o.setAttribute("cx","12"),o.setAttribute("cy","12"),o.setAttribute("r","9"),t.appendChild(a),t.appendChild(o),t}var Sa=(e,t,a)=>{let o=a;for(let r of t){let s=C("span","persona-tool-char");s.style.setProperty("--char-index",String(o)),s.textContent=r===" "?"\xA0":r,e.appendChild(s),o++}return o};function Aa(e,t,a){let o=a?.loadingAnimation??"shimmer",r=a?.loadingAnimationDuration??2e3;if(o==="none"){e.textContent=t;return}if(o==="pulse"){e.setAttribute("data-preserve-animation","true"),e.classList.add("persona-tool-loading-pulse"),e.style.setProperty("--persona-tool-anim-duration",`${r}ms`),e.textContent=t;return}e.setAttribute("data-preserve-animation","true"),e.classList.add(`persona-tool-loading-${o}`),e.style.setProperty("--persona-tool-anim-duration",`${r}ms`),o==="shimmer-color"&&(a?.loadingAnimationColor&&e.style.setProperty("--persona-tool-anim-color",a.loadingAnimationColor),a?.loadingAnimationSecondaryColor&&e.style.setProperty("--persona-tool-anim-secondary-color",a.loadingAnimationSecondaryColor)),Sa(e,t,0)}var Qt="persona-artifact-status-label",va="persona-artifact-status-detail",ka="data-artifact-status-label",Yt=new Map,Ma=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();function ye(e){e&&Yt.delete(e)}function nr(e){let t=e.artifactType==="markdown"?e.file:void 0;return t?de(t):e.artifactType==="component"?"Component":"Document"}function be(e,t,a){let o=nr(e),r=`Generating ${o.toLowerCase()}...`,s=t?.statusLabel;if(typeof s=="string")return{label:s};if(typeof s!="function")return{label:r};let n=e.id,f=Yt.get(n);e.status!=="complete"&&f===void 0&&(f=Ma(),Yt.set(n,f));let h=f===void 0?0:Math.max(0,Ma()-f),p=e.artifactType==="component",i=!p&&typeof e.markdown=="string"?e.markdown:"",d=p?0:i.length,x=p||i===""?0:i.split(`
4
+ `).length,u=e.artifactType==="markdown"?e.file:void 0,m={artifactId:n,artifactType:e.artifactType,title:e.title,typeLabel:o,file:u,chars:d,lines:x,elapsedMs:h,content:()=>p?"":i,surface:a};try{let c=s(m);return typeof c=="string"?{label:c}:c&&typeof c=="object"&&typeof c.label=="string"?{label:c.label,detail:typeof c.detail=="string"?c.detail:void 0}:{label:r}}catch{return{label:r}}}function lr(e){e.className=Qt,e.removeAttribute("data-preserve-animation"),e.style.removeProperty("--persona-tool-anim-duration"),e.style.removeProperty("--persona-tool-anim-color"),e.style.removeProperty("--persona-tool-anim-secondary-color"),e.replaceChildren()}function ce(e,t,a){let o=e.querySelector(`:scope > .${Qt}`);o||(o=C("span",Qt),e.appendChild(o)),o.getAttribute(ka)!==t.label&&(lr(o),Aa(o,t.label,a),o.setAttribute(ka,t.label));let r=e.querySelector(`:scope > .${va}`),s=t.detail;s?(r||(r=C("span",va),e.appendChild(r)),r.textContent!==s&&(r.textContent=s)):r&&r.remove()}var fr={keyword:"persona-code-token-keyword",string:"persona-code-token-string",comment:"persona-code-token-comment",number:"persona-code-token-number",tag:"persona-code-token-tag",attr:"persona-code-token-attr",property:"persona-code-token-property"},ir=15e4,Ke={html:"html",htm:"html",xhtml:"html",xml:"html",svg:"html",css:"css",js:"js",jsx:"js",mjs:"js",cjs:"js",ts:"js",tsx:"js",mts:"js",cts:"js",javascript:"js",typescript:"js",ecmascript:"js",json:"json",jsonc:"json",json5:"json"};function dr(e,t){let a=(e||"").trim().toLowerCase();if(a&&Ke[a])return Ke[a];if(t){let o=t.lastIndexOf(".");if(o>=0){let r=t.slice(o+1).toLowerCase();if(Ke[r])return Ke[r]}}return null}function Ze(e,t){let a=[],o=0,r=0,s=n=>{n>r&&a.push({type:"plain",value:e.slice(r,n)})};for(;o<e.length;){let n=!1;for(let f of t){f.re.lastIndex=o;let h=f.re.exec(e);if(h&&h.index===o&&h[0].length>0){s(o);let p=f.map?f.map(h[0]):f.type;a.push({type:p,value:h[0]}),o+=h[0].length,r=o,n=!0;break}}n||(o+=1)}return s(e.length),a}var ur=new Set(["abstract","any","as","async","await","boolean","break","case","catch","class","const","continue","debugger","declare","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","implements","import","in","instanceof","interface","keyof","let","namespace","never","new","null","number","object","of","private","protected","public","readonly","return","satisfies","set","static","string","super","switch","symbol","this","throw","true","try","type","typeof","undefined","unknown","var","void","while","yield"]),pr=[{type:"comment",re:/\/\/[^\n]*/y},{type:"comment",re:/\/\*[\s\S]*?\*\//y},{type:"string",re:/`(?:\\[\s\S]|[^\\`])*`/y},{type:"string",re:/"(?:\\.|[^"\\\n])*"/y},{type:"string",re:/'(?:\\.|[^'\\\n])*'/y},{type:"number",re:/0[xX][0-9a-fA-F]+|(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/y},{type:"plain",re:/[A-Za-z_$][\w$]*/y,map:e=>ur.has(e)?"keyword":"plain"}];function La(e){return Ze(e,pr)}var mr=[{type:"string",re:/"(?:\\.|[^"\\])*"/y},{type:"number",re:/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/y},{type:"plain",re:/[A-Za-z_]\w*/y,map:e=>e==="true"||e==="false"||e==="null"?"keyword":"plain"}];function cr(e){let t=Ze(e,mr);for(let a=0;a<t.length;a+=1){if(t[a].type!=="string")continue;let o=a+1;for(;o<t.length&&t[o].value.trim()==="";)o+=1;let r=t[o];r&&r.value.replace(/^\s*/,"").startsWith(":")&&(t[a].type="property")}return t}var xr=[{type:"comment",re:/\/\*[\s\S]*?\*\//y},{type:"string",re:/"(?:\\.|[^"\\\n])*"/y},{type:"string",re:/'(?:\\.|[^'\\\n])*'/y},{type:"keyword",re:/@[A-Za-z-]+/y},{type:"number",re:/#[0-9a-fA-F]{3,8}\b/y},{type:"number",re:/-?(?:\d+\.?\d*|\.\d+)(?:[a-z%]+)?/y},{type:"plain",re:/[A-Za-z_-][\w-]*/y}];function Pa(e){let t=Ze(e,xr),a="";for(let o=0;o<t.length;o+=1){let r=t[o];if(r.type==="plain"&&/^[A-Za-z_-][\w-]*$/.test(r.value)){let n=o+1;for(;n<t.length&&t[n].value.trim()==="";)n+=1;let f=t[n];f&&f.value.replace(/^\s*/,"").startsWith(":")&&(a===""||a==="{"||a==="}"||a===";"||a===",")&&(r.type="property")}let s=r.value.replace(/\s+$/,"");s&&(a=s[s.length-1])}return t}var gr=[{type:"tag",re:/<\/?\s*[A-Za-z][\w:-]*/y},{type:"string",re:/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'/y},{type:"attr",re:/[A-Za-z_:@][\w:.-]*(?=\s*=)/y},{type:"attr",re:/[A-Za-z_:@][\w:.-]*/y},{type:"tag",re:/\/?>/y}];function hr(e){let t=[],a=(s,n)=>{n&&t.push({type:s,value:n})},o=e.length,r=0;for(;r<o;){if(e.startsWith("<!--",r)){let n=e.indexOf("-->",r+4),f=n===-1?o:n+3;a("comment",e.slice(r,f)),r=f;continue}if(e[r]==="<"&&e[r+1]==="!"){let n=e.indexOf(">",r),f=n===-1?o:n+1;a("tag",e.slice(r,f)),r=f;continue}if(e[r]==="<"&&/[A-Za-z/]/.test(e[r+1]||"")){let n=e.indexOf(">",r),f=n===-1?o:n+1,h=e.slice(r,f);for(let i of Ze(h,gr))t.push(i);r=f;let p=/^<\s*(script|style)\b/i.exec(h);if(p&&!/\/>\s*$/.test(h)){let i=p[1].toLowerCase(),x=new RegExp("</\\s*"+i+"\\s*>","i").exec(e.slice(r)),u=x?r+x.index:o,m=e.slice(r,u),c=i==="script"?La(m):Pa(m);for(let v of c)t.push(v);r=u}continue}let s=e.indexOf("<",r);if(s===r)a("plain",e[r]),r+=1;else{let n=s===-1?o:s;a("plain",e.slice(r,n)),r=n}}return t}function Cr(e,t){switch(t){case"html":return hr(e);case"css":return Pa(e);case"js":return La(e);case"json":return cr(e)}}function yr(e){let t=pa(),a=C("span","persona-code-line"),o=(r,s)=>{if(!s)return;let n=fr[r];if(n){let f=C("span",n);f.textContent=s,a.appendChild(f)}else a.appendChild(document.createTextNode(s))};for(let r of e){let s=r.value.split(`
5
5
  `);for(let n=0;n<s.length;n+=1)n>0&&(t.appendChild(a),t.appendChild(document.createTextNode(`
6
- `)),a=C("span","persona-code-line")),o(r.type,s[n])}return a.childNodes.length>0?t.appendChild(a):t.lastChild||t.appendChild(a),t}function Ta(e,t,a){let o=e.length<=ir?dr(t,a):null,r=o?Cr(e,o):[{type:"plain",value:e}];return yr(r)}var{setLoader:Hn,load:On,provide:br,getSync:Ra}=qe({fallbackImport:()=>import("./markdown-parsers-entry")}),$e=new Set,wr=()=>{let e=[...$e];$e.clear();for(let t of e)try{t()}catch{}};var Ba=e=>Ra()?()=>{}:($e.add(e),()=>{$e.delete(e)}),Ea=e=>{br(e),wr()},we=Ra;var Sr=e=>{if(!e)return;let t={},a=e;if(a.heading){let o=a.heading;t.heading=(r,s,n)=>o({type:"heading",raw:n,depth:s,text:r,tokens:[]})}if(a.code){let o=a.code;t.code=(r,s,n)=>o({type:"code",raw:"",text:r,lang:s,escaped:n})}if(a.blockquote){let o=a.blockquote;t.blockquote=r=>o({type:"blockquote",raw:"",text:r,tokens:[]})}if(a.table){let o=a.table;t.table=(r,s)=>o({type:"table",raw:"",header:[],rows:[],align:[],headerHtml:r,bodyHtml:s})}if(a.link){let o=a.link;t.link=(r,s,n)=>o({type:"link",raw:"",href:r,title:s??null,text:n,tokens:[]})}if(a.image){let o=a.image;t.image=(r,s,n)=>o({type:"image",raw:"",href:r,title:s??null,text:n})}if(a.list){let o=a.list;t.list=(r,s,n)=>o({type:"list",raw:"",ordered:s,start:n,loose:!1,items:[],itemsHtml:r})}if(a.listitem){let o=a.listitem;t.listitem=(r,s,n)=>o({type:"list_item",raw:"",task:s,checked:n,loose:!1,text:r,tokens:[]})}if(a.paragraph){let o=a.paragraph;t.paragraph=r=>o({type:"paragraph",raw:"",text:r,tokens:[]})}if(a.codespan){let o=a.codespan;t.codespan=r=>o({type:"codespan",raw:"",text:r})}if(a.strong){let o=a.strong;t.strong=r=>o({type:"strong",raw:"",text:r,tokens:[]})}if(a.em){let o=a.em;t.em=r=>o({type:"em",raw:"",text:r,tokens:[]})}if(a.del){let o=a.del;t.del=r=>o({type:"del",raw:"",text:r,tokens:[]})}if(a.html){let o=a.html;t.html=r=>o({type:"html",raw:r,text:r})}if(a.text){let o=a.text;t.text=r=>o({type:"text",raw:r,text:r})}if(a.checkbox){let o=a.checkbox;t.checkbox=r=>o({checked:r})}return a.hr&&(t.hr=a.hr),a.br&&(t.br=a.br),t},ea=e=>{let t=null;return a=>{let o=we();if(!o)return Re(a);if(!t){let{Marked:r}=o,s=e?.markedOptions;t=new r({gfm:s?.gfm??!0,breaks:s?.breaks??!0,pedantic:s?.pedantic,silent:s?.silent});let n=Sr(e?.renderer);n&&t.use({renderer:n})}return t.parse(a)}},Da=e=>e?ea({markedOptions:e.options,renderer:e.renderer}):ea(),Un=ea();var Re=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;");var Ar={ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","p","br","hr","div","span","ul","ol","li","dl","dt","dd","strong","em","b","i","u","s","del","ins","mark","small","sub","sup","abbr","kbd","var","samp","code","a","img","blockquote","pre","details","summary","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col","input","label","select","option","textarea","button"],ALLOWED_ATTR:["href","src","alt","title","target","rel","loading","width","height","colspan","rowspan","scope","class","id","type","name","value","placeholder","disabled","checked","for","aria-label","aria-hidden","aria-expanded","role","tabindex","data-tv-form","data-message-id","data-persona-component-directive","data-preserve-animation","data-persona-instance"]},vr=/^data:image\/(?:png|jpe?g|gif|webp|bmp|x-icon|avif)/i,kr=()=>{let e=null;return t=>{let a=we();if(!a)return Re(t);if(!e){let{DOMPurify:o}=a;e=o(typeof window<"u"?window:void 0),e.addHook("uponSanitizeAttribute",(r,s)=>{if(s.attrName==="src"||s.attrName==="href"){let n=s.attrValue;n.toLowerCase().startsWith("data:")&&!vr.test(n)&&(s.attrValue="",s.keepAttr=!1)}})}return e.sanitize(t,Ar)}},Fa=e=>e===!1?null:typeof e=="function"?e:kr();var ta=class{constructor(){this.components=new Map;this.options=new Map}register(t,a,o){this.components.has(t)&&console.warn(`[ComponentRegistry] Component "${t}" is already registered. Overwriting.`),this.components.set(t,a),o?this.options.set(t,o):this.options.delete(t)}unregister(t){this.components.delete(t),this.options.delete(t)}get(t){return this.components.get(t)}has(t){return this.components.has(t)}getOptions(t){return this.options.get(t)}getAllNames(){return Array.from(this.components.keys())}clear(){this.components.clear(),this.options.clear()}registerAll(t){Object.entries(t).forEach(([a,o])=>{this.register(a,o)})}},Ha=new ta;var Oa=null,Ia=e=>{Oa=e.componentRegistry},qa=()=>Oa;function Je(e){if(!e)return"";if(e.artifactType==="markdown"){let t=e.markdown??"";return e.file?He(t):t}return JSON.stringify({component:e.component,props:e.props},null,2)}var aa=!1;function Mr(e){return"persona-artifact-vt-"+((e||"artifact").replace(/[^A-Za-z0-9_-]/g,"-").replace(/^-+/,"")||"artifact")}function Ua(e,t,a,o){let r=typeof document<"u"?document.startViewTransition:void 0,s=!1;try{s=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{s=!1}if(t!=="auto"||!e||typeof r!="function"||aa||s){o();return}aa=!0;let n=Mr(a);e.style.setProperty("view-transition-name",n);let f=()=>{aa=!1,e.style.removeProperty("view-transition-name")};try{r.call(document,()=>{o()}).finished.then(f,f)}catch{f(),o()}}var Lr="persona-font-mono persona-text-xs persona-whitespace-pre-wrap persona-break-words persona-text-persona-primary",Pr="persona-text-sm persona-leading-relaxed persona-markdown-bubble";function Tr(e){let t=C("div","persona-rounded-lg persona-border persona-border-persona-border persona-p-3 persona-text-persona-primary"),a=C("div","persona-font-semibold persona-text-sm persona-mb-2");a.textContent=e.component?`Component: ${e.component}`:"Component";let o=C("pre","persona-font-mono persona-text-xs persona-whitespace-pre-wrap persona-overflow-x-auto");return o.textContent=JSON.stringify(e.props??{},null,2),t.appendChild(a),t.appendChild(o),t}function Rr(e){if(e===!1)return{enabled:!1,delayMs:0,minVisibleMs:0,timeoutMs:0,injectReadySignal:!1,label:"Starting preview...",labelDelayMs:2e3};let t=e&&typeof e=="object"?e:void 0;return{enabled:!0,delayMs:t?.delayMs??200,minVisibleMs:t?.minVisibleMs??300,timeoutMs:t?.timeoutMs??8e3,injectReadySignal:t?.injectReadySignal!==!1,label:t?.label===!1?!1:t?.label??"Starting preview...",labelDelayMs:t?.labelDelayMs??2e3,renderIndicator:t?.renderIndicator}}var Br=220;function Er(){try{if(typeof crypto<"u"&&crypto.getRandomValues){let e=new Uint32Array(2);return crypto.getRandomValues(e),e[0].toString(36)+e[1].toString(36)}}catch{}return Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2)}function Dr(e){return`
7
- <script>(function(){var d=false;var t=`+JSON.stringify(e)+";function r(){if(d)return;d=true;try{parent.postMessage({persona:'artifact-preview-ready',token:t},'*');}catch(e){}}function s(){if(typeof requestAnimationFrame==='function'){requestAnimationFrame(function(){requestAnimationFrame(r);});}setTimeout(r,150);}if(document.readyState==='complete'){s();}else{window.addEventListener('load',s);}})();</script>"}function Fr(e,t,a){let o=C("div","persona-artifact-frame-loading");if(a.renderIndicator)try{let n=a.renderIndicator({artifactId:e,config:t});if(n)return o.appendChild(n),{el:o,revealLabel:()=>{}}}catch{}let r=C("div","persona-artifact-frame-loading-indicator");r.appendChild(wa());let s=null;return a.label!==!1&&(s=C("div","persona-artifact-frame-loading-text"),s.textContent=a.label,r.appendChild(s)),o.appendChild(r),{el:o,revealLabel:()=>{s&&s.classList.add("persona-artifact-frame-loading-text--visible")}}}function Hr(e,t,a,o,r,s){let n=null,f=0,h=!1,u=new Set,i=()=>{u.forEach(b=>clearTimeout(b)),u.clear()},d=(b,L)=>{let I=setTimeout(()=>{u.delete(I),!(typeof document>"u")&&b()},L);u.add(I)},x=()=>{n&&n.parentElement&&n.remove(),n=null},p=()=>{if(n||h)return;let b=Fr(r,s,o);n=b.el,e.appendChild(n),f=Date.now(),o.label!==!1&&d(b.revealLabel,o.labelDelayMs)},m=()=>{n&&(n.classList.add("persona-artifact-frame-loading--out"),d(x,Br))},c=()=>{a!==null?typeof window<"u"&&window.removeEventListener("message",M):t.removeEventListener("load",S)},v=()=>{if(h||(h=!0,c(),i(),!n))return;let b=Math.max(0,o.minVisibleMs-(Date.now()-f));b>0?d(m,b):m()};function M(b){if(a===null)return;let L=b.data;!L||L.persona!=="artifact-preview-ready"||L.token!==a||b.source===t.contentWindow&&v()}function S(){let b=L=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>L()):setTimeout(L,0)};b(()=>b(()=>v()))}return d(p,o.delayMs),d(v,o.timeoutMs),a!==null?typeof window<"u"&&window.addEventListener("message",M):t.addEventListener("load",S),()=>{h=!0,i(),c(),x()}}function Qe(e,t){let{config:a}=t,o=t.registry??qa()??Ha,r=t.bodyLayout,s=a.markdown?Da(a.markdown):null,n=Fa(a.sanitize),f=e,h=!1,u=g=>{let B=we()!==null;s&&!B&&!h&&(h=!0,Ba(()=>$(f)));let H=s?s(g):Re(g);return s&&B&&n?n(H):H},i=C("div","persona-artifact-preview-body"),d=null,x=null,p=null,m=()=>{p&&(p(),p=null),d=null,x=null},c=null,v=null,M=null,S=!1,b=()=>{c=null,v=null,M=null,S=!1},L=null,I=null,j=()=>{L=null,I=null},oe=40,Q=0,le=g=>typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>g()):setTimeout(g,0),q=g=>g.scrollHeight-g.clientHeight-g.scrollTop<=oe,Z=g=>{if(!r)return;let B=g.scrollHeight-g.clientHeight>1,H=g.scrollHeight-g.clientHeight-g.scrollTop;g.classList.toggle("persona-artifact-fade-top",r.fadeTop&&B&&g.scrollTop>1),g.classList.toggle("persona-artifact-fade-bottom",r.fadeBottom&&B&&H>1)},U=g=>{Q||(Q=le(()=>{Q=0,g.scrollTop=g.scrollHeight,Z(g)}))},W=(g,B,H,y)=>{let P=!!r,O=H.id+"|"+(P?"w":"p");if(!c||M!==O||c.parentElement!==i){m(),j(),i.replaceChildren();let w=C("pre",Lr+" persona-code-pre"),D=C("code","persona-code");if(w.appendChild(D),P){let N=C("div","persona-artifact-source-window");if(N.appendChild(w),i.appendChild(N),!(r?.overflow==="clip")&&typeof N.addEventListener=="function"){let J=()=>N.scrollHeight-N.clientHeight>1;N.addEventListener("scroll",()=>{q(N)&&(S=!1),Z(N)},{passive:!0}),N.addEventListener("wheel",ee=>{J()&&ee.deltaY<0&&(S=!0)},{passive:!0}),N.addEventListener("touchmove",()=>{J()&&(S=!0)},{passive:!0})}c=N}else i.appendChild(w),c=w;v=D,M=O}let T=P?c:null;T&&(T.classList.toggle("persona-artifact-source-window--fixed",y),T.classList.toggle("persona-artifact-source-window--clip",y&&r?.overflow==="clip"));let E=T?q(T):!0;if(v.replaceChildren(Ta(g,B?.language,B?.path)),T){let w=H.status!=="complete";y&&w&&r?.followOutput&&!S&&E?U(T):w||(S=!1),Z(T)}},G=g=>{m(),b(),j(),i.replaceChildren();let B=C("div",Pr);B.innerHTML=u(g),i.appendChild(B)},Y=g=>{let B=g.id,H=a.features?.artifacts,y=be(g,H,"status-body");if(L&&I===B&&L.parentElement===i){let T=L.querySelector(".persona-artifact-status-view-text");T&&ce(T,y,H);return}m(),b(),i.replaceChildren();let P=C("div","persona-artifact-status-view"),O=C("div","persona-artifact-status-view-text");ce(O,y,H),P.appendChild(O),i.appendChild(P),L=P,I=B},$=g=>{f=g;let B=t.resolveViewMode?.(g)??r?.viewMode??"rendered",H=g.artifactType==="markdown"?g.file:void 0,y=g.status!=="complete";y||ye(g.id);let P=y?r?.streamingHeight:r?.completeHeight,O=!!r&&typeof P=="number";if(r?.streamingView==="status"&&y){Y(g);return}if(H){let E=He(g.markdown??""),w=ue(H),D=a.features?.artifacts?.filePreview?.enabled!==!1;if(!y&&B==="rendered"&&D&&(w==="html"||w==="svg")){let xe=g.id+"\0"+E;if(d&&x===xe&&d.parentElement===i)return;b(),j(),m(),i.replaceChildren();let J=a.features?.artifacts?.filePreview,ee=J?.iframeSandbox??"allow-scripts";!J?.dangerouslyAllowSameOrigin&&ee.includes("allow-same-origin")&&(console.warn("[AgentWidget] Stripped allow-same-origin from filePreview.iframeSandbox: it lets artifact content run with the page origin. Set filePreview.dangerouslyAllowSameOrigin to keep it."),ee=ee.split(/\s+/).filter(F=>F&&F!=="allow-same-origin").join(" "));let ge=Rr(J?.loading),_=C("div","persona-artifact-frame"),te=C("iframe","persona-artifact-iframe");te.setAttribute("sandbox",ee),te.setAttribute("data-artifact-id",g.id);let Se=null;ge.enabled&&ge.injectReadySignal?(Se=Er(),te.srcdoc=E+Dr(Se)):te.srcdoc=E,_.appendChild(te),i.appendChild(_),ge.enabled&&(p=Hr(_,te,Se,ge,g.id,a)),d=_,x=xe;return}if(m(),!y&&w==="markdown"&&B==="rendered"){G(E);return}W(E,{language:H.language,path:H.path},g,O);return}if(g.artifactType==="markdown"){if(B==="source"){m(),W(g.markdown??"",void 0,g,O);return}G(g.markdown??"");return}m(),b(),j(),i.replaceChildren();let T=g.component?o.get(g.component):void 0;if(T){let w={message:{id:g.id,role:"assistant",content:"",createdAt:new Date().toISOString()},config:a,updateProps:()=>{}};try{let D=T(g.props??{},w);if(D){i.appendChild(D);return}}catch{}}i.appendChild(Tr(g))};return $(e),{el:i,update(g){$(g)},destroy(){m()}}}function Na(e,t){let a=t.orientation??"horizontal",o=a==="vertical"?"ArrowUp":"ArrowLeft",r=a==="vertical"?"ArrowDown":"ArrowRight";e.setAttribute("role","tablist");let s=[],n=!1,f=d=>{typeof d.scrollIntoView=="function"&&d.scrollIntoView({block:"nearest",inline:"nearest"})},h=d=>{let x=d;return s.findIndex(p=>p===x||p.contains(x))},u=d=>{let x=h(d.target);if(x<0)return;let p=x;if(d.key===r)p=Math.min(x+1,s.length-1);else if(d.key===o)p=Math.max(x-1,0);else if(d.key==="Home")p=0;else if(d.key==="End")p=s.length-1;else return;d.preventDefault(),p!==x&&t.onSelect(p)},i=d=>{let x=h(d.target);x>=0&&f(s[x])};return e.addEventListener("keydown",u),e.addEventListener("focusin",i),{beforeRender(){n=typeof document<"u"&&e.contains(document.activeElement)},render(d,x){if(s=d,d.forEach((p,m)=>{p.setAttribute("role","tab");let c=m===x;p.setAttribute("aria-selected",c?"true":"false"),p.tabIndex=c||x<0&&m===0?0:-1}),n){let p=(x>=0?d[x]:void 0)??d[0];p&&typeof p.focus=="function"&&(f(p),p.focus())}},destroy(){e.removeEventListener("keydown",u),e.removeEventListener("focusin",i)}}}function Va(e,t){let a=e.features?.artifacts?.layout,r=(a?.toolbarPreset??"default")==="document",s=a?.toolbarTitle??"Artifacts",n=a?.closeButtonLabel??"Close",f=a?.panePadding?.trim(),h=a?.tabFadeSize?.trim(),u=l=>({start:l===!1?!1:typeof l=="object"&&l?l.start!==!1:!0,end:l===!1?!1:typeof l=="object"&&l?l.end!==!1:!0}),{start:i,end:d}=u(a?.tabFade),x=typeof document<"u"?C("div","persona-artifact-backdrop persona-fixed persona-inset-0 persona-z-[55] persona-bg-black/30 persona-hidden md:persona-hidden"):null,p=()=>{x?.classList.add("persona-hidden"),m.classList.remove("persona-artifact-drawer-open"),Z?.closeMenu()};x&&x.addEventListener("click",()=>{p(),t.onDismiss?.()});let m=C("aside","persona-artifact-pane persona-flex persona-flex-col persona-min-h-0 persona-min-w-0 persona-bg-persona-surface persona-text-persona-primary persona-border-l persona-border-persona-border");m.setAttribute("data-persona-theme-zone","artifact-pane"),r&&m.classList.add("persona-artifact-pane-document");let c=C("div","persona-artifact-toolbar persona-flex persona-items-center persona-justify-between persona-gap-2 persona-px-2 persona-py-2 persona-border-b persona-border-persona-border persona-shrink-0");c.setAttribute("data-persona-theme-zone","artifact-toolbar"),r&&c.classList.add("persona-artifact-toolbar-document");let v=C("span","persona-text-xs persona-font-medium persona-truncate");v.textContent=s;let M=V({icon:"x",label:n});M.addEventListener("click",()=>{p(),t.onDismiss?.()});let S="rendered",b=je({items:[{id:"rendered",icon:"eye",label:"Rendered view",className:r?"persona-artifact-doc-icon-btn persona-artifact-view-btn":void 0},{id:"source",icon:"code-xml",label:"Source",className:r?"persona-artifact-doc-icon-btn persona-artifact-code-btn":void 0}],selectedId:"rendered",className:"persona-artifact-toggle-group persona-shrink-0",onSelect:l=>{S=l==="source"?"source":"rendered",De()}}),L=C("div","persona-flex persona-items-center persona-gap-1 persona-shrink-0"),I=a?.documentToolbarShowCopyLabel===!0,j=a?.documentToolbarShowCopyChevron===!0,oe=a?.documentToolbarCopyMenuItems,Q=!!(j&&oe&&oe.length>0),le=null,q,Z=null;if(r&&(I||j)&&!Q){if(q=I?me({icon:"copy",label:"Copy",iconSize:14,className:"persona-artifact-doc-copy-btn"}):V({icon:"copy",label:"Copy",className:"persona-artifact-doc-copy-btn"}),j){let l=ne(ve,14,"currentColor",2);l&&q.appendChild(l)}}else r&&Q?(Z=ba({label:"Copy",icon:"copy",iconSize:14,iconOnly:!I,primaryClassName:"persona-artifact-doc-copy-btn",chevronLabel:"More copy options",chevronClassName:"persona-artifact-doc-copy-menu-chevron persona-artifact-doc-icon-btn",menuItems:(oe??[]).map(l=>({id:l.id,label:l.label})),position:"bottom-right",portal:()=>m.closest("[data-persona-root]")??document.body,onSelect:l=>{T(l)}}),le=Z.element,q=Z.primaryButton):r?q=V({icon:"copy",label:"Copy",className:"persona-artifact-doc-icon-btn"}):(q=V({icon:"copy",label:"Copy"}),a?.showCopyButton!==!0&&q.classList.add("persona-hidden"));let U=r?V({icon:"refresh-cw",label:"Refresh",className:"persona-artifact-doc-icon-btn"}):V({icon:"refresh-cw",label:"Refresh"});a?.onDocumentToolbarRefresh||U.classList.add("persona-hidden");let W=r?V({icon:"x",label:n,className:"persona-artifact-doc-icon-btn"}):V({icon:"x",label:n}),G=V({icon:"maximize",label:"Expand artifacts panel",className:"persona-artifact-expand-btn"+(r?" persona-artifact-doc-icon-btn":""),onClick:()=>t.onToggleExpand?.()});a?.showExpandToggle!==!0&&G.classList.add("persona-hidden");let Y=C("div","persona-flex persona-items-center persona-gap-1 persona-shrink-0 persona-artifact-toolbar-custom-actions"),$=e.features?.artifacts?.toolbarActions??[],g=()=>{let l=F.find(se=>se.id===X)??F[F.length-1],k=l?.id??null,A=l?.artifactType==="markdown"?l.markdown??"":"",R=l?JSON.stringify({component:l.component,props:l.props},null,2):"",{filename:z,mime:K,content:fe}=Oe({title:l?.title,markdown:l?.markdown??"",file:l?.file});return{markdown:A,jsonPayload:R,id:k,file:l?.file,suggestedFilename:z,mime:K,content:fe}},B=()=>{let{suggestedFilename:l,mime:k,content:A}=g();A&&Ie({filename:l,mime:k,content:A})},H=l=>{let{id:k,...A}=g();return{actionId:l,artifactId:k,...A}},y=async()=>{let l=F.find(k=>k.id===X)??F[F.length-1];try{return await navigator.clipboard.writeText(Je(l)),!0}catch{return!1}},P=null,O=()=>{P?.();let l=q.querySelector("svg"),k=Number(l?.getAttribute("width"))||16,A=ne(Ae,k,"currentColor",2);if(!l||!A)return;l.replaceWith(A);let R=q.querySelector("span");R&&(R.textContent="Copied");let z=setTimeout(()=>P?.(),2e3);P=()=>{clearTimeout(z),A.replaceWith(l),R&&(R.textContent="Copy"),P=null}};q.addEventListener("click",async()=>{let l=a?.onDocumentToolbarCopyMenuSelect;if(l&&Q){try{if(await l(H("primary"))===!1){await y()&&O();return}O()}catch{}return}await y()&&O()});async function T(l){let k=a?.onDocumentToolbarCopyMenuSelect;try{if(k&&await k(H(l))!==!1)return;if(l==="download"){B();return}let{markdown:A,jsonPayload:R}=g();l==="markdown"||l==="md"?await navigator.clipboard.writeText(A):l==="json"||l==="source"?await navigator.clipboard.writeText(R):await navigator.clipboard.writeText(A||R),O()}catch{}}U.addEventListener("click",async()=>{try{await a?.onDocumentToolbarRefresh?.()}catch{}De()}),W.addEventListener("click",()=>{p(),t.onDismiss?.()});let E=C("span","persona-min-w-0 persona-flex-1 persona-text-xs persona-font-medium persona-text-persona-primary persona-truncate persona-text-center md:persona-text-left");if(r)c.replaceChildren(),le?L.append(le,U,W):L.append(q,U,W),L.insertBefore(Y,W),L.insertBefore(G,W),c.append(b.element,E,L);else{let l=C("div","persona-flex persona-items-center persona-gap-1 persona-shrink-0");l.append(q,Y,G,M),c.appendChild(v),c.appendChild(l)}f&&(c.style.paddingLeft=f,c.style.paddingRight=f);let w=C("div","persona-artifact-list persona-shrink-0 persona-flex persona-gap-1 persona-overflow-x-auto persona-p-2 persona-border-b persona-border-persona-border");h&&w.style.setProperty("--persona-artifact-tab-fade-size",h);let D=e.features?.artifacts?.renderTabBar,N=C("div","persona-artifact-tab-custom persona-shrink-0 persona-border-b persona-border-persona-border persona-hidden"),xe=Na(w,{onSelect:l=>t.onSelect(F[l].id)}),J=l=>{let k=l.scrollWidth-l.clientWidth,A=k>1,R=Math.abs(l.scrollLeft);l.classList.toggle("persona-artifact-tab-fade-start",i&&A&&R>1),l.classList.toggle("persona-artifact-tab-fade-end",d&&A&&R<k-1)},ee=0,ge=()=>{if(ee)return;let l=()=>{ee=0,J(w)};ee=typeof requestAnimationFrame=="function"?requestAnimationFrame(l):setTimeout(l,0)};w.addEventListener("scroll",()=>ge(),{passive:!0}),typeof ResizeObserver<"u"&&new ResizeObserver(()=>J(w)).observe(w);let _=C("div","persona-artifact-content persona-flex-1 persona-min-h-0 persona-overflow-y-auto persona-p-3"),te=()=>{_.scrollLeft=0},Se=()=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(te):setTimeout(te,0)};if(f){for(let l of[w,N])l.style.paddingLeft=f,l.style.paddingRight=f;_.style.padding=f}m.appendChild(c),m.appendChild(w),m.appendChild(N),m.appendChild(_);let F=[],X=null,et=!1,ra=!1,tt=!0,at=!1,oa=null,rt="",ae=null,Ee=!1,$a=l=>l.artifactType==="markdown"&&!!l.file||r?S:"rendered",sa=l=>{r||(l&&!Ee?(c.insertBefore(b.element,v),Ee=!0):!l&&Ee&&(b.element.remove(),Ee=!1))},na=()=>X&&F.find(l=>l.id===X)||F[F.length-1],la=()=>{let l=Te(na());if(!l){Y.replaceChildren();return}let k=$.filter(A=>A.visible===void 0||A.visible(l)).map(A=>Ce(A,{documentChrome:r,onClick:()=>{let R=Te(na());if(R)try{Promise.resolve(A.onClick(R)).catch(()=>{})}catch{}}}));Y.replaceChildren(...k)},De=()=>{la();let l=r&&F.length<=1,k=!!D;if(w.classList.toggle("persona-hidden",l||k),N.classList.toggle("persona-hidden",l||!k),k&&D){let z=F.map(K=>K.id).join("|")+" "+(X??"");if(z!==rt){rt=z;let K=D({records:F,selectedId:X,onSelect:t.onSelect});N.firstElementChild!==K&&N.replaceChildren(K)}}else{xe.beforeRender(),w.replaceChildren();let z=[],K=-1;for(let[fe,se]of F.entries()){let ie=C("button","persona-artifact-tab persona-shrink-0 persona-rounded-lg persona-px-2 persona-py-1 persona-text-xs persona-border persona-border-transparent persona-text-persona-primary");ie.type="button";let ot=se.artifactType==="markdown"?se.file:void 0,da=ot?re(ot.path):se.title||se.id.slice(0,8),pa=ot?.path||se.title||da;ie.textContent=da,ie.title=pa,ie.setAttribute("aria-label",pa),se.id===X&&(ie.classList.add("persona-bg-persona-container","persona-border-persona-border"),K=fe),ie.addEventListener("click",()=>t.onSelect(se.id)),w.appendChild(ie),z.push(ie)}if(xe.render(z,K),K>=0&&X!==oa){oa=X;let fe=z[K];typeof fe.scrollIntoView=="function"&&fe.scrollIntoView({block:"nearest",inline:"nearest"})}J(w)}let A=X&&F.find(z=>z.id===X)||F[F.length-1];if(!A){_.replaceChildren(),ae?.destroy(),ae=null,sa(!1);return}let R=A.artifactType==="markdown"?A.file:void 0;if(sa(!!R&&ue(R)!=="other"),r){let z=R?de(R):A.artifactType==="markdown"?"MD":A.component??"Component",K=(A.title||"Document").trim(),fe=R?re(R.path):K.replace(/\s*·\s*MD\s*$/i,"").trim()||"Document";E.textContent=`${fe} \xB7 ${z}`}else v.textContent=R?re(R.path):s;ae?(ae.el.parentElement!==_&&_.replaceChildren(ae.el),ae.update(A)):(ae=Qe(A,{config:e,resolveViewMode:$a}),_.replaceChildren(ae.el)),_.classList.toggle("persona-artifact-content-flush",!!_.querySelector(".persona-code-pre"))},fa=()=>{let l=F.length>0;if(m.classList.toggle("persona-hidden",!l),x){let R=((typeof m.closest=="function"?m.closest("[data-persona-root]"):null)?.classList.contains("persona-artifact-narrow-host")??!1)||typeof window<"u"&&window.matchMedia("(max-width: 640px)").matches;l&&R&&et?(x.classList.remove("persona-hidden"),m.classList.add("persona-artifact-drawer-open")):(x.classList.add("persona-hidden"),m.classList.remove("persona-artifact-drawer-open"))}},ia=()=>{at=!1,De(),fa()};return{element:m,backdrop:x,update(l){let k=l.selectedId??l.artifacts[l.artifacts.length-1]?.id??null,A=k!==X;F=l.artifacts,X=k,F.length>0&&(et=!0),at=!0,tt&&ia(),A&&te()},setMobileOpen(l){et=l,!l&&x?(x.classList.add("persona-hidden"),m.classList.remove("persona-artifact-drawer-open")):fa()},setExpanded(l){l!==ra&&(ra=l,Se());let k=ne(l?Le:Me,16,"currentColor",2);k&&G.replaceChildren(k);let A=l?"Collapse artifacts panel":"Expand artifacts panel";G.setAttribute("aria-label",A),G.title=A},setExpandToggleVisible(l){G.classList.toggle("persona-hidden",!l)},setCopyButtonVisible(l){r||q.classList.toggle("persona-hidden",!l)},setRefreshButtonVisible(l){U.classList.toggle("persona-hidden",!l)},setCustomActions(l){$=l,la()},setTabFade(l){let k=u(l);k.start===i&&k.end===d||(i=k.start,d=k.end,J(w))},setRenderTabBar(l){l!==D&&(D=l,rt="",De())},setVisible(l){l!==tt&&(tt=l,l&&at&&ia())},destroy(){ae?.destroy(),ae=null}}}function za(e,t){let a=e.file&&typeof e.file=="object"&&!Array.isArray(e.file)?e.file:void 0,o=typeof e.title=="string"&&e.title?e.title:"Untitled artifact",r=a?re(a.path):o,s=typeof e.artifactId=="string"?e.artifactId:"",n=e.status==="streaming"?"streaming":"complete",f=typeof e.artifactType=="string"?e.artifactType:"markdown",h=e.presentation&&typeof e.presentation=="object"&&!Array.isArray(e.presentation)?e.presentation:void 0,u=a?de(a):f==="component"?"Component":"Document",i=document.createElement("div");i.className="persona-artifact-card persona-flex persona-w-full persona-max-w-full persona-items-center persona-gap-3 persona-px-4 persona-py-3",i.tabIndex=0,i.setAttribute("role","button"),i.setAttribute("aria-label",`Open ${r} in artifact panel`),s&&i.setAttribute("data-open-artifact",s);let d=document.createElement("div");d.className="persona-flex persona-h-10 persona-w-10 persona-flex-shrink-0 persona-items-center persona-justify-center persona-rounded-lg",d.style.border="1px solid var(--persona-border, #e5e7eb)",d.style.color="var(--persona-muted, #9ca3af)",d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/></svg>';let x=document.createElement("div");x.className="persona-min-w-0 persona-flex-1 persona-flex persona-flex-col persona-gap-0.5";let p=document.createElement("div");p.className="persona-truncate persona-text-sm persona-font-medium",p.style.color="var(--persona-text, #1f2937)",p.textContent=r;let m=document.createElement("div");if(m.className="persona-text-xs persona-flex persona-items-center persona-gap-1.5",m.style.color="var(--persona-muted, #9ca3af)",n==="streaming"){let c=t?.config?.features?.artifacts,v={id:s,artifactType:f==="component"?"component":"markdown",title:o,status:"streaming",...typeof e.markdown=="string"?{markdown:e.markdown}:{},...a?{file:a}:{},...h?{presentation:h}:{}},M=be(v,c,"card");ce(m,M,c)}else s&&ye(s),m.textContent=u;if(x.append(p,m),i.append(d,x),n==="complete"){let c=t?.config?.features?.artifacts?.cardActions;if(c&&c.length>0){let M={artifactId:s||null,title:r,artifactType:f,markdown:typeof e.markdown=="string"?e.markdown:void 0,file:a};for(let S of c)try{if(S.visible===void 0||S.visible(M)){let b=Ce(S);b.setAttribute("data-artifact-custom-action",S.id),b.className=`${b.className} persona-flex-shrink-0`,i.append(b)}}catch{}}let v=me({label:"Download",className:"persona-flex-shrink-0"});v.title=`Download ${r}`,v.setAttribute("data-download-artifact",s),i.append(v)}return i}var Ye=(e,t)=>{let a=t?.config?.features?.artifacts?.renderCard;if(a){let o=typeof e.title=="string"&&e.title?e.title:"Untitled artifact",r=typeof e.artifactId=="string"?e.artifactId:"",s=e.status==="streaming"?"streaming":"complete",n=typeof e.artifactType=="string"?e.artifactType:"markdown",f=a({artifact:{artifactId:r,title:o,artifactType:n,status:s},config:t.config,defaultRenderer:()=>za(e,t)});if(f)return f}return za(e,t)};var pe=new WeakMap;function Xa(e,t,a){if(t.length===0)return;let o=new Map(t.map(r=>[r.id,r]));e.querySelectorAll("[data-artifact-inline]").forEach(r=>{let s=pe.get(r);if(!s)return;let n=o.get(r.getAttribute("data-artifact-inline")??"");n&&s(n,a)})}function Ka(e){return pe.has(e)}function Or(e){let t=typeof e.artifactId=="string"?e.artifactId:"",a=typeof e.title=="string"&&e.title?e.title:void 0,o=e.status==="streaming"?"streaming":"complete",r=e.presentation&&typeof e.presentation=="object"&&!Array.isArray(e.presentation)?e.presentation:void 0;if(e.artifactType==="component"){let n=e.componentProps,f=n&&typeof n=="object"&&!Array.isArray(n)?n:{};return{id:t,artifactType:"component",title:a,status:o,component:typeof e.component=="string"?e.component:"",props:f,...r?{presentation:r}:{}}}let s=e.file&&typeof e.file=="object"&&!Array.isArray(e.file)?e.file:void 0;return{id:t,artifactType:"markdown",title:a,status:o,markdown:typeof e.markdown=="string"?e.markdown:"",...s?{file:s}:{},...r?{presentation:r}:{}}}function Wa(e){let t=e.artifactType==="markdown"?e.file:void 0,a=t?re(t.path):e.title&&e.title.trim()?e.title:"Untitled artifact",o=t?de(t):e.artifactType==="component"?"Component":"Document";return{title:a,typeLabel:o}}function Ir(e){let t={artifactId:e.id,title:e.title??"",status:e.status,artifactType:e.artifactType};return e.artifactType==="markdown"&&(typeof e.markdown=="string"&&(t.markdown=e.markdown),e.file&&(t.file=e.file)),t}var Ga=180,qr=240,Ur=.8,Nr=300,Vr=500,zr="cubic-bezier(0.2, 0, 0, 1)",_a=240,Wr=.35;function Gr(e,t,a){let{swap:o,onSettled:r}=a,s=!1;try{s=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{s=!1}if(!t||!e.isConnected||s||typeof e.animate!="function"){o(),r();return}e.style.height=`${t}px`,e.style.overflow="hidden";let n=[];for(let f of Array.from(e.children))f instanceof HTMLElement&&n.push(f.animate([{opacity:1},{opacity:0}],{duration:Ga,easing:"ease-out",fill:"forwards"}));window.setTimeout(()=>{for(let M of n)M.cancel();o();let f=()=>{e.style.removeProperty("height"),e.style.removeProperty("overflow")};if(!e.isConnected){f(),r();return}e.style.height="auto";let h=e.getBoundingClientRect().height;if(e.style.height=`${t}px`,!h||Math.abs(h-t)<1){f(),r();return}let u=Math.abs(t-h),i=Math.round(Math.min(Vr,Math.max(Nr,qr+u*Ur))),d=Math.round(i*Wr),x=e.firstElementChild instanceof HTMLElement?e.firstElementChild:null,p=x?x.animate([{opacity:0},{opacity:1}],{duration:_a,delay:d,easing:"ease-out",fill:"backwards"}):null,m=e.animate([{height:`${t}px`},{height:`${h}px`}],{duration:i,easing:zr});e.style.height=`${h}px`;let c=!1,v=()=>{c||(c=!0,f(),r())};Promise.allSettled([m.finished,p?.finished].filter(Boolean)).then(v),window.setTimeout(v,Math.max(i,d+_a)+120)},Ga)}function _r(e){let t=e?.inlineChrome;if(t===!1)return{chromeEnabled:!1,showCopy:!1,showExpand:!1,showViewToggle:!1};let a=typeof t=="object"?t:void 0;return{chromeEnabled:!0,showCopy:a?.showCopy!==!1,showExpand:a?.showExpand!==!1,showViewToggle:a?.showViewToggle!==!1}}var Be="--persona-artifact-inline-body-height";function jr(e){let t=e?.inlineBody,a=t?.streamingView==="status"?"status":"source",o=t?.viewMode==="source"?"source":"rendered",r=320,s=320,n=t?.height;typeof n=="number"||n==="auto"?(r=n,s=n):n&&typeof n=="object"&&(r=n.streaming??320,s=n.complete??320);let f=t?.overflow==="clip"?"clip":"scroll",h=f==="clip"?!1:t?.followOutput!==!1,u,i,d=t?.fadeMask;d===!0?(u=!0,i=!0):d===!1?(u=!1,i=!1):d&&typeof d=="object"?(u=d.top===!0,i=d.bottom===!0):f==="clip"?(u=!1,i=!0):(u=!0,i=!0);let x=t?.transition==="none"?"none":"auto",p=t?.completeDisplay==="card"?"card":"inline";return{streamingView:a,viewMode:o,streamingHeight:r,completeHeight:s,followOutput:h,overflow:f,fadeTop:u,fadeBottom:i,transition:x,completeDisplay:p}}function ja(e,t){let a=Or(e),o=t.config?.features?.artifacts,{chromeEnabled:r,showCopy:s,showExpand:n,showViewToggle:f}=_r(o),h=o?.inlineActions??[],u=jr(o),i=u.completeDisplay==="card",d=null,x=a,p=C("div","persona-artifact-inline persona-w-full persona-max-w-full");p.setAttribute("data-persona-theme-zone","artifact-inline"),a.id&&p.setAttribute("data-artifact-inline",a.id);let m=y=>Ye(Ir(y),t),c=null,v=y=>{c?.destroy(),c=null,p.classList.add("persona-artifact-inline--card"),p.style.removeProperty(Be),p.replaceChildren(m(y)),pe.set(p,P=>{p.replaceChildren(m(P))})};if(i&&a.status==="complete")return v(a),p;let M=Qe(a,{config:t.config,bodyLayout:u,resolveViewMode:()=>d??u.viewMode});c=M;let S=C("div","persona-artifact-inline-body");S.appendChild(M.el);let b=y=>{let P=y.status!=="complete",O=P?u.streamingHeight:u.completeHeight,T=typeof O=="number";T?p.style.setProperty(Be,`${O}px`):p.style.removeProperty(Be);let E=!!M.el.querySelector(".persona-code-pre"),w=!!M.el.querySelector("iframe, .persona-artifact-source-window--fixed, .persona-artifact-status-view");S.classList.toggle("persona-artifact-content-flush",E),S.classList.toggle("persona-artifact-inline-body--sized",T&&w),S.classList.toggle("persona-artifact-inline-body--cap",!P&&!w&&typeof u.completeHeight=="number")},L=a.status,I=(y,P)=>{L!=="complete"&&y.status==="complete"?(typeof u.completeHeight=="number"?p.style.setProperty(Be,`${u.completeHeight}px`):p.style.removeProperty(Be),Ua(S,P?.suppressTransition?"none":u.transition,y.id,()=>{M.update(y),b(y)})):M.update(y),b(y),L=y.status};b(a);let j=u.overflow==="clip"&&n&&!!a.id;if(j&&(S.setAttribute("data-expand-artifact-inline",a.id),S.setAttribute("role","button"),S.setAttribute("tabindex","0"),S.classList.add("persona-cursor-pointer"),S.setAttribute("aria-label",`Open ${Wa(a).title} in panel`)),!r)return p.appendChild(S),pe.set(p,I),p;let oe=C("div","persona-artifact-inline-chrome");oe.setAttribute("data-persona-theme-zone","artifact-inline-chrome");let Q=C("div","persona-artifact-inline-chrome-lead"),le=C("span","persona-flex persona-items-center persona-flex-shrink-0"),q=ne(ke,16,"currentColor",2);q&&le.appendChild(q);let Z=C("span","persona-artifact-inline-title persona-truncate persona-min-w-0"),U=C("span","persona-artifact-inline-type");Q.append(le,Z,U);let W=C("div","persona-artifact-inline-chrome-actions"),G=C("span","persona-flex persona-items-center persona-gap-1"),Y=()=>d??u.viewMode,$=f?je({items:[{id:"rendered",icon:"eye",label:"Rendered view",className:"persona-artifact-doc-icon-btn persona-artifact-view-btn"},{id:"source",icon:"code-xml",label:"Source",className:"persona-artifact-doc-icon-btn persona-artifact-code-btn"}],selectedId:Y(),className:"persona-artifact-toggle-group persona-flex-shrink-0",onSelect:y=>{let P=y==="source"?"source":"rendered";P!==Y()&&(d=P,M.update(x),b(x))}}):null,g=s?V({icon:"copy",label:"Copy",className:"persona-artifact-doc-icon-btn persona-flex-shrink-0"}):null;g&&a.id&&g.setAttribute("data-copy-artifact",a.id);let B=n?V({icon:"maximize",label:"Open in panel",className:"persona-artifact-doc-icon-btn persona-flex-shrink-0"}):null;B&&a.id&&B.setAttribute("data-expand-artifact-inline",a.id),W.appendChild(G),$&&W.appendChild($.element),g&&W.appendChild(g),B&&W.appendChild(B),oe.append(Q,W),p.append(oe,S);let H=y=>{let{title:P,typeLabel:O}=Wa(y);Z.textContent=P,Z.title=P,j&&S.setAttribute("aria-label",`Open ${P} in panel`);let T=y.status!=="complete";if(T){U.classList.contains("persona-artifact-inline-status")||(U.className="persona-artifact-inline-status",U.removeAttribute("data-preserve-animation"),U.replaceChildren());let E=be(y,o,"inline-chrome");ce(U,E,o)}else ye(y.id),U.className="persona-artifact-inline-type",U.removeAttribute("data-preserve-animation"),U.replaceChildren(),U.textContent=O;if(g&&g.classList.toggle("persona-hidden",T),$){let E=y.artifactType==="markdown"?y.file:void 0,w=!1;if(!T&&E&&u.viewMode!=="source"){let D=ue(E);D==="markdown"?w=!0:(D==="html"||D==="svg")&&(w=o?.filePreview?.enabled!==!1)}$.element.classList.toggle("persona-hidden",!w),$.setSelected(Y())}if(G.replaceChildren(),!T&&h.length>0){let E=Te(y);if(E)for(let w of h)try{if(w.visible===void 0||w.visible(E)){let D=Ce(w,{documentChrome:!0});D.setAttribute("data-artifact-custom-action",w.id),D.classList.add("persona-flex-shrink-0"),G.appendChild(D)}}catch{}}};return H(a),pe.set(p,(y,P)=>{if(i&&L!=="complete"&&y.status==="complete"){let O=p.isConnected?p.getBoundingClientRect().height:0;L="complete";let T=y,E=!1,w=D=>{T=D,E=!0};pe.set(p,w),Gr(p,O,{swap:()=>{v(T),E=!1,pe.set(p,w)},onSettled:()=>{E?v(T):pe.set(p,D=>{p.replaceChildren(m(D))})}});return}(y.status!=="complete"||y.id!==x.id)&&(d=null),x=y,I(y,P),H(y)}),p}var Za=(e,t)=>{let a=t?.config?.features?.artifacts?.renderInline;if(a){let o=typeof e.title=="string"&&e.title?e.title:"Untitled artifact",r=typeof e.artifactId=="string"?e.artifactId:"",s=e.status==="streaming"?"streaming":"complete",n=typeof e.artifactType=="string"?e.artifactType:"markdown",f=a({artifact:{artifactId:r,title:o,artifactType:n,status:s},config:t.config,defaultRenderer:()=>ja(e,t)});if(f)return f}return ja(e,t)};export{Ye as PersonaArtifactCard,Za as PersonaArtifactInline,Ea as __provideMarkdownParsers,ca as __setIconsExtraLoader,Je as artifactCopyText,Va as createArtifactPane,Oe as downloadInfoFor,Ka as hasLiveInlineArtifactBlock,Ia as initArtifactsUi,Ie as triggerArtifactDownload,Xa as updateInlineArtifactBlocks};
6
+ `)),a=C("span","persona-code-line")),o(r.type,s[n])}return a.childNodes.length>0?t.appendChild(a):t.lastChild||t.appendChild(a),t}function Ta(e,t,a){let o=e.length<=ir?dr(t,a):null,r=o?Cr(e,o):[{type:"plain",value:e}];return yr(r)}var{setLoader:Hn,load:On,provide:br,getSync:Ra}=qe({fallbackImport:()=>import("./markdown-parsers-entry")}),$e=new Set,wr=()=>{let e=[...$e];$e.clear();for(let t of e)try{t()}catch{}};var Ea=e=>Ra()?()=>{}:($e.add(e),()=>{$e.delete(e)}),Ba=e=>{br(e),wr()},we=Ra;var Sr=e=>{if(!e)return;let t={},a=e;if(a.heading){let o=a.heading;t.heading=(r,s,n)=>o({type:"heading",raw:n,depth:s,text:r,tokens:[]})}if(a.code){let o=a.code;t.code=(r,s,n)=>o({type:"code",raw:"",text:r,lang:s,escaped:n})}if(a.blockquote){let o=a.blockquote;t.blockquote=r=>o({type:"blockquote",raw:"",text:r,tokens:[]})}if(a.table){let o=a.table;t.table=(r,s)=>o({type:"table",raw:"",header:[],rows:[],align:[],headerHtml:r,bodyHtml:s})}if(a.link){let o=a.link;t.link=(r,s,n)=>o({type:"link",raw:"",href:r,title:s??null,text:n,tokens:[]})}if(a.image){let o=a.image;t.image=(r,s,n)=>o({type:"image",raw:"",href:r,title:s??null,text:n})}if(a.list){let o=a.list;t.list=(r,s,n)=>o({type:"list",raw:"",ordered:s,start:n,loose:!1,items:[],itemsHtml:r})}if(a.listitem){let o=a.listitem;t.listitem=(r,s,n)=>o({type:"list_item",raw:"",task:s,checked:n,loose:!1,text:r,tokens:[]})}if(a.paragraph){let o=a.paragraph;t.paragraph=r=>o({type:"paragraph",raw:"",text:r,tokens:[]})}if(a.codespan){let o=a.codespan;t.codespan=r=>o({type:"codespan",raw:"",text:r})}if(a.strong){let o=a.strong;t.strong=r=>o({type:"strong",raw:"",text:r,tokens:[]})}if(a.em){let o=a.em;t.em=r=>o({type:"em",raw:"",text:r,tokens:[]})}if(a.del){let o=a.del;t.del=r=>o({type:"del",raw:"",text:r,tokens:[]})}if(a.html){let o=a.html;t.html=r=>o({type:"html",raw:r,text:r})}if(a.text){let o=a.text;t.text=r=>o({type:"text",raw:r,text:r})}if(a.checkbox){let o=a.checkbox;t.checkbox=r=>o({checked:r})}return a.hr&&(t.hr=a.hr),a.br&&(t.br=a.br),t},ea=e=>{let t=null;return a=>{let o=we();if(!o)return Re(a);if(!t){let{Marked:r}=o,s=e?.markedOptions;t=new r({gfm:s?.gfm??!0,breaks:s?.breaks??!0,pedantic:s?.pedantic,silent:s?.silent});let n=Sr(e?.renderer);n&&t.use({renderer:n})}return t.parse(a)}},Da=e=>e?ea({markedOptions:e.options,renderer:e.renderer}):ea(),Un=ea();var Re=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;");var Ar={ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","p","br","hr","div","span","ul","ol","li","dl","dt","dd","strong","em","b","i","u","s","del","ins","mark","small","sub","sup","abbr","kbd","var","samp","code","a","img","blockquote","pre","details","summary","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col","input","label","select","option","textarea","button"],ALLOWED_ATTR:["href","src","alt","title","target","rel","loading","width","height","colspan","rowspan","scope","class","id","type","name","value","placeholder","disabled","checked","for","aria-label","aria-hidden","aria-expanded","role","tabindex","data-tv-form","data-message-id","data-persona-component-directive","data-preserve-animation","data-persona-instance"]},vr=/^data:image\/(?:png|jpe?g|gif|webp|bmp|x-icon|avif)/i,kr=()=>{let e=null;return t=>{let a=we();if(!a)return Re(t);if(!e){let{DOMPurify:o}=a;e=o(typeof window<"u"?window:void 0),e.addHook("uponSanitizeAttribute",(r,s)=>{if(s.attrName==="src"||s.attrName==="href"){let n=s.attrValue;n.toLowerCase().startsWith("data:")&&!vr.test(n)&&(s.attrValue="",s.keepAttr=!1)}})}return e.sanitize(t,Ar)}},Fa=e=>e===!1?null:typeof e=="function"?e:kr();var ta=class{constructor(){this.components=new Map;this.#e=new Map}#e;register(t,a,o){this.components.has(t)&&console.warn(`[ComponentRegistry] Component "${t}" is already registered. Overwriting.`),this.components.set(t,a),o?this.#e.set(t,o):this.#e.delete(t)}unregister(t){this.components.delete(t),this.#e.delete(t)}get(t){return this.components.get(t)}has(t){return this.components.has(t)}getOptions(t){return this.#e.get(t)}getAllNames(){return Array.from(this.components.keys())}clear(){this.components.clear(),this.#e.clear()}registerAll(t){Object.entries(t).forEach(([a,o])=>{this.register(a,o)})}},Ha=new ta;var Oa=null,Ia=e=>{Oa=e.componentRegistry},qa=()=>Oa;function Je(e){if(!e)return"";if(e.artifactType==="markdown"){let t=e.markdown??"";return e.file?He(t):t}return JSON.stringify({component:e.component,props:e.props},null,2)}var aa=!1;function Mr(e){return"persona-artifact-vt-"+((e||"artifact").replace(/[^A-Za-z0-9_-]/g,"-").replace(/^-+/,"")||"artifact")}function Ua(e,t,a,o){let r=typeof document<"u"?document.startViewTransition:void 0,s=!1;try{s=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{s=!1}if(t!=="auto"||!e||typeof r!="function"||aa||s){o();return}aa=!0;let n=Mr(a);e.style.setProperty("view-transition-name",n);let f=()=>{aa=!1,e.style.removeProperty("view-transition-name")};try{r.call(document,()=>{o()}).finished.then(f,f)}catch{f(),o()}}var Lr="persona-font-mono persona-text-xs persona-whitespace-pre-wrap persona-break-words persona-text-persona-primary",Pr="persona-text-sm persona-leading-relaxed persona-markdown-bubble";function Tr(e){let t=C("div","persona-rounded-lg persona-border persona-border-persona-border persona-p-3 persona-text-persona-primary"),a=C("div","persona-font-semibold persona-text-sm persona-mb-2");a.textContent=e.component?`Component: ${e.component}`:"Component";let o=C("pre","persona-font-mono persona-text-xs persona-whitespace-pre-wrap persona-overflow-x-auto");return o.textContent=JSON.stringify(e.props??{},null,2),t.appendChild(a),t.appendChild(o),t}function Rr(e){if(e===!1)return{enabled:!1,delayMs:0,minVisibleMs:0,timeoutMs:0,injectReadySignal:!1,label:"Starting preview...",labelDelayMs:2e3};let t=e&&typeof e=="object"?e:void 0;return{enabled:!0,delayMs:t?.delayMs??200,minVisibleMs:t?.minVisibleMs??300,timeoutMs:t?.timeoutMs??8e3,injectReadySignal:t?.injectReadySignal!==!1,label:t?.label===!1?!1:t?.label??"Starting preview...",labelDelayMs:t?.labelDelayMs??2e3,renderIndicator:t?.renderIndicator}}var Er=220;function Br(){try{if(typeof crypto<"u"&&crypto.getRandomValues){let e=new Uint32Array(2);return crypto.getRandomValues(e),e[0].toString(36)+e[1].toString(36)}}catch{}return Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2)}function Dr(e){return`
7
+ <script>(function(){var d=false;var t=`+JSON.stringify(e)+";function r(){if(d)return;d=true;try{parent.postMessage({persona:'artifact-preview-ready',token:t},'*');}catch(e){}}function s(){if(typeof requestAnimationFrame==='function'){requestAnimationFrame(function(){requestAnimationFrame(r);});}setTimeout(r,150);}if(document.readyState==='complete'){s();}else{window.addEventListener('load',s);}})();</script>"}function Fr(e,t,a){let o=C("div","persona-artifact-frame-loading");if(a.renderIndicator)try{let n=a.renderIndicator({artifactId:e,config:t});if(n)return o.appendChild(n),{el:o,revealLabel:()=>{}}}catch{}let r=C("div","persona-artifact-frame-loading-indicator");r.appendChild(wa());let s=null;return a.label!==!1&&(s=C("div","persona-artifact-frame-loading-text"),s.textContent=a.label,r.appendChild(s)),o.appendChild(r),{el:o,revealLabel:()=>{s&&s.classList.add("persona-artifact-frame-loading-text--visible")}}}function Hr(e,t,a,o,r,s){let n=null,f=0,h=!1,p=new Set,i=()=>{p.forEach(b=>clearTimeout(b)),p.clear()},d=(b,L)=>{let I=setTimeout(()=>{p.delete(I),!(typeof document>"u")&&b()},L);p.add(I)},x=()=>{n&&n.parentElement&&n.remove(),n=null},u=()=>{if(n||h)return;let b=Fr(r,s,o);n=b.el,e.appendChild(n),f=Date.now(),o.label!==!1&&d(b.revealLabel,o.labelDelayMs)},m=()=>{n&&(n.classList.add("persona-artifact-frame-loading--out"),d(x,Er))},c=()=>{a!==null?typeof window<"u"&&window.removeEventListener("message",M):t.removeEventListener("load",S)},v=()=>{if(h||(h=!0,c(),i(),!n))return;let b=Math.max(0,o.minVisibleMs-(Date.now()-f));b>0?d(m,b):m()};function M(b){if(a===null)return;let L=b.data;!L||L.persona!=="artifact-preview-ready"||L.token!==a||b.source===t.contentWindow&&v()}function S(){let b=L=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>L()):setTimeout(L,0)};b(()=>b(()=>v()))}return d(u,o.delayMs),d(v,o.timeoutMs),a!==null?typeof window<"u"&&window.addEventListener("message",M):t.addEventListener("load",S),()=>{h=!0,i(),c(),x()}}function Qe(e,t){let{config:a}=t,o=t.registry??qa()??Ha,r=t.bodyLayout,s=a.markdown?Da(a.markdown):null,n=Fa(a.sanitize),f=e,h=!1,p=g=>{let E=we()!==null;s&&!E&&!h&&(h=!0,Ea(()=>$(f)));let H=s?s(g):Re(g);return s&&E&&n?n(H):H},i=C("div","persona-artifact-preview-body"),d=null,x=null,u=null,m=()=>{u&&(u(),u=null),d=null,x=null},c=null,v=null,M=null,S=!1,b=()=>{c=null,v=null,M=null,S=!1},L=null,I=null,j=()=>{L=null,I=null},oe=40,Q=0,le=g=>typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>g()):setTimeout(g,0),q=g=>g.scrollHeight-g.clientHeight-g.scrollTop<=oe,Z=g=>{if(!r)return;let E=g.scrollHeight-g.clientHeight>1,H=g.scrollHeight-g.clientHeight-g.scrollTop;g.classList.toggle("persona-artifact-fade-top",r.fadeTop&&E&&g.scrollTop>1),g.classList.toggle("persona-artifact-fade-bottom",r.fadeBottom&&E&&H>1)},U=g=>{Q||(Q=le(()=>{Q=0,g.scrollTop=g.scrollHeight,Z(g)}))},W=(g,E,H,y)=>{let P=!!r,O=H.id+"|"+(P?"w":"p");if(!c||M!==O||c.parentElement!==i){m(),j(),i.replaceChildren();let w=C("pre",Lr+" persona-code-pre"),D=C("code","persona-code");if(w.appendChild(D),P){let N=C("div","persona-artifact-source-window");if(N.appendChild(w),i.appendChild(N),!(r?.overflow==="clip")&&typeof N.addEventListener=="function"){let J=()=>N.scrollHeight-N.clientHeight>1;N.addEventListener("scroll",()=>{q(N)&&(S=!1),Z(N)},{passive:!0}),N.addEventListener("wheel",ee=>{J()&&ee.deltaY<0&&(S=!0)},{passive:!0}),N.addEventListener("touchmove",()=>{J()&&(S=!0)},{passive:!0})}c=N}else i.appendChild(w),c=w;v=D,M=O}let T=P?c:null;T&&(T.classList.toggle("persona-artifact-source-window--fixed",y),T.classList.toggle("persona-artifact-source-window--clip",y&&r?.overflow==="clip"));let B=T?q(T):!0;if(v.replaceChildren(Ta(g,E?.language,E?.path)),T){let w=H.status!=="complete";y&&w&&r?.followOutput&&!S&&B?U(T):w||(S=!1),Z(T)}},G=g=>{m(),b(),j(),i.replaceChildren();let E=C("div",Pr);E.innerHTML=p(g),i.appendChild(E)},Y=g=>{let E=g.id,H=a.features?.artifacts,y=be(g,H,"status-body");if(L&&I===E&&L.parentElement===i){let T=L.querySelector(".persona-artifact-status-view-text");T&&ce(T,y,H);return}m(),b(),i.replaceChildren();let P=C("div","persona-artifact-status-view"),O=C("div","persona-artifact-status-view-text");ce(O,y,H),P.appendChild(O),i.appendChild(P),L=P,I=E},$=g=>{f=g;let E=t.resolveViewMode?.(g)??r?.viewMode??"rendered",H=g.artifactType==="markdown"?g.file:void 0,y=g.status!=="complete";y||ye(g.id);let P=y?r?.streamingHeight:r?.completeHeight,O=!!r&&typeof P=="number";if(r?.streamingView==="status"&&y){Y(g);return}if(H){let B=He(g.markdown??""),w=pe(H),D=a.features?.artifacts?.filePreview?.enabled!==!1;if(!y&&E==="rendered"&&D&&(w==="html"||w==="svg")){let xe=g.id+"\0"+B;if(d&&x===xe&&d.parentElement===i)return;b(),j(),m(),i.replaceChildren();let J=a.features?.artifacts?.filePreview,ee=J?.iframeSandbox??"allow-scripts";!J?.dangerouslyAllowSameOrigin&&ee.includes("allow-same-origin")&&(console.warn("[AgentWidget] Stripped allow-same-origin from filePreview.iframeSandbox: it lets artifact content run with the page origin. Set filePreview.dangerouslyAllowSameOrigin to keep it."),ee=ee.split(/\s+/).filter(F=>F&&F!=="allow-same-origin").join(" "));let ge=Rr(J?.loading),_=C("div","persona-artifact-frame"),te=C("iframe","persona-artifact-iframe");te.setAttribute("sandbox",ee),te.setAttribute("data-artifact-id",g.id);let Se=null;ge.enabled&&ge.injectReadySignal?(Se=Br(),te.srcdoc=B+Dr(Se)):te.srcdoc=B,_.appendChild(te),i.appendChild(_),ge.enabled&&(u=Hr(_,te,Se,ge,g.id,a)),d=_,x=xe;return}if(m(),!y&&w==="markdown"&&E==="rendered"){G(B);return}W(B,{language:H.language,path:H.path},g,O);return}if(g.artifactType==="markdown"){if(E==="source"){m(),W(g.markdown??"",void 0,g,O);return}G(g.markdown??"");return}m(),b(),j(),i.replaceChildren();let T=g.component?o.get(g.component):void 0;if(T){let w={message:{id:g.id,role:"assistant",content:"",createdAt:new Date().toISOString()},config:a,updateProps:()=>{}};try{let D=T(g.props??{},w);if(D){i.appendChild(D);return}}catch{}}i.appendChild(Tr(g))};return $(e),{el:i,update(g){$(g)},destroy(){m()}}}function Na(e,t){let a=t.orientation??"horizontal",o=a==="vertical"?"ArrowUp":"ArrowLeft",r=a==="vertical"?"ArrowDown":"ArrowRight";e.setAttribute("role","tablist");let s=[],n=!1,f=d=>{typeof d.scrollIntoView=="function"&&d.scrollIntoView({block:"nearest",inline:"nearest"})},h=d=>{let x=d;return s.findIndex(u=>u===x||u.contains(x))},p=d=>{let x=h(d.target);if(x<0)return;let u=x;if(d.key===r)u=Math.min(x+1,s.length-1);else if(d.key===o)u=Math.max(x-1,0);else if(d.key==="Home")u=0;else if(d.key==="End")u=s.length-1;else return;d.preventDefault(),u!==x&&t.onSelect(u)},i=d=>{let x=h(d.target);x>=0&&f(s[x])};return e.addEventListener("keydown",p),e.addEventListener("focusin",i),{beforeRender(){n=typeof document<"u"&&e.contains(document.activeElement)},render(d,x){if(s=d,d.forEach((u,m)=>{u.setAttribute("role","tab");let c=m===x;u.setAttribute("aria-selected",c?"true":"false"),u.tabIndex=c||x<0&&m===0?0:-1}),n){let u=(x>=0?d[x]:void 0)??d[0];u&&typeof u.focus=="function"&&(f(u),u.focus())}},destroy(){e.removeEventListener("keydown",p),e.removeEventListener("focusin",i)}}}function Va(e,t){let a=e.features?.artifacts?.layout,r=(a?.toolbarPreset??"default")==="document",s=a?.toolbarTitle??"Artifacts",n=a?.closeButtonLabel??"Close",f=a?.panePadding?.trim(),h=a?.tabFadeSize?.trim(),p=l=>({start:l===!1?!1:typeof l=="object"&&l?l.start!==!1:!0,end:l===!1?!1:typeof l=="object"&&l?l.end!==!1:!0}),{start:i,end:d}=p(a?.tabFade),x=typeof document<"u"?C("div","persona-artifact-backdrop persona-fixed persona-inset-0 persona-z-[55] persona-bg-black/30 persona-hidden md:persona-hidden"):null,u=()=>{x?.classList.add("persona-hidden"),m.classList.remove("persona-artifact-drawer-open"),Z?.closeMenu()};x&&x.addEventListener("click",()=>{u(),t.onDismiss?.()});let m=C("aside","persona-artifact-pane persona-flex persona-flex-col persona-min-h-0 persona-min-w-0 persona-bg-persona-surface persona-text-persona-primary persona-border-l persona-border-persona-border");m.setAttribute("data-persona-theme-zone","artifact-pane"),r&&m.classList.add("persona-artifact-pane-document");let c=C("div","persona-artifact-toolbar persona-flex persona-items-center persona-justify-between persona-gap-2 persona-px-2 persona-py-2 persona-border-b persona-border-persona-border persona-shrink-0");c.setAttribute("data-persona-theme-zone","artifact-toolbar"),r&&c.classList.add("persona-artifact-toolbar-document");let v=C("span","persona-text-xs persona-font-medium persona-truncate");v.textContent=s;let M=V({icon:"x",label:n});M.addEventListener("click",()=>{u(),t.onDismiss?.()});let S="rendered",b=je({items:[{id:"rendered",icon:"eye",label:"Rendered view",className:r?"persona-artifact-doc-icon-btn persona-artifact-view-btn":void 0},{id:"source",icon:"code-xml",label:"Source",className:r?"persona-artifact-doc-icon-btn persona-artifact-code-btn":void 0}],selectedId:"rendered",className:"persona-artifact-toggle-group persona-shrink-0",onSelect:l=>{S=l==="source"?"source":"rendered",De()}}),L=C("div","persona-flex persona-items-center persona-gap-1 persona-shrink-0"),I=a?.documentToolbarShowCopyLabel===!0,j=a?.documentToolbarShowCopyChevron===!0,oe=a?.documentToolbarCopyMenuItems,Q=!!(j&&oe&&oe.length>0),le=null,q,Z=null;if(r&&(I||j)&&!Q){if(q=I?me({icon:"copy",label:"Copy",iconSize:14,className:"persona-artifact-doc-copy-btn"}):V({icon:"copy",label:"Copy",className:"persona-artifact-doc-copy-btn"}),j){let l=ne(ve,14,"currentColor",2);l&&q.appendChild(l)}}else r&&Q?(Z=ba({label:"Copy",icon:"copy",iconSize:14,iconOnly:!I,primaryClassName:"persona-artifact-doc-copy-btn",chevronLabel:"More copy options",chevronClassName:"persona-artifact-doc-copy-menu-chevron persona-artifact-doc-icon-btn",menuItems:(oe??[]).map(l=>({id:l.id,label:l.label})),position:"bottom-right",portal:()=>m.closest("[data-persona-root]")??document.body,onSelect:l=>{T(l)}}),le=Z.element,q=Z.primaryButton):r?q=V({icon:"copy",label:"Copy",className:"persona-artifact-doc-icon-btn"}):(q=V({icon:"copy",label:"Copy"}),a?.showCopyButton!==!0&&q.classList.add("persona-hidden"));let U=r?V({icon:"refresh-cw",label:"Refresh",className:"persona-artifact-doc-icon-btn"}):V({icon:"refresh-cw",label:"Refresh"});a?.onDocumentToolbarRefresh||U.classList.add("persona-hidden");let W=r?V({icon:"x",label:n,className:"persona-artifact-doc-icon-btn"}):V({icon:"x",label:n}),G=V({icon:"maximize",label:"Expand artifacts panel",className:"persona-artifact-expand-btn"+(r?" persona-artifact-doc-icon-btn":""),onClick:()=>t.onToggleExpand?.()});a?.showExpandToggle!==!0&&G.classList.add("persona-hidden");let Y=C("div","persona-flex persona-items-center persona-gap-1 persona-shrink-0 persona-artifact-toolbar-custom-actions"),$=e.features?.artifacts?.toolbarActions??[],g=()=>{let l=F.find(se=>se.id===X)??F[F.length-1],k=l?.id??null,A=l?.artifactType==="markdown"?l.markdown??"":"",R=l?JSON.stringify({component:l.component,props:l.props},null,2):"",{filename:z,mime:K,content:fe}=Oe({title:l?.title,markdown:l?.markdown??"",file:l?.file});return{markdown:A,jsonPayload:R,id:k,file:l?.file,suggestedFilename:z,mime:K,content:fe}},E=()=>{let{suggestedFilename:l,mime:k,content:A}=g();A&&Ie({filename:l,mime:k,content:A})},H=l=>{let{id:k,...A}=g();return{actionId:l,artifactId:k,...A}},y=async()=>{let l=F.find(k=>k.id===X)??F[F.length-1];try{return await navigator.clipboard.writeText(Je(l)),!0}catch{return!1}},P=null,O=()=>{P?.();let l=q.querySelector("svg"),k=Number(l?.getAttribute("width"))||16,A=ne(Ae,k,"currentColor",2);if(!l||!A)return;l.replaceWith(A);let R=q.querySelector("span");R&&(R.textContent="Copied");let z=setTimeout(()=>P?.(),2e3);P=()=>{clearTimeout(z),A.replaceWith(l),R&&(R.textContent="Copy"),P=null}};q.addEventListener("click",async()=>{let l=a?.onDocumentToolbarCopyMenuSelect;if(l&&Q){try{if(await l(H("primary"))===!1){await y()&&O();return}O()}catch{}return}await y()&&O()});async function T(l){let k=a?.onDocumentToolbarCopyMenuSelect;try{if(k&&await k(H(l))!==!1)return;if(l==="download"){E();return}let{markdown:A,jsonPayload:R}=g();l==="markdown"||l==="md"?await navigator.clipboard.writeText(A):l==="json"||l==="source"?await navigator.clipboard.writeText(R):await navigator.clipboard.writeText(A||R),O()}catch{}}U.addEventListener("click",async()=>{try{await a?.onDocumentToolbarRefresh?.()}catch{}De()}),W.addEventListener("click",()=>{u(),t.onDismiss?.()});let B=C("span","persona-min-w-0 persona-flex-1 persona-text-xs persona-font-medium persona-text-persona-primary persona-truncate persona-text-center md:persona-text-left");if(r)c.replaceChildren(),le?L.append(le,U,W):L.append(q,U,W),L.insertBefore(Y,W),L.insertBefore(G,W),c.append(b.element,B,L);else{let l=C("div","persona-flex persona-items-center persona-gap-1 persona-shrink-0");l.append(q,Y,G,M),c.appendChild(v),c.appendChild(l)}f&&(c.style.paddingLeft=f,c.style.paddingRight=f);let w=C("div","persona-artifact-list persona-shrink-0 persona-flex persona-gap-1 persona-overflow-x-auto persona-p-2 persona-border-b persona-border-persona-border");h&&w.style.setProperty("--persona-artifact-tab-fade-size",h);let D=e.features?.artifacts?.renderTabBar,N=C("div","persona-artifact-tab-custom persona-shrink-0 persona-border-b persona-border-persona-border persona-hidden"),xe=Na(w,{onSelect:l=>t.onSelect(F[l].id)}),J=l=>{let k=l.scrollWidth-l.clientWidth,A=k>1,R=Math.abs(l.scrollLeft);l.classList.toggle("persona-artifact-tab-fade-start",i&&A&&R>1),l.classList.toggle("persona-artifact-tab-fade-end",d&&A&&R<k-1)},ee=0,ge=()=>{if(ee)return;let l=()=>{ee=0,J(w)};ee=typeof requestAnimationFrame=="function"?requestAnimationFrame(l):setTimeout(l,0)};w.addEventListener("scroll",()=>ge(),{passive:!0}),typeof ResizeObserver<"u"&&new ResizeObserver(()=>J(w)).observe(w);let _=C("div","persona-artifact-content persona-flex-1 persona-min-h-0 persona-overflow-y-auto persona-p-3"),te=()=>{_.scrollLeft=0},Se=()=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(te):setTimeout(te,0)};if(f){for(let l of[w,N])l.style.paddingLeft=f,l.style.paddingRight=f;_.style.padding=f}m.appendChild(c),m.appendChild(w),m.appendChild(N),m.appendChild(_);let F=[],X=null,et=!1,ra=!1,tt=!0,at=!1,oa=null,rt="",ae=null,Be=!1,$a=l=>l.artifactType==="markdown"&&!!l.file||r?S:"rendered",sa=l=>{r||(l&&!Be?(c.insertBefore(b.element,v),Be=!0):!l&&Be&&(b.element.remove(),Be=!1))},na=()=>X&&F.find(l=>l.id===X)||F[F.length-1],la=()=>{let l=Te(na());if(!l){Y.replaceChildren();return}let k=$.filter(A=>A.visible===void 0||A.visible(l)).map(A=>Ce(A,{documentChrome:r,onClick:()=>{let R=Te(na());if(R)try{Promise.resolve(A.onClick(R)).catch(()=>{})}catch{}}}));Y.replaceChildren(...k)},De=()=>{la();let l=r&&F.length<=1,k=!!D;if(w.classList.toggle("persona-hidden",l||k),N.classList.toggle("persona-hidden",l||!k),k&&D){let z=F.map(K=>K.id).join("|")+" "+(X??"");if(z!==rt){rt=z;let K=D({records:F,selectedId:X,onSelect:t.onSelect});N.firstElementChild!==K&&N.replaceChildren(K)}}else{xe.beforeRender(),w.replaceChildren();let z=[],K=-1;for(let[fe,se]of F.entries()){let ie=C("button","persona-artifact-tab persona-shrink-0 persona-rounded-lg persona-px-2 persona-py-1 persona-text-xs persona-border persona-border-transparent persona-text-persona-primary");ie.type="button";let ot=se.artifactType==="markdown"?se.file:void 0,da=ot?re(ot.path):se.title||se.id.slice(0,8),ua=ot?.path||se.title||da;ie.textContent=da,ie.title=ua,ie.setAttribute("aria-label",ua),se.id===X&&(ie.classList.add("persona-bg-persona-container","persona-border-persona-border"),K=fe),ie.addEventListener("click",()=>t.onSelect(se.id)),w.appendChild(ie),z.push(ie)}if(xe.render(z,K),K>=0&&X!==oa){oa=X;let fe=z[K];typeof fe.scrollIntoView=="function"&&fe.scrollIntoView({block:"nearest",inline:"nearest"})}J(w)}let A=X&&F.find(z=>z.id===X)||F[F.length-1];if(!A){_.replaceChildren(),ae?.destroy(),ae=null,sa(!1);return}let R=A.artifactType==="markdown"?A.file:void 0;if(sa(!!R&&pe(R)!=="other"),r){let z=R?de(R):A.artifactType==="markdown"?"MD":A.component??"Component",K=(A.title||"Document").trim(),fe=R?re(R.path):K.replace(/\s*·\s*MD\s*$/i,"").trim()||"Document";B.textContent=`${fe} \xB7 ${z}`}else v.textContent=R?re(R.path):s;ae?(ae.el.parentElement!==_&&_.replaceChildren(ae.el),ae.update(A)):(ae=Qe(A,{config:e,resolveViewMode:$a}),_.replaceChildren(ae.el)),_.classList.toggle("persona-artifact-content-flush",!!_.querySelector(".persona-code-pre"))},fa=()=>{let l=F.length>0;if(m.classList.toggle("persona-hidden",!l),x){let R=((typeof m.closest=="function"?m.closest("[data-persona-root]"):null)?.classList.contains("persona-artifact-narrow-host")??!1)||typeof window<"u"&&window.matchMedia("(max-width: 640px)").matches;l&&R&&et?(x.classList.remove("persona-hidden"),m.classList.add("persona-artifact-drawer-open")):(x.classList.add("persona-hidden"),m.classList.remove("persona-artifact-drawer-open"))}},ia=()=>{at=!1,De(),fa()};return{element:m,backdrop:x,update(l){let k=l.selectedId??l.artifacts[l.artifacts.length-1]?.id??null,A=k!==X;F=l.artifacts,X=k,F.length>0&&(et=!0),at=!0,tt&&ia(),A&&te()},setMobileOpen(l){et=l,!l&&x?(x.classList.add("persona-hidden"),m.classList.remove("persona-artifact-drawer-open")):fa()},setExpanded(l){l!==ra&&(ra=l,Se());let k=ne(l?Le:Me,16,"currentColor",2);k&&G.replaceChildren(k);let A=l?"Collapse artifacts panel":"Expand artifacts panel";G.setAttribute("aria-label",A),G.title=A},setExpandToggleVisible(l){G.classList.toggle("persona-hidden",!l)},setCopyButtonVisible(l){r||q.classList.toggle("persona-hidden",!l)},setRefreshButtonVisible(l){U.classList.toggle("persona-hidden",!l)},setCustomActions(l){$=l,la()},setTabFade(l){let k=p(l);k.start===i&&k.end===d||(i=k.start,d=k.end,J(w))},setRenderTabBar(l){l!==D&&(D=l,rt="",De())},setVisible(l){l!==tt&&(tt=l,l&&at&&ia())},destroy(){ae?.destroy(),ae=null}}}function za(e,t){let a=e.file&&typeof e.file=="object"&&!Array.isArray(e.file)?e.file:void 0,o=typeof e.title=="string"&&e.title?e.title:"Untitled artifact",r=a?re(a.path):o,s=typeof e.artifactId=="string"?e.artifactId:"",n=e.status==="streaming"?"streaming":"complete",f=typeof e.artifactType=="string"?e.artifactType:"markdown",h=e.presentation&&typeof e.presentation=="object"&&!Array.isArray(e.presentation)?e.presentation:void 0,p=a?de(a):f==="component"?"Component":"Document",i=document.createElement("div");i.className="persona-artifact-card persona-flex persona-w-full persona-max-w-full persona-items-center persona-gap-3 persona-px-4 persona-py-3",i.tabIndex=0,i.setAttribute("role","button"),i.setAttribute("aria-label",`Open ${r} in artifact panel`),s&&i.setAttribute("data-open-artifact",s);let d=document.createElement("div");d.className="persona-flex persona-h-10 persona-w-10 persona-flex-shrink-0 persona-items-center persona-justify-center persona-rounded-lg",d.style.border="1px solid var(--persona-border, #e5e7eb)",d.style.color="var(--persona-muted, #9ca3af)",d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/></svg>';let x=document.createElement("div");x.className="persona-min-w-0 persona-flex-1 persona-flex persona-flex-col persona-gap-0.5";let u=document.createElement("div");u.className="persona-truncate persona-text-sm persona-font-medium",u.style.color="var(--persona-text, #1f2937)",u.textContent=r;let m=document.createElement("div");if(m.className="persona-text-xs persona-flex persona-items-center persona-gap-1.5",m.style.color="var(--persona-muted, #9ca3af)",n==="streaming"){let c=t?.config?.features?.artifacts,v={id:s,artifactType:f==="component"?"component":"markdown",title:o,status:"streaming",...typeof e.markdown=="string"?{markdown:e.markdown}:{},...a?{file:a}:{},...h?{presentation:h}:{}},M=be(v,c,"card");ce(m,M,c)}else s&&ye(s),m.textContent=p;if(x.append(u,m),i.append(d,x),n==="complete"){let c=t?.config?.features?.artifacts?.cardActions;if(c&&c.length>0){let M={artifactId:s||null,title:r,artifactType:f,markdown:typeof e.markdown=="string"?e.markdown:void 0,file:a};for(let S of c)try{if(S.visible===void 0||S.visible(M)){let b=Ce(S);b.setAttribute("data-artifact-custom-action",S.id),b.className=`${b.className} persona-flex-shrink-0`,i.append(b)}}catch{}}let v=me({label:"Download",className:"persona-flex-shrink-0"});v.title=`Download ${r}`,v.setAttribute("data-download-artifact",s),i.append(v)}return i}var Ye=(e,t)=>{let a=t?.config?.features?.artifacts?.renderCard;if(a){let o=typeof e.title=="string"&&e.title?e.title:"Untitled artifact",r=typeof e.artifactId=="string"?e.artifactId:"",s=e.status==="streaming"?"streaming":"complete",n=typeof e.artifactType=="string"?e.artifactType:"markdown",f=a({artifact:{artifactId:r,title:o,artifactType:n,status:s},config:t.config,defaultRenderer:()=>za(e,t)});if(f)return f}return za(e,t)};var ue=new WeakMap;function Xa(e,t,a){if(t.length===0)return;let o=new Map(t.map(r=>[r.id,r]));e.querySelectorAll("[data-artifact-inline]").forEach(r=>{let s=ue.get(r);if(!s)return;let n=o.get(r.getAttribute("data-artifact-inline")??"");n&&s(n,a)})}function Ka(e){return ue.has(e)}function Or(e){let t=typeof e.artifactId=="string"?e.artifactId:"",a=typeof e.title=="string"&&e.title?e.title:void 0,o=e.status==="streaming"?"streaming":"complete",r=e.presentation&&typeof e.presentation=="object"&&!Array.isArray(e.presentation)?e.presentation:void 0;if(e.artifactType==="component"){let n=e.componentProps,f=n&&typeof n=="object"&&!Array.isArray(n)?n:{};return{id:t,artifactType:"component",title:a,status:o,component:typeof e.component=="string"?e.component:"",props:f,...r?{presentation:r}:{}}}let s=e.file&&typeof e.file=="object"&&!Array.isArray(e.file)?e.file:void 0;return{id:t,artifactType:"markdown",title:a,status:o,markdown:typeof e.markdown=="string"?e.markdown:"",...s?{file:s}:{},...r?{presentation:r}:{}}}function Wa(e){let t=e.artifactType==="markdown"?e.file:void 0,a=t?re(t.path):e.title&&e.title.trim()?e.title:"Untitled artifact",o=t?de(t):e.artifactType==="component"?"Component":"Document";return{title:a,typeLabel:o}}function Ir(e){let t={artifactId:e.id,title:e.title??"",status:e.status,artifactType:e.artifactType};return e.artifactType==="markdown"&&(typeof e.markdown=="string"&&(t.markdown=e.markdown),e.file&&(t.file=e.file)),t}var Ga=180,qr=240,Ur=.8,Nr=300,Vr=500,zr="cubic-bezier(0.2, 0, 0, 1)",_a=240,Wr=.35;function Gr(e,t,a){let{swap:o,onSettled:r}=a,s=!1;try{s=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{s=!1}if(!t||!e.isConnected||s||typeof e.animate!="function"){o(),r();return}e.style.height=`${t}px`,e.style.overflow="hidden";let n=[];for(let f of Array.from(e.children))f instanceof HTMLElement&&n.push(f.animate([{opacity:1},{opacity:0}],{duration:Ga,easing:"ease-out",fill:"forwards"}));window.setTimeout(()=>{for(let M of n)M.cancel();o();let f=()=>{e.style.removeProperty("height"),e.style.removeProperty("overflow")};if(!e.isConnected){f(),r();return}e.style.height="auto";let h=e.getBoundingClientRect().height;if(e.style.height=`${t}px`,!h||Math.abs(h-t)<1){f(),r();return}let p=Math.abs(t-h),i=Math.round(Math.min(Vr,Math.max(Nr,qr+p*Ur))),d=Math.round(i*Wr),x=e.firstElementChild instanceof HTMLElement?e.firstElementChild:null,u=x?x.animate([{opacity:0},{opacity:1}],{duration:_a,delay:d,easing:"ease-out",fill:"backwards"}):null,m=e.animate([{height:`${t}px`},{height:`${h}px`}],{duration:i,easing:zr});e.style.height=`${h}px`;let c=!1,v=()=>{c||(c=!0,f(),r())};Promise.allSettled([m.finished,u?.finished].filter(Boolean)).then(v),window.setTimeout(v,Math.max(i,d+_a)+120)},Ga)}function _r(e){let t=e?.inlineChrome;if(t===!1)return{chromeEnabled:!1,showCopy:!1,showExpand:!1,showViewToggle:!1};let a=typeof t=="object"?t:void 0;return{chromeEnabled:!0,showCopy:a?.showCopy!==!1,showExpand:a?.showExpand!==!1,showViewToggle:a?.showViewToggle!==!1}}var Ee="--persona-artifact-inline-body-height";function jr(e){let t=e?.inlineBody,a=t?.streamingView==="status"?"status":"source",o=t?.viewMode==="source"?"source":"rendered",r=320,s=320,n=t?.height;typeof n=="number"||n==="auto"?(r=n,s=n):n&&typeof n=="object"&&(r=n.streaming??320,s=n.complete??320);let f=t?.overflow==="clip"?"clip":"scroll",h=f==="clip"?!1:t?.followOutput!==!1,p,i,d=t?.fadeMask;d===!0?(p=!0,i=!0):d===!1?(p=!1,i=!1):d&&typeof d=="object"?(p=d.top===!0,i=d.bottom===!0):f==="clip"?(p=!1,i=!0):(p=!0,i=!0);let x=t?.transition==="none"?"none":"auto",u=t?.completeDisplay==="card"?"card":"inline";return{streamingView:a,viewMode:o,streamingHeight:r,completeHeight:s,followOutput:h,overflow:f,fadeTop:p,fadeBottom:i,transition:x,completeDisplay:u}}function ja(e,t){let a=Or(e),o=t.config?.features?.artifacts,{chromeEnabled:r,showCopy:s,showExpand:n,showViewToggle:f}=_r(o),h=o?.inlineActions??[],p=jr(o),i=p.completeDisplay==="card",d=null,x=a,u=C("div","persona-artifact-inline persona-w-full persona-max-w-full");u.setAttribute("data-persona-theme-zone","artifact-inline"),a.id&&u.setAttribute("data-artifact-inline",a.id);let m=y=>Ye(Ir(y),t),c=null,v=y=>{c?.destroy(),c=null,u.classList.add("persona-artifact-inline--card"),u.style.removeProperty(Ee),u.replaceChildren(m(y)),ue.set(u,P=>{u.replaceChildren(m(P))})};if(i&&a.status==="complete")return v(a),u;let M=Qe(a,{config:t.config,bodyLayout:p,resolveViewMode:()=>d??p.viewMode});c=M;let S=C("div","persona-artifact-inline-body");S.appendChild(M.el);let b=y=>{let P=y.status!=="complete",O=P?p.streamingHeight:p.completeHeight,T=typeof O=="number";T?u.style.setProperty(Ee,`${O}px`):u.style.removeProperty(Ee);let B=!!M.el.querySelector(".persona-code-pre"),w=!!M.el.querySelector("iframe, .persona-artifact-source-window--fixed, .persona-artifact-status-view");S.classList.toggle("persona-artifact-content-flush",B),S.classList.toggle("persona-artifact-inline-body--sized",T&&w),S.classList.toggle("persona-artifact-inline-body--cap",!P&&!w&&typeof p.completeHeight=="number")},L=a.status,I=(y,P)=>{L!=="complete"&&y.status==="complete"?(typeof p.completeHeight=="number"?u.style.setProperty(Ee,`${p.completeHeight}px`):u.style.removeProperty(Ee),Ua(S,P?.suppressTransition?"none":p.transition,y.id,()=>{M.update(y),b(y)})):M.update(y),b(y),L=y.status};b(a);let j=p.overflow==="clip"&&n&&!!a.id;if(j&&(S.setAttribute("data-expand-artifact-inline",a.id),S.setAttribute("role","button"),S.setAttribute("tabindex","0"),S.classList.add("persona-cursor-pointer"),S.setAttribute("aria-label",`Open ${Wa(a).title} in panel`)),!r)return u.appendChild(S),ue.set(u,I),u;let oe=C("div","persona-artifact-inline-chrome");oe.setAttribute("data-persona-theme-zone","artifact-inline-chrome");let Q=C("div","persona-artifact-inline-chrome-lead"),le=C("span","persona-flex persona-items-center persona-flex-shrink-0"),q=ne(ke,16,"currentColor",2);q&&le.appendChild(q);let Z=C("span","persona-artifact-inline-title persona-truncate persona-min-w-0"),U=C("span","persona-artifact-inline-type");Q.append(le,Z,U);let W=C("div","persona-artifact-inline-chrome-actions"),G=C("span","persona-flex persona-items-center persona-gap-1"),Y=()=>d??p.viewMode,$=f?je({items:[{id:"rendered",icon:"eye",label:"Rendered view",className:"persona-artifact-doc-icon-btn persona-artifact-view-btn"},{id:"source",icon:"code-xml",label:"Source",className:"persona-artifact-doc-icon-btn persona-artifact-code-btn"}],selectedId:Y(),className:"persona-artifact-toggle-group persona-flex-shrink-0",onSelect:y=>{let P=y==="source"?"source":"rendered";P!==Y()&&(d=P,M.update(x),b(x))}}):null,g=s?V({icon:"copy",label:"Copy",className:"persona-artifact-doc-icon-btn persona-flex-shrink-0"}):null;g&&a.id&&g.setAttribute("data-copy-artifact",a.id);let E=n?V({icon:"maximize",label:"Open in panel",className:"persona-artifact-doc-icon-btn persona-flex-shrink-0"}):null;E&&a.id&&E.setAttribute("data-expand-artifact-inline",a.id),W.appendChild(G),$&&W.appendChild($.element),g&&W.appendChild(g),E&&W.appendChild(E),oe.append(Q,W),u.append(oe,S);let H=y=>{let{title:P,typeLabel:O}=Wa(y);Z.textContent=P,Z.title=P,j&&S.setAttribute("aria-label",`Open ${P} in panel`);let T=y.status!=="complete";if(T){U.classList.contains("persona-artifact-inline-status")||(U.className="persona-artifact-inline-status",U.removeAttribute("data-preserve-animation"),U.replaceChildren());let B=be(y,o,"inline-chrome");ce(U,B,o)}else ye(y.id),U.className="persona-artifact-inline-type",U.removeAttribute("data-preserve-animation"),U.replaceChildren(),U.textContent=O;if(g&&g.classList.toggle("persona-hidden",T),$){let B=y.artifactType==="markdown"?y.file:void 0,w=!1;if(!T&&B&&p.viewMode!=="source"){let D=pe(B);D==="markdown"?w=!0:(D==="html"||D==="svg")&&(w=o?.filePreview?.enabled!==!1)}$.element.classList.toggle("persona-hidden",!w),$.setSelected(Y())}if(G.replaceChildren(),!T&&h.length>0){let B=Te(y);if(B)for(let w of h)try{if(w.visible===void 0||w.visible(B)){let D=Ce(w,{documentChrome:!0});D.setAttribute("data-artifact-custom-action",w.id),D.classList.add("persona-flex-shrink-0"),G.appendChild(D)}}catch{}}};return H(a),ue.set(u,(y,P)=>{if(i&&L!=="complete"&&y.status==="complete"){let O=u.isConnected?u.getBoundingClientRect().height:0;L="complete";let T=y,B=!1,w=D=>{T=D,B=!0};ue.set(u,w),Gr(u,O,{swap:()=>{v(T),B=!1,ue.set(u,w)},onSettled:()=>{B?v(T):ue.set(u,D=>{u.replaceChildren(m(D))})}});return}(y.status!=="complete"||y.id!==x.id)&&(d=null),x=y,I(y,P),H(y)}),u}var Za=(e,t)=>{let a=t?.config?.features?.artifacts?.renderInline;if(a){let o=typeof e.title=="string"&&e.title?e.title:"Untitled artifact",r=typeof e.artifactId=="string"?e.artifactId:"",s=e.status==="streaming"?"streaming":"complete",n=typeof e.artifactType=="string"?e.artifactType:"markdown",f=a({artifact:{artifactId:r,title:o,artifactType:n,status:s},config:t.config,defaultRenderer:()=>ja(e,t)});if(f)return f}return ja(e,t)};export{Ye as PersonaArtifactCard,Za as PersonaArtifactInline,Ba as __provideMarkdownParsers,ca as __setIconsExtraLoader,Je as artifactCopyText,Va as createArtifactPane,Oe as downloadInfoFor,Ka as hasLiveInlineArtifactBlock,Ia as initArtifactsUi,Ie as triggerArtifactDownload,Xa as updateInlineArtifactBlocks};
8
8
  /*! Bundled license information:
9
9
 
10
10
  lucide/dist/esm/icons/activity.mjs:
@@ -0,0 +1 @@
1
+ var n={idle:"Online",connecting:"Connecting\u2026",connected:"Streaming\u2026",error:"Offline",paused:"Connection lost\u2026",resuming:"Reconnecting\u2026"},t=1e5,e=t+1,o="https://api.runtype.com";export{n as a,t as b,e as c,o as d};
@@ -0,0 +1 @@
1
+ var t=class extends Error{constructor(o,i,r){super(i),this.name="HistoryProviderError",this.code=o,r?.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=r.retryAfterSeconds)}};function s(e){return e instanceof t}export{t as a,s as b};
@@ -0,0 +1 @@
1
+ var r=class{#t=null;#e=0;#h=[];#o=[];#l=[];#u=!1;#a=!1;#f=0;#m=!1;#y=!1;#r;#i=[];#d=0;#b=!1;#g;#c;#n;#s=null;constructor(t=24e3,e={}){this.#c=t;let s=Math.max(0,e.prebufferMs??0);this.#n=Math.round(t*s/1e3),this.#r=this.#n>0}#A(){if(!this.#t){let e=typeof window<"u"?window:void 0;if(!e)throw new Error("AudioPlaybackManager requires a browser environment");let s=e.AudioContext||e.webkitAudioContext;this.#t=new s({sampleRate:this.#c})}let t=this.#t;return t.state==="suspended"&&!this.#y&&t.resume(),t}enqueue(t){if(t.length===0)return;let e=t;if(this.#s){let i=new Uint8Array(this.#s.length+t.length);i.set(this.#s),i.set(t,this.#s.length),e=i,this.#s=null}if(e.length%2!==0&&(this.#s=new Uint8Array([e[e.length-1]]),e=e.subarray(0,e.length-1)),e.length===0)return;let s=this.#x(e);s.length!==0&&(this.#r?(this.#i.push(s),this.#d+=s.length,clearTimeout(this.#g),this.#d>=this.#n?this.#p():this.#b&&(this.#g=setTimeout(()=>this.#p(),this.#n/this.#c*1e3))):this.#v(s))}markStreamEnd(){this.#i.length>0&&this.#p(),this.#a=!0,this.#w()}flush(){for(let t of this.#h){t.onended=null;try{t.stop(),t.disconnect()}catch{}}this.#h=[],this.#f=0,this.#e=0,this.#u=!1,this.#a=!1,this.#o=[],this.#l=[],this.#s=null,this.#i=[],this.#d=0,this.#r=this.#n>0,this.#m=!1,clearTimeout(this.#g)}setContinuousMode(t){this.#b=t}isPlaying(){return this.#u}onFinished(t){this.#o.push(t)}onStarted(t){this.#l.push(t)}pause(){this.#y=!0,this.#t&&this.#t.state==="running"&&this.#t.suspend()}resume(){this.#y=!1,this.#t&&this.#t.state==="suspended"&&this.#t.resume()}async destroy(){this.flush(),this.#t&&(await this.#t.close(),this.#t=null)}#p(){this.#r=!1;let t=this.#i;this.#i=[],this.#d=0;for(let e of t)this.#v(e)}#v(t){if(t.length===0)return;let e=this.#A(),s=e.createBuffer(1,t.length,this.#c);s.getChannelData(0).set(t);let i=e.createBufferSource();i.buffer=s,i.connect(e.destination);let n=e.currentTime;if(this.#e===0?this.#e=n:this.#e<n&&(this.#e=n,this.#n>0&&(this.#r=!0)),i.start(this.#e),this.#e+=s.duration,this.#h.push(i),this.#f++,this.#u=!0,!this.#m){this.#m=!0;let h=this.#l.slice();this.#l=[];for(let o of h)o()}i.onended=()=>{let h=this.#h.indexOf(i);h!==-1&&(this.#h.splice(h,1),this.#f--,this.#w())}}#w(){if(this.#a&&this.#f<=0&&this.#i.length===0){this.#u=!1,this.#a=!1;let t=this.#o.slice();this.#o=[];for(let e of t)e()}}#x(t){let e=Math.floor(t.length/2),s=new Float32Array(e),i=new DataView(t.buffer,t.byteOffset,t.byteLength);for(let n=0;n<e;n++){let h=i.getInt16(n*2,!0);s[n]=h/32768}return s}};export{r as a};
@@ -0,0 +1,9 @@
1
+ import{c as i}from"./chunk-76IELU7F.js";var c="[data-persona-composer-chip-row]";function p(n){n.style.display=n.childElementCount>0?"flex":"none"}function u(n){let e=n.querySelector(c);if(e)return e;let t=i("div",{className:"persona-composer-chip-row",attrs:{"data-persona-composer-chip-row":""}});t.style.display="none";let o=n.querySelector("[data-persona-composer-quote], [data-persona-composer-pending]");return o?.parentElement===n?n.insertBefore(t,o):n.appendChild(t),t}function s(n){let e=0;for(let t of n.split(`
2
+ `)){let o=/^ {0,3}(`+)/.exec(t);o&&o[1].length>e&&(e=o[1].length)}return e}function r(n,e){let t="`".repeat(Math.max(3,s(e)+1));return`${t}${n}
3
+ ${e}
4
+ ${t}`}function l(n,e,t){return e.includes("</document_content>")?r(n,e):`<document index="${t+1}">
5
+ <source>${n}</source>
6
+ <document_content>
7
+ ${e}
8
+ </document_content>
9
+ </document>`}function f(n,e,t="fenced"){if(typeof t=="function")try{return t(n,e)}catch(o){return console.warn("[persona] contextMentions.llmFormat threw; falling back to the fenced format for this mention",o),r(n.label,n.text)}return t==="document"?l(n.label,n.text,e):r(n.label,n.text)}export{c as a,p as b,u as c,r as d,f as e};
@@ -0,0 +1,3 @@
1
+ var u=/\s/;function g(n,e,t){if(t==="input-start")return e===0;let r=e>0?n[e-1]:"";return t==="line-start"?r===""||r===`
2
+ `:r===""||u.test(r)}function l(n,e,t="@",r="anywhere",o=!1){if(!t||e<=0||e>n.length)return null;let i=e-1;for(;i>=0;){let s=n[i];if(s===t)return g(n,i,r)?{triggerIndex:i,query:n.slice(i+1,e)}:null;if(s===`
3
+ `||s==="\uFFFC"||!o&&u.test(s))return null;i--}return null}function c(n,e,t){for(let r of t){let o=l(n,e,r.trigger,r.position??"anywhere",r.allowSpaces??!1);if(o)return{channel:r,match:o}}return null}function a(n){return n?n!=="insertFromPaste"&&n!=="insertFromDrop":!0}function f(n,e,t){return{value:n.slice(0,e.triggerIndex)+n.slice(t),caret:e.triggerIndex}}export{c as a,a as b,f as c};
@@ -0,0 +1 @@
1
+ import{a as y,b as h,c as A,d as b,e as w,h as M}from"./chunk-S6PBWE75.js";var C=null;var f=()=>{if(C!==null)return C;if(typeof navigator>"u")return!1;let t=navigator.userAgentData?.platform??navigator.platform??"";return/mac|iphone|ipad|ipod/i.test(t)},v="ArrowUp ArrowDown ArrowLeft ArrowRight PageUp PageDown Space",p=(e,t)=>{console.warn(`[persona] ${e} shortcut: ${t}`)},S=e=>{let t=e.toLowerCase().split("+").map(n=>n.trim()),a=t.pop(),o={key:a,mod:!1,shift:!1,alt:!1};for(let n of t)if(n==="mod"||n==="cmd"||n==="ctrl")o.mod=!0;else if(n==="shift")o.shift=!0;else if(n==="alt"||n==="option")o.alt=!0;else return p("unknown modifier in",e),null;return!o.mod||o.shift&&o.alt||/^(enter|esc(ape)?)$/.test(a)||!/^([^+\s]|[a-z]{2,12})$/.test(a)?(p("unsupported",e),null):(a==="space"&&(o.key=" "),o)},E=e=>v.split(" ").find(t=>t.toLowerCase()===e)??(e===" "?"Space":e.length===1?e.toUpperCase():e[0].toUpperCase()+e.slice(1)),x=(e,t)=>{let a=S(e);if(!a)return"";let o=f(),n=E(a.key);if(!t&&o)return`${a.alt?"\u2325":""}${a.shift?"\u21E7":""}\u2318${n}`;let r=[t?o?"Meta":"Control":"Ctrl"];return a.alt&&r.push("Alt"),a.shift&&r.push("Shift"),r.push(n),r.join("+")},K=e=>x(e,!1),W=e=>x(e,!0),D=(e,t)=>t.key?.toLowerCase()===e.key&&(f()?t.metaKey:t.ctrlKey)===e.mod&&!(f()?t.ctrlKey:t.metaKey)&&t.shiftKey===e.shift&&t.altKey===e.alt,P=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable},R=e=>{let t=new Map,a=e?.ownerDocument??(typeof document<"u"?document:null),o=(r,s)=>{if((r.scope??"widget")==="page")return!0;if(!e)return!1;let i=s.composedPath?.();return i?.length?i.includes(e):e.contains(s.target)},n=r=>{if(r.isComposing||!t.size)return;let s=r.composedPath?.()[0]??r.target;for(let i of t.values())if(D(i.parsed,r)&&i.when?.()!==!1&&o(i,r)&&!(!i.allowInInput&&P(s))){r.preventDefault();try{i.run(r)}catch(l){p(`${i.id} threw on`,i.combo),console.warn(l)}return}};return a?.addEventListener("keydown",n),{register(r){let s=S(r.combo);if(!s)return()=>{};let i=`${s.mod?"m":""}${s.shift?"s":""}${s.alt?"a":""}${s.key}`,l=t.get(i);return l?(p(`${l.id} already owns`,r.combo),()=>{}):(t.set(i,{...r,parsed:s}),r.element?.setAttribute("aria-keyshortcuts",W(r.combo)),()=>{t.get(i)?.id===r.id&&t.delete(i),r.element?.removeAttribute("aria-keyshortcuts")})},destroy(){t.clear(),a?.removeEventListener("keydown",n)}}};var N=["user","assistant","system"],I=0;function T(e){if(typeof e!="string"||e==="")return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function g(e){return typeof e=="string"?e:void 0}function k(e){if(typeof e!="object"||e===null)return null;let t=e;switch(t.type){case"text":return typeof t.text=="string"?b(t.text):null;case"image":return typeof t.image=="string"?w(t.image,{mimeType:g(t.mimeType),alt:g(t.alt)}):null;case"file":return typeof t.data=="string"&&typeof t.mimeType=="string"&&typeof t.filename=="string"?M(t.data,t.mimeType,t.filename):null;case"audio":return typeof t.audio=="string"?{type:"audio",audio:t.audio,...g(t.mimeType)!==void 0&&{mimeType:t.mimeType}}:null;case"video":return typeof t.video=="string"?{type:"video",video:t.video,...g(t.mimeType)!==void 0&&{mimeType:t.mimeType}}:null;default:return null}}function L(e,t){let a=T(t),o=e.map(s=>T(s.timestamp)),n=new Array(e.length),r=0;for(;r<o.length;){let s=o[r];if(s!==null){n[r]=s,r+=1;continue}let i=r;for(;i+1<o.length&&o[i+1]===null;)i+=1;let l=i-r+1,d=r>0?n[r-1]:null,c=i+1<o.length?o[i+1]:null,m=c!==null&&a!==null?Math.min(c,a):c??a;for(let u=0;u<l;u+=1)n[r+u]=m!==null?m-(l-u):d!==null?d+u+1:I+u;r=i+1}return n.map(s=>new Date(s).toISOString())}function U(e,t){let a=L(e,t?.beforeCreatedAt),o=[];return e.forEach((n,r)=>{if(typeof n?.id!="string"||n.id===""||!N.includes(n.role))return;let s=n.role,i=a[r];if(n.displayAvailable===!1){let l={historyDisplayUnavailable:!0};o.push({id:n.id,role:s,content:"",createdAt:i,agentMetadata:l});return}if(typeof n.displayContent=="string"){o.push({id:n.id,role:s,content:n.displayContent,createdAt:i});return}if(typeof n.content=="string"){o.push({id:n.id,role:s,content:n.content,createdAt:i});return}if(Array.isArray(n.content)){let l=n.content.map(k).filter(c=>c!==null),d=h(l);o.push({id:n.id,role:s,content:d||(A(l)?y:""),createdAt:i,...l.length>0&&{contentParts:l}});return}o.push({id:n.id,role:s,content:"",createdAt:i})}),o}function O(e){let t=e.content;if(typeof t!="string"||t==="")return;let a=e.contentParts??e.llmContent??e.rawContent??t;if(!(typeof a=="string"&&a===t))return t}function _(e,t){let a=new Map;for(let o of e)a.set(o.id,o);for(let o of t)a.set(o.id,o);return[...a.values()].sort((o,n)=>{let r=new Date(o.createdAt).getTime(),s=new Date(n.createdAt).getTime();if(!Number.isNaN(r)&&!Number.isNaN(s)&&r!==s)return r-s;let i=o.sequence??0,l=n.sequence??0;return i!==l?i-l:o.id.localeCompare(n.id)})}export{U as a,O as b,_ as c,S as d,K as e,W as f,R as g};
@@ -0,0 +1 @@
1
+ import{a as f,b as l}from"./chunk-K7NA7G7J.js";import{b as y,f as u}from"./chunk-TR2H475E.js";function r(t){return t==="card"?"collapsed":t}function p(t){return t.split(";",1)[0].trim().toLowerCase()}function m(t,e){if(!t)return;let n=Object.entries(t);for(let[o,a]of n)if(p(o)===e)return{mode:r(a),selector:p(o)};let i=`${e.split("/",1)[0]}/*`;for(let[o,a]of n)if(p(o)===i)return{mode:r(a),selector:i}}function A(t,e){let n=t?.display,i=typeof n=="string"?{default:n}:n??{};if(e.file&&i.files){if(typeof i.files=="string")return{mode:r(i.files),matchedBy:{type:"files"}};let s=e.file.mimeType?p(e.file.mimeType):void 0,c=s?m(i.files.byMediaType,s):void 0;if(s&&c)return{mode:c.mode,matchedBy:{type:"mediaType",mediaType:s,selector:c.selector}};if(i.files.default)return{mode:r(i.files.default),matchedBy:{type:"files"}}}let o=i.byKind?.[e.artifactType];if(o)return{mode:r(o),matchedBy:{type:"kind",kind:e.artifactType,configuredBy:"byKind"}};let a=i.byType?.[e.artifactType];if(a)return{mode:r(a),matchedBy:{type:"kind",kind:e.artifactType,configuredBy:"byType"}};let d=e.presentation?.preferredMode;return d?{mode:r(d),matchedBy:{type:"preferredMode"}}:i.default?{mode:r(i.default),matchedBy:{type:"default"}}:{mode:"panel",matchedBy:{type:"personaDefault"}}}function P(t,e){return A(t,e).mode}function T(t,e){return JSON.stringify({component:t==="inline"?"PersonaArtifactInline":"PersonaArtifactCard",props:{artifactId:e.artifactId,title:e.title,artifactType:e.artifactType,status:e.status,...e.file?{file:e.file}:{},...e.presentation?{presentation:e.presentation}:{},...t==="inline"&&e.component?{component:e.component}:{},...t==="inline"&&e.componentProps?{componentProps:e.componentProps}:{},...e.markdown!==void 0?{markdown:e.markdown}:{}}})}var h={type:"object",properties:{questions:{type:"array",minItems:1,maxItems:l,description:"Questions to ask the user. Prefer a single question.",items:{type:"object",properties:{question:{type:"string",description:"The complete question, ending with a question mark."},header:{type:"string",maxLength:12,description:'Short topic label, e.g. "Auth method".'},options:{type:"array",minItems:2,maxItems:4,description:'2-4 distinct choices. Do NOT add an "Other" option: free text is automatic.',items:{type:"object",properties:{label:{type:"string",description:"Concise choice text (1-5 words)."},description:{type:"string",description:"What the option means or implies."}},required:["label"],additionalProperties:!1}},multiSelect:{type:"boolean",description:"Allow selecting multiple options. Default false."},allowFreeText:{type:"boolean",description:"Show a free-text input. Default true."}},required:["question","options"],additionalProperties:!1}}},required:["questions"],additionalProperties:!1},g={name:f,description:"Ask the user multiple-choice questions and wait for their answers. Use only when blocked on a decision that is the user's to make: a preference, a choice between valid approaches, or information you cannot infer. Each question offers 2-4 options plus an automatic free-text input. The result maps each question to its answer (an array when multiSelect); a question absent from the result was skipped.",parametersSchema:h,origin:"sdk",annotations:{readOnlyHint:!0}},M=t=>{let e=[],n=t?.features?.askUserQuestion;return n?.expose===!0&&n.enabled!==!1&&e.push(g),u(t).expose&&e.push(y),e};export{r as a,p as b,P as c,T as d,M as e};
@@ -0,0 +1 @@
1
+ import{a as p}from"./chunk-76IELU7F.js";import{parse as D,ARR as j,OBJ as X,STR as K}from"partial-json";var J="ask_user_question",M=8,m="data-persona-ask-sheet-for",G="Other",V="Other\u2026",Q="Type your own answer here",q="Send",Y="Next",z="Back",Z="Submit all",ee="Skip",te=3,w="data-ask-current-index",C="data-ask-question-count",F="data-ask-answers",S="data-ask-grouped",B="data-ask-layout",se=e=>e.layout==="pills"?"pills":"rows",ne=e=>e.getAttribute(B)==="pills"?"pills":"rows",_=!1,W=e=>e.replace(/["\\]/g,"\\$&"),re=e=>e.variant==="tool"&&!!e.toolCall&&e.toolCall.name===J,v=e=>e?.features?.askUserQuestion??{},L=e=>{let s=e.toolCall;if(!s)return{payload:null,complete:!1};let t=s.status==="complete";if(s.args&&typeof s.args=="object")return{payload:s.args,complete:t};let n=s.chunks;if(!n||n.length===0)return{payload:null,complete:t};try{let o=n.join(""),r=D(o,K|X|j);if(r&&typeof r=="object")return{payload:r,complete:t}}catch{}return{payload:null,complete:t}},x=e=>{let s=Array.isArray(e?.questions)?e.questions:[];return s.length>M&&!_&&(_=!0,typeof console<"u"&&console.warn(`[AgentWidget] ask_user_question received ${s.length} questions; truncating to ${M}.`)),s.slice(0,M)},oe=e=>x(e)[0]??null,ae=(e,s)=>x(e)[s]??null,ie=(e,s)=>{let t=s.styles;t&&(t.sheetBackground&&e.style.setProperty("--persona-ask-sheet-bg",t.sheetBackground),t.sheetBorder&&e.style.setProperty("--persona-ask-sheet-border",t.sheetBorder),t.sheetShadow&&e.style.setProperty("--persona-ask-sheet-shadow",t.sheetShadow),t.pillBackground&&e.style.setProperty("--persona-ask-pill-bg",t.pillBackground),t.pillBackgroundSelected&&e.style.setProperty("--persona-ask-pill-bg-selected",t.pillBackgroundSelected),t.pillTextColor&&e.style.setProperty("--persona-ask-pill-fg",t.pillTextColor),t.pillTextColorSelected&&e.style.setProperty("--persona-ask-pill-fg-selected",t.pillTextColorSelected),t.pillBorderRadius&&e.style.setProperty("--persona-ask-pill-radius",t.pillBorderRadius),t.customInputBackground&&e.style.setProperty("--persona-ask-input-bg",t.customInputBackground))},R=(e,s,t)=>{if(e!=="rows")return null;let n=p("span","persona-ask-row-affordance");if(n.setAttribute("aria-hidden","true"),s){let o=p("span","persona-ask-row-check");n.appendChild(o)}else{let o=p("span","persona-ask-row-badge");o.textContent=String(t+1),n.appendChild(o)}return n},le=(e,s,t,n)=>{let r=p("button",t==="rows"?"persona-ask-pill persona-ask-row persona-pointer-events-auto":"persona-ask-pill persona-pointer-events-auto");if(r.type="button",r.setAttribute("role",n?"checkbox":"button"),r.setAttribute("aria-pressed","false"),r.setAttribute("data-ask-user-action","pick"),r.setAttribute("data-option-index",String(s)),r.setAttribute("data-option-label",e.label),t==="rows"){let l=p("span","persona-ask-row-content"),i=p("span","persona-ask-row-label");if(i.textContent=e.label,l.appendChild(i),e.description){let d=p("span","persona-ask-row-description");d.textContent=e.description,l.appendChild(d)}r.appendChild(l);let u=R(t,n,s);u&&r.appendChild(u)}else r.textContent=e.label,e.description&&(r.title=e.description);return r},ue=e=>{let t=p("span",e==="rows"?"persona-ask-pill persona-ask-row persona-ask-pill-skeleton persona-pointer-events-none":"persona-ask-pill persona-ask-pill-skeleton persona-pointer-events-none");return t.setAttribute("aria-hidden","true"),t},pe=(e,s,t,n)=>{let r=p("div",n==="rows"?"persona-ask-pills persona-ask-pills--rows persona-flex persona-flex-col persona-gap-2":"persona-ask-pills persona-flex persona-flex-wrap persona-gap-2");r.setAttribute("role","group"),r.setAttribute("data-ask-pill-list","true");let l=!!e?.multiSelect,u=(Array.isArray(e?.options)?e.options:[]).filter(c=>c&&typeof c.label=="string"&&c.label.length>0);if(u.length===0&&!t){for(let c=0;c<te;c++)r.appendChild(ue(n));return r}if(u.forEach((c,a)=>{r.appendChild(le(c,a,n,l))}),e?.allowFreeText!==!1){let c=n==="rows"?G:V;if(n==="rows"){let a=p("div","persona-ask-pill persona-ask-row persona-ask-row--other persona-ask-pill-custom persona-pointer-events-auto");a.setAttribute("data-ask-user-action","focus-free-text"),a.setAttribute("data-option-index",String(u.length)),a.setAttribute("data-ask-other-row","true");let f=p("span","persona-ask-row-content"),g=document.createElement("input");g.type="text",g.className="persona-ask-row-input persona-flex-1 persona-pointer-events-auto",g.placeholder=s.freeTextPlaceholder??Q,g.setAttribute("data-ask-free-text-input","true"),g.setAttribute("aria-label",s.freeTextLabel??c),f.appendChild(g),a.appendChild(f);let b=R(n,l,u.length);b&&a.appendChild(b),r.appendChild(a)}else{let a=p("button","persona-ask-pill persona-ask-pill-custom persona-pointer-events-auto");a.type="button",a.setAttribute("data-ask-user-action","open-free-text"),a.textContent=s.freeTextLabel??c,r.appendChild(a)}}return r},N=(e,s)=>{let n=p("div",s==="rows"?"persona-ask-free-text persona-ask-free-text--rows persona-flex persona-gap-2 persona-mt-2":"persona-ask-free-text persona-hidden persona-flex persona-gap-2 persona-mt-2");n.setAttribute("data-ask-free-text-row","true");let o=document.createElement("input");if(o.type="text",o.className="persona-ask-free-text-input persona-flex-1 persona-pointer-events-auto",o.placeholder=e.freeTextPlaceholder??Q,o.setAttribute("data-ask-free-text-input","true"),n.appendChild(o),s!=="rows"){let r=p("button","persona-ask-free-text-submit persona-pointer-events-auto");r.type="button",r.textContent=e.submitLabel??q,r.setAttribute("data-ask-user-action","submit-free-text"),n.appendChild(r)}return n},ce=e=>{let s=p("div","persona-ask-multi-actions persona-flex persona-justify-end persona-mt-2");s.setAttribute("data-ask-multi-actions","true");let t=p("button","persona-ask-multi-submit persona-pointer-events-auto");return t.type="button",t.textContent=e.submitLabel??q,t.setAttribute("data-ask-user-action","submit-multi"),t.disabled=!0,s.appendChild(t),s},de=(e,s,t)=>{let n=p("div","persona-ask-nav persona-flex persona-justify-between persona-items-center persona-gap-2 persona-mt-2");n.setAttribute("data-ask-nav-row","true");let o=p("button","persona-ask-nav-back persona-pointer-events-auto");o.type="button",o.textContent=t.backLabel??z,o.setAttribute("data-ask-user-action","back"),o.disabled=e===0,n.appendChild(o);let r=p("div","persona-ask-nav-right persona-flex persona-items-center persona-gap-2"),l=p("button","persona-ask-nav-skip persona-pointer-events-auto");l.type="button",l.textContent=t.skipLabel??ee,l.setAttribute("data-ask-user-action","skip"),r.appendChild(l);let i=p("button","persona-ask-nav-next persona-pointer-events-auto");i.type="button";let u=e===s-1;return i.textContent=u?t.submitAllLabel??Z:t.nextLabel??Y,i.setAttribute("data-ask-user-action",u?"submit-all":"next"),i.disabled=!0,r.appendChild(i),n.appendChild(r),n},T=e=>{let s=e.getAttribute(F);if(!s)return{};try{let t=JSON.parse(s);return t&&typeof t=="object"?t:{}}catch{return{}}},I=(e,s)=>{e.setAttribute(F,JSON.stringify(s))},E=e=>{let s=Number(e.getAttribute(w)??"0");return Number.isFinite(s)?Math.max(0,Math.floor(s)):0},ge=(e,s)=>{e.setAttribute(w,String(Math.max(0,Math.floor(s))))},U=e=>{let s=Number(e.getAttribute(C)??"1");return Number.isFinite(s)?Math.max(1,Math.floor(s)):1},P=e=>e.getAttribute(S)==="true",be=(e,s)=>{let t=e.agentMetadata?.askUserQuestionAnswers;if(!t||typeof t!="object")return{};let n={};return s.forEach((o,r)=>{let l=typeof o?.question=="string"?o.question:"";if(l&&Object.prototype.hasOwnProperty.call(t,l)){let i=t[l];(typeof i=="string"||Array.isArray(i))&&(n[r]=i)}}),n},Ae=(e,s)=>{let t=e.agentMetadata?.askUserQuestionIndex;return typeof t!="number"||!Number.isFinite(t)?0:Math.max(0,Math.min(s-1,Math.floor(t)))},ye=(e,s)=>{let{payload:t}=L(s),n=x(t),o=T(e),r={},l=new Set;return n.forEach((i,u)=>{let d=typeof i?.question=="string"?i.question:"";d&&(l.has(d)&&typeof console<"u"&&console.warn(`[AgentWidget] ask_user_question has duplicate question text "${d}"; later answer wins.`),l.add(d),Object.prototype.hasOwnProperty.call(o,u)&&(r[d]=o[u]))}),r},O=e=>{let s=T(e),t=E(e),n=s[t],o=new Set;typeof n=="string"?o.add(n):Array.isArray(n)&&n.forEach(u=>o.add(u));let r=e.querySelectorAll('[data-ask-user-action="pick"][data-option-label]');r.forEach(u=>{let d=u.getAttribute("data-option-label")??"",c=o.has(d);u.setAttribute("aria-pressed",c?"true":"false"),u.classList.toggle("persona-ask-pill-selected",c)});let l=new Set(Array.from(r).map(u=>u.getAttribute("data-option-label")??"")),i=e.querySelector('[data-ask-free-text-input="true"]');i&&(typeof n=="string"&&n.length>0&&!l.has(n)?(i.value=n,i.closest('[data-ask-free-text-row="true"]')?.classList.remove("persona-hidden")):i.value="")},$=e=>{if(!P(e))return;let s=T(e),t=E(e),n=s[t],o=typeof n=="string"&&n.length>0||Array.isArray(n)&&n.length>0,r=e.querySelector('[data-ask-user-action="next"], [data-ask-user-action="submit-all"]');r&&(r.disabled=!o);let l=e.querySelector('[data-ask-user-action="submit-multi"]');if(l){let i=Array.from(e.querySelectorAll('[aria-pressed="true"][data-option-label]'));l.disabled=i.length===0}},H=(e,s,t)=>{let n=v(t),o=ne(e),{payload:r,complete:l}=L(s),i=P(e),u=E(e),d=U(e),c=i?ae(r,u):oe(r),a=!!c?.multiSelect,f=e.querySelector('[data-ask-step-inline="true"]');f&&(f.textContent=i?`${u+1}/${d}`:"");let g=e.querySelector('[data-ask-stepper="true"]');g&&g.remove();let b=e.querySelector('[data-ask-question="true"]');if(b){let A=typeof c?.question=="string"?c.question:"";b.textContent=A,b.classList.toggle("persona-ask-question-skeleton",!A&&!l)}let h=e.querySelector('[data-ask-pill-list="true"]');if(h){let A=pe(c,n,l,o);h.replaceWith(A)}if(o!=="rows"){let A=e.querySelector('[data-ask-free-text-row="true"]');A&&A.replaceWith(N(n,o))}let k=e.querySelector('[data-ask-multi-actions="true"]');!i&&a&&!k?e.appendChild(ce(n)):(!a||i)&&k&&k.remove(),e.setAttribute("data-multi-select",a?"true":"false");let y=e.querySelector('[data-ask-nav-row="true"]');if(i){let A=de(u,d,n);y?y.replaceWith(A):e.appendChild(A)}else y&&y.remove();O(e),$(e)},fe=(e,s,t)=>{let n=v(s),o=se(n),r=e.toolCall.id,l=x(t),i=Math.max(1,l.length),u=i>1,d=be(e,l),c=u?Ae(e,i):0,a=p("div",["persona-ask-sheet",`persona-ask-sheet--${o}`,"persona-pointer-events-auto","persona-ask-sheet-enter"].join(" "));a.setAttribute(m,r),a.setAttribute("data-tool-call-id",r),a.setAttribute("data-message-id",e.id),a.setAttribute(C,String(i)),a.setAttribute(w,String(c)),a.setAttribute(S,u?"true":"false"),a.setAttribute(B,o),I(a,d),a.setAttribute("role","group"),a.setAttribute("aria-label","Suggested answers"),n.slideInMs!==void 0&&a.style.setProperty("--persona-ask-sheet-duration",`${n.slideInMs}ms`),ie(a,n);let f=p("div","persona-ask-sheet-header persona-flex persona-items-center persona-gap-3"),g=p("div","persona-ask-sheet-question persona-flex-1");g.setAttribute("data-ask-question","true"),g.textContent="",f.appendChild(g);let b=p("span","persona-ask-sheet-step-inline");b.setAttribute("data-ask-step-inline","true"),b.textContent="",f.appendChild(b),a.appendChild(f);let k=p("div",o==="rows"?"persona-ask-pills persona-ask-pills--rows persona-flex persona-flex-col persona-gap-2":"persona-ask-pills persona-flex persona-flex-wrap persona-gap-2");return k.setAttribute("data-ask-pill-list","true"),k.setAttribute("role","group"),a.appendChild(k),o!=="rows"&&a.appendChild(N(n,o)),H(a,e,s),requestAnimationFrame(()=>{requestAnimationFrame(()=>a.classList.remove("persona-ask-sheet-enter"))}),a},ke=(e,s,t)=>{let{payload:n}=L(s),o=Math.max(1,x(n).length);o>U(e)&&(e.setAttribute(C,String(o)),o>1&&!P(e)&&e.setAttribute(S,"true")),H(e,s,t)};var Le=(e,s,t)=>{if(!t||!re(e)||v(s).enabled===!1)return;let o=e.toolCall.id;t.querySelectorAll(`[${m}]`).forEach(d=>{d.getAttribute(m)!==o&&d.remove()});let l=t.querySelector(`[${m}="${W(o)}"]`);if(l){ke(l,e,s);return}let{payload:i}=L(e),u=fe(e,s,i);t.appendChild(u)},Te=(e,s)=>{if(!e)return;let t=s?`[${m}="${W(s)}"]`:`[${m}]`;e.querySelectorAll(t).forEach(o=>{o.classList.add("persona-ask-sheet-leave");let r=Number.parseInt(getComputedStyle(o).getPropertyValue("--persona-ask-sheet-duration")||"180",10);setTimeout(()=>o.remove(),Number.isFinite(r)?r:180)})},Ee=e=>Array.from(e.querySelectorAll('[aria-pressed="true"][data-option-label]')).map(s=>s.getAttribute("data-option-label")).filter(s=>typeof s=="string"&&s.length>0),he=(e,s)=>{let t=T(e),n=E(e);typeof s=="string"&&s.length===0||Array.isArray(s)&&s.length===0?delete t[n]:t[n]=s,I(e,t),O(e),$(e)},Me=(e,s,t,n)=>{let o=U(e),r=Math.max(0,Math.min(o-1,n));ge(e,r),H(e,s,t)};export{J as a,M as b,re as c,L as d,T as e,E as f,U as g,P as h,ye as i,Le as j,Te as k,Ee as l,he as m,Me as n};
@@ -0,0 +1 @@
1
+ var r=["viewTitle","openHistoryLabel","openHistoryBusyLabel","newConversationLabel","expandLabel","collapseLabel","resizeLabel","showEarlierMessagesLabel","openConversationLoadingLabel","openConversationErrorTitle","openConversationRetryLabel","openConversationBackLabel","confirmCancelLabel","deleteConversationConfirmTitle","deleteConversationConfirm","deleteConversationConfirmLabel","clearHistoryConfirmTitle","clearHistoryConfirm","clearHistoryVerifiedConfirm","clearHistoryConfirmLabel","resetIdentityConfirmTitle","resetIdentityConfirm","resetIdentityConfirmLabel","conversationDeletedNotice","identityResetNotice","identityResetUnconfirmedNotice"],i={viewTitle:"Messages",openHistoryLabel:"Messages",openHistoryBusyLabel:"Messages, available once the reply finishes",newConversationLabel:"New conversation",expandLabel:"Expand conversation list",collapseLabel:"Collapse conversation list",resizeLabel:"Resize conversation list",showEarlierMessagesLabel:"Show earlier messages",openConversationLoadingLabel:"Loading conversation",openConversationErrorTitle:"Could not open the conversation.",openConversationRetryLabel:"Try again",openConversationBackLabel:"Back to messages",confirmCancelLabel:"Cancel",deleteConversationConfirmTitle:"Delete conversation",deleteConversationConfirm:"Delete this conversation? This cannot be undone.",deleteConversationConfirmLabel:"Delete",clearHistoryConfirmTitle:"Delete all conversations",clearHistoryConfirm:"Delete all conversations for this assistant on this browser? This cannot be undone.",clearHistoryVerifiedConfirm:"Delete all conversations for this assistant and signed-in user? This cannot be undone.",clearHistoryConfirmLabel:"Delete all",resetIdentityConfirmTitle:"Forget this device",resetIdentityConfirm:"Forget this device? All Persona data stored in this browser is cleared. Records are not deleted elsewhere.",resetIdentityConfirmLabel:"Forget this device",conversationDeletedNotice:"That conversation was deleted. You are now in a new conversation.",identityResetNotice:"This device was forgotten.",identityResetUnconfirmedNotice:"This device was cleared here, but the server could not confirm it."};function s(o){if(!o)return i;let t={...i};for(let n of r){let e=o[n];typeof e=="string"&&e.length>0&&(t[n]=e)}return t}export{i as a,s as b};
@@ -0,0 +1 @@
1
+ function r(o){let e={trigger:o.trigger??"@",position:o.triggerPosition??"anywhere",allowSpaces:!1,sources:Array.isArray(o.sources)?o.sources:[],searchPlaceholder:o.searchPlaceholder,showButton:o.showButton!==!1,buttonIconName:o.buttonIconName,buttonTooltipText:o.buttonTooltipText},n=(o.triggers??[]).map(t=>({trigger:t.trigger,position:t.triggerPosition??"anywhere",allowSpaces:t.allowSpaces??!1,sources:Array.isArray(t.sources)?t.sources:[],searchPlaceholder:t.searchPlaceholder,showButton:t.showButton===!0,buttonIconName:t.buttonIconName,buttonTooltipText:t.buttonTooltipText}));return[e,...n]}export{r as a};
@@ -0,0 +1 @@
1
+ var t="4.26.0";var n=t;export{n as a};
@@ -0,0 +1 @@
1
+ import{a as H,e as k}from"./chunk-ZC66NAIR.js";import{c as D}from"./chunk-2ANTRKTV.js";import{a as f,d as T}from"./chunk-76IELU7F.js";var{setLoader:j,load:N,provide:z,getSync:O}=H({fallbackImport:()=>import("./markdown-parsers-entry-NVFT3TE6.js")}),M=new Set,B=()=>{let i=[...M];M.clear();for(let e of i)try{e()}catch{}};var U=()=>{let i=O();return i?Promise.resolve(i):N().then(e=>(B(),e))},V=i=>O()?()=>{}:(M.add(i),()=>{M.delete(i)}),Y=i=>{z(i),B()},A=O;var W=i=>{if(!i)return;let e={},t=i;if(t.heading){let n=t.heading;e.heading=(o,s,d)=>n({type:"heading",raw:d,depth:s,text:o,tokens:[]})}if(t.code){let n=t.code;e.code=(o,s,d)=>n({type:"code",raw:"",text:o,lang:s,escaped:d})}if(t.blockquote){let n=t.blockquote;e.blockquote=o=>n({type:"blockquote",raw:"",text:o,tokens:[]})}if(t.table){let n=t.table;e.table=(o,s)=>n({type:"table",raw:"",header:[],rows:[],align:[],headerHtml:o,bodyHtml:s})}if(t.link){let n=t.link;e.link=(o,s,d)=>n({type:"link",raw:"",href:o,title:s??null,text:d,tokens:[]})}if(t.image){let n=t.image;e.image=(o,s,d)=>n({type:"image",raw:"",href:o,title:s??null,text:d})}if(t.list){let n=t.list;e.list=(o,s,d)=>n({type:"list",raw:"",ordered:s,start:d,loose:!1,items:[],itemsHtml:o})}if(t.listitem){let n=t.listitem;e.listitem=(o,s,d)=>n({type:"list_item",raw:"",task:s,checked:d,loose:!1,text:o,tokens:[]})}if(t.paragraph){let n=t.paragraph;e.paragraph=o=>n({type:"paragraph",raw:"",text:o,tokens:[]})}if(t.codespan){let n=t.codespan;e.codespan=o=>n({type:"codespan",raw:"",text:o})}if(t.strong){let n=t.strong;e.strong=o=>n({type:"strong",raw:"",text:o,tokens:[]})}if(t.em){let n=t.em;e.em=o=>n({type:"em",raw:"",text:o,tokens:[]})}if(t.del){let n=t.del;e.del=o=>n({type:"del",raw:"",text:o,tokens:[]})}if(t.html){let n=t.html;e.html=o=>n({type:"html",raw:o,text:o})}if(t.text){let n=t.text;e.text=o=>n({type:"text",raw:o,text:o})}if(t.checkbox){let n=t.checkbox;e.checkbox=o=>n({checked:o})}return t.hr&&(e.hr=t.hr),t.br&&(e.br=t.br),e},L=i=>{let e=null;return t=>{let n=A();if(!n)return E(t);if(!e){let{Marked:o}=n,s=i?.markedOptions;e=new o({gfm:s?.gfm??!0,breaks:s?.breaks??!0,pedantic:s?.pedantic,silent:s?.silent});let d=W(i?.renderer);d&&e.use({renderer:d})}return e.parse(t)}},Z=i=>i?L({markedOptions:i.options,renderer:i.renderer}):L(),K=L();var E=i=>i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;");var _={ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","p","br","hr","div","span","ul","ol","li","dl","dt","dd","strong","em","b","i","u","s","del","ins","mark","small","sub","sup","abbr","kbd","var","samp","code","a","img","blockquote","pre","details","summary","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col","input","label","select","option","textarea","button"],ALLOWED_ATTR:["href","src","alt","title","target","rel","loading","width","height","colspan","rowspan","scope","class","id","type","name","value","placeholder","disabled","checked","for","aria-label","aria-hidden","aria-expanded","role","tabindex","data-tv-form","data-message-id","data-persona-component-directive","data-preserve-animation","data-persona-instance"]},F=/^data:image\/(?:png|jpe?g|gif|webp|bmp|x-icon|avif)/i,$=()=>{let i=null;return e=>{let t=A();if(!t)return E(e);if(!i){let{DOMPurify:n}=t;i=n(typeof window<"u"?window:void 0),i.addHook("uponSanitizeAttribute",(o,s)=>{if(s.attrName==="src"||s.attrName==="href"){let d=s.attrValue;d.toLowerCase().startsWith("data:")&&!F.test(d)&&(s.attrValue="",s.keepAttr=!1)}})}return i.sanitize(e,_)}},ne=i=>i===!1?null:typeof i=="function"?i:$();function S(i){let{items:e,onSelect:t,anchor:n,position:o="bottom-left",portal:s,onOpenChange:d}=i,l=f("div","persona-dropdown-menu persona-hidden");l.setAttribute("role","menu"),l.setAttribute("data-persona-theme-zone","dropdown"),s?(l.style.position="fixed",l.style.zIndex=String(D)):(l.style.position="absolute",l.style.top="100%",l.style.marginTop="4px",o==="bottom-right"?l.style.right="0":l.style.left="0");for(let c of e){if(c.dividerBefore){let b=document.createElement("hr");l.appendChild(b)}let m=document.createElement("button");if(m.type="button",m.setAttribute("role","menuitem"),m.setAttribute("data-dropdown-item-id",c.id),c.destructive&&m.setAttribute("data-destructive",""),c.icon){let b=k(c.icon,16,"currentColor",1.5);b&&m.appendChild(b)}let y=document.createElement("span");y.textContent=c.label,m.appendChild(y),m.addEventListener("click",b=>{b.stopPropagation(),p(),t(c.id)}),l.appendChild(m)}let u=null;function r(){if(!s)return;let c=n.getBoundingClientRect();l.style.top=`${c.bottom+4}px`,o==="bottom-right"?(l.style.right=`${window.innerWidth-c.right}px`,l.style.left="auto"):(l.style.left=`${c.left}px`,l.style.right="auto")}function a(){let c=l.classList.contains("persona-hidden");r(),l.classList.remove("persona-hidden"),c&&d?.(!0),requestAnimationFrame(()=>{let m=y=>{!l.contains(y.target)&&!n.contains(y.target)&&p()};document.addEventListener("click",m,!0),u=()=>document.removeEventListener("click",m,!0)})}function p(){let c=!l.classList.contains("persona-hidden");l.classList.add("persona-hidden"),u?.(),u=null,c&&d?.(!1)}function g(){l.classList.contains("persona-hidden")?a():p()}function h(){p(),l.remove()}return s&&s.appendChild(l),{element:l,show:a,hide:p,toggle:g,destroy:h}}function P(i){let{icon:e,label:t,size:n,strokeWidth:o,className:s,chromeless:d,onClick:l,aria:u}=i,r=f("button",T(!d&&"persona-icon-btn",s));r.type="button",r.setAttribute("aria-label",t),r.title=t;let a=k(e,n??16,"currentColor",o??2);if(a&&r.appendChild(a),l&&r.addEventListener("click",l),u)for(let[p,g]of Object.entries(u))r.setAttribute(p,g);return r}function q(i){let{icon:e,label:t,variant:n="default",size:o="sm",iconSize:s,className:d,onClick:l,aria:u}=i,r="persona-label-btn";n!=="default"&&(r+=" persona-label-btn--"+n),r+=" persona-label-btn--"+o,d&&(r+=" "+d);let a=f("button",r);if(a.type="button",a.setAttribute("aria-label",t),e){let g=k(e,s??14,"currentColor",2);g&&a.appendChild(g)}let p=f("span");if(p.textContent=t,a.appendChild(p),l&&a.addEventListener("click",l),u)for(let[g,h]of Object.entries(u))a.setAttribute(g,h);return a}function pe(i){let{items:e,selectedId:t,onSelect:n,className:o}=i,s=f("div","persona-toggle-group"+(o?" "+o:""));s.setAttribute("role","group");let d=t,l=[];function u(){for(let a of l)a.btn.setAttribute("aria-pressed",a.id===d?"true":"false")}for(let a of e){let p;a.icon?p=P({icon:a.icon,label:a.label,className:a.className,onClick:()=>{d=a.id,u(),n(a.id)}}):(p=f("button","persona-icon-btn"+(a.className?" "+a.className:"")),p.type="button",p.setAttribute("aria-label",a.label),p.title=a.label,p.textContent=a.label,p.addEventListener("click",()=>{d=a.id,u(),n(a.id)})),p.setAttribute("aria-pressed",a.id===d?"true":"false"),l.push({id:a.id,btn:p}),s.appendChild(p)}function r(a){d=a,u()}return{element:s,setSelected:r}}function ue(i){let{label:e,icon:t,iconSize:n,iconOnly:o,menuItems:s,onSelect:d,onPrimary:l,position:u="bottom-left",portal:r,chevronLabel:a="More options",chevronIconSize:p,className:g,primaryClassName:h,chevronClassName:c}=i,m=f("div","persona-split-btn"+(g?" "+g:"")),y={label:e,className:"persona-split-btn-primary"+(h?" "+h:""),onClick:l},b=o&&t?P({...y,icon:t,size:n??14}):q({...y,icon:t,iconSize:n??14}),x=P({icon:"chevron-down",label:a,size:p??14,className:"persona-split-btn-chevron"+(c?" "+c:""),aria:{"aria-haspopup":"true","aria-expanded":"false"}});m.append(b,x);let v=null,w=()=>{if(v)return v;let C=(typeof r=="function"?r():r)??void 0;return v=S({items:s,onSelect:d,anchor:m,position:u,portal:C,onOpenChange:I=>{x.setAttribute("aria-expanded",I?"true":"false")}}),C||m.appendChild(v.element),v};return m.isConnected?w():requestAnimationFrame(()=>{v||w()}),x.addEventListener("click",C=>{C.stopPropagation(),w().toggle()}),{element:m,primaryButton:b,chevronButton:x,openMenu:()=>w().show(),closeMenu:()=>v?.hide(),toggleMenu:()=>w().toggle(),destroy:()=>{v?.destroy(),m.remove()}}}function ge(i){let{label:e,icon:t="chevron-down",menuItems:n,onSelect:o,position:s="bottom-left",portal:d,className:l,hover:u}=i,r=f("div","persona-combo-btn"+(l?" "+l:""));r.style.position="relative",r.style.display="inline-flex",r.style.alignItems="center",r.style.cursor="pointer",r.setAttribute("role","button"),r.setAttribute("tabindex","0"),r.setAttribute("aria-haspopup","true"),r.setAttribute("aria-expanded","false"),r.setAttribute("aria-label",e);let a=f("span","persona-combo-btn-label");a.textContent=e,r.appendChild(a);let p=k(t,14,"currentColor",2);p&&(p.style.marginLeft="4px",p.style.opacity="0.6",r.appendChild(p)),u&&(r.style.borderRadius=u.borderRadius??"10px",r.style.padding=u.padding??"6px 4px 6px 12px",r.style.border="1px solid transparent",r.style.transition="background-color 0.15s ease, border-color 0.15s ease",r.addEventListener("mouseenter",()=>{r.style.backgroundColor=u.background??"",r.style.borderColor=u.border??""}),r.addEventListener("mouseleave",()=>{r.style.backgroundColor="",r.style.borderColor="transparent"}));let g=S({items:n,onSelect:c=>{r.setAttribute("aria-expanded","false"),o(c)},anchor:r,position:s,portal:d});d||r.appendChild(g.element);let h=()=>r.getAttribute("data-persona-menu-locked")==="true";return r.addEventListener("click",c=>{if(c.stopPropagation(),h())return;let m=!g.element.classList.contains("persona-hidden");r.setAttribute("aria-expanded",m?"false":"true"),g.toggle()}),r.addEventListener("keydown",c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),r.click())}),{element:r,setLabel:c=>{a.textContent=c,r.setAttribute("aria-label",c)},open:()=>{r.setAttribute("aria-expanded","true"),g.show()},close:()=>{r.setAttribute("aria-expanded","false"),g.hide()},toggle:()=>{let c=!g.element.classList.contains("persona-hidden");r.setAttribute("aria-expanded",c?"false":"true"),g.toggle()},destroy:()=>{g.destroy(),r.remove()}}}var R=class{constructor(){this.components=new Map;this.#e=new Map}#e;register(e,t,n){this.components.has(e)&&console.warn(`[ComponentRegistry] Component "${e}" is already registered. Overwriting.`),this.components.set(e,t),n?this.#e.set(e,n):this.#e.delete(e)}unregister(e){this.components.delete(e),this.#e.delete(e)}get(e){return this.components.get(e)}has(e){return this.components.has(e)}getOptions(e){return this.#e.get(e)}getAllNames(){return Array.from(this.components.keys())}clear(){this.components.clear(),this.#e.clear()}registerAll(e){Object.entries(e).forEach(([t,n])=>{this.register(t,n)})}},fe=new R;var ye=(i,e,t)=>{let n=t;for(let o of e){let s=f("span","persona-tool-char");s.style.setProperty("--char-index",String(n)),s.textContent=o===" "?"\xA0":o,i.appendChild(s),n++}return n};export{U as a,V as b,Y as c,A as d,Z as e,E as f,ne as g,S as h,P as i,q as j,pe as k,ue as l,ge as m,ye as n,fe as o};
@@ -0,0 +1 @@
1
+ var g="[Image]";function u(e){return typeof e=="string"?e:e.filter(t=>t.type==="text").map(t=>t.text).join("")}function f(e){return typeof e=="string"?!1:e.some(t=>t.type==="image")}function c(e){return{type:"text",text:e}}function d(e,t){return{type:"image",image:e,...t?.mimeType&&{mimeType:t.mimeType},...t?.alt&&{alt:t.alt}}}var a=["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","image/bmp"],o=["application/pdf","text/plain","text/markdown","text/csv","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/json"],s=[...a,...o];function p(e){return a.includes(e)||e.startsWith("image/")}function l(e){return p(e.type)}function x(e,t,r){return{type:"file",data:e,mimeType:t,filename:r}}async function y(e){return new Promise((t,r)=>{let n=new FileReader;n.onload=()=>{let i=n.result;l(e)?t({type:"image",image:i,mimeType:e.type,alt:e.name}):t({type:"file",data:i,mimeType:e.type,filename:e.name})},n.onerror=()=>r(new Error("Failed to read file")),n.readAsDataURL(e)})}function P(e,t=s,r=10*1024*1024){return t.includes(e.type)?e.size>r?{valid:!1,error:`File too large. Maximum size: ${Math.round(r/1048576)}MB`}:{valid:!0}:{valid:!1,error:`Invalid file type "${e.type}". Accepted types: ${t.join(", ")}`}}function m(e){let t=e.split(".");return t.length>1?t.pop().toLowerCase():""}function C(e,t){let r=m(t).toUpperCase();return{"application/pdf":"PDF","text/plain":"TXT","text/markdown":"MD","text/csv":"CSV","application/msword":"DOC","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"DOCX","application/vnd.ms-excel":"XLS","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"XLSX","application/json":"JSON"}[e]||r||"FILE"}export{g as a,u as b,f as c,c as d,d as e,s as f,l as g,x as h,y as i,P as j,C as k};