@runtypelabs/persona 4.32.0 → 4.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/activity-ui.cjs +1 -1
- package/dist/activity-ui.js +1 -1
- package/dist/{chunk-BrptyKSq.js → chunk-B3l7TOOv.js} +1 -1
- package/dist/{chunk-CkE90FtA.js → chunk-B4ecQzeK.js} +1 -1
- package/dist/{chunk-BWCo3rCm.js → chunk-B_H0l3u2.js} +1 -1
- package/dist/{chunk-MdlQetfC.js → chunk-BbXc58OA.js} +1 -1
- package/dist/chunk-BkOYJ11B.js +1 -0
- package/dist/{chunk-DE0cSmku.js → chunk-BpjtKnGI.js} +1 -1
- package/dist/{chunk-CzZBmTLd.js → chunk-C9uOhfk5.js} +1 -1
- package/dist/{chunk-CHAwCqpk.js → chunk-CdpVP6LZ.js} +1 -1
- package/dist/{chunk-DZg9bFK6.js → chunk-CumoXK3u.js} +1 -1
- package/dist/{chunk-FEzOcZof.js → chunk-DM-OJt5q.js} +1 -1
- package/dist/{chunk-Cb7qy0c7.js → chunk-DNdeIFJ6.js} +1 -1
- package/dist/{chunk-VaT6xry9.js → chunk-DTGvDx8o.js} +1 -1
- package/dist/{chunk-ezlpsYGk.js → chunk-DVZ8ri1z.js} +1 -1
- package/dist/{chunk-DhedQnek.js → chunk-DgZZqy14.js} +1 -1
- package/dist/{chunk-C2IbR39s.js → chunk-UWMfWW2a.js} +1 -1
- package/dist/client-dispatch.js +1 -1
- package/dist/client-history.js +1 -1
- package/dist/codegen.cjs +1 -1
- package/dist/codegen.js +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +1 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/launcher.global.js +1 -1
- package/dist/launcher.global.js.map +1 -1
- package/dist/theme-editor-preview.cjs +3 -3
- package/dist/theme-editor-preview.js +3 -3
- package/dist/theme-editor.cjs +1 -1
- package/dist/theme-editor.js +1 -1
- package/dist/theme-reference.cjs +1 -1
- package/dist/theme-reference.js +1 -1
- package/dist/voice-runtime.cjs +1 -1
- package/dist/voice-runtime.js +1 -1
- package/dist/widget.css +1 -1
- package/package.json +1 -1
- package/src/styles/widget.css +12 -0
- package/src/utils/brand.test.ts +50 -0
- package/src/utils/brand.ts +6 -2
- package/src/utils/tokens.ts +2 -1
- package/src/utils/tool-activity-summary.test.ts +8 -0
- package/src/utils/tool-activity-summary.ts +2 -1
- package/dist/chunk-DDAwu89-.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,n as l,o as u,p as d,r as f,t as p,u as m,v as h,y as g}from"./chunk-CHAwCqpk.js";import{n as _,r as v,t as y}from"./chunk-BnfM7-qg.js";import{t as b}from"./chunk-CnxIZOzx.js";import{A as x,C as S,D as C,E as ee,F as w,I as T,M as te,N as ne,O as re,P as ie,S as ae,T as oe,_ as se,a as ce,b as le,c as ue,d as de,f as E,g as fe,h as pe,i as me,j as he,k as ge,l as _e,m as ve,n as ye,o as be,r as xe,s as Se,t as Ce,u as we,v as D,w as Te,x as Ee,y as De}from"./chunk-DhedQnek.js";import{_ as Oe,a as ke,c as Ae,d as je,f as Me,g as Ne,h as Pe,i as Fe,l as Ie,m as Le,o as Re,p as ze,r as Be,s as Ve,u as He,v as Ue}from"./chunk-C2IbR39s.js";import{i as We,r as O,t as k}from"./chunk-D5BxWOFB.js";import{i as Ge,n as Ke,r as qe}from"./chunk-Bb41bKyp.js";import{a as Je,c as Ye,i as Xe,l as Ze,n as Qe,o as $e,r as et,s as tt,t as nt}from"./chunk-CVMIncEY.js";import{a as rt,i as it,n as at,o as ot,r as st}from"./chunk-BAdIgC5d.js";import{n as ct,r as A}from"./chunk-DDZBCAer.js";import{n as lt,r as ut,t as dt}from"./chunk-BvhTpG6k.js";import{f as ft,r as pt,s as mt,u as ht}from"./chunk-VaT6xry9.js";import{a as gt,i as _t,r as vt}from"./chunk-xzeTUTrE.js";import{a as yt,c as bt,i as xt,n as St,o as j,r as M,s as N,t as Ct,u as wt}from"./chunk-BWCo3rCm.js";import{m as Tt,n as Et}from"./chunk-mEFmAbxE.js";import{t as Dt}from"./chunk-DDAwu89-.js";import{t as Ot}from"./chunk-C8560fIY.js";import{a as kt,c as At,d as jt,l as Mt,n as Nt,o as Pt,t as Ft,u as It}from"./chunk-BlTD-Wgn.js";import{t as Lt}from"./chunk-aTmHfQO_.js";import{r as Rt,t as zt}from"./chunk-Bz9jAgba.js";import{c as Bt,f as Vt,l as Ht,m as Ut,n as Wt,r as Gt,s as Kt,t as qt,u as Jt}from"./chunk-BEDTp-dm.js";import{n as Yt,t as Xt}from"./chunk-BAkaTZpd.js";import{n as Zt,t as Qt}from"./chunk-Crczk7D3.js";import{n as $t}from"./chunk-py2YB6PV.js";import{a as en,i as tn,n as nn,o as rn,s as an}from"./chunk-Cy1A8vbF.js";import{a as on,c as sn,i as cn,l as ln,n as un,o as dn,r as fn,s as pn,t as mn,u as hn}from"./chunk-BExOAPZb.js";import{n as gn}from"./chunk-DTDHeUsG.js";import{Activity as _n,ArrowRight as vn,Check as yn,ChevronUp as bn,Copy as xn,File as Sn,FileCode as Cn,FileSpreadsheet as wn,FileText as Tn,MessageSquare as En,X as Dn}from"lucide";import"partial-json";import{Idiomorph as On}from"idiomorph";const kn=e=>{let t=0,n=!1,r=Promise.resolve(),i=()=>{},a,o=e.inert===!0,s=()=>{a?.remove(),a=void 0,e.removeAttribute(`data-persona-preparing`),e.inert=o};return{get ready(){return r},prepare(o,c,l=!1){let u=++t;if(i(),!o.length){if(c(),u!==t)return;s(),r=Promise.resolve();return}!l&&!a&&(a=e.ownerDocument.createElement(`style`),a.textContent=`[data-persona-preparing],[data-persona-preparing] *{visibility:hidden!important}`,e.append(a)),l||(e.setAttribute(`data-persona-preparing`,``),e.inert=!0);let d=new Promise((e,t)=>{i=()=>t(/* @__PURE__ */ Error(`Widget destroyed before ready`))});r=Promise.race([Promise.all(o),d]).then(()=>{if(n)throw Error(`Widget destroyed before ready`);if(u!==t||(c(),u!==t))return r;s()},e=>{if(!n&&u!==t)return r;throw e}),r.catch(()=>{})},destroy(){n=!0,++t,i(),s()}}},An={defaultProvenance:d,suppliedPath:e,hasExplicitThemeStyle:t,getExplicitLegacyStyle:f},{setLoader:jn,load:Mn,provide:Nn,getSync:Pn}=v({fallbackImport:()=>import(`./chunk-CkE90FtA.js`)}),Fn=Mn,In=Pn,{setLoader:Ln,load:Rn,provide:zn}=v({fallbackImport:()=>import(`./chunk-C3cPmtjr.js`)});let Bn=null;const Vn=()=>Promise.all([Rn(),Fn()]).then(([e,t])=>(Object.assign(t.turnUi,e),Bn=e)),Hn=()=>Bn,{setLoader:Un,load:Wn,provide:Gn,getSync:Kn}=v({fallbackImport:()=>import(`./chunk-C7-m0EmI.js`)}),qn=Wn,Jn=Kn,{setLoader:Yn,load:P,provide:F,getSync:Xn}=v({fallbackImport:()=>import(`./chunk-BrptyKSq.js`)}),I=P,Zn=Xn,{setLoader:L,load:R,getSync:z,provide:Qn}=v({fallbackImport:()=>import(`./chunk-Ds_twaZn.js`)}),$n=R,er=z;function tr(e){let{items:t,onSelect:n,anchor:r,position:i=`bottom-left`,portal:a,onOpenChange:o}=e,s=k(`div`,`persona-dropdown-menu persona-hidden`);s.setAttribute(`role`,`menu`),s.setAttribute(`data-persona-theme-zone`,`dropdown`),a?(s.style.position=`fixed`,s.style.zIndex=String(qe)):(s.style.position=`absolute`,s.style.top=`100%`,s.style.marginTop=`4px`,i===`bottom-right`?s.style.right=`0`:s.style.left=`0`);for(let e of t){if(e.dividerBefore){let e=document.createElement(`hr`);s.appendChild(e)}let t=document.createElement(`button`);if(t.type=`button`,t.setAttribute(`role`,`menuitem`),t.setAttribute(`data-dropdown-item-id`,e.id),e.destructive&&t.setAttribute(`data-destructive`,``),e.icon){let n=T(e.icon,16,`currentColor`,1.5);n&&t.appendChild(n)}let r=document.createElement(`span`);r.textContent=e.label,t.appendChild(r),t.addEventListener(`click`,t=>{t.stopPropagation(),d(),n(e.id)}),s.appendChild(t)}let c=null;function l(){if(!a)return;let e=r.getBoundingClientRect();s.style.top=`${e.bottom+4}px`,i===`bottom-right`?(s.style.right=`${window.innerWidth-e.right}px`,s.style.left=`auto`):(s.style.left=`${e.left}px`,s.style.right=`auto`)}function u(){let e=s.classList.contains(`persona-hidden`);l(),s.classList.remove(`persona-hidden`),e&&o?.(!0),requestAnimationFrame(()=>{let e=e=>{!s.contains(e.target)&&!r.contains(e.target)&&d()};document.addEventListener(`click`,e,!0),c=()=>document.removeEventListener(`click`,e,!0)})}function d(){let e=!s.classList.contains(`persona-hidden`);s.classList.add(`persona-hidden`),c?.(),c=null,e&&o?.(!1)}function f(){s.classList.contains(`persona-hidden`)?u():d()}function p(){d(),s.remove()}return a&&a.appendChild(s),{element:s,show:u,hide:d,toggle:f,destroy:p}}function nr(e){let{icon:t,label:n,size:r,strokeWidth:i,className:a,chromeless:o,onClick:s,aria:c}=e,l=k(`button`,We(!o&&`persona-icon-btn`,a));l.type=`button`,l.setAttribute(`aria-label`,n),l.title=n;let u=T(t,r??16,`currentColor`,i??2);if(u&&l.appendChild(u),s&&l.addEventListener(`click`,s),c)for(let[e,t]of Object.entries(c))l.setAttribute(e,t);return l}function B(e){let{icon:t,label:n,variant:r=`default`,size:i=`sm`,iconSize:a,className:o,onClick:s,aria:c}=e,l=`persona-label-btn`;r!=="default"&&(l+=` persona-label-btn--`+r),l+=` persona-label-btn--`+i,o&&(l+=` `+o);let u=k(`button`,l);if(u.type=`button`,u.setAttribute(`aria-label`,n),t){let e=T(t,a??14,`currentColor`,2);e&&u.appendChild(e)}let d=k(`span`);if(d.textContent=n,u.appendChild(d),s&&u.addEventListener(`click`,s),c)for(let[e,t]of Object.entries(c))u.setAttribute(e,t);return u}function rr(e){let{items:t,selectedId:n,onSelect:r,className:i}=e,a=k(`div`,`persona-toggle-group`+(i?` `+i:``));a.setAttribute(`role`,`group`);let o=n,s=[];function c(){for(let e of s)e.btn.setAttribute(`aria-pressed`,e.id===o?`true`:`false`)}for(let e of t){let t;e.icon?t=nr({icon:e.icon,label:e.label,className:e.className,onClick:()=>{o=e.id,c(),r(e.id)}}):(t=k(`button`,`persona-icon-btn`+(e.className?` `+e.className:``)),t.type=`button`,t.setAttribute(`aria-label`,e.label),t.title=e.label,t.textContent=e.label,t.addEventListener(`click`,()=>{o=e.id,c(),r(e.id)})),t.setAttribute(`aria-pressed`,e.id===o?`true`:`false`),s.push({id:e.id,btn:t}),a.appendChild(t)}function l(e){o=e,c()}return{element:a,setSelected:l}}function ir(e){let{label:t,icon:n,iconSize:r,iconOnly:i,menuItems:a,onSelect:o,onPrimary:s,position:c=`bottom-left`,portal:l,chevronLabel:u=`More options`,chevronIconSize:d,className:f,primaryClassName:p,chevronClassName:m}=e,h=k(`div`,`persona-split-btn`+(f?` `+f:``)),g={label:t,className:`persona-split-btn-primary`+(p?` `+p:``),onClick:s},_=i&&n?nr({...g,icon:n,size:r??14}):B({...g,icon:n,iconSize:r??14}),v=nr({icon:`chevron-down`,label:u,size:d??14,className:`persona-split-btn-chevron`+(m?` `+m:``),aria:{"aria-haspopup":`true`,"aria-expanded":`false`}});h.append(_,v);let y=null,b=()=>{if(y)return y;let e=(typeof l==`function`?l():l)??void 0;return y=tr({items:a,onSelect:o,anchor:h,position:c,portal:e,onOpenChange:e=>{v.setAttribute(`aria-expanded`,e?`true`:`false`)}}),e||h.appendChild(y.element),y};return h.isConnected?b():requestAnimationFrame(()=>{y||b()}),v.addEventListener(`click`,e=>{e.stopPropagation(),b().toggle()}),{element:h,primaryButton:_,chevronButton:v,openMenu:()=>b().show(),closeMenu:()=>y?.hide(),toggleMenu:()=>b().toggle(),destroy:()=>{y?.destroy(),h.remove()}}}function V(e){let{label:t,icon:n=`chevron-down`,menuItems:r,onSelect:i,position:a=`bottom-left`,portal:o,className:s,hover:c}=e,l=k(`div`,`persona-combo-btn`+(s?` `+s:``));l.style.position=`relative`,l.style.display=`inline-flex`,l.style.alignItems=`center`,l.style.cursor=`pointer`,l.setAttribute(`role`,`button`),l.setAttribute(`tabindex`,`0`),l.setAttribute(`aria-haspopup`,`true`),l.setAttribute(`aria-expanded`,`false`),l.setAttribute(`aria-label`,t);let u=k(`span`,`persona-combo-btn-label`);u.textContent=t,l.appendChild(u);let d=T(n,14,`currentColor`,2);d&&(d.style.marginLeft=`4px`,d.style.opacity=`0.6`,l.appendChild(d)),c&&(l.style.borderRadius=c.borderRadius??`10px`,l.style.padding=c.padding??`6px 4px 6px 12px`,l.style.border=`1px solid transparent`,l.style.transition=`background-color 0.15s ease, border-color 0.15s ease`,l.addEventListener(`mouseenter`,()=>{l.style.backgroundColor=c.background??``,l.style.borderColor=c.border??``}),l.addEventListener(`mouseleave`,()=>{l.style.backgroundColor=``,l.style.borderColor=`transparent`}));let f=tr({items:r,onSelect:e=>{l.setAttribute(`aria-expanded`,`false`),i(e)},anchor:l,position:a,portal:o});o||l.appendChild(f.element);let p=()=>l.getAttribute(`data-persona-menu-locked`)===`true`;return l.addEventListener(`click`,e=>{if(e.stopPropagation(),p())return;let t=!f.element.classList.contains(`persona-hidden`);l.setAttribute(`aria-expanded`,t?`false`:`true`),f.toggle()}),l.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l.click())}),{element:l,setLabel:e=>{u.textContent=e,l.setAttribute(`aria-label`,e)},open:()=>{l.setAttribute(`aria-expanded`,`true`),f.show()},close:()=>{l.setAttribute(`aria-expanded`,`false`),f.hide()},toggle:()=>{let e=!f.element.classList.contains(`persona-hidden`);l.setAttribute(`aria-expanded`,e?`false`:`true`),f.toggle()},destroy:()=>{f.destroy(),l.remove()}}}const ar=[`PersonaArtifactCard`,`PersonaArtifactInline`],{setLoader:or,load:sr,provide:cr,getSync:lr}=v({fallbackImport:()=>import(`./chunk-MdlQetfC.js`)});let ur=null;const dr=/* @__PURE__ */ new Set,fr=e=>{if(ur)return ur;ur=e,e.initArtifactsUi({componentRegistry:ze,loadingLabels:Zn(),buttons:{createIconButton:nr,createLabelButton:B,createSplitButton:ir,createToggleGroup:rr}});for(let t of ar)ze.has(t)||ze.register(t,t===`PersonaArtifactCard`?e.PersonaArtifactCard:e.PersonaArtifactInline,{bubbleChrome:!1});let t=Ne();t?e.__provideMarkdownParsers(t):Ue(()=>{let t=Ne();t&&e.__provideMarkdownParsers(t)}),e.__setIconsExtraLoader!==_&&e.__setIconsExtraLoader(y);let n=[...dr];dr.clear();for(let e of n)try{e()}catch{}return e},pr=()=>Promise.all([sr(),I()]).then(([e])=>fr(e)),mr=()=>{if(ur)return ur;if(!Zn())return null;let e=lr();return e?fr(e):null},hr=e=>ur?()=>{}:(dr.add(e),()=>{dr.delete(e)}),{setLoader:gr,load:_r,provide:vr,getSync:H}=v({fallbackImport:()=>import(`./chunk-DE0cSmku.js`)}),yr=_r,br=H,{setLoader:xr,load:Sr,getSync:Cr}=v({fallbackImport:()=>import(`./chunk-DZg9bFK6.js`)}),wr=Sr,Tr=Cr;function Er(e,t){let n=e.voiceRecognition,r=t.voiceRecognition;return n?.enabled===!0!=(r?.enabled===!0)||n?.provider?.type!==r?.provider?.type||n?.provider?.custom!==r?.provider?.custom||kr(e)!==kr(t)||n?.provider?.runtype?.createPlaybackEngine!==r?.provider?.runtype?.createPlaybackEngine||JSON.stringify(n?.provider?.runtype)!==JSON.stringify(r?.provider?.runtype)||e.agentId!==t.agentId||e.clientToken!==t.clientToken||e.apiUrl!==t.apiUrl}function Dr(e){return e?.type===`runtype`||e?.type===`custom`}const Or=()=>typeof window<`u`&&(`SpeechRecognition`in window||`webkitSpeechRecognition`in window);function U(e){try{if(e?.type===`custom`&&e.custom){let t=e.custom,n=typeof t==`function`?t():t;return!!n&&typeof n.startListening==`function`}return e?.type===`runtype`&&e.runtype?!0:Or()}catch{return!1}}function kr(e){let t=e.voiceRecognition;return Dr(t?.provider)&&(t?.provider?.type!==`custom`||!!t.dictation?.provider||!t.dictation&&t.completionBehavior!==`review`)}const Ar=e=>{let t=[],n=(e,n,r)=>{e&&!n&&t.push(r())};n(!0,Jn(),qn),n(!0,Ne(),Oe);let r=e.turnActivity?.enabled===!0;n(r,Hn(),Vn);let i=r||e.features?.showToolCalls!==!1||e.features?.showReasoning!==!1;n(i,In(),Fn),n(i||e.loadingLabel?.animation!==`none`&&(!!e.loadingLabel?.animate||(e.loadingIndicator?.variant??(e.future?.v5Defaults?`label`:`dots`))===`label`),Zn(),I),n(e.voiceRecognition?.enabled!==!1,er(),$n),n(e.voiceRecognition?.enabled!==!1&&kr(e),Tr(),wr),n(e.features?.artifacts?.enabled===!0,mr(),pr),n(e.contextMentions?.enabled===!0,br(),yr);let a=w();return a&&t.push(a),t};function jr(){let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=null};return{get active(){return e!==null},cancel:t,start(n,r,i,a,o,s=()=>!0){t();let c=n.scrollTop,l=performance.now();if(Math.abs(r()-c)<1){n.scrollTop=r(),a(),o();return}let u=d=>{if(!s()){t(),o();return}let f=Math.min(Math.max(0,(d-l)/i),1);n.scrollTop=c+(r()-c)*(1-(1-f)**3),a(),f<1?e=requestAnimationFrame(u):(e=null,o())};e=requestAnimationFrame(u)}}}function Mr(e,t,n,r,i){let a=jr(),o=!1,s,c=!1,l=e=>{e&&(c=!1),a.active&&(a.cancel(),s=e,c=!!e,i())},u=e=>{[`PageUp`,`PageDown`,`Home`,`End`,`ArrowUp`,`ArrowDown`,` `].includes(e.key)&&l(e)},d=e=>{e.deltaY!==0&&l(e)};return e.addEventListener(`wheel`,d,{passive:!0}),e.addEventListener(`touchstart`,l,{passive:!0}),e.addEventListener(`pointerdown`,l,{passive:!0}),t.addEventListener(`keydown`,u),{get active(){return a.active},cancel:l,get interrupted(){return c},interruptedBy:e=>s===e,start(t){if(o)return;a.cancel(),c=!1,s=void 0;let i=(t.features?.scrollToBottom?.scrollBehavior??(t.future?.v5Defaults?`smooth`:`instant`))===`smooth`,l=t.features?.scrollToBottom?.scrollDurationMs??220,u=Number.isFinite(l)&&l>=0?l:220,d=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;!i||d||u===0?(e.scrollTop=Xe(e),n(),r()):a.start(e,()=>Xe(e),u,n,r)},destroy(){o=!0,a.cancel(),e.removeEventListener(`wheel`,d),e.removeEventListener(`touchstart`,l),e.removeEventListener(`pointerdown`,l),t.removeEventListener(`keydown`,u)}}}function Nr(e,t,n){let r=k(`button`,`persona-scroll-to-bottom-indicator persona-absolute persona-bottom-3 persona-left-1/2 persona-z-10 persona-text-xs persona-transform persona--translate-x-1/2 persona-cursor-pointer`);r.type=`button`,r.setAttribute(`data-persona-scroll-to-bottom-visible`,`false`),r.disabled=!0,r.tabIndex=-1,r.setAttribute(`aria-hidden`,`true`),r.setAttribute(`data-persona-scroll-to-bottom`,`true`);let i=k(`span`,`persona-flex persona-items-center persona-justify-center`);i.setAttribute(`aria-hidden`,`true`);let a=k(`span`,``),o=k(`span`,``);o.setAttribute(`data-persona-scroll-to-bottom-count`,``),r.appendChild(i),r.appendChild(a),r.appendChild(o);let s={},c={activity:`idle`,visible:!1,hovered:!1,focused:!1,reducedMotion:!1},l,u,d,f=``,p=typeof matchMedia==`function`?matchMedia(`(prefers-reduced-motion: reduce)`):void 0;c.reducedMotion=p?.matches??!1;let m=e=>console.warn(`Persona scroll icon failed`,e),h=()=>({config:s,state:{...c},view:t,signal:d.signal}),g=()=>{d?.abort();try{u?.destroy?.()}catch(e){m(e)}u=void 0,d=void 0,i.innerHTML=``,f=``},_=()=>{if(u?.element)return;let t=s.features?.scrollToBottom,n=c.activity===`generating-below`&&(t?.streamingIndicator??(s.future?.v5Defaults?`dots`:`arrow`))===`dots`,r=n?`dots`:`arrow:${t?.iconName??`arrow-down`}`;if(f!==r){if(f=r,i.innerHTML=``,n){let e=k(`span`,`persona-scroll-to-bottom-dots`);for(let t=0;t<3;t++){let n=k(`span`,``);n.style.animationDelay=`${t*150}ms`,e.appendChild(n)}i.appendChild(e)}else{let n=e(t?.iconName??`arrow-down`,`14px`,`currentColor`,2);n&&i.appendChild(n)}}},v=e=>{let t=s.features?.scrollToBottom?.enabled===!1?void 0:s.features?.scrollToBottom?.renderIcon;if(t!==l){if(g(),l=t,l){d=new AbortController;try{let e=l(h());u=e&&`element`in e?e:e?{element:e}:void 0,u?.element&&i.appendChild(u.element)}catch(e){m(e),g()}}}else if(e&&u?.update)try{u.update(h())}catch(e){m(e),g()}_()},y=e=>Object.keys(e).some(t=>e[t]!==c[t]),b=e=>{let t=y(e);c=e,v(t)},x=()=>b({...c,hovered:!0}),S=()=>b({...c,hovered:!1}),C=()=>b({...c,focused:!0}),ee=()=>b({...c,focused:!1}),w=()=>b({...c,reducedMotion:p?.matches??!1}),T=new AbortController;for(let[e,t]of[[`mouseenter`,x],[`mouseleave`,S],[`focus`,C],[`blur`,ee]])r.addEventListener(e,t,{signal:T.signal});return p?.addEventListener?.(`change`,w),{element:r,update(e,t,i=!1,l=0){let u=s.features?.scrollToBottom,d=e.features?.scrollToBottom,f=s.future?.v5Defaults!==e.future?.v5Defaults||[`enabled`,`iconName`,`label`,`streamingIndicator`,`transition`,`scrollBehavior`,`scrollDurationMs`].some(e=>u?.[e]!==d?.[e]);s=e;let p=s.features?.scrollToBottom;t&&=p?.enabled!==!1;let m=r.getRootNode().activeElement===r;r.setAttribute(`data-persona-scroll-to-bottom-visible`,String(t));let h=p?.enabled===!1?`none`:p?.transition??(s.future?.v5Defaults?`fade`:`none`);r.setAttribute(`data-persona-scroll-to-bottom-transition`,h),i&&t?r.setAttribute(`data-persona-scroll-to-bottom-streaming`,``):r.removeAttribute(`data-persona-scroll-to-bottom-streaming`),r.style.display=!t&&h===`none`?`none`:``,r.disabled=!t,r.tabIndex=t?0:-1,r.setAttribute(`aria-hidden`,String(!t)),!t&&m&&(r.blur(),n&&(n.hasAttribute(`tabindex`)||(n.tabIndex=-1),n.focus({preventScroll:!0})));let g=p?.label??``,_=g||`Jump to latest`;r.setAttribute(`aria-label`,`${_}${l>0?` (${l} new)`:``}${i&&t?` (response streaming below)`:``}`),r.title=g,r.setAttribute(`data-persona-scroll-to-bottom-has-label`,String(!!g)),a.textContent=g,a.style.display=g?``:`none`,o.textContent=l>0?String(l):``,o.style.display=l>0?``:`none`;let b={...c,visible:t,hovered:t&&c.hovered,focused:t&&c.focused,activity:i&&t?`generating-below`:`idle`},x=f||y(b);c=b,v(x)},destroy(){g(),T.abort(),p?.removeEventListener?.(`change`,w),r.remove()}}}function Pr(e){let t=/* @__PURE__ */ new Map,n=(t,n)=>({slot:t,signal:n.abort.signal,config:e.config(),defaultContent:()=>e.defaultContent(t)}),r=(n,r)=>{t.delete(n),r.abort.abort();try{r.result.destroy?.()}catch(e){console.error(`[AgentWidget] Error destroying slot "${n}":`,e)}e.remove(n,r.result.element)};return{update(){let i=e.config().layout?.slots??{};for(let[e,n]of t)i[e]!==n.renderer&&r(e,n);for(let[a,o]of Object.entries(i)){if(!o)continue;let i=t.get(a);try{if(!i){i={renderer:o,abort:new AbortController,result:{element:null}},t.set(a,i);let e=o(n(a,i));i.result=e===null||`nodeType`in e?{element:e}:e}else if(i.result.update){let t=i.result.update(n(a,i));t!==void 0&&t!==i.result.element&&(e.remove(a,i.result.element),i.result.element=t)}i.result.element&&e.mount(a,i.result.element)}catch(e){i&&r(a,i),console.error(`[AgentWidget] Error rendering slot "${a}":`,e)}}},remount(){for(let[n,r]of t)r.result.element&&e.mount(n,r.result.element)},detach(n){for(let r of n){let n=t.get(r);n&&e.remove(r,n.result.element)}},destroy(){for(let[e,n]of t)r(e,n)}}}const Fr=`var(--persona-md-table-scroll-fade, 24px)`,Ir=/* @__PURE__ */ new WeakSet;function Lr(e){e.querySelectorAll(`table`).forEach(e=>{if(e.parentElement?.classList.contains(`persona-table-scroll`))return;let t=document.createElement(`div`);t.className=`persona-table-scroll`,e.replaceWith(t),t.appendChild(e)})}function Rr(e){let t=e.scrollWidth-e.clientWidth;if(t<=1){e.removeAttribute(`data-persona-scroll-x`);return}e.setAttribute(`data-persona-scroll-x`,``);let n=getComputedStyle(e).direction===`rtl`?t+e.scrollLeft:e.scrollLeft,r=t-n;e.style.setProperty(`--persona-fade-l`,n<=1?`0px`:Fr),e.style.setProperty(`--persona-fade-r`,r<=1?`0px`:Fr)}function zr(e){Ir.has(e)||(Ir.add(e),e.addEventListener(`scroll`,e=>{let t=e.target;t?.classList?.contains(`persona-table-scroll`)&&Rr(t)},!0)),e.querySelectorAll(`.persona-table-scroll`).forEach(Rr)}const{setLoader:Br,load:Vr,provide:Hr,getSync:Ur}=v({fallbackImport:()=>import(`./chunk-Cb7qy0c7.js`)}),Wr=Vr,Gr=Ur,{setLoader:Kr,load:qr,provide:Jr,getSync:Yr}=v({fallbackImport:()=>import(`./chunk-FEzOcZof.js`)}),Xr=qr,Zr=Yr,{setLoader:Qr,load:$r}=v({fallbackImport:()=>import(`./chunk-CzLEhoB_.js`)}),ei=$r,{setLoader:ti,load:ni}=v({fallbackImport:()=>import(`./chunk-lA5CJCgK.js`)}),ri=ni;function ii(e){return e.startsWith(`agent_`)?{kind:`agentId`,agentId:e}:e.startsWith(`flow_`)?{kind:`flowId`,flowId:e}:null}function ai(e,t){let n=e.trim();if(!n)throw Error("[Persona] `target` is empty.");let r=n.indexOf(`:`);if(r>0){let e=n.slice(0,r),i=n.slice(r+1);if(e===`runtype`){let e=ii(i);if(e)return e;throw Error(`[Persona] target "runtype:${i}" is not a valid Runtype agent_/flow_ id.`)}let a=t?.[e];if(!a)throw Error(`[Persona] No target provider registered for "${e}". Add a \`targetProviders.${e}\` resolver, or use a Runtype agent_/flow_ id.`);return{kind:`payload`,payload:a(i).payload}}let i=ii(n);if(i)return i;let a=t?.default;if(a)return{kind:`payload`,payload:a(n).payload};throw Error(`[Persona] target "${n}" has no provider prefix and is not a Runtype agent_/flow_ id. Use "<provider>:${n}", a Runtype TypeID, or register a \`targetProviders.default\` resolver.`)}const{setLoader:oi,load:si,provide:ci}=v({fallbackImport:()=>import(`./chunk-CzZBmTLd.js`)}),li=si;var ui=class extends Error{constructor(e,t,n){super(t),this.name=`HistoryClientError`,this.code=e,n?.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=n.retryAfterSeconds)}};const di=e=>`reason`in e?e.reason:void 0;function fi(e){switch(e){case`json`:return yt;case`regex-json`:return N;case`xml`:return bt;default:return j}}var pi=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y;#b;#x;#S;#C;#w;#T;constructor(e={},t={}){if(this.#f=0,this.#p=/* @__PURE__ */ new Set,this.#m=null,this.clientSession=null,this.#h=null,this.#g=!1,this.lastSentClientToolsFingerprint=null,this.clientToolsFingerprintSessionId=null,this.#_=null,this.#v=!1,this.#y=!1,this.#b=!1,this.#x=null,this.#S=/* @__PURE__ */ new Set,this.#C=/* @__PURE__ */ new Set,this.webMcpBridge=null,this.#w=null,this.#U=null,this.#G=null,this.#i=e,this.#r=t,e.target&&(e.agentId||e.flowId||e.agent))throw Error("[Persona] `target` is mutually exclusive with `agentId`, `flowId`, and `agent`. Set only one routing field.");this.#e=e.apiUrl??`https://api.runtype.com/v1/dispatch`,this.#t={"Content-Type":`application/json`,"X-Persona-Version":Dt,...e.headers},this.#n=!!e.debug,this.#a=e.streamParser??fi(e.parserType),this.#o=e.contextProviders??[],this.#s=e.requestMiddleware,this.#c=e.customFetch,this.#l=e.parseSSEEvent,this.#u=e.getHeaders,e.webmcp?.enabled===!0&&(this.#w=this.#E(e.webmcp))}#E(e){return ei().then(t=>{let n=new t.WebMcpBridge(e,{recordToolDisplayTitles:ot,getToolDisplayTitle:st,loadPolyfill:rt});return this.#T!==void 0&&n.setConfirmHandler(this.#T),this.webMcpBridge=n,n}).catch(e=>(this.#w=null,console.warn(`[Persona] Failed to load the WebMCP runtime chunk`,e),null))}#D(){return this.webMcpBridge?Promise.resolve(this.webMcpBridge):this.#i.webmcp?.enabled===!0?(this.#w||=this.#E(this.#i.webmcp),this.#w):Promise.resolve(null)}updateConfig(e){this.#i=e}setHistoryInternals(e){this.#r=e}cancelStreams(){if(this.#f+=1,this.#i.backgroundConversations)for(let e of this.#p)e.cancel().catch(()=>{})}setSSEEventCallback(e){this.#d=e}setWebMcpConfirmHandler(e){this.#T=e,this.webMcpBridge?.setConfirmHandler(e)}isWebMcpOperational(){return this.webMcpBridge?.isOperational()===!0}getVoiceClientTools(){if(this.#i.webmcp?.enabled!==!0)return null;let e=()=>this.#D(),t={open:async e=>(await ri()).createVoiceClientToolsSession(t,e),snapshot:async()=>{let t=await(await e())?.snapshotForDispatch()??[];return{tools:t,fingerprint:at(t)}},onChange:t=>{let n=null,r=!1;return e().then(e=>{e&&!r&&(n=e.watchToolChanges(t))}),()=>{r=!0,n?.()}},execute:async(t,n,r)=>{let i=await e();return i?i.executeVoiceToolCall(t,n,r):{status:`failed`,error:{message:`WebMCP runtime failed to load.`}}}};return t}executeWebMcpToolCall(e,t,n,r){return this.#i.webmcp?.enabled===!0?this.#D().then(i=>i?i.executeToolCall(e,t,n,r):{isError:!0,content:[{type:`text`,text:`WebMCP runtime failed to load.`}]}):null}getSSEEventCallback(){return this.#d}isClientTokenMode(){return!!this.#i.clientToken}#O(){let{agentId:e,flowId:t,target:n,targetProviders:r}=this.#i;if(!n)return{agentId:e,flowId:t};let i=ai(n,r);return i.kind===`agentId`?{agentId:i.agentId}:i.kind===`flowId`?{flowId:i.flowId}:{targetPayload:i.payload}}isAgentMode(){return!!(this.#i.agent||this.#O().agentId)}#k(){return this.#i.apiUrl?.replace(/\/+$/,``).replace(/\/v1\/dispatch$/,``)||`https://api.runtype.com`}#A(e){return`${this.#k()}/v1/client/${e}`}getClientSession(){return this.clientSession}async reconnectClientTokenStream(e){let t=await this.initSession(),n=!1;for(;;){let r=t.conversationId,i=await this.readVisitorToken();if(t.durableRecovery?.enabled!==!0||!r||!i)throw new ui(`visitor_token_missing`,`Durable recovery is not enabled for this client session`);let a=`${this.#k()}/v1/client/conversations/${encodeURIComponent(r)}/executions/${encodeURIComponent(e.executionId)}/events`,o=new URLSearchParams({sessionId:t.sessionId,after:e.after}),s=await fetch(`${a}?${o}`,{method:`GET`,headers:{"X-Persona-Version":Dt,"X-Visitor-Token":i},signal:e.signal});if(s.status===401&&!n){n=!0;let e=await li();t=await e.recoverFromUnauthorized(this.#K(),await e.readErrorCode(this.#K(),s),null,!0)}else{if(!s.ok)throw await(await li()).historyErrorFor(this.#K(),s,!0);return s}}}async warmSession(){let e=this.clientSession;return!this.isClientTokenMode()||this.#h||e&&/* @__PURE__ */ new Date<e.expiresAt||this.#g===e?null:(this.#g=e,this.initSession().catch(()=>null))}async initSession(){if(!this.isClientTokenMode())throw Error(`initSession() only available in client token mode`);if(this.clientSession&&/* @__PURE__ */ new Date<this.clientSession.expiresAt)return this.clientSession;if(this.#h)return this.#h;let e=this.#h=this.#R().then(t=>this.#h===e?(this.clientSession=t,this.#g=!1,this.resetClientToolsFingerprint(),this.#i.onSessionInit?.(t),t):this.initSession()).finally(()=>{this.#h===e&&(this.#h=null)});return e}#j(){return this.#i.features?.history?.enabled===!0&&this.isClientTokenMode()&&!this.#v}async readVisitorToken(){let e=this.#r.visitorStore;return e?(await e.ready,await e.get()??null):null}#M(){if(!this.#v){this.#I({state:`unavailable`,reason:`history_disabled`}),this.#v=!0,!this.#y&&typeof console<`u`&&(this.#y=!0,console.warn(`[Persona] Visitor history is disabled for this surface; continuing without it.`)),this.#r.onHistoryAvailabilityChanged?.(!1);for(let e of[...this.#C])e(!1)}}getHistoryIdentityStatus(){return this.#x??this.#N()}subscribeHistoryIdentityStatus(e){return this.#S.add(e),()=>{this.#S.delete(e)}}subscribeHistoryAvailability(e){return this.#C.add(e),this.#v&&e(!1),()=>{this.#C.delete(e)}}#N(){return this.isClientTokenMode()?this.#i.features?.history?.enabled!==!0||this.#v?{state:`unavailable`,reason:`history_disabled`}:this.#P():{state:`unavailable`,reason:`ineligible_mode`}}#P(){let e=this.#x;return e?.state===`browser_only`?e:this.#F()}#F(){return this.#i.features?.history?.scope===`browser`?{state:`browser_only`,reason:`configured_browser_scope`}:this.#i.getIdentityProof?{state:`browser_only`,reason:`proof_unavailable_before_binding`}:{state:`browser_only`,reason:`no_identity_provider`}}#I(e){let t=this.getHistoryIdentityStatus(),n=t.state===e.state&&di(t)===di(e);if(this.#x=e,!n){this.#r.onHistoryIdentityStatusChanged?.(e);for(let t of[...this.#S])t(e)}}async#L(e){return new((Zr())??await(Xr())).ClientDispatch(this.#q()).createClientSession(e)}async#R(){return new((Zr())??await(Xr())).ClientDispatch(this.#q()).initializeSession()}async#z(e){let t=this.#i.getStoredSessionId?.()||null,n=this.#i.getStoredConversationId?.()||null,r=await this.#L({storedSessionId:t,identityProof:e}),i=this.#B(r,n,!1);return this.clientSession=i,this.#h=null,this.#g=!1,this.resetClientToolsFingerprint(),i}#B(e,t,n){let r=e.conversationId;return r&&t&&(n||r!==t)&&this.#r.onHistoryContinuityChanged?.({previousConversationId:t,conversationId:r}),this.#i.setStoredSessionId?.(e.sessionId),r&&(this.#i.setStoredConversationId?.(r),this.#r.setStoredConversationRevision?.(e.conversationRevision??null)),e}#V(e){let t=!1;return{session:e,commit:()=>{t||(t=!0,this.clientSession=e,this.#g=!1,this.resetClientToolsFingerprint())},discard:()=>{t=!0}}}async prepareConversationSession(e,t){if(!this.isClientTokenMode())throw Error(`prepareConversationSession() only available in client token mode`);if(!this.#j())throw new ui(`history_disabled`,`Visitor history is disabled for this surface`);await this.#r.historyBootstrapReady;let n=t?.proof??null;if(!await this.readVisitorToken()&&!n)throw new ui(`conversation_credential_missing`,`Reopening a conversation requires a stored visitor token or an identity proof`);let r=await this.#L({conversationId:e,identityProof:n});return this.#V(r)}async prepareNewConversationSession(){if(!this.isClientTokenMode())throw Error(`prepareNewConversationSession() only available in client token mode`);await this.#r.historyBootstrapReady;let e=await this.#L({});return this.#V(e)}handleExternalCredentialChange(){this.clearClientSession(),this.#j()&&this.#I(this.#F())}clearClientSession(){this.clientSession=null,this.#h=null,this.#g=!1,this.resetClientToolsFingerprint()}resetClientToolsFingerprint(){this.lastSentClientToolsFingerprint=null,this.clientToolsFingerprintSessionId=null,this.#_=null}async sendFeedback(e){if(!this.isClientTokenMode())throw Error(`sendFeedback() only available in client token mode`);if(!this.getClientSession())throw Error(`No active session. Please initialize session first.`);return new((Zr())??await(Xr())).ClientDispatch(this.#q()).sendFeedback(e)}async submitMessageFeedback(e,t){let n=this.getClientSession()??await this.initSession();return this.sendFeedback({sessionId:n.sessionId,messageId:e,type:t})}async submitCSATFeedback(e,t){let n=this.getClientSession()??await this.initSession();return this.sendFeedback({sessionId:n.sessionId,type:`csat`,rating:e,comment:t})}async submitNPSFeedback(e,t){let n=this.getClientSession()??await this.initSession();return this.sendFeedback({sessionId:n.sessionId,type:`nps`,rating:e,comment:t})}async#H(e){e?.throwIfAborted();let t=this.#i.identityProvider;if(t===void 0)return;let n=this.#i.getIdentityProof;if(!t.trim()||!n)throw Error(`Chat identity requires identityProvider and getIdentityProof.`);let r,i;try{let t=Promise.resolve().then(()=>n());r=e?await Promise.race([t,new Promise((t,n)=>{i=()=>n(e.reason),e.addEventListener(`abort`,i,{once:!0}),e.aborted&&i()})]):await t}catch{throw e?.throwIfAborted(),Error(`The identity proof provider failed.`)}finally{i&&e?.removeEventListener(`abort`,i)}if(typeof r!=`string`||!r.trim())throw Error(`A fresh identity proof is required to send this message.`);return{provider:t,token:r}}#U;#W(){let e=this;return this.#U??={get config(){return e.#i},headers:this.#t,getHeaders:this.#u,debug:this.#n,clientApiBase:()=>e.#k(),getClientApiUrl:t=>e.#A(t),getWebMcpBridge:()=>e.#D(),sendWithClientToolsDiff:(t,n,r,i)=>e.#J(t,n,r,i),initSession:()=>e.initSession(),readVisitorToken:()=>e.readVisitorToken(),isClientTokenMode:()=>e.isClientTokenMode()}}#G;#K(){let e=this;return this.#G??={HistoryClientError:ui,get config(){return e.#i},get historyInternals(){return e.#r},get clientSession(){return e.clientSession},clientApiBase:()=>e.#k(),setHistoryIdentityStatus:t=>e.#I(t),browserOnlyStatus:()=>e.#P(),derivedBrowserOnly:()=>e.#F(),reinitWithProof:t=>e.#z(t),isHistoryCapable:()=>e.#j(),clearClientSession:()=>e.clearClientSession(),initSession:()=>e.initSession(),readVisitorToken:()=>e.readVisitorToken(),isClientTokenMode:()=>e.isClientTokenMode()}}async listConversations(e){return(await li()).listConversations(this.#K(),e)}async getConversation(e,t){return(await li()).getConversation(this.#K(),e,t)}async finalizeDisplayProjections(e,t){return(await li()).finalizeDisplayProjections(this.#K(),e,t)}async deleteConversation(e,t){return(await li()).deleteConversation(this.#K(),e,t)}async deleteAllConversations(e){return(await li()).deleteAllConversations(this.#K(),e)}async resetVisitor(){return(await li()).resetVisitor(this.#K())}async dispatch(e,t){e.signal?.throwIfAborted(),Wr().catch(()=>{});let n=this.isClientTokenMode(),r=this.isAgentMode(),i=lt();n&&(this.#m=i),t({type:`status`,status:`connecting`});let a=Zr()??await Xr().catch(e=>{let r=e instanceof Error?e:Error(String(e));throw(!n||this.#m===i)&&t({type:`error`,error:r}),r});if(e.signal?.throwIfAborted(),n&&this.#m!==i)throw new DOMException(`Turn superseded`,`AbortError`);let o=new a.ClientDispatch(this.#q());return n?o.dispatchClientToken(e,t,i):r?o.dispatchAgent(e,t):o.dispatchProxy(e,t)}#q(){let e=this;return Object.setPrototypeOf({HistoryClientError:ui,get claimInFlight(){return e.#b},set claimInFlight(t){e.#b=t},get clientToolsFingerprintSessionId(){return e.clientToolsFingerprintSessionId},set clientToolsFingerprintSessionId(t){e.clientToolsFingerprintSessionId=t},get lastSentClientToolsFingerprint(){return e.lastSentClientToolsFingerprint},set lastSentClientToolsFingerprint(t){e.lastSentClientToolsFingerprint=t},get sentNonEmptyClientToolsSessionId(){return e.#_},set sentNonEmptyClientToolsSessionId(t){e.#_=t},get historyInternals(){return e.#r},markHistoryUnavailable:()=>e.#M(),apiUrl:this.#e,contextProviders:this.#o,requestMiddleware:this.#s,customFetch:this.#c,get clientSession(){return e.clientSession},set clientSession(t){e.clientSession=t},isCurrentTurn:t=>e.#m===t,isHistoryCapable:()=>e.#j(),createClientSession:t=>e.#L(t),finishInit:(t,n,r)=>e.#B(t,n,r),resetSessionWarmLatch:()=>{e.#g=!1},resetClientToolsFingerprint:()=>e.resetClientToolsFingerprint(),clearClientSession:()=>e.clearClientSession(),resolveChatIdentityProof:t=>e.#H(t),routing:()=>e.#O(),builtInClientTools:wt,streamResponse:(...t)=>e.#Y(...t)},this.#W())}async processStream(e,t,n,r,i,a,o){t({type:`status`,status:`connected`});try{await this.#Y(e,t,n,r,i,a,o)}finally{t({type:`status`,status:`idle`})}}async resolveApproval(e,t,n){return(await Wr()).resolveApproval(this.#W(),e,t,n)}async#J(e,t,n,r){return new((Zr())??await(Xr())).ClientDispatch(this.#q()).sendWithClientToolsDiff(e,t,n,r)}async resumeFlow(e,t,n){return(await Wr()).resumeFlow(this.#W(),e,t,n)}async#Y(e,t,n,r,i,a,o){let{streamResponse:s}=Gr()??await Wr();return s({config:()=>this.#i,streamGeneration:()=>this.#f,streamReaders:this.#p,createStreamParser:this.#a,parseSSEEvent:this.#l,onSSEEvent:(e,t)=>this.#d?.(e,t)},e,t,n,r,i,a,o)}};const{setLoader:mi,load:hi}=v({fallbackImport:()=>import(`./chunk-CsBLSRM_.js`)}),gi=hi,{setLoader:_i,load:vi,provide:W,getSync:G}=v({fallbackImport:()=>import(`./chunk-BL6v2bXy.js`)}),K=vi,yi=G,bi=e=>typeof e==`object`&&!!e&&!Array.isArray(e),xi=(e,t)=>{let n=/* @__PURE__ */ new Set;return(Array.isArray(e)?e:[]).flatMap(e=>{if(!bi(e))return[];let{toolCallId:r,name:i}=e;if(typeof r!=`string`||!r||typeof i!=`string`||!i||n.has(r))return[];n.add(r);let a=bi(e.arguments)?e.arguments:{},o=e.result??null;return[{id:`voice-tool-${r}`,role:`assistant`,variant:`tool`,content:``,createdAt:t,streaming:!1,toolCall:{id:r,name:i,status:`complete`,args:a,result:o},agentMetadata:{clientToolAnswer:{toolCallId:r,toolName:i,args:a,result:o}}}]})},Si=e=>e.sourceLabel?`quoted-text source=${e.sourceLabel}`:`quoted-text`;function Ci(e){let t=e?.text?.trim()??``;return t?Lt(Si(e),t):``}function wi(e){let t=Ci(e.quote);return t?e.contentParts&&e.contentParts.length>0?{contentParts:[kt(t),...e.contentParts]}:{llmContent:[t,e.text].filter(Boolean).join(`
|
|
1
|
+
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,n as l,o as u,p as d,r as f,t as p,u as m,v as h,y as g}from"./chunk-CdpVP6LZ.js";import{n as _,r as v,t as y}from"./chunk-BnfM7-qg.js";import{t as b}from"./chunk-CnxIZOzx.js";import{A as x,C as S,D as C,E as ee,F as w,I as T,M as te,N as ne,O as re,P as ie,S as ae,T as oe,_ as se,a as ce,b as le,c as ue,d as de,f as E,g as fe,h as pe,i as me,j as he,k as ge,l as _e,m as ve,n as ye,o as be,r as xe,s as Se,t as Ce,u as we,v as D,w as Te,x as Ee,y as De}from"./chunk-DgZZqy14.js";import{_ as Oe,a as ke,c as Ae,d as je,f as Me,g as Ne,h as Pe,i as Fe,l as Ie,m as Le,o as Re,p as ze,r as Be,s as Ve,u as He,v as Ue}from"./chunk-UWMfWW2a.js";import{i as We,r as O,t as k}from"./chunk-D5BxWOFB.js";import{i as Ge,n as Ke,r as qe}from"./chunk-Bb41bKyp.js";import{a as Je,c as Ye,i as Xe,l as Ze,n as Qe,o as $e,r as et,s as tt,t as nt}from"./chunk-CVMIncEY.js";import{a as rt,i as it,n as at,o as ot,r as st}from"./chunk-BAdIgC5d.js";import{n as ct,r as A}from"./chunk-DDZBCAer.js";import{n as lt,r as ut,t as dt}from"./chunk-BvhTpG6k.js";import{f as ft,r as pt,s as mt,u as ht}from"./chunk-DTGvDx8o.js";import{a as gt,i as _t,r as vt}from"./chunk-xzeTUTrE.js";import{a as yt,c as bt,i as xt,n as St,o as j,r as M,s as N,t as Ct,u as wt}from"./chunk-B_H0l3u2.js";import{m as Tt,n as Et}from"./chunk-mEFmAbxE.js";import{t as Dt}from"./chunk-BkOYJ11B.js";import{t as Ot}from"./chunk-C8560fIY.js";import{a as kt,c as At,d as jt,l as Mt,n as Nt,o as Pt,t as Ft,u as It}from"./chunk-BlTD-Wgn.js";import{t as Lt}from"./chunk-aTmHfQO_.js";import{r as Rt,t as zt}from"./chunk-Bz9jAgba.js";import{c as Bt,f as Vt,l as Ht,m as Ut,n as Wt,r as Gt,s as Kt,t as qt,u as Jt}from"./chunk-BEDTp-dm.js";import{n as Yt,t as Xt}from"./chunk-BAkaTZpd.js";import{n as Zt,t as Qt}from"./chunk-Crczk7D3.js";import{n as $t}from"./chunk-py2YB6PV.js";import{a as en,i as tn,n as nn,o as rn,s as an}from"./chunk-Cy1A8vbF.js";import{a as on,c as sn,i as cn,l as ln,n as un,o as dn,r as fn,s as pn,t as mn,u as hn}from"./chunk-BExOAPZb.js";import{n as gn}from"./chunk-DTDHeUsG.js";import{Activity as _n,ArrowRight as vn,Check as yn,ChevronUp as bn,Copy as xn,File as Sn,FileCode as Cn,FileSpreadsheet as wn,FileText as Tn,MessageSquare as En,X as Dn}from"lucide";import"partial-json";import{Idiomorph as On}from"idiomorph";const kn=e=>{let t=0,n=!1,r=Promise.resolve(),i=()=>{},a,o=e.inert===!0,s=()=>{a?.remove(),a=void 0,e.removeAttribute(`data-persona-preparing`),e.inert=o};return{get ready(){return r},prepare(o,c,l=!1){let u=++t;if(i(),!o.length){if(c(),u!==t)return;s(),r=Promise.resolve();return}!l&&!a&&(a=e.ownerDocument.createElement(`style`),a.textContent=`[data-persona-preparing],[data-persona-preparing] *{visibility:hidden!important}`,e.append(a)),l||(e.setAttribute(`data-persona-preparing`,``),e.inert=!0);let d=new Promise((e,t)=>{i=()=>t(/* @__PURE__ */ Error(`Widget destroyed before ready`))});r=Promise.race([Promise.all(o),d]).then(()=>{if(n)throw Error(`Widget destroyed before ready`);if(u!==t||(c(),u!==t))return r;s()},e=>{if(!n&&u!==t)return r;throw e}),r.catch(()=>{})},destroy(){n=!0,++t,i(),s()}}},An={defaultProvenance:d,suppliedPath:e,hasExplicitThemeStyle:t,getExplicitLegacyStyle:f},{setLoader:jn,load:Mn,provide:Nn,getSync:Pn}=v({fallbackImport:()=>import(`./chunk-B4ecQzeK.js`)}),Fn=Mn,In=Pn,{setLoader:Ln,load:Rn,provide:zn}=v({fallbackImport:()=>import(`./chunk-C3cPmtjr.js`)});let Bn=null;const Vn=()=>Promise.all([Rn(),Fn()]).then(([e,t])=>(Object.assign(t.turnUi,e),Bn=e)),Hn=()=>Bn,{setLoader:Un,load:Wn,provide:Gn,getSync:Kn}=v({fallbackImport:()=>import(`./chunk-C7-m0EmI.js`)}),qn=Wn,Jn=Kn,{setLoader:Yn,load:P,provide:F,getSync:Xn}=v({fallbackImport:()=>import(`./chunk-B3l7TOOv.js`)}),I=P,Zn=Xn,{setLoader:L,load:R,getSync:z,provide:Qn}=v({fallbackImport:()=>import(`./chunk-Ds_twaZn.js`)}),$n=R,er=z;function tr(e){let{items:t,onSelect:n,anchor:r,position:i=`bottom-left`,portal:a,onOpenChange:o}=e,s=k(`div`,`persona-dropdown-menu persona-hidden`);s.setAttribute(`role`,`menu`),s.setAttribute(`data-persona-theme-zone`,`dropdown`),a?(s.style.position=`fixed`,s.style.zIndex=String(qe)):(s.style.position=`absolute`,s.style.top=`100%`,s.style.marginTop=`4px`,i===`bottom-right`?s.style.right=`0`:s.style.left=`0`);for(let e of t){if(e.dividerBefore){let e=document.createElement(`hr`);s.appendChild(e)}let t=document.createElement(`button`);if(t.type=`button`,t.setAttribute(`role`,`menuitem`),t.setAttribute(`data-dropdown-item-id`,e.id),e.destructive&&t.setAttribute(`data-destructive`,``),e.icon){let n=T(e.icon,16,`currentColor`,1.5);n&&t.appendChild(n)}let r=document.createElement(`span`);r.textContent=e.label,t.appendChild(r),t.addEventListener(`click`,t=>{t.stopPropagation(),d(),n(e.id)}),s.appendChild(t)}let c=null;function l(){if(!a)return;let e=r.getBoundingClientRect();s.style.top=`${e.bottom+4}px`,i===`bottom-right`?(s.style.right=`${window.innerWidth-e.right}px`,s.style.left=`auto`):(s.style.left=`${e.left}px`,s.style.right=`auto`)}function u(){let e=s.classList.contains(`persona-hidden`);l(),s.classList.remove(`persona-hidden`),e&&o?.(!0),requestAnimationFrame(()=>{let e=e=>{!s.contains(e.target)&&!r.contains(e.target)&&d()};document.addEventListener(`click`,e,!0),c=()=>document.removeEventListener(`click`,e,!0)})}function d(){let e=!s.classList.contains(`persona-hidden`);s.classList.add(`persona-hidden`),c?.(),c=null,e&&o?.(!1)}function f(){s.classList.contains(`persona-hidden`)?u():d()}function p(){d(),s.remove()}return a&&a.appendChild(s),{element:s,show:u,hide:d,toggle:f,destroy:p}}function nr(e){let{icon:t,label:n,size:r,strokeWidth:i,className:a,chromeless:o,onClick:s,aria:c}=e,l=k(`button`,We(!o&&`persona-icon-btn`,a));l.type=`button`,l.setAttribute(`aria-label`,n),l.title=n;let u=T(t,r??16,`currentColor`,i??2);if(u&&l.appendChild(u),s&&l.addEventListener(`click`,s),c)for(let[e,t]of Object.entries(c))l.setAttribute(e,t);return l}function B(e){let{icon:t,label:n,variant:r=`default`,size:i=`sm`,iconSize:a,className:o,onClick:s,aria:c}=e,l=`persona-label-btn`;r!=="default"&&(l+=` persona-label-btn--`+r),l+=` persona-label-btn--`+i,o&&(l+=` `+o);let u=k(`button`,l);if(u.type=`button`,u.setAttribute(`aria-label`,n),t){let e=T(t,a??14,`currentColor`,2);e&&u.appendChild(e)}let d=k(`span`);if(d.textContent=n,u.appendChild(d),s&&u.addEventListener(`click`,s),c)for(let[e,t]of Object.entries(c))u.setAttribute(e,t);return u}function rr(e){let{items:t,selectedId:n,onSelect:r,className:i}=e,a=k(`div`,`persona-toggle-group`+(i?` `+i:``));a.setAttribute(`role`,`group`);let o=n,s=[];function c(){for(let e of s)e.btn.setAttribute(`aria-pressed`,e.id===o?`true`:`false`)}for(let e of t){let t;e.icon?t=nr({icon:e.icon,label:e.label,className:e.className,onClick:()=>{o=e.id,c(),r(e.id)}}):(t=k(`button`,`persona-icon-btn`+(e.className?` `+e.className:``)),t.type=`button`,t.setAttribute(`aria-label`,e.label),t.title=e.label,t.textContent=e.label,t.addEventListener(`click`,()=>{o=e.id,c(),r(e.id)})),t.setAttribute(`aria-pressed`,e.id===o?`true`:`false`),s.push({id:e.id,btn:t}),a.appendChild(t)}function l(e){o=e,c()}return{element:a,setSelected:l}}function ir(e){let{label:t,icon:n,iconSize:r,iconOnly:i,menuItems:a,onSelect:o,onPrimary:s,position:c=`bottom-left`,portal:l,chevronLabel:u=`More options`,chevronIconSize:d,className:f,primaryClassName:p,chevronClassName:m}=e,h=k(`div`,`persona-split-btn`+(f?` `+f:``)),g={label:t,className:`persona-split-btn-primary`+(p?` `+p:``),onClick:s},_=i&&n?nr({...g,icon:n,size:r??14}):B({...g,icon:n,iconSize:r??14}),v=nr({icon:`chevron-down`,label:u,size:d??14,className:`persona-split-btn-chevron`+(m?` `+m:``),aria:{"aria-haspopup":`true`,"aria-expanded":`false`}});h.append(_,v);let y=null,b=()=>{if(y)return y;let e=(typeof l==`function`?l():l)??void 0;return y=tr({items:a,onSelect:o,anchor:h,position:c,portal:e,onOpenChange:e=>{v.setAttribute(`aria-expanded`,e?`true`:`false`)}}),e||h.appendChild(y.element),y};return h.isConnected?b():requestAnimationFrame(()=>{y||b()}),v.addEventListener(`click`,e=>{e.stopPropagation(),b().toggle()}),{element:h,primaryButton:_,chevronButton:v,openMenu:()=>b().show(),closeMenu:()=>y?.hide(),toggleMenu:()=>b().toggle(),destroy:()=>{y?.destroy(),h.remove()}}}function V(e){let{label:t,icon:n=`chevron-down`,menuItems:r,onSelect:i,position:a=`bottom-left`,portal:o,className:s,hover:c}=e,l=k(`div`,`persona-combo-btn`+(s?` `+s:``));l.style.position=`relative`,l.style.display=`inline-flex`,l.style.alignItems=`center`,l.style.cursor=`pointer`,l.setAttribute(`role`,`button`),l.setAttribute(`tabindex`,`0`),l.setAttribute(`aria-haspopup`,`true`),l.setAttribute(`aria-expanded`,`false`),l.setAttribute(`aria-label`,t);let u=k(`span`,`persona-combo-btn-label`);u.textContent=t,l.appendChild(u);let d=T(n,14,`currentColor`,2);d&&(d.style.marginLeft=`4px`,d.style.opacity=`0.6`,l.appendChild(d)),c&&(l.style.borderRadius=c.borderRadius??`10px`,l.style.padding=c.padding??`6px 4px 6px 12px`,l.style.border=`1px solid transparent`,l.style.transition=`background-color 0.15s ease, border-color 0.15s ease`,l.addEventListener(`mouseenter`,()=>{l.style.backgroundColor=c.background??``,l.style.borderColor=c.border??``}),l.addEventListener(`mouseleave`,()=>{l.style.backgroundColor=``,l.style.borderColor=`transparent`}));let f=tr({items:r,onSelect:e=>{l.setAttribute(`aria-expanded`,`false`),i(e)},anchor:l,position:a,portal:o});o||l.appendChild(f.element);let p=()=>l.getAttribute(`data-persona-menu-locked`)===`true`;return l.addEventListener(`click`,e=>{if(e.stopPropagation(),p())return;let t=!f.element.classList.contains(`persona-hidden`);l.setAttribute(`aria-expanded`,t?`false`:`true`),f.toggle()}),l.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l.click())}),{element:l,setLabel:e=>{u.textContent=e,l.setAttribute(`aria-label`,e)},open:()=>{l.setAttribute(`aria-expanded`,`true`),f.show()},close:()=>{l.setAttribute(`aria-expanded`,`false`),f.hide()},toggle:()=>{let e=!f.element.classList.contains(`persona-hidden`);l.setAttribute(`aria-expanded`,e?`false`:`true`),f.toggle()},destroy:()=>{f.destroy(),l.remove()}}}const ar=[`PersonaArtifactCard`,`PersonaArtifactInline`],{setLoader:or,load:sr,provide:cr,getSync:lr}=v({fallbackImport:()=>import(`./chunk-BbXc58OA.js`)});let ur=null;const dr=/* @__PURE__ */ new Set,fr=e=>{if(ur)return ur;ur=e,e.initArtifactsUi({componentRegistry:ze,loadingLabels:Zn(),buttons:{createIconButton:nr,createLabelButton:B,createSplitButton:ir,createToggleGroup:rr}});for(let t of ar)ze.has(t)||ze.register(t,t===`PersonaArtifactCard`?e.PersonaArtifactCard:e.PersonaArtifactInline,{bubbleChrome:!1});let t=Ne();t?e.__provideMarkdownParsers(t):Ue(()=>{let t=Ne();t&&e.__provideMarkdownParsers(t)}),e.__setIconsExtraLoader!==_&&e.__setIconsExtraLoader(y);let n=[...dr];dr.clear();for(let e of n)try{e()}catch{}return e},pr=()=>Promise.all([sr(),I()]).then(([e])=>fr(e)),mr=()=>{if(ur)return ur;if(!Zn())return null;let e=lr();return e?fr(e):null},hr=e=>ur?()=>{}:(dr.add(e),()=>{dr.delete(e)}),{setLoader:gr,load:_r,provide:vr,getSync:H}=v({fallbackImport:()=>import(`./chunk-BpjtKnGI.js`)}),yr=_r,br=H,{setLoader:xr,load:Sr,getSync:Cr}=v({fallbackImport:()=>import(`./chunk-CumoXK3u.js`)}),wr=Sr,Tr=Cr;function Er(e,t){let n=e.voiceRecognition,r=t.voiceRecognition;return n?.enabled===!0!=(r?.enabled===!0)||n?.provider?.type!==r?.provider?.type||n?.provider?.custom!==r?.provider?.custom||kr(e)!==kr(t)||n?.provider?.runtype?.createPlaybackEngine!==r?.provider?.runtype?.createPlaybackEngine||JSON.stringify(n?.provider?.runtype)!==JSON.stringify(r?.provider?.runtype)||e.agentId!==t.agentId||e.clientToken!==t.clientToken||e.apiUrl!==t.apiUrl}function Dr(e){return e?.type===`runtype`||e?.type===`custom`}const Or=()=>typeof window<`u`&&(`SpeechRecognition`in window||`webkitSpeechRecognition`in window);function U(e){try{if(e?.type===`custom`&&e.custom){let t=e.custom,n=typeof t==`function`?t():t;return!!n&&typeof n.startListening==`function`}return e?.type===`runtype`&&e.runtype?!0:Or()}catch{return!1}}function kr(e){let t=e.voiceRecognition;return Dr(t?.provider)&&(t?.provider?.type!==`custom`||!!t.dictation?.provider||!t.dictation&&t.completionBehavior!==`review`)}const Ar=e=>{let t=[],n=(e,n,r)=>{e&&!n&&t.push(r())};n(!0,Jn(),qn),n(!0,Ne(),Oe);let r=e.turnActivity?.enabled===!0;n(r,Hn(),Vn);let i=r||e.features?.showToolCalls!==!1||e.features?.showReasoning!==!1;n(i,In(),Fn),n(i||e.loadingLabel?.animation!==`none`&&(!!e.loadingLabel?.animate||(e.loadingIndicator?.variant??(e.future?.v5Defaults?`label`:`dots`))===`label`),Zn(),I),n(e.voiceRecognition?.enabled!==!1,er(),$n),n(e.voiceRecognition?.enabled!==!1&&kr(e),Tr(),wr),n(e.features?.artifacts?.enabled===!0,mr(),pr),n(e.contextMentions?.enabled===!0,br(),yr);let a=w();return a&&t.push(a),t};function jr(){let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=null};return{get active(){return e!==null},cancel:t,start(n,r,i,a,o,s=()=>!0){t();let c=n.scrollTop,l=performance.now();if(Math.abs(r()-c)<1){n.scrollTop=r(),a(),o();return}let u=d=>{if(!s()){t(),o();return}let f=Math.min(Math.max(0,(d-l)/i),1);n.scrollTop=c+(r()-c)*(1-(1-f)**3),a(),f<1?e=requestAnimationFrame(u):(e=null,o())};e=requestAnimationFrame(u)}}}function Mr(e,t,n,r,i){let a=jr(),o=!1,s,c=!1,l=e=>{e&&(c=!1),a.active&&(a.cancel(),s=e,c=!!e,i())},u=e=>{[`PageUp`,`PageDown`,`Home`,`End`,`ArrowUp`,`ArrowDown`,` `].includes(e.key)&&l(e)},d=e=>{e.deltaY!==0&&l(e)};return e.addEventListener(`wheel`,d,{passive:!0}),e.addEventListener(`touchstart`,l,{passive:!0}),e.addEventListener(`pointerdown`,l,{passive:!0}),t.addEventListener(`keydown`,u),{get active(){return a.active},cancel:l,get interrupted(){return c},interruptedBy:e=>s===e,start(t){if(o)return;a.cancel(),c=!1,s=void 0;let i=(t.features?.scrollToBottom?.scrollBehavior??(t.future?.v5Defaults?`smooth`:`instant`))===`smooth`,l=t.features?.scrollToBottom?.scrollDurationMs??220,u=Number.isFinite(l)&&l>=0?l:220,d=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;!i||d||u===0?(e.scrollTop=Xe(e),n(),r()):a.start(e,()=>Xe(e),u,n,r)},destroy(){o=!0,a.cancel(),e.removeEventListener(`wheel`,d),e.removeEventListener(`touchstart`,l),e.removeEventListener(`pointerdown`,l),t.removeEventListener(`keydown`,u)}}}function Nr(e,t,n){let r=k(`button`,`persona-scroll-to-bottom-indicator persona-absolute persona-bottom-3 persona-left-1/2 persona-z-10 persona-text-xs persona-transform persona--translate-x-1/2 persona-cursor-pointer`);r.type=`button`,r.setAttribute(`data-persona-scroll-to-bottom-visible`,`false`),r.disabled=!0,r.tabIndex=-1,r.setAttribute(`aria-hidden`,`true`),r.setAttribute(`data-persona-scroll-to-bottom`,`true`);let i=k(`span`,`persona-flex persona-items-center persona-justify-center`);i.setAttribute(`aria-hidden`,`true`);let a=k(`span`,``),o=k(`span`,``);o.setAttribute(`data-persona-scroll-to-bottom-count`,``),r.appendChild(i),r.appendChild(a),r.appendChild(o);let s={},c={activity:`idle`,visible:!1,hovered:!1,focused:!1,reducedMotion:!1},l,u,d,f=``,p=typeof matchMedia==`function`?matchMedia(`(prefers-reduced-motion: reduce)`):void 0;c.reducedMotion=p?.matches??!1;let m=e=>console.warn(`Persona scroll icon failed`,e),h=()=>({config:s,state:{...c},view:t,signal:d.signal}),g=()=>{d?.abort();try{u?.destroy?.()}catch(e){m(e)}u=void 0,d=void 0,i.innerHTML=``,f=``},_=()=>{if(u?.element)return;let t=s.features?.scrollToBottom,n=c.activity===`generating-below`&&(t?.streamingIndicator??(s.future?.v5Defaults?`dots`:`arrow`))===`dots`,r=n?`dots`:`arrow:${t?.iconName??`arrow-down`}`;if(f!==r){if(f=r,i.innerHTML=``,n){let e=k(`span`,`persona-scroll-to-bottom-dots`);for(let t=0;t<3;t++){let n=k(`span`,``);n.style.animationDelay=`${t*150}ms`,e.appendChild(n)}i.appendChild(e)}else{let n=e(t?.iconName??`arrow-down`,`14px`,`currentColor`,2);n&&i.appendChild(n)}}},v=e=>{let t=s.features?.scrollToBottom?.enabled===!1?void 0:s.features?.scrollToBottom?.renderIcon;if(t!==l){if(g(),l=t,l){d=new AbortController;try{let e=l(h());u=e&&`element`in e?e:e?{element:e}:void 0,u?.element&&i.appendChild(u.element)}catch(e){m(e),g()}}}else if(e&&u?.update)try{u.update(h())}catch(e){m(e),g()}_()},y=e=>Object.keys(e).some(t=>e[t]!==c[t]),b=e=>{let t=y(e);c=e,v(t)},x=()=>b({...c,hovered:!0}),S=()=>b({...c,hovered:!1}),C=()=>b({...c,focused:!0}),ee=()=>b({...c,focused:!1}),w=()=>b({...c,reducedMotion:p?.matches??!1}),T=new AbortController;for(let[e,t]of[[`mouseenter`,x],[`mouseleave`,S],[`focus`,C],[`blur`,ee]])r.addEventListener(e,t,{signal:T.signal});return p?.addEventListener?.(`change`,w),{element:r,update(e,t,i=!1,l=0){let u=s.features?.scrollToBottom,d=e.features?.scrollToBottom,f=s.future?.v5Defaults!==e.future?.v5Defaults||[`enabled`,`iconName`,`label`,`streamingIndicator`,`transition`,`scrollBehavior`,`scrollDurationMs`].some(e=>u?.[e]!==d?.[e]);s=e;let p=s.features?.scrollToBottom;t&&=p?.enabled!==!1;let m=r.getRootNode().activeElement===r;r.setAttribute(`data-persona-scroll-to-bottom-visible`,String(t));let h=p?.enabled===!1?`none`:p?.transition??(s.future?.v5Defaults?`fade`:`none`);r.setAttribute(`data-persona-scroll-to-bottom-transition`,h),i&&t?r.setAttribute(`data-persona-scroll-to-bottom-streaming`,``):r.removeAttribute(`data-persona-scroll-to-bottom-streaming`),r.style.display=!t&&h===`none`?`none`:``,r.disabled=!t,r.tabIndex=t?0:-1,r.setAttribute(`aria-hidden`,String(!t)),!t&&m&&(r.blur(),n&&(n.hasAttribute(`tabindex`)||(n.tabIndex=-1),n.focus({preventScroll:!0})));let g=p?.label??``,_=g||`Jump to latest`;r.setAttribute(`aria-label`,`${_}${l>0?` (${l} new)`:``}${i&&t?` (response streaming below)`:``}`),r.title=g,r.setAttribute(`data-persona-scroll-to-bottom-has-label`,String(!!g)),a.textContent=g,a.style.display=g?``:`none`,o.textContent=l>0?String(l):``,o.style.display=l>0?``:`none`;let b={...c,visible:t,hovered:t&&c.hovered,focused:t&&c.focused,activity:i&&t?`generating-below`:`idle`},x=f||y(b);c=b,v(x)},destroy(){g(),T.abort(),p?.removeEventListener?.(`change`,w),r.remove()}}}function Pr(e){let t=/* @__PURE__ */ new Map,n=(t,n)=>({slot:t,signal:n.abort.signal,config:e.config(),defaultContent:()=>e.defaultContent(t)}),r=(n,r)=>{t.delete(n),r.abort.abort();try{r.result.destroy?.()}catch(e){console.error(`[AgentWidget] Error destroying slot "${n}":`,e)}e.remove(n,r.result.element)};return{update(){let i=e.config().layout?.slots??{};for(let[e,n]of t)i[e]!==n.renderer&&r(e,n);for(let[a,o]of Object.entries(i)){if(!o)continue;let i=t.get(a);try{if(!i){i={renderer:o,abort:new AbortController,result:{element:null}},t.set(a,i);let e=o(n(a,i));i.result=e===null||`nodeType`in e?{element:e}:e}else if(i.result.update){let t=i.result.update(n(a,i));t!==void 0&&t!==i.result.element&&(e.remove(a,i.result.element),i.result.element=t)}i.result.element&&e.mount(a,i.result.element)}catch(e){i&&r(a,i),console.error(`[AgentWidget] Error rendering slot "${a}":`,e)}}},remount(){for(let[n,r]of t)r.result.element&&e.mount(n,r.result.element)},detach(n){for(let r of n){let n=t.get(r);n&&e.remove(r,n.result.element)}},destroy(){for(let[e,n]of t)r(e,n)}}}const Fr=`var(--persona-md-table-scroll-fade, 24px)`,Ir=/* @__PURE__ */ new WeakSet;function Lr(e){e.querySelectorAll(`table`).forEach(e=>{if(e.parentElement?.classList.contains(`persona-table-scroll`))return;let t=document.createElement(`div`);t.className=`persona-table-scroll`,e.replaceWith(t),t.appendChild(e)})}function Rr(e){let t=e.scrollWidth-e.clientWidth;if(t<=1){e.removeAttribute(`data-persona-scroll-x`);return}e.setAttribute(`data-persona-scroll-x`,``);let n=getComputedStyle(e).direction===`rtl`?t+e.scrollLeft:e.scrollLeft,r=t-n;e.style.setProperty(`--persona-fade-l`,n<=1?`0px`:Fr),e.style.setProperty(`--persona-fade-r`,r<=1?`0px`:Fr)}function zr(e){Ir.has(e)||(Ir.add(e),e.addEventListener(`scroll`,e=>{let t=e.target;t?.classList?.contains(`persona-table-scroll`)&&Rr(t)},!0)),e.querySelectorAll(`.persona-table-scroll`).forEach(Rr)}const{setLoader:Br,load:Vr,provide:Hr,getSync:Ur}=v({fallbackImport:()=>import(`./chunk-DNdeIFJ6.js`)}),Wr=Vr,Gr=Ur,{setLoader:Kr,load:qr,provide:Jr,getSync:Yr}=v({fallbackImport:()=>import(`./chunk-DM-OJt5q.js`)}),Xr=qr,Zr=Yr,{setLoader:Qr,load:$r}=v({fallbackImport:()=>import(`./chunk-CzLEhoB_.js`)}),ei=$r,{setLoader:ti,load:ni}=v({fallbackImport:()=>import(`./chunk-lA5CJCgK.js`)}),ri=ni;function ii(e){return e.startsWith(`agent_`)?{kind:`agentId`,agentId:e}:e.startsWith(`flow_`)?{kind:`flowId`,flowId:e}:null}function ai(e,t){let n=e.trim();if(!n)throw Error("[Persona] `target` is empty.");let r=n.indexOf(`:`);if(r>0){let e=n.slice(0,r),i=n.slice(r+1);if(e===`runtype`){let e=ii(i);if(e)return e;throw Error(`[Persona] target "runtype:${i}" is not a valid Runtype agent_/flow_ id.`)}let a=t?.[e];if(!a)throw Error(`[Persona] No target provider registered for "${e}". Add a \`targetProviders.${e}\` resolver, or use a Runtype agent_/flow_ id.`);return{kind:`payload`,payload:a(i).payload}}let i=ii(n);if(i)return i;let a=t?.default;if(a)return{kind:`payload`,payload:a(n).payload};throw Error(`[Persona] target "${n}" has no provider prefix and is not a Runtype agent_/flow_ id. Use "<provider>:${n}", a Runtype TypeID, or register a \`targetProviders.default\` resolver.`)}const{setLoader:oi,load:si,provide:ci}=v({fallbackImport:()=>import(`./chunk-C9uOhfk5.js`)}),li=si;var ui=class extends Error{constructor(e,t,n){super(t),this.name=`HistoryClientError`,this.code=e,n?.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=n.retryAfterSeconds)}};const di=e=>`reason`in e?e.reason:void 0;function fi(e){switch(e){case`json`:return yt;case`regex-json`:return N;case`xml`:return bt;default:return j}}var pi=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y;#b;#x;#S;#C;#w;#T;constructor(e={},t={}){if(this.#f=0,this.#p=/* @__PURE__ */ new Set,this.#m=null,this.clientSession=null,this.#h=null,this.#g=!1,this.lastSentClientToolsFingerprint=null,this.clientToolsFingerprintSessionId=null,this.#_=null,this.#v=!1,this.#y=!1,this.#b=!1,this.#x=null,this.#S=/* @__PURE__ */ new Set,this.#C=/* @__PURE__ */ new Set,this.webMcpBridge=null,this.#w=null,this.#U=null,this.#G=null,this.#i=e,this.#r=t,e.target&&(e.agentId||e.flowId||e.agent))throw Error("[Persona] `target` is mutually exclusive with `agentId`, `flowId`, and `agent`. Set only one routing field.");this.#e=e.apiUrl??`https://api.runtype.com/v1/dispatch`,this.#t={"Content-Type":`application/json`,"X-Persona-Version":Dt,...e.headers},this.#n=!!e.debug,this.#a=e.streamParser??fi(e.parserType),this.#o=e.contextProviders??[],this.#s=e.requestMiddleware,this.#c=e.customFetch,this.#l=e.parseSSEEvent,this.#u=e.getHeaders,e.webmcp?.enabled===!0&&(this.#w=this.#E(e.webmcp))}#E(e){return ei().then(t=>{let n=new t.WebMcpBridge(e,{recordToolDisplayTitles:ot,getToolDisplayTitle:st,loadPolyfill:rt});return this.#T!==void 0&&n.setConfirmHandler(this.#T),this.webMcpBridge=n,n}).catch(e=>(this.#w=null,console.warn(`[Persona] Failed to load the WebMCP runtime chunk`,e),null))}#D(){return this.webMcpBridge?Promise.resolve(this.webMcpBridge):this.#i.webmcp?.enabled===!0?(this.#w||=this.#E(this.#i.webmcp),this.#w):Promise.resolve(null)}updateConfig(e){this.#i=e}setHistoryInternals(e){this.#r=e}cancelStreams(){if(this.#f+=1,this.#i.backgroundConversations)for(let e of this.#p)e.cancel().catch(()=>{})}setSSEEventCallback(e){this.#d=e}setWebMcpConfirmHandler(e){this.#T=e,this.webMcpBridge?.setConfirmHandler(e)}isWebMcpOperational(){return this.webMcpBridge?.isOperational()===!0}getVoiceClientTools(){if(this.#i.webmcp?.enabled!==!0)return null;let e=()=>this.#D(),t={open:async e=>(await ri()).createVoiceClientToolsSession(t,e),snapshot:async()=>{let t=await(await e())?.snapshotForDispatch()??[];return{tools:t,fingerprint:at(t)}},onChange:t=>{let n=null,r=!1;return e().then(e=>{e&&!r&&(n=e.watchToolChanges(t))}),()=>{r=!0,n?.()}},execute:async(t,n,r)=>{let i=await e();return i?i.executeVoiceToolCall(t,n,r):{status:`failed`,error:{message:`WebMCP runtime failed to load.`}}}};return t}executeWebMcpToolCall(e,t,n,r){return this.#i.webmcp?.enabled===!0?this.#D().then(i=>i?i.executeToolCall(e,t,n,r):{isError:!0,content:[{type:`text`,text:`WebMCP runtime failed to load.`}]}):null}getSSEEventCallback(){return this.#d}isClientTokenMode(){return!!this.#i.clientToken}#O(){let{agentId:e,flowId:t,target:n,targetProviders:r}=this.#i;if(!n)return{agentId:e,flowId:t};let i=ai(n,r);return i.kind===`agentId`?{agentId:i.agentId}:i.kind===`flowId`?{flowId:i.flowId}:{targetPayload:i.payload}}isAgentMode(){return!!(this.#i.agent||this.#O().agentId)}#k(){return this.#i.apiUrl?.replace(/\/+$/,``).replace(/\/v1\/dispatch$/,``)||`https://api.runtype.com`}#A(e){return`${this.#k()}/v1/client/${e}`}getClientSession(){return this.clientSession}async reconnectClientTokenStream(e){let t=await this.initSession(),n=!1;for(;;){let r=t.conversationId,i=await this.readVisitorToken();if(t.durableRecovery?.enabled!==!0||!r||!i)throw new ui(`visitor_token_missing`,`Durable recovery is not enabled for this client session`);let a=`${this.#k()}/v1/client/conversations/${encodeURIComponent(r)}/executions/${encodeURIComponent(e.executionId)}/events`,o=new URLSearchParams({sessionId:t.sessionId,after:e.after}),s=await fetch(`${a}?${o}`,{method:`GET`,headers:{"X-Persona-Version":Dt,"X-Visitor-Token":i},signal:e.signal});if(s.status===401&&!n){n=!0;let e=await li();t=await e.recoverFromUnauthorized(this.#K(),await e.readErrorCode(this.#K(),s),null,!0)}else{if(!s.ok)throw await(await li()).historyErrorFor(this.#K(),s,!0);return s}}}async warmSession(){let e=this.clientSession;return!this.isClientTokenMode()||this.#h||e&&/* @__PURE__ */ new Date<e.expiresAt||this.#g===e?null:(this.#g=e,this.initSession().catch(()=>null))}async initSession(){if(!this.isClientTokenMode())throw Error(`initSession() only available in client token mode`);if(this.clientSession&&/* @__PURE__ */ new Date<this.clientSession.expiresAt)return this.clientSession;if(this.#h)return this.#h;let e=this.#h=this.#R().then(t=>this.#h===e?(this.clientSession=t,this.#g=!1,this.resetClientToolsFingerprint(),this.#i.onSessionInit?.(t),t):this.initSession()).finally(()=>{this.#h===e&&(this.#h=null)});return e}#j(){return this.#i.features?.history?.enabled===!0&&this.isClientTokenMode()&&!this.#v}async readVisitorToken(){let e=this.#r.visitorStore;return e?(await e.ready,await e.get()??null):null}#M(){if(!this.#v){this.#I({state:`unavailable`,reason:`history_disabled`}),this.#v=!0,!this.#y&&typeof console<`u`&&(this.#y=!0,console.warn(`[Persona] Visitor history is disabled for this surface; continuing without it.`)),this.#r.onHistoryAvailabilityChanged?.(!1);for(let e of[...this.#C])e(!1)}}getHistoryIdentityStatus(){return this.#x??this.#N()}subscribeHistoryIdentityStatus(e){return this.#S.add(e),()=>{this.#S.delete(e)}}subscribeHistoryAvailability(e){return this.#C.add(e),this.#v&&e(!1),()=>{this.#C.delete(e)}}#N(){return this.isClientTokenMode()?this.#i.features?.history?.enabled!==!0||this.#v?{state:`unavailable`,reason:`history_disabled`}:this.#P():{state:`unavailable`,reason:`ineligible_mode`}}#P(){let e=this.#x;return e?.state===`browser_only`?e:this.#F()}#F(){return this.#i.features?.history?.scope===`browser`?{state:`browser_only`,reason:`configured_browser_scope`}:this.#i.getIdentityProof?{state:`browser_only`,reason:`proof_unavailable_before_binding`}:{state:`browser_only`,reason:`no_identity_provider`}}#I(e){let t=this.getHistoryIdentityStatus(),n=t.state===e.state&&di(t)===di(e);if(this.#x=e,!n){this.#r.onHistoryIdentityStatusChanged?.(e);for(let t of[...this.#S])t(e)}}async#L(e){return new((Zr())??await(Xr())).ClientDispatch(this.#q()).createClientSession(e)}async#R(){return new((Zr())??await(Xr())).ClientDispatch(this.#q()).initializeSession()}async#z(e){let t=this.#i.getStoredSessionId?.()||null,n=this.#i.getStoredConversationId?.()||null,r=await this.#L({storedSessionId:t,identityProof:e}),i=this.#B(r,n,!1);return this.clientSession=i,this.#h=null,this.#g=!1,this.resetClientToolsFingerprint(),i}#B(e,t,n){let r=e.conversationId;return r&&t&&(n||r!==t)&&this.#r.onHistoryContinuityChanged?.({previousConversationId:t,conversationId:r}),this.#i.setStoredSessionId?.(e.sessionId),r&&(this.#i.setStoredConversationId?.(r),this.#r.setStoredConversationRevision?.(e.conversationRevision??null)),e}#V(e){let t=!1;return{session:e,commit:()=>{t||(t=!0,this.clientSession=e,this.#g=!1,this.resetClientToolsFingerprint())},discard:()=>{t=!0}}}async prepareConversationSession(e,t){if(!this.isClientTokenMode())throw Error(`prepareConversationSession() only available in client token mode`);if(!this.#j())throw new ui(`history_disabled`,`Visitor history is disabled for this surface`);await this.#r.historyBootstrapReady;let n=t?.proof??null;if(!await this.readVisitorToken()&&!n)throw new ui(`conversation_credential_missing`,`Reopening a conversation requires a stored visitor token or an identity proof`);let r=await this.#L({conversationId:e,identityProof:n});return this.#V(r)}async prepareNewConversationSession(){if(!this.isClientTokenMode())throw Error(`prepareNewConversationSession() only available in client token mode`);await this.#r.historyBootstrapReady;let e=await this.#L({});return this.#V(e)}handleExternalCredentialChange(){this.clearClientSession(),this.#j()&&this.#I(this.#F())}clearClientSession(){this.clientSession=null,this.#h=null,this.#g=!1,this.resetClientToolsFingerprint()}resetClientToolsFingerprint(){this.lastSentClientToolsFingerprint=null,this.clientToolsFingerprintSessionId=null,this.#_=null}async sendFeedback(e){if(!this.isClientTokenMode())throw Error(`sendFeedback() only available in client token mode`);if(!this.getClientSession())throw Error(`No active session. Please initialize session first.`);return new((Zr())??await(Xr())).ClientDispatch(this.#q()).sendFeedback(e)}async submitMessageFeedback(e,t){let n=this.getClientSession()??await this.initSession();return this.sendFeedback({sessionId:n.sessionId,messageId:e,type:t})}async submitCSATFeedback(e,t){let n=this.getClientSession()??await this.initSession();return this.sendFeedback({sessionId:n.sessionId,type:`csat`,rating:e,comment:t})}async submitNPSFeedback(e,t){let n=this.getClientSession()??await this.initSession();return this.sendFeedback({sessionId:n.sessionId,type:`nps`,rating:e,comment:t})}async#H(e){e?.throwIfAborted();let t=this.#i.identityProvider;if(t===void 0)return;let n=this.#i.getIdentityProof;if(!t.trim()||!n)throw Error(`Chat identity requires identityProvider and getIdentityProof.`);let r,i;try{let t=Promise.resolve().then(()=>n());r=e?await Promise.race([t,new Promise((t,n)=>{i=()=>n(e.reason),e.addEventListener(`abort`,i,{once:!0}),e.aborted&&i()})]):await t}catch{throw e?.throwIfAborted(),Error(`The identity proof provider failed.`)}finally{i&&e?.removeEventListener(`abort`,i)}if(typeof r!=`string`||!r.trim())throw Error(`A fresh identity proof is required to send this message.`);return{provider:t,token:r}}#U;#W(){let e=this;return this.#U??={get config(){return e.#i},headers:this.#t,getHeaders:this.#u,debug:this.#n,clientApiBase:()=>e.#k(),getClientApiUrl:t=>e.#A(t),getWebMcpBridge:()=>e.#D(),sendWithClientToolsDiff:(t,n,r,i)=>e.#J(t,n,r,i),initSession:()=>e.initSession(),readVisitorToken:()=>e.readVisitorToken(),isClientTokenMode:()=>e.isClientTokenMode()}}#G;#K(){let e=this;return this.#G??={HistoryClientError:ui,get config(){return e.#i},get historyInternals(){return e.#r},get clientSession(){return e.clientSession},clientApiBase:()=>e.#k(),setHistoryIdentityStatus:t=>e.#I(t),browserOnlyStatus:()=>e.#P(),derivedBrowserOnly:()=>e.#F(),reinitWithProof:t=>e.#z(t),isHistoryCapable:()=>e.#j(),clearClientSession:()=>e.clearClientSession(),initSession:()=>e.initSession(),readVisitorToken:()=>e.readVisitorToken(),isClientTokenMode:()=>e.isClientTokenMode()}}async listConversations(e){return(await li()).listConversations(this.#K(),e)}async getConversation(e,t){return(await li()).getConversation(this.#K(),e,t)}async finalizeDisplayProjections(e,t){return(await li()).finalizeDisplayProjections(this.#K(),e,t)}async deleteConversation(e,t){return(await li()).deleteConversation(this.#K(),e,t)}async deleteAllConversations(e){return(await li()).deleteAllConversations(this.#K(),e)}async resetVisitor(){return(await li()).resetVisitor(this.#K())}async dispatch(e,t){e.signal?.throwIfAborted(),Wr().catch(()=>{});let n=this.isClientTokenMode(),r=this.isAgentMode(),i=lt();n&&(this.#m=i),t({type:`status`,status:`connecting`});let a=Zr()??await Xr().catch(e=>{let r=e instanceof Error?e:Error(String(e));throw(!n||this.#m===i)&&t({type:`error`,error:r}),r});if(e.signal?.throwIfAborted(),n&&this.#m!==i)throw new DOMException(`Turn superseded`,`AbortError`);let o=new a.ClientDispatch(this.#q());return n?o.dispatchClientToken(e,t,i):r?o.dispatchAgent(e,t):o.dispatchProxy(e,t)}#q(){let e=this;return Object.setPrototypeOf({HistoryClientError:ui,get claimInFlight(){return e.#b},set claimInFlight(t){e.#b=t},get clientToolsFingerprintSessionId(){return e.clientToolsFingerprintSessionId},set clientToolsFingerprintSessionId(t){e.clientToolsFingerprintSessionId=t},get lastSentClientToolsFingerprint(){return e.lastSentClientToolsFingerprint},set lastSentClientToolsFingerprint(t){e.lastSentClientToolsFingerprint=t},get sentNonEmptyClientToolsSessionId(){return e.#_},set sentNonEmptyClientToolsSessionId(t){e.#_=t},get historyInternals(){return e.#r},markHistoryUnavailable:()=>e.#M(),apiUrl:this.#e,contextProviders:this.#o,requestMiddleware:this.#s,customFetch:this.#c,get clientSession(){return e.clientSession},set clientSession(t){e.clientSession=t},isCurrentTurn:t=>e.#m===t,isHistoryCapable:()=>e.#j(),createClientSession:t=>e.#L(t),finishInit:(t,n,r)=>e.#B(t,n,r),resetSessionWarmLatch:()=>{e.#g=!1},resetClientToolsFingerprint:()=>e.resetClientToolsFingerprint(),clearClientSession:()=>e.clearClientSession(),resolveChatIdentityProof:t=>e.#H(t),routing:()=>e.#O(),builtInClientTools:wt,streamResponse:(...t)=>e.#Y(...t)},this.#W())}async processStream(e,t,n,r,i,a,o){t({type:`status`,status:`connected`});try{await this.#Y(e,t,n,r,i,a,o)}finally{t({type:`status`,status:`idle`})}}async resolveApproval(e,t,n){return(await Wr()).resolveApproval(this.#W(),e,t,n)}async#J(e,t,n,r){return new((Zr())??await(Xr())).ClientDispatch(this.#q()).sendWithClientToolsDiff(e,t,n,r)}async resumeFlow(e,t,n){return(await Wr()).resumeFlow(this.#W(),e,t,n)}async#Y(e,t,n,r,i,a,o){let{streamResponse:s}=Gr()??await Wr();return s({config:()=>this.#i,streamGeneration:()=>this.#f,streamReaders:this.#p,createStreamParser:this.#a,parseSSEEvent:this.#l,onSSEEvent:(e,t)=>this.#d?.(e,t)},e,t,n,r,i,a,o)}};const{setLoader:mi,load:hi}=v({fallbackImport:()=>import(`./chunk-CsBLSRM_.js`)}),gi=hi,{setLoader:_i,load:vi,provide:W,getSync:G}=v({fallbackImport:()=>import(`./chunk-BL6v2bXy.js`)}),K=vi,yi=G,bi=e=>typeof e==`object`&&!!e&&!Array.isArray(e),xi=(e,t)=>{let n=/* @__PURE__ */ new Set;return(Array.isArray(e)?e:[]).flatMap(e=>{if(!bi(e))return[];let{toolCallId:r,name:i}=e;if(typeof r!=`string`||!r||typeof i!=`string`||!i||n.has(r))return[];n.add(r);let a=bi(e.arguments)?e.arguments:{},o=e.result??null;return[{id:`voice-tool-${r}`,role:`assistant`,variant:`tool`,content:``,createdAt:t,streaming:!1,toolCall:{id:r,name:i,status:`complete`,args:a,result:o},agentMetadata:{clientToolAnswer:{toolCallId:r,toolName:i,args:a,result:o}}}]})},Si=e=>e.sourceLabel?`quoted-text source=${e.sourceLabel}`:`quoted-text`;function Ci(e){let t=e?.text?.trim()??``;return t?Lt(Si(e),t):``}function wi(e){let t=Ci(e.quote);return t?e.contentParts&&e.contentParts.length>0?{contentParts:[kt(t),...e.contentParts]}:{llmContent:[t,e.text].filter(Boolean).join(`
|
|
2
2
|
|
|
3
3
|
`)}:{}}function Ti(e,t=140){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function Ei(e,t){let n=e.findIndex(e=>e.id===t);if(n===-1||e[n].role!==`user`)return null;let r=n+1;for(;r<e.length&&e[r].role!==`user`;)r+=1;return{start:n,end:r}}function Di(e,t){let n=e.findIndex(e=>e.id===t);if(n<=0)return null;for(let t=n-1;t>=0;--t)if(e[t].role===`user`)return e[t].id;return null}function Oi(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role===`user`||n.streaming)return null;if(!(n.role!==`assistant`||n.variant))return Di(e,n.id)?n.id:null}return null}function ki(e){return e.role!==`user`||e.variant||e.streaming||e.contentParts?.length||e.contextMentions?.length||e.contentSegments?.length||e.mentionContext&&Object.keys(e.mentionContext).length>0||e.rawContent!==void 0||e.llmContent!==void 0&&e.llmContent!==e.content||e.quote?!1:typeof e.content==`string`&&e.content.length>0}function Ai(e,t){let{config:n,message:r,onPropsUpdate:i}=t,a=Pe(n,e.component);if(!a){if(ar.includes(e.component)){pr().catch(()=>{});let e=k(`div`,`persona-w-full`);return e.setAttribute(`data-persona-artifact-pending`,`true`),e}return console.warn(`[ComponentMiddleware] Component "${e.component}" not found in registry. Falling back to default rendering.`),null}let o=t.context??{message:r,config:n,signal:t.signal??new AbortController().signal,updateProps:e=>{i&&i(e)}};try{return a(e.props,o)}catch(t){return console.error(`[ComponentMiddleware] Error rendering component "${e.component}":`,t),null}}function ji(e){if(typeof e.rawContent==`string`&&e.rawContent.length>0)return e.rawContent;if(typeof e.content==`string`){let t=e.content.trim();if(t.startsWith(`{`)||t.startsWith(`[`))return e.content}return null}function Mi(e){let t=ji(e);if(!t)return!1;try{let e=JSON.parse(t);return typeof e==`object`&&!!e&&`component`in e&&typeof e.component==`string`}catch{return!1}}function Ni(e){let t=ji(e);if(!t)return null;try{let e=JSON.parse(t);if(typeof e==`object`&&e&&`component`in e&&typeof e.component==`string`){let n=e;return{component:n.component,props:n.props&&typeof n.props==`object`&&n.props!==null?n.props:{},raw:t}}}catch{}return null}function Pi(e){for(let t of[`Microsoft Jenny Online (Natural) - English (United States)`,`Microsoft Aria Online (Natural) - English (United States)`,`Microsoft Guy Online (Natural) - English (United States)`,`Google US English`,`Google UK English Female`,`Ava (Premium)`,`Evan (Enhanced)`,`Samantha (Enhanced)`,`Samantha`,`Daniel`,`Karen`,`Microsoft David Desktop - English (United States)`,`Microsoft Zira Desktop - English (United States)`]){let n=e.find(e=>e.name===t);if(n)return n}return e.find(e=>e.lang.startsWith(`en`))??e[0]}var Fi=class e{constructor(e={}){this.options=e,this.id=`browser`,this.supportsPause=!0}static isSupported(){return typeof window<`u`&&`speechSynthesis`in window}speak(t,n){if(!e.isSupported()){n.onError?.(/* @__PURE__ */ Error(`Web Speech API is unavailable`));return}let r=window.speechSynthesis;r.cancel();let i=new SpeechSynthesisUtterance(t.text),a=r.getVoices();if(t.voice){let e=a.find(e=>e.name===t.voice);e&&(i.voice=e)}else a.length>0&&(i.voice=this.options.pickVoice?this.options.pickVoice(a):Pi(a));t.rate!==void 0&&(i.rate=t.rate),t.pitch!==void 0&&(i.pitch=t.pitch),i.onend=()=>n.onEnd?.(),i.onerror=e=>{let t=e.error;t===`canceled`||t===`interrupted`?n.onEnd?.():n.onError?.(Error(t||`Speech synthesis failed`))},setTimeout(()=>{r.speak(i),n.onStart?.()},50)}pause(){e.isSupported()&&window.speechSynthesis.pause()}resume(){e.isSupported()&&window.speechSynthesis.resume()}stop(){e.isSupported()&&window.speechSynthesis.cancel()}},Ii=class{#e=null;#t=null;#n=`idle`;#r=/* @__PURE__ */ new Set;#i=0;#a;constructor(e){this.#a=e}get supportsPause(){return this.#e?.supportsPause??!0}stateFor(e){return this.#t===e?this.#n:`idle`}activeMessageId(){return this.#t}onChange(e){return this.#r.add(e),()=>this.#r.delete(e)}toggle(e,t){if(this.#t===e){if(this.#n===`playing`){this.#e?.supportsPause?(this.#e.pause(),this.#o(e,`paused`)):this.stop();return}if(this.#n===`paused`){this.#e?.resume(),this.#o(e,`playing`);return}if(this.#n===`loading`){this.stop();return}}this.play(e,t)}async play(e,t){let n=++this.#i;this.#e?.stop(),this.#o(e,`loading`);try{if(!this.#e){let e=await this.#a();if(n!==this.#i)return;if(!e){this.#o(null,`idle`);return}this.#e=e}this.#e.speak(t,{onStart:()=>{n===this.#i&&this.#o(e,`playing`)},onEnd:()=>{n===this.#i&&this.#o(null,`idle`)},onError:()=>{n===this.#i&&this.#o(null,`idle`)}})}catch{n===this.#i&&this.#o(null,`idle`)}}stop(){this.#i++,this.#e?.stop(),this.#o(null,`idle`)}destroy(){this.stop(),this.#e?.destroy?.(),this.#e=null,this.#r.clear()}#o(e,t){this.#t=t===`idle`?null:e,this.#n=t;for(let e of this.#r)e(this.#t,this.#n)}},Li=class{#e;#t=!1;start(e){this.#e=e,this.#t=!1}cancel(){this.#t=!0}accepts(e){return!this.#t&&(!e||!this.#e||e===this.#e)}};function Ri(e){if(!e)return``;let t=zi(e);return Bi(t===null?e:t)}function zi(e){let t=e.trim(),n=t.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/i);if(n&&(t=n[1].trim()),!t.startsWith(`{`))return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&typeof e.text==`string`)return e.text}catch{}return null}function Bi(e){if(!e)return``;let t=e;return t=t.replace(/```[\s\S]*?```/g,` `),t=t.replace(/~~~[\s\S]*?~~~/g,` `),t=t.replace(/`([^`]+)`/g,`$1`),t=t.replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`),t=t.replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`),t=t.replace(/\[([^\]]+)\]\[[^\]]*\]/g,`$1`),t=t.replace(/<\/?[a-zA-Z][^>]*>/g,` `),t=t.replace(/^[ \t]*#{1,6}[ \t]+/gm,``),t=t.replace(/^[ \t]*>[ \t]?/gm,``),t=t.replace(/^[ \t]*[-*+][ \t]+/gm,``),t=t.replace(/^[ \t]*\d+\.[ \t]+/gm,``),t=t.replace(/^[ \t]*([-*_])([ \t]*\1){2,}[ \t]*$/gm,` `),t=t.replace(/(\*\*|__)(.*?)\1/g,`$2`),t=t.replace(/(\*|_)(.*?)\1/g,`$2`),t=t.replace(/~~(.*?)~~/g,`$1`),t=t.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/ /g,` `),t=t.replace(/[ \t]+/g,` `),t=t.replace(/[ \t]*\n[ \t]*/g,`
|
|
4
4
|
`),t=t.replace(/\n{2,}/g,`
|
|
@@ -7,7 +7,7 @@ import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,n as l,o a
|
|
|
7
7
|
`),a=[i,t].filter(Boolean).join(`
|
|
8
8
|
|
|
9
9
|
`),o=Array.isArray(e.contentParts)&&e.contentParts.length>0,s=r.contentParts.length>0;if(o){let t=[];i&&t.push(kt(i)),t.push(...r.contentParts),t.push(...e.contentParts),e.contentParts=t}else if(s){let t=[];a&&t.push(kt(a)),t.push(...r.contentParts),e.contentParts=t}else i&&(e.llmContent=a);Object.keys(r.context).length>0&&(e.mentionContext=r.context)}async sendMessage(e,t){let n=e.trim(),r=!!t?.replayFields&&(t.replayFields.llmContent!==void 0||t.replayFields.rawContent!==void 0||(t.replayFields.contextMentions?.length??0)>0);if(!n&&(!t?.contentParts||t.contentParts.length===0)&&(!t?.mentions||t.mentions.refs.length===0)&&!r)return;this.#re&&!t?.voiceTurn&&(this.#re.failed=!0,this.#re=null),(this.#z||this.#V||this.#R||this.#J)&&await this.#Ue(),this.stopSpeaking(),this.client.cancelStreams(),this.abortController?.abort(),this.#i(),this.#rt(),this.#Qe++,this.#Tt();let i=t?.voiceTurn?.userMessageId,a=i?this.messages.find(e=>e.id===i&&e.role===`user`):void 0,o=a?.id??ut(),s=dt();this.#d=null;let c=t?.contentParts&&Mt(t.contentParts)?Nt:``,l={id:o,role:`user`,content:n||c,createdAt:(/* @__PURE__ */ new Date()).toISOString(),sequence:this.#It(),viaVoice:t?.viaVoice||!1,...t?.contentParts&&t.contentParts.length>0&&{contentParts:t.contentParts},...t?.mentions&&t.mentions.refs.length>0&&{contextMentions:t.mentions.refs},...t?.contentSegments&&t.contentSegments.length>0&&{contentSegments:t.contentSegments},...t?.composerOptions&&{composerOptions:t.composerOptions},...t?.replayFields??{}};a?(a.viaVoice=!0,delete a.voiceCaption,a.content.trim()!==n&&(a.llmContent=n),this.callbacks.onMessagesChanged([...this.messages])):this.#Pt(l),this.#kt(!0);let u=new AbortController;this.abortController=u;let d=this.#e;if(t?.mentions){let e=this.messages.find(e=>e.id===o)??l;if(await this.#Je(e,n,t.mentions.finalize),u.signal.aborted||this.abortController!==u)return;this.callbacks.onMessagesChanged([...this.messages])}if(t?.quote&&!t.replayFields){let e=this.messages.find(e=>e.id===o)??l,n=wi({quote:t.quote,text:e.llmContent??e.content,contentParts:e.contentParts});n.contentParts&&(e.contentParts=n.contentParts),n.llmContent!==void 0&&(e.llmContent=n.llmContent),(n.contentParts||n.llmContent!==void 0)&&(e.quote={...t.quote},this.callbacks.onMessagesChanged([...this.messages]))}let f=(/* @__PURE__ */ new Date()).toISOString(),p=a?[...this.messages.filter(e=>e!==a),{...a,createdAt:f}]:[...this.messages],m=(a??this.messages.find(e=>e.id===o))?.createdAt??f,h=xi(t?.voiceTurn?.priorToolResults,m);for(let e of h)this.messages.some(t=>t.id===e.id)||(this.#Pt(e),p.push({...e,createdAt:f}));let g=h.map(({agentMetadata:e})=>{let{toolCallId:t,toolName:n,args:r,result:i}=e.clientToolAnswer;return{toolCallId:t,name:n,arguments:r,result:i}});try{await this.#Ge(p,u,s,o,{composerOptions:t?.composerOptions,interrupt:t?.interrupt,voiceSpoken:!!t?.voiceTurn,...g.length>0&&{voicePriorToolResults:g}})}catch(e){if(this.#e!==d||this.status===`resuming`||this.#f)return;this.#re&&(this.#re.failed=!0);let t=e instanceof Error&&(e.name===`AbortError`||e.message.includes(`aborted`)||e.message.includes(`abort`));t||this.#At(e),this.#Ot(`idle`),this.#kt(!1),this.abortController=null,this.#a(t?`cancel`:`error`,d),t||(e instanceof Error?this.callbacks.onError?.(e):this.callbacks.onError?.(Error(String(e))))}}resubmitFrom(e,t){let n=Ei(this.messages,e);if(!n)return!1;let r=this.messages[n.start],i=t.replacement,a=i?i.text:r.content,o=i?i.contentParts:r.contentParts;if(!(a?.trim()||(o?.length??0)>0||!i&&(r.llmContent?.trim()?.length??0)>0))return!1;let s=i?void 0:{...r.llmContent!==void 0&&{llmContent:r.llmContent},...r.rawContent!==void 0&&{rawContent:r.rawContent},...r.mentionContext&&{mentionContext:r.mentionContext},...r.contextMentions&&{contextMentions:r.contextMentions},...r.quote&&{quote:r.quote}},c=i?this.#Ye(i.options):r.composerOptions,l=i?i.contentSegments:r.contentSegments,u=i?i.options?.quote:void 0,d=i?i.viaVoice:r.viaVoice;return this.cancel(),this.messages=this.messages.slice(0,n.start),this.sendMessage(a??``,{...o?.length?{contentParts:[...o]}:{},...l?.length?{contentSegments:[...l]}:{},...c?{composerOptions:c}:{},...u?{quote:u}:{},...s&&Object.keys(s).length>0?{replayFields:s}:{},viaVoice:d===!0}),!0}#Ye(e){if(!e)return;let t={};return e.selectedModelId&&(t.selectedModelId=e.selectedModelId),e.activeModeIds?.length&&(t.activeModeIds=[...e.activeModeIds]),Object.keys(t).length>0?t:void 0}async continueConversation(){if(this.streaming)return;(this.#z||this.#V||this.#R||this.#J)&&await this.#Ue(),this.abortController?.abort(),this.#Tt(),this.#i();let e=dt();this.#d=null,this.#kt(!0);let t=new AbortController;this.abortController=t;let n=this.#e,r=[...this.messages];try{await this.client.dispatch({messages:r,signal:t.signal,assistantMessageId:e},e=>{this.#e===n&&this.handleEvent(e)})}catch(e){if(this.#e!==n||this.status===`resuming`||this.#f)return;let t=e instanceof Error&&(e.name===`AbortError`||e.message.includes(`aborted`)||e.message.includes(`abort`));t||this.#At(e),this.#a(t?`cancel`:`error`,n),this.#Ot(`idle`),this.#kt(!1),this.abortController=null,t||(e instanceof Error?this.callbacks.onError?.(e):this.callbacks.onError?.(Error(String(e))))}}async connectStream(e,t){if(this.streaming&&!t?.allowReentry)return;this.#e||this.#i(),t?.allowReentry||this.abortController?.abort(),t?.preserveAssistantId&&t.assistantMessageId&&(this.#d=t.assistantMessageId);let n=t?.preserveAssistantId?t.assistantMessageId:void 0,r=!1;for(let e of this.messages)e.streaming&&e.id!==n&&(e.streaming=!1,r=!0);r&&this.callbacks.onMessagesChanged([...this.messages]),this.#kt(!0);let i=this.#e,a={};try{await this.client.processStream(e,e=>{if(this.#e!==i)return;let n=this.#c;this.#c=a;try{this.handleEvent(e,t?.readOnlyReplay)}finally{this.#c=n}},t?.assistantMessageId,t?.seedContent,this.abortController?.signal,t?.readOnlyReplay?this.messages:void 0,t?.readOnlyReplay?this.#p:void 0),this.#jt(a)}catch(e){if(this.#e!==i)return;if(this.status===`resuming`||this.#f){this.#Mt(a);return}this.#jt(a),this.#Ot(`error`),this.webMcpResolveControllers.size===0&&(this.#kt(!1),this.abortController=null),this.callbacks.onError?.(e instanceof Error?e:Error(String(e)))}}#Xe(){let e=this.config.webmcp;e?.enabled===!0&&!e.onConfirm&&this.client.setWebMcpConfirmHandler(e=>this.requestWebMcpApproval(e))}requestWebMcpApproval(e){try{if(this.config.webmcp?.autoApprove?.(e)===!0)return Promise.resolve(!0)}catch{}if(e.signal?.aborted)return Promise.resolve(!1);let t;do t=`webmcp-${++this.#S}`;while(this.messages.some(e=>e.id===`approval-${t}`||e.approval?.id===t));let n={id:t,status:`pending`,agentId:``,executionId:``,toolName:e.toolName,...e.toolCallId?{toolCallId:e.toolCallId}:{},toolType:`webmcp`,description:e.description??`Allow the assistant to run ${e.toolName}?`,parameters:e.args},r=`approval-${n.id}`;return this.upsertMessage({id:r,role:`assistant`,content:``,createdAt:(/* @__PURE__ */ new Date()).toISOString(),streaming:!1,variant:`approval`,approval:n}),new Promise(t=>{this.webMcpApprovalResolvers.set(r,t),e.signal?.addEventListener(`abort`,()=>this.resolveWebMcpApproval(r,`timeout`),{once:!0})})}resolveWebMcpApproval(e,t){let n=this.webMcpApprovalResolvers.get(e);if(!n)return;this.webMcpApprovalResolvers.delete(e);let r=this.messages.find(t=>t.id===e);r?.approval&&this.upsertMessage({...r,approval:{...r.approval,status:t,resolvedAt:Date.now()}}),n(t===`approved`)}#Ze;#Qe;#$e(e){let t=this.#Ze??={s:this,setStreaming:e=>this.#kt(e),appendMessage:e=>this.#Pt(e),nextSequence:()=>this.#It(),settleApprovalPausedToolCall:e=>this.#Nt(e),resumeAfter:e=>this.#u?.executionId===e?this.#u.lastEventId:void 0},n=yi();if(n)return e(n,t);let r=this.#Qe;return K().then(n=>r===this.#Qe?e(n,t):void 0,e=>{this.callbacks.onError?.(e instanceof Error?e:Error(String(e)))})}resolveApproval(e,t,n){return this.#$e((r,i)=>r.resolveApproval(i,e,t,n))}resolveAskUserQuestion(e,t){return this.#$e((n,r)=>n.resolveAskUserQuestion(r,e,t))}resolveWebMcpToolCall(e){return this.#$e((t,n)=>t.resolveWebMcpToolCall(n,e))}persistAskUserQuestionProgress(e,t){let n=this.messages.find(t=>t.id===e.id);n&&this.upsertMessage({...n,agentMetadata:{...n.agentMetadata,askUserQuestionAnswers:t.answers,askUserQuestionIndex:t.currentIndex}})}markAskUserQuestionResolved(e,t){let n=this.messages.find(t=>t.id===e.id);n&&this.upsertMessage({...n,agentMetadata:{...n.agentMetadata,awaitingLocalTool:!1,askUserQuestionAnswered:!0,...t?{askUserQuestionAnswers:t}:{}}})}#et(e){let t=e.agentMetadata?.executionId,n=e.toolCall?.id;if(!t||!n){let t=this.#x;queueMicrotask(()=>{t===this.#x&&this.resolveWebMcpToolCall(e)});return}let r=this.webMcpAwaitBatches.get(t);r||(r={snapshots:[],seen:/* @__PURE__ */ new Set},this.webMcpAwaitBatches.set(t,r)),!r.seen.has(n)&&(r.seen.add(n),r.snapshots.push(e))}#tt(){if(this.webMcpAwaitBatches.size===0)return;let e=this.#x;queueMicrotask(()=>{if(e===this.#x)for(let e of[...this.webMcpAwaitBatches.keys()])this.#nt(e)})}#nt(e){let t=this.webMcpAwaitBatches.get(e);if(!t)return;this.webMcpAwaitBatches.delete(e);let{snapshots:n}=t;n.length===1?this.resolveWebMcpToolCall(n[0]):n.length>1&&this.#$e((t,r)=>t.resolveWebMcpToolCallBatch(r,e,n))}#rt(){for(let e of this.webMcpResolveControllers)e.abort();this.webMcpResolveControllers.clear();for(let e of[...this.webMcpApprovalResolvers.keys()])this.resolveWebMcpApproval(e,`denied`);this.webMcpAwaitBatches.clear(),this.#x++}cancel(){this.client.cancelStreams(),this.abortController?.abort(),this.abortController=null,this.#Tt(),this.#rt(),this.#Qe++,this.webMcpInflightKeys.clear(),this.stopSpeaking(),this.stopVoicePlayback(),this.#kt(!1),this.#Ot(`idle`),this.#a(`cancel`)}clearMessages(){this.client.cancelStreams(),this.#ut(),this.stopSpeaking(),this.abortController?.abort(),this.abortController=null,this.#Tt(),this.#rt(),this.#Qe++,this.#t=void 0,this.messages=[],this.agentExecution=null,this.#ot(),this.webMcpInflightKeys.clear(),this.webMcpResolvedKeys.clear(),this.client.resetClientToolsFingerprint(),this.#kt(!1),this.#Ot(`idle`),this.callbacks.onMessagesChanged([...this.messages]),this.#a(`cancel`)}getArtifacts(){return[...this.artifacts.values()]}getArtifactById(e){return this.artifacts.get(e)}getSelectedArtifactId(){return this.#b}selectArtifact(e){this.#b=e,this.#st()}clearArtifacts(){this.#ot()}upsertArtifact(e){let t=e.id||`art_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,9)}`,n=e.artifactType===`markdown`?{id:t,artifactType:`markdown`,title:e.title,status:`complete`,markdown:e.content,...e.file?{file:e.file}:{},...e.presentation?{presentation:e.presentation}:{}}:{id:t,artifactType:`component`,title:e.title,status:`complete`,component:e.component,props:e.props??{},...e.presentation?{presentation:e.presentation}:{}};return this.artifacts.set(t,n),this.#b=t,this.#st(),e.transcript!==!1&&this.#it(n),n}#it(e){let t=`artifact-ref-${e.id}`,n=xt(this.config.features?.artifacts,e),r=Ct(n,{artifactId:e.id,title:e.title,artifactType:e.artifactType,status:`complete`,...e.file?{file:e.file}:{},...e.presentation?{presentation:e.presentation}:{},...e.component?{component:e.component}:{},...e.props?{componentProps:e.props}:{},...e.markdown===void 0?{}:{markdown:e.markdown}}),i=this.messages.find(e=>e.id===t);i?(i.rawContent=r,i.streaming=!1,this.callbacks.onMessagesChanged([...this.messages])):this.injectAssistantMessage({id:t,content:``,rawContent:r})}#at(){let e=!1;for(let t of this.artifacts.values()){let n=this.messages.find(e=>e.id===`artifact-ref-${t.id}`);if(!n)continue;let r=xt(this.config.features?.artifacts,t),i=Ct(r,{artifactId:t.id,title:t.title,artifactType:t.artifactType,status:t.status,...t.file?{file:t.file}:{},...t.presentation?{presentation:t.presentation}:{},...t.component?{component:t.component}:{},...t.props?{componentProps:t.props}:{},...t.markdown===void 0?{}:{markdown:t.markdown}});n.rawContent!==i&&(n.rawContent=i,n.streaming=t.status===`streaming`,e=!0)}e&&this.callbacks.onMessagesChanged([...this.messages])}#ot(){(this.artifacts.size!==0||this.#b!==null)&&(this.artifacts.clear(),this.#b=null,this.#st())}#st(){this.callbacks.onArtifactsState?.({artifacts:[...this.artifacts.values()],selectedId:this.#b})}#ct(e){switch(e.type){case`artifact_start`:e.artifactType===`markdown`?this.artifacts.set(e.id,{id:e.id,artifactType:`markdown`,title:e.title,status:`streaming`,markdown:``,...e.file?{file:e.file}:{}}):this.artifacts.set(e.id,{id:e.id,artifactType:`component`,title:e.title,status:`streaming`,component:e.component??``,props:{}}),this.#b=e.id;break;case`artifact_delta`:{let t=this.artifacts.get(e.id);t?.artifactType===`markdown`&&(t.markdown=(t.markdown??``)+e.artDelta);break}case`artifact_update`:{let t=this.artifacts.get(e.id);t?.artifactType===`component`&&(t.props={...t.props,...e.props},e.component&&(t.component=e.component));break}case`artifact_complete`:{let t=this.artifacts.get(e.id);t&&(t.status=`complete`);break}default:return}this.#st()}hydrateMessages(e){this.client.cancelStreams(),this.abortController?.abort(),this.abortController=null,this.#Tt(),this.#rt(),this.#Qe++,this.webMcpInflightKeys.clear(),this.webMcpResolvedKeys.clear(),this.#t=void 0,this.messages=this.#Rt(e.map(e=>({...A(e),streaming:!1,sequence:e.sequence??this.#It()}))),this.#kt(!1),this.#Ot(`idle`),this.callbacks.onMessagesChanged([...this.messages]),this.#a(`cancel`)}hydrateArtifacts(e,t=null,n=!1){this.artifacts.clear();for(let t of e)this.artifacts.set(t.id,{...t,status:n?t.status:`complete`});this.#b=t,this.#st()}assertBackgroundSwitchable(){let e=this.config.backgroundConversations;if(e?.capabilities?.durableExecution!==!0||e.capabilities?.readOnlyReplay!==!0||typeof e.reconnectStream!=`function`)throw new qi(`background_unavailable`,`This backend does not support background conversations`);if(this.config.parseSSEEvent)throw new qi(`background_unavailable`,`Background replay requires the native event parser`);if(this.#_t()||this.webMcpResolveControllers.size||this.webMcpAwaitBatches.size||(this.streaming||this.#f)&&(!this.#u||!this.#k))throw new qi(`conversation_busy`,`This turn cannot safely continue in the background`)}async#lt(){if(this.#h)return;let e=this.config.backgroundConversations,t=this.#N,{BackgroundConversationController:n}=await gi();if(t!==this.#N||e!==this.config.backgroundConversations)throw new qi(`superseded`,`The history identity changed`);if(this.#h)return;this.#h=new n(e,e=>{this.#ft(e)});let r=!0;this.#g=this.#de?.subscribeIdentityStatus(()=>{r||(this.#h?.clear(),this.cancel())})??null,r=!1}#ut(){this.#h?.clear(),this.#h=null,this.#g?.(),this.#g=null}#dt(e){let t=this.#u?.executionId??this.agentExecution?.executionId,n=this.#k;if(!this.config.backgroundConversations||!t||!n)return;let r={conversationId:n,executionId:t,status:e,detached:!1};this.#ft(r)}#ft(e){try{this.config.onConversationExecutionState?.(e)}catch{}try{this.callbacks.onConversationExecutionState?.(e)}catch{}}#pt(){let e=this.config.backgroundConversations,t=this.#k;return e&&t?n=>e.reconnectStream({...n,conversationId:t}):this.config.reconnectStream}#mt(e){this.#i(e.handle.executionId),this.#d=e.handle.assistantMessageId;let t=this.messages.find(e=>e.id===this.#d);t&&(t.streaming=e.streamCheckpoint?.openAssistant??!0),this.#p=e.streamCheckpoint,this.agentExecution={executionId:e.handle.executionId,agentId:``,agentName:``,status:`running`,currentIteration:0,maxTurns:0},this.#u=e.handle,this.#Dt(!0),this.#dt(e.observedStatus??`running`),this.#vt()}#ht(e){let t=this.agentExecution?.executionId;if(!t||!this.#d||this.agentExecution?.status!==`running`)return;let n=this.#u===null;this.#u={executionId:t,lastEventId:e,assistantMessageId:this.#d,status:`running`},this.#Dt(n),n&&this.#dt(`running`)}#gt(){return this.#u!==null&&typeof this.#pt()==`function`&&this.abortController?.signal.aborted!==!0&&this.webMcpResolveControllers.size===0&&this.webMcpAwaitBatches.size===0&&!this.#_t()}#_t(){return this.messages.some(e=>e.agentMetadata?.awaitingLocalTool===!0&&e.agentMetadata?.askUserQuestionAnswered!==!0||e.variant===`approval`&&e.approval?.status===`pending`)}#vt(){this.#f||this.#u&&typeof this.#pt()==`function`&&(this.#f=!0,this.callbacks.onReconnect?.({phase:`paused`,handle:this.#u}),this.#kt(!0),this.#Ot(`resuming`),this.#yt().then(e=>{this.#f&&this.#u&&e.begin()}))}#yt(){return this.#_?Promise.resolve(this.#_):(this.#v||(this.#v=Wi().then(({createReconnectController:e})=>{let t=e(this.#bt());return this.#_=t,t}),this.#v.catch(()=>{this.#v=null})),this.#v)}#bt(){let e=this;return{get config(){return{...e.config,reconnectStream:e.#pt()}},getResumable:()=>e.#u,clearResumable:()=>e.#Et(),getStatus:()=>e.status,setStatus:t=>e.#Ot(t),setStreaming:t=>e.#kt(t),setReconnecting:t=>{e.#f=t},setAbortController:t=>{e.abortController=t},getMessages:()=>e.messages,isAwaitPending:()=>e.#_t(),notifyMessagesChanged:()=>e.callbacks.onMessagesChanged([...e.messages]),resumeConnect:(t,n,r)=>e.connectStream(t,{assistantMessageId:n,allowReentry:!0,preserveAssistantId:!0,seedContent:r,readOnlyReplay:!!e.config.backgroundConversations}),appendMessage:t=>e.#Pt(t),settleParked:t=>e.#xt(t),nextSequence:()=>e.#It(),emitReconnect:t=>e.callbacks.onReconnect?.(t),buildErrorContent:t=>Ji(Error(t),e.config.errorMessage),onError:t=>e.callbacks.onError?.(t)}}reconnectNow(){this.#f?this.#_?.wake():this.#vt()}resumeFromHandle(e){if(typeof this.config.reconnectStream!=`function`||this.#f)return;if(this.#i(e.executionId),this.#_t()){this.#St(e.executionId),this.#u={executionId:e.executionId,lastEventId:e.after,assistantMessageId:this.#d??``,status:`running`};return}let t=this.#Ct(e.executionId)?dt():this.#wt();t||(t=dt(),this.#Pt({id:t,role:`assistant`,content:``,createdAt:(/* @__PURE__ */ new Date()).toISOString(),streaming:!0,sequence:this.#It()})),this.#d=t,this.#St(e.executionId),this.#u={executionId:e.executionId,lastEventId:e.after,assistantMessageId:t,status:`running`},this.#vt()}#xt(e){let t=this.webMcpResolveControllers.size>0||this.webMcpAwaitBatches.size>0;if(!t&&!this.#_t()){if(!this.#Ct(e))return!1;this.#Et()}if(this.#f=!1,!t){let e=!1;for(let t of this.messages)t.streaming&&(t.streaming=!1,e=!0);e&&this.callbacks.onMessagesChanged([...this.messages]),this.#kt(!1),this.abortController=null}return this.#Ot(`idle`),!0}#St(e){this.agentExecution||={executionId:e,agentId:``,agentName:``,status:`running`,currentIteration:0,maxTurns:0}}#Ct(e){return this.messages.some(t=>t.agentMetadata?.executionId===e&&[t.toolCall,...t.tools??[]].some(e=>e?.interrupted===!0))}#wt(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(t.role===`assistant`&&!t.variant)return t.streaming=!0,this.callbacks.onMessagesChanged([...this.messages]),t.id;if(t.role===`user`)break}return null}#Tt(){this.#f=!1,this.#_?.teardown(),this.#Et()}#Et(){this.#y&&=(clearTimeout(this.#y),null);let e=this.#u!==null;this.#u=null,this.#p=void 0,e&&this.config.onExecutionState?.(null)}#Dt(e){let t=this.config.onExecutionState;t&&(e?(this.#y&&=(clearTimeout(this.#y),null),t(this.#u)):this.#y||=setTimeout(()=>{this.#y=null,this.config.onExecutionState?.(this.#u)},500))}getResumableHandle(){return this.#u}#Ot(e){e===`error`&&(this.#n=!0,this.#o()),this.status!==e&&(this.status=e,this.callbacks.onStatusChanged(e))}#kt(e){if(e||this.#o(),this.streaming===e)return;let t=this.streaming;this.streaming=e,this.callbacks.onStreamingChanged(e),t&&!e&&(this.#jt(void 0),this.speakLatestAssistantMessage())}speakLatestAssistantMessage(e){let t=this.config.textToSpeech;if(!t?.enabled||!(!t.provider||t.provider===`browser`||t.provider===`runtype`&&t.browserFallback))return;let n=[...this.messages].reverse().find(e=>e.role===`assistant`&&e.content&&!e.voiceProcessing);if(!n||e&&!e.includes(n.id))return;if(this.ttsSpokenMessageIds.has(n.id)){this.ttsSpokenMessageIds.delete(n.id);return}let r=Ri(n.content);r.trim()&&this.readAloud.play(n.id,{text:r,voice:t.voice,rate:t.rate,pitch:t.pitch})}static pickBestVoice(e){return Pi(e)}toggleReadAloud(e){let t=this.messages.find(t=>t.id===e);if(!t||t.role!==`assistant`)return;let n=Ri(t.content||``);if(!n.trim())return;let r=this.config.textToSpeech;this.readAloud.toggle(e,{text:n,voice:r?.voice,rate:r?.rate,pitch:r?.pitch})}getReadAloudState(e){return this.readAloud.stateFor(e)}onReadAloudChange(e){return this.readAloud.onChange(e)}stopSpeaking(){this.readAloud.stop(),typeof window<`u`&&`speechSynthesis`in window&&window.speechSynthesis.cancel()}#At(e){for(let e of this.messages)e.streaming=!1;let t=Ji(e,this.config.errorMessage);t?this.#Pt({id:dt(),role:`assistant`,content:t,dispatchError:!0,localOnly:!0,createdAt:(/* @__PURE__ */ new Date()).toISOString(),sequence:this.#It()}):this.callbacks.onMessagesChanged([...this.messages])}#jt(e){for(let[t,n]of[...this.#s])n===e&&(this.#s.delete(t),this.#Nt(t))}#Mt(e){for(let[t,n]of this.#s)n===e&&this.#s.set(t,void 0)}#Nt(e){let t=this.messages.find(t=>t.id===e)?.approval,n=t?.toolCallId,r=n&&this.messages.find(e=>e.toolCall?.id===n),i=r&&r.toolCall;if(!i||i.status===`complete`||t.status===`pending`)return;let a={...i,status:`complete`,approvalStatus:t.status,completedAt:Date.now(),...t.status===`approved`?{superseded:!0}:{success:!1,error:t.status===`denied`?`Denied`:`Approval timed out`}};this.upsertMessage({...r,streaming:!1,toolCall:a})}#Pt(e){let t=this.#Ft(e),n=this.messages[this.messages.length-1];this.messages=!n||this.#Lt(n,t)<=0?[...this.messages,t]:this.#Rt([...this.messages,t]),this.callbacks.onMessagesChanged([...this.messages])}upsertMessage(e){let t=this.#Ft(e),n=this.messages.findIndex(e=>e.id===t.id);if(n===-1){this.#Pt(t);return}this.messages=this.messages.map((e,r)=>{if(r!==n||e.toolCall?.name&&it(e.toolCall.name)&&e.toolCall.status===`complete`&&t.toolCall?.id===e.toolCall.id&&t.toolCall.status!==`complete`&&(t.toolCall.status===`pending`&&!t.toolCall.name||!e.toolCall.interrupted&&(e.toolCall.result!==void 0||e.toolCall.success!==void 0)&&(!t.agentMetadata?.executionId||t.agentMetadata.executionId===e.agentMetadata?.executionId)))return e;let i={...e,...t};e.agentMetadata?.askUserQuestionAnswered===!0&&t.agentMetadata&&(i.agentMetadata={...t.agentMetadata,askUserQuestionAnswered:!0,...e.agentMetadata.askUserQuestionAnswers?{askUserQuestionAnswers:e.agentMetadata.askUserQuestionAnswers}:{},awaitingLocalTool:!1}),e.agentMetadata?.suggestRepliesResolved===!0&&t.agentMetadata&&(i.agentMetadata={...i.agentMetadata??t.agentMetadata,suggestRepliesResolved:!0,awaitingLocalTool:!1});let a=e.agentMetadata?.clientToolAnswer;if(a&&i.agentMetadata&&!i.agentMetadata.clientToolAnswer&&(i.agentMetadata={...i.agentMetadata,clientToolAnswer:a}),e.approval&&t.approval&&e.approval.id===t.approval.id){let n=e.approval,r=t.approval;i.approval={...n,...r,executionId:r.executionId||n.executionId,toolCallId:r.toolCallId||n.toolCallId,toolName:r.toolName||n.toolName,description:r.description||n.description,toolType:r.toolType??n.toolType,reason:r.reason??n.reason,parameters:r.parameters??n.parameters}}let o=t.toolCall?.name,s=t.agentMetadata?.executionId,c=t.toolCall?.id;if(o&&Yi(o)&&s&&c&&t.agentMetadata?.awaitingLocalTool===!0){let t=`${s}:${c}`,n=this.webMcpInflightKeys.has(t),r=this.webMcpResolvedKeys.has(t),a=e.toolCall?.name,o=e.agentMetadata?.executionId===s&&e.toolCall?.id===c&&a!==void 0&&Yi(a)&&e.toolCall?.status===`complete`&&!e.toolCall.interrupted;(n||r||o)&&(i.agentMetadata={...i.agentMetadata??{},awaitingLocalTool:!1},i.toolCall=e.toolCall,i.streaming=e.streaming)}return i});let r=this.messages[n],i=this.messages[n-1],a=this.messages[n+1];(i&&this.#Lt(i,r)>0||a&&this.#Lt(r,a)>0)&&(this.messages=this.#Rt(this.messages)),this.callbacks.onMessagesChanged([...this.messages])}#Ft(e){return e.sequence===void 0?{...e,sequence:this.#It()}:{...e}}#It(){return this.#l++}#Lt(e,t){let n=new Date(e.createdAt).getTime(),r=new Date(t.createdAt).getTime();if(!Number.isNaN(n)&&!Number.isNaN(r)&&n!==r)return n-r;let i=e.sequence??0,a=t.sequence??0;return i===a?e.id.localeCompare(t.id):i-a}#Rt(e){return[...e].sort((e,t)=>this.#Lt(e,t))}};function Zi(e){let t=k(`div`,`persona-attachment-preview persona-relative persona-inline-block`),n=e,r=``,i=()=>{let{state:e}=n,r=n.config.attachments?.preview,i=e.kind===`image`,a=i?r?.image:r?.file,o=i?r?.image?.layout??`thumbnail`:r?.file?.layout??`tile`;if(t.dataset.kind=e.kind,t.dataset.layout=o,t.dataset.fileIcon=String(r?.file?.icon!==!1),t.dataset.iconPlacement=r?.file?.iconPlacement??`start`,t.dataset.removeVisibility=a?.remove?.visibility??`always`,t.dataset.removePlacement=a?.remove?.placement??`overlap`,t.replaceChildren(),i&&e.previewUrl){let n=O(`img`,{className:`persona-attachment-image`,attrs:{src:e.previewUrl,alt:e.name},style:{objectFit:r?.image?.fit??`cover`}}),i=r?.image?.name??`hidden`;if(o===`chip`||i!==`hidden`){let r=k(`div`,`persona-attachment-image-card`);r.append(n),i!==`hidden`&&r.append(O(`span`,{className:`persona-attachment-file-name`,text:i===`basename`?e.name.replace(/\.[^.]+$/,``):e.name})),t.append(r)}else t.append(n)}else{let n=k(`div`,`persona-attachment-file`),i=e.mimeType,a=i.includes(`spreadsheet`)||i.includes(`excel`)?wn:i===`application/json`?Cn:i===`application/pdf`||i.startsWith(`text/`)||i.includes(`word`)?Tn:Sn,o=(r?.file?.iconName?T(r.file.iconName,20,`currentColor`,1.5):null)??b(a,20,`currentColor`,1.5);o&&r?.file?.icon!==!1&&(o.classList.add(`persona-attachment-file-icon`),n.append(o));let s=k(`div`,`persona-attachment-file-copy`),c=r?.file?.name??`hidden`;c!==`hidden`&&s.append(O(`span`,{className:`persona-attachment-file-name`,text:c===`basename`?e.name.replace(/\.[^.]+$/,``):e.name}));let l=r?.file?.metadata,u=l===`size`?e.size<1024?`${e.size} B`:e.size<1048576?`${Math.round(e.size/1024)} KB`:`${(e.size/1048576).toFixed(1)} MB`:l===`line-count`&&e.lineCount!==void 0?`${e.lineCount} ${e.lineCount===1?`line`:`lines`}`:``;u&&s.append(O(`span`,{className:`persona-attachment-file-metadata`,text:u})),s.childNodes.length&&n.append(s);let d=r?.file?.badge??`type`;d!==`none`&&n.append(O(`span`,{className:`persona-attachment-file-badge`,text:d===`extension`?e.name.match(/\.([^.]+)$/)?.[1].toUpperCase()??At(i,e.name):At(i,e.name)})),t.append(n)}let s=O(`div`,{className:`persona-attachment-status`,attrs:{"data-persona-attachment-status":``}}),c=k(`div`,`persona-attachment-progress`);c.append(k(`div`,`persona-attachment-progress__bar`));let l=O(`button`,{className:`persona-attachment-retry`,attrs:{type:`button`,"aria-label":`Retry upload`}}),u=T(`rotate-cw`,12,`#ffffff`,2);u?l.append(u):l.textContent=`↻`,l.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),n.actions.retry()}),s.append(c,l);let d=O(`button`,{className:`persona-attachment-remove`,attrs:{type:`button`,"aria-label":`Remove attachment`}}),f=b(Dn,10,`currentColor`,2);f?d.append(f):d.textContent=`×`,d.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),n.actions.remove()}),t.append(s),((a?.remove?.placement===`inline`?t.querySelector(`.persona-attachment-file, .persona-attachment-image-card`):null)??t).append(d)},a=e=>{n=e;let{state:a}=n,o=JSON.stringify([n.config.attachments?.preview,a.lineCount,a.previewUrl]);r!==o&&(r=o,i()),t.dataset.status=a.status,t.setAttribute(`aria-busy`,String(a.status===`uploading`||a.status===`processing`)),t.title=a.status===`error`?`${a.name}: ${a.error??`Upload failed`}`:a.name;let s=t.querySelector(`.persona-attachment-progress__bar`);s&&(s.style.width=typeof a.progress==`number`?`${Math.round(a.progress*100)}%`:``)};return a(e),{element:t,update:a}}const Qi={add:e=>Pt(e)},q=e=>Number.isFinite(e)?Math.min(1,Math.max(0,e)):0,$i={allowedTypes:Ft,maxFileSize:10485760,maxFiles:4};function ea(){return`attach_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}var ta=class e{#e=[];#t;#n=/* @__PURE__ */ new Set;#r=/* @__PURE__ */ new Map;#i=null;#a=/* @__PURE__ */ new Map;#o=/* @__PURE__ */ new WeakMap;#s=!1;#c=!1;constructor(e={}){this.#t={allowedTypes:e.allowedTypes??$i.allowedTypes,maxFileSize:e.maxFileSize??$i.maxFileSize,maxFiles:e.maxFiles??$i.maxFiles,onFileRejected:e.onFileRejected,onAttachmentsChange:e.onAttachmentsChange,preview:e.preview,widgetConfig:e.widgetConfig,instanceId:e.instanceId,renderAttachmentPreview:e.renderAttachmentPreview,adapter:e.adapter}}#l(){return typeof this.#t.adapter?.add==`function`}#u(){return this.#l()?this.#t.adapter:Qi}setPreviewsContainer(e){this.#i!==e&&this.#y(),this.#i=e}remountPreviews(e){if(this.#y(),this.#i=e,e){e.innerHTML=``;for(let e of this.#e)this.#g(e)}this.#x()}updateConfig(e){if(`allowedTypes`in e&&(this.#t.allowedTypes=e.allowedTypes?.length?e.allowedTypes:$i.allowedTypes),`maxFileSize`in e&&(this.#t.maxFileSize=e.maxFileSize??$i.maxFileSize),`maxFiles`in e&&(this.#t.maxFiles=e.maxFiles??$i.maxFiles),`onFileRejected`in e&&(this.#t.onFileRejected=e.onFileRejected),e.onAttachmentsChange!==void 0&&(this.#t.onAttachmentsChange=e.onAttachmentsChange),`adapter`in e&&(this.#t.adapter=e.adapter),`preview`in e&&(this.#t.preview=e.preview),`widgetConfig`in e&&(this.#t.widgetConfig=e.widgetConfig),`instanceId`in e&&(this.#t.instanceId=e.instanceId),`renderAttachmentPreview`in e&&e.renderAttachmentPreview!==this.#t.renderAttachmentPreview)this.#t.renderAttachmentPreview=e.renderAttachmentPreview,this.remountPreviews(this.#i);else for(let e of this.#e)this.#_(e),this.#b(e)}isReady(){return this.#e.every(e=>e.status===`ready`)}getAttachments(){return[...this.#e]}getContentParts(){return this.#e.map(e=>e.contentPart).filter(e=>e!==null)}hasAttachments(){return this.#e.length>0}count(){return this.#e.length}async handleFileSelect(e){e&&e.length!==0&&await this.handleFiles(Array.from(e))}async handleFiles(e){if(!e.length||this.#s)return;let t=[];for(let n of e){if(this.#e.length>=this.#t.maxFiles){this.#t.onFileRejected?.(n,`count`);continue}let e=jt(n,this.#t.allowedTypes,this.#t.maxFileSize);if(!e.valid){let t=e.error?.includes(`type`)?`type`:`size`;this.#t.onFileRejected?.(n,t);continue}let r={id:ea(),file:n,previewUrl:It(n)?URL.createObjectURL(n):null,contentPart:null,status:this.#l()?`uploading`:`processing`,progress:this.#l()?0:void 0};this.#e.push(r),this.#g(r),t.push(r),this.#b(r)}this.#x(),this.#m(),await Promise.all(t.map(e=>this.#d(e)))}async#d(e){let t=new AbortController;this.#a.set(e.id,t);let n=this.#u(),r=()=>this.#s||t.signal.aborted||this.#a.get(e.id)!==t||!this.#e.includes(e);try{let i=await n.add(e.file,{signal:t.signal,onProgress:t=>{r()||e.status!==`uploading`||(e.progress=q(t),this.#_(e),this.#m())}});if(r()){this.#s&&this.#c&&this.#p(i,n);return}this.#o.set(e,n),e.contentPart=i,e.status=`ready`,e.progress=void 0,e.error=void 0}catch(t){if(r())return;e.status=`error`,e.progress=void 0,e.error=t instanceof Error?t.message:String(t??`Upload failed`)}finally{this.#a.get(e.id)===t&&this.#a.delete(e.id)}this.#_(e),this.#m()}retryAttachment(e){let t=this.#e.find(t=>t.id===e);!t||t.status!==`error`||this.#s||(t.status=this.#l()?`uploading`:`processing`,t.progress=this.#l()?0:void 0,t.error=void 0,this.#_(t),this.#m(),this.#d(t))}#f(e){let t=this.#a.get(e);t&&(this.#a.delete(e),t.abort())}removeAttachment(e){let t=this.#e.findIndex(t=>t.id===e);if(t===-1)return;let n=this.#e[t];this.#f(e),n.previewUrl&&URL.revokeObjectURL(n.previewUrl),this.#e.splice(t,1),this.#v(e),this.#n.delete(e);let r=this.#i?.querySelector(`[data-attachment-id="${e}"]`);r&&r.remove(),n.status===`ready`&&n.contentPart&&this.#p(n.contentPart,this.#o.get(n)),this.#x(),this.#m()}async#p(e,t){try{await t?.remove?.(e,{signal:new AbortController().signal})}catch(e){console.error(`[AttachmentManager] adapter.remove failed:`,e)}}clearAttachments(){this.#y(),this.#n.clear();for(let e of this.#e)this.#f(e.id),e.previewUrl&&URL.revokeObjectURL(e.previewUrl);this.#e=[],this.#a.clear(),this.#i&&(this.#i.innerHTML=``),this.#x(),this.#m()}destroy(e){if(!this.#s){this.#s=!0,this.#y(),this.#c=e?.release===!0;for(let e of this.#a.values())e.abort();this.#a.clear();for(let e of this.#e)e.previewUrl&&URL.revokeObjectURL(e.previewUrl),this.#c&&e.status===`ready`&&e.contentPart&&this.#p(e.contentPart,this.#o.get(e));this.#e=[],this.#i=null}}#m(){this.#s||this.#t.onAttachmentsChange?.(this.getAttachments())}#h(e){let t={instanceId:this.#t.instanceId??``,state:Object.freeze({id:e.id,name:e.file.name,mimeType:e.file.type,size:e.file.size,status:e.status,progress:e.progress,error:e.error,lineCount:e.lineCount,kind:It(e.file)?`image`:`file`,previewUrl:e.previewUrl}),config:{...this.#t.widgetConfig,attachments:{...this.#t.widgetConfig?.attachments,preview:this.#t.preview}},actions:{remove:()=>this.removeAttachment(e.id),retry:()=>this.retryAttachment(e.id)},defaultRenderer:()=>Zi(t)};return t}#g(e){if(!this.#i)return;let t=this.#h(e),n=null;try{n=this.#t.renderAttachmentPreview?.(t)??null}catch(e){console.error(`[AttachmentManager] preview renderer failed:`,e)}n??=t.defaultRenderer();let r=n instanceof HTMLElement?{element:n}:n;r.element.dataset.attachmentId=e.id,this.#r.set(e.id,r),this.#i.appendChild(r.element)}#_(e){try{this.#r.get(e.id)?.update?.(this.#h(e))}catch(e){console.error(`[AttachmentManager] preview update failed:`,e)}}#v(e){let t=this.#r.get(e);if(t){this.#r.delete(e);try{t.destroy?.()}catch(e){console.error(`[AttachmentManager] preview cleanup failed:`,e)}finally{t.element.remove()}}}#y(){for(let e of this.#r.keys())this.#v(e)}async#b(e){let t=e.file;if(!this.#n.has(e.id)&&!(this.#t.preview?.file?.metadata!==`line-count`||t.size>1048576||![`text/plain`,`text/markdown`,`text/csv`,`application/json`].includes(t.type))){this.#n.add(e.id);try{let n=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result??``)),r.onerror=()=>n(r.error),r.readAsText(t)});if(this.#s||!this.#e.includes(e)||n.includes(`\0`))return;e.lineCount=n===``?0:n.split(/\r\n|\r|\n/).length-+!!/\r?\n$|\r$/.test(n),this.#_(e)}catch{}}}#x(){this.#i&&(this.#i.style.display=this.#e.length>0?`flex`:`none`)}static fromConfig(t,n){return new e({allowedTypes:t?.allowedTypes,maxFileSize:t?.maxFileSize,maxFiles:t?.maxFiles,onFileRejected:t?.onFileRejected,onAttachmentsChange:n,preview:t?.preview,adapter:t?.adapter})}};const na=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),ra=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.name===r.name&&e.mimeType===r.mimeType&&e.size===r.size&&e.status===r.status&&e.progress===r.progress&&e.error===r.error});function ia(){let e={text:``,attachments:[],mentionRefs:[],selectedModelId:void 0,activeModeIds:[],quote:void 0,pendingSubmission:void 0,preparing:!1,streaming:!1,inputDisabled:!1,sendDisabled:!1},t=/* @__PURE__ */ new Set,n=null,r=!1,i=!1,a=()=>e.preparing?`preparing`:e.streaming?`streaming`:`idle`,o=()=>{let t=a();return Object.freeze({text:e.text,attachments:Object.freeze(e.attachments.map(e=>Object.freeze({...e}))),mentionRefs:Object.freeze([...e.mentionRefs]),selectedModelId:e.selectedModelId,activeModeIds:Object.freeze([...e.activeModeIds]),quote:e.quote?Object.freeze({...e.quote}):void 0,pendingSubmission:e.pendingSubmission,phase:t,inputDisabled:e.inputDisabled,sendDisabled:t!==`idle`||e.sendDisabled||e.inputDisabled})},s=()=>(n||=o(),n),c=()=>{if(r=!1,i||t.size===0)return;let e=s();for(let n of[...t])try{n(e)}catch(e){typeof console<`u`&&console.error(`[AgentWidget] composer state listener failed:`,e)}},l=()=>{n=null,!(i||r)&&(r=!0,queueMicrotask(c))};return{getState:s,subscribe:e=>(t.add(e),()=>t.delete(e)),setText:t=>{e.text!==t&&(e.text=t,l())},setAttachments:t=>{ra(e.attachments,t)||(e.attachments=[...t],l())},setMentionRefs:t=>{na(e.mentionRefs,t)||(e.mentionRefs=[...t],l())},setSelectedModelId:t=>{e.selectedModelId!==t&&(e.selectedModelId=t,l())},setActiveModeIds:t=>{na(e.activeModeIds,t)||(e.activeModeIds=[...t],l())},setQuote:t=>{let n=e.quote;(n?.text!==t?.text||n?.messageId!==t?.messageId||n?.sourceLabel!==t?.sourceLabel)&&(e.quote=t?{...t}:void 0,l())},setPendingSubmission:t=>{e.pendingSubmission!==t&&(e.pendingSubmission=t,l())},setPreparing:t=>{e.preparing!==t&&(e.preparing=t,l())},setStreaming:t=>{e.streaming!==t&&(e.streaming=t,l())},setInputDisabled:t=>{e.inputDisabled!==t&&(e.inputDisabled=t,l())},setSendDisabled:t=>{e.sendDisabled!==t&&(e.sendDisabled=t,l())},flush:()=>{r&&c()},destroy:()=>{i=!0,r=!1,t.clear()}}}const J=(e,...t)=>{for(let n of t){let t=e.querySelector(n);if(t)return t}return null},aa=(e,t)=>{let n=k(`div`,e);return n.setAttribute(t,``),n.setAttribute(`data-persona-composer-synthesized`,``),n.style.display=`contents`,n};function oa(e,t={}){let n=J(e,`[data-persona-composer-form]`),r=J(e,`[data-persona-composer-input]`);if(!n||!r){let e=`[Persona] composer surface is missing required element(s): ${[!n&&`form`,!r&&`input`].filter(Boolean).join(`, `)}. Mark them with data-persona-composer-form / data-persona-composer-input.`;if(t.debug&&(n||r))throw Error(e);return typeof console<`u`&&console.warn(e),null}let i={header:J(e,`[data-persona-composer-header]`),body:J(e,`[data-persona-composer-body]`),actionsStart:J(e,`[data-persona-composer-actions-start]`,`.persona-widget-composer__left-actions`),actionsEnd:J(e,`[data-persona-composer-actions-end]`,`.persona-widget-composer__right-actions`),actionsRow:J(e,`[data-persona-composer-actions]`,`.persona-widget-composer .persona-flex.persona-items-center.persona-justify-between`),suggestions:J(e,`[data-persona-composer-suggestions]`,`.persona-mb-3.persona-flex.persona-flex-wrap.persona-gap-2`),status:J(e,`[data-persona-composer-status]`)},a=/* @__PURE__ */ new Set,o=i.header;o||(a.add(`header`),o=aa(`persona-widget-composer__header`,`data-persona-composer-header`),n.parentNode?n.parentNode.insertBefore(o,n):e.appendChild(o));let s=i.body??r.parentElement??n,c=(e,t,n,r,i)=>{if(t)return t;a.add(e);let o=aa(n,r);return i.appendChild(o),o},l=c(`actionsStart`,i.actionsStart,`persona-widget-composer__left-actions`,`data-persona-composer-actions-start`,n),u=c(`actionsEnd`,i.actionsEnd,`persona-widget-composer__right-actions`,`data-persona-composer-actions-end`,n),d=c(`suggestions`,i.suggestions,`persona-widget-composer__suggestions`,`data-persona-composer-suggestions`,e),f=c(`status`,i.status,`persona-widget-composer__status`,`data-persona-composer-status`,e),p=[],m=(e,t)=>e.target===t.target&&e.type===t.type&&e.handler===t.handler,h=J(e,`[data-persona-composer-attachment-input]`,`input[type="file"]`)??void 0;return{footer:e,form:n,input:r,header:o,body:s,actionsStart:l,actionsEnd:u,suggestions:d,status:f,attachmentInput:h,attachmentPreviews:J(e,`[data-persona-composer-attachment-previews]`,`.persona-attachment-previews`)??void 0,attachmentButton:J(e,`[data-persona-composer-attachment-button]`,`.persona-attachment-button`)??void 0,sendButton:J(e,`[data-persona-composer-submit]`)??void 0,micButton:J(e,`[data-persona-composer-mic]`)??void 0,synthesized:a,found:i,addListener:(e,t,n,r)=>{e.addEventListener(t,n,r),p.push({target:e,type:t,handler:n,options:r})},removeListener:(e,t,n,r)=>{e.removeEventListener(t,n,r),p=p.filter(r=>!m(r,{target:e,type:t,handler:n}))},destroy:()=>{for(let e of p)e.target.removeEventListener(e.type,e.handler,e.options);p=[]}}}function sa(e){let t=O(`div`,{className:`persona-composer-quote`,attrs:{"data-persona-composer-quote":``}});t.style.display=`none`;let n=``,r=!1,i=n=>{let r=k(`span`,`persona-composer-quote-bar`),i=k(`div`,`persona-composer-quote-content`);if(n.sourceLabel){let e=k(`div`,`persona-composer-quote-source`);e.textContent=n.sourceLabel,i.appendChild(e)}let a=O(`div`,{className:`persona-composer-quote-text`,attrs:{"data-persona-composer-quote-text":``}});a.textContent=Ti(n.text),i.appendChild(a);let o=O(`button`,{className:`persona-composer-quote-dismiss`,attrs:{type:`button`,"aria-label":e.dismissLabel??`Remove quote`,"data-persona-composer-quote-dismiss":``}}),s=T(`x`,12,`currentColor`,2);s?o.appendChild(s):o.textContent=`×`,o.addEventListener(`click`,t=>{t.preventDefault(),t.stopPropagation(),e.onDismiss()}),t.replaceChildren(r,i,o)};return{element:t,render:e=>{if(r)return;let a=e?`${e.sourceLabel??``}${e.text}`:``;a!==n&&(n=a,e?(i(e),t.style.display=`flex`):(t.replaceChildren(),t.style.display=`none`))},destroy:()=>{r=!0,t.replaceChildren(),t.remove()}}}function ca(e){let t=O(`div`,{className:`persona-composer-pending`,attrs:{"data-persona-composer-pending":``}});t.style.display=`none`;let n,r=!1,i=(e,t,n,r)=>{let i=O(`button`,{className:`persona-composer-pending-action`,attrs:{type:`button`,"aria-label":t,[n]:``}}),a=T(e,12,`currentColor`,2);return a?i.appendChild(a):i.textContent=t,i.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),r()}),i},a=e=>{let t=Ti(e.text??``,90);if(t)return t;let n=e.contentParts?.length??0;return n>0?n===1?`1 attachment`:`${n} attachments`:(e.mentionRefs?.length??0)>0?e.mentionRefs.map(e=>e.label).join(`, `):`Queued message`};return{element:t,render:o=>{if(r||o===n)return;if(n=o,!o){t.replaceChildren(),t.style.display=`none`;return}let s=k(`span`,`persona-composer-pending-badge`);s.textContent=e.label??`Sends next`;let c=O(`div`,{className:`persona-composer-pending-text`,attrs:{"data-persona-composer-pending-text":``}});c.textContent=a(o),t.replaceChildren(s,c,i(`pencil`,e.editLabel??`Edit queued message`,`data-persona-composer-pending-edit`,e.onEdit),i(`x`,e.removeLabel??`Remove queued message`,`data-persona-composer-pending-remove`,e.onRemove)),t.style.display=`flex`},destroy:()=>{r=!0,t.replaceChildren(),t.remove()}}}function la(e){let t=O(`div`,{className:`persona-message-edit`,attrs:{"data-persona-message-edit":e.messageId,"data-preserve-runtime":``}}),n=O(`textarea`,{className:`persona-message-edit-input`,attrs:{rows:`1`,dir:`auto`,"aria-label":`Edit message`,"data-persona-message-edit-input":``}});n.value=e.initialText;let r=()=>{n.style.height=`auto`,n.style.height=`${n.scrollHeight}px`};n.addEventListener(`input`,r);let i=k(`div`,`persona-message-edit-actions`),a=(e,t,n,r)=>{let i=O(`button`,{className:`persona-message-edit-button ${t}`,attrs:{type:`button`,[n]:``},text:e});return i.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),r()}),i},o=()=>{let t=n.value.trim();t&&e.onSave(t)};return i.append(a(e.cancelLabel??`Cancel`,`persona-message-edit-cancel`,`data-persona-message-edit-cancel`,e.onCancel),a(e.saveLabel??`Send`,`persona-message-edit-save`,`data-persona-message-edit-save`,o)),n.addEventListener(`keydown`,t=>{t.key===`Escape`?(t.preventDefault(),t.stopPropagation(),e.onCancel()):t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),o())}),t.append(n,i),{element:t,getValue:()=>n.value,focus:()=>{n.focus();let e=n.value.length;n.setSelectionRange(e,e),r()},destroy:()=>{t.replaceChildren(),t.remove()}}}function ua(e){let t=e.text??``;if(t.trim().length>0||(e.mentionRefs?.length??0)>0||(e.activeModeIds?.length??0)>0||e.quote||e.selectedModelId)return{text:t,...e.mentionRefs?.length?{mentionRefs:[...e.mentionRefs]}:{},...e.contentSegments?.length?{contentSegments:[...e.contentSegments]}:{},...e.selectedModelId?{selectedModelId:e.selectedModelId}:{},...e.activeModeIds?.length?{activeModeIds:[...e.activeModeIds]}:{},...e.quote?{quote:{...e.quote}}:{}}}function da(e,t){if(!e||typeof e.text!=`string`)return;let n=new Set(t.mentionSourceIds),r=(e.mentionRefs??[]).filter(e=>n.has(e.sourceId)),i=r.length===(e.mentionRefs?.length??0)&&r.length>0,a=new Set(t.modes.map(e=>e.id)),o=(e.activeModeIds??[]).filter(e=>a.has(e)),s=e.selectedModelId&&t.modelIds.includes(e.selectedModelId)?e.selectedModelId:void 0;return{text:e.text,...i?{mentionRefs:r}:{},...i&&e.contentSegments?.length?{contentSegments:e.contentSegments}:{},...s?{selectedModelId:s}:{},...o.length?{activeModeIds:o}:{},...e.quote?.text?{quote:e.quote}:{}}}function fa(e){let t=e.delay??500,n=null,r=!1,i=()=>{n!==null&&(clearTimeout(n),n=null)};return{schedule:()=>{r||(i(),n=setTimeout(()=>{n=null,e.write()},t))},flush:()=>{r||n===null||(i(),e.write())},cancel:i,destroy:()=>{r=!0,i()}}}function pa(e){return e.wrapped||e.text.includes(`
|
|
10
|
-
`)?!1:!(e.hasAttachments||e.hasChips||e.hasQuote||e.hasPendingSubmission)}function ma(){let e=!1;return{observe:(t,n)=>n?(t&&(e=!0),e):(e=!1,!1),release:()=>{e=!1}}}function ha(e){if(!e)return!1;let t=e.ownerDocument?.defaultView;if(!t?.getComputedStyle)return!1;let n=t.getComputedStyle(e),r=Number.parseFloat(n.lineHeight),i=Number.parseFloat(n.fontSize),a=Number.isFinite(r)&&r>0?r:Number.isFinite(i)&&i>0?i*1.4:0;if(!a)return!1;let o=(Number.parseFloat(n.paddingTop)||0)+(Number.parseFloat(n.paddingBottom)||0),s=e.style.height,c=e.style.getPropertyPriority(`height`),l=e.tagName===`TEXTAREA`;l&&(e.style.height=`auto`);let u=e.scrollHeight-o;return l&&e.style.setProperty(`height`,s,c),u>a*1.5}function ga(e){return Object.freeze({text:e.text,contentParts:e.contentParts?Object.freeze([...e.contentParts]):void 0,mentionRefs:Object.freeze([...e.mentionRefs]),contentSegments:e.contentSegments?Object.freeze([...e.contentSegments]):void 0,options:Object.freeze({...e.options}),viaVoice:e.viaVoice})}function _a(e){return e.inputDisabled===!0||e.sendDisabled===!0||e.hasAttachments&&!e.attachmentsReady?!1:!!e.text||e.hasAttachments||e.hasMentions||e.hasServerMentions}const va=e=>typeof e?.then==`function`;function ya(e,t){return t===!1?{status:`canceled`}:(!t||typeof t!=`object`||(typeof t.text==`string`&&(e.text=t.text),t.options&&(e.options={...e.options,...t.options})),{status:`proceed`})}function ba(e,t,n){let r;try{r=e(ga(t),{signal:n})}catch(e){return{status:`error`,error:e}}return va(r)?Promise.resolve(r).then(e=>n.aborted?{status:`aborted`}:ya(t,e),e=>n.aborted?{status:`aborted`}:{status:`error`,error:e}):ya(t,r)}const xa=e=>e?.launcher?.variant??(e?.future?.v5Defaults===!0?`circle`:`pill`),Sa={background:`semantic.colors.primary`,foreground:`semantic.colors.textInverse`,border:`transparent`,size:`48px`,iconSize:`24px`,borderRadius:`palette.radius.full`,shadow:`0 8px 24px rgba(0,0,0,.16)`,offset:`20px`},Ca=`16px`,wa=`transparent`,Ta={colors:{primary:{50:`#ffffff`,100:`#f5f5f5`,200:`#d4d4d4`,300:`#a3a3a3`,400:`#737373`,500:`#171717`,600:`#0f0f0f`,700:`#0a0a0a`,800:`#050505`,900:`#030303`,950:`#000000`},secondary:{50:`#f5f3ff`,100:`#ede9fe`,200:`#ddd6fe`,300:`#c4b5fd`,400:`#a78bfa`,500:`#8b5cf6`,600:`#7c3aed`,700:`#6d28d9`,800:`#5b21b6`,900:`#4c1d95`,950:`#2e1065`},accent:{50:`#ecfeff`,100:`#cffafe`,200:`#a5f3fc`,300:`#67e8f9`,400:`#22d3ee`,500:`#06b6d4`,600:`#0891b2`,700:`#0e7490`,800:`#155e75`,900:`#164e63`,950:`#083344`},gray:{50:`#f9fafb`,100:`#f3f4f6`,200:`#e5e7eb`,300:`#d1d5db`,400:`#9ca3af`,500:`#6b7280`,600:`#4b5563`,700:`#374151`,800:`#1f2937`,900:`#111827`,950:`#030712`},success:{50:`#f0fdf4`,100:`#dcfce7`,200:`#bbf7d0`,300:`#86efac`,400:`#4ade80`,500:`#22c55e`,600:`#16a34a`,700:`#15803d`,800:`#166534`,900:`#14532d`},warning:{50:`#fefce8`,100:`#fef9c3`,200:`#fef08a`,300:`#fde047`,400:`#facc15`,500:`#eab308`,600:`#ca8a04`,700:`#a16207`,800:`#854d0e`,900:`#713f12`},error:{50:`#fef2f2`,100:`#fee2e2`,200:`#fecaca`,300:`#fca5a5`,400:`#f87171`,500:`#ef4444`,600:`#dc2626`,700:`#b91c1c`,800:`#991b1b`,900:`#7f1d1d`},info:{50:`#eff6ff`,100:`#dbeafe`,200:`#bfdbfe`,300:`#93c5fd`,400:`#60a5fa`,500:`#3b82f6`,600:`#2563eb`,700:`#1d4ed8`,800:`#1e40af`,900:`#1e3a8a`,950:`#172554`},purple:{50:`#faf5ff`,100:`#f3e8ff`,200:`#e9d5ff`,300:`#d8b4fe`,400:`#c084fc`,500:`#a855f7`,600:`#9333ea`,700:`#7e22ce`,800:`#6b21a8`,900:`#581c87`,950:`#3b0764`},teal:{50:`#f0fdfa`,100:`#ccfbf1`,200:`#99f6e4`,300:`#5eead4`,400:`#2dd4bf`,500:`#14b8a6`,600:`#0d9488`,700:`#0f766e`,800:`#115e59`,900:`#134e4a`,950:`#042f2e`}},spacing:(()=>{let e={};for(let t of[0,1,2,3,4,5,6,8,10,12,16,20,24,32,40,48,56,64])e[t]=t===0?`0px`:`${t/4}rem`;return e})(),typography:{fontFamily:{sans:`system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,serif:`Georgia, Cambria, "Times New Roman", Times, serif`,mono:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`},fontSize:{xs:`0.75rem`,sm:`0.875rem`,base:`1rem`,lg:`1.125rem`,xl:`1.25rem`,"2xl":`1.5rem`,"3xl":`1.875rem`,"4xl":`2.25rem`},fontWeight:{normal:`400`,medium:`500`,semibold:`600`,bold:`700`},lineHeight:{tight:`1.25`,normal:`1.5`,relaxed:`1.625`}},shadows:{none:`none`,sm:`0 1px 2px 0 rgb(0 0 0 / 0.05)`,md:`0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)`,lg:`0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)`,xl:`0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)`,"2xl":`0 25px 50px -12px rgb(0 0 0 / 0.25)`},borders:{none:`none`,sm:`1px solid`,md:`2px solid`,lg:`4px solid`},radius:{none:`0px`,sm:`0.125rem`,md:`0.375rem`,lg:`0.5rem`,xl:`0.75rem`,"2xl":`1rem`,full:`9999px`}},Ea={colors:{primary:`palette.colors.primary.500`,secondary:`palette.colors.secondary.500`,accent:`palette.colors.primary.600`,surface:`palette.colors.gray.50`,background:`palette.colors.gray.50`,container:`palette.colors.gray.50`,text:`palette.colors.gray.900`,textMuted:`palette.colors.gray.500`,textInverse:`palette.colors.gray.50`,border:`palette.colors.gray.200`,divider:`palette.colors.gray.200`,interactive:{default:`palette.colors.primary.600`,hover:`palette.colors.primary.700`,focus:`palette.colors.primary.600`,active:`palette.colors.primary.600`,disabled:`palette.colors.gray.300`},feedback:{success:`palette.colors.success.500`,warning:`palette.colors.warning.500`,error:`palette.colors.error.500`,info:`palette.colors.info.500`}},spacing:{xs:`palette.spacing.1`,sm:`palette.spacing.2`,md:`palette.spacing.4`,lg:`palette.spacing.6`,xl:`palette.spacing.8`,"2xl":`palette.spacing.10`},typography:{fontFamily:`palette.typography.fontFamily.sans`,fontSize:`palette.typography.fontSize.base`,fontWeight:`palette.typography.fontWeight.normal`,lineHeight:`palette.typography.lineHeight.normal`}},Da={button:{primary:{background:`palette.colors.primary.500`,foreground:`palette.colors.primary.50`,borderRadius:`palette.radius.lg`,padding:`semantic.spacing.md`},secondary:{background:`semantic.colors.surface`,foreground:`semantic.colors.secondary`,borderRadius:`palette.radius.lg`,padding:`semantic.spacing.md`},ghost:{background:`transparent`,foreground:`semantic.colors.text`,borderRadius:`palette.radius.md`,padding:`semantic.spacing.sm`,hoverBackground:`rgba(0, 0, 0, 0.05)`}},input:{background:`semantic.colors.surface`,placeholder:`semantic.colors.textMuted`,borderRadius:`palette.radius.lg`,padding:`semantic.spacing.md`,focus:{border:`palette.colors.gray.400`,ring:`palette.colors.gray.400`}},launcher:{background:`semantic.colors.surface`,foreground:`semantic.colors.primary`,border:`semantic.colors.border`,size:`60px`,iconSize:`28px`,borderRadius:`palette.radius.full`,shadow:`palette.shadows.lg`},panel:{width:E,maxWidth:`none`,height:`min(640px, max(200px, calc(100vh - 64px)))`,maxHeight:`none`,borderRadius:`palette.radius.xl`,shadow:`palette.shadows.xl`,inset:Ca,canvasBackground:wa,modes:{floating:{border:`1px solid var(--persona-border)`,shadow:`palette.shadows.xl`,borderRadius:`palette.radius.xl`},inline:{border:`1px solid var(--persona-border)`,shadow:`none`,borderRadius:`palette.radius.xl`},docked:{border:`none`,shadow:`none`,borderRadius:`palette.radius.xl`},sidebar:{border:`none`,borderRadius:`0`},mobile:{border:`none`,shadow:`none`,borderRadius:`0`}}},header:{background:`palette.colors.primary.500`,foreground:`palette.colors.primary.50`,borderRadius:`palette.radius.xl palette.radius.xl 0 0`,padding:`20px 24px`,minimalPadding:`16px 24px`,iconBackground:`palette.colors.primary.600`,iconForeground:`palette.colors.primary.50`},message:{gap:`12px`,user:{background:`palette.colors.primary.500`,text:`palette.colors.primary.50`,borderRadius:`palette.radius.lg`,shadow:`palette.shadows.sm`},assistant:{background:`semantic.colors.container`,text:`semantic.colors.text`,borderRadius:`palette.radius.lg`,border:`semantic.colors.border`,shadow:`palette.shadows.sm`},border:`semantic.colors.border`},introCard:{background:`transparent`,borderRadius:`palette.radius.2xl`,padding:`semantic.spacing.lg`,shadow:`palette.shadows.none`},suggestion:{chip:{background:`semantic.colors.surface`,foreground:`semantic.colors.text`,border:`semantic.colors.border`,borderRadius:`palette.radius.full`,padding:`0.5rem 0.875rem`,gap:`0.5rem`,itemGap:`8px`,minHeight:`36px`,fontSize:`0.8125rem`,lineHeight:`1.25`,iconSize:`16px`,hoverBackground:`palette.colors.gray.100`,hoverBorder:`palette.colors.gray.300`,pressedBackground:`palette.colors.gray.200`,focusRing:`semantic.colors.interactive.focus`,disabledOpacity:`0.5`},card:{background:`semantic.colors.surface`,foreground:`semantic.colors.text`,border:`semantic.colors.border`,borderRadius:`palette.radius.xl`,padding:`1rem`,shadow:`palette.shadows.sm`,gap:`0.625rem`,itemGap:`8px`,minHeight:`72px`,fontSize:`0.875rem`,lineHeight:`1.35`,iconSize:`18px`,hoverBackground:`palette.colors.gray.100`,hoverBorder:`palette.colors.gray.300`,pressedBackground:`palette.colors.gray.200`,focusRing:`semantic.colors.interactive.focus`,disabledOpacity:`0.5`},list:{background:`transparent`,foreground:`semantic.colors.text`,border:`semantic.colors.border`,borderRadius:`palette.radius.md`,padding:`0.75rem`,gap:`0.625rem`,itemGap:`8px`,minHeight:`44px`,fontSize:`0.875rem`,lineHeight:`1.35`,iconSize:`17px`,hoverBackground:`palette.colors.gray.100`,hoverBorder:`palette.colors.gray.300`,pressedBackground:`palette.colors.gray.200`,focusRing:`semantic.colors.interactive.focus`,disabledOpacity:`0.5`}},toolBubble:{shadow:`palette.shadows.sm`},reasoningBubble:{shadow:`palette.shadows.sm`},composer:{shadow:`palette.shadows.none`},scrollbar:{thumb:`semantic.colors.border`,track:`transparent`},markdown:{inlineCode:{background:`palette.colors.gray.50`,foreground:`palette.colors.gray.900`},link:{foreground:`palette.colors.primary.600`},prose:{fontFamily:`inherit`},codeBlock:{background:`semantic.colors.container`,borderColor:`semantic.colors.border`,textColor:`inherit`,borderRadius:`palette.radius.md`},table:{headerBackground:`semantic.colors.container`,borderColor:`semantic.colors.border`},hr:{color:`semantic.colors.divider`},blockquote:{borderColor:`palette.colors.gray.900`,background:`transparent`,textColor:`palette.colors.gray.500`}},collapsibleWidget:{container:`palette.colors.gray.50`,surface:`semantic.colors.surface`,border:`semantic.colors.border`},voice:{recording:{indicator:`palette.colors.error.500`,background:`palette.colors.error.50`,border:`palette.colors.error.200`},processing:{icon:`palette.colors.primary.500`,background:`palette.colors.primary.50`},speaking:{icon:`palette.colors.success.500`}},approval:{requested:{background:`semantic.colors.surface`,border:`semantic.colors.border`,text:`palette.colors.gray.900`,shadow:`0 1px 2px 0 rgba(11, 11, 11, 0.06), 0 2px 8px 0 rgba(11, 11, 11, 0.04)`},approve:{background:`semantic.colors.primary`,foreground:`semantic.colors.textInverse`,borderRadius:`palette.radius.md`,padding:`semantic.spacing.sm`},deny:{background:`semantic.colors.container`,foreground:`semantic.colors.text`,borderRadius:`palette.radius.md`,padding:`semantic.spacing.sm`}},attachment:{image:{background:`palette.colors.gray.100`,border:`palette.colors.gray.200`}},eventStream:{badge:{flow:{background:`palette.colors.success.100`,foreground:`palette.colors.success.700`},step:{background:`palette.colors.primary.100`,foreground:`palette.colors.primary.700`},reasoning:{background:`palette.colors.warning.100`,foreground:`palette.colors.warning.700`},tool:{background:`palette.colors.purple.100`,foreground:`palette.colors.purple.800`},agent:{background:`palette.colors.teal.100`,foreground:`palette.colors.teal.800`},error:{background:`palette.colors.error.100`,foreground:`palette.colors.error.700`},default:{background:`palette.colors.gray.100`,foreground:`palette.colors.gray.600`}}},scrollToBottom:{background:`components.button.primary.background`,foreground:`components.button.primary.foreground`,border:`semantic.colors.primary`,size:`40px`,borderRadius:`palette.radius.full`,shadow:`palette.shadows.sm`,padding:`0.5rem 0.875rem`,gap:`0.5rem`,fontSize:`0.875rem`,iconSize:`14px`},artifact:{pane:{background:`semantic.colors.container`,toolbarBackground:`semantic.colors.container`}}},Oa=Ta.colors.gray,ka={50:`#fafafa`,100:`#f5f5f5`,200:`#e5e5e5`,300:`#d4d4d4`,400:`#a3a3a3`,500:`#737373`,600:`#525252`,700:`#404040`,800:`#262626`,900:`#171717`,950:`#0a0a0a`},Aa={...Ta,colors:{...Ta.colors,gray:Oa}},ja={...Ta,colors:{...Ta.colors,gray:ka},radius:{none:`0px`,sm:`4px`,md:`8px`,lg:`12px`,xl:`16px`,"2xl":`24px`,full:`9999px`}},Ma=Ea,Na={...Ea,colors:{...Ea.colors,surface:`#ffffff`,background:`#ffffff`,container:`semantic.colors.surface`,textInverse:`#ffffff`},typography:{...Ea.typography,fontSize:`14px`,lineHeight:`1.5`}},Pa=Da,Fa={...Da,scrollToBottom:{...Da.scrollToBottom,background:`semantic.colors.surface`,foreground:`semantic.colors.text`,border:`semantic.colors.border`,size:`32px`},messageActions:{background:`transparent`,border:`none`,hoverBackground:`components.button.ghost.hoverBackground`,hoverForeground:`semantic.colors.text`,borderRadius:`palette.radius.md`},launcher:Sa,activity:{rowHeight:`32px`,labelSize:`13px`,iconSize:`16px`,indent:`0px`,transcriptGap:`0px`,responseGap:`12px`,groupIndent:`16px`,groupGap:`2px`,groupPadding:`2px 0`,bodyPadding:`4px 0`,bodyFontWeight:`400`,sectionGap:`8px`,bodySurface:`transparent`},toolBubble:{shadow:`none`},reasoningBubble:{shadow:`none`},input:{...Da.input,borderRadius:`palette.radius.full`},introCard:{...Da.introCard,title:{fontSize:`22px`,fontWeight:`500`}},suggestion:{chip:{...Da.suggestion.chip,fontWeight:`400`},card:{...Da.suggestion.card,fontWeight:`400`},list:{...Da.suggestion.list,fontWeight:`400`}},panel:{...Da.panel,width:`min(400px, calc(100vw - 24px))`,height:`min(704px, calc(100dvh - 104px))`,borderRadius:`palette.radius.xl`},header:{...Da.header,background:`semantic.colors.container`,foreground:`semantic.colors.text`,padding:`8px 8px 8px 16px`,minimalPadding:`8px 8px 8px 16px`,minHeight:`48px`,borderBottom:`none`,iconBackground:`transparent`,iconForeground:`semantic.colors.text`,iconScale:`1`,iconPadding:`auto`,controlSize:`28px`,controlIconSize:`16px`,controlStrokeWidth:`1.5`,actionIconForeground:`semantic.colors.textMuted`,controlBorderRadius:`8px`,controlHoverBackground:`color-mix(in srgb, var(--persona-text) 8%, transparent)`,controlHoverForeground:`semantic.colors.text`,controlFocusOutline:`2px solid color-mix(in srgb, var(--persona-text) 50%, transparent)`,title:{fontSize:`14px`,fontWeight:`500`,lineHeight:`1.5`}},message:{...Da.message,gap:`20px`,fullscreenGap:`28px`,topFadeHeight:`18px`,user:{...Da.message.user,background:`palette.colors.gray.100`,text:`semantic.colors.text`,borderRadius:`palette.radius.xl`,shadow:`none`,padding:`8px 14px`,fontSize:`14px`,lineHeight:`1.5`},assistant:{...Da.message.assistant,background:`transparent`,border:`transparent`,borderWidth:`0px`,borderRadius:`0px`,shadow:`none`,padding:`0px`,fontSize:`14px`,lineHeight:`1.55`}},artifact:{...Da.artifact,card:{background:`semantic.colors.surface`,border:`1px solid var(--persona-border)`,borderRadius:`palette.radius.lg`,hoverBackground:`components.button.ghost.hoverBackground`,hoverBorderColor:`semantic.colors.border`},inline:{background:`semantic.colors.surface`,border:`1px solid var(--persona-border)`,borderRadius:`palette.radius.lg`,chromeBackground:`semantic.colors.surface`,chromeBorder:`semantic.colors.border`,titleColor:`semantic.colors.text`,mutedColor:`semantic.colors.textMuted`}},composer:{...Da.composer,padding:`8px`,fontSize:`15px`,lineHeight:`1.5`,controlSize:`32px`,controlIconSize:`20px`,expandedPadding:`12px 16px`,expandedBorderRadius:`24px`,sendIconSize:`18px`,sendButtonRadius:`9999px`,footerBorder:`none`,overflowMenu:{borderRadius:`12px`},overlayBand:`linear-gradient(to bottom, transparent, var(--persona-container) 24px)`,focusBorderColor:`color-mix(in srgb, var(--persona-text) 28%, var(--persona-border))`,focusRing:`1px solid color-mix(in srgb, var(--persona-text) 12%, transparent)`}},Ia=e=>fe({future:e}),La=e=>Ia(e)===`v5`?{palette:ja,semantic:Na,components:Fa}:{palette:Aa,semantic:Ma,components:Pa};function Ra(e,t){if(!t.startsWith(`palette.`)&&!t.startsWith(`semantic.`)&&!t.startsWith(`components.`))return t;let n=t.split(`.`),r=e;for(let e of n){if(r==null)return;r=r[e]}return typeof r==`string`&&(r.startsWith(`palette.`)||r.startsWith(`semantic.`)||r.startsWith(`components.`))?Ra(e,r):r}function za(e){let t={};function n(r,i){for(let[a,o]of Object.entries(r)){let r=`${i}.${a}`;if(typeof o==`string`){let n=Ra(e,o);n!==void 0&&(t[r]={path:r,value:n,type:i.includes(`color`)?`color`:i.includes(`spacing`)?`spacing`:i.includes(`typography`)?`typography`:i.includes(`shadow`)?`shadow`:i.includes(`border`)?`border`:`color`})}else typeof o==`object`&&o&&n(o,r)}}return n(e.palette,`palette`),n(e.semantic,`semantic`),n(e.components,`components`),t}function Ba(e){let t=[],n=[];return e.palette||t.push({path:`palette`,message:`Theme must include a palette`,severity:`error`}),e.semantic||n.push({path:`semantic`,message:`No semantic tokens defined - defaults will be used`,severity:`warning`}),e.components||n.push({path:`components`,message:`No component tokens defined - defaults will be used`,severity:`warning`}),{valid:t.length===0,errors:t,warnings:n}}function Va(e,t){let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];n[e]=t&&typeof t==`object`&&!Array.isArray(t)&&r&&typeof r==`object`&&!Array.isArray(r)?Va(t,r):r}return n}function Ha(e,t={}){let n=La(t.future),r=e?.components,i={palette:{...n.palette,...e?.palette,colors:{...n.palette.colors,...e?.palette?.colors},spacing:{...n.palette.spacing,...e?.palette?.spacing},typography:{...n.palette.typography,...e?.palette?.typography},shadows:{...n.palette.shadows,...e?.palette?.shadows},borders:{...n.palette.borders,...e?.palette?.borders},radius:{...n.palette.radius,...e?.palette?.radius}},semantic:{...n.semantic,...e?.semantic,colors:{...n.semantic.colors,...e?.semantic?.colors,interactive:{...n.semantic.colors.interactive,...e?.semantic?.colors?.interactive},feedback:{...n.semantic.colors.feedback,...e?.semantic?.colors?.feedback}},spacing:{...n.semantic.spacing,...e?.semantic?.spacing},typography:{...n.semantic.typography,...e?.semantic?.typography}},components:r?Va(n.components,r):n.components},a=r?.activity;for(let e of[`toolBubble`,`reasoningBubble`]){let t=i.components[e]={...i.components[e]};for(let n of[`rowHeight`,`labelSize`,`iconSize`,`indent`,`bodySurface`])a?.[n]!==void 0&&(n!==`bodySurface`||r?.[e]?.bodySurface===void 0)&&(t[n]=a[n])}let o=r?.collapsibleWidget?.surface;fe(t)===`v4`&&o!==void 0&&a?.bodySurface===void 0&&(i.components.activity={...i.components.activity,bodySurface:o});let s=r?.header;s?.padding!==void 0&&s.minimalPadding===void 0&&(i.components.header.minimalPadding=i.components.header.padding);let c=r?.composer;i.components.composer={...i.components.composer},c?.padding!==void 0&&c.expandedPadding===void 0&&(i.components.composer.expandedPadding=c.padding),r?.input?.borderRadius!==void 0&&c?.expandedBorderRadius===void 0&&(i.components.composer.expandedBorderRadius=r.input.borderRadius);let l=r?.message;if(l?.gap!==void 0&&l.fullscreenGap===void 0&&(i.components.message.fullscreenGap=i.components.message.gap),t.validate!==!1){let e=Ba(i);if(!e.valid)throw Error(`Theme validation failed: ${e.errors.map(e=>e.message).join(`, `)}`)}if(t.plugins)for(let e of t.plugins)i=e.transform(i);return i}const Ua=e=>e.trim()===`0`?`0px`:e,Wa=`--persona-`,Ga=e=>{if(!e)return;let t=e.trim().toLowerCase(),n;if(t.charCodeAt(0)===35){let e=t.slice(1);if(!/^[0-9a-f]+$/.test(e))return;e.length===3||e.length===4?n=[0,1,2].map(t=>parseInt(e[t]+e[t],16)):(e.length===6||e.length===8)&&(n=[0,2,4].map(t=>parseInt(e.slice(t,t+2),16)))}else{let e=t.match(/^rgba?\(([^)]+)\)$/);if(e){let t=e[1].split(/[,/\s]+/).filter(Boolean);t.length>=3&&(n=t.slice(0,3).map(e=>{let t=e.endsWith(`%`),n=parseFloat(t?e.slice(0,-1):e);return t?n/100*255:n}))}}if(!n||n.some(e=>!Number.isFinite(e)))return;let[r,i,a]=n.map(e=>{let t=Math.max(0,Math.min(255,e))/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a},Ka=(e,t)=>{for(let[n,...r]of t){let t;for(let n of r)if(t=n.charCodeAt(0)===61?n.slice(1):e[Wa+n],t!==void 0)break;t!==void 0&&(e[Wa+n]=t)}},qa=[[`primary`,`semantic-colors-primary`,`palette-colors-primary-500`],[`secondary`,`semantic-colors-secondary`,`palette-colors-secondary-500`],[`accent`,`semantic-colors-accent`,`palette-colors-accent-500`],[`surface`,`semantic-colors-surface`,`palette-colors-gray-50`],[`background`,`semantic-colors-background`,`palette-colors-gray-50`],[`container`,`semantic-colors-container`,`palette-colors-gray-100`],[`text`,`semantic-colors-text`,`palette-colors-gray-900`],[`text-muted`,`semantic-colors-textMuted`,`palette-colors-gray-500`],[`text-inverse`,`semantic-colors-textInverse`,`palette-colors-gray-50`],[`border`,`semantic-colors-border`,`palette-colors-gray-200`],[`divider`,`semantic-colors-divider`,`palette-colors-gray-200`],[`muted`,`text-muted`],[`font-family`,`semantic-typography-fontFamily`,`palette-typography-fontFamily-sans`],[`font-size`,`semantic-typography-fontSize`,`palette-typography-fontSize-base`],[`font-weight`,`semantic-typography-fontWeight`,`palette-typography-fontWeight-normal`],[`line-height`,`semantic-typography-lineHeight`,`palette-typography-lineHeight-normal`],[`input-font-family`,`font-family`],[`input-font-weight`,`font-weight`],[`radius-sm`,`palette-radius-sm`,`=0.125rem`],[`radius-md`,`palette-radius-md`,`=0.375rem`],[`radius-lg`,`palette-radius-lg`,`=0.5rem`],[`radius-xl`,`palette-radius-xl`,`=0.75rem`],[`radius-full`,`palette-radius-full`,`=9999px`],[`launcher-radius`,`components-launcher-borderRadius`,`palette-radius-full`,`=9999px`],[`launcher-bg`,`components-launcher-background`,`surface`],[`launcher-fg`,`components-launcher-foreground`,`primary`]],Ja=e=>{let t=za(e),n={};for(let[e,r]of Object.entries(t)){let t=e.replace(/\./g,`-`);n[`--persona-${t}`]=r.value}return n},Ya=e=>{let t=e[`--persona-components-launcher-foreground`];e[`--persona-launcher-fg-muted`]=t&&t!==e[`--persona-primary`]?`color-mix(in srgb, ${t} 70%, transparent)`:e[`--persona-muted`]},Xa=e=>{if(e[`--persona-components-header-iconPadding`]===`auto`){let t=(e[`--persona-components-header-iconBackground`]??e[`--persona-primary`]).trim().toLowerCase(),n=t.match(/^(?:rgba?|hsla?)\(([^)]+)\)$/)?.[1].split(/[,\s/]+/).filter(Boolean);e[`--persona-components-header-iconPadding`]=t===`transparent`||/^#(?:[\da-f]{3}0|[\da-f]{6}00)$/.test(t)||n?.length===4&&parseFloat(n[3])===0?`0px`:`6px`}};function Za(e){let t=Ja(e);Ka(t,qa),Ka(t,[[`ask-sheet-bg`,`components-askUserQuestion-sheet-background`],[`ask-sheet-border`,`components-askUserQuestion-sheet-border`],[`ask-sheet-shadow`,`components-askUserQuestion-sheet-shadow`],[`ask-pill-bg`,`components-askUserQuestion-pill-background`],[`ask-pill-fg`,`components-askUserQuestion-pill-foreground`],[`ask-pill-radius`,`components-askUserQuestion-pill-borderRadius`],[`ask-pill-bg-selected`,`components-askUserQuestion-pill-selectedBackground`],[`ask-pill-fg-selected`,`components-askUserQuestion-pill-selectedForeground`],[`ask-input-bg`,`components-askUserQuestion-customInput-background`],[`voice-recording-indicator`,`components-voice-recording-indicator`,`palette-colors-error-500`],[`voice-recording-bg`,`components-voice-recording-background`,`palette-colors-error-50`],[`voice-processing-icon`,`components-voice-processing-icon`,`palette-colors-primary-500`],[`voice-speaking-icon`,`components-voice-speaking-icon`,`palette-colors-success-500`],[`approval-bg`,`components-approval-requested-background`,`surface`],[`approval-border`,`components-approval-requested-border`,`border`],[`approval-text`,`components-approval-requested-text`,`palette-colors-gray-900`],[`approval-shadow`,`components-approval-requested-shadow`,`=0 1px 2px 0 rgba(11, 11, 11, 0.06), 0 2px 8px 0 rgba(11, 11, 11, 0.04)`],[`approval-approve-bg`,`components-approval-approve-background`,`button-primary-bg`],[`approval-deny-bg`,`components-approval-deny-background`,`container`],[`attachment-image-bg`,`components-attachment-image-background`,`palette-colors-gray-100`],[`attachment-image-border`,`components-attachment-image-border`,`palette-colors-gray-200`]]),Ya(t),Ka(t,[[`launcher-border`,`components-launcher-border`,`border`],[`button-primary-bg`,`components-button-primary-background`,`primary`],[`button-primary-fg`,`components-button-primary-foreground`,`text-inverse`],[`button-radius`,`components-button-primary-borderRadius`,`palette-radius-full`,`=9999px`],[`button-stop-bg`,`components-button-stop-background`],[`button-stop-fg`,`components-button-stop-foreground`]]),Ka(t,[[`button-ghost-bg`,`components-button-ghost-background`,`=transparent`],[`button-ghost-fg`,`components-button-ghost-foreground`,`text`],[`button-ghost-radius`,`components-button-ghost-borderRadius`,`radius-md`,`=0.375rem`],[`button-ghost-hover-bg`,`components-button-ghost-hoverBackground`,`=rgba(0, 0, 0, 0.05)`],[`panel-radius`,`components-panel-borderRadius`,`radius-xl`,`=0.75rem`]]),t[`--persona-panel-border`]=t[`--persona-components-panel-border`]??`1px solid ${t[`--persona-border`]}`,Ka(t,[[`panel-shadow`,`components-panel-shadow`,`palette-shadows-xl`,`=0 25px 50px -12px rgba(0, 0, 0, 0.25)`]]),t[`--persona-panel-inset`]=t[`--persona-components-panel-inset`]??`16px`,t[`--persona-panel-canvas-bg`]=t[`--persona-components-panel-canvasBackground`]??`transparent`,Ka(t,[[`launcher-shadow`,`components-launcher-shadow`,`=0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)`],[`input-radius`,`components-input-borderRadius`,`radius-lg`,`=0.5rem`],[`message-user-radius`,`components-message-user-borderRadius`,`radius-lg`,`=0.5rem`],[`message-assistant-radius`,`components-message-assistant-borderRadius`,`radius-lg`,`=0.5rem`]]);let n=(n,r,i,a=``)=>{if(n)for(let[o,s,c]of i){let i=n[a+o];i&&(t[`--persona-${r}${s}`]=c?Ra(e,i)??i:i)}};Ka(t,[[`header-bg`,`components-header-background`,`surface`]]);let r=t[`--persona-header-bg`],i=t[`--persona-components-header-foreground`],a=i?`color-mix(in srgb, ${i} 72%, ${r})`:void 0;t[`--persona-header-border`]=t[`--persona-components-header-border`]??(i?`color-mix(in srgb, ${i} 14%, ${r})`:void 0)??t[`--persona-divider`],Ka(t,[[`header-icon-bg`,`components-header-iconBackground`,`primary`],[`header-icon-fg`,`components-header-iconForeground`,`text-inverse`]]),Xa(t),t[`--persona-header-title-fg`]=t[`--persona-components-header-title-color`]??t[`--persona-components-header-titleForeground`]??i??t[`--persona-primary`],t[`--persona-header-subtitle-fg`]=t[`--persona-components-header-subtitle-color`]??t[`--persona-components-header-subtitleForeground`]??a??t[`--persona-text-muted`],t[`--persona-header-action-icon-fg`]=t[`--persona-components-header-actionIconForeground`]??a??t[`--persona-muted`],Ka(t,[[`header-control-size`,`components-header-controlSize`,`=32px`],[`header-control-icon-size`,`components-header-controlIconSize`,`=16px`]]),n(e.components?.header,`header-`,[[`shadow`,`shadow`],[`borderBottom`,`border-bottom`],[`minHeight`,`min-height`]]),n(t,`history-rail-header-`,[[`background`,`bg`],[`border`,`border`],[`minHeight`,`min-height`]],`--persona-components-history-railHeader-`),n(t,`history-overlay-`,[[`margin`,`margin`],[`borderRadius`,`radius`],[`shadow`,`shadow`],[`background`,`bg`]],`--persona-components-history-overlay-`),n(t,`history-menu-`,[[`background`,`bg`],[`borderRadius`,`radius`]],`--persona-components-history-menu-`);let o=e.components?.history?.motion;if(o){let e=e=>{if(e===void 0)return;let t=String(e).trim();return/^\d+(\.\d+)?$/.test(t)?`${t}ms`:t},n=e(o.enterDurationMs);n!==void 0&&(t[`--persona-history-enter-ms`]=n);let r=e(o.exitDurationMs);r!==void 0&&(t[`--persona-history-exit-ms`]=r),o.enterEasing&&(t[`--persona-history-enter-easing`]=o.enterEasing),o.exitEasing&&(t[`--persona-history-exit-easing`]=o.exitEasing)}let s=t[`--persona-components-history-dangerForeground`];s&&(t[`--persona-history-danger-fg`]=s),t[`--persona-danger`]=t[`--persona-components-history-confirm-dangerBackground`]??t[`--persona-palette-colors-error-700`]??`#b42318`,t[`--persona-danger-fg`]=t[`--persona-components-history-confirm-dangerForeground`]??`#ffffff`;for(let e of[`scrim`,`shadow`]){let n=t[`--persona-components-history-confirm-${e}`];n&&(t[`--persona-history-confirm-${e}`]=n)}n(t,`tooltip-`,[[`background`,`background`],[`foreground`,`foreground`],[`hintForeground`,`hint-fg`],[`borderRadius`,`radius`],[`fontSize`,`font-size`],[`padding`,`padding`],[`maxWidth`,`max-width`],[`shadow`,`shadow`]],`--persona-components-tooltip-`),e.components?.tooltip?.arrow===!1&&(t[`--persona-tooltip-arrow-display`]=`none`),n(t,`scroll-to-bottom-count-`,[[`background`,`bg`],[`foreground`,`fg`],[`border`,`border`],[`borderRadius`,`radius`],[`size`,`size`],[`padding`,`padding`],[`fontSize`,`font-size`],[`fontWeight`,`font-weight`]],`--persona-components-scrollToBottom-countBadge-`),n(t,`message-action-`,[[`background`,`bg`],[`border`,`border`],[`hoverBackground`,`hover-bg`],[`hoverForeground`,`hover-fg`],[`borderRadius`,`radius`]],`--persona-components-messageActions-`),Ka(t,[[`intro-card-bg`,`components-introCard-background`,`=transparent`],[`intro-card-radius`,`components-introCard-borderRadius`,`=1rem`]]);let c=t[`--persona-components-introCard-background`],l=t[`--persona-components-introCard-shadow`],u=(!c||c===`transparent`||c===`none`)&&(!l||l===`none`),d=t[`--persona-components-introCard-padding`]??`1.5rem`;t[`--persona-intro-card-padding`]=u&&d===`1.5rem`?`1.5rem 0`:d,Ka(t,[[`intro-card-shadow`,`components-introCard-shadow`,`=none`],[`intro-card-border`,`components-introCard-border`,`=none`],[`input-background`,`components-input-background`,`surface`],[`input-placeholder`,`components-input-placeholder`,`text-muted`],[`input-backdrop-filter`,`components-input-backdropFilter`,`=none`],[`message-user-bg`,`components-message-user-background`,`accent`],[`message-user-text`,`components-message-user-text`,`text-inverse`],[`message-user-shadow`,`components-message-user-shadow`,`=0 5px 15px rgba(15, 23, 42, 0.08)`],[`message-assistant-bg`,`components-message-assistant-background`,`surface`],[`message-assistant-text`,`components-message-assistant-text`,`text`],[`message-assistant-border`,`components-message-assistant-border`,`border`],[`message-assistant-shadow`,`components-message-assistant-shadow`,`=0 1px 2px 0 rgb(0 0 0 / 0.05)`],[`scroll-to-bottom-bg`,`components-scrollToBottom-background`,`button-primary-bg`,`accent`],[`scroll-to-bottom-fg`,`components-scrollToBottom-foreground`,`button-primary-fg`,`text-inverse`],[`scroll-to-bottom-border`,`components-scrollToBottom-border`,`primary`],[`scroll-to-bottom-size`,`components-scrollToBottom-size`,`=40px`],[`scroll-to-bottom-radius`,`components-scrollToBottom-borderRadius`,`button-radius`,`radius-full`,`=9999px`],[`scroll-to-bottom-shadow`,`components-scrollToBottom-shadow`,`palette-shadows-sm`,`=0 1px 2px 0 rgb(0 0 0 / 0.05)`],[`scroll-to-bottom-padding`,`components-scrollToBottom-padding`,`=0.5rem 0.875rem`],[`scroll-to-bottom-gap`,`components-scrollToBottom-gap`,`=0.5rem`],[`scroll-to-bottom-font-size`,`components-scrollToBottom-fontSize`,`palette-typography-fontSize-sm`,`=0.875rem`],[`scroll-to-bottom-icon-size`,`components-scrollToBottom-iconSize`,`=14px`],[`event-badge-flow-bg`,`components-eventStream-badge-flow-background`,`=#dcfce7`],[`event-badge-flow-fg`,`components-eventStream-badge-flow-foreground`,`=#15803d`],[`event-badge-step-bg`,`components-eventStream-badge-step-background`,`=#f5f5f5`],[`event-badge-step-fg`,`components-eventStream-badge-step-foreground`,`=#0a0a0a`],[`event-badge-reasoning-bg`,`components-eventStream-badge-reasoning-background`,`=#fef9c3`],[`event-badge-reasoning-fg`,`components-eventStream-badge-reasoning-foreground`,`=#a16207`],[`event-badge-tool-bg`,`components-eventStream-badge-tool-background`,`=#f3e8ff`],[`event-badge-tool-fg`,`components-eventStream-badge-tool-foreground`,`=#6b21a8`],[`event-badge-agent-bg`,`components-eventStream-badge-agent-background`,`=#ccfbf1`],[`event-badge-agent-fg`,`components-eventStream-badge-agent-foreground`,`=#115e59`],[`event-badge-error-bg`,`components-eventStream-badge-error-background`,`=#fee2e2`],[`event-badge-error-fg`,`components-eventStream-badge-error-foreground`,`=#b91c1c`],[`event-badge-default-bg`,`components-eventStream-badge-default-background`,`=#f3f4f6`],[`event-badge-default-fg`,`components-eventStream-badge-default-foreground`,`=#4b5563`],[`tool-bubble-shadow`,`components-toolBubble-shadow`,`=0 5px 15px rgba(15, 23, 42, 0.08)`],[`reasoning-bubble-shadow`,`components-reasoningBubble-shadow`,`=0 5px 15px rgba(15, 23, 42, 0.08)`],[`composer-shadow`,`components-composer-shadow`,`=none`]]),Ka(t,[[`panel-background`,`components-panel-background`,`surface`],[`transcript-background`,`components-message-background`,`container`],[`transcript-top-fade-background`,`components-message-topFadeBackground`,`transcript-background`],[`composer-footer-background`,`components-composer-footerBackground`,`surface`],[`composer-footer-padding`,`components-composer-footerPadding`,`=1rem 1.5rem`],[`composer-padding`,`components-composer-padding`,`=0.75rem 1rem`],[`composer-gap`,`components-composer-gap`,`=0.5rem`],[`composer-font-size`,`components-composer-fontSize`,`=0.875rem`],[`composer-line-height`,`components-composer-lineHeight`,`=1.25rem`],[`composer-control-size`,`components-composer-controlSize`,`=40px`],[`composer-control-icon-size`,`components-composer-controlIconSize`,`=24px`],[`motion-duration-fast`,`components-motion-durationFast`,`=120ms`],[`motion-duration-base`,`components-motion-durationBase`,`=200ms`],[`motion-easing`,`components-motion-easing`,`=cubic-bezier(0.2, 0, 0, 1)`],[`composer-border-color`,`components-composer-borderColor`,`border`,`=#e5e7eb`],[`composer-overlay-band`,`components-composer-overlayBand`,`=transparent`],[`scrollbar-thumb`,`components-scrollbar-thumb`,`border`,`=#e5e7eb`],[`scrollbar-track`,`components-scrollbar-track`,`=transparent`],[`md-inline-code-bg`,`components-markdown-inlineCode-background`,`container`],[`md-inline-code-color`,`components-markdown-inlineCode-foreground`,`text`],[`md-link-color`,`components-markdown-link-foreground`,`accent`,`=#0f0f0f`]]),n(t,`md-`,[[`h1-fontSize`,`h1-size`],[`h1-fontWeight`,`h1-weight`],[`h2-fontSize`,`h2-size`],[`h2-fontWeight`,`h2-weight`]],`--persona-components-markdown-heading-`);let f=t[`--persona-components-markdown-prose-fontFamily`];f&&f!==`inherit`&&(t[`--persona-md-prose-font-family`]=f),Ka(t,[[`md-code-block-bg`,`components-markdown-codeBlock-background`,`container`],[`md-code-block-border-color`,`components-markdown-codeBlock-borderColor`,`border`],[`md-code-block-text-color`,`components-markdown-codeBlock-textColor`,`=inherit`]]),Ka(t,[[`md-code-block-border-radius`,`components-markdown-codeBlock-borderRadius`,`radius-md`,`=0.375rem`]]),Ka(t,[[`md-table-header-bg`,`components-markdown-table-headerBackground`,`container`],[`md-table-border-color`,`components-markdown-table-borderColor`,`border`]]),Ka(t,[[`md-hr-color`,`components-markdown-hr-color`,`divider`]]),Ka(t,[[`md-blockquote-border-color`,`components-markdown-blockquote-borderColor`,`palette-colors-gray-900`],[`md-blockquote-bg`,`components-markdown-blockquote-background`,`=transparent`],[`md-blockquote-text-color`,`components-markdown-blockquote-textColor`,`palette-colors-gray-500`]]);for(let[e,n]of[[`container`,`surface`],[`surface`,`surface`],[`border`,`border`]]){let r=t[`--persona-components-collapsibleWidget-${e}`]??t[`--persona-${n}`];r!==void 0&&(t[`--persona-cw-${e}`]=r,t[`--cw-${e}`]=r)}Ka(t,[[`message-border`,`components-message-border`,`border`]]),Ka(t,[[`message-user-padding`,`components-message-user-padding`],[`message-user-max-width`,`components-message-user-maxWidth`],[`message-user-font-size`,`components-message-user-fontSize`],[`message-user-font-family`,`components-message-user-fontFamily`],[`message-user-line-height`,`components-message-user-lineHeight`],[`message-assistant-padding`,`components-message-assistant-padding`],[`message-assistant-border-width`,`components-message-assistant-borderWidth`],[`message-assistant-max-width`,`components-message-assistant-maxWidth`],[`message-assistant-font-size`,`components-message-assistant-fontSize`],[`message-assistant-font-family`,`components-message-assistant-fontFamily`],[`message-assistant-line-height`,`components-message-assistant-lineHeight`]]);let p=e.components;n(p?.iconButton,`icon-btn-`,[[`background`,`bg`],[`border`,`border`],[`color`,`color`],[`padding`,`padding`],[`borderRadius`,`radius`],[`hoverBackground`,`hover-bg`],[`hoverColor`,`hover-color`],[`activeBackground`,`active-bg`],[`activeBorder`,`active-border`]]),n(p?.labelButton,`label-btn-`,[[`background`,`bg`],[`border`,`border`],[`color`,`color`],[`padding`,`padding`],[`borderRadius`,`radius`],[`hoverBackground`,`hover-bg`],[`fontSize`,`font-size`],[`gap`,`gap`]]),n(p?.toggleGroup,`toggle-group-`,[[`gap`,`gap`],[`borderRadius`,`radius`]]);let m=p?.artifact;if(m?.toolbar){let r=m.toolbar;n(r,`artifact-toolbar-icon-`,[[`iconHoverColor`,`hover-color`],[`iconHoverBackground`,`hover-bg`],[`iconPadding`,`padding`],[`iconBorderRadius`,`radius`],[`iconBorder`,`border`]]),r.toggleGroupGap&&(t[`--persona-artifact-toolbar-toggle-group-gap`]=Ua(r.toggleGroupGap)),r.toggleBorderRadius&&(t[`--persona-artifact-toolbar-toggle-radius`]=r.toggleBorderRadius),r.toggleGroupPadding&&(t[`--persona-artifact-toolbar-toggle-group-padding`]=Ua(r.toggleGroupPadding)),n(r,`artifact-toolbar-toggle-group-`,[[`toggleGroupBorder`,`border`],[`toggleGroupBorderRadius`,`radius`]]),r.toggleGroupBackground&&(t[`--persona-artifact-toolbar-toggle-group-bg`]=Ra(e,r.toggleGroupBackground)??r.toggleGroupBackground),n(r,`artifact-toolbar-copy-`,[[`copyBackground`,`bg`],[`copyBorder`,`border`],[`copyColor`,`color`]]),r.copyBorderRadius&&(t[`--persona-artifact-toolbar-copy-radius`]=Ua(r.copyBorderRadius)),r.copyPadding&&(t[`--persona-artifact-toolbar-copy-padding`]=r.copyPadding),r.copyMenuBackground&&(t[`--persona-artifact-toolbar-copy-menu-bg`]=r.copyMenuBackground,t[`--persona-dropdown-bg`]=t[`--persona-dropdown-bg`]??r.copyMenuBackground),r.copyMenuBorder&&(t[`--persona-artifact-toolbar-copy-menu-border`]=r.copyMenuBorder,t[`--persona-dropdown-border`]=t[`--persona-dropdown-border`]??r.copyMenuBorder),r.copyMenuShadow&&(t[`--persona-artifact-toolbar-copy-menu-shadow`]=r.copyMenuShadow,t[`--persona-dropdown-shadow`]=t[`--persona-dropdown-shadow`]??r.copyMenuShadow),r.copyMenuBorderRadius&&(t[`--persona-artifact-toolbar-copy-menu-radius`]=r.copyMenuBorderRadius,t[`--persona-dropdown-radius`]=t[`--persona-dropdown-radius`]??r.copyMenuBorderRadius),r.copyMenuItemHoverBackground&&(t[`--persona-artifact-toolbar-copy-menu-item-hover-bg`]=r.copyMenuItemHoverBackground,t[`--persona-dropdown-item-hover-bg`]=t[`--persona-dropdown-item-hover-bg`]??r.copyMenuItemHoverBackground),n(r,`artifact-toolbar-`,[[`iconBackground`,`icon-bg`],[`toolbarBorder`,`border`]])}if(m?.tab){let e=m.tab;n(e,`artifact-tab-`,[[`background`,`bg`],[`activeBackground`,`active-bg`],[`activeBorder`,`active-border`],[`borderRadius`,`radius`],[`textColor`,`color`],[`hoverBackground`,`hover-bg`],[`listBackground`,`list-bg`],[`listBorderColor`,`list-border-color`],[`listPadding`,`list-padding`]])}if(m?.pane){let n=m.pane;n.toolbarBackground&&(t[`--persona-artifact-toolbar-bg`]=Ra(e,n.toolbarBackground)??n.toolbarBackground)}n(m?.card,`artifact-card-`,[[`background`,`bg`,!0],[`border`,`border`],[`borderRadius`,`radius`,!0],[`hoverBackground`,`hover-bg`,!0],[`hoverBorderColor`,`hover-border`,!0]]),n(m?.inline,`artifact-inline-`,[[`background`,`bg`,!0],[`border`,`border`],[`borderRadius`,`radius`,!0],[`chromeBackground`,`chrome-bg`,!0],[`chromeBorder`,`chrome-border`,!0],[`titleColor`,`title-color`,!0],[`mutedColor`,`muted-color`,!0],[`frameHeight`,`frame-height`]]);let h=p?.code;h&&(n(h,`code-`,[[`keywordColor`,`keyword-color`],[`stringColor`,`string-color`],[`commentColor`,`comment-color`],[`numberColor`,`number-color`],[`tagColor`,`tag-color`],[`attrColor`,`attr-color`],[`propertyColor`,`property-color`],[`lineNumberColor`,`line-number-color`],[`gutterBorderColor`,`gutter-border-color`]]),h.background&&(t[`--persona-code-bg`]=Ra(e,h.background)??h.background));let g=t[`--persona-surface`],_=t[`--persona-container`],v=t[`--persona-palette-colors-gray-100`]??`#f3f4f6`,y=t[`--persona-palette-colors-gray-200`]??`#e5e7eb`,b=t[`--persona-palette-colors-gray-300`]??`#d1d5db`,x=!_||_===g,S=Ga(g??t[`--persona-background`]),C=x&&S!==void 0&&S<.179,ee=C?`rgba(255, 255, 255, 0.08)`:v,w=C?`rgba(255, 255, 255, 0.12)`:y,T=C?`rgba(255, 255, 255, 0.16)`:b,te=x?ee:_,ne=x?w:_;return t[`--persona-icon-btn-hover-bg`]=t[`--persona-icon-btn-hover-bg`]??te,t[`--persona-icon-btn-active-bg`]=t[`--persona-icon-btn-active-bg`]??ne,x&&(t[`--persona-icon-btn-active-border`]=t[`--persona-icon-btn-active-border`]??T),t[`--persona-label-btn-hover-bg`]=t[`--persona-label-btn-hover-bg`]??te,t[`--persona-artifact-tab-hover-bg`]=t[`--persona-artifact-tab-hover-bg`]??te,t[`--persona-artifact-card-hover-bg`]=t[`--persona-artifact-card-hover-bg`]??te,t}const Qa=e=>!!e&&`launcher`in e&&(e.launcher?.sidebarMode===!0||e.launcher?.mountMode===`docked`),$a=(e,t)=>{if(!t||!Qa(t))return e;let n=t.theme?.components?.panel?.width,r=t.darkTheme?.components?.panel?.width;return(lo(t)===`dark`?r??n:n)==null?{...e,components:{...e.components,panel:{...e.components.panel,width:fe(t)===`v5`?`400px`:`420px`}}}:e},eo={colors:{primary:{50:`#ffffff`,100:`#f5f5f5`,200:`#d4d4d4`,300:`#a3a3a3`,400:`#737373`,500:`#171717`,600:`#0f0f0f`,700:`#0a0a0a`,800:`#050505`,900:`#030303`,950:`#000000`},secondary:{50:`#f5f3ff`,100:`#ede9fe`,200:`#ddd6fe`,300:`#c4b5fd`,400:`#a78bfa`,500:`#8b5cf6`,600:`#7c3aed`,700:`#6d28d9`,800:`#5b21b6`,900:`#4c1d95`,950:`#2e1065`},accent:{50:`#ecfeff`,100:`#cffafe`,200:`#a5f3fc`,300:`#67e8f9`,400:`#22d3ee`,500:`#06b6d4`,600:`#0891b2`,700:`#0e7490`,800:`#155e75`,900:`#164e63`,950:`#083344`},gray:{50:`#f9fafb`,100:`#f3f4f6`,200:`#e5e7eb`,300:`#d1d5db`,400:`#9ca3af`,500:`#6b7280`,600:`#4b5563`,700:`#374151`,800:`#1f2937`,900:`#111827`,950:`#030712`},success:{50:`#f0fdf4`,100:`#dcfce7`,200:`#bbf7d0`,300:`#86efac`,400:`#4ade80`,500:`#22c55e`,600:`#16a34a`,700:`#15803d`,800:`#166534`,900:`#14532d`},warning:{50:`#fefce8`,100:`#fef9c3`,200:`#fef08a`,300:`#fde047`,400:`#facc15`,500:`#eab308`,600:`#ca8a04`,700:`#a16207`,800:`#854d0e`,900:`#713f12`},error:{50:`#fef2f2`,100:`#fee2e2`,200:`#fecaca`,300:`#fca5a5`,400:`#f87171`,500:`#ef4444`,600:`#dc2626`,700:`#b91c1c`,800:`#991b1b`,900:`#7f1d1d`}}},to={components:{button:{ghost:{hoverBackground:`rgba(255, 255, 255, 0.08)`}},markdown:{link:{foreground:`palette.colors.primary.300`}},eventStream:{badge:{flow:{background:`palette.colors.success.900`,foreground:`palette.colors.success.300`},step:{background:`palette.colors.primary.800`,foreground:`palette.colors.primary.200`},reasoning:{background:`palette.colors.warning.900`,foreground:`palette.colors.warning.300`},tool:{background:`palette.colors.purple.900`,foreground:`palette.colors.purple.300`},agent:{background:`palette.colors.teal.900`,foreground:`palette.colors.teal.300`},error:{background:`palette.colors.error.900`,foreground:`palette.colors.error.300`},default:{background:`palette.colors.gray.800`,foreground:`palette.colors.gray.300`}}},history:{dangerForeground:`#f87171`,confirm:{dangerBackground:`palette.colors.error.600`,scrim:`rgba(0, 0, 0, 0.6)`}}}},no=eo,ro={...no,colors:{...no.colors,primary:{50:`#0f0f10`,100:`#27272a`,200:`#3f3f46`,300:`#52525b`,400:`#71717a`,500:`#f4f4f5`,600:`#e4e4e7`,700:`#d4d4d8`,800:`#a1a1aa`,900:`#fafafa`,950:`#ffffff`},gray:{50:`#1a1a1b`,100:`#27272a`,200:`#2a2a2d`,300:`#52525b`,400:`#71717a`,500:`#a1a1aa`,600:`#b4b4bd`,700:`#d4d4d8`,800:`#e4e4e7`,900:`#f4f4f5`,950:`#fafafa`}}},io=to,ao={semantic:{colors:{primary:`palette.colors.primary.500`,accent:`palette.colors.primary.600`,background:`#0f0f10`,surface:`palette.colors.gray.50`,container:`#1c1c20`,text:`palette.colors.gray.900`,textMuted:`palette.colors.gray.500`,textInverse:`#0f0f10`,border:`palette.colors.gray.200`,divider:`palette.colors.gray.200`,interactive:{default:`palette.colors.primary.600`,hover:`palette.colors.primary.700`,focus:`palette.colors.primary.600`,active:`palette.colors.primary.600`}}},components:{...to.components,button:{...to.components?.button,primary:{background:`semantic.colors.primary`,foreground:`palette.colors.primary.50`}},markdown:{inlineCode:{background:`palette.colors.gray.100`,foreground:`semantic.colors.text`},link:{foreground:`semantic.colors.accent`},codeBlock:{background:`semantic.colors.container`,borderColor:`semantic.colors.border`,textColor:`semantic.colors.text`},table:{headerBackground:`palette.colors.gray.100`,borderColor:`semantic.colors.border`},blockquote:{background:`semantic.colors.container`,borderColor:`palette.colors.gray.300`,textColor:`semantic.colors.textMuted`}},eventStream:{...to.components?.eventStream,badge:{...to.components?.eventStream?.badge,step:{background:`palette.colors.gray.100`,foreground:`palette.colors.gray.700`},default:{background:`palette.colors.gray.100`,foreground:`palette.colors.gray.700`}}}}},oo=e=>fe({future:e})===`v5`?{palette:ro,components:ao}:{palette:no,components:io},Y=e=>{if(e&&typeof e==`object`&&!Array.isArray(e))return e},so=()=>typeof document<`u`&&document.documentElement.classList.contains(`dark`)||typeof window<`u`&&window.matchMedia?.(`(prefers-color-scheme: dark)`).matches?`dark`:`light`,co=e=>{let t=e?.colorScheme??r(e?.brand)??`light`;return t===`light`?`light`:t===`dark`?`dark`:so()},lo=e=>co(e),uo=(e,t={})=>Ha(e,t),fo=(e,t={})=>{let n=oo(t.future),r=i(n.components,e??{})??{};return Ha({...r,palette:{...r.palette,colors:fe(t)===`v5`?i(n.palette.colors,r.palette?.colors):{...n.palette.colors,...r.palette?.colors}}},{validate:!1,future:t.future})},po=e=>{let n=lo(e),r=i(m(e?.brand,n,La(e?.future).components,e?.future?.v5Defaults),Y(e?.theme)),a=xa(e)===`circle`?Sa:{...Pa.launcher,...e?.future?.v5Defaults?{offset:`1.5rem`}:{}},o=tn(e),s=i({components:{launcher:a,...o?{panel:{background:`transparent`,modes:{inline:{border:`none`,shadow:`none`,borderRadius:`0`}}},header:{background:`transparent`},message:{background:`transparent`},composer:{footerBackground:`transparent`,footerBorder:`none`,overlayBand:`transparent`}}:{}}},r),c=Y(e?.darkTheme),u=$a(n===`dark`?fo(i(s??{},c??{}),{future:e?.future}):uo(s,{future:e?.future}),e);return Object.defineProperty(u,mo,{value:[...l,`suggestion.chip.padding`,`suggestion.chip.fontWeight`].filter(r=>t(e,r,n))}),u},mo=Symbol(`persona.themeConsumerPaths`),ho=e=>{let t=Za(e);t[`--persona-suggestion-compat-padding`]=`6px 12px`,t[`--persona-suggestion-compat-weight`]=`500`;for(let n of e[mo]??[]){let e=n.split(`.`).join(`-`),r=t[`--persona-components-${e}`];r!==void 0&&(t[n===`suggestion.chip.padding`?`--persona-suggestion-compat-padding`:n===`suggestion.chip.fontWeight`?`--persona-suggestion-compat-weight`:`--persona-consumer-${e}`]=r)}return t},go=/* @__PURE__ */ new WeakMap,_o=(e,t)=>{vo(e,ho(po(t)),t)},vo=(e,t,n)=>{for(let n of go.get(e)??[])n in t||e.style.removeProperty(n);go.set(e,Object.keys(t));for(let[n,r]of Object.entries(t))e.style.setProperty(n,r);e.setAttribute(`data-persona-color-scheme`,lo(n)),e.setAttribute(`data-persona-defaults`,fe(n))},yo=e=>{let t=[];if(typeof document<`u`&&typeof MutationObserver<`u`){let n=new MutationObserver(()=>{e(so())});n.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),t.push(()=>n.disconnect())}if(typeof window<`u`&&window.matchMedia){let n=window.matchMedia(`(prefers-color-scheme: dark)`),r=()=>e(so());n.addEventListener?(n.addEventListener(`change`,r),t.push(()=>n.removeEventListener(`change`,r))):n.addListener&&(n.addListener(r),t.push(()=>n.removeListener(r)))}return()=>{t.forEach(e=>e())}},bo=(e,t)=>e?.layout?.contentMaxWidth??(t?e?.launcher?.composerBar?.contentMaxWidth??`720px`:`768px`),xo=(e,t)=>t||e?.composer?.placement!==`overlay`?`block`:`overlay`,So=e=>{if(typeof e!=`string`)return null;let t=/^\s*(\d+(?:\.\d+)?)\s*%\s*$/.exec(e);if(!t)return null;let n=Number(t[1])/100;return n>0&&n<1?n:null},Co=e=>Math.max(0,Math.round(e.columnHeight*(1-e.fraction))-e.footerHeight),wo=()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgentData?.platform??navigator.platform??``;return/mac|iphone|ipad|ipod/i.test(e)},To=(e,t)=>{console.warn(`[persona] ${e} shortcut: ${t}`)},Eo=e=>{let t=e.toLowerCase().split(`+`).map(e=>e.trim()),n=t.pop(),r={key:n,mod:!1,shift:!1,alt:!1};for(let n of t)if(n===`mod`||n===`cmd`||n===`ctrl`)r.mod=!0;else if(n===`shift`)r.shift=!0;else if(n===`alt`||n===`option`)r.alt=!0;else return To(`unknown modifier in`,e),null;return!r.mod||r.shift&&r.alt||/^(enter|esc(ape)?)$/.test(n)||!/^([^+\s]|[a-z]{2,12})$/.test(n)?(To(`unsupported`,e),null):(n===`space`&&(r.key=` `),r)},Do=e=>`ArrowUp ArrowDown ArrowLeft ArrowRight PageUp PageDown Space`.split(` `).find(t=>t.toLowerCase()===e)??(e===` `?`Space`:e.length===1?e.toUpperCase():e[0].toUpperCase()+e.slice(1)),Oo=(e,t)=>{let n=Eo(e);if(!n)return``;let r=wo(),i=Do(n.key);if(!t&&r)return`${n.alt?`⌥`:``}${n.shift?`⇧`:``}⌘${i}`;let a=[t?r?`Meta`:`Control`:`Ctrl`];return n.alt&&a.push(`Alt`),n.shift&&a.push(`Shift`),a.push(i),a.join(`+`)},ko=e=>Oo(e,!1),Ao=e=>Oo(e,!0),jo=(e,t)=>t.key?.toLowerCase()===e.key&&(wo()?t.metaKey:t.ctrlKey)===e.mod&&!(wo()?t.ctrlKey:t.metaKey)&&t.shiftKey===e.shift&&t.altKey===e.alt,Mo=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable},No=e=>{let t=/* @__PURE__ */ new Map,n=e?.ownerDocument??(typeof document<`u`?document:null),r=(t,n)=>{if((t.scope??`widget`)===`page`)return!0;if(!e)return!1;let r=n.composedPath?.();return r?.length?r.includes(e):e.contains(n.target)},i=e=>{if(e.isComposing||!t.size)return;let n=e.composedPath?.()[0]??e.target;for(let i of t.values())if(jo(i.parsed,e)&&i.when?.()!==!1&&r(i,e)&&(i.allowInInput||!Mo(n))){e.preventDefault();try{i.run(e)}catch(e){To(`${i.id} threw on`,i.combo),console.warn(e)}return}};return n?.addEventListener(`keydown`,i),{register(e){let n=Eo(e.combo);if(!n)return()=>{};let r=`${n.mod?`m`:``}${n.shift?`s`:``}${n.alt?`a`:``}${n.key}`,i=t.get(r);return i?(To(`${i.id} already owns`,e.combo),()=>{}):(t.set(r,{...e,parsed:n}),e.element?.setAttribute(`aria-keyshortcuts`,Ao(e.combo)),()=>{t.get(r)?.id===e.id&&t.delete(r),e.element?.removeAttribute(`aria-keyshortcuts`)})},destroy(){t.clear(),n?.removeEventListener(`keydown`,i)}}},Po=(e,t,n={})=>{let{preserveTypingAnimation:r=!0}=n;On.morph(e,t.innerHTML,{morphStyle:`innerHTML`,callbacks:{beforeNodeMorphed(e,t){if(e instanceof HTMLElement){if(t instanceof HTMLElement&&t.hasAttribute(`data-persona-reuse`)&&e.id===t.id)return!1;if(r){if(e.classList.contains(`persona-animate-typing`)||e.hasAttribute(`data-preserve-runtime`))return!1;if(e.hasAttribute(`data-tool-elapsed`))return t instanceof HTMLElement&&t.getAttribute(`data-tool-elapsed`)===e.getAttribute(`data-tool-elapsed`)?!1:void 0;if(e.hasAttribute(`data-preserve-animation`))return t instanceof HTMLElement&&(!t.hasAttribute(`data-preserve-animation`)||(e.dataset.personaLoadingLabel?e.dataset.personaLoadingAnimation!==t.dataset.personaLoadingAnimation:e.textContent!==t.textContent))&&void 0}}}}})},Fo=e=>e.replace(/^\n+/,``).replace(/\s+$/,``),Io={index:-1,draft:``};function Lo(e){let{direction:t,history:n,currentValue:r,atStart:i,state:a}=e,o=a.index!==-1;if(n.length===0)return{handled:!1,state:a};if(t===`up`){if(!o&&!i)return{handled:!1,state:a};if(!o){let e=n.length-1;return{handled:!0,value:n[e],state:{index:e,draft:r}}}if(a.index>0){let e=a.index-1;return{handled:!0,value:n[e],state:{index:e,draft:a.draft}}}return{handled:!0,state:a}}if(!o)return{handled:!1,state:a};if(a.index<n.length-1){let e=a.index+1;return{handled:!0,value:n[e],state:{index:e,draft:a.draft}}}return{handled:!0,value:a.draft,state:{index:-1,draft:a.draft}}}const Ro=/* @__PURE__ */ new WeakMap;function zo(e){if(typeof e==`string`)return e.length;if(!e)return 0;if(typeof e!=`object`)return JSON.stringify(e)?.length??0;let t=Ro.get(e);return t===void 0&&(t=JSON.stringify(e)?.length??0,Ro.set(e,t)),t}function Bo(e,t){return[e.id,e.role,e.content?.length??0,e.content?.slice(-32)??``,e.streaming?`1`:`0`,e.voiceProcessing?`1`:`0`,e.variant??``,e.dispatchError?`1`:`0`,e.rawContent?.length??0,e.llmContent?.length??0,e.approval?.status??``,e.toolCall?.status??``,e.toolCall?.name??``,e.toolCall?.chunks?.length??0,e.toolCall?.chunks?.[e.toolCall.chunks.length-1]?.slice(-32)??``,zo(e.toolCall?.args),e.reasoning?.chunks?.length??0,e.reasoning?.chunks?.[e.reasoning.chunks.length-1]?.length??0,e.reasoning?.chunks?.[e.reasoning.chunks.length-1]?.slice(-32)??``,e.contentParts?.length??0,e.stopReason??``,e.toolCall?.actionTitle??``,t].join(`\0`)}function Vo(){return/* @__PURE__ */ new Map}function Ho(e,t,n){let r=e.get(t);return r&&r.fingerprint===n?r.wrapper:null}function Uo(e,t,n,r){e.set(t,{fingerprint:n,wrapper:r})}function Wo(e,t){for(let n of e.keys())t.has(n)||e.delete(n)}const{setLoader:Go,load:Ko}=v({fallbackImport:()=>import(`./chunk-Dg7uqL8l.js`)}),qo=Ko;function Jo(e,t=Ke){let n=e.style.position,r=e.style.zIndex,i=e.style.isolation,a=getComputedStyle(e),o=a.position===`static`||a.position===``;return o&&(e.style.position=`relative`),e.style.zIndex=String(t),e.style.isolation=`isolate`,()=>{o&&(e.style.position=n),e.style.zIndex=r,e.style.isolation=i}}let Yo=0,Xo=null;function Zo(e=document){if(Yo++,Yo===1){let t=e.body,n=(e.defaultView??window).scrollY||e.documentElement.scrollTop;Xo={originalOverflow:t.style.overflow,originalPosition:t.style.position,originalTop:t.style.top,originalWidth:t.style.width,scrollY:n},t.style.overflow=`hidden`,t.style.position=`fixed`,t.style.top=`-${n}px`,t.style.width=`100%`}let t=!1;return()=>{if(!t&&(t=!0,Yo=Math.max(0,Yo-1),Yo===0&&Xo)){let t=e.body,n=e.defaultView??window;t.style.overflow=Xo.originalOverflow,t.style.position=Xo.originalPosition,t.style.top=Xo.originalTop,t.style.width=Xo.originalWidth,n.scrollTo(0,Xo.scrollY),Xo=null}}}const Qo={side:`right`,width:`420px`,animate:!0,reveal:`resize`,maxHeight:`100dvh`},$o=e=>(e?.launcher?.mountMode??`floating`)===`docked`,es=e=>(e?.launcher?.mountMode??`floating`)===`composer-bar`,ts=e=>{let t=e?.launcher?.dock,n=nn(e).dockWidth?t?.width:Ra(po(e),`components.panel.width`);return{side:t?.side??Qo.side,width:n??Qo.width,animate:t?.animate??Qo.animate,reveal:t?.reveal??Qo.reveal,maxHeight:t?.maxHeight??Qo.maxHeight}},ns=e=>e.closest(`[data-persona-instance]`)?.dataset.personaInstance,rs=e=>e===`followUp`?`follow-up`:e,is=(e,t=0)=>{if(typeof e==`string`){let t=e.trim();return t?{id:t,label:t,prompt:t,emphasis:`default`}:null}let n=e.label.trim();if(!n)return null;let r=e.prompt?.trim()||n;return{id:e.id?.trim()||r||`suggestion-${t}`,label:n,prompt:r,description:e.description?.trim()||void 0,icon:e.icon,iconColor:e.iconColor?.trim()||void 0,behavior:e.behavior,emphasis:e.emphasis??`default`}},as=/* @__PURE__ */ new WeakSet,os=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,ss=e=>{os()||e.forEach((e,t)=>{typeof e.animate==`function`&&e.animate([{opacity:`0`,transform:`translateY(4px)`},{opacity:`1`,transform:`none`}],{duration:250,delay:t*60,easing:`ease-out`,fill:`backwards`})})},cs=e=>{let{item:n,index:r,surface:i,source:a,variant:o,streaming:c,config:l,plugins:u,chipsConfig:d,session:f,getTextarea:p,eventTarget:m,submitPrompt:h}=e,g=i===`followUp`,_=n.behavior,v=()=>{if(f.isStreaming()||m.closest(`[inert]`))return;let e={instanceId:ns(m),suggestion:{...n},surface:i,source:a,behavior:_},t=m.dispatchEvent(new CustomEvent(`persona:suggestion:selected`,{detail:e,bubbles:!0,composed:!0,cancelable:!0}));if(g&&m.dispatchEvent(new CustomEvent(`persona:suggestReplies:selected`,{detail:{instanceId:ns(m),suggestion:n.prompt},bubbles:!0,composed:!0})),!t)return;for(let e of u)if(e.onSuggestionSelect?.({suggestion:{...n},surface:i,source:a,variant:o,config:l})===!1)return;let r=p();_===`fill`?(r.value=n.prompt,r.dispatchEvent(new Event(`input`,{bubbles:!0,composed:!0})),r.focus()):h?h(n.prompt):(r.value=``,f.sendMessage(n.prompt))},y=()=>{let e=k(`button`,`persona-suggestion persona-suggestion--${o}`);if(e.type=`button`,e.disabled=c,e.dataset.suggestionId=n.id,e.dataset.emphasis=n.emphasis,e.dataset.behavior=_,o===`chip`){let n=l.suggestionChipsConfig===d?l:{suggestionChipsConfig:d},r=e=>s(n,`suggestionChipsConfig.${e}`),i=e=>t(l,`suggestion.chip.${e}`,`light`)||t(l,`suggestion.chip.${e}`,`dark`);d?.fontWeight&&(e.style.fontWeight=!r(`fontWeight`)&&i(`fontWeight`)?`var(--persona-suggestion-compat-weight, 500)`:d.fontWeight);let a=i(`padding`);a&&(e.classList.add(`persona-theme-padding`),e.style.setProperty(`--persona-theme-padding`,`var(--persona-suggestion-compat-padding, 6px 12px)`)),d?.paddingX&&(r(`paddingX`)||!a)&&(e.style.paddingLeft=d.paddingX,e.style.paddingRight=d.paddingX),d?.paddingY&&(r(`paddingY`)||!a)&&(e.style.paddingTop=d.paddingY,e.style.paddingBottom=d.paddingY)}if(n.icon){let t=T(n.icon,`var(--persona-suggestion-icon-size)`,`currentColor`,1.8);t&&(t.classList.add(`persona-suggestion__icon`),n.iconColor&&(t.style.color=n.iconColor),e.appendChild(t))}let r=k(`span`,`persona-suggestion__copy`);if(r.appendChild(O(`span`,{className:`persona-suggestion__label`,text:n.label})),n.description&&o!==`chip`&&r.appendChild(O(`span`,{className:`persona-suggestion__description`,text:n.description})),e.appendChild(r),o!==`chip`){let t=b(vn,16,`currentColor`,1.8);t&&(t.classList.add(`persona-suggestion__arrow`),e.appendChild(t))}return e.addEventListener(`click`,v),e},x=null;for(let e of u)if(e.renderSuggestion&&(x=e.renderSuggestion({suggestion:{...n},index:r,surface:i,source:a,variant:o,streaming:c,config:l,defaultRenderer:y,select:v}),x))break;return x??=y(),x.dataset.suggestionId||=n.id,x.dataset.behavior||=_,x.dataset.emphasis||=n.emphasis,x instanceof HTMLButtonElement||x.setAttribute(`aria-disabled`,c?`true`:`false`),x},ls=e=>{let t=[],n=[],r=null,i=null,a=()=>{e.removeAttribute(`data-scroll-left`),e.removeAttribute(`data-scroll-right`)},o=()=>{if(i=null,e.toggleAttribute(`data-edge-to-edge`,e.hasAttribute(`data-hide-scrollbar`)&&(e.hasAttribute(`data-persona-composer-suggestions`)||e.dataset.personaSuggestions===`follow-up`)&&e.dataset.variant===`chip`&&e.dataset.overflow===`scroll`),e.hasAttribute(`data-edge-to-edge`)&&e.parentElement){let t=e.parentElement,n=getComputedStyle(t),r=parseFloat(n.paddingLeft)||0,i=parseFloat(n.paddingRight)||0;e.style.setProperty(`--persona-suggestion-bleed-left`,`${r}px`),e.style.setProperty(`--persona-suggestion-bleed-right`,`${i}px`);let a=t.closest(`.persona-widget-container`)?.querySelector(`form`),o=t.getBoundingClientRect(),s=a?.getBoundingClientRect();e.style.setProperty(`--persona-suggestion-inset-left`,`${s?.width?s.left-o.left:r}px`),e.style.setProperty(`--persona-suggestion-inset-right`,`${s?.width?o.right-s.right:i}px`)}if(e.hidden||e.dataset.variant!==`chip`||e.dataset.overflow!==`scroll`){a();return}let t=Math.max(0,e.scrollWidth-e.clientWidth);if(t<=1){a();return}let n=getComputedStyle(e).direction===`rtl`,r=Math.min(t,Math.max(0,Math.abs(e.scrollLeft))),o=r<=4,s=r>=t-4,c=n?!s:!o,l=n?!o:!s;e.toggleAttribute(`data-scroll-left`,c),e.toggleAttribute(`data-scroll-right`,l)},s=()=>{i!==null||typeof requestAnimationFrame!=`function`?typeof requestAnimationFrame!=`function`&&o():i=requestAnimationFrame(o)};e.addEventListener(`scroll`,s,{passive:!0});let c=typeof ResizeObserver==`function`?new ResizeObserver(s):null;return c?.observe(e),{buttons:t,elements:n,destroy:()=>{e.removeEventListener(`scroll`,s),c?.disconnect(),i!==null&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(i),i=null},render:(i,c,l,u,d,f)=>{e.replaceChildren(),t.length=0,n.length=0;let p=f?.source??`config`,m=f?.surface??(p===`config`?`starter`:`followUp`),h=m===`followUp`,g=f?.variant??`chip`,_=f?.behavior??`send`,v=f?.overflow??`wrap`,y=f?.config??{},b=f?.plugins??[];e.toggleAttribute(`data-hide-scrollbar`,y.future?.v5Defaults===!0),e.dataset.edgeStyle=y.suggestions?.[h?`followUps`:`starters`]?.edgeStyle??`fade`;let x=typeof f?.maxItems==`number`?Math.max(0,Math.floor(f.maxItems)):void 0,S=h?`followUps`:`starters`;!as.has(y)&&y.debug===!0&&g!==`chip`&&y.suggestions?.[S]?.overflow!==void 0&&(as.add(y),console.info(`[persona] suggestions.${S}.overflow applies to the "chip" variant only; the "${g}" variant manages its own stacking.`));let C=e=>e.map(is).filter(e=>e!==null).map(e=>({...e,behavior:e.behavior??_})),ee=C(i??[]);b.forEach(e=>{e.transformSuggestions&&(ee=C(e.transformSuggestions({suggestions:ee.map(e=>({...e})),surface:m,source:p,config:y})))});let w=x===void 0?ee:ee.slice(0,x);if(!w.length){e.hidden=!0,r=null,a();return}if(!h&&(u??c.getMessages()).some(e=>e.role===`user`)){e.hidden=!0,r=null;return}e.hidden=!1,e.classList.add(`persona-suggestions`),e.dataset.personaSuggestionSurface=rs(m),e.dataset.variant=g,e.dataset.overflow=v;let T=document.createDocumentFragment(),te=c.isStreaming();w.forEach((r,i)=>{let a=cs({item:r,index:i,surface:m,source:p,variant:g,streaming:te,config:y,plugins:b,chipsConfig:d,session:c,getTextarea:()=>l,eventTarget:e,submitPrompt:f?.submitPrompt});T.appendChild(a),n.push(a),[...a instanceof HTMLButtonElement?[a]:[],...Array.from(a.querySelectorAll(`button`))].forEach(e=>{t.includes(e)||(e.disabled=te,t.push(e))})}),e.appendChild(T),o(),s();let ne=JSON.stringify({normalized:w,surface:m,variant:g,source:p});ne!==r&&(r=ne,ss(n),e.dispatchEvent(new CustomEvent(`persona:suggestion:shown`,{detail:{instanceId:ns(e),suggestions:w.map(e=>({...e})),surface:m,source:p,variant:g},bubbles:!0,composed:!0})),h&&e.dispatchEvent(new CustomEvent(`persona:suggestReplies:shown`,{detail:{instanceId:ns(e),suggestions:w.map(e=>e.prompt)},bubbles:!0,composed:!0})))}}},us={"bottom-right":`persona-bottom-6 persona-right-6`,"bottom-left":`persona-bottom-6 persona-left-6`,"top-right":`persona-top-6 persona-right-6`,"top-left":`persona-top-6 persona-left-6`},ds={x:[1.4,1.05]},fs=`persona-relative persona-ml-auto persona-inline-flex persona-items-center persona-justify-center`,ps=(e,t,n={})=>{let{iconSize:r,iconText:i}=n,[a,o]=ds[t]??[1,1.5],s=!r;e.classList.toggle(`persona-header-control--glyph`,s),e.classList.toggle(`persona-header-control--sparse`,s&&a!==1);let c=T(t,`${Math.round((parseFloat(r??``)||16)*a)}px`,`currentColor`,o);c?(c.style.display=`block`,s||(c.style.strokeWidth=`calc(var(--persona-components-header-controlStrokeWidth, 1.5) * ${Number((o/1.5).toFixed(4))})`),e.replaceChildren(c)):i&&(e.textContent=i)},ms=e=>{let{ariaLabel:t,tooltip:n=!0,tooltipHint:r,iconName:i,iconText:a,wrapperClassName:o=fs,size:s,iconSize:c,color:l,backgroundColor:u,borderWidth:d,borderColor:f,borderRadius:p,paddingX:m,paddingY:h,hidden:g,extraClassName:_,attrs:v}=e,y=k(`div`,o),b=!!(d||f),x=O(`button`,{className:We(`persona-header-control`,`persona-inline-flex persona-items-center persona-justify-center persona-cursor-pointer`,!u&&`persona-bg-transparent hover:persona-bg-gray-100`,!b&&`persona-border-none`,!p&&`persona-rounded-full`,_),attrs:{type:`button`,"aria-label":t,...v},style:{width:s,height:s,minWidth:s,minHeight:s,display:g?`none`:void 0,color:l||vs.actionIconColor,backgroundColor:u,border:b?`${d||`0px`} solid ${f||`transparent`}`:void 0,borderRadius:p,paddingLeft:m,paddingRight:m,paddingTop:h,paddingBottom:h}});return i?ps(x,i,{iconSize:c,iconText:a}):a&&(x.textContent=a),y.appendChild(x),Ee({anchor:x,trigger:y,text:()=>x.getAttribute(`aria-label`)??t,hint:r,enabled:n}),{button:x,wrapper:y}},hs=(e,t,n,r={})=>{let i=t?.launcher,a=i?.clearChat,o=e=>n===`close`?`launcher.closeButton${e[0].toUpperCase()}${e.slice(1)}`:`launcher.clearChat.${e===`color`?`iconColor`:e}`,s=e=>le(t,o(e)),c=(e,r)=>De(t,`header.${n}`,e,r),l=(e,t,n)=>s(e)||c(t,n),u=r.buttonSize||s(`size`);D(e,u||c(`size`,`var(--persona-header-control-size, 32px)`),u),!u&&c(`size`,``)===``&&(e.style.width=e.style.height=``);let d=n===`close`?i?.closeButtonBackgroundColor:a?.backgroundColor;e.style.color=l(`color`,`foreground`,vs.actionIconColor),e.style.backgroundColor=s(`backgroundColor`)||(c(`background`,``)?c(`background`,d||`transparent`):d||``),e.classList.toggle(`hover:persona-bg-gray-100`,!d&&!s(`backgroundColor`)&&c(`background`,``)===``);let f=n===`close`?i?.closeButtonBorderWidth:a?.borderWidth,p=n===`close`?i?.closeButtonBorderColor:a?.borderColor,m=!!(f||p||c(`borderWidth`,``)||c(`borderColor`,``));e.style.border=m?`${l(`borderWidth`,`borderWidth`,f||`0px`)} solid ${l(`borderColor`,`borderColor`,p||`transparent`)}`:``,e.classList.toggle(`persona-border-none`,!m);let h=n===`close`?i?.closeButtonBorderRadius:a?.borderRadius;e.style.borderRadius=s(`borderRadius`)||(c(`borderRadius`,``)?c(`borderRadius`,`var(--persona-components-header-controlBorderRadius, 9999px)`):h||``),e.classList.toggle(`persona-rounded-full`,!e.style.borderRadius);let g=n===`close`?i?.closeButtonPaddingX:a?.paddingX,_=n===`close`?i?.closeButtonPaddingY:a?.paddingY,v=c(`padding`,`0px`);se(e,v,s(`paddingX`)||(v===`0px`?g:void 0),s(`paddingY`)||(v===`0px`?_:void 0));let y=n===`close`?i?.closeButtonIconName??`x`:a?.iconName??`refresh-cw`;ps(e,y,{iconSize:r.iconSize,iconText:n===`close`?i?.closeButtonIconText??`×`:void 0});let b=e.querySelector(`svg`);if(b){let e=ds[y]?.[0]??1,t=c(`iconSize`,``);!r.iconSize&&t&&(b.style.width=b.style.height=`calc(${c(`iconSize`,`var(--persona-header-control-icon-size, 16px)`)} * ${e})`),c(`iconStrokeWidth`,``)&&(b.style.strokeWidth=`calc(${c(`iconStrokeWidth`,`var(--persona-components-header-controlStrokeWidth, 1.5)`)} * ${e===1?1:.7})`)}},gs=(e,t={})=>{let{showClose:n=!0,wrapperClassName:r=fs,buttonSize:i,iconSize:a}=t,o=e?.launcher??{},s=o.closeButtonTooltipText??`Close chat`,c=o.closeButtonShowTooltip??!0,{button:l,wrapper:u}=ms({ariaLabel:s,tooltip:c,iconName:o.closeButtonIconName??`x`,iconText:o.closeButtonIconText??`×`,wrapperClassName:r,size:i??o.closeButtonSize,iconSize:a,color:o.closeButtonColor,backgroundColor:o.closeButtonBackgroundColor,borderWidth:o.closeButtonBorderWidth,borderColor:o.closeButtonBorderColor,borderRadius:o.closeButtonBorderRadius,paddingX:o.closeButtonPaddingX,paddingY:o.closeButtonPaddingY,hidden:!n});return hs(l,e,`close`,{buttonSize:i,iconSize:a}),{button:l,wrapper:u}},_s=(e,t={})=>{let{wrapperClassName:n=`persona-relative persona-ml-auto persona-clear-chat-button-wrapper`,buttonSize:r,iconSize:i}=t,a=(e?.launcher??{}).clearChat??{},o=a.tooltipText??`Clear chat`,s=a.showTooltip??!0,{button:c,wrapper:l}=ms({ariaLabel:o,tooltip:s,iconName:a.iconName??`refresh-cw`,wrapperClassName:n,size:r??a.size,iconSize:i,color:a.iconColor,backgroundColor:a.backgroundColor,borderWidth:a.borderWidth,borderColor:a.borderColor,borderRadius:a.borderRadius,paddingX:a.paddingX,paddingY:a.paddingY});return hs(c,e,`clear`,{buttonSize:r,iconSize:i}),{button:c,wrapper:l}},vs={titleColor:`var(--persona-header-title-fg, var(--persona-primary, #0f0f0f))`,subtitleColor:`var(--persona-header-subtitle-fg, var(--persona-text-muted, var(--persona-muted, #9ca3af)))`,actionIconColor:`var(--persona-header-control-state-fg, var(--persona-header-action-icon-fg, var(--persona-muted, #9ca3af)))`,minHeight:`var(--persona-header-min-height, auto)`},ys={fontFamily:`var(--persona-components-header-title-fontFamily, inherit)`,fontSize:`var(--persona-components-header-title-fontSize, 1rem)`,fontWeight:`var(--persona-components-header-title-fontWeight, 600)`,lineHeight:`var(--persona-components-header-title-lineHeight, 1.5rem)`,letterSpacing:`var(--persona-components-header-title-letterSpacing, normal)`},bs={fontFamily:`var(--persona-components-header-subtitle-fontFamily, inherit)`,fontSize:`var(--persona-components-header-subtitle-fontSize, 0.75rem)`,fontWeight:`var(--persona-components-header-subtitle-fontWeight, inherit)`,lineHeight:`var(--persona-components-header-subtitle-lineHeight, 1rem)`,letterSpacing:`var(--persona-components-header-subtitle-letterSpacing, normal)`},xs=e=>{let{config:t,showClose:n=!0}=e,r=O(`div`,{className:`persona-widget-header persona-flex persona-items-center persona-gap-3`,attrs:{"data-persona-theme-zone":`header`},style:{padding:`var(--persona-components-header-padding, 20px 24px)`,minHeight:vs.minHeight,backgroundColor:`var(--persona-header-bg, var(--persona-surface, #ffffff))`,borderBottomColor:`var(--persona-header-border, var(--persona-divider, #f1f5f9))`,boxShadow:`var(--persona-header-shadow, none)`,borderBottom:`var(--persona-header-border-bottom, 1px solid var(--persona-header-border, var(--persona-divider, #f1f5f9)))`}}),i=t?.launcher??{},a=i.headerIconSize??`40px`,o=i.closeButtonPlacement??`inline`,s=i.headerIconHidden??!1,c=i.headerIconName,l=O(`div`,{className:`persona-flex persona-items-center persona-justify-center persona-rounded-xl persona-text-xl`,style:{height:a,width:a,boxSizing:`content-box`,padding:`var(--persona-components-header-iconPadding, 0px)`,flexShrink:`0`,backgroundColor:`var(--persona-header-icon-bg, var(--persona-primary, #0f0f0f))`,color:`var(--persona-header-icon-fg, var(--persona-text-inverse, #ffffff))`}});if(!s){if(c){let e=parseFloat(a)||24,n=T(c,e*.6,`currentColor`,1);n?(n.style.width=`calc(${e}px * var(--persona-components-header-iconScale, 0.6))`,n.style.height=`calc(${e}px * var(--persona-components-header-iconScale, 0.6))`,l.replaceChildren(n)):l.textContent=t?.launcher?.agentIconText??`💬`}else if(t?.launcher?.iconUrl){let e=k(`img`);e.src=t.launcher.iconUrl,e.alt=``,e.className=`persona-rounded-xl persona-object-cover`,e.style.height=a,e.style.width=a,l.replaceChildren(e)}else l.textContent=t?.launcher?.agentIconText??`💬`}let u=k(`div`,`persona-flex persona-flex-col persona-flex-1 persona-min-w-0`),d=O(`span`,{className:`persona-text-base persona-font-semibold`,text:t?.launcher?.title??`Chat Assistant`,style:{color:vs.titleColor,...ys}}),f=O(`span`,{className:`persona-text-xs`,text:t?.launcher?.subtitle??`Here to help you get answers fast`,style:{color:vs.subtitleColor,...bs}});u.append(d,f),s?r.append(u):r.append(l,u);let p=i.clearChat??{},m=p.enabled??!0,h=p.placement??`inline`,g=null,_=null;if(m){let e=_s(t,{wrapperClassName:h===`top-right`?`persona-absolute persona-top-4 persona-z-50`:`persona-relative persona-ml-auto persona-clear-chat-button-wrapper`});g=e.button,_=e.wrapper,h===`top-right`&&(_.style.right=`48px`),h===`inline`&&r.appendChild(_)}let{button:v,wrapper:y}=gs(t,{showClose:n,wrapperClassName:o===`top-right`?`persona-absolute persona-top-4 persona-right-4 persona-z-50`:m&&h===`inline`?`persona-relative persona-inline-flex persona-items-center persona-justify-center`:`persona-relative persona-ml-auto persona-inline-flex persona-items-center persona-justify-center`});return o!==`top-right`&&r.appendChild(y),{header:r,iconHolder:l,headerTitle:d,headerSubtitle:f,closeButton:v,closeButtonWrapper:y,clearChatButton:g,clearChatButtonWrapper:_}},Ss=(e,t,n)=>{let r=n?.launcher??{},i=r.closeButtonPlacement??`inline`,a=r.clearChat?.placement??`inline`;e.appendChild(t.header),i===`top-right`&&(e.style.position=`relative`,e.appendChild(t.closeButtonWrapper)),t.clearChatButtonWrapper&&a===`top-right`&&(e.style.position=`relative`,e.appendChild(t.clearChatButtonWrapper))},Cs=e=>{let t=xs({config:e.config,showClose:e.showClose,onClose:e.onClose,onClearChat:e.onClearChat}),n=e.layoutHeaderConfig?.onTitleClick;if(n){let e=t.headerTitle.parentElement;e&&(e.style.cursor=`pointer`,e.setAttribute(`role`,`button`),e.setAttribute(`tabindex`,`0`),e.addEventListener(`click`,()=>n()),e.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())}))}return t};function ws(e,t,n){if(t?.length)for(let r of t){let{button:t,wrapper:i}=ms({ariaLabel:r.ariaLabel??r.label??r.id,iconName:r.icon,iconText:r.icon?void 0:r.label,tooltipHint:r.shortcut?ko(r.shortcut):void 0,wrapperClassName:`persona-relative persona-inline-flex persona-items-center persona-justify-center`});if(t.setAttribute(`data-persona-header-action`,r.id),r.shortcut){let e=Ao(r.shortcut);e&&t.setAttribute(`aria-keyshortcuts`,e)}if(r.menuItems?.length){let e=tr({items:r.menuItems,onSelect:e=>n?.(e),anchor:i,position:`bottom-right`});i.appendChild(e.element),t.addEventListener(`click`,t=>{t.stopPropagation(),e.toggle()})}else t.addEventListener(`click`,()=>n?.(r.id));e.appendChild(i)}}const Ts={default:Cs,minimal:e=>{let{config:t,showClose:n=!0,onClose:r,layoutHeaderConfig:i,onHeaderAction:a}=e,o=t?.launcher??{},s=k(`div`,`persona-flex persona-items-center persona-justify-between`);s.setAttribute(`data-persona-theme-zone`,`header`),s.style.minHeight=vs.minHeight,s.style.padding=`var(--persona-components-header-minimalPadding, var(--persona-components-header-padding, 16px 24px))`,s.style.backgroundColor=`var(--persona-header-bg, var(--persona-surface, #ffffff))`,s.style.borderBottomColor=`var(--persona-header-border, var(--persona-divider, #f1f5f9))`,s.style.boxShadow=`var(--persona-header-shadow, none)`,s.style.borderBottom=`var(--persona-header-border-bottom, 1px solid var(--persona-header-border, var(--persona-divider, #f1f5f9)))`;let c=i?.titleMenu,l,u;if(c){let e=V({label:o.title??`Chat Assistant`,menuItems:c.menuItems,onSelect:t=>{let n=n=>{n===!1&&e.element.dispatchEvent(new CustomEvent(`persona:title-menu-builtin`,{bubbles:!0,composed:!0,detail:{actionId:t,instanceId:e.element.closest(`[data-persona-instance]`)?.dataset.personaInstance}}))},r=c.onSelect(t);r instanceof Promise?r.then(n,()=>{}):n(r)},hover:c.hover,className:``});l=e.element,l.style.color=vs.titleColor,u=l.querySelector(`.persona-combo-btn-label`)??l}else{if(l=k(`div`,`persona-flex persona-min-w-0 persona-flex-1 persona-items-center persona-gap-1`),u=k(`span`,`persona-text-base persona-font-semibold persona-truncate`),u.style.color=vs.titleColor,Object.assign(u.style,ys),u.textContent=o.title??`Chat Assistant`,l.appendChild(u),i?.onTitleClick){l.style.cursor=`pointer`,l.setAttribute(`role`,`button`),l.setAttribute(`tabindex`,`0`);let e=i.onTitleClick;l.addEventListener(`click`,t=>{t.target.closest(`button`)||e()}),l.addEventListener(`keydown`,t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())})}let e=i?.titleRowHover;e&&(l.style.borderRadius=e.borderRadius??`10px`,l.style.padding=e.padding??`6px 4px 6px 12px`,l.style.margin=`-6px 0 -6px -12px`,l.style.border=`1px solid transparent`,l.style.transition=`background-color 0.15s ease, border-color 0.15s ease`,l.style.width=`fit-content`,l.style.flex=`none`,l.addEventListener(`mouseenter`,()=>{l.style.backgroundColor=e.background??``,l.style.borderColor=e.border??``}),l.addEventListener(`mouseleave`,()=>{l.style.backgroundColor=``,l.style.borderColor=`transparent`}))}s.appendChild(l);let d=`persona-relative persona-inline-flex persona-items-center persona-justify-center`,{button:f,wrapper:p}=gs(t,{showClose:n,wrapperClassName:d});r&&f.addEventListener(`click`,r);let m=k(`div`,`persona-flex persona-items-center persona-gap-1`);c||ws(m,i?.trailingActions,i?.onAction??a);let h=o.clearChat??{},g=null,_=null;if(h.enabled??!0){let e=h.placement??`inline`,n=_s(t,{wrapperClassName:e===`top-right`?`persona-absolute persona-top-4 persona-z-50`:d});g=n.button,_=n.wrapper,e===`top-right`?_.style.right=`48px`:m.appendChild(_)}m.appendChild(p),s.appendChild(m);let v=k(`div`);v.style.display=`none`;let y=k(`span`);return y.style.display=`none`,{header:s,iconHolder:v,headerTitle:u,headerSubtitle:y,closeButton:f,closeButtonWrapper:p,clearChatButton:g,clearChatButtonWrapper:_}}},Es=e=>Ts[e]??Ts.default,Ds=(e,t,n)=>{if(t?.render){let r=t.render({config:e,onClose:n?.onClose,onClearChat:n?.onClearChat,trailingActions:t.trailingActions,onAction:t.onAction}),i=k(`div`);i.style.display=`none`;let a=k(`span`),o=k(`span`),s=k(`button`);s.style.display=`none`;let c=k(`div`);return c.style.display=`none`,{header:r,iconHolder:i,headerTitle:a,headerSubtitle:o,closeButton:s,closeButtonWrapper:c,clearChatButton:null,clearChatButtonWrapper:null}}let r=t?.layout??`default`,i=Es(r)({config:e,showClose:t?.showCloseButton??n?.showClose??!0,onClose:n?.onClose,onClearChat:n?.onClearChat,layoutHeaderConfig:t,onHeaderAction:t?.onAction});return t&&(t.showIcon===!1&&(i.iconHolder.style.display=`none`),t.showTitle===!1&&(i.headerTitle.style.display=`none`),t.showSubtitle===!1&&(i.headerSubtitle.style.display=`none`),t.showCloseButton===!1&&(i.closeButton.style.display=`none`),t.showClearChat===!1&&i.clearChatButtonWrapper&&(i.clearChatButtonWrapper.style.display=`none`)),i};function Os(e,t){if(!t.defaultPrevented){for(let n of t.composedPath()){if(n===e)break;if(n instanceof Element&&n.matches(`button, input, textarea, select, a[href], label, [contenteditable]:not([contenteditable="false"]), [role="button"], [role="link"], [role="checkbox"], [role="radio"], [role="combobox"], [tabindex]`))return}(e.querySelector(`[data-persona-composer-input][contenteditable="true"]`)??e.querySelector(`textarea[data-persona-composer-input]`))?.focus()}}const ks=e=>{let{config:t}=e,n=O(`div`,{className:`persona-widget-footer persona-border-t-persona-divider persona-bg-persona-surface persona-px-6 persona-py-4`,attrs:{"data-persona-theme-zone":`composer`}}),r=we(),i=O(`form`,{className:`persona-widget-composer persona-flex persona-flex-col persona-gap-2 persona-rounded-2xl persona-border persona-border-persona-border persona-bg-persona-input-background persona-px-4 persona-py-3`,attrs:{"data-persona-composer-form":``}}),{textarea:a,attachAutoResize:o}=be(t);o();let s=ue(t),c=Se(t),l=ce(t),u=_e(t),d=O(`div`,{className:`persona-widget-composer__header`,attrs:{"data-persona-composer-header":``},style:{display:`contents`}});i.append(d),l&&(d.append(l.previewsContainer),i.append(l.input)),i.append(a);let f=O(`div`,{className:`persona-widget-composer__actions persona-flex persona-items-center persona-justify-between persona-w-full`,attrs:{"data-persona-composer-actions":``}}),p=O(`div`,{className:`persona-widget-composer__left-actions persona-flex persona-items-center persona-gap-2`,attrs:{"data-persona-composer-actions-start":``}}),m=O(`div`,{className:`persona-widget-composer__right-actions persona-flex persona-items-center persona-gap-2`,attrs:{"data-persona-composer-actions-end":``}});return l&&p.append(l.wrapper),c&&m.append(c.wrapper),m.append(s.wrapper),f.append(p,m),i.append(f),i.addEventListener(`click`,e=>{Os(i,e)}),t?.statusIndicator?.mode===`transient`?n.append(r,u,i):n.append(r,i,u),{footer:n,suggestions:r,composerForm:i,header:d,textarea:a,sendButton:s.button,sendButtonWrapper:s.wrapper,micButton:c?.button??null,micButtonWrapper:c?.wrapper??null,statusText:u,attachmentButton:l?.button??null,attachmentButtonWrapper:l?.wrapper??null,attachmentInput:l?.input??null,attachmentPreviewsContainer:l?.previewsContainer??null,actionsRow:f,leftActions:p,rightActions:m,setSendButtonMode:s.setMode}},X=()=>{let e=O(`button`,{className:`persona-pill-peek`,attrs:{type:`button`,"data-persona-pill-peek":``,"aria-label":`Show conversation`,tabindex:`-1`}}),t=k(`span`,`persona-pill-peek__icon`),n=b(En,16,`currentColor`,1.5);n&&t.appendChild(n);let r=k(`span`,`persona-pill-peek__text`),i=k(`span`,`persona-pill-peek__caret`),a=b(bn,16,`currentColor`,1.5);return a&&i.appendChild(a),e.append(t,r,i),{root:e,textNode:r}},As=e=>{let{config:t}=e,n=O(`div`,{className:`persona-widget-footer persona-widget-footer--pill`,attrs:{"data-persona-theme-zone":`composer`}}),r=we(),i=_e(t);i.style.display=`none`;let{textarea:a,attachAutoResize:o}=be(t,{defaultMaxLines:5});o();let s=ue(t),c=Se(t),l=ce(t);l&&l.previewsContainer.classList.add(`persona-pill-composer__previews`);let u=O(`form`,{className:`persona-widget-composer persona-pill-composer`,attrs:{"data-persona-composer-form":``}}),d=O(`div`,{className:`persona-widget-composer__left-actions persona-pill-composer__left`,attrs:{"data-persona-composer-actions-start":``}});l&&d.append(l.wrapper);let f=O(`div`,{className:`persona-widget-composer__right-actions persona-pill-composer__right`,attrs:{"data-persona-composer-actions-end":``}});c&&f.append(c.wrapper),f.append(s.wrapper),u.addEventListener(`click`,e=>{Os(u,e)}),l&&u.append(l.input),u.append(d,a,f);let p=O(`div`,{className:`persona-pill-composer__header`,attrs:{"data-persona-composer-header":``},style:{display:`contents`}});n.append(p),l&&p.append(l.previewsContainer),n.append(r,u,i);let m=u;return{footer:n,suggestions:r,composerForm:u,header:p,textarea:a,sendButton:s.button,sendButtonWrapper:s.wrapper,micButton:c?.button??null,micButtonWrapper:c?.wrapper??null,statusText:i,attachmentButton:l?.button??null,attachmentButtonWrapper:l?.wrapper??null,attachmentInput:l?.input??null,attachmentPreviewsContainer:l?.previewsContainer??null,actionsRow:m,leftActions:d,rightActions:f,setSendButtonMode:s.setMode}},js=e=>{switch(e){case`max_tool_calls`:return`Tool limit reached.`;case`length`:return`Output token limit reached.`;case`content_filter`:return`The provider filtered this response.`;case`error`:return`Something went wrong generating this response.`;default:return null}},Ms=(e,t)=>{if(!e)return null;let n=js(e);if(n===null)return null;let r=t?.[e];return(r===void 0?n:r)||null},Ns=(e,t)=>O(`div`,{className:`persona-message-stop-reason persona-text-xs persona-mt-2 persona-italic`,attrs:{"data-stop-reason":e,role:`note`},style:{opacity:`0.75`},text:t}),Ps=e=>{let t=e.toLowerCase();return!t.startsWith(`data:image/svg+xml`)&&!!(/^(?:https?|blob):/i.test(e)||t.startsWith(`data:image/`)||!e.includes(`:`))},Fs=e=>{let t=e.toLowerCase();return t.startsWith(`javascript:`)||t.startsWith(`data:text/html`)||t.startsWith(`data:text/javascript`)||t.startsWith(`data:text/xml`)||t.startsWith(`data:application/xhtml`)||t.startsWith(`data:image/svg+xml`)?!1:!!(/^(?:https?|blob):/i.test(e)||t.startsWith(`data:`)||!e.includes(`:`))},Is=e=>!e.contentParts||e.contentParts.length===0?[]:e.contentParts.filter(e=>e.type===`image`&&typeof e.image==`string`&&e.image.trim().length>0),Ls=e=>!e.contentParts||e.contentParts.length===0?[]:e.contentParts.filter(e=>e.type===`audio`&&typeof e.audio==`string`&&e.audio.trim().length>0),Rs=e=>!e.contentParts||e.contentParts.length===0?[]:e.contentParts.filter(e=>e.type===`video`&&typeof e.video==`string`&&e.video.trim().length>0),zs=e=>!e.contentParts||e.contentParts.length===0?[]:e.contentParts.filter(e=>e.type===`file`&&typeof e.data==`string`&&e.data.trim().length>0),Bs=e=>{if(!e||e.length===0)return null;let t=O(`div`,{className:`persona-mention-context-row persona-message-mentions`,attrs:{"data-message-mentions":``}});t.style.display=`flex`;for(let n of e){let e=O(`div`,{className:`persona-mention-chip persona-mention-chip-readonly`,attrs:{"data-status":`ready`,title:n.label}}),r=k(`span`,`persona-mention-chip-icon`),i=T(n.iconName??`at-sign`,13,`currentColor`,2);i&&r.appendChild(i),e.appendChild(r),e.appendChild(O(`span`,{className:`persona-mention-chip-label`,text:n.label})),t.appendChild(e)}return t},Vs=(e,t)=>{let n=document.createDocumentFragment();for(let r of e)r.kind===`text`?n.appendChild(document.createTextNode(r.text)):n.appendChild(Ce(r.ref,{readonly:!0,render:t}));return n},Hs=(e,t,n,r)=>{let i=Math.random().toString(36).slice(2,8),a=e=>`${i}:${e}`,o=n(t.map((e,t)=>e.kind===`text`?e.text:a(t)).join(``));if(!t.every((e,t)=>e.kind===`text`||o.includes(a(t)))){e.replaceChildren(Vs(t,r));return}e.innerHTML=o;let s=RegExp(`${i}:(\\d+)`),c=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),l=[];for(let e=c.nextNode();e;e=c.nextNode())l.push(e);for(let e of l){let n=e;for(let e=s.exec(n.data);e;e=s.exec(n.data)){let i=t[Number(e[1])],a=n.splitText(e.index);a.data=a.data.slice(e[0].length),i?.kind===`mention`&&a.parentNode?.insertBefore(Ce(i.ref,{readonly:!0,render:r}),a),n=a}}},Us=(e,t,n)=>{if(e.length===0)return null;try{let r=k(`div`,`persona-flex persona-flex-col persona-gap-2`);r.setAttribute(`data-message-attachments`,`images`),t&&(r.style.marginBottom=`8px`);let i=0,a=!1,o=()=>{a||(a=!0,r.remove(),n?.())};return e.forEach((e,t)=>{let n=k(`img`);n.alt=e.alt?.trim()||`Attached image ${t+1}`,n.loading=`lazy`,n.decoding=`async`,n.referrerPolicy=`no-referrer`,n.style.display=`block`,n.style.width=`100%`,n.style.maxWidth=`320px`,n.style.maxHeight=`320px`,n.style.height=`auto`,n.style.objectFit=`contain`,n.style.borderRadius=`10px`,n.style.backgroundColor=`var(--persona-attachment-image-bg, var(--persona-container, #f3f4f6))`,n.style.border=`1px solid var(--persona-attachment-image-border, var(--persona-border, #e5e7eb))`;let a=!1;i+=1,n.addEventListener(`error`,()=>{a||(a=!0,i=Math.max(0,i-1),n.remove(),i===0&&o())}),n.addEventListener(`load`,()=>{a=!0}),Ps(e.image)?(n.src=e.image,r.appendChild(n)):(a=!0,i=Math.max(0,i-1),n.remove())}),i===0?(o(),null):r}catch{return n?.(),null}},Z=e=>{if(e.length===0)return null;try{let t=k(`div`,`persona-flex persona-flex-col persona-gap-2`);t.setAttribute(`data-message-attachments`,`audio`);let n=0;return e.forEach(e=>{if(!Fs(e.audio))return;let r=k(`audio`);r.controls=!0,r.preload=`metadata`,r.src=e.audio,r.style.display=`block`,r.style.width=`100%`,r.style.maxWidth=`320px`,t.appendChild(r),n+=1}),n===0?(t.remove(),null):t}catch{return null}},Ws=e=>{if(e.length===0)return null;try{let t=k(`div`,`persona-flex persona-flex-col persona-gap-2`);t.setAttribute(`data-message-attachments`,`video`);let n=0;return e.forEach(e=>{if(!Fs(e.video))return;let r=k(`video`);r.controls=!0,r.preload=`metadata`,r.src=e.video,r.style.display=`block`,r.style.width=`100%`,r.style.maxWidth=`320px`,r.style.maxHeight=`320px`,r.style.borderRadius=`10px`,r.style.backgroundColor=`var(--persona-attachment-image-bg, var(--persona-container, #f3f4f6))`,t.appendChild(r),n+=1}),n===0?(t.remove(),null):t}catch{return null}},Gs=e=>{if(e.length===0)return null;try{let t=k(`div`,`persona-flex persona-flex-col persona-gap-2`);t.setAttribute(`data-message-attachments`,`files`);let n=0;return e.forEach(e=>{if(!Fs(e.data))return;let r=k(`a`);r.href=e.data,r.download=e.filename,r.target=`_blank`,r.rel=`noopener noreferrer`,r.textContent=e.filename,r.className=`persona-message-file-attachment`,r.style.display=`inline-flex`,r.style.alignItems=`center`,r.style.gap=`6px`,r.style.padding=`6px 10px`,r.style.borderRadius=`8px`,r.style.fontSize=`0.875rem`,r.style.textDecoration=`underline`,r.style.backgroundColor=`var(--persona-attachment-file-bg, var(--persona-container, #f3f4f6))`,r.style.border=`1px solid var(--persona-attachment-file-border, var(--persona-border, #e5e7eb))`,r.style.color=`inherit`,t.appendChild(r),n+=1}),n===0?(t.remove(),null):t}catch{return null}},Ks=(e={})=>{let t=e.loadingIndicator,n=e.future?.v5Defaults;if((t?.variant??(n?`label`:`dots`))===`label`){let r=O(`div`,{className:`persona-loading-label`,attrs:{role:`status`}});n&&t?.showBubble!==!0&&r.classList.add(`persona-activity-row`,`persona-activity-header`);let i=e.features?.toolCallDisplay,a=t?.iconVisibility??(i?.grouped!==!1&&(i?.groupedMode??`collapsible`)===`collapsible`?i?.groupIconVisibility:void 0)??i?.iconVisibility,o=t?.iconName??`loader-circle`;if(a!==`never`&&(n||t?.iconName||t?.iconVisibility)){let e=T(o,16);e&&(e.classList.add(`persona-activity-icon`),e.dataset.loadingIconAnimation=t?.iconAnimation??(o===`loader-circle`?`spin`:`none`),r.appendChild(e))}let s=O(`span`,{text:t?.label??`Thinking…`});return r.appendChild(s),Zn()?.applyLoadingLabel(s,e,`waiting`),r}let r=k(`div`,`persona-flex persona-items-center persona-space-x-1 persona-h-5 persona-mt-2`);for(let e=0;e<3;e++){let t=k(`div`,`persona-animate-typing persona-rounded-full persona-h-1.5 persona-w-1.5`);t.style.backgroundColor=`currentColor`,t.style.opacity=`0.4`,t.style.animationDelay=`${e*250}ms`,r.appendChild(t)}let i=k(`span`,`persona-sr-only`);return i.textContent=`Loading`,r.appendChild(i),r},qs=(e,t,n)=>t?.({config:n??{},streaming:!0,location:e,defaultRenderer:()=>Ks(n)})??Ks(n),Js=(e,t)=>{let n=k(`div`,`persona-flex-shrink-0 persona-w-8 persona-h-8 persona-rounded-full persona-flex persona-items-center persona-justify-center persona-text-sm`),r=t===`user`?e.userAvatar:e.assistantAvatar;if(r){if(r.startsWith(`http`)||r.startsWith(`/`)||r.startsWith(`data:`)){let e=k(`img`);e.src=r,e.alt=t===`user`?`User`:`Assistant`,e.className=`persona-w-full persona-h-full persona-rounded-full persona-object-cover`,n.appendChild(e)}else n.textContent=r,n.classList.add(t===`user`?`persona-bg-persona-accent`:`persona-bg-persona-primary`,`persona-text-white`)}else n.textContent=t===`user`?`U`:`A`,n.classList.add(t===`user`?`persona-bg-persona-accent`:`persona-bg-persona-primary`,`persona-text-white`);return n},Ys=(e,t,n=`div`)=>{let r=k(n,`persona-text-xs persona-text-persona-muted`),i=new Date(e.createdAt);return r.textContent=t.format?t.format(i):i.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),r},Xs=(e,t=`bubble`)=>{let n=[`persona-message-bubble`];switch(t){case`flat`:e===`user`?n.push(`persona-message-user-bubble`,`persona-ml-auto`,`persona-text-persona-primary`,`persona-py-2`):n.push(`persona-message-assistant-bubble`,`persona-text-persona-text`,`persona-py-2`);break;case`minimal`:n.push(`persona-text-sm`,`persona-leading-relaxed`),e===`user`?n.push(`persona-message-user-bubble`,`persona-ml-auto`,`persona-bg-persona-accent`,`persona-text-white`,`persona-px-3`,`persona-py-2`,`persona-rounded-lg`):n.push(`persona-message-assistant-bubble`,`persona-bg-persona-container`,`persona-text-persona-text`,`persona-px-3`,`persona-py-2`,`persona-rounded-lg`);break;default:n.push(`persona-rounded-2xl`,`persona-text-sm`,`persona-leading-relaxed`,`persona-shadow-sm`),e===`user`?n.push(`persona-message-user-bubble`,`persona-ml-auto`,`persona-bg-persona-accent`,`persona-text-white`,`persona-px-5`,`persona-py-3`):n.push(`persona-message-assistant-bubble`,`persona-bg-persona-container`,`persona-border`,`persona-border-persona-message-border`,`persona-text-persona-text`,`persona-px-5`,`persona-py-3`)}return n},Zs={bubble:{padding:`0.75rem 1.25rem`,fontSize:`0.875rem`,lineHeight:`1.75`},minimal:{padding:`0.5rem 0.75rem`,fontSize:`0.875rem`,lineHeight:`1.75`},flat:{padding:`0.5rem 0`,fontSize:`inherit`,lineHeight:`inherit`}},Qs=(e,t,n=`bubble`,r)=>{if(!r)return;let i=t===`user`?`user`:`assistant`,a=Zs[n??`bubble`]??Zs.bubble;r.padding&&(e.style.padding=`var(--persona-message-${i}-padding, ${a.padding})`),r.fontSize&&(e.style.fontSize=`var(--persona-message-${i}-font-size, ${a.fontSize})`),r.lineHeight&&(e.style.lineHeight=`var(--persona-message-${i}-line-height, ${a.lineHeight})`),r.fontFamily&&(e.style.fontFamily=`var(--persona-message-${i}-font-family, inherit)`)},$s=e=>`custom:${e}`,ec=(e,t)=>t!==`user`&&t!==`assistant`?[]:(e?.custom??[]).filter(e=>(e.roles??[`assistant`]).includes(t)),tc=(e,t,n,r,i=!1)=>{let a=t.showCopy??!0,o=t.showUpvote??!1,s=t.showDownvote??!1,c=t.showReadAloud??!1,l=(t.showRegenerate??!1)&&r?.canRegenerate===!0,u=(t.showEdit??!1)&&r?.canEdit===!0,d=(t.showQuote??!1)&&r?.canQuote!==!1,f=ec(t,e.role);if(!a&&!o&&!s&&!c&&!l&&!u&&!d&&f.length===0){let t=k(`div`);return t.style.display=`none`,t.id=`actions-${e.id}`,t.setAttribute(`data-actions-for`,e.id),t}let p=t.visibility??(i&&r?.isLastAssistant?`always`:`hover`),m=t.align??`right`,h=t.layout??`pill-inside`,g={left:`persona-message-actions-left`,center:`persona-message-actions-center`,right:`persona-message-actions-right`}[m],_={"pill-inside":`persona-message-actions-pill`,"row-inside":`persona-message-actions-row`}[h],v=k(`div`,`persona-message-actions persona-flex persona-items-center persona-gap-1 persona-mt-2 ${g} ${_} ${p===`hover`?`persona-message-actions-hover`:``} ${i?`persona-message-actions-adaptive`:``}`);v.id=`actions-${e.id}`,v.setAttribute(`data-actions-for`,e.id);let y=(e,t,n)=>{let r=nr({icon:e,label:t,size:14,className:`persona-message-action-btn`,chromeless:!0});return r.setAttribute(`data-action`,n),r};a&&v.appendChild(y(`copy`,`Copy message`,`copy`)),c&&v.appendChild(y(`volume-2`,`Read aloud`,`read-aloud`)),o&&v.appendChild(y(`thumbs-up`,`Upvote`,`upvote`)),s&&v.appendChild(y(`thumbs-down`,`Downvote`,`downvote`)),l&&v.appendChild(y(`refresh-cw`,`Regenerate response`,`regenerate`)),u&&v.appendChild(y(`pencil`,`Edit message`,`edit`)),d&&v.appendChild(y(`quote`,`Quote message`,`quote`));for(let e of f)v.appendChild(y(e.iconName??`ellipsis`,e.label,$s(e.id)));return v},nc=(e,t,n,r,i,a)=>{let o=n??{},s=o.layout??`bubble`,c=o.avatar,l=o.timestamp,u=c?.show??!1,d=l?.show??!1,f=c?.position??`left`,p=l?.position??`below`,m=Xs(e.role,s),h=k(`div`,m.join(` `));h.id=`bubble-${e.id}`,h.setAttribute(`data-message-id`,e.id),h.setAttribute(`data-persona-theme-zone`,e.role===`user`?`user-message`:`assistant-message`);let g=La(a?.widgetConfig?.future).components.message,_=a?.widgetConfig?.theme?.components?.message;Qs(h,e.role,s,e.role===`user`?{...g.user,..._?.user,...a?.widgetConfig?.darkTheme?.components?.message?.user}:{...g.assistant,..._?.assistant,...a?.widgetConfig?.darkTheme?.components?.message?.assistant}),s===`flat`?(h.style.backgroundColor=`transparent`,h.style.color=e.role===`user`?`var(--persona-primary, var(--persona-text))`:`var(--persona-message-assistant-text, var(--persona-text))`):e.role===`user`?(h.style.backgroundColor=`var(--persona-message-user-bg, var(--persona-accent))`,h.style.color=`var(--persona-message-user-text, white)`):e.role===`assistant`&&(h.style.backgroundColor=`var(--persona-message-assistant-bg, var(--persona-container))`,h.style.color=`var(--persona-message-assistant-text, var(--persona-text))`);let v=Is(e),y=e.content?.trim()??``,b=v.length>0&&y===`[Image]`,x=sn(a?.widgetConfig?.features?.streamAnimation),S=a?.widgetConfig?.features?.streamAnimation?.plugins,C=e.role===`assistant`&&x.type!==`none`?ln(x.type,S):null,ee=e.role===`assistant`&&C?.isAnimating?.(e)===!0,w=e.role===`assistant`&&C!==null&&(!!e.streaming||ee);w&&C?.bubbleClass&&h.classList.add(C.bubbleClass);let T=document.createElement(`div`);T.classList.add(`persona-message-content`),e.streaming&&T.classList.add(`persona-content-streaming`),w&&C&&(C.containerClass&&T.classList.add(C.containerClass),T.style.setProperty(`--persona-stream-step`,`${x.speed}ms`),T.style.setProperty(`--persona-stream-duration`,`${x.duration}ms`));let te=w?un(e.content??``,x.buffer,C,e,!!e.streaming):e.content??``,ne=()=>{let n=t({text:te,message:e,streaming:!!e.streaming,raw:e.rawContent});return w&&C?.wrap===`char`?hn(n,`char`,e.id,{skipTags:C.skipTags}):w&&C?.wrap===`word`?hn(n,`word`,e.id,{skipTags:C.skipTags}):n},re=null;if(b?(re=document.createElement(`div`),re.innerHTML=ne(),re.style.display=`none`,T.appendChild(re)):e.contentSegments?.length?Hs(T,e.contentSegments,n=>t({text:n,message:e,streaming:!!e.streaming,raw:e.rawContent}),a?.widgetConfig?.contextMentions?.renderMentionToken):T.innerHTML=ne(),w&&C?.useCaret&&!b&&y){let e=cn(),t=T.querySelectorAll(`.persona-stream-char, .persona-stream-word`),n=t[t.length-1];if(n?.parentNode)n.parentNode.insertBefore(e,n.nextSibling);else{let t=T.lastElementChild;t?t.appendChild(e):T.appendChild(e)}}if(d&&p===`inline`&&e.createdAt){let t=Ys(e,l,`span`);t.classList.add(`persona-timestamp-inline`);let n=T.lastElementChild;n?n.appendChild(t):T.appendChild(t)}if(v.length>0){let e=Us(v,!b&&!!y,()=>{b&&re&&(re.style.display=``)});e?h.appendChild(e):b&&re&&(re.style.display=``)}let ie=Ls(e);if(ie.length>0){let e=Z(ie);e&&h.appendChild(e)}let ae=Rs(e);if(ae.length>0){let e=Ws(ae);e&&h.appendChild(e)}let oe=zs(e);if(oe.length>0){let e=Gs(oe);e&&h.appendChild(e)}let se=e.contentSegments?.length?null:Bs(e.contextMentions);if(se&&h.appendChild(se),h.appendChild(T),d&&p===`below`&&e.createdAt){let t=Ys(e,l);t.classList.add(`persona-mt-1`),h.appendChild(t)}let ce=e.role===`assistant`?Ms(e.stopReason,a?.widgetConfig?.copy?.stopReasonNotice):null;if(e.streaming&&e.role===`assistant`){let e=!!(te&&te.trim()),t=x.placeholder===`skeleton`,n=t&&x.buffer===`line`&&e;if(e)n&&h.appendChild(fn());else if(t)h.appendChild(fn());else{let e=qs(`inline`,a?.loadingIndicatorRenderer,a?.widgetConfig);e&&h.appendChild(e)}}ce&&e.stopReason&&!e.streaming&&(y||(T.style.display=`none`),h.appendChild(Ns(e.stopReason,ce)));let le=e.role===`assistant`&&!e.streaming&&!e.voiceCaption&&e.content&&e.content.trim()&&r?.enabled!==!1,ue=a?.actionEligibility,de=e.role===`user`&&!e.streaming&&r?.enabled!==!1&&(r?.showEdit===!0&&ue?.canEdit===!0||r?.showQuote===!0&&ue?.canQuote===!0||ec(r,`user`).length>0);if((le||de)&&r){let t=tc(e,de?{...r,showCopy:!1,showUpvote:!1,showDownvote:!1,showReadAloud:!1}:r,i,ue,a?.widgetConfig?.future?.v5Defaults===!0&&r.visibility===void 0);h.appendChild(t)}if(!u||e.role===`system`)return h;let E=k(`div`,`persona-message-with-avatar persona-flex persona-gap-2 ${e.role===`user`?`persona-flex-row-reverse`:``}`),fe=Js(c,e.role);return f===`right`||f===`left`&&e.role===`user`?E.append(h,fe):E.append(fe,h),E},rc=(e,t)=>{if(e.replaceChildren(),!t)e.hidden=!0;else if(typeof t==`function`){let n=null;try{n=t()}catch(e){console.warn(`[persona] welcome.icon renderer threw`,e)}if(!n){e.hidden=!0;return}e.appendChild(n),e.hidden=!1}else{if(t.type===`lucide`){let n=T(t.name,40);if(!n){e.hidden=!0;return}e.appendChild(n)}else t.type===`image`?e.appendChild(O(`img`,{className:`persona-welcome-icon-image`,attrs:{src:t.url,alt:t.alt}})):e.appendChild(O(`span`,{className:`persona-welcome-icon-text`,text:t.text}));e.hidden=!1}},ic=(e,t,n={})=>{let r=O(`div`,{className:`persona-welcome-icon`,attrs:{"data-persona-welcome-icon":``}});r.hidden=!0;let i=k(`p`,`persona-welcome-kicker`);i.hidden=!0;let a=k(`h2`,`persona-welcome-title`),o=k(`p`,`persona-welcome-subtitle`),s=O(`div`,{className:`persona-welcome-head-text`},i,a),c=O(`div`,{className:`persona-welcome-title-row`},r,s);return{host:O(`div`,{className:`persona-welcome persona-rounded-2xl`,attrs:{"data-persona-welcome":``,"data-persona-intro-card":``,"data-persona-welcome-variant":`card`},style:{background:`var(--persona-intro-card-bg, transparent)`,boxShadow:n.flatShadow?`none`:`var(--persona-intro-card-shadow, none)`,border:`var(--persona-intro-card-border, none)`}},c,o,t),iconHolder:r,kicker:i,title:a,subtitle:o,starterSuggestions:t}},ac=(e,t,n)=>{t.hidden=!n,t.style.display=n?``:`none`,e.classList.toggle(`persona-gap-6`,n),e.classList.toggle(`persona-gap-3`,!n)},oc=(e,t)=>{e.title.textContent=t.title,e.kicker.textContent=t.kicker??``,e.kicker.hidden=!t.kicker,e.subtitle.textContent=t.subtitle,e.subtitle.hidden=t.subtitle===``,rc(e.iconHolder,t.icon),e.host.setAttribute(`data-persona-welcome-variant`,t.variant),e.host.setAttribute(`data-persona-welcome-dismiss`,t.dismiss),e.host.setAttribute(`data-persona-welcome-layout`,t.layout??`top`),e.host.setAttribute(`data-persona-welcome-anchor`,t.anchor??`bottom`),t.iconPlacement===`inline`?e.host.setAttribute(`data-persona-welcome-icon-placement`,`inline`):e.host.removeAttribute(`data-persona-welcome-icon-placement`),t.align?e.host.setAttribute(`data-persona-welcome-align`,t.align):e.host.removeAttribute(`data-persona-welcome-align`)},sc=`data-persona-welcome-overlay`,cc=`persona-welcome-overlay-active`,lc=/* @__PURE__ */ new WeakMap,uc=(e,t,n)=>{n.setAttribute(`data-persona-welcome-plugin`,``),t.appendChild(n),t.setAttribute(`data-persona-welcome-content`,`plugin`),t.setAttribute(sc,``),e.classList.contains(cc)||(lc.set(e,e.scrollTop),e.classList.add(cc),e.scrollTop=0)},dc=(e,t,n)=>{n&&n!==t&&n.remove(),t.removeAttribute(`data-persona-welcome-content`),t.removeAttribute(sc),e.classList.contains(cc)&&(e.classList.remove(cc),e.scrollTop=lc.get(e)??e.scrollTop,lc.delete(e))},fc=()=>{let e=O(`div`,{className:`persona-welcome-greeting persona-flex persona-flex-col`,attrs:{"data-persona-welcome-greeting":``}});return e.hidden=!0,e},pc=(e,t,n)=>{if(e.replaceChildren(),!t){e.hidden=!0;return}let r=n?.layout?.messages?.layout??`bubble`,i=O(`div`,{className:Xs(`assistant`,r).join(` `),attrs:{"data-persona-theme-zone":`assistant-message`},text:t,style:r===`flat`?{backgroundColor:`transparent`,color:`var(--persona-message-assistant-text, var(--persona-text))`}:{backgroundColor:`var(--persona-message-assistant-bg, var(--persona-container))`,color:`var(--persona-message-assistant-text, var(--persona-text))`}});e.appendChild(O(`div`,{className:`persona-flex`},i)),e.hidden=!1},mc=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,hc=(e,t)=>{if(mc()||typeof e.animate!=`function`||!e.isConnected)return t(null),null;let n=e.getBoundingClientRect(),r=e.parentElement,i=0,a=0,o=0;if(r){let t=getComputedStyle(r);i=parseFloat(t.rowGap)||0;let s=e.previousElementSibling,c=e.nextElementSibling,l=r.getBoundingClientRect().top+(parseFloat(t.borderTopWidth)||0)+(parseFloat(t.paddingTop)||0)-r.scrollTop;a=Math.max(0,s?n.top-s.getBoundingClientRect().bottom-i:n.top-l),o=Math.max(0,c?c.getBoundingClientRect().top-n.bottom-i:0)}let s=e.style.overflow;e.style.overflow=`hidden`;let c=getComputedStyle(e),l=parseFloat(c.paddingTop)||0,u=parseFloat(c.paddingBottom)||0,d=e.animate([{opacity:`1`,transform:`none`,height:`${n.height}px`,minHeight:`0px`,paddingTop:`${l}px`,paddingBottom:`${u}px`,marginTop:`${a}px`,marginBottom:`${o}px`},{opacity:`0`,transform:`translateY(-4px)`,height:`0px`,minHeight:`0px`,paddingTop:`0px`,paddingBottom:`0px`,marginTop:`0px`,marginBottom:`${-i}px`}],{duration:180,easing:`ease-out`,fill:`forwards`}),f=!1,p=()=>{f||(f=!0,e.style.overflow=s,t(d))};return d.finished.then(p).catch(p),d},gc=(e,t,n,r=260)=>{if(t<=1||mc()||typeof e.animate!=`function`||!e.isConnected)return null;let i=n===`drop`?-t:t;return e.animate([{transform:`translateY(${i}px)`},{transform:`none`}],{duration:r,easing:`cubic-bezier(0.2, 0, 0, 1)`,fill:`none`})},_c=/* @__PURE__ */ new WeakSet,vc=(e,t)=>!!e&&e[t]!==void 0,yc=(e,t)=>{e&&e.debug===!0&&t.length&&!_c.has(e)&&(_c.add(e),t.forEach(e=>console.warn(`[persona] ${e}`)))},bc=(e,t=e?.launcher?.fullHeight===!0&&!e.launcher.sidebarMode&&e.launcher.mountMode!==`docked`)=>{let n=e?.welcome,r=e?.copy,i=e?.future?.v5Defaults===!0,a=n?.layout??(i?`centered`:`top`),o=vc(n,`variant`)?n.variant:r?.showWelcomeCard===!1?`none`:`card`,s=o===`hero`&&!i&&n?.layout===void 0?`on-first-message`:vc(n,`dismiss`)?n.dismiss:i||o===`hero`?`on-first-message`:`never`,c=[];for(let[e,t]of[[`title`,`welcomeTitle`],[`subtitle`,`welcomeSubtitle`],[`variant`,`showWelcomeCard`]])vc(n,e)&&vc(r,t)&&c.push(`welcome.${e} and copy.${t} are both set; welcome.${e} wins. copy.${t} is deprecated.`);o===`hero`&&vc(n,`message`)&&c.push(`welcome.message is ignored when welcome.variant is "hero": the hero is the greeting.`),!i&&n?.layout===void 0&&o===`hero`&&vc(n,`dismiss`)&&n.dismiss!==`on-first-message`&&c.push(`welcome.dismiss is pinned to "on-first-message" when welcome.variant is "hero".`);let l=n?.anchor??(o!==`none`&&a===`centered`&&t?`center`:`bottom`),u=So(n?.anchorComposerTop)!==null;return vc(n,`anchorComposerTop`)&&!u&&c.push(`welcome.anchorComposerTop must be a percentage between 0% and 100%; falling back to "44%".`),l!==`center`&&(vc(n,`anchorComposerTop`)||vc(n,`composerGap`))&&c.push(`welcome.anchorComposerTop is ignored unless welcome.anchor is "center".`),yc(e,c),{title:vc(n,`title`)?n.title:r?.welcomeTitle??(i?`What can I help with?`:`Hello 👋`),kicker:n?.kicker??``,subtitle:vc(n,`subtitle`)?n.subtitle:r?.welcomeSubtitle??(i?``:`I can answer questions and help you get things done here.`),icon:n?.icon,align:n?.align===`start`||n?.align===`center`?n.align:a===`centered`?`center`:void 0,iconPlacement:n?.icon&&typeof n.icon!=`function`&&n.icon.placement===`inline`?`inline`:`above`,variant:o,dismiss:s,message:o===`hero`?void 0:n?.message,layout:a,anchor:l,anchorComposerTop:u?n.anchorComposerTop:`44%`,composerGap:n?.composerGap?.trim()||`24px`}},xc=(e=[])=>e.some(e=>e.role===`user`||e.role===`assistant`&&(e.content.trim()||e.contentParts?.some(e=>e.type!==`text`||e.text.trim())||e.toolCall||e.tools?.length||e.reasoning||e.approval)),Sc=e=>xc(e)?`active`:`empty`,Cc=(e,t)=>e.variant!==`none`&&(e.dismiss===`never`||!xc(t)),wc=`var(--persona-components-panel-height)`,Tc=e=>{let t=nn(e),n=t.launcherWidth?e?.launcher?.width:t.legacyLauncherWidth?e?.launcherWidth:void 0,r=e?.launcher?.heightOffset??0,i=r===0?`max(200px, ${wc})`:`max(200px, calc(${wc} - ${r}px))`;return{width:n??`var(--persona-components-panel-width)`,maxWidth:n??`var(--persona-components-panel-maxWidth)`,height:i,maxHeight:`var(--persona-components-panel-maxHeight)`}},Ec=e=>{let t=nn(e);return t.launcherWidth||t.legacyLauncherWidth||e?.theme?.components?.panel?.width!==void 0?Tc(e).width:`100%`},Dc=`16px`,Oc=`10px`,kc=`14px`,Ac=e=>{let t=e?.launcher?.enabled??!0,n=$o(e);if(es(e)){let t=e?.launcher?.composerBar??{},n=k(`div`,`persona-widget-wrapper persona-fixed persona-transition`);n.setAttribute(`data-persona-composer-bar`,``),n.dataset.state=`collapsed`,n.dataset.expandedSize=t.expandedSize??`anchored`,n.style.zIndex=String(e?.launcher?.zIndex??1e5);let r=k(`div`,`persona-widget-panel persona-relative persona-flex persona-flex-1 persona-min-h-0 persona-flex-col`);r.style.width=`100%`,n.appendChild(r);let i=k(`div`,`persona-widget-pill-root`);return i.setAttribute(`data-persona-composer-bar`,``),i.dataset.state=`collapsed`,i.dataset.expandedSize=t.expandedSize??`anchored`,i.style.zIndex=String(e?.launcher?.zIndex??1e5),{wrapper:n,panel:r,pillRoot:i}}if(n){let e=k(`div`,`persona-relative persona-h-full persona-w-full persona-flex persona-flex-1 persona-min-h-0 persona-flex-col`),t=k(`div`,`persona-relative persona-h-full persona-w-full persona-flex persona-flex-1 persona-min-h-0 persona-flex-col`);return e.appendChild(t),{wrapper:e,panel:t}}if(!t){let t=k(`div`,`persona-relative persona-h-full persona-flex persona-flex-col persona-flex-1 persona-min-h-0`),n=k(`div`,`persona-relative persona-flex-1 persona-flex persona-flex-col persona-min-h-0`);return t.style.width=Ec(e),n.style.width=`100%`,t.appendChild(n),{wrapper:t,panel:n}}let r=e?.launcher??{},i=r.position&&us[r.position]?us[r.position]:us[`bottom-right`],a=k(`div`,`persona-widget-wrapper persona-fixed ${i} persona-transition`);a.style.zIndex=String(e?.launcher?.zIndex??1e5);let o=k(`div`,`persona-widget-panel persona-relative persona-min-h-[320px]`),s=Tc(e);return o.style.width=s.width,o.style.maxWidth=s.maxWidth,a.appendChild(o),{wrapper:a,panel:o}},jc=e=>{let t=O(`div`,{className:`persona-suggestions`,attrs:{"data-persona-suggestions":rs(e)}});return t.hidden=!0,t},Mc=(e,t)=>{let n=jc(`starter`),r=ic(e,n,{flatShadow:$o(e)}),i=bc(e);oc(r,i),ac(t,r.host,Cc(i,e?.initialMessages));let a=fc();return pc(a,i.message,e),{welcome:r,greetingHost:a}},Nc=(e,t)=>{let n=k(`div`,`persona-widget-container persona-relative persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-text-persona-primary`);n.setAttribute(`data-persona-theme-zone`,`container`);let{button:r,wrapper:i}=gs(e,{showClose:t,wrapperClassName:`persona-composer-bar-close`,buttonSize:Dc,iconSize:Oc});i.style.position=`absolute`,i.style.top=`8px`,i.style.right=`8px`,i.style.zIndex=`10`;let a=e?.launcher?.clearChat?.enabled??!0,o=null,s=null;if(a){let t=_s(e,{wrapperClassName:`persona-composer-bar-clear-chat`,buttonSize:Dc,iconSize:kc});o=t.button,s=t.wrapper,s.style.position=`absolute`,s.style.top=`8px`,s.style.right=`32px`,s.style.zIndex=`10`}let c=O(`span`,{className:`persona-widget-header`,attrs:{"data-persona-theme-zone":`header`},style:{display:`none`}}),l=O(`div`,{className:`persona-widget-body persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-gap-6 persona-overflow-y-auto persona-bg-persona-container persona-px-6 persona-py-6`,attrs:{id:`persona-scroll-container`,"data-persona-theme-zone":`messages`},style:{paddingTop:`48px`}});l.style.setProperty(`scrollbar-gutter`,`stable`);let{welcome:u,greetingHost:d}=Mc(e,l),{host:f,title:p,subtitle:m}=u,h=u.starterSuggestions,g=k(`div`,`persona-widget-messages persona-flex persona-flex-col`);g.style.gap=`var(--persona-components-message-gap, 12px)`;let _=jc(`followUp`),v=bo(e,!0);v&&(g.style.maxWidth=v,g.style.marginLeft=`auto`,g.style.marginRight=`auto`,g.style.width=`100%`),l.append(f,d,g,_);let y=O(`div`,{className:`persona-composer-overlay persona-pointer-events-none`,attrs:{"data-persona-composer-overlay":``},style:{position:`absolute`,left:`0`,right:`0`,bottom:`calc(var(--persona-composer-overlay-height, 0px) + var(--persona-composer-lift, 0px))`,zIndex:`20`}}),b=As({config:e}),{root:x,textNode:S}=X();return n.append(c,i,l,y),s&&n.appendChild(s),{container:n,body:l,messagesWrapper:g,starterSuggestions:h,transcriptSuggestions:_,composerOverlay:y,suggestions:b.suggestions,textarea:b.textarea,sendButton:b.sendButton,sendButtonWrapper:b.sendButtonWrapper,micButton:b.micButton,micButtonWrapper:b.micButtonWrapper,composerForm:b.composerForm,statusText:b.statusText,welcomeHost:f,welcomeIconHolder:u.iconHolder,greetingHost:d,introKicker:u.kicker,introTitle:p,introSubtitle:m,closeButton:r,closeButtonWrapper:i,clearChatButton:o,clearChatButtonWrapper:s,iconHolder:k(`span`),headerTitle:k(`span`),headerSubtitle:k(`span`),header:c,footer:b.footer,attachmentButton:b.attachmentButton,attachmentButtonWrapper:b.attachmentButtonWrapper,attachmentInput:b.attachmentInput,attachmentPreviewsContainer:b.attachmentPreviewsContainer,actionsRow:b.actionsRow,leftActions:b.leftActions,rightActions:b.rightActions,setSendButtonMode:b.setSendButtonMode,peekBanner:x,peekTextNode:S}},Pc=(e,t=!0)=>{if(es(e))return Nc(e,t);let n=O(`div`,{className:`persona-widget-container persona-flex persona-h-full persona-w-full persona-flex-1 persona-min-h-0 persona-flex-col persona-text-persona-primary persona-bg-persona-surface persona-rounded-2xl persona-overflow-hidden persona-border persona-border-persona-border`,attrs:{"data-persona-theme-zone":`container`}}),r=e?.layout?.header,i=en(e),a=r?Ds(e,r,{showClose:t}):xs({config:e,showClose:t}),o=O(`div`,{className:`persona-widget-body persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-gap-6 persona-overflow-y-auto persona-bg-persona-container persona-px-6 persona-py-6`,attrs:{id:`persona-scroll-container`,"data-persona-theme-zone":`messages`}});o.style.setProperty(`scrollbar-gutter`,`stable`);let{welcome:s,greetingHost:c}=Mc(e,o),{host:l,title:u,subtitle:d}=s,f=s.starterSuggestions,p=k(`div`,`persona-widget-messages persona-flex persona-flex-col`);p.style.gap=`var(--persona-components-message-gap, 12px)`;let m=jc(`followUp`),h=bo(e,!1);h&&(p.style.maxWidth=h,p.style.marginLeft=`auto`,p.style.marginRight=`auto`,p.style.width=`100%`),o.append(l,c,p,m);let g=ks({config:e}),_=e?.layout?.showFooter!==!1;i||(a.header.style.display=`none`),Ss(n,a,e),n.append(o);let v=O(`div`,{className:`persona-composer-overlay persona-pointer-events-none`,attrs:{"data-persona-composer-overlay":``},style:{position:`absolute`,left:`0`,right:`0`,bottom:`calc(var(--persona-composer-overlay-height, 0px) + var(--persona-composer-lift, 0px))`,zIndex:`20`}});return _||(g.footer.style.display=`none`),n.append(g.footer),n.append(v),{container:n,body:o,messagesWrapper:p,starterSuggestions:f,transcriptSuggestions:m,composerOverlay:v,suggestions:g.suggestions,textarea:g.textarea,sendButton:g.sendButton,sendButtonWrapper:g.sendButtonWrapper,micButton:g.micButton,micButtonWrapper:g.micButtonWrapper,composerForm:g.composerForm,statusText:g.statusText,welcomeHost:l,welcomeIconHolder:s.iconHolder,greetingHost:c,introKicker:s.kicker,introTitle:u,introSubtitle:d,closeButton:a.closeButton,closeButtonWrapper:a.closeButtonWrapper,clearChatButton:a.clearChatButton,clearChatButtonWrapper:a.clearChatButtonWrapper,iconHolder:a.iconHolder,headerTitle:a.headerTitle,headerSubtitle:a.headerSubtitle,header:a.header,footer:g.footer,attachmentButton:g.attachmentButton,attachmentButtonWrapper:g.attachmentButtonWrapper,attachmentInput:g.attachmentInput,attachmentPreviewsContainer:g.attachmentPreviewsContainer,actionsRow:g.actionsRow,leftActions:g.leftActions,rightActions:g.rightActions,setSendButtonMode:g.setSendButtonMode}},Fc=(e,t)=>{let n=k(`button`);n.type=`button`,n.innerHTML=`
|
|
10
|
+
`)?!1:!(e.hasAttachments||e.hasChips||e.hasQuote||e.hasPendingSubmission)}function ma(){let e=!1;return{observe:(t,n)=>n?(t&&(e=!0),e):(e=!1,!1),release:()=>{e=!1}}}function ha(e){if(!e)return!1;let t=e.ownerDocument?.defaultView;if(!t?.getComputedStyle)return!1;let n=t.getComputedStyle(e),r=Number.parseFloat(n.lineHeight),i=Number.parseFloat(n.fontSize),a=Number.isFinite(r)&&r>0?r:Number.isFinite(i)&&i>0?i*1.4:0;if(!a)return!1;let o=(Number.parseFloat(n.paddingTop)||0)+(Number.parseFloat(n.paddingBottom)||0),s=e.style.height,c=e.style.getPropertyPriority(`height`),l=e.tagName===`TEXTAREA`;l&&(e.style.height=`auto`);let u=e.scrollHeight-o;return l&&e.style.setProperty(`height`,s,c),u>a*1.5}function ga(e){return Object.freeze({text:e.text,contentParts:e.contentParts?Object.freeze([...e.contentParts]):void 0,mentionRefs:Object.freeze([...e.mentionRefs]),contentSegments:e.contentSegments?Object.freeze([...e.contentSegments]):void 0,options:Object.freeze({...e.options}),viaVoice:e.viaVoice})}function _a(e){return e.inputDisabled===!0||e.sendDisabled===!0||e.hasAttachments&&!e.attachmentsReady?!1:!!e.text||e.hasAttachments||e.hasMentions||e.hasServerMentions}const va=e=>typeof e?.then==`function`;function ya(e,t){return t===!1?{status:`canceled`}:(!t||typeof t!=`object`||(typeof t.text==`string`&&(e.text=t.text),t.options&&(e.options={...e.options,...t.options})),{status:`proceed`})}function ba(e,t,n){let r;try{r=e(ga(t),{signal:n})}catch(e){return{status:`error`,error:e}}return va(r)?Promise.resolve(r).then(e=>n.aborted?{status:`aborted`}:ya(t,e),e=>n.aborted?{status:`aborted`}:{status:`error`,error:e}):ya(t,r)}const xa=e=>e?.launcher?.variant??(e?.future?.v5Defaults===!0?`circle`:`pill`),Sa={background:`semantic.colors.primary`,foreground:`semantic.colors.textInverse`,border:`transparent`,size:`48px`,iconSize:`24px`,borderRadius:`palette.radius.full`,shadow:`0 8px 24px rgba(0,0,0,.16)`,offset:`20px`},Ca=`16px`,wa=`transparent`,Ta={colors:{primary:{50:`#ffffff`,100:`#f5f5f5`,200:`#d4d4d4`,300:`#a3a3a3`,400:`#737373`,500:`#171717`,600:`#0f0f0f`,700:`#0a0a0a`,800:`#050505`,900:`#030303`,950:`#000000`},secondary:{50:`#f5f3ff`,100:`#ede9fe`,200:`#ddd6fe`,300:`#c4b5fd`,400:`#a78bfa`,500:`#8b5cf6`,600:`#7c3aed`,700:`#6d28d9`,800:`#5b21b6`,900:`#4c1d95`,950:`#2e1065`},accent:{50:`#ecfeff`,100:`#cffafe`,200:`#a5f3fc`,300:`#67e8f9`,400:`#22d3ee`,500:`#06b6d4`,600:`#0891b2`,700:`#0e7490`,800:`#155e75`,900:`#164e63`,950:`#083344`},gray:{50:`#f9fafb`,100:`#f3f4f6`,200:`#e5e7eb`,300:`#d1d5db`,400:`#9ca3af`,500:`#6b7280`,600:`#4b5563`,700:`#374151`,800:`#1f2937`,900:`#111827`,950:`#030712`},success:{50:`#f0fdf4`,100:`#dcfce7`,200:`#bbf7d0`,300:`#86efac`,400:`#4ade80`,500:`#22c55e`,600:`#16a34a`,700:`#15803d`,800:`#166534`,900:`#14532d`},warning:{50:`#fefce8`,100:`#fef9c3`,200:`#fef08a`,300:`#fde047`,400:`#facc15`,500:`#eab308`,600:`#ca8a04`,700:`#a16207`,800:`#854d0e`,900:`#713f12`},error:{50:`#fef2f2`,100:`#fee2e2`,200:`#fecaca`,300:`#fca5a5`,400:`#f87171`,500:`#ef4444`,600:`#dc2626`,700:`#b91c1c`,800:`#991b1b`,900:`#7f1d1d`},info:{50:`#eff6ff`,100:`#dbeafe`,200:`#bfdbfe`,300:`#93c5fd`,400:`#60a5fa`,500:`#3b82f6`,600:`#2563eb`,700:`#1d4ed8`,800:`#1e40af`,900:`#1e3a8a`,950:`#172554`},purple:{50:`#faf5ff`,100:`#f3e8ff`,200:`#e9d5ff`,300:`#d8b4fe`,400:`#c084fc`,500:`#a855f7`,600:`#9333ea`,700:`#7e22ce`,800:`#6b21a8`,900:`#581c87`,950:`#3b0764`},teal:{50:`#f0fdfa`,100:`#ccfbf1`,200:`#99f6e4`,300:`#5eead4`,400:`#2dd4bf`,500:`#14b8a6`,600:`#0d9488`,700:`#0f766e`,800:`#115e59`,900:`#134e4a`,950:`#042f2e`}},spacing:(()=>{let e={};for(let t of[0,1,2,3,4,5,6,8,10,12,16,20,24,32,40,48,56,64])e[t]=t===0?`0px`:`${t/4}rem`;return e})(),typography:{fontFamily:{sans:`system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,serif:`Georgia, Cambria, "Times New Roman", Times, serif`,mono:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`},fontSize:{xs:`0.75rem`,sm:`0.875rem`,base:`1rem`,lg:`1.125rem`,xl:`1.25rem`,"2xl":`1.5rem`,"3xl":`1.875rem`,"4xl":`2.25rem`},fontWeight:{normal:`400`,medium:`500`,semibold:`600`,bold:`700`},lineHeight:{tight:`1.25`,normal:`1.5`,relaxed:`1.625`}},shadows:{none:`none`,sm:`0 1px 2px 0 rgb(0 0 0 / 0.05)`,md:`0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)`,lg:`0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)`,xl:`0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)`,"2xl":`0 25px 50px -12px rgb(0 0 0 / 0.25)`},borders:{none:`none`,sm:`1px solid`,md:`2px solid`,lg:`4px solid`},radius:{none:`0px`,sm:`0.125rem`,md:`0.375rem`,lg:`0.5rem`,xl:`0.75rem`,"2xl":`1rem`,full:`9999px`}},Ea={colors:{primary:`palette.colors.primary.500`,secondary:`palette.colors.secondary.500`,accent:`palette.colors.primary.600`,surface:`palette.colors.gray.50`,background:`palette.colors.gray.50`,container:`palette.colors.gray.50`,text:`palette.colors.gray.900`,textMuted:`palette.colors.gray.500`,textInverse:`palette.colors.gray.50`,border:`palette.colors.gray.200`,divider:`palette.colors.gray.200`,interactive:{default:`palette.colors.primary.600`,hover:`palette.colors.primary.700`,focus:`palette.colors.primary.600`,active:`palette.colors.primary.600`,disabled:`palette.colors.gray.300`},feedback:{success:`palette.colors.success.500`,warning:`palette.colors.warning.500`,error:`palette.colors.error.500`,info:`palette.colors.info.500`}},spacing:{xs:`palette.spacing.1`,sm:`palette.spacing.2`,md:`palette.spacing.4`,lg:`palette.spacing.6`,xl:`palette.spacing.8`,"2xl":`palette.spacing.10`},typography:{fontFamily:`palette.typography.fontFamily.sans`,fontSize:`palette.typography.fontSize.base`,fontWeight:`palette.typography.fontWeight.normal`,lineHeight:`palette.typography.lineHeight.normal`}},Da={button:{primary:{background:`palette.colors.primary.500`,foreground:`palette.colors.primary.50`,borderRadius:`palette.radius.lg`,padding:`semantic.spacing.md`},secondary:{background:`semantic.colors.surface`,foreground:`semantic.colors.secondary`,borderRadius:`palette.radius.lg`,padding:`semantic.spacing.md`},ghost:{background:`transparent`,foreground:`semantic.colors.text`,borderRadius:`palette.radius.md`,padding:`semantic.spacing.sm`,hoverBackground:`rgba(0, 0, 0, 0.05)`}},input:{background:`semantic.colors.surface`,placeholder:`semantic.colors.textMuted`,borderRadius:`palette.radius.lg`,padding:`semantic.spacing.md`,focus:{border:`palette.colors.gray.400`,ring:`palette.colors.gray.400`}},launcher:{background:`semantic.colors.surface`,foreground:`semantic.colors.primary`,border:`semantic.colors.border`,size:`60px`,iconSize:`28px`,borderRadius:`palette.radius.full`,shadow:`palette.shadows.lg`},panel:{width:E,maxWidth:`none`,height:`min(640px, max(200px, calc(100vh - 64px)))`,maxHeight:`none`,borderRadius:`palette.radius.xl`,shadow:`palette.shadows.xl`,inset:Ca,canvasBackground:wa,modes:{floating:{border:`1px solid var(--persona-border)`,shadow:`palette.shadows.xl`,borderRadius:`palette.radius.xl`},inline:{border:`1px solid var(--persona-border)`,shadow:`none`,borderRadius:`palette.radius.xl`},docked:{border:`none`,shadow:`none`,borderRadius:`palette.radius.xl`},sidebar:{border:`none`,borderRadius:`0`},mobile:{border:`none`,shadow:`none`,borderRadius:`0`}}},header:{background:`palette.colors.primary.500`,foreground:`palette.colors.primary.50`,borderRadius:`palette.radius.xl palette.radius.xl 0 0`,padding:`20px 24px`,minimalPadding:`16px 24px`,iconBackground:`palette.colors.primary.600`,iconForeground:`palette.colors.primary.50`},message:{gap:`12px`,user:{background:`palette.colors.primary.500`,text:`palette.colors.primary.50`,borderRadius:`palette.radius.lg`,shadow:`palette.shadows.sm`},assistant:{background:`semantic.colors.container`,text:`semantic.colors.text`,borderRadius:`palette.radius.lg`,border:`semantic.colors.border`,shadow:`palette.shadows.sm`},border:`semantic.colors.border`},introCard:{background:`transparent`,borderRadius:`palette.radius.2xl`,padding:`semantic.spacing.lg`,shadow:`palette.shadows.none`},suggestion:{chip:{background:`semantic.colors.surface`,foreground:`semantic.colors.text`,border:`semantic.colors.border`,borderRadius:`palette.radius.full`,padding:`0.5rem 0.875rem`,gap:`0.5rem`,itemGap:`8px`,minHeight:`36px`,fontSize:`0.8125rem`,lineHeight:`1.25`,iconSize:`16px`,hoverBackground:`palette.colors.gray.100`,hoverBorder:`palette.colors.gray.300`,pressedBackground:`palette.colors.gray.200`,focusRing:`semantic.colors.interactive.focus`,disabledOpacity:`0.5`},card:{background:`semantic.colors.surface`,foreground:`semantic.colors.text`,border:`semantic.colors.border`,borderRadius:`palette.radius.xl`,padding:`1rem`,shadow:`palette.shadows.sm`,gap:`0.625rem`,itemGap:`8px`,minHeight:`72px`,fontSize:`0.875rem`,lineHeight:`1.35`,iconSize:`18px`,hoverBackground:`palette.colors.gray.100`,hoverBorder:`palette.colors.gray.300`,pressedBackground:`palette.colors.gray.200`,focusRing:`semantic.colors.interactive.focus`,disabledOpacity:`0.5`},list:{background:`transparent`,foreground:`semantic.colors.text`,border:`semantic.colors.border`,borderRadius:`palette.radius.md`,padding:`0.75rem`,gap:`0.625rem`,itemGap:`8px`,minHeight:`44px`,fontSize:`0.875rem`,lineHeight:`1.35`,iconSize:`17px`,hoverBackground:`palette.colors.gray.100`,hoverBorder:`palette.colors.gray.300`,pressedBackground:`palette.colors.gray.200`,focusRing:`semantic.colors.interactive.focus`,disabledOpacity:`0.5`}},toolBubble:{shadow:`palette.shadows.sm`},reasoningBubble:{shadow:`palette.shadows.sm`},composer:{shadow:`palette.shadows.none`},scrollbar:{thumb:`semantic.colors.border`,track:`transparent`},markdown:{inlineCode:{background:`palette.colors.gray.50`,foreground:`palette.colors.gray.900`},link:{foreground:`palette.colors.primary.600`},prose:{fontFamily:`inherit`},codeBlock:{background:`semantic.colors.container`,borderColor:`semantic.colors.border`,textColor:`inherit`,borderRadius:`palette.radius.md`},table:{headerBackground:`semantic.colors.container`,borderColor:`semantic.colors.border`},hr:{color:`semantic.colors.divider`},blockquote:{borderColor:`palette.colors.gray.900`,background:`transparent`,textColor:`palette.colors.gray.500`}},collapsibleWidget:{container:`palette.colors.gray.50`,surface:`semantic.colors.surface`,border:`semantic.colors.border`},voice:{recording:{indicator:`palette.colors.error.500`,background:`palette.colors.error.50`,border:`palette.colors.error.200`},processing:{icon:`palette.colors.primary.500`,background:`palette.colors.primary.50`},speaking:{icon:`palette.colors.success.500`}},approval:{requested:{background:`semantic.colors.surface`,border:`semantic.colors.border`,text:`palette.colors.gray.900`,shadow:`0 1px 2px 0 rgba(11, 11, 11, 0.06), 0 2px 8px 0 rgba(11, 11, 11, 0.04)`},approve:{background:`semantic.colors.primary`,foreground:`semantic.colors.textInverse`,borderRadius:`palette.radius.md`,padding:`semantic.spacing.sm`},deny:{background:`semantic.colors.container`,foreground:`semantic.colors.text`,borderRadius:`palette.radius.md`,padding:`semantic.spacing.sm`}},attachment:{image:{background:`palette.colors.gray.100`,border:`palette.colors.gray.200`}},eventStream:{badge:{flow:{background:`palette.colors.success.100`,foreground:`palette.colors.success.700`},step:{background:`palette.colors.primary.100`,foreground:`palette.colors.primary.700`},reasoning:{background:`palette.colors.warning.100`,foreground:`palette.colors.warning.700`},tool:{background:`palette.colors.purple.100`,foreground:`palette.colors.purple.800`},agent:{background:`palette.colors.teal.100`,foreground:`palette.colors.teal.800`},error:{background:`palette.colors.error.100`,foreground:`palette.colors.error.700`},default:{background:`palette.colors.gray.100`,foreground:`palette.colors.gray.600`}}},scrollToBottom:{background:`components.button.primary.background`,foreground:`components.button.primary.foreground`,border:`semantic.colors.primary`,size:`40px`,borderRadius:`palette.radius.full`,shadow:`palette.shadows.sm`,padding:`0.5rem 0.875rem`,gap:`0.5rem`,fontSize:`0.875rem`,iconSize:`14px`},artifact:{pane:{background:`semantic.colors.container`,toolbarBackground:`semantic.colors.container`}}},Oa=Ta.colors.gray,ka={50:`#fafafa`,100:`#f5f5f5`,200:`#e5e5e5`,300:`#d4d4d4`,400:`#a3a3a3`,500:`#737373`,600:`#525252`,700:`#404040`,800:`#262626`,900:`#171717`,950:`#0a0a0a`},Aa={...Ta,colors:{...Ta.colors,gray:Oa}},ja={...Ta,colors:{...Ta.colors,gray:ka},radius:{none:`0px`,sm:`4px`,md:`8px`,lg:`12px`,xl:`16px`,"2xl":`24px`,full:`9999px`}},Ma=Ea,Na={...Ea,colors:{...Ea.colors,surface:`#ffffff`,background:`#ffffff`,container:`semantic.colors.surface`,textInverse:`#ffffff`},typography:{...Ea.typography,fontSize:`14px`,lineHeight:`1.5`}},Pa=Da,Fa={...Da,scrollToBottom:{...Da.scrollToBottom,background:`semantic.colors.surface`,foreground:`semantic.colors.text`,border:`semantic.colors.border`,size:`32px`},messageActions:{background:`transparent`,border:`none`,hoverBackground:`components.button.ghost.hoverBackground`,hoverForeground:`semantic.colors.text`,borderRadius:`palette.radius.md`},launcher:Sa,activity:{labelSize:`13px`,iconSize:`16px`,indent:`0px`,transcriptGap:`0px`,responseGap:`12px`,groupIndent:`16px`,groupGap:`2px`,groupPadding:`2px 0`,bodyPadding:`4px 0`,bodyFontWeight:`400`,sectionGap:`8px`,bodySurface:`transparent`},toolBubble:{shadow:`none`},reasoningBubble:{shadow:`none`},input:{...Da.input,borderRadius:`palette.radius.full`},introCard:{...Da.introCard,title:{fontSize:`22px`,fontWeight:`500`}},suggestion:{chip:{...Da.suggestion.chip,fontWeight:`400`},card:{...Da.suggestion.card,fontWeight:`400`},list:{...Da.suggestion.list,fontWeight:`400`}},panel:{...Da.panel,width:`min(400px, calc(100vw - 24px))`,height:`min(704px, calc(100dvh - 104px))`,borderRadius:`palette.radius.xl`},header:{...Da.header,background:`semantic.colors.container`,foreground:`semantic.colors.text`,padding:`8px 8px 8px 16px`,minimalPadding:`8px 8px 8px 16px`,minHeight:`48px`,borderBottom:`none`,iconBackground:`transparent`,iconForeground:`semantic.colors.text`,iconScale:`1`,iconPadding:`auto`,controlSize:`28px`,controlIconSize:`16px`,controlStrokeWidth:`1.5`,actionIconForeground:`semantic.colors.textMuted`,controlBorderRadius:`8px`,controlHoverBackground:`color-mix(in srgb, var(--persona-text) 8%, transparent)`,controlHoverForeground:`semantic.colors.text`,controlFocusOutline:`2px solid color-mix(in srgb, var(--persona-text) 50%, transparent)`,title:{fontSize:`14px`,fontWeight:`500`,lineHeight:`1.5`}},message:{...Da.message,gap:`20px`,fullscreenGap:`28px`,topFadeHeight:`18px`,user:{...Da.message.user,background:`palette.colors.gray.100`,text:`semantic.colors.text`,borderRadius:`palette.radius.xl`,shadow:`none`,padding:`8px 14px`,fontSize:`14px`,lineHeight:`1.5`},assistant:{...Da.message.assistant,background:`transparent`,border:`transparent`,borderWidth:`0px`,borderRadius:`0px`,shadow:`none`,padding:`0px`,fontSize:`14px`,lineHeight:`1.55`}},artifact:{...Da.artifact,card:{background:`semantic.colors.surface`,border:`1px solid var(--persona-border)`,borderRadius:`palette.radius.lg`,hoverBackground:`components.button.ghost.hoverBackground`,hoverBorderColor:`semantic.colors.border`},inline:{background:`semantic.colors.surface`,border:`1px solid var(--persona-border)`,borderRadius:`palette.radius.lg`,chromeBackground:`semantic.colors.surface`,chromeBorder:`semantic.colors.border`,titleColor:`semantic.colors.text`,mutedColor:`semantic.colors.textMuted`}},composer:{...Da.composer,padding:`8px`,fontSize:`15px`,lineHeight:`1.5`,controlSize:`32px`,controlIconSize:`20px`,expandedPadding:`12px 16px`,expandedBorderRadius:`24px`,sendIconSize:`18px`,sendButtonRadius:`9999px`,footerBorder:`none`,overflowMenu:{borderRadius:`12px`},overlayBand:`linear-gradient(to bottom, transparent, var(--persona-container) 24px)`,focusBorderColor:`color-mix(in srgb, var(--persona-text) 28%, var(--persona-border))`,focusRing:`1px solid color-mix(in srgb, var(--persona-text) 12%, transparent)`}},Ia=e=>fe({future:e}),La=e=>Ia(e)===`v5`?{palette:ja,semantic:Na,components:Fa}:{palette:Aa,semantic:Ma,components:Pa};function Ra(e,t){if(!t.startsWith(`palette.`)&&!t.startsWith(`semantic.`)&&!t.startsWith(`components.`))return t;let n=t.split(`.`),r=e;for(let e of n){if(r==null)return;r=r[e]}return typeof r==`string`&&(r.startsWith(`palette.`)||r.startsWith(`semantic.`)||r.startsWith(`components.`))?Ra(e,r):r}function za(e){let t={};function n(r,i){for(let[a,o]of Object.entries(r)){let r=`${i}.${a}`;if(typeof o==`string`){let n=Ra(e,o);n!==void 0&&(t[r]={path:r,value:n,type:i.includes(`color`)?`color`:i.includes(`spacing`)?`spacing`:i.includes(`typography`)?`typography`:i.includes(`shadow`)?`shadow`:i.includes(`border`)?`border`:`color`})}else typeof o==`object`&&o&&n(o,r)}}return n(e.palette,`palette`),n(e.semantic,`semantic`),n(e.components,`components`),t}function Ba(e){let t=[],n=[];return e.palette||t.push({path:`palette`,message:`Theme must include a palette`,severity:`error`}),e.semantic||n.push({path:`semantic`,message:`No semantic tokens defined - defaults will be used`,severity:`warning`}),e.components||n.push({path:`components`,message:`No component tokens defined - defaults will be used`,severity:`warning`}),{valid:t.length===0,errors:t,warnings:n}}function Va(e,t){let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];n[e]=t&&typeof t==`object`&&!Array.isArray(t)&&r&&typeof r==`object`&&!Array.isArray(r)?Va(t,r):r}return n}function Ha(e,t={}){let n=La(t.future),r=e?.components,i={palette:{...n.palette,...e?.palette,colors:{...n.palette.colors,...e?.palette?.colors},spacing:{...n.palette.spacing,...e?.palette?.spacing},typography:{...n.palette.typography,...e?.palette?.typography},shadows:{...n.palette.shadows,...e?.palette?.shadows},borders:{...n.palette.borders,...e?.palette?.borders},radius:{...n.palette.radius,...e?.palette?.radius}},semantic:{...n.semantic,...e?.semantic,colors:{...n.semantic.colors,...e?.semantic?.colors,interactive:{...n.semantic.colors.interactive,...e?.semantic?.colors?.interactive},feedback:{...n.semantic.colors.feedback,...e?.semantic?.colors?.feedback}},spacing:{...n.semantic.spacing,...e?.semantic?.spacing},typography:{...n.semantic.typography,...e?.semantic?.typography}},components:r?Va(n.components,r):n.components},a=r?.activity;for(let e of[`toolBubble`,`reasoningBubble`]){let t=i.components[e]={...i.components[e]};for(let n of[`rowHeight`,`labelSize`,`iconSize`,`indent`,`bodySurface`])a?.[n]!==void 0&&(n!==`bodySurface`||r?.[e]?.bodySurface===void 0)&&(t[n]=a[n])}let o=r?.collapsibleWidget?.surface;fe(t)===`v4`&&o!==void 0&&a?.bodySurface===void 0&&(i.components.activity={...i.components.activity,bodySurface:o});let s=r?.header;s?.padding!==void 0&&s.minimalPadding===void 0&&(i.components.header.minimalPadding=i.components.header.padding);let c=r?.composer;i.components.composer={...i.components.composer},c?.padding!==void 0&&c.expandedPadding===void 0&&(i.components.composer.expandedPadding=c.padding),r?.input?.borderRadius!==void 0&&c?.expandedBorderRadius===void 0&&(i.components.composer.expandedBorderRadius=r.input.borderRadius);let l=r?.message;if(l?.gap!==void 0&&l.fullscreenGap===void 0&&(i.components.message.fullscreenGap=i.components.message.gap),t.validate!==!1){let e=Ba(i);if(!e.valid)throw Error(`Theme validation failed: ${e.errors.map(e=>e.message).join(`, `)}`)}if(t.plugins)for(let e of t.plugins)i=e.transform(i);return i}const Ua=e=>e.trim()===`0`?`0px`:e,Wa=`--persona-`,Ga=e=>{if(!e)return;let t=e.trim().toLowerCase(),n;if(t.charCodeAt(0)===35){let e=t.slice(1);if(!/^[0-9a-f]+$/.test(e))return;e.length===3||e.length===4?n=[0,1,2].map(t=>parseInt(e[t]+e[t],16)):(e.length===6||e.length===8)&&(n=[0,2,4].map(t=>parseInt(e.slice(t,t+2),16)))}else{let e=t.match(/^rgba?\(([^)]+)\)$/);if(e){let t=e[1].split(/[,/\s]+/).filter(Boolean);t.length>=3&&(n=t.slice(0,3).map(e=>{let t=e.endsWith(`%`),n=parseFloat(t?e.slice(0,-1):e);return t?n/100*255:n}))}}if(!n||n.some(e=>!Number.isFinite(e)))return;let[r,i,a]=n.map(e=>{let t=Math.max(0,Math.min(255,e))/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a},Ka=(e,t)=>{for(let[n,...r]of t){let t;for(let n of r)if(t=n.charCodeAt(0)===61?n.slice(1):e[Wa+n],t!==void 0)break;t!==void 0&&(e[Wa+n]=t)}},qa=[[`primary`,`semantic-colors-primary`,`palette-colors-primary-500`],[`secondary`,`semantic-colors-secondary`,`palette-colors-secondary-500`],[`accent`,`semantic-colors-accent`,`palette-colors-accent-500`],[`surface`,`semantic-colors-surface`,`palette-colors-gray-50`],[`background`,`semantic-colors-background`,`palette-colors-gray-50`],[`container`,`semantic-colors-container`,`palette-colors-gray-100`],[`text`,`semantic-colors-text`,`palette-colors-gray-900`],[`text-muted`,`semantic-colors-textMuted`,`palette-colors-gray-500`],[`text-inverse`,`semantic-colors-textInverse`,`palette-colors-gray-50`],[`border`,`semantic-colors-border`,`palette-colors-gray-200`],[`divider`,`semantic-colors-divider`,`palette-colors-gray-200`],[`muted`,`text-muted`],[`font-family`,`semantic-typography-fontFamily`,`palette-typography-fontFamily-sans`],[`font-size`,`semantic-typography-fontSize`,`palette-typography-fontSize-base`],[`font-weight`,`semantic-typography-fontWeight`,`palette-typography-fontWeight-normal`],[`line-height`,`semantic-typography-lineHeight`,`palette-typography-lineHeight-normal`],[`input-font-family`,`font-family`],[`input-font-weight`,`font-weight`],[`radius-sm`,`palette-radius-sm`,`=0.125rem`],[`radius-md`,`palette-radius-md`,`=0.375rem`],[`radius-lg`,`palette-radius-lg`,`=0.5rem`],[`radius-xl`,`palette-radius-xl`,`=0.75rem`],[`radius-full`,`palette-radius-full`,`=9999px`],[`launcher-radius`,`components-launcher-borderRadius`,`palette-radius-full`,`=9999px`],[`launcher-bg`,`components-launcher-background`,`surface`],[`launcher-fg`,`components-launcher-foreground`,`primary`]],Ja=e=>{let t=za(e),n={};for(let[e,r]of Object.entries(t)){let t=e.replace(/\./g,`-`);n[`--persona-${t}`]=r.value}return n},Ya=e=>{let t=e[`--persona-components-launcher-foreground`];e[`--persona-launcher-fg-muted`]=t&&t!==e[`--persona-primary`]?`color-mix(in srgb, ${t} 70%, transparent)`:e[`--persona-muted`]},Xa=e=>{if(e[`--persona-components-header-iconPadding`]===`auto`){let t=(e[`--persona-components-header-iconBackground`]??e[`--persona-primary`]).trim().toLowerCase(),n=t.match(/^(?:rgba?|hsla?)\(([^)]+)\)$/)?.[1].split(/[,\s/]+/).filter(Boolean);e[`--persona-components-header-iconPadding`]=t===`transparent`||/^#(?:[\da-f]{3}0|[\da-f]{6}00)$/.test(t)||n?.length===4&&parseFloat(n[3])===0?`0px`:`6px`}};function Za(e){let t=Ja(e);Ka(t,qa),Ka(t,[[`ask-sheet-bg`,`components-askUserQuestion-sheet-background`],[`ask-sheet-border`,`components-askUserQuestion-sheet-border`],[`ask-sheet-shadow`,`components-askUserQuestion-sheet-shadow`],[`ask-pill-bg`,`components-askUserQuestion-pill-background`],[`ask-pill-fg`,`components-askUserQuestion-pill-foreground`],[`ask-pill-radius`,`components-askUserQuestion-pill-borderRadius`],[`ask-pill-bg-selected`,`components-askUserQuestion-pill-selectedBackground`],[`ask-pill-fg-selected`,`components-askUserQuestion-pill-selectedForeground`],[`ask-input-bg`,`components-askUserQuestion-customInput-background`],[`voice-recording-indicator`,`components-voice-recording-indicator`,`palette-colors-error-500`],[`voice-recording-bg`,`components-voice-recording-background`,`palette-colors-error-50`],[`voice-processing-icon`,`components-voice-processing-icon`,`palette-colors-primary-500`],[`voice-speaking-icon`,`components-voice-speaking-icon`,`palette-colors-success-500`],[`approval-bg`,`components-approval-requested-background`,`surface`],[`approval-border`,`components-approval-requested-border`,`border`],[`approval-text`,`components-approval-requested-text`,`palette-colors-gray-900`],[`approval-shadow`,`components-approval-requested-shadow`,`=0 1px 2px 0 rgba(11, 11, 11, 0.06), 0 2px 8px 0 rgba(11, 11, 11, 0.04)`],[`approval-approve-bg`,`components-approval-approve-background`,`button-primary-bg`],[`approval-deny-bg`,`components-approval-deny-background`,`container`],[`attachment-image-bg`,`components-attachment-image-background`,`palette-colors-gray-100`],[`attachment-image-border`,`components-attachment-image-border`,`palette-colors-gray-200`]]),Ya(t),Ka(t,[[`launcher-border`,`components-launcher-border`,`border`],[`button-primary-bg`,`components-button-primary-background`,`primary`],[`button-primary-fg`,`components-button-primary-foreground`,`text-inverse`],[`button-radius`,`components-button-primary-borderRadius`,`palette-radius-full`,`=9999px`],[`button-stop-bg`,`components-button-stop-background`],[`button-stop-fg`,`components-button-stop-foreground`]]),Ka(t,[[`button-ghost-bg`,`components-button-ghost-background`,`=transparent`],[`button-ghost-fg`,`components-button-ghost-foreground`,`text`],[`button-ghost-radius`,`components-button-ghost-borderRadius`,`radius-md`,`=0.375rem`],[`button-ghost-hover-bg`,`components-button-ghost-hoverBackground`,`=rgba(0, 0, 0, 0.05)`],[`panel-radius`,`components-panel-borderRadius`,`radius-xl`,`=0.75rem`]]),t[`--persona-panel-border`]=t[`--persona-components-panel-border`]??`1px solid ${t[`--persona-border`]}`,Ka(t,[[`panel-shadow`,`components-panel-shadow`,`palette-shadows-xl`,`=0 25px 50px -12px rgba(0, 0, 0, 0.25)`]]),t[`--persona-panel-inset`]=t[`--persona-components-panel-inset`]??`16px`,t[`--persona-panel-canvas-bg`]=t[`--persona-components-panel-canvasBackground`]??`transparent`,Ka(t,[[`launcher-shadow`,`components-launcher-shadow`,`=0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)`],[`input-radius`,`components-input-borderRadius`,`radius-lg`,`=0.5rem`],[`message-user-radius`,`components-message-user-borderRadius`,`radius-lg`,`=0.5rem`],[`message-assistant-radius`,`components-message-assistant-borderRadius`,`radius-lg`,`=0.5rem`]]);let n=(n,r,i,a=``)=>{if(n)for(let[o,s,c]of i){let i=n[a+o];i&&(t[`--persona-${r}${s}`]=c?Ra(e,i)??i:i)}};Ka(t,[[`header-bg`,`components-header-background`,`surface`]]);let r=t[`--persona-header-bg`],i=t[`--persona-components-header-foreground`],a=i?`color-mix(in srgb, ${i} 72%, ${r})`:void 0;t[`--persona-header-border`]=t[`--persona-components-header-border`]??(i?`color-mix(in srgb, ${i} 14%, ${r})`:void 0)??t[`--persona-divider`],Ka(t,[[`header-icon-bg`,`components-header-iconBackground`,`primary`],[`header-icon-fg`,`components-header-iconForeground`,`text-inverse`]]),Xa(t),t[`--persona-header-title-fg`]=t[`--persona-components-header-title-color`]??t[`--persona-components-header-titleForeground`]??i??t[`--persona-primary`],t[`--persona-header-subtitle-fg`]=t[`--persona-components-header-subtitle-color`]??t[`--persona-components-header-subtitleForeground`]??a??t[`--persona-text-muted`],t[`--persona-header-action-icon-fg`]=t[`--persona-components-header-actionIconForeground`]??a??t[`--persona-muted`],Ka(t,[[`header-control-size`,`components-header-controlSize`,`=32px`],[`header-control-icon-size`,`components-header-controlIconSize`,`=16px`]]),n(e.components?.header,`header-`,[[`shadow`,`shadow`],[`borderBottom`,`border-bottom`],[`minHeight`,`min-height`]]),n(t,`history-rail-header-`,[[`background`,`bg`],[`border`,`border`],[`minHeight`,`min-height`]],`--persona-components-history-railHeader-`),n(t,`history-overlay-`,[[`margin`,`margin`],[`borderRadius`,`radius`],[`shadow`,`shadow`],[`background`,`bg`]],`--persona-components-history-overlay-`),n(t,`history-menu-`,[[`background`,`bg`],[`borderRadius`,`radius`]],`--persona-components-history-menu-`);let o=e.components?.history?.motion;if(o){let e=e=>{if(e===void 0)return;let t=String(e).trim();return/^\d+(\.\d+)?$/.test(t)?`${t}ms`:t},n=e(o.enterDurationMs);n!==void 0&&(t[`--persona-history-enter-ms`]=n);let r=e(o.exitDurationMs);r!==void 0&&(t[`--persona-history-exit-ms`]=r),o.enterEasing&&(t[`--persona-history-enter-easing`]=o.enterEasing),o.exitEasing&&(t[`--persona-history-exit-easing`]=o.exitEasing)}let s=t[`--persona-components-history-dangerForeground`];s&&(t[`--persona-history-danger-fg`]=s),t[`--persona-danger`]=t[`--persona-components-history-confirm-dangerBackground`]??t[`--persona-palette-colors-error-700`]??`#b42318`,t[`--persona-danger-fg`]=t[`--persona-components-history-confirm-dangerForeground`]??`#ffffff`;for(let e of[`scrim`,`shadow`]){let n=t[`--persona-components-history-confirm-${e}`];n&&(t[`--persona-history-confirm-${e}`]=n)}n(t,`tooltip-`,[[`background`,`background`],[`foreground`,`foreground`],[`hintForeground`,`hint-fg`],[`borderRadius`,`radius`],[`fontSize`,`font-size`],[`padding`,`padding`],[`maxWidth`,`max-width`],[`shadow`,`shadow`]],`--persona-components-tooltip-`),e.components?.tooltip?.arrow===!1&&(t[`--persona-tooltip-arrow-display`]=`none`),n(t,`scroll-to-bottom-count-`,[[`background`,`bg`],[`foreground`,`fg`],[`border`,`border`],[`borderRadius`,`radius`],[`size`,`size`],[`padding`,`padding`],[`fontSize`,`font-size`],[`fontWeight`,`font-weight`]],`--persona-components-scrollToBottom-countBadge-`),n(t,`message-action-`,[[`background`,`bg`],[`border`,`border`],[`hoverBackground`,`hover-bg`],[`hoverForeground`,`hover-fg`],[`borderRadius`,`radius`]],`--persona-components-messageActions-`),Ka(t,[[`intro-card-bg`,`components-introCard-background`,`=transparent`],[`intro-card-radius`,`components-introCard-borderRadius`,`=1rem`]]);let c=t[`--persona-components-introCard-background`],l=t[`--persona-components-introCard-shadow`],u=(!c||c===`transparent`||c===`none`)&&(!l||l===`none`),d=t[`--persona-components-introCard-padding`]??`1.5rem`;t[`--persona-intro-card-padding`]=u&&d===`1.5rem`?`1.5rem 0`:d,Ka(t,[[`intro-card-shadow`,`components-introCard-shadow`,`=none`],[`intro-card-border`,`components-introCard-border`,`=none`],[`input-background`,`components-input-background`,`surface`],[`input-placeholder`,`components-input-placeholder`,`text-muted`],[`input-backdrop-filter`,`components-input-backdropFilter`,`=none`],[`message-user-bg`,`components-message-user-background`,`accent`],[`message-user-text`,`components-message-user-text`,`text-inverse`],[`message-user-shadow`,`components-message-user-shadow`,`=0 5px 15px rgba(15, 23, 42, 0.08)`],[`message-assistant-bg`,`components-message-assistant-background`,`surface`],[`message-assistant-text`,`components-message-assistant-text`,`text`],[`message-assistant-border`,`components-message-assistant-border`,`border`],[`message-assistant-shadow`,`components-message-assistant-shadow`,`=0 1px 2px 0 rgb(0 0 0 / 0.05)`],[`scroll-to-bottom-bg`,`components-scrollToBottom-background`,`button-primary-bg`,`accent`],[`scroll-to-bottom-fg`,`components-scrollToBottom-foreground`,`button-primary-fg`,`text-inverse`],[`scroll-to-bottom-border`,`components-scrollToBottom-border`,`primary`],[`scroll-to-bottom-size`,`components-scrollToBottom-size`,`=40px`],[`scroll-to-bottom-radius`,`components-scrollToBottom-borderRadius`,`button-radius`,`radius-full`,`=9999px`],[`scroll-to-bottom-shadow`,`components-scrollToBottom-shadow`,`palette-shadows-sm`,`=0 1px 2px 0 rgb(0 0 0 / 0.05)`],[`scroll-to-bottom-padding`,`components-scrollToBottom-padding`,`=0.5rem 0.875rem`],[`scroll-to-bottom-gap`,`components-scrollToBottom-gap`,`=0.5rem`],[`scroll-to-bottom-font-size`,`components-scrollToBottom-fontSize`,`palette-typography-fontSize-sm`,`=0.875rem`],[`scroll-to-bottom-icon-size`,`components-scrollToBottom-iconSize`,`=14px`],[`event-badge-flow-bg`,`components-eventStream-badge-flow-background`,`=#dcfce7`],[`event-badge-flow-fg`,`components-eventStream-badge-flow-foreground`,`=#15803d`],[`event-badge-step-bg`,`components-eventStream-badge-step-background`,`=#f5f5f5`],[`event-badge-step-fg`,`components-eventStream-badge-step-foreground`,`=#0a0a0a`],[`event-badge-reasoning-bg`,`components-eventStream-badge-reasoning-background`,`=#fef9c3`],[`event-badge-reasoning-fg`,`components-eventStream-badge-reasoning-foreground`,`=#a16207`],[`event-badge-tool-bg`,`components-eventStream-badge-tool-background`,`=#f3e8ff`],[`event-badge-tool-fg`,`components-eventStream-badge-tool-foreground`,`=#6b21a8`],[`event-badge-agent-bg`,`components-eventStream-badge-agent-background`,`=#ccfbf1`],[`event-badge-agent-fg`,`components-eventStream-badge-agent-foreground`,`=#115e59`],[`event-badge-error-bg`,`components-eventStream-badge-error-background`,`=#fee2e2`],[`event-badge-error-fg`,`components-eventStream-badge-error-foreground`,`=#b91c1c`],[`event-badge-default-bg`,`components-eventStream-badge-default-background`,`=#f3f4f6`],[`event-badge-default-fg`,`components-eventStream-badge-default-foreground`,`=#4b5563`],[`tool-bubble-shadow`,`components-toolBubble-shadow`,`=0 5px 15px rgba(15, 23, 42, 0.08)`],[`reasoning-bubble-shadow`,`components-reasoningBubble-shadow`,`=0 5px 15px rgba(15, 23, 42, 0.08)`],[`composer-shadow`,`components-composer-shadow`,`=none`]]),Ka(t,[[`panel-background`,`components-panel-background`,`surface`],[`transcript-background`,`components-message-background`,`container`],[`transcript-top-fade-background`,`components-message-topFadeBackground`,`transcript-background`],[`composer-footer-background`,`components-composer-footerBackground`,`surface`],[`composer-footer-padding`,`components-composer-footerPadding`,`=1rem 1.5rem`],[`composer-padding`,`components-composer-padding`,`=0.75rem 1rem`],[`composer-gap`,`components-composer-gap`,`=0.5rem`],[`composer-font-size`,`components-composer-fontSize`,`=0.875rem`],[`composer-line-height`,`components-composer-lineHeight`,`=1.25rem`],[`composer-control-size`,`components-composer-controlSize`,`=40px`],[`composer-control-icon-size`,`components-composer-controlIconSize`,`=24px`],[`motion-duration-fast`,`components-motion-durationFast`,`=120ms`],[`motion-duration-base`,`components-motion-durationBase`,`=200ms`],[`motion-easing`,`components-motion-easing`,`=cubic-bezier(0.2, 0, 0, 1)`],[`composer-border-color`,`components-composer-borderColor`,`border`,`=#e5e7eb`],[`composer-overlay-band`,`components-composer-overlayBand`,`=transparent`],[`scrollbar-thumb`,`components-scrollbar-thumb`,`border`,`=#e5e7eb`],[`scrollbar-track`,`components-scrollbar-track`,`=transparent`],[`md-inline-code-bg`,`components-markdown-inlineCode-background`,`container`],[`md-inline-code-color`,`components-markdown-inlineCode-foreground`,`text`],[`md-link-color`,`components-markdown-link-foreground`,`accent`,`=#0f0f0f`]]),n(t,`md-`,[[`h1-fontSize`,`h1-size`],[`h1-fontWeight`,`h1-weight`],[`h2-fontSize`,`h2-size`],[`h2-fontWeight`,`h2-weight`]],`--persona-components-markdown-heading-`);let f=t[`--persona-components-markdown-prose-fontFamily`];f&&f!==`inherit`&&(t[`--persona-md-prose-font-family`]=f),Ka(t,[[`md-code-block-bg`,`components-markdown-codeBlock-background`,`container`],[`md-code-block-border-color`,`components-markdown-codeBlock-borderColor`,`border`],[`md-code-block-text-color`,`components-markdown-codeBlock-textColor`,`=inherit`]]),Ka(t,[[`md-code-block-border-radius`,`components-markdown-codeBlock-borderRadius`,`radius-md`,`=0.375rem`]]),Ka(t,[[`md-table-header-bg`,`components-markdown-table-headerBackground`,`container`],[`md-table-border-color`,`components-markdown-table-borderColor`,`border`]]),Ka(t,[[`md-hr-color`,`components-markdown-hr-color`,`divider`]]),Ka(t,[[`md-blockquote-border-color`,`components-markdown-blockquote-borderColor`,`palette-colors-gray-900`],[`md-blockquote-bg`,`components-markdown-blockquote-background`,`=transparent`],[`md-blockquote-text-color`,`components-markdown-blockquote-textColor`,`palette-colors-gray-500`]]);for(let[e,n]of[[`container`,`surface`],[`surface`,`surface`],[`border`,`border`]]){let r=t[`--persona-components-collapsibleWidget-${e}`]??t[`--persona-${n}`];r!==void 0&&(t[`--persona-cw-${e}`]=r,t[`--cw-${e}`]=r)}Ka(t,[[`message-border`,`components-message-border`,`border`]]),Ka(t,[[`message-user-padding`,`components-message-user-padding`],[`message-user-max-width`,`components-message-user-maxWidth`],[`message-user-font-size`,`components-message-user-fontSize`],[`message-user-font-family`,`components-message-user-fontFamily`],[`message-user-line-height`,`components-message-user-lineHeight`],[`message-assistant-padding`,`components-message-assistant-padding`],[`message-assistant-border-width`,`components-message-assistant-borderWidth`],[`message-assistant-max-width`,`components-message-assistant-maxWidth`],[`message-assistant-font-size`,`components-message-assistant-fontSize`],[`message-assistant-font-family`,`components-message-assistant-fontFamily`],[`message-assistant-line-height`,`components-message-assistant-lineHeight`]]);let p=e.components;n(p?.iconButton,`icon-btn-`,[[`background`,`bg`],[`border`,`border`],[`color`,`color`],[`padding`,`padding`],[`borderRadius`,`radius`],[`hoverBackground`,`hover-bg`],[`hoverColor`,`hover-color`],[`activeBackground`,`active-bg`],[`activeBorder`,`active-border`]]),n(p?.labelButton,`label-btn-`,[[`background`,`bg`],[`border`,`border`],[`color`,`color`],[`padding`,`padding`],[`borderRadius`,`radius`],[`hoverBackground`,`hover-bg`],[`fontSize`,`font-size`],[`gap`,`gap`]]),n(p?.toggleGroup,`toggle-group-`,[[`gap`,`gap`],[`borderRadius`,`radius`]]);let m=p?.artifact;if(m?.toolbar){let r=m.toolbar;n(r,`artifact-toolbar-icon-`,[[`iconHoverColor`,`hover-color`],[`iconHoverBackground`,`hover-bg`],[`iconPadding`,`padding`],[`iconBorderRadius`,`radius`],[`iconBorder`,`border`]]),r.toggleGroupGap&&(t[`--persona-artifact-toolbar-toggle-group-gap`]=Ua(r.toggleGroupGap)),r.toggleBorderRadius&&(t[`--persona-artifact-toolbar-toggle-radius`]=r.toggleBorderRadius),r.toggleGroupPadding&&(t[`--persona-artifact-toolbar-toggle-group-padding`]=Ua(r.toggleGroupPadding)),n(r,`artifact-toolbar-toggle-group-`,[[`toggleGroupBorder`,`border`],[`toggleGroupBorderRadius`,`radius`]]),r.toggleGroupBackground&&(t[`--persona-artifact-toolbar-toggle-group-bg`]=Ra(e,r.toggleGroupBackground)??r.toggleGroupBackground),n(r,`artifact-toolbar-copy-`,[[`copyBackground`,`bg`],[`copyBorder`,`border`],[`copyColor`,`color`]]),r.copyBorderRadius&&(t[`--persona-artifact-toolbar-copy-radius`]=Ua(r.copyBorderRadius)),r.copyPadding&&(t[`--persona-artifact-toolbar-copy-padding`]=r.copyPadding),r.copyMenuBackground&&(t[`--persona-artifact-toolbar-copy-menu-bg`]=r.copyMenuBackground,t[`--persona-dropdown-bg`]=t[`--persona-dropdown-bg`]??r.copyMenuBackground),r.copyMenuBorder&&(t[`--persona-artifact-toolbar-copy-menu-border`]=r.copyMenuBorder,t[`--persona-dropdown-border`]=t[`--persona-dropdown-border`]??r.copyMenuBorder),r.copyMenuShadow&&(t[`--persona-artifact-toolbar-copy-menu-shadow`]=r.copyMenuShadow,t[`--persona-dropdown-shadow`]=t[`--persona-dropdown-shadow`]??r.copyMenuShadow),r.copyMenuBorderRadius&&(t[`--persona-artifact-toolbar-copy-menu-radius`]=r.copyMenuBorderRadius,t[`--persona-dropdown-radius`]=t[`--persona-dropdown-radius`]??r.copyMenuBorderRadius),r.copyMenuItemHoverBackground&&(t[`--persona-artifact-toolbar-copy-menu-item-hover-bg`]=r.copyMenuItemHoverBackground,t[`--persona-dropdown-item-hover-bg`]=t[`--persona-dropdown-item-hover-bg`]??r.copyMenuItemHoverBackground),n(r,`artifact-toolbar-`,[[`iconBackground`,`icon-bg`],[`toolbarBorder`,`border`]])}if(m?.tab){let e=m.tab;n(e,`artifact-tab-`,[[`background`,`bg`],[`activeBackground`,`active-bg`],[`activeBorder`,`active-border`],[`borderRadius`,`radius`],[`textColor`,`color`],[`hoverBackground`,`hover-bg`],[`listBackground`,`list-bg`],[`listBorderColor`,`list-border-color`],[`listPadding`,`list-padding`]])}if(m?.pane){let n=m.pane;n.toolbarBackground&&(t[`--persona-artifact-toolbar-bg`]=Ra(e,n.toolbarBackground)??n.toolbarBackground)}n(m?.card,`artifact-card-`,[[`background`,`bg`,!0],[`border`,`border`],[`borderRadius`,`radius`,!0],[`hoverBackground`,`hover-bg`,!0],[`hoverBorderColor`,`hover-border`,!0]]),n(m?.inline,`artifact-inline-`,[[`background`,`bg`,!0],[`border`,`border`],[`borderRadius`,`radius`,!0],[`chromeBackground`,`chrome-bg`,!0],[`chromeBorder`,`chrome-border`,!0],[`titleColor`,`title-color`,!0],[`mutedColor`,`muted-color`,!0],[`frameHeight`,`frame-height`]]);let h=p?.code;h&&(n(h,`code-`,[[`keywordColor`,`keyword-color`],[`stringColor`,`string-color`],[`commentColor`,`comment-color`],[`numberColor`,`number-color`],[`tagColor`,`tag-color`],[`attrColor`,`attr-color`],[`propertyColor`,`property-color`],[`lineNumberColor`,`line-number-color`],[`gutterBorderColor`,`gutter-border-color`]]),h.background&&(t[`--persona-code-bg`]=Ra(e,h.background)??h.background));let g=t[`--persona-surface`],_=t[`--persona-container`],v=t[`--persona-palette-colors-gray-100`]??`#f3f4f6`,y=t[`--persona-palette-colors-gray-200`]??`#e5e7eb`,b=t[`--persona-palette-colors-gray-300`]??`#d1d5db`,x=!_||_===g,S=Ga(g??t[`--persona-background`]),C=x&&S!==void 0&&S<.179,ee=C?`rgba(255, 255, 255, 0.08)`:v,w=C?`rgba(255, 255, 255, 0.12)`:y,T=C?`rgba(255, 255, 255, 0.16)`:b,te=x?ee:_,ne=x?w:_;return t[`--persona-icon-btn-hover-bg`]=t[`--persona-icon-btn-hover-bg`]??te,t[`--persona-icon-btn-active-bg`]=t[`--persona-icon-btn-active-bg`]??ne,x&&(t[`--persona-icon-btn-active-border`]=t[`--persona-icon-btn-active-border`]??T),t[`--persona-label-btn-hover-bg`]=t[`--persona-label-btn-hover-bg`]??te,t[`--persona-artifact-tab-hover-bg`]=t[`--persona-artifact-tab-hover-bg`]??te,t[`--persona-artifact-card-hover-bg`]=t[`--persona-artifact-card-hover-bg`]??te,t}const Qa=e=>!!e&&`launcher`in e&&(e.launcher?.sidebarMode===!0||e.launcher?.mountMode===`docked`),$a=(e,t)=>{if(!t||!Qa(t))return e;let n=t.theme?.components?.panel?.width,r=t.darkTheme?.components?.panel?.width;return(lo(t)===`dark`?r??n:n)==null?{...e,components:{...e.components,panel:{...e.components.panel,width:fe(t)===`v5`?`400px`:`420px`}}}:e},eo={colors:{primary:{50:`#ffffff`,100:`#f5f5f5`,200:`#d4d4d4`,300:`#a3a3a3`,400:`#737373`,500:`#171717`,600:`#0f0f0f`,700:`#0a0a0a`,800:`#050505`,900:`#030303`,950:`#000000`},secondary:{50:`#f5f3ff`,100:`#ede9fe`,200:`#ddd6fe`,300:`#c4b5fd`,400:`#a78bfa`,500:`#8b5cf6`,600:`#7c3aed`,700:`#6d28d9`,800:`#5b21b6`,900:`#4c1d95`,950:`#2e1065`},accent:{50:`#ecfeff`,100:`#cffafe`,200:`#a5f3fc`,300:`#67e8f9`,400:`#22d3ee`,500:`#06b6d4`,600:`#0891b2`,700:`#0e7490`,800:`#155e75`,900:`#164e63`,950:`#083344`},gray:{50:`#f9fafb`,100:`#f3f4f6`,200:`#e5e7eb`,300:`#d1d5db`,400:`#9ca3af`,500:`#6b7280`,600:`#4b5563`,700:`#374151`,800:`#1f2937`,900:`#111827`,950:`#030712`},success:{50:`#f0fdf4`,100:`#dcfce7`,200:`#bbf7d0`,300:`#86efac`,400:`#4ade80`,500:`#22c55e`,600:`#16a34a`,700:`#15803d`,800:`#166534`,900:`#14532d`},warning:{50:`#fefce8`,100:`#fef9c3`,200:`#fef08a`,300:`#fde047`,400:`#facc15`,500:`#eab308`,600:`#ca8a04`,700:`#a16207`,800:`#854d0e`,900:`#713f12`},error:{50:`#fef2f2`,100:`#fee2e2`,200:`#fecaca`,300:`#fca5a5`,400:`#f87171`,500:`#ef4444`,600:`#dc2626`,700:`#b91c1c`,800:`#991b1b`,900:`#7f1d1d`}}},to={components:{button:{ghost:{hoverBackground:`rgba(255, 255, 255, 0.08)`}},markdown:{link:{foreground:`palette.colors.primary.300`}},eventStream:{badge:{flow:{background:`palette.colors.success.900`,foreground:`palette.colors.success.300`},step:{background:`palette.colors.primary.800`,foreground:`palette.colors.primary.200`},reasoning:{background:`palette.colors.warning.900`,foreground:`palette.colors.warning.300`},tool:{background:`palette.colors.purple.900`,foreground:`palette.colors.purple.300`},agent:{background:`palette.colors.teal.900`,foreground:`palette.colors.teal.300`},error:{background:`palette.colors.error.900`,foreground:`palette.colors.error.300`},default:{background:`palette.colors.gray.800`,foreground:`palette.colors.gray.300`}}},history:{dangerForeground:`#f87171`,confirm:{dangerBackground:`palette.colors.error.600`,scrim:`rgba(0, 0, 0, 0.6)`}}}},no=eo,ro={...no,colors:{...no.colors,primary:{50:`#0f0f10`,100:`#27272a`,200:`#3f3f46`,300:`#52525b`,400:`#71717a`,500:`#f4f4f5`,600:`#e4e4e7`,700:`#d4d4d8`,800:`#a1a1aa`,900:`#fafafa`,950:`#ffffff`},gray:{50:`#1a1a1b`,100:`#27272a`,200:`#2a2a2d`,300:`#52525b`,400:`#71717a`,500:`#a1a1aa`,600:`#b4b4bd`,700:`#d4d4d8`,800:`#e4e4e7`,900:`#f4f4f5`,950:`#fafafa`}}},io=to,ao={semantic:{colors:{primary:`palette.colors.primary.500`,accent:`palette.colors.primary.600`,background:`#0f0f10`,surface:`palette.colors.gray.50`,container:`#1c1c20`,text:`palette.colors.gray.900`,textMuted:`palette.colors.gray.500`,textInverse:`#0f0f10`,border:`palette.colors.gray.200`,divider:`palette.colors.gray.200`,interactive:{default:`palette.colors.primary.600`,hover:`palette.colors.primary.700`,focus:`palette.colors.primary.600`,active:`palette.colors.primary.600`}}},components:{...to.components,button:{...to.components?.button,primary:{background:`semantic.colors.primary`,foreground:`palette.colors.primary.50`}},markdown:{inlineCode:{background:`palette.colors.gray.100`,foreground:`semantic.colors.text`},link:{foreground:`semantic.colors.accent`},codeBlock:{background:`semantic.colors.container`,borderColor:`semantic.colors.border`,textColor:`semantic.colors.text`},table:{headerBackground:`palette.colors.gray.100`,borderColor:`semantic.colors.border`},blockquote:{background:`semantic.colors.container`,borderColor:`palette.colors.gray.300`,textColor:`semantic.colors.textMuted`}},eventStream:{...to.components?.eventStream,badge:{...to.components?.eventStream?.badge,step:{background:`palette.colors.gray.100`,foreground:`palette.colors.gray.700`},default:{background:`palette.colors.gray.100`,foreground:`palette.colors.gray.700`}}}}},oo=e=>fe({future:e})===`v5`?{palette:ro,components:ao}:{palette:no,components:io},Y=e=>{if(e&&typeof e==`object`&&!Array.isArray(e))return e},so=()=>typeof document<`u`&&document.documentElement.classList.contains(`dark`)||typeof window<`u`&&window.matchMedia?.(`(prefers-color-scheme: dark)`).matches?`dark`:`light`,co=e=>{let t=e?.colorScheme??r(e?.brand)??`light`;return t===`light`?`light`:t===`dark`?`dark`:so()},lo=e=>co(e),uo=(e,t={})=>Ha(e,t),fo=(e,t={})=>{let n=oo(t.future),r=i(n.components,e??{})??{};return Ha({...r,palette:{...r.palette,colors:fe(t)===`v5`?i(n.palette.colors,r.palette?.colors):{...n.palette.colors,...r.palette?.colors}}},{validate:!1,future:t.future})},po=e=>{let n=lo(e),r=i(m(e?.brand,n,La(e?.future).components,e?.future?.v5Defaults),Y(e?.theme)),a=xa(e)===`circle`?Sa:{...Pa.launcher,...e?.future?.v5Defaults?{offset:`1.5rem`}:{}},o=tn(e),s=i({components:{launcher:a,...o?{panel:{background:`transparent`,modes:{inline:{border:`none`,shadow:`none`,borderRadius:`0`}}},header:{background:`transparent`},message:{background:`transparent`},composer:{footerBackground:`transparent`,footerBorder:`none`,overlayBand:`transparent`}}:{}}},r),c=Y(e?.darkTheme),u=$a(n===`dark`?fo(i(s??{},c??{}),{future:e?.future}):uo(s,{future:e?.future}),e);return Object.defineProperty(u,mo,{value:[...l,`suggestion.chip.padding`,`suggestion.chip.fontWeight`].filter(r=>t(e,r,n))}),u},mo=Symbol(`persona.themeConsumerPaths`),ho=e=>{let t=Za(e);t[`--persona-suggestion-compat-padding`]=`6px 12px`,t[`--persona-suggestion-compat-weight`]=`500`;for(let n of e[mo]??[]){let e=n.split(`.`).join(`-`),r=t[`--persona-components-${e}`];r!==void 0&&(t[n===`suggestion.chip.padding`?`--persona-suggestion-compat-padding`:n===`suggestion.chip.fontWeight`?`--persona-suggestion-compat-weight`:`--persona-consumer-${e}`]=r)}return t},go=/* @__PURE__ */ new WeakMap,_o=(e,t)=>{vo(e,ho(po(t)),t)},vo=(e,t,n)=>{for(let n of go.get(e)??[])n in t||e.style.removeProperty(n);go.set(e,Object.keys(t));for(let[n,r]of Object.entries(t))e.style.setProperty(n,r);e.setAttribute(`data-persona-color-scheme`,lo(n)),e.setAttribute(`data-persona-defaults`,fe(n))},yo=e=>{let t=[];if(typeof document<`u`&&typeof MutationObserver<`u`){let n=new MutationObserver(()=>{e(so())});n.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),t.push(()=>n.disconnect())}if(typeof window<`u`&&window.matchMedia){let n=window.matchMedia(`(prefers-color-scheme: dark)`),r=()=>e(so());n.addEventListener?(n.addEventListener(`change`,r),t.push(()=>n.removeEventListener(`change`,r))):n.addListener&&(n.addListener(r),t.push(()=>n.removeListener(r)))}return()=>{t.forEach(e=>e())}},bo=(e,t)=>e?.layout?.contentMaxWidth??(t?e?.launcher?.composerBar?.contentMaxWidth??`720px`:`768px`),xo=(e,t)=>t||e?.composer?.placement!==`overlay`?`block`:`overlay`,So=e=>{if(typeof e!=`string`)return null;let t=/^\s*(\d+(?:\.\d+)?)\s*%\s*$/.exec(e);if(!t)return null;let n=Number(t[1])/100;return n>0&&n<1?n:null},Co=e=>Math.max(0,Math.round(e.columnHeight*(1-e.fraction))-e.footerHeight),wo=()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgentData?.platform??navigator.platform??``;return/mac|iphone|ipad|ipod/i.test(e)},To=(e,t)=>{console.warn(`[persona] ${e} shortcut: ${t}`)},Eo=e=>{let t=e.toLowerCase().split(`+`).map(e=>e.trim()),n=t.pop(),r={key:n,mod:!1,shift:!1,alt:!1};for(let n of t)if(n===`mod`||n===`cmd`||n===`ctrl`)r.mod=!0;else if(n===`shift`)r.shift=!0;else if(n===`alt`||n===`option`)r.alt=!0;else return To(`unknown modifier in`,e),null;return!r.mod||r.shift&&r.alt||/^(enter|esc(ape)?)$/.test(n)||!/^([^+\s]|[a-z]{2,12})$/.test(n)?(To(`unsupported`,e),null):(n===`space`&&(r.key=` `),r)},Do=e=>`ArrowUp ArrowDown ArrowLeft ArrowRight PageUp PageDown Space`.split(` `).find(t=>t.toLowerCase()===e)??(e===` `?`Space`:e.length===1?e.toUpperCase():e[0].toUpperCase()+e.slice(1)),Oo=(e,t)=>{let n=Eo(e);if(!n)return``;let r=wo(),i=Do(n.key);if(!t&&r)return`${n.alt?`⌥`:``}${n.shift?`⇧`:``}⌘${i}`;let a=[t?r?`Meta`:`Control`:`Ctrl`];return n.alt&&a.push(`Alt`),n.shift&&a.push(`Shift`),a.push(i),a.join(`+`)},ko=e=>Oo(e,!1),Ao=e=>Oo(e,!0),jo=(e,t)=>t.key?.toLowerCase()===e.key&&(wo()?t.metaKey:t.ctrlKey)===e.mod&&!(wo()?t.ctrlKey:t.metaKey)&&t.shiftKey===e.shift&&t.altKey===e.alt,Mo=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable},No=e=>{let t=/* @__PURE__ */ new Map,n=e?.ownerDocument??(typeof document<`u`?document:null),r=(t,n)=>{if((t.scope??`widget`)===`page`)return!0;if(!e)return!1;let r=n.composedPath?.();return r?.length?r.includes(e):e.contains(n.target)},i=e=>{if(e.isComposing||!t.size)return;let n=e.composedPath?.()[0]??e.target;for(let i of t.values())if(jo(i.parsed,e)&&i.when?.()!==!1&&r(i,e)&&(i.allowInInput||!Mo(n))){e.preventDefault();try{i.run(e)}catch(e){To(`${i.id} threw on`,i.combo),console.warn(e)}return}};return n?.addEventListener(`keydown`,i),{register(e){let n=Eo(e.combo);if(!n)return()=>{};let r=`${n.mod?`m`:``}${n.shift?`s`:``}${n.alt?`a`:``}${n.key}`,i=t.get(r);return i?(To(`${i.id} already owns`,e.combo),()=>{}):(t.set(r,{...e,parsed:n}),e.element?.setAttribute(`aria-keyshortcuts`,Ao(e.combo)),()=>{t.get(r)?.id===e.id&&t.delete(r),e.element?.removeAttribute(`aria-keyshortcuts`)})},destroy(){t.clear(),n?.removeEventListener(`keydown`,i)}}},Po=(e,t,n={})=>{let{preserveTypingAnimation:r=!0}=n;On.morph(e,t.innerHTML,{morphStyle:`innerHTML`,callbacks:{beforeNodeMorphed(e,t){if(e instanceof HTMLElement){if(t instanceof HTMLElement&&t.hasAttribute(`data-persona-reuse`)&&e.id===t.id)return!1;if(r){if(e.classList.contains(`persona-animate-typing`)||e.hasAttribute(`data-preserve-runtime`))return!1;if(e.hasAttribute(`data-tool-elapsed`))return t instanceof HTMLElement&&t.getAttribute(`data-tool-elapsed`)===e.getAttribute(`data-tool-elapsed`)?!1:void 0;if(e.hasAttribute(`data-preserve-animation`))return t instanceof HTMLElement&&(!t.hasAttribute(`data-preserve-animation`)||(e.dataset.personaLoadingLabel?e.dataset.personaLoadingAnimation!==t.dataset.personaLoadingAnimation:e.textContent!==t.textContent))&&void 0}}}}})},Fo=e=>e.replace(/^\n+/,``).replace(/\s+$/,``),Io={index:-1,draft:``};function Lo(e){let{direction:t,history:n,currentValue:r,atStart:i,state:a}=e,o=a.index!==-1;if(n.length===0)return{handled:!1,state:a};if(t===`up`){if(!o&&!i)return{handled:!1,state:a};if(!o){let e=n.length-1;return{handled:!0,value:n[e],state:{index:e,draft:r}}}if(a.index>0){let e=a.index-1;return{handled:!0,value:n[e],state:{index:e,draft:a.draft}}}return{handled:!0,state:a}}if(!o)return{handled:!1,state:a};if(a.index<n.length-1){let e=a.index+1;return{handled:!0,value:n[e],state:{index:e,draft:a.draft}}}return{handled:!0,value:a.draft,state:{index:-1,draft:a.draft}}}const Ro=/* @__PURE__ */ new WeakMap;function zo(e){if(typeof e==`string`)return e.length;if(!e)return 0;if(typeof e!=`object`)return JSON.stringify(e)?.length??0;let t=Ro.get(e);return t===void 0&&(t=JSON.stringify(e)?.length??0,Ro.set(e,t)),t}function Bo(e,t){return[e.id,e.role,e.content?.length??0,e.content?.slice(-32)??``,e.streaming?`1`:`0`,e.voiceProcessing?`1`:`0`,e.variant??``,e.dispatchError?`1`:`0`,e.rawContent?.length??0,e.llmContent?.length??0,e.approval?.status??``,e.toolCall?.status??``,e.toolCall?.name??``,e.toolCall?.chunks?.length??0,e.toolCall?.chunks?.[e.toolCall.chunks.length-1]?.slice(-32)??``,zo(e.toolCall?.args),e.reasoning?.chunks?.length??0,e.reasoning?.chunks?.[e.reasoning.chunks.length-1]?.length??0,e.reasoning?.chunks?.[e.reasoning.chunks.length-1]?.slice(-32)??``,e.contentParts?.length??0,e.stopReason??``,e.toolCall?.actionTitle??``,t].join(`\0`)}function Vo(){return/* @__PURE__ */ new Map}function Ho(e,t,n){let r=e.get(t);return r&&r.fingerprint===n?r.wrapper:null}function Uo(e,t,n,r){e.set(t,{fingerprint:n,wrapper:r})}function Wo(e,t){for(let n of e.keys())t.has(n)||e.delete(n)}const{setLoader:Go,load:Ko}=v({fallbackImport:()=>import(`./chunk-Dg7uqL8l.js`)}),qo=Ko;function Jo(e,t=Ke){let n=e.style.position,r=e.style.zIndex,i=e.style.isolation,a=getComputedStyle(e),o=a.position===`static`||a.position===``;return o&&(e.style.position=`relative`),e.style.zIndex=String(t),e.style.isolation=`isolate`,()=>{o&&(e.style.position=n),e.style.zIndex=r,e.style.isolation=i}}let Yo=0,Xo=null;function Zo(e=document){if(Yo++,Yo===1){let t=e.body,n=(e.defaultView??window).scrollY||e.documentElement.scrollTop;Xo={originalOverflow:t.style.overflow,originalPosition:t.style.position,originalTop:t.style.top,originalWidth:t.style.width,scrollY:n},t.style.overflow=`hidden`,t.style.position=`fixed`,t.style.top=`-${n}px`,t.style.width=`100%`}let t=!1;return()=>{if(!t&&(t=!0,Yo=Math.max(0,Yo-1),Yo===0&&Xo)){let t=e.body,n=e.defaultView??window;t.style.overflow=Xo.originalOverflow,t.style.position=Xo.originalPosition,t.style.top=Xo.originalTop,t.style.width=Xo.originalWidth,n.scrollTo(0,Xo.scrollY),Xo=null}}}const Qo={side:`right`,width:`420px`,animate:!0,reveal:`resize`,maxHeight:`100dvh`},$o=e=>(e?.launcher?.mountMode??`floating`)===`docked`,es=e=>(e?.launcher?.mountMode??`floating`)===`composer-bar`,ts=e=>{let t=e?.launcher?.dock,n=nn(e).dockWidth?t?.width:Ra(po(e),`components.panel.width`);return{side:t?.side??Qo.side,width:n??Qo.width,animate:t?.animate??Qo.animate,reveal:t?.reveal??Qo.reveal,maxHeight:t?.maxHeight??Qo.maxHeight}},ns=e=>e.closest(`[data-persona-instance]`)?.dataset.personaInstance,rs=e=>e===`followUp`?`follow-up`:e,is=(e,t=0)=>{if(typeof e==`string`){let t=e.trim();return t?{id:t,label:t,prompt:t,emphasis:`default`}:null}let n=e.label.trim();if(!n)return null;let r=e.prompt?.trim()||n;return{id:e.id?.trim()||r||`suggestion-${t}`,label:n,prompt:r,description:e.description?.trim()||void 0,icon:e.icon,iconColor:e.iconColor?.trim()||void 0,behavior:e.behavior,emphasis:e.emphasis??`default`}},as=/* @__PURE__ */ new WeakSet,os=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,ss=e=>{os()||e.forEach((e,t)=>{typeof e.animate==`function`&&e.animate([{opacity:`0`,transform:`translateY(4px)`},{opacity:`1`,transform:`none`}],{duration:250,delay:t*60,easing:`ease-out`,fill:`backwards`})})},cs=e=>{let{item:n,index:r,surface:i,source:a,variant:o,streaming:c,config:l,plugins:u,chipsConfig:d,session:f,getTextarea:p,eventTarget:m,submitPrompt:h}=e,g=i===`followUp`,_=n.behavior,v=()=>{if(f.isStreaming()||m.closest(`[inert]`))return;let e={instanceId:ns(m),suggestion:{...n},surface:i,source:a,behavior:_},t=m.dispatchEvent(new CustomEvent(`persona:suggestion:selected`,{detail:e,bubbles:!0,composed:!0,cancelable:!0}));if(g&&m.dispatchEvent(new CustomEvent(`persona:suggestReplies:selected`,{detail:{instanceId:ns(m),suggestion:n.prompt},bubbles:!0,composed:!0})),!t)return;for(let e of u)if(e.onSuggestionSelect?.({suggestion:{...n},surface:i,source:a,variant:o,config:l})===!1)return;let r=p();_===`fill`?(r.value=n.prompt,r.dispatchEvent(new Event(`input`,{bubbles:!0,composed:!0})),r.focus()):h?h(n.prompt):(r.value=``,f.sendMessage(n.prompt))},y=()=>{let e=k(`button`,`persona-suggestion persona-suggestion--${o}`);if(e.type=`button`,e.disabled=c,e.dataset.suggestionId=n.id,e.dataset.emphasis=n.emphasis,e.dataset.behavior=_,o===`chip`){let n=l.suggestionChipsConfig===d?l:{suggestionChipsConfig:d},r=e=>s(n,`suggestionChipsConfig.${e}`),i=e=>t(l,`suggestion.chip.${e}`,`light`)||t(l,`suggestion.chip.${e}`,`dark`);d?.fontWeight&&(e.style.fontWeight=!r(`fontWeight`)&&i(`fontWeight`)?`var(--persona-suggestion-compat-weight, 500)`:d.fontWeight);let a=i(`padding`);a&&(e.classList.add(`persona-theme-padding`),e.style.setProperty(`--persona-theme-padding`,`var(--persona-suggestion-compat-padding, 6px 12px)`)),d?.paddingX&&(r(`paddingX`)||!a)&&(e.style.paddingLeft=d.paddingX,e.style.paddingRight=d.paddingX),d?.paddingY&&(r(`paddingY`)||!a)&&(e.style.paddingTop=d.paddingY,e.style.paddingBottom=d.paddingY)}if(n.icon){let t=T(n.icon,`var(--persona-suggestion-icon-size)`,`currentColor`,1.8);t&&(t.classList.add(`persona-suggestion__icon`),n.iconColor&&(t.style.color=n.iconColor),e.appendChild(t))}let r=k(`span`,`persona-suggestion__copy`);if(r.appendChild(O(`span`,{className:`persona-suggestion__label`,text:n.label})),n.description&&o!==`chip`&&r.appendChild(O(`span`,{className:`persona-suggestion__description`,text:n.description})),e.appendChild(r),o!==`chip`){let t=b(vn,16,`currentColor`,1.8);t&&(t.classList.add(`persona-suggestion__arrow`),e.appendChild(t))}return e.addEventListener(`click`,v),e},x=null;for(let e of u)if(e.renderSuggestion&&(x=e.renderSuggestion({suggestion:{...n},index:r,surface:i,source:a,variant:o,streaming:c,config:l,defaultRenderer:y,select:v}),x))break;return x??=y(),x.dataset.suggestionId||=n.id,x.dataset.behavior||=_,x.dataset.emphasis||=n.emphasis,x instanceof HTMLButtonElement||x.setAttribute(`aria-disabled`,c?`true`:`false`),x},ls=e=>{let t=[],n=[],r=null,i=null,a=()=>{e.removeAttribute(`data-scroll-left`),e.removeAttribute(`data-scroll-right`)},o=()=>{if(i=null,e.toggleAttribute(`data-edge-to-edge`,e.hasAttribute(`data-hide-scrollbar`)&&(e.hasAttribute(`data-persona-composer-suggestions`)||e.dataset.personaSuggestions===`follow-up`)&&e.dataset.variant===`chip`&&e.dataset.overflow===`scroll`),e.hasAttribute(`data-edge-to-edge`)&&e.parentElement){let t=e.parentElement,n=getComputedStyle(t),r=parseFloat(n.paddingLeft)||0,i=parseFloat(n.paddingRight)||0;e.style.setProperty(`--persona-suggestion-bleed-left`,`${r}px`),e.style.setProperty(`--persona-suggestion-bleed-right`,`${i}px`);let a=t.closest(`.persona-widget-container`)?.querySelector(`form`),o=t.getBoundingClientRect(),s=a?.getBoundingClientRect();e.style.setProperty(`--persona-suggestion-inset-left`,`${s?.width?s.left-o.left:r}px`),e.style.setProperty(`--persona-suggestion-inset-right`,`${s?.width?o.right-s.right:i}px`)}if(e.hidden||e.dataset.variant!==`chip`||e.dataset.overflow!==`scroll`){a();return}let t=Math.max(0,e.scrollWidth-e.clientWidth);if(t<=1){a();return}let n=getComputedStyle(e).direction===`rtl`,r=Math.min(t,Math.max(0,Math.abs(e.scrollLeft))),o=r<=4,s=r>=t-4,c=n?!s:!o,l=n?!o:!s;e.toggleAttribute(`data-scroll-left`,c),e.toggleAttribute(`data-scroll-right`,l)},s=()=>{i!==null||typeof requestAnimationFrame!=`function`?typeof requestAnimationFrame!=`function`&&o():i=requestAnimationFrame(o)};e.addEventListener(`scroll`,s,{passive:!0});let c=typeof ResizeObserver==`function`?new ResizeObserver(s):null;return c?.observe(e),{buttons:t,elements:n,destroy:()=>{e.removeEventListener(`scroll`,s),c?.disconnect(),i!==null&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(i),i=null},render:(i,c,l,u,d,f)=>{e.replaceChildren(),t.length=0,n.length=0;let p=f?.source??`config`,m=f?.surface??(p===`config`?`starter`:`followUp`),h=m===`followUp`,g=f?.variant??`chip`,_=f?.behavior??`send`,v=f?.overflow??`wrap`,y=f?.config??{},b=f?.plugins??[];e.toggleAttribute(`data-hide-scrollbar`,y.future?.v5Defaults===!0),e.dataset.edgeStyle=y.suggestions?.[h?`followUps`:`starters`]?.edgeStyle??`fade`;let x=typeof f?.maxItems==`number`?Math.max(0,Math.floor(f.maxItems)):void 0,S=h?`followUps`:`starters`;!as.has(y)&&y.debug===!0&&g!==`chip`&&y.suggestions?.[S]?.overflow!==void 0&&(as.add(y),console.info(`[persona] suggestions.${S}.overflow applies to the "chip" variant only; the "${g}" variant manages its own stacking.`));let C=e=>e.map(is).filter(e=>e!==null).map(e=>({...e,behavior:e.behavior??_})),ee=C(i??[]);b.forEach(e=>{e.transformSuggestions&&(ee=C(e.transformSuggestions({suggestions:ee.map(e=>({...e})),surface:m,source:p,config:y})))});let w=x===void 0?ee:ee.slice(0,x);if(!w.length){e.hidden=!0,r=null,a();return}if(!h&&(u??c.getMessages()).some(e=>e.role===`user`)){e.hidden=!0,r=null;return}e.hidden=!1,e.classList.add(`persona-suggestions`),e.dataset.personaSuggestionSurface=rs(m),e.dataset.variant=g,e.dataset.overflow=v;let T=document.createDocumentFragment(),te=c.isStreaming();w.forEach((r,i)=>{let a=cs({item:r,index:i,surface:m,source:p,variant:g,streaming:te,config:y,plugins:b,chipsConfig:d,session:c,getTextarea:()=>l,eventTarget:e,submitPrompt:f?.submitPrompt});T.appendChild(a),n.push(a),[...a instanceof HTMLButtonElement?[a]:[],...Array.from(a.querySelectorAll(`button`))].forEach(e=>{t.includes(e)||(e.disabled=te,t.push(e))})}),e.appendChild(T),o(),s();let ne=JSON.stringify({normalized:w,surface:m,variant:g,source:p});ne!==r&&(r=ne,ss(n),e.dispatchEvent(new CustomEvent(`persona:suggestion:shown`,{detail:{instanceId:ns(e),suggestions:w.map(e=>({...e})),surface:m,source:p,variant:g},bubbles:!0,composed:!0})),h&&e.dispatchEvent(new CustomEvent(`persona:suggestReplies:shown`,{detail:{instanceId:ns(e),suggestions:w.map(e=>e.prompt)},bubbles:!0,composed:!0})))}}},us={"bottom-right":`persona-bottom-6 persona-right-6`,"bottom-left":`persona-bottom-6 persona-left-6`,"top-right":`persona-top-6 persona-right-6`,"top-left":`persona-top-6 persona-left-6`},ds={x:[1.4,1.05]},fs=`persona-relative persona-ml-auto persona-inline-flex persona-items-center persona-justify-center`,ps=(e,t,n={})=>{let{iconSize:r,iconText:i}=n,[a,o]=ds[t]??[1,1.5],s=!r;e.classList.toggle(`persona-header-control--glyph`,s),e.classList.toggle(`persona-header-control--sparse`,s&&a!==1);let c=T(t,`${Math.round((parseFloat(r??``)||16)*a)}px`,`currentColor`,o);c?(c.style.display=`block`,s||(c.style.strokeWidth=`calc(var(--persona-components-header-controlStrokeWidth, 1.5) * ${Number((o/1.5).toFixed(4))})`),e.replaceChildren(c)):i&&(e.textContent=i)},ms=e=>{let{ariaLabel:t,tooltip:n=!0,tooltipHint:r,iconName:i,iconText:a,wrapperClassName:o=fs,size:s,iconSize:c,color:l,backgroundColor:u,borderWidth:d,borderColor:f,borderRadius:p,paddingX:m,paddingY:h,hidden:g,extraClassName:_,attrs:v}=e,y=k(`div`,o),b=!!(d||f),x=O(`button`,{className:We(`persona-header-control`,`persona-inline-flex persona-items-center persona-justify-center persona-cursor-pointer`,!u&&`persona-bg-transparent hover:persona-bg-gray-100`,!b&&`persona-border-none`,!p&&`persona-rounded-full`,_),attrs:{type:`button`,"aria-label":t,...v},style:{width:s,height:s,minWidth:s,minHeight:s,display:g?`none`:void 0,color:l||vs.actionIconColor,backgroundColor:u,border:b?`${d||`0px`} solid ${f||`transparent`}`:void 0,borderRadius:p,paddingLeft:m,paddingRight:m,paddingTop:h,paddingBottom:h}});return i?ps(x,i,{iconSize:c,iconText:a}):a&&(x.textContent=a),y.appendChild(x),Ee({anchor:x,trigger:y,text:()=>x.getAttribute(`aria-label`)??t,hint:r,enabled:n}),{button:x,wrapper:y}},hs=(e,t,n,r={})=>{let i=t?.launcher,a=i?.clearChat,o=e=>n===`close`?`launcher.closeButton${e[0].toUpperCase()}${e.slice(1)}`:`launcher.clearChat.${e===`color`?`iconColor`:e}`,s=e=>le(t,o(e)),c=(e,r)=>De(t,`header.${n}`,e,r),l=(e,t,n)=>s(e)||c(t,n),u=r.buttonSize||s(`size`);D(e,u||c(`size`,`var(--persona-header-control-size, 32px)`),u),!u&&c(`size`,``)===``&&(e.style.width=e.style.height=``);let d=n===`close`?i?.closeButtonBackgroundColor:a?.backgroundColor;e.style.color=l(`color`,`foreground`,vs.actionIconColor),e.style.backgroundColor=s(`backgroundColor`)||(c(`background`,``)?c(`background`,d||`transparent`):d||``),e.classList.toggle(`hover:persona-bg-gray-100`,!d&&!s(`backgroundColor`)&&c(`background`,``)===``);let f=n===`close`?i?.closeButtonBorderWidth:a?.borderWidth,p=n===`close`?i?.closeButtonBorderColor:a?.borderColor,m=!!(f||p||c(`borderWidth`,``)||c(`borderColor`,``));e.style.border=m?`${l(`borderWidth`,`borderWidth`,f||`0px`)} solid ${l(`borderColor`,`borderColor`,p||`transparent`)}`:``,e.classList.toggle(`persona-border-none`,!m);let h=n===`close`?i?.closeButtonBorderRadius:a?.borderRadius;e.style.borderRadius=s(`borderRadius`)||(c(`borderRadius`,``)?c(`borderRadius`,`var(--persona-components-header-controlBorderRadius, 9999px)`):h||``),e.classList.toggle(`persona-rounded-full`,!e.style.borderRadius);let g=n===`close`?i?.closeButtonPaddingX:a?.paddingX,_=n===`close`?i?.closeButtonPaddingY:a?.paddingY,v=c(`padding`,`0px`);se(e,v,s(`paddingX`)||(v===`0px`?g:void 0),s(`paddingY`)||(v===`0px`?_:void 0));let y=n===`close`?i?.closeButtonIconName??`x`:a?.iconName??`refresh-cw`;ps(e,y,{iconSize:r.iconSize,iconText:n===`close`?i?.closeButtonIconText??`×`:void 0});let b=e.querySelector(`svg`);if(b){let e=ds[y]?.[0]??1,t=c(`iconSize`,``);!r.iconSize&&t&&(b.style.width=b.style.height=`calc(${c(`iconSize`,`var(--persona-header-control-icon-size, 16px)`)} * ${e})`),c(`iconStrokeWidth`,``)&&(b.style.strokeWidth=`calc(${c(`iconStrokeWidth`,`var(--persona-components-header-controlStrokeWidth, 1.5)`)} * ${e===1?1:.7})`)}},gs=(e,t={})=>{let{showClose:n=!0,wrapperClassName:r=fs,buttonSize:i,iconSize:a}=t,o=e?.launcher??{},s=o.closeButtonTooltipText??`Close chat`,c=o.closeButtonShowTooltip??!0,{button:l,wrapper:u}=ms({ariaLabel:s,tooltip:c,iconName:o.closeButtonIconName??`x`,iconText:o.closeButtonIconText??`×`,wrapperClassName:r,size:i??o.closeButtonSize,iconSize:a,color:o.closeButtonColor,backgroundColor:o.closeButtonBackgroundColor,borderWidth:o.closeButtonBorderWidth,borderColor:o.closeButtonBorderColor,borderRadius:o.closeButtonBorderRadius,paddingX:o.closeButtonPaddingX,paddingY:o.closeButtonPaddingY,hidden:!n});return hs(l,e,`close`,{buttonSize:i,iconSize:a}),{button:l,wrapper:u}},_s=(e,t={})=>{let{wrapperClassName:n=`persona-relative persona-ml-auto persona-clear-chat-button-wrapper`,buttonSize:r,iconSize:i}=t,a=(e?.launcher??{}).clearChat??{},o=a.tooltipText??`Clear chat`,s=a.showTooltip??!0,{button:c,wrapper:l}=ms({ariaLabel:o,tooltip:s,iconName:a.iconName??`refresh-cw`,wrapperClassName:n,size:r??a.size,iconSize:i,color:a.iconColor,backgroundColor:a.backgroundColor,borderWidth:a.borderWidth,borderColor:a.borderColor,borderRadius:a.borderRadius,paddingX:a.paddingX,paddingY:a.paddingY});return hs(c,e,`clear`,{buttonSize:r,iconSize:i}),{button:c,wrapper:l}},vs={titleColor:`var(--persona-header-title-fg, var(--persona-primary, #0f0f0f))`,subtitleColor:`var(--persona-header-subtitle-fg, var(--persona-text-muted, var(--persona-muted, #9ca3af)))`,actionIconColor:`var(--persona-header-control-state-fg, var(--persona-header-action-icon-fg, var(--persona-muted, #9ca3af)))`,minHeight:`var(--persona-header-min-height, auto)`},ys={fontFamily:`var(--persona-components-header-title-fontFamily, inherit)`,fontSize:`var(--persona-components-header-title-fontSize, 1rem)`,fontWeight:`var(--persona-components-header-title-fontWeight, 600)`,lineHeight:`var(--persona-components-header-title-lineHeight, 1.5rem)`,letterSpacing:`var(--persona-components-header-title-letterSpacing, normal)`},bs={fontFamily:`var(--persona-components-header-subtitle-fontFamily, inherit)`,fontSize:`var(--persona-components-header-subtitle-fontSize, 0.75rem)`,fontWeight:`var(--persona-components-header-subtitle-fontWeight, inherit)`,lineHeight:`var(--persona-components-header-subtitle-lineHeight, 1rem)`,letterSpacing:`var(--persona-components-header-subtitle-letterSpacing, normal)`},xs=e=>{let{config:t,showClose:n=!0}=e,r=O(`div`,{className:`persona-widget-header persona-flex persona-items-center persona-gap-3`,attrs:{"data-persona-theme-zone":`header`},style:{padding:`var(--persona-components-header-padding, 20px 24px)`,minHeight:vs.minHeight,backgroundColor:`var(--persona-header-bg, var(--persona-surface, #ffffff))`,borderBottomColor:`var(--persona-header-border, var(--persona-divider, #f1f5f9))`,boxShadow:`var(--persona-header-shadow, none)`,borderBottom:`var(--persona-header-border-bottom, 1px solid var(--persona-header-border, var(--persona-divider, #f1f5f9)))`}}),i=t?.launcher??{},a=i.headerIconSize??`40px`,o=i.closeButtonPlacement??`inline`,s=i.headerIconHidden??!1,c=i.headerIconName,l=O(`div`,{className:`persona-flex persona-items-center persona-justify-center persona-rounded-xl persona-text-xl`,style:{height:a,width:a,boxSizing:`content-box`,padding:`var(--persona-components-header-iconPadding, 0px)`,flexShrink:`0`,backgroundColor:`var(--persona-header-icon-bg, var(--persona-primary, #0f0f0f))`,color:`var(--persona-header-icon-fg, var(--persona-text-inverse, #ffffff))`}});if(!s){if(c){let e=parseFloat(a)||24,n=T(c,e*.6,`currentColor`,1);n?(n.style.width=`calc(${e}px * var(--persona-components-header-iconScale, 0.6))`,n.style.height=`calc(${e}px * var(--persona-components-header-iconScale, 0.6))`,l.replaceChildren(n)):l.textContent=t?.launcher?.agentIconText??`💬`}else if(t?.launcher?.iconUrl){let e=k(`img`);e.src=t.launcher.iconUrl,e.alt=``,e.className=`persona-rounded-xl persona-object-cover`,e.style.height=a,e.style.width=a,l.replaceChildren(e)}else l.textContent=t?.launcher?.agentIconText??`💬`}let u=k(`div`,`persona-flex persona-flex-col persona-flex-1 persona-min-w-0`),d=O(`span`,{className:`persona-text-base persona-font-semibold`,text:t?.launcher?.title??`Chat Assistant`,style:{color:vs.titleColor,...ys}}),f=O(`span`,{className:`persona-text-xs`,text:t?.launcher?.subtitle??`Here to help you get answers fast`,style:{color:vs.subtitleColor,...bs}});u.append(d,f),s?r.append(u):r.append(l,u);let p=i.clearChat??{},m=p.enabled??!0,h=p.placement??`inline`,g=null,_=null;if(m){let e=_s(t,{wrapperClassName:h===`top-right`?`persona-absolute persona-top-4 persona-z-50`:`persona-relative persona-ml-auto persona-clear-chat-button-wrapper`});g=e.button,_=e.wrapper,h===`top-right`&&(_.style.right=`48px`),h===`inline`&&r.appendChild(_)}let{button:v,wrapper:y}=gs(t,{showClose:n,wrapperClassName:o===`top-right`?`persona-absolute persona-top-4 persona-right-4 persona-z-50`:m&&h===`inline`?`persona-relative persona-inline-flex persona-items-center persona-justify-center`:`persona-relative persona-ml-auto persona-inline-flex persona-items-center persona-justify-center`});return o!==`top-right`&&r.appendChild(y),{header:r,iconHolder:l,headerTitle:d,headerSubtitle:f,closeButton:v,closeButtonWrapper:y,clearChatButton:g,clearChatButtonWrapper:_}},Ss=(e,t,n)=>{let r=n?.launcher??{},i=r.closeButtonPlacement??`inline`,a=r.clearChat?.placement??`inline`;e.appendChild(t.header),i===`top-right`&&(e.style.position=`relative`,e.appendChild(t.closeButtonWrapper)),t.clearChatButtonWrapper&&a===`top-right`&&(e.style.position=`relative`,e.appendChild(t.clearChatButtonWrapper))},Cs=e=>{let t=xs({config:e.config,showClose:e.showClose,onClose:e.onClose,onClearChat:e.onClearChat}),n=e.layoutHeaderConfig?.onTitleClick;if(n){let e=t.headerTitle.parentElement;e&&(e.style.cursor=`pointer`,e.setAttribute(`role`,`button`),e.setAttribute(`tabindex`,`0`),e.addEventListener(`click`,()=>n()),e.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())}))}return t};function ws(e,t,n){if(t?.length)for(let r of t){let{button:t,wrapper:i}=ms({ariaLabel:r.ariaLabel??r.label??r.id,iconName:r.icon,iconText:r.icon?void 0:r.label,tooltipHint:r.shortcut?ko(r.shortcut):void 0,wrapperClassName:`persona-relative persona-inline-flex persona-items-center persona-justify-center`});if(t.setAttribute(`data-persona-header-action`,r.id),r.shortcut){let e=Ao(r.shortcut);e&&t.setAttribute(`aria-keyshortcuts`,e)}if(r.menuItems?.length){let e=tr({items:r.menuItems,onSelect:e=>n?.(e),anchor:i,position:`bottom-right`});i.appendChild(e.element),t.addEventListener(`click`,t=>{t.stopPropagation(),e.toggle()})}else t.addEventListener(`click`,()=>n?.(r.id));e.appendChild(i)}}const Ts={default:Cs,minimal:e=>{let{config:t,showClose:n=!0,onClose:r,layoutHeaderConfig:i,onHeaderAction:a}=e,o=t?.launcher??{},s=k(`div`,`persona-flex persona-items-center persona-justify-between`);s.setAttribute(`data-persona-theme-zone`,`header`),s.style.minHeight=vs.minHeight,s.style.padding=`var(--persona-components-header-minimalPadding, var(--persona-components-header-padding, 16px 24px))`,s.style.backgroundColor=`var(--persona-header-bg, var(--persona-surface, #ffffff))`,s.style.borderBottomColor=`var(--persona-header-border, var(--persona-divider, #f1f5f9))`,s.style.boxShadow=`var(--persona-header-shadow, none)`,s.style.borderBottom=`var(--persona-header-border-bottom, 1px solid var(--persona-header-border, var(--persona-divider, #f1f5f9)))`;let c=i?.titleMenu,l,u;if(c){let e=V({label:o.title??`Chat Assistant`,menuItems:c.menuItems,onSelect:t=>{let n=n=>{n===!1&&e.element.dispatchEvent(new CustomEvent(`persona:title-menu-builtin`,{bubbles:!0,composed:!0,detail:{actionId:t,instanceId:e.element.closest(`[data-persona-instance]`)?.dataset.personaInstance}}))},r=c.onSelect(t);r instanceof Promise?r.then(n,()=>{}):n(r)},hover:c.hover,className:``});l=e.element,l.style.color=vs.titleColor,u=l.querySelector(`.persona-combo-btn-label`)??l}else{if(l=k(`div`,`persona-flex persona-min-w-0 persona-flex-1 persona-items-center persona-gap-1`),u=k(`span`,`persona-text-base persona-font-semibold persona-truncate`),u.style.color=vs.titleColor,Object.assign(u.style,ys),u.textContent=o.title??`Chat Assistant`,l.appendChild(u),i?.onTitleClick){l.style.cursor=`pointer`,l.setAttribute(`role`,`button`),l.setAttribute(`tabindex`,`0`);let e=i.onTitleClick;l.addEventListener(`click`,t=>{t.target.closest(`button`)||e()}),l.addEventListener(`keydown`,t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())})}let e=i?.titleRowHover;e&&(l.style.borderRadius=e.borderRadius??`10px`,l.style.padding=e.padding??`6px 4px 6px 12px`,l.style.margin=`-6px 0 -6px -12px`,l.style.border=`1px solid transparent`,l.style.transition=`background-color 0.15s ease, border-color 0.15s ease`,l.style.width=`fit-content`,l.style.flex=`none`,l.addEventListener(`mouseenter`,()=>{l.style.backgroundColor=e.background??``,l.style.borderColor=e.border??``}),l.addEventListener(`mouseleave`,()=>{l.style.backgroundColor=``,l.style.borderColor=`transparent`}))}s.appendChild(l);let d=`persona-relative persona-inline-flex persona-items-center persona-justify-center`,{button:f,wrapper:p}=gs(t,{showClose:n,wrapperClassName:d});r&&f.addEventListener(`click`,r);let m=k(`div`,`persona-flex persona-items-center persona-gap-1`);c||ws(m,i?.trailingActions,i?.onAction??a);let h=o.clearChat??{},g=null,_=null;if(h.enabled??!0){let e=h.placement??`inline`,n=_s(t,{wrapperClassName:e===`top-right`?`persona-absolute persona-top-4 persona-z-50`:d});g=n.button,_=n.wrapper,e===`top-right`?_.style.right=`48px`:m.appendChild(_)}m.appendChild(p),s.appendChild(m);let v=k(`div`);v.style.display=`none`;let y=k(`span`);return y.style.display=`none`,{header:s,iconHolder:v,headerTitle:u,headerSubtitle:y,closeButton:f,closeButtonWrapper:p,clearChatButton:g,clearChatButtonWrapper:_}}},Es=e=>Ts[e]??Ts.default,Ds=(e,t,n)=>{if(t?.render){let r=t.render({config:e,onClose:n?.onClose,onClearChat:n?.onClearChat,trailingActions:t.trailingActions,onAction:t.onAction}),i=k(`div`);i.style.display=`none`;let a=k(`span`),o=k(`span`),s=k(`button`);s.style.display=`none`;let c=k(`div`);return c.style.display=`none`,{header:r,iconHolder:i,headerTitle:a,headerSubtitle:o,closeButton:s,closeButtonWrapper:c,clearChatButton:null,clearChatButtonWrapper:null}}let r=t?.layout??`default`,i=Es(r)({config:e,showClose:t?.showCloseButton??n?.showClose??!0,onClose:n?.onClose,onClearChat:n?.onClearChat,layoutHeaderConfig:t,onHeaderAction:t?.onAction});return t&&(t.showIcon===!1&&(i.iconHolder.style.display=`none`),t.showTitle===!1&&(i.headerTitle.style.display=`none`),t.showSubtitle===!1&&(i.headerSubtitle.style.display=`none`),t.showCloseButton===!1&&(i.closeButton.style.display=`none`),t.showClearChat===!1&&i.clearChatButtonWrapper&&(i.clearChatButtonWrapper.style.display=`none`)),i};function Os(e,t){if(!t.defaultPrevented){for(let n of t.composedPath()){if(n===e)break;if(n instanceof Element&&n.matches(`button, input, textarea, select, a[href], label, [contenteditable]:not([contenteditable="false"]), [role="button"], [role="link"], [role="checkbox"], [role="radio"], [role="combobox"], [tabindex]`))return}(e.querySelector(`[data-persona-composer-input][contenteditable="true"]`)??e.querySelector(`textarea[data-persona-composer-input]`))?.focus()}}const ks=e=>{let{config:t}=e,n=O(`div`,{className:`persona-widget-footer persona-border-t-persona-divider persona-bg-persona-surface persona-px-6 persona-py-4`,attrs:{"data-persona-theme-zone":`composer`}}),r=we(),i=O(`form`,{className:`persona-widget-composer persona-flex persona-flex-col persona-gap-2 persona-rounded-2xl persona-border persona-border-persona-border persona-bg-persona-input-background persona-px-4 persona-py-3`,attrs:{"data-persona-composer-form":``}}),{textarea:a,attachAutoResize:o}=be(t);o();let s=ue(t),c=Se(t),l=ce(t),u=_e(t),d=O(`div`,{className:`persona-widget-composer__header`,attrs:{"data-persona-composer-header":``},style:{display:`contents`}});i.append(d),l&&(d.append(l.previewsContainer),i.append(l.input)),i.append(a);let f=O(`div`,{className:`persona-widget-composer__actions persona-flex persona-items-center persona-justify-between persona-w-full`,attrs:{"data-persona-composer-actions":``}}),p=O(`div`,{className:`persona-widget-composer__left-actions persona-flex persona-items-center persona-gap-2`,attrs:{"data-persona-composer-actions-start":``}}),m=O(`div`,{className:`persona-widget-composer__right-actions persona-flex persona-items-center persona-gap-2`,attrs:{"data-persona-composer-actions-end":``}});return l&&p.append(l.wrapper),c&&m.append(c.wrapper),m.append(s.wrapper),f.append(p,m),i.append(f),i.addEventListener(`click`,e=>{Os(i,e)}),t?.statusIndicator?.mode===`transient`?n.append(r,u,i):n.append(r,i,u),{footer:n,suggestions:r,composerForm:i,header:d,textarea:a,sendButton:s.button,sendButtonWrapper:s.wrapper,micButton:c?.button??null,micButtonWrapper:c?.wrapper??null,statusText:u,attachmentButton:l?.button??null,attachmentButtonWrapper:l?.wrapper??null,attachmentInput:l?.input??null,attachmentPreviewsContainer:l?.previewsContainer??null,actionsRow:f,leftActions:p,rightActions:m,setSendButtonMode:s.setMode}},X=()=>{let e=O(`button`,{className:`persona-pill-peek`,attrs:{type:`button`,"data-persona-pill-peek":``,"aria-label":`Show conversation`,tabindex:`-1`}}),t=k(`span`,`persona-pill-peek__icon`),n=b(En,16,`currentColor`,1.5);n&&t.appendChild(n);let r=k(`span`,`persona-pill-peek__text`),i=k(`span`,`persona-pill-peek__caret`),a=b(bn,16,`currentColor`,1.5);return a&&i.appendChild(a),e.append(t,r,i),{root:e,textNode:r}},As=e=>{let{config:t}=e,n=O(`div`,{className:`persona-widget-footer persona-widget-footer--pill`,attrs:{"data-persona-theme-zone":`composer`}}),r=we(),i=_e(t);i.style.display=`none`;let{textarea:a,attachAutoResize:o}=be(t,{defaultMaxLines:5});o();let s=ue(t),c=Se(t),l=ce(t);l&&l.previewsContainer.classList.add(`persona-pill-composer__previews`);let u=O(`form`,{className:`persona-widget-composer persona-pill-composer`,attrs:{"data-persona-composer-form":``}}),d=O(`div`,{className:`persona-widget-composer__left-actions persona-pill-composer__left`,attrs:{"data-persona-composer-actions-start":``}});l&&d.append(l.wrapper);let f=O(`div`,{className:`persona-widget-composer__right-actions persona-pill-composer__right`,attrs:{"data-persona-composer-actions-end":``}});c&&f.append(c.wrapper),f.append(s.wrapper),u.addEventListener(`click`,e=>{Os(u,e)}),l&&u.append(l.input),u.append(d,a,f);let p=O(`div`,{className:`persona-pill-composer__header`,attrs:{"data-persona-composer-header":``},style:{display:`contents`}});n.append(p),l&&p.append(l.previewsContainer),n.append(r,u,i);let m=u;return{footer:n,suggestions:r,composerForm:u,header:p,textarea:a,sendButton:s.button,sendButtonWrapper:s.wrapper,micButton:c?.button??null,micButtonWrapper:c?.wrapper??null,statusText:i,attachmentButton:l?.button??null,attachmentButtonWrapper:l?.wrapper??null,attachmentInput:l?.input??null,attachmentPreviewsContainer:l?.previewsContainer??null,actionsRow:m,leftActions:d,rightActions:f,setSendButtonMode:s.setMode}},js=e=>{switch(e){case`max_tool_calls`:return`Tool limit reached.`;case`length`:return`Output token limit reached.`;case`content_filter`:return`The provider filtered this response.`;case`error`:return`Something went wrong generating this response.`;default:return null}},Ms=(e,t)=>{if(!e)return null;let n=js(e);if(n===null)return null;let r=t?.[e];return(r===void 0?n:r)||null},Ns=(e,t)=>O(`div`,{className:`persona-message-stop-reason persona-text-xs persona-mt-2 persona-italic`,attrs:{"data-stop-reason":e,role:`note`},style:{opacity:`0.75`},text:t}),Ps=e=>{let t=e.toLowerCase();return!t.startsWith(`data:image/svg+xml`)&&!!(/^(?:https?|blob):/i.test(e)||t.startsWith(`data:image/`)||!e.includes(`:`))},Fs=e=>{let t=e.toLowerCase();return t.startsWith(`javascript:`)||t.startsWith(`data:text/html`)||t.startsWith(`data:text/javascript`)||t.startsWith(`data:text/xml`)||t.startsWith(`data:application/xhtml`)||t.startsWith(`data:image/svg+xml`)?!1:!!(/^(?:https?|blob):/i.test(e)||t.startsWith(`data:`)||!e.includes(`:`))},Is=e=>!e.contentParts||e.contentParts.length===0?[]:e.contentParts.filter(e=>e.type===`image`&&typeof e.image==`string`&&e.image.trim().length>0),Ls=e=>!e.contentParts||e.contentParts.length===0?[]:e.contentParts.filter(e=>e.type===`audio`&&typeof e.audio==`string`&&e.audio.trim().length>0),Rs=e=>!e.contentParts||e.contentParts.length===0?[]:e.contentParts.filter(e=>e.type===`video`&&typeof e.video==`string`&&e.video.trim().length>0),zs=e=>!e.contentParts||e.contentParts.length===0?[]:e.contentParts.filter(e=>e.type===`file`&&typeof e.data==`string`&&e.data.trim().length>0),Bs=e=>{if(!e||e.length===0)return null;let t=O(`div`,{className:`persona-mention-context-row persona-message-mentions`,attrs:{"data-message-mentions":``}});t.style.display=`flex`;for(let n of e){let e=O(`div`,{className:`persona-mention-chip persona-mention-chip-readonly`,attrs:{"data-status":`ready`,title:n.label}}),r=k(`span`,`persona-mention-chip-icon`),i=T(n.iconName??`at-sign`,13,`currentColor`,2);i&&r.appendChild(i),e.appendChild(r),e.appendChild(O(`span`,{className:`persona-mention-chip-label`,text:n.label})),t.appendChild(e)}return t},Vs=(e,t)=>{let n=document.createDocumentFragment();for(let r of e)r.kind===`text`?n.appendChild(document.createTextNode(r.text)):n.appendChild(Ce(r.ref,{readonly:!0,render:t}));return n},Hs=(e,t,n,r)=>{let i=Math.random().toString(36).slice(2,8),a=e=>`${i}:${e}`,o=n(t.map((e,t)=>e.kind===`text`?e.text:a(t)).join(``));if(!t.every((e,t)=>e.kind===`text`||o.includes(a(t)))){e.replaceChildren(Vs(t,r));return}e.innerHTML=o;let s=RegExp(`${i}:(\\d+)`),c=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),l=[];for(let e=c.nextNode();e;e=c.nextNode())l.push(e);for(let e of l){let n=e;for(let e=s.exec(n.data);e;e=s.exec(n.data)){let i=t[Number(e[1])],a=n.splitText(e.index);a.data=a.data.slice(e[0].length),i?.kind===`mention`&&a.parentNode?.insertBefore(Ce(i.ref,{readonly:!0,render:r}),a),n=a}}},Us=(e,t,n)=>{if(e.length===0)return null;try{let r=k(`div`,`persona-flex persona-flex-col persona-gap-2`);r.setAttribute(`data-message-attachments`,`images`),t&&(r.style.marginBottom=`8px`);let i=0,a=!1,o=()=>{a||(a=!0,r.remove(),n?.())};return e.forEach((e,t)=>{let n=k(`img`);n.alt=e.alt?.trim()||`Attached image ${t+1}`,n.loading=`lazy`,n.decoding=`async`,n.referrerPolicy=`no-referrer`,n.style.display=`block`,n.style.width=`100%`,n.style.maxWidth=`320px`,n.style.maxHeight=`320px`,n.style.height=`auto`,n.style.objectFit=`contain`,n.style.borderRadius=`10px`,n.style.backgroundColor=`var(--persona-attachment-image-bg, var(--persona-container, #f3f4f6))`,n.style.border=`1px solid var(--persona-attachment-image-border, var(--persona-border, #e5e7eb))`;let a=!1;i+=1,n.addEventListener(`error`,()=>{a||(a=!0,i=Math.max(0,i-1),n.remove(),i===0&&o())}),n.addEventListener(`load`,()=>{a=!0}),Ps(e.image)?(n.src=e.image,r.appendChild(n)):(a=!0,i=Math.max(0,i-1),n.remove())}),i===0?(o(),null):r}catch{return n?.(),null}},Z=e=>{if(e.length===0)return null;try{let t=k(`div`,`persona-flex persona-flex-col persona-gap-2`);t.setAttribute(`data-message-attachments`,`audio`);let n=0;return e.forEach(e=>{if(!Fs(e.audio))return;let r=k(`audio`);r.controls=!0,r.preload=`metadata`,r.src=e.audio,r.style.display=`block`,r.style.width=`100%`,r.style.maxWidth=`320px`,t.appendChild(r),n+=1}),n===0?(t.remove(),null):t}catch{return null}},Ws=e=>{if(e.length===0)return null;try{let t=k(`div`,`persona-flex persona-flex-col persona-gap-2`);t.setAttribute(`data-message-attachments`,`video`);let n=0;return e.forEach(e=>{if(!Fs(e.video))return;let r=k(`video`);r.controls=!0,r.preload=`metadata`,r.src=e.video,r.style.display=`block`,r.style.width=`100%`,r.style.maxWidth=`320px`,r.style.maxHeight=`320px`,r.style.borderRadius=`10px`,r.style.backgroundColor=`var(--persona-attachment-image-bg, var(--persona-container, #f3f4f6))`,t.appendChild(r),n+=1}),n===0?(t.remove(),null):t}catch{return null}},Gs=e=>{if(e.length===0)return null;try{let t=k(`div`,`persona-flex persona-flex-col persona-gap-2`);t.setAttribute(`data-message-attachments`,`files`);let n=0;return e.forEach(e=>{if(!Fs(e.data))return;let r=k(`a`);r.href=e.data,r.download=e.filename,r.target=`_blank`,r.rel=`noopener noreferrer`,r.textContent=e.filename,r.className=`persona-message-file-attachment`,r.style.display=`inline-flex`,r.style.alignItems=`center`,r.style.gap=`6px`,r.style.padding=`6px 10px`,r.style.borderRadius=`8px`,r.style.fontSize=`0.875rem`,r.style.textDecoration=`underline`,r.style.backgroundColor=`var(--persona-attachment-file-bg, var(--persona-container, #f3f4f6))`,r.style.border=`1px solid var(--persona-attachment-file-border, var(--persona-border, #e5e7eb))`,r.style.color=`inherit`,t.appendChild(r),n+=1}),n===0?(t.remove(),null):t}catch{return null}},Ks=(e={})=>{let t=e.loadingIndicator,n=e.future?.v5Defaults;if((t?.variant??(n?`label`:`dots`))===`label`){let r=O(`div`,{className:`persona-loading-label`,attrs:{role:`status`}});n&&t?.showBubble!==!0&&r.classList.add(`persona-activity-row`,`persona-activity-header`);let i=e.features?.toolCallDisplay,a=t?.iconVisibility??(i?.grouped!==!1&&(i?.groupedMode??`collapsible`)===`collapsible`?i?.groupIconVisibility:void 0)??i?.iconVisibility,o=t?.iconName??`loader-circle`;if(a!==`never`&&(n||t?.iconName||t?.iconVisibility)){let e=T(o,16);e&&(e.classList.add(`persona-activity-icon`),e.dataset.loadingIconAnimation=t?.iconAnimation??(o===`loader-circle`?`spin`:`none`),r.appendChild(e))}let s=O(`span`,{text:t?.label??`Thinking…`});return r.appendChild(s),Zn()?.applyLoadingLabel(s,e,`waiting`),r}let r=k(`div`,`persona-flex persona-items-center persona-space-x-1 persona-h-5 persona-mt-2`);for(let e=0;e<3;e++){let t=k(`div`,`persona-animate-typing persona-rounded-full persona-h-1.5 persona-w-1.5`);t.style.backgroundColor=`currentColor`,t.style.opacity=`0.4`,t.style.animationDelay=`${e*250}ms`,r.appendChild(t)}let i=k(`span`,`persona-sr-only`);return i.textContent=`Loading`,r.appendChild(i),r},qs=(e,t,n)=>t?.({config:n??{},streaming:!0,location:e,defaultRenderer:()=>Ks(n)})??Ks(n),Js=(e,t)=>{let n=k(`div`,`persona-flex-shrink-0 persona-w-8 persona-h-8 persona-rounded-full persona-flex persona-items-center persona-justify-center persona-text-sm`),r=t===`user`?e.userAvatar:e.assistantAvatar;if(r){if(r.startsWith(`http`)||r.startsWith(`/`)||r.startsWith(`data:`)){let e=k(`img`);e.src=r,e.alt=t===`user`?`User`:`Assistant`,e.className=`persona-w-full persona-h-full persona-rounded-full persona-object-cover`,n.appendChild(e)}else n.textContent=r,n.classList.add(t===`user`?`persona-bg-persona-accent`:`persona-bg-persona-primary`,`persona-text-white`)}else n.textContent=t===`user`?`U`:`A`,n.classList.add(t===`user`?`persona-bg-persona-accent`:`persona-bg-persona-primary`,`persona-text-white`);return n},Ys=(e,t,n=`div`)=>{let r=k(n,`persona-text-xs persona-text-persona-muted`),i=new Date(e.createdAt);return r.textContent=t.format?t.format(i):i.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),r},Xs=(e,t=`bubble`)=>{let n=[`persona-message-bubble`];switch(t){case`flat`:e===`user`?n.push(`persona-message-user-bubble`,`persona-ml-auto`,`persona-text-persona-primary`,`persona-py-2`):n.push(`persona-message-assistant-bubble`,`persona-text-persona-text`,`persona-py-2`);break;case`minimal`:n.push(`persona-text-sm`,`persona-leading-relaxed`),e===`user`?n.push(`persona-message-user-bubble`,`persona-ml-auto`,`persona-bg-persona-accent`,`persona-text-white`,`persona-px-3`,`persona-py-2`,`persona-rounded-lg`):n.push(`persona-message-assistant-bubble`,`persona-bg-persona-container`,`persona-text-persona-text`,`persona-px-3`,`persona-py-2`,`persona-rounded-lg`);break;default:n.push(`persona-rounded-2xl`,`persona-text-sm`,`persona-leading-relaxed`,`persona-shadow-sm`),e===`user`?n.push(`persona-message-user-bubble`,`persona-ml-auto`,`persona-bg-persona-accent`,`persona-text-white`,`persona-px-5`,`persona-py-3`):n.push(`persona-message-assistant-bubble`,`persona-bg-persona-container`,`persona-border`,`persona-border-persona-message-border`,`persona-text-persona-text`,`persona-px-5`,`persona-py-3`)}return n},Zs={bubble:{padding:`0.75rem 1.25rem`,fontSize:`0.875rem`,lineHeight:`1.75`},minimal:{padding:`0.5rem 0.75rem`,fontSize:`0.875rem`,lineHeight:`1.75`},flat:{padding:`0.5rem 0`,fontSize:`inherit`,lineHeight:`inherit`}},Qs=(e,t,n=`bubble`,r)=>{if(!r)return;let i=t===`user`?`user`:`assistant`,a=Zs[n??`bubble`]??Zs.bubble;r.padding&&(e.style.padding=`var(--persona-message-${i}-padding, ${a.padding})`),r.fontSize&&(e.style.fontSize=`var(--persona-message-${i}-font-size, ${a.fontSize})`),r.lineHeight&&(e.style.lineHeight=`var(--persona-message-${i}-line-height, ${a.lineHeight})`),r.fontFamily&&(e.style.fontFamily=`var(--persona-message-${i}-font-family, inherit)`)},$s=e=>`custom:${e}`,ec=(e,t)=>t!==`user`&&t!==`assistant`?[]:(e?.custom??[]).filter(e=>(e.roles??[`assistant`]).includes(t)),tc=(e,t,n,r,i=!1)=>{let a=t.showCopy??!0,o=t.showUpvote??!1,s=t.showDownvote??!1,c=t.showReadAloud??!1,l=(t.showRegenerate??!1)&&r?.canRegenerate===!0,u=(t.showEdit??!1)&&r?.canEdit===!0,d=(t.showQuote??!1)&&r?.canQuote!==!1,f=ec(t,e.role);if(!a&&!o&&!s&&!c&&!l&&!u&&!d&&f.length===0){let t=k(`div`);return t.style.display=`none`,t.id=`actions-${e.id}`,t.setAttribute(`data-actions-for`,e.id),t}let p=t.visibility??(i&&r?.isLastAssistant?`always`:`hover`),m=t.align??`right`,h=t.layout??`pill-inside`,g={left:`persona-message-actions-left`,center:`persona-message-actions-center`,right:`persona-message-actions-right`}[m],_={"pill-inside":`persona-message-actions-pill`,"row-inside":`persona-message-actions-row`}[h],v=k(`div`,`persona-message-actions persona-flex persona-items-center persona-gap-1 persona-mt-2 ${g} ${_} ${p===`hover`?`persona-message-actions-hover`:``} ${i?`persona-message-actions-adaptive`:``}`);v.id=`actions-${e.id}`,v.setAttribute(`data-actions-for`,e.id);let y=(e,t,n)=>{let r=nr({icon:e,label:t,size:14,className:`persona-message-action-btn`,chromeless:!0});return r.setAttribute(`data-action`,n),r};a&&v.appendChild(y(`copy`,`Copy message`,`copy`)),c&&v.appendChild(y(`volume-2`,`Read aloud`,`read-aloud`)),o&&v.appendChild(y(`thumbs-up`,`Upvote`,`upvote`)),s&&v.appendChild(y(`thumbs-down`,`Downvote`,`downvote`)),l&&v.appendChild(y(`refresh-cw`,`Regenerate response`,`regenerate`)),u&&v.appendChild(y(`pencil`,`Edit message`,`edit`)),d&&v.appendChild(y(`quote`,`Quote message`,`quote`));for(let e of f)v.appendChild(y(e.iconName??`ellipsis`,e.label,$s(e.id)));return v},nc=(e,t,n,r,i,a)=>{let o=n??{},s=o.layout??`bubble`,c=o.avatar,l=o.timestamp,u=c?.show??!1,d=l?.show??!1,f=c?.position??`left`,p=l?.position??`below`,m=Xs(e.role,s),h=k(`div`,m.join(` `));h.id=`bubble-${e.id}`,h.setAttribute(`data-message-id`,e.id),h.setAttribute(`data-persona-theme-zone`,e.role===`user`?`user-message`:`assistant-message`);let g=La(a?.widgetConfig?.future).components.message,_=a?.widgetConfig?.theme?.components?.message;Qs(h,e.role,s,e.role===`user`?{...g.user,..._?.user,...a?.widgetConfig?.darkTheme?.components?.message?.user}:{...g.assistant,..._?.assistant,...a?.widgetConfig?.darkTheme?.components?.message?.assistant}),s===`flat`?(h.style.backgroundColor=`transparent`,h.style.color=e.role===`user`?`var(--persona-primary, var(--persona-text))`:`var(--persona-message-assistant-text, var(--persona-text))`):e.role===`user`?(h.style.backgroundColor=`var(--persona-message-user-bg, var(--persona-accent))`,h.style.color=`var(--persona-message-user-text, white)`):e.role===`assistant`&&(h.style.backgroundColor=`var(--persona-message-assistant-bg, var(--persona-container))`,h.style.color=`var(--persona-message-assistant-text, var(--persona-text))`);let v=Is(e),y=e.content?.trim()??``,b=v.length>0&&y===`[Image]`,x=sn(a?.widgetConfig?.features?.streamAnimation),S=a?.widgetConfig?.features?.streamAnimation?.plugins,C=e.role===`assistant`&&x.type!==`none`?ln(x.type,S):null,ee=e.role===`assistant`&&C?.isAnimating?.(e)===!0,w=e.role===`assistant`&&C!==null&&(!!e.streaming||ee);w&&C?.bubbleClass&&h.classList.add(C.bubbleClass);let T=document.createElement(`div`);T.classList.add(`persona-message-content`),e.streaming&&T.classList.add(`persona-content-streaming`),w&&C&&(C.containerClass&&T.classList.add(C.containerClass),T.style.setProperty(`--persona-stream-step`,`${x.speed}ms`),T.style.setProperty(`--persona-stream-duration`,`${x.duration}ms`));let te=w?un(e.content??``,x.buffer,C,e,!!e.streaming):e.content??``,ne=()=>{let n=t({text:te,message:e,streaming:!!e.streaming,raw:e.rawContent});return w&&C?.wrap===`char`?hn(n,`char`,e.id,{skipTags:C.skipTags}):w&&C?.wrap===`word`?hn(n,`word`,e.id,{skipTags:C.skipTags}):n},re=null;if(b?(re=document.createElement(`div`),re.innerHTML=ne(),re.style.display=`none`,T.appendChild(re)):e.contentSegments?.length?Hs(T,e.contentSegments,n=>t({text:n,message:e,streaming:!!e.streaming,raw:e.rawContent}),a?.widgetConfig?.contextMentions?.renderMentionToken):T.innerHTML=ne(),w&&C?.useCaret&&!b&&y){let e=cn(),t=T.querySelectorAll(`.persona-stream-char, .persona-stream-word`),n=t[t.length-1];if(n?.parentNode)n.parentNode.insertBefore(e,n.nextSibling);else{let t=T.lastElementChild;t?t.appendChild(e):T.appendChild(e)}}if(d&&p===`inline`&&e.createdAt){let t=Ys(e,l,`span`);t.classList.add(`persona-timestamp-inline`);let n=T.lastElementChild;n?n.appendChild(t):T.appendChild(t)}if(v.length>0){let e=Us(v,!b&&!!y,()=>{b&&re&&(re.style.display=``)});e?h.appendChild(e):b&&re&&(re.style.display=``)}let ie=Ls(e);if(ie.length>0){let e=Z(ie);e&&h.appendChild(e)}let ae=Rs(e);if(ae.length>0){let e=Ws(ae);e&&h.appendChild(e)}let oe=zs(e);if(oe.length>0){let e=Gs(oe);e&&h.appendChild(e)}let se=e.contentSegments?.length?null:Bs(e.contextMentions);if(se&&h.appendChild(se),h.appendChild(T),d&&p===`below`&&e.createdAt){let t=Ys(e,l);t.classList.add(`persona-mt-1`),h.appendChild(t)}let ce=e.role===`assistant`?Ms(e.stopReason,a?.widgetConfig?.copy?.stopReasonNotice):null;if(e.streaming&&e.role===`assistant`){let e=!!(te&&te.trim()),t=x.placeholder===`skeleton`,n=t&&x.buffer===`line`&&e;if(e)n&&h.appendChild(fn());else if(t)h.appendChild(fn());else{let e=qs(`inline`,a?.loadingIndicatorRenderer,a?.widgetConfig);e&&h.appendChild(e)}}ce&&e.stopReason&&!e.streaming&&(y||(T.style.display=`none`),h.appendChild(Ns(e.stopReason,ce)));let le=e.role===`assistant`&&!e.streaming&&!e.voiceCaption&&e.content&&e.content.trim()&&r?.enabled!==!1,ue=a?.actionEligibility,de=e.role===`user`&&!e.streaming&&r?.enabled!==!1&&(r?.showEdit===!0&&ue?.canEdit===!0||r?.showQuote===!0&&ue?.canQuote===!0||ec(r,`user`).length>0);if((le||de)&&r){let t=tc(e,de?{...r,showCopy:!1,showUpvote:!1,showDownvote:!1,showReadAloud:!1}:r,i,ue,a?.widgetConfig?.future?.v5Defaults===!0&&r.visibility===void 0);h.appendChild(t)}if(!u||e.role===`system`)return h;let E=k(`div`,`persona-message-with-avatar persona-flex persona-gap-2 ${e.role===`user`?`persona-flex-row-reverse`:``}`),fe=Js(c,e.role);return f===`right`||f===`left`&&e.role===`user`?E.append(h,fe):E.append(fe,h),E},rc=(e,t)=>{if(e.replaceChildren(),!t)e.hidden=!0;else if(typeof t==`function`){let n=null;try{n=t()}catch(e){console.warn(`[persona] welcome.icon renderer threw`,e)}if(!n){e.hidden=!0;return}e.appendChild(n),e.hidden=!1}else{if(t.type===`lucide`){let n=T(t.name,40);if(!n){e.hidden=!0;return}e.appendChild(n)}else t.type===`image`?e.appendChild(O(`img`,{className:`persona-welcome-icon-image`,attrs:{src:t.url,alt:t.alt}})):e.appendChild(O(`span`,{className:`persona-welcome-icon-text`,text:t.text}));e.hidden=!1}},ic=(e,t,n={})=>{let r=O(`div`,{className:`persona-welcome-icon`,attrs:{"data-persona-welcome-icon":``}});r.hidden=!0;let i=k(`p`,`persona-welcome-kicker`);i.hidden=!0;let a=k(`h2`,`persona-welcome-title`),o=k(`p`,`persona-welcome-subtitle`),s=O(`div`,{className:`persona-welcome-head-text`},i,a),c=O(`div`,{className:`persona-welcome-title-row`},r,s);return{host:O(`div`,{className:`persona-welcome persona-rounded-2xl`,attrs:{"data-persona-welcome":``,"data-persona-intro-card":``,"data-persona-welcome-variant":`card`},style:{background:`var(--persona-intro-card-bg, transparent)`,boxShadow:n.flatShadow?`none`:`var(--persona-intro-card-shadow, none)`,border:`var(--persona-intro-card-border, none)`}},c,o,t),iconHolder:r,kicker:i,title:a,subtitle:o,starterSuggestions:t}},ac=(e,t,n)=>{t.hidden=!n,t.style.display=n?``:`none`,e.classList.toggle(`persona-gap-6`,n),e.classList.toggle(`persona-gap-3`,!n)},oc=(e,t)=>{e.title.textContent=t.title,e.kicker.textContent=t.kicker??``,e.kicker.hidden=!t.kicker,e.subtitle.textContent=t.subtitle,e.subtitle.hidden=t.subtitle===``,rc(e.iconHolder,t.icon),e.host.setAttribute(`data-persona-welcome-variant`,t.variant),e.host.setAttribute(`data-persona-welcome-dismiss`,t.dismiss),e.host.setAttribute(`data-persona-welcome-layout`,t.layout??`top`),e.host.setAttribute(`data-persona-welcome-anchor`,t.anchor??`bottom`),t.iconPlacement===`inline`?e.host.setAttribute(`data-persona-welcome-icon-placement`,`inline`):e.host.removeAttribute(`data-persona-welcome-icon-placement`),t.align?e.host.setAttribute(`data-persona-welcome-align`,t.align):e.host.removeAttribute(`data-persona-welcome-align`)},sc=`data-persona-welcome-overlay`,cc=`persona-welcome-overlay-active`,lc=/* @__PURE__ */ new WeakMap,uc=(e,t,n)=>{n.setAttribute(`data-persona-welcome-plugin`,``),t.appendChild(n),t.setAttribute(`data-persona-welcome-content`,`plugin`),t.setAttribute(sc,``),e.classList.contains(cc)||(lc.set(e,e.scrollTop),e.classList.add(cc),e.scrollTop=0)},dc=(e,t,n)=>{n&&n!==t&&n.remove(),t.removeAttribute(`data-persona-welcome-content`),t.removeAttribute(sc),e.classList.contains(cc)&&(e.classList.remove(cc),e.scrollTop=lc.get(e)??e.scrollTop,lc.delete(e))},fc=()=>{let e=O(`div`,{className:`persona-welcome-greeting persona-flex persona-flex-col`,attrs:{"data-persona-welcome-greeting":``}});return e.hidden=!0,e},pc=(e,t,n)=>{if(e.replaceChildren(),!t){e.hidden=!0;return}let r=n?.layout?.messages?.layout??`bubble`,i=O(`div`,{className:Xs(`assistant`,r).join(` `),attrs:{"data-persona-theme-zone":`assistant-message`},text:t,style:r===`flat`?{backgroundColor:`transparent`,color:`var(--persona-message-assistant-text, var(--persona-text))`}:{backgroundColor:`var(--persona-message-assistant-bg, var(--persona-container))`,color:`var(--persona-message-assistant-text, var(--persona-text))`}});e.appendChild(O(`div`,{className:`persona-flex`},i)),e.hidden=!1},mc=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,hc=(e,t)=>{if(mc()||typeof e.animate!=`function`||!e.isConnected)return t(null),null;let n=e.getBoundingClientRect(),r=e.parentElement,i=0,a=0,o=0;if(r){let t=getComputedStyle(r);i=parseFloat(t.rowGap)||0;let s=e.previousElementSibling,c=e.nextElementSibling,l=r.getBoundingClientRect().top+(parseFloat(t.borderTopWidth)||0)+(parseFloat(t.paddingTop)||0)-r.scrollTop;a=Math.max(0,s?n.top-s.getBoundingClientRect().bottom-i:n.top-l),o=Math.max(0,c?c.getBoundingClientRect().top-n.bottom-i:0)}let s=e.style.overflow;e.style.overflow=`hidden`;let c=getComputedStyle(e),l=parseFloat(c.paddingTop)||0,u=parseFloat(c.paddingBottom)||0,d=e.animate([{opacity:`1`,transform:`none`,height:`${n.height}px`,minHeight:`0px`,paddingTop:`${l}px`,paddingBottom:`${u}px`,marginTop:`${a}px`,marginBottom:`${o}px`},{opacity:`0`,transform:`translateY(-4px)`,height:`0px`,minHeight:`0px`,paddingTop:`0px`,paddingBottom:`0px`,marginTop:`0px`,marginBottom:`${-i}px`}],{duration:180,easing:`ease-out`,fill:`forwards`}),f=!1,p=()=>{f||(f=!0,e.style.overflow=s,t(d))};return d.finished.then(p).catch(p),d},gc=(e,t,n,r=260)=>{if(t<=1||mc()||typeof e.animate!=`function`||!e.isConnected)return null;let i=n===`drop`?-t:t;return e.animate([{transform:`translateY(${i}px)`},{transform:`none`}],{duration:r,easing:`cubic-bezier(0.2, 0, 0, 1)`,fill:`none`})},_c=/* @__PURE__ */ new WeakSet,vc=(e,t)=>!!e&&e[t]!==void 0,yc=(e,t)=>{e&&e.debug===!0&&t.length&&!_c.has(e)&&(_c.add(e),t.forEach(e=>console.warn(`[persona] ${e}`)))},bc=(e,t=e?.launcher?.fullHeight===!0&&!e.launcher.sidebarMode&&e.launcher.mountMode!==`docked`)=>{let n=e?.welcome,r=e?.copy,i=e?.future?.v5Defaults===!0,a=n?.layout??(i?`centered`:`top`),o=vc(n,`variant`)?n.variant:r?.showWelcomeCard===!1?`none`:`card`,s=o===`hero`&&!i&&n?.layout===void 0?`on-first-message`:vc(n,`dismiss`)?n.dismiss:i||o===`hero`?`on-first-message`:`never`,c=[];for(let[e,t]of[[`title`,`welcomeTitle`],[`subtitle`,`welcomeSubtitle`],[`variant`,`showWelcomeCard`]])vc(n,e)&&vc(r,t)&&c.push(`welcome.${e} and copy.${t} are both set; welcome.${e} wins. copy.${t} is deprecated.`);o===`hero`&&vc(n,`message`)&&c.push(`welcome.message is ignored when welcome.variant is "hero": the hero is the greeting.`),!i&&n?.layout===void 0&&o===`hero`&&vc(n,`dismiss`)&&n.dismiss!==`on-first-message`&&c.push(`welcome.dismiss is pinned to "on-first-message" when welcome.variant is "hero".`);let l=n?.anchor??(o!==`none`&&a===`centered`&&t?`center`:`bottom`),u=So(n?.anchorComposerTop)!==null;return vc(n,`anchorComposerTop`)&&!u&&c.push(`welcome.anchorComposerTop must be a percentage between 0% and 100%; falling back to "44%".`),l!==`center`&&(vc(n,`anchorComposerTop`)||vc(n,`composerGap`))&&c.push(`welcome.anchorComposerTop is ignored unless welcome.anchor is "center".`),yc(e,c),{title:vc(n,`title`)?n.title:r?.welcomeTitle??(i?`What can I help with?`:`Hello 👋`),kicker:n?.kicker??``,subtitle:vc(n,`subtitle`)?n.subtitle:r?.welcomeSubtitle??(i?``:`I can answer questions and help you get things done here.`),icon:n?.icon,align:n?.align===`start`||n?.align===`center`?n.align:a===`centered`?`center`:void 0,iconPlacement:n?.icon&&typeof n.icon!=`function`&&n.icon.placement===`inline`?`inline`:`above`,variant:o,dismiss:s,message:o===`hero`?void 0:n?.message,layout:a,anchor:l,anchorComposerTop:u?n.anchorComposerTop:`44%`,composerGap:n?.composerGap?.trim()||`24px`}},xc=(e=[])=>e.some(e=>e.role===`user`||e.role===`assistant`&&(e.content.trim()||e.contentParts?.some(e=>e.type!==`text`||e.text.trim())||e.toolCall||e.tools?.length||e.reasoning||e.approval)),Sc=e=>xc(e)?`active`:`empty`,Cc=(e,t)=>e.variant!==`none`&&(e.dismiss===`never`||!xc(t)),wc=`var(--persona-components-panel-height)`,Tc=e=>{let t=nn(e),n=t.launcherWidth?e?.launcher?.width:t.legacyLauncherWidth?e?.launcherWidth:void 0,r=e?.launcher?.heightOffset??0,i=r===0?`max(200px, ${wc})`:`max(200px, calc(${wc} - ${r}px))`;return{width:n??`var(--persona-components-panel-width)`,maxWidth:n??`var(--persona-components-panel-maxWidth)`,height:i,maxHeight:`var(--persona-components-panel-maxHeight)`}},Ec=e=>{let t=nn(e);return t.launcherWidth||t.legacyLauncherWidth||e?.theme?.components?.panel?.width!==void 0?Tc(e).width:`100%`},Dc=`16px`,Oc=`10px`,kc=`14px`,Ac=e=>{let t=e?.launcher?.enabled??!0,n=$o(e);if(es(e)){let t=e?.launcher?.composerBar??{},n=k(`div`,`persona-widget-wrapper persona-fixed persona-transition`);n.setAttribute(`data-persona-composer-bar`,``),n.dataset.state=`collapsed`,n.dataset.expandedSize=t.expandedSize??`anchored`,n.style.zIndex=String(e?.launcher?.zIndex??1e5);let r=k(`div`,`persona-widget-panel persona-relative persona-flex persona-flex-1 persona-min-h-0 persona-flex-col`);r.style.width=`100%`,n.appendChild(r);let i=k(`div`,`persona-widget-pill-root`);return i.setAttribute(`data-persona-composer-bar`,``),i.dataset.state=`collapsed`,i.dataset.expandedSize=t.expandedSize??`anchored`,i.style.zIndex=String(e?.launcher?.zIndex??1e5),{wrapper:n,panel:r,pillRoot:i}}if(n){let e=k(`div`,`persona-relative persona-h-full persona-w-full persona-flex persona-flex-1 persona-min-h-0 persona-flex-col`),t=k(`div`,`persona-relative persona-h-full persona-w-full persona-flex persona-flex-1 persona-min-h-0 persona-flex-col`);return e.appendChild(t),{wrapper:e,panel:t}}if(!t){let t=k(`div`,`persona-relative persona-h-full persona-flex persona-flex-col persona-flex-1 persona-min-h-0`),n=k(`div`,`persona-relative persona-flex-1 persona-flex persona-flex-col persona-min-h-0`);return t.style.width=Ec(e),n.style.width=`100%`,t.appendChild(n),{wrapper:t,panel:n}}let r=e?.launcher??{},i=r.position&&us[r.position]?us[r.position]:us[`bottom-right`],a=k(`div`,`persona-widget-wrapper persona-fixed ${i} persona-transition`);a.style.zIndex=String(e?.launcher?.zIndex??1e5);let o=k(`div`,`persona-widget-panel persona-relative persona-min-h-[320px]`),s=Tc(e);return o.style.width=s.width,o.style.maxWidth=s.maxWidth,a.appendChild(o),{wrapper:a,panel:o}},jc=e=>{let t=O(`div`,{className:`persona-suggestions`,attrs:{"data-persona-suggestions":rs(e)}});return t.hidden=!0,t},Mc=(e,t)=>{let n=jc(`starter`),r=ic(e,n,{flatShadow:$o(e)}),i=bc(e);oc(r,i),ac(t,r.host,Cc(i,e?.initialMessages));let a=fc();return pc(a,i.message,e),{welcome:r,greetingHost:a}},Nc=(e,t)=>{let n=k(`div`,`persona-widget-container persona-relative persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-text-persona-primary`);n.setAttribute(`data-persona-theme-zone`,`container`);let{button:r,wrapper:i}=gs(e,{showClose:t,wrapperClassName:`persona-composer-bar-close`,buttonSize:Dc,iconSize:Oc});i.style.position=`absolute`,i.style.top=`8px`,i.style.right=`8px`,i.style.zIndex=`10`;let a=e?.launcher?.clearChat?.enabled??!0,o=null,s=null;if(a){let t=_s(e,{wrapperClassName:`persona-composer-bar-clear-chat`,buttonSize:Dc,iconSize:kc});o=t.button,s=t.wrapper,s.style.position=`absolute`,s.style.top=`8px`,s.style.right=`32px`,s.style.zIndex=`10`}let c=O(`span`,{className:`persona-widget-header`,attrs:{"data-persona-theme-zone":`header`},style:{display:`none`}}),l=O(`div`,{className:`persona-widget-body persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-gap-6 persona-overflow-y-auto persona-bg-persona-container persona-px-6 persona-py-6`,attrs:{id:`persona-scroll-container`,"data-persona-theme-zone":`messages`},style:{paddingTop:`48px`}});l.style.setProperty(`scrollbar-gutter`,`stable`);let{welcome:u,greetingHost:d}=Mc(e,l),{host:f,title:p,subtitle:m}=u,h=u.starterSuggestions,g=k(`div`,`persona-widget-messages persona-flex persona-flex-col`);g.style.gap=`var(--persona-components-message-gap, 12px)`;let _=jc(`followUp`),v=bo(e,!0);v&&(g.style.maxWidth=v,g.style.marginLeft=`auto`,g.style.marginRight=`auto`,g.style.width=`100%`),l.append(f,d,g,_);let y=O(`div`,{className:`persona-composer-overlay persona-pointer-events-none`,attrs:{"data-persona-composer-overlay":``},style:{position:`absolute`,left:`0`,right:`0`,bottom:`calc(var(--persona-composer-overlay-height, 0px) + var(--persona-composer-lift, 0px))`,zIndex:`20`}}),b=As({config:e}),{root:x,textNode:S}=X();return n.append(c,i,l,y),s&&n.appendChild(s),{container:n,body:l,messagesWrapper:g,starterSuggestions:h,transcriptSuggestions:_,composerOverlay:y,suggestions:b.suggestions,textarea:b.textarea,sendButton:b.sendButton,sendButtonWrapper:b.sendButtonWrapper,micButton:b.micButton,micButtonWrapper:b.micButtonWrapper,composerForm:b.composerForm,statusText:b.statusText,welcomeHost:f,welcomeIconHolder:u.iconHolder,greetingHost:d,introKicker:u.kicker,introTitle:p,introSubtitle:m,closeButton:r,closeButtonWrapper:i,clearChatButton:o,clearChatButtonWrapper:s,iconHolder:k(`span`),headerTitle:k(`span`),headerSubtitle:k(`span`),header:c,footer:b.footer,attachmentButton:b.attachmentButton,attachmentButtonWrapper:b.attachmentButtonWrapper,attachmentInput:b.attachmentInput,attachmentPreviewsContainer:b.attachmentPreviewsContainer,actionsRow:b.actionsRow,leftActions:b.leftActions,rightActions:b.rightActions,setSendButtonMode:b.setSendButtonMode,peekBanner:x,peekTextNode:S}},Pc=(e,t=!0)=>{if(es(e))return Nc(e,t);let n=O(`div`,{className:`persona-widget-container persona-flex persona-h-full persona-w-full persona-flex-1 persona-min-h-0 persona-flex-col persona-text-persona-primary persona-bg-persona-surface persona-rounded-2xl persona-overflow-hidden persona-border persona-border-persona-border`,attrs:{"data-persona-theme-zone":`container`}}),r=e?.layout?.header,i=en(e),a=r?Ds(e,r,{showClose:t}):xs({config:e,showClose:t}),o=O(`div`,{className:`persona-widget-body persona-flex persona-flex-1 persona-min-h-0 persona-flex-col persona-gap-6 persona-overflow-y-auto persona-bg-persona-container persona-px-6 persona-py-6`,attrs:{id:`persona-scroll-container`,"data-persona-theme-zone":`messages`}});o.style.setProperty(`scrollbar-gutter`,`stable`);let{welcome:s,greetingHost:c}=Mc(e,o),{host:l,title:u,subtitle:d}=s,f=s.starterSuggestions,p=k(`div`,`persona-widget-messages persona-flex persona-flex-col`);p.style.gap=`var(--persona-components-message-gap, 12px)`;let m=jc(`followUp`),h=bo(e,!1);h&&(p.style.maxWidth=h,p.style.marginLeft=`auto`,p.style.marginRight=`auto`,p.style.width=`100%`),o.append(l,c,p,m);let g=ks({config:e}),_=e?.layout?.showFooter!==!1;i||(a.header.style.display=`none`),Ss(n,a,e),n.append(o);let v=O(`div`,{className:`persona-composer-overlay persona-pointer-events-none`,attrs:{"data-persona-composer-overlay":``},style:{position:`absolute`,left:`0`,right:`0`,bottom:`calc(var(--persona-composer-overlay-height, 0px) + var(--persona-composer-lift, 0px))`,zIndex:`20`}});return _||(g.footer.style.display=`none`),n.append(g.footer),n.append(v),{container:n,body:o,messagesWrapper:p,starterSuggestions:f,transcriptSuggestions:m,composerOverlay:v,suggestions:g.suggestions,textarea:g.textarea,sendButton:g.sendButton,sendButtonWrapper:g.sendButtonWrapper,micButton:g.micButton,micButtonWrapper:g.micButtonWrapper,composerForm:g.composerForm,statusText:g.statusText,welcomeHost:l,welcomeIconHolder:s.iconHolder,greetingHost:c,introKicker:s.kicker,introTitle:u,introSubtitle:d,closeButton:a.closeButton,closeButtonWrapper:a.closeButtonWrapper,clearChatButton:a.clearChatButton,clearChatButtonWrapper:a.clearChatButtonWrapper,iconHolder:a.iconHolder,headerTitle:a.headerTitle,headerSubtitle:a.headerSubtitle,header:a.header,footer:g.footer,attachmentButton:g.attachmentButton,attachmentButtonWrapper:g.attachmentButtonWrapper,attachmentInput:g.attachmentInput,attachmentPreviewsContainer:g.attachmentPreviewsContainer,actionsRow:g.actionsRow,leftActions:g.leftActions,rightActions:g.rightActions,setSendButtonMode:g.setSendButtonMode}},Fc=(e,t)=>{let n=k(`button`);n.type=`button`,n.innerHTML=`
|
|
11
11
|
<span class="persona-inline-flex persona-items-center persona-justify-center persona-rounded-full persona-bg-persona-primary persona-text-white" data-role="launcher-icon">💬</span>
|
|
12
12
|
<img data-role="launcher-image" class="persona-rounded-full persona-object-cover" alt="" style="display:none" />
|
|
13
13
|
<span class="persona-flex persona-min-w-0 persona-flex-1 persona-flex-col persona-items-start persona-text-left">
|
|
@@ -15,7 +15,7 @@ import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,n as l,o a
|
|
|
15
15
|
<span class="persona-block persona-w-full persona-truncate persona-text-xs persona-text-persona-launcher-muted" data-role="launcher-subtitle"></span>
|
|
16
16
|
</span>
|
|
17
17
|
<span class="persona-ml-2 persona-grid persona-place-items-center persona-rounded-full persona-bg-persona-primary persona-text-persona-call-to-action" data-role="launcher-call-to-action-icon">↗</span>
|
|
18
|
-
`,n.addEventListener(`click`,t);let r=e=>{let t=e.launcher??{},r=$o(e),i=xa(e)===`circle`;i?(n.dataset.personaLauncherVariant=`circle`,n.setAttribute(`aria-label`,t.title??`Open chat`)):(n.removeAttribute(`data-persona-launcher-variant`),n.removeAttribute(`aria-label`));let a=n.querySelector(`[data-role='launcher-title']`);if(a){let e=t.title??`Chat Assistant`;a.textContent=e,a.setAttribute(`title`,e)}let o=n.querySelector(`[data-role='launcher-subtitle']`);if(o){let e=t.subtitle??`Here to help you get answers fast`;o.textContent=e,o.setAttribute(`title`,e)}let s=n.querySelector(`.persona-flex-col`);s&&(t.textHidden||r||i?s.style.display=`none`:s.style.display=``);let c=n.querySelector(`[data-role='launcher-icon']`);if(c){if(t.agentIconHidden)c.style.display=`none`;else{let e=t.agentIconSize??`40px`;if(c.style.height=e,c.style.width=e,t.agentIconBackgroundColor?(c.style.backgroundColor=t.agentIconBackgroundColor,c.classList.remove(`persona-bg-persona-primary`)):(c.style.backgroundColor=``,c.classList.add(`persona-bg-persona-primary`)),c.innerHTML=``,t.agentIconName){let n=parseFloat(e)||24,r=T(t.agentIconName,n*.6,`var(--persona-text-inverse, #ffffff)`,1.5);r?(c.appendChild(r),c.style.display=``):(c.textContent=t.agentIconText??`💬`,c.style.display=``)}else t.iconUrl?c.style.display=`none`:(c.textContent=t.agentIconText??`💬`,c.style.display=``)}}let l=n.querySelector(`[data-role='launcher-image']`);if(l){let e=t.agentIconSize??`40px`;l.style.height=e,l.style.width=e,t.iconUrl&&!t.agentIconName&&!t.agentIconHidden?(l.src=t.iconUrl,l.style.display=`block`):l.style.display=`none`}let u=n.querySelector(`[data-role='launcher-call-to-action-icon']`);if(u){let e=t.callToActionIconSize??`32px`;u.style.height=e,u.style.width=e,t.callToActionIconBackgroundColor?(u.style.backgroundColor=t.callToActionIconBackgroundColor,u.classList.remove(`persona-bg-persona-primary`)):(u.style.backgroundColor=``,u.classList.add(`persona-bg-persona-primary`)),t.callToActionIconColor?(u.style.color=t.callToActionIconColor,u.classList.remove(`persona-text-persona-call-to-action`)):(u.style.color=``,u.classList.add(`persona-text-persona-call-to-action`));let n=0;if(t.callToActionIconPadding?(u.style.boxSizing=`border-box`,u.style.padding=t.callToActionIconPadding,n=(parseFloat(t.callToActionIconPadding)||0)*2):(u.style.boxSizing=``,u.style.padding=``),t.callToActionIconHidden||i)u.style.display=`none`;else if(u.style.display=r?`none`:``,u.innerHTML=``,t.callToActionIconName){let r=Math.max((parseFloat(e)||24)-n,8),i=T(t.callToActionIconName,r,`currentColor`,1.5);i?u.appendChild(i):u.textContent=t.callToActionIconText??`↗`}else u.textContent=t.callToActionIconText??`↗`}let d=t.position&&us[t.position]?us[t.position]:us[`bottom-right`];n.className=r?`persona-relative persona-mt-4 persona-mb-4 persona-mx-auto persona-flex persona-items-center persona-justify-center persona-rounded-launcher persona-bg-persona-launcher persona-transition hover:persona-translate-y-[-2px] persona-cursor-pointer`:`persona-fixed persona-flex persona-items-center persona-gap-3 persona-rounded-launcher persona-bg-persona-launcher persona-py-2.5 persona-pl-3 persona-pr-3 persona-transition hover:persona-translate-y-[-2px] persona-cursor-pointer ${d}`,r||(n.style.zIndex=String(t.zIndex??1e5)),n.style.border=t.border??`1px solid var(--persona-launcher-border, var(--persona-border, #e5e7eb))`,n.style.boxShadow=t.shadow===void 0?`var(--persona-launcher-shadow, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1))`:t.shadow.trim()===``?`none`:t.shadow,r?(n.style.width=`0`,n.style.minWidth=`0`,n.style.maxWidth=`0`,n.style.padding=`0`,n.style.overflow=`hidden`,n.style.border=`none`,n.style.boxShadow=`none`):(n.style.width=``,n.style.minWidth=``,n.style.maxWidth=t.collapsedMaxWidth??``,n.style.justifyContent=``,n.style.padding=``,n.style.overflow=``)};return e&&r(e),{element:n,update:r,destroy:()=>{n.removeEventListener(`click`,t),n.remove()}}},Ic=/* @__PURE__ */ new Set,Lc=e=>{let t=e?.persistState;return`${(typeof t==`object`?t?.keyPrefix:void 0)??`persona-`}teaser-dismissed`},Rc=(e,t)=>{if(Ic.has(e))return!0;if(!t)return!1;try{return window.localStorage.getItem(e)===`1`}catch{return!1}},zc=(e,t)=>{if(Ic.add(e),t)try{window.localStorage.setItem(e,`1`)}catch{}},Bc=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,Vc=e=>{let t=e?.launcher?.teaser;return!t||!t.text||e?.launcher?.enabled===!1||$o(e??{})?null:t},Hc=(e,t)=>{let n=k(`div`,`persona-launcher-surface`);n.setAttribute(`data-persona-launcher-surface`,`true`);let r=e??{},i=null,a=null,o=null,s=null,c=null,l=!1,u=!1,d=!1,f=!1,p=()=>(i?.frequency??`once`)===`once`&&r.persistState!==!1,m=()=>{c!==null&&(clearTimeout(c),c=null)},h=()=>{a&&l&&(l=!1,a.hidden=!0)},g=e=>{m(),d=!0,h(),zc(Lc(r),e&&p())},_=e=>{i&&!d&&g(e===`user`&&l)},v=()=>{c=null,!(!a||d||f)&&(u=!0,l=!0,a.hidden=!1,!(Bc()||typeof a.animate!=`function`)&&a.animate([{opacity:`0`,transform:`translateY(6px)`},{opacity:`1`,transform:`none`}],{duration:220,easing:`ease-out`,fill:`backwards`}))},y=()=>{i&&a&&(d||u||f||Rc(Lc(r),p())||(m(),c=setTimeout(v,Math.max(0,i.delayMs??0))))},b=()=>{g(p()),t()},x=e=>{e.stopPropagation(),g(p())},S=Fc(e,()=>{_(`user`),t()}),C=()=>{m(),s?.removeEventListener(`click`,b),o?.removeEventListener(`click`,x),a?.remove(),a=null,s=null,o=null,l=!1},ee=()=>{s=O(`button`,{className:`persona-launcher-teaser-text`,attrs:{type:`button`}}),s.addEventListener(`click`,b),o=O(`button`,{className:`persona-launcher-teaser-dismiss`,attrs:{type:`button`},text:`×`}),o.addEventListener(`click`,x),a=O(`div`,{className:`persona-launcher-teaser`,attrs:{"data-persona-launcher-teaser":`true`,role:`status`,"aria-live":`polite`,hidden:``}},s,o),n.insertBefore(a,S.element)},w=()=>{let e=r.launcher?.position??`bottom-right`,t=us[e]??us[`bottom-right`];a?(n.className=We(`persona-launcher-surface`,t),n.setAttribute(`data-teaser`,e),n.style.zIndex=String(r.launcher?.zIndex??1e5),S.element.style.position=`static`):(n.className=`persona-launcher-surface`,n.removeAttribute(`data-teaser`),n.style.zIndex=``,S.element.style.position=``)},T=e=>{let t=Vc(e);i=t,t?(a||ee(),s.textContent=t.text,o.hidden=t.dismissible===!1,o.setAttribute(`aria-label`,t.dismissLabel??`Dismiss message`),y()):C()};return n.appendChild(S.element),e&&(T(e),w()),{element:n,launcher:S,get teaser(){return a?{element:a,show:v,dismiss:g}:null},setPanelOpen:(e,t=`user`)=>{f=e,e&&_(t)},update:e=>{r=e,S.update(e),T(e),w()},destroy:()=>{C(),S.destroy(),n.remove()}}},Uc=({config:e,showClose:t})=>{let{wrapper:n,panel:r,pillRoot:i}=Ac(e),a=Pc(e,t),o={wrapper:n,panel:r,pillRoot:i},s={container:a.container,body:a.body,messagesWrapper:a.messagesWrapper,starterSuggestions:a.starterSuggestions,transcriptSuggestions:a.transcriptSuggestions,composerOverlay:a.composerOverlay,welcomeHost:a.welcomeHost,welcomeIconHolder:a.welcomeIconHolder,greetingHost:a.greetingHost,introTitle:a.introTitle,introSubtitle:a.introSubtitle},c={element:a.header,iconHolder:a.iconHolder,headerTitle:a.headerTitle,headerSubtitle:a.headerSubtitle,closeButton:a.closeButton,closeButtonWrapper:a.closeButtonWrapper,clearChatButton:a.clearChatButton,clearChatButtonWrapper:a.clearChatButtonWrapper},l={footer:a.footer,form:a.composerForm,textarea:a.textarea,sendButton:a.sendButton,sendButtonWrapper:a.sendButtonWrapper,micButton:a.micButton,micButtonWrapper:a.micButtonWrapper,statusText:a.statusText,suggestions:a.suggestions,attachmentButton:a.attachmentButton,attachmentButtonWrapper:a.attachmentButtonWrapper,attachmentInput:a.attachmentInput,attachmentPreviewsContainer:a.attachmentPreviewsContainer,actionsRow:a.actionsRow,leftActions:a.leftActions,rightActions:a.rightActions,setSendButtonMode:a.setSendButtonMode,peekBanner:a.peekBanner,peekTextNode:a.peekTextNode};return{shell:o,panelElements:a,transcript:s,header:c,composer:l,replaceHeader:e=>(c.element.replaceWith(e.header),c.element=e.header,c.iconHolder=e.iconHolder,c.headerTitle=e.headerTitle,c.headerSubtitle=e.headerSubtitle,c.closeButton=e.closeButton,c.closeButtonWrapper=e.closeButtonWrapper,c.clearChatButton=e.clearChatButton,c.clearChatButtonWrapper=e.clearChatButtonWrapper,e),replaceComposer:e=>{l.footer.replaceWith(e),l.footer=e}}},Wc=({config:e,plugins:t,onToggle:n})=>{let r=t.find(e=>e.renderLauncher);if(r?.renderLauncher){let t=r.renderLauncher({config:e,defaultRenderer:()=>Fc(e,n).element,onToggle:n});if(t)return{instance:null,element:t}}let i=Hc(e,n);return{instance:i,element:i.element}},Gc=e=>{let t=e?.persistState;return(typeof t==`object`?t?.keyPrefix:void 0)??`persona-`},Kc=(e,t,n)=>`${Gc(e)}plugin:${t}:${n}`,qc=e=>{let t=/* @__PURE__ */ new Map,n=!1,r=()=>{if(n||e()?.persistState===!1)return null;try{return typeof window>`u`||!window.localStorage?null:window.localStorage}catch{return n=!0,null}};return i=>{let a=t=>Kc(e(),i,t);return{get:e=>{let i=a(e),o=r();if(o)try{return o.getItem(i)}catch{n=!0}return t.get(i)??null},set:(e,i)=>{let o=a(e),s=r();if(s)try{s.setItem(o,i);return}catch{n=!0}t.set(o,i)},remove:e=>{let i=a(e);t.delete(i);let o=r();if(o)try{o.removeItem(i)}catch{n=!0}}}}},{setLoader:Jc,load:Yc,provide:Xc,getSync:Zc}=v({fallbackImport:()=>import(`./chunk-ezlpsYGk.js`)}),Qc=Yc,$c=Zc,{setLoader:el,load:tl}=v({fallbackImport:()=>import(`./chunk-C-EHtpbB.js`)}),nl=tl,rl=[`__proto__`,`prototype`,`constructor`],il=[`collapsed`,`card`,`panel`,`inline`],al=[`markdown`,`component`],ol=/^[a-z0-9][a-z0-9!#$&^_.+-]*\/(\*|[a-z0-9!#$&^_.+-]+)$/,sl=e=>typeof e==`object`&&!!e&&!Array.isArray(e),cl=e=>!rl.includes(e),ll=e=>il.includes(e),ul=e=>Object.keys(e).length>0;function dl(e,t,n,r){e.push({path:t,code:n,message:r})}const fl=`Ignored an unsupported value.`,pl={kind:`mode`},ml={kind:`string`,message:`Expected a CSS length string.`},hl={kind:`boolean`},Q=(...e)=>({kind:`value`,accepts:t=>e.includes(t)}),gl={paneWidth:ml,paneMaxWidth:ml,paneMinWidth:ml,expandedPanelWidth:ml,resizableMinWidth:ml,resizableMaxWidth:ml,expandLauncherPanelWhenOpen:hl,resizable:hl},_l={kind:`object`,message:`Expected a preference object.`,children:{showToolCalls:hl,showReasoning:hl,toolCallDisplay:{kind:`object`,children:{layout:Q(`row`,`card`),collapsedMode:Q(`tool-call`,`tool-name`,`tool-preview`),groupedMode:Q(`stack`,`summary`,`collapsible`),groupAppearance:Q(`plain`,`inset`),groupSummary:Q(`current-action`,`aggregate`),groupBoundary:Q(`adjacent`,`iteration`),groupSummaryMaxItems:{kind:`value`,accepts:e=>Number.isInteger(e)&&e>=0},loadingAnimation:Q(`none`,`pulse`,`shimmer`,`shimmer-color`,`rainbow`),expandable:hl,grouped:hl}},reasoningDisplay:{kind:`object`,children:{layout:Q(`row`,`card`),appearance:Q(`plain`,`inset`,`panel`),expandable:hl,activePreview:hl}},artifacts:{kind:`object`,children:{display:{kind:`object`,bareMode:!0,message:`Expected an artifact display rules object.`,children:{default:pl,files:{kind:`object`,bareMode:!0,message:`Expected collapsed, panel, inline, or a file display rules object.`,children:{default:pl,byMediaType:{kind:`modeMap`,keys:`mediaType`}}},byType:{kind:`modeMap`,keys:al,alias:`byKind`,deprecated:`Use byKind. The legacy selector was normalized automatically.`},byKind:{kind:`modeMap`,keys:al}}},filePreview:{kind:`object`,children:{enabled:hl}},layout:{kind:`object`,children:gl}}}}};function vl(e,t,n,r){if(e!==void 0)switch(t.kind){case`boolean`:return typeof e==`boolean`?e:dl(r,n,`invalid_type`,`Expected a boolean.`);case`string`:return typeof e==`string`?e:dl(r,n,`invalid_type`,t.message);case`value`:return t.accepts(e)?e:dl(r,n,`invalid_value`,fl);case`mode`:return ll(e)?St(e):dl(r,n,`invalid_value`,fl);case`modeMap`:{if(!sl(e))return dl(r,n,`invalid_type`,`Expected an object.`);let i=t.keys===`mediaType`?void 0:t.keys,a={};for(let[t,o]of Object.entries(e)){let e=i?t:M(t);cl(t)&&(i?i.includes(t):ol.test(e))?ll(o)?a[e]=St(o):dl(r,`${n}.${t}`,`invalid_value`,`Expected collapsed, panel, or inline.`):dl(r,`${n}.${t}`,i?`unknown_key`:`invalid_value`,i?`Ignored an unsupported selector.`:`Expected a MIME type such as "text/html" or a wildcard such as "image/*".`)}return ul(a)?a:void 0}case`object`:{if(t.bareMode&&ll(e))return St(e);if(!sl(e))return dl(r,n,`invalid_type`,t.message??`Expected an object.`);let i=Object.keys(t.children),a=e=>n?`${n}.${e}`:e;for(let t of Object.keys(e))(!cl(t)||!i.includes(t))&&dl(r,a(t),`unknown_key`,`Ignored because this key is not part of the persisted preference schema.`);let o={};for(let n of i){let i=t.children[n],s=vl(e[n],i,a(n),r);if(i.deprecated&&e[n]!==void 0&&dl(r,a(n),`deprecated_key`,i.deprecated),s===void 0)continue;let c=i.alias??n,l=o[c];o[c]=sl(l)&&sl(s)?{...l,...s}:s}return ul(o)?o:void 0}}}function yl(e){let t=[];return{preferences:(e===null?void 0:vl(e,_l,``,t))??{},issues:t}}function bl(e){if(Array.isArray(e))return e.map(bl);if(!sl(e))return e;let t={};for(let[n,r]of Object.entries(e))cl(n)&&r!==void 0&&(t[n]=bl(r));return t}function xl(e,t){let n=bl(e);for(let[e,r]of Object.entries(t)){if(!cl(e)||r===void 0)continue;let t=n[e];n[e]=sl(t)&&sl(r)?xl(t,r):bl(r)}return n}function Sl(e){let t={},n;for(let r of e){let e=yl(r).preferences;n=wl(n,e.artifacts?.display),t=xl(t,e)}let r=t;return r.artifacts&&(n===void 0?delete r.artifacts.display:r.artifacts.display=n),r}function Cl(e,t){if(t===void 0)return bl(e);if(typeof t==`string`)return t;let n=typeof e==`string`?{default:e}:e??{},r=t.default??n.default,i={...n.byMediaType,...t.byMediaType},a={...r?{default:r}:{},...ul(i)?{byMediaType:i}:{}};return ul(a)?a:void 0}function wl(e,t){if(t===void 0)return bl(e);if(typeof t==`string`)return t;let n=typeof e==`string`?{default:e}:e??{},r=t.default??n.default,i={...n.byType,...n.byKind,...t.byType,...t.byKind},a=Cl(n.files,t.files),o={...r?{default:r}:{},...ul(i)?{byKind:i}:{},...a===void 0?{}:{files:a}};return ul(o)?o:void 0}function Tl(e={},t){let n=Sl(t),r={...e};for(let e of[`showToolCalls`,`showReasoning`])n[e]!==void 0&&(r[e]=n[e]);for(let t of[`toolCallDisplay`,`reasoningDisplay`])n[t]&&Object.assign(r,{[t]:{...e[t],...n[t]}});if(n.artifacts){let t=e.artifacts??{},i={...t};if(n.artifacts.display!==void 0){let e=wl(t.display,n.artifacts.display);e!==void 0&&(i.display=e)}for(let e of[`filePreview`,`layout`])n.artifacts[e]&&(i[e]={...t[e],...n.artifacts[e]});r.artifacts=i}return r}function El(e){let t=e.preferences;return!t||!ul(t)?e:{...e,features:Tl(e.features??{},[t])}}const{setLoader:Dl,load:Ol,provide:kl,getSync:Al}=v({fallbackImport:()=>import(`./chunk-Bp9uGcpc.js`)}),jl=Ol,Ml=Al,Nl=new class{#e=/* @__PURE__ */ new Map;register(e){this.#e.has(e.id)&&console.warn(`Plugin "${e.id}" is already registered. Overwriting.`),this.#e.set(e.id,e),e.onRegister?.()}unregister(e){let t=this.#e.get(e);t&&(t.onUnregister?.(),this.#e.delete(e))}getAll(){return Array.from(this.#e.values()).sort((e,t)=>(t.priority??0)-(e.priority??0))}getForInstance(e){let t=this.getAll();if(!e||e.length===0)return t;let n=new Set(e.map(e=>e.id));return[...t.filter(e=>!n.has(e.id)),...e].sort((e,t)=>(t.priority??0)-(e.priority??0))}clear(){this.#e.forEach(e=>e.onUnregister?.()),this.#e.clear()}},Pl=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Fl=/* @__PURE__ */ new Set([`headers`,`agent`,`storageAdapter`,`components`,`targetProviders`,`voiceRecognition.provider.custom`,`features.artifacts.display`,`features.streamAnimation.plugins`,`preferences`,`welcome.icon`]),Il=(e,t,n)=>{if(!Pl(e)||!Pl(t)||Fl.has(n))return t;let r={...e};for(let i of Object.keys(t)){if(t[i]===void 0){delete r[i];continue}let a=n?`${n}.${i}`:i;r[i]=Il(e[i],t[i],a)}return r};function Ll(e,t){let r=g(de),i=h(e,t,r),s=a(o(Il(e,t,``),r,i),i);return n(s,c(e,t)),rn(ve(s),an(e,t))}const{setLoader:Rl,load:zl,provide:Bl,getSync:Vl}=v({fallbackImport:()=>import(`./chunk-Cb_AH55z.js`)}),Hl=zl,Ul=Vl,Wl=[...p,`launcherWidth`,`suggestionChips`,`copy.welcomeTitle`,`copy.welcomeSubtitle`,`copy.showWelcomeCard`,`features.suggestReplies.enabled`,`features.suggestReplies.expose`],Gl=e=>{if(!e.debug)return;let t=Ul();if(!t)Hl().then(()=>Gl(e),()=>{});else for(let n of e.current)n in t.LEGACY_MIGRATIONS&&(e.warned.has(n)||(console.warn(`[persona] ${n} is a supported legacy alias. Prefer ${t.LEGACY_MIGRATIONS[n]}. Compatibility behavior remains supported; clear the old field with an own undefined update when migrating.`),e.warned.add(n)))},Kl=e=>{let t={warned:/* @__PURE__ */ new Set,current:new Set(Wl.filter(t=>s(e,t))),debug:e?.debug===!0};return Gl(t),t},ql=(t,n)=>{if(u(n))t.current=new Set(Wl.filter(e=>s(n,e)));else for(let r of Wl){let i=e(n,r);i===`clear`&&t.current.delete(r),i===`explicit`&&t.current.add(r)}Object.prototype.hasOwnProperty.call(n,`debug`)&&(t.debug=n.debug===!0),Gl(t)},Jl=(e={instanceId:``})=>{let t=!1,n=/* @__PURE__ */ new Map,r=(e,r)=>t?()=>{}:(n.has(e)||n.set(e,/* @__PURE__ */ new Set),n.get(e).add(r),()=>i(e,r)),i=(e,t)=>{n.get(e)?.delete(t)};return{on:r,off:i,emit:(t,r)=>{n.get(t)?.forEach(t=>{try{t(r,e)}catch(e){typeof console<`u`&&console.error(`[AgentWidget] Event handler error:`,e)}})},dispose:()=>{t=!0,n.clear()}}},Yl=e=>{let t=e.match(/```(?:json)?\s*([\s\S]*?)```/i);return t?t[1]:e},Xl=e=>{let t=e.trim(),n=t.indexOf(`{`);if(n===-1)return null;let r=0;for(let e=n;e<t.length;e+=1){let i=t[e];if(i===`{`&&(r+=1),i===`}`&&(--r,r===0))return t.slice(n,e+1)}return null},Zl=({text:e})=>{if(!e||!e.includes(`{`))return null;try{let t=Yl(e),n=Xl(t);if(!n)return null;let r=JSON.parse(n);if(!r||typeof r!=`object`||!r.action)return null;let{action:i,...a}=r;return{type:String(i),payload:a,raw:r}}catch{return null}},Ql=e=>typeof e==`string`?e:e==null?``:String(e),$l={message:e=>{if(e.type===`message`)return{handled:!0,displayText:Ql(e.payload.text)}},messageAndClick:(e,t)=>{if(e.type!==`message_and_click`)return;let n=e.payload,r=Ql(n.element);if(r&&t.document?.querySelector){let e=t.document.querySelector(r);e?setTimeout(()=>{e.click()},400):typeof console<`u`&&console.warn(`[AgentWidget] Element not found for selector:`,r)}return{handled:!0,displayText:Ql(n.text)}}},eu=e=>Array.isArray(e)?e.map(e=>String(e)):[],tu=e=>{let t=new Set(eu(e.getSessionMetadata().processedActionMessageIds)),n=()=>{t=new Set(eu(e.getSessionMetadata().processedActionMessageIds))},r=()=>{let n=Array.from(t);e.updateSessionMetadata(e=>({...e,processedActionMessageIds:n}))};return{process:n=>{if(n.streaming||n.message.role!==`assistant`||!n.text||t.has(n.message.id))return null;let i=typeof n.raw==`string`&&n.raw||typeof n.message.rawContent==`string`&&n.message.rawContent||typeof n.text==`string`&&n.text||null;!i&&typeof n.text==`string`&&n.text.trim().startsWith(`{`)&&typeof console<`u`&&console.warn(`[AgentWidget] Structured response detected but no raw payload was provided. Ensure your stream parser returns { text, raw }.`);let a=i?e.parsers.reduce((e,t)=>e||t?.({text:i,message:n.message})||null,null):null;if(!a)return null;t.add(n.message.id),r();let o={action:a,message:n.message};e.emit(`action:detected`,o);for(let t of e.handlers)if(t)try{let r=e.captureResubmitGuard?.(),i=t(a,{message:n.message,metadata:e.getSessionMetadata(),updateMetadata:e.updateSessionMetadata,document:e.documentRef,triggerResubmit:()=>{(!r||r())&&e.emit(`action:resubmit`,o)}});if(!i)continue;if(i.handled){let e=i.persistMessage!==!1;return{text:i.displayText===void 0?``:i.displayText,persist:e,resubmit:i.resubmit}}}catch(e){typeof console<`u`&&console.error(`[AgentWidget] Action handler error:`,e)}return{text:``,persist:!0}},syncFromMetadata:n}},nu=e=>{if(!e)return null;try{return JSON.parse(e)}catch(e){return typeof console<`u`&&console.error(`[AgentWidget] Failed to parse stored state:`,e),null}},ru=e=>e.map(e=>({...e,streaming:!1})),iu=e=>e.map(e=>({...e,status:`complete`})),au=e=>`${e??`persona-`}state`,ou=(e=au())=>{let t=()=>typeof window>`u`||!window.localStorage?null:window.localStorage;return{load:()=>{let n=t();return n?nu(n.getItem(e)):null},save:n=>{let r=t();if(r)try{let t={...n,messages:n.messages?ru(n.messages):void 0,artifacts:n.artifacts?iu(n.artifacts):void 0};r.setItem(e,JSON.stringify(t))}catch(e){typeof console<`u`&&console.error(`[AgentWidget] Failed to persist state:`,e)}},clear:()=>{let n=t();if(n)try{n.removeItem(e)}catch(e){typeof console<`u`&&console.error(`[AgentWidget] Failed to clear stored state:`,e)}}}},su=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t.toString(16).padStart(8,`0`)},cu=async e=>{let t=globalThis.crypto?.subtle;if(t)try{let n=await t.digest(`SHA-256`,new TextEncoder().encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}catch{}return su(e)},lu=async(e,t)=>{let n=await cu(e);return{storageKey:`${t}visitor:${n}`,leaseKey:`${t}visitor-init-lock:${n}`,lockName:`persona-visitor-init:${await cu(`${e}\0${t}`)}`}},uu=(e,t,n)=>{let r=``,i=``,a=``,o=!1,s=!1,c=0,l=null,u=null,d=/* @__PURE__ */ new Set,f=()=>{if(n||o)return null;try{return typeof window>`u`||!window.localStorage?null:window.localStorage}catch{return o=!0,null}},p=()=>{let e=f();if(!e)return l;try{return e.getItem(r)}catch{return o=!0,l}},m=(e,t)=>{if(s||e===l)return;let n=l;l=e,c+=1;let r={previousToken:n,token:e,source:t,revision:c};for(let e of d)e(r)},h=e=>{s||(e.key===null||e.key===r)&&m(e.key===null?null:e.newValue??null,`external`)},g=(async()=>{let o=await lu(e,t);r=o.storageKey,i=o.leaseKey,a=o.lockName,l=p(),!n&&typeof window<`u`&&window.addEventListener(`storage`,h)})(),_=e=>new Promise(t=>setTimeout(t,e)),v=()=>{let e=f();if(!e)return null;try{let t=e.getItem(i);if(!t)return null;let n=JSON.parse(t);return typeof n?.expiresAt==`number`&&typeof n?.ownerNonce==`string`?n:null}catch{return null}},y=e=>{let t=f();if(t)try{v()?.ownerNonce===e&&t.removeItem(i)}catch{}},b=/* @__PURE__ */ new Set,x=e=>s?Promise.reject(/* @__PURE__ */ Error(`Visitor store destroyed before its first init could start`)):e(),S=e=>new Promise(t=>{let n=setTimeout(r,e);function r(){clearTimeout(n),b.delete(r),window.removeEventListener(`storage`,a),t()}function a(e){(e.key===null||e.key===i)&&r()}b.add(r),window.addEventListener(`storage`,a)}),C=async e=>{let t=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,n=Date.now()+15e3;for(;!s&&Date.now()<n;){let n=f();if(!n)break;let r=Date.now(),a=v();if(a&&a.expiresAt>r&&a.ownerNonce!==t)await S(Math.min(a.expiresAt-r,500));else{try{n.setItem(i,JSON.stringify({ownerNonce:t,expiresAt:r+1e4}))}catch{o=!0;break}if(await _(20+Math.random()*40),v()?.ownerNonce!==t)await S(500);else{u=t;try{return await x(e)}finally{u=null,y(t)}}}}return x(e)};return{ready:g,async get(){return await g,m(p(),`external`),l},async set(e){await g;let t=f();if(t)try{t.setItem(r,e)}catch{o=!0}m(e,`local`)},async clear(){await g;let e=f();if(e)try{e.removeItem(r)}catch{o=!0}m(null,`local`)},revision(){return c},subscribe(e){return d.add(e),()=>{d.delete(e)}},async withFirstInitLock(e){await g;let t=globalThis.navigator?.locks;return t?.request?t.request(a,()=>x(e)):f()?C(e):x(e)},matches(r,i,a){return r===e&&i===t&&a===n},destroy(){s=!0,d.clear(),typeof window<`u`&&window.removeEventListener(`storage`,h),u&&y(u);for(let e of[...b])e()}}},{setLoader:du,load:fu}=v({fallbackImport:()=>import(`./chunk-6C23QQdP.js`)}),pu=fu,{setLoader:mu,load:hu,provide:gu,getSync:_u}=v({fallbackImport:()=>import(`./chunk-2FnmZ9AA.js`)}),vu=hu,yu=_u;function bu(){return null}const xu=[`Very dissatisfied`,`Dissatisfied`,`Neutral`,`Satisfied`,`Very satisfied`];function Su(e,t,n){let{onSubmit:r,onDismiss:i,title:a=t===`csat`?`How satisfied are you?`:`How likely are you to recommend us?`,subtitle:o=t===`csat`?`Please rate your experience`:`On a scale of 0 to 10`,commentPlaceholder:s=t===`csat`?`Share your thoughts (optional)...`:`What could we do better? (optional)...`,submitText:c=`Submit`,skipText:l=`Skip`,showComment:u=!0}=e,d=document.createElement(`div`);d.className=`persona-feedback-container persona-feedback-${t}`,d.setAttribute(`role`,`dialog`),d.setAttribute(`aria-label`,t===`csat`?`Customer satisfaction feedback`:`Net Promoter Score feedback`);let f=null,p=document.createElement(`div`);p.className=`persona-feedback-content`;let m=document.createElement(`div`);m.className=`persona-feedback-header`;let h=document.createElement(`h3`);h.className=`persona-feedback-title`,h.textContent=a,m.appendChild(h);let g=document.createElement(`p`);g.className=`persona-feedback-subtitle`,g.textContent=o,m.appendChild(g),p.appendChild(m);let{element:_,attentionTarget:v}=n(e=>{f=e});p.appendChild(_);let y=null;if(u){let e=document.createElement(`div`);e.className=`persona-feedback-comment-container`,y=document.createElement(`textarea`),y.className=`persona-feedback-comment`,y.placeholder=s,y.rows=3,y.setAttribute(`aria-label`,`Additional comments`),e.appendChild(y),p.appendChild(e)}let b=document.createElement(`div`);b.className=`persona-feedback-actions`;let x=document.createElement(`button`);x.type=`button`,x.className=`persona-feedback-btn persona-feedback-btn-skip`,x.textContent=l,x.addEventListener(`click`,()=>{i?.(),d.remove()});let S=document.createElement(`button`);return S.type=`button`,S.className=`persona-feedback-btn persona-feedback-btn-submit`,S.textContent=c,S.addEventListener(`click`,async()=>{if(f===null)v.classList.add(`persona-feedback-shake`),setTimeout(()=>v.classList.remove(`persona-feedback-shake`),500);else{S.disabled=!0,S.textContent=`Submitting...`;try{let e=y?.value.trim()||void 0;await r(f,e),d.remove()}catch(e){S.disabled=!1,S.textContent=c,console.error(`[${t.toUpperCase()} Feedback] Failed to submit:`,e)}}}),b.appendChild(x),b.appendChild(S),p.appendChild(b),d.appendChild(p),d}function Cu(e){return Su(e,`csat`,t=>{let{ratingLabels:n=xu}=e,r=document.createElement(`div`);r.className=`persona-feedback-rating persona-feedback-rating-csat`,r.setAttribute(`role`,`radiogroup`),r.setAttribute(`aria-label`,`Satisfaction rating from 1 to 5`);let i=[];for(let e=1;e<=5;e++){let a=document.createElement(`button`);a.type=`button`,a.className=`persona-feedback-rating-btn persona-feedback-star-btn`,a.setAttribute(`role`,`radio`),a.setAttribute(`aria-checked`,`false`),a.setAttribute(`aria-label`,`${e} star${e>1?`s`:``}: ${n[e-1]}`),a.title=n[e-1],a.dataset.rating=String(e),a.innerHTML=`
|
|
18
|
+
`,n.addEventListener(`click`,t);let r=e=>{let t=e.launcher??{},r=$o(e),i=xa(e)===`circle`;i?(n.dataset.personaLauncherVariant=`circle`,n.setAttribute(`aria-label`,t.title??`Open chat`)):(n.removeAttribute(`data-persona-launcher-variant`),n.removeAttribute(`aria-label`));let a=n.querySelector(`[data-role='launcher-title']`);if(a){let e=t.title??`Chat Assistant`;a.textContent=e,a.setAttribute(`title`,e)}let o=n.querySelector(`[data-role='launcher-subtitle']`);if(o){let e=t.subtitle??`Here to help you get answers fast`;o.textContent=e,o.setAttribute(`title`,e)}let s=n.querySelector(`.persona-flex-col`);s&&(t.textHidden||r||i?s.style.display=`none`:s.style.display=``);let c=n.querySelector(`[data-role='launcher-icon']`);if(c){if(t.agentIconHidden)c.style.display=`none`;else{let e=t.agentIconSize??`40px`;if(c.style.height=e,c.style.width=e,t.agentIconBackgroundColor?(c.style.backgroundColor=t.agentIconBackgroundColor,c.classList.remove(`persona-bg-persona-primary`)):(c.style.backgroundColor=``,c.classList.add(`persona-bg-persona-primary`)),c.innerHTML=``,t.agentIconName){let n=parseFloat(e)||24,r=T(t.agentIconName,n*.6,`var(--persona-text-inverse, #ffffff)`,1.5);r?(c.appendChild(r),c.style.display=``):(c.textContent=t.agentIconText??`💬`,c.style.display=``)}else t.iconUrl?c.style.display=`none`:(c.textContent=t.agentIconText??`💬`,c.style.display=``)}}let l=n.querySelector(`[data-role='launcher-image']`);if(l){let e=t.agentIconSize??`40px`;l.style.height=e,l.style.width=e,t.iconUrl&&!t.agentIconName&&!t.agentIconHidden?(l.src=t.iconUrl,l.style.display=`block`):l.style.display=`none`}let u=n.querySelector(`[data-role='launcher-call-to-action-icon']`);if(u){let e=t.callToActionIconSize??`32px`;u.style.height=e,u.style.width=e,t.callToActionIconBackgroundColor?(u.style.backgroundColor=t.callToActionIconBackgroundColor,u.classList.remove(`persona-bg-persona-primary`)):(u.style.backgroundColor=``,u.classList.add(`persona-bg-persona-primary`)),t.callToActionIconColor?(u.style.color=t.callToActionIconColor,u.classList.remove(`persona-text-persona-call-to-action`)):(u.style.color=``,u.classList.add(`persona-text-persona-call-to-action`));let n=0;if(t.callToActionIconPadding?(u.style.boxSizing=`border-box`,u.style.padding=t.callToActionIconPadding,n=(parseFloat(t.callToActionIconPadding)||0)*2):(u.style.boxSizing=``,u.style.padding=``),t.callToActionIconHidden||i)u.style.display=`none`;else if(u.style.display=r?`none`:``,u.innerHTML=``,t.callToActionIconName){let r=Math.max((parseFloat(e)||24)-n,8),i=T(t.callToActionIconName,r,`currentColor`,1.5);i?u.appendChild(i):u.textContent=t.callToActionIconText??`↗`}else u.textContent=t.callToActionIconText??`↗`}let d=t.position&&us[t.position]?us[t.position]:us[`bottom-right`];n.className=r?`persona-relative persona-mt-4 persona-mb-4 persona-mx-auto persona-flex persona-items-center persona-justify-center persona-rounded-launcher persona-bg-persona-launcher persona-transition hover:persona-translate-y-[-2px] persona-cursor-pointer`:`persona-fixed persona-flex persona-items-center persona-gap-3 persona-rounded-launcher persona-bg-persona-launcher persona-py-2.5 persona-pl-3 persona-pr-3 persona-transition hover:persona-translate-y-[-2px] persona-cursor-pointer ${d}`,r||(n.style.zIndex=String(t.zIndex??1e5)),n.style.border=t.border??`1px solid var(--persona-launcher-border, var(--persona-border, #e5e7eb))`,n.style.boxShadow=t.shadow===void 0?`var(--persona-launcher-shadow, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1))`:t.shadow.trim()===``?`none`:t.shadow,r?(n.style.width=`0`,n.style.minWidth=`0`,n.style.maxWidth=`0`,n.style.padding=`0`,n.style.overflow=`hidden`,n.style.border=`none`,n.style.boxShadow=`none`):(n.style.width=``,n.style.minWidth=``,n.style.maxWidth=t.collapsedMaxWidth??``,n.style.justifyContent=``,n.style.padding=``,n.style.overflow=``)};return e&&r(e),{element:n,update:r,destroy:()=>{n.removeEventListener(`click`,t),n.remove()}}},Ic=/* @__PURE__ */ new Set,Lc=e=>{let t=e?.persistState;return`${(typeof t==`object`?t?.keyPrefix:void 0)??`persona-`}teaser-dismissed`},Rc=(e,t)=>{if(Ic.has(e))return!0;if(!t)return!1;try{return window.localStorage.getItem(e)===`1`}catch{return!1}},zc=(e,t)=>{if(Ic.add(e),t)try{window.localStorage.setItem(e,`1`)}catch{}},Bc=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,Vc=e=>{let t=e?.launcher?.teaser;return!t||!t.text||e?.launcher?.enabled===!1||$o(e??{})?null:t},Hc=(e,t)=>{let n=k(`div`,`persona-launcher-surface`);n.setAttribute(`data-persona-launcher-surface`,`true`);let r=e??{},i=null,a=null,o=null,s=null,c=null,l=!1,u=!1,d=!1,f=!1,p=()=>(i?.frequency??`once`)===`once`&&r.persistState!==!1,m=()=>{c!==null&&(clearTimeout(c),c=null)},h=()=>{a&&l&&(l=!1,a.hidden=!0)},g=e=>{m(),d=!0,h(),zc(Lc(r),e&&p())},_=e=>{i&&!d&&g(e===`user`&&l)},v=()=>{c=null,!(!a||d||f)&&(u=!0,l=!0,a.hidden=!1,!(Bc()||typeof a.animate!=`function`)&&a.animate([{opacity:`0`,transform:`translateY(6px)`},{opacity:`1`,transform:`none`}],{duration:220,easing:`ease-out`,fill:`backwards`}))},y=()=>{i&&a&&(d||u||f||Rc(Lc(r),p())||(m(),c=setTimeout(v,Math.max(0,i.delayMs??0))))},b=()=>{g(p()),t()},x=e=>{e.stopPropagation(),g(p())},S=Fc(e,()=>{_(`user`),t()}),C=()=>{m(),s?.removeEventListener(`click`,b),o?.removeEventListener(`click`,x),a?.remove(),a=null,s=null,o=null,l=!1},ee=()=>{s=O(`button`,{className:`persona-launcher-teaser-text`,attrs:{type:`button`}}),s.addEventListener(`click`,b),o=O(`button`,{className:`persona-launcher-teaser-dismiss`,attrs:{type:`button`},text:`×`}),o.addEventListener(`click`,x),a=O(`div`,{className:`persona-launcher-teaser`,attrs:{"data-persona-launcher-teaser":`true`,role:`status`,"aria-live":`polite`,hidden:``}},s,o),n.insertBefore(a,S.element)},w=()=>{let e=r.launcher?.position??`bottom-right`,t=us[e]??us[`bottom-right`];a?(n.className=We(`persona-launcher-surface`,t),n.setAttribute(`data-teaser`,e),n.style.zIndex=String(r.launcher?.zIndex??1e5),S.element.style.position=`static`):(n.className=`persona-launcher-surface`,n.removeAttribute(`data-teaser`),n.style.zIndex=``,S.element.style.position=``)},T=e=>{let t=Vc(e);i=t,t?(a||ee(),s.textContent=t.text,o.hidden=t.dismissible===!1,o.setAttribute(`aria-label`,t.dismissLabel??`Dismiss message`),y()):C()};return n.appendChild(S.element),e&&(T(e),w()),{element:n,launcher:S,get teaser(){return a?{element:a,show:v,dismiss:g}:null},setPanelOpen:(e,t=`user`)=>{f=e,e&&_(t)},update:e=>{r=e,S.update(e),T(e),w()},destroy:()=>{C(),S.destroy(),n.remove()}}},Uc=({config:e,showClose:t})=>{let{wrapper:n,panel:r,pillRoot:i}=Ac(e),a=Pc(e,t),o={wrapper:n,panel:r,pillRoot:i},s={container:a.container,body:a.body,messagesWrapper:a.messagesWrapper,starterSuggestions:a.starterSuggestions,transcriptSuggestions:a.transcriptSuggestions,composerOverlay:a.composerOverlay,welcomeHost:a.welcomeHost,welcomeIconHolder:a.welcomeIconHolder,greetingHost:a.greetingHost,introTitle:a.introTitle,introSubtitle:a.introSubtitle},c={element:a.header,iconHolder:a.iconHolder,headerTitle:a.headerTitle,headerSubtitle:a.headerSubtitle,closeButton:a.closeButton,closeButtonWrapper:a.closeButtonWrapper,clearChatButton:a.clearChatButton,clearChatButtonWrapper:a.clearChatButtonWrapper},l={footer:a.footer,form:a.composerForm,textarea:a.textarea,sendButton:a.sendButton,sendButtonWrapper:a.sendButtonWrapper,micButton:a.micButton,micButtonWrapper:a.micButtonWrapper,statusText:a.statusText,suggestions:a.suggestions,attachmentButton:a.attachmentButton,attachmentButtonWrapper:a.attachmentButtonWrapper,attachmentInput:a.attachmentInput,attachmentPreviewsContainer:a.attachmentPreviewsContainer,actionsRow:a.actionsRow,leftActions:a.leftActions,rightActions:a.rightActions,setSendButtonMode:a.setSendButtonMode,peekBanner:a.peekBanner,peekTextNode:a.peekTextNode};return{shell:o,panelElements:a,transcript:s,header:c,composer:l,replaceHeader:e=>(c.element.replaceWith(e.header),c.element=e.header,c.iconHolder=e.iconHolder,c.headerTitle=e.headerTitle,c.headerSubtitle=e.headerSubtitle,c.closeButton=e.closeButton,c.closeButtonWrapper=e.closeButtonWrapper,c.clearChatButton=e.clearChatButton,c.clearChatButtonWrapper=e.clearChatButtonWrapper,e),replaceComposer:e=>{l.footer.replaceWith(e),l.footer=e}}},Wc=({config:e,plugins:t,onToggle:n})=>{let r=t.find(e=>e.renderLauncher);if(r?.renderLauncher){let t=r.renderLauncher({config:e,defaultRenderer:()=>Fc(e,n).element,onToggle:n});if(t)return{instance:null,element:t}}let i=Hc(e,n);return{instance:i,element:i.element}},Gc=e=>{let t=e?.persistState;return(typeof t==`object`?t?.keyPrefix:void 0)??`persona-`},Kc=(e,t,n)=>`${Gc(e)}plugin:${t}:${n}`,qc=e=>{let t=/* @__PURE__ */ new Map,n=!1,r=()=>{if(n||e()?.persistState===!1)return null;try{return typeof window>`u`||!window.localStorage?null:window.localStorage}catch{return n=!0,null}};return i=>{let a=t=>Kc(e(),i,t);return{get:e=>{let i=a(e),o=r();if(o)try{return o.getItem(i)}catch{n=!0}return t.get(i)??null},set:(e,i)=>{let o=a(e),s=r();if(s)try{s.setItem(o,i);return}catch{n=!0}t.set(o,i)},remove:e=>{let i=a(e);t.delete(i);let o=r();if(o)try{o.removeItem(i)}catch{n=!0}}}}},{setLoader:Jc,load:Yc,provide:Xc,getSync:Zc}=v({fallbackImport:()=>import(`./chunk-DVZ8ri1z.js`)}),Qc=Yc,$c=Zc,{setLoader:el,load:tl}=v({fallbackImport:()=>import(`./chunk-C-EHtpbB.js`)}),nl=tl,rl=[`__proto__`,`prototype`,`constructor`],il=[`collapsed`,`card`,`panel`,`inline`],al=[`markdown`,`component`],ol=/^[a-z0-9][a-z0-9!#$&^_.+-]*\/(\*|[a-z0-9!#$&^_.+-]+)$/,sl=e=>typeof e==`object`&&!!e&&!Array.isArray(e),cl=e=>!rl.includes(e),ll=e=>il.includes(e),ul=e=>Object.keys(e).length>0;function dl(e,t,n,r){e.push({path:t,code:n,message:r})}const fl=`Ignored an unsupported value.`,pl={kind:`mode`},ml={kind:`string`,message:`Expected a CSS length string.`},hl={kind:`boolean`},Q=(...e)=>({kind:`value`,accepts:t=>e.includes(t)}),gl={paneWidth:ml,paneMaxWidth:ml,paneMinWidth:ml,expandedPanelWidth:ml,resizableMinWidth:ml,resizableMaxWidth:ml,expandLauncherPanelWhenOpen:hl,resizable:hl},_l={kind:`object`,message:`Expected a preference object.`,children:{showToolCalls:hl,showReasoning:hl,toolCallDisplay:{kind:`object`,children:{layout:Q(`row`,`card`),collapsedMode:Q(`tool-call`,`tool-name`,`tool-preview`),groupedMode:Q(`stack`,`summary`,`collapsible`),groupAppearance:Q(`plain`,`inset`),groupSummary:Q(`current-action`,`aggregate`),groupBoundary:Q(`adjacent`,`iteration`),groupSummaryMaxItems:{kind:`value`,accepts:e=>Number.isInteger(e)&&e>=0},loadingAnimation:Q(`none`,`pulse`,`shimmer`,`shimmer-color`,`rainbow`),expandable:hl,grouped:hl}},reasoningDisplay:{kind:`object`,children:{layout:Q(`row`,`card`),appearance:Q(`plain`,`inset`,`panel`),expandable:hl,activePreview:hl}},artifacts:{kind:`object`,children:{display:{kind:`object`,bareMode:!0,message:`Expected an artifact display rules object.`,children:{default:pl,files:{kind:`object`,bareMode:!0,message:`Expected collapsed, panel, inline, or a file display rules object.`,children:{default:pl,byMediaType:{kind:`modeMap`,keys:`mediaType`}}},byType:{kind:`modeMap`,keys:al,alias:`byKind`,deprecated:`Use byKind. The legacy selector was normalized automatically.`},byKind:{kind:`modeMap`,keys:al}}},filePreview:{kind:`object`,children:{enabled:hl}},layout:{kind:`object`,children:gl}}}}};function vl(e,t,n,r){if(e!==void 0)switch(t.kind){case`boolean`:return typeof e==`boolean`?e:dl(r,n,`invalid_type`,`Expected a boolean.`);case`string`:return typeof e==`string`?e:dl(r,n,`invalid_type`,t.message);case`value`:return t.accepts(e)?e:dl(r,n,`invalid_value`,fl);case`mode`:return ll(e)?St(e):dl(r,n,`invalid_value`,fl);case`modeMap`:{if(!sl(e))return dl(r,n,`invalid_type`,`Expected an object.`);let i=t.keys===`mediaType`?void 0:t.keys,a={};for(let[t,o]of Object.entries(e)){let e=i?t:M(t);cl(t)&&(i?i.includes(t):ol.test(e))?ll(o)?a[e]=St(o):dl(r,`${n}.${t}`,`invalid_value`,`Expected collapsed, panel, or inline.`):dl(r,`${n}.${t}`,i?`unknown_key`:`invalid_value`,i?`Ignored an unsupported selector.`:`Expected a MIME type such as "text/html" or a wildcard such as "image/*".`)}return ul(a)?a:void 0}case`object`:{if(t.bareMode&&ll(e))return St(e);if(!sl(e))return dl(r,n,`invalid_type`,t.message??`Expected an object.`);let i=Object.keys(t.children),a=e=>n?`${n}.${e}`:e;for(let t of Object.keys(e))(!cl(t)||!i.includes(t))&&dl(r,a(t),`unknown_key`,`Ignored because this key is not part of the persisted preference schema.`);let o={};for(let n of i){let i=t.children[n],s=vl(e[n],i,a(n),r);if(i.deprecated&&e[n]!==void 0&&dl(r,a(n),`deprecated_key`,i.deprecated),s===void 0)continue;let c=i.alias??n,l=o[c];o[c]=sl(l)&&sl(s)?{...l,...s}:s}return ul(o)?o:void 0}}}function yl(e){let t=[];return{preferences:(e===null?void 0:vl(e,_l,``,t))??{},issues:t}}function bl(e){if(Array.isArray(e))return e.map(bl);if(!sl(e))return e;let t={};for(let[n,r]of Object.entries(e))cl(n)&&r!==void 0&&(t[n]=bl(r));return t}function xl(e,t){let n=bl(e);for(let[e,r]of Object.entries(t)){if(!cl(e)||r===void 0)continue;let t=n[e];n[e]=sl(t)&&sl(r)?xl(t,r):bl(r)}return n}function Sl(e){let t={},n;for(let r of e){let e=yl(r).preferences;n=wl(n,e.artifacts?.display),t=xl(t,e)}let r=t;return r.artifacts&&(n===void 0?delete r.artifacts.display:r.artifacts.display=n),r}function Cl(e,t){if(t===void 0)return bl(e);if(typeof t==`string`)return t;let n=typeof e==`string`?{default:e}:e??{},r=t.default??n.default,i={...n.byMediaType,...t.byMediaType},a={...r?{default:r}:{},...ul(i)?{byMediaType:i}:{}};return ul(a)?a:void 0}function wl(e,t){if(t===void 0)return bl(e);if(typeof t==`string`)return t;let n=typeof e==`string`?{default:e}:e??{},r=t.default??n.default,i={...n.byType,...n.byKind,...t.byType,...t.byKind},a=Cl(n.files,t.files),o={...r?{default:r}:{},...ul(i)?{byKind:i}:{},...a===void 0?{}:{files:a}};return ul(o)?o:void 0}function Tl(e={},t){let n=Sl(t),r={...e};for(let e of[`showToolCalls`,`showReasoning`])n[e]!==void 0&&(r[e]=n[e]);for(let t of[`toolCallDisplay`,`reasoningDisplay`])n[t]&&Object.assign(r,{[t]:{...e[t],...n[t]}});if(n.artifacts){let t=e.artifacts??{},i={...t};if(n.artifacts.display!==void 0){let e=wl(t.display,n.artifacts.display);e!==void 0&&(i.display=e)}for(let e of[`filePreview`,`layout`])n.artifacts[e]&&(i[e]={...t[e],...n.artifacts[e]});r.artifacts=i}return r}function El(e){let t=e.preferences;return!t||!ul(t)?e:{...e,features:Tl(e.features??{},[t])}}const{setLoader:Dl,load:Ol,provide:kl,getSync:Al}=v({fallbackImport:()=>import(`./chunk-Bp9uGcpc.js`)}),jl=Ol,Ml=Al,Nl=new class{#e=/* @__PURE__ */ new Map;register(e){this.#e.has(e.id)&&console.warn(`Plugin "${e.id}" is already registered. Overwriting.`),this.#e.set(e.id,e),e.onRegister?.()}unregister(e){let t=this.#e.get(e);t&&(t.onUnregister?.(),this.#e.delete(e))}getAll(){return Array.from(this.#e.values()).sort((e,t)=>(t.priority??0)-(e.priority??0))}getForInstance(e){let t=this.getAll();if(!e||e.length===0)return t;let n=new Set(e.map(e=>e.id));return[...t.filter(e=>!n.has(e.id)),...e].sort((e,t)=>(t.priority??0)-(e.priority??0))}clear(){this.#e.forEach(e=>e.onUnregister?.()),this.#e.clear()}},Pl=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Fl=/* @__PURE__ */ new Set([`headers`,`agent`,`storageAdapter`,`components`,`targetProviders`,`voiceRecognition.provider.custom`,`features.artifacts.display`,`features.streamAnimation.plugins`,`preferences`,`welcome.icon`]),Il=(e,t,n)=>{if(!Pl(e)||!Pl(t)||Fl.has(n))return t;let r={...e};for(let i of Object.keys(t)){if(t[i]===void 0){delete r[i];continue}let a=n?`${n}.${i}`:i;r[i]=Il(e[i],t[i],a)}return r};function Ll(e,t){let r=g(de),i=h(e,t,r),s=a(o(Il(e,t,``),r,i),i);return n(s,c(e,t)),rn(ve(s),an(e,t))}const{setLoader:Rl,load:zl,provide:Bl,getSync:Vl}=v({fallbackImport:()=>import(`./chunk-Cb_AH55z.js`)}),Hl=zl,Ul=Vl,Wl=[...p,`launcherWidth`,`suggestionChips`,`copy.welcomeTitle`,`copy.welcomeSubtitle`,`copy.showWelcomeCard`,`features.suggestReplies.enabled`,`features.suggestReplies.expose`],Gl=e=>{if(!e.debug)return;let t=Ul();if(!t)Hl().then(()=>Gl(e),()=>{});else for(let n of e.current)n in t.LEGACY_MIGRATIONS&&(e.warned.has(n)||(console.warn(`[persona] ${n} is a supported legacy alias. Prefer ${t.LEGACY_MIGRATIONS[n]}. Compatibility behavior remains supported; clear the old field with an own undefined update when migrating.`),e.warned.add(n)))},Kl=e=>{let t={warned:/* @__PURE__ */ new Set,current:new Set(Wl.filter(t=>s(e,t))),debug:e?.debug===!0};return Gl(t),t},ql=(t,n)=>{if(u(n))t.current=new Set(Wl.filter(e=>s(n,e)));else for(let r of Wl){let i=e(n,r);i===`clear`&&t.current.delete(r),i===`explicit`&&t.current.add(r)}Object.prototype.hasOwnProperty.call(n,`debug`)&&(t.debug=n.debug===!0),Gl(t)},Jl=(e={instanceId:``})=>{let t=!1,n=/* @__PURE__ */ new Map,r=(e,r)=>t?()=>{}:(n.has(e)||n.set(e,/* @__PURE__ */ new Set),n.get(e).add(r),()=>i(e,r)),i=(e,t)=>{n.get(e)?.delete(t)};return{on:r,off:i,emit:(t,r)=>{n.get(t)?.forEach(t=>{try{t(r,e)}catch(e){typeof console<`u`&&console.error(`[AgentWidget] Event handler error:`,e)}})},dispose:()=>{t=!0,n.clear()}}},Yl=e=>{let t=e.match(/```(?:json)?\s*([\s\S]*?)```/i);return t?t[1]:e},Xl=e=>{let t=e.trim(),n=t.indexOf(`{`);if(n===-1)return null;let r=0;for(let e=n;e<t.length;e+=1){let i=t[e];if(i===`{`&&(r+=1),i===`}`&&(--r,r===0))return t.slice(n,e+1)}return null},Zl=({text:e})=>{if(!e||!e.includes(`{`))return null;try{let t=Yl(e),n=Xl(t);if(!n)return null;let r=JSON.parse(n);if(!r||typeof r!=`object`||!r.action)return null;let{action:i,...a}=r;return{type:String(i),payload:a,raw:r}}catch{return null}},Ql=e=>typeof e==`string`?e:e==null?``:String(e),$l={message:e=>{if(e.type===`message`)return{handled:!0,displayText:Ql(e.payload.text)}},messageAndClick:(e,t)=>{if(e.type!==`message_and_click`)return;let n=e.payload,r=Ql(n.element);if(r&&t.document?.querySelector){let e=t.document.querySelector(r);e?setTimeout(()=>{e.click()},400):typeof console<`u`&&console.warn(`[AgentWidget] Element not found for selector:`,r)}return{handled:!0,displayText:Ql(n.text)}}},eu=e=>Array.isArray(e)?e.map(e=>String(e)):[],tu=e=>{let t=new Set(eu(e.getSessionMetadata().processedActionMessageIds)),n=()=>{t=new Set(eu(e.getSessionMetadata().processedActionMessageIds))},r=()=>{let n=Array.from(t);e.updateSessionMetadata(e=>({...e,processedActionMessageIds:n}))};return{process:n=>{if(n.streaming||n.message.role!==`assistant`||!n.text||t.has(n.message.id))return null;let i=typeof n.raw==`string`&&n.raw||typeof n.message.rawContent==`string`&&n.message.rawContent||typeof n.text==`string`&&n.text||null;!i&&typeof n.text==`string`&&n.text.trim().startsWith(`{`)&&typeof console<`u`&&console.warn(`[AgentWidget] Structured response detected but no raw payload was provided. Ensure your stream parser returns { text, raw }.`);let a=i?e.parsers.reduce((e,t)=>e||t?.({text:i,message:n.message})||null,null):null;if(!a)return null;t.add(n.message.id),r();let o={action:a,message:n.message};e.emit(`action:detected`,o);for(let t of e.handlers)if(t)try{let r=e.captureResubmitGuard?.(),i=t(a,{message:n.message,metadata:e.getSessionMetadata(),updateMetadata:e.updateSessionMetadata,document:e.documentRef,triggerResubmit:()=>{(!r||r())&&e.emit(`action:resubmit`,o)}});if(!i)continue;if(i.handled){let e=i.persistMessage!==!1;return{text:i.displayText===void 0?``:i.displayText,persist:e,resubmit:i.resubmit}}}catch(e){typeof console<`u`&&console.error(`[AgentWidget] Action handler error:`,e)}return{text:``,persist:!0}},syncFromMetadata:n}},nu=e=>{if(!e)return null;try{return JSON.parse(e)}catch(e){return typeof console<`u`&&console.error(`[AgentWidget] Failed to parse stored state:`,e),null}},ru=e=>e.map(e=>({...e,streaming:!1})),iu=e=>e.map(e=>({...e,status:`complete`})),au=e=>`${e??`persona-`}state`,ou=(e=au())=>{let t=()=>typeof window>`u`||!window.localStorage?null:window.localStorage;return{load:()=>{let n=t();return n?nu(n.getItem(e)):null},save:n=>{let r=t();if(r)try{let t={...n,messages:n.messages?ru(n.messages):void 0,artifacts:n.artifacts?iu(n.artifacts):void 0};r.setItem(e,JSON.stringify(t))}catch(e){typeof console<`u`&&console.error(`[AgentWidget] Failed to persist state:`,e)}},clear:()=>{let n=t();if(n)try{n.removeItem(e)}catch(e){typeof console<`u`&&console.error(`[AgentWidget] Failed to clear stored state:`,e)}}}},su=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t.toString(16).padStart(8,`0`)},cu=async e=>{let t=globalThis.crypto?.subtle;if(t)try{let n=await t.digest(`SHA-256`,new TextEncoder().encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}catch{}return su(e)},lu=async(e,t)=>{let n=await cu(e);return{storageKey:`${t}visitor:${n}`,leaseKey:`${t}visitor-init-lock:${n}`,lockName:`persona-visitor-init:${await cu(`${e}\0${t}`)}`}},uu=(e,t,n)=>{let r=``,i=``,a=``,o=!1,s=!1,c=0,l=null,u=null,d=/* @__PURE__ */ new Set,f=()=>{if(n||o)return null;try{return typeof window>`u`||!window.localStorage?null:window.localStorage}catch{return o=!0,null}},p=()=>{let e=f();if(!e)return l;try{return e.getItem(r)}catch{return o=!0,l}},m=(e,t)=>{if(s||e===l)return;let n=l;l=e,c+=1;let r={previousToken:n,token:e,source:t,revision:c};for(let e of d)e(r)},h=e=>{s||(e.key===null||e.key===r)&&m(e.key===null?null:e.newValue??null,`external`)},g=(async()=>{let o=await lu(e,t);r=o.storageKey,i=o.leaseKey,a=o.lockName,l=p(),!n&&typeof window<`u`&&window.addEventListener(`storage`,h)})(),_=e=>new Promise(t=>setTimeout(t,e)),v=()=>{let e=f();if(!e)return null;try{let t=e.getItem(i);if(!t)return null;let n=JSON.parse(t);return typeof n?.expiresAt==`number`&&typeof n?.ownerNonce==`string`?n:null}catch{return null}},y=e=>{let t=f();if(t)try{v()?.ownerNonce===e&&t.removeItem(i)}catch{}},b=/* @__PURE__ */ new Set,x=e=>s?Promise.reject(/* @__PURE__ */ Error(`Visitor store destroyed before its first init could start`)):e(),S=e=>new Promise(t=>{let n=setTimeout(r,e);function r(){clearTimeout(n),b.delete(r),window.removeEventListener(`storage`,a),t()}function a(e){(e.key===null||e.key===i)&&r()}b.add(r),window.addEventListener(`storage`,a)}),C=async e=>{let t=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,n=Date.now()+15e3;for(;!s&&Date.now()<n;){let n=f();if(!n)break;let r=Date.now(),a=v();if(a&&a.expiresAt>r&&a.ownerNonce!==t)await S(Math.min(a.expiresAt-r,500));else{try{n.setItem(i,JSON.stringify({ownerNonce:t,expiresAt:r+1e4}))}catch{o=!0;break}if(await _(20+Math.random()*40),v()?.ownerNonce!==t)await S(500);else{u=t;try{return await x(e)}finally{u=null,y(t)}}}}return x(e)};return{ready:g,async get(){return await g,m(p(),`external`),l},async set(e){await g;let t=f();if(t)try{t.setItem(r,e)}catch{o=!0}m(e,`local`)},async clear(){await g;let e=f();if(e)try{e.removeItem(r)}catch{o=!0}m(null,`local`)},revision(){return c},subscribe(e){return d.add(e),()=>{d.delete(e)}},async withFirstInitLock(e){await g;let t=globalThis.navigator?.locks;return t?.request?t.request(a,()=>x(e)):f()?C(e):x(e)},matches(r,i,a){return r===e&&i===t&&a===n},destroy(){s=!0,d.clear(),typeof window<`u`&&window.removeEventListener(`storage`,h),u&&y(u);for(let e of[...b])e()}}},{setLoader:du,load:fu}=v({fallbackImport:()=>import(`./chunk-6C23QQdP.js`)}),pu=fu,{setLoader:mu,load:hu,provide:gu,getSync:_u}=v({fallbackImport:()=>import(`./chunk-2FnmZ9AA.js`)}),vu=hu,yu=_u;function bu(){return null}const xu=[`Very dissatisfied`,`Dissatisfied`,`Neutral`,`Satisfied`,`Very satisfied`];function Su(e,t,n){let{onSubmit:r,onDismiss:i,title:a=t===`csat`?`How satisfied are you?`:`How likely are you to recommend us?`,subtitle:o=t===`csat`?`Please rate your experience`:`On a scale of 0 to 10`,commentPlaceholder:s=t===`csat`?`Share your thoughts (optional)...`:`What could we do better? (optional)...`,submitText:c=`Submit`,skipText:l=`Skip`,showComment:u=!0}=e,d=document.createElement(`div`);d.className=`persona-feedback-container persona-feedback-${t}`,d.setAttribute(`role`,`dialog`),d.setAttribute(`aria-label`,t===`csat`?`Customer satisfaction feedback`:`Net Promoter Score feedback`);let f=null,p=document.createElement(`div`);p.className=`persona-feedback-content`;let m=document.createElement(`div`);m.className=`persona-feedback-header`;let h=document.createElement(`h3`);h.className=`persona-feedback-title`,h.textContent=a,m.appendChild(h);let g=document.createElement(`p`);g.className=`persona-feedback-subtitle`,g.textContent=o,m.appendChild(g),p.appendChild(m);let{element:_,attentionTarget:v}=n(e=>{f=e});p.appendChild(_);let y=null;if(u){let e=document.createElement(`div`);e.className=`persona-feedback-comment-container`,y=document.createElement(`textarea`),y.className=`persona-feedback-comment`,y.placeholder=s,y.rows=3,y.setAttribute(`aria-label`,`Additional comments`),e.appendChild(y),p.appendChild(e)}let b=document.createElement(`div`);b.className=`persona-feedback-actions`;let x=document.createElement(`button`);x.type=`button`,x.className=`persona-feedback-btn persona-feedback-btn-skip`,x.textContent=l,x.addEventListener(`click`,()=>{i?.(),d.remove()});let S=document.createElement(`button`);return S.type=`button`,S.className=`persona-feedback-btn persona-feedback-btn-submit`,S.textContent=c,S.addEventListener(`click`,async()=>{if(f===null)v.classList.add(`persona-feedback-shake`),setTimeout(()=>v.classList.remove(`persona-feedback-shake`),500);else{S.disabled=!0,S.textContent=`Submitting...`;try{let e=y?.value.trim()||void 0;await r(f,e),d.remove()}catch(e){S.disabled=!1,S.textContent=c,console.error(`[${t.toUpperCase()} Feedback] Failed to submit:`,e)}}}),b.appendChild(x),b.appendChild(S),p.appendChild(b),d.appendChild(p),d}function Cu(e){return Su(e,`csat`,t=>{let{ratingLabels:n=xu}=e,r=document.createElement(`div`);r.className=`persona-feedback-rating persona-feedback-rating-csat`,r.setAttribute(`role`,`radiogroup`),r.setAttribute(`aria-label`,`Satisfaction rating from 1 to 5`);let i=[];for(let e=1;e<=5;e++){let a=document.createElement(`button`);a.type=`button`,a.className=`persona-feedback-rating-btn persona-feedback-star-btn`,a.setAttribute(`role`,`radio`),a.setAttribute(`aria-checked`,`false`),a.setAttribute(`aria-label`,`${e} star${e>1?`s`:``}: ${n[e-1]}`),a.title=n[e-1],a.dataset.rating=String(e),a.innerHTML=`
|
|
19
19
|
<svg class="persona-feedback-star" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
20
20
|
<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon>
|
|
21
21
|
</svg>
|