@aginies/embed 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aginies.js +126 -8
- package/dist/aginies.js.map +1 -1
- package/package.json +1 -1
package/dist/aginies.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";var Aginies=(()=>{var fe=Object.defineProperty;var wn=Object.getOwnPropertyDescriptor;var Cn=Object.getOwnPropertyNames;var Fn=Object.prototype.hasOwnProperty;var An=(t,e,n)=>e in t?fe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Sn=(t,e)=>{for(var n in e)fe(t,n,{get:e[n],enumerable:!0})},En=(t,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Cn(e))!Fn.call(t,r)&&r!==n&&fe(t,r,{get:()=>e[r],enumerable:!(a=wn(e,r))||a.enumerable});return t};var Pn=t=>En(fe({},"__esModule",{value:!0}),t);var O=(t,e,n)=>An(t,typeof e!="symbol"?e+"":e,n);var Fa={};Sn(Fa,{approval:()=>xn,autoload:()=>kn,chat:()=>vn,init:()=>bn,version:()=>ka});var ye,b,st,Rn,G,rt,lt,ut,Me,me,ue,dt,Le,Be,Ie,ct,be={},ve=[],Nn=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,de=Array.isArray;function $(t,e){for(var n in e)t[n]=e[n];return t}function He(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function j(t,e,n){var a,r,i,s={};for(i in e)i=="key"?a=e[i]:i=="ref"?r=e[i]:s[i]=e[i];if(arguments.length>2&&(s.children=arguments.length>3?ye.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)s[i]===void 0&&(s[i]=t.defaultProps[i]);return he(t,s,a,r,null)}function he(t,e,n,a,r){var i={type:t,props:e,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++st,__i:-1,__u:0};return r==null&&b.vnode!=null&&b.vnode(i),i}function P(t){return t.children}function q(t,e){this.props=t,this.context=e}function X(t,e){if(e==null)return t.__?X(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"?X(t):null}function Tn(t){if(t.__P&&t.__d){var e=t.__v,n=e.__e,a=[],r=[],i=$({},e);i.__v=e.__v+1,b.vnode&&b.vnode(i),Oe(t.__P,i,e,t.__n,t.__P.namespaceURI,32&e.__u?[n]:null,a,n??X(e),!!(32&e.__u),r),i.__v=e.__v,i.__.__k[i.__i]=i,mt(a,i,r),e.__e=e.__=null,i.__e!=n&&pt(i)}}function pt(t){if((t=t.__)!=null&&t.__c!=null)return t.__e=t.__c.base=null,t.__k.some(function(e){if(e!=null&&e.__e!=null)return t.__e=t.__c.base=e.__e}),pt(t)}function ze(t){(!t.__d&&(t.__d=!0)&&G.push(t)&&!xe.__r++||rt!=b.debounceRendering)&&((rt=b.debounceRendering)||lt)(xe)}function xe(){try{for(var t,e=1;G.length;)G.length>e&&G.sort(ut),t=G.shift(),e=G.length,Tn(t)}finally{G.length=xe.__r=0}}function gt(t,e,n,a,r,i,s,d,c,u,g){var f,l,p,_,v,x,y=a&&a.__k||ve,m=e.length;for(c=Mn(n,e,y,c,m),f=0;f<m;f++)(p=n.__k[f])!=null&&(l=p.__i!=-1&&y[p.__i]||be,p.__i=f,x=Oe(t,p,l,r,i,s,d,c,u,g),_=p.__e,p.ref&&l.ref!=p.ref&&(l.ref&&qe(l.ref,null,p),g.push(p.ref,p.__c||_,p)),v==null&&_!=null&&(v=_),4&p.__u?(c=ft(p,c,t),l.__e&&(l.__e=null)):typeof p.type=="function"&&x!==void 0?c=x:_&&(c=_.nextSibling),p.__u&=-7);return n.__e=v,c}function Mn(t,e,n,a,r){var i,s,d,c,u,g=n.length,f=g,l=0;for(t.__k=new Array(r),i=0;i<r;i++)(s=e[i])!=null&&typeof s!="boolean"&&typeof s!="function"?(typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?s=t.__k[i]=he(null,s,null,null,null):de(s)?s=t.__k[i]=he(P,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?s=t.__k[i]=he(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):t.__k[i]=s,c=i+l,s.__=t,s.__b=t.__b+1,d=null,(u=s.__i=Bn(s,n,c,f))!=-1&&(f--,(d=n[u])&&(d.__u|=2)),d==null||d.__v==null?(u==-1&&(r>g?l--:r<g&&l++),typeof s.type!="function"&&(s.__u|=4)):u!=c&&(u==c-1?l--:u==c+1?l++:(u>c?l--:l++,s.__u|=4))):t.__k[i]=null;if(f)for(i=0;i<g;i++)(d=n[i])!=null&&(2&d.__u)==0&&(d.__e==a&&(a=X(d)),bt(d,d));return a}function ft(t,e,n){var a,r;if(typeof t.type=="function"){for(a=t.__k,r=0;a&&r<a.length;r++)a[r]&&(a[r].__=t,e=ft(a[r],e,n));return e}t.__e!=e&&(e&&t.type&&!e.parentNode&&(e=X(t)),e=n.insertBefore(t.__e,e||null));do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function ce(t,e){return e=e||[],t==null||typeof t=="boolean"||(de(t)?t.some(function(n){ce(n,e)}):e.push(t)),e}function Bn(t,e,n,a){var r,i,s,d=t.key,c=t.type,u=e[n],g=u!=null&&(2&u.__u)==0;if(u===null&&d==null||g&&d==u.key&&c==u.type)return n;if(a>(g?1:0)){for(r=n-1,i=n+1;r>=0||i<e.length;)if((u=e[s=r>=0?r--:i++])!=null&&(2&u.__u)==0&&d==u.key&&c==u.type)return s}return-1}function it(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||Nn.test(e)?n:n+"px"}function _e(t,e,n,a,r){var i,s;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof a=="string"&&(t.style.cssText=a=""),a)for(e in a)n&&e in n||it(t.style,e,"");if(n)for(e in n)a&&n[e]==a[e]||it(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")i=e!=(e=e.replace(dt,"$1")),s=e.toLowerCase(),e=s in t||e=="onFocusOut"||e=="onFocusIn"?s.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+i]=n,n?a?n[ue]=a[ue]:(n[ue]=Le,t.addEventListener(e,i?Ie:Be,i)):t.removeEventListener(e,i?Ie:Be,i);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 ot(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e[me]==null)e[me]=Le++;else if(e[me]<n[ue])return;return n(b.event?b.event(e):e)}}}function Oe(t,e,n,a,r,i,s,d,c,u){var g,f,l,p,_,v,x,y,m,F,k,S,H,ee,W,C,h=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),i=[d=e.__e=n.__e]),(g=b.__b)&&g(e);e:if(typeof h=="function"){f=s.length;try{if(m=e.props,F=h.prototype&&h.prototype.render,k=(g=h.contextType)&&a[g.__c],S=g?k?k.props.value:g.__:a,n.__c?y=(l=e.__c=n.__c).__=l.__E:(F?e.__c=l=new h(m,S):(e.__c=l=new q(m,S),l.constructor=h,l.render=zn),k&&k.sub(l),l.state||(l.state={}),l.__n=a,p=l.__d=!0,l.__h=[],l._sb=[]),F&&l.__s==null&&(l.__s=l.state),F&&h.getDerivedStateFromProps!=null&&(l.__s==l.state&&(l.__s=$({},l.__s)),$(l.__s,h.getDerivedStateFromProps(m,l.__s))),_=l.props,v=l.state,l.__v=e,p)F&&h.getDerivedStateFromProps==null&&l.componentWillMount!=null&&l.componentWillMount(),F&&l.componentDidMount!=null&&l.__h.push(l.componentDidMount);else{if(F&&h.getDerivedStateFromProps==null&&m!==_&&l.componentWillReceiveProps!=null&&l.componentWillReceiveProps(m,S),e.__v==n.__v||!l.__e&&l.shouldComponentUpdate!=null&&l.shouldComponentUpdate(m,l.__s,S)===!1){e.__v!=n.__v&&(l.props=m,l.state=l.__s,l.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(R){R&&(R.__=e)}),ve.push.apply(l.__h,l._sb),l._sb=[],l.__h.length&&s.push(l),d=X(n);break e}l.componentWillUpdate!=null&&l.componentWillUpdate(m,l.__s,S),F&&l.componentDidUpdate!=null&&l.__h.push(function(){l.componentDidUpdate(_,v,x)})}if(l.context=S,l.props=m,l.__P=t,l.__e=!1,H=b.__r,ee=0,F)l.state=l.__s,l.__d=!1,H&&H(e),g=l.render(l.props,l.state,l.context),ve.push.apply(l.__h,l._sb),l._sb=[];else do l.__d=!1,H&&H(e),g=l.render(l.props,l.state,l.context),l.state=l.__s;while(l.__d&&++ee<25);l.state=l.__s,l.getChildContext!=null&&(a=$($({},a),l.getChildContext())),F&&!p&&l.getSnapshotBeforeUpdate!=null&&(x=l.getSnapshotBeforeUpdate(_,v)),W=g!=null&&g.type===P&&g.key==null?ht(g.props.children):g,d=gt(t,de(W)?W:[W],e,n,a,r,i,s,d,c,u),l.base=e.__e,e.__u&=-161,l.__h.length&&s.push(l),y&&(l.__E=l.__=null)}catch(R){if(s.length=f,e.__v=null,c||i!=null){if(R.then){for(e.__u|=c?160:128;d&&d.nodeType==8&&d.nextSibling;)d=d.nextSibling;i!=null&&(i[i.indexOf(d)]=null),e.__e=d}else if(i!=null)for(C=i.length;C--;)He(i[C])}else e.__e=n.__e;e.__k==null&&(e.__k=n.__k||[]),R.then||_t(e),b.__e(R,e,n)}}else i==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):d=e.__e=In(n.__e,e,n,a,r,i,s,c,u);return(g=b.diffed)&&g(e),128&e.__u?void 0:d}function _t(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(_t))}function mt(t,e,n){for(var a=0;a<n.length;a++)qe(n[a],n[++a],n[++a]);b.__c&&b.__c(e,t),t.some(function(r){try{t=r.__h,r.__h=[],t.some(function(i){i.call(r)})}catch(i){b.__e(i,r.__v)}})}function ht(t){return typeof t!="object"||t==null||t.__b>0?t:de(t)?t.map(ht):t.constructor!==void 0?null:$({},t)}function In(t,e,n,a,r,i,s,d,c){var u,g,f,l,p,_,v,x=n.props||be,y=e.props,m=e.type;if(m=="svg"?r="http://www.w3.org/2000/svg":m=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),i!=null){for(u=0;u<i.length;u++)if((p=i[u])&&"setAttribute"in p==!!m&&(m?p.localName==m:p.nodeType==3)){t=p,i[u]=null;break}}if(t==null){if(m==null)return document.createTextNode(y);t=document.createElementNS(r,m,y.is&&y),d&&(b.__m&&b.__m(e,i),d=!1),i=null}if(m==null)x===y||d&&t.data==y||(t.data=y);else{if(i=m=="textarea"&&y.defaultValue!=null?null:i&&ye.call(t.childNodes),!d&&i!=null)for(x={},u=0;u<t.attributes.length;u++)x[(p=t.attributes[u]).name]=p.value;for(u in x)p=x[u],u=="dangerouslySetInnerHTML"?f=p:u=="children"||u in y||u=="value"&&"defaultValue"in y||u=="checked"&&"defaultChecked"in y||_e(t,u,null,p,r);for(u in y)p=y[u],u=="children"?l=p:u=="dangerouslySetInnerHTML"?g=p:u=="value"?_=p:u=="checked"?v=p:d&&typeof p!="function"||x[u]===p||_e(t,u,p,x[u],r);if(g)d||f&&(g.__html==f.__html||g.__html==t.innerHTML)||(t.innerHTML=g.__html),e.__k=[];else if(f&&(t.innerHTML=""),gt(e.type=="template"?t.content:t,de(l)?l:[l],e,n,a,m=="foreignObject"?"http://www.w3.org/1999/xhtml":r,i,s,i?i[0]:n.__k&&X(n,0),d,c),i!=null)for(u=i.length;u--;)He(i[u]);d&&m!="textarea"||(u="value",m=="progress"&&_==null?t.removeAttribute("value"):_!=null&&(_!==t[u]||m=="progress"&&!_||m=="option"&&_!=x[u])&&_e(t,u,_,x[u],r),u="checked",v!=null&&v!=t[u]&&_e(t,u,v,x[u],r))}return t}function qe(t,e,n){try{if(typeof t=="function"){var a=typeof t.__u=="function";a&&t.__u(),a&&e==null||(t.__u=t(e))}else t.current=e}catch(r){b.__e(r,n)}}function bt(t,e,n){var a,r;if(b.unmount&&b.unmount(t),(a=t.ref)&&(a.current&&a.current!=t.__e||qe(a,null,e)),(a=t.__c)!=null){if(a.componentWillUnmount)try{a.componentWillUnmount()}catch(i){b.__e(i,e)}a.base=a.__P=a.__n=null}if(a=t.__k)for(r=0;r<a.length;r++)a[r]&&bt(a[r],e,n||typeof t.type!="function");n||He(t.__e),t.__c=t.__=t.__e=void 0}function zn(t,e,n){return this.constructor(t,n)}function Ue(t,e,n){var a,r,i,s;e==document&&(e=document.documentElement),b.__&&b.__(t,e),r=(a=typeof n=="function")?null:n&&n.__k||e.__k,i=[],s=[],Oe(e,t=(!a&&n||e).__k=j(P,null,[t]),r||be,be,e.namespaceURI,!a&&n?[n]:r?null:e.firstChild?ye.call(e.childNodes):null,i,!a&&n?n:r?r.__e:e.firstChild,a,s),mt(i,t,s),t.props.children=null}function ke(t){function e(n){var a,r;return this.getChildContext||(a=new Set,(r={})[e.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){a=null},this.shouldComponentUpdate=function(i){this.props.value!=i.value&&a.forEach(function(s){s.__e=!0,ze(s)})},this.sub=function(i){a.add(i);var s=i.componentWillUnmount;i.componentWillUnmount=function(){a&&a.delete(i),s&&s.call(i)}}),n.children}return e.__c="__cC"+ct++,e.__=t,e.Provider=e.__l=(e.Consumer=function(n,a){return n.children(a)}).contextType=e,e}ye=ve.slice,b={__e:function(t,e,n,a){for(var r,i,s;e=e.__;)if((r=e.__c)&&!r.__)try{if((i=r.constructor)&&i.getDerivedStateFromError!=null&&(r.setState(i.getDerivedStateFromError(t)),s=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(t,a||{}),s=r.__d),s)return r.__E=r}catch(d){t=d}throw t}},st=0,Rn=function(t){return t!=null&&t.constructor===void 0},q.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=$({},this.state),typeof t=="function"&&(t=t($({},n),this.props)),t&&$(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),ze(this))},q.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),ze(this))},q.prototype.render=P,G=[],lt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ut=function(t,e){return t.__v.__b-e.__v.__b},xe.__r=0,Me=Math.random().toString(8),me="__d"+Me,ue="__a"+Me,dt=/(PointerCapture)$|Capture$/i,Le=0,Be=ot(!1),Ie=ot(!0),ct=0;var ne,A,De,vt,pe=0,St=[],N=b,xt=N.__b,yt=N.__r,kt=N.diffed,wt=N.__c,Ct=N.unmount,Ft=N.__;function Ce(t,e){N.__h&&N.__h(A,t,pe||e),pe=0;var n=A.__H||(A.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function w(t){return pe=1,Et(Rt,t)}function Et(t,e,n){var a=Ce(ne++,2);if(a.t=t,!a.__c&&(a.__=[n?n(e):Rt(void 0,e),function(d){var c=a.__N?a.__N[0]:a.__[0],u=a.t(c,d);c!==u&&(a.__N=[u,a.__[1]],a.__c.setState({}))}],a.__c=A,!A.__f)){var r=function(d,c,u){if(!a.__c.__H)return!0;var g=!1,f=a.__c.props!==d;if(a.__c.__H.__.some(function(p){if(p.__N){g=!0;var _=p.__[0];p.__=p.__N,p.__N=void 0,_!==p.__[0]&&(f=!0)}}),i){var l=i.call(this,d,c,u);return g?l||f:l}return!g||f};A.__f=!0;var i=A.shouldComponentUpdate,s=A.componentWillUpdate;A.componentWillUpdate=function(d,c,u){if(this.__e){var g=i;i=void 0,r(d,c,u),i=g}s&&s.call(this,d,c,u)},A.shouldComponentUpdate=r}return a.__N||a.__}function U(t,e){var n=Ce(ne++,3);!N.__s&&Pt(n.__H,e)&&(n.__=t,n.u=e,A.__H.__h.push(n))}function K(t){return pe=5,Q(function(){return{current:t}},[])}function Q(t,e){var n=Ce(ne++,7);return Pt(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function z(t,e){return pe=8,Q(function(){return t},e)}function $e(t){var e=A.context[t.__c],n=Ce(ne++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(A)),e.props.value):t.__}function Ln(){for(var t;t=St.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(we),e.__h.some(je),e.__h=[]}catch(n){e.__h=[],N.__e(n,t.__v)}}}N.__b=function(t){A=null,xt&&xt(t)},N.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Ft&&Ft(t,e)},N.__r=function(t){yt&&yt(t),ne=0;var e=(A=t.__c).__H;e&&(De===A?(e.__h=[],A.__h=[],e.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.some(we),e.__h.some(je),e.__h=[],ne=0)),De=A},N.diffed=function(t){kt&&kt(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(St.push(e)!==1&&vt===N.requestAnimationFrame||((vt=N.requestAnimationFrame)||Hn)(Ln)),e.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),De=A=null},N.__c=function(t,e){e.some(function(n){try{n.__h.some(we),n.__h=n.__h.filter(function(a){return!a.__||je(a)})}catch(a){e.some(function(r){r.__h&&(r.__h=[])}),e=[],N.__e(a,n.__v)}}),wt&&wt(t,e)},N.unmount=function(t){Ct&&Ct(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.some(function(a){try{we(a)}catch(r){e=r}}),n.__H=void 0,e&&N.__e(e,n.__v))};var At=typeof requestAnimationFrame=="function";function Hn(t){var e,n=function(){clearTimeout(a),At&&cancelAnimationFrame(e),setTimeout(t)},a=setTimeout(n,35);At&&(e=requestAnimationFrame(n))}function we(t){var e=A,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),A=e}function je(t){var e=A;t.__c=t.__(),A=e}function Pt(t,e){return!t||t.length!==e.length||e.some(function(n,a){return n!==t[a]})}function Rt(t,e){return typeof e=="function"?e(t):e}function qt(t,e){for(var n in e)t[n]=e[n];return t}function Nt(t,e){for(var n in t)if(n!=="__source"&&!(n in e))return!0;for(var a in e)if(a!=="__source"&&t[a]!==e[a])return!0;return!1}function Tt(t,e){this.props=t,this.context=e}(Tt.prototype=new q).isPureReactComponent=!0,Tt.prototype.shouldComponentUpdate=function(t,e){return Nt(this.props,t)||Nt(this.state,e)};var Mt=b.__b;b.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),Mt&&Mt(t)};var qn=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function Ae(t){function e(n){var a=qt({},n);return delete a.ref,t(a,n.ref||null)}return e.$$typeof=qn,e.render=t,e.prototype.isReactComponent=e.__f=!0,e.displayName="ForwardRef("+(t.displayName||t.name)+")",e}var Un=b.__e;b.__e=function(t,e,n,a){if(t.then){for(var r,i=e;i=i.__;)if((r=i.__c)&&r.__c)return e.__e==null&&(e.__e=n.__e,e.__k=n.__k||[]),r.__c(t,e)}Un(t,e,n,a)};var Bt=b.unmount;function Ut(t,e,n){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(a){typeof a.__c=="function"&&a.__c()}),t.__c.__H=null),(t=qt({},t)).__c!=null&&(t.__c.__P===n&&(t.__c.__P=e),t.__c.__e=!0,t.__c=null),t.__k=t.__k&&t.__k.map(function(a){return Ut(a,e,n)})),t}function Dt(t,e,n){return t&&n&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(a){return Dt(a,e,n)}),t.__c&&t.__c.__P===e&&(t.__e&&n.appendChild(t.__e),t.__c.__e=!0,t.__c.__P=n)),t}function Ve(){this.__u=0,this.o=null,this.__b=null}function jt(t){var e=t.__&&t.__.__c;return e&&e.__a&&e.__a(t)}function Fe(){this.i=null,this.l=null}b.unmount=function(t){var e=t.__c;e&&(e.__z=!0),e&&e.__R&&e.__R(),e&&32&t.__u&&(t.type=null),Bt&&Bt(t)},(Ve.prototype=new q).__c=function(t,e){var n=e.__c,a=this;a.o==null&&(a.o=[]),a.o.push(n);var r=jt(a.__v),i=!1,s=function(){i||a.__z||(i=!0,n.__R=null,r?r(c):c())};n.__R=s;var d=n.__P;n.__P=null;var c=function(){if(!--a.__u){if(a.state.__a){var u=a.state.__a;a.__v.__k[0]=Dt(u,u.__c.__P,u.__c.__O)}var g;for(a.setState({__a:a.__b=null});g=a.o.pop();)g.__P=d,g.forceUpdate()}};a.__u++||32&e.__u||a.setState({__a:a.__b=a.__v.__k[0]}),t.then(s,s)},Ve.prototype.componentWillUnmount=function(){this.o=[]},Ve.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),a=this.__v.__k[0].__c;this.__v.__k[0]=Ut(this.__b,n,a.__O=a.__P)}this.__b=null}var r=e.__a&&j(P,null,t.fallback);return r&&(r.__u&=-33),[j(P,null,e.__a?null:t.children),r]};var It=function(t,e,n){if(++n[1]===n[0]&&t.l.delete(e),t.props.revealOrder&&(t.props.revealOrder[0]!=="t"||!t.l.size))for(n=t.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;t.i=n=n[2]}};(Fe.prototype=new q).__a=function(t){var e=this,n=jt(e.__v),a=e.l.get(t);return a[0]++,function(r){var i=function(){e.props.revealOrder?(a.push(r),It(e,t,a)):r()};n?n(i):i()}},Fe.prototype.render=function(t){this.i=null,this.l=new Map;var e=ce(t.children);t.revealOrder&&t.revealOrder[0]==="b"&&e.reverse();for(var n=e.length;n--;)this.l.set(e[n],this.i=[1,0,this.i]);return t.children},Fe.prototype.componentDidUpdate=Fe.prototype.componentDidMount=function(){var t=this;this.l.forEach(function(e,n){It(t,n,e)})};var Dn=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,jn=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,$n=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Vn=/[A-Z0-9]/g,Wn=typeof document<"u",Jn=function(t){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(t)};function $t(t,e,n){return e.__k==null&&(e.textContent=""),Ue(t,e),typeof n=="function"&&n(),t?t.__c:null}q.prototype.isReactComponent=!0,["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(t){Object.defineProperty(q.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})});var zt=b.event;b.event=function(t){return zt&&(t=zt(t)),t.persist=function(){},t.isPropagationStopped=function(){return this.cancelBubble},t.isDefaultPrevented=function(){return this.defaultPrevented},t.nativeEvent=t};var Vt,Gn={configurable:!0,get:function(){return this.class}},Lt=b.vnode;b.vnode=function(t){typeof t.type=="string"&&(function(e){var n=e.props,a=e.type,r={},i=a.indexOf("-")==-1;for(var s in n){var d=n[s];if(!(s==="value"&&"defaultValue"in n&&d==null||Wn&&s==="children"&&a==="noscript"||s==="class"||s==="className")){var c=s.toLowerCase();s==="defaultValue"&&"value"in n&&n.value==null?s="value":s==="download"&&d===!0?d="":c==="translate"&&d==="no"?d=!1:c[0]==="o"&&c[1]==="n"?c==="ondoubleclick"?s="ondblclick":c!=="onchange"||a!=="input"&&a!=="textarea"||Jn(n.type)?c==="onfocus"?s="onfocusin":c==="onblur"?s="onfocusout":$n.test(s)&&(s=c):c=s="oninput":i&&jn.test(s)?s=s.replace(Vn,"-$&").toLowerCase():d===null&&(d=void 0),c==="oninput"&&r[s=c]&&(s="oninputCapture"),r[s]=d}}a=="select"&&(r.multiple&&Array.isArray(r.value)&&(r.value=ce(n.children).forEach(function(u){u.props.selected=r.value.indexOf(u.props.value)!=-1})),r.defaultValue!=null&&(r.value=ce(n.children).forEach(function(u){u.props.selected=r.multiple?r.defaultValue.indexOf(u.props.value)!=-1:r.defaultValue==u.props.value}))),n.class&&!n.className?(r.class=n.class,Object.defineProperty(r,"className",Gn)):n.className&&(r.class=r.className=n.className),e.props=r})(t),t.$$typeof=Dn,Lt&&Lt(t)};var Ht=b.__r;b.__r=function(t){Ht&&Ht(t),Vt=t.__c};var Ot=b.diffed;b.diffed=function(t){Ot&&Ot(t);var e=t.props,n=t.__e;n!=null&&t.type==="textarea"&&"value"in e&&e.value!==n.value&&(n.value=e.value==null?"":e.value),Vt=null};function Wt(t){return!!t.__k&&(Ue(null,t),!0)}var M=class extends Error{constructor(n,a,r){super(n);O(this,"status");O(this,"code");this.name="AginiesError",this.status=a,this.code=r}},Kn=t=>t.replace(/\/+$/,""),Ee=class{constructor(e){O(this,"baseUrl");O(this,"token");O(this,"locale");O(this,"fetchImpl");O(this,"state",{status:"idle"});O(this,"listeners",new Set);O(this,"activation",null);O(this,"session",null);if(!e?.baseUrl)throw new M("baseUrl is required",0,"MISSING_BASE_URL");if(!e?.token)throw new M("token is required",0,"MISSING_TOKEN");this.baseUrl=Kn(e.baseUrl),this.token=e.token,this.locale=e.locale??Yn(),this.fetchImpl=e.fetch??((...n)=>fetch(...n))}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}setState(e){this.state=e;for(let n of this.listeners)n(e)}activate(){return this.activation?this.activation:(this.setState({status:"activating"}),this.activation=(async()=>{try{let e=await this.fetchImpl(`${this.baseUrl}/api/ui/activate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:this.token})});if(!e.ok){let a=await Se(e),r=a&&a.error||`HTTP ${e.status}`;return this.setState({status:"rejected",reason:r}),this.state}let n=await e.json();return!n.activated||!n.config?(this.setState({status:"rejected",reason:"Activation refused"}),this.state):(this.session=n.session??null,this.setState({status:"active",config:n.config}),this.state)}catch(e){return this.setState({status:"rejected",reason:e instanceof Error?e.message:"Activation failed"}),this.state}})(),this.activation)}assertActive(){if(this.state.status!=="active")throw new M("Client is not activated",0,"NOT_ACTIVATED")}getSession(){return this.session}hasModule(e){if(this.state.status!=="active")return!1;let n=this.state.config.modules??[];return n.length===0||n.includes(e)}async renewSession(){return this.activation=null,(await this.activate()).status==="active"&&this.session!==null}withSession(e){if(!this.session)return e;let n=new Headers(e.headers??{});return n.has("Authorization")||n.set("Authorization",`Bearer ${this.session.token}`),{...e,headers:n}}async request(e,n={}){let a=`${this.baseUrl}${e.startsWith("/")?e:`/${e}`}`,r=()=>this.fetchImpl(a,this.withSession({credentials:"include",...n})),i=await r();return this.session&&(i.status===401||i.status===403)&&this.session.expiresAt*1e3<=Date.now()+5e3&&await this.renewSession()&&(i=await r()),i}fetchRaw(e,n={}){return this.assertActive(),this.request(e,n)}async getChat(e){this.assertActive();let n=await this.request(`/api/chat/${encodeURIComponent(e)}`),a=await Se(n);if(n.status===401&&a&&typeof a.authRequired=="string")return a;if(!n.ok)throw new M(a?.error||`HTTP ${n.status}`,n.status);return a}async*sendMessage(e,n,a){this.assertActive();let r=await this.request(`/api/chat/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n),signal:a});if(!r.ok){let s=await Se(r);throw r.status===401&&s&&typeof s.authRequired=="string"?new M("Authentication required",401,"AUTH_REQUIRED"):new M(s?.error||`HTTP ${r.status}`,r.status)}if(!(r.headers.get("content-type")??"").includes("text/event-stream")){yield{type:"final",data:await Se(r)},yield{type:"done"};return}yield*Qn(r.body)}};async function*Qn(t){let e=t.getReader(),n=new TextDecoder,a="";try{for(;;){let{done:i,value:s}=await e.read();if(i)break;a+=n.decode(s,{stream:!0});let d=a.indexOf(`
|
|
1
|
+
"use strict";var Aginies=(()=>{var ve=Object.defineProperty;var In=Object.getOwnPropertyDescriptor;var zn=Object.getOwnPropertyNames;var Un=Object.prototype.hasOwnProperty;var Hn=(t,e,n)=>e in t?ve(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var On=(t,e)=>{for(var n in e)ve(t,n,{get:e[n],enumerable:!0})},Dn=(t,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of zn(e))!Un.call(t,r)&&r!==n&&ve(t,r,{get:()=>e[r],enumerable:!(a=In(e,r))||a.enumerable});return t};var qn=t=>Dn(ve({},"__esModule",{value:!0}),t);var G=(t,e,n)=>Hn(t,typeof e!="symbol"?e+"":e,n);var $a={};On($a,{approval:()=>Tn,autoload:()=>Mn,chat:()=>Pn,init:()=>Rn,version:()=>Da});var Fe,k,_t,jn,ne,gt,bt,ht,ze,ye,ge,vt,De,Ue,He,xt,we={},Ce=[],$n=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,fe=Array.isArray;function Y(t,e){for(var n in e)t[n]=e[n];return t}function qe(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Q(t,e,n){var a,r,i,l={};for(i in e)i=="key"?a=e[i]:i=="ref"?r=e[i]:l[i]=e[i];if(arguments.length>2&&(l.children=arguments.length>3?Fe.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 ke(t,l,a,r,null)}function ke(t,e,n,a,r){var i={type:t,props:e,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++_t,__i:-1,__u:0};return r==null&&k.vnode!=null&&k.vnode(i),i}function T(t){return t.children}function K(t,e){this.props=t,this.context=e}function le(t,e){if(e==null)return t.__?le(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"?le(t):null}function Vn(t){if(t.__P&&t.__d){var e=t.__v,n=e.__e,a=[],r=[],i=Y({},e);i.__v=e.__v+1,k.vnode&&k.vnode(i),je(t.__P,i,e,t.__n,t.__P.namespaceURI,32&e.__u?[n]:null,a,n??le(e),!!(32&e.__u),r),i.__v=e.__v,i.__.__k[i.__i]=i,At(a,i,r),e.__e=e.__=null,i.__e!=n&&yt(i)}}function yt(t){if((t=t.__)!=null&&t.__c!=null)return t.__e=t.__c.base=null,t.__k.some(function(e){if(e!=null&&e.__e!=null)return t.__e=t.__c.base=e.__e}),yt(t)}function Oe(t){(!t.__d&&(t.__d=!0)&&ne.push(t)&&!Ae.__r++||gt!=k.debounceRendering)&&((gt=k.debounceRendering)||bt)(Ae)}function Ae(){try{for(var t,e=1;ne.length;)ne.length>e&&ne.sort(ht),t=ne.shift(),e=ne.length,Vn(t)}finally{ne.length=Ae.__r=0}}function kt(t,e,n,a,r,i,l,c,d,u,p){var b,s,g,f,C,w,y=a&&a.__k||Ce,m=e.length;for(d=Wn(n,e,y,d,m),b=0;b<m;b++)(g=n.__k[b])!=null&&(s=g.__i!=-1&&y[g.__i]||we,g.__i=b,w=je(t,g,s,r,i,l,c,d,u,p),f=g.__e,g.ref&&s.ref!=g.ref&&(s.ref&&$e(s.ref,null,g),p.push(g.ref,g.__c||f,g)),C==null&&f!=null&&(C=f),4&g.__u?(d=wt(g,d,t),s.__e&&(s.__e=null)):typeof g.type=="function"&&w!==void 0?d=w:f&&(d=f.nextSibling),g.__u&=-7);return n.__e=C,d}function Wn(t,e,n,a,r){var i,l,c,d,u,p=n.length,b=p,s=0;for(t.__k=new Array(r),i=0;i<r;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]=ke(null,l,null,null,null):fe(l)?l=t.__k[i]=ke(T,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=t.__k[i]=ke(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):t.__k[i]=l,d=i+s,l.__=t,l.__b=t.__b+1,c=null,(u=l.__i=Jn(l,n,d,b))!=-1&&(b--,(c=n[u])&&(c.__u|=2)),c==null||c.__v==null?(u==-1&&(r>p?s--:r<p&&s++),typeof l.type!="function"&&(l.__u|=4)):u!=d&&(u==d-1?s--:u==d+1?s++:(u>d?s--:s++,l.__u|=4))):t.__k[i]=null;if(b)for(i=0;i<p;i++)(c=n[i])!=null&&(2&c.__u)==0&&(c.__e==a&&(a=le(c)),St(c,c));return a}function wt(t,e,n){var a,r;if(typeof t.type=="function"){for(a=t.__k,r=0;a&&r<a.length;r++)a[r]&&(a[r].__=t,e=wt(a[r],e,n));return e}t.__e!=e&&(e&&t.type&&!e.parentNode&&(e=le(t)),e=n.insertBefore(t.__e,e||null));do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function me(t,e){return e=e||[],t==null||typeof t=="boolean"||(fe(t)?t.some(function(n){me(n,e)}):e.push(t)),e}function Jn(t,e,n,a){var r,i,l,c=t.key,d=t.type,u=e[n],p=u!=null&&(2&u.__u)==0;if(u===null&&c==null||p&&c==u.key&&d==u.type)return n;if(a>(p?1:0)){for(r=n-1,i=n+1;r>=0||i<e.length;)if((u=e[l=r>=0?r--:i++])!=null&&(2&u.__u)==0&&c==u.key&&d==u.type)return l}return-1}function ft(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||$n.test(e)?n:n+"px"}function xe(t,e,n,a,r){var i,l;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof a=="string"&&(t.style.cssText=a=""),a)for(e in a)n&&e in n||ft(t.style,e,"");if(n)for(e in n)a&&n[e]==a[e]||ft(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")i=e!=(e=e.replace(vt,"$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?a?n[ge]=a[ge]:(n[ge]=De,t.addEventListener(e,i?He:Ue,i)):t.removeEventListener(e,i?He:Ue,i);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 mt(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e[ye]==null)e[ye]=De++;else if(e[ye]<n[ge])return;return n(k.event?k.event(e):e)}}}function je(t,e,n,a,r,i,l,c,d,u){var p,b,s,g,f,C,w,y,m,v,h,A,L,V,$,S,_=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(d=!!(32&n.__u),i=[c=e.__e=n.__e]),(p=k.__b)&&p(e);e:if(typeof _=="function"){b=l.length;try{if(m=e.props,v=_.prototype&&_.prototype.render,h=(p=_.contextType)&&a[p.__c],A=p?h?h.props.value:p.__:a,n.__c?y=(s=e.__c=n.__c).__=s.__E:(v?e.__c=s=new _(m,A):(e.__c=s=new K(m,A),s.constructor=_,s.render=Kn),h&&h.sub(s),s.state||(s.state={}),s.__n=a,g=s.__d=!0,s.__h=[],s._sb=[]),v&&s.__s==null&&(s.__s=s.state),v&&_.getDerivedStateFromProps!=null&&(s.__s==s.state&&(s.__s=Y({},s.__s)),Y(s.__s,_.getDerivedStateFromProps(m,s.__s))),f=s.props,C=s.state,s.__v=e,g)v&&_.getDerivedStateFromProps==null&&s.componentWillMount!=null&&s.componentWillMount(),v&&s.componentDidMount!=null&&s.__h.push(s.componentDidMount);else{if(v&&_.getDerivedStateFromProps==null&&m!==f&&s.componentWillReceiveProps!=null&&s.componentWillReceiveProps(m,A),e.__v==n.__v||!s.__e&&s.shouldComponentUpdate!=null&&s.shouldComponentUpdate(m,s.__s,A)===!1){e.__v!=n.__v&&(s.props=m,s.state=s.__s,s.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(R){R&&(R.__=e)}),Ce.push.apply(s.__h,s._sb),s._sb=[],s.__h.length&&l.push(s),c=le(n);break e}s.componentWillUpdate!=null&&s.componentWillUpdate(m,s.__s,A),v&&s.componentDidUpdate!=null&&s.__h.push(function(){s.componentDidUpdate(f,C,w)})}if(s.context=A,s.props=m,s.__P=t,s.__e=!1,L=k.__r,V=0,v)s.state=s.__s,s.__d=!1,L&&L(e),p=s.render(s.props,s.state,s.context),Ce.push.apply(s.__h,s._sb),s._sb=[];else do s.__d=!1,L&&L(e),p=s.render(s.props,s.state,s.context),s.state=s.__s;while(s.__d&&++V<25);s.state=s.__s,s.getChildContext!=null&&(a=Y(Y({},a),s.getChildContext())),v&&!g&&s.getSnapshotBeforeUpdate!=null&&(w=s.getSnapshotBeforeUpdate(f,C)),$=p!=null&&p.type===T&&p.key==null?Ft(p.props.children):p,c=kt(t,fe($)?$:[$],e,n,a,r,i,l,c,d,u),s.base=e.__e,e.__u&=-161,s.__h.length&&l.push(s),y&&(s.__E=s.__=null)}catch(R){if(l.length=b,e.__v=null,d||i!=null){if(R.then){for(e.__u|=d?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;i!=null&&(i[i.indexOf(c)]=null),e.__e=c}else if(i!=null)for(S=i.length;S--;)qe(i[S])}else e.__e=n.__e;e.__k==null&&(e.__k=n.__k||[]),R.then||Ct(e),k.__e(R,e,n)}}else i==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):c=e.__e=Gn(n.__e,e,n,a,r,i,l,d,u);return(p=k.diffed)&&p(e),128&e.__u?void 0:c}function Ct(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(Ct))}function At(t,e,n){for(var a=0;a<n.length;a++)$e(n[a],n[++a],n[++a]);k.__c&&k.__c(e,t),t.some(function(r){try{t=r.__h,r.__h=[],t.some(function(i){i.call(r)})}catch(i){k.__e(i,r.__v)}})}function Ft(t){return typeof t!="object"||t==null||t.__b>0?t:fe(t)?t.map(Ft):t.constructor!==void 0?null:Y({},t)}function Gn(t,e,n,a,r,i,l,c,d){var u,p,b,s,g,f,C,w=n.props||we,y=e.props,m=e.type;if(m=="svg"?r="http://www.w3.org/2000/svg":m=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),i!=null){for(u=0;u<i.length;u++)if((g=i[u])&&"setAttribute"in g==!!m&&(m?g.localName==m:g.nodeType==3)){t=g,i[u]=null;break}}if(t==null){if(m==null)return document.createTextNode(y);t=document.createElementNS(r,m,y.is&&y),c&&(k.__m&&k.__m(e,i),c=!1),i=null}if(m==null)w===y||c&&t.data==y||(t.data=y);else{if(i=m=="textarea"&&y.defaultValue!=null?null:i&&Fe.call(t.childNodes),!c&&i!=null)for(w={},u=0;u<t.attributes.length;u++)w[(g=t.attributes[u]).name]=g.value;for(u in w)g=w[u],u=="dangerouslySetInnerHTML"?b=g:u=="children"||u in y||u=="value"&&"defaultValue"in y||u=="checked"&&"defaultChecked"in y||xe(t,u,null,g,r);for(u in y)g=y[u],u=="children"?s=g:u=="dangerouslySetInnerHTML"?p=g:u=="value"?f=g:u=="checked"?C=g:c&&typeof g!="function"||w[u]===g||xe(t,u,g,w[u],r);if(p)c||b&&(p.__html==b.__html||p.__html==t.innerHTML)||(t.innerHTML=p.__html),e.__k=[];else if(b&&(t.innerHTML=""),kt(e.type=="template"?t.content:t,fe(s)?s:[s],e,n,a,m=="foreignObject"?"http://www.w3.org/1999/xhtml":r,i,l,i?i[0]:n.__k&&le(n,0),c,d),i!=null)for(u=i.length;u--;)qe(i[u]);c&&m!="textarea"||(u="value",m=="progress"&&f==null?t.removeAttribute("value"):f!=null&&(f!==t[u]||m=="progress"&&!f||m=="option"&&f!=w[u])&&xe(t,u,f,w[u],r),u="checked",C!=null&&C!=t[u]&&xe(t,u,C,w[u],r))}return t}function $e(t,e,n){try{if(typeof t=="function"){var a=typeof t.__u=="function";a&&t.__u(),a&&e==null||(t.__u=t(e))}else t.current=e}catch(r){k.__e(r,n)}}function St(t,e,n){var a,r;if(k.unmount&&k.unmount(t),(a=t.ref)&&(a.current&&a.current!=t.__e||$e(a,null,e)),(a=t.__c)!=null){if(a.componentWillUnmount)try{a.componentWillUnmount()}catch(i){k.__e(i,e)}a.base=a.__P=a.__n=null}if(a=t.__k)for(r=0;r<a.length;r++)a[r]&&St(a[r],e,n||typeof t.type!="function");n||qe(t.__e),t.__c=t.__=t.__e=void 0}function Kn(t,e,n){return this.constructor(t,n)}function Ve(t,e,n){var a,r,i,l;e==document&&(e=document.documentElement),k.__&&k.__(t,e),r=(a=typeof n=="function")?null:n&&n.__k||e.__k,i=[],l=[],je(e,t=(!a&&n||e).__k=Q(T,null,[t]),r||we,we,e.namespaceURI,!a&&n?[n]:r?null:e.firstChild?Fe.call(e.childNodes):null,i,!a&&n?n:r?r.__e:e.firstChild,a,l),At(i,t,l),t.props.children=null}function Se(t){function e(n){var a,r;return this.getChildContext||(a=new Set,(r={})[e.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){a=null},this.shouldComponentUpdate=function(i){this.props.value!=i.value&&a.forEach(function(l){l.__e=!0,Oe(l)})},this.sub=function(i){a.add(i);var l=i.componentWillUnmount;i.componentWillUnmount=function(){a&&a.delete(i),l&&l.call(i)}}),n.children}return e.__c="__cC"+xt++,e.__=t,e.Provider=e.__l=(e.Consumer=function(n,a){return n.children(a)}).contextType=e,e}Fe=Ce.slice,k={__e:function(t,e,n,a){for(var r,i,l;e=e.__;)if((r=e.__c)&&!r.__)try{if((i=r.constructor)&&i.getDerivedStateFromError!=null&&(r.setState(i.getDerivedStateFromError(t)),l=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(t,a||{}),l=r.__d),l)return r.__E=r}catch(c){t=c}throw t}},_t=0,jn=function(t){return t!=null&&t.constructor===void 0},K.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Y({},this.state),typeof t=="function"&&(t=t(Y({},n),this.props)),t&&Y(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),Oe(this))},K.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Oe(this))},K.prototype.render=T,ne=[],bt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ht=function(t,e){return t.__v.__b-e.__v.__b},Ae.__r=0,ze=Math.random().toString(8),ye="__d"+ze,ge="__a"+ze,vt=/(PointerCapture)$|Capture$/i,De=0,Ue=mt(!1),He=mt(!0),xt=0;var ue,N,We,Et,_e=0,It=[],z=k,Rt=z.__b,Pt=z.__r,Tt=z.diffed,Nt=z.__c,Mt=z.unmount,Bt=z.__;function Re(t,e){z.__h&&z.__h(N,t,_e||e),_e=0;var n=N.__H||(N.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function F(t){return _e=1,zt(Ht,t)}function zt(t,e,n){var a=Re(ue++,2);if(a.t=t,!a.__c&&(a.__=[n?n(e):Ht(void 0,e),function(c){var d=a.__N?a.__N[0]:a.__[0],u=a.t(d,c);d!==u&&(a.__N=[u,a.__[1]],a.__c.setState({}))}],a.__c=N,!N.__f)){var r=function(c,d,u){if(!a.__c.__H)return!0;var p=!1,b=a.__c.props!==c;if(a.__c.__H.__.some(function(g){if(g.__N){p=!0;var f=g.__[0];g.__=g.__N,g.__N=void 0,f!==g.__[0]&&(b=!0)}}),i){var s=i.call(this,c,d,u);return p?s||b:s}return!p||b};N.__f=!0;var i=N.shouldComponentUpdate,l=N.componentWillUpdate;N.componentWillUpdate=function(c,d,u){if(this.__e){var p=i;i=void 0,r(c,d,u),i=p}l&&l.call(this,c,d,u)},N.shouldComponentUpdate=r}return a.__N||a.__}function q(t,e){var n=Re(ue++,3);!z.__s&&Ut(n.__H,e)&&(n.__=t,n.u=e,N.__H.__h.push(n))}function M(t){return _e=5,ae(function(){return{current:t}},[])}function ae(t,e){var n=Re(ue++,7);return Ut(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function B(t,e){return _e=8,ae(function(){return t},e)}function Ge(t){var e=N.context[t.__c],n=Re(ue++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(N)),e.props.value):t.__}function Qn(){for(var t;t=It.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(Ee),e.__h.some(Je),e.__h=[]}catch(n){e.__h=[],z.__e(n,t.__v)}}}z.__b=function(t){N=null,Rt&&Rt(t)},z.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Bt&&Bt(t,e)},z.__r=function(t){Pt&&Pt(t),ue=0;var e=(N=t.__c).__H;e&&(We===N?(e.__h=[],N.__h=[],e.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.some(Ee),e.__h.some(Je),e.__h=[],ue=0)),We=N},z.diffed=function(t){Tt&&Tt(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(It.push(e)!==1&&Et===z.requestAnimationFrame||((Et=z.requestAnimationFrame)||Yn)(Qn)),e.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),We=N=null},z.__c=function(t,e){e.some(function(n){try{n.__h.some(Ee),n.__h=n.__h.filter(function(a){return!a.__||Je(a)})}catch(a){e.some(function(r){r.__h&&(r.__h=[])}),e=[],z.__e(a,n.__v)}}),Nt&&Nt(t,e)},z.unmount=function(t){Mt&&Mt(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.some(function(a){try{Ee(a)}catch(r){e=r}}),n.__H=void 0,e&&z.__e(e,n.__v))};var Lt=typeof requestAnimationFrame=="function";function Yn(t){var e,n=function(){clearTimeout(a),Lt&&cancelAnimationFrame(e),setTimeout(t)},a=setTimeout(n,35);Lt&&(e=requestAnimationFrame(n))}function Ee(t){var e=N,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),N=e}function Je(t){var e=N;t.__c=t.__(),N=e}function Ut(t,e){return!t||t.length!==e.length||e.some(function(n,a){return n!==t[a]})}function Ht(t,e){return typeof e=="function"?e(t):e}function Kt(t,e){for(var n in e)t[n]=e[n];return t}function Ot(t,e){for(var n in t)if(n!=="__source"&&!(n in e))return!0;for(var a in e)if(a!=="__source"&&t[a]!==e[a])return!0;return!1}function Dt(t,e){this.props=t,this.context=e}(Dt.prototype=new K).isPureReactComponent=!0,Dt.prototype.shouldComponentUpdate=function(t,e){return Ot(this.props,t)||Ot(this.state,e)};var qt=k.__b;k.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),qt&&qt(t)};var Xn=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function Te(t){function e(n){var a=Kt({},n);return delete a.ref,t(a,n.ref||null)}return e.$$typeof=Xn,e.render=t,e.prototype.isReactComponent=e.__f=!0,e.displayName="ForwardRef("+(t.displayName||t.name)+")",e}var ea=k.__e;k.__e=function(t,e,n,a){if(t.then){for(var r,i=e;i=i.__;)if((r=i.__c)&&r.__c)return e.__e==null&&(e.__e=n.__e,e.__k=n.__k||[]),r.__c(t,e)}ea(t,e,n,a)};var jt=k.unmount;function Qt(t,e,n){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(a){typeof a.__c=="function"&&a.__c()}),t.__c.__H=null),(t=Kt({},t)).__c!=null&&(t.__c.__P===n&&(t.__c.__P=e),t.__c.__e=!0,t.__c=null),t.__k=t.__k&&t.__k.map(function(a){return Qt(a,e,n)})),t}function Yt(t,e,n){return t&&n&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(a){return Yt(a,e,n)}),t.__c&&t.__c.__P===e&&(t.__e&&n.appendChild(t.__e),t.__c.__e=!0,t.__c.__P=n)),t}function Ke(){this.__u=0,this.o=null,this.__b=null}function Zt(t){var e=t.__&&t.__.__c;return e&&e.__a&&e.__a(t)}function Pe(){this.i=null,this.l=null}k.unmount=function(t){var e=t.__c;e&&(e.__z=!0),e&&e.__R&&e.__R(),e&&32&t.__u&&(t.type=null),jt&&jt(t)},(Ke.prototype=new K).__c=function(t,e){var n=e.__c,a=this;a.o==null&&(a.o=[]),a.o.push(n);var r=Zt(a.__v),i=!1,l=function(){i||a.__z||(i=!0,n.__R=null,r?r(d):d())};n.__R=l;var c=n.__P;n.__P=null;var d=function(){if(!--a.__u){if(a.state.__a){var u=a.state.__a;a.__v.__k[0]=Yt(u,u.__c.__P,u.__c.__O)}var p;for(a.setState({__a:a.__b=null});p=a.o.pop();)p.__P=c,p.forceUpdate()}};a.__u++||32&e.__u||a.setState({__a:a.__b=a.__v.__k[0]}),t.then(l,l)},Ke.prototype.componentWillUnmount=function(){this.o=[]},Ke.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),a=this.__v.__k[0].__c;this.__v.__k[0]=Qt(this.__b,n,a.__O=a.__P)}this.__b=null}var r=e.__a&&Q(T,null,t.fallback);return r&&(r.__u&=-33),[Q(T,null,e.__a?null:t.children),r]};var $t=function(t,e,n){if(++n[1]===n[0]&&t.l.delete(e),t.props.revealOrder&&(t.props.revealOrder[0]!=="t"||!t.l.size))for(n=t.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;t.i=n=n[2]}};(Pe.prototype=new K).__a=function(t){var e=this,n=Zt(e.__v),a=e.l.get(t);return a[0]++,function(r){var i=function(){e.props.revealOrder?(a.push(r),$t(e,t,a)):r()};n?n(i):i()}},Pe.prototype.render=function(t){this.i=null,this.l=new Map;var e=me(t.children);t.revealOrder&&t.revealOrder[0]==="b"&&e.reverse();for(var n=e.length;n--;)this.l.set(e[n],this.i=[1,0,this.i]);return t.children},Pe.prototype.componentDidUpdate=Pe.prototype.componentDidMount=function(){var t=this;this.l.forEach(function(e,n){$t(t,n,e)})};var ta=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,na=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,aa=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ra=/[A-Z0-9]/g,ia=typeof document<"u",oa=function(t){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(t)};function Xt(t,e,n){return e.__k==null&&(e.textContent=""),Ve(t,e),typeof n=="function"&&n(),t?t.__c:null}K.prototype.isReactComponent=!0,["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(t){Object.defineProperty(K.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})});var Vt=k.event;k.event=function(t){return Vt&&(t=Vt(t)),t.persist=function(){},t.isPropagationStopped=function(){return this.cancelBubble},t.isDefaultPrevented=function(){return this.defaultPrevented},t.nativeEvent=t};var en,sa={configurable:!0,get:function(){return this.class}},Wt=k.vnode;k.vnode=function(t){typeof t.type=="string"&&(function(e){var n=e.props,a=e.type,r={},i=a.indexOf("-")==-1;for(var l in n){var c=n[l];if(!(l==="value"&&"defaultValue"in n&&c==null||ia&&l==="children"&&a==="noscript"||l==="class"||l==="className")){var d=l.toLowerCase();l==="defaultValue"&&"value"in n&&n.value==null?l="value":l==="download"&&c===!0?c="":d==="translate"&&c==="no"?c=!1:d[0]==="o"&&d[1]==="n"?d==="ondoubleclick"?l="ondblclick":d!=="onchange"||a!=="input"&&a!=="textarea"||oa(n.type)?d==="onfocus"?l="onfocusin":d==="onblur"?l="onfocusout":aa.test(l)&&(l=d):d=l="oninput":i&&na.test(l)?l=l.replace(ra,"-$&").toLowerCase():c===null&&(c=void 0),d==="oninput"&&r[l=d]&&(l="oninputCapture"),r[l]=c}}a=="select"&&(r.multiple&&Array.isArray(r.value)&&(r.value=me(n.children).forEach(function(u){u.props.selected=r.value.indexOf(u.props.value)!=-1})),r.defaultValue!=null&&(r.value=me(n.children).forEach(function(u){u.props.selected=r.multiple?r.defaultValue.indexOf(u.props.value)!=-1:r.defaultValue==u.props.value}))),n.class&&!n.className?(r.class=n.class,Object.defineProperty(r,"className",sa)):n.className&&(r.class=r.className=n.className),e.props=r})(t),t.$$typeof=ta,Wt&&Wt(t)};var Jt=k.__r;k.__r=function(t){Jt&&Jt(t),en=t.__c};var Gt=k.diffed;k.diffed=function(t){Gt&&Gt(t);var e=t.props,n=t.__e;n!=null&&t.type==="textarea"&&"value"in e&&e.value!==n.value&&(n.value=e.value==null?"":e.value),en=null};function tn(t){return!!t.__k&&(Ve(null,t),!0)}var I=class extends Error{constructor(n,a,r){super(n);G(this,"status");G(this,"code");this.name="AginiesError",this.status=a,this.code=r}},la=t=>t.replace(/\/+$/,""),Ne=class{constructor(e){G(this,"baseUrl");G(this,"token");G(this,"hosted");G(this,"locale");G(this,"fetchImpl");G(this,"state",{status:"idle"});G(this,"listeners",new Set);G(this,"activation",null);G(this,"session",null);if(!e?.baseUrl)throw new I("baseUrl is required",0,"MISSING_BASE_URL");if(!e?.token&&!e?.hosted)throw new I("token is required",0,"MISSING_TOKEN");this.baseUrl=la(e.baseUrl),this.token=e.token??null,this.hosted=e.hosted===!0,this.locale=e.locale??ca(),this.fetchImpl=e.fetch??((...n)=>fetch(...n))}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}setState(e){this.state=e;for(let n of this.listeners)n(e)}activate(){return this.activation?this.activation:(this.setState({status:"activating"}),this.activation=(async()=>{try{let e=await this.fetchImpl(`${this.baseUrl}/api/ui/activate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(this.hosted?{hosted:!0}:{token:this.token})});if(!e.ok){let a=await be(e),r=a&&a.error||`HTTP ${e.status}`;return this.setState({status:"rejected",reason:r}),this.state}let n=await e.json();return!n.activated||!n.config?(this.setState({status:"rejected",reason:"Activation refused"}),this.state):(this.session=n.session??null,this.setState({status:"active",config:n.config}),this.state)}catch(e){return this.setState({status:"rejected",reason:e instanceof Error?e.message:"Activation failed"}),this.state}})(),this.activation)}assertActive(){if(this.state.status!=="active")throw new I("Client is not activated",0,"NOT_ACTIVATED")}getSession(){return this.session}hasModule(e){if(this.state.status!=="active")return!1;let n=this.state.config.modules??[];return n.length===0||n.includes(e)}async renewSession(){return this.activation=null,(await this.activate()).status==="active"&&this.session!==null}withSession(e){if(!this.session)return e;let n=new Headers(e.headers??{});return n.has("Authorization")||n.set("Authorization",`Bearer ${this.session.token}`),{...e,headers:n}}async request(e,n={}){let a=`${this.baseUrl}${e.startsWith("/")?e:`/${e}`}`,r=()=>this.fetchImpl(a,this.withSession({credentials:"include",...n})),i=await r();return this.session&&(i.status===401||i.status===403)&&this.session.expiresAt*1e3<=Date.now()+5e3&&await this.renewSession()&&(i=await r()),i}fetchRaw(e,n={}){return this.assertActive(),this.request(e,n)}async transcribe(e,n,a="turn.webm",r){this.assertActive();let i=new FormData;i.append("file",n,a),r&&i.append("language",r);let l=await this.request(`/api/chat/${encodeURIComponent(e)}/voice/transcribe`,{method:"POST",body:i});if(!l.ok)throw await an(l);return await l.json()}async speak(e,n){this.assertActive();let a=await this.request(`/api/chat/${encodeURIComponent(e)}/voice/speak`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:n})});if(!a.ok)throw await an(a);return a.blob()}async getChat(e){this.assertActive();let n=await this.request(`/api/chat/${encodeURIComponent(e)}`),a=await be(n);if(n.status===401&&a&&typeof a.authRequired=="string")return a;if(!n.ok)throw new I(a?.error||`HTTP ${n.status}`,n.status);return a}async*sendMessage(e,n,a){this.assertActive();let r=await this.request(`/api/chat/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n),signal:a});if(!r.ok){let l=await be(r);throw r.status===401&&l&&typeof l.authRequired=="string"?new I("Authentication required",401,"AUTH_REQUIRED"):new I(l?.error||`HTTP ${r.status}`,r.status)}if(!(r.headers.get("content-type")??"").includes("text/event-stream")){yield{type:"final",data:await be(r)},yield{type:"done"};return}yield*ua(r.body)}};async function*ua(t){let e=t.getReader(),n=new TextDecoder,a="";try{for(;;){let{done:i,value:l}=await e.read();if(i)break;a+=n.decode(l,{stream:!0});let c=a.indexOf(`
|
|
2
2
|
|
|
3
|
-
`);for(;
|
|
3
|
+
`);for(;c!==-1;){let d=a.slice(0,c);a=a.slice(c+2);let u=nn(d);u&&(yield u),c=a.indexOf(`
|
|
4
4
|
|
|
5
|
-
`)}}let r=
|
|
6
|
-
`).find(r=>r.startsWith("data:"));if(!e)return null;let n=e.slice(5).trim();if(!n||n==="[DONE]")return null;let a;try{a=JSON.parse(n)}catch{return{type:"chunk",text:n}}return a.event==="error"?{type:"error",message:a.error||"Stream error"}:a.event==="final"?{type:"final",data:a.data}:typeof a.chunk=="string"?{type:"chunk",blockId:a.blockId,text:a.chunk}:null}async function Se(t){try{return await t.json()}catch{return null}}function Yn(){return typeof document<"u"&&(document.documentElement.lang?.toLowerCase()??"").startsWith("tr")||typeof navigator<"u"&&navigator.language?.toLowerCase().startsWith("tr")?"tr":"en"}var Gt=(t,e,n)=>`/api/resume/${encodeURIComponent(t)}/${encodeURIComponent(e)}${n?`/${encodeURIComponent(n)}`:""}`;async function Kt(t){let e=null;try{e=await t.json()}catch{}if(!t.ok){let n=e?.error;throw new M(n||`HTTP ${t.status}`,t.status,t.status===404?"NOT_FOUND":t.status===403?"FORBIDDEN":void 0)}return e}function Qt(t,e,n){return t.fetchRaw(Gt(e,n)).then(a=>Kt(a))}function Yt(t,e,n,a,r){return t.fetchRaw(Gt(e,n,a),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r?{input:{submission:r}}:{})}).then(i=>Kt(i))}function Pe(t){let e=t?.response?.data?.inputFormat;return Array.isArray(e)?e.map((n,a)=>{if(!n||typeof n!="object")return null;let r=n,i=typeof r.name=="string"?r.name.trim():"";if(!i)return null;let s=d=>typeof d=="string"&&d.trim()?d.trim():void 0;return{id:s(r.id)??`field_${a}`,name:i,label:s(r.label)??i,type:s(r.type)??"string",description:s(r.description),placeholder:s(r.placeholder),value:r.value,required:r.required===!0,options:Array.isArray(r.options)?r.options:void 0,rows:typeof r.rows=="number"?r.rows:void 0}}).filter(n=>n!==null):[]}function Zt(t){let e=t?.response?.data;if(!e||typeof e!="object")return{};let{inputFormat:n,resumeLinks:a,...r}=e;return r}function Zn(t,e){if(e==null)return"";switch(t.type){case"boolean":return typeof e=="boolean"?e?"true":"false":typeof e=="string"&&["true","false"].includes(e.trim().toLowerCase())?e.trim().toLowerCase():"";case"number":return typeof e=="number"?Number.isFinite(e)?String(e):"":String(e);case"array":case"object":case"files":if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return""}default:return typeof e=="string"?e:JSON.stringify(e)}}function Xn(t,e){let n=e.trim();switch(t.type){case"boolean":return{value:n==="true"};case"number":{let a=Number(n);return Number.isFinite(a)?{value:a}:{error:"number"}}case"array":case"object":case"files":try{return{value:JSON.parse(n)}}catch{return{error:"json"}}default:return{value:e}}}function We(t){return Object.fromEntries(t.map(e=>[e.name,Zn(e,e.value)]))}function Xt(t,e){let n={},a={};for(let r of t){let i=e[r.name]??"";if(!(r.type==="boolean"?i==="true"||i==="false":i.trim()!=="")){r.required&&(a[r.name]="required");continue}let{value:d,error:c}=Xn(r,i);c?a[r.name]=c:d!==void 0&&(n[r.name]=d)}return{submission:n,errors:a}}var ea=0;function o(t,e,n,a,r,i){e||(e={});var s,d,c=e;if("ref"in c)for(d in c={},e)d=="ref"?s=e[d]:c[d]=e[d];var u={type:t,props:c,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ea,__i:-1,__u:0,__source:r,__self:i};if(typeof t=="function"&&(s=t.defaultProps))for(d in s)c[d]===void 0&&(c[d]=s[d]);return b.vnode&&b.vnode(u),u}function B(...t){return t.filter(Boolean).join(" ")}var I=Ae(function({variant:e="outline",size:n="md",className:a,type:r="button",...i},s){return o("button",{ref:s,type:r,className:B("agi-btn",`agi-btn--${e}`,`agi-btn--${n}`,a),...i})});function Re({tone:t="default",className:e,...n}){return o("span",{className:B("agi-tag",t!=="default"&&`agi-tag--${t}`,e),...n})}function en({level:t=1,className:e,...n}){return o("div",{className:B("agi-panel",t===2&&"agi-panel--2",e),...n})}function tn({className:t,quiet:e,...n}){return o("p",{className:B("agi-eyebrow",e&&"agi-eyebrow--quiet",t),...n})}function ae({label:t,hint:e,error:n,className:a,children:r,...i}){return o("label",{className:B("agi-field",a),...i,children:[o("span",{className:"agi-field__label",children:t}),r,n?o("span",{className:"agi-field__error",children:n}):e&&o("span",{className:"agi-field__hint",children:e})]})}var Y=Ae(function({className:e,...n},a){return o("input",{ref:a,className:B("agi-input",e),...n})}),Je=Ae(function({className:e,...n},a){return o("textarea",{ref:a,className:B("agi-input","agi-textarea",e),...n})});function re({className:t,label:e}){return o("output",{className:B("agi-spinner",t),"aria-label":e,children:[o("span",{}),o("span",{}),o("span",{})]})}var ta={chat:{open:{tr:"Sohbeti a\xE7",en:"Open chat"},close:{tr:"Kapat",en:"Close"},placeholder:{tr:"Mesaj\u0131n\u0131z\u0131 yaz\u0131n\u2026",en:"Type your message\u2026"},send:{tr:"G\xF6nder",en:"Send"},stop:{tr:"Durdur",en:"Stop"},attach:{tr:"Dosya ekle",en:"Attach file"},attachments:{tr:"Ekler",en:"Attachments"},removeFile:{tr:"Dosyay\u0131 kald\u0131r",en:"Remove file"},tooManyFiles:{tr:"En fazla 5 dosya ekleyebilirsiniz.",en:"You can attach up to 5 files."},fileTooLarge:{tr:"Dosyalar 10 MB'tan k\xFC\xE7\xFCk olmal\u0131.",en:"Files must be smaller than 10 MB."},welcome:{tr:"Merhaba! Size nas\u0131l yard\u0131mc\u0131 olabilirim?",en:"Hi there! How can I help you today?"},thinking:{tr:"Yan\u0131t haz\u0131rlan\u0131yor",en:"Working on it"},stopped:{tr:"Yan\u0131t durduruldu.",en:"Response stopped."},error:{tr:"Bir sorun olu\u015Ftu. L\xFCtfen tekrar deneyin.",en:"Something went wrong. Please try again."},unavailable:{tr:"Bu sohbet \u015Fu anda kullan\u0131lam\u0131yor.",en:"This chat is currently unavailable."},poweredBy:{tr:"Aginies ile",en:"Powered by Aginies"},you:{tr:"Siz",en:"You"},assistant:{tr:"Ajan",en:"Agent"}},auth:{passwordTitle:{tr:"Bu sohbet parola korumal\u0131",en:"This chat is password protected"},passwordHint:{tr:"Devam etmek i\xE7in parolay\u0131 girin.",en:"Enter the password to continue."},password:{tr:"Parola",en:"Password"},emailTitle:{tr:"E-posta ile do\u011Frulama",en:"Verify with your e-mail"},emailHint:{tr:"\u0130\u015F e-postan\u0131z\u0131 girin; size bir kod g\xF6nderece\u011Fiz.",en:"Enter your work e-mail; we will send you a code."},email:{tr:"E-posta",en:"E-mail"},code:{tr:"Do\u011Frulama kodu",en:"Verification code"},codeHint:{tr:"E-postan\u0131za gelen 6 haneli kodu girin.",en:"Enter the 6-digit code from your e-mail."},continue:{tr:"Devam et",en:"Continue"},sendCode:{tr:"Kod g\xF6nder",en:"Send code"},verify:{tr:"Do\u011Frula",en:"Verify"},back:{tr:"Geri",en:"Back"},invalidPassword:{tr:"Parola yanl\u0131\u015F.",en:"Wrong password."},invalidEmail:{tr:"Bu e-posta adresi yetkili de\u011Fil.",en:"This e-mail address is not allowed."},invalidCode:{tr:"Kod ge\xE7ersiz veya s\xFCresi dolmu\u015F.",en:"The code is invalid or has expired."},codeSent:{tr:"Kod g\xF6nderildi.",en:"Code sent."},codeError:{tr:"Kod g\xF6nderilemedi. L\xFCtfen tekrar deneyin.",en:"The code could not be sent. Please try again."},resend:{tr:"Kodu yeniden g\xF6nder",en:"Resend code"},ssoTitle:{tr:"Kurumsal giri\u015F gerekli",en:"Sign in with your organisation"},ssoHint:{tr:"Bu sohbet kurumsal kimlikle a\xE7\u0131l\u0131r.",en:"This chat opens with your organisation account."},ssoButton:{tr:"Kurumsal giri\u015F",en:"Sign in"}},run:{submit:{tr:"\xC7al\u0131\u015Ft\u0131r",en:"Run"},cancel:{tr:"\u0130ptal",en:"Cancel"},running:{tr:"\xC7al\u0131\u015F\u0131yor",en:"Running"},done:{tr:"Tamamland\u0131",en:"Completed"},error:{tr:"Hata",en:"Error"},failed:{tr:"\xC7al\u0131\u015Ft\u0131rma ba\u015Far\u0131s\u0131z oldu.",en:"The run failed."},unauthorized:{tr:"API anahtar\u0131 reddedildi.",en:"The API key was rejected."},steps:{tr:"Ad\u0131mlar",en:"Steps"},execution:{tr:"\xE7al\u0131\u015Ft\u0131rma",en:"execution"}},approval:{eyebrow:{tr:"\u0130nsan onay\u0131",en:"Human approval"},title:{tr:"Onay bekleyen ad\u0131m",en:"A step is waiting for approval"},execution:{tr:"\xE7al\u0131\u015Ft\u0131rma",en:"execution"},pausedAt:{tr:"duraklat\u0131ld\u0131",en:"paused"},points:{tr:"Onay noktalar\u0131",en:"Approval points"},point:{tr:"Nokta",en:"Point"},output:{tr:"Ajan\u0131n \xF6nerisi",en:"What the agent proposes"},queuePosition:{tr:"S\u0131ra",en:"Queue position"},submit:{tr:"Onayla ve devam et",en:"Approve and continue"},submitting:{tr:"G\xF6nderiliyor",en:"Submitting"},refresh:{tr:"Yenile",en:"Refresh"},required:{tr:"Bu alan zorunlu.",en:"This field is required."},notANumber:{tr:"Say\u0131 girin.",en:"Enter a number."},notJson:{tr:"Ge\xE7erli JSON girin.",en:"Enter valid JSON."},notFound:{tr:"Bu onay bulunamad\u0131; s\xFCresi dolmu\u015F veya tamamlanm\u0131\u015F olabilir.",en:"This approval could not be found; it may have expired or been completed."},loadError:{tr:"Onay y\xFCklenemedi.",en:"The approval could not be loaded."},resumeError:{tr:"Devam ettirilemedi.",en:"The run could not be resumed."},resumedMessage:{tr:"Ajan kald\u0131\u011F\u0131 yerden devam ediyor.",en:"The agent is continuing from where it paused."},queuedMessage:{tr:"Onay s\u0131raya al\u0131nd\u0131; \xF6nceki devam i\u015Flemleri bitince \xE7al\u0131\u015Facak.",en:"The approval is queued; it runs after the earlier resumes finish."},paused:{tr:"Onay bekliyor",en:"Awaiting approval"},queued:{tr:"S\u0131rada",en:"Queued"},resuming:{tr:"Devam ediyor",en:"Resuming"},resumed:{tr:"Devam etti",en:"Resumed"},failed:{tr:"Ba\u015Far\u0131s\u0131z",en:"Failed"}},common:{loading:{tr:"Y\xFCkleniyor",en:"Loading"},retry:{tr:"Tekrar dene",en:"Retry"},notActivated:{tr:"Aginies UI paketi etkinle\u015Ftirilmedi.",en:"The Aginies UI package is not activated."}}};function nn(t){return function(n,a){let r=ta[n][a];return r[t]??r.en}}var Ne=null;function Ge(t){return Ne=new Ee(t),Ne.activate(),Ne}var an=ke(null);function ge(t){let{client:e}=L(),n=e.hasModule(t);return U(()=>{!n&&typeof console<"u"&&console.warn(`[aginies] the "${t}" module is not enabled for this activation key`)},[n,t]),n}function Te({client:t,locale:e,fallback:n=null,children:a}){let r=t??Ne,[i,s]=w(r?.getState()??{status:"rejected",reason:"init() was not called"});U(()=>{if(!r)return;s(r.getState());let c=r.subscribe(s);return r.activate(),c},[r]),U(()=>{i.status==="rejected"&&typeof console<"u"&&console.warn(`[aginies] UI kit not activated: ${i.reason}`)},[i]);let d=Q(()=>{if(!r)return null;let c=e??r.locale;return{client:r,state:i,locale:c,t:nn(c)}},[r,i,e]);return d?i.status==="idle"||i.status==="activating"?o(P,{children:n}):i.status==="rejected"?null:o(an.Provider,{value:d,children:a}):null}function L(){let t=$e(an);if(!t)throw new Error("[aginies] useAginies must be used inside <AginiesProvider> after init()");return t}function on(t,e,n){let{client:a,t:r}=L(),[i,s]=w("loading"),[d,c]=w(null),[u,g]=w(n??null),[f,l]=w({}),[p,_]=w({}),[v,x]=w(null),[y,m]=w(null),F=K(n??null),k=Q(()=>d?d.pausePoints.find(h=>h.contextId===u)??d.pausePoints.find(h=>h.resumeStatus==="paused")??d.pausePoints[0]??null:null,[d,u]),S=Q(()=>Pe(k),[k]),H=z(async()=>{s("loading"),x(null);try{let h=await Qt(a,t,e);c(h);let R=n??F.current,E=h.pausePoints.find(D=>D.contextId===R)??h.pausePoints.find(D=>D.resumeStatus==="paused")??h.pausePoints[0];E&&(F.current=E.contextId,g(E.contextId),l(We(Pe(E)))),_({}),s("ready")}catch(h){h instanceof M&&h.code==="NOT_FOUND"?s("not-found"):(x(h instanceof Error?h.message:r("approval","loadError")),s("error"))}},[a,t,e,n,r]);U(()=>{H()},[H]);let ee=z(h=>{F.current=h,g(h);let R=d?.pausePoints.find(E=>E.contextId===h);l(We(Pe(R))),_({})},[d]),W=z((h,R)=>{l(E=>({...E,[h]:R})),_(E=>{if(!(h in E))return E;let{[h]:D,...oe}=E;return oe})},[]),C=z(async()=>{if(!k||i==="submitting")return;let{submission:h,errors:R}=Xt(S,f);if(Object.keys(R).length>0){_(Object.fromEntries(Object.entries(R).map(([E,D])=>[E,D==="required"?r("approval","required"):D==="number"?r("approval","notANumber"):r("approval","notJson")])));return}s("submitting"),x(null);try{let E=await Yt(a,t,e,k.contextId,S.length>0?h:null);m(E),s(E.status==="queued"?"queued":"resumed")}catch(E){x(E instanceof Error?E.message:r("approval","resumeError")),s("ready")}},[a,t,e,k,S,f,i,r]);return{status:i,execution:d,pausePoint:k,fields:S,values:f,errors:p,error:v,outcome:y,select:ee,setValue:W,submit:C,reload:H}}var rn={paused:"warn",queued:"signal",resuming:"signal",resumed:"ok",failed:"bad"};function Ke({workflowId:t,executionId:e,contextId:n,title:a,description:r,submitLabel:i,onResumed:s,hideOutput:d=!1,className:c}){let{t:u,locale:g}=L(),f=ge("approval"),l=on(t,e,n),p=K(s);if(p.current=s,U(()=>{(l.status==="resumed"||l.status==="queued")&&l.outcome&&p.current?.(l.outcome)},[l.status,l.outcome]),!f)return null;let _=l.pausePoint,v=d?{}:Zt(_),x=Object.entries(v),y=_?.resumeStatus==="paused"&&l.status==="ready",m=k=>k?new Date(k).toLocaleString(g==="tr"?"tr-TR":"en-GB"):"",F=k=>{k.preventDefault(),l.submit()};return o(en,{className:B("agi-approval",c),"aria-busy":l.status==="loading",children:[o("header",{className:"agi-approval__head",children:[o(tn,{children:u("approval","eyebrow")}),o("h3",{className:"agi-approval__title",children:a??u("approval","title")}),r&&o("p",{className:"agi-approval__desc",children:r}),l.execution&&o("p",{className:"agi-approval__meta",children:[u("approval","execution")," ",o("span",{className:"agi-approval__meta-value",children:l.execution.executionId.slice(0,8)}),l.execution.pausedAt&&o(P,{children:[" \xB7 ",u("approval","pausedAt")," ",m(l.execution.pausedAt)]})]})]}),l.status==="loading"&&o("div",{className:"agi-approval__state",children:[o(re,{label:u("common","loading")})," ",u("common","loading")]}),l.status==="not-found"&&o("div",{className:"agi-approval__state",children:o("p",{children:u("approval","notFound")})}),l.status==="error"&&o("div",{className:"agi-approval__state",children:[o("p",{className:"agi-approval__error",children:l.error}),o(I,{variant:"outline",size:"sm",onClick:()=>{l.reload()},children:u("common","retry")})]}),l.execution&&l.execution.pausePoints.length>1&&o("nav",{className:"agi-approval__points","aria-label":u("approval","points"),children:l.execution.pausePoints.map((k,S)=>o("button",{type:"button",className:B("agi-approval__point",k.contextId===_?.contextId&&"is-selected"),onClick:()=>l.select(k.contextId),children:[o("span",{children:[u("approval","point")," ",S+1]}),o(Re,{tone:rn[k.resumeStatus]??"default",children:u("approval",k.resumeStatus)})]},k.contextId))}),_&&l.status!=="loading"&&o(P,{children:[o("div",{className:"agi-approval__status",children:[o(Re,{tone:rn[_.resumeStatus]??"default",children:u("approval",_.resumeStatus)}),typeof _.queuePosition=="number"&&_.queuePosition>0&&o("span",{className:"agi-approval__queue",children:[u("approval","queuePosition")," ",_.queuePosition]})]}),x.length>0&&o("section",{className:"agi-approval__output","aria-label":u("approval","output"),children:[o("div",{className:"agi-approval__output-label",children:u("approval","output")}),o("dl",{className:"agi-approval__kv",children:x.map(([k,S])=>o("div",{className:"agi-approval__kv-row",children:[o("dt",{children:k}),o("dd",{children:typeof S=="string"?S:JSON.stringify(S,null,2)})]},k))})]}),(l.status==="resumed"||l.status==="queued")&&l.outcome?o("output",{className:"agi-approval__done",children:[o(Re,{tone:l.status==="queued"?"signal":"ok",children:u("approval",l.status==="queued"?"queued":"resumed")}),o("p",{children:l.status==="queued"?u("approval","queuedMessage"):u("approval","resumedMessage")})]}):o("form",{className:"agi-approval__form",onSubmit:F,children:[l.fields.map(k=>o(ae,{label:k.label,hint:k.description,error:l.errors[k.name],children:na(k,l.values[k.name]??"",S=>l.setValue(k.name,S),!y)},k.id)),l.error&&o("p",{className:"agi-approval__error",children:l.error}),o("div",{className:"agi-approval__actions",children:[o(I,{variant:"signal",type:"submit",disabled:!y,children:l.status==="submitting"?o(P,{children:[o(re,{label:u("approval","submitting")})," ",u("approval","submitting")]}):i??u("approval","submit")}),o(I,{variant:"outline",type:"button",onClick:()=>{l.reload()},disabled:l.status==="submitting",children:u("approval","refresh")})]})]})]})]})}function na(t,e,n,a){switch(t.type){case"boolean":return o("select",{className:"agi-input",value:e,disabled:a,onChange:r=>n(r.target.value),children:[o("option",{value:"",children:"\u2014"}),o("option",{value:"true",children:"true"}),o("option",{value:"false",children:"false"})]});case"number":return o(Y,{type:"number",value:e,placeholder:t.placeholder,required:t.required,disabled:a,onChange:r=>n(r.target.value)});case"array":case"object":case"files":return o(Je,{value:e,rows:t.rows??4,placeholder:t.placeholder??"{ }",required:t.required,disabled:a,className:"agi-approval__json",onChange:r=>n(r.target.value)});default:return Array.isArray(t.options)&&t.options.length>0?o("select",{className:"agi-input",value:e,disabled:a,onChange:r=>n(r.target.value),children:[o("option",{value:"",children:"\u2014"}),t.options.map(r=>{let i=typeof r=="object"&&r!==null?r:{value:r,label:r},s=String(i.value??"");return o("option",{value:s,children:String(i.label??s)},s)})]}):(t.rows??1)>1?o(Je,{value:e,rows:t.rows,placeholder:t.placeholder,required:t.required,disabled:a,onChange:r=>n(r.target.value)}):o(Y,{value:e,placeholder:t.placeholder,required:t.required,disabled:a,onChange:r=>n(r.target.value)})}}function un({text:t,className:e}){return o("div",{className:e,children:cn(dn(t))})}var aa=/^\s*(`{3,}|~{3,})\s*([\w+-]*)\s*$/,ra=/^(#{1,6})\s+(.*?)\s*#*\s*$/,ia=/^\s*([-*_])(?:\s*\1){2,}\s*$/,Qe=/^\s*>\s?(.*)$/,Ye=/^\s*(?:([-*+])|(\d{1,9})[.)])\s+(.*)$/,oa=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/;function dn(t){let e=t.replace(/\r\n?/g,`
|
|
5
|
+
`)}}let r=nn(a);r&&(yield r)}finally{e.releaseLock()}yield{type:"done"}}function nn(t){let e=t.split(`
|
|
6
|
+
`).find(r=>r.startsWith("data:"));if(!e)return null;let n=e.slice(5).trim();if(!n||n==="[DONE]")return null;let a;try{a=JSON.parse(n)}catch{return{type:"chunk",text:n}}return a.event==="error"?{type:"error",message:a.error||"Stream error"}:a.event==="final"?{type:"final",data:a.data}:typeof a.chunk=="string"?{type:"chunk",blockId:a.blockId,text:a.chunk}:null}async function an(t){let e=await be(t);return t.status===401&&e&&typeof e.authRequired=="string"?new I("Authentication required",401,"AUTH_REQUIRED"):t.status===503?new I("Voice is not available",503,"VOICE_UNAVAILABLE"):new I(e?.error||`HTTP ${t.status}`,t.status)}async function be(t){try{return await t.json()}catch{return null}}function ca(){return typeof document<"u"&&(document.documentElement.lang?.toLowerCase()??"").startsWith("tr")||typeof navigator<"u"&&navigator.language?.toLowerCase().startsWith("tr")?"tr":"en"}var rn=(t,e,n)=>`/api/resume/${encodeURIComponent(t)}/${encodeURIComponent(e)}${n?`/${encodeURIComponent(n)}`:""}`;async function on(t){let e=null;try{e=await t.json()}catch{}if(!t.ok){let n=e?.error;throw new I(n||`HTTP ${t.status}`,t.status,t.status===404?"NOT_FOUND":t.status===403?"FORBIDDEN":void 0)}return e}function sn(t,e,n){return t.fetchRaw(rn(e,n)).then(a=>on(a))}function ln(t,e,n,a,r){return t.fetchRaw(rn(e,n,a),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r?{input:{submission:r}}:{})}).then(i=>on(i))}function Me(t){let e=t?.response?.data?.inputFormat;return Array.isArray(e)?e.map((n,a)=>{if(!n||typeof n!="object")return null;let r=n,i=typeof r.name=="string"?r.name.trim():"";if(!i)return null;let l=c=>typeof c=="string"&&c.trim()?c.trim():void 0;return{id:l(r.id)??`field_${a}`,name:i,label:l(r.label)??i,type:l(r.type)??"string",description:l(r.description),placeholder:l(r.placeholder),value:r.value,required:r.required===!0,options:Array.isArray(r.options)?r.options:void 0,rows:typeof r.rows=="number"?r.rows:void 0}}).filter(n=>n!==null):[]}function un(t){let e=t?.response?.data;if(!e||typeof e!="object")return{};let{inputFormat:n,resumeLinks:a,...r}=e;return r}function da(t,e){if(e==null)return"";switch(t.type){case"boolean":return typeof e=="boolean"?e?"true":"false":typeof e=="string"&&["true","false"].includes(e.trim().toLowerCase())?e.trim().toLowerCase():"";case"number":return typeof e=="number"?Number.isFinite(e)?String(e):"":String(e);case"array":case"object":case"files":if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return""}default:return typeof e=="string"?e:JSON.stringify(e)}}function pa(t,e){let n=e.trim();switch(t.type){case"boolean":return{value:n==="true"};case"number":{let a=Number(n);return Number.isFinite(a)?{value:a}:{error:"number"}}case"array":case"object":case"files":try{return{value:JSON.parse(n)}}catch{return{error:"json"}}default:return{value:e}}}function Qe(t){return Object.fromEntries(t.map(e=>[e.name,da(e,e.value)]))}function cn(t,e){let n={},a={};for(let r of t){let i=e[r.name]??"";if(!(r.type==="boolean"?i==="true"||i==="false":i.trim()!=="")){r.required&&(a[r.name]="required");continue}let{value:c,error:d}=pa(r,i);d?a[r.name]=d:c!==void 0&&(n[r.name]=c)}return{submission:n,errors:a}}var ga=0;function o(t,e,n,a,r,i){e||(e={});var l,c,d=e;if("ref"in d)for(c in d={},e)c=="ref"?l=e[c]:d[c]=e[c];var u={type:t,props:d,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ga,__i:-1,__u:0,__source:r,__self:i};if(typeof t=="function"&&(l=t.defaultProps))for(c in l)d[c]===void 0&&(d[c]=l[c]);return k.vnode&&k.vnode(u),u}function H(...t){return t.filter(Boolean).join(" ")}var D=Te(function({variant:e="outline",size:n="md",className:a,type:r="button",...i},l){return o("button",{ref:l,type:r,className:H("agi-btn",`agi-btn--${e}`,`agi-btn--${n}`,a),...i})});function Be({tone:t="default",className:e,...n}){return o("span",{className:H("agi-tag",t!=="default"&&`agi-tag--${t}`,e),...n})}function dn({level:t=1,className:e,...n}){return o("div",{className:H("agi-panel",t===2&&"agi-panel--2",e),...n})}function pn({className:t,quiet:e,...n}){return o("p",{className:H("agi-eyebrow",e&&"agi-eyebrow--quiet",t),...n})}function ce({label:t,hint:e,error:n,className:a,children:r,...i}){return o("label",{className:H("agi-field",a),...i,children:[o("span",{className:"agi-field__label",children:t}),r,n?o("span",{className:"agi-field__error",children:n}):e&&o("span",{className:"agi-field__hint",children:e})]})}var re=Te(function({className:e,...n},a){return o("input",{ref:a,className:H("agi-input",e),...n})}),Ye=Te(function({className:e,...n},a){return o("textarea",{ref:a,className:H("agi-input","agi-textarea",e),...n})});function ie({className:t,label:e}){return o("output",{className:H("agi-spinner",t),"aria-label":e,children:[o("span",{}),o("span",{}),o("span",{})]})}var fa={chat:{open:{tr:"Sohbeti a\xE7",en:"Open chat"},close:{tr:"Kapat",en:"Close"},placeholder:{tr:"Mesaj\u0131n\u0131z\u0131 yaz\u0131n\u2026",en:"Type your message\u2026"},send:{tr:"G\xF6nder",en:"Send"},stop:{tr:"Durdur",en:"Stop"},attach:{tr:"Dosya ekle",en:"Attach file"},attachments:{tr:"Ekler",en:"Attachments"},removeFile:{tr:"Dosyay\u0131 kald\u0131r",en:"Remove file"},tooManyFiles:{tr:"En fazla 5 dosya ekleyebilirsiniz.",en:"You can attach up to 5 files."},fileTooLarge:{tr:"Dosyalar 10 MB'tan k\xFC\xE7\xFCk olmal\u0131.",en:"Files must be smaller than 10 MB."},welcome:{tr:"Merhaba! Size nas\u0131l yard\u0131mc\u0131 olabilirim?",en:"Hi there! How can I help you today?"},thinking:{tr:"Yan\u0131t haz\u0131rlan\u0131yor",en:"Working on it"},stopped:{tr:"Yan\u0131t durduruldu.",en:"Response stopped."},error:{tr:"Bir sorun olu\u015Ftu. L\xFCtfen tekrar deneyin.",en:"Something went wrong. Please try again."},unavailable:{tr:"Bu sohbet \u015Fu anda kullan\u0131lam\u0131yor.",en:"This chat is currently unavailable."},poweredBy:{tr:"Aginies ile",en:"Powered by Aginies"},you:{tr:"Siz",en:"You"},assistant:{tr:"Ajan",en:"Agent"}},auth:{passwordTitle:{tr:"Bu sohbet parola korumal\u0131",en:"This chat is password protected"},passwordHint:{tr:"Devam etmek i\xE7in parolay\u0131 girin.",en:"Enter the password to continue."},password:{tr:"Parola",en:"Password"},emailTitle:{tr:"E-posta ile do\u011Frulama",en:"Verify with your e-mail"},emailHint:{tr:"\u0130\u015F e-postan\u0131z\u0131 girin; size bir kod g\xF6nderece\u011Fiz.",en:"Enter your work e-mail; we will send you a code."},email:{tr:"E-posta",en:"E-mail"},code:{tr:"Do\u011Frulama kodu",en:"Verification code"},codeHint:{tr:"E-postan\u0131za gelen 6 haneli kodu girin.",en:"Enter the 6-digit code from your e-mail."},continue:{tr:"Devam et",en:"Continue"},sendCode:{tr:"Kod g\xF6nder",en:"Send code"},verify:{tr:"Do\u011Frula",en:"Verify"},back:{tr:"Geri",en:"Back"},invalidPassword:{tr:"Parola yanl\u0131\u015F.",en:"Wrong password."},invalidEmail:{tr:"Bu e-posta adresi yetkili de\u011Fil.",en:"This e-mail address is not allowed."},invalidCode:{tr:"Kod ge\xE7ersiz veya s\xFCresi dolmu\u015F.",en:"The code is invalid or has expired."},codeSent:{tr:"Kod g\xF6nderildi.",en:"Code sent."},codeError:{tr:"Kod g\xF6nderilemedi. L\xFCtfen tekrar deneyin.",en:"The code could not be sent. Please try again."},resend:{tr:"Kodu yeniden g\xF6nder",en:"Resend code"},ssoTitle:{tr:"Kurumsal giri\u015F gerekli",en:"Sign in with your organisation"},ssoHint:{tr:"Bu sohbet kurumsal kimlikle a\xE7\u0131l\u0131r.",en:"This chat opens with your organisation account."},ssoButton:{tr:"Kurumsal giri\u015F",en:"Sign in"}},voice:{talk:{tr:"Konu\u015Fmak i\xE7in dokunun",en:"Tap to talk"},stopTalking:{tr:"Bitirmek i\xE7in dokunun",en:"Tap when done"},dictate:{tr:"Sesle yaz",en:"Dictate"},handsFree:{tr:"Sesli sohbet",en:"Voice conversation"},exit:{tr:"Sesli sohbetten \xE7\u0131k",en:"Leave voice conversation"},listening:{tr:"Dinliyor",en:"Listening"},transcribing:{tr:"Yaz\u0131ya d\xF6k\xFCl\xFCyor",en:"Transcribing"},thinking:{tr:"Yan\u0131t haz\u0131rlan\u0131yor",en:"Working on it"},speaking:{tr:"Konu\u015Fuyor",en:"Speaking"},idle:{tr:"Haz\u0131r",en:"Ready"},interrupt:{tr:"S\xF6z\xFCn\xFC kesmek i\xE7in dokunun",en:"Tap to interrupt"},micDenied:{tr:"Mikrofon izni verilmedi. Taray\u0131c\u0131 ayarlar\u0131ndan izin verin.",en:"Microphone access was denied. Allow it in your browser settings."},unsupported:{tr:"Bu taray\u0131c\u0131 ses kayd\u0131n\u0131 desteklemiyor.",en:"This browser cannot record audio."},unavailable:{tr:"Ses \xF6zelli\u011Fi bu sohbet i\xE7in a\xE7\u0131k de\u011Fil.",en:"Voice is not enabled for this chat."},error:{tr:"Ses i\u015Flenemedi. L\xFCtfen tekrar deneyin.",en:"Voice could not be processed. Please try again."}},run:{submit:{tr:"\xC7al\u0131\u015Ft\u0131r",en:"Run"},cancel:{tr:"\u0130ptal",en:"Cancel"},running:{tr:"\xC7al\u0131\u015F\u0131yor",en:"Running"},done:{tr:"Tamamland\u0131",en:"Completed"},error:{tr:"Hata",en:"Error"},failed:{tr:"\xC7al\u0131\u015Ft\u0131rma ba\u015Far\u0131s\u0131z oldu.",en:"The run failed."},unauthorized:{tr:"API anahtar\u0131 reddedildi.",en:"The API key was rejected."},steps:{tr:"Ad\u0131mlar",en:"Steps"},execution:{tr:"\xE7al\u0131\u015Ft\u0131rma",en:"execution"}},approval:{eyebrow:{tr:"\u0130nsan onay\u0131",en:"Human approval"},title:{tr:"Onay bekleyen ad\u0131m",en:"A step is waiting for approval"},execution:{tr:"\xE7al\u0131\u015Ft\u0131rma",en:"execution"},pausedAt:{tr:"duraklat\u0131ld\u0131",en:"paused"},points:{tr:"Onay noktalar\u0131",en:"Approval points"},point:{tr:"Nokta",en:"Point"},output:{tr:"Ajan\u0131n \xF6nerisi",en:"What the agent proposes"},queuePosition:{tr:"S\u0131ra",en:"Queue position"},submit:{tr:"Onayla ve devam et",en:"Approve and continue"},submitting:{tr:"G\xF6nderiliyor",en:"Submitting"},refresh:{tr:"Yenile",en:"Refresh"},required:{tr:"Bu alan zorunlu.",en:"This field is required."},notANumber:{tr:"Say\u0131 girin.",en:"Enter a number."},notJson:{tr:"Ge\xE7erli JSON girin.",en:"Enter valid JSON."},notFound:{tr:"Bu onay bulunamad\u0131; s\xFCresi dolmu\u015F veya tamamlanm\u0131\u015F olabilir.",en:"This approval could not be found; it may have expired or been completed."},loadError:{tr:"Onay y\xFCklenemedi.",en:"The approval could not be loaded."},resumeError:{tr:"Devam ettirilemedi.",en:"The run could not be resumed."},resumedMessage:{tr:"Ajan kald\u0131\u011F\u0131 yerden devam ediyor.",en:"The agent is continuing from where it paused."},queuedMessage:{tr:"Onay s\u0131raya al\u0131nd\u0131; \xF6nceki devam i\u015Flemleri bitince \xE7al\u0131\u015Facak.",en:"The approval is queued; it runs after the earlier resumes finish."},paused:{tr:"Onay bekliyor",en:"Awaiting approval"},queued:{tr:"S\u0131rada",en:"Queued"},resuming:{tr:"Devam ediyor",en:"Resuming"},resumed:{tr:"Devam etti",en:"Resumed"},failed:{tr:"Ba\u015Far\u0131s\u0131z",en:"Failed"}},common:{loading:{tr:"Y\xFCkleniyor",en:"Loading"},retry:{tr:"Tekrar dene",en:"Retry"},notActivated:{tr:"Aginies UI paketi etkinle\u015Ftirilmedi.",en:"The Aginies UI package is not activated."}}};function gn(t){return function(n,a){let r=fa[n][a];return r[t]??r.en}}var Le=null;function Ze(t){return Le=new Ne(t),Le.activate(),Le}var fn=Se(null);function he(t){let{client:e}=j(),n=e.hasModule(t);return q(()=>{!n&&typeof console<"u"&&console.warn(`[aginies] the "${t}" module is not enabled for this activation key`)},[n,t]),n}function Ie({client:t,locale:e,fallback:n=null,children:a}){let r=t??Le,[i,l]=F(r?.getState()??{status:"rejected",reason:"init() was not called"});q(()=>{if(!r)return;l(r.getState());let d=r.subscribe(l);return r.activate(),d},[r]),q(()=>{i.status==="rejected"&&typeof console<"u"&&console.warn(`[aginies] UI kit not activated: ${i.reason}`)},[i]);let c=ae(()=>{if(!r)return null;let d=e??r.locale;return{client:r,state:i,locale:d,t:gn(d)}},[r,i,e]);return c?i.status==="idle"||i.status==="activating"?o(T,{children:n}):i.status==="rejected"?null:o(fn.Provider,{value:c,children:a}):null}function j(){let t=Ge(fn);if(!t)throw new Error("[aginies] useAginies must be used inside <AginiesProvider> after init()");return t}function _n(t,e,n){let{client:a,t:r}=j(),[i,l]=F("loading"),[c,d]=F(null),[u,p]=F(n??null),[b,s]=F({}),[g,f]=F({}),[C,w]=F(null),[y,m]=F(null),v=M(n??null),h=ae(()=>c?c.pausePoints.find(_=>_.contextId===u)??c.pausePoints.find(_=>_.resumeStatus==="paused")??c.pausePoints[0]??null:null,[c,u]),A=ae(()=>Me(h),[h]),L=B(async()=>{l("loading"),w(null);try{let _=await sn(a,t,e);d(_);let R=n??v.current,E=_.pausePoints.find(W=>W.contextId===R)??_.pausePoints.find(W=>W.resumeStatus==="paused")??_.pausePoints[0];E&&(v.current=E.contextId,p(E.contextId),s(Qe(Me(E)))),f({}),l("ready")}catch(_){_ instanceof I&&_.code==="NOT_FOUND"?l("not-found"):(w(_ instanceof Error?_.message:r("approval","loadError")),l("error"))}},[a,t,e,n,r]);q(()=>{L()},[L]);let V=B(_=>{v.current=_,p(_);let R=c?.pausePoints.find(E=>E.contextId===_);s(Qe(Me(R))),f({})},[c]),$=B((_,R)=>{s(E=>({...E,[_]:R})),f(E=>{if(!(_ in E))return E;let{[_]:W,...X}=E;return X})},[]),S=B(async()=>{if(!h||i==="submitting")return;let{submission:_,errors:R}=cn(A,b);if(Object.keys(R).length>0){f(Object.fromEntries(Object.entries(R).map(([E,W])=>[E,W==="required"?r("approval","required"):W==="number"?r("approval","notANumber"):r("approval","notJson")])));return}l("submitting"),w(null);try{let E=await ln(a,t,e,h.contextId,A.length>0?_:null);m(E),l(E.status==="queued"?"queued":"resumed")}catch(E){w(E instanceof Error?E.message:r("approval","resumeError")),l("ready")}},[a,t,e,h,A,b,i,r]);return{status:i,execution:c,pausePoint:h,fields:A,values:b,errors:g,error:C,outcome:y,select:V,setValue:$,submit:S,reload:L}}var mn={paused:"warn",queued:"signal",resuming:"signal",resumed:"ok",failed:"bad"};function Xe({workflowId:t,executionId:e,contextId:n,title:a,description:r,submitLabel:i,onResumed:l,hideOutput:c=!1,className:d}){let{t:u,locale:p}=j(),b=he("approval"),s=_n(t,e,n),g=M(l);if(g.current=l,q(()=>{(s.status==="resumed"||s.status==="queued")&&s.outcome&&g.current?.(s.outcome)},[s.status,s.outcome]),!b)return null;let f=s.pausePoint,C=c?{}:un(f),w=Object.entries(C),y=f?.resumeStatus==="paused"&&s.status==="ready",m=h=>h?new Date(h).toLocaleString(p==="tr"?"tr-TR":"en-GB"):"",v=h=>{h.preventDefault(),s.submit()};return o(dn,{className:H("agi-approval",d),"aria-busy":s.status==="loading",children:[o("header",{className:"agi-approval__head",children:[o(pn,{children:u("approval","eyebrow")}),o("h3",{className:"agi-approval__title",children:a??u("approval","title")}),r&&o("p",{className:"agi-approval__desc",children:r}),s.execution&&o("p",{className:"agi-approval__meta",children:[u("approval","execution")," ",o("span",{className:"agi-approval__meta-value",children:s.execution.executionId.slice(0,8)}),s.execution.pausedAt&&o(T,{children:[" \xB7 ",u("approval","pausedAt")," ",m(s.execution.pausedAt)]})]})]}),s.status==="loading"&&o("div",{className:"agi-approval__state",children:[o(ie,{label:u("common","loading")})," ",u("common","loading")]}),s.status==="not-found"&&o("div",{className:"agi-approval__state",children:o("p",{children:u("approval","notFound")})}),s.status==="error"&&o("div",{className:"agi-approval__state",children:[o("p",{className:"agi-approval__error",children:s.error}),o(D,{variant:"outline",size:"sm",onClick:()=>{s.reload()},children:u("common","retry")})]}),s.execution&&s.execution.pausePoints.length>1&&o("nav",{className:"agi-approval__points","aria-label":u("approval","points"),children:s.execution.pausePoints.map((h,A)=>o("button",{type:"button",className:H("agi-approval__point",h.contextId===f?.contextId&&"is-selected"),onClick:()=>s.select(h.contextId),children:[o("span",{children:[u("approval","point")," ",A+1]}),o(Be,{tone:mn[h.resumeStatus]??"default",children:u("approval",h.resumeStatus)})]},h.contextId))}),f&&s.status!=="loading"&&o(T,{children:[o("div",{className:"agi-approval__status",children:[o(Be,{tone:mn[f.resumeStatus]??"default",children:u("approval",f.resumeStatus)}),typeof f.queuePosition=="number"&&f.queuePosition>0&&o("span",{className:"agi-approval__queue",children:[u("approval","queuePosition")," ",f.queuePosition]})]}),w.length>0&&o("section",{className:"agi-approval__output","aria-label":u("approval","output"),children:[o("div",{className:"agi-approval__output-label",children:u("approval","output")}),o("dl",{className:"agi-approval__kv",children:w.map(([h,A])=>o("div",{className:"agi-approval__kv-row",children:[o("dt",{children:h}),o("dd",{children:typeof A=="string"?A:JSON.stringify(A,null,2)})]},h))})]}),(s.status==="resumed"||s.status==="queued")&&s.outcome?o("output",{className:"agi-approval__done",children:[o(Be,{tone:s.status==="queued"?"signal":"ok",children:u("approval",s.status==="queued"?"queued":"resumed")}),o("p",{children:s.status==="queued"?u("approval","queuedMessage"):u("approval","resumedMessage")})]}):o("form",{className:"agi-approval__form",onSubmit:v,children:[s.fields.map(h=>o(ce,{label:h.label,hint:h.description,error:s.errors[h.name],children:ma(h,s.values[h.name]??"",A=>s.setValue(h.name,A),!y)},h.id)),s.error&&o("p",{className:"agi-approval__error",children:s.error}),o("div",{className:"agi-approval__actions",children:[o(D,{variant:"signal",type:"submit",disabled:!y,children:s.status==="submitting"?o(T,{children:[o(ie,{label:u("approval","submitting")})," ",u("approval","submitting")]}):i??u("approval","submit")}),o(D,{variant:"outline",type:"button",onClick:()=>{s.reload()},disabled:s.status==="submitting",children:u("approval","refresh")})]})]})]})]})}function ma(t,e,n,a){switch(t.type){case"boolean":return o("select",{className:"agi-input",value:e,disabled:a,onChange:r=>n(r.target.value),children:[o("option",{value:"",children:"\u2014"}),o("option",{value:"true",children:"true"}),o("option",{value:"false",children:"false"})]});case"number":return o(re,{type:"number",value:e,placeholder:t.placeholder,required:t.required,disabled:a,onChange:r=>n(r.target.value)});case"array":case"object":case"files":return o(Ye,{value:e,rows:t.rows??4,placeholder:t.placeholder??"{ }",required:t.required,disabled:a,className:"agi-approval__json",onChange:r=>n(r.target.value)});default:return Array.isArray(t.options)&&t.options.length>0?o("select",{className:"agi-input",value:e,disabled:a,onChange:r=>n(r.target.value),children:[o("option",{value:"",children:"\u2014"}),t.options.map(r=>{let i=typeof r=="object"&&r!==null?r:{value:r,label:r},l=String(i.value??"");return o("option",{value:l,children:String(i.label??l)},l)})]}):(t.rows??1)>1?o(Ye,{value:e,rows:t.rows,placeholder:t.placeholder,required:t.required,disabled:a,onChange:r=>n(r.target.value)}):o(re,{value:e,placeholder:t.placeholder,required:t.required,disabled:a,onChange:r=>n(r.target.value)})}}function at({text:t,className:e}){return o("div",{className:e,children:xn(vn(t))})}var _a=/^\s*(`{3,}|~{3,})\s*([\w+-]*)\s*$/,ba=/^(#{1,6})\s+(.*?)\s*#*\s*$/,ha=/^\s*([-*_])(?:\s*\1){2,}\s*$/,et=/^\s*>\s?(.*)$/,tt=/^\s*(?:([-*+])|(\d{1,9})[.)])\s+(.*)$/,va=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/;function vn(t){let e=t.replace(/\r\n?/g,`
|
|
7
7
|
`).split(`
|
|
8
|
-
`),n=[],a=0,r=[],i=()=>{r.length>0&&(n.push({kind:"paragraph",lines:r}),r=[])};for(;a<e.length;){let
|
|
9
|
-
`)});continue}let
|
|
10
|
-
`))});continue}let u=Ye.exec(s);if(u){i();let g=u[2]!==void 0,f=g?Number.parseInt(u[2],10):1,l=[];for(;a<e.length;){let p=Ye.exec(e[a]);if(p&&p[2]!==void 0===g)l.push(p[3]??""),a+=1;else if(l.length>0&&e[a].trim()!==""&&/^\s{2,}/.test(e[a])&&!Ye.test(e[a]))l[l.length-1]=`${l[l.length-1]} ${e[a].trim()}`,a+=1;else break}n.push({kind:"list",ordered:g,start:f,items:l});continue}if(s.includes("|")&&a+1<e.length&&oa.test(e[a+1])){i();let g=Ze(s),f=Ze(e[a+1]).map(p=>{let _=p.startsWith(":"),v=p.endsWith(":");return _&&v?"center":v?"right":_?"left":null}),l=[];for(a+=2;a<e.length&&e[a].includes("|");)l.push(Ze(e[a])),a+=1;n.push({kind:"table",header:g,align:f,rows:l});continue}r.push(s),a+=1}return i(),n}function Ze(t){return t.trim().replace(/^\|/,"").replace(/\|$/,"").split(/(?<!\\)\|/).map(n=>n.replace(/\\\|/g,"|").trim())}function cn(t){return t.map((e,n)=>{switch(e.kind){case"paragraph":return o("p",{children:e.lines.map((a,r)=>o(P,{children:[r>0&&o("br",{}),V(a)]},r))},n);case"heading":{let a=`h${Math.min(e.level+2,6)}`;return o(a,{children:V(e.text)},n)}case"code":return o("pre",{"data-lang":e.lang||void 0,children:o("code",{children:e.code})},n);case"quote":return o("blockquote",{children:cn(e.blocks)},n);case"list":{let a=e.items.map((r,i)=>o("li",{children:V(r)},i));return e.ordered?o("ol",{start:e.start===1?void 0:e.start,children:a},n):o("ul",{children:a},n)}case"table":return o("div",{className:"agi-md__table",children:o("table",{children:[o("thead",{children:o("tr",{children:e.header.map((a,r)=>o("th",{style:sn(e.align[r]),children:V(a)},r))})}),o("tbody",{children:e.rows.map((a,r)=>o("tr",{children:e.header.map((i,s)=>o("td",{style:sn(e.align[s]),children:V(a[s]??"")},s))},r))})]})},n);case"rule":return o("hr",{},n)}})}function sn(t){return t?{textAlign:t}:void 0}var sa=/(`+)([\s\S]*?)\1|\*\*([\s\S]+?)\*\*|(?<![\w`])__([\s\S]+?)__(?![\w])|~~([\s\S]+?)~~|\*([^*\n]+?)\*|(?<![\w`])_([^_\n]+?)_(?![\w])|\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)|(https?:\/\/[^\s<]*[^\s<.,;:!?)\]'"])/g;function V(t){let e=[],n=0,a=0,r=new RegExp(sa.source,"g"),i=r.exec(t);for(;i;){i.index>n&&e.push(t.slice(n,i.index));let[,,s,d,c,u,g,f,l,p,_]=i;s!==void 0?e.push(o("code",{children:s.trim()},a++)):d!==void 0||c!==void 0?e.push(o("strong",{children:V(d??c)},a++)):u!==void 0?e.push(o("del",{children:V(u)},a++)):g!==void 0||f!==void 0?e.push(o("em",{children:V(g??f)},a++)):l!==void 0&&p!==void 0?e.push(ln(a++,p,V(l))):_!==void 0&&e.push(ln(a++,_,_)),n=i.index+i[0].length,i=r.exec(t)}return n<t.length&&e.push(t.slice(n)),e}var la=/^(https?:\/\/|mailto:)/i;function ln(t,e,n){return la.test(e)?o("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:n},t):o(P,{children:n},t)}var Z=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),Xe=t=>Array.isArray(t)&&t.every(e=>typeof e=="string"),ua=t=>Array.isArray(t)&&t.every(e=>typeof e=="number");function da(t){return Z(t)&&typeof t.title=="string"&&typeof t.subtitle=="string"&&typeof t.body=="string"&&typeof t.image=="string"}function ca(t){if(!Z(t))return null;let e=t.text,n=t.buttons,a=t.table,r=t.pie,i=t.image,s=Array.isArray(t.cards)?t.cards:t.card?[t.card]:[];return!Z(e)||typeof e.content!="string"||!Array.isArray(n)||!n.every(d=>Z(d)&&typeof d.label=="string"&&typeof d.action=="string")||!Z(a)||!Xe(a.headers)||!Array.isArray(a.rows)||!a.rows.every(Xe)||!s.every(da)||!Z(r)||!Xe(r.labels)||!ua(r.data)||!Z(i)||typeof i.url!="string"||typeof i.caption!="string"?null:{text:{content:e.content},buttons:n,table:a,cards:s,pie:r,image:i}}function pn(t){let e;try{e=JSON.parse(t)}catch{return null}let n=Array.isArray(e)?e:Z(e)&&Array.isArray(e.items)?e.items:null;if(!n)return null;let a=n.map(ca);return a.some(r=>r===null)?null:{items:a}}function gn({response:t,onAction:e}){return o("div",{className:"agi-sui",children:t.items.map((n,a)=>o("div",{className:"agi-sui__item",children:[n.text.content&&o("p",{className:"agi-sui__text",children:n.text.content}),n.image.url&&o("figure",{className:"agi-sui__figure",children:[o("img",{src:n.image.url,alt:n.image.caption}),n.image.caption&&o("figcaption",{children:n.image.caption})]}),n.cards.length>0&&o("div",{className:"agi-sui__cards",children:n.cards.map((r,i)=>o("div",{className:"agi-panel agi-sui__card",children:[r.image&&o("img",{src:r.image,alt:""}),o("div",{children:[o("div",{className:"agi-sui__card-title",children:r.title}),r.subtitle&&o("div",{className:"agi-sui__card-sub",children:r.subtitle}),r.body&&o("p",{children:r.body})]})]},i))}),n.table.headers.length>0&&o("div",{className:"agi-sui__scroll",children:o("table",{className:"agi-table",children:[o("thead",{children:o("tr",{children:n.table.headers.map((r,i)=>o("th",{children:r},i))})}),o("tbody",{children:n.table.rows.map((r,i)=>o("tr",{children:r.map((s,d)=>o("td",{children:s},d))},i))})]})}),n.pie.labels.length>0&&o(pa,{labels:n.pie.labels,data:n.pie.data}),n.buttons.length>0&&o("div",{className:"agi-sui__actions",children:n.buttons.map((r,i)=>o("button",{type:"button",className:"agi-chip",onClick:()=>e?.(r.action),children:r.label},i))})]},a))})}function pa({labels:t,data:e}){let n=e.reduce((s,d)=>s+Math.max(0,d),0);if(n<=0)return null;let a=0,r=t.map((s,d)=>{let c=Math.max(0,e[d]??0),u=a;return a+=c/n*360,{label:s,value:c,start:u,end:a,color:`var(--data-${d%6+1})`}}),i=(s,d)=>{let f=(s-90)*Math.PI/180,l=(d-90)*Math.PI/180,p=d-s>180?1:0,_=50+48*Math.cos(f),v=50+48*Math.sin(f),x=50+48*Math.cos(l),y=50+48*Math.sin(l);return d-s>=360?`M50 2 A48 48 0 1 1 ${50-.01} 2 Z`:`M50 50 L${_} ${v} A48 48 0 ${p} 1 ${x} ${y} Z`};return o("div",{className:"agi-sui__pie",children:[o("svg",{viewBox:"0 0 100 100",role:"img","aria-label":t.join(", "),children:[o("title",{children:t.join(", ")}),r.map(s=>o("path",{d:i(s.start,s.end),fill:s.color},s.label))]}),o("ul",{children:r.map(s=>o("li",{children:[o("span",{style:{background:s.color}}),s.label,o("b",{children:[Math.round(s.value/n*100),"%"]})]},s.label))})]})}var tt={maxFiles:5,maxBytes:10*1024*1024};function fn(t,e=!0){let{client:n,t:a}=L(),[r,i]=w(null),[s,d]=w(null),[c,u]=w(),[g,f]=w(null),[l,p]=w([]),[_,v]=w(!1),[x]=w(()=>et()),y=K(null),m=z(async()=>{f(null);try{let C=await n.getChat(t);if("authRequired"in C){d(C.authRequired==="public"?null:C.authRequired),u(C.title);return}i(C),d(null)}catch(C){f(C instanceof M&&C.status===403?a("chat","unavailable"):a("chat","error"))}},[n,t,a]);U(()=>{e&&m()},[m,e]);let F=`/api/chat/${encodeURIComponent(t)}`,k=z(async({password:C})=>(await n.fetchRaw(F,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:C,conversationId:x})})).ok?(await m(),!0):!1,[n,F,x,m]),S=z(async C=>{let h=await n.fetchRaw(`${F}/otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:C})});return h.ok?"sent":h.status===403?"unauthorized":"error"},[n,F]),H=z(async(C,h)=>(await n.fetchRaw(`${F}/otp`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:C,otp:h})})).ok?(await m(),!0):!1,[n,F,m]),ee=z(()=>{y.current?.abort(),y.current=null,v(!1),p(C=>{let h=C[C.length-1];return!h||h.role!=="assistant"||!h.streaming?C:[...C.slice(0,-1),{...h,streaming:!1,content:h.content||a("chat","stopped")}]})},[a]),W=z(async(C,h=[])=>{let R=C.trim();if(!R&&h.length===0||_)return;let E={id:et(),role:"user",content:R,attachments:h.map(({name:T,type:J,size:le})=>({name:T,type:J,size:le}))},D=et();p(T=>[...T,E,{id:D,role:"assistant",content:"",streaming:!0}]),v(!0);let oe=new AbortController;y.current=oe;let te="",se=T=>p(J=>J.map(le=>le.id===D?{...le,...T}:le));try{for await(let T of n.sendMessage(t,{input:R,conversationId:x,files:h},oe.signal))if(T.type==="chunk")te+=T.text,se({content:te});else if(T.type==="final"){let J=ga(T.data);J&&!te&&(te=J,se({content:te}))}else T.type==="error"&&se({content:T.message,error:!0,streaming:!1});se({streaming:!1,structured:pn(te)})}catch(T){if(oe.signal.aborted)return;let J=T instanceof M&&T.code==="AUTH_REQUIRED"?a("chat","unavailable"):a("chat","error");se({content:J,error:!0,streaming:!1}),T instanceof M&&T.code==="AUTH_REQUIRED"&&m()}finally{y.current=null,v(!1)}},[_,n,t,x,a,m]);return{config:r,authNeed:s,authTitle:c,loadError:g,messages:l,busy:_,send:W,stop:ee,authenticate:k,requestCode:S,verifyCode:H,reload:m}}function ga(t){if(!t||typeof t!="object")return null;let e=t;if(!e.output)return null;for(let n of Object.values(e.output))if(n&&typeof n=="object"){let a=n;if(typeof a.content=="string")return a.content;if(typeof a.result=="string")return a.result}return null}function et(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function nt({identifier:t,mode:e="inline",position:n="right",launcherLabel:a,defaultOpen:r=!1,theme:i="auto",className:s}){let[d,c]=w(r||e!=="bubble"),{t:u}=L(),g=ge("chat"),f=fn(t,g),l=f.config?.title??f.authTitle??a??"Aginies",p=i==="auto"?void 0:i==="dark"?"dark":"light";if(!g)return null;let _=o("section",{className:B("agi-chat",`agi-chat--${e}`,p,s),"data-theme":p,"aria-label":l,children:[o("header",{className:"agi-chat__head",children:[o("div",{className:"agi-chat__title",children:[f.config?.customizations.imageUrl&&o("img",{src:f.config.customizations.imageUrl,alt:""}),o("div",{children:[o("div",{className:"agi-chat__name",children:l}),f.config?.description&&o("div",{className:"agi-chat__desc",children:f.config.description})]})]}),e==="bubble"&&o("button",{type:"button",className:"agi-chat__close",onClick:()=>c(!1),"aria-label":u("chat","close"),children:"\xD7"})]}),f.loadError?o("div",{className:"agi-chat__state",children:[o("p",{children:f.loadError}),o(I,{variant:"outline",size:"sm",onClick:()=>{f.reload()},children:u("common","retry")})]}):f.authNeed?o(ba,{need:f.authNeed,onPassword:f.authenticate,onRequestCode:f.requestCode,onVerifyCode:f.verifyCode}):f.config?o(P,{children:[o(fa,{messages:f.messages,welcome:f.config.customizations.welcomeMessage||u("chat","welcome"),onAction:v=>{f.send(v)}}),o(_a,{busy:f.busy,onSend:f.send,onStop:f.stop})]}):o("div",{className:"agi-chat__state",children:o(re,{label:u("common","loading")})}),o("footer",{className:"agi-chat__foot",children:o("a",{href:"https://www.aginies.com",target:"_blank",rel:"noreferrer",children:u("chat","poweredBy")})})]});return e!=="bubble"?_:o("div",{className:B("agi-bubble",`agi-bubble--${n}`,p),"data-theme":p,children:[d&&_,o("button",{type:"button",className:B("agi-bubble__launcher",d&&"agi-bubble__launcher--open"),onClick:()=>c(v=>!v),"aria-expanded":d,"aria-label":d?u("chat","close"):u("chat","open"),children:[o("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o("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-5 4v-4H6.5A2.5 2.5 0 0 1 4 13.5v-8z"}),o("path",{d:"M8 8h8M8 11.5h5"})]}),!d&&o("span",{children:a??l})]})]})}function fa({messages:t,welcome:e,onAction:n}){let{t:a}=L(),r=K(null);return U(()=>{r.current?.scrollIntoView?.({block:"end"})},[]),o("div",{className:"agi-chat__messages",role:"log","aria-live":"polite",children:[o("div",{className:"agi-msg agi-msg--assistant",children:[o("span",{className:"agi-msg__who",children:a("chat","assistant")}),o("div",{className:"agi-msg__body",children:e})]}),t.map(i=>o("div",{className:B("agi-msg",`agi-msg--${i.role}`,i.error&&"agi-msg--error"),children:[o("span",{className:"agi-msg__who",children:i.role==="user"?a("chat","you"):a("chat","assistant")}),o("div",{className:"agi-msg__body",children:[i.structured?o(gn,{response:i.structured,onAction:n}):i.content?i.role==="assistant"&&!i.error?o(un,{className:"agi-md",text:i.content}):o("p",{children:i.content}):i.streaming?o("span",{className:"agi-msg__thinking",children:[o(re,{label:a("chat","thinking")})," ",a("chat","thinking")]}):null,i.attachments&&i.attachments.length>0&&o("ul",{className:"agi-msg__files","aria-label":a("chat","attachments"),children:i.attachments.map((s,d)=>o("li",{className:"agi-file",children:[o(_n,{}),o("span",{className:"agi-file__name",children:s.name}),o("span",{className:"agi-file__size",children:ha(s.size)})]},d))})]})]},i.id)),o("div",{ref:r})]})}function _a({busy:t,onSend:e,onStop:n}){let{t:a}=L(),[r,i]=w(""),[s,d]=w([]),[c,u]=w(null),g=K(null),f=_=>{if(_.preventDefault(),t)return;let v=r,x=s;i(""),d([]),u(null),e(v,x)},l=async _=>{let v=Array.from(_.target.files??[]);if(_.target.value="",v.length===0)return;if(s.length+v.length>tt.maxFiles){u(a("chat","tooManyFiles"));return}if(v.some(y=>y.size>tt.maxBytes)){u(a("chat","fileTooLarge"));return}u(null);let x=await Promise.all(v.map(ma));d(y=>[...y,...x])},p=r.trim().length>0||s.length>0;return o("form",{className:"agi-chat__composer",onSubmit:f,children:[(s.length>0||c)&&o("div",{className:"agi-chat__pending",children:[s.map((_,v)=>o("span",{className:"agi-file agi-file--pending",children:[o(_n,{}),o("span",{className:"agi-file__name",children:_.name}),o("button",{type:"button",className:"agi-file__remove","aria-label":`${a("chat","removeFile")}: ${_.name}`,onClick:()=>d(x=>x.filter((y,m)=>m!==v)),children:"\xD7"})]},v)),c&&o("span",{className:"agi-chat__file-error",children:c})]}),o("div",{className:"agi-chat__row",children:[o("input",{ref:g,type:"file",multiple:!0,hidden:!0,onChange:l,"data-testid":"agi-file-input"}),o(I,{variant:"ghost",type:"button","aria-label":a("chat","attach"),title:a("chat","attach"),disabled:t,onClick:()=>g.current?.click(),children:o("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:o("path",{d:"M21 12.5 12.8 20.7a5.5 5.5 0 0 1-7.8-7.8l8.6-8.6a3.5 3.5 0 0 1 5 5l-8.6 8.6a1.5 1.5 0 0 1-2.1-2.1L15.5 8",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}),o(Y,{value:r,onChange:_=>i(_.target.value),placeholder:a("chat","placeholder"),"aria-label":a("chat","placeholder"),autoComplete:"off"}),t?o(I,{variant:"outline",onClick:n,children:a("chat","stop")}):o(I,{variant:"signal",type:"submit",disabled:!p,children:a("chat","send")})]})]})}function ma(t){return new Promise((e,n)=>{let a=new FileReader;a.onload=()=>e({name:t.name,type:t.type||"application/octet-stream",size:t.size,data:String(a.result),lastModified:t.lastModified}),a.onerror=()=>n(a.error),a.readAsDataURL(t)})}function ha(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(0)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function _n(){return o("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[o("path",{d:"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8l-5-5z",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round"}),o("path",{d:"M14 3v5h5",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round"})]})}function ba({need:t,onPassword:e,onRequestCode:n,onVerifyCode:a}){let{t:r,client:i}=L();return t==="sso"?o("div",{className:"agi-chat__state",children:[o("h3",{children:r("auth","ssoTitle")}),o("p",{children:r("auth","ssoHint")}),o(I,{variant:"signal",onClick:()=>window.open(`${i.baseUrl}/chat/`,"_blank","noopener"),children:r("auth","ssoButton")})]}):t==="email"?o(xa,{onRequestCode:n,onVerifyCode:a}):o(va,{onPassword:e})}function va({onPassword:t}){let{t:e}=L(),[n,a]=w(""),[r,i]=w(null),[s,d]=w(!1);return o("form",{className:"agi-chat__state agi-chat__auth",onSubmit:async u=>{u.preventDefault(),d(!0),i(null);let g=await t({password:n});d(!1),g||i(e("auth","invalidPassword"))},children:[o("h3",{children:e("auth","passwordTitle")}),o("p",{children:e("auth","passwordHint")}),o(ae,{label:e("auth","password"),error:r??void 0,children:o(Y,{type:"password",value:n,onChange:u=>a(u.target.value),required:!0,autoComplete:"current-password"})}),o(I,{variant:"signal",type:"submit",disabled:s||!n,children:e("auth","continue")})]})}function xa({onRequestCode:t,onVerifyCode:e}){let{t:n}=L(),[a,r]=w(""),[i,s]=w(""),[d,c]=w("email"),[u,g]=w(null),[f,l]=w(null),[p,_]=w(!1),v=async()=>{_(!0),g(null),l(null);let m=await t(a.trim());_(!1),m==="sent"?(c("code"),l(n("auth","codeSent"))):g(n("auth",m==="unauthorized"?"invalidEmail":"codeError"))},x=async()=>{_(!0),g(null),l(null);let m=await e(a.trim(),i.trim());_(!1),m||g(n("auth","invalidCode"))},y=m=>{m.preventDefault(),d==="email"?v():x()};return d==="code"?o("form",{className:"agi-chat__state agi-chat__auth",onSubmit:y,children:[o("h3",{children:n("auth","emailTitle")}),o("p",{children:[n("auth","codeHint")," ",o("strong",{children:a})]}),o(ae,{label:n("auth","code"),error:u??void 0,hint:f??void 0,children:o(Y,{inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]{6}",maxLength:6,value:i,onChange:m=>s(m.target.value.replace(/\D/g,"")),required:!0})}),o("div",{className:"agi-chat__auth-actions",children:[o(I,{variant:"signal",type:"submit",disabled:p||i.length!==6,children:n("auth","verify")}),o(I,{variant:"ghost",type:"button",disabled:p,onClick:()=>{v()},children:n("auth","resend")}),o(I,{variant:"ghost",type:"button",disabled:p,onClick:()=>{c("email"),s(""),g(null),l(null)},children:n("auth","back")})]})]}):o("form",{className:"agi-chat__state agi-chat__auth",onSubmit:y,children:[o("h3",{children:n("auth","emailTitle")}),o("p",{children:n("auth","emailHint")}),o(ae,{label:n("auth","email"),error:u??void 0,children:o(Y,{type:"email",value:a,onChange:m=>r(m.target.value),required:!0,autoComplete:"email"})}),o(I,{variant:"signal",type:"submit",disabled:p||!a.trim(),children:n("auth","sendCode")})]})}var mn=`/* @aginies/tokens v0.1.0 \u2014 generated from src/tokens.ts. Do not edit by hand. */
|
|
8
|
+
`),n=[],a=0,r=[],i=()=>{r.length>0&&(n.push({kind:"paragraph",lines:r}),r=[])};for(;a<e.length;){let l=e[a];if(l.trim()===""){i(),a+=1;continue}let c=_a.exec(l);if(c){i();let p=c[1],b=c[2]??"",s=[];for(a+=1;a<e.length&&!e[a].trim().startsWith(p);)s.push(e[a]),a+=1;a+=1,n.push({kind:"code",lang:b,code:s.join(`
|
|
9
|
+
`)});continue}let d=ba.exec(l);if(d){i(),n.push({kind:"heading",level:d[1].length,text:d[2]??""}),a+=1;continue}if(ha.test(l)){i(),n.push({kind:"rule"}),a+=1;continue}if(et.test(l)){i();let p=[];for(;a<e.length&&et.test(e[a]);)p.push(et.exec(e[a])[1]??""),a+=1;n.push({kind:"quote",blocks:vn(p.join(`
|
|
10
|
+
`))});continue}let u=tt.exec(l);if(u){i();let p=u[2]!==void 0,b=p?Number.parseInt(u[2],10):1,s=[];for(;a<e.length;){let g=tt.exec(e[a]);if(g&&g[2]!==void 0===p)s.push(g[3]??""),a+=1;else if(s.length>0&&e[a].trim()!==""&&/^\s{2,}/.test(e[a])&&!tt.test(e[a]))s[s.length-1]=`${s[s.length-1]} ${e[a].trim()}`,a+=1;else break}n.push({kind:"list",ordered:p,start:b,items:s});continue}if(l.includes("|")&&a+1<e.length&&va.test(e[a+1])){i();let p=nt(l),b=nt(e[a+1]).map(g=>{let f=g.startsWith(":"),C=g.endsWith(":");return f&&C?"center":C?"right":f?"left":null}),s=[];for(a+=2;a<e.length&&e[a].includes("|");)s.push(nt(e[a])),a+=1;n.push({kind:"table",header:p,align:b,rows:s});continue}r.push(l),a+=1}return i(),n}function nt(t){return t.trim().replace(/^\|/,"").replace(/\|$/,"").split(/(?<!\\)\|/).map(n=>n.replace(/\\\|/g,"|").trim())}function xn(t){return t.map((e,n)=>{switch(e.kind){case"paragraph":return o("p",{children:e.lines.map((a,r)=>o(T,{children:[r>0&&o("br",{}),Z(a)]},r))},n);case"heading":{let a=`h${Math.min(e.level+2,6)}`;return o(a,{children:Z(e.text)},n)}case"code":return o("pre",{"data-lang":e.lang||void 0,children:o("code",{children:e.code})},n);case"quote":return o("blockquote",{children:xn(e.blocks)},n);case"list":{let a=e.items.map((r,i)=>o("li",{children:Z(r)},i));return e.ordered?o("ol",{start:e.start===1?void 0:e.start,children:a},n):o("ul",{children:a},n)}case"table":return o("div",{className:"agi-md__table",children:o("table",{children:[o("thead",{children:o("tr",{children:e.header.map((a,r)=>o("th",{style:bn(e.align[r]),children:Z(a)},r))})}),o("tbody",{children:e.rows.map((a,r)=>o("tr",{children:e.header.map((i,l)=>o("td",{style:bn(e.align[l]),children:Z(a[l]??"")},l))},r))})]})},n);case"rule":return o("hr",{},n)}})}function bn(t){return t?{textAlign:t}:void 0}var xa=/(`+)([\s\S]*?)\1|\*\*([\s\S]+?)\*\*|(?<![\w`])__([\s\S]+?)__(?![\w])|~~([\s\S]+?)~~|\*([^*\n]+?)\*|(?<![\w`])_([^_\n]+?)_(?![\w])|\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)|(https?:\/\/[^\s<]*[^\s<.,;:!?)\]'"])/g;function Z(t){let e=[],n=0,a=0,r=new RegExp(xa.source,"g"),i=r.exec(t);for(;i;){i.index>n&&e.push(t.slice(n,i.index));let[,,l,c,d,u,p,b,s,g,f]=i;l!==void 0?e.push(o("code",{children:l.trim()},a++)):c!==void 0||d!==void 0?e.push(o("strong",{children:Z(c??d)},a++)):u!==void 0?e.push(o("del",{children:Z(u)},a++)):p!==void 0||b!==void 0?e.push(o("em",{children:Z(p??b)},a++)):s!==void 0&&g!==void 0?e.push(hn(a++,g,Z(s))):f!==void 0&&e.push(hn(a++,f,f)),n=i.index+i[0].length,i=r.exec(t)}return n<t.length&&e.push(t.slice(n)),e}var ya=/^(https?:\/\/|mailto:)/i;function hn(t,e,n){return ya.test(e)?o("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:n},t):o(T,{children:n},t)}var oe=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),rt=t=>Array.isArray(t)&&t.every(e=>typeof e=="string"),ka=t=>Array.isArray(t)&&t.every(e=>typeof e=="number");function wa(t){return oe(t)&&typeof t.title=="string"&&typeof t.subtitle=="string"&&typeof t.body=="string"&&typeof t.image=="string"}function Ca(t){if(!oe(t))return null;let e=t.text,n=t.buttons,a=t.table,r=t.pie,i=t.image,l=Array.isArray(t.cards)?t.cards:t.card?[t.card]:[];return!oe(e)||typeof e.content!="string"||!Array.isArray(n)||!n.every(c=>oe(c)&&typeof c.label=="string"&&typeof c.action=="string")||!oe(a)||!rt(a.headers)||!Array.isArray(a.rows)||!a.rows.every(rt)||!l.every(wa)||!oe(r)||!rt(r.labels)||!ka(r.data)||!oe(i)||typeof i.url!="string"||typeof i.caption!="string"?null:{text:{content:e.content},buttons:n,table:a,cards:l,pie:r,image:i}}function yn(t){let e;try{e=JSON.parse(t)}catch{return null}let n=Array.isArray(e)?e:oe(e)&&Array.isArray(e.items)?e.items:null;if(!n)return null;let a=n.map(Ca);return a.some(r=>r===null)?null:{items:a}}function kn({response:t,onAction:e}){return o("div",{className:"agi-sui",children:t.items.map((n,a)=>o("div",{className:"agi-sui__item",children:[n.text.content&&o("p",{className:"agi-sui__text",children:n.text.content}),n.image.url&&o("figure",{className:"agi-sui__figure",children:[o("img",{src:n.image.url,alt:n.image.caption}),n.image.caption&&o("figcaption",{children:n.image.caption})]}),n.cards.length>0&&o("div",{className:"agi-sui__cards",children:n.cards.map((r,i)=>o("div",{className:"agi-panel agi-sui__card",children:[r.image&&o("img",{src:r.image,alt:""}),o("div",{children:[o("div",{className:"agi-sui__card-title",children:r.title}),r.subtitle&&o("div",{className:"agi-sui__card-sub",children:r.subtitle}),r.body&&o("p",{children:r.body})]})]},i))}),n.table.headers.length>0&&o("div",{className:"agi-sui__scroll",children:o("table",{className:"agi-table",children:[o("thead",{children:o("tr",{children:n.table.headers.map((r,i)=>o("th",{children:r},i))})}),o("tbody",{children:n.table.rows.map((r,i)=>o("tr",{children:r.map((l,c)=>o("td",{children:l},c))},i))})]})}),n.pie.labels.length>0&&o(Aa,{labels:n.pie.labels,data:n.pie.data}),n.buttons.length>0&&o("div",{className:"agi-sui__actions",children:n.buttons.map((r,i)=>o("button",{type:"button",className:"agi-chip",onClick:()=>e?.(r.action),children:r.label},i))})]},a))})}function Aa({labels:t,data:e}){let n=e.reduce((l,c)=>l+Math.max(0,c),0);if(n<=0)return null;let a=0,r=t.map((l,c)=>{let d=Math.max(0,e[c]??0),u=a;return a+=d/n*360,{label:l,value:d,start:u,end:a,color:`var(--data-${c%6+1})`}}),i=(l,c)=>{let b=(l-90)*Math.PI/180,s=(c-90)*Math.PI/180,g=c-l>180?1:0,f=50+48*Math.cos(b),C=50+48*Math.sin(b),w=50+48*Math.cos(s),y=50+48*Math.sin(s);return c-l>=360?`M50 2 A48 48 0 1 1 ${50-.01} 2 Z`:`M50 50 L${f} ${C} A48 48 0 ${g} 1 ${w} ${y} Z`};return o("div",{className:"agi-sui__pie",children:[o("svg",{viewBox:"0 0 100 100",role:"img","aria-label":t.join(", "),children:[o("title",{children:t.join(", ")}),r.map(l=>o("path",{d:i(l.start,l.end),fill:l.color},l.label))]}),o("ul",{children:r.map(l=>o("li",{children:[o("span",{style:{background:l.color}}),l.label,o("b",{children:[Math.round(l.value/n*100),"%"]})]},l.label))})]})}var Fa=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"],Sa=800,Ea=.02;function Ra(){return typeof window<"u"&&typeof navigator<"u"&&!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<"u"}function wn({identifier:t,onTranscript:e,language:n,silenceMs:a=1400,maxMs:r=6e4}){let{client:i,t:l}=j(),c=Ra(),[d,u]=F(c?"idle":"unsupported"),[p,b]=F(null),[s,g]=F(0),f=M(null),C=M(null),w=M([]),y=M(!1),m=M([]),v=M(null),h=M(null),A=M(null),L=M(!1),V=M(e);V.current=e;let $=B(()=>{for(let x of m.current)window.clearTimeout(x);m.current=[],v.current&&(window.clearInterval(v.current.interval),v.current.ctx.close().catch(()=>{}),v.current=null),g(0)},[]),S=B(()=>{for(let x of C.current?.getTracks()??[])x.stop();C.current=null},[]),_=B(()=>{let x=h.current;x&&(x.pause(),x.src="",h.current=null),A.current&&(URL.revokeObjectURL(A.current),A.current=null),u(P=>P==="speaking"?"idle":P)},[]),R=B(x=>{x.stop()},[]),E=B(()=>{let x=f.current;!x||x.state==="inactive"||(y.current=!1,R(x))},[R]),W=B(()=>{let x=f.current;!x||x.state==="inactive"||(y.current=!0,R(x))},[R]),X=B((x,P)=>{let O=typeof AudioContext<"u"?AudioContext:window.webkitAudioContext;if(O)try{let U=new O,J=U.createAnalyser();J.fftSize=2048,U.createMediaStreamSource(x).connect(J);let pe=new Uint8Array(J.fftSize),te=!1,ut=Date.now(),Bn=window.setInterval(()=>{J.getByteTimeDomainData(pe);let ct=0;for(let Ln of pe){let pt=(Ln-128)/128;ct+=pt*pt}let dt=Math.sqrt(ct/pe.length);g(Math.min(1,dt*6)),dt>Ea?(te=!0,ut=Date.now()):te&&Date.now()-ut>a&&P()},100);v.current={ctx:U,interval:Bn}}catch{}},[a]),ee=B(async()=>{if(!c){u("unsupported");return}if(L.current||f.current&&f.current.state!=="inactive")return;L.current=!0,_(),b(null);let x;try{x=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{L.current=!1,u("denied"),b(l("voice","micDenied"));return}L.current=!1,C.current=x;let P=Fa.find(U=>MediaRecorder.isTypeSupported?.(U)),O=new MediaRecorder(x,P?{mimeType:P}:void 0);f.current=O,w.current=[],y.current=!1,O.ondataavailable=U=>{U.data&&U.data.size>0&&w.current.push(U.data)},O.onstop=()=>{$(),S(),f.current=null;let U=O.mimeType||P||"audio/webm",J=new Blob(w.current,{type:U});if(w.current=[],y.current||J.size<Sa){u("idle");return}u("transcribing");let pe=U.includes("mp4")?"m4a":U.includes("ogg")?"ogg":"webm";i.transcribe(t,J,`turn.${pe}`,n).then(te=>{u("idle"),te.transcript&&V.current(te.transcript)}).catch(te=>{u("idle"),b(te instanceof I&&te.code==="VOICE_UNAVAILABLE"?l("voice","unavailable"):l("voice","error"))})},O.start(250),u("listening"),X(x,()=>E()),m.current.push(window.setTimeout(()=>E(),r))},[c,_,l,i,t,n,r,E,$,S,X]),se=B(async x=>{_(),b(null),u("speaking");try{let P=await i.speak(t,x),O=URL.createObjectURL(P);A.current=O;let U=new Audio(O);h.current=U,await new Promise(J=>{U.onended=()=>J(),U.onerror=()=>J(),U.onpause=()=>J(),U.play().catch(()=>J())})}catch(P){b(P instanceof I&&P.code==="VOICE_UNAVAILABLE"?l("voice","unavailable"):l("voice","error"))}finally{A.current&&URL.revokeObjectURL(A.current),A.current=null,h.current=null,u(P=>P==="speaking"?"idle":P)}},[i,t,_,l]);return q(()=>()=>{y.current=!0,f.current&&f.current.state!=="inactive"&&f.current.stop(),$(),S();let x=h.current;x&&x.pause(),A.current&&URL.revokeObjectURL(A.current)},[$,S]),{state:d,error:p,supported:c,level:s,startListening:ee,stopListening:E,cancelListening:W,speak:se,stopSpeaking:_}}var ot={maxFiles:5,maxBytes:10*1024*1024};function Cn(t,e=!0){let{client:n,t:a}=j(),[r,i]=F(null),[l,c]=F(null),[d,u]=F(),[p,b]=F(null),[s,g]=F([]),[f,C]=F(!1),[w]=F(()=>it()),y=M(null),m=B(async()=>{b(null);try{let S=await n.getChat(t);if("authRequired"in S){c(S.authRequired==="public"?null:S.authRequired),u(S.title);return}i(S),c(null)}catch(S){b(S instanceof I&&S.status===403?a("chat","unavailable"):a("chat","error"))}},[n,t,a]);q(()=>{e&&m()},[m,e]);let v=`/api/chat/${encodeURIComponent(t)}`,h=B(async({password:S})=>(await n.fetchRaw(v,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:S,conversationId:w})})).ok?(await m(),!0):!1,[n,v,w,m]),A=B(async S=>{let _=await n.fetchRaw(`${v}/otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:S})});return _.ok?"sent":_.status===403?"unauthorized":"error"},[n,v]),L=B(async(S,_)=>(await n.fetchRaw(`${v}/otp`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:S,otp:_})})).ok?(await m(),!0):!1,[n,v,m]),V=B(()=>{y.current?.abort(),y.current=null,C(!1),g(S=>{let _=S[S.length-1];return!_||_.role!=="assistant"||!_.streaming?S:[...S.slice(0,-1),{..._,streaming:!1,content:_.content||a("chat","stopped")}]})},[a]),$=B(async(S,_=[])=>{let R=S.trim();if(!R&&_.length===0||f)return;let E={id:it(),role:"user",content:R,attachments:_.map(({name:x,type:P,size:O})=>({name:x,type:P,size:O}))},W=it();g(x=>[...x,E,{id:W,role:"assistant",content:"",streaming:!0}]),C(!0);let X=new AbortController;y.current=X;let ee="",se=x=>g(P=>P.map(O=>O.id===W?{...O,...x}:O));try{for await(let x of n.sendMessage(t,{input:R,conversationId:w,files:_},X.signal))if(x.type==="chunk")ee+=x.text,se({content:ee});else if(x.type==="final"){let P=Pa(x.data);P&&!ee&&(ee=P,se({content:ee}))}else x.type==="error"&&se({content:x.message,error:!0,streaming:!1});se({streaming:!1,structured:yn(ee)})}catch(x){if(X.signal.aborted)return;let P=x instanceof I&&x.code==="AUTH_REQUIRED"?a("chat","unavailable"):a("chat","error");se({content:P,error:!0,streaming:!1}),x instanceof I&&x.code==="AUTH_REQUIRED"&&m()}finally{y.current=null,C(!1)}},[f,n,t,w,a,m]);return{config:r,authNeed:l,authTitle:d,loadError:p,messages:s,busy:f,send:$,stop:V,authenticate:h,requestCode:A,verifyCode:L,reload:m}}function Pa(t){if(!t||typeof t!="object")return null;let e=t;if(!e.output)return null;for(let n of Object.values(e.output))if(n&&typeof n=="object"){let a=n;if(typeof a.content=="string")return a.content;if(typeof a.result=="string")return a.result}return null}function it(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function st({identifier:t,mode:e="inline",position:n="right",launcherLabel:a,defaultOpen:r=!1,theme:i="auto",voice:l=!0,className:c}){let[d,u]=F(r||e!=="bubble"),{t:p}=j(),b=he("chat"),s=Cn(t,b),[g,f]=F(!1),[C,w]=F(null),y=M(g);y.current=g;let m=M(s.send);m.current=s.send;let v=wn({identifier:t,onTranscript:_=>{y.current?m.current(_):w({id:Date.now(),text:_})}}),h=s.config?.voice,A=l&&v.supported&&h?.stt===!0,L=s.config?.title??s.authTitle??a??"Aginies",V=i==="auto"?void 0:i==="dark"?"dark":"light";if(!b)return null;let $=()=>{v.cancelListening(),v.stopSpeaking(),f(!1)},S=o("section",{className:H("agi-chat",`agi-chat--${e}`,V,c),"data-theme":V,"aria-label":L,children:[o("header",{className:"agi-chat__head",children:[o("div",{className:"agi-chat__title",children:[s.config?.customizations.imageUrl&&o("img",{src:s.config.customizations.imageUrl,alt:""}),o("div",{children:[o("div",{className:"agi-chat__name",children:L}),s.config?.description&&o("div",{className:"agi-chat__desc",children:s.config.description})]})]}),e==="bubble"&&o("button",{type:"button",className:"agi-chat__close",onClick:()=>u(!1),"aria-label":p("chat","close"),children:"\xD7"})]}),s.loadError?o("div",{className:"agi-chat__state",children:[o("p",{children:s.loadError}),o(D,{variant:"outline",size:"sm",onClick:()=>{s.reload()},children:p("common","retry")})]}):s.authNeed?o(za,{need:s.authNeed,onPassword:s.authenticate,onRequestCode:s.requestCode,onVerifyCode:s.verifyCode}):s.config?g?o(Ma,{messages:s.messages,busy:s.busy,voice:v,speakReplies:h?.tts===!0,onExit:$}):o(T,{children:[o(Ta,{messages:s.messages,welcome:s.config.customizations.welcomeMessage||p("chat","welcome"),onAction:_=>{s.send(_)}}),o(Na,{busy:s.busy,onSend:s.send,onStop:s.stop,dictation:C,voice:A?{state:v.state,error:v.error,start:v.startListening,stop:v.stopListening,onHandsFree:()=>f(!0)}:void 0})]}):o("div",{className:"agi-chat__state",children:o(ie,{label:p("common","loading")})}),o("footer",{className:"agi-chat__foot",children:o("a",{href:"https://www.aginies.com",target:"_blank",rel:"noreferrer",children:p("chat","poweredBy")})})]});return e!=="bubble"?S:o("div",{className:H("agi-bubble",`agi-bubble--${n}`,V),"data-theme":V,children:[d&&S,o("button",{type:"button",className:H("agi-bubble__launcher",d&&"agi-bubble__launcher--open"),onClick:()=>u(_=>!_),"aria-expanded":d,"aria-label":d?p("chat","close"):p("chat","open"),children:[o("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o("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-5 4v-4H6.5A2.5 2.5 0 0 1 4 13.5v-8z"}),o("path",{d:"M8 8h8M8 11.5h5"})]}),!d&&o("span",{children:a??L})]})]})}function Ta({messages:t,welcome:e,onAction:n}){let{t:a}=j(),r=M(null);return q(()=>{r.current?.scrollIntoView?.({block:"end"})},[]),o("div",{className:"agi-chat__messages",role:"log","aria-live":"polite",children:[o("div",{className:"agi-msg agi-msg--assistant",children:[o("span",{className:"agi-msg__who",children:a("chat","assistant")}),o("div",{className:"agi-msg__body",children:e})]}),t.map(i=>o("div",{className:H("agi-msg",`agi-msg--${i.role}`,i.error&&"agi-msg--error"),children:[o("span",{className:"agi-msg__who",children:i.role==="user"?a("chat","you"):a("chat","assistant")}),o("div",{className:"agi-msg__body",children:[i.structured?o(kn,{response:i.structured,onAction:n}):i.content?i.role==="assistant"&&!i.error?o(at,{className:"agi-md",text:i.content}):o("p",{children:i.content}):i.streaming?o("span",{className:"agi-msg__thinking",children:[o(ie,{label:a("chat","thinking")})," ",a("chat","thinking")]}):null,i.attachments&&i.attachments.length>0&&o("ul",{className:"agi-msg__files","aria-label":a("chat","attachments"),children:i.attachments.map((l,c)=>o("li",{className:"agi-file",children:[o(Fn,{}),o("span",{className:"agi-file__name",children:l.name}),o("span",{className:"agi-file__size",children:Ia(l.size)})]},c))})]})]},i.id)),o("div",{ref:r})]})}function Na({busy:t,onSend:e,onStop:n,voice:a,dictation:r}){let{t:i}=j(),[l,c]=F(""),[d,u]=F([]),[p,b]=F(null),s=M(null);q(()=>{r&&c(m=>m.trim()?`${m.trimEnd()} ${r.text}`:r.text)},[r]);let g=a?.state==="listening",f=a?.state==="transcribing",C=m=>{if(m.preventDefault(),t)return;let v=l,h=d;c(""),u([]),b(null),e(v,h)},w=async m=>{let v=Array.from(m.target.files??[]);if(m.target.value="",v.length===0)return;if(d.length+v.length>ot.maxFiles){b(i("chat","tooManyFiles"));return}if(v.some(A=>A.size>ot.maxBytes)){b(i("chat","fileTooLarge"));return}b(null);let h=await Promise.all(v.map(La));u(A=>[...A,...h])},y=l.trim().length>0||d.length>0;return o("form",{className:"agi-chat__composer",onSubmit:C,children:[(d.length>0||p)&&o("div",{className:"agi-chat__pending",children:[d.map((m,v)=>o("span",{className:"agi-file agi-file--pending",children:[o(Fn,{}),o("span",{className:"agi-file__name",children:m.name}),o("button",{type:"button",className:"agi-file__remove","aria-label":`${i("chat","removeFile")}: ${m.name}`,onClick:()=>u(h=>h.filter((A,L)=>L!==v)),children:"\xD7"})]},v)),p&&o("span",{className:"agi-chat__file-error",children:p})]}),a?.error&&o("div",{className:"agi-chat__file-error",children:a.error}),o("div",{className:"agi-chat__row",children:[o("input",{ref:s,type:"file",multiple:!0,hidden:!0,onChange:w,"data-testid":"agi-file-input"}),o(D,{variant:"ghost",type:"button","aria-label":i("chat","attach"),title:i("chat","attach"),disabled:t,onClick:()=>s.current?.click(),children:o("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:o("path",{d:"M21 12.5 12.8 20.7a5.5 5.5 0 0 1-7.8-7.8l8.6-8.6a3.5 3.5 0 0 1 5 5l-8.6 8.6a1.5 1.5 0 0 1-2.1-2.1L15.5 8",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}),o(re,{value:l,onChange:m=>c(m.target.value),placeholder:i("chat","placeholder"),"aria-label":i("chat","placeholder"),autoComplete:"off"}),a&&o(T,{children:[o(D,{variant:"ghost",type:"button",className:H("agi-chat__mic",g&&"agi-chat__mic--on"),"aria-label":g?i("voice","stopTalking"):i("voice","dictate"),"aria-pressed":g,title:g?i("voice","stopTalking"):i("voice","dictate"),disabled:t||f,onClick:()=>g?a.stop():void a.start(),children:f?o(ie,{label:i("voice","transcribing")}):o(An,{})}),o(D,{variant:"ghost",type:"button","aria-label":i("voice","handsFree"),title:i("voice","handsFree"),disabled:t||g||f,onClick:a.onHandsFree,children:o(Ba,{})})]}),t?o(D,{variant:"outline",onClick:n,children:i("chat","stop")}):o(D,{variant:"signal",type:"submit",disabled:!y,children:i("chat","send")})]})]})}function Ma({messages:t,busy:e,voice:n,speakReplies:a,onExit:r}){let{t:i}=j(),l=M(null),c=M(!0),d=[...t].reverse().find(C=>C.role==="assistant"),u=[...t].reverse().find(C=>C.role==="user");q(()=>(c.current=!0,l.current=d?.id??null,n.startListening(),()=>{c.current=!1}),[]);let p=d?.id,b=d?.streaming===!0;q(()=>{if(!d||b||p===l.current)return;l.current=p??null,(async()=>(a&&d.content&&!d.error&&await n.speak(d.content),c.current&&await n.startListening()))()},[p,b]);let s=n.state==="listening"?i("voice","listening"):n.state==="transcribing"?i("voice","transcribing"):n.state==="speaking"?i("voice","speaking"):e?i("voice","thinking"):i("voice","idle"),g=n.state==="listening"?i("voice","stopTalking"):n.state==="speaking"?i("voice","interrupt"):n.state==="transcribing"||e?"":i("voice","talk"),f=()=>{n.state==="listening"?n.stopListening():n.state==="speaking"?(n.stopSpeaking(),n.startListening()):n.state==="idle"&&!e&&n.startListening()};return o("section",{className:"agi-voice","aria-label":i("voice","handsFree"),children:[o("button",{type:"button",className:"agi-voice__exit",onClick:r,"aria-label":i("voice","exit"),children:"\xD7"}),o("div",{className:"agi-voice__status","aria-live":"polite",children:s}),u?.content&&o("p",{className:"agi-voice__you",children:u.content}),o("div",{className:"agi-voice__reply",children:d?.content?o(at,{className:"agi-md",text:d.content}):e?o(ie,{label:i("voice","thinking")}):null}),o("button",{type:"button",className:H("agi-voice__orb",`agi-voice__orb--${n.state}`,e&&"agi-voice__orb--busy"),style:{"--agi-level":n.level},onClick:f,"aria-label":g||s,disabled:n.state==="transcribing"||n.state==="unsupported",children:o(An,{size:28})}),o("div",{className:"agi-voice__hint",children:g}),n.error&&o("div",{className:"agi-voice__error",children:n.error})]})}function An({size:t=16}){return o("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),o("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v3M9 21h6"})]})}function Ba(){return o("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o("path",{d:"M4 14v-2a8 8 0 0 1 16 0v2"}),o("rect",{x:"3",y:"13",width:"4",height:"6",rx:"1.5"}),o("rect",{x:"17",y:"13",width:"4",height:"6",rx:"1.5"}),o("path",{d:"M19 19v1a2 2 0 0 1-2 2h-3"})]})}function La(t){return new Promise((e,n)=>{let a=new FileReader;a.onload=()=>e({name:t.name,type:t.type||"application/octet-stream",size:t.size,data:String(a.result),lastModified:t.lastModified}),a.onerror=()=>n(a.error),a.readAsDataURL(t)})}function Ia(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(0)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Fn(){return o("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[o("path",{d:"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8l-5-5z",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round"}),o("path",{d:"M14 3v5h5",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round"})]})}function za({need:t,onPassword:e,onRequestCode:n,onVerifyCode:a}){let{t:r,client:i}=j();return t==="sso"?o("div",{className:"agi-chat__state",children:[o("h3",{children:r("auth","ssoTitle")}),o("p",{children:r("auth","ssoHint")}),o(D,{variant:"signal",onClick:()=>window.open(`${i.baseUrl}/chat/`,"_blank","noopener"),children:r("auth","ssoButton")})]}):t==="email"?o(Ha,{onRequestCode:n,onVerifyCode:a}):o(Ua,{onPassword:e})}function Ua({onPassword:t}){let{t:e}=j(),[n,a]=F(""),[r,i]=F(null),[l,c]=F(!1);return o("form",{className:"agi-chat__state agi-chat__auth",onSubmit:async u=>{u.preventDefault(),c(!0),i(null);let p=await t({password:n});c(!1),p||i(e("auth","invalidPassword"))},children:[o("h3",{children:e("auth","passwordTitle")}),o("p",{children:e("auth","passwordHint")}),o(ce,{label:e("auth","password"),error:r??void 0,children:o(re,{type:"password",value:n,onChange:u=>a(u.target.value),required:!0,autoComplete:"current-password"})}),o(D,{variant:"signal",type:"submit",disabled:l||!n,children:e("auth","continue")})]})}function Ha({onRequestCode:t,onVerifyCode:e}){let{t:n}=j(),[a,r]=F(""),[i,l]=F(""),[c,d]=F("email"),[u,p]=F(null),[b,s]=F(null),[g,f]=F(!1),C=async()=>{f(!0),p(null),s(null);let m=await t(a.trim());f(!1),m==="sent"?(d("code"),s(n("auth","codeSent"))):p(n("auth",m==="unauthorized"?"invalidEmail":"codeError"))},w=async()=>{f(!0),p(null),s(null);let m=await e(a.trim(),i.trim());f(!1),m||p(n("auth","invalidCode"))},y=m=>{m.preventDefault(),c==="email"?C():w()};return c==="code"?o("form",{className:"agi-chat__state agi-chat__auth",onSubmit:y,children:[o("h3",{children:n("auth","emailTitle")}),o("p",{children:[n("auth","codeHint")," ",o("strong",{children:a})]}),o(ce,{label:n("auth","code"),error:u??void 0,hint:b??void 0,children:o(re,{inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]{6}",maxLength:6,value:i,onChange:m=>l(m.target.value.replace(/\D/g,"")),required:!0})}),o("div",{className:"agi-chat__auth-actions",children:[o(D,{variant:"signal",type:"submit",disabled:g||i.length!==6,children:n("auth","verify")}),o(D,{variant:"ghost",type:"button",disabled:g,onClick:()=>{C()},children:n("auth","resend")}),o(D,{variant:"ghost",type:"button",disabled:g,onClick:()=>{d("email"),l(""),p(null),s(null)},children:n("auth","back")})]})]}):o("form",{className:"agi-chat__state agi-chat__auth",onSubmit:y,children:[o("h3",{children:n("auth","emailTitle")}),o("p",{children:n("auth","emailHint")}),o(ce,{label:n("auth","email"),error:u??void 0,children:o(re,{type:"email",value:a,onChange:m=>r(m.target.value),required:!0,autoComplete:"email"})}),o(D,{variant:"signal",type:"submit",disabled:g||!a.trim(),children:n("auth","sendCode")})]})}var Sn=`/* @aginies/tokens v0.1.0 \u2014 generated from src/tokens.ts. Do not edit by hand. */
|
|
11
11
|
|
|
12
12
|
/* Static tokens: type, shape, spacing, motion, layout. */
|
|
13
13
|
:root {
|
|
@@ -1523,6 +1523,124 @@
|
|
|
1523
1523
|
gap: 8px;
|
|
1524
1524
|
}
|
|
1525
1525
|
|
|
1526
|
+
/* \u2500\u2500\u2500 voice \u2500\u2500\u2500 */
|
|
1527
|
+
.agi-chat__mic--on {
|
|
1528
|
+
color: var(--signal);
|
|
1529
|
+
border-color: var(--signal);
|
|
1530
|
+
background: var(--signal-soft);
|
|
1531
|
+
}
|
|
1532
|
+
.agi-voice {
|
|
1533
|
+
position: relative;
|
|
1534
|
+
flex: 1;
|
|
1535
|
+
min-height: 0;
|
|
1536
|
+
display: grid;
|
|
1537
|
+
grid-template-rows: auto auto 1fr auto auto;
|
|
1538
|
+
justify-items: center;
|
|
1539
|
+
align-content: center;
|
|
1540
|
+
gap: 14px;
|
|
1541
|
+
padding: 28px 20px 24px;
|
|
1542
|
+
text-align: center;
|
|
1543
|
+
overflow: hidden;
|
|
1544
|
+
background: radial-gradient(circle at 50% 30%, var(--signal-soft), transparent 60%);
|
|
1545
|
+
}
|
|
1546
|
+
.agi-voice__exit {
|
|
1547
|
+
position: absolute;
|
|
1548
|
+
top: 10px;
|
|
1549
|
+
right: 12px;
|
|
1550
|
+
width: 28px;
|
|
1551
|
+
height: 28px;
|
|
1552
|
+
border-radius: 999px;
|
|
1553
|
+
border: 1px solid var(--line);
|
|
1554
|
+
background: var(--panel);
|
|
1555
|
+
color: var(--text-2);
|
|
1556
|
+
font-size: 16px;
|
|
1557
|
+
line-height: 1;
|
|
1558
|
+
cursor: pointer;
|
|
1559
|
+
}
|
|
1560
|
+
.agi-voice__exit:hover {
|
|
1561
|
+
color: var(--text);
|
|
1562
|
+
border-color: var(--text-2);
|
|
1563
|
+
}
|
|
1564
|
+
.agi-voice__status {
|
|
1565
|
+
font-family: var(--font-mono);
|
|
1566
|
+
font-size: 10.5px;
|
|
1567
|
+
letter-spacing: 0.1em;
|
|
1568
|
+
text-transform: uppercase;
|
|
1569
|
+
color: var(--mute);
|
|
1570
|
+
}
|
|
1571
|
+
.agi-voice__you {
|
|
1572
|
+
margin: 0;
|
|
1573
|
+
max-width: 34ch;
|
|
1574
|
+
color: var(--text-2);
|
|
1575
|
+
font-size: 13.5px;
|
|
1576
|
+
}
|
|
1577
|
+
.agi-voice__reply {
|
|
1578
|
+
min-height: 0;
|
|
1579
|
+
max-width: 46ch;
|
|
1580
|
+
overflow-y: auto;
|
|
1581
|
+
color: var(--text);
|
|
1582
|
+
text-align: left;
|
|
1583
|
+
}
|
|
1584
|
+
.agi-voice__reply .agi-md {
|
|
1585
|
+
font-size: 15px;
|
|
1586
|
+
}
|
|
1587
|
+
.agi-voice__orb {
|
|
1588
|
+
width: 92px;
|
|
1589
|
+
height: 92px;
|
|
1590
|
+
border-radius: 999px;
|
|
1591
|
+
border: 1px solid var(--line-2);
|
|
1592
|
+
background: var(--panel-2);
|
|
1593
|
+
color: var(--text);
|
|
1594
|
+
display: grid;
|
|
1595
|
+
place-items: center;
|
|
1596
|
+
cursor: pointer;
|
|
1597
|
+
transition:
|
|
1598
|
+
box-shadow 120ms linear,
|
|
1599
|
+
border-color 160ms ease,
|
|
1600
|
+
background 160ms ease;
|
|
1601
|
+
}
|
|
1602
|
+
.agi-voice__orb:hover {
|
|
1603
|
+
border-color: var(--text-2);
|
|
1604
|
+
}
|
|
1605
|
+
.agi-voice__orb:disabled {
|
|
1606
|
+
cursor: default;
|
|
1607
|
+
opacity: 0.6;
|
|
1608
|
+
}
|
|
1609
|
+
.agi-voice__orb--listening {
|
|
1610
|
+
border-color: var(--signal);
|
|
1611
|
+
color: var(--signal);
|
|
1612
|
+
background: var(--signal-soft);
|
|
1613
|
+
box-shadow: 0 0 0 calc(4px + var(--agi-level, 0) * 28px)
|
|
1614
|
+
color-mix(in srgb, var(--signal) 22%, transparent);
|
|
1615
|
+
}
|
|
1616
|
+
.agi-voice__orb--speaking {
|
|
1617
|
+
border-color: var(--signal);
|
|
1618
|
+
animation: agi-voice-speak 1.4s ease-in-out infinite;
|
|
1619
|
+
}
|
|
1620
|
+
.agi-voice__orb--busy,
|
|
1621
|
+
.agi-voice__orb--transcribing {
|
|
1622
|
+
border-style: dashed;
|
|
1623
|
+
}
|
|
1624
|
+
@keyframes agi-voice-speak {
|
|
1625
|
+
0%,
|
|
1626
|
+
100% {
|
|
1627
|
+
box-shadow: 0 0 0 4px color-mix(in srgb, var(--signal) 18%, transparent);
|
|
1628
|
+
}
|
|
1629
|
+
50% {
|
|
1630
|
+
box-shadow: 0 0 0 16px color-mix(in srgb, var(--signal) 8%, transparent);
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
.agi-voice__hint {
|
|
1634
|
+
min-height: 1.4em;
|
|
1635
|
+
font-size: 13px;
|
|
1636
|
+
color: var(--text-2);
|
|
1637
|
+
}
|
|
1638
|
+
.agi-voice__error {
|
|
1639
|
+
font-size: 12.5px;
|
|
1640
|
+
color: var(--bad);
|
|
1641
|
+
max-width: 40ch;
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1526
1644
|
/* \u2500\u2500\u2500 markdown in replies \u2500\u2500\u2500 */
|
|
1527
1645
|
.agi-md {
|
|
1528
1646
|
display: grid;
|
|
@@ -2276,5 +2394,5 @@
|
|
|
2276
2394
|
font-size: 10.5px;
|
|
2277
2395
|
color: var(--mute);
|
|
2278
2396
|
}
|
|
2279
|
-
`;function
|
|
2397
|
+
`;function lt(t){return{render:function(e){Xt(e,t)},unmount:function(){tn(t)}}}var Da="0.1.0",En="aginies-embed-styles",de=null;function qa(){if(typeof document>"u"||document.getElementById(En))return;let t=document.createElement("style");t.id=En,t.textContent=Sn,document.head.appendChild(t)}function Rn(t){return qa(),de=Ze(t),de}function Pn(t){if(!de)throw new Error("[aginies] call Aginies.init({ baseUrl, token }) before Aginies.chat()");let{container:e,mode:n="bubble",...a}=t,r=Nn(e,n),i=lt(r);return i.render(Q(Ie,{client:de,children:Q(st,{...a,mode:n})})),{element:r,unmount:()=>{i.unmount(),r.dataset.aginiesOwned==="true"&&r.remove()}}}function Tn(t){if(!de)throw new Error("[aginies] call Aginies.init({ baseUrl, token }) before Aginies.approval()");let{container:e,...n}=t,a=Nn(e,"approval"),r=lt(a);return r.render(Q(Ie,{client:de,children:Q(Xe,n)})),{element:a,unmount:()=>{r.unmount(),a.dataset.aginiesOwned==="true"&&a.remove()}}}function Nn(t,e){if(t){let a=typeof t=="string"?document.querySelector(t):t;if(!a)throw new Error(`[aginies] container not found: ${String(t)}`);return a}let n=document.createElement("div");return n.dataset.aginiesOwned="true",n.dataset.aginiesMode=e,document.body.appendChild(n),n}function Mn(t=ja()){if(!t)return null;let e=t.dataset;if(!e.baseUrl||!e.token)return null;if(Rn({baseUrl:e.baseUrl,token:e.token,locale:e.locale==="tr"||e.locale==="en"?e.locale:void 0}),e.approval){let[a,r,i]=e.approval.split("/");if(!a||!r)return null;let l=()=>Tn({workflowId:a,executionId:r,contextId:i,container:e.container});return document.readyState==="loading"?(document.addEventListener("DOMContentLoaded",()=>l(),{once:!0}),null):l()}if(!e.chat)return null;let n=()=>Pn({identifier:e.chat,mode:e.mode??"bubble",position:e.position??"right",theme:e.theme??"auto",launcherLabel:e.label,container:e.container});return document.readyState==="loading"?(document.addEventListener("DOMContentLoaded",()=>n(),{once:!0}),null):n()}function ja(){return typeof document>"u"?null:document.currentScript??null}typeof window<"u"&&Mn();return qn($a);})();
|
|
2280
2398
|
//# sourceMappingURL=aginies.js.map
|