@ariaflowagents/widget 0.5.10 → 0.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,4 @@
1
- (function(M,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(M=typeof globalThis<"u"?globalThis:M||self,E(M.AriaFlowWidget={}))})(this,function(M){"use strict";var E,m,he,T,ge,pe,me,ve,ne,oe,ie,B={},ye=[],Ze=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,K=Array.isArray;function S(t,e){for(var n in e)t[n]=e[n];return t}function re(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function I(t,e,n){var i,r,o,_={};for(o in e)o=="key"?i=e[o]:o=="ref"?r=e[o]:_[o]=e[o];if(arguments.length>2&&(_.children=arguments.length>3?E.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)_[o]===void 0&&(_[o]=t.defaultProps[o]);return z(t,_,i,r,null)}function z(t,e,n,i,r){var o={type:t,props:e,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++he,__i:-1,__u:0};return r==null&&m.vnode!=null&&m.vnode(o),o}function D(t){return t.children}function J(t,e){this.props=t,this.context=e}function R(t,e){if(e==null)return t.__?R(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?R(t):null}function we(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return we(t)}}function be(t){(!t.__d&&(t.__d=!0)&&T.push(t)&&!G.__r++||ge!=m.debounceRendering)&&((ge=m.debounceRendering)||pe)(G)}function G(){for(var t,e,n,i,r,o,_,a=1;T.length;)T.length>a&&T.sort(me),t=T.shift(),a=T.length,t.__d&&(n=void 0,i=void 0,r=(i=(e=t).__v).__e,o=[],_=[],e.__P&&((n=S({},i)).__v=i.__v+1,m.vnode&&m.vnode(n),se(e.__P,n,i,e.__n,e.__P.namespaceURI,32&i.__u?[r]:null,o,r??R(i),!!(32&i.__u),_),n.__v=i.__v,n.__.__k[n.__i]=n,We(o,n,_),i.__e=i.__=null,n.__e!=r&&we(n)));G.__r=0}function ke(t,e,n,i,r,o,_,a,c,l,d){var s,f,u,b,C,y,p,g=i&&i.__k||ye,N=e.length;for(c=et(n,e,g,c,N),s=0;s<N;s++)(u=n.__k[s])!=null&&(f=u.__i==-1?B:g[u.__i]||B,u.__i=s,y=se(t,u,f,r,o,_,a,c,l,d),b=u.__e,u.ref&&f.ref!=u.ref&&(f.ref&&le(f.ref,null,u),d.push(u.ref,u.__c||b,u)),C==null&&b!=null&&(C=b),(p=!!(4&u.__u))||f.__k===u.__k?c=Ce(u,c,t,p):typeof u.type=="function"&&y!==void 0?c=y:b&&(c=b.nextSibling),u.__u&=-7);return n.__e=C,c}function et(t,e,n,i,r){var o,_,a,c,l,d=n.length,s=d,f=0;for(t.__k=new Array(r),o=0;o<r;o++)(_=e[o])!=null&&typeof _!="boolean"&&typeof _!="function"?(typeof _=="string"||typeof _=="number"||typeof _=="bigint"||_.constructor==String?_=t.__k[o]=z(null,_,null,null,null):K(_)?_=t.__k[o]=z(D,{children:_},null,null,null):_.constructor===void 0&&_.__b>0?_=t.__k[o]=z(_.type,_.props,_.key,_.ref?_.ref:null,_.__v):t.__k[o]=_,c=o+f,_.__=t,_.__b=t.__b+1,a=null,(l=_.__i=tt(_,n,c,s))!=-1&&(s--,(a=n[l])&&(a.__u|=2)),a==null||a.__v==null?(l==-1&&(r>d?f--:r<d&&f++),typeof _.type!="function"&&(_.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,_.__u|=4))):t.__k[o]=null;if(s)for(o=0;o<d;o++)(a=n[o])!=null&&!(2&a.__u)&&(a.__e==i&&(i=R(a)),Se(a,a));return i}function Ce(t,e,n,i){var r,o;if(typeof t.type=="function"){for(r=t.__k,o=0;r&&o<r.length;o++)r[o]&&(r[o].__=t,e=Ce(r[o],e,n,i));return e}t.__e!=e&&(i&&(e&&t.type&&!e.parentNode&&(e=R(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function tt(t,e,n,i){var r,o,_,a=t.key,c=t.type,l=e[n],d=l!=null&&(2&l.__u)==0;if(l===null&&a==null||d&&a==l.key&&c==l.type)return n;if(i>(d?1:0)){for(r=n-1,o=n+1;r>=0||o<e.length;)if((l=e[_=r>=0?r--:o++])!=null&&!(2&l.__u)&&a==l.key&&c==l.type)return _}return-1}function Ae(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||Ze.test(e)?n:n+"px"}function Q(t,e,n,i,r){var o,_;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof i=="string"&&(t.style.cssText=i=""),i)for(e in i)n&&e in n||Ae(t.style,e,"");if(n)for(e in n)i&&n[e]==i[e]||Ae(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(ve,"$1")),_=e.toLowerCase(),e=_ in t||e=="onFocusOut"||e=="onFocusIn"?_.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?i?n.u=i.u:(n.u=ne,t.addEventListener(e,o?ie:oe,o)):t.removeEventListener(e,o?ie:oe,o);else{if(r=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function $e(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ne++;else if(e.t<n.u)return;return n(m.event?m.event(e):e)}}}function se(t,e,n,i,r,o,_,a,c,l){var d,s,f,u,b,C,y,p,g,N,A,H,$,te,k,P,U,W=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),o=[a=e.__e=n.__e]),(d=m.__b)&&d(e);e:if(typeof W=="function")try{if(p=e.props,g="prototype"in W&&W.prototype.render,N=(d=W.contextType)&&i[d.__c],A=d?N?N.props.value:d.__:i,n.__c?y=(s=e.__c=n.__c).__=s.__E:(g?e.__c=s=new W(p,A):(e.__c=s=new J(p,A),s.constructor=W,s.render=ot),N&&N.sub(s),s.state||(s.state={}),s.__n=i,f=s.__d=!0,s.__h=[],s._sb=[]),g&&s.__s==null&&(s.__s=s.state),g&&W.getDerivedStateFromProps!=null&&(s.__s==s.state&&(s.__s=S({},s.__s)),S(s.__s,W.getDerivedStateFromProps(p,s.__s))),u=s.props,b=s.state,s.__v=e,f)g&&W.getDerivedStateFromProps==null&&s.componentWillMount!=null&&s.componentWillMount(),g&&s.componentDidMount!=null&&s.__h.push(s.componentDidMount);else{if(g&&W.getDerivedStateFromProps==null&&p!==u&&s.componentWillReceiveProps!=null&&s.componentWillReceiveProps(p,A),e.__v==n.__v||!s.__e&&s.shouldComponentUpdate!=null&&s.shouldComponentUpdate(p,s.__s,A)===!1){for(e.__v!=n.__v&&(s.props=p,s.state=s.__s,s.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(F){F&&(F.__=e)}),H=0;H<s._sb.length;H++)s.__h.push(s._sb[H]);s._sb=[],s.__h.length&&_.push(s);break e}s.componentWillUpdate!=null&&s.componentWillUpdate(p,s.__s,A),g&&s.componentDidUpdate!=null&&s.__h.push(function(){s.componentDidUpdate(u,b,C)})}if(s.context=A,s.props=p,s.__P=t,s.__e=!1,$=m.__r,te=0,g){for(s.state=s.__s,s.__d=!1,$&&$(e),d=s.render(s.props,s.state,s.context),k=0;k<s._sb.length;k++)s.__h.push(s._sb[k]);s._sb=[]}else do s.__d=!1,$&&$(e),d=s.render(s.props,s.state,s.context),s.state=s.__s;while(s.__d&&++te<25);s.state=s.__s,s.getChildContext!=null&&(i=S(S({},i),s.getChildContext())),g&&!f&&s.getSnapshotBeforeUpdate!=null&&(C=s.getSnapshotBeforeUpdate(u,b)),P=d,d!=null&&d.type===D&&d.key==null&&(P=xe(d.props.children)),a=ke(t,K(P)?P:[P],e,n,i,r,o,_,a,c,l),s.base=e.__e,e.__u&=-161,s.__h.length&&_.push(s),y&&(s.__E=s.__=null)}catch(F){if(e.__v=null,c||o!=null)if(F.then){for(e.__u|=c?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;o[o.indexOf(a)]=null,e.__e=a}else{for(U=o.length;U--;)re(o[U]);_e(e)}else e.__e=n.__e,e.__k=n.__k,F.then||_e(e);m.__e(F,e,n)}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):a=e.__e=nt(n.__e,e,n,i,r,o,_,c,l);return(d=m.diffed)&&d(e),128&e.__u?void 0:a}function _e(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(_e)}function We(t,e,n){for(var i=0;i<n.length;i++)le(n[i],n[++i],n[++i]);m.__c&&m.__c(e,t),t.some(function(r){try{t=r.__h,r.__h=[],t.some(function(o){o.call(r)})}catch(o){m.__e(o,r.__v)}})}function xe(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:K(t)?t.map(xe):S({},t)}function nt(t,e,n,i,r,o,_,a,c){var l,d,s,f,u,b,C,y=n.props||B,p=e.props,g=e.type;if(g=="svg"?r="http://www.w3.org/2000/svg":g=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),o!=null){for(l=0;l<o.length;l++)if((u=o[l])&&"setAttribute"in u==!!g&&(g?u.localName==g:u.nodeType==3)){t=u,o[l]=null;break}}if(t==null){if(g==null)return document.createTextNode(p);t=document.createElementNS(r,g,p.is&&p),a&&(m.__m&&m.__m(e,o),a=!1),o=null}if(g==null)y===p||a&&t.data==p||(t.data=p);else{if(o=o&&E.call(t.childNodes),!a&&o!=null)for(y={},l=0;l<t.attributes.length;l++)y[(u=t.attributes[l]).name]=u.value;for(l in y)if(u=y[l],l!="children"){if(l=="dangerouslySetInnerHTML")s=u;else if(!(l in p)){if(l=="value"&&"defaultValue"in p||l=="checked"&&"defaultChecked"in p)continue;Q(t,l,null,u,r)}}for(l in p)u=p[l],l=="children"?f=u:l=="dangerouslySetInnerHTML"?d=u:l=="value"?b=u:l=="checked"?C=u:a&&typeof u!="function"||y[l]===u||Q(t,l,u,y[l],r);if(d)a||s&&(d.__html==s.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(s&&(t.innerHTML=""),ke(e.type=="template"?t.content:t,K(f)?f:[f],e,n,i,g=="foreignObject"?"http://www.w3.org/1999/xhtml":r,o,_,o?o[0]:n.__k&&R(n,0),a,c),o!=null)for(l=o.length;l--;)re(o[l]);a||(l="value",g=="progress"&&b==null?t.removeAttribute("value"):b!=null&&(b!==t[l]||g=="progress"&&!b||g=="option"&&b!=y[l])&&Q(t,l,b,y[l],r),l="checked",C!=null&&C!=t[l]&&Q(t,l,C,y[l],r))}return t}function le(t,e,n){try{if(typeof t=="function"){var i=typeof t.__u=="function";i&&t.__u(),i&&e==null||(t.__u=t(e))}else t.current=e}catch(r){m.__e(r,n)}}function Se(t,e,n){var i,r;if(m.unmount&&m.unmount(t),(i=t.ref)&&(i.current&&i.current!=t.__e||le(i,null,e)),(i=t.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(o){m.__e(o,e)}i.base=i.__P=null}if(i=t.__k)for(r=0;r<i.length;r++)i[r]&&Se(i[r],e,n||typeof t.type!="function");n||re(t.__e),t.__c=t.__=t.__e=void 0}function ot(t,e,n){return this.constructor(t,n)}function X(t,e,n){var i,r,o,_;e==document&&(e=document.documentElement),m.__&&m.__(t,e),r=(i=typeof n=="function")?null:n&&n.__k||e.__k,o=[],_=[],se(e,t=(!i&&n||e).__k=I(D,null,[t]),r||B,B,e.namespaceURI,!i&&n?[n]:r?null:e.firstChild?E.call(e.childNodes):null,o,!i&&n?n:r?r.__e:e.firstChild,i,_),We(o,t,_)}function Ne(t,e){X(t,e,Ne)}function Fe(t,e,n){var i,r,o,_,a=S({},t.props);for(o in t.type&&t.type.defaultProps&&(_=t.type.defaultProps),e)o=="key"?i=e[o]:o=="ref"?r=e[o]:a[o]=e[o]===void 0&&_!=null?_[o]:e[o];return arguments.length>2&&(a.children=arguments.length>3?E.call(arguments,2):n),z(t.type,a,i||t.key,r||t.ref,null)}E=ye.slice,m={__e:function(t,e,n,i){for(var r,o,_;e=e.__;)if((r=e.__c)&&!r.__)try{if((o=r.constructor)&&o.getDerivedStateFromError!=null&&(r.setState(o.getDerivedStateFromError(t)),_=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(t,i||{}),_=r.__d),_)return r.__E=r}catch(a){t=a}throw t}},he=0,J.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=S({},this.state),typeof t=="function"&&(t=t(S({},n),this.props)),t&&S(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),be(this))},J.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),be(this))},J.prototype.render=D,T=[],pe=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,me=function(t,e){return t.__v.__b-e.__v.__b},G.__r=0,ve=/(PointerCapture)$|Capture$/i,ne=0,oe=$e(!1),ie=$e(!0);function Y(){return Y=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Y.apply(this,arguments)}function Ee(t,e){if(t==null)return{};var n,i,r={},o=Object.keys(t);for(i=0;i<o.length;i++)e.indexOf(n=o[i])>=0||(r[n]=t[n]);return r}var it=["context","children"],rt=["useFragment"];function st(t,e,n,i){function r(){var o=Reflect.construct(HTMLElement,[],r);return o._vdomComponent=t,o._root=o,o}return(r.prototype=Object.create(HTMLElement.prototype)).constructor=r,r.prototype.connectedCallback=function(){lt.call(this,i)},r.prototype.attributeChangedCallback=at,r.prototype.disconnectedCallback=ct,n=n||t.observedAttributes||Object.keys(t.propTypes||{}),r.observedAttributes=n,t.formAssociated&&(r.formAssociated=!0),n.forEach(function(o){Object.defineProperty(r.prototype,o,{get:function(){return this._vdom?this._vdom.props[o]:this._props[o]},set:function(_){this._vdom?this.attributeChangedCallback(o,null,_):(this._props||(this._props={}),this._props[o]=_);var a=typeof _;_!=null&&a!=="string"&&a!=="boolean"&&a!=="number"||this.setAttribute(o,_)}})}),customElements.define(e,r),r}function _t(t){this.getChildContext=function(){return t.context};var e=t.children,n=Ee(t,it);return Fe(e,n)}function lt(t){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=I(_t,Y({},this._props,{context:e.detail.context}),He(this,this._vdomComponent,t)),(this.hasAttribute("hydrate")?Ne:X)(this._vdom,this._root)}function Me(t){return t.replace(/-(\w)/g,function(e,n){return n?n.toUpperCase():""})}function at(t,e,n){if(this._vdom){var i={};i[t]=n=n??void 0,i[Me(t)]=n,this._vdom=Fe(this._vdom,i),X(this._vdom,this._root)}}function ct(){X(this._vdom=null,this._root)}function Te(t,e){var n=this,i=t.useFragment,r=Ee(t,rt);return I(i?D:"slot",Y({},r,{ref:function(o){o?(n.ref=o,n._listener||(n._listener=function(_){_.stopPropagation(),_.detail.context=e},o.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function He(t,e,n){if(t.nodeType===3)return t.data;if(t.nodeType!==1)return null;var i=[],r={},o=0,_=t.attributes,a=t.childNodes;for(o=_.length;o--;)_[o].name!=="slot"&&(r[_[o].name]=_[o].value,r[Me(_[o].name)]=_[o].value);for(o=a.length;o--;){var c=He(a[o],null,n),l=a[o].slot;l?r[l]=I(Te,{name:l},c):i[o]=c}var d=!(!n||!n.shadow),s=e?I(Te,{useFragment:!d},i):i;return!d&&e&&(t.innerHTML=""),I(e||t.nodeName.toLowerCase(),r,s)}var ut=0;function h(t,e,n,i,r,o){e||(e={});var _,a,c=e;if("ref"in c)for(a in c={},e)a=="ref"?_=e[a]:c[a]=e[a];var l={type:t,props:c,key:n,ref:_,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ut,__i:-1,__u:0,__source:r,__self:o};if(typeof t=="function"&&(_=t.defaultProps))for(a in _)c[a]===void 0&&(c[a]=_[a]);return m.vnode&&m.vnode(l),l}var V,v,ae,Pe,Z=0,Ue=[],w=m,Ie=w.__b,De=w.__r,Re=w.diffed,Le=w.__c,Oe=w.unmount,je=w.__;function ce(t,e){w.__h&&w.__h(v,t,Z||e),Z=0;var n=v.__H||(v.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function L(t){return Z=1,dt(Ke,t)}function dt(t,e,n){var i=ce(V++,2);if(i.t=t,!i.__c&&(i.__=[Ke(void 0,e),function(a){var c=i.__N?i.__N[0]:i.__[0],l=i.t(c,a);c!==l&&(i.__N=[l,i.__[1]],i.__c.setState({}))}],i.__c=v,!v.__f)){var r=function(a,c,l){if(!i.__c.__H)return!0;var d=i.__c.__H.__.filter(function(f){return!!f.__c});if(d.every(function(f){return!f.__N}))return!o||o.call(this,a,c,l);var s=i.__c.props!==a;return d.forEach(function(f){if(f.__N){var u=f.__[0];f.__=f.__N,f.__N=void 0,u!==f.__[0]&&(s=!0)}}),o&&o.call(this,a,c,l)||s};v.__f=!0;var o=v.shouldComponentUpdate,_=v.componentWillUpdate;v.componentWillUpdate=function(a,c,l){if(this.__e){var d=o;o=void 0,r(a,c,l),o=d}_&&_.call(this,a,c,l)},v.shouldComponentUpdate=r}return i.__N||i.__}function Be(t,e){var n=ce(V++,3);!w.__s&&qe(n.__H,e)&&(n.__=t,n.u=e,v.__H.__h.push(n))}function ze(t){return Z=5,ft(function(){return{current:t}},[])}function ft(t,e){var n=ce(V++,7);return qe(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function ht(){for(var t;t=Ue.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ee),t.__H.__h.forEach(ue),t.__H.__h=[]}catch(e){t.__H.__h=[],w.__e(e,t.__v)}}w.__b=function(t){v=null,Ie&&Ie(t)},w.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),je&&je(t,e)},w.__r=function(t){De&&De(t),V=0;var e=(v=t.__c).__H;e&&(ae===v?(e.__h=[],v.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(ee),e.__h.forEach(ue),e.__h=[],V=0)),ae=v},w.diffed=function(t){Re&&Re(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Ue.push(e)!==1&&Pe===w.requestAnimationFrame||((Pe=w.requestAnimationFrame)||gt)(ht)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ae=v=null},w.__c=function(t,e){e.some(function(n){try{n.__h.forEach(ee),n.__h=n.__h.filter(function(i){return!i.__||ue(i)})}catch(i){e.some(function(r){r.__h&&(r.__h=[])}),e=[],w.__e(i,n.__v)}}),Le&&Le(t,e)},w.unmount=function(t){Oe&&Oe(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(i){try{ee(i)}catch(r){e=r}}),n.__H=void 0,e&&w.__e(e,n.__v))};var Ve=typeof requestAnimationFrame=="function";function gt(t){var e,n=function(){clearTimeout(i),Ve&&cancelAnimationFrame(e),setTimeout(t)},i=setTimeout(n,35);Ve&&(e=requestAnimationFrame(n))}function ee(t){var e=v,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),v=e}function ue(t){var e=v;t.__c=t.__(),v=e}function qe(t,e){return!t||t.length!==e.length||e.some(function(n,i){return n!==t[i]})}function Ke(t,e){return typeof e=="function"?e(t):e}const pt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let de=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=pt[n[t]&63];return e};class Je{constructor(e,n){this.agentUrl=e,this.agentId=n,this.agentConfig=null,this.ws=null,this.messageCallbacks=new Set,this.connectionCallbacks=new Set,this.messages=[],this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.reconnectDelay=1e3}async initWidget(){try{console.log("[AriaFlow Widget] Fetching agent config...",{agentUrl:this.agentUrl,agentId:this.agentId});try{const n=await fetch(`${this.agentUrl}/api/agent/${this.agentId}`);if(n.ok){const i=await n.json();return console.log("[AriaFlow Widget] Agent config received:",i),!i||i.status!=="active"?(console.error("Agent not found or inactive"),null):(this.agentConfig=i,this.maxReconnectAttempts=i.config.maxRetries||5,this.reconnectDelay=i.config.reconnectDelay||1e3,await this.connectToAgent(),i)}}catch{console.warn("[AriaFlow Widget] Agent config endpoint not available, trying fallback")}console.log("[AriaFlow Widget] Using fallback config for Railway deployment");const e={id:this.agentId,name:this.agentId==="hospital"?"Hospital Support":"Support Agent",wsUrl:`${this.agentUrl.replace(/^https/,"wss")}/ws`,status:"active",capabilities:["chat","streaming"],config:{primaryColor:"#14B8A6",position:"bottom-right",theme:"light",title:this.agentId==="hospital"?"Hospital Support":"Chat Support",subtitle:"We're here to help!",maxRetries:3,reconnectDelay:1e3}};return this.agentConfig=e,await this.connectToAgent(),e}catch(e){return console.error("Failed to initialize widget:",e),null}}async connectToAgent(){if(!this.agentConfig?.wsUrl)throw new Error("No agent WebSocket URL configured");const e=this.getSessionId(),n=`${this.agentConfig.wsUrl}/${e}`;return console.log("[AriaFlow Widget] Connecting to WebSocket:",n),new Promise((i,r)=>{try{this.ws=new WebSocket(n),this.ws.onopen=()=>{console.log("[Widget] Connected to agent"),this.reconnectAttempts=0,this.notifyConnectionChange(!0),i()},this.ws.onmessage=o=>{this.handleMessage(o)},this.ws.onclose=()=>{if(console.log("[Widget] Disconnected from agent"),this.notifyConnectionChange(!1),this.reconnectAttempts<this.maxReconnectAttempts){this.reconnectAttempts++;const o=this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1);console.log(`[Widget] Reconnecting in ${o}ms... (attempt ${this.reconnectAttempts})`),setTimeout(()=>this.connectToAgent(),o)}},this.ws.onerror=o=>{console.error("[Widget] WebSocket error:",o),r(o)}}catch(o){r(o)}})}handleMessage(e){try{const n=JSON.parse(e.data);n.type==="text-delta"?this.setMessages(i=>{const r=i[i.length-1];return r&&r.role==="assistant"?[...i.slice(0,-1),{...r,content:r.content+n.text}]:[...i,{id:de(),role:"assistant",content:n.text,timestamp:Date.now()}]}):n.type==="done"?console.log("[Widget] Response complete"):n.type==="handoff"?console.log(`[Widget] Handoff: ${n.from} -> ${n.to}: ${n.reason}`):n.type==="tool-call"?console.log("[Widget] Tool call:",n.tool):console.log("[Widget] Unknown message type:",n.type)}catch(n){console.error("[Widget] Error parsing message:",e.data,n)}}async sendMessage(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("Not connected to agent");const n={id:de(),role:"user",content:e,timestamp:Date.now()};this.setMessages(r=>[...r,n]);const i=this.getSessionId();this.ws.send(JSON.stringify({message:e,sessionId:i}))}getSessionId(){let e=sessionStorage.getItem("ariaflow_session_id");return e||(e=de(),sessionStorage.setItem("ariaflow_session_id",e)),e}setMessages(e){this.messages=e(this.messages),this.messageCallbacks.forEach(n=>n(this.messages))}onMessages(e){return this.messageCallbacks.add(e),e(this.messages),()=>{this.messageCallbacks.delete(e)}}onConnectionChange(e){return this.connectionCallbacks.add(e),()=>{this.connectionCallbacks.delete(e)}}notifyConnectionChange(e){this.connectionCallbacks.forEach(n=>n(e))}getMessages(){return this.messages}getConfig(){return this.agentConfig}isConnected(){return this.ws?.readyState===WebSocket.OPEN}dispose(){this.ws&&(this.ws.close(),this.ws=null),this.messageCallbacks.clear(),this.connectionCallbacks.clear()}}const fe={none:"0",small:"0.375rem",medium:"0.75rem",large:"1rem"};function Ge({agentUrl:t,agentId:e,widgetId:n,apiUrl:i,mode:r="chat",theme:o="light",position:_="bottom-right",size:a="full",radius:c="medium",baseColor:l,accentColor:d="#14B8A6",buttonBaseColor:s="#000000",buttonAccentColor:f="#FFFFFF",title:u,subtitle:b,emptyChatMessage:C}){const[y,p]=L(!1),[g,N]=L([]),[A,H]=L(""),[$,te]=L(!1),[k,P]=L(!1),[U,W]=L(null),F=ze(null),Xe=ze(null);Be(()=>((async()=>{if(t&&e){console.log("[AriaFlow Widget] Using new agent resolution:",{agentUrl:t,agentId:e});const O=new Je(t,e);F.current=O;try{O.onMessages(j=>{console.log("[AriaFlow Widget] Messages updated:",j.length),N(j)}),O.onConnectionChange(j=>{console.log("[AriaFlow Widget] Connection state:",j),te(j),j&&P(!0)});const q=await O.initWidget();console.log("[AriaFlow Widget] Agent config received:",q),q?(W(q),console.log("[AriaFlow Widget] Widget initialized successfully")):console.error("[AriaFlow Widget] Agent config fetch failed")}catch(q){console.error("[AriaFlow Widget] Initialization error:",q)}}else t&&!e?(console.warn("[AriaFlow Widget] Direct WebSocket URLs are deprecated. Use agent-url + agent-id instead."),console.error("[AriaFlow Widget] Configuration error: agent-id is required")):i&&n?(console.warn("[AriaFlow Widget] Legacy widget config is deprecated. Use agent-url + agent-id instead."),console.error("[AriaFlow Widget] Configuration error: use agent-url + agent-id instead")):console.error("[AriaFlow Widget] Invalid configuration. Provide agent-url and agent-id.")})(),()=>{F.current?.dispose()}),[t,e,n,i]),Be(()=>{Xe.current?.scrollIntoView({behavior:"smooth"})},[g]);const Ye=async()=>{if(!A.trim()||!$)return;const x=A.trim();H("");try{await F.current?.sendMessage(x)}catch(O){console.error("Failed to send message:",O)}},mt=x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),Ye())},vt=u||U?.title||"Chat with us",yt=b||U?.subtitle||"We typically reply within minutes",wt=C||U?.config?.emptyChatMessage||"Start a conversation...";return console.log("[AriaFlow Widget] Rendering widget component",{isInitialized:k,isOpen:y,position:_}),h("div",{className:`ariaflow-widget-container ariaflow-widget-${_} ariaflow-widget-${a} ariaflow-widget-radius-${c}`,"data-theme":o,style:{"--ariaflow-accent-color":d,"--ariaflow-base-color":l},children:[!y&&h("button",{className:"ariaflow-widget-launcher",onClick:()=>p(!0),style:{backgroundColor:s,color:f,opacity:k?1:.8,cursor:k?"pointer":"wait",position:"relative"},"aria-label":k?"Open chat":"Connecting to agent...",disabled:!k,title:k?"Click to start chat":"Connecting to agent...",children:[!k&&h("div",{className:"ariaflow-widget-launcher-loading",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"20px",height:"20px",border:`2px solid ${f}`,borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}}),k&&h("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})]}),y&&k&&h("div",{className:"ariaflow-widget-window",style:{backgroundColor:o==="dark"&&l?l:void 0,borderRadius:fe[c]},children:[h("div",{className:"ariaflow-widget-header",style:{backgroundColor:d,borderRadius:c==="none"?"0":`${fe[c]} ${fe[c]} 0 0`},children:[h("div",{className:"ariaflow-widget-header-content",children:h("div",{className:"ariaflow-widget-title-group",children:[h("h3",{className:"ariaflow-widget-title",children:vt}),h("p",{className:"ariaflow-widget-subtitle",children:yt})]})}),h("button",{className:"ariaflow-widget-close",onClick:()=>p(!1),"aria-label":"Close chat",children:h("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),h("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),!$&&h("div",{className:"ariaflow-widget-status",children:[h("span",{className:"ariaflow-widget-status-dot"}),"Connecting..."]}),h("div",{className:"ariaflow-widget-messages",children:g.length===0?h("div",{className:"ariaflow-widget-empty",children:h("p",{children:$?wt:"Connecting to agent..."})}):h(D,{children:[g.map(x=>h("div",{className:`ariaflow-widget-message ariaflow-widget-message-${x.role}`,children:h("div",{className:"ariaflow-widget-message-bubble",children:x.content})},x.id)),h("div",{ref:Xe})]})}),h("div",{className:"ariaflow-widget-input",children:[h("textarea",{value:A,onInput:x=>H(x.target.value),onKeyDown:mt,placeholder:$?"Type your message...":"Connecting...",rows:1,disabled:!$}),h("button",{className:"ariaflow-widget-send",onClick:Ye,disabled:!A.trim()||!$,style:{backgroundColor:d},"aria-label":"Send message",children:h("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),h("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})]})}st(Ge,"ariaflow-widget",["agent-url","agent-id","widget-id","api-url","mode","theme","position","size","radius","base-color","accent-color","button-base-color","button-accent-color","title","subtitle","empty-chat-message"],!1),typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Qe):Qe());function Qe(){const t=document.querySelectorAll("ariaflow-widget");console.log(`[AriaFlow] Initializing ${t.length} widget(s)`)}M.Widget=Ge,M.WidgetClient=Je,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
1
+ (function(P,M){typeof exports=="object"&&typeof module<"u"?M(exports):typeof define=="function"&&define.amd?define(["exports"],M):(P=typeof globalThis<"u"?globalThis:P||self,M(P.AriaFlowWidget={}))})(this,function(P){"use strict";var M,m,pe,I,me,ye,ve,we,oe,ie,se,q={},be=[],tt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,V=Array.isArray;function x(t,e){for(var n in e)t[n]=e[n];return t}function re(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function L(t,e,n){var o,s,i,l={};for(i in e)i=="key"?o=e[i]:i=="ref"?s=e[i]:l[i]=e[i];if(arguments.length>2&&(l.children=arguments.length>3?M.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)l[i]===void 0&&(l[i]=t.defaultProps[i]);return j(t,l,o,s,null)}function j(t,e,n,o,s){var i={type:t,props:e,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++pe,__i:-1,__u:0};return s==null&&m.vnode!=null&&m.vnode(i),i}function R(t){return t.children}function J(t,e){this.props=t,this.context=e}function Q(t,e){if(e==null)return t.__?Q(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?Q(t):null}function Ce(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Ce(t)}}function ke(t){(!t.__d&&(t.__d=!0)&&I.push(t)&&!K.__r++||me!=m.debounceRendering)&&((me=m.debounceRendering)||ye)(K)}function K(){for(var t,e,n,o,s,i,l,_=1;I.length;)I.length>_&&I.sort(ve),t=I.shift(),_=I.length,t.__d&&(n=void 0,o=void 0,s=(o=(e=t).__v).__e,i=[],l=[],e.__P&&((n=x({},o)).__v=o.__v+1,m.vnode&&m.vnode(n),le(e.__P,n,o,e.__n,e.__P.namespaceURI,32&o.__u?[s]:null,i,s??Q(o),!!(32&o.__u),l),n.__v=o.__v,n.__.__k[n.__i]=n,Ne(i,n,l),o.__e=o.__=null,n.__e!=s&&Ce(n)));K.__r=0}function Ae(t,e,n,o,s,i,l,_,c,a,d){var r,f,u,b,A,v,p,g=o&&o.__k||be,F=e.length;for(c=nt(n,e,g,c,F),r=0;r<F;r++)(u=n.__k[r])!=null&&(f=u.__i==-1?q:g[u.__i]||q,u.__i=r,v=le(t,u,f,s,i,l,_,c,a,d),b=u.__e,u.ref&&f.ref!=u.ref&&(f.ref&&_e(f.ref,null,u),d.push(u.ref,u.__c||b,u)),A==null&&b!=null&&(A=b),(p=!!(4&u.__u))||f.__k===u.__k?c=Se(u,c,t,p):typeof u.type=="function"&&v!==void 0?c=v:b&&(c=b.nextSibling),u.__u&=-7);return n.__e=A,c}function nt(t,e,n,o,s){var i,l,_,c,a,d=n.length,r=d,f=0;for(t.__k=new Array(s),i=0;i<s;i++)(l=e[i])!=null&&typeof l!="boolean"&&typeof l!="function"?(typeof l=="string"||typeof l=="number"||typeof l=="bigint"||l.constructor==String?l=t.__k[i]=j(null,l,null,null,null):V(l)?l=t.__k[i]=j(R,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=t.__k[i]=j(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):t.__k[i]=l,c=i+f,l.__=t,l.__b=t.__b+1,_=null,(a=l.__i=ot(l,n,c,r))!=-1&&(r--,(_=n[a])&&(_.__u|=2)),_==null||_.__v==null?(a==-1&&(s>d?f--:s<d&&f++),typeof l.type!="function"&&(l.__u|=4)):a!=c&&(a==c-1?f--:a==c+1?f++:(a>c?f--:f++,l.__u|=4))):t.__k[i]=null;if(r)for(i=0;i<d;i++)(_=n[i])!=null&&!(2&_.__u)&&(_.__e==o&&(o=Q(_)),Fe(_,_));return o}function Se(t,e,n,o){var s,i;if(typeof t.type=="function"){for(s=t.__k,i=0;s&&i<s.length;i++)s[i]&&(s[i].__=t,e=Se(s[i],e,n,o));return e}t.__e!=e&&(o&&(e&&t.type&&!e.parentNode&&(e=Q(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function ot(t,e,n,o){var s,i,l,_=t.key,c=t.type,a=e[n],d=a!=null&&(2&a.__u)==0;if(a===null&&_==null||d&&_==a.key&&c==a.type)return n;if(o>(d?1:0)){for(s=n-1,i=n+1;s>=0||i<e.length;)if((a=e[l=s>=0?s--:i++])!=null&&!(2&a.__u)&&_==a.key&&c==a.type)return l}return-1}function $e(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||tt.test(e)?n:n+"px"}function G(t,e,n,o,s){var i,l;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)n&&e in n||$e(t.style,e,"");if(n)for(e in n)o&&n[e]==o[e]||$e(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")i=e!=(e=e.replace(we,"$1")),l=e.toLowerCase(),e=l in t||e=="onFocusOut"||e=="onFocusIn"?l.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+i]=n,n?o?n.u=o.u:(n.u=oe,t.addEventListener(e,i?se:ie,i)):t.removeEventListener(e,i?se:ie,i);else{if(s=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function We(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=oe++;else if(e.t<n.u)return;return n(m.event?m.event(e):e)}}}function le(t,e,n,o,s,i,l,_,c,a){var d,r,f,u,b,A,v,p,g,F,S,U,$,ne,k,D,O,W=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),i=[_=e.__e=n.__e]),(d=m.__b)&&d(e);e:if(typeof W=="function")try{if(p=e.props,g="prototype"in W&&W.prototype.render,F=(d=W.contextType)&&o[d.__c],S=d?F?F.props.value:d.__:o,n.__c?v=(r=e.__c=n.__c).__=r.__E:(g?e.__c=r=new W(p,S):(e.__c=r=new J(p,S),r.constructor=W,r.render=st),F&&F.sub(r),r.state||(r.state={}),r.__n=o,f=r.__d=!0,r.__h=[],r._sb=[]),g&&r.__s==null&&(r.__s=r.state),g&&W.getDerivedStateFromProps!=null&&(r.__s==r.state&&(r.__s=x({},r.__s)),x(r.__s,W.getDerivedStateFromProps(p,r.__s))),u=r.props,b=r.state,r.__v=e,f)g&&W.getDerivedStateFromProps==null&&r.componentWillMount!=null&&r.componentWillMount(),g&&r.componentDidMount!=null&&r.__h.push(r.componentDidMount);else{if(g&&W.getDerivedStateFromProps==null&&p!==u&&r.componentWillReceiveProps!=null&&r.componentWillReceiveProps(p,S),e.__v==n.__v||!r.__e&&r.shouldComponentUpdate!=null&&r.shouldComponentUpdate(p,r.__s,S)===!1){for(e.__v!=n.__v&&(r.props=p,r.state=r.__s,r.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(T){T&&(T.__=e)}),U=0;U<r._sb.length;U++)r.__h.push(r._sb[U]);r._sb=[],r.__h.length&&l.push(r);break e}r.componentWillUpdate!=null&&r.componentWillUpdate(p,r.__s,S),g&&r.componentDidUpdate!=null&&r.__h.push(function(){r.componentDidUpdate(u,b,A)})}if(r.context=S,r.props=p,r.__P=t,r.__e=!1,$=m.__r,ne=0,g){for(r.state=r.__s,r.__d=!1,$&&$(e),d=r.render(r.props,r.state,r.context),k=0;k<r._sb.length;k++)r.__h.push(r._sb[k]);r._sb=[]}else do r.__d=!1,$&&$(e),d=r.render(r.props,r.state,r.context),r.state=r.__s;while(r.__d&&++ne<25);r.state=r.__s,r.getChildContext!=null&&(o=x(x({},o),r.getChildContext())),g&&!f&&r.getSnapshotBeforeUpdate!=null&&(A=r.getSnapshotBeforeUpdate(u,b)),D=d,d!=null&&d.type===R&&d.key==null&&(D=xe(d.props.children)),_=Ae(t,V(D)?D:[D],e,n,o,s,i,l,_,c,a),r.base=e.__e,e.__u&=-161,r.__h.length&&l.push(r),v&&(r.__E=r.__=null)}catch(T){if(e.__v=null,c||i!=null)if(T.then){for(e.__u|=c?160:128;_&&_.nodeType==8&&_.nextSibling;)_=_.nextSibling;i[i.indexOf(_)]=null,e.__e=_}else{for(O=i.length;O--;)re(i[O]);ae(e)}else e.__e=n.__e,e.__k=n.__k,T.then||ae(e);m.__e(T,e,n)}else i==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):_=e.__e=it(n.__e,e,n,o,s,i,l,c,a);return(d=m.diffed)&&d(e),128&e.__u?void 0:_}function ae(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(ae)}function Ne(t,e,n){for(var o=0;o<n.length;o++)_e(n[o],n[++o],n[++o]);m.__c&&m.__c(e,t),t.some(function(s){try{t=s.__h,s.__h=[],t.some(function(i){i.call(s)})}catch(i){m.__e(i,s.__v)}})}function xe(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:V(t)?t.map(xe):x({},t)}function it(t,e,n,o,s,i,l,_,c){var a,d,r,f,u,b,A,v=n.props||q,p=e.props,g=e.type;if(g=="svg"?s="http://www.w3.org/2000/svg":g=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),i!=null){for(a=0;a<i.length;a++)if((u=i[a])&&"setAttribute"in u==!!g&&(g?u.localName==g:u.nodeType==3)){t=u,i[a]=null;break}}if(t==null){if(g==null)return document.createTextNode(p);t=document.createElementNS(s,g,p.is&&p),_&&(m.__m&&m.__m(e,i),_=!1),i=null}if(g==null)v===p||_&&t.data==p||(t.data=p);else{if(i=i&&M.call(t.childNodes),!_&&i!=null)for(v={},a=0;a<t.attributes.length;a++)v[(u=t.attributes[a]).name]=u.value;for(a in v)if(u=v[a],a!="children"){if(a=="dangerouslySetInnerHTML")r=u;else if(!(a in p)){if(a=="value"&&"defaultValue"in p||a=="checked"&&"defaultChecked"in p)continue;G(t,a,null,u,s)}}for(a in p)u=p[a],a=="children"?f=u:a=="dangerouslySetInnerHTML"?d=u:a=="value"?b=u:a=="checked"?A=u:_&&typeof u!="function"||v[a]===u||G(t,a,u,v[a],s);if(d)_||r&&(d.__html==r.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(r&&(t.innerHTML=""),Ae(e.type=="template"?t.content:t,V(f)?f:[f],e,n,o,g=="foreignObject"?"http://www.w3.org/1999/xhtml":s,i,l,i?i[0]:n.__k&&Q(n,0),_,c),i!=null)for(a=i.length;a--;)re(i[a]);_||(a="value",g=="progress"&&b==null?t.removeAttribute("value"):b!=null&&(b!==t[a]||g=="progress"&&!b||g=="option"&&b!=v[a])&&G(t,a,b,v[a],s),a="checked",A!=null&&A!=t[a]&&G(t,a,A,v[a],s))}return t}function _e(t,e,n){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(s){m.__e(s,n)}}function Fe(t,e,n){var o,s;if(m.unmount&&m.unmount(t),(o=t.ref)&&(o.current&&o.current!=t.__e||_e(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(i){m.__e(i,e)}o.base=o.__P=null}if(o=t.__k)for(s=0;s<o.length;s++)o[s]&&Fe(o[s],e,n||typeof t.type!="function");n||re(t.__e),t.__c=t.__=t.__e=void 0}function st(t,e,n){return this.constructor(t,n)}function X(t,e,n){var o,s,i,l;e==document&&(e=document.documentElement),m.__&&m.__(t,e),s=(o=typeof n=="function")?null:n&&n.__k||e.__k,i=[],l=[],le(e,t=(!o&&n||e).__k=L(R,null,[t]),s||q,q,e.namespaceURI,!o&&n?[n]:s?null:e.firstChild?M.call(e.childNodes):null,i,!o&&n?n:s?s.__e:e.firstChild,o,l),Ne(i,t,l)}function Me(t,e){X(t,e,Me)}function Ee(t,e,n){var o,s,i,l,_=x({},t.props);for(i in t.type&&t.type.defaultProps&&(l=t.type.defaultProps),e)i=="key"?o=e[i]:i=="ref"?s=e[i]:_[i]=e[i]===void 0&&l!=null?l[i]:e[i];return arguments.length>2&&(_.children=arguments.length>3?M.call(arguments,2):n),j(t.type,_,o||t.key,s||t.ref,null)}M=be.slice,m={__e:function(t,e,n,o){for(var s,i,l;e=e.__;)if((s=e.__c)&&!s.__)try{if((i=s.constructor)&&i.getDerivedStateFromError!=null&&(s.setState(i.getDerivedStateFromError(t)),l=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(t,o||{}),l=s.__d),l)return s.__E=s}catch(_){t=_}throw t}},pe=0,J.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=x({},this.state),typeof t=="function"&&(t=t(x({},n),this.props)),t&&x(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),ke(this))},J.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),ke(this))},J.prototype.render=R,I=[],ye=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ve=function(t,e){return t.__v.__b-e.__v.__b},K.__r=0,we=/(PointerCapture)$|Capture$/i,oe=0,ie=We(!1),se=We(!0);function Y(){return Y=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},Y.apply(this,arguments)}function Te(t,e){if(t==null)return{};var n,o,s={},i=Object.keys(t);for(o=0;o<i.length;o++)e.indexOf(n=i[o])>=0||(s[n]=t[n]);return s}var rt=["context","children"],lt=["useFragment"];function at(t,e,n,o){function s(){var i=Reflect.construct(HTMLElement,[],s);return i._vdomComponent=t,i._root=i,i}return(s.prototype=Object.create(HTMLElement.prototype)).constructor=s,s.prototype.connectedCallback=function(){ct.call(this,o)},s.prototype.attributeChangedCallback=ut,s.prototype.disconnectedCallback=dt,n=n||t.observedAttributes||Object.keys(t.propTypes||{}),s.observedAttributes=n,t.formAssociated&&(s.formAssociated=!0),n.forEach(function(i){Object.defineProperty(s.prototype,i,{get:function(){return this._vdom?this._vdom.props[i]:this._props[i]},set:function(l){this._vdom?this.attributeChangedCallback(i,null,l):(this._props||(this._props={}),this._props[i]=l);var _=typeof l;l!=null&&_!=="string"&&_!=="boolean"&&_!=="number"||this.setAttribute(i,l)}})}),customElements.define(e,s),s}function _t(t){this.getChildContext=function(){return t.context};var e=t.children,n=Te(t,rt);return Ee(e,n)}function ct(t){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=L(_t,Y({},this._props,{context:e.detail.context}),Ie(this,this._vdomComponent,t)),(this.hasAttribute("hydrate")?Me:X)(this._vdom,this._root)}function He(t){return t.replace(/-(\w)/g,function(e,n){return n?n.toUpperCase():""})}function ut(t,e,n){if(this._vdom){var o={};o[t]=n=n??void 0,o[He(t)]=n,this._vdom=Ee(this._vdom,o),X(this._vdom,this._root)}}function dt(){X(this._vdom=null,this._root)}function Pe(t,e){var n=this,o=t.useFragment,s=Te(t,lt);return L(o?R:"slot",Y({},s,{ref:function(i){i?(n.ref=i,n._listener||(n._listener=function(l){l.stopPropagation(),l.detail.context=e},i.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function Ie(t,e,n){if(t.nodeType===3)return t.data;if(t.nodeType!==1)return null;var o=[],s={},i=0,l=t.attributes,_=t.childNodes;for(i=l.length;i--;)l[i].name!=="slot"&&(s[l[i].name]=l[i].value,s[He(l[i].name)]=l[i].value);for(i=_.length;i--;){var c=Ie(_[i],null,n),a=_[i].slot;a?s[a]=L(Pe,{name:a},c):o[i]=c}var d=!(!n||!n.shadow),r=e?L(Pe,{useFragment:!d},o):o;return!d&&e&&(t.innerHTML=""),L(e||t.nodeName.toLowerCase(),s,r)}var ht=0;function h(t,e,n,o,s,i){e||(e={});var l,_,c=e;if("ref"in c)for(_ in c={},e)_=="ref"?l=e[_]:c[_]=e[_];var a={type:t,props:c,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ht,__i:-1,__u:0,__source:s,__self:i};if(typeof t=="function"&&(l=t.defaultProps))for(_ in l)c[_]===void 0&&(c[_]=l[_]);return m.vnode&&m.vnode(a),a}var B,y,ce,Re,Z=0,Ue=[],w=m,De=w.__b,Oe=w.__r,Le=w.diffed,Qe=w.__c,qe=w.unmount,je=w.__;function ue(t,e){w.__h&&w.__h(y,t,Z||e),Z=0;var n=y.__H||(y.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function E(t){return Z=1,ft(Ke,t)}function ft(t,e,n){var o=ue(B++,2);if(o.t=t,!o.__c&&(o.__=[Ke(void 0,e),function(_){var c=o.__N?o.__N[0]:o.__[0],a=o.t(c,_);c!==a&&(o.__N=[a,o.__[1]],o.__c.setState({}))}],o.__c=y,!y.__f)){var s=function(_,c,a){if(!o.__c.__H)return!0;var d=o.__c.__H.__.filter(function(f){return!!f.__c});if(d.every(function(f){return!f.__N}))return!i||i.call(this,_,c,a);var r=o.__c.props!==_;return d.forEach(function(f){if(f.__N){var u=f.__[0];f.__=f.__N,f.__N=void 0,u!==f.__[0]&&(r=!0)}}),i&&i.call(this,_,c,a)||r};y.__f=!0;var i=y.shouldComponentUpdate,l=y.componentWillUpdate;y.componentWillUpdate=function(_,c,a){if(this.__e){var d=i;i=void 0,s(_,c,a),i=d}l&&l.call(this,_,c,a)},y.shouldComponentUpdate=s}return o.__N||o.__}function Be(t,e){var n=ue(B++,3);!w.__s&&Je(n.__H,e)&&(n.__=t,n.u=e,y.__H.__h.push(n))}function ze(t){return Z=5,gt(function(){return{current:t}},[])}function gt(t,e){var n=ue(B++,7);return Je(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function pt(){for(var t;t=Ue.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ee),t.__H.__h.forEach(de),t.__H.__h=[]}catch(e){t.__H.__h=[],w.__e(e,t.__v)}}w.__b=function(t){y=null,De&&De(t)},w.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),je&&je(t,e)},w.__r=function(t){Oe&&Oe(t),B=0;var e=(y=t.__c).__H;e&&(ce===y?(e.__h=[],y.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(ee),e.__h.forEach(de),e.__h=[],B=0)),ce=y},w.diffed=function(t){Le&&Le(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Ue.push(e)!==1&&Re===w.requestAnimationFrame||((Re=w.requestAnimationFrame)||mt)(pt)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ce=y=null},w.__c=function(t,e){e.some(function(n){try{n.__h.forEach(ee),n.__h=n.__h.filter(function(o){return!o.__||de(o)})}catch(o){e.some(function(s){s.__h&&(s.__h=[])}),e=[],w.__e(o,n.__v)}}),Qe&&Qe(t,e)},w.unmount=function(t){qe&&qe(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{ee(o)}catch(s){e=s}}),n.__H=void 0,e&&w.__e(e,n.__v))};var Ve=typeof requestAnimationFrame=="function";function mt(t){var e,n=function(){clearTimeout(o),Ve&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(n,35);Ve&&(e=requestAnimationFrame(n))}function ee(t){var e=y,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),y=e}function de(t){var e=y;t.__c=t.__(),y=e}function Je(t,e){return!t||t.length!==e.length||e.some(function(n,o){return n!==t[o]})}function Ke(t,e){return typeof e=="function"?e(t):e}const yt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let te=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=yt[n[t]&63];return e};class Ge{constructor(e,n){this.agentUrl=e,this.agentId=n,this.agentConfig=null,this.ws=null,this.messageCallbacks=new Set,this.connectionCallbacks=new Set,this.streamingCallbacks=new Set,this.queueCallbacks=new Set,this.messages=[],this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.reconnectDelay=1e3,this.isAgentStreaming=!1,this.messageQueue=[]}async initWidget(){try{console.log("[AriaFlow Widget] Fetching agent config...",{agentUrl:this.agentUrl,agentId:this.agentId});try{const n=await fetch(`${this.agentUrl}/api/agent/${this.agentId}`);if(n.ok){const o=await n.json();return console.log("[AriaFlow Widget] Agent config received:",o),!o||o.status!=="active"?(console.error("Agent not found or inactive"),null):(this.agentConfig=o,this.maxReconnectAttempts=o.config.maxRetries||5,this.reconnectDelay=o.config.reconnectDelay||1e3,await this.connectToAgent(),o)}}catch{console.warn("[AriaFlow Widget] Agent config endpoint not available, trying fallback")}console.log("[AriaFlow Widget] Using fallback config for Railway deployment");const e={id:this.agentId,name:this.agentId==="hospital"?"Hospital Support":"Support Agent",wsUrl:`${this.agentUrl.replace(/^https/,"wss")}/ws`,status:"active",capabilities:["chat","streaming"],config:{primaryColor:"#14B8A6",position:"bottom-right",theme:"light",title:this.agentId==="hospital"?"Hospital Support":"Chat Support",subtitle:"We're here to help!",maxRetries:3,reconnectDelay:1e3}};return this.agentConfig=e,await this.connectToAgent(),e}catch(e){return console.error("Failed to initialize widget:",e),null}}async connectToAgent(){if(!this.agentConfig?.wsUrl)throw new Error("No agent WebSocket URL configured");const e=this.getSessionId(),n=`${this.agentConfig.wsUrl}/${e}`;return console.log("[AriaFlow Widget] Connecting to WebSocket:",n),new Promise((o,s)=>{try{this.ws=new WebSocket(n),this.ws.onopen=()=>{console.log("[Widget] Connected to agent"),this.reconnectAttempts=0,this.notifyConnectionChange(!0),o()},this.ws.onmessage=i=>{this.handleMessage(i)},this.ws.onclose=()=>{if(console.log("[Widget] Disconnected from agent"),this.notifyConnectionChange(!1),this.reconnectAttempts<this.maxReconnectAttempts){this.reconnectAttempts++;const i=this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1);console.log(`[Widget] Reconnecting in ${i}ms... (attempt ${this.reconnectAttempts})`),setTimeout(()=>this.connectToAgent(),i)}},this.ws.onerror=i=>{console.error("[Widget] WebSocket error:",i),s(i)}}catch(i){s(i)}})}handleMessage(e){try{const n=JSON.parse(e.data);if(n.type==="text-delta")this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="assistant"&&s.isStreaming?[...o.slice(0,-1),{...s,content:s.content+n.text}]:[...o,{id:te(),role:"assistant",content:n.text,timestamp:Date.now(),isStreaming:!0}]});else if(n.type==="done")console.log("[Widget] Response complete"),this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="assistant"&&s.isStreaming?[...o.slice(0,-1),{...s,isStreaming:!1}]:o}),this.isAgentStreaming=!1,this.notifyStreamingChange(!1),this.processMessageQueue();else if(n.type==="tool-call"){console.log("[Widget] Tool call:",n.tool);const o={id:te(),role:"tool",content:`Calling tool: ${n.tool.name}`,timestamp:Date.now(),toolCall:{name:n.tool.name,arguments:n.tool.arguments}};this.setMessages(s=>[...s,o])}else n.type==="tool-result"?(console.log("[Widget] Tool result:",n.result),this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="tool"&&!s.toolResult?[...o.slice(0,-1),{...s,content:s.content+`
2
+ Result: ${JSON.stringify(n.result)}`,toolResult:n.result}]:o})):n.type==="agent-start"?(console.log(`[Widget] Agent started: ${n.agentId}`),this.isAgentStreaming=!0,this.notifyStreamingChange(!0)):n.type==="handoff"?console.log(`[Widget] Handoff: ${n.from} -> ${n.to}: ${n.reason}`):console.log("[Widget] Unknown message type:",n.type)}catch(n){console.error("[Widget] Error parsing message:",e.data,n)}}async sendMessage(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("Not connected to agent");const n={id:te(),role:"user",content:e,timestamp:Date.now()};if(this.setMessages(o=>[...o,n]),this.isAgentStreaming){console.log("[Widget] Agent is streaming, queuing message"),this.messageQueue.push(e),this.notifyQueueChange(this.messageQueue.length);return}this.sendToAgent(e)}async sendToAgent(e){const n=this.getSessionId();this.ws.send(JSON.stringify({message:e,sessionId:n}))}async processMessageQueue(){if(this.messageQueue.length!==0){if(this.messageQueue.length===1){const e=this.messageQueue.shift();console.log("[Widget] Sending queued message:",e),this.sendToAgent(e)}else{const e=this.messageQueue.join(`
3
+
4
+ `);this.messageQueue.length=0,console.log("[Widget] Sending combined queued messages:",e),this.sendToAgent(e)}this.notifyQueueChange(this.messageQueue.length)}}getSessionId(){let e=sessionStorage.getItem("ariaflow_session_id");return e||(e=te(),sessionStorage.setItem("ariaflow_session_id",e)),e}setMessages(e){this.messages=e(this.messages),this.messageCallbacks.forEach(n=>n(this.messages))}onMessages(e){return this.messageCallbacks.add(e),e(this.messages),()=>{this.messageCallbacks.delete(e)}}onConnectionChange(e){return this.connectionCallbacks.add(e),()=>{this.connectionCallbacks.delete(e)}}onStreamingChange(e){return this.streamingCallbacks.add(e),()=>{this.streamingCallbacks.delete(e)}}onQueueChange(e){return this.queueCallbacks.add(e),()=>{this.queueCallbacks.delete(e)}}notifyConnectionChange(e){this.connectionCallbacks.forEach(n=>n(e))}notifyStreamingChange(e){this.streamingCallbacks.forEach(n=>n(e))}notifyQueueChange(e){this.queueCallbacks.forEach(n=>n(e))}getMessages(){return this.messages}getConfig(){return this.agentConfig}isConnected(){return this.ws?.readyState===WebSocket.OPEN}dispose(){this.ws&&(this.ws.close(),this.ws=null),this.messageCallbacks.clear(),this.connectionCallbacks.clear()}}const he={none:"0",small:"0.375rem",medium:"0.75rem",large:"1rem"};function Xe({agentUrl:t,agentId:e,widgetId:n,apiUrl:o,mode:s="chat",theme:i="light",position:l="bottom-right",size:_="full",radius:c="medium",baseColor:a,accentColor:d="#14B8A6",buttonBaseColor:r="#000000",buttonAccentColor:f="#FFFFFF",title:u,subtitle:b,emptyChatMessage:A}){const[v,p]=E(!1),[g,F]=E([]),[S,U]=E(""),[$,ne]=E(!1),[k,D]=E(!1),[O,W]=E(null),[T,vt]=E(!1),[fe,wt]=E(0),ge=ze(null),Ze=ze(null);Be(()=>((async()=>{if(t&&e){console.log("[AriaFlow Widget] Using new agent resolution:",{agentUrl:t,agentId:e});const H=new Ge(t,e);ge.current=H;try{H.onMessages(N=>{console.log("[AriaFlow Widget] Messages updated:",N.length),F(N)}),H.onConnectionChange(N=>{console.log("[AriaFlow Widget] Connection state:",N),ne(N),N&&D(!0)}),H.onStreamingChange(N=>{console.log("[AriaFlow Widget] Streaming state:",N),vt(N)}),H.onQueueChange(N=>{console.log("[AriaFlow Widget] Queue count:",N),wt(N)});const z=await H.initWidget();console.log("[AriaFlow Widget] Agent config received:",z),z?(W(z),console.log("[AriaFlow Widget] Widget initialized successfully")):console.error("[AriaFlow Widget] Agent config fetch failed")}catch(z){console.error("[AriaFlow Widget] Initialization error:",z)}}else t&&!e?(console.warn("[AriaFlow Widget] Direct WebSocket URLs are deprecated. Use agent-url + agent-id instead."),console.error("[AriaFlow Widget] Configuration error: agent-id is required")):o&&n?(console.warn("[AriaFlow Widget] Legacy widget config is deprecated. Use agent-url + agent-id instead."),console.error("[AriaFlow Widget] Configuration error: use agent-url + agent-id instead")):console.error("[AriaFlow Widget] Invalid configuration. Provide agent-url and agent-id.")})(),()=>{ge.current?.dispose()}),[t,e,n,o]),Be(()=>{Ze.current?.scrollIntoView({behavior:"smooth"})},[g]);const et=async()=>{if(!S.trim()||!$)return;const C=S.trim();U("");try{await ge.current?.sendMessage(C)}catch(H){console.error("Failed to send message:",H)}},bt=C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),et())},Ct=u||O?.title||"Chat with us",kt=b||O?.subtitle||"We typically reply within minutes",At=A||O?.config?.emptyChatMessage||"Start a conversation...";return console.log("[AriaFlow Widget] Rendering widget component",{isInitialized:k,isOpen:v,position:l}),h("div",{className:`ariaflow-widget-container ariaflow-widget-${l} ariaflow-widget-${_} ariaflow-widget-radius-${c}`,"data-theme":i,style:{"--ariaflow-accent-color":d,"--ariaflow-base-color":a},children:[!v&&h("button",{className:"ariaflow-widget-launcher",onClick:()=>p(!0),style:{backgroundColor:r,color:f,opacity:k?1:.8,cursor:k?"pointer":"wait",position:"relative"},"aria-label":k?"Open chat":"Connecting to agent...",disabled:!k,title:k?"Click to start chat":"Connecting to agent...",children:[!k&&h("div",{className:"ariaflow-widget-launcher-loading",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"20px",height:"20px",border:`2px solid ${f}`,borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}}),k&&h("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})]}),v&&k&&h("div",{className:"ariaflow-widget-window",style:{backgroundColor:i==="dark"&&a?a:void 0,borderRadius:he[c]},children:[h("div",{className:"ariaflow-widget-header",style:{backgroundColor:d,borderRadius:c==="none"?"0":`${he[c]} ${he[c]} 0 0`},children:[h("div",{className:"ariaflow-widget-header-content",children:h("div",{className:"ariaflow-widget-title-group",children:[h("h3",{className:"ariaflow-widget-title",children:Ct}),h("p",{className:"ariaflow-widget-subtitle",children:kt})]})}),h("button",{className:"ariaflow-widget-close",onClick:()=>p(!1),"aria-label":"Close chat",children:h("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),h("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),!$&&h("div",{className:"ariaflow-widget-status",children:[h("span",{className:"ariaflow-widget-status-dot"}),"Connecting..."]}),h("div",{className:"ariaflow-widget-messages",children:g.length===0?h("div",{className:"ariaflow-widget-empty",children:h("p",{children:$?At:"Connecting to agent..."})}):h(R,{children:[g.map(C=>h("div",{className:`ariaflow-widget-message ariaflow-widget-message-${C.role}`,children:h("div",{className:"ariaflow-widget-message-bubble",children:C.role==="tool"?h("div",{className:"ariaflow-widget-tool-message",children:[h("div",{className:"ariaflow-widget-tool-header",children:["🔧 ",C.toolCall?.name]}),h("div",{className:"ariaflow-widget-tool-content",children:[C.toolCall&&h("div",{className:"ariaflow-widget-tool-args",children:[h("strong",{children:"Arguments:"})," ",JSON.stringify(C.toolCall.arguments,null,2)]}),C.toolResult&&h("div",{className:"ariaflow-widget-tool-result",children:[h("strong",{children:"Result:"})," ",JSON.stringify(C.toolResult,null,2)]})]})]}):h(R,{children:[C.content,C.isStreaming&&h("span",{className:"ariaflow-widget-typing-indicator",children:[h("span",{children:"•"}),h("span",{children:"•"}),h("span",{children:"•"})]})]})})},C.id)),h("div",{ref:Ze})]})}),h("div",{className:"ariaflow-widget-input",children:[h("textarea",{value:S,onInput:C=>U(C.target.value),onKeyDown:bt,placeholder:$?T?fe>0?`Agent is responding... (${fe} message${fe>1?"s":""} queued)`:"Agent is responding...":"Type your message...":"Connecting...",rows:1,disabled:!$}),h("button",{className:"ariaflow-widget-send",onClick:et,disabled:!S.trim()||!$,style:{backgroundColor:d},"aria-label":"Send message",children:h("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),h("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})]})}at(Xe,"ariaflow-widget",["agent-url","agent-id","widget-id","api-url","mode","theme","position","size","radius","base-color","accent-color","button-base-color","button-accent-color","title","subtitle","empty-chat-message"],!1),typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Ye):Ye());function Ye(){const t=document.querySelectorAll("ariaflow-widget");console.log(`[AriaFlow] Initializing ${t.length} widget(s)`)}P.Widget=Xe,P.WidgetClient=Ge,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariaflowagents/widget",
3
- "version": "0.5.10",
3
+ "version": "0.5.11",
4
4
  "type": "module",
5
5
  "description": "Embeddable chat widget for AriaFlow Universal Inbox",
6
6
  "main": "./dist/widget.js",