@squadico/chatbot 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -3
- package/dist/chatbot.global.js +1 -1
- package/dist/chatbot.global.js.map +1 -1
- package/dist/element.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.js +1 -1
- package/dist/{src-BL9j5H3p.js → src-2UbcV1gc.js} +19 -7
- package/dist/{src-BL9j5H3p.js.map → src-2UbcV1gc.js.map} +1 -1
- package/dist/{src-BSDQ6Xfm.cjs → src-DNagSAPN.cjs} +2 -2
- package/dist/{src-BSDQ6Xfm.cjs.map → src-DNagSAPN.cjs.map} +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"src-BL9j5H3p.js","names":["l","u","t","i","r","o","e","f","c","a","s","h","p","v","y","d","w","_","m","k","C","q","D","A","T","j","z","B","u","i","f","n","r"],"sources":["../node_modules/preact/dist/preact.module.js","../node_modules/preact/hooks/dist/hooks.module.js","../src/lib/context.ts","../src/lib/i18n.ts","../src/lib/openState.ts","../src/lib/uid.ts","../src/lib/client.ts","../src/lib/conversation.ts","../src/lib/useChat.ts","../node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js","../src/components/Composer.tsx","../src/lib/confirm.ts","../src/components/Approval.tsx","../src/components/Confirm.tsx","../src/components/Choices.tsx","../src/components/RichText.tsx","../src/components/MessageList.tsx","../src/components/ChatbotWidget.tsx","../src/styles.css?inline","../src/element.tsx","../src/index.ts"],"sourcesContent":["var n,l,u,t,i,r,o,e,f,c,a,s,h,p,v,y,d={},w=[],_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,g=Array.isArray;function m(n,l){for(var u in l)n[u]=l[u];return n}function b(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function k(l,u,t){var i,r,o,e={};for(o in u)\"key\"==o?i=u[o]:\"ref\"==o?r=u[o]:e[o]=u[o];if(arguments.length>2&&(e.children=arguments.length>3?n.call(arguments,2):t),\"function\"==typeof l&&null!=l.defaultProps)for(o in l.defaultProps)void 0===e[o]&&(e[o]=l.defaultProps[o]);return x(l,e,i,r,null)}function x(n,t,i,r,o){var e={type:n,props:t,key:i,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==o?++u:o,__i:-1,__u:0};return null==o&&null!=l.vnode&&l.vnode(e),e}function M(){return{current:null}}function S(n){return n.children}function C(n,l){this.props=n,this.context=l}function $(n,l){if(null==l)return n.__?$(n.__,n.__i+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return\"function\"==typeof n.type?$(n):null}function I(n){if(n.__P&&n.__d){var u=n.__v,t=u.__e,i=[],r=[],o=m({},u);o.__v=u.__v+1,l.vnode&&l.vnode(o),q(n.__P,o,u,n.__n,n.__P.namespaceURI,32&u.__u?[t]:null,i,null==t?$(u):t,!!(32&u.__u),r),o.__v=u.__v,o.__.__k[o.__i]=o,D(i,o,r),u.__e=u.__=null,o.__e!=t&&P(o)}}function P(n){if(null!=(n=n.__)&&null!=n.__c)return n.__e=n.__c.base=null,n.__k.some(function(l){if(null!=l&&null!=l.__e)return n.__e=n.__c.base=l.__e}),P(n)}function A(n){(!n.__d&&(n.__d=!0)&&i.push(n)&&!H.__r++||r!=l.debounceRendering)&&((r=l.debounceRendering)||o)(H)}function H(){try{for(var n,l=1;i.length;)i.length>l&&i.sort(e),n=i.shift(),l=i.length,I(n)}finally{i.length=H.__r=0}}function L(n,l,u,t,i,r,o,e,f,c,a){var s,h,p,v,y,_,g=t&&t.__k||w,m=l.length;for(f=T(u,l,g,f,m),s=0;s<m;s++)null!=(p=u.__k[s])&&(h=-1!=p.__i&&g[p.__i]||d,p.__i=s,_=q(n,p,h,i,r,o,e,f,c,a),v=p.__e,p.ref&&h.ref!=p.ref&&(h.ref&&J(h.ref,null,p),a.push(p.ref,p.__c||v,p)),null==y&&null!=v&&(y=v),4&p.__u?(f=j(p,f,n),h.__e&&(h.__e=null)):\"function\"==typeof p.type&&void 0!==_?f=_:v&&(f=v.nextSibling),p.__u&=-7);return u.__e=y,f}function T(n,l,u,t,i){var r,o,e,f,c,a=u.length,s=a,h=0;for(n.__k=new Array(i),r=0;r<i;r++)null!=(o=l[r])&&\"boolean\"!=typeof o&&\"function\"!=typeof o?(\"string\"==typeof o||\"number\"==typeof o||\"bigint\"==typeof o||o.constructor==String?o=n.__k[r]=x(null,o,null,null,null):g(o)?o=n.__k[r]=x(S,{children:o},null,null,null):void 0===o.constructor&&o.__b>0?o=n.__k[r]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):n.__k[r]=o,f=r+h,o.__=n,o.__b=n.__b+1,e=null,-1!=(c=o.__i=O(o,u,f,s))&&(s--,(e=u[c])&&(e.__u|=2)),null==e||null==e.__v?(-1==c&&(i>a?h--:i<a&&h++),\"function\"!=typeof o.type&&(o.__u|=4)):c!=f&&(c==f-1?h--:c==f+1?h++:(c>f?h--:h++,o.__u|=4))):n.__k[r]=null;if(s)for(r=0;r<a;r++)null!=(e=u[r])&&0==(2&e.__u)&&(e.__e==t&&(t=$(e)),K(e,e));return t}function j(n,l,u){var t,i;if(\"function\"==typeof n.type){for(t=n.__k,i=0;t&&i<t.length;i++)t[i]&&(t[i].__=n,l=j(t[i],l,u));return l}n.__e!=l&&(l&&n.type&&!l.parentNode&&(l=$(n)),l=u.insertBefore(n.__e,l||null));do{l=l&&l.nextSibling}while(null!=l&&8==l.nodeType);return l}function F(n,l){return l=l||[],null==n||\"boolean\"==typeof n||(g(n)?n.some(function(n){F(n,l)}):l.push(n)),l}function O(n,l,u,t){var i,r,o,e=n.key,f=n.type,c=l[u],a=null!=c&&0==(2&c.__u);if(null===c&&null==e||a&&e==c.key&&f==c.type)return u;if(t>(a?1:0))for(i=u-1,r=u+1;i>=0||r<l.length;)if(null!=(c=l[o=i>=0?i--:r++])&&0==(2&c.__u)&&e==c.key&&f==c.type)return o;return-1}function z(n,l,u){\"-\"==l[0]?n.setProperty(l,null==u?\"\":u):n[l]=null==u?\"\":\"number\"!=typeof u||_.test(l)?u:u+\"px\"}function N(n,l,u,t,i){var r,o;n:if(\"style\"==l)if(\"string\"==typeof u)n.style.cssText=u;else{if(\"string\"==typeof t&&(n.style.cssText=t=\"\"),t)for(l in t)u&&l in u||z(n.style,l,\"\");if(u)for(l in u)t&&u[l]==t[l]||z(n.style,l,u[l])}else if(\"o\"==l[0]&&\"n\"==l[1])r=l!=(l=l.replace(s,\"$1\")),o=l.toLowerCase(),l=o in n||\"onFocusOut\"==l||\"onFocusIn\"==l?o.slice(2):l.slice(2),n.l||(n.l={}),n.l[l+r]=u,u?t?u[a]=t[a]:(u[a]=h,n.addEventListener(l,r?v:p,r)):n.removeEventListener(l,r?v:p,r);else{if(\"http://www.w3.org/2000/svg\"==i)l=l.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(\"width\"!=l&&\"height\"!=l&&\"href\"!=l&&\"list\"!=l&&\"form\"!=l&&\"tabIndex\"!=l&&\"download\"!=l&&\"rowSpan\"!=l&&\"colSpan\"!=l&&\"role\"!=l&&\"popover\"!=l&&l in n)try{n[l]=null==u?\"\":u;break n}catch(n){}\"function\"==typeof u||(null==u||!1===u&&\"-\"!=l[4]?n.removeAttribute(l):n.setAttribute(l,\"popover\"==l&&1==u?\"\":u))}}function V(n){return function(u){if(this.l){var t=this.l[u.type+n];if(null==u[c])u[c]=h++;else if(u[c]<t[a])return;return t(l.event?l.event(u):u)}}}function q(n,u,t,i,r,o,e,f,c,a){var s,h,p,v,y,d,_,k,x,M,I,P,A,H,T,j,F=u.type;if(void 0!==u.constructor)return null;128&t.__u&&(c=!!(32&t.__u),o=[f=u.__e=t.__e]),(s=l.__b)&&s(u);n:if(\"function\"==typeof F){h=e.length;try{if(x=u.props,M=F.prototype&&F.prototype.render,I=(s=F.contextType)&&i[s.__c],P=s?I?I.props.value:s.__:i,t.__c?k=(p=u.__c=t.__c).__=p.__E:(M?u.__c=p=new F(x,P):(u.__c=p=new C(x,P),p.constructor=F,p.render=Q),I&&I.sub(p),p.state||(p.state={}),p.__n=i,v=p.__d=!0,p.__h=[],p._sb=[]),M&&null==p.__s&&(p.__s=p.state),M&&null!=F.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=m({},p.__s)),m(p.__s,F.getDerivedStateFromProps(x,p.__s))),y=p.props,d=p.state,p.__v=u,v)M&&null==F.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),M&&null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else{if(M&&null==F.getDerivedStateFromProps&&x!==y&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(x,P),u.__v==t.__v||!p.__e&&null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(x,p.__s,P)){u.__v!=t.__v&&(p.props=x,p.state=p.__s,p.__d=!1),u.__e=t.__e,u.__k=t.__k,u.__k.some(function(n){n&&(n.__=u)}),w.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&e.push(p),f=$(t);break n}null!=p.componentWillUpdate&&p.componentWillUpdate(x,p.__s,P),M&&null!=p.componentDidUpdate&&p.__h.push(function(){p.componentDidUpdate(y,d,_)})}if(p.context=P,p.props=x,p.__P=n,p.__e=!1,A=l.__r,H=0,M)p.state=p.__s,p.__d=!1,A&&A(u),s=p.render(p.props,p.state,p.context),w.push.apply(p.__h,p._sb),p._sb=[];else do{p.__d=!1,A&&A(u),s=p.render(p.props,p.state,p.context),p.state=p.__s}while(p.__d&&++H<25);p.state=p.__s,null!=p.getChildContext&&(i=m(m({},i),p.getChildContext())),M&&!v&&null!=p.getSnapshotBeforeUpdate&&(_=p.getSnapshotBeforeUpdate(y,d)),T=null!=s&&s.type===S&&null==s.key?E(s.props.children):s,f=L(n,g(T)?T:[T],u,t,i,r,o,e,f,c,a),p.base=u.__e,u.__u&=-161,p.__h.length&&e.push(p),k&&(p.__E=p.__=null)}catch(n){if(e.length=h,u.__v=null,c||null!=o){if(n.then){for(u.__u|=c?160:128;f&&8==f.nodeType&&f.nextSibling;)f=f.nextSibling;null!=o&&(o[o.indexOf(f)]=null),u.__e=f}else if(null!=o)for(j=o.length;j--;)b(o[j])}else u.__e=t.__e;null==u.__k&&(u.__k=t.__k||[]),n.then||B(u),l.__e(n,u,t)}}else null==o&&u.__v==t.__v?(u.__k=t.__k,u.__e=t.__e):f=u.__e=G(t.__e,u,t,i,r,o,e,c,a);return(s=l.diffed)&&s(u),128&u.__u?void 0:f}function B(n){n&&(n.__c&&(n.__c.__e=!0),n.__k&&n.__k.some(B))}function D(n,u,t){for(var i=0;i<t.length;i++)J(t[i],t[++i],t[++i]);l.__c&&l.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u)})}catch(n){l.__e(n,u.__v)}})}function E(n){return\"object\"!=typeof n||null==n||n.__b>0?n:g(n)?n.map(E):void 0!==n.constructor?null:m({},n)}function G(u,t,i,r,o,e,f,c,a){var s,h,p,v,y,w,_,m=i.props||d,k=t.props,x=t.type;if(\"svg\"==x?o=\"http://www.w3.org/2000/svg\":\"math\"==x?o=\"http://www.w3.org/1998/Math/MathML\":o||(o=\"http://www.w3.org/1999/xhtml\"),null!=e)for(s=0;s<e.length;s++)if((y=e[s])&&\"setAttribute\"in y==!!x&&(x?y.localName==x:3==y.nodeType)){u=y,e[s]=null;break}if(null==u){if(null==x)return document.createTextNode(k);u=document.createElementNS(o,x,k.is&&k),c&&(l.__m&&l.__m(t,e),c=!1),e=null}if(null==x)m===k||c&&u.data==k||(u.data=k);else{if(e=\"textarea\"==x&&null!=k.defaultValue?null:e&&n.call(u.childNodes),!c&&null!=e)for(m={},s=0;s<u.attributes.length;s++)m[(y=u.attributes[s]).name]=y.value;for(s in m)y=m[s],\"dangerouslySetInnerHTML\"==s?p=y:\"children\"==s||s in k||\"value\"==s&&\"defaultValue\"in k||\"checked\"==s&&\"defaultChecked\"in k||N(u,s,null,y,o);for(s in k)y=k[s],\"children\"==s?v=y:\"dangerouslySetInnerHTML\"==s?h=y:\"value\"==s?w=y:\"checked\"==s?_=y:c&&\"function\"!=typeof y||m[s]===y||N(u,s,y,m[s],o);if(h)c||p&&(h.__html==p.__html||h.__html==u.innerHTML)||(u.innerHTML=h.__html),t.__k=[];else if(p&&(u.innerHTML=\"\"),L(\"template\"==t.type?u.content:u,g(v)?v:[v],t,i,r,\"foreignObject\"==x?\"http://www.w3.org/1999/xhtml\":o,e,f,e?e[0]:i.__k&&$(i,0),c,a),null!=e)for(s=e.length;s--;)b(e[s]);c&&\"textarea\"!=x||(s=\"value\",\"progress\"==x&&null==w?u.removeAttribute(\"value\"):null!=w&&(w!==u[s]||\"progress\"==x&&!w||\"option\"==x&&w!=m[s])&&N(u,s,w,m[s],o),s=\"checked\",null!=_&&_!=u[s]&&N(u,s,_,m[s],o))}return u}function J(n,u,t){try{if(\"function\"==typeof n){var i=\"function\"==typeof n.__u;i&&n.__u(),i&&null==u||(n.__u=n(u))}else n.current=u}catch(n){l.__e(n,t)}}function K(n,u,t){var i,r;if(l.unmount&&l.unmount(n),(i=n.ref)&&(i.current&&i.current!=n.__e||J(i,null,u)),null!=(i=n.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(n){l.__e(n,u)}i.base=i.__P=i.__n=null}if(i=n.__k)for(r=0;r<i.length;r++)i[r]&&K(i[r],u,t||\"function\"!=typeof n.type);t||b(n.__e),n.__c=n.__=n.__e=void 0}function Q(n,l,u){return this.constructor(n,u)}function R(u,t,i){var r,o,e,f;t==document&&(t=document.documentElement),l.__&&l.__(u,t),o=(r=\"function\"==typeof i)?null:i&&i.__k||t.__k,e=[],f=[],q(t,u=(!r&&i||t).__k=k(S,null,[u]),o||d,d,t.namespaceURI,!r&&i?[i]:o?null:t.firstChild?n.call(t.childNodes):null,e,!r&&i?i:o?o.__e:t.firstChild,r,f),D(e,u,f),u.props.children=null}function U(n,l){R(n,l,U)}function W(l,u,t){var i,r,o,e,f=m({},l.props);for(o in l.type&&l.type.defaultProps&&(e=l.type.defaultProps),u)\"key\"==o?i=u[o]:\"ref\"==o?r=u[o]:f[o]=void 0===u[o]&&null!=e?e[o]:u[o];return arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):t),x(l.type,f,i||l.key,r||l.ref,null)}function X(n){function l(n){var u,t;return this.getChildContext||(u=new Set,(t={})[l.__c]=this,this.getChildContext=function(){return t},this.componentWillUnmount=function(){u=null},this.shouldComponentUpdate=function(n){this.props.value!=n.value&&u.forEach(function(n){n.__e=!0,A(n)})},this.sub=function(n){u.add(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u&&u.delete(n),l&&l.call(n)}}),n.children}return l.__c=\"__cC\"+y++,l.__=n,l.Provider=l.__l=(l.Consumer=function(n,l){return n.children(l)}).contextType=l,l}n=w.slice,l={__e:function(n,l,u,t){for(var i,r,o;l=l.__;)if((i=l.__c)&&!i.__)try{if((r=i.constructor)&&null!=r.getDerivedStateFromError&&(i.setState(r.getDerivedStateFromError(n)),o=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(n,t||{}),o=i.__d),o)return i.__E=i}catch(l){n=l}throw n}},u=0,t=function(n){return null!=n&&void 0===n.constructor},C.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=m({},this.state),\"function\"==typeof n&&(n=n(m({},u),this.props)),n&&m(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),A(this))},C.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),A(this))},C.prototype.render=S,i=[],o=\"function\"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,e=function(n,l){return n.__v.__b-l.__v.__b},H.__r=0,f=Math.random().toString(8),c=\"__d\"+f,a=\"__a\"+f,s=/(PointerCapture)$|Capture$/i,h=0,p=V(!1),v=V(!0),y=0;export{C as Component,S as Fragment,W as cloneElement,X as createContext,k as createElement,M as createRef,k as h,U as hydrate,t as isValidElement,l as options,R as render,F as toChildArray};\n//# sourceMappingURL=preact.module.js.map\n","import{options as n}from\"preact\";var t,r,u,i,o=0,f=[],c=n,e=c.__b,a=c.__r,v=c.diffed,l=c.__c,m=c.unmount,p=c.__;function s(n,t){c.__h&&c.__h(r,n,o||t),o=0;var u=r.__H||(r.__H={__:[],__h:[]});return n>=u.__.length&&u.__.push({}),u.__[n]}function d(n){return o=1,y(D,n)}function y(n,u,i){var o=s(t++,2);if(o.t=n,!o.__c&&(o.__=[i?i(u):D(void 0,u),function(n){var t=o.__N?o.__N[0]:o.__[0],r=o.t(t,n);t!==r&&(o.__N=[r,o.__[1]],o.__c.setState({}))}],o.__c=r,!r.__f)){var f=function(n,t,r){if(!o.__c.__H)return!0;var u=!1,i=o.__c.props!==n;if(o.__c.__H.__.some(function(n){if(n.__N){u=!0;var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(i=!0)}}),c){var f=c.call(this,n,t,r);return u?f||i:f}return!u||i};r.__f=!0;var c=r.shouldComponentUpdate,e=r.componentWillUpdate;r.componentWillUpdate=function(n,t,r){if(this.__e){var u=c;c=void 0,f(n,t,r),c=u}e&&e.call(this,n,t,r)},r.shouldComponentUpdate=f}return o.__N||o.__}function h(n,u){var i=s(t++,3);!c.__s&&C(i.__H,u)&&(i.__=n,i.u=u,r.__H.__h.push(i))}function _(n,u){var i=s(t++,4);!c.__s&&C(i.__H,u)&&(i.__=n,i.u=u,r.__h.push(i))}function A(n){return o=5,T(function(){return{current:n}},[])}function F(n,t,r){o=6,_(function(){if(\"function\"==typeof n){var r=n(t());return function(){n(null),r&&\"function\"==typeof r&&r()}}if(n)return n.current=t(),function(){return n.current=null}},null==r?r:r.concat(n))}function T(n,r){var u=s(t++,7);return C(u.__H,r)&&(u.__=n(),u.__H=r,u.__h=n),u.__}function q(n,t){return o=8,T(function(){return n},t)}function x(n){var u=r.context[n.__c],i=s(t++,9);return i.c=n,u?(null==i.__&&(i.__=!0,u.sub(r)),u.props.value):n.__}function P(n,t){c.useDebugValue&&c.useDebugValue(t?t(n):n)}function b(n){var u=s(t++,10),i=d();return u.__=n,r.componentDidCatch||(r.componentDidCatch=function(n,t){u.__&&u.__(n,t),i[1](n)}),[i[0],function(){i[1](void 0)}]}function g(){var n=s(t++,11);if(!n.__){for(var u=r.__v;null!==u&&!u.__m&&null!==u.__;)u=u.__;var i=u.__m||(u.__m=[0,0]);n.__=\"P\"+i[0]+\"-\"+i[1]++}return n.__}function j(){for(var n;n=f.shift();){var t=n.__H;if(n.__P&&t)try{t.__h.some(z),t.__h.some(B),t.__h=[]}catch(r){t.__h=[],c.__e(r,n.__v)}}}c.__b=function(n){r=null,e&&e(n)},c.__=function(n,t){n&&t.__k&&t.__k.__m&&(n.__m=t.__k.__m),p&&p(n,t)},c.__r=function(n){a&&a(n),t=0;var i=(r=n.__c).__H;i&&(u===r?(i.__h=[],r.__h=[],i.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(i.__h.some(z),i.__h.some(B),i.__h=[],t=0)),u=r},c.diffed=function(n){v&&v(n);var t=n.__c;t&&t.__H&&(t.__H.__h.length&&(1!==f.push(t)&&i===c.requestAnimationFrame||((i=c.requestAnimationFrame)||w)(j)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),u=r=null},c.__c=function(n,t){t.some(function(n){try{n.__h.some(z),n.__h=n.__h.filter(function(n){return!n.__||B(n)})}catch(r){t.some(function(n){n.__h&&(n.__h=[])}),t=[],c.__e(r,n.__v)}}),l&&l(n,t)},c.unmount=function(n){m&&m(n);var t,r=n.__c;r&&r.__H&&(r.__H.__.some(function(n){try{z(n)}catch(n){t=n}}),r.__H=void 0,t&&c.__e(t,r.__v))};var k=\"function\"==typeof requestAnimationFrame;function w(n){var t,r=function(){clearTimeout(u),k&&cancelAnimationFrame(t),setTimeout(n)},u=setTimeout(r,35);k&&(t=requestAnimationFrame(r))}function z(n){var t=r,u=n.__c;\"function\"==typeof u&&(n.__c=void 0,u()),r=t}function B(n){var t=r;n.__c=n.__(),r=t}function C(n,t){return!n||n.length!==t.length||t.some(function(t,r){return t!==n[r]})}function D(n,t){return\"function\"==typeof t?t(n):t}export{q as useCallback,x as useContext,P as useDebugValue,h as useEffect,b as useErrorBoundary,g as useId,F as useImperativeHandle,_ as useLayoutEffect,T as useMemo,y as useReducer,A as useRef,d as useState};\n//# sourceMappingURL=hooks.module.js.map\n","/**\n * Page context: reading an `{ id, name }` entry and shaping it for the wire.\n *\n * A host object can be named in two ways. Its id alone, under a flat key\n * (`orderId: 'ORD-1'`), or the named object under the entity key\n * (`order: { id: 'ORD-1', name: 'Order #1042' }`). The second form exists for\n * display: the chip shows \"Order #1042\" instead of a UUID, and the host is the\n * only one knowing that name without calling the API.\n *\n * On the wire the agent only reads strings, so `wireContext` splits every named\n * object into `<key>Id` + `<key>Name` right before sending. Keeping a single\n * shape on the network makes the request identical however the host filled its\n * context in.\n *\n * Nothing here is domain-specific: the widget has no list of known entities, it\n * only recognises the `{ id, name }` shape wherever the host used it.\n */\nimport type { ChatbotContext, ContextObject } from '../types'\n\n/** Keys the widget owns and never treats as a host object. */\nconst RESERVED_KEYS = new Set<string>(['sessionId'])\n\n/**\n * Reads a context entry, named object or bare id.\n *\n * Returns `undefined` when it carries no usable id — empty string, object with\n * no `id`: \"nothing selected\", not \"something named nowhere\".\n */\nexport function contextObject(value: unknown): ContextObject | undefined {\n if (typeof value === 'string') {\n return value.length > 0 ? { id: value } : undefined\n }\n if (!value || typeof value !== 'object' || Array.isArray(value)) return undefined\n const { id, name } = value as { id?: unknown; name?: unknown }\n if (typeof id !== 'string' || id.length === 0) return undefined\n return typeof name === 'string' && name.length > 0 ? { id, name } : { id }\n}\n\n/** What a chip displays: the name when the host gave one, the id otherwise. */\nexport function contextLabel(value: unknown): string | undefined {\n const object = contextObject(value)\n if (!object) return undefined\n return object.name ?? object.id\n}\n\n/** Whether an entry carries a named object (`{ id, name? }`) rather than a\n * plain value — the shape the chips and the wire format are built on. */\nexport function isNamedObject(value: unknown): boolean {\n return Boolean(value) && typeof value === 'object' && !Array.isArray(value)\n}\n\n/**\n * Puts the context in the shape the agent reads: `order: { id, name }` becomes\n * `orderId` + `orderName`.\n *\n * Everything else goes through untouched — `sessionId`, an already flat\n * `orderId`, or any free key of the host: the widget does not filter the\n * context, it only translates what it knows how to translate.\n */\nexport function wireContext(context: ChatbotContext): Record<string, unknown> {\n const wire: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(context)) {\n if (RESERVED_KEYS.has(key) || !isNamedObject(value)) {\n wire[key] = value\n continue\n }\n const object = contextObject(value)\n // An empty named key is not sent: it would claim something is selected.\n if (!object) continue\n wire[`${key}Id`] = object.id\n if (object.name) wire[`${key}Name`] = object.name\n }\n return wire\n}\n","/**\n * Every user-facing string of the widget, one bundle per supported language.\n *\n * The host picks the language with a single `locale` prop (`en`, `en-GB`,\n * `fr`, `es-ES`…): its primary subtag selects the bundle, and the tag itself is\n * kept as-is for `Intl` — a `fr-CA` host gets the French copy with Canadian date\n * formatting, which is what a BCP-47 tag means. Declaring nothing reads the\n * browser's own languages instead (`resolveLocale`). An unsupported language\n * falls back to `DEFAULT_LANGUAGE` rather than showing keys.\n *\n * Adding a string means adding it to **every** bundle — the `Strings` type makes\n * that a compile error, not a runtime blank.\n */\n\nexport type LanguageCode = 'en' | 'fr' | 'es'\n\nexport const DEFAULT_LANGUAGE: LanguageCode = 'en'\n\n/** Shipped languages, in the order they are documented. Published so a host can\n * offer its users only the locales the widget really speaks. */\nexport const SUPPORTED_LANGUAGES: readonly LanguageCode[] = ['en', 'fr', 'es']\n\n/** Labels of the context chips shown under the header. The chip titles\n * themselves come from the host's own context keys — the widget knows no\n * domain entity. */\nexport interface ContextStrings {\n /** Accessible name of the chip row. */\n region: string\n}\n\nexport interface Strings {\n heading: string\n subheading: string\n placeholder: string\n greeting: string\n /** Permanent reminder under the composer: a write is proposed, never applied\n * on its own. */\n hint: string\n /** Byline of an assistant message. */\n assistant: string\n /** Accessible name of the three-dot indicator while the answer is streaming. */\n typing: string\n newConversation: string\n close: string\n /** Shorter form, for the `title` tooltip. */\n closeTitle: string\n history: {\n /** The header icon opening the menu. */\n open: string\n /** Accessible name of the menu itself. */\n menu: string\n loading: string\n empty: string\n /** Stands in until the agent has generated a title for the session. */\n untitled: string\n }\n context: ContextStrings\n approval: {\n group: string\n approve: string\n reject: string\n /** Said in the agent's place when it asked for a tool without a word about\n * it: `{tool}` is the name of what it would use. */\n request: string\n /** Heading of the values the tool would be called with. */\n arguments: string\n edit: string\n /** Placeholder of the correction field. */\n correction: string\n correctionLabel: string\n send: string\n }\n confirm: {\n group: string\n yes: string\n no: string\n /** What clicking sends to the agent — a bare \"yes\" is recognised without a\n * model call, so it has to be the word of the user's own language. */\n yesValue: string\n noValue: string\n }\n /** Accessible name of a Markdown checkbox group turned into buttons. */\n choices: string\n /** The footer link a plan that carries our name shows. */\n poweredBy: string\n /** The agents a visitor may address by name, where an application holds several. */\n handles: {\n /** Accessible name of the list `@` opens in the composer. */\n picker: string\n /** Said above the name a message addressed and nobody answers to. The handle\n * itself is rendered beside it, so no sentence needs a placeholder. */\n unknown: string\n /** Introduces the handles that do answer, when the organization offers any. */\n instead: string\n }\n /** A question the agent stopped its turn on, answered by ticking options. */\n selection: {\n /** Accessible name of the option group. */\n group: string\n /** Shown under a single-answer question: one click answers it. */\n single: string\n /** Shown under a multi-answer one: several ticks, one validate. */\n multiple: string\n /** The button that sends what has been ticked. */\n validate: string\n }\n composer: {\n label: string\n send: string\n sendTitle: string\n stop: string\n stopTitle: string\n /** Accessible name of the paperclip, and of the cross on each chip. */\n attach: string\n attachTitle: string\n /** Takes the file's name: \"Remove {name}\". */\n remove: string\n }\n /** What a refused upload means, in the terms of whoever chose the file. */\n attachments: {\n unsupported: string\n tooLarge: string\n tooMany: string\n unreadable: string\n failed: string\n }\n /** Shown in the bubble when a turn failed — the real cause goes to\n * `chatbot-error` and the console, not to the user. */\n error: string\n /** Under the transcript once an agent handed the conversation to a human. */\n withHuman: string\n}\n\nconst EN: Strings = {\n heading: 'Assistant',\n subheading: 'Squadico',\n placeholder: 'Ask your question…',\n greeting: 'Hello! I am your assistant. What would you like to do?',\n hint: 'The assistant proposes an action; nothing is applied without your confirmation.',\n assistant: 'Assistant',\n typing: 'The assistant is writing its answer',\n newConversation: 'New conversation',\n close: 'Close the assistant',\n closeTitle: 'Close',\n history: {\n open: 'Conversation history',\n menu: 'Previous conversations',\n loading: 'Loading…',\n empty: 'No previous conversation.',\n untitled: 'Conversation',\n },\n context: {\n region: 'Context sent to the assistant',\n },\n approval: {\n group: 'Write confirmation',\n approve: 'Yes, apply',\n reject: 'No, cancel',\n request: 'The agent wants to use {tool}.',\n arguments: 'With',\n edit: 'Change…',\n correction: 'What to change — e.g. “the due date is next Monday”',\n correctionLabel: 'Correction to make before approving',\n send: 'Send',\n },\n confirm: {\n group: 'Confirmation',\n yes: 'Yes',\n no: 'No',\n yesValue: 'yes',\n noValue: 'no',\n },\n choices: 'Suggested options',\n poweredBy: 'Powered by Squadico',\n handles: {\n picker: 'Agents you can address',\n unknown: 'Nobody answers to that name here:',\n instead: 'You can address:',\n },\n selection: {\n group: 'Suggested choice',\n single: 'Pick one option.',\n multiple: 'Pick one or more options, then validate.',\n validate: 'Validate',\n },\n composer: {\n label: 'Your message',\n send: 'Send the message',\n sendTitle: 'Send',\n stop: 'Stop the answer',\n stopTitle: 'Stop',\n attach: 'Attach a file',\n attachTitle: 'Attach',\n remove: 'Remove {name}',\n },\n attachments: {\n unsupported: 'This kind of file cannot be attached to a message.',\n tooLarge: 'This file is too large.',\n tooMany: 'This message already carries as many files as it may.',\n unreadable: 'This file could not be read.',\n failed: 'This file could not be attached.',\n },\n error: 'Something went wrong, the assistant could not answer. Try again in a moment.',\n withHuman: 'A member of the team will reply to you here.',\n}\n\nconst FR: Strings = {\n heading: 'Assistant',\n subheading: 'Squadico',\n placeholder: 'Posez votre question…',\n greeting: 'Bonjour ! Je suis votre assistant. Que souhaitez-vous faire ?',\n hint: \"L'assistant propose une action ; rien n'est appliqué sans votre confirmation.\",\n assistant: 'Assistant',\n typing: \"L'assistant rédige sa réponse\",\n newConversation: 'Nouvelle conversation',\n close: \"Fermer l'assistant\",\n closeTitle: 'Fermer',\n history: {\n open: 'Historique des conversations',\n menu: 'Conversations précédentes',\n loading: 'Chargement…',\n empty: 'Aucune conversation précédente.',\n untitled: 'Conversation',\n },\n context: {\n region: \"Contexte transmis à l'assistant\",\n },\n approval: {\n group: \"Validation de l'écriture\",\n approve: 'Oui, appliquer',\n reject: 'Non, annuler',\n request: \"L'agent souhaite utiliser {tool}.\",\n arguments: 'Avec',\n edit: 'Modifier…',\n correction: \"Ce qu'il faut changer — ex. « l'échéance est lundi prochain »\",\n correctionLabel: 'Correction à apporter avant validation',\n send: 'Envoyer',\n },\n confirm: {\n group: 'Confirmation',\n yes: 'Oui',\n no: 'Non',\n yesValue: 'oui',\n noValue: 'non',\n },\n choices: 'Options proposées',\n poweredBy: 'Propulsé par Squadico',\n handles: {\n picker: 'Agents que vous pouvez adresser',\n unknown: 'Personne ne répond à ce nom ici :',\n instead: 'Vous pouvez adresser :',\n },\n selection: {\n group: 'Choix proposé',\n single: 'Sélectionnez une option.',\n multiple: 'Sélectionnez une ou plusieurs options, puis validez.',\n validate: 'Valider',\n },\n composer: {\n label: 'Votre message',\n send: 'Envoyer le message',\n sendTitle: 'Envoyer',\n stop: 'Interrompre la réponse',\n stopTitle: 'Interrompre',\n attach: 'Joindre un fichier',\n attachTitle: 'Joindre',\n remove: 'Retirer {name}',\n },\n attachments: {\n unsupported: 'Ce format de fichier ne peut pas être joint à un message.',\n tooLarge: 'Ce fichier est trop volumineux.',\n tooMany: \"Ce message porte déjà autant de fichiers qu'il le peut.\",\n unreadable: \"Ce fichier n'a pas pu être lu.\",\n failed: 'Impossible de joindre ce fichier.',\n },\n error: \"Une erreur est survenue, l'assistant n'a pas pu répondre. Réessayez dans un instant.\",\n withHuman: \"Un membre de l'équipe va vous répondre ici.\",\n}\n\nconst ES: Strings = {\n heading: 'Asistente',\n subheading: 'Squadico',\n placeholder: 'Haga su pregunta…',\n greeting: '¡Hola! Soy su asistente. ¿Qué desea hacer?',\n hint: 'El asistente propone una acción; no se aplica nada sin su confirmación.',\n assistant: 'Asistente',\n typing: 'El asistente está redactando su respuesta',\n newConversation: 'Nueva conversación',\n close: 'Cerrar el asistente',\n closeTitle: 'Cerrar',\n history: {\n open: 'Historial de conversaciones',\n menu: 'Conversaciones anteriores',\n loading: 'Cargando…',\n empty: 'Ninguna conversación anterior.',\n untitled: 'Conversación',\n },\n context: {\n region: 'Contexto enviado al asistente',\n },\n approval: {\n group: 'Validación de la escritura',\n approve: 'Sí, aplicar',\n reject: 'No, cancelar',\n request: 'El agente quiere usar {tool}.',\n arguments: 'Con',\n edit: 'Modificar…',\n correction: 'Lo que hay que cambiar — p. ej. «el vencimiento es el lunes»',\n correctionLabel: 'Corrección antes de validar',\n send: 'Enviar',\n },\n confirm: {\n group: 'Confirmación',\n yes: 'Sí',\n no: 'No',\n yesValue: 'sí',\n noValue: 'no',\n },\n choices: 'Opciones propuestas',\n poweredBy: 'Con la tecnología de Squadico',\n handles: {\n picker: 'Agentes a los que puedes dirigirte',\n unknown: 'Nadie responde a ese nombre aquí:',\n instead: 'Puedes dirigirte a:',\n },\n selection: {\n group: 'Opción propuesta',\n single: 'Seleccione una opción.',\n multiple: 'Seleccione una o varias opciones y valide.',\n validate: 'Validar',\n },\n composer: {\n label: 'Su mensaje',\n send: 'Enviar el mensaje',\n sendTitle: 'Enviar',\n stop: 'Interrumpir la respuesta',\n stopTitle: 'Interrumpir',\n attach: 'Adjuntar un archivo',\n attachTitle: 'Adjuntar',\n remove: 'Quitar {name}',\n },\n attachments: {\n unsupported: 'Este tipo de archivo no se puede adjuntar a un mensaje.',\n tooLarge: 'Este archivo es demasiado grande.',\n tooMany: 'Este mensaje ya lleva todos los archivos que puede llevar.',\n unreadable: 'No se ha podido leer este archivo.',\n failed: 'No se ha podido adjuntar este archivo.',\n },\n error: 'Se ha producido un error, el asistente no ha podido responder. Inténtelo de nuevo.',\n withHuman: 'Un miembro del equipo le responderá aquí.',\n}\n\nconst BUNDLES: Record<LanguageCode, Strings> = { en: EN, fr: FR, es: ES }\n\n/** Default `Intl` tag per language, used when the host named a language only. */\nconst TAGS: Record<LanguageCode, string> = { en: 'en-GB', fr: 'fr-FR', es: 'es-ES' }\n\n/** A resolved locale: the copy to render, and the tag to format dates with. */\nexport interface Locale {\n code: LanguageCode\n /** BCP-47 tag handed to `Intl` — the host's own when it gave one. */\n tag: string\n t: Strings\n}\n\n/** The bundle a tag names, or `undefined` when the language is not shipped. */\nfunction supported(locale: string | undefined): LanguageCode | undefined {\n const primary = locale?.trim().toLowerCase().split(/[-_]/)[0]\n return primary && primary in BUNDLES ? (primary as LanguageCode) : undefined\n}\n\nexport function resolveLanguage(locale: string | undefined): LanguageCode {\n return supported(locale) ?? DEFAULT_LANGUAGE\n}\n\n/**\n * Languages the browser announces, most preferred first.\n *\n * `navigator.languages` is the ordered list of the user's own preferences —\n * `navigator.language` alone is only its first entry, so a user whose Chrome is\n * in English but who also reads Spanish would never reach the Spanish bundle\n * through it. Absent server-side (SSR of a host importing the package), where\n * there is no user to have preferences.\n */\nfunction browserLocales(): readonly string[] {\n if (typeof navigator === 'undefined') return []\n return navigator.languages?.length ? navigator.languages : [navigator.language]\n}\n\n/**\n * Locale to render with.\n *\n * `locale` is what the host declared (attribute or prop) and it is a decision:\n * a regioned tag of a supported language keeps its region for `Intl` (`fr-CA`),\n * a bare language takes the bundle's own tag, and an unsupported one falls back\n * to `DEFAULT_LANGUAGE` — copy *and* tag, since English copy dated in Portuguese\n * would read as a bug rather than as a fallback. The browser is not consulted\n * then: a host naming a language has its reasons (the user's own account\n * setting, most likely), and the browser would silently overrule them.\n *\n * Declaring nothing is the case this exists for: the user's browser languages\n * are read in their own order, and the first one the widget speaks wins — a\n * Spanish-speaking user gets a Spanish panel without their front having to know\n * the widget ships Spanish at all. None supported, or no browser to ask:\n * `DEFAULT_LANGUAGE`.\n */\nexport function resolveLocale(locale: string | undefined): Locale {\n const declared = locale?.trim()\n const candidates = declared ? [declared] : browserLocales()\n const tag = candidates.find(supported)\n const code = supported(tag) ?? DEFAULT_LANGUAGE\n return { code, tag: tag?.includes('-') ? tag : TAGS[code], t: BUNDLES[code] }\n}\n","/**\n * Remembers whether the user left the panel open or closed, so a reload or a\n * navigation to another page of the host app does not silently undo their last\n * gesture — closing an assistant that reopens itself on the next screen, or\n * losing an open conversation to a route change.\n *\n * `sessionStorage`, not the `localStorage` `useChat` uses for the \"new\n * conversation\" gesture: this is transient UI state belonging to one tab.\n * Reopening the app tomorrow, or in a second tab, starts from the host's own\n * default rather than from a gesture made in another browsing session; the\n * conversation is still there, one click away.\n */\n\n/** One panel state per host origin — enough as long as a page mounts a single\n * widget, which is the case for every current integrator. */\nconst OPEN_STORAGE_KEY = 'squadico-chatbot:open'\n\n/** `undefined` when nothing was ever stored, or storage is unusable — which is\n * distinct from a stored `false` (the user closed the panel) and is what lets\n * a host's `defaultOpen` still apply on a first visit. */\nfunction readOpenState(): boolean | undefined {\n try {\n if (typeof sessionStorage === 'undefined') return undefined\n const raw = sessionStorage.getItem(OPEN_STORAGE_KEY)\n if (raw === '1') return true\n if (raw === '0') return false\n return undefined\n } catch {\n // Storage unavailable (private browsing, blocked cookies…): the panel state\n // stays volatile, as it was before this persistence existed.\n return undefined\n }\n}\n\nexport function writeOpenState(open: boolean): void {\n try {\n if (typeof sessionStorage === 'undefined') return\n sessionStorage.setItem(OPEN_STORAGE_KEY, open ? '1' : '0')\n } catch {\n /* see readOpenState */\n }\n}\n\n/**\n * Resolves the state the panel mounts in.\n *\n * A remembered gesture wins over `defaultOpen`, which is a *default*: the host\n * declares where a first-time visitor starts, the user decides afterwards.\n * A host that needs the panel open on every load calls `openChat()` instead.\n *\n * Shared by both wrappers: `src/react.tsx` applies `defaultOpen` imperatively\n * after mount, so it has to arbitrate the same way or it would reopen a panel\n * the user had closed.\n */\nexport function initialOpen(defaultOpen?: boolean, persist?: boolean): boolean {\n if (persist === false) return defaultOpen ?? false\n return readOpenState() ?? defaultOpen ?? false\n}\n","/**\n * UUID v4. `crypto.randomUUID` only exists in a secure context (https or\n * localhost): the two fallbacks cover an integration served over http:// on a\n * LAN IP, a common staging setup. The API validates `sessionId` as a UUID, so\n * the format has to stay strictly conformant.\n */\nexport function uuid(): string {\n const c = globalThis.crypto as Crypto | undefined\n\n if (c && typeof c.randomUUID === 'function') {\n return c.randomUUID()\n }\n\n const bytes = new Uint8Array(16)\n if (c && typeof c.getRandomValues === 'function') {\n c.getRandomValues(bytes)\n } else {\n for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256)\n }\n // Force version 4 and the RFC 4122 variant.\n bytes[6] = (bytes[6] & 0x0f) | 0x40\n bytes[8] = (bytes[8] & 0x3f) | 0x80\n\n const hex: string[] = []\n for (let i = 0; i < 16; i++) hex.push(bytes[i].toString(16).padStart(2, '0'))\n return (\n hex.slice(0, 4).join('') +\n '-' +\n hex.slice(4, 6).join('') +\n '-' +\n hex.slice(6, 8).join('') +\n '-' +\n hex.slice(8, 10).join('') +\n '-' +\n hex.slice(10, 16).join('')\n )\n}\n","/**\n * HTTP client of the Squadico public API.\n *\n * Four calls, and they are the routes the backend actually serves:\n * - `openConversation` → `POST /public/applications/{embedKey}/conversations`\n * - `replayConversation` → `GET /public/conversations/{id}`\n * - `sendMessage` → `POST /public/conversations/{id}/messages` (SSE)\n * - `resolveApproval` → `POST /public/conversations/{id}/approvals` (SSE)\n *\n * **The widget authenticates nobody.** It is the public surface: the embed key says\n * which application, and the visitor token handed back at open is the whole of the\n * authorization afterwards. The token travels in a header and never in a cookie —\n * third-party cookies are blocked or on their way out, and a header cannot be sent\n * ambiently, which removes CSRF as a class.\n *\n * **The server names the conversation.** Its id comes back from the open call: a\n * visitor allowed to name their own conversation is a visitor choosing which one to\n * read.\n *\n * **The author claim travels once, at open.** A panel has one person in front of it,\n * so one claim per conversation is auditable while one per message would be an\n * annotation anybody could change halfway through. It is attribution and never\n * authorization: what a visitor may read is decided by their token.\n *\n * **Everything is streamed the same way.** Four frame types — `token`, `done`,\n * `error`, `approval_required` — for a fresh question and for a resumed approval\n * alike, plus three a team adds: `handoff` (another agent of the team answers\n * from here, and signs the `done` that follows), `escalated` (the agent handed the\n * conversation to a human) and `held` (a human handles it: the message was kept\n * for them and nothing answers). `done` carries the stored turn (the one a reload would show), on a surface\n * that can hold several agents which one answered, and — when the message addressed\n * a name nobody answers to — that name with the ones that do. That last one is a\n * hint beside an answer and never a refusal: the default agent replied, because a\n * visitor typing `@sale` should get help rather than a 404.\n *\n * **A handle is never routed from here.** The message text is what the server\n * parses, so the picker and the `agent` option both work by putting a handle in\n * front of what somebody types. A client naming its own agent would be a client\n * choosing its own router.\n *\n * No dependency: `fetch` + `ReadableStream`, available everywhere the widget runs.\n */\nimport type {\n AgentHandle,\n ChatAttachment,\n ChatMessage,\n ChatRole,\n PendingApproval,\n} from '../types'\nimport { uuid } from './uid'\n\n/** The Squadico API, written in at build time (`config/api-url.ts`). Not an\n * option: a page embedding the widget does not choose the server it talks to. */\nexport const API_URL: string = __SQUADICO_API_URL__\n\n/** Aligned on `MESSAGE_MAX_LENGTH` in the API's own schema: a message longer than\n * this is a 422 from the form rather than a 400 from a vendor at the first token. */\nexport const MAX_MESSAGE_LENGTH = 20_000\n\nexport class ChatHttpError extends Error {\n readonly status?: number\n /** The API's machine-readable name for the refusal, when it sent one.\n *\n * What a panel branches on: `origin_not_allowed` means stop embedding,\n * `application_has_no_agent` means nothing answers there yet, and\n * `conversation_retired` means open a new conversation. Three reactions a bare\n * status cannot tell apart. */\n readonly code?: string\n\n constructor(message: string, status?: number, code?: string) {\n super(message)\n this.name = 'ChatHttpError'\n this.status = status\n this.code = code\n }\n}\n\nexport interface HostUser {\n id: string\n name?: string\n /** The HMAC the host's *server* computed over `id`, where the application asks\n * for one. Never computed in the page: a digest a browser can produce is a\n * digest anybody can produce, and the secret would be in the page's source. */\n digest?: string\n}\n\nexport interface OpenConversationInit {\n apiUrl: string\n embedKey: string\n /** Who the embedding application has signed in, when it has anybody. */\n user?: HostUser\n /** The handle the page wants to open on. Unknown here opens on the default rather\n * than refusing: a page carrying a renamed handle must keep working. */\n agent?: string\n signal?: AbortSignal\n}\n\n/** What opening a panel answers with. */\nexport interface OpenedConversation {\n conversationId: string\n visitorToken: string\n /** The agent that answers a message addressing nobody. */\n agentName: string\n agentSlug: string\n welcomeMessage?: string\n /** The transcript as it stands — the welcome message, on a fresh conversation. */\n messages: ChatMessage[]\n /** The handles this application offers, which is empty until somebody ticks one. */\n handles: AgentHandle[]\n /** The handle the conversation really opened on — which may not be the one that\n * was asked for, if the server fell back to the default. */\n agentHandle?: string\n /** A human of the organization handles it: no agent answers, and the panel\n * reads the conversation again to show their replies. */\n withHuman?: boolean\n /** Whether the panel shows \"Powered by Squadico\" — the organization's plan says. */\n branding: boolean\n}\n\nexport interface ReplayConversationInit {\n apiUrl: string\n conversationId: string\n visitorToken: string\n signal?: AbortSignal\n}\n\nexport interface SendMessageInit {\n apiUrl: string\n conversationId: string\n visitorToken: string\n message: string\n /** The files this question carries, named rather than implied: anything else\n * the conversation is still holding stays where it is. */\n attachmentIds?: string[]\n /** What the page knows about where the visitor is. Sent as data, never as\n * instructions — see `ChatbotContext`. */\n context?: Record<string, unknown>\n /** The access token the host site holds for its signed-in user — see\n * `getSubjectToken` on the props. */\n subjectToken?: string\n onToken: (token: string) => void\n signal?: AbortSignal\n}\n\nexport interface ResolveApprovalInit {\n apiUrl: string\n conversationId: string\n visitorToken: string\n /** The call the panel is answering for. Checked against what the conversation is\n * actually waiting on, so a stale decision is refused rather than resuming the\n * wrong thing. */\n toolCallId: string\n approved: boolean\n subjectToken?: string\n onToken: (token: string) => void\n signal?: AbortSignal\n}\n\n/** What a turn produced: the stored answer, who wrote it, and what it stopped on. */\nexport interface ChatTurn {\n answer: string\n /** Which agent answered, on a surface that can hold several. */\n agent?: AgentHandle\n /** Set when the turn paused: one tool call is waiting on a decision, and nothing\n * has been written until one is sent. */\n approval?: PendingApproval\n /** The name the message addressed and nobody on this application answers to. The\n * answer came from the default agent all the same. */\n unknownHandle?: string\n /** The handles that *do* answer, to say instead of the mistyped one. Empty when\n * the organization has ticked none — the panel then says only that nobody\n * answers to that name. */\n offered?: AgentHandle[]\n /** The agent the conversation was passed to during this turn, when it has no\n * handle on the application to be announced by — what signs its answer. */\n authorName?: string\n /** The agent handed the conversation to a human of the organization, or one\n * already handles it: no agent answers what comes next. */\n withHuman?: boolean\n /** The message was kept for the human handling the conversation; no agent ran,\n * so there is no answer to draw. */\n held?: boolean\n}\n\ninterface ApiMessage {\n id?: unknown\n role?: unknown\n content?: unknown\n agent?: unknown\n attachments?: unknown\n created_at?: unknown\n kind?: unknown\n author_name?: unknown\n}\n\ninterface ApiAttachment {\n id?: unknown\n kind?: unknown\n filename?: unknown\n content_type?: unknown\n}\n\nfunction endpoint(apiUrl: string, path: string): string {\n return `${apiUrl.replace(/\\/+$/, '')}${path}`\n}\n\nfunction headers(visitorToken?: string, subjectToken?: string): HeadersInit {\n return {\n 'Content-Type': 'application/json',\n Accept: 'text/event-stream, application/json',\n ...(visitorToken ? { 'X-Visitor-Token': visitorToken } : {}),\n ...(subjectToken ? { 'X-Subject-Token': subjectToken } : {}),\n }\n}\n\n/**\n * One validation problem, as FastAPI writes it: where it is, and what is wrong.\n *\n * `loc` is the path to the field, `body` first — the last segment is the name an\n * integrator recognises.\n */\nfunction readProblem(entry: unknown): string | undefined {\n if (!entry || typeof entry !== 'object') return undefined\n const { loc, msg } = entry as { loc?: unknown; msg?: unknown }\n if (typeof msg !== 'string' || !msg) return undefined\n const path = Array.isArray(loc) ? loc.filter((part) => typeof part === 'string') : []\n const field = path.at(-1)\n return field && field !== 'body' ? `${field}: ${msg}` : msg\n}\n\n/**\n * The API answers its refusals as `{ detail, code }`; a proxy in front of it may\n * answer `{ message }`. Both are read, because a bare HTTP status is what makes an\n * integration undiagnosable — and the `code` is what a panel reacts to.\n *\n * A validation refusal answers a *list* of problems, one per field. Joined as\n * objects it reads \"[object Object]\" in a console, which is the difference between\n * a five-minute fix and an afternoon — so each one is rendered as the field it is\n * about and what it says.\n */\nasync function readError(response: Response): Promise<ChatHttpError> {\n let detail = ''\n let code: string | undefined\n try {\n const text = await response.text()\n if (text) {\n try {\n const parsed = JSON.parse(text) as {\n detail?: unknown\n code?: unknown\n message?: unknown\n }\n const raw = parsed.detail ?? parsed.message\n if (Array.isArray(raw)) {\n const problems = raw\n .map((entry) => readProblem(entry) ?? (typeof entry === 'string' ? entry : undefined))\n .filter((problem): problem is string => problem !== undefined)\n detail = problems.length > 0 ? problems.join(', ') : text\n } else {\n detail = typeof raw === 'string' ? raw : text\n }\n code = typeof parsed.code === 'string' ? parsed.code : undefined\n } catch {\n detail = text\n }\n }\n } catch {\n /* unreadable body — fall back to the status alone */\n }\n return new ChatHttpError(detail || `The API answered ${response.status}`, response.status, code)\n}\n\n/** Normalises the agent of a `done` frame. Absent on a surface with one agent. */\nfunction toHandle(raw: unknown): AgentHandle | undefined {\n if (!raw || typeof raw !== 'object') return undefined\n const source = raw as {\n handle?: unknown\n name?: unknown\n avatar_emoji?: unknown\n color?: unknown\n }\n if (typeof source.handle !== 'string' || !source.handle) return undefined\n return {\n handle: source.handle,\n name: typeof source.name === 'string' ? source.name : source.handle,\n avatarEmoji: typeof source.avatar_emoji === 'string' ? source.avatar_emoji : undefined,\n color: typeof source.color === 'string' ? source.color : undefined,\n }\n}\n\n/** Normalises a list of handles — the open response's, or a `done` frame's hint. */\nfunction toHandles(raw: unknown): AgentHandle[] {\n return (Array.isArray(raw) ? raw : [])\n .map(toHandle)\n .filter((handle): handle is AgentHandle => handle !== undefined)\n}\n\n/** Normalises the pause of an `approval_required` frame. */\nfunction toApproval(raw: unknown): PendingApproval | undefined {\n if (!raw || typeof raw !== 'object') return undefined\n const source = raw as { tool_call_id?: unknown; tool?: unknown; arguments?: unknown }\n // With no call id no decision can be sent back for it, which makes the buttons a\n // dead end: better to render nothing than a control that cannot answer.\n if (typeof source.tool_call_id !== 'string' || !source.tool_call_id) return undefined\n return {\n toolCallId: source.tool_call_id,\n tool: typeof source.tool === 'string' ? source.tool : '',\n arguments:\n source.arguments && typeof source.arguments === 'object'\n ? (source.arguments as Record<string, unknown>)\n : {},\n }\n}\n\nconst TRANSCRIPT_ROLES = new Set<string>(['user', 'assistant'])\n\n/** One stored turn, as a panel renders it. */\nfunction toMessage(raw: ApiMessage): ChatMessage | null {\n if (typeof raw.role !== 'string' || !TRANSCRIPT_ROLES.has(raw.role)) return null\n if (typeof raw.content !== 'string' || !raw.content) return null\n const at = typeof raw.created_at === 'string' ? Date.parse(raw.created_at) : Number.NaN\n return {\n id: typeof raw.id === 'string' && raw.id ? raw.id : uuid(),\n role: raw.role as ChatRole,\n content: raw.content,\n createdAt: Number.isNaN(at) ? Date.now() : at,\n agent: toHandle(raw.agent),\n attachments: toAttachments(raw.attachments),\n // A member of the organization answering instead of an agent, by name.\n authorName:\n raw.kind === 'human' && typeof raw.author_name === 'string' && raw.author_name\n ? raw.author_name\n : undefined,\n }\n}\n\n/**\n * The files of one turn, as the API listed them.\n *\n * Read defensively like everything else off the wire, and dropped rather than\n * guessed at: a file this panel cannot name is a file it cannot draw either, and\n * an entry with half a shape would be a chip with no label.\n */\nfunction toAttachments(raw: unknown): ChatAttachment[] | undefined {\n if (!Array.isArray(raw)) return undefined\n const files = raw\n .map((entry) => toAttachment(entry))\n .filter((file): file is ChatAttachment => file !== null)\n return files.length > 0 ? files : undefined\n}\n\nfunction toAttachment(raw: unknown): ChatAttachment | null {\n if (!raw || typeof raw !== 'object') return null\n const { id, kind, filename, content_type: contentType } = raw as ApiAttachment\n if (typeof id !== 'string' || !id) return null\n if (typeof filename !== 'string' || !filename) return null\n return {\n id,\n // Anything the panel does not know how to show is shown as a document,\n // which is a named chip — never as a picture it would fail to draw.\n kind: kind === 'image' ? 'image' : 'document',\n filename,\n contentType: typeof contentType === 'string' ? contentType : 'application/octet-stream',\n }\n}\n\n/**\n * Opens a conversation for a page carrying this application's embed key.\n *\n * The body carries the host's author claim and nothing else. No bearer token: the\n * widget is the public surface, and the key plus the visitor token it gets back are\n * the whole credential story.\n */\nexport async function openConversation(init: OpenConversationInit): Promise<OpenedConversation> {\n const response = await fetch(\n endpoint(init.apiUrl, `/public/applications/${encodeURIComponent(init.embedKey)}/conversations`),\n {\n method: 'POST',\n headers: headers(),\n body: JSON.stringify({\n ...(init.user ? { user: init.user } : {}),\n // Omitted rather than sent empty: the API tells an absent field from a\n // cleared one, and an application always has an agent answering plain text.\n ...(init.agent ? { agent: init.agent } : {}),\n }),\n signal: init.signal,\n },\n )\n if (!response.ok) throw await readError(response)\n\n const data = (await response.json()) as {\n id?: unknown\n visitor_token?: unknown\n agent_name?: unknown\n agent_slug?: unknown\n welcome_message?: unknown\n messages?: unknown\n handles?: unknown\n agent_handle?: unknown\n handling?: unknown\n branding?: unknown\n }\n if (typeof data.id !== 'string' || typeof data.visitor_token !== 'string') {\n throw new ChatHttpError('The API opened a conversation without an id or a token')\n }\n const messages = (Array.isArray(data.messages) ? (data.messages as ApiMessage[]) : [])\n .map(toMessage)\n .filter((message): message is ChatMessage => message !== null)\n return {\n conversationId: data.id,\n visitorToken: data.visitor_token,\n agentName: typeof data.agent_name === 'string' ? data.agent_name : '',\n agentSlug: typeof data.agent_slug === 'string' ? data.agent_slug : '',\n welcomeMessage:\n typeof data.welcome_message === 'string' && data.welcome_message\n ? data.welcome_message\n : undefined,\n messages,\n handles: toHandles(data.handles),\n agentHandle:\n typeof data.agent_handle === 'string' && data.agent_handle ? data.agent_handle : undefined,\n withHuman: typeof data.handling === 'string' && data.handling !== 'agents',\n branding: data.branding === true,\n }\n}\n\n/**\n * Reads a conversation back, on the token it was opened with.\n *\n * What makes a reloaded page keep its conversation instead of opening a second one.\n * The answer is the open response minus the credential — the transcript, the handles\n * the composer offers, and the handle the conversation is on — because the token is\n * handed over once and the caller already holds it.\n */\nexport async function replayConversation(init: ReplayConversationInit): Promise<OpenedConversation> {\n const response = await fetch(\n endpoint(init.apiUrl, `/public/conversations/${encodeURIComponent(init.conversationId)}`),\n { method: 'GET', headers: headers(init.visitorToken), signal: init.signal },\n )\n if (!response.ok) throw await readError(response)\n\n const data = (await response.json()) as {\n id?: unknown\n agent_name?: unknown\n agent_slug?: unknown\n welcome_message?: unknown\n messages?: unknown\n handles?: unknown\n agent_handle?: unknown\n handling?: unknown\n branding?: unknown\n }\n if (typeof data.id !== 'string') {\n throw new ChatHttpError('The API replayed a conversation without an id')\n }\n return {\n conversationId: data.id,\n // The one field a replay cannot answer with, and must not: the caller presented\n // it to get here.\n visitorToken: init.visitorToken,\n agentName: typeof data.agent_name === 'string' ? data.agent_name : '',\n agentSlug: typeof data.agent_slug === 'string' ? data.agent_slug : '',\n welcomeMessage:\n typeof data.welcome_message === 'string' && data.welcome_message\n ? data.welcome_message\n : undefined,\n messages: (Array.isArray(data.messages) ? (data.messages as ApiMessage[]) : [])\n .map(toMessage)\n .filter((message): message is ChatMessage => message !== null),\n handles: toHandles(data.handles),\n agentHandle:\n typeof data.agent_handle === 'string' && data.agent_handle ? data.agent_handle : undefined,\n withHuman: typeof data.handling === 'string' && data.handling !== 'agents',\n branding: data.branding === true,\n }\n}\n\nexport interface AttachmentInit {\n apiUrl: string\n conversationId: string\n visitorToken: string\n signal?: AbortSignal\n}\n\n/**\n * Puts one file on the conversation, before the question that will carry it.\n *\n * Uploaded as it is picked rather than held until the message is sent: a format\n * the product does not take is refused here, in front of somebody who has not\n * written their question yet.\n *\n * What comes back is what was *accepted* — the kind and the type read off the\n * bytes on the server. The panel never decides what a file is.\n */\nexport async function uploadAttachment(\n init: AttachmentInit & { file: File },\n): Promise<ChatAttachment> {\n const body = new FormData()\n body.append('file', init.file)\n const response = await fetch(attachmentsUrl(init), {\n method: 'POST',\n // No content type of our own: the boundary belongs to the `FormData`, and a\n // header written over it hands the API a multipart body labelled otherwise.\n headers: { 'X-Visitor-Token': init.visitorToken },\n body,\n signal: init.signal,\n })\n if (!response.ok) throw await readError(response)\n const accepted = toAttachment(await response.json())\n if (!accepted) throw new ChatHttpError('The upload could not be read', response.status)\n return accepted\n}\n\n/** Takes a file back out of the conversation, bytes and all. */\nexport async function deleteAttachment(\n init: AttachmentInit & { attachmentId: string },\n): Promise<void> {\n const response = await fetch(\n `${attachmentsUrl(init)}/${encodeURIComponent(init.attachmentId)}`,\n {\n method: 'DELETE',\n headers: { 'X-Visitor-Token': init.visitorToken },\n signal: init.signal,\n },\n )\n if (!response.ok) throw await readError(response)\n}\n\n/**\n * The bytes of one file, as something a browser can draw.\n *\n * Fetched rather than linked, and this is the whole reason attachments carry no\n * URL: the route is opened by the visitor token, which travels in a header, and\n * a header is exactly what an `<img src>` cannot send. So the panel reads the\n * file itself and hands the caller an object URL — which the caller owns, and\n * has to revoke.\n */\nexport async function fetchAttachment(\n init: AttachmentInit & { attachmentId: string },\n): Promise<Blob> {\n const response = await fetch(\n `${attachmentsUrl(init)}/${encodeURIComponent(init.attachmentId)}/content`,\n { headers: { 'X-Visitor-Token': init.visitorToken }, signal: init.signal },\n )\n if (!response.ok) throw await readError(response)\n return response.blob()\n}\n\nfunction attachmentsUrl(init: AttachmentInit): string {\n return endpoint(\n init.apiUrl,\n `/public/conversations/${encodeURIComponent(init.conversationId)}/attachments`,\n )\n}\n\n/** Sends one message, and streams the answer as it is written. */\nexport async function sendMessage(init: SendMessageInit): Promise<ChatTurn> {\n return stream(\n endpoint(init.apiUrl, `/public/conversations/${encodeURIComponent(init.conversationId)}/messages`),\n {\n content: init.message,\n attachment_ids: init.attachmentIds ?? [],\n // Omitted rather than sent empty: the API tells an absent field from a\n // cleared one, and a page with nothing to say should say nothing.\n ...(init.context && Object.keys(init.context).length > 0\n ? { context: init.context }\n : {}),\n },\n init,\n )\n}\n\n/**\n * Answers the tool call a turn paused on, and lets the turn carry on.\n *\n * Streamed like a message, because it *is* the same turn continuing: the tokens the\n * agent writes after the call, then the stored answer — or another pause, if it asks\n * for a second tool needing a decision.\n */\nexport async function resolveApproval(init: ResolveApprovalInit): Promise<ChatTurn> {\n return stream(\n endpoint(init.apiUrl, `/public/conversations/${encodeURIComponent(init.conversationId)}/approvals`),\n { tool_call_id: init.toolCallId, approved: init.approved },\n init,\n )\n}\n\ninterface StreamInit {\n visitorToken: string\n subjectToken?: string\n onToken: (token: string) => void\n signal?: AbortSignal\n}\n\n/**\n * Plays one server-sent event stream, whatever started it.\n *\n * Frames are separated by a blank line, but a relay may forward the chunks as it\n * received them — so the buffer is split on lines and the remainder kept, which can\n * be a `data:` line cut in the middle.\n *\n * An `error` frame rejects: once the response is a 200 there is no status code left\n * to fail with, so the failure travels inside the stream and has to become one here.\n * Whatever tokens arrived before it are kept — half an answer already on somebody's\n * screen is not something to erase.\n */\nasync function stream(url: string, body: unknown, init: StreamInit): Promise<ChatTurn> {\n const response = await fetch(url, {\n method: 'POST',\n headers: headers(init.visitorToken, init.subjectToken),\n body: JSON.stringify(body),\n signal: init.signal,\n })\n if (!response.ok) throw await readError(response)\n if (!response.body) throw new ChatHttpError('Answer with no stream body')\n\n const reader = response.body.getReader()\n const decoder = new TextDecoder()\n let buffer = ''\n let event = ''\n let streamed = ''\n let failure: string | undefined\n let handedTo: string | undefined\n const turn: ChatTurn = { answer: '' }\n\n try {\n for (;;) {\n const { value, done } = await reader.read()\n if (done) break\n buffer += decoder.decode(value, { stream: true })\n\n const lines = buffer.split('\\n')\n buffer = lines.pop() ?? ''\n\n for (const raw of lines) {\n const line = raw.trim()\n if (!line) {\n // A blank line ends a frame; the name does not carry over to the next.\n event = ''\n continue\n }\n if (line.startsWith('event:')) {\n event = line.slice(6).trim()\n continue\n }\n if (!line.startsWith('data:')) continue\n\n const payload = line.slice(5).trim()\n if (!payload) continue\n let frame: Record<string, unknown>\n try {\n frame = JSON.parse(payload) as Record<string, unknown>\n } catch {\n continue\n }\n\n if (event === 'token' && typeof frame.text === 'string') {\n streamed += frame.text\n init.onToken(frame.text)\n } else if (event === 'done') {\n turn.answer = typeof frame.content === 'string' ? frame.content : streamed\n turn.agent = toHandle(frame.agent)\n if (typeof frame.unknown_handle === 'string' && frame.unknown_handle) {\n turn.unknownHandle = frame.unknown_handle\n turn.offered = toHandles(frame.handles)\n }\n } else if (event === 'handoff') {\n // Another agent of the team answers from here; whatever came before it\n // was the other agent's, and the answer is what follows.\n if (typeof frame.to_agent_name === 'string') handedTo = frame.to_agent_name\n streamed = ''\n } else if (event === 'escalated') {\n turn.withHuman = true\n } else if (event === 'held') {\n turn.held = true\n turn.withHuman = true\n } else if (event === 'approval_required') {\n turn.approval = toApproval(frame)\n } else if (event === 'error') {\n failure = typeof frame.detail === 'string' ? frame.detail : 'The turn failed'\n }\n }\n if (failure) break\n }\n } finally {\n // Releases the connection even on abort or mid-stream failure.\n void reader.cancel().catch(() => undefined)\n }\n\n if (failure) throw new ChatHttpError(failure)\n if (!turn.answer && !turn.approval) turn.answer = streamed\n if (handedTo && !turn.agent) turn.authorName = handedTo\n return turn\n}\n","/**\n * Remembers which conversation this panel is having, so a reload keeps it.\n *\n * Without this, refreshing the host page silently opened a second conversation and\n * left the first one unreachable — the visitor's own transcript, gone, with no way\n * back to it. What is stored is the pair the API needs to read it again: the id it\n * named, and the visitor token that is the whole of the authorization on it.\n *\n * `sessionStorage`, like the panel's open state and for a sharper reason: that token\n * *is* the credential. One tab's lifetime covers the reload and a navigation inside\n * the host app, which is what this exists for, and it does not leave a working key\n * to somebody's conversation on a shared machine for weeks. Reopening the browser\n * tomorrow starts a new conversation, which for a support panel is the honest\n * default.\n *\n * The embed key and the claimed user id travel with it, and both are checked before\n * anything is replayed. A remembered conversation belongs to one application and to\n * one person: a page that switched applications, or on which somebody else signed\n * in, has to start again — relabelling a transcript is exactly what the author claim\n * exists to prevent.\n */\n\n/** One conversation per host origin — enough while a page mounts a single widget,\n * which is the case for every current integrator. */\nconst CONVERSATION_KEY = 'squadico-chatbot:conversation'\n\nexport interface StoredConversation {\n sessionId: string\n visitorToken: string\n /** Which application it was opened on. A different one is a different panel. */\n embedKey: string\n /** Who the host said was in front of it, when it said anybody. */\n user?: string\n}\n\n/** The conversation this page was having, if it is still the same page's.\n *\n * `undefined` for anything that does not read back as a conversation: nothing\n * stored, storage refused, a half-written entry from an interrupted write. None of\n * those is worth an error — the panel opens a new conversation, which is what it\n * did before it remembered any. */\nexport function readConversation(): StoredConversation | undefined {\n try {\n if (typeof sessionStorage === 'undefined') return undefined\n const raw = sessionStorage.getItem(CONVERSATION_KEY)\n if (!raw) return undefined\n const parsed = JSON.parse(raw) as Partial<StoredConversation>\n if (!parsed.sessionId || !parsed.visitorToken || !parsed.embedKey) return undefined\n return {\n sessionId: parsed.sessionId,\n visitorToken: parsed.visitorToken,\n embedKey: parsed.embedKey,\n user: typeof parsed.user === 'string' ? parsed.user : undefined,\n }\n } catch {\n // Storage unavailable (private browsing, blocked cookies…) or unparseable.\n return undefined\n }\n}\n\nexport function writeConversation(conversation: StoredConversation): void {\n try {\n if (typeof sessionStorage === 'undefined') return\n sessionStorage.setItem(CONVERSATION_KEY, JSON.stringify(conversation))\n } catch {\n /* see readConversation: the conversation stays volatile, as it used to be */\n }\n}\n\nexport function forgetConversation(): void {\n try {\n if (typeof sessionStorage === 'undefined') return\n sessionStorage.removeItem(CONVERSATION_KEY)\n } catch {\n /* see readConversation */\n }\n}\n\n/**\n * Whether a remembered conversation is one *this* panel may carry on.\n *\n * Checked here rather than at each call site so the two reasons to drop one stay\n * together: it belongs to another application, or to another person.\n */\nexport function belongsTo(\n conversation: StoredConversation,\n { embedKey, user }: { embedKey: string; user?: string },\n): boolean {\n return conversation.embedKey === embedKey && conversation.user === user\n}\n","/**\n * State machine of a conversation: opening it, playing turns, deciding a paused\n * tool call, aborting, starting over. Kept out of the rendering so it stays\n * testable and reusable by both wrappers (custom element and React wrapper).\n *\n * **The conversation is opened by the server, once, and lazily.** A panel nobody\n * opened is a conversation nobody had, so the open call is made when the panel is\n * first shown — or on the first message, whichever comes first. The id and the\n * visitor token both come back from it: a visitor allowed to name their own\n * conversation is a visitor choosing which one to read.\n *\n * **And it survives a reload.** The pair is remembered for the tab, and a panel that\n * finds one replays it instead of opening a second conversation and orphaning the\n * first. A remembered conversation belongs to one application and to one person: a\n * page that switched either starts again, and one the API no longer knows about is\n * dropped rather than left to break every turn.\n *\n * **A paused turn is answered, not talked around.** The agent stops before calling a\n * tool and says what it would do; the buttons release it. Typing something else\n * instead is a decision too — the call was never approved, so it never runs, and the\n * backend closes it as the new question goes out. That is why what the user types is\n * always a new message here and never a correction squeezed into a pending decision.\n *\n * **Changing who the host says is in front of the panel opens a new conversation.**\n * Relabelling the old one would put two people's turns under one name, which is\n * exactly what the author claim exists to prevent.\n *\n * **The page context is translated, not forwarded.** A host writes\n * `order: { id, name }` because the chip shows the name; the API takes scalars. The\n * pair goes on the wire and the object stays on screen.\n *\n * **A handle is text, never a field.** The server parses the message for the agent\n * it addresses, so `agent` opens the conversation on one and the picker writes one\n * into what somebody is typing. Nothing here routes: a client naming its own agent\n * would be a client choosing its own router.\n */\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks'\n\nimport type {\n AgentHandle,\n ChatAttachment,\n ChatbotContext,\n ChatbotEvent,\n ChatMessage,\n HostUser,\n PendingApproval,\n SubjectTokenSource,\n} from '../types'\nimport {\n ChatHttpError,\n API_URL,\n openConversation,\n replayConversation,\n resolveApproval,\n deleteAttachment,\n fetchAttachment,\n sendMessage,\n uploadAttachment,\n} from './client'\nimport type { OpenedConversation } from './client'\nimport { belongsTo, forgetConversation, readConversation, writeConversation } from './conversation'\nimport { wireContext } from './context'\nimport { resolveLocale, type Locale } from './i18n'\nimport { uuid } from './uid'\n\n/**\n * Asks the page for the token it holds for its signed-in user, right before a turn\n * goes out. A page with nobody signed in — or a source that fails — sends none,\n * and the turn goes on without acting as anybody.\n */\nasync function subjectTokenOf(source: SubjectTokenSource | undefined): Promise<string | undefined> {\n if (!source) return undefined\n try {\n return (await source()) || undefined\n } catch {\n return undefined\n }\n}\n\nexport interface UseChatOptions {\n /** Where the calls go. Not reachable from the element or the React wrapper:\n * the built-in `API_URL` is the only server a page gets, and this exists for\n * the tests to name theirs. */\n apiUrl?: string\n /** Public key of the application this page embeds. Nothing happens without it. */\n embedKey?: string\n /** Who the host application has signed in, when it has anybody. */\n user?: HostUser\n /** Hands over the access token the host site holds for its signed-in user, asked\n * before every message so it is always fresh. See `ChatbotProps`. */\n getSubjectToken?: SubjectTokenSource\n /** The handle to open the conversation on, for a page that knows who should\n * answer. The visitor can still address somebody else afterwards. */\n agent?: string\n context?: ChatbotContext\n greeting?: string\n /** Language of the error bubble — the only text this module writes. Resolved by\n * the widget; the package's default language otherwise. */\n locale?: Locale\n onEvent?: (event: ChatbotEvent) => void\n /** How often a conversation a human handles is read again, in ms: their replies\n * are not streamed. */\n humanPollMs?: number\n}\n\nexport interface UseChatResult {\n messages: ChatMessage[]\n /** A turn is in flight (request sent, answer not finished yet). */\n busy: boolean\n /** The conversation's id, as the server named it. Empty until it is opened. */\n sessionId: string\n /** The handles this application offers a visitor. Empty until an organization\n * ticks one, which is the ordinary case. */\n handles: AgentHandle[]\n /** The handle the conversation opened on, as the server resolved it — not the one\n * that was asked for, which it may have fallen back from. Empty until it opens,\n * and empty when the page named nobody: the default agent needs no announcing. */\n addressee: string\n /** The tool call awaiting a decision, or `null` the rest of the time. */\n approval: PendingApproval | null\n /** Whether the panel shows \"Powered by Squadico\": the organization's plan says,\n * and nothing does until the conversation opens. */\n branding: boolean\n /** An agent handed the conversation to a human of the organization: no agent\n * answers, and what they reply shows as the conversation is read again. */\n withHuman: boolean\n /** Open the conversation now — what the panel calls when it is first shown, so\n * the welcome message is there to read. Idempotent. */\n start: () => void\n send: (text: string) => void\n /** The files the next question will carry, in the order they were picked. */\n attachments: ChatAttachment[]\n /** The names of the files still going up, so a slow upload is visible. */\n uploading: string[]\n /** Why the last upload was refused, as a key the panel translates. Null when\n * the last one was accepted — a refusal is about the file just picked, not a\n * state the conversation stays in. */\n attachmentError: AttachmentRefusal | null\n /** Puts one file on the conversation, opening it if it is not open yet. */\n attach: (file: File) => void\n /** Takes one back out, bytes and all. */\n detach: (attachmentId: string) => void\n /** Reads the bytes of a file a turn carried — what draws a picture back. */\n loadAttachment: (attachmentId: string) => Promise<Blob>\n /** Answers the paused call. `label` is what is shown on the user's side in the\n * history (\"Yes\" or \"No\"). */\n decide: (approved: boolean, label: string) => void\n stop: () => void\n /** Forget this conversation and open another one on the next message. */\n reset: () => void\n}\n\ninterface OpenConversation {\n /** The conversation's id. Still named `sessionId` because it is what\n * `sessionStorage` holds and what the host page is told in every event. */\n sessionId: string\n visitorToken: string\n}\n\n/** Why an upload was refused, in terms a panel can translate. */\nexport type AttachmentRefusal = 'unsupported' | 'tooLarge' | 'tooMany' | 'unreadable' | 'failed'\n\n/**\n * What a refused upload means, read off the status.\n *\n * Each one is a different instruction to whoever picked the file — send another\n * format, send something smaller, remove one first — which is why they are not\n * one message with a number in it.\n */\nfunction refusalOf(error: unknown): AttachmentRefusal {\n const status = error instanceof ChatHttpError ? error.status : undefined\n if (status === 415) return 'unsupported'\n if (status === 413) return 'tooLarge'\n if (status === 409) return 'tooMany'\n if (status === 422) return 'unreadable'\n return 'failed'\n}\n\n/** What a turn came back with, beyond its text: who answered, what it stopped on,\n * and the name it addressed that nobody here answers to. */\ntype TurnResult = {\n answer: string\n agent?: AgentHandle\n approval?: PendingApproval\n unknownHandle?: string\n offered?: AgentHandle[]\n authorName?: string\n withHuman?: boolean\n held?: boolean\n}\n\n/** How often a conversation a human handles is read again, by default. */\nconst HUMAN_POLL_MS = 5_000\n\n/** Whether a refusal means \"this conversation is over, open another one\".\n *\n * The code and not the status: 409 is also what an application with nothing\n * answering on it replies, and reopening would not help there. */\nfunction retired(error: unknown): boolean {\n return error instanceof ChatHttpError && error.code === 'conversation_retired'\n}\n\nexport function useChat(options: UseChatOptions): UseChatResult {\n const [messages, setMessages] = useState<ChatMessage[]>([])\n const [busy, setBusy] = useState(false)\n const [sessionId, setSessionId] = useState('')\n const [handles, setHandles] = useState<AgentHandle[]>([])\n const [addressee, setAddressee] = useState('')\n const [approval, setApproval] = useState<PendingApproval | null>(null)\n const [withHuman, setWithHuman] = useState(false)\n const [branding, setBranding] = useState(false)\n const [attachments, setAttachments] = useState<ChatAttachment[]>([])\n const [uploading, setUploading] = useState<string[]>([])\n const [attachmentError, setAttachmentError] = useState<AttachmentRefusal | null>(null)\n const abortRef = useRef<AbortController | null>(null)\n\n // Async closures read the props through a ref: without it, a turn started before\n // a context update would send the stale value.\n const latest = useRef(options)\n latest.current = options\n\n // The open call, kept as a promise so two turns starting at once — a click on a\n // suggestion while the panel is opening — share one conversation instead of\n // opening two.\n const opening = useRef<Promise<OpenConversation> | null>(null)\n const conversation = useRef<OpenConversation | null>(null)\n // Which claim the current conversation was opened under, so a change of host user\n // can be told from a re-render.\n const openedFor = useRef<string | undefined>(undefined)\n\n const greeting = options.greeting\n const greetingMessage = useMemo<ChatMessage | null>(\n () =>\n greeting\n ? { id: 'greeting', role: 'assistant', content: greeting, createdAt: Date.now() }\n : null,\n [greeting],\n )\n\n const emit = useCallback((event: ChatbotEvent) => {\n latest.current.onEvent?.(event)\n }, [])\n\n const patch = useCallback((id: string, changes: Partial<ChatMessage>) => {\n setMessages((current) =>\n current.map((message) => (message.id === id ? { ...message, ...changes } : message)),\n )\n }, [])\n\n const fail = useCallback(\n (error: unknown, replyId?: string) => {\n const status = error instanceof ChatHttpError ? error.status : undefined\n const detail = error instanceof Error ? error.message : String(error)\n const message = (latest.current.locale ?? resolveLocale(undefined)).t.error\n if (replyId) patch(replyId, { content: message, streaming: false, error: true })\n emit({\n type: 'chatbot-error',\n message: detail,\n status,\n sessionId: conversation.current?.sessionId ?? '',\n })\n if (typeof console !== 'undefined') {\n console.error('[squadico-chatbot]', detail)\n }\n },\n [emit, patch],\n )\n\n /**\n * The conversation this panel is having, opening it if it has none.\n *\n * The welcome message the application answers with is put on screen as part of\n * opening: an empty panel with a name on it says nothing about what may be asked.\n */\n const conversationNow = useCallback(async (): Promise<OpenConversation> => {\n if (conversation.current) return conversation.current\n if (opening.current) return opening.current\n\n const opts = latest.current\n if (!opts.embedKey) {\n throw new ChatHttpError('No embed key: nothing says which application to open')\n }\n const claim = opts.user\n const apiUrl = opts.apiUrl ?? API_URL\n const embedKey = opts.embedKey\n\n const adopt = (opened: OpenedConversation): OpenConversation => {\n const open = { sessionId: opened.conversationId, visitorToken: opened.visitorToken }\n conversation.current = open\n openedFor.current = claim?.id\n writeConversation({ ...open, embedKey, user: claim?.id })\n setSessionId(opened.conversationId)\n setHandles(opened.handles)\n // Announced only when the page asked for somebody: showing the default\n // agent's own handle would put an `@support` in every composer.\n setAddressee(opts.agent && opened.agentHandle ? opened.agentHandle : '')\n setWithHuman(Boolean(opened.withHuman))\n setBranding(opened.branding)\n // Prepended rather than appended: whatever the panel put on screen while it\n // was opening comes after what the conversation already held.\n if (opened.messages.length > 0) {\n setMessages((current) => [...opened.messages, ...current])\n }\n return open\n }\n\n const fresh = (): Promise<OpenConversation> =>\n openConversation({\n apiUrl,\n embedKey,\n user: claim,\n // Only when the page named one: an application always has an agent\n // answering plain text, and the panel has nothing to announce for it.\n agent: opts.agent,\n }).then(adopt)\n\n // A conversation the API no longer knows about — deleted, or opened against an\n // application that is gone — is dropped rather than retried: a panel that gave\n // up here is a panel one reload broke for good.\n const remembered = readConversation()\n const play =\n remembered && belongsTo(remembered, { embedKey, user: claim?.id })\n ? replayConversation({\n apiUrl,\n conversationId: remembered.sessionId,\n visitorToken: remembered.visitorToken,\n })\n .then(adopt)\n .catch(() => {\n forgetConversation()\n return fresh()\n })\n : fresh()\n\n opening.current = play\n try {\n return await play\n } finally {\n opening.current = null\n }\n }, [])\n\n const start = useCallback(() => {\n if (conversation.current || opening.current) return\n void conversationNow().catch((error: unknown) => fail(error))\n }, [conversationNow, fail])\n\n /**\n * Common body of a turn: appends the pair of bubbles, plays `run`, and publishes\n * what came back — the answer, and the call it stopped on if it stopped.\n */\n const turn = useCallback(\n (\n userText: string,\n run: (\n open: OpenConversation,\n onToken: (text: string) => void,\n signal: AbortSignal,\n ) => Promise<TurnResult>,\n { retry = false, carried = [] }: { retry?: boolean; carried?: ChatAttachment[] } = {},\n ) => {\n if (abortRef.current) return\n\n const controller = new AbortController()\n abortRef.current = controller\n setBusy(true)\n // The buttons of the previous turn are worth nothing now: the decision has\n // just been made, or the user moved on and the backend closed the call.\n setApproval(null)\n\n const replyId = uuid()\n setMessages((current) => [\n ...current,\n {\n id: uuid(),\n role: 'user',\n content: userText,\n createdAt: Date.now(),\n // Drawn from what the composer was holding rather than waited for: the\n // files were accepted before the message left, and a question whose\n // picture appears two seconds later reads as one that failed.\n attachments: carried.length > 0 ? carried : undefined,\n },\n { id: replyId, role: 'assistant', content: '', createdAt: Date.now(), streaming: true },\n ])\n\n const play = async (): Promise<void> => {\n let open = await conversationNow()\n emit({\n type: 'chatbot-message',\n role: 'user',\n content: userText,\n sessionId: open.sessionId,\n })\n let streamed = ''\n const onToken = (chunk: string): void => {\n streamed += chunk\n patch(replyId, { content: streamed })\n }\n let result: TurnResult\n try {\n result = await run(open, onToken, controller.signal)\n } catch (error: unknown) {\n if (!retired(error)) throw error\n // The organization rotated the embed key, so this conversation is over\n // and the remembered one is worthless. Refused before anything was\n // stored or streamed, which is what makes replaying it here safe rather\n // than a second question the visitor did not ask.\n forgetConversation()\n conversation.current = null\n opening.current = null\n if (!retry) throw error\n open = await conversationNow()\n streamed = ''\n patch(replyId, { content: '' })\n result = await run(open, onToken, controller.signal)\n }\n if (result.withHuman) setWithHuman(true)\n if (result.held) {\n // Kept for the human: no agent ran, so there is no answer to draw.\n setMessages((current) => current.filter((message) => message.id !== replyId))\n return\n }\n patch(replyId, {\n content: result.answer,\n streaming: false,\n agent: result.agent,\n authorName: result.authorName,\n approval: result.approval,\n // Kept on the answer it arrived with: the question was answered, and\n // what the panel adds is who could have been asked instead.\n unknownHandle: result.unknownHandle,\n offered: result.offered,\n })\n setApproval(result.approval ?? null)\n emit({\n type: 'chatbot-message',\n role: 'assistant',\n content: result.answer,\n sessionId: open.sessionId,\n agent: result.agent?.handle,\n })\n }\n\n void play()\n .catch((error: unknown) => {\n // A deliberate abort is not an error: keep the text already received.\n if (controller.signal.aborted) {\n patch(replyId, { streaming: false })\n return\n }\n fail(error, replyId)\n })\n .finally(() => {\n abortRef.current = null\n setBusy(false)\n })\n },\n [conversationNow, emit, fail, patch],\n )\n\n const send = useCallback(\n (raw: string) => {\n const text = raw.trim()\n // A file on its own is a turn, and a question about the file. What is\n // refused is the turn carrying neither words nor a file.\n if (!text && attachments.length === 0) return\n // Emptied before the run rather than after it: the files have left with the\n // question, and a composer still showing them would offer to remove part of\n // a turn already on its way.\n const carried = attachments\n setAttachments([])\n setAttachmentError(null)\n turn(\n text,\n async (open, onToken, signal) =>\n sendMessage({\n subjectToken: await subjectTokenOf(latest.current.getSubjectToken),\n apiUrl: latest.current.apiUrl ?? API_URL,\n conversationId: open.sessionId,\n visitorToken: open.visitorToken,\n message: text,\n attachmentIds: carried.map((file) => file.id),\n // Shaped for the wire here and not by the host: `order: { id, name }`\n // is how a page writes it — the chip shows the name — while the API\n // takes text, numbers and booleans, so the pair `orderId` +\n // `orderName` is what travels. Sending the nested object earns a 422\n // and no answer.\n context: latest.current.context ? wireContext(latest.current.context) : undefined,\n onToken,\n signal,\n }),\n // A question refused because the key was rotated is asked again on the\n // fresh conversation: the visitor typed it once, and nothing was stored.\n //\n // Its files are not carried over: they belong to the conversation that\n // was retired, and the ids mean nothing on the new one. The question is\n // asked again, without them, rather than failing on an id nobody knows.\n { retry: true, carried },\n )\n },\n [attachments, turn],\n )\n\n /**\n * Puts one file on the conversation, before the question that will carry it.\n *\n * Opens the conversation if it is not open yet: a visitor may well pick a file\n * before typing anything, and a file has to belong to a conversation to exist\n * at all.\n */\n const attach = useCallback(\n (file: File) => {\n setAttachmentError(null)\n setUploading((waiting) => [...waiting, file.name])\n void conversationNow()\n .then((open) =>\n uploadAttachment({\n apiUrl: latest.current.apiUrl ?? API_URL,\n conversationId: open.sessionId,\n visitorToken: open.visitorToken,\n file,\n }),\n )\n .then((accepted) => setAttachments((files) => [...files, accepted]))\n .catch((error: unknown) => setAttachmentError(refusalOf(error)))\n .finally(() =>\n setUploading((waiting) => {\n const at = waiting.indexOf(file.name)\n return at < 0 ? waiting : [...waiting.slice(0, at), ...waiting.slice(at + 1)]\n }),\n )\n },\n [conversationNow],\n )\n\n /**\n * Takes a file back out of the draft.\n *\n * Dropped from the list first and asked of the server second: the visitor\n * clicked a cross, and a chip that lingers until a round trip finishes reads as\n * a click that did nothing. A delete that fails leaves a file the draft no\n * longer names — an abandoned draft, which the API already knows what to do\n * with.\n */\n const detach = useCallback(\n (attachmentId: string) => {\n setAttachments((files) => files.filter((file) => file.id !== attachmentId))\n const open = conversation.current\n if (!open) return\n void deleteAttachment({\n apiUrl: latest.current.apiUrl ?? API_URL,\n conversationId: open.sessionId,\n visitorToken: open.visitorToken,\n attachmentId,\n }).catch(() => {\n // Nothing to tell anybody: the file is out of the draft either way.\n })\n },\n [],\n )\n\n const loadAttachment = useCallback(async (attachmentId: string): Promise<Blob> => {\n const open = conversation.current\n if (!open) throw new ChatHttpError('No conversation to read that file from')\n return fetchAttachment({\n apiUrl: latest.current.apiUrl ?? API_URL,\n conversationId: open.sessionId,\n visitorToken: open.visitorToken,\n attachmentId,\n })\n }, [])\n\n const decide = useCallback(\n (approved: boolean, label: string) => {\n const waiting = approval\n if (!waiting) return\n turn(label, async (open, onToken, signal) =>\n resolveApproval({\n subjectToken: await subjectTokenOf(latest.current.getSubjectToken),\n apiUrl: latest.current.apiUrl ?? API_URL,\n conversationId: open.sessionId,\n visitorToken: open.visitorToken,\n toolCallId: waiting.toolCallId,\n approved,\n onToken,\n signal,\n }),\n )\n },\n [approval, turn],\n )\n\n const stop = useCallback(() => {\n abortRef.current?.abort()\n abortRef.current = null\n setBusy(false)\n }, [])\n\n const reset = useCallback(() => {\n abortRef.current?.abort()\n abortRef.current = null\n conversation.current = null\n opening.current = null\n openedFor.current = undefined\n // Forgotten as well as dropped: a reload that replayed the conversation\n // somebody just started over would undo the gesture.\n forgetConversation()\n setBusy(false)\n setApproval(null)\n setWithHuman(false)\n setSessionId('')\n setAddressee('')\n setMessages([])\n emit({ type: 'chatbot-reset', sessionId: '' })\n }, [emit])\n\n // A human handles the conversation: their replies arrive with nobody streaming\n // them, so the conversation is read again until the agents have it back.\n const pollMs = options.humanPollMs ?? HUMAN_POLL_MS\n useEffect(() => {\n if (!withHuman || !sessionId) return\n const timer = setInterval(() => {\n const open = conversation.current\n if (!open || abortRef.current) return\n void replayConversation({\n apiUrl: latest.current.apiUrl ?? API_URL,\n conversationId: open.sessionId,\n visitorToken: open.visitorToken,\n })\n .then((replayed) => {\n setMessages(replayed.messages)\n setWithHuman(Boolean(replayed.withHuman))\n })\n .catch(() => {\n // A missed read is caught up by the next one.\n })\n }, pollMs)\n return () => clearInterval(timer)\n }, [withHuman, sessionId, pollMs])\n\n // A different person in front of the panel is a different conversation: their\n // turns must not land under somebody else's name.\n const claimId = options.user?.id\n useEffect(() => {\n if (conversation.current && openedFor.current !== claimId) reset()\n }, [claimId, reset])\n\n const visible = useMemo(\n () => (messages.length === 0 && greetingMessage ? [greetingMessage] : messages),\n [greetingMessage, messages],\n )\n\n return {\n messages: visible,\n busy,\n sessionId,\n handles,\n addressee,\n approval,\n withHuman,\n branding,\n start,\n send,\n attachments,\n uploading,\n attachmentError,\n attach,\n detach,\n loadAttachment,\n decide,\n stop,\n reset,\n }\n}\n","import{options as r,Fragment as e}from\"preact\";export{Fragment}from\"preact\";var t=/[\"&<]/;function n(r){if(0===r.length||!1===t.test(r))return r;for(var e=0,n=0,o=\"\",f=\"\";n<r.length;n++){switch(r.charCodeAt(n)){case 34:f=\""\";break;case 38:f=\"&\";break;case 60:f=\"<\";break;default:continue}n!==e&&(o+=r.slice(e,n)),o+=f,e=n+1}return n!==e&&(o+=r.slice(e,n)),o}var o=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,f=0,i=Array.isArray;function u(e,t,n,o,i,u){t||(t={});var a,c,p=t;if(\"ref\"in p)for(c in p={},t)\"ref\"==c?a=t[c]:p[c]=t[c];var l={type:e,props:p,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--f,__i:-1,__u:0,__source:i,__self:u};if(\"function\"==typeof e&&(a=e.defaultProps))for(c in a)void 0===p[c]&&(p[c]=a[c]);return r.vnode&&r.vnode(l),l}function a(r){var t=u(e,{tpl:r,exprs:[].slice.call(arguments,1)});return t.key=t.__v,t}var c={},p=/[A-Z]/g;function l(e,t){if(r.attr){var f=r.attr(e,t);if(\"string\"==typeof f)return f}if(t=function(r){return null!==r&&\"object\"==typeof r&&\"function\"==typeof r.valueOf?r.valueOf():r}(t),\"ref\"===e||\"key\"===e)return\"\";if(\"style\"===e&&\"object\"==typeof t){var i=\"\";for(var u in t){var a=t[u];if(null!=a&&\"\"!==a){var l=\"-\"==u[0]?u:c[u]||(c[u]=u.replace(p,\"-$&\").toLowerCase()),s=\";\";\"number\"!=typeof a||l.startsWith(\"--\")||o.test(l)||(s=\"px;\"),i=i+l+\":\"+a+s}}return e+'=\"'+n(i)+'\"'}return null==t||!1===t||\"function\"==typeof t||\"object\"==typeof t?\"\":!0===t?e:e+'=\"'+n(\"\"+t)+'\"'}function s(r){if(null==r||\"boolean\"==typeof r||\"function\"==typeof r)return null;if(\"object\"==typeof r){if(void 0===r.constructor)return r;if(i(r)){for(var e=0;e<r.length;e++)r[e]=s(r[e]);return r}}return n(\"\"+r)}export{u as jsx,l as jsxAttr,u as jsxDEV,s as jsxEscape,a as jsxTemplate,u as jsxs};\n//# sourceMappingURL=jsxRuntime.module.js.map\n","import type { JSX } from 'preact'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks'\nimport { MAX_MESSAGE_LENGTH } from '../lib/client'\nimport type { Locale } from '../lib/i18n'\nimport type { AgentHandle, ChatAttachment } from '../types'\n\nconst MAX_ROWS_PX = 132\n\n/**\n * What the picker offers, mirroring what the API accepts.\n *\n * A hint and nothing else: the bytes decide, on the server, and a file renamed\n * past this list is refused there rather than here.\n */\nconst ACCEPTED_FILES =\n 'image/png,image/jpeg,image/gif,image/webp,application/pdf,.docx,.txt,.md,.csv,.json'\n\n/** A handle being typed: where its `@` sits, and what has been written after it. */\ninterface Mention {\n start: number\n query: string\n}\n\n/** What a handle may hold, mirroring the API's own alphabet. */\nconst HANDLE_CHARS = /^[a-zA-Z0-9_-]*$/\n\n/**\n * The handle under the caret, if the caret is in one.\n *\n * An `@` only starts a handle at the beginning of the field or after whitespace:\n * `contact@acme.example` is an address somebody is typing, and opening a picker over\n * it would be the widget interrupting a sentence it misread. Same rule as the\n * server's, which reads a handle only at the head of a message.\n */\nfunction mentionAt(value: string, caret: number): Mention | null {\n const upto = value.slice(0, caret)\n const start = upto.lastIndexOf('@')\n if (start < 0) return null\n if (start > 0 && !/\\s/.test(upto[start - 1] ?? '')) return null\n const query = upto.slice(start + 1)\n return HANDLE_CHARS.test(query) ? { start, query } : null\n}\n\nexport interface ComposerProps {\n placeholder: string\n locale: Locale\n busy: boolean\n /** Focuses the field when the sidebar opens. */\n autoFocus: boolean\n /**\n * The handles this application offers, as the open response returned them.\n *\n * Empty is the ordinary case — a deployment is unlisted until somebody ticks it —\n * and it ships no affordance at all: an empty popup is worse than no popup, and\n * the default agent answers plain text anyway.\n */\n handles?: AgentHandle[]\n /** The handle the conversation opened on, written into the field once so the\n * visitor can see who is being addressed — and delete it. */\n addressee?: string\n /** The files already accepted for this question. */\n attachments?: ChatAttachment[]\n /** The names of the ones still on their way up, so a slow upload is visible. */\n uploading?: string[]\n /** Why the last upload was refused, in the visitor's own language. */\n attachmentError?: string\n /** Absent where a conversation cannot take files — which is also what hides\n * the paperclip rather than showing one that refuses. */\n onAttach?: (file: File) => void\n onDetach?: (attachmentId: string) => void\n onSend: (text: string) => void\n onStop: () => void\n}\n\nexport function Composer({\n placeholder,\n locale,\n busy,\n autoFocus,\n handles,\n addressee,\n attachments = [],\n uploading = [],\n attachmentError,\n onAttach,\n onDetach,\n onSend,\n onStop,\n}: ComposerProps): JSX.Element {\n const [value, setValue] = useState('')\n const [mention, setMention] = useState<Mention | null>(null)\n const [active, setActive] = useState(0)\n const [hovering, setHovering] = useState(false)\n const input = useRef<HTMLTextAreaElement | null>(null)\n const picker = useRef<HTMLInputElement | null>(null)\n const canAttach = Boolean(onAttach)\n const waiting = uploading.length > 0\n\n // What the picker offers right now: the offered handles whose name starts with\n // what is being typed. Nothing matching closes it rather than showing an empty\n // list — at that point the text is a name the panel knows nothing about, and the\n // server will say so once it is sent.\n const matches = useMemo(() => {\n if (!mention || !handles || handles.length === 0) return []\n const query = mention.query.toLowerCase()\n return handles.filter((handle) => handle.handle.startsWith(query))\n }, [handles, mention])\n const picking = matches.length > 0\n\n const grow = useCallback(() => {\n const node = input.current\n if (!node) return\n node.style.height = 'auto'\n const overflowing = node.scrollHeight > MAX_ROWS_PX\n node.style.height = `${Math.min(node.scrollHeight, MAX_ROWS_PX)}px`\n // No scrollbar while the text fits in the max height: otherwise a single\n // line already reserves the scroll gutter.\n node.style.overflowY = overflowing ? 'auto' : 'hidden'\n }, [])\n\n useEffect(() => {\n if (autoFocus) input.current?.focus()\n // Sets the real height at mount: without it the textarea keeps its default\n // `rows=1` height until the first keystroke.\n grow()\n }, [autoFocus, grow])\n\n // A page that opened on a handle starts the visitor off addressing it — as text,\n // which is the only thing that routes, and which they can delete. Never over\n // something already typed: whatever is in the field is theirs.\n useEffect(() => {\n if (!addressee) return\n setValue((current) => (current ? current : `@${addressee} `))\n requestAnimationFrame(grow)\n }, [addressee, grow])\n\n /** Reads the handle under the caret after anything that may have moved it. */\n const scan = useCallback((node: HTMLTextAreaElement) => {\n setMention(mentionAt(node.value, node.selectionStart ?? node.value.length))\n setActive(0)\n }, [])\n\n /**\n * Writes a picked handle where the one being typed was.\n *\n * Text, and only text: the server parses the message, so a name chosen from the\n * list is indistinguishable from one somebody spelled out — which is what keeps\n * the picker a convenience rather than a second router.\n */\n const pick = useCallback(\n (handle: string) => {\n const node = input.current\n if (!node || !mention) return\n const caret = node.selectionStart ?? node.value.length\n const next = `${value.slice(0, mention.start)}@${handle} ${value.slice(caret)}`\n const at = mention.start + handle.length + 2\n setValue(next)\n setMention(null)\n requestAnimationFrame(() => {\n node.focus()\n node.setSelectionRange(at, at)\n grow()\n })\n },\n [grow, mention, value],\n )\n\n /** Hands every picked file up, one round trip each. */\n const take = useCallback(\n (files: FileList | null) => {\n if (!onAttach || !files) return\n for (const file of Array.from(files)) onAttach(file)\n },\n [onAttach],\n )\n\n const submit = useCallback(() => {\n const text = value.trim()\n // Not while a file is still going up: a message names the files it carries,\n // and one that has not landed has no id to name. A file already up is a turn\n // on its own — a question about the file — so only the turn carrying neither\n // words nor a file is held here.\n if ((!text && attachments.length === 0) || busy || waiting) return\n onSend(text)\n setValue('')\n setMention(null)\n // The textarea keeps the sent message's height without this manual reset:\n // `grow` only fires again on the next keystroke.\n requestAnimationFrame(grow)\n }, [attachments.length, busy, grow, onSend, value, waiting])\n\n const onKeyDown = useCallback(\n (event: JSX.TargetedKeyboardEvent<HTMLTextAreaElement>) => {\n // The picker takes the keys it needs while it is open, and only then: with no\n // list on screen every key means what it has always meant.\n if (picking && !event.isComposing) {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault()\n const step = event.key === 'ArrowDown' ? 1 : matches.length - 1\n setActive((current) => (current + step) % matches.length)\n return\n }\n if (event.key === 'Enter' || event.key === 'Tab') {\n event.preventDefault()\n pick((matches[active] ?? matches[0]).handle)\n return\n }\n if (event.key === 'Escape') {\n event.preventDefault()\n // Kept out of the host page: Escape closes the whole panel from a\n // `document` listener, and closing a popup must not close the panel too.\n event.stopPropagation()\n setMention(null)\n return\n }\n }\n // Enter sends, Shift+Enter inserts a line break. `isComposing` avoids\n // sending during an IME composition (CJK keyboards, long accents).\n if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) {\n event.preventDefault()\n submit()\n }\n },\n [active, matches, pick, picking, submit],\n )\n\n const remaining = MAX_MESSAGE_LENGTH - value.length\n\n return (\n <form\n class={`sqc-composer${hovering ? ' sqc-composer--dropping' : ''}`}\n onSubmit={(event) => {\n event.preventDefault()\n submit()\n }}\n onDragOver={(event) => {\n if (!canAttach) return\n event.preventDefault()\n setHovering(true)\n }}\n onDragLeave={() => setHovering(false)}\n onDrop={(event) => {\n if (!canAttach) return\n event.preventDefault()\n setHovering(false)\n take(event.dataTransfer?.files ?? null)\n }}\n >\n {(attachments.length > 0 || waiting || attachmentError) && (\n <div class=\"sqc-attachments\">\n {attachments.map((file) => (\n <span key={file.id} class=\"sqc-chip\" data-kind={file.kind}>\n <span class=\"sqc-chip__name\">{file.filename}</span>\n <button\n type=\"button\"\n class=\"sqc-chip__remove\"\n aria-label={locale.t.composer.remove.replace('{name}', file.filename)}\n onClick={() => onDetach?.(file.id)}\n >\n ×\n </button>\n </span>\n ))}\n {uploading.map((name) => (\n <span key={name} class=\"sqc-chip sqc-chip--waiting\">\n <span class=\"sqc-chip__name\">{name}</span>\n </span>\n ))}\n {attachmentError && (\n <p class=\"sqc-attachments__error\" role=\"status\">\n {attachmentError}\n </p>\n )}\n </div>\n )}\n <div class=\"sqc-composer__field\">\n {picking && (\n <ul class=\"sqc-mentions\" role=\"listbox\" aria-label={locale.t.handles.picker}>\n {matches.map((handle, index) => (\n <li\n key={handle.handle}\n role=\"option\"\n aria-selected={index === active}\n class={`sqc-mention${index === active ? ' sqc-mention--active' : ''}`}\n // The list is clicked while the field has the focus: without this\n // the mousedown blurs the textarea and the caret is gone before\n // there is anywhere to write the handle.\n onMouseDown={(event) => event.preventDefault()}\n onMouseEnter={() => setActive(index)}\n onClick={() => pick(handle.handle)}\n >\n <span class=\"sqc-mention__icon\" aria-hidden=\"true\">\n {handle.avatarEmoji ?? '@'}\n </span>\n <span class=\"sqc-mention__handle\">@{handle.handle}</span>\n <span class=\"sqc-mention__name\">{handle.name}</span>\n </li>\n ))}\n </ul>\n )}\n <textarea\n ref={input}\n class=\"sqc-composer__input\"\n rows={1}\n value={value}\n placeholder={placeholder}\n maxLength={MAX_MESSAGE_LENGTH}\n aria-label={locale.t.composer.label}\n onInput={(event) => {\n setValue(event.currentTarget.value)\n scan(event.currentTarget)\n grow()\n }}\n onKeyDown={onKeyDown}\n // The caret can move without the text changing — a click, an arrow key —\n // and the picker follows the caret, not the keystrokes.\n onClick={(event) => scan(event.currentTarget)}\n // A screenshot pasted straight into the field. Only the files are\n // taken, so pasting text still pastes text.\n onPaste={(event) => {\n const files = event.clipboardData?.files\n if (!canAttach || !files || files.length === 0) return\n event.preventDefault()\n take(files)\n }}\n />\n {remaining <= 200 && (\n <span class=\"sqc-composer__count\" aria-live=\"polite\">\n {remaining}\n </span>\n )}\n </div>\n\n {canAttach && (\n <>\n <input\n ref={picker}\n type=\"file\"\n multiple\n accept={ACCEPTED_FILES}\n class=\"sqc-file-input\"\n onChange={(event) => {\n take(event.currentTarget.files)\n // Cleared so picking the same file twice in a row still fires a\n // change event — otherwise the second attempt does nothing.\n event.currentTarget.value = ''\n }}\n />\n <button\n type=\"button\"\n class=\"sqc-btn sqc-btn--attach\"\n onClick={() => picker.current?.click()}\n aria-label={locale.t.composer.attach}\n title={locale.t.composer.attachTitle}\n >\n {/* Paperclip. */}\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.9\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <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 </svg>\n </button>\n </>\n )}\n\n {busy ? (\n <button\n type=\"button\"\n class=\"sqc-btn sqc-btn--stop\"\n onClick={onStop}\n aria-label={locale.t.composer.stop}\n title={locale.t.composer.stopTitle}\n >\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <rect x=\"7\" y=\"7\" width=\"10\" height=\"10\" rx=\"2\" fill=\"currentColor\" />\n </svg>\n </button>\n ) : (\n <button\n type=\"submit\"\n class=\"sqc-btn sqc-btn--send\"\n disabled={(!value.trim() && attachments.length === 0) || waiting}\n aria-label={locale.t.composer.send}\n title={locale.t.composer.sendTitle}\n >\n {/* Send glyph of the design system. */}\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.9\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M5 12l14-7-5 14-2.5-5.5L5 12z\" />\n </svg>\n </button>\n )}\n </form>\n )\n}\n","/**\n * Detection of the assistant's closed questions, so \"Yes\" / \"No\" can be offered\n * instead of making the user retype the answer.\n *\n * The protocol exposes nothing explicit for this (the API only returns text), so\n * this leans on the phrasings agents actually produce. The list is deliberately\n * narrow: an open question (\"Which records would you like to see?\") must not\n * bring up buttons.\n *\n * A question asked in the user's language is only recognisable with that\n * language's phrasings: the patterns are therefore keyed by language, and the\n * widget's locale picks the set — a single English set would leave a\n * French-speaking host without buttons.\n */\nimport { DEFAULT_LANGUAGE, type LanguageCode } from './i18n'\n\n/** \"Reply YES to confirm\": an answer instruction, not a question. */\nconst ANSWER_HINT: Record<LanguageCode, RegExp> = {\n fr: /\\br[ée]ponde?z? +«?\\s*oui\\b/i,\n en: /\\b(?:reply|answer|respond) +[“\"']?\\s*yes\\b/i,\n es: /\\bresponda?e?d? +«?\\s*s[íi]\\b/i,\n}\n\nconst PATTERNS: Record<LanguageCode, RegExp[]> = {\n fr: [\n /\\b(?:confirmes?[- ]tu|confirmez[- ]vous)\\b/i,\n /\\b(?:valides?[- ]tu|validez[- ]vous)\\b/i,\n /\\b(?:es[- ]tu s[ûu]re?|[êe]tes[- ]vous s[ûu]re?s?)\\b/i,\n /\\b(?:dois[- ]je|puis[- ]je)\\b/i,\n /\\b(?:je continue|on continue|on y va|je lance)\\b/i,\n ANSWER_HINT.fr,\n ],\n en: [\n /\\bdo you confirm\\b/i,\n /\\bdo you (?:want|wish) me to\\b/i,\n /\\b(?:shall|should) I\\b/i,\n /\\bare you sure\\b/i,\n /\\b(?:shall we|should I) (?:proceed|continue|go ahead)\\b/i,\n ANSWER_HINT.en,\n ],\n es: [\n /\\b(?:confirmas|confirma|confirm[áa]is)\\b/i,\n /\\b(?:validas|valida|valid[áa]is)\\b/i,\n /\\best[áa]s? seguro\\b/i,\n /\\b(?:contin[úu]o|procedo|lo lanzo|lo hago)\\b/i,\n /\\bquieres? que\\b/i,\n ANSWER_HINT.es,\n ],\n}\n\n/** Tickable options already carry their own buttons. */\nconst CHECKBOX = /^\\s*(?:[-*•]\\s+)?\\[[ xX]\\]\\s+/m\n\nexport function isConfirmationPrompt(\n text: string,\n language: LanguageCode = DEFAULT_LANGUAGE,\n): boolean {\n if (CHECKBOX.test(text)) return false\n\n const lines = text\n .split('\\n')\n .map((line) => line.trim())\n .filter(Boolean)\n const last = lines[lines.length - 1]\n if (!last) return false\n // A closed question ends with \"?\" — except when the answer instruction takes\n // up the last line (\"Reply YES to confirm.\").\n if (!last.includes('?') && !ANSWER_HINT[language].test(last)) return false\n\n return PATTERNS[language].some((pattern) => pattern.test(last))\n}\n","/**\n * Decision on a tool call the agent stopped before making: yes, or no.\n *\n * The agent paused before calling the tool and wrote what it would do (that is the\n * message body); these buttons are what releases the call, not a bare \"yes\"\n * interpreted by the model. Nothing has been written while they are here.\n *\n * **When it wrote nothing, the call speaks for itself.** Several models ask for a\n * tool with no sentence at all, and a visitor then faces an empty bubble with two\n * buttons under it — a decision nobody can take. So `call`, passed only in that\n * case, names what would be used and with what: approving \"read a pull request\"\n * is not approving *which* one. The values come from a model and are printed as\n * text, never as markup.\n *\n * Two answers and no third. There used to be a \"correct it\" button that opened an\n * input, and the API has never had anything to send it to — a control that cannot be\n * honoured is worse than one that is missing. Saying something else is a new\n * message, and the backend closes the pending call as it goes out: asking instead of\n * deciding is a decision too.\n *\n * Once the decision is made the group is frozen — the history has to stay readable,\n * and a call is not approved twice.\n */\nimport type { JSX } from 'preact'\nimport { useState } from 'preact/hooks'\n\nimport type { Locale } from '../lib/i18n'\nimport type { PendingApproval } from '../types'\n\nexport interface ApprovalProps {\n locale: Locale\n /** The paused call, when the agent asked for it without a word of its own.\n * Absent when it explained itself: its sentence is the message body, and\n * saying the same thing twice reads as two requests. */\n call?: PendingApproval\n /** Absent when the group is frozen: decision already made, or turn in flight. */\n onDecide?: (approved: boolean, label: string) => void\n}\n\n/** The qualification the toolbox adds so two servers may both offer `search`:\n * `mcp_`, `custom_` or `a2a_`, then eight hex characters of an id. Ours, and\n * meaningless to a visitor. */\nconst QUALIFIED_TOOL_NAME = /^(?:mcp|custom|a2a)_[0-9a-f]{8}_/\n\n/** A name a person can read: `pull_request_read` becomes \"Pull request read\".\n * Shaped like the context chips, which humanise the host's own keys the same\n * way — an unreadable name is what makes a decision impossible to take. */\nfunction readable(name: string): string {\n const words = name\n .replace(QUALIFIED_TOOL_NAME, '')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/[_-]+/g, ' ')\n .trim()\n .toLowerCase()\n if (!words) return name\n return words.charAt(0).toUpperCase() + words.slice(1)\n}\n\n/** One argument as a line of text. A flag is said as yes or no, and objects and\n * lists are printed as JSON rather than as \"[object Object]\": a value nobody can\n * read is a value nobody can approve. */\nfunction shown(value: unknown, locale: Locale): string {\n if (value === true) return locale.t.confirm.yes\n if (value === false) return locale.t.confirm.no\n if (typeof value === 'string') return value\n return JSON.stringify(value) ?? String(value)\n}\n\nexport function Approval({ locale, call, onDecide }: ApprovalProps): JSX.Element {\n const { approval, confirm } = locale.t\n const [picked, setPicked] = useState<string | null>(null)\n const live = Boolean(onDecide) && picked === null\n\n const choose = (approved: boolean, label: string): void => {\n setPicked(label)\n onDecide?.(approved, label)\n }\n\n const values = call ? Object.entries(call.arguments) : []\n\n return (\n <div class=\"sqc-approval\" role=\"group\" aria-label={approval.group}>\n {call && (\n <p class=\"sqc-approval__request\" data-testid=\"sqc-approval-tool\">\n {approval.request.replace('{tool}', readable(call.tool))}\n </p>\n )}\n {values.length > 0 && (\n <dl class=\"sqc-approval__args\" data-testid=\"sqc-approval-arguments\">\n {values.map(([name, value]) => (\n <div class=\"sqc-approval__arg\" key={name}>\n <dt class=\"sqc-approval__arg-name\">{readable(name)}</dt>\n <dd class=\"sqc-approval__arg-value\">{shown(value, locale)}</dd>\n </div>\n ))}\n </dl>\n )}\n <div class=\"sqc-approval__actions\">\n <button\n type=\"button\"\n class=\"sqc-approval__btn sqc-approval__btn--yes\"\n aria-pressed={picked === confirm.yes}\n disabled={!live}\n onClick={() => choose(true, confirm.yes)}\n >\n {approval.approve}\n </button>\n <button\n type=\"button\"\n class=\"sqc-approval__btn sqc-approval__btn--no\"\n aria-pressed={picked === confirm.no}\n disabled={!live}\n onClick={() => choose(false, confirm.no)}\n >\n {approval.reject}\n </button>\n </div>\n </div>\n )\n}\n","/**\n * \"Yes\" / \"No\" buttons under a closed question from the assistant.\n *\n * A bare \"yes\" or \"no\" is recognised agent-side without going through the LLM,\n * so clicking is exactly the same as typing the answer. As with the tickable\n * options, the group locks on the choice made, so the history stays readable.\n */\nimport type { JSX } from 'preact'\nimport { useState } from 'preact/hooks'\nimport type { Locale } from '../lib/i18n'\n\nexport interface ConfirmProps {\n locale: Locale\n /** Absent when the group is frozen: older message, or turn in flight. */\n onPick?: (answer: string) => void\n}\n\nexport function Confirm({ locale, onPick }: ConfirmProps): JSX.Element {\n const [picked, setPicked] = useState<string | null>(null)\n const live = Boolean(onPick) && picked === null\n const { confirm } = locale.t\n // The word sent is the one of the user's own language: the agent recognises a\n // bare \"yes\" without a model call, but in that language.\n const answers = [\n { value: confirm.yesValue, label: confirm.yes, kind: 'yes' },\n { value: confirm.noValue, label: confirm.no, kind: 'no' },\n ]\n\n return (\n <div class=\"sqc-confirm\" role=\"group\" aria-label={confirm.group}>\n {answers.map((answer) => (\n <button\n key={answer.value}\n type=\"button\"\n class={`sqc-confirm__btn sqc-confirm__btn--${answer.kind}`}\n aria-pressed={picked === answer.value}\n disabled={!live}\n onClick={() => {\n setPicked(answer.value)\n onPick?.(answer.value)\n }}\n >\n {answer.label}\n </button>\n ))}\n </div>\n )\n}\n","/**\n * Clickable options built from the Markdown checkboxes (`- [ ] Name`) the\n * assistant writes when it offers candidates.\n *\n * The agent resolves the answer by name, so clicking an option amounts to\n * sending its exact label as a message. The choice is single — the agent expects\n * one candidate per turn — and the group locks as soon as an option is taken, so\n * the history stays readable.\n */\nimport type { ComponentChildren, JSX } from 'preact'\nimport { useState } from 'preact/hooks'\nimport type { Locale } from '../lib/i18n'\n\nexport interface ChoiceItem {\n /** Plain text sent to the agent. */\n label: string\n /** Checkbox already ticked in the Markdown (`- [x] …`). */\n checked: boolean\n /** Rendered label (inline Markdown is already applied to it). */\n content: ComponentChildren\n}\n\nfunction CheckIcon(): JSX.Element {\n return (\n <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" aria-hidden=\"true\">\n <path d=\"M3.5 8.5l3 3 6-7\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\n </svg>\n )\n}\n\nexport interface ChoicesProps {\n items: ChoiceItem[]\n locale: Locale\n /** Absent when the group is frozen: older message, or turn in flight. */\n onPick?: (label: string) => void\n}\n\nexport function Choices({ items, locale, onPick }: ChoicesProps): JSX.Element {\n const [picked, setPicked] = useState<string | null>(null)\n const live = Boolean(onPick) && picked === null\n\n return (\n <div class=\"sqc-choices\" role=\"group\" aria-label={locale.t.choices}>\n {items.map((item, index) => {\n // Once a choice is made it becomes the only ticked option: the Markdown\n // state only holds until the user has decided.\n const on = picked === null ? item.checked : picked === item.label\n return (\n <button\n key={`${index}-${item.label}`}\n type=\"button\"\n class=\"sqc-choice\"\n aria-pressed={on}\n disabled={!live}\n onClick={() => {\n setPicked(item.label)\n onPick?.(item.label)\n }}\n >\n <span class={`sqc-choice__box${on ? ' sqc-choice__box--on' : ''}`} aria-hidden=\"true\">\n {on && <CheckIcon />}\n </span>\n <span class=\"sqc-choice__label\">{item.content}</span>\n </button>\n )\n })}\n </div>\n )\n}\n","/**\n * Minimal Markdown rendering of the agent's answers.\n *\n * The agent answers with a stable subset of Markdown: headings, lists\n * (sometimes nested), tables (record listings), identifiers in backticks, links.\n * That subset is covered and nothing more: no Markdown library (weight), and\n * above all **never** any injected HTML — everything is produced as Preact\n * nodes, hence escaped by construction.\n */\nimport type { JSX } from 'preact'\nimport type { Locale } from '../lib/i18n'\nimport { Choices, type ChoiceItem } from './Choices'\n\ntype Inline = JSX.Element | string\n\n/**\n * Emphasis, code, Markdown links and bare URLs. Deliberately without `_`/`__`:\n * domain identifiers (`order_id`, `record_ref`, `item_1`) would be turned into\n * italics at the first pair.\n */\nconst INLINE =\n /(\\*\\*[^*\\n]+\\*\\*|`[^`\\n]+`|~~[^~\\n]+~~|\\[[^\\]\\n]+\\]\\([^)\\s]+\\)|\\*[^*\\n]+\\*|https?:\\/\\/[^\\s<>()]+)/g\n\nconst MD_LINK = /^\\[([^\\]\\n]+)\\]\\(([^)\\s]+)\\)$/\n/** An href is only rendered when it is navigable: no `javascript:`, no `data:`. */\nconst SAFE_HREF = /^(https?:|mailto:)/i\n\nfunction link(href: string, label: string, key: string): Inline {\n if (!SAFE_HREF.test(href)) return label\n return (\n <a key={key} href={href} target=\"_blank\" rel=\"noopener noreferrer\">\n {label}\n </a>\n )\n}\n\nfunction inline(text: string, keyPrefix: string): Inline[] {\n const parts = text.split(INLINE)\n const nodes: Inline[] = []\n\n parts.forEach((part, index) => {\n if (!part) return\n const key = `${keyPrefix}-${index}`\n const mdLink = MD_LINK.exec(part)\n\n if (part.startsWith('**') && part.endsWith('**') && part.length > 4) {\n nodes.push(<strong key={key}>{part.slice(2, -2)}</strong>)\n } else if (part.startsWith('`') && part.endsWith('`') && part.length > 2) {\n nodes.push(<code key={key}>{part.slice(1, -1)}</code>)\n } else if (part.startsWith('~~') && part.endsWith('~~') && part.length > 4) {\n nodes.push(<del key={key}>{part.slice(2, -2)}</del>)\n } else if (mdLink) {\n nodes.push(link(mdLink[2], mdLink[1], key))\n } else if (part.startsWith('*') && part.endsWith('*') && part.length > 2) {\n nodes.push(<em key={key}>{part.slice(1, -1)}</em>)\n } else if (/^https?:\\/\\//.test(part)) {\n nodes.push(link(part, part, key))\n } else {\n nodes.push(part)\n }\n })\n\n return nodes\n}\n\n/**\n * Markdown checkbox, with or without a bullet: the agent writes `- [ ] Name`,\n * but `[ ] Name` is accepted too so this does not depend on the exact template.\n */\nconst CHOICE = /^\\s*(?:[-*•]\\s+)?\\[([ xX])\\]\\s+(.+)$/\n\n/** Text without markup: what the agent must receive when an option is clicked. */\nfunction plain(text: string): string {\n return text\n .replace(/\\[([^\\]\\n]+)\\]\\([^)\\s]+\\)/g, '$1')\n .replace(/\\*\\*|~~|`|\\*/g, '')\n .trim()\n}\n\nconst BULLET = /^(\\s*)[-*•]\\s+/\nconst ORDERED = /^(\\s*)\\d+[.)]\\s+/\nconst HEADING = /^\\s{0,3}(#{1,6})\\s+(.+?)#*\\s*$/\nconst RULE = /^\\s*([-*_])(?:\\s*\\1){2,}\\s*$/\nconst QUOTE = /^\\s*>\\s?(.*)$/\nconst TABLE_ROW = /^\\s*\\|.*\\|\\s*$/\nconst TABLE_SEP = /^\\s*\\|(?:\\s*:?-{1,}:?\\s*\\|)+\\s*$/\nconst FENCE = /^\\s*```/\n\ninterface ListItem {\n depth: number\n ordered: boolean\n text: string\n}\n\n/** Splits a table row into cells (escaped pipes are not handled). */\nfunction cells(row: string): string[] {\n return row\n .replace(/^\\s*\\|/, '')\n .replace(/\\|\\s*$/, '')\n .split('|')\n .map((cell) => cell.trim())\n}\n\n/**\n * Rebuilds nested lists from flat items carrying their indentation depth.\n * Returns the list and the index of the first item left unconsumed.\n */\nfunction buildList(\n items: ListItem[],\n start: number,\n depth: number,\n key: string,\n): [JSX.Element, number] {\n const ordered = items[start].ordered\n const entries: { key: string; text: string | null; nested: JSX.Element[] }[] = []\n let index = start\n\n while (index < items.length && items[index].depth >= depth) {\n const item = items[index]\n // A marker of another kind at the same level opens a separate list rather\n // than mixing bullets and numbers.\n if (item.depth === depth && item.ordered !== ordered) break\n\n if (item.depth > depth) {\n const [nested, next] = buildList(items, index, item.depth, `${key}-${index}`)\n const last = entries[entries.length - 1]\n // A sub-list with no parent (first line already indented) is held in an\n // empty item rather than lost.\n if (last) last.nested.push(nested)\n else entries.push({ key: `${key}-${index}`, text: null, nested: [nested] })\n index = next\n continue\n }\n\n entries.push({ key: `${key}-${index}`, text: item.text, nested: [] })\n index += 1\n }\n\n const children = entries.map((entry) => (\n <li key={entry.key}>\n {entry.text === null ? null : inline(entry.text, entry.key)}\n {entry.nested}\n </li>\n ))\n\n const list = ordered ? (\n <ol key={key}>{children}</ol>\n ) : (\n <ul key={key}>{children}</ul>\n )\n return [list, index]\n}\n\nexport interface RichTextProps {\n text: string\n locale: Locale\n /** Makes the checkboxes clickable; absent, they stay displayed but frozen. */\n onChoice?: (label: string) => void\n}\n\nexport function RichText({ text, locale, onChoice }: RichTextProps): JSX.Element {\n const lines = text.split('\\n')\n const blocks: JSX.Element[] = []\n\n let paragraph: string[] = []\n let items: ListItem[] = []\n let quote: string[] = []\n\n const flushParagraph = (): void => {\n if (!paragraph.length) return\n const key = `p${blocks.length}`\n blocks.push(<p key={key}>{inline(paragraph.join('\\n'), key)}</p>)\n paragraph = []\n }\n\n const flushList = (): void => {\n if (!items.length) return\n let index = 0\n while (index < items.length) {\n const key = `l${blocks.length}`\n const [list, next] = buildList(items, index, items[index].depth, key)\n blocks.push(list)\n index = next\n }\n items = []\n }\n\n const flushQuote = (): void => {\n if (!quote.length) return\n const key = `q${blocks.length}`\n blocks.push(<blockquote key={key}>{inline(quote.join('\\n'), key)}</blockquote>)\n quote = []\n }\n\n const flushAll = (): void => {\n flushParagraph()\n flushList()\n flushQuote()\n }\n\n for (let cursor = 0; cursor < lines.length; cursor += 1) {\n const line = lines[cursor]\n\n // Code block: everything is taken literally until the closing fence. An\n // unclosed block (answer cut mid-stream) is rendered as-is rather\n // than lost.\n if (FENCE.test(line)) {\n flushAll()\n const fence: string[] = []\n cursor += 1\n while (cursor < lines.length && !FENCE.test(lines[cursor])) {\n fence.push(lines[cursor])\n cursor += 1\n }\n const key = `c${blocks.length}`\n blocks.push(\n <pre key={key}>\n <code>{fence.join('\\n')}</code>\n </pre>,\n )\n continue\n }\n\n // Table: only recognised when the header is followed by the separator row,\n // otherwise a sentence containing pipes would become a table.\n if (TABLE_ROW.test(line) && cursor + 1 < lines.length && TABLE_SEP.test(lines[cursor + 1])) {\n flushAll()\n const header = cells(line)\n const rows: string[][] = []\n cursor += 2\n while (cursor < lines.length && TABLE_ROW.test(lines[cursor])) {\n rows.push(cells(lines[cursor]))\n cursor += 1\n }\n cursor -= 1\n\n const key = `t${blocks.length}`\n blocks.push(\n <div key={key} class=\"sqc-table\">\n <table>\n <thead>\n <tr>\n {header.map((cell, index) => (\n <th key={`${key}-h${index}`}>{inline(cell, `${key}-h${index}`)}</th>\n ))}\n </tr>\n </thead>\n <tbody>\n {rows.map((row, rowIndex) => (\n <tr key={`${key}-r${rowIndex}`}>\n {header.map((_, index) => (\n <td key={`${key}-r${rowIndex}c${index}`}>\n {inline(row[index] ?? '', `${key}-r${rowIndex}c${index}`)}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>,\n )\n continue\n }\n\n if (!line.trim()) {\n flushAll()\n continue\n }\n\n // Consecutive checkboxes: a single option group, not a list.\n if (CHOICE.test(line)) {\n flushAll()\n const choices: ChoiceItem[] = []\n while (cursor < lines.length) {\n const choice = CHOICE.exec(lines[cursor])\n if (!choice) break\n const label = choice[2].trim()\n const key = `o${blocks.length}-${choices.length}`\n choices.push({\n // The label sent back to the agent is stripped of its markup: it is\n // matched against the candidates by name comparison.\n label: plain(label),\n checked: choice[1].toLowerCase() === 'x',\n content: inline(label, key),\n })\n cursor += 1\n }\n cursor -= 1\n blocks.push(\n <Choices key={`o${blocks.length}`} items={choices} locale={locale} onPick={onChoice} />,\n )\n continue\n }\n\n const heading = HEADING.exec(line)\n if (heading) {\n flushAll()\n // In a chat bubble a typographic h1 makes no sense: the six Markdown\n // levels are compressed onto h3–h5.\n const depth = heading[1].length\n const Tag = (depth <= 2 ? 'h3' : depth === 3 ? 'h4' : 'h5') as 'h3'\n const key = `h${blocks.length}`\n blocks.push(<Tag key={key}>{inline(heading[2], key)}</Tag>)\n continue\n }\n\n if (RULE.test(line)) {\n flushAll()\n blocks.push(<hr key={`r${blocks.length}`} />)\n continue\n }\n\n const quoted = QUOTE.exec(line)\n if (quoted) {\n flushParagraph()\n flushList()\n quote.push(quoted[1])\n continue\n }\n\n const bullet = BULLET.exec(line)\n const ordered = bullet ? null : ORDERED.exec(line)\n const marker = bullet ?? ordered\n\n if (marker) {\n flushParagraph()\n flushQuote()\n items.push({\n // The raw indentation serves as relative depth: only the comparison\n // between items matters, not the absolute value.\n depth: marker[1].replace(/\\t/g, ' ').length,\n ordered: Boolean(ordered),\n text: line.slice(marker[0].length),\n })\n continue\n }\n\n flushList()\n flushQuote()\n paragraph.push(line)\n }\n\n flushAll()\n\n return <>{blocks}</>\n}\n","import type { JSX } from 'preact'\nimport { useEffect, useLayoutEffect, useRef, useState } from 'preact/hooks'\nimport { isConfirmationPrompt } from '../lib/confirm'\nimport type { Locale } from '../lib/i18n'\nimport type { ChatAttachment, ChatMessage } from '../types'\nimport { Approval } from './Approval'\nimport { Confirm } from './Confirm'\nimport { RichText } from './RichText'\n\n/** Below this distance (px) from the bottom of the list, the user is taken to\n * be following the stream and the list keeps scrolling for them. Beyond it,\n * they have scrolled back through the history: their scroll is left alone. */\nconst STICK_THRESHOLD = 80\n\nfunction Time({ at, locale }: { at: number; locale: Locale }): JSX.Element {\n const date = new Date(at)\n return (\n <time class=\"sqc-msg__time\" dateTime={date.toISOString()}>\n {date.toLocaleTimeString(locale.tag, { hour: '2-digit', minute: '2-digit' })}\n </time>\n )\n}\n\n/** Reads one file's bytes, as a URL this component owns and revokes. */\nexport type AttachmentLoader = (attachmentId: string) => Promise<Blob>\n\n/**\n * One attached picture, drawn once its bytes have arrived.\n *\n * Fetched rather than linked, because the route that serves it is opened by the\n * visitor token — which travels in a header, and a header is what an `<img src>`\n * cannot send. The object URL is revoked when the bubble goes: without that,\n * every picture of a long conversation stays in memory until the page does.\n *\n * A file that will not load draws as its name. The panel is a chat window, not\n * a file manager, and a broken image icon says less than the filename does.\n */\nfunction Picture({ file, load }: { file: ChatAttachment; load: AttachmentLoader }): JSX.Element {\n const [src, setSrc] = useState<string | null>(null)\n\n useEffect(() => {\n let url: string | null = null\n let alive = true\n void load(file.id)\n .then((blob) => {\n if (!alive) return\n url = URL.createObjectURL(blob)\n setSrc(url)\n })\n .catch(() => {\n // Drawn as its name below, which is what a file nobody can open is.\n })\n return () => {\n alive = false\n if (url) URL.revokeObjectURL(url)\n }\n }, [file.id, load])\n\n if (!src) return <span class=\"sqc-chip sqc-chip--waiting\">{file.filename}</span>\n return <img class=\"sqc-attachment__image\" src={src} alt={file.filename} />\n}\n\n/** The files one turn was sent with, under what was written. */\nfunction Attachments({\n files,\n load,\n}: {\n files: ChatAttachment[]\n load?: AttachmentLoader\n}): JSX.Element | null {\n if (files.length === 0 || !load) return null\n return (\n <div class=\"sqc-attachments sqc-attachments--sent\">\n {files.map((file) =>\n file.kind === 'image' ? (\n <Picture key={file.id} file={file} load={load} />\n ) : (\n <span key={file.id} class=\"sqc-chip\" data-kind=\"document\">\n <span class=\"sqc-chip__name\">{file.filename}</span>\n </span>\n ),\n )}\n </div>\n )\n}\n\nfunction Bubble({\n message,\n locale,\n assistantName,\n onChoice,\n onDecide,\n onLoadAttachment,\n}: {\n message: ChatMessage\n locale: Locale\n /** Name the assistant signs its messages with. */\n assistantName: string\n onChoice?: (label: string) => void\n onDecide?: (approved: boolean, label: string) => void\n onLoadAttachment?: AttachmentLoader\n}): JSX.Element {\n const pending = message.streaming && !message.content\n // A paused call carries its own buttons: the \"Do you confirm?\" of the recap\n // must not bring up a second pair.\n const awaiting = Boolean(message.approval)\n\n return (\n <div class={`sqc-msg sqc-msg--${message.role}${message.error ? ' sqc-msg--error' : ''}`}>\n {/* The design system does not put the agent's answer in a bubble: it is\n signed by this line, then set in serif flat on the panel background. */}\n {message.role === 'assistant' && (\n <div class=\"sqc-msg__who\">\n {/* Whoever answered, where an application holds several agents: the\n emoji and the handle are what tell them apart in a transcript, and\n a single-agent panel keeps signing with the name it was given. */}\n {message.agent?.avatarEmoji ? (\n <span class=\"sqc-msg__emoji\" aria-hidden=\"true\">\n {message.agent.avatarEmoji}\n </span>\n ) : (\n <ChatIcon />\n )}\n {message.authorName ?? message.agent?.name ?? assistantName}\n </div>\n )}\n <div class=\"sqc-msg__bubble\">\n {pending ? (\n <span class=\"sqc-typing\" aria-label={locale.t.typing}>\n <i />\n <i />\n <i />\n </span>\n ) : (\n <div class=\"sqc-msg__body\">\n <RichText text={message.content} locale={locale} onChoice={onChoice} />\n {message.streaming && <span class=\"sqc-caret\" aria-hidden=\"true\" />}\n {/* Wait for the stream to end: the closed question is the last\n line, and is only recognisable once written. */}\n {/* The call describes itself only where the agent did not: several\n models ask for a tool with nothing said, and two buttons under an\n empty bubble are a decision nobody can take. */}\n {awaiting && (\n <Approval\n locale={locale}\n call={message.content.trim() === '' ? message.approval : undefined}\n onDecide={onDecide}\n />\n )}\n {!awaiting &&\n !message.streaming &&\n !message.error &&\n isConfirmationPrompt(message.content, locale.code) && (\n <Confirm locale={locale} onPick={onChoice} />\n )}\n {message.unknownHandle && !message.streaming && (\n <Unaddressed message={message} locale={locale} />\n )}\n <Attachments files={message.attachments ?? []} load={onLoadAttachment} />\n </div>\n )}\n {!pending && <Time at={message.createdAt} locale={locale} />}\n </div>\n </div>\n )\n}\n\n/**\n * The note under an answer whose message addressed a name nobody answers to.\n *\n * Under the answer and not in place of it: the question *was* answered, by the\n * agent that answers plain text, so this adds who could have been asked instead. A\n * mistyped name deserves help rather than a refusal.\n *\n * With nothing offered it says only that nobody answers to that name — an\n * organization that ticked no handle has chosen not to publish its list, and\n * quoting it here would undo that.\n */\nfunction Unaddressed({\n message,\n locale,\n}: {\n message: ChatMessage\n locale: Locale\n}): JSX.Element {\n const offered = message.offered ?? []\n return (\n <p class=\"sqc-msg__unaddressed\">\n <span>{locale.t.handles.unknown}</span> <code>@{message.unknownHandle}</code>\n {offered.length > 0 && (\n <>\n {' '}\n <span>{locale.t.handles.instead}</span>{' '}\n {offered.map((handle) => (\n <code key={handle.handle}>@{handle.handle}</code>\n ))}\n </>\n )}\n </p>\n )\n}\n\n/** Lucide `message-circle`: the launcher, the panel title and every answer\n * coming from the assistant. */\nexport function ChatIcon(): JSX.Element {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <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\" />\n </svg>\n )\n}\n\nexport interface MessageListProps {\n messages: ChatMessage[]\n locale: Locale\n /** Name displayed above each answer. */\n assistantName: string\n suggestions?: string[]\n /** Suggestions are only shown on the first turn, as long as the user has\n * written nothing. */\n showSuggestions: boolean\n /** A turn is in flight: the last message's options are disabled. */\n busy?: boolean\n /** A human of the organization handles the conversation: said under the\n * transcript, since no agent will answer what comes next. */\n withHuman?: boolean\n onSuggestion: (text: string) => void\n /** Sends the label of a ticked option as the turn's answer. */\n onChoice: (label: string) => void\n /** Decides the tool call the last message put on hold. */\n onDecide: (approved: boolean, label: string) => void\n /** Reads the bytes of a file a turn carried. Absent where nothing can. */\n onLoadAttachment?: AttachmentLoader\n}\n\nexport function MessageList({\n messages,\n locale,\n assistantName,\n suggestions,\n showSuggestions,\n busy,\n withHuman,\n onSuggestion,\n onChoice,\n onDecide,\n onLoadAttachment,\n}: MessageListProps): JSX.Element {\n const scroller = useRef<HTMLDivElement | null>(null)\n const stick = useRef(true)\n\n // Measured before paint: at that point the DOM already carries the new\n // content, so the distance to the bottom only reflects the pre-render position\n // if it is updated on scroll — hence the handler below.\n useLayoutEffect(() => {\n const node = scroller.current\n if (node && stick.current) node.scrollTop = node.scrollHeight\n }, [messages])\n\n useEffect(() => {\n const node = scroller.current\n if (!node) return\n const onScroll = (): void => {\n stick.current = node.scrollHeight - node.scrollTop - node.clientHeight < STICK_THRESHOLD\n }\n node.addEventListener('scroll', onScroll, { passive: true })\n return () => node.removeEventListener('scroll', onScroll)\n }, [])\n\n return (\n <div class=\"sqc-messages\" ref={scroller} role=\"log\" aria-live=\"polite\" aria-atomic=\"false\">\n {messages.map((message, index) => (\n <Bubble\n key={message.id}\n message={message}\n locale={locale}\n assistantName={assistantName}\n // Only the last answer's options are live: those of earlier turns\n // have already been answered.\n onChoice={\n !busy && message.role === 'assistant' && index === messages.length - 1\n ? onChoice\n : undefined\n }\n onDecide={\n !busy && message.role === 'assistant' && index === messages.length - 1\n ? onDecide\n : undefined\n }\n onLoadAttachment={onLoadAttachment}\n />\n ))}\n\n {withHuman && (\n <p class=\"sqc-with-human\" role=\"status\">\n {locale.t.withHuman}\n </p>\n )}\n\n {showSuggestions && suggestions && suggestions.length > 0 && (\n <div class=\"sqc-suggestions\">\n {suggestions.map((suggestion) => (\n <button\n key={suggestion}\n type=\"button\"\n class=\"sqc-suggestion\"\n onClick={() => onSuggestion(suggestion)}\n >\n {suggestion}\n </button>\n ))}\n </div>\n )}\n </div>\n )\n}\n","import type { JSX } from 'preact'\nimport { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'preact/hooks'\nimport { contextLabel, isNamedObject } from '../lib/context'\nimport { resolveLocale, type Locale } from '../lib/i18n'\nimport { initialOpen, writeOpenState } from '../lib/openState'\nimport { useChat } from '../lib/useChat'\nimport type { ChatbotContext, ChatbotEvent, ChatbotOptions } from '../types'\nimport { Composer } from './Composer'\nimport { ChatIcon, MessageList } from './MessageList'\n\n// Sidebar width of the design system. No accent here: left unset, the\n// stylesheet picks it — black, or white in the dark theme — and a page's own\n// `--sqc-accent` on the element is not overwritten by a default.\nconst DEFAULTS = {\n width: 'min(392px, 100vw)',\n} as const\n\n/** Imperative surface exposed to the wrapper (custom element / React). */\nexport interface ChatbotControls {\n open(): void\n close(): void\n toggle(): void\n reset(): void\n send(text: string): void\n isOpen(): boolean\n sessionId(): string\n}\n\nexport interface ChatbotWidgetProps extends ChatbotOptions {\n onEvent?: (event: ChatbotEvent) => void\n /** Receives the imperative API on mount, `null` on unmount. */\n bind?: (controls: ChatbotControls | null) => void\n}\n\n/** Keys the widget owns: they name the conversation, not the host's page, so\n * they never become a chip. */\nconst HIDDEN_CONTEXT_KEYS = new Set<string>(['sessionId'])\n\n/** Turns a context key into a chip title: `orderId` and `order` both read\n * \"Order\", `deliveryDate` reads \"Delivery date\". The host names its own\n * entities — the widget knows no domain and only makes the key readable. */\nfunction chipLabel(key: string): string {\n const words = key\n .replace(/Id$|Ref$/, '')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/[_-]+/g, ' ')\n .trim()\n .toLowerCase()\n if (!words) return key\n return words.charAt(0).toUpperCase() + words.slice(1)\n}\n\n/**\n * Chips to display: one per context entry carrying a usable value.\n *\n * The value shown is the name when the host provided one\n * (`order: { id, name }`), the id otherwise — a UUID means nothing to the user,\n * but it is all there is when only the id was passed. Anything that is neither a\n * non-empty string nor a `{ id, … }` object is skipped: a chip claims something\n * is selected.\n */\nfunction contextChips(context: ChatbotContext | undefined): { label: string; value: string }[] {\n if (!context) return []\n const chips: { label: string; value: string }[] = []\n for (const [key, entry] of Object.entries(context)) {\n if (HIDDEN_CONTEXT_KEYS.has(key)) continue\n if (typeof entry !== 'string' && !isNamedObject(entry)) continue\n const value = contextLabel(entry)\n if (value) chips.push({ label: chipLabel(key), value })\n }\n return chips\n}\n\n/** An empty label replaces nothing: `heading=\"\"`, or a settings field cleared\n * by the host, hands it back to the translation instead of showing a blank\n * header. */\nfunction override(value: string | undefined, fallback: string): string {\n return value?.trim() ? value : fallback\n}\n\n/** Resolves `theme: 'auto'` to light/dark and follows the system changes. */\nfunction useResolvedTheme(theme: ChatbotOptions['theme']): 'light' | 'dark' {\n const [systemDark, setSystemDark] = useState(false)\n\n useEffect(() => {\n if (theme !== 'auto' || typeof matchMedia !== 'function') return\n const query = matchMedia('(prefers-color-scheme: dark)')\n setSystemDark(query.matches)\n const onChange = (event: MediaQueryListEvent): void => setSystemDark(event.matches)\n query.addEventListener('change', onChange)\n return () => query.removeEventListener('change', onChange)\n }, [theme])\n\n if (theme === 'dark') return 'dark'\n if (theme === 'light') return 'light'\n return systemDark ? 'dark' : 'light'\n}\n\nexport function ChatbotWidget(props: ChatbotWidgetProps): JSX.Element {\n const persistOpen = props.persistOpen ?? true\n const [open, setOpen] = useState(() => initialOpen(props.defaultOpen, persistOpen))\n const [interacted, setInteracted] = useState(false)\n const [unread, setUnread] = useState(false)\n const panel = useRef<HTMLDivElement | null>(null)\n const launcher = useRef<HTMLButtonElement | null>(null)\n\n const theme = useResolvedTheme(props.theme ?? 'light')\n // All the widget's copy comes from here: the language is the one the host\n // declares, and the labels it provides itself (`heading`, `greeting`…) win\n // over the translation.\n const locale: Locale = useMemo(() => resolveLocale(props.locale), [props.locale])\n const t = locale.t\n const heading = override(props.heading, t.heading)\n const assistantName = override(props.assistantName, t.assistant)\n const greeting = override(props.greeting, t.greeting)\n\n const onEvent = props.onEvent\n const chat = useChat({\n embedKey: props.embedKey,\n user: props.user,\n getSubjectToken: props.getSubjectToken,\n agent: props.agent,\n context: props.context,\n greeting,\n locale,\n onEvent,\n })\n\n const {\n send: sendChat,\n reset: resetChat,\n decide,\n stop,\n start,\n busy,\n messages,\n withHuman,\n branding,\n sessionId,\n handles,\n addressee,\n attachments,\n uploading,\n attachmentError,\n attach,\n detach,\n loadAttachment,\n } = chat\n\n // A message received while the sidebar is closed lights the badge on the\n // floating button: it is the only notification channel when the panel is\n // hidden (the case of a `sendMessage()` triggered by the host page).\n useEffect(() => {\n if (!open && messages.some((message) => message.role === 'assistant' && message.id !== 'greeting')) {\n setUnread(true)\n }\n }, [messages, open])\n\n // Synchronous mirror of `open`: `openPanel`/`closePanel` have to know whether\n // they really change the state, so the event is emitted once, without slipping\n // a side effect into the `setOpen` updater.\n const isOpen = useRef(open)\n isOpen.current = open\n\n const openPanel = useCallback(() => {\n setUnread(false)\n if (isOpen.current) return\n isOpen.current = true\n setOpen(true)\n if (persistOpen) writeOpenState(true)\n onEvent?.({ type: 'chatbot-open', sessionId })\n }, [onEvent, persistOpen, sessionId])\n\n const closePanel = useCallback(() => {\n if (!isOpen.current) return\n isOpen.current = false\n setOpen(false)\n if (persistOpen) writeOpenState(false)\n onEvent?.({ type: 'chatbot-close', sessionId })\n // Hand the focus back to the floating button: without it the focus falls\n // back to the host page's `<body>` and keyboard navigation starts over.\n launcher.current?.focus()\n }, [onEvent, persistOpen, sessionId])\n\n // The conversation is opened when the panel is first shown, not on mount: a\n // panel nobody opened is a conversation nobody had — and no visitor token\n // handed to a page that never asked for one. Idempotent, so re-opening the\n // panel does not start a second one.\n useEffect(() => {\n if (open) start()\n }, [open, start])\n\n const send = useCallback(\n (text: string) => {\n setInteracted(true)\n sendChat(text)\n },\n [sendChat],\n )\n\n const reset = useCallback(() => {\n setInteracted(false)\n setUnread(false)\n resetChat()\n }, [resetChat])\n\n // The object exposed to the host has to be stable (a React `ref` must not\n // change identity on every render): it delegates to the fresh closures stored\n // in `handlers`.\n const handlers = useRef({ openPanel, closePanel, send, reset, sessionId })\n handlers.current = { openPanel, closePanel, send, reset, sessionId }\n\n const controls = useRef<ChatbotControls>({\n open: () => handlers.current.openPanel(),\n close: () => handlers.current.closePanel(),\n // `isOpen` (the synchronous mirror) rather than the render value: the host\n // has to be able to read `chatbot.open` right after `openChat()`, before the\n // next render.\n toggle: () => (isOpen.current ? handlers.current.closePanel() : handlers.current.openPanel()),\n reset: () => handlers.current.reset(),\n send: (text: string) => {\n handlers.current.openPanel()\n handlers.current.send(text)\n },\n isOpen: () => isOpen.current,\n sessionId: () => handlers.current.sessionId,\n })\n\n const bind = props.bind\n // `useLayoutEffect` rather than `useEffect`: plain Preact effects are deferred\n // until after paint, whereas the wrapper has to be able to call\n // `sendMessage()` as soon as `connectedCallback()` returns.\n useLayoutEffect(() => {\n bind?.(controls.current)\n return () => bind?.(null)\n }, [bind])\n\n // Escape closes the panel. The listener sits on `document`: shadow DOM\n // keyboard events bubble up to it, and it also covers the case where the focus\n // stayed in the host page.\n useEffect(() => {\n if (!open) return\n const onKeyDown = (event: KeyboardEvent): void => {\n if (event.key === 'Escape') {\n event.stopPropagation()\n closePanel()\n }\n }\n document.addEventListener('keydown', onKeyDown)\n return () => document.removeEventListener('keydown', onKeyDown)\n }, [closePanel, open])\n\n // A conversation is already there. The suggestions have no place under it:\n // they open a conversation, they do not continue one.\n const hasConversation = useMemo(\n () => messages.some((message) => message.id !== 'greeting'),\n [messages],\n )\n\n const chips = useMemo(() => contextChips(props.context), [props.context])\n const rootStyle = {\n ...(props.accent ? { '--sqc-accent': props.accent } : {}),\n '--sqc-width': props.width ?? DEFAULTS.width,\n } as JSX.CSSProperties\n\n return (\n <div\n class=\"sqc\"\n data-theme={theme}\n data-position={props.position ?? 'bottom-right'}\n data-layout={props.layout ?? 'sidebar'}\n data-open={open ? 'true' : 'false'}\n style={rootStyle}\n >\n <button\n ref={launcher}\n type=\"button\"\n class=\"sqc-launcher\"\n aria-label={heading}\n aria-expanded={open}\n aria-haspopup=\"dialog\"\n onClick={openPanel}\n >\n <span class=\"sqc-launcher__icon\">\n {/* The icon can be replaced by an element of the host page:\n `<squadico-chatbot><svg slot=\"launcher-icon\" /></…>`, or the\n `launcherIcon` prop of the React wrapper. A slot, not an option:\n the widget renders inside a shadow root, where a host component\n cannot be mounted — projected through a slot it stays in its own\n tree, with its own CSS, and inherits the button colour here through\n `currentColor`. The content below is the slot fallback, hence the\n default icon. */}\n <slot name=\"launcher-icon\" class=\"sqc-slot-icon\">\n <ChatIcon />\n </slot>\n </span>\n {unread && <span class=\"sqc-launcher__badge\" aria-hidden=\"true\" />}\n </button>\n\n <aside\n ref={panel}\n class=\"sqc-panel\"\n role=\"dialog\"\n aria-modal=\"false\"\n aria-label={heading}\n // `inert` removes the whole subtree from focus and accessibility when\n // the panel is slid off screen — otherwise tabbing would land in an\n // invisible panel.\n {...(open ? {} : { inert: true })}\n >\n <header class=\"sqc-header\">\n <span class=\"sqc-header__icon\" aria-hidden=\"true\">\n <ChatIcon />\n </span>\n <div class=\"sqc-header__titles\">\n <p class=\"sqc-header__heading\">{heading}</p>\n <p class=\"sqc-header__sub\">{override(props.subheading, t.subheading)}</p>\n </div>\n <button\n type=\"button\"\n class=\"sqc-icon-btn\"\n onClick={reset}\n aria-label={t.newConversation}\n data-tip={t.newConversation}\n >\n <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\">\n <path d=\"M20 12a8 8 0 1 1-2.6-5.9M20 4v4h-4\" stroke-linecap=\"round\" />\n </svg>\n </button>\n <button\n type=\"button\"\n class=\"sqc-icon-btn\"\n onClick={closePanel}\n aria-label={t.close}\n data-tip={t.closeTitle}\n >\n <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\">\n <path d=\"M6 6l12 12M18 6L6 18\" stroke-linecap=\"round\" />\n </svg>\n </button>\n </header>\n\n {chips.length > 0 && (\n <div class=\"sqc-context\" aria-label={t.context.region}>\n {chips.map((chip) => (\n <span key={chip.label} class=\"sqc-chip\" title={`${chip.label}: ${chip.value}`}>\n <b>{chip.label}</b>\n {chip.value}\n </span>\n ))}\n </div>\n )}\n\n <MessageList\n messages={messages}\n locale={locale}\n assistantName={assistantName}\n suggestions={props.suggestions}\n showSuggestions={!interacted && !hasConversation}\n busy={busy}\n withHuman={withHuman}\n onSuggestion={send}\n onChoice={send}\n onDecide={decide}\n onLoadAttachment={loadAttachment}\n />\n\n <Composer\n placeholder={override(props.placeholder, t.placeholder)}\n locale={locale}\n busy={busy}\n autoFocus={open}\n handles={handles}\n addressee={addressee}\n attachments={attachments}\n uploading={uploading}\n // Translated here rather than in the hook: the hook knows why an upload\n // was refused, and this is where the panel's language lives.\n attachmentError={attachmentError ? t.attachments[attachmentError] : undefined}\n onAttach={attach}\n onDetach={detach}\n onSend={send}\n onStop={stop}\n />\n\n <p class=\"sqc-hint\">{t.hint}</p>\n {branding && (\n <p class=\"sqc-powered\">\n <a href=\"https://squadico.com\" target=\"_blank\" rel=\"noopener noreferrer\">\n {t.poweredBy}\n </a>\n </p>\n )}\n </aside>\n </div>\n )\n}\n","/*\n * Stylesheet of the widget — injected into the shadow root (constructable\n * stylesheet where supported, `<style>` otherwise). It never leaks into the host\n * page, and the host page cannot override it: the only entry points for an\n * integrator are the `--sqc-*` variables, set on the custom element.\n *\n * `:host` uses `position: fixed; inset: 0; pointer-events: none`: a single\n * element depends on fixed positioning (hence a single breaking point should an\n * ancestor carry a `transform`), and the page stays entirely clickable through\n * the overlay.\n *\n * ── Design system ────────────────────────────────────────────\n * The Squadico design system (v2): near-monochrome. Action is black (hover\n * slate-800), everything around it is slate — white surfaces, slate-200 rules,\n * slate-900 text, slate-500 for what is secondary — and links are blue-600. One\n * sans-serif family, Plus Jakarta Sans. Radii follow its hierarchy: 16px for\n * what holds content (the bubbles), 12px for what is pressed or typed into,\n * 8px for utility icon buttons, full for badges and the launcher. The values\n * are hard-copied here under internal `--sqc-*` names: the widget is a\n * standalone npm package and cannot depend on the host application's CSS\n * variables (they do not exist inside the shadow root of the other\n * integrations).\n *\n * The accent is black by default and the page's to change (`accent`, or\n * `--sqc-accent` on the element). Left unset, the stylesheet decides, which is\n * what lets the dark theme — a derivation on the slate scale, kept because\n * `theme: 'dark' | 'auto'` is part of the public contract — turn it white. The\n * text drawn on it is worked out from its lightness where the browser can.\n *\n * The typeface is referenced, never downloaded: the widget issues no font\n * request. If the host loads it, `font-family` resolution crosses the shadow\n * root and the widget benefits; otherwise the system fallbacks apply.\n */\n\n:host {\n /* ── Public extension points ────────────────────────────── */\n /* `--sqc-accent` is one too, deliberately left unset here: see `.sqc`. */\n --sqc-width: min(392px, 100vw);\n /* Height of the floating window (`layout=\"floating\"`), never taller than\n the space it opens in; the sidebar always takes the full height. */\n --sqc-height: 640px;\n --sqc-z: 2147483000;\n --sqc-radius: 16px;\n --sqc-font-family:\n 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica,\n Arial, sans-serif;\n --sqc-font-heading: var(--sqc-font-family);\n\n position: fixed;\n inset: 0;\n /* Fixed over the whole viewport, so a margin the page's layout gives its\n children — a `space-y-*` column — would shorten the sidebar by as much and\n leave a strip under it. A page's rules beat `:host` except against\n `!important`, which is why this one carries it. */\n margin: 0 !important;\n z-index: var(--sqc-z);\n display: block;\n pointer-events: none;\n font-family: var(--sqc-font-family);\n font-size: 14px;\n line-height: 1.5;\n /* Isolates the type from the host page: without it a `font-size: 62.5%` on\n `html` would render the whole widget at 8.75px. */\n -webkit-font-smoothing: antialiased;\n text-align: left;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.sqc {\n /* Raw design system scale (light): Tailwind's slate. */\n --sqc-neutral-50: #f8fafc;\n --sqc-neutral-100: #f1f5f9;\n --sqc-neutral-200: #e2e8f0;\n --sqc-neutral-300: #cbd5e1;\n --sqc-neutral-400: #94a3b8;\n --sqc-neutral-500: #64748b;\n --sqc-neutral-600: #475569;\n --sqc-neutral-900: #0f172a;\n --sqc-error-50: #fff1f2;\n --sqc-error-100: #ffe4e6;\n --sqc-error-600: #e11d48;\n\n /* Accent: the page's when it set one, black otherwise. */\n --sqc-accent-default: #000000;\n --sqc-accent-color: var(--sqc-accent, var(--sqc-accent-default));\n /* Text on the accent. White on the default black; the `@supports` below works\n it out for any other accent. */\n --sqc-on-accent: #ffffff;\n /* Hover of a filled button: the DS's black → slate-800, as a mix so that it\n holds for an accent the page chose. */\n --sqc-accent-hover: color-mix(in oklab, var(--sqc-accent-color) 84%, var(--sqc-on-accent));\n /* Accent used as a text colour (icons beside a title): the page's accent when\n it set one, the text colour otherwise. */\n --sqc-accent-fg: var(--sqc-accent, var(--sqc-text));\n\n /* Roles. */\n --sqc-bg: #ffffff; /* bg-white */\n --sqc-surface: var(--sqc-neutral-50); /* hover:bg-slate-50 */\n --sqc-selected: var(--sqc-neutral-100); /* active item: bg-slate-100 */\n --sqc-border: var(--sqc-neutral-200);\n --sqc-border-strong: var(--sqc-neutral-300); /* inputs, hovered outlines */\n --sqc-text: var(--sqc-neutral-900);\n --sqc-text-muted: var(--sqc-neutral-500);\n --sqc-link: #2563eb; /* blue-600 */\n --sqc-bubble-user: var(--sqc-accent-color);\n --sqc-bubble-user-text: var(--sqc-on-accent);\n --sqc-code-bg: var(--sqc-neutral-100);\n --sqc-disabled: var(--sqc-neutral-300); /* bg-slate-300 text-white */\n --sqc-shadow:\n 0 10px 15px -3px rgb(15 23 42 / 10%), 0 4px 6px -4px rgb(15 23 42 / 10%); /* shadow-lg */\n /* Bottom-only shadow (no halo around): the history menu, which spans the\n whole sidebar width rather than floating as a card. */\n --sqc-shadow-bottom: 0 6px 8px -6px rgb(15 23 42 / 18%);\n /* Neutral focus, never coloured: a ring for what is pressed, the DS's\n `focus:border-slate-900 focus:ring-slate-900/10` for what is typed into. */\n --sqc-focus: 0 0 0 2px var(--sqc-bg), 0 0 0 4px rgb(15 23 42 / 30%);\n --sqc-focus-input: 0 0 0 3px rgb(15 23 42 / 10%);\n --sqc-danger: var(--sqc-error-600);\n\n position: absolute;\n inset: 0;\n color: var(--sqc-text);\n}\n\n.sqc[data-theme='dark'] {\n --sqc-neutral-50: #172033;\n --sqc-neutral-100: #1e293b;\n --sqc-neutral-200: #334155;\n --sqc-neutral-300: #475569;\n --sqc-neutral-400: #64748b;\n --sqc-neutral-500: #94a3b8;\n --sqc-neutral-600: #cbd5e1;\n --sqc-neutral-900: #f8fafc;\n --sqc-error-50: #2a0a12;\n --sqc-error-100: #4c0519;\n --sqc-error-600: #fb7185;\n\n --sqc-accent-default: #ffffff;\n --sqc-on-accent: #0f172a;\n\n --sqc-bg: #0f172a; /* slate-900, the app's dark card */\n --sqc-link: #60a5fa;\n --sqc-code-bg: #020617;\n --sqc-shadow: 0 10px 24px -4px rgb(0 0 0 / 55%);\n --sqc-shadow-bottom: 0 6px 8px -6px rgb(0 0 0 / 55%);\n --sqc-focus: 0 0 0 2px var(--sqc-bg), 0 0 0 4px rgb(248 250 252 / 35%);\n --sqc-focus-input: 0 0 0 3px rgb(248 250 252 / 12%);\n}\n\n/* Text on an accent the page chose: white on a dark one, slate-900 on a light\n one, decided by its lightness. Where relative colours are not supported, the\n theme's default above stands. */\n@supports (color: oklch(from red l c h)) {\n .sqc {\n --sqc-on-accent: oklch(from var(--sqc-accent-color) clamp(0.208, (0.62 - l) * 1000, 1) 0 0);\n }\n}\n\n.sqc *,\n.sqc *::before,\n.sqc *::after {\n box-sizing: border-box;\n}\n\n/* ── Bouton flottant ──────────────────────────────────────── */\n\n.sqc-launcher {\n position: absolute;\n bottom: 24px;\n right: 24px;\n width: 56px;\n height: 56px;\n padding: 0;\n border: none;\n border-radius: 50%;\n background: var(--sqc-accent-color);\n color: var(--sqc-on-accent);\n cursor: pointer;\n pointer-events: auto;\n display: grid;\n place-items: center;\n box-shadow: var(--sqc-shadow);\n transition:\n transform 0.18s ease,\n opacity 0.18s ease,\n background 0.18s ease,\n box-shadow 0.18s ease;\n}\n\n.sqc[data-position='bottom-left'] .sqc-launcher {\n right: auto;\n left: 24px;\n}\n\n.sqc-launcher:hover {\n transform: scale(1.06);\n background: var(--sqc-accent-hover);\n}\n\n.sqc-launcher:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n/* Panel open: the button fades out, closing happens through the header. */\n.sqc[data-open='true'] .sqc-launcher {\n opacity: 0;\n transform: scale(0.5);\n pointer-events: none;\n}\n\n.sqc-launcher__icon svg {\n width: 26px;\n height: 26px;\n display: block;\n}\n\n/* Icon provided by the host (`slot=\"launcher-icon\"`): same frame as the default\n one. `::slotted()` can only target the projected node itself, never its\n descendants — a host wrapping its icon therefore has to size it on its own\n side, hence the centring here rather than a plain `display: block`. */\n.sqc-slot-icon::slotted(*) {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 26px;\n height: 26px;\n}\n\n.sqc-launcher__badge {\n position: absolute;\n top: 6px;\n right: 6px;\n width: 12px;\n height: 12px;\n border-radius: 50%;\n background: var(--sqc-error-600);\n border: 2px solid var(--sqc-bg);\n}\n\n/* ── Sidebar ──────────────────────────────────────────────── */\n\n.sqc-panel {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n width: var(--sqc-width);\n display: flex;\n flex-direction: column;\n background: var(--sqc-bg);\n border-left: 1px solid var(--sqc-border);\n box-shadow: var(--sqc-shadow);\n pointer-events: auto;\n transform: translateX(100%);\n /* `visibility` is delayed so it only hides at the end of the slide, and\n applied immediately on opening. */\n visibility: hidden;\n transition:\n transform 0.26s cubic-bezier(0.22, 1, 0.36, 1),\n visibility 0s linear 0.26s;\n}\n\n.sqc[data-open='true'] .sqc-panel {\n transform: translateX(0);\n visibility: visible;\n transition:\n transform 0.26s cubic-bezier(0.22, 1, 0.36, 1),\n visibility 0s;\n}\n\n/* ── Floating window ──────────────────────────────────────── */\n\n/* `layout=\"floating\"`: the same panel, lifted off the edge into a rounded\n window that grows out of the launcher's corner. */\n.sqc[data-layout='floating'] .sqc-panel {\n top: auto;\n bottom: 24px;\n right: 24px;\n /* Percentages of the host, which covers the viewport: on a page they are\n the viewport's, in a transformed frame (a preview) the frame's. */\n max-width: calc(100% - 48px);\n height: var(--sqc-height);\n max-height: calc(100% - 48px);\n border: 1px solid var(--sqc-border);\n border-radius: var(--sqc-radius);\n overflow: hidden;\n opacity: 0;\n transform: translateY(16px) scale(0.96);\n transform-origin: bottom right;\n transition:\n transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),\n opacity 0.22s ease,\n visibility 0s linear 0.22s;\n}\n\n.sqc[data-layout='floating'][data-position='bottom-left'] .sqc-panel {\n right: auto;\n left: 24px;\n transform-origin: bottom left;\n}\n\n.sqc[data-layout='floating'][data-open='true'] .sqc-panel {\n opacity: 1;\n transform: none;\n transition:\n transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),\n opacity 0.22s ease,\n visibility 0s;\n}\n\n/* ── Header ───────────────────────────────────────────────── */\n\n/* DS card header: white, bottom rule, bold slate-900 title — no coloured band. */\n.sqc-header {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 13px 12px 13px 16px;\n background: var(--sqc-bg);\n color: var(--sqc-text);\n border-bottom: 1px solid var(--sqc-border);\n flex-shrink: 0;\n}\n\n.sqc-header__icon {\n display: grid;\n place-items: center;\n flex-shrink: 0;\n color: var(--sqc-accent-fg);\n}\n\n.sqc-header__icon svg {\n width: 17px;\n height: 17px;\n display: block;\n}\n\n.sqc-header__titles {\n flex: 1;\n min-width: 0;\n}\n\n.sqc-header__heading,\n.sqc-header__sub {\n margin: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.sqc-header__heading {\n font-family: var(--sqc-font-heading);\n font-size: 15px;\n font-weight: 700;\n letter-spacing: -0.2px;\n}\n\n.sqc-header__sub {\n font-size: 12px;\n color: var(--sqc-text-muted);\n}\n\n.sqc-icon-btn {\n width: 26px;\n height: 26px;\n border: none;\n border-radius: 8px;\n background: none;\n color: var(--sqc-text-muted);\n cursor: pointer;\n display: grid;\n place-items: center;\n flex-shrink: 0;\n transition: background 0.15s ease;\n}\n\n.sqc-icon-btn:hover {\n background: var(--sqc-surface);\n color: var(--sqc-text);\n}\n\n.sqc-icon-btn:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n.sqc-icon-btn svg {\n width: 16px;\n height: 16px;\n}\n\n/* Tooltip of the header icons, in place of the native `title`: that one takes a\n second to appear, is drawn with the system font and theme — outside the shadow\n root, hence out of the panel's reach — and never shows on keyboard focus. The\n label is still carried by `aria-label`: the `::after` is decorative, and an\n assistive technology does not read the same text twice. */\n.sqc-icon-btn[data-tip] {\n position: relative;\n}\n\n.sqc-icon-btn[data-tip]::after {\n content: attr(data-tip);\n position: absolute;\n top: calc(100% + 6px);\n /* Anchored to the right of the button: the three icons sit against the right\n edge of the panel, and a centred bubble would overflow it. */\n right: 0;\n z-index: 6;\n padding: 4px 8px;\n border-radius: 8px;\n /* Inverts the panel colours: dark on light, light on dark, with no extra\n variable to expose. */\n background: var(--sqc-text);\n color: var(--sqc-bg);\n font-family: var(--sqc-font-family);\n font-size: 11px;\n font-weight: 500;\n line-height: 1.3;\n white-space: nowrap;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.12s ease 0.15s;\n}\n\n.sqc-icon-btn[data-tip]:hover::after,\n.sqc-icon-btn[data-tip]:focus-visible::after {\n opacity: 1;\n}\n\n/* ── Conversation history ─────────────────────────────────── */\n\n/* Full sidebar width, not a floating card: only a bottom shadow\n (`--sqc-shadow-bottom`) separates it from what sits below, with no border\n and no shadow all around. */\n.sqc-history-pop {\n position: absolute;\n left: 0;\n right: 0;\n top: 54px;\n z-index: 5;\n}\n\n.sqc-history {\n display: flex;\n flex-direction: column;\n max-height: 320px;\n overflow-y: auto;\n background: var(--sqc-bg);\n box-shadow: var(--sqc-shadow-bottom);\n}\n\n.sqc-history__empty {\n margin: 0;\n padding: 14px 16px;\n font-size: 12px;\n color: var(--sqc-text-muted);\n text-align: center;\n}\n\n.sqc-history__item {\n display: flex;\n flex-direction: column;\n gap: 2px;\n width: 100%;\n padding: 10px 16px;\n border: none;\n border-bottom: 1px solid var(--sqc-border);\n background: none;\n color: var(--sqc-text);\n text-align: left;\n cursor: pointer;\n transition: background 0.15s ease;\n}\n\n.sqc-history__item:last-child {\n border-bottom: none;\n}\n\n.sqc-history__item:hover {\n background: var(--sqc-surface);\n}\n\n.sqc-history__item:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n.sqc-history__item[aria-current='true'] {\n background: var(--sqc-selected);\n}\n\n.sqc-history__item[aria-current='true'] .sqc-history__title {\n color: var(--sqc-text);\n font-weight: 600;\n}\n\n.sqc-history__title {\n font-size: 13px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.sqc-history__date {\n font-size: 11px;\n color: var(--sqc-text-muted);\n}\n\n/* ── Bandeau de contexte ──────────────────────────────────── */\n\n/* A single reminder line, as a neutral slate-100 box. */\n.sqc-context {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n margin: 12px 16px 4px;\n padding: 8px 11px;\n background: var(--sqc-selected);\n border: 1px solid var(--sqc-border);\n border-radius: 12px;\n font-size: 12px;\n color: var(--sqc-text);\n flex-shrink: 0;\n}\n\n.sqc-chip {\n display: inline-flex;\n align-items: baseline;\n gap: 4px;\n max-width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.sqc-chip b {\n font-weight: 600;\n}\n\n/* Separator between two context chips, with no dedicated DOM node. */\n.sqc-chip:not(:last-child)::after {\n content: '·';\n margin-left: 4px;\n opacity: 0.5;\n}\n\n/* ── Fil de conversation ──────────────────────────────────── */\n\n.sqc-messages {\n flex: 1;\n min-height: 0;\n overflow-y: auto;\n overscroll-behavior: contain;\n padding: 12px 16px;\n display: flex;\n flex-direction: column;\n gap: 13px;\n background: var(--sqc-bg);\n scrollbar-width: thin;\n scrollbar-color: var(--sqc-neutral-300) transparent;\n}\n\n.sqc-messages::-webkit-scrollbar {\n width: 6px;\n}\n\n.sqc-messages::-webkit-scrollbar-thumb {\n background: var(--sqc-neutral-300);\n border-radius: 99px;\n}\n\n.sqc-msg {\n display: flex;\n flex-direction: column;\n max-width: 93%;\n font-size: 13.5px;\n}\n\n/* The agent's answer is not a bubble: it is signed by an \"Assistant\" line and\n set flat on the panel background, in the body typeface. */\n.sqc-msg--assistant {\n align-self: flex-start;\n}\n\n.sqc-msg--user {\n align-self: flex-end;\n}\n\n.sqc-msg__who {\n display: flex;\n align-items: center;\n gap: 6px;\n margin-bottom: 4px;\n font-size: 11px;\n font-weight: 500;\n color: var(--sqc-text-muted);\n}\n\n.sqc-msg__who svg {\n width: 12px;\n height: 12px;\n flex-shrink: 0;\n color: var(--sqc-accent-fg);\n}\n\n/* The note under an answer whose message addressed a name nobody answers to. Set\n quietly: the answer above it is what was asked for, and this only says who else\n could have been asked. */\n.sqc-msg__unaddressed {\n margin: 8px 0 0;\n font-size: 11.5px;\n line-height: 1.5;\n color: var(--sqc-text-muted);\n}\n\n.sqc-msg__unaddressed code {\n margin-right: 4px;\n padding: 1px 4px;\n border-radius: 4px;\n background: var(--sqc-code-bg);\n font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font-size: 11px;\n color: var(--sqc-text);\n}\n\n.sqc-msg--user .sqc-msg__bubble {\n padding: 9px 13px;\n background: var(--sqc-bubble-user);\n color: var(--sqc-bubble-user-text);\n border-radius: var(--sqc-radius) var(--sqc-radius) 4px var(--sqc-radius);\n}\n\n.sqc-msg--error .sqc-msg__bubble {\n padding: 11px;\n background: var(--sqc-error-50);\n color: var(--sqc-error-600);\n border: 1px solid var(--sqc-error-100);\n border-radius: 12px;\n}\n\n.sqc-msg__body {\n overflow-wrap: anywhere;\n}\n\n.sqc-msg--assistant .sqc-msg__body {\n font-size: 14px;\n line-height: 1.6;\n}\n\n.sqc-msg__body > *:first-child {\n margin-top: 0;\n}\n\n.sqc-msg__body > *:last-child {\n margin-bottom: 0;\n}\n\n.sqc-msg__body p {\n margin: 0 0 8px;\n white-space: pre-wrap;\n}\n\n.sqc-msg__body ul,\n.sqc-msg__body ol {\n margin: 0 0 8px;\n padding-left: 20px;\n}\n\n.sqc-msg__body li {\n margin-bottom: 3px;\n}\n\n.sqc-msg__body code {\n font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font-size: 0.85em;\n padding: 1px 4px;\n border-radius: 4px;\n background: var(--sqc-code-bg);\n}\n\n.sqc-msg--user .sqc-msg__body code {\n background: rgb(255 255 255 / 22%);\n}\n\n.sqc-msg__body pre {\n margin: 0 0 8px;\n padding: 9px 11px;\n border-radius: 8px;\n background: var(--sqc-code-bg);\n overflow-x: auto;\n}\n\n.sqc-msg__body pre code {\n padding: 0;\n background: none;\n}\n\n.sqc-msg__body a {\n color: inherit;\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n\n/* DS text link: blue-600, underlined on hover. Only in answers: on the accent of\n a bubble, blue would not read. */\n.sqc-msg--assistant .sqc-msg__body a {\n color: var(--sqc-link);\n text-decoration: none;\n}\n\n.sqc-msg--assistant .sqc-msg__body a:hover {\n text-decoration: underline;\n}\n\n/* Headings: ranked by weight and slightly by size — in a 13.5-14px thread, a\n typographic h1 would be grotesque. */\n.sqc-msg__body h3,\n.sqc-msg__body h4,\n.sqc-msg__body h5,\n.sqc-msg__body h6 {\n margin: 12px 0 6px;\n font-family: var(--sqc-font-heading);\n font-weight: 700;\n line-height: 1.3;\n letter-spacing: -0.2px;\n}\n\n.sqc-msg__body h3 {\n font-size: 1.05em;\n}\n\n.sqc-msg__body h4 {\n font-size: 1em;\n}\n\n.sqc-msg__body h5,\n.sqc-msg__body h6 {\n font-size: 0.94em;\n}\n\n.sqc-msg__body ul ul,\n.sqc-msg__body ul ol,\n.sqc-msg__body ol ul,\n.sqc-msg__body ol ol {\n margin: 3px 0 0;\n}\n\n.sqc-msg__body blockquote {\n margin: 0 0 8px;\n padding: 2px 0 2px 10px;\n border-left: 2px solid var(--sqc-border-strong);\n color: var(--sqc-text-muted);\n white-space: pre-wrap;\n}\n\n.sqc-msg--user .sqc-msg__body blockquote {\n border-left-color: rgb(255 255 255 / 45%);\n color: inherit;\n opacity: 0.85;\n}\n\n.sqc-msg__body hr {\n margin: 10px 0;\n border: 0;\n border-top: 1px solid var(--sqc-border);\n}\n\n.sqc-msg--user .sqc-msg__body hr {\n border-top-color: rgb(255 255 255 / 30%);\n}\n\n.sqc-msg__body del {\n opacity: 0.7;\n}\n\n/* Decision on a pending write: the agent showed the payload and stopped there.\n Reuses the `.sqc-confirm` buttons, with a third path opening a correction\n input. */\n.sqc-approval {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin: 11px 0 2px;\n}\n\n.sqc-approval__actions {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n}\n\n/* What the agent would do, said in its place when it said nothing itself. */\n.sqc-approval__request {\n margin: 0;\n font-size: 13px;\n color: var(--sqc-text);\n}\n\n/* The values it would be called with: a name and a value per line, the value\n free to wrap — an id or a URL is what several of them are. */\n.sqc-approval__args {\n display: flex;\n flex-direction: column;\n gap: 4px;\n margin: 0;\n padding: 8px 10px;\n border: 1px solid var(--sqc-border);\n border-radius: 12px;\n background: var(--sqc-surface);\n font-size: 12px;\n}\n\n.sqc-approval__arg {\n display: flex;\n gap: 8px;\n}\n\n.sqc-approval__arg-name {\n flex: 0 0 auto;\n font-weight: 500;\n color: var(--sqc-text-muted);\n}\n\n.sqc-approval__arg-value {\n margin: 0;\n min-width: 0;\n overflow-wrap: anywhere;\n color: var(--sqc-text);\n}\n\n.sqc-approval__btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 1 1 auto;\n height: 32px;\n padding: 0 12px;\n font-family: var(--sqc-font-family);\n font-size: 13px;\n font-weight: 500;\n border-radius: 12px;\n border: 1px solid var(--sqc-border);\n background: var(--sqc-bg);\n color: var(--sqc-text);\n cursor: pointer;\n transition:\n border-color 0.12s ease,\n background 0.12s ease;\n}\n\n.sqc-approval__btn--yes:not(:disabled),\n.sqc-approval__btn--send:not(:disabled) {\n border-color: transparent;\n background: var(--sqc-accent-color);\n color: var(--sqc-on-accent);\n font-weight: 600;\n}\n\n.sqc-approval__btn:hover:not(:disabled) {\n border-color: var(--sqc-border-strong);\n background: var(--sqc-surface);\n}\n\n.sqc-approval__btn--yes:hover:not(:disabled),\n.sqc-approval__btn--send:hover:not(:disabled) {\n border-color: transparent;\n background: var(--sqc-accent-hover);\n}\n\n.sqc-approval__btn:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n.sqc-approval__btn:disabled {\n cursor: default;\n}\n\n/* Frozen: the decision taken stays marked, the others fade out. */\n.sqc-approval__btn:disabled[aria-pressed='false'] {\n opacity: 0.45;\n}\n\n.sqc-approval__btn[aria-pressed='true'] {\n border-color: var(--sqc-border-strong);\n background: var(--sqc-selected);\n color: var(--sqc-text);\n font-weight: 600;\n}\n\n.sqc-approval__edit {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.sqc-approval__input {\n width: 100%;\n padding: 8px 10px;\n font-family: var(--sqc-font-family);\n font-size: 13px;\n line-height: 1.4;\n color: var(--sqc-text);\n background: var(--sqc-bg);\n border: 1px solid var(--sqc-border-strong);\n border-radius: 12px;\n resize: vertical;\n}\n\n.sqc-approval__input:focus-visible {\n outline: none;\n border-color: var(--sqc-text);\n box-shadow: var(--sqc-focus-input);\n}\n\n.sqc-approval__btn--send {\n align-self: flex-end;\n flex: 0 0 auto;\n}\n\n/* Answer to a closed question (\"Do you confirm the creation?\").\n DS `.cactions`: two 32px buttons sharing the width. */\n.sqc-confirm {\n display: flex;\n gap: 8px;\n margin: 11px 0 2px;\n}\n\n.sqc-confirm__btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 1 1 0;\n height: 32px;\n padding: 0 12px;\n font-family: var(--sqc-font-family);\n font-size: 13px;\n font-weight: 500;\n border-radius: 12px;\n border: 1px solid var(--sqc-border);\n background: var(--sqc-bg);\n color: var(--sqc-text);\n cursor: pointer;\n transition:\n border-color 0.12s ease,\n background 0.12s ease;\n}\n\n.sqc-confirm__btn--yes:not(:disabled) {\n border-color: transparent;\n background: var(--sqc-accent-color);\n color: var(--sqc-on-accent);\n font-weight: 600;\n}\n\n.sqc-confirm__btn:hover:not(:disabled) {\n border-color: var(--sqc-border-strong);\n background: var(--sqc-surface);\n}\n\n.sqc-confirm__btn--yes:hover:not(:disabled) {\n border-color: transparent;\n background: var(--sqc-accent-hover);\n}\n\n.sqc-confirm__btn:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n.sqc-confirm__btn:disabled {\n cursor: default;\n}\n\n/* Frozen: the answer given stays marked, the other fades out. */\n.sqc-confirm__btn:disabled[aria-pressed='false'] {\n opacity: 0.45;\n}\n\n.sqc-confirm__btn[aria-pressed='true'] {\n border-color: var(--sqc-border-strong);\n background: var(--sqc-selected);\n color: var(--sqc-text);\n font-weight: 600;\n}\n\n/* Options offered by the assistant (Markdown checkboxes).\n DS `.chip`: vertical list of clickable cards. */\n.sqc-choices {\n display: flex;\n flex-direction: column;\n gap: 7px;\n margin: 10px 0 2px;\n}\n\n.sqc-choice {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n padding: 8px 11px;\n font-family: var(--sqc-font-family);\n font-size: 12.5px;\n text-align: left;\n color: var(--sqc-text);\n background: var(--sqc-bg);\n border: 1px solid var(--sqc-border);\n border-radius: 12px;\n cursor: pointer;\n transition:\n border-color 0.12s ease,\n background 0.12s ease;\n}\n\n.sqc-choice:hover:not(:disabled) {\n border-color: var(--sqc-border-strong);\n background: var(--sqc-surface);\n}\n\n.sqc-choice:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n/* Frozen after answering: the picked option stays readable, the others fade. */\n.sqc-choice:disabled {\n cursor: default;\n}\n\n.sqc-choice:disabled[aria-pressed='false'] {\n opacity: 0.55;\n}\n\n.sqc-choice[aria-pressed='true'] {\n border-color: var(--sqc-border-strong);\n background: var(--sqc-selected);\n}\n\n.sqc-choice__box {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n width: 15px;\n height: 15px;\n border: 1.5px solid var(--sqc-border-strong);\n border-radius: 4px;\n}\n\n.sqc-choice__box--on {\n color: var(--sqc-on-accent);\n background: var(--sqc-accent-color);\n border-color: var(--sqc-accent-color);\n}\n\n.sqc-choice__box svg {\n width: 11px;\n height: 11px;\n}\n\n.sqc-choice__label {\n overflow-wrap: anywhere;\n}\n\n/* What tells an option apart from the others (its type, its owner, its\n reference): displayed under the label, typographically recessed — it is a\n marker, not what goes back to the agent. */\n.sqc-choice__detail {\n display: block;\n margin-top: 1px;\n font-size: 11.5px;\n color: var(--sqc-text-muted);\n}\n\n/* A choice the agent is waiting on: its questions, then the single validation\n answering them all (`Selection.tsx`). */\n.sqc-selection {\n display: flex;\n flex-direction: column;\n gap: 10px;\n margin: 2px 0;\n}\n\n.sqc-selection__question {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.sqc-selection__ask {\n margin: 0;\n font-family: var(--sqc-font-family);\n font-size: 13px;\n font-weight: 600;\n color: var(--sqc-text);\n}\n\n.sqc-selection__actions {\n display: flex;\n}\n\n.sqc-selection__validate {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 1 1 auto;\n height: 32px;\n padding: 0 12px;\n font-family: var(--sqc-font-family);\n font-size: 13px;\n font-weight: 600;\n color: var(--sqc-on-accent);\n background: var(--sqc-accent-color);\n border: 1px solid transparent;\n border-radius: 12px;\n cursor: pointer;\n transition:\n filter 0.12s ease,\n background 0.12s ease;\n}\n\n.sqc-selection__validate:hover:not(:disabled) {\n background: var(--sqc-accent-hover);\n}\n\n.sqc-selection__validate:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n/* Nothing ticked, or answer already sent: the DS's disabled action. */\n.sqc-selection__validate:disabled {\n cursor: not-allowed;\n color: #ffffff;\n background: var(--sqc-disabled);\n}\n\n.sqc-selection__hint {\n margin: 0;\n font-family: var(--sqc-font-family);\n font-size: 11.5px;\n color: var(--sqc-text-muted);\n}\n\n/* Record listings overflow the thread width: the table scrolls horizontally on\n its own, the message does not widen.\n DS: muted uppercase headers, slate-200 rules. */\n.sqc-table {\n margin: 0 0 8px;\n overflow-x: auto;\n scrollbar-width: thin;\n}\n\n.sqc-table table {\n min-width: 100%;\n border-collapse: collapse;\n font-family: var(--sqc-font-family);\n font-size: 12.5px;\n white-space: nowrap;\n}\n\n.sqc-table th,\n.sqc-table td {\n padding: 6px 10px 6px 0;\n text-align: left;\n vertical-align: top;\n border-bottom: 1px solid var(--sqc-border);\n}\n\n.sqc-table thead th {\n font-size: 10.5px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n color: var(--sqc-text-muted);\n}\n\n.sqc-table tbody th {\n font-weight: 500;\n}\n\n.sqc-msg--user .sqc-table th,\n.sqc-msg--user .sqc-table td {\n border-bottom-color: rgb(255 255 255 / 25%);\n}\n\n.sqc-msg--user .sqc-table thead th {\n color: rgb(255 255 255 / 80%);\n}\n\n.sqc-table tbody tr:last-child th,\n.sqc-table tbody tr:last-child td {\n border-bottom: 0;\n}\n\n.sqc-msg__time {\n display: block;\n margin-top: 3px;\n font-size: 10px;\n color: var(--sqc-text-muted);\n font-variant-numeric: tabular-nums;\n}\n\n.sqc-msg--user .sqc-msg__time {\n color: rgb(255 255 255 / 70%);\n text-align: right;\n}\n\n/* Curseur de frappe pendant le streaming. */\n.sqc-caret {\n display: inline-block;\n width: 2px;\n height: 1em;\n margin-left: 2px;\n vertical-align: text-bottom;\n background: currentColor;\n animation: sqc-blink 1s step-end infinite;\n}\n\n@keyframes sqc-blink {\n 0%,\n 100% {\n opacity: 1;\n }\n 50% {\n opacity: 0;\n }\n}\n\n/* Trois points avant le premier token — DS `.typing`. */\n.sqc-typing {\n display: inline-flex;\n gap: 3px;\n padding: 2px 0;\n}\n\n.sqc-typing i {\n width: 5px;\n height: 5px;\n border-radius: 50%;\n background: var(--sqc-neutral-400);\n animation: sqc-pulse 1.2s infinite;\n}\n\n.sqc-typing i:nth-child(2) {\n animation-delay: 0.2s;\n}\n\n.sqc-typing i:nth-child(3) {\n animation-delay: 0.4s;\n}\n\n@keyframes sqc-pulse {\n 0%,\n 60%,\n 100% {\n opacity: 0.25;\n }\n 30% {\n opacity: 1;\n }\n}\n\n/* ── Suggestions ──────────────────────────────────────────── */\n\n/* A full-width stack rather than floating pills: in a 392px panel every other\n pill used to be cut. */\n.sqc-suggestions {\n display: flex;\n flex-direction: column;\n gap: 7px;\n}\n\n.sqc-suggestion {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n padding: 8px 11px;\n border: 1px solid var(--sqc-border);\n border-radius: 12px;\n background: var(--sqc-bg);\n color: var(--sqc-text);\n font-family: var(--sqc-font-family);\n font-size: 12.5px;\n cursor: pointer;\n text-align: left;\n transition:\n background 0.15s ease,\n border-color 0.15s ease;\n}\n\n.sqc-suggestion::before {\n content: '';\n flex: 0 0 auto;\n width: 5px;\n height: 5px;\n border-radius: 50%;\n background: var(--sqc-accent-fg);\n}\n\n.sqc-suggestion:hover {\n background: var(--sqc-surface);\n border-color: var(--sqc-border-strong);\n}\n\n.sqc-suggestion:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n/* ── Zone de saisie ───────────────────────────────────────── */\n\n.sqc-composer {\n display: flex;\n align-items: flex-end;\n /* Wraps so the chips of attached files sit on a row of their own above the\n field, rather than squeezing it. */\n flex-wrap: wrap;\n gap: 8px;\n padding: 12px 14px;\n border-top: 1px solid var(--sqc-border);\n background: var(--sqc-bg);\n flex-shrink: 0;\n}\n\n/* A file being dragged over the composer, which is a drop target like the\n paperclip is a button. */\n.sqc-composer--dropping {\n outline: 2px dashed var(--sqc-accent-color);\n outline-offset: -4px;\n}\n\n/* The files a question is being written with, and the ones it was sent with:\n the same chips in the composer and under a bubble. */\n.sqc-attachments {\n flex-basis: 100%;\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n}\n\n.sqc-attachments--sent {\n margin-top: 8px;\n}\n\n.sqc-chip {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n max-width: 100%;\n padding: 3px 4px 3px 10px;\n border: 1px solid var(--sqc-border);\n border-radius: 999px;\n background: var(--sqc-selected);\n color: var(--sqc-text);\n font-size: 12px;\n}\n\n.sqc-chip--waiting {\n opacity: 0.6;\n padding-right: 10px;\n}\n\n.sqc-chip__name {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n max-width: 180px;\n}\n\n.sqc-chip__remove {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n padding: 0;\n border: 0;\n border-radius: 999px;\n background: transparent;\n color: var(--sqc-text-muted);\n font-size: 14px;\n line-height: 1;\n cursor: pointer;\n}\n\n.sqc-chip__remove:hover {\n background: var(--sqc-selected);\n color: var(--sqc-text);\n}\n\n.sqc-attachments__error {\n flex-basis: 100%;\n margin: 0;\n color: var(--sqc-error-600);\n font-size: 12px;\n}\n\n/* An attached picture, drawn under the message it was sent with. Bounded so a\n photograph does not push the conversation off the panel. */\n.sqc-attachment__image {\n display: block;\n max-width: 100%;\n max-height: 180px;\n border-radius: 12px;\n}\n\n/* The real input is never shown: the paperclip is the control. */\n.sqc-file-input {\n display: none;\n}\n\n.sqc-btn--attach {\n background: transparent;\n color: var(--sqc-text-muted);\n}\n\n.sqc-btn--attach:hover {\n background: var(--sqc-selected);\n color: var(--sqc-text);\n}\n\n.sqc-composer__field {\n position: relative;\n flex: 1;\n min-width: 0;\n}\n\n.sqc-composer__input {\n display: block;\n width: 100%;\n min-height: 38px;\n max-height: 132px;\n padding: 9px 12px;\n border: 1px solid var(--sqc-border-strong);\n border-radius: 12px;\n background: var(--sqc-bg);\n color: var(--sqc-text);\n font-family: var(--sqc-font-family);\n font-size: 13.5px;\n line-height: 1.4;\n resize: none;\n /* No scrollbar by default (a single line): `Composer.tsx` switches to `auto`\n once `scrollHeight` goes past `max-height`. */\n overflow-y: hidden;\n outline: none;\n transition:\n border-color 0.15s ease,\n box-shadow 0.15s ease;\n}\n\n.sqc-composer__input::placeholder {\n color: var(--sqc-neutral-400);\n}\n\n.sqc-composer__input:focus {\n border-color: var(--sqc-text);\n box-shadow: var(--sqc-focus-input);\n}\n\n/* The handle picker `@` opens over the field. Anchored to the field rather than\n the panel: it has to sit on top of the message list, and the composer is the\n only positioned ancestor that follows the textarea as it grows. */\n.sqc-mentions {\n position: absolute;\n left: 0;\n right: 0;\n bottom: calc(100% + 6px);\n z-index: 2;\n max-height: 184px;\n overflow-y: auto;\n margin: 0;\n padding: 4px;\n list-style: none;\n border: 1px solid var(--sqc-border);\n border-radius: 12px;\n background: var(--sqc-bg);\n box-shadow: var(--sqc-shadow);\n scrollbar-width: thin;\n}\n\n.sqc-mention {\n display: flex;\n align-items: baseline;\n gap: 6px;\n padding: 6px 8px;\n border-radius: 8px;\n cursor: pointer;\n font-size: 12.5px;\n color: var(--sqc-text);\n}\n\n.sqc-mention--active {\n background: var(--sqc-neutral-100);\n}\n\n.sqc-mention__icon {\n flex-shrink: 0;\n}\n\n.sqc-mention__handle {\n font-weight: 600;\n}\n\n.sqc-mention__name {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: var(--sqc-text-muted);\n}\n\n.sqc-composer__count {\n position: absolute;\n right: 8px;\n bottom: 4px;\n font-size: 10px;\n color: var(--sqc-text-muted);\n pointer-events: none;\n font-variant-numeric: tabular-nums;\n}\n\n.sqc-btn {\n width: 38px;\n height: 38px;\n border: none;\n border-radius: 12px;\n cursor: pointer;\n display: grid;\n place-items: center;\n flex-shrink: 0;\n transition:\n background 0.15s ease,\n opacity 0.15s ease;\n}\n\n.sqc-btn svg {\n width: 17px;\n height: 17px;\n}\n\n.sqc-btn--send {\n background: var(--sqc-accent-color);\n color: var(--sqc-on-accent);\n}\n\n.sqc-btn--send:hover:not(:disabled) {\n background: var(--sqc-accent-hover);\n}\n\n/* The DS's disabled action: slate-300, white glyph. */\n.sqc-btn--send:disabled {\n background: var(--sqc-disabled);\n color: #ffffff;\n cursor: not-allowed;\n}\n\n.sqc-btn--stop {\n background: var(--sqc-bg);\n color: var(--sqc-text);\n border: 1px solid var(--sqc-border);\n}\n\n.sqc-btn--stop:hover {\n border-color: var(--sqc-border-strong);\n background: var(--sqc-surface);\n}\n\n.sqc-btn:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n/* Permanent reminder that nothing is written without confirmation —\n which is exactly the agent contract (`pending_action`, then \"yes\"). */\n.sqc-hint {\n flex-shrink: 0;\n margin: 0;\n /* Safety margin for the iOS / Android home bar. */\n padding: 0 16px max(9px, env(safe-area-inset-bottom));\n font-size: 10.5px;\n line-height: 1.35;\n color: var(--sqc-text-muted);\n text-align: center;\n}\n\n/* Shown when the organization's plan carries our name. */\n.sqc-powered {\n flex-shrink: 0;\n margin: 0;\n padding: 0 16px max(9px, env(safe-area-inset-bottom));\n font-size: 10.5px;\n line-height: 1.35;\n text-align: center;\n}\n\n.sqc-powered a {\n color: var(--sqc-text-muted);\n text-decoration: none;\n}\n\n.sqc-powered a:hover {\n text-decoration: underline;\n}\n\n/* ── Adaptations ──────────────────────────────────────────── */\n\n@media (max-width: 520px) {\n .sqc {\n --sqc-width: 100vw;\n }\n\n .sqc-panel {\n border-left: none;\n }\n\n .sqc-launcher {\n bottom: 16px;\n right: 16px;\n }\n\n .sqc[data-position='bottom-left'] .sqc-launcher {\n left: 16px;\n }\n\n /* No room for a window on a phone: the floating panel fills the screen. */\n .sqc[data-layout='floating'] .sqc-panel,\n .sqc[data-layout='floating'][data-position='bottom-left'] .sqc-panel {\n inset: 0;\n max-width: none;\n height: auto;\n max-height: none;\n border: none;\n border-radius: 0;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .sqc-launcher,\n .sqc-panel,\n .sqc-btn,\n .sqc-suggestion,\n .sqc-choice,\n .sqc-confirm__btn,\n .sqc-icon-btn {\n transition: none;\n }\n\n .sqc-icon-btn[data-tip]::after {\n transition: none;\n }\n\n .sqc-typing i,\n .sqc-caret {\n animation: none;\n }\n}\n\n/* Once an agent handed the conversation to a human: nothing more is streamed,\n and this is what says a reply is still coming. */\n.sqc-with-human {\n margin: 8px 0 0;\n padding: 8px 12px;\n border: 1px solid var(--sqc-border);\n border-radius: 12px;\n background: var(--sqc-selected);\n color: var(--sqc-neutral-600);\n font-size: 13px;\n}\n","/**\n * Custom element wrapper: `<squadico-chatbot>`.\n *\n * The class is built **lazily** by `defineChatbot()` rather than at module\n * level: `class X extends HTMLElement` would throw a `ReferenceError` on a plain\n * server-side import (Next.js or Nuxt SSR, Node tests).\n */\nimport { render } from 'preact'\nimport { ChatbotWidget, type ChatbotControls } from './components/ChatbotWidget'\nimport styles from './styles.css?inline'\nimport type {\n ChatbotContext,\n ChatbotEvent,\n ChatbotOptions,\n HostUser,\n SubjectTokenSource,\n} from './types'\n\nexport const TAG_NAME = 'squadico-chatbot'\n\nconst ATTRIBUTES = [\n 'embed-key',\n 'context',\n 'user',\n 'agent',\n 'heading',\n 'subheading',\n 'assistant-name',\n 'placeholder',\n 'greeting',\n 'suggestions',\n 'width',\n 'accent',\n 'theme',\n 'position',\n 'layout',\n 'open',\n 'persist-open',\n 'locale',\n] as const\n\n/** A single `CSSStyleSheet` shared by every instance. */\nlet sheet: CSSStyleSheet | null | undefined\n\nfunction sharedSheet(): CSSStyleSheet | null {\n if (sheet !== undefined) return sheet\n try {\n const created = new CSSStyleSheet()\n created.replaceSync(styles)\n sheet = created\n } catch {\n // Safari < 16.4: no constructable stylesheets, fall back to <style>.\n sheet = null\n }\n return sheet\n}\n\nfunction warn(message: string, detail?: unknown): void {\n if (typeof console !== 'undefined') console.warn(`[${TAG_NAME}] ${message}`, detail ?? '')\n}\n\n/**\n * The host user, as an attribute.\n *\n * Accepts the JSON object a page can write in markup (`user='{\"id\":\"42\"}'`) and\n * refuses anything without an id: a claim with nothing to claim is not one, and\n * sending it would open an anonymous conversation while the page believed it had\n * named somebody.\n */\nfunction parseUser(raw: string | null): HostUser | undefined {\n if (!raw || !raw.trim()) return undefined\n try {\n const parsed: unknown = JSON.parse(raw)\n if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {\n const source = parsed as { id?: unknown; name?: unknown; digest?: unknown }\n if (typeof source.id === 'string' && source.id) {\n return {\n id: source.id,\n name: typeof source.name === 'string' && source.name ? source.name : undefined,\n // Carried through rather than validated: what a digest has to *be* is\n // the API's rule, and a page that mistyped one meets a refusal about\n // its claim instead of a console warning about its markup.\n digest:\n typeof source.digest === 'string' && source.digest ? source.digest : undefined,\n }\n }\n }\n warn('the \"user\" attribute needs an object with an id', raw)\n } catch (error) {\n warn('the \"user\" attribute is not valid JSON', error)\n }\n return undefined\n}\n\nfunction parseContext(raw: string | null): ChatbotContext | undefined {\n if (!raw || !raw.trim()) return undefined\n try {\n const parsed: unknown = JSON.parse(raw)\n if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {\n return parsed as ChatbotContext\n }\n warn('the `context` attribute must be a JSON object', raw)\n } catch (error) {\n warn('the `context` attribute is not valid JSON', error)\n }\n return undefined\n}\n\n/** Accepts `[\"a\",\"b\"]` or `a|b` — the second form avoids escaping quotes in a\n * Vue or Angular template. */\nfunction parseSuggestions(raw: string | null): string[] | undefined {\n if (!raw || !raw.trim()) return undefined\n if (raw.trim().startsWith('[')) {\n try {\n const parsed: unknown = JSON.parse(raw)\n if (Array.isArray(parsed)) return parsed.map(String)\n } catch (error) {\n warn('the `suggestions` attribute is not valid JSON', error)\n return undefined\n }\n }\n return raw\n .split('|')\n .map((item) => item.trim())\n .filter(Boolean)\n}\n\n/** A boolean attribute is true by mere presence; `=\"false\"` negates it. */\nfunction parseBool(raw: string | null): boolean | undefined {\n if (raw === null) return undefined\n return raw !== 'false' && raw !== '0'\n}\n\nfunction parseTheme(raw: string | null): ChatbotOptions['theme'] {\n return raw === 'dark' || raw === 'light' || raw === 'auto' ? raw : undefined\n}\n\nfunction parsePosition(raw: string | null): ChatbotOptions['position'] {\n return raw === 'bottom-left' || raw === 'bottom-right' ? raw : undefined\n}\n\nfunction parseLayout(raw: string | null): ChatbotOptions['layout'] {\n return raw === 'floating' || raw === 'sidebar' ? raw : undefined\n}\n\nfunction createElementClass(): CustomElementConstructor {\n return class SquadicoChatbot extends HTMLElement {\n static readonly observedAttributes = ATTRIBUTES\n\n #mount: HTMLDivElement\n #controls: ChatbotControls | null = null\n #scheduled = false\n #connected = false\n #sessionId = ''\n\n /* Values set as properties (objects/functions), which have no attribute\n equivalent. They take precedence over the attributes. */\n #context?: ChatbotContext\n #user?: HostUser\n #getSubjectToken?: SubjectTokenSource\n #agent?: string\n #embedKey?: string\n\n constructor() {\n super()\n const shadow = this.attachShadow({ mode: 'open' })\n const adoptable = sharedSheet()\n if (adoptable) {\n shadow.adoptedStyleSheets = [adoptable]\n } else {\n const style = document.createElement('style')\n style.textContent = styles\n shadow.append(style)\n }\n this.#mount = document.createElement('div')\n shadow.append(this.#mount)\n }\n\n connectedCallback(): void {\n this.#connected = true\n this.#render()\n }\n\n disconnectedCallback(): void {\n this.#connected = false\n render(null, this.#mount)\n this.#controls = null\n }\n\n attributeChangedCallback(name: string, previous: string | null, next: string | null): void {\n if (previous === next) return\n\n // `open` is imperative, not declarative: the render does not read the\n // attribute back, the controls carry the state once the widget is mounted.\n if (name === 'open' && this.#controls) {\n if (parseBool(next)) this.#controls.open()\n else this.#controls.close()\n return\n }\n this.#schedule()\n }\n\n /* ── Properties ────────────────────────────────────────── */\n\n get context(): ChatbotContext | undefined {\n return this.#context ?? parseContext(this.getAttribute('context'))\n }\n\n set context(value: ChatbotContext | undefined) {\n this.#context = value\n this.#schedule()\n }\n\n get embedKey(): string | undefined {\n return this.#embedKey ?? this.getAttribute('embed-key') ?? undefined\n }\n\n set embedKey(value: string | undefined) {\n this.#embedKey = value\n this.#schedule()\n }\n\n /** Who the host application has signed in. Settable as a property, and as a\n * ``user`` attribute holding JSON for a page that only writes markup. */\n get user(): HostUser | undefined {\n return this.#user ?? parseUser(this.getAttribute('user'))\n }\n\n set user(value: HostUser | undefined) {\n this.#user = value\n this.#schedule()\n }\n\n /** Hands over the token the site holds for its signed-in user, before each\n * message. A property only: a function has no attribute form. */\n get getSubjectToken(): SubjectTokenSource | undefined {\n return this.#getSubjectToken\n }\n\n set getSubjectToken(value: SubjectTokenSource | undefined) {\n this.#getSubjectToken = value\n this.#schedule()\n }\n\n /** The handle this page opens on — `agent=\"sales\"` on a pricing page. A name\n * nobody answers to opens on the default agent rather than refusing. */\n get agent(): string | undefined {\n return this.#agent ?? this.getAttribute('agent') ?? undefined\n }\n\n set agent(value: string | undefined) {\n this.#agent = value\n this.#schedule()\n }\n\n get open(): boolean {\n return this.#controls?.isOpen() ?? (parseBool(this.getAttribute('open')) ?? false)\n }\n\n set open(value: boolean) {\n if (value) this.openChat()\n else this.closeChat()\n }\n\n get sessionId(): string {\n return this.#controls?.sessionId() ?? this.#sessionId\n }\n\n /* ── Imperative API ───────────────────────────────────── */\n\n openChat(): void {\n this.#controls?.open()\n }\n\n closeChat(): void {\n this.#controls?.close()\n }\n\n toggleChat(): void {\n this.#controls?.toggle()\n }\n\n reset(): void {\n this.#controls?.reset()\n }\n\n sendMessage(text: string): void {\n if (!this.#controls) {\n warn('sendMessage() called before the component was mounted — ignored')\n return\n }\n this.#controls.send(text)\n }\n\n /* ── Rendering ────────────────────────────────────────── */\n\n /** Batches several mutations in a row (a framework setting five attributes)\n * into a single render. */\n #schedule(): void {\n if (this.#scheduled || !this.#connected) return\n this.#scheduled = true\n queueMicrotask(() => {\n this.#scheduled = false\n if (this.#connected) this.#render()\n })\n }\n\n #emit = (event: ChatbotEvent): void => {\n const { type, ...detail } = event\n this.#sessionId = detail.sessionId\n this.dispatchEvent(\n new CustomEvent(type, {\n detail,\n // Crosses the shadow root to reach the host page's listeners.\n bubbles: true,\n composed: true,\n }),\n )\n }\n\n #bind = (controls: ChatbotControls | null): void => {\n this.#controls = controls\n // The `open` attribute present at mount has already been arbitrated\n // against the remembered panel state (`lib/openState`); this only\n // publishes the initial session.\n if (controls) this.#sessionId = controls.sessionId()\n }\n\n #render(): void {\n const attr = (name: string): string | undefined => this.getAttribute(name) ?? undefined\n\n render(\n <ChatbotWidget\n embedKey={this.embedKey}\n context={this.context}\n user={this.user}\n getSubjectToken={this.getSubjectToken}\n agent={this.agent}\n heading={attr('heading')}\n subheading={attr('subheading')}\n assistantName={attr('assistant-name')}\n placeholder={attr('placeholder')}\n greeting={attr('greeting')}\n suggestions={parseSuggestions(this.getAttribute('suggestions'))}\n width={attr('width')}\n accent={attr('accent')}\n theme={parseTheme(this.getAttribute('theme'))}\n position={parsePosition(this.getAttribute('position'))}\n layout={parseLayout(this.getAttribute('layout'))}\n defaultOpen={parseBool(this.getAttribute('open')) ?? false}\n persistOpen={parseBool(this.getAttribute('persist-open')) ?? true}\n locale={attr('locale')}\n onEvent={this.#emit}\n bind={this.#bind}\n />,\n this.#mount,\n )\n }\n }\n}\n\nlet Constructor: CustomElementConstructor | undefined\n\n/**\n * Registers `<squadico-chatbot>`. Idempotent, and a no-op server-side.\n *\n * @param tag alternative tag name, when `squadico-chatbot` is already taken by\n * another version of the widget on the page.\n */\nexport function defineChatbot(tag: string = TAG_NAME): void {\n if (typeof window === 'undefined' || typeof HTMLElement === 'undefined') return\n Constructor ??= createElementClass()\n if (!window.customElements.get(tag)) {\n window.customElements.define(tag, Constructor)\n }\n}\n","/**\n * Default entry point of `@squadico/chatbot`.\n *\n * Importing it registers `<squadico-chatbot>` in the browser (a deliberate side\n * effect, declared through `sideEffects` in `package.json`) and does nothing\n * server-side, which makes it safe to import from a Next.js or Nuxt component.\n *\n * import '@squadico/chatbot'\n * <squadico-chatbot embed-key=\"sq_pub_…\" />\n */\nexport { defineChatbot, TAG_NAME } from './element'\nexport { DEFAULT_LANGUAGE, SUPPORTED_LANGUAGES, type LanguageCode } from './lib/i18n'\nexport { API_URL, ChatHttpError, MAX_MESSAGE_LENGTH } from './lib/client'\nexport type {\n AgentHandle,\n ApprovalDecision,\n ChatbotContext,\n ChatbotEvent,\n ChatbotEventMap,\n ChatbotEventName,\n ChatbotLayout,\n ChatbotOptions,\n ChatbotTheme,\n ChatMessage,\n ChatRole,\n ContextObject,\n ContextValue,\n HostUser,\n LauncherPosition,\n PendingApproval,\n SquadicoChatbotElement,\n SubjectTokenSource,\n} from './types'\n\nimport { defineChatbot } from './element'\n\ndefineChatbot()\n"],"x_google_ignoreList":[0,1,9],"mappings":";AAAA,IAAI,GAAEA,GAAEC,GAAIE,GAAEC,GAAEC,GAAEC,GAAEC,GAAEC,GAAEC,GAAEC,GAAEC,GAAEC,GAAEC,GAAIE,IAAE,CAAC,GAAEC,IAAE,CAAC,GAAEC,IAAE,qEAAoE,IAAE,MAAM;AAAQ,SAASC,EAAE,GAAE,GAAE;CAAC,KAAI,IAAI,KAAK,GAAE,EAAE,KAAG,EAAE;CAAG,OAAO;AAAC;AAAC,SAAS,EAAE,GAAE;CAAC,KAAG,EAAE,cAAY,EAAE,WAAW,YAAY,CAAC;AAAC;AAAC,SAASC,EAAE,GAAE,GAAE,GAAE;CAAC,IAAI,GAAE,GAAE,GAAE,IAAE,CAAC;CAAE,KAAI,KAAK,GAAE,AAAO,KAAP,QAAS,IAAE,EAAE,KAAU,KAAP,QAAS,IAAE,EAAE,KAAG,EAAE,KAAG,EAAE;CAAG,IAAG,UAAU,SAAO,MAAI,EAAE,WAAS,UAAU,SAAO,IAAE,EAAE,KAAK,WAAU,CAAC,IAAE,IAAe,OAAO,KAAnB,cAA4B,EAAE,gBAAR,MAAqB,KAAI,KAAK,EAAE,cAAa,AAAS,EAAE,OAAX,KAAK,MAAW,EAAE,KAAG,EAAE,aAAa;CAAI,OAAO,EAAE,GAAE,GAAE,GAAE,GAAE,IAAI;AAAC;AAAC,SAAS,EAAE,GAAE,GAAE,GAAE,GAAE,GAAE;CAAC,IAAI,IAAE;EAAC,MAAK;EAAE,OAAM;EAAE,KAAI;EAAE,KAAI;EAAE,KAAI;EAAK,IAAG;EAAK,KAAI;EAAE,KAAI;EAA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MAAM,CAAC,KAAK;GACrD,aAAa,GAAU,KAAK,aAAa,cAAc,CAAC,KAAK;GAC7D,QAAQ,EAAK,QAAQ;GACrB,SAAA,EAAA,GAAS,IAAA;GACT,MAAA,EAAA,GAAM,IAAA;EACP,CAAA,GAAA,EAAA,GACD,IAAA,CACF;CACF;AAEJ;AAEA,IAAI;AAQJ,SAAgB,GAAc,IAAc,IAAgB;CACtD,OAAO,SAAW,OAAe,OAAO,cAAgB,QAC5D,OAAA,KAAgB,GAAmB,IAC9B,OAAO,eAAe,IAAI,CAAG,KAChC,OAAO,eAAe,OAAO,GAAK,EAAW;AAEjD;;;ACnVA,GAAc"}
|
|
1
|
+
{"version":3,"file":"src-2UbcV1gc.js","names":["l","u","t","i","r","o","e","f","c","a","s","h","p","v","y","d","w","_","m","k","C","q","D","A","T","j","z","B","u","i","f","n","r"],"sources":["../node_modules/preact/dist/preact.module.js","../node_modules/preact/hooks/dist/hooks.module.js","../src/lib/context.ts","../src/lib/i18n.ts","../src/lib/openState.ts","../src/lib/uid.ts","../src/lib/client.ts","../src/lib/conversation.ts","../src/lib/useChat.ts","../node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js","../src/components/Composer.tsx","../src/lib/confirm.ts","../src/components/Approval.tsx","../src/components/Confirm.tsx","../src/components/Choices.tsx","../src/components/RichText.tsx","../src/components/MessageList.tsx","../src/components/ChatbotWidget.tsx","../src/styles.css?inline","../src/element.tsx","../src/index.ts"],"sourcesContent":["var n,l,u,t,i,r,o,e,f,c,a,s,h,p,v,y,d={},w=[],_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,g=Array.isArray;function m(n,l){for(var u in l)n[u]=l[u];return n}function b(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function k(l,u,t){var i,r,o,e={};for(o in u)\"key\"==o?i=u[o]:\"ref\"==o?r=u[o]:e[o]=u[o];if(arguments.length>2&&(e.children=arguments.length>3?n.call(arguments,2):t),\"function\"==typeof l&&null!=l.defaultProps)for(o in l.defaultProps)void 0===e[o]&&(e[o]=l.defaultProps[o]);return x(l,e,i,r,null)}function x(n,t,i,r,o){var e={type:n,props:t,key:i,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==o?++u:o,__i:-1,__u:0};return null==o&&null!=l.vnode&&l.vnode(e),e}function M(){return{current:null}}function S(n){return n.children}function C(n,l){this.props=n,this.context=l}function $(n,l){if(null==l)return n.__?$(n.__,n.__i+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return\"function\"==typeof n.type?$(n):null}function I(n){if(n.__P&&n.__d){var u=n.__v,t=u.__e,i=[],r=[],o=m({},u);o.__v=u.__v+1,l.vnode&&l.vnode(o),q(n.__P,o,u,n.__n,n.__P.namespaceURI,32&u.__u?[t]:null,i,null==t?$(u):t,!!(32&u.__u),r),o.__v=u.__v,o.__.__k[o.__i]=o,D(i,o,r),u.__e=u.__=null,o.__e!=t&&P(o)}}function P(n){if(null!=(n=n.__)&&null!=n.__c)return n.__e=n.__c.base=null,n.__k.some(function(l){if(null!=l&&null!=l.__e)return n.__e=n.__c.base=l.__e}),P(n)}function A(n){(!n.__d&&(n.__d=!0)&&i.push(n)&&!H.__r++||r!=l.debounceRendering)&&((r=l.debounceRendering)||o)(H)}function H(){try{for(var n,l=1;i.length;)i.length>l&&i.sort(e),n=i.shift(),l=i.length,I(n)}finally{i.length=H.__r=0}}function L(n,l,u,t,i,r,o,e,f,c,a){var s,h,p,v,y,_,g=t&&t.__k||w,m=l.length;for(f=T(u,l,g,f,m),s=0;s<m;s++)null!=(p=u.__k[s])&&(h=-1!=p.__i&&g[p.__i]||d,p.__i=s,_=q(n,p,h,i,r,o,e,f,c,a),v=p.__e,p.ref&&h.ref!=p.ref&&(h.ref&&J(h.ref,null,p),a.push(p.ref,p.__c||v,p)),null==y&&null!=v&&(y=v),4&p.__u?(f=j(p,f,n),h.__e&&(h.__e=null)):\"function\"==typeof p.type&&void 0!==_?f=_:v&&(f=v.nextSibling),p.__u&=-7);return u.__e=y,f}function T(n,l,u,t,i){var r,o,e,f,c,a=u.length,s=a,h=0;for(n.__k=new Array(i),r=0;r<i;r++)null!=(o=l[r])&&\"boolean\"!=typeof o&&\"function\"!=typeof o?(\"string\"==typeof o||\"number\"==typeof o||\"bigint\"==typeof o||o.constructor==String?o=n.__k[r]=x(null,o,null,null,null):g(o)?o=n.__k[r]=x(S,{children:o},null,null,null):void 0===o.constructor&&o.__b>0?o=n.__k[r]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):n.__k[r]=o,f=r+h,o.__=n,o.__b=n.__b+1,e=null,-1!=(c=o.__i=O(o,u,f,s))&&(s--,(e=u[c])&&(e.__u|=2)),null==e||null==e.__v?(-1==c&&(i>a?h--:i<a&&h++),\"function\"!=typeof o.type&&(o.__u|=4)):c!=f&&(c==f-1?h--:c==f+1?h++:(c>f?h--:h++,o.__u|=4))):n.__k[r]=null;if(s)for(r=0;r<a;r++)null!=(e=u[r])&&0==(2&e.__u)&&(e.__e==t&&(t=$(e)),K(e,e));return t}function j(n,l,u){var t,i;if(\"function\"==typeof n.type){for(t=n.__k,i=0;t&&i<t.length;i++)t[i]&&(t[i].__=n,l=j(t[i],l,u));return l}n.__e!=l&&(l&&n.type&&!l.parentNode&&(l=$(n)),l=u.insertBefore(n.__e,l||null));do{l=l&&l.nextSibling}while(null!=l&&8==l.nodeType);return l}function F(n,l){return l=l||[],null==n||\"boolean\"==typeof n||(g(n)?n.some(function(n){F(n,l)}):l.push(n)),l}function O(n,l,u,t){var i,r,o,e=n.key,f=n.type,c=l[u],a=null!=c&&0==(2&c.__u);if(null===c&&null==e||a&&e==c.key&&f==c.type)return u;if(t>(a?1:0))for(i=u-1,r=u+1;i>=0||r<l.length;)if(null!=(c=l[o=i>=0?i--:r++])&&0==(2&c.__u)&&e==c.key&&f==c.type)return o;return-1}function z(n,l,u){\"-\"==l[0]?n.setProperty(l,null==u?\"\":u):n[l]=null==u?\"\":\"number\"!=typeof u||_.test(l)?u:u+\"px\"}function N(n,l,u,t,i){var r,o;n:if(\"style\"==l)if(\"string\"==typeof u)n.style.cssText=u;else{if(\"string\"==typeof t&&(n.style.cssText=t=\"\"),t)for(l in t)u&&l in u||z(n.style,l,\"\");if(u)for(l in u)t&&u[l]==t[l]||z(n.style,l,u[l])}else if(\"o\"==l[0]&&\"n\"==l[1])r=l!=(l=l.replace(s,\"$1\")),o=l.toLowerCase(),l=o in n||\"onFocusOut\"==l||\"onFocusIn\"==l?o.slice(2):l.slice(2),n.l||(n.l={}),n.l[l+r]=u,u?t?u[a]=t[a]:(u[a]=h,n.addEventListener(l,r?v:p,r)):n.removeEventListener(l,r?v:p,r);else{if(\"http://www.w3.org/2000/svg\"==i)l=l.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(\"width\"!=l&&\"height\"!=l&&\"href\"!=l&&\"list\"!=l&&\"form\"!=l&&\"tabIndex\"!=l&&\"download\"!=l&&\"rowSpan\"!=l&&\"colSpan\"!=l&&\"role\"!=l&&\"popover\"!=l&&l in n)try{n[l]=null==u?\"\":u;break n}catch(n){}\"function\"==typeof u||(null==u||!1===u&&\"-\"!=l[4]?n.removeAttribute(l):n.setAttribute(l,\"popover\"==l&&1==u?\"\":u))}}function V(n){return function(u){if(this.l){var t=this.l[u.type+n];if(null==u[c])u[c]=h++;else if(u[c]<t[a])return;return t(l.event?l.event(u):u)}}}function q(n,u,t,i,r,o,e,f,c,a){var s,h,p,v,y,d,_,k,x,M,I,P,A,H,T,j,F=u.type;if(void 0!==u.constructor)return null;128&t.__u&&(c=!!(32&t.__u),o=[f=u.__e=t.__e]),(s=l.__b)&&s(u);n:if(\"function\"==typeof F){h=e.length;try{if(x=u.props,M=F.prototype&&F.prototype.render,I=(s=F.contextType)&&i[s.__c],P=s?I?I.props.value:s.__:i,t.__c?k=(p=u.__c=t.__c).__=p.__E:(M?u.__c=p=new F(x,P):(u.__c=p=new C(x,P),p.constructor=F,p.render=Q),I&&I.sub(p),p.state||(p.state={}),p.__n=i,v=p.__d=!0,p.__h=[],p._sb=[]),M&&null==p.__s&&(p.__s=p.state),M&&null!=F.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=m({},p.__s)),m(p.__s,F.getDerivedStateFromProps(x,p.__s))),y=p.props,d=p.state,p.__v=u,v)M&&null==F.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),M&&null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else{if(M&&null==F.getDerivedStateFromProps&&x!==y&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(x,P),u.__v==t.__v||!p.__e&&null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(x,p.__s,P)){u.__v!=t.__v&&(p.props=x,p.state=p.__s,p.__d=!1),u.__e=t.__e,u.__k=t.__k,u.__k.some(function(n){n&&(n.__=u)}),w.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&e.push(p),f=$(t);break n}null!=p.componentWillUpdate&&p.componentWillUpdate(x,p.__s,P),M&&null!=p.componentDidUpdate&&p.__h.push(function(){p.componentDidUpdate(y,d,_)})}if(p.context=P,p.props=x,p.__P=n,p.__e=!1,A=l.__r,H=0,M)p.state=p.__s,p.__d=!1,A&&A(u),s=p.render(p.props,p.state,p.context),w.push.apply(p.__h,p._sb),p._sb=[];else do{p.__d=!1,A&&A(u),s=p.render(p.props,p.state,p.context),p.state=p.__s}while(p.__d&&++H<25);p.state=p.__s,null!=p.getChildContext&&(i=m(m({},i),p.getChildContext())),M&&!v&&null!=p.getSnapshotBeforeUpdate&&(_=p.getSnapshotBeforeUpdate(y,d)),T=null!=s&&s.type===S&&null==s.key?E(s.props.children):s,f=L(n,g(T)?T:[T],u,t,i,r,o,e,f,c,a),p.base=u.__e,u.__u&=-161,p.__h.length&&e.push(p),k&&(p.__E=p.__=null)}catch(n){if(e.length=h,u.__v=null,c||null!=o){if(n.then){for(u.__u|=c?160:128;f&&8==f.nodeType&&f.nextSibling;)f=f.nextSibling;null!=o&&(o[o.indexOf(f)]=null),u.__e=f}else if(null!=o)for(j=o.length;j--;)b(o[j])}else u.__e=t.__e;null==u.__k&&(u.__k=t.__k||[]),n.then||B(u),l.__e(n,u,t)}}else null==o&&u.__v==t.__v?(u.__k=t.__k,u.__e=t.__e):f=u.__e=G(t.__e,u,t,i,r,o,e,c,a);return(s=l.diffed)&&s(u),128&u.__u?void 0:f}function B(n){n&&(n.__c&&(n.__c.__e=!0),n.__k&&n.__k.some(B))}function D(n,u,t){for(var i=0;i<t.length;i++)J(t[i],t[++i],t[++i]);l.__c&&l.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u)})}catch(n){l.__e(n,u.__v)}})}function E(n){return\"object\"!=typeof n||null==n||n.__b>0?n:g(n)?n.map(E):void 0!==n.constructor?null:m({},n)}function G(u,t,i,r,o,e,f,c,a){var s,h,p,v,y,w,_,m=i.props||d,k=t.props,x=t.type;if(\"svg\"==x?o=\"http://www.w3.org/2000/svg\":\"math\"==x?o=\"http://www.w3.org/1998/Math/MathML\":o||(o=\"http://www.w3.org/1999/xhtml\"),null!=e)for(s=0;s<e.length;s++)if((y=e[s])&&\"setAttribute\"in y==!!x&&(x?y.localName==x:3==y.nodeType)){u=y,e[s]=null;break}if(null==u){if(null==x)return document.createTextNode(k);u=document.createElementNS(o,x,k.is&&k),c&&(l.__m&&l.__m(t,e),c=!1),e=null}if(null==x)m===k||c&&u.data==k||(u.data=k);else{if(e=\"textarea\"==x&&null!=k.defaultValue?null:e&&n.call(u.childNodes),!c&&null!=e)for(m={},s=0;s<u.attributes.length;s++)m[(y=u.attributes[s]).name]=y.value;for(s in m)y=m[s],\"dangerouslySetInnerHTML\"==s?p=y:\"children\"==s||s in k||\"value\"==s&&\"defaultValue\"in k||\"checked\"==s&&\"defaultChecked\"in k||N(u,s,null,y,o);for(s in k)y=k[s],\"children\"==s?v=y:\"dangerouslySetInnerHTML\"==s?h=y:\"value\"==s?w=y:\"checked\"==s?_=y:c&&\"function\"!=typeof y||m[s]===y||N(u,s,y,m[s],o);if(h)c||p&&(h.__html==p.__html||h.__html==u.innerHTML)||(u.innerHTML=h.__html),t.__k=[];else if(p&&(u.innerHTML=\"\"),L(\"template\"==t.type?u.content:u,g(v)?v:[v],t,i,r,\"foreignObject\"==x?\"http://www.w3.org/1999/xhtml\":o,e,f,e?e[0]:i.__k&&$(i,0),c,a),null!=e)for(s=e.length;s--;)b(e[s]);c&&\"textarea\"!=x||(s=\"value\",\"progress\"==x&&null==w?u.removeAttribute(\"value\"):null!=w&&(w!==u[s]||\"progress\"==x&&!w||\"option\"==x&&w!=m[s])&&N(u,s,w,m[s],o),s=\"checked\",null!=_&&_!=u[s]&&N(u,s,_,m[s],o))}return u}function J(n,u,t){try{if(\"function\"==typeof n){var i=\"function\"==typeof n.__u;i&&n.__u(),i&&null==u||(n.__u=n(u))}else n.current=u}catch(n){l.__e(n,t)}}function K(n,u,t){var i,r;if(l.unmount&&l.unmount(n),(i=n.ref)&&(i.current&&i.current!=n.__e||J(i,null,u)),null!=(i=n.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(n){l.__e(n,u)}i.base=i.__P=i.__n=null}if(i=n.__k)for(r=0;r<i.length;r++)i[r]&&K(i[r],u,t||\"function\"!=typeof n.type);t||b(n.__e),n.__c=n.__=n.__e=void 0}function Q(n,l,u){return this.constructor(n,u)}function R(u,t,i){var r,o,e,f;t==document&&(t=document.documentElement),l.__&&l.__(u,t),o=(r=\"function\"==typeof i)?null:i&&i.__k||t.__k,e=[],f=[],q(t,u=(!r&&i||t).__k=k(S,null,[u]),o||d,d,t.namespaceURI,!r&&i?[i]:o?null:t.firstChild?n.call(t.childNodes):null,e,!r&&i?i:o?o.__e:t.firstChild,r,f),D(e,u,f),u.props.children=null}function U(n,l){R(n,l,U)}function W(l,u,t){var i,r,o,e,f=m({},l.props);for(o in l.type&&l.type.defaultProps&&(e=l.type.defaultProps),u)\"key\"==o?i=u[o]:\"ref\"==o?r=u[o]:f[o]=void 0===u[o]&&null!=e?e[o]:u[o];return arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):t),x(l.type,f,i||l.key,r||l.ref,null)}function X(n){function l(n){var u,t;return this.getChildContext||(u=new Set,(t={})[l.__c]=this,this.getChildContext=function(){return t},this.componentWillUnmount=function(){u=null},this.shouldComponentUpdate=function(n){this.props.value!=n.value&&u.forEach(function(n){n.__e=!0,A(n)})},this.sub=function(n){u.add(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u&&u.delete(n),l&&l.call(n)}}),n.children}return l.__c=\"__cC\"+y++,l.__=n,l.Provider=l.__l=(l.Consumer=function(n,l){return n.children(l)}).contextType=l,l}n=w.slice,l={__e:function(n,l,u,t){for(var i,r,o;l=l.__;)if((i=l.__c)&&!i.__)try{if((r=i.constructor)&&null!=r.getDerivedStateFromError&&(i.setState(r.getDerivedStateFromError(n)),o=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(n,t||{}),o=i.__d),o)return i.__E=i}catch(l){n=l}throw n}},u=0,t=function(n){return null!=n&&void 0===n.constructor},C.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=m({},this.state),\"function\"==typeof n&&(n=n(m({},u),this.props)),n&&m(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),A(this))},C.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),A(this))},C.prototype.render=S,i=[],o=\"function\"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,e=function(n,l){return n.__v.__b-l.__v.__b},H.__r=0,f=Math.random().toString(8),c=\"__d\"+f,a=\"__a\"+f,s=/(PointerCapture)$|Capture$/i,h=0,p=V(!1),v=V(!0),y=0;export{C as Component,S as Fragment,W as cloneElement,X as createContext,k as createElement,M as createRef,k as h,U as hydrate,t as isValidElement,l as options,R as render,F as toChildArray};\n//# sourceMappingURL=preact.module.js.map\n","import{options as n}from\"preact\";var t,r,u,i,o=0,f=[],c=n,e=c.__b,a=c.__r,v=c.diffed,l=c.__c,m=c.unmount,p=c.__;function s(n,t){c.__h&&c.__h(r,n,o||t),o=0;var u=r.__H||(r.__H={__:[],__h:[]});return n>=u.__.length&&u.__.push({}),u.__[n]}function d(n){return o=1,y(D,n)}function y(n,u,i){var o=s(t++,2);if(o.t=n,!o.__c&&(o.__=[i?i(u):D(void 0,u),function(n){var t=o.__N?o.__N[0]:o.__[0],r=o.t(t,n);t!==r&&(o.__N=[r,o.__[1]],o.__c.setState({}))}],o.__c=r,!r.__f)){var f=function(n,t,r){if(!o.__c.__H)return!0;var u=!1,i=o.__c.props!==n;if(o.__c.__H.__.some(function(n){if(n.__N){u=!0;var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(i=!0)}}),c){var f=c.call(this,n,t,r);return u?f||i:f}return!u||i};r.__f=!0;var c=r.shouldComponentUpdate,e=r.componentWillUpdate;r.componentWillUpdate=function(n,t,r){if(this.__e){var u=c;c=void 0,f(n,t,r),c=u}e&&e.call(this,n,t,r)},r.shouldComponentUpdate=f}return o.__N||o.__}function h(n,u){var i=s(t++,3);!c.__s&&C(i.__H,u)&&(i.__=n,i.u=u,r.__H.__h.push(i))}function _(n,u){var i=s(t++,4);!c.__s&&C(i.__H,u)&&(i.__=n,i.u=u,r.__h.push(i))}function A(n){return o=5,T(function(){return{current:n}},[])}function F(n,t,r){o=6,_(function(){if(\"function\"==typeof n){var r=n(t());return function(){n(null),r&&\"function\"==typeof r&&r()}}if(n)return n.current=t(),function(){return n.current=null}},null==r?r:r.concat(n))}function T(n,r){var u=s(t++,7);return C(u.__H,r)&&(u.__=n(),u.__H=r,u.__h=n),u.__}function q(n,t){return o=8,T(function(){return n},t)}function x(n){var u=r.context[n.__c],i=s(t++,9);return i.c=n,u?(null==i.__&&(i.__=!0,u.sub(r)),u.props.value):n.__}function P(n,t){c.useDebugValue&&c.useDebugValue(t?t(n):n)}function b(n){var u=s(t++,10),i=d();return u.__=n,r.componentDidCatch||(r.componentDidCatch=function(n,t){u.__&&u.__(n,t),i[1](n)}),[i[0],function(){i[1](void 0)}]}function g(){var n=s(t++,11);if(!n.__){for(var u=r.__v;null!==u&&!u.__m&&null!==u.__;)u=u.__;var i=u.__m||(u.__m=[0,0]);n.__=\"P\"+i[0]+\"-\"+i[1]++}return n.__}function j(){for(var n;n=f.shift();){var t=n.__H;if(n.__P&&t)try{t.__h.some(z),t.__h.some(B),t.__h=[]}catch(r){t.__h=[],c.__e(r,n.__v)}}}c.__b=function(n){r=null,e&&e(n)},c.__=function(n,t){n&&t.__k&&t.__k.__m&&(n.__m=t.__k.__m),p&&p(n,t)},c.__r=function(n){a&&a(n),t=0;var i=(r=n.__c).__H;i&&(u===r?(i.__h=[],r.__h=[],i.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(i.__h.some(z),i.__h.some(B),i.__h=[],t=0)),u=r},c.diffed=function(n){v&&v(n);var t=n.__c;t&&t.__H&&(t.__H.__h.length&&(1!==f.push(t)&&i===c.requestAnimationFrame||((i=c.requestAnimationFrame)||w)(j)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),u=r=null},c.__c=function(n,t){t.some(function(n){try{n.__h.some(z),n.__h=n.__h.filter(function(n){return!n.__||B(n)})}catch(r){t.some(function(n){n.__h&&(n.__h=[])}),t=[],c.__e(r,n.__v)}}),l&&l(n,t)},c.unmount=function(n){m&&m(n);var t,r=n.__c;r&&r.__H&&(r.__H.__.some(function(n){try{z(n)}catch(n){t=n}}),r.__H=void 0,t&&c.__e(t,r.__v))};var k=\"function\"==typeof requestAnimationFrame;function w(n){var t,r=function(){clearTimeout(u),k&&cancelAnimationFrame(t),setTimeout(n)},u=setTimeout(r,35);k&&(t=requestAnimationFrame(r))}function z(n){var t=r,u=n.__c;\"function\"==typeof u&&(n.__c=void 0,u()),r=t}function B(n){var t=r;n.__c=n.__(),r=t}function C(n,t){return!n||n.length!==t.length||t.some(function(t,r){return t!==n[r]})}function D(n,t){return\"function\"==typeof t?t(n):t}export{q as useCallback,x as useContext,P as useDebugValue,h as useEffect,b as useErrorBoundary,g as useId,F as useImperativeHandle,_ as useLayoutEffect,T as useMemo,y as useReducer,A as useRef,d as useState};\n//# sourceMappingURL=hooks.module.js.map\n","/**\n * Page context: reading an `{ id, name }` entry and shaping it for the wire.\n *\n * A host object can be named in two ways. Its id alone, under a flat key\n * (`orderId: 'ORD-1'`), or the named object under the entity key\n * (`order: { id: 'ORD-1', name: 'Order #1042' }`). The second form exists for\n * display: the chip shows \"Order #1042\" instead of a UUID, and the host is the\n * only one knowing that name without calling the API.\n *\n * On the wire the agent only reads strings, so `wireContext` splits every named\n * object into `<key>Id` + `<key>Name` right before sending. Keeping a single\n * shape on the network makes the request identical however the host filled its\n * context in.\n *\n * Nothing here is domain-specific: the widget has no list of known entities, it\n * only recognises the `{ id, name }` shape wherever the host used it.\n */\nimport type { ChatbotContext, ContextObject } from '../types'\n\n/** Keys the widget owns and never treats as a host object. */\nconst RESERVED_KEYS = new Set<string>(['sessionId'])\n\n/**\n * Reads a context entry, named object or bare id.\n *\n * Returns `undefined` when it carries no usable id — empty string, object with\n * no `id`: \"nothing selected\", not \"something named nowhere\".\n */\nexport function contextObject(value: unknown): ContextObject | undefined {\n if (typeof value === 'string') {\n return value.length > 0 ? { id: value } : undefined\n }\n if (!value || typeof value !== 'object' || Array.isArray(value)) return undefined\n const { id, name } = value as { id?: unknown; name?: unknown }\n if (typeof id !== 'string' || id.length === 0) return undefined\n return typeof name === 'string' && name.length > 0 ? { id, name } : { id }\n}\n\n/** What a chip displays: the name when the host gave one, the id otherwise. */\nexport function contextLabel(value: unknown): string | undefined {\n const object = contextObject(value)\n if (!object) return undefined\n return object.name ?? object.id\n}\n\n/** Whether an entry carries a named object (`{ id, name? }`) rather than a\n * plain value — the shape the chips and the wire format are built on. */\nexport function isNamedObject(value: unknown): boolean {\n return Boolean(value) && typeof value === 'object' && !Array.isArray(value)\n}\n\n/**\n * Puts the context in the shape the agent reads: `order: { id, name }` becomes\n * `orderId` + `orderName`.\n *\n * Everything else goes through untouched — `sessionId`, an already flat\n * `orderId`, or any free key of the host: the widget does not filter the\n * context, it only translates what it knows how to translate.\n */\nexport function wireContext(context: ChatbotContext): Record<string, unknown> {\n const wire: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(context)) {\n if (RESERVED_KEYS.has(key) || !isNamedObject(value)) {\n wire[key] = value\n continue\n }\n const object = contextObject(value)\n // An empty named key is not sent: it would claim something is selected.\n if (!object) continue\n wire[`${key}Id`] = object.id\n if (object.name) wire[`${key}Name`] = object.name\n }\n return wire\n}\n","/**\n * Every user-facing string of the widget, one bundle per supported language.\n *\n * The host picks the language with a single `locale` prop (`en`, `en-GB`,\n * `fr`, `es-ES`…): its primary subtag selects the bundle, and the tag itself is\n * kept as-is for `Intl` — a `fr-CA` host gets the French copy with Canadian date\n * formatting, which is what a BCP-47 tag means. Declaring nothing reads the\n * browser's own languages instead (`resolveLocale`). An unsupported language\n * falls back to `DEFAULT_LANGUAGE` rather than showing keys.\n *\n * Adding a string means adding it to **every** bundle — the `Strings` type makes\n * that a compile error, not a runtime blank.\n */\n\nexport type LanguageCode = 'en' | 'fr' | 'es'\n\nexport const DEFAULT_LANGUAGE: LanguageCode = 'en'\n\n/** Shipped languages, in the order they are documented. Published so a host can\n * offer its users only the locales the widget really speaks. */\nexport const SUPPORTED_LANGUAGES: readonly LanguageCode[] = ['en', 'fr', 'es']\n\n/** Labels of the context chips shown under the header. The chip titles\n * themselves come from the host's own context keys — the widget knows no\n * domain entity. */\nexport interface ContextStrings {\n /** Accessible name of the chip row. */\n region: string\n}\n\nexport interface Strings {\n heading: string\n subheading: string\n placeholder: string\n greeting: string\n /** Permanent reminder under the composer: a write is proposed, never applied\n * on its own. */\n hint: string\n /** Byline of an assistant message. */\n assistant: string\n /** Accessible name of the three-dot indicator while the answer is streaming. */\n typing: string\n newConversation: string\n close: string\n /** Shorter form, for the `title` tooltip. */\n closeTitle: string\n history: {\n /** The header icon opening the menu. */\n open: string\n /** Accessible name of the menu itself. */\n menu: string\n loading: string\n empty: string\n /** Stands in until the agent has generated a title for the session. */\n untitled: string\n }\n context: ContextStrings\n approval: {\n group: string\n approve: string\n reject: string\n /** Said in the agent's place when it asked for a tool without a word about\n * it: `{tool}` is the name of what it would use. */\n request: string\n /** Heading of the values the tool would be called with. */\n arguments: string\n edit: string\n /** Placeholder of the correction field. */\n correction: string\n correctionLabel: string\n send: string\n }\n confirm: {\n group: string\n yes: string\n no: string\n /** What clicking sends to the agent — a bare \"yes\" is recognised without a\n * model call, so it has to be the word of the user's own language. */\n yesValue: string\n noValue: string\n }\n /** Accessible name of a Markdown checkbox group turned into buttons. */\n choices: string\n /** The footer link a plan that carries our name shows. */\n poweredBy: string\n /** The agents a visitor may address by name, where an application holds several. */\n handles: {\n /** Accessible name of the list `@` opens in the composer. */\n picker: string\n /** Said above the name a message addressed and nobody answers to. The handle\n * itself is rendered beside it, so no sentence needs a placeholder. */\n unknown: string\n /** Introduces the handles that do answer, when the organization offers any. */\n instead: string\n }\n /** A question the agent stopped its turn on, answered by ticking options. */\n selection: {\n /** Accessible name of the option group. */\n group: string\n /** Shown under a single-answer question: one click answers it. */\n single: string\n /** Shown under a multi-answer one: several ticks, one validate. */\n multiple: string\n /** The button that sends what has been ticked. */\n validate: string\n }\n composer: {\n label: string\n send: string\n sendTitle: string\n stop: string\n stopTitle: string\n /** Accessible name of the paperclip, and of the cross on each chip. */\n attach: string\n attachTitle: string\n /** Takes the file's name: \"Remove {name}\". */\n remove: string\n }\n /** What a refused upload means, in the terms of whoever chose the file. */\n attachments: {\n unsupported: string\n tooLarge: string\n tooMany: string\n unreadable: string\n failed: string\n }\n /** Shown in the bubble when a turn failed — the real cause goes to\n * `chatbot-error` and the console, not to the user. */\n error: string\n /** Under the transcript once an agent handed the conversation to a human. */\n withHuman: string\n}\n\nconst EN: Strings = {\n heading: 'Assistant',\n subheading: 'Squadico',\n placeholder: 'Ask your question…',\n greeting: 'Hello! I am your assistant. What would you like to do?',\n hint: 'The assistant proposes an action; nothing is applied without your confirmation.',\n assistant: 'Assistant',\n typing: 'The assistant is writing its answer',\n newConversation: 'New conversation',\n close: 'Close the assistant',\n closeTitle: 'Close',\n history: {\n open: 'Conversation history',\n menu: 'Previous conversations',\n loading: 'Loading…',\n empty: 'No previous conversation.',\n untitled: 'Conversation',\n },\n context: {\n region: 'Context sent to the assistant',\n },\n approval: {\n group: 'Write confirmation',\n approve: 'Yes, apply',\n reject: 'No, cancel',\n request: 'The agent wants to use {tool}.',\n arguments: 'With',\n edit: 'Change…',\n correction: 'What to change — e.g. “the due date is next Monday”',\n correctionLabel: 'Correction to make before approving',\n send: 'Send',\n },\n confirm: {\n group: 'Confirmation',\n yes: 'Yes',\n no: 'No',\n yesValue: 'yes',\n noValue: 'no',\n },\n choices: 'Suggested options',\n poweredBy: 'Powered by Squadico',\n handles: {\n picker: 'Agents you can address',\n unknown: 'Nobody answers to that name here:',\n instead: 'You can address:',\n },\n selection: {\n group: 'Suggested choice',\n single: 'Pick one option.',\n multiple: 'Pick one or more options, then validate.',\n validate: 'Validate',\n },\n composer: {\n label: 'Your message',\n send: 'Send the message',\n sendTitle: 'Send',\n stop: 'Stop the answer',\n stopTitle: 'Stop',\n attach: 'Attach a file',\n attachTitle: 'Attach',\n remove: 'Remove {name}',\n },\n attachments: {\n unsupported: 'This kind of file cannot be attached to a message.',\n tooLarge: 'This file is too large.',\n tooMany: 'This message already carries as many files as it may.',\n unreadable: 'This file could not be read.',\n failed: 'This file could not be attached.',\n },\n error: 'Something went wrong, the assistant could not answer. Try again in a moment.',\n withHuman: 'A member of the team will reply to you here.',\n}\n\nconst FR: Strings = {\n heading: 'Assistant',\n subheading: 'Squadico',\n placeholder: 'Posez votre question…',\n greeting: 'Bonjour ! Je suis votre assistant. Que souhaitez-vous faire ?',\n hint: \"L'assistant propose une action ; rien n'est appliqué sans votre confirmation.\",\n assistant: 'Assistant',\n typing: \"L'assistant rédige sa réponse\",\n newConversation: 'Nouvelle conversation',\n close: \"Fermer l'assistant\",\n closeTitle: 'Fermer',\n history: {\n open: 'Historique des conversations',\n menu: 'Conversations précédentes',\n loading: 'Chargement…',\n empty: 'Aucune conversation précédente.',\n untitled: 'Conversation',\n },\n context: {\n region: \"Contexte transmis à l'assistant\",\n },\n approval: {\n group: \"Validation de l'écriture\",\n approve: 'Oui, appliquer',\n reject: 'Non, annuler',\n request: \"L'agent souhaite utiliser {tool}.\",\n arguments: 'Avec',\n edit: 'Modifier…',\n correction: \"Ce qu'il faut changer — ex. « l'échéance est lundi prochain »\",\n correctionLabel: 'Correction à apporter avant validation',\n send: 'Envoyer',\n },\n confirm: {\n group: 'Confirmation',\n yes: 'Oui',\n no: 'Non',\n yesValue: 'oui',\n noValue: 'non',\n },\n choices: 'Options proposées',\n poweredBy: 'Propulsé par Squadico',\n handles: {\n picker: 'Agents que vous pouvez adresser',\n unknown: 'Personne ne répond à ce nom ici :',\n instead: 'Vous pouvez adresser :',\n },\n selection: {\n group: 'Choix proposé',\n single: 'Sélectionnez une option.',\n multiple: 'Sélectionnez une ou plusieurs options, puis validez.',\n validate: 'Valider',\n },\n composer: {\n label: 'Votre message',\n send: 'Envoyer le message',\n sendTitle: 'Envoyer',\n stop: 'Interrompre la réponse',\n stopTitle: 'Interrompre',\n attach: 'Joindre un fichier',\n attachTitle: 'Joindre',\n remove: 'Retirer {name}',\n },\n attachments: {\n unsupported: 'Ce format de fichier ne peut pas être joint à un message.',\n tooLarge: 'Ce fichier est trop volumineux.',\n tooMany: \"Ce message porte déjà autant de fichiers qu'il le peut.\",\n unreadable: \"Ce fichier n'a pas pu être lu.\",\n failed: 'Impossible de joindre ce fichier.',\n },\n error: \"Une erreur est survenue, l'assistant n'a pas pu répondre. Réessayez dans un instant.\",\n withHuman: \"Un membre de l'équipe va vous répondre ici.\",\n}\n\nconst ES: Strings = {\n heading: 'Asistente',\n subheading: 'Squadico',\n placeholder: 'Haga su pregunta…',\n greeting: '¡Hola! Soy su asistente. ¿Qué desea hacer?',\n hint: 'El asistente propone una acción; no se aplica nada sin su confirmación.',\n assistant: 'Asistente',\n typing: 'El asistente está redactando su respuesta',\n newConversation: 'Nueva conversación',\n close: 'Cerrar el asistente',\n closeTitle: 'Cerrar',\n history: {\n open: 'Historial de conversaciones',\n menu: 'Conversaciones anteriores',\n loading: 'Cargando…',\n empty: 'Ninguna conversación anterior.',\n untitled: 'Conversación',\n },\n context: {\n region: 'Contexto enviado al asistente',\n },\n approval: {\n group: 'Validación de la escritura',\n approve: 'Sí, aplicar',\n reject: 'No, cancelar',\n request: 'El agente quiere usar {tool}.',\n arguments: 'Con',\n edit: 'Modificar…',\n correction: 'Lo que hay que cambiar — p. ej. «el vencimiento es el lunes»',\n correctionLabel: 'Corrección antes de validar',\n send: 'Enviar',\n },\n confirm: {\n group: 'Confirmación',\n yes: 'Sí',\n no: 'No',\n yesValue: 'sí',\n noValue: 'no',\n },\n choices: 'Opciones propuestas',\n poweredBy: 'Con la tecnología de Squadico',\n handles: {\n picker: 'Agentes a los que puedes dirigirte',\n unknown: 'Nadie responde a ese nombre aquí:',\n instead: 'Puedes dirigirte a:',\n },\n selection: {\n group: 'Opción propuesta',\n single: 'Seleccione una opción.',\n multiple: 'Seleccione una o varias opciones y valide.',\n validate: 'Validar',\n },\n composer: {\n label: 'Su mensaje',\n send: 'Enviar el mensaje',\n sendTitle: 'Enviar',\n stop: 'Interrumpir la respuesta',\n stopTitle: 'Interrumpir',\n attach: 'Adjuntar un archivo',\n attachTitle: 'Adjuntar',\n remove: 'Quitar {name}',\n },\n attachments: {\n unsupported: 'Este tipo de archivo no se puede adjuntar a un mensaje.',\n tooLarge: 'Este archivo es demasiado grande.',\n tooMany: 'Este mensaje ya lleva todos los archivos que puede llevar.',\n unreadable: 'No se ha podido leer este archivo.',\n failed: 'No se ha podido adjuntar este archivo.',\n },\n error: 'Se ha producido un error, el asistente no ha podido responder. Inténtelo de nuevo.',\n withHuman: 'Un miembro del equipo le responderá aquí.',\n}\n\nconst BUNDLES: Record<LanguageCode, Strings> = { en: EN, fr: FR, es: ES }\n\n/** Default `Intl` tag per language, used when the host named a language only. */\nconst TAGS: Record<LanguageCode, string> = { en: 'en-GB', fr: 'fr-FR', es: 'es-ES' }\n\n/** A resolved locale: the copy to render, and the tag to format dates with. */\nexport interface Locale {\n code: LanguageCode\n /** BCP-47 tag handed to `Intl` — the host's own when it gave one. */\n tag: string\n t: Strings\n}\n\n/** The bundle a tag names, or `undefined` when the language is not shipped. */\nfunction supported(locale: string | undefined): LanguageCode | undefined {\n const primary = locale?.trim().toLowerCase().split(/[-_]/)[0]\n return primary && primary in BUNDLES ? (primary as LanguageCode) : undefined\n}\n\nexport function resolveLanguage(locale: string | undefined): LanguageCode {\n return supported(locale) ?? DEFAULT_LANGUAGE\n}\n\n/**\n * Languages the browser announces, most preferred first.\n *\n * `navigator.languages` is the ordered list of the user's own preferences —\n * `navigator.language` alone is only its first entry, so a user whose Chrome is\n * in English but who also reads Spanish would never reach the Spanish bundle\n * through it. Absent server-side (SSR of a host importing the package), where\n * there is no user to have preferences.\n */\nfunction browserLocales(): readonly string[] {\n if (typeof navigator === 'undefined') return []\n return navigator.languages?.length ? navigator.languages : [navigator.language]\n}\n\n/**\n * Locale to render with.\n *\n * `locale` is what the host declared (attribute or prop) and it is a decision:\n * a regioned tag of a supported language keeps its region for `Intl` (`fr-CA`),\n * a bare language takes the bundle's own tag, and an unsupported one falls back\n * to `DEFAULT_LANGUAGE` — copy *and* tag, since English copy dated in Portuguese\n * would read as a bug rather than as a fallback. The browser is not consulted\n * then: a host naming a language has its reasons (the user's own account\n * setting, most likely), and the browser would silently overrule them.\n *\n * Declaring nothing is the case this exists for: the user's browser languages\n * are read in their own order, and the first one the widget speaks wins — a\n * Spanish-speaking user gets a Spanish panel without their front having to know\n * the widget ships Spanish at all. None supported, or no browser to ask:\n * `DEFAULT_LANGUAGE`.\n */\nexport function resolveLocale(locale: string | undefined): Locale {\n const declared = locale?.trim()\n const candidates = declared ? [declared] : browserLocales()\n const tag = candidates.find(supported)\n const code = supported(tag) ?? DEFAULT_LANGUAGE\n return { code, tag: tag?.includes('-') ? tag : TAGS[code], t: BUNDLES[code] }\n}\n","/**\n * Remembers whether the user left the panel open or closed, so a reload or a\n * navigation to another page of the host app does not silently undo their last\n * gesture — closing an assistant that reopens itself on the next screen, or\n * losing an open conversation to a route change.\n *\n * `sessionStorage`, not the `localStorage` `useChat` uses for the \"new\n * conversation\" gesture: this is transient UI state belonging to one tab.\n * Reopening the app tomorrow, or in a second tab, starts from the host's own\n * default rather than from a gesture made in another browsing session; the\n * conversation is still there, one click away.\n */\n\n/** One panel state per host origin — enough as long as a page mounts a single\n * widget, which is the case for every current integrator. */\nconst OPEN_STORAGE_KEY = 'squadico-chatbot:open'\n\n/** `undefined` when nothing was ever stored, or storage is unusable — which is\n * distinct from a stored `false` (the user closed the panel) and is what lets\n * a host's `defaultOpen` still apply on a first visit. */\nfunction readOpenState(): boolean | undefined {\n try {\n if (typeof sessionStorage === 'undefined') return undefined\n const raw = sessionStorage.getItem(OPEN_STORAGE_KEY)\n if (raw === '1') return true\n if (raw === '0') return false\n return undefined\n } catch {\n // Storage unavailable (private browsing, blocked cookies…): the panel state\n // stays volatile, as it was before this persistence existed.\n return undefined\n }\n}\n\nexport function writeOpenState(open: boolean): void {\n try {\n if (typeof sessionStorage === 'undefined') return\n sessionStorage.setItem(OPEN_STORAGE_KEY, open ? '1' : '0')\n } catch {\n /* see readOpenState */\n }\n}\n\n/**\n * Resolves the state the panel mounts in.\n *\n * A remembered gesture wins over `defaultOpen`, which is a *default*: the host\n * declares where a first-time visitor starts, the user decides afterwards.\n * A host that needs the panel open on every load calls `openChat()` instead.\n *\n * Shared by both wrappers: `src/react.tsx` applies `defaultOpen` imperatively\n * after mount, so it has to arbitrate the same way or it would reopen a panel\n * the user had closed.\n */\nexport function initialOpen(defaultOpen?: boolean, persist?: boolean): boolean {\n if (persist === false) return defaultOpen ?? false\n return readOpenState() ?? defaultOpen ?? false\n}\n","/**\n * UUID v4. `crypto.randomUUID` only exists in a secure context (https or\n * localhost): the two fallbacks cover an integration served over http:// on a\n * LAN IP, a common staging setup. The API validates `sessionId` as a UUID, so\n * the format has to stay strictly conformant.\n */\nexport function uuid(): string {\n const c = globalThis.crypto as Crypto | undefined\n\n if (c && typeof c.randomUUID === 'function') {\n return c.randomUUID()\n }\n\n const bytes = new Uint8Array(16)\n if (c && typeof c.getRandomValues === 'function') {\n c.getRandomValues(bytes)\n } else {\n for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256)\n }\n // Force version 4 and the RFC 4122 variant.\n bytes[6] = (bytes[6] & 0x0f) | 0x40\n bytes[8] = (bytes[8] & 0x3f) | 0x80\n\n const hex: string[] = []\n for (let i = 0; i < 16; i++) hex.push(bytes[i].toString(16).padStart(2, '0'))\n return (\n hex.slice(0, 4).join('') +\n '-' +\n hex.slice(4, 6).join('') +\n '-' +\n hex.slice(6, 8).join('') +\n '-' +\n hex.slice(8, 10).join('') +\n '-' +\n hex.slice(10, 16).join('')\n )\n}\n","/**\n * HTTP client of the Squadico public API.\n *\n * Four calls, and they are the routes the backend actually serves:\n * - `openConversation` → `POST /public/applications/{embedKey}/conversations`\n * - `replayConversation` → `GET /public/conversations/{id}`\n * - `sendMessage` → `POST /public/conversations/{id}/messages` (SSE)\n * - `resolveApproval` → `POST /public/conversations/{id}/approvals` (SSE)\n *\n * **The widget authenticates nobody.** It is the public surface: the embed key says\n * which application, and the visitor token handed back at open is the whole of the\n * authorization afterwards. The token travels in a header and never in a cookie —\n * third-party cookies are blocked or on their way out, and a header cannot be sent\n * ambiently, which removes CSRF as a class.\n *\n * **The server names the conversation.** Its id comes back from the open call: a\n * visitor allowed to name their own conversation is a visitor choosing which one to\n * read.\n *\n * **The author claim travels once, at open.** A panel has one person in front of it,\n * so one claim per conversation is auditable while one per message would be an\n * annotation anybody could change halfway through. It is attribution and never\n * authorization: what a visitor may read is decided by their token.\n *\n * **Everything is streamed the same way.** Four frame types — `token`, `done`,\n * `error`, `approval_required` — for a fresh question and for a resumed approval\n * alike, plus three a team adds: `handoff` (another agent of the team answers\n * from here, and signs the `done` that follows), `escalated` (the agent handed the\n * conversation to a human) and `held` (a human handles it: the message was kept\n * for them and nothing answers). `done` carries the stored turn (the one a reload would show), on a surface\n * that can hold several agents which one answered, and — when the message addressed\n * a name nobody answers to — that name with the ones that do. That last one is a\n * hint beside an answer and never a refusal: the default agent replied, because a\n * visitor typing `@sale` should get help rather than a 404.\n *\n * **A handle is never routed from here.** The message text is what the server\n * parses, so the picker and the `agent` option both work by putting a handle in\n * front of what somebody types. A client naming its own agent would be a client\n * choosing its own router.\n *\n * No dependency: `fetch` + `ReadableStream`, available everywhere the widget runs.\n */\nimport type {\n AgentHandle,\n ChatAttachment,\n ChatMessage,\n ChatRole,\n PendingApproval,\n} from '../types'\nimport { uuid } from './uid'\n\n/** The Squadico API, written in at build time (`config/api-url.ts`). Not an\n * option: a page embedding the widget does not choose the server it talks to. */\nexport const API_URL: string = __SQUADICO_API_URL__\n\n/** Aligned on `MESSAGE_MAX_LENGTH` in the API's own schema: a message longer than\n * this is a 422 from the form rather than a 400 from a vendor at the first token. */\nexport const MAX_MESSAGE_LENGTH = 20_000\n\nexport class ChatHttpError extends Error {\n readonly status?: number\n /** The API's machine-readable name for the refusal, when it sent one.\n *\n * What a panel branches on: `origin_not_allowed` means stop embedding,\n * `application_has_no_agent` means nothing answers there yet, and\n * `conversation_retired` means open a new conversation. Three reactions a bare\n * status cannot tell apart. */\n readonly code?: string\n\n constructor(message: string, status?: number, code?: string) {\n super(message)\n this.name = 'ChatHttpError'\n this.status = status\n this.code = code\n }\n}\n\nexport interface HostUser {\n id: string\n name?: string\n /** The HMAC the host's *server* computed over `id`, where the application asks\n * for one. Never computed in the page: a digest a browser can produce is a\n * digest anybody can produce, and the secret would be in the page's source. */\n digest?: string\n}\n\nexport interface OpenConversationInit {\n apiUrl: string\n embedKey: string\n /** Who the embedding application has signed in, when it has anybody. */\n user?: HostUser\n /** The handle the page wants to open on. Unknown here opens on the default rather\n * than refusing: a page carrying a renamed handle must keep working. */\n agent?: string\n signal?: AbortSignal\n}\n\n/** What opening a panel answers with. */\nexport interface OpenedConversation {\n conversationId: string\n visitorToken: string\n /** The agent that answers a message addressing nobody. */\n agentName: string\n agentSlug: string\n welcomeMessage?: string\n /** The transcript as it stands — the welcome message, on a fresh conversation. */\n messages: ChatMessage[]\n /** The handles this application offers, which is empty until somebody ticks one. */\n handles: AgentHandle[]\n /** The handle the conversation really opened on — which may not be the one that\n * was asked for, if the server fell back to the default. */\n agentHandle?: string\n /** A human of the organization handles it: no agent answers, and the panel\n * reads the conversation again to show their replies. */\n withHuman?: boolean\n /** Whether the panel shows \"Powered by Squadico\" — the organization's plan says. */\n branding: boolean\n}\n\nexport interface ReplayConversationInit {\n apiUrl: string\n conversationId: string\n visitorToken: string\n signal?: AbortSignal\n}\n\nexport interface SendMessageInit {\n apiUrl: string\n conversationId: string\n visitorToken: string\n message: string\n /** The files this question carries, named rather than implied: anything else\n * the conversation is still holding stays where it is. */\n attachmentIds?: string[]\n /** What the page knows about where the visitor is. Sent as data, never as\n * instructions — see `ChatbotContext`. */\n context?: Record<string, unknown>\n /** The access token the host site holds for its signed-in user — see\n * `getSubjectToken` on the props. */\n subjectToken?: string\n onToken: (token: string) => void\n signal?: AbortSignal\n}\n\nexport interface ResolveApprovalInit {\n apiUrl: string\n conversationId: string\n visitorToken: string\n /** The call the panel is answering for. Checked against what the conversation is\n * actually waiting on, so a stale decision is refused rather than resuming the\n * wrong thing. */\n toolCallId: string\n approved: boolean\n subjectToken?: string\n onToken: (token: string) => void\n signal?: AbortSignal\n}\n\n/** What a turn produced: the stored answer, who wrote it, and what it stopped on. */\nexport interface ChatTurn {\n answer: string\n /** Which agent answered, on a surface that can hold several. */\n agent?: AgentHandle\n /** Set when the turn paused: one tool call is waiting on a decision, and nothing\n * has been written until one is sent. */\n approval?: PendingApproval\n /** The name the message addressed and nobody on this application answers to. The\n * answer came from the default agent all the same. */\n unknownHandle?: string\n /** The handles that *do* answer, to say instead of the mistyped one. Empty when\n * the organization has ticked none — the panel then says only that nobody\n * answers to that name. */\n offered?: AgentHandle[]\n /** The agent the conversation was passed to during this turn, when it has no\n * handle on the application to be announced by — what signs its answer. */\n authorName?: string\n /** The agent handed the conversation to a human of the organization, or one\n * already handles it: no agent answers what comes next. */\n withHuman?: boolean\n /** The message was kept for the human handling the conversation; no agent ran,\n * so there is no answer to draw. */\n held?: boolean\n}\n\ninterface ApiMessage {\n id?: unknown\n role?: unknown\n content?: unknown\n agent?: unknown\n attachments?: unknown\n created_at?: unknown\n kind?: unknown\n author_name?: unknown\n}\n\ninterface ApiAttachment {\n id?: unknown\n kind?: unknown\n filename?: unknown\n content_type?: unknown\n}\n\nfunction endpoint(apiUrl: string, path: string): string {\n return `${apiUrl.replace(/\\/+$/, '')}${path}`\n}\n\nfunction headers(visitorToken?: string, subjectToken?: string): HeadersInit {\n return {\n 'Content-Type': 'application/json',\n Accept: 'text/event-stream, application/json',\n ...(visitorToken ? { 'X-Visitor-Token': visitorToken } : {}),\n ...(subjectToken ? { 'X-Subject-Token': subjectToken } : {}),\n }\n}\n\n/**\n * One validation problem, as FastAPI writes it: where it is, and what is wrong.\n *\n * `loc` is the path to the field, `body` first — the last segment is the name an\n * integrator recognises.\n */\nfunction readProblem(entry: unknown): string | undefined {\n if (!entry || typeof entry !== 'object') return undefined\n const { loc, msg } = entry as { loc?: unknown; msg?: unknown }\n if (typeof msg !== 'string' || !msg) return undefined\n const path = Array.isArray(loc) ? loc.filter((part) => typeof part === 'string') : []\n const field = path.at(-1)\n return field && field !== 'body' ? `${field}: ${msg}` : msg\n}\n\n/**\n * The API answers its refusals as `{ detail, code }`; a proxy in front of it may\n * answer `{ message }`. Both are read, because a bare HTTP status is what makes an\n * integration undiagnosable — and the `code` is what a panel reacts to.\n *\n * A validation refusal answers a *list* of problems, one per field. Joined as\n * objects it reads \"[object Object]\" in a console, which is the difference between\n * a five-minute fix and an afternoon — so each one is rendered as the field it is\n * about and what it says.\n */\nasync function readError(response: Response): Promise<ChatHttpError> {\n let detail = ''\n let code: string | undefined\n try {\n const text = await response.text()\n if (text) {\n try {\n const parsed = JSON.parse(text) as {\n detail?: unknown\n code?: unknown\n message?: unknown\n }\n const raw = parsed.detail ?? parsed.message\n if (Array.isArray(raw)) {\n const problems = raw\n .map((entry) => readProblem(entry) ?? (typeof entry === 'string' ? entry : undefined))\n .filter((problem): problem is string => problem !== undefined)\n detail = problems.length > 0 ? problems.join(', ') : text\n } else {\n detail = typeof raw === 'string' ? raw : text\n }\n code = typeof parsed.code === 'string' ? parsed.code : undefined\n } catch {\n detail = text\n }\n }\n } catch {\n /* unreadable body — fall back to the status alone */\n }\n return new ChatHttpError(detail || `The API answered ${response.status}`, response.status, code)\n}\n\n/** Normalises the agent of a `done` frame. Absent on a surface with one agent. */\nfunction toHandle(raw: unknown): AgentHandle | undefined {\n if (!raw || typeof raw !== 'object') return undefined\n const source = raw as {\n handle?: unknown\n name?: unknown\n avatar_emoji?: unknown\n color?: unknown\n }\n if (typeof source.handle !== 'string' || !source.handle) return undefined\n return {\n handle: source.handle,\n name: typeof source.name === 'string' ? source.name : source.handle,\n avatarEmoji: typeof source.avatar_emoji === 'string' ? source.avatar_emoji : undefined,\n color: typeof source.color === 'string' ? source.color : undefined,\n }\n}\n\n/** Normalises a list of handles — the open response's, or a `done` frame's hint. */\nfunction toHandles(raw: unknown): AgentHandle[] {\n return (Array.isArray(raw) ? raw : [])\n .map(toHandle)\n .filter((handle): handle is AgentHandle => handle !== undefined)\n}\n\n/** Normalises the pause of an `approval_required` frame. */\nfunction toApproval(raw: unknown): PendingApproval | undefined {\n if (!raw || typeof raw !== 'object') return undefined\n const source = raw as { tool_call_id?: unknown; tool?: unknown; arguments?: unknown }\n // With no call id no decision can be sent back for it, which makes the buttons a\n // dead end: better to render nothing than a control that cannot answer.\n if (typeof source.tool_call_id !== 'string' || !source.tool_call_id) return undefined\n return {\n toolCallId: source.tool_call_id,\n tool: typeof source.tool === 'string' ? source.tool : '',\n arguments:\n source.arguments && typeof source.arguments === 'object'\n ? (source.arguments as Record<string, unknown>)\n : {},\n }\n}\n\nconst TRANSCRIPT_ROLES = new Set<string>(['user', 'assistant'])\n\n/** One stored turn, as a panel renders it. */\nfunction toMessage(raw: ApiMessage): ChatMessage | null {\n if (typeof raw.role !== 'string' || !TRANSCRIPT_ROLES.has(raw.role)) return null\n if (typeof raw.content !== 'string' || !raw.content) return null\n const at = typeof raw.created_at === 'string' ? Date.parse(raw.created_at) : Number.NaN\n return {\n id: typeof raw.id === 'string' && raw.id ? raw.id : uuid(),\n role: raw.role as ChatRole,\n content: raw.content,\n createdAt: Number.isNaN(at) ? Date.now() : at,\n agent: toHandle(raw.agent),\n attachments: toAttachments(raw.attachments),\n // A member of the organization answering instead of an agent, by name.\n authorName:\n raw.kind === 'human' && typeof raw.author_name === 'string' && raw.author_name\n ? raw.author_name\n : undefined,\n }\n}\n\n/**\n * The files of one turn, as the API listed them.\n *\n * Read defensively like everything else off the wire, and dropped rather than\n * guessed at: a file this panel cannot name is a file it cannot draw either, and\n * an entry with half a shape would be a chip with no label.\n */\nfunction toAttachments(raw: unknown): ChatAttachment[] | undefined {\n if (!Array.isArray(raw)) return undefined\n const files = raw\n .map((entry) => toAttachment(entry))\n .filter((file): file is ChatAttachment => file !== null)\n return files.length > 0 ? files : undefined\n}\n\nfunction toAttachment(raw: unknown): ChatAttachment | null {\n if (!raw || typeof raw !== 'object') return null\n const { id, kind, filename, content_type: contentType } = raw as ApiAttachment\n if (typeof id !== 'string' || !id) return null\n if (typeof filename !== 'string' || !filename) return null\n return {\n id,\n // Anything the panel does not know how to show is shown as a document,\n // which is a named chip — never as a picture it would fail to draw.\n kind: kind === 'image' ? 'image' : 'document',\n filename,\n contentType: typeof contentType === 'string' ? contentType : 'application/octet-stream',\n }\n}\n\n/**\n * Opens a conversation for a page carrying this application's embed key.\n *\n * The body carries the host's author claim and nothing else. No bearer token: the\n * widget is the public surface, and the key plus the visitor token it gets back are\n * the whole credential story.\n */\nexport async function openConversation(init: OpenConversationInit): Promise<OpenedConversation> {\n const response = await fetch(\n endpoint(init.apiUrl, `/public/applications/${encodeURIComponent(init.embedKey)}/conversations`),\n {\n method: 'POST',\n headers: headers(),\n body: JSON.stringify({\n ...(init.user ? { user: init.user } : {}),\n // Omitted rather than sent empty: the API tells an absent field from a\n // cleared one, and an application always has an agent answering plain text.\n ...(init.agent ? { agent: init.agent } : {}),\n }),\n signal: init.signal,\n },\n )\n if (!response.ok) throw await readError(response)\n\n const data = (await response.json()) as {\n id?: unknown\n visitor_token?: unknown\n agent_name?: unknown\n agent_slug?: unknown\n welcome_message?: unknown\n messages?: unknown\n handles?: unknown\n agent_handle?: unknown\n handling?: unknown\n branding?: unknown\n }\n if (typeof data.id !== 'string' || typeof data.visitor_token !== 'string') {\n throw new ChatHttpError('The API opened a conversation without an id or a token')\n }\n const messages = (Array.isArray(data.messages) ? (data.messages as ApiMessage[]) : [])\n .map(toMessage)\n .filter((message): message is ChatMessage => message !== null)\n return {\n conversationId: data.id,\n visitorToken: data.visitor_token,\n agentName: typeof data.agent_name === 'string' ? data.agent_name : '',\n agentSlug: typeof data.agent_slug === 'string' ? data.agent_slug : '',\n welcomeMessage:\n typeof data.welcome_message === 'string' && data.welcome_message\n ? data.welcome_message\n : undefined,\n messages,\n handles: toHandles(data.handles),\n agentHandle:\n typeof data.agent_handle === 'string' && data.agent_handle ? data.agent_handle : undefined,\n withHuman: typeof data.handling === 'string' && data.handling !== 'agents',\n branding: data.branding === true,\n }\n}\n\n/**\n * Reads a conversation back, on the token it was opened with.\n *\n * What makes a reloaded page keep its conversation instead of opening a second one.\n * The answer is the open response minus the credential — the transcript, the handles\n * the composer offers, and the handle the conversation is on — because the token is\n * handed over once and the caller already holds it.\n */\nexport async function replayConversation(init: ReplayConversationInit): Promise<OpenedConversation> {\n const response = await fetch(\n endpoint(init.apiUrl, `/public/conversations/${encodeURIComponent(init.conversationId)}`),\n { method: 'GET', headers: headers(init.visitorToken), signal: init.signal },\n )\n if (!response.ok) throw await readError(response)\n\n const data = (await response.json()) as {\n id?: unknown\n agent_name?: unknown\n agent_slug?: unknown\n welcome_message?: unknown\n messages?: unknown\n handles?: unknown\n agent_handle?: unknown\n handling?: unknown\n branding?: unknown\n }\n if (typeof data.id !== 'string') {\n throw new ChatHttpError('The API replayed a conversation without an id')\n }\n return {\n conversationId: data.id,\n // The one field a replay cannot answer with, and must not: the caller presented\n // it to get here.\n visitorToken: init.visitorToken,\n agentName: typeof data.agent_name === 'string' ? data.agent_name : '',\n agentSlug: typeof data.agent_slug === 'string' ? data.agent_slug : '',\n welcomeMessage:\n typeof data.welcome_message === 'string' && data.welcome_message\n ? data.welcome_message\n : undefined,\n messages: (Array.isArray(data.messages) ? (data.messages as ApiMessage[]) : [])\n .map(toMessage)\n .filter((message): message is ChatMessage => message !== null),\n handles: toHandles(data.handles),\n agentHandle:\n typeof data.agent_handle === 'string' && data.agent_handle ? data.agent_handle : undefined,\n withHuman: typeof data.handling === 'string' && data.handling !== 'agents',\n branding: data.branding === true,\n }\n}\n\nexport interface AttachmentInit {\n apiUrl: string\n conversationId: string\n visitorToken: string\n signal?: AbortSignal\n}\n\n/**\n * Puts one file on the conversation, before the question that will carry it.\n *\n * Uploaded as it is picked rather than held until the message is sent: a format\n * the product does not take is refused here, in front of somebody who has not\n * written their question yet.\n *\n * What comes back is what was *accepted* — the kind and the type read off the\n * bytes on the server. The panel never decides what a file is.\n */\nexport async function uploadAttachment(\n init: AttachmentInit & { file: File },\n): Promise<ChatAttachment> {\n const body = new FormData()\n body.append('file', init.file)\n const response = await fetch(attachmentsUrl(init), {\n method: 'POST',\n // No content type of our own: the boundary belongs to the `FormData`, and a\n // header written over it hands the API a multipart body labelled otherwise.\n headers: { 'X-Visitor-Token': init.visitorToken },\n body,\n signal: init.signal,\n })\n if (!response.ok) throw await readError(response)\n const accepted = toAttachment(await response.json())\n if (!accepted) throw new ChatHttpError('The upload could not be read', response.status)\n return accepted\n}\n\n/** Takes a file back out of the conversation, bytes and all. */\nexport async function deleteAttachment(\n init: AttachmentInit & { attachmentId: string },\n): Promise<void> {\n const response = await fetch(\n `${attachmentsUrl(init)}/${encodeURIComponent(init.attachmentId)}`,\n {\n method: 'DELETE',\n headers: { 'X-Visitor-Token': init.visitorToken },\n signal: init.signal,\n },\n )\n if (!response.ok) throw await readError(response)\n}\n\n/**\n * The bytes of one file, as something a browser can draw.\n *\n * Fetched rather than linked, and this is the whole reason attachments carry no\n * URL: the route is opened by the visitor token, which travels in a header, and\n * a header is exactly what an `<img src>` cannot send. So the panel reads the\n * file itself and hands the caller an object URL — which the caller owns, and\n * has to revoke.\n */\nexport async function fetchAttachment(\n init: AttachmentInit & { attachmentId: string },\n): Promise<Blob> {\n const response = await fetch(\n `${attachmentsUrl(init)}/${encodeURIComponent(init.attachmentId)}/content`,\n { headers: { 'X-Visitor-Token': init.visitorToken }, signal: init.signal },\n )\n if (!response.ok) throw await readError(response)\n return response.blob()\n}\n\nfunction attachmentsUrl(init: AttachmentInit): string {\n return endpoint(\n init.apiUrl,\n `/public/conversations/${encodeURIComponent(init.conversationId)}/attachments`,\n )\n}\n\n/** Sends one message, and streams the answer as it is written. */\nexport async function sendMessage(init: SendMessageInit): Promise<ChatTurn> {\n return stream(\n endpoint(init.apiUrl, `/public/conversations/${encodeURIComponent(init.conversationId)}/messages`),\n {\n content: init.message,\n attachment_ids: init.attachmentIds ?? [],\n // Omitted rather than sent empty: the API tells an absent field from a\n // cleared one, and a page with nothing to say should say nothing.\n ...(init.context && Object.keys(init.context).length > 0\n ? { context: init.context }\n : {}),\n },\n init,\n )\n}\n\n/**\n * Answers the tool call a turn paused on, and lets the turn carry on.\n *\n * Streamed like a message, because it *is* the same turn continuing: the tokens the\n * agent writes after the call, then the stored answer — or another pause, if it asks\n * for a second tool needing a decision.\n */\nexport async function resolveApproval(init: ResolveApprovalInit): Promise<ChatTurn> {\n return stream(\n endpoint(init.apiUrl, `/public/conversations/${encodeURIComponent(init.conversationId)}/approvals`),\n { tool_call_id: init.toolCallId, approved: init.approved },\n init,\n )\n}\n\ninterface StreamInit {\n visitorToken: string\n subjectToken?: string\n onToken: (token: string) => void\n signal?: AbortSignal\n}\n\n/**\n * Plays one server-sent event stream, whatever started it.\n *\n * Frames are separated by a blank line, but a relay may forward the chunks as it\n * received them — so the buffer is split on lines and the remainder kept, which can\n * be a `data:` line cut in the middle.\n *\n * An `error` frame rejects: once the response is a 200 there is no status code left\n * to fail with, so the failure travels inside the stream and has to become one here.\n * Whatever tokens arrived before it are kept — half an answer already on somebody's\n * screen is not something to erase.\n */\nasync function stream(url: string, body: unknown, init: StreamInit): Promise<ChatTurn> {\n const response = await fetch(url, {\n method: 'POST',\n headers: headers(init.visitorToken, init.subjectToken),\n body: JSON.stringify(body),\n signal: init.signal,\n })\n if (!response.ok) throw await readError(response)\n if (!response.body) throw new ChatHttpError('Answer with no stream body')\n\n const reader = response.body.getReader()\n const decoder = new TextDecoder()\n let buffer = ''\n let event = ''\n let streamed = ''\n let failure: string | undefined\n let handedTo: string | undefined\n const turn: ChatTurn = { answer: '' }\n\n try {\n for (;;) {\n const { value, done } = await reader.read()\n if (done) break\n buffer += decoder.decode(value, { stream: true })\n\n const lines = buffer.split('\\n')\n buffer = lines.pop() ?? ''\n\n for (const raw of lines) {\n const line = raw.trim()\n if (!line) {\n // A blank line ends a frame; the name does not carry over to the next.\n event = ''\n continue\n }\n if (line.startsWith('event:')) {\n event = line.slice(6).trim()\n continue\n }\n if (!line.startsWith('data:')) continue\n\n const payload = line.slice(5).trim()\n if (!payload) continue\n let frame: Record<string, unknown>\n try {\n frame = JSON.parse(payload) as Record<string, unknown>\n } catch {\n continue\n }\n\n if (event === 'token' && typeof frame.text === 'string') {\n streamed += frame.text\n init.onToken(frame.text)\n } else if (event === 'done') {\n turn.answer = typeof frame.content === 'string' ? frame.content : streamed\n turn.agent = toHandle(frame.agent)\n if (typeof frame.unknown_handle === 'string' && frame.unknown_handle) {\n turn.unknownHandle = frame.unknown_handle\n turn.offered = toHandles(frame.handles)\n }\n } else if (event === 'handoff') {\n // Another agent of the team answers from here; whatever came before it\n // was the other agent's, and the answer is what follows.\n if (typeof frame.to_agent_name === 'string') handedTo = frame.to_agent_name\n streamed = ''\n } else if (event === 'escalated') {\n turn.withHuman = true\n } else if (event === 'held') {\n turn.held = true\n turn.withHuman = true\n } else if (event === 'approval_required') {\n turn.approval = toApproval(frame)\n } else if (event === 'error') {\n failure = typeof frame.detail === 'string' ? frame.detail : 'The turn failed'\n }\n }\n if (failure) break\n }\n } finally {\n // Releases the connection even on abort or mid-stream failure.\n void reader.cancel().catch(() => undefined)\n }\n\n if (failure) throw new ChatHttpError(failure)\n if (!turn.answer && !turn.approval) turn.answer = streamed\n if (handedTo && !turn.agent) turn.authorName = handedTo\n return turn\n}\n","/**\n * Remembers which conversation this panel is having, so a reload keeps it.\n *\n * Without this, refreshing the host page silently opened a second conversation and\n * left the first one unreachable — the visitor's own transcript, gone, with no way\n * back to it. What is stored is the pair the API needs to read it again: the id it\n * named, and the visitor token that is the whole of the authorization on it.\n *\n * `sessionStorage`, like the panel's open state and for a sharper reason: that token\n * *is* the credential. One tab's lifetime covers the reload and a navigation inside\n * the host app, which is what this exists for, and it does not leave a working key\n * to somebody's conversation on a shared machine for weeks. Reopening the browser\n * tomorrow starts a new conversation, which for a support panel is the honest\n * default.\n *\n * The embed key and the claimed user id travel with it, and both are checked before\n * anything is replayed. A remembered conversation belongs to one application and to\n * one person: a page that switched applications, or on which somebody else signed\n * in, has to start again — relabelling a transcript is exactly what the author claim\n * exists to prevent.\n */\n\n/** One conversation per host origin — enough while a page mounts a single widget,\n * which is the case for every current integrator. */\nconst CONVERSATION_KEY = 'squadico-chatbot:conversation'\n\nexport interface StoredConversation {\n sessionId: string\n visitorToken: string\n /** Which application it was opened on. A different one is a different panel. */\n embedKey: string\n /** Who the host said was in front of it, when it said anybody. */\n user?: string\n}\n\n/** The conversation this page was having, if it is still the same page's.\n *\n * `undefined` for anything that does not read back as a conversation: nothing\n * stored, storage refused, a half-written entry from an interrupted write. None of\n * those is worth an error — the panel opens a new conversation, which is what it\n * did before it remembered any. */\nexport function readConversation(): StoredConversation | undefined {\n try {\n if (typeof sessionStorage === 'undefined') return undefined\n const raw = sessionStorage.getItem(CONVERSATION_KEY)\n if (!raw) return undefined\n const parsed = JSON.parse(raw) as Partial<StoredConversation>\n if (!parsed.sessionId || !parsed.visitorToken || !parsed.embedKey) return undefined\n return {\n sessionId: parsed.sessionId,\n visitorToken: parsed.visitorToken,\n embedKey: parsed.embedKey,\n user: typeof parsed.user === 'string' ? parsed.user : undefined,\n }\n } catch {\n // Storage unavailable (private browsing, blocked cookies…) or unparseable.\n return undefined\n }\n}\n\nexport function writeConversation(conversation: StoredConversation): void {\n try {\n if (typeof sessionStorage === 'undefined') return\n sessionStorage.setItem(CONVERSATION_KEY, JSON.stringify(conversation))\n } catch {\n /* see readConversation: the conversation stays volatile, as it used to be */\n }\n}\n\nexport function forgetConversation(): void {\n try {\n if (typeof sessionStorage === 'undefined') return\n sessionStorage.removeItem(CONVERSATION_KEY)\n } catch {\n /* see readConversation */\n }\n}\n\n/**\n * Whether a remembered conversation is one *this* panel may carry on.\n *\n * Checked here rather than at each call site so the two reasons to drop one stay\n * together: it belongs to another application, or to another person.\n */\nexport function belongsTo(\n conversation: StoredConversation,\n { embedKey, user }: { embedKey: string; user?: string },\n): boolean {\n return conversation.embedKey === embedKey && conversation.user === user\n}\n","/**\n * State machine of a conversation: opening it, playing turns, deciding a paused\n * tool call, aborting, starting over. Kept out of the rendering so it stays\n * testable and reusable by both wrappers (custom element and React wrapper).\n *\n * **The conversation is opened by the server, once, and lazily.** A panel nobody\n * opened is a conversation nobody had, so the open call is made when the panel is\n * first shown — or on the first message, whichever comes first. The id and the\n * visitor token both come back from it: a visitor allowed to name their own\n * conversation is a visitor choosing which one to read.\n *\n * **And it survives a reload.** The pair is remembered for the tab, and a panel that\n * finds one replays it instead of opening a second conversation and orphaning the\n * first. A remembered conversation belongs to one application and to one person: a\n * page that switched either starts again, and one the API no longer knows about is\n * dropped rather than left to break every turn.\n *\n * **A paused turn is answered, not talked around.** The agent stops before calling a\n * tool and says what it would do; the buttons release it. Typing something else\n * instead is a decision too — the call was never approved, so it never runs, and the\n * backend closes it as the new question goes out. That is why what the user types is\n * always a new message here and never a correction squeezed into a pending decision.\n *\n * **Changing who the host says is in front of the panel opens a new conversation.**\n * Relabelling the old one would put two people's turns under one name, which is\n * exactly what the author claim exists to prevent.\n *\n * **The page context is translated, not forwarded.** A host writes\n * `order: { id, name }` because the chip shows the name; the API takes scalars. The\n * pair goes on the wire and the object stays on screen.\n *\n * **A handle is text, never a field.** The server parses the message for the agent\n * it addresses, so `agent` opens the conversation on one and the picker writes one\n * into what somebody is typing. Nothing here routes: a client naming its own agent\n * would be a client choosing its own router.\n */\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks'\n\nimport type {\n AgentHandle,\n ChatAttachment,\n ChatbotContext,\n ChatbotEvent,\n ChatMessage,\n HostUser,\n PendingApproval,\n SubjectTokenSource,\n} from '../types'\nimport {\n ChatHttpError,\n API_URL,\n openConversation,\n replayConversation,\n resolveApproval,\n deleteAttachment,\n fetchAttachment,\n sendMessage,\n uploadAttachment,\n} from './client'\nimport type { OpenedConversation } from './client'\nimport { belongsTo, forgetConversation, readConversation, writeConversation } from './conversation'\nimport { wireContext } from './context'\nimport { resolveLocale, type Locale } from './i18n'\nimport { uuid } from './uid'\n\n/**\n * Asks the page for the token it holds for its signed-in user, right before a turn\n * goes out. A page with nobody signed in — or a source that fails — sends none,\n * and the turn goes on without acting as anybody.\n */\nasync function subjectTokenOf(source: SubjectTokenSource | undefined): Promise<string | undefined> {\n if (!source) return undefined\n try {\n return (await source()) || undefined\n } catch {\n return undefined\n }\n}\n\nexport interface UseChatOptions {\n /** Where the calls go. Not reachable from the element or the React wrapper:\n * the built-in `API_URL` is the only server a page gets, and this exists for\n * the tests to name theirs. */\n apiUrl?: string\n /** Public key of the application this page embeds. Nothing happens without it. */\n embedKey?: string\n /** Who the host application has signed in, when it has anybody. */\n user?: HostUser\n /** Hands over the access token the host site holds for its signed-in user, asked\n * before every message so it is always fresh. See `ChatbotProps`. */\n getSubjectToken?: SubjectTokenSource\n /** The handle to open the conversation on, for a page that knows who should\n * answer. The visitor can still address somebody else afterwards. */\n agent?: string\n context?: ChatbotContext\n greeting?: string\n /** Language of the error bubble — the only text this module writes. Resolved by\n * the widget; the package's default language otherwise. */\n locale?: Locale\n onEvent?: (event: ChatbotEvent) => void\n /** How often a conversation a human handles is read again, in ms: their replies\n * are not streamed. */\n humanPollMs?: number\n}\n\nexport interface UseChatResult {\n messages: ChatMessage[]\n /** A turn is in flight (request sent, answer not finished yet). */\n busy: boolean\n /** The conversation's id, as the server named it. Empty until it is opened. */\n sessionId: string\n /** The handles this application offers a visitor. Empty until an organization\n * ticks one, which is the ordinary case. */\n handles: AgentHandle[]\n /** The handle the conversation opened on, as the server resolved it — not the one\n * that was asked for, which it may have fallen back from. Empty until it opens,\n * and empty when the page named nobody: the default agent needs no announcing. */\n addressee: string\n /** The tool call awaiting a decision, or `null` the rest of the time. */\n approval: PendingApproval | null\n /** Whether the panel shows \"Powered by Squadico\": the organization's plan says,\n * and nothing does until the conversation opens. */\n branding: boolean\n /** An agent handed the conversation to a human of the organization: no agent\n * answers, and what they reply shows as the conversation is read again. */\n withHuman: boolean\n /** Open the conversation now — what the panel calls when it is first shown, so\n * the welcome message is there to read. Idempotent. */\n start: () => void\n send: (text: string) => void\n /** The files the next question will carry, in the order they were picked. */\n attachments: ChatAttachment[]\n /** The names of the files still going up, so a slow upload is visible. */\n uploading: string[]\n /** Why the last upload was refused, as a key the panel translates. Null when\n * the last one was accepted — a refusal is about the file just picked, not a\n * state the conversation stays in. */\n attachmentError: AttachmentRefusal | null\n /** Puts one file on the conversation, opening it if it is not open yet. */\n attach: (file: File) => void\n /** Takes one back out, bytes and all. */\n detach: (attachmentId: string) => void\n /** Reads the bytes of a file a turn carried — what draws a picture back. */\n loadAttachment: (attachmentId: string) => Promise<Blob>\n /** Answers the paused call. `label` is what is shown on the user's side in the\n * history (\"Yes\" or \"No\"). */\n decide: (approved: boolean, label: string) => void\n stop: () => void\n /** Forget this conversation and open another one on the next message. */\n reset: () => void\n}\n\ninterface OpenConversation {\n /** The conversation's id. Still named `sessionId` because it is what\n * `sessionStorage` holds and what the host page is told in every event. */\n sessionId: string\n visitorToken: string\n}\n\n/** Why an upload was refused, in terms a panel can translate. */\nexport type AttachmentRefusal = 'unsupported' | 'tooLarge' | 'tooMany' | 'unreadable' | 'failed'\n\n/**\n * What a refused upload means, read off the status.\n *\n * Each one is a different instruction to whoever picked the file — send another\n * format, send something smaller, remove one first — which is why they are not\n * one message with a number in it.\n */\nfunction refusalOf(error: unknown): AttachmentRefusal {\n const status = error instanceof ChatHttpError ? error.status : undefined\n if (status === 415) return 'unsupported'\n if (status === 413) return 'tooLarge'\n if (status === 409) return 'tooMany'\n if (status === 422) return 'unreadable'\n return 'failed'\n}\n\n/** What a turn came back with, beyond its text: who answered, what it stopped on,\n * and the name it addressed that nobody here answers to. */\ntype TurnResult = {\n answer: string\n agent?: AgentHandle\n approval?: PendingApproval\n unknownHandle?: string\n offered?: AgentHandle[]\n authorName?: string\n withHuman?: boolean\n held?: boolean\n}\n\n/** How often a conversation a human handles is read again, by default. */\nconst HUMAN_POLL_MS = 5_000\n\n/** Whether a refusal means \"this conversation is over, open another one\".\n *\n * The code and not the status: 409 is also what an application with nothing\n * answering on it replies, and reopening would not help there. */\nfunction retired(error: unknown): boolean {\n return error instanceof ChatHttpError && error.code === 'conversation_retired'\n}\n\nexport function useChat(options: UseChatOptions): UseChatResult {\n const [messages, setMessages] = useState<ChatMessage[]>([])\n const [busy, setBusy] = useState(false)\n const [sessionId, setSessionId] = useState('')\n const [handles, setHandles] = useState<AgentHandle[]>([])\n const [addressee, setAddressee] = useState('')\n const [approval, setApproval] = useState<PendingApproval | null>(null)\n const [withHuman, setWithHuman] = useState(false)\n const [branding, setBranding] = useState(false)\n const [attachments, setAttachments] = useState<ChatAttachment[]>([])\n const [uploading, setUploading] = useState<string[]>([])\n const [attachmentError, setAttachmentError] = useState<AttachmentRefusal | null>(null)\n const abortRef = useRef<AbortController | null>(null)\n\n // Async closures read the props through a ref: without it, a turn started before\n // a context update would send the stale value.\n const latest = useRef(options)\n latest.current = options\n\n // The open call, kept as a promise so two turns starting at once — a click on a\n // suggestion while the panel is opening — share one conversation instead of\n // opening two.\n const opening = useRef<Promise<OpenConversation> | null>(null)\n const conversation = useRef<OpenConversation | null>(null)\n // Which claim the current conversation was opened under, so a change of host user\n // can be told from a re-render.\n const openedFor = useRef<string | undefined>(undefined)\n\n const greeting = options.greeting\n const greetingMessage = useMemo<ChatMessage | null>(\n () =>\n greeting\n ? { id: 'greeting', role: 'assistant', content: greeting, createdAt: Date.now() }\n : null,\n [greeting],\n )\n\n const emit = useCallback((event: ChatbotEvent) => {\n latest.current.onEvent?.(event)\n }, [])\n\n const patch = useCallback((id: string, changes: Partial<ChatMessage>) => {\n setMessages((current) =>\n current.map((message) => (message.id === id ? { ...message, ...changes } : message)),\n )\n }, [])\n\n const fail = useCallback(\n (error: unknown, replyId?: string) => {\n const status = error instanceof ChatHttpError ? error.status : undefined\n const detail = error instanceof Error ? error.message : String(error)\n const message = (latest.current.locale ?? resolveLocale(undefined)).t.error\n if (replyId) patch(replyId, { content: message, streaming: false, error: true })\n emit({\n type: 'chatbot-error',\n message: detail,\n status,\n sessionId: conversation.current?.sessionId ?? '',\n })\n if (typeof console !== 'undefined') {\n console.error('[squadico-chatbot]', detail)\n }\n },\n [emit, patch],\n )\n\n /**\n * The conversation this panel is having, opening it if it has none.\n *\n * The welcome message the application answers with is put on screen as part of\n * opening: an empty panel with a name on it says nothing about what may be asked.\n */\n const conversationNow = useCallback(async (): Promise<OpenConversation> => {\n if (conversation.current) return conversation.current\n if (opening.current) return opening.current\n\n const opts = latest.current\n if (!opts.embedKey) {\n throw new ChatHttpError('No embed key: nothing says which application to open')\n }\n const claim = opts.user\n const apiUrl = opts.apiUrl ?? API_URL\n const embedKey = opts.embedKey\n\n const adopt = (opened: OpenedConversation): OpenConversation => {\n const open = { sessionId: opened.conversationId, visitorToken: opened.visitorToken }\n conversation.current = open\n openedFor.current = claim?.id\n writeConversation({ ...open, embedKey, user: claim?.id })\n setSessionId(opened.conversationId)\n setHandles(opened.handles)\n // Announced only when the page asked for somebody: showing the default\n // agent's own handle would put an `@support` in every composer.\n setAddressee(opts.agent && opened.agentHandle ? opened.agentHandle : '')\n setWithHuman(Boolean(opened.withHuman))\n setBranding(opened.branding)\n // Prepended rather than appended: whatever the panel put on screen while it\n // was opening comes after what the conversation already held.\n if (opened.messages.length > 0) {\n setMessages((current) => [...opened.messages, ...current])\n }\n return open\n }\n\n const fresh = (): Promise<OpenConversation> =>\n openConversation({\n apiUrl,\n embedKey,\n user: claim,\n // Only when the page named one: an application always has an agent\n // answering plain text, and the panel has nothing to announce for it.\n agent: opts.agent,\n }).then(adopt)\n\n // A conversation the API no longer knows about — deleted, or opened against an\n // application that is gone — is dropped rather than retried: a panel that gave\n // up here is a panel one reload broke for good.\n const remembered = readConversation()\n const play =\n remembered && belongsTo(remembered, { embedKey, user: claim?.id })\n ? replayConversation({\n apiUrl,\n conversationId: remembered.sessionId,\n visitorToken: remembered.visitorToken,\n })\n .then(adopt)\n .catch(() => {\n forgetConversation()\n return fresh()\n })\n : fresh()\n\n opening.current = play\n try {\n return await play\n } finally {\n opening.current = null\n }\n }, [])\n\n const start = useCallback(() => {\n if (conversation.current || opening.current) return\n void conversationNow().catch((error: unknown) => fail(error))\n }, [conversationNow, fail])\n\n /**\n * Common body of a turn: appends the pair of bubbles, plays `run`, and publishes\n * what came back — the answer, and the call it stopped on if it stopped.\n */\n const turn = useCallback(\n (\n userText: string,\n run: (\n open: OpenConversation,\n onToken: (text: string) => void,\n signal: AbortSignal,\n ) => Promise<TurnResult>,\n { retry = false, carried = [] }: { retry?: boolean; carried?: ChatAttachment[] } = {},\n ) => {\n if (abortRef.current) return\n\n const controller = new AbortController()\n abortRef.current = controller\n setBusy(true)\n // The buttons of the previous turn are worth nothing now: the decision has\n // just been made, or the user moved on and the backend closed the call.\n setApproval(null)\n\n const replyId = uuid()\n setMessages((current) => [\n ...current,\n {\n id: uuid(),\n role: 'user',\n content: userText,\n createdAt: Date.now(),\n // Drawn from what the composer was holding rather than waited for: the\n // files were accepted before the message left, and a question whose\n // picture appears two seconds later reads as one that failed.\n attachments: carried.length > 0 ? carried : undefined,\n },\n { id: replyId, role: 'assistant', content: '', createdAt: Date.now(), streaming: true },\n ])\n\n const play = async (): Promise<void> => {\n let open = await conversationNow()\n emit({\n type: 'chatbot-message',\n role: 'user',\n content: userText,\n sessionId: open.sessionId,\n })\n let streamed = ''\n const onToken = (chunk: string): void => {\n streamed += chunk\n patch(replyId, { content: streamed })\n }\n let result: TurnResult\n try {\n result = await run(open, onToken, controller.signal)\n } catch (error: unknown) {\n if (!retired(error)) throw error\n // The organization rotated the embed key, so this conversation is over\n // and the remembered one is worthless. Refused before anything was\n // stored or streamed, which is what makes replaying it here safe rather\n // than a second question the visitor did not ask.\n forgetConversation()\n conversation.current = null\n opening.current = null\n if (!retry) throw error\n open = await conversationNow()\n streamed = ''\n patch(replyId, { content: '' })\n result = await run(open, onToken, controller.signal)\n }\n if (result.withHuman) setWithHuman(true)\n if (result.held) {\n // Kept for the human: no agent ran, so there is no answer to draw.\n setMessages((current) => current.filter((message) => message.id !== replyId))\n return\n }\n patch(replyId, {\n content: result.answer,\n streaming: false,\n agent: result.agent,\n authorName: result.authorName,\n approval: result.approval,\n // Kept on the answer it arrived with: the question was answered, and\n // what the panel adds is who could have been asked instead.\n unknownHandle: result.unknownHandle,\n offered: result.offered,\n })\n setApproval(result.approval ?? null)\n emit({\n type: 'chatbot-message',\n role: 'assistant',\n content: result.answer,\n sessionId: open.sessionId,\n agent: result.agent?.handle,\n })\n }\n\n void play()\n .catch((error: unknown) => {\n // A deliberate abort is not an error: keep the text already received.\n if (controller.signal.aborted) {\n patch(replyId, { streaming: false })\n return\n }\n fail(error, replyId)\n })\n .finally(() => {\n abortRef.current = null\n setBusy(false)\n })\n },\n [conversationNow, emit, fail, patch],\n )\n\n const send = useCallback(\n (raw: string) => {\n const text = raw.trim()\n // A file on its own is a turn, and a question about the file. What is\n // refused is the turn carrying neither words nor a file.\n if (!text && attachments.length === 0) return\n // Emptied before the run rather than after it: the files have left with the\n // question, and a composer still showing them would offer to remove part of\n // a turn already on its way.\n const carried = attachments\n setAttachments([])\n setAttachmentError(null)\n turn(\n text,\n async (open, onToken, signal) =>\n sendMessage({\n subjectToken: await subjectTokenOf(latest.current.getSubjectToken),\n apiUrl: latest.current.apiUrl ?? API_URL,\n conversationId: open.sessionId,\n visitorToken: open.visitorToken,\n message: text,\n attachmentIds: carried.map((file) => file.id),\n // Shaped for the wire here and not by the host: `order: { id, name }`\n // is how a page writes it — the chip shows the name — while the API\n // takes text, numbers and booleans, so the pair `orderId` +\n // `orderName` is what travels. Sending the nested object earns a 422\n // and no answer.\n context: latest.current.context ? wireContext(latest.current.context) : undefined,\n onToken,\n signal,\n }),\n // A question refused because the key was rotated is asked again on the\n // fresh conversation: the visitor typed it once, and nothing was stored.\n //\n // Its files are not carried over: they belong to the conversation that\n // was retired, and the ids mean nothing on the new one. The question is\n // asked again, without them, rather than failing on an id nobody knows.\n { retry: true, carried },\n )\n },\n [attachments, turn],\n )\n\n /**\n * Puts one file on the conversation, before the question that will carry it.\n *\n * Opens the conversation if it is not open yet: a visitor may well pick a file\n * before typing anything, and a file has to belong to a conversation to exist\n * at all.\n */\n const attach = useCallback(\n (file: File) => {\n setAttachmentError(null)\n setUploading((waiting) => [...waiting, file.name])\n void conversationNow()\n .then((open) =>\n uploadAttachment({\n apiUrl: latest.current.apiUrl ?? API_URL,\n conversationId: open.sessionId,\n visitorToken: open.visitorToken,\n file,\n }),\n )\n .then((accepted) => setAttachments((files) => [...files, accepted]))\n .catch((error: unknown) => setAttachmentError(refusalOf(error)))\n .finally(() =>\n setUploading((waiting) => {\n const at = waiting.indexOf(file.name)\n return at < 0 ? waiting : [...waiting.slice(0, at), ...waiting.slice(at + 1)]\n }),\n )\n },\n [conversationNow],\n )\n\n /**\n * Takes a file back out of the draft.\n *\n * Dropped from the list first and asked of the server second: the visitor\n * clicked a cross, and a chip that lingers until a round trip finishes reads as\n * a click that did nothing. A delete that fails leaves a file the draft no\n * longer names — an abandoned draft, which the API already knows what to do\n * with.\n */\n const detach = useCallback(\n (attachmentId: string) => {\n setAttachments((files) => files.filter((file) => file.id !== attachmentId))\n const open = conversation.current\n if (!open) return\n void deleteAttachment({\n apiUrl: latest.current.apiUrl ?? API_URL,\n conversationId: open.sessionId,\n visitorToken: open.visitorToken,\n attachmentId,\n }).catch(() => {\n // Nothing to tell anybody: the file is out of the draft either way.\n })\n },\n [],\n )\n\n const loadAttachment = useCallback(async (attachmentId: string): Promise<Blob> => {\n const open = conversation.current\n if (!open) throw new ChatHttpError('No conversation to read that file from')\n return fetchAttachment({\n apiUrl: latest.current.apiUrl ?? API_URL,\n conversationId: open.sessionId,\n visitorToken: open.visitorToken,\n attachmentId,\n })\n }, [])\n\n const decide = useCallback(\n (approved: boolean, label: string) => {\n const waiting = approval\n if (!waiting) return\n turn(label, async (open, onToken, signal) =>\n resolveApproval({\n subjectToken: await subjectTokenOf(latest.current.getSubjectToken),\n apiUrl: latest.current.apiUrl ?? API_URL,\n conversationId: open.sessionId,\n visitorToken: open.visitorToken,\n toolCallId: waiting.toolCallId,\n approved,\n onToken,\n signal,\n }),\n )\n },\n [approval, turn],\n )\n\n const stop = useCallback(() => {\n abortRef.current?.abort()\n abortRef.current = null\n setBusy(false)\n }, [])\n\n const reset = useCallback(() => {\n abortRef.current?.abort()\n abortRef.current = null\n conversation.current = null\n opening.current = null\n openedFor.current = undefined\n // Forgotten as well as dropped: a reload that replayed the conversation\n // somebody just started over would undo the gesture.\n forgetConversation()\n setBusy(false)\n setApproval(null)\n setWithHuman(false)\n setSessionId('')\n setAddressee('')\n setMessages([])\n emit({ type: 'chatbot-reset', sessionId: '' })\n }, [emit])\n\n // A human handles the conversation: their replies arrive with nobody streaming\n // them, so the conversation is read again until the agents have it back.\n const pollMs = options.humanPollMs ?? HUMAN_POLL_MS\n useEffect(() => {\n if (!withHuman || !sessionId) return\n const timer = setInterval(() => {\n const open = conversation.current\n if (!open || abortRef.current) return\n void replayConversation({\n apiUrl: latest.current.apiUrl ?? API_URL,\n conversationId: open.sessionId,\n visitorToken: open.visitorToken,\n })\n .then((replayed) => {\n setMessages(replayed.messages)\n setWithHuman(Boolean(replayed.withHuman))\n })\n .catch(() => {\n // A missed read is caught up by the next one.\n })\n }, pollMs)\n return () => clearInterval(timer)\n }, [withHuman, sessionId, pollMs])\n\n // A different person in front of the panel is a different conversation: their\n // turns must not land under somebody else's name.\n const claimId = options.user?.id\n useEffect(() => {\n if (conversation.current && openedFor.current !== claimId) reset()\n }, [claimId, reset])\n\n const visible = useMemo(\n () => (messages.length === 0 && greetingMessage ? [greetingMessage] : messages),\n [greetingMessage, messages],\n )\n\n return {\n messages: visible,\n busy,\n sessionId,\n handles,\n addressee,\n approval,\n withHuman,\n branding,\n start,\n send,\n attachments,\n uploading,\n attachmentError,\n attach,\n detach,\n loadAttachment,\n decide,\n stop,\n reset,\n }\n}\n","import{options as r,Fragment as e}from\"preact\";export{Fragment}from\"preact\";var t=/[\"&<]/;function n(r){if(0===r.length||!1===t.test(r))return r;for(var e=0,n=0,o=\"\",f=\"\";n<r.length;n++){switch(r.charCodeAt(n)){case 34:f=\""\";break;case 38:f=\"&\";break;case 60:f=\"<\";break;default:continue}n!==e&&(o+=r.slice(e,n)),o+=f,e=n+1}return n!==e&&(o+=r.slice(e,n)),o}var o=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,f=0,i=Array.isArray;function u(e,t,n,o,i,u){t||(t={});var a,c,p=t;if(\"ref\"in p)for(c in p={},t)\"ref\"==c?a=t[c]:p[c]=t[c];var l={type:e,props:p,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--f,__i:-1,__u:0,__source:i,__self:u};if(\"function\"==typeof e&&(a=e.defaultProps))for(c in a)void 0===p[c]&&(p[c]=a[c]);return r.vnode&&r.vnode(l),l}function a(r){var t=u(e,{tpl:r,exprs:[].slice.call(arguments,1)});return t.key=t.__v,t}var c={},p=/[A-Z]/g;function l(e,t){if(r.attr){var f=r.attr(e,t);if(\"string\"==typeof f)return f}if(t=function(r){return null!==r&&\"object\"==typeof r&&\"function\"==typeof r.valueOf?r.valueOf():r}(t),\"ref\"===e||\"key\"===e)return\"\";if(\"style\"===e&&\"object\"==typeof t){var i=\"\";for(var u in t){var a=t[u];if(null!=a&&\"\"!==a){var l=\"-\"==u[0]?u:c[u]||(c[u]=u.replace(p,\"-$&\").toLowerCase()),s=\";\";\"number\"!=typeof a||l.startsWith(\"--\")||o.test(l)||(s=\"px;\"),i=i+l+\":\"+a+s}}return e+'=\"'+n(i)+'\"'}return null==t||!1===t||\"function\"==typeof t||\"object\"==typeof t?\"\":!0===t?e:e+'=\"'+n(\"\"+t)+'\"'}function s(r){if(null==r||\"boolean\"==typeof r||\"function\"==typeof r)return null;if(\"object\"==typeof r){if(void 0===r.constructor)return r;if(i(r)){for(var e=0;e<r.length;e++)r[e]=s(r[e]);return r}}return n(\"\"+r)}export{u as jsx,l as jsxAttr,u as jsxDEV,s as jsxEscape,a as jsxTemplate,u as jsxs};\n//# sourceMappingURL=jsxRuntime.module.js.map\n","import type { JSX } from 'preact'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks'\nimport { MAX_MESSAGE_LENGTH } from '../lib/client'\nimport type { Locale } from '../lib/i18n'\nimport type { AgentHandle, ChatAttachment } from '../types'\n\nconst MAX_ROWS_PX = 132\n\n/**\n * What the picker offers, mirroring what the API accepts.\n *\n * A hint and nothing else: the bytes decide, on the server, and a file renamed\n * past this list is refused there rather than here.\n */\nconst ACCEPTED_FILES =\n 'image/png,image/jpeg,image/gif,image/webp,application/pdf,.docx,.txt,.md,.csv,.json'\n\n/** A handle being typed: where its `@` sits, and what has been written after it. */\ninterface Mention {\n start: number\n query: string\n}\n\n/** What a handle may hold, mirroring the API's own alphabet. */\nconst HANDLE_CHARS = /^[a-zA-Z0-9_-]*$/\n\n/**\n * The handle under the caret, if the caret is in one.\n *\n * An `@` only starts a handle at the beginning of the field or after whitespace:\n * `contact@acme.example` is an address somebody is typing, and opening a picker over\n * it would be the widget interrupting a sentence it misread. Same rule as the\n * server's, which reads a handle only at the head of a message.\n */\nfunction mentionAt(value: string, caret: number): Mention | null {\n const upto = value.slice(0, caret)\n const start = upto.lastIndexOf('@')\n if (start < 0) return null\n if (start > 0 && !/\\s/.test(upto[start - 1] ?? '')) return null\n const query = upto.slice(start + 1)\n return HANDLE_CHARS.test(query) ? { start, query } : null\n}\n\nexport interface ComposerProps {\n placeholder: string\n locale: Locale\n busy: boolean\n /** Focuses the field when the sidebar opens. */\n autoFocus: boolean\n /**\n * The handles this application offers, as the open response returned them.\n *\n * Empty is the ordinary case — a deployment is unlisted until somebody ticks it —\n * and it ships no affordance at all: an empty popup is worse than no popup, and\n * the default agent answers plain text anyway.\n */\n handles?: AgentHandle[]\n /** The handle the conversation opened on, written into the field once so the\n * visitor can see who is being addressed — and delete it. */\n addressee?: string\n /** The files already accepted for this question. */\n attachments?: ChatAttachment[]\n /** The names of the ones still on their way up, so a slow upload is visible. */\n uploading?: string[]\n /** Why the last upload was refused, in the visitor's own language. */\n attachmentError?: string\n /** Absent where a conversation cannot take files — which is also what hides\n * the paperclip rather than showing one that refuses. */\n onAttach?: (file: File) => void\n onDetach?: (attachmentId: string) => void\n onSend: (text: string) => void\n onStop: () => void\n}\n\nexport function Composer({\n placeholder,\n locale,\n busy,\n autoFocus,\n handles,\n addressee,\n attachments = [],\n uploading = [],\n attachmentError,\n onAttach,\n onDetach,\n onSend,\n onStop,\n}: ComposerProps): JSX.Element {\n const [value, setValue] = useState('')\n const [mention, setMention] = useState<Mention | null>(null)\n const [active, setActive] = useState(0)\n const [hovering, setHovering] = useState(false)\n const input = useRef<HTMLTextAreaElement | null>(null)\n const picker = useRef<HTMLInputElement | null>(null)\n const canAttach = Boolean(onAttach)\n const waiting = uploading.length > 0\n\n // What the picker offers right now: the offered handles whose name starts with\n // what is being typed. Nothing matching closes it rather than showing an empty\n // list — at that point the text is a name the panel knows nothing about, and the\n // server will say so once it is sent.\n const matches = useMemo(() => {\n if (!mention || !handles || handles.length === 0) return []\n const query = mention.query.toLowerCase()\n return handles.filter((handle) => handle.handle.startsWith(query))\n }, [handles, mention])\n const picking = matches.length > 0\n\n const grow = useCallback(() => {\n const node = input.current\n if (!node) return\n node.style.height = 'auto'\n const overflowing = node.scrollHeight > MAX_ROWS_PX\n node.style.height = `${Math.min(node.scrollHeight, MAX_ROWS_PX)}px`\n // No scrollbar while the text fits in the max height: otherwise a single\n // line already reserves the scroll gutter.\n node.style.overflowY = overflowing ? 'auto' : 'hidden'\n }, [])\n\n useEffect(() => {\n if (autoFocus) input.current?.focus()\n // Sets the real height at mount: without it the textarea keeps its default\n // `rows=1` height until the first keystroke.\n grow()\n }, [autoFocus, grow])\n\n // A page that opened on a handle starts the visitor off addressing it — as text,\n // which is the only thing that routes, and which they can delete. Never over\n // something already typed: whatever is in the field is theirs.\n useEffect(() => {\n if (!addressee) return\n setValue((current) => (current ? current : `@${addressee} `))\n requestAnimationFrame(grow)\n }, [addressee, grow])\n\n /** Reads the handle under the caret after anything that may have moved it. */\n const scan = useCallback((node: HTMLTextAreaElement) => {\n setMention(mentionAt(node.value, node.selectionStart ?? node.value.length))\n setActive(0)\n }, [])\n\n /**\n * Writes a picked handle where the one being typed was.\n *\n * Text, and only text: the server parses the message, so a name chosen from the\n * list is indistinguishable from one somebody spelled out — which is what keeps\n * the picker a convenience rather than a second router.\n */\n const pick = useCallback(\n (handle: string) => {\n const node = input.current\n if (!node || !mention) return\n const caret = node.selectionStart ?? node.value.length\n const next = `${value.slice(0, mention.start)}@${handle} ${value.slice(caret)}`\n const at = mention.start + handle.length + 2\n setValue(next)\n setMention(null)\n requestAnimationFrame(() => {\n node.focus()\n node.setSelectionRange(at, at)\n grow()\n })\n },\n [grow, mention, value],\n )\n\n /** Hands every picked file up, one round trip each. */\n const take = useCallback(\n (files: FileList | null) => {\n if (!onAttach || !files) return\n for (const file of Array.from(files)) onAttach(file)\n },\n [onAttach],\n )\n\n const submit = useCallback(() => {\n const text = value.trim()\n // Not while a file is still going up: a message names the files it carries,\n // and one that has not landed has no id to name. A file already up is a turn\n // on its own — a question about the file — so only the turn carrying neither\n // words nor a file is held here.\n if ((!text && attachments.length === 0) || busy || waiting) return\n onSend(text)\n setValue('')\n setMention(null)\n // The textarea keeps the sent message's height without this manual reset:\n // `grow` only fires again on the next keystroke.\n requestAnimationFrame(grow)\n }, [attachments.length, busy, grow, onSend, value, waiting])\n\n const onKeyDown = useCallback(\n (event: JSX.TargetedKeyboardEvent<HTMLTextAreaElement>) => {\n // The picker takes the keys it needs while it is open, and only then: with no\n // list on screen every key means what it has always meant.\n if (picking && !event.isComposing) {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault()\n const step = event.key === 'ArrowDown' ? 1 : matches.length - 1\n setActive((current) => (current + step) % matches.length)\n return\n }\n if (event.key === 'Enter' || event.key === 'Tab') {\n event.preventDefault()\n pick((matches[active] ?? matches[0]).handle)\n return\n }\n if (event.key === 'Escape') {\n event.preventDefault()\n // Kept out of the host page: Escape closes the whole panel from a\n // `document` listener, and closing a popup must not close the panel too.\n event.stopPropagation()\n setMention(null)\n return\n }\n }\n // Enter sends, Shift+Enter inserts a line break. `isComposing` avoids\n // sending during an IME composition (CJK keyboards, long accents).\n if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) {\n event.preventDefault()\n submit()\n }\n },\n [active, matches, pick, picking, submit],\n )\n\n const remaining = MAX_MESSAGE_LENGTH - value.length\n\n return (\n <form\n class={`sqc-composer${hovering ? ' sqc-composer--dropping' : ''}`}\n onSubmit={(event) => {\n event.preventDefault()\n submit()\n }}\n onDragOver={(event) => {\n if (!canAttach) return\n event.preventDefault()\n setHovering(true)\n }}\n onDragLeave={() => setHovering(false)}\n onDrop={(event) => {\n if (!canAttach) return\n event.preventDefault()\n setHovering(false)\n take(event.dataTransfer?.files ?? null)\n }}\n >\n {(attachments.length > 0 || waiting || attachmentError) && (\n <div class=\"sqc-attachments\">\n {attachments.map((file) => (\n <span key={file.id} class=\"sqc-chip\" data-kind={file.kind}>\n <span class=\"sqc-chip__name\">{file.filename}</span>\n <button\n type=\"button\"\n class=\"sqc-chip__remove\"\n aria-label={locale.t.composer.remove.replace('{name}', file.filename)}\n onClick={() => onDetach?.(file.id)}\n >\n ×\n </button>\n </span>\n ))}\n {uploading.map((name) => (\n <span key={name} class=\"sqc-chip sqc-chip--waiting\">\n <span class=\"sqc-chip__name\">{name}</span>\n </span>\n ))}\n {attachmentError && (\n <p class=\"sqc-attachments__error\" role=\"status\">\n {attachmentError}\n </p>\n )}\n </div>\n )}\n <div class=\"sqc-composer__field\">\n {picking && (\n <ul class=\"sqc-mentions\" role=\"listbox\" aria-label={locale.t.handles.picker}>\n {matches.map((handle, index) => (\n <li\n key={handle.handle}\n role=\"option\"\n aria-selected={index === active}\n class={`sqc-mention${index === active ? ' sqc-mention--active' : ''}`}\n // The list is clicked while the field has the focus: without this\n // the mousedown blurs the textarea and the caret is gone before\n // there is anywhere to write the handle.\n onMouseDown={(event) => event.preventDefault()}\n onMouseEnter={() => setActive(index)}\n onClick={() => pick(handle.handle)}\n >\n <span class=\"sqc-mention__icon\" aria-hidden=\"true\">\n {handle.avatarEmoji ?? '@'}\n </span>\n <span class=\"sqc-mention__handle\">@{handle.handle}</span>\n <span class=\"sqc-mention__name\">{handle.name}</span>\n </li>\n ))}\n </ul>\n )}\n <textarea\n ref={input}\n class=\"sqc-composer__input\"\n rows={1}\n value={value}\n placeholder={placeholder}\n maxLength={MAX_MESSAGE_LENGTH}\n aria-label={locale.t.composer.label}\n onInput={(event) => {\n setValue(event.currentTarget.value)\n scan(event.currentTarget)\n grow()\n }}\n onKeyDown={onKeyDown}\n // The caret can move without the text changing — a click, an arrow key —\n // and the picker follows the caret, not the keystrokes.\n onClick={(event) => scan(event.currentTarget)}\n // A screenshot pasted straight into the field. Only the files are\n // taken, so pasting text still pastes text.\n onPaste={(event) => {\n const files = event.clipboardData?.files\n if (!canAttach || !files || files.length === 0) return\n event.preventDefault()\n take(files)\n }}\n />\n {remaining <= 200 && (\n <span class=\"sqc-composer__count\" aria-live=\"polite\">\n {remaining}\n </span>\n )}\n </div>\n\n {canAttach && (\n <>\n <input\n ref={picker}\n type=\"file\"\n multiple\n accept={ACCEPTED_FILES}\n class=\"sqc-file-input\"\n onChange={(event) => {\n take(event.currentTarget.files)\n // Cleared so picking the same file twice in a row still fires a\n // change event — otherwise the second attempt does nothing.\n event.currentTarget.value = ''\n }}\n />\n <button\n type=\"button\"\n class=\"sqc-btn sqc-btn--attach\"\n onClick={() => picker.current?.click()}\n aria-label={locale.t.composer.attach}\n title={locale.t.composer.attachTitle}\n >\n {/* Paperclip. */}\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.9\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <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 </svg>\n </button>\n </>\n )}\n\n {busy ? (\n <button\n type=\"button\"\n class=\"sqc-btn sqc-btn--stop\"\n onClick={onStop}\n aria-label={locale.t.composer.stop}\n title={locale.t.composer.stopTitle}\n >\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <rect x=\"7\" y=\"7\" width=\"10\" height=\"10\" rx=\"2\" fill=\"currentColor\" />\n </svg>\n </button>\n ) : (\n <button\n type=\"submit\"\n class=\"sqc-btn sqc-btn--send\"\n disabled={(!value.trim() && attachments.length === 0) || waiting}\n aria-label={locale.t.composer.send}\n title={locale.t.composer.sendTitle}\n >\n {/* Send glyph of the design system. */}\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.9\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M5 12l14-7-5 14-2.5-5.5L5 12z\" />\n </svg>\n </button>\n )}\n </form>\n )\n}\n","/**\n * Detection of the assistant's closed questions, so \"Yes\" / \"No\" can be offered\n * instead of making the user retype the answer.\n *\n * The protocol exposes nothing explicit for this (the API only returns text), so\n * this leans on the phrasings agents actually produce. The list is deliberately\n * narrow: an open question (\"Which records would you like to see?\") must not\n * bring up buttons.\n *\n * A question asked in the user's language is only recognisable with that\n * language's phrasings: the patterns are therefore keyed by language, and the\n * widget's locale picks the set — a single English set would leave a\n * French-speaking host without buttons.\n */\nimport { DEFAULT_LANGUAGE, type LanguageCode } from './i18n'\n\n/** \"Reply YES to confirm\": an answer instruction, not a question. */\nconst ANSWER_HINT: Record<LanguageCode, RegExp> = {\n fr: /\\br[ée]ponde?z? +«?\\s*oui\\b/i,\n en: /\\b(?:reply|answer|respond) +[“\"']?\\s*yes\\b/i,\n es: /\\bresponda?e?d? +«?\\s*s[íi]\\b/i,\n}\n\nconst PATTERNS: Record<LanguageCode, RegExp[]> = {\n fr: [\n /\\b(?:confirmes?[- ]tu|confirmez[- ]vous)\\b/i,\n /\\b(?:valides?[- ]tu|validez[- ]vous)\\b/i,\n /\\b(?:es[- ]tu s[ûu]re?|[êe]tes[- ]vous s[ûu]re?s?)\\b/i,\n /\\b(?:dois[- ]je|puis[- ]je)\\b/i,\n /\\b(?:je continue|on continue|on y va|je lance)\\b/i,\n ANSWER_HINT.fr,\n ],\n en: [\n /\\bdo you confirm\\b/i,\n /\\bdo you (?:want|wish) me to\\b/i,\n /\\b(?:shall|should) I\\b/i,\n /\\bare you sure\\b/i,\n /\\b(?:shall we|should I) (?:proceed|continue|go ahead)\\b/i,\n ANSWER_HINT.en,\n ],\n es: [\n /\\b(?:confirmas|confirma|confirm[áa]is)\\b/i,\n /\\b(?:validas|valida|valid[áa]is)\\b/i,\n /\\best[áa]s? seguro\\b/i,\n /\\b(?:contin[úu]o|procedo|lo lanzo|lo hago)\\b/i,\n /\\bquieres? que\\b/i,\n ANSWER_HINT.es,\n ],\n}\n\n/** Tickable options already carry their own buttons. */\nconst CHECKBOX = /^\\s*(?:[-*•]\\s+)?\\[[ xX]\\]\\s+/m\n\nexport function isConfirmationPrompt(\n text: string,\n language: LanguageCode = DEFAULT_LANGUAGE,\n): boolean {\n if (CHECKBOX.test(text)) return false\n\n const lines = text\n .split('\\n')\n .map((line) => line.trim())\n .filter(Boolean)\n const last = lines[lines.length - 1]\n if (!last) return false\n // A closed question ends with \"?\" — except when the answer instruction takes\n // up the last line (\"Reply YES to confirm.\").\n if (!last.includes('?') && !ANSWER_HINT[language].test(last)) return false\n\n return PATTERNS[language].some((pattern) => pattern.test(last))\n}\n","/**\n * Decision on a tool call the agent stopped before making: yes, or no.\n *\n * The agent paused before calling the tool and wrote what it would do (that is the\n * message body); these buttons are what releases the call, not a bare \"yes\"\n * interpreted by the model. Nothing has been written while they are here.\n *\n * **When it wrote nothing, the call speaks for itself.** Several models ask for a\n * tool with no sentence at all, and a visitor then faces an empty bubble with two\n * buttons under it — a decision nobody can take. So `call`, passed only in that\n * case, names what would be used and with what: approving \"read a pull request\"\n * is not approving *which* one. The values come from a model and are printed as\n * text, never as markup.\n *\n * Two answers and no third. There used to be a \"correct it\" button that opened an\n * input, and the API has never had anything to send it to — a control that cannot be\n * honoured is worse than one that is missing. Saying something else is a new\n * message, and the backend closes the pending call as it goes out: asking instead of\n * deciding is a decision too.\n *\n * Once the decision is made the group is frozen — the history has to stay readable,\n * and a call is not approved twice.\n */\nimport type { JSX } from 'preact'\nimport { useState } from 'preact/hooks'\n\nimport type { Locale } from '../lib/i18n'\nimport type { PendingApproval } from '../types'\n\nexport interface ApprovalProps {\n locale: Locale\n /** The paused call, when the agent asked for it without a word of its own.\n * Absent when it explained itself: its sentence is the message body, and\n * saying the same thing twice reads as two requests. */\n call?: PendingApproval\n /** Absent when the group is frozen: decision already made, or turn in flight. */\n onDecide?: (approved: boolean, label: string) => void\n}\n\n/** The qualification the toolbox adds so two servers may both offer `search`:\n * `mcp_`, `custom_` or `a2a_`, then eight hex characters of an id. Ours, and\n * meaningless to a visitor. */\nconst QUALIFIED_TOOL_NAME = /^(?:mcp|custom|a2a)_[0-9a-f]{8}_/\n\n/** A name a person can read: `pull_request_read` becomes \"Pull request read\".\n * Shaped like the context chips, which humanise the host's own keys the same\n * way — an unreadable name is what makes a decision impossible to take. */\nfunction readable(name: string): string {\n const words = name\n .replace(QUALIFIED_TOOL_NAME, '')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/[_-]+/g, ' ')\n .trim()\n .toLowerCase()\n if (!words) return name\n return words.charAt(0).toUpperCase() + words.slice(1)\n}\n\n/** One argument as a line of text. A flag is said as yes or no, and objects and\n * lists are printed as JSON rather than as \"[object Object]\": a value nobody can\n * read is a value nobody can approve. */\nfunction shown(value: unknown, locale: Locale): string {\n if (value === true) return locale.t.confirm.yes\n if (value === false) return locale.t.confirm.no\n if (typeof value === 'string') return value\n return JSON.stringify(value) ?? String(value)\n}\n\nexport function Approval({ locale, call, onDecide }: ApprovalProps): JSX.Element {\n const { approval, confirm } = locale.t\n const [picked, setPicked] = useState<string | null>(null)\n const live = Boolean(onDecide) && picked === null\n\n const choose = (approved: boolean, label: string): void => {\n setPicked(label)\n onDecide?.(approved, label)\n }\n\n const values = call ? Object.entries(call.arguments) : []\n\n return (\n <div class=\"sqc-approval\" role=\"group\" aria-label={approval.group}>\n {call && (\n <p class=\"sqc-approval__request\" data-testid=\"sqc-approval-tool\">\n {approval.request.replace('{tool}', readable(call.tool))}\n </p>\n )}\n {values.length > 0 && (\n <dl class=\"sqc-approval__args\" data-testid=\"sqc-approval-arguments\">\n {values.map(([name, value]) => (\n <div class=\"sqc-approval__arg\" key={name}>\n <dt class=\"sqc-approval__arg-name\">{readable(name)}</dt>\n <dd class=\"sqc-approval__arg-value\">{shown(value, locale)}</dd>\n </div>\n ))}\n </dl>\n )}\n <div class=\"sqc-approval__actions\">\n <button\n type=\"button\"\n class=\"sqc-approval__btn sqc-approval__btn--yes\"\n aria-pressed={picked === confirm.yes}\n disabled={!live}\n onClick={() => choose(true, confirm.yes)}\n >\n {approval.approve}\n </button>\n <button\n type=\"button\"\n class=\"sqc-approval__btn sqc-approval__btn--no\"\n aria-pressed={picked === confirm.no}\n disabled={!live}\n onClick={() => choose(false, confirm.no)}\n >\n {approval.reject}\n </button>\n </div>\n </div>\n )\n}\n","/**\n * \"Yes\" / \"No\" buttons under a closed question from the assistant.\n *\n * A bare \"yes\" or \"no\" is recognised agent-side without going through the LLM,\n * so clicking is exactly the same as typing the answer. As with the tickable\n * options, the group locks on the choice made, so the history stays readable.\n */\nimport type { JSX } from 'preact'\nimport { useState } from 'preact/hooks'\nimport type { Locale } from '../lib/i18n'\n\nexport interface ConfirmProps {\n locale: Locale\n /** Absent when the group is frozen: older message, or turn in flight. */\n onPick?: (answer: string) => void\n}\n\nexport function Confirm({ locale, onPick }: ConfirmProps): JSX.Element {\n const [picked, setPicked] = useState<string | null>(null)\n const live = Boolean(onPick) && picked === null\n const { confirm } = locale.t\n // The word sent is the one of the user's own language: the agent recognises a\n // bare \"yes\" without a model call, but in that language.\n const answers = [\n { value: confirm.yesValue, label: confirm.yes, kind: 'yes' },\n { value: confirm.noValue, label: confirm.no, kind: 'no' },\n ]\n\n return (\n <div class=\"sqc-confirm\" role=\"group\" aria-label={confirm.group}>\n {answers.map((answer) => (\n <button\n key={answer.value}\n type=\"button\"\n class={`sqc-confirm__btn sqc-confirm__btn--${answer.kind}`}\n aria-pressed={picked === answer.value}\n disabled={!live}\n onClick={() => {\n setPicked(answer.value)\n onPick?.(answer.value)\n }}\n >\n {answer.label}\n </button>\n ))}\n </div>\n )\n}\n","/**\n * Clickable options built from the Markdown checkboxes (`- [ ] Name`) the\n * assistant writes when it offers candidates.\n *\n * The agent resolves the answer by name, so clicking an option amounts to\n * sending its exact label as a message. The choice is single — the agent expects\n * one candidate per turn — and the group locks as soon as an option is taken, so\n * the history stays readable.\n */\nimport type { ComponentChildren, JSX } from 'preact'\nimport { useState } from 'preact/hooks'\nimport type { Locale } from '../lib/i18n'\n\nexport interface ChoiceItem {\n /** Plain text sent to the agent. */\n label: string\n /** Checkbox already ticked in the Markdown (`- [x] …`). */\n checked: boolean\n /** Rendered label (inline Markdown is already applied to it). */\n content: ComponentChildren\n}\n\nfunction CheckIcon(): JSX.Element {\n return (\n <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" aria-hidden=\"true\">\n <path d=\"M3.5 8.5l3 3 6-7\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\n </svg>\n )\n}\n\nexport interface ChoicesProps {\n items: ChoiceItem[]\n locale: Locale\n /** Absent when the group is frozen: older message, or turn in flight. */\n onPick?: (label: string) => void\n}\n\nexport function Choices({ items, locale, onPick }: ChoicesProps): JSX.Element {\n const [picked, setPicked] = useState<string | null>(null)\n const live = Boolean(onPick) && picked === null\n\n return (\n <div class=\"sqc-choices\" role=\"group\" aria-label={locale.t.choices}>\n {items.map((item, index) => {\n // Once a choice is made it becomes the only ticked option: the Markdown\n // state only holds until the user has decided.\n const on = picked === null ? item.checked : picked === item.label\n return (\n <button\n key={`${index}-${item.label}`}\n type=\"button\"\n class=\"sqc-choice\"\n aria-pressed={on}\n disabled={!live}\n onClick={() => {\n setPicked(item.label)\n onPick?.(item.label)\n }}\n >\n <span class={`sqc-choice__box${on ? ' sqc-choice__box--on' : ''}`} aria-hidden=\"true\">\n {on && <CheckIcon />}\n </span>\n <span class=\"sqc-choice__label\">{item.content}</span>\n </button>\n )\n })}\n </div>\n )\n}\n","/**\n * Minimal Markdown rendering of the agent's answers.\n *\n * The agent answers with a stable subset of Markdown: headings, lists\n * (sometimes nested), tables (record listings), identifiers in backticks, links.\n * That subset is covered and nothing more: no Markdown library (weight), and\n * above all **never** any injected HTML — everything is produced as Preact\n * nodes, hence escaped by construction.\n */\nimport type { JSX } from 'preact'\nimport type { Locale } from '../lib/i18n'\nimport { Choices, type ChoiceItem } from './Choices'\n\ntype Inline = JSX.Element | string\n\n/**\n * Emphasis, code, Markdown links and bare URLs. Deliberately without `_`/`__`:\n * domain identifiers (`order_id`, `record_ref`, `item_1`) would be turned into\n * italics at the first pair.\n */\nconst INLINE =\n /(\\*\\*[^*\\n]+\\*\\*|`[^`\\n]+`|~~[^~\\n]+~~|\\[[^\\]\\n]+\\]\\([^)\\s]+\\)|\\*[^*\\n]+\\*|https?:\\/\\/[^\\s<>()]+)/g\n\nconst MD_LINK = /^\\[([^\\]\\n]+)\\]\\(([^)\\s]+)\\)$/\n/** An href is only rendered when it is navigable: no `javascript:`, no `data:`. */\nconst SAFE_HREF = /^(https?:|mailto:)/i\n\nfunction link(href: string, label: string, key: string): Inline {\n if (!SAFE_HREF.test(href)) return label\n return (\n <a key={key} href={href} target=\"_blank\" rel=\"noopener noreferrer\">\n {label}\n </a>\n )\n}\n\nfunction inline(text: string, keyPrefix: string): Inline[] {\n const parts = text.split(INLINE)\n const nodes: Inline[] = []\n\n parts.forEach((part, index) => {\n if (!part) return\n const key = `${keyPrefix}-${index}`\n const mdLink = MD_LINK.exec(part)\n\n if (part.startsWith('**') && part.endsWith('**') && part.length > 4) {\n nodes.push(<strong key={key}>{part.slice(2, -2)}</strong>)\n } else if (part.startsWith('`') && part.endsWith('`') && part.length > 2) {\n nodes.push(<code key={key}>{part.slice(1, -1)}</code>)\n } else if (part.startsWith('~~') && part.endsWith('~~') && part.length > 4) {\n nodes.push(<del key={key}>{part.slice(2, -2)}</del>)\n } else if (mdLink) {\n nodes.push(link(mdLink[2], mdLink[1], key))\n } else if (part.startsWith('*') && part.endsWith('*') && part.length > 2) {\n nodes.push(<em key={key}>{part.slice(1, -1)}</em>)\n } else if (/^https?:\\/\\//.test(part)) {\n nodes.push(link(part, part, key))\n } else {\n nodes.push(part)\n }\n })\n\n return nodes\n}\n\n/**\n * Markdown checkbox, with or without a bullet: the agent writes `- [ ] Name`,\n * but `[ ] Name` is accepted too so this does not depend on the exact template.\n */\nconst CHOICE = /^\\s*(?:[-*•]\\s+)?\\[([ xX])\\]\\s+(.+)$/\n\n/** Text without markup: what the agent must receive when an option is clicked. */\nfunction plain(text: string): string {\n return text\n .replace(/\\[([^\\]\\n]+)\\]\\([^)\\s]+\\)/g, '$1')\n .replace(/\\*\\*|~~|`|\\*/g, '')\n .trim()\n}\n\nconst BULLET = /^(\\s*)[-*•]\\s+/\nconst ORDERED = /^(\\s*)\\d+[.)]\\s+/\nconst HEADING = /^\\s{0,3}(#{1,6})\\s+(.+?)#*\\s*$/\nconst RULE = /^\\s*([-*_])(?:\\s*\\1){2,}\\s*$/\nconst QUOTE = /^\\s*>\\s?(.*)$/\nconst TABLE_ROW = /^\\s*\\|.*\\|\\s*$/\nconst TABLE_SEP = /^\\s*\\|(?:\\s*:?-{1,}:?\\s*\\|)+\\s*$/\nconst FENCE = /^\\s*```/\n\ninterface ListItem {\n depth: number\n ordered: boolean\n text: string\n}\n\n/** Splits a table row into cells (escaped pipes are not handled). */\nfunction cells(row: string): string[] {\n return row\n .replace(/^\\s*\\|/, '')\n .replace(/\\|\\s*$/, '')\n .split('|')\n .map((cell) => cell.trim())\n}\n\n/**\n * Rebuilds nested lists from flat items carrying their indentation depth.\n * Returns the list and the index of the first item left unconsumed.\n */\nfunction buildList(\n items: ListItem[],\n start: number,\n depth: number,\n key: string,\n): [JSX.Element, number] {\n const ordered = items[start].ordered\n const entries: { key: string; text: string | null; nested: JSX.Element[] }[] = []\n let index = start\n\n while (index < items.length && items[index].depth >= depth) {\n const item = items[index]\n // A marker of another kind at the same level opens a separate list rather\n // than mixing bullets and numbers.\n if (item.depth === depth && item.ordered !== ordered) break\n\n if (item.depth > depth) {\n const [nested, next] = buildList(items, index, item.depth, `${key}-${index}`)\n const last = entries[entries.length - 1]\n // A sub-list with no parent (first line already indented) is held in an\n // empty item rather than lost.\n if (last) last.nested.push(nested)\n else entries.push({ key: `${key}-${index}`, text: null, nested: [nested] })\n index = next\n continue\n }\n\n entries.push({ key: `${key}-${index}`, text: item.text, nested: [] })\n index += 1\n }\n\n const children = entries.map((entry) => (\n <li key={entry.key}>\n {entry.text === null ? null : inline(entry.text, entry.key)}\n {entry.nested}\n </li>\n ))\n\n const list = ordered ? (\n <ol key={key}>{children}</ol>\n ) : (\n <ul key={key}>{children}</ul>\n )\n return [list, index]\n}\n\nexport interface RichTextProps {\n text: string\n locale: Locale\n /** Makes the checkboxes clickable; absent, they stay displayed but frozen. */\n onChoice?: (label: string) => void\n}\n\nexport function RichText({ text, locale, onChoice }: RichTextProps): JSX.Element {\n const lines = text.split('\\n')\n const blocks: JSX.Element[] = []\n\n let paragraph: string[] = []\n let items: ListItem[] = []\n let quote: string[] = []\n\n const flushParagraph = (): void => {\n if (!paragraph.length) return\n const key = `p${blocks.length}`\n blocks.push(<p key={key}>{inline(paragraph.join('\\n'), key)}</p>)\n paragraph = []\n }\n\n const flushList = (): void => {\n if (!items.length) return\n let index = 0\n while (index < items.length) {\n const key = `l${blocks.length}`\n const [list, next] = buildList(items, index, items[index].depth, key)\n blocks.push(list)\n index = next\n }\n items = []\n }\n\n const flushQuote = (): void => {\n if (!quote.length) return\n const key = `q${blocks.length}`\n blocks.push(<blockquote key={key}>{inline(quote.join('\\n'), key)}</blockquote>)\n quote = []\n }\n\n const flushAll = (): void => {\n flushParagraph()\n flushList()\n flushQuote()\n }\n\n for (let cursor = 0; cursor < lines.length; cursor += 1) {\n const line = lines[cursor]\n\n // Code block: everything is taken literally until the closing fence. An\n // unclosed block (answer cut mid-stream) is rendered as-is rather\n // than lost.\n if (FENCE.test(line)) {\n flushAll()\n const fence: string[] = []\n cursor += 1\n while (cursor < lines.length && !FENCE.test(lines[cursor])) {\n fence.push(lines[cursor])\n cursor += 1\n }\n const key = `c${blocks.length}`\n blocks.push(\n <pre key={key}>\n <code>{fence.join('\\n')}</code>\n </pre>,\n )\n continue\n }\n\n // Table: only recognised when the header is followed by the separator row,\n // otherwise a sentence containing pipes would become a table.\n if (TABLE_ROW.test(line) && cursor + 1 < lines.length && TABLE_SEP.test(lines[cursor + 1])) {\n flushAll()\n const header = cells(line)\n const rows: string[][] = []\n cursor += 2\n while (cursor < lines.length && TABLE_ROW.test(lines[cursor])) {\n rows.push(cells(lines[cursor]))\n cursor += 1\n }\n cursor -= 1\n\n const key = `t${blocks.length}`\n blocks.push(\n <div key={key} class=\"sqc-table\">\n <table>\n <thead>\n <tr>\n {header.map((cell, index) => (\n <th key={`${key}-h${index}`}>{inline(cell, `${key}-h${index}`)}</th>\n ))}\n </tr>\n </thead>\n <tbody>\n {rows.map((row, rowIndex) => (\n <tr key={`${key}-r${rowIndex}`}>\n {header.map((_, index) => (\n <td key={`${key}-r${rowIndex}c${index}`}>\n {inline(row[index] ?? '', `${key}-r${rowIndex}c${index}`)}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>,\n )\n continue\n }\n\n if (!line.trim()) {\n flushAll()\n continue\n }\n\n // Consecutive checkboxes: a single option group, not a list.\n if (CHOICE.test(line)) {\n flushAll()\n const choices: ChoiceItem[] = []\n while (cursor < lines.length) {\n const choice = CHOICE.exec(lines[cursor])\n if (!choice) break\n const label = choice[2].trim()\n const key = `o${blocks.length}-${choices.length}`\n choices.push({\n // The label sent back to the agent is stripped of its markup: it is\n // matched against the candidates by name comparison.\n label: plain(label),\n checked: choice[1].toLowerCase() === 'x',\n content: inline(label, key),\n })\n cursor += 1\n }\n cursor -= 1\n blocks.push(\n <Choices key={`o${blocks.length}`} items={choices} locale={locale} onPick={onChoice} />,\n )\n continue\n }\n\n const heading = HEADING.exec(line)\n if (heading) {\n flushAll()\n // In a chat bubble a typographic h1 makes no sense: the six Markdown\n // levels are compressed onto h3–h5.\n const depth = heading[1].length\n const Tag = (depth <= 2 ? 'h3' : depth === 3 ? 'h4' : 'h5') as 'h3'\n const key = `h${blocks.length}`\n blocks.push(<Tag key={key}>{inline(heading[2], key)}</Tag>)\n continue\n }\n\n if (RULE.test(line)) {\n flushAll()\n blocks.push(<hr key={`r${blocks.length}`} />)\n continue\n }\n\n const quoted = QUOTE.exec(line)\n if (quoted) {\n flushParagraph()\n flushList()\n quote.push(quoted[1])\n continue\n }\n\n const bullet = BULLET.exec(line)\n const ordered = bullet ? null : ORDERED.exec(line)\n const marker = bullet ?? ordered\n\n if (marker) {\n flushParagraph()\n flushQuote()\n items.push({\n // The raw indentation serves as relative depth: only the comparison\n // between items matters, not the absolute value.\n depth: marker[1].replace(/\\t/g, ' ').length,\n ordered: Boolean(ordered),\n text: line.slice(marker[0].length),\n })\n continue\n }\n\n flushList()\n flushQuote()\n paragraph.push(line)\n }\n\n flushAll()\n\n return <>{blocks}</>\n}\n","import type { JSX } from 'preact'\nimport { useEffect, useLayoutEffect, useRef, useState } from 'preact/hooks'\nimport { isConfirmationPrompt } from '../lib/confirm'\nimport type { Locale } from '../lib/i18n'\nimport type { ChatAttachment, ChatMessage } from '../types'\nimport { Approval } from './Approval'\nimport { Confirm } from './Confirm'\nimport { RichText } from './RichText'\n\n/** Below this distance (px) from the bottom of the list, the user is taken to\n * be following the stream and the list keeps scrolling for them. Beyond it,\n * they have scrolled back through the history: their scroll is left alone. */\nconst STICK_THRESHOLD = 80\n\nfunction Time({ at, locale }: { at: number; locale: Locale }): JSX.Element {\n const date = new Date(at)\n return (\n <time class=\"sqc-msg__time\" dateTime={date.toISOString()}>\n {date.toLocaleTimeString(locale.tag, { hour: '2-digit', minute: '2-digit' })}\n </time>\n )\n}\n\n/** Reads one file's bytes, as a URL this component owns and revokes. */\nexport type AttachmentLoader = (attachmentId: string) => Promise<Blob>\n\n/**\n * One attached picture, drawn once its bytes have arrived.\n *\n * Fetched rather than linked, because the route that serves it is opened by the\n * visitor token — which travels in a header, and a header is what an `<img src>`\n * cannot send. The object URL is revoked when the bubble goes: without that,\n * every picture of a long conversation stays in memory until the page does.\n *\n * A file that will not load draws as its name. The panel is a chat window, not\n * a file manager, and a broken image icon says less than the filename does.\n */\nfunction Picture({ file, load }: { file: ChatAttachment; load: AttachmentLoader }): JSX.Element {\n const [src, setSrc] = useState<string | null>(null)\n\n useEffect(() => {\n let url: string | null = null\n let alive = true\n void load(file.id)\n .then((blob) => {\n if (!alive) return\n url = URL.createObjectURL(blob)\n setSrc(url)\n })\n .catch(() => {\n // Drawn as its name below, which is what a file nobody can open is.\n })\n return () => {\n alive = false\n if (url) URL.revokeObjectURL(url)\n }\n }, [file.id, load])\n\n if (!src) return <span class=\"sqc-chip sqc-chip--waiting\">{file.filename}</span>\n return <img class=\"sqc-attachment__image\" src={src} alt={file.filename} />\n}\n\n/** The files one turn was sent with, under what was written. */\nfunction Attachments({\n files,\n load,\n}: {\n files: ChatAttachment[]\n load?: AttachmentLoader\n}): JSX.Element | null {\n if (files.length === 0 || !load) return null\n return (\n <div class=\"sqc-attachments sqc-attachments--sent\">\n {files.map((file) =>\n file.kind === 'image' ? (\n <Picture key={file.id} file={file} load={load} />\n ) : (\n <span key={file.id} class=\"sqc-chip\" data-kind=\"document\">\n <span class=\"sqc-chip__name\">{file.filename}</span>\n </span>\n ),\n )}\n </div>\n )\n}\n\nfunction Bubble({\n message,\n locale,\n assistantName,\n onChoice,\n onDecide,\n onLoadAttachment,\n}: {\n message: ChatMessage\n locale: Locale\n /** Name the assistant signs its messages with. */\n assistantName: string\n onChoice?: (label: string) => void\n onDecide?: (approved: boolean, label: string) => void\n onLoadAttachment?: AttachmentLoader\n}): JSX.Element {\n const pending = message.streaming && !message.content\n // A paused call carries its own buttons: the \"Do you confirm?\" of the recap\n // must not bring up a second pair.\n const awaiting = Boolean(message.approval)\n\n return (\n <div class={`sqc-msg sqc-msg--${message.role}${message.error ? ' sqc-msg--error' : ''}`}>\n {/* The design system does not put the agent's answer in a bubble: it is\n signed by this line, then set in serif flat on the panel background. */}\n {message.role === 'assistant' && (\n <div class=\"sqc-msg__who\">\n {/* Whoever answered, where an application holds several agents: the\n emoji and the handle are what tell them apart in a transcript, and\n a single-agent panel keeps signing with the name it was given. */}\n {message.agent?.avatarEmoji ? (\n <span class=\"sqc-msg__emoji\" aria-hidden=\"true\">\n {message.agent.avatarEmoji}\n </span>\n ) : (\n <ChatIcon />\n )}\n {message.authorName ?? message.agent?.name ?? assistantName}\n </div>\n )}\n <div class=\"sqc-msg__bubble\">\n {pending ? (\n <span class=\"sqc-typing\" aria-label={locale.t.typing}>\n <i />\n <i />\n <i />\n </span>\n ) : (\n <div class=\"sqc-msg__body\">\n <RichText text={message.content} locale={locale} onChoice={onChoice} />\n {message.streaming && <span class=\"sqc-caret\" aria-hidden=\"true\" />}\n {/* Wait for the stream to end: the closed question is the last\n line, and is only recognisable once written. */}\n {/* The call describes itself only where the agent did not: several\n models ask for a tool with nothing said, and two buttons under an\n empty bubble are a decision nobody can take. */}\n {awaiting && (\n <Approval\n locale={locale}\n call={message.content.trim() === '' ? message.approval : undefined}\n onDecide={onDecide}\n />\n )}\n {!awaiting &&\n !message.streaming &&\n !message.error &&\n isConfirmationPrompt(message.content, locale.code) && (\n <Confirm locale={locale} onPick={onChoice} />\n )}\n {message.unknownHandle && !message.streaming && (\n <Unaddressed message={message} locale={locale} />\n )}\n <Attachments files={message.attachments ?? []} load={onLoadAttachment} />\n </div>\n )}\n {!pending && <Time at={message.createdAt} locale={locale} />}\n </div>\n </div>\n )\n}\n\n/**\n * The note under an answer whose message addressed a name nobody answers to.\n *\n * Under the answer and not in place of it: the question *was* answered, by the\n * agent that answers plain text, so this adds who could have been asked instead. A\n * mistyped name deserves help rather than a refusal.\n *\n * With nothing offered it says only that nobody answers to that name — an\n * organization that ticked no handle has chosen not to publish its list, and\n * quoting it here would undo that.\n */\nfunction Unaddressed({\n message,\n locale,\n}: {\n message: ChatMessage\n locale: Locale\n}): JSX.Element {\n const offered = message.offered ?? []\n return (\n <p class=\"sqc-msg__unaddressed\">\n <span>{locale.t.handles.unknown}</span> <code>@{message.unknownHandle}</code>\n {offered.length > 0 && (\n <>\n {' '}\n <span>{locale.t.handles.instead}</span>{' '}\n {offered.map((handle) => (\n <code key={handle.handle}>@{handle.handle}</code>\n ))}\n </>\n )}\n </p>\n )\n}\n\n/** Lucide `message-circle`: the launcher, the panel title and every answer\n * coming from the assistant. */\nexport function ChatIcon(): JSX.Element {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <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\" />\n </svg>\n )\n}\n\nexport interface MessageListProps {\n messages: ChatMessage[]\n locale: Locale\n /** Name displayed above each answer. */\n assistantName: string\n suggestions?: string[]\n /** Suggestions are only shown on the first turn, as long as the user has\n * written nothing. */\n showSuggestions: boolean\n /** A turn is in flight: the last message's options are disabled. */\n busy?: boolean\n /** A human of the organization handles the conversation: said under the\n * transcript, since no agent will answer what comes next. */\n withHuman?: boolean\n onSuggestion: (text: string) => void\n /** Sends the label of a ticked option as the turn's answer. */\n onChoice: (label: string) => void\n /** Decides the tool call the last message put on hold. */\n onDecide: (approved: boolean, label: string) => void\n /** Reads the bytes of a file a turn carried. Absent where nothing can. */\n onLoadAttachment?: AttachmentLoader\n}\n\nexport function MessageList({\n messages,\n locale,\n assistantName,\n suggestions,\n showSuggestions,\n busy,\n withHuman,\n onSuggestion,\n onChoice,\n onDecide,\n onLoadAttachment,\n}: MessageListProps): JSX.Element {\n const scroller = useRef<HTMLDivElement | null>(null)\n const stick = useRef(true)\n\n // Measured before paint: at that point the DOM already carries the new\n // content, so the distance to the bottom only reflects the pre-render position\n // if it is updated on scroll — hence the handler below.\n useLayoutEffect(() => {\n const node = scroller.current\n if (node && stick.current) node.scrollTop = node.scrollHeight\n }, [messages])\n\n useEffect(() => {\n const node = scroller.current\n if (!node) return\n const onScroll = (): void => {\n stick.current = node.scrollHeight - node.scrollTop - node.clientHeight < STICK_THRESHOLD\n }\n node.addEventListener('scroll', onScroll, { passive: true })\n return () => node.removeEventListener('scroll', onScroll)\n }, [])\n\n return (\n <div class=\"sqc-messages\" ref={scroller} role=\"log\" aria-live=\"polite\" aria-atomic=\"false\">\n {messages.map((message, index) => (\n <Bubble\n key={message.id}\n message={message}\n locale={locale}\n assistantName={assistantName}\n // Only the last answer's options are live: those of earlier turns\n // have already been answered.\n onChoice={\n !busy && message.role === 'assistant' && index === messages.length - 1\n ? onChoice\n : undefined\n }\n onDecide={\n !busy && message.role === 'assistant' && index === messages.length - 1\n ? onDecide\n : undefined\n }\n onLoadAttachment={onLoadAttachment}\n />\n ))}\n\n {withHuman && (\n <p class=\"sqc-with-human\" role=\"status\">\n {locale.t.withHuman}\n </p>\n )}\n\n {showSuggestions && suggestions && suggestions.length > 0 && (\n <div class=\"sqc-suggestions\">\n {suggestions.map((suggestion) => (\n <button\n key={suggestion}\n type=\"button\"\n class=\"sqc-suggestion\"\n onClick={() => onSuggestion(suggestion)}\n >\n {suggestion}\n </button>\n ))}\n </div>\n )}\n </div>\n )\n}\n","import type { JSX } from 'preact'\nimport { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'preact/hooks'\nimport { contextLabel, isNamedObject } from '../lib/context'\nimport { resolveLocale, type Locale } from '../lib/i18n'\nimport { initialOpen, writeOpenState } from '../lib/openState'\nimport { useChat } from '../lib/useChat'\nimport type { ChatbotContext, ChatbotEvent, ChatbotOptions } from '../types'\nimport { Composer } from './Composer'\nimport { ChatIcon, MessageList } from './MessageList'\n\n// Sidebar width of the design system. No accent here: left unset, the\n// stylesheet picks it — black, or white in the dark theme — and a page's own\n// `--sqc-accent` on the element is not overwritten by a default.\nconst DEFAULTS = {\n width: 'min(392px, 100vw)',\n} as const\n\n/** Imperative surface exposed to the wrapper (custom element / React). */\nexport interface ChatbotControls {\n open(): void\n close(): void\n toggle(): void\n reset(): void\n send(text: string): void\n isOpen(): boolean\n sessionId(): string\n}\n\nexport interface ChatbotWidgetProps extends ChatbotOptions {\n onEvent?: (event: ChatbotEvent) => void\n /** Receives the imperative API on mount, `null` on unmount. */\n bind?: (controls: ChatbotControls | null) => void\n}\n\n/** Keys the widget owns: they name the conversation, not the host's page, so\n * they never become a chip. */\nconst HIDDEN_CONTEXT_KEYS = new Set<string>(['sessionId'])\n\n/** Turns a context key into a chip title: `orderId` and `order` both read\n * \"Order\", `deliveryDate` reads \"Delivery date\". The host names its own\n * entities — the widget knows no domain and only makes the key readable. */\nfunction chipLabel(key: string): string {\n const words = key\n .replace(/Id$|Ref$/, '')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/[_-]+/g, ' ')\n .trim()\n .toLowerCase()\n if (!words) return key\n return words.charAt(0).toUpperCase() + words.slice(1)\n}\n\n/**\n * Chips to display: one per context entry carrying a usable value.\n *\n * The value shown is the name when the host provided one\n * (`order: { id, name }`), the id otherwise — a UUID means nothing to the user,\n * but it is all there is when only the id was passed. Anything that is neither a\n * non-empty string nor a `{ id, … }` object is skipped: a chip claims something\n * is selected.\n */\nfunction contextChips(context: ChatbotContext | undefined): { label: string; value: string }[] {\n if (!context) return []\n const chips: { label: string; value: string }[] = []\n for (const [key, entry] of Object.entries(context)) {\n if (HIDDEN_CONTEXT_KEYS.has(key)) continue\n if (typeof entry !== 'string' && !isNamedObject(entry)) continue\n const value = contextLabel(entry)\n if (value) chips.push({ label: chipLabel(key), value })\n }\n return chips\n}\n\n/** An empty label replaces nothing: `heading=\"\"`, or a settings field cleared\n * by the host, hands it back to the translation instead of showing a blank\n * header. */\nfunction override(value: string | undefined, fallback: string): string {\n return value?.trim() ? value : fallback\n}\n\n/** Resolves `theme: 'auto'` to light/dark and follows the system changes. */\nfunction useResolvedTheme(theme: ChatbotOptions['theme']): 'light' | 'dark' {\n const [systemDark, setSystemDark] = useState(false)\n\n useEffect(() => {\n if (theme !== 'auto' || typeof matchMedia !== 'function') return\n const query = matchMedia('(prefers-color-scheme: dark)')\n setSystemDark(query.matches)\n const onChange = (event: MediaQueryListEvent): void => setSystemDark(event.matches)\n query.addEventListener('change', onChange)\n return () => query.removeEventListener('change', onChange)\n }, [theme])\n\n if (theme === 'dark') return 'dark'\n if (theme === 'light') return 'light'\n return systemDark ? 'dark' : 'light'\n}\n\nexport function ChatbotWidget(props: ChatbotWidgetProps): JSX.Element {\n const persistOpen = props.persistOpen ?? true\n const [open, setOpen] = useState(() => initialOpen(props.defaultOpen, persistOpen))\n const [interacted, setInteracted] = useState(false)\n const [unread, setUnread] = useState(false)\n const panel = useRef<HTMLDivElement | null>(null)\n const launcher = useRef<HTMLButtonElement | null>(null)\n\n const theme = useResolvedTheme(props.theme ?? 'light')\n // All the widget's copy comes from here: the language is the one the host\n // declares, and the labels it provides itself (`heading`, `greeting`…) win\n // over the translation.\n const locale: Locale = useMemo(() => resolveLocale(props.locale), [props.locale])\n const t = locale.t\n const heading = override(props.heading, t.heading)\n const assistantName = override(props.assistantName, t.assistant)\n const greeting = override(props.greeting, t.greeting)\n\n const onEvent = props.onEvent\n const chat = useChat({\n embedKey: props.embedKey,\n user: props.user,\n getSubjectToken: props.getSubjectToken,\n agent: props.agent,\n context: props.context,\n greeting,\n locale,\n onEvent,\n })\n\n const {\n send: sendChat,\n reset: resetChat,\n decide,\n stop,\n start,\n busy,\n messages,\n withHuman,\n branding,\n sessionId,\n handles,\n addressee,\n attachments,\n uploading,\n attachmentError,\n attach,\n detach,\n loadAttachment,\n } = chat\n\n // A message received while the sidebar is closed lights the badge on the\n // floating button: it is the only notification channel when the panel is\n // hidden (the case of a `sendMessage()` triggered by the host page).\n useEffect(() => {\n if (!open && messages.some((message) => message.role === 'assistant' && message.id !== 'greeting')) {\n setUnread(true)\n }\n }, [messages, open])\n\n // Synchronous mirror of `open`: `openPanel`/`closePanel` have to know whether\n // they really change the state, so the event is emitted once, without slipping\n // a side effect into the `setOpen` updater.\n const isOpen = useRef(open)\n isOpen.current = open\n\n const openPanel = useCallback(() => {\n setUnread(false)\n if (isOpen.current) return\n isOpen.current = true\n setOpen(true)\n if (persistOpen) writeOpenState(true)\n onEvent?.({ type: 'chatbot-open', sessionId })\n }, [onEvent, persistOpen, sessionId])\n\n const closePanel = useCallback(() => {\n if (!isOpen.current) return\n isOpen.current = false\n setOpen(false)\n if (persistOpen) writeOpenState(false)\n onEvent?.({ type: 'chatbot-close', sessionId })\n // Hand the focus back to the floating button: without it the focus falls\n // back to the host page's `<body>` and keyboard navigation starts over.\n launcher.current?.focus()\n }, [onEvent, persistOpen, sessionId])\n\n // The conversation is opened when the panel is first shown, not on mount: a\n // panel nobody opened is a conversation nobody had — and no visitor token\n // handed to a page that never asked for one. Idempotent, so re-opening the\n // panel does not start a second one.\n useEffect(() => {\n if (open) start()\n }, [open, start])\n\n const send = useCallback(\n (text: string) => {\n setInteracted(true)\n sendChat(text)\n },\n [sendChat],\n )\n\n const reset = useCallback(() => {\n setInteracted(false)\n setUnread(false)\n resetChat()\n }, [resetChat])\n\n // The object exposed to the host has to be stable (a React `ref` must not\n // change identity on every render): it delegates to the fresh closures stored\n // in `handlers`.\n const handlers = useRef({ openPanel, closePanel, send, reset, sessionId })\n handlers.current = { openPanel, closePanel, send, reset, sessionId }\n\n const controls = useRef<ChatbotControls>({\n open: () => handlers.current.openPanel(),\n close: () => handlers.current.closePanel(),\n // `isOpen` (the synchronous mirror) rather than the render value: the host\n // has to be able to read `chatbot.open` right after `openChat()`, before the\n // next render.\n toggle: () => (isOpen.current ? handlers.current.closePanel() : handlers.current.openPanel()),\n reset: () => handlers.current.reset(),\n send: (text: string) => {\n handlers.current.openPanel()\n handlers.current.send(text)\n },\n isOpen: () => isOpen.current,\n sessionId: () => handlers.current.sessionId,\n })\n\n const bind = props.bind\n // `useLayoutEffect` rather than `useEffect`: plain Preact effects are deferred\n // until after paint, whereas the wrapper has to be able to call\n // `sendMessage()` as soon as `connectedCallback()` returns.\n useLayoutEffect(() => {\n bind?.(controls.current)\n return () => bind?.(null)\n }, [bind])\n\n // Escape closes the panel. The listener sits on `document`: shadow DOM\n // keyboard events bubble up to it, and it also covers the case where the focus\n // stayed in the host page.\n useEffect(() => {\n if (!open) return\n const onKeyDown = (event: KeyboardEvent): void => {\n if (event.key === 'Escape') {\n event.stopPropagation()\n closePanel()\n }\n }\n document.addEventListener('keydown', onKeyDown)\n return () => document.removeEventListener('keydown', onKeyDown)\n }, [closePanel, open])\n\n // A conversation is already there. The suggestions have no place under it:\n // they open a conversation, they do not continue one.\n const hasConversation = useMemo(\n () => messages.some((message) => message.id !== 'greeting'),\n [messages],\n )\n\n const chips = useMemo(() => contextChips(props.context), [props.context])\n const rootStyle = {\n ...(props.accent ? { '--sqc-accent': props.accent } : {}),\n '--sqc-width': props.width ?? DEFAULTS.width,\n } as JSX.CSSProperties\n\n return (\n <div\n class=\"sqc\"\n data-theme={theme}\n data-position={props.position ?? 'bottom-right'}\n data-layout={props.layout ?? 'sidebar'}\n data-open={open ? 'true' : 'false'}\n style={rootStyle}\n >\n <button\n ref={launcher}\n type=\"button\"\n class=\"sqc-launcher\"\n aria-label={heading}\n aria-expanded={open}\n aria-haspopup=\"dialog\"\n onClick={openPanel}\n >\n <span class=\"sqc-launcher__icon\">\n {/* The icon can be replaced by an element of the host page:\n `<squadico-chatbot><svg slot=\"launcher-icon\" /></…>`, or the\n `launcherIcon` prop of the React wrapper. A slot, not an option:\n the widget renders inside a shadow root, where a host component\n cannot be mounted — projected through a slot it stays in its own\n tree, with its own CSS, and inherits the button colour here through\n `currentColor`. The content below is the slot fallback, hence the\n default icon. */}\n <slot name=\"launcher-icon\" class=\"sqc-slot-icon\">\n <ChatIcon />\n </slot>\n </span>\n {unread && <span class=\"sqc-launcher__badge\" aria-hidden=\"true\" />}\n </button>\n\n <aside\n ref={panel}\n class=\"sqc-panel\"\n role=\"dialog\"\n aria-modal=\"false\"\n aria-label={heading}\n // `inert` removes the whole subtree from focus and accessibility when\n // the panel is slid off screen — otherwise tabbing would land in an\n // invisible panel.\n {...(open ? {} : { inert: true })}\n >\n <header class=\"sqc-header\">\n <span class=\"sqc-header__icon\" aria-hidden=\"true\">\n <ChatIcon />\n </span>\n <div class=\"sqc-header__titles\">\n <p class=\"sqc-header__heading\">{heading}</p>\n <p class=\"sqc-header__sub\">{override(props.subheading, t.subheading)}</p>\n </div>\n <button\n type=\"button\"\n class=\"sqc-icon-btn\"\n onClick={reset}\n aria-label={t.newConversation}\n data-tip={t.newConversation}\n >\n <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\">\n <path d=\"M20 12a8 8 0 1 1-2.6-5.9M20 4v4h-4\" stroke-linecap=\"round\" />\n </svg>\n </button>\n <button\n type=\"button\"\n class=\"sqc-icon-btn\"\n onClick={closePanel}\n aria-label={t.close}\n data-tip={t.closeTitle}\n >\n <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\">\n <path d=\"M6 6l12 12M18 6L6 18\" stroke-linecap=\"round\" />\n </svg>\n </button>\n </header>\n\n {chips.length > 0 && (\n <div class=\"sqc-context\" aria-label={t.context.region}>\n {chips.map((chip) => (\n <span key={chip.label} class=\"sqc-chip\" title={`${chip.label}: ${chip.value}`}>\n <b>{chip.label}</b>\n {chip.value}\n </span>\n ))}\n </div>\n )}\n\n <MessageList\n messages={messages}\n locale={locale}\n assistantName={assistantName}\n suggestions={props.suggestions}\n showSuggestions={!interacted && !hasConversation}\n busy={busy}\n withHuman={withHuman}\n onSuggestion={send}\n onChoice={send}\n onDecide={decide}\n onLoadAttachment={loadAttachment}\n />\n\n <Composer\n placeholder={override(props.placeholder, t.placeholder)}\n locale={locale}\n busy={busy}\n autoFocus={open}\n handles={handles}\n addressee={addressee}\n attachments={attachments}\n uploading={uploading}\n // Translated here rather than in the hook: the hook knows why an upload\n // was refused, and this is where the panel's language lives.\n attachmentError={attachmentError ? t.attachments[attachmentError] : undefined}\n onAttach={attach}\n onDetach={detach}\n onSend={send}\n onStop={stop}\n />\n\n <p class=\"sqc-hint\">{t.hint}</p>\n {branding && (\n <p class=\"sqc-powered\">\n <a href=\"https://squadico.com\" target=\"_blank\" rel=\"noopener noreferrer\">\n {t.poweredBy}\n </a>\n </p>\n )}\n </aside>\n </div>\n )\n}\n","/*\n * Stylesheet of the widget — injected into the shadow root (constructable\n * stylesheet where supported, `<style>` otherwise). It never leaks into the host\n * page, and the host page cannot override it: the only entry points for an\n * integrator are the `--sqc-*` variables, set on the custom element.\n *\n * `:host` uses `position: fixed; inset: 0; pointer-events: none`: a single\n * element depends on fixed positioning (hence a single breaking point should an\n * ancestor carry a `transform`), and the page stays entirely clickable through\n * the overlay.\n *\n * ── Design system ────────────────────────────────────────────\n * The Squadico design system (v2): near-monochrome. Action is black (hover\n * slate-800), everything around it is slate — white surfaces, slate-200 rules,\n * slate-900 text, slate-500 for what is secondary — and links are blue-600. One\n * sans-serif family, Plus Jakarta Sans. Radii follow its hierarchy: 16px for\n * what holds content (the bubbles), 12px for what is pressed or typed into,\n * 8px for utility icon buttons, full for badges and the launcher. The values\n * are hard-copied here under internal `--sqc-*` names: the widget is a\n * standalone npm package and cannot depend on the host application's CSS\n * variables (they do not exist inside the shadow root of the other\n * integrations).\n *\n * The accent is black by default and the page's to change (`accent`, or\n * `--sqc-accent` on the element). Left unset, the stylesheet decides, which is\n * what lets the dark theme — a derivation on the slate scale, kept because\n * `theme: 'dark' | 'auto'` is part of the public contract — turn it white. The\n * text drawn on it is worked out from its lightness where the browser can.\n *\n * The typeface is referenced, never downloaded: the widget issues no font\n * request. If the host loads it, `font-family` resolution crosses the shadow\n * root and the widget benefits; otherwise the system fallbacks apply.\n */\n\n:host {\n /* ── Public extension points ────────────────────────────── */\n /* `--sqc-accent` is one too, deliberately left unset here: see `.sqc`. */\n --sqc-width: min(392px, 100vw);\n /* Height of the floating window (`layout=\"floating\"`), never taller than\n the space it opens in; the sidebar always takes the full height. */\n --sqc-height: 640px;\n --sqc-z: 2147483000;\n --sqc-radius: 16px;\n --sqc-font-family:\n 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica,\n Arial, sans-serif;\n --sqc-font-heading: var(--sqc-font-family);\n\n position: fixed;\n inset: 0;\n /* Fixed over the whole viewport, so a margin the page's layout gives its\n children — a `space-y-*` column — would shorten the sidebar by as much and\n leave a strip under it. A page's rules beat `:host` except against\n `!important`, which is why this one carries it. */\n margin: 0 !important;\n z-index: var(--sqc-z);\n display: block;\n pointer-events: none;\n font-family: var(--sqc-font-family);\n font-size: 14px;\n line-height: 1.5;\n /* Isolates the type from the host page: without it a `font-size: 62.5%` on\n `html` would render the whole widget at 8.75px. */\n -webkit-font-smoothing: antialiased;\n text-align: left;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.sqc {\n /* Raw design system scale (light): Tailwind's slate. */\n --sqc-neutral-50: #f8fafc;\n --sqc-neutral-100: #f1f5f9;\n --sqc-neutral-200: #e2e8f0;\n --sqc-neutral-300: #cbd5e1;\n --sqc-neutral-400: #94a3b8;\n --sqc-neutral-500: #64748b;\n --sqc-neutral-600: #475569;\n --sqc-neutral-900: #0f172a;\n --sqc-error-50: #fff1f2;\n --sqc-error-100: #ffe4e6;\n --sqc-error-600: #e11d48;\n\n /* Accent: the page's when it set one, black otherwise. */\n --sqc-accent-default: #000000;\n --sqc-accent-color: var(--sqc-accent, var(--sqc-accent-default));\n /* Text on the accent. White on the default black; the `@supports` below works\n it out for any other accent. */\n --sqc-on-accent: #ffffff;\n /* Hover of a filled button: the DS's black → slate-800, as a mix so that it\n holds for an accent the page chose. */\n --sqc-accent-hover: color-mix(in oklab, var(--sqc-accent-color) 84%, var(--sqc-on-accent));\n /* Accent used as a text colour (icons beside a title): the page's accent when\n it set one, the text colour otherwise. */\n --sqc-accent-fg: var(--sqc-accent, var(--sqc-text));\n\n /* Roles. */\n --sqc-bg: #ffffff; /* bg-white */\n --sqc-surface: var(--sqc-neutral-50); /* hover:bg-slate-50 */\n --sqc-selected: var(--sqc-neutral-100); /* active item: bg-slate-100 */\n --sqc-border: var(--sqc-neutral-200);\n --sqc-border-strong: var(--sqc-neutral-300); /* inputs, hovered outlines */\n --sqc-text: var(--sqc-neutral-900);\n --sqc-text-muted: var(--sqc-neutral-500);\n --sqc-link: #2563eb; /* blue-600 */\n --sqc-bubble-user: var(--sqc-accent-color);\n --sqc-bubble-user-text: var(--sqc-on-accent);\n --sqc-code-bg: var(--sqc-neutral-100);\n --sqc-disabled: var(--sqc-neutral-300); /* bg-slate-300 text-white */\n --sqc-shadow:\n 0 10px 15px -3px rgb(15 23 42 / 10%), 0 4px 6px -4px rgb(15 23 42 / 10%); /* shadow-lg */\n /* Bottom-only shadow (no halo around): the history menu, which spans the\n whole sidebar width rather than floating as a card. */\n --sqc-shadow-bottom: 0 6px 8px -6px rgb(15 23 42 / 18%);\n /* Neutral focus, never coloured: a ring for what is pressed, the DS's\n `focus:border-slate-900 focus:ring-slate-900/10` for what is typed into. */\n --sqc-focus: 0 0 0 2px var(--sqc-bg), 0 0 0 4px rgb(15 23 42 / 30%);\n --sqc-focus-input: 0 0 0 3px rgb(15 23 42 / 10%);\n --sqc-danger: var(--sqc-error-600);\n\n position: absolute;\n inset: 0;\n color: var(--sqc-text);\n}\n\n.sqc[data-theme='dark'] {\n --sqc-neutral-50: #172033;\n --sqc-neutral-100: #1e293b;\n --sqc-neutral-200: #334155;\n --sqc-neutral-300: #475569;\n --sqc-neutral-400: #64748b;\n --sqc-neutral-500: #94a3b8;\n --sqc-neutral-600: #cbd5e1;\n --sqc-neutral-900: #f8fafc;\n --sqc-error-50: #2a0a12;\n --sqc-error-100: #4c0519;\n --sqc-error-600: #fb7185;\n\n --sqc-accent-default: #ffffff;\n --sqc-on-accent: #0f172a;\n\n --sqc-bg: #0f172a; /* slate-900, the app's dark card */\n --sqc-link: #60a5fa;\n --sqc-code-bg: #020617;\n --sqc-shadow: 0 10px 24px -4px rgb(0 0 0 / 55%);\n --sqc-shadow-bottom: 0 6px 8px -6px rgb(0 0 0 / 55%);\n --sqc-focus: 0 0 0 2px var(--sqc-bg), 0 0 0 4px rgb(248 250 252 / 35%);\n --sqc-focus-input: 0 0 0 3px rgb(248 250 252 / 12%);\n}\n\n/* Text on an accent the page chose: white on a dark one, slate-900 on a light\n one, decided by its lightness. Where relative colours are not supported, the\n theme's default above stands. */\n@supports (color: oklch(from red l c h)) {\n .sqc {\n --sqc-on-accent: oklch(from var(--sqc-accent-color) clamp(0.208, (0.62 - l) * 1000, 1) 0 0);\n }\n}\n\n.sqc *,\n.sqc *::before,\n.sqc *::after {\n box-sizing: border-box;\n}\n\n/* ── Bouton flottant ──────────────────────────────────────── */\n\n.sqc-launcher {\n position: absolute;\n bottom: 24px;\n right: 24px;\n width: 56px;\n height: 56px;\n padding: 0;\n border: none;\n border-radius: 50%;\n background: var(--sqc-accent-color);\n color: var(--sqc-on-accent);\n cursor: pointer;\n pointer-events: auto;\n display: grid;\n place-items: center;\n box-shadow: var(--sqc-shadow);\n transition:\n transform 0.18s ease,\n opacity 0.18s ease,\n background 0.18s ease,\n box-shadow 0.18s ease;\n}\n\n.sqc[data-position='bottom-left'] .sqc-launcher {\n right: auto;\n left: 24px;\n}\n\n.sqc-launcher:hover {\n transform: scale(1.06);\n background: var(--sqc-accent-hover);\n}\n\n.sqc-launcher:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n/* Panel open: the button fades out, closing happens through the header. */\n.sqc[data-open='true'] .sqc-launcher {\n opacity: 0;\n transform: scale(0.5);\n pointer-events: none;\n}\n\n.sqc-launcher__icon svg {\n width: 26px;\n height: 26px;\n display: block;\n}\n\n/* Icon provided by the host (`slot=\"launcher-icon\"`): same frame as the default\n one. `::slotted()` can only target the projected node itself, never its\n descendants — a host wrapping its icon therefore has to size it on its own\n side, hence the centring here rather than a plain `display: block`. */\n.sqc-slot-icon::slotted(*) {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 26px;\n height: 26px;\n}\n\n.sqc-launcher__badge {\n position: absolute;\n top: 6px;\n right: 6px;\n width: 12px;\n height: 12px;\n border-radius: 50%;\n background: var(--sqc-error-600);\n border: 2px solid var(--sqc-bg);\n}\n\n/* ── Sidebar ──────────────────────────────────────────────── */\n\n.sqc-panel {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n width: var(--sqc-width);\n display: flex;\n flex-direction: column;\n background: var(--sqc-bg);\n border-left: 1px solid var(--sqc-border);\n box-shadow: var(--sqc-shadow);\n pointer-events: auto;\n transform: translateX(100%);\n /* `visibility` is delayed so it only hides at the end of the slide, and\n applied immediately on opening. */\n visibility: hidden;\n transition:\n transform 0.26s cubic-bezier(0.22, 1, 0.36, 1),\n visibility 0s linear 0.26s;\n}\n\n.sqc[data-open='true'] .sqc-panel {\n transform: translateX(0);\n visibility: visible;\n transition:\n transform 0.26s cubic-bezier(0.22, 1, 0.36, 1),\n visibility 0s;\n}\n\n/* ── Floating window ──────────────────────────────────────── */\n\n/* `layout=\"floating\"`: the same panel, lifted off the edge into a rounded\n window that grows out of the launcher's corner. */\n.sqc[data-layout='floating'] .sqc-panel {\n top: auto;\n bottom: 24px;\n right: 24px;\n /* Percentages of the host, which covers the viewport: on a page they are\n the viewport's, in a transformed frame (a preview) the frame's. */\n max-width: calc(100% - 48px);\n height: var(--sqc-height);\n max-height: calc(100% - 48px);\n border: 1px solid var(--sqc-border);\n border-radius: var(--sqc-radius);\n overflow: hidden;\n opacity: 0;\n transform: translateY(16px) scale(0.96);\n transform-origin: bottom right;\n transition:\n transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),\n opacity 0.22s ease,\n visibility 0s linear 0.22s;\n}\n\n.sqc[data-layout='floating'][data-position='bottom-left'] .sqc-panel {\n right: auto;\n left: 24px;\n transform-origin: bottom left;\n}\n\n.sqc[data-layout='floating'][data-open='true'] .sqc-panel {\n opacity: 1;\n transform: none;\n transition:\n transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),\n opacity 0.22s ease,\n visibility 0s;\n}\n\n/* ── Header ───────────────────────────────────────────────── */\n\n/* DS card header: white, bottom rule, bold slate-900 title — no coloured band. */\n.sqc-header {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 13px 12px 13px 16px;\n background: var(--sqc-bg);\n color: var(--sqc-text);\n border-bottom: 1px solid var(--sqc-border);\n flex-shrink: 0;\n}\n\n.sqc-header__icon {\n display: grid;\n place-items: center;\n flex-shrink: 0;\n color: var(--sqc-accent-fg);\n}\n\n.sqc-header__icon svg {\n width: 17px;\n height: 17px;\n display: block;\n}\n\n.sqc-header__titles {\n flex: 1;\n min-width: 0;\n}\n\n.sqc-header__heading,\n.sqc-header__sub {\n margin: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.sqc-header__heading {\n font-family: var(--sqc-font-heading);\n font-size: 15px;\n font-weight: 700;\n letter-spacing: -0.2px;\n}\n\n.sqc-header__sub {\n font-size: 12px;\n color: var(--sqc-text-muted);\n}\n\n.sqc-icon-btn {\n width: 26px;\n height: 26px;\n border: none;\n border-radius: 8px;\n background: none;\n color: var(--sqc-text-muted);\n cursor: pointer;\n display: grid;\n place-items: center;\n flex-shrink: 0;\n transition: background 0.15s ease;\n}\n\n.sqc-icon-btn:hover {\n background: var(--sqc-surface);\n color: var(--sqc-text);\n}\n\n.sqc-icon-btn:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n.sqc-icon-btn svg {\n width: 16px;\n height: 16px;\n}\n\n/* Tooltip of the header icons, in place of the native `title`: that one takes a\n second to appear, is drawn with the system font and theme — outside the shadow\n root, hence out of the panel's reach — and never shows on keyboard focus. The\n label is still carried by `aria-label`: the `::after` is decorative, and an\n assistive technology does not read the same text twice. */\n.sqc-icon-btn[data-tip] {\n position: relative;\n}\n\n.sqc-icon-btn[data-tip]::after {\n content: attr(data-tip);\n position: absolute;\n top: calc(100% + 6px);\n /* Anchored to the right of the button: the three icons sit against the right\n edge of the panel, and a centred bubble would overflow it. */\n right: 0;\n z-index: 6;\n padding: 4px 8px;\n border-radius: 8px;\n /* Inverts the panel colours: dark on light, light on dark, with no extra\n variable to expose. */\n background: var(--sqc-text);\n color: var(--sqc-bg);\n font-family: var(--sqc-font-family);\n font-size: 11px;\n font-weight: 500;\n line-height: 1.3;\n white-space: nowrap;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.12s ease 0.15s;\n}\n\n.sqc-icon-btn[data-tip]:hover::after,\n.sqc-icon-btn[data-tip]:focus-visible::after {\n opacity: 1;\n}\n\n/* ── Conversation history ─────────────────────────────────── */\n\n/* Full sidebar width, not a floating card: only a bottom shadow\n (`--sqc-shadow-bottom`) separates it from what sits below, with no border\n and no shadow all around. */\n.sqc-history-pop {\n position: absolute;\n left: 0;\n right: 0;\n top: 54px;\n z-index: 5;\n}\n\n.sqc-history {\n display: flex;\n flex-direction: column;\n max-height: 320px;\n overflow-y: auto;\n background: var(--sqc-bg);\n box-shadow: var(--sqc-shadow-bottom);\n}\n\n.sqc-history__empty {\n margin: 0;\n padding: 14px 16px;\n font-size: 12px;\n color: var(--sqc-text-muted);\n text-align: center;\n}\n\n.sqc-history__item {\n display: flex;\n flex-direction: column;\n gap: 2px;\n width: 100%;\n padding: 10px 16px;\n border: none;\n border-bottom: 1px solid var(--sqc-border);\n background: none;\n color: var(--sqc-text);\n text-align: left;\n cursor: pointer;\n transition: background 0.15s ease;\n}\n\n.sqc-history__item:last-child {\n border-bottom: none;\n}\n\n.sqc-history__item:hover {\n background: var(--sqc-surface);\n}\n\n.sqc-history__item:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n.sqc-history__item[aria-current='true'] {\n background: var(--sqc-selected);\n}\n\n.sqc-history__item[aria-current='true'] .sqc-history__title {\n color: var(--sqc-text);\n font-weight: 600;\n}\n\n.sqc-history__title {\n font-size: 13px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.sqc-history__date {\n font-size: 11px;\n color: var(--sqc-text-muted);\n}\n\n/* ── Bandeau de contexte ──────────────────────────────────── */\n\n/* A single reminder line, as a neutral slate-100 box. */\n.sqc-context {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n margin: 12px 16px 4px;\n padding: 8px 11px;\n background: var(--sqc-selected);\n border: 1px solid var(--sqc-border);\n border-radius: 12px;\n font-size: 12px;\n color: var(--sqc-text);\n flex-shrink: 0;\n}\n\n.sqc-chip {\n display: inline-flex;\n align-items: baseline;\n gap: 4px;\n max-width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.sqc-chip b {\n font-weight: 600;\n}\n\n/* Separator between two context chips, with no dedicated DOM node. */\n.sqc-chip:not(:last-child)::after {\n content: '·';\n margin-left: 4px;\n opacity: 0.5;\n}\n\n/* ── Fil de conversation ──────────────────────────────────── */\n\n.sqc-messages {\n flex: 1;\n min-height: 0;\n overflow-y: auto;\n overscroll-behavior: contain;\n padding: 12px 16px;\n display: flex;\n flex-direction: column;\n gap: 13px;\n background: var(--sqc-bg);\n scrollbar-width: thin;\n scrollbar-color: var(--sqc-neutral-300) transparent;\n}\n\n.sqc-messages::-webkit-scrollbar {\n width: 6px;\n}\n\n.sqc-messages::-webkit-scrollbar-thumb {\n background: var(--sqc-neutral-300);\n border-radius: 99px;\n}\n\n.sqc-msg {\n display: flex;\n flex-direction: column;\n max-width: 93%;\n font-size: 13.5px;\n}\n\n/* The agent's answer is not a bubble: it is signed by an \"Assistant\" line and\n set flat on the panel background, in the body typeface. */\n.sqc-msg--assistant {\n align-self: flex-start;\n}\n\n.sqc-msg--user {\n align-self: flex-end;\n}\n\n.sqc-msg__who {\n display: flex;\n align-items: center;\n gap: 6px;\n margin-bottom: 4px;\n font-size: 11px;\n font-weight: 500;\n color: var(--sqc-text-muted);\n}\n\n.sqc-msg__who svg {\n width: 12px;\n height: 12px;\n flex-shrink: 0;\n color: var(--sqc-accent-fg);\n}\n\n/* The note under an answer whose message addressed a name nobody answers to. Set\n quietly: the answer above it is what was asked for, and this only says who else\n could have been asked. */\n.sqc-msg__unaddressed {\n margin: 8px 0 0;\n font-size: 11.5px;\n line-height: 1.5;\n color: var(--sqc-text-muted);\n}\n\n.sqc-msg__unaddressed code {\n margin-right: 4px;\n padding: 1px 4px;\n border-radius: 4px;\n background: var(--sqc-code-bg);\n font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font-size: 11px;\n color: var(--sqc-text);\n}\n\n.sqc-msg--user .sqc-msg__bubble {\n padding: 9px 13px;\n background: var(--sqc-bubble-user);\n color: var(--sqc-bubble-user-text);\n border-radius: var(--sqc-radius) var(--sqc-radius) 4px var(--sqc-radius);\n}\n\n.sqc-msg--error .sqc-msg__bubble {\n padding: 11px;\n background: var(--sqc-error-50);\n color: var(--sqc-error-600);\n border: 1px solid var(--sqc-error-100);\n border-radius: 12px;\n}\n\n.sqc-msg__body {\n overflow-wrap: anywhere;\n}\n\n.sqc-msg--assistant .sqc-msg__body {\n font-size: 14px;\n line-height: 1.6;\n}\n\n.sqc-msg__body > *:first-child {\n margin-top: 0;\n}\n\n.sqc-msg__body > *:last-child {\n margin-bottom: 0;\n}\n\n.sqc-msg__body p {\n margin: 0 0 8px;\n white-space: pre-wrap;\n}\n\n.sqc-msg__body ul,\n.sqc-msg__body ol {\n margin: 0 0 8px;\n padding-left: 20px;\n}\n\n.sqc-msg__body li {\n margin-bottom: 3px;\n}\n\n.sqc-msg__body code {\n font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font-size: 0.85em;\n padding: 1px 4px;\n border-radius: 4px;\n background: var(--sqc-code-bg);\n}\n\n.sqc-msg--user .sqc-msg__body code {\n background: rgb(255 255 255 / 22%);\n}\n\n.sqc-msg__body pre {\n margin: 0 0 8px;\n padding: 9px 11px;\n border-radius: 8px;\n background: var(--sqc-code-bg);\n overflow-x: auto;\n}\n\n.sqc-msg__body pre code {\n padding: 0;\n background: none;\n}\n\n.sqc-msg__body a {\n color: inherit;\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n\n/* DS text link: blue-600, underlined on hover. Only in answers: on the accent of\n a bubble, blue would not read. */\n.sqc-msg--assistant .sqc-msg__body a {\n color: var(--sqc-link);\n text-decoration: none;\n}\n\n.sqc-msg--assistant .sqc-msg__body a:hover {\n text-decoration: underline;\n}\n\n/* Headings: ranked by weight and slightly by size — in a 13.5-14px thread, a\n typographic h1 would be grotesque. */\n.sqc-msg__body h3,\n.sqc-msg__body h4,\n.sqc-msg__body h5,\n.sqc-msg__body h6 {\n margin: 12px 0 6px;\n font-family: var(--sqc-font-heading);\n font-weight: 700;\n line-height: 1.3;\n letter-spacing: -0.2px;\n}\n\n.sqc-msg__body h3 {\n font-size: 1.05em;\n}\n\n.sqc-msg__body h4 {\n font-size: 1em;\n}\n\n.sqc-msg__body h5,\n.sqc-msg__body h6 {\n font-size: 0.94em;\n}\n\n.sqc-msg__body ul ul,\n.sqc-msg__body ul ol,\n.sqc-msg__body ol ul,\n.sqc-msg__body ol ol {\n margin: 3px 0 0;\n}\n\n.sqc-msg__body blockquote {\n margin: 0 0 8px;\n padding: 2px 0 2px 10px;\n border-left: 2px solid var(--sqc-border-strong);\n color: var(--sqc-text-muted);\n white-space: pre-wrap;\n}\n\n.sqc-msg--user .sqc-msg__body blockquote {\n border-left-color: rgb(255 255 255 / 45%);\n color: inherit;\n opacity: 0.85;\n}\n\n.sqc-msg__body hr {\n margin: 10px 0;\n border: 0;\n border-top: 1px solid var(--sqc-border);\n}\n\n.sqc-msg--user .sqc-msg__body hr {\n border-top-color: rgb(255 255 255 / 30%);\n}\n\n.sqc-msg__body del {\n opacity: 0.7;\n}\n\n/* Decision on a pending write: the agent showed the payload and stopped there.\n Reuses the `.sqc-confirm` buttons, with a third path opening a correction\n input. */\n.sqc-approval {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin: 11px 0 2px;\n}\n\n.sqc-approval__actions {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n}\n\n/* What the agent would do, said in its place when it said nothing itself. */\n.sqc-approval__request {\n margin: 0;\n font-size: 13px;\n color: var(--sqc-text);\n}\n\n/* The values it would be called with: a name and a value per line, the value\n free to wrap — an id or a URL is what several of them are. */\n.sqc-approval__args {\n display: flex;\n flex-direction: column;\n gap: 4px;\n margin: 0;\n padding: 8px 10px;\n border: 1px solid var(--sqc-border);\n border-radius: 12px;\n background: var(--sqc-surface);\n font-size: 12px;\n}\n\n.sqc-approval__arg {\n display: flex;\n gap: 8px;\n}\n\n.sqc-approval__arg-name {\n flex: 0 0 auto;\n font-weight: 500;\n color: var(--sqc-text-muted);\n}\n\n.sqc-approval__arg-value {\n margin: 0;\n min-width: 0;\n overflow-wrap: anywhere;\n color: var(--sqc-text);\n}\n\n.sqc-approval__btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 1 1 auto;\n height: 32px;\n padding: 0 12px;\n font-family: var(--sqc-font-family);\n font-size: 13px;\n font-weight: 500;\n border-radius: 12px;\n border: 1px solid var(--sqc-border);\n background: var(--sqc-bg);\n color: var(--sqc-text);\n cursor: pointer;\n transition:\n border-color 0.12s ease,\n background 0.12s ease;\n}\n\n.sqc-approval__btn--yes:not(:disabled),\n.sqc-approval__btn--send:not(:disabled) {\n border-color: transparent;\n background: var(--sqc-accent-color);\n color: var(--sqc-on-accent);\n font-weight: 600;\n}\n\n.sqc-approval__btn:hover:not(:disabled) {\n border-color: var(--sqc-border-strong);\n background: var(--sqc-surface);\n}\n\n.sqc-approval__btn--yes:hover:not(:disabled),\n.sqc-approval__btn--send:hover:not(:disabled) {\n border-color: transparent;\n background: var(--sqc-accent-hover);\n}\n\n.sqc-approval__btn:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n.sqc-approval__btn:disabled {\n cursor: default;\n}\n\n/* Frozen: the decision taken stays marked, the others fade out. */\n.sqc-approval__btn:disabled[aria-pressed='false'] {\n opacity: 0.45;\n}\n\n.sqc-approval__btn[aria-pressed='true'] {\n border-color: var(--sqc-border-strong);\n background: var(--sqc-selected);\n color: var(--sqc-text);\n font-weight: 600;\n}\n\n.sqc-approval__edit {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.sqc-approval__input {\n width: 100%;\n padding: 8px 10px;\n font-family: var(--sqc-font-family);\n font-size: 13px;\n line-height: 1.4;\n color: var(--sqc-text);\n background: var(--sqc-bg);\n border: 1px solid var(--sqc-border-strong);\n border-radius: 12px;\n resize: vertical;\n}\n\n.sqc-approval__input:focus-visible {\n outline: none;\n border-color: var(--sqc-text);\n box-shadow: var(--sqc-focus-input);\n}\n\n.sqc-approval__btn--send {\n align-self: flex-end;\n flex: 0 0 auto;\n}\n\n/* Answer to a closed question (\"Do you confirm the creation?\").\n DS `.cactions`: two 32px buttons sharing the width. */\n.sqc-confirm {\n display: flex;\n gap: 8px;\n margin: 11px 0 2px;\n}\n\n.sqc-confirm__btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 1 1 0;\n height: 32px;\n padding: 0 12px;\n font-family: var(--sqc-font-family);\n font-size: 13px;\n font-weight: 500;\n border-radius: 12px;\n border: 1px solid var(--sqc-border);\n background: var(--sqc-bg);\n color: var(--sqc-text);\n cursor: pointer;\n transition:\n border-color 0.12s ease,\n background 0.12s ease;\n}\n\n.sqc-confirm__btn--yes:not(:disabled) {\n border-color: transparent;\n background: var(--sqc-accent-color);\n color: var(--sqc-on-accent);\n font-weight: 600;\n}\n\n.sqc-confirm__btn:hover:not(:disabled) {\n border-color: var(--sqc-border-strong);\n background: var(--sqc-surface);\n}\n\n.sqc-confirm__btn--yes:hover:not(:disabled) {\n border-color: transparent;\n background: var(--sqc-accent-hover);\n}\n\n.sqc-confirm__btn:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n.sqc-confirm__btn:disabled {\n cursor: default;\n}\n\n/* Frozen: the answer given stays marked, the other fades out. */\n.sqc-confirm__btn:disabled[aria-pressed='false'] {\n opacity: 0.45;\n}\n\n.sqc-confirm__btn[aria-pressed='true'] {\n border-color: var(--sqc-border-strong);\n background: var(--sqc-selected);\n color: var(--sqc-text);\n font-weight: 600;\n}\n\n/* Options offered by the assistant (Markdown checkboxes).\n DS `.chip`: vertical list of clickable cards. */\n.sqc-choices {\n display: flex;\n flex-direction: column;\n gap: 7px;\n margin: 10px 0 2px;\n}\n\n.sqc-choice {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n padding: 8px 11px;\n font-family: var(--sqc-font-family);\n font-size: 12.5px;\n text-align: left;\n color: var(--sqc-text);\n background: var(--sqc-bg);\n border: 1px solid var(--sqc-border);\n border-radius: 12px;\n cursor: pointer;\n transition:\n border-color 0.12s ease,\n background 0.12s ease;\n}\n\n.sqc-choice:hover:not(:disabled) {\n border-color: var(--sqc-border-strong);\n background: var(--sqc-surface);\n}\n\n.sqc-choice:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n/* Frozen after answering: the picked option stays readable, the others fade. */\n.sqc-choice:disabled {\n cursor: default;\n}\n\n.sqc-choice:disabled[aria-pressed='false'] {\n opacity: 0.55;\n}\n\n.sqc-choice[aria-pressed='true'] {\n border-color: var(--sqc-border-strong);\n background: var(--sqc-selected);\n}\n\n.sqc-choice__box {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n width: 15px;\n height: 15px;\n border: 1.5px solid var(--sqc-border-strong);\n border-radius: 4px;\n}\n\n.sqc-choice__box--on {\n color: var(--sqc-on-accent);\n background: var(--sqc-accent-color);\n border-color: var(--sqc-accent-color);\n}\n\n.sqc-choice__box svg {\n width: 11px;\n height: 11px;\n}\n\n.sqc-choice__label {\n overflow-wrap: anywhere;\n}\n\n/* What tells an option apart from the others (its type, its owner, its\n reference): displayed under the label, typographically recessed — it is a\n marker, not what goes back to the agent. */\n.sqc-choice__detail {\n display: block;\n margin-top: 1px;\n font-size: 11.5px;\n color: var(--sqc-text-muted);\n}\n\n/* A choice the agent is waiting on: its questions, then the single validation\n answering them all (`Selection.tsx`). */\n.sqc-selection {\n display: flex;\n flex-direction: column;\n gap: 10px;\n margin: 2px 0;\n}\n\n.sqc-selection__question {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.sqc-selection__ask {\n margin: 0;\n font-family: var(--sqc-font-family);\n font-size: 13px;\n font-weight: 600;\n color: var(--sqc-text);\n}\n\n.sqc-selection__actions {\n display: flex;\n}\n\n.sqc-selection__validate {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 1 1 auto;\n height: 32px;\n padding: 0 12px;\n font-family: var(--sqc-font-family);\n font-size: 13px;\n font-weight: 600;\n color: var(--sqc-on-accent);\n background: var(--sqc-accent-color);\n border: 1px solid transparent;\n border-radius: 12px;\n cursor: pointer;\n transition:\n filter 0.12s ease,\n background 0.12s ease;\n}\n\n.sqc-selection__validate:hover:not(:disabled) {\n background: var(--sqc-accent-hover);\n}\n\n.sqc-selection__validate:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n/* Nothing ticked, or answer already sent: the DS's disabled action. */\n.sqc-selection__validate:disabled {\n cursor: not-allowed;\n color: #ffffff;\n background: var(--sqc-disabled);\n}\n\n.sqc-selection__hint {\n margin: 0;\n font-family: var(--sqc-font-family);\n font-size: 11.5px;\n color: var(--sqc-text-muted);\n}\n\n/* Record listings overflow the thread width: the table scrolls horizontally on\n its own, the message does not widen.\n DS: muted uppercase headers, slate-200 rules. */\n.sqc-table {\n margin: 0 0 8px;\n overflow-x: auto;\n scrollbar-width: thin;\n}\n\n.sqc-table table {\n min-width: 100%;\n border-collapse: collapse;\n font-family: var(--sqc-font-family);\n font-size: 12.5px;\n white-space: nowrap;\n}\n\n.sqc-table th,\n.sqc-table td {\n padding: 6px 10px 6px 0;\n text-align: left;\n vertical-align: top;\n border-bottom: 1px solid var(--sqc-border);\n}\n\n.sqc-table thead th {\n font-size: 10.5px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n color: var(--sqc-text-muted);\n}\n\n.sqc-table tbody th {\n font-weight: 500;\n}\n\n.sqc-msg--user .sqc-table th,\n.sqc-msg--user .sqc-table td {\n border-bottom-color: rgb(255 255 255 / 25%);\n}\n\n.sqc-msg--user .sqc-table thead th {\n color: rgb(255 255 255 / 80%);\n}\n\n.sqc-table tbody tr:last-child th,\n.sqc-table tbody tr:last-child td {\n border-bottom: 0;\n}\n\n.sqc-msg__time {\n display: block;\n margin-top: 3px;\n font-size: 10px;\n color: var(--sqc-text-muted);\n font-variant-numeric: tabular-nums;\n}\n\n.sqc-msg--user .sqc-msg__time {\n color: rgb(255 255 255 / 70%);\n text-align: right;\n}\n\n/* Curseur de frappe pendant le streaming. */\n.sqc-caret {\n display: inline-block;\n width: 2px;\n height: 1em;\n margin-left: 2px;\n vertical-align: text-bottom;\n background: currentColor;\n animation: sqc-blink 1s step-end infinite;\n}\n\n@keyframes sqc-blink {\n 0%,\n 100% {\n opacity: 1;\n }\n 50% {\n opacity: 0;\n }\n}\n\n/* Trois points avant le premier token — DS `.typing`. */\n.sqc-typing {\n display: inline-flex;\n gap: 3px;\n padding: 2px 0;\n}\n\n.sqc-typing i {\n width: 5px;\n height: 5px;\n border-radius: 50%;\n background: var(--sqc-neutral-400);\n animation: sqc-pulse 1.2s infinite;\n}\n\n.sqc-typing i:nth-child(2) {\n animation-delay: 0.2s;\n}\n\n.sqc-typing i:nth-child(3) {\n animation-delay: 0.4s;\n}\n\n@keyframes sqc-pulse {\n 0%,\n 60%,\n 100% {\n opacity: 0.25;\n }\n 30% {\n opacity: 1;\n }\n}\n\n/* ── Suggestions ──────────────────────────────────────────── */\n\n/* A full-width stack rather than floating pills: in a 392px panel every other\n pill used to be cut. */\n.sqc-suggestions {\n display: flex;\n flex-direction: column;\n gap: 7px;\n}\n\n.sqc-suggestion {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n padding: 8px 11px;\n border: 1px solid var(--sqc-border);\n border-radius: 12px;\n background: var(--sqc-bg);\n color: var(--sqc-text);\n font-family: var(--sqc-font-family);\n font-size: 12.5px;\n cursor: pointer;\n text-align: left;\n transition:\n background 0.15s ease,\n border-color 0.15s ease;\n}\n\n.sqc-suggestion::before {\n content: '';\n flex: 0 0 auto;\n width: 5px;\n height: 5px;\n border-radius: 50%;\n background: var(--sqc-accent-fg);\n}\n\n.sqc-suggestion:hover {\n background: var(--sqc-surface);\n border-color: var(--sqc-border-strong);\n}\n\n.sqc-suggestion:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n/* ── Zone de saisie ───────────────────────────────────────── */\n\n.sqc-composer {\n display: flex;\n align-items: flex-end;\n /* Wraps so the chips of attached files sit on a row of their own above the\n field, rather than squeezing it. */\n flex-wrap: wrap;\n gap: 8px;\n padding: 12px 14px;\n border-top: 1px solid var(--sqc-border);\n background: var(--sqc-bg);\n flex-shrink: 0;\n}\n\n/* A file being dragged over the composer, which is a drop target like the\n paperclip is a button. */\n.sqc-composer--dropping {\n outline: 2px dashed var(--sqc-accent-color);\n outline-offset: -4px;\n}\n\n/* The files a question is being written with, and the ones it was sent with:\n the same chips in the composer and under a bubble. */\n.sqc-attachments {\n flex-basis: 100%;\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n}\n\n.sqc-attachments--sent {\n margin-top: 8px;\n}\n\n.sqc-chip {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n max-width: 100%;\n padding: 3px 4px 3px 10px;\n border: 1px solid var(--sqc-border);\n border-radius: 999px;\n background: var(--sqc-selected);\n color: var(--sqc-text);\n font-size: 12px;\n}\n\n.sqc-chip--waiting {\n opacity: 0.6;\n padding-right: 10px;\n}\n\n.sqc-chip__name {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n max-width: 180px;\n}\n\n.sqc-chip__remove {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n padding: 0;\n border: 0;\n border-radius: 999px;\n background: transparent;\n color: var(--sqc-text-muted);\n font-size: 14px;\n line-height: 1;\n cursor: pointer;\n}\n\n.sqc-chip__remove:hover {\n background: var(--sqc-selected);\n color: var(--sqc-text);\n}\n\n.sqc-attachments__error {\n flex-basis: 100%;\n margin: 0;\n color: var(--sqc-error-600);\n font-size: 12px;\n}\n\n/* An attached picture, drawn under the message it was sent with. Bounded so a\n photograph does not push the conversation off the panel. */\n.sqc-attachment__image {\n display: block;\n max-width: 100%;\n max-height: 180px;\n border-radius: 12px;\n}\n\n/* The real input is never shown: the paperclip is the control. */\n.sqc-file-input {\n display: none;\n}\n\n.sqc-btn--attach {\n background: transparent;\n color: var(--sqc-text-muted);\n}\n\n.sqc-btn--attach:hover {\n background: var(--sqc-selected);\n color: var(--sqc-text);\n}\n\n.sqc-composer__field {\n position: relative;\n flex: 1;\n min-width: 0;\n}\n\n.sqc-composer__input {\n display: block;\n width: 100%;\n min-height: 38px;\n max-height: 132px;\n padding: 9px 12px;\n border: 1px solid var(--sqc-border-strong);\n border-radius: 12px;\n background: var(--sqc-bg);\n color: var(--sqc-text);\n font-family: var(--sqc-font-family);\n font-size: 13.5px;\n line-height: 1.4;\n resize: none;\n /* No scrollbar by default (a single line): `Composer.tsx` switches to `auto`\n once `scrollHeight` goes past `max-height`. */\n overflow-y: hidden;\n outline: none;\n transition:\n border-color 0.15s ease,\n box-shadow 0.15s ease;\n}\n\n.sqc-composer__input::placeholder {\n color: var(--sqc-neutral-400);\n}\n\n.sqc-composer__input:focus {\n border-color: var(--sqc-text);\n box-shadow: var(--sqc-focus-input);\n}\n\n/* The handle picker `@` opens over the field. Anchored to the field rather than\n the panel: it has to sit on top of the message list, and the composer is the\n only positioned ancestor that follows the textarea as it grows. */\n.sqc-mentions {\n position: absolute;\n left: 0;\n right: 0;\n bottom: calc(100% + 6px);\n z-index: 2;\n max-height: 184px;\n overflow-y: auto;\n margin: 0;\n padding: 4px;\n list-style: none;\n border: 1px solid var(--sqc-border);\n border-radius: 12px;\n background: var(--sqc-bg);\n box-shadow: var(--sqc-shadow);\n scrollbar-width: thin;\n}\n\n.sqc-mention {\n display: flex;\n align-items: baseline;\n gap: 6px;\n padding: 6px 8px;\n border-radius: 8px;\n cursor: pointer;\n font-size: 12.5px;\n color: var(--sqc-text);\n}\n\n.sqc-mention--active {\n background: var(--sqc-neutral-100);\n}\n\n.sqc-mention__icon {\n flex-shrink: 0;\n}\n\n.sqc-mention__handle {\n font-weight: 600;\n}\n\n.sqc-mention__name {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: var(--sqc-text-muted);\n}\n\n.sqc-composer__count {\n position: absolute;\n right: 8px;\n bottom: 4px;\n font-size: 10px;\n color: var(--sqc-text-muted);\n pointer-events: none;\n font-variant-numeric: tabular-nums;\n}\n\n.sqc-btn {\n width: 38px;\n height: 38px;\n border: none;\n border-radius: 12px;\n cursor: pointer;\n display: grid;\n place-items: center;\n flex-shrink: 0;\n transition:\n background 0.15s ease,\n opacity 0.15s ease;\n}\n\n.sqc-btn svg {\n width: 17px;\n height: 17px;\n}\n\n.sqc-btn--send {\n background: var(--sqc-accent-color);\n color: var(--sqc-on-accent);\n}\n\n.sqc-btn--send:hover:not(:disabled) {\n background: var(--sqc-accent-hover);\n}\n\n/* The DS's disabled action: slate-300, white glyph. */\n.sqc-btn--send:disabled {\n background: var(--sqc-disabled);\n color: #ffffff;\n cursor: not-allowed;\n}\n\n.sqc-btn--stop {\n background: var(--sqc-bg);\n color: var(--sqc-text);\n border: 1px solid var(--sqc-border);\n}\n\n.sqc-btn--stop:hover {\n border-color: var(--sqc-border-strong);\n background: var(--sqc-surface);\n}\n\n.sqc-btn:focus-visible {\n outline: none;\n box-shadow: var(--sqc-focus);\n}\n\n/* Permanent reminder that nothing is written without confirmation —\n which is exactly the agent contract (`pending_action`, then \"yes\"). */\n.sqc-hint {\n flex-shrink: 0;\n margin: 0;\n /* Safety margin for the iOS / Android home bar. */\n padding: 0 16px max(9px, env(safe-area-inset-bottom));\n font-size: 10.5px;\n line-height: 1.35;\n color: var(--sqc-text-muted);\n text-align: center;\n}\n\n/* Shown when the organization's plan carries our name. */\n.sqc-powered {\n flex-shrink: 0;\n margin: 0;\n padding: 0 16px max(9px, env(safe-area-inset-bottom));\n font-size: 10.5px;\n line-height: 1.35;\n text-align: center;\n}\n\n.sqc-powered a {\n color: var(--sqc-text-muted);\n text-decoration: none;\n}\n\n.sqc-powered a:hover {\n text-decoration: underline;\n}\n\n/* ── Adaptations ──────────────────────────────────────────── */\n\n@media (max-width: 520px) {\n .sqc {\n --sqc-width: 100vw;\n }\n\n .sqc-panel {\n border-left: none;\n }\n\n .sqc-launcher {\n bottom: 16px;\n right: 16px;\n }\n\n .sqc[data-position='bottom-left'] .sqc-launcher {\n left: 16px;\n }\n\n /* No room for a window on a phone: the floating panel fills the screen. */\n .sqc[data-layout='floating'] .sqc-panel,\n .sqc[data-layout='floating'][data-position='bottom-left'] .sqc-panel {\n inset: 0;\n max-width: none;\n height: auto;\n max-height: none;\n border: none;\n border-radius: 0;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .sqc-launcher,\n .sqc-panel,\n .sqc-btn,\n .sqc-suggestion,\n .sqc-choice,\n .sqc-confirm__btn,\n .sqc-icon-btn {\n transition: none;\n }\n\n .sqc-icon-btn[data-tip]::after {\n transition: none;\n }\n\n .sqc-typing i,\n .sqc-caret {\n animation: none;\n }\n}\n\n/* Once an agent handed the conversation to a human: nothing more is streamed,\n and this is what says a reply is still coming. */\n.sqc-with-human {\n margin: 8px 0 0;\n padding: 8px 12px;\n border: 1px solid var(--sqc-border);\n border-radius: 12px;\n background: var(--sqc-selected);\n color: var(--sqc-neutral-600);\n font-size: 13px;\n}\n","/**\n * Custom element wrapper: `<squadico-chatbot>`.\n *\n * The class is built **lazily** by `defineChatbot()` rather than at module\n * level: `class X extends HTMLElement` would throw a `ReferenceError` on a plain\n * server-side import (Next.js or Nuxt SSR, Node tests).\n */\nimport { render } from 'preact'\nimport { ChatbotWidget, type ChatbotControls } from './components/ChatbotWidget'\nimport styles from './styles.css?inline'\nimport type {\n ChatbotContext,\n ChatbotEvent,\n ChatbotOptions,\n HostUser,\n SubjectTokenSource,\n} from './types'\n\nexport const TAG_NAME = 'squadico-chatbot'\n\nconst ATTRIBUTES = [\n 'embed-key',\n 'context',\n 'user',\n 'agent',\n 'heading',\n 'subheading',\n 'assistant-name',\n 'placeholder',\n 'greeting',\n 'suggestions',\n 'width',\n 'accent',\n 'theme',\n 'position',\n 'layout',\n 'open',\n 'persist-open',\n 'locale',\n] as const\n\n/** A single `CSSStyleSheet` shared by every instance. */\nlet sheet: CSSStyleSheet | null | undefined\n\nfunction sharedSheet(): CSSStyleSheet | null {\n if (sheet !== undefined) return sheet\n try {\n const created = new CSSStyleSheet()\n created.replaceSync(styles)\n sheet = created\n } catch {\n // Safari < 16.4: no constructable stylesheets, fall back to <style>.\n sheet = null\n }\n return sheet\n}\n\nfunction warn(message: string, detail?: unknown): void {\n if (typeof console !== 'undefined') console.warn(`[${TAG_NAME}] ${message}`, detail ?? '')\n}\n\n/**\n * The host user, as an attribute.\n *\n * Accepts the JSON object a page can write in markup (`user='{\"id\":\"42\"}'`) and\n * refuses anything without an id: a claim with nothing to claim is not one, and\n * sending it would open an anonymous conversation while the page believed it had\n * named somebody.\n */\nfunction parseUser(raw: string | null): HostUser | undefined {\n if (!raw || !raw.trim()) return undefined\n try {\n const parsed: unknown = JSON.parse(raw)\n if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {\n const source = parsed as { id?: unknown; name?: unknown; digest?: unknown }\n if (typeof source.id === 'string' && source.id) {\n return {\n id: source.id,\n name: typeof source.name === 'string' && source.name ? source.name : undefined,\n // Carried through rather than validated: what a digest has to *be* is\n // the API's rule, and a page that mistyped one meets a refusal about\n // its claim instead of a console warning about its markup.\n digest:\n typeof source.digest === 'string' && source.digest ? source.digest : undefined,\n }\n }\n }\n warn('the \"user\" attribute needs an object with an id', raw)\n } catch (error) {\n warn('the \"user\" attribute is not valid JSON', error)\n }\n return undefined\n}\n\nfunction parseContext(raw: string | null): ChatbotContext | undefined {\n if (!raw || !raw.trim()) return undefined\n try {\n const parsed: unknown = JSON.parse(raw)\n if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {\n return parsed as ChatbotContext\n }\n warn('the `context` attribute must be a JSON object', raw)\n } catch (error) {\n warn('the `context` attribute is not valid JSON', error)\n }\n return undefined\n}\n\n/** Accepts `[\"a\",\"b\"]` or `a|b` — the second form avoids escaping quotes in a\n * Vue or Angular template. */\nfunction parseSuggestions(raw: string | null): string[] | undefined {\n if (!raw || !raw.trim()) return undefined\n if (raw.trim().startsWith('[')) {\n try {\n const parsed: unknown = JSON.parse(raw)\n if (Array.isArray(parsed)) return parsed.map(String)\n } catch (error) {\n warn('the `suggestions` attribute is not valid JSON', error)\n return undefined\n }\n }\n return raw\n .split('|')\n .map((item) => item.trim())\n .filter(Boolean)\n}\n\n/** A boolean attribute is true by mere presence; `=\"false\"` negates it. */\nfunction parseBool(raw: string | null): boolean | undefined {\n if (raw === null) return undefined\n return raw !== 'false' && raw !== '0'\n}\n\nfunction parseTheme(raw: string | null): ChatbotOptions['theme'] {\n return raw === 'dark' || raw === 'light' || raw === 'auto' ? raw : undefined\n}\n\nfunction parsePosition(raw: string | null): ChatbotOptions['position'] {\n return raw === 'bottom-left' || raw === 'bottom-right' ? raw : undefined\n}\n\nfunction parseLayout(raw: string | null): ChatbotOptions['layout'] {\n return raw === 'floating' || raw === 'sidebar' ? raw : undefined\n}\n\n/**\n * Properties a host may write before the element is defined. The script often\n * loads after the page has rendered, and a framework writing `chatbot.context`\n * through a ref on its first effect does so on a bare `HTMLElement`: the value\n * becomes a property of the instance, which would shadow the accessor once the\n * element is upgraded — the widget would keep that first value and never hear\n * about the next ones. `open` is not here: it is an order, not a setting, and\n * there is nothing to open before the widget has mounted.\n */\nconst UPGRADED_PROPERTIES = ['context', 'embedKey', 'user', 'getSubjectToken', 'agent'] as const\n\nfunction createElementClass(): CustomElementConstructor {\n return class SquadicoChatbot extends HTMLElement {\n static readonly observedAttributes = ATTRIBUTES\n\n #mount: HTMLDivElement\n #controls: ChatbotControls | null = null\n #scheduled = false\n #connected = false\n #sessionId = ''\n\n /* Values set as properties (objects/functions), which have no attribute\n equivalent. They take precedence over the attributes. */\n #context?: ChatbotContext\n #user?: HostUser\n #getSubjectToken?: SubjectTokenSource\n #agent?: string\n #embedKey?: string\n\n constructor() {\n super()\n const shadow = this.attachShadow({ mode: 'open' })\n const adoptable = sharedSheet()\n if (adoptable) {\n shadow.adoptedStyleSheets = [adoptable]\n } else {\n const style = document.createElement('style')\n style.textContent = styles\n shadow.append(style)\n }\n this.#mount = document.createElement('div')\n shadow.append(this.#mount)\n\n // Hands every value written before the upgrade to its setter, so the\n // accessor is the one answering from now on.\n for (const name of UPGRADED_PROPERTIES) {\n if (!Object.hasOwn(this, name)) continue\n const value = (this as Record<string, unknown>)[name]\n delete (this as Record<string, unknown>)[name]\n ;(this as Record<string, unknown>)[name] = value\n }\n }\n\n connectedCallback(): void {\n this.#connected = true\n this.#render()\n }\n\n disconnectedCallback(): void {\n this.#connected = false\n render(null, this.#mount)\n this.#controls = null\n }\n\n attributeChangedCallback(name: string, previous: string | null, next: string | null): void {\n if (previous === next) return\n\n // `open` is imperative, not declarative: the render does not read the\n // attribute back, the controls carry the state once the widget is mounted.\n if (name === 'open' && this.#controls) {\n if (parseBool(next)) this.#controls.open()\n else this.#controls.close()\n return\n }\n this.#schedule()\n }\n\n /* ── Properties ────────────────────────────────────────── */\n\n get context(): ChatbotContext | undefined {\n return this.#context ?? parseContext(this.getAttribute('context'))\n }\n\n set context(value: ChatbotContext | undefined) {\n this.#context = value\n this.#schedule()\n }\n\n get embedKey(): string | undefined {\n return this.#embedKey ?? this.getAttribute('embed-key') ?? undefined\n }\n\n set embedKey(value: string | undefined) {\n this.#embedKey = value\n this.#schedule()\n }\n\n /** Who the host application has signed in. Settable as a property, and as a\n * ``user`` attribute holding JSON for a page that only writes markup. */\n get user(): HostUser | undefined {\n return this.#user ?? parseUser(this.getAttribute('user'))\n }\n\n set user(value: HostUser | undefined) {\n this.#user = value\n this.#schedule()\n }\n\n /** Hands over the token the site holds for its signed-in user, before each\n * message. A property only: a function has no attribute form. */\n get getSubjectToken(): SubjectTokenSource | undefined {\n return this.#getSubjectToken\n }\n\n set getSubjectToken(value: SubjectTokenSource | undefined) {\n this.#getSubjectToken = value\n this.#schedule()\n }\n\n /** The handle this page opens on — `agent=\"sales\"` on a pricing page. A name\n * nobody answers to opens on the default agent rather than refusing. */\n get agent(): string | undefined {\n return this.#agent ?? this.getAttribute('agent') ?? undefined\n }\n\n set agent(value: string | undefined) {\n this.#agent = value\n this.#schedule()\n }\n\n get open(): boolean {\n return this.#controls?.isOpen() ?? (parseBool(this.getAttribute('open')) ?? false)\n }\n\n set open(value: boolean) {\n if (value) this.openChat()\n else this.closeChat()\n }\n\n get sessionId(): string {\n return this.#controls?.sessionId() ?? this.#sessionId\n }\n\n /* ── Imperative API ───────────────────────────────────── */\n\n openChat(): void {\n this.#controls?.open()\n }\n\n closeChat(): void {\n this.#controls?.close()\n }\n\n toggleChat(): void {\n this.#controls?.toggle()\n }\n\n reset(): void {\n this.#controls?.reset()\n }\n\n sendMessage(text: string): void {\n if (!this.#controls) {\n warn('sendMessage() called before the component was mounted — ignored')\n return\n }\n this.#controls.send(text)\n }\n\n /* ── Rendering ────────────────────────────────────────── */\n\n /** Batches several mutations in a row (a framework setting five attributes)\n * into a single render. */\n #schedule(): void {\n if (this.#scheduled || !this.#connected) return\n this.#scheduled = true\n queueMicrotask(() => {\n this.#scheduled = false\n if (this.#connected) this.#render()\n })\n }\n\n #emit = (event: ChatbotEvent): void => {\n const { type, ...detail } = event\n this.#sessionId = detail.sessionId\n this.dispatchEvent(\n new CustomEvent(type, {\n detail,\n // Crosses the shadow root to reach the host page's listeners.\n bubbles: true,\n composed: true,\n }),\n )\n }\n\n #bind = (controls: ChatbotControls | null): void => {\n this.#controls = controls\n // The `open` attribute present at mount has already been arbitrated\n // against the remembered panel state (`lib/openState`); this only\n // publishes the initial session.\n if (controls) this.#sessionId = controls.sessionId()\n }\n\n #render(): void {\n const attr = (name: string): string | undefined => this.getAttribute(name) ?? undefined\n\n render(\n <ChatbotWidget\n embedKey={this.embedKey}\n context={this.context}\n user={this.user}\n getSubjectToken={this.getSubjectToken}\n agent={this.agent}\n heading={attr('heading')}\n subheading={attr('subheading')}\n assistantName={attr('assistant-name')}\n placeholder={attr('placeholder')}\n greeting={attr('greeting')}\n suggestions={parseSuggestions(this.getAttribute('suggestions'))}\n width={attr('width')}\n accent={attr('accent')}\n theme={parseTheme(this.getAttribute('theme'))}\n position={parsePosition(this.getAttribute('position'))}\n layout={parseLayout(this.getAttribute('layout'))}\n defaultOpen={parseBool(this.getAttribute('open')) ?? false}\n persistOpen={parseBool(this.getAttribute('persist-open')) ?? true}\n locale={attr('locale')}\n onEvent={this.#emit}\n bind={this.#bind}\n />,\n this.#mount,\n )\n }\n }\n}\n\nlet Constructor: CustomElementConstructor | undefined\n\n/**\n * Registers `<squadico-chatbot>`. Idempotent, and a no-op server-side.\n *\n * @param tag alternative tag name, when `squadico-chatbot` is already taken by\n * another version of the widget on the page.\n */\nexport function defineChatbot(tag: string = TAG_NAME): void {\n if (typeof window === 'undefined' || typeof HTMLElement === 'undefined') return\n Constructor ??= createElementClass()\n if (!window.customElements.get(tag)) {\n window.customElements.define(tag, Constructor)\n }\n}\n","/**\n * Default entry point of `@squadico/chatbot`.\n *\n * Importing it registers `<squadico-chatbot>` in the browser (a deliberate side\n * effect, declared through `sideEffects` in `package.json`) and does nothing\n * server-side, which makes it safe to import from a Next.js or Nuxt component.\n *\n * import '@squadico/chatbot'\n * <squadico-chatbot embed-key=\"sq_pub_…\" />\n */\nexport { defineChatbot, TAG_NAME } from './element'\nexport { DEFAULT_LANGUAGE, SUPPORTED_LANGUAGES, type LanguageCode } from './lib/i18n'\nexport { API_URL, ChatHttpError, MAX_MESSAGE_LENGTH } from './lib/client'\nexport type {\n AgentHandle,\n ApprovalDecision,\n ChatbotContext,\n ChatbotEvent,\n ChatbotEventMap,\n ChatbotEventName,\n ChatbotLayout,\n ChatbotOptions,\n ChatbotTheme,\n ChatMessage,\n ChatRole,\n ContextObject,\n ContextValue,\n HostUser,\n LauncherPosition,\n PendingApproval,\n SquadicoChatbotElement,\n SubjectTokenSource,\n} from './types'\n\nimport { defineChatbot } from './element'\n\ndefineChatbot()\n"],"x_google_ignoreList":[0,1,9],"mappings":";AAAA,IAAI,GAAEA,GAAEC,GAAIE,GAAEC,GAAEC,GAAEC,GAAEC,GAAEC,GAAEC,GAAEC,GAAEC,GAAEC,GAAEC,GAAIE,IAAE,CAAC,GAAEC,IAAE,CAAC,GAAEC,IAAE,qEAAoE,IAAE,MAAM;AAAQ,SAASC,EAAE,GAAE,GAAE;CAAC,KAAI,IAAI,KAAK,GAAE,EAAE,KAAG,EAAE;CAAG,OAAO;AAAC;AAAC,SAAS,EAAE,GAAE;CAAC,KAAG,EAAE,cAAY,EAAE,WAAW,YAAY,CAAC;AAAC;AAAC,SAASC,EAAE,GAAE,GAAE,GAAE;CAAC,IAAI,GAAE,GAAE,GAAE,IAAE,CAAC;CAAE,KAAI,KAAK,GAAE,AAAO,KAAP,QAAS,IAAE,EAAE,KAAU,KAAP,QAAS,IAAE,EAAE,KAAG,EAAE,KAAG,EAAE;CAAG,IAAG,UAAU,SAAO,MAAI,EAAE,WAAS,UAAU,SAAO,IAAE,EAAE,KAAK,WAAU,CAAC,IAAE,IAA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