@aiden-voice/widget 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const WIDGET_VERSION = "0.3.0";
1
+ export declare const WIDGET_VERSION = "0.3.1";
@@ -1,6 +1,7 @@
1
- var whooAidenWidget=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){if((typeof e.publishableKey==`string`&&e.publishableKey.length>0)==(typeof e.sessionToken==`string`&&e.sessionToken.length>0))throw Error("whoo-aiden-widget: init() requires exactly one of `publishableKey` or `sessionToken`, not both or neither.")}var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g={},_=[],v=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,y=Array.isArray;function b(e,t){for(var n in t)e[n]=t[n];return e}function ee(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function x(e,t,r){var i,a,o,s={};for(o in t)o==`key`?i=t[o]:o==`ref`?a=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?n.call(arguments,2):r),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return S(e,s,i,a,null)}function S(e,t,n,a,o){var s={type:e,props:t,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++i,__i:-1,__u:0};return o==null&&r.vnode!=null&&r.vnode(s),s}function C(e){return e.children}function w(e,t){this.props=e,this.context=t}function T(e,t){if(t==null)return e.__?T(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?T(e):null}function E(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,i=[],a=[],o=b({},t);o.__v=t.__v+1,r.vnode&&r.vnode(o),P(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,i,n??T(t),!!(32&t.__u),a),o.__v=t.__v,o.__.__k[o.__i]=o,ae(i,o,a),t.__e=t.__=null,o.__e!=n&&D(o)}}function D(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),D(e)}function O(e){(!e.__d&&(e.__d=!0)&&a.push(e)&&!k.__r++||o!=r.debounceRendering)&&((o=r.debounceRendering)||s)(k)}function k(){try{for(var e,t=1;a.length;)a.length>t&&a.sort(c),e=a.shift(),t=a.length,E(e)}finally{a.length=k.__r=0}}function te(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,v,y=r&&r.__k||_,b=t.length;for(c=ne(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||g,p.__i=d,v=P(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&ce(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),4&p.__u?(c=A(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function ne(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=S(null,o,null,null,null):y(o)?o=e.__k[a]=S(C,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=S(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=j(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=T(s)),le(s,s));return r}function A(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=A(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=T(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function j(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function M(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||v.test(t)?n:n+`px`}function N(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||M(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||M(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(f,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[d]=r[d]:(n[d]=p,e.addEventListener(t,a?h:m,a)):e.removeEventListener(t,a?h:m,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function re(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[u]==null)t[u]=p++;else if(t[u]<n[d])return;return n(r.event?r.event(t):t)}}}function P(e,t,n,i,a,o,s,c,l,u){var d,f,p,m,h,g,v,x,S,E,D,O,k,ne,A,j,M=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[c=t.__e=n.__e]),(d=r.__b)&&d(t);n:if(typeof M==`function`){f=s.length;try{if(S=t.props,E=M.prototype&&M.prototype.render,D=(d=M.contextType)&&i[d.__c],O=d?D?D.props.value:d.__:i,n.__c?x=(p=t.__c=n.__c).__=p.__E:(E?t.__c=p=new M(S,O):(t.__c=p=new w(S,O),p.constructor=M,p.render=ue),D&&D.sub(p),p.state||(p.state={}),p.__n=i,m=p.__d=!0,p.__h=[],p._sb=[]),E&&p.__s==null&&(p.__s=p.state),E&&M.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=b({},p.__s)),b(p.__s,M.getDerivedStateFromProps(S,p.__s))),h=p.props,g=p.state,p.__v=t,m)E&&M.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),E&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(E&&M.getDerivedStateFromProps==null&&S!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(S,O),t.__v==n.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(S,p.__s,O)){t.__v!=n.__v&&(p.props=S,p.state=p.__s,p.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),_.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&s.push(p),c=T(n);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(S,p.__s,O),E&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,g,v)})}if(p.context=O,p.props=S,p.__P=e,p.__e=!1,k=r.__r,ne=0,E)p.state=p.__s,p.__d=!1,k&&k(t),d=p.render(p.props,p.state,p.context),_.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,k&&k(t),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++ne<25);p.state=p.__s,p.getChildContext!=null&&(i=b(b({},i),p.getChildContext())),E&&!m&&p.getSnapshotBeforeUpdate!=null&&(v=p.getSnapshotBeforeUpdate(h,g)),A=d!=null&&d.type===C&&d.key==null?oe(d.props.children):d,c=te(e,y(A)?A:[A],t,n,i,a,o,s,c,l,u),p.base=t.__e,t.__u&=-161,p.__h.length&&s.push(p),x&&(p.__E=p.__=null)}catch(e){if(s.length=f,t.__v=null,l||o!=null){if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o!=null&&(o[o.indexOf(c)]=null),t.__e=c}else if(o!=null)for(j=o.length;j--;)ee(o[j])}else t.__e=n.__e;t.__k??=n.__k||[],e.then||ie(t),r.__e(e,t,n)}}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=se(n.__e,t,n,i,a,o,s,l,u);return(d=r.diffed)&&d(t),128&t.__u?void 0:c}function ie(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ie))}function ae(e,t,n){for(var i=0;i<n.length;i++)ce(n[i],n[++i],n[++i]);r.__c&&r.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){r.__e(e,t.__v)}})}function oe(e){return typeof e!=`object`||!e||e.__b>0?e:y(e)?e.map(oe):e.constructor===void 0?b({},e):null}function se(e,t,i,a,o,s,c,l,u){var d,f,p,m,h,_,v,b=i.props||g,x=t.props,S=t.type;if(S==`svg`?o=`http://www.w3.org/2000/svg`:S==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d<s.length;d++)if((h=s[d])&&`setAttribute`in h==!!S&&(S?h.localName==S:h.nodeType==3)){e=h,s[d]=null;break}}if(e==null){if(S==null)return document.createTextNode(x);e=document.createElementNS(o,S,x.is&&x),l&&=(r.__m&&r.__m(t,s),!1),s=null}if(S==null)b===x||l&&e.data==x||(e.data=x);else{if(s=S==`textarea`&&x.defaultValue!=null?null:s&&n.call(e.childNodes),!l&&s!=null)for(b={},d=0;d<e.attributes.length;d++)b[(h=e.attributes[d]).name]=h.value;for(d in b)h=b[d],d==`dangerouslySetInnerHTML`?p=h:d==`children`||d in x||d==`value`&&`defaultValue`in x||d==`checked`&&`defaultChecked`in x||N(e,d,null,h,o);for(d in x)h=x[d],d==`children`?m=h:d==`dangerouslySetInnerHTML`?f=h:d==`value`?_=h:d==`checked`?v=h:l&&typeof h!=`function`||b[d]===h||N(e,d,h,b[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(p&&(e.innerHTML=``),te(t.type==`template`?e.content:e,y(m)?m:[m],t,i,a,S==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&T(i,0),l,u),s!=null)for(d=s.length;d--;)ee(s[d]);l&&S!=`textarea`||(d=`value`,S==`progress`&&_==null?e.removeAttribute(`value`):_!=null&&(_!==e[d]||S==`progress`&&!_||S==`option`&&_!=b[d])&&N(e,d,_,b[d],o),d=`checked`,v!=null&&v!=e[d]&&N(e,d,v,b[d],o))}return e}function ce(e,t,n){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(e){r.__e(e,n)}}function le(e,t,n){var i,a;if(r.unmount&&r.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||ce(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){r.__e(e,t)}i.base=i.__P=i.__n=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&le(i[a],t,n||typeof e.type!=`function`);n||ee(e.__e),e.__c=e.__=e.__e=void 0}function ue(e,t,n){return this.constructor(e,n)}function de(e,t,i){var a,o,s,c;t==document&&(t=document.documentElement),r.__&&r.__(e,t),o=(a=typeof i==`function`)?null:i&&i.__k||t.__k,s=[],c=[],P(t,e=(!a&&i||t).__k=x(C,null,[e]),o||g,g,t.namespaceURI,!a&&i?[i]:o?null:t.firstChild?n.call(t.childNodes):null,s,!a&&i?i:o?o.__e:t.firstChild,a,c),ae(s,e,c),e.props.children=null}n=_.slice,r={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},i=0,w.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=b({},this.state);typeof e==`function`&&(e=e(b({},n),this.props)),e&&b(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),O(this))},w.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),O(this))},w.prototype.render=C,a=[],s=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,c=function(e,t){return e.__v.__b-t.__v.__b},k.__r=0,l=Math.random().toString(8),u=`__d`+l,d=`__a`+l,f=/(PointerCapture)$|Capture$/i,p=0,m=re(!1),h=re(!0);var F,I,L,fe,R=0,pe=[],z=r,me=z.__b,he=z.__r,ge=z.diffed,_e=z.__c,ve=z.unmount,ye=z.__;function be(e,t){z.__h&&z.__h(I,e,R||t),R=0;var n=I.__H||(I.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function B(e){return R=1,xe(Oe,e)}function xe(e,t,n){var r=be(F++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Oe(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=I,!I.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};I.__f=!0;var a=I.shouldComponentUpdate,o=I.componentWillUpdate;I.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},I.shouldComponentUpdate=i}return r.__N||r.__}function V(e,t){var n=be(F++,3);!z.__s&&De(n.__H,t)&&(n.__=e,n.u=t,I.__H.__h.push(n))}function H(e){return R=5,Se(function(){return{current:e}},[])}function Se(e,t){var n=be(F++,7);return De(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ce(){for(var e;e=pe.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(U),t.__h.some(Ee),t.__h=[]}catch(n){t.__h=[],z.__e(n,e.__v)}}}z.__b=function(e){I=null,me&&me(e)},z.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ye&&ye(e,t)},z.__r=function(e){he&&he(e),F=0;var t=(I=e.__c).__H;t&&(L===I?(t.__h=[],I.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(U),t.__h.some(Ee),t.__h=[],F=0)),L=I},z.diffed=function(e){ge&&ge(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(pe.push(t)!==1&&fe===z.requestAnimationFrame||((fe=z.requestAnimationFrame)||Te)(Ce)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),L=I=null},z.__c=function(e,t){t.some(function(e){try{e.__h.some(U),e.__h=e.__h.filter(function(e){return!e.__||Ee(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],z.__e(n,e.__v)}}),_e&&_e(e,t)},z.unmount=function(e){ve&&ve(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{U(e)}catch(e){t=e}}),n.__H=void 0,t&&z.__e(t,n.__v))};var we=typeof requestAnimationFrame==`function`;function Te(e){var t,n=function(){clearTimeout(r),we&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);we&&(t=requestAnimationFrame(n))}function U(e){var t=I,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),I=t}function Ee(e){var t=I;e.__c=e.__(),I=t}function De(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Oe(e,t){return typeof t==`function`?t(e):t}var ke=0;Array.isArray;function W(e,t,n,i,a,o){t||={};var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ke,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return r.vnode&&r.vnode(u),u}function G({name:e,size:t,children:n}){return W(`svg`,{"data-icon":e,"aria-hidden":`true`,focusable:`false`,width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,children:n})}function Ae({size:e=26}){return W(G,{name:`chat`,size:e,children:[W(`path`,{d:`M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 4v-4h0A1.5 1.5 0 0 1 4 14.5z`}),W(`path`,{d:`M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01`,"stroke-width":`2.5`})]})}function je({size:e=26}){return W(G,{name:`chevron-down`,size:e,children:W(`path`,{d:`M6 9l6 6 6-6`})})}function Me({size:e=18}){return W(G,{name:`close`,size:e,children:W(`path`,{d:`M6 6l12 12M18 6L6 18`})})}var Ne=`M7 11v9M7 11l3.5-7.2A1.8 1.8 0 0 1 14 4.6V9h4.6a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 17.4 20H7M7 11H4.5A1.5 1.5 0 0 0 3 12.5v6A1.5 1.5 0 0 0 4.5 20H7`;function Pe({size:e=16}){return W(G,{name:`thumb-up`,size:e,children:W(`path`,{d:Ne})})}function Fe({size:e=16}){return W(G,{name:`thumb-down`,size:e,children:W(`path`,{d:Ne,transform:`matrix(1 0 0 -1 0 24)`})})}function Ie({isOpen:e,onClick:t,iconUrl:n,buttonRef:r}){let[i,a]=B(`loading`),o=n!==void 0&&i!==`failed`,s=o&&!e&&i===`loaded`;return W(`button`,{type:`button`,class:`whoo-widget-launcher`,onClick:t,"aria-label":e?`Close chat`:`Open chat`,ref:r,children:[e?W(je,{}):s?null:W(Ae,{}),o?W(`img`,{class:`whoo-widget-launcher-icon-image`,src:n,alt:``,referrerpolicy:`no-referrer`,hidden:!s,onLoad:()=>a(`loaded`),onError:()=>a(`failed`)}):null]})}function Le({value:e,onChange:t,onSend:n,disabled:r,inputRef:i}){return W(`div`,{class:`whoo-widget-composer`,children:[W(`label`,{class:`whoo-widget-sr-only`,for:`whoo-widget-composer-input`,children:`Message`}),W(`input`,{id:`whoo-widget-composer-input`,class:`whoo-widget-composer-input`,value:e,readOnly:r,"aria-disabled":r,ref:i,onInput:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&n()}}),W(`button`,{type:`button`,class:`whoo-widget-composer-send`,onClick:n,disabled:r,children:`Send`})]})}function Re({message:e}){return W(`div`,{class:`whoo-widget-error-banner`,role:`alert`,children:e})}var K=/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y,q=/\*\*([^*]+)\*\*/y,J=/(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y,Y=/\*([^*]+)\*/y,ze=/https?:\/\/\S+/y,Be=/[.,;:!?)\]}>]+$/;function Ve(e){let t=[],n=0,r=0,i=n=>{n>r&&t.push({type:`text`,value:e.slice(r,n),start:r,end:n})};for(;n<e.length;){if(e[n]===`!`&&n+1<e.length&&e[n+1]===`[`){let t=/!\[([^\]]*)\]\(([^)]*)\)/y;t.lastIndex=n;let r=t.exec(e);if(r){n+=r[0].length;continue}}if(e[n-1]!==`!`){K.lastIndex=n;let a=K.exec(e);if(a){i(n),t.push({type:`link`,text:a[1],url:a[2],start:n,end:K.lastIndex}),n=K.lastIndex,r=n;continue}}q.lastIndex=n;let a=q.exec(e);if(a){i(n),t.push({type:`bold`,value:a[1],start:n,end:q.lastIndex}),n=q.lastIndex,r=n;continue}J.lastIndex=n;let o=J.exec(e);if(o){i(n),t.push({type:`italic`,value:o[1],start:n,end:J.lastIndex}),n=J.lastIndex,r=n;continue}Y.lastIndex=n;let s=Y.exec(e);if(s){i(n),t.push({type:`italic`,value:s[1],start:n,end:Y.lastIndex}),n=Y.lastIndex,r=n;continue}ze.lastIndex=n;let c=ze.exec(e);if(c){let e=c[0].match(Be),a=e?c[0].slice(0,c[0].length-e[0].length):c[0];if(a.length>0){i(n),t.push({type:`link`,text:a,url:a,start:n,end:n+a.length}),n+=a.length,r=n;continue}}n+=1}return i(e.length),t}function He(e){return Ve(e).map((e,t)=>{switch(e.type){case`bold`:return W(`strong`,{children:e.value},t);case`italic`:return W(`em`,{children:e.value},t);case`link`:return W(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:[e.text,W(`span`,{class:`whoo-widget-sr-only`,children:` (opens in new tab)`})]},t);default:return e.value}})}var Ue=[{value:``,label:`Select a reason (optional)`},{value:`factual`,label:`Factual error`},{value:`incomplete`,label:`Incomplete`},{value:`tone`,label:`Off tone`},{value:`other`,label:`Other`}];function We({state:e,containerRef:t,onThumbsUp:n,onThumbsDown:r,onSubmitDetailed:i,onCancel:a}){let[o,s]=B(``),[c,l]=B(``),u=H(e.status);if(V(()=>{let n=u.current;if(u.current=e.status,n===e.status)return;let r=t?.current;if(!r)return;let i=r.getRootNode();r.contains(i.activeElement)||r.focus()},[e.status,t]),e.status===`submitted`)return W(`div`,{class:`whoo-widget-feedback-submitted`,role:`status`,children:`Thanks for the feedback`});if(e.status===`expanded`)return W(`div`,{class:`whoo-widget-feedback-form`,children:[W(`label`,{children:[W(`span`,{class:`whoo-widget-sr-only`,children:`Additional feedback`}),W(`textarea`,{class:`whoo-widget-feedback-textarea`,value:o,onInput:e=>s(e.target.value),placeholder:`What was wrong? (optional)`})]}),W(`select`,{class:`whoo-widget-feedback-select`,"aria-label":`Feedback category`,value:c,onChange:e=>l(e.target.value),children:Ue.map(e=>W(`option`,{value:e.value,children:e.label},e.value))}),W(`div`,{class:`whoo-widget-feedback-form-buttons`,children:[W(`button`,{type:`button`,class:`whoo-widget-feedback-submit`,onClick:()=>i(o,c),children:`Submit`}),W(`button`,{type:`button`,class:`whoo-widget-feedback-cancel`,onClick:a,children:`Cancel`})]})]});let d=e.status===`submitting`;return W(`div`,{class:`whoo-widget-feedback`,children:[W(`div`,{class:`whoo-widget-feedback-buttons`,children:[W(`button`,{type:`button`,"aria-label":`Good response`,disabled:d,onClick:n,children:W(Pe,{})}),W(`button`,{type:`button`,"aria-label":`Bad response`,disabled:d,onClick:r,children:W(Fe,{})})]}),e.status===`error`?W(`div`,{class:`whoo-widget-feedback-error`,role:`status`,children:`Couldn't send feedback`}):null]})}function Ge({isSlowResponse:e}){return W(`div`,{class:`whoo-widget-pending`,role:`status`,children:[W(`span`,{class:`whoo-widget-typing`,"aria-hidden":`true`,children:[W(`span`,{}),W(`span`,{}),W(`span`,{})]}),e?W(`span`,{class:`whoo-widget-pending-text`,children:`Looking that up for you…`}):null]})}function Ke({url:e,alt:t}){let[n,r]=B(!1);return n?null:W(`img`,{class:`whoo-widget-empty-state-image`,src:e,alt:t,referrerpolicy:`no-referrer`,onError:()=>r(!0)})}function qe({message:e,feedbackState:t,pending:n,isSlowResponse:r,onThumbsUp:i,onThumbsDown:a,onSubmitDetailed:o,onCancelFeedback:s}){let c=H(null),l=e.id;return W(`div`,{ref:c,tabIndex:-1,class:`whoo-widget-message whoo-widget-message--${e.role}`,children:[n?W(Ge,{isSlowResponse:r}):He(e.content),e.role===`assistant`&&l?W(We,{state:t,containerRef:c,onThumbsUp:()=>i(l),onThumbsDown:()=>a(l),onSubmitDetailed:(e,t)=>o(l,e,t),onCancel:()=>s(l)}):null]})}function Je({messages:e,messageFeedback:t,lastCompletedMessageText:n,emptyStateImage:r,isStreaming:i=!1,isSlowResponse:a=!1,onThumbsUp:o,onThumbsDown:s,onSubmitDetailed:c,onCancelFeedback:l}){let u=H(null);return V(()=>{let e=u.current;e&&(e.scrollTop=e.scrollHeight)},[e,a]),W(C,{children:[W(`div`,{class:`whoo-widget-message-list`,ref:u,children:[r?W(Ke,{...r}):null,e.map((n,r)=>W(qe,{message:n,feedbackState:n.id?t[n.id]??{status:`idle`}:{status:`idle`},pending:i&&r===e.length-1&&n.role===`assistant`&&n.content===``,isSlowResponse:a,onThumbsUp:o,onThumbsDown:s,onSubmitDetailed:c,onCancelFeedback:l},n.id??r))]}),W(`div`,{class:`whoo-widget-sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:n??``})]})}var Ye=`button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`;function Xe(e){return Array.from(e.querySelectorAll(Ye)).filter(e=>{let t=getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`})}function Ze({state:e,controller:t,greeting:n}){let r=H(null),i=H(null);V(()=>{i.current?.focus()},[]);let a=e=>{if(e.key===`Escape`){t.close();return}if(e.key!==`Tab`)return;let n=r.current;if(!n)return;let i=Xe(n);if(i.length===0)return;let a=i[0],o=i[i.length-1],s=n.getRootNode().activeElement;if(!n.contains(s)){e.preventDefault(),a.focus();return}e.shiftKey&&s===a?(e.preventDefault(),o.focus()):!e.shiftKey&&s===o&&(e.preventDefault(),a.focus())},o=()=>{let n=e.draft.trim();n&&!e.isStreaming&&(t.setDraft(``),t.sendMessage(n))},s=`Chat with ${e.agentName??(t.config.name?.trim()||`Aiden`)}`,c=e.messages.length===0&&n?[{role:`assistant`,content:n,id:null}]:e.messages,l=t.emptyStateImageUrl,u=e.messages.length===0&&l?{url:l,alt:t.emptyStateImageAlt}:void 0;return W(`div`,{class:`whoo-widget-panel`,role:`dialog`,"aria-modal":`true`,"aria-label":s,ref:r,onKeyDown:a,children:[W(`div`,{class:`whoo-widget-header`,children:[W(`h2`,{class:`whoo-widget-header-title`,children:s}),W(`div`,{class:`whoo-widget-header-actions`,children:[e.messages.length>0&&W(`button`,{type:`button`,class:`whoo-widget-header-reset`,onClick:()=>t.resetConversation(),children:`New conversation`}),W(`button`,{type:`button`,class:`whoo-widget-header-close`,"aria-label":`Close chat`,onClick:()=>t.close(),children:W(Me,{})})]})]}),W(Je,{messages:c,messageFeedback:e.messageFeedback,lastCompletedMessageText:e.lastCompletedMessageText,emptyStateImage:u,isStreaming:e.isStreaming,isSlowResponse:e.isSlowResponse,onThumbsUp:e=>t.submitFeedback(e,`up`),onThumbsDown:e=>t.expandFeedback(e),onSubmitDetailed:(e,n,r)=>t.submitFeedback(e,`down`,n||void 0,r||void 0),onCancelFeedback:e=>t.cancelFeedback(e)}),e.runtimeError&&W(Re,{message:e.runtimeError}),W(Le,{value:e.draft,onChange:e=>t.setDraft(e),onSend:o,disabled:e.isStreaming,inputRef:i})]})}function Qe({controller:e}){let[t,n]=B(e.getState()),r=H(null),i=H(t.isOpen);return V(()=>(n(e.getState()),e.subscribe(n)),[e]),V(()=>{i.current&&!t.isOpen&&r.current?.focus(),i.current=t.isOpen},[t.isOpen]),t.initError?null:W(C,{children:[W(Ie,{isOpen:t.isOpen,onClick:()=>t.isOpen?e.close():e.open(),iconUrl:e.launcherIconUrl,buttonRef:r}),t.isOpen&&W(Ze,{state:t,controller:e,greeting:e.config.greeting})]})}var $e=class extends Error{status;constructor(e,t){super(e),this.name=`WidgetApiError`,this.status=t}};function et(e){if(typeof e!=`string`)return null;let t=e.trim();return t===``?null:t}async function tt(e,t){let n=await fetch(`${e}/api/v1/widget/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({publishable_key:t})});if(!n.ok)throw new $e(`Failed to create widget session (${n.status})`,n.status);let r=await n.json();return{token:r.token,primaryColor:r.primary_color??null,name:et(r.name),accentColor:et(r.accent_color),inkColor:et(r.ink_color)}}async function nt(e,t,n){let r=await fetch(`${e}/api/v1/widget/feedback`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t}`},body:JSON.stringify({message_id:n.messageId,rating:n.rating,correction:n.correction??null,category:n.category??null})});if(!r.ok)throw new $e(`Feedback submission failed (${r.status})`,r.status)}async function*rt(e,t,n,r,i){let a=await fetch(`${e}/api/v1/widget/chat`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t}`},body:JSON.stringify({conversation_id:n,message:r}),signal:i});if(!a.ok||!a.body)throw new $e(`Chat request failed (${a.status})`,a.status);let o=a.body.getReader(),s=new TextDecoder,c=``;for(;;){let{done:e,value:t}=await o.read();if(e)break;c+=s.decode(t,{stream:!0});let n=c.indexOf(`
1
+ var whooAidenWidget=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){if((typeof e.publishableKey==`string`&&e.publishableKey.length>0)==(typeof e.sessionToken==`string`&&e.sessionToken.length>0))throw Error("whoo-aiden-widget: init() requires exactly one of `publishableKey` or `sessionToken`, not both or neither.")}var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g={},_=[],v=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,y=Array.isArray;function b(e,t){for(var n in t)e[n]=t[n];return e}function x(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function S(e,t,r){var i,a,o,s={};for(o in t)o==`key`?i=t[o]:o==`ref`?a=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?n.call(arguments,2):r),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return C(e,s,i,a,null)}function C(e,t,n,a,o){var s={type:e,props:t,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++i,__i:-1,__u:0};return o==null&&r.vnode!=null&&r.vnode(s),s}function w(e){return e.children}function T(e,t){this.props=e,this.context=t}function E(e,t){if(t==null)return e.__?E(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?E(e):null}function D(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,i=[],a=[],o=b({},t);o.__v=t.__v+1,r.vnode&&r.vnode(o),re(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,i,n??E(t),!!(32&t.__u),a),o.__v=t.__v,o.__.__k[o.__i]=o,ae(i,o,a),t.__e=t.__=null,o.__e!=n&&O(o)}}function O(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),O(e)}function k(e){(!e.__d&&(e.__d=!0)&&a.push(e)&&!A.__r++||o!=r.debounceRendering)&&((o=r.debounceRendering)||s)(A)}function A(){try{for(var e,t=1;a.length;)a.length>t&&a.sort(c),e=a.shift(),t=a.length,D(e)}finally{a.length=A.__r=0}}function ee(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,v,y=r&&r.__k||_,b=t.length;for(c=te(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||g,p.__i=d,v=re(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&ce(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),4&p.__u?(c=j(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function te(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=C(null,o,null,null,null):y(o)?o=e.__k[a]=C(w,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=C(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=M(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=E(s)),le(s,s));return r}function j(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=j(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=E(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function M(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function N(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||v.test(t)?n:n+`px`}function P(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||N(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||N(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(f,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[d]=r[d]:(n[d]=p,e.addEventListener(t,a?h:m,a)):e.removeEventListener(t,a?h:m,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function ne(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[u]==null)t[u]=p++;else if(t[u]<n[d])return;return n(r.event?r.event(t):t)}}}function re(e,t,n,i,a,o,s,c,l,u){var d,f,p,m,h,g,v,S,C,D,O,k,A,te,j,M,N=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[c=t.__e=n.__e]),(d=r.__b)&&d(t);n:if(typeof N==`function`){f=s.length;try{if(C=t.props,D=N.prototype&&N.prototype.render,O=(d=N.contextType)&&i[d.__c],k=d?O?O.props.value:d.__:i,n.__c?S=(p=t.__c=n.__c).__=p.__E:(D?t.__c=p=new N(C,k):(t.__c=p=new T(C,k),p.constructor=N,p.render=ue),O&&O.sub(p),p.state||(p.state={}),p.__n=i,m=p.__d=!0,p.__h=[],p._sb=[]),D&&p.__s==null&&(p.__s=p.state),D&&N.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=b({},p.__s)),b(p.__s,N.getDerivedStateFromProps(C,p.__s))),h=p.props,g=p.state,p.__v=t,m)D&&N.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),D&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(D&&N.getDerivedStateFromProps==null&&C!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(C,k),t.__v==n.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(C,p.__s,k)){t.__v!=n.__v&&(p.props=C,p.state=p.__s,p.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),_.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&s.push(p),c=E(n);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(C,p.__s,k),D&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,g,v)})}if(p.context=k,p.props=C,p.__P=e,p.__e=!1,A=r.__r,te=0,D)p.state=p.__s,p.__d=!1,A&&A(t),d=p.render(p.props,p.state,p.context),_.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,A&&A(t),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++te<25);p.state=p.__s,p.getChildContext!=null&&(i=b(b({},i),p.getChildContext())),D&&!m&&p.getSnapshotBeforeUpdate!=null&&(v=p.getSnapshotBeforeUpdate(h,g)),j=d!=null&&d.type===w&&d.key==null?oe(d.props.children):d,c=ee(e,y(j)?j:[j],t,n,i,a,o,s,c,l,u),p.base=t.__e,t.__u&=-161,p.__h.length&&s.push(p),S&&(p.__E=p.__=null)}catch(e){if(s.length=f,t.__v=null,l||o!=null){if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o!=null&&(o[o.indexOf(c)]=null),t.__e=c}else if(o!=null)for(M=o.length;M--;)x(o[M])}else t.__e=n.__e;t.__k??=n.__k||[],e.then||ie(t),r.__e(e,t,n)}}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=se(n.__e,t,n,i,a,o,s,l,u);return(d=r.diffed)&&d(t),128&t.__u?void 0:c}function ie(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ie))}function ae(e,t,n){for(var i=0;i<n.length;i++)ce(n[i],n[++i],n[++i]);r.__c&&r.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){r.__e(e,t.__v)}})}function oe(e){return typeof e!=`object`||!e||e.__b>0?e:y(e)?e.map(oe):e.constructor===void 0?b({},e):null}function se(e,t,i,a,o,s,c,l,u){var d,f,p,m,h,_,v,b=i.props||g,S=t.props,C=t.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d<s.length;d++)if((h=s[d])&&`setAttribute`in h==!!C&&(C?h.localName==C:h.nodeType==3)){e=h,s[d]=null;break}}if(e==null){if(C==null)return document.createTextNode(S);e=document.createElementNS(o,C,S.is&&S),l&&=(r.__m&&r.__m(t,s),!1),s=null}if(C==null)b===S||l&&e.data==S||(e.data=S);else{if(s=C==`textarea`&&S.defaultValue!=null?null:s&&n.call(e.childNodes),!l&&s!=null)for(b={},d=0;d<e.attributes.length;d++)b[(h=e.attributes[d]).name]=h.value;for(d in b)h=b[d],d==`dangerouslySetInnerHTML`?p=h:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||P(e,d,null,h,o);for(d in S)h=S[d],d==`children`?m=h:d==`dangerouslySetInnerHTML`?f=h:d==`value`?_=h:d==`checked`?v=h:l&&typeof h!=`function`||b[d]===h||P(e,d,h,b[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(p&&(e.innerHTML=``),ee(t.type==`template`?e.content:e,y(m)?m:[m],t,i,a,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&E(i,0),l,u),s!=null)for(d=s.length;d--;)x(s[d]);l&&C!=`textarea`||(d=`value`,C==`progress`&&_==null?e.removeAttribute(`value`):_!=null&&(_!==e[d]||C==`progress`&&!_||C==`option`&&_!=b[d])&&P(e,d,_,b[d],o),d=`checked`,v!=null&&v!=e[d]&&P(e,d,v,b[d],o))}return e}function ce(e,t,n){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(e){r.__e(e,n)}}function le(e,t,n){var i,a;if(r.unmount&&r.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||ce(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){r.__e(e,t)}i.base=i.__P=i.__n=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&le(i[a],t,n||typeof e.type!=`function`);n||x(e.__e),e.__c=e.__=e.__e=void 0}function ue(e,t,n){return this.constructor(e,n)}function de(e,t,i){var a,o,s,c;t==document&&(t=document.documentElement),r.__&&r.__(e,t),o=(a=typeof i==`function`)?null:i&&i.__k||t.__k,s=[],c=[],re(t,e=(!a&&i||t).__k=S(w,null,[e]),o||g,g,t.namespaceURI,!a&&i?[i]:o?null:t.firstChild?n.call(t.childNodes):null,s,!a&&i?i:o?o.__e:t.firstChild,a,c),ae(s,e,c),e.props.children=null}n=_.slice,r={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},i=0,T.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=b({},this.state);typeof e==`function`&&(e=e(b({},n),this.props)),e&&b(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),k(this))},T.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),k(this))},T.prototype.render=w,a=[],s=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,c=function(e,t){return e.__v.__b-t.__v.__b},A.__r=0,l=Math.random().toString(8),u=`__d`+l,d=`__a`+l,f=/(PointerCapture)$|Capture$/i,p=0,m=ne(!1),h=ne(!0);var F,I,fe,pe,L=0,me=[],R=r,he=R.__b,ge=R.__r,_e=R.diffed,ve=R.__c,ye=R.unmount,be=R.__;function xe(e,t){R.__h&&R.__h(I,e,L||t),L=0;var n=I.__H||(I.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function z(e){return L=1,Se(ke,e)}function Se(e,t,n){var r=xe(F++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ke(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=I,!I.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};I.__f=!0;var a=I.shouldComponentUpdate,o=I.componentWillUpdate;I.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},I.shouldComponentUpdate=i}return r.__N||r.__}function B(e,t){var n=xe(F++,3);!R.__s&&Oe(n.__H,t)&&(n.__=e,n.u=t,I.__H.__h.push(n))}function V(e){return L=5,Ce(function(){return{current:e}},[])}function Ce(e,t){var n=xe(F++,7);return Oe(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function we(){for(var e;e=me.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(H),t.__h.some(De),t.__h=[]}catch(n){t.__h=[],R.__e(n,e.__v)}}}R.__b=function(e){I=null,he&&he(e)},R.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),be&&be(e,t)},R.__r=function(e){ge&&ge(e),F=0;var t=(I=e.__c).__H;t&&(fe===I?(t.__h=[],I.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(H),t.__h.some(De),t.__h=[],F=0)),fe=I},R.diffed=function(e){_e&&_e(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(me.push(t)!==1&&pe===R.requestAnimationFrame||((pe=R.requestAnimationFrame)||Ee)(we)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),fe=I=null},R.__c=function(e,t){t.some(function(e){try{e.__h.some(H),e.__h=e.__h.filter(function(e){return!e.__||De(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],R.__e(n,e.__v)}}),ve&&ve(e,t)},R.unmount=function(e){ye&&ye(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{H(e)}catch(e){t=e}}),n.__H=void 0,t&&R.__e(t,n.__v))};var Te=typeof requestAnimationFrame==`function`;function Ee(e){var t,n=function(){clearTimeout(r),Te&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Te&&(t=requestAnimationFrame(n))}function H(e){var t=I,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),I=t}function De(e){var t=I;e.__c=e.__(),I=t}function Oe(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function ke(e,t){return typeof t==`function`?t(e):t}var Ae=0;Array.isArray;function U(e,t,n,i,a,o){t||={};var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ae,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return r.vnode&&r.vnode(u),u}function W({name:e,size:t,children:n}){return U(`svg`,{"data-icon":e,"aria-hidden":`true`,focusable:`false`,width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,children:n})}function je({size:e=26}){return U(W,{name:`chat`,size:e,children:[U(`path`,{d:`M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 4v-4h0A1.5 1.5 0 0 1 4 14.5z`}),U(`path`,{d:`M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01`,"stroke-width":`2.5`})]})}function Me({size:e=26}){return U(W,{name:`chevron-down`,size:e,children:U(`path`,{d:`M6 9l6 6 6-6`})})}function Ne({size:e=18}){return U(W,{name:`close`,size:e,children:U(`path`,{d:`M6 6l12 12M18 6L6 18`})})}var Pe=`M7 11v9M7 11l3.5-7.2A1.8 1.8 0 0 1 14 4.6V9h4.6a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 17.4 20H7M7 11H4.5A1.5 1.5 0 0 0 3 12.5v6A1.5 1.5 0 0 0 4.5 20H7`;function Fe({size:e=16}){return U(W,{name:`thumb-up`,size:e,children:U(`path`,{d:Pe})})}function Ie({size:e=16}){return U(W,{name:`thumb-down`,size:e,children:U(`path`,{d:Pe,transform:`matrix(1 0 0 -1 0 24)`})})}function Le({isOpen:e,onClick:t,iconUrl:n,buttonRef:r}){let[i,a]=z(`loading`),o=n!==void 0&&i!==`failed`,s=o&&!e&&i===`loaded`;return U(`button`,{type:`button`,class:`whoo-widget-launcher`,onClick:t,"aria-label":e?`Close chat`:`Open chat`,ref:r,children:[e?U(Me,{}):s?null:U(je,{}),o?U(`img`,{class:`whoo-widget-launcher-icon-image`,src:n,alt:``,referrerpolicy:`no-referrer`,hidden:!s,onLoad:()=>a(`loaded`),onError:()=>a(`failed`)}):null]})}function Re({value:e,onChange:t,onSend:n,disabled:r,inputRef:i}){return U(`div`,{class:`whoo-widget-composer`,children:[U(`label`,{class:`whoo-widget-sr-only`,for:`whoo-widget-composer-input`,children:`Message`}),U(`input`,{id:`whoo-widget-composer-input`,class:`whoo-widget-composer-input`,value:e,readOnly:r,"aria-disabled":r,ref:i,onInput:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&n()}}),U(`button`,{type:`button`,class:`whoo-widget-composer-send`,onClick:n,disabled:r,children:`Send`})]})}function ze({message:e}){return U(`div`,{class:`whoo-widget-error-banner`,role:`alert`,children:e})}var G=/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y,K=/\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y,q=/(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y,J=/\*([^*\s](?:[^*]*[^*\s])?)\*/y,Y=/[ \t]*[*+-][ \t]+/y,Be=/https?:\/\/\S+/y,Ve=/[.,;:!?)\]}>]+$/;function He(e){let t=[],n=0,r=0,i=n=>{n>r&&t.push({type:`text`,value:e.slice(r,n),start:r,end:n})};for(;n<e.length;){if((n===0||e[n-1]===`
2
+ `)&&(Y.lastIndex=n,Y.exec(e))){i(n),t.push({type:`text`,value:`• `,start:n,end:Y.lastIndex}),n=Y.lastIndex,r=n;continue}if(e[n]===`!`&&n+1<e.length&&e[n+1]===`[`){let t=/!\[([^\]]*)\]\(([^)]*)\)/y;t.lastIndex=n;let r=t.exec(e);if(r){n+=r[0].length;continue}}if(e[n-1]!==`!`){G.lastIndex=n;let a=G.exec(e);if(a){i(n),t.push({type:`link`,text:a[1],url:a[2],start:n,end:G.lastIndex}),n=G.lastIndex,r=n;continue}}K.lastIndex=n;let a=K.exec(e);if(a){i(n),t.push({type:`bold`,value:a[1],start:n,end:K.lastIndex}),n=K.lastIndex,r=n;continue}q.lastIndex=n;let o=q.exec(e);if(o){i(n),t.push({type:`italic`,value:o[1],start:n,end:q.lastIndex}),n=q.lastIndex,r=n;continue}J.lastIndex=n;let s=J.exec(e);if(s){i(n),t.push({type:`italic`,value:s[1],start:n,end:J.lastIndex}),n=J.lastIndex,r=n;continue}Be.lastIndex=n;let c=Be.exec(e);if(c){let e=c[0].match(Ve),a=e?c[0].slice(0,c[0].length-e[0].length):c[0];if(a.length>0){i(n),t.push({type:`link`,text:a,url:a,start:n,end:n+a.length}),n+=a.length,r=n;continue}}n+=1}return i(e.length),t}function Ue(e){return He(e).map((e,t)=>{switch(e.type){case`bold`:return U(`strong`,{children:Ue(e.value)},t);case`italic`:return U(`em`,{children:Ue(e.value)},t);case`link`:return U(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:[e.text,U(`span`,{class:`whoo-widget-sr-only`,children:` (opens in new tab)`})]},t);default:return e.value}})}var We=[{value:``,label:`Select a reason (optional)`},{value:`factual`,label:`Factual error`},{value:`incomplete`,label:`Incomplete`},{value:`tone`,label:`Off tone`},{value:`other`,label:`Other`}];function Ge({state:e,containerRef:t,onThumbsUp:n,onThumbsDown:r,onSubmitDetailed:i,onCancel:a}){let[o,s]=z(``),[c,l]=z(``),u=V(e.status);if(B(()=>{let n=u.current;if(u.current=e.status,n===e.status)return;let r=t?.current;if(!r)return;let i=r.getRootNode();r.contains(i.activeElement)||r.focus()},[e.status,t]),e.status===`submitted`)return U(`div`,{class:`whoo-widget-feedback-submitted`,role:`status`,children:`Thanks for the feedback`});if(e.status===`expanded`)return U(`div`,{class:`whoo-widget-feedback-form`,children:[U(`label`,{children:[U(`span`,{class:`whoo-widget-sr-only`,children:`Additional feedback`}),U(`textarea`,{class:`whoo-widget-feedback-textarea`,value:o,onInput:e=>s(e.target.value),placeholder:`What was wrong? (optional)`})]}),U(`select`,{class:`whoo-widget-feedback-select`,"aria-label":`Feedback category`,value:c,onChange:e=>l(e.target.value),children:We.map(e=>U(`option`,{value:e.value,children:e.label},e.value))}),U(`div`,{class:`whoo-widget-feedback-form-buttons`,children:[U(`button`,{type:`button`,class:`whoo-widget-feedback-submit`,onClick:()=>i(o,c),children:`Submit`}),U(`button`,{type:`button`,class:`whoo-widget-feedback-cancel`,onClick:a,children:`Cancel`})]})]});let d=e.status===`submitting`;return U(`div`,{class:`whoo-widget-feedback`,children:[U(`div`,{class:`whoo-widget-feedback-buttons`,children:[U(`button`,{type:`button`,"aria-label":`Good response`,disabled:d,onClick:n,children:U(Fe,{})}),U(`button`,{type:`button`,"aria-label":`Bad response`,disabled:d,onClick:r,children:U(Ie,{})})]}),e.status===`error`?U(`div`,{class:`whoo-widget-feedback-error`,role:`status`,children:`Couldn't send feedback`}):null]})}function Ke({isSlowResponse:e}){return U(`div`,{class:`whoo-widget-pending`,role:`status`,children:[U(`span`,{class:`whoo-widget-typing`,"aria-hidden":`true`,children:[U(`span`,{}),U(`span`,{}),U(`span`,{})]}),e?U(`span`,{class:`whoo-widget-pending-text`,children:`Looking that up for you…`}):null]})}function qe({url:e,alt:t}){let[n,r]=z(!1);return n?null:U(`img`,{class:`whoo-widget-empty-state-image`,src:e,alt:t,referrerpolicy:`no-referrer`,onError:()=>r(!0)})}function Je({message:e,feedbackState:t,pending:n,isSlowResponse:r,onThumbsUp:i,onThumbsDown:a,onSubmitDetailed:o,onCancelFeedback:s}){let c=V(null),l=e.id;return U(`div`,{ref:c,tabIndex:-1,class:`whoo-widget-message whoo-widget-message--${e.role}`,children:[n?U(Ke,{isSlowResponse:r}):Ue(e.content),e.role===`assistant`&&l?U(Ge,{state:t,containerRef:c,onThumbsUp:()=>i(l),onThumbsDown:()=>a(l),onSubmitDetailed:(e,t)=>o(l,e,t),onCancel:()=>s(l)}):null]})}function Ye({messages:e,messageFeedback:t,lastCompletedMessageText:n,emptyStateImage:r,isStreaming:i=!1,isSlowResponse:a=!1,onThumbsUp:o,onThumbsDown:s,onSubmitDetailed:c,onCancelFeedback:l}){let u=V(null);return B(()=>{let e=u.current;e&&(e.scrollTop=e.scrollHeight)},[e,a]),U(w,{children:[U(`div`,{class:`whoo-widget-message-list`,ref:u,children:[r?U(qe,{...r}):null,e.map((n,r)=>U(Je,{message:n,feedbackState:n.id?t[n.id]??{status:`idle`}:{status:`idle`},pending:i&&r===e.length-1&&n.role===`assistant`&&n.content===``,isSlowResponse:a,onThumbsUp:o,onThumbsDown:s,onSubmitDetailed:c,onCancelFeedback:l},n.id??r))]}),U(`div`,{class:`whoo-widget-sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:n??``})]})}var Xe=`button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`;function Ze(e){return Array.from(e.querySelectorAll(Xe)).filter(e=>{let t=getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`})}function Qe({state:e,controller:t,greeting:n}){let r=V(null),i=V(null);B(()=>{i.current?.focus()},[]);let a=e=>{if(e.key===`Escape`){t.close();return}if(e.key!==`Tab`)return;let n=r.current;if(!n)return;let i=Ze(n);if(i.length===0)return;let a=i[0],o=i[i.length-1],s=n.getRootNode().activeElement;if(!n.contains(s)){e.preventDefault(),a.focus();return}e.shiftKey&&s===a?(e.preventDefault(),o.focus()):!e.shiftKey&&s===o&&(e.preventDefault(),a.focus())},o=()=>{let n=e.draft.trim();n&&!e.isStreaming&&(t.setDraft(``),t.sendMessage(n))},s=`Chat with ${e.agentName??(t.config.name?.trim()||`Aiden`)}`,c=e.messages.length===0&&n?[{role:`assistant`,content:n,id:null}]:e.messages,l=t.emptyStateImageUrl,u=e.messages.length===0&&l?{url:l,alt:t.emptyStateImageAlt}:void 0;return U(`div`,{class:`whoo-widget-panel`,role:`dialog`,"aria-modal":`true`,"aria-label":s,ref:r,onKeyDown:a,children:[U(`div`,{class:`whoo-widget-header`,children:[U(`h2`,{class:`whoo-widget-header-title`,children:s}),U(`div`,{class:`whoo-widget-header-actions`,children:[e.messages.length>0&&U(`button`,{type:`button`,class:`whoo-widget-header-reset`,onClick:()=>t.resetConversation(),children:`New conversation`}),U(`button`,{type:`button`,class:`whoo-widget-header-close`,"aria-label":`Close chat`,onClick:()=>t.close(),children:U(Ne,{})})]})]}),U(Ye,{messages:c,messageFeedback:e.messageFeedback,lastCompletedMessageText:e.lastCompletedMessageText,emptyStateImage:u,isStreaming:e.isStreaming,isSlowResponse:e.isSlowResponse,onThumbsUp:e=>t.submitFeedback(e,`up`),onThumbsDown:e=>t.expandFeedback(e),onSubmitDetailed:(e,n,r)=>t.submitFeedback(e,`down`,n||void 0,r||void 0),onCancelFeedback:e=>t.cancelFeedback(e)}),e.runtimeError&&U(ze,{message:e.runtimeError}),U(Re,{value:e.draft,onChange:e=>t.setDraft(e),onSend:o,disabled:e.isStreaming,inputRef:i})]})}function $e({controller:e}){let[t,n]=z(e.getState()),r=V(null),i=V(t.isOpen);return B(()=>(n(e.getState()),e.subscribe(n)),[e]),B(()=>{i.current&&!t.isOpen&&r.current?.focus(),i.current=t.isOpen},[t.isOpen]),t.initError?null:U(w,{children:[U(Le,{isOpen:t.isOpen,onClick:()=>t.isOpen?e.close():e.open(),iconUrl:e.launcherIconUrl,buttonRef:r}),t.isOpen&&U(Qe,{state:t,controller:e,greeting:e.config.greeting})]})}var et=class extends Error{status;constructor(e,t){super(e),this.name=`WidgetApiError`,this.status=t}};function tt(e){if(typeof e!=`string`)return null;let t=e.trim();return t===``?null:t}async function nt(e,t){let n=await fetch(`${e}/api/v1/widget/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({publishable_key:t})});if(!n.ok)throw new et(`Failed to create widget session (${n.status})`,n.status);let r=await n.json();return{token:r.token,primaryColor:r.primary_color??null,name:tt(r.name),accentColor:tt(r.accent_color),inkColor:tt(r.ink_color)}}async function rt(e,t,n){let r=await fetch(`${e}/api/v1/widget/feedback`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t}`},body:JSON.stringify({message_id:n.messageId,rating:n.rating,correction:n.correction??null,category:n.category??null})});if(!r.ok)throw new et(`Feedback submission failed (${r.status})`,r.status)}async function*it(e,t,n,r,i){let a=await fetch(`${e}/api/v1/widget/chat`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t}`},body:JSON.stringify({conversation_id:n,message:r}),signal:i});if(!a.ok||!a.body)throw new et(`Chat request failed (${a.status})`,a.status);let o=a.body.getReader(),s=new TextDecoder,c=``;for(;;){let{done:e,value:t}=await o.read();if(e)break;c+=s.decode(t,{stream:!0});let n=c.indexOf(`
2
3
 
3
4
  `);for(;n!==-1;){let e=c.slice(0,n);c=c.slice(n+2);let t=e.split(`
4
- `).find(e=>e.startsWith(`data: `));t&&(yield it(JSON.parse(t.slice(6)))),n=c.indexOf(`
5
+ `).find(e=>e.startsWith(`data: `));t&&(yield at(JSON.parse(t.slice(6)))),n=c.indexOf(`
5
6
 
6
- `)}}}function it(e){return typeof e.error==`string`?{type:`error`,error:e.error,conversationId:e.conversation_id}:e.done===!0?{type:`done`,conversationId:e.conversation_id,messageId:e.message_id??null}:typeof e.delta==`string`?e.verbatim===!0?{type:`delta`,delta:e.delta,verbatim:!0}:{type:`delta`,delta:e.delta}:{type:`conversation_id`,conversationId:e.conversation_id}}function at(e,t){if(e!=null&&e!==``){if(typeof e==`string`)try{let t=new URL(e);if(t.protocol===`https:`||t.protocol===`data:`&&t.pathname.toLowerCase().startsWith(`image/`))return e}catch{}console.warn(`whoo-aiden-widget: ignoring \`${t}\` -- only https: and data:image/ URLs are allowed.`)}}var ot=40,st=120;function ct(e){let t=[];for(let n of Ve(e))if(n.type===`text`){let e=n.value.split(/(\s+)/),r=n.start;for(let n of e)r+=n.length,n.trim().length>0&&t.push(r)}else t.push(n.end);return t}function lt(e){let t=null;return e?.addEventListener(`abort`,()=>{t?.()},{once:!0}),function(e){return new Promise(n=>{let r=setTimeout(()=>{t=null,n()},e);t=()=>{clearTimeout(r),t=null,n()}})}}async function ut(e,t,n){let r=n?.wordIntervalMs??ot,i=n?.tokenIntervalMs??st,a=n?.signal,o=Ve(e),s=new Set(o.filter(e=>e.type!==`text`).map(e=>e.end)),c=lt(a),l=``;for(let n of ct(e))if(a?.aborted||(l=e.slice(0,n),t(l),await c(s.has(n)?i:r),a?.aborted))return;l!==e&&t(e)}function dt(e){return`whoo-aiden-widget:conversation:${e}`}function ft(e){try{return window.sessionStorage.getItem(dt(e))}catch{return null}}function pt(e,t){try{window.sessionStorage.setItem(dt(e),t)}catch{}}function mt(e){try{window.sessionStorage.removeItem(dt(e))}catch{}}var ht=8e3,gt=class{config;state;listeners=new Set;sessionToken=null;conversationId=null;storageIdentifier;activeRequestController=null;slowResponseTimer=null;prefersReducedMotion;launcherIconUrl;emptyStateImageUrl;emptyStateImageAlt;constructor(e){this.config=e,this.launcherIconUrl=at(e.launcherIconUrl,`launcherIconUrl`),this.emptyStateImageUrl=at(e.emptyStateImageUrl,`emptyStateImageUrl`),this.emptyStateImageAlt=typeof e.emptyStateImageAlt==`string`?e.emptyStateImageAlt.trim():``,this.storageIdentifier=e.publishableKey??`session-token-mode`,this.prefersReducedMotion=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,this.state={isOpen:!1,messages:[],isStreaming:!1,initError:null,runtimeError:null,messageFeedback:{},primaryColor:null,agentName:null,accentColor:null,inkColor:null,lastCompletedMessageText:null,isSlowResponse:!1,draft:``}}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}clearSlowResponse(){this.slowResponseTimer!==null&&(clearTimeout(this.slowResponseTimer),this.slowResponseTimer=null),this.state.isSlowResponse&&this.setState({isSlowResponse:!1})}setState(e){this.state={...this.state,...e};for(let e of this.listeners)e(this.state)}async init(){let e=this.config.apiBaseUrl??`https://api.aidenvoice.com`;try{if(this.config.sessionToken)this.sessionToken=this.config.sessionToken;else if(this.config.publishableKey){let{token:t,primaryColor:n,name:r,accentColor:i,inkColor:a}=await tt(e,this.config.publishableKey);this.sessionToken=t,this.setState({primaryColor:n,agentName:r,accentColor:i,inkColor:a})}else throw Error(`WidgetConfig must include exactly one of publishableKey or sessionToken`)}catch(e){console.error(`[whoo-aiden-widget] initialization failed:`,e),this.setState({initError:e instanceof Error?e.message:String(e)});return}this.conversationId=ft(this.storageIdentifier)}open(){this.setState({isOpen:!0})}resetConversation(){this.activeRequestController?.abort(),this.activeRequestController=null,this.clearSlowResponse(),this.conversationId=null,mt(this.storageIdentifier),this.setState({messages:[],messageFeedback:{},runtimeError:null,isStreaming:!1,lastCompletedMessageText:null})}setDraft(e){this.setState({draft:e})}close(){this.activeRequestController?.abort(),this.activeRequestController=null,this.clearSlowResponse(),this.setState({isOpen:!1})}async sendMessage(e){if(!this.sessionToken)return;let t=this.config.apiBaseUrl??`https://api.aidenvoice.com`,n={role:`user`,content:e,id:null},r={role:`assistant`,content:``,id:null};this.setState({messages:[...this.state.messages,n,r],isStreaming:!0,runtimeError:null});let i=e=>{let t=[...this.state.messages];t[t.length-1]={...t[t.length-1],content:e},this.setState({messages:t})};this.activeRequestController=new AbortController;let{signal:a}=this.activeRequestController;this.slowResponseTimer=setTimeout(()=>{this.slowResponseTimer=null,this.setState({isSlowResponse:!0})},ht);let o=()=>{this.setState({runtimeError:`Something went wrong, please try again.`,...this.state.draft===``?{draft:e}:{}})},s=``;try{for await(let n of rt(t,this.sessionToken,this.conversationId,e,a))if(n.type===`conversation_id`)this.conversationId=n.conversationId,pt(this.storageIdentifier,n.conversationId);else if(n.type===`delta`)this.clearSlowResponse(),n.verbatim&&!this.prefersReducedMotion?(await ut(n.delta,e=>i(e),{signal:a}),s=n.delta):n.verbatim?(s=n.delta,i(s)):(s+=n.delta,i(s));else if(n.type===`done`){if(n.conversationId&&(this.conversationId=n.conversationId,pt(this.storageIdentifier,n.conversationId)),n.messageId){let e=[...this.state.messages];e[e.length-1]={...e[e.length-1],id:n.messageId},this.setState({messages:e})}this.setState({lastCompletedMessageText:s})}else if(n.type===`error`){console.error(`[whoo-aiden-widget] chat error:`,n.error),o(),this.activeRequestController?.abort();break}}catch(e){e?.name===`AbortError`||(console.error(`[whoo-aiden-widget] chat request failed:`,e),o())}finally{this.activeRequestController=null,this.clearSlowResponse(),this.setState({isStreaming:!1})}}expandFeedback(e){this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`expanded`}}})}cancelFeedback(e){this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`idle`}}})}async submitFeedback(e,t,n,r){if(!this.sessionToken)return;let i=this.config.apiBaseUrl??`https://api.aidenvoice.com`;this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`submitting`,rating:t}}});try{await nt(i,this.sessionToken,{messageId:e,rating:t,correction:n,category:r}),this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`submitted`,rating:t}}})}catch(n){console.error(`[whoo-aiden-widget] feedback submission failed:`,n),this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`error`,rating:t}}})}}},_t=`:host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:20px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:var(--whoo-widget-color,#4f46e5);width:56px;height:56px;color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{display:block}.whoo-widget-launcher-icon-image{object-fit:cover;border-radius:50%;width:32px;height:32px}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:88px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:#fff;border-radius:12px;flex-direction:column;width:360px;max-width:calc(100vw - 40px);height:480px;max-height:calc(100vh - 108px);display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-header{border-bottom:1px solid #e5e5e5;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;padding:8px 8px 8px 16px;display:flex}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);text-overflow:ellipsis;white-space:nowrap;margin:0;font-size:15px;font-weight:600;overflow:hidden}.whoo-widget-header-actions{flex-shrink:0;align-items:center;gap:4px;display:flex}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:#f3f4f6}.whoo-widget-message-list{flex:1;min-height:100px;padding:12px;overflow-y:auto}.whoo-widget-empty-state-image{object-fit:contain;max-width:min(160px,100%);height:auto;max-height:160px;margin:8px auto 16px;display:block}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.whoo-widget-message{border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-left:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{color:var(--whoo-widget-ink,#111);background:#f0f0f0}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:#6b7280;border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{color:#991b1b;background:#fee2e2;padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid #e5e5e5;gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid #6b7280;border-radius:6px;flex:1;padding:8px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.whoo-widget-composer-send:disabled,.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:#4b5563;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:#111;background:#0000000f}.whoo-widget-feedback-buttons button:disabled{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;resize:vertical;border:1px solid #6b7280;border-radius:6px;width:100%;padding:6px;font-size:12px}.whoo-widget-feedback-select{border:1px solid #6b7280;border-radius:6px;min-height:24px;padding:4px;font-size:12px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{color:#111;cursor:pointer;background:#fff;border:1px solid #6b7280;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:#6b7280;margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:#991b1b;font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline-offset:2px;outline:2px solid #111827;box-shadow:0 0 0 4px #fff}`,vt=/^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;function yt(e){if(vt.test(e.trim()))return null;let t=document.createElement(`div`);if(t.style.color=e,t.style.color===``)return null;let n=document.createElement(`div`);n.attachShadow({mode:`open`}).appendChild(t),document.body.appendChild(n);let r=getComputedStyle(t).color;n.remove();let i=r.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/);if(!i)return null;let a=i[4]===void 0?1:Number(i[4]);return{rgb:[Number(i[1]),Number(i[2]),Number(i[3])].map(e=>Math.round(e*a+255*(1-a))),translucent:a<1}}function bt(e){return yt(e)?.rgb??null}function X([e,t,n]){let r=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function Z(e,t){let n=Math.max(e,t),r=Math.min(e,t);return(n+.05)/(r+.05)}function xt(e){let t=bt(e);if(!t)return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`),`#ffffff`;let n=X(t);return Z(n,X([0,0,0]))>=Z(n,X([255,255,255]))?`#000000`:`#ffffff`}var Q=`#4f46e5`,St=`#ffffff`,Ct=`#f0f0f0`,wt=4.5;function Tt([e,t,n]){return`#${[e,t,n].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function Et(e,t=St){let n=bt(e),r=bt(t);if(!n||!r)return Q;let i=X(r),a=e=>Z(X(e),i)>=wt;if(a(n))return Tt(n);for(let e=.99;e>0;e-=.01){let t=n.map(t=>Math.round(t*e));if(a(t))return Tt(t)}return`#000000`}var Dt=`#111111`,Ot=`#0000ee`;function $(e){if(!e)return null;let t=yt(e);return t?Tt(t.rgb):null}function kt({color:e,inkColor:t,accentColor:n}){let r=$(e),i=r??Q,a=Et(i),o=$(t),s=o?Et(o,Ct):Dt,c=$(n),l=c?Et(c,Ct):Ot;return{primary:i,textOnPrimary:xt(i),primaryAsText:a,ink:s,link:l,adjusted:{primary:r!==null&&a!==i,ink:o!==null&&s!==o,link:c!==null&&l!==c}}}function At(e,t,n=Q){let r=t;$(t)===null&&(console.warn(`[whoo-aiden-widget] Could not use "${t}" as the theme color; falling back to "${n}".`),r=n);let i=kt({color:r});e.style.setProperty(`--whoo-widget-color`,i.primary),e.style.setProperty(`--whoo-widget-text-on-color`,i.textOnPrimary),e.style.setProperty(`--whoo-widget-color-text`,i.primaryAsText)}function jt(e,{inkColor:t,accentColor:n}){let r=kt({inkColor:t,accentColor:n});e.style.setProperty(`--whoo-widget-ink`,r.ink),e.style.setProperty(`--whoo-widget-link-color`,r.link)}function Mt(e,t){e&&$(e)===null&&console.warn(`[whoo-aiden-widget] Could not use "${e}" as the ${t}; using the default.`)}function Nt(e,t){At(e,t.color??Q),Mt(t.inkColor,`ink color`),Mt(t.accentColor,`accent color`),jt(e,{inkColor:t.inkColor,accentColor:t.accentColor});let n=t.position===`bottom-left`;e.style.setProperty(`--whoo-widget-inset-left`,n?`20px`:`auto`),e.style.setProperty(`--whoo-widget-inset-right`,n?`auto`:`20px`)}function Pt(e){let t=document.createElement(`div`);t.id=`whoo-aiden-widget-host`;let n=t.attachShadow({mode:`open`}),r=document.createElement(`style`);r.textContent=_t,n.appendChild(r);let i=document.createElement(`div`);n.appendChild(i),Nt(i,e);let a=new gt(e),o=null,s=``;return a.subscribe(t=>{t.primaryColor&&t.primaryColor!==o&&(o=t.primaryColor,At(i,t.primaryColor,e.color));let n=`${t.inkColor}|${t.accentColor}`;(t.inkColor||t.accentColor)&&n!==s&&(s=n,jt(i,{inkColor:$(t.inkColor)?t.inkColor:e.inkColor,accentColor:$(t.accentColor)?t.accentColor:e.accentColor}))}),de(W(Qe,{controller:a}),i),a.init(),document.body.appendChild(t),{unmount(){de(null,i),t.remove()}}}function Ft(e){return t(e),Pt(e)}return e.init=Ft,e})({});
7
+ `)}}}function at(e){return typeof e.error==`string`?{type:`error`,error:e.error,conversationId:e.conversation_id}:e.done===!0?{type:`done`,conversationId:e.conversation_id,messageId:e.message_id??null}:typeof e.delta==`string`?e.verbatim===!0?{type:`delta`,delta:e.delta,verbatim:!0}:{type:`delta`,delta:e.delta}:{type:`conversation_id`,conversationId:e.conversation_id}}function ot(e,t){if(e!=null&&e!==``){if(typeof e==`string`)try{let t=new URL(e);if(t.protocol===`https:`||t.protocol===`data:`&&t.pathname.toLowerCase().startsWith(`image/`))return e}catch{}console.warn(`whoo-aiden-widget: ignoring \`${t}\` -- only https: and data:image/ URLs are allowed.`)}}var st=40,ct=120;function lt(e){let t=[];for(let n of He(e))if(n.type===`text`){let e=n.value.split(/(\s+)/),r=n.start;for(let n of e)r+=n.length,n.trim().length>0&&t.push(r)}else t.push(n.end);return t}function ut(e){let t=null;return e?.addEventListener(`abort`,()=>{t?.()},{once:!0}),function(e){return new Promise(n=>{let r=setTimeout(()=>{t=null,n()},e);t=()=>{clearTimeout(r),t=null,n()}})}}async function dt(e,t,n){let r=n?.wordIntervalMs??st,i=n?.tokenIntervalMs??ct,a=n?.signal,o=He(e),s=new Set(o.filter(e=>e.type!==`text`).map(e=>e.end)),c=ut(a),l=``;for(let n of lt(e))if(a?.aborted||(l=e.slice(0,n),t(l),await c(s.has(n)?i:r),a?.aborted))return;l!==e&&t(e)}function ft(e){return`whoo-aiden-widget:conversation:${e}`}function pt(e){try{return window.sessionStorage.getItem(ft(e))}catch{return null}}function mt(e,t){try{window.sessionStorage.setItem(ft(e),t)}catch{}}function ht(e){try{window.sessionStorage.removeItem(ft(e))}catch{}}var gt=8e3,_t=class{config;state;listeners=new Set;sessionToken=null;conversationId=null;storageIdentifier;activeRequestController=null;slowResponseTimer=null;prefersReducedMotion;launcherIconUrl;emptyStateImageUrl;emptyStateImageAlt;constructor(e){this.config=e,this.launcherIconUrl=ot(e.launcherIconUrl,`launcherIconUrl`),this.emptyStateImageUrl=ot(e.emptyStateImageUrl,`emptyStateImageUrl`),this.emptyStateImageAlt=typeof e.emptyStateImageAlt==`string`?e.emptyStateImageAlt.trim():``,this.storageIdentifier=e.publishableKey??`session-token-mode`,this.prefersReducedMotion=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,this.state={isOpen:!1,messages:[],isStreaming:!1,initError:null,runtimeError:null,messageFeedback:{},primaryColor:null,agentName:null,accentColor:null,inkColor:null,lastCompletedMessageText:null,isSlowResponse:!1,draft:``}}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}clearSlowResponse(){this.slowResponseTimer!==null&&(clearTimeout(this.slowResponseTimer),this.slowResponseTimer=null),this.state.isSlowResponse&&this.setState({isSlowResponse:!1})}setState(e){this.state={...this.state,...e};for(let e of this.listeners)e(this.state)}async init(){let e=this.config.apiBaseUrl??`https://api.aidenvoice.com`;try{if(this.config.sessionToken)this.sessionToken=this.config.sessionToken;else if(this.config.publishableKey){let{token:t,primaryColor:n,name:r,accentColor:i,inkColor:a}=await nt(e,this.config.publishableKey);this.sessionToken=t,this.setState({primaryColor:n,agentName:r,accentColor:i,inkColor:a})}else throw Error(`WidgetConfig must include exactly one of publishableKey or sessionToken`)}catch(e){console.error(`[whoo-aiden-widget] initialization failed:`,e),this.setState({initError:e instanceof Error?e.message:String(e)});return}this.conversationId=pt(this.storageIdentifier)}open(){this.setState({isOpen:!0})}resetConversation(){this.activeRequestController?.abort(),this.activeRequestController=null,this.clearSlowResponse(),this.conversationId=null,ht(this.storageIdentifier),this.setState({messages:[],messageFeedback:{},runtimeError:null,isStreaming:!1,lastCompletedMessageText:null})}setDraft(e){this.setState({draft:e})}close(){this.activeRequestController?.abort(),this.activeRequestController=null,this.clearSlowResponse(),this.setState({isOpen:!1})}async sendMessage(e){if(!this.sessionToken)return;let t=this.config.apiBaseUrl??`https://api.aidenvoice.com`,n={role:`user`,content:e,id:null},r={role:`assistant`,content:``,id:null};this.setState({messages:[...this.state.messages,n,r],isStreaming:!0,runtimeError:null});let i=e=>{let t=[...this.state.messages];t[t.length-1]={...t[t.length-1],content:e},this.setState({messages:t})};this.activeRequestController=new AbortController;let{signal:a}=this.activeRequestController;this.slowResponseTimer=setTimeout(()=>{this.slowResponseTimer=null,this.setState({isSlowResponse:!0})},gt);let o=()=>{this.setState({runtimeError:`Something went wrong, please try again.`,...this.state.draft===``?{draft:e}:{}})},s=``;try{for await(let n of it(t,this.sessionToken,this.conversationId,e,a))if(n.type===`conversation_id`)this.conversationId=n.conversationId,mt(this.storageIdentifier,n.conversationId);else if(n.type===`delta`)this.clearSlowResponse(),n.verbatim&&!this.prefersReducedMotion?(await dt(n.delta,e=>i(e),{signal:a}),s=n.delta):n.verbatim?(s=n.delta,i(s)):(s+=n.delta,i(s));else if(n.type===`done`){if(n.conversationId&&(this.conversationId=n.conversationId,mt(this.storageIdentifier,n.conversationId)),n.messageId){let e=[...this.state.messages];e[e.length-1]={...e[e.length-1],id:n.messageId},this.setState({messages:e})}this.setState({lastCompletedMessageText:s})}else if(n.type===`error`){console.error(`[whoo-aiden-widget] chat error:`,n.error),o(),this.activeRequestController?.abort();break}}catch(e){e?.name===`AbortError`||(console.error(`[whoo-aiden-widget] chat request failed:`,e),o())}finally{this.activeRequestController=null,this.clearSlowResponse(),this.setState({isStreaming:!1})}}expandFeedback(e){this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`expanded`}}})}cancelFeedback(e){this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`idle`}}})}async submitFeedback(e,t,n,r){if(!this.sessionToken)return;let i=this.config.apiBaseUrl??`https://api.aidenvoice.com`;this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`submitting`,rating:t}}});try{await rt(i,this.sessionToken,{messageId:e,rating:t,correction:n,category:r}),this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`submitted`,rating:t}}})}catch(n){console.error(`[whoo-aiden-widget] feedback submission failed:`,n),this.setState({messageFeedback:{...this.state.messageFeedback,[e]:{status:`error`,rating:t}}})}}},vt=`:host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:20px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:var(--whoo-widget-color,#4f46e5);width:56px;height:56px;color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{display:block}.whoo-widget-launcher-icon-image{object-fit:cover;border-radius:50%;width:32px;height:32px}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:88px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:#fff;border-radius:12px;flex-direction:column;width:360px;max-width:calc(100vw - 40px);height:480px;max-height:calc(100vh - 108px);display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-header{border-bottom:1px solid #e5e5e5;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;padding:8px 8px 8px 16px;display:flex}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);text-overflow:ellipsis;white-space:nowrap;margin:0;font-size:15px;font-weight:600;overflow:hidden}.whoo-widget-header-actions{flex-shrink:0;align-items:center;gap:4px;display:flex}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:#f3f4f6}.whoo-widget-message-list{flex:1;min-height:100px;padding:12px;overflow-y:auto}.whoo-widget-empty-state-image{object-fit:contain;max-width:min(160px,100%);height:auto;max-height:160px;margin:8px auto 16px;display:block}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.whoo-widget-message{white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-left:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{color:var(--whoo-widget-ink,#111);background:#f0f0f0}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:#6b7280;border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{color:#991b1b;background:#fee2e2;padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid #e5e5e5;gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid #6b7280;border-radius:6px;flex:1;padding:8px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.whoo-widget-composer-send:disabled,.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:#4b5563;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:#111;background:#0000000f}.whoo-widget-feedback-buttons button:disabled{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;resize:vertical;border:1px solid #6b7280;border-radius:6px;width:100%;padding:6px;font-size:12px}.whoo-widget-feedback-select{border:1px solid #6b7280;border-radius:6px;min-height:24px;padding:4px;font-size:12px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{color:#111;cursor:pointer;background:#fff;border:1px solid #6b7280;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:#6b7280;margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:#991b1b;font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline-offset:2px;outline:2px solid #111827;box-shadow:0 0 0 4px #fff}`,yt=/^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;function bt(e){if(yt.test(e.trim()))return null;let t=document.createElement(`div`);if(t.style.color=e,t.style.color===``)return null;let n=document.createElement(`div`);n.attachShadow({mode:`open`}).appendChild(t),document.body.appendChild(n);let r=getComputedStyle(t).color;n.remove();let i=r.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/);if(!i)return null;let a=i[4]===void 0?1:Number(i[4]);return{rgb:[Number(i[1]),Number(i[2]),Number(i[3])].map(e=>Math.round(e*a+255*(1-a))),translucent:a<1}}function xt(e){return bt(e)?.rgb??null}function X([e,t,n]){let r=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function St(e,t){let n=Math.max(e,t),r=Math.min(e,t);return(n+.05)/(r+.05)}function Ct(e){let t=xt(e);if(!t)return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`),`#ffffff`;let n=X(t);return St(n,X([0,0,0]))>=St(n,X([255,255,255]))?`#000000`:`#ffffff`}var Z=`#4f46e5`,wt=`#ffffff`,Tt=`#f0f0f0`,Et=4.5;function Dt([e,t,n]){return`#${[e,t,n].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function Q(e,t=wt){let n=xt(e),r=xt(t);if(!n||!r)return Z;let i=X(r),a=e=>St(X(e),i)>=Et;if(a(n))return Dt(n);for(let e=.99;e>0;e-=.01){let t=n.map(t=>Math.round(t*e));if(a(t))return Dt(t)}return`#000000`}var Ot=`#111111`,kt=`#0000ee`;function $(e){if(!e)return null;let t=bt(e);return t?Dt(t.rgb):null}function At({color:e,inkColor:t,accentColor:n}){let r=$(e),i=r??Z,a=Q(i),o=$(t),s=o?Q(o,Tt):Ot,c=$(n),l=c?Q(c,Tt):kt;return{primary:i,textOnPrimary:Ct(i),primaryAsText:a,ink:s,link:l,adjusted:{primary:r!==null&&a!==i,ink:o!==null&&s!==o,link:c!==null&&l!==c}}}function jt(e,t,n=Z){let r=t;$(t)===null&&(console.warn(`[whoo-aiden-widget] Could not use "${t}" as the theme color; falling back to "${n}".`),r=n);let i=At({color:r});e.style.setProperty(`--whoo-widget-color`,i.primary),e.style.setProperty(`--whoo-widget-text-on-color`,i.textOnPrimary),e.style.setProperty(`--whoo-widget-color-text`,i.primaryAsText)}function Mt(e,{inkColor:t,accentColor:n}){let r=At({inkColor:t,accentColor:n});e.style.setProperty(`--whoo-widget-ink`,r.ink),e.style.setProperty(`--whoo-widget-link-color`,r.link)}function Nt(e,t){e&&$(e)===null&&console.warn(`[whoo-aiden-widget] Could not use "${e}" as the ${t}; using the default.`)}function Pt(e,t){jt(e,t.color??Z),Nt(t.inkColor,`ink color`),Nt(t.accentColor,`accent color`),Mt(e,{inkColor:t.inkColor,accentColor:t.accentColor});let n=t.position===`bottom-left`;e.style.setProperty(`--whoo-widget-inset-left`,n?`20px`:`auto`),e.style.setProperty(`--whoo-widget-inset-right`,n?`auto`:`20px`)}function Ft(e){let t=document.createElement(`div`);t.id=`whoo-aiden-widget-host`;let n=t.attachShadow({mode:`open`}),r=document.createElement(`style`);r.textContent=vt,n.appendChild(r);let i=document.createElement(`div`);n.appendChild(i),Pt(i,e);let a=new _t(e),o=null,s=``;return a.subscribe(t=>{t.primaryColor&&t.primaryColor!==o&&(o=t.primaryColor,jt(i,t.primaryColor,e.color));let n=`${t.inkColor}|${t.accentColor}`;(t.inkColor||t.accentColor)&&n!==s&&(s=n,Mt(i,{inkColor:$(t.inkColor)?t.inkColor:e.inkColor,accentColor:$(t.accentColor)?t.accentColor:e.accentColor}))}),de(U($e,{controller:a}),i),a.init(),document.body.appendChild(t),{unmount(){de(null,i),t.remove()}}}function It(e){return t(e),Ft(e)}return e.init=It,e})({});
package/dist/widget.js CHANGED
@@ -253,21 +253,21 @@ t = g.slice, n = { __e: function(e, t, n, r) {
253
253
  }, k.__r = 0, c = Math.random().toString(8), l = "__d" + c, u = "__a" + c, d = /(PointerCapture)$|Capture$/i, f = 0, p = te(!1), m = te(!0);
254
254
  //#endregion
255
255
  //#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/hooks/dist/hooks.module.js
256
- var F, I, de, fe, L = 0, pe = [], R = n, me = R.__b, he = R.__r, ge = R.diffed, _e = R.__c, ve = R.unmount, ye = R.__;
257
- function be(e, t) {
258
- R.__h && R.__h(I, e, L || t), L = 0;
256
+ var F, I, L, de, R = 0, fe = [], z = n, pe = z.__b, me = z.__r, he = z.diffed, ge = z.__c, _e = z.unmount, ve = z.__;
257
+ function ye(e, t) {
258
+ z.__h && z.__h(I, e, R || t), R = 0;
259
259
  var n = I.__H || (I.__H = {
260
260
  __: [],
261
261
  __h: []
262
262
  });
263
263
  return e >= n.__.length && n.__.push({}), n.__[e];
264
264
  }
265
- function z(e) {
266
- return L = 1, xe(Oe, e);
265
+ function B(e) {
266
+ return R = 1, be(De, e);
267
267
  }
268
- function xe(e, t, n) {
269
- var r = be(F++, 2);
270
- if (r.t = e, !r.__c && (r.__ = [n ? n(t) : Oe(void 0, t), function(e) {
268
+ function be(e, t, n) {
269
+ var r = ye(F++, 2);
270
+ if (r.t = e, !r.__c && (r.__ = [n ? n(t) : De(void 0, t), function(e) {
271
271
  var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
272
272
  t !== n && (r.__N = [n, r.__[1]], r.__c.setState({}));
273
273
  }], r.__c = I, !I.__f)) {
@@ -298,96 +298,96 @@ function xe(e, t, n) {
298
298
  }
299
299
  return r.__N || r.__;
300
300
  }
301
- function B(e, t) {
302
- var n = be(F++, 3);
303
- !R.__s && De(n.__H, t) && (n.__ = e, n.u = t, I.__H.__h.push(n));
301
+ function V(e, t) {
302
+ var n = ye(F++, 3);
303
+ !z.__s && Ee(n.__H, t) && (n.__ = e, n.u = t, I.__H.__h.push(n));
304
304
  }
305
- function V(e) {
306
- return L = 5, Se(function() {
305
+ function H(e) {
306
+ return R = 5, xe(function() {
307
307
  return { current: e };
308
308
  }, []);
309
309
  }
310
- function Se(e, t) {
311
- var n = be(F++, 7);
312
- return De(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
310
+ function xe(e, t) {
311
+ var n = ye(F++, 7);
312
+ return Ee(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
313
313
  }
314
- function Ce() {
315
- for (var e; e = pe.shift();) {
314
+ function Se() {
315
+ for (var e; e = fe.shift();) {
316
316
  var t = e.__H;
317
317
  if (e.__P && t) try {
318
- t.__h.some(H), t.__h.some(Ee), t.__h = [];
318
+ t.__h.some(U), t.__h.some(Te), t.__h = [];
319
319
  } catch (n) {
320
- t.__h = [], R.__e(n, e.__v);
320
+ t.__h = [], z.__e(n, e.__v);
321
321
  }
322
322
  }
323
323
  }
324
- R.__b = function(e) {
325
- I = null, me && me(e);
326
- }, R.__ = function(e, t) {
327
- e && t.__k && t.__k.__m && (e.__m = t.__k.__m), ye && ye(e, t);
328
- }, R.__r = function(e) {
329
- he && he(e), F = 0;
324
+ z.__b = function(e) {
325
+ I = null, pe && pe(e);
326
+ }, z.__ = function(e, t) {
327
+ e && t.__k && t.__k.__m && (e.__m = t.__k.__m), ve && ve(e, t);
328
+ }, z.__r = function(e) {
329
+ me && me(e), F = 0;
330
330
  var t = (I = e.__c).__H;
331
- t && (de === I ? (t.__h = [], I.__h = [], t.__.some(function(e) {
331
+ t && (L === I ? (t.__h = [], I.__h = [], t.__.some(function(e) {
332
332
  e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
333
- })) : (t.__h.some(H), t.__h.some(Ee), t.__h = [], F = 0)), de = I;
334
- }, R.diffed = function(e) {
335
- ge && ge(e);
333
+ })) : (t.__h.some(U), t.__h.some(Te), t.__h = [], F = 0)), L = I;
334
+ }, z.diffed = function(e) {
335
+ he && he(e);
336
336
  var t = e.__c;
337
- t && t.__H && (t.__H.__h.length && (pe.push(t) !== 1 && fe === R.requestAnimationFrame || ((fe = R.requestAnimationFrame) || Te)(Ce)), t.__H.__.some(function(e) {
337
+ t && t.__H && (t.__H.__h.length && (fe.push(t) !== 1 && de === z.requestAnimationFrame || ((de = z.requestAnimationFrame) || we)(Se)), t.__H.__.some(function(e) {
338
338
  e.u &&= (e.__H = e.u, void 0);
339
- })), de = I = null;
340
- }, R.__c = function(e, t) {
339
+ })), L = I = null;
340
+ }, z.__c = function(e, t) {
341
341
  t.some(function(e) {
342
342
  try {
343
- e.__h.some(H), e.__h = e.__h.filter(function(e) {
344
- return !e.__ || Ee(e);
343
+ e.__h.some(U), e.__h = e.__h.filter(function(e) {
344
+ return !e.__ || Te(e);
345
345
  });
346
346
  } catch (n) {
347
347
  t.some(function(e) {
348
348
  e.__h &&= [];
349
- }), t = [], R.__e(n, e.__v);
349
+ }), t = [], z.__e(n, e.__v);
350
350
  }
351
- }), _e && _e(e, t);
352
- }, R.unmount = function(e) {
353
- ve && ve(e);
351
+ }), ge && ge(e, t);
352
+ }, z.unmount = function(e) {
353
+ _e && _e(e);
354
354
  var t, n = e.__c;
355
355
  n && n.__H && (n.__H.__.some(function(e) {
356
356
  try {
357
- H(e);
357
+ U(e);
358
358
  } catch (e) {
359
359
  t = e;
360
360
  }
361
- }), n.__H = void 0, t && R.__e(t, n.__v));
361
+ }), n.__H = void 0, t && z.__e(t, n.__v));
362
362
  };
363
- var we = typeof requestAnimationFrame == "function";
364
- function Te(e) {
363
+ var Ce = typeof requestAnimationFrame == "function";
364
+ function we(e) {
365
365
  var t, n = function() {
366
- clearTimeout(r), we && cancelAnimationFrame(t), setTimeout(e);
366
+ clearTimeout(r), Ce && cancelAnimationFrame(t), setTimeout(e);
367
367
  }, r = setTimeout(n, 35);
368
- we && (t = requestAnimationFrame(n));
368
+ Ce && (t = requestAnimationFrame(n));
369
369
  }
370
- function H(e) {
370
+ function U(e) {
371
371
  var t = I, n = e.__c;
372
372
  typeof n == "function" && (e.__c = void 0, n()), I = t;
373
373
  }
374
- function Ee(e) {
374
+ function Te(e) {
375
375
  var t = I;
376
376
  e.__c = e.__(), I = t;
377
377
  }
378
- function De(e, t) {
378
+ function Ee(e, t) {
379
379
  return !e || e.length !== t.length || t.some(function(t, n) {
380
380
  return t !== e[n];
381
381
  });
382
382
  }
383
- function Oe(e, t) {
383
+ function De(e, t) {
384
384
  return typeof t == "function" ? t(e) : t;
385
385
  }
386
386
  //#endregion
387
387
  //#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
388
- var ke = 0;
388
+ var Oe = 0;
389
389
  Array.isArray;
390
- function U(e, t, r, i, a, o) {
390
+ function W(e, t, r, i, a, o) {
391
391
  t ||= {};
392
392
  var s, c, l = t;
393
393
  if ("ref" in l) for (c in l = {}, t) c == "ref" ? s = t[c] : l[c] = t[c];
@@ -402,7 +402,7 @@ function U(e, t, r, i, a, o) {
402
402
  __e: null,
403
403
  __c: null,
404
404
  constructor: void 0,
405
- __v: --ke,
405
+ __v: --Oe,
406
406
  __i: -1,
407
407
  __u: 0,
408
408
  __source: a,
@@ -413,8 +413,8 @@ function U(e, t, r, i, a, o) {
413
413
  }
414
414
  //#endregion
415
415
  //#region src/components/icons.tsx
416
- function W({ name: e, size: t, children: n }) {
417
- return /* @__PURE__ */ U("svg", {
416
+ function G({ name: e, size: t, children: n }) {
417
+ return /* @__PURE__ */ W("svg", {
418
418
  "data-icon": e,
419
419
  "aria-hidden": "true",
420
420
  focusable: "false",
@@ -429,59 +429,59 @@ function W({ name: e, size: t, children: n }) {
429
429
  children: n
430
430
  });
431
431
  }
432
- function Ae({ size: e = 26 }) {
433
- return /* @__PURE__ */ U(W, {
432
+ function ke({ size: e = 26 }) {
433
+ return /* @__PURE__ */ W(G, {
434
434
  name: "chat",
435
435
  size: e,
436
- children: [/* @__PURE__ */ U("path", { d: "M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 4v-4h0A1.5 1.5 0 0 1 4 14.5z" }), /* @__PURE__ */ U("path", {
436
+ children: [/* @__PURE__ */ W("path", { d: "M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 4v-4h0A1.5 1.5 0 0 1 4 14.5z" }), /* @__PURE__ */ W("path", {
437
437
  d: "M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01",
438
438
  "stroke-width": "2.5"
439
439
  })]
440
440
  });
441
441
  }
442
- function je({ size: e = 26 }) {
443
- return /* @__PURE__ */ U(W, {
442
+ function Ae({ size: e = 26 }) {
443
+ return /* @__PURE__ */ W(G, {
444
444
  name: "chevron-down",
445
445
  size: e,
446
- children: /* @__PURE__ */ U("path", { d: "M6 9l6 6 6-6" })
446
+ children: /* @__PURE__ */ W("path", { d: "M6 9l6 6 6-6" })
447
447
  });
448
448
  }
449
- function Me({ size: e = 18 }) {
450
- return /* @__PURE__ */ U(W, {
449
+ function je({ size: e = 18 }) {
450
+ return /* @__PURE__ */ W(G, {
451
451
  name: "close",
452
452
  size: e,
453
- children: /* @__PURE__ */ U("path", { d: "M6 6l12 12M18 6L6 18" })
453
+ children: /* @__PURE__ */ W("path", { d: "M6 6l12 12M18 6L6 18" })
454
454
  });
455
455
  }
456
- var Ne = "M7 11v9M7 11l3.5-7.2A1.8 1.8 0 0 1 14 4.6V9h4.6a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 17.4 20H7M7 11H4.5A1.5 1.5 0 0 0 3 12.5v6A1.5 1.5 0 0 0 4.5 20H7";
457
- function Pe({ size: e = 16 }) {
458
- return /* @__PURE__ */ U(W, {
456
+ var Me = "M7 11v9M7 11l3.5-7.2A1.8 1.8 0 0 1 14 4.6V9h4.6a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 17.4 20H7M7 11H4.5A1.5 1.5 0 0 0 3 12.5v6A1.5 1.5 0 0 0 4.5 20H7";
457
+ function Ne({ size: e = 16 }) {
458
+ return /* @__PURE__ */ W(G, {
459
459
  name: "thumb-up",
460
460
  size: e,
461
- children: /* @__PURE__ */ U("path", { d: Ne })
461
+ children: /* @__PURE__ */ W("path", { d: Me })
462
462
  });
463
463
  }
464
- function Fe({ size: e = 16 }) {
465
- return /* @__PURE__ */ U(W, {
464
+ function Pe({ size: e = 16 }) {
465
+ return /* @__PURE__ */ W(G, {
466
466
  name: "thumb-down",
467
467
  size: e,
468
- children: /* @__PURE__ */ U("path", {
469
- d: Ne,
468
+ children: /* @__PURE__ */ W("path", {
469
+ d: Me,
470
470
  transform: "matrix(1 0 0 -1 0 24)"
471
471
  })
472
472
  });
473
473
  }
474
474
  //#endregion
475
475
  //#region src/components/Launcher.tsx
476
- function Ie({ isOpen: e, onClick: t, iconUrl: n, buttonRef: r }) {
477
- let [i, a] = z("loading"), o = n !== void 0 && i !== "failed", s = o && !e && i === "loaded";
478
- return /* @__PURE__ */ U("button", {
476
+ function Fe({ isOpen: e, onClick: t, iconUrl: n, buttonRef: r }) {
477
+ let [i, a] = B("loading"), o = n !== void 0 && i !== "failed", s = o && !e && i === "loaded";
478
+ return /* @__PURE__ */ W("button", {
479
479
  type: "button",
480
480
  class: "whoo-widget-launcher",
481
481
  onClick: t,
482
482
  "aria-label": e ? "Close chat" : "Open chat",
483
483
  ref: r,
484
- children: [e ? /* @__PURE__ */ U(je, {}) : s ? null : /* @__PURE__ */ U(Ae, {}), o ? /* @__PURE__ */ U("img", {
484
+ children: [e ? /* @__PURE__ */ W(Ae, {}) : s ? null : /* @__PURE__ */ W(ke, {}), o ? /* @__PURE__ */ W("img", {
485
485
  class: "whoo-widget-launcher-icon-image",
486
486
  src: n,
487
487
  alt: "",
@@ -494,16 +494,16 @@ function Ie({ isOpen: e, onClick: t, iconUrl: n, buttonRef: r }) {
494
494
  }
495
495
  //#endregion
496
496
  //#region src/components/Composer.tsx
497
- function Le({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
498
- return /* @__PURE__ */ U("div", {
497
+ function Ie({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
498
+ return /* @__PURE__ */ W("div", {
499
499
  class: "whoo-widget-composer",
500
500
  children: [
501
- /* @__PURE__ */ U("label", {
501
+ /* @__PURE__ */ W("label", {
502
502
  class: "whoo-widget-sr-only",
503
503
  for: "whoo-widget-composer-input",
504
504
  children: "Message"
505
505
  }),
506
- /* @__PURE__ */ U("input", {
506
+ /* @__PURE__ */ W("input", {
507
507
  id: "whoo-widget-composer-input",
508
508
  class: "whoo-widget-composer-input",
509
509
  value: e,
@@ -515,7 +515,7 @@ function Le({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
515
515
  e.key === "Enter" && n();
516
516
  }
517
517
  }),
518
- /* @__PURE__ */ U("button", {
518
+ /* @__PURE__ */ W("button", {
519
519
  type: "button",
520
520
  class: "whoo-widget-composer-send",
521
521
  onClick: n,
@@ -527,8 +527,8 @@ function Le({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
527
527
  }
528
528
  //#endregion
529
529
  //#region src/components/ErrorBanner.tsx
530
- function Re({ message: e }) {
531
- return /* @__PURE__ */ U("div", {
530
+ function Le({ message: e }) {
531
+ return /* @__PURE__ */ W("div", {
532
532
  class: "whoo-widget-error-banner",
533
533
  role: "alert",
534
534
  children: e
@@ -536,8 +536,8 @@ function Re({ message: e }) {
536
536
  }
537
537
  //#endregion
538
538
  //#region src/markdown/tokenizer.ts
539
- var G = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, K = /\*\*([^*]+)\*\*/y, q = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, J = /\*([^*]+)\*/y, ze = /https?:\/\/\S+/y, Be = /[.,;:!?)\]}>]+$/;
540
- function Ve(e) {
539
+ var K = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, q = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, J = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, Y = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, X = /[ \t]*[*+-][ \t]+/y, Re = /https?:\/\/\S+/y, ze = /[.,;:!?)\]}>]+$/;
540
+ function Be(e) {
541
541
  let t = [], n = 0, r = 0, i = (n) => {
542
542
  n > r && t.push({
543
543
  type: "text",
@@ -547,6 +547,15 @@ function Ve(e) {
547
547
  });
548
548
  };
549
549
  for (; n < e.length;) {
550
+ if ((n === 0 || e[n - 1] === "\n") && (X.lastIndex = n, X.exec(e))) {
551
+ i(n), t.push({
552
+ type: "text",
553
+ value: "• ",
554
+ start: n,
555
+ end: X.lastIndex
556
+ }), n = X.lastIndex, r = n;
557
+ continue;
558
+ }
550
559
  if (e[n] === "!" && n + 1 < e.length && e[n + 1] === "[") {
551
560
  let t = /!\[([^\]]*)\]\(([^)]*)\)/y;
552
561
  t.lastIndex = n;
@@ -557,56 +566,56 @@ function Ve(e) {
557
566
  }
558
567
  }
559
568
  if (e[n - 1] !== "!") {
560
- G.lastIndex = n;
561
- let a = G.exec(e);
569
+ K.lastIndex = n;
570
+ let a = K.exec(e);
562
571
  if (a) {
563
572
  i(n), t.push({
564
573
  type: "link",
565
574
  text: a[1],
566
575
  url: a[2],
567
576
  start: n,
568
- end: G.lastIndex
569
- }), n = G.lastIndex, r = n;
577
+ end: K.lastIndex
578
+ }), n = K.lastIndex, r = n;
570
579
  continue;
571
580
  }
572
581
  }
573
- K.lastIndex = n;
574
- let a = K.exec(e);
582
+ q.lastIndex = n;
583
+ let a = q.exec(e);
575
584
  if (a) {
576
585
  i(n), t.push({
577
586
  type: "bold",
578
587
  value: a[1],
579
588
  start: n,
580
- end: K.lastIndex
581
- }), n = K.lastIndex, r = n;
589
+ end: q.lastIndex
590
+ }), n = q.lastIndex, r = n;
582
591
  continue;
583
592
  }
584
- q.lastIndex = n;
585
- let o = q.exec(e);
593
+ J.lastIndex = n;
594
+ let o = J.exec(e);
586
595
  if (o) {
587
596
  i(n), t.push({
588
597
  type: "italic",
589
598
  value: o[1],
590
599
  start: n,
591
- end: q.lastIndex
592
- }), n = q.lastIndex, r = n;
600
+ end: J.lastIndex
601
+ }), n = J.lastIndex, r = n;
593
602
  continue;
594
603
  }
595
- J.lastIndex = n;
596
- let s = J.exec(e);
604
+ Y.lastIndex = n;
605
+ let s = Y.exec(e);
597
606
  if (s) {
598
607
  i(n), t.push({
599
608
  type: "italic",
600
609
  value: s[1],
601
610
  start: n,
602
- end: J.lastIndex
603
- }), n = J.lastIndex, r = n;
611
+ end: Y.lastIndex
612
+ }), n = Y.lastIndex, r = n;
604
613
  continue;
605
614
  }
606
- ze.lastIndex = n;
607
- let c = ze.exec(e);
615
+ Re.lastIndex = n;
616
+ let c = Re.exec(e);
608
617
  if (c) {
609
- let e = c[0].match(Be), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
618
+ let e = c[0].match(ze), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
610
619
  if (a.length > 0) {
611
620
  i(n), t.push({
612
621
  type: "link",
@@ -624,16 +633,16 @@ function Ve(e) {
624
633
  }
625
634
  //#endregion
626
635
  //#region src/markdown/render.tsx
627
- function He(e) {
628
- return Ve(e).map((e, t) => {
636
+ function Ve(e) {
637
+ return Be(e).map((e, t) => {
629
638
  switch (e.type) {
630
- case "bold": return /* @__PURE__ */ U("strong", { children: e.value }, t);
631
- case "italic": return /* @__PURE__ */ U("em", { children: e.value }, t);
632
- case "link": return /* @__PURE__ */ U("a", {
639
+ case "bold": return /* @__PURE__ */ W("strong", { children: Ve(e.value) }, t);
640
+ case "italic": return /* @__PURE__ */ W("em", { children: Ve(e.value) }, t);
641
+ case "link": return /* @__PURE__ */ W("a", {
633
642
  href: e.url,
634
643
  target: "_blank",
635
644
  rel: "noopener noreferrer",
636
- children: [e.text, /* @__PURE__ */ U("span", {
645
+ children: [e.text, /* @__PURE__ */ W("span", {
637
646
  class: "whoo-widget-sr-only",
638
647
  children: " (opens in new tab)"
639
648
  })]
@@ -644,7 +653,7 @@ function He(e) {
644
653
  }
645
654
  //#endregion
646
655
  //#region src/components/MessageFeedback.tsx
647
- var Ue = [
656
+ var He = [
648
657
  {
649
658
  value: "",
650
659
  label: "Select a reason (optional)"
@@ -666,50 +675,50 @@ var Ue = [
666
675
  label: "Other"
667
676
  }
668
677
  ];
669
- function We({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmitDetailed: i, onCancel: a }) {
670
- let [o, s] = z(""), [c, l] = z(""), u = V(e.status);
671
- if (B(() => {
678
+ function Ue({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmitDetailed: i, onCancel: a }) {
679
+ let [o, s] = B(""), [c, l] = B(""), u = H(e.status);
680
+ if (V(() => {
672
681
  let n = u.current;
673
682
  if (u.current = e.status, n === e.status) return;
674
683
  let r = t?.current;
675
684
  if (!r) return;
676
685
  let i = r.getRootNode();
677
686
  r.contains(i.activeElement) || r.focus();
678
- }, [e.status, t]), e.status === "submitted") return /* @__PURE__ */ U("div", {
687
+ }, [e.status, t]), e.status === "submitted") return /* @__PURE__ */ W("div", {
679
688
  class: "whoo-widget-feedback-submitted",
680
689
  role: "status",
681
690
  children: "Thanks for the feedback"
682
691
  });
683
- if (e.status === "expanded") return /* @__PURE__ */ U("div", {
692
+ if (e.status === "expanded") return /* @__PURE__ */ W("div", {
684
693
  class: "whoo-widget-feedback-form",
685
694
  children: [
686
- /* @__PURE__ */ U("label", { children: [/* @__PURE__ */ U("span", {
695
+ /* @__PURE__ */ W("label", { children: [/* @__PURE__ */ W("span", {
687
696
  class: "whoo-widget-sr-only",
688
697
  children: "Additional feedback"
689
- }), /* @__PURE__ */ U("textarea", {
698
+ }), /* @__PURE__ */ W("textarea", {
690
699
  class: "whoo-widget-feedback-textarea",
691
700
  value: o,
692
701
  onInput: (e) => s(e.target.value),
693
702
  placeholder: "What was wrong? (optional)"
694
703
  })] }),
695
- /* @__PURE__ */ U("select", {
704
+ /* @__PURE__ */ W("select", {
696
705
  class: "whoo-widget-feedback-select",
697
706
  "aria-label": "Feedback category",
698
707
  value: c,
699
708
  onChange: (e) => l(e.target.value),
700
- children: Ue.map((e) => /* @__PURE__ */ U("option", {
709
+ children: He.map((e) => /* @__PURE__ */ W("option", {
701
710
  value: e.value,
702
711
  children: e.label
703
712
  }, e.value))
704
713
  }),
705
- /* @__PURE__ */ U("div", {
714
+ /* @__PURE__ */ W("div", {
706
715
  class: "whoo-widget-feedback-form-buttons",
707
- children: [/* @__PURE__ */ U("button", {
716
+ children: [/* @__PURE__ */ W("button", {
708
717
  type: "button",
709
718
  class: "whoo-widget-feedback-submit",
710
719
  onClick: () => i(o, c),
711
720
  children: "Submit"
712
- }), /* @__PURE__ */ U("button", {
721
+ }), /* @__PURE__ */ W("button", {
713
722
  type: "button",
714
723
  class: "whoo-widget-feedback-cancel",
715
724
  onClick: a,
@@ -719,24 +728,24 @@ function We({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmi
719
728
  ]
720
729
  });
721
730
  let d = e.status === "submitting";
722
- return /* @__PURE__ */ U("div", {
731
+ return /* @__PURE__ */ W("div", {
723
732
  class: "whoo-widget-feedback",
724
- children: [/* @__PURE__ */ U("div", {
733
+ children: [/* @__PURE__ */ W("div", {
725
734
  class: "whoo-widget-feedback-buttons",
726
- children: [/* @__PURE__ */ U("button", {
735
+ children: [/* @__PURE__ */ W("button", {
727
736
  type: "button",
728
737
  "aria-label": "Good response",
729
738
  disabled: d,
730
739
  onClick: n,
731
- children: /* @__PURE__ */ U(Pe, {})
732
- }), /* @__PURE__ */ U("button", {
740
+ children: /* @__PURE__ */ W(Ne, {})
741
+ }), /* @__PURE__ */ W("button", {
733
742
  type: "button",
734
743
  "aria-label": "Bad response",
735
744
  disabled: d,
736
745
  onClick: r,
737
- children: /* @__PURE__ */ U(Fe, {})
746
+ children: /* @__PURE__ */ W(Pe, {})
738
747
  })]
739
- }), e.status === "error" ? /* @__PURE__ */ U("div", {
748
+ }), e.status === "error" ? /* @__PURE__ */ W("div", {
740
749
  class: "whoo-widget-feedback-error",
741
750
  role: "status",
742
751
  children: "Couldn't send feedback"
@@ -745,27 +754,27 @@ function We({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmi
745
754
  }
746
755
  //#endregion
747
756
  //#region src/components/MessageList.tsx
748
- function Ge({ isSlowResponse: e }) {
749
- return /* @__PURE__ */ U("div", {
757
+ function We({ isSlowResponse: e }) {
758
+ return /* @__PURE__ */ W("div", {
750
759
  class: "whoo-widget-pending",
751
760
  role: "status",
752
- children: [/* @__PURE__ */ U("span", {
761
+ children: [/* @__PURE__ */ W("span", {
753
762
  class: "whoo-widget-typing",
754
763
  "aria-hidden": "true",
755
764
  children: [
756
- /* @__PURE__ */ U("span", {}),
757
- /* @__PURE__ */ U("span", {}),
758
- /* @__PURE__ */ U("span", {})
765
+ /* @__PURE__ */ W("span", {}),
766
+ /* @__PURE__ */ W("span", {}),
767
+ /* @__PURE__ */ W("span", {})
759
768
  ]
760
- }), e ? /* @__PURE__ */ U("span", {
769
+ }), e ? /* @__PURE__ */ W("span", {
761
770
  class: "whoo-widget-pending-text",
762
771
  children: "Looking that up for you…"
763
772
  }) : null]
764
773
  });
765
774
  }
766
- function Ke({ url: e, alt: t }) {
767
- let [n, r] = z(!1);
768
- return n ? null : /* @__PURE__ */ U("img", {
775
+ function Ge({ url: e, alt: t }) {
776
+ let [n, r] = B(!1);
777
+ return n ? null : /* @__PURE__ */ W("img", {
769
778
  class: "whoo-widget-empty-state-image",
770
779
  src: e,
771
780
  alt: t,
@@ -773,13 +782,13 @@ function Ke({ url: e, alt: t }) {
773
782
  onError: () => r(!0)
774
783
  });
775
784
  }
776
- function qe({ message: e, feedbackState: t, pending: n, isSlowResponse: r, onThumbsUp: i, onThumbsDown: a, onSubmitDetailed: o, onCancelFeedback: s }) {
777
- let c = V(null), l = e.id;
778
- return /* @__PURE__ */ U("div", {
785
+ function Ke({ message: e, feedbackState: t, pending: n, isSlowResponse: r, onThumbsUp: i, onThumbsDown: a, onSubmitDetailed: o, onCancelFeedback: s }) {
786
+ let c = H(null), l = e.id;
787
+ return /* @__PURE__ */ W("div", {
779
788
  ref: c,
780
789
  tabIndex: -1,
781
790
  class: `whoo-widget-message whoo-widget-message--${e.role}`,
782
- children: [n ? /* @__PURE__ */ U(Ge, { isSlowResponse: r }) : He(e.content), e.role === "assistant" && l ? /* @__PURE__ */ U(We, {
791
+ children: [n ? /* @__PURE__ */ W(We, { isSlowResponse: r }) : Ve(e.content), e.role === "assistant" && l ? /* @__PURE__ */ W(Ue, {
783
792
  state: t,
784
793
  containerRef: c,
785
794
  onThumbsUp: () => i(l),
@@ -789,15 +798,15 @@ function qe({ message: e, feedbackState: t, pending: n, isSlowResponse: r, onThu
789
798
  }) : null]
790
799
  });
791
800
  }
792
- function Je({ messages: e, messageFeedback: t, lastCompletedMessageText: n, emptyStateImage: r, isStreaming: i = !1, isSlowResponse: a = !1, onThumbsUp: o, onThumbsDown: s, onSubmitDetailed: c, onCancelFeedback: l }) {
793
- let u = V(null);
794
- return B(() => {
801
+ function qe({ messages: e, messageFeedback: t, lastCompletedMessageText: n, emptyStateImage: r, isStreaming: i = !1, isSlowResponse: a = !1, onThumbsUp: o, onThumbsDown: s, onSubmitDetailed: c, onCancelFeedback: l }) {
802
+ let u = H(null);
803
+ return V(() => {
795
804
  let e = u.current;
796
805
  e && (e.scrollTop = e.scrollHeight);
797
- }, [e, a]), /* @__PURE__ */ U(C, { children: [/* @__PURE__ */ U("div", {
806
+ }, [e, a]), /* @__PURE__ */ W(C, { children: [/* @__PURE__ */ W("div", {
798
807
  class: "whoo-widget-message-list",
799
808
  ref: u,
800
- children: [r ? /* @__PURE__ */ U(Ke, { ...r }) : null, e.map((n, r) => /* @__PURE__ */ U(qe, {
809
+ children: [r ? /* @__PURE__ */ W(Ge, { ...r }) : null, e.map((n, r) => /* @__PURE__ */ W(Ke, {
801
810
  message: n,
802
811
  feedbackState: n.id ? t[n.id] ?? { status: "idle" } : { status: "idle" },
803
812
  pending: i && r === e.length - 1 && n.role === "assistant" && n.content === "",
@@ -807,7 +816,7 @@ function Je({ messages: e, messageFeedback: t, lastCompletedMessageText: n, empt
807
816
  onSubmitDetailed: c,
808
817
  onCancelFeedback: l
809
818
  }, n.id ?? r))]
810
- }), /* @__PURE__ */ U("div", {
819
+ }), /* @__PURE__ */ W("div", {
811
820
  class: "whoo-widget-sr-only",
812
821
  "aria-live": "polite",
813
822
  "aria-atomic": "true",
@@ -816,16 +825,16 @@ function Je({ messages: e, messageFeedback: t, lastCompletedMessageText: n, empt
816
825
  }
817
826
  //#endregion
818
827
  //#region src/components/Panel.tsx
819
- var Ye = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
820
- function Xe(e) {
821
- return Array.from(e.querySelectorAll(Ye)).filter((e) => {
828
+ var Je = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
829
+ function Ye(e) {
830
+ return Array.from(e.querySelectorAll(Je)).filter((e) => {
822
831
  let t = getComputedStyle(e);
823
832
  return t.display !== "none" && t.visibility !== "hidden";
824
833
  });
825
834
  }
826
- function Ze({ state: e, controller: t, greeting: n }) {
827
- let r = V(null), i = V(null);
828
- B(() => {
835
+ function Xe({ state: e, controller: t, greeting: n }) {
836
+ let r = H(null), i = H(null);
837
+ V(() => {
829
838
  i.current?.focus();
830
839
  }, []);
831
840
  let a = (e) => {
@@ -836,7 +845,7 @@ function Ze({ state: e, controller: t, greeting: n }) {
836
845
  if (e.key !== "Tab") return;
837
846
  let n = r.current;
838
847
  if (!n) return;
839
- let i = Xe(n);
848
+ let i = Ye(n);
840
849
  if (i.length === 0) return;
841
850
  let a = i[0], o = i[i.length - 1], s = n.getRootNode().activeElement;
842
851
  if (!n.contains(s)) {
@@ -855,7 +864,7 @@ function Ze({ state: e, controller: t, greeting: n }) {
855
864
  url: l,
856
865
  alt: t.emptyStateImageAlt
857
866
  } : void 0;
858
- return /* @__PURE__ */ U("div", {
867
+ return /* @__PURE__ */ W("div", {
859
868
  class: "whoo-widget-panel",
860
869
  role: "dialog",
861
870
  "aria-modal": "true",
@@ -863,28 +872,28 @@ function Ze({ state: e, controller: t, greeting: n }) {
863
872
  ref: r,
864
873
  onKeyDown: a,
865
874
  children: [
866
- /* @__PURE__ */ U("div", {
875
+ /* @__PURE__ */ W("div", {
867
876
  class: "whoo-widget-header",
868
- children: [/* @__PURE__ */ U("h2", {
877
+ children: [/* @__PURE__ */ W("h2", {
869
878
  class: "whoo-widget-header-title",
870
879
  children: s
871
- }), /* @__PURE__ */ U("div", {
880
+ }), /* @__PURE__ */ W("div", {
872
881
  class: "whoo-widget-header-actions",
873
- children: [e.messages.length > 0 && /* @__PURE__ */ U("button", {
882
+ children: [e.messages.length > 0 && /* @__PURE__ */ W("button", {
874
883
  type: "button",
875
884
  class: "whoo-widget-header-reset",
876
885
  onClick: () => t.resetConversation(),
877
886
  children: "New conversation"
878
- }), /* @__PURE__ */ U("button", {
887
+ }), /* @__PURE__ */ W("button", {
879
888
  type: "button",
880
889
  class: "whoo-widget-header-close",
881
890
  "aria-label": "Close chat",
882
891
  onClick: () => t.close(),
883
- children: /* @__PURE__ */ U(Me, {})
892
+ children: /* @__PURE__ */ W(je, {})
884
893
  })]
885
894
  })]
886
895
  }),
887
- /* @__PURE__ */ U(Je, {
896
+ /* @__PURE__ */ W(qe, {
888
897
  messages: c,
889
898
  messageFeedback: e.messageFeedback,
890
899
  lastCompletedMessageText: e.lastCompletedMessageText,
@@ -896,8 +905,8 @@ function Ze({ state: e, controller: t, greeting: n }) {
896
905
  onSubmitDetailed: (e, n, r) => t.submitFeedback(e, "down", n || void 0, r || void 0),
897
906
  onCancelFeedback: (e) => t.cancelFeedback(e)
898
907
  }),
899
- e.runtimeError && /* @__PURE__ */ U(Re, { message: e.runtimeError }),
900
- /* @__PURE__ */ U(Le, {
908
+ e.runtimeError && /* @__PURE__ */ W(Le, { message: e.runtimeError }),
909
+ /* @__PURE__ */ W(Ie, {
901
910
  value: e.draft,
902
911
  onChange: (e) => t.setDraft(e),
903
912
  onSend: o,
@@ -909,16 +918,16 @@ function Ze({ state: e, controller: t, greeting: n }) {
909
918
  }
910
919
  //#endregion
911
920
  //#region src/components/App.tsx
912
- function Qe({ controller: e }) {
913
- let [t, n] = z(e.getState()), r = V(null), i = V(t.isOpen);
914
- return B(() => (n(e.getState()), e.subscribe(n)), [e]), B(() => {
921
+ function Ze({ controller: e }) {
922
+ let [t, n] = B(e.getState()), r = H(null), i = H(t.isOpen);
923
+ return V(() => (n(e.getState()), e.subscribe(n)), [e]), V(() => {
915
924
  i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
916
- }, [t.isOpen]), t.initError ? null : /* @__PURE__ */ U(C, { children: [/* @__PURE__ */ U(Ie, {
925
+ }, [t.isOpen]), t.initError ? null : /* @__PURE__ */ W(C, { children: [/* @__PURE__ */ W(Fe, {
917
926
  isOpen: t.isOpen,
918
927
  onClick: () => t.isOpen ? e.close() : e.open(),
919
928
  iconUrl: e.launcherIconUrl,
920
929
  buttonRef: r
921
- }), t.isOpen && /* @__PURE__ */ U(Ze, {
930
+ }), t.isOpen && /* @__PURE__ */ W(Xe, {
922
931
  state: t,
923
932
  controller: e,
924
933
  greeting: e.config.greeting
@@ -926,34 +935,34 @@ function Qe({ controller: e }) {
926
935
  }
927
936
  //#endregion
928
937
  //#region src/api/client.ts
929
- var $e = class extends Error {
938
+ var Qe = class extends Error {
930
939
  status;
931
940
  constructor(e, t) {
932
941
  super(e), this.name = "WidgetApiError", this.status = t;
933
942
  }
934
943
  };
935
- function et(e) {
944
+ function $e(e) {
936
945
  if (typeof e != "string") return null;
937
946
  let t = e.trim();
938
947
  return t === "" ? null : t;
939
948
  }
940
- async function tt(e, t) {
949
+ async function et(e, t) {
941
950
  let n = await fetch(`${e}/api/v1/widget/session`, {
942
951
  method: "POST",
943
952
  headers: { "Content-Type": "application/json" },
944
953
  body: JSON.stringify({ publishable_key: t })
945
954
  });
946
- if (!n.ok) throw new $e(`Failed to create widget session (${n.status})`, n.status);
955
+ if (!n.ok) throw new Qe(`Failed to create widget session (${n.status})`, n.status);
947
956
  let r = await n.json();
948
957
  return {
949
958
  token: r.token,
950
959
  primaryColor: r.primary_color ?? null,
951
- name: et(r.name),
952
- accentColor: et(r.accent_color),
953
- inkColor: et(r.ink_color)
960
+ name: $e(r.name),
961
+ accentColor: $e(r.accent_color),
962
+ inkColor: $e(r.ink_color)
954
963
  };
955
964
  }
956
- async function nt(e, t, n) {
965
+ async function tt(e, t, n) {
957
966
  let r = await fetch(`${e}/api/v1/widget/feedback`, {
958
967
  method: "POST",
959
968
  headers: {
@@ -967,11 +976,11 @@ async function nt(e, t, n) {
967
976
  category: n.category ?? null
968
977
  })
969
978
  });
970
- if (!r.ok) throw new $e(`Feedback submission failed (${r.status})`, r.status);
979
+ if (!r.ok) throw new Qe(`Feedback submission failed (${r.status})`, r.status);
971
980
  }
972
981
  //#endregion
973
982
  //#region src/api/sse.ts
974
- async function* rt(e, t, n, r, i) {
983
+ async function* nt(e, t, n, r, i) {
975
984
  let a = await fetch(`${e}/api/v1/widget/chat`, {
976
985
  method: "POST",
977
986
  headers: {
@@ -984,7 +993,7 @@ async function* rt(e, t, n, r, i) {
984
993
  }),
985
994
  signal: i
986
995
  });
987
- if (!a.ok || !a.body) throw new $e(`Chat request failed (${a.status})`, a.status);
996
+ if (!a.ok || !a.body) throw new Qe(`Chat request failed (${a.status})`, a.status);
988
997
  let o = a.body.getReader(), s = new TextDecoder(), c = "";
989
998
  for (;;) {
990
999
  let { done: e, value: t } = await o.read();
@@ -995,11 +1004,11 @@ async function* rt(e, t, n, r, i) {
995
1004
  let e = c.slice(0, n);
996
1005
  c = c.slice(n + 2);
997
1006
  let t = e.split("\n").find((e) => e.startsWith("data: "));
998
- t && (yield it(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
1007
+ t && (yield rt(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
999
1008
  }
1000
1009
  }
1001
1010
  }
1002
- function it(e) {
1011
+ function rt(e) {
1003
1012
  return typeof e.error == "string" ? {
1004
1013
  type: "error",
1005
1014
  error: e.error,
@@ -1022,7 +1031,7 @@ function it(e) {
1022
1031
  }
1023
1032
  //#endregion
1024
1033
  //#region src/imageUrl.ts
1025
- function at(e, t) {
1034
+ function it(e, t) {
1026
1035
  if (e != null && e !== "") {
1027
1036
  if (typeof e == "string") try {
1028
1037
  let t = new URL(e);
@@ -1033,16 +1042,16 @@ function at(e, t) {
1033
1042
  }
1034
1043
  //#endregion
1035
1044
  //#region src/markdown/reveal.ts
1036
- var ot = 40, st = 120;
1037
- function ct(e) {
1045
+ var at = 40, ot = 120;
1046
+ function st(e) {
1038
1047
  let t = [];
1039
- for (let n of Ve(e)) if (n.type === "text") {
1048
+ for (let n of Be(e)) if (n.type === "text") {
1040
1049
  let e = n.value.split(/(\s+)/), r = n.start;
1041
1050
  for (let n of e) r += n.length, n.trim().length > 0 && t.push(r);
1042
1051
  } else t.push(n.end);
1043
1052
  return t;
1044
1053
  }
1045
- function lt(e) {
1054
+ function ct(e) {
1046
1055
  let t = null;
1047
1056
  return e?.addEventListener("abort", () => {
1048
1057
  t?.();
@@ -1057,31 +1066,31 @@ function lt(e) {
1057
1066
  });
1058
1067
  };
1059
1068
  }
1060
- async function ut(e, t, n) {
1061
- let r = n?.wordIntervalMs ?? ot, i = n?.tokenIntervalMs ?? st, a = n?.signal, o = Ve(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = lt(a), l = "";
1062
- for (let n of ct(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
1069
+ async function lt(e, t, n) {
1070
+ let r = n?.wordIntervalMs ?? at, i = n?.tokenIntervalMs ?? ot, a = n?.signal, o = Be(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = ct(a), l = "";
1071
+ for (let n of st(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
1063
1072
  l !== e && t(e);
1064
1073
  }
1065
1074
  //#endregion
1066
1075
  //#region src/storage.ts
1067
- function Y(e) {
1076
+ function ut(e) {
1068
1077
  return `whoo-aiden-widget:conversation:${e}`;
1069
1078
  }
1070
1079
  function dt(e) {
1071
1080
  try {
1072
- return window.sessionStorage.getItem(Y(e));
1081
+ return window.sessionStorage.getItem(ut(e));
1073
1082
  } catch {
1074
1083
  return null;
1075
1084
  }
1076
1085
  }
1077
1086
  function ft(e, t) {
1078
1087
  try {
1079
- window.sessionStorage.setItem(Y(e), t);
1088
+ window.sessionStorage.setItem(ut(e), t);
1080
1089
  } catch {}
1081
1090
  }
1082
1091
  function pt(e) {
1083
1092
  try {
1084
- window.sessionStorage.removeItem(Y(e));
1093
+ window.sessionStorage.removeItem(ut(e));
1085
1094
  } catch {}
1086
1095
  }
1087
1096
  //#endregion
@@ -1100,7 +1109,7 @@ var mt = 8e3, ht = class {
1100
1109
  emptyStateImageUrl;
1101
1110
  emptyStateImageAlt;
1102
1111
  constructor(e) {
1103
- this.config = e, this.launcherIconUrl = at(e.launcherIconUrl, "launcherIconUrl"), this.emptyStateImageUrl = at(e.emptyStateImageUrl, "emptyStateImageUrl"), this.emptyStateImageAlt = typeof e.emptyStateImageAlt == "string" ? e.emptyStateImageAlt.trim() : "", this.storageIdentifier = e.publishableKey ?? "session-token-mode", this.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
1112
+ this.config = e, this.launcherIconUrl = it(e.launcherIconUrl, "launcherIconUrl"), this.emptyStateImageUrl = it(e.emptyStateImageUrl, "emptyStateImageUrl"), this.emptyStateImageAlt = typeof e.emptyStateImageAlt == "string" ? e.emptyStateImageAlt.trim() : "", this.storageIdentifier = e.publishableKey ?? "session-token-mode", this.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
1104
1113
  isOpen: !1,
1105
1114
  messages: [],
1106
1115
  isStreaming: !1,
@@ -1137,7 +1146,7 @@ var mt = 8e3, ht = class {
1137
1146
  try {
1138
1147
  if (this.config.sessionToken) this.sessionToken = this.config.sessionToken;
1139
1148
  else if (this.config.publishableKey) {
1140
- let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await tt(e, this.config.publishableKey);
1149
+ let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await et(e, this.config.publishableKey);
1141
1150
  this.sessionToken = t, this.setState({
1142
1151
  primaryColor: n,
1143
1152
  agentName: r,
@@ -1208,8 +1217,8 @@ var mt = 8e3, ht = class {
1208
1217
  });
1209
1218
  }, s = "";
1210
1219
  try {
1211
- for await (let n of rt(t, this.sessionToken, this.conversationId, e, a)) if (n.type === "conversation_id") this.conversationId = n.conversationId, ft(this.storageIdentifier, n.conversationId);
1212
- else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await ut(n.delta, (e) => i(e), { signal: a }), s = n.delta) : n.verbatim ? (s = n.delta, i(s)) : (s += n.delta, i(s));
1220
+ for await (let n of nt(t, this.sessionToken, this.conversationId, e, a)) if (n.type === "conversation_id") this.conversationId = n.conversationId, ft(this.storageIdentifier, n.conversationId);
1221
+ else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await lt(n.delta, (e) => i(e), { signal: a }), s = n.delta) : n.verbatim ? (s = n.delta, i(s)) : (s += n.delta, i(s));
1213
1222
  else if (n.type === "done") {
1214
1223
  if (n.conversationId && (this.conversationId = n.conversationId, ft(this.storageIdentifier, n.conversationId)), n.messageId) {
1215
1224
  let e = [...this.state.messages];
@@ -1252,7 +1261,7 @@ var mt = 8e3, ht = class {
1252
1261
  }
1253
1262
  } });
1254
1263
  try {
1255
- await nt(i, this.sessionToken, {
1264
+ await tt(i, this.sessionToken, {
1256
1265
  messageId: e,
1257
1266
  rating: t,
1258
1267
  correction: n,
@@ -1274,7 +1283,7 @@ var mt = 8e3, ht = class {
1274
1283
  } });
1275
1284
  }
1276
1285
  }
1277
- }, gt = ":host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:20px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:var(--whoo-widget-color,#4f46e5);width:56px;height:56px;color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{display:block}.whoo-widget-launcher-icon-image{object-fit:cover;border-radius:50%;width:32px;height:32px}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:88px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:#fff;border-radius:12px;flex-direction:column;width:360px;max-width:calc(100vw - 40px);height:480px;max-height:calc(100vh - 108px);display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-header{border-bottom:1px solid #e5e5e5;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;padding:8px 8px 8px 16px;display:flex}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);text-overflow:ellipsis;white-space:nowrap;margin:0;font-size:15px;font-weight:600;overflow:hidden}.whoo-widget-header-actions{flex-shrink:0;align-items:center;gap:4px;display:flex}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:#f3f4f6}.whoo-widget-message-list{flex:1;min-height:100px;padding:12px;overflow-y:auto}.whoo-widget-empty-state-image{object-fit:contain;max-width:min(160px,100%);height:auto;max-height:160px;margin:8px auto 16px;display:block}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.whoo-widget-message{border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-left:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{color:var(--whoo-widget-ink,#111);background:#f0f0f0}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:#6b7280;border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{color:#991b1b;background:#fee2e2;padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid #e5e5e5;gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid #6b7280;border-radius:6px;flex:1;padding:8px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.whoo-widget-composer-send:disabled,.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:#4b5563;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:#111;background:#0000000f}.whoo-widget-feedback-buttons button:disabled{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;resize:vertical;border:1px solid #6b7280;border-radius:6px;width:100%;padding:6px;font-size:12px}.whoo-widget-feedback-select{border:1px solid #6b7280;border-radius:6px;min-height:24px;padding:4px;font-size:12px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{color:#111;cursor:pointer;background:#fff;border:1px solid #6b7280;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:#6b7280;margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:#991b1b;font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline-offset:2px;outline:2px solid #111827;box-shadow:0 0 0 4px #fff}", _t = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
1286
+ }, gt = ":host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:20px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:var(--whoo-widget-color,#4f46e5);width:56px;height:56px;color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{display:block}.whoo-widget-launcher-icon-image{object-fit:cover;border-radius:50%;width:32px;height:32px}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:88px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:#fff;border-radius:12px;flex-direction:column;width:360px;max-width:calc(100vw - 40px);height:480px;max-height:calc(100vh - 108px);display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-header{border-bottom:1px solid #e5e5e5;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;padding:8px 8px 8px 16px;display:flex}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);text-overflow:ellipsis;white-space:nowrap;margin:0;font-size:15px;font-weight:600;overflow:hidden}.whoo-widget-header-actions{flex-shrink:0;align-items:center;gap:4px;display:flex}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:#f3f4f6}.whoo-widget-message-list{flex:1;min-height:100px;padding:12px;overflow-y:auto}.whoo-widget-empty-state-image{object-fit:contain;max-width:min(160px,100%);height:auto;max-height:160px;margin:8px auto 16px;display:block}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.whoo-widget-message{white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-left:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{color:var(--whoo-widget-ink,#111);background:#f0f0f0}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:#6b7280;border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{color:#991b1b;background:#fee2e2;padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid #e5e5e5;gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid #6b7280;border-radius:6px;flex:1;padding:8px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.whoo-widget-composer-send:disabled,.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:#4b5563;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:#111;background:#0000000f}.whoo-widget-feedback-buttons button:disabled{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;resize:vertical;border:1px solid #6b7280;border-radius:6px;width:100%;padding:6px;font-size:12px}.whoo-widget-feedback-select{border:1px solid #6b7280;border-radius:6px;min-height:24px;padding:4px;font-size:12px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{color:#111;cursor:pointer;background:#fff;border:1px solid #6b7280;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:#6b7280;margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:#991b1b;font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline-offset:2px;outline:2px solid #111827;box-shadow:0 0 0 4px #fff}", _t = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
1278
1287
  function vt(e) {
1279
1288
  if (_t.test(e.trim())) return null;
1280
1289
  let t = document.createElement("div");
@@ -1298,7 +1307,7 @@ function vt(e) {
1298
1307
  function yt(e) {
1299
1308
  return vt(e)?.rgb ?? null;
1300
1309
  }
1301
- function X([e, t, n]) {
1310
+ function Z([e, t, n]) {
1302
1311
  let r = (e) => {
1303
1312
  let t = e / 255;
1304
1313
  return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
@@ -1312,18 +1321,18 @@ function bt(e, t) {
1312
1321
  function xt(e) {
1313
1322
  let t = yt(e);
1314
1323
  if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
1315
- let n = X(t);
1316
- return bt(n, X([
1324
+ let n = Z(t);
1325
+ return bt(n, Z([
1317
1326
  0,
1318
1327
  0,
1319
1328
  0
1320
- ])) >= bt(n, X([
1329
+ ])) >= bt(n, Z([
1321
1330
  255,
1322
1331
  255,
1323
1332
  255
1324
1333
  ])) ? "#000000" : "#ffffff";
1325
1334
  }
1326
- var Z = "#4f46e5", St = "#ffffff", Ct = "#f0f0f0", wt = 4.5;
1335
+ var Q = "#4f46e5", St = "#ffffff", Ct = "#f0f0f0", wt = 4.5;
1327
1336
  function Tt([e, t, n]) {
1328
1337
  return `#${[
1329
1338
  e,
@@ -1333,8 +1342,8 @@ function Tt([e, t, n]) {
1333
1342
  }
1334
1343
  function Et(e, t = St) {
1335
1344
  let n = yt(e), r = yt(t);
1336
- if (!n || !r) return Z;
1337
- let i = X(r), a = (e) => bt(X(e), i) >= wt;
1345
+ if (!n || !r) return Q;
1346
+ let i = Z(r), a = (e) => bt(Z(e), i) >= wt;
1338
1347
  if (a(n)) return Tt(n);
1339
1348
  for (let e = .99; e > 0; e -= .01) {
1340
1349
  let t = n.map((t) => Math.round(t * e));
@@ -1343,13 +1352,13 @@ function Et(e, t = St) {
1343
1352
  return "#000000";
1344
1353
  }
1345
1354
  var Dt = "#111111", Ot = "#0000ee";
1346
- function Q(e) {
1355
+ function $(e) {
1347
1356
  if (!e) return null;
1348
1357
  let t = vt(e);
1349
1358
  return t ? Tt(t.rgb) : null;
1350
1359
  }
1351
- function $({ color: e, inkColor: t, accentColor: n }) {
1352
- let r = Q(e), i = r ?? Z, a = Et(i), o = Q(t), s = o ? Et(o, Ct) : Dt, c = Q(n), l = c ? Et(c, Ct) : Ot;
1360
+ function kt({ color: e, inkColor: t, accentColor: n }) {
1361
+ let r = $(e), i = r ?? Q, a = Et(i), o = $(t), s = o ? Et(o, Ct) : Dt, c = $(n), l = c ? Et(c, Ct) : Ot;
1353
1362
  return {
1354
1363
  primary: i,
1355
1364
  textOnPrimary: xt(i),
@@ -1363,24 +1372,24 @@ function $({ color: e, inkColor: t, accentColor: n }) {
1363
1372
  }
1364
1373
  };
1365
1374
  }
1366
- function kt(e, t, n = Z) {
1375
+ function At(e, t, n = Q) {
1367
1376
  let r = t;
1368
- Q(t) === null && (console.warn(`[whoo-aiden-widget] Could not use "${t}" as the theme color; falling back to "${n}".`), r = n);
1369
- let i = $({ color: r });
1377
+ $(t) === null && (console.warn(`[whoo-aiden-widget] Could not use "${t}" as the theme color; falling back to "${n}".`), r = n);
1378
+ let i = kt({ color: r });
1370
1379
  e.style.setProperty("--whoo-widget-color", i.primary), e.style.setProperty("--whoo-widget-text-on-color", i.textOnPrimary), e.style.setProperty("--whoo-widget-color-text", i.primaryAsText);
1371
1380
  }
1372
- function At(e, { inkColor: t, accentColor: n }) {
1373
- let r = $({
1381
+ function jt(e, { inkColor: t, accentColor: n }) {
1382
+ let r = kt({
1374
1383
  inkColor: t,
1375
1384
  accentColor: n
1376
1385
  });
1377
1386
  e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
1378
1387
  }
1379
- function jt(e, t) {
1380
- e && Q(e) === null && console.warn(`[whoo-aiden-widget] Could not use "${e}" as the ${t}; using the default.`);
1381
- }
1382
1388
  function Mt(e, t) {
1383
- kt(e, t.color ?? Z), jt(t.inkColor, "ink color"), jt(t.accentColor, "accent color"), At(e, {
1389
+ e && $(e) === null && console.warn(`[whoo-aiden-widget] Could not use "${e}" as the ${t}; using the default.`);
1390
+ }
1391
+ function Nt(e, t) {
1392
+ At(e, t.color ?? Q), Mt(t.inkColor, "ink color"), Mt(t.accentColor, "accent color"), jt(e, {
1384
1393
  inkColor: t.inkColor,
1385
1394
  accentColor: t.accentColor
1386
1395
  });
@@ -1389,29 +1398,29 @@ function Mt(e, t) {
1389
1398
  }
1390
1399
  //#endregion
1391
1400
  //#region src/mount.tsx
1392
- function Nt(e) {
1401
+ function Pt(e) {
1393
1402
  let t = document.createElement("div");
1394
1403
  t.id = "whoo-aiden-widget-host";
1395
1404
  let n = t.attachShadow({ mode: "open" }), r = document.createElement("style");
1396
1405
  r.textContent = gt, n.appendChild(r);
1397
1406
  let i = document.createElement("div");
1398
- n.appendChild(i), Mt(i, e);
1407
+ n.appendChild(i), Nt(i, e);
1399
1408
  let a = new ht(e), o = null, s = "";
1400
1409
  return a.subscribe((t) => {
1401
- t.primaryColor && t.primaryColor !== o && (o = t.primaryColor, kt(i, t.primaryColor, e.color));
1410
+ t.primaryColor && t.primaryColor !== o && (o = t.primaryColor, At(i, t.primaryColor, e.color));
1402
1411
  let n = `${t.inkColor}|${t.accentColor}`;
1403
- (t.inkColor || t.accentColor) && n !== s && (s = n, At(i, {
1404
- inkColor: Q(t.inkColor) ? t.inkColor : e.inkColor,
1405
- accentColor: Q(t.accentColor) ? t.accentColor : e.accentColor
1412
+ (t.inkColor || t.accentColor) && n !== s && (s = n, jt(i, {
1413
+ inkColor: $(t.inkColor) ? t.inkColor : e.inkColor,
1414
+ accentColor: $(t.accentColor) ? t.accentColor : e.accentColor
1406
1415
  }));
1407
- }), ue(/* @__PURE__ */ U(Qe, { controller: a }), i), a.init(), document.body.appendChild(t), { unmount() {
1416
+ }), ue(/* @__PURE__ */ W(Ze, { controller: a }), i), a.init(), document.body.appendChild(t), { unmount() {
1408
1417
  ue(null, i), t.remove();
1409
1418
  } };
1410
1419
  }
1411
1420
  //#endregion
1412
1421
  //#region src/index.ts
1413
- function Pt(t) {
1414
- return e(t), Nt(t);
1422
+ function Ft(t) {
1423
+ return e(t), Pt(t);
1415
1424
  }
1416
1425
  //#endregion
1417
- export { Pt as init, $ as resolveTheme };
1426
+ export { Ft as init, kt as resolveTheme };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiden-voice/widget",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "packageManager": "pnpm@11.9.0",
5
5
  "description": "Embeddable chat widget for whoo-aiden",
6
6
  "repository": {