@helpai/elements 0.47.0 → 0.47.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/elements.cjs.js CHANGED
@@ -1,14 +1,14 @@
1
- "use strict";var Ln=Object.defineProperty;var kc=Object.getOwnPropertyDescriptor;var Cc=Object.getOwnPropertyNames;var Tc=Object.prototype.hasOwnProperty;var Ec=(e,t,n)=>t in e?Ln(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ic=(e,t)=>{for(var n in t)Ln(e,n,{get:t[n],enumerable:!0})},Rc=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Cc(t))!Tc.call(e,i)&&i!==n&&Ln(e,i,{get:()=>t[i],enumerable:!(r=kc(t,i))||r.enumerable});return e};var Ac=e=>Rc(Ln({},"__esModule",{value:!0}),e);var J=(e,t,n)=>Ec(e,typeof t!="symbol"?t+"":t,n);var Up={};Ic(Up,{HOOK_WILDCARD:()=>Ur,brand:()=>zp,destroy:()=>Op,getAllInstances:()=>Hp,getInstance:()=>$p,hook:()=>Bp,init:()=>Dp,mount:()=>Ql,resolveInitialHostMode:()=>zr,version:()=>Fp});module.exports=Ac(Up);var Bn,X,Ci,ao,Ze,yi,Ti,Ei,no,Nn,Jt,Ii,so,ro,oo,Lc,On={},$n=[],Mc=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Fn=Array.isArray;function je(e,t){for(var n in t)e[n]=t[n];return e}function lo(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function zn(e,t,n){var r,i,a,l={};for(a in t)a=="key"?r=t[a]:a=="ref"?i=t[a]:l[a]=t[a];if(arguments.length>2&&(l.children=arguments.length>3?Bn.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(a in e.defaultProps)l[a]===void 0&&(l[a]=e.defaultProps[a]);return Dn(e,l,r,i,null)}function Dn(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Ci,__i:-1,__u:0};return i==null&&X.vnode!=null&&X.vnode(a),a}function re(e){return e.children}function et(e,t){this.props=e,this.context=t}function yt(e,t){if(t==null)return e.__?yt(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?yt(e):null}function Nc(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=je({},t);a.__v=t.__v+1,X.vnode&&X.vnode(a),co(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??yt(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,Mi(r,a,i),t.__e=t.__=null,a.__e!=n&&Ri(a)}}function Ri(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),Ri(e)}function Si(e){(!e.__d&&(e.__d=!0)&&Ze.push(e)&&!Hn.__r++||yi!=X.debounceRendering)&&((yi=X.debounceRendering)||Ti)(Hn)}function Hn(){try{for(var e,t=1;Ze.length;)Ze.length>t&&Ze.sort(Ei),e=Ze.shift(),t=Ze.length,Nc(e)}finally{Ze.length=Hn.__r=0}}function Ai(e,t,n,r,i,a,l,s,c,d,u){var _,m,f,g,S,h,v,C=r&&r.__k||$n,b=t.length;for(c=Dc(n,t,C,c,b),_=0;_<b;_++)(f=n.__k[_])!=null&&(m=f.__i!=-1&&C[f.__i]||On,f.__i=_,h=co(e,f,m,i,a,l,s,c,d,u),g=f.__e,f.ref&&m.ref!=f.ref&&(m.ref&&_o(m.ref,null,f),u.push(f.ref,f.__c||g,f)),S==null&&g!=null&&(S=g),(v=!!(4&f.__u))||m.__k===f.__k?(c=Li(f,c,e,v),v&&m.__e&&(m.__e=null)):typeof f.type=="function"&&h!==void 0?c=h:g&&(c=g.nextSibling),f.__u&=-7);return n.__e=S,c}function Dc(e,t,n,r,i){var a,l,s,c,d,u=n.length,_=u,m=0;for(e.__k=new Array(i),a=0;a<i;a++)(l=t[a])!=null&&typeof l!="boolean"&&typeof l!="function"?(typeof l=="string"||typeof l=="number"||typeof l=="bigint"||l.constructor==String?l=e.__k[a]=Dn(null,l,null,null,null):Fn(l)?l=e.__k[a]=Dn(re,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=e.__k[a]=Dn(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):e.__k[a]=l,c=a+m,l.__=e,l.__b=e.__b+1,s=null,(d=l.__i=Oc(l,n,c,_))!=-1&&(_--,(s=n[d])&&(s.__u|=2)),s==null||s.__v==null?(d==-1&&(i>u?m--:i<u&&m++),typeof l.type!="function"&&(l.__u|=4)):d!=c&&(d==c-1?m--:d==c+1?m++:(d>c?m--:m++,l.__u|=4))):e.__k[a]=null;if(_)for(a=0;a<u;a++)(s=n[a])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=yt(s)),Di(s,s));return r}function Li(e,t,n,r){var i,a;if(typeof e.type=="function"){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=Li(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=yt(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Oc(e,t,n,r){var i,a,l,s=e.key,c=e.type,d=t[n],u=d!=null&&(2&d.__u)==0;if(d===null&&s==null||u&&s==d.key&&c==d.type)return n;if(r>(u?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((d=t[l=i>=0?i--:a++])!=null&&(2&d.__u)==0&&s==d.key&&c==d.type)return l}return-1}function wi(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||Mc.test(t)?n:n+"px"}function Mn(e,t,n,r,i){var a,l;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||wi(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||wi(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")a=t!=(t=t.replace(Ii,"$1")),l=t.toLowerCase(),t=l in e||t=="onFocusOut"||t=="onFocusIn"?l.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n[Jt]=r[Jt]:(n[Jt]=so,e.addEventListener(t,a?oo:ro,a)):e.removeEventListener(t,a?oo:ro,a);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function ki(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[Nn]==null)t[Nn]=so++;else if(t[Nn]<n[Jt])return;return n(X.event?X.event(t):t)}}}function co(e,t,n,r,i,a,l,s,c,d){var u,_,m,f,g,S,h,v,C,b,E,D,V,G,ae,K=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=X.__b)&&u(t);e:if(typeof K=="function")try{if(v=t.props,C=K.prototype&&K.prototype.render,b=(u=K.contextType)&&r[u.__c],E=u?b?b.props.value:u.__:r,n.__c?h=(_=t.__c=n.__c).__=_.__E:(C?t.__c=_=new K(v,E):(t.__c=_=new et(v,E),_.constructor=K,_.render=Hc),b&&b.sub(_),_.state||(_.state={}),_.__n=r,m=_.__d=!0,_.__h=[],_._sb=[]),C&&_.__s==null&&(_.__s=_.state),C&&K.getDerivedStateFromProps!=null&&(_.__s==_.state&&(_.__s=je({},_.__s)),je(_.__s,K.getDerivedStateFromProps(v,_.__s))),f=_.props,g=_.state,_.__v=t,m)C&&K.getDerivedStateFromProps==null&&_.componentWillMount!=null&&_.componentWillMount(),C&&_.componentDidMount!=null&&_.__h.push(_.componentDidMount);else{if(C&&K.getDerivedStateFromProps==null&&v!==f&&_.componentWillReceiveProps!=null&&_.componentWillReceiveProps(v,E),t.__v==n.__v||!_.__e&&_.shouldComponentUpdate!=null&&_.shouldComponentUpdate(v,_.__s,E)===!1){t.__v!=n.__v&&(_.props=v,_.state=_.__s,_.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(U){U&&(U.__=t)}),$n.push.apply(_.__h,_._sb),_._sb=[],_.__h.length&&l.push(_);break e}_.componentWillUpdate!=null&&_.componentWillUpdate(v,_.__s,E),C&&_.componentDidUpdate!=null&&_.__h.push(function(){_.componentDidUpdate(f,g,S)})}if(_.context=E,_.props=v,_.__P=e,_.__e=!1,D=X.__r,V=0,C)_.state=_.__s,_.__d=!1,D&&D(t),u=_.render(_.props,_.state,_.context),$n.push.apply(_.__h,_._sb),_._sb=[];else do _.__d=!1,D&&D(t),u=_.render(_.props,_.state,_.context),_.state=_.__s;while(_.__d&&++V<25);_.state=_.__s,_.getChildContext!=null&&(r=je(je({},r),_.getChildContext())),C&&!m&&_.getSnapshotBeforeUpdate!=null&&(S=_.getSnapshotBeforeUpdate(f,g)),G=u!=null&&u.type===re&&u.key==null?Ni(u.props.children):u,s=Ai(e,Fn(G)?G:[G],t,n,r,i,a,l,s,c,d),_.base=t.__e,t.__u&=-161,_.__h.length&&l.push(_),h&&(_.__E=_.__=null)}catch(U){if(t.__v=null,c||a!=null)if(U.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(ae=a.length;ae--;)lo(a[ae]);io(t)}else t.__e=n.__e,t.__k=n.__k,U.then||io(t);X.__e(U,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=$c(n.__e,t,n,r,i,a,l,c,d);return(u=X.diffed)&&u(t),128&t.__u?void 0:s}function io(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(io))}function Mi(e,t,n){for(var r=0;r<n.length;r++)_o(n[r],n[++r],n[++r]);X.__c&&X.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){X.__e(a,i.__v)}})}function Ni(e){return typeof e!="object"||e==null||e.__b>0?e:Fn(e)?e.map(Ni):e.constructor!==void 0?null:je({},e)}function $c(e,t,n,r,i,a,l,s,c){var d,u,_,m,f,g,S,h=n.props||On,v=t.props,C=t.type;if(C=="svg"?i="http://www.w3.org/2000/svg":C=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),a!=null){for(d=0;d<a.length;d++)if((f=a[d])&&"setAttribute"in f==!!C&&(C?f.localName==C:f.nodeType==3)){e=f,a[d]=null;break}}if(e==null){if(C==null)return document.createTextNode(v);e=document.createElementNS(i,C,v.is&&v),s&&(X.__m&&X.__m(t,a),s=!1),a=null}if(C==null)h===v||s&&e.data==v||(e.data=v);else{if(a=C=="textarea"&&v.defaultValue!=null?null:a&&Bn.call(e.childNodes),!s&&a!=null)for(h={},d=0;d<e.attributes.length;d++)h[(f=e.attributes[d]).name]=f.value;for(d in h)f=h[d],d=="dangerouslySetInnerHTML"?_=f:d=="children"||d in v||d=="value"&&"defaultValue"in v||d=="checked"&&"defaultChecked"in v||Mn(e,d,null,f,i);for(d in v)f=v[d],d=="children"?m=f:d=="dangerouslySetInnerHTML"?u=f:d=="value"?g=f:d=="checked"?S=f:s&&typeof f!="function"||h[d]===f||Mn(e,d,f,h[d],i);if(u)s||_&&(u.__html==_.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(_&&(e.innerHTML=""),Ai(t.type=="template"?e.content:e,Fn(m)?m:[m],t,n,r,C=="foreignObject"?"http://www.w3.org/1999/xhtml":i,a,l,a?a[0]:n.__k&&yt(n,0),s,c),a!=null)for(d=a.length;d--;)lo(a[d]);s&&C!="textarea"||(d="value",C=="progress"&&g==null?e.removeAttribute("value"):g!=null&&(g!==e[d]||C=="progress"&&!g||C=="option"&&g!=h[d])&&Mn(e,d,g,h[d],i),d="checked",S!=null&&S!=e[d]&&Mn(e,d,S,h[d],i))}return e}function _o(e,t,n){try{if(typeof e=="function"){var r=typeof e.__u=="function";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){X.__e(i,n)}}function Di(e,t,n){var r,i;if(X.unmount&&X.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||_o(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){X.__e(a,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Di(r[i],t,n||typeof e.type!="function");n||lo(e.__e),e.__c=e.__=e.__e=void 0}function Hc(e,t,n){return this.constructor(e,n)}function Un(e,t,n){var r,i,a,l;t==document&&(t=document.documentElement),X.__&&X.__(e,t),i=(r=typeof n=="function")?null:n&&n.__k||t.__k,a=[],l=[],co(t,e=(!r&&n||t).__k=zn(re,null,[e]),i||On,On,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Bn.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,l),Mi(a,e,l)}Bn=$n.slice,X={__e:function(e,t,n,r){for(var i,a,l;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),l=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),l=i.__d),l)return i.__E=i}catch(s){e=s}throw e}},Ci=0,ao=function(e){return e!=null&&e.constructor===void 0},et.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=je({},this.state),typeof e=="function"&&(e=e(je({},n),this.props)),e&&je(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Si(this))},et.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Si(this))},et.prototype.render=re,Ze=[],Ti=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ei=function(e,t){return e.__v.__b-t.__v.__b},Hn.__r=0,no=Math.random().toString(8),Nn="__d"+no,Jt="__a"+no,Ii=/(PointerCapture)$|Capture$/i,so=0,ro=ki(!1),oo=ki(!0),Lc=0;var x={id:"help-ai",name:"@helpai/elements",global:"HelpAI",tagName:"web-ai-chat",cssPrefix:"helpai",defaultBaseUrl:"https://help.ai",displayName:"Help AI",domain:"help.ai",siteUrl:"https://help.ai"};var St="0.47.0";var Oi={attach:"Attach files",attachmentMimeRejected:"File type not supported",attachmentTooLarge:"File is too large",attachmentTooMany:"Attachment limit reached",conversationClosed:"This conversation is closed",conversationLoading:"Loading conversation\u2026",close:"Close",collapse:"Collapse",collapseSidebar:"Collapse sidebar",composerPlaceholder:"Type a message\u2026",dateLastWeek:"Last 7 days",dateOlder:"Older",dateToday:"Today",dateYesterday:"Yesterday",dropZone:"Drop files to attach",errorGeneric:"Something went wrong",errorRateLimited:"Too many requests \u2014 please try again in a moment.",errorRetry:"Retry",expand:"Expand",expandSidebar:"Expand sidebar",exitFullscreen:"Exit fullscreen",fullscreen:"Fullscreen",history:"History",historyBack:"Back to chat",historyEmpty:"No previous conversations yet",historyLoading:"Loading your conversations\u2026",historyContinue:"Continue the conversation",historyTitle:"Conversation history",language:"Language",launcherOpen:"Open chat",launcherLabel:"Chat with us",micStart:"Start voice input",micStop:"Stop voice input",micUnsupported:"Voice input is not supported in this browser",moreActions:"More actions",newConversation:"New conversation",panelTitle:"Chat",resizeHandle:"Drag to resize",scrollToBottom:"Scroll to latest",send:"Send",soundOff:"Sound off",soundOn:"Sound on",startNewConversation:"Start a new conversation",stop:"Stop",theme:"Theme",themeAuto:"Auto",themeDark:"Dark",themeLight:"Light",textSize:"Text size",textSizeSmall:"Small",textSizeNormal:"Normal",textSizeLarge:"Large",loading:"Loading\u2026",thinking:"Thinking\u2026",thoughts:"Thoughts",usedTool:"Used tool",toolResult:"Result",sources:"Sources",tabHome:"Home",tabConversations:"Conversations",tabHelp:"Help",tabNews:"News",modulesEmpty:"Nothing here yet",moduleBack:"Back",contentLoading:"Loading\u2026",homeGreeting:"How can we help?",homeGreetingNamed:"Hi {name} \u{1F44B}",homeGreetingLead:"How can we help?",homeSearchPlaceholder:"Search for help",homeContentTitle:"Popular articles",homeStatus:"Status",helpTitle:"Help",helpSearchPlaceholder:"Search for help",helpEmpty:"No help articles yet",helpLoading:"Loading help\u2026",helpSearchEmpty:"No results found",newsTitle:"News",newsEmpty:"No news yet",newsLoading:"Loading news\u2026",newsBack:"Back to news",newsPublishedAt:"Published {date}",formSubmit:"Submit",formSkip:"Maybe later",formSubmitted:"Completed",formSkipped:"Maybe later",formFillOut:"Fill out",formRequired:"This field is required",formInvalidEmail:"Enter a valid email address",formInvalidTel:"Enter a valid phone number",formInvalidUrl:"Enter a valid URL",formInvalidNumber:"Enter a valid number",formTooShort:"Too short (min {min} characters)",formTooLong:"Too long (max {max} characters)",formNumberTooSmall:"Must be at least {min}",formNumberTooLarge:"Must be at most {max}",formPatternMismatch:"Please match the requested format",formChooseAtLeast:"Choose at least {min}",formChooseAtMost:"Choose at most {max}",formOther:"Other",formOtherPlaceholder:"Type your answer\u2026",inputRequired:"User Input Required",inputBadge:"User Input",inputAnswered:"Answered",inputSkipped:"Skipped",inputQuestion:"Question",inputResponse:"Response",inputYourAnswer:"Your answer",inputSubmit:"Submit answer",inputSubmitHint:"Enter to submit \xB7 Shift+Enter for new line",inputSkip:"Skip",inputSubmitted:"Answer submitted",respFreeText:"Free Text",respSingleChoice:"Single Choice",respMultiChoice:"Multiple Choice",respConfirmation:"Confirmation",approvalRequired:"Approval required",approve:"Approve",reject:"Reject",approved:"Approved",rejected:"Rejected",approvalReason:"Add a reason (optional)",stepNoLongerActive:"This request is no longer active.",toolParameters:"Parameters",statusCompleted:"Completed",statusDenied:"Denied",statusError:"Error"},Bc={attach:"Joindre des fichiers",attachmentMimeRejected:"Type de fichier non pris en charge",attachmentTooLarge:"Le fichier est trop volumineux",attachmentTooMany:"Limite de pi\xE8ces jointes atteinte",conversationClosed:"Cette conversation est ferm\xE9e",conversationLoading:"Chargement de la conversation\u2026",close:"Fermer",collapse:"R\xE9duire",collapseSidebar:"R\xE9duire la barre lat\xE9rale",composerPlaceholder:"\xC9crivez un message\u2026",dateLastWeek:"7 derniers jours",dateOlder:"Plus ancien",dateToday:"Aujourd'hui",dateYesterday:"Hier",dropZone:"D\xE9posez les fichiers \xE0 joindre",errorGeneric:"Une erreur s'est produite",errorRateLimited:"Trop de requ\xEAtes \u2014 veuillez r\xE9essayer dans un instant.",errorRetry:"R\xE9essayer",expand:"Agrandir",expandSidebar:"D\xE9velopper la barre lat\xE9rale",exitFullscreen:"Quitter le plein \xE9cran",fullscreen:"Plein \xE9cran",history:"Historique",historyBack:"Retour au chat",historyEmpty:"Aucune conversation pour le moment",historyContinue:"Poursuivre la conversation",historyLoading:"Chargement de vos conversations\u2026",historyTitle:"Historique des conversations",language:"Langue",launcherOpen:"Ouvrir le chat",launcherLabel:"Discuter avec nous",micStart:"D\xE9marrer la saisie vocale",micStop:"Arr\xEAter la saisie vocale",micUnsupported:"La saisie vocale n'est pas prise en charge par ce navigateur",moreActions:"Plus d'actions",newConversation:"Nouvelle conversation",panelTitle:"Chat",resizeHandle:"Glisser pour redimensionner",scrollToBottom:"Aller au plus r\xE9cent",send:"Envoyer",soundOff:"Son d\xE9sactiv\xE9",soundOn:"Son activ\xE9",startNewConversation:"D\xE9marrer une nouvelle conversation",stop:"Arr\xEAter",theme:"Th\xE8me",themeAuto:"Auto",themeDark:"Sombre",themeLight:"Clair",textSize:"Taille du texte",textSizeSmall:"Petite",textSizeNormal:"Normale",textSizeLarge:"Grande",loading:"Chargement\u2026",thinking:"R\xE9flexion\u2026",thoughts:"R\xE9flexions",usedTool:"Outil utilis\xE9",toolResult:"R\xE9sultat",sources:"Sources",tabHome:"Accueil",tabConversations:"Conversations",tabHelp:"Aide",tabNews:"Actualit\xE9s",modulesEmpty:"Rien pour le moment",moduleBack:"Retour",contentLoading:"Chargement\u2026",homeGreeting:"Comment pouvons-nous vous aider ?",homeGreetingNamed:"Bonjour {name} \u{1F44B}",homeGreetingLead:"Comment pouvons-nous vous aider ?",homeSearchPlaceholder:"Rechercher de l'aide",homeContentTitle:"Articles populaires",homeStatus:"Statut",helpTitle:"Aide",helpSearchPlaceholder:"Rechercher de l'aide",helpEmpty:"Aucun article d'aide pour le moment",helpLoading:"Chargement de l'aide\u2026",helpSearchEmpty:"Aucun r\xE9sultat trouv\xE9",newsTitle:"Actualit\xE9s",newsEmpty:"Aucune actualit\xE9 pour le moment",newsLoading:"Chargement des actualit\xE9s\u2026",newsBack:"Retour aux actualit\xE9s",newsPublishedAt:"Publi\xE9 le {date}",formSubmit:"Envoyer",formSkip:"Plus tard",formSubmitted:"Termin\xE9",formSkipped:"Plus tard",formFillOut:"Remplir",formRequired:"Ce champ est obligatoire",formInvalidEmail:"Saisissez une adresse e-mail valide",formInvalidTel:"Saisissez un num\xE9ro de t\xE9l\xE9phone valide",formInvalidUrl:"Saisissez une URL valide",formInvalidNumber:"Saisissez un nombre valide",formTooShort:"Trop court (min. {min} caract\xE8res)",formTooLong:"Trop long (max. {max} caract\xE8res)",formNumberTooSmall:"Doit \xEAtre au moins {min}",formNumberTooLarge:"Doit \xEAtre au plus {max}",formPatternMismatch:"Veuillez respecter le format demand\xE9",formChooseAtLeast:"Choisissez au moins {min}",formChooseAtMost:"Choisissez au plus {max}",formOther:"Autre",formOtherPlaceholder:"Saisissez votre r\xE9ponse\u2026",inputRequired:"Saisie requise",inputBadge:"Saisie",inputAnswered:"R\xE9pondu",inputSkipped:"Ignor\xE9",inputQuestion:"Question",inputResponse:"R\xE9ponse",inputYourAnswer:"Votre r\xE9ponse",inputSubmit:"Envoyer la r\xE9ponse",inputSubmitHint:"Entr\xE9e pour envoyer \xB7 Maj+Entr\xE9e pour un saut de ligne",inputSkip:"Ignorer",inputSubmitted:"R\xE9ponse envoy\xE9e",respFreeText:"Texte libre",respSingleChoice:"Choix unique",respMultiChoice:"Choix multiple",respConfirmation:"Confirmation",approvalRequired:"Approbation requise",approve:"Approuver",reject:"Refuser",approved:"Approuv\xE9",rejected:"Refus\xE9",approvalReason:"Ajouter une raison (facultatif)",stepNoLongerActive:"Cette demande n'est plus active.",toolParameters:"Param\xE8tres",statusCompleted:"Termin\xE9",statusDenied:"Refus\xE9",statusError:"Erreur"},Fc={attach:"\u0625\u0631\u0641\u0627\u0642 \u0645\u0644\u0641\u0627\u062A",attachmentMimeRejected:"\u0646\u0648\u0639 \u0627\u0644\u0645\u0644\u0641 \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645",attachmentTooLarge:"\u062D\u062C\u0645 \u0627\u0644\u0645\u0644\u0641 \u0643\u0628\u064A\u0631 \u062C\u062F\u064B\u0627",attachmentTooMany:"\u062A\u0645 \u0628\u0644\u0648\u063A \u0627\u0644\u062D\u062F \u0627\u0644\u0623\u0642\u0635\u0649 \u0644\u0644\u0645\u0631\u0641\u0642\u0627\u062A",conversationClosed:"\u062A\u0645 \u0625\u063A\u0644\u0627\u0642 \u0647\u0630\u0647 \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",conversationLoading:"\u062C\u0627\u0631\u064D \u062A\u062D\u0645\u064A\u0644 \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629\u2026",close:"\u0625\u063A\u0644\u0627\u0642",collapse:"\u0637\u064A\u0651",collapseSidebar:"\u0637\u064A\u0651 \u0627\u0644\u0634\u0631\u064A\u0637 \u0627\u0644\u062C\u0627\u0646\u0628\u064A",composerPlaceholder:"\u0627\u0643\u062A\u0628 \u0631\u0633\u0627\u0644\u0629\u2026",dateLastWeek:"\u0622\u062E\u0631 \u0667 \u0623\u064A\u0627\u0645",dateOlder:"\u0623\u0642\u062F\u0645",dateToday:"\u0627\u0644\u064A\u0648\u0645",dateYesterday:"\u0623\u0645\u0633",dropZone:"\u0623\u0641\u0644\u062A \u0627\u0644\u0645\u0644\u0641\u0627\u062A \u0644\u0625\u0631\u0641\u0627\u0642\u0647\u0627",errorGeneric:"\u062D\u062F\u062B \u062E\u0637\u0623 \u0645\u0627",errorRateLimited:"\u0637\u0644\u0628\u0627\u062A \u0643\u062B\u064A\u0631\u0629 \u062C\u062F\u064B\u0627 \u2014 \u064A\u0631\u062C\u0649 \u0627\u0644\u0645\u062D\u0627\u0648\u0644\u0629 \u0628\u0639\u062F \u0644\u062D\u0638\u0629.",errorRetry:"\u0625\u0639\u0627\u062F\u0629 \u0627\u0644\u0645\u062D\u0627\u0648\u0644\u0629",expand:"\u062A\u0648\u0633\u064A\u0639",expandSidebar:"\u062A\u0648\u0633\u064A\u0639 \u0627\u0644\u0634\u0631\u064A\u0637 \u0627\u0644\u062C\u0627\u0646\u0628\u064A",exitFullscreen:"\u0625\u0646\u0647\u0627\u0621 \u0645\u0644\u0621 \u0627\u0644\u0634\u0627\u0634\u0629",fullscreen:"\u0645\u0644\u0621 \u0627\u0644\u0634\u0627\u0634\u0629",history:"\u0627\u0644\u0633\u062C\u0644",historyBack:"\u0627\u0644\u0639\u0648\u062F\u0629 \u0625\u0644\u0649 \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",historyEmpty:"\u0644\u0627 \u062A\u0648\u062C\u062F \u0645\u062D\u0627\u062F\u062B\u0627\u062A \u0633\u0627\u0628\u0642\u0629 \u0628\u0639\u062F",historyContinue:"\u0645\u062A\u0627\u0628\u0639\u0629 \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",historyLoading:"\u062C\u0627\u0631\u064D \u062A\u062D\u0645\u064A\u0644 \u0645\u062D\u0627\u062F\u062B\u0627\u062A\u0643\u2026",historyTitle:"\u0633\u062C\u0644 \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0627\u062A",language:"\u0627\u0644\u0644\u063A\u0629",launcherOpen:"\u0641\u062A\u062D \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",launcherLabel:"\u062A\u062D\u062F\u062B \u0645\u0639\u0646\u0627",micStart:"\u0628\u062F\u0621 \u0627\u0644\u0625\u062F\u062E\u0627\u0644 \u0627\u0644\u0635\u0648\u062A\u064A",micStop:"\u0625\u064A\u0642\u0627\u0641 \u0627\u0644\u0625\u062F\u062E\u0627\u0644 \u0627\u0644\u0635\u0648\u062A\u064A",micUnsupported:"\u0627\u0644\u0625\u062F\u062E\u0627\u0644 \u0627\u0644\u0635\u0648\u062A\u064A \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645 \u0641\u064A \u0647\u0630\u0627 \u0627\u0644\u0645\u062A\u0635\u0641\u062D",moreActions:"\u0625\u062C\u0631\u0627\u0621\u0627\u062A \u0625\u0636\u0627\u0641\u064A\u0629",newConversation:"\u0645\u062D\u0627\u062F\u062B\u0629 \u062C\u062F\u064A\u062F\u0629",panelTitle:"\u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",resizeHandle:"\u0627\u0633\u062D\u0628 \u0644\u062A\u063A\u064A\u064A\u0631 \u0627\u0644\u062D\u062C\u0645",scrollToBottom:"\u0627\u0644\u0627\u0646\u062A\u0642\u0627\u0644 \u0625\u0644\u0649 \u0627\u0644\u0623\u062D\u062F\u062B",send:"\u0625\u0631\u0633\u0627\u0644",soundOff:"\u0643\u062A\u0645 \u0627\u0644\u0635\u0648\u062A",soundOn:"\u062A\u0634\u063A\u064A\u0644 \u0627\u0644\u0635\u0648\u062A",startNewConversation:"\u0628\u062F\u0621 \u0645\u062D\u0627\u062F\u062B\u0629 \u062C\u062F\u064A\u062F\u0629",stop:"\u0625\u064A\u0642\u0627\u0641",theme:"\u0627\u0644\u0645\u0638\u0647\u0631",themeAuto:"\u062A\u0644\u0642\u0627\u0626\u064A",themeDark:"\u062F\u0627\u0643\u0646",themeLight:"\u0641\u0627\u062A\u062D",textSize:"\u062D\u062C\u0645 \u0627\u0644\u0646\u0635",textSizeSmall:"\u0635\u063A\u064A\u0631",textSizeNormal:"\u0639\u0627\u062F\u064A",textSizeLarge:"\u0643\u0628\u064A\u0631",loading:"\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u062D\u0645\u064A\u0644\u2026",thinking:"\u064A\u0641\u0643\u0631\u2026",thoughts:"\u0627\u0644\u0623\u0641\u0643\u0627\u0631",usedTool:"\u0623\u062F\u0627\u0629 \u0645\u064F\u0633\u062A\u062E\u062F\u064E\u0645\u0629",toolResult:"\u0627\u0644\u0646\u062A\u064A\u062C\u0629",sources:"\u0627\u0644\u0645\u0635\u0627\u062F\u0631",tabHome:"\u0627\u0644\u0631\u0626\u064A\u0633\u064A\u0629",tabConversations:"\u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0627\u062A",tabHelp:"\u0627\u0644\u0645\u0633\u0627\u0639\u062F\u0629",tabNews:"\u0627\u0644\u0623\u062E\u0628\u0627\u0631",modulesEmpty:"\u0644\u0627 \u0634\u064A\u0621 \u0647\u0646\u0627 \u0628\u0639\u062F",moduleBack:"\u0631\u062C\u0648\u0639",contentLoading:"\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u062D\u0645\u064A\u0644\u2026",homeGreeting:"\u0643\u064A\u0641 \u064A\u0645\u0643\u0646\u0646\u0627 \u0645\u0633\u0627\u0639\u062F\u062A\u0643\u061F",homeGreetingNamed:"\u0645\u0631\u062D\u0628\u064B\u0627 {name} \u{1F44B}",homeGreetingLead:"\u0643\u064A\u0641 \u064A\u0645\u0643\u0646\u0646\u0627 \u0645\u0633\u0627\u0639\u062F\u062A\u0643\u061F",homeSearchPlaceholder:"\u0627\u0628\u062D\u062B \u0639\u0646 \u0645\u0633\u0627\u0639\u062F\u0629",homeContentTitle:"\u0645\u0642\u0627\u0644\u0627\u062A \u0634\u0627\u0626\u0639\u0629",homeStatus:"\u0627\u0644\u062D\u0627\u0644\u0629",helpTitle:"\u0627\u0644\u0645\u0633\u0627\u0639\u062F\u0629",helpSearchPlaceholder:"\u0627\u0628\u062D\u062B \u0639\u0646 \u0645\u0633\u0627\u0639\u062F\u0629",helpEmpty:"\u0644\u0627 \u062A\u0648\u062C\u062F \u0645\u0642\u0627\u0644\u0627\u062A \u0645\u0633\u0627\u0639\u062F\u0629 \u0628\u0639\u062F",helpLoading:"\u062C\u0627\u0631\u064D \u062A\u062D\u0645\u064A\u0644 \u0627\u0644\u0645\u0633\u0627\u0639\u062F\u0629\u2026",helpSearchEmpty:"\u0644\u0627 \u062A\u0648\u062C\u062F \u0646\u062A\u0627\u0626\u062C",newsTitle:"\u0627\u0644\u0623\u062E\u0628\u0627\u0631",newsEmpty:"\u0644\u0627 \u062A\u0648\u062C\u062F \u0623\u062E\u0628\u0627\u0631 \u0628\u0639\u062F",newsLoading:"\u062C\u0627\u0631\u064D \u062A\u062D\u0645\u064A\u0644 \u0627\u0644\u0623\u062E\u0628\u0627\u0631\u2026",newsBack:"\u0627\u0644\u0639\u0648\u062F\u0629 \u0625\u0644\u0649 \u0627\u0644\u0623\u062E\u0628\u0627\u0631",newsPublishedAt:"\u0646\u064F\u0634\u0631 \u0641\u064A {date}",formSubmit:"\u0625\u0631\u0633\u0627\u0644",formSkip:"\u0644\u0627\u062D\u0642\u064B\u0627",formSubmitted:"\u062A\u0645",formSkipped:"\u0644\u0627\u062D\u0642\u064B\u0627",formFillOut:"\u062A\u0639\u0628\u0626\u0629",formRequired:"\u0647\u0630\u0627 \u0627\u0644\u062D\u0642\u0644 \u0645\u0637\u0644\u0648\u0628",formInvalidEmail:"\u0623\u062F\u062E\u0644 \u0628\u0631\u064A\u062F\u064B\u0627 \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A\u064B\u0627 \u0635\u062D\u064A\u062D\u064B\u0627",formInvalidTel:"\u0623\u062F\u062E\u0644 \u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0635\u062D\u064A\u062D\u064B\u0627",formInvalidUrl:"\u0623\u062F\u062E\u0644 \u0631\u0627\u0628\u0637\u064B\u0627 \u0635\u062D\u064A\u062D\u064B\u0627",formInvalidNumber:"\u0623\u062F\u062E\u0644 \u0631\u0642\u0645\u064B\u0627 \u0635\u062D\u064A\u062D\u064B\u0627",formTooShort:"\u0642\u0635\u064A\u0631 \u062C\u062F\u064B\u0627 (\u0627\u0644\u062D\u062F \u0627\u0644\u0623\u062F\u0646\u0649 {min} \u062D\u0631\u0641\u064B\u0627)",formTooLong:"\u0637\u0648\u064A\u0644 \u062C\u062F\u064B\u0627 (\u0627\u0644\u062D\u062F \u0627\u0644\u0623\u0642\u0635\u0649 {max} \u062D\u0631\u0641\u064B\u0627)",formNumberTooSmall:"\u064A\u062C\u0628 \u0623\u0644\u0627 \u064A\u0642\u0644 \u0639\u0646 {min}",formNumberTooLarge:"\u064A\u062C\u0628 \u0623\u0644\u0627 \u064A\u0632\u064A\u062F \u0639\u0646 {max}",formPatternMismatch:"\u064A\u0631\u062C\u0649 \u0645\u0637\u0627\u0628\u0642\u0629 \u0627\u0644\u0635\u064A\u063A\u0629 \u0627\u0644\u0645\u0637\u0644\u0648\u0628\u0629",formChooseAtLeast:"\u0627\u062E\u062A\u0631 {min} \u0639\u0644\u0649 \u0627\u0644\u0623\u0642\u0644",formChooseAtMost:"\u0627\u062E\u062A\u0631 {max} \u0639\u0644\u0649 \u0627\u0644\u0623\u0643\u062B\u0631",formOther:"\u0623\u062E\u0631\u0649",formOtherPlaceholder:"\u0627\u0643\u062A\u0628 \u0625\u062C\u0627\u0628\u062A\u0643\u2026",inputRequired:"\u0645\u0637\u0644\u0648\u0628 \u0625\u062F\u062E\u0627\u0644 \u0645\u0646 \u0627\u0644\u0645\u0633\u062A\u062E\u062F\u0645",inputBadge:"\u0625\u062F\u062E\u0627\u0644 \u0627\u0644\u0645\u0633\u062A\u062E\u062F\u0645",inputAnswered:"\u062A\u0645\u062A \u0627\u0644\u0625\u062C\u0627\u0628\u0629",inputSkipped:"\u062A\u0645 \u0627\u0644\u062A\u062E\u0637\u064A",inputQuestion:"\u0627\u0644\u0633\u0624\u0627\u0644",inputResponse:"\u0627\u0644\u0625\u062C\u0627\u0628\u0629",inputYourAnswer:"\u0625\u062C\u0627\u0628\u062A\u0643",inputSubmit:"\u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0625\u062C\u0627\u0628\u0629",inputSubmitHint:"Enter \u0644\u0644\u0625\u0631\u0633\u0627\u0644 \xB7 Shift+Enter \u0644\u0633\u0637\u0631 \u062C\u062F\u064A\u062F",inputSkip:"\u062A\u062E\u0637\u064D\u0651",inputSubmitted:"\u062A\u0645 \u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0625\u062C\u0627\u0628\u0629",respFreeText:"\u0646\u0635 \u062D\u0631",respSingleChoice:"\u0627\u062E\u062A\u064A\u0627\u0631 \u0648\u0627\u062D\u062F",respMultiChoice:"\u0627\u062E\u062A\u064A\u0627\u0631 \u0645\u062A\u0639\u062F\u062F",respConfirmation:"\u062A\u0623\u0643\u064A\u062F",approvalRequired:"\u0645\u0637\u0644\u0648\u0628 \u0645\u0648\u0627\u0641\u0642\u0629",approve:"\u0645\u0648\u0627\u0641\u0642\u0629",reject:"\u0631\u0641\u0636",approved:"\u062A\u0645\u062A \u0627\u0644\u0645\u0648\u0627\u0641\u0642\u0629",rejected:"\u0645\u0631\u0641\u0648\u0636",approvalReason:"\u0623\u0636\u0641 \u0633\u0628\u0628\u064B\u0627 (\u0627\u062E\u062A\u064A\u0627\u0631\u064A)",stepNoLongerActive:"\u0644\u0645 \u064A\u0639\u062F \u0647\u0630\u0627 \u0627\u0644\u0637\u0644\u0628 \u0646\u0634\u0637\u064B\u0627.",toolParameters:"\u0627\u0644\u0645\u0639\u0637\u064A\u0627\u062A",statusCompleted:"\u0645\u0643\u062A\u0645\u0644",statusDenied:"\u0645\u0631\u0641\u0648\u0636",statusError:"\u062E\u0637\u0623"},zc={en:Oi,fr:Bc,ar:Fc};function Wn(e,t){let n=$i(e),r=Vn(t),i=n==="en"?{}:zc[n]??{},a=r?t[n]??{}:t??{},l=r?t.en??{}:{};return{...Oi,...i,...l,...a}}function $i(e){return(e.split("-")[0]??"en").toLowerCase()}var Uc=new Set(["ar","he","iw","fa","ur","ps","sd","ug","yi","dv","ckb","ks","nqo","prs","syr"]);function Hi(e){return Uc.has($i(e))}function Se(e,t){return e[t]??t}function Vn(e){if(!e)return!1;for(let t of Object.values(e))if(t&&typeof t=="object")return!0;return!1}function Bi(e,t){if(!(!e?.length||!t))return e.find(n=>n.locale===t)}function Fi(e,t){let{translations:n,defaultLocale:r,...i}=e,a=Bi(n,t);return a?{...i,title:a.title??i.title,description:a.description??i.description,content:a.content??i.content}:i}function zi(e,t){let{translations:n,defaultLocale:r,...i}=e,a=Bi(n,t);if(!a)return i;let l=new Map((a.fields??[]).map(c=>[c.name,c])),s=i.fields.map(c=>{let d=l.get(c.name);if(!d)return c;let u=new Map((d.options??[]).map(_=>[_.value,_]));return{...c,label:d.label??c.label,placeholder:d.placeholder??c.placeholder,validationHint:d.validationHint??c.validationHint,options:c.options?.map(_=>{let m=u.get(_.value);return m?{..._,label:m.label??_.label,description:m.description??_.description}:_})}});return{...i,title:a.title??i.title,description:a.description??i.description,submitLabel:a.submitLabel??i.submitLabel,fields:s}}var uo=class{get(t){try{return localStorage.getItem(t)}catch{return null}}set(t,n){try{localStorage.setItem(t,n)}catch{}}remove(t){try{localStorage.removeItem(t)}catch{}}},Gn=new uo;var mo=["off","error","warn","info","debug","trace"],go=x.cssPrefix,Ui=`${go}.debug`,Wc=`__${x.global}_DEBUG__`,Vc=`${go}-debug`,Kn=2,po=null;function Gc(){if(typeof window>"u")return 2;try{let e=new URLSearchParams(window.location.search).get(Vc);if(e!==null){let t=fo(e);if(t>=0)return t}}catch{}try{let e=window.localStorage?.getItem(Ui);if(e){let t=fo(e);if(t>=0)return t}}catch{}return window[Wc]?4:2}function fo(e){if(e===!0||e==="1"||e==="true")return 4;if(e===!1||e==="0"||e==="false"||e==="off")return 0;if(typeof e=="number")return Math.max(0,Math.min(5,Math.floor(e)));if(typeof e=="string"){let t=mo.indexOf(e);if(t>=0)return t}return-1}function qn(e){let t=fo(e);if(!(t<0)){Kn=t;try{window.localStorage?.setItem(Ui,mo[t])}catch{}}}function ho(){return mo[Kn]}Kn=Gc();function Wi(e){let t=`[${go}:${e}]`,n=(r,i,a)=>(l,s)=>{if(!(Kn<r)&&(s===void 0?console[i](t,l):console[i](t,l,s),po))try{po({level:a,scope:e,message:l,payload:s})}catch{}};return{error:n(1,"error","error"),warn:n(2,"warn","warn"),info:n(3,"info","info"),debug:n(4,"debug","debug"),trace:n(5,"debug","trace"),scope:r=>Wi(`${e}:${r}`)}}var B=Wi("core");function Vi(e){po=e}var at=B.scope("context"),Kc=new Set(["visitorId","conversationId","conversationId","jwt","token","authorization","password"]),Gi=50,vo=1024,qc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function bo(e){return Ki(e,"userContext",!0)}function xo(e){return Ki(e,"pageContext",!1)}function Ki(e,t,n){if(e==null)return;if(typeof e!="object"||Array.isArray(e)){at.warn(`ignored ${t} \u2014 expected an object`,{type:Array.isArray(e)?"array":typeof e});return}let r={},i=0;for(let[a,l]of Object.entries(e)){if(Kc.has(a)){at.warn(`dropped reserved ${t} key "${a}" \u2014 managed by the widget, not host-settable`);continue}if(l==null)continue;if(i>=Gi){at.warn(`${t} truncated at ${Gi} keys \u2014 dropped "${a}"`);continue}let s=jc(t,a,l);s!==void 0&&(r[a]=s,i++)}return n&&typeof r.email=="string"&&!qc.test(r.email)&&(at.warn(`dropped malformed ${t}.email "${r.email}"`),delete r.email),Object.keys(r).length>0?r:void 0}function jc(e,t,n){if(typeof n=="boolean")return n;if(typeof n=="number"){if(!Number.isFinite(n)){at.warn(`dropped non-finite ${e}.${t}`);return}return n}if(typeof n=="string"){let r=n.trim();return r===""?void 0:r.length>vo?(at.warn(`truncated ${e}.${t} to ${vo} chars`),r.slice(0,vo)):r}at.warn(`dropped ${e}.${t} \u2014 only string/number/boolean values are allowed`,{type:typeof n})}var jn={maxBytes:10485760,maxCount:10,accept:"*/*"},Xn={files:!0,voice:"local",humanInLoop:!0},qi={list:[],byTrigger:{}},Po={enabled:!0,sampleRate:1},Yn={upload:"/pai/upload-file",transcribe:"/pai/transcribe-audio",submitForm:"/pai/submit-form"},wt={variant:"circle",size:"md",label:void 0,icon:"chat",hidden:!1},ji={floating:["theme","textSize","history","close","clear","expand","fullscreen","sound","language"],inline:["theme","textSize","history","close","clear","fullscreen","sound","language"],standalone:["theme","textSize","history","clear","sound","language"],page:["theme","textSize","history","clear","sound","language"],modal:["theme","textSize","history","close","clear","fullscreen","sound","language"],drawer:["theme","textSize","history","close","clear","fullscreen","sound","language"]},yo={enabled:!0,volume:.3,events:void 0},Xi={enabled:!0,events:void 0},Yi=[{label:"tabConversations",layout:"chat"}],Ji={showSearchBar:!0};function kt(e){let t=e!==null&&typeof e=="object"?e:{},n=t.presentation??{},r=t.behavior??{},i=t.i18n??{},a=t.feedback??{},l=t.footer??{},s=t.header??{},{themeMode:c,themeOverrides:d}=Xc(t.theme),u=n.mode??"floating",_=Yc(i.defaultLocale),m=i.availableLocales??[i.locale??_],f=Ct(i.locale??_,m,_),g=(t.baseUrl??x.defaultBaseUrl).replace(/\/$/,""),S=(t.agentApiBaseUrl??`${g}/api/agent`).replace(/\/$/,""),h=(t.dataApiBaseUrl??`${g}/api/data`).replace(/\/$/,"");return{widgetId:t.widgetId??"default",publicKey:t.publicKey,aiAgentDeploymentId:t.aiAgentDeploymentId,baseUrl:g,agentApiBaseUrl:S,dataApiBaseUrl:h,userContext:bo(t.userContext),pageContext:xo(t.pageContext),position:n.position??"bottom-right",themeMode:c,textSize:"normal",themeOverrides:d,mode:u,iframe:n.iframe??!1,responseMode:r.responseMode??"streaming",showReasoning:r.showReasoning??!1,showToolCalls:r.showToolCalls??!1,showSources:r.showSources??!1,features:{files:t.features?.files??Xn.files,voice:t.features?.voice??Xn.voice,humanInLoop:t.features?.humanInLoop??Xn.humanInLoop,tools:t.features?.tools},forms:Qt(t.forms,f),endpoints:{upload:t.endpoints?.upload??Yn.upload,transcribe:t.endpoints?.transcribe??Yn.transcribe,submitForm:t.endpoints?.submitForm??Yn.submitForm},attachments:{accept:t.composer?.attachments?.accept??jn.accept,maxBytes:t.composer?.attachments?.maxBytes??jn.maxBytes,maxCount:t.composer?.attachments?.maxCount??jn.maxCount},locale:f,defaultLocale:_,availableLocales:m,startMinimized:r.startMinimized??!0,actions:Jc(u,s.actions),size:n.size??{},launcher:id(t.launcher),sound:Qc(a.sound),haptics:Zc(a.haptics),strings:Wn(f,i.strings),stringsOverride:i.strings,composerDisclaimer:l.composerDisclaimer??"",poweredBy:td(l.poweredBy),composer:nd(t.composer),modules:rd(t.modules),tracking:ed(t.tracking,h),storage:t.storage??Gn,onMessage:t.onMessage,onOpen:t.onOpen,onClose:t.onClose,onError:t.onError}}function Xc(e){return typeof e=="string"?{themeMode:e,themeOverrides:{}}:e&&typeof e=="object"?{themeMode:"auto",themeOverrides:e}:{themeMode:"auto",themeOverrides:{}}}function Yc(e){return e&&e!=="auto"?e:typeof navigator<"u"&&navigator.language?navigator.language:"en"}function Ct(e,t,n){return t.length<=1||t.includes(e)?e:t.includes(n)?n:t[0]??e}function Jc(e,t){return t??ji[e]}function Qc(e){return{enabled:e?.enabled??yo.enabled,volume:e?.volume??yo.volume,events:e?.events}}function Zc(e){return{enabled:e?.enabled??Xi.enabled,events:e?.events}}function ed(e,t){let n=e?.sampleRate??Po.sampleRate;return{enabled:e?.enabled??Po.enabled,endpoint:e?.endpoint??`${t}/pai/elements-px.gif`,sampleRate:Math.min(1,Math.max(0,Number.isFinite(n)?n:1)),token:e?.token}}function td(e){let n={...{text:`Powered by ${x.displayName}`,href:x.siteUrl},...e};return!!(n.text||n.logoUrl)?n:null}function nd(e){let t=e?.sendButton;return{sendButton:{shape:t?.shape??"circle",icon:t?.icon??"arrowUp",variant:t?.variant??"filled"}}}function rd(e){let t=e===void 0?Yi:e,n=new Set,r=[];for(let a of t.slice(0,4)){if(!a?.label||!a?.layout)continue;let l=a.contentTags?.filter(Boolean),s=a.id??l?.[0]??a.layout;for(;n.has(s);)s=`${s}-${r.length}`;n.add(s);let c={id:s,label:a.label,layout:a.layout};l&&l.length>0&&(c.contentTags=l),a.layout==="home"&&(c.brandName=a.brandName,c.greetingText=a.greetingText,c.showGreeting=a.showGreeting??!0,c.showSearchBar=a.showSearchBar??Ji.showSearchBar,c.showRecentConversations=a.showRecentConversations??!0,a.userAvatars&&a.userAvatars.length>0&&(c.userAvatars=a.userAvatars),a.status&&(c.status=a.status),c.contentBlockTitle=a.contentBlockTitle),r.push(c)}let i=Object.fromEntries(r.map(a=>[a.id,a]));return{list:r,byId:i}}function Qt(e,t){var a;if(!e?.length)return qi;let n=[],r=new Set;for(let l of e){if(!l?.id||r.has(l.id))continue;let s=zi(l,t),c=(s.fields??[]).filter(u=>!!(u&&u.name&&u.label&&u.type)),d=(Array.isArray(s.on)?s.on:[s.on]).map(od).filter(u=>u!==null);c.length===0||d.length===0||(r.add(s.id),n.push({id:s.id,triggers:d,when:s.when,fields:c,title:s.title,description:s.description,submitLabel:s.submitLabel,skippable:s.skippable??!1,frequency:s.frequency??"once",mirrorToContext:s.mirrorToContext??!0,reopenable:s.reopenable??!0,reviewable:s.reviewable??!0}))}let i={};for(let l of n)for(let s of l.triggers)(i[a=s.kind]??(i[a]=[])).push(l);return{list:n,byTrigger:i}}function od(e){if(typeof e!="string")return null;if(e==="pre-chat"||e==="conversation-closed"||e==="panel-close"||e==="manual")return{kind:e};let[t,n]=e.split(":",2);if(t==="after-messages"){let r=Number(n);return Number.isFinite(r)&&r>0?{kind:"after-messages",param:r}:null}if(t==="idle"){let r=Number(n);return Number.isFinite(r)&&r>0?{kind:"idle",param:r}:null}return t==="page-area"&&n?{kind:"page-area",param:n}:null}function id(e){let t=e?.callout?.text?{shape:"pill",position:"auto",delayMs:1200,autoDismissMs:0,animated:!0,persistent:!0,...e.callout}:null;return{variant:e?.variant??wt.variant,size:e?.size??wt.size,label:e?.label??wt.label,icon:e?.icon??wt.icon,hidden:e?.hidden??wt.hidden,callout:t}}function So(e,t,n,r){let i=Ct(t,e.availableLocales,e.defaultLocale);if(i===e.locale&&n===e.themeMode&&r===e.textSize)return e;let a={...e};return i!==e.locale&&(a.locale=i,a.strings=Wn(i,e.stringsOverride)),n!==e.themeMode&&(a.themeMode=n),r!==e.textSize&&(a.textSize=r),a}var ad=["presentation","behavior","theme","launcher","header","composer","feedback","i18n","footer","features","tracking","endpoints"];function wo(e,t){if(!t)return e;let n={...e};for(let a of ad){let l=t[a];if(l===void 0)continue;let s=e[a];if(a==="theme"){s===void 0&&(n[a]=l);continue}a!=="i18n"&&(n[a]=Qi(l,s))}t.modules!==void 0&&e.modules===void 0&&(n.modules=t.modules),t.dataApiBaseUrl!==void 0&&e.dataApiBaseUrl===void 0&&(n.dataApiBaseUrl=t.dataApiBaseUrl);let r=e.i18n,i=t.i18n;if(r||i){let a=Qi(i??{},r);i?.availableLocales!==void 0&&(a.availableLocales=i.availableLocales),i?.defaultLocale!==void 0&&(a.defaultLocale=i.defaultLocale);let l=r?.strings,s=i?.strings;(l||s)&&(a.strings=sd(s,l)),n.i18n=a}return n}function Qi(e,t){if(!t)return e;let n={...e};for(let[r,i]of Object.entries(t))i!==void 0&&(n[r]=i);return n}function sd(e,t){if(!e)return t;if(!t)return e;let n=Vn(e),r=Vn(t);if(!n&&!r)return{...e,...t};let i={},a=n?e:{en:e},l=r?t:{en:t};for(let[s,c]of Object.entries(a))i[s]={...c};for(let[s,c]of Object.entries(l))i[s]={...i[s],...c};return i}var ld=["clear","expand","fullscreen","sound","history","language","theme","textSize","close"],st=e=>e!=="false",cd=e=>e.split(",").map(t=>t.trim()).filter(Boolean),dd=[["public-key","publicKey"],["ai-agent-deployment-id","aiAgentDeploymentId"],["base-url","baseUrl"],["agent-api-base-url","agentApiBaseUrl"],["data-api-base-url","dataApiBaseUrl"],["theme","theme",e=>e]],_d=[["mode","mode",e=>e],["position","position",e=>e],["iframe","iframe",st]],ud=[["width","width"],["height","height"]],pd=[["response-mode","responseMode",e=>e],["start-minimized","startMinimized",st],["show-reasoning","showReasoning",st],["show-tool-calls","showToolCalls",st],["show-sources","showSources",st]],fd=[["locale","locale"]],mf=new Set(ld);var md=[["launcher-variant","variant",e=>e],["launcher-size","size",e=>e],["launcher-icon","icon"],["launcher-hidden","hidden",st]],gd=[["features-files","files",st],["features-voice","voice",e=>e],["features-tools","tools",cd]],hd=[["endpoint-upload","upload"],["endpoint-transcribe","transcribe"]],vd=[["user-id","id"],["user-email","email"],["user-name","name"]],bd=[["page-area","area"],["page-url","url"],["page-path","path"],["page-title","title"]],xd=["launcher-label","callout-text","callout-delay","actions-main","actions-overflow","user-context","page-context"],Pd=[dd,_d,ud,pd,fd,md,gd,hd,vd,bd],yd=new Set(["iframe","start-minimized"]),Sd=[...Pd.flatMap(e=>e.map(([t])=>t).filter(t=>!yd.has(t))),...xd];function Zi(e){return`${x.cssPrefix}:${e}`}function Zt(e,t,n){e.dispatchEvent(new CustomEvent(Zi(t),{detail:n}))}function ea(e,t){let r=Object.entries(t).map(([i,a])=>{let l=Zi(i),s=c=>a(c.detail);return e.addEventListener(l,s),[l,s]});return()=>{for(let[i,a]of r)e.removeEventListener(i,a)}}function Ne(){let e=Date.now(),t=new Uint8Array(16);t[0]=Math.floor(e/2**40)&255,t[1]=Math.floor(e/2**32)&255,t[2]=e>>>24&255,t[3]=e>>>16&255,t[4]=e>>>8&255,t[5]=e&255,wd(t.subarray(6)),t[6]=t[6]&15|112,t[8]=t[8]&63|128;let n=Array.from(t,r=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function wd(e){if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){crypto.getRandomValues(e);return}for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256)}var lt=B.scope("persistence");function Tt(e,t=Gn,n){let r=n?`${e}.${n}`:e,i=`${x.cssPrefix}.storageVersion`,a=t.get(i)??void 0,l=a?`.v${a}`:"",s=`${x.cssPrefix}.${r}${l}`,c=`${x.cssPrefix}${l}.visitorId`,d=`${s}.conversationId`,u=`${s}.userPrefs`,_=`${s}.panelOpen`,m=`${s}.panelSize`,f=`${s}.calloutDismissed`,g=`${s}.sidebarCollapsed`,S=`${s}.activeModule`,h=`${s}.historyCount`,v=`${s}.formsDone`,C={getVisitorId(){let b=t.get(c);if(b)return b;let E=Ne();return t.set(c,E),E},setVisitorId(b){lt.debug("setVisitorId (rebind)",{id:b,scope:r}),t.set(c,b)},loadConversationId(){return t.get(d)??void 0},saveConversationId(b){lt.trace("saveConversationId",{id:b,scope:r}),b?t.set(d,b):t.remove(d)},loadUserPrefs(){let b=t.get(u);if(!b)return{};try{let E=JSON.parse(b);return ta(E)?E:{}}catch(E){return lt.warn("loadUserPrefs parse failed",{error:E}),{}}},saveUserPrefs(b){try{t.set(u,JSON.stringify(b))}catch(E){lt.warn("saveUserPrefs serialise failed",{error:E})}},patchUserPrefs(b){let E=C.loadUserPrefs();C.saveUserPrefs({...E,...b})},loadPanelOpen(){let b=t.get(_);return b==="1"?!0:b==="0"?!1:null},savePanelOpen(b){t.set(_,b?"1":"0")},loadPanelSize(){let b=t.get(m);return b==="normal"||b==="expanded"||b==="fullscreen"?b:null},savePanelSize(b){t.set(m,b)},loadCalloutDismissed(b){if(!b)return!1;let E=t.get(f);return!!E&&E===b},saveCalloutDismissed(b){b?t.set(f,b):t.remove(f)},loadSidebarCollapsed(){let b=t.get(g);return b==="1"?!0:b==="0"?!1:null},saveSidebarCollapsed(b){t.set(g,b?"1":"0")},loadActiveModule(){return t.get(S)||null},saveActiveModule(b){t.set(S,b)},loadHistoryCount(){let b=t.get(h);if(!b)return null;let E=Number.parseInt(b,10);return Number.isFinite(E)&&E>=0?E:null},saveHistoryCount(b){t.set(h,String(b))},loadFormsDone(){let b=t.get(v);if(!b)return{};try{let E=JSON.parse(b);return ta(E)?E:{}}catch(E){return lt.warn("loadFormsDone parse failed",{error:E}),{}}},saveFormDone(b){try{let E=C.loadFormsDone();E[b]=Date.now(),t.set(v,JSON.stringify(E))}catch(E){lt.warn("saveFormDone serialise failed",{error:E})}},rememberStorageVersion(b){b&&b!==t.get(i)&&(lt.debug("rememberStorageVersion (force-reset on next load)",{version:b}),t.set(i,b))},clearConversation(){t.remove(d)}};return C}function ta(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var na=`:host{--__P__-accent-user: __BRAND_ACCENT__;--__P__-accent: var(--__P__-accent-user);--__P__-accent-text-user: __BRAND_ACCENT_TEXT__;--__P__-accent-text: var(--__P__-accent-text-user);--__P__-radius: __BRAND_RADIUS__;--__P__-radius-sm: 8px;--__P__-radius-md: 10px;--__P__-radius-lg: 16px;--__P__-font: __BRAND_FONT__;--__P__-font-display: var(--__P__-font);--__P__-font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;--__P__-bg: oklch(1 0 0);--__P__-bg-elevated: oklch(.9789 .0029 278.3);--__P__-surface: var(--__P__-bg-elevated);--__P__-muted: var(--__P__-fg-muted);--__P__-hover: oklch(.1686 .011 278.3 / .06);--__P__-fg: oklch(.1686 .011 278.3);--__P__-fg-muted: oklch(.4932 .0301 278.3);--__P__-border: oklch(.9312 .0084 278.3);--__P__-border-strong: oklch(.8757 .0131 278.3);--__P__-bubble-user: var(--__P__-accent);--__P__-bubble-user-text: var(--__P__-accent-text);--__P__-bubble-assistant: oklch(.9638 .0058 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-on-accent: var(--__P__-accent-text);--__P__-success: oklch(.6456 .1654 151.53);--__P__-warning: oklch(.7135 .1494 74.05);--__P__-danger: oklch(.5966 .1818 24.51);--__P__-danger-text: oklch(.5054 .1905 27.52);--__P__-danger-bg: oklch(.5966 .1818 24.51 / .1);--__P__-neutral: oklch(.7137 .0192 278.3);--__P__-focus: var(--__P__-accent);--__P__-shadow-panel: 0 8px 24px -8px rgba(13, 15, 20, .18), 0 24px 64px -24px rgba(13, 15, 20, .24);--__P__-shadow-card: 0 1px 2px rgba(13, 15, 20, .06), 0 4px 12px -6px rgba(13, 15, 20, .12);--__P__-backdrop: oklch(.1686 .011 278.3 / .55);--__P__-shadow-fab: 0 6px 16px -4px color-mix(in oklch, var(--__P__-accent) 45%, transparent), 0 12px 32px -12px rgba(13, 15, 20, .25);--__P__-z-fab: 2147483600;--__P__-z-panel: 2147483601;--__P__-panel-w: 380px;--__P__-panel-h: 600px;--__P__-fab-size: 56px;--__P__-space-1: 4px;--__P__-space-2: 8px;--__P__-space-3: 12px;--__P__-space-4: 16px;--__P__-space-5: 20px;--__P__-space-6: 24px;--__P__-space-8: 32px;--__P__-text-scale: 1;--__P__-text-xs: calc(12px * var(--__P__-text-scale));--__P__-text-sm: calc(13px * var(--__P__-text-scale));--__P__-text-base: calc(15px * var(--__P__-text-scale));--__P__-text-md: calc(16px * var(--__P__-text-scale));--__P__-text-lg: calc(18px * var(--__P__-text-scale));--__P__-text-xl: calc(22px * var(--__P__-text-scale));--__P__-text-2xl: calc(30px * var(--__P__-text-scale))}:host([data-text-size="small"]){--__P__-text-scale: .9}:host([data-text-size="large"]){--__P__-text-scale: 1.15}:host{--__P__-ease: cubic-bezier(.2, .7, .2, 1);--__P__-ease-out: cubic-bezier(.2, .7, .2, 1);--__P__-ease-in: cubic-bezier(.4, 0, 1, 1);--__P__-ease-in-out: cubic-bezier(.65, 0, .35, 1);--__P__-dur-quick: .12s;--__P__-dur-base: .22s;--__P__-dur-slow: .32s;font-family:var(--__P__-font);color:var(--__P__-fg);color-scheme:light;--__P__-color-scheme: light}:host([data-theme="dark"]){--__P__-bg: oklch(.1783 .0128 278.3);--__P__-bg-elevated: oklch(.2232 .0182 278.3);--__P__-fg: oklch(.9368 .01 278.3);--__P__-fg-muted: oklch(.7048 .0296 278.3);--__P__-border: oklch(.2752 .0266 278.3);--__P__-border-strong: oklch(.335 .0291 278.3);--__P__-hover: oklch(.9368 .01 278.3 / .08);--__P__-bubble-assistant: oklch(.2474 .0311 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-danger-text: oklch(.8077 .1035 19.57);--__P__-danger-bg: oklch(.5966 .1818 24.51 / .18);--__P__-shadow-panel: 0 8px 24px -8px rgba(0, 0, 0, .6), 0 24px 64px -24px rgba(0, 0, 0, .7);--__P__-shadow-card: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px -6px rgba(0, 0, 0, .5);--__P__-backdrop: rgba(0, 0, 0, .65);color-scheme:dark;--__P__-color-scheme: dark}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-bg: oklch(.1783 .0128 278.3);--__P__-bg-elevated: oklch(.2232 .0182 278.3);--__P__-fg: oklch(.9368 .01 278.3);--__P__-fg-muted: oklch(.7048 .0296 278.3);--__P__-border: oklch(.2752 .0266 278.3);--__P__-border-strong: oklch(.335 .0291 278.3);--__P__-hover: oklch(.9368 .01 278.3 / .08);--__P__-bubble-assistant: oklch(.2474 .0311 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-shadow-panel: 0 8px 24px -8px rgba(0, 0, 0, .6), 0 24px 64px -24px rgba(0, 0, 0, .7);color-scheme:dark;--__P__-color-scheme: dark}}@supports (color: oklch(from red l c h)){:host{--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.3, l, .62) c h);--__P__-accent-text: oklch(from var(--__P__-accent) clamp(0, (l / .623 - 1) * -infinity, 1) 0 h)}:host([data-theme="dark"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h)}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h)}}}@media(prefers-reduced-motion:reduce){:host{--__P__-dur-quick: 1ms;--__P__-dur-base: 1ms;--__P__-dur-slow: 1ms}}
1
+ "use strict";var Ln=Object.defineProperty;var kc=Object.getOwnPropertyDescriptor;var Cc=Object.getOwnPropertyNames;var Tc=Object.prototype.hasOwnProperty;var Ec=(e,t,n)=>t in e?Ln(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ic=(e,t)=>{for(var n in t)Ln(e,n,{get:t[n],enumerable:!0})},Rc=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Cc(t))!Tc.call(e,i)&&i!==n&&Ln(e,i,{get:()=>t[i],enumerable:!(r=kc(t,i))||r.enumerable});return e};var Ac=e=>Rc(Ln({},"__esModule",{value:!0}),e);var J=(e,t,n)=>Ec(e,typeof t!="symbol"?t+"":t,n);var Up={};Ic(Up,{HOOK_WILDCARD:()=>Ur,brand:()=>zp,destroy:()=>Op,getAllInstances:()=>Hp,getInstance:()=>$p,hook:()=>Bp,init:()=>Dp,mount:()=>Ql,resolveInitialHostMode:()=>zr,version:()=>Fp});module.exports=Ac(Up);var Bn,X,Ci,ao,Ze,yi,Ti,Ei,no,Nn,Jt,Ii,so,ro,oo,Lc,On={},$n=[],Mc=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Fn=Array.isArray;function je(e,t){for(var n in t)e[n]=t[n];return e}function lo(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function zn(e,t,n){var r,i,a,l={};for(a in t)a=="key"?r=t[a]:a=="ref"?i=t[a]:l[a]=t[a];if(arguments.length>2&&(l.children=arguments.length>3?Bn.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(a in e.defaultProps)l[a]===void 0&&(l[a]=e.defaultProps[a]);return Dn(e,l,r,i,null)}function Dn(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Ci,__i:-1,__u:0};return i==null&&X.vnode!=null&&X.vnode(a),a}function re(e){return e.children}function et(e,t){this.props=e,this.context=t}function yt(e,t){if(t==null)return e.__?yt(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?yt(e):null}function Nc(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=je({},t);a.__v=t.__v+1,X.vnode&&X.vnode(a),co(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??yt(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,Mi(r,a,i),t.__e=t.__=null,a.__e!=n&&Ri(a)}}function Ri(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),Ri(e)}function Si(e){(!e.__d&&(e.__d=!0)&&Ze.push(e)&&!Hn.__r++||yi!=X.debounceRendering)&&((yi=X.debounceRendering)||Ti)(Hn)}function Hn(){try{for(var e,t=1;Ze.length;)Ze.length>t&&Ze.sort(Ei),e=Ze.shift(),t=Ze.length,Nc(e)}finally{Ze.length=Hn.__r=0}}function Ai(e,t,n,r,i,a,l,s,c,d,u){var _,m,f,g,S,h,v,C=r&&r.__k||$n,b=t.length;for(c=Dc(n,t,C,c,b),_=0;_<b;_++)(f=n.__k[_])!=null&&(m=f.__i!=-1&&C[f.__i]||On,f.__i=_,h=co(e,f,m,i,a,l,s,c,d,u),g=f.__e,f.ref&&m.ref!=f.ref&&(m.ref&&_o(m.ref,null,f),u.push(f.ref,f.__c||g,f)),S==null&&g!=null&&(S=g),(v=!!(4&f.__u))||m.__k===f.__k?(c=Li(f,c,e,v),v&&m.__e&&(m.__e=null)):typeof f.type=="function"&&h!==void 0?c=h:g&&(c=g.nextSibling),f.__u&=-7);return n.__e=S,c}function Dc(e,t,n,r,i){var a,l,s,c,d,u=n.length,_=u,m=0;for(e.__k=new Array(i),a=0;a<i;a++)(l=t[a])!=null&&typeof l!="boolean"&&typeof l!="function"?(typeof l=="string"||typeof l=="number"||typeof l=="bigint"||l.constructor==String?l=e.__k[a]=Dn(null,l,null,null,null):Fn(l)?l=e.__k[a]=Dn(re,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=e.__k[a]=Dn(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):e.__k[a]=l,c=a+m,l.__=e,l.__b=e.__b+1,s=null,(d=l.__i=Oc(l,n,c,_))!=-1&&(_--,(s=n[d])&&(s.__u|=2)),s==null||s.__v==null?(d==-1&&(i>u?m--:i<u&&m++),typeof l.type!="function"&&(l.__u|=4)):d!=c&&(d==c-1?m--:d==c+1?m++:(d>c?m--:m++,l.__u|=4))):e.__k[a]=null;if(_)for(a=0;a<u;a++)(s=n[a])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=yt(s)),Di(s,s));return r}function Li(e,t,n,r){var i,a;if(typeof e.type=="function"){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=Li(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=yt(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Oc(e,t,n,r){var i,a,l,s=e.key,c=e.type,d=t[n],u=d!=null&&(2&d.__u)==0;if(d===null&&s==null||u&&s==d.key&&c==d.type)return n;if(r>(u?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((d=t[l=i>=0?i--:a++])!=null&&(2&d.__u)==0&&s==d.key&&c==d.type)return l}return-1}function wi(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||Mc.test(t)?n:n+"px"}function Mn(e,t,n,r,i){var a,l;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||wi(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||wi(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")a=t!=(t=t.replace(Ii,"$1")),l=t.toLowerCase(),t=l in e||t=="onFocusOut"||t=="onFocusIn"?l.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n[Jt]=r[Jt]:(n[Jt]=so,e.addEventListener(t,a?oo:ro,a)):e.removeEventListener(t,a?oo:ro,a);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function ki(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[Nn]==null)t[Nn]=so++;else if(t[Nn]<n[Jt])return;return n(X.event?X.event(t):t)}}}function co(e,t,n,r,i,a,l,s,c,d){var u,_,m,f,g,S,h,v,C,b,E,D,V,G,ae,K=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=X.__b)&&u(t);e:if(typeof K=="function")try{if(v=t.props,C=K.prototype&&K.prototype.render,b=(u=K.contextType)&&r[u.__c],E=u?b?b.props.value:u.__:r,n.__c?h=(_=t.__c=n.__c).__=_.__E:(C?t.__c=_=new K(v,E):(t.__c=_=new et(v,E),_.constructor=K,_.render=Hc),b&&b.sub(_),_.state||(_.state={}),_.__n=r,m=_.__d=!0,_.__h=[],_._sb=[]),C&&_.__s==null&&(_.__s=_.state),C&&K.getDerivedStateFromProps!=null&&(_.__s==_.state&&(_.__s=je({},_.__s)),je(_.__s,K.getDerivedStateFromProps(v,_.__s))),f=_.props,g=_.state,_.__v=t,m)C&&K.getDerivedStateFromProps==null&&_.componentWillMount!=null&&_.componentWillMount(),C&&_.componentDidMount!=null&&_.__h.push(_.componentDidMount);else{if(C&&K.getDerivedStateFromProps==null&&v!==f&&_.componentWillReceiveProps!=null&&_.componentWillReceiveProps(v,E),t.__v==n.__v||!_.__e&&_.shouldComponentUpdate!=null&&_.shouldComponentUpdate(v,_.__s,E)===!1){t.__v!=n.__v&&(_.props=v,_.state=_.__s,_.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(U){U&&(U.__=t)}),$n.push.apply(_.__h,_._sb),_._sb=[],_.__h.length&&l.push(_);break e}_.componentWillUpdate!=null&&_.componentWillUpdate(v,_.__s,E),C&&_.componentDidUpdate!=null&&_.__h.push(function(){_.componentDidUpdate(f,g,S)})}if(_.context=E,_.props=v,_.__P=e,_.__e=!1,D=X.__r,V=0,C)_.state=_.__s,_.__d=!1,D&&D(t),u=_.render(_.props,_.state,_.context),$n.push.apply(_.__h,_._sb),_._sb=[];else do _.__d=!1,D&&D(t),u=_.render(_.props,_.state,_.context),_.state=_.__s;while(_.__d&&++V<25);_.state=_.__s,_.getChildContext!=null&&(r=je(je({},r),_.getChildContext())),C&&!m&&_.getSnapshotBeforeUpdate!=null&&(S=_.getSnapshotBeforeUpdate(f,g)),G=u!=null&&u.type===re&&u.key==null?Ni(u.props.children):u,s=Ai(e,Fn(G)?G:[G],t,n,r,i,a,l,s,c,d),_.base=t.__e,t.__u&=-161,_.__h.length&&l.push(_),h&&(_.__E=_.__=null)}catch(U){if(t.__v=null,c||a!=null)if(U.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(ae=a.length;ae--;)lo(a[ae]);io(t)}else t.__e=n.__e,t.__k=n.__k,U.then||io(t);X.__e(U,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=$c(n.__e,t,n,r,i,a,l,c,d);return(u=X.diffed)&&u(t),128&t.__u?void 0:s}function io(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(io))}function Mi(e,t,n){for(var r=0;r<n.length;r++)_o(n[r],n[++r],n[++r]);X.__c&&X.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){X.__e(a,i.__v)}})}function Ni(e){return typeof e!="object"||e==null||e.__b>0?e:Fn(e)?e.map(Ni):e.constructor!==void 0?null:je({},e)}function $c(e,t,n,r,i,a,l,s,c){var d,u,_,m,f,g,S,h=n.props||On,v=t.props,C=t.type;if(C=="svg"?i="http://www.w3.org/2000/svg":C=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),a!=null){for(d=0;d<a.length;d++)if((f=a[d])&&"setAttribute"in f==!!C&&(C?f.localName==C:f.nodeType==3)){e=f,a[d]=null;break}}if(e==null){if(C==null)return document.createTextNode(v);e=document.createElementNS(i,C,v.is&&v),s&&(X.__m&&X.__m(t,a),s=!1),a=null}if(C==null)h===v||s&&e.data==v||(e.data=v);else{if(a=C=="textarea"&&v.defaultValue!=null?null:a&&Bn.call(e.childNodes),!s&&a!=null)for(h={},d=0;d<e.attributes.length;d++)h[(f=e.attributes[d]).name]=f.value;for(d in h)f=h[d],d=="dangerouslySetInnerHTML"?_=f:d=="children"||d in v||d=="value"&&"defaultValue"in v||d=="checked"&&"defaultChecked"in v||Mn(e,d,null,f,i);for(d in v)f=v[d],d=="children"?m=f:d=="dangerouslySetInnerHTML"?u=f:d=="value"?g=f:d=="checked"?S=f:s&&typeof f!="function"||h[d]===f||Mn(e,d,f,h[d],i);if(u)s||_&&(u.__html==_.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(_&&(e.innerHTML=""),Ai(t.type=="template"?e.content:e,Fn(m)?m:[m],t,n,r,C=="foreignObject"?"http://www.w3.org/1999/xhtml":i,a,l,a?a[0]:n.__k&&yt(n,0),s,c),a!=null)for(d=a.length;d--;)lo(a[d]);s&&C!="textarea"||(d="value",C=="progress"&&g==null?e.removeAttribute("value"):g!=null&&(g!==e[d]||C=="progress"&&!g||C=="option"&&g!=h[d])&&Mn(e,d,g,h[d],i),d="checked",S!=null&&S!=e[d]&&Mn(e,d,S,h[d],i))}return e}function _o(e,t,n){try{if(typeof e=="function"){var r=typeof e.__u=="function";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){X.__e(i,n)}}function Di(e,t,n){var r,i;if(X.unmount&&X.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||_o(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){X.__e(a,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Di(r[i],t,n||typeof e.type!="function");n||lo(e.__e),e.__c=e.__=e.__e=void 0}function Hc(e,t,n){return this.constructor(e,n)}function Un(e,t,n){var r,i,a,l;t==document&&(t=document.documentElement),X.__&&X.__(e,t),i=(r=typeof n=="function")?null:n&&n.__k||t.__k,a=[],l=[],co(t,e=(!r&&n||t).__k=zn(re,null,[e]),i||On,On,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Bn.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,l),Mi(a,e,l)}Bn=$n.slice,X={__e:function(e,t,n,r){for(var i,a,l;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),l=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),l=i.__d),l)return i.__E=i}catch(s){e=s}throw e}},Ci=0,ao=function(e){return e!=null&&e.constructor===void 0},et.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=je({},this.state),typeof e=="function"&&(e=e(je({},n),this.props)),e&&je(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Si(this))},et.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Si(this))},et.prototype.render=re,Ze=[],Ti=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ei=function(e,t){return e.__v.__b-t.__v.__b},Hn.__r=0,no=Math.random().toString(8),Nn="__d"+no,Jt="__a"+no,Ii=/(PointerCapture)$|Capture$/i,so=0,ro=ki(!1),oo=ki(!0),Lc=0;var x={id:"help-ai",name:"@helpai/elements",global:"HelpAI",tagName:"web-ai-chat",cssPrefix:"helpai",defaultBaseUrl:"https://help.ai",displayName:"Help AI",domain:"help.ai",siteUrl:"https://help.ai"};var St="0.47.1";var Oi={attach:"Attach files",attachmentMimeRejected:"File type not supported",attachmentTooLarge:"File is too large",attachmentTooMany:"Attachment limit reached",conversationClosed:"This conversation is closed",conversationLoading:"Loading conversation\u2026",close:"Close",collapse:"Collapse",collapseSidebar:"Collapse sidebar",composerPlaceholder:"Type a message\u2026",dateLastWeek:"Last 7 days",dateOlder:"Older",dateToday:"Today",dateYesterday:"Yesterday",dropZone:"Drop files to attach",errorGeneric:"Something went wrong",errorRateLimited:"Too many requests \u2014 please try again in a moment.",errorRetry:"Retry",expand:"Expand",expandSidebar:"Expand sidebar",exitFullscreen:"Exit fullscreen",fullscreen:"Fullscreen",history:"History",historyBack:"Back to chat",historyEmpty:"No previous conversations yet",historyLoading:"Loading your conversations\u2026",historyContinue:"Continue the conversation",historyTitle:"Conversation history",language:"Language",launcherOpen:"Open chat",launcherLabel:"Chat with us",micStart:"Start voice input",micStop:"Stop voice input",micUnsupported:"Voice input is not supported in this browser",moreActions:"More actions",newConversation:"New conversation",panelTitle:"Chat",resizeHandle:"Drag to resize",scrollToBottom:"Scroll to latest",send:"Send",soundOff:"Sound off",soundOn:"Sound on",startNewConversation:"Start a new conversation",stop:"Stop",theme:"Theme",themeAuto:"Auto",themeDark:"Dark",themeLight:"Light",textSize:"Text size",textSizeSmall:"Small",textSizeNormal:"Normal",textSizeLarge:"Large",loading:"Loading\u2026",thinking:"Thinking\u2026",thoughts:"Thoughts",usedTool:"Used tool",toolResult:"Result",sources:"Sources",tabHome:"Home",tabConversations:"Conversations",tabHelp:"Help",tabNews:"News",modulesEmpty:"Nothing here yet",moduleBack:"Back",contentLoading:"Loading\u2026",homeGreeting:"How can we help?",homeGreetingNamed:"Hi {name} \u{1F44B}",homeGreetingLead:"How can we help?",homeSearchPlaceholder:"Search for help",homeContentTitle:"Popular articles",homeStatus:"Status",helpTitle:"Help",helpSearchPlaceholder:"Search for help",helpEmpty:"No help articles yet",helpLoading:"Loading help\u2026",helpSearchEmpty:"No results found",newsTitle:"News",newsEmpty:"No news yet",newsLoading:"Loading news\u2026",newsBack:"Back to news",newsPublishedAt:"Published {date}",formSubmit:"Submit",formSkip:"Maybe later",formSubmitted:"Completed",formSkipped:"Maybe later",formFillOut:"Fill out",formRequired:"This field is required",formInvalidEmail:"Enter a valid email address",formInvalidTel:"Enter a valid phone number",formInvalidUrl:"Enter a valid URL",formInvalidNumber:"Enter a valid number",formTooShort:"Too short (min {min} characters)",formTooLong:"Too long (max {max} characters)",formNumberTooSmall:"Must be at least {min}",formNumberTooLarge:"Must be at most {max}",formPatternMismatch:"Please match the requested format",formChooseAtLeast:"Choose at least {min}",formChooseAtMost:"Choose at most {max}",formOther:"Other",formOtherPlaceholder:"Type your answer\u2026",inputRequired:"User Input Required",inputBadge:"User Input",inputAnswered:"Answered",inputSkipped:"Skipped",inputQuestion:"Question",inputResponse:"Response",inputYourAnswer:"Your answer",inputSubmit:"Submit answer",inputSubmitHint:"Enter to submit \xB7 Shift+Enter for new line",inputSkip:"Skip",inputSubmitted:"Answer submitted",respFreeText:"Free Text",respSingleChoice:"Single Choice",respMultiChoice:"Multiple Choice",respConfirmation:"Confirmation",approvalRequired:"Approval required",approve:"Approve",reject:"Reject",approved:"Approved",rejected:"Rejected",approvalReason:"Add a reason (optional)",stepNoLongerActive:"This request is no longer active.",toolParameters:"Parameters",statusCompleted:"Completed",statusDenied:"Denied",statusError:"Error"},Bc={attach:"Joindre des fichiers",attachmentMimeRejected:"Type de fichier non pris en charge",attachmentTooLarge:"Le fichier est trop volumineux",attachmentTooMany:"Limite de pi\xE8ces jointes atteinte",conversationClosed:"Cette conversation est ferm\xE9e",conversationLoading:"Chargement de la conversation\u2026",close:"Fermer",collapse:"R\xE9duire",collapseSidebar:"R\xE9duire la barre lat\xE9rale",composerPlaceholder:"\xC9crivez un message\u2026",dateLastWeek:"7 derniers jours",dateOlder:"Plus ancien",dateToday:"Aujourd'hui",dateYesterday:"Hier",dropZone:"D\xE9posez les fichiers \xE0 joindre",errorGeneric:"Une erreur s'est produite",errorRateLimited:"Trop de requ\xEAtes \u2014 veuillez r\xE9essayer dans un instant.",errorRetry:"R\xE9essayer",expand:"Agrandir",expandSidebar:"D\xE9velopper la barre lat\xE9rale",exitFullscreen:"Quitter le plein \xE9cran",fullscreen:"Plein \xE9cran",history:"Historique",historyBack:"Retour au chat",historyEmpty:"Aucune conversation pour le moment",historyContinue:"Poursuivre la conversation",historyLoading:"Chargement de vos conversations\u2026",historyTitle:"Historique des conversations",language:"Langue",launcherOpen:"Ouvrir le chat",launcherLabel:"Discuter avec nous",micStart:"D\xE9marrer la saisie vocale",micStop:"Arr\xEAter la saisie vocale",micUnsupported:"La saisie vocale n'est pas prise en charge par ce navigateur",moreActions:"Plus d'actions",newConversation:"Nouvelle conversation",panelTitle:"Chat",resizeHandle:"Glisser pour redimensionner",scrollToBottom:"Aller au plus r\xE9cent",send:"Envoyer",soundOff:"Son d\xE9sactiv\xE9",soundOn:"Son activ\xE9",startNewConversation:"D\xE9marrer une nouvelle conversation",stop:"Arr\xEAter",theme:"Th\xE8me",themeAuto:"Auto",themeDark:"Sombre",themeLight:"Clair",textSize:"Taille du texte",textSizeSmall:"Petite",textSizeNormal:"Normale",textSizeLarge:"Grande",loading:"Chargement\u2026",thinking:"R\xE9flexion\u2026",thoughts:"R\xE9flexions",usedTool:"Outil utilis\xE9",toolResult:"R\xE9sultat",sources:"Sources",tabHome:"Accueil",tabConversations:"Conversations",tabHelp:"Aide",tabNews:"Actualit\xE9s",modulesEmpty:"Rien pour le moment",moduleBack:"Retour",contentLoading:"Chargement\u2026",homeGreeting:"Comment pouvons-nous vous aider ?",homeGreetingNamed:"Bonjour {name} \u{1F44B}",homeGreetingLead:"Comment pouvons-nous vous aider ?",homeSearchPlaceholder:"Rechercher de l'aide",homeContentTitle:"Articles populaires",homeStatus:"Statut",helpTitle:"Aide",helpSearchPlaceholder:"Rechercher de l'aide",helpEmpty:"Aucun article d'aide pour le moment",helpLoading:"Chargement de l'aide\u2026",helpSearchEmpty:"Aucun r\xE9sultat trouv\xE9",newsTitle:"Actualit\xE9s",newsEmpty:"Aucune actualit\xE9 pour le moment",newsLoading:"Chargement des actualit\xE9s\u2026",newsBack:"Retour aux actualit\xE9s",newsPublishedAt:"Publi\xE9 le {date}",formSubmit:"Envoyer",formSkip:"Plus tard",formSubmitted:"Termin\xE9",formSkipped:"Plus tard",formFillOut:"Remplir",formRequired:"Ce champ est obligatoire",formInvalidEmail:"Saisissez une adresse e-mail valide",formInvalidTel:"Saisissez un num\xE9ro de t\xE9l\xE9phone valide",formInvalidUrl:"Saisissez une URL valide",formInvalidNumber:"Saisissez un nombre valide",formTooShort:"Trop court (min. {min} caract\xE8res)",formTooLong:"Trop long (max. {max} caract\xE8res)",formNumberTooSmall:"Doit \xEAtre au moins {min}",formNumberTooLarge:"Doit \xEAtre au plus {max}",formPatternMismatch:"Veuillez respecter le format demand\xE9",formChooseAtLeast:"Choisissez au moins {min}",formChooseAtMost:"Choisissez au plus {max}",formOther:"Autre",formOtherPlaceholder:"Saisissez votre r\xE9ponse\u2026",inputRequired:"Saisie requise",inputBadge:"Saisie",inputAnswered:"R\xE9pondu",inputSkipped:"Ignor\xE9",inputQuestion:"Question",inputResponse:"R\xE9ponse",inputYourAnswer:"Votre r\xE9ponse",inputSubmit:"Envoyer la r\xE9ponse",inputSubmitHint:"Entr\xE9e pour envoyer \xB7 Maj+Entr\xE9e pour un saut de ligne",inputSkip:"Ignorer",inputSubmitted:"R\xE9ponse envoy\xE9e",respFreeText:"Texte libre",respSingleChoice:"Choix unique",respMultiChoice:"Choix multiple",respConfirmation:"Confirmation",approvalRequired:"Approbation requise",approve:"Approuver",reject:"Refuser",approved:"Approuv\xE9",rejected:"Refus\xE9",approvalReason:"Ajouter une raison (facultatif)",stepNoLongerActive:"Cette demande n'est plus active.",toolParameters:"Param\xE8tres",statusCompleted:"Termin\xE9",statusDenied:"Refus\xE9",statusError:"Erreur"},Fc={attach:"\u0625\u0631\u0641\u0627\u0642 \u0645\u0644\u0641\u0627\u062A",attachmentMimeRejected:"\u0646\u0648\u0639 \u0627\u0644\u0645\u0644\u0641 \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645",attachmentTooLarge:"\u062D\u062C\u0645 \u0627\u0644\u0645\u0644\u0641 \u0643\u0628\u064A\u0631 \u062C\u062F\u064B\u0627",attachmentTooMany:"\u062A\u0645 \u0628\u0644\u0648\u063A \u0627\u0644\u062D\u062F \u0627\u0644\u0623\u0642\u0635\u0649 \u0644\u0644\u0645\u0631\u0641\u0642\u0627\u062A",conversationClosed:"\u062A\u0645 \u0625\u063A\u0644\u0627\u0642 \u0647\u0630\u0647 \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",conversationLoading:"\u062C\u0627\u0631\u064D \u062A\u062D\u0645\u064A\u0644 \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629\u2026",close:"\u0625\u063A\u0644\u0627\u0642",collapse:"\u0637\u064A\u0651",collapseSidebar:"\u0637\u064A\u0651 \u0627\u0644\u0634\u0631\u064A\u0637 \u0627\u0644\u062C\u0627\u0646\u0628\u064A",composerPlaceholder:"\u0627\u0643\u062A\u0628 \u0631\u0633\u0627\u0644\u0629\u2026",dateLastWeek:"\u0622\u062E\u0631 \u0667 \u0623\u064A\u0627\u0645",dateOlder:"\u0623\u0642\u062F\u0645",dateToday:"\u0627\u0644\u064A\u0648\u0645",dateYesterday:"\u0623\u0645\u0633",dropZone:"\u0623\u0641\u0644\u062A \u0627\u0644\u0645\u0644\u0641\u0627\u062A \u0644\u0625\u0631\u0641\u0627\u0642\u0647\u0627",errorGeneric:"\u062D\u062F\u062B \u062E\u0637\u0623 \u0645\u0627",errorRateLimited:"\u0637\u0644\u0628\u0627\u062A \u0643\u062B\u064A\u0631\u0629 \u062C\u062F\u064B\u0627 \u2014 \u064A\u0631\u062C\u0649 \u0627\u0644\u0645\u062D\u0627\u0648\u0644\u0629 \u0628\u0639\u062F \u0644\u062D\u0638\u0629.",errorRetry:"\u0625\u0639\u0627\u062F\u0629 \u0627\u0644\u0645\u062D\u0627\u0648\u0644\u0629",expand:"\u062A\u0648\u0633\u064A\u0639",expandSidebar:"\u062A\u0648\u0633\u064A\u0639 \u0627\u0644\u0634\u0631\u064A\u0637 \u0627\u0644\u062C\u0627\u0646\u0628\u064A",exitFullscreen:"\u0625\u0646\u0647\u0627\u0621 \u0645\u0644\u0621 \u0627\u0644\u0634\u0627\u0634\u0629",fullscreen:"\u0645\u0644\u0621 \u0627\u0644\u0634\u0627\u0634\u0629",history:"\u0627\u0644\u0633\u062C\u0644",historyBack:"\u0627\u0644\u0639\u0648\u062F\u0629 \u0625\u0644\u0649 \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",historyEmpty:"\u0644\u0627 \u062A\u0648\u062C\u062F \u0645\u062D\u0627\u062F\u062B\u0627\u062A \u0633\u0627\u0628\u0642\u0629 \u0628\u0639\u062F",historyContinue:"\u0645\u062A\u0627\u0628\u0639\u0629 \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",historyLoading:"\u062C\u0627\u0631\u064D \u062A\u062D\u0645\u064A\u0644 \u0645\u062D\u0627\u062F\u062B\u0627\u062A\u0643\u2026",historyTitle:"\u0633\u062C\u0644 \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0627\u062A",language:"\u0627\u0644\u0644\u063A\u0629",launcherOpen:"\u0641\u062A\u062D \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",launcherLabel:"\u062A\u062D\u062F\u062B \u0645\u0639\u0646\u0627",micStart:"\u0628\u062F\u0621 \u0627\u0644\u0625\u062F\u062E\u0627\u0644 \u0627\u0644\u0635\u0648\u062A\u064A",micStop:"\u0625\u064A\u0642\u0627\u0641 \u0627\u0644\u0625\u062F\u062E\u0627\u0644 \u0627\u0644\u0635\u0648\u062A\u064A",micUnsupported:"\u0627\u0644\u0625\u062F\u062E\u0627\u0644 \u0627\u0644\u0635\u0648\u062A\u064A \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645 \u0641\u064A \u0647\u0630\u0627 \u0627\u0644\u0645\u062A\u0635\u0641\u062D",moreActions:"\u0625\u062C\u0631\u0627\u0621\u0627\u062A \u0625\u0636\u0627\u0641\u064A\u0629",newConversation:"\u0645\u062D\u0627\u062F\u062B\u0629 \u062C\u062F\u064A\u062F\u0629",panelTitle:"\u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",resizeHandle:"\u0627\u0633\u062D\u0628 \u0644\u062A\u063A\u064A\u064A\u0631 \u0627\u0644\u062D\u062C\u0645",scrollToBottom:"\u0627\u0644\u0627\u0646\u062A\u0642\u0627\u0644 \u0625\u0644\u0649 \u0627\u0644\u0623\u062D\u062F\u062B",send:"\u0625\u0631\u0633\u0627\u0644",soundOff:"\u0643\u062A\u0645 \u0627\u0644\u0635\u0648\u062A",soundOn:"\u062A\u0634\u063A\u064A\u0644 \u0627\u0644\u0635\u0648\u062A",startNewConversation:"\u0628\u062F\u0621 \u0645\u062D\u0627\u062F\u062B\u0629 \u062C\u062F\u064A\u062F\u0629",stop:"\u0625\u064A\u0642\u0627\u0641",theme:"\u0627\u0644\u0645\u0638\u0647\u0631",themeAuto:"\u062A\u0644\u0642\u0627\u0626\u064A",themeDark:"\u062F\u0627\u0643\u0646",themeLight:"\u0641\u0627\u062A\u062D",textSize:"\u062D\u062C\u0645 \u0627\u0644\u0646\u0635",textSizeSmall:"\u0635\u063A\u064A\u0631",textSizeNormal:"\u0639\u0627\u062F\u064A",textSizeLarge:"\u0643\u0628\u064A\u0631",loading:"\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u062D\u0645\u064A\u0644\u2026",thinking:"\u064A\u0641\u0643\u0631\u2026",thoughts:"\u0627\u0644\u0623\u0641\u0643\u0627\u0631",usedTool:"\u0623\u062F\u0627\u0629 \u0645\u064F\u0633\u062A\u062E\u062F\u064E\u0645\u0629",toolResult:"\u0627\u0644\u0646\u062A\u064A\u062C\u0629",sources:"\u0627\u0644\u0645\u0635\u0627\u062F\u0631",tabHome:"\u0627\u0644\u0631\u0626\u064A\u0633\u064A\u0629",tabConversations:"\u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0627\u062A",tabHelp:"\u0627\u0644\u0645\u0633\u0627\u0639\u062F\u0629",tabNews:"\u0627\u0644\u0623\u062E\u0628\u0627\u0631",modulesEmpty:"\u0644\u0627 \u0634\u064A\u0621 \u0647\u0646\u0627 \u0628\u0639\u062F",moduleBack:"\u0631\u062C\u0648\u0639",contentLoading:"\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u062D\u0645\u064A\u0644\u2026",homeGreeting:"\u0643\u064A\u0641 \u064A\u0645\u0643\u0646\u0646\u0627 \u0645\u0633\u0627\u0639\u062F\u062A\u0643\u061F",homeGreetingNamed:"\u0645\u0631\u062D\u0628\u064B\u0627 {name} \u{1F44B}",homeGreetingLead:"\u0643\u064A\u0641 \u064A\u0645\u0643\u0646\u0646\u0627 \u0645\u0633\u0627\u0639\u062F\u062A\u0643\u061F",homeSearchPlaceholder:"\u0627\u0628\u062D\u062B \u0639\u0646 \u0645\u0633\u0627\u0639\u062F\u0629",homeContentTitle:"\u0645\u0642\u0627\u0644\u0627\u062A \u0634\u0627\u0626\u0639\u0629",homeStatus:"\u0627\u0644\u062D\u0627\u0644\u0629",helpTitle:"\u0627\u0644\u0645\u0633\u0627\u0639\u062F\u0629",helpSearchPlaceholder:"\u0627\u0628\u062D\u062B \u0639\u0646 \u0645\u0633\u0627\u0639\u062F\u0629",helpEmpty:"\u0644\u0627 \u062A\u0648\u062C\u062F \u0645\u0642\u0627\u0644\u0627\u062A \u0645\u0633\u0627\u0639\u062F\u0629 \u0628\u0639\u062F",helpLoading:"\u062C\u0627\u0631\u064D \u062A\u062D\u0645\u064A\u0644 \u0627\u0644\u0645\u0633\u0627\u0639\u062F\u0629\u2026",helpSearchEmpty:"\u0644\u0627 \u062A\u0648\u062C\u062F \u0646\u062A\u0627\u0626\u062C",newsTitle:"\u0627\u0644\u0623\u062E\u0628\u0627\u0631",newsEmpty:"\u0644\u0627 \u062A\u0648\u062C\u062F \u0623\u062E\u0628\u0627\u0631 \u0628\u0639\u062F",newsLoading:"\u062C\u0627\u0631\u064D \u062A\u062D\u0645\u064A\u0644 \u0627\u0644\u0623\u062E\u0628\u0627\u0631\u2026",newsBack:"\u0627\u0644\u0639\u0648\u062F\u0629 \u0625\u0644\u0649 \u0627\u0644\u0623\u062E\u0628\u0627\u0631",newsPublishedAt:"\u0646\u064F\u0634\u0631 \u0641\u064A {date}",formSubmit:"\u0625\u0631\u0633\u0627\u0644",formSkip:"\u0644\u0627\u062D\u0642\u064B\u0627",formSubmitted:"\u062A\u0645",formSkipped:"\u0644\u0627\u062D\u0642\u064B\u0627",formFillOut:"\u062A\u0639\u0628\u0626\u0629",formRequired:"\u0647\u0630\u0627 \u0627\u0644\u062D\u0642\u0644 \u0645\u0637\u0644\u0648\u0628",formInvalidEmail:"\u0623\u062F\u062E\u0644 \u0628\u0631\u064A\u062F\u064B\u0627 \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A\u064B\u0627 \u0635\u062D\u064A\u062D\u064B\u0627",formInvalidTel:"\u0623\u062F\u062E\u0644 \u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0635\u062D\u064A\u062D\u064B\u0627",formInvalidUrl:"\u0623\u062F\u062E\u0644 \u0631\u0627\u0628\u0637\u064B\u0627 \u0635\u062D\u064A\u062D\u064B\u0627",formInvalidNumber:"\u0623\u062F\u062E\u0644 \u0631\u0642\u0645\u064B\u0627 \u0635\u062D\u064A\u062D\u064B\u0627",formTooShort:"\u0642\u0635\u064A\u0631 \u062C\u062F\u064B\u0627 (\u0627\u0644\u062D\u062F \u0627\u0644\u0623\u062F\u0646\u0649 {min} \u062D\u0631\u0641\u064B\u0627)",formTooLong:"\u0637\u0648\u064A\u0644 \u062C\u062F\u064B\u0627 (\u0627\u0644\u062D\u062F \u0627\u0644\u0623\u0642\u0635\u0649 {max} \u062D\u0631\u0641\u064B\u0627)",formNumberTooSmall:"\u064A\u062C\u0628 \u0623\u0644\u0627 \u064A\u0642\u0644 \u0639\u0646 {min}",formNumberTooLarge:"\u064A\u062C\u0628 \u0623\u0644\u0627 \u064A\u0632\u064A\u062F \u0639\u0646 {max}",formPatternMismatch:"\u064A\u0631\u062C\u0649 \u0645\u0637\u0627\u0628\u0642\u0629 \u0627\u0644\u0635\u064A\u063A\u0629 \u0627\u0644\u0645\u0637\u0644\u0648\u0628\u0629",formChooseAtLeast:"\u0627\u062E\u062A\u0631 {min} \u0639\u0644\u0649 \u0627\u0644\u0623\u0642\u0644",formChooseAtMost:"\u0627\u062E\u062A\u0631 {max} \u0639\u0644\u0649 \u0627\u0644\u0623\u0643\u062B\u0631",formOther:"\u0623\u062E\u0631\u0649",formOtherPlaceholder:"\u0627\u0643\u062A\u0628 \u0625\u062C\u0627\u0628\u062A\u0643\u2026",inputRequired:"\u0645\u0637\u0644\u0648\u0628 \u0625\u062F\u062E\u0627\u0644 \u0645\u0646 \u0627\u0644\u0645\u0633\u062A\u062E\u062F\u0645",inputBadge:"\u0625\u062F\u062E\u0627\u0644 \u0627\u0644\u0645\u0633\u062A\u062E\u062F\u0645",inputAnswered:"\u062A\u0645\u062A \u0627\u0644\u0625\u062C\u0627\u0628\u0629",inputSkipped:"\u062A\u0645 \u0627\u0644\u062A\u062E\u0637\u064A",inputQuestion:"\u0627\u0644\u0633\u0624\u0627\u0644",inputResponse:"\u0627\u0644\u0625\u062C\u0627\u0628\u0629",inputYourAnswer:"\u0625\u062C\u0627\u0628\u062A\u0643",inputSubmit:"\u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0625\u062C\u0627\u0628\u0629",inputSubmitHint:"Enter \u0644\u0644\u0625\u0631\u0633\u0627\u0644 \xB7 Shift+Enter \u0644\u0633\u0637\u0631 \u062C\u062F\u064A\u062F",inputSkip:"\u062A\u062E\u0637\u064D\u0651",inputSubmitted:"\u062A\u0645 \u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0625\u062C\u0627\u0628\u0629",respFreeText:"\u0646\u0635 \u062D\u0631",respSingleChoice:"\u0627\u062E\u062A\u064A\u0627\u0631 \u0648\u0627\u062D\u062F",respMultiChoice:"\u0627\u062E\u062A\u064A\u0627\u0631 \u0645\u062A\u0639\u062F\u062F",respConfirmation:"\u062A\u0623\u0643\u064A\u062F",approvalRequired:"\u0645\u0637\u0644\u0648\u0628 \u0645\u0648\u0627\u0641\u0642\u0629",approve:"\u0645\u0648\u0627\u0641\u0642\u0629",reject:"\u0631\u0641\u0636",approved:"\u062A\u0645\u062A \u0627\u0644\u0645\u0648\u0627\u0641\u0642\u0629",rejected:"\u0645\u0631\u0641\u0648\u0636",approvalReason:"\u0623\u0636\u0641 \u0633\u0628\u0628\u064B\u0627 (\u0627\u062E\u062A\u064A\u0627\u0631\u064A)",stepNoLongerActive:"\u0644\u0645 \u064A\u0639\u062F \u0647\u0630\u0627 \u0627\u0644\u0637\u0644\u0628 \u0646\u0634\u0637\u064B\u0627.",toolParameters:"\u0627\u0644\u0645\u0639\u0637\u064A\u0627\u062A",statusCompleted:"\u0645\u0643\u062A\u0645\u0644",statusDenied:"\u0645\u0631\u0641\u0648\u0636",statusError:"\u062E\u0637\u0623"},zc={en:Oi,fr:Bc,ar:Fc};function Wn(e,t){let n=$i(e),r=Vn(t),i=n==="en"?{}:zc[n]??{},a=r?t[n]??{}:t??{},l=r?t.en??{}:{};return{...Oi,...i,...l,...a}}function $i(e){return(e.split("-")[0]??"en").toLowerCase()}var Uc=new Set(["ar","he","iw","fa","ur","ps","sd","ug","yi","dv","ckb","ks","nqo","prs","syr"]);function Hi(e){return Uc.has($i(e))}function we(e,t){return e[t]??t}function Vn(e){if(!e)return!1;for(let t of Object.values(e))if(t&&typeof t=="object")return!0;return!1}function Bi(e,t){if(!(!e?.length||!t))return e.find(n=>n.locale===t)}function Fi(e,t){let{translations:n,defaultLocale:r,...i}=e,a=Bi(n,t);return a?{...i,title:a.title??i.title,description:a.description??i.description,content:a.content??i.content}:i}function zi(e,t){let{translations:n,defaultLocale:r,...i}=e,a=Bi(n,t);if(!a)return i;let l=new Map((a.fields??[]).map(c=>[c.name,c])),s=i.fields.map(c=>{let d=l.get(c.name);if(!d)return c;let u=new Map((d.options??[]).map(_=>[_.value,_]));return{...c,label:d.label??c.label,placeholder:d.placeholder??c.placeholder,validationHint:d.validationHint??c.validationHint,options:c.options?.map(_=>{let m=u.get(_.value);return m?{..._,label:m.label??_.label,description:m.description??_.description}:_})}});return{...i,title:a.title??i.title,description:a.description??i.description,submitLabel:a.submitLabel??i.submitLabel,fields:s}}var uo=class{get(t){try{return localStorage.getItem(t)}catch{return null}}set(t,n){try{localStorage.setItem(t,n)}catch{}}remove(t){try{localStorage.removeItem(t)}catch{}}},Gn=new uo;var mo=["off","error","warn","info","debug","trace"],go=x.cssPrefix,Ui=`${go}.debug`,Wc=`__${x.global}_DEBUG__`,Vc=`${go}-debug`,Kn=2,po=null;function Gc(){if(typeof window>"u")return 2;try{let e=new URLSearchParams(window.location.search).get(Vc);if(e!==null){let t=fo(e);if(t>=0)return t}}catch{}try{let e=window.localStorage?.getItem(Ui);if(e){let t=fo(e);if(t>=0)return t}}catch{}return window[Wc]?4:2}function fo(e){if(e===!0||e==="1"||e==="true")return 4;if(e===!1||e==="0"||e==="false"||e==="off")return 0;if(typeof e=="number")return Math.max(0,Math.min(5,Math.floor(e)));if(typeof e=="string"){let t=mo.indexOf(e);if(t>=0)return t}return-1}function qn(e){let t=fo(e);if(!(t<0)){Kn=t;try{window.localStorage?.setItem(Ui,mo[t])}catch{}}}function ho(){return mo[Kn]}Kn=Gc();function Wi(e){let t=`[${go}:${e}]`,n=(r,i,a)=>(l,s)=>{if(!(Kn<r)&&(s===void 0?console[i](t,l):console[i](t,l,s),po))try{po({level:a,scope:e,message:l,payload:s})}catch{}};return{error:n(1,"error","error"),warn:n(2,"warn","warn"),info:n(3,"info","info"),debug:n(4,"debug","debug"),trace:n(5,"debug","trace"),scope:r=>Wi(`${e}:${r}`)}}var B=Wi("core");function Vi(e){po=e}var at=B.scope("context"),Kc=new Set(["visitorId","conversationId","conversationId","jwt","token","authorization","password"]),Gi=50,vo=1024,qc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function bo(e){return Ki(e,"userContext",!0)}function xo(e){return Ki(e,"pageContext",!1)}function Ki(e,t,n){if(e==null)return;if(typeof e!="object"||Array.isArray(e)){at.warn(`ignored ${t} \u2014 expected an object`,{type:Array.isArray(e)?"array":typeof e});return}let r={},i=0;for(let[a,l]of Object.entries(e)){if(Kc.has(a)){at.warn(`dropped reserved ${t} key "${a}" \u2014 managed by the widget, not host-settable`);continue}if(l==null)continue;if(i>=Gi){at.warn(`${t} truncated at ${Gi} keys \u2014 dropped "${a}"`);continue}let s=jc(t,a,l);s!==void 0&&(r[a]=s,i++)}return n&&typeof r.email=="string"&&!qc.test(r.email)&&(at.warn(`dropped malformed ${t}.email "${r.email}"`),delete r.email),Object.keys(r).length>0?r:void 0}function jc(e,t,n){if(typeof n=="boolean")return n;if(typeof n=="number"){if(!Number.isFinite(n)){at.warn(`dropped non-finite ${e}.${t}`);return}return n}if(typeof n=="string"){let r=n.trim();return r===""?void 0:r.length>vo?(at.warn(`truncated ${e}.${t} to ${vo} chars`),r.slice(0,vo)):r}at.warn(`dropped ${e}.${t} \u2014 only string/number/boolean values are allowed`,{type:typeof n})}var jn={maxBytes:10485760,maxCount:10,accept:"*/*"},Xn={files:!0,voice:"local",humanInLoop:!0},qi={list:[],byTrigger:{}},Po={enabled:!0,sampleRate:1},Yn={upload:"/pai/upload-file",transcribe:"/pai/transcribe-audio",submitForm:"/pai/submit-form"},wt={variant:"circle",size:"md",label:void 0,icon:"chat",hidden:!1},ji={floating:["theme","textSize","history","close","clear","expand","fullscreen","sound","language"],inline:["theme","textSize","history","close","clear","fullscreen","sound","language"],standalone:["theme","textSize","history","clear","sound","language"],page:["theme","textSize","history","clear","sound","language"],modal:["theme","textSize","history","close","clear","fullscreen","sound","language"],drawer:["theme","textSize","history","close","clear","fullscreen","sound","language"]},yo={enabled:!0,volume:.3,events:void 0},Xi={enabled:!0,events:void 0},Yi=[{label:"tabConversations",layout:"chat"}],Ji={showSearchBar:!0};function kt(e){let t=e!==null&&typeof e=="object"?e:{},n=t.presentation??{},r=t.behavior??{},i=t.i18n??{},a=t.feedback??{},l=t.footer??{},s=t.header??{},{themeMode:c,themeOverrides:d}=Xc(t.theme),u=n.mode??"floating",_=Yc(i.defaultLocale),m=i.availableLocales??[i.locale??_],f=Ct(i.locale??_,m,_),g=(t.baseUrl??x.defaultBaseUrl).replace(/\/$/,""),S=(t.agentApiBaseUrl??`${g}/api/agent`).replace(/\/$/,""),h=(t.dataApiBaseUrl??`${g}/api/data`).replace(/\/$/,"");return{widgetId:t.widgetId??"default",publicKey:t.publicKey,aiAgentDeploymentId:t.aiAgentDeploymentId,baseUrl:g,agentApiBaseUrl:S,dataApiBaseUrl:h,userContext:bo(t.userContext),pageContext:xo(t.pageContext),position:n.position??"bottom-right",themeMode:c,textSize:"normal",themeOverrides:d,mode:u,iframe:n.iframe??!1,responseMode:r.responseMode??"streaming",showReasoning:r.showReasoning??!1,showToolCalls:r.showToolCalls??!1,showSources:r.showSources??!1,features:{files:t.features?.files??Xn.files,voice:t.features?.voice??Xn.voice,humanInLoop:t.features?.humanInLoop??Xn.humanInLoop,tools:t.features?.tools},forms:Qt(t.forms,f),endpoints:{upload:t.endpoints?.upload??Yn.upload,transcribe:t.endpoints?.transcribe??Yn.transcribe,submitForm:t.endpoints?.submitForm??Yn.submitForm},attachments:{accept:t.composer?.attachments?.accept??jn.accept,maxBytes:t.composer?.attachments?.maxBytes??jn.maxBytes,maxCount:t.composer?.attachments?.maxCount??jn.maxCount},locale:f,defaultLocale:_,availableLocales:m,startMinimized:r.startMinimized??!0,actions:Jc(u,s.actions),size:n.size??{},launcher:id(t.launcher),sound:Qc(a.sound),haptics:Zc(a.haptics),strings:Wn(f,i.strings),stringsOverride:i.strings,composerDisclaimer:l.composerDisclaimer??"",poweredBy:td(l.poweredBy),composer:nd(t.composer),modules:rd(t.modules),tracking:ed(t.tracking,h),storage:t.storage??Gn,onMessage:t.onMessage,onOpen:t.onOpen,onClose:t.onClose,onError:t.onError}}function Xc(e){return typeof e=="string"?{themeMode:e,themeOverrides:{}}:e&&typeof e=="object"?{themeMode:"auto",themeOverrides:e}:{themeMode:"auto",themeOverrides:{}}}function Yc(e){return e&&e!=="auto"?e:typeof navigator<"u"&&navigator.language?navigator.language:"en"}function Ct(e,t,n){return t.length<=1||t.includes(e)?e:t.includes(n)?n:t[0]??e}function Jc(e,t){return t??ji[e]}function Qc(e){return{enabled:e?.enabled??yo.enabled,volume:e?.volume??yo.volume,events:e?.events}}function Zc(e){return{enabled:e?.enabled??Xi.enabled,events:e?.events}}function ed(e,t){let n=e?.sampleRate??Po.sampleRate;return{enabled:e?.enabled??Po.enabled,endpoint:e?.endpoint??`${t}/pai/elements-px.gif`,sampleRate:Math.min(1,Math.max(0,Number.isFinite(n)?n:1)),token:e?.token}}function td(e){let n={...{text:`Powered by ${x.displayName}`,href:x.siteUrl},...e};return!!(n.text||n.logoUrl)?n:null}function nd(e){let t=e?.sendButton;return{sendButton:{shape:t?.shape??"circle",icon:t?.icon??"arrowUp",variant:t?.variant??"filled"}}}function rd(e){let t=e===void 0?Yi:e,n=new Set,r=[];for(let a of t.slice(0,4)){if(!a?.label||!a?.layout)continue;let l=a.contentTags?.filter(Boolean),s=a.id??l?.[0]??a.layout;for(;n.has(s);)s=`${s}-${r.length}`;n.add(s);let c={id:s,label:a.label,layout:a.layout};l&&l.length>0&&(c.contentTags=l),a.layout==="home"&&(c.brandName=a.brandName,c.greetingText=a.greetingText,c.showGreeting=a.showGreeting??!0,c.showSearchBar=a.showSearchBar??Ji.showSearchBar,c.showRecentConversations=a.showRecentConversations??!0,a.userAvatars&&a.userAvatars.length>0&&(c.userAvatars=a.userAvatars),a.status&&(c.status=a.status),c.contentBlockTitle=a.contentBlockTitle),r.push(c)}let i=Object.fromEntries(r.map(a=>[a.id,a]));return{list:r,byId:i}}function Qt(e,t){var a;if(!e?.length)return qi;let n=[],r=new Set;for(let l of e){if(!l?.id||r.has(l.id))continue;let s=zi(l,t),c=(s.fields??[]).filter(u=>!!(u&&u.name&&u.label&&u.type)),d=(Array.isArray(s.on)?s.on:[s.on]).map(od).filter(u=>u!==null);c.length===0||d.length===0||(r.add(s.id),n.push({id:s.id,triggers:d,when:s.when,fields:c,title:s.title,description:s.description,submitLabel:s.submitLabel,skippable:s.skippable??!1,frequency:s.frequency??"once",mirrorToContext:s.mirrorToContext??!0,reopenable:s.reopenable??!0,reviewable:s.reviewable??!0}))}let i={};for(let l of n)for(let s of l.triggers)(i[a=s.kind]??(i[a]=[])).push(l);return{list:n,byTrigger:i}}function od(e){if(typeof e!="string")return null;if(e==="pre-chat"||e==="conversation-closed"||e==="panel-close"||e==="manual")return{kind:e};let[t,n]=e.split(":",2);if(t==="after-messages"){let r=Number(n);return Number.isFinite(r)&&r>0?{kind:"after-messages",param:r}:null}if(t==="idle"){let r=Number(n);return Number.isFinite(r)&&r>0?{kind:"idle",param:r}:null}return t==="page-area"&&n?{kind:"page-area",param:n}:null}function id(e){let t=e?.callout?.text?{shape:"pill",position:"auto",delayMs:1200,autoDismissMs:0,animated:!0,persistent:!0,...e.callout}:null;return{variant:e?.variant??wt.variant,size:e?.size??wt.size,label:e?.label??wt.label,icon:e?.icon??wt.icon,hidden:e?.hidden??wt.hidden,callout:t}}function So(e,t,n,r){let i=Ct(t,e.availableLocales,e.defaultLocale);if(i===e.locale&&n===e.themeMode&&r===e.textSize)return e;let a={...e};return i!==e.locale&&(a.locale=i,a.strings=Wn(i,e.stringsOverride)),n!==e.themeMode&&(a.themeMode=n),r!==e.textSize&&(a.textSize=r),a}var ad=["presentation","behavior","theme","launcher","header","composer","feedback","i18n","footer","features","tracking","endpoints"];function wo(e,t){if(!t)return e;let n={...e};for(let a of ad){let l=t[a];if(l===void 0)continue;let s=e[a];if(a==="theme"){s===void 0&&(n[a]=l);continue}a!=="i18n"&&(n[a]=Qi(l,s))}t.modules!==void 0&&e.modules===void 0&&(n.modules=t.modules),t.dataApiBaseUrl!==void 0&&e.dataApiBaseUrl===void 0&&(n.dataApiBaseUrl=t.dataApiBaseUrl);let r=e.i18n,i=t.i18n;if(r||i){let a=Qi(i??{},r);i?.availableLocales!==void 0&&(a.availableLocales=i.availableLocales),i?.defaultLocale!==void 0&&(a.defaultLocale=i.defaultLocale);let l=r?.strings,s=i?.strings;(l||s)&&(a.strings=sd(s,l)),n.i18n=a}return n}function Qi(e,t){if(!t)return e;let n={...e};for(let[r,i]of Object.entries(t))i!==void 0&&(n[r]=i);return n}function sd(e,t){if(!e)return t;if(!t)return e;let n=Vn(e),r=Vn(t);if(!n&&!r)return{...e,...t};let i={},a=n?e:{en:e},l=r?t:{en:t};for(let[s,c]of Object.entries(a))i[s]={...c};for(let[s,c]of Object.entries(l))i[s]={...i[s],...c};return i}var ld=["clear","expand","fullscreen","sound","history","language","theme","textSize","close"],st=e=>e!=="false",cd=e=>e.split(",").map(t=>t.trim()).filter(Boolean),dd=[["public-key","publicKey"],["ai-agent-deployment-id","aiAgentDeploymentId"],["base-url","baseUrl"],["agent-api-base-url","agentApiBaseUrl"],["data-api-base-url","dataApiBaseUrl"],["theme","theme",e=>e]],_d=[["mode","mode",e=>e],["position","position",e=>e],["iframe","iframe",st]],ud=[["width","width"],["height","height"]],pd=[["response-mode","responseMode",e=>e],["start-minimized","startMinimized",st],["show-reasoning","showReasoning",st],["show-tool-calls","showToolCalls",st],["show-sources","showSources",st]],fd=[["locale","locale"]],mf=new Set(ld);var md=[["launcher-variant","variant",e=>e],["launcher-size","size",e=>e],["launcher-icon","icon"],["launcher-hidden","hidden",st]],gd=[["features-files","files",st],["features-voice","voice",e=>e],["features-tools","tools",cd]],hd=[["endpoint-upload","upload"],["endpoint-transcribe","transcribe"]],vd=[["user-id","id"],["user-email","email"],["user-name","name"]],bd=[["page-area","area"],["page-url","url"],["page-path","path"],["page-title","title"]],xd=["launcher-label","callout-text","callout-delay","actions-main","actions-overflow","user-context","page-context"],Pd=[dd,_d,ud,pd,fd,md,gd,hd,vd,bd],yd=new Set(["iframe","start-minimized"]),Sd=[...Pd.flatMap(e=>e.map(([t])=>t).filter(t=>!yd.has(t))),...xd];function Zi(e){return`${x.cssPrefix}:${e}`}function Zt(e,t,n){e.dispatchEvent(new CustomEvent(Zi(t),{detail:n}))}function ea(e,t){let r=Object.entries(t).map(([i,a])=>{let l=Zi(i),s=c=>a(c.detail);return e.addEventListener(l,s),[l,s]});return()=>{for(let[i,a]of r)e.removeEventListener(i,a)}}function Ne(){let e=Date.now(),t=new Uint8Array(16);t[0]=Math.floor(e/2**40)&255,t[1]=Math.floor(e/2**32)&255,t[2]=e>>>24&255,t[3]=e>>>16&255,t[4]=e>>>8&255,t[5]=e&255,wd(t.subarray(6)),t[6]=t[6]&15|112,t[8]=t[8]&63|128;let n=Array.from(t,r=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function wd(e){if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){crypto.getRandomValues(e);return}for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256)}var lt=B.scope("persistence");function Tt(e,t=Gn,n){let r=n?`${e}.${n}`:e,i=`${x.cssPrefix}.storageVersion`,a=t.get(i)??void 0,l=a?`.v${a}`:"",s=`${x.cssPrefix}.${r}${l}`,c=`${x.cssPrefix}${l}.visitorId`,d=`${s}.conversationId`,u=`${s}.userPrefs`,_=`${s}.panelOpen`,m=`${s}.panelSize`,f=`${s}.calloutDismissed`,g=`${s}.sidebarCollapsed`,S=`${s}.activeModule`,h=`${s}.historyCount`,v=`${s}.formsDone`,C={getVisitorId(){let b=t.get(c);if(b)return b;let E=Ne();return t.set(c,E),E},setVisitorId(b){lt.debug("setVisitorId (rebind)",{id:b,scope:r}),t.set(c,b)},loadConversationId(){return t.get(d)??void 0},saveConversationId(b){lt.trace("saveConversationId",{id:b,scope:r}),b?t.set(d,b):t.remove(d)},loadUserPrefs(){let b=t.get(u);if(!b)return{};try{let E=JSON.parse(b);return ta(E)?E:{}}catch(E){return lt.warn("loadUserPrefs parse failed",{error:E}),{}}},saveUserPrefs(b){try{t.set(u,JSON.stringify(b))}catch(E){lt.warn("saveUserPrefs serialise failed",{error:E})}},patchUserPrefs(b){let E=C.loadUserPrefs();C.saveUserPrefs({...E,...b})},loadPanelOpen(){let b=t.get(_);return b==="1"?!0:b==="0"?!1:null},savePanelOpen(b){t.set(_,b?"1":"0")},loadPanelSize(){let b=t.get(m);return b==="normal"||b==="expanded"||b==="fullscreen"?b:null},savePanelSize(b){t.set(m,b)},loadCalloutDismissed(b){if(!b)return!1;let E=t.get(f);return!!E&&E===b},saveCalloutDismissed(b){b?t.set(f,b):t.remove(f)},loadSidebarCollapsed(){let b=t.get(g);return b==="1"?!0:b==="0"?!1:null},saveSidebarCollapsed(b){t.set(g,b?"1":"0")},loadActiveModule(){return t.get(S)||null},saveActiveModule(b){t.set(S,b)},loadHistoryCount(){let b=t.get(h);if(!b)return null;let E=Number.parseInt(b,10);return Number.isFinite(E)&&E>=0?E:null},saveHistoryCount(b){t.set(h,String(b))},loadFormsDone(){let b=t.get(v);if(!b)return{};try{let E=JSON.parse(b);return ta(E)?E:{}}catch(E){return lt.warn("loadFormsDone parse failed",{error:E}),{}}},saveFormDone(b){try{let E=C.loadFormsDone();E[b]=Date.now(),t.set(v,JSON.stringify(E))}catch(E){lt.warn("saveFormDone serialise failed",{error:E})}},rememberStorageVersion(b){b&&b!==t.get(i)&&(lt.debug("rememberStorageVersion (force-reset on next load)",{version:b}),t.set(i,b))},clearConversation(){t.remove(d)}};return C}function ta(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var na=`:host{--__P__-accent-user: __BRAND_ACCENT__;--__P__-accent: var(--__P__-accent-user);--__P__-accent-text-user: __BRAND_ACCENT_TEXT__;--__P__-accent-text: var(--__P__-accent-text-user);--__P__-radius: __BRAND_RADIUS__;--__P__-radius-sm: 8px;--__P__-radius-md: 10px;--__P__-radius-lg: 16px;--__P__-font: __BRAND_FONT__;--__P__-font-display: var(--__P__-font);--__P__-font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;--__P__-bg: oklch(1 0 0);--__P__-bg-elevated: oklch(.9789 .0029 278.3);--__P__-surface: var(--__P__-bg-elevated);--__P__-muted: var(--__P__-fg-muted);--__P__-hover: oklch(.1686 .011 278.3 / .06);--__P__-fg: oklch(.1686 .011 278.3);--__P__-fg-muted: oklch(.4932 .0301 278.3);--__P__-border: oklch(.9312 .0084 278.3);--__P__-border-strong: oklch(.8757 .0131 278.3);--__P__-bubble-user: var(--__P__-accent);--__P__-bubble-user-text: var(--__P__-accent-text);--__P__-bubble-assistant: oklch(.9638 .0058 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-on-accent: var(--__P__-accent-text);--__P__-success: oklch(.6456 .1654 151.53);--__P__-warning: oklch(.7135 .1494 74.05);--__P__-danger: oklch(.5966 .1818 24.51);--__P__-danger-text: oklch(.5054 .1905 27.52);--__P__-danger-bg: oklch(.5966 .1818 24.51 / .1);--__P__-neutral: oklch(.7137 .0192 278.3);--__P__-focus: var(--__P__-accent);--__P__-shadow-panel: 0 8px 24px -8px rgba(13, 15, 20, .18), 0 24px 64px -24px rgba(13, 15, 20, .24);--__P__-shadow-card: 0 1px 2px rgba(13, 15, 20, .06), 0 4px 12px -6px rgba(13, 15, 20, .12);--__P__-backdrop: oklch(.1686 .011 278.3 / .55);--__P__-shadow-fab: 0 6px 16px -4px color-mix(in oklch, var(--__P__-accent) 45%, transparent), 0 12px 32px -12px rgba(13, 15, 20, .25);--__P__-z-fab: 2147483600;--__P__-z-panel: 2147483601;--__P__-panel-w: 380px;--__P__-panel-h: 600px;--__P__-fab-size: 56px;--__P__-space-1: 4px;--__P__-space-2: 8px;--__P__-space-3: 12px;--__P__-space-4: 16px;--__P__-space-5: 20px;--__P__-space-6: 24px;--__P__-space-8: 32px;--__P__-text-scale: 1;--__P__-text-xs: calc(12px * var(--__P__-text-scale));--__P__-text-sm: calc(13px * var(--__P__-text-scale));--__P__-text-base: calc(15px * var(--__P__-text-scale));--__P__-text-md: calc(16px * var(--__P__-text-scale));--__P__-text-lg: calc(18px * var(--__P__-text-scale));--__P__-text-xl: calc(22px * var(--__P__-text-scale));--__P__-text-2xl: calc(30px * var(--__P__-text-scale))}:host([data-text-size="small"]){--__P__-text-scale: .9}:host([data-text-size="large"]){--__P__-text-scale: 1.15}:host{--__P__-ease: cubic-bezier(.2, .7, .2, 1);--__P__-ease-out: cubic-bezier(.2, .7, .2, 1);--__P__-ease-in: cubic-bezier(.4, 0, 1, 1);--__P__-ease-in-out: cubic-bezier(.65, 0, .35, 1);--__P__-dur-quick: .12s;--__P__-dur-base: .22s;--__P__-dur-slow: .32s;font-family:var(--__P__-font);color:var(--__P__-fg);color-scheme:light;--__P__-color-scheme: light}:host([data-theme="dark"]){--__P__-bg: oklch(.1783 .0128 278.3);--__P__-bg-elevated: oklch(.2232 .0182 278.3);--__P__-fg: oklch(.9368 .01 278.3);--__P__-fg-muted: oklch(.7048 .0296 278.3);--__P__-border: oklch(.2752 .0266 278.3);--__P__-border-strong: oklch(.335 .0291 278.3);--__P__-hover: oklch(.9368 .01 278.3 / .08);--__P__-bubble-assistant: oklch(.2474 .0311 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-danger-text: oklch(.8077 .1035 19.57);--__P__-danger-bg: oklch(.5966 .1818 24.51 / .18);--__P__-shadow-panel: 0 8px 24px -8px rgba(0, 0, 0, .6), 0 24px 64px -24px rgba(0, 0, 0, .7);--__P__-shadow-card: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px -6px rgba(0, 0, 0, .5);--__P__-backdrop: rgba(0, 0, 0, .65);color-scheme:dark;--__P__-color-scheme: dark}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-bg: oklch(.1783 .0128 278.3);--__P__-bg-elevated: oklch(.2232 .0182 278.3);--__P__-fg: oklch(.9368 .01 278.3);--__P__-fg-muted: oklch(.7048 .0296 278.3);--__P__-border: oklch(.2752 .0266 278.3);--__P__-border-strong: oklch(.335 .0291 278.3);--__P__-hover: oklch(.9368 .01 278.3 / .08);--__P__-bubble-assistant: oklch(.2474 .0311 278.3);--__P__-bubble-assistant-text: var(--__P__-fg);--__P__-shadow-panel: 0 8px 24px -8px rgba(0, 0, 0, .6), 0 24px 64px -24px rgba(0, 0, 0, .7);color-scheme:dark;--__P__-color-scheme: dark}}@supports (color: oklch(from red l c h)){:host{--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.3, l, .62) c h);--__P__-accent-text: oklch(from var(--__P__-accent) clamp(0, (l / .623 - 1) * -infinity, 1) 0 h)}:host([data-theme="dark"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h)}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h)}}}@media(prefers-reduced-motion:reduce){:host{--__P__-dur-quick: 1ms;--__P__-dur-base: 1ms;--__P__-dur-slow: 1ms}}
2
2
  `;var ra=`*,*:before,*:after{box-sizing:border-box;margin:0;padding:0;border:0}button{font:inherit;color:inherit;background:none;cursor:pointer;-webkit-appearance:none;appearance:none;line-height:1}button:focus-visible,[tabindex]:focus-visible,textarea:focus-visible,input:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px}textarea,input{font:inherit;color:inherit;background:none;border:0;outline:0;resize:none}a{color:var(--__P__-accent);text-decoration:underline;text-underline-offset:2px}img,svg{display:block;max-width:100%}ul,ol{list-style:none}.__P__-app{display:block;width:100%;height:100%;font-family:var(--__P__-font);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-feature-settings:"cv11","ss01","ss03"}.__P__-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
3
3
  `;var oa=`.__P__-anchor{color-scheme:var(--__P__-color-scheme, light);right:16px;bottom:16px}.__P__-surface{display:contents}.__P__-surface[hidden]{display:none}:host([data-position="bottom-left"]) .__P__-anchor,:host([data-position="top-left"]) .__P__-anchor{right:auto;left:16px}:host([data-position="top-right"]) .__P__-anchor,:host([data-position="top-left"]) .__P__-anchor{bottom:auto;top:16px}.__P__-anchor{position:fixed;display:flex;flex-direction:column;align-items:flex-end;gap:var(--__P__-space-3);pointer-events:none}.__P__-anchor{--__P__-fab-size: 56px}.__P__-anchor[data-launcher-size=sm]{--__P__-fab-size: 44px}.__P__-anchor[data-launcher-size=md]{--__P__-fab-size: 56px}.__P__-anchor[data-launcher-size=lg]{--__P__-fab-size: 68px}.__P__-anchor>*{pointer-events:auto}.__P__-fab[data-size=sm]{--__P__-fab-size: 44px;font-size:var(--__P__-text-sm)}.__P__-fab[data-size=md]{--__P__-fab-size: 56px;font-size:calc(14px * var(--__P__-text-scale))}.__P__-fab[data-size=lg]{--__P__-fab-size: 68px;font-size:var(--__P__-text-base)}.__P__-fab{display:inline-flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);color:var(--__P__-accent-text);background:var(--__P__-accent);box-shadow:var(--__P__-shadow-fab);font-weight:600;line-height:1;transform-origin:bottom right;animation:__P__-fab-in var(--__P__-dur-base) var(--__P__-ease) both;transition:transform var(--__P__-dur-base) var(--__P__-ease),opacity var(--__P__-dur-base) var(--__P__-ease),box-shadow var(--__P__-dur-base) var(--__P__-ease)}.__P__-fab:hover{transform:translateY(-2px)}.__P__-fab:active{transform:translateY(0)}.__P__-fab:focus-visible{outline:2px solid var(--__P__-on-accent);outline-offset:3px}.__P__-fab svg{width:24px;height:24px;flex-shrink:0}@keyframes __P__-fab-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:none}}.__P__-fab[data-leaving]{position:absolute;right:0;bottom:0;animation:__P__-fab-out var(--__P__-dur-quick) var(--__P__-ease) forwards;pointer-events:none}:host([data-position^="top-"]) .__P__-fab[data-leaving]{bottom:auto;top:0}:host([data-position$="-left"]) .__P__-fab[data-leaving]{right:auto;left:0}@keyframes __P__-fab-out{0%{opacity:1;transform:none}to{opacity:0;transform:scale(.85)}}.__P__-fab[data-variant=circle]{width:var(--__P__-fab-size);height:var(--__P__-fab-size);border-radius:999px}.__P__-fab[data-variant=circle] .__P__-fab-label{display:none}.__P__-fab[data-variant=pill]{height:var(--__P__-fab-size);padding:0 18px 0 16px;border-radius:999px}.__P__-fab[data-variant=bar]{height:var(--__P__-fab-size);padding:0 22px;border-radius:var(--__P__-radius)}.__P__-fab[data-variant=minimal]{height:var(--__P__-fab-size);padding:0 var(--__P__-space-4);border-radius:999px;background:transparent;color:var(--__P__-accent);box-shadow:none;border:1px solid currentColor}.__P__-fab[data-variant=minimal]:hover{background:color-mix(in srgb,var(--__P__-accent) 12%,transparent)}.__P__-callout{--__P__-callout-fab-h: var(--__P__-fab-size, 56px);--__P__-callout-gap: clamp(12px, calc(var(--__P__-callout-fab-h) * .25), 22px);--__P__-callout-nudge-direction: -1;position:absolute;display:inline-flex;align-items:center;gap:var(--__P__-space-2);padding:10px 14px;background:var(--__P__-fg);color:var(--__P__-bg);border-radius:999px;font-size:var(--__P__-text-sm);font-weight:600;line-height:1.2;box-shadow:0 10px 30px -8px #00000059;pointer-events:auto;animation:__P__-callout-in var(--__P__-dur-slow) var(--__P__-ease);z-index:1;max-width:240px;white-space:nowrap}.__P__-callout[data-position=left]{right:calc(100% + var(--__P__-callout-gap));bottom:calc(var(--__P__-callout-fab-h) / 2);transform:translateY(50%)}.__P__-callout[data-position=right]{left:calc(100% + var(--__P__-callout-gap));bottom:calc(var(--__P__-callout-fab-h) / 2);transform:translateY(50%);--__P__-callout-nudge-direction: 1}.__P__-callout[data-position=top]{bottom:calc(100% + var(--__P__-callout-gap));right:0;max-width:min(280px,calc(100vw - 32px))}.__P__-callout[data-position=bottom]{top:calc(100% + var(--__P__-callout-gap));right:0;max-width:min(280px,calc(100vw - 32px))}:host([data-position$="-left"]) .__P__-callout[data-position=top],:host([data-position$="-left"]) .__P__-callout[data-position=bottom]{right:auto;left:0}.__P__-callout[data-shape=bubble]{border-radius:var(--__P__-radius-md);white-space:normal;width:max-content;max-width:min(280px,calc(100vw - 32px))}.__P__-callout[data-shape=callout]{padding:12px 18px;font-size:calc(14px * var(--__P__-text-scale));background:var(--__P__-accent);color:var(--__P__-accent-text)}.__P__-callout:after{content:"";position:absolute;width:12px;height:12px;background:inherit;border-radius:2px;transform:rotate(45deg)}.__P__-callout[data-position=left]:after{right:-5px;top:50%;margin-top:-6px}.__P__-callout[data-position=right]:after{left:-5px;top:50%;margin-top:-6px}.__P__-callout[data-position=top]:after{bottom:-5px;right:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}.__P__-callout[data-position=bottom]:after{top:-5px;right:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}:host([data-position$="-left"]) .__P__-callout[data-position=top]:after,:host([data-position$="-left"]) .__P__-callout[data-position=bottom]:after{right:auto;left:calc(var(--__P__-fab-size, 56px) / 2 - 6px)}.__P__-callout[data-animated]{animation:__P__-callout-in var(--__P__-dur-slow) var(--__P__-ease),__P__-callout-nudge 1.6s var(--__P__-ease-in-out) var(--__P__-dur-slow) infinite}@keyframes __P__-callout-in{0%{opacity:0}to{opacity:1}}@keyframes __P__-callout-nudge{0%,to{margin-left:0;margin-right:0}50%{margin-left:calc(6px * var(--__P__-callout-nudge-direction));margin-right:calc(-6px * var(--__P__-callout-nudge-direction))}}@media(prefers-reduced-motion:reduce){.__P__-callout[data-animated]{animation:__P__-callout-in 1ms var(--__P__-ease)}.__P__-icon-btn[data-recording=true],.__P__-typing span{animation:none}}.__P__-callout-close{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:999px;color:inherit;opacity:.7;cursor:pointer}.__P__-callout-close:hover{opacity:1;background:color-mix(in srgb,currentColor 15%,transparent)}.__P__-callout-close:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-callout-close svg{width:12px;height:12px}.__P__-panel{width:var(--__P__-panel-w);height:var(--__P__-panel-h);max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);background:var(--__P__-bg);color:var(--__P__-fg);border-radius:var(--__P__-radius-lg);box-shadow:var(--__P__-shadow-panel);display:flex;flex-direction:column;overflow:hidden;transform-origin:bottom right;animation:__P__-panel-in var(--__P__-dur-slow) var(--__P__-ease);border:1px solid var(--__P__-border)}@media(prefers-reduced-motion:no-preference){.__P__-panel{transition:width var(--__P__-dur-base) var(--__P__-ease),height var(--__P__-dur-base) var(--__P__-ease),max-width var(--__P__-dur-base) var(--__P__-ease),max-height var(--__P__-dur-base) var(--__P__-ease)}.__P__-panel[data-resizing]{transition:none}}:host([data-mode="open"]) .__P__-panel{width:var(--__P__-widget-w, var(--__P__-panel-w));height:var(--__P__-widget-h, var(--__P__-panel-h));min-width:var(--__P__-resize-min-w, auto);min-height:var(--__P__-resize-min-h, auto);max-width:var(--__P__-resize-max-w, calc(100vw - 32px) );max-height:var(--__P__-resize-max-h, calc(100dvh - 32px) )}@keyframes __P__-panel-in{0%{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:none}}:host([data-mode="expanded"]) .__P__-panel{width:var(--__P__-expanded-w, 640px);height:var(--__P__-expanded-h, 820px);max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px)}:host([data-mode="fullscreen"]){z-index:var(--__P__-z-panel)!important}:host([data-mode="fullscreen"]) .__P__-anchor{inset:0;padding:0;justify-content:flex-end;align-items:flex-end}:host([data-mode="fullscreen"][data-position*="top"]) .__P__-anchor{justify-content:flex-start}:host([data-mode="fullscreen"][data-position*="left"]) .__P__-anchor{align-items:flex-start}:host([data-mode="fullscreen"]) .__P__-panel{width:100vw;height:100dvh;max-width:none;max-height:none;border-radius:0;border:0}:host([data-mode="fullscreen"]) .__P__-fab{display:none}@media(max-width:640px){:host([data-mode="open"]) .__P__-anchor,:host([data-mode="expanded"]) .__P__-anchor{inset:0;align-items:stretch;padding:0}:host([data-mode="open"]) .__P__-panel,:host([data-mode="expanded"]) .__P__-panel{width:100vw;height:100dvh;max-width:none;max-height:none;border-radius:0;border:0}}:host([data-mode="inline"]) .__P__-anchor,:host([data-mode="standalone"]) .__P__-anchor{position:static;inset:auto;padding:0;align-items:stretch;width:100%;height:100%;min-height:0}:host([data-mode="inline"]) .__P__-panel,:host([data-mode="standalone"]) .__P__-panel{width:100%;height:100%;min-width:0;min-height:0;max-width:none;max-height:none;animation:none}:host([data-mode="inline"]) .__P__-fab,:host([data-mode="standalone"]) .__P__-fab{display:none}:host([data-mode="inline"]){min-height:320px}:host([data-mode="inline"]) .__P__-panel{border-radius:var(--__P__-radius)}:host([data-mode="standalone"]) .__P__-panel{border-radius:0;border:0;box-shadow:none}:host([data-mode="modal"]){position:fixed!important;inset:0!important;z-index:var(--__P__-z-panel)!important;display:block!important;width:100vw;height:100dvh;background:var(--__P__-modal-backdrop, var(--__P__-backdrop));animation:__P__-backdrop-in var(--__P__-dur-base) var(--__P__-ease) both;--__P__-panel-w: min(960px, 92vw);--__P__-panel-h: min(720px, 88dvh)}:host([data-mode="modal"]) .__P__-anchor{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:var(--__P__-space-6);pointer-events:none}:host([data-mode="modal"]) .__P__-panel{pointer-events:auto;width:var(--__P__-widget-w, var(--__P__-panel-w));height:var(--__P__-widget-h, var(--__P__-panel-h));max-width:calc(100vw - 48px);max-height:calc(100dvh - 48px);min-width:0;min-height:0;border-radius:var(--__P__-radius);box-shadow:var(--__P__-shadow-panel);animation:__P__-modal-in var(--__P__-dur-base) var(--__P__-ease);translate:var(--__P__-modal-dx, 0px) var(--__P__-modal-dy, 0px)}:host([data-mode="modal"]) .__P__-header,:host([data-mode="modal"]) .__P__-back-header,:host([data-mode="modal"]) .__P__-home-hero{cursor:grab;touch-action:none}:host([data-mode="modal"]) .__P__-panel[data-dragging]{cursor:grabbing;user-select:none}:host([data-mode="modal"]) .__P__-panel[data-dragging] *{cursor:grabbing}:host([data-mode="modal"]) .__P__-fab{display:none}@keyframes __P__-backdrop-in{0%{background:#0000}to{background:var(--__P__-modal-backdrop, var(--__P__-backdrop))}}@keyframes __P__-modal-in{0%{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}:host([data-mode="drawer"]){--__P__-panel-w: min(440px, calc(100vw - 32px) );--__P__-panel-h: 100dvh}:host([data-mode="drawer"]) .__P__-anchor{position:fixed;--__P__-inset-x: var(--__P__-panel-inset, 12px);--__P__-inset-y: var(--__P__-panel-inset, 3dvh);top:var(--__P__-inset-y);bottom:auto;right:var(--__P__-inset-x);left:auto;width:min(var(--__P__-widget-w, var(--__P__-panel-w)),calc(100vw - var(--__P__-inset-x) * 2));height:min(var(--__P__-widget-h, var(--__P__-panel-h)),calc(100dvh - var(--__P__-inset-y) * 2));padding:0;display:block;pointer-events:auto}:host([data-mode="drawer"][data-position$="-left"]) .__P__-anchor{right:auto;left:var(--__P__-inset-x)}:host([data-mode="drawer"][data-position^="bottom-"]) .__P__-anchor{top:auto;bottom:var(--__P__-inset-y)}:host([data-mode="drawer"]) .__P__-panel{width:100%;height:100%;max-width:none;max-height:none;min-width:0;min-height:0;border-radius:var(--__P__-radius, 12px);border:1px solid var(--__P__-border);box-shadow:-8px 16px 32px -12px #00000038;animation:__P__-drawer-in var(--__P__-dur-base) var(--__P__-ease)}:host([data-mode="drawer"][data-position$="-left"]) .__P__-panel{box-shadow:8px 16px 32px -12px #00000038;animation:__P__-drawer-in-left var(--__P__-dur-base) var(--__P__-ease)}.__P__-fab[data-edge-tab]{display:inline-flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--__P__-space-2);position:fixed;top:50%;height:140px;width:auto;min-width:0;padding:10px 8px;writing-mode:vertical-rl;text-orientation:mixed;transform:translateY(-50%);transform-origin:center;animation:__P__-edge-tab-in var(--__P__-dur-base) var(--__P__-ease) both}.__P__-fab[data-edge-tab] svg{writing-mode:horizontal-tb}.__P__-fab[data-edge-tab]:hover{transform:translateY(-50%) scale(1.03)}.__P__-fab[data-edge-tab]:active{transform:translateY(-50%) scale(.97)}:host([data-position$="-right"]) .__P__-fab[data-edge-tab]{right:0;left:auto;border-radius:12px 0 0 12px;box-shadow:-6px 0 18px -8px #0000004d}:host([data-position$="-left"]) .__P__-fab[data-edge-tab]{left:0;right:auto;border-radius:0 12px 12px 0;box-shadow:6px 0 18px -8px #0000004d}.__P__-fab[data-edge-tab][data-leaving]{position:fixed;top:50%;bottom:auto;animation:__P__-edge-tab-out var(--__P__-dur-quick) var(--__P__-ease) forwards}@keyframes __P__-edge-tab-in{0%{opacity:0;transform:translateY(-50%) scale(.9)}to{opacity:1;transform:translateY(-50%) scale(1)}}@keyframes __P__-edge-tab-out{0%{opacity:1;transform:translateY(-50%) scale(1)}to{opacity:0;transform:translateY(-50%) scale(.85)}}@keyframes __P__-drawer-in{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes __P__-drawer-in-left{0%{transform:translate(-100%)}to{transform:translate(0)}}@media(prefers-reduced-motion:reduce){:host([data-mode="drawer"]) .__P__-panel,.__P__-fab[data-edge-tab]{animation:none}}.__P__-header{display:flex;align-items:center;gap:var(--__P__-space-2);padding:10px 12px;border-bottom:1px solid var(--__P__-border);background:var(--__P__-bg)}.__P__-header h1{font-size:calc(14px * var(--__P__-text-scale));font-weight:600;flex:1;letter-spacing:-.01em}.__P__-header-actions{margin-inline-start:auto;display:flex;align-items:center;gap:var(--__P__-space-1);flex-shrink:0}.__P__-agent{flex:1;display:inline-flex;align-items:center;gap:10px;min-width:0}.__P__-agent-avatar{position:relative;width:32px;height:32px;border-radius:999px;background:var(--__P__-bg-elevated);color:var(--__P__-fg-muted);display:inline-flex;align-items:center;justify-content:center;font-weight:700;font-size:var(--__P__-text-xs);overflow:hidden;flex-shrink:0}.__P__-agent-avatar img{width:100%;height:100%;object-fit:cover}.__P__-agent-avatar:after{content:"";position:absolute;right:-1px;bottom:-1px;width:10px;height:10px;border-radius:999px;border:2px solid var(--__P__-bg);background:var(--__P__-neutral)}.__P__-agent-avatar[data-status=online]:after{background:var(--__P__-success)}.__P__-agent-avatar[data-status=away]:after{background:var(--__P__-warning)}.__P__-agent-avatar[data-status=offline]:after{background:var(--__P__-neutral)}.__P__-agent-meta{display:flex;flex-direction:column;line-height:1.15;min-width:0}.__P__-agent-meta strong{font-size:calc(14px * var(--__P__-text-scale));font-weight:600;letter-spacing:-.01em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-agent-meta span{font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-suggestions{display:flex;flex-wrap:nowrap;gap:var(--__P__-space-2);padding:6px 14px 10px;overflow-x:auto;overflow-y:hidden;scroll-behavior:smooth;scroll-snap-type:x proximity;scrollbar-width:none;-ms-overflow-style:none;min-width:0}.__P__-suggestions::-webkit-scrollbar{display:none}.__P__-suggestions:before,.__P__-suggestions:after{content:"";flex:1 1 0;min-width:0}.__P__-suggestion{flex:0 0 auto;scroll-snap-align:center;padding:7px 14px;border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);color:var(--__P__-fg);font-size:var(--__P__-text-sm);font-weight:500;white-space:nowrap;transition:background var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease)}.__P__-suggestion:hover{border-color:var(--__P__-accent);color:var(--__P__-accent);transform:translateY(-1px)}.__P__-suggestion:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px;border-color:var(--__P__-accent)}.__P__-suggestion:active{transform:translateY(0)}.__P__-icon-btn{width:32px;height:32px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted);transition:background var(--__P__-dur-quick) var(--__P__-ease),color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-icon-btn:hover{background:var(--__P__-bg-elevated);color:var(--__P__-fg)}.__P__-icon-btn:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-icon-btn:active{background:var(--__P__-border)}.__P__-icon-btn:disabled{opacity:.45;cursor:not-allowed}.__P__-icon-btn:before{content:"";position:absolute;inset:-6px}.__P__-icon-btn{position:relative}.__P__-icon-btn svg{width:18px;height:18px}.__P__-icon-btn[data-recording=true]{color:var(--__P__-accent);background:color-mix(in srgb,var(--__P__-accent) 12%,transparent);animation:__P__-pulse 1.2s var(--__P__-ease) infinite}@keyframes __P__-pulse{0%,to{box-shadow:0 0 color-mix(in srgb,var(--__P__-accent) 40%,transparent)}50%{box-shadow:0 0 0 6px color-mix(in srgb,var(--__P__-accent) 0%,transparent)}}.__P__-list,.__P__-history,.__P__-module-scroll,.__P__-home-scroll,.__P__-help-list,.__P__-toolui-code,.__P__-sidebar-conversations{scrollbar-width:thin;scrollbar-color:var(--__P__-border-strong) transparent;overscroll-behavior:contain;scrollbar-gutter:stable}.__P__-list::-webkit-scrollbar,.__P__-history::-webkit-scrollbar,.__P__-module-scroll::-webkit-scrollbar,.__P__-home-scroll::-webkit-scrollbar,.__P__-help-list::-webkit-scrollbar,.__P__-toolui-code::-webkit-scrollbar,.__P__-sidebar-conversations::-webkit-scrollbar{width:8px}.__P__-list::-webkit-scrollbar-thumb,.__P__-history::-webkit-scrollbar-thumb,.__P__-module-scroll::-webkit-scrollbar-thumb,.__P__-home-scroll::-webkit-scrollbar-thumb,.__P__-help-list::-webkit-scrollbar-thumb,.__P__-toolui-code::-webkit-scrollbar-thumb,.__P__-sidebar-conversations::-webkit-scrollbar-thumb{background:var(--__P__-border-strong);border-radius:8px}.__P__-list-wrap{position:relative;flex:1;min-height:0;display:flex;flex-direction:column}.__P__-jump{position:absolute;inset-inline-end:14px;bottom:14px;z-index:2;display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:999px;border:1px solid var(--__P__-border);background:var(--__P__-bg-elevated);color:var(--__P__-fg);box-shadow:var(--__P__-shadow-panel);cursor:pointer;opacity:.85;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease);animation:__P__-bubble-in var(--__P__-dur-base) var(--__P__-ease)}.__P__-jump:hover{opacity:1}.__P__-jump:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;opacity:1}.__P__-jump:active{transform:translateY(1px)}.__P__-jump svg{width:18px;height:18px}.__P__-list{flex:1;min-height:0;overflow-y:auto;padding:var(--__P__-space-4);padding-bottom:var(--__P__-space-8);display:flex;flex-direction:column;gap:14px}.__P__-date-divider{position:sticky;top:var(--__P__-space-2);z-index:2;display:flex;justify-content:center;align-items:flex-start;height:0;margin:0;pointer-events:none}.__P__-date-pill{padding:3px 10px;border-radius:999px;font-size:calc(11px * var(--__P__-text-scale));font-weight:600;color:var(--__P__-fg-muted);background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);box-shadow:var(--__P__-shadow-card);opacity:0;pointer-events:none;transition:opacity var(--__P__-dur-base) var(--__P__-ease)}.__P__-list[data-scrolling=true] .__P__-date-pill{opacity:1;pointer-events:auto}@media(prefers-reduced-motion:reduce){.__P__-date-pill{transition:none}}.__P__-bubble-row{display:flex}.__P__-bubble-row[data-role=user]{justify-content:flex-end}.__P__-bubble-row[data-role=assistant]{justify-content:flex-start}.__P__-bubble{max-width:100%;padding:var(--__P__-space-3) var(--__P__-space-4);border-radius:var(--__P__-radius);line-height:1.6;font-size:calc(14px * var(--__P__-text-scale));word-wrap:break-word;overflow-wrap:anywhere;box-shadow:0 1px 2px #0000000a,0 1px 8px -4px #0000000f;animation:__P__-bubble-in var(--__P__-dur-base) var(--__P__-ease)}.__P__-bubble ::selection{background:color-mix(in srgb,var(--__P__-accent) 30%,transparent)}.__P__-bubble-row[data-role=user] .__P__-bubble ::selection{background:#fff6;color:var(--__P__-bubble-user-text)}@keyframes __P__-bubble-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}.__P__-bubble-row[data-role=user] .__P__-bubble{background:var(--__P__-bubble-user);color:var(--__P__-bubble-user-text);border-end-end-radius:5px}.__P__-bubble-row[data-role=assistant] .__P__-bubble{background:var(--__P__-bubble-assistant);color:var(--__P__-bubble-assistant-text);border-end-start-radius:5px}.__P__-bubble-col{display:flex;flex-direction:column;max-width:85%;min-width:0}.__P__-bubble-row[data-role=user] .__P__-bubble-col{align-items:flex-end}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col{align-items:flex-start}.__P__-bubble-time{margin-top:3px;padding:0 4px;font-size:calc(11px * var(--__P__-text-scale));line-height:1;color:var(--__P__-fg-muted);user-select:none}.__P__-md>*:first-child{margin-top:0}.__P__-md>*:last-child{margin-bottom:0}.__P__-md p{margin:10px 0}.__P__-md h1,.__P__-md h2,.__P__-md h3,.__P__-md h4,.__P__-md h5,.__P__-md h6{margin:18px 0 8px;line-height:1.3;letter-spacing:-.01em;font-weight:700}.__P__-md h1{font-size:1.4em}.__P__-md h2{font-size:1.22em}.__P__-md h3{font-size:1.08em}.__P__-md h4,.__P__-md h5,.__P__-md h6{font-size:1em}.__P__-md>h1:first-child,.__P__-md>h2:first-child,.__P__-md>h3:first-child,.__P__-md>h4:first-child,.__P__-md>h5:first-child,.__P__-md>h6:first-child{margin-top:0}.__P__-md ul,.__P__-md ol{padding-inline-start:1.5em;margin:10px 0}.__P__-md ul{list-style:disc}.__P__-md ol{list-style:decimal}.__P__-md li{margin:6px 0;padding-inline-start:2px}.__P__-md li::marker{color:var(--__P__-fg-muted)}.__P__-md li>p{margin:6px 0}.__P__-md li>ul,.__P__-md li>ol{margin:6px 0}.__P__-md strong,.__P__-md b{font-weight:650;letter-spacing:-.005em}.__P__-md em,.__P__-md i{font-style:italic}.__P__-md code{font-family:var(--__P__-font-mono);font-size:.86em;padding:1px 6px;border-radius:5px;background:color-mix(in srgb,var(--__P__-accent) 10%,transparent);color:var(--__P__-fg);border:1px solid color-mix(in srgb,var(--__P__-accent) 16%,transparent)}.__P__-md pre{font-family:var(--__P__-font-mono);font-size:calc(12.5px * var(--__P__-text-scale));padding:12px 14px;border-radius:var(--__P__-radius-sm);background:#7f7f7f1f;overflow-x:auto;margin:var(--__P__-space-3) 0;line-height:1.5}.__P__-md pre code{padding:0;background:none}.__P__-md a{color:inherit;text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px}.__P__-md a:hover{text-decoration-thickness:2px}.__P__-md blockquote{margin:14px 0;padding:6px 14px;border-inline-start:3px solid color-mix(in srgb,var(--__P__-accent) 50%,transparent);background:color-mix(in srgb,var(--__P__-accent) 5%,transparent);border-start-end-radius:var(--__P__-radius-sm);border-end-end-radius:var(--__P__-radius-sm);color:var(--__P__-fg-muted)}.__P__-md blockquote>:first-child{margin-top:0}.__P__-md blockquote>:last-child{margin-bottom:0}.__P__-md hr{border:0;height:1px;background:color-mix(in srgb,currentColor 18%,transparent);margin:var(--__P__-space-4) 0}.__P__-md table{border-collapse:collapse;margin:var(--__P__-space-3) 0;font-size:.95em;display:block;overflow-x:auto;max-width:100%;font-variant-numeric:tabular-nums}.__P__-md th,.__P__-md td{padding:6px 10px;border-bottom:1px solid color-mix(in srgb,currentColor 12%,transparent);text-align:start}.__P__-md th{font-weight:700;background:color-mix(in srgb,currentColor 6%,transparent)}.__P__-md h1+ul,.__P__-md h1+ol,.__P__-md h2+ul,.__P__-md h2+ol,.__P__-md h3+ul,.__P__-md h3+ol,.__P__-md h4+ul,.__P__-md h4+ol{margin-top:var(--__P__-space-1)}.__P__-loading{display:inline-flex;align-items:center;gap:var(--__P__-space-2);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-loading-spinner{width:14px;height:14px;border-radius:999px;border:2px solid currentColor;border-top-color:transparent;animation:__P__-spin .8s linear infinite}@keyframes __P__-spin{to{transform:rotate(1turn)}}.__P__-typing{display:inline-flex;gap:var(--__P__-space-1);padding:var(--__P__-space-1) 0}.__P__-typing span{width:5px;height:5px;border-radius:999px;background:currentColor;opacity:.4;animation:__P__-blink 1.2s var(--__P__-ease) infinite}.__P__-typing span:nth-child(2){animation-delay:.2s}.__P__-typing span:nth-child(3){animation-delay:.4s}@keyframes __P__-blink{0%,80%,to{opacity:.3;transform:translateY(0)}40%{opacity:1;transform:translateY(-2px)}}.__P__-reasoning{margin:var(--__P__-space-1) 0 var(--__P__-space-2);padding-inline-start:var(--__P__-space-3);border-inline-start:2px solid var(--__P__-border-strong)}.__P__-reasoning-summary{display:inline-flex;align-items:center;gap:var(--__P__-space-1);cursor:pointer;list-style:none;user-select:none;color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600}.__P__-reasoning-summary:hover{color:var(--__P__-fg)}.__P__-reasoning-summary:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-reasoning-summary::-webkit-details-marker{display:none}.__P__-reasoning-summary:before{content:"";width:5px;height:5px;border-inline-end:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(-45deg);opacity:.7;transition:transform var(--__P__-dur-quick) var(--__P__-ease)}.__P__-reasoning[open] .__P__-reasoning-summary:before{transform:rotate(45deg)}.__P__-reasoning[data-active=true] .__P__-reasoning-label{animation:__P__-reasoning-pulse 1.4s var(--__P__-ease) infinite}@keyframes __P__-reasoning-pulse{0%,to{opacity:.5}50%{opacity:1}}@media(prefers-reduced-motion:reduce){.__P__-reasoning[data-active=true] .__P__-reasoning-label{animation:none}}.__P__-reasoning-body{margin-top:var(--__P__-space-1);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-reasoning-body>:first-child{margin-top:0}.__P__-reasoning-body>:last-child{margin-bottom:0}.__P__-source{display:inline-flex;align-items:center;gap:6px;max-width:100%;margin-top:6px;margin-inline-end:6px;padding:var(--__P__-space-1) var(--__P__-space-2);border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);text-decoration:none}a.__P__-source:hover{color:var(--__P__-fg);border-color:var(--__P__-accent)}.__P__-source-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-composer{border-top:1px solid var(--__P__-border);padding:10px 12px;background:var(--__P__-bg);display:flex;flex-direction:column;gap:var(--__P__-space-2)}.__P__-composer-row{display:flex;align-items:flex-end;gap:6px}.__P__-textarea{flex:1;height:40px;max-height:160px;padding:10px 12px;border-radius:var(--__P__-radius);background:var(--__P__-bg-elevated);border:1px solid transparent;font-size:calc(14px * var(--__P__-text-scale));line-height:1.4;transition:height var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease),box-shadow var(--__P__-dur-quick) var(--__P__-ease)}.__P__-textarea:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:1px;border-color:var(--__P__-focus)}@media(pointer:coarse){.__P__-textarea,.__P__-home-search-input{font-size:max(16px,calc(16px * var(--__P__-text-scale)))}.__P__-textarea{height:44px}}.__P__-send{width:40px;height:40px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),transform var(--__P__-dur-quick) var(--__P__-ease),background var(--__P__-dur-quick) var(--__P__-ease)}.__P__-send[data-shape=circle]{border-radius:999px}.__P__-send[data-shape=square]{border-radius:var(--__P__-radius-sm)}.__P__-send[data-shape=pill]{width:auto;padding:0 18px;border-radius:999px}.__P__-send[data-variant=filled]{background:var(--__P__-accent);color:var(--__P__-accent-text)}.__P__-send[data-variant=outline]{background:transparent;color:var(--__P__-accent);border-color:var(--__P__-accent)}.__P__-send[data-variant=outline]:not(:disabled):hover{background:color-mix(in srgb,var(--__P__-accent) 10%,transparent)}.__P__-send[data-variant=ghost]{background:transparent;color:var(--__P__-accent)}.__P__-send[data-variant=ghost]:not(:disabled):hover{background:color-mix(in srgb,var(--__P__-accent) 8%,transparent)}.__P__-send:disabled{opacity:.4;cursor:not-allowed}.__P__-send:not(:disabled):hover{transform:translateY(-1px)}.__P__-send:not(:disabled):active{transform:translateY(0)}.__P__-send:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-send svg{width:18px;height:18px}.__P__-composer-actions{display:flex;gap:var(--__P__-space-1);flex-wrap:wrap}.__P__-attachments{display:flex;flex-wrap:wrap;gap:6px}.__P__-attachment-chip{display:inline-flex;align-items:center;gap:6px;padding:var(--__P__-space-1) var(--__P__-space-2) var(--__P__-space-1) var(--__P__-space-1);border-radius:999px;background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);font-size:var(--__P__-text-xs);max-width:200px}.__P__-attachment-thumb{width:24px;height:24px;border-radius:999px;object-fit:cover;background:var(--__P__-border)}.__P__-attachment-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.__P__-attachment-remove{width:18px;height:18px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted)}.__P__-attachment-remove:hover{background:var(--__P__-border);color:var(--__P__-fg)}.__P__-dropzone{position:absolute;inset:8px;border:2px dashed var(--__P__-accent);border-radius:var(--__P__-radius);background:color-mix(in srgb,var(--__P__-accent) 8%,transparent);display:flex;align-items:center;justify-content:center;font-weight:600;color:var(--__P__-accent);pointer-events:none;z-index:10;animation:__P__-fade-in var(--__P__-dur-quick) var(--__P__-ease)}@keyframes __P__-fade-in{0%{opacity:0}to{opacity:1}}.__P__-error{margin-top:var(--__P__-space-1);padding:8px 10px;border-radius:var(--__P__-radius-sm);background:var(--__P__-danger-bg);color:var(--__P__-danger-text);font-size:var(--__P__-text-sm);display:flex;align-items:center;gap:var(--__P__-space-2)}.__P__-error button{color:inherit;text-decoration:underline;font-size:var(--__P__-text-sm)}.__P__-history{flex:1;overflow-y:auto;padding:var(--__P__-space-2) var(--__P__-space-1) var(--__P__-space-3)}.__P__-history-footer{flex:none;padding:var(--__P__-space-2) var(--__P__-space-3) var(--__P__-space-3);border-top:1px solid var(--__P__-border);background:var(--__P__-surface)}.__P__-history-new{width:100%;display:flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);padding:var(--__P__-space-2) var(--__P__-space-3);border:none;border-radius:var(--__P__-radius-md);background:var(--__P__-accent);color:var(--__P__-on-accent);cursor:pointer;font-size:var(--__P__-text-sm);font-weight:600;transition:filter var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-history-new svg{width:16px;height:16px}.__P__-history-new:hover{filter:brightness(1.08)}.__P__-history-new:active{transform:translateY(1px)}.__P__-history-new:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-history-empty{flex:1;display:flex;align-items:center;justify-content:center;padding:40px 16px;color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale));text-align:center}.__P__-history-group{display:flex;flex-direction:column;padding:0 var(--__P__-space-3)}.__P__-history-heading{font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);padding:14px 4px 8px;text-transform:uppercase;letter-spacing:.04em}.__P__-history-card{display:flex;flex-direction:column;background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-lg, 14px);overflow:hidden}.__P__-history-item{all:unset;display:flex;align-items:center;gap:var(--__P__-space-3);padding:12px var(--__P__-space-3);cursor:pointer;transition:background var(--__P__-dur-base) var(--__P__-ease)}.__P__-history-item+.__P__-history-item{border-top:1px solid var(--__P__-border)}.__P__-history-item:hover{background:var(--__P__-bg-elevated)}.__P__-history-item:focus-visible{background:var(--__P__-bg-elevated);outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-history-avatar{flex:none;display:grid;place-items:center;width:36px;height:36px;border-radius:50%;background:color-mix(in oklab,var(--__P__-accent) 12%,transparent);color:var(--__P__-accent)}.__P__-history-avatar svg{width:18px;height:18px}.__P__-history-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.__P__-history-row{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-2)}.__P__-history-title{flex:1;min-width:0;font-size:calc(14px * var(--__P__-text-scale));font-weight:500;color:var(--__P__-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-history-time{flex:none;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-history-preview{flex:1;min-width:0;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-history-dot{flex:none;width:8px;height:8px;border-radius:50%;background:var(--__P__-accent)}.__P__-history-item[data-unread=true] .__P__-history-title{font-weight:600}.__P__-history-item[data-closed=true] .__P__-history-title{color:var(--__P__-fg-muted)}.__P__-history-item-skeleton{cursor:default;pointer-events:none}.__P__-skeleton{display:block;border-radius:4px;background:linear-gradient(90deg,color-mix(in oklab,var(--__P__-fg) 9%,transparent) 30%,color-mix(in oklab,var(--__P__-fg) 17%,transparent),color-mix(in oklab,var(--__P__-fg) 9%,transparent) 70%);background-size:200% 100%;animation:__P__-skeleton-shimmer 1.8s ease-in-out infinite}.__P__-history-avatar.__P__-skeleton{border-radius:50%}.__P__-skeleton-heading{width:52px;height:8px}.__P__-skeleton-title{width:55%;height:12px}.__P__-skeleton-time{width:34px;height:10px}.__P__-skeleton-preview{width:80%;height:10px}@keyframes __P__-skeleton-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media(prefers-reduced-motion:reduce){.__P__-skeleton{animation:none}}.__P__-list-loading{margin:auto;padding:var(--__P__-space-6) var(--__P__-space-4);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);text-align:center}.__P__-readonly-banner{display:flex;flex-direction:column;align-items:center;gap:10px;padding:14px 12px;margin:0 var(--__P__-space-3) var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated);color:var(--__P__-fg-muted);text-align:center;font-size:var(--__P__-text-sm)}.__P__-readonly-label{line-height:1.4}.__P__-readonly-cta{appearance:none;border:0;cursor:pointer;padding:var(--__P__-space-2) var(--__P__-space-4);border-radius:999px;background:var(--__P__-accent);color:var(--__P__-accent-text, #fff);font:inherit;font-weight:600;font-size:var(--__P__-text-sm);transition:filter var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-readonly-cta:hover,.__P__-readonly-cta:focus-visible{filter:brightness(1.1)}.__P__-readonly-cta:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px}.__P__-composer-footer{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:10px 16px;margin:0 var(--__P__-space-3);border-top:1px solid var(--__P__-border);text-align:center;font-size:calc(11px * var(--__P__-text-scale));line-height:1.4;color:var(--__P__-fg-muted)}.__P__-disclaimer{max-width:320px;margin:0 auto;opacity:.9;letter-spacing:.01em}.__P__-poweredby{display:inline-flex;align-items:center;justify-content:center;gap:6px;color:inherit;text-decoration:none;opacity:.7;transition:opacity var(--__P__-dur-base) var(--__P__-ease);font-size:calc(11px * var(--__P__-text-scale));letter-spacing:.02em}.__P__-poweredby:hover{opacity:1}.__P__-poweredby-logo{height:12px;width:auto;display:inline-block;vertical-align:middle}.__P__-poweredby-bar{flex:none;display:flex;align-items:center;justify-content:center;padding:6px 16px;border-top:1px solid var(--__P__-border);background:var(--__P__-bg-elevated)}.__P__-menu-wrap{position:relative;display:inline-flex}.__P__-menu{position:absolute;top:100%;inset-inline-end:0;margin-top:6px;min-width:200px;padding:6px;background:var(--__P__-bg);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);box-shadow:var(--__P__-shadow-panel);z-index:10;display:flex;flex-direction:column;gap:2px;animation:__P__-menu-in var(--__P__-dur-base) var(--__P__-ease)}@media(prefers-reduced-motion:reduce){.__P__-menu{animation:none}}@keyframes __P__-menu-in{0%{opacity:0;transform:translateY(-4px) scale(.98);transform-origin:top right}to{opacity:1;transform:none}}.__P__-menu-item{all:unset;display:flex;align-items:center;gap:10px;padding:8px 10px;font-size:var(--__P__-text-sm);color:var(--__P__-fg);border-radius:var(--__P__-radius-sm);cursor:pointer;user-select:none}.__P__-menu-item:hover{background:var(--__P__-bg-elevated)}.__P__-menu-item:focus-visible{background:var(--__P__-bg-elevated);outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-menu-item[disabled]{opacity:.45;cursor:not-allowed}.__P__-menu-icon{display:inline-flex;width:16px;height:16px;color:var(--__P__-fg-muted)}.__P__-menu-icon svg{width:16px;height:16px}.__P__-menu-label{flex:1}.__P__-menu-check{display:inline-flex;color:var(--__P__-accent)}.__P__-menu-check svg{width:14px;height:14px}.__P__-menu-item-segmented{cursor:default}.__P__-menu-item-segmented:hover{background:transparent}.__P__-segmented{display:inline-flex;gap:2px;padding:2px;background:var(--__P__-bg-elevated);border-radius:var(--__P__-radius-sm)}.__P__-segment{all:unset;min-width:26px;padding:3px 8px;font-size:var(--__P__-text-xs);font-weight:600;letter-spacing:.02em;text-align:center;color:var(--__P__-fg-muted);border-radius:calc(var(--__P__-radius-sm) - 2px);cursor:pointer;transition:color .12s ease,background .12s ease}.__P__-segment:hover{color:var(--__P__-fg)}.__P__-segment[data-on=true]{background:var(--__P__-bg);color:var(--__P__-accent);box-shadow:var(--__P__-shadow-card)}.__P__-segment:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-resize-grip{position:absolute;width:18px;height:18px;display:flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted);opacity:.45;transition:opacity var(--__P__-dur-base) var(--__P__-ease);z-index:2;touch-action:none;user-select:none}.__P__-resize-grip:hover,.__P__-resize-grip:focus-visible{opacity:1}.__P__-resize-grip svg{width:10px;height:10px}.__P__-resize-grip--bottom-left{bottom:2px;left:2px;cursor:nesw-resize;transform:scaleX(-1)}.__P__-resize-grip--bottom-right{bottom:2px;right:2px;cursor:nwse-resize}.__P__-resize-grip--top-left{top:2px;left:2px;cursor:nwse-resize;transform:rotate(180deg)}.__P__-resize-grip--top-right{top:2px;right:2px;cursor:nesw-resize;transform:scaleY(-1)}:host(:not([data-mode="open"])) .__P__-resize-grip{display:none}.__P__-messenger{display:flex;flex-direction:column;overflow:hidden}.__P__-messenger-body,.__P__-messenger-pane{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}.__P__-messenger-pane[hidden]{display:none}@keyframes __P__-view-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}.__P__-module{display:flex;flex-direction:column;height:100%;min-height:0}@media(prefers-reduced-motion:no-preference){.__P__-module,.__P__-history{animation:__P__-view-in .18s var(--__P__-ease-out)}}.__P__-module-scroll{flex:1;min-height:0;overflow-y:auto;padding:var(--__P__-space-3);display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-home{container-type:inline-size;background:radial-gradient(125% 65% at 88% 0%,color-mix(in srgb,#fff 16%,transparent),transparent 55%),linear-gradient(180deg,var(--__P__-accent) 0%,var(--__P__-accent) 22%,color-mix(in srgb,var(--__P__-accent) 28%,var(--__P__-surface)) 44%,var(--__P__-surface) 70%);border-radius:var(--__P__-radius-lg) var(--__P__-radius-lg) 0 0}.__P__-home-scroll{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;background:transparent}.__P__-home-cards{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:4px 14px 16px}.__P__-module-pad{padding:var(--__P__-space-3) var(--__P__-space-3) 0}.__P__-module-empty{display:flex;flex-direction:column;align-items:center;gap:var(--__P__-space-3);padding:var(--__P__-space-8) var(--__P__-space-4);text-align:center;color:var(--__P__-fg-muted);font-size:var(--__P__-text-base)}.__P__-module-retry{padding:var(--__P__-space-2) var(--__P__-space-4);border:1px solid var(--__P__-border-strong);border-radius:var(--__P__-radius-sm);color:var(--__P__-fg);font-weight:600;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out),border-color var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-module-retry:hover{background:var(--__P__-hover);border-color:var(--__P__-accent)}.__P__-module-retry:active{background:var(--__P__-border)}.__P__-module-retry:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-help-list{flex:1;min-height:0;overflow-y:auto;padding-bottom:var(--__P__-space-3)}.__P__-help-group{display:flex;flex-direction:column}.__P__-help-section-title{position:sticky;top:0;z-index:1;margin:0;padding:var(--__P__-space-3) var(--__P__-space-5) var(--__P__-space-2);font-size:var(--__P__-text-xs);font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--__P__-fg-muted);background:var(--__P__-bg)}.__P__-help-card{margin:0 var(--__P__-space-3) var(--__P__-space-3);background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);overflow:hidden}.__P__-help-card .__P__-list-row{border-bottom:0;border-radius:0}.__P__-help-card .__P__-list-row+.__P__-list-row{border-top:1px solid var(--__P__-border)}.__P__-module-cta{padding:var(--__P__-space-3);border-top:1px solid var(--__P__-border)}.__P__-tabbar{display:flex;border-top:1px solid var(--__P__-border);background:var(--__P__-bg-elevated);flex-shrink:0}.__P__-tab{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--__P__-space-1);min-height:48px;padding:var(--__P__-space-2) var(--__P__-space-1);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600;transition:color var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-tab:hover{color:var(--__P__-fg)}.__P__-tab[aria-selected=true]{color:var(--__P__-accent)}.__P__-tab:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-tab:active{background:var(--__P__-hover)}.__P__-tab-icon{position:relative;display:inline-flex}.__P__-tab-icon svg{width:22px;height:22px}.__P__-tab-badge{position:absolute;top:-4px;left:calc(50% + 6px);min-width:16px;height:16px;padding:0 4px;display:inline-flex;align-items:center;justify-content:center;border-radius:999px;background:var(--__P__-accent);color:var(--__P__-on-accent);font-size:calc(10px * var(--__P__-text-scale));font-weight:600;line-height:1}.__P__-home-hero{flex-shrink:0;padding:var(--__P__-space-5) var(--__P__-space-5) var(--__P__-space-3);color:var(--__P__-on-accent);--__P__-focus: var(--__P__-on-accent)}.__P__-home-hero-top{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-3);min-height:32px}.__P__-home-brand{font-size:clamp(calc(12px * var(--__P__-text-scale)),calc(3.2cqi * var(--__P__-text-scale)),calc(14px * var(--__P__-text-scale)));font-weight:600;letter-spacing:.01em;color:color-mix(in srgb,#fff 82%,transparent);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.__P__-home-brand-spacer{flex:1}.__P__-home-hero-actions{display:flex;align-items:center;gap:var(--__P__-space-2);flex-shrink:0}.__P__-home-hero-actions .__P__-icon-btn{color:#fff}.__P__-home-hero-actions .__P__-icon-btn:hover{background:color-mix(in srgb,#fff 18%,transparent);color:#fff}.__P__-home-hero-actions .__P__-icon-btn:active{background:color-mix(in srgb,#fff 26%,transparent)}.__P__-home-greeting{margin:28px 0 0;font-family:var(--__P__-font-display);font-size:clamp(calc(19px * var(--__P__-text-scale)),calc(5.5cqi * var(--__P__-text-scale)),var(--__P__-text-2xl));font-weight:800;line-height:1.18;letter-spacing:-.01em;overflow-wrap:anywhere}.__P__-home-lead{margin:10px 0 0;font-family:var(--__P__-font-display);font-size:clamp(calc(15px * var(--__P__-text-scale)),calc(4.2cqi * var(--__P__-text-scale)),var(--__P__-text-xl));font-weight:600;line-height:1.25;letter-spacing:-.005em;color:color-mix(in srgb,var(--__P__-on-accent) 78%,transparent);overflow-wrap:anywhere}.__P__-home-avatars{display:flex}.__P__-home-avatar{width:30px;height:30px;border-radius:999px;overflow:hidden;margin-inline-start:-10px;border:2px solid color-mix(in srgb,#fff 92%,transparent);box-shadow:0 1px 3px #0000002e;background:var(--__P__-surface);display:inline-flex;align-items:center;justify-content:center;font-size:var(--__P__-text-xs);font-weight:700;color:var(--__P__-fg)}.__P__-home-avatar:first-child{margin-inline-start:0}.__P__-home-avatar img{width:100%;height:100%;object-fit:cover}.__P__-home-content{background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);box-shadow:var(--__P__-shadow-card);overflow:hidden}.__P__-home-content-title{padding:var(--__P__-space-4) var(--__P__-space-4) var(--__P__-space-3);font-size:var(--__P__-text-sm);font-weight:700}.__P__-home-content-list{display:flex;flex-direction:column;padding:0 var(--__P__-space-2) var(--__P__-space-2)}.__P__-home-content-list .__P__-list-row+.__P__-list-row{border-top:1px solid var(--__P__-border)}.__P__-home-card{display:block;width:100%;text-align:start;background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);padding:var(--__P__-space-4);box-shadow:var(--__P__-shadow-card)}.__P__-home-card[data-interactive=true]{cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-home-card[data-interactive=true]:hover{background:var(--__P__-bg-elevated)}.__P__-home-card[data-interactive=true]:active{transform:translateY(1px)}.__P__-home-card[data-interactive=true]:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-home-recent-row{display:flex;align-items:center;gap:var(--__P__-space-3)}.__P__-home-recent-avatar{display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;flex-shrink:0;border-radius:999px;background:color-mix(in oklch,var(--__P__-accent) 14%,transparent);color:var(--__P__-accent)}.__P__-home-recent-avatar svg{width:20px;height:20px}.__P__-home-recent-body{display:flex;flex-direction:column;gap:3px;min-width:0;flex:1}.__P__-home-recent-title{font-weight:600;font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-recent-preview{color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.__P__-home-recent-at{color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);flex-shrink:0}.__P__-home-recent-dot{width:8px;height:8px;border-radius:999px;background:var(--__P__-accent);flex-shrink:0}.__P__-home-recent-row[data-unread=true] .__P__-home-recent-title{font-weight:700}.__P__-home-status{display:flex;align-items:center;gap:var(--__P__-space-3)}.__P__-home-status-icon svg{width:22px;height:22px;color:var(--__P__-success)}.__P__-home-status[data-level=degraded] .__P__-home-status-icon svg{color:var(--__P__-warning)}.__P__-home-status[data-level=down] .__P__-home-status-icon svg{color:var(--__P__-danger)}.__P__-home-status-text{font-weight:600;font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-search{display:flex;align-items:center;gap:var(--__P__-space-2);width:100%;padding:var(--__P__-space-3) var(--__P__-space-4);border-radius:var(--__P__-radius);border:1px solid var(--__P__-border);background:var(--__P__-surface);text-align:start}.__P__-home-search[data-input=true]{background:var(--__P__-bg-elevated)}.__P__-home-search:hover{border-color:var(--__P__-border-strong)}.__P__-home-search:focus-visible,.__P__-home-search:focus-within{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-home-search-text{flex:1;color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale))}.__P__-home-search-input{flex:1;border:0;background:transparent;font-size:calc(14px * var(--__P__-text-scale));color:var(--__P__-fg);outline:none}.__P__-home-search-icon svg{width:18px;height:18px;color:var(--__P__-accent)}.__P__-list-row{display:flex;align-items:center;gap:var(--__P__-space-3);width:100%;min-height:44px;text-align:start;padding:var(--__P__-space-3) var(--__P__-space-2);border-radius:var(--__P__-radius-sm)}.__P__-list-row:hover{background:var(--__P__-hover)}.__P__-list-row:active{background:var(--__P__-border)}.__P__-list-row:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}.__P__-list-row-body{display:flex;flex-direction:column;min-width:0;flex:1}.__P__-list-row-title{font-weight:600;font-size:var(--__P__-text-md);line-height:1.35}.__P__-list-row-sub{color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);margin-top:var(--__P__-space-1);line-height:1.45;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.__P__-list-row-chevron svg{width:18px;height:18px;color:var(--__P__-accent);flex-shrink:0}.__P__-back-header{display:flex;align-items:center;gap:var(--__P__-space-2);padding:10px 12px;border-bottom:1px solid var(--__P__-border);flex-shrink:0}.__P__-back-title{flex:1;text-align:center;font-size:var(--__P__-text-md);font-weight:700;margin:0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-back-spacer{width:32px;height:1px}.__P__-content{display:flex;flex-direction:column;gap:14px;width:100%;max-width:68ch;margin:0 auto}.__P__-content-hero{width:100%;border-radius:var(--__P__-radius)}.__P__-content-subtitle{color:var(--__P__-fg-muted);margin:0}.__P__-content-frame{flex:1;min-height:0;width:100%;border:0;background:#fff}.__P__-news-list{display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-news-card{display:block;width:100%;text-align:start;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);overflow:hidden;background:var(--__P__-surface)}.__P__-news-card{transition:background var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-news-card:hover{background:var(--__P__-bg-elevated)}.__P__-news-card:active{transform:translateY(1px)}.__P__-news-card:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-news-hero{width:100%;display:block}.__P__-news-body{display:flex;flex-direction:column;gap:6px;padding:14px 16px}.__P__-news-title{font-weight:700;font-size:var(--__P__-text-md)}.__P__-news-summary{color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale));display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.__P__-modules-empty{display:flex;align-items:center;justify-content:center;position:relative}.__P__-modules-empty-close{position:absolute;top:12px;inset-inline-end:12px}.__P__-modules-empty-text{color:var(--__P__-fg-muted);font-size:var(--__P__-text-base)}.__P__-form{display:flex;flex-direction:column;gap:var(--__P__-space-4)}.__P__-field{display:flex;flex-direction:column;gap:6px}.__P__-field-label{font-size:var(--__P__-text-sm);font-weight:600;color:var(--__P__-fg)}.__P__-field-req{color:var(--__P__-danger)}.__P__-field-input{width:100%;min-width:0;max-width:100%;box-sizing:border-box;padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);color:var(--__P__-fg);font:inherit;font-size:var(--__P__-text-sm);resize:vertical;transition:border-color var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-field-input:focus-visible{outline:none;border-color:var(--__P__-accent)}.__P__-field[data-invalid=true] .__P__-field-input{border-color:var(--__P__-danger)}.__P__-field-input[type=date],.__P__-field-input[type=time]{appearance:none;-webkit-appearance:none}@media(pointer:coarse){.__P__-field-input{font-size:max(16px,calc(16px * var(--__P__-text-scale)))}}.__P__-field-hint{font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-field-error{font-size:var(--__P__-text-xs);color:var(--__P__-danger)}.__P__-field-choices{display:flex;flex-direction:column;gap:10px;padding-top:2px}.__P__-choice{display:flex;align-items:flex-start;gap:10px;font-size:var(--__P__-text-sm);color:var(--__P__-fg);cursor:pointer}.__P__-choice input{margin-top:2px;accent-color:var(--__P__-accent)}.__P__-form-actions{display:flex;align-items:center;justify-content:flex-end;gap:var(--__P__-space-2);margin-top:var(--__P__-space-2)}.__P__-form-hint{margin-inline-end:auto;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}.__P__-form-submit{padding:var(--__P__-space-2) var(--__P__-space-4);border:none;border-radius:var(--__P__-radius-md);background:var(--__P__-accent);color:var(--__P__-accent-text, #fff);font:inherit;font-weight:600;font-size:var(--__P__-text-sm);cursor:pointer;transition:filter var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-form-submit:hover:not(:disabled){filter:brightness(1.06)}.__P__-form-submit:disabled{opacity:.6;cursor:default}.__P__-form-skip{padding:var(--__P__-space-2) var(--__P__-space-4);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:transparent;color:var(--__P__-fg-muted);font:inherit;font-size:var(--__P__-text-sm);cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-form-skip:hover:not(:disabled){background:var(--__P__-bg-elevated)}.__P__-form-gate{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated)}.__P__-form-gate-title{margin:0;font-size:var(--__P__-text-base);font-weight:700;color:var(--__P__-fg)}.__P__-form-gate-desc{margin:0 0 var(--__P__-space-1);font-size:var(--__P__-text-sm);color:var(--__P__-fg-muted)}.__P__-form-done{display:flex;align-items:center;justify-content:center;gap:6px;padding:6px 12px;border:1px dashed var(--__P__-border);border-radius:999px;align-self:center;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted)}.__P__-form-done svg{width:14px;height:14px;color:var(--__P__-success, #22c55e)}.__P__-form-done[data-outcome=skipped] svg{color:var(--__P__-fg-muted)}.__P__-form-done-fill{border:0;background:none;padding:0 2px;cursor:pointer;font:inherit;font-weight:600;color:var(--__P__-accent)}.__P__-form-done-fill:hover{text-decoration:underline}details.__P__-form-done{display:block;padding:0;border-radius:var(--__P__-radius-md)}details[open].__P__-form-done{width:min(100%,420px);background:var(--__P__-surface)}.__P__-form-done-summary{display:flex;align-items:center;justify-content:center;gap:6px;padding:8px 12px;cursor:pointer;list-style:none}.__P__-form-done-summary::-webkit-details-marker{display:none}.__P__-form-done-summary>svg:last-child{color:var(--__P__-fg-muted);transition:transform .15s var(--__P__-ease)}details[open]>.__P__-form-done-summary>svg:last-child{transform:rotate(90deg)}.__P__-form-answers{margin:0;padding:var(--__P__-space-2) var(--__P__-space-3) var(--__P__-space-3);display:grid;gap:var(--__P__-space-3);text-align:start}.__P__-form-answer{display:grid;gap:6px}.__P__-form-answer dt{font-size:var(--__P__-text-sm);font-weight:600;color:var(--__P__-fg)}.__P__-form-answer dd{margin:0;padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);font-size:var(--__P__-text-sm);font-weight:400;color:var(--__P__-fg);overflow-wrap:anywhere}.__P__-toolui{display:flex;flex-direction:column;gap:var(--__P__-space-3);margin-top:6px;padding:var(--__P__-space-4);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated);font-size:var(--__P__-text-sm)}.__P__-toolui-stale{opacity:.7}details.__P__-toolui-collapsible{gap:0}details.__P__-toolui-collapsible>:not(summary){margin-top:var(--__P__-space-3)}.__P__-toolui-collapsible>summary{cursor:pointer;list-style:none}.__P__-toolui-collapsible>summary::-webkit-details-marker{display:none}.__P__-toolui-head{display:flex;align-items:center;flex-wrap:wrap;gap:8px}.__P__-toolui-title{margin-inline-end:auto;font-weight:600;color:var(--__P__-fg);overflow-wrap:anywhere}.__P__-toolui-badge{padding:3px 10px;border-radius:999px;border:1px solid var(--__P__-border);background:var(--__P__-bg);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600;white-space:nowrap}.__P__-toolui-badge-accent{border-color:color-mix(in oklab,var(--__P__-warning, #f59e0b) 55%,transparent);background:color-mix(in oklab,var(--__P__-warning, #f59e0b) 12%,transparent);color:var(--__P__-warning, #f59e0b)}.__P__-toolui-status{display:inline-flex;align-items:center;gap:5px;margin-inline-start:auto;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted)}.__P__-toolui-status[data-status=completed],.__P__-toolui-status[data-status=approved]{color:var(--__P__-success, #16a34a)}.__P__-toolui-status[data-status=denied],.__P__-toolui-status[data-status=error]{color:var(--__P__-danger, #dc2626)}.__P__-toolui-desc{margin:0;padding:var(--__P__-space-3);border-radius:var(--__P__-radius-sm);background:var(--__P__-bg);border:1px solid var(--__P__-border);color:var(--__P__-fg-muted);line-height:1.5}.__P__-toolui-section{display:flex;flex-direction:column;gap:6px;padding:var(--__P__-space-3);border-radius:var(--__P__-radius-sm);background:var(--__P__-bg);border:1px solid var(--__P__-border)}.__P__-toolui-label{font-size:var(--__P__-text-xs);font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--__P__-fg-muted)}.__P__-toolui-text{margin:0;font-size:var(--__P__-text-base);font-weight:600;color:var(--__P__-fg);line-height:1.4;overflow-wrap:anywhere}.__P__-toolui-code{margin:0;max-height:220px;overflow:auto;color:var(--__P__-fg);font-size:var(--__P__-text-xs);white-space:pre-wrap;word-break:break-word}.__P__-toolui-code[data-error=true]{color:var(--__P__-danger, #dc2626)}.__P__-toolui-note{margin:0;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted)}:host([dir="rtl"]) .__P__-icon-dir{transform:scaleX(-1)}:host([dir="rtl"]) .__P__-field-input[type=date],:host([dir="rtl"]) .__P__-field-input[type=time]{position:relative;text-align:right;padding-left:34px}:host([dir="rtl"]) .__P__-field-input[type=date]::-webkit-datetime-edit,:host([dir="rtl"]) .__P__-field-input[type=time]::-webkit-datetime-edit{text-align:right}:host([dir="rtl"]) .__P__-field-input[type=date]::-webkit-calendar-picker-indicator,:host([dir="rtl"]) .__P__-field-input[type=time]::-webkit-calendar-picker-indicator{position:absolute;left:var(--__P__-space-3);margin:0}
4
4
  `;var ia=`.__P__-standalone-page{margin:0;height:100vh;background:var(--__P__-bg, #fff);display:grid;place-items:stretch}
5
5
  `;var aa=`:host([data-mode="page"]){min-height:0}:host([data-mode="page"]) .__P__-page-shell{display:grid;grid-template-columns:280px 1fr;width:100%;height:100%;min-height:0;background:var(--__P__-bg);color:var(--__P__-fg);transition:grid-template-columns var(--__P__-dur-base) var(--__P__-ease-in-out)}:host([data-mode="page"]) .__P__-page-shell[data-sidebar-collapsed=true]{grid-template-columns:48px 1fr}:host([data-mode="page"]) .__P__-page-chat{display:flex;flex-direction:column;min-width:0;min-height:0;overflow:hidden}:host([data-mode="page"]) .__P__-anchor{position:static;inset:auto;padding:0;align-items:stretch;width:100%;height:100%;min-width:0;min-height:0;flex:1 1 0}:host([data-mode="page"]) .__P__-panel{width:100%;height:100%;min-width:0;min-height:0;max-width:none;max-height:none;border-radius:0;border:0;box-shadow:none;animation:none}:host([data-mode="page"]) .__P__-sidebar{border-inline-end:1px solid var(--__P__-border);display:flex;flex-direction:column;overflow:hidden;background:var(--__P__-surface)}:host([data-mode="page"]) .__P__-sidebar-header{padding:var(--__P__-space-4) var(--__P__-space-5);border-bottom:1px solid var(--__P__-border);display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-2);min-height:56px;box-sizing:border-box}:host([data-mode="page"]) .__P__-sidebar[data-collapsed=true] .__P__-sidebar-header{padding:var(--__P__-space-4) var(--__P__-space-2);justify-content:center}:host([data-mode="page"]) .__P__-sidebar[data-collapsed=true] .__P__-sidebar-logo,:host([data-mode="page"]) .__P__-sidebar[data-collapsed=true] .__P__-sidebar-title{display:none}:host([data-mode="page"]) .__P__-sidebar-toggle{flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:1px solid var(--__P__-border);border-radius:6px;background:transparent;color:var(--__P__-fg);cursor:pointer;transition:background .12s,border-color .12s}:host([data-mode="page"]) .__P__-sidebar-toggle:hover{background:var(--__P__-hover);border-color:var(--__P__-accent)}:host([data-mode="page"]) .__P__-sidebar-toggle:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px}:host([data-mode="page"]) .__P__-sidebar-logo{height:32px;display:block}:host([data-mode="page"]) .__P__-sidebar-title{font-size:var(--__P__-text-md);font-weight:600}:host([data-mode="page"]) .__P__-sidebar-section{padding:var(--__P__-space-3) var(--__P__-space-4);border-bottom:1px solid var(--__P__-border)}:host([data-mode="page"]) .__P__-sidebar-nav{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}:host([data-mode="page"]) .__P__-sidebar-nav-item{display:flex;align-items:center;gap:10px;padding:var(--__P__-space-2) var(--__P__-space-3);border-radius:var(--__P__-radius-sm);color:var(--__P__-fg);text-decoration:none;font-size:calc(14px * var(--__P__-text-scale));transition:background var(--__P__-dur-quick) var(--__P__-ease-out)}:host([data-mode="page"]) .__P__-sidebar-nav-item:hover{background:var(--__P__-hover)}:host([data-mode="page"]) .__P__-sidebar-nav-item:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px}:host([data-mode="page"]) .__P__-sidebar-cards{display:grid;grid-template-columns:1fr;gap:var(--__P__-space-2)}:host([data-mode="page"]) .__P__-sidebar-card{display:block;padding:10px 12px;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-sm);text-decoration:none;color:var(--__P__-fg);transition:border-color var(--__P__-dur-quick) var(--__P__-ease-out)}:host([data-mode="page"]) .__P__-sidebar-card:hover{border-color:var(--__P__-accent)}:host([data-mode="page"]) .__P__-sidebar-card:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}:host([data-mode="page"]) .__P__-sidebar-card-label{font-weight:600;font-size:calc(14px * var(--__P__-text-scale))}:host([data-mode="page"]) .__P__-sidebar-card-desc{font-size:var(--__P__-text-xs);color:var(--__P__-muted);margin-top:2px}:host([data-mode="page"]) .__P__-sidebar-conversations{flex:1 1 auto;overflow-y:auto;padding:var(--__P__-space-3) var(--__P__-space-4)}:host([data-mode="page"]) .__P__-page-chat{display:flex;flex-direction:column;overflow:hidden}@media(max-width:768px){:host([data-mode="page"]) .__P__-page-shell{grid-template-columns:1fr}:host([data-mode="page"]) .__P__-sidebar{display:none}}
6
6
  `;var Rd="helpai",Ad="#5B5BD6",Ld="#FFFFFF",Md="12px",Nd="Inter, system-ui, -apple-system, 'Segoe UI', sans-serif",ko=[na,ra,oa,ia,aa].join(`
7
- `).replace(/__P__/g,Rd).replaceAll("__BRAND_ACCENT_TEXT__",Ld).replaceAll("__BRAND_ACCENT__",Ad).replaceAll("__BRAND_RADIUS__",Md).replaceAll("__BRAND_FONT__",Nd);var Dd=B.scope("mount"),sa=new WeakMap,la={floating:"all: initial; position: fixed; z-index: 2147483600;",flow:"all: initial; display: block; position: relative; width: 100%; height: 100%; z-index: 1; contain: size;",viewport:"all: initial; display: block; position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1;"};function ca(e,t){e.style.cssText=la[t]}function en(e){return e==="floating"||e==="modal"||e==="drawer"?"floating":e==="standalone"||e==="page"?"viewport":"flow"}function Jn(e={}){let t=e.position??"flow";Dd.debug("createShadowMount",{position:t,hasTarget:!!e.target,hasHost:!!e.existingHost});let n=`${x.cssPrefix}-chat-host`;typeof customElements<"u"&&!customElements.get(n)&&customElements.define(n,class extends HTMLElement{});let r;e.existingHost?r=e.existingHost:(r=document.createElement(n),(e.target??document.body).appendChild(r)),r.setAttribute("data-brand",x.id),r.style.cssText=la[t];let i=r.shadowRoot??r.attachShadow({mode:"open"}),a=r.ownerDocument;if(!Od(i,a)){let s=a.createElement("style");s.textContent=ko,i.appendChild(s)}let l=document.createElement("div");return l.className=`${x.cssPrefix}-app`,i.appendChild(l),{appRoot:l,destroy:()=>r.remove(),hostElement:r,shadowRoot:i}}function Od(e,t){if(!("adoptedStyleSheets"in e))return!1;let n=t.defaultView;if(!n||typeof n.CSSStyleSheet!="function")return!1;let r=sa.get(t);if(!r)try{r=new n.CSSStyleSheet,r.replaceSync(ko),sa.set(t,r)}catch{return!1}try{return e.adoptedStyleSheets=[r],!0}catch{return!1}}function $d(e,t){let n=x.cssPrefix;t.accent&&e.style.setProperty(`--${n}-accent-user`,t.accent),t.accentText&&e.style.setProperty(`--${n}-accent-text-user`,t.accentText),t.radius&&e.style.setProperty(`--${n}-radius`,t.radius),t.fontFamily&&e.style.setProperty(`--${n}-font`,t.fontFamily)}function Hd(e,t){e.dataset.theme=t}function Bd(e,t){let n=x.cssPrefix;t.width!==void 0&&e.style.setProperty(`--${n}-panel-w`,t.width),t.height!==void 0&&e.style.setProperty(`--${n}-panel-h`,t.height),t.expanded?.width!==void 0&&e.style.setProperty(`--${n}-expanded-w`,t.expanded.width),t.expanded?.height!==void 0&&e.style.setProperty(`--${n}-expanded-h`,t.expanded.height),t.inset!==void 0&&e.style.setProperty(`--${n}-panel-inset`,t.inset)}function Fd(e,t){e.dataset.position=t}function Qn(e,t){e.dataset.mode=t}function da(e,t){Hd(e,t.themeMode),$d(e,t.themeOverrides),Fd(e,t.position),Bd(e,t.size)}var zd=B.scope("iframe"),Ud='<!doctype html><html><head><meta charset="utf-8"><style>html,body{margin:0;padding:0;background:transparent;overflow:hidden}</style></head><body></body></html>';function pa(e,t,n="closed",r="floating",i=null){zd.debug("createIframeMount",{position:t,initialMode:n,layoutMode:r,hasTarget:!!i});let a=document.createElement("iframe");a.title=`${x.name} chat`,a.setAttribute("allow","microphone; clipboard-write"),ua(a,t,n,r),(r==="inline"&&i?i:document.body).appendChild(a);let s=a.contentDocument;if(!s)throw new Error("iframe contentDocument unavailable (cross-origin?)");s.open(),s.write(Ud),s.close();let c=Jn({...e,target:s.body}),d=new MutationObserver(()=>{ua(a,t,c.hostElement.dataset.mode??"closed",r)});return d.observe(c.hostElement,{attributes:!0,attributeFilter:["data-mode"]}),{...c,iframeElement:a,destroy(){d.disconnect(),c.destroy(),a.remove()}}}var Zn="border:0;background:transparent;z-index:2147483647;pointer-events:auto;",_a={closed:{w:"88px",h:"88px"},expanded:{w:"min(calc(100vw - 32px), 680px)",h:"min(calc(100vh - 32px), 860px)"},open:{w:"min(calc(100vw - 32px), 440px)",h:"min(calc(100vh - 32px), 700px)"}};function ua(e,t,n,r){if(n==="fullscreen"||r==="standalone"){e.style.cssText=`${Zn}position:fixed;inset:0;width:100vw;height:100vh;`;return}if(r==="inline"){e.style.cssText=`${Zn}position:static;display:block;width:100%;height:100%;`;return}if(typeof matchMedia=="function"&&matchMedia("(max-width: 640px)").matches&&(n==="open"||n==="expanded")){e.style.cssText=`${Zn}position:fixed;inset:0;width:100vw;height:100vh;`;return}let a=t.startsWith("top-")?"top":"bottom",l=t.endsWith("-left")?"left":"right",{w:s,h:c}=_a[n]??_a.open;e.style.cssText=`${Zn}position:fixed;${a}:16px;${l}:16px;width:${s};height:${c};`}var er=class{constructor(){J(this,"handlers",new Map)}on(t,n){let r=this.handlers.get(t);return r||(r=new Set,this.handlers.set(t,r)),r.add(n),()=>this.handlers.get(t)?.delete(n)}emit(t,n){let r=this.handlers.get(t);if(r)for(let i of r)try{i(n)}catch{}}clear(){this.handlers.clear()}};var Et,ue,Co,fa,tn=0,ya=[],me=X,ma=me.__b,ga=me.__r,ha=me.diffed,va=me.__c,ba=me.unmount,xa=me.__;function nr(e,t){me.__h&&me.__h(ue,e,tn||t),tn=0;var n=ue.__H||(ue.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function I(e){return tn=1,Wd(Sa,e)}function Wd(e,t,n){var r=nr(Et++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Sa(void 0,t),function(s){var c=r.__N?r.__N[0]:r.__[0],d=r.t(c,s);c!==d&&(r.__N=[d,r.__[1]],r.__c.setState({}))}],r.__c=ue,!ue.__f)){var i=function(s,c,d){if(!r.__c.__H)return!0;var u=r.__c.__H.__.filter(function(m){return m.__c});if(u.every(function(m){return!m.__N}))return!a||a.call(this,s,c,d);var _=r.__c.props!==s;return u.some(function(m){if(m.__N){var f=m.__[0];m.__=m.__N,m.__N=void 0,f!==m.__[0]&&(_=!0)}}),a&&a.call(this,s,c,d)||_};ue.__f=!0;var a=ue.shouldComponentUpdate,l=ue.componentWillUpdate;ue.componentWillUpdate=function(s,c,d){if(this.__e){var u=a;a=void 0,i(s,c,d),a=u}l&&l.call(this,s,c,d)},ue.shouldComponentUpdate=i}return r.__N||r.__}function T(e,t){var n=nr(Et++,3);!me.__s&&Eo(n.__H,t)&&(n.__=e,n.u=t,ue.__H.__h.push(n))}function nn(e,t){var n=nr(Et++,4);!me.__s&&Eo(n.__H,t)&&(n.__=e,n.u=t,ue.__h.push(n))}function M(e){return tn=5,we(function(){return{current:e}},[])}function we(e,t){var n=nr(Et++,7);return Eo(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function H(e,t){return tn=8,we(function(){return e},t)}function Vd(){for(var e;e=ya.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(tr),t.__h.some(To),t.__h=[]}catch(n){t.__h=[],me.__e(n,e.__v)}}}me.__b=function(e){ue=null,ma&&ma(e)},me.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),xa&&xa(e,t)},me.__r=function(e){ga&&ga(e),Et=0;var t=(ue=e.__c).__H;t&&(Co===ue?(t.__h=[],ue.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(tr),t.__h.some(To),t.__h=[],Et=0)),Co=ue},me.diffed=function(e){ha&&ha(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ya.push(t)!==1&&fa===me.requestAnimationFrame||((fa=me.requestAnimationFrame)||Gd)(Vd)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Co=ue=null},me.__c=function(e,t){t.some(function(n){try{n.__h.some(tr),n.__h=n.__h.filter(function(r){return!r.__||To(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],me.__e(r,n.__v)}}),va&&va(e,t)},me.unmount=function(e){ba&&ba(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{tr(r)}catch(i){t=i}}),n.__H=void 0,t&&me.__e(t,n.__v))};var Pa=typeof requestAnimationFrame=="function";function Gd(e){var t,n=function(){clearTimeout(r),Pa&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Pa&&(t=requestAnimationFrame(n))}function tr(e){var t=ue,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),ue=t}function To(e){var t=ue;e.__c=e.__(),ue=t}function Eo(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Sa(e,t){return typeof t=="function"?t(e):t}var Kd=Symbol.for("preact-signals");function ar(){if(Xe>1)Xe--;else{var e,t=!1;for((function(){var i=or;for(or=void 0;i!==void 0;)i.S.v===i.v&&(i.S.i=i.i),i=i.o})();rn!==void 0;){var n=rn;for(rn=void 0,rr++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Ca(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(rr=0,Xe--,t)throw e}}function It(e){if(Xe>0)return e();Io=++qd,Xe++;try{return e()}finally{ar()}}var ie=void 0;function on(e){var t=ie;ie=void 0;try{return e()}finally{ie=t}}var wa,rn=void 0,Xe=0,rr=0,qd=0,Io=0,or=void 0,ir=0;function ka(e){if(ie!==void 0){var t=e.n;if(t===void 0||t.t!==ie)return t={i:0,S:e,p:ie.s,n:void 0,t:ie,e:void 0,x:void 0,r:t},ie.s!==void 0&&(ie.s.n=t),ie.s=t,e.n=t,32&ie.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=ie.s,t.n=void 0,ie.s.n=t,ie.s=t),t}}function he(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}he.prototype.brand=Kd;he.prototype.h=function(){return!0};he.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:on(function(){var r;(r=t.W)==null||r.call(t)}))};he.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&on(function(){var i;(i=t.Z)==null||i.call(t)}))}};he.prototype.subscribe=function(e){var t=this;return Ye(function(){var n=t.value;on(function(){return e(n)})},{name:"sub"})};he.prototype.valueOf=function(){return this.value};he.prototype.toString=function(){return this.value+""};he.prototype.toJSON=function(){return this.value};he.prototype.peek=function(){var e=this;return on(function(){return e.value})};Object.defineProperty(he.prototype,"value",{get:function(){var e=ka(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(rr>100)throw new Error("Cycle detected");(function(n){Xe!==0&&rr===0&&n.l!==Io&&(n.l=Io,or={S:n,v:n.v,i:n.i,o:or})})(this),this.v=e,this.i++,ir++,Xe++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{ar()}}}});function O(e,t){return new he(e,t)}function Ca(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Ta(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Ea(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function ct(e,t){he.call(this,void 0,t),this.x=e,this.s=void 0,this.g=ir-1,this.f=4}ct.prototype=new he;ct.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ir))return!0;if(this.g=ir,this.f|=1,this.i>0&&!Ca(this))return this.f&=-2,!0;var e=ie;try{Ta(this),ie=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return ie=e,Ea(this),this.f&=-2,!0};ct.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}he.prototype.S.call(this,e)};ct.prototype.U=function(e){if(this.t!==void 0&&(he.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};ct.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(ct.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=ka(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function an(e,t){return new ct(e,t)}function Ia(e){var t=e.m;if(e.m=void 0,typeof t=="function"){Xe++;var n=ie;ie=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,Ro(e),r}finally{ie=n,ar()}}}function Ro(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Ia(e)}function jd(e){if(ie!==this)throw new Error("Out-of-order effect");Ea(this),ie=e,this.f&=-2,8&this.f&&Ro(this),ar()}function Rt(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,wa&&wa.push(this)}Rt.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};Rt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Ia(this),Ta(this),Xe++;var e=ie;return ie=this,jd.bind(this,e)};Rt.prototype.N=function(){2&this.f||(this.f|=2,this.u=rn,rn=this)};Rt.prototype.d=function(){this.f|=8,1&this.f||Ro(this)};Rt.prototype.dispose=function(){this.d()};function Ye(e,t){var n=new Rt(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Ra,cr,sr,Xd=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__;var Aa=[];Ye(function(){Ra=this.N})();function At(e,t){X[e]=t.bind(null,X[e]||function(){})}function lr(e){if(sr){var t=sr;sr=void 0,t()}sr=e&&e.S()}function La(e){var t=this,n=e.data,r=dt(n);r.value=n;var i=we(function(){for(var s=t,c=t.__v;c=c.__;)if(c.__c){c.__c.__$f|=4;break}var d=an(function(){var f=r.value.value;return f===0?0:f===!0?"":f||""}),u=an(function(){return!Array.isArray(d.value)&&!ao(d.value)}),_=Ye(function(){if(this.N=Ma,u.value){var f=d.value;s.__v&&s.__v.__e&&s.__v.__e.nodeType===3&&(s.__v.__e.data=f)}}),m=t.__$u.d;return t.__$u.d=function(){_(),m.call(this)},[u,d]},[]),a=i[0],l=i[1];return a.value?l.peek():l.value}La.displayName="ReactiveTextNode";Object.defineProperties(he.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:La},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}});At("__b",function(e,t){if(typeof t.type=="string"){var n,r=t.props;for(var i in r)if(i!=="children"){var a=r[i];a instanceof he&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)});At("__r",function(e,t){if(e(t),t.type!==re){lr();var n,r=t.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=(function(i,a){var l;return Ye(function(){l=this},{name:a}),l.c=i,l})(function(){var i;Xd&&((i=n.y)==null||i.call(n)),r.__$f|=1,r.setState({})},typeof t.type=="function"?t.type.displayName||t.type.name:""))),cr=r,lr(n)}});At("__e",function(e,t,n,r){lr(),cr=void 0,e(t,n,r)});At("diffed",function(e,t){lr(),cr=void 0;var n;if(typeof t.type=="string"&&(n=t.__e)){var r=t.__np,i=t.props;if(r){var a=n.U;if(a)for(var l in a){var s=a[l];s!==void 0&&!(l in r)&&(s.d(),a[l]=void 0)}else a={},n.U=a;for(var c in r){var d=a[c],u=r[c];d===void 0?(d=Yd(n,c,u,i),a[c]=d):d.o(u,i)}}}e(t)});function Yd(e,t,n,r){var i=t in e&&e.ownerSVGElement===void 0,a=O(n);return{o:function(l,s){a.value=l,r=s},d:Ye(function(){this.N=Ma;var l=a.value.value;r[t]!==l&&(r[t]=l,i?e[t]=l:l!=null&&(l!==!1||t[4]==="-")?e.setAttribute(t,l):e.removeAttribute(t))})}}At("unmount",function(e,t){if(typeof t.type=="string"){var n=t.__e;if(n){var r=n.U;if(r){n.U=void 0;for(var i in r){var a=r[i];a&&a.d()}}}var l=t.__np;if(l){var s=t.props;for(var c in l)s[c]=l[c]}t.__np=void 0}else{var d=t.__c;if(d){var u=d.__$u;u&&(d.__$u=void 0,u.d())}}e(t)});At("__h",function(e,t,n,r){(r<3||r===9)&&(t.__$f|=2),e(t,n,r)});et.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in t)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var a=2&this.__$f;if(!(r||a||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var l in e)if(l!=="__source"&&e[l]!==this.props[l])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function dt(e,t){return we(function(){return O(e,t)},[])}function Y(e,t){var n=M(e);return n.current=e,cr.__$f|=4,we(function(){return an(function(){return n.current()},t)},[])}var Jd=function(e){queueMicrotask(function(){queueMicrotask(e)})};function Qd(){It(function(){for(var e;e=Aa.shift();)Ra.call(e)})}function Ma(){Aa.push(this)===1&&(X.requestAnimationFrame||Jd)(Qd)}function Na(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Da(e){return Na(e)}function Oa(e){return!(!Na(e)||e.navigation!==void 0&&!Array.isArray(e.navigation)||e.linkCards!==void 0&&!Array.isArray(e.linkCards))}function dr(e,t,n){return e==="page"?"page":e==="standalone"?"standalone":e==="inline"?t==="fullscreen"?"fullscreen":"inline":e==="modal"||e==="drawer"?n?t==="fullscreen"?"fullscreen":e:"closed":n?t==="fullscreen"?"fullscreen":t==="expanded"?"expanded":"open":"closed"}var Zd=900;function Ao(e,t,n){if(e==="standalone"||e==="page")return"fullscreen";let r=t.initialSize;if(r==="expanded"||r==="fullscreen"||r==="normal")return r;if(r==="auto"){let i=t.autoSizeBreakpoint??Zd;return n>=i?"expanded":"normal"}return"normal"}function sn(e,t,n,r=null){let a=e.mode==="inline"||e.mode==="standalone"||e.mode==="page"||(n??!e.startMinimized),s=e.mode!=="standalone"&&e.mode!=="page"&&e.mode!=="inline"&&r?r:Ao(e.mode,e.size,t);return{panelOpen:a,panelSize:s}}function Lt(){return typeof window>"u"?0:window.innerWidth}var e_="x-public-key",t_="x-ai-agent-deployment-id";function $a(e){return{headers(){let t={};return e.aiAgentDeploymentId&&(t[t_]=e.aiAgentDeploymentId),e.publicKey&&(t[e.publicKeyHeader??e_]=e.publicKey),t}}}var De=class extends Error{constructor(n,r,i,a){super(n);J(this,"code",r);J(this,"status",i);J(this,"cause",a);this.name="StreamError"}};var Ha=B.scope("parser");async function*Lo(e,t){if(!e.ok){let i=await e.text().catch(()=>"");throw new De(`server responded ${e.status}: ${i.slice(0,200)}`,"server",e.status)}if(!e.body)throw new De("response has no body","no-body");let n=e.body.pipeThrough(new TextDecoderStream).getReader(),r="";try{for(;;){if(t.aborted)throw new DOMException("aborted","AbortError");let{done:i,value:a}=await n.read();if(i){let s=r.trim();if(s){let c=Ba(s);c&&(yield c)}return}r+=a;let l;for(;(l=r.indexOf(`
7
+ `).replace(/__P__/g,Rd).replaceAll("__BRAND_ACCENT_TEXT__",Ld).replaceAll("__BRAND_ACCENT__",Ad).replaceAll("__BRAND_RADIUS__",Md).replaceAll("__BRAND_FONT__",Nd);var Dd=B.scope("mount"),sa=new WeakMap,la={floating:"all: initial; position: fixed; z-index: 2147483600;",flow:"all: initial; display: block; position: relative; width: 100%; height: 100%; z-index: 1; contain: size;",viewport:"all: initial; display: block; position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1;"};function ca(e,t){e.style.cssText=la[t]}function en(e){return e==="floating"||e==="modal"||e==="drawer"?"floating":e==="standalone"||e==="page"?"viewport":"flow"}function Jn(e={}){let t=e.position??"flow";Dd.debug("createShadowMount",{position:t,hasTarget:!!e.target,hasHost:!!e.existingHost});let n=`${x.cssPrefix}-chat-host`;typeof customElements<"u"&&!customElements.get(n)&&customElements.define(n,class extends HTMLElement{});let r;e.existingHost?r=e.existingHost:(r=document.createElement(n),(e.target??document.body).appendChild(r)),r.setAttribute("data-brand",x.id),r.style.cssText=la[t];let i=r.shadowRoot??r.attachShadow({mode:"open"}),a=r.ownerDocument;if(!Od(i,a)){let s=a.createElement("style");s.textContent=ko,i.appendChild(s)}let l=document.createElement("div");return l.className=`${x.cssPrefix}-app`,i.appendChild(l),{appRoot:l,destroy:()=>r.remove(),hostElement:r,shadowRoot:i}}function Od(e,t){if(!("adoptedStyleSheets"in e))return!1;let n=t.defaultView;if(!n||typeof n.CSSStyleSheet!="function")return!1;let r=sa.get(t);if(!r)try{r=new n.CSSStyleSheet,r.replaceSync(ko),sa.set(t,r)}catch{return!1}try{return e.adoptedStyleSheets=[r],!0}catch{return!1}}function $d(e,t){let n=x.cssPrefix;t.accent&&e.style.setProperty(`--${n}-accent-user`,t.accent),t.accentText&&e.style.setProperty(`--${n}-accent-text-user`,t.accentText),t.radius&&e.style.setProperty(`--${n}-radius`,t.radius),t.fontFamily&&e.style.setProperty(`--${n}-font`,t.fontFamily)}function Hd(e,t){e.dataset.theme=t}function Bd(e,t){let n=x.cssPrefix;t.width!==void 0&&e.style.setProperty(`--${n}-panel-w`,t.width),t.height!==void 0&&e.style.setProperty(`--${n}-panel-h`,t.height),t.expanded?.width!==void 0&&e.style.setProperty(`--${n}-expanded-w`,t.expanded.width),t.expanded?.height!==void 0&&e.style.setProperty(`--${n}-expanded-h`,t.expanded.height),t.inset!==void 0&&e.style.setProperty(`--${n}-panel-inset`,t.inset)}function Fd(e,t){e.dataset.position=t}function Qn(e,t){e.dataset.mode=t}function da(e,t){Hd(e,t.themeMode),$d(e,t.themeOverrides),Fd(e,t.position),Bd(e,t.size)}var zd=B.scope("iframe"),Ud='<!doctype html><html><head><meta charset="utf-8"><style>html,body{margin:0;padding:0;background:transparent;overflow:hidden}</style></head><body></body></html>';function pa(e,t,n="closed",r="floating",i=null){zd.debug("createIframeMount",{position:t,initialMode:n,layoutMode:r,hasTarget:!!i});let a=document.createElement("iframe");a.title=`${x.name} chat`,a.setAttribute("allow","microphone; clipboard-write"),ua(a,t,n,r),(r==="inline"&&i?i:document.body).appendChild(a);let s=a.contentDocument;if(!s)throw new Error("iframe contentDocument unavailable (cross-origin?)");s.open(),s.write(Ud),s.close();let c=Jn({...e,target:s.body}),d=new MutationObserver(()=>{ua(a,t,c.hostElement.dataset.mode??"closed",r)});return d.observe(c.hostElement,{attributes:!0,attributeFilter:["data-mode"]}),{...c,iframeElement:a,destroy(){d.disconnect(),c.destroy(),a.remove()}}}var Zn="border:0;background:transparent;z-index:2147483647;pointer-events:auto;",_a={closed:{w:"88px",h:"88px"},expanded:{w:"min(calc(100vw - 32px), 680px)",h:"min(calc(100vh - 32px), 860px)"},open:{w:"min(calc(100vw - 32px), 440px)",h:"min(calc(100vh - 32px), 700px)"}};function ua(e,t,n,r){if(n==="fullscreen"||r==="standalone"){e.style.cssText=`${Zn}position:fixed;inset:0;width:100vw;height:100vh;`;return}if(r==="inline"){e.style.cssText=`${Zn}position:static;display:block;width:100%;height:100%;`;return}if(typeof matchMedia=="function"&&matchMedia("(max-width: 640px)").matches&&(n==="open"||n==="expanded")){e.style.cssText=`${Zn}position:fixed;inset:0;width:100vw;height:100vh;`;return}let a=t.startsWith("top-")?"top":"bottom",l=t.endsWith("-left")?"left":"right",{w:s,h:c}=_a[n]??_a.open;e.style.cssText=`${Zn}position:fixed;${a}:16px;${l}:16px;width:${s};height:${c};`}var er=class{constructor(){J(this,"handlers",new Map)}on(t,n){let r=this.handlers.get(t);return r||(r=new Set,this.handlers.set(t,r)),r.add(n),()=>this.handlers.get(t)?.delete(n)}emit(t,n){let r=this.handlers.get(t);if(r)for(let i of r)try{i(n)}catch{}}clear(){this.handlers.clear()}};var Et,ue,Co,fa,tn=0,ya=[],me=X,ma=me.__b,ga=me.__r,ha=me.diffed,va=me.__c,ba=me.unmount,xa=me.__;function nr(e,t){me.__h&&me.__h(ue,e,tn||t),tn=0;var n=ue.__H||(ue.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function I(e){return tn=1,Wd(Sa,e)}function Wd(e,t,n){var r=nr(Et++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Sa(void 0,t),function(s){var c=r.__N?r.__N[0]:r.__[0],d=r.t(c,s);c!==d&&(r.__N=[d,r.__[1]],r.__c.setState({}))}],r.__c=ue,!ue.__f)){var i=function(s,c,d){if(!r.__c.__H)return!0;var u=r.__c.__H.__.filter(function(m){return m.__c});if(u.every(function(m){return!m.__N}))return!a||a.call(this,s,c,d);var _=r.__c.props!==s;return u.some(function(m){if(m.__N){var f=m.__[0];m.__=m.__N,m.__N=void 0,f!==m.__[0]&&(_=!0)}}),a&&a.call(this,s,c,d)||_};ue.__f=!0;var a=ue.shouldComponentUpdate,l=ue.componentWillUpdate;ue.componentWillUpdate=function(s,c,d){if(this.__e){var u=a;a=void 0,i(s,c,d),a=u}l&&l.call(this,s,c,d)},ue.shouldComponentUpdate=i}return r.__N||r.__}function T(e,t){var n=nr(Et++,3);!me.__s&&Eo(n.__H,t)&&(n.__=e,n.u=t,ue.__H.__h.push(n))}function nn(e,t){var n=nr(Et++,4);!me.__s&&Eo(n.__H,t)&&(n.__=e,n.u=t,ue.__h.push(n))}function M(e){return tn=5,ke(function(){return{current:e}},[])}function ke(e,t){var n=nr(Et++,7);return Eo(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function H(e,t){return tn=8,ke(function(){return e},t)}function Vd(){for(var e;e=ya.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(tr),t.__h.some(To),t.__h=[]}catch(n){t.__h=[],me.__e(n,e.__v)}}}me.__b=function(e){ue=null,ma&&ma(e)},me.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),xa&&xa(e,t)},me.__r=function(e){ga&&ga(e),Et=0;var t=(ue=e.__c).__H;t&&(Co===ue?(t.__h=[],ue.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(tr),t.__h.some(To),t.__h=[],Et=0)),Co=ue},me.diffed=function(e){ha&&ha(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ya.push(t)!==1&&fa===me.requestAnimationFrame||((fa=me.requestAnimationFrame)||Gd)(Vd)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Co=ue=null},me.__c=function(e,t){t.some(function(n){try{n.__h.some(tr),n.__h=n.__h.filter(function(r){return!r.__||To(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],me.__e(r,n.__v)}}),va&&va(e,t)},me.unmount=function(e){ba&&ba(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{tr(r)}catch(i){t=i}}),n.__H=void 0,t&&me.__e(t,n.__v))};var Pa=typeof requestAnimationFrame=="function";function Gd(e){var t,n=function(){clearTimeout(r),Pa&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Pa&&(t=requestAnimationFrame(n))}function tr(e){var t=ue,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),ue=t}function To(e){var t=ue;e.__c=e.__(),ue=t}function Eo(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Sa(e,t){return typeof t=="function"?t(e):t}var Kd=Symbol.for("preact-signals");function ar(){if(Xe>1)Xe--;else{var e,t=!1;for((function(){var i=or;for(or=void 0;i!==void 0;)i.S.v===i.v&&(i.S.i=i.i),i=i.o})();rn!==void 0;){var n=rn;for(rn=void 0,rr++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Ca(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(rr=0,Xe--,t)throw e}}function It(e){if(Xe>0)return e();Io=++qd,Xe++;try{return e()}finally{ar()}}var ie=void 0;function on(e){var t=ie;ie=void 0;try{return e()}finally{ie=t}}var wa,rn=void 0,Xe=0,rr=0,qd=0,Io=0,or=void 0,ir=0;function ka(e){if(ie!==void 0){var t=e.n;if(t===void 0||t.t!==ie)return t={i:0,S:e,p:ie.s,n:void 0,t:ie,e:void 0,x:void 0,r:t},ie.s!==void 0&&(ie.s.n=t),ie.s=t,e.n=t,32&ie.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=ie.s,t.n=void 0,ie.s.n=t,ie.s=t),t}}function he(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}he.prototype.brand=Kd;he.prototype.h=function(){return!0};he.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:on(function(){var r;(r=t.W)==null||r.call(t)}))};he.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&on(function(){var i;(i=t.Z)==null||i.call(t)}))}};he.prototype.subscribe=function(e){var t=this;return Ye(function(){var n=t.value;on(function(){return e(n)})},{name:"sub"})};he.prototype.valueOf=function(){return this.value};he.prototype.toString=function(){return this.value+""};he.prototype.toJSON=function(){return this.value};he.prototype.peek=function(){var e=this;return on(function(){return e.value})};Object.defineProperty(he.prototype,"value",{get:function(){var e=ka(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(rr>100)throw new Error("Cycle detected");(function(n){Xe!==0&&rr===0&&n.l!==Io&&(n.l=Io,or={S:n,v:n.v,i:n.i,o:or})})(this),this.v=e,this.i++,ir++,Xe++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{ar()}}}});function O(e,t){return new he(e,t)}function Ca(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Ta(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Ea(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function ct(e,t){he.call(this,void 0,t),this.x=e,this.s=void 0,this.g=ir-1,this.f=4}ct.prototype=new he;ct.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ir))return!0;if(this.g=ir,this.f|=1,this.i>0&&!Ca(this))return this.f&=-2,!0;var e=ie;try{Ta(this),ie=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return ie=e,Ea(this),this.f&=-2,!0};ct.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}he.prototype.S.call(this,e)};ct.prototype.U=function(e){if(this.t!==void 0&&(he.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};ct.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(ct.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=ka(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function an(e,t){return new ct(e,t)}function Ia(e){var t=e.m;if(e.m=void 0,typeof t=="function"){Xe++;var n=ie;ie=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,Ro(e),r}finally{ie=n,ar()}}}function Ro(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Ia(e)}function jd(e){if(ie!==this)throw new Error("Out-of-order effect");Ea(this),ie=e,this.f&=-2,8&this.f&&Ro(this),ar()}function Rt(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,wa&&wa.push(this)}Rt.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};Rt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Ia(this),Ta(this),Xe++;var e=ie;return ie=this,jd.bind(this,e)};Rt.prototype.N=function(){2&this.f||(this.f|=2,this.u=rn,rn=this)};Rt.prototype.d=function(){this.f|=8,1&this.f||Ro(this)};Rt.prototype.dispose=function(){this.d()};function Ye(e,t){var n=new Rt(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Ra,cr,sr,Xd=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__;var Aa=[];Ye(function(){Ra=this.N})();function At(e,t){X[e]=t.bind(null,X[e]||function(){})}function lr(e){if(sr){var t=sr;sr=void 0,t()}sr=e&&e.S()}function La(e){var t=this,n=e.data,r=dt(n);r.value=n;var i=ke(function(){for(var s=t,c=t.__v;c=c.__;)if(c.__c){c.__c.__$f|=4;break}var d=an(function(){var f=r.value.value;return f===0?0:f===!0?"":f||""}),u=an(function(){return!Array.isArray(d.value)&&!ao(d.value)}),_=Ye(function(){if(this.N=Ma,u.value){var f=d.value;s.__v&&s.__v.__e&&s.__v.__e.nodeType===3&&(s.__v.__e.data=f)}}),m=t.__$u.d;return t.__$u.d=function(){_(),m.call(this)},[u,d]},[]),a=i[0],l=i[1];return a.value?l.peek():l.value}La.displayName="ReactiveTextNode";Object.defineProperties(he.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:La},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}});At("__b",function(e,t){if(typeof t.type=="string"){var n,r=t.props;for(var i in r)if(i!=="children"){var a=r[i];a instanceof he&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)});At("__r",function(e,t){if(e(t),t.type!==re){lr();var n,r=t.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=(function(i,a){var l;return Ye(function(){l=this},{name:a}),l.c=i,l})(function(){var i;Xd&&((i=n.y)==null||i.call(n)),r.__$f|=1,r.setState({})},typeof t.type=="function"?t.type.displayName||t.type.name:""))),cr=r,lr(n)}});At("__e",function(e,t,n,r){lr(),cr=void 0,e(t,n,r)});At("diffed",function(e,t){lr(),cr=void 0;var n;if(typeof t.type=="string"&&(n=t.__e)){var r=t.__np,i=t.props;if(r){var a=n.U;if(a)for(var l in a){var s=a[l];s!==void 0&&!(l in r)&&(s.d(),a[l]=void 0)}else a={},n.U=a;for(var c in r){var d=a[c],u=r[c];d===void 0?(d=Yd(n,c,u,i),a[c]=d):d.o(u,i)}}}e(t)});function Yd(e,t,n,r){var i=t in e&&e.ownerSVGElement===void 0,a=O(n);return{o:function(l,s){a.value=l,r=s},d:Ye(function(){this.N=Ma;var l=a.value.value;r[t]!==l&&(r[t]=l,i?e[t]=l:l!=null&&(l!==!1||t[4]==="-")?e.setAttribute(t,l):e.removeAttribute(t))})}}At("unmount",function(e,t){if(typeof t.type=="string"){var n=t.__e;if(n){var r=n.U;if(r){n.U=void 0;for(var i in r){var a=r[i];a&&a.d()}}}var l=t.__np;if(l){var s=t.props;for(var c in l)s[c]=l[c]}t.__np=void 0}else{var d=t.__c;if(d){var u=d.__$u;u&&(d.__$u=void 0,u.d())}}e(t)});At("__h",function(e,t,n,r){(r<3||r===9)&&(t.__$f|=2),e(t,n,r)});et.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in t)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var a=2&this.__$f;if(!(r||a||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var l in e)if(l!=="__source"&&e[l]!==this.props[l])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function dt(e,t){return ke(function(){return O(e,t)},[])}function Y(e,t){var n=M(e);return n.current=e,cr.__$f|=4,ke(function(){return an(function(){return n.current()},t)},[])}var Jd=function(e){queueMicrotask(function(){queueMicrotask(e)})};function Qd(){It(function(){for(var e;e=Aa.shift();)Ra.call(e)})}function Ma(){Aa.push(this)===1&&(X.requestAnimationFrame||Jd)(Qd)}function Na(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Da(e){return Na(e)}function Oa(e){return!(!Na(e)||e.navigation!==void 0&&!Array.isArray(e.navigation)||e.linkCards!==void 0&&!Array.isArray(e.linkCards))}function dr(e,t,n){return e==="page"?"page":e==="standalone"?"standalone":e==="inline"?t==="fullscreen"?"fullscreen":"inline":e==="modal"||e==="drawer"?n?t==="fullscreen"?"fullscreen":e:"closed":n?t==="fullscreen"?"fullscreen":t==="expanded"?"expanded":"open":"closed"}var Zd=900;function Ao(e,t,n){if(e==="standalone"||e==="page")return"fullscreen";let r=t.initialSize;if(r==="expanded"||r==="fullscreen"||r==="normal")return r;if(r==="auto"){let i=t.autoSizeBreakpoint??Zd;return n>=i?"expanded":"normal"}return"normal"}function sn(e,t,n,r=null){let a=e.mode==="inline"||e.mode==="standalone"||e.mode==="page"||(n??!e.startMinimized),s=e.mode!=="standalone"&&e.mode!=="page"&&e.mode!=="inline"&&r?r:Ao(e.mode,e.size,t);return{panelOpen:a,panelSize:s}}function Lt(){return typeof window>"u"?0:window.innerWidth}var e_="x-public-key",t_="x-ai-agent-deployment-id";function $a(e){return{headers(){let t={};return e.aiAgentDeploymentId&&(t[t_]=e.aiAgentDeploymentId),e.publicKey&&(t[e.publicKeyHeader??e_]=e.publicKey),t}}}var De=class extends Error{constructor(n,r,i,a){super(n);J(this,"code",r);J(this,"status",i);J(this,"cause",a);this.name="StreamError"}};var Ha=B.scope("parser");async function*Lo(e,t){if(!e.ok){let i=await e.text().catch(()=>"");throw new De(`server responded ${e.status}: ${i.slice(0,200)}`,"server",e.status)}if(!e.body)throw new De("response has no body","no-body");let n=e.body.pipeThrough(new TextDecoderStream).getReader(),r="";try{for(;;){if(t.aborted)throw new DOMException("aborted","AbortError");let{done:i,value:a}=await n.read();if(i){let s=r.trim();if(s){let c=Ba(s);c&&(yield c)}return}r+=a;let l;for(;(l=r.indexOf(`
8
8
 
9
9
  `))!==-1;){let s=r.slice(0,l);r=r.slice(l+2);let c=Ba(s);c&&(yield c)}}}finally{n.releaseLock()}}function Ba(e){let t="",n;for(let r of e.split(`
10
10
  `))if(!(r===""||r.startsWith(":"))){if(r.startsWith("data:")){let i=r.slice(5).replace(/^ /,"");t=t?`${t}
11
- ${i}`:i;continue}r.startsWith("id:")&&(n=r.slice(3).trim())}if(!t||t==="[DONE]")return null;try{let r=JSON.parse(t);return Ha.trace("chunk",{type:r.type,eventId:n}),{chunk:r,eventId:n}}catch(r){return Ha.trace("frame parse failed",{err:r,payload:t.slice(0,200)}),null}}function n_(e){let t=new TextEncoder().encode(e),n="";for(let r of t)n+=String.fromCharCode(r);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var Fa=e=>e&&Object.keys(e).length>0?e:void 0;function za(e,t){let n=Fa(e),r=Fa(t);if(!n&&!r)return;let i={};return n&&(i.user=n),r&&(i.page=r),n_(JSON.stringify(i))}function _r(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function r_(e){return`tool-${e.startsWith("tool:")?e.slice(5):e}`}function Ua(e){return e.startsWith("tool-")?e.slice(5):e}var Oe={handshake:"/pai/handshake",streamMessage:"/pai/stream-message",streamResume:"/pai/stream-resume",cancelStream:"/pai/cancel-stream",listConversations:"/pai/list-conversations",listMessages:"/pai/list-messages",updateSettings:"/pai/update-settings",markRead:"/pai/mark-read",bootstrap:"/pai/bootstrap",content:"/pai/content",submitForm:"/pai/submit-form"},Wa="context";function Va(e){let n={messages:e.messages.map(i=>({id:i.serverMessageId??i.id,parts:a_(i),role:i.role,createdAt:i.createdAt!==void 0?new Date(i.createdAt).toISOString():void 0})),conversationId:e.conversationId,trigger:e.trigger??"submit-message"};e.messageId&&(n.messageId=e.messageId),e.visitorId&&(n.visitorId=e.visitorId),e.userPrefs&&(n.userPrefs=e.userPrefs);let r=e.tools?.map(i_).filter(i=>i!==null);return r?.length&&(n.data={tools:r}),n}function o_(e){return e.state==="output-available"||e.state==="output-error"||e.state==="output-denied"||e.approval?.approved!==void 0}function i_(e){return typeof e=="string"?e?{code:e}:null:e?.code?e:null}function a_(e){let t=[];for(let n of e.parts)if(n.kind==="step-start"&&t.push({type:"step-start"}),n.kind==="reasoning"&&n.text&&t.push({type:"reasoning",text:n.text,state:n.done?"done":"streaming"}),n.kind==="text"&&n.text&&t.push({text:n.text,type:"text"}),n.kind==="file"&&n.url&&t.push({mediaType:n.mediaType,type:"file",url:n.url}),n.kind==="tool"&&o_(n)){let r={type:r_(n.toolName),toolCallId:n.toolCallId,state:n.state};n.input!==void 0&&(r.input=n.input),n.output!==void 0&&(r.output=n.output),n.error!==void 0&&(r.errorText=n.error),n.approval&&n.approval.approved!==void 0&&(r.approval=n.approval),t.push(r)}for(let n of e.attachments??[])n.url&&t.push({type:"file",url:n.url,mediaType:n.mediaType,filename:n.name,fileId:n.id,fileSize:n.size});return t}var Q=B.scope("transport"),s_=3,ja=400,l_=6e4,Ga=1e4,Ka=3,c_=new Set([408,425,429,500,502,503,504]);function qa(e){return ja*2**e+Math.floor(Math.random()*250)}function d_(e){let t=e.get("retry-after");if(!t)return null;let n=Number(t),r=Number.isFinite(n)?n*1e3:Date.parse(t)-Date.now();return Number.isFinite(r)&&r>=0?Math.min(r,3e4):null}function Mo(e,t){return new Promise(n=>{if(t?.aborted)return n();let r=setTimeout(a,e),i=()=>a();t?.addEventListener("abort",i,{once:!0});function a(){clearTimeout(r),t?.removeEventListener("abort",i),n()}})}var ur=class{constructor(t){J(this,"opts",t);J(this,"visitorId");J(this,"conversationId");J(this,"userContext");J(this,"pageContext");J(this,"locale");J(this,"conversationsCache",new Map);J(this,"contentCache",new Map)}setContext(t,n){this.userContext=t,this.pageContext=n}setLocale(t){this.locale=t}primeIdentity(t,n){t&&(this.visitorId=t),n&&(this.conversationId=n)}envelope(){let t={_ev:St};this.visitorId&&(t.visitorId=this.visitorId),this.conversationId&&(t.conversationId=this.conversationId),this.locale&&(t.locale=this.locale);let n=za(this.userContext,this.pageContext);return n&&(t[Wa]=n),t}withEnvelope(t){return{...this.envelope(),...t}}appendEnvelope(t){for(let[n,r]of Object.entries(this.envelope()))t.append(n,r);return t}withEnvelopeQuery(t){let n=new URL(this.url(t));for(let[r,i]of Object.entries(this.envelope()))n.searchParams.has(r)||n.searchParams.set(r,i);return n.toString()}async handshake(t){Q.debug("handshake \u2192",{visitorId:t.visitorId,conversationId:t.conversationId,locale:t.locale});let n=await this.postJson(Oe.handshake,t,"handshake");return Q.debug("handshake \u2190",{visitorId:n.visitorId,conversationId:n.conversationId,hasWelcome:!!n.welcome,hasConfig:!!n.config,rebind:n.rebind}),u_(n)||Q.warn("handshake response did not match expected shape; using raw response",{response:n}),this.visitorId=n.visitorId??t.visitorId,this.conversationId=n.conversationId,n}async uploadFile(t){Q.debug("uploadFile \u2192",{name:t.name,size:t.size,type:t.type});let n=new FormData;n.append("file",t,t.name);let r=await this.postForm(this.uploadPath,n,"upload");return Q.debug("uploadFile \u2190",{id:r.id,url:r.url}),r}async transcribe(t,n="audio/webm"){Q.debug("transcribe \u2192",{size:t.size,mimeType:n});let r=new FormData;r.append("audio",t,`voice.${__(n)}`),r.append("mimeType",n);let i=await this.postForm(this.transcribePath,r,"transcribe");return Q.debug("transcribe \u2190",{textLen:i.text.length}),i}conversationsKey(t){return`${this.locale??""}|${JSON.stringify(t,Object.keys(t).toSorted())}`}peekConversations(t={}){let n=this.conversationsCache.get(this.conversationsKey(t));if(n?.value&&Date.now()-n.at<Ga)return n.value}listConversations(t={}){let n=this.conversationsKey(t),r=this.conversationsCache.get(n);if(r&&Date.now()-r.at<Ga)return Q.debug("listConversations \u2192 cache",t),r.result;let i={at:Date.now(),result:this.fetchConversations(t).then(a=>(i.value=a,a)).catch(a=>{throw this.conversationsCache.delete(n),a})};return this.conversationsCache.set(n,i),i.result}async fetchConversations(t){let n=new URL(this.url(Oe.listConversations));t.visitorId&&n.searchParams.set("visitorId",t.visitorId),t.limit&&n.searchParams.set("limit",String(t.limit)),t.cursor&&n.searchParams.set("cursor",t.cursor),Q.debug("listConversations \u2192",{visitorId:t.visitorId??this.visitorId,limit:t.limit,cursor:t.cursor});let r=await this.getJson(n.toString(),"listConversations"),i=r.conversations??[];return Q.debug("listConversations \u2190",{count:i.length,nextCursor:r.nextCursor}),{conversations:i.map(a=>({conversationId:a.conversationId,title:a.title,lastMessageAt:a.lastMessageAt,preview:a.preview,canContinue:a.canContinue,unreadCount:a.unreadCount})),nextCursor:r.nextCursor}}async loadConversation(t){let n=new URL(this.url(Oe.listMessages));n.searchParams.set("conversationId",t),Q.debug("loadConversation \u2192",{conversationId:t,visitorId:this.visitorId});let r=await this.getJson(n.toString(),"loadConversation"),i=r.messages??[];return Q.debug("loadConversation \u2190",{conversationId:r.conversationId,canContinue:r.canContinue,messageCount:i.length,hasSuggestions:!!r.suggestions}),{conversationId:r.conversationId,canContinue:r.canContinue??!0,messages:i,agent:r.agent,suggestions:r.suggestions}}async markRead(t){if(!(!this.visitorId||!t)){this.conversationsCache.clear(),Q.debug("markRead \u2192",{conversationId:t,visitorId:this.visitorId});try{await this.postJson(Oe.markRead,{conversationId:t},"markRead")}catch(n){Q.debug("markRead failed (non-fatal)",{err:n})}}}listContent(t={}){let n=`${this.locale??""}|${JSON.stringify(t,Object.keys(t).toSorted())}`,r=this.contentCache.get(n);if(r&&Date.now()-r.at<l_)return Q.debug("listContent \u2192 cache",t),r.result;let i=this.fetchContent(t).catch(a=>{throw this.contentCache.delete(n),a});return this.contentCache.set(n,{at:Date.now(),result:i}),i}async fetchContent(t){let n=new URL(this.dataUrl(Oe.content));for(let[a,l]of Object.entries(t))l!==void 0&&n.searchParams.set(a,Array.isArray(l)?l.join(","):String(l));Q.debug("listContent \u2192",t);let r=await this.getJson(n.toString(),"listContent"),i=(r.items??[]).map(a=>Fi(a,this.locale));return Q.debug("listContent \u2190",{count:i.length,total:r.pagination?.total}),{...r,items:i}}async bootstrap(t){let n=new URL(this.dataUrl(Oe.bootstrap));t&&n.searchParams.set("conversationId",t),Q.debug("bootstrap \u2192",{conversationId:t??this.conversationId});let r=await this.getJson(n.toString(),"bootstrap"),i=r.forms??[],a=r.formSubmissions??[];return Q.debug("bootstrap \u2190",{forms:i.length,formSubmissions:a.length}),{forms:i,formSubmissions:a}}async saveUserPrefs(t){Q.debug("saveUserPrefs \u2192",{visitorId:this.visitorId,conversationId:this.conversationId,settingsKeys:Object.keys(t)});let n=await this.postJson(Oe.updateSettings,{userPrefs:t},"saveUserPrefs");return Q.debug("saveUserPrefs \u2190",{ok:n.ok}),n}get uploadPath(){return this.opts.endpoints?.upload??"/pai/upload-file"}get transcribePath(){return this.opts.endpoints?.transcribe??"/pai/transcribe-audio"}get submitFormPath(){return this.opts.endpoints?.submitForm??Oe.submitForm}async submitForm(t){Q.debug("submitForm \u2192",{formId:t.formId,trigger:t.trigger,fields:Object.keys(t.values).length});try{await this.postJson(this.dataUrl(this.submitFormPath),t,"submitForm")}catch(n){Q.debug("submitForm failed (non-fatal)",{err:n})}}sendMessage(t){this.conversationsCache.clear(),Q.debug("message \u2192",{conversationId:t.conversationId,visitorId:t.visitorId,messageId:t.messageId,messageCount:t.messages.length,trigger:t.trigger,tools:t.data?.tools?.map(l=>l.code)});let n=new AbortController,r=new Set;return{iter:this.runStream(t,n,r),cancel:()=>this.cancelStream(n,t.conversationId)}}resumeStream(){let t=new AbortController,n=new Set;return{iter:this.resumeStreamGen(t,n,!0),cancel:()=>t.abort()}}async*runStream(t,n,r){(yield*this.drain(this.openMessageStream(t,n.signal),r,n))||(yield*this.resumeStreamGen(n,r,!1))}async*resumeStreamGen(t,n,r){for(let i=1;i<=s_&&!t.signal.aborted;i++){if((!r||i>1)&&(await Mo(ja*i,t.signal),t.signal.aborted))return;let a;try{a=await this.fetchImpl(this.resumeUrl(n.size),{method:"GET",credentials:"omit",headers:{accept:"text/event-stream",...this.opts.auth.headers()},signal:t.signal})}catch(s){if(t.signal.aborted)return;Q.debug("resume fetch failed \u2014 retrying",{attempt:i,err:s});continue}if(a.status===204||!a.ok){Q.debug("resume \u2192 no in-flight stream",{status:a.status});return}let l=n.size;if(yield*this.drain(Lo(a,t.signal),n,t))return;if(n.size===l){Q.debug("resume \u2192 stream closed with no new events; nothing to resume");return}}if(!t.signal.aborted)throw new De("stream incomplete after resume attempts","server")}async*drain(t,n,r){try{for await(let i of t){if(r.signal.aborted)return!0;if(i.eventId){if(n.has(i.eventId))continue;n.add(i.eventId)}if(yield i,i.chunk.type==="finish"||i.chunk.type==="error")return!0}}catch(i){if(r.signal.aborted)return!0;if(i instanceof De&&i.status!==void 0)throw i;Q.debug("stream segment dropped",{err:i})}return!1}cancelStream(t,n){t.signal.aborted||(Q.debug("cancel stream",{conversationId:n,visitorId:this.visitorId}),t.abort(),!(!this.visitorId||!n)&&this.fetchImpl(this.url(Oe.cancelStream),{method:"POST",credentials:"omit",headers:{"content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope({})),keepalive:!0}).catch(r=>Q.debug("cancel POST failed (non-fatal)",{err:r})))}async*openMessageStream(t,n){let r=await this.fetchImpl(this.url(Oe.streamMessage),{method:"POST",credentials:"omit",headers:{accept:"text/event-stream","content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope(t)),signal:n});yield*Lo(r,n)}resumeUrl(t){let n=new URL(this.withEnvelopeQuery(Oe.streamResume));return n.searchParams.set("resumeAt",String(t)),n.toString()}async postJson(t,n,r){let i=await this.fetchWithRetry(()=>[this.url(t),{method:"POST",credentials:"omit",headers:{"content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope(n))}],r);return this.assertOk(i,r)}async postForm(t,n,r){let i=await this.fetchImpl(this.url(t),{method:"POST",credentials:"omit",headers:this.opts.auth.headers(),body:this.appendEnvelope(n)});return this.assertOk(i,r)}async getJson(t,n){let r=await this.fetchWithRetry(()=>[this.withEnvelopeQuery(t),{method:"GET",credentials:"omit",headers:{accept:"application/json",...this.opts.auth.headers()}}],n);return this.assertOk(r,n)}async fetchWithRetry(t,n){for(let r=0;;r++){let[i,a]=t(),l;try{l=await this.fetchImpl(i,a)}catch(c){if(r>=Ka)throw new De(`${n} failed: network error`,"network",void 0,c);Q.debug("request network error \u2014 retrying",{label:n,attempt:r}),await Mo(qa(r));continue}if(l.ok||!c_.has(l.status)||r>=Ka)return l;let s=d_(l.headers)??qa(r);Q.debug("request retryable status \u2014 retrying",{label:n,status:l.status,attempt:r,wait:s}),await Mo(s)}}async assertOk(t,n){if(!t.ok)throw new De(`${n} failed: ${t.status}`,"server",t.status);return await t.json()}url(t){return/^https?:\/\//i.test(t)?t:`${this.opts.agentApiBaseUrl}${t}`}dataUrl(t){return/^https?:\/\//i.test(t)?t:`${this.opts.dataApiBaseUrl}${t}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function __(e){return e.includes("webm")?"webm":e.includes("ogg")?"ogg":e.includes("mp4")||e.includes("m4a")?"m4a":e.includes("mpeg")?"mp3":e.includes("wav")?"wav":"bin"}function u_(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.visitorId=="string"&&typeof t.conversationId=="string"}function Xa(e,t){let n=e?[{kind:"text",id:"t0",textSig:O(e),doneSig:O(!0)}]:[];return{id:Ne(),role:"user",createdAt:Date.now(),status:"complete",attachments:t,partsSig:O(n)}}function Do(){return{id:Ne(),role:"assistant",createdAt:Date.now(),status:"streaming",partsSig:O([])}}function Ya(e){let t=Ne();return p_({id:t,role:e.role,createdAt:Date.now(),status:"complete",parts:[{kind:"text",id:`${t}-t0`,text:e.text,done:!0}]})}function p_(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,errorText:e.errorText,finishReason:e.finishReason,serverMessageId:e.serverMessageId,attachments:e.attachments,partsSig:O(e.parts.map(f_))}}function Oo(e){let t=e.parts.map((n,r)=>n.type==="text"?{kind:"text",id:`${e.id}-t${r}`,textSig:O(n.text),doneSig:O(!0)}:n.type==="reasoning"?{kind:"reasoning",id:`${e.id}-r${r}`,textSig:O(n.text),doneSig:O(n.state!=="streaming")}:n.type==="step-start"?{kind:"step-start",id:`${e.id}-ss${r}`}:n.type==="file"?{kind:"file",url:n.url,mediaType:n.mediaType}:n.type==="source-url"?{kind:"source",sourceId:n.sourceId,url:n.url,title:n.title}:n.type==="source-document"?{kind:"source",sourceId:n.sourceId,title:n.title,filename:n.filename,mediaType:n.mediaType}:n.type.startsWith("tool-")?{kind:"tool",toolCallId:n.toolCallId,toolName:Ua(n.type),inputPartialSig:O(""),inputSig:O(n.input),outputSig:O(n.output),errorSig:O(n.errorText),stateSig:O(n.state),approvalSig:O(n.approval)}:null).filter(n=>n!==null);return{id:e.id,role:e.role,serverMessageId:e.id,createdAt:_r(e.createdAt)??Date.now(),status:"complete",partsSig:O(t)}}function Ja(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,errorText:e.errorText,finishReason:e.finishReason,serverMessageId:e.serverMessageId,attachments:e.attachments,parts:e.partsSig.value.map(m_)}}function $o(e){let t="";for(let n of e.partsSig.value)n.kind==="text"&&(t+=n.textSig.value);return t}function f_(e){return e.kind==="text"||e.kind==="reasoning"?{kind:e.kind,id:e.id,textSig:O(e.text),doneSig:O(e.done)}:e.kind==="tool"?{kind:"tool",toolCallId:e.toolCallId,toolName:e.toolName,inputPartialSig:O(e.inputPartial),inputSig:O(e.input),outputSig:O(e.output),errorSig:O(e.error),stateSig:O(e.state),approvalSig:O(e.approval)}:e}function m_(e){return e.kind==="text"||e.kind==="reasoning"?{kind:e.kind,id:e.id,text:e.textSig.value,done:e.doneSig.value}:e.kind==="tool"?{kind:"tool",toolCallId:e.toolCallId,toolName:e.toolName,inputPartial:e.inputPartialSig.value,input:e.inputSig.value,output:e.outputSig.value,error:e.errorSig.value,state:e.stateSig.value,approval:e.approvalSig.value}:e}var Qa=B.scope("reducer"),pr=class{constructor(t){J(this,"messagesSig",t);J(this,"active",null)}attach(t){this.active=t}detach(){this.active=null}apply(t){let n=this.active;if(n)switch(t.type){case"start":t.messageId&&(n.serverMessageId=t.messageId);return;case"finish-step":return;case"start-step":ln(n,{kind:"step-start",id:`ss${n.partsSig.value.length}`});return;case"finish":Qa.debug("finish",{reason:t.finishReason,canContinue:t.canContinue}),n.status="complete",t.finishReason&&(n.finishReason=t.finishReason),this.bumpDone(n);return;case"error":Qa.warn("stream error chunk",{errorText:t.errorText}),n.status="error",n.errorText=t.errorText,this.bumpDone(n);return;case"text-start":Mt(n,"text",t.id);return;case"text-delta":{let r=Mt(n,"text",t.id);r.textSig.value+=t.delta;return}case"text-end":Mt(n,"text",t.id).doneSig.value=!0;return;case"reasoning-start":Mt(n,"reasoning",t.id).doneSig.value=!1;return;case"reasoning-delta":{let r=Mt(n,"reasoning",t.id);r.textSig.value+=t.delta;return}case"reasoning-end":Mt(n,"reasoning",t.id).doneSig.value=!0;return;case"tool-input-start":case"tool-input-delta":case"tool-input-available":case"tool-output-available":case"tool-output-error":case"tool-output-denied":case"tool-approval-request":g_(n,t);return;case"file":ln(n,{kind:"file",url:t.url,mediaType:t.mediaType});return;case"source-url":Za(n,{kind:"source",sourceId:t.sourceId,url:t.url,title:t.title});return;case"source-document":Za(n,{kind:"source",sourceId:t.sourceId,title:t.title,filename:t.filename,mediaType:t.mediaType});return;case"data-notification":return;default:{let r=t}}}bumpDone(t){t.partsSig.value=[...t.partsSig.value],this.messagesSig.value=[...this.messagesSig.value]}};function Mt(e,t,n){let r=e.partsSig.value.find(a=>a.kind===t&&a.id===n);if(r)return r;let i={kind:t,id:n,textSig:O(""),doneSig:O(!1)};return ln(e,i),i}function _t(e,t,n){let r=e.partsSig.value.find(a=>a.kind==="tool"&&a.toolCallId===t);if(r)return r;let i={kind:"tool",toolCallId:t,toolName:n??"tool",inputPartialSig:O(""),inputSig:O(void 0),outputSig:O(void 0),errorSig:O(void 0),stateSig:O("input-streaming"),approvalSig:O(void 0)};return ln(e,i),i}function ln(e,t){e.partsSig.value=[...e.partsSig.value,t]}function Za(e,t){e.partsSig.value.some(n=>n.kind==="source"&&n.sourceId===t.sourceId)||ln(e,t)}function g_(e,t){switch(t.type){case"tool-input-start":_t(e,t.toolCallId,t.toolName);return;case"tool-input-delta":{let n=_t(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case"tool-input-available":{let n=_t(e,t.toolCallId,t.toolName);n.inputSig.value=t.input,n.stateSig.value="input-available";return}case"tool-approval-request":{let n=_t(e,t.toolCallId,t.toolName);n.approvalSig.value={id:t.approvalId},n.stateSig.value="approval-requested";return}case"tool-output-available":{let n=_t(e,t.toolCallId);n.outputSig.value=t.output,n.stateSig.value="output-available";return}case"tool-output-error":{let n=_t(e,t.toolCallId);n.errorSig.value=t.errorText,n.stateSig.value="output-error";return}case"tool-output-denied":{let n=_t(e,t.toolCallId);n.stateSig.value="output-denied";return}default:return}}var es=B.scope("feedback:audio"),fr=class{constructor(){J(this,"ctx",null);J(this,"master",null);J(this,"buffers",new Map)}unlock(){if(this.ctx){this.ctx.state==="suspended"&&this.ctx.resume();return}let t=globalThis.AudioContext??globalThis.webkitAudioContext;if(t)try{this.ctx=new t,this.master=this.ctx.createGain(),this.master.gain.value=1,this.master.connect(this.ctx.destination)}catch(n){es.warn("AudioContext init failed",{err:n})}}setVolume(t){if(!this.master||!this.ctx)return;let n=Math.max(0,Math.min(1,t));this.master.gain.setTargetAtTime(n,this.ctx.currentTime,.01)}playTone(t){let n=this.ctx,r=this.master;if(!n||!r||n.state!=="running")return;let i=n.currentTime,a=t.noteMs/1e3;t.notes.forEach((l,s)=>{let c=n.createOscillator();c.type=t.type,c.frequency.value=l;let d=n.createGain(),u=i+s*a;d.gain.setValueAtTime(1e-4,u),d.gain.exponentialRampToValueAtTime(t.peakGain,u+.005),d.gain.exponentialRampToValueAtTime(1e-4,u+a),c.connect(d).connect(r),c.start(u),c.stop(u+a+.01)})}async playUrl(t){let n=this.ctx,r=this.master;if(!n||!r||n.state!=="running")return;let i=await this.getBuffer(t);if(!i)return;let a=n.createBufferSource();a.buffer=i,a.connect(r),a.start()}destroy(){this.ctx&&this.ctx.close().catch(()=>{}),this.ctx=null,this.master=null,this.buffers.clear()}async getBuffer(t){if(!this.ctx)return null;let n=this.buffers.get(t);if(n)return n instanceof Promise,n;let r=this.ctx,i=fetch(t).then(a=>a.ok?a.arrayBuffer():Promise.reject(new Error(`fetch ${a.status}`))).then(a=>r.decodeAudioData(a)).then(a=>(this.buffers.set(t,a),a)).catch(a=>(es.warn("audio fetch/decode failed",{url:t,err:a}),this.buffers.delete(t),null));return this.buffers.set(t,i),i}};var ts={messageReceived:10,messageSent:0,error:[20,40,20],voiceStart:10,voiceStop:0},ns={messageReceived:{notes:[880,1318.51],noteMs:90,type:"sine",peakGain:.45},messageSent:{notes:[1568],noteMs:60,type:"sine",peakGain:.25},error:{notes:[523.25,392],noteMs:120,type:"triangle",peakGain:.55},voiceStart:{notes:[1318.51],noteMs:50,type:"sine",peakGain:.3},voiceStop:{notes:[880],noteMs:50,type:"sine",peakGain:.3}};var tt=null,mr=0;function h_(){return typeof navigator<"u"&&typeof navigator.vibrate=="function"}function v_(){if(typeof document>"u")return null;let e=document.createElement("input");e.type="checkbox",e.setAttribute("switch",""),e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e.id=`__${x.cssPrefix}_haptic_${Math.random().toString(36).slice(2)}`;let t=document.createElement("label");t.htmlFor=e.id,t.setAttribute("aria-hidden","true");let n="position:absolute!important;width:1px!important;height:1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;opacity:0!important;pointer-events:none!important;";return e.style.cssText=n,t.style.cssText=n,document.body.append(e,t),{input:e,label:t}}function rs(e){if(!(e===0||Array.isArray(e)&&e.every(t=>t===0))){if(h_())try{navigator.vibrate(e);return}catch{}if(tt||(tt=v_()),!!tt)try{tt.label.click()}catch{}}}function os(){mr++;let e=!1;return()=>{e||(e=!0,mr=Math.max(0,mr-1),mr===0&&tt&&(tt.input.remove(),tt.label.remove(),tt=null))}}var b_=B.scope("feedback"),x_=100,gr=class{constructor(t,n){J(this,"mutedSig",O(!1));J(this,"audio",new fr);J(this,"releaseHaptics");J(this,"sound");J(this,"haptics");J(this,"lastPlayed",new Map);J(this,"reducedMotionMq",null);this.sound=t,this.haptics=n,this.releaseHaptics=os(),this.audio.setVolume(this.effectiveVolume()),typeof matchMedia<"u"&&(this.reducedMotionMq=matchMedia("(prefers-reduced-motion: reduce)"))}unlock(){this.audio.unlock(),this.audio.setVolume(this.effectiveVolume())}update(t,n){this.sound=t,this.haptics=n,this.audio.setVolume(this.effectiveVolume())}setMuted(t){this.mutedSig.value!==t&&(this.mutedSig.value=t)}toggleMuted(){this.mutedSig.value=!this.mutedSig.value}play(t){this.mutedSig.value||this.isDeduped(t)||(this.lastPlayed.set(t,performance.now()),this.sound.enabled&&this.playSound(t),this.haptics.enabled&&this.isTouchDevice()&&this.playHaptic(t))}destroy(){this.audio.destroy(),this.releaseHaptics()}isDeduped(t){let n=this.lastPlayed.get(t);return n===void 0?!1:performance.now()-n<x_}playSound(t){let n=this.sound.events?.[t];if(n===!1)return;if(typeof n=="string"){this.audio.playUrl(n).catch(i=>b_.warn("audio play failed",{err:i,url:n}));return}let r=ns[t];r&&this.audio.playTone(r)}playHaptic(t){if(this.reducedMotionMq?.matches)return;let n=this.haptics.events?.[t];if(n===!1)return;let r=n===!0||n===void 0?ts[t]:n;rs(r)}effectiveVolume(){let t=this.sound.volume??.3;return this.reducedMotionMq?.matches?t*.5:t}isTouchDevice(){return typeof window>"u"?!1:matchMedia("(hover: none) and (pointer: coarse)").matches}};function ut(e,t){return e instanceof De&&e.status===429?t.errorRateLimited:t.errorGeneric}var P_=0;function o(e,t,n,r,i,a){t||(t={});var l,s,c=t;if("ref"in c)for(s in c={},t)s=="ref"?l=t[s]:c[s]=t[s];var d={type:e,props:c,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--P_,__i:-1,__u:0,__source:i,__self:a};if(typeof e=="function"&&(l=e.defaultProps))for(s in l)c[s]===void 0&&(c[s]=l[s]);return X.vnode&&X.vnode(d),d}var $={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24"},cn=`${x.cssPrefix}-icon-dir`,y_=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M21 12a8 8 0 0 1-12 6.93L3 21l1.65-5.16A8 8 0 1 1 21 12Z"})}),ze=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M18 6 6 18M6 6l12 12"})}),is=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M12 5v14M5 12h14"})}),as=()=>o("svg",{...$,class:cn,"aria-hidden":"true",children:[o("path",{d:"m22 2-7 20-4-9-9-4Z"}),o("path",{d:"M22 2 11 13"})]}),ss=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M12 19V5M5 12l7-7 7 7"})}),ls=()=>o("svg",{...$,class:cn,"aria-hidden":"true",children:o("path",{d:"M3 20V4l18 8-18 8Z"})}),Nt=()=>o("svg",{...$,class:cn,"aria-hidden":"true",children:o("path",{d:"m9 18 6-6-6-6"})}),cs=()=>o("svg",{...$,"aria-hidden":"true",children:o("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}),ds=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"m21 11-9 9a5.5 5.5 0 0 1-7.78-7.78l8.49-8.49a3.67 3.67 0 0 1 5.19 5.19l-8.49 8.49a1.83 1.83 0 0 1-2.6-2.6l7.78-7.78"})}),_s=()=>o("svg",{...$,"aria-hidden":"true",children:[o("rect",{x:"9",y:"2",width:"6",height:"12",rx:"3"}),o("path",{d:"M5 10a7 7 0 0 0 14 0M12 19v3"})]}),us=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5"})}),ps=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5"})}),fs=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z"})}),ms=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7"})}),gs=()=>o("svg",{...$,"aria-hidden":"true",viewBox:"0 0 10 10",children:o("path",{d:"M9 1L1 9M9 5L5 9M9 9H9",strokeWidth:"1.5"})}),hs=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),o("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),o("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]}),vs=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M11 5 6 9H2v6h4l5 4zM15 9a5 5 0 0 1 0 6M18 7a9 9 0 0 1 0 10"})}),bs=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6"})}),xs=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M3 18 8 6l5 12M4.7 14h6.6"}),o("path",{d:"M14.5 18l3.2-7 3.2 7M15.6 15.8h4.2"})]}),Ps=()=>o("svg",{...$,class:cn,"aria-hidden":"true",children:o("path",{d:"m5 6 6 6-6 6M13 6l6 6-6 6"})}),dn=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M20 6 9 17l-5-5"})}),ys=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M3 3v6h6"}),o("path",{d:"M3.05 13A9 9 0 1 0 6 5.3L3 9"}),o("path",{d:"M12 7v5l3 2"})]}),Ss=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"12",cy:"12",r:"10"}),o("path",{d:"M2 12h20"}),o("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),_n=()=>o("svg",{...$,class:cn,"aria-hidden":"true",children:o("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),ws=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M12 20h9"}),o("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),ks=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"m6 9 6 6 6-6"})}),Cs=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"}),o("path",{d:"M14 2v6h6"})]}),S_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"m12 3-1.5 4.5L6 9l4.5 1.5L12 15l1.5-4.5L18 9l-4.5-1.5Z"}),o("path",{d:"M19 15v4M17 17h4M5 3v2M4 4h2"})]}),Ho=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2Z"})}),Bo=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"12",cy:"12",r:"10"}),o("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),o("path",{d:"M12 17h.01"})]}),w_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"m15 4 3 3-9 9-3-3z"}),o("path",{d:"M18 2v2M20 4h2M3 20l3-3M3 16h2M5 14v2"})]}),k_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("rect",{x:"4",y:"8",width:"16",height:"12",rx:"2"}),o("path",{d:"M12 8V4"}),o("circle",{cx:"12",cy:"3",r:"1"}),o("path",{d:"M2 14h2M20 14h2M9 13h.01M15 13h.01M9.5 17h5"})]}),C_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M4 14v-2a8 8 0 0 1 16 0v2"}),o("rect",{x:"2",y:"14",width:"4",height:"6",rx:"1.5"}),o("rect",{x:"18",y:"14",width:"4",height:"6",rx:"1.5"}),o("path",{d:"M20 20v1a3 3 0 0 1-3 3h-5"})]}),T_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"12",cy:"12",r:"10"}),o("circle",{cx:"12",cy:"12",r:"4"}),o("path",{d:"m4.93 4.93 4.24 4.24M14.83 14.83l4.24 4.24M14.83 9.17l4.24-4.24M4.93 19.07l4.24-4.24"})]}),Fo=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"11",cy:"11",r:"7"}),o("path",{d:"m21 21-4.3-4.3"})]}),Ts=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"12",cy:"12",r:"9"}),o("path",{d:"m8.5 12 2.5 2.5 4.5-5"})]}),Es=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M3 9.5 12 3l9 6.5"}),o("path",{d:"M5 9v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9"})]}),Is=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"m3 11 15-5v12L3 13z"}),o("path",{d:"M3 11v2a2 2 0 0 0 2 2h1V9H5a2 2 0 0 0-2 2z"}),o("path",{d:"M7 15v3a2 2 0 0 0 4 0v-2"}),o("path",{d:"M21 10a3 3 0 0 1 0 4"})]}),un=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z"}),o("path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1"})]}),Rs=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"12",cy:"12",r:"4"}),o("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}),As=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),Ls=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"12",cy:"12",r:"9"}),o("path",{d:"M12 3v18"}),o("path",{d:"M12 3a9 9 0 0 1 0 18z",fill:"currentColor",stroke:"none"})]}),E_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"10.5",cy:"10.5",r:"6.5"}),o("path",{d:"M8 11a2.5 2.5 0 0 0 5 0"}),o("path",{d:"m20 20-4.4-4.4"})]}),I_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M12 3.5 13.6 9 19 10.5 13.6 12 12 17.5 10.4 12 5 10.5 10.4 9z"}),o("path",{d:"M18.5 4v3M20 5.5h-3M5.5 16v2.5M6.75 17.25h-2.5"})]}),R_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M4 18h16"}),o("path",{d:"M5 18a7 7 0 0 1 14 0"}),o("path",{d:"M12 8V6"}),o("path",{d:"M10 6h4"})]}),A_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M7 11V6.5a1.5 1.5 0 0 1 3 0V10"}),o("path",{d:"M10 10V5.5a1.5 1.5 0 0 1 3 0V10"}),o("path",{d:"M13 10V6.5a1.5 1.5 0 0 1 3 0V12"}),o("path",{d:"M16 9.5a1.5 1.5 0 0 1 3 0v2.5a7 7 0 0 1-7 7 7 7 0 0 1-6.4-4.2L4 12.5a1.5 1.5 0 0 1 2.6-1.5L7 11"})]}),Ms={chat:y_,message:Ho,bubbles:un,spark:S_,wand:w_,bot:k_,help:Bo,lifebuoy:T_,headset:C_,search:E_,sparkles:I_,concierge:R_,wave:A_};var R=x.cssPrefix,k={launcher:`${R}-launcher`,callout:`${R}-callout`,calloutDismiss:`${R}-callout-dismiss`,panel:`${R}-panel`,panelHeader:`${R}-panel-header`,resizeGrip:`${R}-resize-grip`,scrollToBottom:`${R}-scroll-to-bottom`,actionHistory:`${R}-action-history`,actionClose:`${R}-action-close`,langSegment:`${R}-lang-segment`,composer:`${R}-composer`,composerInput:`${R}-composer-input`,composerSend:`${R}-composer-send`,composerStop:`${R}-composer-stop`,composerAttach:`${R}-composer-attach`,composerFileInput:`${R}-composer-file-input`,composerVoice:`${R}-composer-voice`,attachmentChip:`${R}-attachment-chip`,attachmentRemove:`${R}-attachment-remove`,suggestion:`${R}-suggestion`,messageBubble:`${R}-message`,messageRetry:`${R}-message-retry`,historyPane:`${R}-history-pane`,historyBack:`${R}-history-back`,historyItem:`${R}-history-item`,sidebar:`${R}-sidebar`,sidebarToggle:`${R}-sidebar-toggle`,sidebarNewConversation:`${R}-sidebar-new-conversation`,sidebarItem:`${R}-sidebar-item`,messengerHome:`${R}-messenger-home`,modulesEmpty:`${R}-modules-empty`,tab:`${R}-tab`,tabBadge:`${R}-tab-badge`,homeView:`${R}-home-view`,homeGreeting:`${R}-home-greeting`,homeBrand:`${R}-home-brand`,backHeader:`${R}-back-header`,contentView:`${R}-content-view`,contentScroll:`${R}-content-scroll`,homeSearch:`${R}-home-search`,helpSearch:`${R}-help-search`,homeRecent:`${R}-home-recent`,homeContentRow:`${R}-home-content-row`,helpArticle:`${R}-help-article`,newsItem:`${R}-news-item`,formGate:`${R}-form-gate`,formDone:`${R}-form-done`,formDoneToggle:`${R}-form-done-toggle`,formAnswers:`${R}-form-answers`,formFill:`${R}-form-fill`,formSubmit:`${R}-form-submit`,formSkip:`${R}-form-skip`,formField:`${R}-form-field`,toolAskInput:`${R}-tool-ask-input`,toolInputSubmit:`${R}-tool-input-submit`,toolInputSkip:`${R}-tool-input-skip`,toolApproval:`${R}-tool-approval`,toolApprove:`${R}-tool-approve`,toolReject:`${R}-tool-reject`,toolDecision:`${R}-tool-decision`,toolCall:`${R}-tool-call`,source:`${R}-source`};function ve(e,t){return`${e}-${t}`}var hr=x.cssPrefix;function Ns({onToggle:e,launcher:t,strings:n,leaving:r,edgeTab:i}){let a=t.variant!=="circle"&&!!t.label;return o("button",{type:"button",class:`${hr}-fab`,"data-variant":t.variant,"data-size":t.size,"data-edge-tab":i?"true":void 0,"data-leaving":r?"true":void 0,"data-testid":k.launcher,onClick:e,"aria-label":n.launcherOpen,children:[L_(t.icon),a?o("span",{class:`${hr}-fab-label`,children:Se(n,t.label??"")}):null]})}function L_(e){let t=Ms[e];return t?o(t,{}):o(M_,{source:e})}function M_({source:e}){return o("span",{ref:t=>{t&&N_(t,e)},"aria-hidden":"true"})}function N_(e,t){if(e.dataset.svgMounted!==t)try{let r=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;r&&r.tagName.toLowerCase()==="svg"&&(e.replaceChildren(document.importNode(r,!0)),e.dataset.svgMounted=t)}catch{}}function Ds({callout:e,launcherPosition:t,strings:n,closeLabel:r,onDismiss:i}){let[a,l]=I(!1);return T(()=>{let s=setTimeout(()=>l(!0),e.delayMs);return()=>clearTimeout(s)},[e.delayMs]),T(()=>{if(!a||e.autoDismissMs<=0)return;let s=setTimeout(i,e.autoDismissMs);return()=>clearTimeout(s)},[a,e.autoDismissMs,i]),a?o("div",{class:`${hr}-callout`,role:"status","data-shape":e.shape,"data-position":D_(e.position,t),"data-animated":e.animated?"true":void 0,"data-testid":k.callout,children:[o("span",{children:Se(n,e.text)}),o("button",{type:"button",class:`${hr}-callout-close`,onClick:i,"aria-label":r,title:r,"data-testid":k.calloutDismiss,children:o(ze,{})})]}):null}function D_(e,t){let n=t.endsWith("-right"),r=t.startsWith("bottom-");return e==="vertical"?r?"top":"bottom":n?"left":"right"}function vr({panelEl:e,resize:t,position:n,initialSize:r,onSizeChange:i,strings:a}){let l=x.cssPrefix,s=M(null);if(T(()=>{if(!e)return;let g=e.style;t.minWidth&&g.setProperty(`--${l}-resize-min-w`,t.minWidth),t.maxWidth&&g.setProperty(`--${l}-resize-max-w`,t.maxWidth),t.minHeight&&g.setProperty(`--${l}-resize-min-h`,t.minHeight),t.maxHeight&&g.setProperty(`--${l}-resize-max-h`,t.maxHeight),r&&(g.setProperty(`--${l}-widget-w`,`${r.width}px`),g.setProperty(`--${l}-widget-h`,`${r.height}px`))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,l,r]),!e)return null;let c=n.startsWith("top-"),d=n.endsWith("-right"),u=`${l}-resize-grip ${l}-resize-grip--${c?"bottom":"top"}-${d?"left":"right"}`,_=g=>{if(!e)return;let S=g.currentTarget,h=e.getBoundingClientRect();s.current={pointerId:g.pointerId,startX:g.clientX,startY:g.clientY,startW:h.width,startH:h.height,dirX:d?-1:1,dirY:c?1:-1},S.setPointerCapture(g.pointerId),e.setAttribute("data-resizing",""),g.preventDefault()},m=g=>{let S=s.current;if(!S||g.pointerId!==S.pointerId||!e)return;let h=(g.clientX-S.startX)*S.dirX,v=(g.clientY-S.startY)*S.dirY;e.style.setProperty(`--${l}-widget-w`,`${S.startW+h}px`),e.style.setProperty(`--${l}-widget-h`,`${S.startH+v}px`)},f=g=>{let S=s.current;if(!S||g.pointerId!==S.pointerId||!e)return;g.currentTarget.releasePointerCapture(g.pointerId),e.removeAttribute("data-resizing");let h=e.getBoundingClientRect();i({width:Math.round(h.width),height:Math.round(h.height)}),s.current=null};return o("div",{class:u,role:"separator","aria-orientation":"vertical","aria-label":a.resizeHandle,title:a.resizeHandle,onPointerDown:_,onPointerMove:m,onPointerUp:f,onPointerCancel:f,"data-testid":k.resizeGrip,children:o(gs,{})})}var pt=x.cssPrefix,O_=`.${pt}-header, .${pt}-back-header, .${pt}-home-hero`,$_='button, a, input, textarea, select, [role="tab"], [contenteditable]',Os=56;function br(e,t){T(()=>{if(!t||!e)return;let n=c=>Number.parseFloat(c)||0,r=(c,d)=>Math.min(d,Math.max(-d,c)),i=null,a=c=>{let d=c.target;if(!(d instanceof Element)||!d.closest(O_)||d.closest($_))return;let u=e.getBoundingClientRect();i={id:c.pointerId,x:c.clientX,y:c.clientY,dx:n(e.style.getPropertyValue(`--${pt}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${pt}-modal-dy`)),maxX:(window.innerWidth+u.width)/2-Os,maxY:(window.innerHeight+u.height)/2-Os},e.dataset.dragging="true",c.preventDefault()},l=c=>{if(!i||c.pointerId!==i.id)return;let d=r(i.dx+c.clientX-i.x,i.maxX),u=r(i.dy+c.clientY-i.y,i.maxY);e.style.setProperty(`--${pt}-modal-dx`,`${d}px`),e.style.setProperty(`--${pt}-modal-dy`,`${u}px`)},s=c=>{!i||c.pointerId!==i.id||(i=null,delete e.dataset.dragging)};return e.addEventListener("pointerdown",a),window.addEventListener("pointermove",l),window.addEventListener("pointerup",s),window.addEventListener("pointercancel",s),()=>{e.removeEventListener("pointerdown",a),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",s),window.removeEventListener("pointercancel",s)}},[e,t])}function pn(e,t,n){switch(e){case"clear":case"sound":case"history":case"language":case"theme":case"textSize":return!0;case"expand":return t==="floating";case"fullscreen":return t!=="standalone";case"close":return t==="standalone"||t==="page"?!1:t==="inline"?n==="fullscreen":!0}}function xr(e,t,n){return pn("close",e,t)?n.includes("close"):!1}function $s(e,t){return e==="inline"&&t==="fullscreen"?"exit-fullscreen":"close"}var H_='a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),[tabindex]:not([tabindex="-1"])';function Pr(e){let t=n=>{if(n.key!=="Tab")return;let r=[...e.querySelectorAll(H_)].filter(s=>s.offsetParent!==null||s===document.activeElement);if(r.length===0){n.preventDefault();return}let i=r[0],a=r[r.length-1];if(!i||!a)return;let l=e.getRootNode().activeElement;n.shiftKey&&l===i?(n.preventDefault(),a.focus()):!n.shiftKey&&l===a&&(n.preventDefault(),i.focus())};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}function yr(e){return e.trim().split(/\s+/).slice(0,2).map(t=>t.charAt(0).toUpperCase()).join("")}var zo=x.cssPrefix;function Hs({agent:e,strings:t}){let n=e.status??"online",r=Se(t,e.name),i=e.title?Se(t,e.title):null;return o("div",{class:`${zo}-agent`,children:[o("div",{class:`${zo}-agent-avatar`,"data-status":n,children:e.avatar?o("img",{src:e.avatar,alt:""}):o("span",{children:yr(r)})}),o("div",{class:`${zo}-agent-meta`,children:[o("strong",{children:r}),i?o("span",{children:i}):null]})]})}var Bs=B.scope("attachments");function Sr(e,t,n){let r=F_(e),i=[],a=[],l=W_(n.accept),s=t.reduce((d,u)=>d+u.size,0),c=t.length;for(let d of r){let u=B_(d,c,s,n,l);if(u){a.push({file:d,reason:u});continue}i.push(U_(d)),s+=d.size,c+=1}return(i.length||a.length)&&Bs.debug("ingest",{accepted:i.length,rejected:a.map(d=>({name:d.file.name,reason:d.reason}))}),{accepted:i,rejected:a}}function Uo(e){try{URL.revokeObjectURL(e.previewUrl)}catch(t){Bs.debug("revokeObjectURL failed",{error:t})}}function B_(e,t,n,r,i){return t>=r.maxCount?"count":n+e.size>r.maxBytes?"bytes":V_(e,i)?null:"mime"}function F_(e){return e?Array.isArray(e)?e.filter(t=>t instanceof File):[...e].map(t=>t instanceof File?t:z_(t)).filter(t=>t!==null):[]}function z_(e){let t=e;return!t?.getAsFile||t.kind!=="file"?null:t.getAsFile()}function U_(e){return{file:e,id:Ne(),mediaType:e.type||"application/octet-stream",name:e.name||"pasted-file",previewUrl:URL.createObjectURL(e),size:e.size}}function W_(e){return e.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean).map(t=>{if(t.startsWith("."))return{kind:"ext",ext:t};let[n="*",r="*"]=t.split("/");return{kind:"mime",type:n,subtype:r}})}function V_(e,t){if(t.length===0)return!0;let[n="*",r="*"]=(e.type||"").toLowerCase().split("/"),i=(e.name||"").toLowerCase();return t.some(a=>a.kind==="ext"?i.endsWith(a.ext):(a.type==="*"||a.type===n)&&(a.subtype==="*"||a.subtype===r))}var fn=x.cssPrefix;function Fs({attachment:e,onRemove:t}){let n=e.mediaType.startsWith("image/");return o("span",{class:`${fn}-attachment-chip`,title:e.name,"data-testid":ve(k.attachmentChip,e.id),children:[n?o("img",{class:`${fn}-attachment-thumb`,src:e.previewUrl,alt:""}):o("span",{class:`${fn}-attachment-thumb`,"aria-hidden":"true",children:o(Cs,{})}),o("span",{class:`${fn}-attachment-name`,children:e.name}),o("button",{type:"button",class:`${fn}-attachment-remove`,onClick:t,"aria-label":`Remove ${e.name}`,"data-testid":ve(k.attachmentRemove,e.id),children:o(ze,{})})]})}var Wo={isSupported:!1,start:()=>{},stop:()=>{}};function Vo(e,t,n){return e==="disabled"?Wo:e==="server"?j_(n):G_(t)}function G_(e){let t=K_();if(!t)return Wo;let n=null;return{isSupported:!0,start(r,i){n=new t,n.continuous=!0,n.interimResults=!0,n.lang=e,n.addEventListener("result",l=>{let s=l,c="",d=!1;for(let u=s.resultIndex;u<s.results.length;u++){let _=s.results[u];_&&(c+=_[0].transcript,_.isFinal&&(d=!0))}r(c,d)});let a=()=>{n=null,i()};n.addEventListener("end",a),n.addEventListener("error",a),n.start()},stop(){n?.stop()}}}function K_(){let e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition}var q_=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus","audio/mp4"];function j_(e){if(typeof MediaRecorder>"u"||!navigator?.mediaDevices?.getUserMedia)return Wo;let t=null,n=null,r=[],i=()=>{for(let a of n?.getTracks()??[])a.stop();n=null};return{isSupported:!0,async start(a,l){try{n=await navigator.mediaDevices.getUserMedia({audio:!0});let s=X_();t=new MediaRecorder(n,s?{mimeType:s}:void 0),r=[],t.addEventListener("dataavailable",c=>{c.data.size>0&&r.push(c.data)}),t.addEventListener("stop",async()=>{let c=t?.mimeType??"audio/webm";i();let d=new Blob(r,{type:c});r=[];try{let{text:u}=await e(d,c);u&&a(u,!0)}catch{}finally{l()}}),t.start()}catch{i(),l()}},stop(){t?.stop()}}}function X_(){for(let e of q_)if(MediaRecorder.isTypeSupported(e))return e}var Ae=x.cssPrefix,ft=B.scope("composer");function Dt(e){return e.reduce((t,n)=>t+n.size,0)}var Y_={arrowUp:ss,paperPlane:as,send:ls,chevron:Nt};function zs({options:e,transport:t,feedback:n,bus:r,isStreaming:i,onSend:a,onStop:l,attachApiRef:s}){let c=e.strings,[d,u]=I(""),[_,m]=I([]),[f,g]=I(!1),S=M(null),h=M(null),v=e.features.files,C=e.features.voice,[b,E]=I(()=>Vo(C,e.locale,(w,q)=>t.transcribe(w,q)));T(()=>{f||C==="disabled"||E(Vo(C,e.locale,(w,q)=>t.transcribe(w,q)))},[e.locale,C,t,f]),T(()=>{let w=S.current;if(!w)return;let q=w.getRootNode(),ne="activeElement"in q?q.activeElement:null;ne&&w.closest(`.${Ae}-panel`)?.contains(ne)||w.focus({preventScroll:!0})},[]),T(()=>{let w=S.current;if(w){if(d.length===0){w.style.height="";return}w.style.height="auto",w.style.height=`${Math.min(w.scrollHeight,160)}px`}},[d]);let D=M(_);D.current=_,T(()=>()=>D.current.forEach(Uo),[]),T(()=>{if(s)return s.current={attachFromDrop:w=>{let q=Sr(w,D.current,e.attachments);q.accepted.length!==0&&(ft.info("attach (drop)",{count:q.accepted.length,totalBytes:Dt(q.accepted)}),r.emit("attach",{count:q.accepted.length,totalBytes:Dt(q.accepted)}),m(ne=>[...ne,...q.accepted]))}},()=>{s.current&&(s.current=null)}},[s,e.attachments]),T(()=>{let w=S.current;if(!w)return;let q=w.closest(`.${Ae}-panel`);if(!q)return;let ne=ce=>{let de=ce.clipboardData;if(!de)return;if(v){let y=Sr(de.items,D.current,e.attachments);if(y.accepted.length>0){ce.preventDefault(),ft.info("attach (paste)",{count:y.accepted.length,totalBytes:Dt(y.accepted)}),r.emit("attach",{count:y.accepted.length,totalBytes:Dt(y.accepted)}),m(z=>[...z,...y.accepted]);return}}if(ce.target===w)return;let Me=de.getData("text/plain");Me&&(ce.preventDefault(),u(y=>y+Me),w.focus())};return q.addEventListener("paste",ne),()=>q.removeEventListener("paste",ne)},[v,e.attachments,Ae]);let V=()=>{let w=d.trim();!w&&_.length===0||i||(a(w,_),u(""),m([]))},G=w=>{w.key!=="Enter"||w.shiftKey||w.isComposing||(w.preventDefault(),i?l():V())},ae=w=>{let q=w.target,ne=Sr(q.files,_,e.attachments);ne.accepted.length>0&&(ft.info("attach (file picker)",{count:ne.accepted.length,totalBytes:Dt(ne.accepted)}),r.emit("attach",{count:ne.accepted.length,totalBytes:Dt(ne.accepted)}),m(ce=>[...ce,...ne.accepted])),q.value=""},K=w=>{ft.info("removeAttachment",{id:w}),r.emit("removeAttachment",{id:w}),m(q=>{let ne=q.find(ce=>ce.id===w);return ne&&Uo(ne),q.filter(ce=>ce.id!==w)})},U=M(null),j=()=>{if(b.isSupported){if(f){let w=U.current?Date.now()-U.current:0;ft.info("voiceStop",{durationMs:w}),r.emit("voiceStop",{durationMs:w}),b.stop(),g(!1),n.play("voiceStop"),U.current=null;return}U.current=Date.now(),ft.info("voiceStart"),r.emit("voiceStart",void 0),g(!0),n.play("voiceStart"),b.start((w,q)=>u(ne=>q?`${ne}${w} `:ne),()=>{if(g(!1),U.current){let w=Date.now()-U.current;ft.debug("voiceStop (auto)",{durationMs:w}),r.emit("voiceStop",{durationMs:w}),U.current=null}})}},be=Y_[e.composer.sendButton.icon];return o("div",{class:`${Ae}-composer`,"data-testid":k.composer,children:[_.length>0?o("div",{class:`${Ae}-attachments`,children:_.map(w=>o(Fs,{attachment:w,onRemove:()=>K(w.id)},w.id))}):null,o("div",{class:`${Ae}-composer-row`,children:[o("div",{class:`${Ae}-composer-actions`,children:[v?o("button",{type:"button",class:`${Ae}-icon-btn`,onClick:()=>h.current?.click(),"aria-label":c.attach,"data-testid":k.composerAttach,children:o(ds,{})}):null,b.isSupported?o("button",{type:"button",class:`${Ae}-icon-btn`,onClick:j,"aria-label":f?c.micStop:c.micStart,"aria-pressed":f,"data-recording":f?"true":void 0,"data-testid":k.composerVoice,children:o(_s,{})}):null]}),o("textarea",{ref:S,class:`${Ae}-textarea`,rows:1,value:d,placeholder:c.composerPlaceholder,onInput:w=>u(w.target.value),onKeyDown:G,"aria-label":c.composerPlaceholder,"data-testid":k.composerInput}),i?o("button",{type:"button",class:`${Ae}-send`,onClick:l,"aria-label":c.stop,"data-testid":k.composerStop,children:o(cs,{})}):o("button",{type:"button",class:`${Ae}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:V,disabled:!d.trim()&&_.length===0,"aria-label":c.send,"data-testid":k.composerSend,children:o(be,{})})]}),o("input",{ref:h,type:"file",multiple:!0,accept:e.attachments.accept,onChange:ae,class:`${Ae}-sr-only`,"data-testid":k.composerFileInput})]})}var J_=x.cssPrefix;function Us({visible:e,strings:t}){return e?o("div",{class:`${J_}-dropzone`,role:"status","aria-live":"polite",children:t.dropZone}):null}function wr({containerRef:e,onDrop:t}){let[n,r]=I(!1);return T(()=>{let i=e.current;if(!i)return;let a=0,l=u=>{a+=1,u.dataTransfer?.types.includes("Files")&&(u.preventDefault(),r(!0))},s=()=>{a-=1,!(a>0)&&(a=0,r(!1))},c=u=>{u.dataTransfer?.types.includes("Files")&&u.preventDefault()},d=u=>{a=0,r(!1),u.dataTransfer&&(u.preventDefault(),t(u.dataTransfer.items))};return i.addEventListener("dragenter",l),i.addEventListener("dragleave",s),i.addEventListener("dragover",c),i.addEventListener("drop",d),()=>{i.removeEventListener("dragenter",l),i.removeEventListener("dragleave",s),i.removeEventListener("dragover",c),i.removeEventListener("drop",d)}},[e,t]),{visible:n}}function Ws({itemCount:e,initialFocusIndex:t}){let[n,r]=I(!1),i=M(null),a=M(null),[l,s]=I(-1),c=H(()=>{r(!1),s(-1),i.current?.focus()},[]),d=H(()=>r(m=>!m),[]);T(()=>{if(!n)return;let m=f=>{let g=a.current,S=i.current;if(!g||!S)return;let h=f.composedPath();h.includes(g)||h.includes(S)||(r(!1),s(-1))};return document.addEventListener("click",m,!0),()=>document.removeEventListener("click",m,!0)},[n]),T(()=>{if(!n||e===0)return;let m=t?.()??0,f=m<0||m>=e?0:m;s(f)},[n,e,t]),T(()=>{if(!n||l<0)return;a.current?.querySelectorAll("[role='menuitem']")?.[l]?.focus()},[n,l]);let u=H(m=>{(m.key==="ArrowDown"||m.key==="Enter"||m.key===" ")&&(m.preventDefault(),r(!0))},[]),_=H(m=>{if(e!==0)switch(m.key){case"Escape":m.preventDefault(),c();return;case"ArrowDown":m.preventDefault(),s(f=>(f+1)%e);return;case"ArrowUp":m.preventDefault(),s(f=>(f-1+e)%e);return;case"Home":m.preventDefault(),s(0);return;case"End":m.preventDefault(),s(e-1)}},[e,c]);return{open:n,focusIndex:l,triggerRef:i,menuRef:a,toggle:d,close:c,onTriggerKey:u,onMenuKey:_}}function Vs({items:e,triggerLabel:t}){let n=x.cssPrefix,r=Ws({itemCount:e.length}),i=s=>{s.disabled||(s.onSelect?.(),s.keepOpen||r.close())},a=(s,c)=>s.onSelectValue?.(c),l=(s,c)=>{let d=c.segments;if(!d?.length)return;let u=Math.max(0,d.findIndex(m=>m.value===c.value)),_=-1;if(s.key==="ArrowRight"||s.key==="Enter"||s.key===" ")_=(u+1)%d.length;else if(s.key==="ArrowLeft")_=(u-1+d.length)%d.length;else return;s.preventDefault(),s.stopPropagation(),a(c,d[_].value)};return o("div",{class:`${n}-menu-wrap`,children:[o("button",{ref:r.triggerRef,type:"button",class:`${n}-icon-btn`,"aria-label":t,"aria-haspopup":"menu","aria-expanded":r.open,title:t,onClick:r.toggle,onKeyDown:r.onTriggerKey,children:o(hs,{})}),r.open?o("div",{ref:r.menuRef,class:`${n}-menu`,role:"menu","aria-label":t,onKeyDown:r.onMenuKey,tabIndex:-1,children:e.map(s=>s.segments?o("div",{role:"menuitem",class:`${n}-menu-item ${n}-menu-item-segmented`,"aria-label":s.label,tabIndex:-1,onKeyDown:c=>l(c,s),children:[s.icon?o("span",{class:`${n}-menu-icon`,children:s.icon}):null,o("span",{class:`${n}-menu-label`,children:s.label}),o("span",{class:`${n}-segmented`,role:"group","aria-label":s.label,children:s.segments.map(c=>{let d=c.value===s.value;return o("button",{type:"button",role:"menuitemradio","aria-checked":d,class:`${n}-segment`,"data-on":d?"true":void 0,lang:c.lang,title:c.value,tabIndex:-1,"data-testid":`${k.langSegment}-${c.value}`,onClick:()=>a(s,c.value),children:c.label},c.value)})})]},s.id):o("button",{type:"button",role:"menuitem",class:`${n}-menu-item`,"aria-pressed":s.type==="switch"?s.on:void 0,disabled:s.disabled,onClick:()=>i(s),children:[s.icon?o("span",{class:`${n}-menu-icon`,children:s.icon}):null,o("span",{class:`${n}-menu-label`,children:s.label}),s.type==="switch"&&s.on?o("span",{class:`${n}-menu-check`,"aria-hidden":"true",children:o(dn,{})}):null]},s.id))}):null]})}var Go=x.cssPrefix;function Q_(e){let t=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)").matches:!0;return e==="auto"?t?"light":"dark":t?e==="light"?"dark":"auto":e==="dark"?"light":"auto"}var Z_={normal:"large",large:"small",small:"normal"};function eu(e){return e==="light"?o(Rs,{}):e==="dark"?o(As,{}):o(Ls,{})}function tu(e){return(e.split("-")[0]??e).toUpperCase()}function Ue({panelProps:e,variant:t}){let{options:n,panelSize:r,feedback:i,onClose:a,onClear:l,onExpand:s,onFullscreen:c,onSoundToggle:d}=e,{onToggleHistory:u,onLocaleChange:_,onThemeChange:m,onTextSizeChange:f}=e,g=n.strings,S=n.mode,h=t==="chat",v=Y(()=>i.mutedSig.value).value,C=new Set(n.actions),b=w=>C.has(w),E=typeof matchMedia=="function"&&matchMedia("(max-width: 640px)").matches,D=w=>E?!1:pn(w,S,r),V=n.themeMode,G={auto:g.themeAuto,light:g.themeLight,dark:g.themeDark},ae=n.textSize,K={small:g.textSizeSmall,normal:g.textSizeNormal,large:g.textSizeLarge},U=[];if(h&&b("clear")&&U.push({id:"clear",icon:o(ws,{}),label:g.newConversation,onSelect:l}),b("expand")&&D("expand")){let w=r==="expanded";U.push({id:"expand",icon:w?o(ps,{}):o(us,{}),label:w?g.collapse:g.expand,type:"switch",on:w,onSelect:s})}if(b("fullscreen")&&D("fullscreen")){let w=r==="fullscreen";U.push({id:"fullscreen",icon:w?o(ms,{}):o(fs,{}),label:w?g.exitFullscreen:g.fullscreen,type:"switch",on:w,onSelect:c})}h&&b("sound")&&U.push({id:"sound",icon:v?o(bs,{}):o(vs,{}),label:v?g.soundOff:g.soundOn,type:"switch",on:!v,onSelect:d}),b("theme")&&U.push({id:"theme",icon:eu(V),label:`${g.theme}: ${G[V]}`,onSelect:()=>m(Q_(V)),keepOpen:!0}),b("textSize")&&U.push({id:"textSize",icon:o(xs,{}),label:`${g.textSize}: ${K[ae]}`,onSelect:()=>f(Z_[ae]),keepOpen:!0}),b("language")&&n.availableLocales.length>1&&U.push({id:"language",icon:o(Ss,{}),label:g.language,segments:n.availableLocales.map(w=>({value:w,label:tu(w),lang:w})),value:n.locale,onSelectValue:_});let j=!!a&&xr(S,r,n.actions),be=h&&b("history");return o("div",{class:`${Go}-header-actions`,children:[be?o("button",{type:"button",class:`${Go}-icon-btn`,onClick:u,"aria-label":g.history,title:g.history,"data-testid":k.actionHistory,children:o(ys,{})}):null,U.length>0?o(Vs,{items:U,triggerLabel:g.moreActions}):null,j?o("button",{type:"button",class:`${Go}-icon-btn`,onClick:a,"aria-label":g.close,title:g.close,"data-testid":k.actionClose,children:o(ze,{})}):null]})}var nu=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ru=/^https?:\/\/[^\s.]+\.[^\s]+$/i,ou=/^[+]?[\d\s().-]{6,}$/;function Ot(e,t){return e.replace(/\{(\w+)\}/g,(n,r)=>String(t[r]??`{${r}}`))}function iu(e){return Array.isArray(e)?e.length:e&&e.trim()?1:0}function au(e,t,n){let r=e.required??!0,i=e.validation;if(e.type==="multiselect"){let l=iu(t);return r&&l===0?n.formRequired:l===0?void 0:i?.minSelections!=null&&l<i.minSelections?Ot(n.formChooseAtLeast,{min:i.minSelections}):i?.maxSelections!=null&&l>i.maxSelections?Ot(n.formChooseAtMost,{max:i.maxSelections}):void 0}let a=typeof t=="string"?t.trim():"";if(!a)return r?n.formRequired:void 0;switch(e.type){case"email":if(!nu.test(a))return n.formInvalidEmail;break;case"url":if(!ru.test(a))return n.formInvalidUrl;break;case"tel":if(!ou.test(a))return n.formInvalidTel;break;case"number":{let l=Number(a);if(!Number.isFinite(l))return n.formInvalidNumber;if(i?.min!=null&&l<i.min)return Ot(n.formNumberTooSmall,{min:i.min});if(i?.max!=null&&l>i.max)return Ot(n.formNumberTooLarge,{max:i.max});break}default:break}if(i?.minLength!=null&&a.length<i.minLength)return Ot(n.formTooShort,{min:i.minLength});if(i?.maxLength!=null&&a.length>i.maxLength)return Ot(n.formTooLong,{max:i.maxLength});if(i?.pattern)try{if(!new RegExp(i.pattern).test(a))return n.formPatternMismatch}catch{}}function Gs(e,t,n){let r={};for(let i of e){let a=au(i,t[i.name],n);a&&(r[i.name]=a)}return r}function Ks(e){let t={};for(let[n,r]of Object.entries(e)){let i=Array.isArray(r)?r.join(", "):r;i&&i.trim()&&(t[n]=i.trim())}return t}var le=x.cssPrefix,kr="__other__";function Cr({fields:e,strings:t,submitLabel:n,onSubmit:r,skipLabel:i,onSkip:a,footerHint:l,disabled:s,rootTestId:c,submitTestId:d,skipTestId:u}){let[_,m]=I(()=>du(e)),[f,g]=I({}),[S,h]=I({}),v=D=>{S[D]&&h(V=>({...V,[D]:""}))},C=(D,V)=>{m(G=>({...G,[D]:V})),v(D)},b=(D,V)=>{g(G=>({...G,[D]:V})),v(D)},E=D=>{if(D.preventDefault(),s)return;let V=_u(e,_,f),G=Gs(e,V,t);if(Object.keys(G).length>0){h(G);return}r(Ks(V))};return o("form",{class:`${le}-form`,onSubmit:E,"data-testid":c,noValidate:!0,children:[e.map(D=>o(su,{field:D,value:_[D.name],otherText:f[D.name]??"",error:S[D.name],disabled:s,strings:t,onChange:V=>C(D.name,V),onOtherChange:V=>b(D.name,V)},D.name)),o("div",{class:`${le}-form-actions`,children:[l?o("span",{class:`${le}-form-hint`,children:l}):null,i&&a?o("button",{type:"button",class:`${le}-form-skip`,onClick:a,disabled:s,"data-testid":u,children:i}):null,o("button",{type:"submit",class:`${le}-form-submit`,disabled:s,"data-testid":d,children:n})]})]})}function su({field:e,value:t,otherText:n,error:r,disabled:i,strings:a,onChange:l,onOtherChange:s}){let c=ve(k.formField,e.name),d=lu({field:e,value:t,otherText:n,disabled:i,strings:a,onChange:l,onOtherChange:s,fieldTid:c});return o("label",{class:`${le}-field`,"data-field":e.name,"data-invalid":r?"true":void 0,children:[o("span",{class:`${le}-field-label`,children:[e.label,e.required??!0?o("span",{class:`${le}-field-req`,"aria-hidden":"true",children:" *"}):null]}),d,e.validationHint&&!r?o("span",{class:`${le}-field-hint`,children:e.validationHint}):null,r?o("span",{class:`${le}-field-error`,role:"alert",children:r}):null]})}function lu(e){let{field:t,value:n,otherText:r,disabled:i,strings:a,onChange:l,onOtherChange:s,fieldTid:c}=e,d=typeof n=="string"?n:"";switch(t.type){case"textarea":return o("textarea",{class:`${le}-field-input`,rows:3,value:d,placeholder:t.placeholder,disabled:i,onInput:u=>l(u.target.value),"data-testid":c});case"select":return o("select",{class:`${le}-field-input`,value:d,disabled:i,onChange:u=>l(u.target.value),"data-testid":c,children:[o("option",{value:"",children:t.placeholder??"\u2014"}),(t.options??[]).map(u=>o("option",{value:u.value,children:u.label??u.value},u.value))]});case"radio":{let u=t.allowOther&&d===kr;return o("div",{class:`${le}-field-choices`,role:"radiogroup","data-testid":c,children:[(t.options??[]).map(_=>o("label",{class:`${le}-choice`,children:[o("input",{type:"radio",name:`${le}-${t.name}`,checked:d===_.value,disabled:i,onChange:()=>l(_.value)}),o("span",{children:_.label??_.value})]},_.value)),t.allowOther?o("label",{class:`${le}-choice`,children:[o("input",{type:"radio",name:`${le}-${t.name}`,checked:d===kr,disabled:i,onChange:()=>l(kr)}),o("span",{children:a.formOther})]}):null,u?o("input",{class:`${le}-field-input`,value:r,placeholder:t.placeholder??a.formOtherPlaceholder,disabled:i,onInput:_=>s(_.target.value)}):null]})}case"checkbox":return o("label",{class:`${le}-choice`,children:[o("input",{type:"checkbox",checked:d==="true",disabled:i,onChange:u=>l(u.target.checked?"true":""),"data-testid":c}),o("span",{children:t.placeholder??t.label})]});case"multiselect":{let u=Array.isArray(n)?n:[],_=(m,f)=>l(f?[...u,m]:u.filter(g=>g!==m));return o("div",{class:`${le}-field-choices`,"data-testid":c,children:[(t.options??[]).map(m=>o("label",{class:`${le}-choice`,children:[o("input",{type:"checkbox",checked:u.includes(m.value),disabled:i,onChange:f=>_(m.value,f.target.checked)}),o("span",{children:m.label??m.value})]},m.value)),t.allowOther||(t.options??[]).length===0?o("textarea",{class:`${le}-field-input`,rows:2,value:r,placeholder:t.placeholder??a.formOtherPlaceholder,disabled:i,onInput:m=>s(m.target.value)}):null]})}default:return o("input",{class:`${le}-field-input`,type:cu(t.type),value:d,placeholder:t.placeholder,disabled:i,onInput:u=>l(u.target.value),"data-testid":c})}}function cu(e){switch(e){case"number":case"email":case"tel":case"url":case"date":case"time":return e;default:return"text"}}function du(e){let t={};for(let n of e)n.defaultValue!=null&&(t[n.name]=n.type==="multiselect"?n.defaultValue.split(",").map(r=>r.trim()).filter(Boolean):n.defaultValue);return t}function _u(e,t,n){let r={...t};for(let i of e){let a=n[i.name]?.trim();if(i.type==="radio"&&i.allowOther&&t[i.name]===kr)r[i.name]=a??"";else if(i.type==="multiselect"&&a){let l=a.split(/[,\n;]+/).map(c=>c.trim()).filter(Boolean),s=Array.isArray(t[i.name])?t[i.name]:[];r[i.name]=[...s,...l]}}return r}var We=x.cssPrefix;function qs({form:e,strings:t,onSubmit:n,onSkip:r}){return o("div",{class:`${We}-form-gate`,"data-testid":k.formGate,children:[e.title?o("h3",{class:`${We}-form-gate-title`,children:e.title}):null,e.description?o("p",{class:`${We}-form-gate-desc`,children:e.description}):null,o(Cr,{fields:e.fields,strings:t,submitLabel:e.submitLabel??t.formSubmit,onSubmit:n,skipLabel:e.skippable?t.formSkip:void 0,onSkip:e.skippable?r:void 0,submitTestId:k.formSubmit,skipTestId:k.formSkip})]})}function js({marker:e,strings:t,onFill:n}){let r=e.outcome==="skipped",i=r?t.formSkipped:t.formSubmitted,a=e.title?o(re,{children:[o("span",{children:e.title}),o("span",{class:`${We}-sr-only`,children:i})]}):o("span",{children:i}),l=e.form?.reviewable??!1,s=!r&&l&&e.values&&Object.keys(e.values).length>0?e.values:null;if(s){let c=d=>e.form?.fields.find(u=>u.name===d)?.label??d;return o("details",{class:`${We}-form-done`,"data-outcome":e.outcome,"data-testid":k.formDone,children:[o("summary",{class:`${We}-form-done-summary`,"data-testid":k.formDoneToggle,children:[o(dn,{}),a,o(Nt,{})]}),o("dl",{class:`${We}-form-answers`,"data-testid":k.formAnswers,children:Object.entries(s).map(([d,u])=>o("div",{class:`${We}-form-answer`,children:[o("dt",{children:c(d)}),o("dd",{children:u})]},d))})]})}return o("div",{class:`${We}-form-done`,"data-outcome":e.outcome,"data-testid":k.formDone,role:"status",children:[r?o(Ps,{}):o(dn,{}),a,r&&e.form?.reopenable&&n?o("button",{type:"button",class:`${We}-form-done-fill`,"data-testid":k.formFill,onClick:n,children:t.formFillOut}):null]})}function Xs(e){if(!e)return!1;let t=e.startsWith("tool:")?e.slice(5):e;return t==="ask-user-input"||t==="ask_user_input"||t==="request-user-input"||t==="request_user_input"}var jo=1,Js=2,Qs=4,Zs=8,el=16;function uu(e){switch(e){case jo:return"href";case Js:return"src";case Qs:return"class";case Zs:return"checked";case el:return"start"}}var pu=e=>{switch(e){case 1:return 3;case 2:return 4;case 3:return 5;case 4:return 6;case 5:return 7;default:return 8}},fu=pu;var Ys=24;function Yo(e){let t=new Uint32Array(Ys);return t[0]=1,{renderer:e,text:"",pending:"",tokens:t,len:0,token:1,fence_end:0,blockquote_idx:0,hr_char:"",hr_chars:0,fence_start:0,spaces:new Uint8Array(Ys),indent:"",indent_len:0,table_state:0}}function tl(e){e.pending.length>0&&Pe(e,`
11
+ ${i}`:i;continue}r.startsWith("id:")&&(n=r.slice(3).trim())}if(!t||t==="[DONE]")return null;try{let r=JSON.parse(t);return Ha.trace("chunk",{type:r.type,eventId:n}),{chunk:r,eventId:n}}catch(r){return Ha.trace("frame parse failed",{err:r,payload:t.slice(0,200)}),null}}function n_(e){let t=new TextEncoder().encode(e),n="";for(let r of t)n+=String.fromCharCode(r);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var Fa=e=>e&&Object.keys(e).length>0?e:void 0;function za(e,t){let n=Fa(e),r=Fa(t);if(!n&&!r)return;let i={};return n&&(i.user=n),r&&(i.page=r),n_(JSON.stringify(i))}function _r(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function r_(e){return`tool-${e.startsWith("tool:")?e.slice(5):e}`}function Ua(e){return e.startsWith("tool-")?e.slice(5):e}var Oe={handshake:"/pai/handshake",streamMessage:"/pai/stream-message",streamResume:"/pai/stream-resume",cancelStream:"/pai/cancel-stream",listConversations:"/pai/list-conversations",listMessages:"/pai/list-messages",updateSettings:"/pai/update-settings",markRead:"/pai/mark-read",bootstrap:"/pai/bootstrap",content:"/pai/content",submitForm:"/pai/submit-form"},Wa="context";function Va(e){let n={messages:e.messages.map(i=>({id:i.serverMessageId??i.id,parts:a_(i),role:i.role,createdAt:i.createdAt!==void 0?new Date(i.createdAt).toISOString():void 0})),conversationId:e.conversationId,trigger:e.trigger??"submit-message"};e.messageId&&(n.messageId=e.messageId),e.visitorId&&(n.visitorId=e.visitorId),e.userPrefs&&(n.userPrefs=e.userPrefs);let r=e.tools?.map(i_).filter(i=>i!==null);return r?.length&&(n.data={tools:r}),n}function o_(e){return e.state==="output-available"||e.state==="output-error"||e.state==="output-denied"||e.approval?.approved!==void 0}function i_(e){return typeof e=="string"?e?{code:e}:null:e?.code?e:null}function a_(e){let t=[];for(let n of e.parts)if(n.kind==="step-start"&&t.push({type:"step-start"}),n.kind==="reasoning"&&n.text&&t.push({type:"reasoning",text:n.text,state:n.done?"done":"streaming"}),n.kind==="text"&&n.text&&t.push({text:n.text,type:"text"}),n.kind==="file"&&n.url&&t.push({mediaType:n.mediaType,type:"file",url:n.url}),n.kind==="tool"&&o_(n)){let r={type:r_(n.toolName),toolCallId:n.toolCallId,state:n.state};n.input!==void 0&&(r.input=n.input),n.output!==void 0&&(r.output=n.output),n.error!==void 0&&(r.errorText=n.error),n.approval&&n.approval.approved!==void 0&&(r.approval=n.approval),t.push(r)}for(let n of e.attachments??[])n.url&&t.push({type:"file",url:n.url,mediaType:n.mediaType,filename:n.name,fileId:n.id,fileSize:n.size});return t}var Q=B.scope("transport"),s_=3,ja=400,l_=6e4,Ga=1e4,Ka=3,c_=new Set([408,425,429,500,502,503,504]);function qa(e){return ja*2**e+Math.floor(Math.random()*250)}function d_(e){let t=e.get("retry-after");if(!t)return null;let n=Number(t),r=Number.isFinite(n)?n*1e3:Date.parse(t)-Date.now();return Number.isFinite(r)&&r>=0?Math.min(r,3e4):null}function Mo(e,t){return new Promise(n=>{if(t?.aborted)return n();let r=setTimeout(a,e),i=()=>a();t?.addEventListener("abort",i,{once:!0});function a(){clearTimeout(r),t?.removeEventListener("abort",i),n()}})}var ur=class{constructor(t){J(this,"opts",t);J(this,"visitorId");J(this,"conversationId");J(this,"userContext");J(this,"pageContext");J(this,"locale");J(this,"conversationsCache",new Map);J(this,"contentCache",new Map)}setContext(t,n){this.userContext=t,this.pageContext=n}setLocale(t){this.locale=t}primeIdentity(t,n){t&&(this.visitorId=t),n&&(this.conversationId=n)}envelope(){let t={_ev:St};this.visitorId&&(t.visitorId=this.visitorId),this.conversationId&&(t.conversationId=this.conversationId),this.locale&&(t.locale=this.locale);let n=za(this.userContext,this.pageContext);return n&&(t[Wa]=n),t}withEnvelope(t){return{...this.envelope(),...t}}appendEnvelope(t){for(let[n,r]of Object.entries(this.envelope()))t.append(n,r);return t}withEnvelopeQuery(t){let n=new URL(this.url(t));for(let[r,i]of Object.entries(this.envelope()))n.searchParams.has(r)||n.searchParams.set(r,i);return n.toString()}async handshake(t){Q.debug("handshake \u2192",{visitorId:t.visitorId,conversationId:t.conversationId,locale:t.locale});let n=await this.postJson(Oe.handshake,t,"handshake");return Q.debug("handshake \u2190",{visitorId:n.visitorId,conversationId:n.conversationId,hasWelcome:!!n.welcome,hasConfig:!!n.config,rebind:n.rebind}),u_(n)||Q.warn("handshake response did not match expected shape; using raw response",{response:n}),this.visitorId=n.visitorId??t.visitorId,this.conversationId=n.conversationId,n}async uploadFile(t){Q.debug("uploadFile \u2192",{name:t.name,size:t.size,type:t.type});let n=new FormData;n.append("file",t,t.name);let r=await this.postForm(this.uploadPath,n,"upload");return Q.debug("uploadFile \u2190",{id:r.id,url:r.url}),r}async transcribe(t,n="audio/webm"){Q.debug("transcribe \u2192",{size:t.size,mimeType:n});let r=new FormData;r.append("audio",t,`voice.${__(n)}`),r.append("mimeType",n);let i=await this.postForm(this.transcribePath,r,"transcribe");return Q.debug("transcribe \u2190",{textLen:i.text.length}),i}conversationsKey(t){return`${this.locale??""}|${JSON.stringify(t,Object.keys(t).toSorted())}`}peekConversations(t={}){let n=this.conversationsCache.get(this.conversationsKey(t));if(n?.value&&Date.now()-n.at<Ga)return n.value}listConversations(t={}){let n=this.conversationsKey(t),r=this.conversationsCache.get(n);if(r&&Date.now()-r.at<Ga)return Q.debug("listConversations \u2192 cache",t),r.result;let i={at:Date.now(),result:this.fetchConversations(t).then(a=>(i.value=a,a)).catch(a=>{throw this.conversationsCache.delete(n),a})};return this.conversationsCache.set(n,i),i.result}async fetchConversations(t){let n=new URL(this.url(Oe.listConversations));t.visitorId&&n.searchParams.set("visitorId",t.visitorId),t.limit&&n.searchParams.set("limit",String(t.limit)),t.cursor&&n.searchParams.set("cursor",t.cursor),Q.debug("listConversations \u2192",{visitorId:t.visitorId??this.visitorId,limit:t.limit,cursor:t.cursor});let r=await this.getJson(n.toString(),"listConversations"),i=r.conversations??[];return Q.debug("listConversations \u2190",{count:i.length,nextCursor:r.nextCursor}),{conversations:i.map(a=>({conversationId:a.conversationId,title:a.title,lastMessageAt:a.lastMessageAt,preview:a.preview,canContinue:a.canContinue,unreadCount:a.unreadCount})),nextCursor:r.nextCursor}}async loadConversation(t){let n=new URL(this.url(Oe.listMessages));n.searchParams.set("conversationId",t),Q.debug("loadConversation \u2192",{conversationId:t,visitorId:this.visitorId});let r=await this.getJson(n.toString(),"loadConversation"),i=r.messages??[];return Q.debug("loadConversation \u2190",{conversationId:r.conversationId,canContinue:r.canContinue,messageCount:i.length,hasSuggestions:!!r.suggestions}),{conversationId:r.conversationId,canContinue:r.canContinue??!0,messages:i,agent:r.agent,suggestions:r.suggestions}}async markRead(t){if(!(!this.visitorId||!t)){this.conversationsCache.clear(),Q.debug("markRead \u2192",{conversationId:t,visitorId:this.visitorId});try{await this.postJson(Oe.markRead,{conversationId:t},"markRead")}catch(n){Q.debug("markRead failed (non-fatal)",{err:n})}}}listContent(t={}){let n=`${this.locale??""}|${JSON.stringify(t,Object.keys(t).toSorted())}`,r=this.contentCache.get(n);if(r&&Date.now()-r.at<l_)return Q.debug("listContent \u2192 cache",t),r.result;let i=this.fetchContent(t).catch(a=>{throw this.contentCache.delete(n),a});return this.contentCache.set(n,{at:Date.now(),result:i}),i}async fetchContent(t){let n=new URL(this.dataUrl(Oe.content));for(let[a,l]of Object.entries(t))l!==void 0&&n.searchParams.set(a,Array.isArray(l)?l.join(","):String(l));Q.debug("listContent \u2192",t);let r=await this.getJson(n.toString(),"listContent"),i=(r.items??[]).map(a=>Fi(a,this.locale));return Q.debug("listContent \u2190",{count:i.length,total:r.pagination?.total}),{...r,items:i}}async bootstrap(t){let n=new URL(this.dataUrl(Oe.bootstrap));t&&n.searchParams.set("conversationId",t),Q.debug("bootstrap \u2192",{conversationId:t??this.conversationId});let r=await this.getJson(n.toString(),"bootstrap"),i=r.forms??[],a=r.formSubmissions??[];return Q.debug("bootstrap \u2190",{forms:i.length,formSubmissions:a.length}),{forms:i,formSubmissions:a}}async saveUserPrefs(t){Q.debug("saveUserPrefs \u2192",{visitorId:this.visitorId,conversationId:this.conversationId,settingsKeys:Object.keys(t)});let n=await this.postJson(Oe.updateSettings,{userPrefs:t},"saveUserPrefs");return Q.debug("saveUserPrefs \u2190",{ok:n.ok}),n}get uploadPath(){return this.opts.endpoints?.upload??"/pai/upload-file"}get transcribePath(){return this.opts.endpoints?.transcribe??"/pai/transcribe-audio"}get submitFormPath(){return this.opts.endpoints?.submitForm??Oe.submitForm}async submitForm(t){Q.debug("submitForm \u2192",{formId:t.formId,trigger:t.trigger,fields:Object.keys(t.values).length});try{await this.postJson(this.dataUrl(this.submitFormPath),t,"submitForm")}catch(n){Q.debug("submitForm failed (non-fatal)",{err:n})}}sendMessage(t){this.conversationsCache.clear(),Q.debug("message \u2192",{conversationId:t.conversationId,visitorId:t.visitorId,messageId:t.messageId,messageCount:t.messages.length,trigger:t.trigger,tools:t.data?.tools?.map(l=>l.code)});let n=new AbortController,r=new Set;return{iter:this.runStream(t,n,r),cancel:()=>this.cancelStream(n,t.conversationId)}}resumeStream(){let t=new AbortController,n=new Set;return{iter:this.resumeStreamGen(t,n,!0),cancel:()=>t.abort()}}async*runStream(t,n,r){(yield*this.drain(this.openMessageStream(t,n.signal),r,n))||(yield*this.resumeStreamGen(n,r,!1))}async*resumeStreamGen(t,n,r){for(let i=1;i<=s_&&!t.signal.aborted;i++){if((!r||i>1)&&(await Mo(ja*i,t.signal),t.signal.aborted))return;let a;try{a=await this.fetchImpl(this.resumeUrl(n.size),{method:"GET",credentials:"omit",headers:{accept:"text/event-stream",...this.opts.auth.headers()},signal:t.signal})}catch(s){if(t.signal.aborted)return;Q.debug("resume fetch failed \u2014 retrying",{attempt:i,err:s});continue}if(a.status===204||!a.ok){Q.debug("resume \u2192 no in-flight stream",{status:a.status});return}let l=n.size;if(yield*this.drain(Lo(a,t.signal),n,t))return;if(n.size===l){Q.debug("resume \u2192 stream closed with no new events; nothing to resume");return}}if(!t.signal.aborted)throw new De("stream incomplete after resume attempts","server")}async*drain(t,n,r){try{for await(let i of t){if(r.signal.aborted)return!0;if(i.eventId){if(n.has(i.eventId))continue;n.add(i.eventId)}if(yield i,i.chunk.type==="finish"||i.chunk.type==="error")return!0}}catch(i){if(r.signal.aborted)return!0;if(i instanceof De&&i.status!==void 0)throw i;Q.debug("stream segment dropped",{err:i})}return!1}cancelStream(t,n){t.signal.aborted||(Q.debug("cancel stream",{conversationId:n,visitorId:this.visitorId}),t.abort(),!(!this.visitorId||!n)&&this.fetchImpl(this.url(Oe.cancelStream),{method:"POST",credentials:"omit",headers:{"content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope({})),keepalive:!0}).catch(r=>Q.debug("cancel POST failed (non-fatal)",{err:r})))}async*openMessageStream(t,n){let r=await this.fetchImpl(this.url(Oe.streamMessage),{method:"POST",credentials:"omit",headers:{accept:"text/event-stream","content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope(t)),signal:n});yield*Lo(r,n)}resumeUrl(t){let n=new URL(this.withEnvelopeQuery(Oe.streamResume));return n.searchParams.set("resumeAt",String(t)),n.toString()}async postJson(t,n,r){let i=await this.fetchWithRetry(()=>[this.url(t),{method:"POST",credentials:"omit",headers:{"content-type":"application/json",...this.opts.auth.headers()},body:JSON.stringify(this.withEnvelope(n))}],r);return this.assertOk(i,r)}async postForm(t,n,r){let i=await this.fetchImpl(this.url(t),{method:"POST",credentials:"omit",headers:this.opts.auth.headers(),body:this.appendEnvelope(n)});return this.assertOk(i,r)}async getJson(t,n){let r=await this.fetchWithRetry(()=>[this.withEnvelopeQuery(t),{method:"GET",credentials:"omit",headers:{accept:"application/json",...this.opts.auth.headers()}}],n);return this.assertOk(r,n)}async fetchWithRetry(t,n){for(let r=0;;r++){let[i,a]=t(),l;try{l=await this.fetchImpl(i,a)}catch(c){if(r>=Ka)throw new De(`${n} failed: network error`,"network",void 0,c);Q.debug("request network error \u2014 retrying",{label:n,attempt:r}),await Mo(qa(r));continue}if(l.ok||!c_.has(l.status)||r>=Ka)return l;let s=d_(l.headers)??qa(r);Q.debug("request retryable status \u2014 retrying",{label:n,status:l.status,attempt:r,wait:s}),await Mo(s)}}async assertOk(t,n){if(!t.ok)throw new De(`${n} failed: ${t.status}`,"server",t.status);return await t.json()}url(t){return/^https?:\/\//i.test(t)?t:`${this.opts.agentApiBaseUrl}${t}`}dataUrl(t){return/^https?:\/\//i.test(t)?t:`${this.opts.dataApiBaseUrl}${t}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function __(e){return e.includes("webm")?"webm":e.includes("ogg")?"ogg":e.includes("mp4")||e.includes("m4a")?"m4a":e.includes("mpeg")?"mp3":e.includes("wav")?"wav":"bin"}function u_(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.visitorId=="string"&&typeof t.conversationId=="string"}function Xa(e,t){let n=e?[{kind:"text",id:"t0",textSig:O(e),doneSig:O(!0)}]:[];return{id:Ne(),role:"user",createdAt:Date.now(),status:"complete",attachments:t,partsSig:O(n)}}function Do(){return{id:Ne(),role:"assistant",createdAt:Date.now(),status:"streaming",partsSig:O([])}}function Ya(e){let t=Ne();return p_({id:t,role:e.role,createdAt:Date.now(),status:"complete",ephemeral:!0,parts:[{kind:"text",id:`${t}-t0`,text:e.text,done:!0}]})}function p_(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,errorText:e.errorText,finishReason:e.finishReason,serverMessageId:e.serverMessageId,ephemeral:e.ephemeral,attachments:e.attachments,partsSig:O(e.parts.map(f_))}}function Oo(e){let t=e.parts.map((n,r)=>n.type==="text"?{kind:"text",id:`${e.id}-t${r}`,textSig:O(n.text),doneSig:O(!0)}:n.type==="reasoning"?{kind:"reasoning",id:`${e.id}-r${r}`,textSig:O(n.text),doneSig:O(n.state!=="streaming")}:n.type==="step-start"?{kind:"step-start",id:`${e.id}-ss${r}`}:n.type==="file"?{kind:"file",url:n.url,mediaType:n.mediaType}:n.type==="source-url"?{kind:"source",sourceId:n.sourceId,url:n.url,title:n.title}:n.type==="source-document"?{kind:"source",sourceId:n.sourceId,title:n.title,filename:n.filename,mediaType:n.mediaType}:n.type.startsWith("tool-")?{kind:"tool",toolCallId:n.toolCallId,toolName:Ua(n.type),inputPartialSig:O(""),inputSig:O(n.input),outputSig:O(n.output),errorSig:O(n.errorText),stateSig:O(n.state),approvalSig:O(n.approval)}:null).filter(n=>n!==null);return{id:e.id,role:e.role,serverMessageId:e.id,createdAt:_r(e.createdAt)??Date.now(),status:"complete",partsSig:O(t)}}function Ja(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,errorText:e.errorText,finishReason:e.finishReason,serverMessageId:e.serverMessageId,ephemeral:e.ephemeral,attachments:e.attachments,parts:e.partsSig.value.map(m_)}}function $o(e){let t="";for(let n of e.partsSig.value)n.kind==="text"&&(t+=n.textSig.value);return t}function f_(e){return e.kind==="text"||e.kind==="reasoning"?{kind:e.kind,id:e.id,textSig:O(e.text),doneSig:O(e.done)}:e.kind==="tool"?{kind:"tool",toolCallId:e.toolCallId,toolName:e.toolName,inputPartialSig:O(e.inputPartial),inputSig:O(e.input),outputSig:O(e.output),errorSig:O(e.error),stateSig:O(e.state),approvalSig:O(e.approval)}:e}function m_(e){return e.kind==="text"||e.kind==="reasoning"?{kind:e.kind,id:e.id,text:e.textSig.value,done:e.doneSig.value}:e.kind==="tool"?{kind:"tool",toolCallId:e.toolCallId,toolName:e.toolName,inputPartial:e.inputPartialSig.value,input:e.inputSig.value,output:e.outputSig.value,error:e.errorSig.value,state:e.stateSig.value,approval:e.approvalSig.value}:e}var Qa=B.scope("reducer"),pr=class{constructor(t){J(this,"messagesSig",t);J(this,"active",null)}attach(t){this.active=t}detach(){this.active=null}apply(t){let n=this.active;if(n)switch(t.type){case"start":t.messageId&&(n.serverMessageId=t.messageId);return;case"finish-step":return;case"start-step":ln(n,{kind:"step-start",id:`ss${n.partsSig.value.length}`});return;case"finish":Qa.debug("finish",{reason:t.finishReason,canContinue:t.canContinue}),n.status="complete",t.finishReason&&(n.finishReason=t.finishReason),this.bumpDone(n);return;case"error":Qa.warn("stream error chunk",{errorText:t.errorText}),n.status="error",n.errorText=t.errorText,this.bumpDone(n);return;case"text-start":Mt(n,"text",t.id);return;case"text-delta":{let r=Mt(n,"text",t.id);r.textSig.value+=t.delta;return}case"text-end":Mt(n,"text",t.id).doneSig.value=!0;return;case"reasoning-start":Mt(n,"reasoning",t.id).doneSig.value=!1;return;case"reasoning-delta":{let r=Mt(n,"reasoning",t.id);r.textSig.value+=t.delta;return}case"reasoning-end":Mt(n,"reasoning",t.id).doneSig.value=!0;return;case"tool-input-start":case"tool-input-delta":case"tool-input-available":case"tool-output-available":case"tool-output-error":case"tool-output-denied":case"tool-approval-request":g_(n,t);return;case"file":ln(n,{kind:"file",url:t.url,mediaType:t.mediaType});return;case"source-url":Za(n,{kind:"source",sourceId:t.sourceId,url:t.url,title:t.title});return;case"source-document":Za(n,{kind:"source",sourceId:t.sourceId,title:t.title,filename:t.filename,mediaType:t.mediaType});return;case"data-notification":return;default:{let r=t}}}bumpDone(t){t.partsSig.value=[...t.partsSig.value],this.messagesSig.value=[...this.messagesSig.value]}};function Mt(e,t,n){let r=e.partsSig.value.find(a=>a.kind===t&&a.id===n);if(r)return r;let i={kind:t,id:n,textSig:O(""),doneSig:O(!1)};return ln(e,i),i}function _t(e,t,n){let r=e.partsSig.value.find(a=>a.kind==="tool"&&a.toolCallId===t);if(r)return r;let i={kind:"tool",toolCallId:t,toolName:n??"tool",inputPartialSig:O(""),inputSig:O(void 0),outputSig:O(void 0),errorSig:O(void 0),stateSig:O("input-streaming"),approvalSig:O(void 0)};return ln(e,i),i}function ln(e,t){e.partsSig.value=[...e.partsSig.value,t]}function Za(e,t){e.partsSig.value.some(n=>n.kind==="source"&&n.sourceId===t.sourceId)||ln(e,t)}function g_(e,t){switch(t.type){case"tool-input-start":_t(e,t.toolCallId,t.toolName);return;case"tool-input-delta":{let n=_t(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case"tool-input-available":{let n=_t(e,t.toolCallId,t.toolName);n.inputSig.value=t.input,n.stateSig.value="input-available";return}case"tool-approval-request":{let n=_t(e,t.toolCallId,t.toolName);n.approvalSig.value={id:t.approvalId},n.stateSig.value="approval-requested";return}case"tool-output-available":{let n=_t(e,t.toolCallId);n.outputSig.value=t.output,n.stateSig.value="output-available";return}case"tool-output-error":{let n=_t(e,t.toolCallId);n.errorSig.value=t.errorText,n.stateSig.value="output-error";return}case"tool-output-denied":{let n=_t(e,t.toolCallId);n.stateSig.value="output-denied";return}default:return}}var es=B.scope("feedback:audio"),fr=class{constructor(){J(this,"ctx",null);J(this,"master",null);J(this,"buffers",new Map)}unlock(){if(this.ctx){this.ctx.state==="suspended"&&this.ctx.resume();return}let t=globalThis.AudioContext??globalThis.webkitAudioContext;if(t)try{this.ctx=new t,this.master=this.ctx.createGain(),this.master.gain.value=1,this.master.connect(this.ctx.destination)}catch(n){es.warn("AudioContext init failed",{err:n})}}setVolume(t){if(!this.master||!this.ctx)return;let n=Math.max(0,Math.min(1,t));this.master.gain.setTargetAtTime(n,this.ctx.currentTime,.01)}playTone(t){let n=this.ctx,r=this.master;if(!n||!r||n.state!=="running")return;let i=n.currentTime,a=t.noteMs/1e3;t.notes.forEach((l,s)=>{let c=n.createOscillator();c.type=t.type,c.frequency.value=l;let d=n.createGain(),u=i+s*a;d.gain.setValueAtTime(1e-4,u),d.gain.exponentialRampToValueAtTime(t.peakGain,u+.005),d.gain.exponentialRampToValueAtTime(1e-4,u+a),c.connect(d).connect(r),c.start(u),c.stop(u+a+.01)})}async playUrl(t){let n=this.ctx,r=this.master;if(!n||!r||n.state!=="running")return;let i=await this.getBuffer(t);if(!i)return;let a=n.createBufferSource();a.buffer=i,a.connect(r),a.start()}destroy(){this.ctx&&this.ctx.close().catch(()=>{}),this.ctx=null,this.master=null,this.buffers.clear()}async getBuffer(t){if(!this.ctx)return null;let n=this.buffers.get(t);if(n)return n instanceof Promise,n;let r=this.ctx,i=fetch(t).then(a=>a.ok?a.arrayBuffer():Promise.reject(new Error(`fetch ${a.status}`))).then(a=>r.decodeAudioData(a)).then(a=>(this.buffers.set(t,a),a)).catch(a=>(es.warn("audio fetch/decode failed",{url:t,err:a}),this.buffers.delete(t),null));return this.buffers.set(t,i),i}};var ts={messageReceived:10,messageSent:0,error:[20,40,20],voiceStart:10,voiceStop:0},ns={messageReceived:{notes:[880,1318.51],noteMs:90,type:"sine",peakGain:.45},messageSent:{notes:[1568],noteMs:60,type:"sine",peakGain:.25},error:{notes:[523.25,392],noteMs:120,type:"triangle",peakGain:.55},voiceStart:{notes:[1318.51],noteMs:50,type:"sine",peakGain:.3},voiceStop:{notes:[880],noteMs:50,type:"sine",peakGain:.3}};var tt=null,mr=0;function h_(){return typeof navigator<"u"&&typeof navigator.vibrate=="function"}function v_(){if(typeof document>"u")return null;let e=document.createElement("input");e.type="checkbox",e.setAttribute("switch",""),e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e.id=`__${x.cssPrefix}_haptic_${Math.random().toString(36).slice(2)}`;let t=document.createElement("label");t.htmlFor=e.id,t.setAttribute("aria-hidden","true");let n="position:absolute!important;width:1px!important;height:1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;opacity:0!important;pointer-events:none!important;";return e.style.cssText=n,t.style.cssText=n,document.body.append(e,t),{input:e,label:t}}function rs(e){if(!(e===0||Array.isArray(e)&&e.every(t=>t===0))){if(h_())try{navigator.vibrate(e);return}catch{}if(tt||(tt=v_()),!!tt)try{tt.label.click()}catch{}}}function os(){mr++;let e=!1;return()=>{e||(e=!0,mr=Math.max(0,mr-1),mr===0&&tt&&(tt.input.remove(),tt.label.remove(),tt=null))}}var b_=B.scope("feedback"),x_=100,gr=class{constructor(t,n){J(this,"mutedSig",O(!1));J(this,"audio",new fr);J(this,"releaseHaptics");J(this,"sound");J(this,"haptics");J(this,"lastPlayed",new Map);J(this,"reducedMotionMq",null);this.sound=t,this.haptics=n,this.releaseHaptics=os(),this.audio.setVolume(this.effectiveVolume()),typeof matchMedia<"u"&&(this.reducedMotionMq=matchMedia("(prefers-reduced-motion: reduce)"))}unlock(){this.audio.unlock(),this.audio.setVolume(this.effectiveVolume())}update(t,n){this.sound=t,this.haptics=n,this.audio.setVolume(this.effectiveVolume())}setMuted(t){this.mutedSig.value!==t&&(this.mutedSig.value=t)}toggleMuted(){this.mutedSig.value=!this.mutedSig.value}play(t){this.mutedSig.value||this.isDeduped(t)||(this.lastPlayed.set(t,performance.now()),this.sound.enabled&&this.playSound(t),this.haptics.enabled&&this.isTouchDevice()&&this.playHaptic(t))}destroy(){this.audio.destroy(),this.releaseHaptics()}isDeduped(t){let n=this.lastPlayed.get(t);return n===void 0?!1:performance.now()-n<x_}playSound(t){let n=this.sound.events?.[t];if(n===!1)return;if(typeof n=="string"){this.audio.playUrl(n).catch(i=>b_.warn("audio play failed",{err:i,url:n}));return}let r=ns[t];r&&this.audio.playTone(r)}playHaptic(t){if(this.reducedMotionMq?.matches)return;let n=this.haptics.events?.[t];if(n===!1)return;let r=n===!0||n===void 0?ts[t]:n;rs(r)}effectiveVolume(){let t=this.sound.volume??.3;return this.reducedMotionMq?.matches?t*.5:t}isTouchDevice(){return typeof window>"u"?!1:matchMedia("(hover: none) and (pointer: coarse)").matches}};function ut(e,t){return e instanceof De&&e.status===429?t.errorRateLimited:t.errorGeneric}var P_=0;function o(e,t,n,r,i,a){t||(t={});var l,s,c=t;if("ref"in c)for(s in c={},t)s=="ref"?l=t[s]:c[s]=t[s];var d={type:e,props:c,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--P_,__i:-1,__u:0,__source:i,__self:a};if(typeof e=="function"&&(l=e.defaultProps))for(s in l)c[s]===void 0&&(c[s]=l[s]);return X.vnode&&X.vnode(d),d}var $={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24"},cn=`${x.cssPrefix}-icon-dir`,y_=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M21 12a8 8 0 0 1-12 6.93L3 21l1.65-5.16A8 8 0 1 1 21 12Z"})}),ze=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M18 6 6 18M6 6l12 12"})}),is=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M12 5v14M5 12h14"})}),as=()=>o("svg",{...$,class:cn,"aria-hidden":"true",children:[o("path",{d:"m22 2-7 20-4-9-9-4Z"}),o("path",{d:"M22 2 11 13"})]}),ss=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M12 19V5M5 12l7-7 7 7"})}),ls=()=>o("svg",{...$,class:cn,"aria-hidden":"true",children:o("path",{d:"M3 20V4l18 8-18 8Z"})}),Nt=()=>o("svg",{...$,class:cn,"aria-hidden":"true",children:o("path",{d:"m9 18 6-6-6-6"})}),cs=()=>o("svg",{...$,"aria-hidden":"true",children:o("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}),ds=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"m21 11-9 9a5.5 5.5 0 0 1-7.78-7.78l8.49-8.49a3.67 3.67 0 0 1 5.19 5.19l-8.49 8.49a1.83 1.83 0 0 1-2.6-2.6l7.78-7.78"})}),_s=()=>o("svg",{...$,"aria-hidden":"true",children:[o("rect",{x:"9",y:"2",width:"6",height:"12",rx:"3"}),o("path",{d:"M5 10a7 7 0 0 0 14 0M12 19v3"})]}),us=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5"})}),ps=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5"})}),fs=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z"})}),ms=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7"})}),gs=()=>o("svg",{...$,"aria-hidden":"true",viewBox:"0 0 10 10",children:o("path",{d:"M9 1L1 9M9 5L5 9M9 9H9",strokeWidth:"1.5"})}),hs=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),o("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),o("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]}),vs=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M11 5 6 9H2v6h4l5 4zM15 9a5 5 0 0 1 0 6M18 7a9 9 0 0 1 0 10"})}),bs=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6"})}),xs=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M3 18 8 6l5 12M4.7 14h6.6"}),o("path",{d:"M14.5 18l3.2-7 3.2 7M15.6 15.8h4.2"})]}),Ps=()=>o("svg",{...$,class:cn,"aria-hidden":"true",children:o("path",{d:"m5 6 6 6-6 6M13 6l6 6-6 6"})}),dn=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M20 6 9 17l-5-5"})}),ys=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M3 3v6h6"}),o("path",{d:"M3.05 13A9 9 0 1 0 6 5.3L3 9"}),o("path",{d:"M12 7v5l3 2"})]}),Ss=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"12",cy:"12",r:"10"}),o("path",{d:"M2 12h20"}),o("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),_n=()=>o("svg",{...$,class:cn,"aria-hidden":"true",children:o("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),ws=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M12 20h9"}),o("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),ks=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"m6 9 6 6 6-6"})}),Cs=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"}),o("path",{d:"M14 2v6h6"})]}),S_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"m12 3-1.5 4.5L6 9l4.5 1.5L12 15l1.5-4.5L18 9l-4.5-1.5Z"}),o("path",{d:"M19 15v4M17 17h4M5 3v2M4 4h2"})]}),Ho=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2Z"})}),Bo=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"12",cy:"12",r:"10"}),o("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),o("path",{d:"M12 17h.01"})]}),w_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"m15 4 3 3-9 9-3-3z"}),o("path",{d:"M18 2v2M20 4h2M3 20l3-3M3 16h2M5 14v2"})]}),k_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("rect",{x:"4",y:"8",width:"16",height:"12",rx:"2"}),o("path",{d:"M12 8V4"}),o("circle",{cx:"12",cy:"3",r:"1"}),o("path",{d:"M2 14h2M20 14h2M9 13h.01M15 13h.01M9.5 17h5"})]}),C_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M4 14v-2a8 8 0 0 1 16 0v2"}),o("rect",{x:"2",y:"14",width:"4",height:"6",rx:"1.5"}),o("rect",{x:"18",y:"14",width:"4",height:"6",rx:"1.5"}),o("path",{d:"M20 20v1a3 3 0 0 1-3 3h-5"})]}),T_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"12",cy:"12",r:"10"}),o("circle",{cx:"12",cy:"12",r:"4"}),o("path",{d:"m4.93 4.93 4.24 4.24M14.83 14.83l4.24 4.24M14.83 9.17l4.24-4.24M4.93 19.07l4.24-4.24"})]}),Fo=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"11",cy:"11",r:"7"}),o("path",{d:"m21 21-4.3-4.3"})]}),Ts=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"12",cy:"12",r:"9"}),o("path",{d:"m8.5 12 2.5 2.5 4.5-5"})]}),Es=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M3 9.5 12 3l9 6.5"}),o("path",{d:"M5 9v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9"})]}),Is=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"m3 11 15-5v12L3 13z"}),o("path",{d:"M3 11v2a2 2 0 0 0 2 2h1V9H5a2 2 0 0 0-2 2z"}),o("path",{d:"M7 15v3a2 2 0 0 0 4 0v-2"}),o("path",{d:"M21 10a3 3 0 0 1 0 4"})]}),un=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z"}),o("path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1"})]}),Rs=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"12",cy:"12",r:"4"}),o("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}),As=()=>o("svg",{...$,"aria-hidden":"true",children:o("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),Ls=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"12",cy:"12",r:"9"}),o("path",{d:"M12 3v18"}),o("path",{d:"M12 3a9 9 0 0 1 0 18z",fill:"currentColor",stroke:"none"})]}),E_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("circle",{cx:"10.5",cy:"10.5",r:"6.5"}),o("path",{d:"M8 11a2.5 2.5 0 0 0 5 0"}),o("path",{d:"m20 20-4.4-4.4"})]}),I_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M12 3.5 13.6 9 19 10.5 13.6 12 12 17.5 10.4 12 5 10.5 10.4 9z"}),o("path",{d:"M18.5 4v3M20 5.5h-3M5.5 16v2.5M6.75 17.25h-2.5"})]}),R_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M4 18h16"}),o("path",{d:"M5 18a7 7 0 0 1 14 0"}),o("path",{d:"M12 8V6"}),o("path",{d:"M10 6h4"})]}),A_=()=>o("svg",{...$,"aria-hidden":"true",children:[o("path",{d:"M7 11V6.5a1.5 1.5 0 0 1 3 0V10"}),o("path",{d:"M10 10V5.5a1.5 1.5 0 0 1 3 0V10"}),o("path",{d:"M13 10V6.5a1.5 1.5 0 0 1 3 0V12"}),o("path",{d:"M16 9.5a1.5 1.5 0 0 1 3 0v2.5a7 7 0 0 1-7 7 7 7 0 0 1-6.4-4.2L4 12.5a1.5 1.5 0 0 1 2.6-1.5L7 11"})]}),Ms={chat:y_,message:Ho,bubbles:un,spark:S_,wand:w_,bot:k_,help:Bo,lifebuoy:T_,headset:C_,search:E_,sparkles:I_,concierge:R_,wave:A_};var R=x.cssPrefix,k={launcher:`${R}-launcher`,callout:`${R}-callout`,calloutDismiss:`${R}-callout-dismiss`,panel:`${R}-panel`,panelHeader:`${R}-panel-header`,resizeGrip:`${R}-resize-grip`,scrollToBottom:`${R}-scroll-to-bottom`,actionHistory:`${R}-action-history`,actionClose:`${R}-action-close`,langSegment:`${R}-lang-segment`,composer:`${R}-composer`,composerInput:`${R}-composer-input`,composerSend:`${R}-composer-send`,composerStop:`${R}-composer-stop`,composerAttach:`${R}-composer-attach`,composerFileInput:`${R}-composer-file-input`,composerVoice:`${R}-composer-voice`,attachmentChip:`${R}-attachment-chip`,attachmentRemove:`${R}-attachment-remove`,suggestion:`${R}-suggestion`,messageBubble:`${R}-message`,messageRetry:`${R}-message-retry`,historyPane:`${R}-history-pane`,historyBack:`${R}-history-back`,historyItem:`${R}-history-item`,sidebar:`${R}-sidebar`,sidebarToggle:`${R}-sidebar-toggle`,sidebarNewConversation:`${R}-sidebar-new-conversation`,sidebarItem:`${R}-sidebar-item`,messengerHome:`${R}-messenger-home`,modulesEmpty:`${R}-modules-empty`,tab:`${R}-tab`,tabBadge:`${R}-tab-badge`,homeView:`${R}-home-view`,homeGreeting:`${R}-home-greeting`,homeBrand:`${R}-home-brand`,backHeader:`${R}-back-header`,contentView:`${R}-content-view`,contentScroll:`${R}-content-scroll`,homeSearch:`${R}-home-search`,helpSearch:`${R}-help-search`,homeRecent:`${R}-home-recent`,homeContentRow:`${R}-home-content-row`,helpArticle:`${R}-help-article`,newsItem:`${R}-news-item`,formGate:`${R}-form-gate`,formDone:`${R}-form-done`,formDoneToggle:`${R}-form-done-toggle`,formAnswers:`${R}-form-answers`,formFill:`${R}-form-fill`,formSubmit:`${R}-form-submit`,formSkip:`${R}-form-skip`,formField:`${R}-form-field`,toolAskInput:`${R}-tool-ask-input`,toolInputSubmit:`${R}-tool-input-submit`,toolInputSkip:`${R}-tool-input-skip`,toolApproval:`${R}-tool-approval`,toolApprove:`${R}-tool-approve`,toolReject:`${R}-tool-reject`,toolDecision:`${R}-tool-decision`,toolCall:`${R}-tool-call`,source:`${R}-source`};function ve(e,t){return`${e}-${t}`}var hr=x.cssPrefix;function Ns({onToggle:e,launcher:t,strings:n,leaving:r,edgeTab:i}){let a=t.variant!=="circle"&&!!t.label;return o("button",{type:"button",class:`${hr}-fab`,"data-variant":t.variant,"data-size":t.size,"data-edge-tab":i?"true":void 0,"data-leaving":r?"true":void 0,"data-testid":k.launcher,onClick:e,"aria-label":n.launcherOpen,children:[L_(t.icon),a?o("span",{class:`${hr}-fab-label`,children:we(n,t.label??"")}):null]})}function L_(e){let t=Ms[e];return t?o(t,{}):o(M_,{source:e})}function M_({source:e}){return o("span",{ref:t=>{t&&N_(t,e)},"aria-hidden":"true"})}function N_(e,t){if(e.dataset.svgMounted!==t)try{let r=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;r&&r.tagName.toLowerCase()==="svg"&&(e.replaceChildren(document.importNode(r,!0)),e.dataset.svgMounted=t)}catch{}}function Ds({callout:e,launcherPosition:t,strings:n,closeLabel:r,onDismiss:i}){let[a,l]=I(!1);return T(()=>{let s=setTimeout(()=>l(!0),e.delayMs);return()=>clearTimeout(s)},[e.delayMs]),T(()=>{if(!a||e.autoDismissMs<=0)return;let s=setTimeout(i,e.autoDismissMs);return()=>clearTimeout(s)},[a,e.autoDismissMs,i]),a?o("div",{class:`${hr}-callout`,role:"status","data-shape":e.shape,"data-position":D_(e.position,t),"data-animated":e.animated?"true":void 0,"data-testid":k.callout,children:[o("span",{children:we(n,e.text)}),o("button",{type:"button",class:`${hr}-callout-close`,onClick:i,"aria-label":r,title:r,"data-testid":k.calloutDismiss,children:o(ze,{})})]}):null}function D_(e,t){let n=t.endsWith("-right"),r=t.startsWith("bottom-");return e==="vertical"?r?"top":"bottom":n?"left":"right"}function vr({panelEl:e,resize:t,position:n,initialSize:r,onSizeChange:i,strings:a}){let l=x.cssPrefix,s=M(null);if(T(()=>{if(!e)return;let g=e.style;t.minWidth&&g.setProperty(`--${l}-resize-min-w`,t.minWidth),t.maxWidth&&g.setProperty(`--${l}-resize-max-w`,t.maxWidth),t.minHeight&&g.setProperty(`--${l}-resize-min-h`,t.minHeight),t.maxHeight&&g.setProperty(`--${l}-resize-max-h`,t.maxHeight),r&&(g.setProperty(`--${l}-widget-w`,`${r.width}px`),g.setProperty(`--${l}-widget-h`,`${r.height}px`))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,l,r]),!e)return null;let c=n.startsWith("top-"),d=n.endsWith("-right"),u=`${l}-resize-grip ${l}-resize-grip--${c?"bottom":"top"}-${d?"left":"right"}`,_=g=>{if(!e)return;let S=g.currentTarget,h=e.getBoundingClientRect();s.current={pointerId:g.pointerId,startX:g.clientX,startY:g.clientY,startW:h.width,startH:h.height,dirX:d?-1:1,dirY:c?1:-1},S.setPointerCapture(g.pointerId),e.setAttribute("data-resizing",""),g.preventDefault()},m=g=>{let S=s.current;if(!S||g.pointerId!==S.pointerId||!e)return;let h=(g.clientX-S.startX)*S.dirX,v=(g.clientY-S.startY)*S.dirY;e.style.setProperty(`--${l}-widget-w`,`${S.startW+h}px`),e.style.setProperty(`--${l}-widget-h`,`${S.startH+v}px`)},f=g=>{let S=s.current;if(!S||g.pointerId!==S.pointerId||!e)return;g.currentTarget.releasePointerCapture(g.pointerId),e.removeAttribute("data-resizing");let h=e.getBoundingClientRect();i({width:Math.round(h.width),height:Math.round(h.height)}),s.current=null};return o("div",{class:u,role:"separator","aria-orientation":"vertical","aria-label":a.resizeHandle,title:a.resizeHandle,onPointerDown:_,onPointerMove:m,onPointerUp:f,onPointerCancel:f,"data-testid":k.resizeGrip,children:o(gs,{})})}var pt=x.cssPrefix,O_=`.${pt}-header, .${pt}-back-header, .${pt}-home-hero`,$_='button, a, input, textarea, select, [role="tab"], [contenteditable]',Os=56;function br(e,t){T(()=>{if(!t||!e)return;let n=c=>Number.parseFloat(c)||0,r=(c,d)=>Math.min(d,Math.max(-d,c)),i=null,a=c=>{let d=c.target;if(!(d instanceof Element)||!d.closest(O_)||d.closest($_))return;let u=e.getBoundingClientRect();i={id:c.pointerId,x:c.clientX,y:c.clientY,dx:n(e.style.getPropertyValue(`--${pt}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${pt}-modal-dy`)),maxX:(window.innerWidth+u.width)/2-Os,maxY:(window.innerHeight+u.height)/2-Os},e.dataset.dragging="true",c.preventDefault()},l=c=>{if(!i||c.pointerId!==i.id)return;let d=r(i.dx+c.clientX-i.x,i.maxX),u=r(i.dy+c.clientY-i.y,i.maxY);e.style.setProperty(`--${pt}-modal-dx`,`${d}px`),e.style.setProperty(`--${pt}-modal-dy`,`${u}px`)},s=c=>{!i||c.pointerId!==i.id||(i=null,delete e.dataset.dragging)};return e.addEventListener("pointerdown",a),window.addEventListener("pointermove",l),window.addEventListener("pointerup",s),window.addEventListener("pointercancel",s),()=>{e.removeEventListener("pointerdown",a),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",s),window.removeEventListener("pointercancel",s)}},[e,t])}function pn(e,t,n){switch(e){case"clear":case"sound":case"history":case"language":case"theme":case"textSize":return!0;case"expand":return t==="floating";case"fullscreen":return t!=="standalone";case"close":return t==="standalone"||t==="page"?!1:t==="inline"?n==="fullscreen":!0}}function xr(e,t,n){return pn("close",e,t)?n.includes("close"):!1}function $s(e,t){return e==="inline"&&t==="fullscreen"?"exit-fullscreen":"close"}var H_='a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),[tabindex]:not([tabindex="-1"])';function Pr(e){let t=n=>{if(n.key!=="Tab")return;let r=[...e.querySelectorAll(H_)].filter(s=>s.offsetParent!==null||s===document.activeElement);if(r.length===0){n.preventDefault();return}let i=r[0],a=r[r.length-1];if(!i||!a)return;let l=e.getRootNode().activeElement;n.shiftKey&&l===i?(n.preventDefault(),a.focus()):!n.shiftKey&&l===a&&(n.preventDefault(),i.focus())};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}function yr(e){return e.trim().split(/\s+/).slice(0,2).map(t=>t.charAt(0).toUpperCase()).join("")}var zo=x.cssPrefix;function Hs({agent:e,strings:t}){let n=e.status??"online",r=we(t,e.name),i=e.title?we(t,e.title):null;return o("div",{class:`${zo}-agent`,children:[o("div",{class:`${zo}-agent-avatar`,"data-status":n,children:e.avatar?o("img",{src:e.avatar,alt:""}):o("span",{children:yr(r)})}),o("div",{class:`${zo}-agent-meta`,children:[o("strong",{children:r}),i?o("span",{children:i}):null]})]})}var Bs=B.scope("attachments");function Sr(e,t,n){let r=F_(e),i=[],a=[],l=W_(n.accept),s=t.reduce((d,u)=>d+u.size,0),c=t.length;for(let d of r){let u=B_(d,c,s,n,l);if(u){a.push({file:d,reason:u});continue}i.push(U_(d)),s+=d.size,c+=1}return(i.length||a.length)&&Bs.debug("ingest",{accepted:i.length,rejected:a.map(d=>({name:d.file.name,reason:d.reason}))}),{accepted:i,rejected:a}}function Uo(e){try{URL.revokeObjectURL(e.previewUrl)}catch(t){Bs.debug("revokeObjectURL failed",{error:t})}}function B_(e,t,n,r,i){return t>=r.maxCount?"count":n+e.size>r.maxBytes?"bytes":V_(e,i)?null:"mime"}function F_(e){return e?Array.isArray(e)?e.filter(t=>t instanceof File):[...e].map(t=>t instanceof File?t:z_(t)).filter(t=>t!==null):[]}function z_(e){let t=e;return!t?.getAsFile||t.kind!=="file"?null:t.getAsFile()}function U_(e){return{file:e,id:Ne(),mediaType:e.type||"application/octet-stream",name:e.name||"pasted-file",previewUrl:URL.createObjectURL(e),size:e.size}}function W_(e){return e.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean).map(t=>{if(t.startsWith("."))return{kind:"ext",ext:t};let[n="*",r="*"]=t.split("/");return{kind:"mime",type:n,subtype:r}})}function V_(e,t){if(t.length===0)return!0;let[n="*",r="*"]=(e.type||"").toLowerCase().split("/"),i=(e.name||"").toLowerCase();return t.some(a=>a.kind==="ext"?i.endsWith(a.ext):(a.type==="*"||a.type===n)&&(a.subtype==="*"||a.subtype===r))}var fn=x.cssPrefix;function Fs({attachment:e,onRemove:t}){let n=e.mediaType.startsWith("image/");return o("span",{class:`${fn}-attachment-chip`,title:e.name,"data-testid":ve(k.attachmentChip,e.id),children:[n?o("img",{class:`${fn}-attachment-thumb`,src:e.previewUrl,alt:""}):o("span",{class:`${fn}-attachment-thumb`,"aria-hidden":"true",children:o(Cs,{})}),o("span",{class:`${fn}-attachment-name`,children:e.name}),o("button",{type:"button",class:`${fn}-attachment-remove`,onClick:t,"aria-label":`Remove ${e.name}`,"data-testid":ve(k.attachmentRemove,e.id),children:o(ze,{})})]})}var Wo={isSupported:!1,start:()=>{},stop:()=>{}};function Vo(e,t,n){return e==="disabled"?Wo:e==="server"?j_(n):G_(t)}function G_(e){let t=K_();if(!t)return Wo;let n=null;return{isSupported:!0,start(r,i){n=new t,n.continuous=!0,n.interimResults=!0,n.lang=e,n.addEventListener("result",l=>{let s=l,c="",d=!1;for(let u=s.resultIndex;u<s.results.length;u++){let _=s.results[u];_&&(c+=_[0].transcript,_.isFinal&&(d=!0))}r(c,d)});let a=()=>{n=null,i()};n.addEventListener("end",a),n.addEventListener("error",a),n.start()},stop(){n?.stop()}}}function K_(){let e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition}var q_=["audio/webm;codecs=opus","audio/webm","audio/ogg;codecs=opus","audio/mp4"];function j_(e){if(typeof MediaRecorder>"u"||!navigator?.mediaDevices?.getUserMedia)return Wo;let t=null,n=null,r=[],i=()=>{for(let a of n?.getTracks()??[])a.stop();n=null};return{isSupported:!0,async start(a,l){try{n=await navigator.mediaDevices.getUserMedia({audio:!0});let s=X_();t=new MediaRecorder(n,s?{mimeType:s}:void 0),r=[],t.addEventListener("dataavailable",c=>{c.data.size>0&&r.push(c.data)}),t.addEventListener("stop",async()=>{let c=t?.mimeType??"audio/webm";i();let d=new Blob(r,{type:c});r=[];try{let{text:u}=await e(d,c);u&&a(u,!0)}catch{}finally{l()}}),t.start()}catch{i(),l()}},stop(){t?.stop()}}}function X_(){for(let e of q_)if(MediaRecorder.isTypeSupported(e))return e}var Ae=x.cssPrefix,ft=B.scope("composer");function Dt(e){return e.reduce((t,n)=>t+n.size,0)}var Y_={arrowUp:ss,paperPlane:as,send:ls,chevron:Nt};function zs({options:e,transport:t,feedback:n,bus:r,isStreaming:i,onSend:a,onStop:l,attachApiRef:s}){let c=e.strings,[d,u]=I(""),[_,m]=I([]),[f,g]=I(!1),S=M(null),h=M(null),v=e.features.files,C=e.features.voice,[b,E]=I(()=>Vo(C,e.locale,(w,q)=>t.transcribe(w,q)));T(()=>{f||C==="disabled"||E(Vo(C,e.locale,(w,q)=>t.transcribe(w,q)))},[e.locale,C,t,f]),T(()=>{let w=S.current;if(!w)return;let q=w.getRootNode(),ne="activeElement"in q?q.activeElement:null;ne&&w.closest(`.${Ae}-panel`)?.contains(ne)||w.focus({preventScroll:!0})},[]),T(()=>{let w=S.current;if(w){if(d.length===0){w.style.height="";return}w.style.height="auto",w.style.height=`${Math.min(w.scrollHeight,160)}px`}},[d]);let D=M(_);D.current=_,T(()=>()=>D.current.forEach(Uo),[]),T(()=>{if(s)return s.current={attachFromDrop:w=>{let q=Sr(w,D.current,e.attachments);q.accepted.length!==0&&(ft.info("attach (drop)",{count:q.accepted.length,totalBytes:Dt(q.accepted)}),r.emit("attach",{count:q.accepted.length,totalBytes:Dt(q.accepted)}),m(ne=>[...ne,...q.accepted]))}},()=>{s.current&&(s.current=null)}},[s,e.attachments]),T(()=>{let w=S.current;if(!w)return;let q=w.closest(`.${Ae}-panel`);if(!q)return;let ne=ce=>{let de=ce.clipboardData;if(!de)return;if(v){let y=Sr(de.items,D.current,e.attachments);if(y.accepted.length>0){ce.preventDefault(),ft.info("attach (paste)",{count:y.accepted.length,totalBytes:Dt(y.accepted)}),r.emit("attach",{count:y.accepted.length,totalBytes:Dt(y.accepted)}),m(z=>[...z,...y.accepted]);return}}if(ce.target===w)return;let Me=de.getData("text/plain");Me&&(ce.preventDefault(),u(y=>y+Me),w.focus())};return q.addEventListener("paste",ne),()=>q.removeEventListener("paste",ne)},[v,e.attachments,Ae]);let V=()=>{let w=d.trim();!w&&_.length===0||i||(a(w,_),u(""),m([]))},G=w=>{w.key!=="Enter"||w.shiftKey||w.isComposing||(w.preventDefault(),i?l():V())},ae=w=>{let q=w.target,ne=Sr(q.files,_,e.attachments);ne.accepted.length>0&&(ft.info("attach (file picker)",{count:ne.accepted.length,totalBytes:Dt(ne.accepted)}),r.emit("attach",{count:ne.accepted.length,totalBytes:Dt(ne.accepted)}),m(ce=>[...ce,...ne.accepted])),q.value=""},K=w=>{ft.info("removeAttachment",{id:w}),r.emit("removeAttachment",{id:w}),m(q=>{let ne=q.find(ce=>ce.id===w);return ne&&Uo(ne),q.filter(ce=>ce.id!==w)})},U=M(null),j=()=>{if(b.isSupported){if(f){let w=U.current?Date.now()-U.current:0;ft.info("voiceStop",{durationMs:w}),r.emit("voiceStop",{durationMs:w}),b.stop(),g(!1),n.play("voiceStop"),U.current=null;return}U.current=Date.now(),ft.info("voiceStart"),r.emit("voiceStart",void 0),g(!0),n.play("voiceStart"),b.start((w,q)=>u(ne=>q?`${ne}${w} `:ne),()=>{if(g(!1),U.current){let w=Date.now()-U.current;ft.debug("voiceStop (auto)",{durationMs:w}),r.emit("voiceStop",{durationMs:w}),U.current=null}})}},be=Y_[e.composer.sendButton.icon];return o("div",{class:`${Ae}-composer`,"data-testid":k.composer,children:[_.length>0?o("div",{class:`${Ae}-attachments`,children:_.map(w=>o(Fs,{attachment:w,onRemove:()=>K(w.id)},w.id))}):null,o("div",{class:`${Ae}-composer-row`,children:[o("div",{class:`${Ae}-composer-actions`,children:[v?o("button",{type:"button",class:`${Ae}-icon-btn`,onClick:()=>h.current?.click(),"aria-label":c.attach,"data-testid":k.composerAttach,children:o(ds,{})}):null,b.isSupported?o("button",{type:"button",class:`${Ae}-icon-btn`,onClick:j,"aria-label":f?c.micStop:c.micStart,"aria-pressed":f,"data-recording":f?"true":void 0,"data-testid":k.composerVoice,children:o(_s,{})}):null]}),o("textarea",{ref:S,class:`${Ae}-textarea`,rows:1,value:d,placeholder:c.composerPlaceholder,onInput:w=>u(w.target.value),onKeyDown:G,"aria-label":c.composerPlaceholder,"data-testid":k.composerInput}),i?o("button",{type:"button",class:`${Ae}-send`,onClick:l,"aria-label":c.stop,"data-testid":k.composerStop,children:o(cs,{})}):o("button",{type:"button",class:`${Ae}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:V,disabled:!d.trim()&&_.length===0,"aria-label":c.send,"data-testid":k.composerSend,children:o(be,{})})]}),o("input",{ref:h,type:"file",multiple:!0,accept:e.attachments.accept,onChange:ae,class:`${Ae}-sr-only`,"data-testid":k.composerFileInput})]})}var J_=x.cssPrefix;function Us({visible:e,strings:t}){return e?o("div",{class:`${J_}-dropzone`,role:"status","aria-live":"polite",children:t.dropZone}):null}function wr({containerRef:e,onDrop:t}){let[n,r]=I(!1);return T(()=>{let i=e.current;if(!i)return;let a=0,l=u=>{a+=1,u.dataTransfer?.types.includes("Files")&&(u.preventDefault(),r(!0))},s=()=>{a-=1,!(a>0)&&(a=0,r(!1))},c=u=>{u.dataTransfer?.types.includes("Files")&&u.preventDefault()},d=u=>{a=0,r(!1),u.dataTransfer&&(u.preventDefault(),t(u.dataTransfer.items))};return i.addEventListener("dragenter",l),i.addEventListener("dragleave",s),i.addEventListener("dragover",c),i.addEventListener("drop",d),()=>{i.removeEventListener("dragenter",l),i.removeEventListener("dragleave",s),i.removeEventListener("dragover",c),i.removeEventListener("drop",d)}},[e,t]),{visible:n}}function Ws({itemCount:e,initialFocusIndex:t}){let[n,r]=I(!1),i=M(null),a=M(null),[l,s]=I(-1),c=H(()=>{r(!1),s(-1),i.current?.focus()},[]),d=H(()=>r(m=>!m),[]);T(()=>{if(!n)return;let m=f=>{let g=a.current,S=i.current;if(!g||!S)return;let h=f.composedPath();h.includes(g)||h.includes(S)||(r(!1),s(-1))};return document.addEventListener("click",m,!0),()=>document.removeEventListener("click",m,!0)},[n]),T(()=>{if(!n||e===0)return;let m=t?.()??0,f=m<0||m>=e?0:m;s(f)},[n,e,t]),T(()=>{if(!n||l<0)return;a.current?.querySelectorAll("[role='menuitem']")?.[l]?.focus()},[n,l]);let u=H(m=>{(m.key==="ArrowDown"||m.key==="Enter"||m.key===" ")&&(m.preventDefault(),r(!0))},[]),_=H(m=>{if(e!==0)switch(m.key){case"Escape":m.preventDefault(),c();return;case"ArrowDown":m.preventDefault(),s(f=>(f+1)%e);return;case"ArrowUp":m.preventDefault(),s(f=>(f-1+e)%e);return;case"Home":m.preventDefault(),s(0);return;case"End":m.preventDefault(),s(e-1)}},[e,c]);return{open:n,focusIndex:l,triggerRef:i,menuRef:a,toggle:d,close:c,onTriggerKey:u,onMenuKey:_}}function Vs({items:e,triggerLabel:t}){let n=x.cssPrefix,r=Ws({itemCount:e.length}),i=s=>{s.disabled||(s.onSelect?.(),s.keepOpen||r.close())},a=(s,c)=>s.onSelectValue?.(c),l=(s,c)=>{let d=c.segments;if(!d?.length)return;let u=Math.max(0,d.findIndex(m=>m.value===c.value)),_=-1;if(s.key==="ArrowRight"||s.key==="Enter"||s.key===" ")_=(u+1)%d.length;else if(s.key==="ArrowLeft")_=(u-1+d.length)%d.length;else return;s.preventDefault(),s.stopPropagation(),a(c,d[_].value)};return o("div",{class:`${n}-menu-wrap`,children:[o("button",{ref:r.triggerRef,type:"button",class:`${n}-icon-btn`,"aria-label":t,"aria-haspopup":"menu","aria-expanded":r.open,title:t,onClick:r.toggle,onKeyDown:r.onTriggerKey,children:o(hs,{})}),r.open?o("div",{ref:r.menuRef,class:`${n}-menu`,role:"menu","aria-label":t,onKeyDown:r.onMenuKey,tabIndex:-1,children:e.map(s=>s.segments?o("div",{role:"menuitem",class:`${n}-menu-item ${n}-menu-item-segmented`,"aria-label":s.label,tabIndex:-1,onKeyDown:c=>l(c,s),children:[s.icon?o("span",{class:`${n}-menu-icon`,children:s.icon}):null,o("span",{class:`${n}-menu-label`,children:s.label}),o("span",{class:`${n}-segmented`,role:"group","aria-label":s.label,children:s.segments.map(c=>{let d=c.value===s.value;return o("button",{type:"button",role:"menuitemradio","aria-checked":d,class:`${n}-segment`,"data-on":d?"true":void 0,lang:c.lang,title:c.value,tabIndex:-1,"data-testid":`${k.langSegment}-${c.value}`,onClick:()=>a(s,c.value),children:c.label},c.value)})})]},s.id):o("button",{type:"button",role:"menuitem",class:`${n}-menu-item`,"aria-pressed":s.type==="switch"?s.on:void 0,disabled:s.disabled,onClick:()=>i(s),children:[s.icon?o("span",{class:`${n}-menu-icon`,children:s.icon}):null,o("span",{class:`${n}-menu-label`,children:s.label}),s.type==="switch"&&s.on?o("span",{class:`${n}-menu-check`,"aria-hidden":"true",children:o(dn,{})}):null]},s.id))}):null]})}var Go=x.cssPrefix;function Q_(e){let t=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)").matches:!0;return e==="auto"?t?"light":"dark":t?e==="light"?"dark":"auto":e==="dark"?"light":"auto"}var Z_={normal:"large",large:"small",small:"normal"};function eu(e){return e==="light"?o(Rs,{}):e==="dark"?o(As,{}):o(Ls,{})}function tu(e){return(e.split("-")[0]??e).toUpperCase()}function Ue({panelProps:e,variant:t}){let{options:n,panelSize:r,feedback:i,onClose:a,onClear:l,onExpand:s,onFullscreen:c,onSoundToggle:d}=e,{onToggleHistory:u,onLocaleChange:_,onThemeChange:m,onTextSizeChange:f}=e,g=n.strings,S=n.mode,h=t==="chat",v=Y(()=>i.mutedSig.value).value,C=new Set(n.actions),b=w=>C.has(w),E=typeof matchMedia=="function"&&matchMedia("(max-width: 640px)").matches,D=w=>E?!1:pn(w,S,r),V=n.themeMode,G={auto:g.themeAuto,light:g.themeLight,dark:g.themeDark},ae=n.textSize,K={small:g.textSizeSmall,normal:g.textSizeNormal,large:g.textSizeLarge},U=[];if(h&&b("clear")&&U.push({id:"clear",icon:o(ws,{}),label:g.newConversation,onSelect:l}),b("expand")&&D("expand")){let w=r==="expanded";U.push({id:"expand",icon:w?o(ps,{}):o(us,{}),label:w?g.collapse:g.expand,type:"switch",on:w,onSelect:s})}if(b("fullscreen")&&D("fullscreen")){let w=r==="fullscreen";U.push({id:"fullscreen",icon:w?o(ms,{}):o(fs,{}),label:w?g.exitFullscreen:g.fullscreen,type:"switch",on:w,onSelect:c})}h&&b("sound")&&U.push({id:"sound",icon:v?o(bs,{}):o(vs,{}),label:v?g.soundOff:g.soundOn,type:"switch",on:!v,onSelect:d}),b("theme")&&U.push({id:"theme",icon:eu(V),label:`${g.theme}: ${G[V]}`,onSelect:()=>m(Q_(V)),keepOpen:!0}),b("textSize")&&U.push({id:"textSize",icon:o(xs,{}),label:`${g.textSize}: ${K[ae]}`,onSelect:()=>f(Z_[ae]),keepOpen:!0}),b("language")&&n.availableLocales.length>1&&U.push({id:"language",icon:o(Ss,{}),label:g.language,segments:n.availableLocales.map(w=>({value:w,label:tu(w),lang:w})),value:n.locale,onSelectValue:_});let j=!!a&&xr(S,r,n.actions),be=h&&b("history");return o("div",{class:`${Go}-header-actions`,children:[be?o("button",{type:"button",class:`${Go}-icon-btn`,onClick:u,"aria-label":g.history,title:g.history,"data-testid":k.actionHistory,children:o(ys,{})}):null,U.length>0?o(Vs,{items:U,triggerLabel:g.moreActions}):null,j?o("button",{type:"button",class:`${Go}-icon-btn`,onClick:a,"aria-label":g.close,title:g.close,"data-testid":k.actionClose,children:o(ze,{})}):null]})}var nu=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ru=/^https?:\/\/[^\s.]+\.[^\s]+$/i,ou=/^[+]?[\d\s().-]{6,}$/;function Ot(e,t){return e.replace(/\{(\w+)\}/g,(n,r)=>String(t[r]??`{${r}}`))}function iu(e){return Array.isArray(e)?e.length:e&&e.trim()?1:0}function au(e,t,n){let r=e.required??!0,i=e.validation;if(e.type==="multiselect"){let l=iu(t);return r&&l===0?n.formRequired:l===0?void 0:i?.minSelections!=null&&l<i.minSelections?Ot(n.formChooseAtLeast,{min:i.minSelections}):i?.maxSelections!=null&&l>i.maxSelections?Ot(n.formChooseAtMost,{max:i.maxSelections}):void 0}let a=typeof t=="string"?t.trim():"";if(!a)return r?n.formRequired:void 0;switch(e.type){case"email":if(!nu.test(a))return n.formInvalidEmail;break;case"url":if(!ru.test(a))return n.formInvalidUrl;break;case"tel":if(!ou.test(a))return n.formInvalidTel;break;case"number":{let l=Number(a);if(!Number.isFinite(l))return n.formInvalidNumber;if(i?.min!=null&&l<i.min)return Ot(n.formNumberTooSmall,{min:i.min});if(i?.max!=null&&l>i.max)return Ot(n.formNumberTooLarge,{max:i.max});break}default:break}if(i?.minLength!=null&&a.length<i.minLength)return Ot(n.formTooShort,{min:i.minLength});if(i?.maxLength!=null&&a.length>i.maxLength)return Ot(n.formTooLong,{max:i.maxLength});if(i?.pattern)try{if(!new RegExp(i.pattern).test(a))return n.formPatternMismatch}catch{}}function Gs(e,t,n){let r={};for(let i of e){let a=au(i,t[i.name],n);a&&(r[i.name]=a)}return r}function Ks(e){let t={};for(let[n,r]of Object.entries(e)){let i=Array.isArray(r)?r.join(", "):r;i&&i.trim()&&(t[n]=i.trim())}return t}var le=x.cssPrefix,kr="__other__";function Cr({fields:e,strings:t,submitLabel:n,onSubmit:r,skipLabel:i,onSkip:a,footerHint:l,disabled:s,rootTestId:c,submitTestId:d,skipTestId:u}){let[_,m]=I(()=>du(e)),[f,g]=I({}),[S,h]=I({}),v=D=>{S[D]&&h(V=>({...V,[D]:""}))},C=(D,V)=>{m(G=>({...G,[D]:V})),v(D)},b=(D,V)=>{g(G=>({...G,[D]:V})),v(D)},E=D=>{if(D.preventDefault(),s)return;let V=_u(e,_,f),G=Gs(e,V,t);if(Object.keys(G).length>0){h(G);return}r(Ks(V))};return o("form",{class:`${le}-form`,onSubmit:E,"data-testid":c,noValidate:!0,children:[e.map(D=>o(su,{field:D,value:_[D.name],otherText:f[D.name]??"",error:S[D.name],disabled:s,strings:t,onChange:V=>C(D.name,V),onOtherChange:V=>b(D.name,V)},D.name)),o("div",{class:`${le}-form-actions`,children:[l?o("span",{class:`${le}-form-hint`,children:l}):null,i&&a?o("button",{type:"button",class:`${le}-form-skip`,onClick:a,disabled:s,"data-testid":u,children:i}):null,o("button",{type:"submit",class:`${le}-form-submit`,disabled:s,"data-testid":d,children:n})]})]})}function su({field:e,value:t,otherText:n,error:r,disabled:i,strings:a,onChange:l,onOtherChange:s}){let c=ve(k.formField,e.name),d=lu({field:e,value:t,otherText:n,disabled:i,strings:a,onChange:l,onOtherChange:s,fieldTid:c});return o("label",{class:`${le}-field`,"data-field":e.name,"data-invalid":r?"true":void 0,children:[o("span",{class:`${le}-field-label`,children:[e.label,e.required??!0?o("span",{class:`${le}-field-req`,"aria-hidden":"true",children:" *"}):null]}),d,e.validationHint&&!r?o("span",{class:`${le}-field-hint`,children:e.validationHint}):null,r?o("span",{class:`${le}-field-error`,role:"alert",children:r}):null]})}function lu(e){let{field:t,value:n,otherText:r,disabled:i,strings:a,onChange:l,onOtherChange:s,fieldTid:c}=e,d=typeof n=="string"?n:"";switch(t.type){case"textarea":return o("textarea",{class:`${le}-field-input`,rows:3,value:d,placeholder:t.placeholder,disabled:i,onInput:u=>l(u.target.value),"data-testid":c});case"select":return o("select",{class:`${le}-field-input`,value:d,disabled:i,onChange:u=>l(u.target.value),"data-testid":c,children:[o("option",{value:"",children:t.placeholder??"\u2014"}),(t.options??[]).map(u=>o("option",{value:u.value,children:u.label??u.value},u.value))]});case"radio":{let u=t.allowOther&&d===kr;return o("div",{class:`${le}-field-choices`,role:"radiogroup","data-testid":c,children:[(t.options??[]).map(_=>o("label",{class:`${le}-choice`,children:[o("input",{type:"radio",name:`${le}-${t.name}`,checked:d===_.value,disabled:i,onChange:()=>l(_.value)}),o("span",{children:_.label??_.value})]},_.value)),t.allowOther?o("label",{class:`${le}-choice`,children:[o("input",{type:"radio",name:`${le}-${t.name}`,checked:d===kr,disabled:i,onChange:()=>l(kr)}),o("span",{children:a.formOther})]}):null,u?o("input",{class:`${le}-field-input`,value:r,placeholder:t.placeholder??a.formOtherPlaceholder,disabled:i,onInput:_=>s(_.target.value)}):null]})}case"checkbox":return o("label",{class:`${le}-choice`,children:[o("input",{type:"checkbox",checked:d==="true",disabled:i,onChange:u=>l(u.target.checked?"true":""),"data-testid":c}),o("span",{children:t.placeholder??t.label})]});case"multiselect":{let u=Array.isArray(n)?n:[],_=(m,f)=>l(f?[...u,m]:u.filter(g=>g!==m));return o("div",{class:`${le}-field-choices`,"data-testid":c,children:[(t.options??[]).map(m=>o("label",{class:`${le}-choice`,children:[o("input",{type:"checkbox",checked:u.includes(m.value),disabled:i,onChange:f=>_(m.value,f.target.checked)}),o("span",{children:m.label??m.value})]},m.value)),t.allowOther||(t.options??[]).length===0?o("textarea",{class:`${le}-field-input`,rows:2,value:r,placeholder:t.placeholder??a.formOtherPlaceholder,disabled:i,onInput:m=>s(m.target.value)}):null]})}default:return o("input",{class:`${le}-field-input`,type:cu(t.type),value:d,placeholder:t.placeholder,disabled:i,onInput:u=>l(u.target.value),"data-testid":c})}}function cu(e){switch(e){case"number":case"email":case"tel":case"url":case"date":case"time":return e;default:return"text"}}function du(e){let t={};for(let n of e)n.defaultValue!=null&&(t[n.name]=n.type==="multiselect"?n.defaultValue.split(",").map(r=>r.trim()).filter(Boolean):n.defaultValue);return t}function _u(e,t,n){let r={...t};for(let i of e){let a=n[i.name]?.trim();if(i.type==="radio"&&i.allowOther&&t[i.name]===kr)r[i.name]=a??"";else if(i.type==="multiselect"&&a){let l=a.split(/[,\n;]+/).map(c=>c.trim()).filter(Boolean),s=Array.isArray(t[i.name])?t[i.name]:[];r[i.name]=[...s,...l]}}return r}var We=x.cssPrefix;function qs({form:e,strings:t,onSubmit:n,onSkip:r}){return o("div",{class:`${We}-form-gate`,"data-testid":k.formGate,children:[e.title?o("h3",{class:`${We}-form-gate-title`,children:e.title}):null,e.description?o("p",{class:`${We}-form-gate-desc`,children:e.description}):null,o(Cr,{fields:e.fields,strings:t,submitLabel:e.submitLabel??t.formSubmit,onSubmit:n,skipLabel:e.skippable?t.formSkip:void 0,onSkip:e.skippable?r:void 0,submitTestId:k.formSubmit,skipTestId:k.formSkip})]})}function js({marker:e,strings:t,onFill:n}){let r=e.outcome==="skipped",i=r?t.formSkipped:t.formSubmitted,a=e.title?o(re,{children:[o("span",{children:e.title}),o("span",{class:`${We}-sr-only`,children:i})]}):o("span",{children:i}),l=e.form?.reviewable??!1,s=!r&&l&&e.values&&Object.keys(e.values).length>0?e.values:null;if(s){let c=d=>e.form?.fields.find(u=>u.name===d)?.label??d;return o("details",{class:`${We}-form-done`,"data-outcome":e.outcome,"data-testid":k.formDone,children:[o("summary",{class:`${We}-form-done-summary`,"data-testid":k.formDoneToggle,children:[o(dn,{}),a,o(Nt,{})]}),o("dl",{class:`${We}-form-answers`,"data-testid":k.formAnswers,children:Object.entries(s).map(([d,u])=>o("div",{class:`${We}-form-answer`,children:[o("dt",{children:c(d)}),o("dd",{children:u})]},d))})]})}return o("div",{class:`${We}-form-done`,"data-outcome":e.outcome,"data-testid":k.formDone,role:"status",children:[r?o(Ps,{}):o(dn,{}),a,r&&e.form?.reopenable&&n?o("button",{type:"button",class:`${We}-form-done-fill`,"data-testid":k.formFill,onClick:n,children:t.formFillOut}):null]})}function Xs(e){if(!e)return!1;let t=e.startsWith("tool:")?e.slice(5):e;return t==="ask-user-input"||t==="ask_user_input"||t==="request-user-input"||t==="request_user_input"}var jo=1,Js=2,Qs=4,Zs=8,el=16;function uu(e){switch(e){case jo:return"href";case Js:return"src";case Qs:return"class";case Zs:return"checked";case el:return"start"}}var pu=e=>{switch(e){case 1:return 3;case 2:return 4;case 3:return 5;case 4:return 6;case 5:return 7;default:return 8}},fu=pu;var Ys=24;function Yo(e){let t=new Uint32Array(Ys);return t[0]=1,{renderer:e,text:"",pending:"",tokens:t,len:0,token:1,fence_end:0,blockquote_idx:0,hr_char:"",hr_chars:0,fence_start:0,spaces:new Uint8Array(Ys),indent:"",indent_len:0,table_state:0}}function tl(e){e.pending.length>0&&Pe(e,`
12
12
  `)}function ee(e){e.text.length!==0&&(console.assert(e.len>0,"Never adding text to root"),e.renderer.add_text(e.renderer.data,e.text),e.text="")}function pe(e){console.assert(e.len>0,"No nodes to end"),e.len-=1,e.token=e.tokens[e.len],e.renderer.end_token(e.renderer.data)}function te(e,t){(e.tokens[e.len]===24||e.tokens[e.len]===23)&&t!==25&&pe(e),e.len+=1,e.tokens[e.len]=t,e.token=t,e.renderer.add_token(e.renderer.data,t)}function mu(e,t,n){for(;n<=e.len;){if(e.tokens[n]===t)return n;n+=1}return-1}function mt(e,t){for(e.fence_start=0;e.len>t;)pe(e)}function Tr(e,t){let n=0;for(let r=0;r<=e.len&&(t-=e.spaces[r],!(t<0));r+=1)switch(e.tokens[r]){case 9:case 10:case 20:case 25:n=r;break}for(;e.len>n;)pe(e);return t}function Ko(e,t){let n=-1,r=-1;for(let i=e.blockquote_idx+1;i<=e.len;i+=1)if(e.tokens[i]===25){if(e.indent_len<e.spaces[i]){r=-1;break}r=i}else e.tokens[i]===t&&(n=i);return r===-1?n===-1?(mt(e,e.blockquote_idx),te(e,t),!0):(mt(e,n),!1):(mt(e,r),te(e,t),!0)}function qo(e,t){te(e,25),e.spaces[e.len]=e.indent_len+t,Je(e),e.token=103}function Je(e){e.indent="",e.indent_len=0,e.pending=""}function Xo(e){switch(e){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return!0;default:return!1}}function gu(e){switch(e){case 32:case 58:case 59:case 41:case 44:case 33:case 46:case 63:case 93:case 10:return!0;default:return!1}}function hu(e){return Xo(e)||gu(e)}function Pe(e,t){for(let n of t){if(e.token===101){switch(n){case" ":e.indent_len+=1;continue;case" ":e.indent_len+=4;continue}let i=Tr(e,e.indent_len);e.indent_len=0,e.token=e.tokens[e.len],i>0&&Pe(e," ".repeat(i))}let r=e.pending+n;switch(e.token){case 21:case 1:case 20:case 24:case 23:switch(console.assert(e.text.length===0,"Root should not have any text"),e.pending[0]){case void 0:e.pending=n;continue;case" ":console.assert(e.pending.length===1),e.pending=n,e.indent+=" ",e.indent_len+=1;continue;case" ":console.assert(e.pending.length===1),e.pending=n,e.indent+=" ",e.indent_len+=4;continue;case`
13
13
  `:if(console.assert(e.pending.length===1),e.tokens[e.len]===25&&e.token===21){pe(e),Je(e),e.pending=n;continue}mt(e,e.blockquote_idx),Je(e),e.blockquote_idx=0,e.fence_start=0,e.pending=n;continue;case"#":switch(n){case"#":if(e.pending.length<6){e.pending=r;continue}break;case" ":Tr(e,e.indent_len),te(e,fu(e.pending.length)),Je(e);continue}break;case">":{let a=mu(e,20,e.blockquote_idx+1);a===-1?(mt(e,e.blockquote_idx),e.blockquote_idx+=1,e.fence_start=0,te(e,20)):e.blockquote_idx=a,Je(e),e.pending=n;continue}case"-":case"*":case"_":if(e.hr_chars===0&&(console.assert(e.pending.length===1,"Pending should be one character"),e.hr_chars=1,e.hr_char=e.pending),e.hr_chars>0){switch(n){case e.hr_char:e.hr_chars+=1,e.pending=r;continue;case" ":e.pending=r;continue;case`
14
14
  `:if(e.hr_chars<3)break;Tr(e,e.indent_len),e.renderer.add_token(e.renderer.data,22),e.renderer.end_token(e.renderer.data),Je(e),e.hr_chars=0;continue}e.hr_chars=0}if(e.pending[0]!=="_"&&e.pending[1]===" "){Ko(e,23),qo(e,2),Pe(e,r.slice(2));continue}break;case"`":if(e.pending.length<3){if(n==="`"){e.pending=r,e.fence_start=r.length;continue}e.fence_start=0;break}switch(n){case"`":e.pending.length===e.fence_start?(e.pending=r,e.fence_start=r.length):(te(e,2),Je(e),e.fence_start=0,Pe(e,r));continue;case`
@@ -36,5 +36,5 @@ ${i}`:i;continue}r.startsWith("id:")&&(n=r.slice(3).trim())}if(!t||t==="[DONE]")
36
36
  `?"":n,e.pending="");continue;case"_":case"*":{if(e.token===19||e.token===30||e.token===31||e.token===14)break;let i=12,a=14,l=e.pending[0];if(l==="_"&&(i=13,a=15),e.pending.length===1){if(l===n){e.pending=r;continue}if(n!==" "&&n!==`
37
37
  `){ee(e),te(e,i),e.pending=n;continue}}else{if(l===n){ee(e),te(e,a),te(e,i),e.pending="";continue}if(n!==" "&&n!==`
38
38
  `){ee(e),te(e,a),e.pending=n;continue}}break}case"~":if(e.token!==19&&e.token!==16){if(e.pending==="~"){if(n==="~"){e.pending=r;continue}}else if(n!==" "&&n!==`
39
- `){ee(e),te(e,16),e.pending=n;continue}}break;case"$":if(e.token!==19&&e.token!==16&&e.pending==="$")if(n==="$"){e.token=105,e.pending=r;continue}else{if(hu(n.charCodeAt(0)))break;ee(e),te(e,31),e.pending=n;continue}break;case"[":if(e.token!==19&&e.token!==17&&e.token!==30&&e.token!==31&&n!=="]"){ee(e),te(e,17),e.pending=n;continue}break;case"!":if(e.token!==19&&n==="["){ee(e),te(e,19),e.pending="";continue}break;case" ":if(e.pending.length===1&&n===" ")continue;break}if(e.token!==19&&e.token!==17&&e.token!==30&&e.token!==31&&n==="h"&&(e.pending===" "||e.pending==="")){e.text+=e.pending,e.pending=n,e.token=102;continue}e.text+=e.pending,e.pending=n}ee(e)}function Jo(e){return{add_token:vu,end_token:bu,add_text:xu,set_attr:Pu,data:{nodes:[e,,,,,],index:0}}}function vu(e,t){let n=e.nodes[e.index],r;switch(t){case 1:return;case 20:r=document.createElement("blockquote");break;case 2:r=document.createElement("p");break;case 21:r=document.createElement("br");break;case 22:r=document.createElement("hr");break;case 3:r=document.createElement("h1");break;case 4:r=document.createElement("h2");break;case 5:r=document.createElement("h3");break;case 6:r=document.createElement("h4");break;case 7:r=document.createElement("h5");break;case 8:r=document.createElement("h6");break;case 12:case 13:r=document.createElement("em");break;case 14:case 15:r=document.createElement("strong");break;case 16:r=document.createElement("s");break;case 11:r=document.createElement("code");break;case 18:case 17:r=document.createElement("a");break;case 19:r=document.createElement("img");break;case 23:r=document.createElement("ul");break;case 24:r=document.createElement("ol");break;case 25:r=document.createElement("li");break;case 26:let i=r=document.createElement("input");i.type="checkbox",i.disabled=!0;break;case 9:case 10:n=n.appendChild(document.createElement("pre")),r=document.createElement("code");break;case 27:r=document.createElement("table");break;case 28:switch(n.children.length){case 0:n=n.appendChild(document.createElement("thead"));break;case 1:n=n.appendChild(document.createElement("tbody"));break;default:n=n.children[1]}r=document.createElement("tr");break;case 29:r=document.createElement(n.parentElement?.tagName==="THEAD"?"th":"td");break;case 30:r=document.createElement("equation-block");break;case 31:r=document.createElement("equation-inline");break}e.nodes[++e.index]=n.appendChild(r)}function bu(e){e.index-=1}function xu(e,t){e.nodes[e.index].appendChild(document.createTextNode(t))}function Pu(e,t,n){e.nodes[e.index].setAttribute(uu(t),n)}function Er({textSig:e,doneSig:t}){let n=M(null);return nn(()=>{let r=n.current;if(!r)return;r.classList.add(`${x.cssPrefix}-md`);let i=Jo(r),a=Yo(i),l=0,s=Ye(()=>{let u=e.value,_=t.value;u.length<l&&(r.replaceChildren(),i=Jo(r),a=Yo(i),l=0);let m=u.slice(l);m&&Pe(a,m),l=u.length,_&&tl(a)}),c=new MutationObserver(u=>{for(let _ of u)for(let m of _.addedNodes){if(!(m instanceof HTMLElement))continue;let f=m.matches?.("a")?[m]:[...m.querySelectorAll?.("a")??[]];for(let g of f)nl(g)}});c.observe(r,{childList:!0,subtree:!0});for(let u of r.querySelectorAll("a"))nl(u);let d=u=>{let _=u.target?.closest?.("a");if(!_||!(_ instanceof HTMLAnchorElement))return;let m=_.getAttribute("href")??"";!m||m.startsWith("#")||(u.preventDefault(),window.open(m,"_blank","noopener,noreferrer"))};return r.addEventListener("click",d),()=>{s(),c.disconnect(),r.removeEventListener("click",d)}},[e,t]),o("div",{ref:n})}function rl({text:e}){let t=we(()=>O(e),[e]),n=we(()=>O(!0),[]);return o(Er,{textSig:t,doneSig:n})}function nl(e){let t=e.getAttribute("href")??"";if(!t||t.startsWith("#"))return;e.target!=="_blank"&&(e.target="_blank");let n=new Set((e.rel||"").split(/\s+/).filter(Boolean));n.add("noopener"),n.add("noreferrer"),e.rel=[...n].join(" ")}var $t=x.cssPrefix;function ol({part:e,strings:t}){let n=e.title||e.filename||e.url||t.sources;return e.url?o("a",{class:`${$t}-source`,href:e.url,target:"_blank",rel:"noreferrer noopener","data-testid":k.source,children:[o("span",{class:`${$t}-source-icon`,"aria-hidden":"true",children:"\u{1F517}"}),o("span",{class:`${$t}-source-label`,children:n})]}):o("span",{class:`${$t}-source`,"data-testid":k.source,children:[o("span",{class:`${$t}-source-icon`,"aria-hidden":"true",children:"\u{1F4C4}"}),o("span",{class:`${$t}-source-label`,children:n})]})}var mn=x.cssPrefix;function Ir(e){return e.startsWith("tool:")||e.startsWith("tool-")?e.slice(5):e}function Su(e,t){return e==="output-error"?"error":e==="output-denied"||t?.approved===!1?"denied":e==="output-available"?"completed":t?.approved===!0?"approved":"pending"}var wu={completed:"\u2713",approved:"\u2713",denied:"\u2715",error:"\u26A0",pending:"\u2022"};function Rr({state:e,approval:t,strings:n}){let r=Su(e,t),i=r==="completed"?n.statusCompleted:r==="approved"?n.approved:r==="denied"?n.statusDenied:r==="error"?n.statusError:"";return i?o("span",{class:`${mn}-toolui-status`,"data-status":r,children:[o("span",{class:`${mn}-toolui-status-icon`,"aria-hidden":"true",children:wu[r]}),i]}):null}function nt({label:e,value:t,error:n}){let r=n?String(t??""):Ar(Qo(t));return r?o("div",{class:`${mn}-toolui-section`,children:[o("span",{class:`${mn}-toolui-label`,children:e}),o("pre",{class:`${mn}-toolui-code`,"data-error":n?"true":void 0,children:r})]}):null}function Qo(e){if(e&&typeof e=="object"){let t=e;if(t.storage==="tool-result-ref"&&"summary"in t)return t.summary}return e}function Ar(e){if(e==null)return"";try{let t=typeof e=="string"?e:JSON.stringify(e,null,2);return!t||t==="{}"||t==="[]"||t==='""'?"":t.length>800?`${t.slice(0,800)}\u2026`:t}catch{return""}}var Ve=x.cssPrefix;function il({part:e,strings:t,active:n,onDecision:r}){let i=Y(()=>e.approvalSig.value),a=Y(()=>e.stateSig.value),l=Y(()=>e.inputSig.value),s=Y(()=>e.outputSig.value),c=Y(()=>e.errorSig.value),d=dt(""),u=i.value?.approved!==void 0||a.value!=="approval-requested";return o("div",{class:`${Ve}-toolui`,"data-testid":u?k.toolDecision:k.toolApproval,children:[o("div",{class:`${Ve}-toolui-head`,children:[o("strong",{class:`${Ve}-toolui-title`,children:Ir(e.toolName)}),u?o(Rr,{state:a.value,approval:i.value,strings:t}):o("span",{class:`${Ve}-toolui-badge ${Ve}-toolui-badge-accent`,children:t.approvalRequired})]}),o(nt,{label:t.toolParameters,value:l.value}),s.value!==void 0?o(nt,{label:t.toolResult,value:s.value}):null,c.value?o(nt,{label:t.statusError,value:c.value,error:!0}):null,u?null:n?o(re,{children:[o("input",{class:`${Ve}-field-input`,value:d.value,placeholder:t.approvalReason,onInput:_=>{d.value=_.target.value}}),o("div",{class:`${Ve}-form-actions`,children:[o("button",{type:"button",class:`${Ve}-form-skip`,onClick:()=>r(e.toolCallId,!1,d.value.trim()||void 0),"data-testid":k.toolReject,children:t.reject}),o("button",{type:"button",class:`${Ve}-form-submit`,onClick:()=>r(e.toolCallId,!0,d.value.trim()||void 0),"data-testid":k.toolApprove,children:t.approve})]})]}):o("p",{class:`${Ve}-toolui-note`,children:t.stepNoLongerActive})]})}function sl(e){let t=e&&typeof e=="object"?e:{},n=t.responseType;return{title:gn(t.title),question:gn(t.question)??"Please provide the missing information.",description:gn(t.description),placeholder:gn(t.placeholder),responseType:n==="single-choice"||n==="multi-choice"||n==="confirmation"||n==="free-text"?n:"free-text",choices:Array.isArray(t.choices)?t.choices:void 0,allowOther:typeof t.allowOther=="boolean"?t.allowOther:void 0,required:typeof t.required=="boolean"?t.required:!0,defaultValues:Array.isArray(t.defaultValues)?t.defaultValues.filter(r=>typeof r=="string"):void 0,minSelections:al(t.minSelections),maxSelections:al(t.maxSelections),validationHint:gn(t.validationHint)}}function ll(e){if(e.responseType==="confirmation")return[];let t=(e.choices??[]).map(ku).filter(i=>i!==null),n="textarea";e.responseType==="single-choice"&&t.length>0?n="radio":e.responseType==="multi-choice"&&(n="multiselect");let r=n==="multiselect"?e.defaultValues?.join(", "):e.defaultValues?.[0];return[{name:"answer",label:e.question,type:n,placeholder:e.placeholder,required:e.required??!0,defaultValue:r,options:t.length>0?t:void 0,allowOther:e.allowOther,validationHint:e.validationHint,validation:n==="multiselect"?{minSelections:e.minSelections,maxSelections:e.maxSelections}:void 0}]}function ku(e){return typeof e=="string"?e?{value:e,label:e}:null:e&&typeof e.value=="string"&&e.value?{value:e.value,label:e.label??e.value,description:e.description}:null}function gn(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function al(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}var ge=x.cssPrefix;function Cu(e,t){switch(e.responseType){case"single-choice":return t.respSingleChoice;case"multi-choice":return t.respMultiChoice;case"confirmation":return t.respConfirmation;default:return t.respFreeText}}function cl({part:e,strings:t,active:n,onSubmit:r,onDecision:i}){let a=Y(()=>e.stateSig.value),l=Y(()=>e.approvalSig.value),s=Y(()=>sl(e.inputSig.value)),c=a.value==="output-available"||a.value==="output-error"||a.value==="output-denied"||a.value==="approval-responded"||l.value?.approved!==void 0,d=l.value!==void 0,u=(f,g)=>{d?i(e.toolCallId,g,f):s.value.responseType==="confirmation"?r(e.toolCallId,{confirmed:g}):r(e.toolCallId,g?{answer:f}:{})},_=s.value;if(c)return o(Eu,{part:e,strings:t,req:_});let m=!n;return o("div",{class:`${ge}-toolui${m?` ${ge}-toolui-stale`:""}`,"data-testid":k.toolAskInput,children:[o("div",{class:`${ge}-toolui-head`,children:[o("span",{class:`${ge}-toolui-badge ${ge}-toolui-badge-accent`,children:t.inputRequired}),o("span",{class:`${ge}-toolui-badge`,children:Cu(_,t)})]}),_.description?o("div",{class:`${ge}-toolui-desc`,children:_.description}):null,o(Zo,{label:t.inputQuestion,text:_.question}),m?o("p",{class:`${ge}-toolui-note`,children:t.stepNoLongerActive}):o(Tu,{req:_,strings:t,resolve:u})]})}function Tu({req:e,strings:t,resolve:n}){if(e.responseType==="confirmation")return o("div",{class:`${ge}-form-actions`,children:[o("span",{class:`${ge}-form-hint`,children:t.inputSubmitHint}),o("button",{type:"button",class:`${ge}-form-skip`,onClick:()=>n(void 0,!1),"data-testid":k.toolInputSkip,children:t.reject}),o("button",{type:"button",class:`${ge}-form-submit`,onClick:()=>n(void 0,!0),"data-testid":k.toolInputSubmit,children:t.approve})]});let r=ll(e).map(i=>(i.label=t.inputYourAnswer,i));return o(Cr,{fields:r,strings:t,submitLabel:t.inputSubmit,footerHint:t.inputSubmitHint,onSubmit:i=>n(i.answer??Object.values(i).join(", "),!0),skipLabel:e.required===!1?t.inputSkip:void 0,onSkip:e.required===!1?()=>n(void 0,!1):void 0,submitTestId:k.toolInputSubmit,skipTestId:k.toolInputSkip})}function Zo({label:e,text:t}){return o("div",{class:`${ge}-toolui-section`,children:[o("span",{class:`${ge}-toolui-label`,children:e}),o("p",{class:`${ge}-toolui-text`,children:t})]})}function Eu({part:e,strings:t,req:n}){let r=Y(()=>e.outputSig.value),i=Y(()=>e.approvalSig.value),a=i.value?.approved===!1,l=i.value?.approved!==void 0?i.value.reason??"":Iu(r.value);return o("div",{class:`${ge}-toolui`,"data-testid":k.toolDecision,children:[o("div",{class:`${ge}-toolui-head`,children:[o("span",{class:`${ge}-toolui-badge ${ge}-toolui-badge-accent`,children:t.inputBadge}),o("span",{class:`${ge}-toolui-badge`,children:a?t.inputSkipped:t.inputAnswered})]}),n.description?o("div",{class:`${ge}-toolui-desc`,children:n.description}):null,o(Zo,{label:t.inputQuestion,text:n.question}),!a&&l?o(Zo,{label:t.inputResponse,text:l}):null]})}function Iu(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="object"){let t=e;return"confirmed"in t?t.confirmed?"Yes":"No":typeof t.responseText=="string"&&t.responseText?t.responseText:Object.values(t).filter(n=>typeof n=="string"||typeof n=="number").join(", ")}return String(e)}var Lr=x.cssPrefix;function dl({part:e,strings:t}){let n=Y(()=>e.inputSig.value),r=Y(()=>e.outputSig.value),i=Y(()=>e.errorSig.value),a=Y(()=>e.stateSig.value),l=Y(()=>e.approvalSig.value);return Y(()=>!!Ar(n.value)||!!i.value||!!Ar(Qo(r.value))).value?o("details",{class:`${Lr}-toolui ${Lr}-toolui-collapsible`,"data-testid":k.toolCall,children:[o("summary",{class:`${Lr}-toolui-head`,children:[o("strong",{class:`${Lr}-toolui-title`,children:Ir(e.toolName)}),o(Rr,{state:a.value,approval:l.value,strings:t})]}),o(nt,{label:t.toolParameters,value:n.value}),r.value!==void 0?o(nt,{label:t.toolResult,value:r.value}):null,i.value?o(nt,{label:t.statusError,value:i.value,error:!0}):null]}):null}var Le=x.cssPrefix;function _l({message:e,strings:t,responseMode:n,showReasoning:r,showToolCalls:i,showSources:a,interactive:l=!1,tool:s}){let d=Y(()=>e.partsSig.value).value,u=Y(()=>e.partsSig.value.some(v=>v.kind==="text"&&v.textSig.value.length>0)),_=Y(()=>r&&e.partsSig.value.some(v=>v.kind==="reasoning")),m=e.role==="assistant"&&e.status==="streaming",f=n==="buffered"&&m,g=m&&!u.value,S=m&&!f&&!(_.value&&g),h=Ru(e.createdAt);return o("div",{class:`${Le}-bubble-row`,"data-role":e.role,"data-testid":ve(k.messageBubble,e.id),children:o("div",{class:`${Le}-bubble-col`,children:[o("div",{class:`${Le}-bubble`,children:[f?o(Ou,{label:t.loading}):d.map(v=>o(Au,{part:v,active:g,strings:t,showReasoning:r,showToolCalls:i,showSources:a,interactive:l,tool:s},Nu(v))),S&&o(Du,{}),e.status==="error"&&e.errorText?o("div",{class:`${Le}-error`,role:"alert",children:o("span",{children:e.errorText})}):null]}),h?o("time",{class:`${Le}-bubble-time`,dateTime:h.iso,title:h.full,children:h.short}):null]})})}function Ru(e){if(typeof e!="number"||!Number.isFinite(e))return null;try{let t=new Date(e);return{short:t.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),full:t.toLocaleString(void 0,{dateStyle:"full",timeStyle:"short"}),iso:t.toISOString()}}catch{return null}}function Au({part:e,active:t,strings:n,showReasoning:r,showToolCalls:i,showSources:a,interactive:l,tool:s}){switch(e.kind){case"step-start":return null;case"text":return o(Er,{textSig:e.textSig,doneSig:e.doneSig});case"reasoning":return r?o(Mu,{part:e,active:t,strings:n}):null;case"tool":return o(Lu,{part:e,strings:n,showToolCalls:i,interactive:l,tool:s});case"file":return e.mediaType.startsWith("image/")?o("img",{src:e.url,alt:"",loading:"lazy"}):o("a",{href:e.url,target:"_blank",rel:"noreferrer noopener",children:e.url});case"source":return a?o(ol,{part:e,strings:n}):null}}function Lu({part:e,strings:t,showToolCalls:n,interactive:r,tool:i}){let a=Y(()=>e.approvalSig.value!==void 0);if(i?.humanInLoop){if(Xs(e.toolName))return o(cl,{part:e,strings:t,active:r,onSubmit:i.onResult,onDecision:i.onDecision});if(a.value)return o(il,{part:e,strings:t,active:r,onDecision:i.onDecision})}return n?o(dl,{part:e,strings:t}):null}function Mu({part:e,active:t,strings:n}){return o("details",{class:`${Le}-reasoning`,open:t,"data-active":t?"true":void 0,children:[o("summary",{class:`${Le}-reasoning-summary`,children:o("span",{class:`${Le}-reasoning-label`,children:t?n.thinking:n.thoughts})}),o("div",{class:`${Le}-reasoning-body`,children:o(Er,{textSig:e.textSig,doneSig:e.doneSig})})]})}function Nu(e){switch(e.kind){case"text":case"reasoning":case"step-start":return`${e.kind}:${e.id}`;case"tool":return`tool:${e.toolCallId}`;case"file":return`file:${e.url}`;case"source":return`source:${e.sourceId}`}}function Du(){return o("span",{class:`${Le}-typing`,"aria-hidden":"true",children:[o("span",{}),o("span",{}),o("span",{})]})}function Ou({label:e}){return o("span",{class:`${Le}-loading`,role:"status",children:[o("span",{class:`${Le}-loading-spinner`,"aria-hidden":"true"}),o("span",{class:`${Le}-loading-label`,children:e})]})}var Ht=x.cssPrefix,ei=120,$u=350,Hu=1200;function ul({messagesSig:e,strings:t,responseMode:n,showReasoning:r,showToolCalls:i,showSources:a,loading:l,idle:s,tool:c,form:d,formMarkers:u,onFillForm:_}){let m=M(null),f=Y(()=>e.value),[g,S]=I(!1),[h,v]=I(!1),C=M(!1),b=M(!1),E=M(!1),D=M(0),V=()=>E.current||performance.now()-D.current<$u,G=M(0),ae=y=>{G.current=performance.now(),y.scrollTop=y.scrollHeight},K=f.value[0]?.id;nn(()=>{let y=m.current;if(!y||f.value.length===0||(C.current=!0,!f.value.some(it=>it.role==="user")))return;let z=()=>ae(y);z();let xe=new ResizeObserver(z);xe.observe(y);let Te=new MutationObserver(z);Te.observe(y,{childList:!0,subtree:!0,characterData:!0});let ye=setTimeout(()=>{xe.disconnect(),Te.disconnect()},300);return()=>{xe.disconnect(),Te.disconnect(),clearTimeout(ye)}},[K]);let U=M(0);T(()=>{let y=m.current,z=f.value,xe=U.current;if(U.current=z.length,!y||!C.current)return;if(z.slice(xe).some(ye=>ye.role==="user")){b.current=!1,ae(y);return}if(!z.some(ye=>ye.role==="user")||b.current||V())return;y.scrollHeight-y.scrollTop-y.clientHeight<ei&&ae(y)},[f.value.length]),T(()=>{let y=m.current;if(!y)return;let z=f.value.at(-1);if(!z||z.status!=="streaming"&&!f.value.some(ye=>ye.role==="user"))return;let xe=()=>{if(b.current||V())return;y.scrollHeight-y.scrollTop-y.clientHeight<ei*2&&ae(y)};if(z.status!=="streaming"){let ye=requestAnimationFrame(xe);return()=>cancelAnimationFrame(ye)}xe();let Te=new MutationObserver(xe);return Te.observe(y,{childList:!0,subtree:!0,characterData:!0}),()=>Te.disconnect()},[f.value]);let j=d?.form.id;nn(()=>{let y=m.current;!y||!j||b.current||f.value.some(z=>z.role==="user")&&ae(y)},[j]),T(()=>{let y=m.current;if(!y)return;let z=()=>S(y.scrollHeight-y.scrollTop-y.clientHeight>ei*2),xe,Te=()=>{z(),performance.now()-G.current>150&&(b.current=y.scrollHeight-y.scrollTop-y.clientHeight>8),v(!0),clearTimeout(xe),xe=setTimeout(()=>v(!1),Hu)},ye=()=>{b.current=!0},it=Ge=>{Ge.deltaY<0&&ye()},ht=0,Ft=Ge=>{ht=Ge.touches[0]?.clientY??0,E.current=!0},vt=Ge=>{(Ge.touches[0]?.clientY??0)>ht+4&&ye()},He=()=>{E.current=!1,D.current=performance.now()},zt=()=>{E.current=!0};return y.addEventListener("scroll",Te,{passive:!0}),y.addEventListener("wheel",it,{passive:!0}),y.addEventListener("touchstart",Ft,{passive:!0}),y.addEventListener("touchmove",vt,{passive:!0}),y.addEventListener("touchend",He,{passive:!0}),y.addEventListener("touchcancel",He,{passive:!0}),y.addEventListener("pointerdown",zt,{passive:!0}),window.addEventListener("pointerup",He,{passive:!0}),window.addEventListener("pointercancel",He,{passive:!0}),z(),()=>{y.removeEventListener("scroll",Te),y.removeEventListener("wheel",it),y.removeEventListener("touchstart",Ft),y.removeEventListener("touchmove",vt),y.removeEventListener("touchend",He),y.removeEventListener("touchcancel",He),y.removeEventListener("pointerdown",zt),window.removeEventListener("pointerup",He),window.removeEventListener("pointercancel",He),clearTimeout(xe)}},[]);let be=()=>{let y=m.current;y&&(b.current=!1,ae(y))},w=[],q="",ne=f.value.at(-1)?.id,ce=[...u??[]].toSorted((y,z)=>(y.createdAt??1/0)-(z.createdAt??1/0)),de=y=>o(js,{marker:y,strings:t,onFill:!d&&_?()=>_(y.formId):void 0},y.key),Me=y=>{for(let z=ce[0];z?.createdAt!==void 0&&!(y!==void 0&&z.createdAt>y);z=ce[0])ce.shift(),w.push(de(z))};for(let y of f.value){Me(y.createdAt);let z=Bu(y.createdAt);z&&z!==q&&(w.push(o("div",{class:`${Ht}-date-divider`,children:o("span",{class:`${Ht}-date-pill`,title:Fu(y.createdAt),children:zu(y.createdAt,t)})},`day:${z}`)),q=z),w.push(o(_l,{message:y,strings:t,responseMode:n,showReasoning:r,showToolCalls:i,showSources:a,interactive:!!s&&y.id===ne,tool:c},y.id))}for(let y of ce)w.push(de(y));return o("div",{class:`${Ht}-list-wrap`,children:[o("div",{ref:m,class:`${Ht}-list`,role:"log","aria-live":"polite","aria-relevant":"additions text","data-scrolling":h?"true":void 0,children:[l&&f.value.length===0?o("div",{class:`${Ht}-list-loading`,role:"status",children:t.conversationLoading}):null,w,d?o(qs,{form:d.form,strings:t,onSubmit:d.onSubmit,onSkip:d.onSkip}):null]}),g?o("button",{type:"button",class:`${Ht}-jump`,onClick:be,"aria-label":t.scrollToBottom,title:t.scrollToBottom,"data-testid":k.scrollToBottom,children:o(ks,{})}):null]})}function Bu(e){if(typeof e!="number"||!Number.isFinite(e))return"";let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function Fu(e){if(typeof e!="number"||!Number.isFinite(e))return"";try{return new Date(e).toLocaleDateString(void 0,{dateStyle:"full"})}catch{return""}}function zu(e,t){let n=new Date(e),r=a=>new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),i=Math.round((r(new Date)-r(n))/864e5);return i<=0?t.dateToday:i===1?t.dateYesterday:i<7?n.toLocaleDateString(void 0,{weekday:"long"}):n.toLocaleDateString(void 0,{month:"long",day:"numeric",year:"numeric"})}var Uu=["today","yesterday","lastWeek","older"];function Wu(e,t){let n=Date.parse(t);if(!Number.isFinite(n))return"older";let r=Math.floor((pl(e)-pl(n))/(1440*60*1e3));return r<=0?"today":r===1?"yesterday":r<7?"lastWeek":"older"}function fl(e,t){let n=new Map;for(let r of t){let i=Wu(e,r.lastMessageAt),a=n.get(i);a?a.push(r):n.set(i,[r])}return Uu.filter(r=>n.has(r)).map(r=>({bucket:r,conversations:n.get(r)}))}function pl(e){let t=new Date(e);return t.setUTCHours(0,0,0,0),t.getTime()}var Vu=B.scope("history"),Gu=3,Ku=6,qu={today:"dateToday",yesterday:"dateYesterday",lastWeek:"dateLastWeek",older:"dateOlder"};function ju(e,t,n){let r=Date.parse(e);return Number.isFinite(r)?new Date(r).toDateString()===new Date(t).toDateString()?new Intl.DateTimeFormat(n,{hour:"numeric",minute:"2-digit"}).format(r):t-r<10080*60*1e3?new Intl.DateTimeFormat(n,{weekday:"short"}).format(r):new Intl.DateTimeFormat(n,{month:"short",day:"numeric"}).format(r):""}function Mr({transport:e,strings:t,locale:n,persistence:r,visitorId:i,onSelect:a,onNewConversation:l}){let s=x.cssPrefix,c=e.peekConversations({visitorId:i}),[d,u]=I(c?"loaded":"loading"),[_,m]=I(c?.conversations??[]);T(()=>{let h=!1;return e.listConversations({visitorId:i}).then(v=>{if(h)return;let C=v.conversations??[];m(C),u("loaded"),r.saveHistoryCount(C.length)}).catch(v=>{h||(Vu.warn("listConversations failed",{err:v}),u("error"))}),()=>{h=!0}},[e,i,r]);let f=l?o("div",{class:`${s}-history-footer`,children:o("button",{type:"button",class:`${s}-history-new`,onClick:l,"data-testid":k.sidebarNewConversation,children:[o(is,{}),t.newConversation]})}):null;if(d==="loading"){let h=Math.min(r.loadHistoryCount()??Gu,Ku);return o(re,{children:[o("div",{class:`${s}-history`,"aria-busy":"true","aria-label":t.historyLoading,children:o("div",{class:`${s}-history-group`,"aria-hidden":"true",children:[o("div",{class:`${s}-history-heading`,children:o("span",{class:`${s}-skeleton ${s}-skeleton-heading`})}),o("div",{class:`${s}-history-card`,children:Array.from({length:Math.max(1,h)},(v,C)=>o("div",{class:`${s}-history-item ${s}-history-item-skeleton`,children:[o("span",{class:`${s}-history-avatar ${s}-skeleton`}),o("span",{class:`${s}-history-body`,children:[o("span",{class:`${s}-history-row`,children:[o("span",{class:`${s}-history-title`,children:o("span",{class:`${s}-skeleton ${s}-skeleton-title`})}),o("span",{class:`${s}-history-time`,children:o("span",{class:`${s}-skeleton ${s}-skeleton-time`})})]}),o("span",{class:`${s}-history-row`,children:o("span",{class:`${s}-history-preview`,children:o("span",{class:`${s}-skeleton ${s}-skeleton-preview`})})})]})]},C))})]})}),f]})}if(d==="error"||_.length===0)return o(re,{children:[o("div",{class:`${s}-history-empty`,children:t.historyEmpty}),f]});let g=Date.now(),S=fl(g,_);return o(re,{children:[o("div",{class:`${s}-history`,role:"list",children:S.map(h=>o("div",{class:`${s}-history-group`,children:[o("div",{class:`${s}-history-heading`,children:t[qu[h.bucket]]}),o("div",{class:`${s}-history-card`,children:h.conversations.map(v=>o("button",{type:"button",role:"listitem",class:`${s}-history-item`,onClick:()=>a(v),"data-closed":v.canContinue?void 0:"true","data-unread":(v.unreadCount??0)>0?"true":void 0,"data-testid":ve(k.historyItem,v.conversationId),children:[o("span",{class:`${s}-history-avatar`,"aria-hidden":"true",children:o(Ho,{})}),o("span",{class:`${s}-history-body`,children:[o("span",{class:`${s}-history-row`,children:[o("span",{class:`${s}-history-title`,children:v.title}),o("span",{class:`${s}-history-time`,children:ju(v.lastMessageAt,g,n)})]}),o("span",{class:`${s}-history-row`,children:[o("span",{class:`${s}-history-preview`,children:v.preview??(v.canContinue?t.historyContinue:t.conversationClosed)}),(v.unreadCount??0)>0?o("span",{class:`${s}-history-dot`}):null]})]})]},v.conversationId))})]},h.bucket))}),f]})}var ml=x.cssPrefix;function gl({suggestions:e,onPick:t}){return e.length===0?null:o("div",{class:`${ml}-suggestions`,role:"group","aria-label":"Suggested replies",children:e.map((n,r)=>o("button",{type:"button",class:`${ml}-suggestion`,onClick:()=>t(n),"data-testid":ve(k.suggestion,r),children:n.label},n.id))})}var Ce=x.cssPrefix;function hl(e){let{options:t,onClose:n}=e,r=t.strings,i=M(null);T(()=>{let c=i.current;if(!c)return;let d=Pr(c),u=_=>{_.key==="Escape"&&n?.()};return c.addEventListener("keydown",u),()=>{d(),c.removeEventListener("keydown",u)}},[n]);let a=M(null),l=H(c=>{a.current?.attachFromDrop(c)},[]),{visible:s}=wr({containerRef:i,onDrop:l});return br(i.current,t.mode==="modal"),o("div",{ref:i,class:`${Ce}-panel`,role:"dialog","aria-modal":"false","aria-label":r.panelTitle,style:{position:"relative"},"data-testid":k.panel,children:[o(ti,{...e,containerEl:i.current,dragOver:s,composerAttachApiRef:a}),o(ni,{poweredBy:e.options.poweredBy})]})}function ti(e){let{options:t,transport:n,feedback:r,bus:i,persistence:a,panelSize:l,view:s,canSend:c,isStreaming:d,loadingMessages:u,messagesSig:_,agent:m,suggestions:f,initialWidgetSize:g,visitorId:S,onClose:h,onBack:v,onClear:C,onToggleHistory:b,onSelectHistoryConversation:E,onNewConversation:D,onWidgetSizeChange:V,onSend:G,onStop:ae,onSuggestion:K,activeForm:U,formMarkers:j,onFormSubmit:be,onFormSkip:w,onFormFill:q,tool:ne,containerEl:ce,dragOver:de,composerAttachApiRef:Me}=e,y=t.strings,z;return U?z=null:c?z=o(re,{children:[o(gl,{suggestions:f,onPick:K}),o(zs,{options:t,transport:n,feedback:r,bus:i,isStreaming:d,onSend:G,onStop:ae,attachApiRef:Me})]}):z=o(Yu,{label:y.conversationClosed,ctaLabel:y.startNewConversation,onNewConversation:C}),o(re,{children:[s==="history"?o(Xu,{strings:y,onBack:b,onClose:h,showClose:xr(t.mode,l,t.actions)}):o("header",{class:`${Ce}-header`,"data-testid":k.panelHeader,children:[v?o("button",{type:"button",class:`${Ce}-icon-btn`,onClick:v,"aria-label":y.moduleBack,title:y.moduleBack,children:o(_n,{})}):null,m?o(Hs,{agent:m,strings:y}):o("h1",{children:y.panelTitle}),o(Ue,{panelProps:e,variant:"chat"})]}),s==="history"?o(Mr,{transport:n,strings:y,locale:t.locale,persistence:a,visitorId:S,onSelect:xe=>E(xe.conversationId),onNewConversation:D}):o(re,{children:[o(Us,{visible:de,strings:y}),o(ul,{messagesSig:_,strings:y,responseMode:t.responseMode,showReasoning:t.showReasoning,showToolCalls:t.showToolCalls,showSources:t.showSources,loading:u,idle:!d,tool:ne,form:U?{form:U,onSubmit:be,onSkip:w}:null,formMarkers:j,onFillForm:q}),z,o(Ju,{disclaimer:t.composerDisclaimer})]}),t.size.resize?.enabled?o(vr,{panelEl:ce,resize:t.size.resize,position:t.position,initialSize:g,onSizeChange:V,strings:y}):null]})}function Xu({strings:e,onBack:t,onClose:n,showClose:r}){return o("header",{class:`${Ce}-header`,children:[o("button",{type:"button",class:`${Ce}-icon-btn`,onClick:t,"aria-label":e.historyBack,title:e.historyBack,children:o(_n,{})}),o("h1",{children:e.historyTitle}),r?o("button",{type:"button",class:`${Ce}-icon-btn`,onClick:n,"aria-label":e.close,title:e.close,children:o(ze,{})}):null]})}function Yu({label:e,ctaLabel:t,onNewConversation:n}){return o("div",{class:`${Ce}-readonly-banner`,role:"note",children:[o("span",{class:`${Ce}-readonly-label`,children:e}),o("button",{type:"button",class:`${Ce}-readonly-cta`,onClick:n,children:t})]})}function Ju({disclaimer:e}){return e?o("div",{class:`${Ce}-composer-footer`,children:o("div",{class:`${Ce}-disclaimer`,children:e})}):null}function ni({poweredBy:e}){return e?o("div",{class:`${Ce}-poweredby-bar`,children:o(Qu,{logoUrl:e.logoUrl,text:e.text,href:e.href})}):null}function Qu({logoUrl:e,text:t,href:n}){let r=o(re,{children:[e?o("img",{class:`${Ce}-poweredby-logo`,src:e,alt:"",loading:"lazy"}):null,t?o("span",{children:t}):null]});return n?o("a",{class:`${Ce}-poweredby`,href:n,target:"_blank",rel:"noopener noreferrer",children:r}):o("span",{class:`${Ce}-poweredby`,children:r})}function vl(e){let t=M(e);t.current=e;let n=M(null);return n.current??(n.current=Zu(t)),n.current}function Zu(e){let t=O(null),n=new Set,r=c=>`${e.current.conversationId()??""}:${c}`,i=c=>c.frequency==="always"?!1:c.frequency==="conversation"?n.has(r(c.id)):c.id in e.current.persistence.loadFormsDone(),a=(c,d)=>{if(t.value)return;let u=e.current;if(c==="manual"){let _=u.forms.list.find(m=>m.id===d);_&&(t.value={form:_,trigger:"manual"});return}for(let _ of u.forms.byTrigger[c]??[]){let m=_.triggers.find(f=>f.kind===c);if(!(!m||!ep(m,u)||i(_)||!tp(_,u))){t.value={form:_,trigger:c};return}}},l=(c,d)=>{let u=t.value;if(!u)return;t.value=null;let{form:_,trigger:m}=u;_.frequency==="conversation"?n.add(r(_.id)):_.frequency!=="always"&&e.current.persistence.saveFormDone(_.id),e.current.onComplete(_,m,c,d)};return{activeForm:t,fire:a,refresh:()=>{let c=t.value;if(!c)return;let d=e.current.forms.list.find(u=>u.id===c.form.id);d&&d!==c.form&&(t.value={form:d,trigger:c.trigger})},complete:c=>l(c,!1),skip:()=>l({},!0)}}function ep(e,t){return e.kind==="after-messages"?t.messageCount()>=Number(e.param??0):e.kind==="page-area"?t.pageArea()===e.param:!0}function tp(e,t){let n=e.when;if(!n)return!0;if(n.missingContext?.length){let i=t.userContext()??{};if(n.missingContext.some(a=>i[a]!==void 0&&i[a]!==""))return!1}if(n.pageArea&&!(Array.isArray(n.pageArea)?n.pageArea:[n.pageArea]).includes(t.pageArea()??""))return!1;let r=t.messageCount();return!(n.minMessages!=null&&r<n.minMessages||n.maxMessages!=null&&r>n.maxMessages)}function bl(e){let t=x.cssPrefix,{site:n,blocks:r,strings:i,collapsed:a}=e,l=r?.navigation??[],s=r?.linkCards??[],c=a?i.expandSidebar:i.collapseSidebar;return o("aside",{class:`${t}-sidebar`,"data-collapsed":a?"true":"false","data-testid":k.sidebar,children:[o("div",{class:`${t}-sidebar-header`,children:[o(np,{site:n}),o("button",{type:"button",class:`${t}-sidebar-toggle`,"aria-label":c,"aria-expanded":a?"false":"true",title:c,onClick:e.onToggleCollapsed,"data-testid":k.sidebarToggle,children:o(rp,{collapsed:a})})]}),a?null:o(re,{children:[l.length>0?o("nav",{class:`${t}-sidebar-section`,"data-section":"navigation",children:o(op,{items:l})}):null,s.length>0?o("div",{class:`${t}-sidebar-section`,"data-section":"link-cards",children:o(ip,{items:s})}):null,e.showConversations?o("div",{class:`${t}-sidebar-conversations`,children:o(Mr,{transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,visitorId:e.visitorId,onSelect:e.onSelectConversation,onNewConversation:e.onNewConversation})}):null]})]})}function np({site:e}){let t=x.cssPrefix;if(e?.logo?.url){let n=e.logo.alt??e.title??"Logo";return o("picture",{children:[e.logoDark?.url?o("source",{srcset:e.logoDark.url,media:"(prefers-color-scheme: dark)"}):null,o("img",{class:`${t}-sidebar-logo`,src:e.logo.url,alt:n})]})}return o("div",{class:`${t}-sidebar-title`,children:e?.title??x.name})}function rp({collapsed:e}){return o("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","aria-hidden":"true",children:e?o("polyline",{points:"9 6 15 12 9 18"}):o("polyline",{points:"15 6 9 12 15 18"})})}function op({items:e}){let t=x.cssPrefix;return o("ul",{class:`${t}-sidebar-nav`,children:e.map(n=>o("li",{children:o("a",{class:`${t}-sidebar-nav-item`,href:n.href,target:n.href?"_blank":void 0,rel:n.href?"noreferrer":void 0,children:[n.icon?o("span",{class:`${t}-sidebar-nav-icon`,"data-icon":n.icon}):null,o("span",{class:`${t}-sidebar-nav-label`,children:n.label})]})},n.id??n.label))})}function ip({items:e}){let t=x.cssPrefix;return o("div",{class:`${t}-sidebar-cards`,children:e.map(n=>o("a",{class:`${t}-sidebar-card`,href:n.href,target:n.href?"_blank":void 0,rel:n.href?"noreferrer":void 0,children:[o("div",{class:`${t}-sidebar-card-label`,children:n.label}),n.description?o("div",{class:`${t}-sidebar-card-desc`,children:n.description}):null]},n.id??n.label))})}var xl=x.cssPrefix;function Pl(e){return o("main",{class:`${xl}-page-shell`,"data-sidebar-collapsed":e.sidebarCollapsed?"true":"false",children:[o(bl,{site:e.site,blocks:e.blocks,transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,visitorId:e.visitorId,showConversations:e.showConversations,onSelectConversation:e.onSelectConversation,onNewConversation:e.onNewConversation,collapsed:e.sidebarCollapsed,onToggleCollapsed:e.onToggleSidebarCollapsed}),o("section",{class:`${xl}-page-chat`,"aria-label":"Chat",children:e.children})]})}var yl=e=>Object.fromEntries(e.map(t=>[t,[]]));function Sl(e,t,n){let r=O({activeTab:e,stacks:yl(t)});return{sig:r,switchTab(i){r.value.activeTab!==i&&(r.value={...r.value,activeTab:i},n?.(i))},push(i){let a=r.value,l=a.stacks[a.activeTab]??[];r.value={...a,stacks:{...a.stacks,[a.activeTab]:[...l,i]}}},pop(){let i=r.value,a=i.stacks[i.activeTab]??[];a.length!==0&&(r.value={...i,stacks:{...i.stacks,[i.activeTab]:a.slice(0,-1)}})},reset(i){r.value={activeTab:i,stacks:yl(t)}}}}var wl=e=>e.stacks[e.activeTab]??[],kl=e=>wl(e).at(-1),Cl=e=>wl(e).length===0;var Tl={Icon:un};var rt=x.cssPrefix;function Nr({title:e,actions:t}){return o("header",{class:`${rt}-back-header`,"data-variant":"title",children:[o("span",{class:`${rt}-back-spacer`,"aria-hidden":"true"}),o("h1",{class:`${rt}-back-title`,children:e}),t??o("span",{class:`${rt}-back-spacer`,"aria-hidden":"true"})]})}function Dr({title:e,backLabel:t,onBack:n,actions:r,testid:i}){return o("header",{class:`${rt}-back-header`,"data-testid":i,children:[o("button",{type:"button",class:`${rt}-icon-btn`,onClick:n,"aria-label":t,title:t,children:o(_n,{})}),o("h1",{class:`${rt}-back-title`,children:e}),r??o("span",{class:`${rt}-back-spacer`,"aria-hidden":"true"})]})}var Bt=x.cssPrefix;function El({placeholder:e,onActivate:t}){return o("button",{type:"button",class:`${Bt}-home-search`,onClick:t,"data-testid":k.homeSearch,children:[o("span",{class:`${Bt}-home-search-text`,children:e}),o("span",{class:`${Bt}-home-search-icon`,"aria-hidden":"true",children:o(Fo,{})})]})}function Il({placeholder:e,value:t,onInput:n}){return o("div",{class:`${Bt}-home-search`,"data-input":"true",children:[o("input",{type:"search",class:`${Bt}-home-search-input`,placeholder:e,value:t,onInput:r=>n(r.currentTarget.value),"data-testid":k.helpSearch}),o("span",{class:`${Bt}-home-search-icon`,"aria-hidden":"true",children:o(Fo,{})})]})}var hn=x.cssPrefix;function Or({title:e,subtitle:t,onClick:n,testid:r}){return o("button",{type:"button",class:`${hn}-list-row`,onClick:n,"data-testid":r,children:[o("span",{class:`${hn}-list-row-body`,children:[o("span",{class:`${hn}-list-row-title`,children:e}),t?o("span",{class:`${hn}-list-row-sub`,children:t}):null]}),o("span",{class:`${hn}-list-row-chevron`,"aria-hidden":"true",children:o(Nt,{})})]})}var Rl=x.cssPrefix;function $e({tone:e="info",message:t,onRetry:n,strings:r}){return o("div",{class:`${Rl}-module-empty`,role:e==="error"?"alert":"status","aria-live":"polite",children:[o("span",{children:t}),n?o("button",{type:"button",class:`${Rl}-module-retry`,onClick:n,children:r.errorRetry}):null]})}var gt=x.cssPrefix,ap=B.scope("help"),sp=(e,t)=>t.url?e.push({kind:"iframe",url:t.url,title:t.title}):e.push({kind:"content",id:t.id,title:t.title});function lp(e){let t=new Map;for(let n of e){let r=n.categories?.[0]??"";(t.get(r)??t.set(r,[]).get(r)).push(n)}return[...t.entries()]}function Al(e,t){let n=t.toLowerCase(),r=n.indexOf(e);if(r!==-1)return 100-Math.min(r,99);let i=0;for(let a of e){if(i=n.indexOf(a,i),i===-1)return 0;i+=1}return 1}function cp(e,t){let n=t.toLowerCase().trim();return n?e.map(r=>({item:r,score:Math.max(Al(n,r.title)*2,Al(n,r.description??""))})).filter(r=>r.score>0).toSorted((r,i)=>i.score-r.score).map(r=>r.item):[]}function Ll({article:e,nav:t}){return o(Or,{title:e.title,subtitle:e.description,onClick:()=>sp(t,e),testid:ve(k.helpArticle,e.id)})}function dp({transport:e,strings:t,config:n,nav:r,bus:i,panelProps:a}){let l=n.contentTags,[s,c]=I("loading"),[d,u]=I(t.errorGeneric),[_,m]=I([]),[f,g]=I(""),[S,h]=I(0);T(()=>{let b=!1;return c("loading"),e.listContent({tags:l,sortBy:"order",limit:100}).then(E=>{if(b)return;let D=E.items??[];m(D),c("loaded"),i.emit("contentView",{section:"help",tags:l?.join(","),count:D.length})}).catch(E=>{b||(ap.warn("listContent (help) failed",{err:E}),u(ut(E,t)),c("error"))}),()=>{b=!0}},[e,l,S,i]);let v=we(()=>cp(_,f),[_,f]);T(()=>{let b=f.trim();if(!b)return;let E=setTimeout(()=>i.emit("contentSearch",{queryLength:b.length,hitCount:v.length}),600);return()=>clearTimeout(E)},[f,v,i]);function C(){return f.trim().length>0?v.length===0?o($e,{message:t.helpSearchEmpty,strings:t}):o("div",{class:`${gt}-help-card`,children:v.map(b=>o(Ll,{article:b,nav:r},b.id))}):s==="loading"?o($e,{message:t.helpLoading,strings:t}):s==="error"?o($e,{tone:"error",message:d,onRetry:()=>h(b=>b+1),strings:t}):_.length===0?o($e,{message:t.helpEmpty,strings:t}):lp(_).map(([b,E])=>o("section",{class:`${gt}-help-group`,children:[b?o("h2",{class:`${gt}-help-section-title`,children:b}):null,o("div",{class:`${gt}-help-card`,children:E.map(D=>o(Ll,{article:D,nav:r},D.id))})]},b))}return o("div",{class:`${gt}-module`,children:[o(Nr,{title:t.helpTitle,actions:o(Ue,{panelProps:a,variant:"plain"})}),o("div",{class:`${gt}-module-pad`,children:o(Il,{placeholder:t.helpSearchPlaceholder,value:f,onInput:g})}),o("div",{class:`${gt}-help-list`,children:C()})]})}var Ml={Icon:Bo,Root:e=>o(dp,{...e})};var Nl=x.cssPrefix;function ri({onClick:e,children:t,testid:n}){return e?o("button",{type:"button",class:`${Nl}-home-card`,"data-interactive":"true",onClick:e,"data-testid":n,children:t}):o("div",{class:`${Nl}-home-card`,"data-testid":n,children:t})}var oe=x.cssPrefix,Dl=B.scope("home");function _p(e){let t=e.options.userContext?.name,n=e.config.greetingText?Se(e.strings,e.config.greetingText):void 0;return n?{title:t?n.replace("{name}",t):n.replace(/\s*\{name\}\s*/," ").trim(),subtitle:e.strings.homeGreetingLead}:t?{title:e.strings.homeGreetingNamed.replace("{name}",t),subtitle:e.strings.homeGreetingLead}:{title:e.strings.homeGreeting}}var up=(e,t)=>t.url?e.push({kind:"iframe",url:t.url,title:t.title}):e.push({kind:"content",id:t.id,title:t.title});function pp(e){let{transport:t,strings:n,config:r,nav:i,bus:a,panelProps:l}=e,[s,c]=I(null),[d,u]=I([]),_=r.contentTags?.join(",");T(()=>{if(!r.showRecentConversations)return;let v=!1;return t.listConversations({limit:1}).then(C=>!v&&c(C.conversations?.[0]??null)).catch(C=>!v&&Dl.warn("listConversations (home) failed",{err:C})),()=>{v=!0}},[t,r.showRecentConversations]),T(()=>{if(!r.contentTags?.length)return;let v=!1;return t.listContent({tags:r.contentTags,limit:6}).then(C=>{if(v)return;let b=C.items??[];u(b),a.emit("contentView",{section:"home",tags:_,count:b.length})}).catch(C=>!v&&Dl.warn("listContent (home) failed",{err:C})),()=>{v=!0}},[t,_,a]);let m=_p(e),f=r.userAvatars??[],g=r.status,S=g?.text?Se(n,g.text):n.homeStatus,h=r.contentBlockTitle?Se(n,r.contentBlockTitle):n.homeContentTitle;return o("div",{class:`${oe}-module ${oe}-home`,"data-testid":k.homeView,children:o("div",{class:`${oe}-home-scroll`,children:[o("div",{class:`${oe}-home-hero`,children:[o("div",{class:`${oe}-home-hero-top`,children:[r.brandName?o("span",{class:`${oe}-home-brand`,"data-testid":k.homeBrand,children:r.brandName}):o("span",{class:`${oe}-home-brand-spacer`,"aria-hidden":"true"}),o("div",{class:`${oe}-home-hero-actions`,children:[f.length>0?o("div",{class:`${oe}-home-avatars`,children:f.map(v=>o("span",{class:`${oe}-home-avatar`,title:v.role?`${v.name} \xB7 ${v.role}`:v.name,children:v.avatar?o("img",{src:v.avatar,alt:"",loading:"lazy"}):o("span",{children:yr(v.name)})},v.name))}):null,o(Ue,{panelProps:l,variant:"plain"})]})]}),r.showGreeting!==!1?o(re,{children:[o("h1",{class:`${oe}-home-greeting`,"data-testid":k.homeGreeting,children:m.title}),m.subtitle?o("p",{class:`${oe}-home-lead`,children:m.subtitle}):null]}):null]}),o("div",{class:`${oe}-home-cards`,children:[r.showSearchBar!==!1?o(El,{placeholder:n.homeSearchPlaceholder,onActivate:()=>i.switchToLayout("help")}):null,s?o(ri,{onClick:()=>i.selectConversation(s.conversationId),testid:k.homeRecent,children:o("div",{class:`${oe}-home-recent-row`,"data-unread":(s.unreadCount??0)>0?"true":void 0,children:[o("span",{class:`${oe}-home-recent-avatar`,"aria-hidden":"true",children:o(un,{})}),o("span",{class:`${oe}-home-recent-body`,children:[o("span",{class:`${oe}-home-recent-title`,children:s.title}),s.preview?o("span",{class:`${oe}-home-recent-preview`,children:s.preview}):null]}),(s.unreadCount??0)>0?o("span",{class:`${oe}-home-recent-dot`,"aria-label":"Unread"}):null]})}):null,g?o(ri,{onClick:g.url?()=>i.push({kind:"iframe",url:g.url,title:S}):void 0,children:o("div",{class:`${oe}-home-status`,"data-level":g.level??"operational",children:[o("span",{class:`${oe}-home-status-icon`,"aria-hidden":"true",children:o(Ts,{})}),o("span",{class:`${oe}-home-status-text`,children:S})]})}):null,d.length>0?o("section",{class:`${oe}-home-content`,children:[o("div",{class:`${oe}-home-content-title`,children:h}),o("div",{class:`${oe}-home-content-list`,children:d.map(v=>o(Or,{title:v.title,subtitle:v.description,onClick:()=>up(i,v),testid:ve(k.homeContentRow,v.id)},v.id))})]}):null]})]})})}var Ol={Icon:Es,Root:e=>o(pp,{...e})};var ot=x.cssPrefix,fp=B.scope("news");function mp({transport:e,strings:t,config:n,nav:r,bus:i,panelProps:a}){let l=n.contentTags,[s,c]=I("loading"),[d,u]=I(t.errorGeneric),[_,m]=I([]),[f,g]=I(0);T(()=>{let h=!1;return c("loading"),e.listContent({tags:l,sortBy:"publishedAt",sortOrder:"desc"}).then(v=>{if(h)return;let C=v.items??[];m(C),c("loaded"),i.emit("contentView",{section:"news",tags:l?.join(","),count:C.length})}).catch(v=>{h||(fp.warn("listContent (news) failed",{err:v}),u(ut(v,t)),c("error"))}),()=>{h=!0}},[e,l,f,i]);function S(){return s==="loading"?o($e,{message:t.newsLoading,strings:t}):s==="error"?o($e,{tone:"error",message:d,onRetry:()=>g(h=>h+1),strings:t}):_.length===0?o($e,{message:t.newsEmpty,strings:t}):o("div",{class:`${ot}-news-list`,children:_.map(h=>o("button",{type:"button",class:`${ot}-news-card`,onClick:()=>r.push({kind:"content",id:h.id,title:h.title}),"data-testid":ve(k.newsItem,h.id),children:[h.image?o("img",{class:`${ot}-news-hero`,src:h.image,alt:"",loading:"lazy"}):null,o("span",{class:`${ot}-news-body`,children:[o("span",{class:`${ot}-news-title`,children:h.title}),h.description?o("span",{class:`${ot}-news-summary`,children:h.description}):null]})]},h.id))})}return o("div",{class:`${ot}-module`,children:[o(Nr,{title:t.newsTitle,actions:o(Ue,{panelProps:a,variant:"plain"})}),o("div",{class:`${ot}-module-scroll`,children:S()})]})}var $l={Icon:Is,Root:e=>o(mp,{...e})};var $r={chat:Tl,home:Ol,help:Ml,news:$l};var vn=x.cssPrefix;function Hl({modules:e,activeTab:t,strings:n,unreadCount:r,onSelect:i}){return o("nav",{class:`${vn}-tabbar`,role:"tablist","aria-label":n.panelTitle,children:e.map(a=>{let l=$r[a.layout].Icon,s=a.id===t,c=a.layout==="chat"&&r>0?r>9?"9+":String(r):null;return o("button",{type:"button",role:"tab","aria-selected":s,class:`${vn}-tab`,onClick:()=>i(a.id),"data-testid":ve(k.tab,a.id),children:[o("span",{class:`${vn}-tab-icon`,"aria-hidden":"true",children:[o(l,{}),c?o("span",{class:`${vn}-tab-badge`,"data-testid":k.tabBadge,children:c}):null]}),o("span",{class:`${vn}-tab-label`,children:Se(n,a.label)})]},a.id)})})}var Bl=x.cssPrefix,gp="allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads";function Fl({url:e,title:t,strings:n,onBack:r,actions:i}){return o("div",{class:`${Bl}-module`,children:[o(Dr,{title:t||n.moduleBack,backLabel:n.moduleBack,onBack:r,actions:i}),o("iframe",{class:`${Bl}-content-frame`,src:e,title:t||"content",sandbox:gp,referrerpolicy:"no-referrer",loading:"lazy",allow:"fullscreen"})]})}var bn=x.cssPrefix,hp=B.scope("content"),vp=5e3;function zl({id:e,title:t,transport:n,strings:r,bus:i,onBack:a,actions:l}){let[s,c]=I(null),[d,u]=I(!1),[_,m]=I(0),f=H(()=>{u(!1),c(null),m(h=>h+1)},[]);T(()=>{let h=!1;return n.listContent({ids:[e],limit:1}).then(v=>{if(h)return;let C=v.items[0];C?(c(C),i.emit("contentOpen",{contentId:e,tags:C.tags?.length?C.tags.join(","):void 0})):u(!0)}).catch(v=>{h||(hp.warn("listContent (reader) failed",{err:v}),u(!0))}),()=>{h=!0}},[n,e,_,i]),T(()=>{if(!s)return;let h=setTimeout(()=>i.emit("contentRead",{contentId:e}),vp);return()=>clearTimeout(h)},[s,e,i]);let g=H(h=>{let C=h.target?.closest?.("a")?.getAttribute("href")??"";C&&!C.startsWith("#")&&i.emit("contentLinkClick",{contentId:e})},[i,e]);function S(){return d?o($e,{tone:"error",message:r.errorGeneric,onRetry:f,strings:r}):s===null?o($e,{message:r.contentLoading,strings:r}):o("article",{class:`${bn}-content`,"data-testid":k.contentView,onClick:g,children:[s.image?o("img",{class:`${bn}-content-hero`,src:s.image,alt:"",loading:"lazy"}):null,s.description?o("p",{class:`${bn}-content-subtitle`,children:s.description}):null,o(rl,{text:s.content??""})]})}return o("div",{class:`${bn}-module`,children:[o(Dr,{title:s?.title||t||r.moduleBack,backLabel:r.moduleBack,onBack:a,actions:l,testid:k.backHeader}),o("div",{class:`${bn}-module-scroll`,"data-testid":k.contentScroll,children:S()})]})}var Hr=x.cssPrefix;function Ul({panelProps:e,enabledModules:t,nav:n,bus:r,unreadCount:i,onSelectConversation:a,onStartNewConversation:l,onSetPanelSize:s}){let c=e.options,d=c.strings,u=M(null),_=M(new Set);T(()=>{let j=u.current;if(!j)return;let be=Pr(j),w=q=>{q.key==="Escape"&&e.onClose?.()};return j.addEventListener("keydown",w),()=>{be(),j.removeEventListener("keydown",w)}},[e.onClose]);let m=M(null),f=H(j=>{m.current?.attachFromDrop(j)},[]),{visible:g}=wr({containerRef:u,onDrop:f});br(u.current,c.mode==="modal");let S=Y(()=>n.sig.value).value,h=kl(S),v=c.modules.byId[S.activeTab],C=h?.kind==="iframe"||h?.kind==="content",b=t.length>1&&(Cl(S)||!C),E=M(null);T(()=>{if(C&&E.current===null)E.current=e.panelSize,e.panelSize==="normal"&&s("expanded");else if(!C&&E.current!==null){let j=E.current;E.current=null,s(j)}},[C]);let D={push:n.push,pop:n.pop,switchTab:n.switchTab,switchToLayout:j=>{let be=t.find(w=>w.layout===j);be&&n.switchTab(be.id)},selectConversation:a,startNewConversation:l},V=j=>({options:c,transport:e.transport,strings:d,config:j,visitorId:e.visitorId,nav:D,bus:r,panelProps:e}),G=o(Ue,{panelProps:e,variant:"plain"});v&&_.current.add(v.id);let ae=t.filter(j=>_.current.has(j.id)),K=j=>{if(j.layout==="chat")return o(ti,{...e,containerEl:u.current,dragOver:g,composerAttachApiRef:m});let be=$r[j.layout].Root;return be?o(be,{...V(j)}):null},U=()=>h?.kind==="iframe"?o(Fl,{url:h.url,title:h.title,strings:d,onBack:n.pop,actions:G}):h?.kind==="content"?o(zl,{id:h.id,title:h.title,transport:e.transport,strings:d,bus:r,onBack:n.pop,actions:G}):null;return o("div",{ref:u,class:`${Hr}-panel ${Hr}-messenger`,role:"dialog","aria-modal":"false","aria-label":d.panelTitle,style:{position:"relative"},"data-testid":k.messengerHome,children:[o("div",{class:`${Hr}-messenger-body`,children:[ae.map(j=>o("div",{class:`${Hr}-messenger-pane`,hidden:C||j.id!==v?.id,children:K(j)},j.id)),U()]}),b?o(Hl,{modules:t,activeTab:S.activeTab,strings:d,unreadCount:i,onSelect:n.switchTab}):null,o(ni,{poweredBy:c.poweredBy}),c.size.resize?.enabled&&!(v?.layout==="chat"&&!h)?o(vr,{panelEl:u.current,resize:c.size.resize,position:c.position,initialSize:e.initialWidgetSize,onSizeChange:e.onWidgetSizeChange,strings:d}):null]})}var xn=x.cssPrefix;function Wl({strings:e,onClose:t}){return o("div",{class:`${xn}-panel ${xn}-modules-empty`,role:"dialog","aria-label":e.panelTitle,"data-testid":k.modulesEmpty,children:[t?o("button",{type:"button",class:`${xn}-icon-btn ${xn}-modules-empty-close`,onClick:t,"aria-label":e.close,title:e.close,children:o(ze,{})}):null,o("p",{class:`${xn}-modules-empty-text`,children:e.modulesEmpty})]})}function Vl({callout:e,persistence:t}){let n=e?.text??"",r=e?.persistent??!0,[i,a]=I(()=>r?!1:t.loadCalloutDismissed(n));T(()=>{a(r?!1:t.loadCalloutDismissed(n))},[n,r,t]);let l=H(()=>{a(!0),r||t.saveCalloutDismissed(n)},[t,n,r]);return{dismissed:i,dismissCallout:l}}var W=B.scope("app"),Br=x.cssPrefix;function Gl(e,t){return Ya({...e,text:Se(t,e.text)})}function bp(e){return e.partsSig.value.find(t=>t.kind==="text")?.textSig.value??""}function xp(e){let t=e.partsSig.value.filter(n=>n.kind==="tool");return t.length>0&&t.every(n=>{let r=n.stateSig.value;return r==="output-available"||r==="output-error"||r==="output-denied"||r==="approval-responded"})}function Kl({options:e,hostElement:t,bus:n}){let[r]=I(()=>Tt(e.widgetId,e.storage,e.aiAgentDeploymentId)),[i,a]=I(()=>r.getVisitorId()),l=r.loadUserPrefs(),[s,c]=I(()=>l.locale??e.locale),[d,u]=I(()=>l.themeMode??e.themeMode),[_,m]=I(()=>l.textSize??e.textSize),f=dt(r.loadConversationId()),g=dt([]),S=dt(0),[h,v]=I(!1),[C,b]=I([]);function E(){let p=e.modules.list,P=new Set(p.map(N=>N.id)),L=r.loadActiveModule();return L&&P.has(L)?L:p[0]?.id??""}function D(){return e.modules.list.find(p=>p.layout==="chat")?.id}let V=M();if(!V.current){let p=e.modules.list.map(P=>P.id);V.current=Sl(E(),p,P=>r.saveActiveModule(P))}let G=V.current,ae=M(void 0);ae.current=D();let[K,U]=I(!1),[j,be]=I(null),[w,q]=I(!1),ne=e.mode==="standalone"||e.mode==="inline",ce=M(sn(e,Lt(),r.loadPanelOpen(),r.loadPanelSize())),[de,Me]=I(ce.current.panelOpen),[y,z]=I(ce.current.panelOpen),xe=M(y);xe.current=y;let Te=M(!1),ye=M(void 0);T(()=>{de&&z(!0)},[de]);let it=M(!1),[ht,Ft]=I(!1),{dismissed:vt,dismissCallout:He}=Vl({callout:e.launcher.callout,persistence:r}),zt=e.launcher.callout?.persistent??!0,Ge=H(()=>{W.info("calloutDismiss"),n.emit("calloutDismiss",void 0),He()},[n,He]),[Ie,bt]=I(ce.current.panelSize),ai=M(!1),[Zl,Wr]=I("chat"),[Ut,Wt]=I(!0),[Ke,Pn]=I(!1),[ec,si]=I(null),[Vr,yn]=I([]),[Sn,wn]=I(null),Vt=M(e.strings),[tc,nc]=I(void 0),[rc,oc]=I(void 0),[ic,ac]=I(()=>r.loadSidebarCollapsed()??!1),[Gr,sc]=I({}),[Z]=I(()=>new ur({agentApiBaseUrl:e.agentApiBaseUrl,dataApiBaseUrl:e.dataApiBaseUrl,auth:$a({publicKey:e.publicKey,aiAgentDeploymentId:e.aiAgentDeploymentId,publicKeyHeader:"x-public-key"}),endpoints:e.endpoints})),[Be]=I(()=>new pr(g)),[se]=I(()=>new gr(e.sound,e.haptics)),Fe=H(p=>{r.patchUserPrefs(p),Z.saveUserPrefs(r.loadUserPrefs()).catch(P=>{W.warn("saveUserPrefs failed",{err:P})})},[r,Z]);T(()=>{l.soundMuted!==void 0&&se.setMuted(l.soundMuted)},[]),T(()=>{t.dataset.theme=d},[t,d,e]),T(()=>{t.dataset.textSize=_},[t,_,e]),T(()=>{se.update(e.sound,e.haptics)},[se,e.sound,e.haptics]),T(()=>()=>se.destroy(),[se]),T(()=>{let p=!0;return se.mutedSig.subscribe(P=>{if(p){p=!1;return}Fe({soundMuted:P})})},[se,Fe]),T(()=>{ai.current||!e.size.initialSize||(ai.current=!0,!r.loadPanelSize()&&bt(Ao(e.mode,e.size,Lt())))},[e.mode,e.size,r]),T(()=>{if(!K||it.current)return;it.current=!0;let p=sn(e,Lt(),r.loadPanelOpen(),r.loadPanelSize());Me(p.panelOpen),bt(p.panelSize)},[K,e,r]);let li=M(!1),ci=M(!1),kn=M(null);T(()=>{if(!(!K||li.current)){if(li.current=!0,ci.current){let p=ae.current;p&&G.switchTab(p);return}G.reset(E())}},[K]);let Cn=H(p=>{!p||p.length===0||(g.value=p.map(P=>Gl(P,Vt.current)))},[g]),Kr=M(null),Tn=H(async p=>{try{let{formSubmissions:P}=await(p?Z.bootstrap(p):Kr.current??Z.bootstrap()),L=new Map;return P.forEach((N,F)=>L.set(N.formId,F)),P.filter((N,F)=>!N.skipped||L.get(N.formId)===F).map((N,F)=>({key:`wire:${N.formId}:${N.createdAt??F}`,formId:N.formId,outcome:N.skipped?"skipped":"submitted",createdAt:_r(N.createdAt),values:N.values}))}catch(P){return W.debug("bootstrap failed \u2014 no form markers (non-fatal)",{err:P}),[]}},[Z]),Gt=M(0),Kt=H((p,P)=>{let L=[...p.map(fe=>fe.createdAt),...P.map(fe=>fe.createdAt)].filter(fe=>fe!==void 0),N=(L.length?Math.min(...L):Date.now())-1,F=(fe,qe)=>`${fe}|${qe}`,A=new Set(p.map(fe=>F(fe.role,bp(fe))));return[...(ye.current?.messages??[]).filter(fe=>!A.has(F(fe.role,Se(Vt.current,fe.text)))).map(fe=>{let qe=Gl(fe,Vt.current);return qe.createdAt=N,qe}),...p]},[]),qr=H(async p=>{let P=Gt.current,L=()=>P!==Gt.current;v(!0);try{let[N,F]=await Promise.all([Z.loadConversation(p),Tn()]);if(L())return;let A=(N.messages??[]).map(Oo);b(F);let ke=kn.current?[kn.current]:[];A.length||ke.length?(g.value=[...Kt(A,F),...ke],Wt(N.canContinue??!0),yn(N.suggestions??[])):g.value=Kt([],F)}catch(N){if(L())return;W.warn("loadThread failed; resetting conversationId",{err:N,conversationId:p}),f.value=void 0,r.saveConversationId(void 0)}finally{L()||v(!1)}},[Z,Tn,g,f,r,Kt]),qt=H(async({newConversation:p})=>{let P=++Gt.current,L=()=>P!==Gt.current,N=f.value,F=p||!N?Ne():N;F!==N&&(f.value=F,r.saveConversationId(F));let A;try{A=await Z.handshake({visitorId:i,conversationId:F,userPrefs:r.loadUserPrefs(),locale:s})}catch(fe){if(L())return;n.emit("error",fe),e.onError?.(fe),p||U(!0);return}if(L())return;if(A.visitorId&&A.visitorId!==i&&(W.info("visitor rebound",{previous:i,current:A.visitorId,reason:A.rebind?.visitorId}),r.setVisitorId(A.visitorId),a(A.visitorId),n.emit("visitorRebound",{previous:i,current:A.visitorId,reason:A.rebind?.visitorId})),A.conversationId&&A.conversationId!==F&&(W.info("conversation rebound",{previous:F,current:A.conversationId,reason:A.rebind?.conversationId}),n.emit("conversationRebound",{previous:F,current:A.conversationId,reason:A.rebind?.conversationId})),A.agent&&si(A.agent),e.mode==="page"&&(A.site&&Da(A.site)?nc(A.site):A.site&&W.warn("invalid site config, using fallback",{site:A.site}),A.blocks&&Oa(A.blocks)?oc(A.blocks):A.blocks&&W.warn("invalid blocks config, using fallback",{blocks:A.blocks})),A.userPrefs&&!p&&(r.saveUserPrefs(A.userPrefs),A.userPrefs.locale&&c(A.userPrefs.locale),A.userPrefs.soundMuted!==void 0&&se.setMuted(A.userPrefs.soundMuted),A.userPrefs.themeMode&&u(A.userPrefs.themeMode),A.userPrefs.textSize&&m(A.userPrefs.textSize)),ye.current=A.welcome,p||n.emit("handshake",A),A.welcome?.suggestions){let fe=Vt.current;yn(A.welcome.suggestions.map(qe=>({...qe,label:Se(fe,qe.label),...qe.text===void 0?{}:{text:Se(fe,qe.text)}})))}!p&&N&&A.conversationId===N?xe.current?qr(N):Te.current=!0:(f.value=A.conversationId,r.saveConversationId(A.conversationId),Cn(A.welcome?.messages)),p||U(!0)},[Z,i,r,e,n,f,se,Cn,qr,s]),jt=JSON.stringify(e.userContext??null),lc=JSON.stringify(e.pageContext??null),cc=JSON.stringify(Gr);T(()=>{let p=Object.keys(Gr).length?{...Gr,...e.userContext}:e.userContext;Z.setContext(p,Pp(e.pageContext))},[Z,jt,lc,cc]);let Re=Ct(s,e.availableLocales,e.defaultLocale);T(()=>{Z.setLocale(Re)},[Z,Re]),T(()=>{t.dir=Hi(Re)?"rtl":"ltr"},[t,Re]),T(()=>{Re!==s&&c(Re)},[Re,s]);let dc=H(async p=>{let P=null;try{for await(let L of p.iter){if(!P){P=Do(),kn.current=P,Be.attach(P),g.value=[...g.value,P],Pn(!0),wn(()=>p.cancel),ci.current=!0;let N=ae.current;N&&G.switchTab(N),W.info("resumed in-flight reply on mount")}Be.apply(L.chunk),L.chunk.type==="finish"&&L.chunk.canContinue===!1&&Wt(!1)}P&&(P.status="complete",se.play("messageReceived"),oi(n,e,"assistant",$o(P)))}catch(L){P&&(P.status="error",P.errorText=ut(L,e.strings),se.play("error")),W.debug("mount resume ended without completing",{err:L})}finally{kn.current=null,P&&(Be.detach(),Pn(!1),wn(null),g.value=[...g.value])}},[Be,g,se,n,e,G]),di=M(null);T(()=>{let p=f.value;return p&&Z.primeIdentity(i,p),qt({newConversation:!1}),()=>{Gt.current++,di.current?.cancel()}},[]),T(()=>{if(y){if(Kr.current=Z.bootstrap(),(async()=>{try{let p=await Kr.current;be(Qt((p??{forms:[]}).forms,Re))}catch(p){W.debug("bootstrap failed \u2014 treating as no forms",{err:p})}finally{q(!0)}})(),Te.current){Te.current=!1;let p=f.value;p&&qr(p)}if(f.value){let p=Z.resumeStream();di.current=p,dc(p)}}},[y]);let En=M(null);T(()=>{if(!y)return;if(En.current===null){En.current=Re;return}if(En.current===Re)return;En.current=Re;let p=!1;return Z.bootstrap().then(P=>{p||be(Qt((P??{forms:[]}).forms,Re))}).catch(P=>W.debug("forms re-localize failed \u2014 keeping current copy",{err:P})),()=>{p=!0}},[y,Re,Z]);let _i=M(jt);T(()=>{!K||_i.current===jt||(_i.current=jt,qt({newConversation:!1}))},[jt,K,qt]),T(()=>{Qn(t,dr(e.mode,Ie,de))},[t,de,Ie,e.mode]),T(()=>{if(e.mode!=="modal"||!de)return;let p=P=>{P.composedPath().some(F=>F instanceof HTMLElement&&F.classList.contains(`${x.cssPrefix}-panel`))||Me(!1)};return t.addEventListener("click",p),()=>t.removeEventListener("click",p)},[t,de,e.mode]),T(()=>{if(e.mode!=="drawer"||!de)return;let p=P=>{P.key==="Escape"&&Me(!1)};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[de,e.mode]);let In=H(async(p,{continueExisting:P})=>{let L=f.value??Ne();f.value||(f.value=L,r.saveConversationId(L));let N=P?g.value:g.value.slice(0,-1),F=Va({messages:N.map(Ja),conversationId:L,messageId:p.serverMessageId??p.id,tools:e.features.tools,visitorId:i,userPrefs:r.loadUserPrefs()});Pn(!0);let A=Z.sendMessage(F);wn(()=>A.cancel);try{for await(let ke of A.iter)Be.apply(ke.chunk),ke.chunk.type==="finish"&&ke.chunk.canContinue===!1&&Wt(!1);p.status="complete",se.play("messageReceived"),oi(n,e,"assistant",$o(p))}catch(ke){p.status="error",p.errorText=ut(ke,e.strings),se.play("error"),n.emit("error",ke),e.onError?.(ke)}finally{Be.detach(),Pn(!1),wn(null),g.value=[...g.value]}},[Z,Be,g,f,e,n,se,r,i]),Rn=H((p,P)=>{if(Ke)return;let L=g.value.at(-1),N=L?.partsSig.value.find(F=>F.kind==="tool"&&F.toolCallId===p);if(!L||!N){W.warn("decideTool: tool part not found",{toolCallId:p});return}P(N),L.partsSig.value=[...L.partsSig.value],xp(L)&&(L.status="streaming",Be.attach(L),In(L,{continueExisting:!0}))},[Ke,g,Be,In]),ui=H((p,P)=>{W.info("toolResult",{toolCallId:p}),n.emit("toolResult",{toolCallId:p}),Rn(p,L=>{L.outputSig.value=P,L.stateSig.value="output-available"})},[n,Rn]),pi=H((p,P,L)=>{W.info("toolDecision",{toolCallId:p,approved:P}),n.emit("toolDecision",{toolCallId:p,approved:P}),Rn(p,N=>{let F=N.approvalSig.value?.id??p;N.approvalSig.value={id:F,approved:P,reason:L},N.stateSig.value="approval-responded"})},[n,Rn]),_c=we(()=>({humanInLoop:e.features.humanInLoop,onResult:ui,onDecision:pi}),[e.features.humanInLoop,ui,pi]),uc=()=>g.value.reduce((p,P)=>p+(P.role==="user"?1:0),0),xt=e.forms.list.length>0?e.forms:j??e.forms,_e=vl({forms:xt,persistence:r,userContext:()=>e.userContext,messageCount:uc,pageArea:()=>e.pageContext?.area?String(e.pageContext.area):void 0,conversationId:()=>f.value,onComplete:(p,P,L,N)=>{W.info("formSubmit",{formId:p.id,trigger:P,skipped:N}),n.emit("formSubmit",{formId:p.id,values:L,skipped:N}),b(A=>[...A.filter(ke=>!(ke.formId===p.id&&ke.outcome==="skipped")),{key:`local:${p.id}:${Date.now()}`,formId:p.id,outcome:N?"skipped":"submitted",createdAt:Date.now(),...N?{}:{values:L}}]);let F=f.value??Ne();f.value||(f.value=F,r.saveConversationId(F),Z.primeIdentity(void 0,F)),!N&&p.mirrorToContext&&sc(A=>({...A,...L})),Z.submitForm({formId:p.id,conversationId:F,trigger:P,values:L,skipped:N})}}),pc=Y(()=>_e.activeForm.value);T(()=>{_e.refresh()},[xt,_e]);let fi=e.pageContext?.area?String(e.pageContext.area):void 0,fc=Y(()=>g.value.length);T(()=>{K&&w&&_e.fire("pre-chat")},[K,w,_e]),T(()=>{w&&!Ut&&_e.fire("conversation-closed")},[w,Ut,_e]),T(()=>{K&&w&&fi&&_e.fire("page-area")},[K,w,fi,_e]);let jr=we(()=>{let p=xt.list.flatMap(P=>P.triggers).filter(P=>P.kind==="idle").map(P=>Number(P.param));return p.length?Math.min(...p)*1e3:0},[xt]);T(()=>{if(!jr||!de)return;let p=setTimeout(()=>_e.fire("idle"),jr);return()=>clearTimeout(p)},[jr,de,_e,fc.value]);let mi=H(async(p,P)=>{if(W.info("send",{textLen:p.length,attachments:P.length,streaming:Ke}),Ke)return;n.emit("send",{text:p,attachmentCount:P.length}),Vr.length>0&&yn([]);let L=await Sp(Z,P,A=>{W.warn("upload failed",{err:A}),n.emit("error",A),e.onError?.(A)});se.unlock(),se.play("messageSent");let N=Xa(p,L),F=Do();g.value=[...g.value,N,F],Be.attach(F),oi(n,e,"user",p),await In(F,{continueExisting:!1}),_e.fire("after-messages")},[Ke,Z,n,e,Vr.length,g,Be,In,_e]),mc=H(()=>{W.info("stop"),n.emit("stop",void 0),Sn?.()},[Sn,n]),gc=H(()=>{se.toggleMuted();let p=se.mutedSig.value;W.info("soundToggle",{muted:p}),n.emit("soundToggle",{muted:p})},[se,n]),Xt=H(()=>{if($s(e.mode,Ie)==="exit-fullscreen"){W.info("close \u2192 exit-fullscreen",{mode:e.mode}),bt("normal"),n.emit("fullscreen",!1);return}W.info("close \u2192 panel closed",{mode:e.mode}),_e.fire("panel-close"),Me(!1),r.savePanelOpen(!1),n.emit("close",void 0),e.onClose?.()},[n,e,r,Ie,_e]),Pt=H(()=>{e.modules.list.some(p=>p.layout==="chat")&&Z.listConversations({limit:50}).then(p=>{S.value=p.conversations.reduce((P,L)=>P+(L.unreadCount??0),0)}).catch(p=>W.debug("refreshUnread failed (non-fatal)",{err:p}))},[Z,e.modules,S]),gi=M(!1);T(()=>{!y||!K||gi.current||(gi.current=!0,Pt())},[y,K,Pt]);let Xr=H(()=>{W.info("open",{mode:e.mode}),se.unlock(),Ft(!0),Me(!0),r.savePanelOpen(!0),!vt&&!zt&&Ge(),setTimeout(()=>Ft(!1),yp),Pt(),n.emit("open",void 0),e.onOpen?.()},[n,e,se,r,vt,zt,Ge,Pt]),Yr=H(()=>{if(!g.value.some(P=>P.role==="user")&&Ut&&f.value){W.info("clear \u2192 reusing empty conversation",{conversationId:f.value}),g.value.length===0&&Cn(ye.current?.messages);return}W.info("clear \u2192 new conversation",{wasStreaming:Ke}),n.emit("clear",void 0),Ke&&Sn?.(),It(()=>{g.value=[],f.value=void 0}),r.clearConversation(),Wt(!0),b([]),qt({newConversation:!0})},[Ke,Sn,g,f,r,qt,n,Ut,Cn]),Jr=H(()=>{Yr(),Wr("chat");let p=e.modules.list.find(P=>P.layout==="chat")?.id;p&&G.switchTab(p)},[Yr,G,e]),Qr=H(()=>{let p=Ie==="expanded"?"normal":"expanded";W.info("expand",{from:Ie,expanded:p==="expanded"}),bt(p),r.savePanelSize(p),n.emit("expand",p==="expanded")},[n,Ie,r]),Zr=H(()=>{let p=Ie==="fullscreen"?"normal":"fullscreen";W.info("fullscreen",{from:Ie,fullscreen:p==="fullscreen"}),bt(p),r.savePanelSize(p),n.emit("fullscreen",p==="fullscreen")},[n,Ie,r]),hc=H(()=>{Wr(p=>{let P=p==="history"?"chat":"history";return W.info("toggleHistory",{view:P}),n.emit("toggleHistory",{view:P}),P})},[n]),vc=H(p=>{W.info("localeChange",{locale:p}),c(p),Fe({locale:p}),n.emit("localeChange",p)},[Fe,n]),bc=H(p=>{W.info("themeChange",{mode:p}),u(p),t.dataset.theme=p,Fe({themeMode:p}),n.emit("themeChange",p)},[t,Fe,n]),xc=H(p=>{W.info("textSizeChange",{size:p}),m(p),t.dataset.textSize=p,Fe({textSize:p}),n.emit("textSizeChange",p)},[t,Fe,n]),Pc=H(()=>{ac(p=>{let P=!p;return W.info("sidebarToggle",{collapsed:P}),r.saveSidebarCollapsed(P),n.emit("sidebarToggle",{collapsed:P}),P})},[r,n]),yc=H(p=>{W.info("resize",p),Fe({widgetSize:p}),n.emit("resize",p)},[Fe,n]),eo=H(async p=>{W.info("selectConversation",{conversationId:p}),n.emit("selectConversation",{conversationId:p});try{let[P,L]=await Promise.all([Z.loadConversation(p),Tn(p)]),N=P.messages.map(Oo);It(()=>{g.value=Kt(N,L),f.value=P.conversationId}),b(L),r.saveConversationId(P.conversationId),P.agent&&si(P.agent),Wt(P.canContinue),yn(P.suggestions??[]),Wr("chat"),await Z.markRead(p),Pt()}catch(P){n.emit("error",P),e.onError?.(P)}},[Z,g,f,n,e,r,Pt,Tn,Kt]),An=M(null),hi=H(p=>{typeof p=="string"&&(w?_e.fire("manual",p):An.current=p)},[w,_e]);T(()=>{!w||!An.current||(_e.fire("manual",An.current),An.current=null)},[w,_e]),T(()=>ea(t,{open:Xr,close:Xt,expand:Qr,fullscreen:Zr,openForm:hi}),[t,Xr,Xt,Qr,Zr,hi]);let Ee=we(()=>So(e,s,d,_),[e,s,d,_]);Vt.current=Ee.strings;let Sc=we(()=>C.map(p=>{let P=xt.list.find(L=>L.id===p.formId);return{...p,title:P?.title,form:P}}),[C,xt]),vi={options:Ee,transport:Z,feedback:se,bus:n,persistence:r,view:Zl,canSend:Ut,isStreaming:Ke,loadingMessages:h,messagesSig:g,agent:ec,suggestions:Vr,initialWidgetSize:l.widgetSize??null,visitorId:i,onClose:Xt,onClear:Yr,onExpand:Qr,onFullscreen:Zr,onSoundToggle:gc,onToggleHistory:hc,onSelectHistoryConversation:eo,onNewConversation:Jr,onLocaleChange:vc,onThemeChange:bc,onTextSizeChange:xc,onWidgetSizeChange:yc,onSend:mi,onStop:mc,onSuggestion:p=>{let P=p.text??p.label;W.info("suggestion",{text:P}),n.emit("suggestion",{text:P}),mi(P,[])},activeForm:pc.value?.form??null,formMarkers:Sc,onFormSubmit:_e.complete,onFormSkip:_e.skip,onFormFill:p=>_e.fire("manual",p),tool:_c},wc=p=>{eo(p);let P=D();P&&G.switchTab(P)};if(!K)return null;let Yt=Ee.modules.list,to=p=>{let P=pn("close",Ee.mode,p);return Yt.length===0?o(Wl,{strings:Ee.strings,onClose:P?Xt:void 0}):Yt.length===1&&Yt[0]?.layout==="chat"?o(hl,{...vi,panelSize:p}):o(Ul,{panelProps:{...vi,panelSize:p,onClose:P?Xt:void 0},enabledModules:Yt,nav:G,bus:n,unreadCount:S.value,onSelectConversation:wc,onStartNewConversation:Jr,onSetPanelSize:bt})};if(e.mode==="page"){let p=L=>{eo(L.conversationId)},P=Yt.some(L=>L.layout==="chat");return o("div",{class:`${Br}-anchor`,children:o(Pl,{site:tc,blocks:rc,transport:Z,strings:Ee.strings,locale:Ee.locale,persistence:r,visitorId:i,showConversations:P,onSelectConversation:p,onNewConversation:Jr,sidebarCollapsed:ic,onToggleSidebarCollapsed:Pc,children:to("fullscreen")})})}if(ne){let p=e.mode==="standalone"?"fullscreen":Ie;return o("div",{class:`${Br}-anchor`,children:to(p)})}let bi=e.mode==="drawer",xi=!(e.mode==="modal")&&!e.launcher.hidden&&(!de||ht),Pi=xi&&!ht&&!vt&&!bi?Ee.launcher.callout:null;return o("div",{class:`${Br}-anchor`,"data-launcher-size":Ee.launcher.size,children:[de||y?o("div",{class:`${Br}-surface`,hidden:!de,children:to(Ie)}):null,xi?o(Ns,{onToggle:Xr,launcher:Ee.launcher,strings:Ee.strings,leaving:ht,edgeTab:bi}):null,Pi?o(Ds,{callout:Pi,launcherPosition:Ee.position,strings:Ee.strings,closeLabel:Ee.strings.close,onDismiss:Ge}):null]})}function Pp(e){let t=e?.url??(typeof location<"u"?location.href:void 0);if(!(!e&&!t))return{...e,...t?{url:t}:{}}}var yp=120;async function Sp(e,t,n){let r=[];for(let i of t)try{let{id:a,url:l}=await e.uploadFile(i.file);r.push({id:a,name:i.name,mediaType:i.mediaType,size:i.size,url:l})}catch(a){n(a)}return r}function oi(e,t,n,r){let i={role:n,text:r};e.emit("message",i),t.onMessage?.(i)}var wp=B.scope("error-boundary"),Fr=class extends et{constructor(){super(...arguments);J(this,"state",{crashed:!1})}componentDidCatch(n,r){wp.error("widget render crashed",{error:n,componentStack:r?.componentStack}),this.setState({crashed:!0}),this.props.onError(n,r?.componentStack)}render(){return this.state.crashed?this.props.fallback:this.props.children}};var kp="1",Cp=60,Tp=2e3,ql={open:()=>{},close:()=>{},expand:e=>({on:e}),fullscreen:e=>({on:e}),send:e=>({attachments:e.attachmentCount}),message:e=>({role:e.role}),stop:()=>{},clear:()=>{},suggestion:()=>{},toggleHistory:e=>({view:e.view}),handshake:()=>{},formSubmit:e=>({formId:e.formId,skipped:e.skipped}),toolResult:()=>{},toolDecision:e=>({approved:e.approved}),contentView:e=>({section:e.section,tags:e.tags,count:e.count}),contentOpen:e=>({contentId:e.contentId,tags:e.tags}),contentSearch:e=>({qlen:e.queryLength,hits:e.hitCount}),contentRead:e=>({contentId:e.contentId}),contentLinkClick:e=>({contentId:e.contentId}),attach:e=>({count:e.count,bytes:e.totalBytes}),voiceStart:()=>{},voiceStop:e=>({ms:e.durationMs}),voiceCancel:()=>{},localeChange:e=>({locale:e}),themeChange:e=>({theme:e}),textSizeChange:e=>({size:e}),soundToggle:e=>({muted:e.muted}),sidebarToggle:e=>({collapsed:e.collapsed}),calloutDismiss:()=>{},error:()=>{}};function Ep(){let e=navigator;return e.globalPrivacyControl===!0||e.doNotTrack==="1"}function Ip(){return location.origin+location.pathname}function Rp(){try{return document.referrer?new URL(document.referrer).origin:""}catch{return""}}function jl(e,t){let n=Math.random(),r=0,i=0,a=new Set,l=(c,d)=>{let{tracking:u,publicKey:_,aiAgentDeploymentId:m,mode:f,themeMode:g}=t.getOptions();if(!u.enabled||Ep()||n>=u.sampleRate)return;let S=performance.now();if(S-r>6e4&&(r=S,i=0),++i>Cp)return;let h=new URLSearchParams;h.set("v",kp),h.set("_ev",St),h.set("e",c),u.token&&h.set("tk",u.token),_&&h.set("pk",_),m&&h.set("dep",m),h.set("vid",t.getVisitorId());let v=t.getConversationId();v&&h.set("cid",v),h.set("url",Ip());let C=Rp();C&&h.set("ref",C),h.set("sw",String(screen.width)),h.set("sh",String(screen.height)),h.set("vw",String(innerWidth)),h.set("vh",String(innerHeight)),h.set("dpr",String(devicePixelRatio)),h.set("lang",navigator.language);try{h.set("tz",Intl.DateTimeFormat().resolvedOptions().timeZone)}catch{}if(h.set("m",f),h.set("th",g),d)for(let[V,G]of Object.entries(d))G!==void 0&&h.set(V,String(G));h.set("ts",String(Date.now()));let b=`${u.endpoint}?${h}`;if(b.length>Tp)return;let E=new Image(1,1);a.add(E);let D=()=>a.delete(E);E.addEventListener("load",D,{once:!0}),E.addEventListener("error",D,{once:!0}),E.src=b},s=Object.keys(ql).map(c=>e.on(c,d=>l(c,ql[c]?.(d))));return()=>{for(let c of s)c();a.clear()}}function Xl(e){let{bus:t,host:n,appRoot:r,persistence:i,reportError:a}=e,l=e.initialRaw,s,c=kt(l),d=!0,u=()=>{c=kt(s?wo(l,s):l)},_=()=>{ca(n,en(c.mode));let g=i.loadUserPrefs().themeMode;da(n,g?{...c,themeMode:g}:c),d&&(Qn(n,zr(c)),d=!1)},m=()=>{_(),Un(zn(Fr,{onError:a},zn(Kl,{bus:t,hostElement:n,options:c})),r)};t.on("handshake",g=>{g.config&&(g.config.storageVersion&&i.rememberStorageVersion(g.config.storageVersion),s=g.config,u(),m())});let f=jl(t,{getOptions:()=>c,getVisitorId:()=>i.getVisitorId(),getConversationId:()=>i.loadConversationId()});return{getOptions:()=>c,getUserOptions:()=>l,render:m,setUserOptions:g=>{l=g,u(),m()},patchUserOptions:g=>{l={...l,...g},u(),m()},destroy:()=>f()}}function zr(e){if(e.mode==="standalone")return"standalone";if(e.mode==="inline")return"inline";let t=Tt(e.widgetId,e.storage,e.aiAgentDeploymentId),{panelOpen:n,panelSize:r}=sn(e,Lt(),t.loadPanelOpen(),t.loadPanelSize());return dr(e.mode,r,n)}var Ap=B.scope("hooks"),Ur="*",ii=new Set;function Yl(e,t,n){let r={widgetId:e,event:t,listener:n};return ii.add(r),()=>{ii.delete(r)}}function Lp(e,t,n){let r=[...ii];for(let i of r)if(Mp(i.widgetId,e.widgetId)&&!(i.event!==Ur&&i.event!==t))try{i.listener(e,t,n)}catch(a){Ap.warn("hook listener threw",{event:t,error:a})}}function Jl(e,t){let n=[];for(let r of Np)n.push(t.on(r,i=>{Lp(e,r,i)}));return()=>{for(let r of n)r()}}function Mp(e,t){return e===Ur||e===t}var Np=["open","close","expand","fullscreen","resize","message","send","stop","clear","selectConversation","suggestion","toggleHistory","formSubmit","toolResult","toolDecision","contentView","contentOpen","contentSearch","contentRead","contentLinkClick","attach","removeAttachment","voiceStart","voiceStop","voiceCancel","localeChange","themeChange","textSizeChange","soundToggle","sidebarToggle","calloutDismiss","error","handshake","visitorRebound","conversationRebound"];var Qe=new Map;function Ql(e){e.debug!==void 0&&qn(e.debug);let t=B.scope("mount");t.info("mount",{widgetId:e.widgetId,publicKey:e.publicKey,mode:e.presentation?.mode});let n=kt(e),r=n.widgetId,i=Qe.get(r);i&&(t.debug("destroy existing instance at slot",{widgetId:r}),i.destroy());let a=zr(n),l=n.iframe?pa({position:en(n.mode)},n.position,a,n.mode,e.target??null):Jn({position:en(n.mode),target:e.target??null});l.hostElement.dataset.widgetId=r;let s=new er,c=Tt(r,n.storage,n.aiAgentDeploymentId),d=S=>{s.emit("error",S),u.getOptions().onError?.(S)},u=Xl({bus:s,host:l.hostElement,appRoot:l.appRoot,persistence:c,initialRaw:e,reportError:d});u.render();let _=l.hostElement,m=null,f=S=>{S.debug!==void 0&&qn(S.debug),u.patchUserOptions(S)},g={widgetId:r,open:()=>Zt(_,"open"),close:()=>Zt(_,"close"),expand:()=>Zt(_,"expand"),openForm:S=>Zt(_,"openForm",S),on:(S,h)=>s.on(S,h),update:S=>{t.debug("update",{patch:S}),f(S)},setUserContext:S=>{t.debug("setUserContext",{keys:Object.keys(S)}),f({userContext:{...u.getUserOptions().userContext,...S}})},clearUserContext:()=>{t.debug("clearUserContext"),f({userContext:void 0})},setPageContext:S=>{t.debug("setPageContext",{keys:Object.keys(S)}),f({pageContext:{...u.getUserOptions().pageContext,...S}})},clearPageContext:()=>{t.debug("clearPageContext"),f({pageContext:void 0})},setDebug:S=>{qn(S),t.info("debug level set",{level:ho()})},debugLevel:()=>ho(),onLog:S=>Vi(S),destroy:()=>{t.info("destroy",{widgetId:r}),m?.(),u.destroy(),s.clear(),Un(null,l.appRoot),l.destroy(),Qe.get(r)===g&&Qe.delete(r)}};return m=Jl(g,s),Qe.set(r,g),g}function Dp(e){let t=e.widgetId??"default",n=Qe.get(t);return n?(n.update(e),n):Ql(e)}function Op(e){if(e!==void 0){Qe.get(e)?.destroy();return}let t=[...Qe.values()];for(let n of t)n.destroy()}function $p(e="default"){return Qe.get(e)??null}function Hp(){return[...Qe.values()]}function Bp(e,t,n){return Yl(e,t,n)}var Fp=St,zp=x;
39
+ `){ee(e),te(e,16),e.pending=n;continue}}break;case"$":if(e.token!==19&&e.token!==16&&e.pending==="$")if(n==="$"){e.token=105,e.pending=r;continue}else{if(hu(n.charCodeAt(0)))break;ee(e),te(e,31),e.pending=n;continue}break;case"[":if(e.token!==19&&e.token!==17&&e.token!==30&&e.token!==31&&n!=="]"){ee(e),te(e,17),e.pending=n;continue}break;case"!":if(e.token!==19&&n==="["){ee(e),te(e,19),e.pending="";continue}break;case" ":if(e.pending.length===1&&n===" ")continue;break}if(e.token!==19&&e.token!==17&&e.token!==30&&e.token!==31&&n==="h"&&(e.pending===" "||e.pending==="")){e.text+=e.pending,e.pending=n,e.token=102;continue}e.text+=e.pending,e.pending=n}ee(e)}function Jo(e){return{add_token:vu,end_token:bu,add_text:xu,set_attr:Pu,data:{nodes:[e,,,,,],index:0}}}function vu(e,t){let n=e.nodes[e.index],r;switch(t){case 1:return;case 20:r=document.createElement("blockquote");break;case 2:r=document.createElement("p");break;case 21:r=document.createElement("br");break;case 22:r=document.createElement("hr");break;case 3:r=document.createElement("h1");break;case 4:r=document.createElement("h2");break;case 5:r=document.createElement("h3");break;case 6:r=document.createElement("h4");break;case 7:r=document.createElement("h5");break;case 8:r=document.createElement("h6");break;case 12:case 13:r=document.createElement("em");break;case 14:case 15:r=document.createElement("strong");break;case 16:r=document.createElement("s");break;case 11:r=document.createElement("code");break;case 18:case 17:r=document.createElement("a");break;case 19:r=document.createElement("img");break;case 23:r=document.createElement("ul");break;case 24:r=document.createElement("ol");break;case 25:r=document.createElement("li");break;case 26:let i=r=document.createElement("input");i.type="checkbox",i.disabled=!0;break;case 9:case 10:n=n.appendChild(document.createElement("pre")),r=document.createElement("code");break;case 27:r=document.createElement("table");break;case 28:switch(n.children.length){case 0:n=n.appendChild(document.createElement("thead"));break;case 1:n=n.appendChild(document.createElement("tbody"));break;default:n=n.children[1]}r=document.createElement("tr");break;case 29:r=document.createElement(n.parentElement?.tagName==="THEAD"?"th":"td");break;case 30:r=document.createElement("equation-block");break;case 31:r=document.createElement("equation-inline");break}e.nodes[++e.index]=n.appendChild(r)}function bu(e){e.index-=1}function xu(e,t){e.nodes[e.index].appendChild(document.createTextNode(t))}function Pu(e,t,n){e.nodes[e.index].setAttribute(uu(t),n)}function Er({textSig:e,doneSig:t}){let n=M(null);return nn(()=>{let r=n.current;if(!r)return;r.classList.add(`${x.cssPrefix}-md`);let i=Jo(r),a=Yo(i),l=0,s=Ye(()=>{let u=e.value,_=t.value;u.length<l&&(r.replaceChildren(),i=Jo(r),a=Yo(i),l=0);let m=u.slice(l);m&&Pe(a,m),l=u.length,_&&tl(a)}),c=new MutationObserver(u=>{for(let _ of u)for(let m of _.addedNodes){if(!(m instanceof HTMLElement))continue;let f=m.matches?.("a")?[m]:[...m.querySelectorAll?.("a")??[]];for(let g of f)nl(g)}});c.observe(r,{childList:!0,subtree:!0});for(let u of r.querySelectorAll("a"))nl(u);let d=u=>{let _=u.target?.closest?.("a");if(!_||!(_ instanceof HTMLAnchorElement))return;let m=_.getAttribute("href")??"";!m||m.startsWith("#")||(u.preventDefault(),window.open(m,"_blank","noopener,noreferrer"))};return r.addEventListener("click",d),()=>{s(),c.disconnect(),r.removeEventListener("click",d)}},[e,t]),o("div",{ref:n})}function rl({text:e}){let t=ke(()=>O(e),[e]),n=ke(()=>O(!0),[]);return o(Er,{textSig:t,doneSig:n})}function nl(e){let t=e.getAttribute("href")??"";if(!t||t.startsWith("#"))return;e.target!=="_blank"&&(e.target="_blank");let n=new Set((e.rel||"").split(/\s+/).filter(Boolean));n.add("noopener"),n.add("noreferrer"),e.rel=[...n].join(" ")}var $t=x.cssPrefix;function ol({part:e,strings:t}){let n=e.title||e.filename||e.url||t.sources;return e.url?o("a",{class:`${$t}-source`,href:e.url,target:"_blank",rel:"noreferrer noopener","data-testid":k.source,children:[o("span",{class:`${$t}-source-icon`,"aria-hidden":"true",children:"\u{1F517}"}),o("span",{class:`${$t}-source-label`,children:n})]}):o("span",{class:`${$t}-source`,"data-testid":k.source,children:[o("span",{class:`${$t}-source-icon`,"aria-hidden":"true",children:"\u{1F4C4}"}),o("span",{class:`${$t}-source-label`,children:n})]})}var mn=x.cssPrefix;function Ir(e){return e.startsWith("tool:")||e.startsWith("tool-")?e.slice(5):e}function Su(e,t){return e==="output-error"?"error":e==="output-denied"||t?.approved===!1?"denied":e==="output-available"?"completed":t?.approved===!0?"approved":"pending"}var wu={completed:"\u2713",approved:"\u2713",denied:"\u2715",error:"\u26A0",pending:"\u2022"};function Rr({state:e,approval:t,strings:n}){let r=Su(e,t),i=r==="completed"?n.statusCompleted:r==="approved"?n.approved:r==="denied"?n.statusDenied:r==="error"?n.statusError:"";return i?o("span",{class:`${mn}-toolui-status`,"data-status":r,children:[o("span",{class:`${mn}-toolui-status-icon`,"aria-hidden":"true",children:wu[r]}),i]}):null}function nt({label:e,value:t,error:n}){let r=n?String(t??""):Ar(Qo(t));return r?o("div",{class:`${mn}-toolui-section`,children:[o("span",{class:`${mn}-toolui-label`,children:e}),o("pre",{class:`${mn}-toolui-code`,"data-error":n?"true":void 0,children:r})]}):null}function Qo(e){if(e&&typeof e=="object"){let t=e;if(t.storage==="tool-result-ref"&&"summary"in t)return t.summary}return e}function Ar(e){if(e==null)return"";try{let t=typeof e=="string"?e:JSON.stringify(e,null,2);return!t||t==="{}"||t==="[]"||t==='""'?"":t.length>800?`${t.slice(0,800)}\u2026`:t}catch{return""}}var Ve=x.cssPrefix;function il({part:e,strings:t,active:n,onDecision:r}){let i=Y(()=>e.approvalSig.value),a=Y(()=>e.stateSig.value),l=Y(()=>e.inputSig.value),s=Y(()=>e.outputSig.value),c=Y(()=>e.errorSig.value),d=dt(""),u=i.value?.approved!==void 0||a.value!=="approval-requested";return o("div",{class:`${Ve}-toolui`,"data-testid":u?k.toolDecision:k.toolApproval,children:[o("div",{class:`${Ve}-toolui-head`,children:[o("strong",{class:`${Ve}-toolui-title`,children:Ir(e.toolName)}),u?o(Rr,{state:a.value,approval:i.value,strings:t}):o("span",{class:`${Ve}-toolui-badge ${Ve}-toolui-badge-accent`,children:t.approvalRequired})]}),o(nt,{label:t.toolParameters,value:l.value}),s.value!==void 0?o(nt,{label:t.toolResult,value:s.value}):null,c.value?o(nt,{label:t.statusError,value:c.value,error:!0}):null,u?null:n?o(re,{children:[o("input",{class:`${Ve}-field-input`,value:d.value,placeholder:t.approvalReason,onInput:_=>{d.value=_.target.value}}),o("div",{class:`${Ve}-form-actions`,children:[o("button",{type:"button",class:`${Ve}-form-skip`,onClick:()=>r(e.toolCallId,!1,d.value.trim()||void 0),"data-testid":k.toolReject,children:t.reject}),o("button",{type:"button",class:`${Ve}-form-submit`,onClick:()=>r(e.toolCallId,!0,d.value.trim()||void 0),"data-testid":k.toolApprove,children:t.approve})]})]}):o("p",{class:`${Ve}-toolui-note`,children:t.stepNoLongerActive})]})}function sl(e){let t=e&&typeof e=="object"?e:{},n=t.responseType;return{title:gn(t.title),question:gn(t.question)??"Please provide the missing information.",description:gn(t.description),placeholder:gn(t.placeholder),responseType:n==="single-choice"||n==="multi-choice"||n==="confirmation"||n==="free-text"?n:"free-text",choices:Array.isArray(t.choices)?t.choices:void 0,allowOther:typeof t.allowOther=="boolean"?t.allowOther:void 0,required:typeof t.required=="boolean"?t.required:!0,defaultValues:Array.isArray(t.defaultValues)?t.defaultValues.filter(r=>typeof r=="string"):void 0,minSelections:al(t.minSelections),maxSelections:al(t.maxSelections),validationHint:gn(t.validationHint)}}function ll(e){if(e.responseType==="confirmation")return[];let t=(e.choices??[]).map(ku).filter(i=>i!==null),n="textarea";e.responseType==="single-choice"&&t.length>0?n="radio":e.responseType==="multi-choice"&&(n="multiselect");let r=n==="multiselect"?e.defaultValues?.join(", "):e.defaultValues?.[0];return[{name:"answer",label:e.question,type:n,placeholder:e.placeholder,required:e.required??!0,defaultValue:r,options:t.length>0?t:void 0,allowOther:e.allowOther,validationHint:e.validationHint,validation:n==="multiselect"?{minSelections:e.minSelections,maxSelections:e.maxSelections}:void 0}]}function ku(e){return typeof e=="string"?e?{value:e,label:e}:null:e&&typeof e.value=="string"&&e.value?{value:e.value,label:e.label??e.value,description:e.description}:null}function gn(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function al(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}var ge=x.cssPrefix;function Cu(e,t){switch(e.responseType){case"single-choice":return t.respSingleChoice;case"multi-choice":return t.respMultiChoice;case"confirmation":return t.respConfirmation;default:return t.respFreeText}}function cl({part:e,strings:t,active:n,onSubmit:r,onDecision:i}){let a=Y(()=>e.stateSig.value),l=Y(()=>e.approvalSig.value),s=Y(()=>sl(e.inputSig.value)),c=a.value==="output-available"||a.value==="output-error"||a.value==="output-denied"||a.value==="approval-responded"||l.value?.approved!==void 0,d=l.value!==void 0,u=(f,g)=>{d?i(e.toolCallId,g,f):s.value.responseType==="confirmation"?r(e.toolCallId,{confirmed:g}):r(e.toolCallId,g?{answer:f}:{})},_=s.value;if(c)return o(Eu,{part:e,strings:t,req:_});let m=!n;return o("div",{class:`${ge}-toolui${m?` ${ge}-toolui-stale`:""}`,"data-testid":k.toolAskInput,children:[o("div",{class:`${ge}-toolui-head`,children:[o("span",{class:`${ge}-toolui-badge ${ge}-toolui-badge-accent`,children:t.inputRequired}),o("span",{class:`${ge}-toolui-badge`,children:Cu(_,t)})]}),_.description?o("div",{class:`${ge}-toolui-desc`,children:_.description}):null,o(Zo,{label:t.inputQuestion,text:_.question}),m?o("p",{class:`${ge}-toolui-note`,children:t.stepNoLongerActive}):o(Tu,{req:_,strings:t,resolve:u})]})}function Tu({req:e,strings:t,resolve:n}){if(e.responseType==="confirmation")return o("div",{class:`${ge}-form-actions`,children:[o("span",{class:`${ge}-form-hint`,children:t.inputSubmitHint}),o("button",{type:"button",class:`${ge}-form-skip`,onClick:()=>n(void 0,!1),"data-testid":k.toolInputSkip,children:t.reject}),o("button",{type:"button",class:`${ge}-form-submit`,onClick:()=>n(void 0,!0),"data-testid":k.toolInputSubmit,children:t.approve})]});let r=ll(e).map(i=>(i.label=t.inputYourAnswer,i));return o(Cr,{fields:r,strings:t,submitLabel:t.inputSubmit,footerHint:t.inputSubmitHint,onSubmit:i=>n(i.answer??Object.values(i).join(", "),!0),skipLabel:e.required===!1?t.inputSkip:void 0,onSkip:e.required===!1?()=>n(void 0,!1):void 0,submitTestId:k.toolInputSubmit,skipTestId:k.toolInputSkip})}function Zo({label:e,text:t}){return o("div",{class:`${ge}-toolui-section`,children:[o("span",{class:`${ge}-toolui-label`,children:e}),o("p",{class:`${ge}-toolui-text`,children:t})]})}function Eu({part:e,strings:t,req:n}){let r=Y(()=>e.outputSig.value),i=Y(()=>e.approvalSig.value),a=i.value?.approved===!1,l=i.value?.approved!==void 0?i.value.reason??"":Iu(r.value);return o("div",{class:`${ge}-toolui`,"data-testid":k.toolDecision,children:[o("div",{class:`${ge}-toolui-head`,children:[o("span",{class:`${ge}-toolui-badge ${ge}-toolui-badge-accent`,children:t.inputBadge}),o("span",{class:`${ge}-toolui-badge`,children:a?t.inputSkipped:t.inputAnswered})]}),n.description?o("div",{class:`${ge}-toolui-desc`,children:n.description}):null,o(Zo,{label:t.inputQuestion,text:n.question}),!a&&l?o(Zo,{label:t.inputResponse,text:l}):null]})}function Iu(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="object"){let t=e;return"confirmed"in t?t.confirmed?"Yes":"No":typeof t.responseText=="string"&&t.responseText?t.responseText:Object.values(t).filter(n=>typeof n=="string"||typeof n=="number").join(", ")}return String(e)}var Lr=x.cssPrefix;function dl({part:e,strings:t}){let n=Y(()=>e.inputSig.value),r=Y(()=>e.outputSig.value),i=Y(()=>e.errorSig.value),a=Y(()=>e.stateSig.value),l=Y(()=>e.approvalSig.value);return Y(()=>!!Ar(n.value)||!!i.value||!!Ar(Qo(r.value))).value?o("details",{class:`${Lr}-toolui ${Lr}-toolui-collapsible`,"data-testid":k.toolCall,children:[o("summary",{class:`${Lr}-toolui-head`,children:[o("strong",{class:`${Lr}-toolui-title`,children:Ir(e.toolName)}),o(Rr,{state:a.value,approval:l.value,strings:t})]}),o(nt,{label:t.toolParameters,value:n.value}),r.value!==void 0?o(nt,{label:t.toolResult,value:r.value}):null,i.value?o(nt,{label:t.statusError,value:i.value,error:!0}):null]}):null}var Le=x.cssPrefix;function _l({message:e,strings:t,responseMode:n,showReasoning:r,showToolCalls:i,showSources:a,interactive:l=!1,tool:s}){let d=Y(()=>e.partsSig.value).value,u=Y(()=>e.partsSig.value.some(v=>v.kind==="text"&&v.textSig.value.length>0)),_=Y(()=>r&&e.partsSig.value.some(v=>v.kind==="reasoning")),m=e.role==="assistant"&&e.status==="streaming",f=n==="buffered"&&m,g=m&&!u.value,S=m&&!f&&!(_.value&&g),h=Ru(e.createdAt);return o("div",{class:`${Le}-bubble-row`,"data-role":e.role,"data-testid":ve(k.messageBubble,e.id),children:o("div",{class:`${Le}-bubble-col`,children:[o("div",{class:`${Le}-bubble`,children:[f?o(Ou,{label:t.loading}):d.map(v=>o(Au,{part:v,active:g,strings:t,showReasoning:r,showToolCalls:i,showSources:a,interactive:l,tool:s},Nu(v))),S&&o(Du,{}),e.status==="error"&&e.errorText?o("div",{class:`${Le}-error`,role:"alert",children:o("span",{children:e.errorText})}):null]}),h?o("time",{class:`${Le}-bubble-time`,dateTime:h.iso,title:h.full,children:h.short}):null]})})}function Ru(e){if(typeof e!="number"||!Number.isFinite(e))return null;try{let t=new Date(e);return{short:t.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),full:t.toLocaleString(void 0,{dateStyle:"full",timeStyle:"short"}),iso:t.toISOString()}}catch{return null}}function Au({part:e,active:t,strings:n,showReasoning:r,showToolCalls:i,showSources:a,interactive:l,tool:s}){switch(e.kind){case"step-start":return null;case"text":return o(Er,{textSig:e.textSig,doneSig:e.doneSig});case"reasoning":return r?o(Mu,{part:e,active:t,strings:n}):null;case"tool":return o(Lu,{part:e,strings:n,showToolCalls:i,interactive:l,tool:s});case"file":return e.mediaType.startsWith("image/")?o("img",{src:e.url,alt:"",loading:"lazy"}):o("a",{href:e.url,target:"_blank",rel:"noreferrer noopener",children:e.url});case"source":return a?o(ol,{part:e,strings:n}):null}}function Lu({part:e,strings:t,showToolCalls:n,interactive:r,tool:i}){let a=Y(()=>e.approvalSig.value!==void 0);if(i?.humanInLoop){if(Xs(e.toolName))return o(cl,{part:e,strings:t,active:r,onSubmit:i.onResult,onDecision:i.onDecision});if(a.value)return o(il,{part:e,strings:t,active:r,onDecision:i.onDecision})}return n?o(dl,{part:e,strings:t}):null}function Mu({part:e,active:t,strings:n}){return o("details",{class:`${Le}-reasoning`,open:t,"data-active":t?"true":void 0,children:[o("summary",{class:`${Le}-reasoning-summary`,children:o("span",{class:`${Le}-reasoning-label`,children:t?n.thinking:n.thoughts})}),o("div",{class:`${Le}-reasoning-body`,children:o(Er,{textSig:e.textSig,doneSig:e.doneSig})})]})}function Nu(e){switch(e.kind){case"text":case"reasoning":case"step-start":return`${e.kind}:${e.id}`;case"tool":return`tool:${e.toolCallId}`;case"file":return`file:${e.url}`;case"source":return`source:${e.sourceId}`}}function Du(){return o("span",{class:`${Le}-typing`,"aria-hidden":"true",children:[o("span",{}),o("span",{}),o("span",{})]})}function Ou({label:e}){return o("span",{class:`${Le}-loading`,role:"status",children:[o("span",{class:`${Le}-loading-spinner`,"aria-hidden":"true"}),o("span",{class:`${Le}-loading-label`,children:e})]})}var Ht=x.cssPrefix,ei=120,$u=350,Hu=1200;function ul({messagesSig:e,strings:t,responseMode:n,showReasoning:r,showToolCalls:i,showSources:a,loading:l,idle:s,tool:c,form:d,formMarkers:u,onFillForm:_}){let m=M(null),f=Y(()=>e.value),[g,S]=I(!1),[h,v]=I(!1),C=M(!1),b=M(!1),E=M(!1),D=M(0),V=()=>E.current||performance.now()-D.current<$u,G=M(0),ae=y=>{G.current=performance.now(),y.scrollTop=y.scrollHeight},K=f.value[0]?.id;nn(()=>{let y=m.current;if(!y||f.value.length===0||(C.current=!0,!f.value.some(it=>it.role==="user")))return;let z=()=>ae(y);z();let xe=new ResizeObserver(z);xe.observe(y);let Te=new MutationObserver(z);Te.observe(y,{childList:!0,subtree:!0,characterData:!0});let ye=setTimeout(()=>{xe.disconnect(),Te.disconnect()},300);return()=>{xe.disconnect(),Te.disconnect(),clearTimeout(ye)}},[K]);let U=M(0);T(()=>{let y=m.current,z=f.value,xe=U.current;if(U.current=z.length,!y||!C.current)return;if(z.slice(xe).some(ye=>ye.role==="user")){b.current=!1,ae(y);return}if(!z.some(ye=>ye.role==="user")||b.current||V())return;y.scrollHeight-y.scrollTop-y.clientHeight<ei&&ae(y)},[f.value.length]),T(()=>{let y=m.current;if(!y)return;let z=f.value.at(-1);if(!z||z.status!=="streaming"&&!f.value.some(ye=>ye.role==="user"))return;let xe=()=>{if(b.current||V())return;y.scrollHeight-y.scrollTop-y.clientHeight<ei*2&&ae(y)};if(z.status!=="streaming"){let ye=requestAnimationFrame(xe);return()=>cancelAnimationFrame(ye)}xe();let Te=new MutationObserver(xe);return Te.observe(y,{childList:!0,subtree:!0,characterData:!0}),()=>Te.disconnect()},[f.value]);let j=d?.form.id;nn(()=>{let y=m.current;!y||!j||b.current||f.value.some(z=>z.role==="user")&&ae(y)},[j]),T(()=>{let y=m.current;if(!y)return;let z=()=>S(y.scrollHeight-y.scrollTop-y.clientHeight>ei*2),xe,Te=()=>{z(),performance.now()-G.current>150&&(b.current=y.scrollHeight-y.scrollTop-y.clientHeight>8),v(!0),clearTimeout(xe),xe=setTimeout(()=>v(!1),Hu)},ye=()=>{b.current=!0},it=Ge=>{Ge.deltaY<0&&ye()},ht=0,Ft=Ge=>{ht=Ge.touches[0]?.clientY??0,E.current=!0},vt=Ge=>{(Ge.touches[0]?.clientY??0)>ht+4&&ye()},He=()=>{E.current=!1,D.current=performance.now()},zt=()=>{E.current=!0};return y.addEventListener("scroll",Te,{passive:!0}),y.addEventListener("wheel",it,{passive:!0}),y.addEventListener("touchstart",Ft,{passive:!0}),y.addEventListener("touchmove",vt,{passive:!0}),y.addEventListener("touchend",He,{passive:!0}),y.addEventListener("touchcancel",He,{passive:!0}),y.addEventListener("pointerdown",zt,{passive:!0}),window.addEventListener("pointerup",He,{passive:!0}),window.addEventListener("pointercancel",He,{passive:!0}),z(),()=>{y.removeEventListener("scroll",Te),y.removeEventListener("wheel",it),y.removeEventListener("touchstart",Ft),y.removeEventListener("touchmove",vt),y.removeEventListener("touchend",He),y.removeEventListener("touchcancel",He),y.removeEventListener("pointerdown",zt),window.removeEventListener("pointerup",He),window.removeEventListener("pointercancel",He),clearTimeout(xe)}},[]);let be=()=>{let y=m.current;y&&(b.current=!1,ae(y))},w=[],q="",ne=f.value.at(-1)?.id,ce=[...u??[]].toSorted((y,z)=>(y.createdAt??1/0)-(z.createdAt??1/0)),de=y=>o(js,{marker:y,strings:t,onFill:!d&&_?()=>_(y.formId):void 0},y.key),Me=y=>{for(let z=ce[0];z?.createdAt!==void 0&&!(y!==void 0&&z.createdAt>y);z=ce[0])ce.shift(),w.push(de(z))};for(let y of f.value){Me(y.createdAt);let z=Bu(y.createdAt);z&&z!==q&&(w.push(o("div",{class:`${Ht}-date-divider`,children:o("span",{class:`${Ht}-date-pill`,title:Fu(y.createdAt),children:zu(y.createdAt,t)})},`day:${z}`)),q=z),w.push(o(_l,{message:y,strings:t,responseMode:n,showReasoning:r,showToolCalls:i,showSources:a,interactive:!!s&&y.id===ne,tool:c},y.id))}for(let y of ce)w.push(de(y));return o("div",{class:`${Ht}-list-wrap`,children:[o("div",{ref:m,class:`${Ht}-list`,role:"log","aria-live":"polite","aria-relevant":"additions text","data-scrolling":h?"true":void 0,children:[l&&f.value.length===0?o("div",{class:`${Ht}-list-loading`,role:"status",children:t.conversationLoading}):null,w,d?o(qs,{form:d.form,strings:t,onSubmit:d.onSubmit,onSkip:d.onSkip}):null]}),g?o("button",{type:"button",class:`${Ht}-jump`,onClick:be,"aria-label":t.scrollToBottom,title:t.scrollToBottom,"data-testid":k.scrollToBottom,children:o(ks,{})}):null]})}function Bu(e){if(typeof e!="number"||!Number.isFinite(e))return"";let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function Fu(e){if(typeof e!="number"||!Number.isFinite(e))return"";try{return new Date(e).toLocaleDateString(void 0,{dateStyle:"full"})}catch{return""}}function zu(e,t){let n=new Date(e),r=a=>new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),i=Math.round((r(new Date)-r(n))/864e5);return i<=0?t.dateToday:i===1?t.dateYesterday:i<7?n.toLocaleDateString(void 0,{weekday:"long"}):n.toLocaleDateString(void 0,{month:"long",day:"numeric",year:"numeric"})}var Uu=["today","yesterday","lastWeek","older"];function Wu(e,t){let n=Date.parse(t);if(!Number.isFinite(n))return"older";let r=Math.floor((pl(e)-pl(n))/(1440*60*1e3));return r<=0?"today":r===1?"yesterday":r<7?"lastWeek":"older"}function fl(e,t){let n=new Map;for(let r of t){let i=Wu(e,r.lastMessageAt),a=n.get(i);a?a.push(r):n.set(i,[r])}return Uu.filter(r=>n.has(r)).map(r=>({bucket:r,conversations:n.get(r)}))}function pl(e){let t=new Date(e);return t.setUTCHours(0,0,0,0),t.getTime()}var Vu=B.scope("history"),Gu=3,Ku=6,qu={today:"dateToday",yesterday:"dateYesterday",lastWeek:"dateLastWeek",older:"dateOlder"};function ju(e,t,n){let r=Date.parse(e);return Number.isFinite(r)?new Date(r).toDateString()===new Date(t).toDateString()?new Intl.DateTimeFormat(n,{hour:"numeric",minute:"2-digit"}).format(r):t-r<10080*60*1e3?new Intl.DateTimeFormat(n,{weekday:"short"}).format(r):new Intl.DateTimeFormat(n,{month:"short",day:"numeric"}).format(r):""}function Mr({transport:e,strings:t,locale:n,persistence:r,visitorId:i,onSelect:a,onNewConversation:l}){let s=x.cssPrefix,c=e.peekConversations({visitorId:i}),[d,u]=I(c?"loaded":"loading"),[_,m]=I(c?.conversations??[]);T(()=>{let h=!1;return e.listConversations({visitorId:i}).then(v=>{if(h)return;let C=v.conversations??[];m(C),u("loaded"),r.saveHistoryCount(C.length)}).catch(v=>{h||(Vu.warn("listConversations failed",{err:v}),u("error"))}),()=>{h=!0}},[e,i,r]);let f=l?o("div",{class:`${s}-history-footer`,children:o("button",{type:"button",class:`${s}-history-new`,onClick:l,"data-testid":k.sidebarNewConversation,children:[o(is,{}),t.newConversation]})}):null;if(d==="loading"){let h=Math.min(r.loadHistoryCount()??Gu,Ku);return o(re,{children:[o("div",{class:`${s}-history`,"aria-busy":"true","aria-label":t.historyLoading,children:o("div",{class:`${s}-history-group`,"aria-hidden":"true",children:[o("div",{class:`${s}-history-heading`,children:o("span",{class:`${s}-skeleton ${s}-skeleton-heading`})}),o("div",{class:`${s}-history-card`,children:Array.from({length:Math.max(1,h)},(v,C)=>o("div",{class:`${s}-history-item ${s}-history-item-skeleton`,children:[o("span",{class:`${s}-history-avatar ${s}-skeleton`}),o("span",{class:`${s}-history-body`,children:[o("span",{class:`${s}-history-row`,children:[o("span",{class:`${s}-history-title`,children:o("span",{class:`${s}-skeleton ${s}-skeleton-title`})}),o("span",{class:`${s}-history-time`,children:o("span",{class:`${s}-skeleton ${s}-skeleton-time`})})]}),o("span",{class:`${s}-history-row`,children:o("span",{class:`${s}-history-preview`,children:o("span",{class:`${s}-skeleton ${s}-skeleton-preview`})})})]})]},C))})]})}),f]})}if(d==="error"||_.length===0)return o(re,{children:[o("div",{class:`${s}-history-empty`,children:t.historyEmpty}),f]});let g=Date.now(),S=fl(g,_);return o(re,{children:[o("div",{class:`${s}-history`,role:"list",children:S.map(h=>o("div",{class:`${s}-history-group`,children:[o("div",{class:`${s}-history-heading`,children:t[qu[h.bucket]]}),o("div",{class:`${s}-history-card`,children:h.conversations.map(v=>o("button",{type:"button",role:"listitem",class:`${s}-history-item`,onClick:()=>a(v),"data-closed":v.canContinue?void 0:"true","data-unread":(v.unreadCount??0)>0?"true":void 0,"data-testid":ve(k.historyItem,v.conversationId),children:[o("span",{class:`${s}-history-avatar`,"aria-hidden":"true",children:o(Ho,{})}),o("span",{class:`${s}-history-body`,children:[o("span",{class:`${s}-history-row`,children:[o("span",{class:`${s}-history-title`,children:v.title}),o("span",{class:`${s}-history-time`,children:ju(v.lastMessageAt,g,n)})]}),o("span",{class:`${s}-history-row`,children:[o("span",{class:`${s}-history-preview`,children:v.preview??(v.canContinue?t.historyContinue:t.conversationClosed)}),(v.unreadCount??0)>0?o("span",{class:`${s}-history-dot`}):null]})]})]},v.conversationId))})]},h.bucket))}),f]})}var ml=x.cssPrefix;function gl({suggestions:e,onPick:t}){return e.length===0?null:o("div",{class:`${ml}-suggestions`,role:"group","aria-label":"Suggested replies",children:e.map((n,r)=>o("button",{type:"button",class:`${ml}-suggestion`,onClick:()=>t(n),"data-testid":ve(k.suggestion,r),children:n.label},n.id))})}var Ce=x.cssPrefix;function hl(e){let{options:t,onClose:n}=e,r=t.strings,i=M(null);T(()=>{let c=i.current;if(!c)return;let d=Pr(c),u=_=>{_.key==="Escape"&&n?.()};return c.addEventListener("keydown",u),()=>{d(),c.removeEventListener("keydown",u)}},[n]);let a=M(null),l=H(c=>{a.current?.attachFromDrop(c)},[]),{visible:s}=wr({containerRef:i,onDrop:l});return br(i.current,t.mode==="modal"),o("div",{ref:i,class:`${Ce}-panel`,role:"dialog","aria-modal":"false","aria-label":r.panelTitle,style:{position:"relative"},"data-testid":k.panel,children:[o(ti,{...e,containerEl:i.current,dragOver:s,composerAttachApiRef:a}),o(ni,{poweredBy:e.options.poweredBy})]})}function ti(e){let{options:t,transport:n,feedback:r,bus:i,persistence:a,panelSize:l,view:s,canSend:c,isStreaming:d,loadingMessages:u,messagesSig:_,agent:m,suggestions:f,initialWidgetSize:g,visitorId:S,onClose:h,onBack:v,onClear:C,onToggleHistory:b,onSelectHistoryConversation:E,onNewConversation:D,onWidgetSizeChange:V,onSend:G,onStop:ae,onSuggestion:K,activeForm:U,formMarkers:j,onFormSubmit:be,onFormSkip:w,onFormFill:q,tool:ne,containerEl:ce,dragOver:de,composerAttachApiRef:Me}=e,y=t.strings,z;return U?z=null:c?z=o(re,{children:[o(gl,{suggestions:f,onPick:K}),o(zs,{options:t,transport:n,feedback:r,bus:i,isStreaming:d,onSend:G,onStop:ae,attachApiRef:Me})]}):z=o(Yu,{label:y.conversationClosed,ctaLabel:y.startNewConversation,onNewConversation:C}),o(re,{children:[s==="history"?o(Xu,{strings:y,onBack:b,onClose:h,showClose:xr(t.mode,l,t.actions)}):o("header",{class:`${Ce}-header`,"data-testid":k.panelHeader,children:[v?o("button",{type:"button",class:`${Ce}-icon-btn`,onClick:v,"aria-label":y.moduleBack,title:y.moduleBack,children:o(_n,{})}):null,m?o(Hs,{agent:m,strings:y}):o("h1",{children:y.panelTitle}),o(Ue,{panelProps:e,variant:"chat"})]}),s==="history"?o(Mr,{transport:n,strings:y,locale:t.locale,persistence:a,visitorId:S,onSelect:xe=>E(xe.conversationId),onNewConversation:D}):o(re,{children:[o(Us,{visible:de,strings:y}),o(ul,{messagesSig:_,strings:y,responseMode:t.responseMode,showReasoning:t.showReasoning,showToolCalls:t.showToolCalls,showSources:t.showSources,loading:u,idle:!d,tool:ne,form:U?{form:U,onSubmit:be,onSkip:w}:null,formMarkers:j,onFillForm:q}),z,o(Ju,{disclaimer:t.composerDisclaimer})]}),t.size.resize?.enabled?o(vr,{panelEl:ce,resize:t.size.resize,position:t.position,initialSize:g,onSizeChange:V,strings:y}):null]})}function Xu({strings:e,onBack:t,onClose:n,showClose:r}){return o("header",{class:`${Ce}-header`,children:[o("button",{type:"button",class:`${Ce}-icon-btn`,onClick:t,"aria-label":e.historyBack,title:e.historyBack,children:o(_n,{})}),o("h1",{children:e.historyTitle}),r?o("button",{type:"button",class:`${Ce}-icon-btn`,onClick:n,"aria-label":e.close,title:e.close,children:o(ze,{})}):null]})}function Yu({label:e,ctaLabel:t,onNewConversation:n}){return o("div",{class:`${Ce}-readonly-banner`,role:"note",children:[o("span",{class:`${Ce}-readonly-label`,children:e}),o("button",{type:"button",class:`${Ce}-readonly-cta`,onClick:n,children:t})]})}function Ju({disclaimer:e}){return e?o("div",{class:`${Ce}-composer-footer`,children:o("div",{class:`${Ce}-disclaimer`,children:e})}):null}function ni({poweredBy:e}){return e?o("div",{class:`${Ce}-poweredby-bar`,children:o(Qu,{logoUrl:e.logoUrl,text:e.text,href:e.href})}):null}function Qu({logoUrl:e,text:t,href:n}){let r=o(re,{children:[e?o("img",{class:`${Ce}-poweredby-logo`,src:e,alt:"",loading:"lazy"}):null,t?o("span",{children:t}):null]});return n?o("a",{class:`${Ce}-poweredby`,href:n,target:"_blank",rel:"noopener noreferrer",children:r}):o("span",{class:`${Ce}-poweredby`,children:r})}function vl(e){let t=M(e);t.current=e;let n=M(null);return n.current??(n.current=Zu(t)),n.current}function Zu(e){let t=O(null),n=new Set,r=c=>`${e.current.conversationId()??""}:${c}`,i=c=>c.frequency==="always"?!1:c.frequency==="conversation"?n.has(r(c.id)):c.id in e.current.persistence.loadFormsDone(),a=(c,d)=>{if(t.value)return;let u=e.current;if(c==="manual"){let _=u.forms.list.find(m=>m.id===d);_&&(t.value={form:_,trigger:"manual"});return}for(let _ of u.forms.byTrigger[c]??[]){let m=_.triggers.find(f=>f.kind===c);if(!(!m||!ep(m,u)||i(_)||!tp(_,u))){t.value={form:_,trigger:c};return}}},l=(c,d)=>{let u=t.value;if(!u)return;t.value=null;let{form:_,trigger:m}=u;_.frequency==="conversation"?n.add(r(_.id)):_.frequency!=="always"&&e.current.persistence.saveFormDone(_.id),e.current.onComplete(_,m,c,d)};return{activeForm:t,fire:a,refresh:()=>{let c=t.value;if(!c)return;let d=e.current.forms.list.find(u=>u.id===c.form.id);d&&d!==c.form&&(t.value={form:d,trigger:c.trigger})},complete:c=>l(c,!1),skip:()=>l({},!0)}}function ep(e,t){return e.kind==="after-messages"?t.messageCount()>=Number(e.param??0):e.kind==="page-area"?t.pageArea()===e.param:!0}function tp(e,t){let n=e.when;if(!n)return!0;if(n.missingContext?.length){let i=t.userContext()??{};if(n.missingContext.some(a=>i[a]!==void 0&&i[a]!==""))return!1}if(n.pageArea&&!(Array.isArray(n.pageArea)?n.pageArea:[n.pageArea]).includes(t.pageArea()??""))return!1;let r=t.messageCount();return!(n.minMessages!=null&&r<n.minMessages||n.maxMessages!=null&&r>n.maxMessages)}function bl(e){let t=x.cssPrefix,{site:n,blocks:r,strings:i,collapsed:a}=e,l=r?.navigation??[],s=r?.linkCards??[],c=a?i.expandSidebar:i.collapseSidebar;return o("aside",{class:`${t}-sidebar`,"data-collapsed":a?"true":"false","data-testid":k.sidebar,children:[o("div",{class:`${t}-sidebar-header`,children:[o(np,{site:n}),o("button",{type:"button",class:`${t}-sidebar-toggle`,"aria-label":c,"aria-expanded":a?"false":"true",title:c,onClick:e.onToggleCollapsed,"data-testid":k.sidebarToggle,children:o(rp,{collapsed:a})})]}),a?null:o(re,{children:[l.length>0?o("nav",{class:`${t}-sidebar-section`,"data-section":"navigation",children:o(op,{items:l})}):null,s.length>0?o("div",{class:`${t}-sidebar-section`,"data-section":"link-cards",children:o(ip,{items:s})}):null,e.showConversations?o("div",{class:`${t}-sidebar-conversations`,children:o(Mr,{transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,visitorId:e.visitorId,onSelect:e.onSelectConversation,onNewConversation:e.onNewConversation})}):null]})]})}function np({site:e}){let t=x.cssPrefix;if(e?.logo?.url){let n=e.logo.alt??e.title??"Logo";return o("picture",{children:[e.logoDark?.url?o("source",{srcset:e.logoDark.url,media:"(prefers-color-scheme: dark)"}):null,o("img",{class:`${t}-sidebar-logo`,src:e.logo.url,alt:n})]})}return o("div",{class:`${t}-sidebar-title`,children:e?.title??x.name})}function rp({collapsed:e}){return o("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","aria-hidden":"true",children:e?o("polyline",{points:"9 6 15 12 9 18"}):o("polyline",{points:"15 6 9 12 15 18"})})}function op({items:e}){let t=x.cssPrefix;return o("ul",{class:`${t}-sidebar-nav`,children:e.map(n=>o("li",{children:o("a",{class:`${t}-sidebar-nav-item`,href:n.href,target:n.href?"_blank":void 0,rel:n.href?"noreferrer":void 0,children:[n.icon?o("span",{class:`${t}-sidebar-nav-icon`,"data-icon":n.icon}):null,o("span",{class:`${t}-sidebar-nav-label`,children:n.label})]})},n.id??n.label))})}function ip({items:e}){let t=x.cssPrefix;return o("div",{class:`${t}-sidebar-cards`,children:e.map(n=>o("a",{class:`${t}-sidebar-card`,href:n.href,target:n.href?"_blank":void 0,rel:n.href?"noreferrer":void 0,children:[o("div",{class:`${t}-sidebar-card-label`,children:n.label}),n.description?o("div",{class:`${t}-sidebar-card-desc`,children:n.description}):null]},n.id??n.label))})}var xl=x.cssPrefix;function Pl(e){return o("main",{class:`${xl}-page-shell`,"data-sidebar-collapsed":e.sidebarCollapsed?"true":"false",children:[o(bl,{site:e.site,blocks:e.blocks,transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,visitorId:e.visitorId,showConversations:e.showConversations,onSelectConversation:e.onSelectConversation,onNewConversation:e.onNewConversation,collapsed:e.sidebarCollapsed,onToggleCollapsed:e.onToggleSidebarCollapsed}),o("section",{class:`${xl}-page-chat`,"aria-label":"Chat",children:e.children})]})}var yl=e=>Object.fromEntries(e.map(t=>[t,[]]));function Sl(e,t,n){let r=O({activeTab:e,stacks:yl(t)});return{sig:r,switchTab(i){r.value.activeTab!==i&&(r.value={...r.value,activeTab:i},n?.(i))},push(i){let a=r.value,l=a.stacks[a.activeTab]??[];r.value={...a,stacks:{...a.stacks,[a.activeTab]:[...l,i]}}},pop(){let i=r.value,a=i.stacks[i.activeTab]??[];a.length!==0&&(r.value={...i,stacks:{...i.stacks,[i.activeTab]:a.slice(0,-1)}})},reset(i){r.value={activeTab:i,stacks:yl(t)}}}}var wl=e=>e.stacks[e.activeTab]??[],kl=e=>wl(e).at(-1),Cl=e=>wl(e).length===0;var Tl={Icon:un};var rt=x.cssPrefix;function Nr({title:e,actions:t}){return o("header",{class:`${rt}-back-header`,"data-variant":"title",children:[o("span",{class:`${rt}-back-spacer`,"aria-hidden":"true"}),o("h1",{class:`${rt}-back-title`,children:e}),t??o("span",{class:`${rt}-back-spacer`,"aria-hidden":"true"})]})}function Dr({title:e,backLabel:t,onBack:n,actions:r,testid:i}){return o("header",{class:`${rt}-back-header`,"data-testid":i,children:[o("button",{type:"button",class:`${rt}-icon-btn`,onClick:n,"aria-label":t,title:t,children:o(_n,{})}),o("h1",{class:`${rt}-back-title`,children:e}),r??o("span",{class:`${rt}-back-spacer`,"aria-hidden":"true"})]})}var Bt=x.cssPrefix;function El({placeholder:e,onActivate:t}){return o("button",{type:"button",class:`${Bt}-home-search`,onClick:t,"data-testid":k.homeSearch,children:[o("span",{class:`${Bt}-home-search-text`,children:e}),o("span",{class:`${Bt}-home-search-icon`,"aria-hidden":"true",children:o(Fo,{})})]})}function Il({placeholder:e,value:t,onInput:n}){return o("div",{class:`${Bt}-home-search`,"data-input":"true",children:[o("input",{type:"search",class:`${Bt}-home-search-input`,placeholder:e,value:t,onInput:r=>n(r.currentTarget.value),"data-testid":k.helpSearch}),o("span",{class:`${Bt}-home-search-icon`,"aria-hidden":"true",children:o(Fo,{})})]})}var hn=x.cssPrefix;function Or({title:e,subtitle:t,onClick:n,testid:r}){return o("button",{type:"button",class:`${hn}-list-row`,onClick:n,"data-testid":r,children:[o("span",{class:`${hn}-list-row-body`,children:[o("span",{class:`${hn}-list-row-title`,children:e}),t?o("span",{class:`${hn}-list-row-sub`,children:t}):null]}),o("span",{class:`${hn}-list-row-chevron`,"aria-hidden":"true",children:o(Nt,{})})]})}var Rl=x.cssPrefix;function $e({tone:e="info",message:t,onRetry:n,strings:r}){return o("div",{class:`${Rl}-module-empty`,role:e==="error"?"alert":"status","aria-live":"polite",children:[o("span",{children:t}),n?o("button",{type:"button",class:`${Rl}-module-retry`,onClick:n,children:r.errorRetry}):null]})}var gt=x.cssPrefix,ap=B.scope("help"),sp=(e,t)=>t.url?e.push({kind:"iframe",url:t.url,title:t.title}):e.push({kind:"content",id:t.id,title:t.title});function lp(e){let t=new Map;for(let n of e){let r=n.categories?.[0]??"";(t.get(r)??t.set(r,[]).get(r)).push(n)}return[...t.entries()]}function Al(e,t){let n=t.toLowerCase(),r=n.indexOf(e);if(r!==-1)return 100-Math.min(r,99);let i=0;for(let a of e){if(i=n.indexOf(a,i),i===-1)return 0;i+=1}return 1}function cp(e,t){let n=t.toLowerCase().trim();return n?e.map(r=>({item:r,score:Math.max(Al(n,r.title)*2,Al(n,r.description??""))})).filter(r=>r.score>0).toSorted((r,i)=>i.score-r.score).map(r=>r.item):[]}function Ll({article:e,nav:t}){return o(Or,{title:e.title,subtitle:e.description,onClick:()=>sp(t,e),testid:ve(k.helpArticle,e.id)})}function dp({transport:e,strings:t,config:n,nav:r,bus:i,panelProps:a}){let l=n.contentTags,[s,c]=I("loading"),[d,u]=I(t.errorGeneric),[_,m]=I([]),[f,g]=I(""),[S,h]=I(0);T(()=>{let b=!1;return c("loading"),e.listContent({tags:l,sortBy:"order",limit:100}).then(E=>{if(b)return;let D=E.items??[];m(D),c("loaded"),i.emit("contentView",{section:"help",tags:l?.join(","),count:D.length})}).catch(E=>{b||(ap.warn("listContent (help) failed",{err:E}),u(ut(E,t)),c("error"))}),()=>{b=!0}},[e,l,S,i]);let v=ke(()=>cp(_,f),[_,f]);T(()=>{let b=f.trim();if(!b)return;let E=setTimeout(()=>i.emit("contentSearch",{queryLength:b.length,hitCount:v.length}),600);return()=>clearTimeout(E)},[f,v,i]);function C(){return f.trim().length>0?v.length===0?o($e,{message:t.helpSearchEmpty,strings:t}):o("div",{class:`${gt}-help-card`,children:v.map(b=>o(Ll,{article:b,nav:r},b.id))}):s==="loading"?o($e,{message:t.helpLoading,strings:t}):s==="error"?o($e,{tone:"error",message:d,onRetry:()=>h(b=>b+1),strings:t}):_.length===0?o($e,{message:t.helpEmpty,strings:t}):lp(_).map(([b,E])=>o("section",{class:`${gt}-help-group`,children:[b?o("h2",{class:`${gt}-help-section-title`,children:b}):null,o("div",{class:`${gt}-help-card`,children:E.map(D=>o(Ll,{article:D,nav:r},D.id))})]},b))}return o("div",{class:`${gt}-module`,children:[o(Nr,{title:t.helpTitle,actions:o(Ue,{panelProps:a,variant:"plain"})}),o("div",{class:`${gt}-module-pad`,children:o(Il,{placeholder:t.helpSearchPlaceholder,value:f,onInput:g})}),o("div",{class:`${gt}-help-list`,children:C()})]})}var Ml={Icon:Bo,Root:e=>o(dp,{...e})};var Nl=x.cssPrefix;function ri({onClick:e,children:t,testid:n}){return e?o("button",{type:"button",class:`${Nl}-home-card`,"data-interactive":"true",onClick:e,"data-testid":n,children:t}):o("div",{class:`${Nl}-home-card`,"data-testid":n,children:t})}var oe=x.cssPrefix,Dl=B.scope("home");function _p(e){let t=e.options.userContext?.name,n=e.config.greetingText?we(e.strings,e.config.greetingText):void 0;return n?{title:t?n.replace("{name}",t):n.replace(/\s*\{name\}\s*/," ").trim(),subtitle:e.strings.homeGreetingLead}:t?{title:e.strings.homeGreetingNamed.replace("{name}",t),subtitle:e.strings.homeGreetingLead}:{title:e.strings.homeGreeting}}var up=(e,t)=>t.url?e.push({kind:"iframe",url:t.url,title:t.title}):e.push({kind:"content",id:t.id,title:t.title});function pp(e){let{transport:t,strings:n,config:r,nav:i,bus:a,panelProps:l}=e,[s,c]=I(null),[d,u]=I([]),_=r.contentTags?.join(",");T(()=>{if(!r.showRecentConversations)return;let v=!1;return t.listConversations({limit:1}).then(C=>!v&&c(C.conversations?.[0]??null)).catch(C=>!v&&Dl.warn("listConversations (home) failed",{err:C})),()=>{v=!0}},[t,r.showRecentConversations]),T(()=>{if(!r.contentTags?.length)return;let v=!1;return t.listContent({tags:r.contentTags,limit:6}).then(C=>{if(v)return;let b=C.items??[];u(b),a.emit("contentView",{section:"home",tags:_,count:b.length})}).catch(C=>!v&&Dl.warn("listContent (home) failed",{err:C})),()=>{v=!0}},[t,_,a]);let m=_p(e),f=r.userAvatars??[],g=r.status,S=g?.text?we(n,g.text):n.homeStatus,h=r.contentBlockTitle?we(n,r.contentBlockTitle):n.homeContentTitle;return o("div",{class:`${oe}-module ${oe}-home`,"data-testid":k.homeView,children:o("div",{class:`${oe}-home-scroll`,children:[o("div",{class:`${oe}-home-hero`,children:[o("div",{class:`${oe}-home-hero-top`,children:[r.brandName?o("span",{class:`${oe}-home-brand`,"data-testid":k.homeBrand,children:r.brandName}):o("span",{class:`${oe}-home-brand-spacer`,"aria-hidden":"true"}),o("div",{class:`${oe}-home-hero-actions`,children:[f.length>0?o("div",{class:`${oe}-home-avatars`,children:f.map(v=>o("span",{class:`${oe}-home-avatar`,title:v.role?`${v.name} \xB7 ${v.role}`:v.name,children:v.avatar?o("img",{src:v.avatar,alt:"",loading:"lazy"}):o("span",{children:yr(v.name)})},v.name))}):null,o(Ue,{panelProps:l,variant:"plain"})]})]}),r.showGreeting!==!1?o(re,{children:[o("h1",{class:`${oe}-home-greeting`,"data-testid":k.homeGreeting,children:m.title}),m.subtitle?o("p",{class:`${oe}-home-lead`,children:m.subtitle}):null]}):null]}),o("div",{class:`${oe}-home-cards`,children:[r.showSearchBar!==!1?o(El,{placeholder:n.homeSearchPlaceholder,onActivate:()=>i.switchToLayout("help")}):null,s?o(ri,{onClick:()=>i.selectConversation(s.conversationId),testid:k.homeRecent,children:o("div",{class:`${oe}-home-recent-row`,"data-unread":(s.unreadCount??0)>0?"true":void 0,children:[o("span",{class:`${oe}-home-recent-avatar`,"aria-hidden":"true",children:o(un,{})}),o("span",{class:`${oe}-home-recent-body`,children:[o("span",{class:`${oe}-home-recent-title`,children:s.title}),s.preview?o("span",{class:`${oe}-home-recent-preview`,children:s.preview}):null]}),(s.unreadCount??0)>0?o("span",{class:`${oe}-home-recent-dot`,"aria-label":"Unread"}):null]})}):null,g?o(ri,{onClick:g.url?()=>i.push({kind:"iframe",url:g.url,title:S}):void 0,children:o("div",{class:`${oe}-home-status`,"data-level":g.level??"operational",children:[o("span",{class:`${oe}-home-status-icon`,"aria-hidden":"true",children:o(Ts,{})}),o("span",{class:`${oe}-home-status-text`,children:S})]})}):null,d.length>0?o("section",{class:`${oe}-home-content`,children:[o("div",{class:`${oe}-home-content-title`,children:h}),o("div",{class:`${oe}-home-content-list`,children:d.map(v=>o(Or,{title:v.title,subtitle:v.description,onClick:()=>up(i,v),testid:ve(k.homeContentRow,v.id)},v.id))})]}):null]})]})})}var Ol={Icon:Es,Root:e=>o(pp,{...e})};var ot=x.cssPrefix,fp=B.scope("news");function mp({transport:e,strings:t,config:n,nav:r,bus:i,panelProps:a}){let l=n.contentTags,[s,c]=I("loading"),[d,u]=I(t.errorGeneric),[_,m]=I([]),[f,g]=I(0);T(()=>{let h=!1;return c("loading"),e.listContent({tags:l,sortBy:"publishedAt",sortOrder:"desc"}).then(v=>{if(h)return;let C=v.items??[];m(C),c("loaded"),i.emit("contentView",{section:"news",tags:l?.join(","),count:C.length})}).catch(v=>{h||(fp.warn("listContent (news) failed",{err:v}),u(ut(v,t)),c("error"))}),()=>{h=!0}},[e,l,f,i]);function S(){return s==="loading"?o($e,{message:t.newsLoading,strings:t}):s==="error"?o($e,{tone:"error",message:d,onRetry:()=>g(h=>h+1),strings:t}):_.length===0?o($e,{message:t.newsEmpty,strings:t}):o("div",{class:`${ot}-news-list`,children:_.map(h=>o("button",{type:"button",class:`${ot}-news-card`,onClick:()=>r.push({kind:"content",id:h.id,title:h.title}),"data-testid":ve(k.newsItem,h.id),children:[h.image?o("img",{class:`${ot}-news-hero`,src:h.image,alt:"",loading:"lazy"}):null,o("span",{class:`${ot}-news-body`,children:[o("span",{class:`${ot}-news-title`,children:h.title}),h.description?o("span",{class:`${ot}-news-summary`,children:h.description}):null]})]},h.id))})}return o("div",{class:`${ot}-module`,children:[o(Nr,{title:t.newsTitle,actions:o(Ue,{panelProps:a,variant:"plain"})}),o("div",{class:`${ot}-module-scroll`,children:S()})]})}var $l={Icon:Is,Root:e=>o(mp,{...e})};var $r={chat:Tl,home:Ol,help:Ml,news:$l};var vn=x.cssPrefix;function Hl({modules:e,activeTab:t,strings:n,unreadCount:r,onSelect:i}){return o("nav",{class:`${vn}-tabbar`,role:"tablist","aria-label":n.panelTitle,children:e.map(a=>{let l=$r[a.layout].Icon,s=a.id===t,c=a.layout==="chat"&&r>0?r>9?"9+":String(r):null;return o("button",{type:"button",role:"tab","aria-selected":s,class:`${vn}-tab`,onClick:()=>i(a.id),"data-testid":ve(k.tab,a.id),children:[o("span",{class:`${vn}-tab-icon`,"aria-hidden":"true",children:[o(l,{}),c?o("span",{class:`${vn}-tab-badge`,"data-testid":k.tabBadge,children:c}):null]}),o("span",{class:`${vn}-tab-label`,children:we(n,a.label)})]},a.id)})})}var Bl=x.cssPrefix,gp="allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads";function Fl({url:e,title:t,strings:n,onBack:r,actions:i}){return o("div",{class:`${Bl}-module`,children:[o(Dr,{title:t||n.moduleBack,backLabel:n.moduleBack,onBack:r,actions:i}),o("iframe",{class:`${Bl}-content-frame`,src:e,title:t||"content",sandbox:gp,referrerpolicy:"no-referrer",loading:"lazy",allow:"fullscreen"})]})}var bn=x.cssPrefix,hp=B.scope("content"),vp=5e3;function zl({id:e,title:t,transport:n,strings:r,bus:i,onBack:a,actions:l}){let[s,c]=I(null),[d,u]=I(!1),[_,m]=I(0),f=H(()=>{u(!1),c(null),m(h=>h+1)},[]);T(()=>{let h=!1;return n.listContent({ids:[e],limit:1}).then(v=>{if(h)return;let C=v.items[0];C?(c(C),i.emit("contentOpen",{contentId:e,tags:C.tags?.length?C.tags.join(","):void 0})):u(!0)}).catch(v=>{h||(hp.warn("listContent (reader) failed",{err:v}),u(!0))}),()=>{h=!0}},[n,e,_,i]),T(()=>{if(!s)return;let h=setTimeout(()=>i.emit("contentRead",{contentId:e}),vp);return()=>clearTimeout(h)},[s,e,i]);let g=H(h=>{let C=h.target?.closest?.("a")?.getAttribute("href")??"";C&&!C.startsWith("#")&&i.emit("contentLinkClick",{contentId:e})},[i,e]);function S(){return d?o($e,{tone:"error",message:r.errorGeneric,onRetry:f,strings:r}):s===null?o($e,{message:r.contentLoading,strings:r}):o("article",{class:`${bn}-content`,"data-testid":k.contentView,onClick:g,children:[s.image?o("img",{class:`${bn}-content-hero`,src:s.image,alt:"",loading:"lazy"}):null,s.description?o("p",{class:`${bn}-content-subtitle`,children:s.description}):null,o(rl,{text:s.content??""})]})}return o("div",{class:`${bn}-module`,children:[o(Dr,{title:s?.title||t||r.moduleBack,backLabel:r.moduleBack,onBack:a,actions:l,testid:k.backHeader}),o("div",{class:`${bn}-module-scroll`,"data-testid":k.contentScroll,children:S()})]})}var Hr=x.cssPrefix;function Ul({panelProps:e,enabledModules:t,nav:n,bus:r,unreadCount:i,onSelectConversation:a,onStartNewConversation:l,onSetPanelSize:s}){let c=e.options,d=c.strings,u=M(null),_=M(new Set);T(()=>{let j=u.current;if(!j)return;let be=Pr(j),w=q=>{q.key==="Escape"&&e.onClose?.()};return j.addEventListener("keydown",w),()=>{be(),j.removeEventListener("keydown",w)}},[e.onClose]);let m=M(null),f=H(j=>{m.current?.attachFromDrop(j)},[]),{visible:g}=wr({containerRef:u,onDrop:f});br(u.current,c.mode==="modal");let S=Y(()=>n.sig.value).value,h=kl(S),v=c.modules.byId[S.activeTab],C=h?.kind==="iframe"||h?.kind==="content",b=t.length>1&&(Cl(S)||!C),E=M(null);T(()=>{if(C&&E.current===null)E.current=e.panelSize,e.panelSize==="normal"&&s("expanded");else if(!C&&E.current!==null){let j=E.current;E.current=null,s(j)}},[C]);let D={push:n.push,pop:n.pop,switchTab:n.switchTab,switchToLayout:j=>{let be=t.find(w=>w.layout===j);be&&n.switchTab(be.id)},selectConversation:a,startNewConversation:l},V=j=>({options:c,transport:e.transport,strings:d,config:j,visitorId:e.visitorId,nav:D,bus:r,panelProps:e}),G=o(Ue,{panelProps:e,variant:"plain"});v&&_.current.add(v.id);let ae=t.filter(j=>_.current.has(j.id)),K=j=>{if(j.layout==="chat")return o(ti,{...e,containerEl:u.current,dragOver:g,composerAttachApiRef:m});let be=$r[j.layout].Root;return be?o(be,{...V(j)}):null},U=()=>h?.kind==="iframe"?o(Fl,{url:h.url,title:h.title,strings:d,onBack:n.pop,actions:G}):h?.kind==="content"?o(zl,{id:h.id,title:h.title,transport:e.transport,strings:d,bus:r,onBack:n.pop,actions:G}):null;return o("div",{ref:u,class:`${Hr}-panel ${Hr}-messenger`,role:"dialog","aria-modal":"false","aria-label":d.panelTitle,style:{position:"relative"},"data-testid":k.messengerHome,children:[o("div",{class:`${Hr}-messenger-body`,children:[ae.map(j=>o("div",{class:`${Hr}-messenger-pane`,hidden:C||j.id!==v?.id,children:K(j)},j.id)),U()]}),b?o(Hl,{modules:t,activeTab:S.activeTab,strings:d,unreadCount:i,onSelect:n.switchTab}):null,o(ni,{poweredBy:c.poweredBy}),c.size.resize?.enabled&&!(v?.layout==="chat"&&!h)?o(vr,{panelEl:u.current,resize:c.size.resize,position:c.position,initialSize:e.initialWidgetSize,onSizeChange:e.onWidgetSizeChange,strings:d}):null]})}var xn=x.cssPrefix;function Wl({strings:e,onClose:t}){return o("div",{class:`${xn}-panel ${xn}-modules-empty`,role:"dialog","aria-label":e.panelTitle,"data-testid":k.modulesEmpty,children:[t?o("button",{type:"button",class:`${xn}-icon-btn ${xn}-modules-empty-close`,onClick:t,"aria-label":e.close,title:e.close,children:o(ze,{})}):null,o("p",{class:`${xn}-modules-empty-text`,children:e.modulesEmpty})]})}function Vl({callout:e,persistence:t}){let n=e?.text??"",r=e?.persistent??!0,[i,a]=I(()=>r?!1:t.loadCalloutDismissed(n));T(()=>{a(r?!1:t.loadCalloutDismissed(n))},[n,r,t]);let l=H(()=>{a(!0),r||t.saveCalloutDismissed(n)},[t,n,r]);return{dismissed:i,dismissCallout:l}}var W=B.scope("app"),Br=x.cssPrefix;function Gl(e,t){return Ya({...e,text:we(t,e.text)})}function bp(e){return e.partsSig.value.find(t=>t.kind==="text")?.textSig.value??""}function xp(e){let t=e.partsSig.value.filter(n=>n.kind==="tool");return t.length>0&&t.every(n=>{let r=n.stateSig.value;return r==="output-available"||r==="output-error"||r==="output-denied"||r==="approval-responded"})}function Kl({options:e,hostElement:t,bus:n}){let[r]=I(()=>Tt(e.widgetId,e.storage,e.aiAgentDeploymentId)),[i,a]=I(()=>r.getVisitorId()),l=r.loadUserPrefs(),[s,c]=I(()=>l.locale??e.locale),[d,u]=I(()=>l.themeMode??e.themeMode),[_,m]=I(()=>l.textSize??e.textSize),f=dt(r.loadConversationId()),g=dt([]),S=dt(0),[h,v]=I(!1),[C,b]=I([]);function E(){let p=e.modules.list,P=new Set(p.map(N=>N.id)),L=r.loadActiveModule();return L&&P.has(L)?L:p[0]?.id??""}function D(){return e.modules.list.find(p=>p.layout==="chat")?.id}let V=M();if(!V.current){let p=e.modules.list.map(P=>P.id);V.current=Sl(E(),p,P=>r.saveActiveModule(P))}let G=V.current,ae=M(void 0);ae.current=D();let[K,U]=I(!1),[j,be]=I(null),[w,q]=I(!1),ne=e.mode==="standalone"||e.mode==="inline",ce=M(sn(e,Lt(),r.loadPanelOpen(),r.loadPanelSize())),[de,Me]=I(ce.current.panelOpen),[y,z]=I(ce.current.panelOpen),xe=M(y);xe.current=y;let Te=M(!1),ye=M(void 0);T(()=>{de&&z(!0)},[de]);let it=M(!1),[ht,Ft]=I(!1),{dismissed:vt,dismissCallout:He}=Vl({callout:e.launcher.callout,persistence:r}),zt=e.launcher.callout?.persistent??!0,Ge=H(()=>{W.info("calloutDismiss"),n.emit("calloutDismiss",void 0),He()},[n,He]),[Ie,bt]=I(ce.current.panelSize),ai=M(!1),[Zl,Wr]=I("chat"),[Ut,Wt]=I(!0),[Ke,Pn]=I(!1),[ec,si]=I(null),[Vr,yn]=I([]),[Sn,wn]=I(null),Vt=M(e.strings),[tc,nc]=I(void 0),[rc,oc]=I(void 0),[ic,ac]=I(()=>r.loadSidebarCollapsed()??!1),[Gr,sc]=I({}),[Z]=I(()=>new ur({agentApiBaseUrl:e.agentApiBaseUrl,dataApiBaseUrl:e.dataApiBaseUrl,auth:$a({publicKey:e.publicKey,aiAgentDeploymentId:e.aiAgentDeploymentId,publicKeyHeader:"x-public-key"}),endpoints:e.endpoints})),[Be]=I(()=>new pr(g)),[se]=I(()=>new gr(e.sound,e.haptics)),Fe=H(p=>{r.patchUserPrefs(p),Z.saveUserPrefs(r.loadUserPrefs()).catch(P=>{W.warn("saveUserPrefs failed",{err:P})})},[r,Z]);T(()=>{l.soundMuted!==void 0&&se.setMuted(l.soundMuted)},[]),T(()=>{t.dataset.theme=d},[t,d,e]),T(()=>{t.dataset.textSize=_},[t,_,e]),T(()=>{se.update(e.sound,e.haptics)},[se,e.sound,e.haptics]),T(()=>()=>se.destroy(),[se]),T(()=>{let p=!0;return se.mutedSig.subscribe(P=>{if(p){p=!1;return}Fe({soundMuted:P})})},[se,Fe]),T(()=>{ai.current||!e.size.initialSize||(ai.current=!0,!r.loadPanelSize()&&bt(Ao(e.mode,e.size,Lt())))},[e.mode,e.size,r]),T(()=>{if(!K||it.current)return;it.current=!0;let p=sn(e,Lt(),r.loadPanelOpen(),r.loadPanelSize());Me(p.panelOpen),bt(p.panelSize)},[K,e,r]);let li=M(!1),ci=M(!1),kn=M(null);T(()=>{if(!(!K||li.current)){if(li.current=!0,ci.current){let p=ae.current;p&&G.switchTab(p);return}G.reset(E())}},[K]);let Cn=H(p=>{!p||p.length===0||(g.value=p.map(P=>Gl(P,Vt.current)))},[g]),Kr=M(null),Tn=H(async p=>{try{let{formSubmissions:P}=await(p?Z.bootstrap(p):Kr.current??Z.bootstrap()),L=new Map;return P.forEach((N,F)=>L.set(N.formId,F)),P.filter((N,F)=>!N.skipped||L.get(N.formId)===F).map((N,F)=>({key:`wire:${N.formId}:${N.createdAt??F}`,formId:N.formId,outcome:N.skipped?"skipped":"submitted",createdAt:_r(N.createdAt),values:N.values}))}catch(P){return W.debug("bootstrap failed \u2014 no form markers (non-fatal)",{err:P}),[]}},[Z]),Gt=M(0),Kt=H((p,P)=>{let L=[...p.map(fe=>fe.createdAt),...P.map(fe=>fe.createdAt)].filter(fe=>fe!==void 0),N=(L.length?Math.min(...L):Date.now())-1,F=(fe,qe)=>`${fe}|${qe}`,A=new Set(p.map(fe=>F(fe.role,bp(fe))));return[...(ye.current?.messages??[]).filter(fe=>!A.has(F(fe.role,we(Vt.current,fe.text)))).map(fe=>{let qe=Gl(fe,Vt.current);return qe.createdAt=N,qe}),...p]},[]),qr=H(async p=>{let P=Gt.current,L=()=>P!==Gt.current;v(!0);try{let[N,F]=await Promise.all([Z.loadConversation(p),Tn()]);if(L())return;let A=(N.messages??[]).map(Oo);b(F);let Se=kn.current?[kn.current]:[];A.length||Se.length?(g.value=[...Kt(A,F),...Se],Wt(N.canContinue??!0),yn(N.suggestions??[])):g.value=Kt([],F)}catch(N){if(L())return;W.warn("loadThread failed; resetting conversationId",{err:N,conversationId:p}),f.value=void 0,r.saveConversationId(void 0)}finally{L()||v(!1)}},[Z,Tn,g,f,r,Kt]),qt=H(async({newConversation:p})=>{let P=++Gt.current,L=()=>P!==Gt.current,N=f.value,F=p||!N?Ne():N;F!==N&&(f.value=F,r.saveConversationId(F));let A;try{A=await Z.handshake({visitorId:i,conversationId:F,userPrefs:r.loadUserPrefs(),locale:s})}catch(fe){if(L())return;n.emit("error",fe),e.onError?.(fe),p||U(!0);return}if(L())return;if(A.visitorId&&A.visitorId!==i&&(W.info("visitor rebound",{previous:i,current:A.visitorId,reason:A.rebind?.visitorId}),r.setVisitorId(A.visitorId),a(A.visitorId),n.emit("visitorRebound",{previous:i,current:A.visitorId,reason:A.rebind?.visitorId})),A.conversationId&&A.conversationId!==F&&(W.info("conversation rebound",{previous:F,current:A.conversationId,reason:A.rebind?.conversationId}),n.emit("conversationRebound",{previous:F,current:A.conversationId,reason:A.rebind?.conversationId})),A.agent&&si(A.agent),e.mode==="page"&&(A.site&&Da(A.site)?nc(A.site):A.site&&W.warn("invalid site config, using fallback",{site:A.site}),A.blocks&&Oa(A.blocks)?oc(A.blocks):A.blocks&&W.warn("invalid blocks config, using fallback",{blocks:A.blocks})),A.userPrefs&&!p&&(r.saveUserPrefs(A.userPrefs),A.userPrefs.locale&&c(A.userPrefs.locale),A.userPrefs.soundMuted!==void 0&&se.setMuted(A.userPrefs.soundMuted),A.userPrefs.themeMode&&u(A.userPrefs.themeMode),A.userPrefs.textSize&&m(A.userPrefs.textSize)),ye.current=A.welcome,p||n.emit("handshake",A),A.welcome?.suggestions){let fe=Vt.current;yn(A.welcome.suggestions.map(qe=>({...qe,label:we(fe,qe.label),...qe.text===void 0?{}:{text:we(fe,qe.text)}})))}!p&&N&&A.conversationId===N?xe.current?qr(N):Te.current=!0:(f.value=A.conversationId,r.saveConversationId(A.conversationId),Cn(A.welcome?.messages)),p||U(!0)},[Z,i,r,e,n,f,se,Cn,qr,s]),jt=JSON.stringify(e.userContext??null),lc=JSON.stringify(e.pageContext??null),cc=JSON.stringify(Gr);T(()=>{let p=Object.keys(Gr).length?{...Gr,...e.userContext}:e.userContext;Z.setContext(p,Pp(e.pageContext))},[Z,jt,lc,cc]);let Re=Ct(s,e.availableLocales,e.defaultLocale);T(()=>{Z.setLocale(Re)},[Z,Re]),T(()=>{t.dir=Hi(Re)?"rtl":"ltr"},[t,Re]),T(()=>{Re!==s&&c(Re)},[Re,s]);let dc=H(async p=>{let P=null;try{for await(let L of p.iter){if(!P){P=Do(),kn.current=P,Be.attach(P),g.value=[...g.value,P],Pn(!0),wn(()=>p.cancel),ci.current=!0;let N=ae.current;N&&G.switchTab(N),W.info("resumed in-flight reply on mount")}Be.apply(L.chunk),L.chunk.type==="finish"&&L.chunk.canContinue===!1&&Wt(!1)}P&&(P.status="complete",se.play("messageReceived"),oi(n,e,"assistant",$o(P)))}catch(L){P&&(P.status="error",P.errorText=ut(L,e.strings),se.play("error")),W.debug("mount resume ended without completing",{err:L})}finally{kn.current=null,P&&(Be.detach(),Pn(!1),wn(null),g.value=[...g.value])}},[Be,g,se,n,e,G]),di=M(null);T(()=>{let p=f.value;return p&&Z.primeIdentity(i,p),qt({newConversation:!1}),()=>{Gt.current++,di.current?.cancel()}},[]),T(()=>{if(y){if(Kr.current=Z.bootstrap(),(async()=>{try{let p=await Kr.current;be(Qt((p??{forms:[]}).forms,Re))}catch(p){W.debug("bootstrap failed \u2014 treating as no forms",{err:p})}finally{q(!0)}})(),Te.current){Te.current=!1;let p=f.value;p&&qr(p)}if(f.value){let p=Z.resumeStream();di.current=p,dc(p)}}},[y]);let En=M(null);T(()=>{if(!y)return;if(En.current===null){En.current=Re;return}if(En.current===Re)return;En.current=Re;let p=!1;return Z.bootstrap().then(P=>{p||be(Qt((P??{forms:[]}).forms,Re))}).catch(P=>W.debug("forms re-localize failed \u2014 keeping current copy",{err:P})),()=>{p=!0}},[y,Re,Z]);let _i=M(jt);T(()=>{!K||_i.current===jt||(_i.current=jt,qt({newConversation:!1}))},[jt,K,qt]),T(()=>{Qn(t,dr(e.mode,Ie,de))},[t,de,Ie,e.mode]),T(()=>{if(e.mode!=="modal"||!de)return;let p=P=>{P.composedPath().some(F=>F instanceof HTMLElement&&F.classList.contains(`${x.cssPrefix}-panel`))||Me(!1)};return t.addEventListener("click",p),()=>t.removeEventListener("click",p)},[t,de,e.mode]),T(()=>{if(e.mode!=="drawer"||!de)return;let p=P=>{P.key==="Escape"&&Me(!1)};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[de,e.mode]);let In=H(async(p,{continueExisting:P})=>{let L=f.value??Ne();f.value||(f.value=L,r.saveConversationId(L));let N=(P?g.value:g.value.slice(0,-1)).filter(Se=>!Se.ephemeral),F=Va({messages:N.map(Ja),conversationId:L,messageId:p.serverMessageId??p.id,tools:e.features.tools,visitorId:i,userPrefs:r.loadUserPrefs()});Pn(!0);let A=Z.sendMessage(F);wn(()=>A.cancel);try{for await(let Se of A.iter)Be.apply(Se.chunk),Se.chunk.type==="finish"&&Se.chunk.canContinue===!1&&Wt(!1);p.status="complete",se.play("messageReceived"),oi(n,e,"assistant",$o(p))}catch(Se){p.status="error",p.errorText=ut(Se,e.strings),se.play("error"),n.emit("error",Se),e.onError?.(Se)}finally{Be.detach(),Pn(!1),wn(null),g.value=[...g.value]}},[Z,Be,g,f,e,n,se,r,i]),Rn=H((p,P)=>{if(Ke)return;let L=g.value.at(-1),N=L?.partsSig.value.find(F=>F.kind==="tool"&&F.toolCallId===p);if(!L||!N){W.warn("decideTool: tool part not found",{toolCallId:p});return}P(N),L.partsSig.value=[...L.partsSig.value],xp(L)&&(L.status="streaming",Be.attach(L),In(L,{continueExisting:!0}))},[Ke,g,Be,In]),ui=H((p,P)=>{W.info("toolResult",{toolCallId:p}),n.emit("toolResult",{toolCallId:p}),Rn(p,L=>{L.outputSig.value=P,L.stateSig.value="output-available"})},[n,Rn]),pi=H((p,P,L)=>{W.info("toolDecision",{toolCallId:p,approved:P}),n.emit("toolDecision",{toolCallId:p,approved:P}),Rn(p,N=>{let F=N.approvalSig.value?.id??p;N.approvalSig.value={id:F,approved:P,reason:L},N.stateSig.value="approval-responded"})},[n,Rn]),_c=ke(()=>({humanInLoop:e.features.humanInLoop,onResult:ui,onDecision:pi}),[e.features.humanInLoop,ui,pi]),uc=()=>g.value.reduce((p,P)=>p+(P.role==="user"?1:0),0),xt=e.forms.list.length>0?e.forms:j??e.forms,_e=vl({forms:xt,persistence:r,userContext:()=>e.userContext,messageCount:uc,pageArea:()=>e.pageContext?.area?String(e.pageContext.area):void 0,conversationId:()=>f.value,onComplete:(p,P,L,N)=>{W.info("formSubmit",{formId:p.id,trigger:P,skipped:N}),n.emit("formSubmit",{formId:p.id,values:L,skipped:N}),b(A=>[...A.filter(Se=>!(Se.formId===p.id&&Se.outcome==="skipped")),{key:`local:${p.id}:${Date.now()}`,formId:p.id,outcome:N?"skipped":"submitted",createdAt:Date.now(),...N?{}:{values:L}}]);let F=f.value??Ne();f.value||(f.value=F,r.saveConversationId(F),Z.primeIdentity(void 0,F)),!N&&p.mirrorToContext&&sc(A=>({...A,...L})),Z.submitForm({formId:p.id,conversationId:F,trigger:P,values:L,skipped:N})}}),pc=Y(()=>_e.activeForm.value);T(()=>{_e.refresh()},[xt,_e]);let fi=e.pageContext?.area?String(e.pageContext.area):void 0,fc=Y(()=>g.value.length);T(()=>{K&&w&&_e.fire("pre-chat")},[K,w,_e]),T(()=>{w&&!Ut&&_e.fire("conversation-closed")},[w,Ut,_e]),T(()=>{K&&w&&fi&&_e.fire("page-area")},[K,w,fi,_e]);let jr=ke(()=>{let p=xt.list.flatMap(P=>P.triggers).filter(P=>P.kind==="idle").map(P=>Number(P.param));return p.length?Math.min(...p)*1e3:0},[xt]);T(()=>{if(!jr||!de)return;let p=setTimeout(()=>_e.fire("idle"),jr);return()=>clearTimeout(p)},[jr,de,_e,fc.value]);let mi=H(async(p,P)=>{if(W.info("send",{textLen:p.length,attachments:P.length,streaming:Ke}),Ke)return;n.emit("send",{text:p,attachmentCount:P.length}),Vr.length>0&&yn([]);let L=await Sp(Z,P,A=>{W.warn("upload failed",{err:A}),n.emit("error",A),e.onError?.(A)});se.unlock(),se.play("messageSent");let N=Xa(p,L),F=Do();g.value=[...g.value,N,F],Be.attach(F),oi(n,e,"user",p),await In(F,{continueExisting:!1}),_e.fire("after-messages")},[Ke,Z,n,e,Vr.length,g,Be,In,_e]),mc=H(()=>{W.info("stop"),n.emit("stop",void 0),Sn?.()},[Sn,n]),gc=H(()=>{se.toggleMuted();let p=se.mutedSig.value;W.info("soundToggle",{muted:p}),n.emit("soundToggle",{muted:p})},[se,n]),Xt=H(()=>{if($s(e.mode,Ie)==="exit-fullscreen"){W.info("close \u2192 exit-fullscreen",{mode:e.mode}),bt("normal"),n.emit("fullscreen",!1);return}W.info("close \u2192 panel closed",{mode:e.mode}),_e.fire("panel-close"),Me(!1),r.savePanelOpen(!1),n.emit("close",void 0),e.onClose?.()},[n,e,r,Ie,_e]),Pt=H(()=>{e.modules.list.some(p=>p.layout==="chat")&&Z.listConversations({limit:50}).then(p=>{S.value=p.conversations.reduce((P,L)=>P+(L.unreadCount??0),0)}).catch(p=>W.debug("refreshUnread failed (non-fatal)",{err:p}))},[Z,e.modules,S]),gi=M(!1);T(()=>{!y||!K||gi.current||(gi.current=!0,Pt())},[y,K,Pt]);let Xr=H(()=>{W.info("open",{mode:e.mode}),se.unlock(),Ft(!0),Me(!0),r.savePanelOpen(!0),!vt&&!zt&&Ge(),setTimeout(()=>Ft(!1),yp),Pt(),n.emit("open",void 0),e.onOpen?.()},[n,e,se,r,vt,zt,Ge,Pt]),Yr=H(()=>{if(!g.value.some(P=>P.role==="user")&&Ut&&f.value){W.info("clear \u2192 reusing empty conversation",{conversationId:f.value}),g.value.length===0&&Cn(ye.current?.messages);return}W.info("clear \u2192 new conversation",{wasStreaming:Ke}),n.emit("clear",void 0),Ke&&Sn?.(),It(()=>{g.value=[],f.value=void 0}),r.clearConversation(),Wt(!0),b([]),qt({newConversation:!0})},[Ke,Sn,g,f,r,qt,n,Ut,Cn]),Jr=H(()=>{Yr(),Wr("chat");let p=e.modules.list.find(P=>P.layout==="chat")?.id;p&&G.switchTab(p)},[Yr,G,e]),Qr=H(()=>{let p=Ie==="expanded"?"normal":"expanded";W.info("expand",{from:Ie,expanded:p==="expanded"}),bt(p),r.savePanelSize(p),n.emit("expand",p==="expanded")},[n,Ie,r]),Zr=H(()=>{let p=Ie==="fullscreen"?"normal":"fullscreen";W.info("fullscreen",{from:Ie,fullscreen:p==="fullscreen"}),bt(p),r.savePanelSize(p),n.emit("fullscreen",p==="fullscreen")},[n,Ie,r]),hc=H(()=>{Wr(p=>{let P=p==="history"?"chat":"history";return W.info("toggleHistory",{view:P}),n.emit("toggleHistory",{view:P}),P})},[n]),vc=H(p=>{W.info("localeChange",{locale:p}),c(p),Fe({locale:p}),n.emit("localeChange",p)},[Fe,n]),bc=H(p=>{W.info("themeChange",{mode:p}),u(p),t.dataset.theme=p,Fe({themeMode:p}),n.emit("themeChange",p)},[t,Fe,n]),xc=H(p=>{W.info("textSizeChange",{size:p}),m(p),t.dataset.textSize=p,Fe({textSize:p}),n.emit("textSizeChange",p)},[t,Fe,n]),Pc=H(()=>{ac(p=>{let P=!p;return W.info("sidebarToggle",{collapsed:P}),r.saveSidebarCollapsed(P),n.emit("sidebarToggle",{collapsed:P}),P})},[r,n]),yc=H(p=>{W.info("resize",p),Fe({widgetSize:p}),n.emit("resize",p)},[Fe,n]),eo=H(async p=>{W.info("selectConversation",{conversationId:p}),n.emit("selectConversation",{conversationId:p});try{let[P,L]=await Promise.all([Z.loadConversation(p),Tn(p)]),N=P.messages.map(Oo);It(()=>{g.value=Kt(N,L),f.value=P.conversationId}),b(L),r.saveConversationId(P.conversationId),P.agent&&si(P.agent),Wt(P.canContinue),yn(P.suggestions??[]),Wr("chat"),await Z.markRead(p),Pt()}catch(P){n.emit("error",P),e.onError?.(P)}},[Z,g,f,n,e,r,Pt,Tn,Kt]),An=M(null),hi=H(p=>{typeof p=="string"&&(w?_e.fire("manual",p):An.current=p)},[w,_e]);T(()=>{!w||!An.current||(_e.fire("manual",An.current),An.current=null)},[w,_e]),T(()=>ea(t,{open:Xr,close:Xt,expand:Qr,fullscreen:Zr,openForm:hi}),[t,Xr,Xt,Qr,Zr,hi]);let Ee=ke(()=>So(e,s,d,_),[e,s,d,_]);Vt.current=Ee.strings;let Sc=ke(()=>C.map(p=>{let P=xt.list.find(L=>L.id===p.formId);return{...p,title:P?.title,form:P}}),[C,xt]),vi={options:Ee,transport:Z,feedback:se,bus:n,persistence:r,view:Zl,canSend:Ut,isStreaming:Ke,loadingMessages:h,messagesSig:g,agent:ec,suggestions:Vr,initialWidgetSize:l.widgetSize??null,visitorId:i,onClose:Xt,onClear:Yr,onExpand:Qr,onFullscreen:Zr,onSoundToggle:gc,onToggleHistory:hc,onSelectHistoryConversation:eo,onNewConversation:Jr,onLocaleChange:vc,onThemeChange:bc,onTextSizeChange:xc,onWidgetSizeChange:yc,onSend:mi,onStop:mc,onSuggestion:p=>{let P=p.text??p.label;W.info("suggestion",{text:P}),n.emit("suggestion",{text:P}),mi(P,[])},activeForm:pc.value?.form??null,formMarkers:Sc,onFormSubmit:_e.complete,onFormSkip:_e.skip,onFormFill:p=>_e.fire("manual",p),tool:_c},wc=p=>{eo(p);let P=D();P&&G.switchTab(P)};if(!K)return null;let Yt=Ee.modules.list,to=p=>{let P=pn("close",Ee.mode,p);return Yt.length===0?o(Wl,{strings:Ee.strings,onClose:P?Xt:void 0}):Yt.length===1&&Yt[0]?.layout==="chat"?o(hl,{...vi,panelSize:p}):o(Ul,{panelProps:{...vi,panelSize:p,onClose:P?Xt:void 0},enabledModules:Yt,nav:G,bus:n,unreadCount:S.value,onSelectConversation:wc,onStartNewConversation:Jr,onSetPanelSize:bt})};if(e.mode==="page"){let p=L=>{eo(L.conversationId)},P=Yt.some(L=>L.layout==="chat");return o("div",{class:`${Br}-anchor`,children:o(Pl,{site:tc,blocks:rc,transport:Z,strings:Ee.strings,locale:Ee.locale,persistence:r,visitorId:i,showConversations:P,onSelectConversation:p,onNewConversation:Jr,sidebarCollapsed:ic,onToggleSidebarCollapsed:Pc,children:to("fullscreen")})})}if(ne){let p=e.mode==="standalone"?"fullscreen":Ie;return o("div",{class:`${Br}-anchor`,children:to(p)})}let bi=e.mode==="drawer",xi=!(e.mode==="modal")&&!e.launcher.hidden&&(!de||ht),Pi=xi&&!ht&&!vt&&!bi?Ee.launcher.callout:null;return o("div",{class:`${Br}-anchor`,"data-launcher-size":Ee.launcher.size,children:[de||y?o("div",{class:`${Br}-surface`,hidden:!de,children:to(Ie)}):null,xi?o(Ns,{onToggle:Xr,launcher:Ee.launcher,strings:Ee.strings,leaving:ht,edgeTab:bi}):null,Pi?o(Ds,{callout:Pi,launcherPosition:Ee.position,strings:Ee.strings,closeLabel:Ee.strings.close,onDismiss:Ge}):null]})}function Pp(e){let t=e?.url??(typeof location<"u"?location.href:void 0);if(!(!e&&!t))return{...e,...t?{url:t}:{}}}var yp=120;async function Sp(e,t,n){let r=[];for(let i of t)try{let{id:a,url:l}=await e.uploadFile(i.file);r.push({id:a,name:i.name,mediaType:i.mediaType,size:i.size,url:l})}catch(a){n(a)}return r}function oi(e,t,n,r){let i={role:n,text:r};e.emit("message",i),t.onMessage?.(i)}var wp=B.scope("error-boundary"),Fr=class extends et{constructor(){super(...arguments);J(this,"state",{crashed:!1})}componentDidCatch(n,r){wp.error("widget render crashed",{error:n,componentStack:r?.componentStack}),this.setState({crashed:!0}),this.props.onError(n,r?.componentStack)}render(){return this.state.crashed?this.props.fallback:this.props.children}};var kp="1",Cp=60,Tp=2e3,ql={open:()=>{},close:()=>{},expand:e=>({on:e}),fullscreen:e=>({on:e}),send:e=>({attachments:e.attachmentCount}),message:e=>({role:e.role}),stop:()=>{},clear:()=>{},suggestion:()=>{},toggleHistory:e=>({view:e.view}),handshake:()=>{},formSubmit:e=>({formId:e.formId,skipped:e.skipped}),toolResult:()=>{},toolDecision:e=>({approved:e.approved}),contentView:e=>({section:e.section,tags:e.tags,count:e.count}),contentOpen:e=>({contentId:e.contentId,tags:e.tags}),contentSearch:e=>({qlen:e.queryLength,hits:e.hitCount}),contentRead:e=>({contentId:e.contentId}),contentLinkClick:e=>({contentId:e.contentId}),attach:e=>({count:e.count,bytes:e.totalBytes}),voiceStart:()=>{},voiceStop:e=>({ms:e.durationMs}),voiceCancel:()=>{},localeChange:e=>({locale:e}),themeChange:e=>({theme:e}),textSizeChange:e=>({size:e}),soundToggle:e=>({muted:e.muted}),sidebarToggle:e=>({collapsed:e.collapsed}),calloutDismiss:()=>{},error:()=>{}};function Ep(){let e=navigator;return e.globalPrivacyControl===!0||e.doNotTrack==="1"}function Ip(){return location.origin+location.pathname}function Rp(){try{return document.referrer?new URL(document.referrer).origin:""}catch{return""}}function jl(e,t){let n=Math.random(),r=0,i=0,a=new Set,l=(c,d)=>{let{tracking:u,publicKey:_,aiAgentDeploymentId:m,mode:f,themeMode:g}=t.getOptions();if(!u.enabled||Ep()||n>=u.sampleRate)return;let S=performance.now();if(S-r>6e4&&(r=S,i=0),++i>Cp)return;let h=new URLSearchParams;h.set("v",kp),h.set("_ev",St),h.set("e",c),u.token&&h.set("tk",u.token),_&&h.set("pk",_),m&&h.set("dep",m),h.set("vid",t.getVisitorId());let v=t.getConversationId();v&&h.set("cid",v),h.set("url",Ip());let C=Rp();C&&h.set("ref",C),h.set("sw",String(screen.width)),h.set("sh",String(screen.height)),h.set("vw",String(innerWidth)),h.set("vh",String(innerHeight)),h.set("dpr",String(devicePixelRatio)),h.set("lang",navigator.language);try{h.set("tz",Intl.DateTimeFormat().resolvedOptions().timeZone)}catch{}if(h.set("m",f),h.set("th",g),d)for(let[V,G]of Object.entries(d))G!==void 0&&h.set(V,String(G));h.set("ts",String(Date.now()));let b=`${u.endpoint}?${h}`;if(b.length>Tp)return;let E=new Image(1,1);a.add(E);let D=()=>a.delete(E);E.addEventListener("load",D,{once:!0}),E.addEventListener("error",D,{once:!0}),E.src=b},s=Object.keys(ql).map(c=>e.on(c,d=>l(c,ql[c]?.(d))));return()=>{for(let c of s)c();a.clear()}}function Xl(e){let{bus:t,host:n,appRoot:r,persistence:i,reportError:a}=e,l=e.initialRaw,s,c=kt(l),d=!0,u=()=>{c=kt(s?wo(l,s):l)},_=()=>{ca(n,en(c.mode));let g=i.loadUserPrefs().themeMode;da(n,g?{...c,themeMode:g}:c),d&&(Qn(n,zr(c)),d=!1)},m=()=>{_(),Un(zn(Fr,{onError:a},zn(Kl,{bus:t,hostElement:n,options:c})),r)};t.on("handshake",g=>{g.config&&(g.config.storageVersion&&i.rememberStorageVersion(g.config.storageVersion),s=g.config,u(),m())});let f=jl(t,{getOptions:()=>c,getVisitorId:()=>i.getVisitorId(),getConversationId:()=>i.loadConversationId()});return{getOptions:()=>c,getUserOptions:()=>l,render:m,setUserOptions:g=>{l=g,u(),m()},patchUserOptions:g=>{l={...l,...g},u(),m()},destroy:()=>f()}}function zr(e){if(e.mode==="standalone")return"standalone";if(e.mode==="inline")return"inline";let t=Tt(e.widgetId,e.storage,e.aiAgentDeploymentId),{panelOpen:n,panelSize:r}=sn(e,Lt(),t.loadPanelOpen(),t.loadPanelSize());return dr(e.mode,r,n)}var Ap=B.scope("hooks"),Ur="*",ii=new Set;function Yl(e,t,n){let r={widgetId:e,event:t,listener:n};return ii.add(r),()=>{ii.delete(r)}}function Lp(e,t,n){let r=[...ii];for(let i of r)if(Mp(i.widgetId,e.widgetId)&&!(i.event!==Ur&&i.event!==t))try{i.listener(e,t,n)}catch(a){Ap.warn("hook listener threw",{event:t,error:a})}}function Jl(e,t){let n=[];for(let r of Np)n.push(t.on(r,i=>{Lp(e,r,i)}));return()=>{for(let r of n)r()}}function Mp(e,t){return e===Ur||e===t}var Np=["open","close","expand","fullscreen","resize","message","send","stop","clear","selectConversation","suggestion","toggleHistory","formSubmit","toolResult","toolDecision","contentView","contentOpen","contentSearch","contentRead","contentLinkClick","attach","removeAttachment","voiceStart","voiceStop","voiceCancel","localeChange","themeChange","textSizeChange","soundToggle","sidebarToggle","calloutDismiss","error","handshake","visitorRebound","conversationRebound"];var Qe=new Map;function Ql(e){e.debug!==void 0&&qn(e.debug);let t=B.scope("mount");t.info("mount",{widgetId:e.widgetId,publicKey:e.publicKey,mode:e.presentation?.mode});let n=kt(e),r=n.widgetId,i=Qe.get(r);i&&(t.debug("destroy existing instance at slot",{widgetId:r}),i.destroy());let a=zr(n),l=n.iframe?pa({position:en(n.mode)},n.position,a,n.mode,e.target??null):Jn({position:en(n.mode),target:e.target??null});l.hostElement.dataset.widgetId=r;let s=new er,c=Tt(r,n.storage,n.aiAgentDeploymentId),d=S=>{s.emit("error",S),u.getOptions().onError?.(S)},u=Xl({bus:s,host:l.hostElement,appRoot:l.appRoot,persistence:c,initialRaw:e,reportError:d});u.render();let _=l.hostElement,m=null,f=S=>{S.debug!==void 0&&qn(S.debug),u.patchUserOptions(S)},g={widgetId:r,open:()=>Zt(_,"open"),close:()=>Zt(_,"close"),expand:()=>Zt(_,"expand"),openForm:S=>Zt(_,"openForm",S),on:(S,h)=>s.on(S,h),update:S=>{t.debug("update",{patch:S}),f(S)},setUserContext:S=>{t.debug("setUserContext",{keys:Object.keys(S)}),f({userContext:{...u.getUserOptions().userContext,...S}})},clearUserContext:()=>{t.debug("clearUserContext"),f({userContext:void 0})},setPageContext:S=>{t.debug("setPageContext",{keys:Object.keys(S)}),f({pageContext:{...u.getUserOptions().pageContext,...S}})},clearPageContext:()=>{t.debug("clearPageContext"),f({pageContext:void 0})},setDebug:S=>{qn(S),t.info("debug level set",{level:ho()})},debugLevel:()=>ho(),onLog:S=>Vi(S),destroy:()=>{t.info("destroy",{widgetId:r}),m?.(),u.destroy(),s.clear(),Un(null,l.appRoot),l.destroy(),Qe.get(r)===g&&Qe.delete(r)}};return m=Jl(g,s),Qe.set(r,g),g}function Dp(e){let t=e.widgetId??"default",n=Qe.get(t);return n?(n.update(e),n):Ql(e)}function Op(e){if(e!==void 0){Qe.get(e)?.destroy();return}let t=[...Qe.values()];for(let n of t)n.destroy()}function $p(e="default"){return Qe.get(e)??null}function Hp(){return[...Qe.values()]}function Bp(e,t,n){return Yl(e,t,n)}var Fp=St,zp=x;
40
40
  //# sourceMappingURL=elements.cjs.js.map