@squadico/chatbot 1.5.2 → 1.6.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.
@@ -1,13 +1,13 @@
1
- var Chatbot=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h={},g=[],_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,v=Array.isArray;function y(e,t){for(var n in t)e[n]=t[n];return e}function b(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function x(e,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?t.call(arguments,2):r),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return S(e,s,i,a,null)}function S(e,t,i,a,o){var s={type:e,props:t,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++r,__i:-1,__u:0};return o==null&&n.vnode!=null&&n.vnode(s),s}function C(e){return e.children}function w(e,t){this.props=e,this.context=t}function T(e,t){if(t==null)return e.__?T(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?T(e):null}function E(e){if(e.__P&&e.__d){var t=e.__v,r=t.__e,i=[],a=[],o=y({},t);o.__v=t.__v+1,n.vnode&&n.vnode(o),L(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[r]:null,i,r??T(t),!!(32&t.__u),a),o.__v=t.__v,o.__.__k[o.__i]=o,R(i,o,a),t.__e=t.__=null,o.__e!=r&&D(o)}}function D(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),D(e)}function O(e){(!e.__d&&(e.__d=!0)&&i.push(e)&&!k.__r++||a!=n.debounceRendering)&&((a=n.debounceRendering)||o)(k)}function k(){try{for(var e,t=1;i.length;)i.length>t&&i.sort(s),e=i.shift(),t=i.length,E(e)}finally{i.length=k.__r=0}}function A(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,_,v,y=r&&r.__k||g,b=t.length;for(c=j(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||h,p.__i=d,v=L(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&ne(f.ref,null,p),u.push(p.ref,p.__c||m,p)),_==null&&m!=null&&(_=m),4&p.__u?(c=M(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=_,c}function j(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=S(null,o,null,null,null):v(o)?o=e.__k[a]=S(C,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=S(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=N(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=T(s)),re(s,s));return r}function M(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=M(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=T(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function N(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function P(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||_.test(t)?n:n+`px`}function F(e,t,n,r,i){var a,o;n: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||P(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||P(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(d,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n[u]=r[u]:(n[u]=f,e.addEventListener(t,a?m:p,a)):e.removeEventListener(t,a?m:p,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function I(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t[l]==null)t[l]=f++;else if(t[l]<r[u])return;return r(n.event?n.event(t):t)}}}function L(e,t,r,i,a,o,s,c,l,u){var d,f,p,m,h,_,x,S,E,D,O,k,j,M,N,P,F=t.type;if(t.constructor!==void 0)return null;128&r.__u&&(l=!!(32&r.__u),o=[c=t.__e=r.__e]),(d=n.__b)&&d(t);n:if(typeof F==`function`){f=s.length;try{if(E=t.props,D=F.prototype&&F.prototype.render,O=(d=F.contextType)&&i[d.__c],k=d?O?O.props.value:d.__:i,r.__c?S=(p=t.__c=r.__c).__=p.__E:(D?t.__c=p=new F(E,k):(t.__c=p=new w(E,k),p.constructor=F,p.render=ie),O&&O.sub(p),p.state||(p.state={}),p.__n=i,m=p.__d=!0,p.__h=[],p._sb=[]),D&&p.__s==null&&(p.__s=p.state),D&&F.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=y({},p.__s)),y(p.__s,F.getDerivedStateFromProps(E,p.__s))),h=p.props,_=p.state,p.__v=t,m)D&&F.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),D&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(D&&F.getDerivedStateFromProps==null&&E!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(E,k),t.__v==r.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(E,p.__s,k)){t.__v!=r.__v&&(p.props=E,p.state=p.__s,p.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(e){e&&(e.__=t)}),g.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&s.push(p),c=T(r);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(E,p.__s,k),D&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,_,x)})}if(p.context=k,p.props=E,p.__P=e,p.__e=!1,j=n.__r,M=0,D)p.state=p.__s,p.__d=!1,j&&j(t),d=p.render(p.props,p.state,p.context),g.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,j&&j(t),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++M<25);p.state=p.__s,p.getChildContext!=null&&(i=y(y({},i),p.getChildContext())),D&&!m&&p.getSnapshotBeforeUpdate!=null&&(x=p.getSnapshotBeforeUpdate(h,_)),N=d!=null&&d.type===C&&d.key==null?te(d.props.children):d,c=A(e,v(N)?N:[N],t,r,i,a,o,s,c,l,u),p.base=t.__e,t.__u&=-161,p.__h.length&&s.push(p),S&&(p.__E=p.__=null)}catch(e){if(s.length=f,t.__v=null,l||o!=null){if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o!=null&&(o[o.indexOf(c)]=null),t.__e=c}else if(o!=null)for(P=o.length;P--;)b(o[P])}else t.__e=r.__e;t.__k??(t.__k=r.__k||[]),e.then||ee(t),n.__e(e,t,r)}}else o==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):c=t.__e=z(r.__e,t,r,i,a,o,s,l,u);return(d=n.diffed)&&d(t),128&t.__u?void 0:c}function ee(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ee))}function R(e,t,r){for(var i=0;i<r.length;i++)ne(r[i],r[++i],r[++i]);n.__c&&n.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){n.__e(e,t.__v)}})}function te(e){return typeof e!=`object`||!e||e.__b>0?e:v(e)?e.map(te):e.constructor===void 0?y({},e):null}function z(e,r,i,a,o,s,c,l,u){var d,f,p,m,g,_,y,x=i.props||h,S=r.props,C=r.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||(o=`http://www.w3.org/1999/xhtml`),s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!C&&(C?g.localName==C:g.nodeType==3)){e=g,s[d]=null;break}}if(e==null){if(C==null)return document.createTextNode(S);e=document.createElementNS(o,C,S.is&&S),l&&(n.__m&&n.__m(r,s),l=!1),s=null}if(C==null)x===S||l&&e.data==S||(e.data=S);else{if(s=C==`textarea`&&S.defaultValue!=null?null:s&&t.call(e.childNodes),!l&&s!=null)for(x={},d=0;d<e.attributes.length;d++)x[(g=e.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||F(e,d,null,g,o);for(d in S)g=S[d],d==`children`?m=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?_=g:d==`checked`?y=g:l&&typeof g!=`function`||x[d]===g||F(e,d,g,x[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),r.__k=[];else if(p&&(e.innerHTML=``),A(r.type==`template`?e.content:e,v(m)?m:[m],r,i,a,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&T(i,0),l,u),s!=null)for(d=s.length;d--;)b(s[d]);l&&C!=`textarea`||(d=`value`,C==`progress`&&_==null?e.removeAttribute(`value`):_!=null&&(_!==e[d]||C==`progress`&&!_||C==`option`&&_!=x[d])&&F(e,d,_,x[d],o),d=`checked`,y!=null&&y!=e[d]&&F(e,d,y,x[d],o))}return e}function ne(e,t,r){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(e){n.__e(e,r)}}function re(e,t,r){var i,a;if(n.unmount&&n.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||ne(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){n.__e(e,t)}i.base=i.__P=i.__n=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&re(i[a],t,r||typeof e.type!=`function`);r||b(e.__e),e.__c=e.__=e.__e=void 0}function ie(e,t,n){return this.constructor(e,n)}function ae(e,r,i){var a,o,s,c;r==document&&(r=document.documentElement),n.__&&n.__(e,r),o=(a=typeof i==`function`)?null:i&&i.__k||r.__k,s=[],c=[],L(r,e=(!a&&i||r).__k=x(C,null,[e]),o||h,h,r.namespaceURI,!a&&i?[i]:o?null:r.firstChild?t.call(r.childNodes):null,s,!a&&i?i:o?o.__e:r.firstChild,a,c),R(s,e,c),e.props.children=null}t=g.slice,n={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},r=0,w.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=y({},this.state);typeof e==`function`&&(e=e(y({},n),this.props)),e&&y(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),O(this))},w.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),O(this))},w.prototype.render=C,i=[],o=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,s=function(e,t){return e.__v.__b-t.__v.__b},k.__r=0,c=Math.random().toString(8),l=`__d`+c,u=`__a`+c,d=/(PointerCapture)$|Capture$/i,f=0,p=I(!1),m=I(!0);var B,V,H,oe,se=0,ce=[],U=n,le=U.__b,ue=U.__r,de=U.diffed,fe=U.__c,pe=U.unmount,me=U.__;function he(e,t){U.__h&&U.__h(V,e,se||t),se=0;var n=V.__H||(V.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function W(e){return se=1,ge(Te,e)}function ge(e,t,n){var r=he(B++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Te(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=V,!V.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};V.__f=!0;var a=V.shouldComponentUpdate,o=V.componentWillUpdate;V.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},V.shouldComponentUpdate=i}return r.__N||r.__}function G(e,t){var n=he(B++,3);!U.__s&&we(n.__H,t)&&(n.__=e,n.u=t,V.__H.__h.push(n))}function _e(e,t){var n=he(B++,4);!U.__s&&we(n.__H,t)&&(n.__=e,n.u=t,V.__h.push(n))}function K(e){return se=5,ve(function(){return{current:e}},[])}function ve(e,t){var n=he(B++,7);return we(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function q(e,t){return se=8,ve(function(){return e},t)}function ye(){for(var e;e=ce.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Se),t.__h.some(Ce),t.__h=[]}catch(n){t.__h=[],U.__e(n,e.__v)}}}U.__b=function(e){V=null,le&&le(e)},U.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),me&&me(e,t)},U.__r=function(e){ue&&ue(e),B=0;var t=(V=e.__c).__H;t&&(H===V?(t.__h=[],V.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Se),t.__h.some(Ce),t.__h=[],B=0)),H=V},U.diffed=function(e){de&&de(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ce.push(t)!==1&&oe===U.requestAnimationFrame||((oe=U.requestAnimationFrame)||xe)(ye)),t.__H.__.some(function(e){e.u&&(e.__H=e.u,e.u=void 0)})),H=V=null},U.__c=function(e,t){t.some(function(e){try{e.__h.some(Se),e.__h=e.__h.filter(function(e){return!e.__||Ce(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],U.__e(n,e.__v)}}),fe&&fe(e,t)},U.unmount=function(e){pe&&pe(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Se(e)}catch(e){t=e}}),n.__H=void 0,t&&U.__e(t,n.__v))};var be=typeof requestAnimationFrame==`function`;function xe(e){var t,n=function(){clearTimeout(r),be&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);be&&(t=requestAnimationFrame(n))}function Se(e){var t=V,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),V=t}function Ce(e){var t=V;e.__c=e.__(),V=t}function we(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Te(e,t){return typeof t==`function`?t(e):t}var Ee=new Set([`sessionId`]);function De(e){if(typeof e==`string`)return e.length>0?{id:e}:void 0;if(!e||typeof e!=`object`||Array.isArray(e))return;let{id:t,name:n}=e;if(typeof t==`string`&&t.length!==0)return typeof n==`string`&&n.length>0?{id:t,name:n}:{id:t}}function Oe(e){let t=De(e);if(t)return t.name??t.id}function ke(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Ae(e){let t={};for(let[n,r]of Object.entries(e)){if(Ee.has(n)||!ke(r)){t[n]=r;continue}let e=De(r);e&&(t[`${n}Id`]=e.id,e.name&&(t[`${n}Name`]=e.name))}return t}var je=`en`,Me=[`en`,`fr`,`es`],Ne={en:{heading:`Assistant`,subheading:`Squadico`,placeholder:`Ask your question…`,greeting:`Hello! I am your assistant. What would you like to do?`,hint:`The assistant proposes an action; nothing is applied without your confirmation.`,assistant:`Assistant`,typing:`The assistant is writing its answer`,activity:{knowledge:`Searching the knowledge base…`,skill:`Following a procedure…`,delegation:`Asking a colleague…`,tool:`Looking it up…`},newConversation:`New conversation`,close:`Close the assistant`,closeTitle:`Close`,history:{open:`Conversation history`,menu:`Previous conversations`,loading:`Loading…`,empty:`No previous conversation.`,untitled:`Conversation`},context:{region:`Context sent to the assistant`},approval:{group:`Write confirmation`,approve:`Yes, apply`,reject:`No, cancel`,request:`The agent wants to use {tool}.`,arguments:`With`,edit:`Change…`,correction:`What to change — e.g. “the due date is next Monday”`,correctionLabel:`Correction to make before approving`,send:`Send`},confirm:{group:`Confirmation`,yes:`Yes`,no:`No`,yesValue:`yes`,noValue:`no`,other:`Propose something else`},choices:`Suggested options`,table:{copy:`Copy`,copied:`Copied`,more:`{count} more rows`},form:{submit:`Send`,required:`Required`,email:`Enter a valid email address`,number:`Enter a number`},poweredBy:`Powered by Squadico`,handles:{picker:`Agents you can address`,unknown:`Nobody answers to that name here:`,instead:`You can address:`,rail:`Agents`},selection:{group:`Suggested choice`,single:`Pick one option.`,multiple:`Pick one or more options, then validate.`,validate:`Validate`},composer:{label:`Your message`,send:`Send the message`,sendTitle:`Send`,stop:`Stop the answer`,stopTitle:`Stop`,attach:`Attach a file`,attachTitle:`Attach`,remove:`Remove {name}`},attachments:{unsupported:`This kind of file cannot be attached to a message.`,tooLarge:`This file is too large.`,tooMany:`This message already carries as many files as it may.`,unreadable:`This file could not be read.`,failed:`This file could not be attached.`},error:`Something went wrong, the assistant could not answer. Try again in a moment.`,withHuman:`A member of the team will reply to you here.`},fr:{heading:`Assistant`,subheading:`Squadico`,placeholder:`Posez votre question…`,greeting:`Bonjour ! Je suis votre assistant. Que souhaitez-vous faire ?`,hint:`L'assistant propose une action ; rien n'est appliqué sans votre confirmation.`,assistant:`Assistant`,typing:`L'assistant rédige sa réponse`,activity:{knowledge:`Recherche dans la base de connaissances…`,skill:`Application d'une procédure…`,delegation:`Consultation d'un collègue…`,tool:`Recherche en cours…`},newConversation:`Nouvelle conversation`,close:`Fermer l'assistant`,closeTitle:`Fermer`,history:{open:`Historique des conversations`,menu:`Conversations précédentes`,loading:`Chargement…`,empty:`Aucune conversation précédente.`,untitled:`Conversation`},context:{region:`Contexte transmis à l'assistant`},approval:{group:`Validation de l'écriture`,approve:`Oui, appliquer`,reject:`Non, annuler`,request:`L'agent souhaite utiliser {tool}.`,arguments:`Avec`,edit:`Modifier…`,correction:`Ce qu'il faut changer — ex. « l'échéance est lundi prochain »`,correctionLabel:`Correction à apporter avant validation`,send:`Envoyer`},confirm:{group:`Confirmation`,yes:`Oui`,no:`Non`,yesValue:`oui`,noValue:`non`,other:`Proposer autre chose`},choices:`Options proposées`,table:{copy:`Copier`,copied:`Copié`,more:`{count} lignes de plus`},form:{submit:`Envoyer`,required:`Obligatoire`,email:`Saisissez une adresse e-mail valide`,number:`Saisissez un nombre`},poweredBy:`Propulsé par Squadico`,handles:{picker:`Agents que vous pouvez adresser`,unknown:`Personne ne répond à ce nom ici :`,instead:`Vous pouvez adresser :`,rail:`Agents`},selection:{group:`Choix proposé`,single:`Sélectionnez une option.`,multiple:`Sélectionnez une ou plusieurs options, puis validez.`,validate:`Valider`},composer:{label:`Votre message`,send:`Envoyer le message`,sendTitle:`Envoyer`,stop:`Interrompre la réponse`,stopTitle:`Interrompre`,attach:`Joindre un fichier`,attachTitle:`Joindre`,remove:`Retirer {name}`},attachments:{unsupported:`Ce format de fichier ne peut pas être joint à un message.`,tooLarge:`Ce fichier est trop volumineux.`,tooMany:`Ce message porte déjà autant de fichiers qu'il le peut.`,unreadable:`Ce fichier n'a pas pu être lu.`,failed:`Impossible de joindre ce fichier.`},error:`Une erreur est survenue, l'assistant n'a pas pu répondre. Réessayez dans un instant.`,withHuman:`Un membre de l'équipe va vous répondre ici.`},es:{heading:`Asistente`,subheading:`Squadico`,placeholder:`Haga su pregunta…`,greeting:`¡Hola! Soy su asistente. ¿Qué desea hacer?`,hint:`El asistente propone una acción; no se aplica nada sin su confirmación.`,assistant:`Asistente`,typing:`El asistente está redactando su respuesta`,activity:{knowledge:`Buscando en la base de conocimientos…`,skill:`Siguiendo un procedimiento…`,delegation:`Consultando a un compañero…`,tool:`Consultando…`},newConversation:`Nueva conversación`,close:`Cerrar el asistente`,closeTitle:`Cerrar`,history:{open:`Historial de conversaciones`,menu:`Conversaciones anteriores`,loading:`Cargando…`,empty:`Ninguna conversación anterior.`,untitled:`Conversación`},context:{region:`Contexto enviado al asistente`},approval:{group:`Validación de la escritura`,approve:`Sí, aplicar`,reject:`No, cancelar`,request:`El agente quiere usar {tool}.`,arguments:`Con`,edit:`Modificar…`,correction:`Lo que hay que cambiar — p. ej. «el vencimiento es el lunes»`,correctionLabel:`Corrección antes de validar`,send:`Enviar`},confirm:{group:`Confirmación`,yes:`Sí`,no:`No`,yesValue:`sí`,noValue:`no`,other:`Proponer otra cosa`},choices:`Opciones propuestas`,table:{copy:`Copiar`,copied:`Copiado`,more:`{count} filas más`},form:{submit:`Enviar`,required:`Obligatorio`,email:`Introduzca un correo electrónico válido`,number:`Introduzca un número`},poweredBy:`Con la tecnología de Squadico`,handles:{picker:`Agentes a los que puedes dirigirte`,unknown:`Nadie responde a ese nombre aquí:`,instead:`Puedes dirigirte a:`,rail:`Agentes`},selection:{group:`Opción propuesta`,single:`Seleccione una opción.`,multiple:`Seleccione una o varias opciones y valide.`,validate:`Validar`},composer:{label:`Su mensaje`,send:`Enviar el mensaje`,sendTitle:`Enviar`,stop:`Interrumpir la respuesta`,stopTitle:`Interrumpir`,attach:`Adjuntar un archivo`,attachTitle:`Adjuntar`,remove:`Quitar {name}`},attachments:{unsupported:`Este tipo de archivo no se puede adjuntar a un mensaje.`,tooLarge:`Este archivo es demasiado grande.`,tooMany:`Este mensaje ya lleva todos los archivos que puede llevar.`,unreadable:`No se ha podido leer este archivo.`,failed:`No se ha podido adjuntar este archivo.`},error:`Se ha producido un error, el asistente no ha podido responder. Inténtelo de nuevo.`,withHuman:`Un miembro del equipo le responderá aquí.`}},Pe={en:`en-GB`,fr:`fr-FR`,es:`es-ES`};function Fe(e){let t=e?.trim().toLowerCase().split(/[-_]/)[0];return t&&t in Ne?t:void 0}function Ie(){return typeof navigator>`u`?[]:navigator.languages?.length?navigator.languages:[navigator.language]}function Le(e){let t=e?.trim(),n=(t?[t]:Ie()).find(Fe),r=Fe(n)??`en`;return{code:r,tag:n?.includes(`-`)?n:Pe[r],t:Ne[r]}}var Re=`squadico-chatbot:open`;function ze(){try{if(typeof sessionStorage>`u`)return;let e=sessionStorage.getItem(Re);return e===`1`||e!==`0`&&void 0}catch{return}}function Be(e){try{if(typeof sessionStorage>`u`)return;sessionStorage.setItem(Re,e?`1`:`0`)}catch{}}function Ve(e,t){return t===!1?e??!1:ze()??e??!1}function He(e,t){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role===`assistant`&&n.agent)return n.agent.handle}return t}function Ue(e,t,n){return!t||t===n||e.trimStart().startsWith(`@`)?e:`@${t} ${e}`}function We(){let e=globalThis.crypto;if(e&&typeof e.randomUUID==`function`)return e.randomUUID();let t=new Uint8Array(16);if(e&&typeof e.getRandomValues==`function`)e.getRandomValues(t);else for(let e=0;e<16;e++)t[e]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=[];for(let e=0;e<16;e++)n.push(t[e].toString(16).padStart(2,`0`));return n.slice(0,4).join(``)+`-`+n.slice(4,6).join(``)+`-`+n.slice(6,8).join(``)+`-`+n.slice(8,10).join(``)+`-`+n.slice(10,16).join(``)}function Ge(e){"@babel/helpers - typeof";return Ge=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},Ge(e)}function Ke(e,t){if(Ge(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Ge(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function qe(e){var t=Ke(e,`string`);return Ge(t)==`symbol`?t:t+``}function Je(e,t,n){return(t=qe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ye=`https://api.squadico.com`,Xe=2e4,J=class extends Error{constructor(e,t,n){super(e),Je(this,`status`,void 0),Je(this,`code`,void 0),this.name=`ChatHttpError`,this.status=t,this.code=n}};function Ze(e,t){return`${e.replace(/\/+$/,``)}${t}`}function Qe(e,t){return{"Content-Type":`application/json`,Accept:`text/event-stream, application/json`,...e?{"X-Visitor-Token":e}:{},...t?{"X-Subject-Token":t}:{}}}function $e(e){if(!e||typeof e!=`object`)return;let{loc:t,msg:n}=e;if(typeof n!=`string`||!n)return;let r=(Array.isArray(t)?t.filter(e=>typeof e==`string`):[]).at(-1);return r&&r!==`body`?`${r}: ${n}`:n}async function et(e){let t=``,n;try{let r=await e.text();if(r)try{let e=JSON.parse(r),i=e.detail??e.message;if(Array.isArray(i)){let e=i.map(e=>$e(e)??(typeof e==`string`?e:void 0)).filter(e=>e!==void 0);t=e.length>0?e.join(`, `):r}else t=typeof i==`string`?i:r;n=typeof e.code==`string`?e.code:void 0}catch{t=r}}catch{}return new J(t||`The API answered ${e.status}`,e.status,n)}function tt(e,t){if(!e||typeof e!=`object`)return;let n=e;if(!(typeof n.handle!=`string`||!n.handle))return{handle:n.handle,name:typeof n.name==`string`?n.name:n.handle,avatarUrl:typeof n.avatar_url==`string`&&n.avatar_url?Ze(t,n.avatar_url):void 0,color:typeof n.color==`string`?n.color:void 0}}function nt(e,t){return(Array.isArray(e)?e:[]).map(e=>tt(e,t)).filter(e=>e!==void 0)}var rt=[`knowledge`,`skill`,`delegation`,`tool`];function it(e){return rt.find(t=>t===e)??`tool`}function at(e){if(!e||typeof e!=`object`)return;let t=e;if(!(typeof t.tool_call_id!=`string`||!t.tool_call_id))return{toolCallId:t.tool_call_id,tool:typeof t.tool==`string`?t.tool:``,arguments:t.arguments&&typeof t.arguments==`object`?t.arguments:{}}}var ot=new Set([`user`,`assistant`]);function st(e,t){if(typeof e.role!=`string`||!ot.has(e.role)||typeof e.content!=`string`||!e.content)return null;let n=typeof e.created_at==`string`?Date.parse(e.created_at):NaN;return{id:typeof e.id==`string`&&e.id?e.id:We(),role:e.role,content:e.content,createdAt:Number.isNaN(n)?Date.now():n,agent:tt(e.agent,t),attachments:ct(e.attachments),authorName:e.kind===`human`&&typeof e.author_name==`string`&&e.author_name?e.author_name:void 0}}function ct(e){if(!Array.isArray(e))return;let t=e.map(e=>lt(e)).filter(e=>e!==null);return t.length>0?t:void 0}function lt(e){if(!e||typeof e!=`object`)return null;let{id:t,kind:n,filename:r,content_type:i}=e;return typeof t!=`string`||!t||typeof r!=`string`||!r?null:{id:t,kind:n===`image`||n===`chart`?n:`document`,filename:r,contentType:typeof i==`string`?i:`application/octet-stream`}}async function ut(e){let t=e.agent?`?agent=${encodeURIComponent(e.agent)}`:``,n=await fetch(Ze(e.apiUrl,`/public/applications/${encodeURIComponent(e.embedKey)}${t}`),{method:`GET`,headers:Qe(),signal:e.signal});if(!n.ok)throw await et(n);let r=await n.json();return{welcomeMessage:typeof r.welcome_message==`string`&&r.welcome_message?r.welcome_message:void 0,agent:tt(r.agent,e.apiUrl),handles:nt(r.handles,e.apiUrl),agentHandle:typeof r.agent_handle==`string`&&r.agent_handle?r.agent_handle:void 0,branding:r.branding===!0}}async function dt(e){let t=await fetch(Ze(e.apiUrl,`/public/applications/${encodeURIComponent(e.embedKey)}/conversations`),{method:`POST`,headers:Qe(),body:JSON.stringify({...e.user?{user:e.user}:{},...e.agent?{agent:e.agent}:{}}),signal:e.signal});if(!t.ok)throw await et(t);let n=await t.json();if(typeof n.id!=`string`||typeof n.visitor_token!=`string`)throw new J(`The API opened a conversation without an id or a token`);let r=(Array.isArray(n.messages)?n.messages:[]).map(t=>st(t,e.apiUrl)).filter(e=>e!==null);return{conversationId:n.id,visitorToken:n.visitor_token,agentName:typeof n.agent_name==`string`?n.agent_name:``,agentSlug:typeof n.agent_slug==`string`?n.agent_slug:``,welcomeMessage:typeof n.welcome_message==`string`&&n.welcome_message?n.welcome_message:void 0,messages:r,handles:nt(n.handles,e.apiUrl),agentHandle:typeof n.agent_handle==`string`&&n.agent_handle?n.agent_handle:void 0,withHuman:typeof n.handling==`string`&&n.handling!==`agents`,branding:n.branding===!0}}async function ft(e){let t=await fetch(Ze(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}`),{method:`GET`,headers:Qe(e.visitorToken),signal:e.signal});if(!t.ok)throw await et(t);let n=await t.json();if(typeof n.id!=`string`)throw new J(`The API replayed a conversation without an id`);return{conversationId:n.id,visitorToken:e.visitorToken,agentName:typeof n.agent_name==`string`?n.agent_name:``,agentSlug:typeof n.agent_slug==`string`?n.agent_slug:``,welcomeMessage:typeof n.welcome_message==`string`&&n.welcome_message?n.welcome_message:void 0,messages:(Array.isArray(n.messages)?n.messages:[]).map(t=>st(t,e.apiUrl)).filter(e=>e!==null),handles:nt(n.handles,e.apiUrl),agentHandle:typeof n.agent_handle==`string`&&n.agent_handle?n.agent_handle:void 0,withHuman:typeof n.handling==`string`&&n.handling!==`agents`,branding:n.branding===!0}}async function pt(e){let t=new FormData;t.append(`file`,e.file);let n=await fetch(gt(e),{method:`POST`,headers:{"X-Visitor-Token":e.visitorToken},body:t,signal:e.signal});if(!n.ok)throw await et(n);let r=lt(await n.json());if(!r)throw new J(`The upload could not be read`,n.status);return r}async function mt(e){let t=await fetch(`${gt(e)}/${encodeURIComponent(e.attachmentId)}`,{method:`DELETE`,headers:{"X-Visitor-Token":e.visitorToken},signal:e.signal});if(!t.ok)throw await et(t)}async function ht(e){let t=await fetch(`${gt(e)}/${encodeURIComponent(e.attachmentId)}/content`,{headers:{"X-Visitor-Token":e.visitorToken},signal:e.signal});if(!t.ok)throw await et(t);return t.blob()}function gt(e){return Ze(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/attachments`)}async function _t(e){return yt(Ze(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/messages`),{content:e.message,attachment_ids:e.attachmentIds??[],...e.context&&Object.keys(e.context).length>0?{context:e.context}:{}},e)}async function vt(e){return yt(Ze(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/approvals`),{tool_call_id:e.toolCallId,approved:e.approved},e)}async function yt(e,t,n){let r=await fetch(e,{method:`POST`,headers:Qe(n.visitorToken,n.subjectToken),body:JSON.stringify({...t,widgets:1}),signal:n.signal});if(!r.ok)throw await et(r);if(!r.body)throw new J(`Answer with no stream body`);let i=r.body.getReader(),a=new TextDecoder,o=``,s=``,c=``,l,u,d={answer:``};try{for(;;){let{value:e,done:t}=await i.read();if(t)break;o+=a.decode(e,{stream:!0});let r=o.split(`
2
- `);o=r.pop()??``;for(let e of r){let t=e.trim();if(!t){s=``;continue}if(t.startsWith(`event:`)){s=t.slice(6).trim();continue}if(!t.startsWith(`data:`))continue;let r=t.slice(5).trim();if(!r)continue;let i;try{i=JSON.parse(r)}catch{continue}s===`token`&&typeof i.text==`string`?(c+=i.text,n.onToken(i.text)):s===`progress`?n.onProgress?.(it(i.activity)):s===`done`?(d.answer=typeof i.content==`string`?i.content:c,d.agent=tt(i.agent,n.apiUrl),typeof i.unknown_handle==`string`&&i.unknown_handle&&(d.unknownHandle=i.unknown_handle,d.offered=nt(i.handles,n.apiUrl))):s===`handoff`?(typeof i.to_agent_name==`string`&&(u=i.to_agent_name),c=``):s===`escalated`?d.withHuman=!0:s===`held`?(d.held=!0,d.withHuman=!0):s===`approval_required`?d.approval=at(i):s===`error`&&(l=typeof i.detail==`string`?i.detail:`The turn failed`)}if(l)break}}finally{i.cancel().catch(()=>void 0)}if(l)throw new J(l);return!d.answer&&!d.approval&&(d.answer=c),u&&!d.agent&&(d.authorName=u),d}var bt=`squadico-chatbot:conversation`;function xt(){try{if(typeof sessionStorage>`u`)return;let e=sessionStorage.getItem(bt);if(!e)return;let t=JSON.parse(e);return!t.sessionId||!t.visitorToken||!t.embedKey?void 0:{sessionId:t.sessionId,visitorToken:t.visitorToken,embedKey:t.embedKey,user:typeof t.user==`string`?t.user:void 0,scope:typeof t.scope==`string`?t.scope:void 0}}catch{return}}function St(e){try{if(typeof sessionStorage>`u`)return;sessionStorage.setItem(bt,JSON.stringify(e))}catch{}}function Ct(){try{if(typeof sessionStorage>`u`)return;sessionStorage.removeItem(bt)}catch{}}function wt(e,{embedKey:t,user:n,scope:r}){return e.embedKey===t&&e.user===n&&e.scope===r}async function Tt(e){if(e)try{return await e()||void 0}catch{return}}var Et=`preview-welcome`;function Dt(e,t){return e===void 0&&t===void 0?void 0:JSON.stringify([e,t])}function Ot(e){let t=e instanceof J?e.status:void 0;return t===415?`unsupported`:t===413?`tooLarge`:t===409?`tooMany`:t===422?`unreadable`:`failed`}var kt=5e3;function At(e){return e instanceof J&&e.code===`conversation_retired`}function jt(e){let[t,n]=W([]),[r,i]=W(!1),[a,o]=W(``),[s,c]=W(0),[l,u]=W([]),[d,f]=W(``),[p,m]=W(``),[h,g]=W(null),[_,v]=W(!1),[y,b]=W(!1),[x,S]=W([]),[C,w]=W([]),[T,E]=W(null),D=K(null),O=K(e);O.current=e;let k=K(null),A=K(null),j=K(null),M=K(null),N=K(void 0),P=e.greeting,F=ve(()=>P?{id:`greeting`,role:`assistant`,content:P,createdAt:Date.now()}:null,[P]),I=q(e=>{O.current.onEvent?.(e)},[]),L=q((e,t)=>{n(n=>n.map(n=>n.id===e?{...n,...t}:n))},[]),ee=q((e,t)=>{let n=e instanceof J?e.status:void 0,r=e instanceof Error?e.message:String(e),i=(O.current.locale??Le(void 0)).t.error;t&&L(t,{content:i,streaming:!1,error:!0,activity:void 0}),I({type:`chatbot-error`,message:r,status:n,sessionId:A.current?.sessionId??``}),typeof console<`u`&&console.error(`[squadico-chatbot]`,r)},[I,L]),R=q(()=>{let e=O.current;if(!e.embedKey)throw new J(`No embed key: nothing says which application to open`);return{opts:e,apiUrl:e.apiUrl??`https://api.squadico.com`,embedKey:e.embedKey,claim:e.user,scope:e.scope}},[]),te=q((e,t)=>{let r={sessionId:t.conversationId,visitorToken:t.visitorToken};return A.current=r,N.current=Dt(e.claim?.id,e.scope),St({...r,embedKey:e.embedKey,user:e.claim?.id,scope:e.scope}),o(t.conversationId),u(t.handles),f(e.opts.agent&&t.agentHandle?t.agentHandle:``),m(t.agentHandle??``),v(!!t.withHuman),b(t.branding),n(e=>[...t.messages,...e.filter(e=>e.id!==Et)]),r},[]),z=q(e=>{if(j.current)return j.current;let t=xt();if(!t||!wt(t,{embedKey:e.embedKey,user:e.claim?.id,scope:e.scope}))return Promise.resolve(null);let n=ft({apiUrl:e.apiUrl,conversationId:t.sessionId,visitorToken:t.visitorToken}).then(t=>te(e,t)).catch(()=>(Ct(),null)).finally(()=>{j.current=null});return j.current=n,n},[te]),ne=q(async()=>{if(A.current)return A.current;if(k.current)return k.current;let e=R(),t=z(e).then(t=>t??dt({apiUrl:e.apiUrl,embedKey:e.embedKey,user:e.claim,agent:e.opts.agent}).then(t=>te(e,t)));k.current=t;try{return await t}finally{k.current=null}},[te,z,R]),re=q(()=>{if(A.current||k.current||M.current)return;let e;try{e=R()}catch(e){ee(e);return}let t=z(e).then(async t=>{if(t||A.current||k.current)return;let r=await ut({apiUrl:e.apiUrl,embedKey:e.embedKey,agent:e.opts.agent});if(A.current||k.current)return;u(r.handles),f(e.opts.agent&&r.agentHandle?r.agentHandle:``),m(r.agentHandle??``),b(r.branding);let i=r.welcomeMessage;i&&n(e=>e.length>0?e:[{id:Et,role:`assistant`,content:i,createdAt:Date.now(),agent:r.agent}])});M.current=t,t.catch(e=>{M.current=null,ee(e)})},[ee,z,R]),ie=q((e,t,{retry:r=!1,carried:a=[]}={})=>{if(D.current)return;let o=new AbortController;D.current=o,i(!0),g(null);let s=We();n(t=>[...t,{id:We(),role:`user`,content:e,createdAt:Date.now(),attachments:a.length>0?a:void 0},{id:s,role:`assistant`,content:``,createdAt:Date.now(),streaming:!0}]),(async()=>{let i=await ne();I({type:`chatbot-message`,role:`user`,content:e,sessionId:i.sessionId});let a=``,c=e=>{a+=e,L(s,{content:a,activity:void 0})},l=e=>{a||L(s,{activity:e})},u;try{u=await t(i,c,o.signal,l)}catch(e){if(!At(e)||(Ct(),A.current=null,k.current=null,!r))throw e;i=await ne(),a=``,L(s,{content:``,activity:void 0}),u=await t(i,c,o.signal,l)}if(u.withHuman&&v(!0),u.held){n(e=>e.filter(e=>e.id!==s));return}L(s,{content:u.answer,streaming:!1,activity:void 0,agent:u.agent,authorName:u.authorName,approval:u.approval,unknownHandle:u.unknownHandle,offered:u.offered}),g(u.approval??null),I({type:`chatbot-message`,role:`assistant`,content:u.answer,sessionId:i.sessionId,agent:u.agent?.handle})})().catch(e=>{if(o.signal.aborted){L(s,{streaming:!1,activity:void 0});return}ee(e,s)}).finally(()=>{D.current=null,i(!1)})},[ne,I,ee,L]),ae=q(e=>{let t=e.trim();if(!t&&x.length===0)return;let n=x;S([]),E(null),ie(t,async(e,r,i,a)=>_t({subjectToken:await Tt(O.current.getSubjectToken),apiUrl:O.current.apiUrl??`https://api.squadico.com`,conversationId:e.sessionId,visitorToken:e.visitorToken,message:t,attachmentIds:n.map(e=>e.id),context:O.current.context?Ae(O.current.context):void 0,onToken:r,onProgress:a,signal:i}),{retry:!0,carried:n})},[x,ie]),B=q(e=>{E(null),w(t=>[...t,e.name]),ne().then(t=>pt({apiUrl:O.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,file:e})).then(e=>S(t=>[...t,e])).catch(e=>E(Ot(e))).finally(()=>w(t=>{let n=t.indexOf(e.name);return n<0?t:[...t.slice(0,n),...t.slice(n+1)]}))},[ne]),V=q(e=>{S(t=>t.filter(t=>t.id!==e));let t=A.current;t&&mt({apiUrl:O.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,attachmentId:e}).catch(()=>{})},[]),H=q(async e=>{let t=A.current;if(!t)throw new J(`No conversation to read that file from`);return ht({apiUrl:O.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,attachmentId:e})},[]),oe=q((e,t)=>{let n=h;n&&ie(t,async(t,r,i,a)=>vt({subjectToken:await Tt(O.current.getSubjectToken),apiUrl:O.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,toolCallId:n.toolCallId,approved:e,onToken:r,onProgress:a,signal:i}))},[h,ie]),se=q(()=>{D.current?.abort(),D.current=null,i(!1)},[]),ce=q(()=>{D.current?.abort(),D.current=null,A.current=null,k.current=null,j.current=null,M.current=null,N.current=void 0,Ct(),i(!1),g(null),v(!1),o(``),c(e=>e+1),f(``),m(``),n([]),I({type:`chatbot-reset`,sessionId:``})},[I]),U=e.humanPollMs??kt;G(()=>{if(!_||!a)return;let e=setInterval(()=>{let e=A.current;!e||D.current||ft({apiUrl:O.current.apiUrl??`https://api.squadico.com`,conversationId:e.sessionId,visitorToken:e.visitorToken}).then(e=>{n(e.messages),v(!!e.withHuman)}).catch(()=>{})},U);return()=>clearInterval(e)},[_,a,U]);let le=Dt(e.user?.id,e.scope);return G(()=>{if(A.current){N.current!==le&&ce();return}if(!M.current||k.current)return;let e;try{e=R()}catch{return}z(e)},[le,ce,z,R]),{messages:ve(()=>t.length===0&&F?[F]:t,[F,t]),busy:r,sessionId:a,resets:s,handles:l,addressee:d,agentHandle:p,approval:h,withHuman:_,branding:y,start:re,send:ae,attachments:x,uploading:C,attachmentError:T,attach:B,detach:V,loadAttachment:H,decide:oe,stop:se,reset:ce}}var Mt=0;Array.isArray;function Y(e,t,r,i,a,o){t||(t={});var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Mt,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return n.vnode&&n.vnode(u),u}function Nt({name:e,color:t,url:n,size:r=16}){let[i,a]=W(void 0),o=!!n&&i!==n;return Y(`span`,{class:`sqc-avatar`,"aria-hidden":`true`,style:{width:`${r}px`,height:`${r}px`,fontSize:`${Math.round(r*.45)}px`,borderRadius:`${Math.round(r*.25)}px`,...o||!t?{}:{backgroundColor:t}},children:o?Y(`img`,{src:n,alt:``,onError:()=>a(n)}):Pt(e)})}function Pt(e){let t=Array.from(e.trim())[0];return t?t.toLocaleUpperCase():`?`}function Ft({handles:e,active:t,disabled:n,onPick:r,label:i}){return Y(`nav`,{class:`sqc-rail`,"aria-label":i,children:e.map(e=>Y(`button`,{type:`button`,class:`sqc-rail__item`,"aria-label":e.name,"aria-pressed":e.handle===t,"data-tip":e.name,disabled:n,onClick:()=>r(e.handle),children:[Y(Nt,{name:e.name,color:e.color,url:e.avatarUrl,size:40}),Y(`span`,{class:`sqc-rail__label`,"aria-hidden":`true`,children:It(e.handle)})]},e.handle))})}function It(e){let t=e.split(/[-_]/)[0]??e;return t.charAt(0).toUpperCase()+t.slice(1)}var Lt=132,Rt=`image/png,image/jpeg,image/gif,image/webp,application/pdf,.docx,.txt,.md,.csv,.json`,zt=/^[a-zA-Z0-9_-]*$/;function Bt(e,t){let n=e.slice(0,t),r=n.lastIndexOf(`@`);if(r<0||r>0&&!/\s/.test(n[r-1]??``))return null;let i=n.slice(r+1);return zt.test(i)?{start:r,query:i}:null}function Vt({placeholder:e,locale:t,busy:n,autoFocus:r,handles:i,addressee:a,attachments:o=[],uploading:s=[],attachmentError:c,onAttach:l,onDetach:u,onSend:d,onStop:f}){let[p,m]=W(``),[h,g]=W(null),[_,v]=W(0),[y,b]=W(!1),x=K(null),S=K(null),w=!!l,T=s.length>0,E=ve(()=>{if(!h||!i||i.length===0)return[];let e=h.query.toLowerCase();return i.filter(t=>t.handle.startsWith(e))},[i,h]),D=E.length>0,O=q(()=>{let e=x.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight>Lt;e.style.height=`${Math.min(e.scrollHeight,Lt)}px`,e.style.overflowY=t?`auto`:`hidden`},[]);G(()=>{r&&x.current?.focus(),O()},[r,O]),G(()=>{a&&(m(e=>e||`@${a} `),requestAnimationFrame(O))},[a,O]);let k=q(e=>{g(Bt(e.value,e.selectionStart??e.value.length)),v(0)},[]),A=q(e=>{let t=x.current;if(!t||!h)return;let n=t.selectionStart??t.value.length,r=`${p.slice(0,h.start)}@${e} ${p.slice(n)}`,i=h.start+e.length+2;m(r),g(null),requestAnimationFrame(()=>{t.focus(),t.setSelectionRange(i,i),O()})},[O,h,p]),j=q(e=>{if(!(!l||!e))for(let t of Array.from(e))l(t)},[l]),M=q(()=>{let e=p.trim();!e&&o.length===0||n||T||(d(e),m(``),g(null),requestAnimationFrame(O))},[o.length,n,O,d,p,T]),N=q(e=>{if(D&&!e.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:E.length-1;v(e=>(e+t)%E.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),A((E[_]??E[0]).handle);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),g(null);return}}e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),M())},[_,E,A,D,M]),P=Xe-p.length;return Y(`form`,{class:`sqc-composer${y?` sqc-composer--dropping`:``}`,onSubmit:e=>{e.preventDefault(),M()},onDragOver:e=>{w&&(e.preventDefault(),b(!0))},onDragLeave:()=>b(!1),onDrop:e=>{w&&(e.preventDefault(),b(!1),j(e.dataTransfer?.files??null))},children:[(o.length>0||T||c)&&Y(`div`,{class:`sqc-attachments`,children:[o.map(e=>Y(`span`,{class:`sqc-chip`,"data-kind":e.kind,children:[Y(`span`,{class:`sqc-chip__name`,children:e.filename}),Y(`button`,{type:`button`,class:`sqc-chip__remove`,"aria-label":t.t.composer.remove.replace(`{name}`,e.filename),onClick:()=>u?.(e.id),children:`×`})]},e.id)),s.map(e=>Y(`span`,{class:`sqc-chip sqc-chip--waiting`,children:Y(`span`,{class:`sqc-chip__name`,children:e})},e)),c&&Y(`p`,{class:`sqc-attachments__error`,role:`status`,children:c})]}),Y(`div`,{class:`sqc-composer__field`,children:[D&&Y(`ul`,{class:`sqc-mentions`,role:`listbox`,"aria-label":t.t.handles.picker,children:E.map((e,t)=>Y(`li`,{role:`option`,"aria-selected":t===_,class:`sqc-mention${t===_?` sqc-mention--active`:``}`,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>v(t),onClick:()=>A(e.handle),children:[Y(`span`,{class:`sqc-mention__icon`,children:Y(Nt,{name:e.name,color:e.color,url:e.avatarUrl,size:18})}),Y(`span`,{class:`sqc-mention__handle`,children:[`@`,e.handle]}),Y(`span`,{class:`sqc-mention__name`,children:e.name})]},e.handle))}),Y(`textarea`,{ref:x,class:`sqc-composer__input`,rows:1,value:p,placeholder:e,maxLength:Xe,"aria-label":t.t.composer.label,onInput:e=>{m(e.currentTarget.value),k(e.currentTarget),O()},onKeyDown:N,onClick:e=>k(e.currentTarget),onPaste:e=>{let t=e.clipboardData?.files;!w||!t||t.length===0||(e.preventDefault(),j(t))}}),P<=200&&Y(`span`,{class:`sqc-composer__count`,"aria-live":`polite`,children:P})]}),w&&Y(C,{children:[Y(`input`,{ref:S,type:`file`,multiple:!0,accept:Rt,class:`sqc-file-input`,onChange:e=>{j(e.currentTarget.files),e.currentTarget.value=``}}),Y(`button`,{type:`button`,class:`sqc-btn sqc-btn--attach`,onClick:()=>S.current?.click(),"aria-label":t.t.composer.attach,title:t.t.composer.attachTitle,children:Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.9`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:Y(`path`,{d:`M21 11.5l-8.8 8.8a5 5 0 01-7.1-7.1l9-9a3.3 3.3 0 014.7 4.7l-9 9a1.6 1.6 0 01-2.3-2.3l8.3-8.3`})})})]}),n?Y(`button`,{type:`button`,class:`sqc-btn sqc-btn--stop`,onClick:f,"aria-label":t.t.composer.stop,title:t.t.composer.stopTitle,children:Y(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:Y(`rect`,{x:`7`,y:`7`,width:`10`,height:`10`,rx:`2`,fill:`currentColor`})})}):Y(`button`,{type:`submit`,class:`sqc-btn sqc-btn--send`,disabled:!p.trim()&&o.length===0||T,"aria-label":t.t.composer.send,title:t.t.composer.sendTitle,children:Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.9`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:Y(`path`,{d:`M5 12l14-7-5 14-2.5-5.5L5 12z`})})})]})}function Ht(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function Ut(e,t){Ht(e,t),t.add(e)}function X(e,t,n){Ht(e,t),t.set(e,n)}function Z(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function Q(e,t){return e.get(Z(e,t))}function $(e,t,n){return e.set(Z(e,t),n),n}var Wt=new Map;function Gt(e){if(Wt.has(e))return Wt.get(e)??null;let t;try{t=new CSSStyleSheet,t.replaceSync(e)}catch{t=null}return Wt.set(e,t),t}function Kt(e,t,n){let r=[...t,`locked`,`language`];var i=new WeakMap,a=new WeakMap,o=new WeakMap,s=new WeakMap,c=new WeakSet;class l extends HTMLElement{constructor(){super(),Ut(this,c),X(this,i,{locked:!1,language:`en`}),X(this,a,void 0),X(this,o,!1),X(this,s,e=>{Q(i,this).locked||(this.set(`locked`,!0),this.dispatchEvent(new CustomEvent(`sqc-reply`,{detail:{text:e},bubbles:!0,composed:!0})))});let e=this.attachShadow({mode:`open`}),t=Gt(n);if(t)e.adoptedStyleSheets=[t];else{let t=document.createElement(`style`);t.textContent=n,e.append(t)}$(a,this,document.createElement(`div`)),e.append(Q(a,this));for(let e of r){if(!Object.hasOwn(this,e))continue;let t=this[e];delete this[e],this[e]=t}}connectedCallback(){$(o,this,!0),Z(c,this,u).call(this)}disconnectedCallback(){$(o,this,!1),ae(null,Q(a,this))}set(e,t){Q(i,this)[e]=t,Z(c,this,u).call(this)}get(e){return Q(i,this)[e]}}function u(){Q(o,this)&&ae(x(e,{...Q(i,this),reply:Q(s,this)}),Q(a,this))}for(let e of r)Object.defineProperty(l.prototype,e,{get(){return this.get(e)},set(t){this.set(e,t)},configurable:!0});return l}var qt={table:`sqc-table`,choices:`sqc-choices`,confirm:`sqc-confirm`,form:`sqc-form`,chart:`sqc-chart`,approval:`sqc-approval`};function Jt(e){return Le(e).t}var Yt=/(\*\*[^*\n]+\*\*|`[^`\n]+`|~~[^~\n]+~~|\[[^\]\n]+\]\([^)\s]+\)|\*[^*\n]+\*|https?:\/\/[^\s<>()]+)/g,Xt=/^\[([^\]\n]+)\]\(([^)\s]+)\)$/,Zt=/^(https?:|mailto:|\/(?!\/))/i;function Qt(e){if(typeof location>`u`)return!1;try{return new URL(e,location.href).origin===location.origin}catch{return!1}}function $t(e,t,n){return Zt.test(e)?Qt(e)?Y(`a`,{href:e,children:t},n):Y(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:t},n):t}function en(e,t){let n=e.split(Yt),r=[];return n.forEach((e,n)=>{if(!e)return;let i=`${t}-${n}`,a=Xt.exec(e);e.startsWith(`**`)&&e.endsWith(`**`)&&e.length>4?r.push(Y(`strong`,{children:e.slice(2,-2)},i)):e.startsWith("`")&&e.endsWith("`")&&e.length>2?r.push(Y(`code`,{children:e.slice(1,-1)},i)):e.startsWith(`~~`)&&e.endsWith(`~~`)&&e.length>4?r.push(Y(`del`,{children:e.slice(2,-2)},i)):a?r.push($t(a[2],a[1],i)):e.startsWith(`*`)&&e.endsWith(`*`)&&e.length>2?r.push(Y(`em`,{children:e.slice(1,-1)},i)):/^https?:\/\//.test(e)?r.push($t(e,e,i)):r.push(e)}),r}function tn(e){return e.replace(/\[([^\]\n]+)\]\([^)\s]+\)/g,`$1`).replace(/\*\*|~~|`|\*/g,``).trim()}function nn(){return Y(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.2`,"aria-hidden":`true`,children:Y(`path`,{d:`M3.5 8.5l3 3 6-7`,"stroke-linecap":`round`,"stroke-linejoin":`round`})})}function rn({options:e=[],multiple:t,checked:n,locked:r,language:i,reply:a}){let o=Jt(i),s=e.map(tn),[c,l]=W(null),u=e.flatMap((e,t)=>n?.includes(e)?[t]:[]),d=c??(t?u:u.slice(0,1)),f=e=>{if(!r){if(!t){l([e]),a(s[e]);return}l(d.includes(e)?d.filter(t=>t!==e):[...d,e])}};return Y(`div`,{class:`choices`,role:`group`,"aria-label":o.choices,children:[e.map((e,t)=>Y(`button`,{type:`button`,class:`choice`,"aria-pressed":d.includes(t),disabled:r,onClick:()=>f(t),children:[Y(`span`,{class:`box${d.includes(t)?` on`:``}`,"aria-hidden":`true`,children:d.includes(t)&&Y(nn,{})}),Y(`span`,{class:`label`,children:en(e,`o${t}`)})]},`${t}-${s[t]}`)),t&&Y(`button`,{type:`button`,class:`send`,disabled:r||d.length===0,onClick:()=>{l(d),a([...d].sort((e,t)=>e-t).map(e=>s[e]).join(`, `))},children:o.selection.validate})]})}function an({locked:e,language:t,reply:n}){let[r,i]=W(null),{confirm:a}=Jt(t),o=[{value:a.yesValue,label:a.yes,kind:`yes`},{value:a.noValue,label:a.no,kind:`no`}];return Y(`div`,{class:`confirm`,role:`group`,"aria-label":a.group,children:[o.map(t=>Y(`button`,{type:`button`,class:t.kind,"aria-pressed":r===t.value,disabled:e,onClick:()=>{i(t.value),n(t.value)},children:t.label},t.kind)),Y(`button`,{type:`button`,class:`other`,disabled:e,onClick:e=>e.currentTarget.dispatchEvent(new CustomEvent(`sqc-compose`,{bubbles:!0,composed:!0})),children:a.other})]})}var on=200,sn=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`}),cn=e=>tn(e??``).replace(/[\t\r\n]+/g,` `);function ln({table:e,language:t}){let n=Jt(t),{header:r=[],rows:i=[]}=e??{},[a,o]=W(null),[s,c]=W(!1),l=ve(()=>{if(!a)return i;let e=a.descending?-1:1;return[...i].sort((t,n)=>e*sn.compare(cn(t[a.column]),cn(n[a.column])))},[i,a]),u=()=>{let e=[r,...l].map(e=>r.map((t,n)=>cn(e[n])).join(` `));navigator.clipboard?.writeText(e.join(`
3
- `)).then(()=>{c(!0),setTimeout(()=>c(!1),2e3)},()=>void 0)},d=l.length-on;return Y(`div`,{children:[Y(`div`,{class:`table`,children:Y(`table`,{children:[Y(`thead`,{children:Y(`tr`,{children:r.map((e,t)=>Y(`th`,{"aria-sort":a?.column===t?a.descending?`descending`:`ascending`:`none`,children:Y(`button`,{type:`button`,onClick:()=>o({column:t,descending:a?.column===t&&!a.descending}),children:en(e,`h${t}`)})},t))})}),Y(`tbody`,{children:l.slice(0,on).map((e,t)=>Y(`tr`,{children:r.map((n,r)=>Y(`td`,{children:en(e[r]??``,`r${t}c${r}`)},r))},t))})]})}),Y(`div`,{class:`foot`,children:[d>0&&Y(`span`,{children:n.table.more.replace(`{count}`,String(d))}),Y(`button`,{type:`button`,class:`copy`,onClick:u,children:s?n.table.copied:n.table.copy})]})]})}var un=[`:host{--w-bg:var(--sqc-bg,#fff);--w-surface:var(--sqc-surface,#f8fafc);--w-selected:var(--sqc-selected,#f1f5f9);--w-border:var(--sqc-border,#e2e8f0);--w-border-strong:var(--sqc-border-strong,#cbd5e1);--w-text:var(--sqc-text,#0f172a);--w-muted:var(--sqc-text-muted,#64748b);--w-accent:var(--sqc-accent-color,var(--sqc-accent,#000));--w-on-accent:var(--sqc-on-accent,#fff);--w-accent-hover:var(--sqc-accent-hover,color-mix(in oklab, var(--w-accent) 84%, var(--w-on-accent)));--w-focus:var(--sqc-focus,0 0 0 2px #fff, 0 0 0 4px #0f172a4d);--w-font:var(--sqc-font-family,system-ui, sans-serif);font-family:var(--w-font);display:block}:host([hidden]){display:none}button{color:inherit;font-family:inherit}button:focus-visible{box-shadow:var(--w-focus);outline:none}`,`.table{scrollbar-width:thin;margin:0 0 8px;overflow-x:auto}table{border-collapse:collapse;white-space:nowrap;min-width:100%;font-size:12.5px}th,td{text-align:left;vertical-align:top;border-bottom:1px solid color-mix(in srgb, currentColor 18%, transparent);padding:6px 10px 6px 0}thead th{text-transform:uppercase;letter-spacing:.05em;font-size:10.5px;font-weight:600}thead button{font:inherit;text-transform:inherit;letter-spacing:inherit;opacity:.7;cursor:pointer;background:0 0;border:0;padding:0}thead button:hover{opacity:1}tbody tr:last-child td{border-bottom:0}.foot{opacity:.8;align-items:center;gap:10px;font-size:11.5px;display:flex}.copy{border:1px solid var(--w-border);cursor:pointer;background:0 0;border-radius:8px;padding:2px 8px;font-size:11.5px}`,`.choices{flex-direction:column;gap:7px;margin:10px 0 2px;display:flex}.choice{text-align:left;width:100%;color:var(--w-text);background:var(--w-bg);border:1px solid var(--w-border);cursor:pointer;border-radius:12px;align-items:center;gap:8px;padding:8px 11px;font-size:12.5px;display:flex}.choice:hover:not(:disabled){border-color:var(--w-border-strong);background:var(--w-surface)}.choice:disabled{cursor:default}.choice:disabled[aria-pressed=false]{opacity:.55}.choice[aria-pressed=true]{border-color:var(--w-border-strong);background:var(--w-selected)}.box{border:1.5px solid var(--w-border-strong);border-radius:4px;flex:none;justify-content:center;align-items:center;width:15px;height:15px;display:inline-flex}.choices:not(:has(.send)) .box{border-radius:50%}.box.on{color:var(--w-on-accent);background:var(--w-accent);border-color:var(--w-accent)}.box svg{width:11px;height:11px}.label{overflow-wrap:anywhere}.send{background:var(--w-accent);height:32px;color:var(--w-on-accent);cursor:pointer;border:0;border-radius:12px;align-self:flex-end;padding:0 14px;font-size:13px;font-weight:600}.send:disabled{opacity:.4;cursor:default}`,`.confirm{flex-wrap:wrap;gap:8px;margin:11px 0 2px;display:flex}.confirm button{border:1px solid var(--w-border);background:var(--w-bg);height:32px;color:var(--w-text);cursor:pointer;border-radius:12px;flex:1 1 0;padding:0 12px;font-size:13px;font-weight:500}.confirm .other{flex-basis:100%}.confirm .yes:not(:disabled){background:var(--w-accent);color:var(--w-on-accent);border-color:#0000;font-weight:600}.confirm button:hover:not(:disabled){border-color:var(--w-border-strong);background:var(--w-surface)}.confirm .yes:hover:not(:disabled){background:var(--w-accent-hover);border-color:#0000}.confirm button:disabled{cursor:default}.confirm button:disabled:not([aria-pressed=true]){opacity:.45}.confirm button[aria-pressed=true]{border-color:var(--w-border-strong);background:var(--w-selected);color:var(--w-text);font-weight:600}`].join(`
4
- `);function dn(){if(typeof customElements>`u`)return;let e=[[qt.table,()=>Kt(ln,[`table`],un)],[qt.choices,()=>Kt(rn,[`options`,`multiple`,`checked`],un)],[qt.confirm,()=>Kt(an,[],un)]];for(let[t,n]of e)customElements.get(t)||customElements.define(t,n())}var fn=/^(?:mcp|custom|a2a)_[0-9a-f]{8}_/;function pn(e){let t=e.replace(fn,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):e}var mn=`chatbot-widgets.global.js`,hn=/(?:\/chatbot\.global\.js|\/@squadico\/chatbot(?:@[^/?#]*)?\/?)(?:[?#]|$)/;function gn(){let e=document.currentScript??Array.from(document.querySelectorAll(`script[src]`)).reverse().find(e=>hn.test(e.src));return{src:e?.src??``,nonce:e?.nonce??``}}var _n=typeof document<`u`?gn():{src:``,nonce:``};function vn(e){let t=new URL(e);return t.pathname.endsWith(`.js`)?new URL(mn,t).href:new URL(`dist/${mn}`,t.href.replace(/\/?$/,`/`)).href}function yn(e,t=``){return new Promise((n,r)=>{if(!e){r(Error(`Squadico chatbot: cannot locate its own script to load the widget extras.`));return}let i=document.createElement(`script`);i.src=vn(e),t&&(i.nonce=t),i.async=!0,i.onload=()=>n(),i.onerror=()=>{i.remove(),r(Error(`Squadico chatbot: failed to load ${i.src}.`))},document.head.append(i)})}function bn(e){let t;return()=>t??(t=e().catch(e=>{t=void 0,console.warn(e instanceof Error?e.message:e)}))}var xn=bn(()=>yn(_n.src,_n.nonce));function Sn(e,t){let n=t[e];return e===t.length-1&&n?.role===`assistant`&&!n.streaming}var Cn={fr:/\br[ée]ponde?z? +«?\s*oui\b/i,en:/\b(?:reply|answer|respond) +[“"']?\s*yes\b/i,es:/\bresponda?e?d? +«?\s*s[íi](?!\p{L})/iu},wn={fr:[/\b(?:confirmes?[- ]tu|confirmez[- ]vous)\b/i,/\b(?:valides?[- ]tu|validez[- ]vous)\b/i,/(?<!\p{L})(?:es[- ]tu s[ûu]re?|[êe]tes[- ]vous s[ûu]re?s?)(?!\p{L})/iu,/\b(?:dois[- ]je|puis[- ]je)\b/i,/\b(?:je continue|on continue|on y va|je lance)\b/i,Cn.fr],en:[/\bdo you confirm\b/i,/\bdo you (?:want|wish) me to\b/i,/\b(?:shall|should) I\b/i,/\bare you sure\b/i,/\b(?:shall we|should I) (?:proceed|continue|go ahead)\b/i,Cn.en],es:[/\b(?:confirmas|confirma|confirm[áa]is)\b/i,/\b(?:validas|valida|valid[áa]is)\b/i,/\best[áa]s? seguro\b/i,/\b(?:contin[úu]o|procedo|lo lanzo|lo hago)\b/i,/\bquieres? que\b/i,Cn.es]},Tn=/^\s*(?:[-*•]\s+)?(?:\[[ xX]\]|\([ xX]\))\s+/m,En=/[ \t]*\(\s*(?:yes|oui|s[íi])\s*\/\s*non?\s*\)\s*$/i;function Dn(e){return e.replace(En,``)}function On(e,t=`en`){if(Tn.test(e))return!1;let n=e.split(`
5
- `).map(e=>e.trim()).filter(Boolean),r=n[n.length-1];return r?En.test(r)?!0:!r.includes(`?`)&&!Cn[t].test(r)?!1:wn[t].some(e=>e.test(r)):!1}var kn=[`text`,`number`,`date`,`email`,`select`];function An(e){try{return JSON.parse(e)}catch{return null}}function jn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Mn(e){return!Array.isArray(e)||e.length===0||e.length>20||!e.every(e=>typeof e==`string`&&e.trim())?null:e}function Nn(e){if(!jn(e))return null;let{name:t,label:n,type:r}=e;if(typeof t!=`string`||!t.trim()||typeof n!=`string`||!n.trim()||typeof r!=`string`||!kn.includes(r))return null;let i={name:t,label:n,type:r,required:e.required===!0};if(r===`select`){let t=Mn(e.options);if(!t)return null;i.options=t}return i}function Pn(e){let t=An(e);if(!jn(t)||!Array.isArray(t.fields)||t.fields.length===0||t.fields.length>12)return null;let n=[];for(let e of t.fields){let t=Nn(e);if(!t||n.some(e=>e.name===t.name))return null;n.push(t)}let r={fields:n};return typeof t.title==`string`&&(r.title=t.title),typeof t.submit==`string`&&(r.submit=t.submit),r}var Fn=/^\s*(?:[-*•]\s+)?(?:\[([ xX])\]|\(([ xX])\))\s+(.+)$/,In=/^\s*\|.*\|\s*$/,Ln=/^\s*\|(?:\s*:?-{1,}:?\s*\|)+\s*$/,Rn=/^\s*```/;function zn(e){return e.replace(/^\s*\|/,``).replace(/\|\s*$/,``).split(`|`).map(e=>e.trim())}function Bn(e,t,n=!0){let r=n&&On(e,t),i=(r?Dn(e):e).split(`
1
+ var Chatbot=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h={},g=[],_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,v=Array.isArray;function y(e,t){for(var n in t)e[n]=t[n];return e}function b(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function x(e,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?t.call(arguments,2):r),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return S(e,s,i,a,null)}function S(e,t,i,a,o){var s={type:e,props:t,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++r,__i:-1,__u:0};return o==null&&n.vnode!=null&&n.vnode(s),s}function C(e){return e.children}function w(e,t){this.props=e,this.context=t}function T(e,t){if(t==null)return e.__?T(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?T(e):null}function E(e){if(e.__P&&e.__d){var t=e.__v,r=t.__e,i=[],a=[],o=y({},t);o.__v=t.__v+1,n.vnode&&n.vnode(o),L(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[r]:null,i,r??T(t),!!(32&t.__u),a),o.__v=t.__v,o.__.__k[o.__i]=o,te(i,o,a),t.__e=t.__=null,o.__e!=r&&D(o)}}function D(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),D(e)}function O(e){(!e.__d&&(e.__d=!0)&&i.push(e)&&!k.__r++||a!=n.debounceRendering)&&((a=n.debounceRendering)||o)(k)}function k(){try{for(var e,t=1;i.length;)i.length>t&&i.sort(s),e=i.shift(),t=i.length,E(e)}finally{i.length=k.__r=0}}function A(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,_,v,y=r&&r.__k||g,b=t.length;for(c=j(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||h,p.__i=d,v=L(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&R(f.ref,null,p),u.push(p.ref,p.__c||m,p)),_==null&&m!=null&&(_=m),4&p.__u?(c=M(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=_,c}function j(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=S(null,o,null,null,null):v(o)?o=e.__k[a]=S(C,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=S(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=N(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=T(s)),z(s,s));return r}function M(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=M(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=T(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function N(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function P(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||_.test(t)?n:n+`px`}function F(e,t,n,r,i){var a,o;n: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||P(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||P(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(d,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n[u]=r[u]:(n[u]=f,e.addEventListener(t,a?m:p,a)):e.removeEventListener(t,a?m:p,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function I(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t[l]==null)t[l]=f++;else if(t[l]<r[u])return;return r(n.event?n.event(t):t)}}}function L(e,t,r,i,a,o,s,c,l,u){var d,f,p,m,h,_,x,S,E,D,O,k,j,M,N,P,F=t.type;if(t.constructor!==void 0)return null;128&r.__u&&(l=!!(32&r.__u),o=[c=t.__e=r.__e]),(d=n.__b)&&d(t);n:if(typeof F==`function`){f=s.length;try{if(E=t.props,D=F.prototype&&F.prototype.render,O=(d=F.contextType)&&i[d.__c],k=d?O?O.props.value:d.__:i,r.__c?S=(p=t.__c=r.__c).__=p.__E:(D?t.__c=p=new F(E,k):(t.__c=p=new w(E,k),p.constructor=F,p.render=ie),O&&O.sub(p),p.state||(p.state={}),p.__n=i,m=p.__d=!0,p.__h=[],p._sb=[]),D&&p.__s==null&&(p.__s=p.state),D&&F.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=y({},p.__s)),y(p.__s,F.getDerivedStateFromProps(E,p.__s))),h=p.props,_=p.state,p.__v=t,m)D&&F.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),D&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(D&&F.getDerivedStateFromProps==null&&E!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(E,k),t.__v==r.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(E,p.__s,k)){t.__v!=r.__v&&(p.props=E,p.state=p.__s,p.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(e){e&&(e.__=t)}),g.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&s.push(p),c=T(r);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(E,p.__s,k),D&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,_,x)})}if(p.context=k,p.props=E,p.__P=e,p.__e=!1,j=n.__r,M=0,D)p.state=p.__s,p.__d=!1,j&&j(t),d=p.render(p.props,p.state,p.context),g.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,j&&j(t),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++M<25);p.state=p.__s,p.getChildContext!=null&&(i=y(y({},i),p.getChildContext())),D&&!m&&p.getSnapshotBeforeUpdate!=null&&(x=p.getSnapshotBeforeUpdate(h,_)),N=d!=null&&d.type===C&&d.key==null?ne(d.props.children):d,c=A(e,v(N)?N:[N],t,r,i,a,o,s,c,l,u),p.base=t.__e,t.__u&=-161,p.__h.length&&s.push(p),S&&(p.__E=p.__=null)}catch(e){if(s.length=f,t.__v=null,l||o!=null){if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o!=null&&(o[o.indexOf(c)]=null),t.__e=c}else if(o!=null)for(P=o.length;P--;)b(o[P])}else t.__e=r.__e;t.__k??(t.__k=r.__k||[]),e.then||ee(t),n.__e(e,t,r)}}else o==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):c=t.__e=re(r.__e,t,r,i,a,o,s,l,u);return(d=n.diffed)&&d(t),128&t.__u?void 0:c}function ee(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ee))}function te(e,t,r){for(var i=0;i<r.length;i++)R(r[i],r[++i],r[++i]);n.__c&&n.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){n.__e(e,t.__v)}})}function ne(e){return typeof e!=`object`||!e||e.__b>0?e:v(e)?e.map(ne):e.constructor===void 0?y({},e):null}function re(e,r,i,a,o,s,c,l,u){var d,f,p,m,g,_,y,x=i.props||h,S=r.props,C=r.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||(o=`http://www.w3.org/1999/xhtml`),s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!C&&(C?g.localName==C:g.nodeType==3)){e=g,s[d]=null;break}}if(e==null){if(C==null)return document.createTextNode(S);e=document.createElementNS(o,C,S.is&&S),l&&(n.__m&&n.__m(r,s),l=!1),s=null}if(C==null)x===S||l&&e.data==S||(e.data=S);else{if(s=C==`textarea`&&S.defaultValue!=null?null:s&&t.call(e.childNodes),!l&&s!=null)for(x={},d=0;d<e.attributes.length;d++)x[(g=e.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||F(e,d,null,g,o);for(d in S)g=S[d],d==`children`?m=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?_=g:d==`checked`?y=g:l&&typeof g!=`function`||x[d]===g||F(e,d,g,x[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),r.__k=[];else if(p&&(e.innerHTML=``),A(r.type==`template`?e.content:e,v(m)?m:[m],r,i,a,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&T(i,0),l,u),s!=null)for(d=s.length;d--;)b(s[d]);l&&C!=`textarea`||(d=`value`,C==`progress`&&_==null?e.removeAttribute(`value`):_!=null&&(_!==e[d]||C==`progress`&&!_||C==`option`&&_!=x[d])&&F(e,d,_,x[d],o),d=`checked`,y!=null&&y!=e[d]&&F(e,d,y,x[d],o))}return e}function R(e,t,r){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(e){n.__e(e,r)}}function z(e,t,r){var i,a;if(n.unmount&&n.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||R(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){n.__e(e,t)}i.base=i.__P=i.__n=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&z(i[a],t,r||typeof e.type!=`function`);r||b(e.__e),e.__c=e.__=e.__e=void 0}function ie(e,t,n){return this.constructor(e,n)}function B(e,r,i){var a,o,s,c;r==document&&(r=document.documentElement),n.__&&n.__(e,r),o=(a=typeof i==`function`)?null:i&&i.__k||r.__k,s=[],c=[],L(r,e=(!a&&i||r).__k=x(C,null,[e]),o||h,h,r.namespaceURI,!a&&i?[i]:o?null:r.firstChild?t.call(r.childNodes):null,s,!a&&i?i:o?o.__e:r.firstChild,a,c),te(s,e,c),e.props.children=null}t=g.slice,n={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},r=0,w.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=y({},this.state);typeof e==`function`&&(e=e(y({},n),this.props)),e&&y(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),O(this))},w.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),O(this))},w.prototype.render=C,i=[],o=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,s=function(e,t){return e.__v.__b-t.__v.__b},k.__r=0,c=Math.random().toString(8),l=`__d`+c,u=`__a`+c,d=/(PointerCapture)$|Capture$/i,f=0,p=I(!1),m=I(!0);var V,H,ae,oe,se=0,ce=[],U=n,le=U.__b,ue=U.__r,de=U.diffed,fe=U.__c,pe=U.unmount,me=U.__;function he(e,t){U.__h&&U.__h(H,e,se||t),se=0;var n=H.__H||(H.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function W(e){return se=1,ge(Te,e)}function ge(e,t,n){var r=he(V++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Te(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=H,!H.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};H.__f=!0;var a=H.shouldComponentUpdate,o=H.componentWillUpdate;H.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},H.shouldComponentUpdate=i}return r.__N||r.__}function G(e,t){var n=he(V++,3);!U.__s&&we(n.__H,t)&&(n.__=e,n.u=t,H.__H.__h.push(n))}function _e(e,t){var n=he(V++,4);!U.__s&&we(n.__H,t)&&(n.__=e,n.u=t,H.__h.push(n))}function K(e){return se=5,ve(function(){return{current:e}},[])}function ve(e,t){var n=he(V++,7);return we(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function q(e,t){return se=8,ve(function(){return e},t)}function ye(){for(var e;e=ce.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Se),t.__h.some(Ce),t.__h=[]}catch(n){t.__h=[],U.__e(n,e.__v)}}}U.__b=function(e){H=null,le&&le(e)},U.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),me&&me(e,t)},U.__r=function(e){ue&&ue(e),V=0;var t=(H=e.__c).__H;t&&(ae===H?(t.__h=[],H.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Se),t.__h.some(Ce),t.__h=[],V=0)),ae=H},U.diffed=function(e){de&&de(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ce.push(t)!==1&&oe===U.requestAnimationFrame||((oe=U.requestAnimationFrame)||xe)(ye)),t.__H.__.some(function(e){e.u&&(e.__H=e.u,e.u=void 0)})),ae=H=null},U.__c=function(e,t){t.some(function(e){try{e.__h.some(Se),e.__h=e.__h.filter(function(e){return!e.__||Ce(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],U.__e(n,e.__v)}}),fe&&fe(e,t)},U.unmount=function(e){pe&&pe(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Se(e)}catch(e){t=e}}),n.__H=void 0,t&&U.__e(t,n.__v))};var be=typeof requestAnimationFrame==`function`;function xe(e){var t,n=function(){clearTimeout(r),be&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);be&&(t=requestAnimationFrame(n))}function Se(e){var t=H,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),H=t}function Ce(e){var t=H;e.__c=e.__(),H=t}function we(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Te(e,t){return typeof t==`function`?t(e):t}var Ee=new Set([`sessionId`]);function De(e){if(typeof e==`string`)return e.length>0?{id:e}:void 0;if(!e||typeof e!=`object`||Array.isArray(e))return;let{id:t,name:n}=e;if(typeof t==`string`&&t.length!==0)return typeof n==`string`&&n.length>0?{id:t,name:n}:{id:t}}function Oe(e){let t=De(e);if(t)return t.name??t.id}function ke(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Ae(e){let t={};for(let[n,r]of Object.entries(e)){if(Ee.has(n)||!ke(r)){t[n]=r;continue}let e=De(r);e&&(t[`${n}Id`]=e.id,e.name&&(t[`${n}Name`]=e.name))}return t}var je=`en`,Me=[`en`,`fr`,`es`],Ne={en:{heading:`Assistant`,subheading:`Squadico`,placeholder:`Ask your question…`,greeting:`Hello! I am your assistant. What would you like to do?`,hint:`The assistant proposes an action; nothing is applied without your confirmation.`,assistant:`Assistant`,typing:`The assistant is writing its answer`,activity:{knowledge:`Searching the knowledge base…`,skill:`Following a procedure…`,delegation:`Asking a colleague…`,tool:`Looking it up…`},newConversation:`New conversation`,close:`Close the assistant`,closeTitle:`Close`,history:{open:`Conversation history`,menu:`Previous conversations`,loading:`Loading…`,empty:`No previous conversation.`,untitled:`Conversation`},context:{region:`Context sent to the assistant`},approval:{group:`Write confirmation`,approve:`Yes, apply`,reject:`No, cancel`,request:`The agent wants to use {tool}.`,arguments:`With`,edit:`Change…`,correction:`What to change — e.g. “the due date is next Monday”`,correctionLabel:`Correction to make before approving`,send:`Send`},confirm:{group:`Confirmation`,yes:`Yes`,no:`No`,yesValue:`yes`,noValue:`no`,other:`Propose something else`},choices:`Suggested options`,table:{copy:`Copy`,copied:`Copied`,more:`{count} more rows`},form:{submit:`Send`,required:`Required`,email:`Enter a valid email address`,number:`Enter a number`},poweredBy:`Powered by Squadico`,handles:{picker:`Agents you can address`,unknown:`Nobody answers to that name here:`,instead:`You can address:`,rail:`Agents`},selection:{group:`Suggested choice`,single:`Pick one option.`,multiple:`Pick one or more options, then validate.`,validate:`Validate`},composer:{label:`Your message`,send:`Send the message`,sendTitle:`Send`,stop:`Stop the answer`,stopTitle:`Stop`,attach:`Attach a file`,attachTitle:`Attach`,remove:`Remove {name}`},attachments:{unsupported:`This kind of file cannot be attached to a message.`,tooLarge:`This file is too large.`,tooMany:`This message already carries as many files as it may.`,unreadable:`This file could not be read.`,failed:`This file could not be attached.`},error:`Something went wrong, the assistant could not answer. Try again in a moment.`,withHuman:`A member of the team will reply to you here.`},fr:{heading:`Assistant`,subheading:`Squadico`,placeholder:`Posez votre question…`,greeting:`Bonjour ! Je suis votre assistant. Que souhaitez-vous faire ?`,hint:`L'assistant propose une action ; rien n'est appliqué sans votre confirmation.`,assistant:`Assistant`,typing:`L'assistant rédige sa réponse`,activity:{knowledge:`Recherche dans la base de connaissances…`,skill:`Application d'une procédure…`,delegation:`Consultation d'un collègue…`,tool:`Recherche en cours…`},newConversation:`Nouvelle conversation`,close:`Fermer l'assistant`,closeTitle:`Fermer`,history:{open:`Historique des conversations`,menu:`Conversations précédentes`,loading:`Chargement…`,empty:`Aucune conversation précédente.`,untitled:`Conversation`},context:{region:`Contexte transmis à l'assistant`},approval:{group:`Validation de l'écriture`,approve:`Oui, appliquer`,reject:`Non, annuler`,request:`L'agent souhaite utiliser {tool}.`,arguments:`Avec`,edit:`Modifier…`,correction:`Ce qu'il faut changer — ex. « l'échéance est lundi prochain »`,correctionLabel:`Correction à apporter avant validation`,send:`Envoyer`},confirm:{group:`Confirmation`,yes:`Oui`,no:`Non`,yesValue:`oui`,noValue:`non`,other:`Proposer autre chose`},choices:`Options proposées`,table:{copy:`Copier`,copied:`Copié`,more:`{count} lignes de plus`},form:{submit:`Envoyer`,required:`Obligatoire`,email:`Saisissez une adresse e-mail valide`,number:`Saisissez un nombre`},poweredBy:`Propulsé par Squadico`,handles:{picker:`Agents que vous pouvez adresser`,unknown:`Personne ne répond à ce nom ici :`,instead:`Vous pouvez adresser :`,rail:`Agents`},selection:{group:`Choix proposé`,single:`Sélectionnez une option.`,multiple:`Sélectionnez une ou plusieurs options, puis validez.`,validate:`Valider`},composer:{label:`Votre message`,send:`Envoyer le message`,sendTitle:`Envoyer`,stop:`Interrompre la réponse`,stopTitle:`Interrompre`,attach:`Joindre un fichier`,attachTitle:`Joindre`,remove:`Retirer {name}`},attachments:{unsupported:`Ce format de fichier ne peut pas être joint à un message.`,tooLarge:`Ce fichier est trop volumineux.`,tooMany:`Ce message porte déjà autant de fichiers qu'il le peut.`,unreadable:`Ce fichier n'a pas pu être lu.`,failed:`Impossible de joindre ce fichier.`},error:`Une erreur est survenue, l'assistant n'a pas pu répondre. Réessayez dans un instant.`,withHuman:`Un membre de l'équipe va vous répondre ici.`},es:{heading:`Asistente`,subheading:`Squadico`,placeholder:`Haga su pregunta…`,greeting:`¡Hola! Soy su asistente. ¿Qué desea hacer?`,hint:`El asistente propone una acción; no se aplica nada sin su confirmación.`,assistant:`Asistente`,typing:`El asistente está redactando su respuesta`,activity:{knowledge:`Buscando en la base de conocimientos…`,skill:`Siguiendo un procedimiento…`,delegation:`Consultando a un compañero…`,tool:`Consultando…`},newConversation:`Nueva conversación`,close:`Cerrar el asistente`,closeTitle:`Cerrar`,history:{open:`Historial de conversaciones`,menu:`Conversaciones anteriores`,loading:`Cargando…`,empty:`Ninguna conversación anterior.`,untitled:`Conversación`},context:{region:`Contexto enviado al asistente`},approval:{group:`Validación de la escritura`,approve:`Sí, aplicar`,reject:`No, cancelar`,request:`El agente quiere usar {tool}.`,arguments:`Con`,edit:`Modificar…`,correction:`Lo que hay que cambiar — p. ej. «el vencimiento es el lunes»`,correctionLabel:`Corrección antes de validar`,send:`Enviar`},confirm:{group:`Confirmación`,yes:`Sí`,no:`No`,yesValue:`sí`,noValue:`no`,other:`Proponer otra cosa`},choices:`Opciones propuestas`,table:{copy:`Copiar`,copied:`Copiado`,more:`{count} filas más`},form:{submit:`Enviar`,required:`Obligatorio`,email:`Introduzca un correo electrónico válido`,number:`Introduzca un número`},poweredBy:`Con la tecnología de Squadico`,handles:{picker:`Agentes a los que puedes dirigirte`,unknown:`Nadie responde a ese nombre aquí:`,instead:`Puedes dirigirte a:`,rail:`Agentes`},selection:{group:`Opción propuesta`,single:`Seleccione una opción.`,multiple:`Seleccione una o varias opciones y valide.`,validate:`Validar`},composer:{label:`Su mensaje`,send:`Enviar el mensaje`,sendTitle:`Enviar`,stop:`Interrumpir la respuesta`,stopTitle:`Interrumpir`,attach:`Adjuntar un archivo`,attachTitle:`Adjuntar`,remove:`Quitar {name}`},attachments:{unsupported:`Este tipo de archivo no se puede adjuntar a un mensaje.`,tooLarge:`Este archivo es demasiado grande.`,tooMany:`Este mensaje ya lleva todos los archivos que puede llevar.`,unreadable:`No se ha podido leer este archivo.`,failed:`No se ha podido adjuntar este archivo.`},error:`Se ha producido un error, el asistente no ha podido responder. Inténtelo de nuevo.`,withHuman:`Un miembro del equipo le responderá aquí.`}},Pe={en:`en-GB`,fr:`fr-FR`,es:`es-ES`};function Fe(e){let t=e?.trim().toLowerCase().split(/[-_]/)[0];return t&&t in Ne?t:void 0}function Ie(){return typeof navigator>`u`?[]:navigator.languages?.length?navigator.languages:[navigator.language]}function Le(e){let t=e?.trim(),n=(t?[t]:Ie()).find(Fe),r=Fe(n)??`en`;return{code:r,tag:n?.includes(`-`)?n:Pe[r],t:Ne[r]}}var Re=`squadico-chatbot:open`;function ze(){try{if(typeof sessionStorage>`u`)return;let e=sessionStorage.getItem(Re);return e===`1`||e!==`0`&&void 0}catch{return}}function Be(e){try{if(typeof sessionStorage>`u`)return;sessionStorage.setItem(Re,e?`1`:`0`)}catch{}}function Ve(e,t){return t===!1?e??!1:ze()??e??!1}function He(){let e=globalThis.crypto;if(e&&typeof e.randomUUID==`function`)return e.randomUUID();let t=new Uint8Array(16);if(e&&typeof e.getRandomValues==`function`)e.getRandomValues(t);else for(let e=0;e<16;e++)t[e]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=[];for(let e=0;e<16;e++)n.push(t[e].toString(16).padStart(2,`0`));return n.slice(0,4).join(``)+`-`+n.slice(4,6).join(``)+`-`+n.slice(6,8).join(``)+`-`+n.slice(8,10).join(``)+`-`+n.slice(10,16).join(``)}function Ue(e){"@babel/helpers - typeof";return Ue=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},Ue(e)}function We(e,t){if(Ue(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Ue(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ge(e){var t=We(e,`string`);return Ue(t)==`symbol`?t:t+``}function Ke(e,t,n){return(t=Ge(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var qe=`https://api.squadico.com`,Je=2e4,J=class extends Error{constructor(e,t,n){super(e),Ke(this,`status`,void 0),Ke(this,`code`,void 0),this.name=`ChatHttpError`,this.status=t,this.code=n}};function Ye(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim()!==``):[]}function Xe(e,t){return`${e.replace(/\/+$/,``)}${t}`}function Ze(e,t){return{"Content-Type":`application/json`,Accept:`text/event-stream, application/json`,...e?{"X-Visitor-Token":e}:{},...t?{"X-Subject-Token":t}:{}}}function Qe(e){if(!e||typeof e!=`object`)return;let{loc:t,msg:n}=e;if(typeof n!=`string`||!n)return;let r=(Array.isArray(t)?t.filter(e=>typeof e==`string`):[]).at(-1);return r&&r!==`body`?`${r}: ${n}`:n}async function $e(e){let t=``,n;try{let r=await e.text();if(r)try{let e=JSON.parse(r),i=e.detail??e.message;if(Array.isArray(i)){let e=i.map(e=>Qe(e)??(typeof e==`string`?e:void 0)).filter(e=>e!==void 0);t=e.length>0?e.join(`, `):r}else t=typeof i==`string`?i:r;n=typeof e.code==`string`?e.code:void 0}catch{t=r}}catch{}return new J(t||`The API answered ${e.status}`,e.status,n)}function et(e,t){if(!e||typeof e!=`object`)return;let n=e;if(!(typeof n.handle!=`string`||!n.handle))return{handle:n.handle,name:typeof n.name==`string`?n.name:n.handle,avatarUrl:typeof n.avatar_url==`string`&&n.avatar_url?Xe(t,n.avatar_url):void 0,color:typeof n.color==`string`?n.color:void 0}}function tt(e,t){return(Array.isArray(e)?e:[]).map(e=>et(e,t)).filter(e=>e!==void 0)}var nt=[`knowledge`,`skill`,`delegation`,`tool`];function rt(e){return nt.find(t=>t===e)??`tool`}function it(e){if(!e||typeof e!=`object`)return;let t=e;if(!(typeof t.tool_call_id!=`string`||!t.tool_call_id))return{toolCallId:t.tool_call_id,tool:typeof t.tool==`string`?t.tool:``,arguments:t.arguments&&typeof t.arguments==`object`?t.arguments:{}}}var at=new Set([`user`,`assistant`]);function ot(e,t){if(typeof e.role!=`string`||!at.has(e.role)||typeof e.content!=`string`||!e.content)return null;let n=typeof e.created_at==`string`?Date.parse(e.created_at):NaN;return{id:typeof e.id==`string`&&e.id?e.id:He(),role:e.role,content:e.content,createdAt:Number.isNaN(n)?Date.now():n,agent:et(e.agent,t),attachments:st(e.attachments),authorName:e.kind===`human`&&typeof e.author_name==`string`&&e.author_name?e.author_name:void 0}}function st(e){if(!Array.isArray(e))return;let t=e.map(e=>ct(e)).filter(e=>e!==null);return t.length>0?t:void 0}function ct(e){if(!e||typeof e!=`object`)return null;let{id:t,kind:n,filename:r,content_type:i}=e;return typeof t!=`string`||!t||typeof r!=`string`||!r?null:{id:t,kind:n===`image`||n===`chart`?n:`document`,filename:r,contentType:typeof i==`string`?i:`application/octet-stream`}}async function lt(e){let t=e.agent?`?agent=${encodeURIComponent(e.agent)}`:``,n=await fetch(Xe(e.apiUrl,`/public/applications/${encodeURIComponent(e.embedKey)}${t}`),{method:`GET`,headers:Ze(),signal:e.signal});if(!n.ok)throw await $e(n);let r=await n.json();return{welcomeMessage:typeof r.welcome_message==`string`&&r.welcome_message?r.welcome_message:void 0,welcomeSuggestions:Ye(r.welcome_suggestions),agent:et(r.agent,e.apiUrl),handles:tt(r.handles,e.apiUrl),agentHandle:typeof r.agent_handle==`string`&&r.agent_handle?r.agent_handle:void 0,branding:r.branding===!0}}async function ut(e){let t=await fetch(Xe(e.apiUrl,`/public/applications/${encodeURIComponent(e.embedKey)}/conversations`),{method:`POST`,headers:Ze(),body:JSON.stringify({...e.user?{user:e.user}:{},...e.agent?{agent:e.agent}:{}}),signal:e.signal});if(!t.ok)throw await $e(t);let n=await t.json();if(typeof n.id!=`string`||typeof n.visitor_token!=`string`)throw new J(`The API opened a conversation without an id or a token`);let r=(Array.isArray(n.messages)?n.messages:[]).map(t=>ot(t,e.apiUrl)).filter(e=>e!==null);return{conversationId:n.id,visitorToken:n.visitor_token,agentName:typeof n.agent_name==`string`?n.agent_name:``,agentSlug:typeof n.agent_slug==`string`?n.agent_slug:``,welcomeMessage:typeof n.welcome_message==`string`&&n.welcome_message?n.welcome_message:void 0,welcomeSuggestions:Ye(n.welcome_suggestions),messages:r,handles:tt(n.handles,e.apiUrl),agentHandle:typeof n.agent_handle==`string`&&n.agent_handle?n.agent_handle:void 0,withHuman:typeof n.handling==`string`&&n.handling!==`agents`,branding:n.branding===!0}}async function dt(e){let t=await fetch(Xe(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}`),{method:`GET`,headers:Ze(e.visitorToken),signal:e.signal});if(!t.ok)throw await $e(t);let n=await t.json();if(typeof n.id!=`string`)throw new J(`The API replayed a conversation without an id`);return{conversationId:n.id,visitorToken:e.visitorToken,agentName:typeof n.agent_name==`string`?n.agent_name:``,agentSlug:typeof n.agent_slug==`string`?n.agent_slug:``,welcomeMessage:typeof n.welcome_message==`string`&&n.welcome_message?n.welcome_message:void 0,welcomeSuggestions:Ye(n.welcome_suggestions),messages:(Array.isArray(n.messages)?n.messages:[]).map(t=>ot(t,e.apiUrl)).filter(e=>e!==null),handles:tt(n.handles,e.apiUrl),agentHandle:typeof n.agent_handle==`string`&&n.agent_handle?n.agent_handle:void 0,withHuman:typeof n.handling==`string`&&n.handling!==`agents`,branding:n.branding===!0}}async function ft(e){let t=new FormData;t.append(`file`,e.file);let n=await fetch(ht(e),{method:`POST`,headers:{"X-Visitor-Token":e.visitorToken},body:t,signal:e.signal});if(!n.ok)throw await $e(n);let r=ct(await n.json());if(!r)throw new J(`The upload could not be read`,n.status);return r}async function pt(e){let t=await fetch(`${ht(e)}/${encodeURIComponent(e.attachmentId)}`,{method:`DELETE`,headers:{"X-Visitor-Token":e.visitorToken},signal:e.signal});if(!t.ok)throw await $e(t)}async function mt(e){let t=await fetch(`${ht(e)}/${encodeURIComponent(e.attachmentId)}/content`,{headers:{"X-Visitor-Token":e.visitorToken},signal:e.signal});if(!t.ok)throw await $e(t);return t.blob()}function ht(e){return Xe(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/attachments`)}async function gt(e){return vt(Xe(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/messages`),{content:e.message,attachment_ids:e.attachmentIds??[],...e.context&&Object.keys(e.context).length>0?{context:e.context}:{}},e)}async function _t(e){return vt(Xe(e.apiUrl,`/public/conversations/${encodeURIComponent(e.conversationId)}/approvals`),{tool_call_id:e.toolCallId,approved:e.approved},e)}async function vt(e,t,n){let r=await fetch(e,{method:`POST`,headers:Ze(n.visitorToken,n.subjectToken),body:JSON.stringify({...t,widgets:1}),signal:n.signal});if(!r.ok)throw await $e(r);if(!r.body)throw new J(`Answer with no stream body`);let i=r.body.getReader(),a=new TextDecoder,o=``,s=``,c=``,l,u,d={answer:``};try{for(;;){let{value:e,done:t}=await i.read();if(t)break;o+=a.decode(e,{stream:!0});let r=o.split(`
2
+ `);o=r.pop()??``;for(let e of r){let t=e.trim();if(!t){s=``;continue}if(t.startsWith(`event:`)){s=t.slice(6).trim();continue}if(!t.startsWith(`data:`))continue;let r=t.slice(5).trim();if(!r)continue;let i;try{i=JSON.parse(r)}catch{continue}s===`token`&&typeof i.text==`string`?(c+=i.text,n.onToken(i.text)):s===`progress`?n.onProgress?.(rt(i.activity)):s===`done`?(d.answer=typeof i.content==`string`?i.content:c,d.agent=et(i.agent,n.apiUrl),typeof i.unknown_handle==`string`&&i.unknown_handle&&(d.unknownHandle=i.unknown_handle,d.offered=tt(i.handles,n.apiUrl))):s===`handoff`?(typeof i.to_agent_name==`string`&&(u=i.to_agent_name),c=``):s===`escalated`?d.withHuman=!0:s===`held`?(d.held=!0,d.withHuman=!0):s===`approval_required`?d.approval=it(i):s===`error`&&(l=typeof i.detail==`string`?i.detail:`The turn failed`)}if(l)break}}finally{i.cancel().catch(()=>void 0)}if(l)throw new J(l);return!d.answer&&!d.approval&&(d.answer=c),u&&!d.agent&&(d.authorName=u),d}var yt=`squadico-chatbot:conversation`;function bt(){try{if(typeof sessionStorage>`u`)return;let e=sessionStorage.getItem(yt);if(!e)return;let t=JSON.parse(e);return t&&typeof t==`object`?t:void 0}catch{return}}function xt(e){try{if(typeof sessionStorage>`u`)return;sessionStorage.setItem(yt,JSON.stringify(e))}catch{}}function St(e){if(!e||typeof e!=`object`)return;let{sessionId:t,visitorToken:n}=e;return typeof t==`string`&&t&&typeof n==`string`&&n?{sessionId:t,visitorToken:n}:void 0}function Ct(e){let t=bt();if(!t||typeof t.embedKey!=`string`||!t.embedKey)return;let n=typeof t.agent==`string`?t.agent:void 0,r=St(e===void 0||n===void 0||e===n?t:t.threads?.[e]);if(r)return{...r,embedKey:t.embedKey,user:typeof t.user==`string`?t.user:void 0,scope:typeof t.scope==`string`?t.scope:void 0,agent:e??n}}function wt(e){let t=bt(),n=t&&Et(t,e)?t.threads??{}:{},r=e.agent?{...n,[e.agent]:{sessionId:e.sessionId,visitorToken:e.visitorToken}}:n;xt({...e,threads:r})}function Tt(e){if(e!==void 0){let t=bt();if(!t)return;let n={...t.threads??{}};delete n[e],xt(t.agent===void 0||t.agent===e?{embedKey:t.embedKey,user:t.user,scope:t.scope,threads:n}:{...t,threads:n});return}try{if(typeof sessionStorage>`u`)return;sessionStorage.removeItem(yt)}catch{}}function Et(e,{embedKey:t,user:n,scope:r}){return e.embedKey===t&&e.user===n&&e.scope===r}async function Dt(e){if(e)try{return await e()||void 0}catch{return}}var Ot=`preview-welcome`;function kt(e,t){return e===void 0&&t===void 0?void 0:JSON.stringify([e,t])}function At(e){let t=e instanceof J?e.status:void 0;return t===415?`unsupported`:t===413?`tooLarge`:t===409?`tooMany`:t===422?`unreadable`:`failed`}var jt=5e3;function Mt(e){return e instanceof J&&e.code===`conversation_retired`}function Nt(e){let[t,n]=W([]),[r,i]=W(!1),[a,o]=W(``),[s,c]=W(0),[l,u]=W([]),[d,f]=W(``),[p,m]=W(``),[h,g]=W(null),[_,v]=W([]),[y,b]=W(!1),[x,S]=W(!1),[C,w]=W([]),[T,E]=W([]),[D,O]=W(null),k=K(null),A=K(e);A.current=e;let j=K(null),M=K(null),N=K(null),P=K(null),F=K(void 0),I=K(void 0),L=K(void 0),ee=K(new Map),te=K({conversation:null,messages:[],welcomeSuggestions:[],approval:null,withHuman:!1,attachments:[]});te.current={conversation:M.current,messages:t,welcomeSuggestions:_,approval:h,withHuman:y,attachments:C};let ne=e.greeting,re=ve(()=>ne?{id:`greeting`,role:`assistant`,content:ne,createdAt:Date.now()}:null,[ne]),R=q(e=>{A.current.onEvent?.(e)},[]),z=q((e,t)=>{n(n=>n.map(n=>n.id===e?{...n,...t}:n))},[]),ie=q((e,t)=>{let n=e instanceof J?e.status:void 0,r=e instanceof Error?e.message:String(e),i=(A.current.locale??Le(void 0)).t.error;t&&z(t,{content:i,streaming:!1,error:!0,activity:void 0}),R({type:`chatbot-error`,message:r,status:n,sessionId:M.current?.sessionId??``}),typeof console<`u`&&console.error(`[squadico-chatbot]`,r)},[R,z]),B=q(()=>{let e=A.current;if(!e.embedKey)throw new J(`No embed key: nothing says which application to open`);return{opts:e,apiUrl:e.apiUrl??`https://api.squadico.com`,embedKey:e.embedKey,claim:e.user,scope:e.scope}},[]),V=q((e,t,r)=>{let i={sessionId:t.conversationId,visitorToken:t.visitorToken};M.current=i,F.current=kt(e.claim?.id,e.scope);let a=r??I.current??t.agentHandle;return I.current=a,L.current??(L.current=a),wt({...i,embedKey:e.embedKey,user:e.claim?.id,scope:e.scope,agent:a}),o(t.conversationId),u(t.handles),f(e.opts.agent&&t.agentHandle?t.agentHandle:``),m(a??``),v(t.welcomeSuggestions),b(!!t.withHuman),S(t.branding),n(e=>[...t.messages,...e.filter(e=>e.id!==Ot)]),i},[]),H=q(e=>{if(N.current)return N.current;let t=I.current,n=Ct(t);if(!n||!Et(n,{embedKey:e.embedKey,user:e.claim?.id,scope:e.scope}))return Promise.resolve(null);let r=dt({apiUrl:e.apiUrl,conversationId:n.sessionId,visitorToken:n.visitorToken}).then(r=>I.current===t?V(e,r,n.agent):null).catch(()=>(Tt(n.agent),null)).finally(()=>{N.current=null});return N.current=r,r},[V]),ae=q(async()=>{if(M.current)return M.current;if(j.current)return j.current;let e=B(),t=H(e).then(t=>t??ut({apiUrl:e.apiUrl,embedKey:e.embedKey,user:e.claim,agent:I.current&&I.current!==L.current?I.current:e.opts.agent}).then(t=>V(e,t)));j.current=t;try{return await t}finally{j.current=null}},[V,H,B]),oe=q(()=>{if(M.current||j.current||P.current)return;let e;try{e=B()}catch(e){ie(e);return}let t=I.current,r=H(e).then(async r=>{if(r||M.current||j.current)return;let i=await lt({apiUrl:e.apiUrl,embedKey:e.embedKey,agent:t??e.opts.agent});if(M.current||j.current||I.current!==t)return;I.current=t??i.agentHandle,L.current??(L.current=I.current),u(i.handles),f(e.opts.agent&&i.agentHandle?i.agentHandle:``),m(I.current??``),v(i.welcomeSuggestions),S(i.branding);let a=i.welcomeMessage;a&&n(e=>e.length>0?e:[{id:Ot,role:`assistant`,content:a,createdAt:Date.now(),agent:i.agent}])});P.current=r,r.catch(e=>{P.current=null,ie(e)})},[ie,H,B]),se=q((e,t,{retry:r=!1,carried:a=[]}={})=>{if(k.current)return;let o=new AbortController;k.current=o,i(!0),g(null);let s=He();n(t=>[...t,{id:He(),role:`user`,content:e,createdAt:Date.now(),attachments:a.length>0?a:void 0},{id:s,role:`assistant`,content:``,createdAt:Date.now(),streaming:!0}]),(async()=>{let i=await ae();R({type:`chatbot-message`,role:`user`,content:e,sessionId:i.sessionId});let a=``,c=e=>{a+=e,z(s,{content:a,activity:void 0})},l=e=>{a||z(s,{activity:e})},u;try{u=await t(i,c,o.signal,l)}catch(e){if(!Mt(e)||(Tt(I.current),M.current=null,j.current=null,!r))throw e;i=await ae(),a=``,z(s,{content:``,activity:void 0}),u=await t(i,c,o.signal,l)}if(u.withHuman&&b(!0),u.held){n(e=>e.filter(e=>e.id!==s));return}z(s,{content:u.answer,streaming:!1,activity:void 0,agent:u.agent,authorName:u.authorName,approval:u.approval,unknownHandle:u.unknownHandle,offered:u.offered}),g(u.approval??null),R({type:`chatbot-message`,role:`assistant`,content:u.answer,sessionId:i.sessionId,agent:u.agent?.handle})})().catch(e=>{if(o.signal.aborted){z(s,{streaming:!1,activity:void 0});return}ie(e,s)}).finally(()=>{k.current=null,i(!1)})},[ae,R,ie,z]),ce=q(e=>{let t=e.trim();if(!t&&C.length===0)return;let n=C;w([]),O(null),se(t,async(e,r,i,a)=>gt({subjectToken:await Dt(A.current.getSubjectToken),apiUrl:A.current.apiUrl??`https://api.squadico.com`,conversationId:e.sessionId,visitorToken:e.visitorToken,message:t,attachmentIds:n.map(e=>e.id),context:A.current.context?Ae(A.current.context):void 0,onToken:r,onProgress:a,signal:i}),{retry:!0,carried:n})},[C,se]),U=q(e=>{O(null),E(t=>[...t,e.name]),ae().then(t=>ft({apiUrl:A.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,file:e})).then(e=>w(t=>[...t,e])).catch(e=>O(At(e))).finally(()=>E(t=>{let n=t.indexOf(e.name);return n<0?t:[...t.slice(0,n),...t.slice(n+1)]}))},[ae]),le=q(e=>{w(t=>t.filter(t=>t.id!==e));let t=M.current;t&&pt({apiUrl:A.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,attachmentId:e}).catch(()=>{})},[]),ue=q(async e=>{let t=M.current;if(!t)throw new J(`No conversation to read that file from`);return mt({apiUrl:A.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,attachmentId:e})},[]),de=q((e,t)=>{let n=h;n&&se(t,async(t,r,i,a)=>_t({subjectToken:await Dt(A.current.getSubjectToken),apiUrl:A.current.apiUrl??`https://api.squadico.com`,conversationId:t.sessionId,visitorToken:t.visitorToken,toolCallId:n.toolCallId,approved:e,onToken:r,onProgress:a,signal:i}))},[h,se]),fe=q(()=>{k.current?.abort(),k.current=null,i(!1)},[]),pe=q(()=>{k.current?.abort(),k.current=null,M.current=null,j.current=null,N.current=null,P.current=null,F.current=void 0,ee.current.clear(),Tt(),i(!1),g(null),b(!1),o(``),c(e=>e+1),f(``),w([]),n([]),v([]),R({type:`chatbot-reset`,sessionId:``})},[R]),me=q(e=>{if(k.current||j.current||e===I.current)return;I.current!==void 0&&ee.current.set(I.current,te.current),I.current=e,m(e),O(null);let t=ee.current.get(e);if(ee.current.delete(e),M.current=t?.conversation??null,N.current=null,P.current=null,n(t?.messages??[]),v(t?.welcomeSuggestions??[]),g(t?.approval??null),b(t?.withHuman??!1),w(t?.attachments??[]),o(t?.conversation?.sessionId??``),t?.conversation){try{let n=B();wt({...t.conversation,embedKey:n.embedKey,user:n.claim?.id,scope:n.scope,agent:e})}catch{}return}oe()},[oe,B]),he=e.humanPollMs??jt;G(()=>{if(!y||!a)return;let e=setInterval(()=>{let e=M.current;!e||k.current||dt({apiUrl:A.current.apiUrl??`https://api.squadico.com`,conversationId:e.sessionId,visitorToken:e.visitorToken}).then(t=>{M.current===e&&(n(t.messages),b(!!t.withHuman))}).catch(()=>{})},he);return()=>clearInterval(e)},[y,a,he]);let ge=kt(e.user?.id,e.scope);return G(()=>{if(M.current){F.current!==ge&&pe();return}if(!P.current||j.current)return;let e;try{e=B()}catch{return}H(e)},[ge,pe,H,B]),{messages:ve(()=>t.length===0&&re?[re]:t,[re,t]),busy:r,sessionId:a,resets:s,handles:l,addressee:d,agentHandle:p,welcomeSuggestions:_,approval:h,withHuman:y,branding:x,start:oe,send:ce,attachments:C,uploading:T,attachmentError:D,attach:U,detach:le,loadAttachment:ue,decide:de,stop:fe,reset:pe,switchTo:me}}var Pt=0;Array.isArray;function Y(e,t,r,i,a,o){t||(t={});var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Pt,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return n.vnode&&n.vnode(u),u}function Ft({name:e,color:t,url:n,size:r=16}){let[i,a]=W(void 0),o=!!n&&i!==n;return Y(`span`,{class:`sqc-avatar`,"aria-hidden":`true`,style:{width:`${r}px`,height:`${r}px`,fontSize:`${Math.round(r*.45)}px`,borderRadius:`${Math.round(r*.25)}px`,...o||!t?{}:{backgroundColor:t}},children:o?Y(`img`,{src:n,alt:``,onError:()=>a(n)}):It(e)})}function It(e){let t=Array.from(e.trim())[0];return t?t.toLocaleUpperCase():`?`}function Lt({handles:e,active:t,disabled:n,onPick:r,label:i}){return Y(`nav`,{class:`sqc-rail`,"aria-label":i,children:e.map(e=>Y(`button`,{type:`button`,class:`sqc-rail__item`,"aria-label":e.name,"aria-pressed":e.handle===t,"data-tip":e.name,disabled:n,onClick:()=>r(e.handle),children:[Y(Ft,{name:e.name,color:e.color,url:e.avatarUrl,size:40}),Y(`span`,{class:`sqc-rail__label`,"aria-hidden":`true`,children:Rt(e.handle)})]},e.handle))})}function Rt(e){let t=e.split(/[-_]/)[0]??e;return t.charAt(0).toUpperCase()+t.slice(1)}var zt=132,Bt=`image/png,image/jpeg,image/gif,image/webp,application/pdf,.docx,.txt,.md,.csv,.json`,Vt=/^[a-zA-Z0-9_-]*$/;function Ht(e,t){let n=e.slice(0,t),r=n.lastIndexOf(`@`);if(r<0||r>0&&!/\s/.test(n[r-1]??``))return null;let i=n.slice(r+1);return Vt.test(i)?{start:r,query:i}:null}function Ut({placeholder:e,locale:t,busy:n,autoFocus:r,handles:i,addressee:a,attachments:o=[],uploading:s=[],attachmentError:c,onAttach:l,onDetach:u,onSend:d,onStop:f}){let[p,m]=W(``),[h,g]=W(null),[_,v]=W(0),[y,b]=W(!1),x=K(null),S=K(null),w=!!l,T=s.length>0,E=ve(()=>{if(!h||!i||i.length===0)return[];let e=h.query.toLowerCase();return i.filter(t=>t.handle.startsWith(e))},[i,h]),D=E.length>0,O=q(()=>{let e=x.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight>zt;e.style.height=`${Math.min(e.scrollHeight,zt)}px`,e.style.overflowY=t?`auto`:`hidden`},[]);G(()=>{r&&x.current?.focus(),O()},[r,O]),G(()=>{a&&(m(e=>e||`@${a} `),requestAnimationFrame(O))},[a,O]);let k=q(e=>{g(Ht(e.value,e.selectionStart??e.value.length)),v(0)},[]),A=q(e=>{let t=x.current;if(!t||!h)return;let n=t.selectionStart??t.value.length,r=`${p.slice(0,h.start)}@${e} ${p.slice(n)}`,i=h.start+e.length+2;m(r),g(null),requestAnimationFrame(()=>{t.focus(),t.setSelectionRange(i,i),O()})},[O,h,p]),j=q(e=>{if(!(!l||!e))for(let t of Array.from(e))l(t)},[l]),M=q(()=>{let e=p.trim();!e&&o.length===0||n||T||(d(e),m(``),g(null),requestAnimationFrame(O))},[o.length,n,O,d,p,T]),N=q(e=>{if(D&&!e.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:E.length-1;v(e=>(e+t)%E.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),A((E[_]??E[0]).handle);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),g(null);return}}e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),M())},[_,E,A,D,M]),P=Je-p.length;return Y(`form`,{class:`sqc-composer${y?` sqc-composer--dropping`:``}`,onSubmit:e=>{e.preventDefault(),M()},onDragOver:e=>{w&&(e.preventDefault(),b(!0))},onDragLeave:()=>b(!1),onDrop:e=>{w&&(e.preventDefault(),b(!1),j(e.dataTransfer?.files??null))},children:[(o.length>0||T||c)&&Y(`div`,{class:`sqc-attachments`,children:[o.map(e=>Y(`span`,{class:`sqc-chip`,"data-kind":e.kind,children:[Y(`span`,{class:`sqc-chip__name`,children:e.filename}),Y(`button`,{type:`button`,class:`sqc-chip__remove`,"aria-label":t.t.composer.remove.replace(`{name}`,e.filename),onClick:()=>u?.(e.id),children:`×`})]},e.id)),s.map(e=>Y(`span`,{class:`sqc-chip sqc-chip--waiting`,children:Y(`span`,{class:`sqc-chip__name`,children:e})},e)),c&&Y(`p`,{class:`sqc-attachments__error`,role:`status`,children:c})]}),Y(`div`,{class:`sqc-composer__field`,children:[D&&Y(`ul`,{class:`sqc-mentions`,role:`listbox`,"aria-label":t.t.handles.picker,children:E.map((e,t)=>Y(`li`,{role:`option`,"aria-selected":t===_,class:`sqc-mention${t===_?` sqc-mention--active`:``}`,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>v(t),onClick:()=>A(e.handle),children:[Y(`span`,{class:`sqc-mention__icon`,children:Y(Ft,{name:e.name,color:e.color,url:e.avatarUrl,size:18})}),Y(`span`,{class:`sqc-mention__handle`,children:[`@`,e.handle]}),Y(`span`,{class:`sqc-mention__name`,children:e.name})]},e.handle))}),Y(`textarea`,{ref:x,class:`sqc-composer__input`,rows:1,value:p,placeholder:e,maxLength:Je,"aria-label":t.t.composer.label,onInput:e=>{m(e.currentTarget.value),k(e.currentTarget),O()},onKeyDown:N,onClick:e=>k(e.currentTarget),onPaste:e=>{let t=e.clipboardData?.files;!w||!t||t.length===0||(e.preventDefault(),j(t))}}),P<=200&&Y(`span`,{class:`sqc-composer__count`,"aria-live":`polite`,children:P})]}),w&&Y(C,{children:[Y(`input`,{ref:S,type:`file`,multiple:!0,accept:Bt,class:`sqc-file-input`,onChange:e=>{j(e.currentTarget.files),e.currentTarget.value=``}}),Y(`button`,{type:`button`,class:`sqc-btn sqc-btn--attach`,onClick:()=>S.current?.click(),"aria-label":t.t.composer.attach,title:t.t.composer.attachTitle,children:Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.9`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:Y(`path`,{d:`M21 11.5l-8.8 8.8a5 5 0 01-7.1-7.1l9-9a3.3 3.3 0 014.7 4.7l-9 9a1.6 1.6 0 01-2.3-2.3l8.3-8.3`})})})]}),n?Y(`button`,{type:`button`,class:`sqc-btn sqc-btn--stop`,onClick:f,"aria-label":t.t.composer.stop,title:t.t.composer.stopTitle,children:Y(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:Y(`rect`,{x:`7`,y:`7`,width:`10`,height:`10`,rx:`2`,fill:`currentColor`})})}):Y(`button`,{type:`submit`,class:`sqc-btn sqc-btn--send`,disabled:!p.trim()&&o.length===0||T,"aria-label":t.t.composer.send,title:t.t.composer.sendTitle,children:Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.9`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:Y(`path`,{d:`M5 12l14-7-5 14-2.5-5.5L5 12z`})})})]})}function Wt(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function Gt(e,t){Wt(e,t),t.add(e)}function X(e,t,n){Wt(e,t),t.set(e,n)}function Z(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function Q(e,t){return e.get(Z(e,t))}function $(e,t,n){return e.set(Z(e,t),n),n}var Kt=new Map;function qt(e){if(Kt.has(e))return Kt.get(e)??null;let t;try{t=new CSSStyleSheet,t.replaceSync(e)}catch{t=null}return Kt.set(e,t),t}function Jt(e,t,n){let r=[...t,`locked`,`language`];var i=new WeakMap,a=new WeakMap,o=new WeakMap,s=new WeakMap,c=new WeakSet;class l extends HTMLElement{constructor(){super(),Gt(this,c),X(this,i,{locked:!1,language:`en`}),X(this,a,void 0),X(this,o,!1),X(this,s,e=>{Q(i,this).locked||(this.set(`locked`,!0),this.dispatchEvent(new CustomEvent(`sqc-reply`,{detail:{text:e},bubbles:!0,composed:!0})))});let e=this.attachShadow({mode:`open`}),t=qt(n);if(t)e.adoptedStyleSheets=[t];else{let t=document.createElement(`style`);t.textContent=n,e.append(t)}$(a,this,document.createElement(`div`)),e.append(Q(a,this));for(let e of r){if(!Object.hasOwn(this,e))continue;let t=this[e];delete this[e],this[e]=t}}connectedCallback(){$(o,this,!0),Z(c,this,u).call(this)}disconnectedCallback(){$(o,this,!1),B(null,Q(a,this))}set(e,t){Q(i,this)[e]=t,Z(c,this,u).call(this)}get(e){return Q(i,this)[e]}}function u(){Q(o,this)&&B(x(e,{...Q(i,this),reply:Q(s,this)}),Q(a,this))}for(let e of r)Object.defineProperty(l.prototype,e,{get(){return this.get(e)},set(t){this.set(e,t)},configurable:!0});return l}var Yt={table:`sqc-table`,choices:`sqc-choices`,confirm:`sqc-confirm`,form:`sqc-form`,chart:`sqc-chart`,approval:`sqc-approval`};function Xt(e){return Le(e).t}var Zt=/(\*\*[^*\n]+\*\*|`[^`\n]+`|~~[^~\n]+~~|\[[^\]\n]+\]\([^)\s]+\)|\*[^*\n]+\*|https?:\/\/[^\s<>()]+)/g,Qt=/^\[([^\]\n]+)\]\(([^)\s]+)\)$/,$t=/^(https?:|mailto:|\/(?!\/))/i;function en(e){if(typeof location>`u`)return!1;try{return new URL(e,location.href).origin===location.origin}catch{return!1}}function tn(e,t,n){return $t.test(e)?en(e)?Y(`a`,{href:e,children:t},n):Y(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:t},n):t}function nn(e,t){let n=e.split(Zt),r=[];return n.forEach((e,n)=>{if(!e)return;let i=`${t}-${n}`,a=Qt.exec(e);e.startsWith(`**`)&&e.endsWith(`**`)&&e.length>4?r.push(Y(`strong`,{children:e.slice(2,-2)},i)):e.startsWith("`")&&e.endsWith("`")&&e.length>2?r.push(Y(`code`,{children:e.slice(1,-1)},i)):e.startsWith(`~~`)&&e.endsWith(`~~`)&&e.length>4?r.push(Y(`del`,{children:e.slice(2,-2)},i)):a?r.push(tn(a[2],a[1],i)):e.startsWith(`*`)&&e.endsWith(`*`)&&e.length>2?r.push(Y(`em`,{children:e.slice(1,-1)},i)):/^https?:\/\//.test(e)?r.push(tn(e,e,i)):r.push(e)}),r}function rn(e){return e.replace(/\[([^\]\n]+)\]\([^)\s]+\)/g,`$1`).replace(/\*\*|~~|`|\*/g,``).trim()}function an(){return Y(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.2`,"aria-hidden":`true`,children:Y(`path`,{d:`M3.5 8.5l3 3 6-7`,"stroke-linecap":`round`,"stroke-linejoin":`round`})})}function on({options:e=[],multiple:t,checked:n,locked:r,language:i,reply:a}){let o=Xt(i),s=e.map(rn),[c,l]=W(null),u=e.flatMap((e,t)=>n?.includes(e)?[t]:[]),d=c??(t?u:u.slice(0,1)),f=e=>{if(!r){if(!t){l([e]),a(s[e]);return}l(d.includes(e)?d.filter(t=>t!==e):[...d,e])}};return Y(`div`,{class:`choices`,role:`group`,"aria-label":o.choices,children:[e.map((e,t)=>Y(`button`,{type:`button`,class:`choice`,"aria-pressed":d.includes(t),disabled:r,onClick:()=>f(t),children:[Y(`span`,{class:`box${d.includes(t)?` on`:``}`,"aria-hidden":`true`,children:d.includes(t)&&Y(an,{})}),Y(`span`,{class:`label`,children:nn(e,`o${t}`)})]},`${t}-${s[t]}`)),t&&Y(`button`,{type:`button`,class:`send`,disabled:r||d.length===0,onClick:()=>{l(d),a([...d].sort((e,t)=>e-t).map(e=>s[e]).join(`, `))},children:o.selection.validate})]})}function sn({locked:e,language:t,reply:n}){let[r,i]=W(null),{confirm:a}=Xt(t),o=[{value:a.yesValue,label:a.yes,kind:`yes`},{value:a.noValue,label:a.no,kind:`no`}];return Y(`div`,{class:`confirm`,role:`group`,"aria-label":a.group,children:[o.map(t=>Y(`button`,{type:`button`,class:t.kind,"aria-pressed":r===t.value,disabled:e,onClick:()=>{i(t.value),n(t.value)},children:t.label},t.kind)),Y(`button`,{type:`button`,class:`other`,disabled:e,onClick:e=>e.currentTarget.dispatchEvent(new CustomEvent(`sqc-compose`,{bubbles:!0,composed:!0})),children:a.other})]})}var cn=200,ln=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`}),un=e=>rn(e??``).replace(/[\t\r\n]+/g,` `);function dn({table:e,language:t}){let n=Xt(t),{header:r=[],rows:i=[]}=e??{},[a,o]=W(null),[s,c]=W(!1),l=ve(()=>{if(!a)return i;let e=a.descending?-1:1;return[...i].sort((t,n)=>e*ln.compare(un(t[a.column]),un(n[a.column])))},[i,a]),u=()=>{let e=[r,...l].map(e=>r.map((t,n)=>un(e[n])).join(` `));navigator.clipboard?.writeText(e.join(`
3
+ `)).then(()=>{c(!0),setTimeout(()=>c(!1),2e3)},()=>void 0)},d=l.length-cn;return Y(`div`,{children:[Y(`div`,{class:`table`,children:Y(`table`,{children:[Y(`thead`,{children:Y(`tr`,{children:r.map((e,t)=>Y(`th`,{"aria-sort":a?.column===t?a.descending?`descending`:`ascending`:`none`,children:Y(`button`,{type:`button`,onClick:()=>o({column:t,descending:a?.column===t&&!a.descending}),children:nn(e,`h${t}`)})},t))})}),Y(`tbody`,{children:l.slice(0,cn).map((e,t)=>Y(`tr`,{children:r.map((n,r)=>Y(`td`,{children:nn(e[r]??``,`r${t}c${r}`)},r))},t))})]})}),Y(`div`,{class:`foot`,children:[d>0&&Y(`span`,{children:n.table.more.replace(`{count}`,String(d))}),Y(`button`,{type:`button`,class:`copy`,onClick:u,children:s?n.table.copied:n.table.copy})]})]})}var fn=[`:host{--w-bg:var(--sqc-bg,#fff);--w-surface:var(--sqc-surface,#f8fafc);--w-selected:var(--sqc-selected,#f1f5f9);--w-border:var(--sqc-border,#e2e8f0);--w-border-strong:var(--sqc-border-strong,#cbd5e1);--w-text:var(--sqc-text,#0f172a);--w-muted:var(--sqc-text-muted,#64748b);--w-accent:var(--sqc-accent-color,var(--sqc-accent,#000));--w-on-accent:var(--sqc-on-accent,#fff);--w-accent-hover:var(--sqc-accent-hover,color-mix(in oklab, var(--w-accent) 84%, var(--w-on-accent)));--w-focus:var(--sqc-focus,0 0 0 2px #fff, 0 0 0 4px #0f172a4d);--w-font:var(--sqc-font-family,system-ui, sans-serif);font-family:var(--w-font);display:block}:host([hidden]){display:none}button{color:inherit;font-family:inherit}button:focus-visible{box-shadow:var(--w-focus);outline:none}`,`.table{scrollbar-width:thin;margin:0 0 8px;overflow-x:auto}table{border-collapse:collapse;white-space:nowrap;min-width:100%;font-size:12.5px}th,td{text-align:left;vertical-align:top;border-bottom:1px solid color-mix(in srgb, currentColor 18%, transparent);padding:6px 10px 6px 0}thead th{text-transform:uppercase;letter-spacing:.05em;font-size:10.5px;font-weight:600}thead button{font:inherit;text-transform:inherit;letter-spacing:inherit;opacity:.7;cursor:pointer;background:0 0;border:0;padding:0}thead button:hover{opacity:1}tbody tr:last-child td{border-bottom:0}.foot{opacity:.8;align-items:center;gap:10px;font-size:11.5px;display:flex}.copy{border:1px solid var(--w-border);cursor:pointer;background:0 0;border-radius:8px;padding:2px 8px;font-size:11.5px}`,`.choices{flex-direction:column;gap:7px;margin:10px 0 2px;display:flex}.choice{text-align:left;width:100%;color:var(--w-text);background:var(--w-bg);border:1px solid var(--w-border);cursor:pointer;border-radius:12px;align-items:center;gap:8px;padding:8px 11px;font-size:12.5px;display:flex}.choice:hover:not(:disabled){border-color:var(--w-border-strong);background:var(--w-surface)}.choice:disabled{cursor:default}.choice:disabled[aria-pressed=false]{opacity:.55}.choice[aria-pressed=true]{border-color:var(--w-border-strong);background:var(--w-selected)}.box{border:1.5px solid var(--w-border-strong);border-radius:4px;flex:none;justify-content:center;align-items:center;width:15px;height:15px;display:inline-flex}.choices:not(:has(.send)) .box{border-radius:50%}.box.on{color:var(--w-on-accent);background:var(--w-accent);border-color:var(--w-accent)}.box svg{width:11px;height:11px}.label{overflow-wrap:anywhere}.send{background:var(--w-accent);height:32px;color:var(--w-on-accent);cursor:pointer;border:0;border-radius:12px;align-self:flex-end;padding:0 14px;font-size:13px;font-weight:600}.send:disabled{opacity:.4;cursor:default}`,`.confirm{flex-wrap:wrap;gap:8px;margin:11px 0 2px;display:flex}.confirm button{border:1px solid var(--w-border);background:var(--w-bg);height:32px;color:var(--w-text);cursor:pointer;border-radius:12px;flex:1 1 0;padding:0 12px;font-size:13px;font-weight:500}.confirm .other{flex-basis:100%}.confirm .yes:not(:disabled){background:var(--w-accent);color:var(--w-on-accent);border-color:#0000;font-weight:600}.confirm button:hover:not(:disabled){border-color:var(--w-border-strong);background:var(--w-surface)}.confirm .yes:hover:not(:disabled){background:var(--w-accent-hover);border-color:#0000}.confirm button:disabled{cursor:default}.confirm button:disabled:not([aria-pressed=true]){opacity:.45}.confirm button[aria-pressed=true]{border-color:var(--w-border-strong);background:var(--w-selected);color:var(--w-text);font-weight:600}`].join(`
4
+ `);function pn(){if(typeof customElements>`u`)return;let e=[[Yt.table,()=>Jt(dn,[`table`],fn)],[Yt.choices,()=>Jt(on,[`options`,`multiple`,`checked`],fn)],[Yt.confirm,()=>Jt(sn,[],fn)]];for(let[t,n]of e)customElements.get(t)||customElements.define(t,n())}var mn=/^(?:mcp|custom|a2a)_[0-9a-f]{8}_/;function hn(e){let t=e.replace(mn,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):e}var gn=`chatbot-widgets.global.js`,_n=/(?:\/chatbot\.global\.js|\/@squadico\/chatbot(?:@[^/?#]*)?\/?)(?:[?#]|$)/;function vn(){let e=document.currentScript??Array.from(document.querySelectorAll(`script[src]`)).reverse().find(e=>_n.test(e.src));return{src:e?.src??``,nonce:e?.nonce??``}}var yn=typeof document<`u`?vn():{src:``,nonce:``};function bn(e){let t=new URL(e);return t.pathname.endsWith(`.js`)?new URL(gn,t).href:new URL(`dist/${gn}`,t.href.replace(/\/?$/,`/`)).href}function xn(e,t=``){return new Promise((n,r)=>{if(!e){r(Error(`Squadico chatbot: cannot locate its own script to load the widget extras.`));return}let i=document.createElement(`script`);i.src=bn(e),t&&(i.nonce=t),i.async=!0,i.onload=()=>n(),i.onerror=()=>{i.remove(),r(Error(`Squadico chatbot: failed to load ${i.src}.`))},document.head.append(i)})}function Sn(e){let t;return()=>t??(t=e().catch(e=>{t=void 0,console.warn(e instanceof Error?e.message:e)}))}var Cn=Sn(()=>xn(yn.src,yn.nonce));function wn(e,t){let n=t[e];return e===t.length-1&&n?.role===`assistant`&&!n.streaming}var Tn={fr:/\br[ée]ponde?z? +«?\s*oui\b/i,en:/\b(?:reply|answer|respond) +[“"']?\s*yes\b/i,es:/\bresponda?e?d? +«?\s*s[íi](?!\p{L})/iu},En={fr:[/\b(?:confirmes?[- ]tu|confirmez[- ]vous)\b/i,/\b(?:valides?[- ]tu|validez[- ]vous)\b/i,/(?<!\p{L})(?:es[- ]tu s[ûu]re?|[êe]tes[- ]vous s[ûu]re?s?)(?!\p{L})/iu,/\b(?:dois[- ]je|puis[- ]je)\b/i,/\b(?:je continue|on continue|on y va|je lance)\b/i,Tn.fr],en:[/\bdo you confirm\b/i,/\bdo you (?:want|wish) me to\b/i,/\b(?:shall|should) I\b/i,/\bare you sure\b/i,/\b(?:shall we|should I) (?:proceed|continue|go ahead)\b/i,Tn.en],es:[/\b(?:confirmas|confirma|confirm[áa]is)\b/i,/\b(?:validas|valida|valid[áa]is)\b/i,/\best[áa]s? seguro\b/i,/\b(?:contin[úu]o|procedo|lo lanzo|lo hago)\b/i,/\bquieres? que\b/i,Tn.es]},Dn=/^\s*(?:[-*•]\s+)?(?:\[[ xX]\]|\([ xX]\))\s+/m,On=/[ \t]*\(\s*(?:yes|oui|s[íi])\s*\/\s*non?\s*\)\s*$/i;function kn(e){return e.replace(On,``)}function An(e,t=`en`){if(Dn.test(e))return!1;let n=e.split(`
5
+ `).map(e=>e.trim()).filter(Boolean),r=n[n.length-1];return r?On.test(r)?!0:!r.includes(`?`)&&!Tn[t].test(r)?!1:En[t].some(e=>e.test(r)):!1}var jn=[`text`,`number`,`date`,`email`,`select`];function Mn(e){try{return JSON.parse(e)}catch{return null}}function Nn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pn(e){return!Array.isArray(e)||e.length===0||e.length>20||!e.every(e=>typeof e==`string`&&e.trim())?null:e}function Fn(e){if(!Nn(e))return null;let{name:t,label:n,type:r}=e;if(typeof t!=`string`||!t.trim()||typeof n!=`string`||!n.trim()||typeof r!=`string`||!jn.includes(r))return null;let i={name:t,label:n,type:r,required:e.required===!0};if(r===`select`){let t=Pn(e.options);if(!t)return null;i.options=t}return i}function In(e){let t=Mn(e);if(!Nn(t)||!Array.isArray(t.fields)||t.fields.length===0||t.fields.length>12)return null;let n=[];for(let e of t.fields){let t=Fn(e);if(!t||n.some(e=>e.name===t.name))return null;n.push(t)}let r={fields:n};return typeof t.title==`string`&&(r.title=t.title),typeof t.submit==`string`&&(r.submit=t.submit),r}var Ln=/^\s*(?:[-*•]\s+)?(?:\[([ xX])\]|\(([ xX])\))\s+(.+)$/,Rn=/^\s*\|.*\|\s*$/,zn=/^\s*\|(?:\s*:?-{1,}:?\s*\|)+\s*$/,Bn=/^\s*```/;function Vn(e){return e.replace(/^\s*\|/,``).replace(/\|\s*$/,``).split(`|`).map(e=>e.trim())}function Hn(e,t,n=!0){let r=n&&An(e,t),i=(r?kn(e):e).split(`
6
6
  `),a=[],o=[],s=()=>{let e=o.join(`
7
- `).replace(/^\n+|\n+$/g,``);e.trim()&&a.push({kind:`markdown`,text:e}),o=[]};for(let e=0;e<i.length;e+=1){let t=i[e];if(Rn.test(t)){let n=e+1;for(;n<i.length&&!Rn.test(i[n]);)n+=1;let r=n<i.length,c=t.replace(/^\s*```/,``).trim().toLowerCase(),l=i.slice(e+1,n).join(`
8
- `),u=null;if(r&&c===`form`){let e=Pn(l);e&&(u={kind:`form`,form:e})}u?(s(),a.push(u)):o.push(...i.slice(e,r?n+1:n)),e=r?n:n-1;continue}if(In.test(t)&&e+1<i.length&&Ln.test(i[e+1])){s();let n=zn(t),r=[];for(e+=2;e<i.length&&In.test(i[e]);)r.push(zn(i[e])),e+=1;--e,a.push({kind:`table`,header:n,rows:r});continue}let n=Fn.exec(t);if(n){let t=n[1]!==void 0,r=[],c=[],l=e,u=n;for(;u&&u[1]!==void 0===t;){let e=u[3].trim();r.push(e),(u[1]??u[2])!==` `&&(t||!c.length)&&c.push(e),l+=1,u=l<i.length?Fn.exec(i[l]):null}if(r.length>20)o.push(...i.slice(e,l));else{s();let e={kind:`choices`,options:r,multiple:t};c.length&&(e.checked=c),a.push(e)}e=l-1;continue}o.push(t)}return s(),{blocks:a,confirm:r}}var Vn=/^(\s*)[-*•]\s+/,Hn=/^(\s*)\d+[.)]\s+/,Un=/^\s{0,3}(#{1,6})\s+(.+?)#*\s*$/,Wn=/^\s*([-*_])(?:\s*\1){2,}\s*$/,Gn=/^\s*>\s?(.*)$/,Kn=/^\s*```/;function qn(e,t,n,r){let i=e[t].ordered,a=[],o=t;for(;o<e.length&&e[o].depth>=n;){let t=e[o];if(t.depth===n&&t.ordered!==i)break;if(t.depth>n){let[n,i]=qn(e,o,t.depth,`${r}-${o}`),s=a[a.length-1];s?s.nested.push(n):a.push({key:`${r}-${o}`,text:null,nested:[n]}),o=i;continue}a.push({key:`${r}-${o}`,text:t.text,nested:[]}),o+=1}let s=a.map(e=>Y(`li`,{children:[e.text===null?null:en(e.text,e.key),e.nested]},e.key));return[Y(i?`ol`:`ul`,{children:s},r),o]}function Jn(e){let t=e.split(`
9
- `),n=[],r=[],i=[],a=[],o=()=>{if(!r.length)return;let e=`p${n.length}`;n.push(Y(`p`,{children:en(r.join(`
10
- `),e)},e)),r=[]},s=()=>{if(!i.length)return;let e=0;for(;e<i.length;){let t=`l${n.length}`,[r,a]=qn(i,e,i[e].depth,t);n.push(r),e=a}i=[]},c=()=>{if(!a.length)return;let e=`q${n.length}`;n.push(Y(`blockquote`,{children:en(a.join(`
11
- `),e)},e)),a=[]},l=()=>{o(),s(),c()};for(let e=0;e<t.length;e+=1){let u=t[e];if(Kn.test(u)){l();let r=[];for(e+=1;e<t.length&&!Kn.test(t[e]);)r.push(t[e]),e+=1;let i=`c${n.length}`;n.push(Y(`pre`,{children:Y(`code`,{children:r.join(`
12
- `)})},i));continue}if(!u.trim()){l();continue}let d=Un.exec(u);if(d){l();let e=d[1].length,t=e<=2?`h3`:e===3?`h4`:`h5`,r=`h${n.length}`;n.push(Y(t,{children:en(d[2],r)},r));continue}if(Wn.test(u)){l(),n.push(Y(`hr`,{},`r${n.length}`));continue}let f=Gn.exec(u);if(f){o(),s(),a.push(f[1]);continue}let p=Vn.exec(u),m=p?null:Hn.exec(u),h=p??m;if(h){o(),c(),i.push({depth:h[1].replace(/\t/g,` `).length,ordered:!!m,text:u.slice(h[0].length)});continue}s(),c(),r.push(u)}return l(),n}function Yn(e){let t=K(null),{form:n,locked:r,language:i}=e;return _e(()=>{xn()},[]),_e(()=>{t.current&&Object.assign(t.current,{form:n,locked:r,language:i})},[n,r,i]),Y(`sqc-form`,{ref:t,children:n.fields.map(e=>Y(`p`,{children:e.label},e.name))})}function Xn(e,t,n){switch(e.kind){case`markdown`:return Y(C,{children:Jn(e.text)});case`table`:return Y(`sqc-table`,{table:{header:e.header,rows:e.rows},locked:n,language:t.code});case`choices`:return Y(`sqc-choices`,{options:e.options,multiple:e.multiple,checked:e.checked,locked:n,language:t.code});case`form`:return Y(Yn,{form:e.form,locked:n,language:t.code})}}function Zn({text:e,locale:t,live:n,confirmable:r}){let{blocks:i,confirm:a}=Bn(e,t.code,r===!0),o=!n;return Y(C,{children:[i.map((e,n)=>Y(C,{children:Xn(e,t,o)},`b${n}`)),a&&Y(`sqc-confirm`,{locked:o,language:t.code})]})}var Qn=80;function $n({at:e,locale:t}){let n=new Date(e);return Y(`time`,{class:`sqc-msg__time`,dateTime:n.toISOString(),children:n.toLocaleTimeString(t.tag,{hour:`2-digit`,minute:`2-digit`})})}function er(e){let{call:t,locked:n,locale:r}=e,i=r.code,a=K(null);_e(()=>{xn()},[t,n]),_e(()=>{a.current&&Object.assign(a.current,{call:t,locked:n,language:i})},[t,n,i]);let o=e=>t=>t.currentTarget?.dispatchEvent(new CustomEvent(`sqc-decision`,{detail:{approved:e},bubbles:!0,composed:!0})),{yes:s,no:c}=r.t.confirm;return Y(`sqc-approval`,{ref:a,children:[t&&Y(`p`,{children:pn(t.tool)}),Y(`button`,{type:`button`,disabled:n,onClick:o(!0),children:s}),Y(`button`,{type:`button`,disabled:n,onClick:o(!1),children:c})]})}function tr({file:e,load:t}){let[n,r]=W(null);return G(()=>{let n=null,i=!0;return t(e.id).then(e=>{i&&(n=URL.createObjectURL(e),r(n))}).catch(()=>{}),()=>{i=!1,n&&URL.revokeObjectURL(n)}},[e.id,t]),n?Y(`img`,{class:`sqc-attachment__image`,src:n,alt:e.filename}):Y(`span`,{class:`sqc-chip sqc-chip--waiting`,children:e.filename})}function nr(e){let{file:t,load:n,language:r}=e,i=K(null),a=ve(()=>n(t.id).then(e=>e.text()).catch(()=>``),[t.id,n]);return _e(()=>{xn()},[]),_e(()=>{i.current&&Object.assign(i.current,{body:a,filename:t.filename,language:r})},[a,t.filename,r]),Y(`sqc-chart`,{class:`sqc-attachment__chart`,ref:i,children:t.filename})}function rr({files:e,load:t,language:n}){return e.length===0||!t?null:Y(`div`,{class:`sqc-attachments sqc-attachments--sent`,children:e.map(e=>e.kind===`image`?Y(tr,{file:e,load:t},e.id):e.kind===`chart`?Y(nr,{file:e,load:t,language:n},e.id):Y(`span`,{class:`sqc-chip`,"data-kind":`document`,children:Y(`span`,{class:`sqc-chip__name`,children:e.filename})},e.id))})}function ir({message:e,locale:t,assistantName:n,live:r,onDecide:i,onLoadAttachment:a}){let o=e.streaming&&!e.content,s=!!e.approval;return Y(`div`,{class:`sqc-msg sqc-msg--${e.role}${e.error?` sqc-msg--error`:``}`,children:[e.role===`assistant`&&Y(`div`,{class:`sqc-msg__who`,children:[e.agent?Y(Nt,{name:e.agent.name,color:e.agent.color,url:e.agent.avatarUrl}):Y(or,{}),e.authorName??e.agent?.name??n]}),Y(`div`,{class:`sqc-msg__bubble`,children:[o?Y(`span`,{class:`sqc-waiting`,children:[Y(`span`,{class:`sqc-typing`,"aria-label":t.t.typing,children:[Y(`i`,{}),Y(`i`,{}),Y(`i`,{})]}),e.activity&&Y(`span`,{class:`sqc-activity`,role:`status`,children:t.t.activity[e.activity]})]}):Y(`div`,{class:`sqc-msg__body`,children:[Y(Zn,{text:e.content,locale:t,live:r,confirmable:e.role===`assistant`&&!s&&!e.streaming&&!e.error}),e.streaming&&Y(`span`,{class:`sqc-caret`,"aria-hidden":`true`}),s&&Y(er,{locale:t,call:e.content.trim()===``?e.approval:void 0,locked:!i}),e.unknownHandle&&!e.streaming&&Y(ar,{message:e,locale:t}),Y(rr,{files:e.attachments??[],load:a,language:t.code})]}),!o&&Y($n,{at:e.createdAt,locale:t})]})]})}function ar({message:e,locale:t}){let n=e.offered??[];return Y(`p`,{class:`sqc-msg__unaddressed`,children:[Y(`span`,{children:t.t.handles.unknown}),` `,Y(`code`,{children:[`@`,e.unknownHandle]}),n.length>0&&Y(C,{children:[` `,Y(`span`,{children:t.t.handles.instead}),` `,n.map(e=>Y(`code`,{children:[`@`,e.handle]},e.handle))]})]})}function or(){return Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:Y(`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`})})}function sr({messages:e,locale:t,assistantName:n,suggestions:r,showSuggestions:i,busy:a,withHuman:o,onSuggestion:s,onChoice:c,onDecide:l,onCompose:u,onLoadAttachment:d}){let f=K(null),p=K(!0);_e(()=>{let e=f.current;e&&p.current&&(e.scrollTop=e.scrollHeight)},[e]);let m=K({onChoice:c,onCompose:u});m.current={onChoice:c,onCompose:u},G(()=>{let e=f.current;if(!e)return;let t=e=>{e.stopPropagation();let t=e.detail?.text;typeof t==`string`&&m.current.onChoice(t)},n=e=>{e.stopPropagation(),m.current.onCompose?.()};return e.addEventListener(`sqc-reply`,t),e.addEventListener(`sqc-compose`,n),()=>{e.removeEventListener(`sqc-reply`,t),e.removeEventListener(`sqc-compose`,n)}},[]);let h=e[e.length-1],g=!a&&h?.role===`assistant`&&!!h.approval,_=K({onDecide:l,decidable:g,locale:t});return _.current={onDecide:l,decidable:g,locale:t},G(()=>{let e=f.current;if(!e)return;let t=e=>{e.stopPropagation();let t=e.detail?.approved,n=_.current;if(typeof t!=`boolean`||!n.decidable)return;let{yes:r,no:i}=n.locale.t.confirm;n.onDecide(t,t?r:i)};return e.addEventListener(`sqc-decision`,t),()=>e.removeEventListener(`sqc-decision`,t)},[]),G(()=>{let e=f.current;if(!e)return;let t=()=>{p.current=e.scrollHeight-e.scrollTop-e.clientHeight<Qn};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),Y(`div`,{class:`sqc-messages`,ref:f,role:`log`,"aria-live":`polite`,"aria-atomic":`false`,children:[e.map((r,i)=>Y(ir,{message:r,locale:t,assistantName:n,live:!a&&Sn(i,e),onDecide:!a&&r.role===`assistant`&&i===e.length-1?l:void 0,onLoadAttachment:d},r.id)),o&&Y(`p`,{class:`sqc-with-human`,role:`status`,children:t.t.withHuman}),i&&r&&r.length>0&&Y(`div`,{class:`sqc-suggestions`,children:r.map(e=>Y(`button`,{type:`button`,class:`sqc-suggestion`,onClick:()=>s(e),children:e},e))})]})}var cr={width:`min(392px, 100vw)`},lr=new Set([`sessionId`]);function ur(e){let t=e.replace(/Id$|Ref$/,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):e}function dr(e){if(!e)return[];let t=[];for(let[n,r]of Object.entries(e)){if(lr.has(n)||typeof r!=`string`&&!ke(r))continue;let e=Oe(r);e&&t.push({label:ur(n),value:e})}return t}function fr(e,t){return e?.trim()?e:t}function pr(e){let[t,n]=W(!1);return G(()=>{if(e!==`auto`||typeof matchMedia!=`function`)return;let t=matchMedia(`(prefers-color-scheme: dark)`);n(t.matches);let r=e=>n(e.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),e===`dark`?`dark`:e===`light`?`light`:t?`dark`:`light`}function mr(e){dn();let t=e.persistOpen??!0,[n,r]=W(()=>Ve(e.defaultOpen,t)),[i,a]=W(!1),[o,s]=W(!1),c=K(null),l=K(null),u=pr(e.theme??`light`),d=ve(()=>Le(e.locale),[e.locale]),f=d.t,p=fr(e.heading,f.heading),m=fr(e.assistantName,f.assistant),h=fr(e.greeting,f.greeting),g=e.onEvent,{send:_,reset:v,decide:y,stop:b,start:x,resets:S,busy:C,messages:w,withHuman:T,branding:E,sessionId:D,handles:O,addressee:k,agentHandle:A,attachments:j,uploading:M,attachmentError:N,attach:P,detach:F,loadAttachment:I}=jt({embedKey:e.embedKey,user:e.user,scope:e.scope,getSubjectToken:e.getSubjectToken,agent:e.agent,context:e.context,greeting:h,locale:d,onEvent:g});G(()=>{!n&&w.some(e=>e.role===`assistant`&&e.id!==`greeting`)&&s(!0)},[w,n]);let L=K(n);L.current=n;let ee=q(()=>{s(!1),!L.current&&(L.current=!0,r(!0),t&&Be(!0),g?.({type:`chatbot-open`,sessionId:D}))},[g,t,D]),R=q(()=>{L.current&&(L.current=!1,r(!1),t&&Be(!1),g?.({type:`chatbot-close`,sessionId:D}),l.current?.focus())},[g,t,D]);G(()=>{n&&x()},[n,S,x]);let te=O.length>=2,z=He(w,A||void 0),[ne,re]=W(void 0),ie=K(void 0),ae=q(e=>{ie.current=e,re(e)},[]);G(()=>{ie.current=void 0,re(void 0)},[z]);let B=q(e=>{a(!0),_(te?Ue(e,ie.current,z):e)},[_,te,z]),V=q(()=>{a(!1),s(!1),v()},[v]),H=K({openPanel:ee,closePanel:R,send:B,reset:V,sessionId:D});H.current={openPanel:ee,closePanel:R,send:B,reset:V,sessionId:D};let oe=K({open:()=>H.current.openPanel(),close:()=>H.current.closePanel(),toggle:()=>L.current?H.current.closePanel():H.current.openPanel(),reset:()=>H.current.reset(),send:e=>{H.current.openPanel(),H.current.send(e)},isOpen:()=>L.current,sessionId:()=>H.current.sessionId}),se=e.bind;_e(()=>(se?.(oe.current),()=>se?.(null)),[se]),G(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&(e.stopPropagation(),R())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[R,n]);let ce=ve(()=>w.some(e=>e.id!==`greeting`),[w]),U=ve(()=>dr(e.context),[e.context]),le={...e.accent?{"--sqc-accent":e.accent}:{},"--sqc-width":e.width??cr.width};return Y(`div`,{class:`sqc`,"data-theme":u,"data-position":e.position??`bottom-right`,"data-layout":e.layout??`sidebar`,"data-open":n?`true`:`false`,style:le,children:[Y(`button`,{ref:l,type:`button`,class:`sqc-launcher`,"aria-label":p,"aria-expanded":n,"aria-haspopup":`dialog`,onClick:ee,children:[Y(`span`,{class:`sqc-launcher__icon`,children:Y(`slot`,{name:`launcher-icon`,class:`sqc-slot-icon`,children:Y(or,{})})}),o&&Y(`span`,{class:`sqc-launcher__badge`,"aria-hidden":`true`})]}),Y(`aside`,{ref:c,class:`sqc-panel`,role:`dialog`,"aria-modal":`false`,"aria-label":p,...n?{}:{inert:!0},children:[Y(`header`,{class:`sqc-header`,children:[Y(`span`,{class:`sqc-header__icon`,"aria-hidden":`true`,children:Y(or,{})}),Y(`div`,{class:`sqc-header__titles`,children:[Y(`p`,{class:`sqc-header__heading`,children:p}),Y(`p`,{class:`sqc-header__sub`,children:fr(e.subheading,f.subheading)})]}),Y(`button`,{type:`button`,class:`sqc-icon-btn`,onClick:V,"aria-label":f.newConversation,"data-tip":f.newConversation,children:Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,children:Y(`path`,{d:`M20 12a8 8 0 1 1-2.6-5.9M20 4v4h-4`,"stroke-linecap":`round`})})}),Y(`button`,{type:`button`,class:`sqc-icon-btn`,onClick:R,"aria-label":f.close,"data-tip":f.closeTitle,children:Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,children:Y(`path`,{d:`M6 6l12 12M18 6L6 18`,"stroke-linecap":`round`})})})]}),Y(`div`,{class:`sqc-panel__body`,children:[te&&Y(Ft,{handles:O,active:ne??z,disabled:T,onPick:ae,label:f.handles.rail}),Y(`div`,{class:`sqc-panel__main`,children:[(e.showContext??!0)&&U.length>0&&Y(`div`,{class:`sqc-context`,"aria-label":f.context.region,children:U.map(e=>Y(`span`,{class:`sqc-chip`,title:`${e.label}: ${e.value}`,children:[Y(`b`,{children:e.label}),e.value]},e.label))}),Y(sr,{messages:w,locale:d,assistantName:m,suggestions:e.suggestions,showSuggestions:!i&&!ce,busy:C,withHuman:T,onSuggestion:B,onChoice:B,onDecide:y,onCompose:()=>c.current?.querySelector(`.sqc-composer__input`)?.focus(),onLoadAttachment:I}),Y(Vt,{placeholder:fr(e.placeholder,f.placeholder),locale:d,busy:C,autoFocus:n,handles:O,addressee:k,attachments:j,uploading:M,attachmentError:N?f.attachments[N]:void 0,onAttach:P,onDetach:F,onSend:B,onStop:b}),Y(`p`,{class:`sqc-hint`,children:f.hint}),E&&Y(`p`,{class:`sqc-powered`,children:Y(`a`,{href:`https://squadico.com`,target:`_blank`,rel:`noopener noreferrer`,children:f.poweredBy})})]})]})]})]})}var hr=`:host{--sqc-width:min(392px, 100vw);--sqc-height:640px;--sqc-z:2147480000;--sqc-radius:16px;--sqc-font-family:"Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;--sqc-font-heading:var(--sqc-font-family);z-index:var(--sqc-z);pointer-events:none;font-family:var(--sqc-font-family);-webkit-font-smoothing:antialiased;text-align:left;font-size:14px;line-height:1.5;display:block;position:fixed;top:0;bottom:0;left:0;right:0;margin:0!important}:host([hidden]){display:none}.sqc{--sqc-neutral-50:#f8fafc;--sqc-neutral-100:#f1f5f9;--sqc-neutral-200:#e2e8f0;--sqc-neutral-300:#cbd5e1;--sqc-neutral-400:#94a3b8;--sqc-neutral-500:#64748b;--sqc-neutral-600:#475569;--sqc-neutral-900:#0f172a;--sqc-error-50:#fff1f2;--sqc-error-100:#ffe4e6;--sqc-error-600:#e11d48;--sqc-accent-default:#000;--sqc-accent-color:var(--sqc-accent,var(--sqc-accent-default));--sqc-on-accent:#fff;--sqc-accent-hover:color-mix(in oklab, var(--sqc-accent-color) 84%, var(--sqc-on-accent));--sqc-accent-fg:var(--sqc-accent,var(--sqc-text));--sqc-bg:#fff;--sqc-surface:var(--sqc-neutral-50);--sqc-selected:var(--sqc-neutral-100);--sqc-border:var(--sqc-neutral-200);--sqc-border-strong:var(--sqc-neutral-300);--sqc-text:var(--sqc-neutral-900);--sqc-text-muted:var(--sqc-neutral-500);--sqc-link:#2563eb;--sqc-bubble-user:var(--sqc-accent-color);--sqc-bubble-user-text:var(--sqc-on-accent);--sqc-code-bg:var(--sqc-neutral-100);--sqc-disabled:var(--sqc-neutral-300);--sqc-shadow:0 10px 15px -3px #0f172a1a, 0 4px 6px -4px #0f172a1a;--sqc-shadow-bottom:0 6px 8px -6px #0f172a2e;--sqc-focus:0 0 0 2px var(--sqc-bg), 0 0 0 4px #0f172a4d;--sqc-focus-input:0 0 0 3px #0f172a1a;--sqc-danger:var(--sqc-error-600);color:var(--sqc-text);position:absolute;top:0;bottom:0;left:0;right:0}.sqc[data-theme=dark]{--sqc-neutral-50:#172033;--sqc-neutral-100:#1e293b;--sqc-neutral-200:#334155;--sqc-neutral-300:#475569;--sqc-neutral-400:#64748b;--sqc-neutral-500:#94a3b8;--sqc-neutral-600:#cbd5e1;--sqc-neutral-900:#f8fafc;--sqc-error-50:#2a0a12;--sqc-error-100:#4c0519;--sqc-error-600:#fb7185;--sqc-accent-default:#fff;--sqc-on-accent:#0f172a;--sqc-bg:#0f172a;--sqc-link:#60a5fa;--sqc-code-bg:#020617;--sqc-shadow:0 10px 24px -4px #0000008c;--sqc-shadow-bottom:0 6px 8px -6px #0000008c;--sqc-focus:0 0 0 2px var(--sqc-bg), 0 0 0 4px #f8fafc59;--sqc-focus-input:0 0 0 3px #f8fafc1f}@supports (color:oklch(from red l c h)){.sqc{--sqc-on-accent:oklch(from var(--sqc-accent-color) clamp(.208, (.62 - l) * 1000, 1) 0 0)}}.sqc *,.sqc :before,.sqc :after{box-sizing:border-box}.sqc-launcher{background:var(--sqc-accent-color);width:56px;height:56px;color:var(--sqc-on-accent);cursor:pointer;pointer-events:auto;box-shadow:var(--sqc-shadow);border:none;border-radius:50%;place-items:center;padding:0;transition:transform .18s,opacity .18s,background .18s,box-shadow .18s;display:grid;position:absolute;bottom:24px;right:24px}.sqc[data-position=bottom-left] .sqc-launcher{left:24px;right:auto}.sqc-launcher:hover{background:var(--sqc-accent-hover);transform:scale(1.06)}.sqc-launcher:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc[data-open=true] .sqc-launcher{opacity:0;pointer-events:none;transform:scale(.5)}.sqc-launcher__icon svg{width:26px;height:26px;display:block}.sqc-slot-icon::slotted(*){justify-content:center;align-items:center;width:26px;height:26px;display:inline-flex}.sqc-launcher__badge{background:var(--sqc-error-600);border:2px solid var(--sqc-bg);border-radius:50%;width:12px;height:12px;position:absolute;top:6px;right:6px}.sqc-panel{width:var(--sqc-width);background:var(--sqc-bg);border-left:1px solid var(--sqc-border);box-shadow:var(--sqc-shadow);pointer-events:auto;visibility:hidden;flex-direction:column;transition:transform .26s cubic-bezier(.22,1,.36,1),visibility 0s linear .26s;display:flex;position:absolute;top:0;bottom:0;right:0;transform:translate(100%)}.sqc-panel__body{flex:1;min-height:0;display:flex}.sqc-panel__main{flex-direction:column;flex:1;min-width:0;min-height:0;display:flex}.sqc-rail{border-right:1px solid var(--sqc-border);background:color-mix(in oklab, var(--sqc-accent-color) 7%, var(--sqc-bg));flex-direction:column;flex-shrink:0;align-items:stretch;gap:6px;width:72px;padding:12px 0;display:flex;overflow:visible}.sqc-rail__item{color:var(--sqc-text-muted);font:inherit;cursor:pointer;background:0 0;border:0;flex-direction:column;align-items:center;gap:4px;padding:4px 0;display:flex;position:relative}.sqc-rail__label{white-space:nowrap;text-overflow:ellipsis;max-width:64px;font-size:10.5px;font-weight:500;line-height:1.2;overflow:hidden}.sqc-rail__item:hover,.sqc-rail__item[aria-pressed=true]{color:var(--sqc-text)}.sqc-rail__item[aria-pressed=true] .sqc-rail__label{font-weight:600}.sqc-rail__item .sqc-avatar{transition:box-shadow .15s}.sqc-rail__item[aria-pressed=true] .sqc-avatar{box-shadow:0 0 0 2px var(--sqc-bg), 0 0 0 4px var(--sqc-accent-color)}.sqc-rail__item:before{content:"";background:var(--sqc-text);border-radius:0 4px 4px 0;width:4px;height:0;transition:height .15s;position:absolute;top:24px;left:0;transform:translateY(-50%)}.sqc-rail__item:hover:before{height:12px}.sqc-rail__item[aria-pressed=true]:before{height:32px}.sqc-rail__item:focus-visible{outline:2px solid var(--sqc-accent-color);outline-offset:-2px;border-radius:8px}.sqc-rail__item:disabled{cursor:not-allowed;opacity:.5}.sqc-rail__item[data-tip]:after{content:attr(data-tip);z-index:2;background:var(--sqc-text);color:var(--sqc-bg);white-space:nowrap;pointer-events:none;opacity:0;border-radius:6px;padding:4px 8px;font-size:12px;font-weight:500;transition:opacity .12s;position:absolute;top:24px;left:calc(100% + 6px);transform:translateY(-50%)}.sqc-rail__item[data-tip]:hover:after{opacity:1}.sqc-rail__item[data-tip]:focus-visible:after{opacity:1}.sqc[data-open=true] .sqc-panel{visibility:visible;transition:transform .26s cubic-bezier(.22,1,.36,1),visibility;transform:translate(0)}.sqc[data-layout=floating] .sqc-panel{max-width:calc(100% - 48px);height:var(--sqc-height);border:1px solid var(--sqc-border);border-radius:var(--sqc-radius);opacity:0;transform-origin:100% 100%;max-height:calc(100% - 48px);transition:transform .22s cubic-bezier(.22,1,.36,1),opacity .22s,visibility 0s linear .22s;top:auto;bottom:24px;right:24px;overflow:hidden;transform:translateY(16px)scale(.96)}.sqc[data-layout=floating][data-position=bottom-left] .sqc-panel{transform-origin:0 100%;left:24px;right:auto}.sqc[data-layout=floating][data-open=true] .sqc-panel{opacity:1;transition:transform .22s cubic-bezier(.22,1,.36,1),opacity .22s,visibility;transform:none}.sqc-header{background:var(--sqc-bg);color:var(--sqc-text);border-bottom:1px solid var(--sqc-border);flex-shrink:0;align-items:center;gap:8px;padding:13px 12px 13px 16px;display:flex}.sqc-header__icon{color:var(--sqc-accent-fg);flex-shrink:0;place-items:center;display:grid}.sqc-header__icon svg{width:17px;height:17px;display:block}.sqc-header__titles{flex:1;min-width:0}.sqc-header__heading,.sqc-header__sub{text-overflow:ellipsis;white-space:nowrap;margin:0;overflow:hidden}.sqc-header__heading{font-family:var(--sqc-font-heading);letter-spacing:-.2px;font-size:15px;font-weight:700}.sqc-header__sub{color:var(--sqc-text-muted);font-size:12px}.sqc-icon-btn{width:26px;height:26px;color:var(--sqc-text-muted);cursor:pointer;background:0 0;border:none;border-radius:8px;flex-shrink:0;place-items:center;transition:background .15s;display:grid}.sqc-icon-btn:hover{background:var(--sqc-surface);color:var(--sqc-text)}.sqc-icon-btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-icon-btn svg{width:16px;height:16px}.sqc-icon-btn[data-tip]{position:relative}.sqc-icon-btn[data-tip]:after{content:attr(data-tip);z-index:6;background:var(--sqc-text);color:var(--sqc-bg);font-family:var(--sqc-font-family);white-space:nowrap;pointer-events:none;opacity:0;border-radius:8px;padding:4px 8px;font-size:11px;font-weight:500;line-height:1.3;transition:opacity .12s .15s;position:absolute;top:calc(100% + 6px);right:0}.sqc-icon-btn[data-tip]:hover:after{opacity:1}.sqc-icon-btn[data-tip]:focus-visible:after{opacity:1}.sqc-history-pop{z-index:5;position:absolute;top:54px;left:0;right:0}.sqc-history{background:var(--sqc-bg);max-height:320px;box-shadow:var(--sqc-shadow-bottom);flex-direction:column;display:flex;overflow-y:auto}.sqc-history__empty{color:var(--sqc-text-muted);text-align:center;margin:0;padding:14px 16px;font-size:12px}.sqc-history__item{border:none;border-bottom:1px solid var(--sqc-border);width:100%;color:var(--sqc-text);text-align:left;cursor:pointer;background:0 0;flex-direction:column;gap:2px;padding:10px 16px;transition:background .15s;display:flex}.sqc-history__item:last-child{border-bottom:none}.sqc-history__item:hover{background:var(--sqc-surface)}.sqc-history__item:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-history__item[aria-current=true]{background:var(--sqc-selected)}.sqc-history__item[aria-current=true] .sqc-history__title{color:var(--sqc-text);font-weight:600}.sqc-history__title{text-overflow:ellipsis;white-space:nowrap;font-size:13px;overflow:hidden}.sqc-history__date{color:var(--sqc-text-muted);font-size:11px}.sqc-context{background:var(--sqc-selected);border:1px solid var(--sqc-border);color:var(--sqc-text);border-radius:12px;flex-wrap:wrap;flex-shrink:0;align-items:center;gap:8px;margin:12px 16px 4px;padding:8px 11px;font-size:12px;display:flex}.sqc-chip{text-overflow:ellipsis;white-space:nowrap;align-items:baseline;gap:4px;max-width:100%;display:inline-flex;overflow:hidden}.sqc-chip b{font-weight:600}.sqc-chip:not(:last-child):after{content:"·";opacity:.5;margin-left:4px}.sqc-messages{overscroll-behavior:contain;background:var(--sqc-bg);scrollbar-width:thin;scrollbar-color:var(--sqc-neutral-300) transparent;flex-direction:column;flex:1;gap:13px;min-height:0;padding:12px 16px;display:flex;overflow-y:auto}.sqc-messages::-webkit-scrollbar{width:6px}.sqc-messages::-webkit-scrollbar-thumb{background:var(--sqc-neutral-300);border-radius:99px}.sqc-msg{flex-direction:column;max-width:93%;font-size:13.5px;display:flex}.sqc-msg--assistant{align-self:stretch}.sqc-msg--user{align-self:flex-end}.sqc-msg__who{color:var(--sqc-text-muted);align-items:center;gap:6px;margin-bottom:4px;font-size:11px;font-weight:500;display:flex}.sqc-msg__who svg{width:12px;height:12px;color:var(--sqc-accent-fg);flex-shrink:0}.sqc-avatar{background:var(--sqc-accent-color);color:var(--sqc-on-accent);-webkit-user-select:none;user-select:none;flex-shrink:0;justify-content:center;align-items:center;font-weight:600;line-height:1;display:inline-flex;overflow:hidden}.sqc-avatar img{object-fit:cover;width:100%;height:100%}.sqc-msg__unaddressed{color:var(--sqc-text-muted);margin:8px 0 0;font-size:11.5px;line-height:1.5}.sqc-msg__unaddressed code{background:var(--sqc-code-bg);color:var(--sqc-text);border-radius:4px;margin-right:4px;padding:1px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11px}.sqc-msg--user .sqc-msg__bubble{background:var(--sqc-bubble-user);color:var(--sqc-bubble-user-text);border-radius:var(--sqc-radius) var(--sqc-radius) 4px var(--sqc-radius);padding:9px 13px}.sqc-msg--error .sqc-msg__bubble{background:var(--sqc-error-50);color:var(--sqc-error-600);border:1px solid var(--sqc-error-100);border-radius:12px;padding:11px}.sqc-msg__body{overflow-wrap:anywhere}.sqc-msg--assistant .sqc-msg__body{font-size:14px;line-height:1.6}.sqc-msg__body>:first-child{margin-top:0}.sqc-msg__body>:last-child{margin-bottom:0}.sqc-msg__body p{white-space:pre-wrap;margin:0 0 8px}.sqc-msg__body ul,.sqc-msg__body ol{margin:0 0 8px;padding-left:20px}.sqc-msg__body li{margin-bottom:3px}.sqc-msg__body code{background:var(--sqc-code-bg);border-radius:4px;padding:1px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.85em}.sqc-msg--user .sqc-msg__body code{background:#ffffff38}.sqc-msg__body pre{background:var(--sqc-code-bg);border-radius:8px;margin:0 0 8px;padding:9px 11px;overflow-x:auto}.sqc-msg__body pre code{background:0 0;padding:0}.sqc-msg__body a{color:inherit;text-underline-offset:2px;text-decoration:underline}.sqc-msg--assistant .sqc-msg__body a{color:var(--sqc-link);text-decoration:none}.sqc-msg--assistant .sqc-msg__body a:hover{text-decoration:underline}.sqc-msg__body h3,.sqc-msg__body h4,.sqc-msg__body h5,.sqc-msg__body h6{font-family:var(--sqc-font-heading);letter-spacing:-.2px;margin:12px 0 6px;font-weight:700;line-height:1.3}.sqc-msg__body h3{font-size:1.05em}.sqc-msg__body h4{font-size:1em}.sqc-msg__body h5,.sqc-msg__body h6{font-size:.94em}.sqc-msg__body ul ul,.sqc-msg__body ul ol,.sqc-msg__body ol ul,.sqc-msg__body ol ol{margin:3px 0 0}.sqc-msg__body blockquote{border-left:2px solid var(--sqc-border-strong);color:var(--sqc-text-muted);white-space:pre-wrap;margin:0 0 8px;padding:2px 0 2px 10px}.sqc-msg--user .sqc-msg__body blockquote{color:inherit;opacity:.85;border-left-color:#ffffff73}.sqc-msg__body hr{border:0;border-top:1px solid var(--sqc-border);margin:10px 0}.sqc-msg--user .sqc-msg__body hr{border-top-color:#ffffff4d}.sqc-msg__body del{opacity:.7}.sqc-selection{flex-direction:column;gap:10px;margin:2px 0;display:flex}.sqc-selection__question{flex-direction:column;gap:2px;display:flex}.sqc-selection__ask{font-family:var(--sqc-font-family);color:var(--sqc-text);margin:0;font-size:13px;font-weight:600}.sqc-selection__actions{display:flex}.sqc-selection__validate{height:32px;font-family:var(--sqc-font-family);color:var(--sqc-on-accent);background:var(--sqc-accent-color);cursor:pointer;border:1px solid #0000;border-radius:12px;flex:auto;justify-content:center;align-items:center;padding:0 12px;font-size:13px;font-weight:600;transition:filter .12s,background .12s;display:inline-flex}.sqc-selection__validate:hover:not(:disabled){background:var(--sqc-accent-hover)}.sqc-selection__validate:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-selection__validate:disabled{cursor:not-allowed;color:#fff;background:var(--sqc-disabled)}.sqc-selection__hint{font-family:var(--sqc-font-family);color:var(--sqc-text-muted);margin:0;font-size:11.5px}.sqc-msg__time{color:var(--sqc-text-muted);font-variant-numeric:tabular-nums;margin-top:3px;font-size:10px;display:block}.sqc-msg--user .sqc-msg__time{color:#ffffffb3;text-align:right}.sqc-caret{vertical-align:text-bottom;background:currentColor;width:2px;height:1em;margin-left:2px;animation:1s step-end infinite sqc-blink;display:inline-block}@keyframes sqc-blink{0%,to{opacity:1}50%{opacity:0}}.sqc-typing{gap:3px;padding:2px 0;display:inline-flex}.sqc-typing i{background:var(--sqc-neutral-400);border-radius:50%;width:5px;height:5px;animation:1.2s infinite sqc-pulse}.sqc-typing i:nth-child(2){animation-delay:.2s}.sqc-typing i:nth-child(3){animation-delay:.4s}.sqc-waiting{align-items:center;gap:8px;display:inline-flex}.sqc-activity{color:var(--sqc-text-muted);font-size:12px}@keyframes sqc-pulse{0%,60%,to{opacity:.25}30%{opacity:1}}.sqc-suggestions{flex-direction:column;gap:7px;display:flex}.sqc-suggestion{border:1px solid var(--sqc-border);background:var(--sqc-bg);width:100%;color:var(--sqc-text);font-family:var(--sqc-font-family);cursor:pointer;text-align:left;border-radius:12px;align-items:center;gap:8px;padding:8px 11px;font-size:12.5px;transition:background .15s,border-color .15s;display:flex}.sqc-suggestion:before{content:"";background:var(--sqc-accent-fg);border-radius:50%;flex:none;width:5px;height:5px}.sqc-suggestion:hover{background:var(--sqc-surface);border-color:var(--sqc-border-strong)}.sqc-suggestion:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-composer{border-top:1px solid var(--sqc-border);background:var(--sqc-bg);flex-wrap:wrap;flex-shrink:0;align-items:flex-end;gap:8px;padding:12px 14px;display:flex}.sqc-composer--dropping{outline:2px dashed var(--sqc-accent-color);outline-offset:-4px}.sqc-attachments{flex-wrap:wrap;flex-basis:100%;gap:6px;display:flex}.sqc-attachments--sent{margin-top:8px}.sqc-chip{border:1px solid var(--sqc-border);background:var(--sqc-selected);max-width:100%;color:var(--sqc-text);border-radius:999px;align-items:center;gap:4px;padding:3px 4px 3px 10px;font-size:12px;display:inline-flex}.sqc-chip--waiting{opacity:.6;padding-right:10px}.sqc-chip__name{text-overflow:ellipsis;white-space:nowrap;max-width:180px;overflow:hidden}.sqc-chip__remove{width:18px;height:18px;color:var(--sqc-text-muted);cursor:pointer;background:0 0;border:0;border-radius:999px;justify-content:center;align-items:center;padding:0;font-size:14px;line-height:1;display:inline-flex}.sqc-chip__remove:hover{background:var(--sqc-selected);color:var(--sqc-text)}.sqc-attachments__error{color:var(--sqc-error-600);flex-basis:100%;margin:0;font-size:12px}.sqc-attachment__image{border-radius:12px;max-width:100%;max-height:180px;display:block}.sqc-attachment__chart{flex-basis:100%;min-width:0}.sqc-file-input{display:none}.sqc-btn--attach{color:var(--sqc-text-muted);background:0 0}.sqc-btn--attach:hover{background:var(--sqc-selected);color:var(--sqc-text)}.sqc-composer__field{flex:1;min-width:0;position:relative}.sqc-composer__input{border:1px solid var(--sqc-border-strong);background:var(--sqc-bg);width:100%;min-height:38px;max-height:132px;color:var(--sqc-text);font-family:var(--sqc-font-family);resize:none;border-radius:12px;outline:none;padding:9px 12px;font-size:13.5px;line-height:1.4;transition:border-color .15s,box-shadow .15s;display:block;overflow-y:hidden}.sqc-composer__input::placeholder{color:var(--sqc-neutral-400)}.sqc-composer__input:focus{border-color:var(--sqc-text);box-shadow:var(--sqc-focus-input)}.sqc-mentions{z-index:2;border:1px solid var(--sqc-border);background:var(--sqc-bg);max-height:184px;box-shadow:var(--sqc-shadow);scrollbar-width:thin;border-radius:12px;margin:0;padding:4px;list-style:none;position:absolute;bottom:calc(100% + 6px);left:0;right:0;overflow-y:auto}.sqc-mention{cursor:pointer;color:var(--sqc-text);border-radius:8px;align-items:baseline;gap:6px;padding:6px 8px;font-size:12.5px;display:flex}.sqc-mention--active{background:var(--sqc-neutral-100)}.sqc-mention__icon{flex-shrink:0}.sqc-mention__handle{font-weight:600}.sqc-mention__name{text-overflow:ellipsis;white-space:nowrap;color:var(--sqc-text-muted);overflow:hidden}.sqc-composer__count{color:var(--sqc-text-muted);pointer-events:none;font-variant-numeric:tabular-nums;font-size:10px;position:absolute;bottom:4px;right:8px}.sqc-btn{cursor:pointer;border:none;border-radius:12px;flex-shrink:0;place-items:center;width:38px;height:38px;transition:background .15s,opacity .15s;display:grid}.sqc-btn svg{width:17px;height:17px}.sqc-btn--send{background:var(--sqc-accent-color);color:var(--sqc-on-accent)}.sqc-btn--send:hover:not(:disabled){background:var(--sqc-accent-hover)}.sqc-btn--send:disabled{background:var(--sqc-disabled);color:#fff;cursor:not-allowed}.sqc-btn--stop{background:var(--sqc-bg);color:var(--sqc-text);border:1px solid var(--sqc-border)}.sqc-btn--stop:hover{border-color:var(--sqc-border-strong);background:var(--sqc-surface)}.sqc-btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-hint{padding:0 16px max(9px, env(safe-area-inset-bottom));color:var(--sqc-text-muted);text-align:center;flex-shrink:0;margin:0;font-size:10.5px;line-height:1.35}.sqc-powered{padding:0 16px max(9px, env(safe-area-inset-bottom));text-align:center;flex-shrink:0;margin:0;font-size:10.5px;line-height:1.35}.sqc-powered a{color:var(--sqc-text-muted);text-decoration:none}.sqc-powered a:hover{text-decoration:underline}@media (max-width:520px){.sqc{--sqc-width:100vw}.sqc-panel{border-left:none}.sqc-launcher{bottom:16px;right:16px}.sqc[data-position=bottom-left] .sqc-launcher{left:16px}.sqc[data-layout=floating] .sqc-panel,.sqc[data-layout=floating][data-position=bottom-left] .sqc-panel{border:none;border-radius:0;max-width:none;height:auto;max-height:none;top:0;bottom:0;left:0;right:0}}@media (prefers-reduced-motion:reduce){.sqc-launcher,.sqc-panel,.sqc-btn,.sqc-suggestion,.sqc-choice,.sqc-confirm__btn,.sqc-icon-btn,.sqc-icon-btn[data-tip]:after,.sqc-rail__item:before,.sqc-rail__item[data-tip]:after,.sqc-rail__item .sqc-avatar{transition:none}.sqc-typing i,.sqc-caret{animation:none}}.sqc-with-human{border:1px solid var(--sqc-border);background:var(--sqc-selected);color:var(--sqc-neutral-600);border-radius:12px;margin:8px 0 0;padding:8px 12px;font-size:13px}`,gr=`squadico-chatbot`,_r=[`embed-key`,`context`,`user`,`agent`,`heading`,`subheading`,`assistant-name`,`placeholder`,`greeting`,`suggestions`,`width`,`accent`,`theme`,`position`,`layout`,`open`,`persist-open`,`show-context`,`locale`],vr;function yr(){if(vr!==void 0)return vr;try{let e=new CSSStyleSheet;e.replaceSync(hr),vr=e}catch{vr=null}return vr}function br(e,t){typeof console<`u`&&console.warn(`[${gr}] ${e}`,t??``)}function xr(e){if(!(!e||!e.trim()))try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t;if(typeof e.id==`string`&&e.id)return{id:e.id,name:typeof e.name==`string`&&e.name?e.name:void 0,digest:typeof e.digest==`string`&&e.digest?e.digest:void 0}}br(`the "user" attribute needs an object with an id`,e)}catch(e){br(`the "user" attribute is not valid JSON`,e)}}function Sr(e){if(!(!e||!e.trim()))try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t;br("the `context` attribute must be a JSON object",e)}catch(e){br("the `context` attribute is not valid JSON",e)}}function Cr(e){if(!(!e||!e.trim())){if(e.trim().startsWith(`[`))try{let t=JSON.parse(e);if(Array.isArray(t))return t.map(String)}catch(e){br("the `suggestions` attribute is not valid JSON",e);return}return e.split(`|`).map(e=>e.trim()).filter(Boolean)}}function wr(e){if(e!==null)return e!==`false`&&e!==`0`}function Tr(e){return e===`dark`||e===`light`||e===`auto`?e:void 0}function Er(e){return e===`bottom-left`||e===`bottom-right`?e:void 0}function Dr(e){return e===`floating`||e===`sidebar`?e:void 0}var Or=[`context`,`embedKey`,`user`,`scope`,`getSubjectToken`,`agent`];function kr(){var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m;return t=new WeakMap,n=new WeakMap,r=new WeakMap,i=new WeakMap,a=new WeakMap,o=new WeakMap,s=new WeakMap,c=new WeakMap,l=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakSet,p=new WeakMap,m=new WeakMap,e=class extends HTMLElement{constructor(){super(),Ut(this,f),X(this,t,void 0),X(this,n,null),X(this,r,!1),X(this,i,!1),X(this,a,``),X(this,o,void 0),X(this,s,void 0),X(this,c,void 0),X(this,l,void 0),X(this,u,void 0),X(this,d,void 0),X(this,p,e=>{let{type:t,...n}=e;$(a,this,n.sessionId),this.dispatchEvent(new CustomEvent(t,{detail:n,bubbles:!0,composed:!0}))}),X(this,m,e=>{$(n,this,e),e&&$(a,this,e.sessionId())});let e=this.attachShadow({mode:`open`}),h=yr();if(h)e.adoptedStyleSheets=[h];else{let t=document.createElement(`style`);t.textContent=hr,e.append(t)}$(t,this,document.createElement(`div`)),e.append(Q(t,this));for(let e of Or){if(!Object.hasOwn(this,e))continue;let t=this[e];delete this[e],this[e]=t}}connectedCallback(){$(i,this,!0),Z(f,this,g).call(this)}disconnectedCallback(){$(i,this,!1),ae(null,Q(t,this)),$(n,this,null)}attributeChangedCallback(e,t,r){if(t!==r){if(e===`open`&&Q(n,this)){wr(r)?Q(n,this).open():Q(n,this).close();return}Z(f,this,h).call(this)}}get context(){return Q(o,this)??Sr(this.getAttribute(`context`))}set context(e){$(o,this,e),Z(f,this,h).call(this)}get embedKey(){return Q(d,this)??this.getAttribute(`embed-key`)??void 0}set embedKey(e){$(d,this,e),Z(f,this,h).call(this)}get scope(){return Q(c,this)}set scope(e){$(c,this,e),Z(f,this,h).call(this)}get user(){return Q(s,this)??xr(this.getAttribute(`user`))}set user(e){$(s,this,e),Z(f,this,h).call(this)}get getSubjectToken(){return Q(l,this)}set getSubjectToken(e){$(l,this,e),Z(f,this,h).call(this)}get agent(){return Q(u,this)??this.getAttribute(`agent`)??void 0}set agent(e){$(u,this,e),Z(f,this,h).call(this)}get open(){return Q(n,this)?.isOpen()??wr(this.getAttribute(`open`))??!1}set open(e){e?this.openChat():this.closeChat()}get sessionId(){return Q(n,this)?.sessionId()??Q(a,this)}openChat(){Q(n,this)?.open()}closeChat(){Q(n,this)?.close()}toggleChat(){Q(n,this)?.toggle()}reset(){Q(n,this)?.reset()}sendMessage(e){if(!Q(n,this)){br(`sendMessage() called before the component was mounted — ignored`);return}Q(n,this).send(e)}},Je(e,`observedAttributes`,_r),e;function h(){Q(r,this)||!Q(i,this)||($(r,this,!0),queueMicrotask(()=>{$(r,this,!1),Q(i,this)&&Z(f,this,g).call(this)}))}function g(){let e=e=>this.getAttribute(e)??void 0;ae(Y(mr,{embedKey:this.embedKey,context:this.context,user:this.user,scope:this.scope,getSubjectToken:this.getSubjectToken,agent:this.agent,heading:e(`heading`),subheading:e(`subheading`),assistantName:e(`assistant-name`),placeholder:e(`placeholder`),greeting:e(`greeting`),suggestions:Cr(this.getAttribute(`suggestions`)),width:e(`width`),accent:e(`accent`),theme:Tr(this.getAttribute(`theme`)),position:Er(this.getAttribute(`position`)),layout:Dr(this.getAttribute(`layout`)),defaultOpen:wr(this.getAttribute(`open`))??!1,persistOpen:wr(this.getAttribute(`persist-open`))??!0,showContext:wr(this.getAttribute(`show-context`))??!0,locale:e(`locale`),onEvent:Q(p,this),bind:Q(m,this)}),Q(t,this))}}var Ar;function jr(e=gr){typeof window>`u`||typeof HTMLElement>`u`||(Ar??(Ar=kr()),window.customElements.get(e)||window.customElements.define(e,Ar))}return jr(),e.API_URL=Ye,e.ChatHttpError=J,e.DEFAULT_LANGUAGE=je,e.MAX_MESSAGE_LENGTH=Xe,e.SUPPORTED_LANGUAGES=Me,e.TAG_NAME=gr,e.defineChatbot=jr,e})({});
7
+ `).replace(/^\n+|\n+$/g,``);e.trim()&&a.push({kind:`markdown`,text:e}),o=[]};for(let e=0;e<i.length;e+=1){let t=i[e];if(Bn.test(t)){let n=e+1;for(;n<i.length&&!Bn.test(i[n]);)n+=1;let r=n<i.length,c=t.replace(/^\s*```/,``).trim().toLowerCase(),l=i.slice(e+1,n).join(`
8
+ `),u=null;if(r&&c===`form`){let e=In(l);e&&(u={kind:`form`,form:e})}u?(s(),a.push(u)):o.push(...i.slice(e,r?n+1:n)),e=r?n:n-1;continue}if(Rn.test(t)&&e+1<i.length&&zn.test(i[e+1])){s();let n=Vn(t),r=[];for(e+=2;e<i.length&&Rn.test(i[e]);)r.push(Vn(i[e])),e+=1;--e,a.push({kind:`table`,header:n,rows:r});continue}let n=Ln.exec(t);if(n){let t=n[1]!==void 0,r=[],c=[],l=e,u=n;for(;u&&u[1]!==void 0===t;){let e=u[3].trim();r.push(e),(u[1]??u[2])!==` `&&(t||!c.length)&&c.push(e),l+=1,u=l<i.length?Ln.exec(i[l]):null}if(r.length>20)o.push(...i.slice(e,l));else{s();let e={kind:`choices`,options:r,multiple:t};c.length&&(e.checked=c),a.push(e)}e=l-1;continue}o.push(t)}return s(),{blocks:a,confirm:r}}var Un=/^(\s*)[-*•]\s+/,Wn=/^(\s*)\d+[.)]\s+/,Gn=/^\s{0,3}(#{1,6})\s+(.+?)#*\s*$/,Kn=/^\s*([-*_])(?:\s*\1){2,}\s*$/,qn=/^\s*>\s?(.*)$/,Jn=/^\s*```/;function Yn(e,t,n,r){let i=e[t].ordered,a=[],o=t;for(;o<e.length&&e[o].depth>=n;){let t=e[o];if(t.depth===n&&t.ordered!==i)break;if(t.depth>n){let[n,i]=Yn(e,o,t.depth,`${r}-${o}`),s=a[a.length-1];s?s.nested.push(n):a.push({key:`${r}-${o}`,text:null,nested:[n]}),o=i;continue}a.push({key:`${r}-${o}`,text:t.text,nested:[]}),o+=1}let s=a.map(e=>Y(`li`,{children:[e.text===null?null:nn(e.text,e.key),e.nested]},e.key));return[Y(i?`ol`:`ul`,{children:s},r),o]}function Xn(e){let t=e.split(`
9
+ `),n=[],r=[],i=[],a=[],o=()=>{if(!r.length)return;let e=`p${n.length}`;n.push(Y(`p`,{children:nn(r.join(`
10
+ `),e)},e)),r=[]},s=()=>{if(!i.length)return;let e=0;for(;e<i.length;){let t=`l${n.length}`,[r,a]=Yn(i,e,i[e].depth,t);n.push(r),e=a}i=[]},c=()=>{if(!a.length)return;let e=`q${n.length}`;n.push(Y(`blockquote`,{children:nn(a.join(`
11
+ `),e)},e)),a=[]},l=()=>{o(),s(),c()};for(let e=0;e<t.length;e+=1){let u=t[e];if(Jn.test(u)){l();let r=[];for(e+=1;e<t.length&&!Jn.test(t[e]);)r.push(t[e]),e+=1;let i=`c${n.length}`;n.push(Y(`pre`,{children:Y(`code`,{children:r.join(`
12
+ `)})},i));continue}if(!u.trim()){l();continue}let d=Gn.exec(u);if(d){l();let e=d[1].length,t=e<=2?`h3`:e===3?`h4`:`h5`,r=`h${n.length}`;n.push(Y(t,{children:nn(d[2],r)},r));continue}if(Kn.test(u)){l(),n.push(Y(`hr`,{},`r${n.length}`));continue}let f=qn.exec(u);if(f){o(),s(),a.push(f[1]);continue}let p=Un.exec(u),m=p?null:Wn.exec(u),h=p??m;if(h){o(),c(),i.push({depth:h[1].replace(/\t/g,` `).length,ordered:!!m,text:u.slice(h[0].length)});continue}s(),c(),r.push(u)}return l(),n}function Zn(e){let t=K(null),{form:n,locked:r,language:i}=e;return _e(()=>{Cn()},[]),_e(()=>{t.current&&Object.assign(t.current,{form:n,locked:r,language:i})},[n,r,i]),Y(`sqc-form`,{ref:t,children:n.fields.map(e=>Y(`p`,{children:e.label},e.name))})}function Qn(e,t,n){switch(e.kind){case`markdown`:return Y(C,{children:Xn(e.text)});case`table`:return Y(`sqc-table`,{table:{header:e.header,rows:e.rows},locked:n,language:t.code});case`choices`:return Y(`sqc-choices`,{options:e.options,multiple:e.multiple,checked:e.checked,locked:n,language:t.code});case`form`:return Y(Zn,{form:e.form,locked:n,language:t.code})}}function $n({text:e,locale:t,live:n,confirmable:r}){let{blocks:i,confirm:a}=Hn(e,t.code,r===!0),o=!n;return Y(C,{children:[i.map((e,n)=>Y(C,{children:Qn(e,t,o)},`b${n}`)),a&&Y(`sqc-confirm`,{locked:o,language:t.code})]})}var er=80;function tr({at:e,locale:t}){let n=new Date(e);return Y(`time`,{class:`sqc-msg__time`,dateTime:n.toISOString(),children:n.toLocaleTimeString(t.tag,{hour:`2-digit`,minute:`2-digit`})})}function nr(e){let{call:t,locked:n,locale:r}=e,i=r.code,a=K(null);_e(()=>{Cn()},[t,n]),_e(()=>{a.current&&Object.assign(a.current,{call:t,locked:n,language:i})},[t,n,i]);let o=e=>t=>t.currentTarget?.dispatchEvent(new CustomEvent(`sqc-decision`,{detail:{approved:e},bubbles:!0,composed:!0})),{yes:s,no:c}=r.t.confirm;return Y(`sqc-approval`,{ref:a,children:[t&&Y(`p`,{children:hn(t.tool)}),Y(`button`,{type:`button`,disabled:n,onClick:o(!0),children:s}),Y(`button`,{type:`button`,disabled:n,onClick:o(!1),children:c})]})}function rr({file:e,load:t}){let[n,r]=W(null);return G(()=>{let n=null,i=!0;return t(e.id).then(e=>{i&&(n=URL.createObjectURL(e),r(n))}).catch(()=>{}),()=>{i=!1,n&&URL.revokeObjectURL(n)}},[e.id,t]),n?Y(`img`,{class:`sqc-attachment__image`,src:n,alt:e.filename}):Y(`span`,{class:`sqc-chip sqc-chip--waiting`,children:e.filename})}function ir(e){let{file:t,load:n,language:r}=e,i=K(null),a=ve(()=>n(t.id).then(e=>e.text()).catch(()=>``),[t.id,n]);return _e(()=>{Cn()},[]),_e(()=>{i.current&&Object.assign(i.current,{body:a,filename:t.filename,language:r})},[a,t.filename,r]),Y(`sqc-chart`,{class:`sqc-attachment__chart`,ref:i,children:t.filename})}function ar({files:e,load:t,language:n}){return e.length===0||!t?null:Y(`div`,{class:`sqc-attachments sqc-attachments--sent`,children:e.map(e=>e.kind===`image`?Y(rr,{file:e,load:t},e.id):e.kind===`chart`?Y(ir,{file:e,load:t,language:n},e.id):Y(`span`,{class:`sqc-chip`,"data-kind":`document`,children:Y(`span`,{class:`sqc-chip__name`,children:e.filename})},e.id))})}function or({message:e,locale:t,assistantName:n,live:r,onDecide:i,onLoadAttachment:a}){let o=e.streaming&&!e.content,s=!!e.approval;return Y(`div`,{class:`sqc-msg sqc-msg--${e.role}${e.error?` sqc-msg--error`:``}`,children:[e.role===`assistant`&&Y(`div`,{class:`sqc-msg__who`,children:[e.agent?Y(Ft,{name:e.agent.name,color:e.agent.color,url:e.agent.avatarUrl}):Y(cr,{}),e.authorName??e.agent?.name??n]}),Y(`div`,{class:`sqc-msg__bubble`,children:[o?Y(`span`,{class:`sqc-waiting`,children:[Y(`span`,{class:`sqc-typing`,"aria-label":t.t.typing,children:[Y(`i`,{}),Y(`i`,{}),Y(`i`,{})]}),e.activity&&Y(`span`,{class:`sqc-activity`,role:`status`,children:t.t.activity[e.activity]})]}):Y(`div`,{class:`sqc-msg__body`,children:[Y($n,{text:e.content,locale:t,live:r,confirmable:e.role===`assistant`&&!s&&!e.streaming&&!e.error}),e.streaming&&Y(`span`,{class:`sqc-caret`,"aria-hidden":`true`}),s&&Y(nr,{locale:t,call:e.content.trim()===``?e.approval:void 0,locked:!i}),e.unknownHandle&&!e.streaming&&Y(sr,{message:e,locale:t}),Y(ar,{files:e.attachments??[],load:a,language:t.code})]}),!o&&Y(tr,{at:e.createdAt,locale:t})]})]})}function sr({message:e,locale:t}){let n=e.offered??[];return Y(`p`,{class:`sqc-msg__unaddressed`,children:[Y(`span`,{children:t.t.handles.unknown}),` `,Y(`code`,{children:[`@`,e.unknownHandle]}),n.length>0&&Y(C,{children:[` `,Y(`span`,{children:t.t.handles.instead}),` `,n.map(e=>Y(`code`,{children:[`@`,e.handle]},e.handle))]})]})}function cr(){return Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:Y(`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`})})}function lr({messages:e,locale:t,assistantName:n,suggestions:r,showSuggestions:i,busy:a,withHuman:o,onSuggestion:s,onChoice:c,onDecide:l,onCompose:u,onLoadAttachment:d}){let f=K(null),p=K(!0);_e(()=>{let e=f.current;e&&p.current&&(e.scrollTop=e.scrollHeight)},[e]);let m=K({onChoice:c,onCompose:u});m.current={onChoice:c,onCompose:u},G(()=>{let e=f.current;if(!e)return;let t=e=>{e.stopPropagation();let t=e.detail?.text;typeof t==`string`&&m.current.onChoice(t)},n=e=>{e.stopPropagation(),m.current.onCompose?.()};return e.addEventListener(`sqc-reply`,t),e.addEventListener(`sqc-compose`,n),()=>{e.removeEventListener(`sqc-reply`,t),e.removeEventListener(`sqc-compose`,n)}},[]);let h=e[e.length-1],g=!a&&h?.role===`assistant`&&!!h.approval,_=K({onDecide:l,decidable:g,locale:t});return _.current={onDecide:l,decidable:g,locale:t},G(()=>{let e=f.current;if(!e)return;let t=e=>{e.stopPropagation();let t=e.detail?.approved,n=_.current;if(typeof t!=`boolean`||!n.decidable)return;let{yes:r,no:i}=n.locale.t.confirm;n.onDecide(t,t?r:i)};return e.addEventListener(`sqc-decision`,t),()=>e.removeEventListener(`sqc-decision`,t)},[]),G(()=>{let e=f.current;if(!e)return;let t=()=>{p.current=e.scrollHeight-e.scrollTop-e.clientHeight<er};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),Y(`div`,{class:`sqc-messages`,ref:f,role:`log`,"aria-live":`polite`,"aria-atomic":`false`,children:[e.map((r,i)=>Y(or,{message:r,locale:t,assistantName:n,live:!a&&wn(i,e),onDecide:!a&&r.role===`assistant`&&i===e.length-1?l:void 0,onLoadAttachment:d},r.id)),o&&Y(`p`,{class:`sqc-with-human`,role:`status`,children:t.t.withHuman}),i&&r&&r.length>0&&Y(`div`,{class:`sqc-suggestions`,children:r.map(e=>Y(`button`,{type:`button`,class:`sqc-suggestion`,onClick:()=>s(e),children:e},e))})]})}var ur={width:`min(392px, 100vw)`},dr=new Set([`sessionId`]);function fr(e){let t=e.replace(/Id$|Ref$/,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):e}function pr(e){if(!e)return[];let t=[];for(let[n,r]of Object.entries(e)){if(dr.has(n)||typeof r!=`string`&&!ke(r))continue;let e=Oe(r);e&&t.push({label:fr(n),value:e})}return t}function mr(e,t){return e?.trim()?e:t}function hr(e){let[t,n]=W(!1);return G(()=>{if(e!==`auto`||typeof matchMedia!=`function`)return;let t=matchMedia(`(prefers-color-scheme: dark)`);n(t.matches);let r=e=>n(e.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),e===`dark`?`dark`:e===`light`?`light`:t?`dark`:`light`}function gr(e){pn();let t=e.persistOpen??!0,[n,r]=W(()=>Ve(e.defaultOpen,t)),[i,a]=W(!1),o=K(null),s=K(null),c=hr(e.theme??`light`),l=ve(()=>Le(e.locale),[e.locale]),u=l.t,d=mr(e.heading,u.heading),f=mr(e.assistantName,u.assistant),p=mr(e.greeting,u.greeting),m=e.onEvent,{send:h,reset:g,decide:_,stop:v,start:y,resets:b,busy:x,messages:S,withHuman:C,branding:w,sessionId:T,handles:E,addressee:D,agentHandle:O,welcomeSuggestions:k,attachments:A,uploading:j,attachmentError:M,attach:N,detach:P,loadAttachment:F,switchTo:I}=Nt({embedKey:e.embedKey,user:e.user,scope:e.scope,getSubjectToken:e.getSubjectToken,agent:e.agent,context:e.context,greeting:p,locale:l,onEvent:m});G(()=>{!n&&S.some(e=>e.role===`assistant`&&e.id!==`greeting`)&&a(!0)},[S,n]);let L=K(n);L.current=n;let ee=q(()=>{a(!1),!L.current&&(L.current=!0,r(!0),t&&Be(!0),m?.({type:`chatbot-open`,sessionId:T}))},[m,t,T]),te=q(()=>{L.current&&(L.current=!1,r(!1),t&&Be(!1),m?.({type:`chatbot-close`,sessionId:T}),s.current?.focus())},[m,t,T]);G(()=>{n&&y()},[n,b,y]);let ne=E.length>=2,re=h,R=q(()=>{a(!1),g()},[g]),z=K({openPanel:ee,closePanel:te,send:re,reset:R,sessionId:T});z.current={openPanel:ee,closePanel:te,send:re,reset:R,sessionId:T};let ie=K({open:()=>z.current.openPanel(),close:()=>z.current.closePanel(),toggle:()=>L.current?z.current.closePanel():z.current.openPanel(),reset:()=>z.current.reset(),send:e=>{z.current.openPanel(),z.current.send(e)},isOpen:()=>L.current,sessionId:()=>z.current.sessionId}),B=e.bind;_e(()=>(B?.(ie.current),()=>B?.(null)),[B]),G(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&(e.stopPropagation(),te())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[te,n]);let V=ve(()=>S.some(e=>e.role===`user`),[S]),H=k.length>0?k:e.suggestions,ae=ve(()=>pr(e.context),[e.context]),oe={...e.accent?{"--sqc-accent":e.accent}:{},"--sqc-width":e.width??ur.width};return Y(`div`,{class:`sqc`,"data-theme":c,"data-position":e.position??`bottom-right`,"data-layout":e.layout??`sidebar`,"data-open":n?`true`:`false`,style:oe,children:[Y(`button`,{ref:s,type:`button`,class:`sqc-launcher`,"aria-label":d,"aria-expanded":n,"aria-haspopup":`dialog`,onClick:ee,children:[Y(`span`,{class:`sqc-launcher__icon`,children:Y(`slot`,{name:`launcher-icon`,class:`sqc-slot-icon`,children:Y(cr,{})})}),i&&Y(`span`,{class:`sqc-launcher__badge`,"aria-hidden":`true`})]}),Y(`aside`,{ref:o,class:`sqc-panel`,role:`dialog`,"aria-modal":`false`,"aria-label":d,...n?{}:{inert:!0},children:[Y(`header`,{class:`sqc-header`,children:[Y(`span`,{class:`sqc-header__icon`,"aria-hidden":`true`,children:Y(cr,{})}),Y(`div`,{class:`sqc-header__titles`,children:[Y(`p`,{class:`sqc-header__heading`,children:d}),Y(`p`,{class:`sqc-header__sub`,children:mr(e.subheading,u.subheading)})]}),Y(`button`,{type:`button`,class:`sqc-icon-btn`,onClick:R,"aria-label":u.newConversation,"data-tip":u.newConversation,children:Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,children:Y(`path`,{d:`M20 12a8 8 0 1 1-2.6-5.9M20 4v4h-4`,"stroke-linecap":`round`})})}),Y(`button`,{type:`button`,class:`sqc-icon-btn`,onClick:te,"aria-label":u.close,"data-tip":u.closeTitle,children:Y(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,children:Y(`path`,{d:`M6 6l12 12M18 6L6 18`,"stroke-linecap":`round`})})})]}),Y(`div`,{class:`sqc-panel__body`,children:[ne&&Y(Lt,{handles:E,active:O||void 0,disabled:x,onPick:I,label:u.handles.rail}),Y(`div`,{class:`sqc-panel__main`,children:[(e.showContext??!0)&&ae.length>0&&Y(`div`,{class:`sqc-context`,"aria-label":u.context.region,children:ae.map(e=>Y(`span`,{class:`sqc-chip`,title:`${e.label}: ${e.value}`,children:[Y(`b`,{children:e.label}),e.value]},e.label))}),Y(lr,{messages:S,locale:l,assistantName:f,suggestions:H,showSuggestions:!V,busy:x,withHuman:C,onSuggestion:re,onChoice:re,onDecide:_,onCompose:()=>o.current?.querySelector(`.sqc-composer__input`)?.focus(),onLoadAttachment:F}),Y(Ut,{placeholder:mr(e.placeholder,u.placeholder),locale:l,busy:x,autoFocus:n,handles:E,addressee:D,attachments:A,uploading:j,attachmentError:M?u.attachments[M]:void 0,onAttach:N,onDetach:P,onSend:re,onStop:v}),Y(`p`,{class:`sqc-hint`,children:u.hint}),w&&Y(`p`,{class:`sqc-powered`,children:Y(`a`,{href:`https://squadico.com`,target:`_blank`,rel:`noopener noreferrer`,children:u.poweredBy})})]})]})]})]})}var _r=`:host{--sqc-width:min(392px, 100vw);--sqc-height:640px;--sqc-z:2147480000;--sqc-radius:16px;--sqc-font-family:"Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;--sqc-font-heading:var(--sqc-font-family);z-index:var(--sqc-z);pointer-events:none;font-family:var(--sqc-font-family);-webkit-font-smoothing:antialiased;text-align:left;font-size:14px;line-height:1.5;display:block;position:fixed;top:0;bottom:0;left:0;right:0;margin:0!important}:host([hidden]){display:none}.sqc{--sqc-neutral-50:#f8fafc;--sqc-neutral-100:#f1f5f9;--sqc-neutral-200:#e2e8f0;--sqc-neutral-300:#cbd5e1;--sqc-neutral-400:#94a3b8;--sqc-neutral-500:#64748b;--sqc-neutral-600:#475569;--sqc-neutral-900:#0f172a;--sqc-error-50:#fff1f2;--sqc-error-100:#ffe4e6;--sqc-error-600:#e11d48;--sqc-accent-default:#000;--sqc-accent-color:var(--sqc-accent,var(--sqc-accent-default));--sqc-on-accent:#fff;--sqc-accent-hover:color-mix(in oklab, var(--sqc-accent-color) 84%, var(--sqc-on-accent));--sqc-accent-fg:var(--sqc-accent,var(--sqc-text));--sqc-bg:#fff;--sqc-surface:var(--sqc-neutral-50);--sqc-selected:var(--sqc-neutral-100);--sqc-border:var(--sqc-neutral-200);--sqc-border-strong:var(--sqc-neutral-300);--sqc-text:var(--sqc-neutral-900);--sqc-text-muted:var(--sqc-neutral-500);--sqc-link:#2563eb;--sqc-bubble-user:var(--sqc-accent-color);--sqc-bubble-user-text:var(--sqc-on-accent);--sqc-code-bg:var(--sqc-neutral-100);--sqc-disabled:var(--sqc-neutral-300);--sqc-shadow:0 10px 15px -3px #0f172a1a, 0 4px 6px -4px #0f172a1a;--sqc-shadow-bottom:0 6px 8px -6px #0f172a2e;--sqc-focus:0 0 0 2px var(--sqc-bg), 0 0 0 4px #0f172a4d;--sqc-focus-input:0 0 0 3px #0f172a1a;--sqc-danger:var(--sqc-error-600);color:var(--sqc-text);position:absolute;top:0;bottom:0;left:0;right:0}.sqc[data-theme=dark]{--sqc-neutral-50:#172033;--sqc-neutral-100:#1e293b;--sqc-neutral-200:#334155;--sqc-neutral-300:#475569;--sqc-neutral-400:#64748b;--sqc-neutral-500:#94a3b8;--sqc-neutral-600:#cbd5e1;--sqc-neutral-900:#f8fafc;--sqc-error-50:#2a0a12;--sqc-error-100:#4c0519;--sqc-error-600:#fb7185;--sqc-accent-default:#fff;--sqc-on-accent:#0f172a;--sqc-bg:#0f172a;--sqc-link:#60a5fa;--sqc-code-bg:#020617;--sqc-shadow:0 10px 24px -4px #0000008c;--sqc-shadow-bottom:0 6px 8px -6px #0000008c;--sqc-focus:0 0 0 2px var(--sqc-bg), 0 0 0 4px #f8fafc59;--sqc-focus-input:0 0 0 3px #f8fafc1f}@supports (color:oklch(from red l c h)){.sqc{--sqc-on-accent:oklch(from var(--sqc-accent-color) clamp(.208, (.62 - l) * 1000, 1) 0 0)}}.sqc *,.sqc :before,.sqc :after{box-sizing:border-box}.sqc-launcher{background:var(--sqc-accent-color);width:56px;height:56px;color:var(--sqc-on-accent);cursor:pointer;pointer-events:auto;box-shadow:var(--sqc-shadow);border:none;border-radius:50%;place-items:center;padding:0;transition:transform .18s,opacity .18s,background .18s,box-shadow .18s;display:grid;position:absolute;bottom:24px;right:24px}.sqc[data-position=bottom-left] .sqc-launcher{left:24px;right:auto}.sqc-launcher:hover{background:var(--sqc-accent-hover);transform:scale(1.06)}.sqc-launcher:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc[data-open=true] .sqc-launcher{opacity:0;pointer-events:none;transform:scale(.5)}.sqc-launcher__icon svg{width:26px;height:26px;display:block}.sqc-slot-icon::slotted(*){justify-content:center;align-items:center;width:26px;height:26px;display:inline-flex}.sqc-launcher__badge{background:var(--sqc-error-600);border:2px solid var(--sqc-bg);border-radius:50%;width:12px;height:12px;position:absolute;top:6px;right:6px}.sqc-panel{width:var(--sqc-width);background:var(--sqc-bg);border-left:1px solid var(--sqc-border);box-shadow:var(--sqc-shadow);pointer-events:auto;visibility:hidden;flex-direction:column;transition:transform .26s cubic-bezier(.22,1,.36,1),visibility 0s linear .26s;display:flex;position:absolute;top:0;bottom:0;right:0;transform:translate(100%)}.sqc-panel__body{flex:1;min-height:0;display:flex}.sqc-panel__main{flex-direction:column;flex:1;min-width:0;min-height:0;display:flex}.sqc-rail{border-right:1px solid var(--sqc-border);background:color-mix(in oklab, var(--sqc-accent-color) 7%, var(--sqc-bg));flex-direction:column;flex-shrink:0;align-items:stretch;gap:6px;width:72px;padding:12px 0;display:flex;overflow:visible}.sqc-rail__item{color:var(--sqc-text-muted);font:inherit;cursor:pointer;background:0 0;border:0;flex-direction:column;align-items:center;gap:4px;padding:4px 0;display:flex;position:relative}.sqc-rail__label{white-space:nowrap;text-overflow:ellipsis;max-width:64px;font-size:10.5px;font-weight:500;line-height:1.2;overflow:hidden}.sqc-rail__item:hover,.sqc-rail__item[aria-pressed=true]{color:var(--sqc-text)}.sqc-rail__item[aria-pressed=true] .sqc-rail__label{font-weight:600}.sqc-rail__item .sqc-avatar{transition:box-shadow .15s}.sqc-rail__item[aria-pressed=true] .sqc-avatar{box-shadow:0 0 0 2px var(--sqc-bg), 0 0 0 4px var(--sqc-accent-color)}.sqc-rail__item:before{content:"";background:var(--sqc-text);border-radius:0 4px 4px 0;width:4px;height:0;transition:height .15s;position:absolute;top:24px;left:0;transform:translateY(-50%)}.sqc-rail__item:hover:before{height:12px}.sqc-rail__item[aria-pressed=true]:before{height:32px}.sqc-rail__item:focus-visible{outline:2px solid var(--sqc-accent-color);outline-offset:-2px;border-radius:8px}.sqc-rail__item:disabled{cursor:not-allowed;opacity:.5}.sqc-rail__item[data-tip]:after{content:attr(data-tip);z-index:2;background:var(--sqc-text);color:var(--sqc-bg);white-space:nowrap;pointer-events:none;opacity:0;border-radius:6px;padding:4px 8px;font-size:12px;font-weight:500;transition:opacity .12s;position:absolute;top:24px;left:calc(100% + 6px);transform:translateY(-50%)}.sqc-rail__item[data-tip]:hover:after{opacity:1}.sqc-rail__item[data-tip]:focus-visible:after{opacity:1}.sqc[data-open=true] .sqc-panel{visibility:visible;transition:transform .26s cubic-bezier(.22,1,.36,1),visibility;transform:translate(0)}.sqc[data-layout=floating] .sqc-panel{max-width:calc(100% - 48px);height:var(--sqc-height);border:1px solid var(--sqc-border);border-radius:var(--sqc-radius);opacity:0;transform-origin:100% 100%;max-height:calc(100% - 48px);transition:transform .22s cubic-bezier(.22,1,.36,1),opacity .22s,visibility 0s linear .22s;top:auto;bottom:24px;right:24px;overflow:hidden;transform:translateY(16px)scale(.96)}.sqc[data-layout=floating][data-position=bottom-left] .sqc-panel{transform-origin:0 100%;left:24px;right:auto}.sqc[data-layout=floating][data-open=true] .sqc-panel{opacity:1;transition:transform .22s cubic-bezier(.22,1,.36,1),opacity .22s,visibility;transform:none}.sqc-header{background:var(--sqc-bg);color:var(--sqc-text);border-bottom:1px solid var(--sqc-border);flex-shrink:0;align-items:center;gap:8px;padding:13px 12px 13px 16px;display:flex}.sqc-header__icon{color:var(--sqc-accent-fg);flex-shrink:0;place-items:center;display:grid}.sqc-header__icon svg{width:17px;height:17px;display:block}.sqc-header__titles{flex:1;min-width:0}.sqc-header__heading,.sqc-header__sub{text-overflow:ellipsis;white-space:nowrap;margin:0;overflow:hidden}.sqc-header__heading{font-family:var(--sqc-font-heading);letter-spacing:-.2px;font-size:15px;font-weight:700}.sqc-header__sub{color:var(--sqc-text-muted);font-size:12px}.sqc-icon-btn{width:26px;height:26px;color:var(--sqc-text-muted);cursor:pointer;background:0 0;border:none;border-radius:8px;flex-shrink:0;place-items:center;transition:background .15s;display:grid}.sqc-icon-btn:hover{background:var(--sqc-surface);color:var(--sqc-text)}.sqc-icon-btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-icon-btn svg{width:16px;height:16px}.sqc-icon-btn[data-tip]{position:relative}.sqc-icon-btn[data-tip]:after{content:attr(data-tip);z-index:6;background:var(--sqc-text);color:var(--sqc-bg);font-family:var(--sqc-font-family);white-space:nowrap;pointer-events:none;opacity:0;border-radius:8px;padding:4px 8px;font-size:11px;font-weight:500;line-height:1.3;transition:opacity .12s .15s;position:absolute;top:calc(100% + 6px);right:0}.sqc-icon-btn[data-tip]:hover:after{opacity:1}.sqc-icon-btn[data-tip]:focus-visible:after{opacity:1}.sqc-history-pop{z-index:5;position:absolute;top:54px;left:0;right:0}.sqc-history{background:var(--sqc-bg);max-height:320px;box-shadow:var(--sqc-shadow-bottom);flex-direction:column;display:flex;overflow-y:auto}.sqc-history__empty{color:var(--sqc-text-muted);text-align:center;margin:0;padding:14px 16px;font-size:12px}.sqc-history__item{border:none;border-bottom:1px solid var(--sqc-border);width:100%;color:var(--sqc-text);text-align:left;cursor:pointer;background:0 0;flex-direction:column;gap:2px;padding:10px 16px;transition:background .15s;display:flex}.sqc-history__item:last-child{border-bottom:none}.sqc-history__item:hover{background:var(--sqc-surface)}.sqc-history__item:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-history__item[aria-current=true]{background:var(--sqc-selected)}.sqc-history__item[aria-current=true] .sqc-history__title{color:var(--sqc-text);font-weight:600}.sqc-history__title{text-overflow:ellipsis;white-space:nowrap;font-size:13px;overflow:hidden}.sqc-history__date{color:var(--sqc-text-muted);font-size:11px}.sqc-context{background:var(--sqc-selected);border:1px solid var(--sqc-border);color:var(--sqc-text);border-radius:12px;flex-wrap:wrap;flex-shrink:0;align-items:center;gap:8px;margin:12px 16px 4px;padding:8px 11px;font-size:12px;display:flex}.sqc-chip{text-overflow:ellipsis;white-space:nowrap;align-items:baseline;gap:4px;max-width:100%;display:inline-flex;overflow:hidden}.sqc-chip b{font-weight:600}.sqc-chip:not(:last-child):after{content:"·";opacity:.5;margin-left:4px}.sqc-messages{overscroll-behavior:contain;background:var(--sqc-bg);scrollbar-width:thin;scrollbar-color:var(--sqc-neutral-300) transparent;flex-direction:column;flex:1;gap:13px;min-height:0;padding:12px 16px;display:flex;overflow-y:auto}.sqc-messages::-webkit-scrollbar{width:6px}.sqc-messages::-webkit-scrollbar-thumb{background:var(--sqc-neutral-300);border-radius:99px}.sqc-msg{flex-direction:column;max-width:93%;font-size:13.5px;display:flex}.sqc-msg--assistant{align-self:stretch}.sqc-msg--user{align-self:flex-end}.sqc-msg__who{color:var(--sqc-text-muted);align-items:center;gap:6px;margin-bottom:4px;font-size:11px;font-weight:500;display:flex}.sqc-msg__who svg{width:12px;height:12px;color:var(--sqc-accent-fg);flex-shrink:0}.sqc-avatar{background:var(--sqc-accent-color);color:var(--sqc-on-accent);-webkit-user-select:none;user-select:none;flex-shrink:0;justify-content:center;align-items:center;font-weight:600;line-height:1;display:inline-flex;overflow:hidden}.sqc-avatar img{object-fit:cover;width:100%;height:100%}.sqc-msg__unaddressed{color:var(--sqc-text-muted);margin:8px 0 0;font-size:11.5px;line-height:1.5}.sqc-msg__unaddressed code{background:var(--sqc-code-bg);color:var(--sqc-text);border-radius:4px;margin-right:4px;padding:1px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11px}.sqc-msg--user .sqc-msg__bubble{background:var(--sqc-bubble-user);color:var(--sqc-bubble-user-text);border-radius:var(--sqc-radius) var(--sqc-radius) 4px var(--sqc-radius);padding:9px 13px}.sqc-msg--error .sqc-msg__bubble{background:var(--sqc-error-50);color:var(--sqc-error-600);border:1px solid var(--sqc-error-100);border-radius:12px;padding:11px}.sqc-msg__body{overflow-wrap:anywhere}.sqc-msg--assistant .sqc-msg__body{font-size:14px;line-height:1.6}.sqc-msg__body>:first-child{margin-top:0}.sqc-msg__body>:last-child{margin-bottom:0}.sqc-msg__body p{white-space:pre-wrap;margin:0 0 8px}.sqc-msg__body ul,.sqc-msg__body ol{margin:0 0 8px;padding-left:20px}.sqc-msg__body li{margin-bottom:3px}.sqc-msg__body code{background:var(--sqc-code-bg);border-radius:4px;padding:1px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.85em}.sqc-msg--user .sqc-msg__body code{background:#ffffff38}.sqc-msg__body pre{background:var(--sqc-code-bg);border-radius:8px;margin:0 0 8px;padding:9px 11px;overflow-x:auto}.sqc-msg__body pre code{background:0 0;padding:0}.sqc-msg__body a{color:inherit;text-underline-offset:2px;text-decoration:underline}.sqc-msg--assistant .sqc-msg__body a{color:var(--sqc-link);text-decoration:none}.sqc-msg--assistant .sqc-msg__body a:hover{text-decoration:underline}.sqc-msg__body h3,.sqc-msg__body h4,.sqc-msg__body h5,.sqc-msg__body h6{font-family:var(--sqc-font-heading);letter-spacing:-.2px;margin:12px 0 6px;font-weight:700;line-height:1.3}.sqc-msg__body h3{font-size:1.05em}.sqc-msg__body h4{font-size:1em}.sqc-msg__body h5,.sqc-msg__body h6{font-size:.94em}.sqc-msg__body ul ul,.sqc-msg__body ul ol,.sqc-msg__body ol ul,.sqc-msg__body ol ol{margin:3px 0 0}.sqc-msg__body blockquote{border-left:2px solid var(--sqc-border-strong);color:var(--sqc-text-muted);white-space:pre-wrap;margin:0 0 8px;padding:2px 0 2px 10px}.sqc-msg--user .sqc-msg__body blockquote{color:inherit;opacity:.85;border-left-color:#ffffff73}.sqc-msg__body hr{border:0;border-top:1px solid var(--sqc-border);margin:10px 0}.sqc-msg--user .sqc-msg__body hr{border-top-color:#ffffff4d}.sqc-msg__body del{opacity:.7}.sqc-selection{flex-direction:column;gap:10px;margin:2px 0;display:flex}.sqc-selection__question{flex-direction:column;gap:2px;display:flex}.sqc-selection__ask{font-family:var(--sqc-font-family);color:var(--sqc-text);margin:0;font-size:13px;font-weight:600}.sqc-selection__actions{display:flex}.sqc-selection__validate{height:32px;font-family:var(--sqc-font-family);color:var(--sqc-on-accent);background:var(--sqc-accent-color);cursor:pointer;border:1px solid #0000;border-radius:12px;flex:auto;justify-content:center;align-items:center;padding:0 12px;font-size:13px;font-weight:600;transition:filter .12s,background .12s;display:inline-flex}.sqc-selection__validate:hover:not(:disabled){background:var(--sqc-accent-hover)}.sqc-selection__validate:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-selection__validate:disabled{cursor:not-allowed;color:#fff;background:var(--sqc-disabled)}.sqc-selection__hint{font-family:var(--sqc-font-family);color:var(--sqc-text-muted);margin:0;font-size:11.5px}.sqc-msg__time{color:var(--sqc-text-muted);font-variant-numeric:tabular-nums;margin-top:3px;font-size:10px;display:block}.sqc-msg--user .sqc-msg__time{color:#ffffffb3;text-align:right}.sqc-caret{vertical-align:text-bottom;background:currentColor;width:2px;height:1em;margin-left:2px;animation:1s step-end infinite sqc-blink;display:inline-block}@keyframes sqc-blink{0%,to{opacity:1}50%{opacity:0}}.sqc-typing{gap:3px;padding:2px 0;display:inline-flex}.sqc-typing i{background:var(--sqc-neutral-400);border-radius:50%;width:5px;height:5px;animation:1.2s infinite sqc-pulse}.sqc-typing i:nth-child(2){animation-delay:.2s}.sqc-typing i:nth-child(3){animation-delay:.4s}.sqc-waiting{align-items:center;gap:8px;display:inline-flex}.sqc-activity{color:var(--sqc-text-muted);font-size:12px}@keyframes sqc-pulse{0%,60%,to{opacity:.25}30%{opacity:1}}.sqc-suggestions{flex-direction:column;gap:7px;display:flex}.sqc-suggestion{border:1px solid var(--sqc-border);background:var(--sqc-bg);width:100%;color:var(--sqc-text);font-family:var(--sqc-font-family);cursor:pointer;text-align:left;border-radius:12px;align-items:center;gap:8px;padding:8px 11px;font-size:12.5px;transition:background .15s,border-color .15s;display:flex}.sqc-suggestion:before{content:"";background:var(--sqc-accent-fg);border-radius:50%;flex:none;width:5px;height:5px}.sqc-suggestion:hover{background:var(--sqc-surface);border-color:var(--sqc-border-strong)}.sqc-suggestion:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-composer{border-top:1px solid var(--sqc-border);background:var(--sqc-bg);flex-wrap:wrap;flex-shrink:0;align-items:flex-end;gap:8px;padding:12px 14px;display:flex}.sqc-composer--dropping{outline:2px dashed var(--sqc-accent-color);outline-offset:-4px}.sqc-attachments{flex-wrap:wrap;flex-basis:100%;gap:6px;display:flex}.sqc-attachments--sent{margin-top:8px}.sqc-chip{border:1px solid var(--sqc-border);background:var(--sqc-selected);max-width:100%;color:var(--sqc-text);border-radius:999px;align-items:center;gap:4px;padding:3px 4px 3px 10px;font-size:12px;display:inline-flex}.sqc-chip--waiting{opacity:.6;padding-right:10px}.sqc-chip__name{text-overflow:ellipsis;white-space:nowrap;max-width:180px;overflow:hidden}.sqc-chip__remove{width:18px;height:18px;color:var(--sqc-text-muted);cursor:pointer;background:0 0;border:0;border-radius:999px;justify-content:center;align-items:center;padding:0;font-size:14px;line-height:1;display:inline-flex}.sqc-chip__remove:hover{background:var(--sqc-selected);color:var(--sqc-text)}.sqc-attachments__error{color:var(--sqc-error-600);flex-basis:100%;margin:0;font-size:12px}.sqc-attachment__image{border-radius:12px;max-width:100%;max-height:180px;display:block}.sqc-attachment__chart{flex-basis:100%;min-width:0}.sqc-file-input{display:none}.sqc-btn--attach{color:var(--sqc-text-muted);background:0 0}.sqc-btn--attach:hover{background:var(--sqc-selected);color:var(--sqc-text)}.sqc-composer__field{flex:1;min-width:0;position:relative}.sqc-composer__input{border:1px solid var(--sqc-border-strong);background:var(--sqc-bg);width:100%;min-height:38px;max-height:132px;color:var(--sqc-text);font-family:var(--sqc-font-family);resize:none;border-radius:12px;outline:none;padding:9px 12px;font-size:13.5px;line-height:1.4;transition:border-color .15s,box-shadow .15s;display:block;overflow-y:hidden}.sqc-composer__input::placeholder{color:var(--sqc-neutral-400)}.sqc-composer__input:focus{border-color:var(--sqc-text);box-shadow:var(--sqc-focus-input)}.sqc-mentions{z-index:2;border:1px solid var(--sqc-border);background:var(--sqc-bg);max-height:184px;box-shadow:var(--sqc-shadow);scrollbar-width:thin;border-radius:12px;margin:0;padding:4px;list-style:none;position:absolute;bottom:calc(100% + 6px);left:0;right:0;overflow-y:auto}.sqc-mention{cursor:pointer;color:var(--sqc-text);border-radius:8px;align-items:baseline;gap:6px;padding:6px 8px;font-size:12.5px;display:flex}.sqc-mention--active{background:var(--sqc-neutral-100)}.sqc-mention__icon{flex-shrink:0}.sqc-mention__handle{font-weight:600}.sqc-mention__name{text-overflow:ellipsis;white-space:nowrap;color:var(--sqc-text-muted);overflow:hidden}.sqc-composer__count{color:var(--sqc-text-muted);pointer-events:none;font-variant-numeric:tabular-nums;font-size:10px;position:absolute;bottom:4px;right:8px}.sqc-btn{cursor:pointer;border:none;border-radius:12px;flex-shrink:0;place-items:center;width:38px;height:38px;transition:background .15s,opacity .15s;display:grid}.sqc-btn svg{width:17px;height:17px}.sqc-btn--send{background:var(--sqc-accent-color);color:var(--sqc-on-accent)}.sqc-btn--send:hover:not(:disabled){background:var(--sqc-accent-hover)}.sqc-btn--send:disabled{background:var(--sqc-disabled);color:#fff;cursor:not-allowed}.sqc-btn--stop{background:var(--sqc-bg);color:var(--sqc-text);border:1px solid var(--sqc-border)}.sqc-btn--stop:hover{border-color:var(--sqc-border-strong);background:var(--sqc-surface)}.sqc-btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-hint{padding:0 16px max(9px, env(safe-area-inset-bottom));color:var(--sqc-text-muted);text-align:center;flex-shrink:0;margin:0;font-size:10.5px;line-height:1.35}.sqc-powered{padding:0 16px max(9px, env(safe-area-inset-bottom));text-align:center;flex-shrink:0;margin:0;font-size:10.5px;line-height:1.35}.sqc-powered a{color:var(--sqc-text-muted);text-decoration:none}.sqc-powered a:hover{text-decoration:underline}@media (max-width:520px){.sqc{--sqc-width:100vw}.sqc-panel{border-left:none}.sqc-launcher{bottom:16px;right:16px}.sqc[data-position=bottom-left] .sqc-launcher{left:16px}.sqc[data-layout=floating] .sqc-panel,.sqc[data-layout=floating][data-position=bottom-left] .sqc-panel{border:none;border-radius:0;max-width:none;height:auto;max-height:none;top:0;bottom:0;left:0;right:0}}@media (prefers-reduced-motion:reduce){.sqc-launcher,.sqc-panel,.sqc-btn,.sqc-suggestion,.sqc-choice,.sqc-confirm__btn,.sqc-icon-btn,.sqc-icon-btn[data-tip]:after,.sqc-rail__item:before,.sqc-rail__item[data-tip]:after,.sqc-rail__item .sqc-avatar{transition:none}.sqc-typing i,.sqc-caret{animation:none}}.sqc-with-human{border:1px solid var(--sqc-border);background:var(--sqc-selected);color:var(--sqc-neutral-600);border-radius:12px;margin:8px 0 0;padding:8px 12px;font-size:13px}`,vr=`squadico-chatbot`,yr=[`embed-key`,`context`,`user`,`agent`,`heading`,`subheading`,`assistant-name`,`placeholder`,`greeting`,`suggestions`,`width`,`accent`,`theme`,`position`,`layout`,`open`,`persist-open`,`show-context`,`locale`],br;function xr(){if(br!==void 0)return br;try{let e=new CSSStyleSheet;e.replaceSync(_r),br=e}catch{br=null}return br}function Sr(e,t){typeof console<`u`&&console.warn(`[${vr}] ${e}`,t??``)}function Cr(e){if(!(!e||!e.trim()))try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t;if(typeof e.id==`string`&&e.id)return{id:e.id,name:typeof e.name==`string`&&e.name?e.name:void 0,digest:typeof e.digest==`string`&&e.digest?e.digest:void 0}}Sr(`the "user" attribute needs an object with an id`,e)}catch(e){Sr(`the "user" attribute is not valid JSON`,e)}}function wr(e){if(!(!e||!e.trim()))try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t;Sr("the `context` attribute must be a JSON object",e)}catch(e){Sr("the `context` attribute is not valid JSON",e)}}function Tr(e){if(!(!e||!e.trim())){if(e.trim().startsWith(`[`))try{let t=JSON.parse(e);if(Array.isArray(t))return t.map(String)}catch(e){Sr("the `suggestions` attribute is not valid JSON",e);return}return e.split(`|`).map(e=>e.trim()).filter(Boolean)}}function Er(e){if(e!==null)return e!==`false`&&e!==`0`}function Dr(e){return e===`dark`||e===`light`||e===`auto`?e:void 0}function Or(e){return e===`bottom-left`||e===`bottom-right`?e:void 0}function kr(e){return e===`floating`||e===`sidebar`?e:void 0}var Ar=[`context`,`embedKey`,`user`,`scope`,`getSubjectToken`,`agent`];function jr(){var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m;return t=new WeakMap,n=new WeakMap,r=new WeakMap,i=new WeakMap,a=new WeakMap,o=new WeakMap,s=new WeakMap,c=new WeakMap,l=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakSet,p=new WeakMap,m=new WeakMap,e=class extends HTMLElement{constructor(){super(),Gt(this,f),X(this,t,void 0),X(this,n,null),X(this,r,!1),X(this,i,!1),X(this,a,``),X(this,o,void 0),X(this,s,void 0),X(this,c,void 0),X(this,l,void 0),X(this,u,void 0),X(this,d,void 0),X(this,p,e=>{let{type:t,...n}=e;$(a,this,n.sessionId),this.dispatchEvent(new CustomEvent(t,{detail:n,bubbles:!0,composed:!0}))}),X(this,m,e=>{$(n,this,e),e&&$(a,this,e.sessionId())});let e=this.attachShadow({mode:`open`}),h=xr();if(h)e.adoptedStyleSheets=[h];else{let t=document.createElement(`style`);t.textContent=_r,e.append(t)}$(t,this,document.createElement(`div`)),e.append(Q(t,this));for(let e of Ar){if(!Object.hasOwn(this,e))continue;let t=this[e];delete this[e],this[e]=t}}connectedCallback(){$(i,this,!0),Z(f,this,g).call(this)}disconnectedCallback(){$(i,this,!1),B(null,Q(t,this)),$(n,this,null)}attributeChangedCallback(e,t,r){if(t!==r){if(e===`open`&&Q(n,this)){Er(r)?Q(n,this).open():Q(n,this).close();return}Z(f,this,h).call(this)}}get context(){return Q(o,this)??wr(this.getAttribute(`context`))}set context(e){$(o,this,e),Z(f,this,h).call(this)}get embedKey(){return Q(d,this)??this.getAttribute(`embed-key`)??void 0}set embedKey(e){$(d,this,e),Z(f,this,h).call(this)}get scope(){return Q(c,this)}set scope(e){$(c,this,e),Z(f,this,h).call(this)}get user(){return Q(s,this)??Cr(this.getAttribute(`user`))}set user(e){$(s,this,e),Z(f,this,h).call(this)}get getSubjectToken(){return Q(l,this)}set getSubjectToken(e){$(l,this,e),Z(f,this,h).call(this)}get agent(){return Q(u,this)??this.getAttribute(`agent`)??void 0}set agent(e){$(u,this,e),Z(f,this,h).call(this)}get open(){return Q(n,this)?.isOpen()??Er(this.getAttribute(`open`))??!1}set open(e){e?this.openChat():this.closeChat()}get sessionId(){return Q(n,this)?.sessionId()??Q(a,this)}openChat(){Q(n,this)?.open()}closeChat(){Q(n,this)?.close()}toggleChat(){Q(n,this)?.toggle()}reset(){Q(n,this)?.reset()}sendMessage(e){if(!Q(n,this)){Sr(`sendMessage() called before the component was mounted — ignored`);return}Q(n,this).send(e)}},Ke(e,`observedAttributes`,yr),e;function h(){Q(r,this)||!Q(i,this)||($(r,this,!0),queueMicrotask(()=>{$(r,this,!1),Q(i,this)&&Z(f,this,g).call(this)}))}function g(){let e=e=>this.getAttribute(e)??void 0;B(Y(gr,{embedKey:this.embedKey,context:this.context,user:this.user,scope:this.scope,getSubjectToken:this.getSubjectToken,agent:this.agent,heading:e(`heading`),subheading:e(`subheading`),assistantName:e(`assistant-name`),placeholder:e(`placeholder`),greeting:e(`greeting`),suggestions:Tr(this.getAttribute(`suggestions`)),width:e(`width`),accent:e(`accent`),theme:Dr(this.getAttribute(`theme`)),position:Or(this.getAttribute(`position`)),layout:kr(this.getAttribute(`layout`)),defaultOpen:Er(this.getAttribute(`open`))??!1,persistOpen:Er(this.getAttribute(`persist-open`))??!0,showContext:Er(this.getAttribute(`show-context`))??!0,locale:e(`locale`),onEvent:Q(p,this),bind:Q(m,this)}),Q(t,this))}}var Mr;function Nr(e=vr){typeof window>`u`||typeof HTMLElement>`u`||(Mr??(Mr=jr()),window.customElements.get(e)||window.customElements.define(e,Mr))}return Nr(),e.API_URL=qe,e.ChatHttpError=J,e.DEFAULT_LANGUAGE=je,e.MAX_MESSAGE_LENGTH=Je,e.SUPPORTED_LANGUAGES=Me,e.TAG_NAME=vr,e.defineChatbot=Nr,e})({});
13
13
  //# sourceMappingURL=chatbot.global.js.map