@helpai/elements 6.14.0 → 6.15.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,12 +1,12 @@
1
1
  'use client';
2
2
  import{useEffect as e,useMemo as t,useRef as n,useSyncExternalStore as r}from"react";const i={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`},a=[`off`,`error`,`warn`,`info`,`debug`,`trace`],o=i.cssPrefix,s=`${o}.debug`,c=`__${i.global}_DEBUG__`,l=`${o}-debug`;let u=2,d=null;function f(){if(typeof window>`u`)return 2;try{let e=new URLSearchParams(window.location.search).get(l);if(e!==null){let t=p(e);if(t>=0)return t}}catch{}try{let e=window.localStorage?.getItem(s);if(e){let t=p(e);if(t>=0)return t}}catch{}return Reflect.get(window,c)?4:2}function p(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=a.findIndex(t=>t===e);if(t>=0)return t}return-1}function m(e){let t=p(e);if(!(t<0)){u=t;try{window.localStorage?.setItem(s,a[t]??`off`)}catch{}}}function h(){return a[u]??`warn`}u=f();function g(e){let t=`[${o}:${e}]`;function n(n,r,i){return(a,o)=>{if(!(u<n)&&(o===void 0?console[r](t,a):console[r](t,a,o),d))try{d({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=>g(`${e}:${t}`)}}const _=g(`core`);function v(e){d=e}function y(e){"@babel/helpers - typeof";return y=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},y(e)}function b(e,t){if(y(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(y(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function x(e){var t=b(e,`string`);return y(t)==`symbol`?t:t+``}function S(e,t,n){return(t=x(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const C=_.scope(`events`),w={open:!1,ready:!1,unread:0};var ee=class{constructor(){S(this,`handlers`,/* @__PURE__ */ new Map),S(this,`taps`,/* @__PURE__ */ new Set)}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)}tap(e){return this.taps.add(e),()=>this.taps.delete(e)}listensTo(e){return(this.handlers.get(e)?.size??0)>0||[...this.taps].some(t=>t.listensTo(e))}emit(e,t){for(let n of this.handlers.get(e)??[])try{n(t)}catch(t){C.warn(`listener threw`,{event:e,error:t})}for(let n of this.taps)n.hear(e,t)}clear(){this.handlers.clear(),this.taps.clear()}};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 te(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 ne(e){return e==null?``:typeof e==`string`?e:JSON.stringify(e)}function re(e,t){e instanceof HTMLInputElement&&e.type===`checkbox`?e.checked!==(t===!0||t===`true`)&&e.click():e instanceof HTMLInputElement&&e.type===`radio`?e.value===ne(t)&&!e.checked&&e.click():k(e,ne(t))}function ie(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]=te(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&&re(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 A(){return[...document.querySelectorAll(`form[toolname][tooldescription]`)].flatMap(e=>{let t=e.getAttribute(`toolname`)?.trim()??``,n=e.getAttribute(`tooldescription`)?.trim()??``;return t&&n?[ie(e,t,n)]:[]})}const ae=`${i.cssPrefix}.page-tools`;function j(e){return typeof e==`object`&&!!e}function oe(e){return j(e)&&(e.state===`running`||e.state===`stopped`||e.state===`finished`&&j(e.outcome))}function se(e){let t=e?JSON.parse(e):void 0;return j(t)?{sent:Array.isArray(t.sent)?t.sent.filter(e=>typeof e==`string`):[],calls:Object.fromEntries(Object.entries(j(t.calls)?t.calls:{}).filter(e=>oe(e[1])))}:{sent:[],calls:{}}}let ce={sent:[],calls:{}};function le(){try{ce=se(sessionStorage.getItem(ae))}catch{}return ce}function ue(e){ce=e;try{sessionStorage.setItem(ae,JSON.stringify(e))}catch{}}const M={markSent(e){let t=le();ue({...t,sent:[...t.sent.filter(t=>t!==e),e].slice(-20)})},sentHere(e){return le().sent.includes(e)},get(e){return le().calls[e]},set(e,t){let n=le(),r=Object.entries(n.calls).filter(([t])=>t!==e);ue({...n,calls:Object.fromEntries([...r,[e,t]].slice(-50))})},clear(e){let t=le();e.some(e=>e in t.calls)&&ue({...t,calls:Object.fromEntries(Object.entries(t.calls).filter(([t])=>!e.includes(t)))})}};function de(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 fe=_.scope(`page-tools`),pe=3e4,me=Symbol.for(`${i.cssPrefix}.page-tools`),he={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.`},ge=`The visitor stopped this before it finished.`;function N(e){return typeof e==`object`&&!!e}function _e(e){return N(e)&&Array.isArray(e.registered)&&e.runs instanceof Map}function ve(){let e=Reflect.get(globalThis,me);if(_e(e))return e;let t={registered:[],runs:/* @__PURE__ */ new Map};return Reflect.set(globalThis,me,t),t}function ye(e,t){let n=N(t)&&t.signal instanceof AbortSignal?t.signal:void 0;if(n?.aborted)return;let r=ve().registered;r.push(e);function i(){let t=r.indexOf(e);t>=0&&r.splice(t,1)}n?.addEventListener(`abort`,i,{once:!0})}function be(e){return e.replace(/[^A-Za-z0-9_-]/g,`_`).slice(0,58)}function xe(e){if(!N(e)||typeof e.name!=`string`||!be(e.name))return;let t=typeof e.title==`string`&&e.title.trim()!==``?e.title.trim().slice(0,120):void 0,n=[e.description,t].find(e=>typeof e==`string`&&e.trim()!==``)??e.name,r=e.preview;return{name:be(e.name),...t?{title:t}:{},...typeof r==`function`?{preview:t=>Reflect.apply(r,e,[t])}:{},description:n.trim().slice(0,1024),inputSchema:{properties:{},...N(e.inputSchema)?e.inputSchema:{},type:`object`},consequential:N(e.annotations)&&e.annotations.consequentialHint===!0}}function Se(e){return e.flatMap(e=>{let t=xe(e),n=N(e)?e.execute:void 0;return!t||typeof n!=`function`?(fe.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 Ce(){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,[])),de(1e3).then(()=>[])]).catch(()=>[]);return(Array.isArray(r)?r:[]).flatMap(t=>{let r=xe(t);return r?[{...r,run:(r,i)=>Reflect.apply(n,e,[t,r,{signal:i}])}]:[]})}async function we(e=[]){let t=Se(A()),n=new Set(t.map(e=>e.name)),r=[...(await Ce()).filter(e=>!n.has(e.name)),...t,...Se(e),...Se(ve().registered)];return new Map(r.map(e=>[e.name,e]))}function Te(e){return[...e.values()].map(({name:e,title:t,description:n,inputSchema:r,consequential:i})=>{let a={name:e,description:n,inputSchema:r};return t&&(a.title=t),i&&(a.annotations={consequentialHint:!0}),a})}function P(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>pe?{truncated:!0,preview:n.slice(0,pe)}:JSON.parse(n)}async function Oe(e){let t=(await we(e.optionTools)).get(Ee(e.toolName));if(!t?.preview)return;let n=t.preview;return Promise.resolve().then(()=>n(e.input)).catch(e=>{fe.warn(`a page tool preview failed`,{name:t.name,error:e})})}async function ke(e){let t=Ee(e.toolName),n=(await we(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=>(fe.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 Ae(e){let{toolCallId:t}=e,n=M.get(t);if(n?.state===`finished`)return Promise.resolve(n.outcome);let{runs:r}=ve(),i=r.get(t);if(i)return i.outcome;if(n?.state===`running`)return M.set(t,{state:`finished`,outcome:he}),e.onSettled(`interrupted`,0),Promise.resolve(he);let a=new AbortController,o=performance.now();M.set(t,{state:`running`});let s=ke({...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 je(e){return e===he.errorText||e===ge}function Me(e){return M.set(e,{state:`stopped`}),ve().runs.get(e)?.controller.abort(),ge}function Ne(e){M.clear([e]),ve().runs.get(e)?.controller.abort()}var F,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We=Symbol.for(`pv`),Ge={},Ke=[],qe=/^m(i|n|o|s|text|space)$/,Je=Array.isArray,Ye=Ke.slice,Xe=Object.assign;function I(e){e&&e.parentNode&&e.remove()}function Ze(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?Ye.call(arguments,2):n),Qe(e,o,r,i,null)}function Qe(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:We,__v:i||++Pe,__i:-1,__u:0};return!i&&F.vnode&&F.vnode(a),a}function L(e){return e.children}function $e(e,t){this.props=e,this.context=t,this.__g=0}function et(e,t){if(t==null)return e.__&&et(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:et(e)}function tt(e){var t,n=e.__v,r=n.__e,i=[],a=[],o=e.__P;o&&((t=Xe({constructor:We},n)).__v=n.__v+1,F.vnode&&F.vnode(t),pt(o,t,n,e.__n,o.namespaceURI,32&n.__u?[r]:null,i,r||et(n),32&n.__u,a),t.__v=n.__v,t.__.__k[t.__i]=t,gt(i,t,a),n.__=n.__e=null,t.__e!=r&&nt(t))}function nt(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),nt(e)}function rt(e){(8&e.__g||(e.__g|=8,Ie.push(e),Re++))&&Le==F.debounceRendering||((Le=F.debounceRendering)||queueMicrotask)(it)}function it(){try{for(var e,t=1;Ie.length;)Ie.length>t&&Ie.sort(ze),e=Ie.shift(),t=Ie.length,8&e.__g&&tt(e)}finally{(Re=Ie.length)&&(Le||queueMicrotask)(it)}}function at(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r.__k||Ke,v=t.length;for(c=ot(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=~p.__i&&_[p.__i]||Ge,p.__i=d,g=pt(e,p,f,i,a,o,s,c,l,u),m=p.__e,(f.ref!=p.ref||8&f.__u)&&(f.ref&&vt(f.ref,null,p,f),p.ref&&u.push(p.ref,p.__c||m,p)),h=h||m,4&p.__u?(c=st(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 ot(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]=Qe(null,o):Je(o)?o=v[a]=Qe(L,{children:o}):o.constructor===We&&o.__b?o=v[a]=Qe(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=lt(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=et(s)),yt(s,s));return r}function st(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=st(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=et(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 ct(e,t){return t=t||[],e!=null&&typeof e!=`boolean`&&(Je(e)?e.some(function(e){ct(e,t)}):t.push(e)),t}function lt(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 ut(e,t,n){n??(n=``),t[0]==`-`?e.setProperty(t,n):e[t]=n}function dt(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||ut(e.style,t);if(n)for(t in n)r&&n[t]==r[t]||ut(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)typeof n!=`function`&&(n=null),typeof r!=`function`&&(r=null),(e.__e||(e.__e={}))[t]=n,n&&r||(o=Ue[t]||(Ue[t]=ft(t)),(e.__a||(e.__a={}))[t]=He,a=t!=(t=t.replace(Ve,`$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 ft(e){return function(t){var n=this.__e;if(n){if(n=n[e],t[Be]==null)t[Be]=He++;else if(t[Be]<this.__a[e])return;return n(F.event?F.event(t):t)}}}function pt(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,ee,T,E,D=t.type;if(t.constructor!==We)return null;128&n.__u&&(c=32&n.__u,u=n.__c.__z)&&(t.__u|=c,d=a=[],u.nodeType==8?s=mt(u,a):a.push(u),s=a[0]||s),(u=F.__b)&&u(t);n:if(typeof D==`function`){f=o.length;try{if(_=t.props,v=(u=D.prototype)&&u.render,y=(u=D.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 D(_,b):(t.__c=p=new $e(_,b),p.constructor=D,p.render=bt),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),D.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=Xe({},p.__s)),Xe(p.__s,D.getDerivedStateFromProps(_,p.__s)))),m=p.props,h=p.state,p.__v=t,n.__c){if(_!==m&&v&&!D.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)}),Ke.push.apply(p.__h,p.__k),p.__k=[],p.__h.length&&o.push(p),s=et(n);break n}p.componentWillUpdate&&p.componentWillUpdate(_,p.__s,b),v&&p.componentDidUpdate&&p.__h.push(function(){p.componentDidUpdate(m,h,g)})}else v&&!D.getDerivedStateFromProps&&p.componentWillMount&&p.componentWillMount(),v&&p.componentDidMount&&p.__h.push(p.componentDidMount);p.context=b,p.props=_,p.__P=e,p.__g&=-5,x=F.__r,S=v?25:0;do p.__g&=-9,x&&x(t),u=p.render(p.props,p.state=p.__s,p.context);while(8&p.__g&&++S<25);v&&(Ke.push.apply(p.__h,p.__k),p.__k=[]),p.state=p.__s,p.getChildContext&&(r=Xe({},r,p.getChildContext())),v&&n.__c&&p.getSnapshotBeforeUpdate&&(g=p.getSnapshotBeforeUpdate(m,h)),C=u&&u.type===L&&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&&yt(e,e)}),n.__k=null),s=n.__k?et(n,0):null),s=at(e,Je(C)?C:[C],t,n,r,i,a,o,s,c,l),_.__P&&(t.__e=null,s=u),t.__u&=-161,d&&d.some(I),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&&e.then){if(t.__u|=128|c,a){for(~(T=a.indexOf(s||void 0))||(T=a.length);(E=a[T-1])&&E.nodeType==8;)T--;for(;T<a.length;T++)if(E=a[T]){if(a[T]=null,w){if(E==ee)break}else{if(E.nodeType!=8)break;E.data.startsWith(`$s`)&&(ee=mt(w=E))}}}if(!w){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;w=s}(u=mt(w=t.__c.__z||(t.__c.__z=w)))?(t.__e=w,s=u):t.__e=s,s=s&&s.nextSibling}else a&&a.some(I)}else t.__e=n.__e;t.__k||(t.__k=n.__k||[]),e&&e.then||ht(t),F.__e(e,t,n)}}else s=t.__e=_t(n.__e,t,n,r,i,a,o,c,l,e);return(u=F.diffed)&&u(t),s}function mt(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 ht(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(ht))}function gt(e,t,n){for(var r=0;r<n.length;)vt(n[r++],n[r++],n[r++]);F.__c&&F.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){F.__e(e,t.__v)}})}function _t(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v=n.props||Ge,y=t.props,b=t.type;if(b==`svg`?i=`http://www.w3.org/2000/svg`:b==`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])&&(b?m.localName==b:m.nodeType==3)){e=m,a[u]=null;break}}if(!e){if(_=l.ownerDocument||document,!b)return _.createTextNode(y);e=_.createElementNS(i,b,y.is?y:l),s&&(F.__m&&F.__m(t,a),s=!1),a=null}if(b){if(l=b==`template`&&e.content||e,a=b==`textarea`&&y.defaultValue!=null?null:a&&Ye.call(l.childNodes),!s&&a)for(v={},u=0;u<e.attributes.length;u++)v[(m=e.attributes[u]).name]=m.value;for(u in v)m=v[u],u==`dangerouslySetInnerHTML`?f=m:u==`children`||u in y||u==`value`&&`defaultValue`in y||u==`checked`&&`defaultChecked`in y||dt(e,u,null,m,i);for(u in y)m=y[u],u==`children`?p=m:u==`dangerouslySetInnerHTML`?d=m:u==`value`?h=m:u==`checked`?g=m:s&&typeof m!=`function`||v[u]===m||dt(e,u,m,v[u],i);d?(s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[]):(f&&(e.textContent=``),(b==`foreignObject`||i==`http://www.w3.org/1998/Math/MathML`&&qe.test(b))&&(i=`http://www.w3.org/1999/xhtml`),at(l,Je(p)?p:[p],t,n,r,i,a,o,a?a[0]:n.__k&&et(n,0),s,c),a&&a.some(I)),s&&b!=`textarea`||(u=`value`,b==`progress`&&h==null?e.removeAttribute(u):h==null||h===e[u]&&(b!=`progress`||h)||dt(e,u,h,v[u],i),u=`checked`,g!=null&&g!=e[u]&&dt(e,u,g,v[u],i))}else v===y||s&&e.data==y||(e.data=y);return e}function vt(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){F.__e(e,n)}}function yt(e,t,n){var r,i,a,o;if(F.unmount&&F.unmount(e),!(r=e.ref)||r.current&&r.current!=e.__e||vt(r,null,t,e),r=e.__c){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){F.__e(e,t)}r.__P=r.__n=null}if(r=e.__k)for(o=0;o<r.length;o++)r[o]&&yt(r[o],t,typeof e.type!=`function`||n&&!e.props.__P);!n&&(r=e.__c)&&(r=r.__z)&&(i=mt(r,a=[]))&&(r==e.__e&&a.some(I),I(i),I(r)),n||I(e.__e),e.__e=e.__c=e.__=null}function bt(e,t,n){return this.constructor(e,n)}function xt(e,t){var n,r,i,a;F.__&&F.__(e,t),t.nodeType==9&&(t=t.documentElement),r=(n=e&&32&e.__u)?null:t.__k,t.__k=Qe(L,{children:[e]}),i=[],a=[],pt(t,t.__k,r||Ge,Ge,t.namespaceURI,r?null:t.firstChild?Ye.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a),gt(i,t.__k,a),t.__k.props.children=null}F={__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 Re=0,e}},Pe=0,Fe=function(e){return e!=null&&e.constructor===We},$e.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=Xe({},this.state)),typeof e==`function`&&(e=e(Xe({},n),this.props)),e&&(Xe(n,e),this.__v&&(t&&this.__k.push(t),rt(this)))},$e.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),rt(this))},$e.prototype.render=L,Ie=[],Re=0,ze=function(e,t){return e.__v.__b-t.__v.__b},Be=Symbol(),Ve=/(PointerCapture)$|Capture$/i,He=0,Ue={};const St=[`en`,`fr`,`es`,`ar`,`he`,`zh`];function Ct(e){let t=e?.split(`-`)[0]?.toLowerCase();return St.find(e=>e===t)??`en`}function wt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Tt(e){return wt(e)?e.id??e.key:void 0}function Et(e,t){return wt(e)&&wt(t)?Object.fromEntries([.../* @__PURE__ */ new Set([...Object.keys(e),...Object.keys(t)])].map(n=>[n,Et(e[n],t[n])])):Array.isArray(e)&&Array.isArray(t)&&t.length>0&&t.every(e=>Tt(e)!==void 0)?e.map(e=>Et(e,t.find(t=>Tt(t)===Tt(e)))):t==null||typeof t==`string`&&!t.trim()?e:t}function Dt(e,t){let n=t?.toLowerCase(),r=n?.split(`-`)[0],i=e.translations??[],a=i.find(e=>e.locale.toLowerCase()===n)??i.find(e=>e.locale.toLowerCase().split(`-`)[0]===r);if(!a)return e;let{locale:o,...s}=a;return Et(e,s)}const Ot={attach:`Attach files`,file:`File`,attachmentMimeRejected:`{name} isn't a file type this chat accepts.`,attachmentTooLarge:`{name} is too large. Files can be up to {max} together.`,poweredBy:`Powered by {name}`,attachmentTooMany:`The attachment limit is {count}.`,attachmentUploadFailed:`{name} couldn't be uploaded.`,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`,dropZoneRejected:`These files can't be attached here`,errorGeneric:`Something went wrong`,errorRateLimited:`Too many requests — please try again in a moment.`,errorRateLimitedIn:`Too many requests — please try again in {seconds} s.`,errorOffline:`Can't reach the server. Check your connection and try again.`,errorServer:`Something went wrong on our side. Please try again.`,errorOriginNotAllowed:`This chat isn't set up for this website yet.`,errorMessageTooLong:`That message is too long. Shorten it and send it again.`,errorReconnecting:`Connection lost. Reconnecting…`,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`,launcherAsk:`Ask {name}`,micBlocked:`The microphone is blocked for this site, so voice input can't start.`,micStart:`Start voice input`,micStop:`Stop voice input`,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`,removeAttachment:`Remove {name}`,suggestedReplies:`Suggested replies`,compactingContext:`Optimizing conversation context…`,soundOff:`Sound off`,soundOn:`Sound on`,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}`,operatorBadgeTitle:`Live chat`,chatNotice:`You're chatting with an AI assistant.`,cancelOperatorRequest:`Keep chatting with the AI`,loginPrompt:`Log in for faster, more personalized support`,loginAction:`Log in`,loginRequired:`Log in to chat with us`,loginExpired:`Your login expired. Log in to continue this chat.`,loginExpiredGuest:`Your login expired. Log in to continue this chat, or start a new conversation as a guest.`,startAsGuest:`Start new conversation`,loggedInAs:`Logged in as {name}`,loggedIn:`Logged in`,dismissLoginPrompt:`Hide`,emailTranscript:`Email transcript`,emailTranscriptPrompt:`Get a copy of this conversation by email.`,emailTranscriptEmailLabel:`Email address`,emailTranscriptSend:`Send transcript`,emailTranscriptSending:`Sending…`,emailTranscriptSent:`Sent to {email}.`,emailTranscriptAlreadySent:`This conversation was already emailed. Send a new message to email it again.`,emailTranscriptLimited:`You've reached the limit for now. Try again later.`,emailTranscriptFailed:`Couldn't send it. Try again.`,emailTranscriptNotDelivered:`Couldn't send to this address. Check it and try again.`,emailTranscriptCancel:`Cancel`,emailTranscriptDone:`Done`,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.`,visualSoldOut:`Sold out`,visualCartEmpty:`Your cart is empty.`,visualQuantity:`Qty`,visualChoose:`Choose`,visualDirect:`Direct`,visualVia:`via`,visualNight:`1 night`,visualNights:`{count} nights`,visualPerNight:`per night`,visualTravellers:`Travellers`,thinking:`Thinking…`,thought:`Thought`,thoughtFor:`Thought for {time}`,toolResult:`Result`,sources:`Sources`,feedbackUp:`Good response`,feedbackDown:`Bad response`,feedbackThanks:`Thanks for your feedback`,copy:`Copy`,copied:`Copied`,copyTicketReference:`Ticket {reference}, copy`,tabHome:`Home`,tabConversations:`Chats`,tabHelp:`Help`,tabNews:`News`,modulesEmpty:`Nothing here yet`,chatUnavailable:`This chat isn't available right now`,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…`,newsShowMore:`Show more`,newsUnseen:`New post`,unread:`Unread`,formRequired:`This field is required`,formInvalidEmail:`Enter a valid email address`,formInvalidTel:`Enter a valid phone number`,formInvalidNumber:`Enter a valid number`,formOtherPlaceholder:`Type your answer…`,inputRequired:`Questions for you`,askFallbackQuestion:`Please provide the missing information.`,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`,decline:`Decline`,changeAnswer:`Change answer`,approvalPrompt:`{action}?`,approvalEditHint:`You can change your answer until this step continues.`,stepInput:`Input`,stepWorking:`Working`,stepWorkingOnIt:`Working on it…`,stepNeedsYourApproval:`Needs your approval`,stepWaitingForVisitor:`Waiting for the visitor`,stepApproved:`Approved`,stepDeclined:`Declined`,stepReplaced:`Replaced`,stepFailed:`Failed`,stepDidNotWork:`Didn't work`,decidedYouApproved:`You approved`,decidedYouDeclined:`You declined`,decidedVisitorApproved:`Visitor approved`,decidedVisitorDeclined:`Visitor declined`,decidedTeamApproved:`Approved by a team member`,decidedTeamDeclined:`Declined by a team member`,decidedMemberApproved:`Approved by {name}`,decidedMemberDeclined:`Declined by {name}`,stepRawData:`Raw data`,decidedRulesApproved:`Auto-approved`,decidedRulesDeclined:`Auto-declined`,edit:`Edit`,toolStepsFailed:`{count} failed`,statusStopped:`Stopped`,toolStepsStopped:`Stopped after {count} steps`,toolStepsStoppedOne:`Stopped after 1 step`},kt={en:Ot,fr:{attach:`Joindre des fichiers`,file:`Fichier`,attachmentMimeRejected:`{name} n'est pas un type de fichier accepté ici.`,attachmentTooLarge:`{name} est trop volumineux. Les fichiers peuvent faire jusqu'à {max} au total.`,poweredBy:`Propulsé par {name}`,attachmentTooMany:`Limite de pièces jointes : {count}.`,attachmentUploadFailed:`{name} n'a pas pu être envoyé.`,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`,dropZoneRejected:`Ces fichiers ne peuvent pas être joints ici`,errorGeneric:`Une erreur s'est produite`,errorRateLimited:`Trop de requêtes — veuillez réessayer dans un instant.`,errorRateLimitedIn:`Trop de requêtes — veuillez réessayer dans {seconds} s.`,errorOffline:`Impossible de joindre le serveur. Vérifiez votre connexion et réessayez.`,errorServer:`Un problème est survenu de notre côté. Veuillez réessayer.`,errorOriginNotAllowed:`Ce chat n'est pas encore configuré pour ce site.`,errorMessageTooLong:`Ce message est trop long. Raccourcissez-le et renvoyez-le.`,errorReconnecting:`Connexion perdue. Reconnexion…`,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`,launcherAsk:`Demander à {name}`,micBlocked:`Le micro est bloqué pour ce site : la saisie vocale ne peut pas démarrer.`,micStart:`Démarrer la saisie vocale`,micStop:`Arrêter la saisie vocale`,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`,removeAttachment:`Retirer {name}`,suggestedReplies:`Réponses suggérées`,compactingContext:`Optimisation du contexte de la conversation…`,soundOff:`Son désactivé`,soundOn:`Son activé`,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}`,operatorBadgeTitle:`Chat en direct`,chatNotice:`Vous discutez avec un assistant IA.`,cancelOperatorRequest:`Continuer avec l'IA`,loginPrompt:`Connectez-vous pour une aide plus rapide et personnalisée`,loginAction:`Se connecter`,loginRequired:`Connectez-vous pour discuter avec nous`,loginExpired:`Votre connexion a expiré. Connectez-vous pour poursuivre cette conversation.`,loginExpiredGuest:`Votre connexion a expiré. Connectez-vous pour poursuivre cette conversation, ou démarrez-en une nouvelle en tant qu'invité.`,startAsGuest:`Démarrer une nouvelle conversation`,loggedInAs:`Connecté en tant que {name}`,loggedIn:`Connecté`,dismissLoginPrompt:`Masquer`,emailTranscript:`Envoyer la transcription`,emailTranscriptPrompt:`Recevez une copie de cette conversation par e-mail.`,emailTranscriptEmailLabel:`Adresse e-mail`,emailTranscriptSend:`Envoyer la transcription`,emailTranscriptSending:`Envoi…`,emailTranscriptSent:`Envoyé à {email}.`,emailTranscriptAlreadySent:`Cette conversation a déjà été envoyée. Envoyez un nouveau message pour l'envoyer à nouveau.`,emailTranscriptLimited:`Vous avez atteint la limite pour le moment. Réessayez plus tard.`,emailTranscriptFailed:`Envoi impossible. Réessayez.`,emailTranscriptNotDelivered:`Envoi impossible à cette adresse. Vérifiez-la et réessayez.`,emailTranscriptCancel:`Annuler`,emailTranscriptDone:`Terminé`,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.`,visualSoldOut:`Épuisé`,visualCartEmpty:`Votre panier est vide.`,visualQuantity:`Qté`,visualChoose:`Choisissez`,visualDirect:`Direct`,visualVia:`via`,visualNight:`1 nuit`,visualNights:`{count} nuits`,visualPerNight:`par nuit`,visualTravellers:`Voyageurs`,thinking:`Réflexion…`,thought:`Réflexion`,thoughtFor:`Réflexion : {time}`,toolResult:`Résultat`,sources:`Sources`,feedbackUp:`Bonne réponse`,feedbackDown:`Mauvaise réponse`,feedbackThanks:`Merci pour votre retour`,copy:`Copier`,copied:`Copié`,copyTicketReference:`Ticket {reference}, copier`,tabHome:`Accueil`,tabConversations:`Chats`,tabHelp:`Aide`,tabNews:`Actualités`,modulesEmpty:`Rien pour le moment`,chatUnavailable:`Ce chat n'est pas disponible 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…`,newsShowMore:`Afficher plus`,newsUnseen:`Nouvelle publication`,unread:`Non lu`,formRequired:`Ce champ est obligatoire`,formInvalidEmail:`Saisissez une adresse e-mail valide`,formInvalidTel:`Saisissez un numéro de téléphone valide`,formInvalidNumber:`Saisissez un nombre valide`,formOtherPlaceholder:`Saisissez votre réponse…`,inputRequired:`Questions pour vous`,askFallbackQuestion:`Veuillez fournir les informations manquantes.`,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`,decline:`Refuser`,changeAnswer:`Modifier la réponse`,approvalPrompt:`{action} ?`,approvalEditHint:`Vous pouvez modifier votre réponse jusqu'à la reprise de cette étape.`,stepInput:`Entrée`,stepWorking:`En cours`,stepWorkingOnIt:`En cours…`,stepNeedsYourApproval:`Votre accord est requis`,stepWaitingForVisitor:`En attente du visiteur`,stepApproved:`Approuvé`,stepDeclined:`Refusé`,stepReplaced:`Remplacé`,stepFailed:`Échec`,stepDidNotWork:`N'a pas fonctionné`,decidedYouApproved:`Vous avez approuvé`,decidedYouDeclined:`Vous avez refusé`,decidedVisitorApproved:`Approuvé par le visiteur`,decidedVisitorDeclined:`Refusé par le visiteur`,decidedTeamApproved:`Approuvé par un membre de l'équipe`,decidedTeamDeclined:`Refusé par un membre de l'équipe`,decidedMemberApproved:`Approuvé par {name}`,decidedMemberDeclined:`Refusé par {name}`,stepRawData:`Données brutes`,decidedRulesApproved:`Approuvé automatiquement`,decidedRulesDeclined:`Refusé automatiquement`,edit:`Modifier`,toolStepsFailed:`{count} en échec`,statusStopped:`Arrêté`,toolStepsStopped:`Arrêté après {count} étapes`,toolStepsStoppedOne:`Arrêté après 1 étape`},es:{attach:`Adjuntar archivos`,file:`Archivo`,attachmentMimeRejected:`{name} no es un tipo de archivo que acepte este chat.`,attachmentTooLarge:`{name} es demasiado grande. Los archivos pueden ocupar hasta {max} en total.`,poweredBy:`Con la tecnología de {name}`,attachmentTooMany:`Límite de adjuntos: {count}.`,attachmentUploadFailed:`No se pudo subir {name}.`,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`,dropZoneRejected:`Estos archivos no se pueden adjuntar aquí`,errorGeneric:`Algo salió mal`,errorRateLimited:`Demasiadas solicitudes: inténtalo de nuevo en un momento.`,errorRateLimitedIn:`Demasiadas solicitudes: inténtalo de nuevo en {seconds} s.`,errorOffline:`No se puede conectar con el servidor. Revisa tu conexión e inténtalo de nuevo.`,errorServer:`Algo salió mal por nuestra parte. Inténtalo de nuevo.`,errorOriginNotAllowed:`Este chat aún no está configurado para este sitio web.`,errorMessageTooLong:`Ese mensaje es demasiado largo. Acórtalo y envíalo de nuevo.`,errorReconnecting:`Se perdió la conexión. Reconectando…`,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`,launcherAsk:`Pregúntale a {name}`,micBlocked:`El micrófono está bloqueado para este sitio, así que la entrada de voz no puede iniciarse.`,micStart:`Iniciar entrada de voz`,micStop:`Detener 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`,removeAttachment:`Quitar {name}`,suggestedReplies:`Respuestas sugeridas`,compactingContext:`Optimizando el contexto de la conversación…`,soundOff:`Sonido desactivado`,soundOn:`Sonido activado`,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}`,operatorBadgeTitle:`Chat en vivo`,chatNotice:`Estás chateando con un asistente de IA.`,cancelOperatorRequest:`Seguir con la IA`,loginPrompt:`Inicia sesión para recibir una ayuda más rápida y personalizada`,loginAction:`Iniciar sesión`,loginRequired:`Inicia sesión para chatear con nosotros`,loginExpired:`Tu sesión ha caducado. Inicia sesión para continuar esta conversación.`,loginExpiredGuest:`Tu sesión ha caducado. Inicia sesión para continuar esta conversación o empieza una nueva como invitado.`,startAsGuest:`Empezar una nueva conversación`,loggedInAs:`Sesión iniciada como {name}`,loggedIn:`Sesión iniciada`,dismissLoginPrompt:`Ocultar`,emailTranscript:`Enviar transcripción`,emailTranscriptPrompt:`Recibe una copia de esta conversación por correo.`,emailTranscriptEmailLabel:`Correo electrónico`,emailTranscriptSend:`Enviar transcripción`,emailTranscriptSending:`Enviando…`,emailTranscriptSent:`Enviado a {email}.`,emailTranscriptAlreadySent:`Esta conversación ya se envió. Envía un mensaje nuevo para enviarla otra vez.`,emailTranscriptLimited:`Has alcanzado el límite por ahora. Inténtalo más tarde.`,emailTranscriptFailed:`No se pudo enviar. Inténtalo de nuevo.`,emailTranscriptNotDelivered:`No se pudo enviar a esta dirección. Revísala e inténtalo de nuevo.`,emailTranscriptCancel:`Cancelar`,emailTranscriptDone:`Listo`,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.`,visualSoldOut:`Agotado`,visualCartEmpty:`Tu carrito está vacío.`,visualQuantity:`Cant.`,visualChoose:`Elige`,visualDirect:`Directo`,visualVia:`vía`,visualNight:`1 noche`,visualNights:`{count} noches`,visualPerNight:`por noche`,visualTravellers:`Viajeros`,thinking:`Pensando…`,thought:`Razonamiento`,thoughtFor:`Razonó durante {time}`,toolResult:`Resultado`,sources:`Fuentes`,feedbackUp:`Buena respuesta`,feedbackDown:`Mala respuesta`,feedbackThanks:`Gracias por tu opinión`,copy:`Copiar`,copied:`Copiado`,copyTicketReference:`Ticket {reference}, copiar`,tabHome:`Inicio`,tabConversations:`Chats`,tabHelp:`Ayuda`,tabNews:`Novedades`,modulesEmpty:`Aún no hay nada aquí`,chatUnavailable:`Este chat no está disponible en este momento`,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…`,newsShowMore:`Mostrar más`,newsUnseen:`Publicación nueva`,unread:`No leído`,formRequired:`Este campo es obligatorio`,formInvalidEmail:`Introduce un correo electrónico válido`,formInvalidTel:`Introduce un número de teléfono válido`,formInvalidNumber:`Introduce un número válido`,formOtherPlaceholder:`Escribe tu respuesta…`,inputRequired:`Preguntas para ti`,askFallbackQuestion:`Indica la información que falta.`,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`,decline:`Rechazar`,changeAnswer:`Cambiar respuesta`,approvalPrompt:`¿{action}?`,approvalEditHint:`Puedes cambiar tu respuesta hasta que este paso continúe.`,stepInput:`Entrada`,stepWorking:`En curso`,stepWorkingOnIt:`En curso…`,stepNeedsYourApproval:`Necesita tu aprobación`,stepWaitingForVisitor:`Esperando al visitante`,stepApproved:`Aprobado`,stepDeclined:`Rechazado`,stepReplaced:`Reemplazado`,stepFailed:`Falló`,stepDidNotWork:`No funcionó`,decidedYouApproved:`Lo aprobaste`,decidedYouDeclined:`Lo rechazaste`,decidedVisitorApproved:`El visitante aprobó`,decidedVisitorDeclined:`El visitante rechazó`,decidedTeamApproved:`Aprobado por un miembro del equipo`,decidedTeamDeclined:`Rechazado por un miembro del equipo`,decidedMemberApproved:`Aprobado por {name}`,decidedMemberDeclined:`Rechazado por {name}`,stepRawData:`Datos sin procesar`,decidedRulesApproved:`Aprobado automáticamente`,decidedRulesDeclined:`Rechazado automáticamente`,edit:`Editar`,toolStepsFailed:`{count} con error`,statusStopped:`Detenido`,toolStepsStopped:`Detenido tras {count} pasos`,toolStepsStoppedOne:`Detenido tras 1 paso`},ar:{attach:`إرفاق ملفات`,file:`ملف`,attachmentMimeRejected:`نوع الملف {name} غير مقبول في هذه المحادثة.`,attachmentTooLarge:`الملف {name} كبير جدًا. يمكن أن يصل حجم الملفات معًا إلى {max}.`,poweredBy:`مدعوم من {name}`,attachmentTooMany:`الحد الأقصى للمرفقات: {count}.`,attachmentUploadFailed:`تعذّر رفع {name}.`,conversationLoading:`جارٍ تحميل الدردشة…`,loadPreviousMessages:`تحميل الرسائل السابقة`,close:`إغلاق`,collapse:`طيّ`,collapseSidebar:`طيّ الشريط الجانبي`,composerPlaceholder:`اكتب رسالة…`,dateLastWeek:`آخر ٧ أيام`,dateOlder:`أقدم`,dateToday:`اليوم`,dateYesterday:`أمس`,dropZone:`أفلت الملفات لإرفاقها`,dropZoneRejected:`لا يمكن إرفاق هذه الملفات هنا`,errorGeneric:`حدث خطأ ما`,errorRateLimited:`طلبات كثيرة جدًا — يرجى المحاولة بعد لحظة.`,errorRateLimitedIn:`طلبات كثيرة جدًا — يرجى المحاولة بعد {seconds} ث.`,errorOffline:`تعذّر الوصول إلى الخادم. تحقّق من اتصالك وحاول مرة أخرى.`,errorServer:`حدث خطأ من جهتنا. يرجى المحاولة مرة أخرى.`,errorOriginNotAllowed:`هذه المحادثة غير مُعدّة لهذا الموقع بعد.`,errorMessageTooLong:`هذه الرسالة طويلة جدًا. اختصرها وأرسلها مرة أخرى.`,errorReconnecting:`انقطع الاتصال. جارٍ إعادة الاتصال…`,errorRetry:`إعادة المحاولة`,expand:`توسيع`,expandSidebar:`توسيع الشريط الجانبي`,exitFullscreen:`إنهاء ملء الشاشة`,fullscreen:`ملء الشاشة`,history:`السجل`,historyBack:`العودة إلى الدردشة`,historyEmpty:`لا توجد دردشات سابقة بعد`,historyContinue:`متابعة الدردشة`,historyLoading:`جارٍ تحميل دردشاتك…`,historyTitle:`سجل الدردشات`,loadMoreConversations:`تحميل المزيد من المحادثات`,language:`اللغة`,launcherOpen:`فتح الدردشة`,launcherAsk:`اسأل {name}`,micBlocked:`الميكروفون محظور لهذا الموقع، لذا لا يمكن بدء الإدخال الصوتي.`,micStart:`بدء الإدخال الصوتي`,micStop:`إيقاف الإدخال الصوتي`,moreActions:`إجراءات إضافية`,newConversation:`دردشة جديدة`,panelTitle:`الدردشة`,popOut:`فتح في علامة تبويب جديدة`,resizeHandle:`اسحب لتغيير الحجم`,scrollToBottom:`الانتقال إلى الأحدث`,send:`إرسال`,queueMessage:`إضافة الرسالة إلى قائمة الانتظار`,removeQueuedMessage:`إزالة الرسالة من قائمة الانتظار`,removeAttachment:`إزالة {name}`,suggestedReplies:`ردود مقترحة`,compactingContext:`جارٍ تحسين سياق المحادثة…`,soundOff:`كتم الصوت`,soundOn:`تشغيل الصوت`,talkToOperator:`التحدث إلى شخص`,connectingOperator:`جارٍ توصيلك بشخص…`,noOperatorAvailable:`لا يوجد موظفون متاحون الآن — اترك بياناتك وسنتواصل معك.`,chattingWithOperator:`أنت تتحدث مع {operator}`,operatorBadgeTitle:`محادثة مباشرة`,chatNotice:`أنت تتحدث مع مساعد ذكاء اصطناعي.`,cancelOperatorRequest:`متابعة المحادثة مع الذكاء الاصطناعي`,loginPrompt:`سجّل الدخول للحصول على دعم أسرع ومخصّص لك`,loginAction:`تسجيل الدخول`,loginRequired:`سجّل الدخول للدردشة معنا`,loginExpired:`انتهت صلاحية تسجيل دخولك. سجّل الدخول لمتابعة هذه المحادثة.`,loginExpiredGuest:`انتهت صلاحية تسجيل دخولك. سجّل الدخول لمتابعة هذه المحادثة، أو ابدأ محادثة جديدة كضيف.`,startAsGuest:`بدء محادثة جديدة`,loggedInAs:`تم تسجيل الدخول باسم {name}`,loggedIn:`تم تسجيل الدخول`,dismissLoginPrompt:`إخفاء`,emailTranscript:`إرسال نص المحادثة`,emailTranscriptPrompt:`احصل على نسخة من هذه المحادثة عبر البريد الإلكتروني.`,emailTranscriptEmailLabel:`عنوان البريد الإلكتروني`,emailTranscriptSend:`إرسال نص المحادثة`,emailTranscriptSending:`جارٍ الإرسال…`,emailTranscriptSent:`تم الإرسال إلى {email}.`,emailTranscriptAlreadySent:`تم إرسال هذه المحادثة بالفعل. أرسل رسالة جديدة لإرسالها مرة أخرى.`,emailTranscriptLimited:`لقد بلغت الحد المسموح به حاليًا. حاول مرة أخرى لاحقًا.`,emailTranscriptFailed:`تعذّر الإرسال. حاول مرة أخرى.`,emailTranscriptNotDelivered:`تعذّر الإرسال إلى هذا العنوان. تحقّق منه وحاول مرة أخرى.`,emailTranscriptCancel:`إلغاء`,emailTranscriptDone:`تم`,stop:`إيقاف`,theme:`المظهر`,themeAuto:`تلقائي`,themeDark:`داكن`,themeLight:`فاتح`,textSize:`حجم النص`,textSizeSmall:`صغير`,textSizeNormal:`عادي`,textSizeLarge:`كبير`,loading:`جارٍ التحميل…`,visualPreparing:`جارٍ إعداد المحتوى المرئي…`,visualError:`تعذر عرض هذا المحتوى المرئي.`,visualPartial:`تعذر عرض بعض أجزاء هذا المحتوى المرئي.`,visualSoldOut:`نفدت الكمية`,visualCartEmpty:`سلتك فارغة.`,visualQuantity:`الكمية`,visualChoose:`اختر`,visualDirect:`مباشر`,visualVia:`عبر`,visualNight:`ليلة واحدة`,visualNights:`الليالي: {count}`,visualPerNight:`لليلة`,visualTravellers:`المسافرون`,thinking:`يفكّر…`,thought:`تفكير`,thoughtFor:`فكّر لمدة {time}`,toolResult:`النتيجة`,sources:`المصادر`,feedbackUp:`رد جيد`,feedbackDown:`رد سيئ`,feedbackThanks:`شكرًا على ملاحظاتك`,copy:`نسخ`,copied:`تم النسخ`,copyTicketReference:`التذكرة {reference}، نسخ`,tabHome:`الرئيسية`,tabConversations:`الدردشات`,tabHelp:`المساعدة`,tabNews:`الأخبار`,modulesEmpty:`لا شيء هنا بعد`,chatUnavailable:`هذه المحادثة غير متاحة حالياً`,moduleBack:`رجوع`,contentLoading:`جارٍ التحميل…`,contentHelpful:`هل كان هذا مفيدًا؟`,homeGreeting:`كيف يمكننا مساعدتك؟`,homeGreetingNamed:`مرحبًا {name} 👋`,homeGreetingLead:`كيف يمكننا مساعدتك؟`,homeSearchPlaceholder:`ابحث عن مساعدة`,homeAskPlaceholder:`اطرح سؤالاً…`,homeWhatsNew:`ما الجديد`,homeContentTitle:`مقالات شائعة`,homeStatus:`الحالة`,helpTitle:`المساعدة`,helpSearchPlaceholder:`ابحث عن مساعدة`,helpEmpty:`لا توجد مقالات مساعدة بعد`,helpLoading:`جارٍ تحميل المساعدة…`,helpSearchEmpty:`لا نتائج لـ «{query}»`,helpShowMore:`عرض المزيد`,newsTitle:`الأخبار`,newsEmpty:`لا توجد أخبار بعد`,newsLoading:`جارٍ تحميل الأخبار…`,newsShowMore:`عرض المزيد`,newsUnseen:`منشور جديد`,unread:`غير مقروء`,formRequired:`هذا الحقل مطلوب`,formInvalidEmail:`أدخل بريدًا إلكترونيًا صحيحًا`,formInvalidTel:`أدخل رقم هاتف صحيحًا`,formInvalidNumber:`أدخل رقمًا صحيحًا`,formOtherPlaceholder:`اكتب إجابتك…`,inputRequired:`أسئلة لك`,askFallbackQuestion:`يرجى تقديم المعلومات الناقصة.`,inputBadge:`أسئلة`,inputAnswered:`تمت الإجابة`,inputSkipped:`تم التخطي`,showOptions:`إظهار الخيارات`,hideOptions:`إخفاء الخيارات`,qtypeText:`إجابتك`,qtypeEmail:`عنوان البريد الإلكتروني`,qtypePhone:`رقم الهاتف`,qtypeNumber:`رقم`,qtypeDate:`تاريخ`,qtypeChooseOne:`اختر واحدًا`,qtypeChooseAny:`اختر أيًا`,qtypeBoolean:`نعم / لا`,inputSubmit:`إرسال الإجابات`,inputSubmitHint:`Enter للإرسال · Shift+Enter = سطر جديد`,inputSkip:`تخطٍّ`,confirmYes:`نعم`,confirmNo:`لا`,approve:`موافقة`,decline:`رفض`,changeAnswer:`تغيير الإجابة`,approvalPrompt:`{action}؟`,approvalEditHint:`يمكنك تغيير إجابتك حتى تستأنف هذه الخطوة.`,stepInput:`المدخلات`,stepWorking:`قيد التنفيذ`,stepWorkingOnIt:`جارٍ التنفيذ…`,stepNeedsYourApproval:`بحاجة إلى موافقتك`,stepWaitingForVisitor:`بانتظار الزائر`,stepApproved:`تمت الموافقة`,stepDeclined:`مرفوض`,stepReplaced:`تم الاستبدال`,stepFailed:`فشل`,stepDidNotWork:`لم ينجح`,decidedYouApproved:`وافقت`,decidedYouDeclined:`رفضت`,decidedVisitorApproved:`وافق الزائر`,decidedVisitorDeclined:`رفض الزائر`,decidedTeamApproved:`وافق عضو في الفريق`,decidedTeamDeclined:`رفض عضو في الفريق`,decidedMemberApproved:`وافق {name}`,decidedMemberDeclined:`رفض {name}`,stepRawData:`البيانات الأولية`,decidedRulesApproved:`تمت الموافقة تلقائيًا`,decidedRulesDeclined:`رُفض تلقائيًا`,edit:`تعديل`,toolStepsFailed:`فشل {count}`,statusStopped:`أُوقف`,toolStepsStopped:`أُوقف بعد {count} خطوات`,toolStepsStoppedOne:`أُوقف بعد خطوة واحدة`},he:{attach:`צירוף קבצים`,file:`קובץ`,attachmentMimeRejected:`הקובץ {name} אינו מסוג שהצ׳אט הזה מקבל.`,attachmentTooLarge:`הקובץ {name} גדול מדי. הקבצים יכולים להגיע יחד עד {max}.`,poweredBy:`מופעל על ידי {name}`,attachmentTooMany:`מספר הקבצים המרבי לצירוף: {count}.`,attachmentUploadFailed:`לא ניתן היה להעלות את {name}.`,conversationLoading:`טוען צ׳אט…`,loadPreviousMessages:`טעינת הודעות קודמות`,close:`סגירה`,collapse:`כיווץ`,collapseSidebar:`כיווץ סרגל הצד`,composerPlaceholder:`כתוב הודעה…`,dateLastWeek:`7 הימים האחרונים`,dateOlder:`ישן יותר`,dateToday:`היום`,dateYesterday:`אתמול`,dropZone:`שחרר קבצים כדי לצרף`,dropZoneRejected:`לא ניתן לצרף כאן את הקבצים האלה`,errorGeneric:`משהו השתבש`,errorRateLimited:`יותר מדי בקשות — נסה שוב בעוד רגע.`,errorRateLimitedIn:`יותר מדי בקשות — נסה שוב בעוד {seconds} שנ׳.`,errorOffline:`אין חיבור לשרת. בדוק את החיבור ונסה שוב.`,errorServer:`משהו השתבש אצלנו. נסה שוב.`,errorOriginNotAllowed:`הצ'אט הזה עדיין לא מוגדר לאתר הזה.`,errorMessageTooLong:`ההודעה הזו ארוכה מדי. קצרו אותה ושלחו שוב.`,errorReconnecting:`החיבור אבד. מתחבר מחדש…`,errorRetry:`נסה שוב`,expand:`הרחבה`,expandSidebar:`הרחבת סרגל הצד`,exitFullscreen:`יציאה ממסך מלא`,fullscreen:`מסך מלא`,history:`היסטוריה`,historyBack:`חזרה לצ׳אט`,historyEmpty:`אין עדיין צ׳אטים קודמים`,historyContinue:`המשך צ׳אט`,historyLoading:`טוען את הצ׳אטים שלך…`,historyTitle:`היסטוריית צ׳אטים`,loadMoreConversations:`טעינת שיחות נוספות`,language:`שפה`,launcherOpen:`פתיחת צ׳אט`,launcherAsk:`לשאול את {name}`,micBlocked:`המיקרופון חסום באתר הזה, ולכן אי אפשר להתחיל קלט קולי.`,micStart:`התחלת קלט קולי`,micStop:`עצירת קלט קולי`,moreActions:`פעולות נוספות`,newConversation:`צ׳אט חדש`,panelTitle:`צ׳אט`,popOut:`פתיחה בכרטיסייה חדשה`,resizeHandle:`גרור לשינוי הגודל`,scrollToBottom:`מעבר לחדש ביותר`,send:`שליחה`,queueMessage:`הוספת ההודעה לתור`,removeQueuedMessage:`הסרת ההודעה מהתור`,removeAttachment:`הסרת {name}`,suggestedReplies:`תשובות מוצעות`,compactingContext:`מבצע אופטימיזציה להקשר השיחה…`,soundOff:`השתקת הצליל`,soundOn:`הפעלת הצליל`,talkToOperator:`דברו עם אדם`,connectingOperator:`מחברים אותך לאדם…`,noOperatorAvailable:`אין נציגים זמינים כעת — השאר את הפרטים שלך ונחזור אליך.`,chattingWithOperator:`אתה מצ׳וטט עם {operator}`,operatorBadgeTitle:`צ׳אט חי`,chatNotice:`אתה מצ׳וטט עם עוזר בינה מלאכותית.`,cancelOperatorRequest:`המשך לשוחח עם ה-AI`,loginPrompt:`התחברו לקבלת תמיכה מהירה ומותאמת אישית`,loginAction:`התחברות`,loginRequired:`התחברו כדי לשוחח איתנו`,loginExpired:`פג תוקף ההתחברות שלך. התחברו כדי להמשיך בשיחה הזו.`,loginExpiredGuest:`פג תוקף ההתחברות שלך. התחברו כדי להמשיך בשיחה הזו, או התחילו שיחה חדשה כאורחים.`,startAsGuest:`התחלת שיחה חדשה`,loggedInAs:`מחובר/ת בתור {name}`,loggedIn:`מחובר/ת`,dismissLoginPrompt:`הסתרה`,emailTranscript:`שליחת תמליל בדוא״ל`,emailTranscriptPrompt:`קבלו עותק של השיחה הזו בדוא״ל.`,emailTranscriptEmailLabel:`כתובת דוא״ל`,emailTranscriptSend:`שליחת התמליל`,emailTranscriptSending:`שולחים…`,emailTranscriptSent:`נשלח אל {email}.`,emailTranscriptAlreadySent:`השיחה הזו כבר נשלחה. שלחו הודעה חדשה כדי לשלוח אותה שוב.`,emailTranscriptLimited:`הגעתם למגבלה כרגע. נסו שוב מאוחר יותר.`,emailTranscriptFailed:`השליחה נכשלה. נסו שוב.`,emailTranscriptNotDelivered:`לא ניתן לשלוח לכתובת הזו. בדקו אותה ונסו שוב.`,emailTranscriptCancel:`ביטול`,emailTranscriptDone:`סיום`,stop:`עצירה`,theme:`ערכת נושא`,themeAuto:`אוטומטי`,themeDark:`כהה`,themeLight:`בהיר`,textSize:`גודל טקסט`,textSizeSmall:`קטן`,textSizeNormal:`רגיל`,textSizeLarge:`גדול`,loading:`טוען…`,visualPreparing:`מכין תצוגה…`,visualError:`לא ניתן היה להציג תצוגה זו.`,visualPartial:`לא ניתן היה להציג חלקים מתצוגה זו.`,visualSoldOut:`אזל מהמלאי`,visualCartEmpty:`העגלה שלך ריקה.`,visualQuantity:`כמות`,visualChoose:`בחרו`,visualDirect:`ישיר`,visualVia:`דרך`,visualNight:`לילה אחד`,visualNights:`{count} לילות`,visualPerNight:`ללילה`,visualTravellers:`נוסעים`,thinking:`חושב…`,thought:`מחשבה`,thoughtFor:`חשב במשך {time}`,toolResult:`תוצאה`,sources:`מקורות`,feedbackUp:`תשובה טובה`,feedbackDown:`תשובה גרועה`,feedbackThanks:`תודה על המשוב`,copy:`העתק`,copied:`הועתק`,copyTicketReference:`פנייה {reference}, העתקה`,tabHome:`בית`,tabConversations:`צ׳אטים`,tabHelp:`עזרה`,tabNews:`חדשות`,modulesEmpty:`אין כאן עדיין כלום`,chatUnavailable:`הצ׳אט הזה אינו זמין כרגע`,moduleBack:`חזרה`,contentLoading:`טוען…`,contentHelpful:`האם זה עזר?`,homeGreeting:`כיצד נוכל לעזור?`,homeGreetingNamed:`שלום {name} 👋`,homeGreetingLead:`כיצד נוכל לעזור?`,homeSearchPlaceholder:`חיפוש עזרה`,homeAskPlaceholder:`שאלו שאלה…`,homeWhatsNew:`מה חדש`,homeContentTitle:`מאמרים פופולריים`,homeStatus:`סטטוס`,helpTitle:`עזרה`,helpSearchPlaceholder:`חיפוש עזרה`,helpEmpty:`אין עדיין מאמרי עזרה`,helpLoading:`טוען עזרה…`,helpSearchEmpty:`אין תוצאות עבור „{query}”`,helpShowMore:`הצגת עוד`,newsTitle:`חדשות`,newsEmpty:`אין עדיין חדשות`,newsLoading:`טוען חדשות…`,newsShowMore:`הצגת עוד`,newsUnseen:`פוסט חדש`,unread:`לא נקרא`,formRequired:`שדה חובה`,formInvalidEmail:`הזן כתובת אימייל תקינה`,formInvalidTel:`הזן מספר טלפון תקין`,formInvalidNumber:`הזן מספר תקין`,formOtherPlaceholder:`כתוב את תשובתך…`,inputRequired:`שאלות עבורך`,askFallbackQuestion:`אנא ספקו את המידע החסר.`,inputBadge:`שאלות`,inputAnswered:`נענה`,inputSkipped:`דולג`,showOptions:`הצג אפשרויות`,hideOptions:`הסתר אפשרויות`,qtypeText:`התשובה שלך`,qtypeEmail:`כתובת אימייל`,qtypePhone:`מספר טלפון`,qtypeNumber:`מספר`,qtypeDate:`תאריך`,qtypeChooseOne:`בחר אחת`,qtypeChooseAny:`בחר כמה`,qtypeBoolean:`כן / לא`,inputSubmit:`שליחת תשובות`,inputSubmitHint:`Enter לשליחה · Shift+Enter = שורה חדשה`,inputSkip:`דילוג`,confirmYes:`כן`,confirmNo:`לא`,approve:`אישור`,decline:`דחייה`,changeAnswer:`שינוי התשובה`,approvalPrompt:`{action}?`,approvalEditHint:`אפשר לשנות את התשובה עד שהשלב הזה ימשיך.`,stepInput:`קלט`,stepWorking:`בביצוע`,stepWorkingOnIt:`מטפלים בזה…`,stepNeedsYourApproval:`נדרש האישור שלך`,stepWaitingForVisitor:`ממתין למבקר`,stepApproved:`אושר`,stepDeclined:`נדחה`,stepReplaced:`הוחלף`,stepFailed:`נכשל`,stepDidNotWork:`לא הצליח`,decidedYouApproved:`אישרת`,decidedYouDeclined:`דחית`,decidedVisitorApproved:`אושר על ידי המבקר`,decidedVisitorDeclined:`נדחה על ידי המבקר`,decidedTeamApproved:`אושר על ידי חבר צוות`,decidedTeamDeclined:`נדחה על ידי חבר צוות`,decidedMemberApproved:`אושר על ידי {name}`,decidedMemberDeclined:`נדחה על ידי {name}`,stepRawData:`נתונים גולמיים`,decidedRulesApproved:`אושר אוטומטית`,decidedRulesDeclined:`נדחה אוטומטית`,edit:`עריכה`,toolStepsFailed:`{count} נכשלו`,statusStopped:`נעצר`,toolStepsStopped:`נעצר אחרי {count} שלבים`,toolStepsStoppedOne:`נעצר אחרי שלב אחד`},zh:{attach:`添加附件`,file:`文件`,attachmentMimeRejected:`此聊天不接受 {name} 的文件类型。`,attachmentTooLarge:`{name} 太大了。文件总大小不能超过 {max}。`,poweredBy:`由 {name} 提供支持`,attachmentTooMany:`最多可添加 {count} 个附件。`,attachmentUploadFailed:`{name} 上传失败。`,conversationLoading:`正在加载聊天…`,loadPreviousMessages:`加载更早的消息`,close:`关闭`,collapse:`收起`,collapseSidebar:`收起侧边栏`,composerPlaceholder:`输入消息…`,dateLastWeek:`最近 7 天`,dateOlder:`更早`,dateToday:`今天`,dateYesterday:`昨天`,dropZone:`拖放文件以添加附件`,dropZoneRejected:`这些文件无法在此添加`,errorGeneric:`出了点问题`,errorRateLimited:`请求过多,请稍后再试。`,errorRateLimitedIn:`请求过多,请在 {seconds} 秒后重试。`,errorOffline:`无法连接服务器。请检查网络后重试。`,errorServer:`我们这边出了点问题。请重试。`,errorOriginNotAllowed:`此聊天尚未为本网站设置。`,errorMessageTooLong:`消息太长了。请缩短后重新发送。`,errorReconnecting:`连接已断开,正在重新连接…`,errorRetry:`重试`,expand:`展开`,expandSidebar:`展开侧边栏`,exitFullscreen:`退出全屏`,fullscreen:`全屏`,history:`历史记录`,historyBack:`返回聊天`,historyEmpty:`还没有以前的聊天`,historyLoading:`正在加载你的聊天…`,historyContinue:`继续聊天`,historyTitle:`聊天记录`,loadMoreConversations:`加载更多对话`,language:`语言`,launcherOpen:`打开聊天`,launcherAsk:`询问 {name}`,micBlocked:`此网站的麦克风已被阻止,无法开始语音输入。`,micStart:`开始语音输入`,micStop:`停止语音输入`,moreActions:`更多操作`,newConversation:`新聊天`,panelTitle:`聊天`,popOut:`在新标签页中打开`,resizeHandle:`拖动以调整大小`,scrollToBottom:`滚动到最新`,send:`发送`,queueMessage:`排队发送`,removeQueuedMessage:`移除排队的消息`,removeAttachment:`移除 {name}`,suggestedReplies:`推荐回复`,compactingContext:`正在优化对话上下文…`,soundOff:`关闭声音`,soundOn:`打开声音`,talkToOperator:`与真人交谈`,connectingOperator:`正在为你联系真人…`,noOperatorAvailable:`目前没有人有空,请留下你的联系方式,我们会跟进。`,chattingWithOperator:`你正在与 {operator} 聊天`,operatorBadgeTitle:`在线聊天`,chatNotice:`你正在与 AI 助手聊天。`,cancelOperatorRequest:`继续与 AI 聊天`,loginPrompt:`登录以获得更快、更个性化的支持`,loginAction:`登录`,loginRequired:`登录后与我们聊天`,loginExpired:`你的登录已过期。请登录以继续此聊天。`,loginExpiredGuest:`你的登录已过期。请登录以继续此聊天,或以访客身份开始新对话。`,startAsGuest:`开始新对话`,loggedInAs:`已登录为 {name}`,loggedIn:`已登录`,dismissLoginPrompt:`隐藏`,emailTranscript:`通过邮件发送聊天记录`,emailTranscriptPrompt:`通过邮件获取此对话的副本。`,emailTranscriptEmailLabel:`邮箱地址`,emailTranscriptSend:`发送聊天记录`,emailTranscriptSending:`正在发送…`,emailTranscriptSent:`已发送至 {email}。`,emailTranscriptAlreadySent:`此对话已通过邮件发送。发送一条新消息后可再次发送。`,emailTranscriptLimited:`你已达到当前上限。请稍后再试。`,emailTranscriptFailed:`发送失败。请重试。`,emailTranscriptNotDelivered:`无法发送到此地址。请检查后重试。`,emailTranscriptCancel:`取消`,emailTranscriptDone:`完成`,stop:`停止`,theme:`主题`,themeAuto:`自动`,themeDark:`深色`,themeLight:`浅色`,textSize:`文字大小`,textSizeSmall:`小`,textSizeNormal:`标准`,textSizeLarge:`大`,loading:`正在加载…`,visualPreparing:`正在准备图表…`,visualError:`无法显示此图表。`,visualPartial:`此图表的部分内容无法显示。`,visualSoldOut:`已售罄`,visualCartEmpty:`你的购物车是空的。`,visualQuantity:`数量`,visualChoose:`选择`,visualDirect:`直飞`,visualVia:`经停`,visualNight:`1 晚`,visualNights:`{count} 晚`,visualPerNight:`每晚`,visualTravellers:`旅客`,thinking:`正在思考…`,thought:`思考过程`,thoughtFor:`思考了 {time}`,toolResult:`结果`,sources:`来源`,feedbackUp:`回答很好`,feedbackDown:`回答不好`,feedbackThanks:`感谢你的反馈`,copy:`复制`,copied:`已复制`,copyTicketReference:`工单 {reference},复制`,tabHome:`首页`,tabConversations:`聊天`,tabHelp:`帮助`,tabNews:`动态`,modulesEmpty:`这里还没有内容`,chatUnavailable:`此聊天目前不可用`,moduleBack:`返回`,contentLoading:`正在加载…`,contentHelpful:`这对你有帮助吗?`,homeGreeting:`有什么可以帮你?`,homeGreetingNamed:`你好,{name} 👋`,homeGreetingLead:`有什么可以帮你?`,homeSearchPlaceholder:`搜索帮助`,homeAskPlaceholder:`提出问题…`,homeWhatsNew:`最新动态`,homeContentTitle:`热门文章`,homeStatus:`状态`,helpTitle:`帮助`,helpSearchPlaceholder:`搜索帮助`,helpEmpty:`还没有帮助文章`,helpLoading:`正在加载帮助…`,helpSearchEmpty:`没有找到“{query}”的结果`,helpShowMore:`显示更多`,newsTitle:`动态`,newsEmpty:`还没有动态`,newsLoading:`正在加载动态…`,newsShowMore:`显示更多`,newsUnseen:`新文章`,unread:`未读`,formRequired:`此项为必填`,formInvalidEmail:`请输入有效的邮箱地址`,formInvalidTel:`请输入有效的电话号码`,formInvalidNumber:`请输入有效的数字`,formOtherPlaceholder:`输入你的回答…`,inputRequired:`需要你回答的问题`,askFallbackQuestion:`请提供缺少的信息。`,inputBadge:`问题`,inputAnswered:`已回答`,inputSkipped:`已跳过`,showOptions:`显示选项`,hideOptions:`隐藏选项`,qtypeText:`你的回答`,qtypeEmail:`邮箱地址`,qtypePhone:`电话号码`,qtypeNumber:`数字`,qtypeDate:`日期`,qtypeChooseOne:`选择一项`,qtypeChooseAny:`可多选`,qtypeBoolean:`是 / 否`,inputSubmit:`提交回答`,inputSubmitHint:`Enter 发送 · Shift+Enter 换行`,inputSkip:`跳过`,confirmYes:`是`,confirmNo:`否`,approve:`批准`,decline:`拒绝`,changeAnswer:`修改回答`,approvalPrompt:`{action}?`,approvalEditHint:`在此步骤继续之前,你可以修改回答。`,stepInput:`输入`,stepWorking:`进行中`,stepWorkingOnIt:`正在处理…`,stepNeedsYourApproval:`需要你的批准`,stepWaitingForVisitor:`等待访客`,stepApproved:`已批准`,stepDeclined:`已拒绝`,stepReplaced:`已替换`,stepFailed:`失败`,stepDidNotWork:`未成功`,decidedYouApproved:`你已批准`,decidedYouDeclined:`你已拒绝`,decidedVisitorApproved:`访客已批准`,decidedVisitorDeclined:`访客已拒绝`,decidedTeamApproved:`团队成员已批准`,decidedTeamDeclined:`团队成员已拒绝`,decidedMemberApproved:`{name} 已批准`,decidedMemberDeclined:`{name} 已拒绝`,stepRawData:`原始数据`,decidedRulesApproved:`已自动批准`,decidedRulesDeclined:`已自动拒绝`,edit:`编辑`,toolStepsFailed:`{count} 个失败`,statusStopped:`已停止`,toolStepsStopped:`在 {count} 步后停止`,toolStepsStoppedOne:`在 1 步后停止`}};function At(e,t){let n=jt(e),r=Ft(t),i=kt[Ct(n)],a=r?{...t[n],...t[e]}:t??{},o=r?t.en??{}:{};return{...Ot,...i,...o,...a}}function jt(e){return(e.split(`-`)[0]??`en`).toLowerCase()}const Mt=/* @__PURE__ */ new Set([`ar`,`he`,`iw`,`fa`,`ur`,`ps`,`sd`,`ug`,`yi`,`dv`,`ckb`,`ks`,`nqo`,`prs`,`syr`]);function Nt(e){return Mt.has(jt(e))}function Pt(e,t){return e[t]??t}function Ft(e){if(!e)return!1;for(let t of Object.values(e))if(t&&typeof t==`object`)return!0;return!1}const It=[`decided`,`auto-decided`,`unasked`,`failed`],Lt=[`platform`,`mcp`,`api`,`webmcp`],Rt=[`none`,`values`,`table`,`json`,`table-and-json`];function zt(e,t){return typeof t==`string`&&e.some(e=>e===t)}const Bt={visitor:{stepsFrom:Lt,stepsShown:[],stepDetails:`values`,showStepSystem:!1,showDecidedBy:!1,foldApprovals:!0},member:{stepsFrom:Lt,stepsShown:It,stepDetails:`table-and-json`,showStepSystem:!0,showDecidedBy:!0,foldApprovals:!0}},Vt=[`showStepSystem`,`showDecidedBy`,`foldApprovals`];function Ht(e){let t={};if(typeof e!=`object`||!e)return t;for(let n of Vt){let r=Reflect.get(e,n);typeof r==`boolean`&&(t[n]=r)}let n=Reflect.get(e,`stepsFrom`);Array.isArray(n)&&(t.stepsFrom=Lt.filter(e=>n.includes(e)));let r=Reflect.get(e,`stepsShown`);Array.isArray(r)&&(t.stepsShown=It.filter(e=>r.includes(e)));let i=Reflect.get(e,`stepDetails`);return zt(Rt,i)&&(t.stepDetails=i),t}function Ut(e,t){return{...Bt[t],...e}}const Wt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Gt(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 Kt(e){if(e.title)return e.title;let t=e.toolName.replace(/^tool[:-]/,``),n=t.indexOf(`__`);return Gt(n>0?t.slice(n+2):t)}function qt(e,t,n){let r=e.approval;return r?.replacedByMessageId?`replaced`:e.state===`output-available`?n.error===void 0?`done`:`failed`:e.state===`output-error`?t.interrupted?`stopped`:`failed`:e.state===`output-denied`||r?.approved===!1?`declined`:e.state===`approval-responded`||r?.approved===!0?t.cutOff?`stopped`:`approved`:e.state===`approval-requested`?t.submitted?`submitted`:t.cutOff?`stopped`:t.superseded?`replaced`:`waiting`:t.live?`running`:`stopped`}function Jt(e,t){if(e.isAutomatic)return`rules`;let n=e.respondedBy;return n?.visitorId?`visitor`:n?.userId?n.userId===t.userId?`you`:`teamMember`:t.decides?`you`:`visitor`}function Yt(e,t,n,r,i){let a=r[t?`inputAnswered`:`inputSkipped`];if(i)return{label:a,title:a};let o=r[t?`stepApproved`:`stepDeclined`];if(e===`teamMember`&&n)return{label:o,title:r[t?`decidedMemberApproved`:`decidedMemberDeclined`].replace(`{name}`,n)};let s=r[Xt[e][+!t]];return e===`you`?{label:o,title:s}:{label:s,title:s}}const Xt={you:[`decidedYouApproved`,`decidedYouDeclined`],visitor:[`decidedVisitorApproved`,`decidedVisitorDeclined`],teamMember:[`decidedTeamApproved`,`decidedTeamDeclined`],rules:[`decidedRulesApproved`,`decidedRulesDeclined`]};function Zt(e,t){switch(e){case`running`:return t.strings.stepWorking;case`waiting`:return t.reader.decides?t.strings.stepNeedsYourApproval:t.strings.stepWaitingForVisitor;case`submitted`:return t.strings.stepWorkingOnIt;case`approved`:return t.strings.stepApproved;case`declined`:return t.card?t.strings.inputSkipped:t.strings.stepDeclined;case`replaced`:return t.card?t.strings.inputSkipped:t.strings.stepReplaced;case`stopped`:return t.strings.statusStopped;case`failed`:return t.plain?t.strings.stepDidNotWork:t.strings.stepFailed;case`done`:return``;default:return e}}function Qt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $t(e){return typeof e==`string`?e.trim():typeof e==`number`||typeof e==`boolean`?String(e):``}function en(e){return $t(e)||(typeof e==`object`&&e?JSON.stringify(e):``)}function tn(e){if(!Qt(e))return en(e);let[t,...n]=Object.values(e).map(en).filter(Boolean);return t===void 0?``:n.length>0?`${t} (${n.join(`, `)})`:t}function nn(e,t){if(!Qt(e))return[];let n=[];function r(e,i){if(Array.isArray(e)){let t=e.map(tn).filter(Boolean).join(`, `);t&&n.push({path:i,value:t});return}if(Qt(e)){for(let[t,n]of Object.entries(e))r(n,[...i,t]);return}let a=$t(e);a&&(t.withIds||!Wt.test(a))&&n.push({path:i,value:a})}r(e,[]);let i=n.map(({path:e})=>Gt(e.at(-1)??``));return n.map(({path:e,value:t},n)=>{let r=i[n]??``;return{label:i.filter(e=>e===r).length>1&&e.length>1?`${Gt(e.at(-2)??``)} · ${r.toLowerCase()}`:r,value:t}})}function rn(e,t){if(Qt(e))return Object.entries(e).find(e=>e[0]!==t&&typeof e[1]==`string`&&e[1].trim().length>0&&!Wt.test(e[1].trim()))?.[1].trim()}function an(e){if(typeof e.toolMetadata?.system==`string`)return e.toolMetadata.system;let t=e.toolMetadata?.systemField,n=typeof t==`string`&&Qt(e.input)?e.input[t]:void 0;return typeof n==`string`&&n.trim()?n.trim():void 0}function on(e,t=1/0){if(e==null)return;let n=typeof e==`string`?e:JSON.stringify(e,null,2);if(n&&n!==`{}`&&n!==`[]`&&n!==`""`)return n.length>t?`${n.slice(0,t)}…`:n}function sn(e){let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}}function cn(e){if(Qt(e)&&e.storage===`tool-result-ref`&&`summary`in e)return cn(e.summary);if(Qt(e)&&Array.isArray(e.content)){let t=e.content.flatMap(e=>Qt(e)&&typeof e.text==`string`?[e.text]:[]).join(`
3
- `),n=Qt(e.structuredContent)?e.structuredContent:sn(t);return e.isError===!0?{value:n,error:Qt(n)&&typeof n.error==`string`?n.error:t}:{value:n}}return Qt(e)&&typeof e.error==`string`&&typeof e.instruction==`string`?{value:e,error:e.error}:{value:e}}function ln(e){return on(e.input)!==void 0||on(e.output)!==void 0||!!e.errorText}function un(e,t){let n=e.approval?`decided`:`unasked`,r=e.approval?.isAutomatic?`auto-decided`:n;return t===`failed`?[r,`failed`]:[r]}function dn(e){let t=e.toolMetadata?.origin;return zt(Lt,t)?t:void 0}function fn(e,t,n){let{display:r}=n,i=e.approval,a=i!==void 0&&!i.isAutomatic;if(a&&pn(e,n.turn))return`card`;let o=n.by===`you`||a&&n.by===void 0&&n.reader.decides,s=dn(e),c=(s===void 0||r.stepsFrom.includes(s))&&un(e,t.status).some(e=>r.stepsShown.includes(e));return!(o||c)||!i&&!ln(e)?`hidden`:a&&!r.foldApprovals?`card`:`step`}function pn(e,t){return e.approval?.replacedByMessageId||(t.superseded||t.cutOff)&&e.approval?.approved===void 0?!1:e.state===`approval-requested`||e.state===`approval-responded`}function mn(e,t){let{turn:n,reader:r,display:i,strings:a}=t,o=cn(e.output),s=qt(e,n,o),c=e.approval,l=c!==void 0&&!c.isAutomatic,u=typeof e.toolMetadata?.card==`string`?e.toolMetadata.card:void 0,d=i.stepDetails,f=d===`table`||d===`table-and-json`,p=d===`none`||d===`values`,m=c?.replacedByMessageId?void 0:c?.approved,h=c&&m!==void 0?Jt(c,r):void 0,g=h===`teamMember`?c?.respondedBy?.userId:void 0,_=h&&m!==void 0&&(h===`you`||h===`rules`||i.showDecidedBy)?{approved:m,by:h,...Yt(h,m,g&&t.names?.get(g),a,u!==void 0),...g?{userId:g}:{}}:void 0,v=Kt(e),y=i.showStepSystem||e.toolMetadata?.nameShared===!0?an(e):void 0,b=rn(e.input,typeof e.toolMetadata?.systemField==`string`?e.toolMetadata.systemField:void 0),x=e.errorText??o.error,S=f&&o.error===void 0?nn(o.value,{withIds:!0}):[],C=d===`json`||d===`table-and-json`?{input:on(e.input),output:on(o.value,4e3)}:void 0,w=l&&pn(e,n),ee=d===`none`&&!w?[]:nn(e.input,{withIds:f||w}),T=x!==void 0&&x!==``&&!p,E=Qt(c?.descriptor)&&Qt(c.descriptor.decision)?c.descriptor.decision:void 0,D=d!==`none`||w?E:void 0,O=_!==void 0&&(s===`approved`||s===`declined`),te={toolCallId:e.toolCallId,placement:`hidden`,...u&&c?{card:u}:{},name:v,...y?{system:y}:{},status:s,statusLabel:O?``:Zt(s,{reader:r,strings:a,card:u!==void 0,plain:p}),..._?{decision:_}:{},...D?{why:D}:{},...b?{summary:b}:{},fields:ee,tables:f,...S.length>0?{resultFields:S}:{},...T?{error:x}:{},...C?{raw:C}:{},opens:ee.length>0||S.length>0||C!==void 0||T||D!==void 0,...l&&!u?{approval:hn(e,s,{turn:n,reader:r,strings:a,name:v})}:{}};return{...te,placement:fn(e,te,{turn:n,reader:r,display:i,by:h})}}function hn(e,t,n){let r=n.strings.approvalPrompt.replace(`{action}`,n.name);return t===`waiting`?{ask:r,buttons:n.reader.decides?`decide`:`none`}:t===`submitted`||!pn(e,n.turn)?{ask:r,buttons:`none`}:n.turn.canAct&&n.reader.decides?{ask:r,buttons:`change`,note:n.strings.approvalEditHint}:t===`approved`?{ask:r,buttons:`none`,note:n.strings.stepWorkingOnIt}:{ask:r,buttons:`none`}}function gn(e){let t=/* @__PURE__ */ new Map;for(let n of e)t.set(n.name,(t.get(n.name)??0)+1);let n=/* @__PURE__ */ new Map;for(let{decision:t}of e){if(!t)continue;let e=n.get(t.title)??{approved:t.approved,label:t.label,title:t.title,...t.userId?{userId:t.userId}:{},count:0};n.set(t.title,{...e,count:e.count+1})}let[r]=e,i=e.some(e=>e.status===`stopped`);return{tools:[...t].map(([e,t])=>({name:e,count:t})),...e.length===1&&r?{single:{name:r.name,...r.system?{system:r.system}:{},...r.summary?{summary:r.summary}:{},..._n(r)}}:{},marks:[...n.values()].map(({count:e,...t})=>Object.assign(t,{label:e>1?`${t.label} ×${e}`:t.label})),failed:e.filter(e=>e.status===`failed`).length,...i?{stopped:{finished:e.filter(e=>e.status!==`stopped`).length}}:{}}}function _n(e){return!e.decision&&(e.status===`replaced`||e.status===`declined`)?{outcome:e.statusLabel}:{}}function vn(e,t){return e===0?t.statusStopped:e===1?t.toolStepsStoppedOne:t.toolStepsStopped.replace(`{count}`,String(e))}const yn=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{}}},bn={get(e){try{return sessionStorage.getItem(e)}catch{return null}},set(e,t){try{sessionStorage.setItem(e,t)}catch{}},remove(e){try{sessionStorage.removeItem(e)}catch{}}},xn={maxBytes:10485760,maxCount:10,accept:`*/*`},Sn={voice:`local`},Cn={enabled:!0,sampleRate:1},wn={upload:`/pai/upload-file`,transcribe:`/pai/transcribe-audio`},Tn={variant:`circle`,size:`md`,label:void 0,icon:`chat`,hidden:!1},En={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`]},Dn={enabled:!0,volume:.3,events:void 0},On={enabled:!0,events:void 0},kn=[{label:`tabConversations`,layout:`chat`}],An=_.scope(`context`),jn=/* @__PURE__ */ new Set([`visitorId`,`conversationId`,`jwt`,`token`,`authorization`,`password`]),Mn=1024,Nn=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Pn(e){return Ln(e,`userContext`,!0)}function Fn(e){return Ln(e,`pageContext`,!1)}function In(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ln(e,t,n){if(e==null)return;if(!In(e)){An.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(jn.has(n)){An.warn(`dropped reserved ${t} key "${n}" — managed by the widget, not host-settable`);continue}if(a==null)continue;if(i>=50){An.warn(`${t} truncated at 50 keys — dropped "${n}"`);continue}let e=Rn(t,n,a);e!==void 0&&(r[n]=e,i++)}return n&&typeof r.email==`string`&&!Nn.test(r.email)&&(An.warn(`dropped malformed context field`,{field:`${t}.email`,reason:`invalid format`}),delete r.email),Object.keys(r).length>0?r:void 0}function Rn(e,t,n){if(typeof n==`boolean`)return n;if(typeof n==`number`){if(!Number.isFinite(n)){An.warn(`dropped non-finite ${e}.${t}`);return}return n}if(typeof n==`string`){let r=n.trim();return r===``?void 0:r.length>Mn?(An.warn(`truncated ${e}.${t} to ${Mn} chars`),r.slice(0,Mn)):r}An.warn(`dropped ${e}.${t} — only string/number/boolean values are allowed`,{type:typeof n})}function zn(e){let t=typeof e==`object`&&e?e:{},n=t.presentation??{},r=t.behavior??{},a=t.i18n??{},o=t.feedback??{},s=t.footer??{},c=t.header??{},l={enabled:t.history?.enabled??!0},{themeMode:u,themeOverrides:d}=Bn(t.theme),f=n.mode??`floating`,p=Vn(a.defaultLocale),m=a.availableLocales??[a.locale??p],h=Hn(a.locale??p,m,p),g=(t.baseUrl??i.defaultBaseUrl).replace(/\/$/,``),_=(t.agentApiBaseUrl??`${g}/api/agent`).replace(/\/$/,``),v=(t.dataApiBaseUrl??`${g}/api/data`).replace(/\/$/,``);return{widgetId:t.widgetId??`default`,publicKey:t.publicKey,aiAgentDeploymentId:t.aiAgentDeploymentId,baseUrl:g,agentApiBaseUrl:_,dataApiBaseUrl:v,userContext:Pn(t.userContext),pageContext:Fn(t.pageContext),position:n.position??(Nt(h)?`bottom-left`:`bottom-right`),themeMode:u,textSize:`normal`,themeOverrides:d,mode:f,responseMode:r.responseMode??`streaming`,showReasoning:r.showReasoning??!1,stepDisplay:Ut(r.stepDisplay,`visitor`),showSources:r.showSources??!1,enableMessageFeedback:!(r.disableMessageFeedback??!1),autoSendSuggestions:r.autoSendSuggestions??!1,cardAnswerWaitSeconds:r.cardAnswerWaitSeconds??60,popOutUrl:r.popOutUrl,features:{voice:t.features?.voice??Sn.voice,fileUpload:!(t.features?.disableFileUpload??!1),humanInLoop:!(t.features?.disableHumanInLoop??!1),emailTranscript:!(t.features?.disableEmailTranscript??!1),operatorRequest:t.features?.enableOperatorRequest===!0&&!(t.features.hideRequestOperatorButton??!1)},endpoints:{upload:t.endpoints?.upload??wn.upload,transcribe:t.endpoints?.transcribe??wn.transcribe},attachments:{accept:t.composer?.attachments?.accept??xn.accept,maxBytes:t.composer?.attachments?.maxBytes??xn.maxBytes,maxCount:t.composer?.attachments?.maxCount??xn.maxCount},locale:h,defaultLocale:p,availableLocales:m,startMinimized:r.startMinimized??!0,actions:Un(f,c.actions,l.enabled),size:{...n.size,resize:{...n.size?.resize,enabled:n.size?.resize?.enabled??!0}},launcher:Xn(t.launcher,t.agent?.name),sound:Wn(o.sound),haptics:Gn(o.haptics),strings:At(h,a.strings),stringsOverride:a.strings,composerDisclaimer:s.composerDisclaimer??``,header:{variant:c.variant??`plain`,notice:c.notice,showNotice:!(c.hideNotice??!1)},poweredBy:qn(s.poweredBy),composer:Jn(t.composer),modules:Yn(t.modules,l.enabled),tracking:Kn(t.tracking,v),history:l,storage:t.storage??yn,userToken:t.userToken,continueLink:t.continueLink,tools:t.tools,onMessage:t.onMessage,onOpen:t.onOpen,onClose:t.onClose,onError:t.onError}}function Bn(e){if(typeof e==`string`)return{themeMode:e,themeOverrides:{}};if(!e||typeof e!=`object`)return{themeMode:`host`,themeOverrides:{}};let{mode:t,...n}=e;return{themeMode:t??`host`,themeOverrides:n}}function Vn(e){return e&&e!==`auto`?e:globalThis.navigator?.language||`en`}function Hn(e,t,n){if(t.length<=1||t.includes(e))return e;let r=e.split(`-`)[0];return r&&t.includes(r)?r:t.includes(n)?n:t[0]??e}function Un(e,t,n){let r=t??En[e];return n?r:r.filter(e=>e!==`history`)}function Wn(e){return{enabled:e?.enabled??Dn.enabled,volume:e?.volume??Dn.volume,events:e?.events}}function Gn(e){return{enabled:e?.enabled??On.enabled,events:e?.events}}function Kn(e,t){let n=e?.sampleRate??Cn.sampleRate;return{enabled:e?.enabled??Cn.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 qn(e){return e?.text===``&&!e.logoUrl?null:{href:i.siteUrl,...e}}function Jn(e){let t=e?.sendButton;return{sendButton:{shape:t?.shape??`circle`,icon:t?.icon??`arrowUp`,variant:t?.variant??`filled`}}}function Yn(e,t){let n=(e??kn).slice(0,4),r=n.some(e=>e?.label&&e.layout===`help`),i=/* @__PURE__ */ new Set,a=[];for(let e of n){if(!e?.label||!e?.layout)continue;let n=e.contentCollectionIds?.filter(Boolean),o=e.id??n?.[0]??e.layout;for(;i.has(o);)o=`${o}-${a.length}`;i.add(o);let s={id:o,label:e.label,layout:e.layout};n?.length&&(s.contentCollectionIds=n),e.layout===`home`&&(s.brandName=e.brandName,s.greetingText=e.greetingText,s.showGreeting=!(e.hideGreeting??!1),s.showSearchBar=r&&!(e.hideSearchBar??!1),s.showRecentConversations=t&&!(e.hideRecentConversations??!1),e.userAvatars?.length&&(s.userAvatars=e.userAvatars),e.status&&(s.status=e.status),s.contentBlockTitle=e.contentBlockTitle),a.push(s)}return{list:a,byId:Object.fromEntries(a.map(e=>[e.id,e]))}}function Xn(e,t){let n=e?.callout?.text?{shape:`pill`,position:`auto`,delayMs:1200,autoDismissMs:0,animated:!0,persistent:!0,...e.callout}:null;return{variant:e?.variant??Tn.variant,size:e?.size??Tn.size,label:e?.label??Tn.label,icon:e?.icon??Tn.icon,hidden:e?.hidden??Tn.hidden,...t&&{personaName:t},callout:n}}function Zn(e,t){return e===`host`?`host`:t??e}function Qn(e,t,n,r){let i=Hn(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=At(i,e.stringsOverride)),n!==e.themeMode&&(a.themeMode=n),r!==e.textSize&&(a.textSize=r),a}function $n(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const er=[`agent`,`presentation`,`behavior`,`theme`,`launcher`,`header`,`composer`,`feedback`,`i18n`,`footer`,`features`,`tracking`,`endpoints`,`history`];function tr(e,t){if(!t)return e;let n={...e};for(let r of er){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]=nr($n(i)?i:{},$n(a)?a:void 0))}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=nr($n(i)?i:{},$n(r)?r:void 0);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=rr(a,t)),n.i18n=e}return n}function nr(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 rr(e,t){if(!e)return t;if(!t)return e;let n=Ft(e),r=Ft(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 ir=[`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`history`,`language`,`theme`,`textSize`,`close`];function ar(e){return e!==`false`}function or(e){try{return Ht(JSON.parse(e))}catch{return}}function sr(e){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>=0?t:void 0}const cr=[[`public-key`,`publicKey`],[`ai-agent-deployment-id`,`aiAgentDeploymentId`],[`base-url`,`baseUrl`],[`agent-api-base-url`,`agentApiBaseUrl`],[`data-api-base-url`,`dataApiBaseUrl`],[`continue-link`,`continueLink`],[`theme`,`theme`,e=>e]],lr=[[`mode`,`mode`,e=>e],[`position`,`position`,e=>e]],ur=[[`width`,`width`],[`height`,`height`]],dr=[[`response-mode`,`responseMode`,e=>e],[`start-minimized`,`startMinimized`,ar],[`show-reasoning`,`showReasoning`,ar],[`step-display`,`stepDisplay`,or],[`show-sources`,`showSources`,ar],[`disable-message-feedback`,`disableMessageFeedback`,ar],[`auto-send-suggestions`,`autoSendSuggestions`,ar],[`card-answer-wait-seconds`,`cardAnswerWaitSeconds`,sr],[`pop-out-url`,`popOutUrl`]],fr=[[`locale`,`locale`]];new Set(ir);const pr=[[`launcher-variant`,`variant`,e=>e],[`launcher-size`,`size`,e=>e],[`launcher-icon`,`icon`],[`launcher-hidden`,`hidden`,ar]],mr=[[`features-disable-file-upload`,`disableFileUpload`,ar],[`features-disable-email-transcript`,`disableEmailTranscript`,ar],[`features-voice`,`voice`,e=>e]],hr=[[`endpoint-upload`,`upload`],[`endpoint-transcribe`,`transcribe`]],gr=[[`user-id`,`id`],[`user-email`,`email`],[`user-name`,`name`]],_r=[[`page-area`,`area`],[`page-url`,`url`],[`page-path`,`path`],[`page-title`,`title`]],vr=[`launcher-label`,`callout-text`,`callout-delay`,`actions`,`user-context`,`page-context`],yr=[cr,lr,ur,dr,fr,pr,mr,hr,gr,_r],br=/* @__PURE__ */ new Set([`start-minimized`]);[...yr.flatMap(e=>e.map(([e])=>e).filter(e=>!br.has(e))),...vr];const xr=_.scope(`track`);function Sr(e,t){let n=typeof e==`string`?e.trim():``;if(!n||n.length>64){xr.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?(xr.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 Cr(e){let t=[];return e.on(`hostEvent`,e=>{t.push({...e,at:Date.now()}),t.length>10&&t.shift()}),t}function wr(){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,Tr(t.subarray(6)),t[6]=(t[6]??0)&15|112,t[8]=(t[8]??0)&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 Tr(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 Er=_.scope(`persistence`);function Dr(e,t=yn,n){let r=n?`${e}.${n}`:e,a=`${i.cssPrefix}.${r}.storageVersion`,o=t.get(a)??void 0,s=o?`.v${o}`:``,c=`${i.cssPrefix}.${r}${s}`,l=`${i.cssPrefix}${s}.visitorId`,u=`${i.cssPrefix}${s}.lastUserSub`,d=`${c}.conversationId`,f=`${c}.userPrefs`,p=`${c}.panelOpen`,m=`${c}.panelSize`,h=`${c}.calloutDismissed`,g=`${c}.sidebarCollapsed`,_=`${c}.activeModule`,v=`${c}.seenNewsId`,y=`${c}.historyCount`,b=`${c}.loginReturn`,x=`${c}.loginPromptDismissedIn`,S={getVisitorId(){let e=t.get(l);if(e)return e;let n=wr();return t.set(l,n),n},loadLastUserSub(){return t.get(u)??void 0},saveLastUserSub(e){t.set(u,e)},loadConversationId(){return t.get(d)??void 0},saveConversationId(e){Er.trace(`saveConversationId`,{id:e,scope:r}),e?t.set(d,e):t.remove(d)},loadDraft(e){return t.get(`${c}.draft.${e}`)??``},saveDraft(e,n){let r=`${c}.draft.${e}`;n?t.set(r,n):t.remove(r)},loadMessageQueue(e){let n=t.get(`${c}.messageQueue.${e}`);if(!n)return[];try{let e=JSON.parse(n);return!Array.isArray(e)||!e.every(kr)?[]:e}catch(e){return Er.warn(`loadMessageQueue parse failed`,{error:e}),[]}},saveMessageQueue(e,n){let r=`${c}.messageQueue.${e}`;if(n.length===0)t.remove(r);else try{t.set(r,JSON.stringify(n))}catch(e){Er.warn(`saveMessageQueue serialise failed`,{error:e})}},loadUserPrefs(){let e=t.get(f);if(!e)return{};try{return Ar(JSON.parse(e))}catch(e){return Er.warn(`loadUserPrefs parse failed`,{error:e}),{}}},saveUserPrefs(e){try{t.set(f,JSON.stringify(e))}catch(e){Er.warn(`saveUserPrefs serialise failed`,{error:e})}},patchUserPrefs(e){let t=S.loadUserPrefs();S.saveUserPrefs({...t,...e})},loadPanelOpen(){let e=t.get(p);return e===`1`||e!==`0`&&null},savePanelOpen(e){t.set(p,e?`1`:`0`)},loadPanelSize(){let e=t.get(m);return e===`normal`||e===`expanded`||e===`fullscreen`?e:null},savePanelSize(e){t.set(m,e)},loadCalloutDismissed(e){if(!e)return!1;let n=t.get(h);return!!n&&n===e},saveCalloutDismissed(e){e?t.set(h,e):t.remove(h)},loadSidebarCollapsed(){let e=t.get(g);return e===`1`||e!==`0`&&null},saveSidebarCollapsed(e){t.set(g,e?`1`:`0`)},loadActiveModule(){return t.get(_)||null},saveActiveModule(e){t.set(_,e)},loadSeenNewsId(){return t.get(v)||null},saveSeenNewsId(e){t.set(v,e)},loadHistoryCount(){let e=t.get(y);if(!e)return null;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:null},saveHistoryCount(e){t.set(y,String(e))},rememberStorageVersion(e){e&&e!==t.get(a)&&(Er.debug(`rememberStorageVersion (force-reset on next load)`,{version:e}),t.set(a,e))},saveLoginReturn(e){bn.set(b,JSON.stringify(e))},takeLoginReturn(){let e=bn.get(b);if(e){bn.remove(b);try{let t=JSON.parse(e);return Or(t)&&typeof t.conversationId==`string`&&t.conversationId&&typeof t.draft==`string`?{conversationId:t.conversationId,draft:t.draft}:void 0}catch(e){Er.warn(`takeLoginReturn parse failed`,{error:e});return}}},loadLoginPromptDismissedIn(){return bn.get(x)??void 0},dismissLoginPromptIn(e){bn.set(x,e)},clearConversation(){t.remove(d)},reset(){let e=t.get(d);e&&(t.remove(`${c}.draft.${e}`),t.remove(`${c}.messageQueue.${e}`));for(let e of[b,x])bn.remove(e);for(let e of[l,u,d,f,m,h,g,_,v,y])t.remove(e);Er.info(`reset: forgot the visitor`,{scope:r})}};return S}function Or(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kr(e){return Or(e)&&typeof e.id==`string`&&e.id.length>0&&typeof e.text==`string`}function Ar(e){if(!Or(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),Or(e.widgetSize)&&typeof e.widgetSize.width==`number`&&typeof e.widgetSize.height==`number`&&(t.widgetSize={width:e.widgetSize.width,height:e.widgetSize.height}),t}const jr=`6.14.0`,Mr={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,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 Nr(){let e=navigator;return e.globalPrivacyControl===!0||e.doNotTrack===`1`}function Pr(){return location.origin+location.pathname}function Fr(){try{return document.referrer?new URL(document.referrer).origin:``}catch{return``}}function Ir(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||Nr()||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`,jr),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`,Pr());let h=Fr();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)}function l(e,t){return Mr[e]?.(t)}let u=Object.keys(Mr).filter(e=>Object.hasOwn(Mr,e)).map(t=>e.on(t,e=>c(t,l(t,e))));return()=>{for(let e of u)e();a.clear()}}const Lr=`: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, .55) 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
+ `),n=Qt(e.structuredContent)?e.structuredContent:sn(t);return e.isError===!0?{value:n,error:Qt(n)&&typeof n.error==`string`?n.error:t}:{value:n}}return Qt(e)&&typeof e.error==`string`&&typeof e.instruction==`string`?{value:e,error:e.error}:{value:e}}function ln(e){return on(e.input)!==void 0||on(e.output)!==void 0||!!e.errorText}function un(e,t){let n=e.approval?`decided`:`unasked`,r=e.approval?.isAutomatic?`auto-decided`:n;return t===`failed`?[r,`failed`]:[r]}function dn(e){let t=e.toolMetadata?.origin;return zt(Lt,t)?t:void 0}function fn(e,t,n){let{display:r}=n,i=e.approval,a=i!==void 0&&!i.isAutomatic;if(a&&pn(e,n.turn))return`card`;let o=n.by===`you`||a&&n.by===void 0&&n.reader.decides,s=dn(e),c=(s===void 0||r.stepsFrom.includes(s))&&un(e,t.status).some(e=>r.stepsShown.includes(e));return!(o||c)||!i&&!ln(e)?`hidden`:a&&!r.foldApprovals?`card`:`step`}function pn(e,t){return e.approval?.replacedByMessageId||(t.superseded||t.cutOff)&&e.approval?.approved===void 0?!1:e.state===`approval-requested`||e.state===`approval-responded`}function mn(e,t){let{turn:n,reader:r,display:i,strings:a}=t,o=cn(e.output),s=qt(e,n,o),c=e.approval,l=c!==void 0&&!c.isAutomatic,u=typeof e.toolMetadata?.card==`string`?e.toolMetadata.card:void 0,d=i.stepDetails,f=d===`table`||d===`table-and-json`,p=d===`none`||d===`values`,m=c?.replacedByMessageId?void 0:c?.approved,h=c&&m!==void 0?Jt(c,r):void 0,g=h===`teamMember`?c?.respondedBy?.userId:void 0,_=h&&m!==void 0&&(h===`you`||h===`rules`||i.showDecidedBy)?{approved:m,by:h,...Yt(h,m,g&&t.names?.get(g),a,u!==void 0),...g?{userId:g}:{}}:void 0,v=Kt(e),y=i.showStepSystem||e.toolMetadata?.nameShared===!0?an(e):void 0,b=rn(e.input,typeof e.toolMetadata?.systemField==`string`?e.toolMetadata.systemField:void 0),x=e.errorText??o.error,S=f&&o.error===void 0?nn(o.value,{withIds:!0}):[],C=d===`json`||d===`table-and-json`?{input:on(e.input),output:on(o.value,4e3)}:void 0,w=l&&pn(e,n),ee=d===`none`&&!w?[]:nn(e.input,{withIds:f||w}),T=x!==void 0&&x!==``&&!p,E=Qt(c?.descriptor)&&Qt(c.descriptor.decision)?c.descriptor.decision:void 0,D=d!==`none`||w?E:void 0,O=_!==void 0&&(s===`approved`||s===`declined`),te={toolCallId:e.toolCallId,placement:`hidden`,...u&&c?{card:u}:{},name:v,...y?{system:y}:{},status:s,statusLabel:O?``:Zt(s,{reader:r,strings:a,card:u!==void 0,plain:p}),..._?{decision:_}:{},...D?{why:D}:{},...b?{summary:b}:{},fields:ee,tables:f,...S.length>0?{resultFields:S}:{},...T?{error:x}:{},...C?{raw:C}:{},opens:ee.length>0||S.length>0||C!==void 0||T||D!==void 0,...l&&!u?{approval:hn(e,s,{turn:n,reader:r,strings:a,name:v})}:{}};return{...te,placement:fn(e,te,{turn:n,reader:r,display:i,by:h})}}function hn(e,t,n){let r=n.strings.approvalPrompt.replace(`{action}`,n.name);return t===`waiting`?{ask:r,buttons:n.reader.decides?`decide`:`none`}:t===`submitted`||!pn(e,n.turn)?{ask:r,buttons:`none`}:n.turn.canAct&&n.reader.decides?{ask:r,buttons:`change`,note:n.strings.approvalEditHint}:t===`approved`?{ask:r,buttons:`none`,note:n.strings.stepWorkingOnIt}:{ask:r,buttons:`none`}}function gn(e){let t=/* @__PURE__ */ new Map;for(let n of e)t.set(n.name,(t.get(n.name)??0)+1);let n=/* @__PURE__ */ new Map;for(let{decision:t}of e){if(!t)continue;let e=n.get(t.title)??{approved:t.approved,label:t.label,title:t.title,...t.userId?{userId:t.userId}:{},count:0};n.set(t.title,{...e,count:e.count+1})}let[r]=e,i=e.some(e=>e.status===`stopped`);return{tools:[...t].map(([e,t])=>({name:e,count:t})),...e.length===1&&r?{single:{name:r.name,...r.system?{system:r.system}:{},...r.summary?{summary:r.summary}:{},..._n(r)}}:{},marks:[...n.values()].map(({count:e,...t})=>Object.assign(t,{label:e>1?`${t.label} ×${e}`:t.label})),failed:e.filter(e=>e.status===`failed`).length,...i?{stopped:{finished:e.filter(e=>e.status!==`stopped`).length}}:{}}}function _n(e){return!e.decision&&(e.status===`replaced`||e.status===`declined`)?{outcome:e.statusLabel}:{}}function vn(e,t){return e===0?t.statusStopped:e===1?t.toolStepsStoppedOne:t.toolStepsStopped.replace(`{count}`,String(e))}const yn=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{}}},bn={get(e){try{return sessionStorage.getItem(e)}catch{return null}},set(e,t){try{sessionStorage.setItem(e,t)}catch{}},remove(e){try{sessionStorage.removeItem(e)}catch{}}},xn={maxBytes:10485760,maxCount:10,accept:`*/*`},Sn={voice:`local`},Cn={enabled:!0,sampleRate:1},wn={upload:`/pai/upload-file`,transcribe:`/pai/transcribe-audio`},Tn={variant:`circle`,size:`md`,label:void 0,icon:`chat`,hidden:!1},En={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`]},Dn={enabled:!0,volume:.3,events:void 0},On={enabled:!0,events:void 0},kn=[{label:`tabConversations`,layout:`chat`}],An=_.scope(`context`),jn=/* @__PURE__ */ new Set([`visitorId`,`conversationId`,`jwt`,`token`,`authorization`,`password`]),Mn=1024,Nn=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Pn(e){return Ln(e,`userContext`,!0)}function Fn(e){return Ln(e,`pageContext`,!1)}function In(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ln(e,t,n){if(e==null)return;if(!In(e)){An.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(jn.has(n)){An.warn(`dropped reserved ${t} key "${n}" — managed by the widget, not host-settable`);continue}if(a==null)continue;if(i>=50){An.warn(`${t} truncated at 50 keys — dropped "${n}"`);continue}let e=Rn(t,n,a);e!==void 0&&(r[n]=e,i++)}return n&&typeof r.email==`string`&&!Nn.test(r.email)&&(An.warn(`dropped malformed context field`,{field:`${t}.email`,reason:`invalid format`}),delete r.email),Object.keys(r).length>0?r:void 0}function Rn(e,t,n){if(typeof n==`boolean`)return n;if(typeof n==`number`){if(!Number.isFinite(n)){An.warn(`dropped non-finite ${e}.${t}`);return}return n}if(typeof n==`string`){let r=n.trim();return r===``?void 0:r.length>Mn?(An.warn(`truncated ${e}.${t} to ${Mn} chars`),r.slice(0,Mn)):r}An.warn(`dropped ${e}.${t} — only string/number/boolean values are allowed`,{type:typeof n})}function zn(e){let t=typeof e==`object`&&e?e:{},n=t.presentation??{},r=t.behavior??{},a=t.i18n??{},o=t.feedback??{},s=t.footer??{},c=t.header??{},l={enabled:t.history?.enabled??!0},{themeMode:u,themeOverrides:d}=Bn(t.theme),f=n.mode??`floating`,p=Vn(a.defaultLocale),m=a.availableLocales??[a.locale??p],h=Hn(a.locale??p,m,p),g=(t.baseUrl??i.defaultBaseUrl).replace(/\/$/,``),_=(t.agentApiBaseUrl??`${g}/api/agent`).replace(/\/$/,``),v=(t.dataApiBaseUrl??`${g}/api/data`).replace(/\/$/,``);return{widgetId:t.widgetId??`default`,publicKey:t.publicKey,aiAgentDeploymentId:t.aiAgentDeploymentId,baseUrl:g,agentApiBaseUrl:_,dataApiBaseUrl:v,userContext:Pn(t.userContext),pageContext:Fn(t.pageContext),position:n.position??(Nt(h)?`bottom-left`:`bottom-right`),themeMode:u,textSize:`normal`,themeOverrides:d,mode:f,responseMode:r.responseMode??`streaming`,showReasoning:r.showReasoning??!1,stepDisplay:Ut(r.stepDisplay,`visitor`),showSources:r.showSources??!1,enableMessageFeedback:!(r.disableMessageFeedback??!1),autoSendSuggestions:r.autoSendSuggestions??!1,cardAnswerWaitSeconds:r.cardAnswerWaitSeconds??60,popOutUrl:r.popOutUrl,features:{voice:t.features?.voice??Sn.voice,fileUpload:!(t.features?.disableFileUpload??!1),humanInLoop:!(t.features?.disableHumanInLoop??!1),emailTranscript:!(t.features?.disableEmailTranscript??!1),operatorRequest:t.features?.enableOperatorRequest===!0&&!(t.features.hideRequestOperatorButton??!1)},endpoints:{upload:t.endpoints?.upload??wn.upload,transcribe:t.endpoints?.transcribe??wn.transcribe},attachments:{accept:t.composer?.attachments?.accept??xn.accept,maxBytes:t.composer?.attachments?.maxBytes??xn.maxBytes,maxCount:t.composer?.attachments?.maxCount??xn.maxCount},locale:h,defaultLocale:p,availableLocales:m,startMinimized:r.startMinimized??!0,actions:Un(f,c.actions,l.enabled),size:{...n.size,resize:{...n.size?.resize,enabled:n.size?.resize?.enabled??!0}},launcher:Xn(t.launcher,t.agent?.name),sound:Wn(o.sound),haptics:Gn(o.haptics),strings:At(h,a.strings),stringsOverride:a.strings,composerDisclaimer:s.composerDisclaimer??``,header:{variant:c.variant??`plain`,notice:c.notice,showNotice:!(c.hideNotice??!1)},poweredBy:qn(s.poweredBy),composer:Jn(t.composer),modules:Yn(t.modules,l.enabled),tracking:Kn(t.tracking,v),history:l,storage:t.storage??yn,userToken:t.userToken,continueLink:t.continueLink,tools:t.tools,onMessage:t.onMessage,onOpen:t.onOpen,onClose:t.onClose,onError:t.onError}}function Bn(e){if(typeof e==`string`)return{themeMode:e,themeOverrides:{}};if(!e||typeof e!=`object`)return{themeMode:`host`,themeOverrides:{}};let{mode:t,...n}=e;return{themeMode:t??`host`,themeOverrides:n}}function Vn(e){return e&&e!==`auto`?e:globalThis.navigator?.language||`en`}function Hn(e,t,n){if(t.length<=1||t.includes(e))return e;let r=e.split(`-`)[0];return r&&t.includes(r)?r:t.includes(n)?n:t[0]??e}function Un(e,t,n){let r=t??En[e];return n?r:r.filter(e=>e!==`history`)}function Wn(e){return{enabled:e?.enabled??Dn.enabled,volume:e?.volume??Dn.volume,events:e?.events}}function Gn(e){return{enabled:e?.enabled??On.enabled,events:e?.events}}function Kn(e,t){let n=e?.sampleRate??Cn.sampleRate;return{enabled:e?.enabled??Cn.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 qn(e){return e?.text===``&&!e.logoUrl?null:{href:i.siteUrl,...e}}function Jn(e){let t=e?.sendButton;return{sendButton:{shape:t?.shape??`circle`,icon:t?.icon??`arrowUp`,variant:t?.variant??`filled`}}}function Yn(e,t){let n=(e??kn).slice(0,4),r=n.some(e=>e?.label&&e.layout===`help`),i=/* @__PURE__ */ new Set,a=[];for(let e of n){if(!e?.label||!e?.layout)continue;let n=e.contentCollectionIds?.filter(Boolean),o=e.id??n?.[0]??e.layout;for(;i.has(o);)o=`${o}-${a.length}`;i.add(o);let s={id:o,label:e.label,layout:e.layout};n?.length&&(s.contentCollectionIds=n),e.layout===`home`&&(s.brandName=e.brandName,s.greetingText=e.greetingText,s.showGreeting=!(e.hideGreeting??!1),s.showSearchBar=r&&!(e.hideSearchBar??!1),s.showRecentConversations=t&&!(e.hideRecentConversations??!1),e.userAvatars?.length&&(s.userAvatars=e.userAvatars),e.status&&(s.status=e.status),s.contentBlockTitle=e.contentBlockTitle),a.push(s)}return{list:a,byId:Object.fromEntries(a.map(e=>[e.id,e]))}}function Xn(e,t){let n=e?.callout?.text?{shape:`pill`,position:`auto`,delayMs:1200,autoDismissMs:0,animated:!0,persistent:!0,...e.callout}:null;return{variant:e?.variant??Tn.variant,size:e?.size??Tn.size,label:e?.label??Tn.label,icon:e?.icon??Tn.icon,hidden:e?.hidden??Tn.hidden,...t&&{personaName:t},callout:n}}function Zn(e,t){return e===`host`?`host`:t??e}function Qn(e,t,n,r){let i=Hn(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=At(i,e.stringsOverride)),n!==e.themeMode&&(a.themeMode=n),r!==e.textSize&&(a.textSize=r),a}function $n(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const er=[`agent`,`presentation`,`behavior`,`theme`,`launcher`,`header`,`composer`,`feedback`,`i18n`,`footer`,`features`,`tracking`,`endpoints`,`history`];function tr(e,t){if(!t)return e;let n={...e};for(let r of er){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]=nr($n(i)?i:{},$n(a)?a:void 0))}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=nr($n(i)?i:{},$n(r)?r:void 0);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=rr(a,t)),n.i18n=e}return n}function nr(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 rr(e,t){if(!e)return t;if(!t)return e;let n=Ft(e),r=Ft(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 ir=[`clear`,`expand`,`fullscreen`,`popOut`,`sound`,`history`,`language`,`theme`,`textSize`,`close`];function ar(e){return e!==`false`}function or(e){try{return Ht(JSON.parse(e))}catch{return}}function sr(e){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>=0?t:void 0}const cr=[[`public-key`,`publicKey`],[`ai-agent-deployment-id`,`aiAgentDeploymentId`],[`base-url`,`baseUrl`],[`agent-api-base-url`,`agentApiBaseUrl`],[`data-api-base-url`,`dataApiBaseUrl`],[`continue-link`,`continueLink`],[`theme`,`theme`,e=>e]],lr=[[`mode`,`mode`,e=>e],[`position`,`position`,e=>e]],ur=[[`width`,`width`],[`height`,`height`]],dr=[[`response-mode`,`responseMode`,e=>e],[`start-minimized`,`startMinimized`,ar],[`show-reasoning`,`showReasoning`,ar],[`step-display`,`stepDisplay`,or],[`show-sources`,`showSources`,ar],[`disable-message-feedback`,`disableMessageFeedback`,ar],[`auto-send-suggestions`,`autoSendSuggestions`,ar],[`card-answer-wait-seconds`,`cardAnswerWaitSeconds`,sr],[`pop-out-url`,`popOutUrl`]],fr=[[`locale`,`locale`]];new Set(ir);const pr=[[`launcher-variant`,`variant`,e=>e],[`launcher-size`,`size`,e=>e],[`launcher-icon`,`icon`],[`launcher-hidden`,`hidden`,ar]],mr=[[`features-disable-file-upload`,`disableFileUpload`,ar],[`features-disable-email-transcript`,`disableEmailTranscript`,ar],[`features-voice`,`voice`,e=>e]],hr=[[`endpoint-upload`,`upload`],[`endpoint-transcribe`,`transcribe`]],gr=[[`user-id`,`id`],[`user-email`,`email`],[`user-name`,`name`]],_r=[[`page-area`,`area`],[`page-url`,`url`],[`page-path`,`path`],[`page-title`,`title`]],vr=[`launcher-label`,`callout-text`,`callout-delay`,`actions`,`user-context`,`page-context`],yr=[cr,lr,ur,dr,fr,pr,mr,hr,gr,_r],br=/* @__PURE__ */ new Set([`start-minimized`]);[...yr.flatMap(e=>e.map(([e])=>e).filter(e=>!br.has(e))),...vr];const xr=_.scope(`track`);function Sr(e,t){let n=typeof e==`string`?e.trim():``;if(!n||n.length>64){xr.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?(xr.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 Cr(e){let t=[];return e.on(`hostEvent`,e=>{t.push({...e,at:Date.now()}),t.length>10&&t.shift()}),t}function wr(){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,Tr(t.subarray(6)),t[6]=(t[6]??0)&15|112,t[8]=(t[8]??0)&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 Tr(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 Er=_.scope(`persistence`);function Dr(e,t=yn,n){let r=n?`${e}.${n}`:e,a=`${i.cssPrefix}.${r}.storageVersion`,o=t.get(a)??void 0,s=o?`.v${o}`:``,c=`${i.cssPrefix}.${r}${s}`,l=`${i.cssPrefix}${s}.visitorId`,u=`${i.cssPrefix}${s}.lastUserSub`,d=`${c}.conversationId`,f=`${c}.userPrefs`,p=`${c}.panelOpen`,m=`${c}.panelSize`,h=`${c}.calloutDismissed`,g=`${c}.sidebarCollapsed`,_=`${c}.activeModule`,v=`${c}.seenNewsId`,y=`${c}.historyCount`,b=`${c}.loginReturn`,x=`${c}.loginPromptDismissedIn`,S={getVisitorId(){let e=t.get(l);if(e)return e;let n=wr();return t.set(l,n),n},loadLastUserSub(){return t.get(u)??void 0},saveLastUserSub(e){t.set(u,e)},loadConversationId(){return t.get(d)??void 0},saveConversationId(e){Er.trace(`saveConversationId`,{id:e,scope:r}),e?t.set(d,e):t.remove(d)},loadDraft(e){return t.get(`${c}.draft.${e}`)??``},saveDraft(e,n){let r=`${c}.draft.${e}`;n?t.set(r,n):t.remove(r)},loadMessageQueue(e){let n=t.get(`${c}.messageQueue.${e}`);if(!n)return[];try{let e=JSON.parse(n);return!Array.isArray(e)||!e.every(kr)?[]:e}catch(e){return Er.warn(`loadMessageQueue parse failed`,{error:e}),[]}},saveMessageQueue(e,n){let r=`${c}.messageQueue.${e}`;if(n.length===0)t.remove(r);else try{t.set(r,JSON.stringify(n))}catch(e){Er.warn(`saveMessageQueue serialise failed`,{error:e})}},loadUserPrefs(){let e=t.get(f);if(!e)return{};try{return Ar(JSON.parse(e))}catch(e){return Er.warn(`loadUserPrefs parse failed`,{error:e}),{}}},saveUserPrefs(e){try{t.set(f,JSON.stringify(e))}catch(e){Er.warn(`saveUserPrefs serialise failed`,{error:e})}},patchUserPrefs(e){let t=S.loadUserPrefs();S.saveUserPrefs({...t,...e})},loadPanelOpen(){let e=t.get(p);return e===`1`||e!==`0`&&null},savePanelOpen(e){t.set(p,e?`1`:`0`)},loadPanelSize(){let e=t.get(m);return e===`normal`||e===`expanded`||e===`fullscreen`?e:null},savePanelSize(e){t.set(m,e)},loadCalloutDismissed(e){if(!e)return!1;let n=t.get(h);return!!n&&n===e},saveCalloutDismissed(e){e?t.set(h,e):t.remove(h)},loadSidebarCollapsed(){let e=t.get(g);return e===`1`||e!==`0`&&null},saveSidebarCollapsed(e){t.set(g,e?`1`:`0`)},loadActiveModule(){return t.get(_)||null},saveActiveModule(e){t.set(_,e)},loadSeenNewsId(){return t.get(v)||null},saveSeenNewsId(e){t.set(v,e)},loadHistoryCount(){let e=t.get(y);if(!e)return null;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:null},saveHistoryCount(e){t.set(y,String(e))},rememberStorageVersion(e){e&&e!==t.get(a)&&(Er.debug(`rememberStorageVersion (force-reset on next load)`,{version:e}),t.set(a,e))},saveLoginReturn(e){bn.set(b,JSON.stringify(e))},takeLoginReturn(){let e=bn.get(b);if(e){bn.remove(b);try{let t=JSON.parse(e);return Or(t)&&typeof t.conversationId==`string`&&t.conversationId&&typeof t.draft==`string`?{conversationId:t.conversationId,draft:t.draft}:void 0}catch(e){Er.warn(`takeLoginReturn parse failed`,{error:e});return}}},loadLoginPromptDismissedIn(){return bn.get(x)??void 0},dismissLoginPromptIn(e){bn.set(x,e)},clearConversation(){t.remove(d)},reset(){let e=t.get(d);e&&(t.remove(`${c}.draft.${e}`),t.remove(`${c}.messageQueue.${e}`));for(let e of[b,x])bn.remove(e);for(let e of[l,u,d,f,m,h,g,_,v,y])t.remove(e);Er.info(`reset: forgot the visitor`,{scope:r})}};return S}function Or(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kr(e){return Or(e)&&typeof e.id==`string`&&e.id.length>0&&typeof e.text==`string`}function Ar(e){if(!Or(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),Or(e.widgetSize)&&typeof e.widgetSize.width==`number`&&typeof e.widgetSize.height==`number`&&(t.widgetSize={width:e.widgetSize.width,height:e.widgetSize.height}),t}const jr=`6.15.0`,Mr={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,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 Nr(){let e=navigator;return e.globalPrivacyControl===!0||e.doNotTrack===`1`}function Pr(){return location.origin+location.pathname}function Fr(){try{return document.referrer?new URL(document.referrer).origin:``}catch{return``}}function Ir(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||Nr()||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`,jr),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`,Pr());let h=Fr();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)}function l(e,t){return Mr[e]?.(t)}let u=Object.keys(Mr).filter(e=>Object.hasOwn(Mr,e)).map(t=>e.on(t,e=>c(t,l(t,e))));return()=>{for(let e of u)e();a.clear()}}const Lr=`: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, .55) 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}}
4
4
 
5
5
  *,*: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}
6
6
 
7
7
  .__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:18px;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;width:max-content;max-width:min(260px,calc(100vw - 100% - var(--__P__-callout-gap) - 32px));white-space:normal;overflow-wrap:anywhere}.__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)}.__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{flex-shrink:0;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;overflow:clip;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}: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: clamp(440px, 32vw, 640px);--__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;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:min(var(--__P__-widget-w, var(--__P__-panel-w)),calc(100vw - var(--__P__-inset-x) * 2));height:100%;min-width:min(var(--__P__-resize-min-w, 0px),calc(100vw - var(--__P__-inset-x) * 2));max-width:var(--__P__-resize-max-w, none);max-height:none;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}}@media(max-width:640px){:host([data-mode="open"][data-position]) .__P__-anchor,:host([data-mode="expanded"][data-position]) .__P__-anchor,:host([data-mode="drawer"][data-position]) .__P__-anchor,:host([data-mode="modal"][data-position]) .__P__-anchor{inset:var(--__P__-visual-viewport-top, 0px) 0 auto;align-items:stretch;width:auto;height:var(--__P__-visual-viewport-height, 100dvh);padding:0}:host([data-mode="open"][data-position]) .__P__-panel,:host([data-mode="expanded"][data-position]) .__P__-panel,:host([data-mode="drawer"][data-position]) .__P__-panel,:host([data-mode="modal"][data-position]) .__P__-panel{width:100vw;height:100%;min-width:0;min-height:0;max-width:none;max-height:none;border-radius:0;border:0;box-shadow:none;translate:none}:host([data-mode="modal"]){background:none;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__-header[data-variant=accent]{background:var(--__P__-accent);color:var(--__P__-on-accent);border-bottom-color:transparent}.__P__-header[data-variant=accent]>h1,.__P__-header[data-variant=accent] .__P__-agent-meta strong,.__P__-header[data-variant=accent] .__P__-agent-sub span,.__P__-header[data-variant=accent] .__P__-agent-ticket,.__P__-header[data-variant=accent] .__P__-agent-ticket:hover,.__P__-header[data-variant=accent]>.__P__-icon-btn,.__P__-header[data-variant=accent] .__P__-header-actions>.__P__-icon-btn,.__P__-header[data-variant=accent] .__P__-menu-wrap>.__P__-icon-btn{color:var(--__P__-on-accent);--__P__-focus: var(--__P__-on-accent)}.__P__-header[data-variant=accent]>.__P__-icon-btn:hover,.__P__-header[data-variant=accent] .__P__-header-actions>.__P__-icon-btn:hover,.__P__-header[data-variant=accent] .__P__-menu-wrap>.__P__-icon-btn:hover{background:color-mix(in oklch,var(--__P__-on-accent) 16%,transparent);color:var(--__P__-on-accent)}.__P__-header[data-variant=accent]>.__P__-icon-btn:active,.__P__-header[data-variant=accent] .__P__-header-actions>.__P__-icon-btn:active,.__P__-header[data-variant=accent] .__P__-menu-wrap>.__P__-icon-btn:active{background:color-mix(in oklch,var(--__P__-on-accent) 24%,transparent)}.__P__-header[data-variant=accent] .__P__-agent-avatar{background:color-mix(in oklch,var(--__P__-on-accent) 18%,transparent);color:var(--__P__-on-accent)}.__P__-header[data-variant=accent] .__P__-agent-avatar:after{border-color:var(--__P__-accent)}.__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:var(--__P__-radius-md);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);flex-shrink:0}.__P__-agent-avatar img{width:100%;height:100%;border-radius:inherit;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__-agent-sub{display:flex;gap:4px;min-width:0}.__P__-agent-sub button+span:before{content:"\\b7\\a0"}.__P__-agent-ticket{flex:none;font-size:var(--__P__-text-xs);color:var(--__P__-fg-muted);cursor:copy}.__P__-agent-ticket:hover{color:var(--__P__-fg)}.__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[data-cut-end=true]{mask-image:linear-gradient(to right,#000 calc(100% - 32px),transparent)}.__P__-suggestions[data-cut-start=true]{mask-image:linear-gradient(to right,transparent,#000 32px)}.__P__-suggestions[data-cut-start=true][data-cut-end=true]{mask-image:linear-gradient(to right,transparent,#000 32px,#000 calc(100% - 32px),transparent)}:host([dir="rtl"]) .__P__-suggestions[data-cut-end=true]{mask-image:linear-gradient(to left,#000 calc(100% - 32px),transparent)}:host([dir="rtl"]) .__P__-suggestions[data-cut-start=true]{mask-image:linear-gradient(to left,transparent,#000 32px)}:host([dir="rtl"]) .__P__-suggestions[data-cut-start=true][data-cut-end=true]{mask-image:linear-gradient(to left,transparent,#000 32px,#000 calc(100% - 32px),transparent)}.__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:0;bottom:14px;z-index:2;margin-inline:auto;display: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;overflow-anchor:none}.__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-body{display:flex;flex-wrap:wrap;align-items:flex-start;gap:var(--__P__-space-3) 6px;min-width:0}.__P__-bubble-body>*{flex:1 0 100%;min-width:0}.__P__-bubble-body>.__P__-source,.__P__-bubble-body>.__P__-typing{flex:0 1 auto}.__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,.__P__-steps){width:100%}.__P__-bubble-row[data-role=assistant] .__P__-bubble-col:has(.__P__-toolui,.__P__-steps) .__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 :not(pre)>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__-file-image,.__P__-file-chip{border-radius:var(--__P__-radius-sm);color:inherit;text-decoration:none}.__P__-file-image{display:block;width:fit-content;max-width:min(100%,240px);overflow:hidden}.__P__-file-image img{max-height:240px;object-fit:cover}.__P__-file-chip{display:flex;align-items:center;gap:var(--__P__-space-2);max-width:min(100%,280px);padding:var(--__P__-space-2);border:1px solid color-mix(in srgb,currentColor 18%,transparent);background:color-mix(in srgb,currentColor 5%,transparent);transition:background var(--__P__-dur-base) var(--__P__-ease)}.__P__-file-chip:hover{background:color-mix(in srgb,currentColor 10%,transparent)}.__P__-file-image:focus-visible,.__P__-file-chip:focus-visible{outline:2px solid currentColor;outline-offset:2px}.__P__-file-chip-icon{flex:none;display:grid;place-items:center;width:32px;height:32px;border-radius:var(--__P__-radius-sm);background:color-mix(in srgb,currentColor 10%,transparent)}.__P__-file-chip-text{display:grid;min-width:0;line-height:1.35}.__P__-file-chip-name{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.__P__-file-chip-meta{font-size:var(--__P__-text-xs);opacity:.75}.__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__-chat-notice{padding:0 var(--__P__-space-3);text-align:center;font-size:var(--__P__-text-xs);line-height:1.5;color:var(--__P__-fg-muted)}.__P__-chat-notice .__P__-md p{margin:0}.__P__-chat-notice .__P__-md a{color:var(--__P__-accent-fg)}.__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__-steps{min-width:0;font-size:var(--__P__-text-sm)}.__P__-steps-head,.__P__-steps-row-head{display:inline-flex;align-items:center;gap:var(--__P__-space-2);max-width:100%;min-width:0;min-height:28px;padding:0;border:0;background:none;color:var(--__P__-fg-muted);font:inherit;text-align:start;cursor:pointer;-webkit-tap-highlight-color:transparent}.__P__-steps-head:hover,.__P__-steps-row-head:hover{color:var(--__P__-fg)}.__P__-steps-head:focus-visible,.__P__-steps-row-head:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-steps-icon,.__P__-steps-row-icon{display:inline-flex;flex:none;align-items:center;justify-content:center;width:16px;height:16px}.__P__-steps-icon svg,.__P__-steps-row-icon svg{width:14px;height:14px}.__P__-steps-label,.__P__-steps-row-label{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-steps-sep{margin-inline:var(--__P__-space-1)}.__P__-steps-name .__P__-steps-count{margin-inline-start:var(--__P__-space-1)}.__P__-steps-count,.__P__-steps-failed,.__P__-steps-denied,.__P__-steps-time{flex:none;font-variant-numeric:tabular-nums}.__P__-steps-failed{color:var(--__P__-danger-text)}.__P__-steps-denied{color:var(--__P__-fg-muted)}.__P__-steps-decision{display:inline-flex;flex:none;align-items:center;gap:var(--__P__-space-1);font-variant-numeric:tabular-nums;color:var(--__P__-success)}.__P__-steps-decision[data-approved=false]{color:var(--__P__-warning)}.__P__-steps-decision svg{width:14px;height:14px}.__P__-steps-row-error{margin:0;color:var(--__P__-danger-text)}.__P__-steps-chevron{display:inline-flex;flex:none;width:16px;height:16px;transition:transform var(--__P__-dur-quick) var(--__P__-ease)}.__P__-steps-chevron svg{width:16px;height:16px}.__P__-steps-chevron[data-open=true]{transform:rotate(180deg)}.__P__-steps-list{position:relative;display:flex;flex-direction:column;gap:var(--__P__-space-1);margin:var(--__P__-space-1) 0 0;padding:0;list-style:none}.__P__-steps-list:before{content:"";position:absolute;inset-block:0;inset-inline-start:7px;width:2px;border-radius:1px;background:var(--__P__-border)}.__P__-steps-row{position:relative;display:grid;grid-template-columns:16px minmax(0,1fr);column-gap:var(--__P__-space-2);align-items:start}.__P__-steps-row .__P__-steps-row-icon{margin-block:6px;border-radius:999px;background:var(--__P__-bubble-assistant);color:var(--__P__-fg-muted)}.__P__-steps-row[data-status=error] .__P__-steps-row-icon{color:var(--__P__-danger-text)}.__P__-steps-row-main{display:flex;flex-direction:column;align-items:flex-start;min-width:0}.__P__-steps-row-name{color:var(--__P__-fg);font-weight:500}.__P__-steps-row-system,.__P__-steps-row-summary{margin-inline-start:var(--__P__-space-2);color:var(--__P__-fg-muted)}.__P__-steps-row-body{grid-column:2;display:flex;flex-direction:column;gap:var(--__P__-space-2);width:100%;margin:var(--__P__-space-1) 0 var(--__P__-space-2)}.__P__-steps-row[data-standalone=true]>:is(.__P__-steps-row-body,.__P__-steps-thought-text){grid-column:1 / -1}.__P__-steps-body{display:grid;grid-template-rows:0fr;transition:grid-template-rows .2s ease-out}.__P__-steps-body[data-open=true]{grid-template-rows:1fr}.__P__-steps-body-inner{min-height:0;overflow:hidden}.__P__-steps-live{min-width:0;overflow:hidden;text-overflow:ellipsis;background:linear-gradient(90deg,var(--__P__-fg-muted) 0%,var(--__P__-fg) 50%,var(--__P__-fg-muted) 100%) 0 0 / 200% 100%;background-clip:text;-webkit-background-clip:text;color:transparent;animation:__P__-steps-shimmer 2s linear infinite}@keyframes __P__-steps-shimmer{to{background-position:-200% 0}}@media(prefers-reduced-motion:reduce){.__P__-steps-body,.__P__-steps-chevron{transition:none}.__P__-steps-live{background:none;color:var(--__P__-fg-muted);animation:none}}.__P__-steps-thought,.__P__-steps-stopped-label{color:var(--__P__-fg-muted)}.__P__-steps-thought-label,.__P__-steps-stopped-label{display:inline-flex;align-items:center;min-height:28px}.__P__-steps-thought-text{grid-column:2;width:100%;margin:var(--__P__-space-1) 0 var(--__P__-space-2)}.__P__-reasoning-body{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%;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{--__P__-composer-line-height: 40px;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)}.__P__-textarea:placeholder-shown{white-space:nowrap;overflow:hidden}.__P__-textarea::placeholder{text-overflow:ellipsis}@media(pointer:coarse){.__P__-textarea{--__P__-textarea-base-height: 44px}.__P__-composer-row{--__P__-composer-line-height: 44px}.__P__-composer-row>.__P__-send{margin-block-end:2px}}.__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;margin-block-end:calc((var(--__P__-composer-line-height) - 32px) / 2)}.__P__-attachments{display:flex;flex-wrap:wrap;gap:6px}.__P__-attachment-chip{position:relative;display:inline-flex;align-items:center;gap:8px;padding:5px;border-radius:var(--__P__-radius-md);background:var(--__P__-bg-elevated);border:1px solid var(--__P__-border);font-size:var(--__P__-text-xs);max-width:220px;overflow:hidden}.__P__-attachment-chip[data-upload=error]{border-color:color-mix(in oklab,var(--__P__-danger) 45%,transparent);background:color-mix(in oklab,var(--__P__-danger) 6%,var(--__P__-bg-elevated))}.__P__-attachment-thumb{flex-shrink:0;width:32px;height:32px;border-radius:var(--__P__-radius-sm);object-fit:cover;background:var(--__P__-border);display:inline-flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted)}.__P__-attachment-text{display:flex;flex-direction:column;min-width:0;line-height:1.3}.__P__-attachment-name{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--__P__-fg);font-weight:500}.__P__-attachment-meta{display:inline-flex;align-items:center;gap:4px;color:var(--__P__-fg-muted);font-variant-numeric:tabular-nums;white-space:nowrap}.__P__-attachment-meta svg{flex:none;width:12px;height:12px}.__P__-attachment-chip[data-upload=error] .__P__-attachment-meta{color:var(--__P__-danger)}.__P__-attachment-chip[data-upload=done] .__P__-attachment-meta svg{color:var(--__P__-success)}.__P__-attachment-progress{position:absolute;inset-inline:0;bottom:0;height:2px;background:color-mix(in oklab,var(--__P__-accent) 15%,transparent)}.__P__-attachment-progress>span{display:block;height:100%;background:var(--__P__-accent);transition:width var(--__P__-dur-quick) var(--__P__-ease)}.__P__-attachment-remove{flex-shrink:0;width:24px;height:24px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;color:var(--__P__-fg-muted)}.__P__-attachment-remove svg{width:14px;height:14px}.__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%,color-mix(in srgb,var(--__P__-bg) 92%,transparent));display:flex;flex-direction:column;gap:10px;align-items:center;justify-content:center;text-align:center;padding:16px;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)}.__P__-dropzone-icon{display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;border-radius:999px;background:color-mix(in srgb,var(--__P__-accent) 14%,transparent)}.__P__-dropzone-icon svg{width:22px;height:22px}.__P__-dropzone[data-state=reject]{border-color:var(--__P__-danger);background:color-mix(in srgb,var(--__P__-danger) 8%,color-mix(in srgb,var(--__P__-bg) 92%,transparent));color:var(--__P__-danger)}.__P__-dropzone[data-state=reject] .__P__-dropzone-icon{background:color-mix(in srgb,var(--__P__-danger) 14%,transparent)}@keyframes __P__-fade-in{0%{opacity:0}to{opacity:1}}.__P__-error{display:flex;align-items:center;gap:var(--__P__-space-2);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)}.__P__-error-icon{display:inline-flex;flex:none;width:16px;height:16px;color:var(--__P__-danger-text)}.__P__-error-icon svg{width:16px;height:16px}.__P__-error-text{min-width:0}.__P__-error-retry{flex:none;margin-inline-start:auto;min-height:28px;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__-error-retry:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-history{flex:1;overflow-y:auto;padding:var(--__P__-space-2) var(--__P__-space-1) var(--__P__-space-3)}.__P__-history-footer{flex:none;padding:var(--__P__-space-2) var(--__P__-space-3) var(--__P__-space-3);border-top:1px solid var(--__P__-border);background:var(--__P__-surface)}.__P__-history-new{width:100%;display:flex;align-items:center;justify-content:center;gap:var(--__P__-space-2);padding:var(--__P__-space-2) var(--__P__-space-3);border:none;border-radius:var(--__P__-radius-md);background:var(--__P__-accent);color:var(--__P__-on-accent);cursor:pointer;font-size:var(--__P__-text-sm);font-weight:600;transition:filter var(--__P__-dur-quick) var(--__P__-ease-out),transform var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-history-new svg{width:16px;height:16px}.__P__-history-new:hover{filter:brightness(1.08)}.__P__-history-new:active{transform:translateY(1px)}.__P__-history-new:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-history-empty{flex:1;display:flex;align-items:center;justify-content:center;padding:40px 16px;color:var(--__P__-fg-muted);font-size:calc(14px * var(--__P__-text-scale));text-align:center}.__P__-history-group{display:flex;flex-direction:column;padding:0 var(--__P__-space-3)}.__P__-history-heading{font-size:var(--__P__-text-xs);font-weight:600;color:var(--__P__-fg-muted);padding:14px 4px 8px;text-transform:uppercase;letter-spacing:.04em}.__P__-history-card{display:flex;flex-direction:column;background:var(--__P__-surface);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-lg, 14px);overflow:hidden}.__P__-history-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:var(--__P__-radius-md);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-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:var(--__P__-radius-md)}.__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__-transcript-layer{position:absolute;inset:0;z-index:20;display:flex;align-items:center;justify-content:center;padding:var(--__P__-space-4);border-radius:inherit;overflow:hidden}.__P__-transcript-backdrop{position:absolute;inset:0;background:var(--__P__-backdrop);animation:__P__-transcript-fade var(--__P__-dur-base) var(--__P__-ease-out)}.__P__-transcript-sheet{position:relative;display:flex;flex-direction:column;gap:var(--__P__-space-3);box-sizing:border-box;width:100%;max-width:360px;padding:var(--__P__-space-4);border-radius:var(--__P__-radius-lg);background:var(--__P__-bg);color:var(--__P__-fg);box-shadow:var(--__P__-shadow-panel),inset 0 0 0 1px var(--__P__-border);animation:__P__-transcript-in var(--__P__-dur-base) var(--__P__-ease-out)}.__P__-transcript-sheet-head{display:flex;align-items:center;gap:var(--__P__-space-2);margin-block:-4px;margin-inline-end:-6px}.__P__-transcript-sheet-icon{display:inline-flex;align-items:center;justify-content:center;inline-size:28px;block-size:28px;flex-shrink:0;border-radius:var(--__P__-radius-sm);background:color-mix(in oklab,var(--__P__-accent) 12%,transparent);color:var(--__P__-accent-fg)}.__P__-transcript-sheet-icon svg{inline-size:16px;block-size:16px}.__P__-transcript-sheet-title{flex:1;min-width:0;margin:0;font-size:var(--__P__-text-base);font-weight:600;text-wrap:balance}.__P__-transcript-sheet-form{display:flex;flex-direction:column;gap:var(--__P__-space-3)}.__P__-transcript-sheet-text{margin:0;font-size:var(--__P__-text-sm);line-height:1.45;color:var(--__P__-fg-muted);overflow-wrap:anywhere;text-wrap:pretty}.__P__-transcript-sheet-sent{display:flex;align-items:flex-start;gap:var(--__P__-space-2);color:var(--__P__-fg)}.__P__-transcript-sheet-sent svg{flex-shrink:0;inline-size:18px;block-size:18px;color:var(--__P__-success)}.__P__-transcript-sheet-action{width:100%;min-height:44px;text-align:center;transition:filter var(--__P__-dur-quick) var(--__P__-ease-out),scale var(--__P__-dur-quick) var(--__P__-ease-out)}.__P__-transcript-sheet-action:active:not(:disabled){scale:.96}@keyframes __P__-transcript-fade{0%{opacity:0}}@keyframes __P__-transcript-in{0%{opacity:0;translate:0 8px}}@media(max-width:640px){.__P__-transcript-layer{align-items:flex-end;padding:0}.__P__-transcript-sheet{max-width:none;padding-bottom:calc(var(--__P__-space-4) + env(safe-area-inset-bottom,0px));border-end-start-radius:0;border-end-end-radius:0;animation-name:__P__-transcript-up}}@keyframes __P__-transcript-up{0%{translate:0 100%}}@media(prefers-reduced-motion:reduce){.__P__-transcript-backdrop,.__P__-transcript-sheet{animation:none}}.__P__-operator-banner{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:start;column-gap:10px;box-sizing:border-box;width:calc(100% - 2 * var(--__P__-space-3));max-width:var(--__P__-conversation-max, 768px);margin:0 auto var(--__P__-space-2);padding:10px 12px;border-radius:var(--__P__-radius-lg);background:var(--__P__-bg-elevated);box-shadow:inset 0 0 0 1px var(--__P__-border);color:var(--__P__-fg);font-size:var(--__P__-text-sm);line-height:1.45;text-align:start}.__P__-operator-label{text-wrap:pretty}.__P__-operator-pulse{width:8px;height:8px;margin-block-start:calc((1.45em - 8px)/2);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__-operator-banner[data-available=false] .__P__-operator-pulse{background:var(--__P__-warning);animation:none}.__P__-operator-banner[data-mode=operator] .__P__-operator-pulse{background:var(--__P__-success)}.__P__-operator-dismiss{width:28px;height:28px;margin-block:-4px;margin-inline-end:-6px}.__P__-operator-dismiss:before{inset:-8px}.__P__-operator-dismiss svg{width:16px;height:16px}@media(prefers-reduced-motion:reduce){.__P__-operator-banner[data-mode=awaiting-operator] .__P__-operator-pulse{animation:none}}@keyframes __P__-operator-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(.7)}}.__P__-login-bar{display:grid;grid-template-columns:auto minmax(0,1fr) auto auto;align-items:center;column-gap:10px;padding:6px 8px;padding-inline-start:14px;border-bottom:1px solid var(--__P__-border);background:var(--__P__-bg-elevated);color:var(--__P__-fg);font-size:var(--__P__-text-sm);line-height:1.4}.__P__-login-bar-icon,.__P__-login-gate-icon{display:inline-flex;color:var(--__P__-fg-muted)}.__P__-login-bar-icon svg{width:16px;height:16px}.__P__-login-bar-text{text-wrap:pretty}.__P__-login-bar[data-kind=user]{grid-template-columns:auto minmax(0,1fr);padding-inline-end:14px;color:var(--__P__-fg-muted)}.__P__-login-bar[data-kind=user] .__P__-login-bar-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.__P__-login-bar-action{appearance:none;border:0;cursor:pointer;padding:6px 12px;border-radius:999px;background:transparent;color:var(--__P__-accent-fg);font:inherit;font-weight:600;white-space:nowrap;transition:background var(--__P__-dur-quick) var(--__P__-ease)}.__P__-login-bar-action:hover{background:var(--__P__-hover)}.__P__-login-bar-action:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:1px}.__P__-login-bar-hide{width:28px;height:28px}.__P__-login-bar-hide:before{inset:-8px}.__P__-login-bar-hide svg{width:16px;height:16px}.__P__-login-gate{display:flex;flex-direction:column;align-items:center;gap:10px;box-sizing:border-box;width:calc(100% - 2 * var(--__P__-space-3));max-width:var(--__P__-conversation-max, 768px);margin:0 auto var(--__P__-space-3);padding:18px 16px;border-radius:var(--__P__-radius-lg);background:var(--__P__-bg-elevated);box-shadow:inset 0 0 0 1px var(--__P__-border);text-align:center}.__P__-login-gate[data-alone]{flex:1;justify-content:center;margin-block-start:var(--__P__-space-3);background:transparent;box-shadow:none}.__P__-login-gate-icon{align-items:center;justify-content:center;width:40px;height:40px;border-radius:50%;background:var(--__P__-bg);box-shadow:inset 0 0 0 1px var(--__P__-border)}.__P__-login-gate[data-alone] .__P__-login-gate-icon{width:48px;height:48px;background:var(--__P__-bg-elevated)}.__P__-login-gate-icon svg{width:20px;height:20px}.__P__-form-actions.__P__-login-gate-actions{justify-content:center;width:100%;max-width:320px;margin-top:var(--__P__-space-1)}.__P__-login-gate-title{margin:0;color:var(--__P__-fg);font-size:var(--__P__-text-md);font-weight:600;line-height:1.35;text-wrap:balance}.__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);color:var(--__P__-fg);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,.__P__-panel[data-resizing] .__P__-resize-grip{opacity:1}.__P__-resize-grip:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:-2px;border-radius:4px}.__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)}.__P__-resize-grip--edge{top:0;bottom:0;left:0;width:8px;height:auto;opacity:1;cursor:ew-resize}.__P__-resize-grip--edge:focus-visible{outline:none}.__P__-resize-grip--edge:after{content:"";position:absolute;top:var(--__P__-radius, 12px);bottom:var(--__P__-radius, 12px);left:0;width:2px;border-radius:1px;background:var(--__P__-focus);opacity:0;transition:opacity var(--__P__-dur-base) var(--__P__-ease)}:host([data-position$="-left"]) .__P__-resize-grip--edge,:host([data-position$="-left"]) .__P__-resize-grip--edge:after{left:auto;right:0}.__P__-resize-grip--edge:hover:after{opacity:1;transition-delay:.15s}.__P__-resize-grip--edge:focus-visible:after,.__P__-panel[data-resizing] .__P__-resize-grip--edge:after{opacity:1}@media(pointer:coarse){.__P__-resize-grip{width:24px;height:24px}.__P__-resize-grip--edge{width:14px;height:auto}}:host(:not([data-mode="open"]):not([data-mode="expanded"]):not([data-mode="drawer"])) .__P__-resize-grip{display:none}@media(max-width:640px){.__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:var(--__P__-radius-md);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:var(--__P__-radius-md);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__-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__-panel-notice{display:flex;align-items:center;justify-content:center;position:relative;padding:var(--__P__-space-6);text-align:center}.__P__-panel-notice-close{position:absolute;top:12px;inset-inline-end:12px}.__P__-panel-notice-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__-toolui{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)}.__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=done]{--__P__-pill: var(--__P__-success, #16a34a)}.__P__-toolui-status[data-status=approved],.__P__-toolui-status[data-status=submitted]{--__P__-pill: oklch(.62 .15 255)}.__P__-toolui-status[data-status=waiting]{--__P__-pill: var(--__P__-warning, #f59e0b)}.__P__-toolui-status[data-status=declined]{--__P__-pill: oklch(.66 .16 45)}.__P__-toolui-status[data-status=failed]{--__P__-pill: var(--__P__-danger, #dc2626)}.__P__-toolui-status[data-status=replaced],.__P__-toolui-status[data-status=running],.__P__-toolui-status[data-status=stopped]{--__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-system{min-width:0;overflow:hidden;color:var(--__P__-fg-muted);text-overflow:ellipsis;white-space:nowrap}.__P__-toolui-preview{min-width:0}.__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-fields{max-height:240px;overflow:auto;overscroll-behavior:contain;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-sm)}.__P__-toolui-fields table{width:100%;border-collapse:collapse;font-size:var(--__P__-text-sm);line-height:1.5}.__P__-toolui-fields tr:nth-child(2n){background:color-mix(in oklab,var(--__P__-fg) 4%,transparent)}.__P__-toolui-fields tr+tr{border-top:1px solid var(--__P__-border)}.__P__-toolui-fields th,.__P__-toolui-fields td{padding:6px var(--__P__-space-2);text-align:start;vertical-align:top}.__P__-toolui-fields th{width:1%;color:var(--__P__-fg-muted);font-weight:400;white-space:nowrap}.__P__-toolui-fields td{color:var(--__P__-fg);white-space:pre-wrap;overflow-wrap:anywhere}.__P__-toolui-fields[data-plain=true]{border:0;border-radius:0}.__P__-toolui-fields[data-plain=true] tr:nth-child(2n){background:none}.__P__-toolui-fields[data-plain=true] tr+tr{border-top:0}.__P__-toolui-fields[data-plain=true] th,.__P__-toolui-fields[data-plain=true] td{padding:1px var(--__P__-space-2) 1px 0}.__P__-toolui-raw>summary{width:fit-content;color:var(--__P__-fg-muted);cursor:pointer}.__P__-toolui-raw>summary:hover{color:var(--__P__-fg)}.__P__-toolui-raw>summary:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px;border-radius:var(--__P__-radius-sm)}.__P__-toolui-raw[open]{display:flex;flex-direction:column;gap:var(--__P__-space-2)}.__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}
8
8
 
9
- .__P__-generative-ui{display:grid;grid-template-columns:minmax(0,1fr);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);gap:16px}.__P__-generative-ui-cell{display:flex;flex-direction:column;align-self:start;min-width:0;gap:16px}.__P__-generative-ui-grid[data-equal-heights]>.__P__-generative-ui-cell{align-self:stretch}.__P__-generative-ui-grid[data-equal-heights]>.__P__-generative-ui-cell>:only-child{flex:1}@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:flex;flex-direction:column;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{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-3);font-size:1.6em;font-weight:700;font-variant-numeric:tabular-nums}.__P__-generative-ui-metric svg{flex:none;width:80px;height:24px;color:var(--__P__-accent)}.__P__-generative-ui-change{align-self:flex-start;padding:2px var(--__P__-space-2);border-radius:var(--__P__-radius-sm);background:var(--__P__-hover);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600;font-variant-numeric:tabular-nums}.__P__-generative-ui-change[data-tone=good]{color:var(--__P__-fg);background:color-mix(in oklch,var(--__P__-success) 18%,transparent)}.__P__-generative-ui-change[data-tone=bad]{color:var(--__P__-danger-text);background:var(--__P__-danger-bg)}.__P__-generative-ui-table-card{container:__P__-generative-ui-table / inline-size}.__P__-generative-ui-table{overflow-x:auto}@container __P__-generative-ui-table (max-width: 639.98px){.__P__-generative-ui-table :is(table,tbody,tr,td){display:block}.__P__-generative-ui-table thead{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}.__P__-generative-ui-table tr{margin-bottom:var(--__P__-space-2);padding:var(--__P__-space-1) var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-sm)}.__P__-generative-ui-table td,.__P__-generative-ui-table td[data-numeric=true]{display:flex;justify-content:space-between;gap:var(--__P__-space-3);padding:var(--__P__-space-1) 0;border:0;text-align:end}.__P__-generative-ui-table td:before{content:attr(data-label);color:var(--__P__-fg-muted);text-align:start}}.__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 :is(th,td)[data-numeric=true]{text-align:end;font-variant-numeric:tabular-nums}.__P__-generative-ui th button{padding:0;border:0;background:none;color:inherit;font:inherit;font-weight:600;text-align:inherit;cursor:pointer}.__P__-generative-ui th button:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-generative-ui th[aria-sort=ascending] button:after{content:" \\2191"}.__P__-generative-ui th[aria-sort=descending] button:after{content:" \\2193"}.__P__-generative-ui-chart{display:block;width:100%;max-height:320px;color:var(--__P__-accent)}.__P__-generative-ui-axis line{stroke:var(--__P__-border)}.__P__-generative-ui-axis text{fill:var(--__P__-fg-muted);font-size:9px}.__P__-generative-ui .__P__-generative-ui-legend{display:flex;flex-wrap:wrap;gap:var(--__P__-space-1) var(--__P__-space-3);margin:0;padding:0;list-style:none;color:var(--__P__-accent);font-size:var(--__P__-text-xs)}.__P__-generative-ui-legend li{display:flex;align-items:center;gap:6px;margin:0}.__P__-generative-ui-legend li:before{content:"";width:10px;height:10px;border-radius:3px;background:currentColor}.__P__-generative-ui-legend span{color:var(--__P__-fg)}.__P__-generative-ui-carousel{display:flex;gap:var(--__P__-space-3);margin:0 calc(var(--__P__-space-1) * -1);padding:0 var(--__P__-space-1) var(--__P__-space-2);overflow-x:auto;scroll-snap-type:x mandatory;scroll-padding-inline:var(--__P__-space-1);scrollbar-width:thin;min-width:0}.__P__-generative-ui-card,.__P__-generative-ui-offer{--__P__-card-width: 280px}.__P__-generative-ui-flight{--__P__-card-width: 300px}.__P__-generative-ui-sheet{--__P__-card-width: 480px}.__P__-generative-ui>section,.__P__-generative-ui-carousel>[role=listitem]>section{width:var(--__P__-card-width, 100%);max-width:100%}.__P__-generative-ui-carousel>[role=listitem]{display:flex;flex:none;max-width:100%;scroll-snap-align:start}.__P__-generative-ui-offer{overflow:hidden}.__P__-generative-ui-footer{display:flex;flex-direction:column;gap:var(--__P__-space-2);margin-top:auto}.__P__-generative-ui-hint{min-height:1.4em;line-height:1.4;color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs)}.__P__-generative-ui-photo{position:relative;display:block;flex:none;width:calc(100% + 2 * var(--__P__-space-3));aspect-ratio:4 / 3;margin:calc(var(--__P__-space-3) * -1) calc(var(--__P__-space-3) * -1) var(--__P__-space-1);overflow:hidden;background:var(--__P__-hover)}.__P__-generative-ui-photo[data-wide=true]{aspect-ratio:16 / 9}.__P__-generative-ui-badges{display:flex;flex-wrap:wrap;gap:var(--__P__-space-1)}.__P__-generative-ui-photo>.__P__-generative-ui-badges{position:absolute;top:var(--__P__-space-2);inset-inline-start:var(--__P__-space-2)}.__P__-generative-ui-photo .__P__-generative-ui-pill{background:var(--__P__-bg-elevated);color:var(--__P__-fg);box-shadow:0 0 0 1px var(--__P__-border)}.__P__-generative-ui-thumb{display:block;flex:0 0 auto;width:48px;height:48px;overflow:hidden;border-radius:var(--__P__-radius-sm);background:var(--__P__-hover)}.__P__-generative-ui-photo img,.__P__-generative-ui-thumb img{display:block;width:100%;max-width:none;height:100%;object-fit:cover}.__P__-generative-ui-heading{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:var(--__P__-space-2)}.__P__-generative-ui-stars{color:var(--__P__-warning);font-size:var(--__P__-text-xs);letter-spacing:1px}.__P__-generative-ui .__P__-generative-ui-details{display:grid;gap:2px;margin:0;padding:0;list-style:none;color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs)}.__P__-generative-ui-details li{display:flex;gap:6px;margin:0}.__P__-generative-ui-details li:before{content:"\\2022";flex:none}.__P__-generative-ui-leg{display:grid;grid-template-columns:minmax(0,1fr);gap:2px}.__P__-generative-ui-leg+.__P__-generative-ui-leg{padding-top:var(--__P__-space-2);border-top:1px solid var(--__P__-border)}.__P__-generative-ui-leg-times{display:flex;align-items:center;gap:var(--__P__-space-1)}.__P__-generative-ui-leg-times>span:not(.__P__-generative-ui-leg-path){display:grid;flex:none;color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600}.__P__-generative-ui-leg-times>span:last-child{text-align:end}.__P__-generative-ui-leg-times strong{color:var(--__P__-fg);font-size:1rem;font-variant-numeric:tabular-nums;white-space:nowrap}.__P__-generative-ui-leg-times sup{font-size:.6em;color:var(--__P__-fg-muted)}.__P__-generative-ui-leg-path{flex:1;min-width:0;padding-bottom:4px;border-bottom:1px solid var(--__P__-border-strong);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);line-height:1.3;text-align:center;overflow-wrap:normal}.__P__-generative-ui .__P__-generative-ui-itinerary{display:grid;gap:var(--__P__-space-2);margin:0;padding:0;list-style:none}.__P__-generative-ui-itinerary li{display:grid;margin:0;padding-inline-start:var(--__P__-space-3);border-inline-start:2px solid var(--__P__-border-strong)}.__P__-generative-ui-title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;line-height:1.35;min-height:2.7em}.__P__-generative-ui a{color:inherit}.__P__-generative-ui .__P__-generative-ui-title a,.__P__-generative-ui .__P__-generative-ui-lines a,.__P__-generative-ui .__P__-generative-ui-actions>a{text-decoration:none}.__P__-generative-ui .__P__-generative-ui-title a:hover,.__P__-generative-ui .__P__-generative-ui-lines span>a:hover{text-decoration:underline}.__P__-generative-ui-pill{display:inline-flex;align-items:center;padding:2px var(--__P__-space-2);border-radius:var(--__P__-radius-sm);background:var(--__P__-hover);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600}.__P__-generative-ui-muted{color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs)}.__P__-generative-ui-star{color:var(--__P__-warning)}.__P__-generative-ui-price{display:flex;flex-wrap:wrap;align-items:baseline;gap:0 var(--__P__-space-2);font-variant-numeric:tabular-nums}.__P__-generative-ui-price strong{font-size:1.1em}.__P__-generative-ui-price s{color:var(--__P__-fg-muted)}.__P__-generative-ui-description{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden;color:var(--__P__-fg-muted)}.__P__-generative-ui-option{display:grid;gap:var(--__P__-space-1);min-width:0;margin:0;padding:0;border:0}.__P__-generative-ui-option legend{padding:0 0 var(--__P__-space-1);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600}.__P__-generative-ui-option div{display:flex;gap:6px;min-width:0;margin:-4px;padding:4px;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}.__P__-generative-ui-option div::-webkit-scrollbar{display:none}.__P__-generative-ui-option div[data-cut-end]{mask-image:linear-gradient(to right,#000 calc(100% - 32px),transparent)}.__P__-generative-ui-option div[data-cut-start]{mask-image:linear-gradient(to right,transparent,#000 32px)}.__P__-generative-ui-option div[data-cut-start][data-cut-end]{mask-image:linear-gradient(to right,transparent,#000 32px,#000 calc(100% - 32px),transparent)}.__P__-generative-ui-option div:dir(rtl)[data-cut-end]{mask-image:linear-gradient(to left,#000 calc(100% - 32px),transparent)}.__P__-generative-ui-option div:dir(rtl)[data-cut-start]{mask-image:linear-gradient(to left,transparent,#000 32px)}.__P__-generative-ui-option div:dir(rtl)[data-cut-start][data-cut-end]{mask-image:linear-gradient(to left,transparent,#000 32px,#000 calc(100% - 32px),transparent)}.__P__-generative-ui-option button{flex:0 0 auto;min-height:32px;padding:0 10px;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-sm);background:var(--__P__-bg-elevated);color:var(--__P__-fg);font:inherit;font-size:var(--__P__-text-sm);white-space:nowrap;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-generative-ui-option button:hover{border-color:var(--__P__-border-strong)}.__P__-generative-ui-option button[aria-pressed=true]{border-color:var(--__P__-accent);box-shadow:inset 0 0 0 1px var(--__P__-accent);font-weight:600}.__P__-generative-ui-option button:disabled{color:var(--__P__-fg-muted);text-decoration:line-through;opacity:.6;cursor:not-allowed}.__P__-generative-ui-actions{display:flex;flex-wrap:wrap;gap:var(--__P__-space-2);margin-top:auto;padding-top:var(--__P__-space-1)}.__P__-generative-ui-actions:not([data-small=true])>*{flex:1 1 auto}.__P__-generative-ui-actions>*{display:inline-flex;align-items:center;justify-content:center;min-height:36px;padding:0 var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-sm);background:var(--__P__-bg-elevated);color:var(--__P__-fg);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;text-decoration:none;white-space:nowrap;min-width:0;overflow:hidden;text-overflow:ellipsis;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-generative-ui-actions>*>span{overflow:hidden;text-overflow:ellipsis}.__P__-generative-ui-actions[data-small=true]>*{min-height:28px;padding:0 var(--__P__-space-2);font-size:var(--__P__-text-xs)}.__P__-generative-ui-actions>:hover{border-color:var(--__P__-border-strong)}.__P__-generative-ui-actions>[data-primary=true]{border-color:var(--__P__-accent);background:var(--__P__-accent);color:var(--__P__-on-accent)}.__P__-generative-ui-actions>:focus-visible,.__P__-generative-ui-option button:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-generative-ui-actions>:disabled{border-color:var(--__P__-border);background:var(--__P__-hover);color:var(--__P__-fg-muted);cursor:not-allowed}.__P__-generative-ui .__P__-generative-ui-lines{display:grid;margin:0;padding:0;list-style:none}.__P__-generative-ui .__P__-generative-ui-lines li{display:flex;margin:0;gap:var(--__P__-space-3);padding:var(--__P__-space-2) 0;border-bottom:1px solid var(--__P__-border)}.__P__-generative-ui .__P__-generative-ui-lines li:first-child{padding-top:0}.__P__-generative-ui-lines li>div{display:grid;flex:1;gap:2px;min-width:0}.__P__-generative-ui-line-head{display:flex;align-items:baseline;gap:var(--__P__-space-3)}.__P__-generative-ui-line-head>span{display:-webkit-box;flex:1;min-width:0;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:2}.__P__-generative-ui-line-head>strong{flex:none;font-variant-numeric:tabular-nums}.__P__-generative-ui-totals{display:grid;gap:var(--__P__-space-1);margin:0;font-variant-numeric:tabular-nums}.__P__-generative-ui-totals div{display:flex;justify-content:space-between;gap:var(--__P__-space-3);color:var(--__P__-fg-muted)}.__P__-generative-ui-totals div:last-child{padding-top:var(--__P__-space-1);color:var(--__P__-fg);font-weight:700}.__P__-generative-ui-totals dt{min-width:0}.__P__-generative-ui-totals dd{flex:none;margin:0;white-space:nowrap}.__P__-generative-ui-notice{padding:var(--__P__-space-2) var(--__P__-space-3);border-radius:var(--__P__-radius-sm);background:var(--__P__-hover)}.__P__-generative-ui-notice[data-severity=warning]{color:var(--__P__-fg);background:color-mix(in oklch,var(--__P__-warning) 16%,transparent)}.__P__-generative-ui-notice[data-severity=error]{color:var(--__P__-danger-text);background:var(--__P__-danger-bg)}.__P__-generative-ui .__P__-generative-ui-timeline{display:grid;gap:var(--__P__-space-2);margin:0;padding:0;list-style:none}.__P__-generative-ui .__P__-generative-ui-timeline li{display:flex;margin:0;align-items:baseline;gap:var(--__P__-space-2);color:var(--__P__-fg-muted)}.__P__-generative-ui-timeline li:before{content:"";flex:0 0 auto;width:8px;height:8px;border:2px solid var(--__P__-border-strong);border-radius:50%}.__P__-generative-ui-timeline li[data-done=true]{color:var(--__P__-fg);font-weight:600}.__P__-generative-ui-timeline li[data-done=true]:before{border-color:var(--__P__-accent);background:var(--__P__-accent)}.__P__-generative-ui-timeline li>:first-child{flex:1}@media(pointer:coarse){.__P__-generative-ui-actions>*{min-height:44px}.__P__-generative-ui-actions>*>span{overflow:hidden;text-overflow:ellipsis}.__P__-generative-ui-actions[data-small=true]>*{min-height:32px}.__P__-generative-ui-option button{min-height:40px}}
9
+ .__P__-generative-ui{display:grid;grid-template-columns:minmax(0,1fr);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{--__P__-cols: 1;display:flex;flex-wrap:wrap;gap:16px}.__P__-generative-ui-cell{display:flex;flex-direction:column;flex:1 1 calc((100% + 16px) * min(var(--__P__-span),var(--__P__-cols)) / var(--__P__-cols) - 16.5px);align-self:flex-start;min-width:0;gap:16px}.__P__-generative-ui-grid[data-equal-heights]>.__P__-generative-ui-cell{align-self:stretch}.__P__-generative-ui-grid[data-equal-heights]>.__P__-generative-ui-cell>:only-child{flex:1}@container __P__-generative-ui-grid (min-width: 496px){.__P__-generative-ui-grid{--__P__-cols: var(--__P__-cols-2)}}@container __P__-generative-ui-grid (min-width: 752px){.__P__-generative-ui-grid{--__P__-cols: var(--__P__-cols-3)}}@container __P__-generative-ui-grid (min-width: 1008px){.__P__-generative-ui-grid{--__P__-cols: var(--__P__-cols-4)}}.__P__-generative-ui section{display:flex;flex-direction:column;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{display:flex;align-items:center;justify-content:space-between;gap:var(--__P__-space-3);font-size:1.6em;font-weight:700;font-variant-numeric:tabular-nums}.__P__-generative-ui-metric svg{flex:none;width:80px;height:24px;color:var(--__P__-accent)}.__P__-generative-ui-change{align-self:flex-start;padding:2px var(--__P__-space-2);border-radius:var(--__P__-radius-sm);background:var(--__P__-hover);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600;font-variant-numeric:tabular-nums}.__P__-generative-ui-change[data-tone=good]{color:var(--__P__-fg);background:color-mix(in oklch,var(--__P__-success) 18%,transparent)}.__P__-generative-ui-change[data-tone=bad]{color:var(--__P__-danger-text);background:var(--__P__-danger-bg)}.__P__-generative-ui-table-card{container:__P__-generative-ui-table / inline-size}.__P__-generative-ui-table{overflow-x:auto}@container __P__-generative-ui-table (max-width: 639.98px){.__P__-generative-ui-table :is(table,tbody,tr,td){display:block}.__P__-generative-ui-table thead{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}.__P__-generative-ui-table tr{margin-bottom:var(--__P__-space-2);padding:var(--__P__-space-1) var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-sm)}.__P__-generative-ui-table td,.__P__-generative-ui-table td[data-numeric=true]{display:flex;justify-content:space-between;gap:var(--__P__-space-3);padding:var(--__P__-space-1) 0;border:0;text-align:end}.__P__-generative-ui-table td:before{content:attr(data-label);color:var(--__P__-fg-muted);text-align:start}}.__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 :is(th,td)[data-numeric=true]{text-align:end;font-variant-numeric:tabular-nums}.__P__-generative-ui th button{padding:0;border:0;background:none;color:inherit;font:inherit;font-weight:600;text-align:inherit;cursor:pointer}.__P__-generative-ui th button:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-generative-ui th[aria-sort=ascending] button:after{content:" \\2191"}.__P__-generative-ui th[aria-sort=descending] button:after{content:" \\2193"}.__P__-generative-ui-chart{display:block;width:100%;max-height:320px;color:var(--__P__-accent)}.__P__-generative-ui-axis line{stroke:var(--__P__-border)}.__P__-generative-ui-axis text{fill:var(--__P__-fg-muted);font-size:9px}.__P__-generative-ui .__P__-generative-ui-legend{display:flex;flex-wrap:wrap;gap:var(--__P__-space-1) var(--__P__-space-3);margin:0;padding:0;list-style:none;color:var(--__P__-accent);font-size:var(--__P__-text-xs)}.__P__-generative-ui-legend li{display:flex;align-items:center;gap:6px;margin:0}.__P__-generative-ui-legend li:before{content:"";width:10px;height:10px;border-radius:3px;background:currentColor}.__P__-generative-ui-legend span{color:var(--__P__-fg)}.__P__-generative-ui-carousel{display:flex;gap:var(--__P__-space-3);margin:0 calc(var(--__P__-space-1) * -1);padding:0 var(--__P__-space-1) var(--__P__-space-2);overflow-x:auto;scroll-snap-type:x mandatory;scroll-padding-inline:var(--__P__-space-1);scrollbar-width:thin;min-width:0}.__P__-generative-ui-card:has(>.__P__-generative-ui-photo),.__P__-generative-ui-offer{--__P__-card-width: 280px}.__P__-generative-ui-flight{--__P__-card-width: 300px}.__P__-generative-ui-sheet{--__P__-card-width: 480px}.__P__-generative-ui>section,.__P__-generative-ui-carousel>[role=listitem]>section{width:var(--__P__-card-width, 100%);max-width:100%}.__P__-generative-ui-cell>section{max-width:var(--__P__-card-width, 100%)}.__P__-generative-ui-carousel>[role=listitem]{display:flex;flex:none;max-width:100%;scroll-snap-align:start}.__P__-generative-ui-offer{overflow:hidden}.__P__-generative-ui-footer{display:flex;flex-direction:column;gap:var(--__P__-space-2);margin-top:auto}.__P__-generative-ui-hint{min-height:1.4em;line-height:1.4;color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs)}.__P__-generative-ui-photo{position:relative;display:block;flex:none;width:calc(100% + 2 * var(--__P__-space-3));aspect-ratio:4 / 3;margin:calc(var(--__P__-space-3) * -1) calc(var(--__P__-space-3) * -1) var(--__P__-space-1);overflow:hidden;background:var(--__P__-hover)}.__P__-generative-ui-photo[data-wide=true]{aspect-ratio:16 / 9}.__P__-generative-ui-badges{display:flex;flex-wrap:wrap;gap:var(--__P__-space-1)}.__P__-generative-ui-photo>.__P__-generative-ui-badges{position:absolute;top:var(--__P__-space-2);inset-inline-start:var(--__P__-space-2)}.__P__-generative-ui-photo .__P__-generative-ui-pill{background:var(--__P__-bg-elevated);color:var(--__P__-fg);box-shadow:0 0 0 1px var(--__P__-border)}.__P__-generative-ui-thumb{display:block;flex:0 0 auto;width:48px;height:48px;overflow:hidden;border-radius:var(--__P__-radius-sm);background:var(--__P__-hover)}.__P__-generative-ui-photo img,.__P__-generative-ui-thumb img{display:block;width:100%;max-width:none;height:100%;object-fit:cover}.__P__-generative-ui-heading{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:var(--__P__-space-2)}.__P__-generative-ui-stars{color:var(--__P__-warning);font-size:var(--__P__-text-xs);letter-spacing:1px}.__P__-generative-ui .__P__-generative-ui-details{display:grid;gap:2px;margin:0;padding:0;list-style:none;color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs)}.__P__-generative-ui-details li{display:flex;gap:6px;margin:0}.__P__-generative-ui-details li:before{content:"\\2022";flex:none}.__P__-generative-ui-leg{display:grid;grid-template-columns:minmax(0,1fr);gap:2px}.__P__-generative-ui-leg+.__P__-generative-ui-leg{padding-top:var(--__P__-space-2);border-top:1px solid var(--__P__-border)}.__P__-generative-ui-leg-times{display:flex;align-items:center;gap:var(--__P__-space-1)}.__P__-generative-ui-leg-times>span:not(.__P__-generative-ui-leg-path){display:grid;flex:none;color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600}.__P__-generative-ui-leg-times>span:last-child{text-align:end}.__P__-generative-ui-leg-times strong{color:var(--__P__-fg);font-size:1rem;font-variant-numeric:tabular-nums;white-space:nowrap}.__P__-generative-ui-leg-times sup{font-size:.6em;color:var(--__P__-fg-muted)}.__P__-generative-ui-leg-path{flex:1;min-width:0;padding-bottom:4px;border-bottom:1px solid var(--__P__-border-strong);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);line-height:1.3;text-align:center;overflow-wrap:normal}.__P__-generative-ui .__P__-generative-ui-itinerary{display:grid;gap:var(--__P__-space-2);margin:0;padding:0;list-style:none}.__P__-generative-ui-itinerary li{display:grid;margin:0;padding-inline-start:var(--__P__-space-3);border-inline-start:2px solid var(--__P__-border-strong)}.__P__-generative-ui-title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;line-height:1.35}:is(.__P__-generative-ui-carousel,.__P__-generative-ui-cell) .__P__-generative-ui-title{min-height:2.7em}.__P__-generative-ui a{color:inherit}.__P__-generative-ui .__P__-generative-ui-title a,.__P__-generative-ui .__P__-generative-ui-lines a,.__P__-generative-ui .__P__-generative-ui-actions>a{text-decoration:none}.__P__-generative-ui .__P__-generative-ui-title a:hover,.__P__-generative-ui .__P__-generative-ui-lines span>a:hover{text-decoration:underline}.__P__-generative-ui-pill{display:inline-flex;align-items:center;padding:2px var(--__P__-space-2);border-radius:var(--__P__-radius-sm);background:var(--__P__-hover);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600}.__P__-generative-ui-muted{color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs)}.__P__-generative-ui-star{color:var(--__P__-warning)}.__P__-generative-ui-price{display:flex;flex-wrap:wrap;align-items:baseline;gap:0 var(--__P__-space-2);font-variant-numeric:tabular-nums}.__P__-generative-ui-price strong{font-size:1.1em}.__P__-generative-ui-price s{color:var(--__P__-fg-muted)}.__P__-generative-ui-description{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden;color:var(--__P__-fg-muted)}.__P__-generative-ui-option{display:grid;gap:var(--__P__-space-1);min-width:0;margin:0;padding:0;border:0}.__P__-generative-ui-option legend{padding:0 0 var(--__P__-space-1);color:var(--__P__-fg-muted);font-size:var(--__P__-text-xs);font-weight:600}.__P__-generative-ui-option div{display:flex;gap:6px;min-width:0;margin:-4px;padding:4px;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}.__P__-generative-ui-option div::-webkit-scrollbar{display:none}.__P__-generative-ui-option div[data-cut-end]{mask-image:linear-gradient(to right,#000 calc(100% - 32px),transparent)}.__P__-generative-ui-option div[data-cut-start]{mask-image:linear-gradient(to right,transparent,#000 32px)}.__P__-generative-ui-option div[data-cut-start][data-cut-end]{mask-image:linear-gradient(to right,transparent,#000 32px,#000 calc(100% - 32px),transparent)}.__P__-generative-ui-option div:dir(rtl)[data-cut-end]{mask-image:linear-gradient(to left,#000 calc(100% - 32px),transparent)}.__P__-generative-ui-option div:dir(rtl)[data-cut-start]{mask-image:linear-gradient(to left,transparent,#000 32px)}.__P__-generative-ui-option div:dir(rtl)[data-cut-start][data-cut-end]{mask-image:linear-gradient(to left,transparent,#000 32px,#000 calc(100% - 32px),transparent)}.__P__-generative-ui-option button{flex:0 0 auto;min-height:32px;padding:0 10px;border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-sm);background:var(--__P__-bg-elevated);color:var(--__P__-fg);font:inherit;font-size:var(--__P__-text-sm);white-space:nowrap;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-generative-ui-option button:hover{border-color:var(--__P__-border-strong)}.__P__-generative-ui-option button[aria-pressed=true]{border-color:var(--__P__-accent);box-shadow:inset 0 0 0 1px var(--__P__-accent);font-weight:600}.__P__-generative-ui-option button:disabled{color:var(--__P__-fg-muted);text-decoration:line-through;opacity:.6;cursor:not-allowed}.__P__-generative-ui-actions{display:flex;flex-wrap:wrap;gap:var(--__P__-space-2);margin-top:auto;padding-top:var(--__P__-space-1)}.__P__-generative-ui-actions:not([data-small=true])>*{flex:1 1 auto}.__P__-generative-ui-actions>*{display:inline-flex;align-items:center;justify-content:center;min-height:36px;padding:0 var(--__P__-space-3);border:1px solid var(--__P__-border);border-radius:var(--__P__-radius-sm);background:var(--__P__-bg-elevated);color:var(--__P__-fg);font:inherit;font-size:var(--__P__-text-sm);font-weight:600;text-decoration:none;white-space:nowrap;min-width:0;overflow:hidden;text-overflow:ellipsis;cursor:pointer;transition:background var(--__P__-dur-quick) var(--__P__-ease),border-color var(--__P__-dur-quick) var(--__P__-ease)}.__P__-generative-ui-actions>*>span{overflow:hidden;text-overflow:ellipsis}.__P__-generative-ui-actions[data-small=true]>*{min-height:28px;padding:0 var(--__P__-space-2);font-size:var(--__P__-text-xs)}.__P__-generative-ui-actions>:hover{border-color:var(--__P__-border-strong)}.__P__-generative-ui-actions>[data-primary=true]{border-color:var(--__P__-accent);background:var(--__P__-accent);color:var(--__P__-on-accent)}.__P__-generative-ui-actions>:focus-visible,.__P__-generative-ui-option button:focus-visible{outline:2px solid var(--__P__-focus);outline-offset:2px}.__P__-generative-ui-actions>:disabled{border-color:var(--__P__-border);background:var(--__P__-hover);color:var(--__P__-fg-muted);cursor:not-allowed}.__P__-generative-ui .__P__-generative-ui-lines{display:grid;margin:0;padding:0;list-style:none}.__P__-generative-ui .__P__-generative-ui-lines li{display:flex;margin:0;gap:var(--__P__-space-3);padding:var(--__P__-space-2) 0;border-bottom:1px solid var(--__P__-border)}.__P__-generative-ui .__P__-generative-ui-lines li:first-child{padding-top:0}.__P__-generative-ui-lines li>div{display:grid;flex:1;gap:2px;min-width:0}.__P__-generative-ui-line-head{display:flex;align-items:baseline;gap:var(--__P__-space-3)}.__P__-generative-ui-line-head>span{display:-webkit-box;flex:1;min-width:0;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:2}.__P__-generative-ui-line-head>strong{flex:none;font-variant-numeric:tabular-nums}.__P__-generative-ui-totals{display:grid;gap:var(--__P__-space-1);margin:0;font-variant-numeric:tabular-nums}.__P__-generative-ui-totals div{display:flex;justify-content:space-between;gap:var(--__P__-space-3);color:var(--__P__-fg-muted)}.__P__-generative-ui-totals div:last-child{padding-top:var(--__P__-space-1);color:var(--__P__-fg);font-weight:700}.__P__-generative-ui-totals dt{min-width:0}.__P__-generative-ui-totals dd{flex:none;margin:0;white-space:nowrap}.__P__-generative-ui-notice{padding:var(--__P__-space-2) var(--__P__-space-3);border-radius:var(--__P__-radius-sm);background:var(--__P__-hover)}.__P__-generative-ui-notice[data-severity=warning]{color:var(--__P__-fg);background:color-mix(in oklch,var(--__P__-warning) 16%,transparent)}.__P__-generative-ui-notice[data-severity=error]{color:var(--__P__-danger-text);background:var(--__P__-danger-bg)}.__P__-generative-ui .__P__-generative-ui-timeline{display:grid;gap:var(--__P__-space-2);margin:0;padding:0;list-style:none}.__P__-generative-ui .__P__-generative-ui-timeline li{display:flex;margin:0;align-items:baseline;gap:var(--__P__-space-2);color:var(--__P__-fg-muted)}.__P__-generative-ui-timeline li:before{content:"";flex:0 0 auto;width:8px;height:8px;border:2px solid var(--__P__-border-strong);border-radius:50%}.__P__-generative-ui-timeline li[data-done=true]{color:var(--__P__-fg);font-weight:600}.__P__-generative-ui-timeline li[data-done=true]:before{border-color:var(--__P__-accent);background:var(--__P__-accent)}.__P__-generative-ui-timeline li>:first-child{flex:1}@media(pointer:coarse){.__P__-generative-ui-actions>*{min-height:44px}.__P__-generative-ui-actions>*>span{overflow:hidden;text-overflow:ellipsis}.__P__-generative-ui-actions[data-small=true]>*{min-height:32px}.__P__-generative-ui-option button{min-height:40px}}
10
10
 
11
11
  :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;border-radius:var(--__P__-radius-md)}: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}}
12
12
  `.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`),Rr=[`data-theme`,`data-color-scheme`,`data-mode`,`data-bs-theme`];function zr(e){if(e){if(e.classList.contains(`dark`))return`dark`;if(e.classList.contains(`light`))return`light`;for(let t of Rr){let n=e.getAttribute(t);if(n===`dark`||n===`light`)return n}}}function Br(e=document){let t=zr(e.documentElement)??zr(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 Vr(e,t=document){let n=Br(t);e(n);function r(){let r=Br(t);r!==n&&(n=r,e(r))}let i=new MutationObserver(r),a={attributes:!0,attributeFilter:[`class`,`style`,...Rr]};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 Hr=_.scope(`mount`),Ur=/* @__PURE__ */ new WeakMap,Wr={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 Gr(e,t){let n=t===`flow`?e.style.height:``;e.style.cssText=Wr[t],n&&(e.style.height=n)}function Kr(e){return e===`floating`||e===`modal`||e===`drawer`?`floating`:e===`standalone`||e===`page`?`viewport`:`flow`}function qr(e={}){let t=e.position??`flow`;Hr.debug(`createShadowMount`,{position:t,hasTarget:!!e.target,hasHost:!!e.existingHost});let n=`${i.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`,i.id),Gr(r,t);let a=r.shadowRoot??r.attachShadow({mode:`open`});for(let e of[`keydown`,`keypress`,`keyup`])a.addEventListener(e,Jr);let o=r.ownerDocument;if(!Yr(a,o)){let e=o.createElement(`style`);e.textContent=Lr,a.appendChild(e)}let s=document.createElement(`div`);return s.className=`${i.cssPrefix}-app`,a.appendChild(s),{appRoot:s,destroy:()=>r.remove(),hostElement:r,shadowRoot:a}}function Jr(e){if(e instanceof KeyboardEvent&&(e.metaKey||e.ctrlKey))return;let t=e.composedPath()[0];t instanceof HTMLElement&&(t.isContentEditable||t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`)&&e.stopPropagation()}function Yr(e,t){if(!(`adoptedStyleSheets`in e))return!1;let n=t.defaultView;if(!n||typeof n.CSSStyleSheet!=`function`)return!1;let r=Ur.get(t);if(!r)try{r=new n.CSSStyleSheet,r.replaceSync(Lr),Ur.set(t,r)}catch{return!1}try{return e.adoptedStyleSheets=[r],!0}catch{return!1}}function Xr(e,t){let n=i.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 Zr(e,t){e.dataset.theme=t===`host`?Br():t}function Qr(e,t){let n=i.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 $r(e,t){e.dataset.position=t}function ei(e,t){e.dataset.mode=t}function ti(e,t){Zr(e,t.themeMode),Xr(e,t.themeOverrides),$r(e,t.position),Qr(e,t.size)}var ni,ri,ii,ai,oi=Object.is,si=0,ci=[],li=[],ui=F,di=ui.__b,fi=ui.__r,pi=ui.diffed,mi=ui.__c,hi=ui.unmount,gi=ui.__;function _i(e,t){ui.__h&&ui.__h(ri,e,si||t),si=0;var n=ri.__H||(ri.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function R(e){return si=1,vi(ki,e)}function vi(e,t,n){var r=_i(ni++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ki(void 0,t),function(e){var t=(r.__N||r.__)[0],n=r.t(t,e);oi(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=ri,!ri.__f)){ri.__f=!0;var i=ri.shouldComponentUpdate;ri.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,oi(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 z(e,t){var n=_i(ni++,3);!ui.__s&&Oi(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,ri.__H.__h.push(n))}function yi(e,t){var n=_i(ni++,4);!ui.__s&&Oi(n.__H,t)&&(n.__P=!1,n.__=e,n.u=t,ri.__h.push(n))}function B(e){return si=5,bi(function(){return{current:e}},[])}function bi(e,t){var n=_i(ni++,7);return Oi(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function V(e,t){return si=8,bi(function(){return e},t)}function xi(){var e=_i(ni++,11);if(!e.__){for(var t=ri.__v;!t.__m&&t.__;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__=`P`+n[0]+`-`+n[1]++}return e.__}function Si(){var e;do{for(;e=li.shift();)try{Ei(e)}catch(t){ui.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=ci.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Ei),t.__h.some(Di),t.__h=[]}catch(n){t.__h=[],ui.__e(n,e.__v)}}}while(li.length)}ui.__b=function(e){ri=null,di&&di(e)},ui.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),gi&&gi(e,t)},ui.__r=function(e){fi&&fi(e),ni=0;var t=(ri=e.__c).__H;t&&(ii==ri?ri.__h=[]:(t.__h.some(Ei),t.__h.some(Di),ni=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),ii=ri},ui.diffed=function(e){pi&&pi(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&Ti(ci.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),ii=ri=null},ui.__c=function(e,t){t.some(function(e){try{e.__h.some(Ei),e.__h=e.__h.filter(function(e){return!e.__||Di(e)})}catch(t){e.__h=[function(){throw t}]}}),mi&&mi(e,t)},ui.unmount=function(e){hi&&hi(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,Ti(li.push(r))}else Ei(r)}catch(e){t=e}}),r.__H=void 0,t&&ui.__e(t,r.__v))};var Ci=typeof requestAnimationFrame==`function`;function wi(e){var t,n=function(){clearTimeout(r),Ci&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ci&&(t=requestAnimationFrame(n))}function Ti(e){e!=1&&ai==ui.requestAnimationFrame||((ai=ui.requestAnimationFrame)||wi)(Si)}function Ei(e){var t=ri,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),ri=t}function Di(e){var t=ri;e.__c=e.__(),ri=t}function Oi(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!oi(t,e[n])})}function ki(e,t){return typeof t==`function`?t(e):t}var Ai=Symbol.for(`preact-signals`);function ji(){if(Li>1)Li--;else{var e,t=!1;for((function(){var e=Vi;for(Vi=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}})();Ii!==void 0;){var n=Ii;for(Ii=void 0,Ri++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Gi(n))try{n.c()}catch(n){t||(e=n,t=!0)}n=r}}if(Ri=0,Li--,t)throw e}}function Mi(e){if(Li>0)return e();Bi=++zi,Li++;try{return e()}finally{ji()}}var Ni,Pi=void 0;function Fi(e){var t=Pi,n=Ni;Pi=void 0,Ni=void 0;try{return e()}finally{Pi=t,Ni=n}}var Ii=void 0,Li=0,Ri=0,zi=0,Bi=0,Vi=void 0,Hi=0;function Ui(e){if(Pi!==void 0){var t=e.n;if(t===void 0||t.t!==Pi)return t={i:0,S:e,p:Pi.s,n:void 0,t:Pi,e:void 0,x:void 0,r:t},Pi.s!==void 0&&(Pi.s.n=t),Pi.s=t,e.n=t,32&Pi.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=Pi.s,t.n=void 0,Pi.s.n=t,Pi.s=t),t}}function Wi(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}Wi.prototype.brand=Ai,Wi.prototype.h=function(){return!0},Wi.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?Fi(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},Wi.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&&Fi(function(){var e;(e=t.Z)==null||e.call(t)}))}},Wi.prototype.subscribe=function(e){var t=this;return ea(function(){var n=t.value;Fi(function(){return e(n)})},{name:`sub`})},Wi.prototype.valueOf=function(){return this.value},Wi.prototype.toString=function(){return this.value+``},Wi.prototype.toJSON=function(){return this.value},Wi.prototype.peek=function(){var e=this;return Fi(function(){return e.value})},Object.defineProperty(Wi.prototype,"value",{get:function(){var e=Ui(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ri>100)throw Error(`Cycle detected`);(function(e){Li!==0&&Ri===0&&e.l!==Bi&&(e.l=Bi,Vi={S:e,v:e.v,i:e.i,o:Vi})})(this),this.v=e,this.i++,Hi++,Li++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{ji()}}}});function H(e,t){return new Wi(e,t)}function Gi(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 Ki(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 qi(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 Ji(e,t){Wi.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Hi-1,this.f=4}Ji.prototype=new Wi,Ji.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Hi))return!0;if(this.g=Hi,this.f|=1,this.i>0&&!Gi(this))return this.f&=-2,!0;var e=Pi;try{Ki(this),Pi=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 Pi=e,qi(this),this.f&=-2,!0},Ji.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)}Wi.prototype.S.call(this,e)},Ji.prototype.U=function(e){if(this.t!==void 0&&(Wi.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)}},Ji.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(Ji.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=Ui(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Yi(e,t){return new Ji(e,t)}function Xi(e){var t=e.j;if(e.j=void 0,typeof t==`function`){Li++;var n=Pi;Pi=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,Zi(e),t}finally{Pi=n,ji()}}}function Zi(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Xi(e)}function Qi(e){if(Pi!==this)throw Error(`Out-of-order effect`);qi(this),Pi=e,this.f&=-2;try{8&this.f&&Zi(this)}finally{ji()}}function $i(e,t){this.x=e,this.j=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Ni&&Ni.push(this)}$i.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.j=t)}finally{e()}},$i.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,Xi(this),Ki(this),Li++;var e=Pi;return Pi=this,Qi.bind(this,e)},$i.prototype.N=function(){2&this.f||(this.f|=2,this.u=Ii,Ii=this)},$i.prototype.d=function(){this.f|=8,1&this.f||Zi(this)},$i.prototype.dispose=function(){this.d()};function ea(e,t){var n=new $i(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var ta,na,ra,ia=typeof window<`u`&&!!window.__PREACT_SIGNALS_DEVTOOLS__,aa=[];ea(function(){ta=this.N})();function oa(e,t){F[e]=t.bind(null,F[e]||function(){})}function sa(e){if(ra){var t=ra;ra=void 0,t()}ra=e&&e.S()}function ca(e){var t=this,n=e.data,r=ua(n);r.name=`ReactiveDom`,r.value=n;var i=bi(function(){for(var e=t,n=t.__v;n=n.__;)if(n.__c){n.__c.__$f|=4;break}var i=Yi(function(){var e=r.value.value;return e===0?0:!0===e?``:e||``}),a=Yi(function(){return!Array.isArray(i.value)&&!Fe(i.value)}),o=ea(function(){if(this.N=ma,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}ca.displayName=`ReactiveTextNode`,Object.defineProperties(Wi.prototype,{constructor:{configurable:!0,value:Ze(L,null).constructor},type:{configurable:!0,value:ca},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}}),oa(`__b`,function(e,t){if(sa(),na=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 Wi&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)}),oa(`__r`,function(e,t){if(e(t),t.type!==L){sa();var n,r=t.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=function(e,t){var n;return ea(function(){n=this},{name:t}),n.c=e,n}(function(e){return function(){var t;ia&&((t=this.y)==null||t.call(this)),e.__$f|=1,e.setState({})}}(r),typeof t.type==`function`?t.type.displayName||t.type.name:``))),na=r,sa(n)}}),oa(`__e`,function(e,t,n,r){sa(),na=void 0,e(t,n,r)}),oa(`diffed`,function(e,t){sa(),na=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=la(n,c,u,i),a[c]=l):l.o(u,i)}}e(t)});function la(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:ea(function(){this.N=ma;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))})}}oa(`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)}),oa(`__h`,function(e,t,n,r){r<3&&(t.__$f|=2),e(t,n,r)}),$e.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 ua(e,t){return bi(function(){return H(e,t)},[])}function da(e,t){var n=B(e);return n.current=e,na.__$f|=4,bi(function(){return Yi(function(){return n.current()},t)},[])}var fa=function(e){queueMicrotask(function(){queueMicrotask(e)})};function pa(){Mi(function(){for(var e;e=aa.shift();)ta.call(e)})}function ma(){aa.push(this)===1&&(F.requestAnimationFrame||fa)(pa)}function ha(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 ga=/* @__PURE__ */ new Set([`home`,`chats`,`help`,`news`]);function _a(e){return typeof e!=`object`||!e||!(`to`in e)||typeof e.to!=`string`||!ga.has(e.to)?!1:!(`id`in e)||e.id===void 0||typeof e.id==`string`}function va(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 ya(e,t){return{text:e,send:typeof t==`object`&&!!t&&`send`in t&&t.send===!0}}function ba(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 xa(e){return`${i.cssPrefix}:${e}`}function Sa(e,t,n){e.dispatchEvent(new CustomEvent(xa(t),{detail:n}))}function Ca(e,t){let n=Object.keys(t).filter(e=>Object.hasOwn(t,e)).map(n=>{let r=t[n],i=xa(n);function a(e){return r(e instanceof CustomEvent?e.detail:void 0)}return e.addEventListener(i,a),[i,a]});return()=>{for(let[t,r]of n)e.removeEventListener(t,r)}}function wa(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 Ta(e){let t=new URL(e),n=i.cssPrefix,r=`${i.cssPrefix}-ask`,a=t.search.slice(1).split(`&`).filter(Boolean),o=t.hash.slice(1).split(`&`).filter(Boolean),s=wa(a,n),c=wa(s.rest,r),l=wa(o,n),u=wa(l.rest,r),d=s.value??l.value,f=(c.value??u.value)?.trim()||void 0;if(d!==void 0||f!==void 0)return t.search=c.rest.join(`&`),t.hash=u.rest.join(`&`),{target:d===void 0?void 0:va(d),...f?{ask:f}:{},url:t.toString()}}const Ea=_.scope(`feedback:audio`);var Da=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){Ea.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=>(Ea.warn(`audio fetch/decode failed`,{url:e,err:t}),this.buffers.delete(e),null));return this.buffers.set(e,r),r}};const Oa={messageReceived:10,messageSent:0,error:[20,40,20],voiceStart:10,voiceStop:0},ka={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 Aa=null,ja=0;function Ma(){return typeof navigator<`u`&&typeof navigator.vibrate==`function`}function Na(){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=`__${i.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;`;e.style.cssText=n,t.style.cssText=n;for(let n of[e,t])n.addEventListener(`click`,e=>e.stopPropagation());return document.body.append(e,t),{input:e,label:t}}function Pa(e){if(!(e===0||Array.isArray(e)&&e.every(e=>e===0))){if(Ma())try{navigator.vibrate(e);return}catch{}if(Aa??(Aa=Na()),Aa)try{Aa.label.click()}catch{}}}function Fa(){ja++;let e=!1;return()=>{e||(e=!0,ja=Math.max(0,ja-1),ja===0&&Aa&&(Aa.input.remove(),Aa.label.remove(),Aa=null))}}const Ia=_.scope(`feedback`);var La=class{constructor(e,t){S(this,`mutedSig`,H(!1)),S(this,`audio`,new Da),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=Fa(),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=>Ia.warn(`audio play failed`,{err:e,url:t}));return}let n=ka[e];n&&this.audio.playTone(n)}playHaptic(e){if(this.reducedMotionMq?.matches)return;let t=this.haptics.events?.[e];t!==!1&&Pa(t===!0||t===void 0?Oa[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 Ra(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function za(e){return Ra(e)}function Ba(e){return!(!Ra(e)||e.navigation!==void 0&&!Array.isArray(e.navigation)||e.linkCards!==void 0&&!Array.isArray(e.linkCards))}function Va(e){if(typeof e!=`object`||!e)return{};let t=Reflect.get(e,`url`);return{url:typeof t==`string`&&/^https?:\/\//i.test(t)&&t.includes(`{returnTo}`)?t:void 0,required:Reflect.get(e,`required`)===!0,hidePrompt:Reflect.get(e,`hidePrompt`)===!0,hideUser:Reflect.get(e,`hideUser`)===!0}}function Ha(e,t){let n=encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`);return e.replaceAll(`{returnTo}`,n)}function Ua(e){let t=e.split(`.`)[1];if(t)try{let e=atob(t.replace(/-/g,`+`).replace(/_/g,`/`)),n=JSON.parse(new TextDecoder().decode(Uint8Array.from(e,e=>e.charCodeAt(0))));return typeof n==`object`&&n&&!Array.isArray(n)?Object.fromEntries(Object.entries(n)):void 0}catch{return}}function Wa(e,t){let n=e?.[t];return typeof n==`string`&&n.trim()?{[t]:n.trim()}:{}}function Ga(e){let t=Ua(e);return{...Wa(t,`name`),...Wa(t,`email`)}}function Ka(e){let t=Ua(e)?.sub;return typeof t==`string`&&t!==``?t:void 0}function qa(){try{return window.top?.location.href??location.href}catch{return location.href}}function Ja(e){try{(window.top??window).location.assign(e)}catch{location.assign(e)}}var Ya=Symbol.for(`pv`),Xa=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:Ya,__v:--Xa,__i:-1,__u:0};return(i||a)&&(l.__source=i,l.__self=a),F.vnode&&F.vnode(l),l}function Za(e){switch(e){case 1:return`href`;case 2:return`src`;case 4:return`class`;case 8:return`checked`;case 16:return`start`}}const Qa=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 $a(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 eo(e){e.pending.length>0&&fo(e,`
@@ -37,37 +37,37 @@ import{useEffect as e,useMemo as t,useRef as n,useSyncExternalStore as r}from"re
37
37
  `?``: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!==`
38
38
  `){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!==`
39
39
  `){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!==`
40
- `){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(uo(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 po(e){return{add_token:mo,end_token:ho,add_text:go,set_attr:_o,data:{nodes:[e,,,,,],index:0}}}function mo(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 ho(e){--e.index}function go(e,t){e.nodes[e.index].appendChild(document.createTextNode(t))}function _o(e,t,n){e.nodes[e.index].setAttribute(Za(t),n)}function vo({amount:e,currency:t},n){let r=new Intl.NumberFormat(`en`,{style:`currency`,currency:t}).resolvedOptions().maximumFractionDigits??2;return new Intl.NumberFormat(n,{style:`currency`,currency:t}).format(e/10**r)}function yo(e,t){let n=new Date(e);return!/^\d{4}-\d{2}-\d{2}/.test(e)||Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeZone:e.length===10?`UTC`:void 0}).format(n)}function bo(e,t){let n=xo(e);return n?new Intl.DateTimeFormat(t,{hour:`numeric`,minute:`2-digit`,timeZone:`UTC`}).format(n):e}function xo(e){let t=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})/.exec(e);return t?Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3]),Number(t[4]),Number(t[5])):void 0}function So(e,t){let[n,r]=[e,t].map(e=>/^\d{4}-\d{2}-\d{2}/.test(e??``)?Date.parse(`${e?.slice(0,10)}T00:00:00Z`):NaN),i=Math.round(((r??NaN)-(n??NaN))/864e5);return i>0?i:void 0}function Co(e,t){return!/^\d{4}-\d{2}-\d{2}/.test(e)||Number.isNaN(Date.parse(e.slice(0,10)))?e:new Intl.DateTimeFormat(t,{weekday:`short`,month:`short`,day:`numeric`,timeZone:`UTC`}).format(Date.parse(e.slice(0,10)))}function wo(e,t,n){return[e,t].flatMap(e=>e?[Co(e,n)]:[]).join(` – `)}function To(e,t){let n=(e,n)=>new Intl.NumberFormat(t,{style:`unit`,unit:n,unitDisplay:`narrow`}).format(e),r=Math.floor(e/60);return[r>0&&n(r,`hour`),e%60>0&&n(e%60,`minute`)].filter(Boolean).join(` `)}function Eo(e,t,n){let r=e.stops===void 0?void 0:e.stops.length===0?t.visualDirect:`${t.visualVia} ${e.stops.join(`, `)}`;return[e.duration===void 0?void 0:To(e.duration,n),r].filter(Boolean).join(` · `)}function Do(e,t){return e===1?t.visualNight:t.visualNights.replace(`{count}`,String(e))}function Oo(e,t,n){let r=e.typeName===`Stay`?e.props.stay:void 0,i=e.typeName===`Stay`?{...e.props.stay,title:e.props.stay.name,start:e.props.stay.checkIn,end:e.props.stay.checkOut,nights:void 0,priceNote:void 0}:e.props.package,a=i.nights??So(i.start,i.end);return{...i,stars:r?.stars,room:r?.room,when:[wo(i.start,i.end,n),a&&Do(a,t)].filter(Boolean).join(` · `),note:r?.nightly?`${vo(r.nightly,n)} ${t.visualPerNight}`:i.priceNote,available:i.available!==!1}}function ko({value:e,best:t}){return t===void 0||t===5?String(e):`${e}/${t}`}function Ao(e){return Array.isArray(e)?e:[e]}function jo({type:e,data:t}){let n=Ao(t[0]?.value??[]).length;if(t.some(e=>Ao(e.value).length!==n))return!1;if(e!==`pie`)return!0;let r=t.map(e=>Ao(e.value)[0]??0);return n===1&&r.every(e=>e>=0)&&r.some(e=>e>0)}const Mo=[`#f59e0b`,`#10b981`,`#ef4444`,`#8b5cf6`,`#0ea5e9`];function No({type:e,data:t},n){let r=t.map(e=>Ao(e.value)),i=Math.max(1,r[0]?.length??1),a=Math.min(0,...r.flat()),o=Math.max(0,...r.flat()),s=o-a||1,c=272/Math.max(1,t.length),l=c*.7/i,u=Math.ceil(t.length/8),d=new Intl.NumberFormat(n,{notation:`compact`,maximumFractionDigits:1});function f(e){return 148-(e-a)/s*136}return{baseline:f(0),barWidth:l,series:Array.from({length:i},(t,n)=>r.map((t,r)=>({x:24+(r+.5)*c+(e===`bar`?(n-(i-1)/2)*l:0),y:f(t[n]??0)}))),labels:t.flatMap((e,t)=>t%u===0?[{x:24+(t+.5)*c,text:e.label.length*5>c*u?`${e.label.slice(0,Math.max(1,Math.floor(c*u/5)-1))}…`:e.label}]:[]),ticks:[.../* @__PURE__ */ new Set([o,a])].map(e=>({y:f(e),text:d.format(e)})),slices:e===`pie`?Po(r.map(e=>e[0]??0)):[]}}function Po(e){let t=e.reduce((e,t)=>e+t,0)||1,n=-Math.PI/2;return e.map(e=>{let r=n+e/t*2*Math.PI,i=Fo(n,Math.min(r,n+2*Math.PI-1e-4));return n=r,{path:i,share:e/t}})}function Fo(e,t){let n=+(t-e>Math.PI),r=(e,t)=>`${(160+e*Math.cos(t)).toFixed(2)} ${(84+e*Math.sin(t)).toFixed(2)}`;return`M${r(64,e)}A64 64 0 ${n} 1 ${r(64,t)}L${r(40,t)}A40 40 0 ${n} 0 ${r(40,e)}Z`}function Io(e){if(!e||e.length<2)return;let t=Math.min(...e),n=Math.max(...e)-t||1;return e.map((r,i)=>`${(i*80/(e.length-1)).toFixed(1)},${(22-(r-t)/n*20).toFixed(1)}`).join(` `)}function Lo(e){let t=/^[^\d\-−+]{0,4}([-−+]?\d[\d.,\s]*?)\s?[^\d]{0,4}$/u.exec(e.trim());if(!t?.[1])return;let n=t[1].replace(/\s/g,``).replace(`−`,`-`),r=n.match(/[.,]/g)??[],i=r.at(-1),a=new Set(r).size>1||r.length===1&&!/^[-+]?[1-9]\d{0,2}[.,]\d{3}$/.test(n)?i:void 0,o=Number(n.replace(a===`,`?/\./g:a===`.`?/,/g:/[.,]/g,``).replace(`,`,`.`));return Number.isFinite(o)?o:void 0}function Ro(e,t){return e.map((e,n)=>{let r=t.map(e=>e[n]??``).filter(e=>e.trim());return r.length>0&&r.every(e=>Lo(e)!==void 0)})}function zo(e,t,n){if(!t)return e;let r=new Intl.Collator(n,{numeric:!0}),i=t.descending?-1:1;return[...e].sort((e,n)=>{let[a,o]=[e[t.column]??``,n[t.column]??``];return i*(t.numeric?(Lo(a)??0)-(Lo(o)??0):r.compare(a,o))})}new Map(Object.entries({Card:280,Product:280,Stay:280,Package:280,Flight:300,Cart:480,Order:480,Booking:480}));function Bo(e){let t=new Set(e.map(e=>{let t=e.typeName===`Cell`?e.props.children.length===1?e.props.children[0]:void 0:e;return t?.typeName===`Metric`?`Card`:t?.typeName}));return t.size===1&&!t.has(void 0)}function Vo({scrollLeft:e,scrollWidth:t,clientWidth:n}){let r=Math.abs(e);return{start:r>1,end:r<t-n-1}}function Ho(e){return/^https:\/\//i.test(e??``)}function Uo(e,t){return(e??[]).flatMap(e=>e.url?Ho(e.url)?[{...e,url:e.url,message:void 0}]:[]:t?[{...e,url:void 0,message:e.label}]:[])}function Wo(e,t,n){return`${e}: ${[t,...Object.entries(n??{}).map(([e,t])=>`${e}: ${t}`)].join(`, `)}`}function Go(e){return[...e.legs.map(e=>e.number??e.carrier),e.fare].filter(Boolean).join(`, `)}function Ko(e,t){return t!==void 0&&t.currency===e.currency&&t.amount>e.amount}function qo(e,t){let n=e.variants??[],r=(e.options??[]).filter(e=>e.values.length).map(r=>({...r,value:t[r.name]??r.values.find(t=>t===e.selected?.[r.name])??(r.values.length===1?r.values[0]:void 0),unavailable:n.length?r.values.filter(e=>!n.some(t=>t.available!==!1&&t.options[r.name]===e)):[]})),i=r.filter(e=>e.value===void 0).map(e=>e.name),a=Object.fromEntries(r.flatMap(e=>e.value===void 0?[]:[[e.name,e.value]])),o=i.length?void 0:n.find(e=>r.every(t=>e.options[t.name]===t.value)),s=!i.length&&n.length?o!==void 0&&o.available!==!1:e.available!==!1;return{options:r,missing:i,chosen:a,available:s,price:o?.price??e.price,compareAtPrice:o?.price?o.compareAtPrice:e.compareAtPrice,image:o?.image??e.image,canBuy:!i.length&&s}}const Jo={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`},Carousel:{$ref:`#/$defs/Carousel`},Text:{$ref:`#/$defs/Text`},Card:{$ref:`#/$defs/Card`},Metric:{$ref:`#/$defs/Metric`},Table:{$ref:`#/$defs/Table`},Chart:{$ref:`#/$defs/Chart`},Product:{$ref:`#/$defs/Product`},Cart:{$ref:`#/$defs/Cart`},Order:{$ref:`#/$defs/Order`},Flight:{$ref:`#/$defs/Flight`},Stay:{$ref:`#/$defs/Stay`},Package:{$ref:`#/$defs/Package`},Booking:{$ref:`#/$defs/Booking`}},required:[`Root`,`Grid`,`Cell`,`Carousel`,`Text`,`Card`,`Metric`,`Table`,`Chart`,`Product`,`Cart`,`Order`,`Flight`,`Stay`,`Package`,`Booking`],additionalProperties:!1,$defs:{Root:{type:`object`,properties:{children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Grid`},{$ref:`#/$defs/Carousel`},{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`},{$ref:`#/$defs/Product`},{$ref:`#/$defs/Cart`},{$ref:`#/$defs/Order`},{$ref:`#/$defs/Flight`},{$ref:`#/$defs/Stay`},{$ref:`#/$defs/Package`},{$ref:`#/$defs/Booking`}]}}},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`},{$ref:`#/$defs/Product`},{$ref:`#/$defs/Cart`},{$ref:`#/$defs/Order`},{$ref:`#/$defs/Flight`},{$ref:`#/$defs/Stay`},{$ref:`#/$defs/Package`},{$ref:`#/$defs/Booking`}]}}},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`},{$ref:`#/$defs/Product`},{$ref:`#/$defs/Cart`},{$ref:`#/$defs/Order`},{$ref:`#/$defs/Flight`},{$ref:`#/$defs/Stay`},{$ref:`#/$defs/Package`},{$ref:`#/$defs/Booking`}]}},span:{type:`integer`,enum:[1,2,3,4],default:1}},required:[`children`],additionalProperties:!1},Carousel:{type:`object`,properties:{children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Card`},{$ref:`#/$defs/Product`},{$ref:`#/$defs/Flight`},{$ref:`#/$defs/Stay`},{$ref:`#/$defs/Package`}]}}},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`},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}},image:{type:`string`}},required:[`title`,`body`],additionalProperties:!1},Metric:{type:`object`,properties:{label:{type:`string`},value:{type:`string`},detail:{type:`string`},change:{type:`object`,properties:{text:{type:`string`},tone:{type:`string`,enum:[`good`,`bad`,`neutral`]}},required:[`text`,`tone`]},trend:{type:`array`,items:{type:`number`}}},required:[`label`,`value`],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`,`pie`]},data:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},value:{anyOf:[{type:`number`},{type:`array`,items:{type:`number`}}]}},required:[`label`,`value`],additionalProperties:!1}},series:{type:`array`,items:{type:`string`}}},required:[`title`,`type`,`data`],additionalProperties:!1},Product:{type:`object`,properties:{product:{type:`object`,properties:{title:{type:`string`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},id:{type:`string`},compareAtPrice:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},image:{type:`string`},url:{type:`string`},description:{type:`string`},badge:{type:`string`},rating:{type:`object`,properties:{value:{type:`number`},count:{type:`integer`},best:{type:`number`}},required:[`value`]},available:{type:`boolean`},options:{type:`array`,items:{type:`object`,properties:{name:{type:`string`},values:{type:`array`,items:{type:`string`}}},required:[`name`,`values`]}},variants:{type:`array`,items:{type:`object`,properties:{options:{type:`object`,additionalProperties:{type:`string`}},id:{type:`string`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},compareAtPrice:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},image:{type:`string`},available:{type:`boolean`}},required:[`options`]}},selected:{type:`object`,additionalProperties:{type:`string`}},details:{type:`array`,items:{type:`string`}}},required:[`title`,`price`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`product`],additionalProperties:!1},Cart:{type:`object`,properties:{cart:{type:`object`,properties:{lines:{type:`array`,items:{type:`object`,properties:{title:{type:`string`},quantity:{type:`integer`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},image:{type:`string`},url:{type:`string`},options:{type:`object`,additionalProperties:{type:`string`}},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`title`,`quantity`,`price`]}},totals:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},amount:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]}},required:[`label`,`amount`]}},messages:{type:`array`,items:{type:`object`,properties:{text:{type:`string`},severity:{type:`string`,enum:[`info`,`warning`,`error`]}},required:[`text`,`severity`]}}},required:[`lines`,`totals`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`cart`],additionalProperties:!1},Order:{type:`object`,properties:{order:{type:`object`,properties:{number:{type:`string`},status:{type:`string`},date:{type:`string`},items:{type:`array`,items:{type:`object`,properties:{title:{type:`string`},quantity:{type:`integer`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},image:{type:`string`},url:{type:`string`},options:{type:`object`,additionalProperties:{type:`string`}},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`title`,`quantity`,`price`]}},totals:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},amount:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]}},required:[`label`,`amount`]}},timeline:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},done:{type:`boolean`},date:{type:`string`}},required:[`label`,`done`]}},details:{type:`array`,items:{type:`string`}}},required:[`number`,`status`,`items`,`totals`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`order`],additionalProperties:!1},Flight:{type:`object`,properties:{flight:{type:`object`,properties:{legs:{type:`array`,items:{type:`object`,properties:{from:{type:`string`},to:{type:`string`},departs:{type:`string`},arrives:{type:`string`},carrier:{type:`string`},number:{type:`string`},duration:{type:`integer`},stops:{type:`array`,items:{type:`string`}}},required:[`from`,`to`,`departs`,`arrives`,`carrier`]},minItems:1},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},id:{type:`string`},priceNote:{type:`string`},fare:{type:`string`},badge:{type:`string`},details:{type:`array`,items:{type:`string`}},available:{type:`boolean`}},required:[`legs`,`price`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`flight`],additionalProperties:!1},Stay:{type:`object`,properties:{stay:{type:`object`,properties:{name:{type:`string`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},id:{type:`string`},image:{type:`string`},url:{type:`string`},location:{type:`string`},stars:{type:`integer`},rating:{type:`object`,properties:{value:{type:`number`},count:{type:`integer`},best:{type:`number`}},required:[`value`]},checkIn:{type:`string`},checkOut:{type:`string`},room:{type:`string`},nightly:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},compareAtPrice:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},badge:{type:`string`},details:{type:`array`,items:{type:`string`}},available:{type:`boolean`}},required:[`name`,`price`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`stay`],additionalProperties:!1},Package:{type:`object`,properties:{package:{type:`object`,properties:{title:{type:`string`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},id:{type:`string`},image:{type:`string`},url:{type:`string`},location:{type:`string`},start:{type:`string`},end:{type:`string`},nights:{type:`integer`},priceNote:{type:`string`},compareAtPrice:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},rating:{type:`object`,properties:{value:{type:`number`},count:{type:`integer`},best:{type:`number`}},required:[`value`]},badge:{type:`string`},details:{type:`array`,items:{type:`string`}},available:{type:`boolean`}},required:[`title`,`price`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`package`],additionalProperties:!1},Booking:{type:`object`,properties:{booking:{type:`object`,properties:{reference:{type:`string`},status:{type:`string`},title:{type:`string`},start:{type:`string`},end:{type:`string`},travellers:{type:`array`,items:{type:`string`}},itinerary:{type:`array`,items:{type:`object`,properties:{title:{type:`string`},date:{type:`string`},time:{type:`string`},detail:{type:`string`}},required:[`title`]}},totals:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},amount:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]}},required:[`label`,`amount`]}},details:{type:`array`,items:{type:`string`}}},required:[`reference`,`status`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`booking`],additionalProperties:!1}}}};function Yo(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 Xo=/* @__PURE__ */ new Set([`Comp`,`Ref`,`StateRef`,`RuntimeRef`,`BinOp`,`UnaryOp`,`Ternary`,`Member`,`Index`,`Assign`,`Str`,`Num`,`Bool`,`Null`,`Arr`,`Obj`,`Ph`]);function Zo(e){return!e||typeof e!=`object`||Array.isArray(e)?!1:Xo.has(e.k)}function Qo(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 $o(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($o)}:typeof e==`object`?{k:`Obj`,entries:Object.entries(e).map(([e,t])=>[e,$o(t)])}:{k:`Null`}}function es(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=es(n);if(!e)return;t.push(e.v)}return{v:t}}case`Obj`:{let t={};for(let[n,r]of e.entries){let e=es(r);if(!e)return;t[n]=e.v}return{v:t}}default:return}}const ts=/* @__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}]]),ns={ActionExpression:!0,OpenUrl:!0,ToAssistant:!0},rs={Query:`Query`,Mutation:`Mutation`};function is(e){return e?.callDefs??ts}function as(e){return ts.has(e)}function os(e){return e in rs}var K;(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`})(K||(K={}));function ss(e){let t=0,n=()=>e[t]??{t:K.EOF},r=()=>{let e=n();return t++,e},i=e=>{n().t===e&&t++};function a(e){switch(e.t){case K.Question:return 1;case K.Or:return 2;case K.And:return 3;case K.EqEq:case K.NotEq:return 4;case K.Greater:case K.Less:case K.GreaterEq:case K.LessEq:return 5;case K.Plus:case K.Minus:return 6;case K.Star:case K.Slash:case K.Percent:return 7;case K.Dot:case K.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===K.Str)return r(),{k:`Str`,v:a.v};if(a.t===K.Num)return r(),{k:`Num`,v:a.v};if(a.t===K.True)return r(),{k:`Bool`,v:!0};if(a.t===K.False)return r(),{k:`Bool`,v:!1};if(a.t===K.Null)return r(),{k:`Null`};if(a.t===K.LBrack)return u();if(a.t===K.LBrace)return d();if(a.t===K.StateVar){let e=a.v;return r(),n().t===K.Equals?(r(),{k:`Assign`,target:e,value:o(0)}):{k:`StateRef`,n:e}}if(a.t===K.Type){let n=a.v;return e[t+1]?.t===K.LParen&&(!as(n)||n===`Action`)?l():(r(),{k:`Ref`,n})}if(a.t===K.BuiltinCall){if(e[t+1]?.t===K.LParen){let e=l();return e.k===`Comp`&&!as(e.name)&&(e.fn=!0),e}return r(),{k:`Ref`,n:a.v}}if(a.t===K.Ident)return r(),{k:`Ref`,n:a.v};if(a.t===K.Not)return r(),{k:`UnaryOp`,op:`!`,operand:o(8)};if(a.t===K.Minus)return r(),{k:`UnaryOp`,op:`-`,operand:o(8)};if(a.t===K.LParen){r();let e=o(0);return i(K.RParen),e}return r(),{k:`Null`}}function c(e){let t=n();if(t.t===K.Plus)return r(),{k:`BinOp`,op:`+`,left:e,right:o(6)};if(t.t===K.Minus)return r(),{k:`BinOp`,op:`-`,left:e,right:o(6)};if(t.t===K.Star)return r(),{k:`BinOp`,op:`*`,left:e,right:o(7)};if(t.t===K.Slash)return r(),{k:`BinOp`,op:`/`,left:e,right:o(7)};if(t.t===K.Percent)return r(),{k:`BinOp`,op:`%`,left:e,right:o(7)};if(t.t===K.EqEq)return r(),{k:`BinOp`,op:`==`,left:e,right:o(4)};if(t.t===K.NotEq)return r(),{k:`BinOp`,op:`!=`,left:e,right:o(4)};if(t.t===K.Greater)return r(),{k:`BinOp`,op:`>`,left:e,right:o(5)};if(t.t===K.Less)return r(),{k:`BinOp`,op:`<`,left:e,right:o(5)};if(t.t===K.GreaterEq)return r(),{k:`BinOp`,op:`>=`,left:e,right:o(5)};if(t.t===K.LessEq)return r(),{k:`BinOp`,op:`<=`,left:e,right:o(5)};if(t.t===K.And)return r(),{k:`BinOp`,op:`&&`,left:e,right:o(3)};if(t.t===K.Or)return r(),{k:`BinOp`,op:`||`,left:e,right:o(2)};if(t.t===K.Question){r();let t=o(0);return i(K.Colon),{k:`Ternary`,cond:e,then:t,else:o(0)}}if(t.t===K.Dot){r();let t=n();return{k:`Member`,obj:e,field:t.t===K.Ident||t.t===K.Type||t.t===K.Str||t.t===K.Num?(r(),String(t.v)):t.t===K.StateVar?(r(),t.v.replace(/^\$/,``)):(r(),`?`)}}if(t.t===K.LBrack){r();let t=o(0);return i(K.RBrack),{k:`Index`,obj:e,index:t}}return e}function l(){let e=n().v;r(),i(K.LParen);let t=[];for(;n().t!==K.RParen&&n().t!==K.EOF;)t.push(o(0)),n().t===K.Comma&&r();return i(K.RParen),{k:`Comp`,name:e,args:t}}function u(){r();let e=[];for(;n().t!==K.RBrack&&n().t!==K.EOF;)e.push(o(0)),n().t===K.Comma&&r();return i(K.RBrack),{k:`Arr`,els:e}}function d(){r();let e=[];for(;n().t!==K.RBrace&&n().t!==K.EOF;){let t=n(),a=t.t===K.Ident||t.t===K.Str||t.t===K.Type||t.t===K.Num?(r(),String(t.v)):t.t===K.StateVar?(r(),t.v.replace(/^\$/,``)):(r(),`?`);i(K.Colon),e.push([a,o(0)]),n().t===K.Comma&&r()}return i(K.RBrace),{k:`Obj`,entries:e}}return o(0)}function cs(e){let t=[],n=0,r=e.length;for(;n<r;){for(;n<r&&(e.charAt(n)===` `||e.charAt(n)===` `||e.charAt(n)===`\r`);)n++;if(n>=r)break;let i=e.charAt(n);if(i===`
40
+ `){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(uo(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 po(e){return{add_token:mo,end_token:ho,add_text:go,set_attr:_o,data:{nodes:[e,,,,,],index:0}}}function mo(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 ho(e){--e.index}function go(e,t){e.nodes[e.index].appendChild(document.createTextNode(t))}function _o(e,t,n){e.nodes[e.index].setAttribute(Za(t),n)}function vo({amount:e,currency:t},n){let r=new Intl.NumberFormat(`en`,{style:`currency`,currency:t}).resolvedOptions().maximumFractionDigits??2;return new Intl.NumberFormat(n,{style:`currency`,currency:t}).format(e/10**r)}function yo(e,t){let n=new Date(e);return!/^\d{4}-\d{2}-\d{2}/.test(e)||Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeZone:e.length===10?`UTC`:void 0}).format(n)}function bo(e,t){let n=xo(e);return n?new Intl.DateTimeFormat(t,{hour:`numeric`,minute:`2-digit`,timeZone:`UTC`}).format(n):e}function xo(e){let t=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})/.exec(e);return t?Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3]),Number(t[4]),Number(t[5])):void 0}function So(e,t){let[n,r]=[e,t].map(e=>/^\d{4}-\d{2}-\d{2}/.test(e??``)?Date.parse(`${e?.slice(0,10)}T00:00:00Z`):NaN),i=Math.round(((r??NaN)-(n??NaN))/864e5);return i>0?i:void 0}function Co(e,t){return!/^\d{4}-\d{2}-\d{2}/.test(e)||Number.isNaN(Date.parse(e.slice(0,10)))?e:new Intl.DateTimeFormat(t,{weekday:`short`,month:`short`,day:`numeric`,timeZone:`UTC`}).format(Date.parse(e.slice(0,10)))}function wo(e,t,n){return[e,t].flatMap(e=>e?[Co(e,n)]:[]).join(` – `)}function To(e,t){let n=(e,n)=>new Intl.NumberFormat(t,{style:`unit`,unit:n,unitDisplay:`narrow`}).format(e),r=Math.floor(e/60);return[r>0&&n(r,`hour`),e%60>0&&n(e%60,`minute`)].filter(Boolean).join(` `)}function Eo(e,t,n){let r=e.stops===void 0?void 0:e.stops.length===0?t.visualDirect:`${t.visualVia} ${e.stops.join(`, `)}`;return[e.duration===void 0?void 0:To(e.duration,n),r].filter(Boolean).join(` · `)}function Do(e,t){return e===1?t.visualNight:t.visualNights.replace(`{count}`,String(e))}function Oo(e,t,n){let r=e.typeName===`Stay`?e.props.stay:void 0,i=e.typeName===`Stay`?{...e.props.stay,title:e.props.stay.name,start:e.props.stay.checkIn,end:e.props.stay.checkOut,nights:void 0,priceNote:void 0}:e.props.package,a=i.nights??So(i.start,i.end);return{...i,stars:r?.stars,room:r?.room,when:[wo(i.start,i.end,n),a&&Do(a,t)].filter(Boolean).join(` · `),note:r?.nightly?`${vo(r.nightly,n)} ${t.visualPerNight}`:i.priceNote,available:i.available!==!1}}function ko({value:e,best:t}){return t===void 0||t===5?String(e):`${e}/${t}`}function Ao(e){return Array.isArray(e)?e:[e]}function jo({type:e,data:t}){let n=Ao(t[0]?.value??[]).length;if(t.some(e=>Ao(e.value).length!==n))return!1;if(e!==`pie`)return!0;let r=t.map(e=>Ao(e.value)[0]??0);return n===1&&r.every(e=>e>=0)&&r.some(e=>e>0)}const Mo=[`#f59e0b`,`#10b981`,`#ef4444`,`#8b5cf6`,`#0ea5e9`];function No({type:e,data:t},n){let r=t.map(e=>Ao(e.value)),i=Math.max(1,r[0]?.length??1),a=Math.min(0,...r.flat()),o=Math.max(0,...r.flat()),s=o-a||1,c=272/Math.max(1,t.length),l=c*.7/i,u=Math.ceil(t.length/8),d=new Intl.NumberFormat(n,{notation:`compact`,maximumFractionDigits:1});function f(e){return 148-(e-a)/s*136}return{baseline:f(0),barWidth:l,series:Array.from({length:i},(t,n)=>r.map((t,r)=>({x:24+(r+.5)*c+(e===`bar`?(n-(i-1)/2)*l:0),y:f(t[n]??0)}))),labels:t.flatMap((e,t)=>t%u===0?[{x:24+(t+.5)*c,text:e.label.length*5>c*u?`${e.label.slice(0,Math.max(1,Math.floor(c*u/5)-1))}…`:e.label}]:[]),ticks:[.../* @__PURE__ */ new Set([o,a])].map(e=>({y:f(e),text:d.format(e)})),slices:e===`pie`?Po(r.map(e=>e[0]??0)):[]}}function Po(e){let t=e.reduce((e,t)=>e+t,0)||1,n=-Math.PI/2;return e.map(e=>{let r=n+e/t*2*Math.PI,i=Fo(n,Math.min(r,n+2*Math.PI-1e-4));return n=r,{path:i,share:e/t}})}function Fo(e,t){let n=+(t-e>Math.PI),r=(e,t)=>`${(160+e*Math.cos(t)).toFixed(2)} ${(84+e*Math.sin(t)).toFixed(2)}`;return`M${r(64,e)}A64 64 0 ${n} 1 ${r(64,t)}L${r(40,t)}A40 40 0 ${n} 0 ${r(40,e)}Z`}function Io(e){if(!e||e.length<2)return;let t=Math.min(...e),n=Math.max(...e)-t||1;return e.map((r,i)=>`${(i*80/(e.length-1)).toFixed(1)},${(22-(r-t)/n*20).toFixed(1)}`).join(` `)}function Lo(e){let t=/^[^\d\-−+]{0,4}([-−+]?\d[\d.,\s]*?)\s?[^\d]{0,4}$/u.exec(e.trim());if(!t?.[1])return;let n=t[1].replace(/\s/g,``).replace(`−`,`-`),r=n.match(/[.,]/g)??[],i=r.at(-1),a=new Set(r).size>1||r.length===1&&!/^[-+]?[1-9]\d{0,2}[.,]\d{3}$/.test(n)?i:void 0,o=Number(n.replace(a===`,`?/\./g:a===`.`?/,/g:/[.,]/g,``).replace(`,`,`.`));return Number.isFinite(o)?o:void 0}function Ro(e,t){return e.map((e,n)=>{let r=t.map(e=>e[n]??``).filter(e=>e.trim());return r.length>0&&r.every(e=>Lo(e)!==void 0)})}function zo(e,t,n){if(!t)return e;let r=new Intl.Collator(n,{numeric:!0}),i=t.descending?-1:1;return[...e].sort((e,n)=>{let[a,o]=[e[t.column]??``,n[t.column]??``];return i*(t.numeric?(Lo(a)??0)-(Lo(o)??0):r.compare(a,o))})}new Map(Object.entries({Product:280,Stay:280,Package:280,Flight:300,Cart:480,Order:480,Booking:480}));function Bo(e){return e.typeName===`Cell`?e.props.span??1:1}function Vo(e,t){let n=e.reduce((e,n)=>e+Math.min(n,t),0);return Math.ceil(n/Math.max(1,Math.ceil(n/t)))||1}function Ho(e){let t=new Set(e.map(e=>{let t=e.typeName===`Cell`?e.props.children.length===1?e.props.children[0]:void 0:e;return t?.typeName===`Metric`?`Card`:t?.typeName}));return t.size===1&&!t.has(void 0)}function Uo({scrollLeft:e,scrollWidth:t,clientWidth:n}){let r=Math.abs(e);return{start:r>1,end:r<t-n-1}}function Wo(e){return/^https:\/\//i.test(e??``)}function Go(e,t){return(e??[]).flatMap(e=>e.url?Wo(e.url)?[{...e,url:e.url,message:void 0}]:[]:t?[{...e,url:void 0,message:e.label}]:[])}function Ko(e,t,n){return`${e}: ${[t,...Object.entries(n??{}).map(([e,t])=>`${e}: ${t}`)].join(`, `)}`}function qo(e){return[...e.legs.map(e=>e.number??e.carrier),e.fare].filter(Boolean).join(`, `)}function Jo(e,t){return t!==void 0&&t.currency===e.currency&&t.amount>e.amount}function Yo(e,t){let n=e.variants??[],r=(e.options??[]).filter(e=>e.values.length).map(r=>({...r,value:t[r.name]??r.values.find(t=>t===e.selected?.[r.name])??(r.values.length===1?r.values[0]:void 0),unavailable:n.length?r.values.filter(e=>!n.some(t=>t.available!==!1&&t.options[r.name]===e)):[]})),i=r.filter(e=>e.value===void 0).map(e=>e.name),a=Object.fromEntries(r.flatMap(e=>e.value===void 0?[]:[[e.name,e.value]])),o=i.length?void 0:n.find(e=>r.every(t=>e.options[t.name]===t.value)),s=!i.length&&n.length?o!==void 0&&o.available!==!1:e.available!==!1;return{options:r,missing:i,chosen:a,available:s,price:o?.price??e.price,compareAtPrice:o?.price?o.compareAtPrice:e.compareAtPrice,image:o?.image??e.image,canBuy:!i.length&&s}}const Xo={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`},Carousel:{$ref:`#/$defs/Carousel`},Text:{$ref:`#/$defs/Text`},Card:{$ref:`#/$defs/Card`},Metric:{$ref:`#/$defs/Metric`},Table:{$ref:`#/$defs/Table`},Chart:{$ref:`#/$defs/Chart`},Product:{$ref:`#/$defs/Product`},Cart:{$ref:`#/$defs/Cart`},Order:{$ref:`#/$defs/Order`},Flight:{$ref:`#/$defs/Flight`},Stay:{$ref:`#/$defs/Stay`},Package:{$ref:`#/$defs/Package`},Booking:{$ref:`#/$defs/Booking`}},required:[`Root`,`Grid`,`Cell`,`Carousel`,`Text`,`Card`,`Metric`,`Table`,`Chart`,`Product`,`Cart`,`Order`,`Flight`,`Stay`,`Package`,`Booking`],additionalProperties:!1,$defs:{Root:{type:`object`,properties:{children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Grid`},{$ref:`#/$defs/Carousel`},{$ref:`#/$defs/Text`},{$ref:`#/$defs/Card`},{$ref:`#/$defs/Metric`},{$ref:`#/$defs/Table`},{$ref:`#/$defs/Chart`},{$ref:`#/$defs/Product`},{$ref:`#/$defs/Cart`},{$ref:`#/$defs/Order`},{$ref:`#/$defs/Flight`},{$ref:`#/$defs/Stay`},{$ref:`#/$defs/Package`},{$ref:`#/$defs/Booking`}]}}},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`},{$ref:`#/$defs/Product`},{$ref:`#/$defs/Cart`},{$ref:`#/$defs/Order`},{$ref:`#/$defs/Flight`},{$ref:`#/$defs/Stay`},{$ref:`#/$defs/Package`},{$ref:`#/$defs/Booking`}]}}},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`},{$ref:`#/$defs/Product`},{$ref:`#/$defs/Cart`},{$ref:`#/$defs/Order`},{$ref:`#/$defs/Flight`},{$ref:`#/$defs/Stay`},{$ref:`#/$defs/Package`},{$ref:`#/$defs/Booking`}]}},span:{type:`integer`,enum:[1,2,3,4],default:1}},required:[`children`],additionalProperties:!1},Carousel:{type:`object`,properties:{children:{type:`array`,items:{anyOf:[{$ref:`#/$defs/Card`},{$ref:`#/$defs/Product`},{$ref:`#/$defs/Flight`},{$ref:`#/$defs/Stay`},{$ref:`#/$defs/Package`}]}}},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`},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}},image:{type:`string`}},required:[`title`,`body`],additionalProperties:!1},Metric:{type:`object`,properties:{label:{type:`string`},value:{type:`string`},detail:{type:`string`},change:{type:`object`,properties:{text:{type:`string`},tone:{type:`string`,enum:[`good`,`bad`,`neutral`]}},required:[`text`,`tone`]},trend:{type:`array`,items:{type:`number`}}},required:[`label`,`value`],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`,`pie`]},data:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},value:{anyOf:[{type:`number`},{type:`array`,items:{type:`number`}}]}},required:[`label`,`value`],additionalProperties:!1}},series:{type:`array`,items:{type:`string`}}},required:[`title`,`type`,`data`],additionalProperties:!1},Product:{type:`object`,properties:{product:{type:`object`,properties:{title:{type:`string`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},id:{type:`string`},compareAtPrice:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},image:{type:`string`},url:{type:`string`},description:{type:`string`},badge:{type:`string`},rating:{type:`object`,properties:{value:{type:`number`},count:{type:`integer`},best:{type:`number`}},required:[`value`]},available:{type:`boolean`},options:{type:`array`,items:{type:`object`,properties:{name:{type:`string`},values:{type:`array`,items:{type:`string`}}},required:[`name`,`values`]}},variants:{type:`array`,items:{type:`object`,properties:{options:{type:`object`,additionalProperties:{type:`string`}},id:{type:`string`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},compareAtPrice:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},image:{type:`string`},available:{type:`boolean`}},required:[`options`]}},selected:{type:`object`,additionalProperties:{type:`string`}},details:{type:`array`,items:{type:`string`}}},required:[`title`,`price`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`product`],additionalProperties:!1},Cart:{type:`object`,properties:{cart:{type:`object`,properties:{lines:{type:`array`,items:{type:`object`,properties:{title:{type:`string`},quantity:{type:`integer`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},image:{type:`string`},url:{type:`string`},options:{type:`object`,additionalProperties:{type:`string`}},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`title`,`quantity`,`price`]}},totals:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},amount:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]}},required:[`label`,`amount`]}},messages:{type:`array`,items:{type:`object`,properties:{text:{type:`string`},severity:{type:`string`,enum:[`info`,`warning`,`error`]}},required:[`text`,`severity`]}}},required:[`lines`,`totals`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`cart`],additionalProperties:!1},Order:{type:`object`,properties:{order:{type:`object`,properties:{number:{type:`string`},status:{type:`string`},date:{type:`string`},items:{type:`array`,items:{type:`object`,properties:{title:{type:`string`},quantity:{type:`integer`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},image:{type:`string`},url:{type:`string`},options:{type:`object`,additionalProperties:{type:`string`}},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`title`,`quantity`,`price`]}},totals:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},amount:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]}},required:[`label`,`amount`]}},timeline:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},done:{type:`boolean`},date:{type:`string`}},required:[`label`,`done`]}},details:{type:`array`,items:{type:`string`}}},required:[`number`,`status`,`items`,`totals`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`order`],additionalProperties:!1},Flight:{type:`object`,properties:{flight:{type:`object`,properties:{legs:{type:`array`,items:{type:`object`,properties:{from:{type:`string`},to:{type:`string`},departs:{type:`string`},arrives:{type:`string`},carrier:{type:`string`},number:{type:`string`},duration:{type:`integer`},stops:{type:`array`,items:{type:`string`}}},required:[`from`,`to`,`departs`,`arrives`,`carrier`]},minItems:1},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},id:{type:`string`},priceNote:{type:`string`},fare:{type:`string`},badge:{type:`string`},details:{type:`array`,items:{type:`string`}},available:{type:`boolean`}},required:[`legs`,`price`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`flight`],additionalProperties:!1},Stay:{type:`object`,properties:{stay:{type:`object`,properties:{name:{type:`string`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},id:{type:`string`},image:{type:`string`},url:{type:`string`},location:{type:`string`},stars:{type:`integer`},rating:{type:`object`,properties:{value:{type:`number`},count:{type:`integer`},best:{type:`number`}},required:[`value`]},checkIn:{type:`string`},checkOut:{type:`string`},room:{type:`string`},nightly:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},compareAtPrice:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},badge:{type:`string`},details:{type:`array`,items:{type:`string`}},available:{type:`boolean`}},required:[`name`,`price`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`stay`],additionalProperties:!1},Package:{type:`object`,properties:{package:{type:`object`,properties:{title:{type:`string`},price:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},id:{type:`string`},image:{type:`string`},url:{type:`string`},location:{type:`string`},start:{type:`string`},end:{type:`string`},nights:{type:`integer`},priceNote:{type:`string`},compareAtPrice:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]},rating:{type:`object`,properties:{value:{type:`number`},count:{type:`integer`},best:{type:`number`}},required:[`value`]},badge:{type:`string`},details:{type:`array`,items:{type:`string`}},available:{type:`boolean`}},required:[`title`,`price`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`package`],additionalProperties:!1},Booking:{type:`object`,properties:{booking:{type:`object`,properties:{reference:{type:`string`},status:{type:`string`},title:{type:`string`},start:{type:`string`},end:{type:`string`},travellers:{type:`array`,items:{type:`string`}},itinerary:{type:`array`,items:{type:`object`,properties:{title:{type:`string`},date:{type:`string`},time:{type:`string`},detail:{type:`string`}},required:[`title`]}},totals:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},amount:{type:`object`,properties:{amount:{type:`integer`},currency:{type:`string`,pattern:`^[A-Za-z]{3}$`}},required:[`amount`,`currency`]}},required:[`label`,`amount`]}},details:{type:`array`,items:{type:`string`}}},required:[`reference`,`status`]},actions:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},url:{type:`string`},primary:{type:`boolean`}},required:[`label`]}}},required:[`booking`],additionalProperties:!1}}}};function Zo(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 Qo=/* @__PURE__ */ new Set([`Comp`,`Ref`,`StateRef`,`RuntimeRef`,`BinOp`,`UnaryOp`,`Ternary`,`Member`,`Index`,`Assign`,`Str`,`Num`,`Bool`,`Null`,`Arr`,`Obj`,`Ph`]);function $o(e){return!e||typeof e!=`object`||Array.isArray(e)?!1:Qo.has(e.k)}function es(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 ts(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(ts)}:typeof e==`object`?{k:`Obj`,entries:Object.entries(e).map(([e,t])=>[e,ts(t)])}:{k:`Null`}}function ns(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=ns(n);if(!e)return;t.push(e.v)}return{v:t}}case`Obj`:{let t={};for(let[n,r]of e.entries){let e=ns(r);if(!e)return;t[n]=e.v}return{v:t}}default:return}}const rs=/* @__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}]]),is={ActionExpression:!0,OpenUrl:!0,ToAssistant:!0},as={Query:`Query`,Mutation:`Mutation`};function os(e){return e?.callDefs??rs}function ss(e){return rs.has(e)}function cs(e){return e in as}var K;(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`})(K||(K={}));function ls(e){let t=0,n=()=>e[t]??{t:K.EOF},r=()=>{let e=n();return t++,e},i=e=>{n().t===e&&t++};function a(e){switch(e.t){case K.Question:return 1;case K.Or:return 2;case K.And:return 3;case K.EqEq:case K.NotEq:return 4;case K.Greater:case K.Less:case K.GreaterEq:case K.LessEq:return 5;case K.Plus:case K.Minus:return 6;case K.Star:case K.Slash:case K.Percent:return 7;case K.Dot:case K.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===K.Str)return r(),{k:`Str`,v:a.v};if(a.t===K.Num)return r(),{k:`Num`,v:a.v};if(a.t===K.True)return r(),{k:`Bool`,v:!0};if(a.t===K.False)return r(),{k:`Bool`,v:!1};if(a.t===K.Null)return r(),{k:`Null`};if(a.t===K.LBrack)return u();if(a.t===K.LBrace)return d();if(a.t===K.StateVar){let e=a.v;return r(),n().t===K.Equals?(r(),{k:`Assign`,target:e,value:o(0)}):{k:`StateRef`,n:e}}if(a.t===K.Type){let n=a.v;return e[t+1]?.t===K.LParen&&(!ss(n)||n===`Action`)?l():(r(),{k:`Ref`,n})}if(a.t===K.BuiltinCall){if(e[t+1]?.t===K.LParen){let e=l();return e.k===`Comp`&&!ss(e.name)&&(e.fn=!0),e}return r(),{k:`Ref`,n:a.v}}if(a.t===K.Ident)return r(),{k:`Ref`,n:a.v};if(a.t===K.Not)return r(),{k:`UnaryOp`,op:`!`,operand:o(8)};if(a.t===K.Minus)return r(),{k:`UnaryOp`,op:`-`,operand:o(8)};if(a.t===K.LParen){r();let e=o(0);return i(K.RParen),e}return r(),{k:`Null`}}function c(e){let t=n();if(t.t===K.Plus)return r(),{k:`BinOp`,op:`+`,left:e,right:o(6)};if(t.t===K.Minus)return r(),{k:`BinOp`,op:`-`,left:e,right:o(6)};if(t.t===K.Star)return r(),{k:`BinOp`,op:`*`,left:e,right:o(7)};if(t.t===K.Slash)return r(),{k:`BinOp`,op:`/`,left:e,right:o(7)};if(t.t===K.Percent)return r(),{k:`BinOp`,op:`%`,left:e,right:o(7)};if(t.t===K.EqEq)return r(),{k:`BinOp`,op:`==`,left:e,right:o(4)};if(t.t===K.NotEq)return r(),{k:`BinOp`,op:`!=`,left:e,right:o(4)};if(t.t===K.Greater)return r(),{k:`BinOp`,op:`>`,left:e,right:o(5)};if(t.t===K.Less)return r(),{k:`BinOp`,op:`<`,left:e,right:o(5)};if(t.t===K.GreaterEq)return r(),{k:`BinOp`,op:`>=`,left:e,right:o(5)};if(t.t===K.LessEq)return r(),{k:`BinOp`,op:`<=`,left:e,right:o(5)};if(t.t===K.And)return r(),{k:`BinOp`,op:`&&`,left:e,right:o(3)};if(t.t===K.Or)return r(),{k:`BinOp`,op:`||`,left:e,right:o(2)};if(t.t===K.Question){r();let t=o(0);return i(K.Colon),{k:`Ternary`,cond:e,then:t,else:o(0)}}if(t.t===K.Dot){r();let t=n();return{k:`Member`,obj:e,field:t.t===K.Ident||t.t===K.Type||t.t===K.Str||t.t===K.Num?(r(),String(t.v)):t.t===K.StateVar?(r(),t.v.replace(/^\$/,``)):(r(),`?`)}}if(t.t===K.LBrack){r();let t=o(0);return i(K.RBrack),{k:`Index`,obj:e,index:t}}return e}function l(){let e=n().v;r(),i(K.LParen);let t=[];for(;n().t!==K.RParen&&n().t!==K.EOF;)t.push(o(0)),n().t===K.Comma&&r();return i(K.RParen),{k:`Comp`,name:e,args:t}}function u(){r();let e=[];for(;n().t!==K.RBrack&&n().t!==K.EOF;)e.push(o(0)),n().t===K.Comma&&r();return i(K.RBrack),{k:`Arr`,els:e}}function d(){r();let e=[];for(;n().t!==K.RBrace&&n().t!==K.EOF;){let t=n(),a=t.t===K.Ident||t.t===K.Str||t.t===K.Type||t.t===K.Num?(r(),String(t.v)):t.t===K.StateVar?(r(),t.v.replace(/^\$/,``)):(r(),`?`);i(K.Colon),e.push([a,o(0)]),n().t===K.Comma&&r()}return i(K.RBrace),{k:`Obj`,entries:e}}return o(0)}function us(e){let t=[],n=0,r=e.length;for(;n<r;){for(;n<r&&(e.charAt(n)===` `||e.charAt(n)===` `||e.charAt(n)===`\r`);)n++;if(n>=r)break;let i=e.charAt(n);if(i===`
41
41
  `){t.push({t:K.Newline}),n++;continue}if(i===`(`){t.push({t:K.LParen}),n++;continue}if(i===`)`){t.push({t:K.RParen}),n++;continue}if(i===`[`){t.push({t:K.LBrack}),n++;continue}if(i===`]`){t.push({t:K.RBrack}),n++;continue}if(i===`{`){t.push({t:K.LBrace}),n++;continue}if(i===`}`){t.push({t:K.RBrace}),n++;continue}if(i===`,`){t.push({t:K.Comma}),n++;continue}if(i===`:`){t.push({t:K.Colon}),n++;continue}if(i===`=`){n+1<r&&e.charAt(n+1)===`=`?(t.push({t:K.EqEq}),n+=2):(t.push({t:K.Equals}),n++);continue}if(i===`!`){n+1<r&&e.charAt(n+1)===`=`?(t.push({t:K.NotEq}),n+=2):(t.push({t:K.Not}),n++);continue}if(i===`>`){n+1<r&&e.charAt(n+1)===`=`?(t.push({t:K.GreaterEq}),n+=2):(t.push({t:K.Greater}),n++);continue}if(i===`<`){n+1<r&&e.charAt(n+1)===`=`?(t.push({t:K.LessEq}),n+=2):(t.push({t:K.Less}),n++);continue}if(i===`&`){n+1<r&&e.charAt(n+1)===`&`?(t.push({t:K.And}),n+=2):(t.push({t:K.And}),n++);continue}if(i===`|`){n+1<r&&e.charAt(n+1)===`|`?(t.push({t:K.Or}),n+=2):(t.push({t:K.Or}),n++);continue}if(i===`.`){t.push({t:K.Dot}),n++;continue}if(i===`?`){t.push({t:K.Question}),n++;continue}if(i===`+`){t.push({t:K.Plus}),n++;continue}if(i===`*`){t.push({t:K.Star}),n++;continue}if(i===`/`){t.push({t:K.Slash}),n++;continue}if(i===`%`){t.push({t:K.Percent}),n++;continue}if(i===`"`){let i=n;n++;let a=!1;for(;n<r;)if(e.charAt(n)===`\\`)n+=2;else if(e.charAt(n)===`"`){n++,a=!0;break}else n++;let o=e.slice(i,n);try{let e=a?o:o+`"`;t.push({t:K.Str,v:JSON.parse(e)})}catch{let e=o.replace(/^"|"$/g,``);t.push({t:K.Str,v:e})}continue}if(i===`'`){n++;let i=``;for(;n<r;)if(e.charAt(n)===`\\`){if(n++,n<r){let t=e.charAt(n);i+=t===`'`?`'`:t===`\\`?`\\`:t===`n`?`
42
- `:t===`t`?` `:t,n++}}else if(e.charAt(n)===`'`){n++;break}else i+=e.charAt(n),n++;t.push({t:K.Str,v:i});continue}if(i===`-`){let i=t.length>0?t[t.length-1]:null;if(!((i==null||i.t!==K.Num&&i.t!==K.Str&&i.t!==K.Ident&&i.t!==K.Type&&i.t!==K.RParen&&i.t!==K.RBrack&&i.t!==K.True&&i.t!==K.False&&i.t!==K.Null&&i.t!==K.StateVar&&i.t!==K.BuiltinCall)&&n+1<r&&e.charAt(n+1)>=`0`&&e.charAt(n+1)<=`9`)){t.push({t:K.Minus}),n++;continue}}let a=i>=`0`&&i<=`9`,o=i===`-`&&n+1<r&&e.charAt(n+1)>=`0`&&e.charAt(n+1)<=`9`;if(a||o){let i=n;for(e.charAt(n)===`-`&&n++;n<r&&e.charAt(n)>=`0`&&e.charAt(n)<=`9`;)n++;if(n<r&&e.charAt(n)===`.`&&n+1<r&&e.charAt(n+1)>=`0`&&e.charAt(n+1)<=`9`)for(n++;n<r&&e.charAt(n)>=`0`&&e.charAt(n)<=`9`;)n++;if(n<r&&(e.charAt(n)===`e`||e.charAt(n)===`E`))for(n++,n<r&&(e.charAt(n)===`+`||e.charAt(n)===`-`)&&n++;n<r&&e.charAt(n)>=`0`&&e.charAt(n)<=`9`;)n++;t.push({t:K.Num,v:+e.slice(i,n)})}else if(i===`$`&&n+1<r&&(e.charAt(n+1)>=`a`&&e.charAt(n+1)<=`z`||e.charAt(n+1)>=`A`&&e.charAt(n+1)<=`Z`||e.charAt(n+1)===`_`)){let i=n;for(n++;n<r&&(e.charAt(n)>=`a`&&e.charAt(n)<=`z`||e.charAt(n)>=`A`&&e.charAt(n)<=`Z`||e.charAt(n)>=`0`&&e.charAt(n)<=`9`||e.charAt(n)===`_`);)n++;t.push({t:K.StateVar,v:e.slice(i,n)})}else if(i>=`a`&&i<=`z`||i>=`A`&&i<=`Z`||i===`_`){let a=n;for(;n<r&&(e.charAt(n)>=`a`&&e.charAt(n)<=`z`||e.charAt(n)>=`A`&&e.charAt(n)<=`Z`||e.charAt(n)>=`0`&&e.charAt(n)<=`9`||e.charAt(n)===`_`);)n++;let o=e.slice(a,n);if(o===`true`){t.push({t:K.True});continue}if(o===`false`){t.push({t:K.False});continue}if(o===`null`){t.push({t:K.Null});continue}let s=i>=`A`&&i<=`Z`?K.Type:K.Ident;t.push({t:s,v:o})}else if(i===`@`&&n+1<r&&(e.charAt(n+1)>=`a`&&e.charAt(n+1)<=`z`||e.charAt(n+1)>=`A`&&e.charAt(n+1)<=`Z`||e.charAt(n+1)===`_`)){n++;let i=n;for(;n<r&&(e.charAt(n)>=`a`&&e.charAt(n)<=`z`||e.charAt(n)>=`A`&&e.charAt(n)<=`Z`||e.charAt(n)>=`0`&&e.charAt(n)<=`9`||e.charAt(n)===`_`);)n++;t.push({t:K.BuiltinCall,v:e.slice(i,n)})}else n++}return t.push({t:K.EOF}),t}function ls(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 us;(function(e){e.ContinueConversation=`continue_conversation`,e.OpenUrl=`open_url`})(us||(us={}));const ds={},fs=[];function ps(e){return Array.isArray(e)?`array`:typeof e}function ms(e){return typeof e.$ref==`string`?e.$ref.split(`/`).pop():void 0}function hs(e){return`$ref`in e||`anyOf`in e||`oneOf`in e||`allOf`in e}function gs(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 _s(e){if(e&&typeof e==`object`&&!Array.isArray(e))return e.default}function vs(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=ms(t);if(n)return n;let r=gs(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 ys(e,t){return`${e}(${t.map(e=>{let t=vs(e.schema),n=e.required?`${e.name}*`:e.name;return t?`${n}: ${t}`:n}).join(`, `)})`}function bs(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:ps(e)}:t.expectedType&&t.expectedType!==n?{expected:t.expectedType,actual:ps(e)}:null}function xs(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 Ss(e,t,n,r){e.errors.push({code:r.code,component:t,path:n,message:xs(t,n,r),statementId:e.currentStatementId,...r.code===`no-root`&&r.reason===`fallback`&&{severity:`warning`}})}const Cs=Symbol(`invalid`);function ws(e,t){return t===void 0?e?Cs:void 0:t}function Ts(e,t,n,r,i){return hs(t)?!1:typeof t.type==`string`||Array.isArray(t.enum)||`const`in t?(Ss(i,n,r,{code:`type-mismatch`,expected:typeof t.type==`string`?t.type:`a literal value`,actual:`component "${e.typeName}"`}),!0):!1}function Es(e){return(e.anyOf??e.oneOf??[e]).map(ms)}function Ds(e,t){let n=Es(e);return n.length>0&&n.every(e=>e!==void 0&&t.cat?.has(e))}function Os(e,t,n,r,i){if(typeof e!=`object`||Array.isArray(e))return Ss(i,n,r,{code:`type-mismatch`,expected:`object`,actual:ps(e)}),Cs;let a=e,o,s=t.properties&&typeof t.properties==`object`?t.properties:ds,c=Array.isArray(t.required)?t.required:fs,l=!1;if(!i.partial)for(let e of c){let t=e in a;if(!t||a[e]==null){let c=_s(s[e]);if(c!==void 0){(o??(o={...a}))[e]=c;continue}Ss(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=js(a[e],t,n,`${r}/${e}`,i);u===Cs&&(u=ws(c.includes(e),_s(t)),u===Cs)?l=!0:u!==a[e]&&(o??(o={...a}),u===void 0?delete o[e]:o[e]=u)}return l?Cs:o??a}function ks(e,t,n,r,i){if(!Array.isArray(e))return Ss(i,n,r,{code:`type-mismatch`,expected:`array`,actual:ps(e)}),Cs;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=js(e[t],a,n,`${r}/${t}`,i);s!==e[t]&&!o&&(o=e.slice(0,t)),o&&s!==Cs&&o.push(s)}return o??e}function As(e,t,n,r,i){let a=gs(t);if(a.expectedType==null&&a.enumValues==null||a.enumValues&&i.partial)return!1;let o=bs(e,a);return o?(Ss(i,n,r,{code:`type-mismatch`,...o}),!0):!1}function js(e,t,n,r,i){if(!t||typeof t!=`object`||Array.isArray(t))return e;let a=t;if(e==null||Zo(e))return e;if(ls(e))return Ts(e,a,n,r,i)?Cs:e;if(hs(a))return Ds(a,i)?(Ss(i,n,r,{code:`type-mismatch`,expected:Es(a).join(` | `),actual:Array.isArray(e)?`array`:typeof e==`object`?`plain object`:typeof e}),Cs):e;let o=a.type;return o===`object`?Os(e,a,n,r,i):o===`array`?ks(e,a,n,r,i):As(e,a,n,r,i)?Cs:e}function Ms(e){if(typeof e!=`object`||!e)return!1;if(Zo(e))return!0;if(Array.isArray(e))return e.some(Ms);if(ls(e))return Object.values(e.props).some(Ms);let t=e;return Array.isArray(t.steps)?!0:Object.values(t).some(Ms)}function Ns(e,t,n){if(t.visited.has(e))return t.unres.push(e),n===`expr`?{k:`Ph`,n:e}:null;let r=t.syms.get(e);if(!r)return t.unres.push(e),n===`expr`?{k:`Ph`,n:e}:null;if(t.unreached?.delete(e),r.k===`Comp`&&os(r.name))return{k:`RuntimeRef`,n:e,refType:r.name===rs.Mutation?`mutation`:`query`};t.visited.add(e);let i=t.currentStatementId;t.currentStatementId=e;try{let i=n===`value`?Hs(r,t):Vs(r,t);return n===`value`&&ls(i)&&(i.statementId=e),i}finally{t.currentStatementId=i,t.visited.delete(e)}}function Ps(e,t){return is(t.cat).has(e)||os(e)}function Fs(e,t){let n={};for(let[r,i]of t.entries()){let t=e[r];if(t===void 0)break;n[i.name]=t}return n}function Is(e,t,n,r){let{params:i}=n;t.length>i.length&&Ss(r,e,``,{code:`excess-args`,declared:i.length,got:t.length});let a=Fs(t,i),o=!1,s=r.errors.length;for(let t of i){let n=a[t.name],s=n?es(n):{v:void 0};if(!s)continue;if(s.v==null){if(!t.required||t.defaultValue!==void 0)continue;Ss(r,e,`/${t.name}`,{code:n?`null-required`:`missing-required`,signature:ys(e,i)}),o=!0;continue}let c=js(s.v,t.schema,e,`/${t.name}`,r);c===Cs&&(c=ws(t.required,t.defaultValue)),c===Cs?o=!0:c===void 0?delete a[t.name]:c!==s.v&&(a[t.name]=$o(c))}return n.kind===`action`&&r.errors.length>s&&(o=!0),o?null:a}function Ls(e,t,n){let r=e.args.map(n),i=is(t.cat).get(e.name);if(!i||i.lazy)return{...e,args:r};let a=i.builtin?Fs(r,i.params):Is(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 Rs(e,t,n){let r=t.currentStatementId;t.currentStatementId=n;let i=/* @__PURE__ */ new Set;for(let n of e)Qo(n,e=>{if(e.k!==`Comp`||i.has(e))return;i.add(e);let n=is(t.cat).get(e.name);n&&!n.lazy&&(e.mappedProps=(n.builtin?null:Is(e.name,e.args,n,t))??Fs(e.args,n.params))});t.currentStatementId=r}function zs(e,t,n){let r=is(t.cat).get(e.name);if(r?.kind!==`function`||!r.lazy||e.args.length<3)return null;let i=e.args[1];if(!i)return null;let 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:Bs(e,t,o));return{...e,args:s}}function Bs(e,t,n){switch(e.k){case`Ref`:return n.has(e.n)?e:Ns(e.n,t,`expr`);case`Ph`:return e;case`Comp`:{if(e.fn&&!Ps(e.name,t))return Ss(t,e.name,``,{code:`unknown-function`}),{k:`Null`};let r=zs(e,t,n);if(r)return r;if(Ps(e.name,t))return Ls(e,t,e=>Bs(e,t,n));let i=e.args.map(e=>Bs(e,t,n)),a=t.cat?.get(e.name);if(a){let t={};for(let[e,n]of a.params.entries()){let r=i[e];r&&(t[n.name]=r)}return{...e,args:i,mappedProps:t}}return Ss(t,e.name,``,{code:`unknown-component`,available:t.cat&&[...t.cat.keys()]}),{...e,args:i}}case`Arr`:return{...e,els:e.els.map(e=>Bs(e,t,n))};case`Obj`:return{...e,entries:e.entries.map(([e,r])=>[e,Bs(r,t,n)])};case`BinOp`:return{...e,left:Bs(e.left,t,n),right:Bs(e.right,t,n)};case`UnaryOp`:return{...e,operand:Bs(e.operand,t,n)};case`Ternary`:return{...e,cond:Bs(e.cond,t,n),then:Bs(e.then,t,n),else:Bs(e.else,t,n)};case`Member`:return{...e,obj:Bs(e.obj,t,n)};case`Index`:return{...e,obj:Bs(e.obj,t,n),index:Bs(e.index,t,n)};case`Assign`:return{...e,value:Bs(e.value,t,n)};default:return e}}function Vs(e,t){return Bs(e,t,/* @__PURE__ */ new Set)}function Hs(e,t){switch(e.k){case`Ref`:return Ns(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=Hs(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]=Hs(i,t);return n}case`Comp`:{let{name:n,args:r}=e;if(e.fn&&!Ps(n,t))return Ss(t,n,``,{code:`unknown-function`}),null;if(os(n))return Ss(t,n,``,{code:`inline-reserved`}),null;if(Ps(n,t))return zs(e,t,/* @__PURE__ */ new Set)||Ls(e,t,e=>Vs(e,t));let i=t.cat?.get(n),a={};if(i){let e=!1;for(let[o,s]of i.params.entries()){let i=r[o];if(!i)break;let c=t.prunedValues,l=Hs(i,t);if(t.prunedValues>c&&Ss(t,n,`/${s.name}`,{code:`pruned-value`}),a[s.name]=l,s.schema===void 0)continue;if(l==null&&s.defaultValue!==void 0){Ss(t,n,`/${s.name}`,{code:`type-mismatch`,expected:vs(s.schema)??`a defined value`,actual:l===null?`null`:`undefined`}),a[s.name]=s.defaultValue,t.prunedValues=c;continue}let u=js(l,s.schema,n,`/${s.name}`,t);u===Cs&&(u=ws(s.required,s.defaultValue),s.defaultValue!==void 0&&(t.prunedValues=c),u===Cs?e=!0:u===void 0&&delete a[s.name]),u!==Cs&&u!==void 0&&(a[s.name]=u)}r.length>i.params.length&&Ss(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||(Ss(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)Ss(t,n,`/${r.name}`,{code:r.name in a?`null-required`:`missing-required`,signature:ys(n,i.params)});return null}}if(e)return null}else return Ss(t,n,``,{code:`unknown-component`,available:t.cat&&[...t.cat.keys()]}),null;let o=Object.values(a).some(e=>Ms(e));return{type:`element`,typeName:n,props:a,partial:t.partial,hasDynamicProps:o}}default:return Yo(e)?Vs(e,t):e}}function Us(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 Ws(e){let t=[],n=0;for(;n<e.length;){for(;n<e.length&&e[n]?.t===K.Newline;)n++;if(n>=e.length||e[n]?.t===K.EOF)break;let r=e[n];if(!r)break;if(r.t!==K.Ident&&r.t!==K.Type&&r.t!==K.StateVar){for(;n<e.length&&e[n]?.t!==K.Newline&&e[n]?.t!==K.EOF;)n++;continue}let i=r.v,a=r.t;if(n++,n>=e.length||e[n]?.t!==K.Equals){for(;n<e.length&&e[n]?.t!==K.Newline&&e[n]?.t!==K.EOF;)n++;continue}n++;let o=[],s=0,c=0;for(;n<e.length&&e[n]?.t!==K.EOF;){let t=e[n]?.t;if(t===K.Newline&&s<=0&&c<=0){let t=n+1;for(;t<e.length&&e[t]?.t===K.Newline;)t++;let r=t<e.length?e[t]?.t:K.EOF;if(r===K.Question||r===K.Colon&&c>0){n++;continue}break}if(t===K.Newline){n++;continue}t===K.LParen||t===K.LBrack||t===K.LBrace?s++:(t===K.RParen||t===K.RBrack||t===K.RBrace)&&s>0?s--:t===K.Question&&s===0?c++:t===K.Colon&&s===0&&c>0&&c--;let r=e[n++];r&&o.push(r)}o.length&&t.push({id:i,idTokenType:a,tokens:o})}return t}function Gs(e=!0){return{root:null,meta:{incomplete:e,unresolved:[],orphaned:[],statementCount:0,errors:[]},stateDeclarations:{},queryStatements:[],mutationStatements:[]}}function Ks(e){if(!Zo(e))return[];let t=/* @__PURE__ */ new Set;return Qo(e,e=>{e.k===`StateRef`&&t.add(e.n)}),[...t]}function qs(e,t){if(t.k===`Comp`&&t.name===rs.Query){let n=Ks(t.args[1]);return{kind:`query`,id:e.id,call:{callee:rs.Query,args:t.args},expr:t,deps:n.length>0?n:void 0}}return t.k===`Comp`&&t.name===rs.Mutation?{kind:`mutation`,id:e.id,call:{callee:rs.Mutation,args:t.args},expr:t}:e.idTokenType===K.StateVar?{kind:`state`,id:e.id,init:t}:{kind:`value`,id:e.id,expr:t}}function Js(e,t,n){let r={},i=[],a=[];for(let n of e)switch(n.kind){case`state`:r[n.id]=Hs(n.init,t);break;case`query`:Rs(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`:Rs(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 Ks(i))e===n?.name&&n.stmts.has(t)||e in r||(r[e]=null)}return{stateDeclarations:r,queryStatements:i,mutationStatements:a}}const Ys=`root`;function Xs(e){return e?.k===`Comp`&&!e.fn&&!as(e.name)&&!os(e.name)}function Zs(e,t){if(e.has(Ys))return{id:Ys,fallback:!1};for(let n of e.values())if(n.kind===`value`&&Xs(n.expr)&&n.expr.name===t)return{id:n.id,fallback:!0};return null}function Qs(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 Xs(e)}function $s(e){let t=!1;return Qo(e,e=>{Xs(e)&&(t=!0)}),t}function ec(e,t,n,r,i,a,o){let s=Zs(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,h=s&&c.get(s.id);if(s&&h){let e=Hs(h,f);ls(e)?(p=e,p.statementId=s.id):Zo(e)&&$s(e)&&(m=e)}let{stateDeclarations:g,queryStatements:_,mutationStatements:v}=Js(t,f,o);f.currentStatementId=s?.id;let y=a??``;s?!p&&!m&&!Qs(c.get(s.id),c)?Ss(f,y,``,{code:`no-root`,reason:`not-component`}):s.fallback&&Ss(f,y,``,{code:`no-root`,reason:p?`fallback`:`missing`}):Ss(f,y,``,{code:`no-root`,reason:`missing`});let b=s?[...d]:[];return{root:p,...m?{rootExpression:m}:{},meta:{incomplete:n,unresolved:l,orphaned:b,statementCount:r,errors:u},stateDeclarations:g,queryStatements:_,mutationStatements:v}}function tc(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 nc(e){let t=[],n=0;for(;n<e.length;){let r=-1;for(;n<e.length;){let t=tc(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]!==`
43
- `;)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=tc(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(`
42
+ `:t===`t`?` `:t,n++}}else if(e.charAt(n)===`'`){n++;break}else i+=e.charAt(n),n++;t.push({t:K.Str,v:i});continue}if(i===`-`){let i=t.length>0?t[t.length-1]:null;if(!((i==null||i.t!==K.Num&&i.t!==K.Str&&i.t!==K.Ident&&i.t!==K.Type&&i.t!==K.RParen&&i.t!==K.RBrack&&i.t!==K.True&&i.t!==K.False&&i.t!==K.Null&&i.t!==K.StateVar&&i.t!==K.BuiltinCall)&&n+1<r&&e.charAt(n+1)>=`0`&&e.charAt(n+1)<=`9`)){t.push({t:K.Minus}),n++;continue}}let a=i>=`0`&&i<=`9`,o=i===`-`&&n+1<r&&e.charAt(n+1)>=`0`&&e.charAt(n+1)<=`9`;if(a||o){let i=n;for(e.charAt(n)===`-`&&n++;n<r&&e.charAt(n)>=`0`&&e.charAt(n)<=`9`;)n++;if(n<r&&e.charAt(n)===`.`&&n+1<r&&e.charAt(n+1)>=`0`&&e.charAt(n+1)<=`9`)for(n++;n<r&&e.charAt(n)>=`0`&&e.charAt(n)<=`9`;)n++;if(n<r&&(e.charAt(n)===`e`||e.charAt(n)===`E`))for(n++,n<r&&(e.charAt(n)===`+`||e.charAt(n)===`-`)&&n++;n<r&&e.charAt(n)>=`0`&&e.charAt(n)<=`9`;)n++;t.push({t:K.Num,v:+e.slice(i,n)})}else if(i===`$`&&n+1<r&&(e.charAt(n+1)>=`a`&&e.charAt(n+1)<=`z`||e.charAt(n+1)>=`A`&&e.charAt(n+1)<=`Z`||e.charAt(n+1)===`_`)){let i=n;for(n++;n<r&&(e.charAt(n)>=`a`&&e.charAt(n)<=`z`||e.charAt(n)>=`A`&&e.charAt(n)<=`Z`||e.charAt(n)>=`0`&&e.charAt(n)<=`9`||e.charAt(n)===`_`);)n++;t.push({t:K.StateVar,v:e.slice(i,n)})}else if(i>=`a`&&i<=`z`||i>=`A`&&i<=`Z`||i===`_`){let a=n;for(;n<r&&(e.charAt(n)>=`a`&&e.charAt(n)<=`z`||e.charAt(n)>=`A`&&e.charAt(n)<=`Z`||e.charAt(n)>=`0`&&e.charAt(n)<=`9`||e.charAt(n)===`_`);)n++;let o=e.slice(a,n);if(o===`true`){t.push({t:K.True});continue}if(o===`false`){t.push({t:K.False});continue}if(o===`null`){t.push({t:K.Null});continue}let s=i>=`A`&&i<=`Z`?K.Type:K.Ident;t.push({t:s,v:o})}else if(i===`@`&&n+1<r&&(e.charAt(n+1)>=`a`&&e.charAt(n+1)<=`z`||e.charAt(n+1)>=`A`&&e.charAt(n+1)<=`Z`||e.charAt(n+1)===`_`)){n++;let i=n;for(;n<r&&(e.charAt(n)>=`a`&&e.charAt(n)<=`z`||e.charAt(n)>=`A`&&e.charAt(n)<=`Z`||e.charAt(n)>=`0`&&e.charAt(n)<=`9`||e.charAt(n)===`_`);)n++;t.push({t:K.BuiltinCall,v:e.slice(i,n)})}else n++}return t.push({t:K.EOF}),t}function ds(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 fs;(function(e){e.ContinueConversation=`continue_conversation`,e.OpenUrl=`open_url`})(fs||(fs={}));const ps={},ms=[];function hs(e){return Array.isArray(e)?`array`:typeof e}function gs(e){return typeof e.$ref==`string`?e.$ref.split(`/`).pop():void 0}function _s(e){return`$ref`in e||`anyOf`in e||`oneOf`in e||`allOf`in e}function vs(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 ys(e){if(e&&typeof e==`object`&&!Array.isArray(e))return e.default}function bs(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=gs(t);if(n)return n;let r=vs(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 xs(e,t){return`${e}(${t.map(e=>{let t=bs(e.schema),n=e.required?`${e.name}*`:e.name;return t?`${n}: ${t}`:n}).join(`, `)})`}function Ss(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:hs(e)}:t.expectedType&&t.expectedType!==n?{expected:t.expectedType,actual:hs(e)}:null}function Cs(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 ws(e,t,n,r){e.errors.push({code:r.code,component:t,path:n,message:Cs(t,n,r),statementId:e.currentStatementId,...r.code===`no-root`&&r.reason===`fallback`&&{severity:`warning`}})}const Ts=Symbol(`invalid`);function Es(e,t){return t===void 0?e?Ts:void 0:t}function Ds(e,t,n,r,i){return _s(t)?!1:typeof t.type==`string`||Array.isArray(t.enum)||`const`in t?(ws(i,n,r,{code:`type-mismatch`,expected:typeof t.type==`string`?t.type:`a literal value`,actual:`component "${e.typeName}"`}),!0):!1}function Os(e){return(e.anyOf??e.oneOf??[e]).map(gs)}function ks(e,t){let n=Os(e);return n.length>0&&n.every(e=>e!==void 0&&t.cat?.has(e))}function As(e,t,n,r,i){if(typeof e!=`object`||Array.isArray(e))return ws(i,n,r,{code:`type-mismatch`,expected:`object`,actual:hs(e)}),Ts;let a=e,o,s=t.properties&&typeof t.properties==`object`?t.properties:ps,c=Array.isArray(t.required)?t.required:ms,l=!1;if(!i.partial)for(let e of c){let t=e in a;if(!t||a[e]==null){let c=ys(s[e]);if(c!==void 0){(o??(o={...a}))[e]=c;continue}ws(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=Ns(a[e],t,n,`${r}/${e}`,i);u===Ts&&(u=Es(c.includes(e),ys(t)),u===Ts)?l=!0:u!==a[e]&&(o??(o={...a}),u===void 0?delete o[e]:o[e]=u)}return l?Ts:o??a}function js(e,t,n,r,i){if(!Array.isArray(e))return ws(i,n,r,{code:`type-mismatch`,expected:`array`,actual:hs(e)}),Ts;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=Ns(e[t],a,n,`${r}/${t}`,i);s!==e[t]&&!o&&(o=e.slice(0,t)),o&&s!==Ts&&o.push(s)}return o??e}function Ms(e,t,n,r,i){let a=vs(t);if(a.expectedType==null&&a.enumValues==null||a.enumValues&&i.partial)return!1;let o=Ss(e,a);return o?(ws(i,n,r,{code:`type-mismatch`,...o}),!0):!1}function Ns(e,t,n,r,i){if(!t||typeof t!=`object`||Array.isArray(t))return e;let a=t;if(e==null||$o(e))return e;if(ds(e))return Ds(e,a,n,r,i)?Ts:e;if(_s(a))return ks(a,i)?(ws(i,n,r,{code:`type-mismatch`,expected:Os(a).join(` | `),actual:Array.isArray(e)?`array`:typeof e==`object`?`plain object`:typeof e}),Ts):e;let o=a.type;return o===`object`?As(e,a,n,r,i):o===`array`?js(e,a,n,r,i):Ms(e,a,n,r,i)?Ts:e}function Ps(e){if(typeof e!=`object`||!e)return!1;if($o(e))return!0;if(Array.isArray(e))return e.some(Ps);if(ds(e))return Object.values(e.props).some(Ps);let t=e;return Array.isArray(t.steps)?!0:Object.values(t).some(Ps)}function Fs(e,t,n){if(t.visited.has(e))return t.unres.push(e),n===`expr`?{k:`Ph`,n:e}:null;let r=t.syms.get(e);if(!r)return t.unres.push(e),n===`expr`?{k:`Ph`,n:e}:null;if(t.unreached?.delete(e),r.k===`Comp`&&cs(r.name))return{k:`RuntimeRef`,n:e,refType:r.name===as.Mutation?`mutation`:`query`};t.visited.add(e);let i=t.currentStatementId;t.currentStatementId=e;try{let i=n===`value`?Ws(r,t):Us(r,t);return n===`value`&&ds(i)&&(i.statementId=e),i}finally{t.currentStatementId=i,t.visited.delete(e)}}function Is(e,t){return os(t.cat).has(e)||cs(e)}function Ls(e,t){let n={};for(let[r,i]of t.entries()){let t=e[r];if(t===void 0)break;n[i.name]=t}return n}function Rs(e,t,n,r){let{params:i}=n;t.length>i.length&&ws(r,e,``,{code:`excess-args`,declared:i.length,got:t.length});let a=Ls(t,i),o=!1,s=r.errors.length;for(let t of i){let n=a[t.name],s=n?ns(n):{v:void 0};if(!s)continue;if(s.v==null){if(!t.required||t.defaultValue!==void 0)continue;ws(r,e,`/${t.name}`,{code:n?`null-required`:`missing-required`,signature:xs(e,i)}),o=!0;continue}let c=Ns(s.v,t.schema,e,`/${t.name}`,r);c===Ts&&(c=Es(t.required,t.defaultValue)),c===Ts?o=!0:c===void 0?delete a[t.name]:c!==s.v&&(a[t.name]=ts(c))}return n.kind===`action`&&r.errors.length>s&&(o=!0),o?null:a}function zs(e,t,n){let r=e.args.map(n),i=os(t.cat).get(e.name);if(!i||i.lazy)return{...e,args:r};let a=i.builtin?Ls(r,i.params):Rs(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 Bs(e,t,n){let r=t.currentStatementId;t.currentStatementId=n;let i=/* @__PURE__ */ new Set;for(let n of e)es(n,e=>{if(e.k!==`Comp`||i.has(e))return;i.add(e);let n=os(t.cat).get(e.name);n&&!n.lazy&&(e.mappedProps=(n.builtin?null:Rs(e.name,e.args,n,t))??Ls(e.args,n.params))});t.currentStatementId=r}function Vs(e,t,n){let r=os(t.cat).get(e.name);if(r?.kind!==`function`||!r.lazy||e.args.length<3)return null;let i=e.args[1];if(!i)return null;let 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:Hs(e,t,o));return{...e,args:s}}function Hs(e,t,n){switch(e.k){case`Ref`:return n.has(e.n)?e:Fs(e.n,t,`expr`);case`Ph`:return e;case`Comp`:{if(e.fn&&!Is(e.name,t))return ws(t,e.name,``,{code:`unknown-function`}),{k:`Null`};let r=Vs(e,t,n);if(r)return r;if(Is(e.name,t))return zs(e,t,e=>Hs(e,t,n));let i=e.args.map(e=>Hs(e,t,n)),a=t.cat?.get(e.name);if(a){let t={};for(let[e,n]of a.params.entries()){let r=i[e];r&&(t[n.name]=r)}return{...e,args:i,mappedProps:t}}return ws(t,e.name,``,{code:`unknown-component`,available:t.cat&&[...t.cat.keys()]}),{...e,args:i}}case`Arr`:return{...e,els:e.els.map(e=>Hs(e,t,n))};case`Obj`:return{...e,entries:e.entries.map(([e,r])=>[e,Hs(r,t,n)])};case`BinOp`:return{...e,left:Hs(e.left,t,n),right:Hs(e.right,t,n)};case`UnaryOp`:return{...e,operand:Hs(e.operand,t,n)};case`Ternary`:return{...e,cond:Hs(e.cond,t,n),then:Hs(e.then,t,n),else:Hs(e.else,t,n)};case`Member`:return{...e,obj:Hs(e.obj,t,n)};case`Index`:return{...e,obj:Hs(e.obj,t,n),index:Hs(e.index,t,n)};case`Assign`:return{...e,value:Hs(e.value,t,n)};default:return e}}function Us(e,t){return Hs(e,t,/* @__PURE__ */ new Set)}function Ws(e,t){switch(e.k){case`Ref`:return Fs(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=Ws(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]=Ws(i,t);return n}case`Comp`:{let{name:n,args:r}=e;if(e.fn&&!Is(n,t))return ws(t,n,``,{code:`unknown-function`}),null;if(cs(n))return ws(t,n,``,{code:`inline-reserved`}),null;if(Is(n,t))return Vs(e,t,/* @__PURE__ */ new Set)||zs(e,t,e=>Us(e,t));let i=t.cat?.get(n),a={};if(i){let e=!1;for(let[o,s]of i.params.entries()){let i=r[o];if(!i)break;let c=t.prunedValues,l=Ws(i,t);if(t.prunedValues>c&&ws(t,n,`/${s.name}`,{code:`pruned-value`}),a[s.name]=l,s.schema===void 0)continue;if(l==null&&s.defaultValue!==void 0){ws(t,n,`/${s.name}`,{code:`type-mismatch`,expected:bs(s.schema)??`a defined value`,actual:l===null?`null`:`undefined`}),a[s.name]=s.defaultValue,t.prunedValues=c;continue}let u=Ns(l,s.schema,n,`/${s.name}`,t);u===Ts&&(u=Es(s.required,s.defaultValue),s.defaultValue!==void 0&&(t.prunedValues=c),u===Ts?e=!0:u===void 0&&delete a[s.name]),u!==Ts&&u!==void 0&&(a[s.name]=u)}r.length>i.params.length&&ws(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||(ws(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)ws(t,n,`/${r.name}`,{code:r.name in a?`null-required`:`missing-required`,signature:xs(n,i.params)});return null}}if(e)return null}else return ws(t,n,``,{code:`unknown-component`,available:t.cat&&[...t.cat.keys()]}),null;let o=Object.values(a).some(e=>Ps(e));return{type:`element`,typeName:n,props:a,partial:t.partial,hasDynamicProps:o}}default:return Zo(e)?Us(e,t):e}}function Gs(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 Ks(e){let t=[],n=0;for(;n<e.length;){for(;n<e.length&&e[n]?.t===K.Newline;)n++;if(n>=e.length||e[n]?.t===K.EOF)break;let r=e[n];if(!r)break;if(r.t!==K.Ident&&r.t!==K.Type&&r.t!==K.StateVar){for(;n<e.length&&e[n]?.t!==K.Newline&&e[n]?.t!==K.EOF;)n++;continue}let i=r.v,a=r.t;if(n++,n>=e.length||e[n]?.t!==K.Equals){for(;n<e.length&&e[n]?.t!==K.Newline&&e[n]?.t!==K.EOF;)n++;continue}n++;let o=[],s=0,c=0;for(;n<e.length&&e[n]?.t!==K.EOF;){let t=e[n]?.t;if(t===K.Newline&&s<=0&&c<=0){let t=n+1;for(;t<e.length&&e[t]?.t===K.Newline;)t++;let r=t<e.length?e[t]?.t:K.EOF;if(r===K.Question||r===K.Colon&&c>0){n++;continue}break}if(t===K.Newline){n++;continue}t===K.LParen||t===K.LBrack||t===K.LBrace?s++:(t===K.RParen||t===K.RBrack||t===K.RBrace)&&s>0?s--:t===K.Question&&s===0?c++:t===K.Colon&&s===0&&c>0&&c--;let r=e[n++];r&&o.push(r)}o.length&&t.push({id:i,idTokenType:a,tokens:o})}return t}function qs(e=!0){return{root:null,meta:{incomplete:e,unresolved:[],orphaned:[],statementCount:0,errors:[]},stateDeclarations:{},queryStatements:[],mutationStatements:[]}}function Js(e){if(!$o(e))return[];let t=/* @__PURE__ */ new Set;return es(e,e=>{e.k===`StateRef`&&t.add(e.n)}),[...t]}function Ys(e,t){if(t.k===`Comp`&&t.name===as.Query){let n=Js(t.args[1]);return{kind:`query`,id:e.id,call:{callee:as.Query,args:t.args},expr:t,deps:n.length>0?n:void 0}}return t.k===`Comp`&&t.name===as.Mutation?{kind:`mutation`,id:e.id,call:{callee:as.Mutation,args:t.args},expr:t}:e.idTokenType===K.StateVar?{kind:`state`,id:e.id,init:t}:{kind:`value`,id:e.id,expr:t}}function Xs(e,t,n){let r={},i=[],a=[];for(let n of e)switch(n.kind){case`state`:r[n.id]=Ws(n.init,t);break;case`query`:Bs(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`:Bs(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 Js(i))e===n?.name&&n.stmts.has(t)||e in r||(r[e]=null)}return{stateDeclarations:r,queryStatements:i,mutationStatements:a}}const Zs=`root`;function Qs(e){return e?.k===`Comp`&&!e.fn&&!ss(e.name)&&!cs(e.name)}function $s(e,t){if(e.has(Zs))return{id:Zs,fallback:!1};for(let n of e.values())if(n.kind===`value`&&Qs(n.expr)&&n.expr.name===t)return{id:n.id,fallback:!0};return null}function ec(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 Qs(e)}function tc(e){let t=!1;return es(e,e=>{Qs(e)&&(t=!0)}),t}function nc(e,t,n,r,i,a,o){let s=$s(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,h=s&&c.get(s.id);if(s&&h){let e=Ws(h,f);ds(e)?(p=e,p.statementId=s.id):$o(e)&&tc(e)&&(m=e)}let{stateDeclarations:g,queryStatements:_,mutationStatements:v}=Xs(t,f,o);f.currentStatementId=s?.id;let y=a??``;s?!p&&!m&&!ec(c.get(s.id),c)?ws(f,y,``,{code:`no-root`,reason:`not-component`}):s.fallback&&ws(f,y,``,{code:`no-root`,reason:p?`fallback`:`missing`}):ws(f,y,``,{code:`no-root`,reason:`missing`});let b=s?[...d]:[];return{root:p,...m?{rootExpression:m}:{},meta:{incomplete:n,unresolved:l,orphaned:b,statementCount:r,errors:u},stateDeclarations:g,queryStatements:_,mutationStatements:v}}function rc(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 ic(e){let t=[],n=0;for(;n<e.length;){let r=-1;for(;n<e.length;){let t=rc(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]!==`
43
+ `;)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=rc(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(`
44
44
  `);if(e.startsWith("```")){let t=3;for(;t<e.length&&e[t]!==`
45
- `;)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 rc(e){let t=!1;return e.split(`
45
+ `;)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 ac(e){let t=!1;return e.split(`
46
46
  `).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(`
47
- `)}function ic(e){return rc(nc(e.trim())).trim()}function ac(e,t,n){let r=ic(e);if(!r)return Gs();let{text:i,wasIncomplete:a}=Us(r),o=Ws(cs(i));if(!o.length)return Gs(a);let s=/* @__PURE__ */ new Map;for(let e of o){let t=qs(e,ss(e.tokens));s.set(e.id,t)}return ec(s,[...s.values()],a,s.size,t,n)}function oc(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 Ws(cs(t))){let t=qs(e,ss(e.tokens));a.set(e.id,t),o++}}function c(){let e=ic(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
+ `)}function oc(e){return ac(ic(e.trim())).trim()}function sc(e,t,n){let r=oc(e);if(!r)return qs();let{text:i,wasIncomplete:a}=Gs(r),o=Ks(us(i));if(!o.length)return qs(a);let s=/* @__PURE__ */ new Map;for(let e of o){let t=Ys(e,ls(e.tokens));s.set(e.id,t)}return nc(s,[...s.values()],a,s.size,t,n)}function cc(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 Ks(us(t))){let t=Ys(e,ls(e.tokens));a.set(e.id,t),o++}}function c(){let e=oc(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===`
48
48
  `&&e<=0&&t<=0){let e=c+1;for(;e<r.length&&(r[e]===` `||r[e]===` `||r[e]===`\r`||r[e]===`
49
- `);)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(),d=i?u:u.replace(/(\d)\.$/,`$1`);if(!d)return o===0?Gs():ec(a,[...a.values()],!1,o,e,t);let{text:f,wasIncomplete:p}=Us(d),m=Ws(cs(f));if(!m.length)return o===0?Gs(p):ec(a,[...a.values()],p,o,e,t);let h=new Map(a),g=/* @__PURE__ */ new Set;for(let e of m){if(a.has(e.id)&&p)continue;let t=qs(e,ss(e.tokens));h.set(e.id,t),g.add(t)}let _=i?void 0:/\$\w+$/.exec(n)?.[0],v=_&&d.endsWith(_)&&!RegExp(`\\${_}(?!\\w)`).test(d.slice(0,-_.length))?_:void 0;return ec(h,[...h.values()],p,o+m.length,e,t,v?{name:v,stmts:g}: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 sc(e,t){if(!e||typeof e!=`object`)return e;let n=e.$ref;if(typeof n==`string`)return t.has(n)?sc(t.get(n),t):e;let r=Array.isArray(e)?[...e]:{...e},i=!1;for(let[e,n]of Object.entries(r))r[e]=sc(n,t),i||(i=r[e]!==n);return i?r:e}function cc(e,t){let n=e.properties??{},r=e.required??[];return Object.keys(n).map(e=>({name:e,required:r.includes(e),defaultValue:_s(n[e]),schema:t.size?sc(n[e],t):n[e]}))}function lc(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(ns),...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:cc(a,r)});t.callDefs=new Map(ts);for(let[n,i]of Object.entries(e.functions??{}))t.callDefs.set(n,{kind:`function`,params:cc(i.params,r)});for(let[n,i]of Object.entries(e.actions??{}))t.callDefs.set(n,{kind:`action`,params:cc(i.params,r)});return t}const uc=Jo.schema.$defs;function dc(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fc(e,t){if(e.$ref)return pc(t)&&t.typeName===e.$ref.split(`/`).at(-1);if(e.anyOf)return e.anyOf.some(e=>fc(e,t));if(e.enum&&!e.enum.includes(t))return!1;switch(e.type){case`string`:return typeof t==`string`&&(e.pattern===void 0||new RegExp(e.pattern,`u`).test(t));case`integer`:return Number.isInteger(t);case`number`:return typeof t==`number`&&Number.isFinite(t);case`boolean`:return typeof t==`boolean`;case`array`:return Array.isArray(t)&&t.length>=(e.minItems??0)&&t.every(t=>e.items===void 0||fc(e.items,t));case`object`:{if(!dc(t)||!(e.required??[]).every(e=>Object.hasOwn(t,e)))return!1;let{properties:n={},additionalProperties:r}=e;return Object.entries(t).every(([e,t])=>{let i=Object.hasOwn(n,e)?n[e]:void 0;return i?fc(i,t):typeof r==`object`?fc(r,t):r!==!1})}default:return!0}}function pc(e){if(!dc(e)||typeof e.typeName!=`string`||typeof e.statementId!=`string`||e.typeName===Jo.root)return!1;let t=Object.hasOwn(uc,e.typeName)?uc[e.typeName]:void 0;return t!==void 0&&fc(t,e.props)}const mc=lc(Jo.schema),hc={parse(e){return ac(e,mc,Jo.root)}};function gc(){return oc(mc,Jo.root)}const _c=Jo.schema.$defs,vc=new Map(Object.entries(_c).map(([e,t])=>[e,new Set(t.properties?.children?.items?.anyOf?.map(e=>e.$ref?.split(`/`).at(-1)))])),yc=new Set(Object.entries(_c).flatMap(([e,t])=>Object.values(t.properties??{}).some(e=>e.type===`object`||e.items?.type===`object`)?[e]:[]));function bc(){let e=gc(),t=[];return function(n,r){let i=xc(e.set(n,!r),r,n,Sc(t));return r&&t.length>0&&(i.error||i.elements.length===0)?{...i,error:!1,elements:t}:(t=i.elements,i)}}function xc(e,t,n,r){let i=Cc(e,t,n,r);return!t&&(i.error||i.diagnostics.errors.length>0||i.diagnostics.unresolved.length>0||i.diagnostics.incomplete)&&console.warn(`Generative UI diagnostics`,{error:i.error,partial:i.partial,diagnostics:i.diagnostics}),i}function Sc(e,t=/* @__PURE__ */ new Map){for(let n of e)t.set(n.statementId,n),`children`in n.props&&Sc(n.props.children,t);return t}function Cc(e,t,n,r){let i=t&&!/\n\s*$/.test(n??``)?n?.match(/^\w+(?=\s*=)/gm)?.at(-1):void 0,a=e.root?.props.children,o=/* @__PURE__ */ new Set,s=e.meta,c=e.meta.errors.some(e=>e.severity!==`warning`&&!(e.component===`Grid`&&e.path===`/columns`||e.component===`Cell`&&e.path===`/span`));function l(t,n,r){s===e.meta&&(s={...e.meta,errors:[...e.meta.errors]}),s.errors.push({code:`type-mismatch`,component:t.typeName,path:n,message:r,statementId:t.statementId}),c=!0}function u(n,a,s){if(!ls(n)||typeof n.statementId!=`string`||o.has(n.statementId)){l(a,`/children/${s}`,`Child must be a valid, uniquely named component`);return}if(!vc.get(a.typeName)?.has(n.typeName)){l(a,`/children/${s}`,`Component is not allowed at this nesting level`);return}if(o.add(n.statementId),yc.has(n.typeName)&&n.statementId===i)return r?.get(n.statementId);if((n.typeName===`Chart`||n.typeName===`Table`)&&e.meta.errors.some(e=>e.statementId===n.statementId&&e.severity!==`warning`))return;let d=(n.typeName===`Grid`||n.typeName===`Cell`||n.typeName===`Carousel`)&&Array.isArray(n.props.children)?n.props.children.flatMap((e,t)=>{let r=u(e,n,t);return r?[r]:[]}):void 0,f=!1;function p(e){return Object.fromEntries(Object.entries(e).flatMap(([e,t])=>t==null?[]:[[e,m(t)]]))}function m(e){return Array.isArray(e)?(e.some(e=>e==null)&&(f=!0),e.flatMap(e=>e==null?[]:[m(e)])):typeof e==`object`&&e&&!ls(e)?p(e):e}let h=p(n.props);if(f&&(n.typeName===`Chart`||n.typeName===`Table`)){l(n,``,`A list item is missing`);return}f&&(c=!0);let g={...n,props:{...h,...d&&{children:d}}};if(!pc(g))l(n,``,`Component does not match the catalog`);else if(g.typeName===`Table`&&g.props.rows.some(e=>e.length!==g.props.columns.length))l(n,`/rows`,`Every table row must contain one value per column`);else if(g.typeName===`Chart`&&!jo(g.props))l(n,`/data`,`Every chart point must contain one value per series, and a pie one value`);else if(d?.length!==0&&(g.typeName!==`Chart`&&g.typeName!==`Table`||!t&&!e.meta.incomplete))return g}let d=e.root,f=d&&Array.isArray(a)?a.flatMap((e,t)=>{if(ls(e)&&e.typeName===`Cell`)return l(d,`/children/${t}`,`Cell must be inside a Grid`),[];let n=u(e,d,t);return n&&n.typeName!==`Cell`?[n]:[]}):[],p=d?.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`);p&&d&&l(d,``,`Executable content is not supported by the static catalog`),d&&d.typeName!==Jo.root&&l(d,``,`The block must use the catalog root component`);let m=p||d!==null&&d.typeName!==Jo.root||!t&&(!Array.isArray(a)||f.length===0),h=!t&&!m&&(c||e.meta.incomplete);return{elements:m?[]:f,error:m,partial:h,diagnostics:s}}function wc(e,t){return Cc(hc.parse(e),!1).elements.flatMap(e=>Tc(e,t)).join(`
49
+ `);)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(),d=i?u:u.replace(/(\d)\.$/,`$1`);if(!d)return o===0?qs():nc(a,[...a.values()],!1,o,e,t);let{text:f,wasIncomplete:p}=Gs(d),m=Ks(us(f));if(!m.length)return o===0?qs(p):nc(a,[...a.values()],p,o,e,t);let h=new Map(a),g=/* @__PURE__ */ new Set;for(let e of m){if(a.has(e.id)&&p)continue;let t=Ys(e,ls(e.tokens));h.set(e.id,t),g.add(t)}let _=i?void 0:/\$\w+$/.exec(n)?.[0],v=_&&d.endsWith(_)&&!RegExp(`\\${_}(?!\\w)`).test(d.slice(0,-_.length))?_:void 0;return nc(h,[...h.values()],p,o+m.length,e,t,v?{name:v,stmts:g}: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 lc(e,t){if(!e||typeof e!=`object`)return e;let n=e.$ref;if(typeof n==`string`)return t.has(n)?lc(t.get(n),t):e;let r=Array.isArray(e)?[...e]:{...e},i=!1;for(let[e,n]of Object.entries(r))r[e]=lc(n,t),i||(i=r[e]!==n);return i?r:e}function uc(e,t){let n=e.properties??{},r=e.required??[];return Object.keys(n).map(e=>({name:e,required:r.includes(e),defaultValue:ys(n[e]),schema:t.size?lc(n[e],t):n[e]}))}function dc(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(is),...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:uc(a,r)});t.callDefs=new Map(rs);for(let[n,i]of Object.entries(e.functions??{}))t.callDefs.set(n,{kind:`function`,params:uc(i.params,r)});for(let[n,i]of Object.entries(e.actions??{}))t.callDefs.set(n,{kind:`action`,params:uc(i.params,r)});return t}const fc=Xo.schema.$defs;function pc(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function mc(e,t){if(e.$ref)return hc(t)&&t.typeName===e.$ref.split(`/`).at(-1);if(e.anyOf)return e.anyOf.some(e=>mc(e,t));if(e.enum&&!e.enum.includes(t))return!1;switch(e.type){case`string`:return typeof t==`string`&&(e.pattern===void 0||new RegExp(e.pattern,`u`).test(t));case`integer`:return Number.isInteger(t);case`number`:return typeof t==`number`&&Number.isFinite(t);case`boolean`:return typeof t==`boolean`;case`array`:return Array.isArray(t)&&t.length>=(e.minItems??0)&&t.every(t=>e.items===void 0||mc(e.items,t));case`object`:{if(!pc(t)||!(e.required??[]).every(e=>Object.hasOwn(t,e)))return!1;let{properties:n={},additionalProperties:r}=e;return Object.entries(t).every(([e,t])=>{let i=Object.hasOwn(n,e)?n[e]:void 0;return i?mc(i,t):typeof r==`object`?mc(r,t):r!==!1})}default:return!0}}function hc(e){if(!pc(e)||typeof e.typeName!=`string`||typeof e.statementId!=`string`||e.typeName===Xo.root)return!1;let t=Object.hasOwn(fc,e.typeName)?fc[e.typeName]:void 0;return t!==void 0&&mc(t,e.props)}const gc=dc(Xo.schema),_c={parse(e){return sc(e,gc,Xo.root)}};function vc(){return cc(gc,Xo.root)}const yc=Xo.schema.$defs,bc=new Map(Object.entries(yc).map(([e,t])=>[e,new Set(t.properties?.children?.items?.anyOf?.map(e=>e.$ref?.split(`/`).at(-1)))])),xc=new Set(Object.entries(yc).flatMap(([e,t])=>Object.values(t.properties??{}).some(e=>e.type===`object`||e.items?.type===`object`)?[e]:[]));function Sc(){let e=vc(),t=[];return function(n,r){let i=Cc(e.set(n,!r),r,n,wc(t));return r&&t.length>0&&(i.error||i.elements.length===0)?{...i,error:!1,elements:t}:(t=i.elements,i)}}function Cc(e,t,n,r){let i=Tc(e,t,n,r);return!t&&(i.error||i.diagnostics.errors.length>0||i.diagnostics.unresolved.length>0||i.diagnostics.incomplete)&&console.warn(`Generative UI diagnostics`,{error:i.error,partial:i.partial,diagnostics:i.diagnostics}),i}function wc(e,t=/* @__PURE__ */ new Map){for(let n of e)t.set(n.statementId,n),`children`in n.props&&wc(n.props.children,t);return t}function Tc(e,t,n,r){let i=t&&!/\n\s*$/.test(n??``)?n?.match(/^\w+(?=\s*=)/gm)?.at(-1):void 0,a=e.root?.props.children,o=/* @__PURE__ */ new Set,s=e.meta,c=e.meta.errors.some(e=>e.severity!==`warning`&&!(e.component===`Grid`&&e.path===`/columns`||e.component===`Cell`&&e.path===`/span`));function l(t,n,r){s===e.meta&&(s={...e.meta,errors:[...e.meta.errors]}),s.errors.push({code:`type-mismatch`,component:t.typeName,path:n,message:r,statementId:t.statementId}),c=!0}function u(n,a,s){if(!ds(n)||typeof n.statementId!=`string`||o.has(n.statementId)){l(a,`/children/${s}`,`Child must be a valid, uniquely named component`);return}if(!bc.get(a.typeName)?.has(n.typeName)){l(a,`/children/${s}`,`Component is not allowed at this nesting level`);return}if(o.add(n.statementId),xc.has(n.typeName)&&n.statementId===i)return r?.get(n.statementId);if((n.typeName===`Chart`||n.typeName===`Table`)&&e.meta.errors.some(e=>e.statementId===n.statementId&&e.severity!==`warning`))return;let d=(n.typeName===`Grid`||n.typeName===`Cell`||n.typeName===`Carousel`)&&Array.isArray(n.props.children)?n.props.children.flatMap((e,t)=>{let r=u(e,n,t);return r?[r]:[]}):void 0,f=!1;function p(e){return Object.fromEntries(Object.entries(e).flatMap(([e,t])=>t==null?[]:[[e,m(t)]]))}function m(e){return Array.isArray(e)?(e.some(e=>e==null)&&(f=!0),e.flatMap(e=>e==null?[]:[m(e)])):typeof e==`object`&&e&&!ds(e)?p(e):e}let h=p(n.props);if(f&&(n.typeName===`Chart`||n.typeName===`Table`)){l(n,``,`A list item is missing`);return}f&&(c=!0);let g={...n,props:{...h,...d&&{children:d}}};if(!hc(g))l(n,``,`Component does not match the catalog`);else if(g.typeName===`Table`&&g.props.rows.some(e=>e.length!==g.props.columns.length))l(n,`/rows`,`Every table row must contain one value per column`);else if(g.typeName===`Chart`&&!jo(g.props))l(n,`/data`,`Every chart point must contain one value per series, and a pie one value`);else if(d?.length!==0&&(g.typeName!==`Chart`&&g.typeName!==`Table`||!t&&!e.meta.incomplete))return g}let d=e.root,f=d&&Array.isArray(a)?a.flatMap((e,t)=>{if(ds(e)&&e.typeName===`Cell`)return l(d,`/children/${t}`,`Cell must be inside a Grid`),[];let n=u(e,d,t);return n&&n.typeName!==`Cell`?[n]:[]}):[],p=d?.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`);p&&d&&l(d,``,`Executable content is not supported by the static catalog`),d&&d.typeName!==Xo.root&&l(d,``,`The block must use the catalog root component`);let m=p||d!==null&&d.typeName!==Xo.root||!t&&(!Array.isArray(a)||f.length===0),h=!t&&!m&&(c||e.meta.incomplete);return{elements:m?[]:f,error:m,partial:h,diagnostics:s}}function Ec(e,t){return Tc(_c.parse(e),!1).elements.flatMap(e=>Dc(e,t)).join(`
50
50
 
51
- `)}function Tc(e,t){switch(e.typeName){case`Grid`:case`Cell`:case`Carousel`:return e.props.children.flatMap(e=>Tc(e,t));case`Text`:return[e.props.text];case`Card`:return[`${e.props.title}\n${e.props.body}`];case`Metric`:return[[e.props.label,e.props.value,e.props.change?.text,e.props.detail].filter(Boolean).join(`
51
+ `)}function Dc(e,t){switch(e.typeName){case`Grid`:case`Cell`:case`Carousel`:return e.props.children.flatMap(e=>Dc(e,t));case`Text`:return[e.props.text];case`Card`:return[`${e.props.title}\n${e.props.body}`];case`Metric`:return[[e.props.label,e.props.value,e.props.change?.text,e.props.detail].filter(Boolean).join(`
52
52
  `)];case`Table`:return[[e.props.title,e.props.columns.join(` `),...e.props.rows.map(e=>e.join(` `))].join(`
53
53
  `)];case`Chart`:return[[e.props.title,...e.props.series?.length?[e.props.series.join(`, `)]:[],...e.props.data.map(e=>`${e.label}: ${Ao(e.value).join(`, `)}`)].join(`
54
54
  `)];case`Product`:return[[e.props.product.title,vo(e.props.product.price,t),e.props.product.description,...e.props.product.details??[]].filter(Boolean).join(`
55
- `)];case`Cart`:return[[...e.props.cart.lines.map(e=>Dc(e,t)),...e.props.cart.totals.map(e=>Oc(e,t))].join(`
56
- `)];case`Order`:return[[`${e.props.order.number} · ${e.props.order.status}`,...e.props.order.details??[],...e.props.order.items.map(e=>Dc(e,t)),...e.props.order.totals.map(e=>Oc(e,t))].join(`
57
- `)];case`Flight`:return[[...e.props.flight.legs.map(e=>Ec(e,t)),[e.props.flight.fare,vo(e.props.flight.price,t),e.props.flight.priceNote].filter(Boolean).join(` · `),...e.props.flight.details??[]].join(`
55
+ `)];case`Cart`:return[[...e.props.cart.lines.map(e=>kc(e,t)),...e.props.cart.totals.map(e=>Ac(e,t))].join(`
56
+ `)];case`Order`:return[[`${e.props.order.number} · ${e.props.order.status}`,...e.props.order.details??[],...e.props.order.items.map(e=>kc(e,t)),...e.props.order.totals.map(e=>Ac(e,t))].join(`
57
+ `)];case`Flight`:return[[...e.props.flight.legs.map(e=>Oc(e,t)),[e.props.flight.fare,vo(e.props.flight.price,t),e.props.flight.priceNote].filter(Boolean).join(` · `),...e.props.flight.details??[]].join(`
58
58
  `)];case`Stay`:return[[e.props.stay.name,e.props.stay.location,wo(e.props.stay.checkIn,e.props.stay.checkOut,t),e.props.stay.room,vo(e.props.stay.price,t),...e.props.stay.details??[]].filter(Boolean).join(`
59
59
  `)];case`Package`:return[[e.props.package.title,e.props.package.location,wo(e.props.package.start,e.props.package.end,t),[vo(e.props.package.price,t),e.props.package.priceNote].filter(Boolean).join(` `),...e.props.package.details??[]].filter(Boolean).join(`
60
- `)];case`Booking`:return[[`${e.props.booking.reference} · ${e.props.booking.status}`,e.props.booking.title,wo(e.props.booking.start,e.props.booking.end,t),e.props.booking.travellers?.join(`, `),...(e.props.booking.itinerary??[]).map(e=>[e.date&&Co(e.date,t),e.time,e.title,e.detail].filter(Boolean).join(` · `)),...(e.props.booking.totals??[]).map(e=>Oc(e,t)),...e.props.booking.details??[]].filter(Boolean).join(`
61
- `)]}}function Ec(e,t){let n=So(e.departs,e.arrives);return`${[e.carrier,e.number].filter(Boolean).join(` `)}: ${e.from} ${Co(e.departs,t)} ${bo(e.departs,t)} → ${e.to} ${bo(e.arrives,t)}${n?` +${n}`:``}`}function Dc(e,t){return`${[e.title,...Object.values(e.options??{})].join(`, `)} × ${e.quantity}: ${vo(e.price,t)}`}function Oc(e,t){return`${e.label}: ${vo(e.amount,t)}`}function kc(e,{cssPrefix:t,strings:n,locale:r,onAction:i}){let a=[],o=H(!1),s;return{...po(e),set_attr(e,c,l){if(c!==4||l!==`openui`||e.index!==1)return _o(e,c,l);let u=document.createElement(`div`);e.nodes[e.index]?.parentElement?.replaceWith(u),s={textSig:H(``),doneSig:H(!1)},a.push(u),xt(U(Ac,{cssPrefix:t,textSig:s.textSig,doneSig:s.doneSig,replyDoneSig:o,strings:n,locale:r,onAction:i}),u)},add_text(e,t){s?s.textSig.value=s.textSig.peek()+t:go(e,t)},end_token(e){s&&(s.doneSig.value=!0,s=void 0),ho(e)},finish(){s&&(s.doneSig.value=!0),o.value=!0},dispose(){for(let e of a)xt(null,e);a.length=0,s=void 0}}}function Ac({textSig:e,doneSig:t,replyDoneSig:n,cssPrefix:r,strings:i,locale:a,onAction:o}){let s=bi(()=>{let n=bc();return Yi(()=>n(e.value,!t.value))},[e,t]),c={cssPrefix:r,strings:i,locale:a,onAction:o,busy:!n.value};return s.value.error?U(`div`,{role:`alert`,children:i.visualError}):U(`div`,{class:`${r}-generative-ui`,"aria-busy":!t.value,children:[s.value.elements.map(e=>U(jc,{element:e,context:c},e.statementId)),s.value.partial&&U(`p`,{role:`status`,children:i.visualPartial}),s.value.elements.length===0&&!t.value?U(`span`,{role:`status`,children:i.visualPreparing}):null]})}function jc({element:e,context:t}){let{cssPrefix:n}=t;if(e.typeName===`Grid`)return U(`div`,{class:`${n}-generative-ui-grid-container`,children:U(`div`,{class:`${n}-generative-ui-grid`,"data-columns":e.props.columns,"data-equal-heights":Bo(e.props.children)||void 0,children:e.props.children.map(e=>U(`div`,{class:`${n}-generative-ui-cell`,"data-span":e.typeName===`Cell`?e.props.span??1:1,children:e.typeName===`Cell`?e.props.children.map(e=>U(jc,{element:e,context:t},e.statementId)):U(jc,{element:e,context:t})},e.statementId))})});switch(e.typeName){case`Carousel`:return U(`div`,{role:`list`,class:`${n}-generative-ui-carousel`,children:e.props.children.map(e=>U(`div`,{role:`listitem`,children:U(jc,{element:e,context:t})},e.statementId))});case`Text`:return U(`p`,{children:e.props.text});case`Card`:return U(`section`,{class:`${n}-generative-ui-card`,children:[Ho(e.props.image)&&U(Fc,{src:e.props.image,class:`${n}-generative-ui-photo`,wide:!0}),U(`strong`,{class:`${n}-generative-ui-title`,title:e.props.title,children:e.props.title}),U(`p`,{children:e.props.body}),U(Pc,{actions:e.props.actions,context:t,disabled:t.busy})]});case`Product`:return U(Mc,{...e.props,context:t});case`Flight`:return U(Bc,{...e.props,context:t});case`Stay`:case`Package`:return U(zc,{element:e,context:t});case`Booking`:{let{booking:r}=e.props;return U(`section`,{class:`${n}-generative-ui-sheet`,children:[U(`div`,{class:`${n}-generative-ui-heading`,children:[U(`strong`,{dir:`ltr`,children:r.reference}),U(`span`,{class:`${n}-generative-ui-pill`,children:r.status})]}),r.title&&U(`strong`,{children:r.title}),U(Lc,{parts:[wo(r.start,r.end,t.locale),r.travellers?.length&&`${t.strings.visualTravellers}: ${r.travellers.join(`, `)}`],context:t}),r.itinerary?.length?U(`ol`,{class:`${n}-generative-ui-itinerary`,children:r.itinerary.map((e,r)=>U(`li`,{children:[U(`span`,{class:`${n}-generative-ui-muted`,children:[e.date&&Co(e.date,t.locale),e.time].filter(Boolean).join(` · `)}),U(`strong`,{children:e.title}),e.detail&&U(`span`,{class:`${n}-generative-ui-muted`,children:e.detail})]},r))}):null,U(Gc,{totals:r.totals??[],context:t}),U(Rc,{details:r.details,context:t}),U(Pc,{actions:e.props.actions,context:t,disabled:t.busy})]})}case`Cart`:return U(`section`,{class:`${n}-generative-ui-sheet`,children:[e.props.cart.messages?.map(e=>U(`p`,{role:e.severity===`info`?`status`:`alert`,class:`${n}-generative-ui-notice`,"data-severity":e.severity,children:e.text},e.text)),e.props.cart.lines.length?U(Nc,{lines:e.props.cart.lines,context:t}):U(`p`,{class:`${n}-generative-ui-muted`,children:t.strings.visualCartEmpty}),e.props.cart.lines.length>0&&U(Gc,{totals:e.props.cart.totals,context:t}),U(Pc,{actions:e.props.actions,context:t,disabled:t.busy})]});case`Order`:return U(`section`,{class:`${n}-generative-ui-sheet`,children:[U(`div`,{class:`${n}-generative-ui-heading`,children:[U(`strong`,{dir:`ltr`,children:e.props.order.number}),U(`span`,{class:`${n}-generative-ui-pill`,children:e.props.order.status})]}),e.props.order.date&&U(`p`,{class:`${n}-generative-ui-muted`,children:yo(e.props.order.date,t.locale)}),U(Rc,{details:e.props.order.details,context:t}),e.props.order.timeline?.length?U(`ol`,{class:`${n}-generative-ui-timeline`,children:e.props.order.timeline.map(e=>U(`li`,{"data-done":e.done,children:[U(`span`,{children:e.label}),e.date&&U(`span`,{class:`${n}-generative-ui-muted`,children:yo(e.date,t.locale)})]},e.label))}):null,U(Nc,{lines:e.props.order.items,context:t}),U(Gc,{totals:e.props.order.totals,context:t}),U(Pc,{actions:e.props.actions,context:t,disabled:t.busy})]});case`Metric`:{let t=Io(e.props.trend);return U(`section`,{children:[U(`strong`,{children:e.props.label}),U(`div`,{class:`${n}-generative-ui-metric`,children:[U(`span`,{children:e.props.value}),t&&U(`svg`,{viewBox:`0 0 80 24`,"aria-hidden":`true`,children:U(`polyline`,{points:t,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linejoin":`round`,"stroke-linecap":`round`})})]}),e.props.change&&U(`span`,{class:`${n}-generative-ui-change`,"data-tone":e.props.change.tone,children:e.props.change.text}),e.props.detail&&U(`p`,{children:e.props.detail})]})}case`Table`:return U(Hc,{...e.props,context:t});case`Chart`:return U(Kc,{element:e,context:t})}}function Mc({product:e,actions:t,context:n}){let{cssPrefix:r,strings:i}=n,[a,o]=R({}),s=qo(e,a),c=Uo(t,n.onAction!==void 0).some(e=>e.message!==void 0);return U(`section`,{class:`${r}-generative-ui-offer`,children:[U(Ic,{image:s.image,url:e.url,badge:e.badge,available:s.available,context:n}),U(`strong`,{class:`${r}-generative-ui-title`,title:e.title,children:U(Uc,{title:e.title,url:e.url})}),U(Wc,{price:s.price,compareAtPrice:s.compareAtPrice,context:n}),U(Lc,{parts:[],rating:e.rating,context:n}),e.description&&U(`p`,{class:`${r}-generative-ui-description`,title:e.description,children:e.description}),U(Rc,{details:e.details,context:n}),U(`div`,{class:`${r}-generative-ui-footer`,children:[s.options.map(e=>U(`fieldset`,{class:`${r}-generative-ui-option`,children:[U(`legend`,{children:e.name}),U(Jc,{children:e.values.map(t=>U(`button`,{type:`button`,"aria-pressed":e.value===t,disabled:e.unavailable.includes(t),onClick:()=>o({...a,[e.name]:t}),children:t},t))})]},e.name)),c&&U(`p`,{class:`${r}-generative-ui-hint`,children:s.missing.length>0&&`${i.visualChoose} ${s.missing.join(`, `)}`}),U(Pc,{actions:t,context:n,disabled:n.busy||!s.canBuy,getMessage:t=>Wo(t,e.title,s.chosen)})]})]})}function Nc({lines:e,context:t}){let{cssPrefix:n,strings:r}=t;if(!e.length)return null;let i=e.some(e=>e.image);return U(`ul`,{class:`${n}-generative-ui-lines`,children:e.map((e,a)=>U(`li`,{children:[i&&U(Fc,{src:e.image??``,class:`${n}-generative-ui-thumb`},e.image),U(`div`,{children:[U(`div`,{class:`${n}-generative-ui-line-head`,children:[U(`span`,{children:U(Uc,{title:e.title,url:e.url})}),U(`strong`,{children:vo(e.price,t.locale)})]}),U(`span`,{class:`${n}-generative-ui-muted`,children:[...Object.entries(e.options??{}).map(([e,t])=>`${e}: ${t}`),`${r.visualQuantity} ${e.quantity}`].join(` · `)}),U(Pc,{actions:e.actions,context:t,disabled:t.busy,small:!0,getMessage:t=>Wo(t,e.title,e.options)})]})]},a))})}function Pc({actions:e,context:t,disabled:n,small:r,getMessage:i}){let a=Uo(e,t.onAction!==void 0);return a.length?U(`div`,{class:`${t.cssPrefix}-generative-ui-actions`,"data-small":r,children:a.map(e=>{if(e.message===void 0)return U(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-primary":e.primary,title:e.label,children:U(`span`,{children:e.label})},e.label);let r=e.message;return U(`button`,{type:`button`,disabled:n,"data-primary":e.primary,title:e.label,onClick:()=>t.onAction?.(i?.(r)??r),children:U(`span`,{children:e.label})},e.label)})}):null}function Fc({src:e,href:t,class:n,wide:r,children:i}){let[a,o]=R(!1),s=!a&&Ho(e)&&U(`img`,{src:e,alt:``,loading:`lazy`,referrerpolicy:`no-referrer`,onError:()=>o(!0)});return Ho(t)?U(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,tabIndex:-1,"aria-hidden":`true`,class:n,"data-wide":r,children:[s,i]}):U(`span`,{class:n,"data-wide":r,children:[s,i]})}function Ic({image:e,url:t,badge:n,available:r,context:{cssPrefix:i,strings:a}}){let o=(n||!r)&&U(`span`,{class:`${i}-generative-ui-badges`,children:[n&&U(`span`,{class:`${i}-generative-ui-pill`,children:n}),!r&&U(`span`,{class:`${i}-generative-ui-pill`,children:a.visualSoldOut})]});return Ho(e)?U(Fc,{src:e,href:t,class:`${i}-generative-ui-photo`,children:o},e):o||null}function Lc({parts:e,rating:t,context:{cssPrefix:n}}){let r=e.filter(e=>typeof e==`string`&&e).join(` · `);return!r&&!t?null:U(`span`,{class:`${n}-generative-ui-muted`,children:[t&&U(L,{children:[U(`span`,{"aria-hidden":`true`,class:`${n}-generative-ui-star`,children:[`★`,` `]}),ko(t),t.count!==void 0&&` (${t.count})`,r&&` · `]}),r]})}function Rc({details:e,context:{cssPrefix:t}}){return e?.length?U(`ul`,{class:`${t}-generative-ui-details`,children:e.map(e=>U(`li`,{children:e},e))}):null}function zc({element:e,context:t}){let{cssPrefix:n,locale:r}=t,i=Oo(e,t.strings,r);return U(`section`,{class:`${n}-generative-ui-offer`,children:[U(Ic,{image:i.image,url:i.url,badge:i.badge,available:i.available,context:t}),U(`strong`,{class:`${n}-generative-ui-title`,title:i.title,children:[U(Uc,{title:i.title,url:i.url}),i.stars!==void 0&&i.stars>0&&U(`span`,{class:`${n}-generative-ui-stars`,role:`img`,"aria-label":`${i.stars} ★`,children:[` `,`★`.repeat(Math.min(i.stars,5))]})]}),U(Lc,{parts:[i.location],rating:i.rating,context:t}),U(Lc,{parts:[i.when],context:t}),i.room&&U(`p`,{children:i.room}),U(Rc,{details:i.details,context:t}),U(`div`,{class:`${n}-generative-ui-footer`,children:[U(Wc,{price:i.price,compareAtPrice:i.compareAtPrice,note:i.note,context:t}),U(Pc,{actions:e.props.actions,context:t,disabled:t.busy||!i.available,getMessage:e=>Wo(e,i.title,void 0)})]})]})}function Bc({flight:e,actions:t,context:n}){let{cssPrefix:r,strings:i,locale:a}=n;return U(`section`,{class:`${r}-generative-ui-flight`,children:[e.legs.map((e,t)=>U(Vc,{leg:e,strings:i,locale:a,cssPrefix:r},t)),U(Rc,{details:e.details,context:n}),U(`div`,{class:`${r}-generative-ui-footer`,children:[U(Ic,{image:void 0,url:void 0,badge:e.badge,available:e.available!==!1,context:n}),U(Wc,{price:e.price,compareAtPrice:void 0,note:[e.fare,e.priceNote].filter(Boolean).join(` · `),context:n}),U(Pc,{actions:t,context:n,disabled:n.busy||e.available===!1,getMessage:t=>Wo(t,Go(e),void 0)})]})]})}function Vc({leg:e,strings:t,locale:n,cssPrefix:r}){let i=So(e.departs,e.arrives),a=Eo(e,t,n);return U(`div`,{class:`${r}-generative-ui-leg`,children:[U(`span`,{class:`${r}-generative-ui-muted`,children:[e.carrier,e.number,Co(e.departs,n)].filter(Boolean).join(` · `)}),U(`div`,{class:`${r}-generative-ui-leg-times`,children:[U(`span`,{children:[U(`strong`,{children:bo(e.departs,n)}),U(`span`,{children:e.from})]}),U(`span`,{class:`${r}-generative-ui-leg-path`,children:a}),U(`span`,{children:[U(`strong`,{children:[bo(e.arrives,n),i!==void 0&&U(`sup`,{children:[`+`,i]})]}),U(`span`,{children:e.to})]})]})]})}function Hc({title:e,columns:t,rows:n,context:{cssPrefix:r,locale:i}}){let[a,o]=R(void 0),s=Ro(t,n),c=zo(n,a&&{...a,numeric:s[a.column]??!1},i);return U(`section`,{class:`${r}-generative-ui-table-card`,children:U(`div`,{class:`${r}-generative-ui-table`,children:U(`table`,{children:[U(`caption`,{children:e}),U(`thead`,{children:U(`tr`,{children:t.map((e,t)=>U(`th`,{scope:`col`,"data-numeric":s[t],"aria-sort":a?.column===t?a.descending?`descending`:`ascending`:void 0,children:U(`button`,{type:`button`,onClick:()=>o({column:t,descending:a?.column===t&&!a.descending}),children:e})},t))})}),U(`tbody`,{children:c.map((e,n)=>U(`tr`,{children:e.map((e,n)=>U(`td`,{"data-numeric":s[n],"data-label":t[n],children:e},n))},n))})]})})})}function Uc({title:e,url:t}){return Ho(t)?U(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:e}):U(L,{children:e})}function Wc({price:e,compareAtPrice:t,note:n,context:{cssPrefix:r,locale:i}}){return U(`span`,{class:`${r}-generative-ui-price`,children:[U(`strong`,{children:vo(e,i)}),t&&Ko(e,t)&&U(`s`,{children:vo(t,i)}),n&&U(`span`,{class:`${r}-generative-ui-muted`,children:n})]})}function Gc({totals:e,context:{cssPrefix:t,locale:n}}){return e.length?U(`dl`,{class:`${t}-generative-ui-totals`,children:e.map(e=>U(`div`,{children:[U(`dt`,{children:e.label}),U(`dd`,{children:vo(e.amount,n)})]},e.label))}):null}function Kc({element:e,context:{cssPrefix:t,locale:n}}){let{type:r,data:i,series:a=[],title:o}=e.props,{baseline:s,barWidth:c,series:l,labels:u,ticks:d,slices:f}=No(e.props,n),p=[`currentColor`,...Mo],m=r===`pie`?i.map((e,t)=>`${e.label} ${Math.round((f[t]?.share??0)*100)}%`):l.length>1?a:[];return U(`section`,{children:[U(`strong`,{children:o}),U(`svg`,{class:`${t}-generative-ui-chart`,viewBox:`0 0 320 168`,role:`img`,"aria-label":`${o}. ${a.length>1?`${a.join(` / `)}. `:``}${i.map(e=>`${e.label}: ${Ao(e.value).join(` / `)}`).join(`, `)}`,children:[r===`pie`?f.map((e,t)=>U(`path`,{d:e.path,fill:p[t%p.length]},t)):l.map((e,t)=>r===`line`?U(`g`,{fill:p[t%p.length],children:[U(`polyline`,{points:e.map(e=>`${e.x},${e.y}`).join(` `),fill:`none`,stroke:p[t%p.length],"stroke-width":2.5,"stroke-linejoin":`round`}),e.map((e,t)=>U(`circle`,{cx:e.x,cy:e.y,r:3},t))]},t):U(`g`,{fill:p[t%p.length],children:e.map((e,t)=>U(`rect`,{x:e.x-c/2,y:Math.min(e.y,s),width:c,height:Math.abs(e.y-s),rx:2},t))},t)),r!==`pie`&&U(`g`,{class:`${t}-generative-ui-axis`,children:[U(`line`,{x1:24,x2:296,y1:s,y2:s}),u.map((e,t)=>U(`text`,{x:e.x,y:164,"text-anchor":`middle`,children:e.text},t)),d.map(e=>U(`text`,{x:20,y:e.y+3,"text-anchor":`end`,children:e.text},e.text))]})]}),m.length>0&&U(`ul`,{class:`${t}-generative-ui-legend`,children:m.map((e,t)=>U(`li`,{style:{color:t?p[t%p.length]:void 0},children:U(`span`,{children:e})},t))})]})}function qc(e,t){if(!e.includes("```openui"))return e;let n=``,r=0,i=0,a=0,o=0,s;function c(i){s?.language===`openui`&&(n+=e.slice(r,s.start)+wc(s.source,t)+(e[i-1]===`
60
+ `)];case`Booking`:return[[`${e.props.booking.reference} · ${e.props.booking.status}`,e.props.booking.title,wo(e.props.booking.start,e.props.booking.end,t),e.props.booking.travellers?.join(`, `),...(e.props.booking.itinerary??[]).map(e=>[e.date&&Co(e.date,t),e.time,e.title,e.detail].filter(Boolean).join(` · `)),...(e.props.booking.totals??[]).map(e=>Ac(e,t)),...e.props.booking.details??[]].filter(Boolean).join(`
61
+ `)]}}function Oc(e,t){let n=So(e.departs,e.arrives);return`${[e.carrier,e.number].filter(Boolean).join(` `)}: ${e.from} ${Co(e.departs,t)} ${bo(e.departs,t)} → ${e.to} ${bo(e.arrives,t)}${n?` +${n}`:``}`}function kc(e,t){return`${[e.title,...Object.values(e.options??{})].join(`, `)} × ${e.quantity}: ${vo(e.price,t)}`}function Ac(e,t){return`${e.label}: ${vo(e.amount,t)}`}function jc(e,{cssPrefix:t,strings:n,locale:r,onAction:i}){let a=[],o=H(!1),s;return{...po(e),set_attr(e,c,l){if(c!==4||l!==`openui`||e.index!==1)return _o(e,c,l);let u=document.createElement(`div`);e.nodes[e.index]?.parentElement?.replaceWith(u),s={textSig:H(``),doneSig:H(!1)},a.push(u),xt(U(Mc,{cssPrefix:t,textSig:s.textSig,doneSig:s.doneSig,replyDoneSig:o,strings:n,locale:r,onAction:i}),u)},add_text(e,t){s?s.textSig.value=s.textSig.peek()+t:go(e,t)},end_token(e){s&&(s.doneSig.value=!0,s=void 0),ho(e)},finish(){s&&(s.doneSig.value=!0),o.value=!0},dispose(){for(let e of a)xt(null,e);a.length=0,s=void 0}}}function Mc({textSig:e,doneSig:t,replyDoneSig:n,cssPrefix:r,strings:i,locale:a,onAction:o}){let s=bi(()=>{let n=Sc();return Yi(()=>n(e.value,!t.value))},[e,t]),c={cssPrefix:r,strings:i,locale:a,onAction:o,busy:!n.value};return s.value.error?U(`div`,{role:`alert`,children:i.visualError}):U(`div`,{class:`${r}-generative-ui`,"aria-busy":!t.value,children:[s.value.elements.map(e=>U(Nc,{element:e,context:c},e.statementId)),s.value.partial&&U(`p`,{role:`status`,children:i.visualPartial}),s.value.elements.length===0&&!t.value?U(`span`,{role:`status`,children:i.visualPreparing}):null]})}function Nc({element:e,context:t}){let{cssPrefix:n}=t;if(e.typeName===`Grid`)return U(`div`,{class:`${n}-generative-ui-grid-container`,children:U(`div`,{class:`${n}-generative-ui-grid`,"data-equal-heights":Ho(e.props.children)||void 0,style:Object.fromEntries([2,3,4].map(t=>[`--${n}-cols-${t}`,Vo(e.props.children.map(Bo),Math.min(t,e.props.columns))])),children:e.props.children.map(e=>U(`div`,{class:`${n}-generative-ui-cell`,style:{[`--${n}-span`]:Bo(e)},children:e.typeName===`Cell`?e.props.children.map(e=>U(Nc,{element:e,context:t},e.statementId)):U(Nc,{element:e,context:t})},e.statementId))})});switch(e.typeName){case`Carousel`:return U(`div`,{role:`list`,class:`${n}-generative-ui-carousel`,children:e.props.children.map(e=>U(`div`,{role:`listitem`,children:U(Nc,{element:e,context:t})},e.statementId))});case`Text`:return U(`p`,{children:e.props.text});case`Card`:return U(`section`,{class:`${n}-generative-ui-card`,children:[Wo(e.props.image)&&U(Lc,{src:e.props.image,class:`${n}-generative-ui-photo`,wide:!0}),U(`strong`,{class:`${n}-generative-ui-title`,title:e.props.title,children:e.props.title}),U(`p`,{children:e.props.body}),U(Ic,{actions:e.props.actions,context:t,disabled:t.busy})]});case`Product`:return U(Pc,{...e.props,context:t});case`Flight`:return U(Hc,{...e.props,context:t});case`Stay`:case`Package`:return U(Vc,{element:e,context:t});case`Booking`:{let{booking:r}=e.props;return U(`section`,{class:`${n}-generative-ui-sheet`,children:[U(`div`,{class:`${n}-generative-ui-heading`,children:[U(`strong`,{dir:`ltr`,children:r.reference}),U(`span`,{class:`${n}-generative-ui-pill`,children:r.status})]}),r.title&&U(`strong`,{children:r.title}),U(zc,{parts:[wo(r.start,r.end,t.locale),r.travellers?.length&&`${t.strings.visualTravellers}: ${r.travellers.join(`, `)}`],context:t}),r.itinerary?.length?U(`ol`,{class:`${n}-generative-ui-itinerary`,children:r.itinerary.map((e,r)=>U(`li`,{children:[U(`span`,{class:`${n}-generative-ui-muted`,children:[e.date&&Co(e.date,t.locale),e.time].filter(Boolean).join(` · `)}),U(`strong`,{children:e.title}),e.detail&&U(`span`,{class:`${n}-generative-ui-muted`,children:e.detail})]},r))}):null,U(qc,{totals:r.totals??[],context:t}),U(Bc,{details:r.details,context:t}),U(Ic,{actions:e.props.actions,context:t,disabled:t.busy})]})}case`Cart`:return U(`section`,{class:`${n}-generative-ui-sheet`,children:[e.props.cart.messages?.map(e=>U(`p`,{role:e.severity===`info`?`status`:`alert`,class:`${n}-generative-ui-notice`,"data-severity":e.severity,children:e.text},e.text)),e.props.cart.lines.length?U(Fc,{lines:e.props.cart.lines,context:t}):U(`p`,{class:`${n}-generative-ui-muted`,children:t.strings.visualCartEmpty}),e.props.cart.lines.length>0&&U(qc,{totals:e.props.cart.totals,context:t}),U(Ic,{actions:e.props.actions,context:t,disabled:t.busy})]});case`Order`:return U(`section`,{class:`${n}-generative-ui-sheet`,children:[U(`div`,{class:`${n}-generative-ui-heading`,children:[U(`strong`,{dir:`ltr`,children:e.props.order.number}),U(`span`,{class:`${n}-generative-ui-pill`,children:e.props.order.status})]}),e.props.order.date&&U(`p`,{class:`${n}-generative-ui-muted`,children:yo(e.props.order.date,t.locale)}),U(Bc,{details:e.props.order.details,context:t}),e.props.order.timeline?.length?U(`ol`,{class:`${n}-generative-ui-timeline`,children:e.props.order.timeline.map(e=>U(`li`,{"data-done":e.done,children:[U(`span`,{children:e.label}),e.date&&U(`span`,{class:`${n}-generative-ui-muted`,children:yo(e.date,t.locale)})]},e.label))}):null,U(Fc,{lines:e.props.order.items,context:t}),U(qc,{totals:e.props.order.totals,context:t}),U(Ic,{actions:e.props.actions,context:t,disabled:t.busy})]});case`Metric`:{let t=Io(e.props.trend);return U(`section`,{children:[U(`strong`,{children:e.props.label}),U(`div`,{class:`${n}-generative-ui-metric`,children:[U(`span`,{children:e.props.value}),t&&U(`svg`,{viewBox:`0 0 80 24`,"aria-hidden":`true`,children:U(`polyline`,{points:t,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linejoin":`round`,"stroke-linecap":`round`})})]}),e.props.change&&U(`span`,{class:`${n}-generative-ui-change`,"data-tone":e.props.change.tone,children:e.props.change.text}),e.props.detail&&U(`p`,{children:e.props.detail})]})}case`Table`:return U(Wc,{...e.props,context:t});case`Chart`:return U(Jc,{element:e,context:t})}}function Pc({product:e,actions:t,context:n}){let{cssPrefix:r,strings:i}=n,[a,o]=R({}),s=Yo(e,a),c=Go(t,n.onAction!==void 0).some(e=>e.message!==void 0);return U(`section`,{class:`${r}-generative-ui-offer`,children:[U(Rc,{image:s.image,url:e.url,badge:e.badge,available:s.available,context:n}),U(`strong`,{class:`${r}-generative-ui-title`,title:e.title,children:U(Gc,{title:e.title,url:e.url})}),U(Kc,{price:s.price,compareAtPrice:s.compareAtPrice,context:n}),U(zc,{parts:[],rating:e.rating,context:n}),e.description&&U(`p`,{class:`${r}-generative-ui-description`,title:e.description,children:e.description}),U(Bc,{details:e.details,context:n}),U(`div`,{class:`${r}-generative-ui-footer`,children:[s.options.map(e=>U(`fieldset`,{class:`${r}-generative-ui-option`,children:[U(`legend`,{children:e.name}),U(Xc,{children:e.values.map(t=>U(`button`,{type:`button`,"aria-pressed":e.value===t,disabled:e.unavailable.includes(t),onClick:()=>o({...a,[e.name]:t}),children:t},t))})]},e.name)),c&&U(`p`,{class:`${r}-generative-ui-hint`,children:s.missing.length>0&&`${i.visualChoose} ${s.missing.join(`, `)}`}),U(Ic,{actions:t,context:n,disabled:n.busy||!s.canBuy,getMessage:t=>Ko(t,e.title,s.chosen)})]})]})}function Fc({lines:e,context:t}){let{cssPrefix:n,strings:r}=t;if(!e.length)return null;let i=e.some(e=>e.image);return U(`ul`,{class:`${n}-generative-ui-lines`,children:e.map((e,a)=>U(`li`,{children:[i&&U(Lc,{src:e.image??``,class:`${n}-generative-ui-thumb`},e.image),U(`div`,{children:[U(`div`,{class:`${n}-generative-ui-line-head`,children:[U(`span`,{children:U(Gc,{title:e.title,url:e.url})}),U(`strong`,{children:vo(e.price,t.locale)})]}),U(`span`,{class:`${n}-generative-ui-muted`,children:[...Object.entries(e.options??{}).map(([e,t])=>`${e}: ${t}`),`${r.visualQuantity} ${e.quantity}`].join(` · `)}),U(Ic,{actions:e.actions,context:t,disabled:t.busy,small:!0,getMessage:t=>Ko(t,e.title,e.options)})]})]},a))})}function Ic({actions:e,context:t,disabled:n,small:r,getMessage:i}){let a=Go(e,t.onAction!==void 0);return a.length?U(`div`,{class:`${t.cssPrefix}-generative-ui-actions`,"data-small":r,children:a.map(e=>{if(e.message===void 0)return U(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-primary":e.primary,title:e.label,children:U(`span`,{children:e.label})},e.label);let r=e.message;return U(`button`,{type:`button`,disabled:n,"data-primary":e.primary,title:e.label,onClick:()=>t.onAction?.(i?.(r)??r),children:U(`span`,{children:e.label})},e.label)})}):null}function Lc({src:e,href:t,class:n,wide:r,children:i}){let[a,o]=R(!1),s=!a&&Wo(e)&&U(`img`,{src:e,alt:``,loading:`lazy`,referrerpolicy:`no-referrer`,onError:()=>o(!0)});return Wo(t)?U(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,tabIndex:-1,"aria-hidden":`true`,class:n,"data-wide":r,children:[s,i]}):U(`span`,{class:n,"data-wide":r,children:[s,i]})}function Rc({image:e,url:t,badge:n,available:r,context:{cssPrefix:i,strings:a}}){let o=(n||!r)&&U(`span`,{class:`${i}-generative-ui-badges`,children:[n&&U(`span`,{class:`${i}-generative-ui-pill`,children:n}),!r&&U(`span`,{class:`${i}-generative-ui-pill`,children:a.visualSoldOut})]});return Wo(e)?U(Lc,{src:e,href:t,class:`${i}-generative-ui-photo`,children:o},e):o||null}function zc({parts:e,rating:t,context:{cssPrefix:n}}){let r=e.filter(e=>typeof e==`string`&&e).join(` · `);return!r&&!t?null:U(`span`,{class:`${n}-generative-ui-muted`,children:[t&&U(L,{children:[U(`span`,{"aria-hidden":`true`,class:`${n}-generative-ui-star`,children:[`★`,` `]}),ko(t),t.count!==void 0&&` (${t.count})`,r&&` · `]}),r]})}function Bc({details:e,context:{cssPrefix:t}}){return e?.length?U(`ul`,{class:`${t}-generative-ui-details`,children:e.map(e=>U(`li`,{children:e},e))}):null}function Vc({element:e,context:t}){let{cssPrefix:n,locale:r}=t,i=Oo(e,t.strings,r);return U(`section`,{class:`${n}-generative-ui-offer`,children:[U(Rc,{image:i.image,url:i.url,badge:i.badge,available:i.available,context:t}),U(`strong`,{class:`${n}-generative-ui-title`,title:i.title,children:[U(Gc,{title:i.title,url:i.url}),i.stars!==void 0&&i.stars>0&&U(`span`,{class:`${n}-generative-ui-stars`,role:`img`,"aria-label":`${i.stars} ★`,children:[` `,`★`.repeat(Math.min(i.stars,5))]})]}),U(zc,{parts:[i.location],rating:i.rating,context:t}),U(zc,{parts:[i.when],context:t}),i.room&&U(`p`,{children:i.room}),U(Bc,{details:i.details,context:t}),U(`div`,{class:`${n}-generative-ui-footer`,children:[U(Kc,{price:i.price,compareAtPrice:i.compareAtPrice,note:i.note,context:t}),U(Ic,{actions:e.props.actions,context:t,disabled:t.busy||!i.available,getMessage:e=>Ko(e,i.title,void 0)})]})]})}function Hc({flight:e,actions:t,context:n}){let{cssPrefix:r,strings:i,locale:a}=n;return U(`section`,{class:`${r}-generative-ui-flight`,children:[e.legs.map((e,t)=>U(Uc,{leg:e,strings:i,locale:a,cssPrefix:r},t)),U(Bc,{details:e.details,context:n}),U(`div`,{class:`${r}-generative-ui-footer`,children:[U(Rc,{image:void 0,url:void 0,badge:e.badge,available:e.available!==!1,context:n}),U(Kc,{price:e.price,compareAtPrice:void 0,note:[e.fare,e.priceNote].filter(Boolean).join(` · `),context:n}),U(Ic,{actions:t,context:n,disabled:n.busy||e.available===!1,getMessage:t=>Ko(t,qo(e),void 0)})]})]})}function Uc({leg:e,strings:t,locale:n,cssPrefix:r}){let i=So(e.departs,e.arrives),a=Eo(e,t,n);return U(`div`,{class:`${r}-generative-ui-leg`,children:[U(`span`,{class:`${r}-generative-ui-muted`,children:[e.carrier,e.number,Co(e.departs,n)].filter(Boolean).join(` · `)}),U(`div`,{class:`${r}-generative-ui-leg-times`,children:[U(`span`,{children:[U(`strong`,{children:bo(e.departs,n)}),U(`span`,{children:e.from})]}),U(`span`,{class:`${r}-generative-ui-leg-path`,children:a}),U(`span`,{children:[U(`strong`,{children:[bo(e.arrives,n),i!==void 0&&U(`sup`,{children:[`+`,i]})]}),U(`span`,{children:e.to})]})]})]})}function Wc({title:e,columns:t,rows:n,context:{cssPrefix:r,locale:i}}){let[a,o]=R(void 0),s=Ro(t,n),c=zo(n,a&&{...a,numeric:s[a.column]??!1},i);return U(`section`,{class:`${r}-generative-ui-table-card`,children:U(`div`,{class:`${r}-generative-ui-table`,children:U(`table`,{children:[U(`caption`,{children:e}),U(`thead`,{children:U(`tr`,{children:t.map((e,t)=>U(`th`,{scope:`col`,"data-numeric":s[t],"aria-sort":a?.column===t?a.descending?`descending`:`ascending`:void 0,children:U(`button`,{type:`button`,onClick:()=>o({column:t,descending:a?.column===t&&!a.descending}),children:e})},t))})}),U(`tbody`,{children:c.map((e,n)=>U(`tr`,{children:e.map((e,n)=>U(`td`,{"data-numeric":s[n],"data-label":t[n],children:e},n))},n))})]})})})}function Gc({title:e,url:t}){return Wo(t)?U(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:e}):U(L,{children:e})}function Kc({price:e,compareAtPrice:t,note:n,context:{cssPrefix:r,locale:i}}){return U(`span`,{class:`${r}-generative-ui-price`,children:[U(`strong`,{children:vo(e,i)}),t&&Jo(e,t)&&U(`s`,{children:vo(t,i)}),n&&U(`span`,{class:`${r}-generative-ui-muted`,children:n})]})}function qc({totals:e,context:{cssPrefix:t,locale:n}}){return e.length?U(`dl`,{class:`${t}-generative-ui-totals`,children:e.map(e=>U(`div`,{children:[U(`dt`,{children:e.label}),U(`dd`,{children:vo(e.amount,n)})]},e.label))}):null}function Jc({element:e,context:{cssPrefix:t,locale:n}}){let{type:r,data:i,series:a=[],title:o}=e.props,{baseline:s,barWidth:c,series:l,labels:u,ticks:d,slices:f}=No(e.props,n),p=[`currentColor`,...Mo],m=r===`pie`?i.map((e,t)=>`${e.label} ${Math.round((f[t]?.share??0)*100)}%`):l.length>1?a:[];return U(`section`,{children:[U(`strong`,{children:o}),U(`svg`,{class:`${t}-generative-ui-chart`,viewBox:`0 0 320 168`,role:`img`,"aria-label":`${o}. ${a.length>1?`${a.join(` / `)}. `:``}${i.map(e=>`${e.label}: ${Ao(e.value).join(` / `)}`).join(`, `)}`,children:[r===`pie`?f.map((e,t)=>U(`path`,{d:e.path,fill:p[t%p.length]},t)):l.map((e,t)=>r===`line`?U(`g`,{fill:p[t%p.length],children:[U(`polyline`,{points:e.map(e=>`${e.x},${e.y}`).join(` `),fill:`none`,stroke:p[t%p.length],"stroke-width":2.5,"stroke-linejoin":`round`}),e.map((e,t)=>U(`circle`,{cx:e.x,cy:e.y,r:3},t))]},t):U(`g`,{fill:p[t%p.length],children:e.map((e,t)=>U(`rect`,{x:e.x-c/2,y:Math.min(e.y,s),width:c,height:Math.abs(e.y-s),rx:2},t))},t)),r!==`pie`&&U(`g`,{class:`${t}-generative-ui-axis`,children:[U(`line`,{x1:24,x2:296,y1:s,y2:s}),u.map((e,t)=>U(`text`,{x:e.x,y:164,"text-anchor":`middle`,children:e.text},t)),d.map(e=>U(`text`,{x:20,y:e.y+3,"text-anchor":`end`,children:e.text},e.text))]})]}),m.length>0&&U(`ul`,{class:`${t}-generative-ui-legend`,children:m.map((e,t)=>U(`li`,{style:{color:t?p[t%p.length]:void 0},children:U(`span`,{children:e})},t))})]})}function Yc(e,t){if(!e.includes("```openui"))return e;let n=``,r=0,i=0,a=0,o=0,s;function c(i){s?.language===`openui`&&(n+=e.slice(r,s.start)+Ec(s.source,t)+(e[i-1]===`
62
62
  `?`
63
63
  `:``),r=i),s=void 0}let l=$a({data:void 0,add_token(e,t){o+=1,t===10&&o===1&&(s={start:a,source:``,language:``})},set_attr(e,t,n){s&&t===4&&(s.language=n)},add_text(e,t){s&&(s.source+=t)},end_token(){s&&c(Math.min(i+1,e.length)),--o}});for(;i<e.length;i++)fo(l,e.charAt(i)),e[i]===`
64
- `&&(a=i+1);return eo(l),s&&c(e.length),n+e.slice(r)}function Jc({children:e}){let t=B(null),[n,r]=R({start:!1,end:!1});return z(()=>{let e=t.current;if(!e)return;function n(){if(!e)return;let t=Vo(e);r(e=>e.start===t.start&&e.end===t.end?e:t)}n(),e.addEventListener(`scroll`,n,{passive:!0});let i=typeof ResizeObserver>`u`?void 0:new ResizeObserver(n);return i?.observe(e),()=>{e.removeEventListener(`scroll`,n),i?.disconnect()}},[]),U(`div`,{ref:t,"data-cut-start":n.start||void 0,"data-cut-end":n.end||void 0,children:e})}function Yc(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function Xc(e){return`tool-${e.startsWith(`tool:`)?e.slice(5):e}`}function Zc(e){return e.startsWith(`tool-`)?e.slice(5):e}const Qc={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`,emailTranscript:`/pai/email-transcript`,cancelOperatorRequest:`/pai/cancel-request-operator`,content:`/pai/content`,contentCollections:`/pai/content/collection/list`,contentVoteSet:`/pai/content/vote/set`},$c=`context`;function el(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function tl(e){if(!el(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,assignedOperatorName:typeof t.assignedOperatorName==`string`&&t.assignedOperatorName?t.assignedOperatorName:void 0,assignedOperatorAvatar:typeof t.assignedOperatorAvatar==`string`&&t.assignedOperatorAvatar?t.assignedOperatorAvatar:void 0,operatorAvailable:typeof t.operatorAvailable==`boolean`?t.operatorAvailable:void 0}}function nl(e){if(!el(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 rl(e){let t=el(e)?e.suggestions:void 0;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!el(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 il(e){let t={messages:e.messages.map(e=>({id:e.serverMessageId??e.id,parts:ol(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 al(e){return e.state===`output-available`||e.state===`output-error`||e.state===`output-denied`||e.approval?.approved!==void 0}function ol(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,filename:n.filename,fileId:n.fileId,fileSize:n.fileSize}),n.kind===`tool`&&al(n)){let e=n.dynamic?{type:`dynamic-tool`,toolName:n.toolName,toolCallId:n.toolCallId,state:n.state}:{type:Xc(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 sl(e,t,n=wr()){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 cl(){return{id:wr(),role:`assistant`,createdAt:Date.now(),status:`streaming`,partsSig:H([])}}function ll(e){let t=wr();return ul({id:t,role:e.role,createdAt:Date.now(),status:`complete`,ephemeral:!0,parts:[{kind:`text`,id:`${t}-t0`,text:e.text,done:!0}]})}function ul(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(Xl))}}function dl(e){return e.status===`failed`?`error`:e.role===`assistant`&&e.status===`streaming`?`streaming`:`complete`}function fl(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,filename:t.filename,fileId:t.fileId,fileSize:t.fileSize}: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:Zc(t.type),title:t.title,dynamic:t.type===`dynamic-tool`||void 0,toolMetadata:t.toolMetadata,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`?rl(r.data):void 0,serverMessageId:e.id,createdAt:Date.parse(e.createdAt),status:dl(e),canceled:e.status===`canceled`,feedback:e.feedback??null,stepTimings:pl(e.metadata?.steps),partsSig:H(n)}}function pl(e){if(e?.length&&e.every(e=>ml(e.durationMs)))return e.map(({durationMs:e,reasoningMs:t})=>({durationMs:Number(e),...ml(t)?{reasoningMs:t}:{}}))}function ml(e){return typeof e==`number`&&Number.isFinite(e)}function hl(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 gl(e){return e.role===`assistant`&&e.status===`streaming`&&hl(e)}function _l(e){let t=e.length-1;return e.filter((e,n)=>n===t||!gl(e)).map(fl)}function vl(e,t){let n=!t&&e.at(-1)?.role===`assistant`?-2:-1,r=e.at(n);return!r||r.ephemeral?[]:[r]}function yl(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(Zl)}}function bl(e){let t=``;for(let n of e.partsSig.value)n.kind===`text`&&(t+=n.textSig.value);return t}function xl(e,t,n,r,i=t.createdAt){let a=e.find(e=>e.role===`user`&&!e.ephemeral);function o(e,t){return(e.role===`assistant`?qc(bl(e)):bl(e)).replace(/\s+/g,` `).trim().slice(0,t)}let s=a?o(a,80):``,c=o(t,120);return{conversationId:n,title:s||r,lastMessageAt:new Date(i).toISOString(),preview:c||void 0}}function Sl(e){return bl(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`||e.kind===`source`)}function Cl(e){return bl(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`)}function wl(e){return e===`approval-responded`||e===`output-available`||e===`output-denied`||e===`output-error`}function Tl(e){return e.kind===`tool`}function El(e){return e.kind===`text`&&e.textSig.value.trim()!==``||e.kind===`file`}function Dl(e){let t=e.partsSig.value,n=t.findLastIndex(e=>e.kind===`tool`);return t.slice(n+1).some(El)}function Ol(e){if(e.role!==`assistant`)return!1;let t=e.partsSig.value.filter(Tl);return t.length>0&&t.every(e=>wl(e.stateSig.value))}function kl(e){return e.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`)&&!Dl(e)}function Al(e,t){return!e.partsSig.value.slice(t+1).some(e=>e.kind===`step-start`||El(e))}function jl(e){return e.partsSig.value.some(e=>Tl(e)&&!wl(e.stateSig.value))}function Ml(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 Nl(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 Pl(e,t,n,r){if(!Fl(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&&bl(n).length>=bl(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&&bl(t).length>=bl(e).length)}function Fl(e){return e?.role===`assistant`&&e.status===`streaming`&&e.serverMessageId===void 0}function Il(e,t){let n=new Set(e.partsSig.value.filter(Tl).map(e=>e.toolCallId));return t.partsSig.value.filter(Tl).every(e=>n.has(e.toolCallId))}function Ll(e,t){let n=new Map(t.partsSig.value.filter(Tl).filter(e=>wl(e.stateSig.value)).map(e=>[e.toolCallId,e]));if(n.size===0)return;let r=!1,i=e.partsSig.value.map(e=>{if(!Tl(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,u=e.toolMetadata??t.toolMetadata;return o===e.approvalSig&&s===e.inputSig&&c===e.toolName&&l===e.dynamic&&u===e.toolMetadata?e:(r=!0,{...e,toolName:c,dynamic:l,toolMetadata:u,inputSig:s,approvalSig:o})});r&&(e.partsSig.value=i)}function Rl(e){let t=e.flatMap(e=>e.role===`assistant`&&e.status!==`streaming`?Yc(e.startedAt)??[]:[]);return new Set(e.filter(e=>e.role===`user`&&t.some(t=>t>=(Yc(e.createdAt)??1/0))).map(e=>e.id))}function zl(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||Sl(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`)?Nl(t,e):t.status!==`streaming`&&bl(t).startsWith(bl(e))&&Il(t,e)?(e.createdAt!==void 0&&(t.createdAt=e.createdAt),Ll(t,e),e.stepTimings&&(t.stepTimings=e.stepTimings),t.suggestions??(t.suggestions=e.suggestions),t.feedback===void 0&&(t.feedback=e.feedback),e.canceled&&(t.canceled=!0),t):Nl(t,e):e)}),s=n.filter(e=>!i.has(e)),c=s.findLast(Fl),l=/* @__PURE__ */ new Map;e.forEach((e,t)=>{l.set(e.id,t),e.serverMessageId!==void 0&&l.set(e.serverMessageId,t)});let u=Pl(c,c?n.slice(0,n.indexOf(c)):[],a,l);if(c&&u){let e=o.indexOf(u);e>=0&&(o[e]=Nl(c,u)),s=s.filter(e=>e!==c)}return[...o,...s]}function Bl(e,t){let n=new Map(t.flatMap(e=>e.serverMessageId===void 0?[]:[[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,Nl(e,t);if(e.serverMessageId===void 0)return e;t.createdAt!==void 0&&e.createdAt!==t.createdAt&&(e.createdAt=t.createdAt,a=!0);let r=bl(t),i=bl(e),o=t.status!==`streaming`&&r.length>=i.length&&Gl(e,t);if(r.length>i.length||r===i&&t.partsSig.value.length>e.partsSig.value.length||o)return a=!0,Nl(e,t);if((t.stepTimings?.length??0)>(e.stepTimings?.length??0)&&(e.stepTimings=t.stepTimings,a=!0),e.status===`streaming`&&t.status!==`streaming`&&Hl(e,t)){if(e.continuationStreaming&&jl(t))return e;if(!Gl(t,e))return a=!0,Nl(e,t)}return e}),s=[...n].filter(([e])=>!i.has(e)).map(([,e])=>e),c=o.findLastIndex(Fl),l=o[c],u=Pl(l,o.slice(0,c),s,r);if(l!==void 0&&u!==void 0&&bl(u).length>=bl(l).length&&(Nl(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 Vl(e,t){if(e.role!==t.role)return!1;let n=bl(t),r=bl(e);return n.length>r.length||t.partsSig.value.length>e.partsSig.value.length||Gl(e,t)}function Hl(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&&Ul(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 Ul(e,t){return(e.startsWith(`tool:`)?e.slice(5):e)===(t.startsWith(`tool:`)?t.slice(5):t)}const Wl={"input-streaming":0,"input-available":1,"approval-requested":2,"approval-responded":3,"output-available":4,"output-denied":4,"output-error":4};function Gl(e,t){let n=new Map(e.partsSig.value.filter(Tl).map(e=>[e.toolCallId,e]));return t.partsSig.value.filter(Tl).some(e=>{let t=n.get(e.toolCallId);if(!t||Wl[e.stateSig.value]>Wl[t.stateSig.value])return!0;let r=e.approvalSig.value?.approved;return r!==void 0&&r!==t.approvalSig.value?.approved})}function Kl(e){return e.role===`assistant`&&e.status!==`streaming`&&e.canceled!==!0&&!Sl(e)}function ql(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`&&!Kl(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 Jl(e,t){return e.canceled===!0&&e.role===`assistant`&&e.status!==`streaming`&&!Cl(e)&&!t}function Yl(e,t){return e.operatorRoutedTurn?Kl(e)?`drop`:`complete-operator-routed`:t||Kl(e)?`error`:`complete`}function Xl(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,title:e.title,dynamic:e.dynamic,toolMetadata:e.toolMetadata,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 Zl(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,title:e.title,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 Ql(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 $l(e){return e&&Object.keys(e).length>0?e:void 0}function eu(e,t,n=[]){let r=$l(e),i=$l(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=Ql(JSON.stringify({...r&&{user:r},...o&&{page:o}}));if(s.length<=8192||e===0)return s}}var tu=class extends Error{constructor(e,t,n,r,i,a){super(e),this.code=t,this.status=n,this.cause=r,this.retryAfterSeconds=i,this.errorCode=a,this.name=`StreamError`}};const nu=_.scope(`parser`);async function*ru(e,t,n){if(!e.ok){let t=await e.text().catch(()=>``);throw new tu(`server responded ${e.status}: ${t.slice(0,200)}`,`server`,e.status)}for await(let r of iu(e,t)){let e=au(r,n);if(e===`done`)return;e&&(yield e)}}async function*iu(e,t){if(!e.body)throw new tu(`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(`
64
+ `&&(a=i+1);return eo(l),s&&c(e.length),n+e.slice(r)}function Xc({children:e}){let t=B(null),[n,r]=R({start:!1,end:!1});return z(()=>{let e=t.current;if(!e)return;function n(){if(!e)return;let t=Uo(e);r(e=>e.start===t.start&&e.end===t.end?e:t)}n(),e.addEventListener(`scroll`,n,{passive:!0});let i=typeof ResizeObserver>`u`?void 0:new ResizeObserver(n);return i?.observe(e),()=>{e.removeEventListener(`scroll`,n),i?.disconnect()}},[]),U(`div`,{ref:t,"data-cut-start":n.start||void 0,"data-cut-end":n.end||void 0,children:e})}function Zc(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function Qc(e){return`tool-${e.startsWith(`tool:`)?e.slice(5):e}`}function $c(e){return e.startsWith(`tool-`)?e.slice(5):e}const el={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`,emailTranscript:`/pai/email-transcript`,cancelOperatorRequest:`/pai/cancel-request-operator`,content:`/pai/content`,contentCollections:`/pai/content/collection/list`,contentVoteSet:`/pai/content/vote/set`},tl=`context`;function nl(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function rl(e){if(!nl(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,assignedOperatorName:typeof t.assignedOperatorName==`string`&&t.assignedOperatorName?t.assignedOperatorName:void 0,assignedOperatorAvatar:typeof t.assignedOperatorAvatar==`string`&&t.assignedOperatorAvatar?t.assignedOperatorAvatar:void 0,operatorAvailable:typeof t.operatorAvailable==`boolean`?t.operatorAvailable:void 0}}function il(e){if(!nl(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 al(e){let t=nl(e)?e.suggestions:void 0;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!nl(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 ol(e){let t={messages:e.messages.map(e=>({id:e.serverMessageId??e.id,parts:cl(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 sl(e){return e.state===`output-available`||e.state===`output-error`||e.state===`output-denied`||e.approval?.approved!==void 0}function cl(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,filename:n.filename,fileId:n.fileId,fileSize:n.fileSize}),n.kind===`tool`&&sl(n)){let e=n.dynamic?{type:`dynamic-tool`,toolName:n.toolName,toolCallId:n.toolCallId,state:n.state}:{type:Qc(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 ll(e,t,n=wr()){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 ul(){return{id:wr(),role:`assistant`,createdAt:Date.now(),status:`streaming`,partsSig:H([])}}function dl(e){let t=wr();return fl({id:t,role:e.role,createdAt:Date.now(),status:`complete`,ephemeral:!0,parts:[{kind:`text`,id:`${t}-t0`,text:e.text,done:!0}]})}function fl(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(Ql))}}function pl(e){return e.status===`failed`?`error`:e.role===`assistant`&&e.status===`streaming`?`streaming`:`complete`}function ml(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,filename:t.filename,fileId:t.fileId,fileSize:t.fileSize}: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:$c(t.type),title:t.title,dynamic:t.type===`dynamic-tool`||void 0,toolMetadata:t.toolMetadata,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`?al(r.data):void 0,serverMessageId:e.id,createdAt:Date.parse(e.createdAt),status:pl(e),canceled:e.status===`canceled`,feedback:e.feedback??null,stepTimings:hl(e.metadata?.steps),partsSig:H(n)}}function hl(e){if(e?.length&&e.every(e=>gl(e.durationMs)))return e.map(({durationMs:e,reasoningMs:t})=>({durationMs:Number(e),...gl(t)?{reasoningMs:t}:{}}))}function gl(e){return typeof e==`number`&&Number.isFinite(e)}function _l(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 vl(e){return e.role===`assistant`&&e.status===`streaming`&&_l(e)}function yl(e){let t=e.length-1;return e.filter((e,n)=>n===t||!vl(e)).map(ml)}function bl(e,t){let n=!t&&e.at(-1)?.role===`assistant`?-2:-1,r=e.at(n);return!r||r.ephemeral?[]:[r]}function xl(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($l)}}function Sl(e){let t=``;for(let n of e.partsSig.value)n.kind===`text`&&(t+=n.textSig.value);return t}function Cl(e,t,n,r,i=t.createdAt){let a=e.find(e=>e.role===`user`&&!e.ephemeral);function o(e,t){return(e.role===`assistant`?Yc(Sl(e)):Sl(e)).replace(/\s+/g,` `).trim().slice(0,t)}let s=a?o(a,80):``,c=o(t,120);return{conversationId:n,title:s||r,lastMessageAt:new Date(i).toISOString(),preview:c||void 0}}function wl(e){return Sl(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`||e.kind===`source`)}function Tl(e){return Sl(e).trim()!==``||e.partsSig.value.some(e=>e.kind===`tool`||e.kind===`file`)}function El(e){return e===`approval-responded`||e===`output-available`||e===`output-denied`||e===`output-error`}function Dl(e){return e.kind===`tool`}function Ol(e){return e.kind===`text`&&e.textSig.value.trim()!==``||e.kind===`file`}function kl(e){let t=e.partsSig.value,n=t.findLastIndex(e=>e.kind===`tool`);return t.slice(n+1).some(Ol)}function Al(e){if(e.role!==`assistant`)return!1;let t=e.partsSig.value.filter(Dl);return t.length>0&&t.every(e=>El(e.stateSig.value))}function jl(e){return e.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`)&&!kl(e)}function Ml(e,t){return!e.partsSig.value.slice(t+1).some(e=>e.kind===`step-start`||Ol(e))}function Nl(e){return e.partsSig.value.some(e=>Dl(e)&&!El(e.stateSig.value))}function Pl(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 Fl(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 Il(e,t,n,r){if(!Ll(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&&Sl(n).length>=Sl(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&&Sl(t).length>=Sl(e).length)}function Ll(e){return e?.role===`assistant`&&e.status===`streaming`&&e.serverMessageId===void 0}function Rl(e,t){let n=new Set(e.partsSig.value.filter(Dl).map(e=>e.toolCallId));return t.partsSig.value.filter(Dl).every(e=>n.has(e.toolCallId))}function zl(e,t){let n=new Map(t.partsSig.value.filter(Dl).filter(e=>El(e.stateSig.value)).map(e=>[e.toolCallId,e]));if(n.size===0)return;let r=!1,i=e.partsSig.value.map(e=>{if(!Dl(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,u=e.toolMetadata??t.toolMetadata;return o===e.approvalSig&&s===e.inputSig&&c===e.toolName&&l===e.dynamic&&u===e.toolMetadata?e:(r=!0,{...e,toolName:c,dynamic:l,toolMetadata:u,inputSig:s,approvalSig:o})});r&&(e.partsSig.value=i)}function Bl(e){let t=e.flatMap(e=>e.role===`assistant`&&e.status!==`streaming`?Zc(e.startedAt)??[]:[]);return new Set(e.filter(e=>e.role===`user`&&t.some(t=>t>=(Zc(e.createdAt)??1/0))).map(e=>e.id))}function Vl(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||wl(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`)?Fl(t,e):t.status!==`streaming`&&Sl(t).startsWith(Sl(e))&&Rl(t,e)?(e.createdAt!==void 0&&(t.createdAt=e.createdAt),zl(t,e),e.stepTimings&&(t.stepTimings=e.stepTimings),t.suggestions??(t.suggestions=e.suggestions),t.feedback===void 0&&(t.feedback=e.feedback),e.canceled&&(t.canceled=!0),t):Fl(t,e):e)}),s=n.filter(e=>!i.has(e)),c=s.findLast(Ll),l=/* @__PURE__ */ new Map;e.forEach((e,t)=>{l.set(e.id,t),e.serverMessageId!==void 0&&l.set(e.serverMessageId,t)});let u=Il(c,c?n.slice(0,n.indexOf(c)):[],a,l);if(c&&u){let e=o.indexOf(u);e>=0&&(o[e]=Fl(c,u)),s=s.filter(e=>e!==c)}return[...o,...s]}function Hl(e,t){let n=new Map(t.flatMap(e=>e.serverMessageId===void 0?[]:[[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,Fl(e,t);if(e.serverMessageId===void 0)return e;t.createdAt!==void 0&&e.createdAt!==t.createdAt&&(e.createdAt=t.createdAt,a=!0);let r=Sl(t),i=Sl(e),o=t.status!==`streaming`&&r.length>=i.length&&ql(e,t);if(r.length>i.length||r===i&&t.partsSig.value.length>e.partsSig.value.length||o)return a=!0,Fl(e,t);if((t.stepTimings?.length??0)>(e.stepTimings?.length??0)&&(e.stepTimings=t.stepTimings,a=!0),e.status===`streaming`&&t.status!==`streaming`&&Wl(e,t)){if(e.continuationStreaming&&Nl(t))return e;if(!ql(t,e))return a=!0,Fl(e,t)}return e}),s=[...n].filter(([e])=>!i.has(e)).map(([,e])=>e),c=o.findLastIndex(Ll),l=o[c],u=Il(l,o.slice(0,c),s,r);if(l!==void 0&&u!==void 0&&Sl(u).length>=Sl(l).length&&(Fl(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 Ul(e,t){if(e.role!==t.role)return!1;let n=Sl(t),r=Sl(e);return n.length>r.length||t.partsSig.value.length>e.partsSig.value.length||ql(e,t)}function Wl(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&&Gl(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 Gl(e,t){return(e.startsWith(`tool:`)?e.slice(5):e)===(t.startsWith(`tool:`)?t.slice(5):t)}const Kl={"input-streaming":0,"input-available":1,"approval-requested":2,"approval-responded":3,"output-available":4,"output-denied":4,"output-error":4};function ql(e,t){let n=new Map(e.partsSig.value.filter(Dl).map(e=>[e.toolCallId,e]));return t.partsSig.value.filter(Dl).some(e=>{let t=n.get(e.toolCallId);if(!t||Kl[e.stateSig.value]>Kl[t.stateSig.value])return!0;let r=e.approvalSig.value?.approved;return r!==void 0&&r!==t.approvalSig.value?.approved})}function Jl(e){return e.role===`assistant`&&e.status!==`streaming`&&e.canceled!==!0&&!wl(e)}function Yl(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`&&!Jl(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 Xl(e,t){return e.canceled===!0&&e.role===`assistant`&&e.status!==`streaming`&&!Tl(e)&&!t}function Zl(e,t){return e.operatorRoutedTurn?Jl(e)?`drop`:`complete-operator-routed`:t||Jl(e)?`error`:`complete`}function Ql(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,title:e.title,dynamic:e.dynamic,toolMetadata:e.toolMetadata,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 $l(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,title:e.title,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 eu(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 tu(e){return e&&Object.keys(e).length>0?e:void 0}function nu(e,t,n=[]){let r=tu(e),i=tu(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=eu(JSON.stringify({...r&&{user:r},...o&&{page:o}}));if(s.length<=8192||e===0)return s}}var ru=class extends Error{constructor(e,t,n,r,i,a){super(e),this.code=t,this.status=n,this.cause=r,this.retryAfterSeconds=i,this.errorCode=a,this.name=`StreamError`}};const iu=_.scope(`parser`);async function*au(e,t,n){if(!e.ok){let t=await e.text().catch(()=>``);throw new ru(`server responded ${e.status}: ${t.slice(0,200)}`,`server`,e.status)}for await(let r of ou(e,t)){let e=su(r,n);if(e===`done`)return;e&&(yield e)}}async function*ou(e,t){if(!e.body)throw new ru(`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(`
65
65
 
66
- `))!==-1;){let e=r.slice(0,a);r=r.slice(a+2),yield e}}}finally{n.releaseLock()}}function au(e,t){let n=``,r;for(let i of e.split(`
67
- `))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);if(!ou(e))throw TypeError(`unrecognized chunk`);return nu.trace(`chunk`,{type:e.type,eventId:r}),{chunk:e,eventId:r}}catch(e){throw nu.trace(`frame parse failed`,{errorType:e instanceof Error?e.name:typeof e,payloadLength:n.length}),new tu(`invalid SSE frame`,`network`,void 0,e)}}function ou(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof Reflect.get(e,`type`)==`string`}const su=/* @__PURE__ */ new Set([101,204,205,304]);function cu(e){let t=new Headers;for(let n of e.trim().split(/[\r\n]+/)){let e=n.indexOf(`:`);e>0&&t.append(n.slice(0,e).trim(),n.slice(e+1).trim())}return t}function lu(e){return async function(t,n){let r=new Request(t,n),i=await r.blob();return new Promise((t,n)=>{if(r.signal.aborted){n(r.signal.reason);return}let a=new XMLHttpRequest;a.open(r.method,r.url),a.withCredentials=r.credentials===`include`,a.responseType=`blob`,r.headers.forEach((e,t)=>a.setRequestHeader(t,e)),a.upload.addEventListener(`progress`,t=>{t.lengthComputable&&t.total>0&&e(t.loaded/t.total)}),a.addEventListener(`load`,()=>{t(new Response(su.has(a.status)?null:a.response,{status:a.status,statusText:a.statusText,headers:cu(a.getAllResponseHeaders())}))}),a.addEventListener(`error`,()=>n(/* @__PURE__ */ TypeError(`Failed to fetch`))),a.addEventListener(`abort`,()=>n(r.signal.reason)),r.signal.addEventListener(`abort`,()=>a.abort(),{once:!0}),a.send(i)})}}const uu=_.scope(`transport`);async function du(e){try{let t=await e.clone().json();if(typeof t!=`object`||!t)return{};let n=Reflect.get(t,`error`);return{error:typeof n==`string`?n:void 0,loginUrl:Va(Reflect.get(t,`login`)).url}}catch{return{}}}const fu=6e4,pu=/* @__PURE__ */ new WeakMap;function mu(e){return pu.get(e)}function hu(e,t){return pu.set(e,t),e}function gu(e){return Math.max(e?.upsertRevision??0,e?.read?.revision??0)}function _u(e,t){return e.conversationId===t.conversationId&&e.title===t.title&&e.lastMessageAt===t.lastMessageAt&&e.preview===t.preview&&e.hasUnread===t.hasUnread&&e.controlState===t.controlState}function vu(e,t,n=!0){switch(t.type){case`snapshot`:{let n=new Map(e.map(e=>[e.conversationId,e])),r=e.filter(e=>(mu(e)?.activityRevision??0)>t.requestedRevision).toSorted((e,t)=>(mu(t)?.activityRevision??0)-(mu(e)?.activityRevision??0)),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=mu(r);return(i?.upsertRevision??0)>t.requestedRevision?r:i?.read&&!r.hasUnread&&i.read.lastMessageAt===e.lastMessageAt?hu({...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)),r=e[n];if(!r)return e;let i=mu(r);if(gu(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?hu({...e,hasUnread:!1},o):e):(hu(r,o),e)}case`upsert`:{let r=e.findIndex(e=>e.conversationId===t.conversation.conversationId);if(r<0&&!n)return e;let i=e[r],a=i?mu(i):void 0;if(gu(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&&_u(i,c)?(hu(i,s),e):(hu(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 yu=/* @__PURE__ */ new Set([408,425,429,500,502,503,504]);function bu(e){return 400*2**e+Math.floor(Math.random()*250)}function xu(e){return 6e4+Math.ceil(e/1048576)*15e3}function Su(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 Cu=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)}};function wu(e,t){let{translations:n,defaultLocale:r,...i}=Dt(e,t);return i}var Tu=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 Cu(1e4)),S(this,`contentCache`,new Cu(fu)),S(this,`contentCollectionsCache`,new Cu(fu))}setUserToken(e){this.userTokenSource=e,this.userToken=typeof e==`string`&&e||void 0,this.userTokenRequest=typeof e==`function`?this.fetchUserToken():void 0,this.opts.onLoginState?.(e?{status:`pending`}:{status:`anonymous`})}async userSub(){return this.userTokenRequest&&await this.userTokenRequest,this.userToken?Ka(this.userToken):void 0}reportLogin(e){this.opts.onLoginState?.(e===`loggedIn`&&this.userToken?{status:e,...Ga(this.userToken)}:{status:e===`loggedIn`?`anonymous`:e})}async refreshUserToken(){let e=this.userToken;return typeof this.userTokenSource==`function`&&(this.userTokenRequest&&await this.userTokenRequest,this.userToken===e&&await this.fetchUserToken(),!!this.userToken&&this.userToken!==e)}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:jr};this.visitorId&&(e.visitorId=this.visitorId),this.conversationId&&(e.conversationId=this.conversationId),this.locale&&(e.locale=this.locale);let t=eu(this.userContext,this.pageContext);return t&&(e[$c]=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){uu.debug(`handshake →`,{visitorId:e.visitorId,conversationId:e.conversationId,locale:e.locale});let t=ku(`handshake`,await this.postJson(Qc.handshake,e,`handshake`),ju),n=t.loginStatus===`expired`&&await this.refreshUserToken()?ku(`handshake`,await this.postJson(Qc.handshake,e,`handshake`),ju):t;return this.reportLogin(n.loginStatus??(this.userToken?`loggedIn`:`anonymous`)),uu.debug(`handshake ←`,{visitorId:n.visitorId,conversationId:n.conversationId,hasWelcome:!!n.welcome,hasConfig:!!n.config,rebind:n.rebind}),this.visitorId=n.visitorId,this.conversationId=n.conversationId,n}async uploadFile(e,t,n){uu.debug(`uploadFile →`,{name:e.name,size:e.size,type:e.type});let r=new FormData;r.append(`file`,e,e.name);let i=ku(`upload`,await this.postForm(this.uploadPath,r,`upload`,t,xu(e.size),n),Mu);return uu.debug(`uploadFile ←`,{id:i.id,url:i.url}),i}async transcribe(e,t=`audio/webm`){uu.debug(`transcribe →`,{size:e.size,mimeType:t});let n=new FormData;n.append(`audio`,e,`voice.${Eu(t)}`),n.append(`mimeType`,t);let r=ku(`transcribe`,await this.postForm(this.transcribePath,n,`transcribe`),Nu);return uu.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=vu(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(Qc.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(`,`)),ku(`listConversations`,await this.getJson(t.toString(),`listConversations`),Fu)}async loadConversation(e,{ids:t=[],beforeId:n,beforeCreatedAt:r}={}){let i=new URL(this.url(Qc.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=ku(`loadConversation`,await this.getJson(i.toString(),`loadConversation`),Iu);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=vu(e.conversations,n);return t===e.conversations?e:{...e,conversations:t}});for(let e of this.conversationListeners)e(n);try{await this.postJson(Qc.markRead,{conversationId:e},`markRead`,!0)}catch(e){uu.debug(`markRead failed (non-fatal)`,{err:e})}}async requestOperator(){if(this.visitorId&&this.conversationId)try{return Au(`requestOperator`,await this.postJson(Qc.requestOperator,{},`requestOperator`))}catch(e){uu.debug(`requestOperator failed (non-fatal)`,{err:e});return}}async emailTranscript(e){return ku(`emailTranscript`,await this.postJson(Qc.emailTranscript,{email:e},`emailTranscript`),Lu)}async cancelOperatorRequest(){if(this.visitorId&&this.conversationId)try{return Au(`cancelOperatorRequest`,await this.postJson(Qc.cancelOperatorRequest,{},`cancelOperatorRequest`))}catch(e){uu.debug(`cancelOperatorRequest failed (non-fatal)`,{err:e});return}}listContent(e={}){return this.contentCache.getOrFetch(JSON.stringify(e,Object.keys(e).toSorted()),()=>this.fetchContent(e)).then(e=>({...e,items:e.items.map(e=>wu(e,this.locale))}))}async fetchContent(e){let t=new URL(this.dataUrl(Qc.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=ku(`listContent`,await this.getJson(t.toString(),`listContent`),Ru);return{...n,items:n.items??[]}}async setContentVote(e){try{await this.postJson(this.dataUrl(Qc.contentVoteSet),e,`setContentVote`)}catch{}}listContentCollections(e){return this.contentCollectionsCache.getOrFetch(e.join(`,`),()=>this.fetchContentCollections(e)).then(e=>({items:e.items.map(e=>wu(e,this.locale))}))}async fetchContentCollections(e){let t=new URL(this.dataUrl(Qc.contentCollections));return e.length&&t.searchParams.set(`ids`,e.join(`,`)),{items:ku(`listContentCollections`,await this.getJson(t.toString(),`listContentCollections`),zu).items??[]}}async saveUserPrefs(e){await this.postJson(Qc.updateSettings,{userPrefs:e},`saveUserPrefs`)}get uploadPath(){return this.opts.endpoints?.upload??`/pai/upload-file`}get transcribePath(){return this.opts.endpoints?.transcribe??`/pai/transcribe-audio`}async submitFeedback(e){uu.debug(`submitFeedback →`,{messageId:e.messageId,value:e.value});try{await this.postJson(Qc.messageFeedback,{messageId:e.messageId,set:{feedback:e.value}},`submitFeedback`)}catch(e){uu.debug(`submitFeedback failed (non-fatal)`,{err:e})}}async sendTurn(e,t={}){uu.debug(`message →`,{conversationId:e.conversationId,visitorId:e.visitorId,messageCount:e.messages.length});let n=JSON.stringify({...this.withEnvelope(e),[$c]:eu(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(Qc.streamMessage),{method:`POST`,credentials:`omit`,headers:{accept:`application/json`,"content-type":`application/json`,...this.headersFor(this.url(Qc.streamMessage))},body:n,keepalive:r,signal:e}));if(t.status!==202)throw new tu(`sendTurn failed: expected 202, received ${t.status}`,`server`,t.status,void 0,Bu(t),(await du(t)).error);let i;try{i=await t.json()}catch(n){throw e?.aborted?n:new tu(`sendTurn failed: invalid acknowledgement`,`server`,t.status,n)}if(!Du(i))throw new tu(`sendTurn failed: invalid acknowledgement`,`server`,t.status);return i},void 0,3e4)}catch(e){throw e instanceof tu?e:new tu(`sendTurn failed: network error`,`network`,void 0,e)}}cancelTurn(e,t){this.visitorId&&e&&t&&(uu.debug(`cancel stream`,{conversationId:e,runId:t,visitorId:this.visitorId}),this.fetchImpl(this.url(Qc.cancelStream),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.headersFor(this.url(Qc.cancelStream))},body:JSON.stringify(this.withEnvelope({conversationId:e,runId:t})),keepalive:!0}).catch(e=>uu.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{a=await this.withFreshUserToken(()=>this.fetchImpl(this.resumeUrl(),{method:`GET`,credentials:`omit`,cache:`no-store`,headers:{accept:`text/event-stream`,...this.headersFor(this.resumeUrl())},signal:t.signal}))}catch(t){return i(),e.signal.aborted||uu.debug(`resume-stream fetch failed — reconnecting`,{err:t}),`held`}if(!a.ok)return i(),a.status===409||yu.has(a.status)?(uu.debug(`resume-stream → transient response; reconnecting`,{status:a.status}),`held`):(uu.debug(`resume-stream → endpoint unavailable`,{status:a.status}),`unavailable`);if(!a.body)return i(),uu.debug(`resume-stream → bodyless response; stopping`,{status:a.status}),`unavailable`;if(!(a.headers.get(`content-type`)??``).includes(`text/event-stream`))return i(),uu.debug(`resume-stream → non-SSE response; stopping`),`unavailable`;let o=!1;try{for await(let{chunk:n}of ru(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`;uu.debug(`resume-stream segment dropped — reconnecting`,{err:t})}finally{i()}return`held`}resumeUrl(){return this.withEnvelopeQuery(Qc.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,a){let o=a?lu(a):this.fetchImpl;return this.runWithAbort(async r=>{let i=await this.withFreshUserToken(()=>o(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 tu(`${t} failed: network error`,`network`,void 0,e);uu.debug(`request network error — retrying`,{label:t,attempt:n}),await de(bu(n));continue}if(r.ok||!yu.has(r.status)||n>=3)return r;let i=Su(r.headers)??bu(n);uu.debug(`request retryable status — retrying`,{label:t,status:r.status,attempt:n,wait:i}),await de(i)}}async assertOk(e,t){if(!e.ok)throw new tu(`${t} failed: ${e.status}`,`server`,e.status,void 0,void 0,(await du(e)).error);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)},t=>{uu.warn(`userToken function failed`,{err:t}),this.userTokenSource===e&&(this.userToken=void 0)});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}:{},...t&&this.opts.continueLink?{"x-continue-link":this.opts.continueLink}:{}}}async withFreshUserToken(e){this.userTokenRequest&&await this.userTokenRequest;let t=await e();if(t.status!==401)return t;let n=await du(t);if(n.error===`USER_TOKEN_REQUIRED`)return this.opts.onLoginState?.({status:`required`,loginUrl:n.loginUrl}),t;if(!this.userToken)return t;if(!await this.refreshUserToken())return this.reportLogin(`expired`),t;this.reportLogin(`loggedIn`);let r=await e();return r.status===401&&this.reportLogin(`expired`),r}url(e){return/^https?:\/\//i.test(e)?e:`${this.opts.agentApiBaseUrl}${e}`}dataUrl(e){return`${this.opts.dataApiBaseUrl}${e}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function Eu(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 Du(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 Ou(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ku(e,t,n){if(!n(t))throw new tu(`${e} failed: invalid response body`,`server`);return t}function Au(e,t){let n=tl(Ou(t)?t.controlState:void 0);if(!n)throw new tu(`${e} failed: invalid response body`,`server`);return n}function ju(e){return!(!Ou(e)||typeof e.visitorId!=`string`||typeof e.conversationId!=`string`||e.welcome!==void 0&&(!Ou(e.welcome)||e.welcome.messages!==void 0&&!Array.isArray(e.welcome.messages)))}function Mu(e){return Ou(e)&&typeof e.id==`string`&&typeof e.url==`string`&&typeof e.originalName==`string`&&typeof e.mimeType==`string`&&typeof e.fileSize==`number`}function Nu(e){return Ou(e)&&typeof e.text==`string`}function Pu(e){return Ou(e)&&typeof e.page==`number`&&typeof e.limit==`number`&&typeof e.total==`number`&&typeof e.totalPages==`number`&&typeof e.hasNext==`boolean`&&typeof e.hasPrev==`boolean`}function Fu(e){return Ou(e)&&Array.isArray(e.conversations)&&e.conversations.every(Ou)&&Pu(e.pagination)}function Iu(e){return Ou(e)&&typeof e.conversationId==`string`&&Array.isArray(e.messages)&&e.messages.every(Ou)}function Lu(e){return Ou(e)&&typeof e.status==`string`&&typeof e.to==`string`}function Ru(e){return Ou(e)&&(e.items===void 0||Array.isArray(e.items)&&e.items.every(Ou))&&(e.pagination===void 0||Pu(e.pagination))}function zu(e){return Ou(e)&&(e.items===void 0||Array.isArray(e.items)&&e.items.every(Ou))}function Bu(e){let t=Number(e.headers.get(`retry-after`));return Number.isInteger(t)&&t>0?t:void 0}function Vu(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 Hu(e,t,n){return Vu(`close`,e,t)?n.includes(`close`):!1}function Uu(e,t){return e===`inline`&&t===`fullscreen`?`exit-fullscreen`:`close`}function Wu(e,t,n,r){let i={role:n,text:r};e.emit(`message`,i),t.onMessage?.(i)}function Gu(e){return Object.fromEntries(e.map(e=>[e,[]]))}function Ku(e,t,n){return e.includes(t)?t:e.includes(n)?n:e[0]??``}function qu(e,t,n){let r=[...new Set(t)],i=H({activeTab:Ku(r,e,``),stacks:Gu(r)});return{sig:i,reconcile(e,t){let a=[...new Set(e)],o=i.value,s=Ku(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:Ku(r,e,``),stacks:Gu(r)}}}}function Ju(e){return e.stacks[e.activeTab]??[]}function Yu(e){return Ju(e).at(-1)}function Xu(e){return Ju(e).length===0}function Zu(e){/^(https?:)?\//i.test(e)&&window.open(e,`_blank`,`noopener,noreferrer`)}function Qu(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 $u(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 ed(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:$u(e.mode,e.size,t)}}function td(){return typeof window>`u`?0:window.innerWidth}const q={fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`},nd=`${i.cssPrefix}-icon-dir`;function rd(){return/* @__PURE__ */ U(`svg`,{...q,"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 id(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M18 6 6 18M6 6l12 12`})})}function ad(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M12 5v14M5 12h14`})})}function od(){return/* @__PURE__ */ U(`svg`,{...q,class:nd,"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 sd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M12 19V5M5 12l7-7 7 7`})})}function cd(){return/* @__PURE__ */ U(`svg`,{...q,class:nd,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 20V4l18 8-18 8Z`})})}function ld(){return/* @__PURE__ */ U(`svg`,{...q,class:nd,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`m9 18 6-6-6-6`})})}function ud(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}function dd(){return/* @__PURE__ */ U(`svg`,{...q,"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 fd(){return/* @__PURE__ */ U(`svg`,{...q,"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 pd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`8`,r:`4.5`}),/* @__PURE__ */ U(`path`,{d:`M4.5 20.5a7.5 7.5 0 0 1 15 0`})]})}function md(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5`})})}function hd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5`})})}function gd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z`})})}function _d(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7`})})}function vd(){return/* @__PURE__ */ U(`svg`,{...q,"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 yd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,viewBox:`0 0 10 10`,children:/* @__PURE__ */ U(`path`,{d:`M9 1L1 9M9 5L5 9M9 9H9`,strokeWidth:`1.5`})})}function bd(){return/* @__PURE__ */ U(`svg`,{...q,"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 xd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Sd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6`})})}function Cd(){return/* @__PURE__ */ U(`svg`,{...q,"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 wd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M20 6 9 17l-5-5`})})}function Td(){return/* @__PURE__ */ U(`svg`,{...q,"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 Ed(){return/* @__PURE__ */ U(`svg`,{...q,"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 Dd(){return/* @__PURE__ */ U(`svg`,{...q,class:nd,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M19 12H5M12 19l-7-7 7-7`})})}function Od(){return/* @__PURE__ */ U(`svg`,{...q,"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 kd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`rect`,{x:`3`,y:`5`,width:`18`,height:`14`,rx:`2`}),/* @__PURE__ */ U(`path`,{d:`m3 7 9 6 9-6`})]})}function Ad(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`m6 9 6 6 6-6`})})}function jd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Md(){return/* @__PURE__ */ U(`svg`,{...q,"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 Nd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Pd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Fd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Id(){return/* @__PURE__ */ U(`svg`,{...q,"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 Ld(){return/* @__PURE__ */ U(`svg`,{...q,"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 Rd(){return/* @__PURE__ */ U(`svg`,{...q,"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 zd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`11`,cy:`11`,r:`7`}),/* @__PURE__ */ U(`path`,{d:`m21 21-4.3-4.3`})]})}function Bd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Vd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Hd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Ud(){return/* @__PURE__ */ U(`svg`,{...q,"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 Wd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Gd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Kd(){return/* @__PURE__ */ U(`svg`,{...q,"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 qd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Jd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Yd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Xd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Zd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Qd(){return/* @__PURE__ */ U(`svg`,{...q,"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 $d(){return/* @__PURE__ */ U(`svg`,{...q,"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 ef(){return/* @__PURE__ */ U(`svg`,{...q,"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 tf(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`M12 7v5l3 2`})]})}function nf(){return/* @__PURE__ */ U(`svg`,{...q,"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 rf(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`m15 9-6 6M9 9l6 6`})]})}function af(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M12 18V5M15 13a4.17 4.17 0 01-3-4 4.17 4.17 0 01-3 4M17.707 6.294A3 3 0 1012 5a3 3 0 10-5.707 1.294M17.996 5.125a4 4 0 012.526 5.77M18 18a4 4 0 002-7.465M19.967 17.482a4 4 0 11-7.967.517 4 4 0 11-7.967-.517M6 18a4 4 0 01-2-7.465M6.004 5.125a4 4 0 00-2.526 5.77`})})}function of(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ U(`path`,{d:`M12 8v4M12 16h.01`})]})}const sf={chat:rd,message:Nd,bubbles:Ud,spark:Md,wand:Fd,bot:Id,help:Pd,lifebuoy:Rd,headset:Ld,search:qd,sparkles:Jd,concierge:Yd,wave:Xd},J=i.cssPrefix,Y={launcher:`${J}-launcher`,callout:`${J}-callout`,calloutDismiss:`${J}-callout-dismiss`,panel:`${J}-panel`,panelHeader:`${J}-panel-header`,resizeGrip:`${J}-resize-grip`,scrollToBottom:`${J}-scroll-to-bottom`,loadPreviousMessages:`${J}-load-previous-messages`,actionHistory:`${J}-action-history`,actionClose:`${J}-action-close`,emailTranscriptSheet:`${J}-email-transcript-sheet`,emailTranscriptEmail:`${J}-email-transcript-email`,emailTranscriptSend:`${J}-email-transcript-send`,langSegment:`${J}-lang-segment`,composer:`${J}-composer`,composerInput:`${J}-composer-input`,composerCount:`${J}-composer-count`,composerSend:`${J}-composer-send`,composerStop:`${J}-composer-stop`,compactionStatus:`${J}-compaction-status`,messageQueue:`${J}-message-queue`,queuedMessage:`${J}-queued-message`,queuedMessageRemove:`${J}-queued-message-remove`,composerAttach:`${J}-composer-attach`,composerFileInput:`${J}-composer-file-input`,composerVoice:`${J}-composer-voice`,attachmentChip:`${J}-attachment-chip`,attachmentRemove:`${J}-attachment-remove`,attachmentRetry:`${J}-attachment-retry`,suggestion:`${J}-suggestion`,messageBubble:`${J}-message`,messageRetry:`${J}-message-retry`,messageFile:`${J}-message-file`,messageFeedback:`${J}-message-feedback`,feedbackUp:`${J}-feedback-up`,feedbackDown:`${J}-feedback-down`,messageCopy:`${J}-message-copy`,historyItem:`${J}-history-item`,historyLoadMore:`${J}-history-load-more`,sidebar:`${J}-sidebar`,sidebarToggle:`${J}-sidebar-toggle`,sidebarNewConversation:`${J}-sidebar-new-conversation`,messengerHome:`${J}-messenger-home`,panelNotice:`${J}-panel-notice`,tab:`${J}-tab`,tabBadge:`${J}-tab-badge`,homeView:`${J}-home-view`,homeGreeting:`${J}-home-greeting`,homeBrand:`${J}-home-brand`,backHeader:`${J}-back-header`,contentView:`${J}-content-view`,contentScroll:`${J}-content-scroll`,homeSearch:`${J}-home-search`,helpSearch:`${J}-help-search`,homeRecent:`${J}-home-recent`,homeAsk:`${J}-home-ask`,homeWhatsNew:`${J}-home-whats-new`,homeContentRow:`${J}-home-content-row`,helpArticle:`${J}-help-article`,newsItem:`${J}-news-item`,newsMore:`${J}-news-more`,formField:`${J}-form-field`,toolAskQuestions:`${J}-tool-ask-questions`,toolInputSubmit:`${J}-tool-input-submit`,toolInputSkip:`${J}-tool-input-skip`,toolApproval:`${J}-tool-approval`,toolPreview:`${J}-tool-preview`,toolApprove:`${J}-tool-approve`,toolDecline:`${J}-tool-decline`,toolEdit:`${J}-tool-edit`,toolDecision:`${J}-tool-decision`,typingDots:`${J}-typing-dots`,reasoning:`${J}-reasoning`,replyStopped:`${J}-reply-stopped`,toolAskSummary:`${J}-ask-questions-summary`,toolAskOptions:`${J}-ask-questions-options-toggle`,toolSteps:`${J}-tool-steps`,toolStep:`${J}-tool-step`,source:`${J}-source`,operatorRequest:`${J}-operator-request`,chatNotice:`${J}-chat-notice`,operatorBanner:`${J}-operator-banner`,cancelOperatorRequest:`${J}-cancel-operator-request`,loginBar:`${J}-login-bar`,loginBarAction:`${J}-login-bar-action`,loginBarHide:`${J}-login-bar-hide`,loginGate:`${J}-login-gate`,loginGateAction:`${J}-login-gate-action`,loginGateGuest:`${J}-login-gate-guest`,loggedIn:`${J}-logged-in`};function cf(e,t){return`${e}-${t}`}const lf=i.cssPrefix;function uf({buttonRef:e,onToggle:t,launcher:n,strings:r,leaving:i,edgeTab:a}){let o=n.variant===`circle`?``:df(n,r);return/* @__PURE__ */ U(`button`,{ref:e,type:`button`,class:`${lf}-fab`,part:`launcher`,"data-variant":n.variant,"data-size":n.size,"data-edge-tab":a?`true`:void 0,"data-leaving":i?`true`:void 0,"data-testid":Y.launcher,onClick:t,"aria-label":r.launcherOpen,children:[ff(n.icon),o?/* @__PURE__ */ U(`span`,{class:`${lf}-fab-label`,children:o}):null]})}function df(e,t){return e.label?Pt(t,e.label):e.personaName?t.launcherAsk.replace(`{name}`,Pt(t,e.personaName)):``}function ff(e){let t=sf[e];return t?/* @__PURE__ */ U(t,{}):/* @__PURE__ */ U(pf,{source:e})}function pf({source:e}){return/* @__PURE__ */ U(`span`,{ref:t=>{t&&mf(t,e)},"aria-hidden":`true`})}function mf(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 hf({callout:e,launcherPosition:t,strings:n,closeLabel:r,onDismiss:i}){let[a,o]=R(!1),s=B(null),[c,l]=R(!0);return yi(()=>{let e=s.current?.parentElement;if(!e)return;let t=()=>l(window.innerWidth-e.getBoundingClientRect().width>=gf);return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)}),z(()=>{let t=setTimeout(()=>o(!0),e.delayMs);return()=>clearTimeout(t)},[e.delayMs]),z(()=>{if(!a||e.autoDismissMs<=0)return;let t=setTimeout(i,e.autoDismissMs);return()=>clearTimeout(t)},[a,e.autoDismissMs,i]),a?/* @__PURE__ */ U(`div`,{ref:s,class:`${lf}-callout`,role:`status`,"data-shape":e.shape,"data-position":_f(e.position,t,c),"data-animated":e.animated?`true`:void 0,"data-testid":Y.callout,children:[/* @__PURE__ */ U(`span`,{children:Pt(n,e.text)}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${lf}-callout-close`,onClick:i,"aria-label":r,title:r,"data-testid":Y.calloutDismiss,children:/* @__PURE__ */ U(id,{})})]}):null}const gf=200;function _f(e,t,n=!0){let r=t.endsWith(`-right`),i=t.startsWith(`bottom-`);return e===`vertical`||e===`auto`&&!n?i?`top`:`bottom`:r?`left`:`right`}function vf(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(),o=a instanceof ShadowRoot?a.activeElement:null;t.shiftKey&&o===r?(t.preventDefault(),i.focus()):!t.shiftKey&&o===i&&(t.preventDefault(),r.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)}const yf=i.cssPrefix;function bf({title:e,actions:t}){return/* @__PURE__ */ U(`header`,{class:`${yf}-back-header`,part:`header`,"data-variant":`title`,children:[/* @__PURE__ */ U(`span`,{class:`${yf}-back-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ U(`h1`,{class:`${yf}-back-title`,children:e}),t??/* @__PURE__ */ U(`span`,{class:`${yf}-back-spacer`,"aria-hidden":`true`})]})}function xf({title:e,backLabel:t,onBack:n,actions:r,testid:i}){return/* @__PURE__ */ U(`header`,{class:`${yf}-back-header`,part:`header`,"data-testid":i,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${yf}-icon-btn`,onClick:n,"aria-label":t,title:t,children:/* @__PURE__ */ U(Dd,{})}),/* @__PURE__ */ U(`h1`,{class:`${yf}-back-title`,children:e}),r??/* @__PURE__ */ U(`span`,{class:`${yf}-back-spacer`,"aria-hidden":`true`})]})}function Sf({textSig:e,doneSig:t,generativeUi:n=!1,strings:r=Ot,onCardAction:a}){let o=B(null),s=B(null);return yi(()=>{let c=o.current;if(!c)return;c.classList.add(`${i.cssPrefix}-md`);let l=s.current,u={generativeUi:n,strings:r,onCardAction:a},d=()=>{s.current?.renderer?.dispose();let o=document.createElement(`div`),l=n?kc(o,{cssPrefix:i.cssPrefix,strings:r,onAction:a}):void 0,d=$a(Df(Mf(l??po(o)))),f=e.value,p=f.length-Tf(f);if(!t.value)for(;p>0&&f[p-1]===`_`;)p--;let m=Ef(f.slice(0,p));return m&&fo(d,m),t.value&&(eo(d),l?.finish()),c.replaceChildren(o),{settings:u,container:o,parser:d,renderer:l,lastLen:p,lastText:f.slice(0,p)}},f=l&&l.settings.generativeUi===n&&l.settings.strings===r&&l.settings.onCardAction===a&&e.value.startsWith(l.lastText)?l:d();s.current=f;let p=ea(()=>{let n=e.value,r=t.value;if(n.length<f.lastLen){f=d(),s.current=f;return}let i=Math.max(n.length-Tf(n),f.lastLen);if(!r)for(;i>f.lastLen&&n[i-1]===`_`;)i--;let a=Math.max(f.lastLen-1,0),o=Ef(n.slice(a,i)).slice(f.lastLen-a);o&&fo(f.parser,o),f.lastLen=i,f.lastText=n.slice(0,i),r&&(eo(f.parser),f.renderer?.finish())}),m=new MutationObserver(()=>Nf(c));m.observe(c,{childList:!0,subtree:!0}),Nf(c);function h(e){let t=e.target instanceof Element?e.target.closest(`a`):null;if(!t||!(t instanceof HTMLAnchorElement))return;let n=t.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`))}return c.addEventListener(`click`,h),()=>{p(),m.disconnect(),c.removeEventListener(`click`,h)}},[e,t,n,r,a]),z(()=>()=>{s.current?.renderer?.dispose(),s.current=null},[]),/* @__PURE__ */ U(`div`,{ref:o})}function Cf({text:e}){return/* @__PURE__ */ U(Sf,{textSig:bi(()=>H(e),[e]),doneSig:bi(()=>H(!0),[])})}const wf=/([\p{L}\p{N}])(_+)(?=[\p{L}\p{N}])/gu;function Tf(e){if((e.match(/^[ \t]*`{3,}/gm)?.length??0)%2==0)return 0;let t=e.trimEnd(),n=t.lastIndexOf(`
68
- `)+1;return/^[ \t]*`{3,}[^`]*$/.test(t.slice(n))?e.length-n:0}function Ef(e){return e.replace(wf,(e,t,n)=>t+``.repeat(n.length))}function Df(e){return{...e,add_text:(t,n)=>e.add_text(t,n.replaceAll(``,`_`)),set_attr:(t,n,r)=>e.set_attr(t,n,r.replaceAll(``,`_`))}}const Of=/<(\/?)(?:(Note|Info|Tip|Warning|Danger|Check|Callout)|Tabs?|Steps?|AccordionGroup|Accordion|Expandable|Columns|CardGroup|Card|Frame|CodeGroup|Badge|Icon|Video|Embed|ParamField|ResponseField)\b((?:"[^"]*"|'[^']*'|[^>"'])*?)(\/?)>|(^|\n)([ \t]*)(```[^]*?(?:\n[ \t]*```|$))?/g;function kf(e){let t=0,n=``;return e.replace(Of,(e,r,i,a,o,s,c,l)=>{if(r===void 0)return t?s+(l?.split(`\n${c}`).join(`
69
- `)??n):e;if(r)return t--,i&&(n=n.slice(2)),i?`\n${n}`:``;o||(t++,i&&(n+=`> `));let u={};a.replace(/(\w+)=(["'])(.*?)\2/g,(e,t,n,r)=>u[t]=r);let d=u.href??u.src,f=u.title??u.path??u.query??u.body??u.header??u.name??d;return(i?`> `:``)+(f?`**${d?`[${f}](${d})`:f}**${u.type?` \`${u.type}\``:``}\n${n}`:``)})}const Af=/* @__PURE__ */ new Set([`http:`,`https:`,`mailto:`,`tel:`]),jf=/* @__PURE__ */ new Set([`http:`,`https:`]);function Mf(e){let t=document.createElement(`a`);return{...e,set_attr:(n,r,i)=>{if(r!==1&&r!==2||(t.href=i,(r===1?Af:jf).has(t.protocol)))return e.set_attr(n,r,i);let a=r===2?n.nodes[n.index]:void 0;a?.replaceWith(...a.childNodes)}}}function Nf(e){for(let t of e.querySelectorAll(`a`)){let e=t.getAttribute(`href`)??``;e&&!e.startsWith(`#`)&&(t.target=`_blank`,t.rel=`noopener noreferrer`)}}const Pf=/* @__PURE__ */ new Set([11,12,13,14,15,16,17,18,19,31]);function Ff(e){let t=``,n=[],r=$a({data:void 0,add_token:(e,r)=>{n.push(r),Pf.has(r)||(t+=` `)},end_token:()=>{let e=n.pop();e!==void 0&&!Pf.has(e)&&(t+=` `)},add_text:(e,n)=>void(t+=n),set_attr:()=>void 0});return fo(r,Ef(e)),eo(r),t.replaceAll(``,`_`).replace(/\s+/g,` `).trim()}const If=i.cssPrefix;function Lf({tone:e=`info`,message:t,onRetry:n,strings:r}){return/* @__PURE__ */ U(`div`,{class:`${If}-module-empty`,role:e===`error`?`alert`:`status`,"aria-live":`polite`,children:[/* @__PURE__ */ U(`span`,{children:t}),n?/* @__PURE__ */ U(`button`,{type:`button`,class:`${If}-module-retry`,onClick:n,children:r.errorRetry}):null]})}const Rf=i.cssPrefix,zf=_.scope(`content`);function Bf({id:e,title:t,transport:n,strings:r,bus:i,onBack:a,actions:o}){let[s,c]=R(null),[l,u]=R(!1),[d,f]=R(!1),[p,m]=R(0),[h,g]=R(null),_=V(()=>{f(!1),c(null),m(e=>e+1)},[]);z(()=>{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||(zf.warn(`listContent (reader) failed`,{err:e}),f(!0))}),()=>{t=!0}},[n,e,p,i]),z(()=>{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 instanceof HTMLElement?t.target.closest(`a`):null)?.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(Lf,{tone:`error`,message:r.errorGeneric,onRetry:_,strings:r}):s===null?/* @__PURE__ */ U(Lf,{message:r.contentLoading,strings:r}):/* @__PURE__ */ U(`article`,{class:`${Rf}-content`,"data-testid":Y.contentView,onClick:v,children:[s.image?/* @__PURE__ */ U(`img`,{class:`${Rf}-content-hero`,src:s.image,alt:``,loading:`lazy`}):null,s.description?/* @__PURE__ */ U(`p`,{class:`${Rf}-content-subtitle`,children:s.description}):null,/* @__PURE__ */ U(Cf,{text:kf(s.content??``)}),l?/* @__PURE__ */ U(`div`,{class:`${Rf}-content-vote`,"aria-live":`polite`,children:h===e?r.feedbackThanks:/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`span`,{children:r.contentHelpful}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Rf}-module-retry`,onClick:()=>y(1),children:r.confirmYes}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Rf}-module-retry`,onClick:()=>y(0),children:r.confirmNo})]})}):null]})}return/* @__PURE__ */ U(`div`,{class:`${Rf}-module`,children:[/* @__PURE__ */ U(xf,{title:s?.title||t||r.moduleBack,backLabel:r.moduleBack,onBack:a,actions:o,testid:Y.backHeader}),/* @__PURE__ */ U(`div`,{class:`${Rf}-module-scroll`,"data-testid":Y.contentScroll,children:b()})]})}function Vf({itemCount:e,initialFocusIndex:t}){let[n,r]=R(!1),i=B(null),a=B(null),[o,s]=R(-1),c=V(()=>{r(!1),s(-1),i.current?.focus()},[]),l=V(()=>r(e=>!e),[]);return z(()=>{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]),z(()=>{if(!n||e===0)return;let r=t?.()??0;s(r<0||r>=e?0:r)},[n,e,t]),z(()=>{!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(),t.stopPropagation(),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 Hf({items:e,triggerLabel:t}){let n=i.cssPrefix,r=Vf({itemCount:e.length});function a(e){e.disabled||(e.onSelect?.(),e.keepOpen||r.close())}function o(e,t){return e.onSelectValue?.(t)}function s(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;let a=n[i];a&&(e.preventDefault(),e.stopPropagation(),o(t,a.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(bd,{})}),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=>s(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":`${Y.langSegment}-${t.value}`,onClick:()=>o(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:()=>a(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(wd,{})}):null]},e.id))}):null]})}const Uf=i.cssPrefix;function Wf(e){let t=typeof matchMedia!=`function`||matchMedia(`(prefers-color-scheme: dark)`).matches;return e===`auto`?t?`light`:`dark`:t?e===`light`?`dark`:`auto`:e===`dark`?`light`:`auto`}const Gf={normal:`large`,large:`small`,small:`normal`};function Kf(e){return U(e===`light`?Wd:e===`dark`?Gd:Kd,{})}function qf(e,t){let n=e.split(`-`)[0];return(t.some(t=>t!==e&&t.split(`-`)[0]===n)?e:n??e).toUpperCase()}function Jf(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 Yf({panelProps:e,variant:t,onEmailTranscript:n,onLogIn:r}){let{options:i,panelSize:a,feedback:o,onClose:s,onClear:c,onExpand:l,onFullscreen:u,onSoundToggle:d}=e,{onToggleHistory:f,onLocaleChange:p,onThemeChange:m,onTextSizeChange:h}=e,g=i.strings,_=i.mode,v=t===`chat`,y=da(()=>o.mutedSig.value).value,b=new Set(i.actions);function x(e){return b.has(e)}let S=typeof matchMedia==`function`&&matchMedia(`(max-width: 640px)`).matches;function C(e){return!S&&Vu(e,_,a)}let w=i.themeMode,ee={auto:g.themeAuto,light:g.themeLight,dark:g.themeDark},T=i.textSize,E={small:g.textSizeSmall,normal:g.textSizeNormal,large:g.textSizeLarge},D=[];if(v&&x(`clear`)&&D.push({id:`clear`,icon:/* @__PURE__ */ U(Od,{}),label:g.newConversation,onSelect:c}),v&&n&&D.push({id:`emailTranscript`,icon:/* @__PURE__ */ U(kd,{}),label:g.emailTranscript,onSelect:n}),v&&r&&D.push({id:`logIn`,icon:/* @__PURE__ */ U(pd,{}),label:g.loginAction,onSelect:r}),x(`expand`)&&C(`expand`)){let e=a===`expanded`;D.push({id:`expand`,icon:U(e?hd:md,{}),label:e?g.collapse:g.expand,type:`switch`,on:e,onSelect:l})}if(x(`fullscreen`)&&C(`fullscreen`)){let e=a===`fullscreen`;D.push({id:`fullscreen`,icon:U(e?_d:gd,{}),label:e?g.exitFullscreen:g.fullscreen,type:`switch`,on:e,onSelect:u})}let O=i.popOutUrl,te=i.aiAgentDeploymentId;x(`popOut`)&&O&&te&&Vu(`popOut`,_,a)&&D.push({id:`popOut`,icon:/* @__PURE__ */ U(vd,{}),label:g.popOut,onSelect:()=>{let t=Jf(O,{conversationId:e.conversationId,widgetId:i.widgetId,publicKey:i.publicKey,aiAgentDeploymentId:te});t&&window.open(t,`_blank`,`noopener,noreferrer`)}}),v&&x(`sound`)&&D.push({id:`sound`,icon:U(y?Sd:xd,{}),label:y?g.soundOff:g.soundOn,type:`switch`,on:!y,onSelect:d}),x(`theme`)&&w!==`host`&&D.push({id:`theme`,icon:Kf(w),label:`${g.theme}: ${ee[w]}`,onSelect:()=>m(Wf(w)),keepOpen:!0}),x(`textSize`)&&D.push({id:`textSize`,icon:/* @__PURE__ */ U(Cd,{}),label:`${g.textSize}: ${E[T]}`,onSelect:()=>h(Gf[T]),keepOpen:!0}),x(`language`)&&i.availableLocales.length>1&&D.push({id:`language`,icon:/* @__PURE__ */ U(Ed,{}),label:g.language,segments:i.availableLocales.map(e=>({value:e,label:qf(e,i.availableLocales),lang:e})),value:i.locale,onSelectValue:p});let k=!!s&&Hu(_,a,i.actions),ne=v&&x(`history`);return/* @__PURE__ */ U(`div`,{class:`${Uf}-header-actions`,children:[ne?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Uf}-icon-btn`,onClick:f,"aria-label":g.history,title:g.history,"data-testid":Y.actionHistory,children:/* @__PURE__ */ U(Td,{})}):null,D.length>0?/* @__PURE__ */ U(Hf,{items:D,triggerLabel:g.moreActions}):null,k?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Uf}-icon-btn`,onClick:s,"aria-label":g.close,title:g.close,"data-testid":Y.actionClose,children:/* @__PURE__ */ U(id,{})}):null]})}const Xf={Icon:Ud};function Zf(e,t){return e instanceof tu?e.status===429?e.retryAfterSeconds?t.errorRateLimitedIn.replace(`{seconds}`,String(e.retryAfterSeconds)):t.errorRateLimited:e.code===`network`?t.errorOffline:e.status===403?t.errorOriginNotAllowed:e.errorCode===`MESSAGE_TOO_LONG`?t.errorMessageTooLong:e.status!==void 0&&e.status>=500?t.errorServer:t.errorGeneric:t.errorGeneric}const Qf=i.cssPrefix;function $f({placeholder:e,onActivate:t}){return/* @__PURE__ */ U(`button`,{type:`button`,class:`${Qf}-home-search`,onClick:t,"data-testid":Y.homeSearch,children:[/* @__PURE__ */ U(`span`,{class:`${Qf}-home-search-text`,children:e}),/* @__PURE__ */ U(`span`,{class:`${Qf}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(zd,{})})]})}function ep({placeholder:e,value:t,onInput:n}){return/* @__PURE__ */ U(`div`,{class:`${Qf}-home-search`,"data-input":`true`,children:[/* @__PURE__ */ U(`input`,{type:`search`,class:`${Qf}-home-search-input`,placeholder:e,value:t,maxLength:200,onInput:e=>n(e.currentTarget.value),"data-testid":Y.helpSearch}),/* @__PURE__ */ U(`span`,{class:`${Qf}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(zd,{})})]})}const tp=i.cssPrefix;function np({title:e,subtitle:t,onClick:n,testid:r}){return/* @__PURE__ */ U(`button`,{type:`button`,class:`${tp}-list-row`,onClick:n,"data-testid":r,children:[/* @__PURE__ */ U(`span`,{class:`${tp}-list-row-body`,children:[/* @__PURE__ */ U(`span`,{class:`${tp}-list-row-title`,children:e}),t?/* @__PURE__ */ U(`span`,{class:`${tp}-list-row-sub`,children:t}):null]}),/* @__PURE__ */ U(`span`,{class:`${tp}-list-row-chevron`,"aria-hidden":`true`,children:/* @__PURE__ */ U(ld,{})})]})}const rp=i.cssPrefix,ip=_.scope(`help`);function ap(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 op({transport:e,strings:t,bus:n},r,i){let[a,o]=R(),s=B(void 0),c=r?.join(`,`);function l(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&&(ip.warn(`listContent (help) failed`,{err:e,page:a}),o(n=>n&&{...n,loading:!1,error:Zf(e,t)}))})}return z(()=>{if(!r?.length)o(void 0);else return l(1),()=>{s.current=void 0}},[e,c,i]),[a,()=>!a?.loading&&l((a?.pagination?.page??0)+1)]}function sp(e){let{strings:t,config:n,nav:r,panelProps:i}=e,a=n.contentCollectionIds,[o,s]=R(``),[c,l]=R(``),u=op(e,a),d=op(e,c?a:void 0,c),[f,p]=o.trim()?d:u;z(()=>{let e=setTimeout(()=>l(o.trim()),300);return()=>clearTimeout(e)},[o]);function m(){if(!a?.length)return/* @__PURE__ */ U(Lf,{message:t.helpEmpty,strings:t});let e=f?.error?/* @__PURE__ */ U(Lf,{tone:`error`,message:f.error,onRetry:p,strings:t}):null;return e&&!f?.pagination?e:!f||!f.pagination&&!f.items.length?/* @__PURE__ */ U(Lf,{message:t.helpLoading,strings:t}):f.items.length?/* @__PURE__ */ U(L,{children:[ap(f.items,a,f.collections).map(e=>/* @__PURE__ */ U(`section`,{class:`${rp}-help-group`,children:[e.title?/* @__PURE__ */ U(`h2`,{class:`${rp}-help-section-title`,children:e.title}):null,/* @__PURE__ */ U(`div`,{class:`${rp}-help-card`,children:e.rows.map(e=>/* @__PURE__ */ U(np,{title:e.title,subtitle:e.description,onClick:()=>e.url?Zu(e.url):r.push({kind:`content`,id:e.id,title:e.title}),testid:cf(Y.helpArticle,e.id)},e.id))})]},e.id)),e,f.pagination?.hasNext&&!e?/* @__PURE__ */ U(`div`,{children:/* @__PURE__ */ U(`div`,{class:`${rp}-help-card`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${rp}-list-row ${rp}-help-more`,onClick:p,"aria-busy":f.loading,children:[f.loading?/* @__PURE__ */ U(`span`,{class:`${rp}-loading-spinner`,"aria-hidden":`true`}):null,t.helpShowMore]})})}):null]}):/* @__PURE__ */ U(Lf,{message:f.search?t.helpSearchEmpty.replace(`{query}`,f.search):t.helpEmpty,strings:t})}return/* @__PURE__ */ U(`div`,{class:`${rp}-module`,children:[/* @__PURE__ */ U(bf,{title:t.helpTitle,actions:/* @__PURE__ */ U(Yf,{panelProps:i,variant:`plain`})}),/* @__PURE__ */ U(`div`,{class:`${rp}-module-pad`,children:/* @__PURE__ */ U(ep,{placeholder:t.helpSearchPlaceholder,value:o,onInput:s})}),/* @__PURE__ */ U(`div`,{class:`${rp}-help-list`,children:m()})]})}const cp={Icon:Pd,Root:e=>/* @__PURE__ */ U(sp,{...e})},lp=_.scope(`attachments`);function up(e,t,n){let r=hp(e),i=[],a=[],o=bp(n.accept),s=t.reduce((e,t)=>e+t.size,0),c=t.length;for(let e of r){let t=mp(e,c,s,n,o);t?a.push({file:e,reason:t}):(i.push(yp(e)),s+=e.size,c+=1)}return(i.length||a.length)&&lp.debug(`ingest`,{accepted:i.length,rejected:a.map(e=>({name:e.file.name,reason:e.reason}))}),{accepted:i,rejected:a}}function dp(e){let t=Math.min(Math.floor(Math.log10(Math.max(e,1))/3),2);return new Intl.NumberFormat(void 0,{style:`unit`,unit:[`byte`,`kilobyte`,`megabyte`][t],unitDisplay:`narrow`,maximumFractionDigits:1}).format(e/1e3**t)}function fp(e,t){let n=bp(t);return!e||n.length===0||n.some(t=>t.kind===`ext`||xp(new File([],``,{type:e}),[t]))}function pp(e){try{URL.revokeObjectURL(e.previewUrl)}catch(e){lp.debug(`revokeObjectURL failed`,{error:e})}}function mp(e,t,n,r,i){return t>=r.maxCount?`count`:n+e.size>r.maxBytes?`bytes`:xp(e,i)?null:`mime`}function hp(e){return e?Array.isArray(e)?e.filter(e=>e instanceof File):[...e].map(e=>e instanceof File?e:gp(e)).filter(e=>e!==null):[]}function gp(e){let t=_p(e)?e:null;return!t?.getAsFile||t.kind!==`file`?null:t.getAsFile()}function _p(e){return vp(e)&&(e.getAsFile===void 0||typeof e.getAsFile==`function`)}function vp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yp(e){return{file:e,id:wr(),mediaType:e.type||`application/octet-stream`,name:e.name||`pasted-file`,previewUrl:URL.createObjectURL(e),size:e.size}}function bp(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 xp(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 Sp=i.cssPrefix,Cp={error:of,done:wd};function wp({attachment:e,upload:t,strings:n,onRemove:r,disabled:i=!1}){let a=/^image\/(jpeg|png|gif|webp|avif|bmp|x-ms-bmp|svg\+xml)$/i.test(e.mediaType),o=Math.round((t?.fraction??0)*100),s=dp(e.size),c=t?.status===`error`||t?.status===`done`?Cp[t.status]:void 0;return/* @__PURE__ */ U(`span`,{class:`${Sp}-attachment-chip`,"data-upload":t?.status,title:e.name,"data-testid":cf(Y.attachmentChip,e.id),children:[a?/* @__PURE__ */ U(`img`,{class:`${Sp}-attachment-thumb`,src:e.previewUrl,alt:``}):/* @__PURE__ */ U(`span`,{class:`${Sp}-attachment-thumb`,"aria-hidden":`true`,children:/* @__PURE__ */ U(jd,{})}),/* @__PURE__ */ U(`span`,{class:`${Sp}-attachment-text`,children:[/* @__PURE__ */ U(`span`,{class:`${Sp}-attachment-name`,children:e.name}),/* @__PURE__ */ U(`span`,{class:`${Sp}-attachment-meta`,children:[c?/* @__PURE__ */ U(c,{}):null,t?.status===`uploading`?`${o}% · ${s}`:s]})]}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Sp}-attachment-remove`,onClick:r,disabled:i,"aria-label":n.removeAttachment.replace(`{name}`,e.name),"data-testid":cf(Y.attachmentRemove,e.id),children:/* @__PURE__ */ U(id,{})}),t?.status===`uploading`?/* @__PURE__ */ U(`span`,{class:`${Sp}-attachment-progress`,role:`progressbar`,"aria-label":e.name,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":o,children:/* @__PURE__ */ U(`span`,{style:{width:`${o}%`}})}):null]})}const Tp=/* @__PURE__ */ new WeakMap;function Ep(e){e.currentTarget&&Tp.set(e.currentTarget,e.timeStamp)}function Dp(e){let t=e.currentTarget?Tp.get(e.currentTarget):void 0;return e.isComposing||t!==void 0&&e.timeStamp-t<100}const Op=i.cssPrefix;function kp({text:e,retryLabel:t,onRetry:n,retryTestId:r}){return/* @__PURE__ */ U(`div`,{class:`${Op}-error`,role:`alert`,children:[/* @__PURE__ */ U(`span`,{class:`${Op}-error-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(of,{})}),/* @__PURE__ */ U(`span`,{class:`${Op}-error-text`,children:e}),n&&t?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Op}-error-retry`,onClick:n,"data-testid":r,children:t}):null]})}const Ap={isSupported:!1,start:()=>void 0,stop:()=>void 0,cancel:()=>void 0};function jp(e,t,n){return e===`disabled`?Ap:e===`server`?Fp(n):Mp(t)}function Mp(e){let t=Np();if(!t)return Ap;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(e){l||r!==s||n!==c||(l=!0,n=null,a(e))}c.addEventListener(`end`,()=>u(!1)),c.addEventListener(`error`,e=>u(`error`in e&&(e.error===`not-allowed`||e.error===`service-not-allowed`)));try{c.start()}catch{u(!1)}},stop(){n?.stop()},cancel(){r++;let e=n;n=null,e?.abort()}}}function Np(){return window.SpeechRecognition??window.webkitSpeechRecognition}const Pp=[`audio/webm;codecs=opus`,`audio/webm`,`audio/ogg;codecs=opus`,`audio/mp4`];function Fp(e){if(typeof MediaRecorder>`u`||!navigator?.mediaDevices?.getUserMedia)return Ap;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(!1))}}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=Ip(),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(e){r(s),n===s&&t===s.generation&&(n=null,o(e instanceof DOMException&&e.name===`NotAllowedError`))}},stop(){let e=n;e&&(e.recorder?e.recorder.state!==`inactive`&&e.recorder.stop():i())},cancel(){i()}}}function Ip(){for(let e of Pp)if(MediaRecorder.isTypeSupported(e))return e}function Lp(e,{file:t,reason:n},r){return n===`count`?e.attachmentTooMany.replace(`{count}`,String(r.maxCount)):n===`bytes`?e.attachmentTooLarge.replace(`{name}`,t.name).replace(`{max}`,dp(r.maxBytes)):e.attachmentMimeRejected.replace(`{name}`,t.name)}const Rp=i.cssPrefix,zp=_.scope(`composer`);function Bp(e){return e.reduce((e,t)=>e+t.size,0)}const Vp={arrowUp:sd,paperPlane:od,send:cd,chevron:ld};function Hp(e){return`activeElement`in e}function Up(e){return`host`in e&&`activeElement`in e}function Wp(e){return`clipboardData`in e}function Gp({options:e,transport:t,feedback:n,bus:r,persistence:i,conversationId:a,maxMessageCharacters:o,isStreaming:s,pageToolRunning:c=!1,isMemoryCompacting:l=!1,canReleaseQueuedMessages:u=!0,queueManualMessages:d=!1,replyAwaitsCard:f=!1,active:p=!0,isPreparing:m=!1,attachmentUploadsSig:h,operatorRequestEnabled:g,canRequestOperator:_=!1,controlMode:v=`ai-agent`,onRequestOperator:y,onSend:b,onStop:x,apiRef:S}){let C=e.strings,[w,ee]=R(()=>i.loadDraft(a)),[T,E]=R([]),[D,O]=R(),[te,k]=R(()=>i.loadMessageQueue(a).map(e=>({id:e.id,text:e.text,attachments:[]}))),ne=B(te),re=B(!1),ie=B(void 0),[A,ae]=R(!1),[j,oe]=R(!1),[se,ce]=R(!1),[le,ue]=R(!1),M=B(!1),de=B(null),fe=B(null),pe=B(null),me=B(0),he=B(a);he.current=a;let ge=B(p);ge.current=p;let N=B(m);N.current=m;let _e=le||m||!p,ve=s&&v===`ai-agent`,ye=ve||l&&v===`ai-agent`,be=v===`ai-agent`&&(ye||d||te.length>0),xe=V(e=>{k(t=>{let n=e(t);return i.saveMessageQueue(he.current,n.filter(e=>e.attachments.length===0).map(({id:e,text:t})=>({id:e,text:t}))),ne.current=n,n})},[i]),Se=V(e=>{xe(t=>(t.find(t=>t.id===e)?.attachments.forEach(pp),t.filter(t=>t.id!==e)))},[xe]),Ce=V(e=>{ee(t=>{let n=(typeof e==`function`?e(t):e).slice(0,o);return n===t?t:(i.saveDraft(he.current,n),n)})},[i,o]),we=e.features.fileUpload,Te=e.features.voice,[P,Ee]=R(()=>jp(Te,e.locale,(e,n)=>t.transcribe(e,n))),De=B(P);De.current=P;let Oe=B({mode:Te,locale:e.locale,transport:t});z(()=>{let n=Oe.current;(n.mode!==Te||n.locale!==e.locale||n.transport!==t)&&(Oe.current={mode:Te,locale:e.locale,transport:t},me.current++,De.current.cancel(),pe.current=null,oe(!1),Ee(jp(Te,e.locale,(e,n)=>t.transcribe(e,n))))},[e.locale,Te,t]),yi(()=>()=>{me.current++,P.cancel()},[P]);let ke=V(e=>{let t=pe.current;if(t===null)return!1;let n=Math.round(performance.now()-t);return zp[e](`voiceStop`,{durationMs:n}),r.emit(`voiceStop`,{durationMs:n}),pe.current=null,!0},[r]),Ae=V(()=>{pe.current!==null&&(P.stop(),oe(!1),ke(`info`)&&n.play(`voiceStop`))},[ke,n,P]),je=V(()=>{me.current++,P.cancel(),oe(!1),ke(`info`)&&n.play(`voiceStop`)},[ke,n,P]);z(()=>{(m||!p)&&je()},[p,je,m]),z(()=>{let e=de.current;if(!e)return;let t=e.getRootNode(),n=Hp(t)?t.activeElement:null;n&&e.closest(`.${Rp}-panel`)?.contains(n)||e.focus({preventScroll:!0})},[]),z(()=>{let e=de.current;if(!e)return;if(w.length===0){e.style.height=``;return}e.style.height=`auto`;let t=getComputedStyle(e),n=Number.parseFloat(t.getPropertyValue(`--${Rp}-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`},[w]);let Me=B(T);Me.current=T,z(()=>()=>{Me.current.forEach(pp);for(let e of ne.current)e.attachments.forEach(pp)},[]),yi(()=>{if(S)return S.current={attachFromDrop:t=>{if(!we||!ge.current||M.current||N.current)return;let n=up(t,Me.current,e.attachments);O(n.rejected[0]),n.accepted.length!==0&&(zp.info(`attach (drop)`,{count:n.accepted.length,totalBytes:Bp(n.accepted)}),r.emit(`attach`,{count:n.accepted.length,totalBytes:Bp(n.accepted)}),E(e=>[...e,...n.accepted]))},fill:e=>{if(!ge.current||M.current||N.current)return;Ce(e);let t=de.current;t&&(t.focus({preventScroll:!0}),requestAnimationFrame(()=>t.setSelectionRange(t.value.length,t.value.length)))},acceptQueuedMessage:Se},()=>{S.current&&(S.current=null)}},[S,we,m,e.attachments,Se,Ce]),z(()=>{let t=de.current;if(!t)return;let n=t.closest(`.${Rp}-panel`);if(!n)return;let i=n=>{if(!ge.current||M.current||N.current)return;let i=n.clipboardData;if(!i)return;let a=n.target instanceof HTMLElement?n.target.closest(`input, textarea, [contenteditable]:not([contenteditable='false'])`):null;if(a&&a!==t)return;if(we){let t=up(i.items,Me.current,e.attachments);if(O(t.rejected[0]),t.accepted.length>0){n.preventDefault(),zp.info(`attach (paste)`,{count:t.accepted.length,totalBytes:Bp(t.accepted)}),r.emit(`attach`,{count:t.accepted.length,totalBytes:Bp(t.accepted)}),E(e=>[...e,...t.accepted]);return}}if(a===t)return;let o=i.getData(`text/plain`);o&&(n.preventDefault(),Ce(e=>e+o),t.focus())};function a(e){Wp(e)&&i(e)}return n.addEventListener(`paste`,a),()=>n.removeEventListener(`paste`,a)},[we,e.attachments,Ce]);async function Ne(){let e=w.trim();if(!e&&T.length===0||!p||ve||M.current||m)return;je(),M.current=!0,ue(!0);let t=w,n=T;try{await b(e,n)&&(O(void 0),Ce(e=>e===t?``:e),E(e=>e===n?(n.forEach(pp),Me.current=[],[]):e))}finally{M.current=!1,ue(!1),requestAnimationFrame(()=>{let e=de.current;if(!e||e.disabled||!ge.current)return;let t=e.getRootNode(),n=Hp(t)?t.activeElement:null,r=n?.getAttribute(`data-testid`);if(!(n&&n!==e&&r!==Y.composerSend&&r!==Y.composerStop)){if(Up(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 F(){let e=w.trim();if(!e&&T.length===0||!p||!be||M.current||m)return;je();let t=T;xe(n=>[...n,{id:wr(),text:e,attachments:t}]),ye||ae(!0),Ce(``),E(e=>e===t?(Me.current=[],[]):e),de.current?.focus({preventScroll:!0})}z(()=>{ye&&(re.current=!1,ie.current=void 0,ae(!1))},[ye]),z(()=>{let t=te[0];if(!t||!u||ye||re.current||le||m||!p)return;let n=f&&!A?(ie.current??(ie.current=performance.now()+e.cardAnswerWaitSeconds*1e3))-performance.now():0,r=setTimeout(()=>{re.current=!0,b(t.text,t.attachments,t.id).then(e=>{e?Se(t.id):re.current=!1})},Math.max(n,300));return()=>clearTimeout(r)},[p,u,A,m,b,e.cardAnswerWaitSeconds,ye,te,Se,f,le]);function Pe(e){e.key!==`Enter`||e.shiftKey||Dp(e)||(e.preventDefault(),be&&(w.trim()||T.length>0)?F():ve?x():Ne())}function Fe(t){if(!(t.target instanceof HTMLInputElement))return;let n=t.target;if(!p||M.current||m){n.value=``;return}let i=up(n.files,T,e.attachments);O(i.rejected[0]),i.accepted.length>0&&(zp.info(`attach (file picker)`,{count:i.accepted.length,totalBytes:Bp(i.accepted)}),r.emit(`attach`,{count:i.accepted.length,totalBytes:Bp(i.accepted)}),E(e=>[...e,...i.accepted])),n.value=``}function Ie(e){!p||M.current||m||(zp.info(`removeAttachment`,{id:e}),r.emit(`removeAttachment`,{id:e}),O(void 0),E(t=>{let n=t.find(t=>t.id===e);return n&&pp(n),t.filter(t=>t.id!==e)}))}function Le(){if(j){Ae();return}if(!p||!P.isSupported||M.current||m)return;let e=++me.current;pe.current=performance.now(),zp.info(`voiceStart`),r.emit(`voiceStart`,void 0),ce(!1),oe(!0),n.play(`voiceStart`),P.start((t,n)=>{me.current===e&&ge.current&&!N.current&&!M.current&&n&&Ce(e=>`${e}${t} `)},t=>{me.current===e&&ge.current&&(oe(!1),ce(t),ke(`debug`))})}let Re=Vp[e.composer.sendButton.icon],ze=!!(w.trim()||T.length>0),Be=h?.value,Ve=T.some(e=>Be?.get(e.id)?.status===`uploading`),He=T.filter(e=>Be?.get(e.id)?.status===`error`),Ue=He.find(e=>Be?.get(e.id)?.refusal),We=Ue&&(Be?.get(Ue.id)?.refusal===`INVALID_FILE_TYPE`?C.attachmentMimeRejected:C.attachmentUploadFailed).replace(`{name}`,Ue.name),Ge=ve||Ve||c&&!ze;return/* @__PURE__ */ U(`div`,{class:`${Rp}-composer`,part:`composer`,"data-testid":Y.composer,children:[te.length>0?/* @__PURE__ */ U(`div`,{class:`${Rp}-message-queue`,"aria-label":C.queueMessage,"data-testid":Y.messageQueue,children:te.map(e=>/* @__PURE__ */ U(`div`,{class:`${Rp}-attachment-chip ${Rp}-queued-message`,"data-testid":`${Y.queuedMessage}-${e.id}`,children:[/* @__PURE__ */ U(`span`,{class:`${Rp}-attachment-name ${Rp}-queued-text`,children:e.text||e.attachments.map(e=>e.name).join(`, `)}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Rp}-attachment-remove`,onClick:()=>Se(e.id),"aria-label":C.removeQueuedMessage,title:C.removeQueuedMessage,"data-testid":`${Y.queuedMessageRemove}-${e.id}`,children:/* @__PURE__ */ U(id,{})})]},e.id))}):null,T.length>0?/* @__PURE__ */ U(`div`,{class:`${Rp}-attachments`,children:T.map(e=>/* @__PURE__ */ U(wp,{attachment:e,upload:Be?.get(e.id),strings:C,onRemove:()=>Ie(e.id),disabled:_e},e.id))}):null,He.length>0&&!_e?/* @__PURE__ */ U(kp,{text:We??C.attachmentUploadFailed.replace(`{name}`,He.map(e=>e.name).join(`, `)),retryLabel:C.errorRetry,onRetry:Ue?void 0:()=>void Ne(),retryTestId:Y.attachmentRetry}):null,D?/* @__PURE__ */ U(`p`,{class:`${Rp}-field-error`,role:`alert`,children:Lp(C,D,e.attachments)}):null,se?/* @__PURE__ */ U(`p`,{class:`${Rp}-field-error`,role:`alert`,children:C.micBlocked}):null,o!==void 0&&w.length>=o*.9?/* @__PURE__ */ U(`p`,{class:`${Rp}-field-${w.length<o?`hint`:`error`}`,"data-testid":Y.composerCount,children:`${w.length} / ${o}`}):null,/* @__PURE__ */ U(`div`,{class:`${Rp}-composer-row`,children:[/* @__PURE__ */ U(`div`,{class:`${Rp}-composer-actions`,children:[we?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Rp}-icon-btn`,onClick:()=>fe.current?.click(),disabled:_e,"aria-label":C.attach,title:C.attach,"data-testid":Y.composerAttach,children:/* @__PURE__ */ U(dd,{})}):null,P.isSupported?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Rp}-icon-btn`,onClick:Le,disabled:_e,"aria-label":j?C.micStop:C.micStart,title:j?C.micStop:C.micStart,"aria-pressed":j,"data-recording":j?`true`:void 0,"data-testid":Y.composerVoice,children:/* @__PURE__ */ U(fd,{})}):null,g&&v===`ai-agent`&&y?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Rp}-icon-btn`,onClick:y,disabled:_e||!_,"aria-label":C.talkToOperator,title:C.talkToOperator,"data-testid":Y.operatorRequest,children:/* @__PURE__ */ U(pd,{})}):null]}),/* @__PURE__ */ U(`textarea`,{ref:de,name:`message`,class:`${Rp}-textarea`,rows:1,value:w,maxLength:o,placeholder:C.composerPlaceholder,onInput:e=>Ce(e.currentTarget.value),onKeyDown:Pe,onCompositionEnd:Ep,disabled:_e,"aria-label":C.composerPlaceholder,"data-testid":Y.composerInput}),be&&ze?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Rp}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:F,disabled:_e,"aria-label":C.queueMessage,title:C.queueMessage,"data-testid":Y.composerSend,children:/* @__PURE__ */ U(Re,{})}):null,Ge?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Rp}-send`,onClick:x,disabled:_e&&!Ve,"aria-label":C.stop,"data-testid":Y.composerStop,children:/* @__PURE__ */ U(ud,{})}):null,!Ge&&(!be||!ze)?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Rp}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:()=>void Ne(),disabled:_e||!w.trim()&&T.length===0,"aria-label":C.send,"data-testid":Y.composerSend,children:/* @__PURE__ */ U(Re,{})}):null]}),/* @__PURE__ */ U(`input`,{ref:fe,name:`attachments`,type:`file`,multiple:!0,accept:e.attachments.accept,onChange:Fe,disabled:_e,class:`${Rp}-sr-only`,"data-testid":Y.composerFileInput})]})}const Kp=i.cssPrefix;function qp({onClick:e,children:t,testid:n}){return e?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Kp}-home-card`,"data-interactive":`true`,onClick:e,"data-testid":n,children:t}):/* @__PURE__ */ U(`div`,{class:`${Kp}-home-card`,"data-testid":n,children:t})}function Jp(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}const Yp=i.cssPrefix,Xp=_.scope(`news`);function Zp(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 Qp({options:e,transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}){let c=r.contentCollectionIds,l=c?.join(`,`),[u,d]=R({items:[],loading:!0}),f=B(void 0);function p(e){if(!c?.length)return;let r={};f.current=r,d(e=>({...e,loading:!0,error:void 0})),t.listContent({contentCollectionIds:c,sortBy:`publishedAt`,sortOrder:`desc`,page:e,limit:10}).then(t=>{if(f.current!==r||(d(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=>{f.current===r&&(Xp.warn(`listContent (news) failed`,{err:t,page:e}),d(e=>({...e,loading:!1,error:Zf(t,n)})))})}function m(){u.loading||p((u.pagination?.page??0)+1)}z(()=>(d({items:[],loading:!0}),p(1),()=>{f.current=void 0}),[t,l]);function h(t){let n=Zp(t.publishedAt,e.locale);return/* @__PURE__ */ U(`button`,{type:`button`,class:`${Yp}-news-card`,onClick:()=>i.push({kind:`content`,id:t.id,title:t.title}),"data-testid":cf(Y.newsItem,t.id),children:[t.image?/* @__PURE__ */ U(`img`,{class:`${Yp}-news-hero`,src:t.image,alt:``,loading:`lazy`}):null,/* @__PURE__ */ U(`span`,{class:`${Yp}-news-body`,children:[/* @__PURE__ */ U(`span`,{class:`${Yp}-news-title`,children:t.title}),n||t.tags?.length?/* @__PURE__ */ U(`span`,{class:`${Yp}-news-meta`,children:[n?/* @__PURE__ */ U(`time`,{dateTime:t.publishedAt,children:n}):null,t.tags?.map(e=>/* @__PURE__ */ U(`span`,{class:`${Yp}-news-tag`,children:e},e))]}):null,t.description?/* @__PURE__ */ U(`span`,{class:`${Yp}-news-summary`,children:t.description}):null]})]},t.id)}function g(){if(!c?.length)return/* @__PURE__ */ U(Lf,{message:n.newsEmpty,strings:n});let e=u.error?/* @__PURE__ */ U(Lf,{tone:`error`,message:u.error,onRetry:m,strings:n}):null;return e&&!u.pagination?e:u.pagination?u.items.length?/* @__PURE__ */ U(`div`,{class:`${Yp}-news-list`,children:[u.items.map(h),e,u.pagination.hasNext&&!e?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Yp}-news-more`,onClick:m,"aria-busy":u.loading,"data-testid":Y.newsMore,children:[u.loading?/* @__PURE__ */ U(`span`,{class:`${Yp}-loading-spinner`,"aria-hidden":`true`}):null,n.newsShowMore]}):null]}):/* @__PURE__ */ U(Lf,{message:n.newsEmpty,strings:n}):/* @__PURE__ */ U(Lf,{message:n.newsLoading,strings:n})}return/* @__PURE__ */ U(`div`,{class:`${Yp}-module`,children:[/* @__PURE__ */ U(bf,{title:n.newsTitle,actions:/* @__PURE__ */ U(Yf,{panelProps:o,variant:`plain`})}),/* @__PURE__ */ U(`div`,{class:`${Yp}-module-scroll`,children:g()})]})}const $p={Icon:Hd,Root:e=>/* @__PURE__ */ U(Qp,{...e})},X=i.cssPrefix,em=_.scope(`home`);function tm(e){let t=e.options.userContext?.name,n=e.config.greetingText?Pt(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 nm(e,t){return t.url?Zu(t.url):e.push({kind:`content`,id:t.id,title:t.title})}function rm({options:e,onAsk:t}){let[n,r]=R(``),{sendButton:i}=e.composer,a=Vp[i.icon];function o(e){e.preventDefault();let i=n.trim();i&&(r(``),t(i))}return/* @__PURE__ */ U(`form`,{class:`${X}-home-search ${X}-home-ask`,"data-input":`true`,onSubmit:o,"data-testid":Y.homeAsk,children:[/* @__PURE__ */ U(`input`,{type:`text`,class:`${X}-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:`${X}-send`,"data-shape":i.shape,"data-variant":i.variant,disabled:!n.trim(),"aria-label":e.strings.send,children:/* @__PURE__ */ U(a,{})})]})}function im(e,t){return vu(e,t,t.type!==`upsert`||t.activity===!0)}function am(e){let{transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}=e,[c,l]=R(null),[u,d]=R([]),f=r.contentCollectionIds?.join(`,`),p=e.options.modules.list.some(e=>e.layout===`chat`);z(()=>{if(r.showRecentConversations===!1)return;let e=!1,n=!0,i=[],a=t.subscribeConversationChanges(e=>{n&&i.push(e),l(t=>im(t?[t]:[],e)[0]??null)});return t.listConversations({limit:p?50:1}).then(t=>{if(e)return;let r=i.reduce(im,t.conversations);i=[],n=!1,l(r[0]??null)}).catch(t=>{e||(i=[],n=!1,em.warn(`listConversations (home) failed`,{err:t}))}),()=>{e=!0,a()}},[t,r.showRecentConversations,p]),z(()=>{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&&em.warn(`listContent (home) failed`,{err:t})),()=>{e=!0}},[t,f,a]);let m=tm(e),h=r.userAvatars??[],g=r.status,_=g?.text?Pt(n,g.text):n.homeStatus,v=g?.url,y=r.contentBlockTitle?Pt(n,r.contentBlockTitle):n.homeContentTitle,b=s.item,x=Zp(b?.publishedAt,e.options.locale);return/* @__PURE__ */ U(`div`,{class:`${X}-module ${X}-home`,"data-testid":Y.homeView,children:/* @__PURE__ */ U(`div`,{class:`${X}-home-scroll`,children:[/* @__PURE__ */ U(`div`,{class:`${X}-home-hero`,children:[/* @__PURE__ */ U(`div`,{class:`${X}-home-hero-top`,children:[r.brandName?/* @__PURE__ */ U(`span`,{class:`${X}-home-brand`,"data-testid":Y.homeBrand,children:r.brandName}):/* @__PURE__ */ U(`span`,{class:`${X}-home-brand-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ U(`div`,{class:`${X}-home-hero-actions`,children:[h.length>0?/* @__PURE__ */ U(`div`,{class:`${X}-home-avatars`,children:h.map(e=>/* @__PURE__ */ U(`span`,{class:`${X}-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:Jp(e.name)})},e.name))}):null,/* @__PURE__ */ U(Yf,{panelProps:o,variant:`plain`})]})]}),r.showGreeting===!1?null:/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`h1`,{class:`${X}-home-greeting`,"data-testid":Y.homeGreeting,children:m.title}),m.subtitle?/* @__PURE__ */ U(`p`,{class:`${X}-home-lead`,children:m.subtitle}):null]})]}),/* @__PURE__ */ U(`div`,{class:`${X}-home-cards`,children:[p?/* @__PURE__ */ U(rm,{options:e.options,onAsk:e=>i.startNewConversation(e)}):null,r.showSearchBar===!1?null:/* @__PURE__ */ U($f,{placeholder:n.homeSearchPlaceholder,onActivate:()=>i.switchToLayout(`help`)}),b?/* @__PURE__ */ U(qp,{onClick:()=>{s.markSeen(b.id),i.push({kind:`content`,id:b.id,title:b.title})},testid:Y.homeWhatsNew,children:/* @__PURE__ */ U(`div`,{class:`${X}-home-recent-row`,"data-unread":s.unseen?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Hd,{})}),/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-body`,children:[/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-title`,children:n.homeWhatsNew}),/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-preview`,children:x?`${b.title} · ${x}`:b.title})]}),s.unseen?/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-dot`,role:`img`,"aria-label":n.newsUnseen}):null]})}):null,c?/* @__PURE__ */ U(qp,{onClick:()=>i.selectConversation(c),testid:Y.homeRecent,children:/* @__PURE__ */ U(`div`,{class:`${X}-home-recent-row`,"data-unread":c.hasUnread?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Ud,{})}),/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-body`,children:[/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-title`,children:c.title}),c.preview?/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-preview`,children:Ff(c.preview)}):null]}),c.hasUnread?/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-dot`,role:`img`,"aria-label":n.unread}):null]})}):null,g?/* @__PURE__ */ U(qp,{onClick:v?()=>Zu(v):void 0,children:/* @__PURE__ */ U(`div`,{class:`${X}-home-status`,"data-level":g.level??`operational`,children:[/* @__PURE__ */ U(`span`,{class:`${X}-home-status-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Bd,{})}),/* @__PURE__ */ U(`span`,{class:`${X}-home-status-text`,children:_})]})}):null,u.length>0?/* @__PURE__ */ U(`section`,{class:`${X}-home-content`,children:[/* @__PURE__ */ U(`div`,{class:`${X}-home-content-title`,children:y}),/* @__PURE__ */ U(`div`,{class:`${X}-home-content-list`,children:u.map(e=>/* @__PURE__ */ U(np,{title:e.title,subtitle:e.description,onClick:()=>nm(i,e),testid:cf(Y.homeContentRow,e.id)},e.id))})]}):null]})]})})}const om={chat:Xf,home:{Icon:Vd,Root:e=>/* @__PURE__ */ U(am,{...e})},help:cp,news:$p},sm=i.cssPrefix;function cm({modules:e,activeTab:t,strings:n,hasUnread:r,onSelect:i}){return/* @__PURE__ */ U(`nav`,{class:`${sm}-tabbar`,role:`tablist`,"aria-label":n.panelTitle,children:e.map(e=>{let a=om[e.layout].Icon,o=e.id===t,s=e.layout===`chat`&&r;return/* @__PURE__ */ U(`button`,{type:`button`,role:`tab`,"aria-selected":o,class:`${sm}-tab`,onClick:()=>i(e.id),"data-testid":cf(Y.tab,e.id),children:[/* @__PURE__ */ U(`span`,{class:`${sm}-tab-icon`,children:[/* @__PURE__ */ U(a,{}),s?/* @__PURE__ */ U(`span`,{class:`${sm}-tab-badge`,"data-testid":Y.tabBadge,role:`img`,"aria-label":n.unread}):null]}),/* @__PURE__ */ U(`span`,{class:`${sm}-tab-label`,children:Pt(n,e.label)})]},e.id)})})}const lm=i.cssPrefix;function um({agent:e,strings:t,ticketReference:n,person:r=!1}){let i=e.status??`online`,a=Pt(t,e.name),o=e.title?Pt(t,e.title):null,s=r?/* @__PURE__ */ U(pd,{}):/* @__PURE__ */ U(`span`,{children:Jp(a)});return/* @__PURE__ */ U(`div`,{class:`${lm}-agent`,children:[/* @__PURE__ */ U(`div`,{class:`${lm}-agent-avatar`,"data-status":i,children:e.avatar?/* @__PURE__ */ U(`img`,{src:e.avatar,alt:``}):s}),/* @__PURE__ */ U(`div`,{class:`${lm}-agent-meta`,children:[/* @__PURE__ */ U(`strong`,{children:a}),o||n?/* @__PURE__ */ U(`div`,{class:`${lm}-agent-sub`,children:[n?/* @__PURE__ */ U(dm,{reference:n,strings:t}):null,o?/* @__PURE__ */ U(`span`,{children:o}):null]}):null]})]})}function dm({reference:e,strings:t}){let[n,r]=R(!1);function i(){navigator.clipboard?.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)}).catch(()=>{})}return/* @__PURE__ */ U(`button`,{type:`button`,class:`${lm}-agent-ticket`,onClick:i,title:t.copy,"aria-label":n?t.copied:t.copyTicketReference.replace(`{reference}`,e),children:n?t.copied:e})}const fm=[`today`,`yesterday`,`lastWeek`,`older`];function pm(e,t){let n=Date.parse(t);if(!Number.isFinite(n))return`older`;let r=Math.round((hm(e)-hm(n))/864e5);return r<=0?`today`:r===1?`yesterday`:r<7?`lastWeek`:`older`}function mm(e,t){let n=/* @__PURE__ */ new Map;for(let r of t){let t=pm(e,r.lastMessageAt),i=n.get(t);i?i.push(r):n.set(t,[r])}return fm.flatMap(e=>{let t=n.get(e);return t?[{bucket:e,conversations:t}]:[]})}function hm(e){return new Date(e).setHours(0,0,0,0)}const gm=_.scope(`history`),_m={today:`dateToday`,yesterday:`dateYesterday`,lastWeek:`dateLastWeek`,older:`dateOlder`};function vm(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=vu(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=vu(e.conversations,t,n);return r===e.conversations?e:{...t.type===`snapshot`?t.result:e,conversations:r}}function ym(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 bm({transport:e,strings:t,locale:n,persistence:r,onSelect:a,onNewConversation:o}){let s=i.cssPrefix,c=e.peekConversations({limit:50}),[l,u]=R(c?`loaded`:`loading`),[d,f]=R(0),[p,m]=R(c),[h,g]=R(!1),_=B(void 0),v=p?.conversations??[],y=p?.pagination;z(()=>{let n=!1,i=!0,a=[],o=e.subscribeConversationChanges(e=>{i&&a.push(e),m(t=>t&&vm(t,e))});_.current=void 0,g(!1);let s=e.peekConversations({limit:50});return m(s),u(s?`loaded`:`loading`),e.listConversations({limit:50}).then(e=>{if(n)return;let t=e;for(let e of a)t=vm(t,e);a=[],i=!1,m(t),u(`loaded`),r.saveHistoryCount(t.conversations.length)}).catch(e=>{n||(a=[],i=!1,gm.warn(`listConversations failed`,{err:e}),u({failure:Zf(e,t)}))}),()=>{n=!0,o(),_.current=void 0}},[e,r,n,d]);async function b(){if(_.current||!y?.hasNext)return;let t={};_.current=t,g(!0);try{let n=await e.listConversations({page:y.page+1,limit:y.limit});if(_.current!==t)return;m(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(_.current!==t)return;gm.warn(`listConversations page failed`,{err:e,page:y.page+1})}finally{_.current===t&&(_.current=void 0,g(!1))}}let x=o?/* @__PURE__ */ U(`div`,{class:`${s}-history-footer`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${s}-history-new`,onClick:o,"data-testid":Y.sidebarNewConversation,children:[/* @__PURE__ */ U(ad,{}),t.newConversation]})}):null;if(l===`loading`){let e=Math.min(r.loadHistoryCount()??3,6);return/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`div`,{class:`${s}-history`,"aria-busy":`true`,"aria-label":t.historyLoading,children:/* @__PURE__ */ U(`div`,{class:`${s}-history-group`,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`div`,{class:`${s}-history-heading`,children:/* @__PURE__ */ U(`span`,{class:`${s}-skeleton ${s}-skeleton-heading`})}),/* @__PURE__ */ U(`div`,{class:`${s}-history-card`,children:Array.from({length:Math.max(1,e)},(e,t)=>/* @__PURE__ */ U(`div`,{class:`${s}-history-item ${s}-history-item-skeleton`,children:[/* @__PURE__ */ U(`span`,{class:`${s}-history-avatar ${s}-skeleton`}),/* @__PURE__ */ U(`span`,{class:`${s}-history-body`,children:[/* @__PURE__ */ U(`span`,{class:`${s}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${s}-history-title`,children:/* @__PURE__ */ U(`span`,{class:`${s}-skeleton ${s}-skeleton-title`})}),/* @__PURE__ */ U(`span`,{class:`${s}-history-time`,children:/* @__PURE__ */ U(`span`,{class:`${s}-skeleton ${s}-skeleton-time`})})]}),/* @__PURE__ */ U(`span`,{class:`${s}-history-row`,children:/* @__PURE__ */ U(`span`,{class:`${s}-history-preview`,children:/* @__PURE__ */ U(`span`,{class:`${s}-skeleton ${s}-skeleton-preview`})})})]})]},t))})]})}),x]})}if(typeof l==`object`)return/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(Lf,{tone:`error`,message:l.failure,onRetry:()=>f(e=>e+1),strings:t}),x]});if(v.length===0)return/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`div`,{class:`${s}-history-empty`,children:t.historyEmpty}),x]});let S=Date.now(),C=mm(S,v);return/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`div`,{class:`${s}-history`,role:`list`,children:[C.map(e=>/* @__PURE__ */ U(`div`,{class:`${s}-history-group`,children:[/* @__PURE__ */ U(`div`,{class:`${s}-history-heading`,children:t[_m[e.bucket]]}),/* @__PURE__ */ U(`div`,{class:`${s}-history-card`,children:e.conversations.map(e=>/* @__PURE__ */ U(`div`,{role:`listitem`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${s}-history-item`,onClick:()=>a(e),"data-unread":e.hasUnread?`true`:void 0,"data-testid":cf(Y.historyItem,e.conversationId),children:[/* @__PURE__ */ U(`span`,{class:`${s}-history-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Nd,{})}),/* @__PURE__ */ U(`span`,{class:`${s}-history-body`,children:[/* @__PURE__ */ U(`span`,{class:`${s}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${s}-history-title`,children:e.title}),/* @__PURE__ */ U(`span`,{class:`${s}-history-time`,children:[e.ticketReference&&`${e.ticketReference} · `,ym(e.lastMessageAt,S,n)]})]}),/* @__PURE__ */ U(`span`,{class:`${s}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${s}-history-preview`,children:e.preview&&Ff(e.preview)||t.historyContinue}),e.hasUnread?/* @__PURE__ */ U(`span`,{class:`${s}-history-dot`,role:`img`,"aria-label":t.unread}):null]})]})]})},e.conversationId))})]},e.bucket)),y?.hasNext?/* @__PURE__ */ U(`div`,{class:`${s}-history-more`,children:/* @__PURE__ */ U(`button`,{type:`button`,onClick:b,disabled:h,"aria-busy":h,"data-testid":Y.historyLoadMore,children:t.loadMoreConversations})}):null]}),x]})}const xm=i.cssPrefix;function Sm({state:e,strings:t}){return e?/* @__PURE__ */ U(`div`,{class:`${xm}-dropzone`,"data-state":e,role:`status`,"aria-live":`polite`,children:[/* @__PURE__ */ U(`span`,{class:`${xm}-dropzone-icon`,"aria-hidden":`true`,children:U(e===`reject`?of:dd,{})}),e===`reject`?t.dropZoneRejected:t.dropZone]}):null}const Cm=new RegExp(String.raw`^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$`),wm=/^[+]?[\d\s().-]{6,}$/;function Tm(e,t,n){let r=Array.isArray(t)?t.join(``):t?.trim()??``;if(!r)return e.required?n.formRequired:void 0;if(e.type===`email`&&!Cm.test(r))return n.formInvalidEmail;if(e.type===`tel`&&!wm.test(r))return n.formInvalidTel;if(e.type===`number`&&!Number.isFinite(Number(r)))return n.formInvalidNumber}function Em(e,t,n){return Object.fromEntries(e.flatMap(e=>{let r=Tm(e,t[e.name],n);return r?[[e.name,r]]:[]}))}const Dm=i.cssPrefix;function Om(e){return e.tokenEmail||e.userContext?.email?.trim()}function km(e,t){let n=e instanceof tu?e.status:void 0;return n===400?t.formInvalidEmail:n===409?t.emailTranscriptAlreadySent:n===422?t.emailTranscriptNotDelivered:n===429?t.emailTranscriptLimited:t.emailTranscriptFailed}function Am(e){return`host`in e&&`activeElement`in e}function jm({transport:e,strings:t,knownEmail:n,onClose:r}){let[i,a]=R(n??``),[o,s]=R(!1),[c,l]=R({status:`idle`}),u=B(null),d=xi(),f=`${d}-title`,p=`${d}-error`,m=c.status===`sending`,h=c.status===`sent`;yi(()=>{let e=u.current;if(!e)return;let t=e.getRootNode(),n=Am(t)?t.activeElement:null,r=vf(e);return()=>{r(),n instanceof HTMLElement&&n.isConnected&&n.focus({preventScroll:!0})}},[]),yi(()=>{u.current?.querySelector(`[data-autofocus]`)?.focus({preventScroll:!0})},[h]);async function g(n){if(n.preventDefault(),m)return;let r=i.trim();if(!Cm.test(r)){s(!0),u.current?.querySelector(`input`)?.focus();return}s(!1),l({status:`sending`});let a=await e.emailTranscript(r).then(e=>({status:`sent`,to:e.to}),e=>({status:`failed`,message:km(e,t)}));l(a)}function _(e){e.key===`Tab`&&e.stopPropagation(),e.key===`Escape`&&(e.stopPropagation(),r())}return/* @__PURE__ */ U(`div`,{class:`${Dm}-transcript-layer`,children:[/* @__PURE__ */ U(`div`,{class:`${Dm}-transcript-backdrop`,"aria-hidden":`true`,onClick:r}),/* @__PURE__ */ U(`section`,{ref:u,class:`${Dm}-transcript-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":f,onKeyDown:_,"data-testid":Y.emailTranscriptSheet,children:[/* @__PURE__ */ U(`header`,{class:`${Dm}-transcript-sheet-head`,children:[/* @__PURE__ */ U(`span`,{class:`${Dm}-transcript-sheet-icon`,children:/* @__PURE__ */ U(kd,{})}),/* @__PURE__ */ U(`h2`,{id:f,class:`${Dm}-transcript-sheet-title`,children:t.emailTranscript}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Dm}-icon-btn`,onClick:r,"aria-label":t.emailTranscriptCancel,title:t.emailTranscriptCancel,children:/* @__PURE__ */ U(id,{})})]}),c.status===`sent`?/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`p`,{class:`${Dm}-transcript-sheet-text ${Dm}-transcript-sheet-sent`,role:`status`,children:[/* @__PURE__ */ U(nf,{}),/* @__PURE__ */ U(`span`,{children:t.emailTranscriptSent.replace(`{email}`,c.to)})]}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Dm}-form-submit ${Dm}-transcript-sheet-action`,onClick:r,"data-autofocus":!0,children:t.emailTranscriptDone})]}):/* @__PURE__ */ U(`form`,{class:`${Dm}-transcript-sheet-form`,onSubmit:e=>void g(e),noValidate:!0,children:[/* @__PURE__ */ U(`p`,{class:`${Dm}-transcript-sheet-text`,children:t.emailTranscriptPrompt}),/* @__PURE__ */ U(`label`,{class:`${Dm}-field`,"data-invalid":o?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${Dm}-field-label`,children:t.emailTranscriptEmailLabel}),/* @__PURE__ */ U(`input`,{class:`${Dm}-field-input`,type:`email`,name:`email`,autocomplete:`email`,inputMode:`email`,autocapitalize:`off`,spellcheck:!1,value:i,readOnly:m,"aria-invalid":o,"aria-describedby":o?p:void 0,onInput:e=>{a(e.currentTarget.value),s(!1)},"data-autofocus":!0,"data-testid":Y.emailTranscriptEmail}),o?/* @__PURE__ */ U(`span`,{id:p,class:`${Dm}-field-error`,role:`alert`,children:t.formInvalidEmail}):null]}),/* @__PURE__ */ U(`button`,{type:`submit`,class:`${Dm}-form-submit ${Dm}-transcript-sheet-action`,disabled:m,"aria-busy":m,"data-testid":Y.emailTranscriptSend,children:m?t.emailTranscriptSending:t.emailTranscriptSend}),c.status===`failed`?/* @__PURE__ */ U(`p`,{class:`${Dm}-field-error`,role:`alert`,children:c.message}):null]})]})]})}var Mm=Object.assign;function Nm(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 Pm=/^(-|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|asp|fill|st)/;function Fm(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:Nm(this.props,e)}function r(t){return this.shouldComponentUpdate=n,Ze(e,t)}return r.displayName=`Memo(`+(e.displayName||e.name)+`)`,r.prototype.isReactComponent=!0,r.type=e,r}var Im=Symbol.for(`react.element`),Lm=/^(?: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]/,Rm=/[A-Z0-9]/g,zm=typeof document<`u`,Bm=function(e){return/fil|che|rad/.test(e)};$e.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty($e.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Vm=F.event;F.event=function(e){return Vm&&(e=Vm(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var Hm={configurable:!0,get:function(){return this.class}},Um=F.vnode;F.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||zm&&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`||Pm.test(c)||(s||(s=o=Mm({},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`||Bm(t.type)?l==`onfocus`?a=`onfocusin`:l==`onblur`&&(a=`onfocusout`):l=a=`oninput`,l==`oninput`&&r[a=l]&&(a=`oninputCapture`)}else i&&Lm.test(a)?a=a.replace(Rm,`-$&`).toLowerCase():o===null&&(o=void 0);r[a]=o}}if(n==`select`){var u=r.defaultValue==null?r.multiple&&Array.isArray(r.value)?r.value:null:r.defaultValue;u!=null&&(r.value=ct(t.children).forEach(function(e){e.props.selected=r.multiple?u.indexOf(e.props.value)!=-1:u==e.props.value}))}t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",Hm)):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=Mm({},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=Im,Um&&Um(e)};const Wm=i.cssPrefix;function Gm({messageId:e,initial:t,strings:n,onFeedback:r}){let[i,a]=R(t);z(()=>a(t),[e,t]);function o(t){let n=i===t?null:t;a(n),r(e,n)}return/* @__PURE__ */ U(`div`,{class:`${Wm}-feedback`,role:`group`,"data-testid":Y.messageFeedback,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${Wm}-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":Y.feedbackUp,children:/* @__PURE__ */ U(Qd,{})}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Wm}-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":Y.feedbackDown,children:/* @__PURE__ */ U($d,{})}),/* @__PURE__ */ U(`span`,{class:`${Wm}-sr-only`,role:`status`,"aria-live":`polite`,children:i?n.feedbackThanks:``})]})}function Km(e){return e.partsSig.value.some(e=>e.kind===`text`&&e.textSig.value.length>0)}function qm(e){return e.partsSig.value.some(e=>e.kind===`reasoning`)}function Jm(e){return e.streaming&&!e.bufferedHold&&!(e.reasoningVisible&&e.working)}function Ym(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:Jm({streaming:t,bufferedHold:a,reasoningVisible:n,working:o}),emptyReply:r,hidden:i}}const Xm=i.cssPrefix;function Zm({part:e,strings:t}){let n=e.title||e.filename||e.url||t.sources;return e.url?/* @__PURE__ */ U(`a`,{class:`${Xm}-source`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-testid":Y.source,children:[/* @__PURE__ */ U(`span`,{class:`${Xm}-source-icon`,"aria-hidden":`true`,children:`🔗`}),/* @__PURE__ */ U(`span`,{class:`${Xm}-source-label`,children:n})]}):/* @__PURE__ */ U(`span`,{class:`${Xm}-source`,"data-testid":Y.source,children:[/* @__PURE__ */ U(`span`,{class:`${Xm}-source-icon`,"aria-hidden":`true`,children:`📄`}),/* @__PURE__ */ U(`span`,{class:`${Xm}-source-label`,children:n})]})}const Qm=i.cssPrefix;function $m(e){return{toolCallId:e.toolCallId,toolName:e.toolName,...e.title?{title:e.title}:{},state:e.stateSig.value,input:e.inputSig.value,output:e.outputSig.value,...e.errorSig.value?{errorText:e.errorSig.value}:{},...e.approvalSig.value?{approval:e.approvalSig.value}:{},...e.toolMetadata?{toolMetadata:e.toolMetadata}:{}}}function eh(e,t){if(t?.replacedByMessageId)return{terminal:!1,responded:!1,decided:!1};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 th({status:e,label:t,icon:n}){return/* @__PURE__ */ U(`span`,{class:`${Qm}-toolui-badge ${Qm}-toolui-status`,"data-status":e,children:[/* @__PURE__ */ U(`span`,{class:`${Qm}-toolui-status-icon`,children:n??/* @__PURE__ */ U(nh,{status:e})}),t]})}function nh({status:e}){return e===`running`?/* @__PURE__ */ U(`span`,{class:`${Qm}-loading-spinner`}):U(e===`stopped`?ud:e===`waiting`||e===`submitted`?tf:e===`failed`||e===`declined`||e===`replaced`?rf:nf,{})}function rh({decision:e}){return/* @__PURE__ */ U(`span`,{class:`${Qm}-steps-decision`,"data-approved":e.approved?`true`:`false`,title:e.title,children:[e.approved?/* @__PURE__ */ U(nf,{}):/* @__PURE__ */ U(rf,{}),e.label]})}function ih({view:e,strings:t}){let n=e.raw;return/* @__PURE__ */ U(L,{children:[e.error?/* @__PURE__ */ U(`p`,{class:`${Qm}-steps-row-error`,children:e.error}):null,e.fields.length>0?/* @__PURE__ */ U(ah,{fields:e.fields,label:e.tables?t.stepInput:void 0,plain:!e.tables}):null,e.resultFields?/* @__PURE__ */ U(ah,{fields:e.resultFields,label:t.toolResult}):null,n?.input||n?.output?/* @__PURE__ */ U(`details`,{class:`${Qm}-toolui-raw`,open:!e.tables,children:[/* @__PURE__ */ U(`summary`,{children:t.stepRawData}),n.input?/* @__PURE__ */ U(oh,{label:t.stepInput,text:n.input}):null,n.output?/* @__PURE__ */ U(oh,{label:t.toolResult,text:n.output}):null]}):null]})}function ah({fields:e,label:t,plain:n=!1}){let r=/* @__PURE__ */ U(`div`,{class:`${Qm}-toolui-fields`,"data-plain":n?`true`:void 0,children:/* @__PURE__ */ U(`table`,{children:/* @__PURE__ */ U(`tbody`,{children:e.map(({label:e,value:t},n)=>/* @__PURE__ */ U(`tr`,{children:[/* @__PURE__ */ U(`th`,{scope:`row`,children:e}),/* @__PURE__ */ U(`td`,{children:t})]},`${e}#${n}`))})})});return t?/* @__PURE__ */ U(`div`,{class:`${Qm}-toolui-section`,children:[/* @__PURE__ */ U(`span`,{class:`${Qm}-toolui-label`,children:t}),r]}):r}function oh({label:e,text:t}){return/* @__PURE__ */ U(`div`,{class:`${Qm}-toolui-section`,children:[/* @__PURE__ */ U(`span`,{class:`${Qm}-toolui-label`,children:e}),/* @__PURE__ */ U(`pre`,{class:`${Qm}-toolui-code`,children:t})]})}const sh=i.cssPrefix;function ch({part:e,view:t,strings:n,locale:r,canAct:i,onDecision:a,onEdit:o,preview:s}){let c=t.approval,l=t.status===`waiting`||t.status===`submitted`||t.status===`approved`,u=e.toolCallId;return/* @__PURE__ */ U(`details`,{class:`${sh}-toolui ${sh}-toolui-collapsible`,open:l||c?.buttons===`change`||void 0,"data-testid":t.status===`waiting`?Y.toolApproval:Y.toolDecision,"data-status":t.status,children:[/* @__PURE__ */ U(`summary`,{class:`${sh}-toolui-head`,children:[/* @__PURE__ */ U(`span`,{class:`${sh}-toolui-prompt`,children:l&&c?c.ask:t.name}),t.system?/* @__PURE__ */ U(`span`,{class:`${sh}-toolui-system`,children:t.system}):null,/* @__PURE__ */ U(`span`,{class:`${sh}-toolui-head-end`,children:[t.decision?/* @__PURE__ */ U(rh,{decision:t.decision}):null,t.statusLabel?/* @__PURE__ */ U(th,{status:t.status,label:t.statusLabel}):null,/* @__PURE__ */ U(`span`,{class:`${sh}-toolui-chevron`,children:/* @__PURE__ */ U(Ad,{})})]})]}),/* @__PURE__ */ U(`div`,{class:`${sh}-toolui-collapse-body`,children:[l&&s&&P(e.toolMetadata)?/* @__PURE__ */ U(uh,{toolName:e.toolName,input:e.inputSig.value,preview:s,strings:n,locale:r}):null,/* @__PURE__ */ U(ih,{view:t,strings:n}),c?.note?/* @__PURE__ */ U(`p`,{class:`${sh}-toolui-subtle`,children:c.note}):null,c?.buttons===`decide`?/* @__PURE__ */ U(`div`,{class:`${sh}-toolui-actions`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${sh}-form-skip`,disabled:!i,onClick:()=>a(u,!1),"data-testid":Y.toolDecline,children:n.decline}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${sh}-form-submit`,disabled:!i,onClick:()=>a(u,!0),"data-testid":Y.toolApprove,children:n.approve})]}):null,c?.buttons===`change`?/* @__PURE__ */ U(`div`,{class:`${sh}-toolui-actions`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${sh}-form-skip`,onClick:()=>o(u),"data-testid":Y.toolEdit,children:n.changeAnswer})}):null]})]})}function lh(e){if(typeof e==`object`&&e&&`totals`in e)return`number`in e&&`items`in e?`root = Root([preview])\npreview = Order(${JSON.stringify(e)})`:`lines`in e?`root = Root([preview])\npreview = Cart(${JSON.stringify(e)})`:void 0}function uh({toolName:e,input:t,preview:n,strings:r,locale:i}){let[a,o]=R();z(()=>{let r=!0;return n(e,t).then(e=>{r&&o(lh(e))}),()=>{r=!1}},[e,t,n]);let s=bi(()=>a?{textSig:H(a),doneSig:H(!0),replyDoneSig:H(!0)}:void 0,[a]);return s?/* @__PURE__ */ U(`div`,{class:`${sh}-toolui-preview`,"data-testid":Y.toolPreview,children:/* @__PURE__ */ U(Ac,{cssPrefix:sh,textSig:s.textSig,doneSig:s.doneSig,replyDoneSig:s.replyDoneSig,strings:r,locale:i})}):null}const dh=[`text`,`email`,`phone`,`number`,`date`,`single-select`,`multi-select`,`boolean`];function fh(e){return typeof e==`object`&&!!e}function ph(e,t){let n=fh(e)?e:{},r=(Array.isArray(n.questions)?n.questions:[]).map((e,n)=>mh(e,n,t)).filter(e=>e!==null);return{intro:_h(n.intro),questions:r}}function mh(e,t,n){if(!fh(e))return null;let r=dh.find(t=>t===e.type)??`text`;return{key:_h(e.key)??`q${t+1}`,question:_h(e.question)??n,type:r,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:_h(e.helpText)}}function hh(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 gh(e,t,n){return e.questions.map(e=>{let r=hh(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 _h(e){return typeof e==`string`&&e.trim()?e.trim():void 0}const vh=i.cssPrefix;function yh({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]=R(()=>l??{}),[_,v]=R({}),[y,b]=R({});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=Ch(e,h,_),a=Em(e,i,t);Object.keys(a).length>0?b(a):r(i)}function ee(e){!s||e.key!==`Enter`||e.shiftKey||Dp(e)||e.target&&`tagName`in e.target&&e.target.tagName===`TEXTAREA`&&w(e)}return/* @__PURE__ */ U(`form`,{class:`${vh}-form`,onSubmit:w,onKeyDown:ee,onCompositionEnd:Ep,"data-testid":f,noValidate:!0,children:[e.map(e=>/* @__PURE__ */ U(bh,{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:`${vh}-form-actions`,children:[o?/* @__PURE__ */ U(`span`,{class:`${vh}-form-hint`,children:o}):null,i&&a?/* @__PURE__ */ U(`button`,{type:`button`,class:`${vh}-form-skip`,onClick:a,disabled:c,"data-testid":m,children:i}):null,/* @__PURE__ */ U(`button`,{type:`submit`,class:`${vh}-form-submit`,disabled:c,"data-testid":p,children:n})]})]})}function bh({field:e,value:t,otherText:n,error:r,disabled:i,typeLabel:a,strings:o,onChange:s,onOtherChange:c}){let l=cf(Y.formField,e.name),u=xi(),d=xh({field:e,value:t,otherText:n,disabled:i,strings:o,onChange:s,onOtherChange:c,fieldTid:l,labelId:u});return/* @__PURE__ */ U(e.type===`radio`||e.type===`multiselect`?`div`:`label`,{class:`${vh}-field`,"data-field":e.name,"data-invalid":r?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${vh}-field-head`,children:[/* @__PURE__ */ U(`span`,{class:`${vh}-field-label`,id:u,children:[e.label,e.required?/* @__PURE__ */ U(`span`,{class:`${vh}-field-req`,"aria-hidden":`true`,children:` *`}):null]}),a?/* @__PURE__ */ U(`span`,{class:`${vh}-field-type`,children:a}):null]}),d,e.validationHint&&!r?/* @__PURE__ */ U(`span`,{class:`${vh}-field-hint`,children:e.validationHint}):null,r?/* @__PURE__ */ U(`span`,{class:`${vh}-field-error`,role:`alert`,children:r}):null]})}function xh(e){let{field:t,value:n,otherText:r,disabled:i,strings:a,onChange:o,onOtherChange:s,fieldTid:c,labelId:l}=e,u=typeof n==`string`?n:``;switch(t.type){case`textarea`:return/* @__PURE__ */ U(`textarea`,{class:`${vh}-field-input`,rows:3,value:u,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c});case`radio`:return/* @__PURE__ */ U(`div`,{class:`${vh}-field-choices`,role:`radiogroup`,"aria-labelledby":l,"data-testid":c,children:(t.options??[]).map(e=>/* @__PURE__ */ U(`label`,{class:`${vh}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`radio`,name:`${vh}-${t.name}`,checked:u===e.value,disabled:i,onChange:()=>o(e.value)}),/* @__PURE__ */ U(`span`,{children:e.label})]},e.value))});case`multiselect`:{let e=Array.isArray(n)?n:[];function u(t,n){return o(n?[...e,t]:e.filter(e=>e!==t))}return/* @__PURE__ */ U(`div`,{class:`${vh}-field-choices`,role:`group`,"aria-labelledby":l,"data-testid":c,children:[(t.options??[]).map(t=>/* @__PURE__ */ U(`label`,{class:`${vh}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`checkbox`,checked:e.includes(t.value),disabled:i,onChange:e=>u(t.value,e.currentTarget.checked)}),/* @__PURE__ */ U(`span`,{children:t.label})]},t.value)),(t.options??[]).length===0?/* @__PURE__ */ U(`textarea`,{class:`${vh}-field-input`,rows:2,value:r,placeholder:a.formOtherPlaceholder,disabled:i,onInput:e=>s(e.currentTarget.value)}):null]})}default:return/* @__PURE__ */ U(`input`,{...Sh(t.type),class:`${vh}-field-input`,value:u,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c})}}function Sh(e){switch(e){case`number`:return{type:e};case`email`:return{type:e};case`tel`:return{type:e};case`date`:return{type:e};default:return{type:`text`}}}function Ch(e,t,n){let r={...t};for(let i of e){let e=n[i.name]?.trim();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 wh=i.cssPrefix;function Th({skipped:e,submitted:t,strings:n}){return e?{status:`replaced`,statusLabel:n.inputSkipped}:t?{status:`submitted`,statusLabel:n.stepWorkingOnIt}:{status:`done`,statusLabel:n.inputAnswered}}const Eh={text:`qtypeText`,email:`qtypeEmail`,phone:`qtypePhone`,number:`qtypeNumber`,date:`qtypeDate`,"single-select":`qtypeChooseOne`,"multi-select":`qtypeChooseAny`,boolean:`qtypeBoolean`};function Dh(e,t){let n={};for(let r of e)n[r.key]=t[Eh[r.type]];return n}function Oh({part:e,strings:t,active:n,superseded:r=!1,continuationStreaming:i=!1,folded:a=!1,onDecision:o,onEdit:s}){let c=bi(()=>Yi(()=>e.stateSig.value),[e]).value,l=bi(()=>Yi(()=>e.approvalSig.value),[e]).value,u=bi(()=>Yi(()=>ph(e.inputSig.value,t.askFallbackQuestion)),[e,t]).value,{terminal:d,decided:f}=eh(c,l),p=f&&l?.approved===!0,m=i&&!f,h=!f&&!r&&!m,g=!h&&!p&&!m,_=p&&n&&!d,v=u.questions,[y,b]=R(null),x=y??(h||p||m),[S,C]=R(!1),w=v.length>1?rd:Pd,ee=h?t.inputRequired:t.inputBadge,T=m?/* @__PURE__ */ U(`p`,{class:`${wh}-toolui-subtle`,children:t.stepWorkingOnIt}):h?/* @__PURE__ */ U(kh,{req:u,strings:t,active:n,resolve:(t,n)=>o(e.toolCallId,n,t)}):S?/* @__PURE__ */ U(yh,{fields:gh(u,t.confirmYes,t.confirmNo),strings:t,submitLabel:t.inputSubmit,onSubmit:()=>{},disabled:!0,hideActions:!0,fieldTypeLabels:Dh(v,t),initialValues:p?Ih(v,l?.reason):void 0}):/* @__PURE__ */ U(Ah,{questions:v,answers:p?Fh(l?.reason):{},strings:t}),{status:E,statusLabel:D}=Th({skipped:g,submitted:m,strings:t});return/* @__PURE__ */ U(`details`,{class:`${wh}-toolui ${wh}-toolui-collapsible${r?` ${wh}-toolui-stale`:``}`,open:x,onToggle:e=>{let t=e.currentTarget.open;t!==x&&b(t)},"data-testid":h?Y.toolAskQuestions:Y.toolDecision,children:[/* @__PURE__ */ U(`summary`,{class:`${wh}-toolui-head`,children:[/* @__PURE__ */ U(`span`,{class:`${wh}-toolui-q-pill`,children:[/* @__PURE__ */ U(w,{}),ee]}),/* @__PURE__ */ U(`span`,{class:`${wh}-toolui-head-end`,children:[h||a?null:/* @__PURE__ */ U(th,{status:E,icon:U(g?rf:nf,{}),label:D}),/* @__PURE__ */ U(`span`,{class:`${wh}-toolui-chevron`,children:/* @__PURE__ */ U(Ad,{})})]})]}),/* @__PURE__ */ U(`div`,{class:`${wh}-toolui-collapse-body`,children:[u.intro?/* @__PURE__ */ U(`div`,{class:`${wh}-toolui-desc`,children:u.intro}):null,T,h||m?null:/* @__PURE__ */ U(`div`,{class:`${wh}-toolui-footer`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${wh}-toolui-options-toggle`,onClick:()=>C(e=>!e),"data-testid":Y.toolAskOptions,children:[/* @__PURE__ */ U(`span`,{class:`${wh}-toolui-options-chevron${S?` ${wh}-open`:``}`,children:/* @__PURE__ */ U(Ad,{})}),S?t.hideOptions:t.showOptions]}),_?/* @__PURE__ */ U(`button`,{type:`button`,class:`${wh}-form-skip`,onClick:()=>s(e.toolCallId),"data-testid":Y.toolEdit,children:t.edit}):null]})]})]})}function kh({req:e,strings:t,active:n,resolve:r}){let i=gh(e,t.confirmYes,t.confirmNo),a=e.questions.length===1&&e.questions[0]?.type===`text`;return/* @__PURE__ */ U(yh,{fields:i,strings:t,disabled:!n,submitLabel:t.inputSubmit,footerHint:a?t.inputSubmitHint:void 0,onSubmit:t=>r(Mh(e.questions,t),!0),skipLabel:t.inputSkip,onSkip:()=>r(void 0,!1),submitOnEnter:a,fieldTypeLabels:Dh(e.questions,t),submitTestId:Y.toolInputSubmit,skipTestId:Y.toolInputSkip})}function Ah({questions:e,answers:t,strings:n}){return/* @__PURE__ */ U(`div`,{class:`${wh}-toolui-summary`,"data-testid":Y.toolAskSummary,children:e.map(e=>/* @__PURE__ */ U(`div`,{class:`${wh}-field`,children:[/* @__PURE__ */ U(`span`,{class:`${wh}-field-head`,children:/* @__PURE__ */ U(`span`,{class:`${wh}-field-label`,children:[e.question,e.required?/* @__PURE__ */ U(`span`,{class:`${wh}-field-req`,"aria-hidden":`true`,children:` *`}):null]})}),/* @__PURE__ */ U(`p`,{class:`${wh}-toolui-answer`,children:jh(e,t[e.key],n)||`—`})]},e.key))})}function jh(e,t,n){return e.type===`boolean`?t===`yes`?n.confirmYes:t===`no`?n.confirmNo:t??``:t??``}function Mh(e,t){let n=e.flatMap(e=>{let n=t[e.key],r=typeof n==`string`?n.trim():n;return r?.length?[{key:e.key,value:r}]:[]});return JSON.stringify({answers:n})}function Nh(e){if(!e)return{};let t=(()=>{try{return JSON.parse(e)}catch{return}})(),n=Ph(t)?t.answers:void 0;if(!Array.isArray(n))return{};let r={};for(let e of n)if(Ph(e)){let{key:t,value:n}=e;if(typeof t!=`string`)continue;typeof n==`string`?r[t]=n:Array.isArray(n)&&(r[t]=n.filter(e=>typeof e==`string`))}return r}function Ph(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Fh(e){let t=Nh(e),n={};for(let[e,r]of Object.entries(t))n[e]=Array.isArray(r)?r.join(`, `):r;return n}function Ih(e,t){let n=Nh(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}const Z=i.cssPrefix;function Lh(e,t){let n=[];for(let[r,i]of e.entries()){let e=n.at(-1),a=i.kind===`tool`?t.viewOf(i):void 0,o=Rh(i,a,t.showReasoning);o?e?.kind===`steps`?(e.rows.push(o),e.indices.push(r)):n.push({kind:`steps`,rows:[o],indices:[r]}):i.kind===`step-start`||i.kind===`reasoning`||i.kind===`source`&&!t.showSources||a?.placement===`hidden`||n.push({kind:`part`,part:i,index:r})}return n}function Rh(e,t,n){return e.kind===`reasoning`?n?{kind:`thought`,part:e}:void 0:e.kind===`tool`&&t?.placement===`step`?{kind:`tool`,part:e,view:t}:void 0}function zh(e,t){let n=[...new Set(t)];if(e&&n.length!==0&&!n.some(t=>t<0||t>=e.length))return n.reduce((t,n)=>t+(e[n]?.durationMs??0),0)}function Bh(e){let t=[];for(let n of e)t.push((t.at(-1)??-1)+ +(n.kind===`step-start`));return t}function Vh(e,t){return e.streaming?t.thinking:e.reasoningMs===void 0?t.thought:t.thoughtFor.replace(`{time}`,Hh(e.reasoningMs))}function Hh(e){if(e<1e4)return`${Number((e/1e3).toFixed(1))} s`;let t=Math.round(e/1e3);return t<60?`${t} s`:`${Math.floor(t/60)} m ${t%60} s`}function Uh(e){return e.split(`
70
- `).map(e=>e.trim()).findLast(e=>/^\*\*[^*].*\*\*$/.test(e))?.slice(2,-2).trim()}function Wh(e,t){return e?.kind===`tool`?`${e.view.name}…`:(e&&Uh(e.part.textSig.value))??t.thinking}function Gh({rows:e,steps:t=[],stepTimings:n,timed:r=!0,strings:i,running:a,runStartedAt:o,renderCard:s}){let[c,l]=R(!1),[u,d]=R(!1),f=gn(e.flatMap(e=>e.kind===`tool`?[e.view]:[])),p=e.at(-1),m=bi(()=>Yi(()=>Wh(p,i)),[p,i]).value,h=r?zh(n,t):void 0;function g(){l(!c),d(!0)}let[_]=e;return!a&&e.length===1&&_?.kind===`tool`?/* @__PURE__ */ U(`div`,{class:`${Z}-steps`,"data-testid":Y.toolSteps,"data-stopped":f.stopped?`true`:void 0,children:/* @__PURE__ */ U(Zh,{part:_.part,view:_.view,strings:i,durationMs:h,standalone:!0,renderCard:s})}):/* @__PURE__ */ U(`div`,{class:`${Z}-steps`,"data-testid":Y.toolSteps,"data-running":a?`true`:void 0,"data-stopped":f.stopped?`true`:void 0,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${Z}-steps-head`,"aria-expanded":c,onClick:g,children:[/* @__PURE__ */ U(`span`,{class:`${Z}-steps-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(qh,{running:a,stopped:f.stopped!==void 0})}),/* @__PURE__ */ U(`span`,{class:`${Z}-steps-label`,children:a?/* @__PURE__ */ U(`span`,{class:`${Z}-steps-live`,children:m}):/* @__PURE__ */ U(Jh,{line:f,strings:i})}),!a&&f.failed>0?/* @__PURE__ */ U(`span`,{class:`${Z}-steps-failed`,children:i.toolStepsFailed.replace(`{count}`,String(f.failed))}):null,a?null:f.marks.map(e=>/* @__PURE__ */ U(rh,{decision:e},e.title)),a&&o?/* @__PURE__ */ U(Kh,{since:o}):null,!a&&h!==void 0?/* @__PURE__ */ U(`span`,{class:`${Z}-steps-time`,children:Hh(h)}):null,/* @__PURE__ */ U(`span`,{class:`${Z}-steps-chevron`,"data-open":c?`true`:void 0,children:/* @__PURE__ */ U(Ad,{})})]}),/* @__PURE__ */ U(`span`,{class:`${Z}-sr-only`,role:`status`,children:a?m:``}),/* @__PURE__ */ U(`div`,{class:`${Z}-steps-body`,"data-open":c?`true`:void 0,inert:!c,children:/* @__PURE__ */ U(`div`,{class:`${Z}-steps-body-inner`,children:u?/* @__PURE__ */ U(`ol`,{class:`${Z}-steps-list`,children:e.map((r,o)=>r.kind===`tool`?/* @__PURE__ */ U(Zh,{part:r.part,view:r.view,strings:i,renderCard:s},r.part.toolCallId):/* @__PURE__ */ U(Qh,{part:r.part,current:a&&o===e.length-1,reasoningMs:n?.[t[o]??-1]?.reasoningMs,strings:i},`${r.part.id}#${o}`))}):null})})]})}function Kh({since:e}){let[t,n]=R(()=>Date.now());z(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let r=Math.max(0,Math.floor((t-Date.parse(e))/1e3));return/* @__PURE__ */ U(`span`,{class:`${Z}-steps-time`,children:Hh(r*1e3)})}function qh({running:e,stopped:t}){return e?/* @__PURE__ */ U(`span`,{class:`${Z}-loading-spinner`}):U(t?ud:ef,{})}function Jh({line:e,strings:t}){return e.stopped?/* @__PURE__ */ U(L,{children:vn(e.stopped.finished,t)}):e.single?/* @__PURE__ */ U(L,{children:[e.single.name,e.single.summary?/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`span`,{class:`${Z}-steps-sep`,"aria-hidden":`true`,children:`·`}),/* @__PURE__ */ U(`span`,{class:`${Z}-steps-summary`,children:e.single.summary})]}):null,e.single.outcome?/* @__PURE__ */ U(`span`,{class:`${Z}-steps-denied`,children:e.single.outcome}):null]}):/* @__PURE__ */ U(L,{children:e.tools.map(({name:e,count:t},n)=>/* @__PURE__ */ U(`span`,{class:`${Z}-steps-name`,children:[n>0?/* @__PURE__ */ U(`span`,{class:`${Z}-steps-sep`,"aria-hidden":`true`,children:`·`}):null,e,t>1?/* @__PURE__ */ U(`span`,{class:`${Z}-steps-count`,children:[`×`,t]}):null]},e))})}function Yh({view:e}){let t=e.statusLabel&&e.status!==`running`?/* @__PURE__ */ U(`span`,{class:e.status===`failed`?`${Z}-steps-failed`:`${Z}-steps-denied`,children:e.statusLabel}):null;return/* @__PURE__ */ U(L,{children:[e.decision?/* @__PURE__ */ U(rh,{decision:e.decision}):null,t]})}function Xh({view:e,durationMs:t}){return/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`span`,{class:`${Z}-steps-row-label`,children:[/* @__PURE__ */ U(`span`,{class:`${Z}-steps-row-name`,children:e.name}),e.system?/* @__PURE__ */ U(`span`,{class:`${Z}-steps-row-system`,children:e.system}):null,e.summary?/* @__PURE__ */ U(`span`,{class:`${Z}-steps-row-summary`,children:e.summary}):null]}),/* @__PURE__ */ U(Yh,{view:e}),t===void 0?null:/* @__PURE__ */ U(`span`,{class:`${Z}-steps-time`,children:Hh(t)})]})}function Zh({part:e,view:t,strings:n,durationMs:r,standalone:i=!1,renderCard:a}){let[o,s]=R(!1);return/* @__PURE__ */ U(i?`div`:`li`,{class:`${Z}-steps-row`,"data-testid":Y.toolStep,"data-status":t.status,"data-standalone":i?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${Z}-steps-row-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(nh,{status:t.status})}),/* @__PURE__ */ U(`div`,{class:`${Z}-steps-row-main`,children:t.opens?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Z}-steps-row-head`,"aria-expanded":o,onClick:()=>s(!o),children:[/* @__PURE__ */ U(Xh,{view:t,durationMs:r}),/* @__PURE__ */ U(`span`,{class:`${Z}-steps-chevron`,"data-open":o?`true`:void 0,children:/* @__PURE__ */ U(Ad,{})})]}):/* @__PURE__ */ U(`span`,{class:`${Z}-steps-row-head`,children:/* @__PURE__ */ U(Xh,{view:t,durationMs:r})})}),o&&t.opens?/* @__PURE__ */ U(`div`,{class:`${Z}-steps-row-body`,children:(t.card?a?.(e,t):void 0)??/* @__PURE__ */ U(ih,{view:t,strings:n})}):null]})}function Qh({part:e,current:t,reasoningMs:n,strings:r,standalone:i=!1}){let[a,o]=R(!1),s=bi(()=>Yi(()=>e.textSig.value.trim()===``),[e]).value,c=/* @__PURE__ */ U(`span`,{class:t?`${Z}-steps-thought-label ${Z}-steps-live`:`${Z}-steps-thought-label`,children:Vh({streaming:t,reasoningMs:n},r)});return/* @__PURE__ */ U(i?`div`:`li`,{class:`${Z}-steps-row ${Z}-steps-thought`,"data-status":`thought`,"data-testid":i?Y.reasoning:void 0,"data-standalone":i?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${Z}-steps-row-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(af,{})}),/* @__PURE__ */ U(`div`,{class:`${Z}-steps-row-main`,children:s?c:/* @__PURE__ */ U(`button`,{type:`button`,class:`${Z}-steps-row-head`,"aria-expanded":a,onClick:()=>o(!a),children:[c,/* @__PURE__ */ U(`span`,{class:`${Z}-steps-chevron`,"data-open":a?`true`:void 0,children:/* @__PURE__ */ U(Ad,{})})]})}),a&&!s?/* @__PURE__ */ U(`div`,{class:`${Z}-steps-thought-text ${Z}-reasoning-body`,children:/* @__PURE__ */ U(Sf,{textSig:e.textSig,doneSig:e.doneSig})}):null]})}const $h=i.cssPrefix,eg=Fm(tg);function tg({message:e,status:t,createdAt:n,strings:r,locale:i,responseMode:a,showReasoning:o,stepDisplay:s,showSources:c,interactive:l=!1,superseded:u=!1,tool:d,onRetry:f,enableMessageFeedback:p=!1,onFeedback:m,reconnecting:h=!1,clientToolRunning:g=!1,onCardAction:_}){let v=[...bi(()=>Yi(()=>e.partsSig.value),[e]).value];for(let t of e.attachments??[])t.url&&!v.some(e=>e.kind===`file`&&e.url===t.url)&&v.push({kind:`file`,url:t.url,mediaType:t.mediaType,filename:t.name,fileId:t.id,fileSize:t.size});let y=bi(()=>Yi(()=>Kl(e)),[e,t,e.canceled]),b=bi(()=>Yi(()=>Km(e)),[e]),x=bi(()=>Yi(()=>o&&qm(e)),[e,o]),S=bi(()=>Yi(()=>Jl(e,x.value)),[e,x,t,e.canceled]),C=bi(()=>Yi(()=>!Cl(e)),[e]),w=t===`streaming`,ee=e.role===`assistant`&&g,T=e.role===`assistant`&&(w||ee),E=w||ee,D=Ym({streaming:T,responseMode:a,reasoningVisible:x.value,hasAnswerText:b.value,emptyReply:y.value,hidden:S.value}),{bufferedHold:O,showStreamDots:te}=D;if(D.hidden)return null;let k=rg(n,i),ne=e.role===`assistant`||e.role===`operator`,re=p&&!!m&&!!e.serverMessageId&&ne&&!E&&t!==`error`&&!y.value,ie=E?``:v.filter(e=>e.kind===`text`).map(t=>e.role===`assistant`?qc(t.textSig.peek()):t.textSig.peek()).join(`
66
+ `))!==-1;){let e=r.slice(0,a);r=r.slice(a+2),yield e}}}finally{n.releaseLock()}}function su(e,t){let n=``,r;for(let i of e.split(`
67
+ `))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);if(!cu(e))throw TypeError(`unrecognized chunk`);return iu.trace(`chunk`,{type:e.type,eventId:r}),{chunk:e,eventId:r}}catch(e){throw iu.trace(`frame parse failed`,{errorType:e instanceof Error?e.name:typeof e,payloadLength:n.length}),new ru(`invalid SSE frame`,`network`,void 0,e)}}function cu(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof Reflect.get(e,`type`)==`string`}const lu=/* @__PURE__ */ new Set([101,204,205,304]);function uu(e){let t=new Headers;for(let n of e.trim().split(/[\r\n]+/)){let e=n.indexOf(`:`);e>0&&t.append(n.slice(0,e).trim(),n.slice(e+1).trim())}return t}function du(e){return async function(t,n){let r=new Request(t,n),i=await r.blob();return new Promise((t,n)=>{if(r.signal.aborted){n(r.signal.reason);return}let a=new XMLHttpRequest;a.open(r.method,r.url),a.withCredentials=r.credentials===`include`,a.responseType=`blob`,r.headers.forEach((e,t)=>a.setRequestHeader(t,e)),a.upload.addEventListener(`progress`,t=>{t.lengthComputable&&t.total>0&&e(t.loaded/t.total)}),a.addEventListener(`load`,()=>{t(new Response(lu.has(a.status)?null:a.response,{status:a.status,statusText:a.statusText,headers:uu(a.getAllResponseHeaders())}))}),a.addEventListener(`error`,()=>n(/* @__PURE__ */ TypeError(`Failed to fetch`))),a.addEventListener(`abort`,()=>n(r.signal.reason)),r.signal.addEventListener(`abort`,()=>a.abort(),{once:!0}),a.send(i)})}}const fu=_.scope(`transport`);async function pu(e){try{let t=await e.clone().json();if(typeof t!=`object`||!t)return{};let n=Reflect.get(t,`error`);return{error:typeof n==`string`?n:void 0,loginUrl:Va(Reflect.get(t,`login`)).url}}catch{return{}}}const mu=6e4,hu=/* @__PURE__ */ new WeakMap;function gu(e){return hu.get(e)}function _u(e,t){return hu.set(e,t),e}function vu(e){return Math.max(e?.upsertRevision??0,e?.read?.revision??0)}function yu(e,t){return e.conversationId===t.conversationId&&e.title===t.title&&e.lastMessageAt===t.lastMessageAt&&e.preview===t.preview&&e.hasUnread===t.hasUnread&&e.controlState===t.controlState}function bu(e,t,n=!0){switch(t.type){case`snapshot`:{let n=new Map(e.map(e=>[e.conversationId,e])),r=e.filter(e=>(gu(e)?.activityRevision??0)>t.requestedRevision).toSorted((e,t)=>(gu(t)?.activityRevision??0)-(gu(e)?.activityRevision??0)),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=gu(r);return(i?.upsertRevision??0)>t.requestedRevision?r:i?.read&&!r.hasUnread&&i.read.lastMessageAt===e.lastMessageAt?_u({...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)),r=e[n];if(!r)return e;let i=gu(r);if(vu(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?_u({...e,hasUnread:!1},o):e):(_u(r,o),e)}case`upsert`:{let r=e.findIndex(e=>e.conversationId===t.conversation.conversationId);if(r<0&&!n)return e;let i=e[r],a=i?gu(i):void 0;if(vu(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&&yu(i,c)?(_u(i,s),e):(_u(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 xu=/* @__PURE__ */ new Set([408,425,429,500,502,503,504]);function Su(e){return 400*2**e+Math.floor(Math.random()*250)}function Cu(e){return 6e4+Math.ceil(e/1048576)*15e3}function wu(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 Tu=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)}};function Eu(e,t){let{translations:n,defaultLocale:r,...i}=Dt(e,t);return i}var Du=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 Tu(1e4)),S(this,`contentCache`,new Tu(mu)),S(this,`contentCollectionsCache`,new Tu(mu))}setUserToken(e){this.userTokenSource=e,this.userToken=typeof e==`string`&&e||void 0,this.userTokenRequest=typeof e==`function`?this.fetchUserToken():void 0,this.opts.onLoginState?.(e?{status:`pending`}:{status:`anonymous`})}async userSub(){return this.userTokenRequest&&await this.userTokenRequest,this.userToken?Ka(this.userToken):void 0}reportLogin(e){this.opts.onLoginState?.(e===`loggedIn`&&this.userToken?{status:e,...Ga(this.userToken)}:{status:e===`loggedIn`?`anonymous`:e})}async refreshUserToken(){let e=this.userToken;return typeof this.userTokenSource==`function`&&(this.userTokenRequest&&await this.userTokenRequest,this.userToken===e&&await this.fetchUserToken(),!!this.userToken&&this.userToken!==e)}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:jr};this.visitorId&&(e.visitorId=this.visitorId),this.conversationId&&(e.conversationId=this.conversationId),this.locale&&(e.locale=this.locale);let t=nu(this.userContext,this.pageContext);return t&&(e[tl]=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){fu.debug(`handshake →`,{visitorId:e.visitorId,conversationId:e.conversationId,locale:e.locale});let t=ju(`handshake`,await this.postJson(el.handshake,e,`handshake`),Nu),n=t.loginStatus===`expired`&&await this.refreshUserToken()?ju(`handshake`,await this.postJson(el.handshake,e,`handshake`),Nu):t;return this.reportLogin(n.loginStatus??(this.userToken?`loggedIn`:`anonymous`)),fu.debug(`handshake ←`,{visitorId:n.visitorId,conversationId:n.conversationId,hasWelcome:!!n.welcome,hasConfig:!!n.config,rebind:n.rebind}),this.visitorId=n.visitorId,this.conversationId=n.conversationId,n}async uploadFile(e,t,n){fu.debug(`uploadFile →`,{name:e.name,size:e.size,type:e.type});let r=new FormData;r.append(`file`,e,e.name);let i=ju(`upload`,await this.postForm(this.uploadPath,r,`upload`,t,Cu(e.size),n),Pu);return fu.debug(`uploadFile ←`,{id:i.id,url:i.url}),i}async transcribe(e,t=`audio/webm`){fu.debug(`transcribe →`,{size:e.size,mimeType:t});let n=new FormData;n.append(`audio`,e,`voice.${Ou(t)}`),n.append(`mimeType`,t);let r=ju(`transcribe`,await this.postForm(this.transcribePath,n,`transcribe`),Fu);return fu.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=bu(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(el.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(`,`)),ju(`listConversations`,await this.getJson(t.toString(),`listConversations`),Lu)}async loadConversation(e,{ids:t=[],beforeId:n,beforeCreatedAt:r}={}){let i=new URL(this.url(el.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=ju(`loadConversation`,await this.getJson(i.toString(),`loadConversation`),Ru);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=bu(e.conversations,n);return t===e.conversations?e:{...e,conversations:t}});for(let e of this.conversationListeners)e(n);try{await this.postJson(el.markRead,{conversationId:e},`markRead`,!0)}catch(e){fu.debug(`markRead failed (non-fatal)`,{err:e})}}async requestOperator(){if(this.visitorId&&this.conversationId)try{return Mu(`requestOperator`,await this.postJson(el.requestOperator,{},`requestOperator`))}catch(e){fu.debug(`requestOperator failed (non-fatal)`,{err:e});return}}async emailTranscript(e){return ju(`emailTranscript`,await this.postJson(el.emailTranscript,{email:e},`emailTranscript`),zu)}async cancelOperatorRequest(){if(this.visitorId&&this.conversationId)try{return Mu(`cancelOperatorRequest`,await this.postJson(el.cancelOperatorRequest,{},`cancelOperatorRequest`))}catch(e){fu.debug(`cancelOperatorRequest failed (non-fatal)`,{err:e});return}}listContent(e={}){return this.contentCache.getOrFetch(JSON.stringify(e,Object.keys(e).toSorted()),()=>this.fetchContent(e)).then(e=>({...e,items:e.items.map(e=>Eu(e,this.locale))}))}async fetchContent(e){let t=new URL(this.dataUrl(el.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=ju(`listContent`,await this.getJson(t.toString(),`listContent`),Bu);return{...n,items:n.items??[]}}async setContentVote(e){try{await this.postJson(this.dataUrl(el.contentVoteSet),e,`setContentVote`)}catch{}}listContentCollections(e){return this.contentCollectionsCache.getOrFetch(e.join(`,`),()=>this.fetchContentCollections(e)).then(e=>({items:e.items.map(e=>Eu(e,this.locale))}))}async fetchContentCollections(e){let t=new URL(this.dataUrl(el.contentCollections));return e.length&&t.searchParams.set(`ids`,e.join(`,`)),{items:ju(`listContentCollections`,await this.getJson(t.toString(),`listContentCollections`),Vu).items??[]}}async saveUserPrefs(e){await this.postJson(el.updateSettings,{userPrefs:e},`saveUserPrefs`)}get uploadPath(){return this.opts.endpoints?.upload??`/pai/upload-file`}get transcribePath(){return this.opts.endpoints?.transcribe??`/pai/transcribe-audio`}async submitFeedback(e){fu.debug(`submitFeedback →`,{messageId:e.messageId,value:e.value});try{await this.postJson(el.messageFeedback,{messageId:e.messageId,set:{feedback:e.value}},`submitFeedback`)}catch(e){fu.debug(`submitFeedback failed (non-fatal)`,{err:e})}}async sendTurn(e,t={}){fu.debug(`message →`,{conversationId:e.conversationId,visitorId:e.visitorId,messageCount:e.messages.length});let n=JSON.stringify({...this.withEnvelope(e),[tl]:nu(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(el.streamMessage),{method:`POST`,credentials:`omit`,headers:{accept:`application/json`,"content-type":`application/json`,...this.headersFor(this.url(el.streamMessage))},body:n,keepalive:r,signal:e}));if(t.status!==202)throw new ru(`sendTurn failed: expected 202, received ${t.status}`,`server`,t.status,void 0,Hu(t),(await pu(t)).error);let i;try{i=await t.json()}catch(n){throw e?.aborted?n:new ru(`sendTurn failed: invalid acknowledgement`,`server`,t.status,n)}if(!ku(i))throw new ru(`sendTurn failed: invalid acknowledgement`,`server`,t.status);return i},void 0,3e4)}catch(e){throw e instanceof ru?e:new ru(`sendTurn failed: network error`,`network`,void 0,e)}}cancelTurn(e,t){this.visitorId&&e&&t&&(fu.debug(`cancel stream`,{conversationId:e,runId:t,visitorId:this.visitorId}),this.fetchImpl(this.url(el.cancelStream),{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`,...this.headersFor(this.url(el.cancelStream))},body:JSON.stringify(this.withEnvelope({conversationId:e,runId:t})),keepalive:!0}).catch(e=>fu.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{a=await this.withFreshUserToken(()=>this.fetchImpl(this.resumeUrl(),{method:`GET`,credentials:`omit`,cache:`no-store`,headers:{accept:`text/event-stream`,...this.headersFor(this.resumeUrl())},signal:t.signal}))}catch(t){return i(),e.signal.aborted||fu.debug(`resume-stream fetch failed — reconnecting`,{err:t}),`held`}if(!a.ok)return i(),a.status===409||xu.has(a.status)?(fu.debug(`resume-stream → transient response; reconnecting`,{status:a.status}),`held`):(fu.debug(`resume-stream → endpoint unavailable`,{status:a.status}),`unavailable`);if(!a.body)return i(),fu.debug(`resume-stream → bodyless response; stopping`,{status:a.status}),`unavailable`;if(!(a.headers.get(`content-type`)??``).includes(`text/event-stream`))return i(),fu.debug(`resume-stream → non-SSE response; stopping`),`unavailable`;let o=!1;try{for await(let{chunk:n}of au(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`;fu.debug(`resume-stream segment dropped — reconnecting`,{err:t})}finally{i()}return`held`}resumeUrl(){return this.withEnvelopeQuery(el.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,a){let o=a?du(a):this.fetchImpl;return this.runWithAbort(async r=>{let i=await this.withFreshUserToken(()=>o(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 ru(`${t} failed: network error`,`network`,void 0,e);fu.debug(`request network error — retrying`,{label:t,attempt:n}),await de(Su(n));continue}if(r.ok||!xu.has(r.status)||n>=3)return r;let i=wu(r.headers)??Su(n);fu.debug(`request retryable status — retrying`,{label:t,status:r.status,attempt:n,wait:i}),await de(i)}}async assertOk(e,t){if(!e.ok)throw new ru(`${t} failed: ${e.status}`,`server`,e.status,void 0,void 0,(await pu(e)).error);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)},t=>{fu.warn(`userToken function failed`,{err:t}),this.userTokenSource===e&&(this.userToken=void 0)});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}:{},...t&&this.opts.continueLink?{"x-continue-link":this.opts.continueLink}:{}}}async withFreshUserToken(e){this.userTokenRequest&&await this.userTokenRequest;let t=await e();if(t.status!==401)return t;let n=await pu(t);if(n.error===`USER_TOKEN_REQUIRED`)return this.opts.onLoginState?.({status:`required`,loginUrl:n.loginUrl}),t;if(!this.userToken)return t;if(!await this.refreshUserToken())return this.reportLogin(`expired`),t;this.reportLogin(`loggedIn`);let r=await e();return r.status===401&&this.reportLogin(`expired`),r}url(e){return/^https?:\/\//i.test(e)?e:`${this.opts.agentApiBaseUrl}${e}`}dataUrl(e){return`${this.opts.dataApiBaseUrl}${e}`}get fetchImpl(){return this.opts.fetchImpl??globalThis.fetch.bind(globalThis)}};function Ou(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 ku(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 Au(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ju(e,t,n){if(!n(t))throw new ru(`${e} failed: invalid response body`,`server`);return t}function Mu(e,t){let n=rl(Au(t)?t.controlState:void 0);if(!n)throw new ru(`${e} failed: invalid response body`,`server`);return n}function Nu(e){return!(!Au(e)||typeof e.visitorId!=`string`||typeof e.conversationId!=`string`||e.welcome!==void 0&&(!Au(e.welcome)||e.welcome.messages!==void 0&&!Array.isArray(e.welcome.messages)))}function Pu(e){return Au(e)&&typeof e.id==`string`&&typeof e.url==`string`&&typeof e.originalName==`string`&&typeof e.mimeType==`string`&&typeof e.fileSize==`number`}function Fu(e){return Au(e)&&typeof e.text==`string`}function Iu(e){return Au(e)&&typeof e.page==`number`&&typeof e.limit==`number`&&typeof e.total==`number`&&typeof e.totalPages==`number`&&typeof e.hasNext==`boolean`&&typeof e.hasPrev==`boolean`}function Lu(e){return Au(e)&&Array.isArray(e.conversations)&&e.conversations.every(Au)&&Iu(e.pagination)}function Ru(e){return Au(e)&&typeof e.conversationId==`string`&&Array.isArray(e.messages)&&e.messages.every(Au)}function zu(e){return Au(e)&&typeof e.status==`string`&&typeof e.to==`string`}function Bu(e){return Au(e)&&(e.items===void 0||Array.isArray(e.items)&&e.items.every(Au))&&(e.pagination===void 0||Iu(e.pagination))}function Vu(e){return Au(e)&&(e.items===void 0||Array.isArray(e.items)&&e.items.every(Au))}function Hu(e){let t=Number(e.headers.get(`retry-after`));return Number.isInteger(t)&&t>0?t:void 0}function Uu(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 Wu(e,t,n){return Uu(`close`,e,t)?n.includes(`close`):!1}function Gu(e,t){return e===`inline`&&t===`fullscreen`?`exit-fullscreen`:`close`}function Ku(e,t,n,r){let i={role:n,text:r};e.emit(`message`,i),t.onMessage?.(i)}function qu(e){return Object.fromEntries(e.map(e=>[e,[]]))}function Ju(e,t,n){return e.includes(t)?t:e.includes(n)?n:e[0]??``}function Yu(e,t,n){let r=[...new Set(t)],i=H({activeTab:Ju(r,e,``),stacks:qu(r)});return{sig:i,reconcile(e,t){let a=[...new Set(e)],o=i.value,s=Ju(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:Ju(r,e,``),stacks:qu(r)}}}}function Xu(e){return e.stacks[e.activeTab]??[]}function Zu(e){return Xu(e).at(-1)}function Qu(e){return Xu(e).length===0}function $u(e){/^(https?:)?\//i.test(e)&&window.open(e,`_blank`,`noopener,noreferrer`)}function ed(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 td(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 nd(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:td(e.mode,e.size,t)}}function rd(){return typeof window>`u`?0:window.innerWidth}const q={fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`},id=`${i.cssPrefix}-icon-dir`;function ad(){return/* @__PURE__ */ U(`svg`,{...q,"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 od(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M18 6 6 18M6 6l12 12`})})}function sd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M12 5v14M5 12h14`})})}function cd(){return/* @__PURE__ */ U(`svg`,{...q,class:id,"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 ld(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M12 19V5M5 12l7-7 7 7`})})}function ud(){return/* @__PURE__ */ U(`svg`,{...q,class:id,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 20V4l18 8-18 8Z`})})}function dd(){return/* @__PURE__ */ U(`svg`,{...q,class:id,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`m9 18 6-6-6-6`})})}function fd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}function pd(){return/* @__PURE__ */ U(`svg`,{...q,"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 md(){return/* @__PURE__ */ U(`svg`,{...q,"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 hd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`8`,r:`4.5`}),/* @__PURE__ */ U(`path`,{d:`M4.5 20.5a7.5 7.5 0 0 1 15 0`})]})}function gd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 8V3h5M21 8V3h-5M3 16v5h5M21 16v5h-5`})})}function _d(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M8 3v5H3M16 3v5h5M8 21v-5H3M16 21v-5h5`})})}function vd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M3 3h7v2H5v5H3zM21 3h-7v2h5v5h2zM3 21h7v-2H5v-5H3zM21 21h-7v-2h5v-5h2z`})})}function yd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M10 3v5H3M14 3v5h7M10 21v-5H3M14 21v-5h7`})})}function bd(){return/* @__PURE__ */ U(`svg`,{...q,"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 xd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,viewBox:`0 0 10 10`,children:/* @__PURE__ */ U(`path`,{d:`M9 1L1 9M9 5L5 9M9 9H9`,strokeWidth:`1.5`})})}function Sd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Cd(){return/* @__PURE__ */ U(`svg`,{...q,"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 wd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M11 5 6 9H2v6h4l5 4zM22 9l-6 6M16 9l6 6`})})}function Td(){return/* @__PURE__ */ U(`svg`,{...q,"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 Ed(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M20 6 9 17l-5-5`})})}function Dd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Od(){return/* @__PURE__ */ U(`svg`,{...q,"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 kd(){return/* @__PURE__ */ U(`svg`,{...q,class:id,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M19 12H5M12 19l-7-7 7-7`})})}function Ad(){return/* @__PURE__ */ U(`svg`,{...q,"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 jd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`rect`,{x:`3`,y:`5`,width:`18`,height:`14`,rx:`2`}),/* @__PURE__ */ U(`path`,{d:`m3 7 9 6 9-6`})]})}function Md(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`m6 9 6 6 6-6`})})}function Nd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Pd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Fd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Id(){return/* @__PURE__ */ U(`svg`,{...q,"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 Ld(){return/* @__PURE__ */ U(`svg`,{...q,"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 Rd(){return/* @__PURE__ */ U(`svg`,{...q,"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 zd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Bd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Vd(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`11`,cy:`11`,r:`7`}),/* @__PURE__ */ U(`path`,{d:`m21 21-4.3-4.3`})]})}function Hd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Ud(){return/* @__PURE__ */ U(`svg`,{...q,"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 Wd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Gd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Kd(){return/* @__PURE__ */ U(`svg`,{...q,"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 qd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Jd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Yd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Xd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Zd(){return/* @__PURE__ */ U(`svg`,{...q,"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 Qd(){return/* @__PURE__ */ U(`svg`,{...q,"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 $d(){return/* @__PURE__ */ U(`svg`,{...q,"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 ef(){return/* @__PURE__ */ U(`svg`,{...q,"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 tf(){return/* @__PURE__ */ U(`svg`,{...q,"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 nf(){return/* @__PURE__ */ U(`svg`,{...q,"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 rf(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`M12 7v5l3 2`})]})}function af(){return/* @__PURE__ */ U(`svg`,{...q,"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 of(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`9`}),/* @__PURE__ */ U(`path`,{d:`m15 9-6 6M9 9l6 6`})]})}function sf(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:/* @__PURE__ */ U(`path`,{d:`M12 18V5M15 13a4.17 4.17 0 01-3-4 4.17 4.17 0 01-3 4M17.707 6.294A3 3 0 1012 5a3 3 0 10-5.707 1.294M17.996 5.125a4 4 0 012.526 5.77M18 18a4 4 0 002-7.465M19.967 17.482a4 4 0 11-7.967.517 4 4 0 11-7.967-.517M6 18a4 4 0 01-2-7.465M6.004 5.125a4 4 0 00-2.526 5.77`})})}function cf(){return/* @__PURE__ */ U(`svg`,{...q,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`circle`,{cx:`12`,cy:`12`,r:`10`}),/* @__PURE__ */ U(`path`,{d:`M12 8v4M12 16h.01`})]})}const lf={chat:ad,message:Fd,bubbles:Gd,spark:Pd,wand:Ld,bot:Rd,help:Id,lifebuoy:Bd,headset:zd,search:Yd,sparkles:Xd,concierge:Zd,wave:Qd},J=i.cssPrefix,Y={launcher:`${J}-launcher`,callout:`${J}-callout`,calloutDismiss:`${J}-callout-dismiss`,panel:`${J}-panel`,panelHeader:`${J}-panel-header`,resizeGrip:`${J}-resize-grip`,scrollToBottom:`${J}-scroll-to-bottom`,loadPreviousMessages:`${J}-load-previous-messages`,actionHistory:`${J}-action-history`,actionClose:`${J}-action-close`,emailTranscriptSheet:`${J}-email-transcript-sheet`,emailTranscriptEmail:`${J}-email-transcript-email`,emailTranscriptSend:`${J}-email-transcript-send`,langSegment:`${J}-lang-segment`,composer:`${J}-composer`,composerInput:`${J}-composer-input`,composerCount:`${J}-composer-count`,composerSend:`${J}-composer-send`,composerStop:`${J}-composer-stop`,compactionStatus:`${J}-compaction-status`,messageQueue:`${J}-message-queue`,queuedMessage:`${J}-queued-message`,queuedMessageRemove:`${J}-queued-message-remove`,composerAttach:`${J}-composer-attach`,composerFileInput:`${J}-composer-file-input`,composerVoice:`${J}-composer-voice`,attachmentChip:`${J}-attachment-chip`,attachmentRemove:`${J}-attachment-remove`,attachmentRetry:`${J}-attachment-retry`,suggestion:`${J}-suggestion`,messageBubble:`${J}-message`,messageRetry:`${J}-message-retry`,messageFile:`${J}-message-file`,messageFeedback:`${J}-message-feedback`,feedbackUp:`${J}-feedback-up`,feedbackDown:`${J}-feedback-down`,messageCopy:`${J}-message-copy`,historyItem:`${J}-history-item`,historyLoadMore:`${J}-history-load-more`,sidebar:`${J}-sidebar`,sidebarToggle:`${J}-sidebar-toggle`,sidebarNewConversation:`${J}-sidebar-new-conversation`,messengerHome:`${J}-messenger-home`,panelNotice:`${J}-panel-notice`,tab:`${J}-tab`,tabBadge:`${J}-tab-badge`,homeView:`${J}-home-view`,homeGreeting:`${J}-home-greeting`,homeBrand:`${J}-home-brand`,backHeader:`${J}-back-header`,contentView:`${J}-content-view`,contentScroll:`${J}-content-scroll`,homeSearch:`${J}-home-search`,helpSearch:`${J}-help-search`,homeRecent:`${J}-home-recent`,homeAsk:`${J}-home-ask`,homeWhatsNew:`${J}-home-whats-new`,homeContentRow:`${J}-home-content-row`,helpArticle:`${J}-help-article`,newsItem:`${J}-news-item`,newsMore:`${J}-news-more`,formField:`${J}-form-field`,toolAskQuestions:`${J}-tool-ask-questions`,toolInputSubmit:`${J}-tool-input-submit`,toolInputSkip:`${J}-tool-input-skip`,toolApproval:`${J}-tool-approval`,toolPreview:`${J}-tool-preview`,toolApprove:`${J}-tool-approve`,toolDecline:`${J}-tool-decline`,toolEdit:`${J}-tool-edit`,toolDecision:`${J}-tool-decision`,typingDots:`${J}-typing-dots`,reasoning:`${J}-reasoning`,replyStopped:`${J}-reply-stopped`,toolAskSummary:`${J}-ask-questions-summary`,toolAskOptions:`${J}-ask-questions-options-toggle`,toolSteps:`${J}-tool-steps`,toolStep:`${J}-tool-step`,source:`${J}-source`,operatorRequest:`${J}-operator-request`,chatNotice:`${J}-chat-notice`,operatorBanner:`${J}-operator-banner`,cancelOperatorRequest:`${J}-cancel-operator-request`,loginBar:`${J}-login-bar`,loginBarAction:`${J}-login-bar-action`,loginBarHide:`${J}-login-bar-hide`,loginGate:`${J}-login-gate`,loginGateAction:`${J}-login-gate-action`,loginGateGuest:`${J}-login-gate-guest`,loggedIn:`${J}-logged-in`};function uf(e,t){return`${e}-${t}`}const df=i.cssPrefix;function ff({buttonRef:e,onToggle:t,launcher:n,strings:r,leaving:i,edgeTab:a}){let o=n.variant===`circle`?``:pf(n,r);return/* @__PURE__ */ U(`button`,{ref:e,type:`button`,class:`${df}-fab`,part:`launcher`,"data-variant":n.variant,"data-size":n.size,"data-edge-tab":a?`true`:void 0,"data-leaving":i?`true`:void 0,"data-testid":Y.launcher,onClick:t,"aria-label":r.launcherOpen,children:[mf(n.icon),o?/* @__PURE__ */ U(`span`,{class:`${df}-fab-label`,children:o}):null]})}function pf(e,t){return e.label?Pt(t,e.label):e.personaName?t.launcherAsk.replace(`{name}`,Pt(t,e.personaName)):``}function mf(e){let t=lf[e];return t?/* @__PURE__ */ U(t,{}):/* @__PURE__ */ U(hf,{source:e})}function hf({source:e}){return/* @__PURE__ */ U(`span`,{ref:t=>{t&&gf(t,e)},"aria-hidden":`true`})}function gf(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 _f({callout:e,launcherPosition:t,strings:n,closeLabel:r,onDismiss:i}){let[a,o]=R(!1),s=B(null),[c,l]=R(!0);return yi(()=>{let e=s.current?.parentElement;if(!e)return;let t=()=>l(window.innerWidth-e.getBoundingClientRect().width>=vf);return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)}),z(()=>{let t=setTimeout(()=>o(!0),e.delayMs);return()=>clearTimeout(t)},[e.delayMs]),z(()=>{if(!a||e.autoDismissMs<=0)return;let t=setTimeout(i,e.autoDismissMs);return()=>clearTimeout(t)},[a,e.autoDismissMs,i]),a?/* @__PURE__ */ U(`div`,{ref:s,class:`${df}-callout`,role:`status`,"data-shape":e.shape,"data-position":yf(e.position,t,c),"data-animated":e.animated?`true`:void 0,"data-testid":Y.callout,children:[/* @__PURE__ */ U(`span`,{children:Pt(n,e.text)}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${df}-callout-close`,onClick:i,"aria-label":r,title:r,"data-testid":Y.calloutDismiss,children:/* @__PURE__ */ U(od,{})})]}):null}const vf=200;function yf(e,t,n=!0){let r=t.endsWith(`-right`),i=t.startsWith(`bottom-`);return e===`vertical`||e===`auto`&&!n?i?`top`:`bottom`:r?`left`:`right`}function bf(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(),o=a instanceof ShadowRoot?a.activeElement:null;t.shiftKey&&o===r?(t.preventDefault(),i.focus()):!t.shiftKey&&o===i&&(t.preventDefault(),r.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)}const xf=i.cssPrefix;function Sf({title:e,actions:t}){return/* @__PURE__ */ U(`header`,{class:`${xf}-back-header`,part:`header`,"data-variant":`title`,children:[/* @__PURE__ */ U(`span`,{class:`${xf}-back-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ U(`h1`,{class:`${xf}-back-title`,children:e}),t??/* @__PURE__ */ U(`span`,{class:`${xf}-back-spacer`,"aria-hidden":`true`})]})}function Cf({title:e,backLabel:t,onBack:n,actions:r,testid:i}){return/* @__PURE__ */ U(`header`,{class:`${xf}-back-header`,part:`header`,"data-testid":i,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${xf}-icon-btn`,onClick:n,"aria-label":t,title:t,children:/* @__PURE__ */ U(kd,{})}),/* @__PURE__ */ U(`h1`,{class:`${xf}-back-title`,children:e}),r??/* @__PURE__ */ U(`span`,{class:`${xf}-back-spacer`,"aria-hidden":`true`})]})}function wf({textSig:e,doneSig:t,generativeUi:n=!1,strings:r=Ot,onCardAction:a}){let o=B(null),s=B(null);return yi(()=>{let c=o.current;if(!c)return;c.classList.add(`${i.cssPrefix}-md`);let l=s.current,u={generativeUi:n,strings:r,onCardAction:a},d=()=>{s.current?.renderer?.dispose();let o=document.createElement(`div`),l=n?jc(o,{cssPrefix:i.cssPrefix,strings:r,onAction:a}):void 0,d=$a(kf(Pf(l??po(o)))),f=e.value,p=f.length-Df(f);if(!t.value)for(;p>0&&f[p-1]===`_`;)p--;let m=Of(f.slice(0,p));return m&&fo(d,m),t.value&&(eo(d),l?.finish()),c.replaceChildren(o),{settings:u,container:o,parser:d,renderer:l,lastLen:p,lastText:f.slice(0,p)}},f=l&&l.settings.generativeUi===n&&l.settings.strings===r&&l.settings.onCardAction===a&&e.value.startsWith(l.lastText)?l:d();s.current=f;let p=ea(()=>{let n=e.value,r=t.value;if(n.length<f.lastLen){f=d(),s.current=f;return}let i=Math.max(n.length-Df(n),f.lastLen);if(!r)for(;i>f.lastLen&&n[i-1]===`_`;)i--;let a=Math.max(f.lastLen-1,0),o=Of(n.slice(a,i)).slice(f.lastLen-a);o&&fo(f.parser,o),f.lastLen=i,f.lastText=n.slice(0,i),r&&(eo(f.parser),f.renderer?.finish())}),m=new MutationObserver(()=>Ff(c));m.observe(c,{childList:!0,subtree:!0}),Ff(c);function h(e){let t=e.target instanceof Element?e.target.closest(`a`):null;if(!t||!(t instanceof HTMLAnchorElement))return;let n=t.getAttribute(`href`)??``;n&&!n.startsWith(`#`)&&(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`))}return c.addEventListener(`click`,h),()=>{p(),m.disconnect(),c.removeEventListener(`click`,h)}},[e,t,n,r,a]),z(()=>()=>{s.current?.renderer?.dispose(),s.current=null},[]),/* @__PURE__ */ U(`div`,{ref:o})}function Tf({text:e}){return/* @__PURE__ */ U(wf,{textSig:bi(()=>H(e),[e]),doneSig:bi(()=>H(!0),[])})}const Ef=/([\p{L}\p{N}])(_+)(?=[\p{L}\p{N}])/gu;function Df(e){if((e.match(/^[ \t]*`{3,}/gm)?.length??0)%2==0)return 0;let t=e.trimEnd(),n=t.lastIndexOf(`
68
+ `)+1;return/^[ \t]*`{3,}[^`]*$/.test(t.slice(n))?e.length-n:0}function Of(e){return e.replace(Ef,(e,t,n)=>t+``.repeat(n.length))}function kf(e){return{...e,add_text:(t,n)=>e.add_text(t,n.replaceAll(``,`_`)),set_attr:(t,n,r)=>e.set_attr(t,n,r.replaceAll(``,`_`))}}const Af=/<(\/?)(?:(Note|Info|Tip|Warning|Danger|Check|Callout)|Tabs?|Steps?|AccordionGroup|Accordion|Expandable|Columns|CardGroup|Card|Frame|CodeGroup|Badge|Icon|Video|Embed|ParamField|ResponseField)\b((?:"[^"]*"|'[^']*'|[^>"'])*?)(\/?)>|(^|\n)([ \t]*)(```[^]*?(?:\n[ \t]*```|$))?/g;function jf(e){let t=0,n=``;return e.replace(Af,(e,r,i,a,o,s,c,l)=>{if(r===void 0)return t?s+(l?.split(`\n${c}`).join(`
69
+ `)??n):e;if(r)return t--,i&&(n=n.slice(2)),i?`\n${n}`:``;o||(t++,i&&(n+=`> `));let u={};a.replace(/(\w+)=(["'])(.*?)\2/g,(e,t,n,r)=>u[t]=r);let d=u.href??u.src,f=u.title??u.path??u.query??u.body??u.header??u.name??d;return(i?`> `:``)+(f?`**${d?`[${f}](${d})`:f}**${u.type?` \`${u.type}\``:``}\n${n}`:``)})}const Mf=/* @__PURE__ */ new Set([`http:`,`https:`,`mailto:`,`tel:`]),Nf=/* @__PURE__ */ new Set([`http:`,`https:`]);function Pf(e){let t=document.createElement(`a`);return{...e,set_attr:(n,r,i)=>{if(r!==1&&r!==2||(t.href=i,(r===1?Mf:Nf).has(t.protocol)))return e.set_attr(n,r,i);let a=r===2?n.nodes[n.index]:void 0;a?.replaceWith(...a.childNodes)}}}function Ff(e){for(let t of e.querySelectorAll(`a`)){let e=t.getAttribute(`href`)??``;e&&!e.startsWith(`#`)&&(t.target=`_blank`,t.rel=`noopener noreferrer`)}}const If=/* @__PURE__ */ new Set([11,12,13,14,15,16,17,18,19,31]);function Lf(e){let t=``,n=[],r=$a({data:void 0,add_token:(e,r)=>{n.push(r),If.has(r)||(t+=` `)},end_token:()=>{let e=n.pop();e!==void 0&&!If.has(e)&&(t+=` `)},add_text:(e,n)=>void(t+=n),set_attr:()=>void 0});return fo(r,Of(e)),eo(r),t.replaceAll(``,`_`).replace(/\s+/g,` `).trim()}const Rf=i.cssPrefix;function zf({tone:e=`info`,message:t,onRetry:n,strings:r}){return/* @__PURE__ */ U(`div`,{class:`${Rf}-module-empty`,role:e===`error`?`alert`:`status`,"aria-live":`polite`,children:[/* @__PURE__ */ U(`span`,{children:t}),n?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Rf}-module-retry`,onClick:n,children:r.errorRetry}):null]})}const Bf=i.cssPrefix,Vf=_.scope(`content`);function Hf({id:e,title:t,transport:n,strings:r,bus:i,onBack:a,actions:o}){let[s,c]=R(null),[l,u]=R(!1),[d,f]=R(!1),[p,m]=R(0),[h,g]=R(null),_=V(()=>{f(!1),c(null),m(e=>e+1)},[]);z(()=>{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||(Vf.warn(`listContent (reader) failed`,{err:e}),f(!0))}),()=>{t=!0}},[n,e,p,i]),z(()=>{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 instanceof HTMLElement?t.target.closest(`a`):null)?.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(zf,{tone:`error`,message:r.errorGeneric,onRetry:_,strings:r}):s===null?/* @__PURE__ */ U(zf,{message:r.contentLoading,strings:r}):/* @__PURE__ */ U(`article`,{class:`${Bf}-content`,"data-testid":Y.contentView,onClick:v,children:[s.image?/* @__PURE__ */ U(`img`,{class:`${Bf}-content-hero`,src:s.image,alt:``,loading:`lazy`}):null,s.description?/* @__PURE__ */ U(`p`,{class:`${Bf}-content-subtitle`,children:s.description}):null,/* @__PURE__ */ U(Tf,{text:jf(s.content??``)}),l?/* @__PURE__ */ U(`div`,{class:`${Bf}-content-vote`,"aria-live":`polite`,children:h===e?r.feedbackThanks:/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`span`,{children:r.contentHelpful}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Bf}-module-retry`,onClick:()=>y(1),children:r.confirmYes}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Bf}-module-retry`,onClick:()=>y(0),children:r.confirmNo})]})}):null]})}return/* @__PURE__ */ U(`div`,{class:`${Bf}-module`,children:[/* @__PURE__ */ U(Cf,{title:s?.title||t||r.moduleBack,backLabel:r.moduleBack,onBack:a,actions:o,testid:Y.backHeader}),/* @__PURE__ */ U(`div`,{class:`${Bf}-module-scroll`,"data-testid":Y.contentScroll,children:b()})]})}function Uf({itemCount:e,initialFocusIndex:t}){let[n,r]=R(!1),i=B(null),a=B(null),[o,s]=R(-1),c=V(()=>{r(!1),s(-1),i.current?.focus()},[]),l=V(()=>r(e=>!e),[]);return z(()=>{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]),z(()=>{if(!n||e===0)return;let r=t?.()??0;s(r<0||r>=e?0:r)},[n,e,t]),z(()=>{!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(),t.stopPropagation(),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 Wf({items:e,triggerLabel:t}){let n=i.cssPrefix,r=Uf({itemCount:e.length});function a(e){e.disabled||(e.onSelect?.(),e.keepOpen||r.close())}function o(e,t){return e.onSelectValue?.(t)}function s(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;let a=n[i];a&&(e.preventDefault(),e.stopPropagation(),o(t,a.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(Sd,{})}),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=>s(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":`${Y.langSegment}-${t.value}`,onClick:()=>o(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:()=>a(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(Ed,{})}):null]},e.id))}):null]})}const Gf=i.cssPrefix;function Kf(e){let t=typeof matchMedia!=`function`||matchMedia(`(prefers-color-scheme: dark)`).matches;return e===`auto`?t?`light`:`dark`:t?e===`light`?`dark`:`auto`:e===`dark`?`light`:`auto`}const qf={normal:`large`,large:`small`,small:`normal`};function Jf(e){return U(e===`light`?Kd:e===`dark`?qd:Jd,{})}function Yf(e,t){let n=e.split(`-`)[0];return(t.some(t=>t!==e&&t.split(`-`)[0]===n)?e:n??e).toUpperCase()}function Xf(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 Zf({panelProps:e,variant:t,onEmailTranscript:n,onLogIn:r}){let{options:i,panelSize:a,feedback:o,onClose:s,onClear:c,onExpand:l,onFullscreen:u,onSoundToggle:d}=e,{onToggleHistory:f,onLocaleChange:p,onThemeChange:m,onTextSizeChange:h}=e,g=i.strings,_=i.mode,v=t===`chat`,y=da(()=>o.mutedSig.value).value,b=new Set(i.actions);function x(e){return b.has(e)}let S=typeof matchMedia==`function`&&matchMedia(`(max-width: 640px)`).matches;function C(e){return!S&&Uu(e,_,a)}let w=i.themeMode,ee={auto:g.themeAuto,light:g.themeLight,dark:g.themeDark},T=i.textSize,E={small:g.textSizeSmall,normal:g.textSizeNormal,large:g.textSizeLarge},D=[];if(v&&x(`clear`)&&D.push({id:`clear`,icon:/* @__PURE__ */ U(Ad,{}),label:g.newConversation,onSelect:c}),v&&n&&D.push({id:`emailTranscript`,icon:/* @__PURE__ */ U(jd,{}),label:g.emailTranscript,onSelect:n}),v&&r&&D.push({id:`logIn`,icon:/* @__PURE__ */ U(hd,{}),label:g.loginAction,onSelect:r}),x(`expand`)&&C(`expand`)){let e=a===`expanded`;D.push({id:`expand`,icon:U(e?_d:gd,{}),label:e?g.collapse:g.expand,type:`switch`,on:e,onSelect:l})}if(x(`fullscreen`)&&C(`fullscreen`)){let e=a===`fullscreen`;D.push({id:`fullscreen`,icon:U(e?yd:vd,{}),label:e?g.exitFullscreen:g.fullscreen,type:`switch`,on:e,onSelect:u})}let O=i.popOutUrl,te=i.aiAgentDeploymentId;x(`popOut`)&&O&&te&&Uu(`popOut`,_,a)&&D.push({id:`popOut`,icon:/* @__PURE__ */ U(bd,{}),label:g.popOut,onSelect:()=>{let t=Xf(O,{conversationId:e.conversationId,widgetId:i.widgetId,publicKey:i.publicKey,aiAgentDeploymentId:te});t&&window.open(t,`_blank`,`noopener,noreferrer`)}}),v&&x(`sound`)&&D.push({id:`sound`,icon:U(y?wd:Cd,{}),label:y?g.soundOff:g.soundOn,type:`switch`,on:!y,onSelect:d}),x(`theme`)&&w!==`host`&&D.push({id:`theme`,icon:Jf(w),label:`${g.theme}: ${ee[w]}`,onSelect:()=>m(Kf(w)),keepOpen:!0}),x(`textSize`)&&D.push({id:`textSize`,icon:/* @__PURE__ */ U(Td,{}),label:`${g.textSize}: ${E[T]}`,onSelect:()=>h(qf[T]),keepOpen:!0}),x(`language`)&&i.availableLocales.length>1&&D.push({id:`language`,icon:/* @__PURE__ */ U(Od,{}),label:g.language,segments:i.availableLocales.map(e=>({value:e,label:Yf(e,i.availableLocales),lang:e})),value:i.locale,onSelectValue:p});let k=!!s&&Wu(_,a,i.actions),ne=v&&x(`history`);return/* @__PURE__ */ U(`div`,{class:`${Gf}-header-actions`,children:[ne?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Gf}-icon-btn`,onClick:f,"aria-label":g.history,title:g.history,"data-testid":Y.actionHistory,children:/* @__PURE__ */ U(Dd,{})}):null,D.length>0?/* @__PURE__ */ U(Wf,{items:D,triggerLabel:g.moreActions}):null,k?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Gf}-icon-btn`,onClick:s,"aria-label":g.close,title:g.close,"data-testid":Y.actionClose,children:/* @__PURE__ */ U(od,{})}):null]})}const Qf={Icon:Gd};function $f(e,t){return e instanceof ru?e.status===429?e.retryAfterSeconds?t.errorRateLimitedIn.replace(`{seconds}`,String(e.retryAfterSeconds)):t.errorRateLimited:e.code===`network`?t.errorOffline:e.status===403?t.errorOriginNotAllowed:e.errorCode===`MESSAGE_TOO_LONG`?t.errorMessageTooLong:e.status!==void 0&&e.status>=500?t.errorServer:t.errorGeneric:t.errorGeneric}const ep=i.cssPrefix;function tp({placeholder:e,onActivate:t}){return/* @__PURE__ */ U(`button`,{type:`button`,class:`${ep}-home-search`,onClick:t,"data-testid":Y.homeSearch,children:[/* @__PURE__ */ U(`span`,{class:`${ep}-home-search-text`,children:e}),/* @__PURE__ */ U(`span`,{class:`${ep}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Vd,{})})]})}function np({placeholder:e,value:t,onInput:n}){return/* @__PURE__ */ U(`div`,{class:`${ep}-home-search`,"data-input":`true`,children:[/* @__PURE__ */ U(`input`,{type:`search`,class:`${ep}-home-search-input`,placeholder:e,value:t,maxLength:200,onInput:e=>n(e.currentTarget.value),"data-testid":Y.helpSearch}),/* @__PURE__ */ U(`span`,{class:`${ep}-home-search-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Vd,{})})]})}const rp=i.cssPrefix;function ip({title:e,subtitle:t,onClick:n,testid:r}){return/* @__PURE__ */ U(`button`,{type:`button`,class:`${rp}-list-row`,onClick:n,"data-testid":r,children:[/* @__PURE__ */ U(`span`,{class:`${rp}-list-row-body`,children:[/* @__PURE__ */ U(`span`,{class:`${rp}-list-row-title`,children:e}),t?/* @__PURE__ */ U(`span`,{class:`${rp}-list-row-sub`,children:t}):null]}),/* @__PURE__ */ U(`span`,{class:`${rp}-list-row-chevron`,"aria-hidden":`true`,children:/* @__PURE__ */ U(dd,{})})]})}const ap=i.cssPrefix,op=_.scope(`help`);function sp(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 cp({transport:e,strings:t,bus:n},r,i){let[a,o]=R(),s=B(void 0),c=r?.join(`,`);function l(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&&(op.warn(`listContent (help) failed`,{err:e,page:a}),o(n=>n&&{...n,loading:!1,error:$f(e,t)}))})}return z(()=>{if(!r?.length)o(void 0);else return l(1),()=>{s.current=void 0}},[e,c,i]),[a,()=>!a?.loading&&l((a?.pagination?.page??0)+1)]}function lp(e){let{strings:t,config:n,nav:r,panelProps:i}=e,a=n.contentCollectionIds,[o,s]=R(``),[c,l]=R(``),u=cp(e,a),d=cp(e,c?a:void 0,c),[f,p]=o.trim()?d:u;z(()=>{let e=setTimeout(()=>l(o.trim()),300);return()=>clearTimeout(e)},[o]);function m(){if(!a?.length)return/* @__PURE__ */ U(zf,{message:t.helpEmpty,strings:t});let e=f?.error?/* @__PURE__ */ U(zf,{tone:`error`,message:f.error,onRetry:p,strings:t}):null;return e&&!f?.pagination?e:!f||!f.pagination&&!f.items.length?/* @__PURE__ */ U(zf,{message:t.helpLoading,strings:t}):f.items.length?/* @__PURE__ */ U(L,{children:[sp(f.items,a,f.collections).map(e=>/* @__PURE__ */ U(`section`,{class:`${ap}-help-group`,children:[e.title?/* @__PURE__ */ U(`h2`,{class:`${ap}-help-section-title`,children:e.title}):null,/* @__PURE__ */ U(`div`,{class:`${ap}-help-card`,children:e.rows.map(e=>/* @__PURE__ */ U(ip,{title:e.title,subtitle:e.description,onClick:()=>e.url?$u(e.url):r.push({kind:`content`,id:e.id,title:e.title}),testid:uf(Y.helpArticle,e.id)},e.id))})]},e.id)),e,f.pagination?.hasNext&&!e?/* @__PURE__ */ U(`div`,{children:/* @__PURE__ */ U(`div`,{class:`${ap}-help-card`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${ap}-list-row ${ap}-help-more`,onClick:p,"aria-busy":f.loading,children:[f.loading?/* @__PURE__ */ U(`span`,{class:`${ap}-loading-spinner`,"aria-hidden":`true`}):null,t.helpShowMore]})})}):null]}):/* @__PURE__ */ U(zf,{message:f.search?t.helpSearchEmpty.replace(`{query}`,f.search):t.helpEmpty,strings:t})}return/* @__PURE__ */ U(`div`,{class:`${ap}-module`,children:[/* @__PURE__ */ U(Sf,{title:t.helpTitle,actions:/* @__PURE__ */ U(Zf,{panelProps:i,variant:`plain`})}),/* @__PURE__ */ U(`div`,{class:`${ap}-module-pad`,children:/* @__PURE__ */ U(np,{placeholder:t.helpSearchPlaceholder,value:o,onInput:s})}),/* @__PURE__ */ U(`div`,{class:`${ap}-help-list`,children:m()})]})}const up={Icon:Id,Root:e=>/* @__PURE__ */ U(lp,{...e})},dp=_.scope(`attachments`);function fp(e,t,n){let r=_p(e),i=[],a=[],o=Sp(n.accept),s=t.reduce((e,t)=>e+t.size,0),c=t.length;for(let e of r){let t=gp(e,c,s,n,o);t?a.push({file:e,reason:t}):(i.push(xp(e)),s+=e.size,c+=1)}return(i.length||a.length)&&dp.debug(`ingest`,{accepted:i.length,rejected:a.map(e=>({name:e.file.name,reason:e.reason}))}),{accepted:i,rejected:a}}function pp(e){let t=Math.min(Math.floor(Math.log10(Math.max(e,1))/3),2);return new Intl.NumberFormat(void 0,{style:`unit`,unit:[`byte`,`kilobyte`,`megabyte`][t],unitDisplay:`narrow`,maximumFractionDigits:1}).format(e/1e3**t)}function mp(e,t){let n=Sp(t);return!e||n.length===0||n.some(t=>t.kind===`ext`||Cp(new File([],``,{type:e}),[t]))}function hp(e){try{URL.revokeObjectURL(e.previewUrl)}catch(e){dp.debug(`revokeObjectURL failed`,{error:e})}}function gp(e,t,n,r,i){return t>=r.maxCount?`count`:n+e.size>r.maxBytes?`bytes`:Cp(e,i)?null:`mime`}function _p(e){return e?Array.isArray(e)?e.filter(e=>e instanceof File):[...e].map(e=>e instanceof File?e:vp(e)).filter(e=>e!==null):[]}function vp(e){let t=yp(e)?e:null;return!t?.getAsFile||t.kind!==`file`?null:t.getAsFile()}function yp(e){return bp(e)&&(e.getAsFile===void 0||typeof e.getAsFile==`function`)}function bp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xp(e){return{file:e,id:wr(),mediaType:e.type||`application/octet-stream`,name:e.name||`pasted-file`,previewUrl:URL.createObjectURL(e),size:e.size}}function Sp(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 Cp(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 wp=i.cssPrefix,Tp={error:cf,done:Ed};function Ep({attachment:e,upload:t,strings:n,onRemove:r,disabled:i=!1}){let a=/^image\/(jpeg|png|gif|webp|avif|bmp|x-ms-bmp|svg\+xml)$/i.test(e.mediaType),o=Math.round((t?.fraction??0)*100),s=pp(e.size),c=t?.status===`error`||t?.status===`done`?Tp[t.status]:void 0;return/* @__PURE__ */ U(`span`,{class:`${wp}-attachment-chip`,"data-upload":t?.status,title:e.name,"data-testid":uf(Y.attachmentChip,e.id),children:[a?/* @__PURE__ */ U(`img`,{class:`${wp}-attachment-thumb`,src:e.previewUrl,alt:``}):/* @__PURE__ */ U(`span`,{class:`${wp}-attachment-thumb`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Nd,{})}),/* @__PURE__ */ U(`span`,{class:`${wp}-attachment-text`,children:[/* @__PURE__ */ U(`span`,{class:`${wp}-attachment-name`,children:e.name}),/* @__PURE__ */ U(`span`,{class:`${wp}-attachment-meta`,children:[c?/* @__PURE__ */ U(c,{}):null,t?.status===`uploading`?`${o}% · ${s}`:s]})]}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${wp}-attachment-remove`,onClick:r,disabled:i,"aria-label":n.removeAttachment.replace(`{name}`,e.name),"data-testid":uf(Y.attachmentRemove,e.id),children:/* @__PURE__ */ U(od,{})}),t?.status===`uploading`?/* @__PURE__ */ U(`span`,{class:`${wp}-attachment-progress`,role:`progressbar`,"aria-label":e.name,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":o,children:/* @__PURE__ */ U(`span`,{style:{width:`${o}%`}})}):null]})}const Dp=/* @__PURE__ */ new WeakMap;function Op(e){e.currentTarget&&Dp.set(e.currentTarget,e.timeStamp)}function kp(e){let t=e.currentTarget?Dp.get(e.currentTarget):void 0;return e.isComposing||t!==void 0&&e.timeStamp-t<100}const Ap=i.cssPrefix;function jp({text:e,retryLabel:t,onRetry:n,retryTestId:r}){return/* @__PURE__ */ U(`div`,{class:`${Ap}-error`,role:`alert`,children:[/* @__PURE__ */ U(`span`,{class:`${Ap}-error-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(cf,{})}),/* @__PURE__ */ U(`span`,{class:`${Ap}-error-text`,children:e}),n&&t?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ap}-error-retry`,onClick:n,"data-testid":r,children:t}):null]})}const Mp={isSupported:!1,start:()=>void 0,stop:()=>void 0,cancel:()=>void 0};function Np(e,t,n){return e===`disabled`?Mp:e===`server`?Lp(n):Pp(t)}function Pp(e){let t=Fp();if(!t)return Mp;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(e){l||r!==s||n!==c||(l=!0,n=null,a(e))}c.addEventListener(`end`,()=>u(!1)),c.addEventListener(`error`,e=>u(`error`in e&&(e.error===`not-allowed`||e.error===`service-not-allowed`)));try{c.start()}catch{u(!1)}},stop(){n?.stop()},cancel(){r++;let e=n;n=null,e?.abort()}}}function Fp(){return window.SpeechRecognition??window.webkitSpeechRecognition}const Ip=[`audio/webm;codecs=opus`,`audio/webm`,`audio/ogg;codecs=opus`,`audio/mp4`];function Lp(e){if(typeof MediaRecorder>`u`||!navigator?.mediaDevices?.getUserMedia)return Mp;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(!1))}}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=Rp(),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(e){r(s),n===s&&t===s.generation&&(n=null,o(e instanceof DOMException&&e.name===`NotAllowedError`))}},stop(){let e=n;e&&(e.recorder?e.recorder.state!==`inactive`&&e.recorder.stop():i())},cancel(){i()}}}function Rp(){for(let e of Ip)if(MediaRecorder.isTypeSupported(e))return e}function zp(e,{file:t,reason:n},r){return n===`count`?e.attachmentTooMany.replace(`{count}`,String(r.maxCount)):n===`bytes`?e.attachmentTooLarge.replace(`{name}`,t.name).replace(`{max}`,pp(r.maxBytes)):e.attachmentMimeRejected.replace(`{name}`,t.name)}const Bp=i.cssPrefix,Vp=_.scope(`composer`);function Hp(e){return e.reduce((e,t)=>e+t.size,0)}const Up={arrowUp:ld,paperPlane:cd,send:ud,chevron:dd};function Wp(e){return`activeElement`in e}function Gp(e){return`host`in e&&`activeElement`in e}function Kp(e){return`clipboardData`in e}function qp({options:e,transport:t,feedback:n,bus:r,persistence:i,conversationId:a,maxMessageCharacters:o,isStreaming:s,pageToolRunning:c=!1,isMemoryCompacting:l=!1,canReleaseQueuedMessages:u=!0,queueManualMessages:d=!1,replyAwaitsCard:f=!1,active:p=!0,isPreparing:m=!1,attachmentUploadsSig:h,operatorRequestEnabled:g,canRequestOperator:_=!1,controlMode:v=`ai-agent`,onRequestOperator:y,onSend:b,onStop:x,apiRef:S}){let C=e.strings,[w,ee]=R(()=>i.loadDraft(a)),[T,E]=R([]),[D,O]=R(),[te,k]=R(()=>i.loadMessageQueue(a).map(e=>({id:e.id,text:e.text,attachments:[]}))),ne=B(te),re=B(!1),ie=B(void 0),[A,ae]=R(!1),[j,oe]=R(!1),[se,ce]=R(!1),[le,ue]=R(!1),M=B(!1),de=B(null),fe=B(null),pe=B(null),me=B(0),he=B(a);he.current=a;let ge=B(p);ge.current=p;let N=B(m);N.current=m;let _e=le||m||!p,ve=s&&v===`ai-agent`,ye=ve||l&&v===`ai-agent`,be=v===`ai-agent`&&(ye||d||te.length>0),xe=V(e=>{k(t=>{let n=e(t);return i.saveMessageQueue(he.current,n.filter(e=>e.attachments.length===0).map(({id:e,text:t})=>({id:e,text:t}))),ne.current=n,n})},[i]),Se=V(e=>{xe(t=>(t.find(t=>t.id===e)?.attachments.forEach(hp),t.filter(t=>t.id!==e)))},[xe]),Ce=V(e=>{ee(t=>{let n=(typeof e==`function`?e(t):e).slice(0,o);return n===t?t:(i.saveDraft(he.current,n),n)})},[i,o]),we=e.features.fileUpload,Te=e.features.voice,[P,Ee]=R(()=>Np(Te,e.locale,(e,n)=>t.transcribe(e,n))),De=B(P);De.current=P;let Oe=B({mode:Te,locale:e.locale,transport:t});z(()=>{let n=Oe.current;(n.mode!==Te||n.locale!==e.locale||n.transport!==t)&&(Oe.current={mode:Te,locale:e.locale,transport:t},me.current++,De.current.cancel(),pe.current=null,oe(!1),Ee(Np(Te,e.locale,(e,n)=>t.transcribe(e,n))))},[e.locale,Te,t]),yi(()=>()=>{me.current++,P.cancel()},[P]);let ke=V(e=>{let t=pe.current;if(t===null)return!1;let n=Math.round(performance.now()-t);return Vp[e](`voiceStop`,{durationMs:n}),r.emit(`voiceStop`,{durationMs:n}),pe.current=null,!0},[r]),Ae=V(()=>{pe.current!==null&&(P.stop(),oe(!1),ke(`info`)&&n.play(`voiceStop`))},[ke,n,P]),je=V(()=>{me.current++,P.cancel(),oe(!1),ke(`info`)&&n.play(`voiceStop`)},[ke,n,P]);z(()=>{(m||!p)&&je()},[p,je,m]),z(()=>{let e=de.current;if(!e)return;let t=e.getRootNode(),n=Wp(t)?t.activeElement:null;n&&e.closest(`.${Bp}-panel`)?.contains(n)||e.focus({preventScroll:!0})},[]),z(()=>{let e=de.current;if(!e)return;if(w.length===0){e.style.height=``;return}e.style.height=`auto`;let t=getComputedStyle(e),n=Number.parseFloat(t.getPropertyValue(`--${Bp}-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`},[w]);let Me=B(T);Me.current=T,z(()=>()=>{Me.current.forEach(hp);for(let e of ne.current)e.attachments.forEach(hp)},[]),yi(()=>{if(S)return S.current={attachFromDrop:t=>{if(!we||!ge.current||M.current||N.current)return;let n=fp(t,Me.current,e.attachments);O(n.rejected[0]),n.accepted.length!==0&&(Vp.info(`attach (drop)`,{count:n.accepted.length,totalBytes:Hp(n.accepted)}),r.emit(`attach`,{count:n.accepted.length,totalBytes:Hp(n.accepted)}),E(e=>[...e,...n.accepted]))},fill:e=>{if(!ge.current||M.current||N.current)return;Ce(e);let t=de.current;t&&(t.focus({preventScroll:!0}),requestAnimationFrame(()=>t.setSelectionRange(t.value.length,t.value.length)))},acceptQueuedMessage:Se},()=>{S.current&&(S.current=null)}},[S,we,m,e.attachments,Se,Ce]),z(()=>{let t=de.current;if(!t)return;let n=t.closest(`.${Bp}-panel`);if(!n)return;let i=n=>{if(!ge.current||M.current||N.current)return;let i=n.clipboardData;if(!i)return;let a=n.target instanceof HTMLElement?n.target.closest(`input, textarea, [contenteditable]:not([contenteditable='false'])`):null;if(a&&a!==t)return;if(we){let t=fp(i.items,Me.current,e.attachments);if(O(t.rejected[0]),t.accepted.length>0){n.preventDefault(),Vp.info(`attach (paste)`,{count:t.accepted.length,totalBytes:Hp(t.accepted)}),r.emit(`attach`,{count:t.accepted.length,totalBytes:Hp(t.accepted)}),E(e=>[...e,...t.accepted]);return}}if(a===t)return;let o=i.getData(`text/plain`);o&&(n.preventDefault(),Ce(e=>e+o),t.focus())};function a(e){Kp(e)&&i(e)}return n.addEventListener(`paste`,a),()=>n.removeEventListener(`paste`,a)},[we,e.attachments,Ce]);async function Ne(){let e=w.trim();if(!e&&T.length===0||!p||ve||M.current||m)return;je(),M.current=!0,ue(!0);let t=w,n=T;try{await b(e,n)&&(O(void 0),Ce(e=>e===t?``:e),E(e=>e===n?(n.forEach(hp),Me.current=[],[]):e))}finally{M.current=!1,ue(!1),requestAnimationFrame(()=>{let e=de.current;if(!e||e.disabled||!ge.current)return;let t=e.getRootNode(),n=Wp(t)?t.activeElement:null,r=n?.getAttribute(`data-testid`);if(!(n&&n!==e&&r!==Y.composerSend&&r!==Y.composerStop)){if(Gp(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 F(){let e=w.trim();if(!e&&T.length===0||!p||!be||M.current||m)return;je();let t=T;xe(n=>[...n,{id:wr(),text:e,attachments:t}]),ye||ae(!0),Ce(``),E(e=>e===t?(Me.current=[],[]):e),de.current?.focus({preventScroll:!0})}z(()=>{ye&&(re.current=!1,ie.current=void 0,ae(!1))},[ye]),z(()=>{let t=te[0];if(!t||!u||ye||re.current||le||m||!p)return;let n=f&&!A?(ie.current??(ie.current=performance.now()+e.cardAnswerWaitSeconds*1e3))-performance.now():0,r=setTimeout(()=>{re.current=!0,b(t.text,t.attachments,t.id).then(e=>{e?Se(t.id):re.current=!1})},Math.max(n,300));return()=>clearTimeout(r)},[p,u,A,m,b,e.cardAnswerWaitSeconds,ye,te,Se,f,le]);function Pe(e){e.key!==`Enter`||e.shiftKey||kp(e)||(e.preventDefault(),be&&(w.trim()||T.length>0)?F():ve?x():Ne())}function Fe(t){if(!(t.target instanceof HTMLInputElement))return;let n=t.target;if(!p||M.current||m){n.value=``;return}let i=fp(n.files,T,e.attachments);O(i.rejected[0]),i.accepted.length>0&&(Vp.info(`attach (file picker)`,{count:i.accepted.length,totalBytes:Hp(i.accepted)}),r.emit(`attach`,{count:i.accepted.length,totalBytes:Hp(i.accepted)}),E(e=>[...e,...i.accepted])),n.value=``}function Ie(e){!p||M.current||m||(Vp.info(`removeAttachment`,{id:e}),r.emit(`removeAttachment`,{id:e}),O(void 0),E(t=>{let n=t.find(t=>t.id===e);return n&&hp(n),t.filter(t=>t.id!==e)}))}function Le(){if(j){Ae();return}if(!p||!P.isSupported||M.current||m)return;let e=++me.current;pe.current=performance.now(),Vp.info(`voiceStart`),r.emit(`voiceStart`,void 0),ce(!1),oe(!0),n.play(`voiceStart`),P.start((t,n)=>{me.current===e&&ge.current&&!N.current&&!M.current&&n&&Ce(e=>`${e}${t} `)},t=>{me.current===e&&ge.current&&(oe(!1),ce(t),ke(`debug`))})}let Re=Up[e.composer.sendButton.icon],ze=!!(w.trim()||T.length>0),Be=h?.value,Ve=T.some(e=>Be?.get(e.id)?.status===`uploading`),He=T.filter(e=>Be?.get(e.id)?.status===`error`),Ue=He.find(e=>Be?.get(e.id)?.refusal),We=Ue&&(Be?.get(Ue.id)?.refusal===`INVALID_FILE_TYPE`?C.attachmentMimeRejected:C.attachmentUploadFailed).replace(`{name}`,Ue.name),Ge=ve||Ve||c&&!ze;return/* @__PURE__ */ U(`div`,{class:`${Bp}-composer`,part:`composer`,"data-testid":Y.composer,children:[te.length>0?/* @__PURE__ */ U(`div`,{class:`${Bp}-message-queue`,"aria-label":C.queueMessage,"data-testid":Y.messageQueue,children:te.map(e=>/* @__PURE__ */ U(`div`,{class:`${Bp}-attachment-chip ${Bp}-queued-message`,"data-testid":`${Y.queuedMessage}-${e.id}`,children:[/* @__PURE__ */ U(`span`,{class:`${Bp}-attachment-name ${Bp}-queued-text`,children:e.text||e.attachments.map(e=>e.name).join(`, `)}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Bp}-attachment-remove`,onClick:()=>Se(e.id),"aria-label":C.removeQueuedMessage,title:C.removeQueuedMessage,"data-testid":`${Y.queuedMessageRemove}-${e.id}`,children:/* @__PURE__ */ U(od,{})})]},e.id))}):null,T.length>0?/* @__PURE__ */ U(`div`,{class:`${Bp}-attachments`,children:T.map(e=>/* @__PURE__ */ U(Ep,{attachment:e,upload:Be?.get(e.id),strings:C,onRemove:()=>Ie(e.id),disabled:_e},e.id))}):null,He.length>0&&!_e?/* @__PURE__ */ U(jp,{text:We??C.attachmentUploadFailed.replace(`{name}`,He.map(e=>e.name).join(`, `)),retryLabel:C.errorRetry,onRetry:Ue?void 0:()=>void Ne(),retryTestId:Y.attachmentRetry}):null,D?/* @__PURE__ */ U(`p`,{class:`${Bp}-field-error`,role:`alert`,children:zp(C,D,e.attachments)}):null,se?/* @__PURE__ */ U(`p`,{class:`${Bp}-field-error`,role:`alert`,children:C.micBlocked}):null,o!==void 0&&w.length>=o*.9?/* @__PURE__ */ U(`p`,{class:`${Bp}-field-${w.length<o?`hint`:`error`}`,"data-testid":Y.composerCount,children:`${w.length} / ${o}`}):null,/* @__PURE__ */ U(`div`,{class:`${Bp}-composer-row`,children:[/* @__PURE__ */ U(`div`,{class:`${Bp}-composer-actions`,children:[we?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Bp}-icon-btn`,onClick:()=>fe.current?.click(),disabled:_e,"aria-label":C.attach,title:C.attach,"data-testid":Y.composerAttach,children:/* @__PURE__ */ U(pd,{})}):null,P.isSupported?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Bp}-icon-btn`,onClick:Le,disabled:_e,"aria-label":j?C.micStop:C.micStart,title:j?C.micStop:C.micStart,"aria-pressed":j,"data-recording":j?`true`:void 0,"data-testid":Y.composerVoice,children:/* @__PURE__ */ U(md,{})}):null,g&&v===`ai-agent`&&y?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Bp}-icon-btn`,onClick:y,disabled:_e||!_,"aria-label":C.talkToOperator,title:C.talkToOperator,"data-testid":Y.operatorRequest,children:/* @__PURE__ */ U(hd,{})}):null]}),/* @__PURE__ */ U(`textarea`,{ref:de,name:`message`,class:`${Bp}-textarea`,rows:1,value:w,maxLength:o,placeholder:C.composerPlaceholder,onInput:e=>Ce(e.currentTarget.value),onKeyDown:Pe,onCompositionEnd:Op,disabled:_e,"aria-label":C.composerPlaceholder,"data-testid":Y.composerInput}),be&&ze?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Bp}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:F,disabled:_e,"aria-label":C.queueMessage,title:C.queueMessage,"data-testid":Y.composerSend,children:/* @__PURE__ */ U(Re,{})}):null,Ge?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Bp}-send`,onClick:x,disabled:_e&&!Ve,"aria-label":C.stop,"data-testid":Y.composerStop,children:/* @__PURE__ */ U(fd,{})}):null,!Ge&&(!be||!ze)?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Bp}-send`,"data-shape":e.composer.sendButton.shape,"data-variant":e.composer.sendButton.variant,onClick:()=>void Ne(),disabled:_e||!w.trim()&&T.length===0,"aria-label":C.send,"data-testid":Y.composerSend,children:/* @__PURE__ */ U(Re,{})}):null]}),/* @__PURE__ */ U(`input`,{ref:fe,name:`attachments`,type:`file`,multiple:!0,accept:e.attachments.accept,onChange:Fe,disabled:_e,class:`${Bp}-sr-only`,"data-testid":Y.composerFileInput})]})}const Jp=i.cssPrefix;function Yp({onClick:e,children:t,testid:n}){return e?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Jp}-home-card`,"data-interactive":`true`,onClick:e,"data-testid":n,children:t}):/* @__PURE__ */ U(`div`,{class:`${Jp}-home-card`,"data-testid":n,children:t})}function Xp(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}const Zp=i.cssPrefix,Qp=_.scope(`news`);function $p(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 em({options:e,transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}){let c=r.contentCollectionIds,l=c?.join(`,`),[u,d]=R({items:[],loading:!0}),f=B(void 0);function p(e){if(!c?.length)return;let r={};f.current=r,d(e=>({...e,loading:!0,error:void 0})),t.listContent({contentCollectionIds:c,sortBy:`publishedAt`,sortOrder:`desc`,page:e,limit:10}).then(t=>{if(f.current!==r||(d(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=>{f.current===r&&(Qp.warn(`listContent (news) failed`,{err:t,page:e}),d(e=>({...e,loading:!1,error:$f(t,n)})))})}function m(){u.loading||p((u.pagination?.page??0)+1)}z(()=>(d({items:[],loading:!0}),p(1),()=>{f.current=void 0}),[t,l]);function h(t){let n=$p(t.publishedAt,e.locale);return/* @__PURE__ */ U(`button`,{type:`button`,class:`${Zp}-news-card`,onClick:()=>i.push({kind:`content`,id:t.id,title:t.title}),"data-testid":uf(Y.newsItem,t.id),children:[t.image?/* @__PURE__ */ U(`img`,{class:`${Zp}-news-hero`,src:t.image,alt:``,loading:`lazy`}):null,/* @__PURE__ */ U(`span`,{class:`${Zp}-news-body`,children:[/* @__PURE__ */ U(`span`,{class:`${Zp}-news-title`,children:t.title}),n||t.tags?.length?/* @__PURE__ */ U(`span`,{class:`${Zp}-news-meta`,children:[n?/* @__PURE__ */ U(`time`,{dateTime:t.publishedAt,children:n}):null,t.tags?.map(e=>/* @__PURE__ */ U(`span`,{class:`${Zp}-news-tag`,children:e},e))]}):null,t.description?/* @__PURE__ */ U(`span`,{class:`${Zp}-news-summary`,children:t.description}):null]})]},t.id)}function g(){if(!c?.length)return/* @__PURE__ */ U(zf,{message:n.newsEmpty,strings:n});let e=u.error?/* @__PURE__ */ U(zf,{tone:`error`,message:u.error,onRetry:m,strings:n}):null;return e&&!u.pagination?e:u.pagination?u.items.length?/* @__PURE__ */ U(`div`,{class:`${Zp}-news-list`,children:[u.items.map(h),e,u.pagination.hasNext&&!e?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Zp}-news-more`,onClick:m,"aria-busy":u.loading,"data-testid":Y.newsMore,children:[u.loading?/* @__PURE__ */ U(`span`,{class:`${Zp}-loading-spinner`,"aria-hidden":`true`}):null,n.newsShowMore]}):null]}):/* @__PURE__ */ U(zf,{message:n.newsEmpty,strings:n}):/* @__PURE__ */ U(zf,{message:n.newsLoading,strings:n})}return/* @__PURE__ */ U(`div`,{class:`${Zp}-module`,children:[/* @__PURE__ */ U(Sf,{title:n.newsTitle,actions:/* @__PURE__ */ U(Zf,{panelProps:o,variant:`plain`})}),/* @__PURE__ */ U(`div`,{class:`${Zp}-module-scroll`,children:g()})]})}const tm={Icon:Wd,Root:e=>/* @__PURE__ */ U(em,{...e})},X=i.cssPrefix,nm=_.scope(`home`);function rm(e){let t=e.options.userContext?.name,n=e.config.greetingText?Pt(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 im(e,t){return t.url?$u(t.url):e.push({kind:`content`,id:t.id,title:t.title})}function am({options:e,onAsk:t}){let[n,r]=R(``),{sendButton:i}=e.composer,a=Up[i.icon];function o(e){e.preventDefault();let i=n.trim();i&&(r(``),t(i))}return/* @__PURE__ */ U(`form`,{class:`${X}-home-search ${X}-home-ask`,"data-input":`true`,onSubmit:o,"data-testid":Y.homeAsk,children:[/* @__PURE__ */ U(`input`,{type:`text`,class:`${X}-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:`${X}-send`,"data-shape":i.shape,"data-variant":i.variant,disabled:!n.trim(),"aria-label":e.strings.send,children:/* @__PURE__ */ U(a,{})})]})}function om(e,t){return bu(e,t,t.type!==`upsert`||t.activity===!0)}function sm(e){let{transport:t,strings:n,config:r,nav:i,bus:a,panelProps:o,latestNews:s}=e,[c,l]=R(null),[u,d]=R([]),f=r.contentCollectionIds?.join(`,`),p=e.options.modules.list.some(e=>e.layout===`chat`);z(()=>{if(r.showRecentConversations===!1)return;let e=!1,n=!0,i=[],a=t.subscribeConversationChanges(e=>{n&&i.push(e),l(t=>om(t?[t]:[],e)[0]??null)});return t.listConversations({limit:p?50:1}).then(t=>{if(e)return;let r=i.reduce(om,t.conversations);i=[],n=!1,l(r[0]??null)}).catch(t=>{e||(i=[],n=!1,nm.warn(`listConversations (home) failed`,{err:t}))}),()=>{e=!0,a()}},[t,r.showRecentConversations,p]),z(()=>{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&&nm.warn(`listContent (home) failed`,{err:t})),()=>{e=!0}},[t,f,a]);let m=rm(e),h=r.userAvatars??[],g=r.status,_=g?.text?Pt(n,g.text):n.homeStatus,v=g?.url,y=r.contentBlockTitle?Pt(n,r.contentBlockTitle):n.homeContentTitle,b=s.item,x=$p(b?.publishedAt,e.options.locale);return/* @__PURE__ */ U(`div`,{class:`${X}-module ${X}-home`,"data-testid":Y.homeView,children:/* @__PURE__ */ U(`div`,{class:`${X}-home-scroll`,children:[/* @__PURE__ */ U(`div`,{class:`${X}-home-hero`,children:[/* @__PURE__ */ U(`div`,{class:`${X}-home-hero-top`,children:[r.brandName?/* @__PURE__ */ U(`span`,{class:`${X}-home-brand`,"data-testid":Y.homeBrand,children:r.brandName}):/* @__PURE__ */ U(`span`,{class:`${X}-home-brand-spacer`,"aria-hidden":`true`}),/* @__PURE__ */ U(`div`,{class:`${X}-home-hero-actions`,children:[h.length>0?/* @__PURE__ */ U(`div`,{class:`${X}-home-avatars`,children:h.map(e=>/* @__PURE__ */ U(`span`,{class:`${X}-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:Xp(e.name)})},e.name))}):null,/* @__PURE__ */ U(Zf,{panelProps:o,variant:`plain`})]})]}),r.showGreeting===!1?null:/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`h1`,{class:`${X}-home-greeting`,"data-testid":Y.homeGreeting,children:m.title}),m.subtitle?/* @__PURE__ */ U(`p`,{class:`${X}-home-lead`,children:m.subtitle}):null]})]}),/* @__PURE__ */ U(`div`,{class:`${X}-home-cards`,children:[p?/* @__PURE__ */ U(am,{options:e.options,onAsk:e=>i.startNewConversation(e)}):null,r.showSearchBar===!1?null:/* @__PURE__ */ U(tp,{placeholder:n.homeSearchPlaceholder,onActivate:()=>i.switchToLayout(`help`)}),b?/* @__PURE__ */ U(Yp,{onClick:()=>{s.markSeen(b.id),i.push({kind:`content`,id:b.id,title:b.title})},testid:Y.homeWhatsNew,children:/* @__PURE__ */ U(`div`,{class:`${X}-home-recent-row`,"data-unread":s.unseen?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Wd,{})}),/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-body`,children:[/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-title`,children:n.homeWhatsNew}),/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-preview`,children:x?`${b.title} · ${x}`:b.title})]}),s.unseen?/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-dot`,role:`img`,"aria-label":n.newsUnseen}):null]})}):null,c?/* @__PURE__ */ U(Yp,{onClick:()=>i.selectConversation(c),testid:Y.homeRecent,children:/* @__PURE__ */ U(`div`,{class:`${X}-home-recent-row`,"data-unread":c.hasUnread?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Gd,{})}),/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-body`,children:[/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-title`,children:c.title}),c.preview?/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-preview`,children:Lf(c.preview)}):null]}),c.hasUnread?/* @__PURE__ */ U(`span`,{class:`${X}-home-recent-dot`,role:`img`,"aria-label":n.unread}):null]})}):null,g?/* @__PURE__ */ U(Yp,{onClick:v?()=>$u(v):void 0,children:/* @__PURE__ */ U(`div`,{class:`${X}-home-status`,"data-level":g.level??`operational`,children:[/* @__PURE__ */ U(`span`,{class:`${X}-home-status-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Hd,{})}),/* @__PURE__ */ U(`span`,{class:`${X}-home-status-text`,children:_})]})}):null,u.length>0?/* @__PURE__ */ U(`section`,{class:`${X}-home-content`,children:[/* @__PURE__ */ U(`div`,{class:`${X}-home-content-title`,children:y}),/* @__PURE__ */ U(`div`,{class:`${X}-home-content-list`,children:u.map(e=>/* @__PURE__ */ U(ip,{title:e.title,subtitle:e.description,onClick:()=>im(i,e),testid:uf(Y.homeContentRow,e.id)},e.id))})]}):null]})]})})}const cm={chat:Qf,home:{Icon:Ud,Root:e=>/* @__PURE__ */ U(sm,{...e})},help:up,news:tm},lm=i.cssPrefix;function um({modules:e,activeTab:t,strings:n,hasUnread:r,onSelect:i}){return/* @__PURE__ */ U(`nav`,{class:`${lm}-tabbar`,role:`tablist`,"aria-label":n.panelTitle,children:e.map(e=>{let a=cm[e.layout].Icon,o=e.id===t,s=e.layout===`chat`&&r;return/* @__PURE__ */ U(`button`,{type:`button`,role:`tab`,"aria-selected":o,class:`${lm}-tab`,onClick:()=>i(e.id),"data-testid":uf(Y.tab,e.id),children:[/* @__PURE__ */ U(`span`,{class:`${lm}-tab-icon`,children:[/* @__PURE__ */ U(a,{}),s?/* @__PURE__ */ U(`span`,{class:`${lm}-tab-badge`,"data-testid":Y.tabBadge,role:`img`,"aria-label":n.unread}):null]}),/* @__PURE__ */ U(`span`,{class:`${lm}-tab-label`,children:Pt(n,e.label)})]},e.id)})})}const dm=i.cssPrefix;function fm({agent:e,strings:t,ticketReference:n,person:r=!1}){let i=e.status??`online`,a=Pt(t,e.name),o=e.title?Pt(t,e.title):null,s=r?/* @__PURE__ */ U(hd,{}):/* @__PURE__ */ U(`span`,{children:Xp(a)});return/* @__PURE__ */ U(`div`,{class:`${dm}-agent`,children:[/* @__PURE__ */ U(`div`,{class:`${dm}-agent-avatar`,"data-status":i,children:e.avatar?/* @__PURE__ */ U(`img`,{src:e.avatar,alt:``}):s}),/* @__PURE__ */ U(`div`,{class:`${dm}-agent-meta`,children:[/* @__PURE__ */ U(`strong`,{children:a}),o||n?/* @__PURE__ */ U(`div`,{class:`${dm}-agent-sub`,children:[n?/* @__PURE__ */ U(pm,{reference:n,strings:t}):null,o?/* @__PURE__ */ U(`span`,{children:o}):null]}):null]})]})}function pm({reference:e,strings:t}){let[n,r]=R(!1);function i(){navigator.clipboard?.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)}).catch(()=>{})}return/* @__PURE__ */ U(`button`,{type:`button`,class:`${dm}-agent-ticket`,onClick:i,title:t.copy,"aria-label":n?t.copied:t.copyTicketReference.replace(`{reference}`,e),children:n?t.copied:e})}const mm=[`today`,`yesterday`,`lastWeek`,`older`];function hm(e,t){let n=Date.parse(t);if(!Number.isFinite(n))return`older`;let r=Math.round((_m(e)-_m(n))/864e5);return r<=0?`today`:r===1?`yesterday`:r<7?`lastWeek`:`older`}function gm(e,t){let n=/* @__PURE__ */ new Map;for(let r of t){let t=hm(e,r.lastMessageAt),i=n.get(t);i?i.push(r):n.set(t,[r])}return mm.flatMap(e=>{let t=n.get(e);return t?[{bucket:e,conversations:t}]:[]})}function _m(e){return new Date(e).setHours(0,0,0,0)}const vm=_.scope(`history`),ym={today:`dateToday`,yesterday:`dateYesterday`,lastWeek:`dateLastWeek`,older:`dateOlder`};function bm(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=bu(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=bu(e.conversations,t,n);return r===e.conversations?e:{...t.type===`snapshot`?t.result:e,conversations:r}}function xm(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 Sm({transport:e,strings:t,locale:n,persistence:r,onSelect:a,onNewConversation:o}){let s=i.cssPrefix,c=e.peekConversations({limit:50}),[l,u]=R(c?`loaded`:`loading`),[d,f]=R(0),[p,m]=R(c),[h,g]=R(!1),_=B(void 0),v=p?.conversations??[],y=p?.pagination;z(()=>{let n=!1,i=!0,a=[],o=e.subscribeConversationChanges(e=>{i&&a.push(e),m(t=>t&&bm(t,e))});_.current=void 0,g(!1);let s=e.peekConversations({limit:50});return m(s),u(s?`loaded`:`loading`),e.listConversations({limit:50}).then(e=>{if(n)return;let t=e;for(let e of a)t=bm(t,e);a=[],i=!1,m(t),u(`loaded`),r.saveHistoryCount(t.conversations.length)}).catch(e=>{n||(a=[],i=!1,vm.warn(`listConversations failed`,{err:e}),u({failure:$f(e,t)}))}),()=>{n=!0,o(),_.current=void 0}},[e,r,n,d]);async function b(){if(_.current||!y?.hasNext)return;let t={};_.current=t,g(!0);try{let n=await e.listConversations({page:y.page+1,limit:y.limit});if(_.current!==t)return;m(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(_.current!==t)return;vm.warn(`listConversations page failed`,{err:e,page:y.page+1})}finally{_.current===t&&(_.current=void 0,g(!1))}}let x=o?/* @__PURE__ */ U(`div`,{class:`${s}-history-footer`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${s}-history-new`,onClick:o,"data-testid":Y.sidebarNewConversation,children:[/* @__PURE__ */ U(sd,{}),t.newConversation]})}):null;if(l===`loading`){let e=Math.min(r.loadHistoryCount()??3,6);return/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`div`,{class:`${s}-history`,"aria-busy":`true`,"aria-label":t.historyLoading,children:/* @__PURE__ */ U(`div`,{class:`${s}-history-group`,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`div`,{class:`${s}-history-heading`,children:/* @__PURE__ */ U(`span`,{class:`${s}-skeleton ${s}-skeleton-heading`})}),/* @__PURE__ */ U(`div`,{class:`${s}-history-card`,children:Array.from({length:Math.max(1,e)},(e,t)=>/* @__PURE__ */ U(`div`,{class:`${s}-history-item ${s}-history-item-skeleton`,children:[/* @__PURE__ */ U(`span`,{class:`${s}-history-avatar ${s}-skeleton`}),/* @__PURE__ */ U(`span`,{class:`${s}-history-body`,children:[/* @__PURE__ */ U(`span`,{class:`${s}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${s}-history-title`,children:/* @__PURE__ */ U(`span`,{class:`${s}-skeleton ${s}-skeleton-title`})}),/* @__PURE__ */ U(`span`,{class:`${s}-history-time`,children:/* @__PURE__ */ U(`span`,{class:`${s}-skeleton ${s}-skeleton-time`})})]}),/* @__PURE__ */ U(`span`,{class:`${s}-history-row`,children:/* @__PURE__ */ U(`span`,{class:`${s}-history-preview`,children:/* @__PURE__ */ U(`span`,{class:`${s}-skeleton ${s}-skeleton-preview`})})})]})]},t))})]})}),x]})}if(typeof l==`object`)return/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(zf,{tone:`error`,message:l.failure,onRetry:()=>f(e=>e+1),strings:t}),x]});if(v.length===0)return/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`div`,{class:`${s}-history-empty`,children:t.historyEmpty}),x]});let S=Date.now(),C=gm(S,v);return/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`div`,{class:`${s}-history`,role:`list`,children:[C.map(e=>/* @__PURE__ */ U(`div`,{class:`${s}-history-group`,children:[/* @__PURE__ */ U(`div`,{class:`${s}-history-heading`,children:t[ym[e.bucket]]}),/* @__PURE__ */ U(`div`,{class:`${s}-history-card`,children:e.conversations.map(e=>/* @__PURE__ */ U(`div`,{role:`listitem`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${s}-history-item`,onClick:()=>a(e),"data-unread":e.hasUnread?`true`:void 0,"data-testid":uf(Y.historyItem,e.conversationId),children:[/* @__PURE__ */ U(`span`,{class:`${s}-history-avatar`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Fd,{})}),/* @__PURE__ */ U(`span`,{class:`${s}-history-body`,children:[/* @__PURE__ */ U(`span`,{class:`${s}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${s}-history-title`,children:e.title}),/* @__PURE__ */ U(`span`,{class:`${s}-history-time`,children:[e.ticketReference&&`${e.ticketReference} · `,xm(e.lastMessageAt,S,n)]})]}),/* @__PURE__ */ U(`span`,{class:`${s}-history-row`,children:[/* @__PURE__ */ U(`span`,{class:`${s}-history-preview`,children:e.preview&&Lf(e.preview)||t.historyContinue}),e.hasUnread?/* @__PURE__ */ U(`span`,{class:`${s}-history-dot`,role:`img`,"aria-label":t.unread}):null]})]})]})},e.conversationId))})]},e.bucket)),y?.hasNext?/* @__PURE__ */ U(`div`,{class:`${s}-history-more`,children:/* @__PURE__ */ U(`button`,{type:`button`,onClick:b,disabled:h,"aria-busy":h,"data-testid":Y.historyLoadMore,children:t.loadMoreConversations})}):null]}),x]})}const Cm=i.cssPrefix;function wm({state:e,strings:t}){return e?/* @__PURE__ */ U(`div`,{class:`${Cm}-dropzone`,"data-state":e,role:`status`,"aria-live":`polite`,children:[/* @__PURE__ */ U(`span`,{class:`${Cm}-dropzone-icon`,"aria-hidden":`true`,children:U(e===`reject`?cf:pd,{})}),e===`reject`?t.dropZoneRejected:t.dropZone]}):null}const Tm=new RegExp(String.raw`^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$`),Em=/^[+]?[\d\s().-]{6,}$/;function Dm(e,t,n){let r=Array.isArray(t)?t.join(``):t?.trim()??``;if(!r)return e.required?n.formRequired:void 0;if(e.type===`email`&&!Tm.test(r))return n.formInvalidEmail;if(e.type===`tel`&&!Em.test(r))return n.formInvalidTel;if(e.type===`number`&&!Number.isFinite(Number(r)))return n.formInvalidNumber}function Om(e,t,n){return Object.fromEntries(e.flatMap(e=>{let r=Dm(e,t[e.name],n);return r?[[e.name,r]]:[]}))}const km=i.cssPrefix;function Am(e){return e.tokenEmail||e.userContext?.email?.trim()}function jm(e,t){let n=e instanceof ru?e.status:void 0;return n===400?t.formInvalidEmail:n===409?t.emailTranscriptAlreadySent:n===422?t.emailTranscriptNotDelivered:n===429?t.emailTranscriptLimited:t.emailTranscriptFailed}function Mm(e){return`host`in e&&`activeElement`in e}function Nm({transport:e,strings:t,knownEmail:n,onClose:r}){let[i,a]=R(n??``),[o,s]=R(!1),[c,l]=R({status:`idle`}),u=B(null),d=xi(),f=`${d}-title`,p=`${d}-error`,m=c.status===`sending`,h=c.status===`sent`;yi(()=>{let e=u.current;if(!e)return;let t=e.getRootNode(),n=Mm(t)?t.activeElement:null,r=bf(e);return()=>{r(),n instanceof HTMLElement&&n.isConnected&&n.focus({preventScroll:!0})}},[]),yi(()=>{u.current?.querySelector(`[data-autofocus]`)?.focus({preventScroll:!0})},[h]);async function g(n){if(n.preventDefault(),m)return;let r=i.trim();if(!Tm.test(r)){s(!0),u.current?.querySelector(`input`)?.focus();return}s(!1),l({status:`sending`});let a=await e.emailTranscript(r).then(e=>({status:`sent`,to:e.to}),e=>({status:`failed`,message:jm(e,t)}));l(a)}function _(e){e.key===`Tab`&&e.stopPropagation(),e.key===`Escape`&&(e.stopPropagation(),r())}return/* @__PURE__ */ U(`div`,{class:`${km}-transcript-layer`,children:[/* @__PURE__ */ U(`div`,{class:`${km}-transcript-backdrop`,"aria-hidden":`true`,onClick:r}),/* @__PURE__ */ U(`section`,{ref:u,class:`${km}-transcript-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":f,onKeyDown:_,"data-testid":Y.emailTranscriptSheet,children:[/* @__PURE__ */ U(`header`,{class:`${km}-transcript-sheet-head`,children:[/* @__PURE__ */ U(`span`,{class:`${km}-transcript-sheet-icon`,children:/* @__PURE__ */ U(jd,{})}),/* @__PURE__ */ U(`h2`,{id:f,class:`${km}-transcript-sheet-title`,children:t.emailTranscript}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${km}-icon-btn`,onClick:r,"aria-label":t.emailTranscriptCancel,title:t.emailTranscriptCancel,children:/* @__PURE__ */ U(od,{})})]}),c.status===`sent`?/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`p`,{class:`${km}-transcript-sheet-text ${km}-transcript-sheet-sent`,role:`status`,children:[/* @__PURE__ */ U(af,{}),/* @__PURE__ */ U(`span`,{children:t.emailTranscriptSent.replace(`{email}`,c.to)})]}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${km}-form-submit ${km}-transcript-sheet-action`,onClick:r,"data-autofocus":!0,children:t.emailTranscriptDone})]}):/* @__PURE__ */ U(`form`,{class:`${km}-transcript-sheet-form`,onSubmit:e=>void g(e),noValidate:!0,children:[/* @__PURE__ */ U(`p`,{class:`${km}-transcript-sheet-text`,children:t.emailTranscriptPrompt}),/* @__PURE__ */ U(`label`,{class:`${km}-field`,"data-invalid":o?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${km}-field-label`,children:t.emailTranscriptEmailLabel}),/* @__PURE__ */ U(`input`,{class:`${km}-field-input`,type:`email`,name:`email`,autocomplete:`email`,inputMode:`email`,autocapitalize:`off`,spellcheck:!1,value:i,readOnly:m,"aria-invalid":o,"aria-describedby":o?p:void 0,onInput:e=>{a(e.currentTarget.value),s(!1)},"data-autofocus":!0,"data-testid":Y.emailTranscriptEmail}),o?/* @__PURE__ */ U(`span`,{id:p,class:`${km}-field-error`,role:`alert`,children:t.formInvalidEmail}):null]}),/* @__PURE__ */ U(`button`,{type:`submit`,class:`${km}-form-submit ${km}-transcript-sheet-action`,disabled:m,"aria-busy":m,"data-testid":Y.emailTranscriptSend,children:m?t.emailTranscriptSending:t.emailTranscriptSend}),c.status===`failed`?/* @__PURE__ */ U(`p`,{class:`${km}-field-error`,role:`alert`,children:c.message}):null]})]})]})}var Pm=Object.assign;function Fm(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 Im=/^(-|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|asp|fill|st)/;function Lm(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:Fm(this.props,e)}function r(t){return this.shouldComponentUpdate=n,Ze(e,t)}return r.displayName=`Memo(`+(e.displayName||e.name)+`)`,r.prototype.isReactComponent=!0,r.type=e,r}var Rm=Symbol.for(`react.element`),zm=/^(?: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]/,Bm=/[A-Z0-9]/g,Vm=typeof document<`u`,Hm=function(e){return/fil|che|rad/.test(e)};$e.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty($e.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Um=F.event;F.event=function(e){return Um&&(e=Um(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var Wm={configurable:!0,get:function(){return this.class}},Gm=F.vnode;F.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||Vm&&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`||Im.test(c)||(s||(s=o=Pm({},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`||Hm(t.type)?l==`onfocus`?a=`onfocusin`:l==`onblur`&&(a=`onfocusout`):l=a=`oninput`,l==`oninput`&&r[a=l]&&(a=`oninputCapture`)}else i&&zm.test(a)?a=a.replace(Bm,`-$&`).toLowerCase():o===null&&(o=void 0);r[a]=o}}if(n==`select`){var u=r.defaultValue==null?r.multiple&&Array.isArray(r.value)?r.value:null:r.defaultValue;u!=null&&(r.value=ct(t.children).forEach(function(e){e.props.selected=r.multiple?u.indexOf(e.props.value)!=-1:u==e.props.value}))}t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",Wm)):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=Pm({},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=Rm,Gm&&Gm(e)};const Km=i.cssPrefix;function qm({messageId:e,initial:t,strings:n,onFeedback:r}){let[i,a]=R(t);z(()=>a(t),[e,t]);function o(t){let n=i===t?null:t;a(n),r(e,n)}return/* @__PURE__ */ U(`div`,{class:`${Km}-feedback`,role:`group`,"data-testid":Y.messageFeedback,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${Km}-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":Y.feedbackUp,children:/* @__PURE__ */ U(ef,{})}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Km}-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":Y.feedbackDown,children:/* @__PURE__ */ U(tf,{})}),/* @__PURE__ */ U(`span`,{class:`${Km}-sr-only`,role:`status`,"aria-live":`polite`,children:i?n.feedbackThanks:``})]})}function Jm(e){return e.partsSig.value.some(e=>e.kind===`text`&&e.textSig.value.length>0)}function Ym(e){return e.partsSig.value.some(e=>e.kind===`reasoning`)}function Xm(e){return e.streaming&&!e.bufferedHold&&!(e.reasoningVisible&&e.working)}function Zm(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:Xm({streaming:t,bufferedHold:a,reasoningVisible:n,working:o}),emptyReply:r,hidden:i}}const Qm=i.cssPrefix;function $m({part:e,strings:t}){let n=e.title||e.filename||e.url||t.sources;return e.url?/* @__PURE__ */ U(`a`,{class:`${Qm}-source`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-testid":Y.source,children:[/* @__PURE__ */ U(`span`,{class:`${Qm}-source-icon`,"aria-hidden":`true`,children:`🔗`}),/* @__PURE__ */ U(`span`,{class:`${Qm}-source-label`,children:n})]}):/* @__PURE__ */ U(`span`,{class:`${Qm}-source`,"data-testid":Y.source,children:[/* @__PURE__ */ U(`span`,{class:`${Qm}-source-icon`,"aria-hidden":`true`,children:`📄`}),/* @__PURE__ */ U(`span`,{class:`${Qm}-source-label`,children:n})]})}const eh=i.cssPrefix;function th(e){return{toolCallId:e.toolCallId,toolName:e.toolName,...e.title?{title:e.title}:{},state:e.stateSig.value,input:e.inputSig.value,output:e.outputSig.value,...e.errorSig.value?{errorText:e.errorSig.value}:{},...e.approvalSig.value?{approval:e.approvalSig.value}:{},...e.toolMetadata?{toolMetadata:e.toolMetadata}:{}}}function nh(e,t){if(t?.replacedByMessageId)return{terminal:!1,responded:!1,decided:!1};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 rh({status:e,label:t,icon:n}){return/* @__PURE__ */ U(`span`,{class:`${eh}-toolui-badge ${eh}-toolui-status`,"data-status":e,children:[/* @__PURE__ */ U(`span`,{class:`${eh}-toolui-status-icon`,children:n??/* @__PURE__ */ U(ih,{status:e})}),t]})}function ih({status:e}){return e===`running`?/* @__PURE__ */ U(`span`,{class:`${eh}-loading-spinner`}):U(e===`stopped`?fd:e===`waiting`||e===`submitted`?rf:e===`failed`||e===`declined`||e===`replaced`?of:af,{})}function ah({decision:e}){return/* @__PURE__ */ U(`span`,{class:`${eh}-steps-decision`,"data-approved":e.approved?`true`:`false`,title:e.title,children:[e.approved?/* @__PURE__ */ U(af,{}):/* @__PURE__ */ U(of,{}),e.label]})}function oh({view:e,strings:t}){let n=e.raw;return/* @__PURE__ */ U(L,{children:[e.error?/* @__PURE__ */ U(`p`,{class:`${eh}-steps-row-error`,children:e.error}):null,e.fields.length>0?/* @__PURE__ */ U(sh,{fields:e.fields,label:e.tables?t.stepInput:void 0,plain:!e.tables}):null,e.resultFields?/* @__PURE__ */ U(sh,{fields:e.resultFields,label:t.toolResult}):null,n?.input||n?.output?/* @__PURE__ */ U(`details`,{class:`${eh}-toolui-raw`,open:!e.tables,children:[/* @__PURE__ */ U(`summary`,{children:t.stepRawData}),n.input?/* @__PURE__ */ U(ch,{label:t.stepInput,text:n.input}):null,n.output?/* @__PURE__ */ U(ch,{label:t.toolResult,text:n.output}):null]}):null]})}function sh({fields:e,label:t,plain:n=!1}){let r=/* @__PURE__ */ U(`div`,{class:`${eh}-toolui-fields`,"data-plain":n?`true`:void 0,children:/* @__PURE__ */ U(`table`,{children:/* @__PURE__ */ U(`tbody`,{children:e.map(({label:e,value:t},n)=>/* @__PURE__ */ U(`tr`,{children:[/* @__PURE__ */ U(`th`,{scope:`row`,children:e}),/* @__PURE__ */ U(`td`,{children:t})]},`${e}#${n}`))})})});return t?/* @__PURE__ */ U(`div`,{class:`${eh}-toolui-section`,children:[/* @__PURE__ */ U(`span`,{class:`${eh}-toolui-label`,children:t}),r]}):r}function ch({label:e,text:t}){return/* @__PURE__ */ U(`div`,{class:`${eh}-toolui-section`,children:[/* @__PURE__ */ U(`span`,{class:`${eh}-toolui-label`,children:e}),/* @__PURE__ */ U(`pre`,{class:`${eh}-toolui-code`,children:t})]})}const lh=i.cssPrefix;function uh({part:e,view:t,strings:n,locale:r,canAct:i,onDecision:a,onEdit:o,preview:s}){let c=t.approval,l=t.status===`waiting`||t.status===`submitted`||t.status===`approved`,u=e.toolCallId;return/* @__PURE__ */ U(`details`,{class:`${lh}-toolui ${lh}-toolui-collapsible`,open:l||c?.buttons===`change`||void 0,"data-testid":t.status===`waiting`?Y.toolApproval:Y.toolDecision,"data-status":t.status,children:[/* @__PURE__ */ U(`summary`,{class:`${lh}-toolui-head`,children:[/* @__PURE__ */ U(`span`,{class:`${lh}-toolui-prompt`,children:l&&c?c.ask:t.name}),t.system?/* @__PURE__ */ U(`span`,{class:`${lh}-toolui-system`,children:t.system}):null,/* @__PURE__ */ U(`span`,{class:`${lh}-toolui-head-end`,children:[t.decision?/* @__PURE__ */ U(ah,{decision:t.decision}):null,t.statusLabel?/* @__PURE__ */ U(rh,{status:t.status,label:t.statusLabel}):null,/* @__PURE__ */ U(`span`,{class:`${lh}-toolui-chevron`,children:/* @__PURE__ */ U(Md,{})})]})]}),/* @__PURE__ */ U(`div`,{class:`${lh}-toolui-collapse-body`,children:[l&&s&&P(e.toolMetadata)?/* @__PURE__ */ U(fh,{toolName:e.toolName,input:e.inputSig.value,preview:s,strings:n,locale:r}):null,/* @__PURE__ */ U(oh,{view:t,strings:n}),c?.note?/* @__PURE__ */ U(`p`,{class:`${lh}-toolui-subtle`,children:c.note}):null,c?.buttons===`decide`?/* @__PURE__ */ U(`div`,{class:`${lh}-toolui-actions`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${lh}-form-skip`,disabled:!i,onClick:()=>a(u,!1),"data-testid":Y.toolDecline,children:n.decline}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${lh}-form-submit`,disabled:!i,onClick:()=>a(u,!0),"data-testid":Y.toolApprove,children:n.approve})]}):null,c?.buttons===`change`?/* @__PURE__ */ U(`div`,{class:`${lh}-toolui-actions`,children:/* @__PURE__ */ U(`button`,{type:`button`,class:`${lh}-form-skip`,onClick:()=>o(u),"data-testid":Y.toolEdit,children:n.changeAnswer})}):null]})]})}function dh(e){if(typeof e==`object`&&e&&`totals`in e)return`number`in e&&`items`in e?`root = Root([preview])\npreview = Order(${JSON.stringify(e)})`:`lines`in e?`root = Root([preview])\npreview = Cart(${JSON.stringify(e)})`:void 0}function fh({toolName:e,input:t,preview:n,strings:r,locale:i}){let[a,o]=R();z(()=>{let r=!0;return n(e,t).then(e=>{r&&o(dh(e))}),()=>{r=!1}},[e,t,n]);let s=bi(()=>a?{textSig:H(a),doneSig:H(!0),replyDoneSig:H(!0)}:void 0,[a]);return s?/* @__PURE__ */ U(`div`,{class:`${lh}-toolui-preview`,"data-testid":Y.toolPreview,children:/* @__PURE__ */ U(Mc,{cssPrefix:lh,textSig:s.textSig,doneSig:s.doneSig,replyDoneSig:s.replyDoneSig,strings:r,locale:i})}):null}const ph=[`text`,`email`,`phone`,`number`,`date`,`single-select`,`multi-select`,`boolean`];function mh(e){return typeof e==`object`&&!!e}function hh(e,t){let n=mh(e)?e:{},r=(Array.isArray(n.questions)?n.questions:[]).map((e,n)=>gh(e,n,t)).filter(e=>e!==null);return{intro:yh(n.intro),questions:r}}function gh(e,t,n){if(!mh(e))return null;let r=ph.find(t=>t===e.type)??`text`;return{key:yh(e.key)??`q${t+1}`,question:yh(e.question)??n,type:r,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:yh(e.helpText)}}function _h(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 vh(e,t,n){return e.questions.map(e=>{let r=_h(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 yh(e){return typeof e==`string`&&e.trim()?e.trim():void 0}const bh=i.cssPrefix;function xh({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]=R(()=>l??{}),[_,v]=R({}),[y,b]=R({});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=Th(e,h,_),a=Om(e,i,t);Object.keys(a).length>0?b(a):r(i)}function ee(e){!s||e.key!==`Enter`||e.shiftKey||kp(e)||e.target&&`tagName`in e.target&&e.target.tagName===`TEXTAREA`&&w(e)}return/* @__PURE__ */ U(`form`,{class:`${bh}-form`,onSubmit:w,onKeyDown:ee,onCompositionEnd:Op,"data-testid":f,noValidate:!0,children:[e.map(e=>/* @__PURE__ */ U(Sh,{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:`${bh}-form-actions`,children:[o?/* @__PURE__ */ U(`span`,{class:`${bh}-form-hint`,children:o}):null,i&&a?/* @__PURE__ */ U(`button`,{type:`button`,class:`${bh}-form-skip`,onClick:a,disabled:c,"data-testid":m,children:i}):null,/* @__PURE__ */ U(`button`,{type:`submit`,class:`${bh}-form-submit`,disabled:c,"data-testid":p,children:n})]})]})}function Sh({field:e,value:t,otherText:n,error:r,disabled:i,typeLabel:a,strings:o,onChange:s,onOtherChange:c}){let l=uf(Y.formField,e.name),u=xi(),d=Ch({field:e,value:t,otherText:n,disabled:i,strings:o,onChange:s,onOtherChange:c,fieldTid:l,labelId:u});return/* @__PURE__ */ U(e.type===`radio`||e.type===`multiselect`?`div`:`label`,{class:`${bh}-field`,"data-field":e.name,"data-invalid":r?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${bh}-field-head`,children:[/* @__PURE__ */ U(`span`,{class:`${bh}-field-label`,id:u,children:[e.label,e.required?/* @__PURE__ */ U(`span`,{class:`${bh}-field-req`,"aria-hidden":`true`,children:` *`}):null]}),a?/* @__PURE__ */ U(`span`,{class:`${bh}-field-type`,children:a}):null]}),d,e.validationHint&&!r?/* @__PURE__ */ U(`span`,{class:`${bh}-field-hint`,children:e.validationHint}):null,r?/* @__PURE__ */ U(`span`,{class:`${bh}-field-error`,role:`alert`,children:r}):null]})}function Ch(e){let{field:t,value:n,otherText:r,disabled:i,strings:a,onChange:o,onOtherChange:s,fieldTid:c,labelId:l}=e,u=typeof n==`string`?n:``;switch(t.type){case`textarea`:return/* @__PURE__ */ U(`textarea`,{class:`${bh}-field-input`,rows:3,value:u,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c});case`radio`:return/* @__PURE__ */ U(`div`,{class:`${bh}-field-choices`,role:`radiogroup`,"aria-labelledby":l,"data-testid":c,children:(t.options??[]).map(e=>/* @__PURE__ */ U(`label`,{class:`${bh}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`radio`,name:`${bh}-${t.name}`,checked:u===e.value,disabled:i,onChange:()=>o(e.value)}),/* @__PURE__ */ U(`span`,{children:e.label})]},e.value))});case`multiselect`:{let e=Array.isArray(n)?n:[];function u(t,n){return o(n?[...e,t]:e.filter(e=>e!==t))}return/* @__PURE__ */ U(`div`,{class:`${bh}-field-choices`,role:`group`,"aria-labelledby":l,"data-testid":c,children:[(t.options??[]).map(t=>/* @__PURE__ */ U(`label`,{class:`${bh}-choice`,children:[/* @__PURE__ */ U(`input`,{type:`checkbox`,checked:e.includes(t.value),disabled:i,onChange:e=>u(t.value,e.currentTarget.checked)}),/* @__PURE__ */ U(`span`,{children:t.label})]},t.value)),(t.options??[]).length===0?/* @__PURE__ */ U(`textarea`,{class:`${bh}-field-input`,rows:2,value:r,placeholder:a.formOtherPlaceholder,disabled:i,onInput:e=>s(e.currentTarget.value)}):null]})}default:return/* @__PURE__ */ U(`input`,{...wh(t.type),class:`${bh}-field-input`,value:u,disabled:i,onInput:e=>o(e.currentTarget.value),"data-testid":c})}}function wh(e){switch(e){case`number`:return{type:e};case`email`:return{type:e};case`tel`:return{type:e};case`date`:return{type:e};default:return{type:`text`}}}function Th(e,t,n){let r={...t};for(let i of e){let e=n[i.name]?.trim();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 Eh=i.cssPrefix;function Dh({skipped:e,submitted:t,strings:n}){return e?{status:`replaced`,statusLabel:n.inputSkipped}:t?{status:`submitted`,statusLabel:n.stepWorkingOnIt}:{status:`done`,statusLabel:n.inputAnswered}}const Oh={text:`qtypeText`,email:`qtypeEmail`,phone:`qtypePhone`,number:`qtypeNumber`,date:`qtypeDate`,"single-select":`qtypeChooseOne`,"multi-select":`qtypeChooseAny`,boolean:`qtypeBoolean`};function kh(e,t){let n={};for(let r of e)n[r.key]=t[Oh[r.type]];return n}function Ah({part:e,strings:t,active:n,superseded:r=!1,continuationStreaming:i=!1,folded:a=!1,onDecision:o,onEdit:s}){let c=bi(()=>Yi(()=>e.stateSig.value),[e]).value,l=bi(()=>Yi(()=>e.approvalSig.value),[e]).value,u=bi(()=>Yi(()=>hh(e.inputSig.value,t.askFallbackQuestion)),[e,t]).value,{terminal:d,decided:f}=nh(c,l),p=f&&l?.approved===!0,m=i&&!f,h=!f&&!r&&!m,g=!h&&!p&&!m,_=p&&n&&!d,v=u.questions,[y,b]=R(null),x=y??(h||p||m),[S,C]=R(!1),w=v.length>1?ad:Id,ee=h?t.inputRequired:t.inputBadge,T=m?/* @__PURE__ */ U(`p`,{class:`${Eh}-toolui-subtle`,children:t.stepWorkingOnIt}):h?/* @__PURE__ */ U(jh,{req:u,strings:t,active:n,resolve:(t,n)=>o(e.toolCallId,n,t)}):S?/* @__PURE__ */ U(xh,{fields:vh(u,t.confirmYes,t.confirmNo),strings:t,submitLabel:t.inputSubmit,onSubmit:()=>{},disabled:!0,hideActions:!0,fieldTypeLabels:kh(v,t),initialValues:p?Rh(v,l?.reason):void 0}):/* @__PURE__ */ U(Mh,{questions:v,answers:p?Lh(l?.reason):{},strings:t}),{status:E,statusLabel:D}=Dh({skipped:g,submitted:m,strings:t});return/* @__PURE__ */ U(`details`,{class:`${Eh}-toolui ${Eh}-toolui-collapsible${r?` ${Eh}-toolui-stale`:``}`,open:x,onToggle:e=>{let t=e.currentTarget.open;t!==x&&b(t)},"data-testid":h?Y.toolAskQuestions:Y.toolDecision,children:[/* @__PURE__ */ U(`summary`,{class:`${Eh}-toolui-head`,children:[/* @__PURE__ */ U(`span`,{class:`${Eh}-toolui-q-pill`,children:[/* @__PURE__ */ U(w,{}),ee]}),/* @__PURE__ */ U(`span`,{class:`${Eh}-toolui-head-end`,children:[h||a?null:/* @__PURE__ */ U(rh,{status:E,icon:U(g?of:af,{}),label:D}),/* @__PURE__ */ U(`span`,{class:`${Eh}-toolui-chevron`,children:/* @__PURE__ */ U(Md,{})})]})]}),/* @__PURE__ */ U(`div`,{class:`${Eh}-toolui-collapse-body`,children:[u.intro?/* @__PURE__ */ U(`div`,{class:`${Eh}-toolui-desc`,children:u.intro}):null,T,h||m?null:/* @__PURE__ */ U(`div`,{class:`${Eh}-toolui-footer`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${Eh}-toolui-options-toggle`,onClick:()=>C(e=>!e),"data-testid":Y.toolAskOptions,children:[/* @__PURE__ */ U(`span`,{class:`${Eh}-toolui-options-chevron${S?` ${Eh}-open`:``}`,children:/* @__PURE__ */ U(Md,{})}),S?t.hideOptions:t.showOptions]}),_?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Eh}-form-skip`,onClick:()=>s(e.toolCallId),"data-testid":Y.toolEdit,children:t.edit}):null]})]})]})}function jh({req:e,strings:t,active:n,resolve:r}){let i=vh(e,t.confirmYes,t.confirmNo),a=e.questions.length===1&&e.questions[0]?.type===`text`;return/* @__PURE__ */ U(xh,{fields:i,strings:t,disabled:!n,submitLabel:t.inputSubmit,footerHint:a?t.inputSubmitHint:void 0,onSubmit:t=>r(Ph(e.questions,t),!0),skipLabel:t.inputSkip,onSkip:()=>r(void 0,!1),submitOnEnter:a,fieldTypeLabels:kh(e.questions,t),submitTestId:Y.toolInputSubmit,skipTestId:Y.toolInputSkip})}function Mh({questions:e,answers:t,strings:n}){return/* @__PURE__ */ U(`div`,{class:`${Eh}-toolui-summary`,"data-testid":Y.toolAskSummary,children:e.map(e=>/* @__PURE__ */ U(`div`,{class:`${Eh}-field`,children:[/* @__PURE__ */ U(`span`,{class:`${Eh}-field-head`,children:/* @__PURE__ */ U(`span`,{class:`${Eh}-field-label`,children:[e.question,e.required?/* @__PURE__ */ U(`span`,{class:`${Eh}-field-req`,"aria-hidden":`true`,children:` *`}):null]})}),/* @__PURE__ */ U(`p`,{class:`${Eh}-toolui-answer`,children:Nh(e,t[e.key],n)||`—`})]},e.key))})}function Nh(e,t,n){return e.type===`boolean`?t===`yes`?n.confirmYes:t===`no`?n.confirmNo:t??``:t??``}function Ph(e,t){let n=e.flatMap(e=>{let n=t[e.key],r=typeof n==`string`?n.trim():n;return r?.length?[{key:e.key,value:r}]:[]});return JSON.stringify({answers:n})}function Fh(e){if(!e)return{};let t=(()=>{try{return JSON.parse(e)}catch{return}})(),n=Ih(t)?t.answers:void 0;if(!Array.isArray(n))return{};let r={};for(let e of n)if(Ih(e)){let{key:t,value:n}=e;if(typeof t!=`string`)continue;typeof n==`string`?r[t]=n:Array.isArray(n)&&(r[t]=n.filter(e=>typeof e==`string`))}return r}function Ih(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Lh(e){let t=Fh(e),n={};for(let[e,r]of Object.entries(t))n[e]=Array.isArray(r)?r.join(`, `):r;return n}function Rh(e,t){let n=Fh(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}const Z=i.cssPrefix;function zh(e,t){let n=[];for(let[r,i]of e.entries()){let e=n.at(-1),a=i.kind===`tool`?t.viewOf(i):void 0,o=Bh(i,a,t.showReasoning);o?e?.kind===`steps`?(e.rows.push(o),e.indices.push(r)):n.push({kind:`steps`,rows:[o],indices:[r]}):i.kind===`step-start`||i.kind===`reasoning`||i.kind===`source`&&!t.showSources||a?.placement===`hidden`||n.push({kind:`part`,part:i,index:r})}return n}function Bh(e,t,n){return e.kind===`reasoning`?n?{kind:`thought`,part:e}:void 0:e.kind===`tool`&&t?.placement===`step`?{kind:`tool`,part:e,view:t}:void 0}function Vh(e,t){let n=[...new Set(t)];if(e&&n.length!==0&&!n.some(t=>t<0||t>=e.length))return n.reduce((t,n)=>t+(e[n]?.durationMs??0),0)}function Hh(e){let t=[];for(let n of e)t.push((t.at(-1)??-1)+ +(n.kind===`step-start`));return t}function Uh(e,t){return e.streaming?t.thinking:e.reasoningMs===void 0?t.thought:t.thoughtFor.replace(`{time}`,Wh(e.reasoningMs))}function Wh(e){if(e<1e4)return`${Number((e/1e3).toFixed(1))} s`;let t=Math.round(e/1e3);return t<60?`${t} s`:`${Math.floor(t/60)} m ${t%60} s`}function Gh(e){return e.split(`
70
+ `).map(e=>e.trim()).findLast(e=>/^\*\*[^*].*\*\*$/.test(e))?.slice(2,-2).trim()}function Kh(e,t){return e?.kind===`tool`?`${e.view.name}…`:(e&&Gh(e.part.textSig.value))??t.thinking}function qh({rows:e,steps:t=[],stepTimings:n,timed:r=!0,strings:i,running:a,runStartedAt:o,renderCard:s}){let[c,l]=R(!1),[u,d]=R(!1),f=gn(e.flatMap(e=>e.kind===`tool`?[e.view]:[])),p=e.at(-1),m=bi(()=>Yi(()=>Kh(p,i)),[p,i]).value,h=r?Vh(n,t):void 0;function g(){l(!c),d(!0)}let[_]=e;return!a&&e.length===1&&_?.kind===`tool`?/* @__PURE__ */ U(`div`,{class:`${Z}-steps`,"data-testid":Y.toolSteps,"data-stopped":f.stopped?`true`:void 0,children:/* @__PURE__ */ U($h,{part:_.part,view:_.view,strings:i,durationMs:h,standalone:!0,renderCard:s})}):/* @__PURE__ */ U(`div`,{class:`${Z}-steps`,"data-testid":Y.toolSteps,"data-running":a?`true`:void 0,"data-stopped":f.stopped?`true`:void 0,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${Z}-steps-head`,"aria-expanded":c,onClick:g,children:[/* @__PURE__ */ U(`span`,{class:`${Z}-steps-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Yh,{running:a,stopped:f.stopped!==void 0})}),/* @__PURE__ */ U(`span`,{class:`${Z}-steps-label`,children:a?/* @__PURE__ */ U(`span`,{class:`${Z}-steps-live`,children:m}):/* @__PURE__ */ U(Xh,{line:f,strings:i})}),!a&&f.failed>0?/* @__PURE__ */ U(`span`,{class:`${Z}-steps-failed`,children:i.toolStepsFailed.replace(`{count}`,String(f.failed))}):null,a?null:f.marks.map(e=>/* @__PURE__ */ U(ah,{decision:e},e.title)),a&&o?/* @__PURE__ */ U(Jh,{since:o}):null,!a&&h!==void 0?/* @__PURE__ */ U(`span`,{class:`${Z}-steps-time`,children:Wh(h)}):null,/* @__PURE__ */ U(`span`,{class:`${Z}-steps-chevron`,"data-open":c?`true`:void 0,children:/* @__PURE__ */ U(Md,{})})]}),/* @__PURE__ */ U(`span`,{class:`${Z}-sr-only`,role:`status`,children:a?m:``}),/* @__PURE__ */ U(`div`,{class:`${Z}-steps-body`,"data-open":c?`true`:void 0,inert:!c,children:/* @__PURE__ */ U(`div`,{class:`${Z}-steps-body-inner`,children:u?/* @__PURE__ */ U(`ol`,{class:`${Z}-steps-list`,children:e.map((r,o)=>r.kind===`tool`?/* @__PURE__ */ U($h,{part:r.part,view:r.view,strings:i,renderCard:s},r.part.toolCallId):/* @__PURE__ */ U(eg,{part:r.part,current:a&&o===e.length-1,reasoningMs:n?.[t[o]??-1]?.reasoningMs,strings:i},`${r.part.id}#${o}`))}):null})})]})}function Jh({since:e}){let[t,n]=R(()=>Date.now());z(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let r=Math.max(0,Math.floor((t-Date.parse(e))/1e3));return/* @__PURE__ */ U(`span`,{class:`${Z}-steps-time`,children:Wh(r*1e3)})}function Yh({running:e,stopped:t}){return e?/* @__PURE__ */ U(`span`,{class:`${Z}-loading-spinner`}):U(t?fd:nf,{})}function Xh({line:e,strings:t}){return e.stopped?/* @__PURE__ */ U(L,{children:vn(e.stopped.finished,t)}):e.single?/* @__PURE__ */ U(L,{children:[e.single.name,e.single.summary?/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`span`,{class:`${Z}-steps-sep`,"aria-hidden":`true`,children:`·`}),/* @__PURE__ */ U(`span`,{class:`${Z}-steps-summary`,children:e.single.summary})]}):null,e.single.outcome?/* @__PURE__ */ U(`span`,{class:`${Z}-steps-denied`,children:e.single.outcome}):null]}):/* @__PURE__ */ U(L,{children:e.tools.map(({name:e,count:t},n)=>/* @__PURE__ */ U(`span`,{class:`${Z}-steps-name`,children:[n>0?/* @__PURE__ */ U(`span`,{class:`${Z}-steps-sep`,"aria-hidden":`true`,children:`·`}):null,e,t>1?/* @__PURE__ */ U(`span`,{class:`${Z}-steps-count`,children:[`×`,t]}):null]},e))})}function Zh({view:e}){let t=e.statusLabel&&e.status!==`running`?/* @__PURE__ */ U(`span`,{class:e.status===`failed`?`${Z}-steps-failed`:`${Z}-steps-denied`,children:e.statusLabel}):null;return/* @__PURE__ */ U(L,{children:[e.decision?/* @__PURE__ */ U(ah,{decision:e.decision}):null,t]})}function Qh({view:e,durationMs:t}){return/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`span`,{class:`${Z}-steps-row-label`,children:[/* @__PURE__ */ U(`span`,{class:`${Z}-steps-row-name`,children:e.name}),e.system?/* @__PURE__ */ U(`span`,{class:`${Z}-steps-row-system`,children:e.system}):null,e.summary?/* @__PURE__ */ U(`span`,{class:`${Z}-steps-row-summary`,children:e.summary}):null]}),/* @__PURE__ */ U(Zh,{view:e}),t===void 0?null:/* @__PURE__ */ U(`span`,{class:`${Z}-steps-time`,children:Wh(t)})]})}function $h({part:e,view:t,strings:n,durationMs:r,standalone:i=!1,renderCard:a}){let[o,s]=R(!1);return/* @__PURE__ */ U(i?`div`:`li`,{class:`${Z}-steps-row`,"data-testid":Y.toolStep,"data-status":t.status,"data-standalone":i?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${Z}-steps-row-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(ih,{status:t.status})}),/* @__PURE__ */ U(`div`,{class:`${Z}-steps-row-main`,children:t.opens?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Z}-steps-row-head`,"aria-expanded":o,onClick:()=>s(!o),children:[/* @__PURE__ */ U(Qh,{view:t,durationMs:r}),/* @__PURE__ */ U(`span`,{class:`${Z}-steps-chevron`,"data-open":o?`true`:void 0,children:/* @__PURE__ */ U(Md,{})})]}):/* @__PURE__ */ U(`span`,{class:`${Z}-steps-row-head`,children:/* @__PURE__ */ U(Qh,{view:t,durationMs:r})})}),o&&t.opens?/* @__PURE__ */ U(`div`,{class:`${Z}-steps-row-body`,children:(t.card?a?.(e,t):void 0)??/* @__PURE__ */ U(oh,{view:t,strings:n})}):null]})}function eg({part:e,current:t,reasoningMs:n,strings:r,standalone:i=!1}){let[a,o]=R(!1),s=bi(()=>Yi(()=>e.textSig.value.trim()===``),[e]).value,c=/* @__PURE__ */ U(`span`,{class:t?`${Z}-steps-thought-label ${Z}-steps-live`:`${Z}-steps-thought-label`,children:Uh({streaming:t,reasoningMs:n},r)});return/* @__PURE__ */ U(i?`div`:`li`,{class:`${Z}-steps-row ${Z}-steps-thought`,"data-status":`thought`,"data-testid":i?Y.reasoning:void 0,"data-standalone":i?`true`:void 0,children:[/* @__PURE__ */ U(`span`,{class:`${Z}-steps-row-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(sf,{})}),/* @__PURE__ */ U(`div`,{class:`${Z}-steps-row-main`,children:s?c:/* @__PURE__ */ U(`button`,{type:`button`,class:`${Z}-steps-row-head`,"aria-expanded":a,onClick:()=>o(!a),children:[c,/* @__PURE__ */ U(`span`,{class:`${Z}-steps-chevron`,"data-open":a?`true`:void 0,children:/* @__PURE__ */ U(Md,{})})]})}),a&&!s?/* @__PURE__ */ U(`div`,{class:`${Z}-steps-thought-text ${Z}-reasoning-body`,children:/* @__PURE__ */ U(wf,{textSig:e.textSig,doneSig:e.doneSig})}):null]})}const tg=i.cssPrefix,ng=Lm(rg);function rg({message:e,status:t,createdAt:n,strings:r,locale:i,responseMode:a,showReasoning:o,stepDisplay:s,showSources:c,interactive:l=!1,superseded:u=!1,tool:d,onRetry:f,enableMessageFeedback:p=!1,onFeedback:m,reconnecting:h=!1,clientToolRunning:g=!1,onCardAction:_}){let v=[...bi(()=>Yi(()=>e.partsSig.value),[e]).value];for(let t of e.attachments??[])t.url&&!v.some(e=>e.kind===`file`&&e.url===t.url)&&v.push({kind:`file`,url:t.url,mediaType:t.mediaType,filename:t.name,fileId:t.id,fileSize:t.size});let y=bi(()=>Yi(()=>Jl(e)),[e,t,e.canceled]),b=bi(()=>Yi(()=>Jm(e)),[e]),x=bi(()=>Yi(()=>o&&Ym(e)),[e,o]),S=bi(()=>Yi(()=>Xl(e,x.value)),[e,x,t,e.canceled]),C=bi(()=>Yi(()=>!Tl(e)),[e]),w=t===`streaming`,ee=e.role===`assistant`&&g,T=e.role===`assistant`&&(w||ee),E=w||ee,D=Zm({streaming:T,responseMode:a,reasoningVisible:x.value,hasAnswerText:b.value,emptyReply:y.value,hidden:S.value}),{bufferedHold:O,showStreamDots:te}=D;if(D.hidden)return null;let k=ag(n,i),ne=e.role===`assistant`||e.role===`operator`,re=p&&!!m&&!!e.serverMessageId&&ne&&!E&&t!==`error`&&!y.value,ie=E?``:v.filter(e=>e.kind===`text`).map(t=>e.role===`assistant`?Yc(t.textSig.peek()):t.textSig.peek()).join(`
71
71
 
72
- `).trim(),A=!E&&t!==`error`&&!y.value&&ie.length>0,ae=e.canceled===!0||t===`error`;function j(n){return l&&t===`complete`&&Al(e,n)}let oe=/* @__PURE__ */ new Map;for(let[t,n]of v.entries()){if(n.kind!==`tool`)continue;let i=P(n.toolMetadata),a=mn($m(n),{turn:{live:T||i&&!u,cutOff:ae,superseded:u,submitted:e.continuationStreaming===!0&&n.approvalSig.value?.approved===void 0,canAct:j(t),interrupted:i&&je(n.errorSig.value)},reader:{decides:!0},display:s,strings:r});oe.set(n.toolCallId,a.placement===`card`&&!d?.humanInLoop?{...a,placement:`hidden`}:a)}function se(e){let t=oe.get(e.toolCallId);if(!t)throw Error(`no step view for ${e.toolCallId}`);return t}let ce=Lh(v,{showReasoning:o,showSources:c,viewOf:se}),le=Bh(v),ue=e.canceled===!0&&!w&&C.value&&x.value,M=ce.at(-1),de=M?.kind===`steps`?M.indices.at(-1):M?.index;function fe(t,n){return/* @__PURE__ */ U(ig,{part:t,generativeUi:e.role===`assistant`,onCardAction:_,current:T&&n===de,reasoningMs:e.stepTimings?.[le[n]??-1]?.reasoningMs,strings:r,locale:i,showReasoning:o,showSources:c,view:t.kind===`tool`?oe.get(t.toolCallId):void 0,canAct:j(n),superseded:u,continuationStreaming:e.continuationStreaming===!0,tool:d},`${sg(t)}#${n}`)}let pe=re||A;return/* @__PURE__ */ U(`div`,{class:`${$h}-bubble-row`,"data-role":e.role,"aria-busy":T?`true`:void 0,"data-testid":cf(Y.messageBubble,e.serverMessageId??e.id),children:/* @__PURE__ */ U(`div`,{class:`${$h}-bubble-col`,children:[/* @__PURE__ */ U(`div`,{class:`${$h}-bubble`,children:[e.role===`operator`&&e.operatorInitials?/* @__PURE__ */ U(`span`,{class:`${$h}-bubble-author`,children:e.operatorInitials}):null,/* @__PURE__ */ U(`div`,{class:`${$h}-bubble-body`,children:[O?/* @__PURE__ */ U(lg,{label:r.loading}):ce.flatMap((t,n)=>t.kind===`part`?[fe(t.part,t.index)]:t.rows.some(e=>e.kind===`tool`)?[/* @__PURE__ */ U(Gh,{rows:t.rows,steps:t.indices.map(e=>le[e]??-1),stepTimings:e.stepTimings,timed:!ae,strings:r,running:T&&n===ce.length-1,runStartedAt:e.runStartedAt,renderCard:(e,t)=>t.card===`questions`&&d?/* @__PURE__ */ U(Oh,{part:e,strings:r,active:!1,superseded:t.status===`replaced`,folded:!0,onDecision:d.onDecision,onEdit:d.onEdit}):void 0},`steps#${t.indices[0]}`)]:t.rows.map((e,n)=>fe(e.part,t.indices[n]??n))),ue?/* @__PURE__ */ U(`div`,{class:`${$h}-steps-row`,"data-status":`stopped`,"data-testid":Y.replyStopped,children:[/* @__PURE__ */ U(`span`,{class:`${$h}-steps-row-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(ud,{})}),/* @__PURE__ */ U(`div`,{class:`${$h}-steps-row-main`,children:/* @__PURE__ */ U(`span`,{class:`${$h}-steps-stopped-label`,children:r.statusStopped})})]}):null,te&&!h?/* @__PURE__ */ U(cg,{}):null,t===`error`||y.value?/* @__PURE__ */ U(kp,{text:og(e,t,r),retryLabel:r.errorRetry,onRetry:f?()=>f(e):void 0,retryTestId:Y.messageRetry}):null,h&&T?/* @__PURE__ */ U(kp,{text:r.errorReconnecting,retryTestId:Y.messageRetry}):null]})]}),k||pe?/* @__PURE__ */ U(`div`,{class:`${$h}-bubble-meta`,children:[k?/* @__PURE__ */ U(`time`,{class:`${$h}-bubble-time`,dateTime:k.iso,title:k.full,children:k.short}):null,pe?/* @__PURE__ */ U(`div`,{class:`${$h}-bubble-actions`,children:[re&&e.serverMessageId?/* @__PURE__ */ U(Gm,{messageId:e.serverMessageId,initial:e.feedback??null,strings:r,onFeedback:m}):null,A?/* @__PURE__ */ U(ng,{text:ie,strings:r}):null]}):null]}):null]})})}function ng({text:e,strings:t}){let[n,r]=R(!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:`${$h}-msg-action`,"data-active":n?`true`:void 0,"aria-label":a,title:a,onClick:i,"data-testid":Y.messageCopy,children:U(n?wd:Zd,{})})}function rg(e,t){if(typeof e!=`number`||!Number.isFinite(e))return null;try{let n=new Date(e);return{short:n.toLocaleTimeString(t,{hour:`numeric`,minute:`2-digit`}),full:n.toLocaleString(t,{dateStyle:`full`,timeStyle:`short`}),iso:n.toISOString()}}catch{return null}}function ig({part:e,generativeUi:t,onCardAction:n,current:r,reasoningMs:i,strings:a,locale:o,showReasoning:s,showSources:c,view:l,canAct:u,superseded:d,continuationStreaming:f,tool:p}){switch(e.kind){case`step-start`:return null;case`text`:return/* @__PURE__ */ U(Sf,{textSig:e.textSig,doneSig:e.doneSig,generativeUi:t,strings:a,onCardAction:n});case`reasoning`:return s?/* @__PURE__ */ U(Qh,{part:e,current:r,reasoningMs:i,strings:a,standalone:!0}):null;case`tool`:return l?.placement!==`card`||!p?null:l.card===`questions`?/* @__PURE__ */ U(Oh,{part:e,strings:a,active:u,superseded:d,continuationStreaming:f,onDecision:p.onDecision,onEdit:p.onEdit}):/* @__PURE__ */ U(ch,{part:e,view:l,strings:a,locale:o,canAct:u,onDecision:p.onDecision,onEdit:p.onEdit,preview:p.preview});case`file`:return/* @__PURE__ */ U(ag,{part:e,strings:a});case`source`:return c?/* @__PURE__ */ U(Zm,{part:e,strings:a}):null}}function ag({part:e,strings:t}){let n=e.filename??t.file;if(e.mediaType.startsWith(`image/`))return/* @__PURE__ */ U(`a`,{class:`${$h}-file-image`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,title:n,"data-testid":Y.messageFile,children:/* @__PURE__ */ U(`img`,{src:e.url,alt:n,loading:`lazy`})});let r=(n.includes(`.`)?n.split(`.`).pop():e.mediaType.split(`/`).pop())?.toUpperCase(),i=e.fileSize===void 0?void 0:dp(e.fileSize);return/* @__PURE__ */ U(`a`,{class:`${$h}-file-chip`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,title:n,"data-testid":Y.messageFile,children:[/* @__PURE__ */ U(`span`,{class:`${$h}-file-chip-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(jd,{})}),/* @__PURE__ */ U(`span`,{class:`${$h}-file-chip-text`,children:[/* @__PURE__ */ U(`span`,{class:`${$h}-file-chip-name`,children:n}),/* @__PURE__ */ U(`span`,{class:`${$h}-file-chip-meta`,children:[r,i].filter(Boolean).join(` · `)})]})]})}function og(e,t,n){return e.errorText?e.errorText:t===`error`&&e.role===`assistant`?n.errorServer:n.errorGeneric}function sg(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 cg(){return/* @__PURE__ */ U(`span`,{class:`${$h}-typing`,"data-testid":Y.typingDots,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`span`,{}),/* @__PURE__ */ U(`span`,{}),/* @__PURE__ */ U(`span`,{})]})}function lg({label:e}){return/* @__PURE__ */ U(`span`,{class:`${$h}-loading`,role:`status`,children:[/* @__PURE__ */ U(`span`,{class:`${$h}-loading-spinner`,"aria-hidden":`true`}),/* @__PURE__ */ U(`span`,{class:`${$h}-loading-label`,children:e})]})}const ug=i.cssPrefix;function dg({messagesSig:e,reconnectingSig:t,pageToolRunning:n,strings:r,notice:i,locale:a,responseMode:o,showReasoning:s,stepDisplay:c,showSources:l,enableMessageFeedback:u,onFeedback:d,loading:f,onLoadPreviousMessages:p,idle:m,controlMode:h=`ai-agent`,tool:g,onRetry:_,onCardAction:v}){let y=B(null),b=da(()=>e.value),x=fg(a),[S,C]=R(!1),[w,ee]=R(!1),T=B(!1),E=B(!1),[D,O]=R(),te=B(!1),k=B(!1),ne=B(!1),re=B(0);function ie(){return ne.current||performance.now()-re.current<350}let A=B(0);function ae(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 C(e.scrollHeight-e.scrollTop-e.clientHeight>240)}function oe(e){A.current=performance.now(),e.scrollTop=e.scrollHeight,ae(e)}function se(e,t){oe(e);let n=t,r=0;function i(){k.current||ie()||(oe(e),--n>0&&(r=requestAnimationFrame(i)))}return t>0&&(r=requestAnimationFrame(i)),()=>cancelAnimationFrame(r)}function ce(e,t){let n,r,i,a=-1;function o(){n.disconnect(),r.disconnect(),clearTimeout(i)}function s(){if(k.current||ie()||a>=0&&e.scrollTop<a-4)return o();oe(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 le=b.value[0]?.id;yi(()=>{let e=y.current;if(e&&b.value.length!==0&&!E.current&&(te.current=!0,b.value.some(e=>e.role===`user`)))return ce(e,300)},[le]);let ue=B(0);z(()=>{let e=y.current,t=b.value,n=ue.current;if(ue.current=t.length,e&&te.current&&!E.current){if(t.slice(n).some(e=>e.role===`user`))return k.current=!1,se(e,3);t.some(e=>e.role===`user`)&&(k.current||ie()||e.scrollHeight-e.scrollTop-e.clientHeight<120&&oe(e))}},[b.value.length]);let M=B(null);z(()=>{let e=y.current,t=b.value.at(-1),n=M.current;if(M.current=t?{id:t.id,streaming:t.status===`streaming`}:null,e&&te.current&&t&&t.id===n?.id&&!n.streaming&&t.status===`streaming`)return k.current=!1,se(e,3)},[b.value]),z(()=>{let e=y.current;if(!e)return;let t=b.value.at(-1);if(!t||t.status!==`streaming`&&!b.value.some(e=>e.role===`user`))return;let n=()=>{k.current||ie()||e.scrollHeight-e.scrollTop-e.clientHeight<240&&oe(e)};if(t.status!==`streaming`)return ce(e,300);n();let r=new MutationObserver(n);return r.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>r.disconnect()},[b.value]),z(()=>{let e=y.current;if(!e)return;let t=()=>{j(e),ae(e),performance.now()-A.current>150&&(k.current=e.scrollHeight-e.scrollTop-e.clientHeight>8)};function n(){k.current=!0}function r(e){e.deltaY<0&&n()}let i=0;function a(e){i=e.touches[0]?.clientY??0,ne.current=!0}function o(e){(e.touches[0]?.clientY??0)>i+4&&n()}function s(){ne.current=!1,re.current=performance.now()}function c(){ne.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)}},[]),z(()=>{let e=y.current;if(!e)return;let t=e.clientHeight,n=new ResizeObserver(()=>{if(e.clientHeight===t)return;let n=e.scrollHeight-e.scrollTop-t<=120;t=e.clientHeight,n&&!E.current&&b.value.some(e=>e.role===`user`)&&(k.current=!1,oe(e))});return n.observe(e),()=>n.disconnect()},[]);function de(){let e=y.current;e&&(k.current=!1,oe(e))}let fe=b.value.filter(e=>!e.ephemeral),pe=fe[0],me=pe?.serverMessageId??pe?.id,he=!!(p&&fe.length>=50&&me!==D);async function ge(){if(!p||T.current)return;let e=y.current,t=e?.scrollHeight??0,n=e?.scrollTop??0;T.current=!0,E.current=!0,ee(!0);try{let r=await p();r===!1&&me&&O(me),r&&e&&(await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e()))),e.scrollTop=n+e.scrollHeight-t,ae(e),j(e))}finally{E.current=!1,T.current=!1,ee(!1)}}let N=[],_e=``,ve=b.value.at(-1)?.id,ye=t?.value===!0,be=n===!0;for(let e of b.value){if(e.role===`assistant`&&e.id!==ve&&Kl(e))continue;let t=pg(e.createdAt);t&&t!==_e&&(N.push(/* @__PURE__ */ U(`div`,{class:`${ug}-date-divider`,children:/* @__PURE__ */ U(`span`,{class:`${ug}-date-pill`,title:mg(e.createdAt,x),children:hg(e.createdAt,r,x)})},`day:${t}`)),_e=t);let n=e.retryAction!==void 0||e.role===`assistant`&&e.id===ve?ql(b.value,e):void 0,i=n!==void 0&&(n.kind!==`continue-assistant`||h===`ai-agent`);N.push(/* @__PURE__ */ U(eg,{message:e,status:e.status,createdAt:e.createdAt,strings:r,locale:x,responseMode:o,showReasoning:s,stepDisplay:c,showSources:l,interactive:!!m&&h===`ai-agent`&&e.id===ve,superseded:e.id!==ve,tool:g,onRetry:m&&i&&(e.role===`user`||e.id===ve)?_:void 0,enableMessageFeedback:u,onFeedback:d,reconnecting:ye&&e.id===ve,clientToolRunning:be&&e.id===ve&&e.role===`assistant`,onCardAction:v},e.id))}return/* @__PURE__ */ U(`div`,{class:`${ug}-list-wrap`,children:[/* @__PURE__ */ U(`div`,{ref:y,class:`${ug}-list ${ug}-list--fade`,part:`messages`,role:`log`,"aria-live":`polite`,"aria-relevant":`additions text`,children:[f&&b.value.length===0?/* @__PURE__ */ U(`div`,{class:`${ug}-list-loading`,role:`status`,children:r.conversationLoading}):null,i&&!he?/* @__PURE__ */ U(`div`,{class:`${ug}-chat-notice`,role:`note`,"data-testid":Y.chatNotice,children:/* @__PURE__ */ U(Cf,{text:i})}):null,he?/* @__PURE__ */ U(`div`,{class:`${ug}-load-previous`,children:/* @__PURE__ */ U(`button`,{type:`button`,onClick:ge,disabled:w,"aria-busy":w,"data-testid":Y.loadPreviousMessages,children:r.loadPreviousMessages})}):null,N]}),S?/* @__PURE__ */ U(`button`,{type:`button`,class:`${ug}-jump`,onClick:de,"aria-label":r.scrollToBottom,title:r.scrollToBottom,"data-testid":Y.scrollToBottom,children:/* @__PURE__ */ U(Ad,{})}):null]})}function fg(e){try{return Intl.getCanonicalLocales(e)[0]}catch{return}}function pg(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function mg(e,t){if(typeof e!=`number`||!Number.isFinite(e))return``;try{return new Date(e).toLocaleDateString(t,{dateStyle:`full`})}catch{return``}}function hg(e,t,n){let r=new Date(e);function i(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}let a=Math.round((i(/* @__PURE__ */ new Date)-i(r))/864e5);return a<=0?t.dateToday:a===1?t.dateYesterday:a<7?r.toLocaleDateString(n,{weekday:`long`}):r.toLocaleDateString(n,{month:`long`,day:`numeric`,year:`numeric`})}function gg({panelEl:e,resize:t,position:n,edge:r,initialSize:a,onSizeChange:o,onResizeStart:s,strings:c}){let l=i.cssPrefix,u=B(null),[d,f]=R(null),p=a?.width,m=a?.height;if(z(()=>{if(!e)return;let n=e.style;n.setProperty(`--${l}-resize-min-w`,t.minWidth??`320px`),n.setProperty(`--${l}-resize-min-h`,t.minHeight??`400px`),t.maxWidth&&n.setProperty(`--${l}-resize-max-w`,t.maxWidth),t.maxHeight&&n.setProperty(`--${l}-resize-max-h`,t.maxHeight),p!==void 0&&m!==void 0&&(n.setProperty(`--${l}-widget-w`,`${p}px`),n.setProperty(`--${l}-widget-h`,`${m}px`)),f(Math.round(e.getBoundingClientRect().width/window.innerWidth*100))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,l,p,m]),!e)return null;let h=n.startsWith(`top-`),g=n.endsWith(`-right`),_=g?-1:1,v=h?1:-1,y=`${l}-resize-grip--${r?`edge`:`${h?`bottom`:`top`}-${g?`left`:`right`}`}`;function b(e){e.setAttribute(`data-resizing`,``),s?.()}function x(e,t,n){e.style.setProperty(`--${l}-widget-w`,`${t}px`),r||e.style.setProperty(`--${l}-widget-h`,`${n}px`)}function S(e){let t=e.getBoundingClientRect(),n={width:Math.round(t.width),height:Math.round(t.height)};e.style.setProperty(`--${l}-widget-w`,`${n.width}px`),r||e.style.setProperty(`--${l}-widget-h`,`${n.height}px`),f(Math.round(n.width/window.innerWidth*100)),o(n)}function C(t){if(!e)return;let n=e.getBoundingClientRect();u.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startW:n.width,startH:n.height,moved:!1},t.currentTarget.setPointerCapture(t.pointerId),t.preventDefault()}function w(t){let n=u.current;if(!n||t.pointerId!==n.pointerId||!e)return;let i=(t.clientX-n.startX)*_,a=r?0:(t.clientY-n.startY)*v;(n.moved||i!==0||a!==0)&&(n.moved||b(e),n.moved=!0,x(e,n.startW+i,n.startH+a))}function ee(t){let n=u.current;n&&t.pointerId===n.pointerId&&e&&(t.currentTarget.releasePointerCapture(t.pointerId),u.current=null,n.moved&&(e.removeAttribute(`data-resizing`),S(e)))}function T(e){return e===`ArrowLeft`?[-1,0]:e===`ArrowRight`?[1,0]:r?null:e===`ArrowUp`?[0,-1]:e===`ArrowDown`?[0,1]:null}function E(t){let n=T(t.key);if(!n||!e)return;t.preventDefault();let r=t.shiftKey?64:16;t.repeat||b(e);let i=e.getBoundingClientRect();x(e,i.width+n[0]*r*_,i.height+n[1]*r*v)}function D(t){T(t.key)&&e&&(e.removeAttribute(`data-resizing`),S(e))}return/* @__PURE__ */ U(`div`,{class:`${l}-resize-grip ${y}`,role:`separator`,"aria-orientation":`vertical`,"aria-label":c.resizeHandle,"aria-valuenow":d??void 0,tabIndex:0,title:c.resizeHandle,onPointerDown:C,onPointerMove:w,onPointerUp:ee,onPointerCancel:ee,onKeyDown:E,onKeyUp:D,"data-testid":Y.resizeGrip,children:r?null:/* @__PURE__ */ U(yd,{})})}const _g=i.cssPrefix;function vg({suggestions:e,strings:t,onPick:n,disabled:r=!1}){let i=B(null),[a,o]=R({start:!1,end:!1});return z(()=>{let e=i.current;if(!e)return;function t(){if(!e)return;let t=Math.abs(e.scrollLeft),n=t>1,r=t<e.scrollWidth-e.clientWidth-1;o(e=>e.start===n&&e.end===r?e:{start:n,end:r})}t(),e.addEventListener(`scroll`,t,{passive:!0});let n=typeof ResizeObserver>`u`?void 0:new ResizeObserver(t);return n?.observe(e),()=>{e.removeEventListener(`scroll`,t),n?.disconnect()}},[e]),e.length===0?null:/* @__PURE__ */ U(`div`,{ref:i,class:`${_g}-suggestions`,role:`group`,"aria-label":t.suggestedReplies,"data-cut-start":a.start?`true`:void 0,"data-cut-end":a.end?`true`:void 0,children:e.map((e,t)=>/* @__PURE__ */ U(`button`,{type:`button`,class:`${_g}-suggestion`,onClick:()=>n(e),disabled:r,"data-testid":cf(Y.suggestion,t),children:e.label},e.id))})}const yg=i.cssPrefix,bg=`.${yg}-header, .${yg}-back-header, .${yg}-home-hero`;function xg(e,t){z(()=>{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(bg)||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(`--${yg}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${yg}-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(`--${yg}-modal-dx`,`${n}px`),e.style.setProperty(`--${yg}-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 Sg({containerRef:e,onDrop:t,accept:n,disabled:r=!1}){let[i,a]=R();return z(()=>{if(r){a(void 0);return}let i=e.current;if(!i)return;let o=0;function s(e){o+=1,e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),a([...e.dataTransfer.items].every(e=>e.kind!==`file`||fp(e.type,n))?`accept`:`reject`))}function c(){--o,o>0||(o=0,a(void 0))}function l(e){e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()}function u(e){o=0,a(void 0),e.dataTransfer&&(e.preventDefault(),t(e.dataTransfer.items))}return i.addEventListener(`dragenter`,s),i.addEventListener(`dragleave`,c),i.addEventListener(`dragover`,l),i.addEventListener(`drop`,u),()=>{i.removeEventListener(`dragenter`,s),i.removeEventListener(`dragleave`,c),i.removeEventListener(`dragover`,l),i.removeEventListener(`drop`,u)}},[n,e,r,t]),r?void 0:i}const Q=i.cssPrefix;function Cg(e){let{options:t,onClose:n}=e,r=t.strings,i=B(null);z(()=>{let e=i.current;if(!e||!n)return;let t=vf(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.sendPreparing&&e.options.features.fileUpload,s=Sg({containerRef:i,onDrop:V(e=>{o&&a.current?.attachFromDrop(e)},[a,o]),accept:e.options.attachments.accept,disabled:!o});return xg(i.current,t.mode===`modal`),/* @__PURE__ */ U(`div`,{ref:i,class:`${Q}-panel`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":r.panelTitle,style:{position:`relative`},"data-testid":Y.panel,children:[/* @__PURE__ */ U(wg,{...e,containerEl:i.current,dragOver:s}),/* @__PURE__ */ U(Mg,{poweredBy:e.options.poweredBy,strings:e.options.strings})]})}function wg(e){let{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,composerKey:s,panelSize:c,view:l,isStreaming:u,isMemoryCompacting:d,canReleaseQueuedMessages:f,queueManualMessages:p,replyAwaitsCard:m,sendPreparing:h,attachmentUploadsSig:g,controlMode:_,assignedOperator:v,operatorAvailable:y,operatorRequestEnabled:b,onRequestOperator:x,onCancelOperatorRequest:S,loadingMessages:C,onLoadPreviousMessages:w,messagesSig:ee,reconnectingSig:T,agent:E,ticketReference:D,login:O,onStartAsGuest:te,suggestions:k,initialWidgetSize:ne,onClose:re,onBack:ie,onExpand:A,onToggleHistory:ae,onSelectHistoryConversation:j,onNewConversation:oe,onWidgetSizeChange:se,onSend:ce,onStop:le,onSuggestion:ue,tool:M,onRetry:de,onMessageFeedback:fe,onCardAction:pe,containerEl:me,dragOver:he,composerApiRef:ge}=e,N=t.strings,_e=_===`operator`?v:void 0,ve=_e?{name:_e.name??_e.initials,avatar:_e.avatar,title:N.operatorBadgeTitle,status:`online`}:E,ye=t.header.showNotice?Pt(N,t.header.notice||`chatNotice`):void 0,be=da(()=>ee.value.some(e=>!e.ephemeral&&e.role!==`system`)).value,xe=da(()=>ee.value.length>0).value,[Se,Ce]=R(),we=Se===o,Te=t.features.emailTranscript&&be?()=>Ce(o):void 0,P=O.gate?/* @__PURE__ */ U(jg,{login:{...O,gate:O.gate},alone:!xe,onStartAsGuest:te,strings:N}):/* @__PURE__ */ U(L,{children:[_&&_!==`ai-agent`?/* @__PURE__ */ U(Eg,{controlMode:_,operatorName:v?.name??v?.initials,operatorAvailable:y,onCancelOperatorRequest:S,strings:N}):null,d&&_===`ai-agent`?/* @__PURE__ */ U(`div`,{class:`${Q}-loading ${Q}-compaction-status`,role:`status`,"data-testid":Y.compactionStatus,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-loading-spinner`,"aria-hidden":`true`}),N.compactingContext]}):null,!u&&!d&&_===`ai-agent`&&/* @__PURE__ */ U(vg,{suggestions:k,strings:N,onPick:ue,disabled:h}),/* @__PURE__ */ U(Gp,{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,maxMessageCharacters:e.maxMessageCharacters,isStreaming:u,pageToolRunning:e.pageToolRunning,isMemoryCompacting:d,canReleaseQueuedMessages:f,queueManualMessages:p,replyAwaitsCard:m,active:e.composerActive&&l===`chat`,isPreparing:h,attachmentUploadsSig:g,operatorRequestEnabled:b,canRequestOperator:be,controlMode:_,onRequestOperator:x,onSend:ce,onStop:le,apiRef:ge},s)]});return/* @__PURE__ */ U(L,{children:[l===`history`?/* @__PURE__ */ U(Tg,{strings:N,onBack:ae,onClose:re,showClose:Hu(t.mode,c,t.actions)}):/* @__PURE__ */ U(`header`,{class:`${Q}-header`,part:`header`,"data-variant":t.header.variant,"data-testid":Y.panelHeader,children:[ie?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Q}-icon-btn`,onClick:ie,"aria-label":N.moduleBack,title:N.moduleBack,children:/* @__PURE__ */ U(Dd,{})}):null,ve?/* @__PURE__ */ U(um,{agent:ve,strings:N,ticketReference:D,person:!!_e}):/* @__PURE__ */ U(`h1`,{children:N.panelTitle}),/* @__PURE__ */ U(Yf,{panelProps:O.gate?{...e,options:{...t,actions:t.actions.filter(e=>e!==`history`)}}:e,variant:`chat`,onEmailTranscript:Te,onLogIn:O.menuLogIn})]}),l===`history`?/* @__PURE__ */ U(bm,{transport:n,strings:N,locale:t.locale,persistence:a,onSelect:j,onNewConversation:oe}):/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(Sm,{state:he,strings:N}),O.strip?/* @__PURE__ */ U(kg,{strip:O.strip,onLogIn:O.onLogIn,onHide:O.onHidePrompt,strings:N}):null,O.gate&&!xe?null:/* @__PURE__ */ U(dg,{messagesSig:ee,reconnectingSig:T,pageToolRunning:e.pageToolRunning,strings:N,notice:ye,locale:t.locale,responseMode:t.responseMode,showReasoning:t.showReasoning,stepDisplay:t.stepDisplay,showSources:t.showSources,enableMessageFeedback:t.enableMessageFeedback,onFeedback:fe,loading:C,onLoadPreviousMessages:w,idle:!u&&!h,controlMode:_,tool:M,onRetry:de,onCardAction:pe}),P,/* @__PURE__ */ U(Og,{disclaimer:t.composerDisclaimer}),we?/* @__PURE__ */ U(jm,{transport:n,strings:N,knownEmail:Om({tokenEmail:O.email,userContext:t.userContext}),onClose:()=>Ce(void 0)}):null]}),t.size.resize?.enabled?/* @__PURE__ */ U(gg,{panelEl:me,resize:t.size.resize,position:t.position,edge:t.mode===`drawer`,initialSize:ne,onSizeChange:se,onResizeStart:t.mode===`floating`&&c===`expanded`?A:void 0,strings:N}):null]})}function Tg({strings:e,onBack:t,onClose:n,showClose:r}){return/* @__PURE__ */ U(`header`,{class:`${Q}-header`,part:`header`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${Q}-icon-btn`,onClick:t,"aria-label":e.historyBack,title:e.historyBack,children:/* @__PURE__ */ U(Dd,{})}),/* @__PURE__ */ U(`h1`,{children:e.historyTitle}),r?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Q}-icon-btn`,onClick:n,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ U(id,{})}):null]})}function Eg({controlMode:e,operatorName:t,operatorAvailable:n,onCancelOperatorRequest:r,strings:i}){let[a,o]=R(!1),s=Dg(e,t,n,i);function c(){r&&(o(!0),r().finally(()=>o(!1)))}return/* @__PURE__ */ U(`div`,{class:`${Q}-operator-banner`,"data-mode":e,"data-available":n===!1?`false`:void 0,"data-testid":Y.operatorBanner,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-operator-pulse`,"aria-hidden":`true`}),/* @__PURE__ */ U(`span`,{class:`${Q}-operator-label`,role:`status`,children:s}),e===`awaiting-operator`&&r?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Q}-icon-btn ${Q}-operator-dismiss`,onClick:c,disabled:a,"aria-label":i.cancelOperatorRequest,title:i.cancelOperatorRequest,"data-testid":Y.cancelOperatorRequest,children:/* @__PURE__ */ U(id,{})}):null]})}function Dg(e,t,n,r){return e===`operator`?r.chattingWithOperator.replace(`{operator}`,t??``):n===!1?r.noOperatorAvailable:r.connectingOperator}function Og({disclaimer:e}){return e?/* @__PURE__ */ U(`div`,{class:`${Q}-composer-footer`,children:/* @__PURE__ */ U(`div`,{class:`${Q}-disclaimer`,children:e})}):null}function kg({strip:e,onLogIn:t,onHide:n,strings:r}){let i=e.kind===`user`;return/* @__PURE__ */ U(`div`,{class:`${Q}-login-bar`,"data-kind":e.kind,role:i?`status`:`note`,"data-testid":i?Y.loggedIn:Y.loginBar,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-login-bar-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(pd,{})}),i?/* @__PURE__ */ U(`span`,{class:`${Q}-login-bar-text`,children:e.who?r.loggedInAs.replace(`{name}`,e.who):r.loggedIn}):/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`span`,{class:`${Q}-login-bar-text`,children:r.loginPrompt}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Q}-login-bar-action`,onClick:t,"data-testid":Y.loginBarAction,children:r.loginAction}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Q}-icon-btn ${Q}-login-bar-hide`,onClick:n,"aria-label":r.dismissLoginPrompt,title:r.dismissLoginPrompt,"data-testid":Y.loginBarHide,children:/* @__PURE__ */ U(id,{})})]})]})}function Ag(e,t){return e.gate===`required`?t.loginRequired:e.canStartAsGuest?t.loginExpiredGuest:t.loginExpired}function jg({login:e,alone:t,onStartAsGuest:n,strings:r}){return/* @__PURE__ */ U(`div`,{class:`${Q}-login-gate`,"data-gate":e.gate,"data-alone":t?``:void 0,"data-testid":Y.loginGate,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-login-gate-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(pd,{})}),/* @__PURE__ */ U(`p`,{class:`${Q}-login-gate-title`,role:`status`,children:Ag(e,r)}),e.canLogIn||e.canStartAsGuest?/* @__PURE__ */ U(`div`,{class:`${Q}-form-actions ${Q}-login-gate-actions`,children:[e.canStartAsGuest?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Q}-form-skip`,onClick:n,"data-testid":Y.loginGateGuest,children:r.startAsGuest}):null,e.canLogIn?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Q}-form-submit`,onClick:e.onLogIn,"data-testid":Y.loginGateAction,children:r.loginAction}):null]}):null]})}function Mg({poweredBy:e,strings:t}){return e?/* @__PURE__ */ U(`div`,{class:`${Q}-poweredby-bar`,children:/* @__PURE__ */ U(Ng,{logoUrl:e.logoUrl,text:e.text??t.poweredBy.replace(`{name}`,i.displayName),href:e.href})}):null}function Ng({logoUrl:e,text:t,href:n}){let r=/* @__PURE__ */ U(L,{children:[e?/* @__PURE__ */ U(`img`,{class:`${Q}-poweredby-logo`,src:e,alt:``,loading:`lazy`}):null,t?/* @__PURE__ */ U(`span`,{children:t}):null]});return n?/* @__PURE__ */ U(`a`,{class:`${Q}-poweredby`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:r}):/* @__PURE__ */ U(`span`,{class:`${Q}-poweredby`,children:r})}const Pg=i.cssPrefix;function Fg({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=B(null),f=B(/* @__PURE__ */ new Set);z(()=>{let t=d.current;if(!t||!e.onClose)return;let n=vf(t);function r(t){t.key===`Escape`&&e.onClose?.()}return t.addEventListener(`keydown`,r),()=>{n(),t.removeEventListener(`keydown`,r)}},[e.onClose]);let p=da(()=>n.sig.value).value,m=Yu(p),h=l.modules.byId[p.activeTab],g=e.composerActive&&h?.layout===`chat`&&m===void 0,_=e.composerApiRef,v=g&&e.view===`chat`&&!e.sendPreparing&&e.options.features.fileUpload,y=Sg({containerRef:d,onDrop:V(e=>{v&&_.current?.attachFromDrop(e)},[_,v]),accept:e.options.attachments.accept,disabled:!v});xg(d.current,l.mode===`modal`);let b=m?.kind===`content`,x=t.length>1&&Xu(p),S=B(null);z(()=>{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 ee=/* @__PURE__ */ U(Yf,{panelProps:e,variant:`plain`});h&&f.current.add(h.id);let T=t.filter(e=>f.current.has(e.id));function E(t){if(t.layout===`chat`)return/* @__PURE__ */ U(wg,{...e,composerActive:g,containerEl:d.current,dragOver:y});let n=om[t.layout].Root;return n?/* @__PURE__ */ U(n,{...w(t)}):null}function D(){return m?.kind===`content`?/* @__PURE__ */ U(Bf,{id:m.id,title:m.title,transport:e.transport,strings:u,bus:r,onBack:()=>n.pop(),actions:ee}):null}return/* @__PURE__ */ U(`div`,{ref:d,class:`${Pg}-panel ${Pg}-messenger`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":u.panelTitle,style:{position:`relative`},"data-testid":Y.messengerHome,children:[/* @__PURE__ */ U(`div`,{class:`${Pg}-messenger-body`,children:[T.map(e=>/* @__PURE__ */ U(`div`,{class:`${Pg}-messenger-pane`,hidden:b||e.id!==h?.id,children:E(e)},e.id)),D()]}),x?/* @__PURE__ */ U(cm,{modules:t,activeTab:p.activeTab,strings:u,hasUnread:i,onSelect:e=>n.switchTab(e)}):null,/* @__PURE__ */ U(Mg,{poweredBy:l.poweredBy,strings:l.strings}),l.size.resize?.enabled&&(h?.layout!==`chat`||m)?/* @__PURE__ */ U(gg,{panelEl:d.current,resize:l.size.resize,position:l.position,edge:l.mode===`drawer`,initialSize:e.initialWidgetSize,onSizeChange:e.onWidgetSizeChange,onResizeStart:l.mode===`floating`&&e.panelSize===`expanded`?e.onExpand:void 0,strings:u}):null]})}function Ig(e){let t=i.cssPrefix,{site:n,blocks:r,strings:a,collapsed:o}=e,s=r?.navigation??[],c=r?.linkCards??[],l=o?a.expandSidebar:a.collapseSidebar;return/* @__PURE__ */ U(`aside`,{class:`${t}-sidebar`,"data-collapsed":o?`true`:`false`,"data-testid":Y.sidebar,children:[/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-header`,children:[/* @__PURE__ */ U(Lg,{site:n}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${t}-sidebar-toggle`,"aria-label":l,"aria-expanded":o?`false`:`true`,title:l,onClick:e.onToggleCollapsed,"data-testid":Y.sidebarToggle,children:/* @__PURE__ */ U(Rg,{collapsed:o})})]}),o?null:/* @__PURE__ */ U(L,{children:[s.length>0?/* @__PURE__ */ U(`nav`,{class:`${t}-sidebar-section`,"data-section":`navigation`,children:/* @__PURE__ */ U(zg,{items:s})}):null,c.length>0?/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-section`,"data-section":`link-cards`,children:/* @__PURE__ */ U(Bg,{items:c})}):null,e.showConversations?/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-conversations`,children:/* @__PURE__ */ U(bm,{transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,onSelect:e.onSelectConversation,onNewConversation:e.onNewConversation})}):null]})]})}function Lg({site:e}){let t=i.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??i.name})}function Rg({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 zg({items:e}){let t=i.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 Bg({items:e}){let t=i.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 Vg=i.cssPrefix;function Hg(e){return/* @__PURE__ */ U(`main`,{class:`${Vg}-page-shell`,"data-sidebar-collapsed":e.sidebarCollapsed?`true`:`false`,children:[/* @__PURE__ */ U(Ig,{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:`${Vg}-page-chat`,"aria-label":e.strings.panelTitle,children:e.children})]})}const Ug=i.cssPrefix;function Wg({strings:e,text:t,onClose:n}){return/* @__PURE__ */ U(`div`,{class:`${Ug}-panel ${Ug}-panel-notice`,part:`panel`,role:`dialog`,"aria-label":e.panelTitle,"data-testid":Y.panelNotice,children:[n?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Ug}-icon-btn ${Ug}-panel-notice-close`,onClick:n,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ U(id,{})}):null,/* @__PURE__ */ U(`p`,{class:`${Ug}-panel-notice-text`,children:t})]})}const Gg=_.scope(`hitl`);function Kg(e){return e.kind===`tool`&&P(e.toolMetadata)&&(e.stateSig.value===`input-available`||e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved===!0)}function qg(e,t){t.errorSig.value=Me(t.toolCallId),t.stateSig.value=`output-error`,e.partsSig.value=[...e.partsSig.value]}function Jg(e,t){let n=e.slice(0,e.indexOf(t)).findLast(e=>e.role===`user`);return n!==void 0&&M.sentHere(n.id)}function Yg(e){let{streaming:t,controlModeSig:n,messagesSig:r,sendAiTurn:i,bus:a,humanInLoop:o,tools:s}=e,c=B(t);c.current=t;let l=B(s);l.current=s;let u=B(/* @__PURE__ */ new Map),d=da(()=>{let e=r.value,t=e.at(-1);return n.value!==`ai-agent`||t?.role!==`assistant`||t.status!==`complete`?!1:t.partsSig.value.some(e=>Kg(e)&&M.get(e.toolCallId)?.state!==`stopped`)&&Jg(e,t)}).value,f=V((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 Gg.warn(`decideTool: tool part not found`,{toolCallId:e}),!1;if(o.status!==`complete`||!Al(o,s)||!t(l))return!1;if(a(l),o.partsSig.value=[...o.partsSig.value],!Ol(o)||o.partsSig.value.some(Kg))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]),p=V((e,t)=>{let{toolCallId:n,toolName:r}=t;u.current.has(n)||(u.current.set(n,e),Ae({toolCallId:n,toolName:r,input:t.inputSig.value,optionTools:l.current??[],onSettled:(e,t)=>{Gg.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(n,Kg,t=>{e.state===`output-available`?t.outputSig.value=e.output:t.errorSig.value=e.errorText,t.stateSig.value=e.state})}))},[a,f]),m=V(()=>{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),Ne(t))}let t=e.at(-1);if(c.current||t?.role!==`assistant`||t.status!==`complete`)return;let n=t.partsSig.value.filter(Kg);if(n.length!==0&&Jg(e,t))for(let e of n)M.get(e.toolCallId)?.state===`stopped`?qg(t,e):p(t.id,e)},[r,p]);z(()=>m(),[t,m]),z(()=>r.subscribe(()=>m()),[r,m]);let h=V((e,t,n)=>{let i=!1,o;if(!f(e,e=>e.stateSig.value===`approval-requested`,r=>{P(r.toolMetadata)&&(o=r),i=r.toolMetadata?.card===`questions`;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&&p(s.id,o),o&&!t&&a.emit(`toolResult`,{toolCallId:e,name:Ee(o.toolName),status:`declined`,durationMs:0}),i?(Gg.info(`toolResult`,{toolCallId:e}),a.emit(`toolResult`,{toolCallId:e})):(Gg.info(`toolDecision`,{toolCallId:e,approved:t}),a.emit(`toolDecision`,{toolCallId:e,approved:t}))},[a,f,r,p]),g=V(e=>{f(e,e=>e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved!==void 0&&!Kg(e),t=>{let n=t.approvalSig.value?.id??e;t.approvalSig.value={id:n},t.stateSig.value=`approval-requested`})},[f]);return{toolInteraction:bi(()=>({humanInLoop:o,onDecision:h,onEdit:g,preview:(e,t)=>Oe({toolName:e,input:t,optionTools:l.current??[]})}),[o,h,g]),pageToolsRunning:d,stopPageTools:V(()=>{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?qg(e,n):Me(t),Gg.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()},[a,r])}}const Xg=_.scope(`latest-news`);function Zg({transport:e,options:t,persistence:n,enabled:r}){let i=t.modules.list.find(e=>e.layout===`news`)?.contentCollectionIds,a=i?.join(`,`),[o,s]=R(),[c,l]=R(()=>n.loadSeenNewsId());z(()=>{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=>Xg.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 Qg({callout:e,persistence:t}){let n=e?.text??``,r=e?.persistent??!0,[i,a]=R(()=>!r&&t.loadCalloutDismissed(n));return z(()=>{a(!r&&t.loadCalloutDismissed(n))},[n,r,t]),{dismissed:i,dismissCallout:V(()=>{a(!0),r||t.saveCalloutDismissed(n)},[t,n,r])}}const $g=_.scope(`login`);function e_(e,t){switch(e.status){case`required`:return`required`;case`expired`:return`expired`;case`anonymous`:return t?`required`:void 0;case`pending`:case`loggedIn`:return;default:return e}}function t_(e,t,n){if(e.status===`loggedIn`)return t.hideUser?void 0:{kind:`user`,who:e.name??e.email};if(!(e.status!==`anonymous`||!t.url||t.hidePrompt||n))return{kind:`prompt`}}function n_(e){let{state:t,deployment:n,bus:r,persistence:i,conversationIdSig:a}=e,[o,s]=R(()=>i.loadLoginPromptDismissedIn()),c=da(()=>a.value).value,l=o!==void 0&&o===c,u=(t.status===`required`?t.loginUrl:void 0)??n.url,d=e_(t,n.required),f=V(()=>{let e=qa(),t=r.listensTo(`loginRequested`);if($g.info(`loginRequested`,{pageLogsIn:t}),r.emit(`loginRequested`,{returnTo:e}),t||!u)return;let n=a.value;n&&i.saveLoginReturn({conversationId:n,draft:i.loadDraft(n)}),i.savePanelOpen(!1),Ja(Ha(u,e))},[r,a,u,i]),p=V(()=>{let e=a.value;e&&(i.dismissLoginPromptIn(e),s(e))},[a,i]),m=!!u||r.listensTo(`loginRequested`);return{strip:t_(t,n,!!d||l),gate:d,canStartAsGuest:d===`expired`&&!n.required,email:t.status===`loggedIn`?t.email:void 0,canLogIn:m,onLogIn:f,menuLogIn:t.status===`anonymous`&&!d&&m?f:void 0,onHidePrompt:p}}function r_(e){let{transport:t,conversationIdSig:n}=e,r=ua(`ai-agent`),i=ua(void 0),a=ua(void 0),o=B(void 0),s=V(e=>{let t=e.controlRevision,s=o.current;if(s&&s.conversationId===n.value&&t<s.revision)return;o.current={conversationId:n.value,revision:t},r.value=e.controlMode;let c=e.assignedOperatorInitials;i.value=c?{initials:c,name:e.assignedOperatorName,avatar:e.assignedOperatorAvatar}:void 0,e.controlMode===`awaiting-operator`?e.operatorAvailable!==void 0&&(a.value=e.operatorAvailable):a.value=void 0},[n,r,i,a]);return{controlModeSig:r,assignedOperatorSig:i,operatorAvailableSig:a,applyControlState:s,adoptControlStateChunk:V(e=>{if(e.type!==`data-control-state`)return;let t=tl(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 i_=i.cssPrefix,a_=`--${i_}-visual-viewport-height`,o_=`--${i_}-visual-viewport-top`;function s_(e){let{hostElement:t,mode:n,panelSize:r,isOpen:i,surfaceReady:a,onClose:o}=e;yi(()=>{ei(t,Qu(n,r,i))},[t,i,r,n]),yi(()=>{if(!i||!a)return;let e=t.ownerDocument.defaultView,n=e?.visualViewport,r=t.shadowRoot?.querySelector(`.${i_}-anchor`);if(!e||!n||!r)return;let o=()=>{r.style.setProperty(a_,`${n.height}px`),r.style.setProperty(o_,`${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(a_),r.style.removeProperty(o_)}},[t,i,a]),z(()=>{if(n!==`modal`||!i)return;function e(e){e.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains(`${i_}-panel`))||o()}return t.addEventListener(`click`,e),()=>t.removeEventListener(`click`,e)},[t,i,n,o]),z(()=>{if(n!==`drawer`||!i)return;function e(e){e.key===`Escape`&&!e.composedPath().includes(t)&&o()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,i,n,o])}const c_=_.scope(`reducer`);var l_=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),S(this,`turnChunks`,[]),S(this,`turnRow`,null)}attach(e){this.active=e,this.openTextParts.clear()}detach(){this.active=null,this.replay=null,this.openTextParts.clear()}beginReplay(e,t){let n=cl();n.id=e.id;let r=u_(e)||kl(e)&&(e.status!==`streaming`||Ol(e)),i=e.status===`streaming`&&Ol(e)&&Dl(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,d_(a,i),e.liveCatchUp&&u_(e.shadow)&&(i.status===`streaming`||kl(i))?(e.probeContinuation=!1,e.continuationTailReplay=!1,e):(e.probeContinuation=u_(i)||kl(i)&&(i.status!==`streaming`||Ol(i)),e.continuationTailReplay=i.status===`streaming`&&Ol(i)&&Dl(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;d_(e,i);let a=u_(e)&&kl(i);return i.status!==`streaming`&&!a?(this.detach(),null):(this.replayTurn(),this.replay?this.replay.shadow:this.active)}replayTurn(){let[e,...t]=this.turnChunks;if(e?.type!==`start`)return;let n=this.messagesSig.value.find(t=>t.serverMessageId===e.messageId);if(n!==void 0&&n!==this.turnRow){this.detach();for(let n of[e,...t])this.applyResume(n)}}promoteReplay(e){let{baseline:t,shadow:n}=e;return Mi(()=>{t.role=n.role,t.serverMessageId=n.serverMessageId,t.operatorInitials=n.operatorInitials,t.status=n.status,n.canceled&&(t.canceled=!0),t.finishReason=n.finishReason,t.errorText=n.errorText,t.suggestions=n.suggestions??t.suggestions,t.runStartedAt=n.runStartedAt??t.runStartedAt,t.stepTimings=n.stepTimings??t.stepTimings,t.partsSig.value=n.partsSig.value,this.messagesSig.value=[...this.messagesSig.value]}),this.replay=null,this.active=t,t}promoteContinuation(e){let{baseline:t,chunks:n}=e,r=jl(t);return this.replay=null,Mi(()=>{t.partsSig.value=t.partsSig.value.slice(0,f_(t,n)+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,t){let{baseline:n}=e,r=jl(n);return this.replay=null,Mi(()=>{n.awaitingContinuation=!1,n.status=`streaming`,n.finishReason=void 0,n.errorText=void 0,n.suggestions=void 0,this.attach(n),this.apply(t),n.continuationStreaming=r||void 0,this.messagesSig.value=[...this.messagesSig.value]}),n}applyResume(e){e.type===`start`&&(this.turnChunks=[]);let t=this.applyTurnChunk(e);return this.turnChunks.push(e),this.turnRow=t??this.replay?.baseline??this.active??this.turnRow,t}applyTurnChunk(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&&!Sl(a))return this.attach(a),this.apply(e),null;let o=cl();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(!g_(n,r,e)){if(s){if(n.status===`streaming`&&n.awaitingContinuation!==!0){let n=this.settleOwnedContinuation(t,e);return this.detach(),n}b_(n,r)&&(n.continuationStreaming=!0,this.messagesSig.value=[...this.messagesSig.value],this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id})),this.detach()}return null}let i=u_(n)&&s?this.settleOwnedContinuation(t,e):this.promoteContinuation(t);return s?(i.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:i.serverMessageId??i.id}):i.continuationStreaming=!1),this.detach(),i):null}if(a&&m_(n,r)){let e=this.promoteContinuation(t);return s?(this.detach(),e):null}if(!o)return s&&this.detach(),null;if(s&&!Sl(n)&&Sl(r)){let e=this.promoteReplay(t);return this.detach(),e}if(!p_(n,r))return s&&(this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}),this.detach()),null;let c=this.promoteReplay(t);return s?(this.detach(),c):null}let t=this.refreshActive();if(!t)return null;if(this.replay)return this.applyTurnChunk(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),S_(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?.runStartedAt&&(t.runStartedAt=n.runStartedAt),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`:S_(t,{kind:`step-start`,id:`ss-${this.partSeq++}`});return;case`message-metadata`:t.stepTimings=pl(e.messageMetadata?.steps)??t.stepTimings;return;case`finish`:c_.debug(`finish`,{reason:e.finishReason}),t.stepTimings=pl(e.messageMetadata?.steps)??t.stepTimings,t.status=`complete`,t.retryAction=void 0,e.finishReason&&(t.finishReason=e.finishReason),this.bumpDone(t);return;case`error`:c_.warn(`stream error chunk`,{errorText:e.errorText}),t.status=`error`,t.errorText=void 0,this.bumpDone(t);return;case`abort`:c_.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`:case`tool-approval-response`:w_(t,e);return;case`file`:S_(t,{kind:`file`,url:e.url,mediaType:e.mediaType,filename:e.filename,fileId:e.fileId,fileSize:e.fileSize});return;case`source-url`:C_(t,{kind:`source`,sourceId:e.sourceId,url:e.url,title:e.title});return;case`source-document`:C_(t,{kind:`source`,sourceId:e.sourceId,title:e.title,filename:e.filename,mediaType:e.mediaType});return;case`data-suggestions`:t.suggestions=rl(e.data);return;case`data-control-state`:t.operatorRoutedTurn=e.data.controlMode!==`ai-agent`;return;case`data-memory-compaction-state`:return}}bumpDone(e){Mi(()=>{e.partsSig.value=[...e.partsSig.value],this.messagesSig.value.includes(e)&&(this.messagesSig.value=[...this.messagesSig.value])})}};function u_(e){return e.awaitingContinuation===!0||e.continuationStreaming===!0||e.retryAction?.kind===`continue-assistant`}function d_(e,t){e.canceled&&(t.canceled=!0),u_(e)&&(t.status===`streaming`||kl(t))&&(t.awaitingContinuation??(t.awaitingContinuation=e.awaitingContinuation),t.continuationStreaming??(t.continuationStreaming=e.continuationStreaming),t.retryAction===void 0&&(t.retryAction=e.retryAction))}function f_(e,t){let n=e.partsSig.value,r=t.findIndex(e=>e.type===`start-step`),i=new Set(t.slice(0,r<0?t.length:r).flatMap(e=>`toolCallId`in e&&e.type.startsWith(`tool-output`)?[e.toolCallId]:[])),a=n.findLastIndex(e=>e.kind===`tool`&&(e.stateSig.value===`approval-requested`||e.stateSig.value===`approval-responded`||i.has(e.toolCallId)));if(a>=0)return a;let o=new Set(t.flatMap(e=>e.type===`tool-input-start`||e.type===`tool-input-available`?[e.toolCallId]:[]));return n.some(e=>e.kind===`tool`&&o.has(e.toolCallId))?-1:n.findLastIndex(e=>e.kind===`tool`)}function p_(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)=>h_(e,r[t]))}function m_(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)=>h_(e,a[t]))}function h_(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||!Ul(t.toolName,e.toolName)||Wl[t.stateSig.value]<Wl[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 g_(e,t,n){return __(e,n)||!v_(e,t)?!0:n.type!==`finish`&&n.type!==`error`&&n.type!==`abort`?!1:Dl(t)||e.awaitingContinuation===!0&&n.type!==`finish`?!0:e.awaitingContinuation===!0&&t.partsSig.value.every(e=>e.kind===`step-start`)}function __(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&&Wl[n.stateSig.value]<4}function v_(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)=>y_(r[t+n],e)))}function y_(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`||Ul(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 b_(e,t){if(u_(e)||!kl(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 x_(e,t,n={}){let r=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);if(r)return n.dynamic&&(r.dynamic=!0),r.toolMetadata??(r.toolMetadata=n.toolMetadata),r.title=n.title??r.title,r;let i={kind:`tool`,toolCallId:t,toolName:n.toolName??`tool`,title:n.title,dynamic:n.dynamic?!0:void 0,toolMetadata:n.toolMetadata,inputPartialSig:H(``),inputSig:H(void 0),outputSig:H(void 0),errorSig:H(void 0),stateSig:H(`input-streaming`),approvalSig:H(void 0)};return S_(e,i),i}function S_(e,t){e.partsSig.value=[...e.partsSig.value,t]}function C_(e,t){e.partsSig.value.some(e=>e.kind===`source`&&e.sourceId===t.sourceId)||S_(e,t)}function w_(e,t){switch(t.type){case`tool-input-start`:x_(e,t.toolCallId,t);return;case`tool-input-delta`:{let n=x_(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case`tool-input-available`:{let n=x_(e,t.toolCallId,t);n.inputSig.value=t.input,n.stateSig.value=`input-available`;return}case`tool-input-error`:{let n=x_(e,t.toolCallId,t);n.inputSig.value=t.input,n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-approval-request`:{let n=x_(e,t.toolCallId,t);if(t.isAutomatic){n.approvalSig.value={id:t.approvalId,isAutomatic:!0};return}n.approvalSig.value={id:t.approvalId},n.stateSig.value=`approval-requested`;return}case`tool-approval-response`:{let n=e.partsSig.value.find(e=>e.kind===`tool`&&e.approvalSig.value?.id===t.approvalId);n?.approvalSig.value&&(n.approvalSig.value={...n.approvalSig.value,approved:t.approved,reason:t.reason});return}case`tool-output-available`:{let n=x_(e,t.toolCallId,t);n.outputSig.value=t.output,n.stateSig.value=`output-available`;return}case`tool-output-error`:{let n=x_(e,t.toolCallId,t);n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-output-denied`:{let n=x_(e,t.toolCallId);n.stateSig.value=`output-denied`;return}default:return}}const T_=1e3;async function E_(e){let t=T_,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;e.onDropped?.(),o!==void 0&&e.now()-o>=1e3&&(t=T_),await e.sleep(t),t=Math.min(t*2,15e3)}}function D_(e){let{activated:t,conversationReady:n,paused:r,conversationIdSig:i,messagesSig:a,optionsRef:o,transport:s,visitorId:c,adoptControlStateChunk:l,adoptMemoryCompactionStateChunk:u,settleSuggestions:d,recordConversationReply:f,transcriptRecoverySig:p,beginConversationTranscript:m,commitConversationTranscript:h,runCancellation:g,feedback:_,bus:v,loadInitialThread:y,shouldReconcileOnConnect:b,reconnectingSig:x}=e,S=B(0);z(()=>{if(!t||!n||r||!i.value)return;let e=i.value,C=new AbortController,w=e=>{},ee=new l_(a,e=>w(e));s.primeIdentity(c,e);let T=!1,E=!1,D,O=!1,te,k=0,ne,re,ie=Date.now(),A,ae=!1,j=!1,oe=!1,se;function ce(t,n){if(!Sl(t))return;let r=a.value.findLast(e=>!e.ephemeral),i=t.serverMessageId??t.id;if(!(r&&(r.serverMessageId??r.id)!==i)){if(A&&ae&&!a.value.some(e=>e.role===`user`&&!e.ephemeral))se={replyId:i,activityAt:n};else return xl(a.value,t,e,o.current.strings.newConversation,n)}}function le(e,t,n){let r=ce(e,n);if(!r)return;let i=`${e.serverMessageId??e.id}:${t}:${r.preview??``}`;i!==re&&(re=i,s.publishConversation({...r,hasUnread:!0},!0))}let ue;function M(){ue&&(clearTimeout(ue.timer),ue=void 0)}function fe(){let e=ue;if(!e)return;clearTimeout(e.timer),ue=void 0;let t=a.value.find(t=>(t.serverMessageId??t.id)===e.replyId);(t?.role===`assistant`||t?.role===`operator`)&&le(t,e.generation,e.activityAt)}function pe(e,t,n){M(),ue={replyId:e.serverMessageId??e.id,generation:t,activityAt:n,timer:setTimeout(fe,120)}}function me(e,t,n=Date.now(),r=!0){M();let i=ce(e,n);if(!i)return;let a=`${e.serverMessageId??e.id}:${t}`;a!==ne&&(ne=a,f(i),r&&A&&!ae&&(j=!0))}function he(e,t){(e||!g.localSendRef.current)&&g.settle(t)}function ge(e,t=[],n=!1,r,i=k,s=Date.now(),c=!0){let l=o.current;if(e.canceled){me(e,i,s,c),he(n,r);return}let u=!0,f=e.status===`error`;switch(Yl(e,f)){case`drop`:a.value=a.value.filter(t=>t!==e),u=!1;break;case`complete-operator-routed`:e.status=`complete`,n&&(_.play(`messageReceived`),Wu(v,l,`assistant`,bl(e)));break;case`error`:if(e.status=`error`,n){_.play(`error`);let e=/* @__PURE__ */ Error(f?`stream error chunk`:`empty reply`);v.emit(`error`,e),l.onError?.(e)}break;case`complete`:e.status=`complete`,n&&(_.play(`messageReceived`),Wu(v,l,`assistant`,bl(e))),d(e,t)}u&&me(e,i,s,c),he(n,r)}function N(t){if(C.signal.aborted||i.value!==e)return;if(l(t),u?.(t),t.type===`start`){fe();let n=t.messageId===void 0?void 0:a.value.find(e=>e.serverMessageId===t.messageId||e.id===t.messageId);O=n!==void 0&&n.status!==`streaming`;let r=te?.senderRole===`visitor`?te.messageId:void 0;te={messageId:t.messageId,senderRole:t.messageMetadata?.senderRole},k+=1,ie=Date.now(),re=void 0,T=t.messageMetadata?.senderRole===void 0,E=!1,D=T?t.messageMetadata?.runId:void 0;let i=T?t.messageMetadata?.senderMessageId:void 0;function o(e){return e.role===`assistant`&&e.retryAction?.kind===`resend-user`&&e.retryAction.messageId===i}if(i&&a.value.some(o)&&(a.value=a.value.filter(e=>!o(e))),T){let n=t.messageId!==void 0&&a.value.some(e=>e.serverMessageId===t.messageId||e.id===t.messageId),i=a.value.at(-1),o=t.messageId!==void 0&&(i?.serverMessageId===t.messageId||i?.id===t.messageId),s=g.localSendRef.current&&(!n||o)&&i?.role===`assistant`&&i.status===`streaming`&&(o||i.serverMessageId===void 0&&i.partsSig.value.length===0);E=g.captureStart(e,t,s,r)}}let n=T&&(t.type===`finish`||t.type===`error`||t.type===`abort`),r=n?D:void 0,s=n&&(E||g.ownsLocalRun(r)),c=k,d=O;n&&(T=!1,E=!1,D=void 0);let f=ee.applyResume(t),p=te?.messageId,m=p===void 0?void 0:a.value.find(e=>e.serverMessageId===p||e.id===p);O&&te?.senderRole!==`visitor`&&(f!==null||m?.status===`streaming`)&&(O=!1,d=!1);let h=!O&&(m?.role===`assistant`||m?.role===`operator`);t.type===`text-delta`&&h&&pe(m,k,ie),t.type===`text-end`&&(M(),h&&le(m,k,ie)),f?f.role===`operator`?(d||(_.play(`messageReceived`),Wu(v,o.current,`operator`,bl(f))),me(f,c,ie),O=!1,n&&(s||!g.localSendRef.current)&&g.settle(r)):f.role===`assistant`&&(ge(f,[],s,r,c,ie),O=!1):n&&(s||!g.localSendRef.current)&&g.settle(r)}async function _e(t){let n=k,r=await s.loadConversation(e,t?{ids:[t]}:void 0).catch(()=>null);if(C.signal.aborted||i.value!==e||!r)return!1;r.controlState&&l({type:`data-control-state`,data:r.controlState});let o=a.value.at(-1),c=n===k&&(t===void 0||o!==void 0&&(o.serverMessageId===t||o.id===t));if(r.messages.length===0)return!0;let u=a.value,f=t===void 0?u.at(-1):u.find(e=>e.serverMessageId===t||e.id===t),p=Bl(u,_l(r.messages)),m=Rl(r.messages),h=p.messages.filter(e=>!(e.role===`assistant`&&e.retryAction?.kind===`resend-user`&&m.has(e.retryAction.messageId)));if(!p.changed&&h.length===p.messages.length)return!0;a.value=h;let _=t===void 0?h.at(-1):h.find(e=>e.serverMessageId===t||e.id===t),v=f!==void 0&&_!==void 0&&(f.id===_.id||f.serverMessageId!==void 0&&f.serverMessageId===_.serverMessageId),y=_!==void 0&&_.status!==`streaming`&&(!v||f?.status===`streaming`),b=v&&f?.status===`streaming`?Date.now():_?.createdAt;return c&&y&&_.role===`assistant`?ge(_,_.suggestions??[],g.localSendRef.current,void 0,n,b,!1):c&&y&&_.role===`operator`?me(_,n,b,!1):c&&_?.role===`assistant`&&_.status!==`streaming`&&d(_,_.suggestions??[]),!0}let ve=/* @__PURE__ */ new Set;w=({messageId:e})=>{if(ve.has(e)||!a.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(){let e=se;se=void 0;let t=e&&a.value.find(t=>(t.serverMessageId??t.id)===e.replyId),n=t&&ce(t,e.activityAt);n&&f(n)}function be(t=!1){if(C.signal.aborted||i.value!==e){j=!1;return}if(A){j=!0;return}let n=t?y(e):void 0,r=n??(!t||b()?_e():void 0);if(!r)return;m(e),A=r,ae=n!==void 0;function a(t=!1){A===r&&(A=void 0,ee.replayTurn(),j?(j=!1,be()):(ye(),t&&h(e)))}r.then(a,()=>a(!1))}let xe=p.subscribe(e=>{e<=S.current||(S.current=e,oe&&be())});return E_({signal:C.signal,now:()=>performance.now(),sleep:e=>de(e,C.signal),connect:e=>s.connectResumeStream({signal:C.signal,onChunk:N,onConnected:()=>{x.value=!1,e()}}),onDropped:()=>{x.value=!0},onInitialBoundaryReady:()=>{oe=!0,be(!0)},backfill:()=>be()}),()=>{C.abort(),x.value=!1,M(),xe(),ee.detach()}},[t,n,r,i,i.value,c,s,l,u,d,f,p,m,h,g,a,v,_,y,b,x])}function O_(e){let{transport:t,setStreaming:n}=e,r=B(void 0),i=B(void 0),a=B(!1),o=B(void 0),s=B(!1),c=B(/* @__PURE__ */ new Map),l=B(/* @__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=>{if(e!==void 0){l.current.add(e);let t=l.current.values().next().value;l.current.size>32&&t!==void 0&&l.current.delete(t)}(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 bi(()=>({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 k_=_.scope(`send`);function A_(e,t,n,r,i){e.publishConversation({...xl(t,n,r,i),hasUnread:!1},!0)}function j_(e,t){return e.id===t.id||(e.serverMessageId??e.id)===(t.serverMessageId??t.id)}function M_(e){return e.findLast(e=>!e.ephemeral&&e.role!==`system`&&(e.role===`user`||e.status!==`streaming`||Sl(e)))}function N_(e,t,n,r,i){let a=M_(t);a?.role===`user`&&j_(a,n)&&A_(e,t,a,r,i)}function P_(e){return e instanceof tu&&e.status===404&&e.errorCode===`CONVERSATION_NOT_FOUND`}function F_(e){return!(e instanceof tu)||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 I_(e){let{transport:t,messagesSig:n,conversationIdSig:r,options:i,bus:a,feedback:o,persistence:s,visitorId:c,adoptConversationId:l,applyControlState:u,setTicket:d,settleSuggestions:f,runCancellation:p,onConversationNotFound:m}=e,h=V(()=>{let e=r.value??wr();return r.value||(r.value=e,s.saveConversationId(e)),e},[r,s]);return{sendAiTurn:V(async({continueExisting:e,turn:g,movedFromConversation:_=!1})=>{let v=h(),y=n.value.at(-1),b=g?[g]:vl(n.value,e),x=b[0];x?.role===`user`&&M.markSent(x.id);let S=b.map(yl),C=s.loadUserPrefs(),w=we(i.tools).then(n=>t.sendTurn(il({messages:S,conversationId:v,visitorId:c,userPrefs:C,clientTools:Te(n)}),{keepalive:e}));p.begin(w);try{let a=await w;if(r.value!==v||!p.acceptAck(w,a))return!1;if(l(a.conversationId),d({conversationId:a.conversationId,reference:a.ticketReference}),a.runId&&x?.role===`user`&&N_(t,n.value,x,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);let r=_l(o.messages),{messages:s,changed:c}=Bl(n.value,r);c&&(n.value=s);let l=r.findLast(e=>!e.ephemeral&&e.role!==`system`),d=M_(n.value);d&&l&&j_(d,l)&&A_(t,n.value,d,a.conversationId,i.strings.newConversation);let p=y?n.value.find(e=>e.id===y.id&&e.role===`assistant`&&e.status!==`streaming`):void 0;p&&f(p,p.suggestions??[]),!e&&y?.role===`assistant`&&n.value.includes(y)&&y.serverMessageId===void 0&&!Sl(y)&&(n.value=n.value.filter(e=>e!==y))}else y?.role===`assistant`&&n.value.includes(y)&&(y.status=`error`,y.errorText=i.strings.errorGeneric,y.retryAction=e?{kind:`continue-assistant`,messageId:y.serverMessageId??y.id}:x?.role===`user`?{kind:`resend-user`,messageId:x.id}:null,n.value=[...n.value])}return!0}catch(c){if(r.value!==v)return!1;if(!p.reject(w))return x?.role===`user`&&N_(t,n.value,x,v,i.strings.newConversation),!0;if(!e&&!_&&x?.role===`user`&&P_(c))return m(x);if(!e&&x?.role===`user`&&c instanceof tu&&c.status===401){let e=y?.role===`assistant`&&y.serverMessageId===void 0?y:void 0;return n.value=n.value.filter(t=>t!==x&&t!==e),s.saveDraft(v,bl(x)),!1}let l=Zf(c,i.strings),d=F_(c),h=g?.role===`assistant`?g:n.value.at(-1);if(e&&h?.role===`assistant`&&c instanceof tu&&c.status===409){let e=h.serverMessageId??h.id,i=await t.loadConversation(v,{ids:[e]}).catch(()=>null);if(r.value!==v)return!1;if(i){i.controlState&&u(i.controlState);let t=_l(i.messages),r=t.find(t=>(t.serverMessageId??t.id)===e);if(r&&Vl(h,r)){let{messages:r,changed:i}=Bl(n.value,t),a=r.find(t=>(t.serverMessageId??t.id)===e);if(i&&a&&a!==h)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(h)||h.status!==`streaming`)return!1;h.continuationStreaming=!0}if(e&&h?.role===`assistant`)h.status=`error`,h.errorText=l,h.retryAction=d?{kind:`continue-assistant`,messageId:h.serverMessageId??h.id}:null,n.value=[...n.value];else if(y?.role===`assistant`&&n.value.includes(y)){y.status=`error`,y.errorText=l;let e=b[0];y.retryAction=d&&e?.role===`user`?{kind:`resend-user`,messageId:e.id}:null,n.value=[...n.value]}else{let e=cl();e.status=`error`,e.errorText=l;let t=b[0];e.retryAction=d&&t?.role===`user`?{kind:`resend-user`,messageId:t.id}:null,n.value=[...n.value,e]}return o.play(`error`),a.emit(`error`,c),i.onError?.(c),!1}},[t,n,i,a,o,s,c,l,u,d,f,h,p,m]),sendRoutedTurn:V(async e=>{let u=h();e.status=`pending`,e.errorText=void 0,e.retryAction=void 0,n.value.includes(e)&&(n.value=[...n.value]),M.markSent(e.id);let f=[yl(e)],g=s.loadUserPrefs(),_=we(i.tools).then(e=>t.sendTurn(il({messages:f,conversationId:u,visitorId:c,userPrefs:g,clientTools:Te(e)})));p.beginRouted(_,e.id);try{let a=await _;return r.value===u?p.acceptRoutedAck(_,a)?(l(a.conversationId),d({conversationId:a.conversationId,reference:a.ticketReference}),N_(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(_),!1)}catch(s){let c=p.rejectRouted(_);if(r.value!==u)return!1;if(!c)return N_(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 N_(t,n.value,e,u,i.strings.newConversation),!0;if(P_(s))return m(e);k_.debug(`operator-routed send failed`,{error:s});let l=s instanceof Error?s:Error(String(s));return e.status=`error`,e.errorText=Zf(s,i.strings),e.retryAction=F_(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,d,h,p,m])}}const L_=_.scope(`unread`);function R_(e){let{transport:t,options:n,conversationIdSig:r,isConversationVisibleRef:i,activated:a,conversationReady:o}=e,s=ua(!1),c=ua(0),l=ua(0),u=B([]),d=B(void 0),f=B(!1),p=B(!1),m=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]),h=V(e=>{let t=r.value,n=u.current.find(e=>e.conversationId===t),i=vu(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,m(),o&&(l.value+=1)},[r,m,l]),g=V(()=>{if(m(),!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,m,t]),_=V(e=>{r.value===e&&(d.current=void 0,m())},[r,m]),v=V(e=>{r.value===e&&(d.current=e,g())},[r,g]),y=V(e=>d.current===e,[]),b=V((e=!1)=>{if(!n.history.enabled||!n.modules.list.some(e=>e.layout===`chat`))return;function r(e){f.current?e&&(p.current=!0):(f.current=!0,t.listConversations({limit:50},e).then(t=>{e||h({type:`snapshot`,result:t,requestedRevision:0}),g()}).catch(e=>L_.debug(`refreshUnread failed (non-fatal)`,{err:e})).finally(()=>{f.current=!1,p.current&&(p.current=!1,r(!0))}))}r(e)},[h,g,n.history.enabled,n.modules,t]),x=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]);z(()=>t.subscribeConversationChanges(h),[h,t]);let S=B(!1);return z(()=>{a&&o&&!S.current&&(S.current=!0,b())},[a,o,b]),z(()=>{if(!a)return;function e(){document.visibilityState===`visible`&&(g(),b(!0))}return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[a,g,b]),{hasUnreadSig:s,unreadCountSig:c,transcriptRecoverySig:l,markVisibleConversationRead:g,beginConversationTranscript:_,commitConversationTranscript:v,isConversationTranscriptCommitted:y,recordConversationReply:x,refreshUnread:b}}const z_=_.scope(`settings`);function B_(e){let{options:t,persistence:n,transport:r,feedback:i,hostElement:a,bus:o}=e,s=n.loadUserPrefs(),[c,l]=R(()=>s.locale??t.locale),[u,d]=R(s.themeMode),f=Zn(t.themeMode,u),[p,m]=R(()=>s.textSize??t.textSize),h=V(e=>{n.patchUserPrefs(e),r.saveUserPrefs(n.loadUserPrefs()).catch(e=>z_.warn(`saveUserPrefs failed`,{err:e}))},[n,r]);z(()=>{s.soundMuted!==void 0&&i.setMuted(s.soundMuted)},[]),z(()=>{if(f!==`host`)a.dataset.theme=f;else return Vr(e=>{a.dataset.theme=e})},[a,f,t]),z(()=>{a.dataset.textSize=p},[a,p,t]),z(()=>{let e=!0;return i.mutedSig.subscribe(t=>{e?e=!1:h({soundMuted:t})})},[i,h]);let g=Hn(c,t.availableLocales,t.defaultLocale);return z(()=>{r.setLocale(g)},[r,g]),z(()=>{a.dir=Nt(g)?`rtl`:`ltr`},[a,g]),z(()=>{g!==c&&l(g)},[g,c]),{activeLocale:c,activeThemeMode:f,activeTextSize:p,setActiveLocale:l,setActiveThemeMode:d,setActiveTextSize:m,patchAndSync:h,handleLocaleChange:V(e=>{z_.info(`localeChange`,{locale:e}),l(e),h({locale:e}),o.emit(`localeChange`,e)},[h,o]),handleThemeChange:V(e=>{z_.info(`themeChange`,{mode:e}),d(e),a.dataset.theme=e,h({themeMode:e}),o.emit(`themeChange`,e)},[a,h,o]),handleTextSizeChange:V(e=>{z_.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;z_.info(`soundToggle`,{muted:e}),o.emit(`soundToggle`,{muted:e})},[i,o])}}const $=_.scope(`app`),V_=i.cssPrefix,H_={home:`home`,chats:`chat`,help:`help`,news:`news`};function U_({options:e,hostElement:t,bus:n,recentHostEvents:r,loginRevision:a=0,onPersonChanged:o,onStartAsGuest:s}){let c=e.aiAgentDeploymentId;if(!c)throw Error(`aiAgentDeploymentId is required`);let[l]=R(()=>Dr(e.widgetId,e.storage,e.aiAgentDeploymentId)),[u,d]=R(()=>l.getVisitorId()),f=l.loadUserPrefs(),p=ua(l.loadConversationId()),m=B(p.value!==void 0),h=ua(p.value??``),g=ua([]),_=ua(!1),[v,y]=R(!1),b=B(void 0);function x(){let t=e.modules.list,n=new Set(t.map(e=>e.id)),r=l.loadActiveModule();return r&&n.has(r)?r:t[0]?.id??``}function S(){return e.modules.list.find(e=>e.layout===`chat`)?.id}function C(){let t=S();return t?e.modules.list.length===1||T.sig.value.activeTab===t:!1}let ee=B(void 0);if(!ee.current){let t=e.modules.list.map(e=>e.id),n=l.loadActiveModule()??t[0]??``;ee.current=qu(n,n?[...t,n]:t,e=>l.saveActiveModule(e))}let T=ee.current,E=da(()=>T.sig.value.activeTab).value,D=da(()=>p.value).value,[O,te]=R(!1),[k,ne]=R(!1),re=e.mode===`standalone`||e.mode===`inline`,ie=B(ed(e,td(),l.loadPanelOpen(),l.loadPanelSize())),[A,ae]=R(ie.current.panelOpen),[j,oe]=R(ie.current.panelOpen),se=B(void 0),ce=B(void 0),le=B(!1),ue=B(void 0),M=B(e.strings),de=B(void 0);z(()=>{A&&oe(!0)},[A]);let fe=B(!1),[pe,me]=R(!1),he=B(null),ge=B(!1),{dismissed:N,dismissCallout:_e}=Qg({callout:e.launcher.callout,persistence:l}),ve=e.launcher.callout?.persistent??!0,ye=V(()=>{$.info(`calloutDismiss`),n.emit(`calloutDismiss`,void 0),_e()},[n,_e]),[be,xe]=R(ie.current.panelSize),Se=B(!1),[Ce,we]=R(`chat`),Te=B(()=>!1);Te.current=()=>A&&Ce===`chat`&&!document.hidden&&C();let[P,Ee]=R(!1),De=B(P);De.current=P;let Oe=B(null),[ke,Ae]=R(!1),je=ua(/* @__PURE__ */ new Map),Me=V((e,t)=>{let n=new Map(je.value);t?n.set(e,t):n.delete(e),je.value=n},[je]),[Ne,F]=R(null),[Pe,Fe]=R(),[Ie,Le]=R([]),Re=B(e);Re.current=e;let[ze,Be]=R(void 0),[Ve,He]=R(void 0),[Ue,We]=R(()=>l.loadSidebarCollapsed()??!1),[Ge,Ke]=R({status:`anonymous`}),[qe,Je]=R({}),[Ye,Xe]=R(),[I]=R(()=>new Tu({agentApiBaseUrl:e.agentApiBaseUrl,dataApiBaseUrl:e.dataApiBaseUrl,auth:ha({publicKey:e.publicKey,aiAgentDeploymentId:c,publicKeyHeader:`x-public-key`}),endpoints:e.endpoints,recentHostEvents:r,onLoginState:Ke,continueLink:e.continueLink})),[Ze]=R(()=>new La(e.sound,e.haptics)),Qe=O_({transport:I,setStreaming:Ee}),{activeLocale:L,activeThemeMode:$e,activeTextSize:et,setActiveLocale:tt,setActiveThemeMode:nt,setActiveTextSize:rt,patchAndSync:it,handleLocaleChange:at,handleThemeChange:ot,handleTextSizeChange:st,handleSoundToggle:ct}=B_({options:e,persistence:l,transport:I,feedback:Ze,hostElement:t,bus:n}),{controlModeSig:lt,assignedOperatorSig:ut,operatorAvailableSig:dt,applyControlState:ft,adoptControlStateChunk:pt,requestOperator:mt,cancelOperatorRequest:ht}=r_({transport:I,conversationIdSig:p}),gt=ua(/* @__PURE__ */ new Map),_t=V(e=>{if(e.type!==`data-memory-compaction-state`)return;let t=p.value;if(!t)return;let n=nl(e.data);if(!n)return;let r=gt.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(gt.value);i.set(t,n),gt.value=i},[p,gt]),{hasUnreadSig:vt,unreadCountSig:yt,transcriptRecoverySig:bt,markVisibleConversationRead:xt,beginConversationTranscript:St,commitConversationTranscript:Ct,isConversationTranscriptCommitted:wt,recordConversationReply:Tt,refreshUnread:Et}=R_({transport:I,options:e,conversationIdSig:p,isConversationVisibleRef:Te,activated:j,conversationReady:O}),Ot=n_({state:Ge,deployment:qe,bus:n,persistence:l,conversationIdSig:p}),kt=A&&e.modules.byId[E]?.layout===`home`,At=Zg({transport:I,options:e,persistence:l,enabled:O&&kt});z(()=>{xt()},[E,A,Ce,D,xt]),z(()=>{Ze.update(e.sound,e.haptics)},[Ze,e.sound,e.haptics]),z(()=>()=>Ze.destroy(),[Ze]),z(()=>{!Se.current&&e.size.initialSize&&(Se.current=!0,l.loadPanelSize()||xe($u(e.mode,e.size,td())))},[e.mode,e.size,l]),z(()=>{if(!O||fe.current)return;fe.current=!0;let t=ed(e,td(),l.loadPanelOpen(),l.loadPanelSize());ae(t.panelOpen),xe(t.panelSize)},[O,e,l]);let jt=B(null);z(()=>{O&&T.reconcile(e.modules.list.map(e=>e.id),x())},[O,e.modules.list,T]);let Mt=V(e=>{e&&e.length!==0&&(g.value=e.map(e=>ll({...e,text:Pt(M.current,e.text)})))},[g]),Nt=B(0),Ft=B(0),It=V(e=>{if(e===p.value)return;let t=p.value;Ft.current++,y(!1),t&&(l.saveDraft(e,l.loadDraft(t)),l.saveDraft(t,``),l.saveMessageQueue(e,l.loadMessageQueue(t)),l.saveMessageQueue(t,[])),p.value=e,l.saveConversationId(e),I.primeIdentity(void 0,e),$.info(`conversation rebound`,{previous:t,current:e}),t&&n.emit(`conversationRebound`,{previous:t,current:e})},[n,p,l,I]),Lt=V(e=>{let t=e.map(e=>e.createdAt).filter(e=>e!==void 0),n=(t.length?Math.min(...t):Date.now())-1;return[...(ue.current?.messages??[]).map(e=>{let t=ll({...e,text:Pt(M.current,e.text)});return t.createdAt=n,t}),...e]},[]),Rt=V(async e=>{let t=Ft.current;function r(){return t!==Ft.current||p.value!==e}ce.current===e&&(ce.current=void 0),y(!0);try{let t=await I.loadConversation(e);if(r())return!1;let n=_l(t.messages),i=Lt(zl(n,g.value));if(g.value=i,ce.current=i.some(e=>e.role===`user`)?void 0:e,n.length>0||t.controlState!==void 0){Fe({conversationId:e,reference:t.ticketReference}),t.controlState&&ft(t.controlState);let r=n.findLast(e=>e.role===`assistant`&&!e.ephemeral);Le(r?.suggestions??[])}return!0}catch(t){return r()||($.warn(`loadThread failed; keeping conversation active`,{err:t,conversationId:e}),n.emit(`error`,t),Re.current.onError?.(t)),!1}finally{r()||y(!1)}},[I,g,p,Lt,n]),zt=V(e=>{if(se.current===e)return se.current=void 0,Rt(e)},[Rt]),Bt=V(()=>{if(b.current)return Promise.resolve(void 0);let t=p.value,r=g.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=Ft.current,s={};return b.current=s,(async()=>{try{let e=await I.loadConversation(t,{beforeId:i,beforeCreatedAt:a});if(b.current!==s||Ft.current!==o||p.value!==t)return;if(e.messages.length===0)return!1;let n=e.messages.map(fl),r=g.value,c=Ml(r,n);if(c!==r){let e=Math.min(...n.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)}g.value=c}return!0}catch(r){if(b.current!==s||Ft.current!==o||p.value!==t)return;$.warn(`load previous messages failed`,{err:r,conversationId:t,beforeId:i}),n.emit(`error`,r),e.onError?.(r);return}finally{b.current===s&&(b.current=void 0)}})()},[n,p,g,e,I]),Vt=V(async({newConversation:t})=>{let r=++Nt.current;function i(){return r!==Nt.current}if(!t){let e=await I.userSub(),t=l.loadLastUserSub();if(i())return;if(t&&t!==e){o?.();return}e&&l.saveLastUserSub(e)}let a=p.value,s=t||!a?wr():a;s!==a&&(Ft.current++,y(!1),Mi(()=>{p.value=s,h.value=s}),l.saveConversationId(s)),I.primeIdentity(u,s);let c;try{c=await I.handshake({visitorId:u,conversationId:s,userPrefs:l.loadUserPrefs(),locale:L})}catch(r){if(i())return;n.emit(`error`,r),e.onError?.(r);let a=r instanceof tu&&r.errorCode?G_[r.errorCode]:void 0;if(a){$.warn(`the widget is not shown: ${a}`),(re||e.mode===`page`)&&ne(!0);return}t||te(!0);return}if(i())return;e.continueLink&&c.visitorId!==u&&d(c.visitorId),c.conversationId!==s&&It(c.conversationId),de.current=c;let f=Dt(c,L);F(f.agent),Je(Va(c.config?.login));let g=c.config?.maxMessageCharacters;Xe(typeof g==`number`&&g>0?g:void 0),f.site&&za(f.site)?Be(f.site):f.site&&$.warn(`invalid site config, using fallback`,{site:f.site}),f.blocks&&Ba(f.blocks)?He(f.blocks):f.blocks&&$.warn(`invalid blocks config, using fallback`,{blocks:f.blocks});let _=Ar(c.userPrefs);if(Object.keys(_).length>0&&!t&&(l.saveUserPrefs(_),_.locale&&tt(_.locale),_.soundMuted!==void 0&&Ze.setMuted(_.soundMuted),_.themeMode&&nt(_.themeMode),_.textSize&&rt(_.textSize)),ue.current=f.welcome,t||n.emit(`handshake`,c),f.welcome?.suggestions){let e=M.current;Le(f.welcome.suggestions.map(t=>({...t,label:Pt(e,t.label),...t.text===void 0?{}:{text:Pt(e,t.text)}})))}let v=!t&&(c.conversationId===a||e.continueLink!==void 0);m.current=v,v?le.current||(se.current=c.conversationId):(ce.current=c.conversationId,Mt(f.welcome?.messages),Ct(c.conversationId)),t||te(!0)},[I,u,l,e,n,p,h,Ze,Mt,L,It,Ct,o]),Ht=JSON.stringify(e.userContext??null);z(()=>{I.setContext(e.userContext,W_(e.pageContext))},[I,Ht,JSON.stringify(e.pageContext??null)]);let Ut=B(!1);z(()=>{I.setUserToken(e.userToken),Ut.current?Vt({newConversation:!1}).then(()=>{j&&Et(!0)}):Ut.current=!0},[I,e.userToken,a]);let Wt=V((e,t=[])=>Le(e.suggestions??t),[]);z(()=>(I.primeIdentity(u,p.value),Vt({newConversation:!1}),()=>{Nt.current++,Ft.current++}),[]),z(()=>{j&&O&&!le.current&&(le.current=!0,se.current===p.value&&y(!0))},[j,O]);let Gt=B(Ht);z(()=>{O&&Gt.current!==Ht&&(Gt.current=Ht,Vt({newConversation:!1}))},[Ht,O,Vt]);let Kt=B(async()=>!1),{sendAiTurn:qt,sendRoutedTurn:Jt}=I_({onConversationNotFound:e=>Kt.current(e),transport:I,messagesSig:g,conversationIdSig:p,options:e,bus:n,feedback:Ze,persistence:l,visitorId:u,adoptConversationId:It,applyControlState:ft,setTicket:Fe,settleSuggestions:Wt,runCancellation:Qe}),{toolInteraction:Yt,pageToolsRunning:Xt,stopPageTools:Zt}=Yg({streaming:P,controlModeSig:lt,messagesSig:g,sendAiTurn:qt,bus:n,humanInLoop:e.features.humanInLoop,tools:e.tools}),Qt=V((e,t)=>{let r=g.value.find(t=>t.serverMessageId===e);r&&(r.feedback=t),$.info(`messageFeedback`,{messageId:e,value:t}),n.emit(`messageFeedback`,{messageId:e,value:t}),I.submitFeedback({messageId:e,value:t})},[n,g,I]),$t=V(()=>m.current||g.value.some(e=>!e.ephemeral&&e.role===`user`),[g]);D_({activated:j,conversationReady:O,paused:Ge.status===`pending`||Ge.status===`expired`,conversationIdSig:p,messagesSig:g,optionsRef:Re,transport:I,visitorId:u,adoptControlStateChunk:pt,adoptMemoryCompactionStateChunk:_t,settleSuggestions:Wt,recordConversationReply:Tt,transcriptRecoverySig:bt,beginConversationTranscript:St,commitConversationTranscript:Ct,runCancellation:Qe,feedback:Ze,bus:n,loadInitialThread:zt,shouldReconcileOnConnect:$t,reconnectingSig:_});let en=V(async(t,r,i)=>{if(Oe.current||Ot.gate)return!1;let a=p.value,o=a?gt.value.get(a):void 0,s=lt.value!==`ai-agent`;if(!s&&o?.status===`compacting`||($.info(`send`,{textLen:t.length,attachments:r.length,streaming:De.current,routedToOperator:s}),De.current&&!s))return!1;let c=new AbortController,l={conversationId:a,controller:c};Oe.current=l,Ae(!0);try{Ze.unlock(),je.value=/* @__PURE__ */ new Map;let o=await J_(I,r,c.signal,Me,t=>{c.signal.aborted||($.warn(`upload failed`,{err:t}),n.emit(`error`,t),e.onError?.(t))});if(c.signal.aborted||p.value!==a)return!1;let s=a?gt.value.get(a):void 0,l=lt.value!==`ai-agent`;if(!l&&s?.status===`compacting`||De.current&&!l||!i&&o.length<r.length||!t&&o.length===0)return!1;n.emit(`send`,{text:t,attachmentCount:r.length}),Ie.length>0&&Le([]),Ze.play(`messageSent`);let u=sl(t,o,i);return Wu(n,e,`user`,t),l?(g.value=[...g.value,u],i?await Jt(u):(Jt(u),!0)):(g.value=[...g.value,u,cl()],i?await qt({continueExisting:!1}):(qt({continueExisting:!1}),!0))}finally{Oe.current===l&&(Oe.current=null,Ae(!1))}},[I,n,e,Ie.length,g,p,gt,qt,Jt,lt,je,Me,Ot.gate]),tn=B(en);tn.current=en;let nn=p.value,rn=(nn?gt.value.get(nn):void 0)?.status===`compacting`,an=lt.value===`ai-agent`,on=da(()=>{let e=g.value.at(-1);return e?.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`&&(e.stateSig.value===`approval-requested`||e.stateSig.value===`approval-responded`))}),sn=da(()=>g.value.some(e=>e.retryAction?.kind===`resend-user`||e.retryAction?.kind===`continue-assistant`));yi(()=>{let e=p.value;return()=>{let t=Oe.current;t&&t.conversationId===e&&(Oe.current=null,Ae(!1),t.controller.abort())}},[p.value]);let cn=V(()=>{if(Oe.current){$.info(`stop uploads`),Oe.current.controller.abort();return}if(Xt){$.info(`stop page tools`),n.emit(`stop`,void 0),Zt();return}if(!Qe.stop())return;$.info(`stop`),n.emit(`stop`,void 0);let e=g.value.at(-1);e&&e.role!==`user`&&e.status===`streaming`&&(e.canceled=!0,g.value=[...g.value])},[Qe,n,g,Xt,Zt]),ln=V(e=>{$.info(`card action`,{text:e}),tn.current(e,[])},[]),un=V(e=>{if(P)return;let t=g.value,n=ql(t,e);if(n)switch($.info(`retry`,{kind:n.kind,messageId:n.messageId}),n.kind){case`continue-assistant`:if(lt.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,g.value=[...t],qt({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&&jt.current?.acceptQueuedMessage(n.messageId)};if(r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,lt.value!==`ai-agent`){g.value=e.role===`assistant`?t.filter(t=>t!==e):[...t],Jt(r).then(i);return}let a=cl();g.value=e.role===`assistant`?t.map(t=>t===e?a:t):[...t,a],qt({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=sl(bl(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]),lt.value!==`ai-agent`){g.value=[...t,r],Jt(r);return}g.value=[...t,r,cl()],qt({continueExisting:!1,turn:r});return}default:return n}},[P,g,lt,qt,Jt]),dn=V(()=>{Uu(e.mode,be)===`exit-fullscreen`?($.info(`close → exit-fullscreen`,{mode:e.mode}),xe(`normal`),n.emit(`fullscreen`,!1)):($.info(`close → panel closed`,{mode:e.mode}),ge.current=t.contains(t.ownerDocument.activeElement),ae(!1),l.savePanelOpen(!1),n.emit(`close`,void 0),e.onClose?.())},[n,e,l,be,t]);s_({hostElement:t,mode:e.mode,panelSize:be,isOpen:A,surfaceReady:O,onClose:dn}),z(()=>{!A&&ge.current&&(ge.current=!1,he.current?.focus())},[A]);let fn=V(()=>{$.info(`open`,{mode:e.mode}),Ze.unlock(),me(!0),ae(!0),l.savePanelOpen(!0),!N&&!ve&&ye(),setTimeout(()=>me(!1),K_),n.emit(`open`,void 0),e.onOpen?.()},[n,e,Ze,l,N,ve,ye]),pn=V(()=>{let e=g.value.some(e=>e.role===`user`);if(ce.current===p.value&&!e&&p.value)$.info(`clear → reusing empty conversation`,{conversationId:p.value}),g.value.length===0&&Mt(ue.current?.messages);else return $.info(`clear → new conversation`,{wasStreaming:P}),n.emit(`clear`,void 0),Qe.settle(),m.current=!1,se.current=void 0,ce.current=void 0,Mi(()=>{g.value=[],p.value=void 0,ft({controlMode:`ai-agent`,controlRevision:0})}),l.clearConversation(),Le([]),Vt({newConversation:!0})},[P,g,p,l,Vt,n,Mt,Qe,ft]);Kt.current=async e=>($.info(`conversation not found → new conversation`,{messageId:e.id}),await pn(),e.status=`complete`,e.errorText=void 0,e.retryAction=void 0,g.value=[...g.value,e,cl()],qt({continueExisting:!1,turn:e,movedFromConversation:!0}));let mn=V(()=>{let t=pn();we(`chat`);let n=e.modules.list.find(e=>e.layout===`chat`)?.id;return n&&T.switchTab(n),t},[pn,T,e]),hn=V(async e=>{await mn(),await tn.current(e,[])||jt.current?.fill(e)},[mn]),gn=V(()=>{let e=be===`expanded`?`normal`:`expanded`;$.info(`expand`,{from:be,expanded:e===`expanded`}),xe(e),l.savePanelSize(e),n.emit(`expand`,e===`expanded`)},[n,be,l]),_n=V(()=>{let e=be===`fullscreen`?`normal`:`fullscreen`;$.info(`fullscreen`,{from:be,fullscreen:e===`fullscreen`}),xe(e),l.savePanelSize(e),n.emit(`fullscreen`,e===`fullscreen`)},[n,be,l]),vn=V(()=>{we(e=>{let t=e===`history`?`chat`:`history`;return $.info(`toggleHistory`,{view:t}),n.emit(`toggleHistory`,{view:t}),t})},[n]),yn=V(()=>{We(e=>{let t=!e;return $.info(`sidebarToggle`,{collapsed:t}),l.saveSidebarCollapsed(t),n.emit(`sidebarToggle`,{collapsed:t}),t})},[l,n]),bn=V(e=>{$.info(`resize`,e),it({widgetSize:e}),n.emit(`resize`,e)},[it,n]),xn=V(async t=>{let r=t.conversationId;if(r===p.value&&wt(r)){$.info(`selectConversation`,{conversationId:r,cached:!0}),n.emit(`selectConversation`,{conversationId:r}),I.publishConversation(t),we(`chat`);let e=S();e&&T.switchTab(e),Ct(r);return}let i=++Nt.current;Ft.current++,y(!1);function a(){return i!==Nt.current}$.info(`selectConversation`,{conversationId:r,wasStreaming:P}),n.emit(`selectConversation`,{conversationId:r}),I.publishConversation(t);try{let e=await I.loadConversation(r);if(a())return;Qe.settle(),m.current=!0,se.current=void 0;let t=_l(e.messages),n=e.conversationId!==p.value,i=n?t:zl(t,g.value);ce.current=i.some(e=>e.role===`user`)?void 0:e.conversationId,Mi(()=>{g.value=Lt(i),n&&(h.value=e.conversationId),p.value=e.conversationId}),l.saveConversationId(e.conversationId),I.primeIdentity(u,e.conversationId),Fe({conversationId:e.conversationId,reference:e.ticketReference}),e.controlState&&ft(e.controlState);let o=i.findLast(e=>e.role===`assistant`&&!e.ephemeral);Le(o?.suggestions??[]),n?St(e.conversationId):Ct(e.conversationId),we(`chat`);let s=S();s&&T.switchTab(s)}catch(t){if(a())return;n.emit(`error`,t),e.onError?.(t)}},[I,g,p,h,n,e,l,Lt,P,u,Qe,St,Ct,wt,T]),Sn=B(void 0),Cn=V(t=>{let n=e.modules.list.find(e=>e.layout===H_[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;T.open(n.id,r)},[e.modules,T]),wn=V(e=>{A||fn(),e!=null&&(_a(e)?O?Cn(e):Sn.current=e:$.warn(`open: unknown target`,{detail:e}))},[A,fn,O,Cn]);z(()=>{O&&Sn.current&&(Cn(Sn.current),Sn.current=void 0)},[O,Cn]);let Tn=O&&!v&&(!an||!sn.value),[En,Dn]=R(),On=V(e=>{let t=ba(e);t?(A||fn(),Dn(t)):$.warn(`ask: expected { text, send? } with non-empty text`,{detail:e})},[A,fn]),kn=A&&O&&!v,An=kn&&Tn&&!ke&&!(an&&(P||rn));z(()=>{if(En===void 0||!(En.send?An:kn))return;let e=S();e?Ce!==`chat`||!C()?(we(`chat`),T.switchTab(e)):(Dn(void 0),En.send?en(En.text,[]).then(e=>{e||jt.current?.fill(En.text)}):jt.current?.fill(En.text)):($.warn(`ask: the widget has no chat`),Dn(void 0))},[En,kn,An,Ce,E,e.modules,T,en]),z(()=>{if(e.widgetId!=="default")return;let n=`data-${i.cssPrefix}-`,r=[`ask`,`open`,`close`].map(e=>n+e);function a(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`);a===null?o===null?Sa(t,`close`):Sa(t,`open`,va(o)):Sa(t,`ask`,ya(a||(i.textContent??``),{send:i.hasAttribute(`${n}send`)}))}return document.addEventListener(`click`,a),()=>document.removeEventListener(`click`,a)},[e.widgetId,t]),z(()=>{if(e.widgetId!=="default")return;let n=Ta(location.href);n&&(history.replaceState(history.state,``,n.url),n.ask?Sa(t,`ask`,ya(n.ask)):Sa(t,`open`,n.target))},[e.widgetId,t]);let jn=B(w),Mn=e.mode===`page`||e.mode===`inline`||e.mode===`standalone`;z(()=>ea(()=>{let e=p.value,t={open:Mn||A,ready:O,unread:yt.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,A,O,yt,p]);let Nn=B({handleOpenCommand:wn,handleClose:dn,handleExpand:gn,handleFullscreen:_n,handleAskCommand:On});Nn.current={handleOpenCommand:wn,handleClose:dn,handleExpand:gn,handleFullscreen:_n,handleAskCommand:On},yi(()=>Ca(t,{open:e=>Nn.current.handleOpenCommand(e),close:()=>Nn.current.handleClose(),expand:()=>Nn.current.handleExpand(),fullscreen:()=>Nn.current.handleFullscreen(),ask:e=>Nn.current.handleAskCommand(e)}),[t]);let Pn=bi(()=>Qn(e,L,$e,et),[e,L,$e,et]);M.current=Pn.strings,z(()=>{let e=de.current;if(!e?.translations?.length)return;let t=Dt(e,L);F(t.agent),t.site&&za(t.site)&&Be(t.site),t.blocks&&Ba(t.blocks)&&He(t.blocks)},[L]);function Fn(e){xn(e)}let In={options:Pn,transport:I,feedback:Ze,bus:n,persistence:l,conversationId:p.value??``,composerKey:h.value,composerApiRef:jt,view:Ce,isStreaming:P,pageToolRunning:Xt,isMemoryCompacting:rn,canReleaseQueuedMessages:Tn,queueManualMessages:an&&sn.value,replyAwaitsCard:an&&on.value,sendPreparing:ke,attachmentUploadsSig:je,composerActive:Pn.mode===`page`||Pn.mode===`inline`||Pn.mode===`standalone`||A,controlMode:lt.value,assignedOperator:ut.value,operatorAvailable:dt.value,operatorRequestEnabled:e.features.operatorRequest,onRequestOperator:mt,onCancelOperatorRequest:ht,loadingMessages:v,onLoadPreviousMessages:Bt,messagesSig:g,reconnectingSig:_,agent:Ne,ticketReference:Pe?.conversationId===p.value?Pe?.reference:void 0,login:Ot,onStartAsGuest:s,maxMessageCharacters:Ye,suggestions:Ie,initialWidgetSize:f.widgetSize??null,onClear:pn,onExpand:gn,onFullscreen:_n,onSoundToggle:ct,onToggleHistory:vn,onSelectHistoryConversation:Fn,onNewConversation:mn,onLocaleChange:at,onThemeChange:ot,onTextSizeChange:st,onWidgetSizeChange:bn,onSend:en,onStop:cn,onSuggestion:t=>{if(Oe.current)return;let r=t.text??t.label;$.info(`suggestion`,{text:r,autoSend:e.autoSendSuggestions}),n.emit(`suggestion`,{text:r}),e.autoSendSuggestions?en(r,[]):jt.current?.fill(r)},tool:Yt,onRetry:un,onMessageFeedback:Qt,onCardAction:ln};if(k)return/* @__PURE__ */ U(`div`,{class:`${V_}-anchor`,children:/* @__PURE__ */ U(Wg,{strings:Pn.strings,text:Pn.strings.chatUnavailable})});if(!O)return null;let Ln=Pn.modules.list;function Rn(e){let t=Vu(`close`,Pn.mode,e)?dn:void 0;return Ln.length===0?/* @__PURE__ */ U(Wg,{strings:Pn.strings,text:Pn.strings.modulesEmpty,onClose:t}):Ln.length===1&&Ln[0]?.layout===`chat`?/* @__PURE__ */ U(Cg,{...In,panelSize:e,onClose:t}):/* @__PURE__ */ U(Fg,{panelProps:{...In,panelSize:e,onClose:t},enabledModules:Ln,nav:T,bus:n,hasUnread:vt.value,latestNews:At,onSelectConversation:Fn,onStartNewConversation:hn,onSetPanelSize:xe})}if(e.mode===`page`){let t=e.history.enabled&&Ln.some(e=>e.layout===`chat`);return/* @__PURE__ */ U(`div`,{class:`${V_}-anchor`,children:/* @__PURE__ */ U(Hg,{site:ze,blocks:Ve,transport:I,strings:Pn.strings,locale:Pn.locale,persistence:l,showConversations:t,onSelectConversation:Fn,onNewConversation:mn,sidebarCollapsed:Ue,onToggleSidebarCollapsed:yn,children:Rn(`fullscreen`)})})}if(re){let t=e.mode===`standalone`?`fullscreen`:be;return/* @__PURE__ */ U(`div`,{class:`${V_}-anchor`,children:Rn(t)})}let zn=e.mode===`drawer`,Bn=e.mode!==`modal`&&!e.launcher.hidden&&(!A||pe),Vn=Bn&&!pe&&!N&&!zn?Pn.launcher.callout:null;return/* @__PURE__ */ U(`div`,{class:`${V_}-anchor`,"data-launcher-size":Pn.launcher.size,children:[A||j?/* @__PURE__ */ U(`div`,{class:`${V_}-surface`,hidden:!A,children:Rn(be)}):null,Bn?/* @__PURE__ */ U(uf,{buttonRef:he,onToggle:fn,launcher:Pn.launcher,strings:Pn.strings,leaving:pe,edgeTab:zn}):null,Vn?/* @__PURE__ */ U(hf,{callout:Vn,launcherPosition:Pn.position,strings:Pn.strings,closeLabel:Pn.strings.close,onDismiss:ye}):null]})}function W_(e){let t=e?.url??(typeof location<`u`?location.href:void 0);if(e||t)return{...e,...t?{url:t}:{}}}const G_={AI_AGENT_PUBLIC_ACCESS_NOT_FOUND:`the deployment was not found or is turned off`,AI_AGENT_PUBLIC_ORIGIN_NOT_ALLOWED:`this website is not in the deployment's allowed origins`},K_=120,q_=/* @__PURE__ */ new WeakMap;async function J_(e,t,n,r,i){return(await Promise.all(t.map(async t=>{try{r(t.id,{status:`uploading`});let i=q_.get(t)??await e.uploadFile(t.file,n,e=>r(t.id,{status:`uploading`,fraction:e}));return q_.set(t,i),r(t.id,{status:`done`}),{id:i.id,name:i.originalName,mediaType:i.mimeType,size:i.fileSize,url:i.url}}catch(e){r(t.id,n.aborted?void 0:{status:`error`,refusal:e instanceof tu&&e.status===400?e.errorCode:void 0}),i(e);return}}))).filter(e=>e!==void 0)}const Y_=_.scope(`error-boundary`);var X_=class extends $e{constructor(...e){super(...e),S(this,`state`,{crashed:!(`toSorted`in Array.prototype)})}componentDidCatch(e,t){Y_.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 Z_(e){let{bus:t,host:n,appRoot:r,persistence:i,reportError:a}=e,o=e.initialRaw,s,c,l=zn(o),u=i.loadUserPrefs().locale??l.locale,d=!0,f=0,p=0,m=Cr(t);function h(){let e=s&&Dt({config:s,translations:c},u).config;l=zn(e?tr(o,e):o)}function g(){Gr(n,Kr(l.mode)),ti(n,{...l,themeMode:Zn(l.themeMode,i.loadUserPrefs().themeMode)}),d&&(ei(n,Q_(l)),d=!1)}function _(){g(),xt(Ze(X_,{onError:a},Ze(U_,{key:f,bus:t,hostElement:n,options:l,recentHostEvents:m,loginRevision:p,onPersonChanged:b,onStartAsGuest:x})),r)}t.on(`handshake`,e=>{e.config&&(e.config.storageVersion&&i.rememberStorageVersion(e.config.storageVersion),s=e.config,c=e.translations,h(),_())}),t.on(`localeChange`,e=>{u=e,c?.length&&(h(),_())});let v=Ir(t,{getOptions:()=>l,getVisitorId:()=>i.getVisitorId(),getConversationId:()=>i.loadConversationId()});function y(){let e=i.takeLoginReturn();return e?(i.saveConversationId(e.conversationId),i.saveDraft(e.conversationId,e.draft),i.savePanelOpen(!0),!0):!1}o.userToken&&y();function b(){i.reset(),m.length=0,f+=1,d=!0,h(),_()}function x(){o={...o,userContext:void 0,userToken:void 0},b()}function S(e){`userToken`in e&&e.userToken&&!o.userToken&&y()&&(f+=1),o={...o,...e},h(),_()}return{getOptions:()=>l,getUserOptions:()=>o,render:_,setUserOptions:e=>{o=e,h(),_()},patchUserOptions:S,login:e=>{p+=1,S({userToken:e})},reset:()=>x(),destroy:()=>v()}}function Q_(e){if(e.mode===`standalone`)return`standalone`;if(e.mode===`inline`)return`inline`;let t=Dr(e.widgetId,e.storage,e.aiAgentDeploymentId),{panelOpen:n,panelSize:r}=ed(e,td(),t.loadPanelOpen(),t.loadPanelSize());return Qu(e.mode,r,n)}const $_=_.scope(`hooks`),ev=`*`,tv=/* @__PURE__ */ new Set;function nv(e,t,n){let r={widgetId:e,event:t,listener:n};return tv.add(r),()=>{tv.delete(r)}}function rv(e,t,n){let r=[...tv];for(let i of r)if(av(i.widgetId,e.widgetId)&&(i.event===`*`||i.event===t))try{i.listener(e,t,n)}catch(e){$_.warn(`hook listener threw`,{event:t,error:e})}}function iv(e,t){return t.tap({hear:(t,n)=>rv(e,t,n),listensTo:t=>[...tv].some(n=>n.event===t&&av(n.widgetId,e.widgetId))})}function av(e,t){return e===`*`||e===t}const ov=/* @__PURE__ */ new Map;function sv(e){if(!e.aiAgentDeploymentId)throw Error(`aiAgentDeploymentId is required`);e.debug!==void 0&&m(e.debug);let t=_.scope(`mount`);t.info(`mount`,{widgetId:e.widgetId,publicKey:e.publicKey,mode:e.presentation?.mode});let n=zn(e),r=n.widgetId,i=ov.get(r);i&&(t.debug(`destroy existing instance at slot`,{widgetId:r}),i.destroy());let a=qr({position:Kr(n.mode),target:e.target??null});a.hostElement.dataset.widgetId=r;let o=new ee,s=Dr(r,n.storage,n.aiAgentDeploymentId);function c(e){o.emit(`error`,e),l.getOptions().onError?.(e)}let l=Z_({bus:o,host:a.hostElement,appRoot:a.appRoot,persistence:s,initialRaw:e,reportError:c}),u=w,d=()=>{},f=new Promise(e=>{d=e});o.on(`state`,e=>{u=e,e.ready&&d()}),l.render();let p=a.hostElement,g=null;function y(e){e.debug!==void 0&&m(e.debug),l.patchUserOptions(e)}let b={widgetId:r,open:e=>Sa(p,`open`,e),close:()=>Sa(p,`close`),expand:()=>Sa(p,`expand`),ask:(e,t)=>Sa(p,`ask`,ya(e,t)),on:(e,t)=>o.on(e,t),update:e=>{t.debug(`update`,{patch:e}),y(e)},setUserContext:e=>{t.debug(`setUserContext`,{keys:Object.keys(e)}),y({userContext:{...l.getUserOptions().userContext,...e}})},clearUserContext:()=>{t.debug(`clearUserContext`),y({userContext:void 0})},setPageContext:e=>{t.debug(`setPageContext`,{keys:Object.keys(e)}),y({pageContext:{...l.getUserOptions().pageContext,...e}})},clearPageContext:()=>{t.debug(`clearPageContext`),y({pageContext:void 0})},get state(){return u},ready:f,reset:()=>{t.info(`reset`,{widgetId:r}),l.reset()},login:e=>{t.info(`login`,{widgetId:r}),l.login(e)},track:(e,t)=>{let n=Sr(e,t);n&&o.emit(`hostEvent`,n)},registerTool:ye,setDebug:e=>{m(e),t.info(`debug level set`,{level:h()})},debugLevel:()=>h(),onLog:e=>v(e),destroy:()=>{t.info(`destroy`,{widgetId:r}),o.emit(`state`,w),g?.(),l.destroy(),o.clear(),xt(null,a.appRoot),a.destroy(),ov.get(r)===b&&ov.delete(r)}};return g=iv(b,o),ov.set(r,b),b}function cv(e){if(!e.aiAgentDeploymentId)throw Error(`aiAgentDeploymentId is required`);let t=e.widgetId??`default`,n=ov.get(t);return n?(n.update(e),n):sv(e)}function lv(e){if(e!==void 0){ov.get(e)?.destroy();return}let t=[...ov.values()];for(let e of t)e.destroy()}function uv(e=`default`){return ov.get(e)??null}function dv(){return[...ov.values()]}const fv=jr,pv=i,mv=/* @__PURE__ */ new WeakMap;let hv=0;function gv(e){if(typeof e!=`function`)return e;let t=mv.get(e)??++hv;return mv.set(e,t),`function#${t}`}function _v(t){let r=n(t);r.current=t;let i=t.widgetId??`default`,a=JSON.stringify({...t,userToken:gv(t.userToken)});return e(()=>()=>lv(i),[i]),e(()=>{cv({...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 vv(e=`default`){return{state:r(t=>nv(e,`state`,t),()=>uv(e)?.state??w,()=>w),...t(()=>({ask:(t,n)=>uv(e)?.ask(t,n),open:t=>uv(e)?.open(t),close:()=>uv(e)?.close(),reset:()=>uv(e)?.reset(),track:(t,n)=>uv(e)?.track(t,n)}),[e])}}function yv(t){let r=n(t);r.current=t;let i=JSON.stringify(t);e(()=>{let e=new AbortController,t=r.current.preview?{preview:e=>r.current.preview?.(e)}:{};return ye({...r.current,...t,execute:(e,t)=>r.current.execute(e,t)},{signal:e.signal}),()=>e.abort()},[i])}export{ev as HOOK_WILDCARD,_v as HelpAI,pv as brand,lv as destroy,dv as getAllInstances,uv as getInstance,nv as hook,cv as init,sv as mount,Q_ as resolveInitialHostMode,vv as useHelpAI,yv as useHelpAITool,fv as version};
72
+ `).trim(),A=!E&&t!==`error`&&!y.value&&ie.length>0,ae=e.canceled===!0||t===`error`;function j(n){return l&&t===`complete`&&Ml(e,n)}let oe=/* @__PURE__ */ new Map;for(let[t,n]of v.entries()){if(n.kind!==`tool`)continue;let i=P(n.toolMetadata),a=mn(th(n),{turn:{live:T||i&&!u,cutOff:ae,superseded:u,submitted:e.continuationStreaming===!0&&n.approvalSig.value?.approved===void 0,canAct:j(t),interrupted:i&&je(n.errorSig.value)},reader:{decides:!0},display:s,strings:r});oe.set(n.toolCallId,a.placement===`card`&&!d?.humanInLoop?{...a,placement:`hidden`}:a)}function se(e){let t=oe.get(e.toolCallId);if(!t)throw Error(`no step view for ${e.toolCallId}`);return t}let ce=zh(v,{showReasoning:o,showSources:c,viewOf:se}),le=Hh(v),ue=e.canceled===!0&&!w&&C.value&&x.value,M=ce.at(-1),de=M?.kind===`steps`?M.indices.at(-1):M?.index;function fe(t,n){return/* @__PURE__ */ U(og,{part:t,generativeUi:e.role===`assistant`,onCardAction:_,current:T&&n===de,reasoningMs:e.stepTimings?.[le[n]??-1]?.reasoningMs,strings:r,locale:i,showReasoning:o,showSources:c,view:t.kind===`tool`?oe.get(t.toolCallId):void 0,canAct:j(n),superseded:u,continuationStreaming:e.continuationStreaming===!0,tool:d},`${lg(t)}#${n}`)}let pe=re||A;return/* @__PURE__ */ U(`div`,{class:`${tg}-bubble-row`,"data-role":e.role,"aria-busy":T?`true`:void 0,"data-testid":uf(Y.messageBubble,e.serverMessageId??e.id),children:/* @__PURE__ */ U(`div`,{class:`${tg}-bubble-col`,children:[/* @__PURE__ */ U(`div`,{class:`${tg}-bubble`,children:[e.role===`operator`&&e.operatorInitials?/* @__PURE__ */ U(`span`,{class:`${tg}-bubble-author`,children:e.operatorInitials}):null,/* @__PURE__ */ U(`div`,{class:`${tg}-bubble-body`,children:[O?/* @__PURE__ */ U(dg,{label:r.loading}):ce.flatMap((t,n)=>t.kind===`part`?[fe(t.part,t.index)]:t.rows.some(e=>e.kind===`tool`)?[/* @__PURE__ */ U(qh,{rows:t.rows,steps:t.indices.map(e=>le[e]??-1),stepTimings:e.stepTimings,timed:!ae,strings:r,running:T&&n===ce.length-1,runStartedAt:e.runStartedAt,renderCard:(e,t)=>t.card===`questions`&&d?/* @__PURE__ */ U(Ah,{part:e,strings:r,active:!1,superseded:t.status===`replaced`,folded:!0,onDecision:d.onDecision,onEdit:d.onEdit}):void 0},`steps#${t.indices[0]}`)]:t.rows.map((e,n)=>fe(e.part,t.indices[n]??n))),ue?/* @__PURE__ */ U(`div`,{class:`${tg}-steps-row`,"data-status":`stopped`,"data-testid":Y.replyStopped,children:[/* @__PURE__ */ U(`span`,{class:`${tg}-steps-row-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(fd,{})}),/* @__PURE__ */ U(`div`,{class:`${tg}-steps-row-main`,children:/* @__PURE__ */ U(`span`,{class:`${tg}-steps-stopped-label`,children:r.statusStopped})})]}):null,te&&!h?/* @__PURE__ */ U(ug,{}):null,t===`error`||y.value?/* @__PURE__ */ U(jp,{text:cg(e,t,r),retryLabel:r.errorRetry,onRetry:f?()=>f(e):void 0,retryTestId:Y.messageRetry}):null,h&&T?/* @__PURE__ */ U(jp,{text:r.errorReconnecting,retryTestId:Y.messageRetry}):null]})]}),k||pe?/* @__PURE__ */ U(`div`,{class:`${tg}-bubble-meta`,children:[k?/* @__PURE__ */ U(`time`,{class:`${tg}-bubble-time`,dateTime:k.iso,title:k.full,children:k.short}):null,pe?/* @__PURE__ */ U(`div`,{class:`${tg}-bubble-actions`,children:[re&&e.serverMessageId?/* @__PURE__ */ U(qm,{messageId:e.serverMessageId,initial:e.feedback??null,strings:r,onFeedback:m}):null,A?/* @__PURE__ */ U(ig,{text:ie,strings:r}):null]}):null]}):null]})})}function ig({text:e,strings:t}){let[n,r]=R(!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:`${tg}-msg-action`,"data-active":n?`true`:void 0,"aria-label":a,title:a,onClick:i,"data-testid":Y.messageCopy,children:U(n?Ed:$d,{})})}function ag(e,t){if(typeof e!=`number`||!Number.isFinite(e))return null;try{let n=new Date(e);return{short:n.toLocaleTimeString(t,{hour:`numeric`,minute:`2-digit`}),full:n.toLocaleString(t,{dateStyle:`full`,timeStyle:`short`}),iso:n.toISOString()}}catch{return null}}function og({part:e,generativeUi:t,onCardAction:n,current:r,reasoningMs:i,strings:a,locale:o,showReasoning:s,showSources:c,view:l,canAct:u,superseded:d,continuationStreaming:f,tool:p}){switch(e.kind){case`step-start`:return null;case`text`:return/* @__PURE__ */ U(wf,{textSig:e.textSig,doneSig:e.doneSig,generativeUi:t,strings:a,onCardAction:n});case`reasoning`:return s?/* @__PURE__ */ U(eg,{part:e,current:r,reasoningMs:i,strings:a,standalone:!0}):null;case`tool`:return l?.placement!==`card`||!p?null:l.card===`questions`?/* @__PURE__ */ U(Ah,{part:e,strings:a,active:u,superseded:d,continuationStreaming:f,onDecision:p.onDecision,onEdit:p.onEdit}):/* @__PURE__ */ U(uh,{part:e,view:l,strings:a,locale:o,canAct:u,onDecision:p.onDecision,onEdit:p.onEdit,preview:p.preview});case`file`:return/* @__PURE__ */ U(sg,{part:e,strings:a});case`source`:return c?/* @__PURE__ */ U($m,{part:e,strings:a}):null}}function sg({part:e,strings:t}){let n=e.filename??t.file;if(e.mediaType.startsWith(`image/`))return/* @__PURE__ */ U(`a`,{class:`${tg}-file-image`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,title:n,"data-testid":Y.messageFile,children:/* @__PURE__ */ U(`img`,{src:e.url,alt:n,loading:`lazy`})});let r=(n.includes(`.`)?n.split(`.`).pop():e.mediaType.split(`/`).pop())?.toUpperCase(),i=e.fileSize===void 0?void 0:pp(e.fileSize);return/* @__PURE__ */ U(`a`,{class:`${tg}-file-chip`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,title:n,"data-testid":Y.messageFile,children:[/* @__PURE__ */ U(`span`,{class:`${tg}-file-chip-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(Nd,{})}),/* @__PURE__ */ U(`span`,{class:`${tg}-file-chip-text`,children:[/* @__PURE__ */ U(`span`,{class:`${tg}-file-chip-name`,children:n}),/* @__PURE__ */ U(`span`,{class:`${tg}-file-chip-meta`,children:[r,i].filter(Boolean).join(` · `)})]})]})}function cg(e,t,n){return e.errorText?e.errorText:t===`error`&&e.role===`assistant`?n.errorServer:n.errorGeneric}function lg(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 ug(){return/* @__PURE__ */ U(`span`,{class:`${tg}-typing`,"data-testid":Y.typingDots,"aria-hidden":`true`,children:[/* @__PURE__ */ U(`span`,{}),/* @__PURE__ */ U(`span`,{}),/* @__PURE__ */ U(`span`,{})]})}function dg({label:e}){return/* @__PURE__ */ U(`span`,{class:`${tg}-loading`,role:`status`,children:[/* @__PURE__ */ U(`span`,{class:`${tg}-loading-spinner`,"aria-hidden":`true`}),/* @__PURE__ */ U(`span`,{class:`${tg}-loading-label`,children:e})]})}const fg=i.cssPrefix;function pg({messagesSig:e,reconnectingSig:t,pageToolRunning:n,strings:r,notice:i,locale:a,responseMode:o,showReasoning:s,stepDisplay:c,showSources:l,enableMessageFeedback:u,onFeedback:d,loading:f,onLoadPreviousMessages:p,idle:m,controlMode:h=`ai-agent`,tool:g,onRetry:_,onCardAction:v}){let y=B(null),b=da(()=>e.value),x=mg(a),[S,C]=R(!1),[w,ee]=R(!1),T=B(!1),E=B(!1),[D,O]=R(),te=B(!1),k=B(!1),ne=B(!1),re=B(0);function ie(){return ne.current||performance.now()-re.current<350}let A=B(0);function ae(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 C(e.scrollHeight-e.scrollTop-e.clientHeight>240)}function oe(e){A.current=performance.now(),e.scrollTop=e.scrollHeight,ae(e)}function se(e,t){oe(e);let n=t,r=0;function i(){k.current||ie()||(oe(e),--n>0&&(r=requestAnimationFrame(i)))}return t>0&&(r=requestAnimationFrame(i)),()=>cancelAnimationFrame(r)}function ce(e,t){let n,r,i,a=-1;function o(){n.disconnect(),r.disconnect(),clearTimeout(i)}function s(){if(k.current||ie()||a>=0&&e.scrollTop<a-4)return o();oe(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 le=b.value[0]?.id;yi(()=>{let e=y.current;if(e&&b.value.length!==0&&!E.current&&(te.current=!0,b.value.some(e=>e.role===`user`)))return ce(e,300)},[le]);let ue=B(0);z(()=>{let e=y.current,t=b.value,n=ue.current;if(ue.current=t.length,e&&te.current&&!E.current){if(t.slice(n).some(e=>e.role===`user`))return k.current=!1,se(e,3);t.some(e=>e.role===`user`)&&(k.current||ie()||e.scrollHeight-e.scrollTop-e.clientHeight<120&&oe(e))}},[b.value.length]);let M=B(null);z(()=>{let e=y.current,t=b.value.at(-1),n=M.current;if(M.current=t?{id:t.id,streaming:t.status===`streaming`}:null,e&&te.current&&t&&t.id===n?.id&&!n.streaming&&t.status===`streaming`)return k.current=!1,se(e,3)},[b.value]),z(()=>{let e=y.current;if(!e)return;let t=b.value.at(-1);if(!t||t.status!==`streaming`&&!b.value.some(e=>e.role===`user`))return;let n=()=>{k.current||ie()||e.scrollHeight-e.scrollTop-e.clientHeight<240&&oe(e)};if(t.status!==`streaming`)return ce(e,300);n();let r=new MutationObserver(n);return r.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>r.disconnect()},[b.value]),z(()=>{let e=y.current;if(!e)return;let t=()=>{j(e),ae(e),performance.now()-A.current>150&&(k.current=e.scrollHeight-e.scrollTop-e.clientHeight>8)};function n(){k.current=!0}function r(e){e.deltaY<0&&n()}let i=0;function a(e){i=e.touches[0]?.clientY??0,ne.current=!0}function o(e){(e.touches[0]?.clientY??0)>i+4&&n()}function s(){ne.current=!1,re.current=performance.now()}function c(){ne.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)}},[]),z(()=>{let e=y.current;if(!e)return;let t=e.clientHeight,n=new ResizeObserver(()=>{if(e.clientHeight===t)return;let n=e.scrollHeight-e.scrollTop-t<=120;t=e.clientHeight,n&&!E.current&&b.value.some(e=>e.role===`user`)&&(k.current=!1,oe(e))});return n.observe(e),()=>n.disconnect()},[]);function de(){let e=y.current;e&&(k.current=!1,oe(e))}let fe=b.value.filter(e=>!e.ephemeral),pe=fe[0],me=pe?.serverMessageId??pe?.id,he=!!(p&&fe.length>=50&&me!==D);async function ge(){if(!p||T.current)return;let e=y.current,t=e?.scrollHeight??0,n=e?.scrollTop??0;T.current=!0,E.current=!0,ee(!0);try{let r=await p();r===!1&&me&&O(me),r&&e&&(await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e()))),e.scrollTop=n+e.scrollHeight-t,ae(e),j(e))}finally{E.current=!1,T.current=!1,ee(!1)}}let N=[],_e=``,ve=b.value.at(-1)?.id,ye=t?.value===!0,be=n===!0;for(let e of b.value){if(e.role===`assistant`&&e.id!==ve&&Jl(e))continue;let t=hg(e.createdAt);t&&t!==_e&&(N.push(/* @__PURE__ */ U(`div`,{class:`${fg}-date-divider`,children:/* @__PURE__ */ U(`span`,{class:`${fg}-date-pill`,title:gg(e.createdAt,x),children:_g(e.createdAt,r,x)})},`day:${t}`)),_e=t);let n=e.retryAction!==void 0||e.role===`assistant`&&e.id===ve?Yl(b.value,e):void 0,i=n!==void 0&&(n.kind!==`continue-assistant`||h===`ai-agent`);N.push(/* @__PURE__ */ U(ng,{message:e,status:e.status,createdAt:e.createdAt,strings:r,locale:x,responseMode:o,showReasoning:s,stepDisplay:c,showSources:l,interactive:!!m&&h===`ai-agent`&&e.id===ve,superseded:e.id!==ve,tool:g,onRetry:m&&i&&(e.role===`user`||e.id===ve)?_:void 0,enableMessageFeedback:u,onFeedback:d,reconnecting:ye&&e.id===ve,clientToolRunning:be&&e.id===ve&&e.role===`assistant`,onCardAction:v},e.id))}return/* @__PURE__ */ U(`div`,{class:`${fg}-list-wrap`,children:[/* @__PURE__ */ U(`div`,{ref:y,class:`${fg}-list ${fg}-list--fade`,part:`messages`,role:`log`,"aria-live":`polite`,"aria-relevant":`additions text`,children:[f&&b.value.length===0?/* @__PURE__ */ U(`div`,{class:`${fg}-list-loading`,role:`status`,children:r.conversationLoading}):null,i&&!he?/* @__PURE__ */ U(`div`,{class:`${fg}-chat-notice`,role:`note`,"data-testid":Y.chatNotice,children:/* @__PURE__ */ U(Tf,{text:i})}):null,he?/* @__PURE__ */ U(`div`,{class:`${fg}-load-previous`,children:/* @__PURE__ */ U(`button`,{type:`button`,onClick:ge,disabled:w,"aria-busy":w,"data-testid":Y.loadPreviousMessages,children:r.loadPreviousMessages})}):null,N]}),S?/* @__PURE__ */ U(`button`,{type:`button`,class:`${fg}-jump`,onClick:de,"aria-label":r.scrollToBottom,title:r.scrollToBottom,"data-testid":Y.scrollToBottom,children:/* @__PURE__ */ U(Md,{})}):null]})}function mg(e){try{return Intl.getCanonicalLocales(e)[0]}catch{return}}function hg(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function gg(e,t){if(typeof e!=`number`||!Number.isFinite(e))return``;try{return new Date(e).toLocaleDateString(t,{dateStyle:`full`})}catch{return``}}function _g(e,t,n){let r=new Date(e);function i(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}let a=Math.round((i(/* @__PURE__ */ new Date)-i(r))/864e5);return a<=0?t.dateToday:a===1?t.dateYesterday:a<7?r.toLocaleDateString(n,{weekday:`long`}):r.toLocaleDateString(n,{month:`long`,day:`numeric`,year:`numeric`})}function vg({panelEl:e,resize:t,position:n,edge:r,initialSize:a,onSizeChange:o,onResizeStart:s,strings:c}){let l=i.cssPrefix,u=B(null),[d,f]=R(null),p=a?.width,m=a?.height;if(z(()=>{if(!e)return;let n=e.style;n.setProperty(`--${l}-resize-min-w`,t.minWidth??`320px`),n.setProperty(`--${l}-resize-min-h`,t.minHeight??`400px`),t.maxWidth&&n.setProperty(`--${l}-resize-max-w`,t.maxWidth),t.maxHeight&&n.setProperty(`--${l}-resize-max-h`,t.maxHeight),p!==void 0&&m!==void 0&&(n.setProperty(`--${l}-widget-w`,`${p}px`),n.setProperty(`--${l}-widget-h`,`${m}px`)),f(Math.round(e.getBoundingClientRect().width/window.innerWidth*100))},[e,t.minWidth,t.maxWidth,t.minHeight,t.maxHeight,l,p,m]),!e)return null;let h=n.startsWith(`top-`),g=n.endsWith(`-right`),_=g?-1:1,v=h?1:-1,y=`${l}-resize-grip--${r?`edge`:`${h?`bottom`:`top`}-${g?`left`:`right`}`}`;function b(e){e.setAttribute(`data-resizing`,``),s?.()}function x(e,t,n){e.style.setProperty(`--${l}-widget-w`,`${t}px`),r||e.style.setProperty(`--${l}-widget-h`,`${n}px`)}function S(e){let t=e.getBoundingClientRect(),n={width:Math.round(t.width),height:Math.round(t.height)};e.style.setProperty(`--${l}-widget-w`,`${n.width}px`),r||e.style.setProperty(`--${l}-widget-h`,`${n.height}px`),f(Math.round(n.width/window.innerWidth*100)),o(n)}function C(t){if(!e)return;let n=e.getBoundingClientRect();u.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startW:n.width,startH:n.height,moved:!1},t.currentTarget.setPointerCapture(t.pointerId),t.preventDefault()}function w(t){let n=u.current;if(!n||t.pointerId!==n.pointerId||!e)return;let i=(t.clientX-n.startX)*_,a=r?0:(t.clientY-n.startY)*v;(n.moved||i!==0||a!==0)&&(n.moved||b(e),n.moved=!0,x(e,n.startW+i,n.startH+a))}function ee(t){let n=u.current;n&&t.pointerId===n.pointerId&&e&&(t.currentTarget.releasePointerCapture(t.pointerId),u.current=null,n.moved&&(e.removeAttribute(`data-resizing`),S(e)))}function T(e){return e===`ArrowLeft`?[-1,0]:e===`ArrowRight`?[1,0]:r?null:e===`ArrowUp`?[0,-1]:e===`ArrowDown`?[0,1]:null}function E(t){let n=T(t.key);if(!n||!e)return;t.preventDefault();let r=t.shiftKey?64:16;t.repeat||b(e);let i=e.getBoundingClientRect();x(e,i.width+n[0]*r*_,i.height+n[1]*r*v)}function D(t){T(t.key)&&e&&(e.removeAttribute(`data-resizing`),S(e))}return/* @__PURE__ */ U(`div`,{class:`${l}-resize-grip ${y}`,role:`separator`,"aria-orientation":`vertical`,"aria-label":c.resizeHandle,"aria-valuenow":d??void 0,tabIndex:0,title:c.resizeHandle,onPointerDown:C,onPointerMove:w,onPointerUp:ee,onPointerCancel:ee,onKeyDown:E,onKeyUp:D,"data-testid":Y.resizeGrip,children:r?null:/* @__PURE__ */ U(xd,{})})}const yg=i.cssPrefix;function bg({suggestions:e,strings:t,onPick:n,disabled:r=!1}){let i=B(null),[a,o]=R({start:!1,end:!1});return z(()=>{let e=i.current;if(!e)return;function t(){if(!e)return;let t=Math.abs(e.scrollLeft),n=t>1,r=t<e.scrollWidth-e.clientWidth-1;o(e=>e.start===n&&e.end===r?e:{start:n,end:r})}t(),e.addEventListener(`scroll`,t,{passive:!0});let n=typeof ResizeObserver>`u`?void 0:new ResizeObserver(t);return n?.observe(e),()=>{e.removeEventListener(`scroll`,t),n?.disconnect()}},[e]),e.length===0?null:/* @__PURE__ */ U(`div`,{ref:i,class:`${yg}-suggestions`,role:`group`,"aria-label":t.suggestedReplies,"data-cut-start":a.start?`true`:void 0,"data-cut-end":a.end?`true`:void 0,children:e.map((e,t)=>/* @__PURE__ */ U(`button`,{type:`button`,class:`${yg}-suggestion`,onClick:()=>n(e),disabled:r,"data-testid":uf(Y.suggestion,t),children:e.label},e.id))})}const xg=i.cssPrefix,Sg=`.${xg}-header, .${xg}-back-header, .${xg}-home-hero`;function Cg(e,t){z(()=>{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(Sg)||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(`--${xg}-modal-dx`)),dy:n(e.style.getPropertyValue(`--${xg}-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(`--${xg}-modal-dx`,`${n}px`),e.style.setProperty(`--${xg}-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 wg({containerRef:e,onDrop:t,accept:n,disabled:r=!1}){let[i,a]=R();return z(()=>{if(r){a(void 0);return}let i=e.current;if(!i)return;let o=0;function s(e){o+=1,e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),a([...e.dataTransfer.items].every(e=>e.kind!==`file`||mp(e.type,n))?`accept`:`reject`))}function c(){--o,o>0||(o=0,a(void 0))}function l(e){e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()}function u(e){o=0,a(void 0),e.dataTransfer&&(e.preventDefault(),t(e.dataTransfer.items))}return i.addEventListener(`dragenter`,s),i.addEventListener(`dragleave`,c),i.addEventListener(`dragover`,l),i.addEventListener(`drop`,u),()=>{i.removeEventListener(`dragenter`,s),i.removeEventListener(`dragleave`,c),i.removeEventListener(`dragover`,l),i.removeEventListener(`drop`,u)}},[n,e,r,t]),r?void 0:i}const Q=i.cssPrefix;function Tg(e){let{options:t,onClose:n}=e,r=t.strings,i=B(null);z(()=>{let e=i.current;if(!e||!n)return;let t=bf(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.sendPreparing&&e.options.features.fileUpload,s=wg({containerRef:i,onDrop:V(e=>{o&&a.current?.attachFromDrop(e)},[a,o]),accept:e.options.attachments.accept,disabled:!o});return Cg(i.current,t.mode===`modal`),/* @__PURE__ */ U(`div`,{ref:i,class:`${Q}-panel`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":r.panelTitle,style:{position:`relative`},"data-testid":Y.panel,children:[/* @__PURE__ */ U(Eg,{...e,containerEl:i.current,dragOver:s}),/* @__PURE__ */ U(Pg,{poweredBy:e.options.poweredBy,strings:e.options.strings})]})}function Eg(e){let{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,composerKey:s,panelSize:c,view:l,isStreaming:u,isMemoryCompacting:d,canReleaseQueuedMessages:f,queueManualMessages:p,replyAwaitsCard:m,sendPreparing:h,attachmentUploadsSig:g,controlMode:_,assignedOperator:v,operatorAvailable:y,operatorRequestEnabled:b,onRequestOperator:x,onCancelOperatorRequest:S,loadingMessages:C,onLoadPreviousMessages:w,messagesSig:ee,reconnectingSig:T,agent:E,ticketReference:D,login:O,onStartAsGuest:te,suggestions:k,initialWidgetSize:ne,onClose:re,onBack:ie,onExpand:A,onToggleHistory:ae,onSelectHistoryConversation:j,onNewConversation:oe,onWidgetSizeChange:se,onSend:ce,onStop:le,onSuggestion:ue,tool:M,onRetry:de,onMessageFeedback:fe,onCardAction:pe,containerEl:me,dragOver:he,composerApiRef:ge}=e,N=t.strings,_e=_===`operator`?v:void 0,ve=_e?{name:_e.name??_e.initials,avatar:_e.avatar,title:N.operatorBadgeTitle,status:`online`}:E,ye=t.header.showNotice?Pt(N,t.header.notice||`chatNotice`):void 0,be=da(()=>ee.value.some(e=>!e.ephemeral&&e.role!==`system`)).value,xe=da(()=>ee.value.length>0).value,[Se,Ce]=R(),we=Se===o,Te=t.features.emailTranscript&&be?()=>Ce(o):void 0,P=O.gate?/* @__PURE__ */ U(Ng,{login:{...O,gate:O.gate},alone:!xe,onStartAsGuest:te,strings:N}):/* @__PURE__ */ U(L,{children:[_&&_!==`ai-agent`?/* @__PURE__ */ U(Og,{controlMode:_,operatorName:v?.name??v?.initials,operatorAvailable:y,onCancelOperatorRequest:S,strings:N}):null,d&&_===`ai-agent`?/* @__PURE__ */ U(`div`,{class:`${Q}-loading ${Q}-compaction-status`,role:`status`,"data-testid":Y.compactionStatus,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-loading-spinner`,"aria-hidden":`true`}),N.compactingContext]}):null,!u&&!d&&_===`ai-agent`&&/* @__PURE__ */ U(bg,{suggestions:k,strings:N,onPick:ue,disabled:h}),/* @__PURE__ */ U(qp,{options:t,transport:n,feedback:r,bus:i,persistence:a,conversationId:o,maxMessageCharacters:e.maxMessageCharacters,isStreaming:u,pageToolRunning:e.pageToolRunning,isMemoryCompacting:d,canReleaseQueuedMessages:f,queueManualMessages:p,replyAwaitsCard:m,active:e.composerActive&&l===`chat`,isPreparing:h,attachmentUploadsSig:g,operatorRequestEnabled:b,canRequestOperator:be,controlMode:_,onRequestOperator:x,onSend:ce,onStop:le,apiRef:ge},s)]});return/* @__PURE__ */ U(L,{children:[l===`history`?/* @__PURE__ */ U(Dg,{strings:N,onBack:ae,onClose:re,showClose:Wu(t.mode,c,t.actions)}):/* @__PURE__ */ U(`header`,{class:`${Q}-header`,part:`header`,"data-variant":t.header.variant,"data-testid":Y.panelHeader,children:[ie?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Q}-icon-btn`,onClick:ie,"aria-label":N.moduleBack,title:N.moduleBack,children:/* @__PURE__ */ U(kd,{})}):null,ve?/* @__PURE__ */ U(fm,{agent:ve,strings:N,ticketReference:D,person:!!_e}):/* @__PURE__ */ U(`h1`,{children:N.panelTitle}),/* @__PURE__ */ U(Zf,{panelProps:O.gate?{...e,options:{...t,actions:t.actions.filter(e=>e!==`history`)}}:e,variant:`chat`,onEmailTranscript:Te,onLogIn:O.menuLogIn})]}),l===`history`?/* @__PURE__ */ U(Sm,{transport:n,strings:N,locale:t.locale,persistence:a,onSelect:j,onNewConversation:oe}):/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(wm,{state:he,strings:N}),O.strip?/* @__PURE__ */ U(jg,{strip:O.strip,onLogIn:O.onLogIn,onHide:O.onHidePrompt,strings:N}):null,O.gate&&!xe?null:/* @__PURE__ */ U(pg,{messagesSig:ee,reconnectingSig:T,pageToolRunning:e.pageToolRunning,strings:N,notice:ye,locale:t.locale,responseMode:t.responseMode,showReasoning:t.showReasoning,stepDisplay:t.stepDisplay,showSources:t.showSources,enableMessageFeedback:t.enableMessageFeedback,onFeedback:fe,loading:C,onLoadPreviousMessages:w,idle:!u&&!h,controlMode:_,tool:M,onRetry:de,onCardAction:pe}),P,/* @__PURE__ */ U(Ag,{disclaimer:t.composerDisclaimer}),we?/* @__PURE__ */ U(Nm,{transport:n,strings:N,knownEmail:Am({tokenEmail:O.email,userContext:t.userContext}),onClose:()=>Ce(void 0)}):null]}),t.size.resize?.enabled?/* @__PURE__ */ U(vg,{panelEl:me,resize:t.size.resize,position:t.position,edge:t.mode===`drawer`,initialSize:ne,onSizeChange:se,onResizeStart:t.mode===`floating`&&c===`expanded`?A:void 0,strings:N}):null]})}function Dg({strings:e,onBack:t,onClose:n,showClose:r}){return/* @__PURE__ */ U(`header`,{class:`${Q}-header`,part:`header`,children:[/* @__PURE__ */ U(`button`,{type:`button`,class:`${Q}-icon-btn`,onClick:t,"aria-label":e.historyBack,title:e.historyBack,children:/* @__PURE__ */ U(kd,{})}),/* @__PURE__ */ U(`h1`,{children:e.historyTitle}),r?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Q}-icon-btn`,onClick:n,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ U(od,{})}):null]})}function Og({controlMode:e,operatorName:t,operatorAvailable:n,onCancelOperatorRequest:r,strings:i}){let[a,o]=R(!1),s=kg(e,t,n,i);function c(){r&&(o(!0),r().finally(()=>o(!1)))}return/* @__PURE__ */ U(`div`,{class:`${Q}-operator-banner`,"data-mode":e,"data-available":n===!1?`false`:void 0,"data-testid":Y.operatorBanner,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-operator-pulse`,"aria-hidden":`true`}),/* @__PURE__ */ U(`span`,{class:`${Q}-operator-label`,role:`status`,children:s}),e===`awaiting-operator`&&r?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Q}-icon-btn ${Q}-operator-dismiss`,onClick:c,disabled:a,"aria-label":i.cancelOperatorRequest,title:i.cancelOperatorRequest,"data-testid":Y.cancelOperatorRequest,children:/* @__PURE__ */ U(od,{})}):null]})}function kg(e,t,n,r){return e===`operator`?r.chattingWithOperator.replace(`{operator}`,t??``):n===!1?r.noOperatorAvailable:r.connectingOperator}function Ag({disclaimer:e}){return e?/* @__PURE__ */ U(`div`,{class:`${Q}-composer-footer`,children:/* @__PURE__ */ U(`div`,{class:`${Q}-disclaimer`,children:e})}):null}function jg({strip:e,onLogIn:t,onHide:n,strings:r}){let i=e.kind===`user`;return/* @__PURE__ */ U(`div`,{class:`${Q}-login-bar`,"data-kind":e.kind,role:i?`status`:`note`,"data-testid":i?Y.loggedIn:Y.loginBar,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-login-bar-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(hd,{})}),i?/* @__PURE__ */ U(`span`,{class:`${Q}-login-bar-text`,children:e.who?r.loggedInAs.replace(`{name}`,e.who):r.loggedIn}):/* @__PURE__ */ U(L,{children:[/* @__PURE__ */ U(`span`,{class:`${Q}-login-bar-text`,children:r.loginPrompt}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Q}-login-bar-action`,onClick:t,"data-testid":Y.loginBarAction,children:r.loginAction}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${Q}-icon-btn ${Q}-login-bar-hide`,onClick:n,"aria-label":r.dismissLoginPrompt,title:r.dismissLoginPrompt,"data-testid":Y.loginBarHide,children:/* @__PURE__ */ U(od,{})})]})]})}function Mg(e,t){return e.gate===`required`?t.loginRequired:e.canStartAsGuest?t.loginExpiredGuest:t.loginExpired}function Ng({login:e,alone:t,onStartAsGuest:n,strings:r}){return/* @__PURE__ */ U(`div`,{class:`${Q}-login-gate`,"data-gate":e.gate,"data-alone":t?``:void 0,"data-testid":Y.loginGate,children:[/* @__PURE__ */ U(`span`,{class:`${Q}-login-gate-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ U(hd,{})}),/* @__PURE__ */ U(`p`,{class:`${Q}-login-gate-title`,role:`status`,children:Mg(e,r)}),e.canLogIn||e.canStartAsGuest?/* @__PURE__ */ U(`div`,{class:`${Q}-form-actions ${Q}-login-gate-actions`,children:[e.canStartAsGuest?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Q}-form-skip`,onClick:n,"data-testid":Y.loginGateGuest,children:r.startAsGuest}):null,e.canLogIn?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Q}-form-submit`,onClick:e.onLogIn,"data-testid":Y.loginGateAction,children:r.loginAction}):null]}):null]})}function Pg({poweredBy:e,strings:t}){return e?/* @__PURE__ */ U(`div`,{class:`${Q}-poweredby-bar`,children:/* @__PURE__ */ U(Fg,{logoUrl:e.logoUrl,text:e.text??t.poweredBy.replace(`{name}`,i.displayName),href:e.href})}):null}function Fg({logoUrl:e,text:t,href:n}){let r=/* @__PURE__ */ U(L,{children:[e?/* @__PURE__ */ U(`img`,{class:`${Q}-poweredby-logo`,src:e,alt:``,loading:`lazy`}):null,t?/* @__PURE__ */ U(`span`,{children:t}):null]});return n?/* @__PURE__ */ U(`a`,{class:`${Q}-poweredby`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:r}):/* @__PURE__ */ U(`span`,{class:`${Q}-poweredby`,children:r})}const Ig=i.cssPrefix;function Lg({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=B(null),f=B(/* @__PURE__ */ new Set);z(()=>{let t=d.current;if(!t||!e.onClose)return;let n=bf(t);function r(t){t.key===`Escape`&&e.onClose?.()}return t.addEventListener(`keydown`,r),()=>{n(),t.removeEventListener(`keydown`,r)}},[e.onClose]);let p=da(()=>n.sig.value).value,m=Zu(p),h=l.modules.byId[p.activeTab],g=e.composerActive&&h?.layout===`chat`&&m===void 0,_=e.composerApiRef,v=g&&e.view===`chat`&&!e.sendPreparing&&e.options.features.fileUpload,y=wg({containerRef:d,onDrop:V(e=>{v&&_.current?.attachFromDrop(e)},[_,v]),accept:e.options.attachments.accept,disabled:!v});Cg(d.current,l.mode===`modal`);let b=m?.kind===`content`,x=t.length>1&&Qu(p),S=B(null);z(()=>{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 ee=/* @__PURE__ */ U(Zf,{panelProps:e,variant:`plain`});h&&f.current.add(h.id);let T=t.filter(e=>f.current.has(e.id));function E(t){if(t.layout===`chat`)return/* @__PURE__ */ U(Eg,{...e,composerActive:g,containerEl:d.current,dragOver:y});let n=cm[t.layout].Root;return n?/* @__PURE__ */ U(n,{...w(t)}):null}function D(){return m?.kind===`content`?/* @__PURE__ */ U(Hf,{id:m.id,title:m.title,transport:e.transport,strings:u,bus:r,onBack:()=>n.pop(),actions:ee}):null}return/* @__PURE__ */ U(`div`,{ref:d,class:`${Ig}-panel ${Ig}-messenger`,part:`panel`,role:`dialog`,"aria-modal":`false`,"aria-label":u.panelTitle,style:{position:`relative`},"data-testid":Y.messengerHome,children:[/* @__PURE__ */ U(`div`,{class:`${Ig}-messenger-body`,children:[T.map(e=>/* @__PURE__ */ U(`div`,{class:`${Ig}-messenger-pane`,hidden:b||e.id!==h?.id,children:E(e)},e.id)),D()]}),x?/* @__PURE__ */ U(um,{modules:t,activeTab:p.activeTab,strings:u,hasUnread:i,onSelect:e=>n.switchTab(e)}):null,/* @__PURE__ */ U(Pg,{poweredBy:l.poweredBy,strings:l.strings}),l.size.resize?.enabled&&(h?.layout!==`chat`||m)?/* @__PURE__ */ U(vg,{panelEl:d.current,resize:l.size.resize,position:l.position,edge:l.mode===`drawer`,initialSize:e.initialWidgetSize,onSizeChange:e.onWidgetSizeChange,onResizeStart:l.mode===`floating`&&e.panelSize===`expanded`?e.onExpand:void 0,strings:u}):null]})}function Rg(e){let t=i.cssPrefix,{site:n,blocks:r,strings:a,collapsed:o}=e,s=r?.navigation??[],c=r?.linkCards??[],l=o?a.expandSidebar:a.collapseSidebar;return/* @__PURE__ */ U(`aside`,{class:`${t}-sidebar`,"data-collapsed":o?`true`:`false`,"data-testid":Y.sidebar,children:[/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-header`,children:[/* @__PURE__ */ U(zg,{site:n}),/* @__PURE__ */ U(`button`,{type:`button`,class:`${t}-sidebar-toggle`,"aria-label":l,"aria-expanded":o?`false`:`true`,title:l,onClick:e.onToggleCollapsed,"data-testid":Y.sidebarToggle,children:/* @__PURE__ */ U(Bg,{collapsed:o})})]}),o?null:/* @__PURE__ */ U(L,{children:[s.length>0?/* @__PURE__ */ U(`nav`,{class:`${t}-sidebar-section`,"data-section":`navigation`,children:/* @__PURE__ */ U(Vg,{items:s})}):null,c.length>0?/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-section`,"data-section":`link-cards`,children:/* @__PURE__ */ U(Hg,{items:c})}):null,e.showConversations?/* @__PURE__ */ U(`div`,{class:`${t}-sidebar-conversations`,children:/* @__PURE__ */ U(Sm,{transport:e.transport,strings:e.strings,locale:e.locale,persistence:e.persistence,onSelect:e.onSelectConversation,onNewConversation:e.onNewConversation})}):null]})]})}function zg({site:e}){let t=i.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??i.name})}function Bg({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 Vg({items:e}){let t=i.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 Hg({items:e}){let t=i.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 Ug=i.cssPrefix;function Wg(e){return/* @__PURE__ */ U(`main`,{class:`${Ug}-page-shell`,"data-sidebar-collapsed":e.sidebarCollapsed?`true`:`false`,children:[/* @__PURE__ */ U(Rg,{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:`${Ug}-page-chat`,"aria-label":e.strings.panelTitle,children:e.children})]})}const Gg=i.cssPrefix;function Kg({strings:e,text:t,onClose:n}){return/* @__PURE__ */ U(`div`,{class:`${Gg}-panel ${Gg}-panel-notice`,part:`panel`,role:`dialog`,"aria-label":e.panelTitle,"data-testid":Y.panelNotice,children:[n?/* @__PURE__ */ U(`button`,{type:`button`,class:`${Gg}-icon-btn ${Gg}-panel-notice-close`,onClick:n,"aria-label":e.close,title:e.close,children:/* @__PURE__ */ U(od,{})}):null,/* @__PURE__ */ U(`p`,{class:`${Gg}-panel-notice-text`,children:t})]})}const qg=_.scope(`hitl`);function Jg(e){return e.kind===`tool`&&P(e.toolMetadata)&&(e.stateSig.value===`input-available`||e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved===!0)}function Yg(e,t){t.errorSig.value=Me(t.toolCallId),t.stateSig.value=`output-error`,e.partsSig.value=[...e.partsSig.value]}function Xg(e,t){let n=e.slice(0,e.indexOf(t)).findLast(e=>e.role===`user`);return n!==void 0&&M.sentHere(n.id)}function Zg(e){let{streaming:t,controlModeSig:n,messagesSig:r,sendAiTurn:i,bus:a,humanInLoop:o,tools:s}=e,c=B(t);c.current=t;let l=B(s);l.current=s;let u=B(/* @__PURE__ */ new Map),d=da(()=>{let e=r.value,t=e.at(-1);return n.value!==`ai-agent`||t?.role!==`assistant`||t.status!==`complete`?!1:t.partsSig.value.some(e=>Jg(e)&&M.get(e.toolCallId)?.state!==`stopped`)&&Xg(e,t)}).value,f=V((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 qg.warn(`decideTool: tool part not found`,{toolCallId:e}),!1;if(o.status!==`complete`||!Ml(o,s)||!t(l))return!1;if(a(l),o.partsSig.value=[...o.partsSig.value],!Al(o)||o.partsSig.value.some(Jg))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]),p=V((e,t)=>{let{toolCallId:n,toolName:r}=t;u.current.has(n)||(u.current.set(n,e),Ae({toolCallId:n,toolName:r,input:t.inputSig.value,optionTools:l.current??[],onSettled:(e,t)=>{qg.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(n,Jg,t=>{e.state===`output-available`?t.outputSig.value=e.output:t.errorSig.value=e.errorText,t.stateSig.value=e.state})}))},[a,f]),m=V(()=>{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),Ne(t))}let t=e.at(-1);if(c.current||t?.role!==`assistant`||t.status!==`complete`)return;let n=t.partsSig.value.filter(Jg);if(n.length!==0&&Xg(e,t))for(let e of n)M.get(e.toolCallId)?.state===`stopped`?Yg(t,e):p(t.id,e)},[r,p]);z(()=>m(),[t,m]),z(()=>r.subscribe(()=>m()),[r,m]);let h=V((e,t,n)=>{let i=!1,o;if(!f(e,e=>e.stateSig.value===`approval-requested`,r=>{P(r.toolMetadata)&&(o=r),i=r.toolMetadata?.card===`questions`;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&&p(s.id,o),o&&!t&&a.emit(`toolResult`,{toolCallId:e,name:Ee(o.toolName),status:`declined`,durationMs:0}),i?(qg.info(`toolResult`,{toolCallId:e}),a.emit(`toolResult`,{toolCallId:e})):(qg.info(`toolDecision`,{toolCallId:e,approved:t}),a.emit(`toolDecision`,{toolCallId:e,approved:t}))},[a,f,r,p]),g=V(e=>{f(e,e=>e.stateSig.value===`approval-responded`&&e.approvalSig.value?.approved!==void 0&&!Jg(e),t=>{let n=t.approvalSig.value?.id??e;t.approvalSig.value={id:n},t.stateSig.value=`approval-requested`})},[f]);return{toolInteraction:bi(()=>({humanInLoop:o,onDecision:h,onEdit:g,preview:(e,t)=>Oe({toolName:e,input:t,optionTools:l.current??[]})}),[o,h,g]),pageToolsRunning:d,stopPageTools:V(()=>{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?Yg(e,n):Me(t),qg.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()},[a,r])}}const Qg=_.scope(`latest-news`);function $g({transport:e,options:t,persistence:n,enabled:r}){let i=t.modules.list.find(e=>e.layout===`news`)?.contentCollectionIds,a=i?.join(`,`),[o,s]=R(),[c,l]=R(()=>n.loadSeenNewsId());z(()=>{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=>Qg.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 e_({callout:e,persistence:t}){let n=e?.text??``,r=e?.persistent??!0,[i,a]=R(()=>!r&&t.loadCalloutDismissed(n));return z(()=>{a(!r&&t.loadCalloutDismissed(n))},[n,r,t]),{dismissed:i,dismissCallout:V(()=>{a(!0),r||t.saveCalloutDismissed(n)},[t,n,r])}}const t_=_.scope(`login`);function n_(e,t){switch(e.status){case`required`:return`required`;case`expired`:return`expired`;case`anonymous`:return t?`required`:void 0;case`pending`:case`loggedIn`:return;default:return e}}function r_(e,t,n){if(e.status===`loggedIn`)return t.hideUser?void 0:{kind:`user`,who:e.name??e.email};if(!(e.status!==`anonymous`||!t.url||t.hidePrompt||n))return{kind:`prompt`}}function i_(e){let{state:t,deployment:n,bus:r,persistence:i,conversationIdSig:a}=e,[o,s]=R(()=>i.loadLoginPromptDismissedIn()),c=da(()=>a.value).value,l=o!==void 0&&o===c,u=(t.status===`required`?t.loginUrl:void 0)??n.url,d=n_(t,n.required),f=V(()=>{let e=qa(),t=r.listensTo(`loginRequested`);if(t_.info(`loginRequested`,{pageLogsIn:t}),r.emit(`loginRequested`,{returnTo:e}),t||!u)return;let n=a.value;n&&i.saveLoginReturn({conversationId:n,draft:i.loadDraft(n)}),i.savePanelOpen(!1),Ja(Ha(u,e))},[r,a,u,i]),p=V(()=>{let e=a.value;e&&(i.dismissLoginPromptIn(e),s(e))},[a,i]),m=!!u||r.listensTo(`loginRequested`);return{strip:r_(t,n,!!d||l),gate:d,canStartAsGuest:d===`expired`&&!n.required,email:t.status===`loggedIn`?t.email:void 0,canLogIn:m,onLogIn:f,menuLogIn:t.status===`anonymous`&&!d&&m?f:void 0,onHidePrompt:p}}function a_(e){let{transport:t,conversationIdSig:n}=e,r=ua(`ai-agent`),i=ua(void 0),a=ua(void 0),o=B(void 0),s=V(e=>{let t=e.controlRevision,s=o.current;if(s&&s.conversationId===n.value&&t<s.revision)return;o.current={conversationId:n.value,revision:t},r.value=e.controlMode;let c=e.assignedOperatorInitials;i.value=c?{initials:c,name:e.assignedOperatorName,avatar:e.assignedOperatorAvatar}:void 0,e.controlMode===`awaiting-operator`?e.operatorAvailable!==void 0&&(a.value=e.operatorAvailable):a.value=void 0},[n,r,i,a]);return{controlModeSig:r,assignedOperatorSig:i,operatorAvailableSig:a,applyControlState:s,adoptControlStateChunk:V(e=>{if(e.type!==`data-control-state`)return;let t=rl(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 o_=i.cssPrefix,s_=`--${o_}-visual-viewport-height`,c_=`--${o_}-visual-viewport-top`;function l_(e){let{hostElement:t,mode:n,panelSize:r,isOpen:i,surfaceReady:a,onClose:o}=e;yi(()=>{ei(t,ed(n,r,i))},[t,i,r,n]),yi(()=>{if(!i||!a)return;let e=t.ownerDocument.defaultView,n=e?.visualViewport,r=t.shadowRoot?.querySelector(`.${o_}-anchor`);if(!e||!n||!r)return;let o=()=>{r.style.setProperty(s_,`${n.height}px`),r.style.setProperty(c_,`${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(s_),r.style.removeProperty(c_)}},[t,i,a]),z(()=>{if(n!==`modal`||!i)return;function e(e){e.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains(`${o_}-panel`))||o()}return t.addEventListener(`click`,e),()=>t.removeEventListener(`click`,e)},[t,i,n,o]),z(()=>{if(n!==`drawer`||!i)return;function e(e){e.key===`Escape`&&!e.composedPath().includes(t)&&o()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,i,n,o])}const u_=_.scope(`reducer`);var d_=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),S(this,`turnChunks`,[]),S(this,`turnRow`,null)}attach(e){this.active=e,this.openTextParts.clear()}detach(){this.active=null,this.replay=null,this.openTextParts.clear()}beginReplay(e,t){let n=ul();n.id=e.id;let r=f_(e)||jl(e)&&(e.status!==`streaming`||Al(e)),i=e.status===`streaming`&&Al(e)&&kl(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,p_(a,i),e.liveCatchUp&&f_(e.shadow)&&(i.status===`streaming`||jl(i))?(e.probeContinuation=!1,e.continuationTailReplay=!1,e):(e.probeContinuation=f_(i)||jl(i)&&(i.status!==`streaming`||Al(i)),e.continuationTailReplay=i.status===`streaming`&&Al(i)&&kl(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;p_(e,i);let a=f_(e)&&jl(i);return i.status!==`streaming`&&!a?(this.detach(),null):(this.replayTurn(),this.replay?this.replay.shadow:this.active)}replayTurn(){let[e,...t]=this.turnChunks;if(e?.type!==`start`)return;let n=this.messagesSig.value.find(t=>t.serverMessageId===e.messageId);if(n!==void 0&&n!==this.turnRow){this.detach();for(let n of[e,...t])this.applyResume(n)}}promoteReplay(e){let{baseline:t,shadow:n}=e;return Mi(()=>{t.role=n.role,t.serverMessageId=n.serverMessageId,t.operatorInitials=n.operatorInitials,t.status=n.status,n.canceled&&(t.canceled=!0),t.finishReason=n.finishReason,t.errorText=n.errorText,t.suggestions=n.suggestions??t.suggestions,t.runStartedAt=n.runStartedAt??t.runStartedAt,t.stepTimings=n.stepTimings??t.stepTimings,t.partsSig.value=n.partsSig.value,this.messagesSig.value=[...this.messagesSig.value]}),this.replay=null,this.active=t,t}promoteContinuation(e){let{baseline:t,chunks:n}=e,r=Nl(t);return this.replay=null,Mi(()=>{t.partsSig.value=t.partsSig.value.slice(0,m_(t,n)+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,t){let{baseline:n}=e,r=Nl(n);return this.replay=null,Mi(()=>{n.awaitingContinuation=!1,n.status=`streaming`,n.finishReason=void 0,n.errorText=void 0,n.suggestions=void 0,this.attach(n),this.apply(t),n.continuationStreaming=r||void 0,this.messagesSig.value=[...this.messagesSig.value]}),n}applyResume(e){e.type===`start`&&(this.turnChunks=[]);let t=this.applyTurnChunk(e);return this.turnChunks.push(e),this.turnRow=t??this.replay?.baseline??this.active??this.turnRow,t}applyTurnChunk(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&&!wl(a))return this.attach(a),this.apply(e),null;let o=ul();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(!v_(n,r,e)){if(s){if(n.status===`streaming`&&n.awaitingContinuation!==!0){let n=this.settleOwnedContinuation(t,e);return this.detach(),n}S_(n,r)&&(n.continuationStreaming=!0,this.messagesSig.value=[...this.messagesSig.value],this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id})),this.detach()}return null}let i=f_(n)&&s?this.settleOwnedContinuation(t,e):this.promoteContinuation(t);return s?(i.continuationStreaming&&(e.type===`finish`?this.onReconcileNeeded?.({messageId:i.serverMessageId??i.id}):i.continuationStreaming=!1),this.detach(),i):null}if(a&&g_(n,r)){let e=this.promoteContinuation(t);return s?(this.detach(),e):null}if(!o)return s&&this.detach(),null;if(s&&!wl(n)&&wl(r)){let e=this.promoteReplay(t);return this.detach(),e}if(!h_(n,r))return s&&(this.onReconcileNeeded?.({messageId:n.serverMessageId??n.id}),this.detach()),null;let c=this.promoteReplay(t);return s?(this.detach(),c):null}let t=this.refreshActive();if(!t)return null;if(this.replay)return this.applyTurnChunk(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),w_(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?.runStartedAt&&(t.runStartedAt=n.runStartedAt),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`:w_(t,{kind:`step-start`,id:`ss-${this.partSeq++}`});return;case`message-metadata`:t.stepTimings=hl(e.messageMetadata?.steps)??t.stepTimings;return;case`finish`:u_.debug(`finish`,{reason:e.finishReason}),t.stepTimings=hl(e.messageMetadata?.steps)??t.stepTimings,t.status=`complete`,t.retryAction=void 0,e.finishReason&&(t.finishReason=e.finishReason),this.bumpDone(t);return;case`error`:u_.warn(`stream error chunk`,{errorText:e.errorText}),t.status=`error`,t.errorText=void 0,this.bumpDone(t);return;case`abort`:u_.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`:case`tool-approval-response`:E_(t,e);return;case`file`:w_(t,{kind:`file`,url:e.url,mediaType:e.mediaType,filename:e.filename,fileId:e.fileId,fileSize:e.fileSize});return;case`source-url`:T_(t,{kind:`source`,sourceId:e.sourceId,url:e.url,title:e.title});return;case`source-document`:T_(t,{kind:`source`,sourceId:e.sourceId,title:e.title,filename:e.filename,mediaType:e.mediaType});return;case`data-suggestions`:t.suggestions=al(e.data);return;case`data-control-state`:t.operatorRoutedTurn=e.data.controlMode!==`ai-agent`;return;case`data-memory-compaction-state`:return}}bumpDone(e){Mi(()=>{e.partsSig.value=[...e.partsSig.value],this.messagesSig.value.includes(e)&&(this.messagesSig.value=[...this.messagesSig.value])})}};function f_(e){return e.awaitingContinuation===!0||e.continuationStreaming===!0||e.retryAction?.kind===`continue-assistant`}function p_(e,t){e.canceled&&(t.canceled=!0),f_(e)&&(t.status===`streaming`||jl(t))&&(t.awaitingContinuation??(t.awaitingContinuation=e.awaitingContinuation),t.continuationStreaming??(t.continuationStreaming=e.continuationStreaming),t.retryAction===void 0&&(t.retryAction=e.retryAction))}function m_(e,t){let n=e.partsSig.value,r=t.findIndex(e=>e.type===`start-step`),i=new Set(t.slice(0,r<0?t.length:r).flatMap(e=>`toolCallId`in e&&e.type.startsWith(`tool-output`)?[e.toolCallId]:[])),a=n.findLastIndex(e=>e.kind===`tool`&&(e.stateSig.value===`approval-requested`||e.stateSig.value===`approval-responded`||i.has(e.toolCallId)));if(a>=0)return a;let o=new Set(t.flatMap(e=>e.type===`tool-input-start`||e.type===`tool-input-available`?[e.toolCallId]:[]));return n.some(e=>e.kind===`tool`&&o.has(e.toolCallId))?-1:n.findLastIndex(e=>e.kind===`tool`)}function h_(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)=>__(e,r[t]))}function g_(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)=>__(e,a[t]))}function __(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||!Gl(t.toolName,e.toolName)||Kl[t.stateSig.value]<Kl[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 v_(e,t,n){return y_(e,n)||!b_(e,t)?!0:n.type!==`finish`&&n.type!==`error`&&n.type!==`abort`?!1:kl(t)||e.awaitingContinuation===!0&&n.type!==`finish`?!0:e.awaitingContinuation===!0&&t.partsSig.value.every(e=>e.kind===`step-start`)}function y_(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&&Kl[n.stateSig.value]<4}function b_(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)=>x_(r[t+n],e)))}function x_(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`||Gl(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 S_(e,t){if(f_(e)||!jl(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 C_(e,t,n={}){let r=e.partsSig.value.find(e=>e.kind===`tool`&&e.toolCallId===t);if(r)return n.dynamic&&(r.dynamic=!0),r.toolMetadata??(r.toolMetadata=n.toolMetadata),r.title=n.title??r.title,r;let i={kind:`tool`,toolCallId:t,toolName:n.toolName??`tool`,title:n.title,dynamic:n.dynamic?!0:void 0,toolMetadata:n.toolMetadata,inputPartialSig:H(``),inputSig:H(void 0),outputSig:H(void 0),errorSig:H(void 0),stateSig:H(`input-streaming`),approvalSig:H(void 0)};return w_(e,i),i}function w_(e,t){e.partsSig.value=[...e.partsSig.value,t]}function T_(e,t){e.partsSig.value.some(e=>e.kind===`source`&&e.sourceId===t.sourceId)||w_(e,t)}function E_(e,t){switch(t.type){case`tool-input-start`:C_(e,t.toolCallId,t);return;case`tool-input-delta`:{let n=C_(e,t.toolCallId);n.inputPartialSig.value+=t.inputTextDelta;return}case`tool-input-available`:{let n=C_(e,t.toolCallId,t);n.inputSig.value=t.input,n.stateSig.value=`input-available`;return}case`tool-input-error`:{let n=C_(e,t.toolCallId,t);n.inputSig.value=t.input,n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-approval-request`:{let n=C_(e,t.toolCallId,t);if(t.isAutomatic){n.approvalSig.value={id:t.approvalId,isAutomatic:!0};return}n.approvalSig.value={id:t.approvalId},n.stateSig.value=`approval-requested`;return}case`tool-approval-response`:{let n=e.partsSig.value.find(e=>e.kind===`tool`&&e.approvalSig.value?.id===t.approvalId);n?.approvalSig.value&&(n.approvalSig.value={...n.approvalSig.value,approved:t.approved,reason:t.reason});return}case`tool-output-available`:{let n=C_(e,t.toolCallId,t);n.outputSig.value=t.output,n.stateSig.value=`output-available`;return}case`tool-output-error`:{let n=C_(e,t.toolCallId,t);n.errorSig.value=t.errorText,n.stateSig.value=`output-error`;return}case`tool-output-denied`:{let n=C_(e,t.toolCallId);n.stateSig.value=`output-denied`;return}default:return}}const D_=1e3;async function O_(e){let t=D_,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;e.onDropped?.(),o!==void 0&&e.now()-o>=1e3&&(t=D_),await e.sleep(t),t=Math.min(t*2,15e3)}}function k_(e){let{activated:t,conversationReady:n,paused:r,conversationIdSig:i,messagesSig:a,optionsRef:o,transport:s,visitorId:c,adoptControlStateChunk:l,adoptMemoryCompactionStateChunk:u,settleSuggestions:d,recordConversationReply:f,transcriptRecoverySig:p,beginConversationTranscript:m,commitConversationTranscript:h,runCancellation:g,feedback:_,bus:v,loadInitialThread:y,shouldReconcileOnConnect:b,reconnectingSig:x}=e,S=B(0);z(()=>{if(!t||!n||r||!i.value)return;let e=i.value,C=new AbortController,w=e=>{},ee=new d_(a,e=>w(e));s.primeIdentity(c,e);let T=!1,E=!1,D,O=!1,te,k=0,ne,re,ie=Date.now(),A,ae=!1,j=!1,oe=!1,se;function ce(t,n){if(!wl(t))return;let r=a.value.findLast(e=>!e.ephemeral),i=t.serverMessageId??t.id;if(!(r&&(r.serverMessageId??r.id)!==i)){if(A&&ae&&!a.value.some(e=>e.role===`user`&&!e.ephemeral))se={replyId:i,activityAt:n};else return Cl(a.value,t,e,o.current.strings.newConversation,n)}}function le(e,t,n){let r=ce(e,n);if(!r)return;let i=`${e.serverMessageId??e.id}:${t}:${r.preview??``}`;i!==re&&(re=i,s.publishConversation({...r,hasUnread:!0},!0))}let ue;function M(){ue&&(clearTimeout(ue.timer),ue=void 0)}function fe(){let e=ue;if(!e)return;clearTimeout(e.timer),ue=void 0;let t=a.value.find(t=>(t.serverMessageId??t.id)===e.replyId);(t?.role===`assistant`||t?.role===`operator`)&&le(t,e.generation,e.activityAt)}function pe(e,t,n){M(),ue={replyId:e.serverMessageId??e.id,generation:t,activityAt:n,timer:setTimeout(fe,120)}}function me(e,t,n=Date.now(),r=!0){M();let i=ce(e,n);if(!i)return;let a=`${e.serverMessageId??e.id}:${t}`;a!==ne&&(ne=a,f(i),r&&A&&!ae&&(j=!0))}function he(e,t){(e||!g.localSendRef.current)&&g.settle(t)}function ge(e,t=[],n=!1,r,i=k,s=Date.now(),c=!0){let l=o.current;if(e.canceled){me(e,i,s,c),he(n,r);return}let u=!0,f=e.status===`error`;switch(Zl(e,f)){case`drop`:a.value=a.value.filter(t=>t!==e),u=!1;break;case`complete-operator-routed`:e.status=`complete`,n&&(_.play(`messageReceived`),Ku(v,l,`assistant`,Sl(e)));break;case`error`:if(e.status=`error`,n){_.play(`error`);let e=/* @__PURE__ */ Error(f?`stream error chunk`:`empty reply`);v.emit(`error`,e),l.onError?.(e)}break;case`complete`:e.status=`complete`,n&&(_.play(`messageReceived`),Ku(v,l,`assistant`,Sl(e))),d(e,t)}u&&me(e,i,s,c),he(n,r)}function N(t){if(C.signal.aborted||i.value!==e)return;if(l(t),u?.(t),t.type===`start`){fe();let n=t.messageId===void 0?void 0:a.value.find(e=>e.serverMessageId===t.messageId||e.id===t.messageId);O=n!==void 0&&n.status!==`streaming`;let r=te?.senderRole===`visitor`?te.messageId:void 0;te={messageId:t.messageId,senderRole:t.messageMetadata?.senderRole},k+=1,ie=Date.now(),re=void 0,T=t.messageMetadata?.senderRole===void 0,E=!1,D=T?t.messageMetadata?.runId:void 0;let i=T?t.messageMetadata?.senderMessageId:void 0;function o(e){return e.role===`assistant`&&e.retryAction?.kind===`resend-user`&&e.retryAction.messageId===i}if(i&&a.value.some(o)&&(a.value=a.value.filter(e=>!o(e))),T){let n=t.messageId!==void 0&&a.value.some(e=>e.serverMessageId===t.messageId||e.id===t.messageId),i=a.value.at(-1),o=t.messageId!==void 0&&(i?.serverMessageId===t.messageId||i?.id===t.messageId),s=g.localSendRef.current&&(!n||o)&&i?.role===`assistant`&&i.status===`streaming`&&(o||i.serverMessageId===void 0&&i.partsSig.value.length===0);E=g.captureStart(e,t,s,r)}}let n=T&&(t.type===`finish`||t.type===`error`||t.type===`abort`),r=n?D:void 0,s=n&&(E||g.ownsLocalRun(r)),c=k,d=O;n&&(T=!1,E=!1,D=void 0);let f=ee.applyResume(t),p=te?.messageId,m=p===void 0?void 0:a.value.find(e=>e.serverMessageId===p||e.id===p);O&&te?.senderRole!==`visitor`&&(f!==null||m?.status===`streaming`)&&(O=!1,d=!1);let h=!O&&(m?.role===`assistant`||m?.role===`operator`);t.type===`text-delta`&&h&&pe(m,k,ie),t.type===`text-end`&&(M(),h&&le(m,k,ie)),f?f.role===`operator`?(d||(_.play(`messageReceived`),Ku(v,o.current,`operator`,Sl(f))),me(f,c,ie),O=!1,n&&(s||!g.localSendRef.current)&&g.settle(r)):f.role===`assistant`&&(ge(f,[],s,r,c,ie),O=!1):n&&(s||!g.localSendRef.current)&&g.settle(r)}async function _e(t){let n=k,r=await s.loadConversation(e,t?{ids:[t]}:void 0).catch(()=>null);if(C.signal.aborted||i.value!==e||!r)return!1;r.controlState&&l({type:`data-control-state`,data:r.controlState});let o=a.value.at(-1),c=n===k&&(t===void 0||o!==void 0&&(o.serverMessageId===t||o.id===t));if(r.messages.length===0)return!0;let u=a.value,f=t===void 0?u.at(-1):u.find(e=>e.serverMessageId===t||e.id===t),p=Hl(u,yl(r.messages)),m=Bl(r.messages),h=p.messages.filter(e=>!(e.role===`assistant`&&e.retryAction?.kind===`resend-user`&&m.has(e.retryAction.messageId)));if(!p.changed&&h.length===p.messages.length)return!0;a.value=h;let _=t===void 0?h.at(-1):h.find(e=>e.serverMessageId===t||e.id===t),v=f!==void 0&&_!==void 0&&(f.id===_.id||f.serverMessageId!==void 0&&f.serverMessageId===_.serverMessageId),y=_!==void 0&&_.status!==`streaming`&&(!v||f?.status===`streaming`),b=v&&f?.status===`streaming`?Date.now():_?.createdAt;return c&&y&&_.role===`assistant`?ge(_,_.suggestions??[],g.localSendRef.current,void 0,n,b,!1):c&&y&&_.role===`operator`?me(_,n,b,!1):c&&_?.role===`assistant`&&_.status!==`streaming`&&d(_,_.suggestions??[]),!0}let ve=/* @__PURE__ */ new Set;w=({messageId:e})=>{if(ve.has(e)||!a.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(){let e=se;se=void 0;let t=e&&a.value.find(t=>(t.serverMessageId??t.id)===e.replyId),n=t&&ce(t,e.activityAt);n&&f(n)}function be(t=!1){if(C.signal.aborted||i.value!==e){j=!1;return}if(A){j=!0;return}let n=t?y(e):void 0,r=n??(!t||b()?_e():void 0);if(!r)return;m(e),A=r,ae=n!==void 0;function a(t=!1){A===r&&(A=void 0,ee.replayTurn(),j?(j=!1,be()):(ye(),t&&h(e)))}r.then(a,()=>a(!1))}let xe=p.subscribe(e=>{e<=S.current||(S.current=e,oe&&be())});return O_({signal:C.signal,now:()=>performance.now(),sleep:e=>de(e,C.signal),connect:e=>s.connectResumeStream({signal:C.signal,onChunk:N,onConnected:()=>{x.value=!1,e()}}),onDropped:()=>{x.value=!0},onInitialBoundaryReady:()=>{oe=!0,be(!0)},backfill:()=>be()}),()=>{C.abort(),x.value=!1,M(),xe(),ee.detach()}},[t,n,r,i,i.value,c,s,l,u,d,f,p,m,h,g,a,v,_,y,b,x])}function A_(e){let{transport:t,setStreaming:n}=e,r=B(void 0),i=B(void 0),a=B(!1),o=B(void 0),s=B(!1),c=B(/* @__PURE__ */ new Map),l=B(/* @__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=>{if(e!==void 0){l.current.add(e);let t=l.current.values().next().value;l.current.size>32&&t!==void 0&&l.current.delete(t)}(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 bi(()=>({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 j_=_.scope(`send`);function M_(e,t,n,r,i){e.publishConversation({...Cl(t,n,r,i),hasUnread:!1},!0)}function N_(e,t){return e.id===t.id||(e.serverMessageId??e.id)===(t.serverMessageId??t.id)}function P_(e){return e.findLast(e=>!e.ephemeral&&e.role!==`system`&&(e.role===`user`||e.status!==`streaming`||wl(e)))}function F_(e,t,n,r,i){let a=P_(t);a?.role===`user`&&N_(a,n)&&M_(e,t,a,r,i)}function I_(e){return e instanceof ru&&e.status===404&&e.errorCode===`CONVERSATION_NOT_FOUND`}function L_(e){return!(e instanceof ru)||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 R_(e){let{transport:t,messagesSig:n,conversationIdSig:r,options:i,bus:a,feedback:o,persistence:s,visitorId:c,adoptConversationId:l,applyControlState:u,setTicket:d,settleSuggestions:f,runCancellation:p,onConversationNotFound:m}=e,h=V(()=>{let e=r.value??wr();return r.value||(r.value=e,s.saveConversationId(e)),e},[r,s]);return{sendAiTurn:V(async({continueExisting:e,turn:g,movedFromConversation:_=!1})=>{let v=h(),y=n.value.at(-1),b=g?[g]:bl(n.value,e),x=b[0];x?.role===`user`&&M.markSent(x.id);let S=b.map(xl),C=s.loadUserPrefs(),w=we(i.tools).then(n=>t.sendTurn(ol({messages:S,conversationId:v,visitorId:c,userPrefs:C,clientTools:Te(n)}),{keepalive:e}));p.begin(w);try{let a=await w;if(r.value!==v||!p.acceptAck(w,a))return!1;if(l(a.conversationId),d({conversationId:a.conversationId,reference:a.ticketReference}),a.runId&&x?.role===`user`&&F_(t,n.value,x,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);let r=yl(o.messages),{messages:s,changed:c}=Hl(n.value,r);c&&(n.value=s);let l=r.findLast(e=>!e.ephemeral&&e.role!==`system`),d=P_(n.value);d&&l&&N_(d,l)&&M_(t,n.value,d,a.conversationId,i.strings.newConversation);let p=y?n.value.find(e=>e.id===y.id&&e.role===`assistant`&&e.status!==`streaming`):void 0;p&&f(p,p.suggestions??[]),!e&&y?.role===`assistant`&&n.value.includes(y)&&y.serverMessageId===void 0&&!wl(y)&&(n.value=n.value.filter(e=>e!==y))}else y?.role===`assistant`&&n.value.includes(y)&&(y.status=`error`,y.errorText=i.strings.errorGeneric,y.retryAction=e?{kind:`continue-assistant`,messageId:y.serverMessageId??y.id}:x?.role===`user`?{kind:`resend-user`,messageId:x.id}:null,n.value=[...n.value])}return!0}catch(c){if(r.value!==v)return!1;if(!p.reject(w))return x?.role===`user`&&F_(t,n.value,x,v,i.strings.newConversation),!0;if(!e&&!_&&x?.role===`user`&&I_(c))return m(x);if(!e&&x?.role===`user`&&c instanceof ru&&c.status===401){let e=y?.role===`assistant`&&y.serverMessageId===void 0?y:void 0;return n.value=n.value.filter(t=>t!==x&&t!==e),s.saveDraft(v,Sl(x)),!1}let l=$f(c,i.strings),d=L_(c),h=g?.role===`assistant`?g:n.value.at(-1);if(e&&h?.role===`assistant`&&c instanceof ru&&c.status===409){let e=h.serverMessageId??h.id,i=await t.loadConversation(v,{ids:[e]}).catch(()=>null);if(r.value!==v)return!1;if(i){i.controlState&&u(i.controlState);let t=yl(i.messages),r=t.find(t=>(t.serverMessageId??t.id)===e);if(r&&Ul(h,r)){let{messages:r,changed:i}=Hl(n.value,t),a=r.find(t=>(t.serverMessageId??t.id)===e);if(i&&a&&a!==h)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(h)||h.status!==`streaming`)return!1;h.continuationStreaming=!0}if(e&&h?.role===`assistant`)h.status=`error`,h.errorText=l,h.retryAction=d?{kind:`continue-assistant`,messageId:h.serverMessageId??h.id}:null,n.value=[...n.value];else if(y?.role===`assistant`&&n.value.includes(y)){y.status=`error`,y.errorText=l;let e=b[0];y.retryAction=d&&e?.role===`user`?{kind:`resend-user`,messageId:e.id}:null,n.value=[...n.value]}else{let e=ul();e.status=`error`,e.errorText=l;let t=b[0];e.retryAction=d&&t?.role===`user`?{kind:`resend-user`,messageId:t.id}:null,n.value=[...n.value,e]}return o.play(`error`),a.emit(`error`,c),i.onError?.(c),!1}},[t,n,i,a,o,s,c,l,u,d,f,h,p,m]),sendRoutedTurn:V(async e=>{let u=h();e.status=`pending`,e.errorText=void 0,e.retryAction=void 0,n.value.includes(e)&&(n.value=[...n.value]),M.markSent(e.id);let f=[xl(e)],g=s.loadUserPrefs(),_=we(i.tools).then(e=>t.sendTurn(ol({messages:f,conversationId:u,visitorId:c,userPrefs:g,clientTools:Te(e)})));p.beginRouted(_,e.id);try{let a=await _;return r.value===u?p.acceptRoutedAck(_,a)?(l(a.conversationId),d({conversationId:a.conversationId,reference:a.ticketReference}),F_(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(_),!1)}catch(s){let c=p.rejectRouted(_);if(r.value!==u)return!1;if(!c)return F_(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 F_(t,n.value,e,u,i.strings.newConversation),!0;if(I_(s))return m(e);j_.debug(`operator-routed send failed`,{error:s});let l=s instanceof Error?s:Error(String(s));return e.status=`error`,e.errorText=$f(s,i.strings),e.retryAction=L_(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,d,h,p,m])}}const z_=_.scope(`unread`);function B_(e){let{transport:t,options:n,conversationIdSig:r,isConversationVisibleRef:i,activated:a,conversationReady:o}=e,s=ua(!1),c=ua(0),l=ua(0),u=B([]),d=B(void 0),f=B(!1),p=B(!1),m=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]),h=V(e=>{let t=r.value,n=u.current.find(e=>e.conversationId===t),i=bu(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,m(),o&&(l.value+=1)},[r,m,l]),g=V(()=>{if(m(),!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,m,t]),_=V(e=>{r.value===e&&(d.current=void 0,m())},[r,m]),v=V(e=>{r.value===e&&(d.current=e,g())},[r,g]),y=V(e=>d.current===e,[]),b=V((e=!1)=>{if(!n.history.enabled||!n.modules.list.some(e=>e.layout===`chat`))return;function r(e){f.current?e&&(p.current=!0):(f.current=!0,t.listConversations({limit:50},e).then(t=>{e||h({type:`snapshot`,result:t,requestedRevision:0}),g()}).catch(e=>z_.debug(`refreshUnread failed (non-fatal)`,{err:e})).finally(()=>{f.current=!1,p.current&&(p.current=!1,r(!0))}))}r(e)},[h,g,n.history.enabled,n.modules,t]),x=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]);z(()=>t.subscribeConversationChanges(h),[h,t]);let S=B(!1);return z(()=>{a&&o&&!S.current&&(S.current=!0,b())},[a,o,b]),z(()=>{if(!a)return;function e(){document.visibilityState===`visible`&&(g(),b(!0))}return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[a,g,b]),{hasUnreadSig:s,unreadCountSig:c,transcriptRecoverySig:l,markVisibleConversationRead:g,beginConversationTranscript:_,commitConversationTranscript:v,isConversationTranscriptCommitted:y,recordConversationReply:x,refreshUnread:b}}const V_=_.scope(`settings`);function H_(e){let{options:t,persistence:n,transport:r,feedback:i,hostElement:a,bus:o}=e,s=n.loadUserPrefs(),[c,l]=R(()=>s.locale??t.locale),[u,d]=R(s.themeMode),f=Zn(t.themeMode,u),[p,m]=R(()=>s.textSize??t.textSize),h=V(e=>{n.patchUserPrefs(e),r.saveUserPrefs(n.loadUserPrefs()).catch(e=>V_.warn(`saveUserPrefs failed`,{err:e}))},[n,r]);z(()=>{s.soundMuted!==void 0&&i.setMuted(s.soundMuted)},[]),z(()=>{if(f!==`host`)a.dataset.theme=f;else return Vr(e=>{a.dataset.theme=e})},[a,f,t]),z(()=>{a.dataset.textSize=p},[a,p,t]),z(()=>{let e=!0;return i.mutedSig.subscribe(t=>{e?e=!1:h({soundMuted:t})})},[i,h]);let g=Hn(c,t.availableLocales,t.defaultLocale);return z(()=>{r.setLocale(g)},[r,g]),z(()=>{a.dir=Nt(g)?`rtl`:`ltr`},[a,g]),z(()=>{g!==c&&l(g)},[g,c]),{activeLocale:c,activeThemeMode:f,activeTextSize:p,setActiveLocale:l,setActiveThemeMode:d,setActiveTextSize:m,patchAndSync:h,handleLocaleChange:V(e=>{V_.info(`localeChange`,{locale:e}),l(e),h({locale:e}),o.emit(`localeChange`,e)},[h,o]),handleThemeChange:V(e=>{V_.info(`themeChange`,{mode:e}),d(e),a.dataset.theme=e,h({themeMode:e}),o.emit(`themeChange`,e)},[a,h,o]),handleTextSizeChange:V(e=>{V_.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;V_.info(`soundToggle`,{muted:e}),o.emit(`soundToggle`,{muted:e})},[i,o])}}const $=_.scope(`app`),U_=i.cssPrefix,W_={home:`home`,chats:`chat`,help:`help`,news:`news`};function G_({options:e,hostElement:t,bus:n,recentHostEvents:r,loginRevision:a=0,onPersonChanged:o,onStartAsGuest:s}){let c=e.aiAgentDeploymentId;if(!c)throw Error(`aiAgentDeploymentId is required`);let[l]=R(()=>Dr(e.widgetId,e.storage,e.aiAgentDeploymentId)),[u,d]=R(()=>l.getVisitorId()),f=l.loadUserPrefs(),p=ua(l.loadConversationId()),m=B(p.value!==void 0),h=ua(p.value??``),g=ua([]),_=ua(!1),[v,y]=R(!1),b=B(void 0);function x(){let t=e.modules.list,n=new Set(t.map(e=>e.id)),r=l.loadActiveModule();return r&&n.has(r)?r:t[0]?.id??``}function S(){return e.modules.list.find(e=>e.layout===`chat`)?.id}function C(){let t=S();return t?e.modules.list.length===1||T.sig.value.activeTab===t:!1}let ee=B(void 0);if(!ee.current){let t=e.modules.list.map(e=>e.id),n=l.loadActiveModule()??t[0]??``;ee.current=Yu(n,n?[...t,n]:t,e=>l.saveActiveModule(e))}let T=ee.current,E=da(()=>T.sig.value.activeTab).value,D=da(()=>p.value).value,[O,te]=R(!1),[k,ne]=R(!1),re=e.mode===`standalone`||e.mode===`inline`,ie=B(nd(e,rd(),l.loadPanelOpen(),l.loadPanelSize())),[A,ae]=R(ie.current.panelOpen),[j,oe]=R(ie.current.panelOpen),se=B(void 0),ce=B(void 0),le=B(!1),ue=B(void 0),M=B(e.strings),de=B(void 0);z(()=>{A&&oe(!0)},[A]);let fe=B(!1),[pe,me]=R(!1),he=B(null),ge=B(!1),{dismissed:N,dismissCallout:_e}=e_({callout:e.launcher.callout,persistence:l}),ve=e.launcher.callout?.persistent??!0,ye=V(()=>{$.info(`calloutDismiss`),n.emit(`calloutDismiss`,void 0),_e()},[n,_e]),[be,xe]=R(ie.current.panelSize),Se=B(!1),[Ce,we]=R(`chat`),Te=B(()=>!1);Te.current=()=>A&&Ce===`chat`&&!document.hidden&&C();let[P,Ee]=R(!1),De=B(P);De.current=P;let Oe=B(null),[ke,Ae]=R(!1),je=ua(/* @__PURE__ */ new Map),Me=V((e,t)=>{let n=new Map(je.value);t?n.set(e,t):n.delete(e),je.value=n},[je]),[Ne,F]=R(null),[Pe,Fe]=R(),[Ie,Le]=R([]),Re=B(e);Re.current=e;let[ze,Be]=R(void 0),[Ve,He]=R(void 0),[Ue,We]=R(()=>l.loadSidebarCollapsed()??!1),[Ge,Ke]=R({status:`anonymous`}),[qe,Je]=R({}),[Ye,Xe]=R(),[I]=R(()=>new Du({agentApiBaseUrl:e.agentApiBaseUrl,dataApiBaseUrl:e.dataApiBaseUrl,auth:ha({publicKey:e.publicKey,aiAgentDeploymentId:c,publicKeyHeader:`x-public-key`}),endpoints:e.endpoints,recentHostEvents:r,onLoginState:Ke,continueLink:e.continueLink})),[Ze]=R(()=>new La(e.sound,e.haptics)),Qe=A_({transport:I,setStreaming:Ee}),{activeLocale:L,activeThemeMode:$e,activeTextSize:et,setActiveLocale:tt,setActiveThemeMode:nt,setActiveTextSize:rt,patchAndSync:it,handleLocaleChange:at,handleThemeChange:ot,handleTextSizeChange:st,handleSoundToggle:ct}=H_({options:e,persistence:l,transport:I,feedback:Ze,hostElement:t,bus:n}),{controlModeSig:lt,assignedOperatorSig:ut,operatorAvailableSig:dt,applyControlState:ft,adoptControlStateChunk:pt,requestOperator:mt,cancelOperatorRequest:ht}=a_({transport:I,conversationIdSig:p}),gt=ua(/* @__PURE__ */ new Map),_t=V(e=>{if(e.type!==`data-memory-compaction-state`)return;let t=p.value;if(!t)return;let n=il(e.data);if(!n)return;let r=gt.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(gt.value);i.set(t,n),gt.value=i},[p,gt]),{hasUnreadSig:vt,unreadCountSig:yt,transcriptRecoverySig:bt,markVisibleConversationRead:xt,beginConversationTranscript:St,commitConversationTranscript:Ct,isConversationTranscriptCommitted:wt,recordConversationReply:Tt,refreshUnread:Et}=B_({transport:I,options:e,conversationIdSig:p,isConversationVisibleRef:Te,activated:j,conversationReady:O}),Ot=i_({state:Ge,deployment:qe,bus:n,persistence:l,conversationIdSig:p}),kt=A&&e.modules.byId[E]?.layout===`home`,At=$g({transport:I,options:e,persistence:l,enabled:O&&kt});z(()=>{xt()},[E,A,Ce,D,xt]),z(()=>{Ze.update(e.sound,e.haptics)},[Ze,e.sound,e.haptics]),z(()=>()=>Ze.destroy(),[Ze]),z(()=>{!Se.current&&e.size.initialSize&&(Se.current=!0,l.loadPanelSize()||xe(td(e.mode,e.size,rd())))},[e.mode,e.size,l]),z(()=>{if(!O||fe.current)return;fe.current=!0;let t=nd(e,rd(),l.loadPanelOpen(),l.loadPanelSize());ae(t.panelOpen),xe(t.panelSize)},[O,e,l]);let jt=B(null);z(()=>{O&&T.reconcile(e.modules.list.map(e=>e.id),x())},[O,e.modules.list,T]);let Mt=V(e=>{e&&e.length!==0&&(g.value=e.map(e=>dl({...e,text:Pt(M.current,e.text)})))},[g]),Nt=B(0),Ft=B(0),It=V(e=>{if(e===p.value)return;let t=p.value;Ft.current++,y(!1),t&&(l.saveDraft(e,l.loadDraft(t)),l.saveDraft(t,``),l.saveMessageQueue(e,l.loadMessageQueue(t)),l.saveMessageQueue(t,[])),p.value=e,l.saveConversationId(e),I.primeIdentity(void 0,e),$.info(`conversation rebound`,{previous:t,current:e}),t&&n.emit(`conversationRebound`,{previous:t,current:e})},[n,p,l,I]),Lt=V(e=>{let t=e.map(e=>e.createdAt).filter(e=>e!==void 0),n=(t.length?Math.min(...t):Date.now())-1;return[...(ue.current?.messages??[]).map(e=>{let t=dl({...e,text:Pt(M.current,e.text)});return t.createdAt=n,t}),...e]},[]),Rt=V(async e=>{let t=Ft.current;function r(){return t!==Ft.current||p.value!==e}ce.current===e&&(ce.current=void 0),y(!0);try{let t=await I.loadConversation(e);if(r())return!1;let n=yl(t.messages),i=Lt(Vl(n,g.value));if(g.value=i,ce.current=i.some(e=>e.role===`user`)?void 0:e,n.length>0||t.controlState!==void 0){Fe({conversationId:e,reference:t.ticketReference}),t.controlState&&ft(t.controlState);let r=n.findLast(e=>e.role===`assistant`&&!e.ephemeral);Le(r?.suggestions??[])}return!0}catch(t){return r()||($.warn(`loadThread failed; keeping conversation active`,{err:t,conversationId:e}),n.emit(`error`,t),Re.current.onError?.(t)),!1}finally{r()||y(!1)}},[I,g,p,Lt,n]),zt=V(e=>{if(se.current===e)return se.current=void 0,Rt(e)},[Rt]),Bt=V(()=>{if(b.current)return Promise.resolve(void 0);let t=p.value,r=g.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=Ft.current,s={};return b.current=s,(async()=>{try{let e=await I.loadConversation(t,{beforeId:i,beforeCreatedAt:a});if(b.current!==s||Ft.current!==o||p.value!==t)return;if(e.messages.length===0)return!1;let n=e.messages.map(ml),r=g.value,c=Pl(r,n);if(c!==r){let e=Math.min(...n.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)}g.value=c}return!0}catch(r){if(b.current!==s||Ft.current!==o||p.value!==t)return;$.warn(`load previous messages failed`,{err:r,conversationId:t,beforeId:i}),n.emit(`error`,r),e.onError?.(r);return}finally{b.current===s&&(b.current=void 0)}})()},[n,p,g,e,I]),Vt=V(async({newConversation:t})=>{let r=++Nt.current;function i(){return r!==Nt.current}if(!t){let e=await I.userSub(),t=l.loadLastUserSub();if(i())return;if(t&&t!==e){o?.();return}e&&l.saveLastUserSub(e)}let a=p.value,s=t||!a?wr():a;s!==a&&(Ft.current++,y(!1),Mi(()=>{p.value=s,h.value=s}),l.saveConversationId(s)),I.primeIdentity(u,s);let c;try{c=await I.handshake({visitorId:u,conversationId:s,userPrefs:l.loadUserPrefs(),locale:L})}catch(r){if(i())return;n.emit(`error`,r),e.onError?.(r);let a=r instanceof ru&&r.errorCode?q_[r.errorCode]:void 0;if(a){$.warn(`the widget is not shown: ${a}`),(re||e.mode===`page`)&&ne(!0);return}t||te(!0);return}if(i())return;e.continueLink&&c.visitorId!==u&&d(c.visitorId),c.conversationId!==s&&It(c.conversationId),de.current=c;let f=Dt(c,L);F(f.agent),Je(Va(c.config?.login));let g=c.config?.maxMessageCharacters;Xe(typeof g==`number`&&g>0?g:void 0),f.site&&za(f.site)?Be(f.site):f.site&&$.warn(`invalid site config, using fallback`,{site:f.site}),f.blocks&&Ba(f.blocks)?He(f.blocks):f.blocks&&$.warn(`invalid blocks config, using fallback`,{blocks:f.blocks});let _=Ar(c.userPrefs);if(Object.keys(_).length>0&&!t&&(l.saveUserPrefs(_),_.locale&&tt(_.locale),_.soundMuted!==void 0&&Ze.setMuted(_.soundMuted),_.themeMode&&nt(_.themeMode),_.textSize&&rt(_.textSize)),ue.current=f.welcome,t||n.emit(`handshake`,c),f.welcome?.suggestions){let e=M.current;Le(f.welcome.suggestions.map(t=>({...t,label:Pt(e,t.label),...t.text===void 0?{}:{text:Pt(e,t.text)}})))}let v=!t&&(c.conversationId===a||e.continueLink!==void 0);m.current=v,v?le.current||(se.current=c.conversationId):(ce.current=c.conversationId,Mt(f.welcome?.messages),Ct(c.conversationId)),t||te(!0)},[I,u,l,e,n,p,h,Ze,Mt,L,It,Ct,o]),Ht=JSON.stringify(e.userContext??null);z(()=>{I.setContext(e.userContext,K_(e.pageContext))},[I,Ht,JSON.stringify(e.pageContext??null)]);let Ut=B(!1);z(()=>{I.setUserToken(e.userToken),Ut.current?Vt({newConversation:!1}).then(()=>{j&&Et(!0)}):Ut.current=!0},[I,e.userToken,a]);let Wt=V((e,t=[])=>Le(e.suggestions??t),[]);z(()=>(I.primeIdentity(u,p.value),Vt({newConversation:!1}),()=>{Nt.current++,Ft.current++}),[]),z(()=>{j&&O&&!le.current&&(le.current=!0,se.current===p.value&&y(!0))},[j,O]);let Gt=B(Ht);z(()=>{O&&Gt.current!==Ht&&(Gt.current=Ht,Vt({newConversation:!1}))},[Ht,O,Vt]);let Kt=B(async()=>!1),{sendAiTurn:qt,sendRoutedTurn:Jt}=R_({onConversationNotFound:e=>Kt.current(e),transport:I,messagesSig:g,conversationIdSig:p,options:e,bus:n,feedback:Ze,persistence:l,visitorId:u,adoptConversationId:It,applyControlState:ft,setTicket:Fe,settleSuggestions:Wt,runCancellation:Qe}),{toolInteraction:Yt,pageToolsRunning:Xt,stopPageTools:Zt}=Zg({streaming:P,controlModeSig:lt,messagesSig:g,sendAiTurn:qt,bus:n,humanInLoop:e.features.humanInLoop,tools:e.tools}),Qt=V((e,t)=>{let r=g.value.find(t=>t.serverMessageId===e);r&&(r.feedback=t),$.info(`messageFeedback`,{messageId:e,value:t}),n.emit(`messageFeedback`,{messageId:e,value:t}),I.submitFeedback({messageId:e,value:t})},[n,g,I]),$t=V(()=>m.current||g.value.some(e=>!e.ephemeral&&e.role===`user`),[g]);k_({activated:j,conversationReady:O,paused:Ge.status===`pending`||Ge.status===`expired`,conversationIdSig:p,messagesSig:g,optionsRef:Re,transport:I,visitorId:u,adoptControlStateChunk:pt,adoptMemoryCompactionStateChunk:_t,settleSuggestions:Wt,recordConversationReply:Tt,transcriptRecoverySig:bt,beginConversationTranscript:St,commitConversationTranscript:Ct,runCancellation:Qe,feedback:Ze,bus:n,loadInitialThread:zt,shouldReconcileOnConnect:$t,reconnectingSig:_});let en=V(async(t,r,i)=>{if(Oe.current||Ot.gate)return!1;let a=p.value,o=a?gt.value.get(a):void 0,s=lt.value!==`ai-agent`;if(!s&&o?.status===`compacting`||($.info(`send`,{textLen:t.length,attachments:r.length,streaming:De.current,routedToOperator:s}),De.current&&!s))return!1;let c=new AbortController,l={conversationId:a,controller:c};Oe.current=l,Ae(!0);try{Ze.unlock(),je.value=/* @__PURE__ */ new Map;let o=await X_(I,r,c.signal,Me,t=>{c.signal.aborted||($.warn(`upload failed`,{err:t}),n.emit(`error`,t),e.onError?.(t))});if(c.signal.aborted||p.value!==a)return!1;let s=a?gt.value.get(a):void 0,l=lt.value!==`ai-agent`;if(!l&&s?.status===`compacting`||De.current&&!l||!i&&o.length<r.length||!t&&o.length===0)return!1;n.emit(`send`,{text:t,attachmentCount:r.length}),Ie.length>0&&Le([]),Ze.play(`messageSent`);let u=ll(t,o,i);return Ku(n,e,`user`,t),l?(g.value=[...g.value,u],i?await Jt(u):(Jt(u),!0)):(g.value=[...g.value,u,ul()],i?await qt({continueExisting:!1}):(qt({continueExisting:!1}),!0))}finally{Oe.current===l&&(Oe.current=null,Ae(!1))}},[I,n,e,Ie.length,g,p,gt,qt,Jt,lt,je,Me,Ot.gate]),tn=B(en);tn.current=en;let nn=p.value,rn=(nn?gt.value.get(nn):void 0)?.status===`compacting`,an=lt.value===`ai-agent`,on=da(()=>{let e=g.value.at(-1);return e?.role===`assistant`&&e.partsSig.value.some(e=>e.kind===`tool`&&(e.stateSig.value===`approval-requested`||e.stateSig.value===`approval-responded`))}),sn=da(()=>g.value.some(e=>e.retryAction?.kind===`resend-user`||e.retryAction?.kind===`continue-assistant`));yi(()=>{let e=p.value;return()=>{let t=Oe.current;t&&t.conversationId===e&&(Oe.current=null,Ae(!1),t.controller.abort())}},[p.value]);let cn=V(()=>{if(Oe.current){$.info(`stop uploads`),Oe.current.controller.abort();return}if(Xt){$.info(`stop page tools`),n.emit(`stop`,void 0),Zt();return}if(!Qe.stop())return;$.info(`stop`),n.emit(`stop`,void 0);let e=g.value.at(-1);e&&e.role!==`user`&&e.status===`streaming`&&(e.canceled=!0,g.value=[...g.value])},[Qe,n,g,Xt,Zt]),ln=V(e=>{$.info(`card action`,{text:e}),tn.current(e,[])},[]),un=V(e=>{if(P)return;let t=g.value,n=Yl(t,e);if(n)switch($.info(`retry`,{kind:n.kind,messageId:n.messageId}),n.kind){case`continue-assistant`:if(lt.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,g.value=[...t],qt({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&&jt.current?.acceptQueuedMessage(n.messageId)};if(r.status=`complete`,r.errorText=void 0,r.retryAction=void 0,lt.value!==`ai-agent`){g.value=e.role===`assistant`?t.filter(t=>t!==e):[...t],Jt(r).then(i);return}let a=ul();g.value=e.role===`assistant`?t.map(t=>t===e?a:t):[...t,a],qt({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=ll(Sl(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]),lt.value!==`ai-agent`){g.value=[...t,r],Jt(r);return}g.value=[...t,r,ul()],qt({continueExisting:!1,turn:r});return}default:return n}},[P,g,lt,qt,Jt]),dn=V(()=>{Gu(e.mode,be)===`exit-fullscreen`?($.info(`close → exit-fullscreen`,{mode:e.mode}),xe(`normal`),n.emit(`fullscreen`,!1)):($.info(`close → panel closed`,{mode:e.mode}),ge.current=t.contains(t.ownerDocument.activeElement),ae(!1),l.savePanelOpen(!1),n.emit(`close`,void 0),e.onClose?.())},[n,e,l,be,t]);l_({hostElement:t,mode:e.mode,panelSize:be,isOpen:A,surfaceReady:O,onClose:dn}),z(()=>{!A&&ge.current&&(ge.current=!1,he.current?.focus())},[A]);let fn=V(()=>{$.info(`open`,{mode:e.mode}),Ze.unlock(),me(!0),ae(!0),l.savePanelOpen(!0),!N&&!ve&&ye(),setTimeout(()=>me(!1),J_),n.emit(`open`,void 0),e.onOpen?.()},[n,e,Ze,l,N,ve,ye]),pn=V(()=>{let e=g.value.some(e=>e.role===`user`);if(ce.current===p.value&&!e&&p.value)$.info(`clear → reusing empty conversation`,{conversationId:p.value}),g.value.length===0&&Mt(ue.current?.messages);else return $.info(`clear → new conversation`,{wasStreaming:P}),n.emit(`clear`,void 0),Qe.settle(),m.current=!1,se.current=void 0,ce.current=void 0,Mi(()=>{g.value=[],p.value=void 0,ft({controlMode:`ai-agent`,controlRevision:0})}),l.clearConversation(),Le([]),Vt({newConversation:!0})},[P,g,p,l,Vt,n,Mt,Qe,ft]);Kt.current=async e=>($.info(`conversation not found → new conversation`,{messageId:e.id}),await pn(),e.status=`complete`,e.errorText=void 0,e.retryAction=void 0,g.value=[...g.value,e,ul()],qt({continueExisting:!1,turn:e,movedFromConversation:!0}));let mn=V(()=>{let t=pn();we(`chat`);let n=e.modules.list.find(e=>e.layout===`chat`)?.id;return n&&T.switchTab(n),t},[pn,T,e]),hn=V(async e=>{await mn(),await tn.current(e,[])||jt.current?.fill(e)},[mn]),gn=V(()=>{let e=be===`expanded`?`normal`:`expanded`;$.info(`expand`,{from:be,expanded:e===`expanded`}),xe(e),l.savePanelSize(e),n.emit(`expand`,e===`expanded`)},[n,be,l]),_n=V(()=>{let e=be===`fullscreen`?`normal`:`fullscreen`;$.info(`fullscreen`,{from:be,fullscreen:e===`fullscreen`}),xe(e),l.savePanelSize(e),n.emit(`fullscreen`,e===`fullscreen`)},[n,be,l]),vn=V(()=>{we(e=>{let t=e===`history`?`chat`:`history`;return $.info(`toggleHistory`,{view:t}),n.emit(`toggleHistory`,{view:t}),t})},[n]),yn=V(()=>{We(e=>{let t=!e;return $.info(`sidebarToggle`,{collapsed:t}),l.saveSidebarCollapsed(t),n.emit(`sidebarToggle`,{collapsed:t}),t})},[l,n]),bn=V(e=>{$.info(`resize`,e),it({widgetSize:e}),n.emit(`resize`,e)},[it,n]),xn=V(async t=>{let r=t.conversationId;if(r===p.value&&wt(r)){$.info(`selectConversation`,{conversationId:r,cached:!0}),n.emit(`selectConversation`,{conversationId:r}),I.publishConversation(t),we(`chat`);let e=S();e&&T.switchTab(e),Ct(r);return}let i=++Nt.current;Ft.current++,y(!1);function a(){return i!==Nt.current}$.info(`selectConversation`,{conversationId:r,wasStreaming:P}),n.emit(`selectConversation`,{conversationId:r}),I.publishConversation(t);try{let e=await I.loadConversation(r);if(a())return;Qe.settle(),m.current=!0,se.current=void 0;let t=yl(e.messages),n=e.conversationId!==p.value,i=n?t:Vl(t,g.value);ce.current=i.some(e=>e.role===`user`)?void 0:e.conversationId,Mi(()=>{g.value=Lt(i),n&&(h.value=e.conversationId),p.value=e.conversationId}),l.saveConversationId(e.conversationId),I.primeIdentity(u,e.conversationId),Fe({conversationId:e.conversationId,reference:e.ticketReference}),e.controlState&&ft(e.controlState);let o=i.findLast(e=>e.role===`assistant`&&!e.ephemeral);Le(o?.suggestions??[]),n?St(e.conversationId):Ct(e.conversationId),we(`chat`);let s=S();s&&T.switchTab(s)}catch(t){if(a())return;n.emit(`error`,t),e.onError?.(t)}},[I,g,p,h,n,e,l,Lt,P,u,Qe,St,Ct,wt,T]),Sn=B(void 0),Cn=V(t=>{let n=e.modules.list.find(e=>e.layout===W_[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;T.open(n.id,r)},[e.modules,T]),wn=V(e=>{A||fn(),e!=null&&(_a(e)?O?Cn(e):Sn.current=e:$.warn(`open: unknown target`,{detail:e}))},[A,fn,O,Cn]);z(()=>{O&&Sn.current&&(Cn(Sn.current),Sn.current=void 0)},[O,Cn]);let Tn=O&&!v&&(!an||!sn.value),[En,Dn]=R(),On=V(e=>{let t=ba(e);t?(A||fn(),Dn(t)):$.warn(`ask: expected { text, send? } with non-empty text`,{detail:e})},[A,fn]),kn=A&&O&&!v,An=kn&&Tn&&!ke&&!(an&&(P||rn));z(()=>{if(En===void 0||!(En.send?An:kn))return;let e=S();e?Ce!==`chat`||!C()?(we(`chat`),T.switchTab(e)):(Dn(void 0),En.send?en(En.text,[]).then(e=>{e||jt.current?.fill(En.text)}):jt.current?.fill(En.text)):($.warn(`ask: the widget has no chat`),Dn(void 0))},[En,kn,An,Ce,E,e.modules,T,en]),z(()=>{if(e.widgetId!=="default")return;let n=`data-${i.cssPrefix}-`,r=[`ask`,`open`,`close`].map(e=>n+e);function a(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`);a===null?o===null?Sa(t,`close`):Sa(t,`open`,va(o)):Sa(t,`ask`,ya(a||(i.textContent??``),{send:i.hasAttribute(`${n}send`)}))}return document.addEventListener(`click`,a),()=>document.removeEventListener(`click`,a)},[e.widgetId,t]),z(()=>{if(e.widgetId!=="default")return;let n=Ta(location.href);n&&(history.replaceState(history.state,``,n.url),n.ask?Sa(t,`ask`,ya(n.ask)):Sa(t,`open`,n.target))},[e.widgetId,t]);let jn=B(w),Mn=e.mode===`page`||e.mode===`inline`||e.mode===`standalone`;z(()=>ea(()=>{let e=p.value,t={open:Mn||A,ready:O,unread:yt.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,A,O,yt,p]);let Nn=B({handleOpenCommand:wn,handleClose:dn,handleExpand:gn,handleFullscreen:_n,handleAskCommand:On});Nn.current={handleOpenCommand:wn,handleClose:dn,handleExpand:gn,handleFullscreen:_n,handleAskCommand:On},yi(()=>Ca(t,{open:e=>Nn.current.handleOpenCommand(e),close:()=>Nn.current.handleClose(),expand:()=>Nn.current.handleExpand(),fullscreen:()=>Nn.current.handleFullscreen(),ask:e=>Nn.current.handleAskCommand(e)}),[t]);let Pn=bi(()=>Qn(e,L,$e,et),[e,L,$e,et]);M.current=Pn.strings,z(()=>{let e=de.current;if(!e?.translations?.length)return;let t=Dt(e,L);F(t.agent),t.site&&za(t.site)&&Be(t.site),t.blocks&&Ba(t.blocks)&&He(t.blocks)},[L]);function Fn(e){xn(e)}let In={options:Pn,transport:I,feedback:Ze,bus:n,persistence:l,conversationId:p.value??``,composerKey:h.value,composerApiRef:jt,view:Ce,isStreaming:P,pageToolRunning:Xt,isMemoryCompacting:rn,canReleaseQueuedMessages:Tn,queueManualMessages:an&&sn.value,replyAwaitsCard:an&&on.value,sendPreparing:ke,attachmentUploadsSig:je,composerActive:Pn.mode===`page`||Pn.mode===`inline`||Pn.mode===`standalone`||A,controlMode:lt.value,assignedOperator:ut.value,operatorAvailable:dt.value,operatorRequestEnabled:e.features.operatorRequest,onRequestOperator:mt,onCancelOperatorRequest:ht,loadingMessages:v,onLoadPreviousMessages:Bt,messagesSig:g,reconnectingSig:_,agent:Ne,ticketReference:Pe?.conversationId===p.value?Pe?.reference:void 0,login:Ot,onStartAsGuest:s,maxMessageCharacters:Ye,suggestions:Ie,initialWidgetSize:f.widgetSize??null,onClear:pn,onExpand:gn,onFullscreen:_n,onSoundToggle:ct,onToggleHistory:vn,onSelectHistoryConversation:Fn,onNewConversation:mn,onLocaleChange:at,onThemeChange:ot,onTextSizeChange:st,onWidgetSizeChange:bn,onSend:en,onStop:cn,onSuggestion:t=>{if(Oe.current)return;let r=t.text??t.label;$.info(`suggestion`,{text:r,autoSend:e.autoSendSuggestions}),n.emit(`suggestion`,{text:r}),e.autoSendSuggestions?en(r,[]):jt.current?.fill(r)},tool:Yt,onRetry:un,onMessageFeedback:Qt,onCardAction:ln};if(k)return/* @__PURE__ */ U(`div`,{class:`${U_}-anchor`,children:/* @__PURE__ */ U(Kg,{strings:Pn.strings,text:Pn.strings.chatUnavailable})});if(!O)return null;let Ln=Pn.modules.list;function Rn(e){let t=Uu(`close`,Pn.mode,e)?dn:void 0;return Ln.length===0?/* @__PURE__ */ U(Kg,{strings:Pn.strings,text:Pn.strings.modulesEmpty,onClose:t}):Ln.length===1&&Ln[0]?.layout===`chat`?/* @__PURE__ */ U(Tg,{...In,panelSize:e,onClose:t}):/* @__PURE__ */ U(Lg,{panelProps:{...In,panelSize:e,onClose:t},enabledModules:Ln,nav:T,bus:n,hasUnread:vt.value,latestNews:At,onSelectConversation:Fn,onStartNewConversation:hn,onSetPanelSize:xe})}if(e.mode===`page`){let t=e.history.enabled&&Ln.some(e=>e.layout===`chat`);return/* @__PURE__ */ U(`div`,{class:`${U_}-anchor`,children:/* @__PURE__ */ U(Wg,{site:ze,blocks:Ve,transport:I,strings:Pn.strings,locale:Pn.locale,persistence:l,showConversations:t,onSelectConversation:Fn,onNewConversation:mn,sidebarCollapsed:Ue,onToggleSidebarCollapsed:yn,children:Rn(`fullscreen`)})})}if(re){let t=e.mode===`standalone`?`fullscreen`:be;return/* @__PURE__ */ U(`div`,{class:`${U_}-anchor`,children:Rn(t)})}let zn=e.mode===`drawer`,Bn=e.mode!==`modal`&&!e.launcher.hidden&&(!A||pe),Vn=Bn&&!pe&&!N&&!zn?Pn.launcher.callout:null;return/* @__PURE__ */ U(`div`,{class:`${U_}-anchor`,"data-launcher-size":Pn.launcher.size,children:[A||j?/* @__PURE__ */ U(`div`,{class:`${U_}-surface`,hidden:!A,children:Rn(be)}):null,Bn?/* @__PURE__ */ U(ff,{buttonRef:he,onToggle:fn,launcher:Pn.launcher,strings:Pn.strings,leaving:pe,edgeTab:zn}):null,Vn?/* @__PURE__ */ U(_f,{callout:Vn,launcherPosition:Pn.position,strings:Pn.strings,closeLabel:Pn.strings.close,onDismiss:ye}):null]})}function K_(e){let t=e?.url??(typeof location<`u`?location.href:void 0);if(e||t)return{...e,...t?{url:t}:{}}}const q_={AI_AGENT_PUBLIC_ACCESS_NOT_FOUND:`the deployment was not found or is turned off`,AI_AGENT_PUBLIC_ORIGIN_NOT_ALLOWED:`this website is not in the deployment's allowed origins`},J_=120,Y_=/* @__PURE__ */ new WeakMap;async function X_(e,t,n,r,i){return(await Promise.all(t.map(async t=>{try{r(t.id,{status:`uploading`});let i=Y_.get(t)??await e.uploadFile(t.file,n,e=>r(t.id,{status:`uploading`,fraction:e}));return Y_.set(t,i),r(t.id,{status:`done`}),{id:i.id,name:i.originalName,mediaType:i.mimeType,size:i.fileSize,url:i.url}}catch(e){r(t.id,n.aborted?void 0:{status:`error`,refusal:e instanceof ru&&e.status===400?e.errorCode:void 0}),i(e);return}}))).filter(e=>e!==void 0)}const Z_=_.scope(`error-boundary`);var Q_=class extends $e{constructor(...e){super(...e),S(this,`state`,{crashed:!(`toSorted`in Array.prototype)})}componentDidCatch(e,t){Z_.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 $_(e){let{bus:t,host:n,appRoot:r,persistence:i,reportError:a}=e,o=e.initialRaw,s,c,l=zn(o),u=i.loadUserPrefs().locale??l.locale,d=!0,f=0,p=0,m=Cr(t);function h(){let e=s&&Dt({config:s,translations:c},u).config;l=zn(e?tr(o,e):o)}function g(){Gr(n,Kr(l.mode)),ti(n,{...l,themeMode:Zn(l.themeMode,i.loadUserPrefs().themeMode)}),d&&(ei(n,ev(l)),d=!1)}function _(){g(),xt(Ze(Q_,{onError:a},Ze(G_,{key:f,bus:t,hostElement:n,options:l,recentHostEvents:m,loginRevision:p,onPersonChanged:b,onStartAsGuest:x})),r)}t.on(`handshake`,e=>{e.config&&(e.config.storageVersion&&i.rememberStorageVersion(e.config.storageVersion),s=e.config,c=e.translations,h(),_())}),t.on(`localeChange`,e=>{u=e,c?.length&&(h(),_())});let v=Ir(t,{getOptions:()=>l,getVisitorId:()=>i.getVisitorId(),getConversationId:()=>i.loadConversationId()});function y(){let e=i.takeLoginReturn();return e?(i.saveConversationId(e.conversationId),i.saveDraft(e.conversationId,e.draft),i.savePanelOpen(!0),!0):!1}o.userToken&&y();function b(){i.reset(),m.length=0,f+=1,d=!0,h(),_()}function x(){o={...o,userContext:void 0,userToken:void 0},b()}function S(e){`userToken`in e&&e.userToken&&!o.userToken&&y()&&(f+=1),o={...o,...e},h(),_()}return{getOptions:()=>l,getUserOptions:()=>o,render:_,setUserOptions:e=>{o=e,h(),_()},patchUserOptions:S,login:e=>{p+=1,S({userToken:e})},reset:()=>x(),destroy:()=>v()}}function ev(e){if(e.mode===`standalone`)return`standalone`;if(e.mode===`inline`)return`inline`;let t=Dr(e.widgetId,e.storage,e.aiAgentDeploymentId),{panelOpen:n,panelSize:r}=nd(e,rd(),t.loadPanelOpen(),t.loadPanelSize());return ed(e.mode,r,n)}const tv=_.scope(`hooks`),nv=`*`,rv=/* @__PURE__ */ new Set;function iv(e,t,n){let r={widgetId:e,event:t,listener:n};return rv.add(r),()=>{rv.delete(r)}}function av(e,t,n){let r=[...rv];for(let i of r)if(sv(i.widgetId,e.widgetId)&&(i.event===`*`||i.event===t))try{i.listener(e,t,n)}catch(e){tv.warn(`hook listener threw`,{event:t,error:e})}}function ov(e,t){return t.tap({hear:(t,n)=>av(e,t,n),listensTo:t=>[...rv].some(n=>n.event===t&&sv(n.widgetId,e.widgetId))})}function sv(e,t){return e===`*`||e===t}const cv=/* @__PURE__ */ new Map;function lv(e){if(!e.aiAgentDeploymentId)throw Error(`aiAgentDeploymentId is required`);e.debug!==void 0&&m(e.debug);let t=_.scope(`mount`);t.info(`mount`,{widgetId:e.widgetId,publicKey:e.publicKey,mode:e.presentation?.mode});let n=zn(e),r=n.widgetId,i=cv.get(r);i&&(t.debug(`destroy existing instance at slot`,{widgetId:r}),i.destroy());let a=qr({position:Kr(n.mode),target:e.target??null});a.hostElement.dataset.widgetId=r;let o=new ee,s=Dr(r,n.storage,n.aiAgentDeploymentId);function c(e){o.emit(`error`,e),l.getOptions().onError?.(e)}let l=$_({bus:o,host:a.hostElement,appRoot:a.appRoot,persistence:s,initialRaw:e,reportError:c}),u=w,d=()=>{},f=new Promise(e=>{d=e});o.on(`state`,e=>{u=e,e.ready&&d()}),l.render();let p=a.hostElement,g=null;function y(e){e.debug!==void 0&&m(e.debug),l.patchUserOptions(e)}let b={widgetId:r,open:e=>Sa(p,`open`,e),close:()=>Sa(p,`close`),expand:()=>Sa(p,`expand`),ask:(e,t)=>Sa(p,`ask`,ya(e,t)),on:(e,t)=>o.on(e,t),update:e=>{t.debug(`update`,{patch:e}),y(e)},setUserContext:e=>{t.debug(`setUserContext`,{keys:Object.keys(e)}),y({userContext:{...l.getUserOptions().userContext,...e}})},clearUserContext:()=>{t.debug(`clearUserContext`),y({userContext:void 0})},setPageContext:e=>{t.debug(`setPageContext`,{keys:Object.keys(e)}),y({pageContext:{...l.getUserOptions().pageContext,...e}})},clearPageContext:()=>{t.debug(`clearPageContext`),y({pageContext:void 0})},get state(){return u},ready:f,reset:()=>{t.info(`reset`,{widgetId:r}),l.reset()},login:e=>{t.info(`login`,{widgetId:r}),l.login(e)},track:(e,t)=>{let n=Sr(e,t);n&&o.emit(`hostEvent`,n)},registerTool:ye,setDebug:e=>{m(e),t.info(`debug level set`,{level:h()})},debugLevel:()=>h(),onLog:e=>v(e),destroy:()=>{t.info(`destroy`,{widgetId:r}),o.emit(`state`,w),g?.(),l.destroy(),o.clear(),xt(null,a.appRoot),a.destroy(),cv.get(r)===b&&cv.delete(r)}};return g=ov(b,o),cv.set(r,b),b}function uv(e){if(!e.aiAgentDeploymentId)throw Error(`aiAgentDeploymentId is required`);let t=e.widgetId??`default`,n=cv.get(t);return n?(n.update(e),n):lv(e)}function dv(e){if(e!==void 0){cv.get(e)?.destroy();return}let t=[...cv.values()];for(let e of t)e.destroy()}function fv(e=`default`){return cv.get(e)??null}function pv(){return[...cv.values()]}const mv=jr,hv=i,gv=/* @__PURE__ */ new WeakMap;let _v=0;function vv(e){if(typeof e!=`function`)return e;let t=gv.get(e)??++_v;return gv.set(e,t),`function#${t}`}function yv(t){let r=n(t);r.current=t;let i=t.widgetId??`default`,a=JSON.stringify({...t,userToken:vv(t.userToken)});return e(()=>()=>dv(i),[i]),e(()=>{uv({...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 bv(e=`default`){return{state:r(t=>iv(e,`state`,t),()=>fv(e)?.state??w,()=>w),...t(()=>({ask:(t,n)=>fv(e)?.ask(t,n),open:t=>fv(e)?.open(t),close:()=>fv(e)?.close(),reset:()=>fv(e)?.reset(),track:(t,n)=>fv(e)?.track(t,n)}),[e])}}function xv(t){let r=n(t);r.current=t;let i=JSON.stringify(t);e(()=>{let e=new AbortController,t=r.current.preview?{preview:e=>r.current.preview?.(e)}:{};return ye({...r.current,...t,execute:(e,t)=>r.current.execute(e,t)},{signal:e.signal}),()=>e.abort()},[i])}export{nv as HOOK_WILDCARD,yv as HelpAI,hv as brand,dv as destroy,pv as getAllInstances,fv as getInstance,iv as hook,uv as init,lv as mount,ev as resolveInitialHostMode,bv as useHelpAI,xv as useHelpAITool,mv as version};
73
73
  //# sourceMappingURL=react.mjs.map