@helpai/elements 1.10.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/react.mjs CHANGED
@@ -1,21 +1,21 @@
1
1
  'use client';
2
- import{useEffect as e,useMemo as t,useRef as n,useSyncExternalStore as r}from"react";function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const c={open:!1,ready:!1,unread:0};var l=class{constructor(){s(this,`handlers`,/* @__PURE__ */ new Map)}on(e,t){let n=this.handlers.get(e);return n||(n=/* @__PURE__ */ new Set,this.handlers.set(e,n)),n.add(t),()=>this.handlers.get(e)?.delete(t)}emit(e,t){let n=this.handlers.get(e);if(n)for(let e of n)try{e(t)}catch{}}clear(){this.handlers.clear()}},u,d,f,p,m,h,g,_,v,y,b,x={},S=[],ee=/^m(i|n|o|s|text|space)$/,C=Array.isArray,te=S.slice,w=Object.assign;function T(e){e&&e.parentNode&&e.remove()}function E(e,t,n){var r,i,a,o={},s=arguments.length;for(a in t)a==`key`?r=t[a]:a==`ref`&&typeof e!=`function`?i=t[a]:o[a]=t[a];return s>2&&(o.children=s>3?te.call(arguments,2):n),D(e,o,r,i,null)}function D(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||++d,__i:-1,__u:0};return!i&&u.vnode&&u.vnode(a),a}function O(e){return e.children}function ne(e,t){this.props=e,this.context=t,this.__g=0}function k(e,t){if(t==null)return e.__&&k(e.__,e.__i+1);for(var n;t<e.__k.length;t++)if((n=e.__k[t])&&n.__e)return n.__e;return typeof e.type!=`function`||e.props.__P?null:k(e)}function A(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),A(e)}function re(e){(8&e.__g||(e.__g|=8,p.push(e),h++))&&m==u.debounceRendering||((m=u.debounceRendering)||queueMicrotask)(j)}function j(){var e,t,n,r,i,a,o,s,c;try{for(t=1;p.length;)p.length>t&&p.sort(g),e=p.shift(),t=p.length,8&e.__g&&(r=void 0,i=void 0,a=(i=(n=e).__v).__e,o=[],s=[],(c=n.__P)&&((r=w({constructor:void 0},i)).__v=i.__v+1,u.vnode&&u.vnode(r),de(c,r,i,n.__n,c.namespaceURI,32&i.__u?[a]:null,o,a||k(i),32&i.__u,s),r.__v=i.__v,r.__.__k[r.__i]=r,me(o,r,s),i.__=i.__e=null,r.__e!=a&&A(r)))}finally{(h=p.length)&&(m||queueMicrotask)(j)}}function ie(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r.__k||S,v=t.length;for(c=M(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=~p.__i&&_[p.__i]||x,p.__i=d,g=de(e,p,f,i,a,o,s,c,l,u),m=p.__e,(f.ref!=p.ref||8&f.__u)&&(f.ref&&ge(f.ref,null,p,f),p.ref&&u.push(p.ref,p.__c||m,p)),h=h||m,4&p.__u?(c=ae(p,c,e,!f.__v),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-21);return n.__e=h,c}function M(e,t,n,r,i){var a,o,s,c,l,u,d,f,p,m=n.length,h=m,g=0,_=0,v=e.__k=Array(i);for(a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o!=`object`||o.constructor==String?o=v[a]=D(null,o):C(o)?o=v[a]=D(O,{children:o}):o.constructor===void 0&&o.__b?o=v[a]=D(o.type,o.props,o.key,o.ref,o.__v):v[a]=o,c=a+g,o.__=e,o.__b=e.__b+1,s=null,~(l=o.__i=se(o,n,c,h))&&(h--,(s=n[l])&&(s.__u|=2)),s&&s.__v?(o.__u|=16,l==c-1?g--:l==c+1?g++:l!=c&&(l>c?g--:g++,_=1)):(~l||(i>m?g--:i<m&&g++),typeof o.type!=`function`&&(o.__u|=4))):v[a]=null;if(_){for(u=[],d=[],a=0;a<i;a++)if((o=v[a])&&16&o.__u){for(g=0,f=u.length;g<f;)u[p=g+f>>1]<o.__i?g=p+1:f=p;u[g]=o.__i,d[a]=g+1}for(g=u.length;a--;)d[a]&&(d[a]==g?g--:v[a].__u|=4)}if(h)for(a=0;a<m;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=k(s)),N(s,s));return r}function ae(e,t,n,r){var i,a,o,s;if(typeof e.type==`function`){if(e.props.__P)return t;if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&(i[a].__=e,t=ae(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=k(e))&&!t.parentNode&&(t=null),o=e.__e,s=t;s&&s.nodeType==8;)s=s.nextSibling;for(o!=s&&(!r&&n.moveBefore&&o.parentNode?n.moveBefore(o,t):n.insertBefore(o,t||null)),t=o;(t=t&&t.nextSibling)&&t.nodeType==8&&!t.data.startsWith(`$s`););return t}function oe(e,t){return t=t||[],e!=null&&typeof e!=`boolean`&&(C(e)?e.some(function(e){oe(e,t)}):t.push(e)),t}function se(e,t,n,r){var i,a=e.key,o=e.type,s=t[n],c=s&&!(2&s.__u);if(s===null&&a==null||c&&a==s.key&&o==s.type)return n;if(r>+!!c){for(i=n-1;i>=0;i--)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i;for(i=n+1;i<t.length;i++)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i}return-1}function ce(e,t,n){n??(n=``),t[0]==`-`?e.setProperty(t,n):e[t]=n}function le(e,t,n,r,i){var a,o;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||ce(e.style,t);if(n)for(t in n)r&&n[t]==r[t]||ce(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)(e.__e||(e.__e={}))[t]=n,n&&r||(o=b[t]||(b[t]=ue(t)),(e.__a||(e.__a={}))[t]=y,a=t!=(t=t.replace(v,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),n?e.addEventListener(t,o,a):e.removeEventListener(t,o,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??``;return}catch{}if(typeof n==`function`)return;n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n)}}function ue(e){return function(t){var n=this.__e;if(n){if(n=n[e],t[_]==null)t[_]=y++;else if(t[_]<this.__a[e])return;return n(u.event?u.event(t):t)}}}function de(e,t,n,r,i,a,o,s,c,l){var d,f,p,m,h,g,_,v,y,b,x,ee,te,E,D,A,re,j,M=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=32&n.__u,d=n.__c.__z)&&(t.__u|=c,f=a=[],d.nodeType==8?s=fe(d,a):a.push(d),s=a[0]||s),(d=u.__b)&&d(t);n:if(typeof M==`function`){p=o.length;try{if(v=t.props,y=(d=M.prototype)&&d.render,b=(d=M.contextType)&&r[d.__c],x=d?b?b.props.value:d.__:r,(m=n.__c)?(t.__c=m,2&m.__g&&(m.__g|=1)):(y?t.__c=m=new M(v,x):(t.__c=m=new ne(v,x),m.constructor=M,m.render=_e),b&&b.sub(m),m.state||(m.state={}),m.__n=r,m.__g|=8,m.__h=[],m.__k=[]),y&&(m.__s||(m.__s=m.state),M.getDerivedStateFromProps&&(m.__s==m.state&&(m.__s=w({},m.__s)),w(m.__s,M.getDerivedStateFromProps(v,m.__s)))),h=m.props,g=m.state,m.__v=t,n.__c){if(v!==h&&y&&!M.getDerivedStateFromProps&&m.componentWillReceiveProps&&m.componentWillReceiveProps(v,x),t.__v==n.__v&&!(8&m.__g)||!(4&m.__g)&&m.shouldComponentUpdate&&!1===m.shouldComponentUpdate(v,m.__s,x)){t.__v!=n.__v&&(m.props=v,m.state=m.__s,m.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),S.push.apply(m.__h,m.__k),m.__k=[],m.__h.length&&o.push(m),s=k(n);break n}m.componentWillUpdate&&m.componentWillUpdate(v,m.__s,x),y&&m.componentDidUpdate&&m.__h.push(function(){m.componentDidUpdate(h,g,_)})}else y&&!M.getDerivedStateFromProps&&m.componentWillMount&&m.componentWillMount(),y&&m.componentDidMount&&m.__h.push(m.componentDidMount);if(m.context=x,m.props=v,m.__P=e,m.__g&=-5,ee=u.__r,te=0,y)m.state=m.__s,m.__g&=-9,ee&&ee(t),d=m.render(m.props,m.state,m.context),S.push.apply(m.__h,m.__k),m.__k=[];else do m.__g&=-9,ee&&ee(t),d=m.render(m.props,m.state,m.context),m.state=m.__s;while(8&m.__g&&++te<25);m.state=m.__s,m.getChildContext&&(r=w({},r,m.getChildContext())),y&&n.__c&&m.getSnapshotBeforeUpdate&&(_=m.getSnapshotBeforeUpdate(h,g)),E=d&&d.type===O&&d.key==null?d.props.children:d,v.__P&&(d=s,i=(e=v.__P).namespaceURI,c=a=null,n.props&&n.props.__P!=e&&(n.__k.some(function(e){e&&N(e,e)}),n.__k=null),s=n.__k?k(n,0):null),s=ie(e,C(E)?E:[E],t,n,r,i,a,o,s,c,l),v.__P&&(t.__e=null,s=d),t.__u&=-161,f&&f.some(T),m.__h.length&&o.push(m),1&m.__g&&(m.__g&=-4)}catch(e){if(o.length=p,t.__v=null,c||a){if(e.then){if(D=0,t.__u|=128|c,a){for(~(re=a.indexOf(s||void 0))||(re=a.length);(j=a[re-1])&&j.nodeType==8;)re--;for(;re<a.length;re++)if(j=a[re]){if(a[re]=null,j.nodeType==8){if(j.data.startsWith(`$s`))D++||(A=j);else if(D&&j.data.startsWith(`/$s`)&&!--D)break}else if(!D)break}}if(!A){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;A=s}(d=fe(A=t.__c.__z||(t.__c.__z=A)))?(t.__e=A,s=d):t.__e=s,s=s&&s.nextSibling}else a&&a.some(T)}else t.__e=n.__e;t.__k||(t.__k=n.__k||[]),e.then||pe(t),u.__e(e,t,n)}}else s=t.__e=he(n.__e,t,n,r,i,a,o,c,l,e);return(d=u.diffed)&&d(t),s}function fe(e,t){if(e&&e.nodeType==8&&e.data.startsWith(`$s`))for(var n=1;e=e.nextSibling;){if(e.nodeType==8){if(e.data.startsWith(`$s`))n++;else if(e.data.startsWith(`/$s`)&&!--n)return e}t&&t.push(e)}}function pe(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(pe))}function me(e,t,n){for(var r=0;r<n.length;)ge(n[r++],n[r++],n[r++]);u.__c&&u.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){u.__e(e,t.__v)}})}function he(e,t,n,r,i,a,o,s,c,l){var d,f,p,m,h,g,_,v,y,b=n.props||x,S=t.props,w=t.type;if(w==`svg`?i=`http://www.w3.org/2000/svg`:w==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||(i=`http://www.w3.org/1999/xhtml`),a){for(d=0;d<a.length;d++)if((h=a[d])&&(w?h.localName==w:h.nodeType==3)){e=h,a[d]=null;break}}if(!e){if(v=l.ownerDocument||document,!w)return v.createTextNode(S);e=v.createElementNS(i,w,S.is&&S),s&&(u.__m&&u.__m(t,a),s=!1),a=null}if(w){if(l=w==`template`?e.content:e,a=w==`textarea`&&S.defaultValue!=null?null:a&&te.call(l.childNodes),!s&&a)for(b={},d=0;d<e.attributes.length;d++)b[(h=e.attributes[d]).name]=h.value;for(d in b)h=b[d],d==`dangerouslySetInnerHTML`?p=h:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||le(e,d,null,h,i);for(d in y=1&n.__u,S)h=S[d],d==`children`?m=h:d==`dangerouslySetInnerHTML`?f=h:d==`value`?g=h:d==`checked`?_=h:s&&typeof h!=`function`||!(b[d]!==h||y&&h!=null)||le(e,d,h,b[d],i);f?(s||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[]):(p&&(e.textContent=``),(w==`foreignObject`||i==`http://www.w3.org/1998/Math/MathML`&&ee.test(w))&&(i=`http://www.w3.org/1999/xhtml`),ie(l,C(m)?m:[m],t,n,r,i,a,o,a?a[0]:n.__k&&k(n,0),s,c),a&&a.some(T)),s&&w!=`textarea`||(d=`value`,w==`progress`&&g==null?e.removeAttribute(d):g==null||g===e[d]&&(w!=`progress`||g)||le(e,d,g,b[d],i),d=`checked`,_!=null&&_!=e[d]&&le(e,d,_,b[d],i))}else b===S||s&&e.data==S||(e.data=S);return e}function ge(e,t,n,r){try{typeof e==`function`?t?t.__x=e(t)||1:r&&(r=r.__c||r.__e)&&(t=r.__x)&&(r.__x=null,typeof t==`function`?t():e(null)):e.current=t}catch(e){u.__e(e,n)}}function N(e,t,n){var r,i,a,o;if(u.unmount&&u.unmount(e),!(r=e.ref)||r.current&&r.current!=e.__e||ge(r,null,t,e),r=e.__c){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){u.__e(e,t)}r.__P=r.__n=null}if(r=e.__k)for(o=0;o<r.length;o++)r[o]&&N(r[o],t,typeof e.type!=`function`||n&&!e.props.__P);!n&&(r=e.__c)&&(r=r.__z)&&(i=fe(r,a=[]))&&(r==e.__e&&a.some(T),T(i),T(r)),(r=e.__e)&&(n||T(r),r.__e&&(r.__e=null)),e.__e=e.__c=e.__=null}function _e(e,t,n){return this.constructor(e,n)}function ve(e,t){var n,r,i,a;u.__&&u.__(e,t),t.nodeType==9&&(t=t.documentElement),r=(n=e&&32&e.__u)?null:t.__k,t.__k=D(O,{children:[e]}),i=[],a=[],de(t,t.__k,r||x,x,t.namespaceURI,r?null:t.firstChild?te.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a),me(i,t.__k,a),t.__k.props.children=null}u={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((o=(a=i.constructor)&&a.getDerivedStateFromError)&&i.setState(a.getDerivedStateFromError(e)),i.componentDidCatch&&(i.componentDidCatch(e,r||{}),o=1),o&&8&i.__g)return void(i.__g|=2)}catch(t){e=t}}throw h=0,e}},d=0,f=function(e){return e!=null&&e.constructor===void 0},ne.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=w({},this.state)),typeof e==`function`&&(e=e(w({},n),this.props)),e&&(w(n,e),this.__v&&(t&&this.__k.push(t),re(this)))},ne.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),re(this))},ne.prototype.render=O,p=[],h=0,g=function(e,t){return e.__v.__b-t.__v.__b},_=Symbol(),v=/(PointerCapture)$|Capture$/i,y=0,b={};function ye(e,t){if(e?.length&&t)return e.find(e=>e.locale===t)}function be(e,t){let{translations:n,defaultLocale:r,...i}=e,a=ye(n,t);return a?{...i,title:a.title??i.title,description:a.description??i.description,content:a.content??i.content}:i}function xe(e,t){let{translations:n,defaultLocale:r,...i}=e,a=ye(n,t);return a?{...i,title:a.title??i.title,description:a.description??i.description}:i}function Se(e,t){let{translations:n,defaultLocale:r,...i}=e,a=ye(n,t);if(!a)return i;let o=new Map((a.fields??[]).map(e=>[e.name,e])),s=i.fields.map(e=>{let t=o.get(e.name);if(!t)return e;let n=new Map((t.options??[]).map(e=>[e.value,e]));return{...e,label:t.label??e.label,placeholder:t.placeholder??e.placeholder,validationHint:t.validationHint??e.validationHint,options:e.options?.map(e=>{let t=n.get(e.value);return t?{...e,label:t.label??e.label,description:t.description??e.description}:e})}});return{...i,title:a.title??i.title,description:a.description??i.description,submitLabel:a.submitLabel??i.submitLabel,fields:s}}const Ce={attach:`Attach files`,attachmentMimeRejected:`File type not supported`,attachmentTooLarge:`File is too large`,attachmentTooMany:`Attachment limit reached`,conversationClosed:`This chat is closed`,conversationLoading:`Loading chat…`,loadPreviousMessages:`Load previous messages`,close:`Close`,collapse:`Collapse`,collapseSidebar:`Collapse sidebar`,composerPlaceholder:`Type a message…`,dateLastWeek:`Last 7 days`,dateOlder:`Older`,dateToday:`Today`,dateYesterday:`Yesterday`,dropZone:`Drop files to attach`,errorGeneric:`Something went wrong`,errorRateLimited:`Too many requests — 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 chats yet`,historyLoading:`Loading your chats…`,historyContinue:`Continue the chat`,historyTitle:`Chat history`,loadMoreConversations:`Load more conversations`,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 chat`,panelTitle:`Chat`,popOut:`Open in new tab`,resizeHandle:`Drag to resize`,scrollToBottom:`Scroll to latest`,send:`Send`,queueMessage:`Queue message`,removeQueuedMessage:`Remove queued message`,compactingContext:`Optimizing conversation context…`,soundOff:`Sound off`,soundOn:`Sound on`,startNewConversation:`Start a new chat`,talkToOperator:`Talk to a person`,connectingOperator:`Connecting you to a person…`,noOperatorAvailable:`No one's available right now — leave your details and we'll follow up.`,chattingWithOperator:`You're chatting with {operator}`,cancelOperatorRequest:`Keep chatting with the AI`,stop:`Stop`,theme:`Theme`,themeAuto:`Auto`,themeDark:`Dark`,themeLight:`Light`,textSize:`Text size`,textSizeSmall:`Small`,textSizeNormal:`Normal`,textSizeLarge:`Large`,loading:`Loading…`,visualPreparing:`Preparing visual…`,visualError:`This visual could not be displayed.`,visualPartial:`Some parts of this visual could not be displayed.`,thinking:`Thinking…`,thoughts:`Thoughts`,toolResult:`Result`,sources:`Sources`,feedbackUp:`Good response`,feedbackDown:`Bad response`,feedbackThanks:`Thanks for your feedback`,copy:`Copy`,copied:`Copied`,tabHome:`Home`,tabConversations:`Chats`,tabHelp:`Help`,tabNews:`News`,modulesEmpty:`Nothing here yet`,moduleBack:`Back`,contentLoading:`Loading…`,contentHelpful:`Was this helpful?`,homeGreeting:`How can we help?`,homeGreetingNamed:`Hi {name} 👋`,homeGreetingLead:`How can we help?`,homeSearchPlaceholder:`Search for help`,homeAskPlaceholder:`Ask a question…`,homeWhatsNew:`What's new`,homeContentTitle:`Popular articles`,homeStatus:`Status`,helpTitle:`Help`,helpSearchPlaceholder:`Search for help`,helpEmpty:`No help articles yet`,helpLoading:`Loading help…`,helpSearchEmpty:`No results for “{query}”`,helpShowMore:`Show more`,newsTitle:`News`,newsEmpty:`No news yet`,newsLoading:`Loading news…`,newsBack:`Back to news`,newsPublishedAt:`Published {date}`,newsShowMore:`Show more`,newsUnseen:`New post`,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…`,inputRequired:`Questions for you`,inputBadge:`Questions`,inputAnswered:`Answered`,inputSkipped:`Skipped`,showOptions:`Show options`,hideOptions:`Hide options`,qtypeText:`Your answer`,qtypeEmail:`Email address`,qtypePhone:`Phone number`,qtypeNumber:`Number`,qtypeDate:`Date`,qtypeChooseOne:`Pick one`,qtypeChooseAny:`Pick any`,qtypeBoolean:`Yes / No`,inputSubmit:`Submit answers`,inputSubmitHint:`Enter to send · Shift+Enter = new line`,inputSkip:`Skip`,confirmYes:`Yes`,confirmNo:`No`,approve:`Approve`,reject:`Reject`,approvalPrompt:`{tool} requires your approval to execute.`,approvalBody:`Review the tool input above and decide whether to allow this action.`,approvalYourResponse:`Your response: {decision}`,approvalEditHint:`You can edit this response until this step continues.`,approvalSubmitting:`Response submitted. Request in progress…`,edit:`Edit`,toolParameters:`Parameters`,statusAwaiting:`Awaiting Approval`,statusResponded:`Submitted`,statusRunning:`Running`,statusCompleted:`Completed`,statusDenied:`Denied`,statusError:`Error`,statusSuperseded:`Skipped`},we={en:Ce,fr:{attach:`Joindre des fichiers`,attachmentMimeRejected:`Type de fichier non pris en charge`,attachmentTooLarge:`Le fichier est trop volumineux`,attachmentTooMany:`Limite de pièces jointes atteinte`,conversationClosed:`Ce chat est fermé`,conversationLoading:`Chargement du chat…`,loadPreviousMessages:`Charger les messages précédents`,close:`Fermer`,collapse:`Réduire`,collapseSidebar:`Réduire la barre latérale`,composerPlaceholder:`Écrivez un message…`,dateLastWeek:`7 derniers jours`,dateOlder:`Plus ancien`,dateToday:`Aujourd'hui`,dateYesterday:`Hier`,dropZone:`Déposez les fichiers à joindre`,errorGeneric:`Une erreur s'est produite`,errorRateLimited:`Trop de requêtes — veuillez réessayer dans un instant.`,errorRetry:`Réessayer`,expand:`Agrandir`,expandSidebar:`Développer la barre latérale`,exitFullscreen:`Quitter le plein écran`,fullscreen:`Plein écran`,history:`Historique`,historyBack:`Retour au chat`,historyEmpty:`Aucun chat pour le moment`,historyContinue:`Poursuivre le chat`,historyLoading:`Chargement de vos chats…`,historyTitle:`Historique des chats`,loadMoreConversations:`Charger plus de conversations`,language:`Langue`,launcherOpen:`Ouvrir le chat`,launcherLabel:`Discuter avec nous`,micStart:`Démarrer la saisie vocale`,micStop:`Arrêter la saisie vocale`,micUnsupported:`La saisie vocale n'est pas prise en charge par ce navigateur`,moreActions:`Plus d'actions`,newConversation:`Nouveau chat`,panelTitle:`Chat`,popOut:`Ouvrir dans un nouvel onglet`,resizeHandle:`Glisser pour redimensionner`,scrollToBottom:`Aller au plus récent`,send:`Envoyer`,queueMessage:`Mettre le message en attente`,removeQueuedMessage:`Retirer le message en attente`,compactingContext:`Optimisation du contexte de la conversation…`,soundOff:`Son désactivé`,soundOn:`Son activé`,startNewConversation:`Démarrer un nouveau chat`,talkToOperator:`Parler à une personne`,connectingOperator:`Mise en relation avec une personne…`,noOperatorAvailable:`Personne n'est disponible pour le moment — laissez vos coordonnées et nous reviendrons vers vous.`,chattingWithOperator:`Vous discutez avec {operator}`,cancelOperatorRequest:`Continuer avec l'IA`,stop:`Arrêter`,theme:`Thème`,themeAuto:`Auto`,themeDark:`Sombre`,themeLight:`Clair`,textSize:`Taille du texte`,textSizeSmall:`Petite`,textSizeNormal:`Normale`,textSizeLarge:`Grande`,loading:`Chargement…`,visualPreparing:`Préparation du visuel…`,visualError:`Ce visuel n’a pas pu être affiché.`,visualPartial:`Certaines parties de ce visuel n’ont pas pu être affichées.`,thinking:`Réflexion…`,thoughts:`Réflexions`,toolResult:`Résultat`,sources:`Sources`,feedbackUp:`Bonne réponse`,feedbackDown:`Mauvaise réponse`,feedbackThanks:`Merci pour votre retour`,copy:`Copier`,copied:`Copié`,tabHome:`Accueil`,tabConversations:`Chats`,tabHelp:`Aide`,tabNews:`Actualités`,modulesEmpty:`Rien pour le moment`,moduleBack:`Retour`,contentLoading:`Chargement…`,contentHelpful:`Cela vous a-t-il aidé ?`,homeGreeting:`Comment pouvons-nous vous aider ?`,homeGreetingNamed:`Bonjour {name} 👋`,homeGreetingLead:`Comment pouvons-nous vous aider ?`,homeSearchPlaceholder:`Rechercher de l'aide`,homeAskPlaceholder:`Posez une question…`,homeWhatsNew:`Nouveautés`,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…`,helpSearchEmpty:`Aucun résultat pour «\xA0{query}\xA0»`,helpShowMore:`Afficher plus`,newsTitle:`Actualités`,newsEmpty:`Aucune actualité pour le moment`,newsLoading:`Chargement des actualités…`,newsBack:`Retour aux actualités`,newsPublishedAt:`Publié le {date}`,newsShowMore:`Afficher plus`,newsUnseen:`Nouvelle publication`,formSubmit:`Envoyer`,formSkip:`Plus tard`,formSubmitted:`Terminé`,formSkipped:`Plus tard`,formFillOut:`Remplir`,formRequired:`Ce champ est obligatoire`,formInvalidEmail:`Saisissez une adresse e-mail valide`,formInvalidTel:`Saisissez un numéro de téléphone valide`,formInvalidUrl:`Saisissez une URL valide`,formInvalidNumber:`Saisissez un nombre valide`,formTooShort:`Trop court (min. {min} caractères)`,formTooLong:`Trop long (max. {max} caractères)`,formNumberTooSmall:`Doit être au moins {min}`,formNumberTooLarge:`Doit être au plus {max}`,formPatternMismatch:`Veuillez respecter le format demandé`,formChooseAtLeast:`Choisissez au moins {min}`,formChooseAtMost:`Choisissez au plus {max}`,formOther:`Autre`,formOtherPlaceholder:`Saisissez votre réponse…`,inputRequired:`Questions pour vous`,inputBadge:`Questions`,inputAnswered:`Répondu`,inputSkipped:`Ignoré`,showOptions:`Afficher les options`,hideOptions:`Masquer les options`,qtypeText:`Votre réponse`,qtypeEmail:`Adresse e-mail`,qtypePhone:`Numéro de téléphone`,qtypeNumber:`Nombre`,qtypeDate:`Date`,qtypeChooseOne:`Choisir une`,qtypeChooseAny:`Choisir plusieurs`,qtypeBoolean:`Oui / Non`,inputSubmit:`Envoyer les réponses`,inputSubmitHint:`Entrée pour envoyer · Maj+Entrée = saut de ligne`,inputSkip:`Ignorer`,confirmYes:`Oui`,confirmNo:`Non`,approve:`Approuver`,reject:`Refuser`,approvalPrompt:`{tool} nécessite votre approbation pour s'exécuter.`,approvalBody:`Vérifiez les paramètres ci-dessus et décidez d'autoriser ou non cette action.`,approvalYourResponse:`Votre réponse : {decision}`,approvalEditHint:`Vous pouvez modifier votre réponse jusqu'à la reprise de cette étape.`,approvalSubmitting:`Réponse envoyée. Traitement en cours…`,edit:`Modifier`,toolParameters:`Paramètres`,statusAwaiting:`En attente d'approbation`,statusResponded:`Envoyé`,statusRunning:`En cours`,statusCompleted:`Terminé`,statusDenied:`Refusé`,statusError:`Erreur`,statusSuperseded:`Ignoré`},ar:{attach:`إرفاق ملفات`,attachmentMimeRejected:`نوع الملف غير مدعوم`,attachmentTooLarge:`حجم الملف كبير جدًا`,attachmentTooMany:`تم بلوغ الحد الأقصى للمرفقات`,conversationClosed:`تم إغلاق هذه الدردشة`,conversationLoading:`جارٍ تحميل الدردشة…`,loadPreviousMessages:`تحميل الرسائل السابقة`,close:`إغلاق`,collapse:`طيّ`,collapseSidebar:`طيّ الشريط الجانبي`,composerPlaceholder:`اكتب رسالة…`,dateLastWeek:`آخر ٧ أيام`,dateOlder:`أقدم`,dateToday:`اليوم`,dateYesterday:`أمس`,dropZone:`أفلت الملفات لإرفاقها`,errorGeneric:`حدث خطأ ما`,errorRateLimited:`طلبات كثيرة جدًا — يرجى المحاولة بعد لحظة.`,errorRetry:`إعادة المحاولة`,expand:`توسيع`,expandSidebar:`توسيع الشريط الجانبي`,exitFullscreen:`إنهاء ملء الشاشة`,fullscreen:`ملء الشاشة`,history:`السجل`,historyBack:`العودة إلى الدردشة`,historyEmpty:`لا توجد دردشات سابقة بعد`,historyContinue:`متابعة الدردشة`,historyLoading:`جارٍ تحميل دردشاتك…`,historyTitle:`سجل الدردشات`,loadMoreConversations:`تحميل المزيد من المحادثات`,language:`اللغة`,launcherOpen:`فتح الدردشة`,launcherLabel:`تحدث معنا`,micStart:`بدء الإدخال الصوتي`,micStop:`إيقاف الإدخال الصوتي`,micUnsupported:`الإدخال الصوتي غير مدعوم في هذا المتصفح`,moreActions:`إجراءات إضافية`,newConversation:`دردشة جديدة`,panelTitle:`الدردشة`,popOut:`فتح في علامة تبويب جديدة`,resizeHandle:`اسحب لتغيير الحجم`,scrollToBottom:`الانتقال إلى الأحدث`,send:`إرسال`,queueMessage:`إضافة الرسالة إلى قائمة الانتظار`,removeQueuedMessage:`إزالة الرسالة من قائمة الانتظار`,compactingContext:`جارٍ تحسين سياق المحادثة…`,soundOff:`كتم الصوت`,soundOn:`تشغيل الصوت`,startNewConversation:`بدء دردشة جديدة`,talkToOperator:`التحدث إلى شخص`,connectingOperator:`جارٍ توصيلك بشخص…`,noOperatorAvailable:`لا يوجد موظفون متاحون الآن — اترك بياناتك وسنتواصل معك.`,chattingWithOperator:`أنت تتحدث مع {operator}`,cancelOperatorRequest:`متابعة المحادثة مع الذكاء الاصطناعي`,stop:`إيقاف`,theme:`المظهر`,themeAuto:`تلقائي`,themeDark:`داكن`,themeLight:`فاتح`,textSize:`حجم النص`,textSizeSmall:`صغير`,textSizeNormal:`عادي`,textSizeLarge:`كبير`,loading:`جارٍ التحميل…`,visualPreparing:`جارٍ إعداد المحتوى المرئي…`,visualError:`تعذر عرض هذا المحتوى المرئي.`,visualPartial:`تعذر عرض بعض أجزاء هذا المحتوى المرئي.`,thinking:`يفكّر…`,thoughts:`الأفكار`,toolResult:`النتيجة`,sources:`المصادر`,feedbackUp:`رد جيد`,feedbackDown:`رد سيئ`,feedbackThanks:`شكرًا على ملاحظاتك`,copy:`نسخ`,copied:`تم النسخ`,tabHome:`الرئيسية`,tabConversations:`الدردشات`,tabHelp:`المساعدة`,tabNews:`الأخبار`,modulesEmpty:`لا شيء هنا بعد`,moduleBack:`رجوع`,contentLoading:`جارٍ التحميل…`,contentHelpful:`هل كان هذا مفيدًا؟`,homeGreeting:`كيف يمكننا مساعدتك؟`,homeGreetingNamed:`مرحبًا {name} 👋`,homeGreetingLead:`كيف يمكننا مساعدتك؟`,homeSearchPlaceholder:`ابحث عن مساعدة`,homeAskPlaceholder:`اطرح سؤالاً…`,homeWhatsNew:`ما الجديد`,homeContentTitle:`مقالات شائعة`,homeStatus:`الحالة`,helpTitle:`المساعدة`,helpSearchPlaceholder:`ابحث عن مساعدة`,helpEmpty:`لا توجد مقالات مساعدة بعد`,helpLoading:`جارٍ تحميل المساعدة…`,helpSearchEmpty:`لا نتائج لـ «{query}»`,helpShowMore:`عرض المزيد`,newsTitle:`الأخبار`,newsEmpty:`لا توجد أخبار بعد`,newsLoading:`جارٍ تحميل الأخبار…`,newsBack:`العودة إلى الأخبار`,newsPublishedAt:`نُشر في {date}`,newsShowMore:`عرض المزيد`,newsUnseen:`منشور جديد`,formSubmit:`إرسال`,formSkip:`لاحقًا`,formSubmitted:`تم`,formSkipped:`لاحقًا`,formFillOut:`تعبئة`,formRequired:`هذا الحقل مطلوب`,formInvalidEmail:`أدخل بريدًا إلكترونيًا صحيحًا`,formInvalidTel:`أدخل رقم هاتف صحيحًا`,formInvalidUrl:`أدخل رابطًا صحيحًا`,formInvalidNumber:`أدخل رقمًا صحيحًا`,formTooShort:`قصير جدًا (الحد الأدنى {min} حرفًا)`,formTooLong:`طويل جدًا (الحد الأقصى {max} حرفًا)`,formNumberTooSmall:`يجب ألا يقل عن {min}`,formNumberTooLarge:`يجب ألا يزيد عن {max}`,formPatternMismatch:`يرجى مطابقة الصيغة المطلوبة`,formChooseAtLeast:`اختر {min} على الأقل`,formChooseAtMost:`اختر {max} على الأكثر`,formOther:`أخرى`,formOtherPlaceholder:`اكتب إجابتك…`,inputRequired:`أسئلة لك`,inputBadge:`أسئلة`,inputAnswered:`تمت الإجابة`,inputSkipped:`تم التخطي`,showOptions:`إظهار الخيارات`,hideOptions:`إخفاء الخيارات`,qtypeText:`إجابتك`,qtypeEmail:`عنوان البريد الإلكتروني`,qtypePhone:`رقم الهاتف`,qtypeNumber:`رقم`,qtypeDate:`تاريخ`,qtypeChooseOne:`اختر واحدًا`,qtypeChooseAny:`اختر أيًا`,qtypeBoolean:`نعم / لا`,inputSubmit:`إرسال الإجابات`,inputSubmitHint:`Enter للإرسال · Shift+Enter = سطر جديد`,inputSkip:`تخطٍّ`,confirmYes:`نعم`,confirmNo:`لا`,approve:`موافقة`,reject:`رفض`,approvalPrompt:`تتطلب {tool} موافقتك للتنفيذ.`,approvalBody:`راجع مُعطيات الأداة أعلاه وقرّر السماح بهذا الإجراء أو رفضه.`,approvalYourResponse:`ردّك: {decision}`,approvalEditHint:`يمكنك تعديل ردّك حتى تستأنف هذه الخطوة.`,approvalSubmitting:`تم إرسال الرد. جارٍ التنفيذ…`,edit:`تعديل`,toolParameters:`المعطيات`,statusAwaiting:`بانتظار الموافقة`,statusResponded:`تم الإرسال`,statusRunning:`قيد التنفيذ`,statusCompleted:`مكتمل`,statusDenied:`مرفوض`,statusError:`خطأ`,statusSuperseded:`تم التخطي`},es:{attach:`Adjuntar archivos`,attachmentMimeRejected:`Tipo de archivo no admitido`,attachmentTooLarge:`El archivo es demasiado grande`,attachmentTooMany:`Se alcanzó el límite de adjuntos`,conversationClosed:`Este chat está cerrado`,conversationLoading:`Cargando chat…`,loadPreviousMessages:`Cargar mensajes anteriores`,close:`Cerrar`,collapse:`Contraer`,collapseSidebar:`Contraer la barra lateral`,composerPlaceholder:`Escribe un mensaje…`,dateLastWeek:`Últimos 7 días`,dateOlder:`Anteriores`,dateToday:`Hoy`,dateYesterday:`Ayer`,dropZone:`Suelta los archivos para adjuntarlos`,errorGeneric:`Algo salió mal`,errorRateLimited:`Demasiadas solicitudes: inténtalo de nuevo en un momento.`,errorRetry:`Reintentar`,expand:`Ampliar`,expandSidebar:`Expandir la barra lateral`,exitFullscreen:`Salir de pantalla completa`,fullscreen:`Pantalla completa`,history:`Historial`,historyBack:`Volver al chat`,historyEmpty:`Aún no tienes chats`,historyContinue:`Continuar el chat`,historyLoading:`Cargando tus chats…`,historyTitle:`Historial de chats`,loadMoreConversations:`Cargar más conversaciones`,language:`Idioma`,launcherOpen:`Abrir el chat`,launcherLabel:`Chatea con nosotros`,micStart:`Iniciar entrada de voz`,micStop:`Detener entrada de voz`,micUnsupported:`Este navegador no admite la entrada de voz`,moreActions:`Más acciones`,newConversation:`Nuevo chat`,panelTitle:`Chat`,popOut:`Abrir en una pestaña nueva`,resizeHandle:`Arrastra para cambiar el tamaño`,scrollToBottom:`Ir a lo más reciente`,send:`Enviar`,queueMessage:`Poner mensaje en cola`,removeQueuedMessage:`Quitar mensaje de la cola`,compactingContext:`Optimizando el contexto de la conversación…`,soundOff:`Sonido desactivado`,soundOn:`Sonido activado`,startNewConversation:`Iniciar un chat nuevo`,talkToOperator:`Hablar con una persona`,connectingOperator:`Conectándote con una persona…`,noOperatorAvailable:`Nadie está disponible ahora — deja tus datos y te contactaremos.`,chattingWithOperator:`Estás chateando con {operator}`,cancelOperatorRequest:`Seguir con la IA`,stop:`Detener`,theme:`Tema`,themeAuto:`Automático`,themeDark:`Oscuro`,themeLight:`Claro`,textSize:`Tamaño del texto`,textSizeSmall:`Pequeño`,textSizeNormal:`Normal`,textSizeLarge:`Grande`,loading:`Cargando…`,visualPreparing:`Preparando visualización…`,visualError:`No se pudo mostrar esta visualización.`,visualPartial:`No se pudieron mostrar algunas partes de esta visualización.`,thinking:`Pensando…`,thoughts:`Razonamiento`,toolResult:`Resultado`,sources:`Fuentes`,feedbackUp:`Buena respuesta`,feedbackDown:`Mala respuesta`,feedbackThanks:`Gracias por tu opinión`,copy:`Copiar`,copied:`Copiado`,tabHome:`Inicio`,tabConversations:`Chats`,tabHelp:`Ayuda`,tabNews:`Novedades`,modulesEmpty:`Aún no hay nada aquí`,moduleBack:`Atrás`,contentLoading:`Cargando…`,contentHelpful:`¿Te resultó útil?`,homeGreeting:`¿Cómo podemos ayudarte?`,homeGreetingNamed:`Hola, {name} 👋`,homeGreetingLead:`¿Cómo podemos ayudarte?`,homeSearchPlaceholder:`Buscar ayuda`,homeAskPlaceholder:`Haz una pregunta…`,homeWhatsNew:`Lo nuevo`,homeContentTitle:`Artículos populares`,homeStatus:`Estado`,helpTitle:`Ayuda`,helpSearchPlaceholder:`Buscar ayuda`,helpEmpty:`Aún no hay artículos de ayuda`,helpLoading:`Cargando la ayuda…`,helpSearchEmpty:`Sin resultados para «{query}»`,helpShowMore:`Mostrar más`,newsTitle:`Novedades`,newsEmpty:`Aún no hay novedades`,newsLoading:`Cargando novedades…`,newsBack:`Volver a novedades`,newsPublishedAt:`Publicado el {date}`,newsShowMore:`Mostrar más`,newsUnseen:`Publicación nueva`,formSubmit:`Enviar`,formSkip:`Quizá más tarde`,formSubmitted:`Completado`,formSkipped:`Quizá más tarde`,formFillOut:`Completar`,formRequired:`Este campo es obligatorio`,formInvalidEmail:`Introduce un correo electrónico válido`,formInvalidTel:`Introduce un número de teléfono válido`,formInvalidUrl:`Introduce una URL válida`,formInvalidNumber:`Introduce un número válido`,formTooShort:`Demasiado corto (mín. {min} caracteres)`,formTooLong:`Demasiado largo (máx. {max} caracteres)`,formNumberTooSmall:`Debe ser al menos {min}`,formNumberTooLarge:`Debe ser como máximo {max}`,formPatternMismatch:`Respeta el formato solicitado`,formChooseAtLeast:`Elige al menos {min}`,formChooseAtMost:`Elige como máximo {max}`,formOther:`Otro`,formOtherPlaceholder:`Escribe tu respuesta…`,inputRequired:`Preguntas para ti`,inputBadge:`Preguntas`,inputAnswered:`Respondido`,inputSkipped:`Omitido`,showOptions:`Mostrar opciones`,hideOptions:`Ocultar opciones`,qtypeText:`Tu respuesta`,qtypeEmail:`Correo electrónico`,qtypePhone:`Número de teléfono`,qtypeNumber:`Número`,qtypeDate:`Fecha`,qtypeChooseOne:`Elige una`,qtypeChooseAny:`Elige varias`,qtypeBoolean:`Sí / No`,inputSubmit:`Enviar respuestas`,inputSubmitHint:`Enter para enviar · Mayús+Enter = nueva línea`,inputSkip:`Omitir`,confirmYes:`Sí`,confirmNo:`No`,approve:`Aprobar`,reject:`Rechazar`,approvalPrompt:`{tool} requiere tu aprobación para ejecutarse.`,approvalBody:`Revisa los parámetros de arriba y decide si permites esta acción.`,approvalYourResponse:`Tu respuesta: {decision}`,approvalEditHint:`Puedes cambiar tu respuesta hasta que este paso continúe.`,approvalSubmitting:`Respuesta enviada. Procesando…`,edit:`Editar`,toolParameters:`Parámetros`,statusAwaiting:`Esperando aprobación`,statusResponded:`Enviado`,statusRunning:`En curso`,statusCompleted:`Completado`,statusDenied:`Denegado`,statusError:`Error`,statusSuperseded:`Omitido`},he:{attach:`צירוף קבצים`,attachmentMimeRejected:`סוג הקובץ אינו נתמך`,attachmentTooLarge:`הקובץ גדול מדי`,attachmentTooMany:`הגעת למספר המרבי של קבצים מצורפים`,conversationClosed:`הצ׳אט הזה נסגר`,conversationLoading:`טוען צ׳אט…`,loadPreviousMessages:`טעינת הודעות קודמות`,close:`סגירה`,collapse:`כיווץ`,collapseSidebar:`כיווץ סרגל הצד`,composerPlaceholder:`כתוב הודעה…`,dateLastWeek:`7 הימים האחרונים`,dateOlder:`ישן יותר`,dateToday:`היום`,dateYesterday:`אתמול`,dropZone:`שחרר קבצים כדי לצרף`,errorGeneric:`משהו השתבש`,errorRateLimited:`יותר מדי בקשות — נסה שוב בעוד רגע.`,errorRetry:`נסה שוב`,expand:`הרחבה`,expandSidebar:`הרחבת סרגל הצד`,exitFullscreen:`יציאה ממסך מלא`,fullscreen:`מסך מלא`,history:`היסטוריה`,historyBack:`חזרה לצ׳אט`,historyEmpty:`אין עדיין צ׳אטים קודמים`,historyContinue:`המשך צ׳אט`,historyLoading:`טוען את הצ׳אטים שלך…`,historyTitle:`היסטוריית צ׳אטים`,loadMoreConversations:`טעינת שיחות נוספות`,language:`שפה`,launcherOpen:`פתיחת צ׳אט`,launcherLabel:`דברו איתנו`,micStart:`התחלת קלט קולי`,micStop:`עצירת קלט קולי`,micUnsupported:`קלט קולי אינו נתמך בדפדפן זה`,moreActions:`פעולות נוספות`,newConversation:`צ׳אט חדש`,panelTitle:`צ׳אט`,popOut:`פתיחה בכרטיסייה חדשה`,resizeHandle:`גרור לשינוי הגודל`,scrollToBottom:`מעבר לחדש ביותר`,send:`שליחה`,queueMessage:`הוספת ההודעה לתור`,removeQueuedMessage:`הסרת ההודעה מהתור`,compactingContext:`מבצע אופטימיזציה להקשר השיחה…`,soundOff:`השתקת הצליל`,soundOn:`הפעלת הצליל`,startNewConversation:`התחלת צ׳אט חדש`,talkToOperator:`דברו עם אדם`,connectingOperator:`מחברים אותך לאדם…`,noOperatorAvailable:`אין נציגים זמינים כעת — השאר את הפרטים שלך ונחזור אליך.`,chattingWithOperator:`אתה מצ׳וטט עם {operator}`,cancelOperatorRequest:`המשך לשוחח עם ה-AI`,stop:`עצירה`,theme:`ערכת נושא`,themeAuto:`אוטומטי`,themeDark:`כהה`,themeLight:`בהיר`,textSize:`גודל טקסט`,textSizeSmall:`קטן`,textSizeNormal:`רגיל`,textSizeLarge:`גדול`,loading:`טוען…`,visualPreparing:`מכין תצוגה…`,visualError:`לא ניתן היה להציג תצוגה זו.`,visualPartial:`לא ניתן היה להציג חלקים מתצוגה זו.`,thinking:`חושב…`,thoughts:`מחשבות`,toolResult:`תוצאה`,sources:`מקורות`,feedbackUp:`תשובה טובה`,feedbackDown:`תשובה גרועה`,feedbackThanks:`תודה על המשוב`,copy:`העתק`,copied:`הועתק`,tabHome:`בית`,tabConversations:`צ׳אטים`,tabHelp:`עזרה`,tabNews:`חדשות`,modulesEmpty:`אין כאן עדיין כלום`,moduleBack:`חזרה`,contentLoading:`טוען…`,contentHelpful:`האם זה עזר?`,homeGreeting:`כיצד נוכל לעזור?`,homeGreetingNamed:`שלום {name} 👋`,homeGreetingLead:`כיצד נוכל לעזור?`,homeSearchPlaceholder:`חיפוש עזרה`,homeAskPlaceholder:`שאלו שאלה…`,homeWhatsNew:`מה חדש`,homeContentTitle:`מאמרים פופולריים`,homeStatus:`סטטוס`,helpTitle:`עזרה`,helpSearchPlaceholder:`חיפוש עזרה`,helpEmpty:`אין עדיין מאמרי עזרה`,helpLoading:`טוען עזרה…`,helpSearchEmpty:`אין תוצאות עבור „{query}”`,helpShowMore:`הצגת עוד`,newsTitle:`חדשות`,newsEmpty:`אין עדיין חדשות`,newsLoading:`טוען חדשות…`,newsBack:`חזרה לחדשות`,newsPublishedAt:`פורסם ב-{date}`,newsShowMore:`הצגת עוד`,newsUnseen:`פוסט חדש`,formSubmit:`שליחה`,formSkip:`אחר כך`,formSubmitted:`נשלח`,formSkipped:`דולג`,formFillOut:`מילוי`,formRequired:`שדה חובה`,formInvalidEmail:`הזן כתובת אימייל תקינה`,formInvalidTel:`הזן מספר טלפון תקין`,formInvalidUrl:`הזן כתובת URL תקינה`,formInvalidNumber:`הזן מספר תקין`,formTooShort:`קצר מדי (לפחות {min} תווים)`,formTooLong:`ארוך מדי (לכל היותר {max} תווים)`,formNumberTooSmall:`חייב להיות לפחות {min}`,formNumberTooLarge:`חייב להיות לכל היותר {max}`,formPatternMismatch:`התאם לתבנית הנדרשת`,formChooseAtLeast:`בחר לפחות {min}`,formChooseAtMost:`בחר לכל היותר {max}`,formOther:`אחר`,formOtherPlaceholder:`כתוב את תשובתך…`,inputRequired:`שאלות עבורך`,inputBadge:`שאלות`,inputAnswered:`נענה`,inputSkipped:`דולג`,showOptions:`הצג אפשרויות`,hideOptions:`הסתר אפשרויות`,qtypeText:`התשובה שלך`,qtypeEmail:`כתובת אימייל`,qtypePhone:`מספר טלפון`,qtypeNumber:`מספר`,qtypeDate:`תאריך`,qtypeChooseOne:`בחר אחת`,qtypeChooseAny:`בחר כמה`,qtypeBoolean:`כן / לא`,inputSubmit:`שליחת תשובות`,inputSubmitHint:`Enter לשליחה · Shift+Enter = שורה חדשה`,inputSkip:`דילוג`,confirmYes:`כן`,confirmNo:`לא`,approve:`אישור`,reject:`דחייה`,approvalPrompt:`הכלי {tool} דורש את אישורך כדי לפעול.`,approvalBody:`בדוק את פרמטרי הכלי שלמעלה והחלט אם לאשר פעולה זו.`,approvalYourResponse:`התגובה שלך: {decision}`,approvalEditHint:`ניתן לערוך את תגובתך עד שהשלב הזה יתחדש.`,approvalSubmitting:`התגובה נשלחה. מבצע…`,edit:`עריכה`,toolParameters:`פרמטרים`,statusAwaiting:`ממתין לאישור`,statusResponded:`נשלח`,statusRunning:`פועל`,statusCompleted:`הושלם`,statusDenied:`נדחה`,statusError:`שגיאה`,statusSuperseded:`דולג`}};function Te(e,t){let n=Ee(e),r=Ae(t),i=n===`en`?{}:we[n]??{},a=r?t[n]??{}:t??{},o=r?t.en??{}:{};return{...Ce,...i,...o,...a}}function Ee(e){return(e.split(`-`)[0]??`en`).toLowerCase()}const De=/* @__PURE__ */ new Set([`ar`,`he`,`iw`,`fa`,`ur`,`ps`,`sd`,`ug`,`yi`,`dv`,`ckb`,`ks`,`nqo`,`prs`,`syr`]);function Oe(e){return De.has(Ee(e))}function ke(e,t){return e[t]??t}function Ae(e){if(!e)return!1;for(let t of Object.values(e))if(t&&typeof t==`object`)return!0;return!1}const P={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`},je=new class{get(e){try{return localStorage.getItem(e)}catch{return null}}set(e,t){try{localStorage.setItem(e,t)}catch{}}remove(e){try{localStorage.removeItem(e)}catch{}}},Me={maxBytes:10485760,maxCount:10,accept:`*/*`},Ne={voice:`local`},Pe={list:[],byTrigger:{}},Fe={enabled:!0,sampleRate:1},Ie={upload:`/pai/upload-file`,transcribe:`/pai/transcribe-audio`,submitForm:`/pai/submit-form`},Le={variant:`circle`,size:`md`,label:void 0,icon:`chat`,hidden:!1},Re={floating:[`theme`,`textSize`,`history`,`close`,`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`language`],inline:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`],standalone:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],page:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],modal:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`],drawer:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`]},ze={enabled:!0,volume:.3,events:void 0},Be={enabled:!0,events:void 0},Ve=[{label:`tabConversations`,layout:`chat`}],He=[`off`,`error`,`warn`,`info`,`debug`,`trace`],F=P.cssPrefix,Ue=`${F}.debug`,We=`__${P.global}_DEBUG__`,Ge=`${F}-debug`;let Ke=2,qe=null;function Je(){if(typeof window>`u`)return 2;try{let e=new URLSearchParams(window.location.search).get(Ge);if(e!==null){let t=Ye(e);if(t>=0)return t}}catch{}try{let e=window.localStorage?.getItem(Ue);if(e){let t=Ye(e);if(t>=0)return t}}catch{}return Reflect.get(window,We)?4:2}function Ye(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=He.findIndex(t=>t===e);if(t>=0)return t}return-1}function Xe(e){let t=Ye(e);if(!(t<0)){Ke=t;try{window.localStorage?.setItem(Ue,He[t]??`off`)}catch{}}}function Ze(){return He[Ke]??`warn`}Ke=Je();function Qe(e){let t=`[${F}:${e}]`;function n(n,r,i){return(a,o)=>{if(!(Ke<n)&&(o===void 0?console[r](t,a):console[r](t,a,o),qe))try{qe({level:i,scope:e,message:a,payload:o})}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:t=>Qe(`${e}:${t}`)}}const I=Qe(`core`);function $e(e){qe=e}const et=I.scope(`context`),tt=/* @__PURE__ */ new Set([`visitorId`,`conversationId`,`jwt`,`token`,`authorization`,`password`]),nt=1024,rt=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function it(e){return ot(e,`userContext`,!0)}function at(e){return ot(e,`pageContext`,!1)}function ot(e,t,n){if(e==null)return;if(typeof e!=`object`||Array.isArray(e)){et.warn(`ignored ${t} — expected an object`,{type:Array.isArray(e)?`array`:typeof e});return}let r={},i=0;for(let[n,a]of Object.entries(e)){if(tt.has(n)){et.warn(`dropped reserved ${t} key "${n}" — managed by the widget, not host-settable`);continue}if(a==null)continue;if(i>=50){et.warn(`${t} truncated at 50 keys — dropped "${n}"`);continue}let e=st(t,n,a);e!==void 0&&(r[n]=e,i++)}return n&&typeof r.email==`string`&&!rt.test(r.email)&&(et.warn(`dropped malformed context field`,{field:`${t}.email`,reason:`invalid format`}),delete r.email),Object.keys(r).length>0?r:void 0}function st(e,t,n){if(typeof n==`boolean`)return n;if(typeof n==`number`){if(!Number.isFinite(n)){et.warn(`dropped non-finite ${e}.${t}`);return}return n}if(typeof n==`string`){let r=n.trim();return r===``?void 0:r.length>nt?(et.warn(`truncated ${e}.${t} to ${nt} chars`),r.slice(0,nt)):r}et.warn(`dropped ${e}.${t} — only string/number/boolean values are allowed`,{type:typeof n})}function ct(e){let t=typeof e==`object`&&e?e:{},n=t.presentation??{},r=t.behavior??{},i=t.i18n??{},a=t.feedback??{},o=t.footer??{},s=t.header??{},{themeMode:c,themeOverrides:l}=lt(t.theme),u=n.mode??`floating`,d=ut(i.defaultLocale),f=i.availableLocales??[i.locale??d],p=dt(i.locale??d,f,d),m=(t.baseUrl??P.defaultBaseUrl).replace(/\/$/,``),h=(t.agentApiBaseUrl??`${m}/api/agent`).replace(/\/$/,``),g=(t.dataApiBaseUrl??`${m}/api/data`).replace(/\/$/,``);return{widgetId:t.widgetId??`default`,publicKey:t.publicKey,aiAgentDeploymentId:t.aiAgentDeploymentId,baseUrl:m,agentApiBaseUrl:h,dataApiBaseUrl:g,userContext:it(t.userContext),pageContext:at(t.pageContext),position:n.position??`bottom-right`,themeMode:c,textSize:`normal`,themeOverrides:l,mode:u,iframe:n.iframe??!1,responseMode:r.responseMode??`streaming`,showReasoning:r.showReasoning??!1,showToolCalls:r.showToolCalls??!1,showSources:r.showSources??!1,enableMessageFeedback:!(r.disableMessageFeedback??!1),autoSendSuggestions:r.autoSendSuggestions??!1,popOutUrl:r.popOutUrl,features:{voice:t.features?.voice??Ne.voice,fileUpload:!(t.features?.disableFileUpload??!1),humanInLoop:!(t.features?.disableHumanInLoop??!1),operatorRequest:t.features?.enableOperatorRequest===!0},forms:yt(t.forms,p),endpoints:{upload:t.endpoints?.upload??Ie.upload,transcribe:t.endpoints?.transcribe??Ie.transcribe,submitForm:t.endpoints?.submitForm??Ie.submitForm},attachments:{accept:t.composer?.attachments?.accept??Me.accept,maxBytes:t.composer?.attachments?.maxBytes??Me.maxBytes,maxCount:t.composer?.attachments?.maxCount??Me.maxCount},locale:p,defaultLocale:d,availableLocales:f,startMinimized:r.startMinimized??!0,actions:ft(u,s.actions),size:n.size??{},launcher:xt(t.launcher),sound:pt(a.sound),haptics:mt(a.haptics),strings:Te(p,i.strings),stringsOverride:i.strings,composerDisclaimer:o.composerDisclaimer??``,poweredBy:gt(o.poweredBy),composer:_t(t.composer),modules:vt(t.modules),tracking:ht(t.tracking,g),storage:t.storage??je,userToken:t.userToken,onMessage:t.onMessage,onOpen:t.onOpen,onClose:t.onClose,onError:t.onError}}function lt(e){if(typeof e==`string`)return{themeMode:e,themeOverrides:{}};if(!e||typeof e!=`object`)return{themeMode:`auto`,themeOverrides:{}};let{mode:t,...n}=e;return{themeMode:t??`auto`,themeOverrides:n}}function ut(e){return e&&e!==`auto`?e:globalThis.navigator?.language||`en`}function dt(e,t,n){return t.length<=1||t.includes(e)?e:t.includes(n)?n:t[0]??e}function ft(e,t){return t??Re[e]}function pt(e){return{enabled:e?.enabled??ze.enabled,volume:e?.volume??ze.volume,events:e?.events}}function mt(e){return{enabled:e?.enabled??Be.enabled,events:e?.events}}function ht(e,t){let n=e?.sampleRate??Fe.sampleRate;return{enabled:e?.enabled??Fe.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 gt(e){let t={text:`Powered by ${P.displayName}`,href:P.siteUrl,...e};return t.text||t.logoUrl?t:null}function _t(e){let t=e?.sendButton;return{sendButton:{shape:t?.shape??`circle`,icon:t?.icon??`arrowUp`,variant:t?.variant??`filled`}}}function vt(e){let t=e??Ve,n=/* @__PURE__ */ new Set,r=[];for(let e of t.slice(0,4)){if(!e?.label||!e?.layout)continue;let t=e.contentCollectionIds?.filter(Boolean),i=e.id??t?.[0]??e.layout;for(;n.has(i);)i=`${i}-${r.length}`;n.add(i);let a={id:i,label:e.label,layout:e.layout};t?.length&&(a.contentCollectionIds=t),e.layout===`home`&&(a.brandName=e.brandName,a.greetingText=e.greetingText,a.showGreeting=!(e.hideGreeting??!1),a.showSearchBar=!(e.hideSearchBar??!1),a.showRecentConversations=!(e.hideRecentConversations??!1),e.userAvatars?.length&&(a.userAvatars=e.userAvatars),e.status&&(a.status=e.status),a.contentBlockTitle=e.contentBlockTitle),r.push(a)}return{list:r,byId:Object.fromEntries(r.map(e=>[e.id,e]))}}function yt(e,t){if(!e?.length)return Pe;let n=[],r=/* @__PURE__ */ new Set;for(let i of e){if(!i?.id||r.has(i.id))continue;let e=Se(i,t),a=(e.fields??[]).filter(e=>!!(e?.name&&e.label&&e.type)),o=(Array.isArray(e.on)?e.on:[e.on]).map(bt).filter(e=>e!==null);a.length!==0&&o.length!==0&&(r.add(e.id),n.push({id:e.id,triggers:o,when:e.when,fields:a,title:e.title,description:e.description,submitLabel:e.submitLabel,skippable:e.skippable??!1,frequency:e.frequency??`once`,mirrorToContext:e.mirrorToContext??!0,reopenable:e.reopenable??!0,reviewable:e.reviewable??!0}))}let i={};for(let e of n){var a;for(let t of e.triggers)(i[a=t.kind]??(i[a]=[])).push(e)}return{list:n,byTrigger:i}}function bt(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 e=Number(n);return Number.isFinite(e)&&e>0?{kind:`after-messages`,param:e}:null}if(t===`idle`){let e=Number(n);return Number.isFinite(e)&&e>0?{kind:`idle`,param:e}:null}return t===`page-area`&&n?{kind:`page-area`,param:n}:null}function xt(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??Le.variant,size:e?.size??Le.size,label:e?.label??Le.label,icon:e?.icon??Le.icon,hidden:e?.hidden??Le.hidden,callout:t}}function St(e,t,n,r){let i=dt(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=Te(i,e.stringsOverride)),n!==e.themeMode&&(a.themeMode=n),r!==e.textSize&&(a.textSize=r),a}const Ct=[`presentation`,`behavior`,`theme`,`launcher`,`header`,`composer`,`feedback`,`i18n`,`footer`,`features`,`tracking`,`endpoints`];function wt(e,t){if(!t)return e;let n={...e};for(let r of Ct){let i=t[r];if(i===void 0)continue;let a=e[r];r===`theme`?a===void 0?n[r]=i:typeof a==`string`&&typeof i==`object`&&i&&(n[r]={...i,mode:a}):r!==`i18n`&&(n[r]=Tt(i,a))}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 e=Tt(i??{},r);i?.availableLocales!==void 0&&(e.availableLocales=i.availableLocales),i?.defaultLocale!==void 0&&(e.defaultLocale=i.defaultLocale);let t=r?.strings,a=i?.strings;(t||a)&&(e.strings=Et(a,t)),n.i18n=e}return n}function Tt(e,t){if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function Et(e,t){if(!e)return t;if(!t)return e;let n=Ae(e),r=Ae(t);if(!n&&!r)return{...e,...t};let i={},a=n?e:{en:e},o=r?t:{en:t};for(let[e,t]of Object.entries(a))i[e]={...t};for(let[e,t]of Object.entries(o))i[e]={...i[e],...t};return i}const Dt=[`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`history`,`language`,`theme`,`textSize`,`close`];function Ot(e){return e!==`false`}const kt=[[`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]],At=[[`mode`,`mode`,e=>e],[`position`,`position`,e=>e],[`iframe`,`iframe`,Ot]],jt=[[`width`,`width`],[`height`,`height`]],Mt=[[`response-mode`,`responseMode`,e=>e],[`start-minimized`,`startMinimized`,Ot],[`show-reasoning`,`showReasoning`,Ot],[`show-tool-calls`,`showToolCalls`,Ot],[`show-sources`,`showSources`,Ot],[`disable-message-feedback`,`disableMessageFeedback`,Ot],[`auto-send-suggestions`,`autoSendSuggestions`,Ot],[`pop-out-url`,`popOutUrl`]],Nt=[[`locale`,`locale`]];new Set(Dt);const Pt=[[`launcher-variant`,`variant`,e=>e],[`launcher-size`,`size`,e=>e],[`launcher-icon`,`icon`],[`launcher-hidden`,`hidden`,Ot]],Ft=[[`features-disable-file-upload`,`disableFileUpload`,Ot],[`features-voice`,`voice`,e=>e]],It=[[`endpoint-upload`,`upload`],[`endpoint-transcribe`,`transcribe`]],Lt=[[`user-id`,`id`],[`user-email`,`email`],[`user-name`,`name`]],Rt=[[`page-area`,`area`],[`page-url`,`url`],[`page-path`,`path`],[`page-title`,`title`]],zt=[`launcher-label`,`callout-text`,`callout-delay`,`actions`,`user-context`,`page-context`],Bt=[kt,At,jt,Mt,Nt,Pt,Ft,It,Lt,Rt],Vt=/* @__PURE__ */ new Set([`iframe`,`start-minimized`]);[...Bt.flatMap(e=>e.map(([e])=>e).filter(e=>!Vt.has(e))),...zt];function Ht(){let e=Date.now(),t=/* @__PURE__ */ 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,Ut(t.subarray(6)),t[6]=t[6]&15|112,t[8]=t[8]&63|128;let n=Array.from(t,e=>e.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 Ut(e){if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256)}const Wt=I.scope(`persistence`);function Gt(e,t=je,n){let r=n?`${e}.${n}`:e,i=`${P.cssPrefix}.storageVersion`,a=t.get(i)??void 0,o=a?`.v${a}`:``,s=`${P.cssPrefix}.${r}${o}`,c=`${P.cssPrefix}${o}.visitorId`,l=`${s}.conversationId`,u=`${s}.userPrefs`,d=`${s}.panelOpen`,f=`${s}.panelSize`,p=`${s}.calloutDismissed`,m=`${s}.sidebarCollapsed`,h=`${s}.activeModule`,g=`${s}.seenNewsId`,_=`${s}.historyCount`,v=`${s}.formsDone`,y={getVisitorId(){let e=t.get(c);if(e)return e;let n=Ht();return t.set(c,n),n},loadConversationId(){return t.get(l)??void 0},saveConversationId(e){Wt.trace(`saveConversationId`,{id:e,scope:r}),e?t.set(l,e):t.remove(l)},loadDraft(e){return t.get(`${s}.draft.${e}`)??``},saveDraft(e,n){let r=`${s}.draft.${e}`;n?t.set(r,n):t.remove(r)},loadMessageQueue(e){let n=t.get(`${s}.messageQueue.${e}`);if(!n)return[];try{let e=JSON.parse(n);return!Array.isArray(e)||!e.every(qt)?[]:e}catch(e){return Wt.warn(`loadMessageQueue parse failed`,{error:e}),[]}},saveMessageQueue(e,n){let r=`${s}.messageQueue.${e}`;if(n.length===0)t.remove(r);else try{t.set(r,JSON.stringify(n))}catch(e){Wt.warn(`saveMessageQueue serialise failed`,{error:e})}},loadUserPrefs(){let e=t.get(u);if(!e)return{};try{return Jt(JSON.parse(e))}catch(e){return Wt.warn(`loadUserPrefs parse failed`,{error:e}),{}}},saveUserPrefs(e){try{t.set(u,JSON.stringify(e))}catch(e){Wt.warn(`saveUserPrefs serialise failed`,{error:e})}},patchUserPrefs(e){let t=y.loadUserPrefs();y.saveUserPrefs({...t,...e})},loadPanelOpen(){let e=t.get(d);return e===`1`||e!==`0`&&null},savePanelOpen(e){t.set(d,e?`1`:`0`)},loadPanelSize(){let e=t.get(f);return e===`normal`||e===`expanded`||e===`fullscreen`?e:null},savePanelSize(e){t.set(f,e)},loadCalloutDismissed(e){if(!e)return!1;let n=t.get(p);return!!n&&n===e},saveCalloutDismissed(e){e?t.set(p,e):t.remove(p)},loadSidebarCollapsed(){let e=t.get(m);return e===`1`||e!==`0`&&null},saveSidebarCollapsed(e){t.set(m,e?`1`:`0`)},loadActiveModule(){return t.get(h)||null},saveActiveModule(e){t.set(h,e)},loadSeenNewsId(){return t.get(g)||null},saveSeenNewsId(e){t.set(g,e)},loadHistoryCount(){let e=t.get(_);if(!e)return null;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:null},saveHistoryCount(e){t.set(_,String(e))},loadFormsDone(){let e=t.get(v);if(!e)return{};try{let t=JSON.parse(e);return Kt(t)?Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]==`number`)):{}}catch(e){return Wt.warn(`loadFormsDone parse failed`,{error:e}),{}}},saveFormDone(e){try{let n=y.loadFormsDone();n[e]=Date.now(),t.set(v,JSON.stringify(n))}catch(e){Wt.warn(`saveFormDone serialise failed`,{error:e})}},rememberStorageVersion(e){e&&e!==t.get(i)&&(Wt.debug(`rememberStorageVersion (force-reset on next load)`,{version:e}),t.set(i,e))},clearConversation(){t.remove(l)},reset(){let e=t.get(l);e&&(t.remove(`${s}.draft.${e}`),t.remove(`${s}.messageQueue.${e}`));for(let e of[c,l,u,d,f,p,m,h,g,_,v])t.remove(e);Wt.info(`reset: forgot the visitor`,{scope:r})}};return y}function Kt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qt(e){return Kt(e)&&typeof e.id==`string`&&e.id.length>0&&typeof e.text==`string`}function Jt(e){if(!Kt(e))return{};let t={};return typeof e.locale==`string`&&(t.locale=e.locale),typeof e.soundMuted==`boolean`&&(t.soundMuted=e.soundMuted),(e.themeMode===`auto`||e.themeMode===`light`||e.themeMode===`dark`)&&(t.themeMode=e.themeMode),(e.textSize===`small`||e.textSize===`normal`||e.textSize===`large`)&&(t.textSize=e.textSize),Kt(e.widgetSize)&&typeof e.widgetSize.width==`number`&&typeof e.widgetSize.height==`number`&&(t.widgetSize={width:e.widgetSize.width,height:e.widgetSize.height}),t}const Yt=`1.10.0`,Xt={open:()=>void 0,close:()=>void 0,expand:e=>({on:e}),fullscreen:e=>({on:e}),send:e=>({attachments:e.attachmentCount}),message:e=>({role:e.role}),stop:()=>void 0,clear:()=>void 0,suggestion:()=>void 0,toggleHistory:e=>({view:e.view}),handshake:()=>void 0,formSubmit:e=>({formId:e.formId,skipped:e.skipped}),toolResult:()=>void 0,toolDecision:e=>({approved:e.approved}),messageFeedback:e=>({value:e.value??`none`}),contentView:e=>({section:e.section,count:e.count}),contentOpen:e=>({contentId:e.contentId,contentCollectionId:e.contentCollectionId}),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:()=>void 0,voiceStop:e=>({ms:e.durationMs}),voiceCancel:()=>void 0,localeChange:e=>({locale:e}),themeChange:e=>({theme:e}),textSizeChange:e=>({size:e}),soundToggle:e=>({muted:e.muted}),sidebarToggle:e=>({collapsed:e.collapsed}),calloutDismiss:()=>void 0,error:()=>void 0};function Zt(){let e=navigator;return e.globalPrivacyControl===!0||e.doNotTrack===`1`}function Qt(){return location.origin+location.pathname}function $t(){try{return document.referrer?new URL(document.referrer).origin:``}catch{return``}}function en(e,t){let n=Math.random(),r=0,i=0,a=/* @__PURE__ */ new Set;function o(e,o){let{tracking:s,publicKey:c,aiAgentDeploymentId:l,mode:u,themeMode:d}=t.getOptions();if(!s.enabled||Zt()||n>=s.sampleRate)return;let f=performance.now();if(f-r>6e4&&(r=f,i=0),++i>60)return;let p=new URLSearchParams;p.set(`v`,`1`),p.set(`_ev`,Yt),p.set(`e`,e),s.token&&p.set(`tk`,s.token),c&&p.set(`pk`,c),l&&p.set(`dep`,l),p.set(`vid`,t.getVisitorId());let m=t.getConversationId();m&&p.set(`cid`,m),p.set(`url`,Qt());let h=$t();h&&p.set(`ref`,h),p.set(`sw`,String(screen.width)),p.set(`sh`,String(screen.height)),p.set(`vw`,String(innerWidth)),p.set(`vh`,String(innerHeight)),p.set(`dpr`,String(devicePixelRatio)),p.set(`lang`,navigator.language);try{p.set(`tz`,Intl.DateTimeFormat().resolvedOptions().timeZone)}catch{}if(p.set(`m`,u),p.set(`th`,d),o)for(let[e,t]of Object.entries(o))t!==void 0&&p.set(e,String(t));p.set(`ts`,String(Date.now()));let g=`${s.endpoint}?${p}`;if(g.length>2e3)return;let _=new Image(1,1);a.add(_);function v(){return a.delete(_)}_.addEventListener(`load`,v,{once:!0}),_.addEventListener(`error`,v,{once:!0}),_.src=g}let s=[];function c(e,t){if(s&&e!==`handshake`){s.length<60&&s.push([e,t]);return}let n=s??[];s=void 0;for(let[e,t]of n)o(e,t);o(e,t)}let l=Object.keys(Xt).map(t=>e.on(t,e=>c(t,Xt[t]?.(e))));return()=>{for(let e of l)e();a.clear()}}const tn=`: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__-accent-fg: var(--__P__-accent);--__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__-pill-l-min: .3;--__P__-pill-l-max: .46;--__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__-conversation-max: 768px;--__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-mode="modal"]),:host([data-mode="drawer"]){--__P__-conversation-max: 100%}: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);--__P__-pill-l-min: .75;--__P__-pill-l-max: .92;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__-pill-l-min: .75;--__P__-pill-l-max: .92;--__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);--__P__-accent-fg: oklch(from var(--__P__-accent-user) clamp(.3, l, .46) c h)}:host([data-theme="dark"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h);--__P__-accent-fg: var(--__P__-accent)}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h);--__P__-accent-fg: var(--__P__-accent)}}}@media(prefers-reduced-motion:reduce){:host{--__P__-dur-quick: 1ms;--__P__-dur-base: 1ms;--__P__-dur-slow: 1ms}}
2
+ import{useEffect as e,useMemo as t,useRef as n,useSyncExternalStore as r}from"react";function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const c={open:!1,ready:!1,unread:0};var l=class{constructor(){s(this,`handlers`,/* @__PURE__ */ new Map)}on(e,t){let n=this.handlers.get(e);return n||(n=/* @__PURE__ */ new Set,this.handlers.set(e,n)),n.add(t),()=>this.handlers.get(e)?.delete(t)}emit(e,t){let n=this.handlers.get(e);if(n)for(let e of n)try{e(t)}catch{}}clear(){this.handlers.clear()}};const u={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`},d=[`off`,`error`,`warn`,`info`,`debug`,`trace`],f=u.cssPrefix,p=`${f}.debug`,m=`__${u.global}_DEBUG__`,h=`${f}-debug`;let g=2,_=null;function v(){if(typeof window>`u`)return 2;try{let e=new URLSearchParams(window.location.search).get(h);if(e!==null){let t=y(e);if(t>=0)return t}}catch{}try{let e=window.localStorage?.getItem(p);if(e){let t=y(e);if(t>=0)return t}}catch{}return Reflect.get(window,m)?4:2}function y(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=d.findIndex(t=>t===e);if(t>=0)return t}return-1}function b(e){let t=y(e);if(!(t<0)){g=t;try{window.localStorage?.setItem(p,d[t]??`off`)}catch{}}}function x(){return d[g]??`warn`}g=v();function S(e){let t=`[${f}:${e}]`;function n(n,r,i){return(a,o)=>{if(!(g<n)&&(o===void 0?console[r](t,a):console[r](t,a,o),_))try{_({level:i,scope:e,message:a,payload:o})}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:t=>S(`${e}:${t}`)}}const C=S(`core`);function w(e){_=e}const T=/* @__PURE__ */ new Set([`hidden`,`submit`,`button`,`reset`,`image`,`file`,`password`]);function E(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function D(e){return!E(e)||e.name===``||e.disabled?!1:!(e instanceof HTMLInputElement&&T.has(e.type))}function O(e){let t=e.labels?.[0]?.textContent?.trim();return e.getAttribute(`toolparamdescription`)??(t||e.getAttribute(`aria-description`))??void 0}function ee(e,t){let n=O(e),r=n?{description:n}:{};return e instanceof HTMLSelectElement?{...r,type:`string`,enum:[...e.options].map(e=>e.value)}:e instanceof HTMLTextAreaElement?{...r,type:`string`}:e.type===`checkbox`?{...r,type:`boolean`}:e.type===`radio`?{...r,type:`string`,enum:t}:e.type===`number`||e.type===`range`?{...r,type:`number`}:{...r,type:`string`}}function k(e,t){Object.getOwnPropertyDescriptor(Reflect.getPrototypeOf(e)??e,`value`)?.set?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}function te(e){return e==null?``:typeof e==`string`?e:JSON.stringify(e)}function ne(e,t){e instanceof HTMLInputElement&&e.type===`checkbox`?e.checked!==(t===!0||t===`true`)&&e.click():e instanceof HTMLInputElement&&e.type===`radio`?e.value===te(t)&&!e.checked&&e.click():k(e,te(t))}function A(e,t,n){let r=[...e.elements].filter(D),i={},a=/* @__PURE__ */ new Set;for(let e of r){var o;let t=r.flatMap(t=>t instanceof HTMLInputElement&&t.type===`radio`&&t.name===e.name?[t.value]:[]);i[o=e.name]??(i[o]=ee(e,t)),e.required&&a.add(e.name)}return{name:t,description:n,inputSchema:{type:`object`,properties:i,...a.size>0?{required:[...a]}:{}},execute(t){let n=typeof t==`object`&&t?Object.entries(t):[];for(let[e,t]of n)for(let n of r)n.name===e&&ne(n,t);if(!e.hasAttribute(`toolautosubmit`))return`Filled in the form. The visitor still needs to check it and press its submit button.`;let i=[...new Set([...e.elements].flatMap(e=>E(e)&&e.name&&!e.checkValidity()?[e.name]:[]))];return i.length>0?`Filled in the form, but it can't be submitted yet: ${i.join(`, `)} still needs the visitor. Ask them to complete it and press the submit button.`:(setTimeout(()=>e.requestSubmit(),0),`Filled in the form and submitted it.`)}}}function j(){return[...document.querySelectorAll(`form[toolname][tooldescription]`)].flatMap(e=>{let t=e.getAttribute(`toolname`)?.trim()??``,n=e.getAttribute(`tooldescription`)?.trim()??``;return t&&n?[A(e,t,n)]:[]})}const re=`${u.cssPrefix}.page-tools`;function ie(e){return typeof e==`object`&&!!e}function ae(e){return ie(e)&&(e.state===`running`||e.state===`stopped`||e.state===`finished`&&ie(e.outcome))}function oe(e){let t=e?JSON.parse(e):void 0;return ie(t)?{sent:Array.isArray(t.sent)?t.sent.filter(e=>typeof e==`string`):[],calls:Object.fromEntries(Object.entries(ie(t.calls)?t.calls:{}).filter(e=>ae(e[1])))}:{sent:[],calls:{}}}let se={sent:[],calls:{}};function ce(){try{se=oe(sessionStorage.getItem(re))}catch{}return se}function le(e){se=e;try{sessionStorage.setItem(re,JSON.stringify(e))}catch{}}const M={markSent(e){let t=ce();le({...t,sent:[...t.sent.filter(t=>t!==e),e].slice(-20)})},sentHere(e){return ce().sent.includes(e)},get(e){return ce().calls[e]},set(e,t){let n=ce(),r=Object.entries(n.calls).filter(([t])=>t!==e);le({...n,calls:Object.fromEntries([...r,[e,t]].slice(-50))})},clear(e){let t=ce();e.some(e=>e in t.calls)&&le({...t,calls:Object.fromEntries(Object.entries(t.calls).filter(([t])=>!e.includes(t)))})}};function ue(e,t){return new Promise(n=>{if(t?.aborted)return n();let r=setTimeout(a,e);function i(){return a()}t?.addEventListener(`abort`,i,{once:!0});function a(){clearTimeout(r),t?.removeEventListener(`abort`,i),n()}})}const de=C.scope(`page-tools`),fe=3e4,pe=Symbol.for(`${u.cssPrefix}.page-tools`),me={state:`output-error`,errorText:`The page reloaded before this finished, so it may or may not have taken effect. Check with the visitor before trying it again.`},he=`The visitor stopped this before it finished.`;function N(e){return typeof e==`object`&&!!e}function ge(e){return N(e)&&Array.isArray(e.registered)&&e.runs instanceof Map}function _e(){let e=Reflect.get(globalThis,pe);if(ge(e))return e;let t={registered:[],runs:/* @__PURE__ */ new Map};return Reflect.set(globalThis,pe,t),t}function ve(e,t){let n=N(t)&&t.signal instanceof AbortSignal?t.signal:void 0;if(n?.aborted)return;let r=_e().registered;r.push(e);function i(){let t=r.indexOf(e);t>=0&&r.splice(t,1)}n?.addEventListener(`abort`,i,{once:!0})}function ye(e){return e.replace(/[^A-Za-z0-9_-]/g,`_`).slice(0,58)}function be(e){if(!N(e)||typeof e.name!=`string`||!ye(e.name))return;let t=[e.description,e.title].find(e=>typeof e==`string`&&e.trim()!==``)??e.name;return{name:ye(e.name),description:t.trim().slice(0,1024),inputSchema:{properties:{},...N(e.inputSchema)?e.inputSchema:{},type:`object`},consequential:N(e.annotations)&&e.annotations.consequentialHint===!0}}function xe(e){return e.flatMap(e=>{let t=be(e),n=N(e)?e.execute:void 0;return!t||typeof n!=`function`?(de.warn(`skipped a tool without a name or an execute function`,e),[]):[{...t,run:(t,r)=>Reflect.apply(n,e,[t,{signal:r}])}]})}async function Se(){let e=Reflect.get(document,`modelContext`)??Reflect.get(navigator,`modelContext`);if(!N(e)||typeof e.getTools!=`function`||typeof e.executeTool!=`function`)return[];let t=e.getTools,n=e.executeTool,r=await Promise.race([Promise.resolve().then(()=>Reflect.apply(t,e,[])),ue(1e3).then(()=>[])]).catch(()=>[]);return(Array.isArray(r)?r:[]).flatMap(t=>{let r=be(t);return r?[{...r,run:(r,i)=>Reflect.apply(n,e,[t,r,{signal:i}])}]:[]})}async function Ce(e=[]){let t=xe(j()),n=new Set(t.map(e=>e.name)),r=[...(await Se()).filter(e=>!n.has(e.name)),...t,...xe(e),...xe(_e().registered)];return new Map(r.map(e=>[e.name,e]))}function we(e){return[...e.values()].map(({name:e,description:t,inputSchema:n,consequential:r})=>r?{name:e,description:t,inputSchema:n,annotations:{consequentialHint:!0}}:{name:e,description:t,inputSchema:n})}function Te(e){return e?.execution===`client`}function Ee(e){return e.startsWith(`site__`)?e.slice(6):e}function De(e){if(e===void 0||typeof e==`function`||typeof e==`symbol`)return null;let t=/* @__PURE__ */ new WeakSet,n=JSON.stringify(e,(e,n)=>{if(typeof n==`bigint`)return n.toString();if(typeof n!=`function`&&typeof n!=`symbol`)return n instanceof Node?`[${n.nodeName.toLowerCase()}]`:N(n)?t.has(n)?`[circular]`:(t.add(n),n):n});return n.length>fe?{truncated:!0,preview:n.slice(0,fe)}:JSON.parse(n)}async function Oe(e){let t=Ee(e.toolName),n=(await Ce(e.optionTools)).get(t);return n?Promise.resolve().then(()=>n.run(e.input,e.signal)).then(e=>({state:`output-available`,output:De(e)})).catch(e=>(de.warn(`a page tool failed`,{name:t,error:e}),{state:`output-error`,errorText:(e instanceof Error?e.message:String(e)).slice(0,1e3)||`The page tool failed.`})):{state:`output-error`,errorText:`This page doesn't offer "${t}" right now; the visitor may have moved on. Tell them, or continue without it.`}}function ke(e){let{toolCallId:t}=e,n=M.get(t);if(n?.state===`finished`)return Promise.resolve(n.outcome);let{runs:r}=_e(),i=r.get(t);if(i)return i.outcome;if(n?.state===`running`)return M.set(t,{state:`finished`,outcome:me}),e.onSettled(`interrupted`,0),Promise.resolve(me);let a=new AbortController,o=performance.now();M.set(t,{state:`running`});let s=Oe({...e,signal:a.signal}).then(n=>(r.delete(t),M.get(t)?.state===`running`&&(M.set(t,{state:`finished`,outcome:n}),e.onSettled(n.state===`output-available`?`completed`:`failed`,Math.round(performance.now()-o))),n));return r.set(t,{outcome:s,controller:a}),s}function Ae(e){return e===me.errorText||e===he}function je(e){return M.set(e,{state:`stopped`}),_e().runs.get(e)?.controller.abort(),he}function Me(e){M.clear([e]),_e().runs.get(e)?.controller.abort()}var P,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,F={},Ue=[],We=/^m(i|n|o|s|text|space)$/,Ge=Array.isArray,Ke=Ue.slice,qe=Object.assign;function Je(e){e&&e.parentNode&&e.remove()}function Ye(e,t,n){var r,i,a,o={},s=arguments.length;for(a in t)a==`key`?r=t[a]:a==`ref`&&typeof e!=`function`?i=t[a]:o[a]=t[a];return s>2&&(o.children=s>3?Ke.call(arguments,2):n),Xe(e,o,r,i,null)}function Xe(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||++Ne,__i:-1,__u:0};return!i&&P.vnode&&P.vnode(a),a}function Ze(e){return e.children}function Qe(e,t){this.props=e,this.context=t,this.__g=0}function $e(e,t){if(t==null)return e.__&&$e(e.__,e.__i+1);for(var n;t<e.__k.length;t++)if((n=e.__k[t])&&n.__e)return n.__e;return typeof e.type!=`function`||e.props.__P?null:$e(e)}function et(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),et(e)}function tt(e){(8&e.__g||(e.__g|=8,Fe.push(e),Le++))&&Ie==P.debounceRendering||((Ie=P.debounceRendering)||queueMicrotask)(nt)}function nt(){var e,t,n,r,i,a,o,s,c;try{for(t=1;Fe.length;)Fe.length>t&&Fe.sort(Re),e=Fe.shift(),t=Fe.length,8&e.__g&&(r=void 0,i=void 0,a=(i=(n=e).__v).__e,o=[],s=[],(c=n.__P)&&((r=qe({constructor:void 0},i)).__v=i.__v+1,P.vnode&&P.vnode(r),dt(c,r,i,n.__n,c.namespaceURI,32&i.__u?[a]:null,o,a||$e(i),32&i.__u,s),r.__v=i.__v,r.__.__k[r.__i]=r,mt(o,r,s),i.__=i.__e=null,r.__e!=a&&et(r)))}finally{(Le=Fe.length)&&(Ie||queueMicrotask)(nt)}}function rt(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r.__k||Ue,v=t.length;for(c=it(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=~p.__i&&_[p.__i]||F,p.__i=d,g=dt(e,p,f,i,a,o,s,c,l,u),m=p.__e,(f.ref!=p.ref||8&f.__u)&&(f.ref&&gt(f.ref,null,p,f),p.ref&&u.push(p.ref,p.__c||m,p)),h=h||m,4&p.__u?(c=at(p,c,e,!f.__v),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-21);return n.__e=h,c}function it(e,t,n,r,i){var a,o,s,c,l,u,d,f,p,m=n.length,h=m,g=0,_=0,v=e.__k=Array(i);for(a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o!=`object`||o.constructor==String?o=v[a]=Xe(null,o):Ge(o)?o=v[a]=Xe(Ze,{children:o}):o.constructor===void 0&&o.__b?o=v[a]=Xe(o.type,o.props,o.key,o.ref,o.__v):v[a]=o,c=a+g,o.__=e,o.__b=e.__b+1,s=null,~(l=o.__i=st(o,n,c,h))&&(h--,(s=n[l])&&(s.__u|=2)),s&&s.__v?(o.__u|=16,l==c-1?g--:l==c+1?g++:l!=c&&(l>c?g--:g++,_=1)):(~l||(i>m?g--:i<m&&g++),typeof o.type!=`function`&&(o.__u|=4))):v[a]=null;if(_){for(u=[],d=[],a=0;a<i;a++)if((o=v[a])&&16&o.__u){for(g=0,f=u.length;g<f;)u[p=g+f>>1]<o.__i?g=p+1:f=p;u[g]=o.__i,d[a]=g+1}for(g=u.length;a--;)d[a]&&(d[a]==g?g--:v[a].__u|=4)}if(h)for(a=0;a<m;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=$e(s)),_t(s,s));return r}function at(e,t,n,r){var i,a,o,s;if(typeof e.type==`function`){if(e.props.__P)return t;if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&(i[a].__=e,t=at(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=$e(e))&&!t.parentNode&&(t=null),o=e.__e,s=t;s&&s.nodeType==8;)s=s.nextSibling;for(o!=s&&(!r&&n.moveBefore&&o.parentNode?n.moveBefore(o,t):n.insertBefore(o,t||null)),t=o;(t=t&&t.nextSibling)&&t.nodeType==8&&!t.data.startsWith(`$s`););return t}function ot(e,t){return t=t||[],e!=null&&typeof e!=`boolean`&&(Ge(e)?e.some(function(e){ot(e,t)}):t.push(e)),t}function st(e,t,n,r){var i,a=e.key,o=e.type,s=t[n],c=s&&!(2&s.__u);if(s===null&&a==null||c&&a==s.key&&o==s.type)return n;if(r>+!!c){for(i=n-1;i>=0;i--)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i;for(i=n+1;i<t.length;i++)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i}return-1}function ct(e,t,n){n??(n=``),t[0]==`-`?e.setProperty(t,n):e[t]=n}function lt(e,t,n,r,i){var a,o;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||ct(e.style,t);if(n)for(t in n)r&&n[t]==r[t]||ct(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)(e.__e||(e.__e={}))[t]=n,n&&r||(o=He[t]||(He[t]=ut(t)),(e.__a||(e.__a={}))[t]=Ve,a=t!=(t=t.replace(Be,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),n?e.addEventListener(t,o,a):e.removeEventListener(t,o,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??``;return}catch{}if(typeof n==`function`)return;n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n)}}function ut(e){return function(t){var n=this.__e;if(n){if(n=n[e],t[ze]==null)t[ze]=Ve++;else if(t[ze]<this.__a[e])return;return n(P.event?P.event(t):t)}}}function dt(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=32&n.__u,u=n.__c.__z)&&(t.__u|=c,d=a=[],u.nodeType==8?s=ft(u,a):a.push(u),s=a[0]||s),(u=P.__b)&&u(t);n:if(typeof O==`function`){f=o.length;try{if(_=t.props,v=(u=O.prototype)&&u.render,y=(u=O.contextType)&&r[u.__c],b=u?y?y.props.value:u.__:r,(p=n.__c)?(t.__c=p,2&p.__g&&(p.__g|=1)):(v?t.__c=p=new O(_,b):(t.__c=p=new Qe(_,b),p.constructor=O,p.render=vt),y&&y.sub(p),p.state||(p.state={}),p.__n=r,p.__g|=8,p.__h=[],p.__k=[]),v&&(p.__s||(p.__s=p.state),O.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=qe({},p.__s)),qe(p.__s,O.getDerivedStateFromProps(_,p.__s)))),m=p.props,h=p.state,p.__v=t,n.__c){if(_!==m&&v&&!O.getDerivedStateFromProps&&p.componentWillReceiveProps&&p.componentWillReceiveProps(_,b),t.__v==n.__v&&!(8&p.__g)||!(4&p.__g)&&p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(_,p.__s,b)){t.__v!=n.__v&&(p.props=_,p.state=p.__s,p.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),Ue.push.apply(p.__h,p.__k),p.__k=[],p.__h.length&&o.push(p),s=$e(n);break n}p.componentWillUpdate&&p.componentWillUpdate(_,p.__s,b),v&&p.componentDidUpdate&&p.__h.push(function(){p.componentDidUpdate(m,h,g)})}else v&&!O.getDerivedStateFromProps&&p.componentWillMount&&p.componentWillMount(),v&&p.componentDidMount&&p.__h.push(p.componentDidMount);if(p.context=b,p.props=_,p.__P=e,p.__g&=-5,x=P.__r,S=0,v)p.state=p.__s,p.__g&=-9,x&&x(t),u=p.render(p.props,p.state,p.context),Ue.push.apply(p.__h,p.__k),p.__k=[];else do p.__g&=-9,x&&x(t),u=p.render(p.props,p.state,p.context),p.state=p.__s;while(8&p.__g&&++S<25);p.state=p.__s,p.getChildContext&&(r=qe({},r,p.getChildContext())),v&&n.__c&&p.getSnapshotBeforeUpdate&&(g=p.getSnapshotBeforeUpdate(m,h)),C=u&&u.type===Ze&&u.key==null?u.props.children:u,_.__P&&(u=s,i=(e=_.__P).namespaceURI,c=a=null,n.props&&n.props.__P!=e&&(n.__k.some(function(e){e&&_t(e,e)}),n.__k=null),s=n.__k?$e(n,0):null),s=rt(e,Ge(C)?C:[C],t,n,r,i,a,o,s,c,l),_.__P&&(t.__e=null,s=u),t.__u&=-161,d&&d.some(Je),p.__h.length&&o.push(p),1&p.__g&&(p.__g&=-4)}catch(e){if(o.length=f,t.__v=null,c||a){if(e.then){if(w=0,t.__u|=128|c,a){for(~(E=a.indexOf(s||void 0))||(E=a.length);(D=a[E-1])&&D.nodeType==8;)E--;for(;E<a.length;E++)if(D=a[E]){if(a[E]=null,D.nodeType==8){if(D.data.startsWith(`$s`))w++||(T=D);else if(w&&D.data.startsWith(`/$s`)&&!--w)break}else if(!w)break}}if(!T){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;T=s}(u=ft(T=t.__c.__z||(t.__c.__z=T)))?(t.__e=T,s=u):t.__e=s,s=s&&s.nextSibling}else a&&a.some(Je)}else t.__e=n.__e;t.__k||(t.__k=n.__k||[]),e.then||pt(t),P.__e(e,t,n)}}else s=t.__e=ht(n.__e,t,n,r,i,a,o,c,l,e);return(u=P.diffed)&&u(t),s}function ft(e,t){if(e&&e.nodeType==8&&e.data.startsWith(`$s`))for(var n=1;e=e.nextSibling;){if(e.nodeType==8){if(e.data.startsWith(`$s`))n++;else if(e.data.startsWith(`/$s`)&&!--n)return e}t&&t.push(e)}}function pt(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(pt))}function mt(e,t,n){for(var r=0;r<n.length;)gt(n[r++],n[r++],n[r++]);P.__c&&P.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){P.__e(e,t.__v)}})}function ht(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y=n.props||F,b=t.props,x=t.type;if(x==`svg`?i=`http://www.w3.org/2000/svg`:x==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||(i=`http://www.w3.org/1999/xhtml`),a){for(u=0;u<a.length;u++)if((m=a[u])&&(x?m.localName==x:m.nodeType==3)){e=m,a[u]=null;break}}if(!e){if(_=l.ownerDocument||document,!x)return _.createTextNode(b);e=_.createElementNS(i,x,b.is&&b),s&&(P.__m&&P.__m(t,a),s=!1),a=null}if(x){if(l=x==`template`?e.content:e,a=x==`textarea`&&b.defaultValue!=null?null:a&&Ke.call(l.childNodes),!s&&a)for(y={},u=0;u<e.attributes.length;u++)y[(m=e.attributes[u]).name]=m.value;for(u in y)m=y[u],u==`dangerouslySetInnerHTML`?f=m:u==`children`||u in b||u==`value`&&`defaultValue`in b||u==`checked`&&`defaultChecked`in b||lt(e,u,null,m,i);for(u in v=1&n.__u,b)m=b[u],u==`children`?p=m:u==`dangerouslySetInnerHTML`?d=m:u==`value`?h=m:u==`checked`?g=m:s&&typeof m!=`function`||!(y[u]!==m||v&&m!=null)||lt(e,u,m,y[u],i);d?(s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[]):(f&&(e.textContent=``),(x==`foreignObject`||i==`http://www.w3.org/1998/Math/MathML`&&We.test(x))&&(i=`http://www.w3.org/1999/xhtml`),rt(l,Ge(p)?p:[p],t,n,r,i,a,o,a?a[0]:n.__k&&$e(n,0),s,c),a&&a.some(Je)),s&&x!=`textarea`||(u=`value`,x==`progress`&&h==null?e.removeAttribute(u):h==null||h===e[u]&&(x!=`progress`||h)||lt(e,u,h,y[u],i),u=`checked`,g!=null&&g!=e[u]&&lt(e,u,g,y[u],i))}else y===b||s&&e.data==b||(e.data=b);return e}function gt(e,t,n,r){try{typeof e==`function`?t?t.__x=e(t)||1:r&&(r=r.__c||r.__e)&&(t=r.__x)&&(r.__x=null,typeof t==`function`?t():e(null)):e.current=t}catch(e){P.__e(e,n)}}function _t(e,t,n){var r,i,a,o;if(P.unmount&&P.unmount(e),!(r=e.ref)||r.current&&r.current!=e.__e||gt(r,null,t,e),r=e.__c){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){P.__e(e,t)}r.__P=r.__n=null}if(r=e.__k)for(o=0;o<r.length;o++)r[o]&&_t(r[o],t,typeof e.type!=`function`||n&&!e.props.__P);!n&&(r=e.__c)&&(r=r.__z)&&(i=ft(r,a=[]))&&(r==e.__e&&a.some(Je),Je(i),Je(r)),(r=e.__e)&&(n||Je(r),r.__e&&(r.__e=null)),e.__e=e.__c=e.__=null}function vt(e,t,n){return this.constructor(e,n)}function yt(e,t){var n,r,i,a;P.__&&P.__(e,t),t.nodeType==9&&(t=t.documentElement),r=(n=e&&32&e.__u)?null:t.__k,t.__k=Xe(Ze,{children:[e]}),i=[],a=[],dt(t,t.__k,r||F,F,t.namespaceURI,r?null:t.firstChild?Ke.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a),mt(i,t.__k,a),t.__k.props.children=null}P={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((o=(a=i.constructor)&&a.getDerivedStateFromError)&&i.setState(a.getDerivedStateFromError(e)),i.componentDidCatch&&(i.componentDidCatch(e,r||{}),o=1),o&&8&i.__g)return void(i.__g|=2)}catch(t){e=t}}throw Le=0,e}},Ne=0,Pe=function(e){return e!=null&&e.constructor===void 0},Qe.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=qe({},this.state)),typeof e==`function`&&(e=e(qe({},n),this.props)),e&&(qe(n,e),this.__v&&(t&&this.__k.push(t),tt(this)))},Qe.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),tt(this))},Qe.prototype.render=Ze,Fe=[],Le=0,Re=function(e,t){return e.__v.__b-t.__v.__b},ze=Symbol(),Be=/(PointerCapture)$|Capture$/i,Ve=0,He={};function bt(e,t){if(e?.length&&t)return e.find(e=>e.locale===t)}function xt(e,t){let{translations:n,defaultLocale:r,...i}=e,a=bt(n,t);return a?{...i,title:a.title??i.title,description:a.description??i.description,content:a.content??i.content}:i}function St(e,t){let{translations:n,defaultLocale:r,...i}=e,a=bt(n,t);return a?{...i,title:a.title??i.title,description:a.description??i.description}:i}function Ct(e,t){let{translations:n,defaultLocale:r,...i}=e,a=bt(n,t);if(!a)return i;let o=new Map((a.fields??[]).map(e=>[e.name,e])),s=i.fields.map(e=>{let t=o.get(e.name);if(!t)return e;let n=new Map((t.options??[]).map(e=>[e.value,e]));return{...e,label:t.label??e.label,placeholder:t.placeholder??e.placeholder,validationHint:t.validationHint??e.validationHint,options:e.options?.map(e=>{let t=n.get(e.value);return t?{...e,label:t.label??e.label,description:t.description??e.description}:e})}});return{...i,title:a.title??i.title,description:a.description??i.description,submitLabel:a.submitLabel??i.submitLabel,fields:s}}const wt={attach:`Attach files`,attachmentMimeRejected:`File type not supported`,attachmentTooLarge:`File is too large`,attachmentTooMany:`Attachment limit reached`,conversationClosed:`This chat is closed`,conversationLoading:`Loading chat…`,loadPreviousMessages:`Load previous messages`,close:`Close`,collapse:`Collapse`,collapseSidebar:`Collapse sidebar`,composerPlaceholder:`Type a message…`,dateLastWeek:`Last 7 days`,dateOlder:`Older`,dateToday:`Today`,dateYesterday:`Yesterday`,dropZone:`Drop files to attach`,errorGeneric:`Something went wrong`,errorRateLimited:`Too many requests — 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 chats yet`,historyLoading:`Loading your chats…`,historyContinue:`Continue the chat`,historyTitle:`Chat history`,loadMoreConversations:`Load more conversations`,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 chat`,panelTitle:`Chat`,popOut:`Open in new tab`,resizeHandle:`Drag to resize`,scrollToBottom:`Scroll to latest`,send:`Send`,queueMessage:`Queue message`,removeQueuedMessage:`Remove queued message`,compactingContext:`Optimizing conversation context…`,soundOff:`Sound off`,soundOn:`Sound on`,startNewConversation:`Start a new chat`,talkToOperator:`Talk to a person`,connectingOperator:`Connecting you to a person…`,noOperatorAvailable:`No one's available right now — leave your details and we'll follow up.`,chattingWithOperator:`You're chatting with {operator}`,cancelOperatorRequest:`Keep chatting with the AI`,stop:`Stop`,theme:`Theme`,themeAuto:`Auto`,themeDark:`Dark`,themeLight:`Light`,textSize:`Text size`,textSizeSmall:`Small`,textSizeNormal:`Normal`,textSizeLarge:`Large`,loading:`Loading…`,visualPreparing:`Preparing visual…`,visualError:`This visual could not be displayed.`,visualPartial:`Some parts of this visual could not be displayed.`,thinking:`Thinking…`,thoughts:`Thoughts`,toolResult:`Result`,sources:`Sources`,feedbackUp:`Good response`,feedbackDown:`Bad response`,feedbackThanks:`Thanks for your feedback`,copy:`Copy`,copied:`Copied`,tabHome:`Home`,tabConversations:`Chats`,tabHelp:`Help`,tabNews:`News`,modulesEmpty:`Nothing here yet`,moduleBack:`Back`,contentLoading:`Loading…`,contentHelpful:`Was this helpful?`,homeGreeting:`How can we help?`,homeGreetingNamed:`Hi {name} 👋`,homeGreetingLead:`How can we help?`,homeSearchPlaceholder:`Search for help`,homeAskPlaceholder:`Ask a question…`,homeWhatsNew:`What's new`,homeContentTitle:`Popular articles`,homeStatus:`Status`,helpTitle:`Help`,helpSearchPlaceholder:`Search for help`,helpEmpty:`No help articles yet`,helpLoading:`Loading help…`,helpSearchEmpty:`No results for “{query}”`,helpShowMore:`Show more`,newsTitle:`News`,newsEmpty:`No news yet`,newsLoading:`Loading news…`,newsBack:`Back to news`,newsPublishedAt:`Published {date}`,newsShowMore:`Show more`,newsUnseen:`New post`,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…`,inputRequired:`Questions for you`,inputBadge:`Questions`,inputAnswered:`Answered`,inputSkipped:`Skipped`,showOptions:`Show options`,hideOptions:`Hide options`,qtypeText:`Your answer`,qtypeEmail:`Email address`,qtypePhone:`Phone number`,qtypeNumber:`Number`,qtypeDate:`Date`,qtypeChooseOne:`Pick one`,qtypeChooseAny:`Pick any`,qtypeBoolean:`Yes / No`,inputSubmit:`Submit answers`,inputSubmitHint:`Enter to send · Shift+Enter = new line`,inputSkip:`Skip`,confirmYes:`Yes`,confirmNo:`No`,approve:`Approve`,reject:`Reject`,approvalPrompt:`{tool} requires your approval to execute.`,approvalBody:`Review the tool input above and decide whether to allow this action.`,approvalYourResponse:`Your response: {decision}`,approvalEditHint:`You can edit this response until this step continues.`,approvalSubmitting:`Response submitted. Request in progress…`,edit:`Edit`,toolParameters:`Parameters`,statusAwaiting:`Awaiting Approval`,statusResponded:`Submitted`,statusRunning:`Running`,statusCompleted:`Completed`,statusDenied:`Denied`,statusError:`Error`,statusSuperseded:`Skipped`,statusIncomplete:`Not completed`},Tt={en:wt,fr:{attach:`Joindre des fichiers`,attachmentMimeRejected:`Type de fichier non pris en charge`,attachmentTooLarge:`Le fichier est trop volumineux`,attachmentTooMany:`Limite de pièces jointes atteinte`,conversationClosed:`Ce chat est fermé`,conversationLoading:`Chargement du chat…`,loadPreviousMessages:`Charger les messages précédents`,close:`Fermer`,collapse:`Réduire`,collapseSidebar:`Réduire la barre latérale`,composerPlaceholder:`Écrivez un message…`,dateLastWeek:`7 derniers jours`,dateOlder:`Plus ancien`,dateToday:`Aujourd'hui`,dateYesterday:`Hier`,dropZone:`Déposez les fichiers à joindre`,errorGeneric:`Une erreur s'est produite`,errorRateLimited:`Trop de requêtes — veuillez réessayer dans un instant.`,errorRetry:`Réessayer`,expand:`Agrandir`,expandSidebar:`Développer la barre latérale`,exitFullscreen:`Quitter le plein écran`,fullscreen:`Plein écran`,history:`Historique`,historyBack:`Retour au chat`,historyEmpty:`Aucun chat pour le moment`,historyContinue:`Poursuivre le chat`,historyLoading:`Chargement de vos chats…`,historyTitle:`Historique des chats`,loadMoreConversations:`Charger plus de conversations`,language:`Langue`,launcherOpen:`Ouvrir le chat`,launcherLabel:`Discuter avec nous`,micStart:`Démarrer la saisie vocale`,micStop:`Arrêter la saisie vocale`,micUnsupported:`La saisie vocale n'est pas prise en charge par ce navigateur`,moreActions:`Plus d'actions`,newConversation:`Nouveau chat`,panelTitle:`Chat`,popOut:`Ouvrir dans un nouvel onglet`,resizeHandle:`Glisser pour redimensionner`,scrollToBottom:`Aller au plus récent`,send:`Envoyer`,queueMessage:`Mettre le message en attente`,removeQueuedMessage:`Retirer le message en attente`,compactingContext:`Optimisation du contexte de la conversation…`,soundOff:`Son désactivé`,soundOn:`Son activé`,startNewConversation:`Démarrer un nouveau chat`,talkToOperator:`Parler à une personne`,connectingOperator:`Mise en relation avec une personne…`,noOperatorAvailable:`Personne n'est disponible pour le moment — laissez vos coordonnées et nous reviendrons vers vous.`,chattingWithOperator:`Vous discutez avec {operator}`,cancelOperatorRequest:`Continuer avec l'IA`,stop:`Arrêter`,theme:`Thème`,themeAuto:`Auto`,themeDark:`Sombre`,themeLight:`Clair`,textSize:`Taille du texte`,textSizeSmall:`Petite`,textSizeNormal:`Normale`,textSizeLarge:`Grande`,loading:`Chargement…`,visualPreparing:`Préparation du visuel…`,visualError:`Ce visuel n’a pas pu être affiché.`,visualPartial:`Certaines parties de ce visuel n’ont pas pu être affichées.`,thinking:`Réflexion…`,thoughts:`Réflexions`,toolResult:`Résultat`,sources:`Sources`,feedbackUp:`Bonne réponse`,feedbackDown:`Mauvaise réponse`,feedbackThanks:`Merci pour votre retour`,copy:`Copier`,copied:`Copié`,tabHome:`Accueil`,tabConversations:`Chats`,tabHelp:`Aide`,tabNews:`Actualités`,modulesEmpty:`Rien pour le moment`,moduleBack:`Retour`,contentLoading:`Chargement…`,contentHelpful:`Cela vous a-t-il aidé ?`,homeGreeting:`Comment pouvons-nous vous aider ?`,homeGreetingNamed:`Bonjour {name} 👋`,homeGreetingLead:`Comment pouvons-nous vous aider ?`,homeSearchPlaceholder:`Rechercher de l'aide`,homeAskPlaceholder:`Posez une question…`,homeWhatsNew:`Nouveautés`,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…`,helpSearchEmpty:`Aucun résultat pour «\xA0{query}\xA0»`,helpShowMore:`Afficher plus`,newsTitle:`Actualités`,newsEmpty:`Aucune actualité pour le moment`,newsLoading:`Chargement des actualités…`,newsBack:`Retour aux actualités`,newsPublishedAt:`Publié le {date}`,newsShowMore:`Afficher plus`,newsUnseen:`Nouvelle publication`,formSubmit:`Envoyer`,formSkip:`Plus tard`,formSubmitted:`Terminé`,formSkipped:`Plus tard`,formFillOut:`Remplir`,formRequired:`Ce champ est obligatoire`,formInvalidEmail:`Saisissez une adresse e-mail valide`,formInvalidTel:`Saisissez un numéro de téléphone valide`,formInvalidUrl:`Saisissez une URL valide`,formInvalidNumber:`Saisissez un nombre valide`,formTooShort:`Trop court (min. {min} caractères)`,formTooLong:`Trop long (max. {max} caractères)`,formNumberTooSmall:`Doit être au moins {min}`,formNumberTooLarge:`Doit être au plus {max}`,formPatternMismatch:`Veuillez respecter le format demandé`,formChooseAtLeast:`Choisissez au moins {min}`,formChooseAtMost:`Choisissez au plus {max}`,formOther:`Autre`,formOtherPlaceholder:`Saisissez votre réponse…`,inputRequired:`Questions pour vous`,inputBadge:`Questions`,inputAnswered:`Répondu`,inputSkipped:`Ignoré`,showOptions:`Afficher les options`,hideOptions:`Masquer les options`,qtypeText:`Votre réponse`,qtypeEmail:`Adresse e-mail`,qtypePhone:`Numéro de téléphone`,qtypeNumber:`Nombre`,qtypeDate:`Date`,qtypeChooseOne:`Choisir une`,qtypeChooseAny:`Choisir plusieurs`,qtypeBoolean:`Oui / Non`,inputSubmit:`Envoyer les réponses`,inputSubmitHint:`Entrée pour envoyer · Maj+Entrée = saut de ligne`,inputSkip:`Ignorer`,confirmYes:`Oui`,confirmNo:`Non`,approve:`Approuver`,reject:`Refuser`,approvalPrompt:`{tool} nécessite votre approbation pour s'exécuter.`,approvalBody:`Vérifiez les paramètres ci-dessus et décidez d'autoriser ou non cette action.`,approvalYourResponse:`Votre réponse : {decision}`,approvalEditHint:`Vous pouvez modifier votre réponse jusqu'à la reprise de cette étape.`,approvalSubmitting:`Réponse envoyée. Traitement en cours…`,edit:`Modifier`,toolParameters:`Paramètres`,statusAwaiting:`En attente d'approbation`,statusResponded:`Envoyé`,statusRunning:`En cours`,statusCompleted:`Terminé`,statusDenied:`Refusé`,statusError:`Erreur`,statusSuperseded:`Ignoré`,statusIncomplete:`Non terminé`},ar:{attach:`إرفاق ملفات`,attachmentMimeRejected:`نوع الملف غير مدعوم`,attachmentTooLarge:`حجم الملف كبير جدًا`,attachmentTooMany:`تم بلوغ الحد الأقصى للمرفقات`,conversationClosed:`تم إغلاق هذه الدردشة`,conversationLoading:`جارٍ تحميل الدردشة…`,loadPreviousMessages:`تحميل الرسائل السابقة`,close:`إغلاق`,collapse:`طيّ`,collapseSidebar:`طيّ الشريط الجانبي`,composerPlaceholder:`اكتب رسالة…`,dateLastWeek:`آخر ٧ أيام`,dateOlder:`أقدم`,dateToday:`اليوم`,dateYesterday:`أمس`,dropZone:`أفلت الملفات لإرفاقها`,errorGeneric:`حدث خطأ ما`,errorRateLimited:`طلبات كثيرة جدًا — يرجى المحاولة بعد لحظة.`,errorRetry:`إعادة المحاولة`,expand:`توسيع`,expandSidebar:`توسيع الشريط الجانبي`,exitFullscreen:`إنهاء ملء الشاشة`,fullscreen:`ملء الشاشة`,history:`السجل`,historyBack:`العودة إلى الدردشة`,historyEmpty:`لا توجد دردشات سابقة بعد`,historyContinue:`متابعة الدردشة`,historyLoading:`جارٍ تحميل دردشاتك…`,historyTitle:`سجل الدردشات`,loadMoreConversations:`تحميل المزيد من المحادثات`,language:`اللغة`,launcherOpen:`فتح الدردشة`,launcherLabel:`تحدث معنا`,micStart:`بدء الإدخال الصوتي`,micStop:`إيقاف الإدخال الصوتي`,micUnsupported:`الإدخال الصوتي غير مدعوم في هذا المتصفح`,moreActions:`إجراءات إضافية`,newConversation:`دردشة جديدة`,panelTitle:`الدردشة`,popOut:`فتح في علامة تبويب جديدة`,resizeHandle:`اسحب لتغيير الحجم`,scrollToBottom:`الانتقال إلى الأحدث`,send:`إرسال`,queueMessage:`إضافة الرسالة إلى قائمة الانتظار`,removeQueuedMessage:`إزالة الرسالة من قائمة الانتظار`,compactingContext:`جارٍ تحسين سياق المحادثة…`,soundOff:`كتم الصوت`,soundOn:`تشغيل الصوت`,startNewConversation:`بدء دردشة جديدة`,talkToOperator:`التحدث إلى شخص`,connectingOperator:`جارٍ توصيلك بشخص…`,noOperatorAvailable:`لا يوجد موظفون متاحون الآن — اترك بياناتك وسنتواصل معك.`,chattingWithOperator:`أنت تتحدث مع {operator}`,cancelOperatorRequest:`متابعة المحادثة مع الذكاء الاصطناعي`,stop:`إيقاف`,theme:`المظهر`,themeAuto:`تلقائي`,themeDark:`داكن`,themeLight:`فاتح`,textSize:`حجم النص`,textSizeSmall:`صغير`,textSizeNormal:`عادي`,textSizeLarge:`كبير`,loading:`جارٍ التحميل…`,visualPreparing:`جارٍ إعداد المحتوى المرئي…`,visualError:`تعذر عرض هذا المحتوى المرئي.`,visualPartial:`تعذر عرض بعض أجزاء هذا المحتوى المرئي.`,thinking:`يفكّر…`,thoughts:`الأفكار`,toolResult:`النتيجة`,sources:`المصادر`,feedbackUp:`رد جيد`,feedbackDown:`رد سيئ`,feedbackThanks:`شكرًا على ملاحظاتك`,copy:`نسخ`,copied:`تم النسخ`,tabHome:`الرئيسية`,tabConversations:`الدردشات`,tabHelp:`المساعدة`,tabNews:`الأخبار`,modulesEmpty:`لا شيء هنا بعد`,moduleBack:`رجوع`,contentLoading:`جارٍ التحميل…`,contentHelpful:`هل كان هذا مفيدًا؟`,homeGreeting:`كيف يمكننا مساعدتك؟`,homeGreetingNamed:`مرحبًا {name} 👋`,homeGreetingLead:`كيف يمكننا مساعدتك؟`,homeSearchPlaceholder:`ابحث عن مساعدة`,homeAskPlaceholder:`اطرح سؤالاً…`,homeWhatsNew:`ما الجديد`,homeContentTitle:`مقالات شائعة`,homeStatus:`الحالة`,helpTitle:`المساعدة`,helpSearchPlaceholder:`ابحث عن مساعدة`,helpEmpty:`لا توجد مقالات مساعدة بعد`,helpLoading:`جارٍ تحميل المساعدة…`,helpSearchEmpty:`لا نتائج لـ «{query}»`,helpShowMore:`عرض المزيد`,newsTitle:`الأخبار`,newsEmpty:`لا توجد أخبار بعد`,newsLoading:`جارٍ تحميل الأخبار…`,newsBack:`العودة إلى الأخبار`,newsPublishedAt:`نُشر في {date}`,newsShowMore:`عرض المزيد`,newsUnseen:`منشور جديد`,formSubmit:`إرسال`,formSkip:`لاحقًا`,formSubmitted:`تم`,formSkipped:`لاحقًا`,formFillOut:`تعبئة`,formRequired:`هذا الحقل مطلوب`,formInvalidEmail:`أدخل بريدًا إلكترونيًا صحيحًا`,formInvalidTel:`أدخل رقم هاتف صحيحًا`,formInvalidUrl:`أدخل رابطًا صحيحًا`,formInvalidNumber:`أدخل رقمًا صحيحًا`,formTooShort:`قصير جدًا (الحد الأدنى {min} حرفًا)`,formTooLong:`طويل جدًا (الحد الأقصى {max} حرفًا)`,formNumberTooSmall:`يجب ألا يقل عن {min}`,formNumberTooLarge:`يجب ألا يزيد عن {max}`,formPatternMismatch:`يرجى مطابقة الصيغة المطلوبة`,formChooseAtLeast:`اختر {min} على الأقل`,formChooseAtMost:`اختر {max} على الأكثر`,formOther:`أخرى`,formOtherPlaceholder:`اكتب إجابتك…`,inputRequired:`أسئلة لك`,inputBadge:`أسئلة`,inputAnswered:`تمت الإجابة`,inputSkipped:`تم التخطي`,showOptions:`إظهار الخيارات`,hideOptions:`إخفاء الخيارات`,qtypeText:`إجابتك`,qtypeEmail:`عنوان البريد الإلكتروني`,qtypePhone:`رقم الهاتف`,qtypeNumber:`رقم`,qtypeDate:`تاريخ`,qtypeChooseOne:`اختر واحدًا`,qtypeChooseAny:`اختر أيًا`,qtypeBoolean:`نعم / لا`,inputSubmit:`إرسال الإجابات`,inputSubmitHint:`Enter للإرسال · Shift+Enter = سطر جديد`,inputSkip:`تخطٍّ`,confirmYes:`نعم`,confirmNo:`لا`,approve:`موافقة`,reject:`رفض`,approvalPrompt:`تتطلب {tool} موافقتك للتنفيذ.`,approvalBody:`راجع مُعطيات الأداة أعلاه وقرّر السماح بهذا الإجراء أو رفضه.`,approvalYourResponse:`ردّك: {decision}`,approvalEditHint:`يمكنك تعديل ردّك حتى تستأنف هذه الخطوة.`,approvalSubmitting:`تم إرسال الرد. جارٍ التنفيذ…`,edit:`تعديل`,toolParameters:`المعطيات`,statusAwaiting:`بانتظار الموافقة`,statusResponded:`تم الإرسال`,statusRunning:`قيد التنفيذ`,statusCompleted:`مكتمل`,statusDenied:`مرفوض`,statusError:`خطأ`,statusSuperseded:`تم التخطي`,statusIncomplete:`لم يكتمل`},es:{attach:`Adjuntar archivos`,attachmentMimeRejected:`Tipo de archivo no admitido`,attachmentTooLarge:`El archivo es demasiado grande`,attachmentTooMany:`Se alcanzó el límite de adjuntos`,conversationClosed:`Este chat está cerrado`,conversationLoading:`Cargando chat…`,loadPreviousMessages:`Cargar mensajes anteriores`,close:`Cerrar`,collapse:`Contraer`,collapseSidebar:`Contraer la barra lateral`,composerPlaceholder:`Escribe un mensaje…`,dateLastWeek:`Últimos 7 días`,dateOlder:`Anteriores`,dateToday:`Hoy`,dateYesterday:`Ayer`,dropZone:`Suelta los archivos para adjuntarlos`,errorGeneric:`Algo salió mal`,errorRateLimited:`Demasiadas solicitudes: inténtalo de nuevo en un momento.`,errorRetry:`Reintentar`,expand:`Ampliar`,expandSidebar:`Expandir la barra lateral`,exitFullscreen:`Salir de pantalla completa`,fullscreen:`Pantalla completa`,history:`Historial`,historyBack:`Volver al chat`,historyEmpty:`Aún no tienes chats`,historyContinue:`Continuar el chat`,historyLoading:`Cargando tus chats…`,historyTitle:`Historial de chats`,loadMoreConversations:`Cargar más conversaciones`,language:`Idioma`,launcherOpen:`Abrir el chat`,launcherLabel:`Chatea con nosotros`,micStart:`Iniciar entrada de voz`,micStop:`Detener entrada de voz`,micUnsupported:`Este navegador no admite la entrada de voz`,moreActions:`Más acciones`,newConversation:`Nuevo chat`,panelTitle:`Chat`,popOut:`Abrir en una pestaña nueva`,resizeHandle:`Arrastra para cambiar el tamaño`,scrollToBottom:`Ir a lo más reciente`,send:`Enviar`,queueMessage:`Poner mensaje en cola`,removeQueuedMessage:`Quitar mensaje de la cola`,compactingContext:`Optimizando el contexto de la conversación…`,soundOff:`Sonido desactivado`,soundOn:`Sonido activado`,startNewConversation:`Iniciar un chat nuevo`,talkToOperator:`Hablar con una persona`,connectingOperator:`Conectándote con una persona…`,noOperatorAvailable:`Nadie está disponible ahora — deja tus datos y te contactaremos.`,chattingWithOperator:`Estás chateando con {operator}`,cancelOperatorRequest:`Seguir con la IA`,stop:`Detener`,theme:`Tema`,themeAuto:`Automático`,themeDark:`Oscuro`,themeLight:`Claro`,textSize:`Tamaño del texto`,textSizeSmall:`Pequeño`,textSizeNormal:`Normal`,textSizeLarge:`Grande`,loading:`Cargando…`,visualPreparing:`Preparando visualización…`,visualError:`No se pudo mostrar esta visualización.`,visualPartial:`No se pudieron mostrar algunas partes de esta visualización.`,thinking:`Pensando…`,thoughts:`Razonamiento`,toolResult:`Resultado`,sources:`Fuentes`,feedbackUp:`Buena respuesta`,feedbackDown:`Mala respuesta`,feedbackThanks:`Gracias por tu opinión`,copy:`Copiar`,copied:`Copiado`,tabHome:`Inicio`,tabConversations:`Chats`,tabHelp:`Ayuda`,tabNews:`Novedades`,modulesEmpty:`Aún no hay nada aquí`,moduleBack:`Atrás`,contentLoading:`Cargando…`,contentHelpful:`¿Te resultó útil?`,homeGreeting:`¿Cómo podemos ayudarte?`,homeGreetingNamed:`Hola, {name} 👋`,homeGreetingLead:`¿Cómo podemos ayudarte?`,homeSearchPlaceholder:`Buscar ayuda`,homeAskPlaceholder:`Haz una pregunta…`,homeWhatsNew:`Lo nuevo`,homeContentTitle:`Artículos populares`,homeStatus:`Estado`,helpTitle:`Ayuda`,helpSearchPlaceholder:`Buscar ayuda`,helpEmpty:`Aún no hay artículos de ayuda`,helpLoading:`Cargando la ayuda…`,helpSearchEmpty:`Sin resultados para «{query}»`,helpShowMore:`Mostrar más`,newsTitle:`Novedades`,newsEmpty:`Aún no hay novedades`,newsLoading:`Cargando novedades…`,newsBack:`Volver a novedades`,newsPublishedAt:`Publicado el {date}`,newsShowMore:`Mostrar más`,newsUnseen:`Publicación nueva`,formSubmit:`Enviar`,formSkip:`Quizá más tarde`,formSubmitted:`Completado`,formSkipped:`Quizá más tarde`,formFillOut:`Completar`,formRequired:`Este campo es obligatorio`,formInvalidEmail:`Introduce un correo electrónico válido`,formInvalidTel:`Introduce un número de teléfono válido`,formInvalidUrl:`Introduce una URL válida`,formInvalidNumber:`Introduce un número válido`,formTooShort:`Demasiado corto (mín. {min} caracteres)`,formTooLong:`Demasiado largo (máx. {max} caracteres)`,formNumberTooSmall:`Debe ser al menos {min}`,formNumberTooLarge:`Debe ser como máximo {max}`,formPatternMismatch:`Respeta el formato solicitado`,formChooseAtLeast:`Elige al menos {min}`,formChooseAtMost:`Elige como máximo {max}`,formOther:`Otro`,formOtherPlaceholder:`Escribe tu respuesta…`,inputRequired:`Preguntas para ti`,inputBadge:`Preguntas`,inputAnswered:`Respondido`,inputSkipped:`Omitido`,showOptions:`Mostrar opciones`,hideOptions:`Ocultar opciones`,qtypeText:`Tu respuesta`,qtypeEmail:`Correo electrónico`,qtypePhone:`Número de teléfono`,qtypeNumber:`Número`,qtypeDate:`Fecha`,qtypeChooseOne:`Elige una`,qtypeChooseAny:`Elige varias`,qtypeBoolean:`Sí / No`,inputSubmit:`Enviar respuestas`,inputSubmitHint:`Enter para enviar · Mayús+Enter = nueva línea`,inputSkip:`Omitir`,confirmYes:`Sí`,confirmNo:`No`,approve:`Aprobar`,reject:`Rechazar`,approvalPrompt:`{tool} requiere tu aprobación para ejecutarse.`,approvalBody:`Revisa los parámetros de arriba y decide si permites esta acción.`,approvalYourResponse:`Tu respuesta: {decision}`,approvalEditHint:`Puedes cambiar tu respuesta hasta que este paso continúe.`,approvalSubmitting:`Respuesta enviada. Procesando…`,edit:`Editar`,toolParameters:`Parámetros`,statusAwaiting:`Esperando aprobación`,statusResponded:`Enviado`,statusRunning:`En curso`,statusCompleted:`Completado`,statusDenied:`Denegado`,statusError:`Error`,statusSuperseded:`Omitido`,statusIncomplete:`No completado`},he:{attach:`צירוף קבצים`,attachmentMimeRejected:`סוג הקובץ אינו נתמך`,attachmentTooLarge:`הקובץ גדול מדי`,attachmentTooMany:`הגעת למספר המרבי של קבצים מצורפים`,conversationClosed:`הצ׳אט הזה נסגר`,conversationLoading:`טוען צ׳אט…`,loadPreviousMessages:`טעינת הודעות קודמות`,close:`סגירה`,collapse:`כיווץ`,collapseSidebar:`כיווץ סרגל הצד`,composerPlaceholder:`כתוב הודעה…`,dateLastWeek:`7 הימים האחרונים`,dateOlder:`ישן יותר`,dateToday:`היום`,dateYesterday:`אתמול`,dropZone:`שחרר קבצים כדי לצרף`,errorGeneric:`משהו השתבש`,errorRateLimited:`יותר מדי בקשות — נסה שוב בעוד רגע.`,errorRetry:`נסה שוב`,expand:`הרחבה`,expandSidebar:`הרחבת סרגל הצד`,exitFullscreen:`יציאה ממסך מלא`,fullscreen:`מסך מלא`,history:`היסטוריה`,historyBack:`חזרה לצ׳אט`,historyEmpty:`אין עדיין צ׳אטים קודמים`,historyContinue:`המשך צ׳אט`,historyLoading:`טוען את הצ׳אטים שלך…`,historyTitle:`היסטוריית צ׳אטים`,loadMoreConversations:`טעינת שיחות נוספות`,language:`שפה`,launcherOpen:`פתיחת צ׳אט`,launcherLabel:`דברו איתנו`,micStart:`התחלת קלט קולי`,micStop:`עצירת קלט קולי`,micUnsupported:`קלט קולי אינו נתמך בדפדפן זה`,moreActions:`פעולות נוספות`,newConversation:`צ׳אט חדש`,panelTitle:`צ׳אט`,popOut:`פתיחה בכרטיסייה חדשה`,resizeHandle:`גרור לשינוי הגודל`,scrollToBottom:`מעבר לחדש ביותר`,send:`שליחה`,queueMessage:`הוספת ההודעה לתור`,removeQueuedMessage:`הסרת ההודעה מהתור`,compactingContext:`מבצע אופטימיזציה להקשר השיחה…`,soundOff:`השתקת הצליל`,soundOn:`הפעלת הצליל`,startNewConversation:`התחלת צ׳אט חדש`,talkToOperator:`דברו עם אדם`,connectingOperator:`מחברים אותך לאדם…`,noOperatorAvailable:`אין נציגים זמינים כעת — השאר את הפרטים שלך ונחזור אליך.`,chattingWithOperator:`אתה מצ׳וטט עם {operator}`,cancelOperatorRequest:`המשך לשוחח עם ה-AI`,stop:`עצירה`,theme:`ערכת נושא`,themeAuto:`אוטומטי`,themeDark:`כהה`,themeLight:`בהיר`,textSize:`גודל טקסט`,textSizeSmall:`קטן`,textSizeNormal:`רגיל`,textSizeLarge:`גדול`,loading:`טוען…`,visualPreparing:`מכין תצוגה…`,visualError:`לא ניתן היה להציג תצוגה זו.`,visualPartial:`לא ניתן היה להציג חלקים מתצוגה זו.`,thinking:`חושב…`,thoughts:`מחשבות`,toolResult:`תוצאה`,sources:`מקורות`,feedbackUp:`תשובה טובה`,feedbackDown:`תשובה גרועה`,feedbackThanks:`תודה על המשוב`,copy:`העתק`,copied:`הועתק`,tabHome:`בית`,tabConversations:`צ׳אטים`,tabHelp:`עזרה`,tabNews:`חדשות`,modulesEmpty:`אין כאן עדיין כלום`,moduleBack:`חזרה`,contentLoading:`טוען…`,contentHelpful:`האם זה עזר?`,homeGreeting:`כיצד נוכל לעזור?`,homeGreetingNamed:`שלום {name} 👋`,homeGreetingLead:`כיצד נוכל לעזור?`,homeSearchPlaceholder:`חיפוש עזרה`,homeAskPlaceholder:`שאלו שאלה…`,homeWhatsNew:`מה חדש`,homeContentTitle:`מאמרים פופולריים`,homeStatus:`סטטוס`,helpTitle:`עזרה`,helpSearchPlaceholder:`חיפוש עזרה`,helpEmpty:`אין עדיין מאמרי עזרה`,helpLoading:`טוען עזרה…`,helpSearchEmpty:`אין תוצאות עבור „{query}”`,helpShowMore:`הצגת עוד`,newsTitle:`חדשות`,newsEmpty:`אין עדיין חדשות`,newsLoading:`טוען חדשות…`,newsBack:`חזרה לחדשות`,newsPublishedAt:`פורסם ב-{date}`,newsShowMore:`הצגת עוד`,newsUnseen:`פוסט חדש`,formSubmit:`שליחה`,formSkip:`אחר כך`,formSubmitted:`נשלח`,formSkipped:`דולג`,formFillOut:`מילוי`,formRequired:`שדה חובה`,formInvalidEmail:`הזן כתובת אימייל תקינה`,formInvalidTel:`הזן מספר טלפון תקין`,formInvalidUrl:`הזן כתובת URL תקינה`,formInvalidNumber:`הזן מספר תקין`,formTooShort:`קצר מדי (לפחות {min} תווים)`,formTooLong:`ארוך מדי (לכל היותר {max} תווים)`,formNumberTooSmall:`חייב להיות לפחות {min}`,formNumberTooLarge:`חייב להיות לכל היותר {max}`,formPatternMismatch:`התאם לתבנית הנדרשת`,formChooseAtLeast:`בחר לפחות {min}`,formChooseAtMost:`בחר לכל היותר {max}`,formOther:`אחר`,formOtherPlaceholder:`כתוב את תשובתך…`,inputRequired:`שאלות עבורך`,inputBadge:`שאלות`,inputAnswered:`נענה`,inputSkipped:`דולג`,showOptions:`הצג אפשרויות`,hideOptions:`הסתר אפשרויות`,qtypeText:`התשובה שלך`,qtypeEmail:`כתובת אימייל`,qtypePhone:`מספר טלפון`,qtypeNumber:`מספר`,qtypeDate:`תאריך`,qtypeChooseOne:`בחר אחת`,qtypeChooseAny:`בחר כמה`,qtypeBoolean:`כן / לא`,inputSubmit:`שליחת תשובות`,inputSubmitHint:`Enter לשליחה · Shift+Enter = שורה חדשה`,inputSkip:`דילוג`,confirmYes:`כן`,confirmNo:`לא`,approve:`אישור`,reject:`דחייה`,approvalPrompt:`הכלי {tool} דורש את אישורך כדי לפעול.`,approvalBody:`בדוק את פרמטרי הכלי שלמעלה והחלט אם לאשר פעולה זו.`,approvalYourResponse:`התגובה שלך: {decision}`,approvalEditHint:`ניתן לערוך את תגובתך עד שהשלב הזה יתחדש.`,approvalSubmitting:`התגובה נשלחה. מבצע…`,edit:`עריכה`,toolParameters:`פרמטרים`,statusAwaiting:`ממתין לאישור`,statusResponded:`נשלח`,statusRunning:`פועל`,statusCompleted:`הושלם`,statusDenied:`נדחה`,statusError:`שגיאה`,statusSuperseded:`דולג`,statusIncomplete:`לא הושלם`}};function Et(e,t){let n=Dt(e),r=jt(t),i=n===`en`?{}:Tt[n]??{},a=r?t[n]??{}:t??{},o=r?t.en??{}:{};return{...wt,...i,...o,...a}}function Dt(e){return(e.split(`-`)[0]??`en`).toLowerCase()}const Ot=/* @__PURE__ */ new Set([`ar`,`he`,`iw`,`fa`,`ur`,`ps`,`sd`,`ug`,`yi`,`dv`,`ckb`,`ks`,`nqo`,`prs`,`syr`]);function kt(e){return Ot.has(Dt(e))}function At(e,t){return e[t]??t}function jt(e){if(!e)return!1;for(let t of Object.values(e))if(t&&typeof t==`object`)return!0;return!1}const Mt=new class{get(e){try{return localStorage.getItem(e)}catch{return null}}set(e,t){try{localStorage.setItem(e,t)}catch{}}remove(e){try{localStorage.removeItem(e)}catch{}}},Nt={maxBytes:10485760,maxCount:10,accept:`*/*`},Pt={voice:`local`},Ft={list:[],byTrigger:{}},It={enabled:!0,sampleRate:1},Lt={upload:`/pai/upload-file`,transcribe:`/pai/transcribe-audio`,submitForm:`/pai/submit-form`},Rt={variant:`circle`,size:`md`,label:void 0,icon:`chat`,hidden:!1},zt={floating:[`theme`,`textSize`,`history`,`close`,`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`language`],inline:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`],standalone:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],page:[`theme`,`textSize`,`history`,`clear`,`sound`,`language`],modal:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`],drawer:[`theme`,`textSize`,`history`,`close`,`clear`,`fullscreen`,`popOut`,`sound`,`language`]},Bt={enabled:!0,volume:.3,events:void 0},Vt={enabled:!0,events:void 0},Ht=[{label:`tabConversations`,layout:`chat`}],Ut=C.scope(`context`),Wt=/* @__PURE__ */ new Set([`visitorId`,`conversationId`,`jwt`,`token`,`authorization`,`password`]),Gt=1024,Kt=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function qt(e){return Yt(e,`userContext`,!0)}function Jt(e){return Yt(e,`pageContext`,!1)}function Yt(e,t,n){if(e==null)return;if(typeof e!=`object`||Array.isArray(e)){Ut.warn(`ignored ${t} — expected an object`,{type:Array.isArray(e)?`array`:typeof e});return}let r={},i=0;for(let[n,a]of Object.entries(e)){if(Wt.has(n)){Ut.warn(`dropped reserved ${t} key "${n}" — managed by the widget, not host-settable`);continue}if(a==null)continue;if(i>=50){Ut.warn(`${t} truncated at 50 keys — dropped "${n}"`);continue}let e=Xt(t,n,a);e!==void 0&&(r[n]=e,i++)}return n&&typeof r.email==`string`&&!Kt.test(r.email)&&(Ut.warn(`dropped malformed context field`,{field:`${t}.email`,reason:`invalid format`}),delete r.email),Object.keys(r).length>0?r:void 0}function Xt(e,t,n){if(typeof n==`boolean`)return n;if(typeof n==`number`){if(!Number.isFinite(n)){Ut.warn(`dropped non-finite ${e}.${t}`);return}return n}if(typeof n==`string`){let r=n.trim();return r===``?void 0:r.length>Gt?(Ut.warn(`truncated ${e}.${t} to ${Gt} chars`),r.slice(0,Gt)):r}Ut.warn(`dropped ${e}.${t} — only string/number/boolean values are allowed`,{type:typeof n})}function Zt(e){let t=typeof e==`object`&&e?e:{},n=t.presentation??{},r=t.behavior??{},i=t.i18n??{},a=t.feedback??{},o=t.footer??{},s=t.header??{},{themeMode:c,themeOverrides:l}=Qt(t.theme),d=n.mode??`floating`,f=$t(i.defaultLocale),p=i.availableLocales??[i.locale??f],m=en(i.locale??f,p,f),h=(t.baseUrl??u.defaultBaseUrl).replace(/\/$/,``),g=(t.agentApiBaseUrl??`${h}/api/agent`).replace(/\/$/,``),_=(t.dataApiBaseUrl??`${h}/api/data`).replace(/\/$/,``);return{widgetId:t.widgetId??`default`,publicKey:t.publicKey,aiAgentDeploymentId:t.aiAgentDeploymentId,baseUrl:h,agentApiBaseUrl:g,dataApiBaseUrl:_,userContext:qt(t.userContext),pageContext:Jt(t.pageContext),position:n.position??`bottom-right`,themeMode:c,textSize:`normal`,themeOverrides:l,mode:d,iframe:n.iframe??!1,responseMode:r.responseMode??`streaming`,showReasoning:r.showReasoning??!1,showToolCalls:r.showToolCalls??!1,showSources:r.showSources??!1,enableMessageFeedback:!(r.disableMessageFeedback??!1),autoSendSuggestions:r.autoSendSuggestions??!1,popOutUrl:r.popOutUrl,features:{voice:t.features?.voice??Pt.voice,fileUpload:!(t.features?.disableFileUpload??!1),humanInLoop:!(t.features?.disableHumanInLoop??!1),operatorRequest:t.features?.enableOperatorRequest===!0},forms:ln(t.forms,m),endpoints:{upload:t.endpoints?.upload??Lt.upload,transcribe:t.endpoints?.transcribe??Lt.transcribe,submitForm:t.endpoints?.submitForm??Lt.submitForm},attachments:{accept:t.composer?.attachments?.accept??Nt.accept,maxBytes:t.composer?.attachments?.maxBytes??Nt.maxBytes,maxCount:t.composer?.attachments?.maxCount??Nt.maxCount},locale:m,defaultLocale:f,availableLocales:p,startMinimized:r.startMinimized??!0,actions:tn(d,s.actions),size:n.size??{},launcher:dn(t.launcher),sound:nn(a.sound),haptics:rn(a.haptics),strings:Et(m,i.strings),stringsOverride:i.strings,composerDisclaimer:o.composerDisclaimer??``,poweredBy:on(o.poweredBy),composer:sn(t.composer),modules:cn(t.modules),tracking:an(t.tracking,_),storage:t.storage??Mt,userToken:t.userToken,tools:t.tools,onMessage:t.onMessage,onOpen:t.onOpen,onClose:t.onClose,onError:t.onError}}function Qt(e){if(typeof e==`string`)return{themeMode:e,themeOverrides:{}};if(!e||typeof e!=`object`)return{themeMode:`auto`,themeOverrides:{}};let{mode:t,...n}=e;return{themeMode:t??`auto`,themeOverrides:n}}function $t(e){return e&&e!==`auto`?e:globalThis.navigator?.language||`en`}function en(e,t,n){return t.length<=1||t.includes(e)?e:t.includes(n)?n:t[0]??e}function tn(e,t){return t??zt[e]}function nn(e){return{enabled:e?.enabled??Bt.enabled,volume:e?.volume??Bt.volume,events:e?.events}}function rn(e){return{enabled:e?.enabled??Vt.enabled,events:e?.events}}function an(e,t){let n=e?.sampleRate??It.sampleRate;return{enabled:e?.enabled??It.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 on(e){let t={text:`Powered by ${u.displayName}`,href:u.siteUrl,...e};return t.text||t.logoUrl?t:null}function sn(e){let t=e?.sendButton;return{sendButton:{shape:t?.shape??`circle`,icon:t?.icon??`arrowUp`,variant:t?.variant??`filled`}}}function cn(e){let t=e??Ht,n=/* @__PURE__ */ new Set,r=[];for(let e of t.slice(0,4)){if(!e?.label||!e?.layout)continue;let t=e.contentCollectionIds?.filter(Boolean),i=e.id??t?.[0]??e.layout;for(;n.has(i);)i=`${i}-${r.length}`;n.add(i);let a={id:i,label:e.label,layout:e.layout};t?.length&&(a.contentCollectionIds=t),e.layout===`home`&&(a.brandName=e.brandName,a.greetingText=e.greetingText,a.showGreeting=!(e.hideGreeting??!1),a.showSearchBar=!(e.hideSearchBar??!1),a.showRecentConversations=!(e.hideRecentConversations??!1),e.userAvatars?.length&&(a.userAvatars=e.userAvatars),e.status&&(a.status=e.status),a.contentBlockTitle=e.contentBlockTitle),r.push(a)}return{list:r,byId:Object.fromEntries(r.map(e=>[e.id,e]))}}function ln(e,t){if(!e?.length)return Ft;let n=[],r=/* @__PURE__ */ new Set;for(let i of e){if(!i?.id||r.has(i.id))continue;let e=Ct(i,t),a=(e.fields??[]).filter(e=>!!(e?.name&&e.label&&e.type)),o=(Array.isArray(e.on)?e.on:[e.on]).map(un).filter(e=>e!==null);a.length!==0&&o.length!==0&&(r.add(e.id),n.push({id:e.id,triggers:o,when:e.when,fields:a,title:e.title,description:e.description,submitLabel:e.submitLabel,skippable:e.skippable??!1,frequency:e.frequency??`once`,mirrorToContext:e.mirrorToContext??!0,reopenable:e.reopenable??!0,reviewable:e.reviewable??!0}))}let i={};for(let e of n){var a;for(let t of e.triggers)(i[a=t.kind]??(i[a]=[])).push(e)}return{list:n,byTrigger:i}}function un(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 e=Number(n);return Number.isFinite(e)&&e>0?{kind:`after-messages`,param:e}:null}if(t===`idle`){let e=Number(n);return Number.isFinite(e)&&e>0?{kind:`idle`,param:e}:null}return t===`page-area`&&n?{kind:`page-area`,param:n}:null}function dn(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??Rt.variant,size:e?.size??Rt.size,label:e?.label??Rt.label,icon:e?.icon??Rt.icon,hidden:e?.hidden??Rt.hidden,callout:t}}function fn(e,t,n,r){let i=en(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=Et(i,e.stringsOverride)),n!==e.themeMode&&(a.themeMode=n),r!==e.textSize&&(a.textSize=r),a}const pn=[`presentation`,`behavior`,`theme`,`launcher`,`header`,`composer`,`feedback`,`i18n`,`footer`,`features`,`tracking`,`endpoints`];function mn(e,t){if(!t)return e;let n={...e};for(let r of pn){let i=t[r];if(i===void 0)continue;let a=e[r];r===`theme`?a===void 0?n[r]=i:typeof a==`string`&&typeof i==`object`&&i&&(n[r]={...i,mode:a}):r!==`i18n`&&(n[r]=hn(i,a))}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 e=hn(i??{},r);i?.availableLocales!==void 0&&(e.availableLocales=i.availableLocales),i?.defaultLocale!==void 0&&(e.defaultLocale=i.defaultLocale);let t=r?.strings,a=i?.strings;(t||a)&&(e.strings=gn(a,t)),n.i18n=e}return n}function hn(e,t){if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function gn(e,t){if(!e)return t;if(!t)return e;let n=jt(e),r=jt(t);if(!n&&!r)return{...e,...t};let i={},a=n?e:{en:e},o=r?t:{en:t};for(let[e,t]of Object.entries(a))i[e]={...t};for(let[e,t]of Object.entries(o))i[e]={...i[e],...t};return i}const _n=[`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`history`,`language`,`theme`,`textSize`,`close`];function vn(e){return e!==`false`}const yn=[[`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]],bn=[[`mode`,`mode`,e=>e],[`position`,`position`,e=>e],[`iframe`,`iframe`,vn]],xn=[[`width`,`width`],[`height`,`height`]],Sn=[[`response-mode`,`responseMode`,e=>e],[`start-minimized`,`startMinimized`,vn],[`show-reasoning`,`showReasoning`,vn],[`show-tool-calls`,`showToolCalls`,vn],[`show-sources`,`showSources`,vn],[`disable-message-feedback`,`disableMessageFeedback`,vn],[`auto-send-suggestions`,`autoSendSuggestions`,vn],[`pop-out-url`,`popOutUrl`]],Cn=[[`locale`,`locale`]];new Set(_n);const wn=[[`launcher-variant`,`variant`,e=>e],[`launcher-size`,`size`,e=>e],[`launcher-icon`,`icon`],[`launcher-hidden`,`hidden`,vn]],Tn=[[`features-disable-file-upload`,`disableFileUpload`,vn],[`features-voice`,`voice`,e=>e]],En=[[`endpoint-upload`,`upload`],[`endpoint-transcribe`,`transcribe`]],Dn=[[`user-id`,`id`],[`user-email`,`email`],[`user-name`,`name`]],On=[[`page-area`,`area`],[`page-url`,`url`],[`page-path`,`path`],[`page-title`,`title`]],kn=[`launcher-label`,`callout-text`,`callout-delay`,`actions`,`user-context`,`page-context`],An=[yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On],jn=/* @__PURE__ */ new Set([`iframe`,`start-minimized`]);[...An.flatMap(e=>e.map(([e])=>e).filter(e=>!jn.has(e))),...kn];const Mn=C.scope(`track`);function Nn(e,t){let n=typeof e==`string`?e.trim():``;if(!n||n.length>64){Mn.warn(`track: ignored an event without a name of 1–64 characters`,{name:e});return}let r=Object.fromEntries(Object.entries(typeof t==`object`&&t?t:{}).filter(e=>typeof e[1]==`string`||typeof e[1]==`boolean`||Number.isFinite(e[1])));return JSON.stringify(r).length>256?(Mn.warn(`track: sent the event without its data, which is over 256 characters`,{name:n}),{name:n}):Object.keys(r).length>0?{name:n,data:r}:{name:n}}function Pn(e){let t=[];return e.on(`hostEvent`,e=>{t.push({...e,at:Date.now()}),t.length>10&&t.shift()}),t}function Fn(){let e=Date.now(),t=/* @__PURE__ */ 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,In(t.subarray(6)),t[6]=t[6]&15|112,t[8]=t[8]&63|128;let n=Array.from(t,e=>e.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 In(e){if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256)}const Ln=C.scope(`persistence`);function Rn(e,t=Mt,n){let r=n?`${e}.${n}`:e,i=`${u.cssPrefix}.storageVersion`,a=t.get(i)??void 0,o=a?`.v${a}`:``,s=`${u.cssPrefix}.${r}${o}`,c=`${u.cssPrefix}${o}.visitorId`,l=`${s}.conversationId`,d=`${s}.userPrefs`,f=`${s}.panelOpen`,p=`${s}.panelSize`,m=`${s}.calloutDismissed`,h=`${s}.sidebarCollapsed`,g=`${s}.activeModule`,_=`${s}.seenNewsId`,v=`${s}.historyCount`,y=`${s}.formsDone`,b={getVisitorId(){let e=t.get(c);if(e)return e;let n=Fn();return t.set(c,n),n},loadConversationId(){return t.get(l)??void 0},saveConversationId(e){Ln.trace(`saveConversationId`,{id:e,scope:r}),e?t.set(l,e):t.remove(l)},loadDraft(e){return t.get(`${s}.draft.${e}`)??``},saveDraft(e,n){let r=`${s}.draft.${e}`;n?t.set(r,n):t.remove(r)},loadMessageQueue(e){let n=t.get(`${s}.messageQueue.${e}`);if(!n)return[];try{let e=JSON.parse(n);return!Array.isArray(e)||!e.every(Bn)?[]:e}catch(e){return Ln.warn(`loadMessageQueue parse failed`,{error:e}),[]}},saveMessageQueue(e,n){let r=`${s}.messageQueue.${e}`;if(n.length===0)t.remove(r);else try{t.set(r,JSON.stringify(n))}catch(e){Ln.warn(`saveMessageQueue serialise failed`,{error:e})}},loadUserPrefs(){let e=t.get(d);if(!e)return{};try{return Vn(JSON.parse(e))}catch(e){return Ln.warn(`loadUserPrefs parse failed`,{error:e}),{}}},saveUserPrefs(e){try{t.set(d,JSON.stringify(e))}catch(e){Ln.warn(`saveUserPrefs serialise failed`,{error:e})}},patchUserPrefs(e){let t=b.loadUserPrefs();b.saveUserPrefs({...t,...e})},loadPanelOpen(){let e=t.get(f);return e===`1`||e!==`0`&&null},savePanelOpen(e){t.set(f,e?`1`:`0`)},loadPanelSize(){let e=t.get(p);return e===`normal`||e===`expanded`||e===`fullscreen`?e:null},savePanelSize(e){t.set(p,e)},loadCalloutDismissed(e){if(!e)return!1;let n=t.get(m);return!!n&&n===e},saveCalloutDismissed(e){e?t.set(m,e):t.remove(m)},loadSidebarCollapsed(){let e=t.get(h);return e===`1`||e!==`0`&&null},saveSidebarCollapsed(e){t.set(h,e?`1`:`0`)},loadActiveModule(){return t.get(g)||null},saveActiveModule(e){t.set(g,e)},loadSeenNewsId(){return t.get(_)||null},saveSeenNewsId(e){t.set(_,e)},loadHistoryCount(){let e=t.get(v);if(!e)return null;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:null},saveHistoryCount(e){t.set(v,String(e))},loadFormsDone(){let e=t.get(y);if(!e)return{};try{let t=JSON.parse(e);return zn(t)?Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]==`number`)):{}}catch(e){return Ln.warn(`loadFormsDone parse failed`,{error:e}),{}}},saveFormDone(e){try{let n=b.loadFormsDone();n[e]=Date.now(),t.set(y,JSON.stringify(n))}catch(e){Ln.warn(`saveFormDone serialise failed`,{error:e})}},rememberStorageVersion(e){e&&e!==t.get(i)&&(Ln.debug(`rememberStorageVersion (force-reset on next load)`,{version:e}),t.set(i,e))},clearConversation(){t.remove(l)},reset(){let e=t.get(l);e&&(t.remove(`${s}.draft.${e}`),t.remove(`${s}.messageQueue.${e}`));for(let e of[c,l,d,f,p,m,h,g,_,v,y])t.remove(e);Ln.info(`reset: forgot the visitor`,{scope:r})}};return b}function zn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Bn(e){return zn(e)&&typeof e.id==`string`&&e.id.length>0&&typeof e.text==`string`}function Vn(e){if(!zn(e))return{};let t={};return typeof e.locale==`string`&&(t.locale=e.locale),typeof e.soundMuted==`boolean`&&(t.soundMuted=e.soundMuted),(e.themeMode===`auto`||e.themeMode===`light`||e.themeMode===`dark`)&&(t.themeMode=e.themeMode),(e.textSize===`small`||e.textSize===`normal`||e.textSize===`large`)&&(t.textSize=e.textSize),zn(e.widgetSize)&&typeof e.widgetSize.width==`number`&&typeof e.widgetSize.height==`number`&&(t.widgetSize={width:e.widgetSize.width,height:e.widgetSize.height}),t}const Hn=`1.11.0`,Un={open:()=>void 0,close:()=>void 0,expand:e=>({on:e}),fullscreen:e=>({on:e}),send:e=>({attachments:e.attachmentCount}),message:e=>({role:e.role}),stop:()=>void 0,clear:()=>void 0,suggestion:()=>void 0,toggleHistory:e=>({view:e.view}),handshake:()=>void 0,formSubmit:e=>({formId:e.formId,skipped:e.skipped}),toolResult:()=>void 0,toolDecision:e=>({approved:e.approved}),hostEvent:e=>({name:e.name,data:e.data&&JSON.stringify(e.data)}),messageFeedback:e=>({value:e.value??`none`}),contentView:e=>({section:e.section,count:e.count}),contentOpen:e=>({contentId:e.contentId,contentCollectionId:e.contentCollectionId}),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:()=>void 0,voiceStop:e=>({ms:e.durationMs}),voiceCancel:()=>void 0,localeChange:e=>({locale:e}),themeChange:e=>({theme:e}),textSizeChange:e=>({size:e}),soundToggle:e=>({muted:e.muted}),sidebarToggle:e=>({collapsed:e.collapsed}),calloutDismiss:()=>void 0,error:()=>void 0};function Wn(){let e=navigator;return e.globalPrivacyControl===!0||e.doNotTrack===`1`}function Gn(){return location.origin+location.pathname}function Kn(){try{return document.referrer?new URL(document.referrer).origin:``}catch{return``}}function qn(e,t){let n=Math.random(),r=0,i=0,a=/* @__PURE__ */ new Set;function o(e,o){let{tracking:s,publicKey:c,aiAgentDeploymentId:l,mode:u,themeMode:d}=t.getOptions();if(!s.enabled||Wn()||n>=s.sampleRate)return;let f=performance.now();if(f-r>6e4&&(r=f,i=0),++i>60)return;let p=new URLSearchParams;p.set(`v`,`1`),p.set(`_ev`,Hn),p.set(`e`,e),s.token&&p.set(`tk`,s.token),c&&p.set(`pk`,c),l&&p.set(`dep`,l),p.set(`vid`,t.getVisitorId());let m=t.getConversationId();m&&p.set(`cid`,m),p.set(`url`,Gn());let h=Kn();h&&p.set(`ref`,h),p.set(`sw`,String(screen.width)),p.set(`sh`,String(screen.height)),p.set(`vw`,String(innerWidth)),p.set(`vh`,String(innerHeight)),p.set(`dpr`,String(devicePixelRatio)),p.set(`lang`,navigator.language);try{p.set(`tz`,Intl.DateTimeFormat().resolvedOptions().timeZone)}catch{}if(p.set(`m`,u),p.set(`th`,d),o)for(let[e,t]of Object.entries(o))t!==void 0&&p.set(e,String(t));p.set(`ts`,String(Date.now()));let g=`${s.endpoint}?${p}`;if(g.length>2e3)return;let _=new Image(1,1);a.add(_);function v(){return a.delete(_)}_.addEventListener(`load`,v,{once:!0}),_.addEventListener(`error`,v,{once:!0}),_.src=g}let s=[];function c(e,t){if(s&&e!==`handshake`){s.length<60&&s.push([e,t]);return}let n=s??[];s=void 0;for(let[e,t]of n)o(e,t);o(e,t)}let l=Object.keys(Un).map(t=>e.on(t,e=>c(t,Un[t]?.(e))));return()=>{for(let e of l)e();a.clear()}}const Jn=`: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__-accent-fg: var(--__P__-accent);--__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__-pill-l-min: .3;--__P__-pill-l-max: .46;--__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__-conversation-max: 768px;--__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-mode="modal"]),:host([data-mode="drawer"]){--__P__-conversation-max: 100%}: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);--__P__-pill-l-min: .75;--__P__-pill-l-max: .92;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__-pill-l-min: .75;--__P__-pill-l-max: .92;--__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);--__P__-accent-fg: oklch(from var(--__P__-accent-user) clamp(.3, l, .46) c h)}:host([data-theme="dark"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h);--__P__-accent-fg: var(--__P__-accent)}@media(prefers-color-scheme:dark){:host([data-theme="auto"]){--__P__-accent: oklch(from var(--__P__-accent-user) clamp(.65, l, .85) c h);--__P__-accent-fg: var(--__P__-accent)}}}@media(prefers-reduced-motion:reduce){:host{--__P__-dur-quick: 1ms;--__P__-dur-base: 1ms;--__P__-dur-slow: 1ms}}
3
3
 
4
4
  *,*: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-fg);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}
5
5
 
6
- .__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-fg);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;overscroll-behavior:none;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:var(--__P__-visual-viewport-top, 0px) 0 auto;height:var(--__P__-visual-viewport-height, 100dvh);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:100%;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:var(--__P__-visual-viewport-top, 0px) 0 auto;align-items:stretch;height:var(--__P__-visual-viewport-height, 100dvh);padding:0}:host([data-mode="open"]) .__P__-panel,:host([data-mode="expanded"]) .__P__-panel{width:100vw;height:100%;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-fg);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;position:relative;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 svg{width:18px;height:18px}.__P__-icon-btn[data-recording=true]{color:var(--__P__-accent-fg);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__-list--fade{--__P__-fade-size: 20px;--__P__-fade-top: 0px;--__P__-fade-bottom: 0px;-webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 var(--__P__-fade-top),#000 calc(100% - var(--__P__-fade-bottom)),transparent 100%);mask-image:linear-gradient(to bottom,transparent 0,#000 var(--__P__-fade-top),#000 calc(100% - var(--__P__-fade-bottom)),transparent 100%)}.__P__-list--fade[data-fade-top=true]{--__P__-fade-top: var(--__P__-fade-size)}.__P__-list--fade[data-fade-bottom=true]{--__P__-fade-bottom: var(--__P__-fade-size)}.__P__-list>*{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-load-previous,.__P__-history-more{display:flex;justify-content:center}.__P__-load-previous button,.__P__-history-more button{border:0;padding:4px 8px;background:transparent;color:var(--__P__-accent);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;cursor:pointer}.__P__-load-previous button:hover,.__P__-history-more button:hover{text-decoration:underline}.__P__-load-previous button:focus-visible,.__P__-history-more button:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-load-previous button:disabled,.__P__-history-more button:disabled{cursor:wait;opacity:.6}.__P__-date-divider{display:flex;justify-content:center;margin-block:var(--__P__-space-3)}.__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)}.__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%;min-width:0;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:break-word;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:1px solid var(--__P__-border);border-end-start-radius:5px}.__P__-bubble-row[data-role=operator] .__P__-bubble{display:flex;align-items:stretch;padding:0;overflow:hidden;background:var(--__P__-bubble-assistant);color:var(--__P__-bubble-assistant-text);border-end-start-radius:5px}.__P__-bubble-row[data-role=operator] .__P__-bubble-col{align-items:flex-start}.__P__-bubble-author{display:flex;flex:0 0 auto;align-items:center;padding:0 .875rem;border-inline-end:1px solid color-mix(in oklab,var(--__P__-accent),transparent 60%);color:var(--__P__-accent);font-size:calc(13px * var(--__P__-text-scale));font-weight:600;letter-spacing:.025em;user-select:none}.__P__-bubble-row[data-role=operator] .__P__-bubble-body{flex:1 1 auto;min-width:0;padding:var(--__P__-space-3) var(--__P__-space-4)}.__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-row[data-role=assistant] .__P__-bubble-col:has(.__P__-toolui){width:100%}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col:has(.__P__-toolui) .__P__-bubble{width:100%}@media(max-width:640px){.__P__-bubble-col{max-width:92%}.__P__-toolui:not(.__P__-toolui-collapsible){padding:var(--__P__-space-3);gap:var(--__P__-space-2)}details.__P__-toolui-collapsible>summary{padding:var(--__P__-space-2) var(--__P__-space-3)}details.__P__-toolui-collapsible>.__P__-toolui-section{margin:var(--__P__-space-3)}.__P__-toolui-section,.__P__-toolui-desc{padding:var(--__P__-space-2) var(--__P__-space-3)}}.__P__-bubble-meta{display:flex;align-items:center;gap:8px;margin-top:2px;padding:0 2px;min-height:24px}.__P__-bubble-actions{display:flex;align-items:center;gap:2px}.__P__-bubble-time{font-size:calc(11px * var(--__P__-text-scale));line-height:1;color:var(--__P__-fg-muted);user-select:none}.__P__-feedback{display:flex;align-items:center;gap:2px}.__P__-msg-action{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border:0;border-radius:var(--__P__-radius-sm);background:transparent;color:var(--__P__-fg-muted);cursor:pointer;opacity:.65;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),background var(--__P__-dur-quick) var(--__P__-ease),color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-msg-action:hover{opacity:1;background:var(--__P__-bg-elevated);color:var(--__P__-fg)}.__P__-msg-action:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;opacity:1}.__P__-msg-action[data-active=true]{opacity:1;color:var(--__P__-accent-fg)}.__P__-msg-action svg{width:15px;height:15px}.__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>*{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-compaction-status{width:100%;padding:10px 14px;justify-content:center;font-size:var(--__P__-text-xs)}.__P__-message-queue{display:flex;max-height:112px;flex-direction:column;gap:var(--__P__-space-1);overflow-y:auto}.__P__-attachment-chip.__P__-queued-message{width:100%;max-width:none}.__P__-queued-text{min-width:0;flex:1}.__P__-composer-row{display:flex;align-items:flex-end;gap:6px}.__P__-textarea{flex:1;--__P__-textarea-base-height: 40px;height:var(--__P__-textarea-base-height);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)}.__P__-textarea:focus-visible{outline:none;border-color:var(--__P__-focus)}@media(pointer:coarse){.__P__-textarea{--__P__-textarea-base-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-fg);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-fg)}.__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-fg);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 12px;border-radius:var(--__P__-radius-sm);background:color-mix(in oklab,var(--__P__-danger) 8%,var(--__P__-bg-elevated));border:1px solid color-mix(in oklab,var(--__P__-danger) 20%,transparent);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);display:flex;align-items:center;gap:var(--__P__-space-2)}.__P__-error span{min-width:0}.__P__-error button{margin-inline-start:auto;flex-shrink:0;border:0;background:none;padding:0;color:var(--__P__-accent-fg);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;text-decoration:underline;white-space:nowrap;cursor:pointer}.__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-card>[role=listitem]{display:flex;flex-direction:column}.__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-card>*+*{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-fg)}.__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__-operator-banner{display:flex;align-items:center;justify-content:center;gap:8px;margin:0 var(--__P__-space-3) var(--__P__-space-1);padding:8px 12px;border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-bg-elevated),var(--__P__-accent) 6%);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);line-height:1.3;text-align:center}.__P__-operator-pulse{flex:0 0 auto;width:8px;height:8px;border-radius:50%;background:var(--__P__-accent)}.__P__-operator-banner[data-mode=awaiting-operator] .__P__-operator-pulse{animation:__P__-operator-pulse 1.4s var(--__P__-ease-out) infinite}.__P__-cancel-operator-request{flex:0 0 auto;padding:0;border:0;background:none;color:var(--__P__-accent);font:inherit;font-weight:600;text-decoration:underline;text-underline-offset:2px;cursor:pointer}.__P__-cancel-operator-request:hover{opacity:.8}.__P__-cancel-operator-request:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px;border-radius:var(--__P__-radius-sm)}@keyframes __P__-operator-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(.7)}}.__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-fg)}.__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-fg);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__-help-more{justify-content:center;color:var(--__P__-accent-fg);font-weight:600}.__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)}@media(hover:hover){.__P__-tab:hover{background:var(--__P__-hover)}}.__P__-tab[aria-selected=true]{color:var(--__P__-accent-fg)}.__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:-2px;left:calc(50% + 6px);width:8px;height:8px;border-radius:50%;background:var(--__P__-accent);box-shadow:0 0 0 2px var(--__P__-bg-elevated)}.__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-fg)}.__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;line-height:1.45}.__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-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{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-home-search[data-input=true]:focus-within{outline:none;border-color:var(--__P__-focus)}.__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-input:focus-visible{outline:none}.__P__-home-search-icon svg{width:18px;height:18px;color:var(--__P__-accent-fg)}.__P__-home-ask{padding-block:6px;padding-inline-end:6px}.__P__-home-ask .__P__-send{width:32px;height:32px;flex-shrink:0}.__P__-home-ask .__P__-send[data-shape=pill]{width:auto;padding:0 14px}.__P__-home-ask .__P__-send svg{width:16px;height:16px}.__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-fg);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__-history>*,.__P__-home-scroll>*,.__P__-module-scroll>*,.__P__-help-list>*,.__P__-history-footer>*,.__P__-module-pad{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-header,.__P__-back-header{padding-inline:max(12px,calc((100% - var(--__P__-conversation-max, 768px)) / 2))}.__P__-tabbar{padding-inline:max(0px,calc((100% - var(--__P__-conversation-max, 768px)) / 2))}.__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-vote{display:flex;align-items:center;flex-wrap:wrap;gap:var(--__P__-space-2);padding-top:var(--__P__-space-3);border-top:1px solid var(--__P__-border)}.__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;line-height:1.45;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);overflow:hidden;background:var(--__P__-surface);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-meta{display:flex;flex-wrap:wrap;align-items:center;gap:6px;color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-news-tag{padding:1px 8px;border-radius:6px;background:var(--__P__-hover);color:var(--__P__-fg);font-size:calc(12px * var(--__P__-text-scale));white-space:nowrap}.__P__-news-more{display:flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);width:100%;min-height:44px;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);background:var(--__P__-surface);color:var(--__P__-accent-fg);font-weight:600}.__P__-news-more:hover{background:var(--__P__-bg-elevated)}.__P__-news-more:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__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-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:var(--__P__-space-2)}.__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-type{flex-shrink:0;align-self:center;margin-inline-start:auto;border:1px solid var(--__P__-border);border-radius:5px;background:color-mix(in oklab,var(--__P__-fg-muted) 9%,transparent);padding:1px 7px;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);white-space:nowrap}.__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__-textarea,.__P__-home-search-input,.__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;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:var(--__P__-space-2);margin-top:var(--__P__-space-2)}.__P__-form-hint{flex:1 1 auto;min-width:6rem;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);white-space:nowrap;flex-shrink:0;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);white-space:nowrap;flex-shrink:0;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-form-skip:hover:not(:disabled){background:var(--__P__-bg-elevated)}@media(max-width:640px){.__P__-form-hint{flex-basis:100%;margin-inline-end:0;font-size:var(--__P__-text-xs)}.__P__-form-submit,.__P__-form-skip{flex:1 1 0;text-align:center}}.__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-fg)}.__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{margin-block:var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-lg, 14px);background:var(--__P__-bg-elevated);font-size:var(--__P__-text-sm)}.__P__-toolui:not(.__P__-toolui-collapsible){display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4)}.__P__-toolui-group{display:flex;flex-direction:column;gap:var(--__P__-space-3);margin-block:var(--__P__-space-3)}.__P__-toolui-group>.__P__-toolui{margin-block:0}.__P__-toolui-stale{opacity:.7}details.__P__-toolui-collapsible>summary{display:flex;align-items:center;gap:var(--__P__-space-2);padding:var(--__P__-space-3) var(--__P__-space-4);cursor:pointer;list-style:none;-webkit-tap-highlight-color:transparent;user-select:none}details.__P__-toolui-collapsible>summary::-webkit-details-marker{display:none}details.__P__-toolui-collapsible[open]>summary{border-bottom:1px solid var(--__P__-border)}details.__P__-toolui-collapsible>.__P__-toolui-section{margin:var(--__P__-space-4)}details.__P__-toolui-collapsible>.__P__-toolui-section~.__P__-toolui-section{margin-top:calc(-1 * var(--__P__-space-2))}.__P__-toolui-name-text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-toolui-chevron{display:inline-flex;color:var(--__P__-fg-muted);transition:transform var(--__P__-dur-quick) var(--__P__-ease-out)}details.__P__-toolui-collapsible>summary .__P__-toolui-status{margin-inline-start:auto}.__P__-toolui-chevron svg{width:16px;height:16px}details.__P__-toolui-collapsible[open]>summary .__P__-toolui-chevron{transform:rotate(180deg)}.__P__-toolui-badge,.__P__-toolui-name-pill,.__P__-toolui-q-pill{--__P__-pill: var(--__P__-fg-muted);display:inline-flex;min-width:0;align-items:center;gap:5px;padding:3px 7px;border-radius:5px;border:1px solid var(--__P__-border);background:color-mix(in oklab,var(--__P__-fg-muted) 9%,transparent);color:var(--__P__-pill);font-size:var(--__P__-text-xs);font-weight:600;white-space:nowrap}.__P__-toolui-badge svg,.__P__-toolui-name-pill svg,.__P__-toolui-q-pill svg{flex-shrink:0;width:14px;height:14px}.__P__-toolui-status-icon{display:inline-flex}.__P__-toolui-name-pill{--__P__-pill: oklch(.68 .13 233)}.__P__-toolui-q-pill{--__P__-pill: oklch(.66 .12 195)}.__P__-toolui-status[data-status=completed]{--__P__-pill: var(--__P__-success, #16a34a)}.__P__-toolui-status[data-status=responded]{--__P__-pill: oklch(.62 .15 255)}.__P__-toolui-status[data-status=awaiting]{--__P__-pill: var(--__P__-warning, #f59e0b)}.__P__-toolui-status[data-status=denied]{--__P__-pill: oklch(.66 .16 45)}.__P__-toolui-status[data-status=error]{--__P__-pill: var(--__P__-danger, #dc2626)}.__P__-toolui-status[data-status=superseded]{--__P__-pill: var(--__P__-fg-muted)}@supports (color: oklch(from red l c h)){.__P__-toolui-badge,.__P__-toolui-name-pill,.__P__-toolui-q-pill{color:oklch(from var(--__P__-pill) clamp(var(--__P__-pill-l-min),l,var(--__P__-pill-l-max)) c h)}}.__P__-toolui-head{display:flex;align-items:center;flex-wrap:wrap;gap:var(--__P__-space-2)}.__P__-toolui-head-end{display:inline-flex;align-items:center;gap:var(--__P__-space-2);margin-inline-start:auto}.__P__-toolui-collapse-body{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4)}.__P__-toolui-summary{display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-toolui-collapse-body>.__P__-form{gap:var(--__P__-space-3)}.__P__-toolui-collapse-body>.__P__-form>.__P__-field,.__P__-toolui-summary>.__P__-field{padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-bg) 80%,transparent);line-height:1.5}.__P__-toolui-collapse-body>.__P__-form>.__P__-field{gap:var(--__P__-space-2)}.__P__-toolui-summary>.__P__-field{gap:var(--__P__-space-1)}.__P__-toolui-summary .__P__-field-label{color:var(--__P__-fg-muted)}.__P__-toolui-answer{margin:0;font-size:var(--__P__-text-sm);color:var(--__P__-fg-muted);overflow-wrap:anywhere;white-space:pre-wrap}.__P__-toolui-footer{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-3);margin-inline:calc(-1 * var(--__P__-space-4));padding:var(--__P__-space-3) var(--__P__-space-4) 0;border-top:1px solid var(--__P__-border)}.__P__-toolui-options-toggle{display:inline-flex;align-items:center;gap:4px;border:0;background:transparent;padding:0;cursor:pointer;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);transition:color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-toolui-options-toggle:hover{color:var(--__P__-fg)}.__P__-toolui-options-chevron{display:inline-flex;transition:transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-toolui-options-chevron svg{width:14px;height:14px}.__P__-toolui-options-chevron.__P__-open{transform:rotate(180deg)}.__P__-toolui-desc{margin:0;padding:var(--__P__-space-3);border-radius:var(--__P__-radius-md);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:8px;padding:var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);border:1px solid var(--__P__-border)}.__P__-toolui:not(.__P__-toolui-collapsible) .__P__-toolui-section,.__P__-toolui:not(.__P__-toolui-collapsible) .__P__-toolui-desc{padding:0;background:none;border:0;border-radius:0}.__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-code{margin:0;max-height:240px;overflow:auto;color:var(--__P__-fg);font-family:var(--__P__-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);font-size:var(--__P__-text-xs);line-height:1.5;white-space:pre-wrap;word-break:break-word}.__P__-toolui-code[data-error=true]{color:var(--__P__-danger, #dc2626)}.__P__-toolui-body{gap:6px}.__P__-toolui-prompt{margin:0;font-weight:600;color:var(--__P__-fg);overflow-wrap:anywhere}.__P__-toolui-subtle{margin:0;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);line-height:1.5}.__P__-toolui-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:var(--__P__-space-2);margin-top:var(--__P__-space-2)}: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}
6
+ .__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-fg);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;overscroll-behavior:none;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:var(--__P__-visual-viewport-top, 0px) 0 auto;height:var(--__P__-visual-viewport-height, 100dvh);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:100%;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:var(--__P__-visual-viewport-top, 0px) 0 auto;align-items:stretch;height:var(--__P__-visual-viewport-height, 100dvh);padding:0}:host([data-mode="open"]) .__P__-panel,:host([data-mode="expanded"]) .__P__-panel{width:100vw;height:100%;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-fg);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;position:relative;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 svg{width:18px;height:18px}.__P__-icon-btn[data-recording=true]{color:var(--__P__-accent-fg);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__-list--fade{--__P__-fade-size: 20px;--__P__-fade-top: 0px;--__P__-fade-bottom: 0px;-webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 var(--__P__-fade-top),#000 calc(100% - var(--__P__-fade-bottom)),transparent 100%);mask-image:linear-gradient(to bottom,transparent 0,#000 var(--__P__-fade-top),#000 calc(100% - var(--__P__-fade-bottom)),transparent 100%)}.__P__-list--fade[data-fade-top=true]{--__P__-fade-top: var(--__P__-fade-size)}.__P__-list--fade[data-fade-bottom=true]{--__P__-fade-bottom: var(--__P__-fade-size)}.__P__-list>*{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-load-previous,.__P__-history-more{display:flex;justify-content:center}.__P__-load-previous button,.__P__-history-more button{border:0;padding:4px 8px;background:transparent;color:var(--__P__-accent);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;cursor:pointer}.__P__-load-previous button:hover,.__P__-history-more button:hover{text-decoration:underline}.__P__-load-previous button:focus-visible,.__P__-history-more button:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-load-previous button:disabled,.__P__-history-more button:disabled{cursor:wait;opacity:.6}.__P__-date-divider{display:flex;justify-content:center;margin-block:var(--__P__-space-3)}.__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)}.__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%;min-width:0;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:break-word;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:1px solid var(--__P__-border);border-end-start-radius:5px}.__P__-bubble-row[data-role=operator] .__P__-bubble{display:flex;align-items:stretch;padding:0;overflow:hidden;background:var(--__P__-bubble-assistant);color:var(--__P__-bubble-assistant-text);border-end-start-radius:5px}.__P__-bubble-row[data-role=operator] .__P__-bubble-col{align-items:flex-start}.__P__-bubble-author{display:flex;flex:0 0 auto;align-items:center;padding:0 .875rem;border-inline-end:1px solid color-mix(in oklab,var(--__P__-accent),transparent 60%);color:var(--__P__-accent);font-size:calc(13px * var(--__P__-text-scale));font-weight:600;letter-spacing:.025em;user-select:none}.__P__-bubble-row[data-role=operator] .__P__-bubble-body{flex:1 1 auto;min-width:0;padding:var(--__P__-space-3) var(--__P__-space-4)}.__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-row[data-role=assistant] .__P__-bubble-col:has(.__P__-toolui){width:100%}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col:has(.__P__-toolui) .__P__-bubble{width:100%}@media(max-width:640px){.__P__-bubble-col{max-width:92%}.__P__-toolui:not(.__P__-toolui-collapsible){padding:var(--__P__-space-3);gap:var(--__P__-space-2)}details.__P__-toolui-collapsible>summary{padding:var(--__P__-space-2) var(--__P__-space-3)}details.__P__-toolui-collapsible>.__P__-toolui-section{margin:var(--__P__-space-3)}.__P__-toolui-section,.__P__-toolui-desc{padding:var(--__P__-space-2) var(--__P__-space-3)}}.__P__-bubble-meta{display:flex;align-items:center;gap:8px;margin-top:2px;padding:0 2px;min-height:24px}.__P__-bubble-actions{display:flex;align-items:center;gap:2px}.__P__-bubble-time{font-size:calc(11px * var(--__P__-text-scale));line-height:1;color:var(--__P__-fg-muted);user-select:none}.__P__-feedback{display:flex;align-items:center;gap:2px}.__P__-msg-action{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border:0;border-radius:var(--__P__-radius-sm);background:transparent;color:var(--__P__-fg-muted);cursor:pointer;opacity:.65;transition:opacity var(--__P__-dur-quick) var(--__P__-ease),background var(--__P__-dur-quick) var(--__P__-ease),color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-msg-action:hover{opacity:1;background:var(--__P__-bg-elevated);color:var(--__P__-fg)}.__P__-msg-action:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;opacity:1}.__P__-msg-action[data-active=true]{opacity:1;color:var(--__P__-accent-fg)}.__P__-msg-action svg{width:15px;height:15px}.__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>*{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-compaction-status{width:100%;padding:10px 14px;justify-content:center;font-size:var(--__P__-text-xs)}.__P__-message-queue{display:flex;max-height:112px;flex-direction:column;gap:var(--__P__-space-1);overflow-y:auto}.__P__-attachment-chip.__P__-queued-message{width:100%;max-width:none}.__P__-queued-text{min-width:0;flex:1}.__P__-composer-row{display:flex;align-items:flex-end;gap:6px}.__P__-textarea{flex:1;--__P__-textarea-base-height: 40px;height:var(--__P__-textarea-base-height);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)}.__P__-textarea:focus-visible{outline:none;border-color:var(--__P__-focus)}@media(pointer:coarse){.__P__-textarea{--__P__-textarea-base-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-fg);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-fg)}.__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-fg);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 12px;border-radius:var(--__P__-radius-sm);background:color-mix(in oklab,var(--__P__-danger) 8%,var(--__P__-bg-elevated));border:1px solid color-mix(in oklab,var(--__P__-danger) 20%,transparent);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);display:flex;align-items:center;gap:var(--__P__-space-2)}.__P__-error span{min-width:0}.__P__-error button{margin-inline-start:auto;flex-shrink:0;border:0;background:none;padding:0;color:var(--__P__-accent-fg);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;text-decoration:underline;white-space:nowrap;cursor:pointer}.__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-card>[role=listitem]{display:flex;flex-direction:column}.__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-card>*+*{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-fg)}.__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__-operator-banner{display:flex;align-items:center;justify-content:center;gap:8px;margin:0 var(--__P__-space-3) var(--__P__-space-1);padding:8px 12px;border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-bg-elevated),var(--__P__-accent) 6%);color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm);line-height:1.3;text-align:center}.__P__-operator-pulse{flex:0 0 auto;width:8px;height:8px;border-radius:50%;background:var(--__P__-accent)}.__P__-operator-banner[data-mode=awaiting-operator] .__P__-operator-pulse{animation:__P__-operator-pulse 1.4s var(--__P__-ease-out) infinite}.__P__-cancel-operator-request{flex:0 0 auto;padding:0;border:0;background:none;color:var(--__P__-accent);font:inherit;font-weight:600;text-decoration:underline;text-underline-offset:2px;cursor:pointer}.__P__-cancel-operator-request:hover{opacity:.8}.__P__-cancel-operator-request:focus-visible{outline:2px solid var(--__P__-accent);outline-offset:2px;border-radius:var(--__P__-radius-sm)}@keyframes __P__-operator-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(.7)}}.__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-fg)}.__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-fg);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__-help-more{justify-content:center;color:var(--__P__-accent-fg);font-weight:600}.__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)}@media(hover:hover){.__P__-tab:hover{background:var(--__P__-hover)}}.__P__-tab[aria-selected=true]{color:var(--__P__-accent-fg)}.__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:-2px;left:calc(50% + 6px);width:8px;height:8px;border-radius:50%;background:var(--__P__-accent);box-shadow:0 0 0 2px var(--__P__-bg-elevated)}.__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-fg)}.__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;line-height:1.45}.__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-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{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-home-search[data-input=true]:focus-within{outline:none;border-color:var(--__P__-focus)}.__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-input:focus-visible{outline:none}.__P__-home-search-icon svg{width:18px;height:18px;color:var(--__P__-accent-fg)}.__P__-home-ask{padding-block:6px;padding-inline-end:6px}.__P__-home-ask .__P__-send{width:32px;height:32px;flex-shrink:0}.__P__-home-ask .__P__-send[data-shape=pill]{width:auto;padding:0 14px}.__P__-home-ask .__P__-send svg{width:16px;height:16px}.__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-fg);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__-history>*,.__P__-home-scroll>*,.__P__-module-scroll>*,.__P__-help-list>*,.__P__-history-footer>*,.__P__-module-pad{width:100%;max-width:var(--__P__-conversation-max, 768px);margin-inline:auto}.__P__-header,.__P__-back-header{padding-inline:max(12px,calc((100% - var(--__P__-conversation-max, 768px)) / 2))}.__P__-tabbar{padding-inline:max(0px,calc((100% - var(--__P__-conversation-max, 768px)) / 2))}.__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-vote{display:flex;align-items:center;flex-wrap:wrap;gap:var(--__P__-space-2);padding-top:var(--__P__-space-3);border-top:1px solid var(--__P__-border)}.__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;line-height:1.45;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);overflow:hidden;background:var(--__P__-surface);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-meta{display:flex;flex-wrap:wrap;align-items:center;gap:6px;color:var(--__P__-fg-muted);font-size:var(--__P__-text-sm)}.__P__-news-tag{padding:1px 8px;border-radius:6px;background:var(--__P__-hover);color:var(--__P__-fg);font-size:calc(12px * var(--__P__-text-scale));white-space:nowrap}.__P__-news-more{display:flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);width:100%;min-height:44px;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius);background:var(--__P__-surface);color:var(--__P__-accent-fg);font-weight:600}.__P__-news-more:hover{background:var(--__P__-bg-elevated)}.__P__-news-more:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__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-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:var(--__P__-space-2)}.__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-type{flex-shrink:0;align-self:center;margin-inline-start:auto;border:1px solid var(--__P__-border);border-radius:5px;background:color-mix(in oklab,var(--__P__-fg-muted) 9%,transparent);padding:1px 7px;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);white-space:nowrap}.__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__-textarea,.__P__-home-search-input,.__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;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:var(--__P__-space-2);margin-top:var(--__P__-space-2)}.__P__-form-hint{flex:1 1 auto;min-width:6rem;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);white-space:nowrap;flex-shrink:0;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);white-space:nowrap;flex-shrink:0;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-form-skip:hover:not(:disabled){background:var(--__P__-bg-elevated)}@media(max-width:640px){.__P__-form-hint{flex-basis:100%;margin-inline-end:0;font-size:var(--__P__-text-xs)}.__P__-form-submit,.__P__-form-skip{flex:1 1 0;text-align:center}}.__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-fg)}.__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{margin-block:var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-lg, 14px);background:var(--__P__-bg-elevated);font-size:var(--__P__-text-sm)}.__P__-toolui:not(.__P__-toolui-collapsible){display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4)}.__P__-toolui-group{display:flex;flex-direction:column;gap:var(--__P__-space-3);margin-block:var(--__P__-space-3)}.__P__-toolui-group>.__P__-toolui{margin-block:0}.__P__-toolui-stale{opacity:.7}details.__P__-toolui-collapsible>summary{display:flex;align-items:center;gap:var(--__P__-space-2);padding:var(--__P__-space-3) var(--__P__-space-4);cursor:pointer;list-style:none;-webkit-tap-highlight-color:transparent;user-select:none}details.__P__-toolui-collapsible>summary::-webkit-details-marker{display:none}details.__P__-toolui-collapsible[open]>summary{border-bottom:1px solid var(--__P__-border)}details.__P__-toolui-collapsible>.__P__-toolui-section{margin:var(--__P__-space-4)}details.__P__-toolui-collapsible>.__P__-toolui-section~.__P__-toolui-section{margin-top:calc(-1 * var(--__P__-space-2))}.__P__-toolui-name-text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-toolui-chevron{display:inline-flex;color:var(--__P__-fg-muted);transition:transform var(--__P__-dur-quick) var(--__P__-ease-out)}details.__P__-toolui-collapsible>summary .__P__-toolui-status{margin-inline-start:auto}.__P__-toolui-chevron svg{width:16px;height:16px}details.__P__-toolui-collapsible[open]>summary .__P__-toolui-chevron{transform:rotate(180deg)}.__P__-toolui-badge,.__P__-toolui-name-pill,.__P__-toolui-q-pill{--__P__-pill: var(--__P__-fg-muted);display:inline-flex;min-width:0;align-items:center;gap:5px;padding:3px 7px;border-radius:5px;border:1px solid var(--__P__-border);background:color-mix(in oklab,var(--__P__-fg-muted) 9%,transparent);color:var(--__P__-pill);font-size:var(--__P__-text-xs);font-weight:600;white-space:nowrap}.__P__-toolui-badge svg,.__P__-toolui-name-pill svg,.__P__-toolui-q-pill svg{flex-shrink:0;width:14px;height:14px}.__P__-toolui-status-icon{display:inline-flex}.__P__-toolui-name-pill{--__P__-pill: oklch(.68 .13 233)}.__P__-toolui-q-pill{--__P__-pill: oklch(.66 .12 195)}.__P__-toolui-status[data-status=completed]{--__P__-pill: var(--__P__-success, #16a34a)}.__P__-toolui-status[data-status=responded]{--__P__-pill: oklch(.62 .15 255)}.__P__-toolui-status[data-status=awaiting]{--__P__-pill: var(--__P__-warning, #f59e0b)}.__P__-toolui-status[data-status=denied]{--__P__-pill: oklch(.66 .16 45)}.__P__-toolui-status[data-status=error]{--__P__-pill: var(--__P__-danger, #dc2626)}.__P__-toolui-status[data-status=superseded],.__P__-toolui-status[data-status=incomplete]{--__P__-pill: var(--__P__-fg-muted)}@supports (color: oklch(from red l c h)){.__P__-toolui-badge,.__P__-toolui-name-pill,.__P__-toolui-q-pill{color:oklch(from var(--__P__-pill) clamp(var(--__P__-pill-l-min),l,var(--__P__-pill-l-max)) c h)}}.__P__-toolui-head{display:flex;align-items:center;flex-wrap:wrap;gap:var(--__P__-space-2)}.__P__-toolui-head-end{display:inline-flex;align-items:center;gap:var(--__P__-space-2);margin-inline-start:auto}.__P__-toolui-collapse-body{display:flex;flex-direction:column;gap:var(--__P__-space-3);padding:var(--__P__-space-4)}.__P__-toolui-summary{display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-toolui-collapse-body>.__P__-form{gap:var(--__P__-space-3)}.__P__-toolui-collapse-body>.__P__-form>.__P__-field,.__P__-toolui-summary>.__P__-field{padding:10px var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);background:color-mix(in oklab,var(--__P__-bg) 80%,transparent);line-height:1.5}.__P__-toolui-collapse-body>.__P__-form>.__P__-field{gap:var(--__P__-space-2)}.__P__-toolui-summary>.__P__-field{gap:var(--__P__-space-1)}.__P__-toolui-summary .__P__-field-label{color:var(--__P__-fg-muted)}.__P__-toolui-answer{margin:0;font-size:var(--__P__-text-sm);color:var(--__P__-fg-muted);overflow-wrap:anywhere;white-space:pre-wrap}.__P__-toolui-footer{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-3);margin-inline:calc(-1 * var(--__P__-space-4));padding:var(--__P__-space-3) var(--__P__-space-4) 0;border-top:1px solid var(--__P__-border)}.__P__-toolui-options-toggle{display:inline-flex;align-items:center;gap:4px;border:0;background:transparent;padding:0;cursor:pointer;font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);transition:color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-toolui-options-toggle:hover{color:var(--__P__-fg)}.__P__-toolui-options-chevron{display:inline-flex;transition:transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-toolui-options-chevron svg{width:14px;height:14px}.__P__-toolui-options-chevron.__P__-open{transform:rotate(180deg)}.__P__-toolui-desc{margin:0;padding:var(--__P__-space-3);border-radius:var(--__P__-radius-md);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:8px;padding:var(--__P__-space-3);border-radius:var(--__P__-radius-md);background:var(--__P__-bg);border:1px solid var(--__P__-border)}.__P__-toolui:not(.__P__-toolui-collapsible) .__P__-toolui-section,.__P__-toolui:not(.__P__-toolui-collapsible) .__P__-toolui-desc{padding:0;background:none;border:0;border-radius:0}.__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-code{margin:0;max-height:240px;overflow:auto;color:var(--__P__-fg);font-family:var(--__P__-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);font-size:var(--__P__-text-xs);line-height:1.5;white-space:pre-wrap;word-break:break-word}.__P__-toolui-code[data-error=true]{color:var(--__P__-danger, #dc2626)}.__P__-toolui-body{gap:6px}.__P__-toolui-prompt{margin:0;font-weight:600;color:var(--__P__-fg);overflow-wrap:anywhere}.__P__-toolui-subtle{margin:0;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);line-height:1.5}.__P__-toolui-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:var(--__P__-space-2);margin-top:var(--__P__-space-2)}: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}
7
7
 
8
8
  .__P__-generative-ui{display:grid;gap:var(--__P__-space-3);overflow-wrap:anywhere;white-space:pre-wrap}.__P__-generative-ui p{margin:0}.__P__-generative-ui-grid-container{container:__P__-generative-ui-grid / inline-size;min-width:0}.__P__-generative-ui-grid{display:grid;grid-template-columns:minmax(0,1fr);align-items:start;gap:16px}.__P__-generative-ui-cell{display:grid;align-content:start;min-width:0;gap:16px}@container __P__-generative-ui-grid (min-width: 496px){.__P__-generative-ui-grid:is([data-columns="2"],[data-columns="3"],[data-columns="4"]){grid-template-columns:repeat(2,minmax(0,1fr))}.__P__-generative-ui-grid:is([data-columns="2"],[data-columns="3"],[data-columns="4"])>.__P__-generative-ui-cell:is([data-span="2"],[data-span="3"],[data-span="4"]){grid-column:span 2}}@container __P__-generative-ui-grid (min-width: 752px){.__P__-generative-ui-grid:is([data-columns="3"],[data-columns="4"]){grid-template-columns:repeat(3,minmax(0,1fr))}.__P__-generative-ui-grid:is([data-columns="3"],[data-columns="4"])>.__P__-generative-ui-cell:is([data-span="3"],[data-span="4"]){grid-column:span 3}}@container __P__-generative-ui-grid (min-width: 1008px){.__P__-generative-ui-grid[data-columns="4"]{grid-template-columns:repeat(4,minmax(0,1fr))}.__P__-generative-ui-grid[data-columns="4"]>.__P__-generative-ui-cell[data-span="4"]{grid-column:span 4}}.__P__-generative-ui section{display:grid;gap:var(--__P__-space-2);padding:var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-md);min-width:0}.__P__-generative-ui-metric{font-size:1.6em;font-weight:700}.__P__-generative-ui-table{overflow-x:auto}.__P__-generative-ui table{width:100%;border-collapse:collapse;white-space:normal}.__P__-generative-ui caption{text-align:start;font-weight:600;padding-bottom:var(--__P__-space-2)}.__P__-generative-ui th,.__P__-generative-ui td{text-align:start;padding:var(--__P__-space-2);border-bottom:1px solid var(--__P__-border)}.__P__-generative-ui-chart{display:block;width:100%;color:var(--__P__-accent)}.__P__-generative-ui-axis{stroke:var(--__P__-border)}.__P__-generative-ui-data{display:flex;flex-wrap:wrap;gap:var(--__P__-space-2);font-size:.85em}
9
9
 
10
10
  :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}}
11
- `.replace(/__P__/g,`helpai`).replaceAll(`__BRAND_ACCENT_TEXT__`,`#FFFFFF`).replaceAll(`__BRAND_ACCENT__`,`#5B5BD6`).replaceAll(`__BRAND_RADIUS__`,`12px`).replaceAll(`__BRAND_FONT__`,`Inter, system-ui, -apple-system, 'Segoe UI', sans-serif`),nn=[`data-theme`,`data-color-scheme`,`data-mode`,`data-bs-theme`];function rn(e){if(e){if(e.classList.contains(`dark`))return`dark`;if(e.classList.contains(`light`))return`light`;for(let t of nn){let n=e.getAttribute(t);if(n===`dark`||n===`light`)return n}}}function an(e=document){let t=rn(e.documentElement)??rn(e.body);if(t)return t;let n=getComputedStyle(e.documentElement).colorScheme.trim();return n===`dark`||n===`light`?n:typeof matchMedia==`function`&&matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function on(e,t=document){let n=an(t);e(n);function r(){let r=an(t);r!==n&&(n=r,e(r))}let i=new MutationObserver(r),a={attributes:!0,attributeFilter:[`class`,`style`,...nn]};i.observe(t.documentElement,a),t.body&&i.observe(t.body,a);let o=typeof matchMedia==`function`?matchMedia(`(prefers-color-scheme: dark)`):void 0;return o?.addEventListener(`change`,r),()=>{i.disconnect(),o?.removeEventListener(`change`,r)}}const sn=I.scope(`mount`),cn=/* @__PURE__ */ new WeakMap,ln={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 un(e,t){e.style.cssText=ln[t]}function dn(e){return e===`floating`||e===`modal`||e===`drawer`?`floating`:e===`standalone`||e===`page`?`viewport`:`flow`}function fn(e={}){let t=e.position??`flow`;sn.debug(`createShadowMount`,{position:t,hasTarget:!!e.target,hasHost:!!e.existingHost});let n=`${P.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`,P.id),r.style.cssText=ln[t];let i=r.shadowRoot??r.attachShadow({mode:`open`}),a=r.ownerDocument;if(!pn(i,a)){let e=a.createElement(`style`);e.textContent=tn,i.appendChild(e)}let o=document.createElement(`div`);return o.className=`${P.cssPrefix}-app`,i.appendChild(o),{appRoot:o,destroy:()=>r.remove(),hostElement:r,shadowRoot:i}}function pn(e,t){if(!(`adoptedStyleSheets`in e))return!1;let n=t.defaultView;if(!n||typeof n.CSSStyleSheet!=`function`)return!1;let r=cn.get(t);if(!r)try{r=new n.CSSStyleSheet,r.replaceSync(tn),cn.set(t,r)}catch{return!1}try{return e.adoptedStyleSheets=[r],!0}catch{return!1}}function mn(e,t){let n=P.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),t.contentMaxWidth&&e.style.setProperty(`--${n}-conversation-max`,t.contentMaxWidth)}function hn(e,t){e.dataset.theme=t===`host`?an():t}function gn(e,t){let n=P.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 _n(e,t){e.dataset.position=t}function vn(e,t){e.dataset.mode=t}function yn(e,t){hn(e,t.themeMode),mn(e,t.themeOverrides),_n(e,t.position),gn(e,t.size)}var bn,xn,Sn,Cn,wn=Object.is,Tn=0,En=[],Dn=[],On=u,kn=On.__b,An=On.__r,jn=On.diffed,Mn=On.__c,Nn=On.unmount,Pn=On.__;function Fn(e,t){On.__h&&On.__h(xn,e,Tn||t),Tn=0;var n=xn.__H||(xn.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function L(e){return Tn=1,In(Gn,e)}function In(e,t,n){var r=Fn(bn++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Gn(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);wn(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=xn,!xn.__f)){xn.__f=!0;var i=xn.shouldComponentUpdate;xn.shouldComponentUpdate=function(e,t,n){var r=this.__H;if(!r)return!0;var a=!1,o=this.props!=e;if(r.__.some(function(e){e.__N&&(a=!0,wn(e.__[0],e.__N[0])||(o=!0))}),i){var s=i.call(this,e,t,n);return a?s||o:s}return!a||o}}return r.__}function R(e,t){var n=Fn(bn++,3);!On.__s&&Wn(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,xn.__H.__h.push(n))}function Ln(e,t){var n=Fn(bn++,4);!On.__s&&Wn(n.__H,t)&&(n.__P=!1,n.__=e,n.u=t,xn.__h.push(n))}function z(e){return Tn=5,B(function(){return{current:e}},[])}function B(e,t){var n=Fn(bn++,7);return Wn(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function V(e,t){return Tn=8,B(function(){return e},t)}function Rn(){var e;do{for(;e=Dn.shift();)try{Hn(e)}catch(t){On.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=En.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Hn),t.__h.some(Un),t.__h=[]}catch(n){t.__h=[],On.__e(n,e.__v)}}}while(Dn.length)}On.__b=function(e){xn=null,kn&&kn(e)},On.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Pn&&Pn(e,t)},On.__r=function(e){An&&An(e),bn=0;var t=(xn=e.__c).__H;t&&(Sn==xn?xn.__h=[]:(t.__h.some(Hn),t.__h.some(Un),bn=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),Sn=xn},On.diffed=function(e){jn&&jn(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&Vn(En.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),Sn=xn=null},On.__c=function(e,t){t.some(function(e){try{e.__h.some(Hn),e.__h=e.__h.filter(function(e){return!e.__||Un(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],On.__e(n,e.__v)}}),Mn&&Mn(e,t)},On.unmount=function(e){Nn&&Nn(e);var t,n,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n=n&&n.__c}r.__P=n,Vn(Dn.push(r))}else Hn(r)}catch(e){t=e}}),r.__H=void 0,t&&On.__e(t,r.__v))};var zn=typeof requestAnimationFrame==`function`;function Bn(e){var t,n=function(){clearTimeout(r),zn&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);zn&&(t=requestAnimationFrame(n))}function Vn(e){e!=1&&Cn==On.requestAnimationFrame||((Cn=On.requestAnimationFrame)||Bn)(Rn)}function Hn(e){var t=xn,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),xn=t}function Un(e){var t=xn;e.__c=e.__(),xn=t}function Wn(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!wn(t,e[n])})}function Gn(e,t){return typeof t==`function`?t(e):t}var Kn=Symbol.for(`preact-signals`);function qn(){if($n>1)$n--;else{var e,t=!1;for((function(){var e=rr;for(rr=void 0;e!==void 0;){var t=e.S;if(t.v===e.v)for(var n=t.t;n!==void 0;n=n.x)n.i===e.i&&(n.i=t.i);e=e.o}})();Qn!==void 0;){var n=Qn;for(Qn=void 0,er++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&sr(n))try{n.c()}catch(n){t||(e=n,t=!0)}n=r}}if(er=0,$n--,t)throw e}}function Jn(e){if($n>0)return e();nr=++tr,$n++;try{return e()}finally{qn()}}var Yn,Xn=void 0;function Zn(e){var t=Xn,n=Yn;Xn=void 0,Yn=void 0;try{return e()}finally{Xn=t,Yn=n}}var Qn=void 0,$n=0,er=0,tr=0,nr=0,rr=void 0,ir=0;function ar(e){if(Xn!==void 0){var t=e.n;if(t===void 0||t.t!==Xn)return t={i:0,S:e,p:Xn.s,n:void 0,t:Xn,e:void 0,x:void 0,r:t},Xn.s!==void 0&&(Xn.s.n=t),Xn.s=t,e.n=t,32&Xn.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=Xn.s,t.n=void 0,Xn.s.n=t,Xn.s=t),t}}function or(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}or.prototype.brand=Kn,or.prototype.h=function(){return!0},or.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?Zn(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},or.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&&Zn(function(){var e;(e=t.Z)==null||e.call(t)}))}},or.prototype.subscribe=function(e){var t=this;return gr(function(){var n=t.value;Zn(function(){return e(n)})},{name:`sub`})},or.prototype.valueOf=function(){return this.value},or.prototype.toString=function(){return this.value+``},or.prototype.toJSON=function(){return this.value},or.prototype.peek=function(){var e=this;return Zn(function(){return e.value})},Object.defineProperty(or.prototype,"value",{get:function(){var e=ar(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(er>100)throw Error(`Cycle detected`);(function(e){$n!==0&&er===0&&e.l!==nr&&(e.l=nr,rr={S:e,v:e.v,i:e.i,o:rr})})(this),this.v=e,this.i++,ir++,$n++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{qn()}}}});function H(e,t){return new or(e,t)}function sr(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 cr(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 lr(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 ur(e,t){or.call(this,void 0,t),this.x=e,this.s=void 0,this.g=ir-1,this.f=4}ur.prototype=new or,ur.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&&!sr(this))return this.f&=-2,!0;var e=Xn;try{cr(this),Xn=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return Xn=e,lr(this),this.f&=-2,!0},ur.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)}or.prototype.S.call(this,e)},ur.prototype.U=function(e){if(this.t!==void 0&&(or.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)}},ur.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(ur.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=ar(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function dr(e,t){return new ur(e,t)}function fr(e){var t=e.m;if(e.m=void 0,typeof t==`function`){$n++;var n=Xn;Xn=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,pr(e),t}finally{Xn=n,qn()}}}function pr(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,fr(e)}function mr(e){if(Xn!==this)throw Error(`Out-of-order effect`);lr(this),Xn=e,this.f&=-2,8&this.f&&pr(this),qn()}function hr(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Yn&&Yn.push(this)}hr.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()}},hr.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,fr(this),cr(this),$n++;var e=Xn;return Xn=this,mr.bind(this,e)},hr.prototype.N=function(){2&this.f||(this.f|=2,this.u=Qn,Qn=this)},hr.prototype.d=function(){this.f|=8,1&this.f||pr(this)},hr.prototype.dispose=function(){this.d()};function gr(e,t){var n=new hr(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var _r,vr,yr,br=typeof window<`u`&&!!window.__PREACT_SIGNALS_DEVTOOLS__,xr=[];gr(function(){_r=this.N})();function Sr(e,t){u[e]=t.bind(null,u[e]||function(){})}function Cr(e){if(yr){var t=yr;yr=void 0,t()}yr=e&&e.S()}function wr(e){var t=this,n=e.data,r=Er(n);r.name=`ReactiveDom`,r.value=n;var i=B(function(){for(var e=t,n=t.__v;n=n.__;)if(n.__c){n.__c.__$f|=4;break}var i=dr(function(){var e=r.value.value;return e===0?0:!0===e?``:e||``}),a=dr(function(){return!Array.isArray(i.value)&&!f(i.value)}),o=gr(function(){if(this.N=Ar,a.value){var t=i.value;e.__v&&e.__v.__e&&e.__v.__e.nodeType===3&&(e.__v.__e.data=t)}}),s=t.__$u.d;return t.__$u.d=function(){o(),s.call(this)},[a,i]},[]),a=i[0],o=i[1];return a.value?o.peek():o.value}wr.displayName=`ReactiveTextNode`,Object.defineProperties(or.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:wr},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}}),Sr(`__b`,function(e,t){if(Cr(),vr=void 0,typeof t.type==`string`){var n,r=t.props;for(var i in r)if(i!==`children`){var a=r[i];a instanceof or&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)}),Sr(`__r`,function(e,t){if(e(t),t.type!==O){Cr();var n,r=t.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=function(e,t){var n;return gr(function(){n=this},{name:t}),n.c=e,n}(function(e){return function(){var t;br&&((t=this.y)==null||t.call(this)),e.__$f|=1,e.setState({})}}(r),typeof t.type==`function`?t.type.displayName||t.type.name:``))),vr=r,Cr(n)}}),Sr(`__e`,function(e,t,n,r){Cr(),vr=void 0,e(t,n,r)}),Sr(`diffed`,function(e,t){Cr(),vr=void 0;var n;if(typeof t.type==`string`&&(n=t.__e)){var r=t.__np,i=t.props,a=n.U;if(a)for(var o in a){var s=a[o];s===void 0||r&&o in r||(s.d(),a[o]=void 0)}if(r)for(var c in a||(a={},n.U=a),r){var l=a[c],u=r[c];l===void 0?(l=Tr(n,c,u,i),a[c]=l):l.o(u,i)}}e(t)});function Tr(e,t,n,r){var i=t in e&&e.ownerSVGElement===void 0,a=H(n);return{o:function(e,t){a.value=e,r=t},d:gr(function(){this.N=Ar;var n=a.value.value;r[t]!==n&&(r[t]=n,i?e[t]=n:n!=null&&(!1!==n||t[4]===`-`)?e.setAttribute(t,n):e.removeAttribute(t))})}}Sr(`unmount`,function(e,t){if(typeof t.type==`string`){var n=t.__e;if(n){var r=n.U;if(r)for(var i in n.U=void 0,r){var a=r[i];a&&a.d()}}var o=t.__np;if(o){var s=t.props;for(var c in o)s[c]=o[c]}t.__np=void 0}else{var l=t.__c;if(l){l.__$f|=8;var u=l.__$u;u&&(l.__$u=void 0,u.d())}}e(t)}),Sr(`__h`,function(e,t,n,r){r<3&&(t.__$f|=2),e(t,n,r)}),ne.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`&&!0===this.u){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 o in e)if(o!==`__source`&&e[o]!==this.props[o])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function Er(e,t){return B(function(){return H(e,t)},[])}function Dr(e,t){var n=z(e);return n.current=e,vr.__$f|=4,B(function(){return dr(function(){return n.current()},t)},[])}var Or=function(e){queueMicrotask(function(){queueMicrotask(e)})};function kr(){Jn(function(){for(var e;e=xr.shift();)_r.call(e)})}function Ar(){xr.push(this)===1&&(u.requestAnimationFrame||Or)(kr)}function jr(e){if(!e.aiAgentDeploymentId)throw Error(`aiAgentDeploymentId is required`);return{headers(){let t={"x-ai-agent-deployment-id":e.aiAgentDeploymentId};return e.publicKey&&(t[e.publicKeyHeader??`x-public-key`]=e.publicKey),t}}}const Mr=/* @__PURE__ */ new Set([`home`,`chats`,`help`,`news`]);function Nr(e){return typeof e!=`object`||!e||!(`to`in e)||typeof e.to!=`string`||!Mr.has(e.to)?!1:!(`id`in e)||e.id===void 0||typeof e.id==`string`}function Pr(e){let[t=``,...n]=e.trim().split(`/`);if(t===``||t===`open`)return;let r=n.join(`/`);return r?{to:t,id:r}:{to:t}}function Fr(e,t){return{text:e,send:typeof t==`object`&&!!t&&`send`in t&&t.send===!0}}function Ir(e){if(typeof e!=`object`||!e||!(`text`in e)||typeof e.text!=`string`)return;let t=e.text.trim();return t?{text:t,send:`send`in e&&e.send===!0}:void 0}function Lr(e){return`${P.cssPrefix}:${e}`}function Rr(e,t,n){e.dispatchEvent(new CustomEvent(Lr(t),{detail:n}))}function zr(e,t){let n=Object.entries(t).map(([t,n])=>{let r=Lr(t);function i(e){return n(e.detail)}return e.addEventListener(r,i),[r,i]});return()=>{for(let[t,r]of n)e.removeEventListener(t,r)}}function Br(e,t){let n=[],r;for(let i of e){let e=new URLSearchParams(i);e.has(t)?r??(r=e.get(t)??``):n.push(i)}return{value:r,rest:n}}function Vr(e){let t=new URL(e),n=P.cssPrefix,r=`${P.cssPrefix}-ask`,i=t.search.slice(1).split(`&`).filter(Boolean),a=t.hash.slice(1).split(`&`).filter(Boolean),o=Br(i,n),s=Br(o.rest,r),c=Br(a,n),l=Br(c.rest,r),u=o.value??c.value,d=(s.value??l.value)?.trim()||void 0;if(u!==void 0||d!==void 0)return t.search=s.rest.join(`&`),t.hash=l.rest.join(`&`),{target:u===void 0?void 0:Pr(u),...d?{ask:d}:{},url:t.toString()}}const Hr=I.scope(`feedback:audio`);var Ur=class{constructor(){s(this,`ctx`,null),s(this,`master`,null),s(this,`buffers`,/* @__PURE__ */ new Map)}unlock(){if(this.ctx){this.ctx.state===`suspended`&&this.ctx.resume();return}let e=globalThis.AudioContext??globalThis.webkitAudioContext;if(e)try{this.ctx=new e,this.master=this.ctx.createGain(),this.master.gain.value=1,this.master.connect(this.ctx.destination)}catch(e){Hr.warn(`AudioContext init failed`,{err:e})}}setVolume(e){if(!this.master||!this.ctx)return;let t=Math.max(0,Math.min(1,e));this.master.gain.setTargetAtTime(t,this.ctx.currentTime,.01)}playTone(e){let t=this.ctx,n=this.master;if(!t||!n||t.state!==`running`)return;let r=t.currentTime,i=e.noteMs/1e3;e.notes.forEach((a,o)=>{let s=t.createOscillator();s.type=e.type,s.frequency.value=a;let c=t.createGain(),l=r+o*i;c.gain.setValueAtTime(1e-4,l),c.gain.exponentialRampToValueAtTime(e.peakGain,l+.005),c.gain.exponentialRampToValueAtTime(1e-4,l+i),s.connect(c).connect(n),s.start(l),s.stop(l+i+.01)})}async playUrl(e){let t=this.ctx,n=this.master;if(!t||!n||t.state!==`running`)return;let r=await this.getBuffer(e);if(!r)return;let i=t.createBufferSource();i.buffer=r,i.connect(n),i.start()}destroy(){this.ctx&&this.ctx.close().catch(()=>void 0),this.ctx=null,this.master=null,this.buffers.clear()}async getBuffer(e){if(!this.ctx)return null;let t=this.buffers.get(e);if(t)return t instanceof Promise,t;let n=this.ctx,r=fetch(e).then(e=>e.ok?e.arrayBuffer():Promise.reject(/* @__PURE__ */ Error(`fetch ${e.status}`))).then(e=>n.decodeAudioData(e)).then(t=>(this.buffers.set(e,t),t)).catch(t=>(Hr.warn(`audio fetch/decode failed`,{url:e,err:t}),this.buffers.delete(e),null));return this.buffers.set(e,r),r}};const Wr={messageReceived:10,messageSent:0,error:[20,40,20],voiceStart:10,voiceStop:0},Gr={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}};let Kr=null,qr=0;function Jr(){return typeof navigator<`u`&&typeof navigator.vibrate==`function`}function Yr(){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=`__${P.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 Xr(e){if(!(e===0||Array.isArray(e)&&e.every(e=>e===0))){if(Jr())try{navigator.vibrate(e);return}catch{}if(Kr??(Kr=Yr()),Kr)try{Kr.label.click()}catch{}}}function Zr(){qr++;let e=!1;return()=>{e||(e=!0,qr=Math.max(0,qr-1),qr===0&&Kr&&(Kr.input.remove(),Kr.label.remove(),Kr=null))}}const Qr=I.scope(`feedback`);var $r=class{constructor(e,t){s(this,`mutedSig`,H(!1)),s(this,`audio`,new Ur),s(this,`releaseHaptics`,void 0),s(this,`sound`,void 0),s(this,`haptics`,void 0),s(this,`lastPlayed`,/* @__PURE__ */ new Map),s(this,`reducedMotionMq`,null),this.sound=e,this.haptics=t,this.releaseHaptics=Zr(),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(e,t){this.sound=e,this.haptics=t,this.audio.setVolume(this.effectiveVolume())}setMuted(e){this.mutedSig.value!==e&&(this.mutedSig.value=e)}toggleMuted(){this.mutedSig.value=!this.mutedSig.value}play(e){this.mutedSig.value||this.isDeduped(e)||(this.lastPlayed.set(e,performance.now()),this.sound.enabled&&this.playSound(e),this.haptics.enabled&&this.isTouchDevice()&&this.playHaptic(e))}destroy(){this.audio.destroy(),this.releaseHaptics()}isDeduped(e){let t=this.lastPlayed.get(e);return t!==void 0&&performance.now()-t<100}playSound(e){let t=this.sound.events?.[e];if(t===!1)return;if(typeof t==`string`){this.audio.playUrl(t).catch(e=>Qr.warn(`audio play failed`,{err:e,url:t}));return}let n=Gr[e];n&&this.audio.playTone(n)}playHaptic(e){if(this.reducedMotionMq?.matches)return;let t=this.haptics.events?.[e];t!==!1&&Xr(t===!0||t===void 0?Wr[e]:t)}effectiveVolume(){let e=this.sound.volume??.3;return this.reducedMotionMq?.matches?e*.5:e}isTouchDevice(){return typeof window>`u`?!1:matchMedia(`(hover: none) and (pointer: coarse)`).matches}};function ei(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function ti(e){return ei(e)}function ni(e){return!(!ei(e)||e.navigation!==void 0&&!Array.isArray(e.navigation)||e.linkCards!==void 0&&!Array.isArray(e.linkCards))}var ri=0;Array.isArray;function U(e,t,n,r,i,a){t||(t={});var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ri,__i:-1,__u:0};return(i||a)&&(l.__source=i,l.__self=a),u.vnode&&u.vnode(l),l}function ii(e){switch(e){case 1:return`href`;case 2:return`src`;case 4:return`class`;case 8:return`checked`;case 16:return`start`}}const ai=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}};function oi(e){let t=/* @__PURE__ */ new Uint32Array(24);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:/* @__PURE__ */ new Uint8Array(24),indent:``,indent_len:0,table_state:0}}function si(e){e.pending.length>0&&vi(e,`
12
- `)}function W(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 ci(e){console.assert(e.len>0,`No nodes to end`),--e.len,e.token=e.tokens[e.len],e.renderer.end_token(e.renderer.data)}function G(e,t){(e.tokens[e.len]===24||e.tokens[e.len]===23)&&t!==25&&ci(e),e.len+=1,e.tokens[e.len]=t,e.token=t,e.renderer.add_token(e.renderer.data,t)}function li(e,t,n){for(;n<=e.len;){if(e.tokens[n]===t)return n;n+=1}return-1}function ui(e,t){for(e.fence_start=0;e.len>t;)ci(e)}function di(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}for(;e.len>n;)ci(e);return t}function fi(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?(ui(e,e.blockquote_idx),G(e,t),!0):(ui(e,n),!1):(ui(e,r),G(e,t),!0)}function pi(e,t){G(e,25),e.spaces[e.len]=e.indent_len+t,mi(e),e.token=103}function mi(e){e.indent=``,e.indent_len=0,e.pending=``}function hi(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 gi(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 _i(e){return hi(e)||gi(e)}function vi(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 t=di(e,e.indent_len);e.indent_len=0,e.token=e.tokens[e.len],t>0&&vi(e,` `.repeat(t))}let t=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
- `:if(console.assert(e.pending.length===1),e.tokens[e.len]===25&&e.token===21){ci(e),mi(e),e.pending=n;continue}ui(e,e.blockquote_idx),mi(e),e.blockquote_idx=0,e.fence_start=0,e.pending=n;continue;case`#`:switch(n){case`#`:if(e.pending.length<6){e.pending=t;continue}break;case` `:di(e,e.indent_len),G(e,ai(e.pending.length)),mi(e);continue}break;case`>`:{let t=li(e,20,e.blockquote_idx+1);t===-1?(ui(e,e.blockquote_idx),e.blockquote_idx+=1,e.fence_start=0,G(e,20)):e.blockquote_idx=t,mi(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=t;continue;case` `:e.pending=t;continue;case`
14
- `:if(e.hr_chars<3)break;di(e,e.indent_len),e.renderer.add_token(e.renderer.data,22),e.renderer.end_token(e.renderer.data),mi(e),e.hr_chars=0;continue}e.hr_chars=0}if(e.pending[0]!==`_`&&e.pending[1]===` `){fi(e,23),pi(e,2),vi(e,t.slice(2));continue}break;case"`":if(e.pending.length<3){if(n==="`"){e.pending=t,e.fence_start=t.length;continue}e.fence_start=0;break}switch(n){case"`":e.pending.length===e.fence_start?(e.pending=t,e.fence_start=t.length):(G(e,2),mi(e),e.fence_start=0,vi(e,t));continue;case`
15
- `:di(e,e.indent_len),G(e,10),e.pending.length>e.fence_start&&e.renderer.set_attr(e.renderer.data,4,e.pending.slice(e.fence_start)),mi(e),e.token=101;continue;default:e.pending=t;continue}case`+`:if(n!==` `)break;fi(e,23),pi(e,2);continue;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:if(e.pending[e.pending.length-1]===`.`){if(n!==` `)break;fi(e,24)&&e.pending!==`1.`&&e.renderer.set_attr(e.renderer.data,16,e.pending.slice(0,-1)),pi(e,e.pending.length+1);continue}{let r=n.charCodeAt(0);if(r===46||hi(r)){e.pending=t;continue}}break;case`|`:ui(e,e.blockquote_idx),G(e,27),G(e,28),e.pending=``,vi(e,n);continue}let r=t;if(e.token===21)e.token=e.tokens[e.len],e.renderer.add_token(e.renderer.data,21),e.renderer.end_token(e.renderer.data);else if(e.indent_len>=4){let n=0;for(;n<4;n+=1)if(e.indent[n]===` `){n+=1;break}r=e.indent.slice(n)+t,G(e,9)}else G(e,2);mi(e),vi(e,r);continue;case 27:if(e.table_state===1)switch(n){case`-`:case` `:case`|`:case`:`:e.pending=t;continue;case`
16
- `:e.table_state=2,e.pending=``;continue;default:ci(e),e.table_state=0}else switch(e.pending){case`|`:G(e,28),e.pending=``,vi(e,n);continue;case`
17
- `:ci(e),e.pending=``,e.table_state=0,vi(e,n);continue}break;case 28:switch(e.pending){case``:break;case`|`:G(e,29),ci(e),e.pending=``,vi(e,n);continue;case`
18
- `:ci(e),e.table_state=Math.min(e.table_state+1,2),e.pending=``,vi(e,n);continue;default:G(e,29),vi(e,n);continue}break;case 29:if(e.pending===`|`){W(e),ci(e),e.pending=``,vi(e,n);continue}break;case 9:switch(t){case`
11
+ `.replace(/__P__/g,`helpai`).replaceAll(`__BRAND_ACCENT_TEXT__`,`#FFFFFF`).replaceAll(`__BRAND_ACCENT__`,`#5B5BD6`).replaceAll(`__BRAND_RADIUS__`,`12px`).replaceAll(`__BRAND_FONT__`,`Inter, system-ui, -apple-system, 'Segoe UI', sans-serif`),Yn=[`data-theme`,`data-color-scheme`,`data-mode`,`data-bs-theme`];function Xn(e){if(e){if(e.classList.contains(`dark`))return`dark`;if(e.classList.contains(`light`))return`light`;for(let t of Yn){let n=e.getAttribute(t);if(n===`dark`||n===`light`)return n}}}function Zn(e=document){let t=Xn(e.documentElement)??Xn(e.body);if(t)return t;let n=getComputedStyle(e.documentElement).colorScheme.trim();return n===`dark`||n===`light`?n:typeof matchMedia==`function`&&matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function Qn(e,t=document){let n=Zn(t);e(n);function r(){let r=Zn(t);r!==n&&(n=r,e(r))}let i=new MutationObserver(r),a={attributes:!0,attributeFilter:[`class`,`style`,...Yn]};i.observe(t.documentElement,a),t.body&&i.observe(t.body,a);let o=typeof matchMedia==`function`?matchMedia(`(prefers-color-scheme: dark)`):void 0;return o?.addEventListener(`change`,r),()=>{i.disconnect(),o?.removeEventListener(`change`,r)}}const $n=C.scope(`mount`),er=/* @__PURE__ */ new WeakMap,tr={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 nr(e,t){e.style.cssText=tr[t]}function rr(e){return e===`floating`||e===`modal`||e===`drawer`?`floating`:e===`standalone`||e===`page`?`viewport`:`flow`}function ir(e={}){let t=e.position??`flow`;$n.debug(`createShadowMount`,{position:t,hasTarget:!!e.target,hasHost:!!e.existingHost});let n=`${u.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`,u.id),r.style.cssText=tr[t];let i=r.shadowRoot??r.attachShadow({mode:`open`}),a=r.ownerDocument;if(!ar(i,a)){let e=a.createElement(`style`);e.textContent=Jn,i.appendChild(e)}let o=document.createElement(`div`);return o.className=`${u.cssPrefix}-app`,i.appendChild(o),{appRoot:o,destroy:()=>r.remove(),hostElement:r,shadowRoot:i}}function ar(e,t){if(!(`adoptedStyleSheets`in e))return!1;let n=t.defaultView;if(!n||typeof n.CSSStyleSheet!=`function`)return!1;let r=er.get(t);if(!r)try{r=new n.CSSStyleSheet,r.replaceSync(Jn),er.set(t,r)}catch{return!1}try{return e.adoptedStyleSheets=[r],!0}catch{return!1}}function or(e,t){let n=u.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),t.contentMaxWidth&&e.style.setProperty(`--${n}-conversation-max`,t.contentMaxWidth)}function sr(e,t){e.dataset.theme=t===`host`?Zn():t}function cr(e,t){let n=u.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 lr(e,t){e.dataset.position=t}function ur(e,t){e.dataset.mode=t}function dr(e,t){sr(e,t.themeMode),or(e,t.themeOverrides),lr(e,t.position),cr(e,t.size)}var fr,pr,mr,hr,gr=Object.is,_r=0,vr=[],yr=[],br=P,xr=br.__b,Sr=br.__r,Cr=br.diffed,wr=br.__c,Tr=br.unmount,Er=br.__;function Dr(e,t){br.__h&&br.__h(pr,e,_r||t),_r=0;var n=pr.__H||(pr.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function I(e){return _r=1,Or(Lr,e)}function Or(e,t,n){var r=Dr(fr++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Lr(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);gr(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=pr,!pr.__f)){pr.__f=!0;var i=pr.shouldComponentUpdate;pr.shouldComponentUpdate=function(e,t,n){var r=this.__H;if(!r)return!0;var a=!1,o=this.props!=e;if(r.__.some(function(e){e.__N&&(a=!0,gr(e.__[0],e.__N[0])||(o=!0))}),i){var s=i.call(this,e,t,n);return a?s||o:s}return!a||o}}return r.__}function L(e,t){var n=Dr(fr++,3);!br.__s&&Ir(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,pr.__H.__h.push(n))}function kr(e,t){var n=Dr(fr++,4);!br.__s&&Ir(n.__H,t)&&(n.__P=!1,n.__=e,n.u=t,pr.__h.push(n))}function R(e){return _r=5,z(function(){return{current:e}},[])}function z(e,t){var n=Dr(fr++,7);return Ir(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function B(e,t){return _r=8,z(function(){return e},t)}function Ar(){var e;do{for(;e=yr.shift();)try{Pr(e)}catch(t){br.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=vr.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Pr),t.__h.some(Fr),t.__h=[]}catch(n){t.__h=[],br.__e(n,e.__v)}}}while(yr.length)}br.__b=function(e){pr=null,xr&&xr(e)},br.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Er&&Er(e,t)},br.__r=function(e){Sr&&Sr(e),fr=0;var t=(pr=e.__c).__H;t&&(mr==pr?pr.__h=[]:(t.__h.some(Pr),t.__h.some(Fr),fr=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),mr=pr},br.diffed=function(e){Cr&&Cr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&Nr(vr.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),mr=pr=null},br.__c=function(e,t){t.some(function(e){try{e.__h.some(Pr),e.__h=e.__h.filter(function(e){return!e.__||Fr(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],br.__e(n,e.__v)}}),wr&&wr(e,t)},br.unmount=function(e){Tr&&Tr(e);var t,n,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n=n&&n.__c}r.__P=n,Nr(yr.push(r))}else Pr(r)}catch(e){t=e}}),r.__H=void 0,t&&br.__e(t,r.__v))};var jr=typeof requestAnimationFrame==`function`;function Mr(e){var t,n=function(){clearTimeout(r),jr&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);jr&&(t=requestAnimationFrame(n))}function Nr(e){e!=1&&hr==br.requestAnimationFrame||((hr=br.requestAnimationFrame)||Mr)(Ar)}function Pr(e){var t=pr,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),pr=t}function Fr(e){var t=pr;e.__c=e.__(),pr=t}function Ir(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!gr(t,e[n])})}function Lr(e,t){return typeof t==`function`?t(e):t}var Rr=Symbol.for(`preact-signals`);function zr(){if(Gr>1)Gr--;else{var e,t=!1;for((function(){var e=Yr;for(Yr=void 0;e!==void 0;){var t=e.S;if(t.v===e.v)for(var n=t.t;n!==void 0;n=n.x)n.i===e.i&&(n.i=t.i);e=e.o}})();Wr!==void 0;){var n=Wr;for(Wr=void 0,Kr++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&$r(n))try{n.c()}catch(n){t||(e=n,t=!0)}n=r}}if(Kr=0,Gr--,t)throw e}}function Br(e){if(Gr>0)return e();Jr=++qr,Gr++;try{return e()}finally{zr()}}var Vr,Hr=void 0;function Ur(e){var t=Hr,n=Vr;Hr=void 0,Vr=void 0;try{return e()}finally{Hr=t,Vr=n}}var Wr=void 0,Gr=0,Kr=0,qr=0,Jr=0,Yr=void 0,Xr=0;function Zr(e){if(Hr!==void 0){var t=e.n;if(t===void 0||t.t!==Hr)return t={i:0,S:e,p:Hr.s,n:void 0,t:Hr,e:void 0,x:void 0,r:t},Hr.s!==void 0&&(Hr.s.n=t),Hr.s=t,e.n=t,32&Hr.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=Hr.s,t.n=void 0,Hr.s.n=t,Hr.s=t),t}}function Qr(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}Qr.prototype.brand=Rr,Qr.prototype.h=function(){return!0},Qr.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?Ur(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},Qr.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&&Ur(function(){var e;(e=t.Z)==null||e.call(t)}))}},Qr.prototype.subscribe=function(e){var t=this;return si(function(){var n=t.value;Ur(function(){return e(n)})},{name:`sub`})},Qr.prototype.valueOf=function(){return this.value},Qr.prototype.toString=function(){return this.value+``},Qr.prototype.toJSON=function(){return this.value},Qr.prototype.peek=function(){var e=this;return Ur(function(){return e.value})},Object.defineProperty(Qr.prototype,"value",{get:function(){var e=Zr(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Kr>100)throw Error(`Cycle detected`);(function(e){Gr!==0&&Kr===0&&e.l!==Jr&&(e.l=Jr,Yr={S:e,v:e.v,i:e.i,o:Yr})})(this),this.v=e,this.i++,Xr++,Gr++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{zr()}}}});function V(e,t){return new Qr(e,t)}function $r(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 ei(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 ti(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 ni(e,t){Qr.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Xr-1,this.f=4}ni.prototype=new Qr,ni.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Xr))return!0;if(this.g=Xr,this.f|=1,this.i>0&&!$r(this))return this.f&=-2,!0;var e=Hr;try{ei(this),Hr=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return Hr=e,ti(this),this.f&=-2,!0},ni.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)}Qr.prototype.S.call(this,e)},ni.prototype.U=function(e){if(this.t!==void 0&&(Qr.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)}},ni.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(ni.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=Zr(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function H(e,t){return new ni(e,t)}function ri(e){var t=e.m;if(e.m=void 0,typeof t==`function`){Gr++;var n=Hr;Hr=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,ii(e),t}finally{Hr=n,zr()}}}function ii(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,ri(e)}function ai(e){if(Hr!==this)throw Error(`Out-of-order effect`);ti(this),Hr=e,this.f&=-2,8&this.f&&ii(this),zr()}function oi(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Vr&&Vr.push(this)}oi.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()}},oi.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,ri(this),ei(this),Gr++;var e=Hr;return Hr=this,ai.bind(this,e)},oi.prototype.N=function(){2&this.f||(this.f|=2,this.u=Wr,Wr=this)},oi.prototype.d=function(){this.f|=8,1&this.f||ii(this)},oi.prototype.dispose=function(){this.d()};function si(e,t){var n=new oi(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var ci,li,ui,di=typeof window<`u`&&!!window.__PREACT_SIGNALS_DEVTOOLS__,fi=[];si(function(){ci=this.N})();function pi(e,t){P[e]=t.bind(null,P[e]||function(){})}function mi(e){if(ui){var t=ui;ui=void 0,t()}ui=e&&e.S()}function hi(e){var t=this,n=e.data,r=_i(n);r.name=`ReactiveDom`,r.value=n;var i=z(function(){for(var e=t,n=t.__v;n=n.__;)if(n.__c){n.__c.__$f|=4;break}var i=H(function(){var e=r.value.value;return e===0?0:!0===e?``:e||``}),a=H(function(){return!Array.isArray(i.value)&&!Pe(i.value)}),o=si(function(){if(this.N=xi,a.value){var t=i.value;e.__v&&e.__v.__e&&e.__v.__e.nodeType===3&&(e.__v.__e.data=t)}}),s=t.__$u.d;return t.__$u.d=function(){o(),s.call(this)},[a,i]},[]),a=i[0],o=i[1];return a.value?o.peek():o.value}hi.displayName=`ReactiveTextNode`,Object.defineProperties(Qr.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:hi},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}}),pi(`__b`,function(e,t){if(mi(),li=void 0,typeof t.type==`string`){var n,r=t.props;for(var i in r)if(i!==`children`){var a=r[i];a instanceof Qr&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)}),pi(`__r`,function(e,t){if(e(t),t.type!==Ze){mi();var n,r=t.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=function(e,t){var n;return si(function(){n=this},{name:t}),n.c=e,n}(function(e){return function(){var t;di&&((t=this.y)==null||t.call(this)),e.__$f|=1,e.setState({})}}(r),typeof t.type==`function`?t.type.displayName||t.type.name:``))),li=r,mi(n)}}),pi(`__e`,function(e,t,n,r){mi(),li=void 0,e(t,n,r)}),pi(`diffed`,function(e,t){mi(),li=void 0;var n;if(typeof t.type==`string`&&(n=t.__e)){var r=t.__np,i=t.props,a=n.U;if(a)for(var o in a){var s=a[o];s===void 0||r&&o in r||(s.d(),a[o]=void 0)}if(r)for(var c in a||(a={},n.U=a),r){var l=a[c],u=r[c];l===void 0?(l=gi(n,c,u,i),a[c]=l):l.o(u,i)}}e(t)});function gi(e,t,n,r){var i=t in e&&e.ownerSVGElement===void 0,a=V(n);return{o:function(e,t){a.value=e,r=t},d:si(function(){this.N=xi;var n=a.value.value;r[t]!==n&&(r[t]=n,i?e[t]=n:n!=null&&(!1!==n||t[4]===`-`)?e.setAttribute(t,n):e.removeAttribute(t))})}}pi(`unmount`,function(e,t){if(typeof t.type==`string`){var n=t.__e;if(n){var r=n.U;if(r)for(var i in n.U=void 0,r){var a=r[i];a&&a.d()}}var o=t.__np;if(o){var s=t.props;for(var c in o)s[c]=o[c]}t.__np=void 0}else{var l=t.__c;if(l){l.__$f|=8;var u=l.__$u;u&&(l.__$u=void 0,u.d())}}e(t)}),pi(`__h`,function(e,t,n,r){r<3&&(t.__$f|=2),e(t,n,r)}),Qe.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`&&!0===this.u){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 o in e)if(o!==`__source`&&e[o]!==this.props[o])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function _i(e,t){return z(function(){return V(e,t)},[])}function vi(e,t){var n=R(e);return n.current=e,li.__$f|=4,z(function(){return H(function(){return n.current()},t)},[])}var yi=function(e){queueMicrotask(function(){queueMicrotask(e)})};function bi(){Br(function(){for(var e;e=fi.shift();)ci.call(e)})}function xi(){fi.push(this)===1&&(P.requestAnimationFrame||yi)(bi)}function Si(e){if(!e.aiAgentDeploymentId)throw Error(`aiAgentDeploymentId is required`);return{headers(){let t={"x-ai-agent-deployment-id":e.aiAgentDeploymentId};return e.publicKey&&(t[e.publicKeyHeader??`x-public-key`]=e.publicKey),t}}}const Ci=/* @__PURE__ */ new Set([`home`,`chats`,`help`,`news`]);function wi(e){return typeof e!=`object`||!e||!(`to`in e)||typeof e.to!=`string`||!Ci.has(e.to)?!1:!(`id`in e)||e.id===void 0||typeof e.id==`string`}function Ti(e){let[t=``,...n]=e.trim().split(`/`);if(t===``||t===`open`)return;let r=n.join(`/`);return r?{to:t,id:r}:{to:t}}function Ei(e,t){return{text:e,send:typeof t==`object`&&!!t&&`send`in t&&t.send===!0}}function Di(e){if(typeof e!=`object`||!e||!(`text`in e)||typeof e.text!=`string`)return;let t=e.text.trim();return t?{text:t,send:`send`in e&&e.send===!0}:void 0}function Oi(e){return`${u.cssPrefix}:${e}`}function ki(e,t,n){e.dispatchEvent(new CustomEvent(Oi(t),{detail:n}))}function Ai(e,t){let n=Object.entries(t).map(([t,n])=>{let r=Oi(t);function i(e){return n(e.detail)}return e.addEventListener(r,i),[r,i]});return()=>{for(let[t,r]of n)e.removeEventListener(t,r)}}function ji(e,t){let n=[],r;for(let i of e){let e=new URLSearchParams(i);e.has(t)?r??(r=e.get(t)??``):n.push(i)}return{value:r,rest:n}}function Mi(e){let t=new URL(e),n=u.cssPrefix,r=`${u.cssPrefix}-ask`,i=t.search.slice(1).split(`&`).filter(Boolean),a=t.hash.slice(1).split(`&`).filter(Boolean),o=ji(i,n),s=ji(o.rest,r),c=ji(a,n),l=ji(c.rest,r),d=o.value??c.value,f=(s.value??l.value)?.trim()||void 0;if(d!==void 0||f!==void 0)return t.search=s.rest.join(`&`),t.hash=l.rest.join(`&`),{target:d===void 0?void 0:Ti(d),...f?{ask:f}:{},url:t.toString()}}const Ni=C.scope(`feedback:audio`);var Pi=class{constructor(){s(this,`ctx`,null),s(this,`master`,null),s(this,`buffers`,/* @__PURE__ */ new Map)}unlock(){if(this.ctx){this.ctx.state===`suspended`&&this.ctx.resume();return}let e=globalThis.AudioContext??globalThis.webkitAudioContext;if(e)try{this.ctx=new e,this.master=this.ctx.createGain(),this.master.gain.value=1,this.master.connect(this.ctx.destination)}catch(e){Ni.warn(`AudioContext init failed`,{err:e})}}setVolume(e){if(!this.master||!this.ctx)return;let t=Math.max(0,Math.min(1,e));this.master.gain.setTargetAtTime(t,this.ctx.currentTime,.01)}playTone(e){let t=this.ctx,n=this.master;if(!t||!n||t.state!==`running`)return;let r=t.currentTime,i=e.noteMs/1e3;e.notes.forEach((a,o)=>{let s=t.createOscillator();s.type=e.type,s.frequency.value=a;let c=t.createGain(),l=r+o*i;c.gain.setValueAtTime(1e-4,l),c.gain.exponentialRampToValueAtTime(e.peakGain,l+.005),c.gain.exponentialRampToValueAtTime(1e-4,l+i),s.connect(c).connect(n),s.start(l),s.stop(l+i+.01)})}async playUrl(e){let t=this.ctx,n=this.master;if(!t||!n||t.state!==`running`)return;let r=await this.getBuffer(e);if(!r)return;let i=t.createBufferSource();i.buffer=r,i.connect(n),i.start()}destroy(){this.ctx&&this.ctx.close().catch(()=>void 0),this.ctx=null,this.master=null,this.buffers.clear()}async getBuffer(e){if(!this.ctx)return null;let t=this.buffers.get(e);if(t)return t instanceof Promise,t;let n=this.ctx,r=fetch(e).then(e=>e.ok?e.arrayBuffer():Promise.reject(/* @__PURE__ */ Error(`fetch ${e.status}`))).then(e=>n.decodeAudioData(e)).then(t=>(this.buffers.set(e,t),t)).catch(t=>(Ni.warn(`audio fetch/decode failed`,{url:e,err:t}),this.buffers.delete(e),null));return this.buffers.set(e,r),r}};const Fi={messageReceived:10,messageSent:0,error:[20,40,20],voiceStart:10,voiceStop:0},Ii={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}};let Li=null,Ri=0;function zi(){return typeof navigator<`u`&&typeof navigator.vibrate==`function`}function Bi(){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=`__${u.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 Vi(e){if(!(e===0||Array.isArray(e)&&e.every(e=>e===0))){if(zi())try{navigator.vibrate(e);return}catch{}if(Li??(Li=Bi()),Li)try{Li.label.click()}catch{}}}function Hi(){Ri++;let e=!1;return()=>{e||(e=!0,Ri=Math.max(0,Ri-1),Ri===0&&Li&&(Li.input.remove(),Li.label.remove(),Li=null))}}const Ui=C.scope(`feedback`);var Wi=class{constructor(e,t){s(this,`mutedSig`,V(!1)),s(this,`audio`,new Pi),s(this,`releaseHaptics`,void 0),s(this,`sound`,void 0),s(this,`haptics`,void 0),s(this,`lastPlayed`,/* @__PURE__ */ new Map),s(this,`reducedMotionMq`,null),this.sound=e,this.haptics=t,this.releaseHaptics=Hi(),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(e,t){this.sound=e,this.haptics=t,this.audio.setVolume(this.effectiveVolume())}setMuted(e){this.mutedSig.value!==e&&(this.mutedSig.value=e)}toggleMuted(){this.mutedSig.value=!this.mutedSig.value}play(e){this.mutedSig.value||this.isDeduped(e)||(this.lastPlayed.set(e,performance.now()),this.sound.enabled&&this.playSound(e),this.haptics.enabled&&this.isTouchDevice()&&this.playHaptic(e))}destroy(){this.audio.destroy(),this.releaseHaptics()}isDeduped(e){let t=this.lastPlayed.get(e);return t!==void 0&&performance.now()-t<100}playSound(e){let t=this.sound.events?.[e];if(t===!1)return;if(typeof t==`string`){this.audio.playUrl(t).catch(e=>Ui.warn(`audio play failed`,{err:e,url:t}));return}let n=Ii[e];n&&this.audio.playTone(n)}playHaptic(e){if(this.reducedMotionMq?.matches)return;let t=this.haptics.events?.[e];t!==!1&&Vi(t===!0||t===void 0?Fi[e]:t)}effectiveVolume(){let e=this.sound.volume??.3;return this.reducedMotionMq?.matches?e*.5:e}isTouchDevice(){return typeof window>`u`?!1:matchMedia(`(hover: none) and (pointer: coarse)`).matches}};function Gi(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Ki(e){return Gi(e)}function qi(e){return!(!Gi(e)||e.navigation!==void 0&&!Array.isArray(e.navigation)||e.linkCards!==void 0&&!Array.isArray(e.linkCards))}var Ji=0;Array.isArray;function U(e,t,n,r,i,a){t||(t={});var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ji,__i:-1,__u:0};return(i||a)&&(l.__source=i,l.__self=a),P.vnode&&P.vnode(l),l}function Yi(e){switch(e){case 1:return`href`;case 2:return`src`;case 4:return`class`;case 8:return`checked`;case 16:return`start`}}const Xi=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}};function Zi(e){let t=/* @__PURE__ */ new Uint32Array(24);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:/* @__PURE__ */ new Uint8Array(24),indent:``,indent_len:0,table_state:0}}function Qi(e){e.pending.length>0&&la(e,`
12
+ `)}function W(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 $i(e){console.assert(e.len>0,`No nodes to end`),--e.len,e.token=e.tokens[e.len],e.renderer.end_token(e.renderer.data)}function G(e,t){(e.tokens[e.len]===24||e.tokens[e.len]===23)&&t!==25&&$i(e),e.len+=1,e.tokens[e.len]=t,e.token=t,e.renderer.add_token(e.renderer.data,t)}function ea(e,t,n){for(;n<=e.len;){if(e.tokens[n]===t)return n;n+=1}return-1}function ta(e,t){for(e.fence_start=0;e.len>t;)$i(e)}function na(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}for(;e.len>n;)$i(e);return t}function ra(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?(ta(e,e.blockquote_idx),G(e,t),!0):(ta(e,n),!1):(ta(e,r),G(e,t),!0)}function ia(e,t){G(e,25),e.spaces[e.len]=e.indent_len+t,aa(e),e.token=103}function aa(e){e.indent=``,e.indent_len=0,e.pending=``}function oa(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 sa(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 ca(e){return oa(e)||sa(e)}function la(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 t=na(e,e.indent_len);e.indent_len=0,e.token=e.tokens[e.len],t>0&&la(e,` `.repeat(t))}let t=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
+ `:if(console.assert(e.pending.length===1),e.tokens[e.len]===25&&e.token===21){$i(e),aa(e),e.pending=n;continue}ta(e,e.blockquote_idx),aa(e),e.blockquote_idx=0,e.fence_start=0,e.pending=n;continue;case`#`:switch(n){case`#`:if(e.pending.length<6){e.pending=t;continue}break;case` `:na(e,e.indent_len),G(e,Xi(e.pending.length)),aa(e);continue}break;case`>`:{let t=ea(e,20,e.blockquote_idx+1);t===-1?(ta(e,e.blockquote_idx),e.blockquote_idx+=1,e.fence_start=0,G(e,20)):e.blockquote_idx=t,aa(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=t;continue;case` `:e.pending=t;continue;case`
14
+ `:if(e.hr_chars<3)break;na(e,e.indent_len),e.renderer.add_token(e.renderer.data,22),e.renderer.end_token(e.renderer.data),aa(e),e.hr_chars=0;continue}e.hr_chars=0}if(e.pending[0]!==`_`&&e.pending[1]===` `){ra(e,23),ia(e,2),la(e,t.slice(2));continue}break;case"`":if(e.pending.length<3){if(n==="`"){e.pending=t,e.fence_start=t.length;continue}e.fence_start=0;break}switch(n){case"`":e.pending.length===e.fence_start?(e.pending=t,e.fence_start=t.length):(G(e,2),aa(e),e.fence_start=0,la(e,t));continue;case`
15
+ `:na(e,e.indent_len),G(e,10),e.pending.length>e.fence_start&&e.renderer.set_attr(e.renderer.data,4,e.pending.slice(e.fence_start)),aa(e),e.token=101;continue;default:e.pending=t;continue}case`+`:if(n!==` `)break;ra(e,23),ia(e,2);continue;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:if(e.pending[e.pending.length-1]===`.`){if(n!==` `)break;ra(e,24)&&e.pending!==`1.`&&e.renderer.set_attr(e.renderer.data,16,e.pending.slice(0,-1)),ia(e,e.pending.length+1);continue}{let r=n.charCodeAt(0);if(r===46||oa(r)){e.pending=t;continue}}break;case`|`:ta(e,e.blockquote_idx),G(e,27),G(e,28),e.pending=``,la(e,n);continue}let r=t;if(e.token===21)e.token=e.tokens[e.len],e.renderer.add_token(e.renderer.data,21),e.renderer.end_token(e.renderer.data);else if(e.indent_len>=4){let n=0;for(;n<4;n+=1)if(e.indent[n]===` `){n+=1;break}r=e.indent.slice(n)+t,G(e,9)}else G(e,2);aa(e),la(e,r);continue;case 27:if(e.table_state===1)switch(n){case`-`:case` `:case`|`:case`:`:e.pending=t;continue;case`
16
+ `:e.table_state=2,e.pending=``;continue;default:$i(e),e.table_state=0}else switch(e.pending){case`|`:G(e,28),e.pending=``,la(e,n);continue;case`
17
+ `:$i(e),e.pending=``,e.table_state=0,la(e,n);continue}break;case 28:switch(e.pending){case``:break;case`|`:G(e,29),$i(e),e.pending=``,la(e,n);continue;case`
18
+ `:$i(e),e.table_state=Math.min(e.table_state+1,2),e.pending=``,la(e,n);continue;default:G(e,29),la(e,n);continue}break;case 29:if(e.pending===`|`){W(e),$i(e),e.pending=``,la(e,n);continue}break;case 9:switch(t){case`
19
19
  `:case`
20
20
  `:case`
21
21
  `:case`
@@ -25,38 +25,38 @@ import{useEffect as e,useMemo as t,useRef as n,useSyncExternalStore as r}from"re
25
25
  `:case`
26
26
  `:case`
27
27
  `:case`
28
- `:e.pending=t;continue;default:e.pending.length===0?e.text+=n:(W(e),ci(e),e.pending=n);continue}case 10:switch(n){case"`":e.pending=t;continue;case`
29
- `:if(t.length===e.fence_start+e.fence_end+1){W(e),ci(e),e.pending=``,e.fence_start=0,e.fence_end=0,e.token=101;continue}e.token=101;break;case` `:if(e.pending[0]===`
30
- `){e.pending=t,e.fence_end+=1;continue}}e.text+=e.pending,e.pending=n,e.fence_end=1;continue;case 11:switch(n){case"`":t.length===e.fence_start+Number(e.pending[0]===` `)?(W(e),ci(e),e.pending=``,e.fence_start=0):e.pending=t;continue;case`
31
- `:e.text+=e.pending,e.pending=``,e.token=21,e.blockquote_idx=0,W(e);continue;case` `:e.text+=e.pending,e.pending=n;continue;default:e.text+=t,e.pending=``;continue}case 103:switch(e.pending.length){case 0:if(n!==`[`)break;e.pending=t;continue;case 1:if(n!==` `&&n!==`x`)break;e.pending=t;continue;case 2:if(n!==`]`)break;e.pending=t;continue;case 3:if(n!==` `)break;e.renderer.add_token(e.renderer.data,26),e.pending[1]===`x`&&e.renderer.set_attr(e.renderer.data,8,``),e.renderer.end_token(e.renderer.data),e.pending=` `;continue}e.token=e.tokens[e.len],e.pending=``,vi(e,t);continue;case 14:case 15:{let t=`*`,r=12;if(e.token===15&&(t=`_`,r=13),t===e.pending){if(W(e),t===n){ci(e),e.pending=``;continue}G(e,r),e.pending=n;continue}break}case 12:case 13:{let r=`*`,i=14;switch(e.token===13&&(r=`_`,i=15),e.pending){case r:r===n?e.tokens[e.len-1]===i?e.pending=t:(W(e),G(e,i),e.pending=``):(W(e),ci(e),e.pending=n);continue;case r+r:let a=e.token;W(e),ci(e),ci(e),r===n?e.pending=``:(G(e,a),e.pending=n);continue}break}case 16:if(t===`~~`){W(e),ci(e),e.pending=``;continue}break;case 105:n===`
32
- `?(W(e),G(e,30),e.pending=``):(e.token=e.tokens[e.len],e.pending[0]===`\\`?e.text+=`[`:e.text+=`$$`,e.pending=``,vi(e,n));continue;case 30:if(t===`\\]`||t===`$$`){W(e),ci(e),e.pending=``;continue}break;case 31:if(t===`\\)`||e.pending[0]===`$`){W(e),ci(e),e.pending=n===`)`?``:n;continue}break;case 102:t===`http://`||t===`https://`?(W(e),G(e,18),e.pending=t,e.text=t):`http:/`[e.pending.length]===n||`https:/`[e.pending.length]===n?e.pending=t:(e.token=e.tokens[e.len],vi(e,n));continue;case 17:case 19:if(e.pending===`]`){W(e),n===`(`?e.pending=t:(ci(e),e.pending=n);continue}if(e.pending[0]===`]`&&e.pending[1]===`(`){if(n===`)`){let t=e.token===17?1:2,n=e.pending.slice(2);e.renderer.set_attr(e.renderer.data,t,n),ci(e),e.pending=``}else e.pending+=n;continue}break;case 18:n===` `||n===`
33
- `||n===`\\`?(e.renderer.set_attr(e.renderer.data,1,e.pending),W(e),ci(e),e.pending=n):(e.text+=n,e.pending=t);continue;case 104:if(t.startsWith(`<br`)){if(t.length===3||n===` `||n===`/`&&(t.length===4||e.pending[e.pending.length-1]===` `)){e.pending=t;continue}if(n===`>`){W(e),e.token=e.tokens[e.len],e.renderer.add_token(e.renderer.data,21),e.renderer.end_token(e.renderer.data),e.pending=``;continue}}e.token=e.tokens[e.len],e.text+=`<`,e.pending=e.pending.slice(1),vi(e,n);continue}switch(e.pending[0]){case`\\`:if(e.token===19||e.token===30||e.token===31)break;switch(n){case`(`:W(e),G(e,31),e.pending=``;continue;case`[`:e.token=105,e.pending=t;continue;case`
34
- `:e.pending=n;continue;default:let r=n.charCodeAt(0);e.pending=``,e.text+=hi(r)||r>=65&&r<=90||r>=97&&r<=122?t:n;continue}case`
35
- `:switch(e.token){case 19:case 30:case 31:break;case 3:case 4:case 5:case 6:case 7:case 8:W(e),ui(e,e.blockquote_idx),e.blockquote_idx=0,e.pending=n;continue;default:W(e),e.pending=n,e.token=21,e.blockquote_idx=0;continue}break;case`<`:if(e.token!==19&&e.token!==30&&e.token!==31){W(e),e.pending=t,e.token=104;continue}break;case"`":if(e.token===19)break;n==="`"?(e.fence_start+=1,e.pending=t):(e.fence_start+=1,W(e),G(e,11),e.text=n===` `||n===`
28
+ `:e.pending=t;continue;default:e.pending.length===0?e.text+=n:(W(e),$i(e),e.pending=n);continue}case 10:switch(n){case"`":e.pending=t;continue;case`
29
+ `:if(t.length===e.fence_start+e.fence_end+1){W(e),$i(e),e.pending=``,e.fence_start=0,e.fence_end=0,e.token=101;continue}e.token=101;break;case` `:if(e.pending[0]===`
30
+ `){e.pending=t,e.fence_end+=1;continue}}e.text+=e.pending,e.pending=n,e.fence_end=1;continue;case 11:switch(n){case"`":t.length===e.fence_start+Number(e.pending[0]===` `)?(W(e),$i(e),e.pending=``,e.fence_start=0):e.pending=t;continue;case`
31
+ `:e.text+=e.pending,e.pending=``,e.token=21,e.blockquote_idx=0,W(e);continue;case` `:e.text+=e.pending,e.pending=n;continue;default:e.text+=t,e.pending=``;continue}case 103:switch(e.pending.length){case 0:if(n!==`[`)break;e.pending=t;continue;case 1:if(n!==` `&&n!==`x`)break;e.pending=t;continue;case 2:if(n!==`]`)break;e.pending=t;continue;case 3:if(n!==` `)break;e.renderer.add_token(e.renderer.data,26),e.pending[1]===`x`&&e.renderer.set_attr(e.renderer.data,8,``),e.renderer.end_token(e.renderer.data),e.pending=` `;continue}e.token=e.tokens[e.len],e.pending=``,la(e,t);continue;case 14:case 15:{let t=`*`,r=12;if(e.token===15&&(t=`_`,r=13),t===e.pending){if(W(e),t===n){$i(e),e.pending=``;continue}G(e,r),e.pending=n;continue}break}case 12:case 13:{let r=`*`,i=14;switch(e.token===13&&(r=`_`,i=15),e.pending){case r:r===n?e.tokens[e.len-1]===i?e.pending=t:(W(e),G(e,i),e.pending=``):(W(e),$i(e),e.pending=n);continue;case r+r:let a=e.token;W(e),$i(e),$i(e),r===n?e.pending=``:(G(e,a),e.pending=n);continue}break}case 16:if(t===`~~`){W(e),$i(e),e.pending=``;continue}break;case 105:n===`
32
+ `?(W(e),G(e,30),e.pending=``):(e.token=e.tokens[e.len],e.pending[0]===`\\`?e.text+=`[`:e.text+=`$$`,e.pending=``,la(e,n));continue;case 30:if(t===`\\]`||t===`$$`){W(e),$i(e),e.pending=``;continue}break;case 31:if(t===`\\)`||e.pending[0]===`$`){W(e),$i(e),e.pending=n===`)`?``:n;continue}break;case 102:t===`http://`||t===`https://`?(W(e),G(e,18),e.pending=t,e.text=t):`http:/`[e.pending.length]===n||`https:/`[e.pending.length]===n?e.pending=t:(e.token=e.tokens[e.len],la(e,n));continue;case 17:case 19:if(e.pending===`]`){W(e),n===`(`?e.pending=t:($i(e),e.pending=n);continue}if(e.pending[0]===`]`&&e.pending[1]===`(`){if(n===`)`){let t=e.token===17?1:2,n=e.pending.slice(2);e.renderer.set_attr(e.renderer.data,t,n),$i(e),e.pending=``}else e.pending+=n;continue}break;case 18:n===` `||n===`
33
+ `||n===`\\`?(e.renderer.set_attr(e.renderer.data,1,e.pending),W(e),$i(e),e.pending=n):(e.text+=n,e.pending=t);continue;case 104:if(t.startsWith(`<br`)){if(t.length===3||n===` `||n===`/`&&(t.length===4||e.pending[e.pending.length-1]===` `)){e.pending=t;continue}if(n===`>`){W(e),e.token=e.tokens[e.len],e.renderer.add_token(e.renderer.data,21),e.renderer.end_token(e.renderer.data),e.pending=``;continue}}e.token=e.tokens[e.len],e.text+=`<`,e.pending=e.pending.slice(1),la(e,n);continue}switch(e.pending[0]){case`\\`:if(e.token===19||e.token===30||e.token===31)break;switch(n){case`(`:W(e),G(e,31),e.pending=``;continue;case`[`:e.token=105,e.pending=t;continue;case`
34
+ `:e.pending=n;continue;default:let r=n.charCodeAt(0);e.pending=``,e.text+=oa(r)||r>=65&&r<=90||r>=97&&r<=122?t:n;continue}case`
35
+ `:switch(e.token){case 19:case 30:case 31:break;case 3:case 4:case 5:case 6:case 7:case 8:W(e),ta(e,e.blockquote_idx),e.blockquote_idx=0,e.pending=n;continue;default:W(e),e.pending=n,e.token=21,e.blockquote_idx=0;continue}break;case`<`:if(e.token!==19&&e.token!==30&&e.token!==31){W(e),e.pending=t,e.token=104;continue}break;case"`":if(e.token===19)break;n==="`"?(e.fence_start+=1,e.pending=t):(e.fence_start+=1,W(e),G(e,11),e.text=n===` `||n===`
36
36
  `?``:n,e.pending=``);continue;case`_`:case`*`:{if(e.token===19||e.token===30||e.token===31||e.token===14)break;let r=12,i=14,a=e.pending[0];if(a===`_`&&(r=13,i=15),e.pending.length===1){if(a===n){e.pending=t;continue}if(n!==` `&&n!==`
37
37
  `){W(e),G(e,r),e.pending=n;continue}}else{if(a===n){W(e),G(e,i),G(e,r),e.pending=``;continue}if(n!==` `&&n!==`
38
38
  `){W(e),G(e,i),e.pending=n;continue}}break}case`~`:if(e.token!==19&&e.token!==16){if(e.pending===`~`){if(n===`~`){e.pending=t;continue}}else if(n!==` `&&n!==`
39
- `){W(e),G(e,16),e.pending=n;continue}}break;case`$`:if(e.token!==19&&e.token!==16&&e.pending===`$`){if(n===`$`){e.token=105,e.pending=t;continue}if(_i(n.charCodeAt(0)))break;W(e),G(e,31),e.pending=n;continue}break;case`[`:if(e.token!==19&&e.token!==17&&e.token!==30&&e.token!==31&&n!==`]`){W(e),G(e,17),e.pending=n;continue}break;case`!`:if(e.token!==19&&n===`[`){W(e),G(e,19),e.pending=``;continue}break;case` `:if(e.pending.length===1&&n===` `)continue}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):(e.text+=e.pending,e.pending=n)}W(e)}function yi(e){return{add_token:bi,end_token:xi,add_text:Si,set_attr:Ci,data:{nodes:[e,,,,,],index:0}}}function bi(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 e=r=document.createElement(`input`);e.type=`checkbox`,e.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`)}e.nodes[++e.index]=n.appendChild(r)}function xi(e){--e.index}function Si(e,t){e.nodes[e.index].appendChild(document.createTextNode(t))}function Ci(e,t,n){e.nodes[e.index].setAttribute(ii(t),n)}const wi={root:`Root`,schema:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{Root:{$ref:`#/$defs/Root`},Grid:{$ref:`#/$defs/Grid`},Cell:{$ref:`#/$defs/Cell`},Text:{$ref:`#/$defs/Text`},Card:{$ref:`#/$defs/Card`},Metric:{$ref:`#/$defs/Metric`},Table:{$ref:`#/$defs/Table`},Chart:{$ref:`#/$defs/Chart`}},required:[`Root`,`Grid`,`Cell`,`Text`,`Card`,`Metric`,`Table`,`Chart`],additionalProperties:!1,$defs:{Root:{type:`object`,properties:{children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Grid`},{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`}]}}},required:[`children`],additionalProperties:!1},Grid:{type:`object`,properties:{columns:{type:`integer`,enum:[1,2,3,4],default:1},children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Cell`},{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`}]}}},required:[`columns`,`children`],additionalProperties:!1},Cell:{type:`object`,properties:{children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`}]}},span:{type:`integer`,enum:[1,2,3,4],default:1}},required:[`children`],additionalProperties:!1},Text:{type:`object`,properties:{text:{type:`string`}},required:[`text`],additionalProperties:!1},Card:{type:`object`,properties:{title:{type:`string`},body:{type:`string`}},required:[`title`,`body`],additionalProperties:!1},Metric:{type:`object`,properties:{label:{type:`string`},value:{type:`string`},detail:{type:`string`}},required:[`label`,`value`,`detail`],additionalProperties:!1},Table:{type:`object`,properties:{title:{type:`string`},columns:{type:`array`,items:{type:`string`}},rows:{type:`array`,items:{type:`array`,items:{type:`string`}}}},required:[`title`,`columns`,`rows`],additionalProperties:!1},Chart:{type:`object`,properties:{title:{type:`string`},type:{type:`string`,enum:[`bar`,`line`]},data:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},value:{type:`number`}},required:[`label`,`value`],additionalProperties:!1}}},required:[`title`,`type`,`data`],additionalProperties:!1}}}},Ti=Fi,Ei={type:`object`,properties:{typeName:{const:`Grid`},statementId:{type:`string`},props:{type:`object`,properties:{columns:{type:`integer`,enum:[1,2,3,4],default:1},children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Cell`},{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`}]}}},required:[`columns`,`children`],additionalProperties:!1}},required:[`typeName`,`statementId`,`props`]},Di={type:`object`,properties:{typeName:{const:`Cell`},statementId:{type:`string`},props:{type:`object`,properties:{children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`}]}},span:{type:`integer`,enum:[1,2,3,4],default:1}},required:[`children`],additionalProperties:!1}},required:[`typeName`,`statementId`,`props`]};function Oi(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e,dynamicAnchors:a={}}={}){let o=Oi.evaluated;if(o.dynamicProps&&(o.props=void 0),o.dynamicItems&&(o.items=void 0),e&&typeof e==`object`&&!Array.isArray(e)){let n;if(e.typeName===void 0&&(n=`typeName`)||e.statementId===void 0&&(n=`statementId`)||e.props===void 0&&(n=`props`))return Oi.errors=[{instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:n}}],!1;if(e.typeName!==void 0){if(e.typeName!==`Text`)return Oi.errors=[{instancePath:t+`/typeName`,schemaPath:`#/properties/typeName/const`,keyword:`const`,params:{allowedValue:`Text`}}],!1;var s=!0}else var s=!0;if(s){if(e.statementId!==void 0){if(typeof e.statementId!=`string`)return Oi.errors=[{instancePath:t+`/statementId`,schemaPath:`#/properties/statementId/type`,keyword:`type`,params:{type:`string`}}],!1;var s=!0}else var s=!0;if(s){if(e.props!==void 0){let n=e.props;if(n&&typeof n==`object`&&!Array.isArray(n)){let e;if(n.text===void 0&&(e=`text`))return Oi.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/required`,keyword:`required`,params:{missingProperty:e}}],!1;for(let e in n)if(e!==`text`)return Oi.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e}}],!1;if(n.text!==void 0&&typeof n.text!=`string`)return Oi.errors=[{instancePath:t+`/props/text`,schemaPath:`#/properties/props/properties/text/type`,keyword:`type`,params:{type:`string`}}],!1}else return Oi.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/type`,keyword:`type`,params:{type:`object`}}],!1;var s=!0}else var s=!0}}}else return Oi.errors=[{instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`}}],!1;return Oi.errors=null,!0}Oi.evaluated={props:{typeName:!0,statementId:!0,props:!0},dynamicProps:!1,dynamicItems:!1};function ki(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e,dynamicAnchors:a={}}={}){let o=ki.evaluated;if(o.dynamicProps&&(o.props=void 0),o.dynamicItems&&(o.items=void 0),e&&typeof e==`object`&&!Array.isArray(e)){let n;if(e.typeName===void 0&&(n=`typeName`)||e.statementId===void 0&&(n=`statementId`)||e.props===void 0&&(n=`props`))return ki.errors=[{instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:n}}],!1;if(e.typeName!==void 0){if(e.typeName!==`Card`)return ki.errors=[{instancePath:t+`/typeName`,schemaPath:`#/properties/typeName/const`,keyword:`const`,params:{allowedValue:`Card`}}],!1;var s=!0}else var s=!0;if(s){if(e.statementId!==void 0){if(typeof e.statementId!=`string`)return ki.errors=[{instancePath:t+`/statementId`,schemaPath:`#/properties/statementId/type`,keyword:`type`,params:{type:`string`}}],!1;var s=!0}else var s=!0;if(s){if(e.props!==void 0){let n=e.props;if(n&&typeof n==`object`&&!Array.isArray(n)){let e;if(n.title===void 0&&(e=`title`)||n.body===void 0&&(e=`body`))return ki.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/required`,keyword:`required`,params:{missingProperty:e}}],!1;for(let e in n)if(e!==`title`&&e!==`body`)return ki.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e}}],!1;if(n.title!==void 0){if(typeof n.title!=`string`)return ki.errors=[{instancePath:t+`/props/title`,schemaPath:`#/properties/props/properties/title/type`,keyword:`type`,params:{type:`string`}}],!1;var c=!0}else var c=!0;if(c){if(n.body!==void 0){if(typeof n.body!=`string`)return ki.errors=[{instancePath:t+`/props/body`,schemaPath:`#/properties/props/properties/body/type`,keyword:`type`,params:{type:`string`}}],!1;var c=!0}else var c=!0}}else return ki.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/type`,keyword:`type`,params:{type:`object`}}],!1;var s=!0}else var s=!0}}}else return ki.errors=[{instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`}}],!1;return ki.errors=null,!0}ki.evaluated={props:{typeName:!0,statementId:!0,props:!0},dynamicProps:!1,dynamicItems:!1};function Ai(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e,dynamicAnchors:a={}}={}){let o=Ai.evaluated;if(o.dynamicProps&&(o.props=void 0),o.dynamicItems&&(o.items=void 0),e&&typeof e==`object`&&!Array.isArray(e)){let n;if(e.typeName===void 0&&(n=`typeName`)||e.statementId===void 0&&(n=`statementId`)||e.props===void 0&&(n=`props`))return Ai.errors=[{instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:n}}],!1;if(e.typeName!==void 0){if(e.typeName!==`Metric`)return Ai.errors=[{instancePath:t+`/typeName`,schemaPath:`#/properties/typeName/const`,keyword:`const`,params:{allowedValue:`Metric`}}],!1;var s=!0}else var s=!0;if(s){if(e.statementId!==void 0){if(typeof e.statementId!=`string`)return Ai.errors=[{instancePath:t+`/statementId`,schemaPath:`#/properties/statementId/type`,keyword:`type`,params:{type:`string`}}],!1;var s=!0}else var s=!0;if(s){if(e.props!==void 0){let n=e.props;if(n&&typeof n==`object`&&!Array.isArray(n)){let e;if(n.label===void 0&&(e=`label`)||n.value===void 0&&(e=`value`)||n.detail===void 0&&(e=`detail`))return Ai.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/required`,keyword:`required`,params:{missingProperty:e}}],!1;for(let e in n)if(e!==`label`&&e!==`value`&&e!==`detail`)return Ai.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e}}],!1;if(n.label!==void 0){if(typeof n.label!=`string`)return Ai.errors=[{instancePath:t+`/props/label`,schemaPath:`#/properties/props/properties/label/type`,keyword:`type`,params:{type:`string`}}],!1;var c=!0}else var c=!0;if(c){if(n.value!==void 0){if(typeof n.value!=`string`)return Ai.errors=[{instancePath:t+`/props/value`,schemaPath:`#/properties/props/properties/value/type`,keyword:`type`,params:{type:`string`}}],!1;var c=!0}else var c=!0;if(c){if(n.detail!==void 0){if(typeof n.detail!=`string`)return Ai.errors=[{instancePath:t+`/props/detail`,schemaPath:`#/properties/props/properties/detail/type`,keyword:`type`,params:{type:`string`}}],!1;var c=!0}else var c=!0}}}else return Ai.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/type`,keyword:`type`,params:{type:`object`}}],!1;var s=!0}else var s=!0}}}else return Ai.errors=[{instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`}}],!1;return Ai.errors=null,!0}Ai.evaluated={props:{typeName:!0,statementId:!0,props:!0},dynamicProps:!1,dynamicItems:!1};function ji(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e,dynamicAnchors:a={}}={}){let o=ji.evaluated;if(o.dynamicProps&&(o.props=void 0),o.dynamicItems&&(o.items=void 0),e&&typeof e==`object`&&!Array.isArray(e)){let n;if(e.typeName===void 0&&(n=`typeName`)||e.statementId===void 0&&(n=`statementId`)||e.props===void 0&&(n=`props`))return ji.errors=[{instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:n}}],!1;if(e.typeName!==void 0){if(e.typeName!==`Table`)return ji.errors=[{instancePath:t+`/typeName`,schemaPath:`#/properties/typeName/const`,keyword:`const`,params:{allowedValue:`Table`}}],!1;var s=!0}else var s=!0;if(s){if(e.statementId!==void 0){if(typeof e.statementId!=`string`)return ji.errors=[{instancePath:t+`/statementId`,schemaPath:`#/properties/statementId/type`,keyword:`type`,params:{type:`string`}}],!1;var s=!0}else var s=!0;if(s){if(e.props!==void 0){let n=e.props;if(n&&typeof n==`object`&&!Array.isArray(n)){let e;if(n.title===void 0&&(e=`title`)||n.columns===void 0&&(e=`columns`)||n.rows===void 0&&(e=`rows`))return ji.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/required`,keyword:`required`,params:{missingProperty:e}}],!1;for(let e in n)if(e!==`title`&&e!==`columns`&&e!==`rows`)return ji.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e}}],!1;if(n.title!==void 0){if(typeof n.title!=`string`)return ji.errors=[{instancePath:t+`/props/title`,schemaPath:`#/properties/props/properties/title/type`,keyword:`type`,params:{type:`string`}}],!1;var c=!0}else var c=!0;if(c){if(n.columns!==void 0){let e=n.columns;if(Array.isArray(e)){let n=e.length;for(let r=0;r<n;r++)if(typeof e[r]!=`string`)return ji.errors=[{instancePath:t+`/props/columns/`+r,schemaPath:`#/properties/props/properties/columns/items/type`,keyword:`type`,params:{type:`string`}}],!1}else return ji.errors=[{instancePath:t+`/props/columns`,schemaPath:`#/properties/props/properties/columns/type`,keyword:`type`,params:{type:`array`}}],!1;var c=!0}else var c=!0;if(c){if(n.rows!==void 0){let e=n.rows;if(Array.isArray(e)){let n=e.length;for(let r=0;r<n;r++){let n=e[r];if(Array.isArray(n)){let e=n.length;for(let i=0;i<e;i++)if(typeof n[i]!=`string`)return ji.errors=[{instancePath:t+`/props/rows/`+r+`/`+i,schemaPath:`#/properties/props/properties/rows/items/items/type`,keyword:`type`,params:{type:`string`}}],!1}else return ji.errors=[{instancePath:t+`/props/rows/`+r,schemaPath:`#/properties/props/properties/rows/items/type`,keyword:`type`,params:{type:`array`}}],!1}}else return ji.errors=[{instancePath:t+`/props/rows`,schemaPath:`#/properties/props/properties/rows/type`,keyword:`type`,params:{type:`array`}}],!1;var c=!0}else var c=!0}}}else return ji.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/type`,keyword:`type`,params:{type:`object`}}],!1;var s=!0}else var s=!0}}}else return ji.errors=[{instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`}}],!1;return ji.errors=null,!0}ji.evaluated={props:{typeName:!0,statementId:!0,props:!0},dynamicProps:!1,dynamicItems:!1};const Mi={type:`object`,properties:{typeName:{const:`Chart`},statementId:{type:`string`},props:{type:`object`,properties:{title:{type:`string`},type:{type:`string`,enum:[`bar`,`line`]},data:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},value:{type:`number`}},required:[`label`,`value`],additionalProperties:!1}}},required:[`title`,`type`,`data`],additionalProperties:!1}},required:[`typeName`,`statementId`,`props`]};function K(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e,dynamicAnchors:a={}}={}){let o=K.evaluated;if(o.dynamicProps&&(o.props=void 0),o.dynamicItems&&(o.items=void 0),e&&typeof e==`object`&&!Array.isArray(e)){let n;if(e.typeName===void 0&&(n=`typeName`)||e.statementId===void 0&&(n=`statementId`)||e.props===void 0&&(n=`props`))return K.errors=[{instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:n}}],!1;if(e.typeName!==void 0){if(e.typeName!==`Chart`)return K.errors=[{instancePath:t+`/typeName`,schemaPath:`#/properties/typeName/const`,keyword:`const`,params:{allowedValue:`Chart`}}],!1;var s=!0}else var s=!0;if(s){if(e.statementId!==void 0){if(typeof e.statementId!=`string`)return K.errors=[{instancePath:t+`/statementId`,schemaPath:`#/properties/statementId/type`,keyword:`type`,params:{type:`string`}}],!1;var s=!0}else var s=!0;if(s){if(e.props!==void 0){let n=e.props;if(n&&typeof n==`object`&&!Array.isArray(n)){let e;if(n.title===void 0&&(e=`title`)||n.type===void 0&&(e=`type`)||n.data===void 0&&(e=`data`))return K.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/required`,keyword:`required`,params:{missingProperty:e}}],!1;for(let e in n)if(e!==`title`&&e!==`type`&&e!==`data`)return K.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e}}],!1;if(n.title!==void 0){if(typeof n.title!=`string`)return K.errors=[{instancePath:t+`/props/title`,schemaPath:`#/properties/props/properties/title/type`,keyword:`type`,params:{type:`string`}}],!1;var c=!0}else var c=!0;if(c){if(n.type!==void 0){let e=n.type;if(typeof e!=`string`)return K.errors=[{instancePath:t+`/props/type`,schemaPath:`#/properties/props/properties/type/type`,keyword:`type`,params:{type:`string`}}],!1;if(e!==`bar`&&e!==`line`)return K.errors=[{instancePath:t+`/props/type`,schemaPath:`#/properties/props/properties/type/enum`,keyword:`enum`,params:{allowedValues:Mi.properties.props.properties.type.enum}}],!1;var c=!0}else var c=!0;if(c){if(n.data!==void 0){let e=n.data;if(Array.isArray(e)){let n=e.length;for(let r=0;r<n;r++){let n=e[r];if(n&&typeof n==`object`&&!Array.isArray(n)){let e;if(n.label===void 0&&(e=`label`)||n.value===void 0&&(e=`value`))return K.errors=[{instancePath:t+`/props/data/`+r,schemaPath:`#/properties/props/properties/data/items/required`,keyword:`required`,params:{missingProperty:e}}],!1;for(let e in n)if(e!==`label`&&e!==`value`)return K.errors=[{instancePath:t+`/props/data/`+r,schemaPath:`#/properties/props/properties/data/items/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e}}],!1;if(n.label!==void 0){if(typeof n.label!=`string`)return K.errors=[{instancePath:t+`/props/data/`+r+`/label`,schemaPath:`#/properties/props/properties/data/items/properties/label/type`,keyword:`type`,params:{type:`string`}}],!1;var l=!0}else var l=!0;if(l){if(n.value!==void 0){let e=n.value;if(!(typeof e==`number`&&isFinite(e)))return K.errors=[{instancePath:t+`/props/data/`+r+`/value`,schemaPath:`#/properties/props/properties/data/items/properties/value/type`,keyword:`type`,params:{type:`number`}}],!1;var l=!0}else var l=!0}}else return K.errors=[{instancePath:t+`/props/data/`+r,schemaPath:`#/properties/props/properties/data/items/type`,keyword:`type`,params:{type:`object`}}],!1}}else return K.errors=[{instancePath:t+`/props/data`,schemaPath:`#/properties/props/properties/data/type`,keyword:`type`,params:{type:`array`}}],!1;var c=!0}else var c=!0}}}else return K.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/type`,keyword:`type`,params:{type:`object`}}],!1;var s=!0}else var s=!0}}}else return K.errors=[{instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`}}],!1;return K.errors=null,!0}K.evaluated={props:{typeName:!0,statementId:!0,props:!0},dynamicProps:!1,dynamicItems:!1};function Ni(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e,dynamicAnchors:a={}}={}){let o=null,s=0,c=Ni.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),s===0){if(e&&typeof e==`object`&&!Array.isArray(e)){let n;if(e.typeName===void 0&&(n=`typeName`)||e.statementId===void 0&&(n=`statementId`)||e.props===void 0&&(n=`props`))return Ni.errors=[{instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:n}}],!1;if(e.typeName!==void 0){let n=s;if(e.typeName!==`Cell`)return Ni.errors=[{instancePath:t+`/typeName`,schemaPath:`#/properties/typeName/const`,keyword:`const`,params:{allowedValue:`Cell`}}],!1;var l=n===s}else var l=!0;if(l){if(e.statementId!==void 0){let n=s;if(typeof e.statementId!=`string`)return Ni.errors=[{instancePath:t+`/statementId`,schemaPath:`#/properties/statementId/type`,keyword:`type`,params:{type:`string`}}],!1;var l=n===s}else var l=!0;if(l){if(e.props!==void 0){let n=e.props,r=s;if(s===r){if(n&&typeof n==`object`&&!Array.isArray(n)){let e;if(n.children===void 0&&(e=`children`))return Ni.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/required`,keyword:`required`,params:{missingProperty:e}}],!1;{let e=s;for(let e in n)if(e!==`children`&&e!==`span`)return Ni.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e}}],!1;if(e===s){if(n.children!==void 0){let e=n.children,r=s;if(s===r){if(Array.isArray(e)){let n=e.length;for(let r=0;r<n;r++){let n=e[r],c=s,l=s,f=!1,p=s;Oi(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?Oi.errors:o.concat(Oi.errors),s=o.length);var u=p===s;if(f=f||u,u){var d={};d.typeName=!0,d.statementId=!0,d.props=!0}let m=s;ki(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?ki.errors:o.concat(ki.errors),s=o.length);var u=m===s;f=f||u,u&&d!==!0&&(d=d||{},d.typeName=!0,d.statementId=!0,d.props=!0);let h=s;Ai(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?Ai.errors:o.concat(Ai.errors),s=o.length);var u=h===s;f=f||u,u&&d!==!0&&(d=d||{},d.typeName=!0,d.statementId=!0,d.props=!0);let g=s;ji(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?ji.errors:o.concat(ji.errors),s=o.length);var u=g===s;f=f||u,u&&d!==!0&&(d=d||{},d.typeName=!0,d.statementId=!0,d.props=!0);let _=s;K(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?K.errors:o.concat(K.errors),s=o.length);var u=_===s;if(f=f||u,u&&d!==!0&&(d=d||{},d.typeName=!0,d.statementId=!0,d.props=!0),f)s=l,o!==null&&(l?o.length=l:o=null);else{let e={instancePath:t+`/props/children/`+r,schemaPath:`#/properties/props/properties/children/items/anyOf`,keyword:`anyOf`,params:{}};return o===null?o=[e]:o.push(e),s++,Ni.errors=o,!1}if(c!==s)break}}else return Ni.errors=[{instancePath:t+`/props/children`,schemaPath:`#/properties/props/properties/children/type`,keyword:`type`,params:{type:`array`}}],!1}var f=r===s}else var f=!0;if(f){if(n.span!==void 0){let e=n.span,r=s;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e))return Ni.errors=[{instancePath:t+`/props/span`,schemaPath:`#/properties/props/properties/span/type`,keyword:`type`,params:{type:`integer`}}],!1;if(e!==1&&e!==2&&e!==3&&e!==4)return Ni.errors=[{instancePath:t+`/props/span`,schemaPath:`#/properties/props/properties/span/enum`,keyword:`enum`,params:{allowedValues:Di.properties.props.properties.span.enum}}],!1;var f=r===s}else var f=!0}}}}else return Ni.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/type`,keyword:`type`,params:{type:`object`}}],!1}var l=r===s}else var l=!0}}}else return Ni.errors=[{instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`}}],!1}return Ni.errors=o,s===0}Ni.evaluated={props:{typeName:!0,statementId:!0,props:!0},dynamicProps:!1,dynamicItems:!1};function Pi(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e,dynamicAnchors:a={}}={}){let o=null,s=0,c=Pi.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),s===0){if(e&&typeof e==`object`&&!Array.isArray(e)){let n;if(e.typeName===void 0&&(n=`typeName`)||e.statementId===void 0&&(n=`statementId`)||e.props===void 0&&(n=`props`))return Pi.errors=[{instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:n}}],!1;if(e.typeName!==void 0){let n=s;if(e.typeName!==`Grid`)return Pi.errors=[{instancePath:t+`/typeName`,schemaPath:`#/properties/typeName/const`,keyword:`const`,params:{allowedValue:`Grid`}}],!1;var l=n===s}else var l=!0;if(l){if(e.statementId!==void 0){let n=s;if(typeof e.statementId!=`string`)return Pi.errors=[{instancePath:t+`/statementId`,schemaPath:`#/properties/statementId/type`,keyword:`type`,params:{type:`string`}}],!1;var l=n===s}else var l=!0;if(l){if(e.props!==void 0){let n=e.props,r=s;if(s===r){if(n&&typeof n==`object`&&!Array.isArray(n)){let e;if(n.columns===void 0&&(e=`columns`)||n.children===void 0&&(e=`children`))return Pi.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/required`,keyword:`required`,params:{missingProperty:e}}],!1;{let e=s;for(let e in n)if(e!==`columns`&&e!==`children`)return Pi.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e}}],!1;if(e===s){if(n.columns!==void 0){let e=n.columns,r=s;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e))return Pi.errors=[{instancePath:t+`/props/columns`,schemaPath:`#/properties/props/properties/columns/type`,keyword:`type`,params:{type:`integer`}}],!1;if(e!==1&&e!==2&&e!==3&&e!==4)return Pi.errors=[{instancePath:t+`/props/columns`,schemaPath:`#/properties/props/properties/columns/enum`,keyword:`enum`,params:{allowedValues:Ei.properties.props.properties.columns.enum}}],!1;var u=r===s}else var u=!0;if(u){if(n.children!==void 0){let e=n.children,r=s;if(s===r){if(Array.isArray(e)){let n=e.length;for(let r=0;r<n;r++){let n=e[r],c=s,l=s,u=!1,p=s;Ni(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?Ni.errors:o.concat(Ni.errors),s=o.length);var d=p===s;if(u=u||d,d){var f={};f.typeName=!0,f.statementId=!0,f.props=!0}let m=s;Oi(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?Oi.errors:o.concat(Oi.errors),s=o.length);var d=m===s;u=u||d,d&&f!==!0&&(f=f||{},f.typeName=!0,f.statementId=!0,f.props=!0);let h=s;ki(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?ki.errors:o.concat(ki.errors),s=o.length);var d=h===s;u=u||d,d&&f!==!0&&(f=f||{},f.typeName=!0,f.statementId=!0,f.props=!0);let g=s;Ai(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?Ai.errors:o.concat(Ai.errors),s=o.length);var d=g===s;u=u||d,d&&f!==!0&&(f=f||{},f.typeName=!0,f.statementId=!0,f.props=!0);let _=s;ji(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?ji.errors:o.concat(ji.errors),s=o.length);var d=_===s;u=u||d,d&&f!==!0&&(f=f||{},f.typeName=!0,f.statementId=!0,f.props=!0);let v=s;K(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?K.errors:o.concat(K.errors),s=o.length);var d=v===s;if(u=u||d,d&&f!==!0&&(f=f||{},f.typeName=!0,f.statementId=!0,f.props=!0),u)s=l,o!==null&&(l?o.length=l:o=null);else{let e={instancePath:t+`/props/children/`+r,schemaPath:`#/properties/props/properties/children/items/anyOf`,keyword:`anyOf`,params:{}};return o===null?o=[e]:o.push(e),s++,Pi.errors=o,!1}if(c!==s)break}}else return Pi.errors=[{instancePath:t+`/props/children`,schemaPath:`#/properties/props/properties/children/type`,keyword:`type`,params:{type:`array`}}],!1}var u=r===s}else var u=!0}}}}else return Pi.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/type`,keyword:`type`,params:{type:`object`}}],!1}var l=r===s}else var l=!0}}}else return Pi.errors=[{instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`}}],!1}return Pi.errors=o,s===0}Pi.evaluated={props:{typeName:!0,statementId:!0,props:!0},dynamicProps:!1,dynamicItems:!1};function Fi(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e,dynamicAnchors:a={}}={}){let o=null,s=0,c=Fi.evaluated;c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0);let l=s,u=!1,d=s;Pi(e,{instancePath:t,parentData:n,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?Pi.errors:o.concat(Pi.errors),s=o.length);var f=d===s;if(u=u||f,f){var p={};p.typeName=!0,p.statementId=!0,p.props=!0}let m=s;Ni(e,{instancePath:t,parentData:n,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?Ni.errors:o.concat(Ni.errors),s=o.length);var f=m===s;u=u||f,f&&p!==!0&&(p=p||{},p.typeName=!0,p.statementId=!0,p.props=!0);let h=s;Oi(e,{instancePath:t,parentData:n,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?Oi.errors:o.concat(Oi.errors),s=o.length);var f=h===s;u=u||f,f&&p!==!0&&(p=p||{},p.typeName=!0,p.statementId=!0,p.props=!0);let g=s;ki(e,{instancePath:t,parentData:n,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?ki.errors:o.concat(ki.errors),s=o.length);var f=g===s;u=u||f,f&&p!==!0&&(p=p||{},p.typeName=!0,p.statementId=!0,p.props=!0);let _=s;Ai(e,{instancePath:t,parentData:n,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?Ai.errors:o.concat(Ai.errors),s=o.length);var f=_===s;u=u||f,f&&p!==!0&&(p=p||{},p.typeName=!0,p.statementId=!0,p.props=!0);let v=s;ji(e,{instancePath:t,parentData:n,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?ji.errors:o.concat(ji.errors),s=o.length);var f=v===s;u=u||f,f&&p!==!0&&(p=p||{},p.typeName=!0,p.statementId=!0,p.props=!0);let y=s;K(e,{instancePath:t,parentData:n,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?K.errors:o.concat(K.errors),s=o.length);var f=y===s;if(u=u||f,f&&p!==!0&&(p=p||{},p.typeName=!0,p.statementId=!0,p.props=!0),u)s=l,o!==null&&(l?o.length=l:o=null);else{let e={instancePath:t,schemaPath:`#/anyOf`,keyword:`anyOf`,params:{}};return o===null?o=[e]:o.push(e),s++,Fi.errors=o,!1}return Fi.errors=o,c.props=p,s===0}Fi.evaluated={dynamicProps:!0,dynamicItems:!1};function Ii(e){switch(e.k){case`StateRef`:case`RuntimeRef`:case`BinOp`:case`UnaryOp`:case`Ternary`:case`Member`:case`Index`:case`Assign`:return!0;default:return!1}}const Li=/* @__PURE__ */ new Set([`Comp`,`Ref`,`StateRef`,`RuntimeRef`,`BinOp`,`UnaryOp`,`Ternary`,`Member`,`Index`,`Assign`,`Str`,`Num`,`Bool`,`Null`,`Arr`,`Obj`,`Ph`]);function Ri(e){return!e||typeof e!=`object`||Array.isArray(e)?!1:Li.has(e.k)}function zi(e,t){let n=e=>{switch(t(e),e.k){case`Comp`:e.args.forEach(n),Object.values(e.mappedProps??{}).forEach(n);break;case`Arr`:e.els.forEach(n);break;case`Obj`:e.entries.forEach(([,e])=>n(e));break;case`BinOp`:n(e.left),n(e.right);break;case`UnaryOp`:n(e.operand);break;case`Ternary`:n(e.cond),n(e.then),n(e.else);break;case`Member`:n(e.obj);break;case`Index`:n(e.obj),n(e.index);break;case`Assign`:n(e.value)}};n(e)}function Bi(e){return e==null?{k:`Null`}:typeof e==`string`?{k:`Str`,v:e}:typeof e==`number`?{k:`Num`,v:e}:typeof e==`boolean`?{k:`Bool`,v:e}:Array.isArray(e)?{k:`Arr`,els:e.map(Bi)}:typeof e==`object`?{k:`Obj`,entries:Object.entries(e).map(([e,t])=>[e,Bi(t)])}:{k:`Null`}}function Vi(e){switch(e.k){case`Str`:case`Num`:case`Bool`:return{v:e.v};case`Null`:return{v:null};case`Arr`:{let t=[];for(let n of e.els){let e=Vi(n);if(!e)return;t.push(e.v)}return{v:t}}case`Obj`:{let t={};for(let[n,r]of e.entries){let e=Vi(r);if(!e)return;t[n]=e.v}return{v:t}}default:return}}const Hi=/* @__PURE__ */ new Map([[`Count`,{kind:`function`,params:[{name:`array`,required:!1}],builtin:!0}],[`First`,{kind:`function`,params:[{name:`array`,required:!1}],builtin:!0}],[`Last`,{kind:`function`,params:[{name:`array`,required:!1}],builtin:!0}],[`Sum`,{kind:`function`,params:[{name:`numbers`,required:!1}],builtin:!0}],[`Avg`,{kind:`function`,params:[{name:`numbers`,required:!1}],builtin:!0}],[`Min`,{kind:`function`,params:[{name:`numbers`,required:!1}],builtin:!0}],[`Max`,{kind:`function`,params:[{name:`numbers`,required:!1}],builtin:!0}],[`Sort`,{kind:`function`,params:[{name:`array`,required:!1},{name:`field`,required:!1},{name:`direction`,required:!1}],builtin:!0}],[`Filter`,{kind:`function`,params:[{name:`array`,required:!1},{name:`field`,required:!1},{name:`operator`,required:!1},{name:`value`,required:!1}],builtin:!0}],[`Round`,{kind:`function`,params:[{name:`number`,required:!1},{name:`decimals`,required:!1}],builtin:!0}],[`Abs`,{kind:`function`,params:[{name:`number`,required:!1}],builtin:!0}],[`Floor`,{kind:`function`,params:[{name:`number`,required:!1}],builtin:!0}],[`Ceil`,{kind:`function`,params:[{name:`number`,required:!1}],builtin:!0}],[`Each`,{kind:`function`,params:[{name:`array`,required:!1},{name:`varName`,required:!1},{name:`template`,required:!1}],builtin:!0,lazy:!0}],[`Run`,{kind:`action`,params:[{name:`ref`,required:!1}],builtin:!0,lazy:!0}],[`ToAssistant`,{kind:`action`,params:[{name:`message`,required:!1},{name:`context`,required:!1}],builtin:!0}],[`OpenUrl`,{kind:`action`,params:[{name:`url`,required:!1}],builtin:!0}],[`Set`,{kind:`action`,params:[{name:`variable`,required:!1},{name:`value`,required:!1}],builtin:!0,lazy:!0}],[`Reset`,{kind:`action`,params:[{name:`variable`,required:!1}],builtin:!0,lazy:!0}],[`Action`,{kind:`action`,params:[{name:`steps`,required:!0}],builtin:!0,lazy:!0}]]),Ui={ActionExpression:!0,OpenUrl:!0,ToAssistant:!0},Wi={Query:`Query`,Mutation:`Mutation`};function Gi(e){return e?.callDefs??Hi}function Ki(e){return Hi.has(e)}function qi(e){return e in Wi}var q;(function(e){e[e.Newline=0]=`Newline`,e[e.LParen=1]=`LParen`,e[e.RParen=2]=`RParen`,e[e.LBrack=3]=`LBrack`,e[e.RBrack=4]=`RBrack`,e[e.LBrace=5]=`LBrace`,e[e.RBrace=6]=`RBrace`,e[e.Comma=7]=`Comma`,e[e.Colon=8]=`Colon`,e[e.Equals=9]=`Equals`,e[e.True=10]=`True`,e[e.False=11]=`False`,e[e.Null=12]=`Null`,e[e.EOF=13]=`EOF`,e[e.Str=14]=`Str`,e[e.Num=15]=`Num`,e[e.Ident=16]=`Ident`,e[e.Type=17]=`Type`,e[e.StateVar=18]=`StateVar`,e[e.Dot=19]=`Dot`,e[e.Plus=20]=`Plus`,e[e.Minus=21]=`Minus`,e[e.Star=22]=`Star`,e[e.Slash=23]=`Slash`,e[e.Percent=24]=`Percent`,e[e.EqEq=25]=`EqEq`,e[e.NotEq=26]=`NotEq`,e[e.Greater=27]=`Greater`,e[e.Less=28]=`Less`,e[e.GreaterEq=29]=`GreaterEq`,e[e.LessEq=30]=`LessEq`,e[e.And=31]=`And`,e[e.Or=32]=`Or`,e[e.Not=33]=`Not`,e[e.Question=34]=`Question`,e[e.BuiltinCall=35]=`BuiltinCall`})(q||(q={}));function Ji(e){let t=0,n=()=>e[t]??{t:q.EOF},r=()=>{let e=n();return t++,e},i=e=>{n().t===e&&t++};function a(e){switch(e.t){case q.Question:return 1;case q.Or:return 2;case q.And:return 3;case q.EqEq:case q.NotEq:return 4;case q.Greater:case q.Less:case q.GreaterEq:case q.LessEq:return 5;case q.Plus:case q.Minus:return 6;case q.Star:case q.Slash:case q.Percent:return 7;case q.Dot:case q.LBrack:return 9;default:return 0}}function o(e=0){let t=s();for(;a(n())>e;)t=c(t);return t}function s(){let a=n();if(a.t===q.Str)return r(),{k:`Str`,v:a.v};if(a.t===q.Num)return r(),{k:`Num`,v:a.v};if(a.t===q.True)return r(),{k:`Bool`,v:!0};if(a.t===q.False)return r(),{k:`Bool`,v:!1};if(a.t===q.Null)return r(),{k:`Null`};if(a.t===q.LBrack)return u();if(a.t===q.LBrace)return d();if(a.t===q.StateVar){let e=a.v;return r(),n().t===q.Equals?(r(),{k:`Assign`,target:e,value:o(0)}):{k:`StateRef`,n:e}}if(a.t===q.Type){let n=a.v;return e[t+1]?.t===q.LParen&&(!Ki(n)||n===`Action`)?l():(r(),{k:`Ref`,n})}if(a.t===q.BuiltinCall){if(e[t+1]?.t===q.LParen){let e=l();return e.k===`Comp`&&!Ki(e.name)&&(e.fn=!0),e}return r(),{k:`Ref`,n:a.v}}if(a.t===q.Ident)return r(),{k:`Ref`,n:a.v};if(a.t===q.Not)return r(),{k:`UnaryOp`,op:`!`,operand:o(8)};if(a.t===q.Minus)return r(),{k:`UnaryOp`,op:`-`,operand:o(8)};if(a.t===q.LParen){r();let e=o(0);return i(q.RParen),e}return r(),{k:`Null`}}function c(e){let t=n();if(t.t===q.Plus)return r(),{k:`BinOp`,op:`+`,left:e,right:o(6)};if(t.t===q.Minus)return r(),{k:`BinOp`,op:`-`,left:e,right:o(6)};if(t.t===q.Star)return r(),{k:`BinOp`,op:`*`,left:e,right:o(7)};if(t.t===q.Slash)return r(),{k:`BinOp`,op:`/`,left:e,right:o(7)};if(t.t===q.Percent)return r(),{k:`BinOp`,op:`%`,left:e,right:o(7)};if(t.t===q.EqEq)return r(),{k:`BinOp`,op:`==`,left:e,right:o(4)};if(t.t===q.NotEq)return r(),{k:`BinOp`,op:`!=`,left:e,right:o(4)};if(t.t===q.Greater)return r(),{k:`BinOp`,op:`>`,left:e,right:o(5)};if(t.t===q.Less)return r(),{k:`BinOp`,op:`<`,left:e,right:o(5)};if(t.t===q.GreaterEq)return r(),{k:`BinOp`,op:`>=`,left:e,right:o(5)};if(t.t===q.LessEq)return r(),{k:`BinOp`,op:`<=`,left:e,right:o(5)};if(t.t===q.And)return r(),{k:`BinOp`,op:`&&`,left:e,right:o(3)};if(t.t===q.Or)return r(),{k:`BinOp`,op:`||`,left:e,right:o(2)};if(t.t===q.Question){r();let t=o(0);return i(q.Colon),{k:`Ternary`,cond:e,then:t,else:o(0)}}if(t.t===q.Dot){r();let t=n();return{k:`Member`,obj:e,field:t.t===q.Ident||t.t===q.Type||t.t===q.Str||t.t===q.Num?(r(),String(t.v)):t.t===q.StateVar?(r(),t.v.replace(/^\$/,``)):(r(),`?`)}}if(t.t===q.LBrack){r();let t=o(0);return i(q.RBrack),{k:`Index`,obj:e,index:t}}return e}function l(){let e=n().v;r(),i(q.LParen);let t=[];for(;n().t!==q.RParen&&n().t!==q.EOF;)t.push(o(0)),n().t===q.Comma&&r();return i(q.RParen),{k:`Comp`,name:e,args:t}}function u(){r();let e=[];for(;n().t!==q.RBrack&&n().t!==q.EOF;)e.push(o(0)),n().t===q.Comma&&r();return i(q.RBrack),{k:`Arr`,els:e}}function d(){r();let e=[];for(;n().t!==q.RBrace&&n().t!==q.EOF;){let t=n(),a=t.t===q.Ident||t.t===q.Str||t.t===q.Type||t.t===q.Num?(r(),String(t.v)):t.t===q.StateVar?(r(),t.v.replace(/^\$/,``)):(r(),`?`);i(q.Colon),e.push([a,o(0)]),n().t===q.Comma&&r()}return i(q.RBrace),{k:`Obj`,entries:e}}return o(0)}function Yi(e){let t=[],n=0,r=e.length;for(;n<r;){for(;n<r&&(e[n]===` `||e[n]===` `||e[n]===`\r`);)n++;if(n>=r)break;let i=e[n];if(i===`
39
+ `){W(e),G(e,16),e.pending=n;continue}}break;case`$`:if(e.token!==19&&e.token!==16&&e.pending===`$`){if(n===`$`){e.token=105,e.pending=t;continue}if(ca(n.charCodeAt(0)))break;W(e),G(e,31),e.pending=n;continue}break;case`[`:if(e.token!==19&&e.token!==17&&e.token!==30&&e.token!==31&&n!==`]`){W(e),G(e,17),e.pending=n;continue}break;case`!`:if(e.token!==19&&n===`[`){W(e),G(e,19),e.pending=``;continue}break;case` `:if(e.pending.length===1&&n===` `)continue}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):(e.text+=e.pending,e.pending=n)}W(e)}function ua(e){return{add_token:da,end_token:fa,add_text:pa,set_attr:ma,data:{nodes:[e,,,,,],index:0}}}function da(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 e=r=document.createElement(`input`);e.type=`checkbox`,e.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`)}e.nodes[++e.index]=n.appendChild(r)}function fa(e){--e.index}function pa(e,t){e.nodes[e.index].appendChild(document.createTextNode(t))}function ma(e,t,n){e.nodes[e.index].setAttribute(Yi(t),n)}const ha={root:`Root`,schema:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{Root:{$ref:`#/$defs/Root`},Grid:{$ref:`#/$defs/Grid`},Cell:{$ref:`#/$defs/Cell`},Text:{$ref:`#/$defs/Text`},Card:{$ref:`#/$defs/Card`},Metric:{$ref:`#/$defs/Metric`},Table:{$ref:`#/$defs/Table`},Chart:{$ref:`#/$defs/Chart`}},required:[`Root`,`Grid`,`Cell`,`Text`,`Card`,`Metric`,`Table`,`Chart`],additionalProperties:!1,$defs:{Root:{type:`object`,properties:{children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Grid`},{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`}]}}},required:[`children`],additionalProperties:!1},Grid:{type:`object`,properties:{columns:{type:`integer`,enum:[1,2,3,4],default:1},children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Cell`},{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`}]}}},required:[`columns`,`children`],additionalProperties:!1},Cell:{type:`object`,properties:{children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`}]}},span:{type:`integer`,enum:[1,2,3,4],default:1}},required:[`children`],additionalProperties:!1},Text:{type:`object`,properties:{text:{type:`string`}},required:[`text`],additionalProperties:!1},Card:{type:`object`,properties:{title:{type:`string`},body:{type:`string`}},required:[`title`,`body`],additionalProperties:!1},Metric:{type:`object`,properties:{label:{type:`string`},value:{type:`string`},detail:{type:`string`}},required:[`label`,`value`,`detail`],additionalProperties:!1},Table:{type:`object`,properties:{title:{type:`string`},columns:{type:`array`,items:{type:`string`}},rows:{type:`array`,items:{type:`array`,items:{type:`string`}}}},required:[`title`,`columns`,`rows`],additionalProperties:!1},Chart:{type:`object`,properties:{title:{type:`string`},type:{type:`string`,enum:[`bar`,`line`]},data:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},value:{type:`number`}},required:[`label`,`value`],additionalProperties:!1}}},required:[`title`,`type`,`data`],additionalProperties:!1}}}},ga=Ea,_a={type:`object`,properties:{typeName:{const:`Grid`},statementId:{type:`string`},props:{type:`object`,properties:{columns:{type:`integer`,enum:[1,2,3,4],default:1},children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Cell`},{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`}]}}},required:[`columns`,`children`],additionalProperties:!1}},required:[`typeName`,`statementId`,`props`]},va={type:`object`,properties:{typeName:{const:`Cell`},statementId:{type:`string`},props:{type:`object`,properties:{children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`}]}},span:{type:`integer`,enum:[1,2,3,4],default:1}},required:[`children`],additionalProperties:!1}},required:[`typeName`,`statementId`,`props`]};function ya(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e,dynamicAnchors:a={}}={}){let o=ya.evaluated;if(o.dynamicProps&&(o.props=void 0),o.dynamicItems&&(o.items=void 0),e&&typeof e==`object`&&!Array.isArray(e)){let n;if(e.typeName===void 0&&(n=`typeName`)||e.statementId===void 0&&(n=`statementId`)||e.props===void 0&&(n=`props`))return ya.errors=[{instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:n}}],!1;if(e.typeName!==void 0){if(e.typeName!==`Text`)return ya.errors=[{instancePath:t+`/typeName`,schemaPath:`#/properties/typeName/const`,keyword:`const`,params:{allowedValue:`Text`}}],!1;var s=!0}else var s=!0;if(s){if(e.statementId!==void 0){if(typeof e.statementId!=`string`)return ya.errors=[{instancePath:t+`/statementId`,schemaPath:`#/properties/statementId/type`,keyword:`type`,params:{type:`string`}}],!1;var s=!0}else var s=!0;if(s){if(e.props!==void 0){let n=e.props;if(n&&typeof n==`object`&&!Array.isArray(n)){let e;if(n.text===void 0&&(e=`text`))return ya.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/required`,keyword:`required`,params:{missingProperty:e}}],!1;for(let e in n)if(e!==`text`)return ya.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e}}],!1;if(n.text!==void 0&&typeof n.text!=`string`)return ya.errors=[{instancePath:t+`/props/text`,schemaPath:`#/properties/props/properties/text/type`,keyword:`type`,params:{type:`string`}}],!1}else return ya.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/type`,keyword:`type`,params:{type:`object`}}],!1;var s=!0}else var s=!0}}}else return ya.errors=[{instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`}}],!1;return ya.errors=null,!0}ya.evaluated={props:{typeName:!0,statementId:!0,props:!0},dynamicProps:!1,dynamicItems:!1};function ba(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e,dynamicAnchors:a={}}={}){let o=ba.evaluated;if(o.dynamicProps&&(o.props=void 0),o.dynamicItems&&(o.items=void 0),e&&typeof e==`object`&&!Array.isArray(e)){let n;if(e.typeName===void 0&&(n=`typeName`)||e.statementId===void 0&&(n=`statementId`)||e.props===void 0&&(n=`props`))return ba.errors=[{instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:n}}],!1;if(e.typeName!==void 0){if(e.typeName!==`Card`)return ba.errors=[{instancePath:t+`/typeName`,schemaPath:`#/properties/typeName/const`,keyword:`const`,params:{allowedValue:`Card`}}],!1;var s=!0}else var s=!0;if(s){if(e.statementId!==void 0){if(typeof e.statementId!=`string`)return ba.errors=[{instancePath:t+`/statementId`,schemaPath:`#/properties/statementId/type`,keyword:`type`,params:{type:`string`}}],!1;var s=!0}else var s=!0;if(s){if(e.props!==void 0){let n=e.props;if(n&&typeof n==`object`&&!Array.isArray(n)){let e;if(n.title===void 0&&(e=`title`)||n.body===void 0&&(e=`body`))return ba.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/required`,keyword:`required`,params:{missingProperty:e}}],!1;for(let e in n)if(e!==`title`&&e!==`body`)return ba.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e}}],!1;if(n.title!==void 0){if(typeof n.title!=`string`)return ba.errors=[{instancePath:t+`/props/title`,schemaPath:`#/properties/props/properties/title/type`,keyword:`type`,params:{type:`string`}}],!1;var c=!0}else var c=!0;if(c){if(n.body!==void 0){if(typeof n.body!=`string`)return ba.errors=[{instancePath:t+`/props/body`,schemaPath:`#/properties/props/properties/body/type`,keyword:`type`,params:{type:`string`}}],!1;var c=!0}else var c=!0}}else return ba.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/type`,keyword:`type`,params:{type:`object`}}],!1;var s=!0}else var s=!0}}}else return ba.errors=[{instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`}}],!1;return ba.errors=null,!0}ba.evaluated={props:{typeName:!0,statementId:!0,props:!0},dynamicProps:!1,dynamicItems:!1};function xa(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e,dynamicAnchors:a={}}={}){let o=xa.evaluated;if(o.dynamicProps&&(o.props=void 0),o.dynamicItems&&(o.items=void 0),e&&typeof e==`object`&&!Array.isArray(e)){let n;if(e.typeName===void 0&&(n=`typeName`)||e.statementId===void 0&&(n=`statementId`)||e.props===void 0&&(n=`props`))return xa.errors=[{instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:n}}],!1;if(e.typeName!==void 0){if(e.typeName!==`Metric`)return xa.errors=[{instancePath:t+`/typeName`,schemaPath:`#/properties/typeName/const`,keyword:`const`,params:{allowedValue:`Metric`}}],!1;var s=!0}else var s=!0;if(s){if(e.statementId!==void 0){if(typeof e.statementId!=`string`)return xa.errors=[{instancePath:t+`/statementId`,schemaPath:`#/properties/statementId/type`,keyword:`type`,params:{type:`string`}}],!1;var s=!0}else var s=!0;if(s){if(e.props!==void 0){let n=e.props;if(n&&typeof n==`object`&&!Array.isArray(n)){let e;if(n.label===void 0&&(e=`label`)||n.value===void 0&&(e=`value`)||n.detail===void 0&&(e=`detail`))return xa.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/required`,keyword:`required`,params:{missingProperty:e}}],!1;for(let e in n)if(e!==`label`&&e!==`value`&&e!==`detail`)return xa.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e}}],!1;if(n.label!==void 0){if(typeof n.label!=`string`)return xa.errors=[{instancePath:t+`/props/label`,schemaPath:`#/properties/props/properties/label/type`,keyword:`type`,params:{type:`string`}}],!1;var c=!0}else var c=!0;if(c){if(n.value!==void 0){if(typeof n.value!=`string`)return xa.errors=[{instancePath:t+`/props/value`,schemaPath:`#/properties/props/properties/value/type`,keyword:`type`,params:{type:`string`}}],!1;var c=!0}else var c=!0;if(c){if(n.detail!==void 0){if(typeof n.detail!=`string`)return xa.errors=[{instancePath:t+`/props/detail`,schemaPath:`#/properties/props/properties/detail/type`,keyword:`type`,params:{type:`string`}}],!1;var c=!0}else var c=!0}}}else return xa.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/type`,keyword:`type`,params:{type:`object`}}],!1;var s=!0}else var s=!0}}}else return xa.errors=[{instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`}}],!1;return xa.errors=null,!0}xa.evaluated={props:{typeName:!0,statementId:!0,props:!0},dynamicProps:!1,dynamicItems:!1};function Sa(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e,dynamicAnchors:a={}}={}){let o=Sa.evaluated;if(o.dynamicProps&&(o.props=void 0),o.dynamicItems&&(o.items=void 0),e&&typeof e==`object`&&!Array.isArray(e)){let n;if(e.typeName===void 0&&(n=`typeName`)||e.statementId===void 0&&(n=`statementId`)||e.props===void 0&&(n=`props`))return Sa.errors=[{instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:n}}],!1;if(e.typeName!==void 0){if(e.typeName!==`Table`)return Sa.errors=[{instancePath:t+`/typeName`,schemaPath:`#/properties/typeName/const`,keyword:`const`,params:{allowedValue:`Table`}}],!1;var s=!0}else var s=!0;if(s){if(e.statementId!==void 0){if(typeof e.statementId!=`string`)return Sa.errors=[{instancePath:t+`/statementId`,schemaPath:`#/properties/statementId/type`,keyword:`type`,params:{type:`string`}}],!1;var s=!0}else var s=!0;if(s){if(e.props!==void 0){let n=e.props;if(n&&typeof n==`object`&&!Array.isArray(n)){let e;if(n.title===void 0&&(e=`title`)||n.columns===void 0&&(e=`columns`)||n.rows===void 0&&(e=`rows`))return Sa.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/required`,keyword:`required`,params:{missingProperty:e}}],!1;for(let e in n)if(e!==`title`&&e!==`columns`&&e!==`rows`)return Sa.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e}}],!1;if(n.title!==void 0){if(typeof n.title!=`string`)return Sa.errors=[{instancePath:t+`/props/title`,schemaPath:`#/properties/props/properties/title/type`,keyword:`type`,params:{type:`string`}}],!1;var c=!0}else var c=!0;if(c){if(n.columns!==void 0){let e=n.columns;if(Array.isArray(e)){let n=e.length;for(let r=0;r<n;r++)if(typeof e[r]!=`string`)return Sa.errors=[{instancePath:t+`/props/columns/`+r,schemaPath:`#/properties/props/properties/columns/items/type`,keyword:`type`,params:{type:`string`}}],!1}else return Sa.errors=[{instancePath:t+`/props/columns`,schemaPath:`#/properties/props/properties/columns/type`,keyword:`type`,params:{type:`array`}}],!1;var c=!0}else var c=!0;if(c){if(n.rows!==void 0){let e=n.rows;if(Array.isArray(e)){let n=e.length;for(let r=0;r<n;r++){let n=e[r];if(Array.isArray(n)){let e=n.length;for(let i=0;i<e;i++)if(typeof n[i]!=`string`)return Sa.errors=[{instancePath:t+`/props/rows/`+r+`/`+i,schemaPath:`#/properties/props/properties/rows/items/items/type`,keyword:`type`,params:{type:`string`}}],!1}else return Sa.errors=[{instancePath:t+`/props/rows/`+r,schemaPath:`#/properties/props/properties/rows/items/type`,keyword:`type`,params:{type:`array`}}],!1}}else return Sa.errors=[{instancePath:t+`/props/rows`,schemaPath:`#/properties/props/properties/rows/type`,keyword:`type`,params:{type:`array`}}],!1;var c=!0}else var c=!0}}}else return Sa.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/type`,keyword:`type`,params:{type:`object`}}],!1;var s=!0}else var s=!0}}}else return Sa.errors=[{instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`}}],!1;return Sa.errors=null,!0}Sa.evaluated={props:{typeName:!0,statementId:!0,props:!0},dynamicProps:!1,dynamicItems:!1};const Ca={type:`object`,properties:{typeName:{const:`Chart`},statementId:{type:`string`},props:{type:`object`,properties:{title:{type:`string`},type:{type:`string`,enum:[`bar`,`line`]},data:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},value:{type:`number`}},required:[`label`,`value`],additionalProperties:!1}}},required:[`title`,`type`,`data`],additionalProperties:!1}},required:[`typeName`,`statementId`,`props`]};function K(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e,dynamicAnchors:a={}}={}){let o=K.evaluated;if(o.dynamicProps&&(o.props=void 0),o.dynamicItems&&(o.items=void 0),e&&typeof e==`object`&&!Array.isArray(e)){let n;if(e.typeName===void 0&&(n=`typeName`)||e.statementId===void 0&&(n=`statementId`)||e.props===void 0&&(n=`props`))return K.errors=[{instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:n}}],!1;if(e.typeName!==void 0){if(e.typeName!==`Chart`)return K.errors=[{instancePath:t+`/typeName`,schemaPath:`#/properties/typeName/const`,keyword:`const`,params:{allowedValue:`Chart`}}],!1;var s=!0}else var s=!0;if(s){if(e.statementId!==void 0){if(typeof e.statementId!=`string`)return K.errors=[{instancePath:t+`/statementId`,schemaPath:`#/properties/statementId/type`,keyword:`type`,params:{type:`string`}}],!1;var s=!0}else var s=!0;if(s){if(e.props!==void 0){let n=e.props;if(n&&typeof n==`object`&&!Array.isArray(n)){let e;if(n.title===void 0&&(e=`title`)||n.type===void 0&&(e=`type`)||n.data===void 0&&(e=`data`))return K.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/required`,keyword:`required`,params:{missingProperty:e}}],!1;for(let e in n)if(e!==`title`&&e!==`type`&&e!==`data`)return K.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e}}],!1;if(n.title!==void 0){if(typeof n.title!=`string`)return K.errors=[{instancePath:t+`/props/title`,schemaPath:`#/properties/props/properties/title/type`,keyword:`type`,params:{type:`string`}}],!1;var c=!0}else var c=!0;if(c){if(n.type!==void 0){let e=n.type;if(typeof e!=`string`)return K.errors=[{instancePath:t+`/props/type`,schemaPath:`#/properties/props/properties/type/type`,keyword:`type`,params:{type:`string`}}],!1;if(e!==`bar`&&e!==`line`)return K.errors=[{instancePath:t+`/props/type`,schemaPath:`#/properties/props/properties/type/enum`,keyword:`enum`,params:{allowedValues:Ca.properties.props.properties.type.enum}}],!1;var c=!0}else var c=!0;if(c){if(n.data!==void 0){let e=n.data;if(Array.isArray(e)){let n=e.length;for(let r=0;r<n;r++){let n=e[r];if(n&&typeof n==`object`&&!Array.isArray(n)){let e;if(n.label===void 0&&(e=`label`)||n.value===void 0&&(e=`value`))return K.errors=[{instancePath:t+`/props/data/`+r,schemaPath:`#/properties/props/properties/data/items/required`,keyword:`required`,params:{missingProperty:e}}],!1;for(let e in n)if(e!==`label`&&e!==`value`)return K.errors=[{instancePath:t+`/props/data/`+r,schemaPath:`#/properties/props/properties/data/items/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e}}],!1;if(n.label!==void 0){if(typeof n.label!=`string`)return K.errors=[{instancePath:t+`/props/data/`+r+`/label`,schemaPath:`#/properties/props/properties/data/items/properties/label/type`,keyword:`type`,params:{type:`string`}}],!1;var l=!0}else var l=!0;if(l){if(n.value!==void 0){let e=n.value;if(!(typeof e==`number`&&isFinite(e)))return K.errors=[{instancePath:t+`/props/data/`+r+`/value`,schemaPath:`#/properties/props/properties/data/items/properties/value/type`,keyword:`type`,params:{type:`number`}}],!1;var l=!0}else var l=!0}}else return K.errors=[{instancePath:t+`/props/data/`+r,schemaPath:`#/properties/props/properties/data/items/type`,keyword:`type`,params:{type:`object`}}],!1}}else return K.errors=[{instancePath:t+`/props/data`,schemaPath:`#/properties/props/properties/data/type`,keyword:`type`,params:{type:`array`}}],!1;var c=!0}else var c=!0}}}else return K.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/type`,keyword:`type`,params:{type:`object`}}],!1;var s=!0}else var s=!0}}}else return K.errors=[{instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`}}],!1;return K.errors=null,!0}K.evaluated={props:{typeName:!0,statementId:!0,props:!0},dynamicProps:!1,dynamicItems:!1};function wa(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e,dynamicAnchors:a={}}={}){let o=null,s=0,c=wa.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),s===0){if(e&&typeof e==`object`&&!Array.isArray(e)){let n;if(e.typeName===void 0&&(n=`typeName`)||e.statementId===void 0&&(n=`statementId`)||e.props===void 0&&(n=`props`))return wa.errors=[{instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:n}}],!1;if(e.typeName!==void 0){let n=s;if(e.typeName!==`Cell`)return wa.errors=[{instancePath:t+`/typeName`,schemaPath:`#/properties/typeName/const`,keyword:`const`,params:{allowedValue:`Cell`}}],!1;var l=n===s}else var l=!0;if(l){if(e.statementId!==void 0){let n=s;if(typeof e.statementId!=`string`)return wa.errors=[{instancePath:t+`/statementId`,schemaPath:`#/properties/statementId/type`,keyword:`type`,params:{type:`string`}}],!1;var l=n===s}else var l=!0;if(l){if(e.props!==void 0){let n=e.props,r=s;if(s===r){if(n&&typeof n==`object`&&!Array.isArray(n)){let e;if(n.children===void 0&&(e=`children`))return wa.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/required`,keyword:`required`,params:{missingProperty:e}}],!1;{let e=s;for(let e in n)if(e!==`children`&&e!==`span`)return wa.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e}}],!1;if(e===s){if(n.children!==void 0){let e=n.children,r=s;if(s===r){if(Array.isArray(e)){let n=e.length;for(let r=0;r<n;r++){let n=e[r],c=s,l=s,f=!1,p=s;ya(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?ya.errors:o.concat(ya.errors),s=o.length);var u=p===s;if(f=f||u,u){var d={};d.typeName=!0,d.statementId=!0,d.props=!0}let m=s;ba(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?ba.errors:o.concat(ba.errors),s=o.length);var u=m===s;f=f||u,u&&d!==!0&&(d=d||{},d.typeName=!0,d.statementId=!0,d.props=!0);let h=s;xa(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?xa.errors:o.concat(xa.errors),s=o.length);var u=h===s;f=f||u,u&&d!==!0&&(d=d||{},d.typeName=!0,d.statementId=!0,d.props=!0);let g=s;Sa(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?Sa.errors:o.concat(Sa.errors),s=o.length);var u=g===s;f=f||u,u&&d!==!0&&(d=d||{},d.typeName=!0,d.statementId=!0,d.props=!0);let _=s;K(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?K.errors:o.concat(K.errors),s=o.length);var u=_===s;if(f=f||u,u&&d!==!0&&(d=d||{},d.typeName=!0,d.statementId=!0,d.props=!0),f)s=l,o!==null&&(l?o.length=l:o=null);else{let e={instancePath:t+`/props/children/`+r,schemaPath:`#/properties/props/properties/children/items/anyOf`,keyword:`anyOf`,params:{}};return o===null?o=[e]:o.push(e),s++,wa.errors=o,!1}if(c!==s)break}}else return wa.errors=[{instancePath:t+`/props/children`,schemaPath:`#/properties/props/properties/children/type`,keyword:`type`,params:{type:`array`}}],!1}var f=r===s}else var f=!0;if(f){if(n.span!==void 0){let e=n.span,r=s;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e))return wa.errors=[{instancePath:t+`/props/span`,schemaPath:`#/properties/props/properties/span/type`,keyword:`type`,params:{type:`integer`}}],!1;if(e!==1&&e!==2&&e!==3&&e!==4)return wa.errors=[{instancePath:t+`/props/span`,schemaPath:`#/properties/props/properties/span/enum`,keyword:`enum`,params:{allowedValues:va.properties.props.properties.span.enum}}],!1;var f=r===s}else var f=!0}}}}else return wa.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/type`,keyword:`type`,params:{type:`object`}}],!1}var l=r===s}else var l=!0}}}else return wa.errors=[{instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`}}],!1}return wa.errors=o,s===0}wa.evaluated={props:{typeName:!0,statementId:!0,props:!0},dynamicProps:!1,dynamicItems:!1};function Ta(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e,dynamicAnchors:a={}}={}){let o=null,s=0,c=Ta.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),s===0){if(e&&typeof e==`object`&&!Array.isArray(e)){let n;if(e.typeName===void 0&&(n=`typeName`)||e.statementId===void 0&&(n=`statementId`)||e.props===void 0&&(n=`props`))return Ta.errors=[{instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:n}}],!1;if(e.typeName!==void 0){let n=s;if(e.typeName!==`Grid`)return Ta.errors=[{instancePath:t+`/typeName`,schemaPath:`#/properties/typeName/const`,keyword:`const`,params:{allowedValue:`Grid`}}],!1;var l=n===s}else var l=!0;if(l){if(e.statementId!==void 0){let n=s;if(typeof e.statementId!=`string`)return Ta.errors=[{instancePath:t+`/statementId`,schemaPath:`#/properties/statementId/type`,keyword:`type`,params:{type:`string`}}],!1;var l=n===s}else var l=!0;if(l){if(e.props!==void 0){let n=e.props,r=s;if(s===r){if(n&&typeof n==`object`&&!Array.isArray(n)){let e;if(n.columns===void 0&&(e=`columns`)||n.children===void 0&&(e=`children`))return Ta.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/required`,keyword:`required`,params:{missingProperty:e}}],!1;{let e=s;for(let e in n)if(e!==`columns`&&e!==`children`)return Ta.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e}}],!1;if(e===s){if(n.columns!==void 0){let e=n.columns,r=s;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e))return Ta.errors=[{instancePath:t+`/props/columns`,schemaPath:`#/properties/props/properties/columns/type`,keyword:`type`,params:{type:`integer`}}],!1;if(e!==1&&e!==2&&e!==3&&e!==4)return Ta.errors=[{instancePath:t+`/props/columns`,schemaPath:`#/properties/props/properties/columns/enum`,keyword:`enum`,params:{allowedValues:_a.properties.props.properties.columns.enum}}],!1;var u=r===s}else var u=!0;if(u){if(n.children!==void 0){let e=n.children,r=s;if(s===r){if(Array.isArray(e)){let n=e.length;for(let r=0;r<n;r++){let n=e[r],c=s,l=s,u=!1,p=s;wa(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?wa.errors:o.concat(wa.errors),s=o.length);var d=p===s;if(u=u||d,d){var f={};f.typeName=!0,f.statementId=!0,f.props=!0}let m=s;ya(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?ya.errors:o.concat(ya.errors),s=o.length);var d=m===s;u=u||d,d&&f!==!0&&(f=f||{},f.typeName=!0,f.statementId=!0,f.props=!0);let h=s;ba(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?ba.errors:o.concat(ba.errors),s=o.length);var d=h===s;u=u||d,d&&f!==!0&&(f=f||{},f.typeName=!0,f.statementId=!0,f.props=!0);let g=s;xa(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?xa.errors:o.concat(xa.errors),s=o.length);var d=g===s;u=u||d,d&&f!==!0&&(f=f||{},f.typeName=!0,f.statementId=!0,f.props=!0);let _=s;Sa(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?Sa.errors:o.concat(Sa.errors),s=o.length);var d=_===s;u=u||d,d&&f!==!0&&(f=f||{},f.typeName=!0,f.statementId=!0,f.props=!0);let v=s;K(n,{instancePath:t+`/props/children/`+r,parentData:e,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?K.errors:o.concat(K.errors),s=o.length);var d=v===s;if(u=u||d,d&&f!==!0&&(f=f||{},f.typeName=!0,f.statementId=!0,f.props=!0),u)s=l,o!==null&&(l?o.length=l:o=null);else{let e={instancePath:t+`/props/children/`+r,schemaPath:`#/properties/props/properties/children/items/anyOf`,keyword:`anyOf`,params:{}};return o===null?o=[e]:o.push(e),s++,Ta.errors=o,!1}if(c!==s)break}}else return Ta.errors=[{instancePath:t+`/props/children`,schemaPath:`#/properties/props/properties/children/type`,keyword:`type`,params:{type:`array`}}],!1}var u=r===s}else var u=!0}}}}else return Ta.errors=[{instancePath:t+`/props`,schemaPath:`#/properties/props/type`,keyword:`type`,params:{type:`object`}}],!1}var l=r===s}else var l=!0}}}else return Ta.errors=[{instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`}}],!1}return Ta.errors=o,s===0}Ta.evaluated={props:{typeName:!0,statementId:!0,props:!0},dynamicProps:!1,dynamicItems:!1};function Ea(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e,dynamicAnchors:a={}}={}){let o=null,s=0,c=Ea.evaluated;c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0);let l=s,u=!1,d=s;Ta(e,{instancePath:t,parentData:n,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?Ta.errors:o.concat(Ta.errors),s=o.length);var f=d===s;if(u=u||f,f){var p={};p.typeName=!0,p.statementId=!0,p.props=!0}let m=s;wa(e,{instancePath:t,parentData:n,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?wa.errors:o.concat(wa.errors),s=o.length);var f=m===s;u=u||f,f&&p!==!0&&(p=p||{},p.typeName=!0,p.statementId=!0,p.props=!0);let h=s;ya(e,{instancePath:t,parentData:n,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?ya.errors:o.concat(ya.errors),s=o.length);var f=h===s;u=u||f,f&&p!==!0&&(p=p||{},p.typeName=!0,p.statementId=!0,p.props=!0);let g=s;ba(e,{instancePath:t,parentData:n,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?ba.errors:o.concat(ba.errors),s=o.length);var f=g===s;u=u||f,f&&p!==!0&&(p=p||{},p.typeName=!0,p.statementId=!0,p.props=!0);let _=s;xa(e,{instancePath:t,parentData:n,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?xa.errors:o.concat(xa.errors),s=o.length);var f=_===s;u=u||f,f&&p!==!0&&(p=p||{},p.typeName=!0,p.statementId=!0,p.props=!0);let v=s;Sa(e,{instancePath:t,parentData:n,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?Sa.errors:o.concat(Sa.errors),s=o.length);var f=v===s;u=u||f,f&&p!==!0&&(p=p||{},p.typeName=!0,p.statementId=!0,p.props=!0);let y=s;K(e,{instancePath:t,parentData:n,parentDataProperty:r,rootData:i,dynamicAnchors:a})||(o=o===null?K.errors:o.concat(K.errors),s=o.length);var f=y===s;if(u=u||f,f&&p!==!0&&(p=p||{},p.typeName=!0,p.statementId=!0,p.props=!0),u)s=l,o!==null&&(l?o.length=l:o=null);else{let e={instancePath:t,schemaPath:`#/anyOf`,keyword:`anyOf`,params:{}};return o===null?o=[e]:o.push(e),s++,Ea.errors=o,!1}return Ea.errors=o,c.props=p,s===0}Ea.evaluated={dynamicProps:!0,dynamicItems:!1};function Da(e){switch(e.k){case`StateRef`:case`RuntimeRef`:case`BinOp`:case`UnaryOp`:case`Ternary`:case`Member`:case`Index`:case`Assign`:return!0;default:return!1}}const Oa=/* @__PURE__ */ new Set([`Comp`,`Ref`,`StateRef`,`RuntimeRef`,`BinOp`,`UnaryOp`,`Ternary`,`Member`,`Index`,`Assign`,`Str`,`Num`,`Bool`,`Null`,`Arr`,`Obj`,`Ph`]);function ka(e){return!e||typeof e!=`object`||Array.isArray(e)?!1:Oa.has(e.k)}function Aa(e,t){let n=e=>{switch(t(e),e.k){case`Comp`:e.args.forEach(n),Object.values(e.mappedProps??{}).forEach(n);break;case`Arr`:e.els.forEach(n);break;case`Obj`:e.entries.forEach(([,e])=>n(e));break;case`BinOp`:n(e.left),n(e.right);break;case`UnaryOp`:n(e.operand);break;case`Ternary`:n(e.cond),n(e.then),n(e.else);break;case`Member`:n(e.obj);break;case`Index`:n(e.obj),n(e.index);break;case`Assign`:n(e.value)}};n(e)}function ja(e){return e==null?{k:`Null`}:typeof e==`string`?{k:`Str`,v:e}:typeof e==`number`?{k:`Num`,v:e}:typeof e==`boolean`?{k:`Bool`,v:e}:Array.isArray(e)?{k:`Arr`,els:e.map(ja)}:typeof e==`object`?{k:`Obj`,entries:Object.entries(e).map(([e,t])=>[e,ja(t)])}:{k:`Null`}}function Ma(e){switch(e.k){case`Str`:case`Num`:case`Bool`:return{v:e.v};case`Null`:return{v:null};case`Arr`:{let t=[];for(let n of e.els){let e=Ma(n);if(!e)return;t.push(e.v)}return{v:t}}case`Obj`:{let t={};for(let[n,r]of e.entries){let e=Ma(r);if(!e)return;t[n]=e.v}return{v:t}}default:return}}const Na=/* @__PURE__ */ new Map([[`Count`,{kind:`function`,params:[{name:`array`,required:!1}],builtin:!0}],[`First`,{kind:`function`,params:[{name:`array`,required:!1}],builtin:!0}],[`Last`,{kind:`function`,params:[{name:`array`,required:!1}],builtin:!0}],[`Sum`,{kind:`function`,params:[{name:`numbers`,required:!1}],builtin:!0}],[`Avg`,{kind:`function`,params:[{name:`numbers`,required:!1}],builtin:!0}],[`Min`,{kind:`function`,params:[{name:`numbers`,required:!1}],builtin:!0}],[`Max`,{kind:`function`,params:[{name:`numbers`,required:!1}],builtin:!0}],[`Sort`,{kind:`function`,params:[{name:`array`,required:!1},{name:`field`,required:!1},{name:`direction`,required:!1}],builtin:!0}],[`Filter`,{kind:`function`,params:[{name:`array`,required:!1},{name:`field`,required:!1},{name:`operator`,required:!1},{name:`value`,required:!1}],builtin:!0}],[`Round`,{kind:`function`,params:[{name:`number`,required:!1},{name:`decimals`,required:!1}],builtin:!0}],[`Abs`,{kind:`function`,params:[{name:`number`,required:!1}],builtin:!0}],[`Floor`,{kind:`function`,params:[{name:`number`,required:!1}],builtin:!0}],[`Ceil`,{kind:`function`,params:[{name:`number`,required:!1}],builtin:!0}],[`Each`,{kind:`function`,params:[{name:`array`,required:!1},{name:`varName`,required:!1},{name:`template`,required:!1}],builtin:!0,lazy:!0}],[`Run`,{kind:`action`,params:[{name:`ref`,required:!1}],builtin:!0,lazy:!0}],[`ToAssistant`,{kind:`action`,params:[{name:`message`,required:!1},{name:`context`,required:!1}],builtin:!0}],[`OpenUrl`,{kind:`action`,params:[{name:`url`,required:!1}],builtin:!0}],[`Set`,{kind:`action`,params:[{name:`variable`,required:!1},{name:`value`,required:!1}],builtin:!0,lazy:!0}],[`Reset`,{kind:`action`,params:[{name:`variable`,required:!1}],builtin:!0,lazy:!0}],[`Action`,{kind:`action`,params:[{name:`steps`,required:!0}],builtin:!0,lazy:!0}]]),Pa={ActionExpression:!0,OpenUrl:!0,ToAssistant:!0},Fa={Query:`Query`,Mutation:`Mutation`};function Ia(e){return e?.callDefs??Na}function La(e){return Na.has(e)}function Ra(e){return e in Fa}var q;(function(e){e[e.Newline=0]=`Newline`,e[e.LParen=1]=`LParen`,e[e.RParen=2]=`RParen`,e[e.LBrack=3]=`LBrack`,e[e.RBrack=4]=`RBrack`,e[e.LBrace=5]=`LBrace`,e[e.RBrace=6]=`RBrace`,e[e.Comma=7]=`Comma`,e[e.Colon=8]=`Colon`,e[e.Equals=9]=`Equals`,e[e.True=10]=`True`,e[e.False=11]=`False`,e[e.Null=12]=`Null`,e[e.EOF=13]=`EOF`,e[e.Str=14]=`Str`,e[e.Num=15]=`Num`,e[e.Ident=16]=`Ident`,e[e.Type=17]=`Type`,e[e.StateVar=18]=`StateVar`,e[e.Dot=19]=`Dot`,e[e.Plus=20]=`Plus`,e[e.Minus=21]=`Minus`,e[e.Star=22]=`Star`,e[e.Slash=23]=`Slash`,e[e.Percent=24]=`Percent`,e[e.EqEq=25]=`EqEq`,e[e.NotEq=26]=`NotEq`,e[e.Greater=27]=`Greater`,e[e.Less=28]=`Less`,e[e.GreaterEq=29]=`GreaterEq`,e[e.LessEq=30]=`LessEq`,e[e.And=31]=`And`,e[e.Or=32]=`Or`,e[e.Not=33]=`Not`,e[e.Question=34]=`Question`,e[e.BuiltinCall=35]=`BuiltinCall`})(q||(q={}));function za(e){let t=0,n=()=>e[t]??{t:q.EOF},r=()=>{let e=n();return t++,e},i=e=>{n().t===e&&t++};function a(e){switch(e.t){case q.Question:return 1;case q.Or:return 2;case q.And:return 3;case q.EqEq:case q.NotEq:return 4;case q.Greater:case q.Less:case q.GreaterEq:case q.LessEq:return 5;case q.Plus:case q.Minus:return 6;case q.Star:case q.Slash:case q.Percent:return 7;case q.Dot:case q.LBrack:return 9;default:return 0}}function o(e=0){let t=s();for(;a(n())>e;)t=c(t);return t}function s(){let a=n();if(a.t===q.Str)return r(),{k:`Str`,v:a.v};if(a.t===q.Num)return r(),{k:`Num`,v:a.v};if(a.t===q.True)return r(),{k:`Bool`,v:!0};if(a.t===q.False)return r(),{k:`Bool`,v:!1};if(a.t===q.Null)return r(),{k:`Null`};if(a.t===q.LBrack)return u();if(a.t===q.LBrace)return d();if(a.t===q.StateVar){let e=a.v;return r(),n().t===q.Equals?(r(),{k:`Assign`,target:e,value:o(0)}):{k:`StateRef`,n:e}}if(a.t===q.Type){let n=a.v;return e[t+1]?.t===q.LParen&&(!La(n)||n===`Action`)?l():(r(),{k:`Ref`,n})}if(a.t===q.BuiltinCall){if(e[t+1]?.t===q.LParen){let e=l();return e.k===`Comp`&&!La(e.name)&&(e.fn=!0),e}return r(),{k:`Ref`,n:a.v}}if(a.t===q.Ident)return r(),{k:`Ref`,n:a.v};if(a.t===q.Not)return r(),{k:`UnaryOp`,op:`!`,operand:o(8)};if(a.t===q.Minus)return r(),{k:`UnaryOp`,op:`-`,operand:o(8)};if(a.t===q.LParen){r();let e=o(0);return i(q.RParen),e}return r(),{k:`Null`}}function c(e){let t=n();if(t.t===q.Plus)return r(),{k:`BinOp`,op:`+`,left:e,right:o(6)};if(t.t===q.Minus)return r(),{k:`BinOp`,op:`-`,left:e,right:o(6)};if(t.t===q.Star)return r(),{k:`BinOp`,op:`*`,left:e,right:o(7)};if(t.t===q.Slash)return r(),{k:`BinOp`,op:`/`,left:e,right:o(7)};if(t.t===q.Percent)return r(),{k:`BinOp`,op:`%`,left:e,right:o(7)};if(t.t===q.EqEq)return r(),{k:`BinOp`,op:`==`,left:e,right:o(4)};if(t.t===q.NotEq)return r(),{k:`BinOp`,op:`!=`,left:e,right:o(4)};if(t.t===q.Greater)return r(),{k:`BinOp`,op:`>`,left:e,right:o(5)};if(t.t===q.Less)return r(),{k:`BinOp`,op:`<`,left:e,right:o(5)};if(t.t===q.GreaterEq)return r(),{k:`BinOp`,op:`>=`,left:e,right:o(5)};if(t.t===q.LessEq)return r(),{k:`BinOp`,op:`<=`,left:e,right:o(5)};if(t.t===q.And)return r(),{k:`BinOp`,op:`&&`,left:e,right:o(3)};if(t.t===q.Or)return r(),{k:`BinOp`,op:`||`,left:e,right:o(2)};if(t.t===q.Question){r();let t=o(0);return i(q.Colon),{k:`Ternary`,cond:e,then:t,else:o(0)}}if(t.t===q.Dot){r();let t=n();return{k:`Member`,obj:e,field:t.t===q.Ident||t.t===q.Type||t.t===q.Str||t.t===q.Num?(r(),String(t.v)):t.t===q.StateVar?(r(),t.v.replace(/^\$/,``)):(r(),`?`)}}if(t.t===q.LBrack){r();let t=o(0);return i(q.RBrack),{k:`Index`,obj:e,index:t}}return e}function l(){let e=n().v;r(),i(q.LParen);let t=[];for(;n().t!==q.RParen&&n().t!==q.EOF;)t.push(o(0)),n().t===q.Comma&&r();return i(q.RParen),{k:`Comp`,name:e,args:t}}function u(){r();let e=[];for(;n().t!==q.RBrack&&n().t!==q.EOF;)e.push(o(0)),n().t===q.Comma&&r();return i(q.RBrack),{k:`Arr`,els:e}}function d(){r();let e=[];for(;n().t!==q.RBrace&&n().t!==q.EOF;){let t=n(),a=t.t===q.Ident||t.t===q.Str||t.t===q.Type||t.t===q.Num?(r(),String(t.v)):t.t===q.StateVar?(r(),t.v.replace(/^\$/,``)):(r(),`?`);i(q.Colon),e.push([a,o(0)]),n().t===q.Comma&&r()}return i(q.RBrace),{k:`Obj`,entries:e}}return o(0)}function Ba(e){let t=[],n=0,r=e.length;for(;n<r;){for(;n<r&&(e[n]===` `||e[n]===` `||e[n]===`\r`);)n++;if(n>=r)break;let i=e[n];if(i===`
40
40
  `){t.push({t:q.Newline}),n++;continue}if(i===`(`){t.push({t:q.LParen}),n++;continue}if(i===`)`){t.push({t:q.RParen}),n++;continue}if(i===`[`){t.push({t:q.LBrack}),n++;continue}if(i===`]`){t.push({t:q.RBrack}),n++;continue}if(i===`{`){t.push({t:q.LBrace}),n++;continue}if(i===`}`){t.push({t:q.RBrace}),n++;continue}if(i===`,`){t.push({t:q.Comma}),n++;continue}if(i===`:`){t.push({t:q.Colon}),n++;continue}if(i===`=`){n+1<r&&e[n+1]===`=`?(t.push({t:q.EqEq}),n+=2):(t.push({t:q.Equals}),n++);continue}if(i===`!`){n+1<r&&e[n+1]===`=`?(t.push({t:q.NotEq}),n+=2):(t.push({t:q.Not}),n++);continue}if(i===`>`){n+1<r&&e[n+1]===`=`?(t.push({t:q.GreaterEq}),n+=2):(t.push({t:q.Greater}),n++);continue}if(i===`<`){n+1<r&&e[n+1]===`=`?(t.push({t:q.LessEq}),n+=2):(t.push({t:q.Less}),n++);continue}if(i===`&`){n+1<r&&e[n+1]===`&`?(t.push({t:q.And}),n+=2):(t.push({t:q.And}),n++);continue}if(i===`|`){n+1<r&&e[n+1]===`|`?(t.push({t:q.Or}),n+=2):(t.push({t:q.Or}),n++);continue}if(i===`.`){t.push({t:q.Dot}),n++;continue}if(i===`?`){t.push({t:q.Question}),n++;continue}if(i===`+`){t.push({t:q.Plus}),n++;continue}if(i===`*`){t.push({t:q.Star}),n++;continue}if(i===`/`){t.push({t:q.Slash}),n++;continue}if(i===`%`){t.push({t:q.Percent}),n++;continue}if(i===`"`){let i=n;n++;let a=!1;for(;n<r;)if(e[n]===`\\`)n+=2;else if(e[n]===`"`){n++,a=!0;break}else n++;let o=e.slice(i,n);try{let e=a?o:o+`"`;t.push({t:q.Str,v:JSON.parse(e)})}catch{let e=o.replace(/^"|"$/g,``);t.push({t:q.Str,v:e})}continue}if(i===`'`){n++;let i=``;for(;n<r;)if(e[n]===`\\`){if(n++,n<r){let t=e[n];i+=t===`'`?`'`:t===`\\`?`\\`:t===`n`?`
41
- `:t===`t`?` `:t,n++}}else if(e[n]===`'`){n++;break}else i+=e[n],n++;t.push({t:q.Str,v:i});continue}if(i===`-`){let i=t.length>0?t[t.length-1]:null;if(!((i==null||i.t!==q.Num&&i.t!==q.Str&&i.t!==q.Ident&&i.t!==q.Type&&i.t!==q.RParen&&i.t!==q.RBrack&&i.t!==q.True&&i.t!==q.False&&i.t!==q.Null&&i.t!==q.StateVar&&i.t!==q.BuiltinCall)&&n+1<r&&e[n+1]>=`0`&&e[n+1]<=`9`)){t.push({t:q.Minus}),n++;continue}}let a=i>=`0`&&i<=`9`,o=i===`-`&&n+1<r&&e[n+1]>=`0`&&e[n+1]<=`9`;if(a||o){let i=n;for(e[n]===`-`&&n++;n<r&&e[n]>=`0`&&e[n]<=`9`;)n++;if(n<r&&e[n]===`.`&&n+1<r&&e[n+1]>=`0`&&e[n+1]<=`9`)for(n++;n<r&&e[n]>=`0`&&e[n]<=`9`;)n++;if(n<r&&(e[n]===`e`||e[n]===`E`))for(n++,n<r&&(e[n]===`+`||e[n]===`-`)&&n++;n<r&&e[n]>=`0`&&e[n]<=`9`;)n++;t.push({t:q.Num,v:+e.slice(i,n)})}else if(i===`$`&&n+1<r&&(e[n+1]>=`a`&&e[n+1]<=`z`||e[n+1]>=`A`&&e[n+1]<=`Z`||e[n+1]===`_`)){let i=n;for(n++;n<r&&(e[n]>=`a`&&e[n]<=`z`||e[n]>=`A`&&e[n]<=`Z`||e[n]>=`0`&&e[n]<=`9`||e[n]===`_`);)n++;t.push({t:q.StateVar,v:e.slice(i,n)})}else if(i>=`a`&&i<=`z`||i>=`A`&&i<=`Z`||i===`_`){let a=n;for(;n<r&&(e[n]>=`a`&&e[n]<=`z`||e[n]>=`A`&&e[n]<=`Z`||e[n]>=`0`&&e[n]<=`9`||e[n]===`_`);)n++;let o=e.slice(a,n);if(o===`true`){t.push({t:q.True});continue}if(o===`false`){t.push({t:q.False});continue}if(o===`null`){t.push({t:q.Null});continue}let s=i>=`A`&&i<=`Z`?q.Type:q.Ident;t.push({t:s,v:o})}else if(i===`@`&&n+1<r&&(e[n+1]>=`a`&&e[n+1]<=`z`||e[n+1]>=`A`&&e[n+1]<=`Z`||e[n+1]===`_`)){n++;let i=n;for(;n<r&&(e[n]>=`a`&&e[n]<=`z`||e[n]>=`A`&&e[n]<=`Z`||e[n]>=`0`&&e[n]<=`9`||e[n]===`_`);)n++;t.push({t:q.BuiltinCall,v:e.slice(i,n)})}else n++}return t.push({t:q.EOF}),t}function Xi(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return t.type===`element`&&typeof t.typeName==`string`&&typeof t.props==`object`&&t.props!==null&&typeof t.partial==`boolean`}var Zi;(function(e){e.ContinueConversation=`continue_conversation`,e.OpenUrl=`open_url`})(Zi||(Zi={}));const Qi={},$i=[];function ea(e){return Array.isArray(e)?`array`:typeof e}function ta(e){return typeof e.$ref==`string`?e.$ref.split(`/`).pop():void 0}function na(e){return`$ref`in e||`anyOf`in e||`oneOf`in e||`allOf`in e}function ra(e){if(Array.isArray(e.enum))return{enumValues:e.enum};if(`const`in e)return{enumValues:[e.const]};switch(e.type){case`string`:return{expectedType:`string`};case`number`:case`integer`:return{expectedType:`number`};case`boolean`:return{expectedType:`boolean`};default:return{}}}function ia(e){if(e&&typeof e==`object`&&!Array.isArray(e))return e.default}function aa(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=ta(t);if(n)return n;let r=ra(t);return r.enumValues?r.enumValues.map(e=>JSON.stringify(e)).join(`|`):r.expectedType?r.expectedType:typeof t.type==`string`?t.type:void 0}function oa(e,t){return`${e}(${t.map(e=>{let t=aa(e.schema),n=e.required?`${e.name}*`:e.name;return t?`${n}: ${t}`:n}).join(`, `)})`}function sa(e,t){let n=typeof e;return t.enumValues?t.enumValues.includes(e)?null:{expected:`one of [${t.enumValues.map(e=>JSON.stringify(e)).join(`, `)}]`,actual:ea(e)}:t.expectedType&&t.expectedType!==n?{expected:t.expectedType,actual:ea(e)}:null}function ca(e,t,n){switch(n.code){case`type-mismatch`:return`field "${t}" expects ${n.expected} but got ${n.actual}`;case`pruned-value`:return`field "${t}" lost an unresolved or invalid value`;case`missing-required`:return`missing required field "${t}"${n.signature?` — signature: ${n.signature}`:``}`;case`null-required`:return`required field "${t}" cannot be null${n.signature?` — signature: ${n.signature}`:``}`;case`unknown-component`:return`Unknown component "${e}" — not found in catalog or builtins${n.available?.length?`. Available components: ${n.available.join(`, `)}`:``}`;case`inline-reserved`:return`${e}() must be declared as a top-level statement, not used inline as a value`;case`excess-args`:return`${e} takes ${n.declared} arg(s), got ${n.got} (${n.got-n.declared} excess dropped)`;case`unknown-function`:return`Unknown function "@${e}": not a built-in or action step. The call evaluates to null`;case`no-root`:return n.reason===`not-component`?`root does not evaluate to a component`:n.reason===`fallback`?`No root statement. Rendering the first statement that calls the root component ${e}`:e?`No root statement, and no statement calls the root component ${e}`:`No root statement`}}function la(e,t,n,r){e.errors.push({code:r.code,component:t,path:n,message:ca(t,n,r),statementId:e.currentStatementId,...r.code===`no-root`&&r.reason===`fallback`&&{severity:`warning`}})}const ua=Symbol(`invalid`);function da(e,t){return t===void 0?e?ua:void 0:t}function fa(e,t,n,r,i){return na(t)?!1:typeof t.type==`string`||Array.isArray(t.enum)||`const`in t?(la(i,n,r,{code:`type-mismatch`,expected:typeof t.type==`string`?t.type:`a literal value`,actual:`component "${e.typeName}"`}),!0):!1}function pa(e){return(e.anyOf??e.oneOf??[e]).map(ta)}function ma(e,t){let n=pa(e);return n.length>0&&n.every(e=>e!==void 0&&t.cat?.has(e))}function ha(e,t,n,r,i){if(typeof e!=`object`||Array.isArray(e))return la(i,n,r,{code:`type-mismatch`,expected:`object`,actual:ea(e)}),ua;let a=e,o,s=t.properties&&typeof t.properties==`object`?t.properties:Qi,c=Array.isArray(t.required)?t.required:$i,l=!1;if(!i.partial)for(let e of c){let t=e in a;if(!t||a[e]==null){let c=ia(s[e]);if(c!==void 0){(o??(o={...a}))[e]=c;continue}la(i,n,`${r}/${e}`,{code:t?`null-required`:`missing-required`}),l=!0}}for(let e of Object.keys(s)){if(!(e in a))continue;let t=s[e],u=va(a[e],t,n,`${r}/${e}`,i);u===ua&&(u=da(c.includes(e),ia(t)),u===ua)?l=!0:u!==a[e]&&(o??(o={...a}),u===void 0?delete o[e]:o[e]=u)}return l?ua:o??a}function ga(e,t,n,r,i){if(!Array.isArray(e))return la(i,n,r,{code:`type-mismatch`,expected:`array`,actual:ea(e)}),ua;let a=t.items;if(!a||typeof a!=`object`||Array.isArray(a))return e;let o;for(let t=0;t<e.length;t++){let s=va(e[t],a,n,`${r}/${t}`,i);s!==e[t]&&!o&&(o=e.slice(0,t)),o&&s!==ua&&o.push(s)}return o??e}function _a(e,t,n,r,i){let a=ra(t);if(a.expectedType==null&&a.enumValues==null||a.enumValues&&i.partial)return!1;let o=sa(e,a);return o?(la(i,n,r,{code:`type-mismatch`,...o}),!0):!1}function va(e,t,n,r,i){if(!t||typeof t!=`object`||Array.isArray(t))return e;let a=t;if(e==null||Ri(e))return e;if(Xi(e))return fa(e,a,n,r,i)?ua:e;if(na(a))return ma(a,i)?(la(i,n,r,{code:`type-mismatch`,expected:pa(a).join(` | `),actual:Array.isArray(e)?`array`:typeof e==`object`?`plain object`:typeof e}),ua):e;let o=a.type;return o===`object`?ha(e,a,n,r,i):o===`array`?ga(e,a,n,r,i):_a(e,a,n,r,i)?ua:e}function ya(e){if(typeof e!=`object`||!e)return!1;if(Ri(e))return!0;if(Array.isArray(e))return e.some(ya);if(Xi(e))return Object.values(e.props).some(ya);let t=e;return Array.isArray(t.steps)?!0:Object.values(t).some(ya)}function ba(e,t,n){if(t.visited.has(e)||!t.syms.has(e))return t.unres.push(e),n===`expr`?{k:`Ph`,n:e}:null;let r=t.syms.get(e);if(t.unreached?.delete(e),r.k===`Comp`&&qi(r.name))return{k:`RuntimeRef`,n:e,refType:r.name===Wi.Mutation?`mutation`:`query`};t.visited.add(e);let i=t.currentStatementId;t.currentStatementId=e;try{let i=n===`value`?ka(r,t):Oa(r,t);return n===`value`&&Xi(i)&&(i.statementId=e),i}finally{t.currentStatementId=i,t.visited.delete(e)}}function xa(e,t){return Gi(t.cat).has(e)||qi(e)}function Sa(e,t){let n={};for(let r=0;r<t.length&&r<e.length;r++)n[t[r].name]=e[r];return n}function Ca(e,t,n,r){let{params:i}=n;t.length>i.length&&la(r,e,``,{code:`excess-args`,declared:i.length,got:t.length});let a=Sa(t,i),o=!1,s=r.errors.length;for(let t of i){let n=a[t.name],s=n?Vi(n):{v:void 0};if(!s)continue;if(s.v==null){if(!t.required||t.defaultValue!==void 0)continue;la(r,e,`/${t.name}`,{code:n?`null-required`:`missing-required`,signature:oa(e,i)}),o=!0;continue}let c=va(s.v,t.schema,e,`/${t.name}`,r);c===ua&&(c=da(t.required,t.defaultValue)),c===ua?o=!0:c===void 0?delete a[t.name]:c!==s.v&&(a[t.name]=Bi(c))}return n.kind===`action`&&r.errors.length>s&&(o=!0),o?null:a}function wa(e,t,n){let r=e.args.map(n),i=Gi(t.cat).get(e.name);if(!i||i.lazy)return{...e,args:r};let a=i.builtin?Sa(r,i.params):Ca(e.name,r,i,t);return a?{...e,args:r,mappedProps:a}:i.kind===`action`?{k:`Comp`,name:`Action`,args:[{k:`Arr`,els:[]}]}:{k:`Null`}}function Ta(e,t,n){let r=t.currentStatementId;t.currentStatementId=n;let i=/* @__PURE__ */ new Set;for(let n of e)zi(n,e=>{if(e.k!==`Comp`||i.has(e))return;i.add(e);let n=Gi(t.cat).get(e.name);n&&!n.lazy&&(e.mappedProps=(n.builtin?null:Ca(e.name,e.args,n,t))??Sa(e.args,n.params))});t.currentStatementId=r}function Ea(e,t,n){let r=Gi(t.cat).get(e.name);if(r?.kind!==`function`||!r.lazy||e.args.length<3)return null;let i=e.args[1],a=i.k===`Ref`?i.n:i.k===`Str`?i.v:null;if(!a)return null;let o=new Set(n);o.add(a);let s=e.args.map((e,n)=>n===1?e:Da(e,t,o));return{...e,args:s}}function Da(e,t,n){switch(e.k){case`Ref`:return n.has(e.n)?e:ba(e.n,t,`expr`);case`Ph`:return e;case`Comp`:{if(e.fn&&!xa(e.name,t))return la(t,e.name,``,{code:`unknown-function`}),{k:`Null`};let r=Ea(e,t,n);if(r)return r;if(xa(e.name,t))return wa(e,t,e=>Da(e,t,n));let i=e.args.map(e=>Da(e,t,n)),a=t.cat?.get(e.name);if(a){let t={};for(let e=0;e<a.params.length&&e<i.length;e++)t[a.params[e].name]=i[e];return{...e,args:i,mappedProps:t}}return la(t,e.name,``,{code:`unknown-component`,available:t.cat&&[...t.cat.keys()]}),{...e,args:i}}case`Arr`:return{...e,els:e.els.map(e=>Da(e,t,n))};case`Obj`:return{...e,entries:e.entries.map(([e,r])=>[e,Da(r,t,n)])};case`BinOp`:return{...e,left:Da(e.left,t,n),right:Da(e.right,t,n)};case`UnaryOp`:return{...e,operand:Da(e.operand,t,n)};case`Ternary`:return{...e,cond:Da(e.cond,t,n),then:Da(e.then,t,n),else:Da(e.else,t,n)};case`Member`:return{...e,obj:Da(e.obj,t,n)};case`Index`:return{...e,obj:Da(e.obj,t,n),index:Da(e.index,t,n)};case`Assign`:return{...e,value:Da(e.value,t,n)};default:return e}}function Oa(e,t){return Da(e,t,/* @__PURE__ */ new Set)}function ka(e,t){switch(e.k){case`Ref`:return ba(e.n,t,`value`);case`Str`:return e.v;case`Num`:return e.v;case`Bool`:return e.v;case`Null`:return null;case`Ph`:return null;case`Arr`:{let n=[];for(let r of e.els){if(r.k===`Ph`){t.prunedValues++;continue}let e=ka(r,t);e===null&&(r.k===`Comp`||r.k===`Ref`)?t.prunedValues++:n.push(e)}return n}case`Obj`:{let n={};for(let[r,i]of e.entries)n[r]=ka(i,t);return n}case`Comp`:{let{name:n,args:r}=e;if(e.fn&&!xa(n,t))return la(t,n,``,{code:`unknown-function`}),null;if(qi(n))return la(t,n,``,{code:`inline-reserved`}),null;if(xa(n,t))return Ea(e,t,/* @__PURE__ */ new Set)||wa(e,t,e=>Oa(e,t));let i=t.cat?.get(n),a={};if(i){let e=!1;for(let o=0;o<i.params.length&&o<r.length;o++){let s=i.params[o],c=t.prunedValues,l=ka(r[o],t);if(t.prunedValues>c&&la(t,n,`/${s.name}`,{code:`pruned-value`}),a[s.name]=l,s.schema===void 0)continue;if(l==null&&s.defaultValue!==void 0){la(t,n,`/${s.name}`,{code:`type-mismatch`,expected:aa(s.schema)??`a defined value`,actual:l===null?`null`:`undefined`}),a[s.name]=s.defaultValue,t.prunedValues=c;continue}let u=va(l,s.schema,n,`/${s.name}`,t);u===ua&&(u=da(s.required,s.defaultValue),s.defaultValue!==void 0&&(t.prunedValues=c),u===ua?e=!0:u===void 0&&delete a[s.name]),u!==ua&&u!==void 0&&(a[s.name]=u)}r.length>i.params.length&&la(t,n,``,{code:`excess-args`,declared:i.params.length,got:r.length});let o=i.params.filter(e=>e.required&&(!(e.name in a)||a[e.name]===null));if(o.length){let e=o.filter(e=>e.defaultValue===void 0||(la(t,n,`/${e.name}`,{code:e.name in a?`null-required`:`missing-required`}),a[e.name]=e.defaultValue,!1));if(e.length){for(let r of e)la(t,n,`/${r.name}`,{code:r.name in a?`null-required`:`missing-required`,signature:oa(n,i.params)});return null}}if(e)return null}else return la(t,n,``,{code:`unknown-component`,available:t.cat&&[...t.cat.keys()]}),null;let o=Object.values(a).some(e=>ya(e));return{type:`element`,typeName:n,props:a,partial:t.partial,hasDynamicProps:o}}default:return Ii(e)?Oa(e,t):e}}function Aa(e){let t=[],n=!1,r=!1;for(let i=0;i<e.length;i++){let a=e[i];r?r=!1:a===`\\`&&n?r=!0:n?a===n&&(n=!1):a===`"`||a===`'`?n=a:a===`(`||a===`[`||a===`{`?t.push(a):(a===`)`&&t[t.length-1]===`(`||a===`]`&&t[t.length-1]===`[`||a===`}`&&t[t.length-1]===`{`)&&t.pop()}if(!(n||t.length>0))return{text:e,wasIncomplete:!1};let i=e;n&&(r&&(i+=`\\`),i+=n);for(let e=t.length-1;e>=0;e--)i+=t[e]===`(`?`)`:t[e]===`[`?`]`:`}`;return{text:i,wasIncomplete:!0}}function ja(e){let t=[],n=0;for(;n<e.length;){for(;n<e.length&&e[n].t===q.Newline;)n++;if(n>=e.length||e[n].t===q.EOF)break;let r=e[n];if(r.t!==q.Ident&&r.t!==q.Type&&r.t!==q.StateVar){for(;n<e.length&&e[n].t!==q.Newline&&e[n].t!==q.EOF;)n++;continue}let i=r.v,a=r.t;if(n++,n>=e.length||e[n].t!==q.Equals){for(;n<e.length&&e[n].t!==q.Newline&&e[n].t!==q.EOF;)n++;continue}n++;let o=[],s=0,c=0;for(;n<e.length&&e[n].t!==q.EOF;){let t=e[n].t;if(t===q.Newline&&s<=0&&c<=0){let t=n+1;for(;t<e.length&&e[t].t===q.Newline;)t++;let r=t<e.length?e[t].t:q.EOF;if(r===q.Question||r===q.Colon&&c>0){n++;continue}break}t===q.Newline?n++:(t===q.LParen||t===q.LBrack||t===q.LBrace?s++:(t===q.RParen||t===q.RBrack||t===q.RBrace)&&s>0?s--:t===q.Question&&s===0?c++:t===q.Colon&&s===0&&c>0&&c--,o.push(e[n++]))}o.length&&t.push({id:i,idTokenType:a,tokens:o})}return t}function Ma(e=!0){return{root:null,meta:{incomplete:e,unresolved:[],orphaned:[],statementCount:0,errors:[]},stateDeclarations:{},queryStatements:[],mutationStatements:[]}}function Na(e){if(!Ri(e))return[];let t=/* @__PURE__ */ new Set;return zi(e,e=>{e.k===`StateRef`&&t.add(e.n)}),[...t]}function Pa(e,t){if(t.k===`Comp`&&t.name===Wi.Query){let n=Na(t.args[1]);return{kind:`query`,id:e.id,call:{callee:Wi.Query,args:t.args},expr:t,deps:n.length>0?n:void 0}}return t.k===`Comp`&&t.name===Wi.Mutation?{kind:`mutation`,id:e.id,call:{callee:Wi.Mutation,args:t.args},expr:t}:e.idTokenType===q.StateVar?{kind:`state`,id:e.id,init:t}:{kind:`value`,id:e.id,expr:t}}function Fa(e,t,n){let r={},i=[],a=[];for(let n of e)switch(n.kind){case`state`:r[n.id]=ka(n.init,t);break;case`query`:Ta(n.call.args,t,n.id),i.push({statementId:n.id,toolAST:n.call.args[0]??null,argsAST:n.call.args[1]??null,defaultsAST:n.call.args[2]??null,refreshAST:n.call.args[3]??null,deps:n.deps,complete:!0});break;case`mutation`:Ta(n.call.args,t,n.id),a.push({statementId:n.id,toolAST:n.call.args[0]??null,argsAST:n.call.args[1]??null})}for(let t of e){let e=t.kind===`state`?[t.init]:t.kind===`value`?[t.expr]:t.kind===`query`||t.kind===`mutation`?t.call.args:[];for(let i of e)for(let e of Na(i))e===n?.name&&n.stmts.has(t)||e in r||(r[e]=null)}return{stateDeclarations:r,queryStatements:i,mutationStatements:a}}const Ia=`root`;function La(e){return e?.k===`Comp`&&!e.fn&&!Ki(e.name)&&!qi(e.name)}function Ra(e,t){if(e.has(Ia))return{id:Ia,fallback:!1};for(let n of e.values())if(n.kind===`value`&&La(n.expr)&&n.expr.name===t)return{id:n.id,fallback:!0};return null}function za(e,t){let n=/* @__PURE__ */ new Set;for(;e?.k===`Ref`&&!n.has(e.n);)n.add(e.n),e=t.get(e.n);return La(e)}function Ba(e){let t=!1;return zi(e,e=>{La(e)&&(t=!0)}),t}function Va(e,t,n,r,i,a,o){let s=Ra(e,a),c=/* @__PURE__ */ new Map;for(let[t,n]of e)c.set(t,n.kind===`state`?n.init:n.expr);let l=[],u=[],d=/* @__PURE__ */ new Set;for(let[t,n]of e)t!==s?.id&&n.kind!==`state`&&n.kind!==`query`&&n.kind!==`mutation`&&d.add(t);let f={syms:c,cat:i,errors:u,unres:l,prunedValues:0,visited:/* @__PURE__ */ new Set,partial:n,currentStatementId:s?.id,unreached:d},p=null,m;if(s){let e=ka(c.get(s.id),f);Xi(e)?(p=e,p.statementId=s.id):Ri(e)&&Ba(e)&&(m=e)}let{stateDeclarations:h,queryStatements:g,mutationStatements:_}=Fa(t,f,o);f.currentStatementId=s?.id;let v=a??``;s?!p&&!m&&!za(c.get(s.id),c)?la(f,v,``,{code:`no-root`,reason:`not-component`}):s.fallback&&la(f,v,``,{code:`no-root`,reason:p?`fallback`:`missing`}):la(f,v,``,{code:`no-root`,reason:`missing`});let y=s?[...d]:[];return{root:p,...m?{rootExpression:m}:{},meta:{incomplete:n,unresolved:l,orphaned:y,statementCount:r,errors:u},stateDeclarations:h,queryStatements:g,mutationStatements:_}}function Ha(e,t){if(e[t]!==`"`)return t;let n=t+1;for(;n<e.length;){let t=e[n];if(t===`\\`)n+=2;else if(t===`"`)return n+1;else n++}return n}function Ua(e){let t=[],n=0;for(;n<e.length;){let r=-1;for(;n<e.length;){let t=Ha(e,n);if(t>n)n=t;else{if(e[n]==="`"&&n+1<e.length&&e[n+1]==="`"&&n+2<e.length&&e[n+2]==="`"){r=n;break}n++}}if(r===-1)break;let i=r+3;for(;i<e.length&&e[i]!==`
42
- `;)i++;if(i>=e.length){t.push(e.slice(r+3).replace(/^[^\n]*\n?/,``)),n=e.length;break}i++;let a=-1,o=i;for(;o<e.length;){let t=Ha(e,o);if(t>o)o=t;else{if(e[o]==="`"&&o+1<e.length&&e[o+1]==="`"&&o+2<e.length&&e[o+2]==="`"){a=o;break}o++}}a===-1?(t.push(e.slice(i)),n=e.length):(t.push(e.slice(i,a)),n=a+3)}if(t.length>0)return t.join(`
41
+ `:t===`t`?` `:t,n++}}else if(e[n]===`'`){n++;break}else i+=e[n],n++;t.push({t:q.Str,v:i});continue}if(i===`-`){let i=t.length>0?t[t.length-1]:null;if(!((i==null||i.t!==q.Num&&i.t!==q.Str&&i.t!==q.Ident&&i.t!==q.Type&&i.t!==q.RParen&&i.t!==q.RBrack&&i.t!==q.True&&i.t!==q.False&&i.t!==q.Null&&i.t!==q.StateVar&&i.t!==q.BuiltinCall)&&n+1<r&&e[n+1]>=`0`&&e[n+1]<=`9`)){t.push({t:q.Minus}),n++;continue}}let a=i>=`0`&&i<=`9`,o=i===`-`&&n+1<r&&e[n+1]>=`0`&&e[n+1]<=`9`;if(a||o){let i=n;for(e[n]===`-`&&n++;n<r&&e[n]>=`0`&&e[n]<=`9`;)n++;if(n<r&&e[n]===`.`&&n+1<r&&e[n+1]>=`0`&&e[n+1]<=`9`)for(n++;n<r&&e[n]>=`0`&&e[n]<=`9`;)n++;if(n<r&&(e[n]===`e`||e[n]===`E`))for(n++,n<r&&(e[n]===`+`||e[n]===`-`)&&n++;n<r&&e[n]>=`0`&&e[n]<=`9`;)n++;t.push({t:q.Num,v:+e.slice(i,n)})}else if(i===`$`&&n+1<r&&(e[n+1]>=`a`&&e[n+1]<=`z`||e[n+1]>=`A`&&e[n+1]<=`Z`||e[n+1]===`_`)){let i=n;for(n++;n<r&&(e[n]>=`a`&&e[n]<=`z`||e[n]>=`A`&&e[n]<=`Z`||e[n]>=`0`&&e[n]<=`9`||e[n]===`_`);)n++;t.push({t:q.StateVar,v:e.slice(i,n)})}else if(i>=`a`&&i<=`z`||i>=`A`&&i<=`Z`||i===`_`){let a=n;for(;n<r&&(e[n]>=`a`&&e[n]<=`z`||e[n]>=`A`&&e[n]<=`Z`||e[n]>=`0`&&e[n]<=`9`||e[n]===`_`);)n++;let o=e.slice(a,n);if(o===`true`){t.push({t:q.True});continue}if(o===`false`){t.push({t:q.False});continue}if(o===`null`){t.push({t:q.Null});continue}let s=i>=`A`&&i<=`Z`?q.Type:q.Ident;t.push({t:s,v:o})}else if(i===`@`&&n+1<r&&(e[n+1]>=`a`&&e[n+1]<=`z`||e[n+1]>=`A`&&e[n+1]<=`Z`||e[n+1]===`_`)){n++;let i=n;for(;n<r&&(e[n]>=`a`&&e[n]<=`z`||e[n]>=`A`&&e[n]<=`Z`||e[n]>=`0`&&e[n]<=`9`||e[n]===`_`);)n++;t.push({t:q.BuiltinCall,v:e.slice(i,n)})}else n++}return t.push({t:q.EOF}),t}function Va(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return t.type===`element`&&typeof t.typeName==`string`&&typeof t.props==`object`&&t.props!==null&&typeof t.partial==`boolean`}var Ha;(function(e){e.ContinueConversation=`continue_conversation`,e.OpenUrl=`open_url`})(Ha||(Ha={}));const Ua={},Wa=[];function Ga(e){return Array.isArray(e)?`array`:typeof e}function Ka(e){return typeof e.$ref==`string`?e.$ref.split(`/`).pop():void 0}function qa(e){return`$ref`in e||`anyOf`in e||`oneOf`in e||`allOf`in e}function Ja(e){if(Array.isArray(e.enum))return{enumValues:e.enum};if(`const`in e)return{enumValues:[e.const]};switch(e.type){case`string`:return{expectedType:`string`};case`number`:case`integer`:return{expectedType:`number`};case`boolean`:return{expectedType:`boolean`};default:return{}}}function Ya(e){if(e&&typeof e==`object`&&!Array.isArray(e))return e.default}function Xa(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=Ka(t);if(n)return n;let r=Ja(t);return r.enumValues?r.enumValues.map(e=>JSON.stringify(e)).join(`|`):r.expectedType?r.expectedType:typeof t.type==`string`?t.type:void 0}function Za(e,t){return`${e}(${t.map(e=>{let t=Xa(e.schema),n=e.required?`${e.name}*`:e.name;return t?`${n}: ${t}`:n}).join(`, `)})`}function Qa(e,t){let n=typeof e;return t.enumValues?t.enumValues.includes(e)?null:{expected:`one of [${t.enumValues.map(e=>JSON.stringify(e)).join(`, `)}]`,actual:Ga(e)}:t.expectedType&&t.expectedType!==n?{expected:t.expectedType,actual:Ga(e)}:null}function $a(e,t,n){switch(n.code){case`type-mismatch`:return`field "${t}" expects ${n.expected} but got ${n.actual}`;case`pruned-value`:return`field "${t}" lost an unresolved or invalid value`;case`missing-required`:return`missing required field "${t}"${n.signature?` — signature: ${n.signature}`:``}`;case`null-required`:return`required field "${t}" cannot be null${n.signature?` — signature: ${n.signature}`:``}`;case`unknown-component`:return`Unknown component "${e}" — not found in catalog or builtins${n.available?.length?`. Available components: ${n.available.join(`, `)}`:``}`;case`inline-reserved`:return`${e}() must be declared as a top-level statement, not used inline as a value`;case`excess-args`:return`${e} takes ${n.declared} arg(s), got ${n.got} (${n.got-n.declared} excess dropped)`;case`unknown-function`:return`Unknown function "@${e}": not a built-in or action step. The call evaluates to null`;case`no-root`:return n.reason===`not-component`?`root does not evaluate to a component`:n.reason===`fallback`?`No root statement. Rendering the first statement that calls the root component ${e}`:e?`No root statement, and no statement calls the root component ${e}`:`No root statement`}}function eo(e,t,n,r){e.errors.push({code:r.code,component:t,path:n,message:$a(t,n,r),statementId:e.currentStatementId,...r.code===`no-root`&&r.reason===`fallback`&&{severity:`warning`}})}const to=Symbol(`invalid`);function no(e,t){return t===void 0?e?to:void 0:t}function ro(e,t,n,r,i){return qa(t)?!1:typeof t.type==`string`||Array.isArray(t.enum)||`const`in t?(eo(i,n,r,{code:`type-mismatch`,expected:typeof t.type==`string`?t.type:`a literal value`,actual:`component "${e.typeName}"`}),!0):!1}function io(e){return(e.anyOf??e.oneOf??[e]).map(Ka)}function ao(e,t){let n=io(e);return n.length>0&&n.every(e=>e!==void 0&&t.cat?.has(e))}function oo(e,t,n,r,i){if(typeof e!=`object`||Array.isArray(e))return eo(i,n,r,{code:`type-mismatch`,expected:`object`,actual:Ga(e)}),to;let a=e,o,s=t.properties&&typeof t.properties==`object`?t.properties:Ua,c=Array.isArray(t.required)?t.required:Wa,l=!1;if(!i.partial)for(let e of c){let t=e in a;if(!t||a[e]==null){let c=Ya(s[e]);if(c!==void 0){(o??(o={...a}))[e]=c;continue}eo(i,n,`${r}/${e}`,{code:t?`null-required`:`missing-required`}),l=!0}}for(let e of Object.keys(s)){if(!(e in a))continue;let t=s[e],u=lo(a[e],t,n,`${r}/${e}`,i);u===to&&(u=no(c.includes(e),Ya(t)),u===to)?l=!0:u!==a[e]&&(o??(o={...a}),u===void 0?delete o[e]:o[e]=u)}return l?to:o??a}function so(e,t,n,r,i){if(!Array.isArray(e))return eo(i,n,r,{code:`type-mismatch`,expected:`array`,actual:Ga(e)}),to;let a=t.items;if(!a||typeof a!=`object`||Array.isArray(a))return e;let o;for(let t=0;t<e.length;t++){let s=lo(e[t],a,n,`${r}/${t}`,i);s!==e[t]&&!o&&(o=e.slice(0,t)),o&&s!==to&&o.push(s)}return o??e}function co(e,t,n,r,i){let a=Ja(t);if(a.expectedType==null&&a.enumValues==null||a.enumValues&&i.partial)return!1;let o=Qa(e,a);return o?(eo(i,n,r,{code:`type-mismatch`,...o}),!0):!1}function lo(e,t,n,r,i){if(!t||typeof t!=`object`||Array.isArray(t))return e;let a=t;if(e==null||ka(e))return e;if(Va(e))return ro(e,a,n,r,i)?to:e;if(qa(a))return ao(a,i)?(eo(i,n,r,{code:`type-mismatch`,expected:io(a).join(` | `),actual:Array.isArray(e)?`array`:typeof e==`object`?`plain object`:typeof e}),to):e;let o=a.type;return o===`object`?oo(e,a,n,r,i):o===`array`?so(e,a,n,r,i):co(e,a,n,r,i)?to:e}function uo(e){if(typeof e!=`object`||!e)return!1;if(ka(e))return!0;if(Array.isArray(e))return e.some(uo);if(Va(e))return Object.values(e.props).some(uo);let t=e;return Array.isArray(t.steps)?!0:Object.values(t).some(uo)}function fo(e,t,n){if(t.visited.has(e)||!t.syms.has(e))return t.unres.push(e),n===`expr`?{k:`Ph`,n:e}:null;let r=t.syms.get(e);if(t.unreached?.delete(e),r.k===`Comp`&&Ra(r.name))return{k:`RuntimeRef`,n:e,refType:r.name===Fa.Mutation?`mutation`:`query`};t.visited.add(e);let i=t.currentStatementId;t.currentStatementId=e;try{let i=n===`value`?xo(r,t):bo(r,t);return n===`value`&&Va(i)&&(i.statementId=e),i}finally{t.currentStatementId=i,t.visited.delete(e)}}function po(e,t){return Ia(t.cat).has(e)||Ra(e)}function mo(e,t){let n={};for(let r=0;r<t.length&&r<e.length;r++)n[t[r].name]=e[r];return n}function ho(e,t,n,r){let{params:i}=n;t.length>i.length&&eo(r,e,``,{code:`excess-args`,declared:i.length,got:t.length});let a=mo(t,i),o=!1,s=r.errors.length;for(let t of i){let n=a[t.name],s=n?Ma(n):{v:void 0};if(!s)continue;if(s.v==null){if(!t.required||t.defaultValue!==void 0)continue;eo(r,e,`/${t.name}`,{code:n?`null-required`:`missing-required`,signature:Za(e,i)}),o=!0;continue}let c=lo(s.v,t.schema,e,`/${t.name}`,r);c===to&&(c=no(t.required,t.defaultValue)),c===to?o=!0:c===void 0?delete a[t.name]:c!==s.v&&(a[t.name]=ja(c))}return n.kind===`action`&&r.errors.length>s&&(o=!0),o?null:a}function go(e,t,n){let r=e.args.map(n),i=Ia(t.cat).get(e.name);if(!i||i.lazy)return{...e,args:r};let a=i.builtin?mo(r,i.params):ho(e.name,r,i,t);return a?{...e,args:r,mappedProps:a}:i.kind===`action`?{k:`Comp`,name:`Action`,args:[{k:`Arr`,els:[]}]}:{k:`Null`}}function _o(e,t,n){let r=t.currentStatementId;t.currentStatementId=n;let i=/* @__PURE__ */ new Set;for(let n of e)Aa(n,e=>{if(e.k!==`Comp`||i.has(e))return;i.add(e);let n=Ia(t.cat).get(e.name);n&&!n.lazy&&(e.mappedProps=(n.builtin?null:ho(e.name,e.args,n,t))??mo(e.args,n.params))});t.currentStatementId=r}function vo(e,t,n){let r=Ia(t.cat).get(e.name);if(r?.kind!==`function`||!r.lazy||e.args.length<3)return null;let i=e.args[1],a=i.k===`Ref`?i.n:i.k===`Str`?i.v:null;if(!a)return null;let o=new Set(n);o.add(a);let s=e.args.map((e,n)=>n===1?e:yo(e,t,o));return{...e,args:s}}function yo(e,t,n){switch(e.k){case`Ref`:return n.has(e.n)?e:fo(e.n,t,`expr`);case`Ph`:return e;case`Comp`:{if(e.fn&&!po(e.name,t))return eo(t,e.name,``,{code:`unknown-function`}),{k:`Null`};let r=vo(e,t,n);if(r)return r;if(po(e.name,t))return go(e,t,e=>yo(e,t,n));let i=e.args.map(e=>yo(e,t,n)),a=t.cat?.get(e.name);if(a){let t={};for(let e=0;e<a.params.length&&e<i.length;e++)t[a.params[e].name]=i[e];return{...e,args:i,mappedProps:t}}return eo(t,e.name,``,{code:`unknown-component`,available:t.cat&&[...t.cat.keys()]}),{...e,args:i}}case`Arr`:return{...e,els:e.els.map(e=>yo(e,t,n))};case`Obj`:return{...e,entries:e.entries.map(([e,r])=>[e,yo(r,t,n)])};case`BinOp`:return{...e,left:yo(e.left,t,n),right:yo(e.right,t,n)};case`UnaryOp`:return{...e,operand:yo(e.operand,t,n)};case`Ternary`:return{...e,cond:yo(e.cond,t,n),then:yo(e.then,t,n),else:yo(e.else,t,n)};case`Member`:return{...e,obj:yo(e.obj,t,n)};case`Index`:return{...e,obj:yo(e.obj,t,n),index:yo(e.index,t,n)};case`Assign`:return{...e,value:yo(e.value,t,n)};default:return e}}function bo(e,t){return yo(e,t,/* @__PURE__ */ new Set)}function xo(e,t){switch(e.k){case`Ref`:return fo(e.n,t,`value`);case`Str`:return e.v;case`Num`:return e.v;case`Bool`:return e.v;case`Null`:return null;case`Ph`:return null;case`Arr`:{let n=[];for(let r of e.els){if(r.k===`Ph`){t.prunedValues++;continue}let e=xo(r,t);e===null&&(r.k===`Comp`||r.k===`Ref`)?t.prunedValues++:n.push(e)}return n}case`Obj`:{let n={};for(let[r,i]of e.entries)n[r]=xo(i,t);return n}case`Comp`:{let{name:n,args:r}=e;if(e.fn&&!po(n,t))return eo(t,n,``,{code:`unknown-function`}),null;if(Ra(n))return eo(t,n,``,{code:`inline-reserved`}),null;if(po(n,t))return vo(e,t,/* @__PURE__ */ new Set)||go(e,t,e=>bo(e,t));let i=t.cat?.get(n),a={};if(i){let e=!1;for(let o=0;o<i.params.length&&o<r.length;o++){let s=i.params[o],c=t.prunedValues,l=xo(r[o],t);if(t.prunedValues>c&&eo(t,n,`/${s.name}`,{code:`pruned-value`}),a[s.name]=l,s.schema===void 0)continue;if(l==null&&s.defaultValue!==void 0){eo(t,n,`/${s.name}`,{code:`type-mismatch`,expected:Xa(s.schema)??`a defined value`,actual:l===null?`null`:`undefined`}),a[s.name]=s.defaultValue,t.prunedValues=c;continue}let u=lo(l,s.schema,n,`/${s.name}`,t);u===to&&(u=no(s.required,s.defaultValue),s.defaultValue!==void 0&&(t.prunedValues=c),u===to?e=!0:u===void 0&&delete a[s.name]),u!==to&&u!==void 0&&(a[s.name]=u)}r.length>i.params.length&&eo(t,n,``,{code:`excess-args`,declared:i.params.length,got:r.length});let o=i.params.filter(e=>e.required&&(!(e.name in a)||a[e.name]===null));if(o.length){let e=o.filter(e=>e.defaultValue===void 0||(eo(t,n,`/${e.name}`,{code:e.name in a?`null-required`:`missing-required`}),a[e.name]=e.defaultValue,!1));if(e.length){for(let r of e)eo(t,n,`/${r.name}`,{code:r.name in a?`null-required`:`missing-required`,signature:Za(n,i.params)});return null}}if(e)return null}else return eo(t,n,``,{code:`unknown-component`,available:t.cat&&[...t.cat.keys()]}),null;let o=Object.values(a).some(e=>uo(e));return{type:`element`,typeName:n,props:a,partial:t.partial,hasDynamicProps:o}}default:return Da(e)?bo(e,t):e}}function So(e){let t=[],n=!1,r=!1;for(let i=0;i<e.length;i++){let a=e[i];r?r=!1:a===`\\`&&n?r=!0:n?a===n&&(n=!1):a===`"`||a===`'`?n=a:a===`(`||a===`[`||a===`{`?t.push(a):(a===`)`&&t[t.length-1]===`(`||a===`]`&&t[t.length-1]===`[`||a===`}`&&t[t.length-1]===`{`)&&t.pop()}if(!(n||t.length>0))return{text:e,wasIncomplete:!1};let i=e;n&&(r&&(i+=`\\`),i+=n);for(let e=t.length-1;e>=0;e--)i+=t[e]===`(`?`)`:t[e]===`[`?`]`:`}`;return{text:i,wasIncomplete:!0}}function Co(e){let t=[],n=0;for(;n<e.length;){for(;n<e.length&&e[n].t===q.Newline;)n++;if(n>=e.length||e[n].t===q.EOF)break;let r=e[n];if(r.t!==q.Ident&&r.t!==q.Type&&r.t!==q.StateVar){for(;n<e.length&&e[n].t!==q.Newline&&e[n].t!==q.EOF;)n++;continue}let i=r.v,a=r.t;if(n++,n>=e.length||e[n].t!==q.Equals){for(;n<e.length&&e[n].t!==q.Newline&&e[n].t!==q.EOF;)n++;continue}n++;let o=[],s=0,c=0;for(;n<e.length&&e[n].t!==q.EOF;){let t=e[n].t;if(t===q.Newline&&s<=0&&c<=0){let t=n+1;for(;t<e.length&&e[t].t===q.Newline;)t++;let r=t<e.length?e[t].t:q.EOF;if(r===q.Question||r===q.Colon&&c>0){n++;continue}break}t===q.Newline?n++:(t===q.LParen||t===q.LBrack||t===q.LBrace?s++:(t===q.RParen||t===q.RBrack||t===q.RBrace)&&s>0?s--:t===q.Question&&s===0?c++:t===q.Colon&&s===0&&c>0&&c--,o.push(e[n++]))}o.length&&t.push({id:i,idTokenType:a,tokens:o})}return t}function wo(e=!0){return{root:null,meta:{incomplete:e,unresolved:[],orphaned:[],statementCount:0,errors:[]},stateDeclarations:{},queryStatements:[],mutationStatements:[]}}function To(e){if(!ka(e))return[];let t=/* @__PURE__ */ new Set;return Aa(e,e=>{e.k===`StateRef`&&t.add(e.n)}),[...t]}function Eo(e,t){if(t.k===`Comp`&&t.name===Fa.Query){let n=To(t.args[1]);return{kind:`query`,id:e.id,call:{callee:Fa.Query,args:t.args},expr:t,deps:n.length>0?n:void 0}}return t.k===`Comp`&&t.name===Fa.Mutation?{kind:`mutation`,id:e.id,call:{callee:Fa.Mutation,args:t.args},expr:t}:e.idTokenType===q.StateVar?{kind:`state`,id:e.id,init:t}:{kind:`value`,id:e.id,expr:t}}function Do(e,t,n){let r={},i=[],a=[];for(let n of e)switch(n.kind){case`state`:r[n.id]=xo(n.init,t);break;case`query`:_o(n.call.args,t,n.id),i.push({statementId:n.id,toolAST:n.call.args[0]??null,argsAST:n.call.args[1]??null,defaultsAST:n.call.args[2]??null,refreshAST:n.call.args[3]??null,deps:n.deps,complete:!0});break;case`mutation`:_o(n.call.args,t,n.id),a.push({statementId:n.id,toolAST:n.call.args[0]??null,argsAST:n.call.args[1]??null})}for(let t of e){let e=t.kind===`state`?[t.init]:t.kind===`value`?[t.expr]:t.kind===`query`||t.kind===`mutation`?t.call.args:[];for(let i of e)for(let e of To(i))e===n?.name&&n.stmts.has(t)||e in r||(r[e]=null)}return{stateDeclarations:r,queryStatements:i,mutationStatements:a}}const Oo=`root`;function ko(e){return e?.k===`Comp`&&!e.fn&&!La(e.name)&&!Ra(e.name)}function Ao(e,t){if(e.has(Oo))return{id:Oo,fallback:!1};for(let n of e.values())if(n.kind===`value`&&ko(n.expr)&&n.expr.name===t)return{id:n.id,fallback:!0};return null}function jo(e,t){let n=/* @__PURE__ */ new Set;for(;e?.k===`Ref`&&!n.has(e.n);)n.add(e.n),e=t.get(e.n);return ko(e)}function Mo(e){let t=!1;return Aa(e,e=>{ko(e)&&(t=!0)}),t}function No(e,t,n,r,i,a,o){let s=Ao(e,a),c=/* @__PURE__ */ new Map;for(let[t,n]of e)c.set(t,n.kind===`state`?n.init:n.expr);let l=[],u=[],d=/* @__PURE__ */ new Set;for(let[t,n]of e)t!==s?.id&&n.kind!==`state`&&n.kind!==`query`&&n.kind!==`mutation`&&d.add(t);let f={syms:c,cat:i,errors:u,unres:l,prunedValues:0,visited:/* @__PURE__ */ new Set,partial:n,currentStatementId:s?.id,unreached:d},p=null,m;if(s){let e=xo(c.get(s.id),f);Va(e)?(p=e,p.statementId=s.id):ka(e)&&Mo(e)&&(m=e)}let{stateDeclarations:h,queryStatements:g,mutationStatements:_}=Do(t,f,o);f.currentStatementId=s?.id;let v=a??``;s?!p&&!m&&!jo(c.get(s.id),c)?eo(f,v,``,{code:`no-root`,reason:`not-component`}):s.fallback&&eo(f,v,``,{code:`no-root`,reason:p?`fallback`:`missing`}):eo(f,v,``,{code:`no-root`,reason:`missing`});let y=s?[...d]:[];return{root:p,...m?{rootExpression:m}:{},meta:{incomplete:n,unresolved:l,orphaned:y,statementCount:r,errors:u},stateDeclarations:h,queryStatements:g,mutationStatements:_}}function Po(e,t){if(e[t]!==`"`)return t;let n=t+1;for(;n<e.length;){let t=e[n];if(t===`\\`)n+=2;else if(t===`"`)return n+1;else n++}return n}function Fo(e){let t=[],n=0;for(;n<e.length;){let r=-1;for(;n<e.length;){let t=Po(e,n);if(t>n)n=t;else{if(e[n]==="`"&&n+1<e.length&&e[n+1]==="`"&&n+2<e.length&&e[n+2]==="`"){r=n;break}n++}}if(r===-1)break;let i=r+3;for(;i<e.length&&e[i]!==`
42
+ `;)i++;if(i>=e.length){t.push(e.slice(r+3).replace(/^[^\n]*\n?/,``)),n=e.length;break}i++;let a=-1,o=i;for(;o<e.length;){let t=Po(e,o);if(t>o)o=t;else{if(e[o]==="`"&&o+1<e.length&&e[o+1]==="`"&&o+2<e.length&&e[o+2]==="`"){a=o;break}o++}}a===-1?(t.push(e.slice(i)),n=e.length):(t.push(e.slice(i,a)),n=a+3)}if(t.length>0)return t.join(`
43
43
  `);if(e.startsWith("```")){let t=3;for(;t<e.length&&e[t]!==`
44
- `;)t++;let n=t<e.length?t+1:3,r=e.slice(n),i=r.lastIndexOf("```");return i===-1?r:r.slice(0,i)}return e}function Wa(e){let t=!1;return e.split(`
44
+ `;)t++;let n=t<e.length?t+1:3,r=e.slice(n),i=r.lastIndexOf("```");return i===-1?r:r.slice(0,i)}return e}function Io(e){let t=!1;return e.split(`
45
45
  `).map(e=>{for(let n=0;n<e.length;n++){let r=e[n];if(t){if(r===`\\`&&n+1<e.length){n++;continue}r===t&&(t=!1)}else if(r===`"`||r===`'`)t=r;else if(r===`/`&&e[n+1]===`/`||r===`#`)return e.substring(0,n).trimEnd()}return e}).join(`
46
- `)}function Ga(e){return Wa(Ua(e.trim())).trim()}function Ka(e,t,n){let r=Ga(e);if(!r)return Ma();let{text:i,wasIncomplete:a}=Aa(r),o=ja(Yi(i));if(!o.length)return Ma(a);let s=/* @__PURE__ */ new Map;for(let e of o){let t=Pa(e,Ji(e.tokens));s.set(e.id,t)}return Va(s,[...s.values()],a,s.size,t,n)}function qa(e,t){let n=``,r=``,i=0,a=/* @__PURE__ */ new Map,o=0;function s(e){let t=e.trim();if(t)for(let e of ja(Yi(t))){let t=Pa(e,Ji(e.tokens));a.set(e.id,t),o++}}function c(){let e=Ga(n);e.startsWith(r.slice(0,i))||(i=0,a.clear(),o=0),r=e}function l(){let e=0,t=0,n=!1,a=!1,o=i;for(let c=i;c<r.length;c++){let l=r[c];if(a)a=!1;else if(l===`\\`&&n)a=!0;else if(n)l===n&&(n=!1);else if(l===`"`||l===`'`)n=l;else if(l===`(`||l===`[`||l===`{`)e++;else if(l===`)`||l===`]`||l===`}`)e=Math.max(0,e-1);else if(l===`?`&&e===0)t++;else if(l===`:`&&e===0&&t>0)t--;else if(l===`
46
+ `)}function Lo(e){return Io(Fo(e.trim())).trim()}function Ro(e,t,n){let r=Lo(e);if(!r)return wo();let{text:i,wasIncomplete:a}=So(r),o=Co(Ba(i));if(!o.length)return wo(a);let s=/* @__PURE__ */ new Map;for(let e of o){let t=Eo(e,za(e.tokens));s.set(e.id,t)}return No(s,[...s.values()],a,s.size,t,n)}function zo(e,t){let n=``,r=``,i=0,a=/* @__PURE__ */ new Map,o=0;function s(e){let t=e.trim();if(t)for(let e of Co(Ba(t))){let t=Eo(e,za(e.tokens));a.set(e.id,t),o++}}function c(){let e=Lo(n);e.startsWith(r.slice(0,i))||(i=0,a.clear(),o=0),r=e}function l(){let e=0,t=0,n=!1,a=!1,o=i;for(let c=i;c<r.length;c++){let l=r[c];if(a)a=!1;else if(l===`\\`&&n)a=!0;else if(n)l===n&&(n=!1);else if(l===`"`||l===`'`)n=l;else if(l===`(`||l===`[`||l===`{`)e++;else if(l===`)`||l===`]`||l===`}`)e=Math.max(0,e-1);else if(l===`?`&&e===0)t++;else if(l===`:`&&e===0&&t>0)t--;else if(l===`
47
47
  `&&e<=0&&t<=0){let e=c+1;for(;e<r.length&&(r[e]===` `||r[e]===` `||r[e]===`\r`||r[e]===`
48
- `);)e++;if(e<r.length&&(r[e]===`?`||r[e]===`:`&&t>0))continue;let n=r.slice(o,c).trim();n&&s(n),o=c+1,i=c+1}}return o}function u(i=!1){c();let s=l(),u=r.slice(s).trim();if(!u)return o===0?Ma():Va(a,[...a.values()],!1,o,e,t);let{text:d,wasIncomplete:f}=Aa(u),p=ja(Yi(d));if(!p.length)return o===0?Ma(f):Va(a,[...a.values()],f,o,e,t);let m=new Map(a),h=/* @__PURE__ */ new Set;for(let e of p){if(a.has(e.id)&&f)continue;let t=Pa(e,Ji(e.tokens));m.set(e.id,t),h.add(t)}let g=i?void 0:/\$\w+$/.exec(n)?.[0],_=g&&u.endsWith(g)&&!RegExp(`\\${g}(?!\\w)`).test(u.slice(0,-g.length))?g:void 0;return Va(m,[...m.values()],f,o+p.length,e,t,_?{name:_,stmts:h}:void 0)}function d(){n=``,r=``,i=0,a.clear(),o=0}return{push(e,t){return n+=e,u(t)},set(e,t){(e.length<n.length||!e.startsWith(n))&&d();let r=e.slice(n.length);return r&&(n+=r),u(t)},getResult:u}}function Ja(e,t){if(!e||typeof e!=`object`)return e;let n=e.$ref;if(typeof n==`string`)return t.has(n)?Ja(t.get(n),t):e;let r=Array.isArray(e)?[...e]:{...e},i=!1;for(let[e,n]of Object.entries(r))r[e]=Ja(n,t),i||(i=r[e]!==n);return i?r:e}function Ya(e,t){let n=e.properties??{},r=e.required??[];return Object.keys(n).map(e=>({name:e,required:r.includes(e),defaultValue:ia(n[e]),schema:t.size?Ja(n[e],t):n[e]}))}function Xa(e){let t=/* @__PURE__ */ new Map,n=e.properties&&new Set(Object.keys(e.properties)),r=/* @__PURE__ */ new Map;for(let t of[...Object.keys(Ui),...Object.keys(e.actions??{})]){let i=e.$defs?.[t];i&&!n?.has(t)&&r.set(`#/$defs/${t}`,i)}for(let[i,a]of Object.entries(e.$defs??{}))(n?!n.has(i):r.has(`#/$defs/${i}`))||t.set(i,{params:Ya(a,r)});t.callDefs=new Map(Hi);for(let[n,i]of Object.entries(e.functions??{}))t.callDefs.set(n,{kind:`function`,params:Ya(i.params,r)});for(let[n,i]of Object.entries(e.actions??{}))t.callDefs.set(n,{kind:`action`,params:Ya(i.params,r)});return t}const Za=Xa(wi.schema),Qa={parse(e){return Ka(e,Za,wi.root)}};function $a(){return qa(Za,wi.root)}function eo(e,t){let n=e.root?.props.children,r=/* @__PURE__ */ new Set,i=e.meta,a=e.meta.errors.some(e=>e.severity!==`warning`&&!(e.component===`Grid`&&e.path===`/columns`||e.component===`Cell`&&e.path===`/span`));function o(t,n,r){i===e.meta&&(i={...e.meta,errors:[...e.meta.errors]}),i.errors.push({code:`type-mismatch`,component:t.typeName,path:n,message:r,statementId:t.statementId}),a=!0}function s(n,i,a){if(!Xi(n)||typeof n.statementId!=`string`||r.has(n.statementId)){o(i,`/children/${a}`,`Child must be a valid, uniquely named component`);return}if(n.typeName===`Root`||n.typeName===`Grid`&&i.typeName!==`Root`||n.typeName===`Cell`&&i.typeName===`Cell`){o(i,`/children/${a}`,`Component is not allowed at this nesting level`);return}if(r.add(n.statementId),(n.typeName===`Chart`||n.typeName===`Table`)&&e.meta.errors.some(e=>e.statementId===n.statementId&&e.severity!==`warning`))return;let c=(n.typeName===`Grid`||n.typeName===`Cell`)&&Array.isArray(n.props.children)?n.props.children.flatMap((e,t)=>{let r=s(e,n,t);return r?[r]:[]}):void 0,l=c?{...n,props:{...n.props,children:c}}:n;if(!Ti(l))o(n,``,`Component does not match the catalog`);else if(l.typeName===`Table`&&l.props.rows.some(e=>e.length!==l.props.columns.length))o(n,`/rows`,`Every table row must contain one value per column`);else if(c?.length!==0&&(l.typeName!==`Chart`&&l.typeName!==`Table`||!t&&!e.meta.incomplete))return l}let c=e.root,l=c&&Array.isArray(n)?n.flatMap((e,t)=>{if(Xi(e)&&e.typeName===`Cell`)return o(c,`/children/${t}`,`Cell must be inside a Grid`),[];let n=s(e,c,t);return n&&n.typeName!==`Cell`?[n]:[]}):[],u=c?.hasDynamicProps===!0||e.queryStatements.length>0||e.mutationStatements.length>0||Object.keys(e.stateDeclarations).length>0||e.meta.errors.some(e=>e.code===`unknown-function`||e.code===`inline-reserved`);u&&c&&o(c,``,`Executable content is not supported by the static catalog`),c&&c.typeName!==wi.root&&o(c,``,`The block must use the catalog root component`);let d=u||c!==null&&c.typeName!==wi.root||!t&&(!Array.isArray(n)||l.length===0),f=!t&&!d&&(a||e.meta.incomplete);return!t&&(d||i.errors.length>0||i.unresolved.length>0||i.incomplete)&&console.warn(`Generative UI diagnostics`,{error:d,partial:f,diagnostics:i}),{elements:d?[]:l,error:d,partial:f,diagnostics:i}}function to(e){return eo(Qa.parse(e),!1).elements.flatMap(no).join(`
48
+ `);)e++;if(e<r.length&&(r[e]===`?`||r[e]===`:`&&t>0))continue;let n=r.slice(o,c).trim();n&&s(n),o=c+1,i=c+1}}return o}function u(i=!1){c();let s=l(),u=r.slice(s).trim();if(!u)return o===0?wo():No(a,[...a.values()],!1,o,e,t);let{text:d,wasIncomplete:f}=So(u),p=Co(Ba(d));if(!p.length)return o===0?wo(f):No(a,[...a.values()],f,o,e,t);let m=new Map(a),h=/* @__PURE__ */ new Set;for(let e of p){if(a.has(e.id)&&f)continue;let t=Eo(e,za(e.tokens));m.set(e.id,t),h.add(t)}let g=i?void 0:/\$\w+$/.exec(n)?.[0],_=g&&u.endsWith(g)&&!RegExp(`\\${g}(?!\\w)`).test(u.slice(0,-g.length))?g:void 0;return No(m,[...m.values()],f,o+p.length,e,t,_?{name:_,stmts:h}:void 0)}function d(){n=``,r=``,i=0,a.clear(),o=0}return{push(e,t){return n+=e,u(t)},set(e,t){(e.length<n.length||!e.startsWith(n))&&d();let r=e.slice(n.length);return r&&(n+=r),u(t)},getResult:u}}function Bo(e,t){if(!e||typeof e!=`object`)return e;let n=e.$ref;if(typeof n==`string`)return t.has(n)?Bo(t.get(n),t):e;let r=Array.isArray(e)?[...e]:{...e},i=!1;for(let[e,n]of Object.entries(r))r[e]=Bo(n,t),i||(i=r[e]!==n);return i?r:e}function Vo(e,t){let n=e.properties??{},r=e.required??[];return Object.keys(n).map(e=>({name:e,required:r.includes(e),defaultValue:Ya(n[e]),schema:t.size?Bo(n[e],t):n[e]}))}function Ho(e){let t=/* @__PURE__ */ new Map,n=e.properties&&new Set(Object.keys(e.properties)),r=/* @__PURE__ */ new Map;for(let t of[...Object.keys(Pa),...Object.keys(e.actions??{})]){let i=e.$defs?.[t];i&&!n?.has(t)&&r.set(`#/$defs/${t}`,i)}for(let[i,a]of Object.entries(e.$defs??{}))(n?!n.has(i):r.has(`#/$defs/${i}`))||t.set(i,{params:Vo(a,r)});t.callDefs=new Map(Na);for(let[n,i]of Object.entries(e.functions??{}))t.callDefs.set(n,{kind:`function`,params:Vo(i.params,r)});for(let[n,i]of Object.entries(e.actions??{}))t.callDefs.set(n,{kind:`action`,params:Vo(i.params,r)});return t}const Uo=Ho(ha.schema),Wo={parse(e){return Ro(e,Uo,ha.root)}};function Go(){return zo(Uo,ha.root)}function Ko(e,t){let n=e.root?.props.children,r=/* @__PURE__ */ new Set,i=e.meta,a=e.meta.errors.some(e=>e.severity!==`warning`&&!(e.component===`Grid`&&e.path===`/columns`||e.component===`Cell`&&e.path===`/span`));function o(t,n,r){i===e.meta&&(i={...e.meta,errors:[...e.meta.errors]}),i.errors.push({code:`type-mismatch`,component:t.typeName,path:n,message:r,statementId:t.statementId}),a=!0}function s(n,i,a){if(!Va(n)||typeof n.statementId!=`string`||r.has(n.statementId)){o(i,`/children/${a}`,`Child must be a valid, uniquely named component`);return}if(n.typeName===`Root`||n.typeName===`Grid`&&i.typeName!==`Root`||n.typeName===`Cell`&&i.typeName===`Cell`){o(i,`/children/${a}`,`Component is not allowed at this nesting level`);return}if(r.add(n.statementId),(n.typeName===`Chart`||n.typeName===`Table`)&&e.meta.errors.some(e=>e.statementId===n.statementId&&e.severity!==`warning`))return;let c=(n.typeName===`Grid`||n.typeName===`Cell`)&&Array.isArray(n.props.children)?n.props.children.flatMap((e,t)=>{let r=s(e,n,t);return r?[r]:[]}):void 0,l=c?{...n,props:{...n.props,children:c}}:n;if(!ga(l))o(n,``,`Component does not match the catalog`);else if(l.typeName===`Table`&&l.props.rows.some(e=>e.length!==l.props.columns.length))o(n,`/rows`,`Every table row must contain one value per column`);else if(c?.length!==0&&(l.typeName!==`Chart`&&l.typeName!==`Table`||!t&&!e.meta.incomplete))return l}let c=e.root,l=c&&Array.isArray(n)?n.flatMap((e,t)=>{if(Va(e)&&e.typeName===`Cell`)return o(c,`/children/${t}`,`Cell must be inside a Grid`),[];let n=s(e,c,t);return n&&n.typeName!==`Cell`?[n]:[]}):[],u=c?.hasDynamicProps===!0||e.queryStatements.length>0||e.mutationStatements.length>0||Object.keys(e.stateDeclarations).length>0||e.meta.errors.some(e=>e.code===`unknown-function`||e.code===`inline-reserved`);u&&c&&o(c,``,`Executable content is not supported by the static catalog`),c&&c.typeName!==ha.root&&o(c,``,`The block must use the catalog root component`);let d=u||c!==null&&c.typeName!==ha.root||!t&&(!Array.isArray(n)||l.length===0),f=!t&&!d&&(a||e.meta.incomplete);return!t&&(d||i.errors.length>0||i.unresolved.length>0||i.incomplete)&&console.warn(`Generative UI diagnostics`,{error:d,partial:f,diagnostics:i}),{elements:d?[]:l,error:d,partial:f,diagnostics:i}}function qo(e){return Ko(Wo.parse(e),!1).elements.flatMap(Jo).join(`
49
49
 
50
- `)}function no(e){return e.typeName===`Grid`||e.typeName===`Cell`?e.props.children.flatMap(no):e.typeName===`Text`?[e.props.text]:e.typeName===`Card`?[`${e.props.title}\n${e.props.body}`]:e.typeName===`Metric`?[[e.props.label,e.props.value,e.props.detail].filter(Boolean).join(`
50
+ `)}function Jo(e){return e.typeName===`Grid`||e.typeName===`Cell`?e.props.children.flatMap(Jo):e.typeName===`Text`?[e.props.text]:e.typeName===`Card`?[`${e.props.title}\n${e.props.body}`]:e.typeName===`Metric`?[[e.props.label,e.props.value,e.props.detail].filter(Boolean).join(`
51
51
  `)]:e.typeName===`Table`?[[e.props.title,e.props.columns.join(` `),...e.props.rows.map(e=>e.join(` `))].join(`
52
52
  `)]:[[e.props.title,...e.props.data.map(e=>`${e.label}: ${e.value}`)].join(`
53
- `)]}function ro(e,{cssPrefix:t,strings:n}){let r=[],i;return{...yi(e),set_attr(e,a,o){if(a!==4||o!==`openui`||e.index!==1)return Ci(e,a,o);let s=document.createElement(`div`);e.nodes[e.index]?.parentElement?.replaceWith(s),i={textSig:H(``),doneSig:H(!1)},r.push(s),ve(U(io,{cssPrefix:t,textSig:i.textSig,doneSig:i.doneSig,strings:n}),s)},add_text(e,t){i?i.textSig.value=i.textSig.peek()+t:Si(e,t)},end_token(e){i&&(i.doneSig.value=!0,i=void 0),xi(e)},finish(){i&&(i.doneSig.value=!0)},dispose(){for(let e of r)ve(null,e);r.length=0,i=void 0}}}function io({textSig:e,doneSig:t,cssPrefix:n,strings:r}){let i=B(()=>{let n=$a();return dr(()=>eo(n.set(e.value,t.value),!t.value))},[e,t]);return i.value.error?U(`div`,{role:`alert`,children:r.visualError}):U(`div`,{class:`${n}-generative-ui`,"aria-busy":!t.value,children:[i.value.elements.map(e=>U(ao,{element:e,cssPrefix:n},e.statementId)),i.value.partial&&U(`p`,{role:`status`,children:r.visualPartial}),i.value.elements.length===0&&!t.value?U(`span`,{role:`status`,children:r.visualPreparing}):null]})}function ao({element:e,cssPrefix:t}){if(e.typeName===`Grid`)return U(`div`,{class:`${t}-generative-ui-grid-container`,children:U(`div`,{class:`${t}-generative-ui-grid`,"data-columns":e.props.columns,children:e.props.children.map(e=>U(`div`,{class:`${t}-generative-ui-cell`,"data-span":e.typeName===`Cell`?e.props.span??1:1,children:e.typeName===`Cell`?e.props.children.map(e=>U(ao,{element:e,cssPrefix:t},e.statementId)):U(ao,{element:e,cssPrefix:t})},e.statementId))})});switch(e.typeName){case`Text`:return U(`p`,{children:e.props.text});case`Card`:return U(`section`,{children:[U(`strong`,{children:e.props.title}),U(`p`,{children:e.props.body})]});case`Metric`:return U(`section`,{children:[U(`strong`,{children:e.props.label}),U(`span`,{class:`${t}-generative-ui-metric`,children:e.props.value}),e.props.detail&&U(`p`,{children:e.props.detail})]});case`Table`:return U(`section`,{children:U(`div`,{class:`${t}-generative-ui-table`,children:U(`table`,{children:[U(`caption`,{children:e.props.title}),U(`thead`,{children:U(`tr`,{children:e.props.columns.map((e,t)=>U(`th`,{scope:`col`,children:e},t))})}),U(`tbody`,{children:e.props.rows.map((e,t)=>U(`tr`,{children:e.map((e,t)=>U(`td`,{children:e},t))},t))})]})})});case`Chart`:return U(oo,{element:e,cssPrefix:t})}}function oo({element:e,cssPrefix:t}){let n=Math.min(0,...e.props.data.map(e=>e.value)),r=Math.max(0,...e.props.data.map(e=>e.value))-n||1,i=148+n/r*136,a=e.props.data.map((t,i)=>({x:24+(i+.5)*272/e.props.data.length,y:148-(t.value-n)/r*136}));return U(`section`,{children:[U(`strong`,{children:e.props.title}),U(`svg`,{class:`${t}-generative-ui-chart`,viewBox:`0 0 320 168`,role:`img`,"aria-label":`${e.props.title}. ${e.props.data.map(e=>`${e.label}: ${e.value}`).join(`, `)}`,children:[U(`line`,{class:`${t}-generative-ui-axis`,x1:24,x2:296,y1:i,y2:i}),e.props.type===`line`&&U(`polyline`,{points:a.map(e=>`${e.x},${e.y}`).join(` `),fill:`none`,stroke:`currentColor`,"stroke-width":3}),a.map((t,n)=>e.props.type===`bar`?U(`rect`,{x:t.x-96/e.props.data.length,y:Math.min(t.y,i),width:192/e.props.data.length,height:Math.abs(t.y-i),fill:`currentColor`},n):U(`circle`,{cx:t.x,cy:t.y,r:3,fill:`currentColor`},n))]}),U(`div`,{class:`${t}-generative-ui-data`,children:e.props.data.map((e,t)=>U(`span`,{children:[e.label,`: `,e.value]},t))})]})}function so(e){if(!e.includes("```openui"))return e;let t=``,n=0,r=0,i=0,a=0,o;function s(r){o?.language===`openui`&&(t+=e.slice(n,o.start)+to(o.source)+(e[r-1]===`
53
+ `)]}function Yo(e,{cssPrefix:t,strings:n}){let r=[],i;return{...ua(e),set_attr(e,a,o){if(a!==4||o!==`openui`||e.index!==1)return ma(e,a,o);let s=document.createElement(`div`);e.nodes[e.index]?.parentElement?.replaceWith(s),i={textSig:V(``),doneSig:V(!1)},r.push(s),yt(U(Xo,{cssPrefix:t,textSig:i.textSig,doneSig:i.doneSig,strings:n}),s)},add_text(e,t){i?i.textSig.value=i.textSig.peek()+t:pa(e,t)},end_token(e){i&&(i.doneSig.value=!0,i=void 0),fa(e)},finish(){i&&(i.doneSig.value=!0)},dispose(){for(let e of r)yt(null,e);r.length=0,i=void 0}}}function Xo({textSig:e,doneSig:t,cssPrefix:n,strings:r}){let i=z(()=>{let n=Go();return H(()=>Ko(n.set(e.value,t.value),!t.value))},[e,t]);return i.value.error?U(`div`,{role:`alert`,children:r.visualError}):U(`div`,{class:`${n}-generative-ui`,"aria-busy":!t.value,children:[i.value.elements.map(e=>U(Zo,{element:e,cssPrefix:n},e.statementId)),i.value.partial&&U(`p`,{role:`status`,children:r.visualPartial}),i.value.elements.length===0&&!t.value?U(`span`,{role:`status`,children:r.visualPreparing}):null]})}function Zo({element:e,cssPrefix:t}){if(e.typeName===`Grid`)return U(`div`,{class:`${t}-generative-ui-grid-container`,children:U(`div`,{class:`${t}-generative-ui-grid`,"data-columns":e.props.columns,children:e.props.children.map(e=>U(`div`,{class:`${t}-generative-ui-cell`,"data-span":e.typeName===`Cell`?e.props.span??1:1,children:e.typeName===`Cell`?e.props.children.map(e=>U(Zo,{element:e,cssPrefix:t},e.statementId)):U(Zo,{element:e,cssPrefix:t})},e.statementId))})});switch(e.typeName){case`Text`:return U(`p`,{children:e.props.text});case`Card`:return U(`section`,{children:[U(`strong`,{children:e.props.title}),U(`p`,{children:e.props.body})]});case`Metric`:return U(`section`,{children:[U(`strong`,{children:e.props.label}),U(`span`,{class:`${t}-generative-ui-metric`,children:e.props.value}),e.props.detail&&U(`p`,{children:e.props.detail})]});case`Table`:return U(`section`,{children:U(`div`,{class:`${t}-generative-ui-table`,children:U(`table`,{children:[U(`caption`,{children:e.props.title}),U(`thead`,{children:U(`tr`,{children:e.props.columns.map((e,t)=>U(`th`,{scope:`col`,children:e},t))})}),U(`tbody`,{children:e.props.rows.map((e,t)=>U(`tr`,{children:e.map((e,t)=>U(`td`,{children:e},t))},t))})]})})});case`Chart`:return U(Qo,{element:e,cssPrefix:t})}}function Qo({element:e,cssPrefix:t}){let n=Math.min(0,...e.props.data.map(e=>e.value)),r=Math.max(0,...e.props.data.map(e=>e.value))-n||1,i=148+n/r*136,a=e.props.data.map((t,i)=>({x:24+(i+.5)*272/e.props.data.length,y:148-(t.value-n)/r*136}));return U(`section`,{children:[U(`strong`,{children:e.props.title}),U(`svg`,{class:`${t}-generative-ui-chart`,viewBox:`0 0 320 168`,role:`img`,"aria-label":`${e.props.title}. ${e.props.data.map(e=>`${e.label}: ${e.value}`).join(`, `)}`,children:[U(`line`,{class:`${t}-generative-ui-axis`,x1:24,x2:296,y1:i,y2:i}),e.props.type===`line`&&U(`polyline`,{points:a.map(e=>`${e.x},${e.y}`).join(` `),fill:`none`,stroke:`currentColor`,"stroke-width":3}),a.map((t,n)=>e.props.type===`bar`?U(`rect`,{x:t.x-96/e.props.data.length,y:Math.min(t.y,i),width:192/e.props.data.length,height:Math.abs(t.y-i),fill:`currentColor`},n):U(`circle`,{cx:t.x,cy:t.y,r:3,fill:`currentColor`},n))]}),U(`div`,{class:`${t}-generative-ui-data`,children:e.props.data.map((e,t)=>U(`span`,{children:[e.label,`: `,e.value]},t))})]})}function $o(e){if(!e.includes("```openui"))return e;let t=``,n=0,r=0,i=0,a=0,o;function s(r){o?.language===`openui`&&(t+=e.slice(n,o.start)+qo(o.source)+(e[r-1]===`
54
54
  `?`
55
- `:``),n=r),o=void 0}let c=oi({data:void 0,add_token(e,t){a+=1,t===10&&a===1&&(o={start:i,source:``,language:``})},set_attr(e,t,n){o&&t===4&&(o.language=n)},add_text(e,t){o&&(o.source+=t)},end_token(){o&&s(Math.min(r+1,e.length)),--a}});for(;r<e.length;r++)vi(c,e.charAt(r)),e[r]===`
56
- `&&(i=r+1);return si(c),o&&s(e.length),t+e.slice(n)}function co(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function lo(e){return`tool-${e.startsWith(`tool:`)?e.slice(5):e}`}function uo(e){return e.startsWith(`tool-`)?e.slice(5):e}const fo={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`,messageFeedback:`/pai/message-feedback`,requestOperator:`/pai/request-operator`,cancelOperatorRequest:`/pai/cancel-request-operator`,bootstrap:`/pai/bootstrap`,content:`/pai/content`,contentCollections:`/pai/content/collection/list`,contentVoteSet:`/pai/content/vote/set`,submitForm:`/pai/submit-form`};function po(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function mo(e){if(!po(e))return;let t=e,n=t.controlMode,r=t.controlRevision;if(!(n!==`ai-agent`&&n!==`awaiting-operator`&&n!==`operator`||typeof r!=`number`||!Number.isSafeInteger(r)||r<0))return{controlMode:n,controlRevision:r,assignedOperatorInitials:typeof t.assignedOperatorInitials==`string`&&t.assignedOperatorInitials?t.assignedOperatorInitials:void 0,operatorAvailable:typeof t.operatorAvailable==`boolean`?t.operatorAvailable:void 0}}function ho(e){if(!po(e))return;let t=e.status,n=e.postFinishSequence;if(!(t!==`compacting`&&t!==`ready`||typeof n!=`number`||!Number.isSafeInteger(n)||n<0))return{status:t,postFinishSequence:n}}function go(e){let t=po(e)?e.suggestions:void 0;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!po(e))continue;let{id:t,label:r,text:i}=e;typeof r==`string`&&r&&n.push({id:typeof t==`string`&&t?t:`s${n.length}`,label:r,text:typeof i==`string`&&i?i:r})}return n}function _o(e){let t={messages:e.messages.map(e=>({id:e.serverMessageId??e.id,parts:yo(e),role:e.role})),conversationId:e.conversationId,responseType:`ack`};return e.visitorId&&(t.visitorId=e.visitorId),e.userPrefs&&(t.userPrefs=e.userPrefs),t}function vo(e){return e.state===`output-available`||e.state===`output-error`||e.state===`output-denied`||e.approval?.approved!==void 0}function yo(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`&&vo(n)){let e=n.dynamic?{type:`dynamic-tool`,toolName:n.toolName,toolCallId:n.toolCallId,state:n.state}:{type:lo(n.toolName),toolCallId:n.toolCallId,state:n.state};n.input!==void 0&&(e.input=n.input),n.output!==void 0&&(e.output=n.output),n.error!==void 0&&(e.errorText=n.error),n.approval?.approved!==void 0&&(e.approval=n.approval),t.push(e)}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}function bo(e,t,n=Ht()){let r=e?[{kind:`text`,id:`t0`,textSig:H(e),doneSig:H(!0)}]:[];return{id:n,role:`user`,createdAt:Date.now(),status:`complete`,attachments:t,partsSig:H(r)}}function xo(){return{id:Ht(),role:`assistant`,createdAt:Date.now(),status:`streaming`,partsSig:H([])}}function So(e){let t=Ht();return Co({id:t,role:e.role,createdAt:Date.now(),status:`complete`,ephemeral:!0,parts:[{kind:`text`,id:`${t}-t0`,text:e.text,done:!0}]})}function Co(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,canceled:e.canceled,errorText:e.errorText,finishReason:e.finishReason,serverMessageId:e.serverMessageId,ephemeral:e.ephemeral,attachments:e.attachments,feedback:e.feedback,partsSig:H(e.parts.map(as))}}function wo(e){return e.status===`failed`?`error`:e.role===`assistant`&&e.status===`streaming`?`streaming`:`complete`}function To(e){let t=/* @__PURE__ */ new Set,n=e.parts.map((t,n)=>t.type===`text`?{kind:`text`,id:`${e.id}-t${n}`,textSig:H(t.text),doneSig:H(!0)}:t.type===`reasoning`?{kind:`reasoning`,id:`${e.id}-r${n}`,textSig:H(t.text),doneSig:H(t.state!==`streaming`)}:t.type===`step-start`?{kind:`step-start`,id:`${e.id}-ss${n}`}:t.type===`file`?{kind:`file`,url:t.url,mediaType:t.mediaType}:t.type===`source-url`?{kind:`source`,sourceId:t.sourceId,url:t.url,title:t.title}:t.type===`source-document`?{kind:`source`,sourceId:t.sourceId,title:t.title,filename:t.filename,mediaType:t.mediaType}:t.type===`data-suggestions`?null:t.type===`dynamic-tool`||t.type.startsWith(`tool-`)?{kind:`tool`,toolCallId:t.toolCallId,toolName:t.type===`dynamic-tool`?t.toolName:uo(t.type),dynamic:t.type===`dynamic-tool`||void 0,inputPartialSig:H(``),inputSig:H(t.input),outputSig:H(t.output),errorSig:H(t.errorText),stateSig:H(t.state),approvalSig:H(t.approval)}:null).filter(e=>e!==null).filter(e=>e.kind!==`source`||!t.has(e.sourceId)&&(t.add(e.sourceId),!0)),r=e.parts.find(e=>e.type===`data-suggestions`);return{id:e.id,role:e.role,operatorInitials:e.operatorInitials,suggestions:r?.type===`data-suggestions`?go(r.data):void 0,serverMessageId:e.id,createdAt:Date.parse(e.createdAt),status:wo(e),canceled:e.status===`canceled`,feedback:e.feedback??null,partsSig:H(n)}}function Eo(e){return!e.parts.some(e=>e.type===`text`&&e.text.trim()!==``||e.type===`dynamic-tool`||e.type.startsWith(`tool-`)||e.type===`file`||e.type===`source-url`||e.type===`source-document`)}function Do(e){return e.role===`assistant`&&e.status===`streaming`&&Eo(e)}function Oo(e){let t=e.length-1;return e.filter((e,n)=>n===t||!Do(e)).map(To)}function ko(e,t){let n=!t&&e.at(-1)?.role===`assistant`?-2:-1,r=e.at(n);return!r||r.ephemeral?[]:[r]}function Ao(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,canceled:e.canceled,errorText:e.errorText,finishReason:e.finishReason,serverMessageId:e.serverMessageId,ephemeral:e.ephemeral,attachments:e.attachments,parts:e.partsSig.value.map(os)}}function jo(e){let t=``;for(let n of e.partsSig.value)n.kind===`text`&&(t+=n.textSig.value);return t}function Mo(e,t,n,r,i,a=t.createdAt){let o=e.find(e=>e.role===`user`&&!e.ephemeral);function s(e,t){return(e.role===`assistant`?so(jo(e)):jo(e)).replace(/\s+/g,` `).trim().slice(0,t)}let c=o?s(o,80):``,l=s(t,120);return{conversationId:n,title:c||r,lastMessageAt:new Date(a).toISOString(),preview:l||void 0,canContinue:i}}function No(e){return jo(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`||e.kind===`source`)}function Po(e){return jo(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`)}function Fo(e){return e===`approval-responded`||e===`output-available`||e===`output-denied`||e===`output-error`}function Io(e){return e.kind===`tool`}function Lo(e){return e.kind===`text`&&e.textSig.value.trim()!==``||e.kind===`file`}function Ro(e){let t=e.partsSig.value,n=t.findLastIndex(e=>e.kind===`tool`);return t.slice(n+1).some(Lo)}function zo(e){if(e.role!==`assistant`)return!1;let t=e.partsSig.value.filter(Io);return t.length>0&&t.every(e=>Fo(e.stateSig.value))}function Bo(e){return e.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`)&&!Ro(e)}function Vo(e,t){return!e.partsSig.value.slice(t+1).some(e=>e.kind===`step-start`||Lo(e))}function Ho(e){return e.partsSig.value.some(e=>Io(e)&&!Fo(e.stateSig.value))}function Uo(e,t){if(t.length===0)return e;let n=/* @__PURE__ */ new Set;for(let t of e)n.add(t.id),t.serverMessageId&&n.add(t.serverMessageId);let r=t.filter(e=>{let t=[e.id,e.serverMessageId].filter(e=>e!==void 0);return!t.some(e=>n.has(e))&&(t.forEach(e=>n.add(e)),!0)});if(r.length===0)return e;let i=e.findIndex(e=>!e.ephemeral),a=i<0?e.length:i;return[...e.slice(0,a),...r,...e.slice(a)]}function Wo(e,t){return t.id=e.id,e.canceled&&(t.canceled=!0),e.feedback!==void 0&&(t.feedback=e.feedback),t.suggestions??(t.suggestions=e.suggestions),t}function Go(e,t,n,r){if(!Ko(e))return;if(t.length===0){let t=Math.max(...r.values());return n.find(n=>n.role===`assistant`&&r.get(n.serverMessageId??n.id)===t&&jo(n).length>=jo(e).length)}let i=t.at(-1);if(i?.role!==`user`)return;let a=r.get(i.serverMessageId??i.id);if(a!==void 0)return n.find(t=>t.role===`assistant`&&r.get(t.serverMessageId??t.id)===a+1&&jo(t).length>=jo(e).length)}function Ko(e){return e?.role===`assistant`&&e.status===`streaming`&&e.serverMessageId===void 0}function qo(e,t){let n=new Map(t.partsSig.value.filter(Io).filter(e=>Fo(e.stateSig.value)).map(e=>[e.toolCallId,e]));if(n.size===0)return;let r=!1,i=e.partsSig.value.map(e=>{if(!Io(e))return e;let t=n.get(e.toolCallId);if(!t)return e;let i=e.approvalSig.value,a=t.approvalSig.value,o=i===void 0||i.approved===void 0&&a?.approved!==void 0?t.approvalSig:e.approvalSig,s=e.inputSig.value===void 0?t.inputSig:e.inputSig,c=e.toolName===`tool`?t.toolName:e.toolName,l=e.dynamic??t.dynamic;return o===e.approvalSig&&s===e.inputSig&&c===e.toolName&&l===e.dynamic?e:(r=!0,{...e,toolName:c,dynamic:l,inputSig:s,approvalSig:o})});r&&(e.partsSig.value=i)}function Jo(e,t){let n=t.filter(e=>!e.ephemeral&&(e.status===`streaming`||e.status===`pending`||e.status===`error`||e.retryAction!==void 0||(e.attachments?.length??0)>0||No(e))),r=/* @__PURE__ */ new Map;for(let e of n)r.set(e.id,e),e.serverMessageId!==void 0&&r.set(e.serverMessageId,e);let i=/* @__PURE__ */ new Set,a=[],o=e.map(e=>{let t=(e.serverMessageId===void 0?void 0:r.get(e.serverMessageId))??r.get(e.id);return t===void 0?(a.push(e),e):(i.add(t),t.role===e.role?t.role===`user`&&t.serverMessageId===void 0&&(t.status===`pending`||t.status===`error`)?Wo(t,e):t.status===`streaming`||jo(t).length>=jo(e).length?(qo(t,e),t.suggestions??(t.suggestions=e.suggestions),t.feedback===void 0&&(t.feedback=e.feedback),e.canceled&&(t.canceled=!0),t):Wo(t,e):e)}),s=n.filter(e=>!i.has(e)),c=s.findLast(Ko),l=/* @__PURE__ */ new Map;e.forEach((e,t)=>{l.set(e.id,t),e.serverMessageId!==void 0&&l.set(e.serverMessageId,t)});let u=Go(c,c?n.slice(0,n.indexOf(c)):[],a,l);if(c&&u){let e=o.indexOf(u);e>=0&&(o[e]=Wo(c,u)),s=s.filter(e=>e!==c)}return[...o,...s]}function Yo(e,t){let n=new Map(t.filter(e=>e.serverMessageId!==void 0).map(e=>[e.serverMessageId,e])),r=/* @__PURE__ */ new Map;t.forEach((e,t)=>{r.set(e.id,t),e.serverMessageId!==void 0&&r.set(e.serverMessageId,t)});let i=new Set(e.flatMap(e=>[e.serverMessageId,e.id].filter(e=>e!==void 0))),a=!1,o=e.map(e=>{let t=n.get(e.serverMessageId??e.id);if(t===void 0||t.role!==e.role)return e;if(e.role===`user`&&e.serverMessageId===void 0)return a=!0,Wo(e,t);if(e.serverMessageId===void 0)return e;let r=jo(t),i=jo(e),o=t.status!==`streaming`&&r.length>=i.length&&es(e,t);if(r.length>i.length||r===i&&t.partsSig.value.length>e.partsSig.value.length||o)return a=!0,Wo(e,t);if(e.status===`streaming`&&t.status!==`streaming`&&Zo(e,t)){if(e.continuationStreaming&&Ho(t))return e;if(!es(t,e))return a=!0,Wo(e,t)}return e}),s=[...n.values()].filter(e=>!i.has(e.serverMessageId)),c=o.findLastIndex(Ko),l=o[c],u=Go(l,o.slice(0,c),s,r);if(l!==void 0&&u!==void 0&&jo(u).length>=jo(l).length&&(Wo(l,u),o[c]=u,s.splice(s.indexOf(u),1),a=!0),s.length===0)return{messages:a?o:e,changed:a};for(let e of s){let t=r.get(e.serverMessageId??e.id),n=!1,i=o.findIndex(e=>{let i=r.get(e.serverMessageId??e.id);return t===void 0?!1:i===void 0?n:i>t||(n=!0,!1)});i===-1?o.push(e):o.splice(i,0,e)}return{messages:o,changed:!0}}function Xo(e,t){if(e.role!==t.role)return!1;let n=jo(t),r=jo(e);return n.length>r.length||t.partsSig.value.length>e.partsSig.value.length||es(e,t)}function Zo(e,t){let n=e.partsSig.value,r=t.partsSig.value;return n.length===r.length&&n.every((e,t)=>{let n=r[t];switch(e.kind){case`text`:return n?.kind===`text`&&n.textSig.value===e.textSig.value;case`reasoning`:return n?.kind===`reasoning`&&n.textSig.value===e.textSig.value;case`step-start`:return n?.kind===`step-start`;case`tool`:return n?.kind===`tool`&&n.toolCallId===e.toolCallId&&Qo(n.toolName,e.toolName);case`file`:return n?.kind===`file`&&n.url===e.url&&n.mediaType===e.mediaType;case`source`:return n?.kind===`source`&&n.sourceId===e.sourceId&&n.url===e.url&&n.title===e.title&&n.filename===e.filename&&n.mediaType===e.mediaType;default:return e}})}function Qo(e,t){return(e.startsWith(`tool:`)?e.slice(5):e)===(t.startsWith(`tool:`)?t.slice(5):t)}const $o={"input-streaming":0,"input-available":1,"approval-requested":2,"approval-responded":3,"output-available":4,"output-denied":4,"output-error":4};function es(e,t){let n=new Map(e.partsSig.value.filter(Io).map(e=>[e.toolCallId,e]));return t.partsSig.value.filter(Io).some(e=>{let t=n.get(e.toolCallId);if(!t||$o[e.stateSig.value]>$o[t.stateSig.value])return!0;let r=e.approvalSig.value?.approved;return r!==void 0&&r!==t.approvalSig.value?.approved})}function ts(e){return e.role===`assistant`&&e.status!==`streaming`&&!No(e)}function ns(e,t){if(!e.includes(t)||t.retryAction===null)return;if(t.retryAction)return t.retryAction;if(t!==e.at(-1)||t.role!==`assistant`||t.serverMessageId===void 0||t.status!==`error`&&!ts(t))return;let n=e.indexOf(t);for(let t=n-1;t>=0;t--){let n=e[t];if(n?.role===`user`&&!n.ephemeral)return{kind:`repeat-user`,messageId:n.id}}}function rs(e){return e.canceled===!0&&e.role===`assistant`&&e.status!==`streaming`&&!Po(e)}function is(e,t){return e.operatorRoutedTurn?ts(e)?`drop`:`complete-operator-routed`:t||ts(e)?`error`:`complete`}function as(e){return e.kind===`text`||e.kind===`reasoning`?{kind:e.kind,id:e.id,textSig:H(e.text),doneSig:H(e.done)}:e.kind===`tool`?{kind:`tool`,toolCallId:e.toolCallId,toolName:e.toolName,dynamic:e.dynamic,inputPartialSig:H(e.inputPartial),inputSig:H(e.input),outputSig:H(e.output),errorSig:H(e.error),stateSig:H(e.state),approvalSig:H(e.approval)}:e}function os(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,dynamic:e.dynamic,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}function ss(e,t){return new Promise(n=>{if(t?.aborted)return n();let r=setTimeout(a,e);function i(){return a()}t?.addEventListener(`abort`,i,{once:!0});function a(){clearTimeout(r),t?.removeEventListener(`abort`,i),n()}})}function cs(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function ls(e){return e&&Object.keys(e).length>0?e:void 0}function us(e,t){let n=ls(e),r=ls(t);if(!n&&!r)return;let i={};return n&&(i.user=n),r&&(i.page=r),cs(JSON.stringify(i))}var ds=class extends Error{constructor(e,t,n,r){super(e),this.code=t,this.status=n,this.cause=r,this.name=`StreamError`}};const fs=I.scope(`parser`);async function*ps(e,t,n){if(!e.ok){let t=await e.text().catch(()=>``);throw new ds(`server responded ${e.status}: ${t.slice(0,200)}`,`server`,e.status)}for await(let r of ms(e,t)){let e=hs(r,n);if(e===`done`)return;e&&(yield e)}}async function*ms(e,t){if(!e.body)throw new ds(`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:e,value:i}=await n.read();if(e){let e=r.trim();e&&(yield e);return}r+=i;let a;for(;(a=r.indexOf(`
55
+ `:``),n=r),o=void 0}let c=Zi({data:void 0,add_token(e,t){a+=1,t===10&&a===1&&(o={start:i,source:``,language:``})},set_attr(e,t,n){o&&t===4&&(o.language=n)},add_text(e,t){o&&(o.source+=t)},end_token(){o&&s(Math.min(r+1,e.length)),--a}});for(;r<e.length;r++)la(c,e.charAt(r)),e[r]===`
56
+ `&&(i=r+1);return Qi(c),o&&s(e.length),t+e.slice(n)}function es(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function ts(e){return`tool-${e.startsWith(`tool:`)?e.slice(5):e}`}function ns(e){return e.startsWith(`tool-`)?e.slice(5):e}const rs={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`,messageFeedback:`/pai/message-feedback`,requestOperator:`/pai/request-operator`,cancelOperatorRequest:`/pai/cancel-request-operator`,bootstrap:`/pai/bootstrap`,content:`/pai/content`,contentCollections:`/pai/content/collection/list`,contentVoteSet:`/pai/content/vote/set`,submitForm:`/pai/submit-form`},is=`context`;function as(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function os(e){if(!as(e))return;let t=e,n=t.controlMode,r=t.controlRevision;if(!(n!==`ai-agent`&&n!==`awaiting-operator`&&n!==`operator`||typeof r!=`number`||!Number.isSafeInteger(r)||r<0))return{controlMode:n,controlRevision:r,assignedOperatorInitials:typeof t.assignedOperatorInitials==`string`&&t.assignedOperatorInitials?t.assignedOperatorInitials:void 0,operatorAvailable:typeof t.operatorAvailable==`boolean`?t.operatorAvailable:void 0}}function ss(e){if(!as(e))return;let t=e.status,n=e.postFinishSequence;if(!(t!==`compacting`&&t!==`ready`||typeof n!=`number`||!Number.isSafeInteger(n)||n<0))return{status:t,postFinishSequence:n}}function cs(e){let t=as(e)?e.suggestions:void 0;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!as(e))continue;let{id:t,label:r,text:i}=e;typeof r==`string`&&r&&n.push({id:typeof t==`string`&&t?t:`s${n.length}`,label:r,text:typeof i==`string`&&i?i:r})}return n}function ls(e){let t={messages:e.messages.map(e=>({id:e.serverMessageId??e.id,parts:ds(e),role:e.role})),conversationId:e.conversationId,responseType:`ack`};return e.visitorId&&(t.visitorId=e.visitorId),e.userPrefs&&(t.userPrefs=e.userPrefs),e.clientTools?.length&&(t.clientTools=e.clientTools),t}function us(e){return e.state===`output-available`||e.state===`output-error`||e.state===`output-denied`||e.approval?.approved!==void 0}function ds(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`&&us(n)){let e=n.dynamic?{type:`dynamic-tool`,toolName:n.toolName,toolCallId:n.toolCallId,state:n.state}:{type:ts(n.toolName),toolCallId:n.toolCallId,state:n.state};n.input!==void 0&&(e.input=n.input),n.output!==void 0&&(e.output=n.output),n.error!==void 0&&(e.errorText=n.error),n.approval?.approved!==void 0&&(e.approval=n.approval),n.toolMetadata&&(e.toolMetadata=n.toolMetadata),t.push(e)}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}function fs(e,t,n=Fn()){let r=e?[{kind:`text`,id:`t0`,textSig:V(e),doneSig:V(!0)}]:[];return{id:n,role:`user`,createdAt:Date.now(),status:`complete`,attachments:t,partsSig:V(r)}}function ps(){return{id:Fn(),role:`assistant`,createdAt:Date.now(),status:`streaming`,partsSig:V([])}}function ms(e){let t=Fn();return hs({id:t,role:e.role,createdAt:Date.now(),status:`complete`,ephemeral:!0,parts:[{kind:`text`,id:`${t}-t0`,text:e.text,done:!0}]})}function hs(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,canceled:e.canceled,errorText:e.errorText,finishReason:e.finishReason,serverMessageId:e.serverMessageId,ephemeral:e.ephemeral,attachments:e.attachments,feedback:e.feedback,partsSig:V(e.parts.map(Zs))}}function gs(e){return e.status===`failed`?`error`:e.role===`assistant`&&e.status===`streaming`?`streaming`:`complete`}function _s(e){let t=/* @__PURE__ */ new Set,n=e.parts.map((t,n)=>t.type===`text`?{kind:`text`,id:`${e.id}-t${n}`,textSig:V(t.text),doneSig:V(!0)}:t.type===`reasoning`?{kind:`reasoning`,id:`${e.id}-r${n}`,textSig:V(t.text),doneSig:V(t.state!==`streaming`)}:t.type===`step-start`?{kind:`step-start`,id:`${e.id}-ss${n}`}:t.type===`file`?{kind:`file`,url:t.url,mediaType:t.mediaType}:t.type===`source-url`?{kind:`source`,sourceId:t.sourceId,url:t.url,title:t.title}:t.type===`source-document`?{kind:`source`,sourceId:t.sourceId,title:t.title,filename:t.filename,mediaType:t.mediaType}:t.type===`data-suggestions`?null:t.type===`dynamic-tool`||t.type.startsWith(`tool-`)?{kind:`tool`,toolCallId:t.toolCallId,toolName:t.type===`dynamic-tool`?t.toolName:ns(t.type),dynamic:t.type===`dynamic-tool`||void 0,toolMetadata:t.toolMetadata,inputPartialSig:V(``),inputSig:V(t.input),outputSig:V(t.output),errorSig:V(t.errorText),stateSig:V(t.state),approvalSig:V(t.approval)}:null).filter(e=>e!==null).filter(e=>e.kind!==`source`||!t.has(e.sourceId)&&(t.add(e.sourceId),!0)),r=e.parts.find(e=>e.type===`data-suggestions`);return{id:e.id,role:e.role,operatorInitials:e.operatorInitials,suggestions:r?.type===`data-suggestions`?cs(r.data):void 0,serverMessageId:e.id,createdAt:Date.parse(e.createdAt),status:gs(e),canceled:e.status===`canceled`,feedback:e.feedback??null,partsSig:V(n)}}function vs(e){return!e.parts.some(e=>e.type===`text`&&e.text.trim()!==``||e.type===`dynamic-tool`||e.type.startsWith(`tool-`)||e.type===`file`||e.type===`source-url`||e.type===`source-document`)}function ys(e){return e.role===`assistant`&&e.status===`streaming`&&vs(e)}function bs(e){let t=e.length-1;return e.filter((e,n)=>n===t||!ys(e)).map(_s)}function xs(e,t){let n=!t&&e.at(-1)?.role===`assistant`?-2:-1,r=e.at(n);return!r||r.ephemeral?[]:[r]}function Ss(e){return{id:e.id,role:e.role,createdAt:e.createdAt,status:e.status,canceled:e.canceled,errorText:e.errorText,finishReason:e.finishReason,serverMessageId:e.serverMessageId,ephemeral:e.ephemeral,attachments:e.attachments,parts:e.partsSig.value.map(Qs)}}function Cs(e){let t=``;for(let n of e.partsSig.value)n.kind===`text`&&(t+=n.textSig.value);return t}function ws(e,t,n,r,i,a=t.createdAt){let o=e.find(e=>e.role===`user`&&!e.ephemeral);function s(e,t){return(e.role===`assistant`?$o(Cs(e)):Cs(e)).replace(/\s+/g,` `).trim().slice(0,t)}let c=o?s(o,80):``,l=s(t,120);return{conversationId:n,title:c||r,lastMessageAt:new Date(a).toISOString(),preview:l||void 0,canContinue:i}}function Ts(e){return Cs(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`||e.kind===`source`)}function Es(e){return Cs(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`)}function Ds(e){return e===`approval-responded`||e===`output-available`||e===`output-denied`||e===`output-error`}function Os(e){return e.kind===`tool`}function ks(e){return e.kind===`text`&&e.textSig.value.trim()!==``||e.kind===`file`}function As(e){let t=e.partsSig.value,n=t.findLastIndex(e=>e.kind===`tool`);return t.slice(n+1).some(ks)}function js(e){if(e.role!==`assistant`)return!1;let t=e.partsSig.value.filter(Os);return t.length>0&&t.every(e=>Ds(e.stateSig.value))}function Ms(e){return e.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`)&&!As(e)}function Ns(e,t){return!e.partsSig.value.slice(t+1).some(e=>e.kind===`step-start`||ks(e))}function Ps(e){return e.partsSig.value.some(e=>Os(e)&&!Ds(e.stateSig.value))}function Fs(e,t){if(t.length===0)return e;let n=/* @__PURE__ */ new Set;for(let t of e)n.add(t.id),t.serverMessageId&&n.add(t.serverMessageId);let r=t.filter(e=>{let t=[e.id,e.serverMessageId].filter(e=>e!==void 0);return!t.some(e=>n.has(e))&&(t.forEach(e=>n.add(e)),!0)});if(r.length===0)return e;let i=e.findIndex(e=>!e.ephemeral),a=i<0?e.length:i;return[...e.slice(0,a),...r,...e.slice(a)]}function Is(e,t){return t.id=e.id,e.canceled&&(t.canceled=!0),e.feedback!==void 0&&(t.feedback=e.feedback),t.suggestions??(t.suggestions=e.suggestions),t}function Ls(e,t,n,r){if(!Rs(e))return;if(t.length===0){let t=Math.max(...r.values());return n.find(n=>n.role===`assistant`&&r.get(n.serverMessageId??n.id)===t&&Cs(n).length>=Cs(e).length)}let i=t.at(-1);if(i?.role!==`user`)return;let a=r.get(i.serverMessageId??i.id);if(a!==void 0)return n.find(t=>t.role===`assistant`&&r.get(t.serverMessageId??t.id)===a+1&&Cs(t).length>=Cs(e).length)}function Rs(e){return e?.role===`assistant`&&e.status===`streaming`&&e.serverMessageId===void 0}function zs(e,t){let n=new Map(t.partsSig.value.filter(Os).filter(e=>Ds(e.stateSig.value)).map(e=>[e.toolCallId,e]));if(n.size===0)return;let r=!1,i=e.partsSig.value.map(e=>{if(!Os(e))return e;let t=n.get(e.toolCallId);if(!t)return e;let i=e.approvalSig.value,a=t.approvalSig.value,o=i===void 0||i.approved===void 0&&a?.approved!==void 0?t.approvalSig:e.approvalSig,s=e.inputSig.value===void 0?t.inputSig:e.inputSig,c=e.toolName===`tool`?t.toolName:e.toolName,l=e.dynamic??t.dynamic;return o===e.approvalSig&&s===e.inputSig&&c===e.toolName&&l===e.dynamic?e:(r=!0,{...e,toolName:c,dynamic:l,inputSig:s,approvalSig:o})});r&&(e.partsSig.value=i)}function Bs(e,t){let n=t.filter(e=>!e.ephemeral&&(e.status===`streaming`||e.status===`pending`||e.status===`error`||e.retryAction!==void 0||(e.attachments?.length??0)>0||Ts(e))),r=/* @__PURE__ */ new Map;for(let e of n)r.set(e.id,e),e.serverMessageId!==void 0&&r.set(e.serverMessageId,e);let i=/* @__PURE__ */ new Set,a=[],o=e.map(e=>{let t=(e.serverMessageId===void 0?void 0:r.get(e.serverMessageId))??r.get(e.id);return t===void 0?(a.push(e),e):(i.add(t),t.role===e.role?t.role===`user`&&t.serverMessageId===void 0&&(t.status===`pending`||t.status===`error`)?Is(t,e):t.status===`streaming`||Cs(t).length>=Cs(e).length?(zs(t,e),t.suggestions??(t.suggestions=e.suggestions),t.feedback===void 0&&(t.feedback=e.feedback),e.canceled&&(t.canceled=!0),t):Is(t,e):e)}),s=n.filter(e=>!i.has(e)),c=s.findLast(Rs),l=/* @__PURE__ */ new Map;e.forEach((e,t)=>{l.set(e.id,t),e.serverMessageId!==void 0&&l.set(e.serverMessageId,t)});let u=Ls(c,c?n.slice(0,n.indexOf(c)):[],a,l);if(c&&u){let e=o.indexOf(u);e>=0&&(o[e]=Is(c,u)),s=s.filter(e=>e!==c)}return[...o,...s]}function Vs(e,t){let n=new Map(t.filter(e=>e.serverMessageId!==void 0).map(e=>[e.serverMessageId,e])),r=/* @__PURE__ */ new Map;t.forEach((e,t)=>{r.set(e.id,t),e.serverMessageId!==void 0&&r.set(e.serverMessageId,t)});let i=new Set(e.flatMap(e=>[e.serverMessageId,e.id].filter(e=>e!==void 0))),a=!1,o=e.map(e=>{let t=n.get(e.serverMessageId??e.id);if(t===void 0||t.role!==e.role)return e;if(e.role===`user`&&e.serverMessageId===void 0)return a=!0,Is(e,t);if(e.serverMessageId===void 0)return e;let r=Cs(t),i=Cs(e),o=t.status!==`streaming`&&r.length>=i.length&&Ks(e,t);if(r.length>i.length||r===i&&t.partsSig.value.length>e.partsSig.value.length||o)return a=!0,Is(e,t);if(e.status===`streaming`&&t.status!==`streaming`&&Us(e,t)){if(e.continuationStreaming&&Ps(t))return e;if(!Ks(t,e))return a=!0,Is(e,t)}return e}),s=[...n.values()].filter(e=>!i.has(e.serverMessageId)),c=o.findLastIndex(Rs),l=o[c],u=Ls(l,o.slice(0,c),s,r);if(l!==void 0&&u!==void 0&&Cs(u).length>=Cs(l).length&&(Is(l,u),o[c]=u,s.splice(s.indexOf(u),1),a=!0),s.length===0)return{messages:a?o:e,changed:a};for(let e of s){let t=r.get(e.serverMessageId??e.id),n=!1,i=o.findIndex(e=>{let i=r.get(e.serverMessageId??e.id);return t===void 0?!1:i===void 0?n:i>t||(n=!0,!1)});i===-1?o.push(e):o.splice(i,0,e)}return{messages:o,changed:!0}}function Hs(e,t){if(e.role!==t.role)return!1;let n=Cs(t),r=Cs(e);return n.length>r.length||t.partsSig.value.length>e.partsSig.value.length||Ks(e,t)}function Us(e,t){let n=e.partsSig.value,r=t.partsSig.value;return n.length===r.length&&n.every((e,t)=>{let n=r[t];switch(e.kind){case`text`:return n?.kind===`text`&&n.textSig.value===e.textSig.value;case`reasoning`:return n?.kind===`reasoning`&&n.textSig.value===e.textSig.value;case`step-start`:return n?.kind===`step-start`;case`tool`:return n?.kind===`tool`&&n.toolCallId===e.toolCallId&&Ws(n.toolName,e.toolName);case`file`:return n?.kind===`file`&&n.url===e.url&&n.mediaType===e.mediaType;case`source`:return n?.kind===`source`&&n.sourceId===e.sourceId&&n.url===e.url&&n.title===e.title&&n.filename===e.filename&&n.mediaType===e.mediaType;default:return e}})}function Ws(e,t){return(e.startsWith(`tool:`)?e.slice(5):e)===(t.startsWith(`tool:`)?t.slice(5):t)}const Gs={"input-streaming":0,"input-available":1,"approval-requested":2,"approval-responded":3,"output-available":4,"output-denied":4,"output-error":4};function Ks(e,t){let n=new Map(e.partsSig.value.filter(Os).map(e=>[e.toolCallId,e]));return t.partsSig.value.filter(Os).some(e=>{let t=n.get(e.toolCallId);if(!t||Gs[e.stateSig.value]>Gs[t.stateSig.value])return!0;let r=e.approvalSig.value?.approved;return r!==void 0&&r!==t.approvalSig.value?.approved})}function qs(e){return e.role===`assistant`&&e.status!==`streaming`&&!Ts(e)}function Js(e,t){if(!e.includes(t)||t.retryAction===null)return;if(t.retryAction)return t.retryAction;if(t!==e.at(-1)||t.role!==`assistant`||t.serverMessageId===void 0||t.status!==`error`&&!qs(t))return;let n=e.indexOf(t);for(let t=n-1;t>=0;t--){let n=e[t];if(n?.role===`user`&&!n.ephemeral)return{kind:`repeat-user`,messageId:n.id}}}function Ys(e){return e.canceled===!0&&e.role===`assistant`&&e.status!==`streaming`&&!Es(e)}function Xs(e,t){return e.operatorRoutedTurn?qs(e)?`drop`:`complete-operator-routed`:t||qs(e)?`error`:`complete`}function Zs(e){return e.kind===`text`||e.kind===`reasoning`?{kind:e.kind,id:e.id,textSig:V(e.text),doneSig:V(e.done)}:e.kind===`tool`?{kind:`tool`,toolCallId:e.toolCallId,toolName:e.toolName,dynamic:e.dynamic,toolMetadata:e.toolMetadata,inputPartialSig:V(e.inputPartial),inputSig:V(e.input),outputSig:V(e.output),errorSig:V(e.error),stateSig:V(e.state),approvalSig:V(e.approval)}:e}function Qs(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,dynamic:e.dynamic,toolMetadata:e.toolMetadata,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}function $s(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function ec(e){return e&&Object.keys(e).length>0?e:void 0}function tc(e,t,n=[]){let r=ec(e),i=ec(t),a=Date.now();for(let e=n.length;;--e){let t=n.slice(n.length-e).map(({name:e,data:t,at:n})=>({name:e,data:t,secondsAgo:Math.round((a-n)/1e3)})),o=t.length>0?{...i,recentEvents:t}:i;if(!r&&!o)return;let s=$s(JSON.stringify({...r&&{user:r},...o&&{page:o}}));if(s.length<=8192||e===0)return s}}var nc=class extends Error{constructor(e,t,n,r){super(e),this.code=t,this.status=n,this.cause=r,this.name=`StreamError`}};const rc=C.scope(`parser`);async function*ic(e,t,n){if(!e.ok){let t=await e.text().catch(()=>``);throw new nc(`server responded ${e.status}: ${t.slice(0,200)}`,`server`,e.status)}for await(let r of ac(e,t)){let e=oc(r,n);if(e===`done`)return;e&&(yield e)}}async function*ac(e,t){if(!e.body)throw new nc(`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:e,value:i}=await n.read();if(e){let e=r.trim();e&&(yield e);return}r+=i;let a;for(;(a=r.indexOf(`
57
57
 
58
- `))!==-1;){let e=r.slice(0,a);r=r.slice(a+2),yield e}}}finally{n.releaseLock()}}function hs(e,t){let n=``,r;for(let i of e.split(`
59
- `))if(i!==``){if(i.startsWith(`:`))t?.(i.slice(1).trim());else if(i.startsWith(`data:`)){let e=i.slice(5).replace(/^ /,``);n=n?`${n}\n${e}`:e}else i.startsWith(`id:`)&&(r=i.slice(3).trim())}if(n===`[DONE]`)return`done`;if(!n)return null;try{let e=JSON.parse(n);return fs.trace(`chunk`,{type:e.type,eventId:r}),{chunk:e,eventId:r}}catch(e){throw fs.trace(`frame parse failed`,{errorType:e instanceof Error?e.name:typeof e,payloadLength:n.length}),new ds(`invalid SSE frame`,`network`,void 0,e)}}const J=I.scope(`transport`),gs=6e4,_s=/* @__PURE__ */ new WeakMap;function vs(e){return _s.get(e)}function ys(e,t){return _s.set(e,t),e}function bs(e){return Math.max(e?.upsertRevision??0,e?.read?.revision??0)}function xs(e,t){return e.conversationId===t.conversationId&&e.title===t.title&&e.lastMessageAt===t.lastMessageAt&&e.preview===t.preview&&e.canContinue===t.canContinue&&e.hasUnread===t.hasUnread&&e.controlState===t.controlState}function Ss(e,t,n=!0){switch(t.type){case`snapshot`:{let n=new Map(e.map(e=>[e.conversationId,e])),r=e.filter(e=>(vs(e)?.activityRevision??0)>t.requestedRevision).toSorted((e,t)=>vs(t).activityRevision-vs(e).activityRevision),i=new Set(r.map(e=>e.conversationId));return[...r,...t.result.conversations.filter(e=>!i.has(e.conversationId)).map(e=>{let r=n.get(e.conversationId);if(!r)return e;let i=vs(r);return(i?.upsertRevision??0)>t.requestedRevision?r:i?.read&&!r.hasUnread&&i.read.lastMessageAt===e.lastMessageAt?ys({...e,hasUnread:!1},{upsertRevision:0,read:i.read}):e})]}case`read`:{let n=e.findIndex(e=>e.conversationId===t.conversationId&&(t.lastMessageAt===void 0||e.lastMessageAt===t.lastMessageAt));if(n<0)return e;let r=e[n],i=vs(r);if(bs(i)>t.revision)return e;let a=t.lastMessageAt??r.lastMessageAt,o={upsertRevision:i?.upsertRevision??0,...i?.activityRevision===void 0?{}:{activityRevision:i.activityRevision},read:{revision:t.revision,...a?{lastMessageAt:a}:{}}};return r.hasUnread?e.map((e,t)=>t===n?ys({...e,hasUnread:!1},o):e):(ys(r,o),e)}case`upsert`:{let r=e.findIndex(e=>e.conversationId===t.conversation.conversationId);if(r<0&&!n)return e;let i=r<0?void 0:e[r],a=i?vs(i):void 0;if(bs(a)>t.revision)return e;let o=t.activity?t.revision:a?.activityRevision,s={upsertRevision:t.revision,...o===void 0?{}:{activityRevision:o},...!t.conversation.hasUnread&&a?.read?{read:a.read}:{}},c=i?{...i,...t.conversation,title:i.title}:{...t.conversation};return i&&xs(i,c)?(ys(i,s),e):(ys(c,s),t.activity?[c,...e.filter(e=>e.conversationId!==c.conversationId)]:i?e.map((e,t)=>t===r?c:e):[...e,c])}default:return t}}const Cs=/* @__PURE__ */ new Set([408,425,429,500,502,503,504]);function ws(e){return 400*2**e+Math.floor(Math.random()*250)}function Ts(e){return 6e4+Math.ceil(e/1048576)*15e3}function Es(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}var Ds=class{constructor(e){this.ttlMs=e,s(this,`map`,/* @__PURE__ */ new Map)}getOrFetch(e,t){let n=this.map.get(e);if(n&&performance.now()-n.at<this.ttlMs)return n.result;let r={at:performance.now(),result:t().then(e=>(r.value=e,e)).catch(t=>{throw this.map.get(e)===r&&this.map.delete(e),t})};return this.map.set(e,r),r.result}peek(e){let t=this.map.get(e);if(t?.value!==void 0&&performance.now()-t.at<this.ttlMs)return t.value}update(e){for(let t of this.map.values())if(t.value!==void 0){let n=e(t.value);t.value=n,t.result=Promise.resolve(n)}else t.result=t.result.then(n=>{let r=e(n);return t.value=r,r})}delete(e){this.map.delete(e)}},Os=class{constructor(e){this.opts=e,s(this,`conversationListeners`,/* @__PURE__ */ new Set),s(this,`conversationRevision`,0),s(this,`visitorId`,void 0),s(this,`conversationId`,void 0),s(this,`userContext`,void 0),s(this,`pageContext`,void 0),s(this,`locale`,void 0),s(this,`userTokenSource`,void 0),s(this,`userToken`,void 0),s(this,`userTokenRequest`,void 0),s(this,`conversationsCache`,new Ds(1e4)),s(this,`contentCache`,new Ds(gs)),s(this,`contentCollectionsCache`,new Ds(gs))}setUserToken(e){this.userTokenSource=e,this.userToken=typeof e==`string`&&e||void 0,this.userTokenRequest=typeof e==`function`?this.fetchUserToken():void 0}setContext(e,t){this.userContext=e,this.pageContext=t}setLocale(e){this.locale=e}primeIdentity(e,t){e&&(this.visitorId=e),t&&(this.conversationId=t)}envelope(){let e={_ev:Yt};this.visitorId&&(e.visitorId=this.visitorId),this.conversationId&&(e.conversationId=this.conversationId),this.locale&&(e.locale=this.locale);let t=us(this.userContext,this.pageContext);return t&&(e.context=t),e}withEnvelope(e){return{...this.envelope(),...e}}appendEnvelope(e){for(let[t,n]of Object.entries(this.envelope()))e.append(t,n);return e}withEnvelopeQuery(e){let t=new URL(this.url(e));for(let[e,n]of Object.entries(this.envelope()))t.searchParams.has(e)||t.searchParams.set(e,n);return t.toString()}async handshake(e){J.debug(`handshake →`,{visitorId:e.visitorId,conversationId:e.conversationId,locale:e.locale}),this.userTokenRequest&&await this.userTokenRequest;let t=await this.postJson(fo.handshake,e,`handshake`);return J.debug(`handshake ←`,{visitorId:t.visitorId,conversationId:t.conversationId,hasWelcome:!!t.welcome,hasConfig:!!t.config,rebind:t.rebind}),this.visitorId=e.visitorId,this.conversationId=t.conversationId,t}async uploadFile(e,t){J.debug(`uploadFile →`,{name:e.name,size:e.size,type:e.type});let n=new FormData;n.append(`file`,e,e.name);let r=await this.postForm(this.uploadPath,n,`upload`,t,Ts(e.size));return J.debug(`uploadFile ←`,{id:r.id,url:r.url}),r}async transcribe(e,t=`audio/webm`){J.debug(`transcribe →`,{size:e.size,mimeType:t});let n=new FormData;n.append(`audio`,e,`voice.${ks(t)}`),n.append(`mimeType`,t);let r=await this.postForm(this.transcribePath,n,`transcribe`);return J.debug(`transcribe ←`,{textLen:r.text.length}),r}subscribeConversationChanges(e){return this.conversationListeners.add(e),()=>this.conversationListeners.delete(e)}publishConversation(e,t=!1){let n={type:`upsert`,conversation:e,revision:++this.conversationRevision,...t?{activity:!0}:{}};this.conversationsCache.update(r=>{let i=r.pagination.page===1,a=r.conversations.some(t=>t.conversationId===e.conversationId),o=Ss(r.conversations,n,i&&t),s=i&&o.length>r.pagination.limit?o.slice(0,r.pagination.limit):o;if(!i||!t||a||r.pagination.hasNext)return s===r.conversations?r:{...r,conversations:s};let c=Math.max(r.pagination.total,r.conversations.length)+1,l=Math.ceil(c/r.pagination.limit);return{...r,conversations:s,pagination:{...r.pagination,total:c,totalPages:l,hasNext:r.pagination.page<l}}});for(let e of this.conversationListeners)e(n)}localeCacheKey(e){return`${this.locale??``}|${JSON.stringify(e,Object.keys(e).toSorted())}`}peekConversations(e={}){return this.conversationsCache.peek(this.localeCacheKey(e))}listConversations(e={},t=!1){if((e.page??1)>1)return this.fetchConversations(e);let n=this.localeCacheKey(e),r=this.conversationRevision;t&&this.conversationsCache.delete(n);let i=this.conversationsCache.getOrFetch(n,()=>this.fetchConversations(e));return t?i.then(e=>{let t={type:`snapshot`,result:e,requestedRevision:r};for(let e of this.conversationListeners)e(t);return e}):i}async fetchConversations(e){let t=new URL(this.url(fo.listConversations));return e.visitorId&&t.searchParams.set(`visitorId`,e.visitorId),e.page&&t.searchParams.set(`page`,String(e.page)),e.limit&&t.searchParams.set(`limit`,String(e.limit)),e.ids?.length&&t.searchParams.set(`ids`,e.ids.join(`,`)),this.getJson(t.toString(),`listConversations`)}async loadConversation(e,{ids:t=[],beforeId:n,beforeCreatedAt:r}={}){let i=new URL(this.url(fo.listMessages));i.searchParams.set(`conversationId`,e),i.searchParams.set(`limit`,`50`),t.length>0&&i.searchParams.set(`ids`,t.join(`,`)),n&&i.searchParams.set(`beforeId`,n),r&&i.searchParams.set(`beforeCreatedAt`,r);let a=await this.getJson(i.toString(),`loadConversation`);return{...a,messages:a.messages.toReversed()}}async markRead(e,t){if(!this.visitorId||!e)return;let n={type:`read`,conversationId:e,...t===void 0?{}:{lastMessageAt:t},revision:++this.conversationRevision};this.conversationsCache.update(e=>{let t=Ss(e.conversations,n);return t===e.conversations?e:{...e,conversations:t}});for(let e of this.conversationListeners)e(n);try{await this.postJson(fo.markRead,{conversationId:e},`markRead`,!0)}catch(e){J.debug(`markRead failed (non-fatal)`,{err:e})}}async requestOperator(){if(this.visitorId&&this.conversationId)try{return(await this.postJson(fo.requestOperator,{},`requestOperator`)).controlState}catch(e){J.debug(`requestOperator failed (non-fatal)`,{err:e});return}}async cancelOperatorRequest(){if(this.visitorId&&this.conversationId)try{return(await this.postJson(fo.cancelOperatorRequest,{},`cancelOperatorRequest`)).controlState}catch(e){J.debug(`cancelOperatorRequest failed (non-fatal)`,{err:e});return}}listContent(e={}){return this.contentCache.getOrFetch(this.localeCacheKey(e),()=>this.fetchContent(e))}async fetchContent(e){let t=new URL(this.dataUrl(fo.content));for(let[n,r]of Object.entries(e))r!==void 0&&t.searchParams.set(n,Array.isArray(r)?r.join(`,`):String(r));let n=await this.getJson(t.toString(),`listContent`),r=n.items?.map(e=>be(e,this.locale))??[];return{...n,items:r}}async setContentVote(e){try{await this.postJson(this.dataUrl(fo.contentVoteSet),e,`setContentVote`)}catch{}}listContentCollections(e){return this.contentCollectionsCache.getOrFetch(this.localeCacheKey({ids:e}),()=>this.fetchContentCollections(e))}async fetchContentCollections(e){let t=new URL(this.dataUrl(fo.contentCollections));return e.length&&t.searchParams.set(`ids`,e.join(`,`)),{items:(await this.getJson(t.toString(),`listContentCollections`)).items?.map(e=>xe(e,this.locale))??[]}}async bootstrap(e){let t=new URL(this.dataUrl(fo.bootstrap));e&&t.searchParams.set(`conversationId`,e);let n=await this.getJson(t.toString(),`bootstrap`);return{forms:n.forms??[],formSubmissions:n.formSubmissions??[]}}async saveUserPrefs(e){return this.postJson(fo.updateSettings,{userPrefs:e},`saveUserPrefs`)}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??fo.submitForm}async submitForm(e){J.debug(`submitForm →`,{formId:e.formId,trigger:e.trigger,fields:Object.keys(e.values).length});try{await this.postJson(this.dataUrl(this.submitFormPath),e,`submitForm`)}catch(e){J.debug(`submitForm failed (non-fatal)`,{err:e})}}async submitFeedback(e){J.debug(`submitFeedback →`,{messageId:e.messageId,value:e.value});try{await this.postJson(fo.messageFeedback,{messageId:e.messageId,set:{feedback:e.value}},`submitFeedback`)}catch(e){J.debug(`submitFeedback failed (non-fatal)`,{err:e})}}async sendTurn(e){J.debug(`message →`,{conversationId:e.conversationId,visitorId:e.visitorId,messageCount:e.messages.length});try{return await this.runWithAbort(async t=>{let n=await this.withFreshUserToken(()=>this.fetchImpl(this.url(fo.streamMessage),{method:`POST`,credentials:`omit`,headers:{accept:`application/json`,"content-type":`application/json`,...this.headersFor(this.url(fo.streamMessage))},body:JSON.stringify(this.withEnvelope(e)),signal:t}));if(n.status!==202)throw new ds(`sendTurn failed: expected 202, received ${n.status}`,`server`,n.status);let r;try{r=await n.json()}catch(e){throw t?.aborted?e:new ds(`sendTurn failed: invalid acknowledgement`,`server`,n.status,e)}if(!As(r))throw new ds(`sendTurn failed: invalid acknowledgement`,`server`,n.status);return r},void 0,3e4)}catch(e){throw e instanceof ds?e:new ds(`sendTurn failed: network error`,`network`,void 0,e)}}cancelTurn(e,t){this.visitorId&&e&&t&&(J.debug(`cancel stream`,{conversationId:e,runId:t,visitorId:this.visitorId}),this.fetchImpl(this.url(fo.cancelStream),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.headersFor(this.url(fo.cancelStream))},body:JSON.stringify(this.withEnvelope({conversationId:e,runId:t})),keepalive:!0}).catch(e=>J.debug(`cancel POST failed (non-fatal)`,{err:e})))}async connectResumeStream(e){let t=new AbortController;function n(){return t.abort(e.signal.reason)}e.signal.aborted?n():e.signal.addEventListener(`abort`,n,{once:!0});let r=setTimeout(()=>t.abort(),1e4);function i(){clearTimeout(r),e.signal.removeEventListener(`abort`,n)}let a;try{this.userTokenRequest&&await this.userTokenRequest,a=await this.fetchImpl(this.resumeUrl(),{method:`GET`,credentials:`omit`,headers:{accept:`text/event-stream`,...this.headersFor(this.resumeUrl())},signal:t.signal})}catch(t){return i(),e.signal.aborted||J.debug(`resume-stream fetch failed — reconnecting`,{err:t}),`held`}if(!a.ok)return i(),a.status===401&&typeof this.userTokenSource==`function`?(await this.fetchUserToken(),`held`):a.status===409||Cs.has(a.status)?(J.debug(`resume-stream → transient response; reconnecting`,{status:a.status}),`held`):(J.debug(`resume-stream → endpoint unavailable`,{status:a.status}),`unavailable`);if(!a.body)return i(),J.debug(`resume-stream → bodyless response; stopping`,{status:a.status}),`unavailable`;if(!(a.headers.get(`content-type`)??``).includes(`text/event-stream`))return i(),J.debug(`resume-stream → non-SSE response; stopping`),`unavailable`;let o=!1;try{for await(let{chunk:n}of ps(a,t.signal,t=>{o||t!==`connected`||(o=!0,clearTimeout(r),e.onConnected())})){if(e.signal.aborted)return`held`;e.onChunk(n)}}catch(t){if(e.signal.aborted)return`held`;J.debug(`resume-stream segment dropped — reconnecting`,{err:t})}finally{i()}return`held`}resumeUrl(){return this.withEnvelopeQuery(fo.streamResume)}async postJson(e,t,n,r=!1){let i=await this.fetchWithRetry(()=>[this.url(e),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.headersFor(this.url(e))},body:JSON.stringify(this.withEnvelope(t)),...r?{keepalive:!0}:{}}],n);return this.assertOk(i,n)}async postForm(e,t,n,r,i){return this.runWithAbort(async r=>{let i=await this.withFreshUserToken(()=>this.fetchImpl(this.url(e),{method:`POST`,credentials:`omit`,headers:this.headersFor(this.url(e)),body:this.appendEnvelope(t),signal:r}));return this.assertOk(i,n)},r,i)}async runWithAbort(e,t,n){if(!t&&n===void 0)return e();let r=new AbortController;function i(){return r.abort(t?.reason)}t?.aborted?i():t?.addEventListener(`abort`,i,{once:!0});let a=n===void 0?void 0:setTimeout(()=>r.abort(),n);try{return await e(r.signal)}finally{a!==void 0&&clearTimeout(a),t?.removeEventListener(`abort`,i)}}async getJson(e,t){let n=await this.fetchWithRetry(()=>[this.withEnvelopeQuery(e),{method:`GET`,credentials:`omit`,headers:{accept:`application/json`,...this.headersFor(this.url(e))}}],t);return this.assertOk(n,t)}async fetchWithRetry(e,t){for(let n=0;;n++){let r;try{r=await this.withFreshUserToken(()=>this.fetchImpl(...e()))}catch(e){if(n>=3)throw new ds(`${t} failed: network error`,`network`,void 0,e);J.debug(`request network error — retrying`,{label:t,attempt:n}),await ss(ws(n));continue}if(r.ok||!Cs.has(r.status)||n>=3)return r;let i=Es(r.headers)??ws(n);J.debug(`request retryable status — retrying`,{label:t,status:r.status,attempt:n,wait:i}),await ss(i)}}async assertOk(e,t){if(!e.ok)throw new ds(`${t} failed: ${e.status}`,`server`,e.status);return await e.json()}fetchUserToken(){let e=this.userTokenSource;if(typeof e!=`function`)return Promise.resolve();let t=Promise.resolve().then(e).then(t=>{this.userTokenSource===e&&(this.userToken=t||void 0)},e=>{J.warn(`userToken function failed; continuing as an anonymous visitor`,{err:e})});return this.userTokenRequest=t,t}headersFor(e){let t=!/^https?:\/\//i.test(e)||e.startsWith(`${this.opts.agentApiBaseUrl}/`);return{...this.opts.auth.headers(),...t&&this.userToken?{"x-user-token":this.userToken}:{}}}async withFreshUserToken(e){let t=await e();return t.status!==401||!this.userTokenSource?t:typeof this.userTokenSource==`function`?(await this.fetchUserToken(),e()):(J.warn(`userToken rejected as invalid or expired; pass a function so the widget can fetch a fresh one`),t)}url(e){return/^https?:\/\//i.test(e)?e:`${this.opts.agentApiBaseUrl}${e}`}dataUrl(e){return/^https?:\/\//i.test(e)?e:`${this.opts.dataApiBaseUrl}${e}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function ks(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 As(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`status`),n=Reflect.get(e,`conversationId`),r=Reflect.get(e,`runId`);return t===`accepted`&&typeof n==`string`&&n.length>0&&(r===void 0||typeof r==`string`&&r.length>0)}function js(e,t,n){switch(e){case`clear`:case`sound`:case`history`:case`language`:case`theme`:case`textSize`:return!0;case`popOut`:return t!==`standalone`&&t!==`page`;case`expand`:return t===`floating`;case`fullscreen`:return t!==`standalone`;case`close`:return t===`standalone`||t===`page`?!1:t!==`inline`||n===`fullscreen`}}function Ms(e,t,n){return js(`close`,e,t)?n.includes(`close`):!1}function Ns(e,t){return e===`inline`&&t===`fullscreen`?`exit-fullscreen`:`close`}function Ps(e,t,n,r){let i={role:n,text:r};e.emit(`message`,i),t.onMessage?.(i)}function Fs(e){let t=z(e);t.current=e;let n=z(null);return n.current??(n.current=Is(t)),n.current}function Is(e){let t=H(null),n=/* @__PURE__ */ new Set;function r(t){return`${e.current.conversationId()??``}:${t}`}function i(t){return t.frequency===`always`?!1:t.frequency===`conversation`?n.has(r(t.id)):t.id in e.current.persistence.loadFormsDone()}function a(n,r){if(t.value)return;let a=e.current;if(n===`manual`){let e=a.forms.list.find(e=>e.id===r);e&&(t.value={form:e,trigger:`manual`})}else for(let e of a.forms.byTrigger[n]??[]){let r=e.triggers.find(e=>e.kind===n);if(r&&Ls(r,a)&&!i(e)&&Rs(e,a)){t.value={form:e,trigger:n};return}}}function o(i,a){let o=t.value;if(!o)return;t.value=null;let{form:s,trigger:c}=o;s.frequency===`conversation`?n.add(r(s.id)):s.frequency!==`always`&&e.current.persistence.saveFormDone(s.id),e.current.onComplete(s,c,i,a)}function s(){let n=t.value;if(!n)return;let r=e.current.forms.list.find(e=>e.id===n.form.id);r&&r!==n.form&&(t.value={form:r,trigger:n.trigger})}return{activeForm:t,fire:a,refresh:s,complete:e=>o(e,!1),skip:()=>o({},!0)}}function Ls(e,t){return e.kind===`after-messages`?t.messageCount()>=Number(e.param??0):e.kind!==`page-area`||t.pageArea()===e.param}function Rs(e,t){let n=e.when;if(!n)return!0;if(n.missingContext?.length){let e=t.userContext()??{};if(n.missingContext.some(t=>e[t]!==void 0&&e[t]!==``))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 zs(e){return Object.fromEntries(e.map(e=>[e,[]]))}function Bs(e,t,n){return e.includes(t)?t:e.includes(n)?n:e[0]??``}function Vs(e,t,n){let r=[...new Set(t)],i=H({activeTab:Bs(r,e,``),stacks:zs(r)});return{sig:i,reconcile(e,t){let a=[...new Set(e)],o=i.value,s=Bs(a,o.activeTab,t),c=Object.fromEntries(a.map(e=>[e,o.stacks[e]??[]])),l=s===o.activeTab&&a.length===Object.keys(o.stacks).length&&a.every(e=>o.stacks[e]===c[e]);r=a,!l&&(i.value={activeTab:s,stacks:c},s!==o.activeTab&&s&&n?.(s))},switchTab(e){e in i.value.stacks&&i.value.activeTab!==e&&(i.value={...i.value,activeTab:e},n?.(e))},open(e,t){let r=i.value;e in r.stacks&&(i.value={activeTab:e,stacks:{...r.stacks,[e]:t?[t]:[]}},r.activeTab!==e&&n?.(e))},push(e){let t=i.value,n=t.stacks[t.activeTab]??[];i.value={...t,stacks:{...t.stacks,[t.activeTab]:[...n,e]}}},pop(){let e=i.value,t=e.stacks[e.activeTab]??[];t.length!==0&&(i.value={...e,stacks:{...e.stacks,[e.activeTab]:t.slice(0,-1)}})},reset(e){i.value={activeTab:Bs(r,e,``),stacks:zs(r)}}}}function Hs(e){return e.stacks[e.activeTab]??[]}function Us(e){return Hs(e).at(-1)}function Ws(e){return Hs(e).length===0}function Gs(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`}function Ks(e,t,n){if(e===`standalone`||e===`page`)return`fullscreen`;let r=t.initialSize;return r===`expanded`||r===`fullscreen`||r===`normal`?r:n>0&&n<640?`fullscreen`:n>=(t.autoSizeBreakpoint??900)?`expanded`:`normal`}function qs(e,t,n,r=null){return{panelOpen:e.mode===`inline`||e.mode===`standalone`||e.mode===`page`||(n??!e.startMinimized),panelSize:e.mode!==`standalone`&&e.mode!==`page`&&e.mode!==`inline`&&r?r:Ks(e.mode,e.size,t)}}function Js(){return typeof window>`u`?0:window.innerWidth}const Y={fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`},Ys=`${P.cssPrefix}-icon-dir`;function Xs(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M21 12a8 8 0 0 1-12 6.93L3 21l1.65-5.16A8 8 0 1 1 21 12Z`})})}function Zs(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M18 6 6 18M6 6l12 12`})})}function Qs(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M12 5v14M5 12h14`})})}function $s(){return/* @__PURE__ */ U(`svg`,{...Y,class:Ys,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`m22 2-7 20-4-9-9-4Z`}),/* @__PURE__ */ U(`path`,{d:`M22 2 11 13`})]})}function ec(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M12 19V5M5 12l7-7 7 7`})})}function tc(){return/* @__PURE__ */ U(`svg`,{...Y,class:Ys,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 20V4l18 8-18 8Z`})})}function nc(){return/* @__PURE__ */ U(`svg`,{...Y,class:Ys,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`m9 18 6-6-6-6`})})}function rc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}function ic(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`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`})})}function ac(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`rect`,{x:`9`,y:`2`,width:`6`,height:`12`,rx:`3`}),/* @__PURE__ */ U(`path`,{d:`M5 10a7 7 0 0 0 14 0M12 19v3`})]})}function oc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5`})})}function sc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5`})})}function cc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z`})})}function lc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7`})})}function uc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M14 3h7v7M21 3l-9 9`}),/* @__PURE__ */ U(`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`})]})}function dc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,viewBox:`0 0 10 10`,children:/* @__PURE__ */ U(`path`,{d:`M9 1L1 9M9 5L5 9M9 9H9`,strokeWidth:`1.5`})})}function fc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`5`,r:`1.5`,fill:`currentColor`,stroke:`none`}),/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`1.5`,fill:`currentColor`,stroke:`none`}),/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`19`,r:`1.5`,fill:`currentColor`,stroke:`none`})]})}function pc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M11 5 6 9H2v6h4l5 4zM15 9a5 5 0 0 1 0 6M18 7a9 9 0 0 1 0 10`})})}function mc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6`})})}function hc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M3 18 8 6l5 12M4.7 14h6.6`}),/* @__PURE__ */ U(`path`,{d:`M14.5 18l3.2-7 3.2 7M15.6 15.8h4.2`})]})}function gc(){return/* @__PURE__ */ U(`svg`,{...Y,class:Ys,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`m5 6 6 6-6 6M13 6l6 6-6 6`})})}function _c(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M20 6 9 17l-5-5`})})}function vc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M3 3v6h6`}),/* @__PURE__ */ U(`path`,{d:`M3.05 13A9 9 0 1 0 6 5.3L3 9`}),/* @__PURE__ */ U(`path`,{d:`M12 7v5l3 2`})]})}function yc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ U(`path`,{d:`M2 12h20`}),/* @__PURE__ */ U(`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`})]})}function bc(){return/* @__PURE__ */ U(`svg`,{...Y,class:Ys,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M19 12H5M12 19l-7-7 7-7`})})}function xc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M12 20h9`}),/* @__PURE__ */ U(`path`,{d:`M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z`})]})}function Sc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`m6 9 6 6 6-6`})})}function Cc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z`}),/* @__PURE__ */ U(`path`,{d:`M14 2v6h6`})]})}function wc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`m12 3-1.5 4.5L6 9l4.5 1.5L12 15l1.5-4.5L18 9l-4.5-1.5Z`}),/* @__PURE__ */ U(`path`,{d:`M19 15v4M17 17h4M5 3v2M4 4h2`})]})}function Tc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2Z`})})}function Ec(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ U(`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`}),/* @__PURE__ */ U(`path`,{d:`M12 17h.01`})]})}function Dc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`m15 4 3 3-9 9-3-3z`}),/* @__PURE__ */ U(`path`,{d:`M18 2v2M20 4h2M3 20l3-3M3 16h2M5 14v2`})]})}function Oc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`rect`,{x:`4`,y:`8`,width:`16`,height:`12`,rx:`2`}),/* @__PURE__ */ U(`path`,{d:`M12 8V4`}),/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`3`,r:`1`}),/* @__PURE__ */ U(`path`,{d:`M2 14h2M20 14h2M9 13h.01M15 13h.01M9.5 17h5`})]})}function kc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M4 14v-2a8 8 0 0 1 16 0v2`}),/* @__PURE__ */ U(`rect`,{x:`2`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),/* @__PURE__ */ U(`rect`,{x:`18`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),/* @__PURE__ */ U(`path`,{d:`M20 20v1a3 3 0 0 1-3 3h-5`})]})}function Ac(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`4`}),/* @__PURE__ */ U(`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`})]})}function jc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`11`,cy:`11`,r:`7`}),/* @__PURE__ */ U(`path`,{d:`m21 21-4.3-4.3`})]})}function Mc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]})}function Nc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M3 9.5 12 3l9 6.5`}),/* @__PURE__ */ U(`path`,{d:`M5 9v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9`})]})}function Pc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`m3 11 15-5v12L3 13z`}),/* @__PURE__ */ U(`path`,{d:`M3 11v2a2 2 0 0 0 2 2h1V9H5a2 2 0 0 0-2 2z`}),/* @__PURE__ */ U(`path`,{d:`M7 15v3a2 2 0 0 0 4 0v-2`}),/* @__PURE__ */ U(`path`,{d:`M21 10a3 3 0 0 1 0 4`})]})}function Fc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`}),/* @__PURE__ */ U(`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`})]})}function Ic(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`4`}),/* @__PURE__ */ U(`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`})]})}function Lc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`})})}function Rc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`M12 3v18`}),/* @__PURE__ */ U(`path`,{d:`M12 3a9 9 0 0 1 0 18z`,fill:`currentColor`,stroke:`none`})]})}function zc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`10.5`,cy:`10.5`,r:`6.5`}),/* @__PURE__ */ U(`path`,{d:`M8 11a2.5 2.5 0 0 0 5 0`}),/* @__PURE__ */ U(`path`,{d:`m20 20-4.4-4.4`})]})}function Bc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`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`}),/* @__PURE__ */ U(`path`,{d:`M18.5 4v3M20 5.5h-3M5.5 16v2.5M6.75 17.25h-2.5`})]})}function Vc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M4 18h16`}),/* @__PURE__ */ U(`path`,{d:`M5 18a7 7 0 0 1 14 0`}),/* @__PURE__ */ U(`path`,{d:`M12 8V6`}),/* @__PURE__ */ U(`path`,{d:`M10 6h4`})]})}function Hc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M7 11V6.5a1.5 1.5 0 0 1 3 0V10`}),/* @__PURE__ */ U(`path`,{d:`M10 10V5.5a1.5 1.5 0 0 1 3 0V10`}),/* @__PURE__ */ U(`path`,{d:`M13 10V6.5a1.5 1.5 0 0 1 3 0V12`}),/* @__PURE__ */ U(`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`})]})}function Uc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`rect`,{x:`9`,y:`9`,width:`11`,height:`11`,rx:`2`}),/* @__PURE__ */ U(`path`,{d:`M5 15a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2`})]})}function Wc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M7 10v11H4a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1z`}),/* @__PURE__ */ U(`path`,{d:`M7 10l4-7a2.5 2.5 0 0 1 2.5 2.5V8h5a2 2 0 0 1 2 2.3l-1.2 8A2 2 0 0 1 17.3 20H7`})]})}function Gc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M17 14V3h3a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1z`}),/* @__PURE__ */ U(`path`,{d:`M17 14l-4 7a2.5 2.5 0 0 1-2.5-2.5V16h-5a2 2 0 0 1-2-2.3l1.2-8A2 2 0 0 1 6.7 4H17`})]})}function Kc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`3.5`}),/* @__PURE__ */ U(`path`,{d:`M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M19.1 4.9l-2.1 2.1M7 17l-2.1 2.1`})]})}function qc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`M12 7v5l3 2`})]})}function Jc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]})}function Yc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`m15 9-6 6M9 9l6 6`})]})}const Xc={chat:Xs,message:Tc,bubbles:Fc,spark:wc,wand:Dc,bot:Oc,help:Ec,lifebuoy:Ac,headset:kc,search:zc,sparkles:Bc,concierge:Vc,wave:Hc},X=P.cssPrefix,Z={launcher:`${X}-launcher`,callout:`${X}-callout`,calloutDismiss:`${X}-callout-dismiss`,panel:`${X}-panel`,panelHeader:`${X}-panel-header`,resizeGrip:`${X}-resize-grip`,scrollToBottom:`${X}-scroll-to-bottom`,loadPreviousMessages:`${X}-load-previous-messages`,actionHistory:`${X}-action-history`,actionClose:`${X}-action-close`,langSegment:`${X}-lang-segment`,composer:`${X}-composer`,composerInput:`${X}-composer-input`,composerSend:`${X}-composer-send`,composerStop:`${X}-composer-stop`,compactionStatus:`${X}-compaction-status`,messageQueue:`${X}-message-queue`,queuedMessage:`${X}-queued-message`,queuedMessageRemove:`${X}-queued-message-remove`,composerAttach:`${X}-composer-attach`,composerFileInput:`${X}-composer-file-input`,composerVoice:`${X}-composer-voice`,attachmentChip:`${X}-attachment-chip`,attachmentRemove:`${X}-attachment-remove`,suggestion:`${X}-suggestion`,messageBubble:`${X}-message`,messageRetry:`${X}-message-retry`,messageFeedback:`${X}-message-feedback`,feedbackUp:`${X}-feedback-up`,feedbackDown:`${X}-feedback-down`,messageCopy:`${X}-message-copy`,historyPane:`${X}-history-pane`,historyBack:`${X}-history-back`,historyItem:`${X}-history-item`,historyLoadMore:`${X}-history-load-more`,sidebar:`${X}-sidebar`,sidebarToggle:`${X}-sidebar-toggle`,sidebarNewConversation:`${X}-sidebar-new-conversation`,sidebarItem:`${X}-sidebar-item`,messengerHome:`${X}-messenger-home`,modulesEmpty:`${X}-modules-empty`,tab:`${X}-tab`,tabBadge:`${X}-tab-badge`,homeView:`${X}-home-view`,homeGreeting:`${X}-home-greeting`,homeBrand:`${X}-home-brand`,backHeader:`${X}-back-header`,contentView:`${X}-content-view`,contentScroll:`${X}-content-scroll`,homeSearch:`${X}-home-search`,helpSearch:`${X}-help-search`,homeRecent:`${X}-home-recent`,homeAsk:`${X}-home-ask`,homeWhatsNew:`${X}-home-whats-new`,homeContentRow:`${X}-home-content-row`,helpArticle:`${X}-help-article`,newsItem:`${X}-news-item`,newsMore:`${X}-news-more`,formGate:`${X}-form-gate`,formDone:`${X}-form-done`,formDoneToggle:`${X}-form-done-toggle`,formAnswers:`${X}-form-answers`,formFill:`${X}-form-fill`,formSubmit:`${X}-form-submit`,formSkip:`${X}-form-skip`,formField:`${X}-form-field`,toolAskQuestions:`${X}-tool-ask-questions`,toolInputSubmit:`${X}-tool-input-submit`,toolInputSkip:`${X}-tool-input-skip`,toolApproval:`${X}-tool-approval`,toolApprove:`${X}-tool-approve`,toolReject:`${X}-tool-reject`,toolEdit:`${X}-tool-edit`,toolDecision:`${X}-tool-decision`,typingDots:`${X}-typing-dots`,reasoning:`${X}-reasoning`,toolAskSummary:`${X}-ask-questions-summary`,toolAskOptions:`${X}-ask-questions-options-toggle`,toolCall:`${X}-tool-call`,source:`${X}-source`,operatorRequest:`${X}-operator-request`,operatorBanner:`${X}-operator-banner`,cancelOperatorRequest:`${X}-cancel-operator-request`};function Zc(e,t){return`${e}-${t}`}const Qc=P.cssPrefix;function $c({onToggle:e,launcher:t,strings:n,leaving:r,edgeTab:i}){let a=t.variant!==`circle`&&!!t.label;return/* @__PURE__ */ U(`button`,{type:`button`,class:`${Qc}-fab`,part:`launcher`,"data-variant":t.variant,"data-size":t.size,"data-edge-tab":i?`true`:void 0,"data-leaving":r?`true`:void 0,"data-testid":Z.launcher,onClick:e,"aria-label":n.launcherOpen,children:[el(t.icon),a?/* @__PURE__ */ U(`span`,{class:`${Qc}-fab-label`,children:ke(n,t.label??``)}):null]})}function el(e){let t=Xc[e];return t?/* @__PURE__ */ U(t,{}):/* @__PURE__ */ U(tl,{source:e})}function tl({source:e}){return/* @__PURE__ */ U(`span`,{ref:t=>{t&&nl(t,e)},"aria-hidden":`true`})}function nl(e,t){if(e.dataset.svgMounted!==t)try{let n=new DOMParser().parseFromString(t,`image/svg+xml`).documentElement;n.tagName.toLowerCase()===`svg`&&(e.replaceChildren(document.importNode(n,!0)),e.dataset.svgMounted=t)}catch{}}function rl({callout:e,launcherPosition:t,strings:n,closeLabel:r,onDismiss:i}){let[a,o]=L(!1);return R(()=>{let t=setTimeout(()=>o(!0),e.delayMs);return()=>clearTimeout(t)},[e.delayMs]),R(()=>{if(!a||e.autoDismissMs<=0)return;let t=setTimeout(i,e.autoDismissMs);return()=>clearTimeout(t)},[a,e.autoDismissMs,i]),a?/* @__PURE__ */ U(`div`,{class:`${Qc}-callout`,role:`status`,"data-shape":e.shape,"data-position":il(e.position,t),"data-animated":e.animated?`true`:void 0,"data-testid":Z.callout,children:[/* @__PURE__ */ U(`span`,{children:ke(n,e.text)}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Qc}-callout-close`,onClick:i,"aria-label":r,title:r,"data-testid":Z.calloutDismiss,children:/* @__PURE__ */ U(Zs,{})})]}):null}function il(e,t){let n=t.endsWith(`-right`),r=t.startsWith(`bottom-`);return e===`vertical`?r?`top`:`bottom`:n?`left`:`right`}function al(e){function t(t){if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(`a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),[tabindex]:not([tabindex="-1"])`)].filter(e=>e.offsetParent!==null||e===document.activeElement);if(n.length===0){t.preventDefault();return}let r=n[0],i=n[n.length-1];if(!r||!i)return;let a=e.getRootNode().activeElement;t.shiftKey&&a===r?(t.preventDefault(),i.focus()):!t.shiftKey&&a===i&&(t.preventDefault(),r.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)}const ol=P.cssPrefix;function sl({title:e,actions:t}){return/* @__PURE__ */ U(`header`,{class:`${ol}-back-header`,part:`header`,"data-variant":`title`,children:[/* @__PURE__ */ U(`span`,{class:`${ol}-back-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ U(`h1`,{class:`${ol}-back-title`,children:e}),t??/* @__PURE__ */ U(`span`,{class:`${ol}-back-spacer`,"aria-hidden":`true`})]})}function cl({title:e,backLabel:t,onBack:n,actions:r,testid:i}){return/* @__PURE__ */ U(`header`,{class:`${ol}-back-header`,part:`header`,"data-testid":i,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${ol}-icon-btn`,onClick:n,"aria-label":t,title:t,children:/* @__PURE__ */ U(bc,{})}),/* @__PURE__ */ U(`h1`,{class:`${ol}-back-title`,children:e}),r??/* @__PURE__ */ U(`span`,{class:`${ol}-back-spacer`,"aria-hidden":`true`})]})}function ll({textSig:e,doneSig:t,generativeUi:n=!1,strings:r=Ce}){let i=z(null);return Ln(()=>{let a=i.current;if(!a)return;a.classList.add(`${P.cssPrefix}-md`),a.replaceChildren();let o=n?ro(a,{cssPrefix:P.cssPrefix,strings:r}):void 0,s=oi(o??yi(a)),c=0,l=gr(()=>{let i=e.value,l=t.value;i.length<c&&(o?.dispose(),a.replaceChildren(),o=n?ro(a,{cssPrefix:P.cssPrefix,strings:r}):void 0,s=oi(o??yi(a)),c=0);let u=i.slice(c);u&&vi(s,u),c=i.length,l&&(si(s),o?.finish())}),u=new MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes){if(!(e instanceof HTMLElement))continue;let t=e.matches?.(`a`)?[e]:[...e.querySelectorAll?.(`a`)??[]];for(let e of t)dl(e)}});u.observe(a,{childList:!0,subtree:!0});for(let e of a.querySelectorAll(`a`))dl(e);function d(e){let t=e.target?.closest?.(`a`);if(!t||!(t instanceof HTMLAnchorElement))return;let n=t.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`))}return a.addEventListener(`click`,d),()=>{l(),o?.dispose(),u.disconnect(),a.removeEventListener(`click`,d)}},[e,t,n,r]),/* @__PURE__ */ U(`div`,{ref:i})}function ul({text:e}){return/* @__PURE__ */ U(ll,{textSig:B(()=>H(e),[e]),doneSig:B(()=>H(!0),[])})}function dl(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(` `)}const fl=/* @__PURE__ */ new Set([11,12,13,14,15,16,17,18,19,31]);function pl(e){let t=``,n=[],r=oi({data:void 0,add_token:(e,r)=>{n.push(r),fl.has(r)||(t+=` `)},end_token:()=>{let e=n.pop();e!==void 0&&!fl.has(e)&&(t+=` `)},add_text:(e,n)=>void(t+=n),set_attr:()=>void 0});return vi(r,e),si(r),t.replace(/\s+/g,` `).trim()}const ml=P.cssPrefix;function hl({tone:e=`info`,message:t,onRetry:n,strings:r}){return/* @__PURE__ */ U(`div`,{class:`${ml}-module-empty`,role:e===`error`?`alert`:`status`,"aria-live":`polite`,children:[/* @__PURE__ */ U(`span`,{children:t}),n?/* @__PURE__ */ U(`button`,{type:`button`,class:`${ml}-module-retry`,onClick:n,children:r.errorRetry}):null]})}const gl=P.cssPrefix,_l=I.scope(`content`);function vl({id:e,title:t,transport:n,strings:r,bus:i,onBack:a,actions:o}){let[s,c]=L(null),[l,u]=L(!1),[d,f]=L(!1),[p,m]=L(0),[h,g]=L(null),_=V(()=>{f(!1),c(null),m(e=>e+1)},[]);R(()=>{let t=!1,r=n.listContentCollections([]).catch(()=>void 0);return Promise.all([n.listContent({ids:[e],limit:1}),r]).then(([n,r])=>{if(t)return;let a=n.items[0];a?(c(a),u(r?.items.find(e=>e.id===a.contentCollectionId)?.settings?.voteAccess===`portal`),i.emit(`contentOpen`,{contentId:e,contentCollectionId:a.contentCollectionId})):f(!0)}).catch(e=>{t||(_l.warn(`listContent (reader) failed`,{err:e}),f(!0))}),()=>{t=!0}},[n,e,p,i]),R(()=>{if(!s)return;let t=setTimeout(()=>i.emit(`contentRead`,{contentId:e}),5e3);return()=>clearTimeout(t)},[s,e,i]);let v=V(t=>{let n=(t.target?.closest?.(`a`))?.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&i.emit(`contentLinkClick`,{contentId:e})},[i,e]);function y(t){g(e),n.setContentVote({contentId:e,value:t})}function b(){return d?/* @__PURE__ */ U(hl,{tone:`error`,message:r.errorGeneric,onRetry:_,strings:r}):s===null?/* @__PURE__ */ U(hl,{message:r.contentLoading,strings:r}):/* @__PURE__ */ U(`article`,{class:`${gl}-content`,"data-testid":Z.contentView,onClick:v,children:[s.image?/* @__PURE__ */ U(`img`,{class:`${gl}-content-hero`,src:s.image,alt:``,loading:`lazy`}):null,s.description?/* @__PURE__ */ U(`p`,{class:`${gl}-content-subtitle`,children:s.description}):null,/* @__PURE__ */ U(ul,{text:s.content??``}),l?/* @__PURE__ */ U(`div`,{class:`${gl}-content-vote`,"aria-live":`polite`,children:h===e?r.feedbackThanks:/* @__PURE__ */ U(O,{children:[/* @__PURE__ */ U(`span`,{children:r.contentHelpful}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${gl}-module-retry`,onClick:()=>y(1),children:r.confirmYes}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${gl}-module-retry`,onClick:()=>y(0),children:r.confirmNo})]})}):null]})}return/* @__PURE__ */ U(`div`,{class:`${gl}-module`,children:[/* @__PURE__ */ U(cl,{title:s?.title||t||r.moduleBack,backLabel:r.moduleBack,onBack:a,actions:o,testid:Z.backHeader}),/* @__PURE__ */ U(`div`,{class:`${gl}-module-scroll`,"data-testid":Z.contentScroll,children:b()})]})}function yl({itemCount:e,initialFocusIndex:t}){let[n,r]=L(!1),i=z(null),a=z(null),[o,s]=L(-1),c=V(()=>{r(!1),s(-1),i.current?.focus()},[]),l=V(()=>r(e=>!e),[]);return R(()=>{if(!n)return;function e(e){let t=a.current,n=i.current;if(!t||!n)return;let o=e.composedPath();o.includes(t)||o.includes(n)||(r(!1),s(-1))}return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)},[n]),R(()=>{if(!n||e===0)return;let r=t?.()??0;s(r<0||r>=e?0:r)},[n,e,t]),R(()=>{!n||o<0||(a.current?.querySelectorAll(`[role='menuitem']`))?.[o]?.focus()},[n,o]),{open:n,focusIndex:o,triggerRef:i,menuRef:a,toggle:l,close:c,onTriggerKey:V(e=>{(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(!0))},[]),onMenuKey:V(t=>{if(e!==0)switch(t.key){case`Escape`:t.preventDefault(),c();return;case`ArrowDown`:t.preventDefault(),s(t=>(t+1)%e);return;case`ArrowUp`:t.preventDefault(),s(t=>(t-1+e)%e);return;case`Home`:t.preventDefault(),s(0);return;case`End`:t.preventDefault(),s(e-1)}},[e,c])}}function bl({items:e,triggerLabel:t}){let n=P.cssPrefix,r=yl({itemCount:e.length});function i(e){e.disabled||(e.onSelect?.(),e.keepOpen||r.close())}function a(e,t){return e.onSelectValue?.(t)}function o(e,t){let n=t.segments;if(!n?.length)return;let r=Math.max(0,n.findIndex(e=>e.value===t.value)),i=-1;if(e.key===`ArrowRight`||e.key===`Enter`||e.key===` `)i=(r+1)%n.length;else if(e.key===`ArrowLeft`)i=(r-1+n.length)%n.length;else return;e.preventDefault(),e.stopPropagation(),a(t,n[i].value)}return/* @__PURE__ */ U(`div`,{class:`${n}-menu-wrap`,children:[/* @__PURE__ */ U(`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:/* @__PURE__ */ U(fc,{})}),r.open?/* @__PURE__ */ U(`div`,{ref:r.menuRef,class:`${n}-menu`,role:`menu`,"aria-label":t,onKeyDown:r.onMenuKey,tabIndex:-1,children:e.map(e=>e.segments?/* @__PURE__ */ U(`div`,{role:`menuitem`,class:`${n}-menu-item ${n}-menu-item-segmented`,"aria-label":e.label,tabIndex:-1,onKeyDown:t=>o(t,e),children:[e.icon?/* @__PURE__ */ U(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,/* @__PURE__ */ U(`span`,{class:`${n}-menu-label`,children:e.label}),/* @__PURE__ */ U(`span`,{class:`${n}-segmented`,role:`group`,"aria-label":e.label,children:e.segments.map(t=>{let r=t.value===e.value;return/* @__PURE__ */ U(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,class:`${n}-segment`,"data-on":r?`true`:void 0,lang:t.lang,title:t.value,tabIndex:-1,"data-testid":`${Z.langSegment}-${t.value}`,onClick:()=>a(e,t.value),children:t.label},t.value)})})]},e.id):/* @__PURE__ */ U(`button`,{type:`button`,role:`menuitem`,class:`${n}-menu-item`,"aria-pressed":e.type===`switch`?e.on:void 0,disabled:e.disabled,onClick:()=>i(e),children:[e.icon?/* @__PURE__ */ U(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,/* @__PURE__ */ U(`span`,{class:`${n}-menu-label`,children:e.label}),e.type===`switch`&&e.on?/* @__PURE__ */ U(`span`,{class:`${n}-menu-check`,"aria-hidden":`true`,children:/* @__PURE__ */ U(_c,{})}):null]},e.id))}):null]})}const xl=P.cssPrefix;function Sl(e){let t=typeof matchMedia!=`function`||matchMedia(`(prefers-color-scheme: dark)`).matches;return e===`host`?an()===`dark`?`light`:`dark`:e===`auto`?t?`light`:`dark`:t?e===`light`?`dark`:`auto`:e===`dark`?`light`:`auto`}const Cl={normal:`large`,large:`small`,small:`normal`};function wl(e){return U(e===`light`?Ic:e===`dark`?Lc:Rc,{})}function Tl(e){return(e.split(`-`)[0]??e).toUpperCase()}function El(e,t){let n;try{n=new URL(e,window.location.href)}catch{return}if(n.protocol===`http:`||n.protocol===`https:`)return t.conversationId&&n.searchParams.set(`chat`,t.conversationId),n.searchParams.set(`widgetId`,t.widgetId),t.publicKey&&n.searchParams.set(`public_key`,t.publicKey),n.searchParams.set(`ai_agent_deployment_id`,t.aiAgentDeploymentId),n.href}function Dl({panelProps:e,variant:t}){let{options:n,panelSize:r,feedback:i,onClose:a,onClear:o,onExpand:s,onFullscreen:c,onSoundToggle:l}=e,{onToggleHistory:u,onLocaleChange:d,onThemeChange:f,onTextSizeChange:p}=e,m=n.strings,h=n.mode,g=t===`chat`,_=Dr(()=>i.mutedSig.value).value,v=new Set(n.actions);function y(e){return v.has(e)}let b=typeof matchMedia==`function`&&matchMedia(`(max-width: 640px)`).matches;function x(e){return!b&&js(e,h,r)}let S=n.themeMode,ee={auto:m.themeAuto,light:m.themeLight,dark:m.themeDark,host:m.themeAuto},C=n.textSize,te={small:m.textSizeSmall,normal:m.textSizeNormal,large:m.textSizeLarge},w=[];if(g&&y(`clear`)&&w.push({id:`clear`,icon:/* @__PURE__ */ U(xc,{}),label:m.newConversation,onSelect:o}),y(`expand`)&&x(`expand`)){let e=r===`expanded`;w.push({id:`expand`,icon:U(e?sc:oc,{}),label:e?m.collapse:m.expand,type:`switch`,on:e,onSelect:s})}if(y(`fullscreen`)&&x(`fullscreen`)){let e=r===`fullscreen`;w.push({id:`fullscreen`,icon:U(e?lc:cc,{}),label:e?m.exitFullscreen:m.fullscreen,type:`switch`,on:e,onSelect:c})}let T=n.popOutUrl,E=n.aiAgentDeploymentId;y(`popOut`)&&T&&E&&js(`popOut`,h,r)&&w.push({id:`popOut`,icon:/* @__PURE__ */ U(uc,{}),label:m.popOut,onSelect:()=>{let t=El(T,{conversationId:e.conversationId,widgetId:n.widgetId,publicKey:n.publicKey,aiAgentDeploymentId:E});t&&window.open(t,`_blank`,`noopener,noreferrer`)}}),g&&y(`sound`)&&w.push({id:`sound`,icon:U(_?mc:pc,{}),label:_?m.soundOff:m.soundOn,type:`switch`,on:!_,onSelect:l}),y(`theme`)&&w.push({id:`theme`,icon:wl(S),label:`${m.theme}: ${ee[S]}`,onSelect:()=>f(Sl(S)),keepOpen:!0}),y(`textSize`)&&w.push({id:`textSize`,icon:/* @__PURE__ */ U(hc,{}),label:`${m.textSize}: ${te[C]}`,onSelect:()=>p(Cl[C]),keepOpen:!0}),y(`language`)&&n.availableLocales.length>1&&w.push({id:`language`,icon:/* @__PURE__ */ U(yc,{}),label:m.language,segments:n.availableLocales.map(e=>({value:e,label:Tl(e),lang:e})),value:n.locale,onSelectValue:d});let D=!!a&&Ms(h,r,n.actions),O=g&&y(`history`);return/* @__PURE__ */ U(`div`,{class:`${xl}-header-actions`,children:[O?/* @__PURE__ */ U(`button`,{type:`button`,class:`${xl}-icon-btn`,onClick:u,"aria-label":m.history,title:m.history,"data-testid":Z.actionHistory,children:/* @__PURE__ */ U(vc,{})}):null,w.length>0?/* @__PURE__ */ U(bl,{items:w,triggerLabel:m.moreActions}):null,D?/* @__PURE__ */ U(`button`,{type:`button`,class:`${xl}-icon-btn`,onClick:a,"aria-label":m.close,title:m.close,"data-testid":Z.actionClose,children:/* @__PURE__ */ U(Zs,{})}):null]})}const Ol={Icon:Fc};function kl(e,t){return e instanceof ds&&e.status===429?t.errorRateLimited:t.errorGeneric}const Al=P.cssPrefix;function jl({placeholder:e,onActivate:t}){return/* @__PURE__ */ U(`button`,{type:`button`,class:`${Al}-home-search`,onClick:t,"data-testid":Z.homeSearch,children:[/* @__PURE__ */ U(`span`,{class:`${Al}-home-search-text`,children:e}),/* @__PURE__ */ U(`span`,{class:`${Al}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(jc,{})})]})}function Ml({placeholder:e,value:t,onInput:n}){return/* @__PURE__ */ U(`div`,{class:`${Al}-home-search`,"data-input":`true`,children:[/* @__PURE__ */ U(`input`,{type:`search`,class:`${Al}-home-search-input`,placeholder:e,value:t,maxLength:200,onInput:e=>n(e.currentTarget.value),"data-testid":Z.helpSearch}),/* @__PURE__ */ U(`span`,{class:`${Al}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(jc,{})})]})}const Nl=P.cssPrefix;function Pl({title:e,subtitle:t,onClick:n,testid:r}){return/* @__PURE__ */ U(`button`,{type:`button`,class:`${Nl}-list-row`,onClick:n,"data-testid":r,children:[/* @__PURE__ */ U(`span`,{class:`${Nl}-list-row-body`,children:[/* @__PURE__ */ U(`span`,{class:`${Nl}-list-row-title`,children:e}),t?/* @__PURE__ */ U(`span`,{class:`${Nl}-list-row-sub`,children:t}):null]}),/* @__PURE__ */ U(`span`,{class:`${Nl}-list-row-chevron`,"aria-hidden":`true`,children:/* @__PURE__ */ U(nc,{})})]})}const Fl=P.cssPrefix,Il=I.scope(`help`);function Ll(e,t,n){let r=new Map(n.map(e=>[e.id,e.title]));return t.map(t=>({id:t,title:r.get(t),rows:e.filter(e=>e.contentCollectionId===t)})).filter(e=>e.rows.length>0)}function Rl({transport:e,strings:t,bus:n},r,i){let[a,o]=L(),s=z(void 0);function c(a){if(!r?.length)return;let c={};s.current=c,o(e=>({search:i,items:[],collections:[],...e,pagination:a>1?e?.pagination:void 0,loading:!0,error:void 0})),Promise.all([e.listContent({contentCollectionIds:r,sortBy:`order`,page:a,limit:20,search:i}),a>1?void 0:e.listContentCollections(r)]).then(([e,t])=>{s.current===c&&(o(n=>({search:i,items:[...a>1?n?.items??[]:[],...e.items],collections:t?.items??n?.collections??[],pagination:e.pagination,loading:!1})),!(a>1)&&(i?n.emit(`contentSearch`,{queryLength:i.length,hitCount:e.pagination.total}):n.emit(`contentView`,{section:`help`,count:e.items.length})))}).catch(e=>{s.current===c&&(Il.warn(`listContent (help) failed`,{err:e,page:a}),o(n=>n&&{...n,loading:!1,error:kl(e,t)}))})}return R(()=>{if(!r?.length)o(void 0);else return c(1),()=>{s.current=void 0}},[e,r,i]),[a,()=>!a?.loading&&c((a?.pagination?.page??0)+1)]}function zl(e){let{strings:t,config:n,nav:r,panelProps:i}=e,a=n.contentCollectionIds,[o,s]=L(``),[c,l]=L(``),u=Rl(e,a),d=Rl(e,c?a:void 0,c),[f,p]=o.trim()?d:u;R(()=>{let e=setTimeout(()=>l(o.trim()),300);return()=>clearTimeout(e)},[o]);function m(){if(!a?.length)return/* @__PURE__ */ U(hl,{message:t.helpEmpty,strings:t});let e=f?.error?/* @__PURE__ */ U(hl,{tone:`error`,message:f.error,onRetry:p,strings:t}):null;return e&&!f?.pagination?e:!f||!f.pagination&&!f.items.length?/* @__PURE__ */ U(hl,{message:t.helpLoading,strings:t}):f.items.length?/* @__PURE__ */ U(O,{children:[Ll(f.items,a,f.collections).map(e=>/* @__PURE__ */ U(`section`,{class:`${Fl}-help-group`,children:[e.title?/* @__PURE__ */ U(`h2`,{class:`${Fl}-help-section-title`,children:e.title}):null,/* @__PURE__ */ U(`div`,{class:`${Fl}-help-card`,children:e.rows.map(e=>/* @__PURE__ */ U(Pl,{title:e.title,subtitle:e.description,onClick:()=>r.push(e.url?{kind:`iframe`,url:e.url,title:e.title}:{kind:`content`,id:e.id,title:e.title}),testid:Zc(Z.helpArticle,e.id)},e.id))})]},e.id)),e,f.pagination?.hasNext&&!e?/* @__PURE__ */ U(`div`,{children:/* @__PURE__ */ U(`div`,{class:`${Fl}-help-card`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${Fl}-list-row ${Fl}-help-more`,onClick:p,"aria-busy":f.loading,children:[f.loading?/* @__PURE__ */ U(`span`,{class:`${Fl}-loading-spinner`,"aria-hidden":`true`}):null,t.helpShowMore]})})}):null]}):/* @__PURE__ */ U(hl,{message:f.search?t.helpSearchEmpty.replace(`{query}`,f.search):t.helpEmpty,strings:t})}return/* @__PURE__ */ U(`div`,{class:`${Fl}-module`,children:[/* @__PURE__ */ U(sl,{title:t.helpTitle,actions:/* @__PURE__ */ U(Dl,{panelProps:i,variant:`plain`})}),/* @__PURE__ */ U(`div`,{class:`${Fl}-module-pad`,children:/* @__PURE__ */ U(Ml,{placeholder:t.helpSearchPlaceholder,value:o,onInput:s})}),/* @__PURE__ */ U(`div`,{class:`${Fl}-help-list`,children:m()})]})}const Bl={Icon:Ec,Root:e=>/* @__PURE__ */ U(zl,{...e})},Vl=I.scope(`attachments`);function Hl(e,t,n){let r=Gl(e),i=[],a=[],o=Jl(n.accept),s=t.reduce((e,t)=>e+t.size,0),c=t.length;for(let e of r){let t=Wl(e,c,s,n,o);t?a.push({file:e,reason:t}):(i.push(ql(e)),s+=e.size,c+=1)}return(i.length||a.length)&&Vl.debug(`ingest`,{accepted:i.length,rejected:a.map(e=>({name:e.file.name,reason:e.reason}))}),{accepted:i,rejected:a}}function Ul(e){try{URL.revokeObjectURL(e.previewUrl)}catch(e){Vl.debug(`revokeObjectURL failed`,{error:e})}}function Wl(e,t,n,r,i){return t>=r.maxCount?`count`:n+e.size>r.maxBytes?`bytes`:Yl(e,i)?null:`mime`}function Gl(e){return e?Array.isArray(e)?e.filter(e=>e instanceof File):[...e].map(e=>e instanceof File?e:Kl(e)).filter(e=>e!==null):[]}function Kl(e){let t=e;return!t?.getAsFile||t.kind!==`file`?null:t.getAsFile()}function ql(e){return{file:e,id:Ht(),mediaType:e.type||`application/octet-stream`,name:e.name||`pasted-file`,previewUrl:URL.createObjectURL(e),size:e.size}}function Jl(e){return e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean).map(e=>{if(e.startsWith(`.`))return{kind:`ext`,ext:e};let[t=`*`,n=`*`]=e.split(`/`);return{kind:`mime`,type:t,subtype:n}})}function Yl(e,t){if(t.length===0)return!0;let[n=`*`,r=`*`]=(e.type||``).toLowerCase().split(`/`),i=(e.name||``).toLowerCase();return t.some(e=>e.kind===`ext`?i.endsWith(e.ext):e.type===`image`&&e.subtype===`*`&&/\.(heic|heif|avif|bmp|tif|tiff)$/.test(i)?!0:(e.type===`*`||e.type===n)&&(e.subtype===`*`||e.subtype===r))}const Xl=P.cssPrefix;function Zl({attachment:e,onRemove:t,disabled:n=!1}){let r=/^image\/(jpeg|png|gif|webp|avif|bmp|x-ms-bmp|svg\+xml)$/i.test(e.mediaType);return/* @__PURE__ */ U(`span`,{class:`${Xl}-attachment-chip`,title:e.name,"data-testid":Zc(Z.attachmentChip,e.id),children:[r?/* @__PURE__ */ U(`img`,{class:`${Xl}-attachment-thumb`,src:e.previewUrl,alt:``}):/* @__PURE__ */ U(`span`,{class:`${Xl}-attachment-thumb`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Cc,{})}),/* @__PURE__ */ U(`span`,{class:`${Xl}-attachment-name`,children:e.name}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Xl}-attachment-remove`,onClick:t,disabled:n,"aria-label":`Remove ${e.name}`,"data-testid":Zc(Z.attachmentRemove,e.id),children:/* @__PURE__ */ U(Zs,{})})]})}const Ql={isSupported:!1,start:()=>void 0,stop:()=>void 0,cancel:()=>void 0};function $l(e,t,n){return e===`disabled`?Ql:e===`server`?ru(n):eu(t)}function eu(e){let t=tu();if(!t)return Ql;let n=null,r=0;return{isSupported:!0,start(i,a){let o=n,s=++r;n=null,o?.abort();let c=new t;n=c,c.continuous=!0,c.interimResults=!0,c.lang=e;let l=!1;c.addEventListener(`result`,e=>{if(r!==s||n!==c)return;let t=e,a=``,o=!1;for(let e=t.resultIndex;e<t.results.length;e++){let n=t.results[e];n&&(a+=n[0].transcript,n.isFinal&&(o=!0))}i(a,o)});function u(){l||r!==s||n!==c||(l=!0,n=null,a())}c.addEventListener(`end`,u),c.addEventListener(`error`,u);try{c.start()}catch{u()}},stop(){n?.stop()},cancel(){r++;let e=n;n=null,e?.abort()}}}function tu(){return window.SpeechRecognition??window.webkitSpeechRecognition}const nu=[`audio/webm;codecs=opus`,`audio/webm`,`audio/ogg;codecs=opus`,`audio/mp4`];function ru(e){if(typeof MediaRecorder>`u`||!navigator?.mediaDevices?.getUserMedia)return Ql;let t=0,n=null;function r(e){for(let t of e.stream?.getTracks()??[])t.stop();e.stream=null}function i(){t++;let e=n;n=null,e&&(r(e),e.recorder?.state!==`inactive`&&e.recorder?.stop())}async function a(i){if(i.finishing)return;i.finishing=!0;let a=i.recorder?.mimeType??`audio/webm`;r(i);let o=new Blob(i.chunks,{type:a});i.chunks=[];try{let{text:r}=await e(o,a);n===i&&t===i.generation&&r&&i.onText(r,!0)}catch{}finally{n===i&&t===i.generation&&(n=null,i.onEnd())}}return{isSupported:!0,async start(e,o){i();let s={generation:t,recorder:null,stream:null,chunks:[],onText:e,onEnd:o,finishing:!1};n=s;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});if(n!==s||t!==s.generation){for(let t of e.getTracks())t.stop();return}s.stream=e;let r=iu(),i=new MediaRecorder(e,r?{mimeType:r}:void 0);s.recorder=i,i.addEventListener(`dataavailable`,e=>{n===s&&t===s.generation&&e.data.size>0&&s.chunks.push(e.data)}),i.addEventListener(`stop`,()=>{n===s&&t===s.generation&&a(s)}),i.start()}catch{r(s),n===s&&t===s.generation&&(n=null,o())}},stop(){let e=n;e&&(e.recorder?e.recorder.state!==`inactive`&&e.recorder.stop():i())},cancel(){i()}}}function iu(){for(let e of nu)if(MediaRecorder.isTypeSupported(e))return e}const au=P.cssPrefix,ou=I.scope(`composer`);function su(e){return e.reduce((e,t)=>e+t.size,0)}const cu={arrowUp:ec,paperPlane:$s,send:tc,chevron:nc};function lu(e){return`activeElement`in e}function uu(e){return`host`in e&&`activeElement`in e}function du({options:e,transport:t,feedback:n,bus:r,persistence:i,conversationId:a,isStreaming:o,isMemoryCompacting:s=!1,canReleaseQueuedMessages:c=!0,queueManualMessages:l=!1,active:u=!0,isPreparing:d=!1,operatorRequestEnabled:f,canRequestOperator:p=!1,controlMode:m=`ai-agent`,onRequestOperator:h,onSend:g,onStop:_,apiRef:v}){let y=e.strings,[b,x]=L(()=>i.loadDraft(a)),[S,ee]=L([]),[C,te]=L(()=>i.loadMessageQueue(a).map(e=>({id:e.id,text:e.text,attachments:[]}))),w=z(C),T=z(!1),[E,D]=L(!1),[O,ne]=L(!1),k=z(!1),A=z(null),re=z(null),j=z(null),ie=z(0),M=z(a);M.current=a;let ae=z(u);ae.current=u;let oe=z(d);oe.current=d;let se=O||d||!u,ce=o&&m===`ai-agent`,le=ce||s&&m===`ai-agent`,ue=m===`ai-agent`&&(le||l||C.length>0),de=V(e=>{te(t=>{let n=e(t);return i.saveMessageQueue(M.current,n.filter(e=>e.attachments.length===0).map(({id:e,text:t})=>({id:e,text:t}))),w.current=n,n})},[i]),fe=V(e=>{de(t=>(t.find(t=>t.id===e)?.attachments.forEach(Ul),t.filter(t=>t.id!==e)))},[de]),pe=V(e=>{x(t=>{let n=typeof e==`function`?e(t):e;return n===t?t:(i.saveDraft(M.current,n),n)})},[i]),me=e.features.fileUpload,he=e.features.voice,[ge,N]=L(()=>$l(he,e.locale,(e,n)=>t.transcribe(e,n))),_e=z(ge);_e.current=ge;let ve=z({mode:he,locale:e.locale,transport:t});R(()=>{let n=ve.current;(n.mode!==he||n.locale!==e.locale||n.transport!==t)&&(ve.current={mode:he,locale:e.locale,transport:t},ie.current++,_e.current.cancel(),j.current=null,D(!1),N($l(he,e.locale,(e,n)=>t.transcribe(e,n))))},[e.locale,he,t]),Ln(()=>()=>{ie.current++,ge.cancel()},[ge]);let ye=V(e=>{let t=j.current;if(t===null)return!1;let n=Math.round(performance.now()-t);return ou[e](`voiceStop`,{durationMs:n}),r.emit(`voiceStop`,{durationMs:n}),j.current=null,!0},[r]),be=V(()=>{j.current!==null&&(ge.stop(),D(!1),ye(`info`)&&n.play(`voiceStop`))},[ye,n,ge]),xe=V(()=>{ie.current++,ge.cancel(),D(!1),ye(`info`)&&n.play(`voiceStop`)},[ye,n,ge]);R(()=>{(d||!u)&&xe()},[u,xe,d]),R(()=>{let e=A.current;if(!e)return;let t=e.getRootNode(),n=lu(t)?t.activeElement:null;n&&e.closest(`.${au}-panel`)?.contains(n)||e.focus({preventScroll:!0})},[]),R(()=>{let e=A.current;if(!e)return;if(b.length===0){e.style.height=``;return}e.style.height=`auto`;let t=getComputedStyle(e),n=Number.parseFloat(t.getPropertyValue(`--${au}-textarea-base-height`)),r=Number.parseFloat(t.borderTopWidth)+Number.parseFloat(t.borderBottomWidth),i=Math.min(e.scrollHeight+r,Number.parseFloat(t.maxHeight)),a=Number.parseFloat(t.fontSize)*.7;e.style.height=`${i<n+a?n:i}px`},[b]);let Se=z(S);Se.current=S,R(()=>()=>{Se.current.forEach(Ul);for(let e of w.current)e.attachments.forEach(Ul)},[]),Ln(()=>{if(v)return v.current={attachFromDrop:t=>{if(!me||!ae.current||k.current||oe.current)return;let n=Hl(t,Se.current,e.attachments);n.accepted.length!==0&&(ou.info(`attach (drop)`,{count:n.accepted.length,totalBytes:su(n.accepted)}),r.emit(`attach`,{count:n.accepted.length,totalBytes:su(n.accepted)}),ee(e=>[...e,...n.accepted]))},fill:e=>{if(!ae.current||k.current||oe.current)return;pe(e);let t=A.current;t&&(t.focus({preventScroll:!0}),requestAnimationFrame(()=>t.setSelectionRange(t.value.length,t.value.length)))},acceptQueuedMessage:fe},()=>{v.current&&(v.current=null)}},[v,me,d,e.attachments,fe,pe]),R(()=>{let t=A.current;if(!t)return;let n=t.closest(`.${au}-panel`);if(!n)return;let i=n=>{if(!ae.current||k.current||oe.current)return;let i=n.clipboardData;if(!i)return;let a=n.target?.closest?.(`input, textarea, [contenteditable]:not([contenteditable='false'])`);if(a&&a!==t)return;if(me){let t=Hl(i.items,Se.current,e.attachments);if(t.accepted.length>0){n.preventDefault(),ou.info(`attach (paste)`,{count:t.accepted.length,totalBytes:su(t.accepted)}),r.emit(`attach`,{count:t.accepted.length,totalBytes:su(t.accepted)}),ee(e=>[...e,...t.accepted]);return}}if(a===t)return;let o=i.getData(`text/plain`);o&&(n.preventDefault(),pe(e=>e+o),t.focus())};return n.addEventListener(`paste`,i),()=>n.removeEventListener(`paste`,i)},[me,e.attachments,pe]);async function Ce(){let e=b.trim();if(!e&&S.length===0||!u||ce||k.current||d)return;xe(),k.current=!0,ne(!0);let t=b,n=S;try{await g(e,n)&&(pe(e=>e===t?``:e),ee(e=>e===n?(n.forEach(Ul),Se.current=[],[]):e))}finally{k.current=!1,ne(!1),requestAnimationFrame(()=>{let e=A.current;if(!e||e.disabled||!ae.current)return;let t=e.getRootNode(),n=lu(t)?t.activeElement:null,r=n?.getAttribute(`data-testid`);if(!(n&&n!==e&&r!==Z.composerSend&&r!==Z.composerStop)){if(uu(t)){let e=t.host.ownerDocument;if(!e.hasFocus())return;let n=e.activeElement;if(n&&n!==t.host&&n!==e.body)return}e.focus({preventScroll:!0})}})}}function we(){let e=b.trim();if(!e&&S.length===0||!u||!ue||k.current||d)return;xe();let t=S;de(n=>[...n,{id:Ht(),text:e,attachments:t}]),pe(``),ee(e=>e===t?(Se.current=[],[]):e),A.current?.focus({preventScroll:!0})}R(()=>{le&&(T.current=!1)},[le]),R(()=>{let e=C[0];if(!e||!c||le||T.current||O||d||!u)return;let t=setTimeout(()=>{T.current=!0,g(e.text,e.attachments,e.id).then(t=>{t?fe(e.id):T.current=!1})},300);return()=>clearTimeout(t)},[u,c,d,g,le,C,fe,O]);function Te(e){e.key!==`Enter`||e.shiftKey||e.isComposing||(e.preventDefault(),ue&&(b.trim()||S.length>0)?we():ce?_():Ce())}function Ee(t){let n=t.target;if(!u||k.current||d){n.value=``;return}let i=Hl(n.files,S,e.attachments);i.accepted.length>0&&(ou.info(`attach (file picker)`,{count:i.accepted.length,totalBytes:su(i.accepted)}),r.emit(`attach`,{count:i.accepted.length,totalBytes:su(i.accepted)}),ee(e=>[...e,...i.accepted])),n.value=``}function De(e){!u||k.current||d||(ou.info(`removeAttachment`,{id:e}),r.emit(`removeAttachment`,{id:e}),ee(t=>{let n=t.find(t=>t.id===e);return n&&Ul(n),t.filter(t=>t.id!==e)}))}function Oe(){if(E){be();return}if(!u||!ge.isSupported||k.current||d)return;let e=++ie.current;j.current=performance.now(),ou.info(`voiceStart`),r.emit(`voiceStart`,void 0),D(!0),n.play(`voiceStart`),ge.start((t,n)=>{ie.current===e&&ae.current&&!oe.current&&!k.current&&n&&pe(e=>`${e}${t} `)},()=>{ie.current===e&&ae.current&&(D(!1),ye(`debug`))})}let ke=cu[e.composer.sendButton.icon],Ae=!!(b.trim()||S.length>0);return/* @__PURE__ */ U(`div`,{class:`${au}-composer`,part:`composer`,"data-testid":Z.composer,children:[C.length>0?/* @__PURE__ */ U(`div`,{class:`${au}-message-queue`,"aria-label":y.queueMessage,"data-testid":Z.messageQueue,children:C.map(e=>/* @__PURE__ */ U(`div`,{class:`${au}-attachment-chip ${au}-queued-message`,"data-testid":`${Z.queuedMessage}-${e.id}`,children:[/* @__PURE__ */ U(`span`,{class:`${au}-attachment-name ${au}-queued-text`,children:e.text||e.attachments.map(e=>e.name).join(`, `)}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${au}-attachment-remove`,onClick:()=>fe(e.id),"aria-label":y.removeQueuedMessage,title:y.removeQueuedMessage,"data-testid":`${Z.queuedMessageRemove}-${e.id}`,children:/* @__PURE__ */ U(Zs,{})})]},e.id))}):null,S.length>0?/* @__PURE__ */ U(`div`,{class:`${au}-attachments`,children:S.map(e=>/* @__PURE__ */ U(Zl,{attachment:e,onRemove:()=>De(e.id),disabled:se},e.id))}):null,/* @__PURE__ */ U(`div`,{class:`${au}-composer-row`,children:[/* @__PURE__ */ U(`div`,{class:`${au}-composer-actions`,children:[me?/* @__PURE__ */ U(`button`,{type:`button`,class:`${au}-icon-btn`,onClick:()=>re.current?.click(),disabled:se,"aria-label":y.attach,"data-testid":Z.composerAttach,children:/* @__PURE__ */ U(ic,{})}):null,ge.isSupported?/* @__PURE__ */ U(`button`,{type:`button`,class:`${au}-icon-btn`,onClick:Oe,disabled:se,"aria-label":E?y.micStop:y.micStart,"aria-pressed":E,"data-recording":E?`true`:void 0,"data-testid":Z.composerVoice,children:/* @__PURE__ */ U(ac,{})}):null]}),/* @__PURE__ */ U(`textarea`,{ref:A,name:`message`,class:`${au}-textarea`,rows:1,value:b,placeholder:y.composerPlaceholder,onInput:e=>pe(e.currentTarget.value),onKeyDown:Te,disabled:se,"aria-label":y.composerPlaceholder,"data-testid":Z.composerInput}),ue&&Ae?/* @__PURE__ */ U(`button`,{type:`button`,class:`${au}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:we,disabled:se,"aria-label":y.queueMessage,title:y.queueMessage,"data-testid":Z.composerSend,children:/* @__PURE__ */ U(ke,{})}):null,ce?/* @__PURE__ */ U(`button`,{type:`button`,class:`${au}-send`,onClick:_,disabled:se,"aria-label":y.stop,"data-testid":Z.composerStop,children:/* @__PURE__ */ U(rc,{})}):null,!ce&&(!ue||!Ae)?/* @__PURE__ */ U(`button`,{type:`button`,class:`${au}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:()=>void Ce(),disabled:se||!b.trim()&&S.length===0,"aria-label":y.send,"data-testid":Z.composerSend,children:/* @__PURE__ */ U(ke,{})}):null,f&&m===`ai-agent`&&h?/* @__PURE__ */ U(`button`,{type:`button`,class:`${au}-icon-btn`,onClick:h,disabled:se||!p,"aria-label":y.talkToOperator,title:y.talkToOperator,"data-testid":Z.operatorRequest,children:/* @__PURE__ */ U(kc,{})}):null]}),/* @__PURE__ */ U(`input`,{ref:re,name:`attachments`,type:`file`,multiple:!0,accept:e.attachments.accept,onChange:Ee,disabled:se,class:`${au}-sr-only`,"data-testid":Z.composerFileInput})]})}const fu=P.cssPrefix;function pu({onClick:e,children:t,testid:n}){return e?/* @__PURE__ */ U(`button`,{type:`button`,class:`${fu}-home-card`,"data-interactive":`true`,onClick:e,"data-testid":n,children:t}):/* @__PURE__ */ U(`div`,{class:`${fu}-home-card`,"data-testid":n,children:t})}function mu(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}const hu=P.cssPrefix,gu=I.scope(`news`);function _u(e,t){let n=e?new Date(e):void 0;if(n&&!Number.isNaN(n.getTime()))return new Intl.DateTimeFormat(t,{dateStyle:`medium`}).format(n)}function vu({options:e,transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}){let c=r.contentCollectionIds,[l,u]=L({items:[],loading:!0}),d=z(void 0);function f(e){if(!c?.length)return;let r={};d.current=r,u(e=>({...e,loading:!0,error:void 0})),t.listContent({contentCollectionIds:c,sortBy:`publishedAt`,sortOrder:`desc`,page:e,limit:10}).then(t=>{if(d.current!==r||(u(n=>({items:e>1?[...n.items,...t.items]:t.items,pagination:t.pagination,loading:!1})),e>1))return;a.emit(`contentView`,{section:`news`,count:t.items.length});let n=t.items[0];n&&s.markSeen(n.id)}).catch(t=>{d.current===r&&(gu.warn(`listContent (news) failed`,{err:t,page:e}),u(e=>({...e,loading:!1,error:kl(t,n)})))})}function p(){l.loading||f((l.pagination?.page??0)+1)}R(()=>(u({items:[],loading:!0}),f(1),()=>{d.current=void 0}),[t,c]);function m(t){let n=_u(t.publishedAt,e.locale);return/* @__PURE__ */ U(`button`,{type:`button`,class:`${hu}-news-card`,onClick:()=>i.push({kind:`content`,id:t.id,title:t.title}),"data-testid":Zc(Z.newsItem,t.id),children:[t.image?/* @__PURE__ */ U(`img`,{class:`${hu}-news-hero`,src:t.image,alt:``,loading:`lazy`}):null,/* @__PURE__ */ U(`span`,{class:`${hu}-news-body`,children:[/* @__PURE__ */ U(`span`,{class:`${hu}-news-title`,children:t.title}),n||t.tags?.length?/* @__PURE__ */ U(`span`,{class:`${hu}-news-meta`,children:[n?/* @__PURE__ */ U(`time`,{dateTime:t.publishedAt,children:n}):null,t.tags?.map(e=>/* @__PURE__ */ U(`span`,{class:`${hu}-news-tag`,children:e},e))]}):null,t.description?/* @__PURE__ */ U(`span`,{class:`${hu}-news-summary`,children:t.description}):null]})]},t.id)}function h(){if(!c?.length)return/* @__PURE__ */ U(hl,{message:n.newsEmpty,strings:n});let e=l.error?/* @__PURE__ */ U(hl,{tone:`error`,message:l.error,onRetry:p,strings:n}):null;return e&&!l.pagination?e:l.pagination?l.items.length?/* @__PURE__ */ U(`div`,{class:`${hu}-news-list`,children:[l.items.map(m),e,l.pagination.hasNext&&!e?/* @__PURE__ */ U(`button`,{type:`button`,class:`${hu}-news-more`,onClick:p,"aria-busy":l.loading,"data-testid":Z.newsMore,children:[l.loading?/* @__PURE__ */ U(`span`,{class:`${hu}-loading-spinner`,"aria-hidden":`true`}):null,n.newsShowMore]}):null]}):/* @__PURE__ */ U(hl,{message:n.newsEmpty,strings:n}):/* @__PURE__ */ U(hl,{message:n.newsLoading,strings:n})}return/* @__PURE__ */ U(`div`,{class:`${hu}-module`,children:[/* @__PURE__ */ U(sl,{title:n.newsTitle,actions:/* @__PURE__ */ U(Dl,{panelProps:o,variant:`plain`})}),/* @__PURE__ */ U(`div`,{class:`${hu}-module-scroll`,children:h()})]})}const yu={Icon:Pc,Root:e=>/* @__PURE__ */ U(vu,{...e})},Q=P.cssPrefix,bu=I.scope(`home`);function xu(e){let t=e.options.userContext?.name,n=e.config.greetingText?ke(e.strings,e.config.greetingText):void 0;if(n){let r=t?n.replace(`{name}`,t):n.replace(/\s*\{name\}\s*/,` `).trim(),i=e.strings.homeGreetingLead;return{title:r,subtitle:r.toLowerCase()===i.toLowerCase()?void 0:i}}return t?{title:e.strings.homeGreetingNamed.replace(`{name}`,t),subtitle:e.strings.homeGreetingLead}:{title:e.strings.homeGreeting}}function Su(e,t){return t.url?e.push({kind:`iframe`,url:t.url,title:t.title}):e.push({kind:`content`,id:t.id,title:t.title})}function Cu({options:e,onAsk:t}){let[n,r]=L(``),{sendButton:i}=e.composer,a=cu[i.icon];function o(e){e.preventDefault();let i=n.trim();i&&(r(``),t(i))}return/* @__PURE__ */ U(`form`,{class:`${Q}-home-search ${Q}-home-ask`,"data-input":`true`,onSubmit:o,"data-testid":Z.homeAsk,children:[/* @__PURE__ */ U(`input`,{type:`text`,class:`${Q}-home-search-input`,placeholder:e.strings.homeAskPlaceholder,"aria-label":e.strings.homeAskPlaceholder,value:n,enterKeyHint:`send`,onInput:e=>r(e.currentTarget.value)}),/* @__PURE__ */ U(`button`,{type:`submit`,class:`${Q}-send`,"data-shape":i.shape,"data-variant":i.variant,disabled:!n.trim(),"aria-label":e.strings.send,children:/* @__PURE__ */ U(a,{})})]})}function wu(e,t){return Ss(e,t,t.type!==`upsert`||t.activity===!0)}function Tu(e){let{transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}=e,[c,l]=L(null),[u,d]=L([]),f=r.contentCollectionIds?.join(`,`),p=e.options.modules.list.some(e=>e.layout===`chat`);R(()=>{if(r.showRecentConversations===!1)return;let e=!1,n=!0,i=[],a=t.subscribeConversationChanges(e=>{n&&i.push(e),l(t=>wu(t?[t]:[],e)[0]??null)});return t.listConversations({limit:p?50:1}).then(t=>{if(e)return;let r=i.reduce(wu,t.conversations);i=[],n=!1,l(r[0]??null)}).catch(t=>{e||(i=[],n=!1,bu.warn(`listConversations (home) failed`,{err:t}))}),()=>{e=!0,a()}},[t,r.showRecentConversations,p]),R(()=>{if(!r.contentCollectionIds?.length)return;let e=!1;return t.listContent({contentCollectionIds:r.contentCollectionIds,pinned:!0,limit:6}).then(t=>{e||(d(t.items),a.emit(`contentView`,{section:`home`,count:t.items.length}))}).catch(t=>!e&&bu.warn(`listContent (home) failed`,{err:t})),()=>{e=!0}},[t,f,a]);let m=xu(e),h=r.userAvatars??[],g=r.status,_=g?.text?ke(n,g.text):n.homeStatus,v=r.contentBlockTitle?ke(n,r.contentBlockTitle):n.homeContentTitle,y=s.item,b=_u(y?.publishedAt,e.options.locale);return/* @__PURE__ */ U(`div`,{class:`${Q}-module ${Q}-home`,"data-testid":Z.homeView,children:/* @__PURE__ */ U(`div`,{class:`${Q}-home-scroll`,children:[/* @__PURE__ */ U(`div`,{class:`${Q}-home-hero`,children:[/* @__PURE__ */ U(`div`,{class:`${Q}-home-hero-top`,children:[r.brandName?/* @__PURE__ */ U(`span`,{class:`${Q}-home-brand`,"data-testid":Z.homeBrand,children:r.brandName}):/* @__PURE__ */ U(`span`,{class:`${Q}-home-brand-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ U(`div`,{class:`${Q}-home-hero-actions`,children:[h.length>0?/* @__PURE__ */ U(`div`,{class:`${Q}-home-avatars`,children:h.map(e=>/* @__PURE__ */ U(`span`,{class:`${Q}-home-avatar`,title:e.role?`${e.name} · ${e.role}`:e.name,children:e.avatar?/* @__PURE__ */ U(`img`,{src:e.avatar,alt:``,loading:`lazy`}):/* @__PURE__ */ U(`span`,{children:mu(e.name)})},e.name))}):null,/* @__PURE__ */ U(Dl,{panelProps:o,variant:`plain`})]})]}),r.showGreeting===!1?null:/* @__PURE__ */ U(O,{children:[/* @__PURE__ */ U(`h1`,{class:`${Q}-home-greeting`,"data-testid":Z.homeGreeting,children:m.title}),m.subtitle?/* @__PURE__ */ U(`p`,{class:`${Q}-home-lead`,children:m.subtitle}):null]})]}),/* @__PURE__ */ U(`div`,{class:`${Q}-home-cards`,children:[p?/* @__PURE__ */ U(Cu,{options:e.options,onAsk:e=>i.startNewConversation(e)}):null,r.showSearchBar===!1?null:/* @__PURE__ */ U(jl,{placeholder:n.homeSearchPlaceholder,onActivate:()=>i.switchToLayout(`help`)}),y?/* @__PURE__ */ U(pu,{onClick:()=>{s.markSeen(y.id),i.push({kind:`content`,id:y.id,title:y.title})},testid:Z.homeWhatsNew,children:/* @__PURE__ */ U(`div`,{class:`${Q}-home-recent-row`,"data-unread":s.unseen?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Pc,{})}),/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-body`,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-title`,children:n.homeWhatsNew}),/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-preview`,children:b?`${y.title} · ${b}`:y.title})]}),s.unseen?/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-dot`,role:`img`,"aria-label":n.newsUnseen}):null]})}):null,c?/* @__PURE__ */ U(pu,{onClick:()=>i.selectConversation(c),testid:Z.homeRecent,children:/* @__PURE__ */ U(`div`,{class:`${Q}-home-recent-row`,"data-unread":c.hasUnread?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Fc,{})}),/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-body`,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-title`,children:c.title}),c.preview?/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-preview`,children:pl(c.preview)}):null]}),c.hasUnread?/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-dot`,"aria-label":`Unread`}):null]})}):null,g?/* @__PURE__ */ U(pu,{onClick:g.url?()=>i.push({kind:`iframe`,url:g.url,title:_}):void 0,children:/* @__PURE__ */ U(`div`,{class:`${Q}-home-status`,"data-level":g.level??`operational`,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-status-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Mc,{})}),/* @__PURE__ */ U(`span`,{class:`${Q}-home-status-text`,children:_})]})}):null,u.length>0?/* @__PURE__ */ U(`section`,{class:`${Q}-home-content`,children:[/* @__PURE__ */ U(`div`,{class:`${Q}-home-content-title`,children:v}),/* @__PURE__ */ U(`div`,{class:`${Q}-home-content-list`,children:u.map(e=>/* @__PURE__ */ U(Pl,{title:e.title,subtitle:e.description,onClick:()=>Su(i,e),testid:Zc(Z.homeContentRow,e.id)},e.id))})]}):null]})]})})}const Eu={chat:Ol,home:{Icon:Nc,Root:e=>/* @__PURE__ */ U(Tu,{...e})},help:Bl,news:yu},Du=P.cssPrefix;function Ou({modules:e,activeTab:t,strings:n,hasUnread:r,onSelect:i}){return/* @__PURE__ */ U(`nav`,{class:`${Du}-tabbar`,role:`tablist`,"aria-label":n.panelTitle,children:e.map(e=>{let a=Eu[e.layout].Icon,o=e.id===t,s=e.layout===`chat`&&r;return/* @__PURE__ */ U(`button`,{type:`button`,role:`tab`,"aria-selected":o,class:`${Du}-tab`,onClick:()=>i(e.id),"data-testid":Zc(Z.tab,e.id),children:[/* @__PURE__ */ U(`span`,{class:`${Du}-tab-icon`,"aria-hidden":`true`,children:[/* @__PURE__ */ U(a,{}),s?/* @__PURE__ */ U(`span`,{class:`${Du}-tab-badge`,"data-testid":Z.tabBadge,"aria-label":`Unread`}):null]}),/* @__PURE__ */ U(`span`,{class:`${Du}-tab-label`,children:ke(n,e.label)})]},e.id)})})}const ku=P.cssPrefix;function Au({url:e,title:t,strings:n,onBack:r,actions:i}){return/* @__PURE__ */ U(`div`,{class:`${ku}-module`,children:[/* @__PURE__ */ U(cl,{title:t||n.moduleBack,backLabel:n.moduleBack,onBack:r,actions:i}),/* @__PURE__ */ U(`iframe`,{class:`${ku}-content-frame`,src:e,title:t||`content`,sandbox:`allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads`,referrerpolicy:`no-referrer`,loading:`lazy`,allow:`fullscreen`})]})}const ju=P.cssPrefix;function Mu({agent:e,strings:t}){let n=e.status??`online`,r=ke(t,e.name),i=e.title?ke(t,e.title):null;return/* @__PURE__ */ U(`div`,{class:`${ju}-agent`,children:[/* @__PURE__ */ U(`div`,{class:`${ju}-agent-avatar`,"data-status":n,children:e.avatar?/* @__PURE__ */ U(`img`,{src:e.avatar,alt:``}):/* @__PURE__ */ U(`span`,{children:mu(r)})}),/* @__PURE__ */ U(`div`,{class:`${ju}-agent-meta`,children:[/* @__PURE__ */ U(`strong`,{children:r}),i?/* @__PURE__ */ U(`span`,{children:i}):null]})]})}const Nu=[`today`,`yesterday`,`lastWeek`,`older`];function Pu(e,t){let n=Date.parse(t);if(!Number.isFinite(n))return`older`;let r=Math.floor((Iu(e)-Iu(n))/864e5);return r<=0?`today`:r===1?`yesterday`:r<7?`lastWeek`:`older`}function Fu(e,t){let n=/* @__PURE__ */ new Map;for(let r of t){let t=Pu(e,r.lastMessageAt),i=n.get(t);i?i.push(r):n.set(t,[r])}return Nu.filter(e=>n.has(e)).map(e=>({bucket:e,conversations:n.get(e)}))}function Iu(e){let t=new Date(e);return t.setUTCHours(0,0,0,0),t.getTime()}const Lu=I.scope(`history`),Ru={today:`dateToday`,yesterday:`dateYesterday`,lastWeek:`dateLastWeek`,older:`dateOlder`};function zu(e,t){let n=t.type!==`upsert`||t.activity===!0;if(t.type===`snapshot`&&t.result.pagination.page===1&&e.pagination.page>1){let r=Ss(e.conversations.slice(0,t.result.pagination.limit),t,n);if(t.result.conversations.length===0){if(r.length===0)return t.result;let e=Math.max(t.result.pagination.total,r.length);return{...t.result,conversations:r,pagination:{...t.result.pagination,total:e,totalPages:Math.ceil(e/t.result.pagination.limit)}}}let i=new Set(r.map(e=>e.conversationId)),a=e.conversations.slice(t.result.pagination.limit).filter(e=>!i.has(e.conversationId)),o=e.pagination.page,s={...t.result.pagination,page:o,hasPrev:o>1,hasNext:o<t.result.pagination.totalPages};return{conversations:[...r,...a],pagination:s}}let r=Ss(e.conversations,t,n);return r===e.conversations?e:{...t.type===`snapshot`?t.result:e,conversations:r}}function Bu(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<6048e5?new Intl.DateTimeFormat(n,{weekday:`short`}).format(r):new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`}).format(r):``}function Vu({transport:e,strings:t,locale:n,persistence:r,onSelect:i,onNewConversation:a}){let o=P.cssPrefix,s=e.peekConversations({limit:50}),[c,l]=L(s?`loaded`:`loading`),[u,d]=L(s),[f,p]=L(!1),m=z(void 0),h=u?.conversations??[],g=u?.pagination;R(()=>{let t=!1,n=!0,i=[],a=e.subscribeConversationChanges(e=>{n&&i.push(e),d(t=>t&&zu(t,e))});m.current=void 0,p(!1);let o=e.peekConversations({limit:50});return d(o),l(o?`loaded`:`loading`),e.listConversations({limit:50}).then(e=>{if(t)return;let a=e;for(let e of i)a=zu(a,e);i=[],n=!1,d(a),l(`loaded`),r.saveHistoryCount(a.conversations.length)}).catch(e=>{t||(i=[],n=!1,Lu.warn(`listConversations failed`,{err:e}),l(`error`))}),()=>{t=!0,a(),m.current=void 0}},[e,r,n]);async function _(){if(m.current||!g?.hasNext)return;let t={};m.current=t,p(!0);try{let n=await e.listConversations({page:g.page+1,limit:g.limit});if(m.current!==t)return;d(e=>{if(!e)return e;let t=new Set(e.conversations.map(e=>e.conversationId)),i=n.conversations.filter(e=>!t.has(e.conversationId)&&(t.add(e.conversationId),!0)),a={conversations:[...e.conversations,...i],pagination:n.pagination};return r.saveHistoryCount(a.conversations.length),a})}catch(e){if(m.current!==t)return;Lu.warn(`listConversations page failed`,{err:e,page:g.page+1})}finally{m.current===t&&(m.current=void 0,p(!1))}}let v=a?/* @__PURE__ */ U(`div`,{class:`${o}-history-footer`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${o}-history-new`,onClick:a,"data-testid":Z.sidebarNewConversation,children:[/* @__PURE__ */ U(Qs,{}),t.newConversation]})}):null;if(c===`loading`){let e=Math.min(r.loadHistoryCount()??3,6);return/* @__PURE__ */ U(O,{children:[/* @__PURE__ */ U(`div`,{class:`${o}-history`,"aria-busy":`true`,"aria-label":t.historyLoading,children:/* @__PURE__ */ U(`div`,{class:`${o}-history-group`,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`div`,{class:`${o}-history-heading`,children:/* @__PURE__ */ U(`span`,{class:`${o}-skeleton ${o}-skeleton-heading`})}),/* @__PURE__ */ U(`div`,{class:`${o}-history-card`,children:Array.from({length:Math.max(1,e)},(e,t)=>/* @__PURE__ */ U(`div`,{class:`${o}-history-item ${o}-history-item-skeleton`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-avatar ${o}-skeleton`}),/* @__PURE__ */ U(`span`,{class:`${o}-history-body`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-title`,children:/* @__PURE__ */ U(`span`,{class:`${o}-skeleton ${o}-skeleton-title`})}),/* @__PURE__ */ U(`span`,{class:`${o}-history-time`,children:/* @__PURE__ */ U(`span`,{class:`${o}-skeleton ${o}-skeleton-time`})})]}),/* @__PURE__ */ U(`span`,{class:`${o}-history-row`,children:/* @__PURE__ */ U(`span`,{class:`${o}-history-preview`,children:/* @__PURE__ */ U(`span`,{class:`${o}-skeleton ${o}-skeleton-preview`})})})]})]},t))})]})}),v]})}if(c===`error`||h.length===0)return/* @__PURE__ */ U(O,{children:[/* @__PURE__ */ U(`div`,{class:`${o}-history-empty`,children:t.historyEmpty}),v]});let y=Date.now(),b=Fu(y,h);return/* @__PURE__ */ U(O,{children:[/* @__PURE__ */ U(`div`,{class:`${o}-history`,role:`list`,children:[b.map(e=>/* @__PURE__ */ U(`div`,{class:`${o}-history-group`,children:[/* @__PURE__ */ U(`div`,{class:`${o}-history-heading`,children:t[Ru[e.bucket]]}),/* @__PURE__ */ U(`div`,{class:`${o}-history-card`,children:e.conversations.map(e=>/* @__PURE__ */ U(`div`,{role:`listitem`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${o}-history-item`,onClick:()=>i(e),"data-closed":e.canContinue?void 0:`true`,"data-unread":e.hasUnread?`true`:void 0,"data-testid":Zc(Z.historyItem,e.conversationId),children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Tc,{})}),/* @__PURE__ */ U(`span`,{class:`${o}-history-body`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-title`,children:e.title}),/* @__PURE__ */ U(`span`,{class:`${o}-history-time`,children:Bu(e.lastMessageAt,y,n)})]}),/* @__PURE__ */ U(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-preview`,children:e.preview&&pl(e.preview)||(e.canContinue?t.historyContinue:t.conversationClosed)}),e.hasUnread?/* @__PURE__ */ U(`span`,{class:`${o}-history-dot`}):null]})]})]})},e.conversationId))})]},e.bucket)),g?.hasNext?/* @__PURE__ */ U(`div`,{class:`${o}-history-more`,children:/* @__PURE__ */ U(`button`,{type:`button`,onClick:_,disabled:f,"aria-busy":f,"data-testid":Z.historyLoadMore,children:t.loadMoreConversations})}):null]}),v]})}const Hu=P.cssPrefix;function Uu({visible:e,strings:t}){return e?/* @__PURE__ */ U(`div`,{class:`${Hu}-dropzone`,role:`status`,"aria-live":`polite`,children:t.dropZone}):null}const Wu=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Gu=/^https?:\/\/[^\s.]+\.[^\s]+$/i,Ku=/^[+]?[\d\s().-]{6,}$/;function qu(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>String(t[n]??`{${n}}`))}function Ju(e){return Array.isArray(e)?e.length:+!!e?.trim()}function Yu(e,t,n){let r=e.required??!0,i=e.validation;if(e.type===`multiselect`){let e=Ju(t);return r&&e===0?n.formRequired:e===0?void 0:i?.minSelections!=null&&e<i.minSelections?qu(n.formChooseAtLeast,{min:i.minSelections}):i?.maxSelections!=null&&e>i.maxSelections?qu(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(!Wu.test(a))return n.formInvalidEmail;break;case`url`:if(!Gu.test(a))return n.formInvalidUrl;break;case`tel`:if(!Ku.test(a))return n.formInvalidTel;break;case`number`:{let e=Number(a);if(!Number.isFinite(e))return n.formInvalidNumber;if(i?.min!=null&&e<i.min)return qu(n.formNumberTooSmall,{min:i.min});if(i?.max!=null&&e>i.max)return qu(n.formNumberTooLarge,{max:i.max});break}}if(i?.minLength!=null&&a.length<i.minLength)return qu(n.formTooShort,{min:i.minLength});if(i?.maxLength!=null&&a.length>i.maxLength)return qu(n.formTooLong,{max:i.maxLength});if(i?.pattern)try{if(!new RegExp(i.pattern).test(a))return n.formPatternMismatch}catch{}}function Xu(e,t,n){let r={};for(let i of e){let e=Yu(i,t[i.name],n);e&&(r[i.name]=e)}return r}function Zu(e){let t={};for(let[n,r]of Object.entries(e)){let e=Array.isArray(r)?r.join(`, `):r;e.trim()&&(t[n]=e.trim())}return t}const Qu=P.cssPrefix,$u=`__other__`;function ed({fields:e,strings:t,submitLabel:n,onSubmit:r,skipLabel:i,onSkip:a,footerHint:o,submitOnEnter:s,disabled:c,initialValues:l,hideActions:u,fieldTypeLabels:d,rootTestId:f,submitTestId:p,skipTestId:m}){let[h,g]=L(()=>({...id(e),...l})),[_,v]=L({}),[y,b]=L({});function x(e){y[e]&&b(t=>({...t,[e]:``}))}function S(e,t){g(n=>({...n,[e]:t})),x(e)}function ee(e,t){v(n=>({...n,[e]:t})),x(e)}function C(n){if(n.preventDefault(),c)return;let i=ad(e,h,_),a=Xu(e,i,t);Object.keys(a).length>0?b(a):r(Zu(i))}function te(e){!s||e.key!==`Enter`||e.shiftKey||e.isComposing||e.target&&`tagName`in e.target&&e.target.tagName===`TEXTAREA`&&C(e)}return/* @__PURE__ */ U(`form`,{class:`${Qu}-form`,onSubmit:C,onKeyDown:te,"data-testid":f,noValidate:!0,children:[e.map(e=>/* @__PURE__ */ U(td,{field:e,value:h[e.name],otherText:_[e.name]??``,error:y[e.name],disabled:c,typeLabel:d?.[e.name],strings:t,onChange:t=>S(e.name,t),onOtherChange:t=>ee(e.name,t)},e.name)),u?null:/* @__PURE__ */ U(`div`,{class:`${Qu}-form-actions`,children:[o?/* @__PURE__ */ U(`span`,{class:`${Qu}-form-hint`,children:o}):null,i&&a?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Qu}-form-skip`,onClick:a,disabled:c,"data-testid":m,children:i}):null,/* @__PURE__ */ U(`button`,{type:`submit`,class:`${Qu}-form-submit`,disabled:c,"data-testid":p,children:n})]})]})}function td({field:e,value:t,otherText:n,error:r,disabled:i,typeLabel:a,strings:o,onChange:s,onOtherChange:c}){let l=nd({field:e,value:t,otherText:n,disabled:i,strings:o,onChange:s,onOtherChange:c,fieldTid:Zc(Z.formField,e.name)});return/* @__PURE__ */ U(`label`,{class:`${Qu}-field`,"data-field":e.name,"data-invalid":r?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${Qu}-field-head`,children:[/* @__PURE__ */ U(`span`,{class:`${Qu}-field-label`,children:[e.label,e.required??!0?/* @__PURE__ */ U(`span`,{class:`${Qu}-field-req`,"aria-hidden":`true`,children:` *`}):null]}),a?/* @__PURE__ */ U(`span`,{class:`${Qu}-field-type`,children:a}):null]}),l,e.validationHint&&!r?/* @__PURE__ */ U(`span`,{class:`${Qu}-field-hint`,children:e.validationHint}):null,r?/* @__PURE__ */ U(`span`,{class:`${Qu}-field-error`,role:`alert`,children:r}):null]})}function nd(e){let{field:t,value:n,otherText:r,disabled:i,strings:a,onChange:o,onOtherChange:s,fieldTid:c}=e,l=typeof n==`string`?n:``;switch(t.type){case`textarea`:return/* @__PURE__ */ U(`textarea`,{class:`${Qu}-field-input`,rows:3,value:l,placeholder:t.placeholder,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c});case`select`:return/* @__PURE__ */ U(`select`,{class:`${Qu}-field-input`,value:l,disabled:i,onChange:e=>o(e.currentTarget.value),"data-testid":c,children:[/* @__PURE__ */ U(`option`,{value:``,children:t.placeholder??`—`}),(t.options??[]).map(e=>/* @__PURE__ */ U(`option`,{value:e.value,children:e.label??e.value},e.value))]});case`radio`:{let e=t.allowOther&&l===$u;return/* @__PURE__ */ U(`div`,{class:`${Qu}-field-choices`,role:`radiogroup`,"data-testid":c,children:[(t.options??[]).map(e=>/* @__PURE__ */ U(`label`,{class:`${Qu}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`radio`,name:`${Qu}-${t.name}`,checked:l===e.value,disabled:i,onChange:()=>o(e.value)}),/* @__PURE__ */ U(`span`,{children:e.label??e.value})]},e.value)),t.allowOther?/* @__PURE__ */ U(`label`,{class:`${Qu}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`radio`,name:`${Qu}-${t.name}`,checked:l===$u,disabled:i,onChange:()=>o($u)}),/* @__PURE__ */ U(`span`,{children:a.formOther})]}):null,e?/* @__PURE__ */ U(`input`,{class:`${Qu}-field-input`,value:r,placeholder:t.placeholder??a.formOtherPlaceholder,disabled:i,onInput:e=>s(e.currentTarget.value)}):null]})}case`checkbox`:return/* @__PURE__ */ U(`label`,{class:`${Qu}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`checkbox`,checked:l===`true`,disabled:i,onChange:e=>o(e.currentTarget.checked?`true`:``),"data-testid":c}),/* @__PURE__ */ U(`span`,{children:t.placeholder??t.label})]});case`multiselect`:{let e=Array.isArray(n)?n:[];function l(t,n){return o(n?[...e,t]:e.filter(e=>e!==t))}return/* @__PURE__ */ U(`div`,{class:`${Qu}-field-choices`,"data-testid":c,children:[(t.options??[]).map(t=>/* @__PURE__ */ U(`label`,{class:`${Qu}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`checkbox`,checked:e.includes(t.value),disabled:i,onChange:e=>l(t.value,e.currentTarget.checked)}),/* @__PURE__ */ U(`span`,{children:t.label??t.value})]},t.value)),t.allowOther||(t.options??[]).length===0?/* @__PURE__ */ U(`textarea`,{class:`${Qu}-field-input`,rows:2,value:r,placeholder:t.placeholder??a.formOtherPlaceholder,disabled:i,onInput:e=>s(e.currentTarget.value)}):null]})}default:return/* @__PURE__ */ U(`input`,{...rd(t.type),class:`${Qu}-field-input`,value:l,placeholder:t.placeholder,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c})}}function rd(e){switch(e){case`number`:return{type:e};case`email`:return{type:e};case`tel`:return{type:e};case`url`:return{type:e};case`date`:case`time`:return{type:e};default:return{type:`text`}}}function id(e){let t={};for(let n of e)n.defaultValue!=null&&(t[n.name]=n.type===`multiselect`?n.defaultValue.split(`,`).map(e=>e.trim()).filter(Boolean):n.defaultValue);return t}function ad(e,t,n){let r={...t};for(let i of e){let e=n[i.name]?.trim();if(i.type===`radio`&&i.allowOther&&t[i.name]===$u)r[i.name]=e??``;else if(i.type===`multiselect`&&e){let n=e.split(/[,\n;]+/).map(e=>e.trim()).filter(Boolean),a=t[i.name];r[i.name]=[...Array.isArray(a)?a:[],...n]}}return r}const od=P.cssPrefix;function sd({form:e,strings:t,onSubmit:n,onSkip:r}){return/* @__PURE__ */ U(`div`,{class:`${od}-form-gate`,"data-testid":Z.formGate,children:[e.title?/* @__PURE__ */ U(`h3`,{class:`${od}-form-gate-title`,children:e.title}):null,e.description?/* @__PURE__ */ U(`p`,{class:`${od}-form-gate-desc`,children:e.description}):null,/* @__PURE__ */ U(ed,{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:Z.formSubmit,skipTestId:Z.formSkip})]})}function cd({marker:e,strings:t,onFill:n}){let r=e.outcome===`skipped`,i=r?t.formSkipped:t.formSubmitted,a=e.title?/* @__PURE__ */ U(O,{children:[/* @__PURE__ */ U(`span`,{children:e.title}),/* @__PURE__ */ U(`span`,{class:`${od}-sr-only`,children:i})]}):/* @__PURE__ */ U(`span`,{children:i}),o=e.form?.reviewable??!1,s=!r&&o&&e.values&&Object.keys(e.values).length>0?e.values:null;if(s){function t(t){return e.form?.fields.find(e=>e.name===t)?.label??t}return/* @__PURE__ */ U(`details`,{class:`${od}-form-done`,"data-outcome":e.outcome,"data-testid":Z.formDone,children:[/* @__PURE__ */ U(`summary`,{class:`${od}-form-done-summary`,"data-testid":Z.formDoneToggle,children:[/* @__PURE__ */ U(_c,{}),a,/* @__PURE__ */ U(nc,{})]}),/* @__PURE__ */ U(`dl`,{class:`${od}-form-answers`,"data-testid":Z.formAnswers,children:Object.entries(s).map(([e,n])=>/* @__PURE__ */ U(`div`,{class:`${od}-form-answer`,children:[/* @__PURE__ */ U(`dt`,{children:t(e)}),/* @__PURE__ */ U(`dd`,{children:n})]},e))})]})}return/* @__PURE__ */ U(`div`,{class:`${od}-form-done`,"data-outcome":e.outcome,"data-testid":Z.formDone,role:`status`,children:[U(r?gc:_c,{}),a,r&&e.form?.reopenable&&n?/* @__PURE__ */ U(`button`,{type:`button`,class:`${od}-form-done-fill`,"data-testid":Z.formFill,onClick:n,children:t.formFillOut}):null]})}var ld=Object.assign;function ud(e,t){for(var n in e)if(n!=`__source`&&e[n]!==t[n])return!0;for(var r in t)if(r!=`__source`&&!(r in e))return!0;return!1}var dd=/^(-|f[lo].*[^se]$|g.{5,}[^ps]$|z|o[pr]|(W.{5})?[lL]i.*(t|mp)$|an|(bo|s).{4}Im|sca|m.{6}[ds]|ta|c.*[st]$|wido|ini)/;function fd(e,t){function n(e){var n=this.props.ref;return n!=e.ref&&n&&(typeof n==`function`?n(null):n.current=null),t?!t(this.props,e)||n!=e.ref:ud(this.props,e)}function r(t){return this.shouldComponentUpdate=n,E(e,t)}return r.displayName=`Memo(`+(e.displayName||e.name)+`)`,r.prototype.isReactComponent=!0,r.type=e,r}var pd=Symbol.for(`react.element`),md=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(?!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,hd=/[A-Z0-9]/g,gd=typeof document<`u`,_d=function(e){return/fil|che|rad/.test(e)};ne.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(ne.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var vd=u.event;u.event=function(e){return vd&&(e=vd(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var yd={configurable:!0,get:function(){return this.class}},bd=u.vnode;u.vnode=function(e){if(typeof e.type==`string`)(function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)==-1;for(var a in t){var o=t[a];if(!(a==`value`&&`defaultValue`in t&&o==null||gd&&a==`children`&&n==`noscript`||a==`class`||a==`className`)){if(a==`style`&&o&&o.constructor==Object){var s=void 0;for(var c in o)typeof o[c]!=`number`||dd.test(c)||(s||(s=o=ld({},o)),o[c]+=`px`)}else if(a==`defaultValue`&&`value`in t&&t.value==null)a=`value`;else if(a==`download`&&!0===o)o=``;else if(a==`translate`&&o===`no`)o=!1;else if(a[0]==`o`&&a[1]==`n`){var l=a.toLowerCase();l==`ondoubleclick`?a=`ondblclick`:l!=`onchange`||n!=`input`&&n!=`textarea`||_d(t.type)?l==`onfocus`?a=`onfocusin`:l==`onblur`&&(a=`onfocusout`):l=a=`oninput`,l==`oninput`&&r[a=l]&&(a=`oninputCapture`)}else i&&md.test(a)?a=a.replace(hd,`-$&`).toLowerCase():o===null&&(o=void 0);r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=oe(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=oe(t.children).forEach(function(e){e.props.selected=r.multiple?r.defaultValue.indexOf(e.props.value)!=-1:r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",yd)):t.className&&(r.class=r.className=t.className),e.props=r})(e);else if(typeof e.type==`function`&&(`ref`in e.props&&`prototype`in e.type&&e.type.prototype.render&&(e.ref=e.props.ref,delete e.props.ref),e.type.defaultProps)){var t=ld({},e.props);for(var n in e.type.defaultProps)t[n]===void 0&&(t[n]=e.type.defaultProps[n]);e.props=t}e.ref&&!(`ref`in e.props)&&Object.defineProperty(e.props,"ref",{value:e.ref,configurable:!0,writable:!0}),e.$$typeof=pd,bd&&bd(e)};function xd(e){return e?(e.startsWith(`tool:`)?e.slice(5):e)===`ask-user-questions`:!1}const Sd=P.cssPrefix;function Cd({messageId:e,initial:t,strings:n,onFeedback:r}){let[i,a]=L(t);R(()=>a(t),[e,t]);function o(t){let n=i===t?null:t;a(n),r(e,n)}return/* @__PURE__ */ U(`div`,{class:`${Sd}-feedback`,role:`group`,"data-testid":Z.messageFeedback,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${Sd}-msg-action`,"data-active":i===`up`?`true`:void 0,"aria-pressed":i===`up`,"aria-label":n.feedbackUp,title:n.feedbackUp,onClick:()=>o(`up`),"data-testid":Z.feedbackUp,children:/* @__PURE__ */ U(Wc,{})}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Sd}-msg-action`,"data-active":i===`down`?`true`:void 0,"aria-pressed":i===`down`,"aria-label":n.feedbackDown,title:n.feedbackDown,onClick:()=>o(`down`),"data-testid":Z.feedbackDown,children:/* @__PURE__ */ U(Gc,{})}),/* @__PURE__ */ U(`span`,{class:`${Sd}-sr-only`,role:`status`,"aria-live":`polite`,children:i?n.feedbackThanks:``})]})}const wd=P.cssPrefix;function Td(e){let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function Ed(e){if(e.startsWith(`tool:`)||e.startsWith(`tool-`))return e.slice(5);let t=e.indexOf(`__`),n=e.slice(t+2);return t>0&&n?`${Td(e.slice(0,t))} · ${Td(n)}`:e}function Dd(e,t){let n=e===`output-available`||e===`output-error`||e===`output-denied`,r=e===`approval-responded`||t?.approved!==void 0;return{terminal:n,responded:r,decided:n||r}}function Od({status:e,icon:t,label:n}){return/* @__PURE__ */ U(`span`,{class:`${wd}-toolui-badge ${wd}-toolui-status`,"data-status":e,children:[/* @__PURE__ */ U(`span`,{class:`${wd}-toolui-status-icon`,children:t}),n]})}function kd(e,t){return e===`output-error`?`error`:e===`output-denied`||t?.approved===!1?`denied`:e===`output-available`?`completed`:e===`approval-responded`||t?.approved===!0?`responded`:e===`approval-requested`?`awaiting`:`running`}function Ad(e,t,n={}){return n.submitted?`responded`:Nd(kd(e,t),n.superseded,n.live??!0)}function jd({status:e}){return U(e===`denied`||e===`error`||e===`superseded`?Yc:e===`completed`||e===`responded`?Jc:qc,{})}function Md(e,t){switch(e){case`awaiting`:return t.statusAwaiting;case`responded`:return t.statusResponded;case`completed`:return t.statusCompleted;case`denied`:return t.statusDenied;case`error`:return t.statusError;case`superseded`:return t.statusSuperseded;default:return t.statusRunning}}function Nd(e,t,n){return t&&(e===`awaiting`||e===`running`)?`superseded`:!n&&e===`running`?`error`:e}function Pd({state:e,approval:t,strings:n,superseded:r,live:i=!0,submitted:a=!1}){let o=Ad(e,t,{superseded:r,live:i,submitted:a});return/* @__PURE__ */ U(Od,{status:o,icon:/* @__PURE__ */ U(jd,{status:o}),label:Md(o,n)})}function Fd({name:e,state:t,approval:n,strings:r,superseded:i,live:a,submitted:o}){return/* @__PURE__ */ U(O,{children:[/* @__PURE__ */ U(`span`,{class:`${wd}-toolui-name-pill`,children:[/* @__PURE__ */ U(Kc,{}),/* @__PURE__ */ U(`span`,{class:`${wd}-toolui-name-text`,children:e})]}),/* @__PURE__ */ U(Pd,{state:t,approval:n,strings:r,superseded:i,live:a,submitted:o}),/* @__PURE__ */ U(`span`,{class:`${wd}-toolui-chevron`,children:/* @__PURE__ */ U(Sc,{})})]})}function Id({part:e,strings:t,testid:n,superseded:r,live:i,submitted:a}){let o=B(()=>dr(()=>e.inputSig.value),[e]),s=B(()=>dr(()=>e.outputSig.value),[e]),c=B(()=>dr(()=>e.errorSig.value),[e]),l=B(()=>dr(()=>e.stateSig.value),[e]),u=B(()=>dr(()=>e.approvalSig.value),[e]);return/* @__PURE__ */ U(`details`,{class:`${wd}-toolui ${wd}-toolui-collapsible`,"data-testid":n,children:[/* @__PURE__ */ U(`summary`,{class:`${wd}-toolui-head`,children:/* @__PURE__ */ U(Fd,{name:Ed(e.toolName),state:l.value,approval:u.value,strings:t,superseded:r,live:i,submitted:a})}),/* @__PURE__ */ U(Ld,{label:t.toolParameters,value:o.value}),s.value===void 0?null:/* @__PURE__ */ U(Ld,{label:t.toolResult,value:s.value}),c.value?/* @__PURE__ */ U(Ld,{label:t.statusError,value:c.value,error:!0}):null]})}function Ld({label:e,value:t,error:n}){let r=n?typeof t==`string`?t:``:zd(Rd(t));return r?/* @__PURE__ */ U(`div`,{class:`${wd}-toolui-section`,children:[/* @__PURE__ */ U(`span`,{class:`${wd}-toolui-label`,children:e}),/* @__PURE__ */ U(`pre`,{class:`${wd}-toolui-code`,"data-error":n?`true`:void 0,children:r})]}):null}function Rd(e){if(e&&typeof e==`object`){let t=e;if(t.storage===`tool-result-ref`&&`summary`in t)return t.summary}return e}function zd(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)}…`:t}catch{return``}}function Bd(e){return e.partsSig.value.some(e=>e.kind===`text`&&e.textSig.value.length>0)}function Vd(e){return e.partsSig.value.some(e=>e.kind===`reasoning`)}function Hd(e){return e.streaming&&!e.bufferedHold&&!(e.reasoningVisible&&e.working)}function Ud(e){let{streaming:t,reasoningVisible:n,emptyReply:r,hidden:i}=e,a=e.responseMode===`buffered`&&t,o=t&&!e.hasAnswerText;return{streaming:t,bufferedHold:a,reasoningVisible:n,working:o,showStreamDots:Hd({streaming:t,bufferedHold:a,reasoningVisible:n,working:o}),emptyReply:r,hidden:i}}function Wd(e,t){let n=e.stateSig.value,r=e.approvalSig.value,{terminal:i,responded:a,decided:o}=Dd(n,r),s=t.continuationStreaming===!0&&!o,c=t.superseded&&!o&&!s;return{pill:Ad(n,r,{superseded:c,live:t.live,submitted:s}),state:n,terminal:i,decided:o||s,showApproveReject:!o&&!t.superseded&&!s,showAnswered:a&&!i&&!c,showSubmitted:s,showEdit:a&&t.active&&!i,skipped:c,answeredApproved:r?.approved}}const Gd=P.cssPrefix;function Kd({part:e,strings:t}){let n=e.title||e.filename||e.url||t.sources;return e.url?/* @__PURE__ */ U(`a`,{class:`${Gd}-source`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-testid":Z.source,children:[/* @__PURE__ */ U(`span`,{class:`${Gd}-source-icon`,"aria-hidden":`true`,children:`🔗`}),/* @__PURE__ */ U(`span`,{class:`${Gd}-source-label`,children:n})]}):/* @__PURE__ */ U(`span`,{class:`${Gd}-source`,"data-testid":Z.source,children:[/* @__PURE__ */ U(`span`,{class:`${Gd}-source-icon`,"aria-hidden":`true`,children:`📄`}),/* @__PURE__ */ U(`span`,{class:`${Gd}-source-label`,children:n})]})}const qd=P.cssPrefix;function Jd({part:e,strings:t,active:n,superseded:r=!1,continuationStreaming:i=!1,onDecision:a,onEdit:o}){let s=B(()=>dr(()=>e.approvalSig.value),[e]),c=B(()=>dr(()=>Wd(e,{active:n,superseded:r,continuationStreaming:i})),[e,n,r,i]).value,{terminal:l,showApproveReject:u,showAnswered:d,showSubmitted:f,showEdit:p,skipped:m}=c,h=Ed(e.toolName),g=c.answeredApproved,_=e.toolCallId,v=/* @__PURE__ */ U(O,{children:[/* @__PURE__ */ U(`p`,{class:`${qd}-toolui-prompt`,children:t.approvalPrompt.replace(`{tool}`,h)}),/* @__PURE__ */ U(`p`,{class:`${qd}-toolui-subtle`,children:t.approvalBody})]});f?v=/* @__PURE__ */ U(`p`,{class:`${qd}-toolui-subtle`,children:t.approvalSubmitting}):d&&g!==!1?v=/* @__PURE__ */ U(O,{children:[/* @__PURE__ */ U(`p`,{class:`${qd}-toolui-prompt`,children:[t.approvalYourResponse.replace(`{decision}`,g?t.approve:t.reject),s.value?.reason?` — ${s.value.reason}`:``]}),p?/* @__PURE__ */ U(`p`,{class:`${qd}-toolui-subtle`,children:t.approvalEditHint}):null,p?null:/* @__PURE__ */ U(`p`,{class:`${qd}-toolui-subtle`,children:t.approvalSubmitting})]}):d&&(v=/* @__PURE__ */ U(O,{}));let y=u||f||p||d&&g!==!1;return/* @__PURE__ */ U(`div`,{class:`${qd}-toolui-group`,"data-testid":c.decided?Z.toolDecision:Z.toolApproval,children:[/* @__PURE__ */ U(Id,{part:e,strings:t,superseded:m,submitted:f}),m||l||!y?null:/* @__PURE__ */ U(`div`,{class:`${qd}-toolui ${qd}-toolui-body`,children:[v,u?/* @__PURE__ */ U(`div`,{class:`${qd}-toolui-actions`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${qd}-form-skip`,disabled:!n,onClick:()=>a(_,!1),"data-testid":Z.toolReject,children:t.reject}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${qd}-form-submit`,disabled:!n,onClick:()=>a(_,!0),"data-testid":Z.toolApprove,children:t.approve})]}):null,p?/* @__PURE__ */ U(`div`,{class:`${qd}-toolui-actions`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${qd}-form-skip`,onClick:()=>o(_),"data-testid":Z.toolEdit,children:t.edit})}):null]})]})}const Yd=[`text`,`email`,`phone`,`number`,`date`,`single-select`,`multi-select`,`boolean`];function Xd(e){return typeof e==`object`&&!!e}function Zd(e){let t=Xd(e)?e:{},n=(Array.isArray(t.questions)?t.questions:[]).map(Qd).filter(e=>e!==null);return{intro:tf(t.intro),questions:n}}function Qd(e,t){if(!Xd(e))return null;let n=Yd.find(t=>t===e.type)??`text`;return{key:tf(e.key)??`q${t+1}`,question:tf(e.question)??`Please provide the missing information.`,type:n,options:Array.isArray(e.options)?e.options.filter(e=>typeof e==`string`&&e.trim().length>0):void 0,required:typeof e.required==`boolean`?e.required:void 0,helpText:tf(e.helpText)}}function $d(e){switch(e){case`text`:return`textarea`;case`phone`:return`tel`;case`single-select`:case`boolean`:return`radio`;case`multi-select`:return`multiselect`;default:return e}}function ef(e,t,n){return e.questions.map(e=>{let r=$d(e.type),i=e.type===`boolean`?[{value:`yes`,label:t},{value:`no`,label:n}]:(e.options??[]).map(e=>({value:e,label:e}));return{name:e.key,label:e.question,type:r,required:e.required??!1,options:i.length>0?i:void 0,validationHint:e.helpText}})}function tf(e){return typeof e==`string`&&e.trim()?e.trim():void 0}const nf=P.cssPrefix;function rf({skipped:e,submitted:t,strings:n}){return e?{status:`superseded`,statusLabel:n.inputSkipped}:t?{status:`responded`,statusLabel:n.statusResponded}:{status:`completed`,statusLabel:n.inputAnswered}}const af={text:`qtypeText`,email:`qtypeEmail`,phone:`qtypePhone`,number:`qtypeNumber`,date:`qtypeDate`,"single-select":`qtypeChooseOne`,"multi-select":`qtypeChooseAny`,boolean:`qtypeBoolean`};function of(e,t){let n={};for(let r of e)n[r.key]=t[af[r.type]];return n}function sf({part:e,strings:t,active:n,superseded:r=!1,continuationStreaming:i=!1,onDecision:a,onEdit:o}){let s=B(()=>dr(()=>e.stateSig.value),[e]).value,c=B(()=>dr(()=>e.approvalSig.value),[e]).value,l=B(()=>dr(()=>Zd(e.inputSig.value)),[e]).value,{terminal:u,decided:d}=Dd(s,c),f=d&&c?.approved===!0,p=i&&!d,m=!d&&!r&&!p,h=!m&&!f&&!p,g=f&&n&&!u,_=l.questions,[v,y]=L(null),b=v??(m||f||p),[x,S]=L(!1),ee=_.length>1?Xs:Ec,C=m?t.inputRequired:t.inputBadge,te=p?/* @__PURE__ */ U(`p`,{class:`${nf}-toolui-subtle`,children:t.approvalSubmitting}):m?/* @__PURE__ */ U(cf,{req:l,strings:t,active:n,resolve:(t,n)=>a(e.toolCallId,n,t)}):x?/* @__PURE__ */ U(ed,{fields:ef(l,t.confirmYes,t.confirmNo),strings:t,submitLabel:t.inputSubmit,onSubmit:()=>{},disabled:!0,hideActions:!0,fieldTypeLabels:of(_,t),initialValues:f?mf(_,c?.reason):void 0}):/* @__PURE__ */ U(lf,{questions:_,answers:f?pf(c?.reason):{},strings:t}),{status:w,statusLabel:T}=rf({skipped:h,submitted:p,strings:t});return/* @__PURE__ */ U(`details`,{class:`${nf}-toolui ${nf}-toolui-collapsible${r?` ${nf}-toolui-stale`:``}`,open:b,onToggle:e=>{let t=e.currentTarget.open;t!==b&&y(t)},"data-testid":m?Z.toolAskQuestions:Z.toolDecision,children:[/* @__PURE__ */ U(`summary`,{class:`${nf}-toolui-head`,children:[/* @__PURE__ */ U(`span`,{class:`${nf}-toolui-q-pill`,children:[/* @__PURE__ */ U(ee,{}),C]}),/* @__PURE__ */ U(`span`,{class:`${nf}-toolui-head-end`,children:[m?null:/* @__PURE__ */ U(Od,{status:w,icon:U(h?Yc:Jc,{}),label:T}),/* @__PURE__ */ U(`span`,{class:`${nf}-toolui-chevron`,children:/* @__PURE__ */ U(Sc,{})})]})]}),/* @__PURE__ */ U(`div`,{class:`${nf}-toolui-collapse-body`,children:[l.intro?/* @__PURE__ */ U(`div`,{class:`${nf}-toolui-desc`,children:l.intro}):null,te,m||p?null:/* @__PURE__ */ U(`div`,{class:`${nf}-toolui-footer`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${nf}-toolui-options-toggle`,onClick:()=>S(e=>!e),"data-testid":Z.toolAskOptions,children:[/* @__PURE__ */ U(`span`,{class:`${nf}-toolui-options-chevron${x?` ${nf}-open`:``}`,children:/* @__PURE__ */ U(Sc,{})}),x?t.hideOptions:t.showOptions]}),g?/* @__PURE__ */ U(`button`,{type:`button`,class:`${nf}-form-skip`,onClick:()=>o(e.toolCallId),"data-testid":Z.toolEdit,children:t.edit}):null]})]})]})}function cf({req:e,strings:t,active:n,resolve:r}){let i=ef(e,t.confirmYes,t.confirmNo),a=e.questions.length===1&&e.questions[0]?.type===`text`;return/* @__PURE__ */ U(ed,{fields:i,strings:t,disabled:!n,submitLabel:t.inputSubmit,footerHint:a?t.inputSubmitHint:void 0,onSubmit:t=>r(df(e.questions,t),!0),skipLabel:t.inputSkip,onSkip:()=>r(void 0,!1),submitOnEnter:a,fieldTypeLabels:of(e.questions,t),submitTestId:Z.toolInputSubmit,skipTestId:Z.toolInputSkip})}function lf({questions:e,answers:t,strings:n}){return/* @__PURE__ */ U(`div`,{class:`${nf}-toolui-summary`,"data-testid":Z.toolAskSummary,children:e.map(e=>/* @__PURE__ */ U(`div`,{class:`${nf}-field`,children:[/* @__PURE__ */ U(`span`,{class:`${nf}-field-head`,children:/* @__PURE__ */ U(`span`,{class:`${nf}-field-label`,children:[e.question,e.required?/* @__PURE__ */ U(`span`,{class:`${nf}-field-req`,"aria-hidden":`true`,children:` *`}):null]})}),/* @__PURE__ */ U(`p`,{class:`${nf}-toolui-answer`,children:uf(e,t[e.key],n)||`—`})]},e.key))})}function uf(e,t,n){return e.type===`boolean`?t===`yes`?n.confirmYes:t===`no`?n.confirmNo:t??``:t??``}function df(e,t){let n=e.flatMap(e=>{let n=t[e.key];if(n==null||n.trim()===``)return[];let r=e.type===`multi-select`?n.split(`,`).map(e=>e.trim()).filter(Boolean):n;return[{key:e.key,value:r}]});return JSON.stringify({answers:n})}function ff(e){if(!e)return{};let t=(()=>{try{return JSON.parse(e)}catch{return}})()?.answers;if(!Array.isArray(t))return{};let n={};for(let e of t)if(e&&typeof e==`object`&&`key`in e){let{key:t,value:r}=e;if(typeof t!=`string`)continue;typeof r==`string`?n[t]=r:Array.isArray(r)&&(n[t]=r.filter(e=>typeof e==`string`))}return n}function pf(e){let t=ff(e),n={};for(let[e,r]of Object.entries(t))n[e]=Array.isArray(r)?r.join(`, `):r;return n}function mf(e,t){let n=ff(t),r={};for(let t of e){let e=n[t.key];e!==void 0&&(t.type===`multi-select`?r[t.key]=Array.isArray(e)?e:[e]:r[t.key]=Array.isArray(e)?e[0]??``:e)}return r}function hf({part:e,strings:t,live:n}){let r=B(()=>dr(()=>e.inputSig.value),[e]),i=B(()=>dr(()=>e.outputSig.value),[e]),a=B(()=>dr(()=>e.errorSig.value),[e]);return B(()=>dr(()=>!!zd(r.value)||!!a.value||!!zd(Rd(i.value))),[r,i,a]).value?/* @__PURE__ */ U(Id,{part:e,strings:t,testid:Z.toolCall,live:n}):null}const gf=P.cssPrefix,_f=fd(vf);function vf({message:e,status:t,strings:n,responseMode:r,showReasoning:i,showToolCalls:a,showSources:o,interactive:s=!1,superseded:c=!1,tool:l,onRetry:u,enableMessageFeedback:d=!1,onFeedback:f}){let p=[...B(()=>dr(()=>e.partsSig.value),[e]).value];for(let t of e.attachments??[])t.url&&!p.some(e=>e.kind===`file`&&e.url===t.url)&&p.push({kind:`file`,url:t.url,mediaType:t.mediaType});let m=B(()=>dr(()=>ts(e)),[e]),h=B(()=>dr(()=>rs(e)),[e]),g=B(()=>dr(()=>Bd(e)),[e]),_=B(()=>dr(()=>i&&Vd(e)),[e,i]),v=t===`streaming`,y=e.role===`assistant`&&v,b=Ud({streaming:y,responseMode:r,reasoningVisible:_.value,hasAnswerText:g.value,emptyReply:m.value,hidden:h.value}),{bufferedHold:x,working:S,showStreamDots:ee}=b;if(b.hidden)return null;let C=bf(e.createdAt),te=e.role===`assistant`||e.role===`operator`,w=d&&!!f&&!!e.serverMessageId&&te&&!v&&t!==`error`&&!m.value,T=v?``:p.filter(e=>e.kind===`text`).map(t=>e.role===`assistant`?so(t.textSig.peek()):t.textSig.peek()).join(`
58
+ `))!==-1;){let e=r.slice(0,a);r=r.slice(a+2),yield e}}}finally{n.releaseLock()}}function oc(e,t){let n=``,r;for(let i of e.split(`
59
+ `))if(i!==``){if(i.startsWith(`:`))t?.(i.slice(1).trim());else if(i.startsWith(`data:`)){let e=i.slice(5).replace(/^ /,``);n=n?`${n}\n${e}`:e}else i.startsWith(`id:`)&&(r=i.slice(3).trim())}if(n===`[DONE]`)return`done`;if(!n)return null;try{let e=JSON.parse(n);return rc.trace(`chunk`,{type:e.type,eventId:r}),{chunk:e,eventId:r}}catch(e){throw rc.trace(`frame parse failed`,{errorType:e instanceof Error?e.name:typeof e,payloadLength:n.length}),new nc(`invalid SSE frame`,`network`,void 0,e)}}const J=C.scope(`transport`),sc=6e4,cc=/* @__PURE__ */ new WeakMap;function lc(e){return cc.get(e)}function uc(e,t){return cc.set(e,t),e}function dc(e){return Math.max(e?.upsertRevision??0,e?.read?.revision??0)}function fc(e,t){return e.conversationId===t.conversationId&&e.title===t.title&&e.lastMessageAt===t.lastMessageAt&&e.preview===t.preview&&e.canContinue===t.canContinue&&e.hasUnread===t.hasUnread&&e.controlState===t.controlState}function pc(e,t,n=!0){switch(t.type){case`snapshot`:{let n=new Map(e.map(e=>[e.conversationId,e])),r=e.filter(e=>(lc(e)?.activityRevision??0)>t.requestedRevision).toSorted((e,t)=>lc(t).activityRevision-lc(e).activityRevision),i=new Set(r.map(e=>e.conversationId));return[...r,...t.result.conversations.filter(e=>!i.has(e.conversationId)).map(e=>{let r=n.get(e.conversationId);if(!r)return e;let i=lc(r);return(i?.upsertRevision??0)>t.requestedRevision?r:i?.read&&!r.hasUnread&&i.read.lastMessageAt===e.lastMessageAt?uc({...e,hasUnread:!1},{upsertRevision:0,read:i.read}):e})]}case`read`:{let n=e.findIndex(e=>e.conversationId===t.conversationId&&(t.lastMessageAt===void 0||e.lastMessageAt===t.lastMessageAt));if(n<0)return e;let r=e[n],i=lc(r);if(dc(i)>t.revision)return e;let a=t.lastMessageAt??r.lastMessageAt,o={upsertRevision:i?.upsertRevision??0,...i?.activityRevision===void 0?{}:{activityRevision:i.activityRevision},read:{revision:t.revision,...a?{lastMessageAt:a}:{}}};return r.hasUnread?e.map((e,t)=>t===n?uc({...e,hasUnread:!1},o):e):(uc(r,o),e)}case`upsert`:{let r=e.findIndex(e=>e.conversationId===t.conversation.conversationId);if(r<0&&!n)return e;let i=r<0?void 0:e[r],a=i?lc(i):void 0;if(dc(a)>t.revision)return e;let o=t.activity?t.revision:a?.activityRevision,s={upsertRevision:t.revision,...o===void 0?{}:{activityRevision:o},...!t.conversation.hasUnread&&a?.read?{read:a.read}:{}},c=i?{...i,...t.conversation,title:i.title}:{...t.conversation};return i&&fc(i,c)?(uc(i,s),e):(uc(c,s),t.activity?[c,...e.filter(e=>e.conversationId!==c.conversationId)]:i?e.map((e,t)=>t===r?c:e):[...e,c])}default:return t}}const mc=/* @__PURE__ */ new Set([408,425,429,500,502,503,504]);function hc(e){return 400*2**e+Math.floor(Math.random()*250)}function gc(e){return 6e4+Math.ceil(e/1048576)*15e3}function _c(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}var vc=class{constructor(e){this.ttlMs=e,s(this,`map`,/* @__PURE__ */ new Map)}getOrFetch(e,t){let n=this.map.get(e);if(n&&performance.now()-n.at<this.ttlMs)return n.result;let r={at:performance.now(),result:t().then(e=>(r.value=e,e)).catch(t=>{throw this.map.get(e)===r&&this.map.delete(e),t})};return this.map.set(e,r),r.result}peek(e){let t=this.map.get(e);if(t?.value!==void 0&&performance.now()-t.at<this.ttlMs)return t.value}update(e){for(let t of this.map.values())if(t.value!==void 0){let n=e(t.value);t.value=n,t.result=Promise.resolve(n)}else t.result=t.result.then(n=>{let r=e(n);return t.value=r,r})}delete(e){this.map.delete(e)}},yc=class{constructor(e){this.opts=e,s(this,`conversationListeners`,/* @__PURE__ */ new Set),s(this,`conversationRevision`,0),s(this,`visitorId`,void 0),s(this,`conversationId`,void 0),s(this,`userContext`,void 0),s(this,`pageContext`,void 0),s(this,`locale`,void 0),s(this,`userTokenSource`,void 0),s(this,`userToken`,void 0),s(this,`userTokenRequest`,void 0),s(this,`conversationsCache`,new vc(1e4)),s(this,`contentCache`,new vc(sc)),s(this,`contentCollectionsCache`,new vc(sc))}setUserToken(e){this.userTokenSource=e,this.userToken=typeof e==`string`&&e||void 0,this.userTokenRequest=typeof e==`function`?this.fetchUserToken():void 0}setContext(e,t){this.userContext=e,this.pageContext=t}setLocale(e){this.locale=e}primeIdentity(e,t){e&&(this.visitorId=e),t&&(this.conversationId=t)}envelope(){let e={_ev:Hn};this.visitorId&&(e.visitorId=this.visitorId),this.conversationId&&(e.conversationId=this.conversationId),this.locale&&(e.locale=this.locale);let t=tc(this.userContext,this.pageContext);return t&&(e[is]=t),e}withEnvelope(e){return{...this.envelope(),...e}}appendEnvelope(e){for(let[t,n]of Object.entries(this.envelope()))e.append(t,n);return e}withEnvelopeQuery(e){let t=new URL(this.url(e));for(let[e,n]of Object.entries(this.envelope()))t.searchParams.has(e)||t.searchParams.set(e,n);return t.toString()}async handshake(e){J.debug(`handshake →`,{visitorId:e.visitorId,conversationId:e.conversationId,locale:e.locale}),this.userTokenRequest&&await this.userTokenRequest;let t=await this.postJson(rs.handshake,e,`handshake`);return J.debug(`handshake ←`,{visitorId:t.visitorId,conversationId:t.conversationId,hasWelcome:!!t.welcome,hasConfig:!!t.config,rebind:t.rebind}),this.visitorId=e.visitorId,this.conversationId=t.conversationId,t}async uploadFile(e,t){J.debug(`uploadFile →`,{name:e.name,size:e.size,type:e.type});let n=new FormData;n.append(`file`,e,e.name);let r=await this.postForm(this.uploadPath,n,`upload`,t,gc(e.size));return J.debug(`uploadFile ←`,{id:r.id,url:r.url}),r}async transcribe(e,t=`audio/webm`){J.debug(`transcribe →`,{size:e.size,mimeType:t});let n=new FormData;n.append(`audio`,e,`voice.${bc(t)}`),n.append(`mimeType`,t);let r=await this.postForm(this.transcribePath,n,`transcribe`);return J.debug(`transcribe ←`,{textLen:r.text.length}),r}subscribeConversationChanges(e){return this.conversationListeners.add(e),()=>this.conversationListeners.delete(e)}publishConversation(e,t=!1){let n={type:`upsert`,conversation:e,revision:++this.conversationRevision,...t?{activity:!0}:{}};this.conversationsCache.update(r=>{let i=r.pagination.page===1,a=r.conversations.some(t=>t.conversationId===e.conversationId),o=pc(r.conversations,n,i&&t),s=i&&o.length>r.pagination.limit?o.slice(0,r.pagination.limit):o;if(!i||!t||a||r.pagination.hasNext)return s===r.conversations?r:{...r,conversations:s};let c=Math.max(r.pagination.total,r.conversations.length)+1,l=Math.ceil(c/r.pagination.limit);return{...r,conversations:s,pagination:{...r.pagination,total:c,totalPages:l,hasNext:r.pagination.page<l}}});for(let e of this.conversationListeners)e(n)}localeCacheKey(e){return`${this.locale??``}|${JSON.stringify(e,Object.keys(e).toSorted())}`}peekConversations(e={}){return this.conversationsCache.peek(this.localeCacheKey(e))}listConversations(e={},t=!1){if((e.page??1)>1)return this.fetchConversations(e);let n=this.localeCacheKey(e),r=this.conversationRevision;t&&this.conversationsCache.delete(n);let i=this.conversationsCache.getOrFetch(n,()=>this.fetchConversations(e));return t?i.then(e=>{let t={type:`snapshot`,result:e,requestedRevision:r};for(let e of this.conversationListeners)e(t);return e}):i}async fetchConversations(e){let t=new URL(this.url(rs.listConversations));return e.visitorId&&t.searchParams.set(`visitorId`,e.visitorId),e.page&&t.searchParams.set(`page`,String(e.page)),e.limit&&t.searchParams.set(`limit`,String(e.limit)),e.ids?.length&&t.searchParams.set(`ids`,e.ids.join(`,`)),this.getJson(t.toString(),`listConversations`)}async loadConversation(e,{ids:t=[],beforeId:n,beforeCreatedAt:r}={}){let i=new URL(this.url(rs.listMessages));i.searchParams.set(`conversationId`,e),i.searchParams.set(`limit`,`50`),t.length>0&&i.searchParams.set(`ids`,t.join(`,`)),n&&i.searchParams.set(`beforeId`,n),r&&i.searchParams.set(`beforeCreatedAt`,r);let a=await this.getJson(i.toString(),`loadConversation`);return{...a,messages:a.messages.toReversed()}}async markRead(e,t){if(!this.visitorId||!e)return;let n={type:`read`,conversationId:e,...t===void 0?{}:{lastMessageAt:t},revision:++this.conversationRevision};this.conversationsCache.update(e=>{let t=pc(e.conversations,n);return t===e.conversations?e:{...e,conversations:t}});for(let e of this.conversationListeners)e(n);try{await this.postJson(rs.markRead,{conversationId:e},`markRead`,!0)}catch(e){J.debug(`markRead failed (non-fatal)`,{err:e})}}async requestOperator(){if(this.visitorId&&this.conversationId)try{return(await this.postJson(rs.requestOperator,{},`requestOperator`)).controlState}catch(e){J.debug(`requestOperator failed (non-fatal)`,{err:e});return}}async cancelOperatorRequest(){if(this.visitorId&&this.conversationId)try{return(await this.postJson(rs.cancelOperatorRequest,{},`cancelOperatorRequest`)).controlState}catch(e){J.debug(`cancelOperatorRequest failed (non-fatal)`,{err:e});return}}listContent(e={}){return this.contentCache.getOrFetch(this.localeCacheKey(e),()=>this.fetchContent(e))}async fetchContent(e){let t=new URL(this.dataUrl(rs.content));for(let[n,r]of Object.entries(e))r!==void 0&&t.searchParams.set(n,Array.isArray(r)?r.join(`,`):String(r));let n=await this.getJson(t.toString(),`listContent`),r=n.items?.map(e=>xt(e,this.locale))??[];return{...n,items:r}}async setContentVote(e){try{await this.postJson(this.dataUrl(rs.contentVoteSet),e,`setContentVote`)}catch{}}listContentCollections(e){return this.contentCollectionsCache.getOrFetch(this.localeCacheKey({ids:e}),()=>this.fetchContentCollections(e))}async fetchContentCollections(e){let t=new URL(this.dataUrl(rs.contentCollections));return e.length&&t.searchParams.set(`ids`,e.join(`,`)),{items:(await this.getJson(t.toString(),`listContentCollections`)).items?.map(e=>St(e,this.locale))??[]}}async bootstrap(e){let t=new URL(this.dataUrl(rs.bootstrap));e&&t.searchParams.set(`conversationId`,e);let n=await this.getJson(t.toString(),`bootstrap`);return{forms:n.forms??[],formSubmissions:n.formSubmissions??[]}}async saveUserPrefs(e){return this.postJson(rs.updateSettings,{userPrefs:e},`saveUserPrefs`)}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??rs.submitForm}async submitForm(e){J.debug(`submitForm →`,{formId:e.formId,trigger:e.trigger,fields:Object.keys(e.values).length});try{await this.postJson(this.dataUrl(this.submitFormPath),e,`submitForm`)}catch(e){J.debug(`submitForm failed (non-fatal)`,{err:e})}}async submitFeedback(e){J.debug(`submitFeedback →`,{messageId:e.messageId,value:e.value});try{await this.postJson(rs.messageFeedback,{messageId:e.messageId,set:{feedback:e.value}},`submitFeedback`)}catch(e){J.debug(`submitFeedback failed (non-fatal)`,{err:e})}}async sendTurn(e,t={}){J.debug(`message →`,{conversationId:e.conversationId,visitorId:e.visitorId,messageCount:e.messages.length});let n=JSON.stringify({...this.withEnvelope(e),[is]:tc(this.userContext,this.pageContext,this.opts.recentHostEvents)}),r=t.keepalive===!0&&new Blob([n]).size<6e4;try{return await this.runWithAbort(async e=>{let t=await this.withFreshUserToken(()=>this.fetchImpl(this.url(rs.streamMessage),{method:`POST`,credentials:`omit`,headers:{accept:`application/json`,"content-type":`application/json`,...this.headersFor(this.url(rs.streamMessage))},body:n,keepalive:r,signal:e}));if(t.status!==202)throw new nc(`sendTurn failed: expected 202, received ${t.status}`,`server`,t.status);let i;try{i=await t.json()}catch(n){throw e?.aborted?n:new nc(`sendTurn failed: invalid acknowledgement`,`server`,t.status,n)}if(!xc(i))throw new nc(`sendTurn failed: invalid acknowledgement`,`server`,t.status);return i},void 0,3e4)}catch(e){throw e instanceof nc?e:new nc(`sendTurn failed: network error`,`network`,void 0,e)}}cancelTurn(e,t){this.visitorId&&e&&t&&(J.debug(`cancel stream`,{conversationId:e,runId:t,visitorId:this.visitorId}),this.fetchImpl(this.url(rs.cancelStream),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.headersFor(this.url(rs.cancelStream))},body:JSON.stringify(this.withEnvelope({conversationId:e,runId:t})),keepalive:!0}).catch(e=>J.debug(`cancel POST failed (non-fatal)`,{err:e})))}async connectResumeStream(e){let t=new AbortController;function n(){return t.abort(e.signal.reason)}e.signal.aborted?n():e.signal.addEventListener(`abort`,n,{once:!0});let r=setTimeout(()=>t.abort(),1e4);function i(){clearTimeout(r),e.signal.removeEventListener(`abort`,n)}let a;try{this.userTokenRequest&&await this.userTokenRequest,a=await this.fetchImpl(this.resumeUrl(),{method:`GET`,credentials:`omit`,headers:{accept:`text/event-stream`,...this.headersFor(this.resumeUrl())},signal:t.signal})}catch(t){return i(),e.signal.aborted||J.debug(`resume-stream fetch failed — reconnecting`,{err:t}),`held`}if(!a.ok)return i(),a.status===401&&typeof this.userTokenSource==`function`?(await this.fetchUserToken(),`held`):a.status===409||mc.has(a.status)?(J.debug(`resume-stream → transient response; reconnecting`,{status:a.status}),`held`):(J.debug(`resume-stream → endpoint unavailable`,{status:a.status}),`unavailable`);if(!a.body)return i(),J.debug(`resume-stream → bodyless response; stopping`,{status:a.status}),`unavailable`;if(!(a.headers.get(`content-type`)??``).includes(`text/event-stream`))return i(),J.debug(`resume-stream → non-SSE response; stopping`),`unavailable`;let o=!1;try{for await(let{chunk:n}of ic(a,t.signal,t=>{o||t!==`connected`||(o=!0,clearTimeout(r),e.onConnected())})){if(e.signal.aborted)return`held`;e.onChunk(n)}}catch(t){if(e.signal.aborted)return`held`;J.debug(`resume-stream segment dropped — reconnecting`,{err:t})}finally{i()}return`held`}resumeUrl(){return this.withEnvelopeQuery(rs.streamResume)}async postJson(e,t,n,r=!1){let i=await this.fetchWithRetry(()=>[this.url(e),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.headersFor(this.url(e))},body:JSON.stringify(this.withEnvelope(t)),...r?{keepalive:!0}:{}}],n);return this.assertOk(i,n)}async postForm(e,t,n,r,i){return this.runWithAbort(async r=>{let i=await this.withFreshUserToken(()=>this.fetchImpl(this.url(e),{method:`POST`,credentials:`omit`,headers:this.headersFor(this.url(e)),body:this.appendEnvelope(t),signal:r}));return this.assertOk(i,n)},r,i)}async runWithAbort(e,t,n){if(!t&&n===void 0)return e();let r=new AbortController;function i(){return r.abort(t?.reason)}t?.aborted?i():t?.addEventListener(`abort`,i,{once:!0});let a=n===void 0?void 0:setTimeout(()=>r.abort(),n);try{return await e(r.signal)}finally{a!==void 0&&clearTimeout(a),t?.removeEventListener(`abort`,i)}}async getJson(e,t){let n=await this.fetchWithRetry(()=>[this.withEnvelopeQuery(e),{method:`GET`,credentials:`omit`,headers:{accept:`application/json`,...this.headersFor(this.url(e))}}],t);return this.assertOk(n,t)}async fetchWithRetry(e,t){for(let n=0;;n++){let r;try{r=await this.withFreshUserToken(()=>this.fetchImpl(...e()))}catch(e){if(n>=3)throw new nc(`${t} failed: network error`,`network`,void 0,e);J.debug(`request network error — retrying`,{label:t,attempt:n}),await ue(hc(n));continue}if(r.ok||!mc.has(r.status)||n>=3)return r;let i=_c(r.headers)??hc(n);J.debug(`request retryable status — retrying`,{label:t,status:r.status,attempt:n,wait:i}),await ue(i)}}async assertOk(e,t){if(!e.ok)throw new nc(`${t} failed: ${e.status}`,`server`,e.status);return await e.json()}fetchUserToken(){let e=this.userTokenSource;if(typeof e!=`function`)return Promise.resolve();let t=Promise.resolve().then(e).then(t=>{this.userTokenSource===e&&(this.userToken=t||void 0)},e=>{J.warn(`userToken function failed; continuing as an anonymous visitor`,{err:e})});return this.userTokenRequest=t,t}headersFor(e){let t=!/^https?:\/\//i.test(e)||e.startsWith(`${this.opts.agentApiBaseUrl}/`);return{...this.opts.auth.headers(),...t&&this.userToken?{"x-user-token":this.userToken}:{}}}async withFreshUserToken(e){let t=await e();return t.status!==401||!this.userTokenSource?t:typeof this.userTokenSource==`function`?(await this.fetchUserToken(),e()):(J.warn(`userToken rejected as invalid or expired; pass a function so the widget can fetch a fresh one`),t)}url(e){return/^https?:\/\//i.test(e)?e:`${this.opts.agentApiBaseUrl}${e}`}dataUrl(e){return/^https?:\/\//i.test(e)?e:`${this.opts.dataApiBaseUrl}${e}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function bc(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 xc(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`status`),n=Reflect.get(e,`conversationId`),r=Reflect.get(e,`runId`);return t===`accepted`&&typeof n==`string`&&n.length>0&&(r===void 0||typeof r==`string`&&r.length>0)}function Sc(e,t,n){switch(e){case`clear`:case`sound`:case`history`:case`language`:case`theme`:case`textSize`:return!0;case`popOut`:return t!==`standalone`&&t!==`page`;case`expand`:return t===`floating`;case`fullscreen`:return t!==`standalone`;case`close`:return t===`standalone`||t===`page`?!1:t!==`inline`||n===`fullscreen`}}function Cc(e,t,n){return Sc(`close`,e,t)?n.includes(`close`):!1}function wc(e,t){return e===`inline`&&t===`fullscreen`?`exit-fullscreen`:`close`}function Tc(e,t,n,r){let i={role:n,text:r};e.emit(`message`,i),t.onMessage?.(i)}function Ec(e){let t=R(e);t.current=e;let n=R(null);return n.current??(n.current=Dc(t)),n.current}function Dc(e){let t=V(null),n=/* @__PURE__ */ new Set;function r(t){return`${e.current.conversationId()??``}:${t}`}function i(t){return t.frequency===`always`?!1:t.frequency===`conversation`?n.has(r(t.id)):t.id in e.current.persistence.loadFormsDone()}function a(n,r){if(t.value)return;let a=e.current;if(n===`manual`){let e=a.forms.list.find(e=>e.id===r);e&&(t.value={form:e,trigger:`manual`})}else for(let e of a.forms.byTrigger[n]??[]){let r=e.triggers.find(e=>e.kind===n);if(r&&Oc(r,a)&&!i(e)&&kc(e,a)){t.value={form:e,trigger:n};return}}}function o(i,a){let o=t.value;if(!o)return;t.value=null;let{form:s,trigger:c}=o;s.frequency===`conversation`?n.add(r(s.id)):s.frequency!==`always`&&e.current.persistence.saveFormDone(s.id),e.current.onComplete(s,c,i,a)}function s(){let n=t.value;if(!n)return;let r=e.current.forms.list.find(e=>e.id===n.form.id);r&&r!==n.form&&(t.value={form:r,trigger:n.trigger})}return{activeForm:t,fire:a,refresh:s,complete:e=>o(e,!1),skip:()=>o({},!0)}}function Oc(e,t){return e.kind===`after-messages`?t.messageCount()>=Number(e.param??0):e.kind!==`page-area`||t.pageArea()===e.param}function kc(e,t){let n=e.when;if(!n)return!0;if(n.missingContext?.length){let e=t.userContext()??{};if(n.missingContext.some(t=>e[t]!==void 0&&e[t]!==``))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 Ac(e){return Object.fromEntries(e.map(e=>[e,[]]))}function jc(e,t,n){return e.includes(t)?t:e.includes(n)?n:e[0]??``}function Mc(e,t,n){let r=[...new Set(t)],i=V({activeTab:jc(r,e,``),stacks:Ac(r)});return{sig:i,reconcile(e,t){let a=[...new Set(e)],o=i.value,s=jc(a,o.activeTab,t),c=Object.fromEntries(a.map(e=>[e,o.stacks[e]??[]])),l=s===o.activeTab&&a.length===Object.keys(o.stacks).length&&a.every(e=>o.stacks[e]===c[e]);r=a,!l&&(i.value={activeTab:s,stacks:c},s!==o.activeTab&&s&&n?.(s))},switchTab(e){e in i.value.stacks&&i.value.activeTab!==e&&(i.value={...i.value,activeTab:e},n?.(e))},open(e,t){let r=i.value;e in r.stacks&&(i.value={activeTab:e,stacks:{...r.stacks,[e]:t?[t]:[]}},r.activeTab!==e&&n?.(e))},push(e){let t=i.value,n=t.stacks[t.activeTab]??[];i.value={...t,stacks:{...t.stacks,[t.activeTab]:[...n,e]}}},pop(){let e=i.value,t=e.stacks[e.activeTab]??[];t.length!==0&&(i.value={...e,stacks:{...e.stacks,[e.activeTab]:t.slice(0,-1)}})},reset(e){i.value={activeTab:jc(r,e,``),stacks:Ac(r)}}}}function Nc(e){return e.stacks[e.activeTab]??[]}function Pc(e){return Nc(e).at(-1)}function Fc(e){return Nc(e).length===0}function Ic(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`}function Lc(e,t,n){if(e===`standalone`||e===`page`)return`fullscreen`;let r=t.initialSize;return r===`expanded`||r===`fullscreen`||r===`normal`?r:n>0&&n<640?`fullscreen`:n>=(t.autoSizeBreakpoint??900)?`expanded`:`normal`}function Rc(e,t,n,r=null){return{panelOpen:e.mode===`inline`||e.mode===`standalone`||e.mode===`page`||(n??!e.startMinimized),panelSize:e.mode!==`standalone`&&e.mode!==`page`&&e.mode!==`inline`&&r?r:Lc(e.mode,e.size,t)}}function zc(){return typeof window>`u`?0:window.innerWidth}const Y={fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`},Bc=`${u.cssPrefix}-icon-dir`;function Vc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M21 12a8 8 0 0 1-12 6.93L3 21l1.65-5.16A8 8 0 1 1 21 12Z`})})}function Hc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M18 6 6 18M6 6l12 12`})})}function Uc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M12 5v14M5 12h14`})})}function Wc(){return/* @__PURE__ */ U(`svg`,{...Y,class:Bc,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`m22 2-7 20-4-9-9-4Z`}),/* @__PURE__ */ U(`path`,{d:`M22 2 11 13`})]})}function Gc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M12 19V5M5 12l7-7 7 7`})})}function Kc(){return/* @__PURE__ */ U(`svg`,{...Y,class:Bc,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 20V4l18 8-18 8Z`})})}function qc(){return/* @__PURE__ */ U(`svg`,{...Y,class:Bc,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`m9 18 6-6-6-6`})})}function Jc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}function Yc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`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`})})}function Xc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`rect`,{x:`9`,y:`2`,width:`6`,height:`12`,rx:`3`}),/* @__PURE__ */ U(`path`,{d:`M5 10a7 7 0 0 0 14 0M12 19v3`})]})}function Zc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5`})})}function Qc(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5`})})}function $c(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z`})})}function el(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7`})})}function tl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M14 3h7v7M21 3l-9 9`}),/* @__PURE__ */ U(`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`})]})}function nl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,viewBox:`0 0 10 10`,children:/* @__PURE__ */ U(`path`,{d:`M9 1L1 9M9 5L5 9M9 9H9`,strokeWidth:`1.5`})})}function rl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`5`,r:`1.5`,fill:`currentColor`,stroke:`none`}),/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`1.5`,fill:`currentColor`,stroke:`none`}),/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`19`,r:`1.5`,fill:`currentColor`,stroke:`none`})]})}function il(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M11 5 6 9H2v6h4l5 4zM15 9a5 5 0 0 1 0 6M18 7a9 9 0 0 1 0 10`})})}function al(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6`})})}function ol(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M3 18 8 6l5 12M4.7 14h6.6`}),/* @__PURE__ */ U(`path`,{d:`M14.5 18l3.2-7 3.2 7M15.6 15.8h4.2`})]})}function sl(){return/* @__PURE__ */ U(`svg`,{...Y,class:Bc,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`m5 6 6 6-6 6M13 6l6 6-6 6`})})}function cl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M20 6 9 17l-5-5`})})}function ll(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M3 3v6h6`}),/* @__PURE__ */ U(`path`,{d:`M3.05 13A9 9 0 1 0 6 5.3L3 9`}),/* @__PURE__ */ U(`path`,{d:`M12 7v5l3 2`})]})}function ul(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ U(`path`,{d:`M2 12h20`}),/* @__PURE__ */ U(`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`})]})}function dl(){return/* @__PURE__ */ U(`svg`,{...Y,class:Bc,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M19 12H5M12 19l-7-7 7-7`})})}function fl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M12 20h9`}),/* @__PURE__ */ U(`path`,{d:`M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z`})]})}function pl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`m6 9 6 6 6-6`})})}function ml(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z`}),/* @__PURE__ */ U(`path`,{d:`M14 2v6h6`})]})}function hl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`m12 3-1.5 4.5L6 9l4.5 1.5L12 15l1.5-4.5L18 9l-4.5-1.5Z`}),/* @__PURE__ */ U(`path`,{d:`M19 15v4M17 17h4M5 3v2M4 4h2`})]})}function gl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2Z`})})}function _l(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ U(`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`}),/* @__PURE__ */ U(`path`,{d:`M12 17h.01`})]})}function vl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`m15 4 3 3-9 9-3-3z`}),/* @__PURE__ */ U(`path`,{d:`M18 2v2M20 4h2M3 20l3-3M3 16h2M5 14v2`})]})}function yl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`rect`,{x:`4`,y:`8`,width:`16`,height:`12`,rx:`2`}),/* @__PURE__ */ U(`path`,{d:`M12 8V4`}),/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`3`,r:`1`}),/* @__PURE__ */ U(`path`,{d:`M2 14h2M20 14h2M9 13h.01M15 13h.01M9.5 17h5`})]})}function bl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M4 14v-2a8 8 0 0 1 16 0v2`}),/* @__PURE__ */ U(`rect`,{x:`2`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),/* @__PURE__ */ U(`rect`,{x:`18`,y:`14`,width:`4`,height:`6`,rx:`1.5`}),/* @__PURE__ */ U(`path`,{d:`M20 20v1a3 3 0 0 1-3 3h-5`})]})}function xl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`4`}),/* @__PURE__ */ U(`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`})]})}function Sl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`11`,cy:`11`,r:`7`}),/* @__PURE__ */ U(`path`,{d:`m21 21-4.3-4.3`})]})}function Cl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]})}function wl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M3 9.5 12 3l9 6.5`}),/* @__PURE__ */ U(`path`,{d:`M5 9v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9`})]})}function Tl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`m3 11 15-5v12L3 13z`}),/* @__PURE__ */ U(`path`,{d:`M3 11v2a2 2 0 0 0 2 2h1V9H5a2 2 0 0 0-2 2z`}),/* @__PURE__ */ U(`path`,{d:`M7 15v3a2 2 0 0 0 4 0v-2`}),/* @__PURE__ */ U(`path`,{d:`M21 10a3 3 0 0 1 0 4`})]})}function El(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`}),/* @__PURE__ */ U(`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`})]})}function Dl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`4`}),/* @__PURE__ */ U(`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`})]})}function Ol(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`})})}function kl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`M12 3v18`}),/* @__PURE__ */ U(`path`,{d:`M12 3a9 9 0 0 1 0 18z`,fill:`currentColor`,stroke:`none`})]})}function Al(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`10.5`,cy:`10.5`,r:`6.5`}),/* @__PURE__ */ U(`path`,{d:`M8 11a2.5 2.5 0 0 0 5 0`}),/* @__PURE__ */ U(`path`,{d:`m20 20-4.4-4.4`})]})}function jl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`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`}),/* @__PURE__ */ U(`path`,{d:`M18.5 4v3M20 5.5h-3M5.5 16v2.5M6.75 17.25h-2.5`})]})}function Ml(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M4 18h16`}),/* @__PURE__ */ U(`path`,{d:`M5 18a7 7 0 0 1 14 0`}),/* @__PURE__ */ U(`path`,{d:`M12 8V6`}),/* @__PURE__ */ U(`path`,{d:`M10 6h4`})]})}function Nl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M7 11V6.5a1.5 1.5 0 0 1 3 0V10`}),/* @__PURE__ */ U(`path`,{d:`M10 10V5.5a1.5 1.5 0 0 1 3 0V10`}),/* @__PURE__ */ U(`path`,{d:`M13 10V6.5a1.5 1.5 0 0 1 3 0V12`}),/* @__PURE__ */ U(`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`})]})}function Pl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`rect`,{x:`9`,y:`9`,width:`11`,height:`11`,rx:`2`}),/* @__PURE__ */ U(`path`,{d:`M5 15a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2`})]})}function Fl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M7 10v11H4a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1z`}),/* @__PURE__ */ U(`path`,{d:`M7 10l4-7a2.5 2.5 0 0 1 2.5 2.5V8h5a2 2 0 0 1 2 2.3l-1.2 8A2 2 0 0 1 17.3 20H7`})]})}function Il(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`path`,{d:`M17 14V3h3a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1z`}),/* @__PURE__ */ U(`path`,{d:`M17 14l-4 7a2.5 2.5 0 0 1-2.5-2.5V16h-5a2 2 0 0 1-2-2.3l1.2-8A2 2 0 0 1 6.7 4H17`})]})}function Ll(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`3.5`}),/* @__PURE__ */ U(`path`,{d:`M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M19.1 4.9l-2.1 2.1M7 17l-2.1 2.1`})]})}function Rl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`M12 7v5l3 2`})]})}function zl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`m8.5 12 2.5 2.5 4.5-5`})]})}function Bl(){return/* @__PURE__ */ U(`svg`,{...Y,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`m15 9-6 6M9 9l6 6`})]})}const Vl={chat:Vc,message:gl,bubbles:El,spark:hl,wand:vl,bot:yl,help:_l,lifebuoy:xl,headset:bl,search:Al,sparkles:jl,concierge:Ml,wave:Nl},X=u.cssPrefix,Z={launcher:`${X}-launcher`,callout:`${X}-callout`,calloutDismiss:`${X}-callout-dismiss`,panel:`${X}-panel`,panelHeader:`${X}-panel-header`,resizeGrip:`${X}-resize-grip`,scrollToBottom:`${X}-scroll-to-bottom`,loadPreviousMessages:`${X}-load-previous-messages`,actionHistory:`${X}-action-history`,actionClose:`${X}-action-close`,langSegment:`${X}-lang-segment`,composer:`${X}-composer`,composerInput:`${X}-composer-input`,composerSend:`${X}-composer-send`,composerStop:`${X}-composer-stop`,compactionStatus:`${X}-compaction-status`,messageQueue:`${X}-message-queue`,queuedMessage:`${X}-queued-message`,queuedMessageRemove:`${X}-queued-message-remove`,composerAttach:`${X}-composer-attach`,composerFileInput:`${X}-composer-file-input`,composerVoice:`${X}-composer-voice`,attachmentChip:`${X}-attachment-chip`,attachmentRemove:`${X}-attachment-remove`,suggestion:`${X}-suggestion`,messageBubble:`${X}-message`,messageRetry:`${X}-message-retry`,messageFeedback:`${X}-message-feedback`,feedbackUp:`${X}-feedback-up`,feedbackDown:`${X}-feedback-down`,messageCopy:`${X}-message-copy`,historyPane:`${X}-history-pane`,historyBack:`${X}-history-back`,historyItem:`${X}-history-item`,historyLoadMore:`${X}-history-load-more`,sidebar:`${X}-sidebar`,sidebarToggle:`${X}-sidebar-toggle`,sidebarNewConversation:`${X}-sidebar-new-conversation`,sidebarItem:`${X}-sidebar-item`,messengerHome:`${X}-messenger-home`,modulesEmpty:`${X}-modules-empty`,tab:`${X}-tab`,tabBadge:`${X}-tab-badge`,homeView:`${X}-home-view`,homeGreeting:`${X}-home-greeting`,homeBrand:`${X}-home-brand`,backHeader:`${X}-back-header`,contentView:`${X}-content-view`,contentScroll:`${X}-content-scroll`,homeSearch:`${X}-home-search`,helpSearch:`${X}-help-search`,homeRecent:`${X}-home-recent`,homeAsk:`${X}-home-ask`,homeWhatsNew:`${X}-home-whats-new`,homeContentRow:`${X}-home-content-row`,helpArticle:`${X}-help-article`,newsItem:`${X}-news-item`,newsMore:`${X}-news-more`,formGate:`${X}-form-gate`,formDone:`${X}-form-done`,formDoneToggle:`${X}-form-done-toggle`,formAnswers:`${X}-form-answers`,formFill:`${X}-form-fill`,formSubmit:`${X}-form-submit`,formSkip:`${X}-form-skip`,formField:`${X}-form-field`,toolAskQuestions:`${X}-tool-ask-questions`,toolInputSubmit:`${X}-tool-input-submit`,toolInputSkip:`${X}-tool-input-skip`,toolApproval:`${X}-tool-approval`,toolApprove:`${X}-tool-approve`,toolReject:`${X}-tool-reject`,toolEdit:`${X}-tool-edit`,toolDecision:`${X}-tool-decision`,typingDots:`${X}-typing-dots`,reasoning:`${X}-reasoning`,toolAskSummary:`${X}-ask-questions-summary`,toolAskOptions:`${X}-ask-questions-options-toggle`,toolCall:`${X}-tool-call`,source:`${X}-source`,operatorRequest:`${X}-operator-request`,operatorBanner:`${X}-operator-banner`,cancelOperatorRequest:`${X}-cancel-operator-request`};function Hl(e,t){return`${e}-${t}`}const Ul=u.cssPrefix;function Wl({onToggle:e,launcher:t,strings:n,leaving:r,edgeTab:i}){let a=t.variant!==`circle`&&!!t.label;return/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ul}-fab`,part:`launcher`,"data-variant":t.variant,"data-size":t.size,"data-edge-tab":i?`true`:void 0,"data-leaving":r?`true`:void 0,"data-testid":Z.launcher,onClick:e,"aria-label":n.launcherOpen,children:[Gl(t.icon),a?/* @__PURE__ */ U(`span`,{class:`${Ul}-fab-label`,children:At(n,t.label??``)}):null]})}function Gl(e){let t=Vl[e];return t?/* @__PURE__ */ U(t,{}):/* @__PURE__ */ U(Kl,{source:e})}function Kl({source:e}){return/* @__PURE__ */ U(`span`,{ref:t=>{t&&ql(t,e)},"aria-hidden":`true`})}function ql(e,t){if(e.dataset.svgMounted!==t)try{let n=new DOMParser().parseFromString(t,`image/svg+xml`).documentElement;n.tagName.toLowerCase()===`svg`&&(e.replaceChildren(document.importNode(n,!0)),e.dataset.svgMounted=t)}catch{}}function Jl({callout:e,launcherPosition:t,strings:n,closeLabel:r,onDismiss:i}){let[a,o]=I(!1);return L(()=>{let t=setTimeout(()=>o(!0),e.delayMs);return()=>clearTimeout(t)},[e.delayMs]),L(()=>{if(!a||e.autoDismissMs<=0)return;let t=setTimeout(i,e.autoDismissMs);return()=>clearTimeout(t)},[a,e.autoDismissMs,i]),a?/* @__PURE__ */ U(`div`,{class:`${Ul}-callout`,role:`status`,"data-shape":e.shape,"data-position":Yl(e.position,t),"data-animated":e.animated?`true`:void 0,"data-testid":Z.callout,children:[/* @__PURE__ */ U(`span`,{children:At(n,e.text)}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ul}-callout-close`,onClick:i,"aria-label":r,title:r,"data-testid":Z.calloutDismiss,children:/* @__PURE__ */ U(Hc,{})})]}):null}function Yl(e,t){let n=t.endsWith(`-right`),r=t.startsWith(`bottom-`);return e===`vertical`?r?`top`:`bottom`:n?`left`:`right`}function Xl(e){function t(t){if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(`a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),[tabindex]:not([tabindex="-1"])`)].filter(e=>e.offsetParent!==null||e===document.activeElement);if(n.length===0){t.preventDefault();return}let r=n[0],i=n[n.length-1];if(!r||!i)return;let a=e.getRootNode().activeElement;t.shiftKey&&a===r?(t.preventDefault(),i.focus()):!t.shiftKey&&a===i&&(t.preventDefault(),r.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)}const Zl=u.cssPrefix;function Ql({title:e,actions:t}){return/* @__PURE__ */ U(`header`,{class:`${Zl}-back-header`,part:`header`,"data-variant":`title`,children:[/* @__PURE__ */ U(`span`,{class:`${Zl}-back-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ U(`h1`,{class:`${Zl}-back-title`,children:e}),t??/* @__PURE__ */ U(`span`,{class:`${Zl}-back-spacer`,"aria-hidden":`true`})]})}function $l({title:e,backLabel:t,onBack:n,actions:r,testid:i}){return/* @__PURE__ */ U(`header`,{class:`${Zl}-back-header`,part:`header`,"data-testid":i,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${Zl}-icon-btn`,onClick:n,"aria-label":t,title:t,children:/* @__PURE__ */ U(dl,{})}),/* @__PURE__ */ U(`h1`,{class:`${Zl}-back-title`,children:e}),r??/* @__PURE__ */ U(`span`,{class:`${Zl}-back-spacer`,"aria-hidden":`true`})]})}function eu({textSig:e,doneSig:t,generativeUi:n=!1,strings:r=wt}){let i=R(null);return kr(()=>{let a=i.current;if(!a)return;a.classList.add(`${u.cssPrefix}-md`),a.replaceChildren();let o=n?Yo(a,{cssPrefix:u.cssPrefix,strings:r}):void 0,s=Zi(o??ua(a)),c=0,l=si(()=>{let i=e.value,l=t.value;i.length<c&&(o?.dispose(),a.replaceChildren(),o=n?Yo(a,{cssPrefix:u.cssPrefix,strings:r}):void 0,s=Zi(o??ua(a)),c=0);let d=i.slice(c);d&&la(s,d),c=i.length,l&&(Qi(s),o?.finish())}),d=new MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes){if(!(e instanceof HTMLElement))continue;let t=e.matches?.(`a`)?[e]:[...e.querySelectorAll?.(`a`)??[]];for(let e of t)nu(e)}});d.observe(a,{childList:!0,subtree:!0});for(let e of a.querySelectorAll(`a`))nu(e);function f(e){let t=e.target?.closest?.(`a`);if(!t||!(t instanceof HTMLAnchorElement))return;let n=t.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`))}return a.addEventListener(`click`,f),()=>{l(),o?.dispose(),d.disconnect(),a.removeEventListener(`click`,f)}},[e,t,n,r]),/* @__PURE__ */ U(`div`,{ref:i})}function tu({text:e}){return/* @__PURE__ */ U(eu,{textSig:z(()=>V(e),[e]),doneSig:z(()=>V(!0),[])})}function nu(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(` `)}const ru=/* @__PURE__ */ new Set([11,12,13,14,15,16,17,18,19,31]);function iu(e){let t=``,n=[],r=Zi({data:void 0,add_token:(e,r)=>{n.push(r),ru.has(r)||(t+=` `)},end_token:()=>{let e=n.pop();e!==void 0&&!ru.has(e)&&(t+=` `)},add_text:(e,n)=>void(t+=n),set_attr:()=>void 0});return la(r,e),Qi(r),t.replace(/\s+/g,` `).trim()}const au=u.cssPrefix;function ou({tone:e=`info`,message:t,onRetry:n,strings:r}){return/* @__PURE__ */ U(`div`,{class:`${au}-module-empty`,role:e===`error`?`alert`:`status`,"aria-live":`polite`,children:[/* @__PURE__ */ U(`span`,{children:t}),n?/* @__PURE__ */ U(`button`,{type:`button`,class:`${au}-module-retry`,onClick:n,children:r.errorRetry}):null]})}const su=u.cssPrefix,cu=C.scope(`content`);function lu({id:e,title:t,transport:n,strings:r,bus:i,onBack:a,actions:o}){let[s,c]=I(null),[l,u]=I(!1),[d,f]=I(!1),[p,m]=I(0),[h,g]=I(null),_=B(()=>{f(!1),c(null),m(e=>e+1)},[]);L(()=>{let t=!1,r=n.listContentCollections([]).catch(()=>void 0);return Promise.all([n.listContent({ids:[e],limit:1}),r]).then(([n,r])=>{if(t)return;let a=n.items[0];a?(c(a),u(r?.items.find(e=>e.id===a.contentCollectionId)?.settings?.voteAccess===`portal`),i.emit(`contentOpen`,{contentId:e,contentCollectionId:a.contentCollectionId})):f(!0)}).catch(e=>{t||(cu.warn(`listContent (reader) failed`,{err:e}),f(!0))}),()=>{t=!0}},[n,e,p,i]),L(()=>{if(!s)return;let t=setTimeout(()=>i.emit(`contentRead`,{contentId:e}),5e3);return()=>clearTimeout(t)},[s,e,i]);let v=B(t=>{let n=(t.target?.closest?.(`a`))?.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&i.emit(`contentLinkClick`,{contentId:e})},[i,e]);function y(t){g(e),n.setContentVote({contentId:e,value:t})}function b(){return d?/* @__PURE__ */ U(ou,{tone:`error`,message:r.errorGeneric,onRetry:_,strings:r}):s===null?/* @__PURE__ */ U(ou,{message:r.contentLoading,strings:r}):/* @__PURE__ */ U(`article`,{class:`${su}-content`,"data-testid":Z.contentView,onClick:v,children:[s.image?/* @__PURE__ */ U(`img`,{class:`${su}-content-hero`,src:s.image,alt:``,loading:`lazy`}):null,s.description?/* @__PURE__ */ U(`p`,{class:`${su}-content-subtitle`,children:s.description}):null,/* @__PURE__ */ U(tu,{text:s.content??``}),l?/* @__PURE__ */ U(`div`,{class:`${su}-content-vote`,"aria-live":`polite`,children:h===e?r.feedbackThanks:/* @__PURE__ */ U(Ze,{children:[/* @__PURE__ */ U(`span`,{children:r.contentHelpful}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${su}-module-retry`,onClick:()=>y(1),children:r.confirmYes}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${su}-module-retry`,onClick:()=>y(0),children:r.confirmNo})]})}):null]})}return/* @__PURE__ */ U(`div`,{class:`${su}-module`,children:[/* @__PURE__ */ U($l,{title:s?.title||t||r.moduleBack,backLabel:r.moduleBack,onBack:a,actions:o,testid:Z.backHeader}),/* @__PURE__ */ U(`div`,{class:`${su}-module-scroll`,"data-testid":Z.contentScroll,children:b()})]})}function uu({itemCount:e,initialFocusIndex:t}){let[n,r]=I(!1),i=R(null),a=R(null),[o,s]=I(-1),c=B(()=>{r(!1),s(-1),i.current?.focus()},[]),l=B(()=>r(e=>!e),[]);return L(()=>{if(!n)return;function e(e){let t=a.current,n=i.current;if(!t||!n)return;let o=e.composedPath();o.includes(t)||o.includes(n)||(r(!1),s(-1))}return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)},[n]),L(()=>{if(!n||e===0)return;let r=t?.()??0;s(r<0||r>=e?0:r)},[n,e,t]),L(()=>{!n||o<0||(a.current?.querySelectorAll(`[role='menuitem']`))?.[o]?.focus()},[n,o]),{open:n,focusIndex:o,triggerRef:i,menuRef:a,toggle:l,close:c,onTriggerKey:B(e=>{(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(!0))},[]),onMenuKey:B(t=>{if(e!==0)switch(t.key){case`Escape`:t.preventDefault(),c();return;case`ArrowDown`:t.preventDefault(),s(t=>(t+1)%e);return;case`ArrowUp`:t.preventDefault(),s(t=>(t-1+e)%e);return;case`Home`:t.preventDefault(),s(0);return;case`End`:t.preventDefault(),s(e-1)}},[e,c])}}function du({items:e,triggerLabel:t}){let n=u.cssPrefix,r=uu({itemCount:e.length});function i(e){e.disabled||(e.onSelect?.(),e.keepOpen||r.close())}function a(e,t){return e.onSelectValue?.(t)}function o(e,t){let n=t.segments;if(!n?.length)return;let r=Math.max(0,n.findIndex(e=>e.value===t.value)),i=-1;if(e.key===`ArrowRight`||e.key===`Enter`||e.key===` `)i=(r+1)%n.length;else if(e.key===`ArrowLeft`)i=(r-1+n.length)%n.length;else return;e.preventDefault(),e.stopPropagation(),a(t,n[i].value)}return/* @__PURE__ */ U(`div`,{class:`${n}-menu-wrap`,children:[/* @__PURE__ */ U(`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:/* @__PURE__ */ U(rl,{})}),r.open?/* @__PURE__ */ U(`div`,{ref:r.menuRef,class:`${n}-menu`,role:`menu`,"aria-label":t,onKeyDown:r.onMenuKey,tabIndex:-1,children:e.map(e=>e.segments?/* @__PURE__ */ U(`div`,{role:`menuitem`,class:`${n}-menu-item ${n}-menu-item-segmented`,"aria-label":e.label,tabIndex:-1,onKeyDown:t=>o(t,e),children:[e.icon?/* @__PURE__ */ U(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,/* @__PURE__ */ U(`span`,{class:`${n}-menu-label`,children:e.label}),/* @__PURE__ */ U(`span`,{class:`${n}-segmented`,role:`group`,"aria-label":e.label,children:e.segments.map(t=>{let r=t.value===e.value;return/* @__PURE__ */ U(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,class:`${n}-segment`,"data-on":r?`true`:void 0,lang:t.lang,title:t.value,tabIndex:-1,"data-testid":`${Z.langSegment}-${t.value}`,onClick:()=>a(e,t.value),children:t.label},t.value)})})]},e.id):/* @__PURE__ */ U(`button`,{type:`button`,role:`menuitem`,class:`${n}-menu-item`,"aria-pressed":e.type===`switch`?e.on:void 0,disabled:e.disabled,onClick:()=>i(e),children:[e.icon?/* @__PURE__ */ U(`span`,{class:`${n}-menu-icon`,children:e.icon}):null,/* @__PURE__ */ U(`span`,{class:`${n}-menu-label`,children:e.label}),e.type===`switch`&&e.on?/* @__PURE__ */ U(`span`,{class:`${n}-menu-check`,"aria-hidden":`true`,children:/* @__PURE__ */ U(cl,{})}):null]},e.id))}):null]})}const fu=u.cssPrefix;function pu(e){let t=typeof matchMedia!=`function`||matchMedia(`(prefers-color-scheme: dark)`).matches;return e===`host`?Zn()===`dark`?`light`:`dark`:e===`auto`?t?`light`:`dark`:t?e===`light`?`dark`:`auto`:e===`dark`?`light`:`auto`}const mu={normal:`large`,large:`small`,small:`normal`};function hu(e){return U(e===`light`?Dl:e===`dark`?Ol:kl,{})}function gu(e){return(e.split(`-`)[0]??e).toUpperCase()}function _u(e,t){let n;try{n=new URL(e,window.location.href)}catch{return}if(n.protocol===`http:`||n.protocol===`https:`)return t.conversationId&&n.searchParams.set(`chat`,t.conversationId),n.searchParams.set(`widgetId`,t.widgetId),t.publicKey&&n.searchParams.set(`public_key`,t.publicKey),n.searchParams.set(`ai_agent_deployment_id`,t.aiAgentDeploymentId),n.href}function vu({panelProps:e,variant:t}){let{options:n,panelSize:r,feedback:i,onClose:a,onClear:o,onExpand:s,onFullscreen:c,onSoundToggle:l}=e,{onToggleHistory:u,onLocaleChange:d,onThemeChange:f,onTextSizeChange:p}=e,m=n.strings,h=n.mode,g=t===`chat`,_=vi(()=>i.mutedSig.value).value,v=new Set(n.actions);function y(e){return v.has(e)}let b=typeof matchMedia==`function`&&matchMedia(`(max-width: 640px)`).matches;function x(e){return!b&&Sc(e,h,r)}let S=n.themeMode,C={auto:m.themeAuto,light:m.themeLight,dark:m.themeDark,host:m.themeAuto},w=n.textSize,T={small:m.textSizeSmall,normal:m.textSizeNormal,large:m.textSizeLarge},E=[];if(g&&y(`clear`)&&E.push({id:`clear`,icon:/* @__PURE__ */ U(fl,{}),label:m.newConversation,onSelect:o}),y(`expand`)&&x(`expand`)){let e=r===`expanded`;E.push({id:`expand`,icon:U(e?Qc:Zc,{}),label:e?m.collapse:m.expand,type:`switch`,on:e,onSelect:s})}if(y(`fullscreen`)&&x(`fullscreen`)){let e=r===`fullscreen`;E.push({id:`fullscreen`,icon:U(e?el:$c,{}),label:e?m.exitFullscreen:m.fullscreen,type:`switch`,on:e,onSelect:c})}let D=n.popOutUrl,O=n.aiAgentDeploymentId;y(`popOut`)&&D&&O&&Sc(`popOut`,h,r)&&E.push({id:`popOut`,icon:/* @__PURE__ */ U(tl,{}),label:m.popOut,onSelect:()=>{let t=_u(D,{conversationId:e.conversationId,widgetId:n.widgetId,publicKey:n.publicKey,aiAgentDeploymentId:O});t&&window.open(t,`_blank`,`noopener,noreferrer`)}}),g&&y(`sound`)&&E.push({id:`sound`,icon:U(_?al:il,{}),label:_?m.soundOff:m.soundOn,type:`switch`,on:!_,onSelect:l}),y(`theme`)&&E.push({id:`theme`,icon:hu(S),label:`${m.theme}: ${C[S]}`,onSelect:()=>f(pu(S)),keepOpen:!0}),y(`textSize`)&&E.push({id:`textSize`,icon:/* @__PURE__ */ U(ol,{}),label:`${m.textSize}: ${T[w]}`,onSelect:()=>p(mu[w]),keepOpen:!0}),y(`language`)&&n.availableLocales.length>1&&E.push({id:`language`,icon:/* @__PURE__ */ U(ul,{}),label:m.language,segments:n.availableLocales.map(e=>({value:e,label:gu(e),lang:e})),value:n.locale,onSelectValue:d});let ee=!!a&&Cc(h,r,n.actions),k=g&&y(`history`);return/* @__PURE__ */ U(`div`,{class:`${fu}-header-actions`,children:[k?/* @__PURE__ */ U(`button`,{type:`button`,class:`${fu}-icon-btn`,onClick:u,"aria-label":m.history,title:m.history,"data-testid":Z.actionHistory,children:/* @__PURE__ */ U(ll,{})}):null,E.length>0?/* @__PURE__ */ U(du,{items:E,triggerLabel:m.moreActions}):null,ee?/* @__PURE__ */ U(`button`,{type:`button`,class:`${fu}-icon-btn`,onClick:a,"aria-label":m.close,title:m.close,"data-testid":Z.actionClose,children:/* @__PURE__ */ U(Hc,{})}):null]})}const yu={Icon:El};function bu(e,t){return e instanceof nc&&e.status===429?t.errorRateLimited:t.errorGeneric}const xu=u.cssPrefix;function Su({placeholder:e,onActivate:t}){return/* @__PURE__ */ U(`button`,{type:`button`,class:`${xu}-home-search`,onClick:t,"data-testid":Z.homeSearch,children:[/* @__PURE__ */ U(`span`,{class:`${xu}-home-search-text`,children:e}),/* @__PURE__ */ U(`span`,{class:`${xu}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Sl,{})})]})}function Cu({placeholder:e,value:t,onInput:n}){return/* @__PURE__ */ U(`div`,{class:`${xu}-home-search`,"data-input":`true`,children:[/* @__PURE__ */ U(`input`,{type:`search`,class:`${xu}-home-search-input`,placeholder:e,value:t,maxLength:200,onInput:e=>n(e.currentTarget.value),"data-testid":Z.helpSearch}),/* @__PURE__ */ U(`span`,{class:`${xu}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Sl,{})})]})}const wu=u.cssPrefix;function Tu({title:e,subtitle:t,onClick:n,testid:r}){return/* @__PURE__ */ U(`button`,{type:`button`,class:`${wu}-list-row`,onClick:n,"data-testid":r,children:[/* @__PURE__ */ U(`span`,{class:`${wu}-list-row-body`,children:[/* @__PURE__ */ U(`span`,{class:`${wu}-list-row-title`,children:e}),t?/* @__PURE__ */ U(`span`,{class:`${wu}-list-row-sub`,children:t}):null]}),/* @__PURE__ */ U(`span`,{class:`${wu}-list-row-chevron`,"aria-hidden":`true`,children:/* @__PURE__ */ U(qc,{})})]})}const Eu=u.cssPrefix,Du=C.scope(`help`);function Ou(e,t,n){let r=new Map(n.map(e=>[e.id,e.title]));return t.map(t=>({id:t,title:r.get(t),rows:e.filter(e=>e.contentCollectionId===t)})).filter(e=>e.rows.length>0)}function ku({transport:e,strings:t,bus:n},r,i){let[a,o]=I(),s=R(void 0);function c(a){if(!r?.length)return;let c={};s.current=c,o(e=>({search:i,items:[],collections:[],...e,pagination:a>1?e?.pagination:void 0,loading:!0,error:void 0})),Promise.all([e.listContent({contentCollectionIds:r,sortBy:`order`,page:a,limit:20,search:i}),a>1?void 0:e.listContentCollections(r)]).then(([e,t])=>{s.current===c&&(o(n=>({search:i,items:[...a>1?n?.items??[]:[],...e.items],collections:t?.items??n?.collections??[],pagination:e.pagination,loading:!1})),!(a>1)&&(i?n.emit(`contentSearch`,{queryLength:i.length,hitCount:e.pagination.total}):n.emit(`contentView`,{section:`help`,count:e.items.length})))}).catch(e=>{s.current===c&&(Du.warn(`listContent (help) failed`,{err:e,page:a}),o(n=>n&&{...n,loading:!1,error:bu(e,t)}))})}return L(()=>{if(!r?.length)o(void 0);else return c(1),()=>{s.current=void 0}},[e,r,i]),[a,()=>!a?.loading&&c((a?.pagination?.page??0)+1)]}function Au(e){let{strings:t,config:n,nav:r,panelProps:i}=e,a=n.contentCollectionIds,[o,s]=I(``),[c,l]=I(``),u=ku(e,a),d=ku(e,c?a:void 0,c),[f,p]=o.trim()?d:u;L(()=>{let e=setTimeout(()=>l(o.trim()),300);return()=>clearTimeout(e)},[o]);function m(){if(!a?.length)return/* @__PURE__ */ U(ou,{message:t.helpEmpty,strings:t});let e=f?.error?/* @__PURE__ */ U(ou,{tone:`error`,message:f.error,onRetry:p,strings:t}):null;return e&&!f?.pagination?e:!f||!f.pagination&&!f.items.length?/* @__PURE__ */ U(ou,{message:t.helpLoading,strings:t}):f.items.length?/* @__PURE__ */ U(Ze,{children:[Ou(f.items,a,f.collections).map(e=>/* @__PURE__ */ U(`section`,{class:`${Eu}-help-group`,children:[e.title?/* @__PURE__ */ U(`h2`,{class:`${Eu}-help-section-title`,children:e.title}):null,/* @__PURE__ */ U(`div`,{class:`${Eu}-help-card`,children:e.rows.map(e=>/* @__PURE__ */ U(Tu,{title:e.title,subtitle:e.description,onClick:()=>r.push(e.url?{kind:`iframe`,url:e.url,title:e.title}:{kind:`content`,id:e.id,title:e.title}),testid:Hl(Z.helpArticle,e.id)},e.id))})]},e.id)),e,f.pagination?.hasNext&&!e?/* @__PURE__ */ U(`div`,{children:/* @__PURE__ */ U(`div`,{class:`${Eu}-help-card`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${Eu}-list-row ${Eu}-help-more`,onClick:p,"aria-busy":f.loading,children:[f.loading?/* @__PURE__ */ U(`span`,{class:`${Eu}-loading-spinner`,"aria-hidden":`true`}):null,t.helpShowMore]})})}):null]}):/* @__PURE__ */ U(ou,{message:f.search?t.helpSearchEmpty.replace(`{query}`,f.search):t.helpEmpty,strings:t})}return/* @__PURE__ */ U(`div`,{class:`${Eu}-module`,children:[/* @__PURE__ */ U(Ql,{title:t.helpTitle,actions:/* @__PURE__ */ U(vu,{panelProps:i,variant:`plain`})}),/* @__PURE__ */ U(`div`,{class:`${Eu}-module-pad`,children:/* @__PURE__ */ U(Cu,{placeholder:t.helpSearchPlaceholder,value:o,onInput:s})}),/* @__PURE__ */ U(`div`,{class:`${Eu}-help-list`,children:m()})]})}const ju={Icon:_l,Root:e=>/* @__PURE__ */ U(Au,{...e})},Mu=C.scope(`attachments`);function Nu(e,t,n){let r=Iu(e),i=[],a=[],o=zu(n.accept),s=t.reduce((e,t)=>e+t.size,0),c=t.length;for(let e of r){let t=Fu(e,c,s,n,o);t?a.push({file:e,reason:t}):(i.push(Ru(e)),s+=e.size,c+=1)}return(i.length||a.length)&&Mu.debug(`ingest`,{accepted:i.length,rejected:a.map(e=>({name:e.file.name,reason:e.reason}))}),{accepted:i,rejected:a}}function Pu(e){try{URL.revokeObjectURL(e.previewUrl)}catch(e){Mu.debug(`revokeObjectURL failed`,{error:e})}}function Fu(e,t,n,r,i){return t>=r.maxCount?`count`:n+e.size>r.maxBytes?`bytes`:Bu(e,i)?null:`mime`}function Iu(e){return e?Array.isArray(e)?e.filter(e=>e instanceof File):[...e].map(e=>e instanceof File?e:Lu(e)).filter(e=>e!==null):[]}function Lu(e){let t=e;return!t?.getAsFile||t.kind!==`file`?null:t.getAsFile()}function Ru(e){return{file:e,id:Fn(),mediaType:e.type||`application/octet-stream`,name:e.name||`pasted-file`,previewUrl:URL.createObjectURL(e),size:e.size}}function zu(e){return e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean).map(e=>{if(e.startsWith(`.`))return{kind:`ext`,ext:e};let[t=`*`,n=`*`]=e.split(`/`);return{kind:`mime`,type:t,subtype:n}})}function Bu(e,t){if(t.length===0)return!0;let[n=`*`,r=`*`]=(e.type||``).toLowerCase().split(`/`),i=(e.name||``).toLowerCase();return t.some(e=>e.kind===`ext`?i.endsWith(e.ext):e.type===`image`&&e.subtype===`*`&&/\.(heic|heif|avif|bmp|tif|tiff)$/.test(i)?!0:(e.type===`*`||e.type===n)&&(e.subtype===`*`||e.subtype===r))}const Vu=u.cssPrefix;function Hu({attachment:e,onRemove:t,disabled:n=!1}){let r=/^image\/(jpeg|png|gif|webp|avif|bmp|x-ms-bmp|svg\+xml)$/i.test(e.mediaType);return/* @__PURE__ */ U(`span`,{class:`${Vu}-attachment-chip`,title:e.name,"data-testid":Hl(Z.attachmentChip,e.id),children:[r?/* @__PURE__ */ U(`img`,{class:`${Vu}-attachment-thumb`,src:e.previewUrl,alt:``}):/* @__PURE__ */ U(`span`,{class:`${Vu}-attachment-thumb`,"aria-hidden":`true`,children:/* @__PURE__ */ U(ml,{})}),/* @__PURE__ */ U(`span`,{class:`${Vu}-attachment-name`,children:e.name}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Vu}-attachment-remove`,onClick:t,disabled:n,"aria-label":`Remove ${e.name}`,"data-testid":Hl(Z.attachmentRemove,e.id),children:/* @__PURE__ */ U(Hc,{})})]})}const Uu={isSupported:!1,start:()=>void 0,stop:()=>void 0,cancel:()=>void 0};function Wu(e,t,n){return e===`disabled`?Uu:e===`server`?Ju(n):Gu(t)}function Gu(e){let t=Ku();if(!t)return Uu;let n=null,r=0;return{isSupported:!0,start(i,a){let o=n,s=++r;n=null,o?.abort();let c=new t;n=c,c.continuous=!0,c.interimResults=!0,c.lang=e;let l=!1;c.addEventListener(`result`,e=>{if(r!==s||n!==c)return;let t=e,a=``,o=!1;for(let e=t.resultIndex;e<t.results.length;e++){let n=t.results[e];n&&(a+=n[0].transcript,n.isFinal&&(o=!0))}i(a,o)});function u(){l||r!==s||n!==c||(l=!0,n=null,a())}c.addEventListener(`end`,u),c.addEventListener(`error`,u);try{c.start()}catch{u()}},stop(){n?.stop()},cancel(){r++;let e=n;n=null,e?.abort()}}}function Ku(){return window.SpeechRecognition??window.webkitSpeechRecognition}const qu=[`audio/webm;codecs=opus`,`audio/webm`,`audio/ogg;codecs=opus`,`audio/mp4`];function Ju(e){if(typeof MediaRecorder>`u`||!navigator?.mediaDevices?.getUserMedia)return Uu;let t=0,n=null;function r(e){for(let t of e.stream?.getTracks()??[])t.stop();e.stream=null}function i(){t++;let e=n;n=null,e&&(r(e),e.recorder?.state!==`inactive`&&e.recorder?.stop())}async function a(i){if(i.finishing)return;i.finishing=!0;let a=i.recorder?.mimeType??`audio/webm`;r(i);let o=new Blob(i.chunks,{type:a});i.chunks=[];try{let{text:r}=await e(o,a);n===i&&t===i.generation&&r&&i.onText(r,!0)}catch{}finally{n===i&&t===i.generation&&(n=null,i.onEnd())}}return{isSupported:!0,async start(e,o){i();let s={generation:t,recorder:null,stream:null,chunks:[],onText:e,onEnd:o,finishing:!1};n=s;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});if(n!==s||t!==s.generation){for(let t of e.getTracks())t.stop();return}s.stream=e;let r=Yu(),i=new MediaRecorder(e,r?{mimeType:r}:void 0);s.recorder=i,i.addEventListener(`dataavailable`,e=>{n===s&&t===s.generation&&e.data.size>0&&s.chunks.push(e.data)}),i.addEventListener(`stop`,()=>{n===s&&t===s.generation&&a(s)}),i.start()}catch{r(s),n===s&&t===s.generation&&(n=null,o())}},stop(){let e=n;e&&(e.recorder?e.recorder.state!==`inactive`&&e.recorder.stop():i())},cancel(){i()}}}function Yu(){for(let e of qu)if(MediaRecorder.isTypeSupported(e))return e}const Xu=u.cssPrefix,Zu=C.scope(`composer`);function Qu(e){return e.reduce((e,t)=>e+t.size,0)}const $u={arrowUp:Gc,paperPlane:Wc,send:Kc,chevron:qc};function ed(e){return`activeElement`in e}function td(e){return`host`in e&&`activeElement`in e}function nd({options:e,transport:t,feedback:n,bus:r,persistence:i,conversationId:a,isStreaming:o,pageToolRunning:s=!1,isMemoryCompacting:c=!1,canReleaseQueuedMessages:l=!0,queueManualMessages:u=!1,active:d=!0,isPreparing:f=!1,operatorRequestEnabled:p,canRequestOperator:m=!1,controlMode:h=`ai-agent`,onRequestOperator:g,onSend:_,onStop:v,apiRef:y}){let b=e.strings,[x,S]=I(()=>i.loadDraft(a)),[C,w]=I([]),[T,E]=I(()=>i.loadMessageQueue(a).map(e=>({id:e.id,text:e.text,attachments:[]}))),D=R(T),O=R(!1),[ee,k]=I(!1),[te,ne]=I(!1),A=R(!1),j=R(null),re=R(null),ie=R(null),ae=R(0),oe=R(a);oe.current=a;let se=R(d);se.current=d;let ce=R(f);ce.current=f;let le=te||f||!d,M=o&&h===`ai-agent`,ue=M||c&&h===`ai-agent`,de=h===`ai-agent`&&(ue||u||T.length>0),fe=B(e=>{E(t=>{let n=e(t);return i.saveMessageQueue(oe.current,n.filter(e=>e.attachments.length===0).map(({id:e,text:t})=>({id:e,text:t}))),D.current=n,n})},[i]),pe=B(e=>{fe(t=>(t.find(t=>t.id===e)?.attachments.forEach(Pu),t.filter(t=>t.id!==e)))},[fe]),me=B(e=>{S(t=>{let n=typeof e==`function`?e(t):e;return n===t?t:(i.saveDraft(oe.current,n),n)})},[i]),he=e.features.fileUpload,N=e.features.voice,[ge,_e]=I(()=>Wu(N,e.locale,(e,n)=>t.transcribe(e,n))),ve=R(ge);ve.current=ge;let ye=R({mode:N,locale:e.locale,transport:t});L(()=>{let n=ye.current;(n.mode!==N||n.locale!==e.locale||n.transport!==t)&&(ye.current={mode:N,locale:e.locale,transport:t},ae.current++,ve.current.cancel(),ie.current=null,k(!1),_e(Wu(N,e.locale,(e,n)=>t.transcribe(e,n))))},[e.locale,N,t]),kr(()=>()=>{ae.current++,ge.cancel()},[ge]);let be=B(e=>{let t=ie.current;if(t===null)return!1;let n=Math.round(performance.now()-t);return Zu[e](`voiceStop`,{durationMs:n}),r.emit(`voiceStop`,{durationMs:n}),ie.current=null,!0},[r]),xe=B(()=>{ie.current!==null&&(ge.stop(),k(!1),be(`info`)&&n.play(`voiceStop`))},[be,n,ge]),Se=B(()=>{ae.current++,ge.cancel(),k(!1),be(`info`)&&n.play(`voiceStop`)},[be,n,ge]);L(()=>{(f||!d)&&Se()},[d,Se,f]),L(()=>{let e=j.current;if(!e)return;let t=e.getRootNode(),n=ed(t)?t.activeElement:null;n&&e.closest(`.${Xu}-panel`)?.contains(n)||e.focus({preventScroll:!0})},[]),L(()=>{let e=j.current;if(!e)return;if(x.length===0){e.style.height=``;return}e.style.height=`auto`;let t=getComputedStyle(e),n=Number.parseFloat(t.getPropertyValue(`--${Xu}-textarea-base-height`)),r=Number.parseFloat(t.borderTopWidth)+Number.parseFloat(t.borderBottomWidth),i=Math.min(e.scrollHeight+r,Number.parseFloat(t.maxHeight)),a=Number.parseFloat(t.fontSize)*.7;e.style.height=`${i<n+a?n:i}px`},[x]);let Ce=R(C);Ce.current=C,L(()=>()=>{Ce.current.forEach(Pu);for(let e of D.current)e.attachments.forEach(Pu)},[]),kr(()=>{if(y)return y.current={attachFromDrop:t=>{if(!he||!se.current||A.current||ce.current)return;let n=Nu(t,Ce.current,e.attachments);n.accepted.length!==0&&(Zu.info(`attach (drop)`,{count:n.accepted.length,totalBytes:Qu(n.accepted)}),r.emit(`attach`,{count:n.accepted.length,totalBytes:Qu(n.accepted)}),w(e=>[...e,...n.accepted]))},fill:e=>{if(!se.current||A.current||ce.current)return;me(e);let t=j.current;t&&(t.focus({preventScroll:!0}),requestAnimationFrame(()=>t.setSelectionRange(t.value.length,t.value.length)))},acceptQueuedMessage:pe},()=>{y.current&&(y.current=null)}},[y,he,f,e.attachments,pe,me]),L(()=>{let t=j.current;if(!t)return;let n=t.closest(`.${Xu}-panel`);if(!n)return;let i=n=>{if(!se.current||A.current||ce.current)return;let i=n.clipboardData;if(!i)return;let a=n.target?.closest?.(`input, textarea, [contenteditable]:not([contenteditable='false'])`);if(a&&a!==t)return;if(he){let t=Nu(i.items,Ce.current,e.attachments);if(t.accepted.length>0){n.preventDefault(),Zu.info(`attach (paste)`,{count:t.accepted.length,totalBytes:Qu(t.accepted)}),r.emit(`attach`,{count:t.accepted.length,totalBytes:Qu(t.accepted)}),w(e=>[...e,...t.accepted]);return}}if(a===t)return;let o=i.getData(`text/plain`);o&&(n.preventDefault(),me(e=>e+o),t.focus())};return n.addEventListener(`paste`,i),()=>n.removeEventListener(`paste`,i)},[he,e.attachments,me]);async function we(){let e=x.trim();if(!e&&C.length===0||!d||M||A.current||f)return;Se(),A.current=!0,ne(!0);let t=x,n=C;try{await _(e,n)&&(me(e=>e===t?``:e),w(e=>e===n?(n.forEach(Pu),Ce.current=[],[]):e))}finally{A.current=!1,ne(!1),requestAnimationFrame(()=>{let e=j.current;if(!e||e.disabled||!se.current)return;let t=e.getRootNode(),n=ed(t)?t.activeElement:null,r=n?.getAttribute(`data-testid`);if(!(n&&n!==e&&r!==Z.composerSend&&r!==Z.composerStop)){if(td(t)){let e=t.host.ownerDocument;if(!e.hasFocus())return;let n=e.activeElement;if(n&&n!==t.host&&n!==e.body)return}e.focus({preventScroll:!0})}})}}function Te(){let e=x.trim();if(!e&&C.length===0||!d||!de||A.current||f)return;Se();let t=C;fe(n=>[...n,{id:Fn(),text:e,attachments:t}]),me(``),w(e=>e===t?(Ce.current=[],[]):e),j.current?.focus({preventScroll:!0})}L(()=>{ue&&(O.current=!1)},[ue]),L(()=>{let e=T[0];if(!e||!l||ue||O.current||te||f||!d)return;let t=setTimeout(()=>{O.current=!0,_(e.text,e.attachments,e.id).then(t=>{t?pe(e.id):O.current=!1})},300);return()=>clearTimeout(t)},[d,l,f,_,ue,T,pe,te]);function Ee(e){e.key!==`Enter`||e.shiftKey||e.isComposing||(e.preventDefault(),de&&(x.trim()||C.length>0)?Te():M?v():we())}function De(t){let n=t.target;if(!d||A.current||f){n.value=``;return}let i=Nu(n.files,C,e.attachments);i.accepted.length>0&&(Zu.info(`attach (file picker)`,{count:i.accepted.length,totalBytes:Qu(i.accepted)}),r.emit(`attach`,{count:i.accepted.length,totalBytes:Qu(i.accepted)}),w(e=>[...e,...i.accepted])),n.value=``}function Oe(e){!d||A.current||f||(Zu.info(`removeAttachment`,{id:e}),r.emit(`removeAttachment`,{id:e}),w(t=>{let n=t.find(t=>t.id===e);return n&&Pu(n),t.filter(t=>t.id!==e)}))}function ke(){if(ee){xe();return}if(!d||!ge.isSupported||A.current||f)return;let e=++ae.current;ie.current=performance.now(),Zu.info(`voiceStart`),r.emit(`voiceStart`,void 0),k(!0),n.play(`voiceStart`),ge.start((t,n)=>{ae.current===e&&se.current&&!ce.current&&!A.current&&n&&me(e=>`${e}${t} `)},()=>{ae.current===e&&se.current&&(k(!1),be(`debug`))})}let Ae=$u[e.composer.sendButton.icon],je=!!(x.trim()||C.length>0),Me=M||s&&!je;return/* @__PURE__ */ U(`div`,{class:`${Xu}-composer`,part:`composer`,"data-testid":Z.composer,children:[T.length>0?/* @__PURE__ */ U(`div`,{class:`${Xu}-message-queue`,"aria-label":b.queueMessage,"data-testid":Z.messageQueue,children:T.map(e=>/* @__PURE__ */ U(`div`,{class:`${Xu}-attachment-chip ${Xu}-queued-message`,"data-testid":`${Z.queuedMessage}-${e.id}`,children:[/* @__PURE__ */ U(`span`,{class:`${Xu}-attachment-name ${Xu}-queued-text`,children:e.text||e.attachments.map(e=>e.name).join(`, `)}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Xu}-attachment-remove`,onClick:()=>pe(e.id),"aria-label":b.removeQueuedMessage,title:b.removeQueuedMessage,"data-testid":`${Z.queuedMessageRemove}-${e.id}`,children:/* @__PURE__ */ U(Hc,{})})]},e.id))}):null,C.length>0?/* @__PURE__ */ U(`div`,{class:`${Xu}-attachments`,children:C.map(e=>/* @__PURE__ */ U(Hu,{attachment:e,onRemove:()=>Oe(e.id),disabled:le},e.id))}):null,/* @__PURE__ */ U(`div`,{class:`${Xu}-composer-row`,children:[/* @__PURE__ */ U(`div`,{class:`${Xu}-composer-actions`,children:[he?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Xu}-icon-btn`,onClick:()=>re.current?.click(),disabled:le,"aria-label":b.attach,"data-testid":Z.composerAttach,children:/* @__PURE__ */ U(Yc,{})}):null,ge.isSupported?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Xu}-icon-btn`,onClick:ke,disabled:le,"aria-label":ee?b.micStop:b.micStart,"aria-pressed":ee,"data-recording":ee?`true`:void 0,"data-testid":Z.composerVoice,children:/* @__PURE__ */ U(Xc,{})}):null]}),/* @__PURE__ */ U(`textarea`,{ref:j,name:`message`,class:`${Xu}-textarea`,rows:1,value:x,placeholder:b.composerPlaceholder,onInput:e=>me(e.currentTarget.value),onKeyDown:Ee,disabled:le,"aria-label":b.composerPlaceholder,"data-testid":Z.composerInput}),de&&je?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Xu}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:Te,disabled:le,"aria-label":b.queueMessage,title:b.queueMessage,"data-testid":Z.composerSend,children:/* @__PURE__ */ U(Ae,{})}):null,Me?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Xu}-send`,onClick:v,disabled:le,"aria-label":b.stop,"data-testid":Z.composerStop,children:/* @__PURE__ */ U(Jc,{})}):null,!Me&&(!de||!je)?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Xu}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:()=>void we(),disabled:le||!x.trim()&&C.length===0,"aria-label":b.send,"data-testid":Z.composerSend,children:/* @__PURE__ */ U(Ae,{})}):null,p&&h===`ai-agent`&&g?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Xu}-icon-btn`,onClick:g,disabled:le||!m,"aria-label":b.talkToOperator,title:b.talkToOperator,"data-testid":Z.operatorRequest,children:/* @__PURE__ */ U(bl,{})}):null]}),/* @__PURE__ */ U(`input`,{ref:re,name:`attachments`,type:`file`,multiple:!0,accept:e.attachments.accept,onChange:De,disabled:le,class:`${Xu}-sr-only`,"data-testid":Z.composerFileInput})]})}const rd=u.cssPrefix;function id({onClick:e,children:t,testid:n}){return e?/* @__PURE__ */ U(`button`,{type:`button`,class:`${rd}-home-card`,"data-interactive":`true`,onClick:e,"data-testid":n,children:t}):/* @__PURE__ */ U(`div`,{class:`${rd}-home-card`,"data-testid":n,children:t})}function ad(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}const od=u.cssPrefix,sd=C.scope(`news`);function cd(e,t){let n=e?new Date(e):void 0;if(n&&!Number.isNaN(n.getTime()))return new Intl.DateTimeFormat(t,{dateStyle:`medium`}).format(n)}function ld({options:e,transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}){let c=r.contentCollectionIds,[l,u]=I({items:[],loading:!0}),d=R(void 0);function f(e){if(!c?.length)return;let r={};d.current=r,u(e=>({...e,loading:!0,error:void 0})),t.listContent({contentCollectionIds:c,sortBy:`publishedAt`,sortOrder:`desc`,page:e,limit:10}).then(t=>{if(d.current!==r||(u(n=>({items:e>1?[...n.items,...t.items]:t.items,pagination:t.pagination,loading:!1})),e>1))return;a.emit(`contentView`,{section:`news`,count:t.items.length});let n=t.items[0];n&&s.markSeen(n.id)}).catch(t=>{d.current===r&&(sd.warn(`listContent (news) failed`,{err:t,page:e}),u(e=>({...e,loading:!1,error:bu(t,n)})))})}function p(){l.loading||f((l.pagination?.page??0)+1)}L(()=>(u({items:[],loading:!0}),f(1),()=>{d.current=void 0}),[t,c]);function m(t){let n=cd(t.publishedAt,e.locale);return/* @__PURE__ */ U(`button`,{type:`button`,class:`${od}-news-card`,onClick:()=>i.push({kind:`content`,id:t.id,title:t.title}),"data-testid":Hl(Z.newsItem,t.id),children:[t.image?/* @__PURE__ */ U(`img`,{class:`${od}-news-hero`,src:t.image,alt:``,loading:`lazy`}):null,/* @__PURE__ */ U(`span`,{class:`${od}-news-body`,children:[/* @__PURE__ */ U(`span`,{class:`${od}-news-title`,children:t.title}),n||t.tags?.length?/* @__PURE__ */ U(`span`,{class:`${od}-news-meta`,children:[n?/* @__PURE__ */ U(`time`,{dateTime:t.publishedAt,children:n}):null,t.tags?.map(e=>/* @__PURE__ */ U(`span`,{class:`${od}-news-tag`,children:e},e))]}):null,t.description?/* @__PURE__ */ U(`span`,{class:`${od}-news-summary`,children:t.description}):null]})]},t.id)}function h(){if(!c?.length)return/* @__PURE__ */ U(ou,{message:n.newsEmpty,strings:n});let e=l.error?/* @__PURE__ */ U(ou,{tone:`error`,message:l.error,onRetry:p,strings:n}):null;return e&&!l.pagination?e:l.pagination?l.items.length?/* @__PURE__ */ U(`div`,{class:`${od}-news-list`,children:[l.items.map(m),e,l.pagination.hasNext&&!e?/* @__PURE__ */ U(`button`,{type:`button`,class:`${od}-news-more`,onClick:p,"aria-busy":l.loading,"data-testid":Z.newsMore,children:[l.loading?/* @__PURE__ */ U(`span`,{class:`${od}-loading-spinner`,"aria-hidden":`true`}):null,n.newsShowMore]}):null]}):/* @__PURE__ */ U(ou,{message:n.newsEmpty,strings:n}):/* @__PURE__ */ U(ou,{message:n.newsLoading,strings:n})}return/* @__PURE__ */ U(`div`,{class:`${od}-module`,children:[/* @__PURE__ */ U(Ql,{title:n.newsTitle,actions:/* @__PURE__ */ U(vu,{panelProps:o,variant:`plain`})}),/* @__PURE__ */ U(`div`,{class:`${od}-module-scroll`,children:h()})]})}const ud={Icon:Tl,Root:e=>/* @__PURE__ */ U(ld,{...e})},Q=u.cssPrefix,dd=C.scope(`home`);function fd(e){let t=e.options.userContext?.name,n=e.config.greetingText?At(e.strings,e.config.greetingText):void 0;if(n){let r=t?n.replace(`{name}`,t):n.replace(/\s*\{name\}\s*/,` `).trim(),i=e.strings.homeGreetingLead;return{title:r,subtitle:r.toLowerCase()===i.toLowerCase()?void 0:i}}return t?{title:e.strings.homeGreetingNamed.replace(`{name}`,t),subtitle:e.strings.homeGreetingLead}:{title:e.strings.homeGreeting}}function pd(e,t){return t.url?e.push({kind:`iframe`,url:t.url,title:t.title}):e.push({kind:`content`,id:t.id,title:t.title})}function md({options:e,onAsk:t}){let[n,r]=I(``),{sendButton:i}=e.composer,a=$u[i.icon];function o(e){e.preventDefault();let i=n.trim();i&&(r(``),t(i))}return/* @__PURE__ */ U(`form`,{class:`${Q}-home-search ${Q}-home-ask`,"data-input":`true`,onSubmit:o,"data-testid":Z.homeAsk,children:[/* @__PURE__ */ U(`input`,{type:`text`,class:`${Q}-home-search-input`,placeholder:e.strings.homeAskPlaceholder,"aria-label":e.strings.homeAskPlaceholder,value:n,enterKeyHint:`send`,onInput:e=>r(e.currentTarget.value)}),/* @__PURE__ */ U(`button`,{type:`submit`,class:`${Q}-send`,"data-shape":i.shape,"data-variant":i.variant,disabled:!n.trim(),"aria-label":e.strings.send,children:/* @__PURE__ */ U(a,{})})]})}function hd(e,t){return pc(e,t,t.type!==`upsert`||t.activity===!0)}function gd(e){let{transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}=e,[c,l]=I(null),[u,d]=I([]),f=r.contentCollectionIds?.join(`,`),p=e.options.modules.list.some(e=>e.layout===`chat`);L(()=>{if(r.showRecentConversations===!1)return;let e=!1,n=!0,i=[],a=t.subscribeConversationChanges(e=>{n&&i.push(e),l(t=>hd(t?[t]:[],e)[0]??null)});return t.listConversations({limit:p?50:1}).then(t=>{if(e)return;let r=i.reduce(hd,t.conversations);i=[],n=!1,l(r[0]??null)}).catch(t=>{e||(i=[],n=!1,dd.warn(`listConversations (home) failed`,{err:t}))}),()=>{e=!0,a()}},[t,r.showRecentConversations,p]),L(()=>{if(!r.contentCollectionIds?.length)return;let e=!1;return t.listContent({contentCollectionIds:r.contentCollectionIds,pinned:!0,limit:6}).then(t=>{e||(d(t.items),a.emit(`contentView`,{section:`home`,count:t.items.length}))}).catch(t=>!e&&dd.warn(`listContent (home) failed`,{err:t})),()=>{e=!0}},[t,f,a]);let m=fd(e),h=r.userAvatars??[],g=r.status,_=g?.text?At(n,g.text):n.homeStatus,v=r.contentBlockTitle?At(n,r.contentBlockTitle):n.homeContentTitle,y=s.item,b=cd(y?.publishedAt,e.options.locale);return/* @__PURE__ */ U(`div`,{class:`${Q}-module ${Q}-home`,"data-testid":Z.homeView,children:/* @__PURE__ */ U(`div`,{class:`${Q}-home-scroll`,children:[/* @__PURE__ */ U(`div`,{class:`${Q}-home-hero`,children:[/* @__PURE__ */ U(`div`,{class:`${Q}-home-hero-top`,children:[r.brandName?/* @__PURE__ */ U(`span`,{class:`${Q}-home-brand`,"data-testid":Z.homeBrand,children:r.brandName}):/* @__PURE__ */ U(`span`,{class:`${Q}-home-brand-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ U(`div`,{class:`${Q}-home-hero-actions`,children:[h.length>0?/* @__PURE__ */ U(`div`,{class:`${Q}-home-avatars`,children:h.map(e=>/* @__PURE__ */ U(`span`,{class:`${Q}-home-avatar`,title:e.role?`${e.name} · ${e.role}`:e.name,children:e.avatar?/* @__PURE__ */ U(`img`,{src:e.avatar,alt:``,loading:`lazy`}):/* @__PURE__ */ U(`span`,{children:ad(e.name)})},e.name))}):null,/* @__PURE__ */ U(vu,{panelProps:o,variant:`plain`})]})]}),r.showGreeting===!1?null:/* @__PURE__ */ U(Ze,{children:[/* @__PURE__ */ U(`h1`,{class:`${Q}-home-greeting`,"data-testid":Z.homeGreeting,children:m.title}),m.subtitle?/* @__PURE__ */ U(`p`,{class:`${Q}-home-lead`,children:m.subtitle}):null]})]}),/* @__PURE__ */ U(`div`,{class:`${Q}-home-cards`,children:[p?/* @__PURE__ */ U(md,{options:e.options,onAsk:e=>i.startNewConversation(e)}):null,r.showSearchBar===!1?null:/* @__PURE__ */ U(Su,{placeholder:n.homeSearchPlaceholder,onActivate:()=>i.switchToLayout(`help`)}),y?/* @__PURE__ */ U(id,{onClick:()=>{s.markSeen(y.id),i.push({kind:`content`,id:y.id,title:y.title})},testid:Z.homeWhatsNew,children:/* @__PURE__ */ U(`div`,{class:`${Q}-home-recent-row`,"data-unread":s.unseen?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Tl,{})}),/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-body`,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-title`,children:n.homeWhatsNew}),/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-preview`,children:b?`${y.title} · ${b}`:y.title})]}),s.unseen?/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-dot`,role:`img`,"aria-label":n.newsUnseen}):null]})}):null,c?/* @__PURE__ */ U(id,{onClick:()=>i.selectConversation(c),testid:Z.homeRecent,children:/* @__PURE__ */ U(`div`,{class:`${Q}-home-recent-row`,"data-unread":c.hasUnread?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(El,{})}),/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-body`,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-title`,children:c.title}),c.preview?/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-preview`,children:iu(c.preview)}):null]}),c.hasUnread?/* @__PURE__ */ U(`span`,{class:`${Q}-home-recent-dot`,"aria-label":`Unread`}):null]})}):null,g?/* @__PURE__ */ U(id,{onClick:g.url?()=>i.push({kind:`iframe`,url:g.url,title:_}):void 0,children:/* @__PURE__ */ U(`div`,{class:`${Q}-home-status`,"data-level":g.level??`operational`,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-home-status-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Cl,{})}),/* @__PURE__ */ U(`span`,{class:`${Q}-home-status-text`,children:_})]})}):null,u.length>0?/* @__PURE__ */ U(`section`,{class:`${Q}-home-content`,children:[/* @__PURE__ */ U(`div`,{class:`${Q}-home-content-title`,children:v}),/* @__PURE__ */ U(`div`,{class:`${Q}-home-content-list`,children:u.map(e=>/* @__PURE__ */ U(Tu,{title:e.title,subtitle:e.description,onClick:()=>pd(i,e),testid:Hl(Z.homeContentRow,e.id)},e.id))})]}):null]})]})})}const _d={chat:yu,home:{Icon:wl,Root:e=>/* @__PURE__ */ U(gd,{...e})},help:ju,news:ud},vd=u.cssPrefix;function yd({modules:e,activeTab:t,strings:n,hasUnread:r,onSelect:i}){return/* @__PURE__ */ U(`nav`,{class:`${vd}-tabbar`,role:`tablist`,"aria-label":n.panelTitle,children:e.map(e=>{let a=_d[e.layout].Icon,o=e.id===t,s=e.layout===`chat`&&r;return/* @__PURE__ */ U(`button`,{type:`button`,role:`tab`,"aria-selected":o,class:`${vd}-tab`,onClick:()=>i(e.id),"data-testid":Hl(Z.tab,e.id),children:[/* @__PURE__ */ U(`span`,{class:`${vd}-tab-icon`,"aria-hidden":`true`,children:[/* @__PURE__ */ U(a,{}),s?/* @__PURE__ */ U(`span`,{class:`${vd}-tab-badge`,"data-testid":Z.tabBadge,"aria-label":`Unread`}):null]}),/* @__PURE__ */ U(`span`,{class:`${vd}-tab-label`,children:At(n,e.label)})]},e.id)})})}const bd=u.cssPrefix;function xd({url:e,title:t,strings:n,onBack:r,actions:i}){return/* @__PURE__ */ U(`div`,{class:`${bd}-module`,children:[/* @__PURE__ */ U($l,{title:t||n.moduleBack,backLabel:n.moduleBack,onBack:r,actions:i}),/* @__PURE__ */ U(`iframe`,{class:`${bd}-content-frame`,src:e,title:t||`content`,sandbox:`allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads`,referrerpolicy:`no-referrer`,loading:`lazy`,allow:`fullscreen`})]})}const Sd=u.cssPrefix;function Cd({agent:e,strings:t}){let n=e.status??`online`,r=At(t,e.name),i=e.title?At(t,e.title):null;return/* @__PURE__ */ U(`div`,{class:`${Sd}-agent`,children:[/* @__PURE__ */ U(`div`,{class:`${Sd}-agent-avatar`,"data-status":n,children:e.avatar?/* @__PURE__ */ U(`img`,{src:e.avatar,alt:``}):/* @__PURE__ */ U(`span`,{children:ad(r)})}),/* @__PURE__ */ U(`div`,{class:`${Sd}-agent-meta`,children:[/* @__PURE__ */ U(`strong`,{children:r}),i?/* @__PURE__ */ U(`span`,{children:i}):null]})]})}const wd=[`today`,`yesterday`,`lastWeek`,`older`];function Td(e,t){let n=Date.parse(t);if(!Number.isFinite(n))return`older`;let r=Math.floor((Dd(e)-Dd(n))/864e5);return r<=0?`today`:r===1?`yesterday`:r<7?`lastWeek`:`older`}function Ed(e,t){let n=/* @__PURE__ */ new Map;for(let r of t){let t=Td(e,r.lastMessageAt),i=n.get(t);i?i.push(r):n.set(t,[r])}return wd.filter(e=>n.has(e)).map(e=>({bucket:e,conversations:n.get(e)}))}function Dd(e){let t=new Date(e);return t.setUTCHours(0,0,0,0),t.getTime()}const Od=C.scope(`history`),kd={today:`dateToday`,yesterday:`dateYesterday`,lastWeek:`dateLastWeek`,older:`dateOlder`};function Ad(e,t){let n=t.type!==`upsert`||t.activity===!0;if(t.type===`snapshot`&&t.result.pagination.page===1&&e.pagination.page>1){let r=pc(e.conversations.slice(0,t.result.pagination.limit),t,n);if(t.result.conversations.length===0){if(r.length===0)return t.result;let e=Math.max(t.result.pagination.total,r.length);return{...t.result,conversations:r,pagination:{...t.result.pagination,total:e,totalPages:Math.ceil(e/t.result.pagination.limit)}}}let i=new Set(r.map(e=>e.conversationId)),a=e.conversations.slice(t.result.pagination.limit).filter(e=>!i.has(e.conversationId)),o=e.pagination.page,s={...t.result.pagination,page:o,hasPrev:o>1,hasNext:o<t.result.pagination.totalPages};return{conversations:[...r,...a],pagination:s}}let r=pc(e.conversations,t,n);return r===e.conversations?e:{...t.type===`snapshot`?t.result:e,conversations:r}}function jd(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<6048e5?new Intl.DateTimeFormat(n,{weekday:`short`}).format(r):new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`}).format(r):``}function Md({transport:e,strings:t,locale:n,persistence:r,onSelect:i,onNewConversation:a}){let o=u.cssPrefix,s=e.peekConversations({limit:50}),[c,l]=I(s?`loaded`:`loading`),[d,f]=I(s),[p,m]=I(!1),h=R(void 0),g=d?.conversations??[],_=d?.pagination;L(()=>{let t=!1,n=!0,i=[],a=e.subscribeConversationChanges(e=>{n&&i.push(e),f(t=>t&&Ad(t,e))});h.current=void 0,m(!1);let o=e.peekConversations({limit:50});return f(o),l(o?`loaded`:`loading`),e.listConversations({limit:50}).then(e=>{if(t)return;let a=e;for(let e of i)a=Ad(a,e);i=[],n=!1,f(a),l(`loaded`),r.saveHistoryCount(a.conversations.length)}).catch(e=>{t||(i=[],n=!1,Od.warn(`listConversations failed`,{err:e}),l(`error`))}),()=>{t=!0,a(),h.current=void 0}},[e,r,n]);async function v(){if(h.current||!_?.hasNext)return;let t={};h.current=t,m(!0);try{let n=await e.listConversations({page:_.page+1,limit:_.limit});if(h.current!==t)return;f(e=>{if(!e)return e;let t=new Set(e.conversations.map(e=>e.conversationId)),i=n.conversations.filter(e=>!t.has(e.conversationId)&&(t.add(e.conversationId),!0)),a={conversations:[...e.conversations,...i],pagination:n.pagination};return r.saveHistoryCount(a.conversations.length),a})}catch(e){if(h.current!==t)return;Od.warn(`listConversations page failed`,{err:e,page:_.page+1})}finally{h.current===t&&(h.current=void 0,m(!1))}}let y=a?/* @__PURE__ */ U(`div`,{class:`${o}-history-footer`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${o}-history-new`,onClick:a,"data-testid":Z.sidebarNewConversation,children:[/* @__PURE__ */ U(Uc,{}),t.newConversation]})}):null;if(c===`loading`){let e=Math.min(r.loadHistoryCount()??3,6);return/* @__PURE__ */ U(Ze,{children:[/* @__PURE__ */ U(`div`,{class:`${o}-history`,"aria-busy":`true`,"aria-label":t.historyLoading,children:/* @__PURE__ */ U(`div`,{class:`${o}-history-group`,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`div`,{class:`${o}-history-heading`,children:/* @__PURE__ */ U(`span`,{class:`${o}-skeleton ${o}-skeleton-heading`})}),/* @__PURE__ */ U(`div`,{class:`${o}-history-card`,children:Array.from({length:Math.max(1,e)},(e,t)=>/* @__PURE__ */ U(`div`,{class:`${o}-history-item ${o}-history-item-skeleton`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-avatar ${o}-skeleton`}),/* @__PURE__ */ U(`span`,{class:`${o}-history-body`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-title`,children:/* @__PURE__ */ U(`span`,{class:`${o}-skeleton ${o}-skeleton-title`})}),/* @__PURE__ */ U(`span`,{class:`${o}-history-time`,children:/* @__PURE__ */ U(`span`,{class:`${o}-skeleton ${o}-skeleton-time`})})]}),/* @__PURE__ */ U(`span`,{class:`${o}-history-row`,children:/* @__PURE__ */ U(`span`,{class:`${o}-history-preview`,children:/* @__PURE__ */ U(`span`,{class:`${o}-skeleton ${o}-skeleton-preview`})})})]})]},t))})]})}),y]})}if(c===`error`||g.length===0)return/* @__PURE__ */ U(Ze,{children:[/* @__PURE__ */ U(`div`,{class:`${o}-history-empty`,children:t.historyEmpty}),y]});let b=Date.now(),x=Ed(b,g);return/* @__PURE__ */ U(Ze,{children:[/* @__PURE__ */ U(`div`,{class:`${o}-history`,role:`list`,children:[x.map(e=>/* @__PURE__ */ U(`div`,{class:`${o}-history-group`,children:[/* @__PURE__ */ U(`div`,{class:`${o}-history-heading`,children:t[kd[e.bucket]]}),/* @__PURE__ */ U(`div`,{class:`${o}-history-card`,children:e.conversations.map(e=>/* @__PURE__ */ U(`div`,{role:`listitem`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${o}-history-item`,onClick:()=>i(e),"data-closed":e.canContinue?void 0:`true`,"data-unread":e.hasUnread?`true`:void 0,"data-testid":Hl(Z.historyItem,e.conversationId),children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(gl,{})}),/* @__PURE__ */ U(`span`,{class:`${o}-history-body`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-title`,children:e.title}),/* @__PURE__ */ U(`span`,{class:`${o}-history-time`,children:jd(e.lastMessageAt,b,n)})]}),/* @__PURE__ */ U(`span`,{class:`${o}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${o}-history-preview`,children:e.preview&&iu(e.preview)||(e.canContinue?t.historyContinue:t.conversationClosed)}),e.hasUnread?/* @__PURE__ */ U(`span`,{class:`${o}-history-dot`}):null]})]})]})},e.conversationId))})]},e.bucket)),_?.hasNext?/* @__PURE__ */ U(`div`,{class:`${o}-history-more`,children:/* @__PURE__ */ U(`button`,{type:`button`,onClick:v,disabled:p,"aria-busy":p,"data-testid":Z.historyLoadMore,children:t.loadMoreConversations})}):null]}),y]})}const Nd=u.cssPrefix;function Pd({visible:e,strings:t}){return e?/* @__PURE__ */ U(`div`,{class:`${Nd}-dropzone`,role:`status`,"aria-live":`polite`,children:t.dropZone}):null}const Fd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Id=/^https?:\/\/[^\s.]+\.[^\s]+$/i,Ld=/^[+]?[\d\s().-]{6,}$/;function Rd(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>String(t[n]??`{${n}}`))}function zd(e){return Array.isArray(e)?e.length:+!!e?.trim()}function Bd(e,t,n){let r=e.required??!0,i=e.validation;if(e.type===`multiselect`){let e=zd(t);return r&&e===0?n.formRequired:e===0?void 0:i?.minSelections!=null&&e<i.minSelections?Rd(n.formChooseAtLeast,{min:i.minSelections}):i?.maxSelections!=null&&e>i.maxSelections?Rd(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(!Fd.test(a))return n.formInvalidEmail;break;case`url`:if(!Id.test(a))return n.formInvalidUrl;break;case`tel`:if(!Ld.test(a))return n.formInvalidTel;break;case`number`:{let e=Number(a);if(!Number.isFinite(e))return n.formInvalidNumber;if(i?.min!=null&&e<i.min)return Rd(n.formNumberTooSmall,{min:i.min});if(i?.max!=null&&e>i.max)return Rd(n.formNumberTooLarge,{max:i.max});break}}if(i?.minLength!=null&&a.length<i.minLength)return Rd(n.formTooShort,{min:i.minLength});if(i?.maxLength!=null&&a.length>i.maxLength)return Rd(n.formTooLong,{max:i.maxLength});if(i?.pattern)try{if(!new RegExp(i.pattern).test(a))return n.formPatternMismatch}catch{}}function Vd(e,t,n){let r={};for(let i of e){let e=Bd(i,t[i.name],n);e&&(r[i.name]=e)}return r}function Hd(e){let t={};for(let[n,r]of Object.entries(e)){let e=Array.isArray(r)?r.join(`, `):r;e.trim()&&(t[n]=e.trim())}return t}const Ud=u.cssPrefix,Wd=`__other__`;function Gd({fields:e,strings:t,submitLabel:n,onSubmit:r,skipLabel:i,onSkip:a,footerHint:o,submitOnEnter:s,disabled:c,initialValues:l,hideActions:u,fieldTypeLabels:d,rootTestId:f,submitTestId:p,skipTestId:m}){let[h,g]=I(()=>({...Yd(e),...l})),[_,v]=I({}),[y,b]=I({});function x(e){y[e]&&b(t=>({...t,[e]:``}))}function S(e,t){g(n=>({...n,[e]:t})),x(e)}function C(e,t){v(n=>({...n,[e]:t})),x(e)}function w(n){if(n.preventDefault(),c)return;let i=Xd(e,h,_),a=Vd(e,i,t);Object.keys(a).length>0?b(a):r(Hd(i))}function T(e){!s||e.key!==`Enter`||e.shiftKey||e.isComposing||e.target&&`tagName`in e.target&&e.target.tagName===`TEXTAREA`&&w(e)}return/* @__PURE__ */ U(`form`,{class:`${Ud}-form`,onSubmit:w,onKeyDown:T,"data-testid":f,noValidate:!0,children:[e.map(e=>/* @__PURE__ */ U(Kd,{field:e,value:h[e.name],otherText:_[e.name]??``,error:y[e.name],disabled:c,typeLabel:d?.[e.name],strings:t,onChange:t=>S(e.name,t),onOtherChange:t=>C(e.name,t)},e.name)),u?null:/* @__PURE__ */ U(`div`,{class:`${Ud}-form-actions`,children:[o?/* @__PURE__ */ U(`span`,{class:`${Ud}-form-hint`,children:o}):null,i&&a?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ud}-form-skip`,onClick:a,disabled:c,"data-testid":m,children:i}):null,/* @__PURE__ */ U(`button`,{type:`submit`,class:`${Ud}-form-submit`,disabled:c,"data-testid":p,children:n})]})]})}function Kd({field:e,value:t,otherText:n,error:r,disabled:i,typeLabel:a,strings:o,onChange:s,onOtherChange:c}){let l=qd({field:e,value:t,otherText:n,disabled:i,strings:o,onChange:s,onOtherChange:c,fieldTid:Hl(Z.formField,e.name)});return/* @__PURE__ */ U(`label`,{class:`${Ud}-field`,"data-field":e.name,"data-invalid":r?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${Ud}-field-head`,children:[/* @__PURE__ */ U(`span`,{class:`${Ud}-field-label`,children:[e.label,e.required??!0?/* @__PURE__ */ U(`span`,{class:`${Ud}-field-req`,"aria-hidden":`true`,children:` *`}):null]}),a?/* @__PURE__ */ U(`span`,{class:`${Ud}-field-type`,children:a}):null]}),l,e.validationHint&&!r?/* @__PURE__ */ U(`span`,{class:`${Ud}-field-hint`,children:e.validationHint}):null,r?/* @__PURE__ */ U(`span`,{class:`${Ud}-field-error`,role:`alert`,children:r}):null]})}function qd(e){let{field:t,value:n,otherText:r,disabled:i,strings:a,onChange:o,onOtherChange:s,fieldTid:c}=e,l=typeof n==`string`?n:``;switch(t.type){case`textarea`:return/* @__PURE__ */ U(`textarea`,{class:`${Ud}-field-input`,rows:3,value:l,placeholder:t.placeholder,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c});case`select`:return/* @__PURE__ */ U(`select`,{class:`${Ud}-field-input`,value:l,disabled:i,onChange:e=>o(e.currentTarget.value),"data-testid":c,children:[/* @__PURE__ */ U(`option`,{value:``,children:t.placeholder??`—`}),(t.options??[]).map(e=>/* @__PURE__ */ U(`option`,{value:e.value,children:e.label??e.value},e.value))]});case`radio`:{let e=t.allowOther&&l===Wd;return/* @__PURE__ */ U(`div`,{class:`${Ud}-field-choices`,role:`radiogroup`,"data-testid":c,children:[(t.options??[]).map(e=>/* @__PURE__ */ U(`label`,{class:`${Ud}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`radio`,name:`${Ud}-${t.name}`,checked:l===e.value,disabled:i,onChange:()=>o(e.value)}),/* @__PURE__ */ U(`span`,{children:e.label??e.value})]},e.value)),t.allowOther?/* @__PURE__ */ U(`label`,{class:`${Ud}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`radio`,name:`${Ud}-${t.name}`,checked:l===Wd,disabled:i,onChange:()=>o(Wd)}),/* @__PURE__ */ U(`span`,{children:a.formOther})]}):null,e?/* @__PURE__ */ U(`input`,{class:`${Ud}-field-input`,value:r,placeholder:t.placeholder??a.formOtherPlaceholder,disabled:i,onInput:e=>s(e.currentTarget.value)}):null]})}case`checkbox`:return/* @__PURE__ */ U(`label`,{class:`${Ud}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`checkbox`,checked:l===`true`,disabled:i,onChange:e=>o(e.currentTarget.checked?`true`:``),"data-testid":c}),/* @__PURE__ */ U(`span`,{children:t.placeholder??t.label})]});case`multiselect`:{let e=Array.isArray(n)?n:[];function l(t,n){return o(n?[...e,t]:e.filter(e=>e!==t))}return/* @__PURE__ */ U(`div`,{class:`${Ud}-field-choices`,"data-testid":c,children:[(t.options??[]).map(t=>/* @__PURE__ */ U(`label`,{class:`${Ud}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`checkbox`,checked:e.includes(t.value),disabled:i,onChange:e=>l(t.value,e.currentTarget.checked)}),/* @__PURE__ */ U(`span`,{children:t.label??t.value})]},t.value)),t.allowOther||(t.options??[]).length===0?/* @__PURE__ */ U(`textarea`,{class:`${Ud}-field-input`,rows:2,value:r,placeholder:t.placeholder??a.formOtherPlaceholder,disabled:i,onInput:e=>s(e.currentTarget.value)}):null]})}default:return/* @__PURE__ */ U(`input`,{...Jd(t.type),class:`${Ud}-field-input`,value:l,placeholder:t.placeholder,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c})}}function Jd(e){switch(e){case`number`:return{type:e};case`email`:return{type:e};case`tel`:return{type:e};case`url`:return{type:e};case`date`:case`time`:return{type:e};default:return{type:`text`}}}function Yd(e){let t={};for(let n of e)n.defaultValue!=null&&(t[n.name]=n.type===`multiselect`?n.defaultValue.split(`,`).map(e=>e.trim()).filter(Boolean):n.defaultValue);return t}function Xd(e,t,n){let r={...t};for(let i of e){let e=n[i.name]?.trim();if(i.type===`radio`&&i.allowOther&&t[i.name]===Wd)r[i.name]=e??``;else if(i.type===`multiselect`&&e){let n=e.split(/[,\n;]+/).map(e=>e.trim()).filter(Boolean),a=t[i.name];r[i.name]=[...Array.isArray(a)?a:[],...n]}}return r}const Zd=u.cssPrefix;function Qd({form:e,strings:t,onSubmit:n,onSkip:r}){return/* @__PURE__ */ U(`div`,{class:`${Zd}-form-gate`,"data-testid":Z.formGate,children:[e.title?/* @__PURE__ */ U(`h3`,{class:`${Zd}-form-gate-title`,children:e.title}):null,e.description?/* @__PURE__ */ U(`p`,{class:`${Zd}-form-gate-desc`,children:e.description}):null,/* @__PURE__ */ U(Gd,{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:Z.formSubmit,skipTestId:Z.formSkip})]})}function $d({marker:e,strings:t,onFill:n}){let r=e.outcome===`skipped`,i=r?t.formSkipped:t.formSubmitted,a=e.title?/* @__PURE__ */ U(Ze,{children:[/* @__PURE__ */ U(`span`,{children:e.title}),/* @__PURE__ */ U(`span`,{class:`${Zd}-sr-only`,children:i})]}):/* @__PURE__ */ U(`span`,{children:i}),o=e.form?.reviewable??!1,s=!r&&o&&e.values&&Object.keys(e.values).length>0?e.values:null;if(s){function t(t){return e.form?.fields.find(e=>e.name===t)?.label??t}return/* @__PURE__ */ U(`details`,{class:`${Zd}-form-done`,"data-outcome":e.outcome,"data-testid":Z.formDone,children:[/* @__PURE__ */ U(`summary`,{class:`${Zd}-form-done-summary`,"data-testid":Z.formDoneToggle,children:[/* @__PURE__ */ U(cl,{}),a,/* @__PURE__ */ U(qc,{})]}),/* @__PURE__ */ U(`dl`,{class:`${Zd}-form-answers`,"data-testid":Z.formAnswers,children:Object.entries(s).map(([e,n])=>/* @__PURE__ */ U(`div`,{class:`${Zd}-form-answer`,children:[/* @__PURE__ */ U(`dt`,{children:t(e)}),/* @__PURE__ */ U(`dd`,{children:n})]},e))})]})}return/* @__PURE__ */ U(`div`,{class:`${Zd}-form-done`,"data-outcome":e.outcome,"data-testid":Z.formDone,role:`status`,children:[U(r?sl:cl,{}),a,r&&e.form?.reopenable&&n?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Zd}-form-done-fill`,"data-testid":Z.formFill,onClick:n,children:t.formFillOut}):null]})}var ef=Object.assign;function tf(e,t){for(var n in e)if(n!=`__source`&&e[n]!==t[n])return!0;for(var r in t)if(r!=`__source`&&!(r in e))return!0;return!1}var nf=/^(-|f[lo].*[^se]$|g.{5,}[^ps]$|z|o[pr]|(W.{5})?[lL]i.*(t|mp)$|an|(bo|s).{4}Im|sca|m.{6}[ds]|ta|c.*[st]$|wido|ini)/;function rf(e,t){function n(e){var n=this.props.ref;return n!=e.ref&&n&&(typeof n==`function`?n(null):n.current=null),t?!t(this.props,e)||n!=e.ref:tf(this.props,e)}function r(t){return this.shouldComponentUpdate=n,Ye(e,t)}return r.displayName=`Memo(`+(e.displayName||e.name)+`)`,r.prototype.isReactComponent=!0,r.type=e,r}var af=Symbol.for(`react.element`),of=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(?!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,sf=/[A-Z0-9]/g,cf=typeof document<`u`,lf=function(e){return/fil|che|rad/.test(e)};Qe.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(Qe.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var uf=P.event;P.event=function(e){return uf&&(e=uf(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var df={configurable:!0,get:function(){return this.class}},ff=P.vnode;P.vnode=function(e){if(typeof e.type==`string`)(function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)==-1;for(var a in t){var o=t[a];if(!(a==`value`&&`defaultValue`in t&&o==null||cf&&a==`children`&&n==`noscript`||a==`class`||a==`className`)){if(a==`style`&&o&&o.constructor==Object){var s=void 0;for(var c in o)typeof o[c]!=`number`||nf.test(c)||(s||(s=o=ef({},o)),o[c]+=`px`)}else if(a==`defaultValue`&&`value`in t&&t.value==null)a=`value`;else if(a==`download`&&!0===o)o=``;else if(a==`translate`&&o===`no`)o=!1;else if(a[0]==`o`&&a[1]==`n`){var l=a.toLowerCase();l==`ondoubleclick`?a=`ondblclick`:l!=`onchange`||n!=`input`&&n!=`textarea`||lf(t.type)?l==`onfocus`?a=`onfocusin`:l==`onblur`&&(a=`onfocusout`):l=a=`oninput`,l==`oninput`&&r[a=l]&&(a=`oninputCapture`)}else i&&of.test(a)?a=a.replace(sf,`-$&`).toLowerCase():o===null&&(o=void 0);r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=ot(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=ot(t.children).forEach(function(e){e.props.selected=r.multiple?r.defaultValue.indexOf(e.props.value)!=-1:r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",df)):t.className&&(r.class=r.className=t.className),e.props=r})(e);else if(typeof e.type==`function`&&(`ref`in e.props&&`prototype`in e.type&&e.type.prototype.render&&(e.ref=e.props.ref,delete e.props.ref),e.type.defaultProps)){var t=ef({},e.props);for(var n in e.type.defaultProps)t[n]===void 0&&(t[n]=e.type.defaultProps[n]);e.props=t}e.ref&&!(`ref`in e.props)&&Object.defineProperty(e.props,"ref",{value:e.ref,configurable:!0,writable:!0}),e.$$typeof=af,ff&&ff(e)};function pf(e){return e?(e.startsWith(`tool:`)?e.slice(5):e)===`ask-user-questions`:!1}const mf=u.cssPrefix;function hf({messageId:e,initial:t,strings:n,onFeedback:r}){let[i,a]=I(t);L(()=>a(t),[e,t]);function o(t){let n=i===t?null:t;a(n),r(e,n)}return/* @__PURE__ */ U(`div`,{class:`${mf}-feedback`,role:`group`,"data-testid":Z.messageFeedback,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${mf}-msg-action`,"data-active":i===`up`?`true`:void 0,"aria-pressed":i===`up`,"aria-label":n.feedbackUp,title:n.feedbackUp,onClick:()=>o(`up`),"data-testid":Z.feedbackUp,children:/* @__PURE__ */ U(Fl,{})}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${mf}-msg-action`,"data-active":i===`down`?`true`:void 0,"aria-pressed":i===`down`,"aria-label":n.feedbackDown,title:n.feedbackDown,onClick:()=>o(`down`),"data-testid":Z.feedbackDown,children:/* @__PURE__ */ U(Il,{})}),/* @__PURE__ */ U(`span`,{class:`${mf}-sr-only`,role:`status`,"aria-live":`polite`,children:i?n.feedbackThanks:``})]})}const gf=u.cssPrefix;function _f(e){let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function vf(e){if(e.startsWith(`tool:`)||e.startsWith(`tool-`))return e.slice(5);let t=e.indexOf(`__`),n=e.slice(t+2);return t>0&&n?`${_f(e.slice(0,t))} · ${_f(n)}`:e}function yf(e,t){let n=e===`output-available`||e===`output-error`||e===`output-denied`,r=e===`approval-responded`||t?.approved!==void 0;return{terminal:n,responded:r,decided:n||r}}function bf({status:e,icon:t,label:n}){return/* @__PURE__ */ U(`span`,{class:`${gf}-toolui-badge ${gf}-toolui-status`,"data-status":e,children:[/* @__PURE__ */ U(`span`,{class:`${gf}-toolui-status-icon`,children:t}),n]})}function xf(e,t){return e===`output-error`?`error`:e===`output-denied`||t?.approved===!1?`denied`:e===`output-available`?`completed`:e===`approval-responded`||t?.approved===!0?`responded`:e===`approval-requested`?`awaiting`:`running`}function Sf(e,t,n={}){return n.submitted?`responded`:n.incomplete?`incomplete`:Tf(xf(e,t),n.superseded,n.live??!0)}function Cf({status:e}){return U(e===`denied`||e===`error`||e===`superseded`||e===`incomplete`?Bl:e===`completed`||e===`responded`?zl:Rl,{})}function wf(e,t){switch(e){case`awaiting`:return t.statusAwaiting;case`responded`:return t.statusResponded;case`completed`:return t.statusCompleted;case`denied`:return t.statusDenied;case`error`:return t.statusError;case`superseded`:return t.statusSuperseded;case`incomplete`:return t.statusIncomplete;default:return t.statusRunning}}function Tf(e,t,n){return t&&(e===`awaiting`||e===`running`)?`superseded`:!n&&e===`running`?`error`:e}function Ef({state:e,approval:t,strings:n,superseded:r,live:i=!0,submitted:a=!1,incomplete:o=!1}){let s=Sf(e,t,{superseded:r,live:i,submitted:a,incomplete:o});return/* @__PURE__ */ U(bf,{status:s,icon:/* @__PURE__ */ U(Cf,{status:s}),label:wf(s,n)})}function Df({name:e,state:t,approval:n,strings:r,superseded:i,live:a,submitted:o,incomplete:s}){return/* @__PURE__ */ U(Ze,{children:[/* @__PURE__ */ U(`span`,{class:`${gf}-toolui-name-pill`,children:[/* @__PURE__ */ U(Ll,{}),/* @__PURE__ */ U(`span`,{class:`${gf}-toolui-name-text`,children:e})]}),/* @__PURE__ */ U(Ef,{state:t,approval:n,strings:r,superseded:i,live:a,submitted:o,incomplete:s}),/* @__PURE__ */ U(`span`,{class:`${gf}-toolui-chevron`,children:/* @__PURE__ */ U(pl,{})})]})}function Of({part:e,strings:t,testid:n,superseded:r,live:i,submitted:a,incomplete:o}){let s=z(()=>H(()=>e.inputSig.value),[e]),c=z(()=>H(()=>e.outputSig.value),[e]),l=z(()=>H(()=>e.errorSig.value),[e]),u=z(()=>H(()=>e.stateSig.value),[e]),d=z(()=>H(()=>e.approvalSig.value),[e]),f=z(()=>H(()=>Te(e.toolMetadata)&&Ae(e.errorSig.value)),[e]),p=o===!0||f.value;return/* @__PURE__ */ U(`details`,{class:`${gf}-toolui ${gf}-toolui-collapsible`,"data-testid":n,children:[/* @__PURE__ */ U(`summary`,{class:`${gf}-toolui-head`,children:/* @__PURE__ */ U(Df,{name:vf(e.toolName),state:u.value,approval:d.value,strings:t,superseded:r,live:i,submitted:a,incomplete:p})}),/* @__PURE__ */ U(kf,{label:t.toolParameters,value:s.value}),c.value===void 0?null:/* @__PURE__ */ U(kf,{label:t.toolResult,value:c.value}),l.value&&!p?/* @__PURE__ */ U(kf,{label:t.statusError,value:l.value,error:!0}):null]})}function kf({label:e,value:t,error:n}){let r=n?typeof t==`string`?t:``:jf(Af(t));return r?/* @__PURE__ */ U(`div`,{class:`${gf}-toolui-section`,children:[/* @__PURE__ */ U(`span`,{class:`${gf}-toolui-label`,children:e}),/* @__PURE__ */ U(`pre`,{class:`${gf}-toolui-code`,"data-error":n?`true`:void 0,children:r})]}):null}function Af(e){if(e&&typeof e==`object`){let t=e;if(t.storage===`tool-result-ref`&&`summary`in t)return t.summary}return e}function jf(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)}…`:t}catch{return``}}function Mf(e){return e.partsSig.value.some(e=>e.kind===`text`&&e.textSig.value.length>0)}function Nf(e){return e.partsSig.value.some(e=>e.kind===`reasoning`)}function Pf(e){return e.streaming&&!e.bufferedHold&&!(e.reasoningVisible&&e.working)}function Ff(e){let{streaming:t,reasoningVisible:n,emptyReply:r,hidden:i}=e,a=e.responseMode===`buffered`&&t,o=t&&!e.hasAnswerText;return{streaming:t,bufferedHold:a,reasoningVisible:n,working:o,showStreamDots:Pf({streaming:t,bufferedHold:a,reasoningVisible:n,working:o}),emptyReply:r,hidden:i}}function If(e,t){let n=e.stateSig.value,r=e.approvalSig.value,{terminal:i,responded:a,decided:o}=yf(n,r),s=t.continuationStreaming===!0&&!o,c=t.superseded&&!o&&!s;return{pill:Sf(n,r,{superseded:c,live:t.live,submitted:s,incomplete:Te(e.toolMetadata)&&Ae(e.errorSig.value)}),state:n,terminal:i,decided:o||s,showApproveReject:!o&&!t.superseded&&!s,showAnswered:a&&!i&&!c,showSubmitted:s,showEdit:a&&t.active&&!i,skipped:c,answeredApproved:r?.approved}}const Lf=u.cssPrefix;function Rf({part:e,strings:t}){let n=e.title||e.filename||e.url||t.sources;return e.url?/* @__PURE__ */ U(`a`,{class:`${Lf}-source`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-testid":Z.source,children:[/* @__PURE__ */ U(`span`,{class:`${Lf}-source-icon`,"aria-hidden":`true`,children:`🔗`}),/* @__PURE__ */ U(`span`,{class:`${Lf}-source-label`,children:n})]}):/* @__PURE__ */ U(`span`,{class:`${Lf}-source`,"data-testid":Z.source,children:[/* @__PURE__ */ U(`span`,{class:`${Lf}-source-icon`,"aria-hidden":`true`,children:`📄`}),/* @__PURE__ */ U(`span`,{class:`${Lf}-source-label`,children:n})]})}const zf=u.cssPrefix;function Bf({part:e,strings:t,active:n,superseded:r=!1,continuationStreaming:i=!1,onDecision:a,onEdit:o}){let s=z(()=>H(()=>e.approvalSig.value),[e]),c=z(()=>H(()=>If(e,{active:n,superseded:r,continuationStreaming:i})),[e,n,r,i]).value,{terminal:l,showApproveReject:u,showAnswered:d,showSubmitted:f,showEdit:p,skipped:m}=c,h=vf(e.toolName),g=c.answeredApproved,_=e.toolCallId,v=/* @__PURE__ */ U(Ze,{children:[/* @__PURE__ */ U(`p`,{class:`${zf}-toolui-prompt`,children:t.approvalPrompt.replace(`{tool}`,h)}),/* @__PURE__ */ U(`p`,{class:`${zf}-toolui-subtle`,children:t.approvalBody})]});f?v=/* @__PURE__ */ U(`p`,{class:`${zf}-toolui-subtle`,children:t.approvalSubmitting}):d&&g!==!1?v=/* @__PURE__ */ U(Ze,{children:[/* @__PURE__ */ U(`p`,{class:`${zf}-toolui-prompt`,children:[t.approvalYourResponse.replace(`{decision}`,g?t.approve:t.reject),s.value?.reason?` — ${s.value.reason}`:``]}),p?/* @__PURE__ */ U(`p`,{class:`${zf}-toolui-subtle`,children:t.approvalEditHint}):null,p?null:/* @__PURE__ */ U(`p`,{class:`${zf}-toolui-subtle`,children:t.approvalSubmitting})]}):d&&(v=/* @__PURE__ */ U(Ze,{}));let y=u||f||p||d&&g!==!1;return/* @__PURE__ */ U(`div`,{class:`${zf}-toolui-group`,"data-testid":c.decided?Z.toolDecision:Z.toolApproval,children:[/* @__PURE__ */ U(Of,{part:e,strings:t,superseded:m,submitted:f}),m||l||!y?null:/* @__PURE__ */ U(`div`,{class:`${zf}-toolui ${zf}-toolui-body`,children:[v,u?/* @__PURE__ */ U(`div`,{class:`${zf}-toolui-actions`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${zf}-form-skip`,disabled:!n,onClick:()=>a(_,!1),"data-testid":Z.toolReject,children:t.reject}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${zf}-form-submit`,disabled:!n,onClick:()=>a(_,!0),"data-testid":Z.toolApprove,children:t.approve})]}):null,p?/* @__PURE__ */ U(`div`,{class:`${zf}-toolui-actions`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${zf}-form-skip`,onClick:()=>o(_),"data-testid":Z.toolEdit,children:t.edit})}):null]})]})}const Vf=[`text`,`email`,`phone`,`number`,`date`,`single-select`,`multi-select`,`boolean`];function Hf(e){return typeof e==`object`&&!!e}function Uf(e){let t=Hf(e)?e:{},n=(Array.isArray(t.questions)?t.questions:[]).map(Wf).filter(e=>e!==null);return{intro:qf(t.intro),questions:n}}function Wf(e,t){if(!Hf(e))return null;let n=Vf.find(t=>t===e.type)??`text`;return{key:qf(e.key)??`q${t+1}`,question:qf(e.question)??`Please provide the missing information.`,type:n,options:Array.isArray(e.options)?e.options.filter(e=>typeof e==`string`&&e.trim().length>0):void 0,required:typeof e.required==`boolean`?e.required:void 0,helpText:qf(e.helpText)}}function Gf(e){switch(e){case`text`:return`textarea`;case`phone`:return`tel`;case`single-select`:case`boolean`:return`radio`;case`multi-select`:return`multiselect`;default:return e}}function Kf(e,t,n){return e.questions.map(e=>{let r=Gf(e.type),i=e.type===`boolean`?[{value:`yes`,label:t},{value:`no`,label:n}]:(e.options??[]).map(e=>({value:e,label:e}));return{name:e.key,label:e.question,type:r,required:e.required??!1,options:i.length>0?i:void 0,validationHint:e.helpText}})}function qf(e){return typeof e==`string`&&e.trim()?e.trim():void 0}const Jf=u.cssPrefix;function Yf({skipped:e,submitted:t,strings:n}){return e?{status:`superseded`,statusLabel:n.inputSkipped}:t?{status:`responded`,statusLabel:n.statusResponded}:{status:`completed`,statusLabel:n.inputAnswered}}const Xf={text:`qtypeText`,email:`qtypeEmail`,phone:`qtypePhone`,number:`qtypeNumber`,date:`qtypeDate`,"single-select":`qtypeChooseOne`,"multi-select":`qtypeChooseAny`,boolean:`qtypeBoolean`};function Zf(e,t){let n={};for(let r of e)n[r.key]=t[Xf[r.type]];return n}function Qf({part:e,strings:t,active:n,superseded:r=!1,continuationStreaming:i=!1,onDecision:a,onEdit:o}){let s=z(()=>H(()=>e.stateSig.value),[e]).value,c=z(()=>H(()=>e.approvalSig.value),[e]).value,l=z(()=>H(()=>Uf(e.inputSig.value)),[e]).value,{terminal:u,decided:d}=yf(s,c),f=d&&c?.approved===!0,p=i&&!d,m=!d&&!r&&!p,h=!m&&!f&&!p,g=f&&n&&!u,_=l.questions,[v,y]=I(null),b=v??(m||f||p),[x,S]=I(!1),C=_.length>1?Vc:_l,w=m?t.inputRequired:t.inputBadge,T=p?/* @__PURE__ */ U(`p`,{class:`${Jf}-toolui-subtle`,children:t.approvalSubmitting}):m?/* @__PURE__ */ U($f,{req:l,strings:t,active:n,resolve:(t,n)=>a(e.toolCallId,n,t)}):x?/* @__PURE__ */ U(Gd,{fields:Kf(l,t.confirmYes,t.confirmNo),strings:t,submitLabel:t.inputSubmit,onSubmit:()=>{},disabled:!0,hideActions:!0,fieldTypeLabels:Zf(_,t),initialValues:f?ap(_,c?.reason):void 0}):/* @__PURE__ */ U(ep,{questions:_,answers:f?ip(c?.reason):{},strings:t}),{status:E,statusLabel:D}=Yf({skipped:h,submitted:p,strings:t});return/* @__PURE__ */ U(`details`,{class:`${Jf}-toolui ${Jf}-toolui-collapsible${r?` ${Jf}-toolui-stale`:``}`,open:b,onToggle:e=>{let t=e.currentTarget.open;t!==b&&y(t)},"data-testid":m?Z.toolAskQuestions:Z.toolDecision,children:[/* @__PURE__ */ U(`summary`,{class:`${Jf}-toolui-head`,children:[/* @__PURE__ */ U(`span`,{class:`${Jf}-toolui-q-pill`,children:[/* @__PURE__ */ U(C,{}),w]}),/* @__PURE__ */ U(`span`,{class:`${Jf}-toolui-head-end`,children:[m?null:/* @__PURE__ */ U(bf,{status:E,icon:U(h?Bl:zl,{}),label:D}),/* @__PURE__ */ U(`span`,{class:`${Jf}-toolui-chevron`,children:/* @__PURE__ */ U(pl,{})})]})]}),/* @__PURE__ */ U(`div`,{class:`${Jf}-toolui-collapse-body`,children:[l.intro?/* @__PURE__ */ U(`div`,{class:`${Jf}-toolui-desc`,children:l.intro}):null,T,m||p?null:/* @__PURE__ */ U(`div`,{class:`${Jf}-toolui-footer`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${Jf}-toolui-options-toggle`,onClick:()=>S(e=>!e),"data-testid":Z.toolAskOptions,children:[/* @__PURE__ */ U(`span`,{class:`${Jf}-toolui-options-chevron${x?` ${Jf}-open`:``}`,children:/* @__PURE__ */ U(pl,{})}),x?t.hideOptions:t.showOptions]}),g?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Jf}-form-skip`,onClick:()=>o(e.toolCallId),"data-testid":Z.toolEdit,children:t.edit}):null]})]})]})}function $f({req:e,strings:t,active:n,resolve:r}){let i=Kf(e,t.confirmYes,t.confirmNo),a=e.questions.length===1&&e.questions[0]?.type===`text`;return/* @__PURE__ */ U(Gd,{fields:i,strings:t,disabled:!n,submitLabel:t.inputSubmit,footerHint:a?t.inputSubmitHint:void 0,onSubmit:t=>r(np(e.questions,t),!0),skipLabel:t.inputSkip,onSkip:()=>r(void 0,!1),submitOnEnter:a,fieldTypeLabels:Zf(e.questions,t),submitTestId:Z.toolInputSubmit,skipTestId:Z.toolInputSkip})}function ep({questions:e,answers:t,strings:n}){return/* @__PURE__ */ U(`div`,{class:`${Jf}-toolui-summary`,"data-testid":Z.toolAskSummary,children:e.map(e=>/* @__PURE__ */ U(`div`,{class:`${Jf}-field`,children:[/* @__PURE__ */ U(`span`,{class:`${Jf}-field-head`,children:/* @__PURE__ */ U(`span`,{class:`${Jf}-field-label`,children:[e.question,e.required?/* @__PURE__ */ U(`span`,{class:`${Jf}-field-req`,"aria-hidden":`true`,children:` *`}):null]})}),/* @__PURE__ */ U(`p`,{class:`${Jf}-toolui-answer`,children:tp(e,t[e.key],n)||`—`})]},e.key))})}function tp(e,t,n){return e.type===`boolean`?t===`yes`?n.confirmYes:t===`no`?n.confirmNo:t??``:t??``}function np(e,t){let n=e.flatMap(e=>{let n=t[e.key];if(n==null||n.trim()===``)return[];let r=e.type===`multi-select`?n.split(`,`).map(e=>e.trim()).filter(Boolean):n;return[{key:e.key,value:r}]});return JSON.stringify({answers:n})}function rp(e){if(!e)return{};let t=(()=>{try{return JSON.parse(e)}catch{return}})()?.answers;if(!Array.isArray(t))return{};let n={};for(let e of t)if(e&&typeof e==`object`&&`key`in e){let{key:t,value:r}=e;if(typeof t!=`string`)continue;typeof r==`string`?n[t]=r:Array.isArray(r)&&(n[t]=r.filter(e=>typeof e==`string`))}return n}function ip(e){let t=rp(e),n={};for(let[e,r]of Object.entries(t))n[e]=Array.isArray(r)?r.join(`, `):r;return n}function ap(e,t){let n=rp(t),r={};for(let t of e){let e=n[t.key];e!==void 0&&(t.type===`multi-select`?r[t.key]=Array.isArray(e)?e:[e]:r[t.key]=Array.isArray(e)?e[0]??``:e)}return r}function op({part:e,strings:t,live:n,superseded:r}){let i=z(()=>H(()=>e.inputSig.value),[e]),a=z(()=>H(()=>e.outputSig.value),[e]),o=z(()=>H(()=>e.errorSig.value),[e]),s=Te(e.toolMetadata);if(!z(()=>H(()=>!!jf(i.value)||!!o.value||!!jf(Af(a.value))),[i,a,o]).value&&!s)return null;let c=a.value===void 0&&!o.value;return/* @__PURE__ */ U(Of,{part:e,strings:t,testid:Z.toolCall,live:n||s&&!r,incomplete:s&&r&&c})}const sp=u.cssPrefix,cp=rf(lp);function lp({message:e,status:t,strings:n,responseMode:r,showReasoning:i,showToolCalls:a,showSources:o,interactive:s=!1,superseded:c=!1,tool:l,onRetry:u,enableMessageFeedback:d=!1,onFeedback:f}){let p=[...z(()=>H(()=>e.partsSig.value),[e]).value];for(let t of e.attachments??[])t.url&&!p.some(e=>e.kind===`file`&&e.url===t.url)&&p.push({kind:`file`,url:t.url,mediaType:t.mediaType});let m=z(()=>H(()=>qs(e)),[e]),h=z(()=>H(()=>Ys(e)),[e]),g=z(()=>H(()=>Mf(e)),[e]),_=z(()=>H(()=>i&&Nf(e)),[e,i]),v=t===`streaming`,y=e.role===`assistant`&&v,b=Ff({streaming:y,responseMode:r,reasoningVisible:_.value,hasAnswerText:g.value,emptyReply:m.value,hidden:h.value}),{bufferedHold:x,working:S,showStreamDots:C}=b;if(b.hidden)return null;let w=dp(e.createdAt),T=e.role===`assistant`||e.role===`operator`,E=d&&!!f&&!!e.serverMessageId&&T&&!v&&t!==`error`&&!m.value,D=v?``:p.filter(e=>e.kind===`text`).map(t=>e.role===`assistant`?$o(t.textSig.peek()):t.textSig.peek()).join(`
60
60
 
61
- `).trim(),E=!v&&t!==`error`&&!m.value&&T.length>0,D=w||E;return/* @__PURE__ */ U(`div`,{class:`${gf}-bubble-row`,"data-role":e.role,"data-testid":Zc(Z.messageBubble,e.serverMessageId??e.id),children:/* @__PURE__ */ U(`div`,{class:`${gf}-bubble-col`,children:[/* @__PURE__ */ U(`div`,{class:`${gf}-bubble`,children:[e.role===`operator`&&e.operatorInitials?/* @__PURE__ */ U(`span`,{class:`${gf}-bubble-author`,children:e.operatorInitials}):null,/* @__PURE__ */ U(`div`,{class:`${gf}-bubble-body`,children:[x?/* @__PURE__ */ U(Ef,{label:n.loading}):p.map((r,u)=>/* @__PURE__ */ U(xf,{part:r,generativeUi:e.role===`assistant`,active:S,live:y,strings:n,showReasoning:i,showToolCalls:a,showSources:o,interactive:s&&t===`complete`&&(r.kind!==`tool`||Vo(e,u)),superseded:c,continuationStreaming:e.continuationStreaming===!0,tool:l},`${wf(r)}#${u}`)),ee&&/* @__PURE__ */ U(Tf,{}),t===`error`||m.value?/* @__PURE__ */ U(`div`,{class:`${gf}-error`,role:`alert`,children:[/* @__PURE__ */ U(`span`,{children:e.errorText??n.errorGeneric}),u?/* @__PURE__ */ U(`button`,{type:`button`,class:`${gf}-error-retry`,onClick:()=>u(e),"data-testid":Z.messageRetry,children:n.errorRetry}):null]}):null]})]}),C||D?/* @__PURE__ */ U(`div`,{class:`${gf}-bubble-meta`,children:[C?/* @__PURE__ */ U(`time`,{class:`${gf}-bubble-time`,dateTime:C.iso,title:C.full,children:C.short}):null,D?/* @__PURE__ */ U(`div`,{class:`${gf}-bubble-actions`,children:[w&&e.serverMessageId?/* @__PURE__ */ U(Cd,{messageId:e.serverMessageId,initial:e.feedback??null,strings:n,onFeedback:f}):null,E?/* @__PURE__ */ U(yf,{text:T,strings:n}):null]}):null]}):null]})})}function yf({text:e,strings:t}){let[n,r]=L(!1);function i(){navigator.clipboard?.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)}).catch(()=>{})}let a=n?t.copied:t.copy;return/* @__PURE__ */ U(`button`,{type:`button`,class:`${gf}-msg-action`,"data-active":n?`true`:void 0,"aria-label":a,title:a,onClick:i,"data-testid":Z.messageCopy,children:U(n?_c:Uc,{})})}function bf(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 xf({part:e,generativeUi:t,active:n,live:r,strings:i,showReasoning:a,showToolCalls:o,showSources:s,interactive:c,superseded:l,continuationStreaming:u,tool:d}){switch(e.kind){case`step-start`:return null;case`text`:return/* @__PURE__ */ U(ll,{textSig:e.textSig,doneSig:e.doneSig,generativeUi:t,strings:i});case`reasoning`:return a?/* @__PURE__ */ U(Cf,{part:e,active:n,strings:i}):null;case`tool`:return/* @__PURE__ */ U(Sf,{part:e,strings:i,showToolCalls:o,interactive:c,superseded:l,continuationStreaming:u,live:r,tool:d});case`file`:return e.mediaType.startsWith(`image/`)?/* @__PURE__ */ U(`img`,{src:e.url,alt:``,loading:`lazy`}):/* @__PURE__ */ U(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,children:e.url});case`source`:return s?/* @__PURE__ */ U(Kd,{part:e,strings:i}):null}}function Sf({part:e,strings:t,showToolCalls:n,interactive:r,superseded:i,continuationStreaming:a,live:o,tool:s}){let c=B(()=>dr(()=>e.approvalSig.value!==void 0),[e]);return s?.humanInLoop&&c.value?xd(e.toolName)?/* @__PURE__ */ U(sf,{part:e,strings:t,active:r,superseded:i,continuationStreaming:a,onDecision:s.onDecision,onEdit:s.onEdit}):/* @__PURE__ */ U(Jd,{part:e,strings:t,active:r,superseded:i,continuationStreaming:a,onDecision:s.onDecision,onEdit:s.onEdit}):n?/* @__PURE__ */ U(hf,{part:e,strings:t,live:o}):null}function Cf({part:e,active:t,strings:n}){return/* @__PURE__ */ U(`details`,{class:`${gf}-reasoning`,"data-testid":Z.reasoning,open:t,"data-active":t?`true`:void 0,children:[/* @__PURE__ */ U(`summary`,{class:`${gf}-reasoning-summary`,children:/* @__PURE__ */ U(`span`,{class:`${gf}-reasoning-label`,children:t?n.thinking:n.thoughts})}),/* @__PURE__ */ U(`div`,{class:`${gf}-reasoning-body`,children:/* @__PURE__ */ U(ll,{textSig:e.textSig,doneSig:e.doneSig})})]})}function wf(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 Tf(){return/* @__PURE__ */ U(`span`,{class:`${gf}-typing`,"data-testid":Z.typingDots,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`span`,{}),/* @__PURE__ */ U(`span`,{}),/* @__PURE__ */ U(`span`,{})]})}function Ef({label:e}){return/* @__PURE__ */ U(`span`,{class:`${gf}-loading`,role:`status`,children:[/* @__PURE__ */ U(`span`,{class:`${gf}-loading-spinner`,"aria-hidden":`true`}),/* @__PURE__ */ U(`span`,{class:`${gf}-loading-label`,children:e})]})}const Df=P.cssPrefix;function Of({messagesSig:e,strings:t,responseMode:n,showReasoning:r,showToolCalls:i,showSources:a,enableMessageFeedback:o,onFeedback:s,loading:c,onLoadPreviousMessages:l,idle:u,controlMode:d=`ai-agent`,tool:f,onRetry:p,form:m,formMarkers:h,onFillForm:g}){let _=z(null),v=Dr(()=>e.value),[y,b]=L(!1),[x,S]=L(!1),ee=z(!1),C=z(!1),[te,w]=L(),T=z(!1),E=z(!1),D=z(!1),O=z(0);function ne(){return D.current||performance.now()-O.current<350}let k=z(0);function A(e){let t=e.scrollHeight-e.clientHeight>1;e.dataset.fadeTop=t&&e.scrollTop>1?`true`:`false`,e.dataset.fadeBottom=t&&e.scrollHeight-e.scrollTop-e.clientHeight>1?`true`:`false`}function re(e){return b(e.scrollHeight-e.scrollTop-e.clientHeight>240)}function j(e){k.current=performance.now(),e.scrollTop=e.scrollHeight,A(e)}function ie(e,t){j(e);let n=t,r=0;function i(){E.current||ne()||(j(e),--n>0&&(r=requestAnimationFrame(i)))}return t>0&&(r=requestAnimationFrame(i)),()=>cancelAnimationFrame(r)}function M(e,t){let n,r,i,a=-1;function o(){n.disconnect(),r.disconnect(),clearTimeout(i)}function s(){if(E.current||ne()||a>=0&&e.scrollTop<a-4)return o();j(e),a=e.scrollTop}return n=new ResizeObserver(s),r=new MutationObserver(s),s(),n.observe(e),r.observe(e,{childList:!0,subtree:!0,characterData:!0}),i=setTimeout(o,t),o}let ae=v.value[0]?.id;Ln(()=>{let e=_.current;if(e&&v.value.length!==0&&!C.current&&(T.current=!0,v.value.some(e=>e.role===`user`)))return M(e,300)},[ae]);let oe=z(0);R(()=>{let e=_.current,t=v.value,n=oe.current;if(oe.current=t.length,e&&T.current&&!C.current){if(t.slice(n).some(e=>e.role===`user`))return E.current=!1,ie(e,3);t.some(e=>e.role===`user`)&&(E.current||ne()||e.scrollHeight-e.scrollTop-e.clientHeight<120&&j(e))}},[v.value.length]);let se=z(null);R(()=>{let e=_.current,t=v.value.at(-1),n=se.current;if(se.current=t?{id:t.id,streaming:t.status===`streaming`}:null,e&&T.current&&t&&t.id===n?.id&&!n.streaming&&t.status===`streaming`)return E.current=!1,ie(e,3)},[v.value]),R(()=>{let e=_.current;if(!e)return;let t=v.value.at(-1);if(!t||t.status!==`streaming`&&!v.value.some(e=>e.role===`user`))return;let n=()=>{E.current||ne()||e.scrollHeight-e.scrollTop-e.clientHeight<240&&j(e)};if(t.status!==`streaming`)return M(e,300);n();let r=new MutationObserver(n);return r.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>r.disconnect()},[v.value]);let ce=m?.form.id,le=!!m&&(h??[]).some(e=>e.formId===m.form.id);Ln(()=>{let e=_.current;e&&ce&&!E.current&&v.value.some(e=>e.role===`user`)&&(le?e.querySelector(`[data-testid="${Z.formGate}"]`)?.scrollIntoView({block:`nearest`}):j(e))},[ce,le]),R(()=>{let e=_.current;if(!e)return;let t=()=>{re(e),A(e),performance.now()-k.current>150&&(E.current=e.scrollHeight-e.scrollTop-e.clientHeight>8)};function n(){E.current=!0}function r(e){e.deltaY<0&&n()}let i=0;function a(e){i=e.touches[0]?.clientY??0,D.current=!0}function o(e){(e.touches[0]?.clientY??0)>i+4&&n()}function s(){D.current=!1,O.current=performance.now()}function c(){D.current=!0}return e.addEventListener(`scroll`,t,{passive:!0}),e.addEventListener(`wheel`,r,{passive:!0}),e.addEventListener(`touchstart`,a,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`touchend`,s,{passive:!0}),e.addEventListener(`touchcancel`,s,{passive:!0}),e.addEventListener(`pointerdown`,c,{passive:!0}),window.addEventListener(`pointerup`,s,{passive:!0}),window.addEventListener(`pointercancel`,s,{passive:!0}),re(e),()=>{e.removeEventListener(`scroll`,t),e.removeEventListener(`wheel`,r),e.removeEventListener(`touchstart`,a),e.removeEventListener(`touchmove`,o),e.removeEventListener(`touchend`,s),e.removeEventListener(`touchcancel`,s),e.removeEventListener(`pointerdown`,c),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)}},[]);function ue(){let e=_.current;e&&(E.current=!1,j(e))}let de=v.value.filter(e=>!e.ephemeral),fe=de[0],pe=fe?.serverMessageId??fe?.id,me=!!(l&&de.length>=50&&pe!==te);async function he(){if(!l||ee.current)return;let e=_.current,t=e?.scrollHeight??0,n=e?.scrollTop??0;ee.current=!0,C.current=!0,S(!0);try{let r=await l();r===!1&&pe&&w(pe),r&&e&&(await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e()))),e.scrollTop=n+e.scrollHeight-t,A(e),re(e))}finally{C.current=!1,ee.current=!1,S(!1)}}let ge=[],N=``,_e=v.value.at(-1)?.id,ve=[...h??[]].toSorted((e,t)=>(e.createdAt??1/0)-(t.createdAt??1/0));function ye(e){return m&&e.formId===m.form.id?/* @__PURE__ */ U(sd,{form:m.form,strings:t,onSubmit:m.onSubmit,onSkip:m.onSkip},`gate:${e.formId}`):/* @__PURE__ */ U(cd,{marker:e,strings:t,onFill:!m&&g?()=>g(e.formId):void 0},e.key)}function be(e){for(let t=ve[0];t?.createdAt!==void 0&&!(e!==void 0&&t.createdAt>e);t=ve[0])ve.shift(),ge.push(ye(t))}for(let e of v.value){if(e.role===`assistant`&&e.id!==_e&&ts(e))continue;be(e.createdAt);let c=kf(e.createdAt);c&&c!==N&&(ge.push(/* @__PURE__ */ U(`div`,{class:`${Df}-date-divider`,children:/* @__PURE__ */ U(`span`,{class:`${Df}-date-pill`,title:Af(e.createdAt),children:jf(e.createdAt,t)})},`day:${c}`)),N=c);let l=e.retryAction!==void 0||e.role===`assistant`&&e.id===_e?ns(v.value,e):void 0,m=l!==void 0&&(l.kind!==`continue-assistant`||d===`ai-agent`);ge.push(/* @__PURE__ */ U(_f,{message:e,status:e.status,strings:t,responseMode:n,showReasoning:r,showToolCalls:i,showSources:a,interactive:!!u&&d===`ai-agent`&&e.id===_e,superseded:e.id!==_e,tool:f,onRetry:u&&m&&(e.role===`user`||e.id===_e)?p:void 0,enableMessageFeedback:o,onFeedback:s},e.id))}for(let e of ve)ge.push(ye(e));return/* @__PURE__ */ U(`div`,{class:`${Df}-list-wrap`,children:[/* @__PURE__ */ U(`div`,{ref:_,class:`${Df}-list ${Df}-list--fade`,part:`messages`,role:`log`,"aria-live":`polite`,"aria-relevant":`additions text`,children:[c&&v.value.length===0?/* @__PURE__ */ U(`div`,{class:`${Df}-list-loading`,role:`status`,children:t.conversationLoading}):null,me?/* @__PURE__ */ U(`div`,{class:`${Df}-load-previous`,children:/* @__PURE__ */ U(`button`,{type:`button`,onClick:he,disabled:x,"aria-busy":x,"data-testid":Z.loadPreviousMessages,children:t.loadPreviousMessages})}):null,ge,m&&!le?/* @__PURE__ */ U(sd,{form:m.form,strings:t,onSubmit:m.onSubmit,onSkip:m.onSkip}):null]}),y?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Df}-jump`,onClick:ue,"aria-label":t.scrollToBottom,title:t.scrollToBottom,"data-testid":Z.scrollToBottom,children:/* @__PURE__ */ U(Sc,{})}):null]})}function kf(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function Af(e){if(typeof e!=`number`||!Number.isFinite(e))return``;try{return new Date(e).toLocaleDateString(void 0,{dateStyle:`full`})}catch{return``}}function jf(e,t){let n=new Date(e);function r(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}let i=Math.round((r(/* @__PURE__ */ 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`})}function Mf({panelEl:e,resize:t,position:n,initialSize:r,onSizeChange:i,strings:a}){let o=P.cssPrefix,s=z(null);if(R(()=>{if(!e)return;let n=e.style;t.minWidth&&n.setProperty(`--${o}-resize-min-w`,t.minWidth),t.maxWidth&&n.setProperty(`--${o}-resize-max-w`,t.maxWidth),t.minHeight&&n.setProperty(`--${o}-resize-min-h`,t.minHeight),t.maxHeight&&n.setProperty(`--${o}-resize-max-h`,t.maxHeight),r&&(n.setProperty(`--${o}-widget-w`,`${r.width}px`),n.setProperty(`--${o}-widget-h`,`${r.height}px`))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,o,r]),!e)return null;let c=n.startsWith(`top-`),l=n.endsWith(`-right`),u=`${o}-resize-grip ${o}-resize-grip--${c?`bottom`:`top`}-${l?`left`:`right`}`;function d(t){if(!e)return;let n=t.currentTarget,r=e.getBoundingClientRect();s.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startW:r.width,startH:r.height,dirX:l?-1:1,dirY:c?1:-1},n.setPointerCapture(t.pointerId),e.setAttribute(`data-resizing`,``),t.preventDefault()}function f(t){let n=s.current;if(!n||t.pointerId!==n.pointerId||!e)return;let r=(t.clientX-n.startX)*n.dirX,i=(t.clientY-n.startY)*n.dirY;e.style.setProperty(`--${o}-widget-w`,`${n.startW+r}px`),e.style.setProperty(`--${o}-widget-h`,`${n.startH+i}px`)}function p(t){let n=s.current;if(!n||t.pointerId!==n.pointerId||!e)return;t.currentTarget.releasePointerCapture(t.pointerId),e.removeAttribute(`data-resizing`);let r=e.getBoundingClientRect();i({width:Math.round(r.width),height:Math.round(r.height)}),s.current=null}return/* @__PURE__ */ U(`div`,{class:u,role:`separator`,"aria-orientation":`vertical`,"aria-label":a.resizeHandle,title:a.resizeHandle,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,"data-testid":Z.resizeGrip,children:/* @__PURE__ */ U(dc,{})})}const Nf=P.cssPrefix;function Pf({suggestions:e,onPick:t,disabled:n=!1}){return e.length===0?null:/* @__PURE__ */ U(`div`,{class:`${Nf}-suggestions`,role:`group`,"aria-label":`Suggested replies`,children:e.map((e,r)=>/* @__PURE__ */ U(`button`,{type:`button`,class:`${Nf}-suggestion`,onClick:()=>t(e),disabled:n,"data-testid":Zc(Z.suggestion,r),children:e.label},e.id))})}const Ff=P.cssPrefix,If=`.${Ff}-header, .${Ff}-back-header, .${Ff}-home-hero`;function Lf(e,t){R(()=>{if(!t||!e)return;function n(e){return Number.parseFloat(e)||0}function r(e,t){return Math.min(t,Math.max(-t,e))}let i=null,a=t=>{let r=t.target;if(!(r instanceof Element)||!r.closest(If)||r.closest(`button, a, input, textarea, select, [role="tab"], [contenteditable]`))return;let a=e.getBoundingClientRect();i={id:t.pointerId,x:t.clientX,y:t.clientY,dx:n(e.style.getPropertyValue(`--${Ff}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${Ff}-modal-dy`)),maxX:(window.innerWidth+a.width)/2-56,maxY:(window.innerHeight+a.height)/2-56},e.dataset.dragging=`true`,t.preventDefault()},o=t=>{if(!i||t.pointerId!==i.id)return;let n=r(i.dx+t.clientX-i.x,i.maxX),a=r(i.dy+t.clientY-i.y,i.maxY);e.style.setProperty(`--${Ff}-modal-dx`,`${n}px`),e.style.setProperty(`--${Ff}-modal-dy`,`${a}px`)},s=t=>{i&&t.pointerId===i.id&&(i=null,delete e.dataset.dragging)};return e.addEventListener(`pointerdown`,a),window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s),()=>{e.removeEventListener(`pointerdown`,a),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)}},[e,t])}function Rf({containerRef:e,onDrop:t,disabled:n=!1}){let[r,i]=L(!1);return R(()=>{if(n){i(!1);return}let r=e.current;if(!r)return;let a=0;function o(e){a+=1,e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),i(!0))}function s(){--a,!(a>0)&&(a=0,i(!1))}function c(e){e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()}function l(e){a=0,i(!1),e.dataTransfer&&(e.preventDefault(),t(e.dataTransfer.items))}return r.addEventListener(`dragenter`,o),r.addEventListener(`dragleave`,s),r.addEventListener(`dragover`,c),r.addEventListener(`drop`,l),()=>{r.removeEventListener(`dragenter`,o),r.removeEventListener(`dragleave`,s),r.removeEventListener(`dragover`,c),r.removeEventListener(`drop`,l)}},[e,n,t]),{visible:!n&&r}}const zf=P.cssPrefix;function Bf(e){let{options:t,onClose:n}=e,r=t.strings,i=z(null);R(()=>{let e=i.current;if(!e)return;let t=al(e);function r(e){e.key===`Escape`&&n?.()}return e.addEventListener(`keydown`,r),()=>{t(),e.removeEventListener(`keydown`,r)}},[n]);let a=e.composerApiRef,o=e.composerActive&&e.view===`chat`&&e.canSend&&!e.activeForm&&!e.sendPreparing&&e.options.features.fileUpload,{visible:s}=Rf({containerRef:i,onDrop:V(e=>{o&&a.current?.attachFromDrop(e)},[a,o]),disabled:!o});return Lf(i.current,t.mode===`modal`),/* @__PURE__ */ U(`div`,{ref:i,class:`${zf}-panel`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":r.panelTitle,style:{position:`relative`},"data-testid":Z.panel,children:[/* @__PURE__ */ U(Vf,{...e,containerEl:i.current,dragOver:s}),/* @__PURE__ */ U(qf,{poweredBy:e.options.poweredBy})]})}function Vf(e){let{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,composerKey:s,panelSize:c,view:l,canSend:u,isStreaming:d,isMemoryCompacting:f,canReleaseQueuedMessages:p,queueManualMessages:m,sendPreparing:h,controlMode:g,assignedOperatorInitials:_,operatorAvailable:v,operatorRequestEnabled:y,onRequestOperator:b,onCancelOperatorRequest:x,loadingMessages:S,onLoadPreviousMessages:ee,messagesSig:C,agent:te,suggestions:w,initialWidgetSize:T,onClose:E,onBack:D,onClear:ne,onToggleHistory:k,onSelectHistoryConversation:A,onNewConversation:re,onWidgetSizeChange:j,onSend:ie,onStop:M,onSuggestion:ae,activeForm:oe,formMarkers:se,onFormSubmit:ce,onFormSkip:le,onFormFill:ue,tool:de,onRetry:fe,onMessageFeedback:pe,containerEl:me,dragOver:he,composerApiRef:ge}=e,N=t.strings,_e=Dr(()=>C.value.some(e=>!e.ephemeral&&e.role!==`system`)).value,ve;return ve=oe?null:u?/* @__PURE__ */ U(O,{children:[g&&g!==`ai-agent`?/* @__PURE__ */ U(Wf,{controlMode:g,operatorInitials:_,operatorAvailable:v,onCancelOperatorRequest:x,strings:N}):null,f&&g===`ai-agent`?/* @__PURE__ */ U(`div`,{class:`${zf}-loading ${zf}-compaction-status`,role:`status`,"data-testid":Z.compactionStatus,children:[/* @__PURE__ */ U(`span`,{class:`${zf}-loading-spinner`,"aria-hidden":`true`}),N.compactingContext]}):null,!d&&!f&&g===`ai-agent`&&/* @__PURE__ */ U(Pf,{suggestions:w,onPick:ae,disabled:h}),/* @__PURE__ */ U(du,{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,isStreaming:d,isMemoryCompacting:f,canReleaseQueuedMessages:p,queueManualMessages:m,active:e.composerActive&&l===`chat`,isPreparing:h,operatorRequestEnabled:y,canRequestOperator:_e,controlMode:g,onRequestOperator:b,onSend:ie,onStop:M,apiRef:ge},s)]}):/* @__PURE__ */ U(Uf,{label:N.conversationClosed,ctaLabel:N.startNewConversation,onNewConversation:ne}),/* @__PURE__ */ U(O,{children:[l===`history`?/* @__PURE__ */ U(Hf,{strings:N,onBack:k,onClose:E,showClose:Ms(t.mode,c,t.actions)}):/* @__PURE__ */ U(`header`,{class:`${zf}-header`,part:`header`,"data-testid":Z.panelHeader,children:[D?/* @__PURE__ */ U(`button`,{type:`button`,class:`${zf}-icon-btn`,onClick:D,"aria-label":N.moduleBack,title:N.moduleBack,children:/* @__PURE__ */ U(bc,{})}):null,te?/* @__PURE__ */ U(Mu,{agent:te,strings:N}):/* @__PURE__ */ U(`h1`,{children:N.panelTitle}),/* @__PURE__ */ U(Dl,{panelProps:e,variant:`chat`})]}),l===`history`?/* @__PURE__ */ U(Vu,{transport:n,strings:N,locale:t.locale,persistence:a,onSelect:A,onNewConversation:re}):/* @__PURE__ */ U(O,{children:[/* @__PURE__ */ U(Uu,{visible:he,strings:N}),/* @__PURE__ */ U(Of,{messagesSig:C,strings:N,responseMode:t.responseMode,showReasoning:t.showReasoning,showToolCalls:t.showToolCalls,showSources:t.showSources,enableMessageFeedback:t.enableMessageFeedback,onFeedback:pe,loading:S,onLoadPreviousMessages:ee,idle:!d&&!h&&u&&!oe,controlMode:g,tool:de,onRetry:fe,form:oe?{form:oe,onSubmit:ce,onSkip:le}:null,formMarkers:se,onFillForm:ue}),ve,/* @__PURE__ */ U(Kf,{disclaimer:t.composerDisclaimer})]}),t.size.resize?.enabled?/* @__PURE__ */ U(Mf,{panelEl:me,resize:t.size.resize,position:t.position,initialSize:T,onSizeChange:j,strings:N}):null]})}function Hf({strings:e,onBack:t,onClose:n,showClose:r}){return/* @__PURE__ */ U(`header`,{class:`${zf}-header`,part:`header`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${zf}-icon-btn`,onClick:t,"aria-label":e.historyBack,title:e.historyBack,children:/* @__PURE__ */ U(bc,{})}),/* @__PURE__ */ U(`h1`,{children:e.historyTitle}),r?/* @__PURE__ */ U(`button`,{type:`button`,class:`${zf}-icon-btn`,onClick:n,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ U(Zs,{})}):null]})}function Uf({label:e,ctaLabel:t,onNewConversation:n}){return/* @__PURE__ */ U(`div`,{class:`${zf}-readonly-banner`,role:`note`,children:[/* @__PURE__ */ U(`span`,{class:`${zf}-readonly-label`,children:e}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${zf}-readonly-cta`,onClick:n,children:t})]})}function Wf({controlMode:e,operatorInitials:t,operatorAvailable:n,onCancelOperatorRequest:r,strings:i}){let a=Gf(e,t,n,i);return/* @__PURE__ */ U(`div`,{class:`${zf}-operator-banner`,role:`status`,"data-mode":e,"data-testid":Z.operatorBanner,children:[/* @__PURE__ */ U(`span`,{class:`${zf}-operator-pulse`,"aria-hidden":`true`}),/* @__PURE__ */ U(`span`,{class:`${zf}-operator-label`,children:a}),e===`awaiting-operator`&&r?/* @__PURE__ */ U(`button`,{type:`button`,class:`${zf}-cancel-operator-request`,"data-testid":Z.cancelOperatorRequest,onClick:r,children:i.cancelOperatorRequest}):null]})}function Gf(e,t,n,r){return e===`operator`?r.chattingWithOperator.replace(`{operator}`,t??``):n===!1?r.noOperatorAvailable:r.connectingOperator}function Kf({disclaimer:e}){return e?/* @__PURE__ */ U(`div`,{class:`${zf}-composer-footer`,children:/* @__PURE__ */ U(`div`,{class:`${zf}-disclaimer`,children:e})}):null}function qf({poweredBy:e}){return e?/* @__PURE__ */ U(`div`,{class:`${zf}-poweredby-bar`,children:/* @__PURE__ */ U(Jf,{logoUrl:e.logoUrl,text:e.text,href:e.href})}):null}function Jf({logoUrl:e,text:t,href:n}){let r=/* @__PURE__ */ U(O,{children:[e?/* @__PURE__ */ U(`img`,{class:`${zf}-poweredby-logo`,src:e,alt:``,loading:`lazy`}):null,t?/* @__PURE__ */ U(`span`,{children:t}):null]});return n?/* @__PURE__ */ U(`a`,{class:`${zf}-poweredby`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:r}):/* @__PURE__ */ U(`span`,{class:`${zf}-poweredby`,children:r})}const Yf=P.cssPrefix;function Xf({panelProps:e,enabledModules:t,nav:n,bus:r,hasUnread:i,latestNews:a,onSelectConversation:o,onStartNewConversation:s,onSetPanelSize:c}){let l=e.options,u=l.strings,d=z(null),f=z(/* @__PURE__ */ new Set);R(()=>{let t=d.current;if(!t)return;let n=al(t);function r(t){t.key===`Escape`&&e.onClose?.()}return t.addEventListener(`keydown`,r),()=>{n(),t.removeEventListener(`keydown`,r)}},[e.onClose]);let p=Dr(()=>n.sig.value).value,m=Us(p),h=l.modules.byId[p.activeTab],g=e.composerActive&&h?.layout===`chat`&&m===void 0,_=e.composerApiRef,v=g&&e.view===`chat`&&e.canSend&&!e.activeForm&&!e.sendPreparing&&e.options.features.fileUpload,{visible:y}=Rf({containerRef:d,onDrop:V(e=>{v&&_.current?.attachFromDrop(e)},[_,v]),disabled:!v});Lf(d.current,l.mode===`modal`);let b=m?.kind===`iframe`||m?.kind===`content`,x=t.length>1&&(Ws(p)||!b),S=z(null);R(()=>{if(b&&S.current===null)S.current=e.panelSize,e.panelSize===`normal`&&c(`expanded`);else if(!b&&S.current!==null){let e=S.current;S.current=null,c(e)}},[b]);let ee={push:e=>n.push(e),pop:()=>n.pop(),switchTab:e=>n.switchTab(e),switchToLayout:e=>{let r=t.find(t=>t.layout===e);r&&n.switchTab(r.id)},selectConversation:o,startNewConversation:s};function C(t){return{options:l,transport:e.transport,strings:u,config:t,nav:ee,bus:r,panelProps:e,latestNews:a}}let te=/* @__PURE__ */ U(Dl,{panelProps:e,variant:`plain`});h&&f.current.add(h.id);let w=t.filter(e=>f.current.has(e.id));function T(t){if(t.layout===`chat`)return/* @__PURE__ */ U(Vf,{...e,composerActive:g,containerEl:d.current,dragOver:y});let n=Eu[t.layout].Root;return n?/* @__PURE__ */ U(n,{...C(t)}):null}function E(){return m?.kind===`iframe`?/* @__PURE__ */ U(Au,{url:m.url,title:m.title,strings:u,onBack:()=>n.pop(),actions:te}):m?.kind===`content`?/* @__PURE__ */ U(vl,{id:m.id,title:m.title,transport:e.transport,strings:u,bus:r,onBack:()=>n.pop(),actions:te}):null}return/* @__PURE__ */ U(`div`,{ref:d,class:`${Yf}-panel ${Yf}-messenger`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":u.panelTitle,style:{position:`relative`},"data-testid":Z.messengerHome,children:[/* @__PURE__ */ U(`div`,{class:`${Yf}-messenger-body`,children:[w.map(e=>/* @__PURE__ */ U(`div`,{class:`${Yf}-messenger-pane`,hidden:b||e.id!==h?.id,children:T(e)},e.id)),E()]}),x?/* @__PURE__ */ U(Ou,{modules:t,activeTab:p.activeTab,strings:u,hasUnread:i,onSelect:e=>n.switchTab(e)}):null,/* @__PURE__ */ U(qf,{poweredBy:l.poweredBy}),l.size.resize?.enabled&&(h?.layout!==`chat`||m)?/* @__PURE__ */ U(Mf,{panelEl:d.current,resize:l.size.resize,position:l.position,initialSize:e.initialWidgetSize,onSizeChange:e.onWidgetSizeChange,strings:u}):null]})}const Zf=P.cssPrefix;function Qf({strings:e,onClose:t}){return/* @__PURE__ */ U(`div`,{class:`${Zf}-panel ${Zf}-modules-empty`,part:`panel`,role:`dialog`,"aria-label":e.panelTitle,"data-testid":Z.modulesEmpty,children:[t?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Zf}-icon-btn ${Zf}-modules-empty-close`,onClick:t,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ U(Zs,{})}):null,/* @__PURE__ */ U(`p`,{class:`${Zf}-modules-empty-text`,children:e.modulesEmpty})]})}function $f(e){let t=P.cssPrefix,{site:n,blocks:r,strings:i,collapsed:a}=e,o=r?.navigation??[],s=r?.linkCards??[],c=a?i.expandSidebar:i.collapseSidebar;return/* @__PURE__ */ U(`aside`,{class:`${t}-sidebar`,"data-collapsed":a?`true`:`false`,"data-testid":Z.sidebar,children:[/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-header`,children:[/* @__PURE__ */ U(ep,{site:n}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${t}-sidebar-toggle`,"aria-label":c,"aria-expanded":a?`false`:`true`,title:c,onClick:e.onToggleCollapsed,"data-testid":Z.sidebarToggle,children:/* @__PURE__ */ U(tp,{collapsed:a})})]}),a?null:/* @__PURE__ */ U(O,{children:[o.length>0?/* @__PURE__ */ U(`nav`,{class:`${t}-sidebar-section`,"data-section":`navigation`,children:/* @__PURE__ */ U(np,{items:o})}):null,s.length>0?/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-section`,"data-section":`link-cards`,children:/* @__PURE__ */ U(rp,{items:s})}):null,e.showConversations?/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-conversations`,children:/* @__PURE__ */ U(Vu,{transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,onSelect:e.onSelectConversation,onNewConversation:e.onNewConversation})}):null]})]})}function ep({site:e}){let t=P.cssPrefix;if(e?.logo?.url){let n=e.logo.alt??e.title??`Logo`;return/* @__PURE__ */ U(`picture`,{children:[e.logoDark?.url?/* @__PURE__ */ U(`source`,{srcset:e.logoDark.url,media:`(prefers-color-scheme: dark)`}):null,/* @__PURE__ */ U(`img`,{class:`${t}-sidebar-logo`,src:e.logo.url,alt:n})]})}return/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-title`,children:e?.title??P.name})}function tp({collapsed:e}){return/* @__PURE__ */ U(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`,children:e?/* @__PURE__ */ U(`polyline`,{points:`9 6 15 12 9 18`}):/* @__PURE__ */ U(`polyline`,{points:`15 6 9 12 15 18`})})}function np({items:e}){let t=P.cssPrefix;return/* @__PURE__ */ U(`ul`,{class:`${t}-sidebar-nav`,children:e.map(e=>/* @__PURE__ */ U(`li`,{children:/* @__PURE__ */ U(`a`,{class:`${t}-sidebar-nav-item`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[e.icon?/* @__PURE__ */ U(`span`,{class:`${t}-sidebar-nav-icon`,"data-icon":e.icon}):null,/* @__PURE__ */ U(`span`,{class:`${t}-sidebar-nav-label`,children:e.label})]})},e.id??e.label))})}function rp({items:e}){let t=P.cssPrefix;return/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-cards`,children:e.map(e=>/* @__PURE__ */ U(`a`,{class:`${t}-sidebar-card`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-card-label`,children:e.label}),e.description?/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-card-desc`,children:e.description}):null]},e.id??e.label))})}const ip=P.cssPrefix;function ap(e){return/* @__PURE__ */ U(`main`,{class:`${ip}-page-shell`,"data-sidebar-collapsed":e.sidebarCollapsed?`true`:`false`,children:[/* @__PURE__ */ U($f,{site:e.site,blocks:e.blocks,transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,showConversations:e.showConversations,onSelectConversation:e.onSelectConversation,onNewConversation:e.onNewConversation,collapsed:e.sidebarCollapsed,onToggleCollapsed:e.onToggleSidebarCollapsed}),/* @__PURE__ */ U(`section`,{class:`${ip}-page-chat`,"aria-label":e.strings.panelTitle,children:e.children})]})}const op=I.scope(`hitl`);function sp(e){let{streaming:t,controlModeSig:n,messagesSig:r,sendAiTurn:i,bus:a,humanInLoop:o}=e,s=z(t);s.current=t;let c=V((e,t,a)=>{if(s.current||n.value!==`ai-agent`)return!1;let o=r.value.at(-1),c=o?.partsSig.value.findIndex(t=>t.kind===`tool`&&t.toolCallId===e)??-1,l=o?.partsSig.value[c];return!o||l?.kind!==`tool`?(op.warn(`decideTool: tool part not found`,{toolCallId:e}),!1):o.status!==`complete`||!Vo(o,c)||!t(l)?!1:(a(l),o.partsSig.value=[...o.partsSig.value],zo(o)&&(o.status=`streaming`,o.retryAction={kind:`continue-assistant`,messageId:o.serverMessageId??o.id},o.awaitingContinuation=!0,r.value=[...r.value],i({continueExisting:!0})),!0)},[n,r,i]),l=V((e,t,n)=>{let r=!1;c(e,e=>e.stateSig.value===`approval-requested`,i=>{r=xd(i.toolName);let a=i.approvalSig.value?.id??e;i.approvalSig.value={id:a,approved:t,reason:n},i.stateSig.value=`approval-responded`})&&(r?(op.info(`toolResult`,{toolCallId:e}),a.emit(`toolResult`,{toolCallId:e})):(op.info(`toolDecision`,{toolCallId:e,approved:t}),a.emit(`toolDecision`,{toolCallId:e,approved:t})))},[a,c]),u=V(e=>{c(e,e=>e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved!==void 0,t=>{let n=t.approvalSig.value?.id??e;t.approvalSig.value={id:n},t.stateSig.value=`approval-requested`})},[c]);return{toolInteraction:B(()=>({humanInLoop:o,onDecision:l,onEdit:u}),[o,l,u])}}const cp=I.scope(`latest-news`);function lp({transport:e,options:t,persistence:n,enabled:r}){let i=t.modules.list.find(e=>e.layout===`news`)?.contentCollectionIds,a=i?.join(`,`),[o,s]=L(),[c,l]=L(()=>n.loadSeenNewsId());R(()=>{if(!r||!i?.length)return;let t=!1;return e.listContent({contentCollectionIds:i,sortBy:`publishedAt`,sortOrder:`desc`,limit:1}).then(e=>{t||s(e.items[0])}).catch(e=>cp.debug(`listContent (latest news) failed (non-fatal)`,{err:e})),()=>{t=!0}},[e,r,a]);let u=V(e=>{n.saveSeenNewsId(e),l(e)},[n]);return{item:o,unseen:o!==void 0&&o.id!==c,markSeen:u}}function up({callout:e,persistence:t}){let n=e?.text??``,r=e?.persistent??!0,[i,a]=L(()=>!r&&t.loadCalloutDismissed(n));return R(()=>{a(!r&&t.loadCalloutDismissed(n))},[n,r,t]),{dismissed:i,dismissCallout:V(()=>{a(!0),r||t.saveCalloutDismissed(n)},[t,n,r])}}function dp(e){let{transport:t,conversationIdSig:n}=e,r=Er(`ai-agent`),i=Er(void 0),a=Er(void 0),o=z(void 0),s=V(e=>{let t=e.controlRevision,s=o.current;s&&s.conversationId===n.value&&t<s.revision||(o.current={conversationId:n.value,revision:t},r.value=e.controlMode,i.value=e.assignedOperatorInitials,e.controlMode===`awaiting-operator`?e.operatorAvailable!==void 0&&(a.value=e.operatorAvailable):a.value=void 0)},[n,r,i,a]);return{controlModeSig:r,assignedOperatorInitialsSig:i,operatorAvailableSig:a,applyControlState:s,adoptControlStateChunk:V(e=>{if(e.type!==`data-control-state`)return;let t=mo(e.data);t&&s(t)},[s]),requestOperator:V(async()=>{let e=n.value,r=await t.requestOperator();r&&n.value===e&&s(r)},[t,n,s]),cancelOperatorRequest:V(async()=>{let e=n.value,r=await t.cancelOperatorRequest();r&&n.value===e&&s(r)},[t,n,s])}}const fp=P.cssPrefix,pp=`--${fp}-visual-viewport-height`,mp=`--${fp}-visual-viewport-top`;function hp(e){let{hostElement:t,mode:n,panelSize:r,isOpen:i,surfaceReady:a,setIsOpen:o}=e;Ln(()=>{vn(t,Gs(n,r,i))},[t,i,r,n]),Ln(()=>{if(!i||!a)return;let e=t.ownerDocument.defaultView,n=e?.visualViewport,r=t.shadowRoot?.querySelector(`.${fp}-anchor`);if(!e||!n||!r)return;let o=()=>{r.style.setProperty(pp,`${n.height}px`),r.style.setProperty(mp,`${n.offsetTop}px`)},s=0,c=()=>{e.cancelAnimationFrame(s),s=e.requestAnimationFrame(()=>{s=e.requestAnimationFrame(o)})};return o(),n.addEventListener(`resize`,c),n.addEventListener(`scroll`,c),()=>{e.cancelAnimationFrame(s),n.removeEventListener(`resize`,c),n.removeEventListener(`scroll`,c),r.style.removeProperty(pp),r.style.removeProperty(mp)}},[t,i,a]),R(()=>{if(n!==`modal`||!i)return;function e(e){e.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains(`${fp}-panel`))||o(!1)}return t.addEventListener(`click`,e),()=>t.removeEventListener(`click`,e)},[t,i,n,o]),R(()=>{if(n!==`drawer`||!i)return;function e(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,n,o])}const gp=I.scope(`reducer`);var _p=class{constructor(e,t){this.messagesSig=e,this.onReconcileNeeded=t,s(this,`active`,null),s(this,`openTextParts`,/* @__PURE__ */ new Map),s(this,`partSeq`,0),s(this,`replay`,null)}attach(e){this.active=e,this.openTextParts.clear()}detach(){this.active=null,this.replay=null,this.openTextParts.clear()}beginReplay(e,t){let n=xo();n.id=e.id;let r=yp(e)||Bo(e)&&(e.status!==`streaming`||zo(e)),i=e.status===`streaming`&&zo(e)&&Ro(e);this.replay={baseline:e,shadow:n,chunks:[t],probeContinuation:r,continuationTailReplay:i,liveCatchUp:e.status===`streaming`&&!r},this.attach(n),this.apply(t)}refreshReplayBaseline(){let e=this.replay;if(!e)return null;let t=e.shadow.serverMessageId??e.baseline.serverMessageId,n=this.messagesSig.value,r=n.at(-1),i=r===e.baseline||r?.id===e.baseline.id||t!==void 0&&r?.serverMessageId===t?r:n.find(t=>t===e.baseline)??n.find(n=>n.id===e.baseline.id||t!==void 0&&n.serverMessageId===t);if(!i)return this.detach(),null;if(i===e.baseline)return e;let a=e.baseline;return e.baseline=i,bp(a,i),e.liveCatchUp&&yp(e.shadow)&&(i.status===`streaming`||Bo(i))?(e.probeContinuation=!1,e.continuationTailReplay=!1,e):(e.probeContinuation=yp(i)||Bo(i)&&(i.status!==`streaming`||zo(i)),e.continuationTailReplay=i.status===`streaming`&&zo(i)&&Ro(i),e.liveCatchUp=i.status===`streaming`&&!e.probeContinuation,e)}refreshActive(){let e=this.active;if(!e)return null;let t=e.serverMessageId,n=this.messagesSig.value,r=n.at(-1),i=r===e||r?.id===e.id||t!==void 0&&r?.serverMessageId===t?r:n.find(t=>t===e)??n.find(n=>n.id===e.id||t!==void 0&&n.serverMessageId===t);if(!i)return this.detach(),null;if(i===e)return e;bp(e,i);let a=yp(e)&&Bo(i);return i.status!==`streaming`&&!a?(this.detach(),null):(this.replay={baseline:i,shadow:e,chunks:[],probeContinuation:!1,continuationTailReplay:!1,liveCatchUp:!0},e)}promoteReplay(){let{baseline:e,shadow:t}=this.replay;return Jn(()=>{e.role=t.role,e.serverMessageId=t.serverMessageId,e.operatorInitials=t.operatorInitials,e.status=t.status,t.canceled&&(e.canceled=!0),e.finishReason=t.finishReason,e.errorText=t.errorText,e.suggestions=t.suggestions??e.suggestions,e.partsSig.value=t.partsSig.value,this.messagesSig.value=[...this.messagesSig.value]}),this.replay=null,this.active=e,e}promoteContinuation(e=!1){let{baseline:t,chunks:n}=this.replay,r=Ho(t);return this.replay=null,Jn(()=>{if(e){let e=t.partsSig.value.findLastIndex(e=>e.kind===`tool`);t.partsSig.value=t.partsSig.value.slice(0,e+1)}t.awaitingContinuation=!1,t.status=`streaming`,t.finishReason=void 0,t.errorText=void 0,t.suggestions=void 0,this.attach(t);for(let e of n)this.apply(e);t.continuationStreaming=r||void 0,this.messagesSig.value=[...this.messagesSig.value]}),t}settleOwnedContinuation(e){let{baseline:t}=this.replay,n=Ho(t);return this.replay=null,Jn(()=>{t.awaitingContinuation=!1,t.status=`streaming`,t.finishReason=void 0,t.errorText=void 0,t.suggestions=void 0,this.attach(t),this.apply(e),t.continuationStreaming=n||void 0,this.messagesSig.value=[...this.messagesSig.value]}),t}applyResume(e){if(e.type===`start`){let t=(this.replay?.baseline??this.active)?.serverMessageId;t!==void 0&&e.messageId!==void 0&&t!==e.messageId&&this.onReconcileNeeded?.({messageId:t}),this.detach();let n=e.messageId,r=n===void 0?void 0:this.messagesSig.value.find(e=>e.serverMessageId===n||e.id===n);if(r!==void 0)return e.messageMetadata?.senderRole===`visitor`&&r.role===`user`&&(r.status===`pending`||r.status===`error`)&&(r.serverMessageId=n,r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,this.messagesSig.value=[...this.messagesSig.value]),this.beginReplay(r,e),null;let i=e.messageMetadata?.senderRole,a=this.messagesSig.value.at(-1);if(i===void 0&&a?.role===`assistant`&&a.status===`streaming`&&a.serverMessageId===void 0&&!No(a))return this.attach(a),this.apply(e),null;let o=xo();return this.attach(o),this.messagesSig.value=[...this.messagesSig.value,o],this.apply(e),null}if(this.replay){let t=this.refreshReplayBaseline();if(!t)return null;t.chunks.push(e),e.type===`data-control-state`&&(t.baseline.operatorRoutedTurn=e.data.controlMode!==`ai-agent`),this.apply(e);let{baseline:n,shadow:r,probeContinuation:i,continuationTailReplay:a,liveCatchUp:o}=t,s=e.type===`finish`||e.type===`error`||e.type===`abort`;if(i){if(!wp(n,r,e))return s&&(Op(n,r)&&(n.continuationStreaming=!0,this.messagesSig.value=[...this.messagesSig.value],this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id})),this.detach()),null;let t=yp(n)&&s?this.settleOwnedContinuation(e):this.promoteContinuation();return s?(t.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:t.serverMessageId??t.id}):t.continuationStreaming=!1),this.detach(),t):null}if(a&&Sp(n,r)){let e=this.promoteContinuation(!0);return s?(this.detach(),e):null}if(!o)return s&&this.detach(),null;if(s&&!No(n)&&No(r)){let e=this.promoteReplay();return this.detach(),e}if(!xp(n,r))return s&&(this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}),this.detach()),null;let c=this.promoteReplay();return s?(this.detach(),c):null}let t=this.refreshActive();if(!t)return null;if(this.replay)return this.applyResume(e);if(this.apply(e),e.type===`finish`||e.type===`error`||e.type===`abort`){let n=t;return n.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}):n.continuationStreaming=!1),this.detach(),n}return null}ensureTextPart(e,t,n){let r=`${t}:${n}`,i=this.openTextParts.get(r);if(i)return i;let a={kind:t,id:`${n}#${this.partSeq++}`,textSig:H(``),doneSig:H(!1)};return this.openTextParts.set(r,a),Ap(e,a),a}apply(e){let t=this.active;if(t)switch(e.type){case`start`:{e.messageId&&(t.serverMessageId=e.messageId);let n=e.messageMetadata;n?.senderRole===`operator`?(t.role=`operator`,n.operatorInitials&&(t.operatorInitials=n.operatorInitials)):n?.senderRole===`visitor`&&(t.role=`user`);return}case`finish-step`:this.openTextParts.clear();return;case`start-step`:Ap(t,{kind:`step-start`,id:`ss-${this.partSeq++}`});return;case`finish`:gp.debug(`finish`,{reason:e.finishReason,canContinue:e.canContinue}),t.status=`complete`,t.retryAction=void 0,e.finishReason&&(t.finishReason=e.finishReason),this.bumpDone(t);return;case`error`:gp.warn(`stream error chunk`,{errorText:e.errorText}),t.status=`error`,t.errorText=e.errorText,this.bumpDone(t);return;case`abort`:gp.debug(`stream abort chunk (canceled)`),t.status=`complete`,t.canceled=!0,t.retryAction=void 0,this.bumpDone(t);return;case`text-start`:this.ensureTextPart(t,`text`,e.id);return;case`text-delta`:{let n=this.ensureTextPart(t,`text`,e.id);n.textSig.value+=e.delta;return}case`text-end`:this.ensureTextPart(t,`text`,e.id).doneSig.value=!0;return;case`reasoning-start`:this.ensureTextPart(t,`reasoning`,e.id).doneSig.value=!1;return;case`reasoning-delta`:{let n=this.ensureTextPart(t,`reasoning`,e.id);n.textSig.value+=e.delta;return}case`reasoning-end`:this.ensureTextPart(t,`reasoning`,e.id).doneSig.value=!0;return;case`tool-input-start`:case`tool-input-delta`:case`tool-input-available`:case`tool-input-error`:case`tool-output-available`:case`tool-output-error`:case`tool-output-denied`:case`tool-approval-request`:Mp(t,e);return;case`file`:Ap(t,{kind:`file`,url:e.url,mediaType:e.mediaType});return;case`source-url`:jp(t,{kind:`source`,sourceId:e.sourceId,url:e.url,title:e.title});return;case`source-document`:jp(t,{kind:`source`,sourceId:e.sourceId,title:e.title,filename:e.filename,mediaType:e.mediaType});return;case`data-suggestions`:t.suggestions=go(e.data);return;case`data-control-state`:t.operatorRoutedTurn=e.data.controlMode!==`ai-agent`;return;case`data-memory-compaction-state`:return}}bumpDone(e){Jn(()=>{e.partsSig.value=[...e.partsSig.value],this.messagesSig.value.includes(e)&&(this.messagesSig.value=[...this.messagesSig.value])})}};const vp={"input-streaming":0,"input-available":1,"approval-requested":2,"approval-responded":3,"output-available":4,"output-denied":4,"output-error":4};function yp(e){return e.awaitingContinuation===!0||e.continuationStreaming===!0||e.retryAction?.kind===`continue-assistant`}function bp(e,t){e.canceled&&(t.canceled=!0),yp(e)&&(t.status===`streaming`||Bo(t))&&(t.awaitingContinuation??(t.awaitingContinuation=e.awaitingContinuation),t.continuationStreaming??(t.continuationStreaming=e.continuationStreaming),t.retryAction===void 0&&(t.retryAction=e.retryAction))}function xp(e,t){let n=e.partsSig.value,r=t.partsSig.value;return e.role!==t.role||r.length<n.length?!1:n.every((e,t)=>Cp(e,r[t]))}function Sp(e,t){let n=e.partsSig.value,r=n.findLastIndex(e=>e.kind===`tool`),i=new Set(n.slice(0,r+1).flatMap(e=>e.kind===`tool`?[e.toolCallId]:[])),a=t.partsSig.value.filter(e=>e.kind!==`tool`||!i.has(e.toolCallId)),o=n.slice(r+1);return a.length<o.length?!1:o.every((e,t)=>Cp(e,a[t]))}function Cp(e,t){switch(e.kind){case`text`:case`reasoning`:return t?.kind===e.kind&&t.textSig.value.startsWith(e.textSig.value);case`step-start`:return t?.kind===`step-start`;case`tool`:{if(t?.kind!==`tool`||t.toolCallId!==e.toolCallId||!Qo(t.toolName,e.toolName)||vp[t.stateSig.value]<vp[e.stateSig.value])return!1;let n=e.approvalSig.value?.approved;return n===void 0||t.approvalSig.value?.approved===n}case`file`:return t?.kind===`file`&&t.url===e.url&&t.mediaType===e.mediaType;case`source`:return t?.kind===`source`&&t.sourceId===e.sourceId&&t.url===e.url&&t.title===e.title&&t.filename===e.filename&&t.mediaType===e.mediaType;default:return e}}function wp(e,t,n){return Tp(e,n)||!Ep(e,t)?!0:n.type!==`finish`&&n.type!==`error`&&n.type!==`abort`?!1:Ro(t)||e.awaitingContinuation===!0&&n.type!==`finish`?!0:e.awaitingContinuation===!0&&t.partsSig.value.every(e=>e.kind===`step-start`)}function Tp(e,t){if(t.type!==`tool-output-available`&&t.type!==`tool-output-error`&&t.type!==`tool-output-denied`)return!1;let n=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t.toolCallId);return n!==void 0&&vp[n.stateSig.value]<4}function Ep(e,t){let n=t.partsSig.value;if(n.length===0)return!0;let r=e.partsSig.value;return r.some((e,t)=>n.every((e,n)=>Dp(r[t+n],e)))}function Dp(e,t){switch(t.kind){case`text`:case`reasoning`:return e?.kind===t.kind&&e.textSig.value.startsWith(t.textSig.value);case`step-start`:return e?.kind===`step-start`;case`tool`:return e?.kind===`tool`&&e.toolCallId===t.toolCallId&&(t.toolName===`tool`||Qo(e.toolName,t.toolName));case`file`:return e?.kind===`file`&&e.url===t.url&&e.mediaType===t.mediaType;case`source`:return e?.kind===`source`&&e.sourceId===t.sourceId&&e.url===t.url&&e.title===t.title&&e.filename===t.filename&&e.mediaType===t.mediaType;default:return t}}function Op(e,t){if(yp(e)||!Bo(e))return!1;let n=new Set(e.partsSig.value.filter(e=>e.kind===`tool`).map(e=>e.toolCallId));return!t.partsSig.value.some(e=>e.kind===`tool`&&n.has(e.toolCallId))}function kp(e,t,n,r){let i=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);if(i)return r&&(i.dynamic=!0),i;let a={kind:`tool`,toolCallId:t,toolName:n??`tool`,dynamic:r?!0:void 0,inputPartialSig:H(``),inputSig:H(void 0),outputSig:H(void 0),errorSig:H(void 0),stateSig:H(`input-streaming`),approvalSig:H(void 0)};return Ap(e,a),a}function Ap(e,t){e.partsSig.value=[...e.partsSig.value,t]}function jp(e,t){e.partsSig.value.some(e=>e.kind===`source`&&e.sourceId===t.sourceId)||Ap(e,t)}function Mp(e,t){switch(t.type){case`tool-input-start`:kp(e,t.toolCallId,t.toolName,t.dynamic);return;case`tool-input-delta`:{let n=kp(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case`tool-input-available`:{let n=kp(e,t.toolCallId,t.toolName,t.dynamic);n.inputSig.value=t.input,n.stateSig.value=`input-available`;return}case`tool-input-error`:{let n=kp(e,t.toolCallId,t.toolName,t.dynamic);n.inputSig.value=t.input,n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-approval-request`:{let n=kp(e,t.toolCallId,t.toolName);n.approvalSig.value={id:t.approvalId},n.stateSig.value=`approval-requested`;return}case`tool-output-available`:{let n=kp(e,t.toolCallId,void 0,t.dynamic);n.outputSig.value=t.output,n.stateSig.value=`output-available`;return}case`tool-output-error`:{let n=kp(e,t.toolCallId,void 0,t.dynamic);n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-output-denied`:{let n=kp(e,t.toolCallId);n.stateSig.value=`output-denied`;return}default:return}}const Np=1e3;async function Pp(e){let t=Np,n=!1,r=!1,i=!1;function a(){i||e.signal.aborted||(i=!0,e.onInitialBoundaryReady())}for(;!e.signal.aborted;){let o,s=`held`;try{s=await e.connect(()=>{if(e.signal.aborted)return;o=e.now();let t=n||r;n=!0,r=!1,i?t&&e.backfill():a()})}catch{}if(e.signal.aborted||(!n&&o===void 0&&(r=!0,a()),s===`unavailable`))return;o!==void 0&&e.now()-o>=1e3&&(t=Np),await e.sleep(t),t=Math.min(t*2,15e3)}}function Fp(e){let{activated:t,conversationReady:n,conversationIdSig:r,messagesSig:i,optionsRef:a,transport:o,visitorId:s,adoptControlStateChunk:c,adoptMemoryCompactionStateChunk:l,settleSuggestions:u,recordConversationReply:d,transcriptRecoverySig:f,beginConversationTranscript:p,commitConversationTranscript:m,onReplyLanded:h,runCancellation:g,canContinueRef:_,setCanSend:v,feedback:y,bus:b,loadInitialThread:x,shouldReconcileOnConnect:S}=e,ee=z(0);R(()=>{if(!t||!n||!r.value)return;let e=r.value,C=new AbortController,te=e=>{},w=new _p(i,e=>te(e));o.primeIdentity(s,e);let T=!1,E=!1,D,O=!1,ne,k=0,A=_.current,re,j,ie=Date.now(),M,ae=!1,oe=!1;function se(t,n,r){if(!No(t))return;let o=i.value.findLast(e=>!e.ephemeral),s=t.serverMessageId??t.id;if(!(o&&(o.serverMessageId??o.id)!==s))return Mo(i.value,t,e,a.current.strings.newConversation,n,r)}function ce(e,t,n,r){let i=se(e,t,r);if(!i)return;let a=`${e.serverMessageId??e.id}:${n}:${i.preview??``}`;a!==j&&(j=a,o.publishConversation({...i,hasUnread:!0},!0))}let le;function ue(){le&&(clearTimeout(le.timer),le=void 0)}function de(){let e=le;if(!e)return;clearTimeout(e.timer),le=void 0;let t=i.value.find(t=>(t.serverMessageId??t.id)===e.replyId);(t?.role===`assistant`||t?.role===`operator`)&&ce(t,e.canContinue,e.generation,e.activityAt)}function fe(e,t,n,r){ue(),le={replyId:e.serverMessageId??e.id,canContinue:t,generation:n,activityAt:r,timer:setTimeout(de,120)}}function pe(e,t,n,r=Date.now(),i=!0){ue();let a=se(e,t,r);if(!a)return;let o=`${e.serverMessageId??e.id}:${n}`;o!==re&&(re=o,d(a),i&&M&&(ae=!0))}function me(e,t){(e||!g.localSendRef.current)&&g.settle(t),e&&h()}function he(e,t=[],n=!1,r,o=A,s=k,c=Date.now(),l=!0){let d=a.current;if(e.canceled){pe(e,o,s,c,l),me(n,r);return}let f=!0,p=e.status===`error`;switch(is(e,p)){case`drop`:i.value=i.value.filter(t=>t!==e),f=!1;break;case`complete-operator-routed`:e.status=`complete`,n&&(y.play(`messageReceived`),Ps(b,d,`assistant`,jo(e)));break;case`error`:if(e.status=`error`,e.errorText=d.strings.errorGeneric,n){y.play(`error`);let e=/* @__PURE__ */ Error(p?`stream error chunk`:`empty reply`);b.emit(`error`,e),d.onError?.(e)}break;case`complete`:e.status=`complete`,n&&(y.play(`messageReceived`),Ps(b,d,`assistant`,jo(e))),u(e,t)}f&&pe(e,o,s,c,l),me(n,r)}function ge(t){if(C.signal.aborted||r.value!==e)return;if(c(t),l?.(t),t.type===`start`){de();let n=t.messageId===void 0?void 0:i.value.find(e=>e.serverMessageId===t.messageId||e.id===t.messageId);O=n!==void 0&&n.status!==`streaming`;let r=ne?.senderRole===`visitor`?ne.messageId:void 0;if(ne={messageId:t.messageId,senderRole:t.messageMetadata?.senderRole},k+=1,ie=Date.now(),j=void 0,T=t.messageMetadata?.senderRole===void 0,E=!1,D=T?t.messageMetadata?.runId:void 0,T){let n=t.messageId!==void 0&&i.value.some(e=>e.serverMessageId===t.messageId||e.id===t.messageId),a=i.value.at(-1),o=t.messageId!==void 0&&(a?.serverMessageId===t.messageId||a?.id===t.messageId),s=g.localSendRef.current&&(!n||o)&&a?.role===`assistant`&&a.status===`streaming`&&(o||a.serverMessageId===void 0&&a.partsSig.value.length===0);E=g.captureStart(e,t,s,r)}}let n=T&&(t.type===`finish`||t.type===`error`||t.type===`abort`),o=n?D:void 0,s=n&&(E||g.ownsLocalRun(o)),u=k,d=O;t.type===`finish`&&t.canContinue!==void 0&&(A=t.canContinue);let f=A;n&&(T=!1,E=!1,D=void 0);let p=w.applyResume(t),m=ne?.messageId,h=m===void 0?void 0:i.value.find(e=>e.serverMessageId===m||e.id===m);O&&ne?.senderRole!==`visitor`&&(p!==null||h?.status===`streaming`)&&(O=!1,d=!1);let _=!O&&(h?.role===`assistant`||h?.role===`operator`);t.type===`text-delta`&&_&&fe(h,A,k,ie),t.type===`text-end`&&(ue(),_&&ce(h,A,k,ie)),t.type===`finish`&&t.canContinue===!1&&v(!1),p?p.role===`operator`?(d||(y.play(`messageReceived`),Ps(b,a.current,`operator`,jo(p))),pe(p,f,u,ie),O=!1,n&&(s||!g.localSendRef.current)&&g.settle(o)):p.role===`assistant`&&(he(p,[],s,o,f,u,ie),O=!1):n&&(s||!g.localSendRef.current)&&g.settle(o)}async function N(t){let n=k,a=await o.loadConversation(e,t?{ids:[t]}:void 0).catch(()=>null);if(C.signal.aborted||r.value!==e||!a)return!1;a.controlState&&c({type:`data-control-state`,data:a.controlState});let s=i.value.at(-1),l=n===k&&(t===void 0||s!==void 0&&(s.serverMessageId===t||s.id===t));if(a.messages.length===0)return!0;l&&(A=a.canContinue,v(A));let d=i.value,f=t===void 0?d.at(-1):d.find(e=>e.serverMessageId===t||e.id===t),{messages:p,changed:m}=Yo(d,Oo(a.messages));if(!m)return!0;i.value=p;let h=t===void 0?p.at(-1):p.find(e=>e.serverMessageId===t||e.id===t),_=f!==void 0&&h!==void 0&&(f.id===h.id||f.serverMessageId!==void 0&&f.serverMessageId===h.serverMessageId),y=h!==void 0&&h.status!==`streaming`&&(!_||f?.status===`streaming`),b=_&&f?.status===`streaming`?Date.now():h?.createdAt;return l&&y&&h.role===`assistant`?he(h,h.suggestions??[],g.localSendRef.current,void 0,a.canContinue,n,b,!1):l&&y&&h.role===`operator`?pe(h,a.canContinue,n,b,!1):l&&h?.role===`assistant`&&h.status!==`streaming`&&u(h,h.suggestions??[]),!0}let _e=/* @__PURE__ */ new Set;te=({messageId:e})=>{if(_e.has(e)||!i.value.some(t=>t.serverMessageId===e||t.id===e))return;_e.add(e);function t(){return _e.delete(e)}N(e).then(t,t)};function ve(t=!1){if(C.signal.aborted||r.value!==e){ae=!1;return}if(M){ae=!0;return}let n=t?x(e)??(S()?N():void 0):N();if(!n)return;p(e),M=n;function i(t=!1){M===n&&(M=void 0,ae?(ae=!1,ve()):t&&m(e))}n.then(i,()=>i(!1))}let ye=f.subscribe(e=>{e<=ee.current||(ee.current=e,oe&&ve())});return Pp({signal:C.signal,now:()=>performance.now(),sleep:e=>ss(e,C.signal),connect:e=>o.connectResumeStream({signal:C.signal,onChunk:ge,onConnected:e}),onInitialBoundaryReady:()=>{oe=!0,ve(!0)},backfill:()=>ve()}),()=>{C.abort(),ue(),ye(),w.detach()}},[t,n,r,r.value,s,o,c,l,u,d,f,p,m,h,g,_,v,i,b,y,x,S])}function Ip(e){let{transport:t,setStreaming:n}=e,r=z(void 0),i=z(void 0),a=z(!1),o=z(void 0),s=z(!1),c=z(/* @__PURE__ */ new Map),l=z(/* @__PURE__ */ new Set),u=V((e,n)=>{let r=`${e}:${n}`;o.current!==r&&(o.current=r,t.cancelTurn(e,n))},[t]),d=V(e=>{r.current=void 0,i.current=e,a.current=!1,o.current=void 0,s.current=!0,n(!0)},[n]),f=V((e,t)=>{c.current.set(e,{messageId:t})},[]),p=V(e=>{e!==void 0&&(l.current.add(e),l.current.size>32&&l.current.delete(l.current.values().next().value)),(e===void 0||r.current?.runId===e)&&(r.current=void 0,i.current=void 0,a.current=!1,s.current=!1,n(!1))},[n]),m=V((e,t)=>i.current===e?(i.current=void 0,t.runId?(r.current={conversationId:t.conversationId,runId:t.runId},n(!0),a.current&&u(t.conversationId,t.runId),!0):(p(),!0)):t.runId&&r.current?.runId===t.runId?(r.current={conversationId:t.conversationId,runId:t.runId},a.current&&u(t.conversationId,t.runId),!0):!1,[u,n,p]),h=V((e,t)=>{let d=c.current.get(e);return d?(c.current.delete(e),!t.runId||l.current.has(t.runId)?!0:d.runId===void 0?(s.current||i.current||(r.current={conversationId:t.conversationId,runId:t.runId},i.current=void 0,a.current=!1,o.current=void 0,s.current=!0,n(!0)),!0):(d.runId===t.runId&&r.current?.runId===t.runId&&(r.current={conversationId:t.conversationId,runId:t.runId},a.current&&u(t.conversationId,t.runId)),!0)):!1},[u,n]),g=V(e=>i.current===e&&(p(),!0),[p]),_=V(e=>{let t=c.current.get(e);return t?(c.current.delete(e),t.runId===void 0):!1},[]),v=V((e,t,d,f)=>{let p=t.messageMetadata?.runId;if(t.messageMetadata?.senderRole!==void 0||typeof p!=`string`||!p||l.current.has(p))return!1;if(r.current?.runId===p)return s.current;if(s.current)return r.current||!d?!1:(i.current=void 0,r.current={conversationId:e,runId:p},n(!0),a.current&&u(e,p),!0);let m=[...c.current.values()].filter(e=>e.runId===void 0).find(e=>e.messageId===f);return m?(m.runId=p,r.current={conversationId:e,runId:p},i.current=void 0,a.current=!1,o.current=void 0,s.current=!0,n(!0),!0):(i.current=void 0,r.current={conversationId:e,runId:p},n(!0),a.current&&u(e,p),s.current)},[u,n]),y=V(e=>typeof e==`string`&&r.current?.runId===e&&s.current,[]),b=V(()=>{let e=r.current;if(e)return a.current=!0,u(e.conversationId,e.runId),!0;let t=i.current;return t?(a.current=!0,t.then(e=>{e.runId&&u(e.conversationId,e.runId)}).catch(()=>void 0),!0):!1},[u]);return B(()=>({localSendRef:s,begin:d,beginRouted:f,acceptAck:m,acceptRoutedAck:h,reject:g,rejectRouted:_,captureStart:v,ownsLocalRun:y,settle:p,stop:b}),[m,h,d,f,v,y,g,_,p,b])}const Lp=I.scope(`send`);function Rp(e,t,n,r,i,a=!0){e.publishConversation({...Mo(t,n,r,i,a),hasUnread:!1},!0)}function zp(e,t){return e.id===t.id||(e.serverMessageId??e.id)===(t.serverMessageId??t.id)}function Bp(e){return e.findLast(e=>!e.ephemeral&&e.role!==`system`&&(e.role===`user`||e.status!==`streaming`||No(e)))}function Vp(e,t,n,r,i){let a=Bp(t);a?.role===`user`&&zp(a,n)&&Rp(e,t,a,r,i)}function Hp(e){return!(e instanceof ds)||e.code===`network`||e.status===void 0||e.status===202||e.status===408||e.status===425||e.status===429||e.status>=500&&e.status<600}function Up(e){let{transport:t,messagesSig:n,conversationIdSig:r,options:i,bus:a,feedback:o,persistence:s,visitorId:c,adoptConversationId:l,applyControlState:u,setCanSend:d,settleSuggestions:f,runCancellation:p}=e,m=V(()=>{let e=r.value??Ht();return r.value||(r.value=e,s.saveConversationId(e)),e},[r,s]);return{sendAiTurn:V(async({continueExisting:e,turn:h})=>{let g=m(),_=n.value.at(-1),v=h?[h]:ko(n.value,e),y=v[0],b=_o({messages:v.map(Ao),conversationId:g,visitorId:c,userPrefs:s.loadUserPrefs()}),x=t.sendTurn(b);p.begin(x);try{let a=await x;if(r.value!==g||!p.acceptAck(x,a))return!1;if(l(a.conversationId),a.runId&&y?.role===`user`&&Vp(t,n.value,y,a.conversationId,i.strings.newConversation),!a.runId){let o=await t.loadConversation(a.conversationId).catch(()=>null);if(r.value!==a.conversationId)return!0;if(o){o.controlState&&u(o.controlState),d(o.canContinue);let r=Oo(o.messages),{messages:s,changed:c}=Yo(n.value,r);c&&(n.value=s);let l=r.findLast(e=>!e.ephemeral&&e.role!==`system`),p=Bp(n.value);p&&l&&zp(p,l)&&Rp(t,n.value,p,a.conversationId,i.strings.newConversation,o.canContinue);let m=_?n.value.find(e=>e.id===_.id&&e.role===`assistant`&&e.status!==`streaming`):void 0;m&&f(m,m.suggestions??[]),!e&&_?.role===`assistant`&&n.value.includes(_)&&_.serverMessageId===void 0&&!No(_)&&(n.value=n.value.filter(e=>e!==_))}else _?.role===`assistant`&&n.value.includes(_)&&(_.status=`error`,_.errorText=i.strings.errorGeneric,_.retryAction=e?{kind:`continue-assistant`,messageId:_.serverMessageId??_.id}:y?.role===`user`?{kind:`resend-user`,messageId:y.id}:null,n.value=[...n.value])}return!0}catch(s){if(r.value!==g)return!1;if(!p.reject(x))return y?.role===`user`&&Vp(t,n.value,y,g,i.strings.newConversation),!0;let c=kl(s,i.strings),l=Hp(s),m=h?.role===`assistant`?h:n.value.at(-1);if(e&&m?.role===`assistant`&&s instanceof ds&&s.status===409){let e=m.serverMessageId??m.id,i=await t.loadConversation(g,{ids:[e]}).catch(()=>null);if(r.value!==g)return!1;if(i){i.controlState&&u(i.controlState),d(i.canContinue);let t=Oo(i.messages),r=t.find(t=>(t.serverMessageId??t.id)===e);if(r&&Xo(m,r)){let{messages:r,changed:i}=Yo(n.value,t),a=r.find(t=>(t.serverMessageId??t.id)===e);if(i&&a&&a!==m)return a.awaitingContinuation=!1,a.continuationStreaming=void 0,a.retryAction=null,n.value=r,a.status!==`streaming`&&f(a,a.suggestions??[]),!0}}if(!n.value.includes(m)||m.status!==`streaming`)return!1;m.continuationStreaming=!0}if(e&&m?.role===`assistant`)m.status=`error`,m.errorText=c,m.retryAction=l?{kind:`continue-assistant`,messageId:m.serverMessageId??m.id}:null,n.value=[...n.value];else if(_?.role===`assistant`&&n.value.includes(_)){_.status=`error`,_.errorText=c;let e=v[0];_.retryAction=l&&e?.role===`user`?{kind:`resend-user`,messageId:e.id}:null,n.value=[...n.value]}else{let e=xo();e.status=`error`,e.errorText=c;let t=v[0];e.retryAction=l&&t?.role===`user`?{kind:`resend-user`,messageId:t.id}:null,n.value=[...n.value,e]}return o.play(`error`),a.emit(`error`,s),i.onError?.(s),!1}},[t,n,i,a,o,s,c,l,u,d,f,m,p]),sendRoutedTurn:V(async e=>{let u=m();e.status=`pending`,e.errorText=void 0,e.retryAction=void 0,n.value.includes(e)&&(n.value=[...n.value]);let d=_o({messages:[Ao(e)],conversationId:u,visitorId:c,userPrefs:s.loadUserPrefs()}),f=t.sendTurn(d);p.beginRouted(f,e.id);try{let a=await f;return r.value===u?p.acceptRoutedAck(f,a)?(l(a.conversationId),Vp(t,n.value,e,a.conversationId,i.strings.newConversation),e.status===`pending`&&(e.status=`complete`,n.value.includes(e)&&(n.value=[...n.value])),!0):!1:(p.rejectRouted(f),!1)}catch(s){let c=p.rejectRouted(f);if(r.value!==u)return!1;if(!c)return Vp(t,n.value,e,u,i.strings.newConversation),e.status===`pending`&&(e.status=`complete`,n.value.includes(e)&&(n.value=[...n.value])),!0;if(e.status!==`pending`)return Vp(t,n.value,e,u,i.strings.newConversation),!0;Lp.debug(`operator-routed send failed`,{error:s});let l=s instanceof Error?s:Error(String(s));return e.status=`error`,e.errorText=kl(s,i.strings),e.retryAction=Hp(s)?{kind:`resend-user`,messageId:e.id}:null,n.value.includes(e)&&(n.value=[...n.value]),o.play(`error`),a.emit(`error`,l),i.onError?.(l),!1}},[t,n,i,a,o,s,c,l,m,p])}}const Wp=I.scope(`unread`);function Gp(e){let{transport:t,options:n,conversationIdSig:r,isConversationVisibleRef:i,activated:a,conversationReady:o}=e,s=Er(!1),c=Er(0),l=Er(0),u=z([]),d=z(void 0),f=z(!1),p=V(()=>{let e=r.value,t=i.current()&&d.current===e?e:void 0,n=u.current.filter(e=>e.hasUnread&&e.conversationId!==t).length;c.value=n,s.value=n>0},[r,s,c,i]),m=V(e=>{let t=r.value,n=u.current.find(e=>e.conversationId===t),i=Ss(u.current,e),a=i.find(e=>e.conversationId===t),o=e.type===`snapshot`&&t!==void 0&&a?.hasUnread===!0&&d.current===t&&n!==void 0&&n.lastMessageAt!==a.lastMessageAt;o&&(d.current=void 0),u.current=i,p(),o&&(l.value+=1)},[r,p,l]),h=V(()=>{if(p(),!i.current())return;let e=r.value;if(!e||d.current!==e)return;let n=u.current.find(t=>t.conversationId===e);n?.hasUnread&&t.markRead(e,n.lastMessageAt)},[r,i,p,t]),g=V(e=>{r.value===e&&(d.current=void 0,p())},[r,p]),_=V(e=>{r.value===e&&(d.current=e,h())},[r,h]),v=V(e=>d.current===e,[]),y=V((e=!1)=>{n.modules.list.some(e=>e.layout===`chat`)&&(f.current||(f.current=!0,t.listConversations({limit:50},e).then(t=>{e||m({type:`snapshot`,result:t,requestedRevision:0}),h()}).catch(e=>Wp.debug(`refreshUnread failed (non-fatal)`,{err:e})).finally(()=>{f.current=!1})))},[m,h,n.modules,t]),b=V(e=>{let n=e.conversationId,a=i.current()&&r.value===n&&d.current===n,o=u.current.find(e=>e.conversationId===n),s=a&&(o?.lastMessageAt!==e.lastMessageAt||o.hasUnread);t.publishConversation({...e,hasUnread:!a},!0),s&&t.markRead(n,e.lastMessageAt)},[r,i,t]);R(()=>t.subscribeConversationChanges(m),[m,t]);let x=z(!1);return R(()=>{a&&o&&!x.current&&(x.current=!0,y())},[a,o,y]),R(()=>{if(!a)return;function e(){document.visibilityState===`visible`&&(h(),y(!0))}return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[a,h,y]),{hasUnreadSig:s,unreadCountSig:c,transcriptRecoverySig:l,markVisibleConversationRead:h,beginConversationTranscript:g,commitConversationTranscript:_,isConversationTranscriptCommitted:v,recordConversationReply:b}}const Kp=I.scope(`settings`);function qp(e){let{options:t,persistence:n,transport:r,feedback:i,hostElement:a,bus:o}=e,s=n.loadUserPrefs(),[c,l]=L(()=>s.locale??t.locale),[u,d]=L(s.themeMode),f=u??t.themeMode,[p,m]=L(()=>s.textSize??t.textSize),h=V(e=>{n.patchUserPrefs(e),r.saveUserPrefs(n.loadUserPrefs()).catch(e=>Kp.warn(`saveUserPrefs failed`,{err:e}))},[n,r]);R(()=>{s.soundMuted!==void 0&&i.setMuted(s.soundMuted)},[]),R(()=>{if(f!==`host`)a.dataset.theme=f;else return on(e=>{a.dataset.theme=e})},[a,f,t]),R(()=>{a.dataset.textSize=p},[a,p,t]),R(()=>{let e=!0;return i.mutedSig.subscribe(t=>{e?e=!1:h({soundMuted:t})})},[i,h]);let g=dt(c,t.availableLocales,t.defaultLocale);return R(()=>{r.setLocale(g)},[r,g]),R(()=>{a.dir=Oe(g)?`rtl`:`ltr`},[a,g]),R(()=>{g!==c&&l(g)},[g,c]),{activeLocale:c,activeThemeMode:f,activeTextSize:p,effectiveLocale:g,setActiveLocale:l,setActiveThemeMode:d,setActiveTextSize:m,patchAndSync:h,handleLocaleChange:V(e=>{Kp.info(`localeChange`,{locale:e}),l(e),h({locale:e}),o.emit(`localeChange`,e)},[h,o]),handleThemeChange:V(e=>{Kp.info(`themeChange`,{mode:e}),d(e),a.dataset.theme=e,h({themeMode:e}),o.emit(`themeChange`,e)},[a,h,o]),handleTextSizeChange:V(e=>{Kp.info(`textSizeChange`,{size:e}),m(e),a.dataset.textSize=e,h({textSize:e}),o.emit(`textSizeChange`,e)},[a,h,o]),handleSoundToggle:V(()=>{i.toggleMuted();let e=i.mutedSig.value;Kp.info(`soundToggle`,{muted:e}),o.emit(`soundToggle`,{muted:e})},[i,o])}}const $=I.scope(`app`),Jp=P.cssPrefix,Yp={home:`home`,chats:`chat`,help:`help`,news:`news`};function Xp(e,t){return So({...e,text:ke(t,e.text)})}function Zp({options:e,hostElement:t,bus:n}){let r=e.aiAgentDeploymentId;if(!r)throw Error(`aiAgentDeploymentId is required`);let[i]=L(()=>Gt(e.widgetId,e.storage,e.aiAgentDeploymentId)),[a]=L(()=>i.getVisitorId()),o=i.loadUserPrefs(),s=Er(i.loadConversationId()),l=z(s.value!==void 0),u=Er(s.value??``),d=Er([]),[f,p]=L(!1),m=z(void 0),[h,g]=L([]);function _(){let t=e.modules.list,n=new Set(t.map(e=>e.id)),r=i.loadActiveModule();return r&&n.has(r)?r:t[0]?.id??``}function v(){return e.modules.list.find(e=>e.layout===`chat`)?.id}function y(){let t=v();return t?e.modules.list.length===1||x.sig.value.activeTab===t:!1}let b=z(void 0);if(!b.current){let t=e.modules.list.map(e=>e.id),n=i.loadActiveModule()??t[0]??``;b.current=Vs(n,n?[...t,n]:t,e=>i.saveActiveModule(e))}let x=b.current,S=Dr(()=>x.sig.value.activeTab).value,ee=Dr(()=>s.value).value,[C,te]=L(!1),[w,T]=L(null),[E,D]=L(!1),O=e.mode===`standalone`||e.mode===`inline`,ne=z(qs(e,Js(),i.loadPanelOpen(),i.loadPanelSize())),[k,A]=L(ne.current.panelOpen),[re,j]=L(ne.current.panelOpen),ie=z(void 0),M=z(void 0),ae=z(!1),oe=z(void 0);R(()=>{k&&j(!0)},[k]);let se=z(!1),[ce,le]=L(!1),{dismissed:ue,dismissCallout:de}=up({callout:e.launcher.callout,persistence:i}),fe=e.launcher.callout?.persistent??!0,pe=V(()=>{$.info(`calloutDismiss`),n.emit(`calloutDismiss`,void 0),de()},[n,de]),[me,he]=L(ne.current.panelSize),ge=z(!1),[N,_e]=L(`chat`),ve=z(()=>!1);ve.current=()=>k&&N===`chat`&&!document.hidden&&y();let[ye,be]=L(!0),xe=z(ye);xe.current=ye;let[Se,Ce]=L(!1),we=z(Se);we.current=Se;let Te=z(null),[Ee,De]=L(!1),[Oe,Ae]=L(null),[je,Me]=L([]),Ne=z(e.strings),Pe=z(e);Pe.current=e;let[Fe,Ie]=L(void 0),[Le,Re]=L(void 0),[ze,Be]=L(()=>i.loadSidebarCollapsed()??!1),[Ve,He]=L({}),[F]=L(()=>new Os({agentApiBaseUrl:e.agentApiBaseUrl,dataApiBaseUrl:e.dataApiBaseUrl,auth:jr({publicKey:e.publicKey,aiAgentDeploymentId:r,publicKeyHeader:`x-public-key`}),endpoints:e.endpoints})),[Ue]=L(()=>new $r(e.sound,e.haptics)),We=Ip({transport:F,setStreaming:Ce}),{activeLocale:Ge,activeThemeMode:Ke,activeTextSize:qe,effectiveLocale:Je,setActiveLocale:Ye,setActiveThemeMode:Xe,setActiveTextSize:Ze,patchAndSync:Qe,handleLocaleChange:I,handleThemeChange:$e,handleTextSizeChange:et,handleSoundToggle:tt}=qp({options:e,persistence:i,transport:F,feedback:Ue,hostElement:t,bus:n}),{controlModeSig:nt,assignedOperatorInitialsSig:rt,operatorAvailableSig:it,applyControlState:at,adoptControlStateChunk:ot,requestOperator:st,cancelOperatorRequest:ct}=dp({transport:F,conversationIdSig:s}),lt=Er(/* @__PURE__ */ new Map),ut=V(e=>{if(e.type!==`data-memory-compaction-state`)return;let t=s.value;if(!t)return;let n=ho(e.data);if(!n)return;let r=lt.value.get(t);if(r&&(n.postFinishSequence<r.postFinishSequence||n.postFinishSequence===r.postFinishSequence&&(r.status===`ready`||r.status===n.status)))return;let i=new Map(lt.value);i.set(t,n),lt.value=i},[s,lt]),{hasUnreadSig:dt,unreadCountSig:ft,transcriptRecoverySig:pt,markVisibleConversationRead:mt,beginConversationTranscript:ht,commitConversationTranscript:gt,isConversationTranscriptCommitted:_t,recordConversationReply:vt}=Gp({transport:F,options:e,conversationIdSig:s,isConversationVisibleRef:ve,activated:re,conversationReady:C}),bt=k&&e.modules.byId[S]?.layout===`home`,xt=lp({transport:F,options:e,persistence:i,enabled:C&&bt});R(()=>{mt()},[S,k,N,ee,mt]),R(()=>{Ue.update(e.sound,e.haptics)},[Ue,e.sound,e.haptics]),R(()=>()=>Ue.destroy(),[Ue]),R(()=>{!ge.current&&e.size.initialSize&&(ge.current=!0,!i.loadPanelSize()&&he(Ks(e.mode,e.size,Js())))},[e.mode,e.size,i]),R(()=>{if(!C||se.current)return;se.current=!0;let t=qs(e,Js(),i.loadPanelOpen(),i.loadPanelSize());A(t.panelOpen),he(t.panelSize)},[C,e,i]);let Ct=z(null);R(()=>{C&&x.reconcile(e.modules.list.map(e=>e.id),_())},[C,e.modules.list,x]);let wt=V(e=>{e&&e.length!==0&&(d.value=e.map(e=>Xp(e,Ne.current)))},[d]),Tt=z(null),Et=V(async e=>{try{let{formSubmissions:t}=await(e?F.bootstrap(e):Tt.current??F.bootstrap()),n=/* @__PURE__ */ new Map;return t.forEach((e,t)=>n.set(e.formId,t)),t.filter((e,t)=>!e.skipped||n.get(e.formId)===t).map((e,t)=>({key:`wire:${e.formId}:${e.createdAt??t}`,formId:e.formId,outcome:e.skipped?`skipped`:`submitted`,createdAt:co(e.createdAt),values:e.values}))}catch(e){return $.debug(`bootstrap failed — no form markers (non-fatal)`,{err:e}),[]}},[F]),Dt=z(0),Ot=z(0),kt=V(e=>{if(e===s.value)return;let t=s.value;Ot.current++,p(!1),t&&(i.saveDraft(e,i.loadDraft(t)),i.saveDraft(t,``),i.saveMessageQueue(e,i.loadMessageQueue(t)),i.saveMessageQueue(t,[])),s.value=e,i.saveConversationId(e),F.primeIdentity(void 0,e),$.info(`conversation rebound`,{previous:t,current:e}),t&&n.emit(`conversationRebound`,{previous:t,current:e})},[n,s,i,F]),At=V((e,t)=>{let n=[...e.map(e=>e.createdAt),...t.map(e=>e.createdAt)].filter(e=>e!==void 0),r=(n.length?Math.min(...n):Date.now())-1;return[...(oe.current?.messages??[]).map(e=>{let t=Xp(e,Ne.current);return t.createdAt=r,t}),...e]},[]),jt=V(async e=>{let t=Ot.current;function r(){return t!==Ot.current||s.value!==e}M.current===e&&(M.current=void 0),p(!0);try{let[t,n]=await Promise.all([F.loadConversation(e),Et()]);if(r())return!1;let i=Oo(t.messages);g(n);let a=At(Jo(i,d.value),n);if(d.value=a,M.current=a.some(e=>e.role===`user`)?void 0:e,i.length>0||t.controlState!==void 0){be(t.canContinue),t.controlState&&at(t.controlState);let e=i.findLast(e=>e.role===`assistant`&&!e.ephemeral);Me(e?.suggestions??[])}return!0}catch(t){return r()||($.warn(`loadThread failed; keeping conversation active`,{err:t,conversationId:e}),n.emit(`error`,t),Pe.current.onError?.(t)),!1}finally{r()||p(!1)}},[F,Et,d,s,At,n]),Mt=V(e=>{if(ie.current===e)return ie.current=void 0,jt(e)},[jt]),Nt=V(()=>{if(m.current)return Promise.resolve(void 0);let t=s.value,r=d.value.find(e=>e.serverMessageId!==void 0),i=r?.serverMessageId,a=r?new Date(r.createdAt).toISOString():void 0;if(!t||!i||!a)return Promise.resolve(void 0);let o=Ot.current,c={};return m.current=c,(async()=>{try{let e=await F.loadConversation(t,{beforeId:i,beforeCreatedAt:a});if(m.current!==c||Ot.current!==o||s.value!==t)return;if(e.messages.length===0)return!1;let n=e.messages.map(To),r=d.value,l=Uo(r,n);if(l!==r){let e=Math.min(...n.map(e=>e.createdAt??1/0),...h.map(e=>e.createdAt??1/0));if(Number.isFinite(e))for(let t of r){if(!t.ephemeral)break;(t.createdAt??1/0)>=e&&(t.createdAt=e-1)}d.value=l}return!0}catch(r){if(m.current!==c||Ot.current!==o||s.value!==t)return;$.warn(`load previous messages failed`,{err:r,conversationId:t,beforeId:i}),n.emit(`error`,r),e.onError?.(r);return}finally{m.current===c&&(m.current=void 0)}})()},[n,s,h,d,e,F]),Pt=V(async({newConversation:t})=>{let r=++Dt.current;function o(){return r!==Dt.current}let c=s.value,d=t||!c?Ht():c;d!==c&&(Ot.current++,p(!1),Jn(()=>{s.value=d,u.value=d}),i.saveConversationId(d)),F.primeIdentity(a,d);let f;try{f=await F.handshake({visitorId:a,conversationId:d,userPrefs:i.loadUserPrefs(),locale:Ge})}catch(r){if(o())return;n.emit(`error`,r),e.onError?.(r),t||te(!0);return}if(o())return;f.conversationId!==d&&kt(f.conversationId),Ae(f.agent),e.mode===`page`&&(f.site&&ti(f.site)?Ie(f.site):f.site&&$.warn(`invalid site config, using fallback`,{site:f.site}),f.blocks&&ni(f.blocks)?Re(f.blocks):f.blocks&&$.warn(`invalid blocks config, using fallback`,{blocks:f.blocks}));let m=Jt(f.userPrefs);if(Object.keys(m).length>0&&!t&&(i.saveUserPrefs(m),m.locale&&Ye(m.locale),m.soundMuted!==void 0&&Ue.setMuted(m.soundMuted),m.themeMode&&Xe(m.themeMode),m.textSize&&Ze(m.textSize)),oe.current=f.welcome,t||n.emit(`handshake`,f),f.welcome?.suggestions){let e=Ne.current;Me(f.welcome.suggestions.map(t=>({...t,label:ke(e,t.label),...t.text===void 0?{}:{text:ke(e,t.text)}})))}let h=!t&&c&&f.conversationId===c;l.current=!!h,h?ae.current||(ie.current=f.conversationId):(M.current=f.conversationId,wt(f.welcome?.messages),gt(f.conversationId)),t||te(!0)},[F,a,i,e,n,s,u,Ue,wt,Ge,kt,gt]),Ft=JSON.stringify(e.userContext??null);R(()=>{let t=Object.keys(Ve).length?{...Ve,...e.userContext}:e.userContext;F.setContext(t,Qp(e.pageContext))},[F,Ft,JSON.stringify(e.pageContext??null),JSON.stringify(Ve)]),R(()=>F.setUserToken(e.userToken),[F,e.userToken]);let It=V((e,t=[])=>Me(e.suggestions??t),[]);R(()=>(F.primeIdentity(a,s.value),Pt({newConversation:!1}),()=>{Dt.current++,Ot.current++}),[]),R(()=>{re&&C&&!ae.current&&(ae.current=!0,Tt.current=F.bootstrap(),(async()=>{try{let e=await Tt.current;T(yt((e??{forms:[]}).forms,Je))}catch(e){$.debug(`bootstrap failed — treating as no forms`,{err:e})}finally{D(!0)}})(),ie.current===s.value&&p(!0))},[re,C]);let Lt=z(null);R(()=>{if(!re||!C||(Lt.current??(Lt.current=Je),Lt.current===Je))return;Lt.current=Je;let e=!1;return F.bootstrap().then(t=>{e||T(yt((t??{forms:[]}).forms,Je))}).catch(e=>$.debug(`forms re-localize failed — keeping current copy`,{err:e})),()=>{e=!0}},[re,C,Je,F]);let Rt=z(Ft);R(()=>{C&&Rt.current!==Ft&&(Rt.current=Ft,Pt({newConversation:!1}))},[Ft,C,Pt]),hp({hostElement:t,mode:e.mode,panelSize:me,isOpen:k,surfaceReady:C,setIsOpen:A});let{sendAiTurn:zt,sendRoutedTurn:Bt}=Up({transport:F,messagesSig:d,conversationIdSig:s,options:e,bus:n,feedback:Ue,persistence:i,visitorId:a,adoptConversationId:kt,applyControlState:at,setCanSend:be,settleSuggestions:It,runCancellation:We}),{toolInteraction:Vt}=sp({streaming:Se,controlModeSig:nt,messagesSig:d,sendAiTurn:zt,bus:n,humanInLoop:e.features.humanInLoop}),Ut=V((e,t)=>{let r=d.value.find(t=>t.serverMessageId===e);r&&(r.feedback=t),$.info(`messageFeedback`,{messageId:e,value:t}),n.emit(`messageFeedback`,{messageId:e,value:t}),F.submitFeedback({messageId:e,value:t})},[n,d,F]);function Wt(){return d.value.reduce((e,t)=>e+ +(t.role===`user`),0)}let Kt=e.forms.list.length>0?e.forms:w??e.forms,qt=Fs({forms:Kt,persistence:i,userContext:()=>e.userContext,messageCount:Wt,pageArea:()=>e.pageContext?.area?String(e.pageContext.area):void 0,conversationId:()=>s.value,onComplete:(e,t,r,a)=>{$.info(`formSubmit`,{formId:e.id,trigger:t,skipped:a}),n.emit(`formSubmit`,{formId:e.id,values:r,skipped:a}),g(t=>{let n=t.find(t=>t.formId===e.id&&t.outcome===`skipped`)?.createdAt??Date.now();return[...t.filter(t=>t.formId!==e.id||t.outcome!==`skipped`),{key:`local:${e.id}:${n}`,formId:e.id,outcome:a?`skipped`:`submitted`,createdAt:n,...a?{}:{values:r}}]});let o=s.value??Ht();s.value||(s.value=o,i.saveConversationId(o),F.primeIdentity(void 0,o)),!a&&e.mirrorToContext&&He(e=>({...e,...r})),F.submitForm({formId:e.id,conversationId:o,trigger:t,values:r,skipped:a})}}),Yt=Dr(()=>qt.activeForm.value);Fp({activated:re,conversationReady:C,conversationIdSig:s,messagesSig:d,optionsRef:Pe,transport:F,visitorId:a,adoptControlStateChunk:ot,adoptMemoryCompactionStateChunk:ut,settleSuggestions:It,recordConversationReply:vt,transcriptRecoverySig:pt,beginConversationTranscript:ht,commitConversationTranscript:gt,onReplyLanded:V(()=>qt.fire(`after-messages`),[qt]),runCancellation:We,canContinueRef:xe,setCanSend:be,feedback:Ue,bus:n,loadInitialThread:Mt,shouldReconcileOnConnect:V(()=>l.current||d.value.some(e=>!e.ephemeral&&e.role===`user`),[d])}),R(()=>{qt.refresh()},[Kt,qt]);let Xt=e.pageContext?.area?String(e.pageContext.area):void 0,Zt=Dr(()=>d.value.length);R(()=>{C&&E&&qt.fire(`pre-chat`)},[C,E,qt]),R(()=>{E&&!ye&&qt.fire(`conversation-closed`)},[E,ye,qt]),R(()=>{C&&E&&Xt&&qt.fire(`page-area`)},[C,E,Xt,qt]);let Qt=B(()=>{let e=Kt.list.flatMap(e=>e.triggers).filter(e=>e.kind===`idle`).map(e=>Number(e.param));return e.length?Math.min(...e)*1e3:0},[Kt]);R(()=>{if(!Qt||!k)return;let e=setTimeout(()=>qt.fire(`idle`),Qt);return()=>clearTimeout(e)},[Qt,k,qt,Zt.value]);let $t=V(async(t,r,i)=>{if(Te.current)return!1;let a=s.value,o=a?lt.value.get(a):void 0,c=nt.value!==`ai-agent`;if(!c&&o?.status===`compacting`||($.info(`send`,{textLen:t.length,attachments:r.length,streaming:we.current,routedToOperator:c}),we.current&&!c))return!1;let l=new AbortController,u={conversationId:a,controller:l};Te.current=u,De(!0);try{Ue.unlock();let o=await em(F,r,l.signal,t=>{l.signal.aborted||($.warn(`upload failed`,{err:t}),n.emit(`error`,t),e.onError?.(t))});if(l.signal.aborted||s.value!==a||!xe.current||qt.activeForm.value)return!1;let c=a?lt.value.get(a):void 0,u=nt.value!==`ai-agent`;if(!u&&c?.status===`compacting`||we.current&&!u||!t&&o.length===0)return!1;n.emit(`send`,{text:t,attachmentCount:r.length}),je.length>0&&Me([]),Ue.play(`messageSent`);let f=bo(t,o,i);return Ps(n,e,`user`,t),u?(d.value=[...d.value,f],i?await Bt(f):(Bt(f),!0)):(d.value=[...d.value,f,xo()],i?await zt({continueExisting:!1}):(zt({continueExisting:!1}),!0))}finally{Te.current===u&&(Te.current=null,De(!1))}},[F,n,e,je.length,d,s,lt,zt,Bt,nt]),en=z($t);en.current=$t;let tn=s.value,nn=(tn?lt.value.get(tn):void 0)?.status===`compacting`,rn=nt.value===`ai-agent`,an=Dr(()=>{let e=d.value.at(-1);return e?.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`&&e.stateSig.value===`approval-requested`)}),on=Dr(()=>d.value.some(e=>e.retryAction?.kind===`resend-user`||e.retryAction?.kind===`continue-assistant`));Ln(()=>{let e=s.value;return()=>{let t=Te.current;t&&t.conversationId===e&&(Te.current=null,De(!1),t.controller.abort())}},[s.value]),R(()=>{(!ye||Yt.value)&&Te.current?.controller.abort()},[Yt.value,ye]);let sn=V(()=>{if(!We.stop())return;$.info(`stop`),n.emit(`stop`,void 0);let e=d.value.at(-1);e&&e.role!==`user`&&e.status===`streaming`&&(e.canceled=!0,d.value=[...d.value])},[We,n,d]),cn=V(e=>{if(Se)return;let t=d.value,n=ns(t,e);if(n)switch($.info(`retry`,{kind:n.kind,messageId:n.messageId}),n.kind){case`continue-assistant`:if(nt.value!==`ai-agent`||e.role!==`assistant`||(e.serverMessageId??e.id)!==n.messageId)return;e.status=`streaming`,e.errorText=void 0,e.retryAction=void 0,e.awaitingContinuation=!0,d.value=[...t],zt({continueExisting:!0,turn:e});return;case`resend-user`:{let r=t.find(e=>e.role===`user`&&e.id===n.messageId);if(!r)return;let i=e=>{e&&Ct.current?.acceptQueuedMessage(n.messageId)};if(r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,nt.value!==`ai-agent`){d.value=e.role===`assistant`?t.filter(t=>t!==e):[...t],Bt(r).then(i);return}let a=xo();d.value=e.role===`assistant`?t.map(t=>t===e?a:t):[...t,a],zt({continueExisting:!1,turn:r}).then(i);return}case`repeat-user`:{let e=t.find(e=>e.role===`user`&&e.id===n.messageId);if(!e)return;let r=bo(jo(e),e.attachments?.map(e=>({...e}))??[]),i=new Set(r.attachments?.flatMap(e=>e.url?[e.url]:[])??[]),a=e.partsSig.value.flatMap(e=>e.kind===`file`&&!i.has(e.url)?[{...e}]:[]);if(a.length>0&&(r.partsSig.value=[...r.partsSig.value,...a]),nt.value!==`ai-agent`){d.value=[...t,r],Bt(r);return}d.value=[...t,r,xo()],zt({continueExisting:!1,turn:r});return}default:return n}},[Se,d,nt,zt,Bt]),ln=V(()=>{Ns(e.mode,me)===`exit-fullscreen`?($.info(`close → exit-fullscreen`,{mode:e.mode}),he(`normal`),n.emit(`fullscreen`,!1)):($.info(`close → panel closed`,{mode:e.mode}),qt.fire(`panel-close`),A(!1),i.savePanelOpen(!1),n.emit(`close`,void 0),e.onClose?.())},[n,e,i,me,qt]),un=V(()=>{$.info(`open`,{mode:e.mode}),Ue.unlock(),le(!0),A(!0),i.savePanelOpen(!0),!ue&&!fe&&pe(),setTimeout(()=>le(!1),$p),n.emit(`open`,void 0),e.onOpen?.()},[n,e,Ue,i,ue,fe,pe]),dn=V(()=>{let e=d.value.some(e=>e.role===`user`);if(M.current===s.value&&!e&&ye&&s.value)$.info(`clear → reusing empty conversation`,{conversationId:s.value}),d.value.length===0&&wt(oe.current?.messages);else return $.info(`clear → new conversation`,{wasStreaming:Se}),n.emit(`clear`,void 0),We.settle(),l.current=!1,ie.current=void 0,M.current=void 0,Jn(()=>{d.value=[],s.value=void 0,at({controlMode:`ai-agent`,controlRevision:0})}),i.clearConversation(),be(!0),g([]),Me([]),Pt({newConversation:!0})},[Se,d,s,i,Pt,n,ye,wt,We,at]),fn=V(()=>{let t=dn();_e(`chat`);let n=e.modules.list.find(e=>e.layout===`chat`)?.id;return n&&x.switchTab(n),t},[dn,x,e]),pn=V(async e=>{await fn(),await en.current(e,[])||Ct.current?.fill(e)},[fn]),mn=V(()=>{let e=me===`expanded`?`normal`:`expanded`;$.info(`expand`,{from:me,expanded:e===`expanded`}),he(e),i.savePanelSize(e),n.emit(`expand`,e===`expanded`)},[n,me,i]),hn=V(()=>{let e=me===`fullscreen`?`normal`:`fullscreen`;$.info(`fullscreen`,{from:me,fullscreen:e===`fullscreen`}),he(e),i.savePanelSize(e),n.emit(`fullscreen`,e===`fullscreen`)},[n,me,i]),gn=V(()=>{_e(e=>{let t=e===`history`?`chat`:`history`;return $.info(`toggleHistory`,{view:t}),n.emit(`toggleHistory`,{view:t}),t})},[n]),_n=V(()=>{Be(e=>{let t=!e;return $.info(`sidebarToggle`,{collapsed:t}),i.saveSidebarCollapsed(t),n.emit(`sidebarToggle`,{collapsed:t}),t})},[i,n]),vn=V(e=>{$.info(`resize`,e),Qe({widgetSize:e}),n.emit(`resize`,e)},[Qe,n]),yn=V(async t=>{let r=t.conversationId;if(r===s.value&&_t(r)){$.info(`selectConversation`,{conversationId:r,cached:!0}),n.emit(`selectConversation`,{conversationId:r}),F.publishConversation(t),_e(`chat`);let e=v();e&&x.switchTab(e),gt(r);return}let o=++Dt.current;Ot.current++,p(!1);function c(){return o!==Dt.current}$.info(`selectConversation`,{conversationId:r,wasStreaming:Se}),n.emit(`selectConversation`,{conversationId:r}),F.publishConversation(t);try{let[e,t]=await Promise.all([F.loadConversation(r),Et(r)]);if(c())return;We.settle(),l.current=!0,ie.current=void 0;let n=Oo(e.messages),o=e.conversationId!==s.value,f=o?n:Jo(n,d.value);M.current=f.some(e=>e.role===`user`)?void 0:e.conversationId,Jn(()=>{d.value=At(f,t),o&&(u.value=e.conversationId),s.value=e.conversationId}),g(t),i.saveConversationId(e.conversationId),F.primeIdentity(a,e.conversationId),be(e.canContinue),e.controlState&&at(e.controlState);let p=f.findLast(e=>e.role===`assistant`&&!e.ephemeral);Me(p?.suggestions??[]),o?ht(e.conversationId):gt(e.conversationId),_e(`chat`);let m=v();m&&x.switchTab(m)}catch(t){if(c())return;n.emit(`error`,t),e.onError?.(t)}},[F,d,s,u,n,e,i,Et,At,Se,a,We,ht,gt,_t,x]),bn=z(null),xn=V(e=>{typeof e==`string`&&(E?qt.fire(`manual`,e):bn.current=e)},[E,qt]);R(()=>{E&&bn.current&&(qt.fire(`manual`,bn.current),bn.current=null)},[E,qt]);let Sn=z(void 0),Cn=V(t=>{let n=e.modules.list.find(e=>e.layout===Yp[t.to]);if(!n){$.warn(`open: the widget has no such tab`,{to:t.to});return}let r=t.id&&(n.layout===`help`||n.layout===`news`)?{kind:`content`,id:t.id,title:``}:void 0;x.open(n.id,r)},[e.modules,x]),wn=V(e=>{k||un(),e!==void 0&&(Nr(e)?C?Cn(e):Sn.current=e:$.warn(`open: unknown target`,{detail:e}))},[k,un,C,Cn]);R(()=>{C&&Sn.current&&(Cn(Sn.current),Sn.current=void 0)},[C,Cn]);let Tn=C&&!f&&!Yt.value&&(!rn||!an.value&&!on.value),[En,Dn]=L(),On=V(e=>{let t=Ir(e);t?(k||un(),Dn(t)):$.warn(`ask: expected { text, send? } with non-empty text`,{detail:e})},[k,un]),kn=k&&E&&ye&&C&&!f&&!Yt.value,An=kn&&Tn&&!Ee&&!(rn&&(Se||nn));R(()=>{if(En===void 0||!(En.send?An:kn))return;let e=v();e?N!==`chat`||!y()?(_e(`chat`),x.switchTab(e)):(Dn(void 0),En.send?$t(En.text,[]).then(e=>{e||Ct.current?.fill(En.text)}):Ct.current?.fill(En.text)):($.warn(`ask: the widget has no chat`),Dn(void 0))},[En,kn,An,N,S,e.modules,x,$t]),R(()=>{if(e.widgetId!=="default")return;let n=`data-${P.cssPrefix}-`,r=[`ask`,`open`,`close`,`form`].map(e=>n+e);function i(e){let i=e.composedPath().find(e=>e instanceof Element&&r.some(t=>e.hasAttribute(t)));if(!(i instanceof Element))return;e.preventDefault();let a=i.getAttribute(`${n}ask`),o=i.getAttribute(`${n}open`),s=i.getAttribute(`${n}form`);a===null?o===null?s===null?Rr(t,`close`):Rr(t,`openForm`,s):Rr(t,`open`,Pr(o)):Rr(t,`ask`,Fr(a||(i.textContent??``),{send:i.hasAttribute(`${n}send`)}))}return document.addEventListener(`click`,i),()=>document.removeEventListener(`click`,i)},[e.widgetId,t]),R(()=>{if(e.widgetId!=="default")return;let n=Vr(location.href);n&&(history.replaceState(history.state,``,n.url),n.ask?Rr(t,`ask`,Fr(n.ask)):Rr(t,`open`,n.target))},[e.widgetId,t]);let jn=z(c),Mn=e.mode===`page`||e.mode===`inline`||e.mode===`standalone`;R(()=>gr(()=>{let e=s.value,t={open:Mn||k,ready:C,unread:ft.value,...e?{conversationId:e}:{}},r=jn.current;(t.open!==r.open||t.ready!==r.ready||t.unread!==r.unread||t.conversationId!==r.conversationId)&&(jn.current=t,n.emit(`state`,t),t.unread!==r.unread&&n.emit(`unread`,t.unread))}),[n,Mn,k,C,ft,s]);let Nn=z({handleOpenCommand:wn,handleClose:ln,handleExpand:mn,handleFullscreen:hn,openForm:xn,handleAskCommand:On});Nn.current={handleOpenCommand:wn,handleClose:ln,handleExpand:mn,handleFullscreen:hn,openForm:xn,handleAskCommand:On},Ln(()=>zr(t,{open:e=>Nn.current.handleOpenCommand(e),close:()=>Nn.current.handleClose(),expand:()=>Nn.current.handleExpand(),fullscreen:()=>Nn.current.handleFullscreen(),openForm:e=>Nn.current.openForm(e),ask:e=>Nn.current.handleAskCommand(e)}),[t]);let Pn=B(()=>St(e,Ge,Ke,qe),[e,Ge,Ke,qe]);Ne.current=Pn.strings;let Fn=B(()=>h.map(e=>{let t=Kt.list.find(t=>t.id===e.formId);return{...e,title:t?.title,form:t}}),[h,Kt]);function In(e){yn(e)}let Rn={options:Pn,transport:F,feedback:Ue,bus:n,persistence:i,conversationId:s.value??``,composerKey:u.value,composerApiRef:Ct,view:N,canSend:ye,isStreaming:Se,isMemoryCompacting:nn,canReleaseQueuedMessages:Tn,queueManualMessages:rn&&(an.value||on.value),sendPreparing:Ee,composerActive:Pn.mode===`page`||Pn.mode===`inline`||Pn.mode===`standalone`||k,controlMode:nt.value,assignedOperatorInitials:rt.value,operatorAvailable:it.value,operatorRequestEnabled:e.features.operatorRequest,onRequestOperator:st,onCancelOperatorRequest:ct,loadingMessages:f,onLoadPreviousMessages:Nt,messagesSig:d,agent:Oe,suggestions:je,initialWidgetSize:o.widgetSize??null,onClose:ln,onClear:dn,onExpand:mn,onFullscreen:hn,onSoundToggle:tt,onToggleHistory:gn,onSelectHistoryConversation:In,onNewConversation:fn,onLocaleChange:I,onThemeChange:$e,onTextSizeChange:et,onWidgetSizeChange:vn,onSend:$t,onStop:sn,onSuggestion:t=>{if(Te.current)return;let r=t.text??t.label;$.info(`suggestion`,{text:r,autoSend:e.autoSendSuggestions}),n.emit(`suggestion`,{text:r}),e.autoSendSuggestions?$t(r,[]):Ct.current?.fill(r)},activeForm:Yt.value?.form??null,formMarkers:Fn,onFormSubmit:qt.complete,onFormSkip:qt.skip,onFormFill:e=>qt.fire(`manual`,e),tool:Vt,onRetry:cn,onMessageFeedback:Ut};if(!C)return null;let zn=Pn.modules.list;function Bn(e){let t=js(`close`,Pn.mode,e);return zn.length===0?/* @__PURE__ */ U(Qf,{strings:Pn.strings,onClose:t?ln:void 0}):zn.length===1&&zn[0]?.layout===`chat`?/* @__PURE__ */ U(Bf,{...Rn,panelSize:e}):/* @__PURE__ */ U(Xf,{panelProps:{...Rn,panelSize:e,onClose:t?ln:void 0},enabledModules:zn,nav:x,bus:n,hasUnread:dt.value,latestNews:xt,onSelectConversation:In,onStartNewConversation:pn,onSetPanelSize:he})}if(e.mode===`page`){let e=zn.some(e=>e.layout===`chat`);return/* @__PURE__ */ U(`div`,{class:`${Jp}-anchor`,children:/* @__PURE__ */ U(ap,{site:Fe,blocks:Le,transport:F,strings:Pn.strings,locale:Pn.locale,persistence:i,showConversations:e,onSelectConversation:In,onNewConversation:fn,sidebarCollapsed:ze,onToggleSidebarCollapsed:_n,children:Bn(`fullscreen`)})})}if(O){let t=e.mode===`standalone`?`fullscreen`:me;return/* @__PURE__ */ U(`div`,{class:`${Jp}-anchor`,children:Bn(t)})}let Vn=e.mode===`drawer`,Hn=e.mode!==`modal`&&!e.launcher.hidden&&(!k||ce),Un=Hn&&!ce&&!ue&&!Vn?Pn.launcher.callout:null;return/* @__PURE__ */ U(`div`,{class:`${Jp}-anchor`,"data-launcher-size":Pn.launcher.size,children:[k||re?/* @__PURE__ */ U(`div`,{class:`${Jp}-surface`,hidden:!k,children:Bn(me)}):null,Hn?/* @__PURE__ */ U($c,{onToggle:un,launcher:Pn.launcher,strings:Pn.strings,leaving:ce,edgeTab:Vn}):null,Un?/* @__PURE__ */ U(rl,{callout:Un,launcherPosition:Pn.position,strings:Pn.strings,closeLabel:Pn.strings.close,onDismiss:pe}):null]})}function Qp(e){let t=e?.url??(typeof location<`u`?location.href:void 0);if(e||t)return{...e,...t?{url:t}:{}}}const $p=120;async function em(e,t,n,r){return(await Promise.all(t.map(async t=>{try{let{id:r,url:i,originalName:a,mimeType:o,fileSize:s}=await e.uploadFile(t.file,n);return{id:r,name:a,mediaType:o,size:s,url:i}}catch(e){r(e);return}}))).filter(e=>e!==void 0)}const tm=I.scope(`error-boundary`);var nm=class extends ne{constructor(...e){super(...e),s(this,`state`,{crashed:!1})}componentDidCatch(e,t){tm.error(`widget render crashed`,{error:e,componentStack:t?.componentStack}),this.setState({crashed:!0}),this.props.onError(e,t?.componentStack)}render(){return this.state.crashed?this.props.fallback:this.props.children}};function rm(e){let{bus:t,host:n,appRoot:r,persistence:i,reportError:a}=e,o=e.initialRaw,s,c=ct(o),l=!0,u=0;function d(){c=ct(s?wt(o,s):o)}function f(){un(n,dn(c.mode));let e=i.loadUserPrefs().themeMode;yn(n,e?{...c,themeMode:e}:c),l&&(vn(n,im(c)),l=!1)}function p(){f(),ve(E(nm,{onError:a},E(Zp,{key:u,bus:t,hostElement:n,options:c})),r)}t.on(`handshake`,e=>{e.config&&(e.config.storageVersion&&i.rememberStorageVersion(e.config.storageVersion),s=e.config,d(),p())});let m=en(t,{getOptions:()=>c,getVisitorId:()=>i.getVisitorId(),getConversationId:()=>i.loadConversationId()});function h(e={}){i.reset(),o={...o,userContext:void 0,userToken:void 0,...e},u+=1,l=!0,d(),p()}return{getOptions:()=>c,getUserOptions:()=>o,render:p,setUserOptions:e=>{o=e,d(),p()},patchUserOptions:e=>{let t=`userToken`in e&&e.userToken!==o.userToken;t&&o.userToken?h(e):(t&&(u+=1),o={...o,...e},d(),p())},reset:()=>h(),destroy:()=>m()}}function im(e){if(e.mode===`standalone`)return`standalone`;if(e.mode===`inline`)return`inline`;let t=Gt(e.widgetId,e.storage,e.aiAgentDeploymentId),{panelOpen:n,panelSize:r}=qs(e,Js(),t.loadPanelOpen(),t.loadPanelSize());return Gs(e.mode,r,n)}const am=I.scope(`hooks`),om=`*`,sm=/* @__PURE__ */ new Set;function cm(e,t,n){let r={widgetId:e,event:t,listener:n};return sm.add(r),()=>{sm.delete(r)}}function lm(e,t,n){let r=[...sm];for(let i of r)if(dm(i.widgetId,e.widgetId)&&(i.event===`*`||i.event===t))try{i.listener(e,t,n)}catch(e){am.warn(`hook listener threw`,{event:t,error:e})}}function um(e,t){let n=[];for(let r of fm)n.push(t.on(r,t=>{lm(e,r,t)}));return()=>{for(let e of n)e()}}function dm(e,t){return e===`*`||e===t}const fm=/* @__PURE__ */ `open.close.expand.fullscreen.resize.message.send.stop.clear.selectConversation.suggestion.toggleHistory.formSubmit.toolResult.toolDecision.messageFeedback.contentView.contentOpen.contentSearch.contentRead.contentLinkClick.attach.removeAttachment.voiceStart.voiceStop.voiceCancel.localeChange.themeChange.textSizeChange.soundToggle.sidebarToggle.calloutDismiss.error.handshake.conversationRebound.state.unread`.split(`.`),pm=I.scope(`iframe`);function mm(e,t,n=`closed`,r=`floating`,i=null){pm.debug(`createIframeMount`,{position:t,initialMode:n,layoutMode:r,hasTarget:!!i});let a=document.createElement(`iframe`);a.title=`${P.name} chat`,a.setAttribute(`allow`,`microphone; clipboard-write`),_m(a,t,n,r),(r===`inline`&&i?i:document.body).appendChild(a);let o=a.contentDocument;if(!o)throw Error(`iframe contentDocument unavailable (cross-origin?)`);o.open(),o.write(`<!doctype html><html><head><meta charset="utf-8"><style>html,body{margin:0;padding:0;background:transparent;overflow:hidden}</style></head><body></body></html>`),o.close();let s=fn({...e,target:o.body}),c=new MutationObserver(()=>{_m(a,t,s.hostElement.dataset.mode??`closed`,r)});return c.observe(s.hostElement,{attributes:!0,attributeFilter:[`data-mode`]}),{...s,iframeElement:a,destroy(){c.disconnect(),s.destroy(),a.remove()}}}const hm=`border:0;background:transparent;z-index:2147483647;pointer-events:auto;`,gm={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 _m(e,t,n,r){if(n===`fullscreen`||r===`standalone`){e.style.cssText=`${hm}position:fixed;inset:0;width:100vw;height:100vh;`;return}if(r===`inline`){e.style.cssText=`${hm}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=`${hm}position:fixed;inset:0;width:100vw;height:100vh;`;return}let i=t.startsWith(`top-`)?`top`:`bottom`,a=t.endsWith(`-left`)?`left`:`right`,{w:o,h:s}=gm[n]??gm.open;e.style.cssText=`${hm}position:fixed;${i}:16px;${a}:16px;width:${o};height:${s};`}const vm=/* @__PURE__ */ new Map;function ym(e){if(!e.aiAgentDeploymentId)throw Error(`aiAgentDeploymentId is required`);e.debug!==void 0&&Xe(e.debug);let t=I.scope(`mount`);t.info(`mount`,{widgetId:e.widgetId,publicKey:e.publicKey,mode:e.presentation?.mode});let n=ct(e),r=n.widgetId,i=vm.get(r);i&&(t.debug(`destroy existing instance at slot`,{widgetId:r}),i.destroy());let a=im(n),o=n.iframe?mm({position:dn(n.mode)},n.position,a,n.mode,e.target??null):fn({position:dn(n.mode),target:e.target??null});o.hostElement.dataset.widgetId=r;let s=new l,u=Gt(r,n.storage,n.aiAgentDeploymentId);function d(e){s.emit(`error`,e),f.getOptions().onError?.(e)}let f=rm({bus:s,host:o.hostElement,appRoot:o.appRoot,persistence:u,initialRaw:e,reportError:d}),p=c,m=()=>{},h=new Promise(e=>{m=e});s.on(`state`,e=>{p=e,e.ready&&m()}),f.render();let g=o.hostElement,_=null;function v(e){e.debug!==void 0&&Xe(e.debug),f.patchUserOptions(e)}let y={widgetId:r,open:e=>Rr(g,`open`,e),close:()=>Rr(g,`close`),expand:()=>Rr(g,`expand`),openForm:e=>Rr(g,`openForm`,e),ask:(e,t)=>Rr(g,`ask`,Fr(e,t)),on:(e,t)=>s.on(e,t),update:e=>{t.debug(`update`,{patch:e}),v(e)},setUserContext:e=>{t.debug(`setUserContext`,{keys:Object.keys(e)}),v({userContext:{...f.getUserOptions().userContext,...e}})},clearUserContext:()=>{t.debug(`clearUserContext`),v({userContext:void 0})},setPageContext:e=>{t.debug(`setPageContext`,{keys:Object.keys(e)}),v({pageContext:{...f.getUserOptions().pageContext,...e}})},clearPageContext:()=>{t.debug(`clearPageContext`),v({pageContext:void 0})},get state(){return p},ready:h,reset:()=>{t.info(`reset`,{widgetId:r}),f.reset()},login:e=>{t.info(`login`,{widgetId:r}),v({userToken:e})},setDebug:e=>{Xe(e),t.info(`debug level set`,{level:Ze()})},debugLevel:()=>Ze(),onLog:e=>$e(e),destroy:()=>{t.info(`destroy`,{widgetId:r}),s.emit(`state`,c),_?.(),f.destroy(),s.clear(),ve(null,o.appRoot),o.destroy(),vm.get(r)===y&&vm.delete(r)}};return _=um(y,s),vm.set(r,y),y}function bm(e){if(!e.aiAgentDeploymentId)throw Error(`aiAgentDeploymentId is required`);let t=e.widgetId??`default`,n=vm.get(t);return n?(n.update(e),n):ym(e)}function xm(e){if(e!==void 0){vm.get(e)?.destroy();return}let t=[...vm.values()];for(let e of t)e.destroy()}function Sm(e=`default`){return vm.get(e)??null}function Cm(){return[...vm.values()]}function wm(e,t,n){return cm(e,t,n)}const Tm=Yt,Em=P,Dm=/* @__PURE__ */ new WeakMap;let Om=0;function km(e){if(typeof e!=`function`)return e;let t=Dm.get(e)??++Om;return Dm.set(e,t),`function#${t}`}function Am(t){let r=n(t);r.current=t;let i=t.widgetId??`default`,a=JSON.stringify({...t,userToken:km(t.userToken)});return e(()=>()=>xm(i),[i]),e(()=>{bm({...r.current,userToken:r.current.userToken,onMessage:e=>r.current.onMessage?.(e),onOpen:()=>r.current.onOpen?.(),onClose:()=>r.current.onClose?.(),onError:e=>r.current.onError?.(e)})},[a]),null}function jm(e=`default`){return{state:r(t=>wm(e,`state`,t),()=>Sm(e)?.state??c,()=>c),...t(()=>({ask:(t,n)=>Sm(e)?.ask(t,n),open:t=>Sm(e)?.open(t),close:()=>Sm(e)?.close(),reset:()=>Sm(e)?.reset()}),[e])}}export{om as HOOK_WILDCARD,Am as HelpAI,Em as brand,xm as destroy,Cm as getAllInstances,Sm as getInstance,wm as hook,bm as init,ym as mount,im as resolveInitialHostMode,jm as useHelpAI,Tm as version};
61
+ `).trim(),O=!v&&t!==`error`&&!m.value&&D.length>0,ee=E||O;return/* @__PURE__ */ U(`div`,{class:`${sp}-bubble-row`,"data-role":e.role,"data-testid":Hl(Z.messageBubble,e.serverMessageId??e.id),children:/* @__PURE__ */ U(`div`,{class:`${sp}-bubble-col`,children:[/* @__PURE__ */ U(`div`,{class:`${sp}-bubble`,children:[e.role===`operator`&&e.operatorInitials?/* @__PURE__ */ U(`span`,{class:`${sp}-bubble-author`,children:e.operatorInitials}):null,/* @__PURE__ */ U(`div`,{class:`${sp}-bubble-body`,children:[x?/* @__PURE__ */ U(_p,{label:n.loading}):p.map((r,u)=>/* @__PURE__ */ U(fp,{part:r,generativeUi:e.role===`assistant`,active:S,live:y,strings:n,showReasoning:i,showToolCalls:a,showSources:o,interactive:s&&t===`complete`&&(r.kind!==`tool`||Ns(e,u)),superseded:c,continuationStreaming:e.continuationStreaming===!0,tool:l},`${hp(r)}#${u}`)),C&&/* @__PURE__ */ U(gp,{}),t===`error`||m.value?/* @__PURE__ */ U(`div`,{class:`${sp}-error`,role:`alert`,children:[/* @__PURE__ */ U(`span`,{children:e.errorText??n.errorGeneric}),u?/* @__PURE__ */ U(`button`,{type:`button`,class:`${sp}-error-retry`,onClick:()=>u(e),"data-testid":Z.messageRetry,children:n.errorRetry}):null]}):null]})]}),w||ee?/* @__PURE__ */ U(`div`,{class:`${sp}-bubble-meta`,children:[w?/* @__PURE__ */ U(`time`,{class:`${sp}-bubble-time`,dateTime:w.iso,title:w.full,children:w.short}):null,ee?/* @__PURE__ */ U(`div`,{class:`${sp}-bubble-actions`,children:[E&&e.serverMessageId?/* @__PURE__ */ U(hf,{messageId:e.serverMessageId,initial:e.feedback??null,strings:n,onFeedback:f}):null,O?/* @__PURE__ */ U(up,{text:D,strings:n}):null]}):null]}):null]})})}function up({text:e,strings:t}){let[n,r]=I(!1);function i(){navigator.clipboard?.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)}).catch(()=>{})}let a=n?t.copied:t.copy;return/* @__PURE__ */ U(`button`,{type:`button`,class:`${sp}-msg-action`,"data-active":n?`true`:void 0,"aria-label":a,title:a,onClick:i,"data-testid":Z.messageCopy,children:U(n?cl:Pl,{})})}function dp(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 fp({part:e,generativeUi:t,active:n,live:r,strings:i,showReasoning:a,showToolCalls:o,showSources:s,interactive:c,superseded:l,continuationStreaming:u,tool:d}){switch(e.kind){case`step-start`:return null;case`text`:return/* @__PURE__ */ U(eu,{textSig:e.textSig,doneSig:e.doneSig,generativeUi:t,strings:i});case`reasoning`:return a?/* @__PURE__ */ U(mp,{part:e,active:n,strings:i}):null;case`tool`:return/* @__PURE__ */ U(pp,{part:e,strings:i,showToolCalls:o,interactive:c,superseded:l,continuationStreaming:u,live:r,tool:d});case`file`:return e.mediaType.startsWith(`image/`)?/* @__PURE__ */ U(`img`,{src:e.url,alt:``,loading:`lazy`}):/* @__PURE__ */ U(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,children:e.url});case`source`:return s?/* @__PURE__ */ U(Rf,{part:e,strings:i}):null}}function pp({part:e,strings:t,showToolCalls:n,interactive:r,superseded:i,continuationStreaming:a,live:o,tool:s}){let c=z(()=>H(()=>e.approvalSig.value!==void 0),[e]);return s?.humanInLoop&&c.value?pf(e.toolName)?/* @__PURE__ */ U(Qf,{part:e,strings:t,active:r,superseded:i,continuationStreaming:a,onDecision:s.onDecision,onEdit:s.onEdit}):/* @__PURE__ */ U(Bf,{part:e,strings:t,active:r,superseded:i,continuationStreaming:a,onDecision:s.onDecision,onEdit:s.onEdit}):n?/* @__PURE__ */ U(op,{part:e,strings:t,live:o,superseded:i}):null}function mp({part:e,active:t,strings:n}){return/* @__PURE__ */ U(`details`,{class:`${sp}-reasoning`,"data-testid":Z.reasoning,open:t,"data-active":t?`true`:void 0,children:[/* @__PURE__ */ U(`summary`,{class:`${sp}-reasoning-summary`,children:/* @__PURE__ */ U(`span`,{class:`${sp}-reasoning-label`,children:t?n.thinking:n.thoughts})}),/* @__PURE__ */ U(`div`,{class:`${sp}-reasoning-body`,children:/* @__PURE__ */ U(eu,{textSig:e.textSig,doneSig:e.doneSig})})]})}function hp(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 gp(){return/* @__PURE__ */ U(`span`,{class:`${sp}-typing`,"data-testid":Z.typingDots,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`span`,{}),/* @__PURE__ */ U(`span`,{}),/* @__PURE__ */ U(`span`,{})]})}function _p({label:e}){return/* @__PURE__ */ U(`span`,{class:`${sp}-loading`,role:`status`,children:[/* @__PURE__ */ U(`span`,{class:`${sp}-loading-spinner`,"aria-hidden":`true`}),/* @__PURE__ */ U(`span`,{class:`${sp}-loading-label`,children:e})]})}const vp=u.cssPrefix;function yp({messagesSig:e,strings:t,responseMode:n,showReasoning:r,showToolCalls:i,showSources:a,enableMessageFeedback:o,onFeedback:s,loading:c,onLoadPreviousMessages:l,idle:u,controlMode:d=`ai-agent`,tool:f,onRetry:p,form:m,formMarkers:h,onFillForm:g}){let _=R(null),v=vi(()=>e.value),[y,b]=I(!1),[x,S]=I(!1),C=R(!1),w=R(!1),[T,E]=I(),D=R(!1),O=R(!1),ee=R(!1),k=R(0);function te(){return ee.current||performance.now()-k.current<350}let ne=R(0);function A(e){let t=e.scrollHeight-e.clientHeight>1;e.dataset.fadeTop=t&&e.scrollTop>1?`true`:`false`,e.dataset.fadeBottom=t&&e.scrollHeight-e.scrollTop-e.clientHeight>1?`true`:`false`}function j(e){return b(e.scrollHeight-e.scrollTop-e.clientHeight>240)}function re(e){ne.current=performance.now(),e.scrollTop=e.scrollHeight,A(e)}function ie(e,t){re(e);let n=t,r=0;function i(){O.current||te()||(re(e),--n>0&&(r=requestAnimationFrame(i)))}return t>0&&(r=requestAnimationFrame(i)),()=>cancelAnimationFrame(r)}function ae(e,t){let n,r,i,a=-1;function o(){n.disconnect(),r.disconnect(),clearTimeout(i)}function s(){if(O.current||te()||a>=0&&e.scrollTop<a-4)return o();re(e),a=e.scrollTop}return n=new ResizeObserver(s),r=new MutationObserver(s),s(),n.observe(e),r.observe(e,{childList:!0,subtree:!0,characterData:!0}),i=setTimeout(o,t),o}let oe=v.value[0]?.id;kr(()=>{let e=_.current;if(e&&v.value.length!==0&&!w.current&&(D.current=!0,v.value.some(e=>e.role===`user`)))return ae(e,300)},[oe]);let se=R(0);L(()=>{let e=_.current,t=v.value,n=se.current;if(se.current=t.length,e&&D.current&&!w.current){if(t.slice(n).some(e=>e.role===`user`))return O.current=!1,ie(e,3);t.some(e=>e.role===`user`)&&(O.current||te()||e.scrollHeight-e.scrollTop-e.clientHeight<120&&re(e))}},[v.value.length]);let ce=R(null);L(()=>{let e=_.current,t=v.value.at(-1),n=ce.current;if(ce.current=t?{id:t.id,streaming:t.status===`streaming`}:null,e&&D.current&&t&&t.id===n?.id&&!n.streaming&&t.status===`streaming`)return O.current=!1,ie(e,3)},[v.value]),L(()=>{let e=_.current;if(!e)return;let t=v.value.at(-1);if(!t||t.status!==`streaming`&&!v.value.some(e=>e.role===`user`))return;let n=()=>{O.current||te()||e.scrollHeight-e.scrollTop-e.clientHeight<240&&re(e)};if(t.status!==`streaming`)return ae(e,300);n();let r=new MutationObserver(n);return r.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>r.disconnect()},[v.value]);let le=m?.form.id,M=!!m&&(h??[]).some(e=>e.formId===m.form.id);kr(()=>{let e=_.current;e&&le&&!O.current&&v.value.some(e=>e.role===`user`)&&(M?e.querySelector(`[data-testid="${Z.formGate}"]`)?.scrollIntoView({block:`nearest`}):re(e))},[le,M]),L(()=>{let e=_.current;if(!e)return;let t=()=>{j(e),A(e),performance.now()-ne.current>150&&(O.current=e.scrollHeight-e.scrollTop-e.clientHeight>8)};function n(){O.current=!0}function r(e){e.deltaY<0&&n()}let i=0;function a(e){i=e.touches[0]?.clientY??0,ee.current=!0}function o(e){(e.touches[0]?.clientY??0)>i+4&&n()}function s(){ee.current=!1,k.current=performance.now()}function c(){ee.current=!0}return e.addEventListener(`scroll`,t,{passive:!0}),e.addEventListener(`wheel`,r,{passive:!0}),e.addEventListener(`touchstart`,a,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`touchend`,s,{passive:!0}),e.addEventListener(`touchcancel`,s,{passive:!0}),e.addEventListener(`pointerdown`,c,{passive:!0}),window.addEventListener(`pointerup`,s,{passive:!0}),window.addEventListener(`pointercancel`,s,{passive:!0}),j(e),()=>{e.removeEventListener(`scroll`,t),e.removeEventListener(`wheel`,r),e.removeEventListener(`touchstart`,a),e.removeEventListener(`touchmove`,o),e.removeEventListener(`touchend`,s),e.removeEventListener(`touchcancel`,s),e.removeEventListener(`pointerdown`,c),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)}},[]);function ue(){let e=_.current;e&&(O.current=!1,re(e))}let de=v.value.filter(e=>!e.ephemeral),fe=de[0],pe=fe?.serverMessageId??fe?.id,me=!!(l&&de.length>=50&&pe!==T);async function he(){if(!l||C.current)return;let e=_.current,t=e?.scrollHeight??0,n=e?.scrollTop??0;C.current=!0,w.current=!0,S(!0);try{let r=await l();r===!1&&pe&&E(pe),r&&e&&(await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e()))),e.scrollTop=n+e.scrollHeight-t,A(e),j(e))}finally{w.current=!1,C.current=!1,S(!1)}}let N=[],ge=``,_e=v.value.at(-1)?.id,ve=[...h??[]].toSorted((e,t)=>(e.createdAt??1/0)-(t.createdAt??1/0));function ye(e){return m&&e.formId===m.form.id?/* @__PURE__ */ U(Qd,{form:m.form,strings:t,onSubmit:m.onSubmit,onSkip:m.onSkip},`gate:${e.formId}`):/* @__PURE__ */ U($d,{marker:e,strings:t,onFill:!m&&g?()=>g(e.formId):void 0},e.key)}function be(e){for(let t=ve[0];t?.createdAt!==void 0&&!(e!==void 0&&t.createdAt>e);t=ve[0])ve.shift(),N.push(ye(t))}for(let e of v.value){if(e.role===`assistant`&&e.id!==_e&&qs(e))continue;be(e.createdAt);let c=bp(e.createdAt);c&&c!==ge&&(N.push(/* @__PURE__ */ U(`div`,{class:`${vp}-date-divider`,children:/* @__PURE__ */ U(`span`,{class:`${vp}-date-pill`,title:xp(e.createdAt),children:Sp(e.createdAt,t)})},`day:${c}`)),ge=c);let l=e.retryAction!==void 0||e.role===`assistant`&&e.id===_e?Js(v.value,e):void 0,m=l!==void 0&&(l.kind!==`continue-assistant`||d===`ai-agent`);N.push(/* @__PURE__ */ U(cp,{message:e,status:e.status,strings:t,responseMode:n,showReasoning:r,showToolCalls:i,showSources:a,interactive:!!u&&d===`ai-agent`&&e.id===_e,superseded:e.id!==_e,tool:f,onRetry:u&&m&&(e.role===`user`||e.id===_e)?p:void 0,enableMessageFeedback:o,onFeedback:s},e.id))}for(let e of ve)N.push(ye(e));return/* @__PURE__ */ U(`div`,{class:`${vp}-list-wrap`,children:[/* @__PURE__ */ U(`div`,{ref:_,class:`${vp}-list ${vp}-list--fade`,part:`messages`,role:`log`,"aria-live":`polite`,"aria-relevant":`additions text`,children:[c&&v.value.length===0?/* @__PURE__ */ U(`div`,{class:`${vp}-list-loading`,role:`status`,children:t.conversationLoading}):null,me?/* @__PURE__ */ U(`div`,{class:`${vp}-load-previous`,children:/* @__PURE__ */ U(`button`,{type:`button`,onClick:he,disabled:x,"aria-busy":x,"data-testid":Z.loadPreviousMessages,children:t.loadPreviousMessages})}):null,N,m&&!M?/* @__PURE__ */ U(Qd,{form:m.form,strings:t,onSubmit:m.onSubmit,onSkip:m.onSkip}):null]}),y?/* @__PURE__ */ U(`button`,{type:`button`,class:`${vp}-jump`,onClick:ue,"aria-label":t.scrollToBottom,title:t.scrollToBottom,"data-testid":Z.scrollToBottom,children:/* @__PURE__ */ U(pl,{})}):null]})}function bp(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function xp(e){if(typeof e!=`number`||!Number.isFinite(e))return``;try{return new Date(e).toLocaleDateString(void 0,{dateStyle:`full`})}catch{return``}}function Sp(e,t){let n=new Date(e);function r(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}let i=Math.round((r(/* @__PURE__ */ 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`})}function Cp({panelEl:e,resize:t,position:n,initialSize:r,onSizeChange:i,strings:a}){let o=u.cssPrefix,s=R(null);if(L(()=>{if(!e)return;let n=e.style;t.minWidth&&n.setProperty(`--${o}-resize-min-w`,t.minWidth),t.maxWidth&&n.setProperty(`--${o}-resize-max-w`,t.maxWidth),t.minHeight&&n.setProperty(`--${o}-resize-min-h`,t.minHeight),t.maxHeight&&n.setProperty(`--${o}-resize-max-h`,t.maxHeight),r&&(n.setProperty(`--${o}-widget-w`,`${r.width}px`),n.setProperty(`--${o}-widget-h`,`${r.height}px`))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,o,r]),!e)return null;let c=n.startsWith(`top-`),l=n.endsWith(`-right`),d=`${o}-resize-grip ${o}-resize-grip--${c?`bottom`:`top`}-${l?`left`:`right`}`;function f(t){if(!e)return;let n=t.currentTarget,r=e.getBoundingClientRect();s.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startW:r.width,startH:r.height,dirX:l?-1:1,dirY:c?1:-1},n.setPointerCapture(t.pointerId),e.setAttribute(`data-resizing`,``),t.preventDefault()}function p(t){let n=s.current;if(!n||t.pointerId!==n.pointerId||!e)return;let r=(t.clientX-n.startX)*n.dirX,i=(t.clientY-n.startY)*n.dirY;e.style.setProperty(`--${o}-widget-w`,`${n.startW+r}px`),e.style.setProperty(`--${o}-widget-h`,`${n.startH+i}px`)}function m(t){let n=s.current;if(!n||t.pointerId!==n.pointerId||!e)return;t.currentTarget.releasePointerCapture(t.pointerId),e.removeAttribute(`data-resizing`);let r=e.getBoundingClientRect();i({width:Math.round(r.width),height:Math.round(r.height)}),s.current=null}return/* @__PURE__ */ U(`div`,{class:d,role:`separator`,"aria-orientation":`vertical`,"aria-label":a.resizeHandle,title:a.resizeHandle,onPointerDown:f,onPointerMove:p,onPointerUp:m,onPointerCancel:m,"data-testid":Z.resizeGrip,children:/* @__PURE__ */ U(nl,{})})}const wp=u.cssPrefix;function Tp({suggestions:e,onPick:t,disabled:n=!1}){return e.length===0?null:/* @__PURE__ */ U(`div`,{class:`${wp}-suggestions`,role:`group`,"aria-label":`Suggested replies`,children:e.map((e,r)=>/* @__PURE__ */ U(`button`,{type:`button`,class:`${wp}-suggestion`,onClick:()=>t(e),disabled:n,"data-testid":Hl(Z.suggestion,r),children:e.label},e.id))})}const Ep=u.cssPrefix,Dp=`.${Ep}-header, .${Ep}-back-header, .${Ep}-home-hero`;function Op(e,t){L(()=>{if(!t||!e)return;function n(e){return Number.parseFloat(e)||0}function r(e,t){return Math.min(t,Math.max(-t,e))}let i=null,a=t=>{let r=t.target;if(!(r instanceof Element)||!r.closest(Dp)||r.closest(`button, a, input, textarea, select, [role="tab"], [contenteditable]`))return;let a=e.getBoundingClientRect();i={id:t.pointerId,x:t.clientX,y:t.clientY,dx:n(e.style.getPropertyValue(`--${Ep}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${Ep}-modal-dy`)),maxX:(window.innerWidth+a.width)/2-56,maxY:(window.innerHeight+a.height)/2-56},e.dataset.dragging=`true`,t.preventDefault()},o=t=>{if(!i||t.pointerId!==i.id)return;let n=r(i.dx+t.clientX-i.x,i.maxX),a=r(i.dy+t.clientY-i.y,i.maxY);e.style.setProperty(`--${Ep}-modal-dx`,`${n}px`),e.style.setProperty(`--${Ep}-modal-dy`,`${a}px`)},s=t=>{i&&t.pointerId===i.id&&(i=null,delete e.dataset.dragging)};return e.addEventListener(`pointerdown`,a),window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s),()=>{e.removeEventListener(`pointerdown`,a),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)}},[e,t])}function kp({containerRef:e,onDrop:t,disabled:n=!1}){let[r,i]=I(!1);return L(()=>{if(n){i(!1);return}let r=e.current;if(!r)return;let a=0;function o(e){a+=1,e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),i(!0))}function s(){--a,!(a>0)&&(a=0,i(!1))}function c(e){e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()}function l(e){a=0,i(!1),e.dataTransfer&&(e.preventDefault(),t(e.dataTransfer.items))}return r.addEventListener(`dragenter`,o),r.addEventListener(`dragleave`,s),r.addEventListener(`dragover`,c),r.addEventListener(`drop`,l),()=>{r.removeEventListener(`dragenter`,o),r.removeEventListener(`dragleave`,s),r.removeEventListener(`dragover`,c),r.removeEventListener(`drop`,l)}},[e,n,t]),{visible:!n&&r}}const Ap=u.cssPrefix;function jp(e){let{options:t,onClose:n}=e,r=t.strings,i=R(null);L(()=>{let e=i.current;if(!e)return;let t=Xl(e);function r(e){e.key===`Escape`&&n?.()}return e.addEventListener(`keydown`,r),()=>{t(),e.removeEventListener(`keydown`,r)}},[n]);let a=e.composerApiRef,o=e.composerActive&&e.view===`chat`&&e.canSend&&!e.activeForm&&!e.sendPreparing&&e.options.features.fileUpload,{visible:s}=kp({containerRef:i,onDrop:B(e=>{o&&a.current?.attachFromDrop(e)},[a,o]),disabled:!o});return Op(i.current,t.mode===`modal`),/* @__PURE__ */ U(`div`,{ref:i,class:`${Ap}-panel`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":r.panelTitle,style:{position:`relative`},"data-testid":Z.panel,children:[/* @__PURE__ */ U(Mp,{...e,containerEl:i.current,dragOver:s}),/* @__PURE__ */ U(Rp,{poweredBy:e.options.poweredBy})]})}function Mp(e){let{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,composerKey:s,panelSize:c,view:l,canSend:u,isStreaming:d,isMemoryCompacting:f,canReleaseQueuedMessages:p,queueManualMessages:m,sendPreparing:h,controlMode:g,assignedOperatorInitials:_,operatorAvailable:v,operatorRequestEnabled:y,onRequestOperator:b,onCancelOperatorRequest:x,loadingMessages:S,onLoadPreviousMessages:C,messagesSig:w,agent:T,suggestions:E,initialWidgetSize:D,onClose:O,onBack:ee,onClear:k,onToggleHistory:te,onSelectHistoryConversation:ne,onNewConversation:A,onWidgetSizeChange:j,onSend:re,onStop:ie,onSuggestion:ae,activeForm:oe,formMarkers:se,onFormSubmit:ce,onFormSkip:le,onFormFill:M,tool:ue,onRetry:de,onMessageFeedback:fe,containerEl:pe,dragOver:me,composerApiRef:he}=e,N=t.strings,ge=vi(()=>w.value.some(e=>!e.ephemeral&&e.role!==`system`)).value,_e;return _e=oe?null:u?/* @__PURE__ */ U(Ze,{children:[g&&g!==`ai-agent`?/* @__PURE__ */ U(Fp,{controlMode:g,operatorInitials:_,operatorAvailable:v,onCancelOperatorRequest:x,strings:N}):null,f&&g===`ai-agent`?/* @__PURE__ */ U(`div`,{class:`${Ap}-loading ${Ap}-compaction-status`,role:`status`,"data-testid":Z.compactionStatus,children:[/* @__PURE__ */ U(`span`,{class:`${Ap}-loading-spinner`,"aria-hidden":`true`}),N.compactingContext]}):null,!d&&!f&&g===`ai-agent`&&/* @__PURE__ */ U(Tp,{suggestions:E,onPick:ae,disabled:h}),/* @__PURE__ */ U(nd,{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,isStreaming:d,pageToolRunning:e.pageToolRunning,isMemoryCompacting:f,canReleaseQueuedMessages:p,queueManualMessages:m,active:e.composerActive&&l===`chat`,isPreparing:h,operatorRequestEnabled:y,canRequestOperator:ge,controlMode:g,onRequestOperator:b,onSend:re,onStop:ie,apiRef:he},s)]}):/* @__PURE__ */ U(Pp,{label:N.conversationClosed,ctaLabel:N.startNewConversation,onNewConversation:k}),/* @__PURE__ */ U(Ze,{children:[l===`history`?/* @__PURE__ */ U(Np,{strings:N,onBack:te,onClose:O,showClose:Cc(t.mode,c,t.actions)}):/* @__PURE__ */ U(`header`,{class:`${Ap}-header`,part:`header`,"data-testid":Z.panelHeader,children:[ee?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ap}-icon-btn`,onClick:ee,"aria-label":N.moduleBack,title:N.moduleBack,children:/* @__PURE__ */ U(dl,{})}):null,T?/* @__PURE__ */ U(Cd,{agent:T,strings:N}):/* @__PURE__ */ U(`h1`,{children:N.panelTitle}),/* @__PURE__ */ U(vu,{panelProps:e,variant:`chat`})]}),l===`history`?/* @__PURE__ */ U(Md,{transport:n,strings:N,locale:t.locale,persistence:a,onSelect:ne,onNewConversation:A}):/* @__PURE__ */ U(Ze,{children:[/* @__PURE__ */ U(Pd,{visible:me,strings:N}),/* @__PURE__ */ U(yp,{messagesSig:w,strings:N,responseMode:t.responseMode,showReasoning:t.showReasoning,showToolCalls:t.showToolCalls,showSources:t.showSources,enableMessageFeedback:t.enableMessageFeedback,onFeedback:fe,loading:S,onLoadPreviousMessages:C,idle:!d&&!h&&u&&!oe,controlMode:g,tool:ue,onRetry:de,form:oe?{form:oe,onSubmit:ce,onSkip:le}:null,formMarkers:se,onFillForm:M}),_e,/* @__PURE__ */ U(Lp,{disclaimer:t.composerDisclaimer})]}),t.size.resize?.enabled?/* @__PURE__ */ U(Cp,{panelEl:pe,resize:t.size.resize,position:t.position,initialSize:D,onSizeChange:j,strings:N}):null]})}function Np({strings:e,onBack:t,onClose:n,showClose:r}){return/* @__PURE__ */ U(`header`,{class:`${Ap}-header`,part:`header`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ap}-icon-btn`,onClick:t,"aria-label":e.historyBack,title:e.historyBack,children:/* @__PURE__ */ U(dl,{})}),/* @__PURE__ */ U(`h1`,{children:e.historyTitle}),r?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ap}-icon-btn`,onClick:n,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ U(Hc,{})}):null]})}function Pp({label:e,ctaLabel:t,onNewConversation:n}){return/* @__PURE__ */ U(`div`,{class:`${Ap}-readonly-banner`,role:`note`,children:[/* @__PURE__ */ U(`span`,{class:`${Ap}-readonly-label`,children:e}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ap}-readonly-cta`,onClick:n,children:t})]})}function Fp({controlMode:e,operatorInitials:t,operatorAvailable:n,onCancelOperatorRequest:r,strings:i}){let a=Ip(e,t,n,i);return/* @__PURE__ */ U(`div`,{class:`${Ap}-operator-banner`,role:`status`,"data-mode":e,"data-testid":Z.operatorBanner,children:[/* @__PURE__ */ U(`span`,{class:`${Ap}-operator-pulse`,"aria-hidden":`true`}),/* @__PURE__ */ U(`span`,{class:`${Ap}-operator-label`,children:a}),e===`awaiting-operator`&&r?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ap}-cancel-operator-request`,"data-testid":Z.cancelOperatorRequest,onClick:r,children:i.cancelOperatorRequest}):null]})}function Ip(e,t,n,r){return e===`operator`?r.chattingWithOperator.replace(`{operator}`,t??``):n===!1?r.noOperatorAvailable:r.connectingOperator}function Lp({disclaimer:e}){return e?/* @__PURE__ */ U(`div`,{class:`${Ap}-composer-footer`,children:/* @__PURE__ */ U(`div`,{class:`${Ap}-disclaimer`,children:e})}):null}function Rp({poweredBy:e}){return e?/* @__PURE__ */ U(`div`,{class:`${Ap}-poweredby-bar`,children:/* @__PURE__ */ U(zp,{logoUrl:e.logoUrl,text:e.text,href:e.href})}):null}function zp({logoUrl:e,text:t,href:n}){let r=/* @__PURE__ */ U(Ze,{children:[e?/* @__PURE__ */ U(`img`,{class:`${Ap}-poweredby-logo`,src:e,alt:``,loading:`lazy`}):null,t?/* @__PURE__ */ U(`span`,{children:t}):null]});return n?/* @__PURE__ */ U(`a`,{class:`${Ap}-poweredby`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:r}):/* @__PURE__ */ U(`span`,{class:`${Ap}-poweredby`,children:r})}const Bp=u.cssPrefix;function Vp({panelProps:e,enabledModules:t,nav:n,bus:r,hasUnread:i,latestNews:a,onSelectConversation:o,onStartNewConversation:s,onSetPanelSize:c}){let l=e.options,u=l.strings,d=R(null),f=R(/* @__PURE__ */ new Set);L(()=>{let t=d.current;if(!t)return;let n=Xl(t);function r(t){t.key===`Escape`&&e.onClose?.()}return t.addEventListener(`keydown`,r),()=>{n(),t.removeEventListener(`keydown`,r)}},[e.onClose]);let p=vi(()=>n.sig.value).value,m=Pc(p),h=l.modules.byId[p.activeTab],g=e.composerActive&&h?.layout===`chat`&&m===void 0,_=e.composerApiRef,v=g&&e.view===`chat`&&e.canSend&&!e.activeForm&&!e.sendPreparing&&e.options.features.fileUpload,{visible:y}=kp({containerRef:d,onDrop:B(e=>{v&&_.current?.attachFromDrop(e)},[_,v]),disabled:!v});Op(d.current,l.mode===`modal`);let b=m?.kind===`iframe`||m?.kind===`content`,x=t.length>1&&(Fc(p)||!b),S=R(null);L(()=>{if(b&&S.current===null)S.current=e.panelSize,e.panelSize===`normal`&&c(`expanded`);else if(!b&&S.current!==null){let e=S.current;S.current=null,c(e)}},[b]);let C={push:e=>n.push(e),pop:()=>n.pop(),switchTab:e=>n.switchTab(e),switchToLayout:e=>{let r=t.find(t=>t.layout===e);r&&n.switchTab(r.id)},selectConversation:o,startNewConversation:s};function w(t){return{options:l,transport:e.transport,strings:u,config:t,nav:C,bus:r,panelProps:e,latestNews:a}}let T=/* @__PURE__ */ U(vu,{panelProps:e,variant:`plain`});h&&f.current.add(h.id);let E=t.filter(e=>f.current.has(e.id));function D(t){if(t.layout===`chat`)return/* @__PURE__ */ U(Mp,{...e,composerActive:g,containerEl:d.current,dragOver:y});let n=_d[t.layout].Root;return n?/* @__PURE__ */ U(n,{...w(t)}):null}function O(){return m?.kind===`iframe`?/* @__PURE__ */ U(xd,{url:m.url,title:m.title,strings:u,onBack:()=>n.pop(),actions:T}):m?.kind===`content`?/* @__PURE__ */ U(lu,{id:m.id,title:m.title,transport:e.transport,strings:u,bus:r,onBack:()=>n.pop(),actions:T}):null}return/* @__PURE__ */ U(`div`,{ref:d,class:`${Bp}-panel ${Bp}-messenger`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":u.panelTitle,style:{position:`relative`},"data-testid":Z.messengerHome,children:[/* @__PURE__ */ U(`div`,{class:`${Bp}-messenger-body`,children:[E.map(e=>/* @__PURE__ */ U(`div`,{class:`${Bp}-messenger-pane`,hidden:b||e.id!==h?.id,children:D(e)},e.id)),O()]}),x?/* @__PURE__ */ U(yd,{modules:t,activeTab:p.activeTab,strings:u,hasUnread:i,onSelect:e=>n.switchTab(e)}):null,/* @__PURE__ */ U(Rp,{poweredBy:l.poweredBy}),l.size.resize?.enabled&&(h?.layout!==`chat`||m)?/* @__PURE__ */ U(Cp,{panelEl:d.current,resize:l.size.resize,position:l.position,initialSize:e.initialWidgetSize,onSizeChange:e.onWidgetSizeChange,strings:u}):null]})}const Hp=u.cssPrefix;function Up({strings:e,onClose:t}){return/* @__PURE__ */ U(`div`,{class:`${Hp}-panel ${Hp}-modules-empty`,part:`panel`,role:`dialog`,"aria-label":e.panelTitle,"data-testid":Z.modulesEmpty,children:[t?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Hp}-icon-btn ${Hp}-modules-empty-close`,onClick:t,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ U(Hc,{})}):null,/* @__PURE__ */ U(`p`,{class:`${Hp}-modules-empty-text`,children:e.modulesEmpty})]})}function Wp(e){let t=u.cssPrefix,{site:n,blocks:r,strings:i,collapsed:a}=e,o=r?.navigation??[],s=r?.linkCards??[],c=a?i.expandSidebar:i.collapseSidebar;return/* @__PURE__ */ U(`aside`,{class:`${t}-sidebar`,"data-collapsed":a?`true`:`false`,"data-testid":Z.sidebar,children:[/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-header`,children:[/* @__PURE__ */ U(Gp,{site:n}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${t}-sidebar-toggle`,"aria-label":c,"aria-expanded":a?`false`:`true`,title:c,onClick:e.onToggleCollapsed,"data-testid":Z.sidebarToggle,children:/* @__PURE__ */ U(Kp,{collapsed:a})})]}),a?null:/* @__PURE__ */ U(Ze,{children:[o.length>0?/* @__PURE__ */ U(`nav`,{class:`${t}-sidebar-section`,"data-section":`navigation`,children:/* @__PURE__ */ U(qp,{items:o})}):null,s.length>0?/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-section`,"data-section":`link-cards`,children:/* @__PURE__ */ U(Jp,{items:s})}):null,e.showConversations?/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-conversations`,children:/* @__PURE__ */ U(Md,{transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,onSelect:e.onSelectConversation,onNewConversation:e.onNewConversation})}):null]})]})}function Gp({site:e}){let t=u.cssPrefix;if(e?.logo?.url){let n=e.logo.alt??e.title??`Logo`;return/* @__PURE__ */ U(`picture`,{children:[e.logoDark?.url?/* @__PURE__ */ U(`source`,{srcset:e.logoDark.url,media:`(prefers-color-scheme: dark)`}):null,/* @__PURE__ */ U(`img`,{class:`${t}-sidebar-logo`,src:e.logo.url,alt:n})]})}return/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-title`,children:e?.title??u.name})}function Kp({collapsed:e}){return/* @__PURE__ */ U(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"aria-hidden":`true`,children:e?/* @__PURE__ */ U(`polyline`,{points:`9 6 15 12 9 18`}):/* @__PURE__ */ U(`polyline`,{points:`15 6 9 12 15 18`})})}function qp({items:e}){let t=u.cssPrefix;return/* @__PURE__ */ U(`ul`,{class:`${t}-sidebar-nav`,children:e.map(e=>/* @__PURE__ */ U(`li`,{children:/* @__PURE__ */ U(`a`,{class:`${t}-sidebar-nav-item`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[e.icon?/* @__PURE__ */ U(`span`,{class:`${t}-sidebar-nav-icon`,"data-icon":e.icon}):null,/* @__PURE__ */ U(`span`,{class:`${t}-sidebar-nav-label`,children:e.label})]})},e.id??e.label))})}function Jp({items:e}){let t=u.cssPrefix;return/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-cards`,children:e.map(e=>/* @__PURE__ */ U(`a`,{class:`${t}-sidebar-card`,href:e.href,target:e.href?`_blank`:void 0,rel:e.href?`noreferrer`:void 0,children:[/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-card-label`,children:e.label}),e.description?/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-card-desc`,children:e.description}):null]},e.id??e.label))})}const Yp=u.cssPrefix;function Xp(e){return/* @__PURE__ */ U(`main`,{class:`${Yp}-page-shell`,"data-sidebar-collapsed":e.sidebarCollapsed?`true`:`false`,children:[/* @__PURE__ */ U(Wp,{site:e.site,blocks:e.blocks,transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,showConversations:e.showConversations,onSelectConversation:e.onSelectConversation,onNewConversation:e.onNewConversation,collapsed:e.sidebarCollapsed,onToggleCollapsed:e.onToggleSidebarCollapsed}),/* @__PURE__ */ U(`section`,{class:`${Yp}-page-chat`,"aria-label":e.strings.panelTitle,children:e.children})]})}const Zp=C.scope(`hitl`);function Qp(e){return e.kind===`tool`&&Te(e.toolMetadata)&&(e.stateSig.value===`input-available`||e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved===!0)}function $p(e,t){t.errorSig.value=je(t.toolCallId),t.stateSig.value=`output-error`,e.partsSig.value=[...e.partsSig.value]}function em(e,t){let n=e.slice(0,e.indexOf(t)).findLast(e=>e.role===`user`);return n!==void 0&&M.sentHere(n.id)}function tm(e){let{streaming:t,controlModeSig:n,messagesSig:r,sendAiTurn:i,bus:a,humanInLoop:o,tools:s}=e,c=R(t);c.current=t;let l=R(s);l.current=s;let u=R(/* @__PURE__ */ new Map),[d,f]=I(!1),p=B((e,t,a)=>{if(c.current||n.value!==`ai-agent`)return!1;let o=r.value.at(-1),s=o?.partsSig.value.findIndex(t=>t.kind===`tool`&&t.toolCallId===e)??-1,l=o?.partsSig.value[s];if(!o||l?.kind!==`tool`)return Zp.warn(`decideTool: tool part not found`,{toolCallId:e}),!1;if(o.status!==`complete`||!Ns(o,s)||!t(l))return!1;if(a(l),o.partsSig.value=[...o.partsSig.value],!js(o)||o.partsSig.value.some(Qp))return!0;o.status=`streaming`,o.retryAction={kind:`continue-assistant`,messageId:o.serverMessageId??o.id},o.awaitingContinuation=!0,r.value=[...r.value];let u=o.partsSig.value.flatMap(e=>e.kind===`tool`?[e.toolCallId]:[]);return i({continueExisting:!0}).then(e=>e&&M.clear(u)),!0},[n,r,i]),m=B((e,t)=>{let{toolCallId:n,toolName:r}=t;u.current.has(n)||(u.current.set(n,e),f(!0),ke({toolCallId:n,toolName:r,input:t.inputSig.value,optionTools:l.current??[],onSettled:(e,t)=>{Zp.info(`toolResult`,{toolCallId:n,status:e}),a.emit(`toolResult`,{toolCallId:n,name:Ee(r),status:e,durationMs:t})}}).then(e=>{u.current.delete(n)&&(f(u.current.size>0),p(n,Qp,t=>{e.state===`output-available`?t.outputSig.value=e.output:t.errorSig.value=e.errorText,t.stateSig.value=e.state}))}))},[a,p]),h=B(()=>{let e=r.value;for(let[t,n]of u.current){let r=e.findIndex(e=>e.id===n);r<0||r===e.length-1||(u.current.delete(t),Me(t),f(u.current.size>0))}let t=e.at(-1);if(c.current||t?.role!==`assistant`||t.status!==`complete`)return;let n=t.partsSig.value.filter(e=>Qp(e)&&e.stateSig.value===`input-available`);if(n.length!==0&&em(e,t))for(let e of n)M.get(e.toolCallId)?.state===`stopped`?$p(t,e):m(t.id,e)},[r,m]);L(()=>h(),[t,h]),L(()=>r.subscribe(()=>h()),[r,h]);let g=B((e,t,n)=>{let i=!1,o;if(!p(e,e=>e.stateSig.value===`approval-requested`,r=>{Te(r.toolMetadata)&&(o=r),i=pf(r.toolName);let a=r.approvalSig.value?.id??e;r.approvalSig.value={id:a,approved:t,reason:n},r.stateSig.value=`approval-responded`}))return;let s=r.value.at(-1);o&&t&&s&&m(s.id,o),o&&!t&&a.emit(`toolResult`,{toolCallId:e,name:Ee(o.toolName),status:`declined`,durationMs:0}),i?(Zp.info(`toolResult`,{toolCallId:e}),a.emit(`toolResult`,{toolCallId:e})):(Zp.info(`toolDecision`,{toolCallId:e,approved:t}),a.emit(`toolDecision`,{toolCallId:e,approved:t}))},[a,p,r,m]),_=B(e=>{p(e,e=>e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved!==void 0&&!Qp(e),t=>{let n=t.approvalSig.value?.id??e;t.approvalSig.value={id:n},t.stateSig.value=`approval-requested`})},[p]);return{toolInteraction:z(()=>({humanInLoop:o,onDecision:g,onEdit:_}),[o,g,_]),pageToolsRunning:d,stopPageTools:B(()=>{let e=r.value.at(-1);for(let t of u.current.keys()){let n=e?.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);e&&n?$p(e,n):je(t),Zp.info(`toolResult`,{toolCallId:t,status:`stopped`}),a.emit(`toolResult`,{toolCallId:t,name:n?Ee(n.toolName):void 0,status:`stopped`,durationMs:0})}u.current.clear(),f(!1)},[a,r])}}const nm=C.scope(`latest-news`);function rm({transport:e,options:t,persistence:n,enabled:r}){let i=t.modules.list.find(e=>e.layout===`news`)?.contentCollectionIds,a=i?.join(`,`),[o,s]=I(),[c,l]=I(()=>n.loadSeenNewsId());L(()=>{if(!r||!i?.length)return;let t=!1;return e.listContent({contentCollectionIds:i,sortBy:`publishedAt`,sortOrder:`desc`,limit:1}).then(e=>{t||s(e.items[0])}).catch(e=>nm.debug(`listContent (latest news) failed (non-fatal)`,{err:e})),()=>{t=!0}},[e,r,a]);let u=B(e=>{n.saveSeenNewsId(e),l(e)},[n]);return{item:o,unseen:o!==void 0&&o.id!==c,markSeen:u}}function im({callout:e,persistence:t}){let n=e?.text??``,r=e?.persistent??!0,[i,a]=I(()=>!r&&t.loadCalloutDismissed(n));return L(()=>{a(!r&&t.loadCalloutDismissed(n))},[n,r,t]),{dismissed:i,dismissCallout:B(()=>{a(!0),r||t.saveCalloutDismissed(n)},[t,n,r])}}function am(e){let{transport:t,conversationIdSig:n}=e,r=_i(`ai-agent`),i=_i(void 0),a=_i(void 0),o=R(void 0),s=B(e=>{let t=e.controlRevision,s=o.current;s&&s.conversationId===n.value&&t<s.revision||(o.current={conversationId:n.value,revision:t},r.value=e.controlMode,i.value=e.assignedOperatorInitials,e.controlMode===`awaiting-operator`?e.operatorAvailable!==void 0&&(a.value=e.operatorAvailable):a.value=void 0)},[n,r,i,a]);return{controlModeSig:r,assignedOperatorInitialsSig:i,operatorAvailableSig:a,applyControlState:s,adoptControlStateChunk:B(e=>{if(e.type!==`data-control-state`)return;let t=os(e.data);t&&s(t)},[s]),requestOperator:B(async()=>{let e=n.value,r=await t.requestOperator();r&&n.value===e&&s(r)},[t,n,s]),cancelOperatorRequest:B(async()=>{let e=n.value,r=await t.cancelOperatorRequest();r&&n.value===e&&s(r)},[t,n,s])}}const om=u.cssPrefix,sm=`--${om}-visual-viewport-height`,cm=`--${om}-visual-viewport-top`;function lm(e){let{hostElement:t,mode:n,panelSize:r,isOpen:i,surfaceReady:a,setIsOpen:o}=e;kr(()=>{ur(t,Ic(n,r,i))},[t,i,r,n]),kr(()=>{if(!i||!a)return;let e=t.ownerDocument.defaultView,n=e?.visualViewport,r=t.shadowRoot?.querySelector(`.${om}-anchor`);if(!e||!n||!r)return;let o=()=>{r.style.setProperty(sm,`${n.height}px`),r.style.setProperty(cm,`${n.offsetTop}px`)},s=0,c=()=>{e.cancelAnimationFrame(s),s=e.requestAnimationFrame(()=>{s=e.requestAnimationFrame(o)})};return o(),n.addEventListener(`resize`,c),n.addEventListener(`scroll`,c),()=>{e.cancelAnimationFrame(s),n.removeEventListener(`resize`,c),n.removeEventListener(`scroll`,c),r.style.removeProperty(sm),r.style.removeProperty(cm)}},[t,i,a]),L(()=>{if(n!==`modal`||!i)return;function e(e){e.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains(`${om}-panel`))||o(!1)}return t.addEventListener(`click`,e),()=>t.removeEventListener(`click`,e)},[t,i,n,o]),L(()=>{if(n!==`drawer`||!i)return;function e(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,n,o])}const um=C.scope(`reducer`);var dm=class{constructor(e,t){this.messagesSig=e,this.onReconcileNeeded=t,s(this,`active`,null),s(this,`openTextParts`,/* @__PURE__ */ new Map),s(this,`partSeq`,0),s(this,`replay`,null)}attach(e){this.active=e,this.openTextParts.clear()}detach(){this.active=null,this.replay=null,this.openTextParts.clear()}beginReplay(e,t){let n=ps();n.id=e.id;let r=pm(e)||Ms(e)&&(e.status!==`streaming`||js(e)),i=e.status===`streaming`&&js(e)&&As(e);this.replay={baseline:e,shadow:n,chunks:[t],probeContinuation:r,continuationTailReplay:i,liveCatchUp:e.status===`streaming`&&!r},this.attach(n),this.apply(t)}refreshReplayBaseline(){let e=this.replay;if(!e)return null;let t=e.shadow.serverMessageId??e.baseline.serverMessageId,n=this.messagesSig.value,r=n.at(-1),i=r===e.baseline||r?.id===e.baseline.id||t!==void 0&&r?.serverMessageId===t?r:n.find(t=>t===e.baseline)??n.find(n=>n.id===e.baseline.id||t!==void 0&&n.serverMessageId===t);if(!i)return this.detach(),null;if(i===e.baseline)return e;let a=e.baseline;return e.baseline=i,mm(a,i),e.liveCatchUp&&pm(e.shadow)&&(i.status===`streaming`||Ms(i))?(e.probeContinuation=!1,e.continuationTailReplay=!1,e):(e.probeContinuation=pm(i)||Ms(i)&&(i.status!==`streaming`||js(i)),e.continuationTailReplay=i.status===`streaming`&&js(i)&&As(i),e.liveCatchUp=i.status===`streaming`&&!e.probeContinuation,e)}refreshActive(){let e=this.active;if(!e)return null;let t=e.serverMessageId,n=this.messagesSig.value,r=n.at(-1),i=r===e||r?.id===e.id||t!==void 0&&r?.serverMessageId===t?r:n.find(t=>t===e)??n.find(n=>n.id===e.id||t!==void 0&&n.serverMessageId===t);if(!i)return this.detach(),null;if(i===e)return e;mm(e,i);let a=pm(e)&&Ms(i);return i.status!==`streaming`&&!a?(this.detach(),null):(this.replay={baseline:i,shadow:e,chunks:[],probeContinuation:!1,continuationTailReplay:!1,liveCatchUp:!0},e)}promoteReplay(){let{baseline:e,shadow:t}=this.replay;return Br(()=>{e.role=t.role,e.serverMessageId=t.serverMessageId,e.operatorInitials=t.operatorInitials,e.status=t.status,t.canceled&&(e.canceled=!0),e.finishReason=t.finishReason,e.errorText=t.errorText,e.suggestions=t.suggestions??e.suggestions,e.partsSig.value=t.partsSig.value,this.messagesSig.value=[...this.messagesSig.value]}),this.replay=null,this.active=e,e}promoteContinuation(e=!1){let{baseline:t,chunks:n}=this.replay,r=Ps(t);return this.replay=null,Br(()=>{if(e){let e=t.partsSig.value.findLastIndex(e=>e.kind===`tool`);t.partsSig.value=t.partsSig.value.slice(0,e+1)}t.awaitingContinuation=!1,t.status=`streaming`,t.finishReason=void 0,t.errorText=void 0,t.suggestions=void 0,this.attach(t);for(let e of n)this.apply(e);t.continuationStreaming=r||void 0,this.messagesSig.value=[...this.messagesSig.value]}),t}settleOwnedContinuation(e){let{baseline:t}=this.replay,n=Ps(t);return this.replay=null,Br(()=>{t.awaitingContinuation=!1,t.status=`streaming`,t.finishReason=void 0,t.errorText=void 0,t.suggestions=void 0,this.attach(t),this.apply(e),t.continuationStreaming=n||void 0,this.messagesSig.value=[...this.messagesSig.value]}),t}applyResume(e){if(e.type===`start`){let t=(this.replay?.baseline??this.active)?.serverMessageId;t!==void 0&&e.messageId!==void 0&&t!==e.messageId&&this.onReconcileNeeded?.({messageId:t}),this.detach();let n=e.messageId,r=n===void 0?void 0:this.messagesSig.value.find(e=>e.serverMessageId===n||e.id===n);if(r!==void 0)return e.messageMetadata?.senderRole===`visitor`&&r.role===`user`&&(r.status===`pending`||r.status===`error`)&&(r.serverMessageId=n,r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,this.messagesSig.value=[...this.messagesSig.value]),this.beginReplay(r,e),null;let i=e.messageMetadata?.senderRole,a=this.messagesSig.value.at(-1);if(i===void 0&&a?.role===`assistant`&&a.status===`streaming`&&a.serverMessageId===void 0&&!Ts(a))return this.attach(a),this.apply(e),null;let o=ps();return this.attach(o),this.messagesSig.value=[...this.messagesSig.value,o],this.apply(e),null}if(this.replay){let t=this.refreshReplayBaseline();if(!t)return null;t.chunks.push(e),e.type===`data-control-state`&&(t.baseline.operatorRoutedTurn=e.data.controlMode!==`ai-agent`),this.apply(e);let{baseline:n,shadow:r,probeContinuation:i,continuationTailReplay:a,liveCatchUp:o}=t,s=e.type===`finish`||e.type===`error`||e.type===`abort`;if(i){if(!vm(n,r,e))return s&&(Sm(n,r)&&(n.continuationStreaming=!0,this.messagesSig.value=[...this.messagesSig.value],this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id})),this.detach()),null;let t=pm(n)&&s?this.settleOwnedContinuation(e):this.promoteContinuation();return s?(t.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:t.serverMessageId??t.id}):t.continuationStreaming=!1),this.detach(),t):null}if(a&&gm(n,r)){let e=this.promoteContinuation(!0);return s?(this.detach(),e):null}if(!o)return s&&this.detach(),null;if(s&&!Ts(n)&&Ts(r)){let e=this.promoteReplay();return this.detach(),e}if(!hm(n,r))return s&&(this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}),this.detach()),null;let c=this.promoteReplay();return s?(this.detach(),c):null}let t=this.refreshActive();if(!t)return null;if(this.replay)return this.applyResume(e);if(this.apply(e),e.type===`finish`||e.type===`error`||e.type===`abort`){let n=t;return n.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}):n.continuationStreaming=!1),this.detach(),n}return null}ensureTextPart(e,t,n){let r=`${t}:${n}`,i=this.openTextParts.get(r);if(i)return i;let a={kind:t,id:`${n}#${this.partSeq++}`,textSig:V(``),doneSig:V(!1)};return this.openTextParts.set(r,a),wm(e,a),a}apply(e){let t=this.active;if(t)switch(e.type){case`start`:{e.messageId&&(t.serverMessageId=e.messageId);let n=e.messageMetadata;n?.senderRole===`operator`?(t.role=`operator`,n.operatorInitials&&(t.operatorInitials=n.operatorInitials)):n?.senderRole===`visitor`&&(t.role=`user`);return}case`finish-step`:this.openTextParts.clear();return;case`start-step`:wm(t,{kind:`step-start`,id:`ss-${this.partSeq++}`});return;case`finish`:um.debug(`finish`,{reason:e.finishReason,canContinue:e.canContinue}),t.status=`complete`,t.retryAction=void 0,e.finishReason&&(t.finishReason=e.finishReason),this.bumpDone(t);return;case`error`:um.warn(`stream error chunk`,{errorText:e.errorText}),t.status=`error`,t.errorText=e.errorText,this.bumpDone(t);return;case`abort`:um.debug(`stream abort chunk (canceled)`),t.status=`complete`,t.canceled=!0,t.retryAction=void 0,this.bumpDone(t);return;case`text-start`:this.ensureTextPart(t,`text`,e.id);return;case`text-delta`:{let n=this.ensureTextPart(t,`text`,e.id);n.textSig.value+=e.delta;return}case`text-end`:this.ensureTextPart(t,`text`,e.id).doneSig.value=!0;return;case`reasoning-start`:this.ensureTextPart(t,`reasoning`,e.id).doneSig.value=!1;return;case`reasoning-delta`:{let n=this.ensureTextPart(t,`reasoning`,e.id);n.textSig.value+=e.delta;return}case`reasoning-end`:this.ensureTextPart(t,`reasoning`,e.id).doneSig.value=!0;return;case`tool-input-start`:case`tool-input-delta`:case`tool-input-available`:case`tool-input-error`:case`tool-output-available`:case`tool-output-error`:case`tool-output-denied`:case`tool-approval-request`:Em(t,e);return;case`file`:wm(t,{kind:`file`,url:e.url,mediaType:e.mediaType});return;case`source-url`:Tm(t,{kind:`source`,sourceId:e.sourceId,url:e.url,title:e.title});return;case`source-document`:Tm(t,{kind:`source`,sourceId:e.sourceId,title:e.title,filename:e.filename,mediaType:e.mediaType});return;case`data-suggestions`:t.suggestions=cs(e.data);return;case`data-control-state`:t.operatorRoutedTurn=e.data.controlMode!==`ai-agent`;return;case`data-memory-compaction-state`:return}}bumpDone(e){Br(()=>{e.partsSig.value=[...e.partsSig.value],this.messagesSig.value.includes(e)&&(this.messagesSig.value=[...this.messagesSig.value])})}};const fm={"input-streaming":0,"input-available":1,"approval-requested":2,"approval-responded":3,"output-available":4,"output-denied":4,"output-error":4};function pm(e){return e.awaitingContinuation===!0||e.continuationStreaming===!0||e.retryAction?.kind===`continue-assistant`}function mm(e,t){e.canceled&&(t.canceled=!0),pm(e)&&(t.status===`streaming`||Ms(t))&&(t.awaitingContinuation??(t.awaitingContinuation=e.awaitingContinuation),t.continuationStreaming??(t.continuationStreaming=e.continuationStreaming),t.retryAction===void 0&&(t.retryAction=e.retryAction))}function hm(e,t){let n=e.partsSig.value,r=t.partsSig.value;return e.role!==t.role||r.length<n.length?!1:n.every((e,t)=>_m(e,r[t]))}function gm(e,t){let n=e.partsSig.value,r=n.findLastIndex(e=>e.kind===`tool`),i=new Set(n.slice(0,r+1).flatMap(e=>e.kind===`tool`?[e.toolCallId]:[])),a=t.partsSig.value.filter(e=>e.kind!==`tool`||!i.has(e.toolCallId)),o=n.slice(r+1);return a.length<o.length?!1:o.every((e,t)=>_m(e,a[t]))}function _m(e,t){switch(e.kind){case`text`:case`reasoning`:return t?.kind===e.kind&&t.textSig.value.startsWith(e.textSig.value);case`step-start`:return t?.kind===`step-start`;case`tool`:{if(t?.kind!==`tool`||t.toolCallId!==e.toolCallId||!Ws(t.toolName,e.toolName)||fm[t.stateSig.value]<fm[e.stateSig.value])return!1;let n=e.approvalSig.value?.approved;return n===void 0||t.approvalSig.value?.approved===n}case`file`:return t?.kind===`file`&&t.url===e.url&&t.mediaType===e.mediaType;case`source`:return t?.kind===`source`&&t.sourceId===e.sourceId&&t.url===e.url&&t.title===e.title&&t.filename===e.filename&&t.mediaType===e.mediaType;default:return e}}function vm(e,t,n){return ym(e,n)||!bm(e,t)?!0:n.type!==`finish`&&n.type!==`error`&&n.type!==`abort`?!1:As(t)||e.awaitingContinuation===!0&&n.type!==`finish`?!0:e.awaitingContinuation===!0&&t.partsSig.value.every(e=>e.kind===`step-start`)}function ym(e,t){if(t.type!==`tool-output-available`&&t.type!==`tool-output-error`&&t.type!==`tool-output-denied`)return!1;let n=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t.toolCallId);return n!==void 0&&fm[n.stateSig.value]<4}function bm(e,t){let n=t.partsSig.value;if(n.length===0)return!0;let r=e.partsSig.value;return r.some((e,t)=>n.every((e,n)=>xm(r[t+n],e)))}function xm(e,t){switch(t.kind){case`text`:case`reasoning`:return e?.kind===t.kind&&e.textSig.value.startsWith(t.textSig.value);case`step-start`:return e?.kind===`step-start`;case`tool`:return e?.kind===`tool`&&e.toolCallId===t.toolCallId&&(t.toolName===`tool`||Ws(e.toolName,t.toolName));case`file`:return e?.kind===`file`&&e.url===t.url&&e.mediaType===t.mediaType;case`source`:return e?.kind===`source`&&e.sourceId===t.sourceId&&e.url===t.url&&e.title===t.title&&e.filename===t.filename&&e.mediaType===t.mediaType;default:return t}}function Sm(e,t){if(pm(e)||!Ms(e))return!1;let n=new Set(e.partsSig.value.filter(e=>e.kind===`tool`).map(e=>e.toolCallId));return!t.partsSig.value.some(e=>e.kind===`tool`&&n.has(e.toolCallId))}function Cm(e,t,n,r,i){let a=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);if(a)return r&&(a.dynamic=!0),a.toolMetadata??(a.toolMetadata=i),a;let o={kind:`tool`,toolCallId:t,toolName:n??`tool`,dynamic:r?!0:void 0,toolMetadata:i,inputPartialSig:V(``),inputSig:V(void 0),outputSig:V(void 0),errorSig:V(void 0),stateSig:V(`input-streaming`),approvalSig:V(void 0)};return wm(e,o),o}function wm(e,t){e.partsSig.value=[...e.partsSig.value,t]}function Tm(e,t){e.partsSig.value.some(e=>e.kind===`source`&&e.sourceId===t.sourceId)||wm(e,t)}function Em(e,t){switch(t.type){case`tool-input-start`:Cm(e,t.toolCallId,t.toolName,t.dynamic,t.toolMetadata);return;case`tool-input-delta`:{let n=Cm(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case`tool-input-available`:{let n=Cm(e,t.toolCallId,t.toolName,t.dynamic,t.toolMetadata);n.inputSig.value=t.input,n.stateSig.value=`input-available`;return}case`tool-input-error`:{let n=Cm(e,t.toolCallId,t.toolName,t.dynamic);n.inputSig.value=t.input,n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-approval-request`:{let n=Cm(e,t.toolCallId,t.toolName);n.approvalSig.value={id:t.approvalId},n.stateSig.value=`approval-requested`;return}case`tool-output-available`:{let n=Cm(e,t.toolCallId,void 0,t.dynamic);n.outputSig.value=t.output,n.stateSig.value=`output-available`;return}case`tool-output-error`:{let n=Cm(e,t.toolCallId,void 0,t.dynamic);n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-output-denied`:{let n=Cm(e,t.toolCallId);n.stateSig.value=`output-denied`;return}default:return}}const Dm=1e3;async function Om(e){let t=Dm,n=!1,r=!1,i=!1;function a(){i||e.signal.aborted||(i=!0,e.onInitialBoundaryReady())}for(;!e.signal.aborted;){let o,s=`held`;try{s=await e.connect(()=>{if(e.signal.aborted)return;o=e.now();let t=n||r;n=!0,r=!1,i?t&&e.backfill():a()})}catch{}if(e.signal.aborted||(!n&&o===void 0&&(r=!0,a()),s===`unavailable`))return;o!==void 0&&e.now()-o>=1e3&&(t=Dm),await e.sleep(t),t=Math.min(t*2,15e3)}}function km(e){let{activated:t,conversationReady:n,conversationIdSig:r,messagesSig:i,optionsRef:a,transport:o,visitorId:s,adoptControlStateChunk:c,adoptMemoryCompactionStateChunk:l,settleSuggestions:u,recordConversationReply:d,transcriptRecoverySig:f,beginConversationTranscript:p,commitConversationTranscript:m,onReplyLanded:h,runCancellation:g,canContinueRef:_,setCanSend:v,feedback:y,bus:b,loadInitialThread:x,shouldReconcileOnConnect:S}=e,C=R(0);L(()=>{if(!t||!n||!r.value)return;let e=r.value,w=new AbortController,T=e=>{},E=new dm(i,e=>T(e));o.primeIdentity(s,e);let D=!1,O=!1,ee,k=!1,te,ne=0,A=_.current,j,re,ie=Date.now(),ae,oe=!1,se=!1;function ce(t,n,r){if(!Ts(t))return;let o=i.value.findLast(e=>!e.ephemeral),s=t.serverMessageId??t.id;if(!(o&&(o.serverMessageId??o.id)!==s))return ws(i.value,t,e,a.current.strings.newConversation,n,r)}function le(e,t,n,r){let i=ce(e,t,r);if(!i)return;let a=`${e.serverMessageId??e.id}:${n}:${i.preview??``}`;a!==re&&(re=a,o.publishConversation({...i,hasUnread:!0},!0))}let M;function de(){M&&(clearTimeout(M.timer),M=void 0)}function fe(){let e=M;if(!e)return;clearTimeout(e.timer),M=void 0;let t=i.value.find(t=>(t.serverMessageId??t.id)===e.replyId);(t?.role===`assistant`||t?.role===`operator`)&&le(t,e.canContinue,e.generation,e.activityAt)}function pe(e,t,n,r){de(),M={replyId:e.serverMessageId??e.id,canContinue:t,generation:n,activityAt:r,timer:setTimeout(fe,120)}}function me(e,t,n,r=Date.now(),i=!0){de();let a=ce(e,t,r);if(!a)return;let o=`${e.serverMessageId??e.id}:${n}`;o!==j&&(j=o,d(a),i&&ae&&(oe=!0))}function he(e,t){(e||!g.localSendRef.current)&&g.settle(t),e&&h()}function N(e,t=[],n=!1,r,o=A,s=ne,c=Date.now(),l=!0){let d=a.current;if(e.canceled){me(e,o,s,c,l),he(n,r);return}let f=!0,p=e.status===`error`;switch(Xs(e,p)){case`drop`:i.value=i.value.filter(t=>t!==e),f=!1;break;case`complete-operator-routed`:e.status=`complete`,n&&(y.play(`messageReceived`),Tc(b,d,`assistant`,Cs(e)));break;case`error`:if(e.status=`error`,e.errorText=d.strings.errorGeneric,n){y.play(`error`);let e=/* @__PURE__ */ Error(p?`stream error chunk`:`empty reply`);b.emit(`error`,e),d.onError?.(e)}break;case`complete`:e.status=`complete`,n&&(y.play(`messageReceived`),Tc(b,d,`assistant`,Cs(e))),u(e,t)}f&&me(e,o,s,c,l),he(n,r)}function ge(t){if(w.signal.aborted||r.value!==e)return;if(c(t),l?.(t),t.type===`start`){fe();let n=t.messageId===void 0?void 0:i.value.find(e=>e.serverMessageId===t.messageId||e.id===t.messageId);k=n!==void 0&&n.status!==`streaming`;let r=te?.senderRole===`visitor`?te.messageId:void 0;if(te={messageId:t.messageId,senderRole:t.messageMetadata?.senderRole},ne+=1,ie=Date.now(),re=void 0,D=t.messageMetadata?.senderRole===void 0,O=!1,ee=D?t.messageMetadata?.runId:void 0,D){let n=t.messageId!==void 0&&i.value.some(e=>e.serverMessageId===t.messageId||e.id===t.messageId),a=i.value.at(-1),o=t.messageId!==void 0&&(a?.serverMessageId===t.messageId||a?.id===t.messageId),s=g.localSendRef.current&&(!n||o)&&a?.role===`assistant`&&a.status===`streaming`&&(o||a.serverMessageId===void 0&&a.partsSig.value.length===0);O=g.captureStart(e,t,s,r)}}let n=D&&(t.type===`finish`||t.type===`error`||t.type===`abort`),o=n?ee:void 0,s=n&&(O||g.ownsLocalRun(o)),u=ne,d=k;t.type===`finish`&&t.canContinue!==void 0&&(A=t.canContinue);let f=A;n&&(D=!1,O=!1,ee=void 0);let p=E.applyResume(t),m=te?.messageId,h=m===void 0?void 0:i.value.find(e=>e.serverMessageId===m||e.id===m);k&&te?.senderRole!==`visitor`&&(p!==null||h?.status===`streaming`)&&(k=!1,d=!1);let _=!k&&(h?.role===`assistant`||h?.role===`operator`);t.type===`text-delta`&&_&&pe(h,A,ne,ie),t.type===`text-end`&&(de(),_&&le(h,A,ne,ie)),t.type===`finish`&&t.canContinue===!1&&v(!1),p?p.role===`operator`?(d||(y.play(`messageReceived`),Tc(b,a.current,`operator`,Cs(p))),me(p,f,u,ie),k=!1,n&&(s||!g.localSendRef.current)&&g.settle(o)):p.role===`assistant`&&(N(p,[],s,o,f,u,ie),k=!1):n&&(s||!g.localSendRef.current)&&g.settle(o)}async function _e(t){let n=ne,a=await o.loadConversation(e,t?{ids:[t]}:void 0).catch(()=>null);if(w.signal.aborted||r.value!==e||!a)return!1;a.controlState&&c({type:`data-control-state`,data:a.controlState});let s=i.value.at(-1),l=n===ne&&(t===void 0||s!==void 0&&(s.serverMessageId===t||s.id===t));if(a.messages.length===0)return!0;l&&(A=a.canContinue,v(A));let d=i.value,f=t===void 0?d.at(-1):d.find(e=>e.serverMessageId===t||e.id===t),{messages:p,changed:m}=Vs(d,bs(a.messages));if(!m)return!0;i.value=p;let h=t===void 0?p.at(-1):p.find(e=>e.serverMessageId===t||e.id===t),_=f!==void 0&&h!==void 0&&(f.id===h.id||f.serverMessageId!==void 0&&f.serverMessageId===h.serverMessageId),y=h!==void 0&&h.status!==`streaming`&&(!_||f?.status===`streaming`),b=_&&f?.status===`streaming`?Date.now():h?.createdAt;return l&&y&&h.role===`assistant`?N(h,h.suggestions??[],g.localSendRef.current,void 0,a.canContinue,n,b,!1):l&&y&&h.role===`operator`?me(h,a.canContinue,n,b,!1):l&&h?.role===`assistant`&&h.status!==`streaming`&&u(h,h.suggestions??[]),!0}let ve=/* @__PURE__ */ new Set;T=({messageId:e})=>{if(ve.has(e)||!i.value.some(t=>t.serverMessageId===e||t.id===e))return;ve.add(e);function t(){return ve.delete(e)}_e(e).then(t,t)};function ye(t=!1){if(w.signal.aborted||r.value!==e){oe=!1;return}if(ae){oe=!0;return}let n=t?x(e)??(S()?_e():void 0):_e();if(!n)return;p(e),ae=n;function i(t=!1){ae===n&&(ae=void 0,oe?(oe=!1,ye()):t&&m(e))}n.then(i,()=>i(!1))}let be=f.subscribe(e=>{e<=C.current||(C.current=e,se&&ye())});return Om({signal:w.signal,now:()=>performance.now(),sleep:e=>ue(e,w.signal),connect:e=>o.connectResumeStream({signal:w.signal,onChunk:ge,onConnected:e}),onInitialBoundaryReady:()=>{se=!0,ye(!0)},backfill:()=>ye()}),()=>{w.abort(),de(),be(),E.detach()}},[t,n,r,r.value,s,o,c,l,u,d,f,p,m,h,g,_,v,i,b,y,x,S])}function Am(e){let{transport:t,setStreaming:n}=e,r=R(void 0),i=R(void 0),a=R(!1),o=R(void 0),s=R(!1),c=R(/* @__PURE__ */ new Map),l=R(/* @__PURE__ */ new Set),u=B((e,n)=>{let r=`${e}:${n}`;o.current!==r&&(o.current=r,t.cancelTurn(e,n))},[t]),d=B(e=>{r.current=void 0,i.current=e,a.current=!1,o.current=void 0,s.current=!0,n(!0)},[n]),f=B((e,t)=>{c.current.set(e,{messageId:t})},[]),p=B(e=>{e!==void 0&&(l.current.add(e),l.current.size>32&&l.current.delete(l.current.values().next().value)),(e===void 0||r.current?.runId===e)&&(r.current=void 0,i.current=void 0,a.current=!1,s.current=!1,n(!1))},[n]),m=B((e,t)=>i.current===e?(i.current=void 0,t.runId?(r.current={conversationId:t.conversationId,runId:t.runId},n(!0),a.current&&u(t.conversationId,t.runId),!0):(p(),!0)):t.runId&&r.current?.runId===t.runId?(r.current={conversationId:t.conversationId,runId:t.runId},a.current&&u(t.conversationId,t.runId),!0):!1,[u,n,p]),h=B((e,t)=>{let d=c.current.get(e);return d?(c.current.delete(e),!t.runId||l.current.has(t.runId)?!0:d.runId===void 0?(s.current||i.current||(r.current={conversationId:t.conversationId,runId:t.runId},i.current=void 0,a.current=!1,o.current=void 0,s.current=!0,n(!0)),!0):(d.runId===t.runId&&r.current?.runId===t.runId&&(r.current={conversationId:t.conversationId,runId:t.runId},a.current&&u(t.conversationId,t.runId)),!0)):!1},[u,n]),g=B(e=>i.current===e&&(p(),!0),[p]),_=B(e=>{let t=c.current.get(e);return t?(c.current.delete(e),t.runId===void 0):!1},[]),v=B((e,t,d,f)=>{let p=t.messageMetadata?.runId;if(t.messageMetadata?.senderRole!==void 0||typeof p!=`string`||!p||l.current.has(p))return!1;if(r.current?.runId===p)return s.current;if(s.current)return r.current||!d?!1:(i.current=void 0,r.current={conversationId:e,runId:p},n(!0),a.current&&u(e,p),!0);let m=[...c.current.values()].filter(e=>e.runId===void 0).find(e=>e.messageId===f);return m?(m.runId=p,r.current={conversationId:e,runId:p},i.current=void 0,a.current=!1,o.current=void 0,s.current=!0,n(!0),!0):(i.current=void 0,r.current={conversationId:e,runId:p},n(!0),a.current&&u(e,p),s.current)},[u,n]),y=B(e=>typeof e==`string`&&r.current?.runId===e&&s.current,[]),b=B(()=>{let e=r.current;if(e)return a.current=!0,u(e.conversationId,e.runId),!0;let t=i.current;return t?(a.current=!0,t.then(e=>{e.runId&&u(e.conversationId,e.runId)}).catch(()=>void 0),!0):!1},[u]);return z(()=>({localSendRef:s,begin:d,beginRouted:f,acceptAck:m,acceptRoutedAck:h,reject:g,rejectRouted:_,captureStart:v,ownsLocalRun:y,settle:p,stop:b}),[m,h,d,f,v,y,g,_,p,b])}const jm=C.scope(`send`);function Mm(e,t,n,r,i,a=!0){e.publishConversation({...ws(t,n,r,i,a),hasUnread:!1},!0)}function Nm(e,t){return e.id===t.id||(e.serverMessageId??e.id)===(t.serverMessageId??t.id)}function Pm(e){return e.findLast(e=>!e.ephemeral&&e.role!==`system`&&(e.role===`user`||e.status!==`streaming`||Ts(e)))}function Fm(e,t,n,r,i){let a=Pm(t);a?.role===`user`&&Nm(a,n)&&Mm(e,t,a,r,i)}function Im(e){return!(e instanceof nc)||e.code===`network`||e.status===void 0||e.status===202||e.status===408||e.status===425||e.status===429||e.status>=500&&e.status<600}function Lm(e){let{transport:t,messagesSig:n,conversationIdSig:r,options:i,bus:a,feedback:o,persistence:s,visitorId:c,adoptConversationId:l,applyControlState:u,setCanSend:d,settleSuggestions:f,runCancellation:p}=e,m=B(()=>{let e=r.value??Fn();return r.value||(r.value=e,s.saveConversationId(e)),e},[r,s]);return{sendAiTurn:B(async({continueExisting:e,turn:h})=>{let g=m(),_=n.value.at(-1),v=h?[h]:xs(n.value,e),y=v[0];y?.role===`user`&&M.markSent(y.id);let b=v.map(Ss),x=s.loadUserPrefs(),S=Ce(i.tools).then(n=>t.sendTurn(ls({messages:b,conversationId:g,visitorId:c,userPrefs:x,clientTools:we(n)}),{keepalive:e}));p.begin(S);try{let a=await S;if(r.value!==g||!p.acceptAck(S,a))return!1;if(l(a.conversationId),a.runId&&y?.role===`user`&&Fm(t,n.value,y,a.conversationId,i.strings.newConversation),!a.runId){let o=await t.loadConversation(a.conversationId).catch(()=>null);if(r.value!==a.conversationId)return!0;if(o){o.controlState&&u(o.controlState),d(o.canContinue);let r=bs(o.messages),{messages:s,changed:c}=Vs(n.value,r);c&&(n.value=s);let l=r.findLast(e=>!e.ephemeral&&e.role!==`system`),p=Pm(n.value);p&&l&&Nm(p,l)&&Mm(t,n.value,p,a.conversationId,i.strings.newConversation,o.canContinue);let m=_?n.value.find(e=>e.id===_.id&&e.role===`assistant`&&e.status!==`streaming`):void 0;m&&f(m,m.suggestions??[]),!e&&_?.role===`assistant`&&n.value.includes(_)&&_.serverMessageId===void 0&&!Ts(_)&&(n.value=n.value.filter(e=>e!==_))}else _?.role===`assistant`&&n.value.includes(_)&&(_.status=`error`,_.errorText=i.strings.errorGeneric,_.retryAction=e?{kind:`continue-assistant`,messageId:_.serverMessageId??_.id}:y?.role===`user`?{kind:`resend-user`,messageId:y.id}:null,n.value=[...n.value])}return!0}catch(s){if(r.value!==g)return!1;if(!p.reject(S))return y?.role===`user`&&Fm(t,n.value,y,g,i.strings.newConversation),!0;let c=bu(s,i.strings),l=Im(s),m=h?.role===`assistant`?h:n.value.at(-1);if(e&&m?.role===`assistant`&&s instanceof nc&&s.status===409){let e=m.serverMessageId??m.id,i=await t.loadConversation(g,{ids:[e]}).catch(()=>null);if(r.value!==g)return!1;if(i){i.controlState&&u(i.controlState),d(i.canContinue);let t=bs(i.messages),r=t.find(t=>(t.serverMessageId??t.id)===e);if(r&&Hs(m,r)){let{messages:r,changed:i}=Vs(n.value,t),a=r.find(t=>(t.serverMessageId??t.id)===e);if(i&&a&&a!==m)return a.awaitingContinuation=!1,a.continuationStreaming=void 0,a.retryAction=null,n.value=r,a.status!==`streaming`&&f(a,a.suggestions??[]),!0}}if(!n.value.includes(m)||m.status!==`streaming`)return!1;m.continuationStreaming=!0}if(e&&m?.role===`assistant`)m.status=`error`,m.errorText=c,m.retryAction=l?{kind:`continue-assistant`,messageId:m.serverMessageId??m.id}:null,n.value=[...n.value];else if(_?.role===`assistant`&&n.value.includes(_)){_.status=`error`,_.errorText=c;let e=v[0];_.retryAction=l&&e?.role===`user`?{kind:`resend-user`,messageId:e.id}:null,n.value=[...n.value]}else{let e=ps();e.status=`error`,e.errorText=c;let t=v[0];e.retryAction=l&&t?.role===`user`?{kind:`resend-user`,messageId:t.id}:null,n.value=[...n.value,e]}return o.play(`error`),a.emit(`error`,s),i.onError?.(s),!1}},[t,n,i,a,o,s,c,l,u,d,f,m,p]),sendRoutedTurn:B(async e=>{let u=m();e.status=`pending`,e.errorText=void 0,e.retryAction=void 0,n.value.includes(e)&&(n.value=[...n.value]),M.markSent(e.id);let d=[Ss(e)],f=s.loadUserPrefs(),h=Ce(i.tools).then(e=>t.sendTurn(ls({messages:d,conversationId:u,visitorId:c,userPrefs:f,clientTools:we(e)})));p.beginRouted(h,e.id);try{let a=await h;return r.value===u?p.acceptRoutedAck(h,a)?(l(a.conversationId),Fm(t,n.value,e,a.conversationId,i.strings.newConversation),e.status===`pending`&&(e.status=`complete`,n.value.includes(e)&&(n.value=[...n.value])),!0):!1:(p.rejectRouted(h),!1)}catch(s){let c=p.rejectRouted(h);if(r.value!==u)return!1;if(!c)return Fm(t,n.value,e,u,i.strings.newConversation),e.status===`pending`&&(e.status=`complete`,n.value.includes(e)&&(n.value=[...n.value])),!0;if(e.status!==`pending`)return Fm(t,n.value,e,u,i.strings.newConversation),!0;jm.debug(`operator-routed send failed`,{error:s});let l=s instanceof Error?s:Error(String(s));return e.status=`error`,e.errorText=bu(s,i.strings),e.retryAction=Im(s)?{kind:`resend-user`,messageId:e.id}:null,n.value.includes(e)&&(n.value=[...n.value]),o.play(`error`),a.emit(`error`,l),i.onError?.(l),!1}},[t,n,i,a,o,s,c,l,m,p])}}const Rm=C.scope(`unread`);function zm(e){let{transport:t,options:n,conversationIdSig:r,isConversationVisibleRef:i,activated:a,conversationReady:o}=e,s=_i(!1),c=_i(0),l=_i(0),u=R([]),d=R(void 0),f=R(!1),p=B(()=>{let e=r.value,t=i.current()&&d.current===e?e:void 0,n=u.current.filter(e=>e.hasUnread&&e.conversationId!==t).length;c.value=n,s.value=n>0},[r,s,c,i]),m=B(e=>{let t=r.value,n=u.current.find(e=>e.conversationId===t),i=pc(u.current,e),a=i.find(e=>e.conversationId===t),o=e.type===`snapshot`&&t!==void 0&&a?.hasUnread===!0&&d.current===t&&n!==void 0&&n.lastMessageAt!==a.lastMessageAt;o&&(d.current=void 0),u.current=i,p(),o&&(l.value+=1)},[r,p,l]),h=B(()=>{if(p(),!i.current())return;let e=r.value;if(!e||d.current!==e)return;let n=u.current.find(t=>t.conversationId===e);n?.hasUnread&&t.markRead(e,n.lastMessageAt)},[r,i,p,t]),g=B(e=>{r.value===e&&(d.current=void 0,p())},[r,p]),_=B(e=>{r.value===e&&(d.current=e,h())},[r,h]),v=B(e=>d.current===e,[]),y=B((e=!1)=>{n.modules.list.some(e=>e.layout===`chat`)&&(f.current||(f.current=!0,t.listConversations({limit:50},e).then(t=>{e||m({type:`snapshot`,result:t,requestedRevision:0}),h()}).catch(e=>Rm.debug(`refreshUnread failed (non-fatal)`,{err:e})).finally(()=>{f.current=!1})))},[m,h,n.modules,t]),b=B(e=>{let n=e.conversationId,a=i.current()&&r.value===n&&d.current===n,o=u.current.find(e=>e.conversationId===n),s=a&&(o?.lastMessageAt!==e.lastMessageAt||o.hasUnread);t.publishConversation({...e,hasUnread:!a},!0),s&&t.markRead(n,e.lastMessageAt)},[r,i,t]);L(()=>t.subscribeConversationChanges(m),[m,t]);let x=R(!1);return L(()=>{a&&o&&!x.current&&(x.current=!0,y())},[a,o,y]),L(()=>{if(!a)return;function e(){document.visibilityState===`visible`&&(h(),y(!0))}return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[a,h,y]),{hasUnreadSig:s,unreadCountSig:c,transcriptRecoverySig:l,markVisibleConversationRead:h,beginConversationTranscript:g,commitConversationTranscript:_,isConversationTranscriptCommitted:v,recordConversationReply:b}}const Bm=C.scope(`settings`);function Vm(e){let{options:t,persistence:n,transport:r,feedback:i,hostElement:a,bus:o}=e,s=n.loadUserPrefs(),[c,l]=I(()=>s.locale??t.locale),[u,d]=I(s.themeMode),f=u??t.themeMode,[p,m]=I(()=>s.textSize??t.textSize),h=B(e=>{n.patchUserPrefs(e),r.saveUserPrefs(n.loadUserPrefs()).catch(e=>Bm.warn(`saveUserPrefs failed`,{err:e}))},[n,r]);L(()=>{s.soundMuted!==void 0&&i.setMuted(s.soundMuted)},[]),L(()=>{if(f!==`host`)a.dataset.theme=f;else return Qn(e=>{a.dataset.theme=e})},[a,f,t]),L(()=>{a.dataset.textSize=p},[a,p,t]),L(()=>{let e=!0;return i.mutedSig.subscribe(t=>{e?e=!1:h({soundMuted:t})})},[i,h]);let g=en(c,t.availableLocales,t.defaultLocale);return L(()=>{r.setLocale(g)},[r,g]),L(()=>{a.dir=kt(g)?`rtl`:`ltr`},[a,g]),L(()=>{g!==c&&l(g)},[g,c]),{activeLocale:c,activeThemeMode:f,activeTextSize:p,effectiveLocale:g,setActiveLocale:l,setActiveThemeMode:d,setActiveTextSize:m,patchAndSync:h,handleLocaleChange:B(e=>{Bm.info(`localeChange`,{locale:e}),l(e),h({locale:e}),o.emit(`localeChange`,e)},[h,o]),handleThemeChange:B(e=>{Bm.info(`themeChange`,{mode:e}),d(e),a.dataset.theme=e,h({themeMode:e}),o.emit(`themeChange`,e)},[a,h,o]),handleTextSizeChange:B(e=>{Bm.info(`textSizeChange`,{size:e}),m(e),a.dataset.textSize=e,h({textSize:e}),o.emit(`textSizeChange`,e)},[a,h,o]),handleSoundToggle:B(()=>{i.toggleMuted();let e=i.mutedSig.value;Bm.info(`soundToggle`,{muted:e}),o.emit(`soundToggle`,{muted:e})},[i,o])}}const $=C.scope(`app`),Hm=u.cssPrefix,Um={home:`home`,chats:`chat`,help:`help`,news:`news`};function Wm(e,t){return ms({...e,text:At(t,e.text)})}function Gm({options:e,hostElement:t,bus:n,recentHostEvents:r}){let i=e.aiAgentDeploymentId;if(!i)throw Error(`aiAgentDeploymentId is required`);let[a]=I(()=>Rn(e.widgetId,e.storage,e.aiAgentDeploymentId)),[o]=I(()=>a.getVisitorId()),s=a.loadUserPrefs(),l=_i(a.loadConversationId()),d=R(l.value!==void 0),f=_i(l.value??``),p=_i([]),[m,h]=I(!1),g=R(void 0),[_,v]=I([]);function y(){let t=e.modules.list,n=new Set(t.map(e=>e.id)),r=a.loadActiveModule();return r&&n.has(r)?r:t[0]?.id??``}function b(){return e.modules.list.find(e=>e.layout===`chat`)?.id}function x(){let t=b();return t?e.modules.list.length===1||C.sig.value.activeTab===t:!1}let S=R(void 0);if(!S.current){let t=e.modules.list.map(e=>e.id),n=a.loadActiveModule()??t[0]??``;S.current=Mc(n,n?[...t,n]:t,e=>a.saveActiveModule(e))}let C=S.current,w=vi(()=>C.sig.value.activeTab).value,T=vi(()=>l.value).value,[E,D]=I(!1),[O,ee]=I(null),[k,te]=I(!1),ne=e.mode===`standalone`||e.mode===`inline`,A=R(Rc(e,zc(),a.loadPanelOpen(),a.loadPanelSize())),[j,re]=I(A.current.panelOpen),[ie,ae]=I(A.current.panelOpen),oe=R(void 0),se=R(void 0),ce=R(!1),le=R(void 0);L(()=>{j&&ae(!0)},[j]);let M=R(!1),[ue,de]=I(!1),{dismissed:fe,dismissCallout:pe}=im({callout:e.launcher.callout,persistence:a}),me=e.launcher.callout?.persistent??!0,he=B(()=>{$.info(`calloutDismiss`),n.emit(`calloutDismiss`,void 0),pe()},[n,pe]),[N,ge]=I(A.current.panelSize),_e=R(!1),[ve,ye]=I(`chat`),be=R(()=>!1);be.current=()=>j&&ve===`chat`&&!document.hidden&&x();let[xe,Se]=I(!0),Ce=R(xe);Ce.current=xe;let[we,Te]=I(!1),Ee=R(we);Ee.current=we;let De=R(null),[Oe,ke]=I(!1),[Ae,je]=I(null),[Me,P]=I([]),Ne=R(e.strings),Pe=R(e);Pe.current=e;let[Fe,Ie]=I(void 0),[Le,Re]=I(void 0),[ze,Be]=I(()=>a.loadSidebarCollapsed()??!1),[Ve,He]=I({}),[F]=I(()=>new yc({agentApiBaseUrl:e.agentApiBaseUrl,dataApiBaseUrl:e.dataApiBaseUrl,auth:Si({publicKey:e.publicKey,aiAgentDeploymentId:i,publicKeyHeader:`x-public-key`}),endpoints:e.endpoints,recentHostEvents:r})),[Ue]=I(()=>new Wi(e.sound,e.haptics)),We=Am({transport:F,setStreaming:Te}),{activeLocale:Ge,activeThemeMode:Ke,activeTextSize:qe,effectiveLocale:Je,setActiveLocale:Ye,setActiveThemeMode:Xe,setActiveTextSize:Ze,patchAndSync:Qe,handleLocaleChange:$e,handleThemeChange:et,handleTextSizeChange:tt,handleSoundToggle:nt}=Vm({options:e,persistence:a,transport:F,feedback:Ue,hostElement:t,bus:n}),{controlModeSig:rt,assignedOperatorInitialsSig:it,operatorAvailableSig:at,applyControlState:ot,adoptControlStateChunk:st,requestOperator:ct,cancelOperatorRequest:lt}=am({transport:F,conversationIdSig:l}),ut=_i(/* @__PURE__ */ new Map),dt=B(e=>{if(e.type!==`data-memory-compaction-state`)return;let t=l.value;if(!t)return;let n=ss(e.data);if(!n)return;let r=ut.value.get(t);if(r&&(n.postFinishSequence<r.postFinishSequence||n.postFinishSequence===r.postFinishSequence&&(r.status===`ready`||r.status===n.status)))return;let i=new Map(ut.value);i.set(t,n),ut.value=i},[l,ut]),{hasUnreadSig:ft,unreadCountSig:pt,transcriptRecoverySig:mt,markVisibleConversationRead:ht,beginConversationTranscript:gt,commitConversationTranscript:_t,isConversationTranscriptCommitted:vt,recordConversationReply:yt}=zm({transport:F,options:e,conversationIdSig:l,isConversationVisibleRef:be,activated:ie,conversationReady:E}),bt=j&&e.modules.byId[w]?.layout===`home`,xt=rm({transport:F,options:e,persistence:a,enabled:E&&bt});L(()=>{ht()},[w,j,ve,T,ht]),L(()=>{Ue.update(e.sound,e.haptics)},[Ue,e.sound,e.haptics]),L(()=>()=>Ue.destroy(),[Ue]),L(()=>{!_e.current&&e.size.initialSize&&(_e.current=!0,!a.loadPanelSize()&&ge(Lc(e.mode,e.size,zc())))},[e.mode,e.size,a]),L(()=>{if(!E||M.current)return;M.current=!0;let t=Rc(e,zc(),a.loadPanelOpen(),a.loadPanelSize());re(t.panelOpen),ge(t.panelSize)},[E,e,a]);let St=R(null);L(()=>{E&&C.reconcile(e.modules.list.map(e=>e.id),y())},[E,e.modules.list,C]);let Ct=B(e=>{e&&e.length!==0&&(p.value=e.map(e=>Wm(e,Ne.current)))},[p]),wt=R(null),Tt=B(async e=>{try{let{formSubmissions:t}=await(e?F.bootstrap(e):wt.current??F.bootstrap()),n=/* @__PURE__ */ new Map;return t.forEach((e,t)=>n.set(e.formId,t)),t.filter((e,t)=>!e.skipped||n.get(e.formId)===t).map((e,t)=>({key:`wire:${e.formId}:${e.createdAt??t}`,formId:e.formId,outcome:e.skipped?`skipped`:`submitted`,createdAt:es(e.createdAt),values:e.values}))}catch(e){return $.debug(`bootstrap failed — no form markers (non-fatal)`,{err:e}),[]}},[F]),Et=R(0),Dt=R(0),Ot=B(e=>{if(e===l.value)return;let t=l.value;Dt.current++,h(!1),t&&(a.saveDraft(e,a.loadDraft(t)),a.saveDraft(t,``),a.saveMessageQueue(e,a.loadMessageQueue(t)),a.saveMessageQueue(t,[])),l.value=e,a.saveConversationId(e),F.primeIdentity(void 0,e),$.info(`conversation rebound`,{previous:t,current:e}),t&&n.emit(`conversationRebound`,{previous:t,current:e})},[n,l,a,F]),kt=B((e,t)=>{let n=[...e.map(e=>e.createdAt),...t.map(e=>e.createdAt)].filter(e=>e!==void 0),r=(n.length?Math.min(...n):Date.now())-1;return[...(le.current?.messages??[]).map(e=>{let t=Wm(e,Ne.current);return t.createdAt=r,t}),...e]},[]),jt=B(async e=>{let t=Dt.current;function r(){return t!==Dt.current||l.value!==e}se.current===e&&(se.current=void 0),h(!0);try{let[t,n]=await Promise.all([F.loadConversation(e),Tt()]);if(r())return!1;let i=bs(t.messages);v(n);let a=kt(Bs(i,p.value),n);if(p.value=a,se.current=a.some(e=>e.role===`user`)?void 0:e,i.length>0||t.controlState!==void 0){Se(t.canContinue),t.controlState&&ot(t.controlState);let e=i.findLast(e=>e.role===`assistant`&&!e.ephemeral);P(e?.suggestions??[])}return!0}catch(t){return r()||($.warn(`loadThread failed; keeping conversation active`,{err:t,conversationId:e}),n.emit(`error`,t),Pe.current.onError?.(t)),!1}finally{r()||h(!1)}},[F,Tt,p,l,kt,n]),Mt=B(e=>{if(oe.current===e)return oe.current=void 0,jt(e)},[jt]),Nt=B(()=>{if(g.current)return Promise.resolve(void 0);let t=l.value,r=p.value.find(e=>e.serverMessageId!==void 0),i=r?.serverMessageId,a=r?new Date(r.createdAt).toISOString():void 0;if(!t||!i||!a)return Promise.resolve(void 0);let o=Dt.current,s={};return g.current=s,(async()=>{try{let e=await F.loadConversation(t,{beforeId:i,beforeCreatedAt:a});if(g.current!==s||Dt.current!==o||l.value!==t)return;if(e.messages.length===0)return!1;let n=e.messages.map(_s),r=p.value,c=Fs(r,n);if(c!==r){let e=Math.min(...n.map(e=>e.createdAt??1/0),..._.map(e=>e.createdAt??1/0));if(Number.isFinite(e))for(let t of r){if(!t.ephemeral)break;(t.createdAt??1/0)>=e&&(t.createdAt=e-1)}p.value=c}return!0}catch(r){if(g.current!==s||Dt.current!==o||l.value!==t)return;$.warn(`load previous messages failed`,{err:r,conversationId:t,beforeId:i}),n.emit(`error`,r),e.onError?.(r);return}finally{g.current===s&&(g.current=void 0)}})()},[n,l,_,p,e,F]),Pt=B(async({newConversation:t})=>{let r=++Et.current;function i(){return r!==Et.current}let s=l.value,c=t||!s?Fn():s;c!==s&&(Dt.current++,h(!1),Br(()=>{l.value=c,f.value=c}),a.saveConversationId(c)),F.primeIdentity(o,c);let u;try{u=await F.handshake({visitorId:o,conversationId:c,userPrefs:a.loadUserPrefs(),locale:Ge})}catch(r){if(i())return;n.emit(`error`,r),e.onError?.(r),t||D(!0);return}if(i())return;u.conversationId!==c&&Ot(u.conversationId),je(u.agent),e.mode===`page`&&(u.site&&Ki(u.site)?Ie(u.site):u.site&&$.warn(`invalid site config, using fallback`,{site:u.site}),u.blocks&&qi(u.blocks)?Re(u.blocks):u.blocks&&$.warn(`invalid blocks config, using fallback`,{blocks:u.blocks}));let p=Vn(u.userPrefs);if(Object.keys(p).length>0&&!t&&(a.saveUserPrefs(p),p.locale&&Ye(p.locale),p.soundMuted!==void 0&&Ue.setMuted(p.soundMuted),p.themeMode&&Xe(p.themeMode),p.textSize&&Ze(p.textSize)),le.current=u.welcome,t||n.emit(`handshake`,u),u.welcome?.suggestions){let e=Ne.current;P(u.welcome.suggestions.map(t=>({...t,label:At(e,t.label),...t.text===void 0?{}:{text:At(e,t.text)}})))}let m=!t&&s&&u.conversationId===s;d.current=!!m,m?ce.current||(oe.current=u.conversationId):(se.current=u.conversationId,Ct(u.welcome?.messages),_t(u.conversationId)),t||D(!0)},[F,o,a,e,n,l,f,Ue,Ct,Ge,Ot,_t]),Ft=JSON.stringify(e.userContext??null);L(()=>{let t=Object.keys(Ve).length?{...Ve,...e.userContext}:e.userContext;F.setContext(t,Km(e.pageContext))},[F,Ft,JSON.stringify(e.pageContext??null),JSON.stringify(Ve)]),L(()=>F.setUserToken(e.userToken),[F,e.userToken]);let It=B((e,t=[])=>P(e.suggestions??t),[]);L(()=>(F.primeIdentity(o,l.value),Pt({newConversation:!1}),()=>{Et.current++,Dt.current++}),[]),L(()=>{ie&&E&&!ce.current&&(ce.current=!0,wt.current=F.bootstrap(),(async()=>{try{let e=await wt.current;ee(ln((e??{forms:[]}).forms,Je))}catch(e){$.debug(`bootstrap failed — treating as no forms`,{err:e})}finally{te(!0)}})(),oe.current===l.value&&h(!0))},[ie,E]);let Lt=R(null);L(()=>{if(!ie||!E||(Lt.current??(Lt.current=Je),Lt.current===Je))return;Lt.current=Je;let e=!1;return F.bootstrap().then(t=>{e||ee(ln((t??{forms:[]}).forms,Je))}).catch(e=>$.debug(`forms re-localize failed — keeping current copy`,{err:e})),()=>{e=!0}},[ie,E,Je,F]);let Rt=R(Ft);L(()=>{E&&Rt.current!==Ft&&(Rt.current=Ft,Pt({newConversation:!1}))},[Ft,E,Pt]),lm({hostElement:t,mode:e.mode,panelSize:N,isOpen:j,surfaceReady:E,setIsOpen:re});let{sendAiTurn:zt,sendRoutedTurn:Bt}=Lm({transport:F,messagesSig:p,conversationIdSig:l,options:e,bus:n,feedback:Ue,persistence:a,visitorId:o,adoptConversationId:Ot,applyControlState:ot,setCanSend:Se,settleSuggestions:It,runCancellation:We}),{toolInteraction:Vt,pageToolsRunning:Ht,stopPageTools:Ut}=tm({streaming:we,controlModeSig:rt,messagesSig:p,sendAiTurn:zt,bus:n,humanInLoop:e.features.humanInLoop,tools:e.tools}),Wt=B((e,t)=>{let r=p.value.find(t=>t.serverMessageId===e);r&&(r.feedback=t),$.info(`messageFeedback`,{messageId:e,value:t}),n.emit(`messageFeedback`,{messageId:e,value:t}),F.submitFeedback({messageId:e,value:t})},[n,p,F]);function Gt(){return p.value.reduce((e,t)=>e+ +(t.role===`user`),0)}let Kt=e.forms.list.length>0?e.forms:O??e.forms,qt=Ec({forms:Kt,persistence:a,userContext:()=>e.userContext,messageCount:Gt,pageArea:()=>e.pageContext?.area?String(e.pageContext.area):void 0,conversationId:()=>l.value,onComplete:(e,t,r,i)=>{$.info(`formSubmit`,{formId:e.id,trigger:t,skipped:i}),n.emit(`formSubmit`,{formId:e.id,values:r,skipped:i}),v(t=>{let n=t.find(t=>t.formId===e.id&&t.outcome===`skipped`)?.createdAt??Date.now();return[...t.filter(t=>t.formId!==e.id||t.outcome!==`skipped`),{key:`local:${e.id}:${n}`,formId:e.id,outcome:i?`skipped`:`submitted`,createdAt:n,...i?{}:{values:r}}]});let o=l.value??Fn();l.value||(l.value=o,a.saveConversationId(o),F.primeIdentity(void 0,o)),!i&&e.mirrorToContext&&He(e=>({...e,...r})),F.submitForm({formId:e.id,conversationId:o,trigger:t,values:r,skipped:i})}}),Jt=vi(()=>qt.activeForm.value);km({activated:ie,conversationReady:E,conversationIdSig:l,messagesSig:p,optionsRef:Pe,transport:F,visitorId:o,adoptControlStateChunk:st,adoptMemoryCompactionStateChunk:dt,settleSuggestions:It,recordConversationReply:yt,transcriptRecoverySig:mt,beginConversationTranscript:gt,commitConversationTranscript:_t,onReplyLanded:B(()=>qt.fire(`after-messages`),[qt]),runCancellation:We,canContinueRef:Ce,setCanSend:Se,feedback:Ue,bus:n,loadInitialThread:Mt,shouldReconcileOnConnect:B(()=>d.current||p.value.some(e=>!e.ephemeral&&e.role===`user`),[p])}),L(()=>{qt.refresh()},[Kt,qt]);let Yt=e.pageContext?.area?String(e.pageContext.area):void 0,Xt=vi(()=>p.value.length);L(()=>{E&&k&&qt.fire(`pre-chat`)},[E,k,qt]),L(()=>{k&&!xe&&qt.fire(`conversation-closed`)},[k,xe,qt]),L(()=>{E&&k&&Yt&&qt.fire(`page-area`)},[E,k,Yt,qt]);let Zt=z(()=>{let e=Kt.list.flatMap(e=>e.triggers).filter(e=>e.kind===`idle`).map(e=>Number(e.param));return e.length?Math.min(...e)*1e3:0},[Kt]);L(()=>{if(!Zt||!j)return;let e=setTimeout(()=>qt.fire(`idle`),Zt);return()=>clearTimeout(e)},[Zt,j,qt,Xt.value]);let Qt=B(async(t,r,i)=>{if(De.current)return!1;let a=l.value,o=a?ut.value.get(a):void 0,s=rt.value!==`ai-agent`;if(!s&&o?.status===`compacting`||($.info(`send`,{textLen:t.length,attachments:r.length,streaming:Ee.current,routedToOperator:s}),Ee.current&&!s))return!1;let c=new AbortController,u={conversationId:a,controller:c};De.current=u,ke(!0);try{Ue.unlock();let o=await Jm(F,r,c.signal,t=>{c.signal.aborted||($.warn(`upload failed`,{err:t}),n.emit(`error`,t),e.onError?.(t))});if(c.signal.aborted||l.value!==a||!Ce.current||qt.activeForm.value)return!1;let s=a?ut.value.get(a):void 0,u=rt.value!==`ai-agent`;if(!u&&s?.status===`compacting`||Ee.current&&!u||!t&&o.length===0)return!1;n.emit(`send`,{text:t,attachmentCount:r.length}),Me.length>0&&P([]),Ue.play(`messageSent`);let d=fs(t,o,i);return Tc(n,e,`user`,t),u?(p.value=[...p.value,d],i?await Bt(d):(Bt(d),!0)):(p.value=[...p.value,d,ps()],i?await zt({continueExisting:!1}):(zt({continueExisting:!1}),!0))}finally{De.current===u&&(De.current=null,ke(!1))}},[F,n,e,Me.length,p,l,ut,zt,Bt,rt]),$t=R(Qt);$t.current=Qt;let en=l.value,tn=(en?ut.value.get(en):void 0)?.status===`compacting`,nn=rt.value===`ai-agent`,rn=vi(()=>{let e=p.value.at(-1);return e?.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`&&e.stateSig.value===`approval-requested`)}),an=vi(()=>p.value.some(e=>e.retryAction?.kind===`resend-user`||e.retryAction?.kind===`continue-assistant`));kr(()=>{let e=l.value;return()=>{let t=De.current;t&&t.conversationId===e&&(De.current=null,ke(!1),t.controller.abort())}},[l.value]),L(()=>{(!xe||Jt.value)&&De.current?.controller.abort()},[Jt.value,xe]);let on=B(()=>{if(Ht){$.info(`stop page tools`),n.emit(`stop`,void 0),Ut();return}if(!We.stop())return;$.info(`stop`),n.emit(`stop`,void 0);let e=p.value.at(-1);e&&e.role!==`user`&&e.status===`streaming`&&(e.canceled=!0,p.value=[...p.value])},[We,n,p,Ht,Ut]),sn=B(e=>{if(we)return;let t=p.value,n=Js(t,e);if(n)switch($.info(`retry`,{kind:n.kind,messageId:n.messageId}),n.kind){case`continue-assistant`:if(rt.value!==`ai-agent`||e.role!==`assistant`||(e.serverMessageId??e.id)!==n.messageId)return;e.status=`streaming`,e.errorText=void 0,e.retryAction=void 0,e.awaitingContinuation=!0,p.value=[...t],zt({continueExisting:!0,turn:e});return;case`resend-user`:{let r=t.find(e=>e.role===`user`&&e.id===n.messageId);if(!r)return;let i=e=>{e&&St.current?.acceptQueuedMessage(n.messageId)};if(r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,rt.value!==`ai-agent`){p.value=e.role===`assistant`?t.filter(t=>t!==e):[...t],Bt(r).then(i);return}let a=ps();p.value=e.role===`assistant`?t.map(t=>t===e?a:t):[...t,a],zt({continueExisting:!1,turn:r}).then(i);return}case`repeat-user`:{let e=t.find(e=>e.role===`user`&&e.id===n.messageId);if(!e)return;let r=fs(Cs(e),e.attachments?.map(e=>({...e}))??[]),i=new Set(r.attachments?.flatMap(e=>e.url?[e.url]:[])??[]),a=e.partsSig.value.flatMap(e=>e.kind===`file`&&!i.has(e.url)?[{...e}]:[]);if(a.length>0&&(r.partsSig.value=[...r.partsSig.value,...a]),rt.value!==`ai-agent`){p.value=[...t,r],Bt(r);return}p.value=[...t,r,ps()],zt({continueExisting:!1,turn:r});return}default:return n}},[we,p,rt,zt,Bt]),cn=B(()=>{wc(e.mode,N)===`exit-fullscreen`?($.info(`close → exit-fullscreen`,{mode:e.mode}),ge(`normal`),n.emit(`fullscreen`,!1)):($.info(`close → panel closed`,{mode:e.mode}),qt.fire(`panel-close`),re(!1),a.savePanelOpen(!1),n.emit(`close`,void 0),e.onClose?.())},[n,e,a,N,qt]),un=B(()=>{$.info(`open`,{mode:e.mode}),Ue.unlock(),de(!0),re(!0),a.savePanelOpen(!0),!fe&&!me&&he(),setTimeout(()=>de(!1),qm),n.emit(`open`,void 0),e.onOpen?.()},[n,e,Ue,a,fe,me,he]),dn=B(()=>{let e=p.value.some(e=>e.role===`user`);if(se.current===l.value&&!e&&xe&&l.value)$.info(`clear → reusing empty conversation`,{conversationId:l.value}),p.value.length===0&&Ct(le.current?.messages);else return $.info(`clear → new conversation`,{wasStreaming:we}),n.emit(`clear`,void 0),We.settle(),d.current=!1,oe.current=void 0,se.current=void 0,Br(()=>{p.value=[],l.value=void 0,ot({controlMode:`ai-agent`,controlRevision:0})}),a.clearConversation(),Se(!0),v([]),P([]),Pt({newConversation:!0})},[we,p,l,a,Pt,n,xe,Ct,We,ot]),pn=B(()=>{let t=dn();ye(`chat`);let n=e.modules.list.find(e=>e.layout===`chat`)?.id;return n&&C.switchTab(n),t},[dn,C,e]),mn=B(async e=>{await pn(),await $t.current(e,[])||St.current?.fill(e)},[pn]),hn=B(()=>{let e=N===`expanded`?`normal`:`expanded`;$.info(`expand`,{from:N,expanded:e===`expanded`}),ge(e),a.savePanelSize(e),n.emit(`expand`,e===`expanded`)},[n,N,a]),gn=B(()=>{let e=N===`fullscreen`?`normal`:`fullscreen`;$.info(`fullscreen`,{from:N,fullscreen:e===`fullscreen`}),ge(e),a.savePanelSize(e),n.emit(`fullscreen`,e===`fullscreen`)},[n,N,a]),_n=B(()=>{ye(e=>{let t=e===`history`?`chat`:`history`;return $.info(`toggleHistory`,{view:t}),n.emit(`toggleHistory`,{view:t}),t})},[n]),vn=B(()=>{Be(e=>{let t=!e;return $.info(`sidebarToggle`,{collapsed:t}),a.saveSidebarCollapsed(t),n.emit(`sidebarToggle`,{collapsed:t}),t})},[a,n]),yn=B(e=>{$.info(`resize`,e),Qe({widgetSize:e}),n.emit(`resize`,e)},[Qe,n]),bn=B(async t=>{let r=t.conversationId;if(r===l.value&&vt(r)){$.info(`selectConversation`,{conversationId:r,cached:!0}),n.emit(`selectConversation`,{conversationId:r}),F.publishConversation(t),ye(`chat`);let e=b();e&&C.switchTab(e),_t(r);return}let i=++Et.current;Dt.current++,h(!1);function s(){return i!==Et.current}$.info(`selectConversation`,{conversationId:r,wasStreaming:we}),n.emit(`selectConversation`,{conversationId:r}),F.publishConversation(t);try{let[e,t]=await Promise.all([F.loadConversation(r),Tt(r)]);if(s())return;We.settle(),d.current=!0,oe.current=void 0;let n=bs(e.messages),i=e.conversationId!==l.value,c=i?n:Bs(n,p.value);se.current=c.some(e=>e.role===`user`)?void 0:e.conversationId,Br(()=>{p.value=kt(c,t),i&&(f.value=e.conversationId),l.value=e.conversationId}),v(t),a.saveConversationId(e.conversationId),F.primeIdentity(o,e.conversationId),Se(e.canContinue),e.controlState&&ot(e.controlState);let u=c.findLast(e=>e.role===`assistant`&&!e.ephemeral);P(u?.suggestions??[]),i?gt(e.conversationId):_t(e.conversationId),ye(`chat`);let m=b();m&&C.switchTab(m)}catch(t){if(s())return;n.emit(`error`,t),e.onError?.(t)}},[F,p,l,f,n,e,a,Tt,kt,we,o,We,gt,_t,vt,C]),xn=R(null),Sn=B(e=>{typeof e==`string`&&(k?qt.fire(`manual`,e):xn.current=e)},[k,qt]);L(()=>{k&&xn.current&&(qt.fire(`manual`,xn.current),xn.current=null)},[k,qt]);let Cn=R(void 0),wn=B(t=>{let n=e.modules.list.find(e=>e.layout===Um[t.to]);if(!n){$.warn(`open: the widget has no such tab`,{to:t.to});return}let r=t.id&&(n.layout===`help`||n.layout===`news`)?{kind:`content`,id:t.id,title:``}:void 0;C.open(n.id,r)},[e.modules,C]),Tn=B(e=>{j||un(),e!==void 0&&(wi(e)?E?wn(e):Cn.current=e:$.warn(`open: unknown target`,{detail:e}))},[j,un,E,wn]);L(()=>{E&&Cn.current&&(wn(Cn.current),Cn.current=void 0)},[E,wn]);let En=E&&!m&&!Jt.value&&(!nn||!rn.value&&!an.value),[Dn,On]=I(),kn=B(e=>{let t=Di(e);t?(j||un(),On(t)):$.warn(`ask: expected { text, send? } with non-empty text`,{detail:e})},[j,un]),An=j&&k&&xe&&E&&!m&&!Jt.value,jn=An&&En&&!Oe&&!(nn&&(we||tn));L(()=>{if(Dn===void 0||!(Dn.send?jn:An))return;let e=b();e?ve!==`chat`||!x()?(ye(`chat`),C.switchTab(e)):(On(void 0),Dn.send?Qt(Dn.text,[]).then(e=>{e||St.current?.fill(Dn.text)}):St.current?.fill(Dn.text)):($.warn(`ask: the widget has no chat`),On(void 0))},[Dn,An,jn,ve,w,e.modules,C,Qt]),L(()=>{if(e.widgetId!=="default")return;let n=`data-${u.cssPrefix}-`,r=[`ask`,`open`,`close`,`form`].map(e=>n+e);function i(e){let i=e.composedPath().find(e=>e instanceof Element&&r.some(t=>e.hasAttribute(t)));if(!(i instanceof Element))return;e.preventDefault();let a=i.getAttribute(`${n}ask`),o=i.getAttribute(`${n}open`),s=i.getAttribute(`${n}form`);a===null?o===null?s===null?ki(t,`close`):ki(t,`openForm`,s):ki(t,`open`,Ti(o)):ki(t,`ask`,Ei(a||(i.textContent??``),{send:i.hasAttribute(`${n}send`)}))}return document.addEventListener(`click`,i),()=>document.removeEventListener(`click`,i)},[e.widgetId,t]),L(()=>{if(e.widgetId!=="default")return;let n=Mi(location.href);n&&(history.replaceState(history.state,``,n.url),n.ask?ki(t,`ask`,Ei(n.ask)):ki(t,`open`,n.target))},[e.widgetId,t]);let Mn=R(c),Nn=e.mode===`page`||e.mode===`inline`||e.mode===`standalone`;L(()=>si(()=>{let e=l.value,t={open:Nn||j,ready:E,unread:pt.value,...e?{conversationId:e}:{}},r=Mn.current;(t.open!==r.open||t.ready!==r.ready||t.unread!==r.unread||t.conversationId!==r.conversationId)&&(Mn.current=t,n.emit(`state`,t),t.unread!==r.unread&&n.emit(`unread`,t.unread))}),[n,Nn,j,E,pt,l]);let Pn=R({handleOpenCommand:Tn,handleClose:cn,handleExpand:hn,handleFullscreen:gn,openForm:Sn,handleAskCommand:kn});Pn.current={handleOpenCommand:Tn,handleClose:cn,handleExpand:hn,handleFullscreen:gn,openForm:Sn,handleAskCommand:kn},kr(()=>Ai(t,{open:e=>Pn.current.handleOpenCommand(e),close:()=>Pn.current.handleClose(),expand:()=>Pn.current.handleExpand(),fullscreen:()=>Pn.current.handleFullscreen(),openForm:e=>Pn.current.openForm(e),ask:e=>Pn.current.handleAskCommand(e)}),[t]);let In=z(()=>fn(e,Ge,Ke,qe),[e,Ge,Ke,qe]);Ne.current=In.strings;let Ln=z(()=>_.map(e=>{let t=Kt.list.find(t=>t.id===e.formId);return{...e,title:t?.title,form:t}}),[_,Kt]);function zn(e){bn(e)}let Bn={options:In,transport:F,feedback:Ue,bus:n,persistence:a,conversationId:l.value??``,composerKey:f.value,composerApiRef:St,view:ve,canSend:xe,isStreaming:we,pageToolRunning:Ht,isMemoryCompacting:tn,canReleaseQueuedMessages:En,queueManualMessages:nn&&(rn.value||an.value),sendPreparing:Oe,composerActive:In.mode===`page`||In.mode===`inline`||In.mode===`standalone`||j,controlMode:rt.value,assignedOperatorInitials:it.value,operatorAvailable:at.value,operatorRequestEnabled:e.features.operatorRequest,onRequestOperator:ct,onCancelOperatorRequest:lt,loadingMessages:m,onLoadPreviousMessages:Nt,messagesSig:p,agent:Ae,suggestions:Me,initialWidgetSize:s.widgetSize??null,onClose:cn,onClear:dn,onExpand:hn,onFullscreen:gn,onSoundToggle:nt,onToggleHistory:_n,onSelectHistoryConversation:zn,onNewConversation:pn,onLocaleChange:$e,onThemeChange:et,onTextSizeChange:tt,onWidgetSizeChange:yn,onSend:Qt,onStop:on,onSuggestion:t=>{if(De.current)return;let r=t.text??t.label;$.info(`suggestion`,{text:r,autoSend:e.autoSendSuggestions}),n.emit(`suggestion`,{text:r}),e.autoSendSuggestions?Qt(r,[]):St.current?.fill(r)},activeForm:Jt.value?.form??null,formMarkers:Ln,onFormSubmit:qt.complete,onFormSkip:qt.skip,onFormFill:e=>qt.fire(`manual`,e),tool:Vt,onRetry:sn,onMessageFeedback:Wt};if(!E)return null;let Hn=In.modules.list;function Un(e){let t=Sc(`close`,In.mode,e);return Hn.length===0?/* @__PURE__ */ U(Up,{strings:In.strings,onClose:t?cn:void 0}):Hn.length===1&&Hn[0]?.layout===`chat`?/* @__PURE__ */ U(jp,{...Bn,panelSize:e}):/* @__PURE__ */ U(Vp,{panelProps:{...Bn,panelSize:e,onClose:t?cn:void 0},enabledModules:Hn,nav:C,bus:n,hasUnread:ft.value,latestNews:xt,onSelectConversation:zn,onStartNewConversation:mn,onSetPanelSize:ge})}if(e.mode===`page`){let e=Hn.some(e=>e.layout===`chat`);return/* @__PURE__ */ U(`div`,{class:`${Hm}-anchor`,children:/* @__PURE__ */ U(Xp,{site:Fe,blocks:Le,transport:F,strings:In.strings,locale:In.locale,persistence:a,showConversations:e,onSelectConversation:zn,onNewConversation:pn,sidebarCollapsed:ze,onToggleSidebarCollapsed:vn,children:Un(`fullscreen`)})})}if(ne){let t=e.mode===`standalone`?`fullscreen`:N;return/* @__PURE__ */ U(`div`,{class:`${Hm}-anchor`,children:Un(t)})}let Wn=e.mode===`drawer`,Gn=e.mode!==`modal`&&!e.launcher.hidden&&(!j||ue),Kn=Gn&&!ue&&!fe&&!Wn?In.launcher.callout:null;return/* @__PURE__ */ U(`div`,{class:`${Hm}-anchor`,"data-launcher-size":In.launcher.size,children:[j||ie?/* @__PURE__ */ U(`div`,{class:`${Hm}-surface`,hidden:!j,children:Un(N)}):null,Gn?/* @__PURE__ */ U(Wl,{onToggle:un,launcher:In.launcher,strings:In.strings,leaving:ue,edgeTab:Wn}):null,Kn?/* @__PURE__ */ U(Jl,{callout:Kn,launcherPosition:In.position,strings:In.strings,closeLabel:In.strings.close,onDismiss:he}):null]})}function Km(e){let t=e?.url??(typeof location<`u`?location.href:void 0);if(e||t)return{...e,...t?{url:t}:{}}}const qm=120;async function Jm(e,t,n,r){return(await Promise.all(t.map(async t=>{try{let{id:r,url:i,originalName:a,mimeType:o,fileSize:s}=await e.uploadFile(t.file,n);return{id:r,name:a,mediaType:o,size:s,url:i}}catch(e){r(e);return}}))).filter(e=>e!==void 0)}const Ym=C.scope(`error-boundary`);var Xm=class extends Qe{constructor(...e){super(...e),s(this,`state`,{crashed:!1})}componentDidCatch(e,t){Ym.error(`widget render crashed`,{error:e,componentStack:t?.componentStack}),this.setState({crashed:!0}),this.props.onError(e,t?.componentStack)}render(){return this.state.crashed?this.props.fallback:this.props.children}};function Zm(e){let{bus:t,host:n,appRoot:r,persistence:i,reportError:a}=e,o=e.initialRaw,s,c=Zt(o),l=!0,u=0,d=Pn(t);function f(){c=Zt(s?mn(o,s):o)}function p(){nr(n,rr(c.mode));let e=i.loadUserPrefs().themeMode;dr(n,e?{...c,themeMode:e}:c),l&&(ur(n,Qm(c)),l=!1)}function m(){p(),yt(Ye(Xm,{onError:a},Ye(Gm,{key:u,bus:t,hostElement:n,options:c,recentHostEvents:d})),r)}t.on(`handshake`,e=>{e.config&&(e.config.storageVersion&&i.rememberStorageVersion(e.config.storageVersion),s=e.config,f(),m())});let h=qn(t,{getOptions:()=>c,getVisitorId:()=>i.getVisitorId(),getConversationId:()=>i.loadConversationId()});function g(e={}){i.reset(),o={...o,userContext:void 0,userToken:void 0,...e},d.length=0,u+=1,l=!0,f(),m()}return{getOptions:()=>c,getUserOptions:()=>o,render:m,setUserOptions:e=>{o=e,f(),m()},patchUserOptions:e=>{let t=`userToken`in e&&e.userToken!==o.userToken;t&&o.userToken?g(e):(t&&(u+=1),o={...o,...e},f(),m())},reset:()=>g(),destroy:()=>h()}}function Qm(e){if(e.mode===`standalone`)return`standalone`;if(e.mode===`inline`)return`inline`;let t=Rn(e.widgetId,e.storage,e.aiAgentDeploymentId),{panelOpen:n,panelSize:r}=Rc(e,zc(),t.loadPanelOpen(),t.loadPanelSize());return Ic(e.mode,r,n)}const $m=C.scope(`hooks`),eh=`*`,th=/* @__PURE__ */ new Set;function nh(e,t,n){let r={widgetId:e,event:t,listener:n};return th.add(r),()=>{th.delete(r)}}function rh(e,t,n){let r=[...th];for(let i of r)if(ah(i.widgetId,e.widgetId)&&(i.event===`*`||i.event===t))try{i.listener(e,t,n)}catch(e){$m.warn(`hook listener threw`,{event:t,error:e})}}function ih(e,t){let n=[];for(let r of oh)n.push(t.on(r,t=>{rh(e,r,t)}));return()=>{for(let e of n)e()}}function ah(e,t){return e===`*`||e===t}const oh=/* @__PURE__ */ `open.close.expand.fullscreen.resize.message.send.stop.clear.selectConversation.suggestion.toggleHistory.formSubmit.toolResult.toolDecision.hostEvent.messageFeedback.contentView.contentOpen.contentSearch.contentRead.contentLinkClick.attach.removeAttachment.voiceStart.voiceStop.voiceCancel.localeChange.themeChange.textSizeChange.soundToggle.sidebarToggle.calloutDismiss.error.handshake.conversationRebound.state.unread`.split(`.`),sh=C.scope(`iframe`);function ch(e,t,n=`closed`,r=`floating`,i=null){sh.debug(`createIframeMount`,{position:t,initialMode:n,layoutMode:r,hasTarget:!!i});let a=document.createElement(`iframe`);a.title=`${u.name} chat`,a.setAttribute(`allow`,`microphone; clipboard-write`),dh(a,t,n,r),(r===`inline`&&i?i:document.body).appendChild(a);let o=a.contentDocument;if(!o)throw Error(`iframe contentDocument unavailable (cross-origin?)`);o.open(),o.write(`<!doctype html><html><head><meta charset="utf-8"><style>html,body{margin:0;padding:0;background:transparent;overflow:hidden}</style></head><body></body></html>`),o.close();let s=ir({...e,target:o.body}),c=new MutationObserver(()=>{dh(a,t,s.hostElement.dataset.mode??`closed`,r)});return c.observe(s.hostElement,{attributes:!0,attributeFilter:[`data-mode`]}),{...s,iframeElement:a,destroy(){c.disconnect(),s.destroy(),a.remove()}}}const lh=`border:0;background:transparent;z-index:2147483647;pointer-events:auto;`,uh={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 dh(e,t,n,r){if(n===`fullscreen`||r===`standalone`){e.style.cssText=`${lh}position:fixed;inset:0;width:100vw;height:100vh;`;return}if(r===`inline`){e.style.cssText=`${lh}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=`${lh}position:fixed;inset:0;width:100vw;height:100vh;`;return}let i=t.startsWith(`top-`)?`top`:`bottom`,a=t.endsWith(`-left`)?`left`:`right`,{w:o,h:s}=uh[n]??uh.open;e.style.cssText=`${lh}position:fixed;${i}:16px;${a}:16px;width:${o};height:${s};`}const fh=/* @__PURE__ */ new Map;function ph(e){if(!e.aiAgentDeploymentId)throw Error(`aiAgentDeploymentId is required`);e.debug!==void 0&&b(e.debug);let t=C.scope(`mount`);t.info(`mount`,{widgetId:e.widgetId,publicKey:e.publicKey,mode:e.presentation?.mode});let n=Zt(e),r=n.widgetId,i=fh.get(r);i&&(t.debug(`destroy existing instance at slot`,{widgetId:r}),i.destroy());let a=Qm(n),o=n.iframe?ch({position:rr(n.mode)},n.position,a,n.mode,e.target??null):ir({position:rr(n.mode),target:e.target??null});o.hostElement.dataset.widgetId=r;let s=new l,u=Rn(r,n.storage,n.aiAgentDeploymentId);function d(e){s.emit(`error`,e),f.getOptions().onError?.(e)}let f=Zm({bus:s,host:o.hostElement,appRoot:o.appRoot,persistence:u,initialRaw:e,reportError:d}),p=c,m=()=>{},h=new Promise(e=>{m=e});s.on(`state`,e=>{p=e,e.ready&&m()}),f.render();let g=o.hostElement,_=null;function v(e){e.debug!==void 0&&b(e.debug),f.patchUserOptions(e)}let y={widgetId:r,open:e=>ki(g,`open`,e),close:()=>ki(g,`close`),expand:()=>ki(g,`expand`),openForm:e=>ki(g,`openForm`,e),ask:(e,t)=>ki(g,`ask`,Ei(e,t)),on:(e,t)=>s.on(e,t),update:e=>{t.debug(`update`,{patch:e}),v(e)},setUserContext:e=>{t.debug(`setUserContext`,{keys:Object.keys(e)}),v({userContext:{...f.getUserOptions().userContext,...e}})},clearUserContext:()=>{t.debug(`clearUserContext`),v({userContext:void 0})},setPageContext:e=>{t.debug(`setPageContext`,{keys:Object.keys(e)}),v({pageContext:{...f.getUserOptions().pageContext,...e}})},clearPageContext:()=>{t.debug(`clearPageContext`),v({pageContext:void 0})},get state(){return p},ready:h,reset:()=>{t.info(`reset`,{widgetId:r}),f.reset()},login:e=>{t.info(`login`,{widgetId:r}),v({userToken:e})},track:(e,t)=>{let n=Nn(e,t);n&&s.emit(`hostEvent`,n)},registerTool:ve,setDebug:e=>{b(e),t.info(`debug level set`,{level:x()})},debugLevel:()=>x(),onLog:e=>w(e),destroy:()=>{t.info(`destroy`,{widgetId:r}),s.emit(`state`,c),_?.(),f.destroy(),s.clear(),yt(null,o.appRoot),o.destroy(),fh.get(r)===y&&fh.delete(r)}};return _=ih(y,s),fh.set(r,y),y}function mh(e){if(!e.aiAgentDeploymentId)throw Error(`aiAgentDeploymentId is required`);let t=e.widgetId??`default`,n=fh.get(t);return n?(n.update(e),n):ph(e)}function hh(e){if(e!==void 0){fh.get(e)?.destroy();return}let t=[...fh.values()];for(let e of t)e.destroy()}function gh(e=`default`){return fh.get(e)??null}function _h(){return[...fh.values()]}function vh(e,t,n){return nh(e,t,n)}const yh=Hn,bh=u,xh=/* @__PURE__ */ new WeakMap;let Sh=0;function Ch(e){if(typeof e!=`function`)return e;let t=xh.get(e)??++Sh;return xh.set(e,t),`function#${t}`}function wh(t){let r=n(t);r.current=t;let i=t.widgetId??`default`,a=JSON.stringify({...t,userToken:Ch(t.userToken)});return e(()=>()=>hh(i),[i]),e(()=>{mh({...r.current,userToken:r.current.userToken,onMessage:e=>r.current.onMessage?.(e),onOpen:()=>r.current.onOpen?.(),onClose:()=>r.current.onClose?.(),onError:e=>r.current.onError?.(e),tools:r.current.tools?.map(e=>Object.assign({},e,{execute:(t,n)=>(r.current.tools?.find(t=>t.name===e.name)??e).execute(t,n)}))})},[a]),null}function Th(e=`default`){return{state:r(t=>vh(e,`state`,t),()=>gh(e)?.state??c,()=>c),...t(()=>({ask:(t,n)=>gh(e)?.ask(t,n),open:t=>gh(e)?.open(t),close:()=>gh(e)?.close(),reset:()=>gh(e)?.reset(),track:(t,n)=>gh(e)?.track(t,n)}),[e])}}function Eh(t){let r=n(t);r.current=t;let i=JSON.stringify(t);e(()=>{let e=new AbortController;return ve({...r.current,execute:(e,t)=>r.current.execute(e,t)},{signal:e.signal}),()=>e.abort()},[i])}export{eh as HOOK_WILDCARD,wh as HelpAI,bh as brand,hh as destroy,_h as getAllInstances,gh as getInstance,vh as hook,mh as init,ph as mount,Qm as resolveInitialHostMode,Th as useHelpAI,Eh as useHelpAITool,yh as version};
62
62
  //# sourceMappingURL=react.mjs.map