@evelan/jexity-widget 0.10.5-canary.21 → 0.10.5
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/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/react.mjs +4 -4
- package/dist/react.mjs.map +1 -1
- package/dist/widget.js +3 -3
- package/dist/widget.js.map +1 -1
- package/package.json +1 -1
package/dist/widget.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(){"use strict";var Me,m,qn,Mn,ue,Ln,On,Nn,zn,Et,Pt,qt,Bn,Le={},Qn=[],Vi=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Oe=Array.isArray;function H(t,e){for(var n in e)t[n]=e[n];return t}function Mt(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function O(t,e,n){var r,i,s,o={};for(s in e)s=="key"?r=e[s]:s=="ref"?i=e[s]:o[s]=e[s];if(arguments.length>2&&(o.children=arguments.length>3?Me.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(s in t.defaultProps)o[s]===void 0&&(o[s]=t.defaultProps[s]);return Ne(t,o,r,i,null)}function Ne(t,e,n,r,i){var s={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++qn,__i:-1,__u:0};return i==null&&m.vnode!=null&&m.vnode(s),s}function Wi(){return{current:null}}function N(t){return t.children}function F(t,e){this.props=t,this.context=e}function ye(t,e){if(e==null)return t.__?ye(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"?ye(t):null}function Fn(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Fn(t)}}function Lt(t){(!t.__d&&(t.__d=!0)&&ue.push(t)&&!st.__r++||Ln!=m.debounceRendering)&&((Ln=m.debounceRendering)||On)(st)}function st(){for(var t,e,n,r,i,s,o,l=1;ue.length;)ue.length>l&&ue.sort(Nn),t=ue.shift(),l=ue.length,t.__d&&(n=void 0,r=void 0,i=(r=(e=t).__v).__e,s=[],o=[],e.__P&&((n=H({},r)).__v=r.__v+1,m.vnode&&m.vnode(n),Ot(e.__P,n,r,e.__n,e.__P.namespaceURI,32&r.__u?[i]:null,s,i??ye(r),!!(32&r.__u),o),n.__v=r.__v,n.__.__k[n.__i]=n,Hn(s,n,o),r.__e=r.__=null,n.__e!=i&&Fn(n)));st.__r=0}function Dn(t,e,n,r,i,s,o,l,a,h,d){var c,p,f,g,x,k,_,w=r&&r.__k||Qn,Y=e.length;for(a=Hi(n,e,w,a,Y),c=0;c<Y;c++)(f=n.__k[c])!=null&&(p=f.__i==-1?Le:w[f.__i]||Le,f.__i=c,k=Ot(t,f,p,i,s,o,l,a,h,d),g=f.__e,f.ref&&p.ref!=f.ref&&(p.ref&&zt(p.ref,null,f),d.push(f.ref,f.__c||g,f)),x==null&&g!=null&&(x=g),(_=!!(4&f.__u))||p.__k===f.__k?a=Un(f,a,t,_):typeof f.type=="function"&&k!==void 0?a=k:g&&(a=g.nextSibling),f.__u&=-7);return n.__e=x,a}function Hi(t,e,n,r,i){var s,o,l,a,h,d=n.length,c=d,p=0;for(t.__k=new Array(i),s=0;s<i;s++)(o=e[s])!=null&&typeof o!="boolean"&&typeof o!="function"?(a=s+p,(o=t.__k[s]=typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?Ne(null,o,null,null,null):Oe(o)?Ne(N,{children:o},null,null,null):o.constructor==null&&o.__b>0?Ne(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o).__=t,o.__b=t.__b+1,l=null,(h=o.__i=Ji(o,n,a,c))!=-1&&(c--,(l=n[h])&&(l.__u|=2)),l==null||l.__v==null?(h==-1&&(i>d?p--:i<d&&p++),typeof o.type!="function"&&(o.__u|=4)):h!=a&&(h==a-1?p--:h==a+1?p++:(h>a?p--:p++,o.__u|=4))):t.__k[s]=null;if(c)for(s=0;s<d;s++)(l=n[s])!=null&&(2&l.__u)==0&&(l.__e==r&&(r=ye(l)),Gn(l,l));return r}function Un(t,e,n,r){var i,s;if(typeof t.type=="function"){for(i=t.__k,s=0;i&&s<i.length;s++)i[s]&&(i[s].__=t,e=Un(i[s],e,n,r));return e}t.__e!=e&&(r&&(e&&t.type&&!e.parentNode&&(e=ye(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function J(t,e){return e=e||[],t==null||typeof t=="boolean"||(Oe(t)?t.some(function(n){J(n,e)}):e.push(t)),e}function Ji(t,e,n,r){var i,s,o,l=t.key,a=t.type,h=e[n],d=h!=null&&(2&h.__u)==0;if(h===null&&t.key==null||d&&l==h.key&&a==h.type)return n;if(r>(d?1:0)){for(i=n-1,s=n+1;i>=0||s<e.length;)if((h=e[o=i>=0?i--:s++])!=null&&(2&h.__u)==0&&l==h.key&&a==h.type)return o}return-1}function Vn(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||Vi.test(e)?n:n+"px"}function ot(t,e,n,r,i){var s,o;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||Vn(t.style,e,"");if(n)for(e in n)r&&n[e]==r[e]||Vn(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(zn,"$1")),o=e.toLowerCase(),e=o in t||e=="onFocusOut"||e=="onFocusIn"?o.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+s]=n,n?r?n.u=r.u:(n.u=Et,t.addEventListener(e,s?qt:Pt,s)):t.removeEventListener(e,s?qt:Pt,s);else{if(i=="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 Wn(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=Et++;else if(e.t<n.u)return;return n(m.event?m.event(e):e)}}}function Ot(t,e,n,r,i,s,o,l,a,h){var d,c,p,f,g,x,k,_,w,Y,ee,ce,W,Ui,It,it,In,te=e.type;if(e.constructor!=null)return null;128&n.__u&&(a=!!(32&n.__u),s=[l=e.__e=n.__e]),(d=m.__b)&&d(e);e:if(typeof te=="function")try{if(_=e.props,w="prototype"in te&&te.prototype.render,Y=(d=te.contextType)&&r[d.__c],ee=d?Y?Y.props.value:d.__:r,n.__c?k=(c=e.__c=n.__c).__=c.__E:(w?e.__c=c=new te(_,ee):(e.__c=c=new F(_,ee),c.constructor=te,c.render=Ki),Y&&Y.sub(c),c.props=_,c.state||(c.state={}),c.context=ee,c.__n=r,p=c.__d=!0,c.__h=[],c._sb=[]),w&&c.__s==null&&(c.__s=c.state),w&&te.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=H({},c.__s)),H(c.__s,te.getDerivedStateFromProps(_,c.__s))),f=c.props,g=c.state,c.__v=e,p)w&&te.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),w&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(w&&te.getDerivedStateFromProps==null&&_!==f&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(_,ee),!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(_,c.__s,ee)===!1||e.__v==n.__v){for(e.__v!=n.__v&&(c.props=_,c.state=c.__s,c.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(qe){qe&&(qe.__=e)}),ce=0;ce<c._sb.length;ce++)c.__h.push(c._sb[ce]);c._sb=[],c.__h.length&&o.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(_,c.__s,ee),w&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(f,g,x)})}if(c.context=ee,c.props=_,c.__P=t,c.__e=!1,W=m.__r,Ui=0,w){for(c.state=c.__s,c.__d=!1,W&&W(e),d=c.render(c.props,c.state,c.context),It=0;It<c._sb.length;It++)c.__h.push(c._sb[It]);c._sb=[]}else do c.__d=!1,W&&W(e),d=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++Ui<25);c.state=c.__s,c.getChildContext!=null&&(r=H(H({},r),c.getChildContext())),w&&!p&&c.getSnapshotBeforeUpdate!=null&&(x=c.getSnapshotBeforeUpdate(f,g)),it=d,d!=null&&d.type===N&&d.key==null&&(it=Jn(d.props.children)),l=Dn(t,Oe(it)?it:[it],e,n,r,i,s,o,l,a,h),c.base=e.__e,e.__u&=-161,c.__h.length&&o.push(c),k&&(c.__E=c.__=null)}catch(qe){if(e.__v=null,a||s!=null)if(qe.then){for(e.__u|=a?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;s[s.indexOf(l)]=null,e.__e=l}else{for(In=s.length;In--;)Mt(s[In]);Nt(e)}else e.__e=n.__e,e.__k=n.__k,qe.then||Nt(e);m.__e(qe,e,n)}else s==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):l=e.__e=Gi(n.__e,e,n,r,i,s,o,a,h);return(d=m.diffed)&&d(e),128&e.__u?void 0:l}function Nt(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(Nt)}function Hn(t,e,n){for(var r=0;r<n.length;r++)zt(n[r],n[++r],n[++r]);m.__c&&m.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(s){s.call(i)})}catch(s){m.__e(s,i.__v)}})}function Jn(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:Oe(t)?t.map(Jn):H({},t)}function Gi(t,e,n,r,i,s,o,l,a){var h,d,c,p,f,g,x,k=n.props,_=e.props,w=e.type;if(w=="svg"?i="http://www.w3.org/2000/svg":w=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(h=0;h<s.length;h++)if((f=s[h])&&"setAttribute"in f==!!w&&(w?f.localName==w:f.nodeType==3)){t=f,s[h]=null;break}}if(t==null){if(w==null)return document.createTextNode(_);t=document.createElementNS(i,w,_.is&&_),l&&(m.__m&&m.__m(e,s),l=!1),s=null}if(w==null)k===_||l&&t.data==_||(t.data=_);else{if(s=s&&Me.call(t.childNodes),k=n.props||Le,!l&&s!=null)for(k={},h=0;h<t.attributes.length;h++)k[(f=t.attributes[h]).name]=f.value;for(h in k)if(f=k[h],h!="children"){if(h=="dangerouslySetInnerHTML")c=f;else if(!(h in _)){if(h=="value"&&"defaultValue"in _||h=="checked"&&"defaultChecked"in _)continue;ot(t,h,null,f,i)}}for(h in _)f=_[h],h=="children"?p=f:h=="dangerouslySetInnerHTML"?d=f:h=="value"?g=f:h=="checked"?x=f:l&&typeof f!="function"||k[h]===f||ot(t,h,f,k[h],i);if(d)l||c&&(d.__html==c.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(c&&(t.innerHTML=""),Dn(e.type=="template"?t.content:t,Oe(p)?p:[p],e,n,r,w=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,o,s?s[0]:n.__k&&ye(n,0),l,a),s!=null)for(h=s.length;h--;)Mt(s[h]);l||(h="value",w=="progress"&&g==null?t.removeAttribute("value"):g!=null&&(g!==t[h]||w=="progress"&&!g||w=="option"&&g!=k[h])&&ot(t,h,g,k[h],i),h="checked",x!=null&&x!=t[h]&&ot(t,h,x,k[h],i))}return t}function zt(t,e,n){try{if(typeof t=="function"){var r=typeof t.__u=="function";r&&t.__u(),r&&e==null||(t.__u=t(e))}else t.current=e}catch(i){m.__e(i,n)}}function Gn(t,e,n){var r,i;if(m.unmount&&m.unmount(t),(r=t.ref)&&(r.current&&r.current!=t.__e||zt(r,null,e)),(r=t.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(s){m.__e(s,e)}r.base=r.__P=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&Gn(r[i],e,n||typeof t.type!="function");n||Mt(t.__e),t.__c=t.__=t.__e=void 0}function Ki(t,e,n){return this.constructor(t,n)}function he(t,e,n){var r,i,s,o;e==document&&(e=document.documentElement),m.__&&m.__(t,e),i=(r=typeof n=="function")?null:n&&n.__k||e.__k,s=[],o=[],Ot(e,t=(!r&&n||e).__k=O(N,null,[t]),i||Le,Le,e.namespaceURI,!r&&n?[n]:i?null:e.firstChild?Me.call(e.childNodes):null,s,!r&&n?n:i?i.__e:e.firstChild,r,o),Hn(s,t,o)}function Kn(t,e){he(t,e,Kn)}function Zi(t,e,n){var r,i,s,o,l=H({},t.props);for(s in t.type&&t.type.defaultProps&&(o=t.type.defaultProps),e)s=="key"?r=e[s]:s=="ref"?i=e[s]:l[s]=e[s]===void 0&&o!=null?o[s]:e[s];return arguments.length>2&&(l.children=arguments.length>3?Me.call(arguments,2):n),Ne(t.type,l,r||t.key,i||t.ref,null)}function Xi(t){function e(n){var r,i;return this.getChildContext||(r=new Set,(i={})[e.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(s){this.props.value!=s.value&&r.forEach(function(o){o.__e=!0,Lt(o)})},this.sub=function(s){r.add(s);var o=s.componentWillUnmount;s.componentWillUnmount=function(){r&&r.delete(s),o&&o.call(s)}}),n.children}return e.__c="__cC"+Bn++,e.__=t,e.Provider=e.__l=(e.Consumer=function(n,r){return n.children(r)}).contextType=e,e}Me=Qn.slice,m={__e:function(t,e,n,r){for(var i,s,o;e=e.__;)if((i=e.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(t)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,r||{}),o=i.__d),o)return i.__E=i}catch(l){t=l}throw t}},qn=0,Mn=function(t){return t!=null&&t.constructor==null},F.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=H({},this.state),typeof t=="function"&&(t=t(H({},n),this.props)),t&&H(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),Lt(this))},F.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Lt(this))},F.prototype.render=N,ue=[],On=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Nn=function(t,e){return t.__v.__b-e.__v.__b},st.__r=0,zn=/(PointerCapture)$|Capture$/i,Et=0,Pt=Wn(!1),qt=Wn(!0),Bn=0;var Yi=0;function u(t,e,n,r,i,s){e||(e={});var o,l,a=e;if("ref"in a)for(l in a={},e)l=="ref"?o=e[l]:a[l]=e[l];var h={type:t,props:a,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Yi,__i:-1,__u:0,__source:i,__self:s};if(typeof t=="function"&&(o=t.defaultProps))for(l in o)a[l]===void 0&&(a[l]=o[l]);return m.vnode&&m.vnode(h),h}var ie,S,Bt,Zn,ve=0,Xn=[],j=m,Yn=j.__b,er=j.__r,tr=j.diffed,nr=j.__c,rr=j.unmount,ir=j.__;function _e(t,e){j.__h&&j.__h(S,t,ve||e),ve=0;var n=S.__H||(S.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function T(t){return ve=1,Qt(cr,t)}function Qt(t,e,n){var r=_e(ie++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):cr(void 0,e),function(l){var a=r.__N?r.__N[0]:r.__[0],h=r.t(a,l);a!==h&&(r.__N=[h,r.__[1]],r.__c.setState({}))}],r.__c=S,!S.__f)){var i=function(l,a,h){if(!r.__c.__H)return!0;var d=r.__c.__H.__.filter(function(p){return!!p.__c});if(d.every(function(p){return!p.__N}))return!s||s.call(this,l,a,h);var c=r.__c.props!==l;return d.forEach(function(p){if(p.__N){var f=p.__[0];p.__=p.__N,p.__N=void 0,f!==p.__[0]&&(c=!0)}}),s&&s.call(this,l,a,h)||c};S.__f=!0;var s=S.shouldComponentUpdate,o=S.componentWillUpdate;S.componentWillUpdate=function(l,a,h){if(this.__e){var d=s;s=void 0,i(l,a,h),s=d}o&&o.call(this,l,a,h)},S.shouldComponentUpdate=i}return r.__N||r.__}function M(t,e){var n=_e(ie++,3);!j.__s&&Dt(n.__H,e)&&(n.__=t,n.u=e,S.__H.__h.push(n))}function ze(t,e){var n=_e(ie++,4);!j.__s&&Dt(n.__H,e)&&(n.__=t,n.u=e,S.__h.push(n))}function Be(t){return ve=5,z(function(){return{current:t}},[])}function sr(t,e,n){ve=6,ze(function(){if(typeof t=="function"){var r=t(e());return function(){t(null),r&&typeof r=="function"&&r()}}if(t)return t.current=e(),function(){return t.current=null}},n==null?n:n.concat(t))}function z(t,e){var n=_e(ie++,7);return Dt(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function Qe(t,e){return ve=8,z(function(){return t},e)}function at(t){var e=S.context[t.__c],n=_e(ie++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(S)),e.props.value):t.__}function or(t,e){j.useDebugValue&&j.useDebugValue(e?e(t):t)}function ar(){var t=_e(ie++,11);if(!t.__){for(var e=S.__v;e!==null&&!e.__m&&e.__!==null;)e=e.__;var n=e.__m||(e.__m=[0,0]);t.__="P"+n[0]+"-"+n[1]++}return t.__}function es(){for(var t;t=Xn.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(lt),t.__H.__h.forEach(Ft),t.__H.__h=[]}catch(e){t.__H.__h=[],j.__e(e,t.__v)}}j.__b=function(t){S=null,Yn&&Yn(t)},j.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),ir&&ir(t,e)},j.__r=function(t){er&&er(t),ie=0;var e=(S=t.__c).__H;e&&(Bt===S?(e.__h=[],S.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(lt),e.__h.forEach(Ft),e.__h=[],ie=0)),Bt=S},j.diffed=function(t){tr&&tr(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Xn.push(e)!==1&&Zn===j.requestAnimationFrame||((Zn=j.requestAnimationFrame)||ts)(es)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Bt=S=null},j.__c=function(t,e){e.some(function(n){try{n.__h.forEach(lt),n.__h=n.__h.filter(function(r){return!r.__||Ft(r)})}catch(r){e.some(function(i){i.__h&&(i.__h=[])}),e=[],j.__e(r,n.__v)}}),nr&&nr(t,e)},j.unmount=function(t){rr&&rr(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{lt(r)}catch(i){e=i}}),n.__H=void 0,e&&j.__e(e,n.__v))};var lr=typeof requestAnimationFrame=="function";function ts(t){var e,n=function(){clearTimeout(r),lr&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,35);lr&&(e=requestAnimationFrame(n))}function lt(t){var e=S,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),S=e}function Ft(t){var e=S;t.__c=t.__(),S=e}function Dt(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function cr(t,e){return typeof e=="function"?e(t):e}function ur(t,e){for(var n in e)t[n]=e[n];return t}function Ut(t,e){for(var n in t)if(n!=="__source"&&!(n in e))return!0;for(var r in e)if(r!=="__source"&&t[r]!==e[r])return!0;return!1}function hr(t,e){var n=e(),r=T({t:{__:n,u:e}}),i=r[0].t,s=r[1];return ze(function(){i.__=n,i.u=e,Vt(i)&&s({t:i})},[t,n,e]),M(function(){return Vt(i)&&s({t:i}),t(function(){Vt(i)&&s({t:i})})},[t]),n}function Vt(t){var e,n,r=t.u,i=t.__;try{var s=r();return!((e=i)===(n=s)&&(e!==0||1/e==1/n)||e!=e&&n!=n)}catch{return!0}}function dr(t){t()}function fr(t){return t}function pr(){return[!1,dr]}var gr=ze;function Wt(t,e){this.props=t,this.context=e}function ns(t,e){function n(i){var s=this.props.ref,o=s==i.ref;return!o&&s&&(s.call?s(null):s.current=null),e?!e(this.props,i)||!o:Ut(this.props,i)}function r(i){return this.shouldComponentUpdate=n,O(t,i)}return r.displayName="Memo("+(t.displayName||t.name)+")",r.prototype.isReactComponent=!0,r.__f=!0,r.type=t,r}(Wt.prototype=new F).isPureReactComponent=!0,Wt.prototype.shouldComponentUpdate=function(t,e){return Ut(this.props,t)||Ut(this.state,e)};var mr=m.__b;m.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),mr&&mr(t)};var rs=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function is(t){function e(n){var r=ur({},n);return delete r.ref,t(r,n.ref||null)}return e.$$typeof=rs,e.render=t,e.prototype.isReactComponent=e.__f=!0,e.displayName="ForwardRef("+(t.displayName||t.name)+")",e}var xr=function(t,e){return t==null?null:J(J(t).map(e))},ss={map:xr,forEach:xr,count:function(t){return t?J(t).length:0},only:function(t){var e=J(t);if(e.length!==1)throw"Children.only";return e[0]},toArray:J},os=m.__e;m.__e=function(t,e,n,r){if(t.then){for(var i,s=e;s=s.__;)if((i=s.__c)&&i.__c)return e.__e==null&&(e.__e=n.__e,e.__k=n.__k),i.__c(t,e)}os(t,e,n,r)};var br=m.unmount;function yr(t,e,n){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(r){typeof r.__c=="function"&&r.__c()}),t.__c.__H=null),(t=ur({},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(r){return yr(r,e,n)})),t}function vr(t,e,n){return t&&n&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(r){return vr(r,e,n)}),t.__c&&t.__c.__P===e&&(t.__e&&n.appendChild(t.__e),t.__c.__e=!0,t.__c.__P=n)),t}function ct(){this.__u=0,this.o=null,this.__b=null}function _r(t){var e=t.__.__c;return e&&e.__a&&e.__a(t)}function as(t){var e,n,r;function i(s){if(e||(e=t()).then(function(o){n=o.default||o},function(o){r=o}),r)throw r;if(!n)throw e;return O(n,s)}return i.displayName="Lazy",i.__f=!0,i}function Fe(){this.i=null,this.l=null}m.unmount=function(t){var e=t.__c;e&&e.__R&&e.__R(),e&&32&t.__u&&(t.type=null),br&&br(t)},(ct.prototype=new F).__c=function(t,e){var n=e.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=_r(r.__v),s=!1,o=function(){s||(s=!0,n.__R=null,i?i(l):l())};n.__R=o;var l=function(){if(!--r.__u){if(r.state.__a){var a=r.state.__a;r.__v.__k[0]=vr(a,a.__c.__P,a.__c.__O)}var h;for(r.setState({__a:r.__b=null});h=r.o.pop();)h.forceUpdate()}};r.__u++||32&e.__u||r.setState({__a:r.__b=r.__v.__k[0]}),t.then(o,o)},ct.prototype.componentWillUnmount=function(){this.o=[]},ct.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=yr(this.__b,n,r.__O=r.__P)}this.__b=null}var i=e.__a&&O(N,null,t.fallback);return i&&(i.__u&=-33),[O(N,null,e.__a?null:t.children),i]};var wr=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]}};function ls(t){return this.getChildContext=function(){return t.context},t.children}function cs(t){var e=this,n=t.h;if(e.componentWillUnmount=function(){he(null,e.v),e.v=null,e.h=null},e.h&&e.h!==n&&e.componentWillUnmount(),!e.v){for(var r=e.__v;r!==null&&!r.__m&&r.__!==null;)r=r.__;e.h=n,e.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:r.__m},contains:function(){return!0},insertBefore:function(i,s){this.childNodes.push(i),e.h.insertBefore(i,s)},removeChild:function(i){this.childNodes.splice(this.childNodes.indexOf(i)>>>1,1),e.h.removeChild(i)}}}he(O(ls,{context:e.context},t.__v),e.v)}function us(t,e){var n=O(cs,{__v:t,h:e});return n.containerInfo=e,n}(Fe.prototype=new F).__a=function(t){var e=this,n=_r(e.__v),r=e.l.get(t);return r[0]++,function(i){var s=function(){e.props.revealOrder?(r.push(i),wr(e,t,r)):i()};n?n(s):s()}},Fe.prototype.render=function(t){this.i=null,this.l=new Map;var e=J(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){wr(t,n,e)})};var kr=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,hs=/^(?: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]/,ds=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,fs=/[A-Z0-9]/g,ps=typeof document<"u",gs=function(t){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(t)};function ms(t,e,n){return e.__k==null&&(e.textContent=""),he(t,e),typeof n=="function"&&n(),t?t.__c:null}function xs(t,e,n){return Kn(t,e),typeof n=="function"&&n(),t?t.__c:null}F.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(t){Object.defineProperty(F.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})});var Sr=m.event;function bs(){}function ys(){return this.cancelBubble}function vs(){return this.defaultPrevented}m.event=function(t){return Sr&&(t=Sr(t)),t.persist=bs,t.isPropagationStopped=ys,t.isDefaultPrevented=vs,t.nativeEvent=t};var Ht,_s={enumerable:!1,configurable:!0,get:function(){return this.class}},jr=m.vnode;m.vnode=function(t){typeof t.type=="string"&&(function(e){var n=e.props,r=e.type,i={},s=r.indexOf("-")===-1;for(var o in n){var l=n[o];if(!(o==="value"&&"defaultValue"in n&&l==null||ps&&o==="children"&&r==="noscript"||o==="class"||o==="className")){var a=o.toLowerCase();o==="defaultValue"&&"value"in n&&n.value==null?o="value":o==="download"&&l===!0?l="":a==="translate"&&l==="no"?l=!1:a[0]==="o"&&a[1]==="n"?a==="ondoubleclick"?o="ondblclick":a!=="onchange"||r!=="input"&&r!=="textarea"||gs(n.type)?a==="onfocus"?o="onfocusin":a==="onblur"?o="onfocusout":ds.test(o)&&(o=a):a=o="oninput":s&&hs.test(o)?o=o.replace(fs,"-$&").toLowerCase():l===null&&(l=void 0),a==="oninput"&&i[o=a]&&(o="oninputCapture"),i[o]=l}}r=="select"&&i.multiple&&Array.isArray(i.value)&&(i.value=J(n.children).forEach(function(h){h.props.selected=i.value.indexOf(h.props.value)!=-1})),r=="select"&&i.defaultValue!=null&&(i.value=J(n.children).forEach(function(h){h.props.selected=i.multiple?i.defaultValue.indexOf(h.props.value)!=-1:i.defaultValue==h.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,"className",_s)):(n.className&&!n.class||n.class&&n.className)&&(i.class=i.className=n.className),e.props=i})(t),t.$$typeof=kr,jr&&jr(t)};var Cr=m.__r;m.__r=function(t){Cr&&Cr(t),Ht=t.__c};var Rr=m.diffed;m.diffed=function(t){Rr&&Rr(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),Ht=null};var ws={ReactCurrentDispatcher:{current:{readContext:function(t){return Ht.__n[t.__c].props.value},useCallback:Qe,useContext:at,useDebugValue:or,useDeferredValue:fr,useEffect:M,useId:ar,useImperativeHandle:sr,useInsertionEffect:gr,useLayoutEffect:ze,useMemo:z,useReducer:Qt,useRef:Be,useState:T,useSyncExternalStore:hr,useTransition:pr}}};function ks(t){return O.bind(null,t)}function ut(t){return!!t&&t.$$typeof===kr}function Ss(t){return ut(t)&&t.type===N}function js(t){return!!t&&!!t.displayName&&(typeof t.displayName=="string"||t.displayName instanceof String)&&t.displayName.startsWith("Memo(")}function Cs(t){return ut(t)?Zi.apply(null,arguments):t}function Rs(t){return!!t.__k&&(he(null,t),!0)}function Ts(t){return t&&(t.base||t.nodeType===1&&t)||null}for(var $s=function(t,e){return t(e)},As=function(t,e){return t(e)},Is=N,Es=ut,Jt={useState:T,useId:ar,useReducer:Qt,useEffect:M,useLayoutEffect:ze,useInsertionEffect:gr,useTransition:pr,useDeferredValue:fr,useSyncExternalStore:hr,startTransition:dr,useRef:Be,useImperativeHandle:sr,useMemo:z,useCallback:Qe,useContext:at,useDebugValue:or,version:"18.3.1",Children:ss,render:ms,hydrate:xs,unmountComponentAtNode:Rs,createPortal:us,createElement:O,createContext:Xi,createFactory:ks,cloneElement:Cs,createRef:Wi,Fragment:N,isValidElement:ut,isElement:Es,isFragment:Ss,isMemo:js,findDOMNode:Ts,Component:F,PureComponent:Wt,memo:ns,forwardRef:is,flushSync:As,unstable_batchedUpdates:$s,StrictMode:Is,Suspense:ct,SuspenseList:Fe,lazy:as,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:ws},G=[],B=[],Ps=Uint8Array,Gt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",we=0,qs=Gt.length;we<qs;++we)G[we]=Gt[we],B[Gt.charCodeAt(we)]=we;B[45]=62,B[95]=63;function Ms(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var r=n===e?0:4-n%4;return[n,r]}function Ls(t,e,n){return(e+n)*3/4-n}function De(t){var e,n=Ms(t),r=n[0],i=n[1],s=new Ps(Ls(t,r,i)),o=0,l=i>0?r-4:r,a;for(a=0;a<l;a+=4)e=B[t.charCodeAt(a)]<<18|B[t.charCodeAt(a+1)]<<12|B[t.charCodeAt(a+2)]<<6|B[t.charCodeAt(a+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=B[t.charCodeAt(a)]<<2|B[t.charCodeAt(a+1)]>>4,s[o++]=e&255),i===1&&(e=B[t.charCodeAt(a)]<<10|B[t.charCodeAt(a+1)]<<4|B[t.charCodeAt(a+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function Os(t){return G[t>>18&63]+G[t>>12&63]+G[t>>6&63]+G[t&63]}function Ns(t,e,n){for(var r,i=[],s=e;s<n;s+=3)r=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push(Os(r));return i.join("")}function Ue(t){for(var e,n=t.length,r=n%3,i=[],s=16383,o=0,l=n-r;o<l;o+=s)i.push(Ns(t,o,o+s>l?l:o+s));return r===1?(e=t[n-1],i.push(G[e>>2]+G[e<<4&63]+"==")):r===2&&(e=(t[n-2]<<8)+t[n-1],i.push(G[e>>10]+G[e>>4&63]+G[e<<2&63]+"=")),i.join("")}function ne(t){if(t===void 0)return{};if(!Tr(t))throw new Error(`The arguments to a Convex function must be an object. Received: ${t}`);return t}function zs(t){if(typeof t>"u")throw new Error("Client created with undefined deployment address. If you used an environment variable, check that it's set.");if(typeof t!="string")throw new Error(`Invalid deployment address: found ${t}".`);if(!(t.startsWith("http:")||t.startsWith("https:")))throw new Error(`Invalid deployment address: Must start with "https://" or "http://". Found "${t}".`);try{new URL(t)}catch{throw new Error(`Invalid deployment address: "${t}" is not a valid URL. If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`)}if(t.endsWith(".convex.site"))throw new Error(`Invalid deployment address: "${t}" ends with .convex.site, which is used for HTTP Actions. Convex deployment URLs typically end with .convex.cloud? If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`)}function Tr(t){const e=typeof t=="object",n=Object.getPrototypeOf(t),r=n===null||n===Object.prototype||n?.constructor?.name==="Object";return e&&r}const $r=!0,ke=BigInt("-9223372036854775808"),Kt=BigInt("9223372036854775807"),Zt=BigInt("0"),Bs=BigInt("8"),Qs=BigInt("256");function Ar(t){return Number.isNaN(t)||!Number.isFinite(t)||Object.is(t,-0)}function Fs(t){t<Zt&&(t-=ke+ke);let e=t.toString(16);e.length%2===1&&(e="0"+e);const n=new Uint8Array(new ArrayBuffer(8));let r=0;for(const i of e.match(/.{2}/g).reverse())n.set([parseInt(i,16)],r++),t>>=Bs;return Ue(n)}function Ds(t){const e=De(t);if(e.byteLength!==8)throw new Error(`Received ${e.byteLength} bytes, expected 8 for $integer`);let n=Zt,r=Zt;for(const i of e)n+=BigInt(i)*Qs**r,r++;return n>Kt&&(n+=ke+ke),n}function Us(t){if(t<ke||Kt<t)throw new Error(`BigInt ${t} does not fit into a 64-bit signed integer.`);const e=new ArrayBuffer(8);return new DataView(e).setBigInt64(0,t,!0),Ue(new Uint8Array(e))}function Vs(t){const e=De(t);if(e.byteLength!==8)throw new Error(`Received ${e.byteLength} bytes, expected 8 for $integer`);return new DataView(e.buffer).getBigInt64(0,!0)}const Ws=DataView.prototype.setBigInt64?Us:Fs,Hs=DataView.prototype.getBigInt64?Vs:Ds,Ir=1024;function Er(t){if(t.length>Ir)throw new Error(`Field name ${t} exceeds maximum field name length ${Ir}.`);if(t.startsWith("$"))throw new Error(`Field name ${t} starts with a '$', which is reserved.`);for(let e=0;e<t.length;e+=1){const n=t.charCodeAt(e);if(n<32||n>=127)throw new Error(`Field name ${t} has invalid character '${t[e]}': Field names can only contain non-control ASCII characters`)}}function Se(t){if(t===null||typeof t=="boolean"||typeof t=="number"||typeof t=="string")return t;if(Array.isArray(t))return t.map(r=>Se(r));if(typeof t!="object")throw new Error(`Unexpected type of ${t}`);const e=Object.entries(t);if(e.length===1){const r=e[0][0];if(r==="$bytes"){if(typeof t.$bytes!="string")throw new Error(`Malformed $bytes field on ${t}`);return De(t.$bytes).buffer}if(r==="$integer"){if(typeof t.$integer!="string")throw new Error(`Malformed $integer field on ${t}`);return Hs(t.$integer)}if(r==="$float"){if(typeof t.$float!="string")throw new Error(`Malformed $float field on ${t}`);const i=De(t.$float);if(i.byteLength!==8)throw new Error(`Received ${i.byteLength} bytes, expected 8 for $float`);const o=new DataView(i.buffer).getFloat64(0,$r);if(!Ar(o))throw new Error(`Float ${o} should be encoded as a number`);return o}if(r==="$set")throw new Error("Received a Set which is no longer supported as a Convex type.");if(r==="$map")throw new Error("Received a Map which is no longer supported as a Convex type.")}const n={};for(const[r,i]of Object.entries(t))Er(r),n[r]=Se(i);return n}const Pr=16384;function Ve(t){const e=JSON.stringify(t,(n,r)=>r===void 0?"undefined":typeof r=="bigint"?`${r.toString()}n`:r);if(e.length>Pr){const n="[...truncated]";let r=Pr-n.length;const i=e.codePointAt(r-1);return i!==void 0&&i>65535&&(r-=1),e.substring(0,r)+n}return e}function Xt(t,e,n,r){if(t===void 0){const o=n&&` (present at path ${n} in original object ${Ve(e)})`;throw new Error(`undefined is not a valid Convex value${o}. To learn about Convex's supported types, see https://docs.convex.dev/using/types.`)}if(t===null)return t;if(typeof t=="bigint"){if(t<ke||Kt<t)throw new Error(`BigInt ${t} does not fit into a 64-bit signed integer.`);return{$integer:Ws(t)}}if(typeof t=="number")if(Ar(t)){const o=new ArrayBuffer(8);return new DataView(o).setFloat64(0,t,$r),{$float:Ue(new Uint8Array(o))}}else return t;if(typeof t=="boolean"||typeof t=="string")return t;if(t instanceof ArrayBuffer)return{$bytes:Ue(new Uint8Array(t))};if(Array.isArray(t))return t.map((o,l)=>Xt(o,e,n+`[${l}]`));if(t instanceof Set)throw new Error(Yt(n,"Set",[...t],e));if(t instanceof Map)throw new Error(Yt(n,"Map",[...t],e));if(!Tr(t)){const o=t?.constructor?.name,l=o?`${o} `:"";throw new Error(Yt(n,l,t,e))}const i={},s=Object.entries(t);s.sort(([o,l],[a,h])=>o===a?0:o<a?-1:1);for(const[o,l]of s)l!==void 0&&(Er(o),i[o]=Xt(l,e,n+`.${o}`));return i}function Yt(t,e,n,r){return t?`${e}${Ve(n)} is not a supported Convex type (present at path ${t} in original object ${Ve(r)}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.`:`${e}${Ve(n)} is not a supported Convex type.`}function K(t){return Xt(t,t,"")}var Js=Object.defineProperty,Gs=(t,e,n)=>e in t?Js(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,en=(t,e,n)=>Gs(t,typeof e!="symbol"?e+"":e,n),qr,Mr;const Ks=Symbol.for("ConvexError");class tn extends(Mr=Error,qr=Ks,Mr){constructor(e){super(typeof e=="string"?e:Ve(e)),en(this,"name","ConvexError"),en(this,"data"),en(this,qr,!0),this.data=e}}const Lr=()=>Array.from({length:4},()=>0);Lr(),Lr();const Or="1.37.0";var Zs=Object.defineProperty,Xs=(t,e,n)=>e in t?Zs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Nr=(t,e,n)=>Xs(t,typeof e!="symbol"?e+"":e,n);const Ys="color:rgb(0, 145, 255)";function zr(t){switch(t){case"query":return"Q";case"mutation":return"M";case"action":return"A";case"any":return"?"}}class Br{constructor(e){Nr(this,"_onLogLineFuncs"),Nr(this,"_verbose"),this._onLogLineFuncs={},this._verbose=e.verbose}addLogLineListener(e){let n=Math.random().toString(36).substring(2,15);for(let r=0;r<10&&this._onLogLineFuncs[n]!==void 0;r++)n=Math.random().toString(36).substring(2,15);return this._onLogLineFuncs[n]=e,()=>{delete this._onLogLineFuncs[n]}}logVerbose(...e){if(this._verbose)for(const n of Object.values(this._onLogLineFuncs))n("debug",`${new Date().toISOString()}`,...e)}log(...e){for(const n of Object.values(this._onLogLineFuncs))n("info",...e)}warn(...e){for(const n of Object.values(this._onLogLineFuncs))n("warn",...e)}error(...e){for(const n of Object.values(this._onLogLineFuncs))n("error",...e)}}function Qr(t){const e=new Br(t);return e.addLogLineListener((n,...r)=>{switch(n){case"debug":console.debug(...r);break;case"info":console.log(...r);break;case"warn":console.warn(...r);break;case"error":console.error(...r);break;default:console.log(...r)}}),e}function Fr(t){return new Br(t)}function ht(t,e,n,r,i){const s=zr(n);if(typeof i=="object"&&(i=`ConvexError ${JSON.stringify(i.errorData,null,2)}`),e==="info"){const o=i.match(/^\[.*?\] /);if(o===null){t.error(`[CONVEX ${s}(${r})] Could not parse console.log`);return}const l=i.slice(1,o[0].length-2),a=i.slice(o[0].length);t.log(`%c[CONVEX ${s}(${r})] [${l}]`,Ys,a)}else t.error(`[CONVEX ${s}(${r})] ${i}`)}function eo(t,e){const n=`[CONVEX FATAL ERROR] ${e}`;return t.error(n),new Error(n)}function je(t,e,n){return`[CONVEX ${zr(t)}(${e})] ${n.errorMessage}
|
|
2
|
-
Called by client`}function nn(t,e){return e.data=t.errorData,e}function de(t){const e=t.split(":");let n,r;return e.length===1?(n=e[0],r="default"):(n=e.slice(0,e.length-1).join(":"),r=e[e.length-1]),n.endsWith(".js")&&(n=n.slice(0,-3)),`${n}:${r}`}function fe(t,e){return JSON.stringify({udfPath:de(t),args:K(e)})}function Dr(t,e,n){const{initialNumItems:r,id:i}=n;return JSON.stringify({type:"paginated",udfPath:de(t),args:K(e),options:K({initialNumItems:r,id:i})})}var to=Object.defineProperty,no=(t,e,n)=>e in t?to(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Z=(t,e,n)=>no(t,typeof e!="symbol"?e+"":e,n);class ro{constructor(){Z(this,"nextQueryId"),Z(this,"querySetVersion"),Z(this,"querySet"),Z(this,"queryIdToToken"),Z(this,"identityVersion"),Z(this,"auth"),Z(this,"outstandingQueriesOlderThanRestart"),Z(this,"outstandingAuthOlderThanRestart"),Z(this,"paused"),Z(this,"pendingQuerySetModifications"),this.nextQueryId=0,this.querySetVersion=0,this.identityVersion=0,this.querySet=new Map,this.queryIdToToken=new Map,this.outstandingQueriesOlderThanRestart=new Set,this.outstandingAuthOlderThanRestart=!1,this.paused=!1,this.pendingQuerySetModifications=new Map}hasSyncedPastLastReconnect(){return this.outstandingQueriesOlderThanRestart.size===0&&!this.outstandingAuthOlderThanRestart}markAuthCompletion(){this.outstandingAuthOlderThanRestart=!1}subscribe(e,n,r,i){const s=de(e),o=fe(s,n),l=this.querySet.get(o);if(l!==void 0)return l.numSubscribers+=1,{queryToken:o,modification:null,unsubscribe:()=>this.removeSubscriber(o)};{const a=this.nextQueryId++,h={id:a,canonicalizedUdfPath:s,args:n,numSubscribers:1,journal:r,componentPath:i};this.querySet.set(o,h),this.queryIdToToken.set(a,o);const d=this.querySetVersion,c=this.querySetVersion+1,p={type:"Add",queryId:a,udfPath:s,args:[K(n)],journal:r,componentPath:i};return this.paused?this.pendingQuerySetModifications.set(a,p):this.querySetVersion=c,{queryToken:o,modification:{type:"ModifyQuerySet",baseVersion:d,newVersion:c,modifications:[p]},unsubscribe:()=>this.removeSubscriber(o)}}}transition(e){for(const n of e.modifications)switch(n.type){case"QueryUpdated":case"QueryFailed":{this.outstandingQueriesOlderThanRestart.delete(n.queryId);const r=n.journal;if(r!==void 0){const i=this.queryIdToToken.get(n.queryId);i!==void 0&&(this.querySet.get(i).journal=r)}break}case"QueryRemoved":{this.outstandingQueriesOlderThanRestart.delete(n.queryId);break}default:throw new Error(`Invalid modification ${n.type}`)}}queryId(e,n){const r=de(e),i=fe(r,n),s=this.querySet.get(i);return s!==void 0?s.id:null}isCurrentOrNewerAuthVersion(e){return e>=this.identityVersion}getAuth(){return this.auth}setAuth(e){this.auth={tokenType:"User",value:e};const n=this.identityVersion;return this.paused||(this.identityVersion=n+1),{type:"Authenticate",baseVersion:n,...this.auth}}setAdminAuth(e,n){const r={tokenType:"Admin",value:e,impersonating:n};this.auth=r;const i=this.identityVersion;return this.paused||(this.identityVersion=i+1),{type:"Authenticate",baseVersion:i,...r}}clearAuth(){this.auth=void 0,this.markAuthCompletion();const e=this.identityVersion;return this.paused||(this.identityVersion=e+1),{type:"Authenticate",tokenType:"None",baseVersion:e}}hasAuth(){return!!this.auth}isNewAuth(e){return this.auth?.value!==e}queryPath(e){const n=this.queryIdToToken.get(e);return n?this.querySet.get(n).canonicalizedUdfPath:null}queryArgs(e){const n=this.queryIdToToken.get(e);return n?this.querySet.get(n).args:null}queryToken(e){return this.queryIdToToken.get(e)??null}queryJournal(e){return this.querySet.get(e)?.journal}restart(){this.unpause(),this.outstandingQueriesOlderThanRestart.clear();const e=[];for(const i of this.querySet.values()){const s={type:"Add",queryId:i.id,udfPath:i.canonicalizedUdfPath,args:[K(i.args)],journal:i.journal,componentPath:i.componentPath};e.push(s),this.outstandingQueriesOlderThanRestart.add(i.id)}this.querySetVersion=1;const n={type:"ModifyQuerySet",baseVersion:0,newVersion:1,modifications:e};if(!this.auth)return this.identityVersion=0,[n,void 0];this.outstandingAuthOlderThanRestart=!0;const r={type:"Authenticate",baseVersion:0,...this.auth};return this.identityVersion=1,[n,r]}pause(){this.paused=!0}resume(){const e=this.pendingQuerySetModifications.size>0?{type:"ModifyQuerySet",baseVersion:this.querySetVersion,newVersion:++this.querySetVersion,modifications:Array.from(this.pendingQuerySetModifications.values())}:void 0,n=this.auth!==void 0?{type:"Authenticate",baseVersion:this.identityVersion++,...this.auth}:void 0;return this.unpause(),[e,n]}unpause(){this.paused=!1,this.pendingQuerySetModifications.clear()}removeSubscriber(e){const n=this.querySet.get(e);if(n.numSubscribers>1)return n.numSubscribers-=1,null;{this.querySet.delete(e),this.queryIdToToken.delete(n.id),this.outstandingQueriesOlderThanRestart.delete(n.id);const r=this.querySetVersion,i=this.querySetVersion+1,s={type:"Remove",queryId:n.id};return this.paused?this.pendingQuerySetModifications.has(n.id)?this.pendingQuerySetModifications.delete(n.id):this.pendingQuerySetModifications.set(n.id,s):this.querySetVersion=i,{type:"ModifyQuerySet",baseVersion:r,newVersion:i,modifications:[s]}}}}var io=Object.defineProperty,so=(t,e,n)=>e in t?io(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,dt=(t,e,n)=>so(t,typeof e!="symbol"?e+"":e,n);class oo{constructor(e,n){this.logger=e,this.markConnectionStateDirty=n,dt(this,"inflightRequests"),dt(this,"requestsOlderThanRestart"),dt(this,"inflightMutationsCount",0),dt(this,"inflightActionsCount",0),this.inflightRequests=new Map,this.requestsOlderThanRestart=new Set}request(e,n){const r=new Promise(i=>{const s=n?"Requested":"NotSent";this.inflightRequests.set(e.requestId,{message:e,status:{status:s,requestedAt:new Date,onResult:i}}),e.type==="Mutation"?this.inflightMutationsCount++:e.type==="Action"&&this.inflightActionsCount++});return this.markConnectionStateDirty(),r}onResponse(e){const n=this.inflightRequests.get(e.requestId);if(n===void 0||n.status.status==="Completed")return null;const r=n.message.type==="Mutation"?"mutation":"action",i=n.message.udfPath;for(const a of e.logLines)ht(this.logger,"info",r,i,a);const s=n.status;let o,l;if(e.success)o={success:!0,logLines:e.logLines,value:Se(e.result)},l=()=>s.onResult(o);else{const a=e.result,{errorData:h}=e;ht(this.logger,"error",r,i,a),o={success:!1,errorMessage:a,errorData:h!==void 0?Se(h):void 0,logLines:e.logLines},l=()=>s.onResult(o)}return e.type==="ActionResponse"||!e.success?(l(),this.inflightRequests.delete(e.requestId),this.requestsOlderThanRestart.delete(e.requestId),n.message.type==="Action"?this.inflightActionsCount--:n.message.type==="Mutation"&&this.inflightMutationsCount--,this.markConnectionStateDirty(),{requestId:e.requestId,result:o}):(n.status={status:"Completed",result:o,ts:e.ts,onResolve:l},null)}removeCompleted(e){const n=new Map;for(const[r,i]of this.inflightRequests.entries()){const s=i.status;s.status==="Completed"&&s.ts.lessThanOrEqual(e)&&(s.onResolve(),n.set(r,s.result),i.message.type==="Mutation"?this.inflightMutationsCount--:i.message.type==="Action"&&this.inflightActionsCount--,this.inflightRequests.delete(r),this.requestsOlderThanRestart.delete(r))}return n.size>0&&this.markConnectionStateDirty(),n}restart(){this.requestsOlderThanRestart=new Set(this.inflightRequests.keys());const e=[];for(const[n,r]of this.inflightRequests){if(r.status.status==="NotSent"){r.status.status="Requested",e.push(r.message);continue}if(r.message.type==="Mutation")e.push(r.message);else if(r.message.type==="Action"){if(this.inflightRequests.delete(n),this.requestsOlderThanRestart.delete(n),this.inflightActionsCount--,r.status.status==="Completed")throw new Error("Action should never be in 'Completed' state");r.status.onResult({success:!1,errorMessage:"Connection lost while action was in flight",logLines:[]})}}return this.markConnectionStateDirty(),e}resume(){const e=[];for(const[,n]of this.inflightRequests)if(n.status.status==="NotSent"){n.status.status="Requested",e.push(n.message);continue}return e}hasIncompleteRequests(){for(const e of this.inflightRequests.values())if(e.status.status==="Requested")return!0;return!1}hasInflightRequests(){return this.inflightRequests.size>0}hasSyncedPastLastReconnect(){return this.requestsOlderThanRestart.size===0}timeOfOldestInflightRequest(){if(this.inflightRequests.size===0)return null;let e=Date.now();for(const n of this.inflightRequests.values())n.status.status!=="Completed"&&n.status.requestedAt.getTime()<e&&(e=n.status.requestedAt.getTime());return new Date(e)}inflightMutations(){return this.inflightMutationsCount}inflightActions(){return this.inflightActionsCount}}const We=Symbol.for("functionName"),Ur=Symbol.for("toReferencePath");function ao(t){return t[Ur]??null}function lo(t){return t.startsWith("function://")}function co(t){let e;if(typeof t=="string")lo(t)?e={functionHandle:t}:e={name:t};else if(t[We])e={name:t[We]};else{const n=ao(t);if(!n)throw new Error(`${t} is not a functionReference`);e={reference:n}}return e}function E(t){const e=co(t);if(e.name===void 0)throw e.functionHandle!==void 0?new Error(`Expected function reference like "api.file.func" or "internal.file.func", but received function handle ${e.functionHandle}`):e.reference!==void 0?new Error(`Expected function reference in the current component like "api.file.func" or "internal.file.func", but received reference ${e.reference}`):new Error(`Expected function reference like "api.file.func" or "internal.file.func", but received ${JSON.stringify(e)}`);if(typeof t=="string")return t;const n=t[We];if(!n)throw new Error(`${t} is not a functionReference`);return n}function Vr(t){return{[We]:t}}function Wr(t=[]){const e={get(n,r){if(typeof r=="string"){const i=[...t,r];return Wr(i)}else if(r===We){if(t.length<2){const o=["api",...t].join(".");throw new Error(`API path is expected to be of the form \`api.moduleName.functionName\`. Found: \`${o}\``)}const i=t.slice(0,-1).join("/"),s=t[t.length-1];return s==="default"?i:i+":"+s}else return r===Symbol.toStringTag?"FunctionReference":void 0}};return new Proxy({},e)}const uo=Wr();var ho=Object.defineProperty,fo=(t,e,n)=>e in t?ho(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ft=(t,e,n)=>fo(t,typeof e!="symbol"?e+"":e,n);class He{constructor(e){ft(this,"queryResults"),ft(this,"modifiedQueries"),this.queryResults=e,this.modifiedQueries=[]}getQuery(e,...n){const r=ne(n[0]),i=E(e),s=this.queryResults.get(fe(i,r));if(s!==void 0)return He.queryValue(s.result)}getAllQueries(e){const n=[],r=E(e);for(const i of this.queryResults.values())i.udfPath===de(r)&&n.push({args:i.args,value:He.queryValue(i.result)});return n}setQuery(e,n,r){const i=ne(n),s=E(e),o=fe(s,i);let l;r===void 0?l=void 0:l={success:!0,value:r,logLines:[]};const a={udfPath:s,args:i,result:l};this.queryResults.set(o,a),this.modifiedQueries.push(o)}static queryValue(e){if(e!==void 0)return e.success?e.value:void 0}}class po{constructor(){ft(this,"queryResults"),ft(this,"optimisticUpdates"),this.queryResults=new Map,this.optimisticUpdates=[]}ingestQueryResultsFromServer(e,n){this.optimisticUpdates=this.optimisticUpdates.filter(o=>!n.has(o.mutationId));const r=this.queryResults;this.queryResults=new Map(e);const i=new He(this.queryResults);for(const o of this.optimisticUpdates)o.update(i);const s=[];for(const[o,l]of this.queryResults){const a=r.get(o);(a===void 0||a.result!==l.result)&&s.push(o)}return s}applyOptimisticUpdate(e,n){this.optimisticUpdates.push({update:e,mutationId:n});const r=new He(this.queryResults);return e(r),r.modifiedQueries}rawQueryResult(e){const n=this.queryResults.get(e);if(n!==void 0)return n.result}queryResult(e){const n=this.queryResults.get(e);if(n===void 0)return;const r=n.result;if(r!==void 0){if(r.success)return r.value;throw r.errorData!==void 0?nn(r,new tn(je("query",n.udfPath,r))):new Error(je("query",n.udfPath,r))}}hasQueryResult(e){return this.queryResults.get(e)!==void 0}queryLogs(e){return this.queryResults.get(e)?.result?.logLines}}var go=Object.defineProperty,mo=(t,e,n)=>e in t?go(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,rn=(t,e,n)=>mo(t,typeof e!="symbol"?e+"":e,n);class P{constructor(e,n){rn(this,"low"),rn(this,"high"),rn(this,"__isUnsignedLong__"),this.low=e|0,this.high=n|0,this.__isUnsignedLong__=!0}static isLong(e){return(e&&e.__isUnsignedLong__)===!0}static fromBytesLE(e){return new P(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24)}toBytesLE(){const e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]}static fromNumber(e){return isNaN(e)||e<0?Hr:e>=xo?bo:new P(e%Je|0,e/Je|0)}toString(){return(BigInt(this.high)*BigInt(Je)+BigInt(this.low)).toString()}equals(e){return P.isLong(e)||(e=P.fromValue(e)),this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low}notEquals(e){return!this.equals(e)}comp(e){return P.isLong(e)||(e=P.fromValue(e)),this.equals(e)?0:e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1}lessThanOrEqual(e){return this.comp(e)<=0}static fromValue(e){return typeof e=="number"?P.fromNumber(e):new P(e.low,e.high)}}const Hr=new P(0,0),Jr=65536,Je=Jr*Jr,xo=Je*Je,bo=new P(-1,-1);var yo=Object.defineProperty,vo=(t,e,n)=>e in t?yo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,pt=(t,e,n)=>vo(t,typeof e!="symbol"?e+"":e,n);class Gr{constructor(e,n){pt(this,"version"),pt(this,"remoteQuerySet"),pt(this,"queryPath"),pt(this,"logger"),this.version={querySet:0,ts:P.fromNumber(0),identity:0},this.remoteQuerySet=new Map,this.queryPath=e,this.logger=n}transition(e){const n=e.startVersion;if(this.version.querySet!==n.querySet||this.version.ts.notEquals(n.ts)||this.version.identity!==n.identity)throw new Error(`Invalid start version: ${n.ts.toString()}:${n.querySet}:${n.identity}, transitioning from ${this.version.ts.toString()}:${this.version.querySet}:${this.version.identity}`);for(const r of e.modifications)switch(r.type){case"QueryUpdated":{const i=this.queryPath(r.queryId);if(i)for(const o of r.logLines)ht(this.logger,"info","query",i,o);const s=Se(r.value??null);this.remoteQuerySet.set(r.queryId,{success:!0,value:s,logLines:r.logLines});break}case"QueryFailed":{const i=this.queryPath(r.queryId);if(i)for(const o of r.logLines)ht(this.logger,"info","query",i,o);const{errorData:s}=r;this.remoteQuerySet.set(r.queryId,{success:!1,errorMessage:r.errorMessage,errorData:s!==void 0?Se(s):void 0,logLines:r.logLines});break}case"QueryRemoved":{this.remoteQuerySet.delete(r.queryId);break}default:throw new Error(`Invalid modification ${r.type}`)}this.version=e.endVersion}remoteQueryResults(){return this.remoteQuerySet}timestamp(){return this.version.ts}}function sn(t){const e=De(t);return P.fromBytesLE(Array.from(e))}function _o(t){const e=new Uint8Array(t.toBytesLE());return Ue(e)}function Kr(t){switch(t.type){case"FatalError":case"AuthError":case"ActionResponse":case"TransitionChunk":case"Ping":return{...t};case"MutationResponse":return t.success?{...t,ts:sn(t.ts)}:{...t};case"Transition":return{...t,startVersion:{...t.startVersion,ts:sn(t.startVersion.ts)},endVersion:{...t.endVersion,ts:sn(t.endVersion.ts)}}}}function wo(t){switch(t.type){case"Authenticate":case"ModifyQuerySet":case"Mutation":case"Action":case"Event":return{...t};case"Connect":return t.maxObservedTimestamp!==void 0?{...t,maxObservedTimestamp:_o(t.maxObservedTimestamp)}:{...t,maxObservedTimestamp:void 0}}}var ko=Object.defineProperty,So=(t,e,n)=>e in t?ko(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,C=(t,e,n)=>So(t,typeof e!="symbol"?e+"":e,n);const jo=1e3,Co=1001,Ro=1005,To=4040;let gt;function Ce(){return gt===void 0&&(gt=Date.now()),typeof performance>"u"||!performance.now?Date.now():Math.round(gt+performance.now())}function Zr(){return`t=${Math.round((Ce()-gt)/100)/10}s`}const Xr={InternalServerError:{timeout:1e3},SubscriptionsWorkerFullError:{timeout:3e3},TooManyConcurrentRequests:{timeout:3e3},CommitterFullError:{timeout:3e3},AwsTooManyRequestsException:{timeout:3e3},ExecuteFullError:{timeout:3e3},SystemTimeoutError:{timeout:3e3},ExpiredInQueue:{timeout:3e3},VectorIndexesUnavailable:{timeout:1e3},SearchIndexesUnavailable:{timeout:1e3},TableSummariesUnavailable:{timeout:1e3},VectorIndexTooLarge:{timeout:3e3},SearchIndexTooLarge:{timeout:3e3},TooManyWritesInTimePeriod:{timeout:3e3}};function $o(t){if(t===void 0)return"Unknown";for(const e of Object.keys(Xr))if(t.startsWith(e))return e;return"Unknown"}class Ao{constructor(e,n,r,i,s,o){this.markConnectionStateDirty=s,this.debug=o,C(this,"socket"),C(this,"connectionCount"),C(this,"_hasEverConnected",!1),C(this,"lastCloseReason"),C(this,"transitionChunkBuffer",null),C(this,"defaultInitialBackoff"),C(this,"maxBackoff"),C(this,"retries"),C(this,"serverInactivityThreshold"),C(this,"reconnectDueToServerInactivityTimeout"),C(this,"scheduledReconnect",null),C(this,"networkOnlineHandler",null),C(this,"pendingNetworkRecoveryInfo",null),C(this,"uri"),C(this,"onOpen"),C(this,"onResume"),C(this,"onMessage"),C(this,"webSocketConstructor"),C(this,"logger"),C(this,"onServerDisconnectError"),this.webSocketConstructor=r,this.socket={state:"disconnected"},this.connectionCount=0,this.lastCloseReason="InitialConnect",this.defaultInitialBackoff=1e3,this.maxBackoff=16e3,this.retries=0,this.serverInactivityThreshold=6e4,this.reconnectDueToServerInactivityTimeout=null,this.uri=e,this.onOpen=n.onOpen,this.onResume=n.onResume,this.onMessage=n.onMessage,this.onServerDisconnectError=n.onServerDisconnectError,this.logger=i,this.setupNetworkListener(),this.connect()}setSocketState(e){this.socket=e,this._logVerbose(`socket state changed: ${this.socket.state}, paused: ${"paused"in this.socket?this.socket.paused:void 0}`),this.markConnectionStateDirty()}setupNetworkListener(){typeof window>"u"||typeof window.addEventListener!="function"||this.networkOnlineHandler===null&&(this.networkOnlineHandler=()=>{this._logVerbose("network online event detected"),this.tryReconnectImmediately()},window.addEventListener("online",this.networkOnlineHandler),this._logVerbose("network online event listener registered"))}cleanupNetworkListener(){this.networkOnlineHandler&&typeof window<"u"&&typeof window.removeEventListener=="function"&&(window.removeEventListener("online",this.networkOnlineHandler),this.networkOnlineHandler=null,this._logVerbose("network online event listener removed"))}assembleTransition(e){if(e.partNumber<0||e.partNumber>=e.totalParts||e.totalParts===0||this.transitionChunkBuffer&&(this.transitionChunkBuffer.totalParts!==e.totalParts||this.transitionChunkBuffer.transitionId!==e.transitionId))throw this.transitionChunkBuffer=null,new Error("Invalid TransitionChunk");if(this.transitionChunkBuffer===null&&(this.transitionChunkBuffer={chunks:[],totalParts:e.totalParts,transitionId:e.transitionId}),e.partNumber!==this.transitionChunkBuffer.chunks.length){const n=this.transitionChunkBuffer.chunks.length;throw this.transitionChunkBuffer=null,new Error(`TransitionChunk received out of order: expected part ${n}, got ${e.partNumber}`)}if(this.transitionChunkBuffer.chunks.push(e.chunk),this.transitionChunkBuffer.chunks.length===e.totalParts){const n=this.transitionChunkBuffer.chunks.join("");this.transitionChunkBuffer=null;const r=Kr(JSON.parse(n));if(r.type!=="Transition")throw new Error(`Expected Transition, got ${r.type} after assembling chunks`);return r}return null}connect(){if(this.socket.state==="terminated")return;if(this.socket.state!=="disconnected"&&this.socket.state!=="stopped")throw new Error("Didn't start connection from disconnected state: "+this.socket.state);const e=new this.webSocketConstructor(this.uri);this._logVerbose("constructed WebSocket"),this.setSocketState({state:"connecting",ws:e,paused:"no"}),this.resetServerInactivityTimeout(),e.onopen=()=>{if(this.logger.logVerbose("begin ws.onopen"),this.socket.state!=="connecting")throw new Error("onopen called with socket not in connecting state");if(this.setSocketState({state:"ready",ws:e,paused:this.socket.paused==="yes"?"uninitialized":"no"}),this.resetServerInactivityTimeout(),this.socket.paused==="no"&&(this._hasEverConnected=!0,this.onOpen({connectionCount:this.connectionCount,lastCloseReason:this.lastCloseReason,clientTs:Ce()})),this.lastCloseReason!=="InitialConnect"&&(this.lastCloseReason?this.logger.log("WebSocket reconnected at",Zr(),"after disconnect due to",this.lastCloseReason):this.logger.log("WebSocket reconnected at",Zr())),this.connectionCount+=1,this.lastCloseReason=null,this.pendingNetworkRecoveryInfo!==null){const{timeSavedMs:n}=this.pendingNetworkRecoveryInfo;this.pendingNetworkRecoveryInfo=null,this.sendMessage({type:"Event",eventType:"NetworkRecoveryReconnect",event:{timeSavedMs:n}}),this.logger.log(`Network recovery reconnect saved ~${Math.round(n/1e3)}s of waiting`)}},e.onerror=n=>{this.transitionChunkBuffer=null;const r=n.message;r&&this.logger.log(`WebSocket error message: ${r}`)},e.onmessage=n=>{this.resetServerInactivityTimeout();const r=n.data.length;let i=Kr(JSON.parse(n.data));if(this._logVerbose(`received ws message with type ${i.type}`),i.type==="Ping")return;if(i.type==="TransitionChunk"){const o=this.assembleTransition(i);if(!o)return;i=o,this._logVerbose(`assembled full ws message of type ${i.type}`)}this.transitionChunkBuffer!==null&&(this.transitionChunkBuffer=null,this.logger.log(`Received unexpected ${i.type} while buffering TransitionChunks`)),i.type==="Transition"&&this.reportLargeTransition({messageLength:r,transition:i}),this.onMessage(i).hasSyncedPastLastReconnect&&(this.retries=0,this.markConnectionStateDirty())},e.onclose=n=>{if(this._logVerbose("begin ws.onclose"),this.transitionChunkBuffer=null,this.lastCloseReason===null&&(this.lastCloseReason=n.reason||`closed with code ${n.code}`),n.code!==jo&&n.code!==Co&&n.code!==Ro&&n.code!==To){let i=`WebSocket closed with code ${n.code}`;n.reason&&(i+=`: ${n.reason}`),this.logger.log(i),this.onServerDisconnectError&&n.reason&&this.onServerDisconnectError(i)}const r=$o(n.reason);this.scheduleReconnect(r)}}socketState(){return this.socket.state}sendMessage(e){const n={type:e.type,...e.type==="Authenticate"&&e.tokenType==="User"?{value:`...${e.value.slice(-7)}`}:{}};if(this.socket.state==="ready"&&this.socket.paused==="no"){const r=wo(e),i=JSON.stringify(r);let s=!1;try{this.socket.ws.send(i),s=!0}catch(o){this.logger.log(`Failed to send message on WebSocket, reconnecting: ${o}`),this.closeAndReconnect("FailedToSendMessage")}return this._logVerbose(`${s?"sent":"failed to send"} message with type ${e.type}: ${JSON.stringify(n)}`),!0}return this._logVerbose(`message not sent (socket state: ${this.socket.state}, paused: ${"paused"in this.socket?this.socket.paused:void 0}): ${JSON.stringify(n)}`),!1}resetServerInactivityTimeout(){this.socket.state!=="terminated"&&(this.reconnectDueToServerInactivityTimeout!==null&&(clearTimeout(this.reconnectDueToServerInactivityTimeout),this.reconnectDueToServerInactivityTimeout=null),this.reconnectDueToServerInactivityTimeout=setTimeout(()=>{this.closeAndReconnect("InactiveServer")},this.serverInactivityThreshold))}scheduleReconnect(e){this.scheduledReconnect&&(clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null),this.socket={state:"disconnected"};const n=this.nextBackoff(e);this.markConnectionStateDirty(),this.logger.log(`Attempting reconnect in ${Math.round(n)}ms`);const r=Ce(),i=setTimeout(()=>{this.scheduledReconnect?.timeout===i&&(this.scheduledReconnect=null,this.connect())},n);this.scheduledReconnect={timeout:i,scheduledAt:r,backoffMs:n}}closeAndReconnect(e){switch(this._logVerbose(`begin closeAndReconnect with reason ${e}`),this.socket.state){case"disconnected":case"terminated":case"stopped":return;case"connecting":case"ready":{this.lastCloseReason=e,this.close(),this.scheduleReconnect("client");return}default:this.socket}}close(){switch(this.transitionChunkBuffer=null,this.socket.state){case"disconnected":case"terminated":case"stopped":return Promise.resolve();case"connecting":{const e=this.socket.ws;return e.onmessage=n=>{this._logVerbose("Ignoring message received after close")},new Promise(n=>{e.onclose=()=>{this._logVerbose("Closed after connecting"),n()},e.onopen=()=>{this._logVerbose("Opened after connecting"),e.close()}})}case"ready":{this._logVerbose("ws.close called");const e=this.socket.ws;e.onmessage=r=>{this._logVerbose("Ignoring message received after close")};const n=new Promise(r=>{e.onclose=()=>{r()}});return e.close(),n}default:return this.socket,Promise.resolve()}}terminate(){switch(this.reconnectDueToServerInactivityTimeout&&clearTimeout(this.reconnectDueToServerInactivityTimeout),this.scheduledReconnect&&(clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null),this.cleanupNetworkListener(),this.socket.state){case"terminated":case"stopped":case"disconnected":case"connecting":case"ready":{const e=this.close();return this.setSocketState({state:"terminated"}),e}default:throw this.socket,new Error(`Invalid websocket state: ${this.socket.state}`)}}stop(){switch(this.socket.state){case"terminated":return Promise.resolve();case"connecting":case"stopped":case"disconnected":case"ready":{this.cleanupNetworkListener();const e=this.close();return this.socket={state:"stopped"},e}default:return this.socket,Promise.resolve()}}tryRestart(){switch(this.socket.state){case"stopped":break;case"terminated":case"connecting":case"ready":case"disconnected":this.logger.logVerbose("Restart called without stopping first");return;default:this.socket}this.setupNetworkListener(),this.connect()}pause(){switch(this.socket.state){case"disconnected":case"stopped":case"terminated":return;case"connecting":case"ready":{this.socket={...this.socket,paused:"yes"};return}default:{this.socket;return}}}tryReconnectImmediately(){if(this._logVerbose("tryReconnectImmediately called"),this.socket.state!=="disconnected"){this._logVerbose(`tryReconnectImmediately called but socket state is ${this.socket.state}, no action taken`);return}let e=null;if(this.scheduledReconnect){const n=Ce()-this.scheduledReconnect.scheduledAt;e=Math.max(0,this.scheduledReconnect.backoffMs-n),this._logVerbose(`would have waited ${Math.round(e)}ms more (backoff was ${Math.round(this.scheduledReconnect.backoffMs)}ms, elapsed ${Math.round(n)}ms)`),clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null,this._logVerbose("canceled scheduled reconnect")}this.logger.log("Network recovery detected, reconnecting immediately"),this.pendingNetworkRecoveryInfo=e!==null?{timeSavedMs:e}:null,this.connect()}resume(){switch(this.socket.state){case"connecting":this.socket={...this.socket,paused:"no"};return;case"ready":this.socket.paused==="uninitialized"?(this.socket={...this.socket,paused:"no"},this._hasEverConnected=!0,this.onOpen({connectionCount:this.connectionCount,lastCloseReason:this.lastCloseReason,clientTs:Ce()})):this.socket.paused==="yes"&&(this.socket={...this.socket,paused:"no"},this.onResume());return;case"terminated":case"stopped":case"disconnected":return;default:this.socket}this.connect()}connectionState(){return{isConnected:this.socket.state==="ready",hasEverConnected:this._hasEverConnected,connectionCount:this.connectionCount,connectionRetries:this.retries}}_logVerbose(e){this.logger.logVerbose(e)}nextBackoff(e){const r=(e==="client"?100:e==="Unknown"?this.defaultInitialBackoff:Xr[e].timeout)*Math.pow(2,this.retries);this.retries+=1;const i=Math.min(r,this.maxBackoff),s=i*(Math.random()-.5);return i+s}reportLargeTransition({transition:e,messageLength:n}){if(e.clientClockSkew===void 0||e.serverTs===void 0)return;const r=Ce()-e.clientClockSkew-e.serverTs/1e6,i=`${Math.round(r)}ms`,s=`${Math.round(n/1e4)/100}MB`,o=n/(r/1e3),l=`${Math.round(o/1e4)/100}MB per second`;this._logVerbose(`received ${s} transition in ${i} at ${l}`),n>2e7?this.logger.log(`received query results totaling more that 20MB (${s}) which will take a long time to download on slower connections`):r>2e4&&this.logger.log(`received query results totaling ${s} which took more than 20s to arrive (${i})`),this.debug&&this.sendMessage({type:"Event",eventType:"ClientReceivedTransition",event:{transitionTransitTime:r,messageLength:n}})}}function Io(){return Eo()}function Eo(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}class Ge extends Error{}Ge.prototype.name="InvalidTokenError";function Po(t){return decodeURIComponent(atob(t).replace(/(.)/g,(e,n)=>{let r=n.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}function qo(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return Po(e)}catch{return atob(e)}}function Yr(t,e){if(typeof t!="string")throw new Ge("Invalid token specified: must be a string");e||(e={});const n=e.header===!0?0:1,r=t.split(".")[n];if(typeof r!="string")throw new Ge(`Invalid token specified: missing part #${n+1}`);let i;try{i=qo(r)}catch(s){throw new Ge(`Invalid token specified: invalid base64 for part #${n+1} (${s.message})`)}try{return JSON.parse(i)}catch(s){throw new Ge(`Invalid token specified: invalid json for part #${n+1} (${s.message})`)}}var Mo=Object.defineProperty,Lo=(t,e,n)=>e in t?Mo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Q=(t,e,n)=>Lo(t,typeof e!="symbol"?e+"":e,n);const Oo=480*60*60*1e3,ei=2;class No{constructor(e,n,r){Q(this,"authState",{state:"noAuth"}),Q(this,"configVersion",0),Q(this,"syncState"),Q(this,"authenticate"),Q(this,"stopSocket"),Q(this,"tryRestartSocket"),Q(this,"pauseSocket"),Q(this,"resumeSocket"),Q(this,"clearAuth"),Q(this,"logger"),Q(this,"refreshTokenLeewaySeconds"),Q(this,"tokenConfirmationAttempts",0),this.syncState=e,this.authenticate=n.authenticate,this.stopSocket=n.stopSocket,this.tryRestartSocket=n.tryRestartSocket,this.pauseSocket=n.pauseSocket,this.resumeSocket=n.resumeSocket,this.clearAuth=n.clearAuth,this.logger=r.logger,this.refreshTokenLeewaySeconds=r.refreshTokenLeewaySeconds}async setConfig(e,n){this.resetAuthState(),this._logVerbose("pausing WS for auth token fetch"),this.pauseSocket();const r=await this.fetchTokenAndGuardAgainstRace(e,{forceRefreshToken:!1});r.isFromOutdatedConfig||(r.value?(this.setAuthState({state:"waitingForServerConfirmationOfCachedToken",config:{fetchToken:e,onAuthChange:n},hasRetried:!1}),this.authenticate(r.value)):(this.setAuthState({state:"initialRefetch",config:{fetchToken:e,onAuthChange:n}}),await this.refetchToken()),this._logVerbose("resuming WS after auth token fetch"),this.resumeSocket())}onTransition(e){if(this.syncState.isCurrentOrNewerAuthVersion(e.endVersion.identity)&&!(e.endVersion.identity<=e.startVersion.identity)){if(this._logVerbose(`auth state is ${this.authState.state} when handling transition`),this.syncState.markAuthCompletion(),this.authState.state==="waitingForServerConfirmationOfCachedToken"){this._logVerbose("server confirmed auth token is valid"),this.refetchToken(),this.authState.config.onAuthChange(!0);return}this.authState.state==="waitingForServerConfirmationOfFreshToken"&&(this._logVerbose("server confirmed new auth token is valid"),this.scheduleTokenRefetch(this.authState.token),this.tokenConfirmationAttempts=0,this.authState.hadAuth||this.authState.config.onAuthChange(!0))}}onAuthError(e){if(e.authUpdateAttempted===!1&&(this.authState.state==="waitingForServerConfirmationOfFreshToken"||this.authState.state==="waitingForServerConfirmationOfCachedToken")){this._logVerbose("ignoring non-auth token expired error");return}const{baseVersion:n}=e;if(!this.syncState.isCurrentOrNewerAuthVersion(n+1)){this._logVerbose("ignoring auth error for previous auth attempt");return}this.tryToReauthenticate(e)}async tryToReauthenticate(e){if(this._logVerbose(`attempting to reauthenticate: ${e.error}`),this.authState.state==="noAuth"||this.authState.state==="waitingForServerConfirmationOfFreshToken"&&this.tokenConfirmationAttempts>=ei){this.logger.error(`Failed to authenticate: "${e.error}", check your server auth config`),this.syncState.hasAuth()&&this.syncState.clearAuth(),this.authState.state!=="noAuth"&&this.setAndReportAuthFailed(this.authState.config.onAuthChange);return}this.authState.state==="waitingForServerConfirmationOfFreshToken"&&(this.tokenConfirmationAttempts++,this._logVerbose(`retrying reauthentication, ${ei-this.tokenConfirmationAttempts} attempts remaining`)),await this.stopSocket();const n=await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken,{forceRefreshToken:!0});n.isFromOutdatedConfig||(n.value&&this.syncState.isNewAuth(n.value)?(this.authenticate(n.value),this.setAuthState({state:"waitingForServerConfirmationOfFreshToken",config:this.authState.config,token:n.value,hadAuth:this.authState.state==="notRefetching"||this.authState.state==="waitingForScheduledRefetch"})):(this._logVerbose("reauthentication failed, could not fetch a new token"),this.syncState.hasAuth()&&this.syncState.clearAuth(),this.setAndReportAuthFailed(this.authState.config.onAuthChange)),this.tryRestartSocket())}async refetchToken(){if(this.authState.state==="noAuth")return;this._logVerbose("refetching auth token");const e=await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken,{forceRefreshToken:!0});e.isFromOutdatedConfig||(e.value?this.syncState.isNewAuth(e.value)?(this.setAuthState({state:"waitingForServerConfirmationOfFreshToken",hadAuth:this.syncState.hasAuth(),token:e.value,config:this.authState.config}),this.authenticate(e.value)):this.setAuthState({state:"notRefetching",config:this.authState.config}):(this._logVerbose("refetching token failed"),this.syncState.hasAuth()&&this.clearAuth(),this.setAndReportAuthFailed(this.authState.config.onAuthChange)),this._logVerbose("restarting WS after auth token fetch (if currently stopped)"),this.tryRestartSocket())}scheduleTokenRefetch(e){if(this.authState.state==="noAuth")return;const n=this.decodeToken(e);if(!n){this.logger.error("Auth token is not a valid JWT, cannot refetch the token");return}const{iat:r,exp:i}=n;if(!r||!i){this.logger.error("Auth token does not have required fields, cannot refetch the token");return}const s=i-r;if(s<=2){this.logger.error("Auth token does not live long enough, cannot refetch the token");return}let o=Math.min(Oo,(s-this.refreshTokenLeewaySeconds)*1e3);o<=0&&(this.logger.warn(`Refetching auth token immediately, configured leeway ${this.refreshTokenLeewaySeconds}s is larger than the token's lifetime ${s}s`),o=0);const l=setTimeout(()=>{this._logVerbose("running scheduled token refetch"),this.refetchToken()},o);this.setAuthState({state:"waitingForScheduledRefetch",refetchTokenTimeoutId:l,config:this.authState.config}),this._logVerbose(`scheduled preemptive auth token refetching in ${o}ms`)}async fetchTokenAndGuardAgainstRace(e,n){const r=++this.configVersion;this._logVerbose(`fetching token with config version ${r}`);const i=await e(n);return this.configVersion!==r?(this._logVerbose(`stale config version, expected ${r}, got ${this.configVersion}`),{isFromOutdatedConfig:!0}):{isFromOutdatedConfig:!1,value:i}}stop(){this.resetAuthState(),this.configVersion++,this._logVerbose(`config version bumped to ${this.configVersion}`)}setAndReportAuthFailed(e){e(!1),this.resetAuthState()}resetAuthState(){this.setAuthState({state:"noAuth"})}setAuthState(e){const n=e.state==="waitingForServerConfirmationOfFreshToken"?{hadAuth:e.hadAuth,state:e.state,token:`...${e.token.slice(-7)}`}:{state:e.state};switch(this._logVerbose(`setting auth state to ${JSON.stringify(n)}`),e.state){case"waitingForScheduledRefetch":case"notRefetching":case"noAuth":this.tokenConfirmationAttempts=0;break}this.authState.state==="waitingForScheduledRefetch"&&clearTimeout(this.authState.refetchTokenTimeoutId),this.authState=e}decodeToken(e){try{return Yr(e)}catch(n){return this._logVerbose(`Error decoding token: ${n instanceof Error?n.message:"Unknown error"}`),null}}_logVerbose(e){this.logger.logVerbose(`${e} [v${this.configVersion}]`)}}const zo=["convexClientConstructed","convexWebSocketOpen","convexFirstMessageReceived"];function Bo(t,e){const n={sessionId:e};typeof performance>"u"||!performance.mark||performance.mark(t,{detail:n})}function Qo(t){let e=t.name.slice(6);return e=e.charAt(0).toLowerCase()+e.slice(1),{name:e,startTime:t.startTime}}function Fo(t){if(typeof performance>"u"||!performance.getEntriesByName)return[];const e=[];for(const n of zo){const r=performance.getEntriesByName(n).filter(i=>i.entryType==="mark").filter(i=>i.detail.sessionId===t);e.push(...r)}return e.map(Qo)}var Do=Object.defineProperty,Uo=(t,e,n)=>e in t?Do(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,R=(t,e,n)=>Uo(t,typeof e!="symbol"?e+"":e,n);class Vo{constructor(e,n,r){if(R(this,"address"),R(this,"state"),R(this,"requestManager"),R(this,"webSocketManager"),R(this,"authenticationManager"),R(this,"remoteQuerySet"),R(this,"optimisticQueryResults"),R(this,"_transitionHandlerCounter",0),R(this,"_nextRequestId"),R(this,"_onTransitionFns",new Map),R(this,"_sessionId"),R(this,"firstMessageReceived",!1),R(this,"debug"),R(this,"logger"),R(this,"maxObservedTimestamp"),R(this,"connectionStateSubscribers",new Map),R(this,"nextConnectionStateSubscriberId",0),R(this,"_lastPublishedConnectionState"),R(this,"markConnectionStateDirty",()=>{Promise.resolve().then(()=>{const f=this.connectionState();if(JSON.stringify(f)!==JSON.stringify(this._lastPublishedConnectionState)){this._lastPublishedConnectionState=f;for(const g of this.connectionStateSubscribers.values())g(f)}})}),R(this,"mark",f=>{this.debug&&Bo(f,this.sessionId)}),typeof e=="object")throw new Error("Passing a ClientConfig object is no longer supported. Pass the URL of the Convex deployment as a string directly.");r?.skipConvexDeploymentUrlCheck!==!0&&zs(e),r={...r};const i=r.authRefreshTokenLeewaySeconds??10;let s=r.webSocketConstructor;if(!s&&typeof WebSocket>"u")throw new Error("No WebSocket global variable defined! To use Convex in an environment without WebSocket try the HTTP client: https://docs.convex.dev/api/classes/browser.ConvexHttpClient");s=s||WebSocket,this.debug=r.reportDebugInfoToConvex??!1,this.address=e,this.logger=r.logger===!1?Fr({verbose:r.verbose??!1}):r.logger!==!0&&r.logger?r.logger:Qr({verbose:r.verbose??!1});const o=e.search("://");if(o===-1)throw new Error("Provided address was not an absolute URL.");const l=e.substring(o+3),a=e.substring(0,o);let h;if(a==="http")h="ws";else if(a==="https")h="wss";else throw new Error(`Unknown parent protocol ${a}`);const d=`${h}://${l}/api/${Or}/sync`;this.state=new ro,this.remoteQuerySet=new Gr(f=>this.state.queryPath(f),this.logger),this.requestManager=new oo(this.logger,this.markConnectionStateDirty);const c=()=>{this.webSocketManager.pause(),this.state.pause()};this.authenticationManager=new No(this.state,{authenticate:f=>{const g=this.state.setAuth(f);return this.webSocketManager.sendMessage(g),g.baseVersion},stopSocket:()=>this.webSocketManager.stop(),tryRestartSocket:()=>this.webSocketManager.tryRestart(),pauseSocket:c,resumeSocket:()=>this.webSocketManager.resume(),clearAuth:()=>{this.clearAuth()}},{logger:this.logger,refreshTokenLeewaySeconds:i}),this.optimisticQueryResults=new po,this.addOnTransitionHandler(f=>{n(f.queries.map(g=>g.token))}),this._nextRequestId=0,this._sessionId=Io();const{unsavedChangesWarning:p}=r;if(typeof window>"u"||typeof window.addEventListener>"u"){if(p===!0)throw new Error("unsavedChangesWarning requested, but window.addEventListener not found! Remove {unsavedChangesWarning: true} from Convex client options.")}else p!==!1&&window.addEventListener("beforeunload",f=>{if(this.requestManager.hasIncompleteRequests()){f.preventDefault();const g="Are you sure you want to leave? Your changes may not be saved.";return(f||window.event).returnValue=g,g}});this.webSocketManager=new Ao(d,{onOpen:f=>{this.mark("convexWebSocketOpen"),this.webSocketManager.sendMessage({...f,type:"Connect",sessionId:this._sessionId,maxObservedTimestamp:this.maxObservedTimestamp}),this.remoteQuerySet=new Gr(k=>this.state.queryPath(k),this.logger);const[g,x]=this.state.restart();x&&this.webSocketManager.sendMessage(x),this.webSocketManager.sendMessage(g);for(const k of this.requestManager.restart())this.webSocketManager.sendMessage(k)},onResume:()=>{const[f,g]=this.state.resume();g&&this.webSocketManager.sendMessage(g),f&&this.webSocketManager.sendMessage(f);for(const x of this.requestManager.resume())this.webSocketManager.sendMessage(x)},onMessage:f=>{switch(this.firstMessageReceived||(this.firstMessageReceived=!0,this.mark("convexFirstMessageReceived"),this.reportMarks()),f.type){case"Transition":{this.observedTimestamp(f.endVersion.ts),this.authenticationManager.onTransition(f),this.remoteQuerySet.transition(f),this.state.transition(f);const g=this.requestManager.removeCompleted(this.remoteQuerySet.timestamp());this.notifyOnQueryResultChanges(g);break}case"MutationResponse":{f.success&&this.observedTimestamp(f.ts);const g=this.requestManager.onResponse(f);g!==null&&this.notifyOnQueryResultChanges(new Map([[g.requestId,g.result]]));break}case"ActionResponse":{this.requestManager.onResponse(f);break}case"AuthError":{this.authenticationManager.onAuthError(f);break}case"FatalError":{const g=eo(this.logger,f.error);throw this.webSocketManager.terminate(),g}}return{hasSyncedPastLastReconnect:this.hasSyncedPastLastReconnect()}},onServerDisconnectError:r.onServerDisconnectError},s,this.logger,this.markConnectionStateDirty,this.debug),this.mark("convexClientConstructed"),r.expectAuth&&c()}hasSyncedPastLastReconnect(){return this.requestManager.hasSyncedPastLastReconnect()&&this.state.hasSyncedPastLastReconnect()}observedTimestamp(e){(this.maxObservedTimestamp===void 0||this.maxObservedTimestamp.lessThanOrEqual(e))&&(this.maxObservedTimestamp=e)}getMaxObservedTimestamp(){return this.maxObservedTimestamp}notifyOnQueryResultChanges(e){const n=this.remoteQuerySet.remoteQueryResults(),r=new Map;for(const[s,o]of n){const l=this.state.queryToken(s);if(l!==null){const a={result:o,udfPath:this.state.queryPath(s),args:this.state.queryArgs(s)};r.set(l,a)}}const i=this.optimisticQueryResults.ingestQueryResultsFromServer(r,new Set(e.keys()));this.handleTransition({queries:i.map(s=>{const o=this.optimisticQueryResults.rawQueryResult(s);return{token:s,modification:{kind:"Updated",result:o}}}),reflectedMutations:Array.from(e).map(([s,o])=>({requestId:s,result:o})),timestamp:this.remoteQuerySet.timestamp()})}handleTransition(e){for(const n of this._onTransitionFns.values())n(e)}addOnTransitionHandler(e){const n=this._transitionHandlerCounter++;return this._onTransitionFns.set(n,e),()=>this._onTransitionFns.delete(n)}getCurrentAuthClaims(){const e=this.state.getAuth();let n={};if(e&&e.tokenType==="User")try{n=e?Yr(e.value):{}}catch{n={}}else return;return{token:e.value,decoded:n}}setAuth(e,n){this.authenticationManager.setConfig(e,n)}hasAuth(){return this.state.hasAuth()}setAdminAuth(e,n){const r=this.state.setAdminAuth(e,n);this.webSocketManager.sendMessage(r)}clearAuth(){const e=this.state.clearAuth();this.webSocketManager.sendMessage(e)}subscribe(e,n,r){const i=ne(n),{modification:s,queryToken:o,unsubscribe:l}=this.state.subscribe(e,i,r?.journal,r?.componentPath);return s!==null&&this.webSocketManager.sendMessage(s),{queryToken:o,unsubscribe:()=>{const a=l();a&&this.webSocketManager.sendMessage(a)}}}localQueryResult(e,n){const r=ne(n),i=fe(e,r);return this.optimisticQueryResults.queryResult(i)}localQueryResultByToken(e){return this.optimisticQueryResults.queryResult(e)}hasLocalQueryResultByToken(e){return this.optimisticQueryResults.hasQueryResult(e)}localQueryLogs(e,n){const r=ne(n),i=fe(e,r);return this.optimisticQueryResults.queryLogs(i)}queryJournal(e,n){const r=ne(n),i=fe(e,r);return this.state.queryJournal(i)}connectionState(){const e=this.webSocketManager.connectionState();return{hasInflightRequests:this.requestManager.hasInflightRequests(),isWebSocketConnected:e.isConnected,hasEverConnected:e.hasEverConnected,connectionCount:e.connectionCount,connectionRetries:e.connectionRetries,timeOfOldestInflightRequest:this.requestManager.timeOfOldestInflightRequest(),inflightMutations:this.requestManager.inflightMutations(),inflightActions:this.requestManager.inflightActions()}}subscribeToConnectionState(e){const n=this.nextConnectionStateSubscriberId++;return this.connectionStateSubscribers.set(n,e),()=>{this.connectionStateSubscribers.delete(n)}}async mutation(e,n,r){const i=await this.mutationInternal(e,n,r);if(!i.success)throw i.errorData!==void 0?nn(i,new tn(je("mutation",e,i))):new Error(je("mutation",e,i));return i.value}async mutationInternal(e,n,r,i){const{mutationPromise:s}=this.enqueueMutation(e,n,r,i);return s}enqueueMutation(e,n,r,i){const s=ne(n);this.tryReportLongDisconnect();const o=this.nextRequestId;if(this._nextRequestId++,r!==void 0){const d=r.optimisticUpdate;if(d!==void 0){const c=g=>{d(g,s)instanceof Promise&&this.logger.warn("Optimistic update handler returned a Promise. Optimistic updates should be synchronous.")},f=this.optimisticQueryResults.applyOptimisticUpdate(c,o).map(g=>{const x=this.localQueryResultByToken(g);return{token:g,modification:{kind:"Updated",result:x===void 0?void 0:{success:!0,value:x,logLines:[]}}}});this.handleTransition({queries:f,reflectedMutations:[],timestamp:this.remoteQuerySet.timestamp()})}}const l={type:"Mutation",requestId:o,udfPath:e,componentPath:i,args:[K(s)]},a=this.webSocketManager.sendMessage(l),h=this.requestManager.request(l,a);return{requestId:o,mutationPromise:h}}async action(e,n){const r=await this.actionInternal(e,n);if(!r.success)throw r.errorData!==void 0?nn(r,new tn(je("action",e,r))):new Error(je("action",e,r));return r.value}async actionInternal(e,n,r){const i=ne(n),s=this.nextRequestId;this._nextRequestId++,this.tryReportLongDisconnect();const o={type:"Action",requestId:s,udfPath:e,componentPath:r,args:[K(i)]},l=this.webSocketManager.sendMessage(o);return this.requestManager.request(o,l)}async close(){return this.authenticationManager.stop(),this.webSocketManager.terminate()}get url(){return this.address}get nextRequestId(){return this._nextRequestId}get sessionId(){return this._sessionId}reportMarks(){if(this.debug){const e=Fo(this.sessionId);this.webSocketManager.sendMessage({type:"Event",eventType:"ClientConnect",event:e})}}tryReportLongDisconnect(){if(!this.debug)return;const e=this.connectionState().timeOfOldestInflightRequest;if(e===null||Date.now()-e.getTime()<=60*1e3)return;const n=`${this.address}/api/debug_event`;fetch(n,{method:"POST",headers:{"Content-Type":"application/json","Convex-Client":`npm-${Or}`},body:JSON.stringify({event:"LongWebsocketDisconnect"})}).then(r=>{r.ok||this.logger.warn("Analytics request failed with response:",r.body)}).catch(r=>{this.logger.warn("Analytics response failed with error:",r)})}}function on(t){if(typeof t!="object"||t===null||!Array.isArray(t.page)||typeof t.isDone!="boolean"||typeof t.continueCursor!="string")throw new Error(`Not a valid paginated query result: ${t?.toString()}`);return t}var Wo=Object.defineProperty,Ho=(t,e,n)=>e in t?Wo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ti=(t,e,n)=>Ho(t,typeof e!="symbol"?e+"":e,n);class Jo{constructor(e,n){this.client=e,this.onTransition=n,ti(this,"paginatedQuerySet",new Map),ti(this,"lastTransitionTs"),this.lastTransitionTs=P.fromNumber(0),this.client.addOnTransitionHandler(r=>this.onBaseTransition(r))}subscribe(e,n,r){const i=de(e),s=Dr(i,n,r),o=()=>this.removePaginatedQuerySubscriber(s),l=this.paginatedQuerySet.get(s);return l?(l.numSubscribers+=1,{paginatedQueryToken:s,unsubscribe:o}):(this.paginatedQuerySet.set(s,{token:s,canonicalizedUdfPath:i,args:n,numSubscribers:1,options:{initialNumItems:r.initialNumItems},nextPageKey:0,pageKeys:[],pageKeyToQuery:new Map,ongoingSplits:new Map,skip:!1,id:r.id}),this.addPageToPaginatedQuery(s,null,r.initialNumItems),{paginatedQueryToken:s,unsubscribe:o})}localQueryResult(e,n,r){const i=de(e),s=Dr(i,n,r);return this.localQueryResultByToken(s)}localQueryResultByToken(e){const n=this.paginatedQuerySet.get(e);if(!n)return;const r=this.activePageQueryTokens(n);if(r.length===0)return{results:[],status:"LoadingFirstPage",loadMore:a=>this.loadMoreOfPaginatedQuery(e,a)};let i=[],s=!1,o=!1;for(const a of r){const h=this.client.localQueryResultByToken(a);if(h===void 0){s=!0,o=!1;continue}const d=on(h);i=i.concat(d.page),o=!!d.isDone}let l;return s?l=i.length===0?"LoadingFirstPage":"LoadingMore":o?l="Exhausted":l="CanLoadMore",{results:i,status:l,loadMore:a=>this.loadMoreOfPaginatedQuery(e,a)}}onBaseTransition(e){const n=e.queries.map(o=>o.token),r=this.queriesContainingTokens(n);let i=[];r.length>0&&(this.processPaginatedQuerySplits(r,o=>this.client.localQueryResultByToken(o)),i=r.map(o=>({token:o,modification:{kind:"Updated",result:this.localQueryResultByToken(o)}})));const s={...e,paginatedQueries:i};this.onTransition(s)}loadMoreOfPaginatedQuery(e,n){this.mustGetPaginatedQuery(e);const r=this.queryTokenForLastPageOfPaginatedQuery(e),i=this.client.localQueryResultByToken(r);if(!i)return!1;const s=on(i);if(s.isDone)return!1;this.addPageToPaginatedQuery(e,s.continueCursor,n);const o={timestamp:this.lastTransitionTs,reflectedMutations:[],queries:[],paginatedQueries:[{token:e,modification:{kind:"Updated",result:this.localQueryResultByToken(e)}}]};return this.onTransition(o),!0}queriesContainingTokens(e){if(e.length===0)return[];const n=[],r=new Set(e);for(const[i,s]of this.paginatedQuerySet)for(const o of this.allQueryTokens(s))if(r.has(o)){n.push(i);break}return n}processPaginatedQuerySplits(e,n){for(const r of e){const i=this.mustGetPaginatedQuery(r),{ongoingSplits:s,pageKeyToQuery:o,pageKeys:l}=i;for(const[a,[h,d]]of s)n(o.get(h).queryToken)!==void 0&&n(o.get(d).queryToken)!==void 0&&this.completePaginatedQuerySplit(i,a,h,d);for(const a of l){if(s.has(a))continue;const h=o.get(a).queryToken,d=n(h);if(!d)continue;const c=on(d);c.splitCursor&&(c.pageStatus==="SplitRecommended"||c.pageStatus==="SplitRequired"||c.page.length>i.options.initialNumItems*2)&&this.splitPaginatedQueryPage(i,a,c.splitCursor,c.continueCursor)}}}splitPaginatedQueryPage(e,n,r,i){const s=e.nextPageKey++,o=e.nextPageKey++,l={cursor:i,numItems:e.options.initialNumItems,id:e.id},a=this.client.subscribe(e.canonicalizedUdfPath,{...e.args,paginationOpts:{...l,cursor:null,endCursor:r}});e.pageKeyToQuery.set(s,a);const h=this.client.subscribe(e.canonicalizedUdfPath,{...e.args,paginationOpts:{...l,cursor:r,endCursor:i}});e.pageKeyToQuery.set(o,h),e.ongoingSplits.set(n,[s,o])}addPageToPaginatedQuery(e,n,r){const i=this.mustGetPaginatedQuery(e),s=i.nextPageKey++,o={cursor:n,numItems:r,id:i.id},l={...i.args,paginationOpts:o},a=this.client.subscribe(i.canonicalizedUdfPath,l);return i.pageKeys.push(s),i.pageKeyToQuery.set(s,a),a}removePaginatedQuerySubscriber(e){const n=this.paginatedQuerySet.get(e);if(n&&(n.numSubscribers-=1,!(n.numSubscribers>0))){for(const r of n.pageKeyToQuery.values())r.unsubscribe();this.paginatedQuerySet.delete(e)}}completePaginatedQuerySplit(e,n,r,i){const s=e.pageKeyToQuery.get(n);e.pageKeyToQuery.delete(n);const o=e.pageKeys.indexOf(n);e.pageKeys.splice(o,1,r,i),e.ongoingSplits.delete(n),s.unsubscribe()}activePageQueryTokens(e){return e.pageKeys.map(n=>e.pageKeyToQuery.get(n).queryToken)}allQueryTokens(e){return Array.from(e.pageKeyToQuery.values()).map(n=>n.queryToken)}queryTokenForLastPageOfPaginatedQuery(e){const n=this.mustGetPaginatedQuery(e),r=n.pageKeys[n.pageKeys.length-1];if(r===void 0)throw new Error(`No pages for paginated query ${e}`);return n.pageKeyToQuery.get(r).queryToken}mustGetPaginatedQuery(e){const n=this.paginatedQuerySet.get(e);if(!n)throw new Error("paginated query no longer exists for token "+e);return n}}function Go({getCurrentValue:t,subscribe:e}){const[n,r]=T(()=>({getCurrentValue:t,subscribe:e,value:t()}));let i=n.value;return(n.getCurrentValue!==t||n.subscribe!==e)&&(i=t(),r({getCurrentValue:t,subscribe:e,value:i})),M(()=>{let s=!1;const o=()=>{s||r(a=>{if(a.getCurrentValue!==t||a.subscribe!==e)return a;const h=t();return a.value===h?a:{...a,value:h}})},l=e(o);return o(),()=>{s=!0,l()}},[t,e]),i}var Ko=Object.defineProperty,Zo=(t,e,n)=>e in t?Ko(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,re=(t,e,n)=>Zo(t,typeof e!="symbol"?e+"":e,n);const Xo=5e3;if(typeof Jt>"u")throw new Error("Required dependency 'react' not found");function ni(t,e,n){function r(i){return na(i),e.mutation(t,i,{optimisticUpdate:n})}return r.withOptimisticUpdate=function(s){if(n!==void 0)throw new Error(`Already specified optimistic update for mutation ${E(t)}`);return ni(t,e,s)},r}class Yo{constructor(e,n){if(re(this,"address"),re(this,"cachedSync"),re(this,"cachedPaginatedQueryClient"),re(this,"listeners"),re(this,"options"),re(this,"closed",!1),re(this,"_logger"),re(this,"adminAuth"),re(this,"fakeUserIdentity"),e===void 0)throw new Error("No address provided to ConvexReactClient.\nIf trying to deploy to production, make sure to follow all the instructions found at https://docs.convex.dev/production/hosting/\nIf running locally, make sure to run `convex dev` and ensure the .env.local file is populated.");if(typeof e!="string")throw new Error(`ConvexReactClient requires a URL like 'https://happy-otter-123.convex.cloud', received something of type ${typeof e} instead.`);if(!e.includes("://"))throw new Error("Provided address was not an absolute URL.");this.address=e,this.listeners=new Map,this._logger=n?.logger===!1?Fr({verbose:n?.verbose??!1}):n?.logger!==!0&&n?.logger?n.logger:Qr({verbose:n?.verbose??!1}),this.options={...n,logger:this._logger}}get url(){return this.address}get sync(){if(this.closed)throw new Error("ConvexReactClient has already been closed.");return this.cachedSync?this.cachedSync:(this.cachedSync=new Vo(this.address,()=>{},this.options),this.adminAuth&&this.cachedSync.setAdminAuth(this.adminAuth,this.fakeUserIdentity),this.cachedPaginatedQueryClient=new Jo(this.cachedSync,e=>this.handleTransition(e)),this.cachedSync)}get paginatedQueryClient(){if(this.sync,this.cachedPaginatedQueryClient)return this.cachedPaginatedQueryClient;throw new Error("Should already be instantiated")}setAuth(e,n){if(typeof e=="string")throw new Error("Passing a string to ConvexReactClient.setAuth is no longer supported, please upgrade to passing in an async function to handle reauthentication.");this.sync.setAuth(e,n??(()=>{}))}clearAuth(){this.sync.clearAuth()}setAdminAuth(e,n){if(this.adminAuth=e,this.fakeUserIdentity=n,this.closed)throw new Error("ConvexReactClient has already been closed.");this.cachedSync&&this.sync.setAdminAuth(e,n)}watchQuery(e,...n){const[r,i]=n,s=E(e);return{onUpdate:o=>{const{queryToken:l,unsubscribe:a}=this.sync.subscribe(s,r,i),h=this.listeners.get(l);return h!==void 0?h.add(o):this.listeners.set(l,new Set([o])),()=>{if(this.closed)return;const d=this.listeners.get(l);d.delete(o),d.size===0&&this.listeners.delete(l),a()}},localQueryResult:()=>{if(this.cachedSync)return this.cachedSync.localQueryResult(s,r)},localQueryLogs:()=>{if(this.cachedSync)return this.cachedSync.localQueryLogs(s,r)},journal:()=>{if(this.cachedSync)return this.cachedSync.queryJournal(s,r)}}}prewarmQuery(e){const n=e.extendSubscriptionFor??Xo,i=this.watchQuery(e.query,e.args||{}).onUpdate(()=>{});setTimeout(i,n)}watchPaginatedQuery(e,n,r){const i=E(e);return{onUpdate:s=>{const{paginatedQueryToken:o,unsubscribe:l}=this.paginatedQueryClient.subscribe(i,n||{},r),a=this.listeners.get(o);return a!==void 0?a.add(s):this.listeners.set(o,new Set([s])),()=>{if(this.closed)return;const h=this.listeners.get(o);h.delete(s),h.size===0&&this.listeners.delete(o),l()}},localQueryResult:()=>this.paginatedQueryClient.localQueryResult(i,n,r)}}mutation(e,...n){const[r,i]=n,s=E(e);return this.sync.mutation(s,r,i)}action(e,...n){const r=E(e);return this.sync.action(r,...n)}query(e,...n){const r=this.watchQuery(e,...n),i=r.localQueryResult();return i!==void 0?Promise.resolve(i):new Promise((s,o)=>{const l=r.onUpdate(()=>{l();try{s(r.localQueryResult())}catch(a){o(a)}})})}connectionState(){return this.sync.connectionState()}subscribeToConnectionState(e){return this.sync.subscribeToConnectionState(e)}get logger(){return this._logger}async close(){if(this.closed=!0,this.listeners=new Map,this.cachedPaginatedQueryClient&&(this.cachedPaginatedQueryClient=void 0),this.cachedSync){const e=this.cachedSync;this.cachedSync=void 0,await e.close()}}handleTransition(e){const n=e.queries.map(i=>i.token),r=e.paginatedQueries.map(i=>i.token);this.transition([...n,...r])}transition(e){for(const n of e){const r=this.listeners.get(n);if(r)for(const i of r)i()}}}const an=Jt.createContext(void 0);function ea(){return at(an)}const ta=({client:t,children:e})=>Jt.createElement(an.Provider,{value:t},e);function ri(t,...e){const n=e[0]==="skip",r=e[0]==="skip"?{}:ne(e[0]),i=typeof t=="string"?Vr(t):t,s=E(i),o=z(()=>n?{}:{query:{query:i,args:r}},[JSON.stringify(K(r)),s,n]),a=oa(o).query;if(a instanceof Error)throw a;return a}function mt(t){const e=typeof t=="string"?Vr(t):t,n=at(an);if(n===void 0)throw new Error("Could not find Convex client! `useMutation` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");return z(()=>ni(e,n),[n,E(e)])}function na(t){if(typeof t=="object"&&t!==null&&"bubbles"in t&&"persist"in t&&"isDefaultPrevented"in t)throw new Error("Convex function called with SyntheticEvent object. Did you use a Convex function as an event handler directly? Event handlers like onClick receive an event object as their first argument. These SyntheticEvent objects are not valid Convex values. Try wrapping the function like `const handler = () => myMutation();` and using `handler` in the event handler.")}var ra=Object.defineProperty,ia=(t,e,n)=>e in t?ra(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ln=(t,e,n)=>ia(t,typeof e!="symbol"?e+"":e,n);class sa{constructor(e){ln(this,"createWatch"),ln(this,"queries"),ln(this,"listeners"),this.createWatch=e,this.queries={},this.listeners=new Set}setQueries(e){for(const n of Object.keys(e)){const{query:r,args:i,paginationOptions:s}=e[n];if(E(r),this.queries[n]===void 0)this.addQuery(n,r,i,s?{paginationOptions:s}:{});else{const o=this.queries[n];(E(r)!==E(o.query)||JSON.stringify(K(i))!==JSON.stringify(K(o.args))||JSON.stringify(s)!==JSON.stringify(o.paginationOptions))&&(this.removeQuery(n),this.addQuery(n,r,i,s?{paginationOptions:s}:{}))}}for(const n of Object.keys(this.queries))e[n]===void 0&&this.removeQuery(n)}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}getLocalResults(e){const n={};for(const r of Object.keys(e)){const{query:i,args:s}=e[r],o=e[r].paginationOptions;E(i);const l=this.createWatch(i,s,o?{paginationOptions:o}:{});let a;try{a=l.localQueryResult()}catch(h){if(h instanceof Error)a=h;else throw h}n[r]=a}return n}setCreateWatch(e){this.createWatch=e;for(const n of Object.keys(this.queries)){const{query:r,args:i,watch:s,paginationOptions:o}=this.queries[n],l="journal"in s?s.journal():void 0;this.removeQuery(n),this.addQuery(n,r,i,{...l?{journal:l}:[],...o?{paginationOptions:o}:{}})}}destroy(){for(const e of Object.keys(this.queries))this.removeQuery(e);this.listeners=new Set}addQuery(e,n,r,{paginationOptions:i,journal:s}){if(this.queries[e]!==void 0)throw new Error(`Tried to add a new query with identifier ${e} when it already exists.`);const o=this.createWatch(n,r,{...s?{journal:s}:[],...i?{paginationOptions:i}:{}}),l=o.onUpdate(()=>this.notifyListeners());this.queries[e]={query:n,args:r,watch:o,unsubscribe:l,...i?{paginationOptions:i}:{}}}removeQuery(e){const n=this.queries[e];if(n===void 0)throw new Error(`No query found with identifier ${e}.`);n.unsubscribe(),delete this.queries[e]}notifyListeners(){for(const e of this.listeners)e()}}function oa(t){const e=ea();if(e===void 0)throw new Error("Could not find Convex client! `useQuery` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");const n=z(()=>(r,i,{journal:s,paginationOptions:o})=>o?e.watchPaginatedQuery(r,i,o):e.watchQuery(r,i,s?{journal:s}:{}),[e]);return aa(t,n)}function aa(t,e){const[n]=T(()=>new sa(e));n.createWatch!==e&&n.setCreateWatch(e),M(()=>()=>n.destroy(),[n]);const r=z(()=>({getCurrentValue:()=>n.getLocalResults(t),subscribe:i=>(n.setQueries(t),n.subscribe(i))}),[n,t]);return Go(r)}var la=Symbol.for("preact-signals");function xt(){if(se>1)se--;else{for(var t,e=!1;Ke!==void 0;){var n=Ke;for(Ke=void 0,cn++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&oi(n))try{n.c()}catch(i){e||(t=i,e=!0)}n=r}}if(cn=0,se--,e)throw t}}function ca(t){if(se>0)return t();se++;try{return t()}finally{xt()}}var y=void 0;function ii(t){var e=y;y=void 0;try{return t()}finally{y=e}}var Ke=void 0,se=0,cn=0,bt=0;function si(t){if(y!==void 0){var e=t.n;if(e===void 0||e.t!==y)return e={i:0,S:t,p:y.s,n:void 0,t:y,e:void 0,x:void 0,r:e},y.s!==void 0&&(y.s.n=e),y.s=e,t.n=e,32&y.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=y.s,e.n=void 0,y.s.n=e,y.s=e),e}}function $(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}$.prototype.brand=la,$.prototype.h=function(){return!0},$.prototype.S=function(t){var e=this,n=this.t;n!==t&&t.e===void 0&&(t.x=n,this.t=t,n!==void 0?n.e=t:ii(function(){var r;(r=e.W)==null||r.call(e)}))},$.prototype.U=function(t){var e=this;if(this.t!==void 0){var n=t.e,r=t.x;n!==void 0&&(n.x=r,t.e=void 0),r!==void 0&&(r.e=n,t.x=void 0),t===this.t&&(this.t=r,r===void 0&&ii(function(){var i;(i=e.Z)==null||i.call(e)}))}},$.prototype.subscribe=function(t){var e=this;return Ze(function(){var n=e.value,r=y;y=void 0;try{t(n)}finally{y=r}},{name:"sub"})},$.prototype.valueOf=function(){return this.value},$.prototype.toString=function(){return this.value+""},$.prototype.toJSON=function(){return this.value},$.prototype.peek=function(){var t=y;y=void 0;try{return this.value}finally{y=t}},Object.defineProperty($.prototype,"value",{get:function(){var t=si(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(cn>100)throw new Error("Cycle detected");this.v=t,this.i++,bt++,se++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{xt()}}}});function L(t,e){return new $(t,e)}function oi(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function ai(t){for(var e=t.s;e!==void 0;e=e.n){var n=e.S.n;if(n!==void 0&&(e.r=n),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function li(t){for(var e=t.s,n=void 0;e!==void 0;){var r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):n=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}t.s=n}function pe(t,e){$.call(this,void 0),this.x=t,this.s=void 0,this.g=bt-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}pe.prototype=new $,pe.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===bt))return!0;if(this.g=bt,this.f|=1,this.i>0&&!oi(this))return this.f&=-2,!0;var t=y;try{ai(this),y=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return y=t,li(this),this.f&=-2,!0},pe.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}$.prototype.S.call(this,t)},pe.prototype.U=function(t){if(this.t!==void 0&&($.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}},pe.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}},Object.defineProperty(pe.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=si(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function un(t,e){return new pe(t,e)}function ci(t){var e=t.u;if(t.u=void 0,typeof e=="function"){se++;var n=y;y=void 0;try{e()}catch(r){throw t.f&=-2,t.f|=8,hn(t),r}finally{y=n,xt()}}}function hn(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,ci(t)}function ua(t){if(y!==this)throw new Error("Out-of-order effect");li(this),y=t,this.f&=-2,8&this.f&&hn(this),xt()}function Re(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}Re.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{t()}},Re.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ci(this),ai(this),se++;var t=y;return y=this,ua.bind(this,t)},Re.prototype.N=function(){2&this.f||(this.f|=2,this.o=Ke,Ke=this)},Re.prototype.d=function(){this.f|=8,1&this.f||hn(this)},Re.prototype.dispose=function(){this.d()};function Ze(t,e){var n=new Re(t,e);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var ui,yt,vt,ha=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__,hi=[];Ze(function(){ui=this.N})();function Te(t,e){m[t]=e.bind(null,m[t]||function(){})}function _t(t){if(vt){var e=vt;vt=void 0,e()}vt=t&&t.S()}function di(t){var e=this,n=t.data,r=Xe(n);r.value=n;var i=z(function(){for(var l=e,a=e.__v;a=a.__;)if(a.__c){a.__c.__$f|=4;break}var h=un(function(){var f=r.value.value;return f===0?0:f===!0?"":f||""}),d=un(function(){return!Array.isArray(h.value)&&!Mn(h.value)}),c=Ze(function(){if(this.N=fi,d.value){var f=h.value;l.__v&&l.__v.__e&&l.__v.__e.nodeType===3&&(l.__v.__e.data=f)}}),p=e.__$u.d;return e.__$u.d=function(){c(),p.call(this)},[d,h]},[]),s=i[0],o=i[1];return s.value?o.peek():o.value}di.displayName="ReactiveTextNode",Object.defineProperties($.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:di},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Te("__b",function(t,e){if(typeof e.type=="string"){var n,r=e.props;for(var i in r)if(i!=="children"){var s=r[i];s instanceof $&&(n||(e.__np=n={}),n[i]=s,r[i]=s.peek())}}t(e)}),Te("__r",function(t,e){if(t(e),e.type!==N){_t();var n,r=e.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=(function(i,s){var o;return Ze(function(){o=this},{name:s}),o.c=i,o})(function(){var i;ha&&((i=n.y)==null||i.call(n)),r.__$f|=1,r.setState({})},typeof e.type=="function"?e.type.displayName||e.type.name:""))),yt=r,_t(n)}}),Te("__e",function(t,e,n,r){_t(),yt=void 0,t(e,n,r)}),Te("diffed",function(t,e){_t(),yt=void 0;var n;if(typeof e.type=="string"&&(n=e.__e)){var r=e.__np,i=e.props;if(r){var s=n.U;if(s)for(var o in s){var l=s[o];l!==void 0&&!(o in r)&&(l.d(),s[o]=void 0)}else s={},n.U=s;for(var a in r){var h=s[a],d=r[a];h===void 0?(h=da(n,a,d,i),s[a]=h):h.o(d,i)}}}t(e)});function da(t,e,n,r){var i=e in t&&t.ownerSVGElement===void 0,s=L(n);return{o:function(o,l){s.value=o,r=l},d:Ze(function(){this.N=fi;var o=s.value.value;r[e]!==o&&(r[e]=o,i?t[e]=o:o!=null&&(o!==!1||e[4]==="-")?t.setAttribute(e,o):t.removeAttribute(e))})}}Te("unmount",function(t,e){if(typeof e.type=="string"){var n=e.__e;if(n){var r=n.U;if(r){n.U=void 0;for(var i in r){var s=r[i];s&&s.d()}}}}else{var o=e.__c;if(o){var l=o.__$u;l&&(o.__$u=void 0,l.d())}}t(e)}),Te("__h",function(t,e,n,r){(r<3||r===9)&&(e.__$f|=2),t(e,n,r)}),F.prototype.shouldComponentUpdate=function(t,e){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in e)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var s=2&this.__$f;if(!(r||s||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var o in t)if(o!=="__source"&&t[o]!==this.props[o])return!0;for(var l in this.props)if(!(l in t))return!0;return!1};function Xe(t,e){return z(function(){return L(t,e)},[])}function fa(t,e){var n=Be(t);return n.current=t,yt.__$f|=4,z(function(){return un(function(){return n.current()},e)},[])}var pa=function(t){queueMicrotask(function(){queueMicrotask(t)})};function ga(){ca(function(){for(var t;t=hi.shift();)ui.call(t)})}function fi(){hi.push(this)===1&&(m.requestAnimationFrame||pa)(ga)}const A=L(!1),wt=L(void 0),kt=L(void 0);function ma(t){return t.replace(/\.convex\.site\b/,".convex.cloud")}function dn(t){return t.replace(/\.convex\.cloud\b/,".convex.site")}function xa(t,e){const n=t.title??e?.title??"Assistant";return{title:n,greeting:t.greeting??e?.welcomeMessage??`Hi! I'm ${n}. How can I help?`,locale:t.locale??e?.locale,position:t.position??e?.position,colorScheme:t.colorScheme??e?.colorScheme,hideBranding:t.hideBranding??e?.hideBranding??!1,triggerIcon:t.triggerIcon??e?.triggerIcon??"chat",triggerRadius:t.triggerRadius??e?.triggerRadius??"full",triggerLabel:t.triggerLabel??e?.triggerLabel??"Chatte mit uns",mode:t.mode??"floating",primaryColor:t.primaryColor??e?.primaryColor,accentColor:t.accentColor??e?.accentColor,fontFamily:t.fontFamily??e?.fontFamily,fontSize:t.fontSize??e?.fontSize,borderRadius:t.borderRadius??e?.borderRadius,windowWidth:t.windowWidth??e?.windowWidth,windowHeight:t.windowHeight??e?.windowHeight}}async function ba(t,e,n,r){const i=new URL(`${t}/widget/config`);i.searchParams.set("orgSlug",e),r&&i.searchParams.set("projSlug",r);const s=await fetch(i.toString(),{signal:n});return s.ok?s.json():null}function ya(t,e,n){const[r,i]=T(null);return M(()=>{i(null);const s=n??"https://tame-spider-109.eu-west-1.convex.cloud",o=s?dn(s):void 0;if(!o||!t)return;const l=new AbortController;async function a(h){try{const d=await ba(h,t,l.signal,e);d&&i(d)}catch(d){if(d instanceof Error&&d.name==="AbortError")return}}return a(o),()=>{l.abort()}},[t,e,n]),r}async function pi(t,e,n){try{const r=await fetch(`${e}/widget/bootstrap`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n?{orgSlug:t,projSlug:n}:{orgSlug:t}),credentials:"omit"});if(r.ok){const i=await r.json();return{ok:!0,token:i.token,excludePaths:i.excludePaths}}return r.status===403?{ok:!1,error:"unauthorized"}:r.status===404?{ok:!1,error:"not_found"}:r.status===429?{ok:!1,error:"rate_limited",retryAfterSec:Number(r.headers.get("Retry-After"))||60}:{ok:!1,error:"network"}}catch{return{ok:!1,error:"network"}}}function va(t,e,n,r){M(()=>{if(n)return;const i=r??"https://tame-spider-109.eu-west-1.convex.cloud",s=i?dn(i):void 0;if(!s||!t)return;let o=!1;return(async()=>{const l=await pi(t,s,e);if(!o)if(l.ok)kt.value=l.token;else{const a=e?`project '${t}/${e}'`:`org '${t}'`;l.error==="unauthorized"?console.error(`[JexityChat] This domain is not authorized for ${a}. Check the widget's domain rules.`):l.error==="not_found"?console.error(`[JexityChat] No active widget config found for ${a}.`):l.error==="rate_limited"?console.error(`[JexityChat] Bootstrap rate-limited for ${a}. Retry after ${l.retryAfterSec??60}s.`):console.error(`[JexityChat] Bootstrap failed: ${l.error}`)}})(),()=>{o=!0}},[t,e,n,r])}const gi={title:"Assistant",statusOnline:"Online · Responds in seconds",inputPlaceholder:"Type a message…",aiThinking:"AI is responding…",sendAriaLabel:"Send message",openChatAriaLabel:"Open chat",closeChatAriaLabel:"Close chat",errorNetwork:"Network error. Please try again.",errorQuota:"Message limit reached. Please try again later.",errorRateLimited:"Too many messages. Try again in {seconds}s.",localeLabelDe:"DE",localeLabelEn:"EN",resumeConversation:"Resume conversation",sessionNotFound:"Your previous session was not found. Starting a new conversation.",startNewConversation:"Start new conversation",chatWith:"Chat with {title}",haveReferenceNumber:"Have a reference number?",referencePlaceholder:"e.g. JEX-A3B7C2",resume:"Resume",howCanWeHelp:"How can we help?",getInstantHelp:"Get instant help",submitTicket:"Submit a ticket",replyByEmail:"We'll reply by email",ticketSubmitted:"Ticket submitted",yourReferenceNumber:"Your reference number:",sentToEmailHint:"We've sent it to your email. Use this number to follow up.",done:"Done",submittingTicket:"Submitting your ticket…",yourName:"Your name",yourEmail:"Your email",submit:"Submit",back:"Go back",escalationFormTitle:"Leave your details",escalationSubtitle:"Our team will get back to you by email so you don’t have to wait here.",escalationNameLabel:"Your name",escalationEmailLabel:"Your email",escalationSubmit:"Send to team",escalationSubmitting:"Sending…",escalationSubmitted:"Request submitted",escalationConsent:"We’ll only use your email to respond to this conversation.",escalationSkip:"Skip, I’ll wait here",escalationPromptTitle:"Talk to our team",escalationPromptSubtitle:"We can notify you by email when our team replies.",escalationPromptSubmit:"Leave details",escalationSubmitFailed:"Failed to submit. Please try again.",sessionNotFoundPrompt:"Session not found. Would you like to start a new conversation?",sessionResolved:"This conversation has been resolved.",tryAgain:"Try again",goBack:"Go back",somethingWentWrong:"Something went wrong",fabLabel:"Chat with us",chatNoLongerAvailable:"This chat is no longer available."},_a={title:"Assistent",statusOnline:"Online · Antwortet in Sekunden",inputPlaceholder:"Nachricht eingeben…",aiThinking:"KI antwortet…",sendAriaLabel:"Nachricht senden",openChatAriaLabel:"Chat öffnen",closeChatAriaLabel:"Chat schließen",errorNetwork:"Netzwerkfehler. Bitte versuche es erneut.",errorQuota:"Nachrichtenlimit erreicht. Bitte versuche es später erneut.",errorRateLimited:"Zu viele Nachrichten. Bitte in {seconds} Sek. erneut versuchen.",localeLabelDe:"DE",localeLabelEn:"EN",resumeConversation:"Gespräch fortsetzen",sessionNotFound:"Ihre vorherige Sitzung wurde nicht gefunden. Ein neues Gespräch wird gestartet.",startNewConversation:"Neues Gespräch beginnen",chatWith:"Chatte mit {title}",haveReferenceNumber:"Hast du eine Referenznummer?",referencePlaceholder:"z.B. JEX-A3B7C2",resume:"Fortsetzen",howCanWeHelp:"Wie können wir helfen?",getInstantHelp:"Soforthilfe erhalten",submitTicket:"Ticket einreichen",replyByEmail:"Wir antworten per E-Mail",ticketSubmitted:"Ticket eingereicht",yourReferenceNumber:"Deine Referenznummer:",sentToEmailHint:"Wir haben sie an deine E-Mail gesendet. Verwende diese Nummer für Rückfragen.",done:"Fertig",submittingTicket:"Dein Ticket wird übermittelt…",yourName:"Dein Name",yourEmail:"Deine E-Mail",submit:"Absenden",back:"Zurück",escalationFormTitle:"Hinterlassen Sie Ihre Daten",escalationSubtitle:"Unser Team meldet sich per E-Mail bei Ihnen — Sie müssen nicht hier warten.",escalationNameLabel:"Ihr Name",escalationEmailLabel:"Ihre E-Mail",escalationSubmit:"An Team senden",escalationSubmitting:"Wird gesendet…",escalationSubmitted:"Anfrage gesendet",escalationConsent:"Wir verwenden Ihre E-Mail nur, um auf diese Unterhaltung zu antworten.",escalationSkip:"Überspringen, ich warte hier",escalationPromptTitle:"Sprechen Sie mit unserem Team",escalationPromptSubtitle:"Wir benachrichtigen Sie per E-Mail, wenn wir antworten.",escalationPromptSubmit:"Daten hinterlassen",escalationSubmitFailed:"Senden fehlgeschlagen. Bitte versuche es erneut.",sessionNotFoundPrompt:"Sitzung nicht gefunden. Möchten Sie ein neues Gespräch beginnen?",sessionResolved:"Diese Unterhaltung wurde abgeschlossen.",tryAgain:"Erneut versuchen",goBack:"Zurück",somethingWentWrong:"Etwas ist schiefgelaufen",fabLabel:"Chatte mit uns",chatNoLongerAvailable:"Dieser Chat ist nicht mehr verfügbar."},wa=[{value:"de",label:"Deutsch",flag:"🇩🇪"},{value:"en",label:"English",flag:"🇬🇧"}],ka="de",Sa="jex-locale",fn=L("de"),ja={en:gi,de:_a};function q(){return ja[fn.value]??gi}function pn(t){if(!t)return null;const e=(t.split("-")[0]??"").toLowerCase();return wa.some(r=>r.value===e)?e:null}function mi(t){const e=pn(t);if(e)return e;try{const n=pn(localStorage.getItem(Sa));if(n)return n}catch{}if(typeof navigator<"u"){const n=pn(navigator.language);if(n)return n}return ka}function Ca(t){M(()=>{function e(n){const r=t??window.location.origin;if(n.origin!==r||n.data?.type!=="jexity:config")return;const{locale:i}=n.data.payload;i&&(fn.value=mi(i))}return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[t])}const gn="jex-session-ref",St="jex-session-active",oe=L(null),ge=L(!1);function Ra(){return"JEX-"+Math.random().toString(36).slice(2,8).toUpperCase()}function Ta(){try{const t=sessionStorage.getItem(gn),e=sessionStorage.getItem(St);oe.value=t??null,ge.value=t!==null&&e==="true"}catch{oe.value=null,ge.value=!1}}function mn(){const t=Ra();oe.value=t,ge.value=!1;try{sessionStorage.setItem(gn,t),sessionStorage.removeItem(St)}catch{}return t}function $a(t){oe.value=t,ge.value=!0;try{sessionStorage.setItem(gn,t),sessionStorage.setItem(St,"true")}catch{}}function Aa(){if(oe.value){ge.value=!0;try{sessionStorage.setItem(St,"true")}catch{}}}function Ia(t){const e={},{primaryColor:n,theme:r}=t;if(n&&(e["--jex-primary"]=n,e["--jex-bg-trigger"]=n,e["--jex-bg-header"]=n,e["--jex-bg-msg-user"]=n,e["--jex-bg-send-btn"]=n),t.accentColor&&(e["--jex-accent"]=t.accentColor),r?.bg){const i=r.bg;i.trigger&&(e["--jex-bg-trigger"]=i.trigger),i.header&&(e["--jex-bg-header"]=i.header),i.msgUser&&(e["--jex-bg-msg-user"]=i.msgUser),i.msgBot&&(e["--jex-bg-msg-bot"]=i.msgBot),i.window&&(e["--jex-bg-window"]=i.window),i.sendBtn&&(e["--jex-bg-send-btn"]=i.sendBtn)}if(r?.text){const i=r.text;i.header&&(e["--jex-text-header"]=i.header),i.msgUser&&(e["--jex-text-msg-user"]=i.msgUser),i.msgBot&&(e["--jex-text-msg-bot"]=i.msgBot),i.main&&(e["--jex-text-main"]=i.main),i.muted&&(e["--jex-text-muted"]=i.muted)}if(r?.border){const i=r.border;i.window&&(e["--jex-border-window"]=i.window),i.input&&(e["--jex-border-input"]=i.input)}return t.fontFamily&&(e["--jex-font-family"]=t.fontFamily),t.fontSize&&(e["--jex-font-size"]=`${t.fontSize}px`),t.borderRadius&&(e["--jex-radius"]=t.borderRadius),t.windowWidth&&(e["--jex-window-width"]=`${t.windowWidth}px`),t.windowHeight&&(e["--jex-window-height"]=`${t.windowHeight}px`),Object.keys(e).length>0?e:void 0}const D=L([{id:"home"}]),Ea=L("screen");function $e(t){D.value=[...D.value,t]}function xn(){D.value.length>1&&(D.value=D.value.slice(0,-1))}function Ae(t){D.value=[...D.value.slice(0,-1),t]}function bn({size:t=24}){return u("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[u("path",{d:"M12 8V4H8"}),u("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),u("path",{d:"M2 14h2"}),u("path",{d:"M20 14h2"}),u("path",{d:"M15 13v2"}),u("path",{d:"M9 13v2"})]})}function xi({title:t}){const e=q(),n=D.value.length>1;return u("header",{class:"jex-chat-header",children:[n&&u("button",{class:"jex-header-back",onClick:xn,"aria-label":e.back||"Go back",children:u("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:u("path",{d:"m15 18-6-6 6-6"})})}),!n&&u(bn,{size:24}),u("div",{class:"jex-header-info",children:[u("h3",{children:t}),u("p",{children:e.statusOnline})]})]})}function Pa({size:t=14}){return u("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:u("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})})}function bi(){return u("div",{class:"jex-widget-footer",children:u("a",{href:"https://jexitychat.de",target:"_blank",rel:"noopener noreferrer",class:"jex-branding",children:[u(Pa,{size:14}),u("span",{children:["Powered by ",u("strong",{children:"Jexity"})]})]})})}function yi({size:t=28}){return u("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:u("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function qa({size:t=28}){return u("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[u("path",{d:"M18 6 6 18"}),u("path",{d:"m6 6 12 12"})]})}function Ma({size:t=24,...e}){return u("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e,children:u("path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"})})}const La={chat:u(yi,{size:28}),bot:u(bn,{size:28}),sparkles:u(Ma,{size:28})},Oa={none:"0px",sm:"0.5rem",md:"0.75rem",lg:"1.25rem",full:"9999px"};function Na({radius:t="full",iconOption:e="chat",label:n}){const r=q(),i=n??r.fabLabel,s=i!=="";return u("button",{class:`jex-floating-button ${!A.value&&s?"jex-has-label":""}`,style:{borderRadius:Oa[t]??"9999px"},onClick:()=>{A.value=!A.value},"aria-label":A.value?r.closeChatAriaLabel:r.openChatAriaLabel,children:A.value?u(qa,{size:28}):u("div",{class:"jex-fab-inner",children:[La[e],s&&u("span",{class:"jex-fab-label",children:i})]})})}function za({title:t}){const e=q(),n=oe.value,[r,i]=T("");function s(){mn(),$e({id:"chat"})}function o(){$e({id:"chat"})}function l(a){a.preventDefault();const h=r.trim().toUpperCase();h&&($a(h),$e({id:"chat"}))}return u("div",{class:"jex-home",children:[u("div",{class:"jex-home-hero",children:[u("div",{class:"jex-home-avatar",children:[u(yi,{size:24}),u("span",{class:"jex-home-status-dot"})]}),u("div",{class:"jex-home-hero-text",children:[u("h2",{class:"jex-home-title",children:t}),u("span",{class:"jex-home-status",children:e.statusOnline})]})]}),u("form",{class:"jex-home-lookup",onSubmit:l,children:[u("input",{class:"jex-home-lookup-input",type:"text",placeholder:e.referencePlaceholder,value:r,onInput:a=>{i(a.currentTarget.value)}}),u("button",{class:"jex-home-lookup-submit",type:"submit",disabled:!r.trim(),children:e.resume})]}),u("div",{class:"jex-home-actions",children:[n&&u("button",{class:"jex-home-resume-card",onClick:o,children:[u("div",{class:"jex-home-resume-top",children:[u("span",{class:"jex-home-resume-label",children:e.resumeConversation}),u("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",class:"jex-home-resume-arrow",children:u("path",{d:"M6 3l5 5-5 5",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})})]}),u("span",{class:"jex-home-resume-ref",children:n})]}),u("button",{class:"jex-home-new-btn",onClick:s,children:n?e.startNewConversation:e.chatWith.replace("{title}",t)})]})]})}function Ba({title:t}){const e=q();return u("div",{class:"jex-selection",children:[u("h2",{class:"jex-selection-title",children:e.howCanWeHelp}),u("div",{class:"jex-selection-options",children:[u("button",{class:"jex-selection-option",onClick:()=>$e({id:"chat"}),children:[u("span",{class:"jex-selection-icon",children:"💬"}),u("span",{class:"jex-selection-label",children:e.chatWith.replace("{title}",t)}),u("span",{class:"jex-selection-sub",children:e.getInstantHelp})]}),u("button",{class:"jex-selection-option",onClick:()=>$e({id:"form"}),children:[u("span",{class:"jex-selection-icon",children:"📝"}),u("span",{class:"jex-selection-label",children:e.submitTicket}),u("span",{class:"jex-selection-sub",children:e.replyByEmail})]})]})]})}function vi(t,e){const n={get(r,i){if(typeof i=="string"){const s=[...e,i];return vi(t,s)}else if(i===Ur){if(e.length<1){const s=[t,...e].join(".");throw new Error(`API path is expected to be of the form \`${t}.childComponent.functionName\`. Found: \`${s}\``)}return"_reference/childComponent/"+e.join("/")}else return}};return new Proxy({},n)}const Qa=()=>vi("components",[]),Ie=uo;Qa();function Fa(t,e){const n=Be(null),r=Xe(!1),i=Xe(!1),s=Xe(!1),o=Xe(null),l=mt(Ie.functions.chat.public.sessions.createOrResume),a=async p=>{const f=kt.value;if(!f)return console.warn("[JexityChat] No bootstrap token — session creation blocked."),null;const g=await l({orgSlug:t,...e?{projSlug:e}:{},visitorId:p,bootstrapToken:f,...wt.value?{source:wt.value}:{}});o.value=g.status;const x={sessionId:g.sessionId,visitorId:p};return n.current=x,{session:x,result:g}},h=Qe(async()=>{if(n.current)return n.current;if(s.value)return null;r.value=!0;const p=oe.value!==null,f=oe.value??mn();try{const g=await a(f);return g?(p&&g.result.isNew&&(i.value=!0,s.value=!0),g.session):null}catch(g){return console.error("[JexityChat] Failed to create session:",g),null}finally{r.value=!1}},[t,e,l,r,i,s]),d=Qe(async()=>{n.current=null,s.value=!1,i.value=!1;const p=mn();r.value=!0;try{return(await a(p))?.session??null}catch(f){return console.error("[JexityChat] Failed to create fresh session:",f),null}finally{r.value=!1}},[t,e,l,r,i,s,o]),c=n.current;return{sessionId:c?.sessionId??null,visitorId:c?.visitorId??null,isLoading:r.value,sessionNotFound:i.value,resumeFailed:s.value,sessionStatus:o.value,isOrgDeleted:o.value==="org_deleted",ensureSession:h,startFresh:d}}const Da=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();const _i=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Ua=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());const wi=t=>{const e=Ua(t);return e.charAt(0).toUpperCase()+e.slice(1)};var Va={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};const Wa=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const Ha=({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,children:i,iconNode:s,class:o="",...l})=>O("svg",{...Va,width:String(e),height:e,stroke:t,"stroke-width":r?Number(n)*24/Number(e):n,class:["lucide",o].join(" "),...!i&&!Wa(l)&&{"aria-hidden":"true"},...l},[...s.map(([a,h])=>O(a,h)),...J(i)]);const Ja=(t,e)=>{const n=({class:r="",className:i="",children:s,...o})=>O(Ha,{...o,iconNode:e,class:Da(`lucide-${_i(wi(t))}`,`lucide-${_i(t)}`,r,i)},s);return n.displayName=wi(t),n};const Ga=Ja("corner-up-left",[["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}],["path",{d:"M9 14 4 9l5-5",key:"102s5s"}]]);function yn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var me=yn();function ki(t){me=t}var xe={exec:()=>null};function b(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(I.caret,"$1"),n=n.replace(i,o),r},getRegex:()=>new RegExp(n,e)};return r}var Ka=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),I={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},Za=/^(?:[ \t]*(?:\n|$))+/,Xa=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ya=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ye=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,el=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,vn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Si=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ji=b(Si).replace(/bull/g,vn).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),tl=b(Si).replace(/bull/g,vn).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),_n=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,nl=/^[^\n]+/,wn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,rl=b(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",wn).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),il=b(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,vn).getRegex(),jt="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",kn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,sl=b("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",kn).replace("tag",jt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ci=b(_n).replace("hr",Ye).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",jt).getRegex(),ol=b(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ci).getRegex(),Sn={blockquote:ol,code:Xa,def:rl,fences:Ya,heading:el,hr:Ye,html:sl,lheading:ji,list:il,newline:Za,paragraph:Ci,table:xe,text:nl},Ri=b("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ye).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",jt).getRegex(),al={...Sn,lheading:tl,table:Ri,paragraph:b(_n).replace("hr",Ye).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ri).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",jt).getRegex()},ll={...Sn,html:b(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",kn).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:xe,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:b(_n).replace("hr",Ye).replace("heading",` *#{1,6} *[^
|
|
1
|
+
(function(){"use strict";var Me,m,qn,Mn,ue,Ln,On,Nn,zn,Et,Pt,qt,Bn,Le={},Qn=[],Vi=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Oe=Array.isArray;function H(t,e){for(var n in e)t[n]=e[n];return t}function Mt(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function O(t,e,n){var r,i,s,o={};for(s in e)s=="key"?r=e[s]:s=="ref"?i=e[s]:o[s]=e[s];if(arguments.length>2&&(o.children=arguments.length>3?Me.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(s in t.defaultProps)o[s]===void 0&&(o[s]=t.defaultProps[s]);return Ne(t,o,r,i,null)}function Ne(t,e,n,r,i){var s={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++qn,__i:-1,__u:0};return i==null&&m.vnode!=null&&m.vnode(s),s}function Wi(){return{current:null}}function N(t){return t.children}function F(t,e){this.props=t,this.context=e}function ye(t,e){if(e==null)return t.__?ye(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"?ye(t):null}function Fn(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Fn(t)}}function Lt(t){(!t.__d&&(t.__d=!0)&&ue.push(t)&&!st.__r++||Ln!=m.debounceRendering)&&((Ln=m.debounceRendering)||On)(st)}function st(){for(var t,e,n,r,i,s,o,l=1;ue.length;)ue.length>l&&ue.sort(Nn),t=ue.shift(),l=ue.length,t.__d&&(n=void 0,r=void 0,i=(r=(e=t).__v).__e,s=[],o=[],e.__P&&((n=H({},r)).__v=r.__v+1,m.vnode&&m.vnode(n),Ot(e.__P,n,r,e.__n,e.__P.namespaceURI,32&r.__u?[i]:null,s,i??ye(r),!!(32&r.__u),o),n.__v=r.__v,n.__.__k[n.__i]=n,Hn(s,n,o),r.__e=r.__=null,n.__e!=i&&Fn(n)));st.__r=0}function Dn(t,e,n,r,i,s,o,l,a,h,d){var c,p,f,g,x,k,_,w=r&&r.__k||Qn,Y=e.length;for(a=Hi(n,e,w,a,Y),c=0;c<Y;c++)(f=n.__k[c])!=null&&(p=f.__i==-1?Le:w[f.__i]||Le,f.__i=c,k=Ot(t,f,p,i,s,o,l,a,h,d),g=f.__e,f.ref&&p.ref!=f.ref&&(p.ref&&zt(p.ref,null,f),d.push(f.ref,f.__c||g,f)),x==null&&g!=null&&(x=g),(_=!!(4&f.__u))||p.__k===f.__k?a=Un(f,a,t,_):typeof f.type=="function"&&k!==void 0?a=k:g&&(a=g.nextSibling),f.__u&=-7);return n.__e=x,a}function Hi(t,e,n,r,i){var s,o,l,a,h,d=n.length,c=d,p=0;for(t.__k=new Array(i),s=0;s<i;s++)(o=e[s])!=null&&typeof o!="boolean"&&typeof o!="function"?(a=s+p,(o=t.__k[s]=typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?Ne(null,o,null,null,null):Oe(o)?Ne(N,{children:o},null,null,null):o.constructor==null&&o.__b>0?Ne(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o).__=t,o.__b=t.__b+1,l=null,(h=o.__i=Ji(o,n,a,c))!=-1&&(c--,(l=n[h])&&(l.__u|=2)),l==null||l.__v==null?(h==-1&&(i>d?p--:i<d&&p++),typeof o.type!="function"&&(o.__u|=4)):h!=a&&(h==a-1?p--:h==a+1?p++:(h>a?p--:p++,o.__u|=4))):t.__k[s]=null;if(c)for(s=0;s<d;s++)(l=n[s])!=null&&(2&l.__u)==0&&(l.__e==r&&(r=ye(l)),Gn(l,l));return r}function Un(t,e,n,r){var i,s;if(typeof t.type=="function"){for(i=t.__k,s=0;i&&s<i.length;s++)i[s]&&(i[s].__=t,e=Un(i[s],e,n,r));return e}t.__e!=e&&(r&&(e&&t.type&&!e.parentNode&&(e=ye(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function J(t,e){return e=e||[],t==null||typeof t=="boolean"||(Oe(t)?t.some(function(n){J(n,e)}):e.push(t)),e}function Ji(t,e,n,r){var i,s,o,l=t.key,a=t.type,h=e[n],d=h!=null&&(2&h.__u)==0;if(h===null&&t.key==null||d&&l==h.key&&a==h.type)return n;if(r>(d?1:0)){for(i=n-1,s=n+1;i>=0||s<e.length;)if((h=e[o=i>=0?i--:s++])!=null&&(2&h.__u)==0&&l==h.key&&a==h.type)return o}return-1}function Vn(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||Vi.test(e)?n:n+"px"}function ot(t,e,n,r,i){var s,o;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||Vn(t.style,e,"");if(n)for(e in n)r&&n[e]==r[e]||Vn(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(zn,"$1")),o=e.toLowerCase(),e=o in t||e=="onFocusOut"||e=="onFocusIn"?o.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+s]=n,n?r?n.u=r.u:(n.u=Et,t.addEventListener(e,s?qt:Pt,s)):t.removeEventListener(e,s?qt:Pt,s);else{if(i=="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 Wn(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=Et++;else if(e.t<n.u)return;return n(m.event?m.event(e):e)}}}function Ot(t,e,n,r,i,s,o,l,a,h){var d,c,p,f,g,x,k,_,w,Y,ee,ce,W,Ui,It,it,In,te=e.type;if(e.constructor!=null)return null;128&n.__u&&(a=!!(32&n.__u),s=[l=e.__e=n.__e]),(d=m.__b)&&d(e);e:if(typeof te=="function")try{if(_=e.props,w="prototype"in te&&te.prototype.render,Y=(d=te.contextType)&&r[d.__c],ee=d?Y?Y.props.value:d.__:r,n.__c?k=(c=e.__c=n.__c).__=c.__E:(w?e.__c=c=new te(_,ee):(e.__c=c=new F(_,ee),c.constructor=te,c.render=Ki),Y&&Y.sub(c),c.props=_,c.state||(c.state={}),c.context=ee,c.__n=r,p=c.__d=!0,c.__h=[],c._sb=[]),w&&c.__s==null&&(c.__s=c.state),w&&te.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=H({},c.__s)),H(c.__s,te.getDerivedStateFromProps(_,c.__s))),f=c.props,g=c.state,c.__v=e,p)w&&te.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),w&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(w&&te.getDerivedStateFromProps==null&&_!==f&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(_,ee),!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(_,c.__s,ee)===!1||e.__v==n.__v){for(e.__v!=n.__v&&(c.props=_,c.state=c.__s,c.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(qe){qe&&(qe.__=e)}),ce=0;ce<c._sb.length;ce++)c.__h.push(c._sb[ce]);c._sb=[],c.__h.length&&o.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(_,c.__s,ee),w&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(f,g,x)})}if(c.context=ee,c.props=_,c.__P=t,c.__e=!1,W=m.__r,Ui=0,w){for(c.state=c.__s,c.__d=!1,W&&W(e),d=c.render(c.props,c.state,c.context),It=0;It<c._sb.length;It++)c.__h.push(c._sb[It]);c._sb=[]}else do c.__d=!1,W&&W(e),d=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++Ui<25);c.state=c.__s,c.getChildContext!=null&&(r=H(H({},r),c.getChildContext())),w&&!p&&c.getSnapshotBeforeUpdate!=null&&(x=c.getSnapshotBeforeUpdate(f,g)),it=d,d!=null&&d.type===N&&d.key==null&&(it=Jn(d.props.children)),l=Dn(t,Oe(it)?it:[it],e,n,r,i,s,o,l,a,h),c.base=e.__e,e.__u&=-161,c.__h.length&&o.push(c),k&&(c.__E=c.__=null)}catch(qe){if(e.__v=null,a||s!=null)if(qe.then){for(e.__u|=a?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;s[s.indexOf(l)]=null,e.__e=l}else{for(In=s.length;In--;)Mt(s[In]);Nt(e)}else e.__e=n.__e,e.__k=n.__k,qe.then||Nt(e);m.__e(qe,e,n)}else s==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):l=e.__e=Gi(n.__e,e,n,r,i,s,o,a,h);return(d=m.diffed)&&d(e),128&e.__u?void 0:l}function Nt(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(Nt)}function Hn(t,e,n){for(var r=0;r<n.length;r++)zt(n[r],n[++r],n[++r]);m.__c&&m.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(s){s.call(i)})}catch(s){m.__e(s,i.__v)}})}function Jn(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:Oe(t)?t.map(Jn):H({},t)}function Gi(t,e,n,r,i,s,o,l,a){var h,d,c,p,f,g,x,k=n.props,_=e.props,w=e.type;if(w=="svg"?i="http://www.w3.org/2000/svg":w=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(h=0;h<s.length;h++)if((f=s[h])&&"setAttribute"in f==!!w&&(w?f.localName==w:f.nodeType==3)){t=f,s[h]=null;break}}if(t==null){if(w==null)return document.createTextNode(_);t=document.createElementNS(i,w,_.is&&_),l&&(m.__m&&m.__m(e,s),l=!1),s=null}if(w==null)k===_||l&&t.data==_||(t.data=_);else{if(s=s&&Me.call(t.childNodes),k=n.props||Le,!l&&s!=null)for(k={},h=0;h<t.attributes.length;h++)k[(f=t.attributes[h]).name]=f.value;for(h in k)if(f=k[h],h!="children"){if(h=="dangerouslySetInnerHTML")c=f;else if(!(h in _)){if(h=="value"&&"defaultValue"in _||h=="checked"&&"defaultChecked"in _)continue;ot(t,h,null,f,i)}}for(h in _)f=_[h],h=="children"?p=f:h=="dangerouslySetInnerHTML"?d=f:h=="value"?g=f:h=="checked"?x=f:l&&typeof f!="function"||k[h]===f||ot(t,h,f,k[h],i);if(d)l||c&&(d.__html==c.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(c&&(t.innerHTML=""),Dn(e.type=="template"?t.content:t,Oe(p)?p:[p],e,n,r,w=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,o,s?s[0]:n.__k&&ye(n,0),l,a),s!=null)for(h=s.length;h--;)Mt(s[h]);l||(h="value",w=="progress"&&g==null?t.removeAttribute("value"):g!=null&&(g!==t[h]||w=="progress"&&!g||w=="option"&&g!=k[h])&&ot(t,h,g,k[h],i),h="checked",x!=null&&x!=t[h]&&ot(t,h,x,k[h],i))}return t}function zt(t,e,n){try{if(typeof t=="function"){var r=typeof t.__u=="function";r&&t.__u(),r&&e==null||(t.__u=t(e))}else t.current=e}catch(i){m.__e(i,n)}}function Gn(t,e,n){var r,i;if(m.unmount&&m.unmount(t),(r=t.ref)&&(r.current&&r.current!=t.__e||zt(r,null,e)),(r=t.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(s){m.__e(s,e)}r.base=r.__P=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&Gn(r[i],e,n||typeof t.type!="function");n||Mt(t.__e),t.__c=t.__=t.__e=void 0}function Ki(t,e,n){return this.constructor(t,n)}function he(t,e,n){var r,i,s,o;e==document&&(e=document.documentElement),m.__&&m.__(t,e),i=(r=typeof n=="function")?null:n&&n.__k||e.__k,s=[],o=[],Ot(e,t=(!r&&n||e).__k=O(N,null,[t]),i||Le,Le,e.namespaceURI,!r&&n?[n]:i?null:e.firstChild?Me.call(e.childNodes):null,s,!r&&n?n:i?i.__e:e.firstChild,r,o),Hn(s,t,o)}function Kn(t,e){he(t,e,Kn)}function Zi(t,e,n){var r,i,s,o,l=H({},t.props);for(s in t.type&&t.type.defaultProps&&(o=t.type.defaultProps),e)s=="key"?r=e[s]:s=="ref"?i=e[s]:l[s]=e[s]===void 0&&o!=null?o[s]:e[s];return arguments.length>2&&(l.children=arguments.length>3?Me.call(arguments,2):n),Ne(t.type,l,r||t.key,i||t.ref,null)}function Xi(t){function e(n){var r,i;return this.getChildContext||(r=new Set,(i={})[e.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(s){this.props.value!=s.value&&r.forEach(function(o){o.__e=!0,Lt(o)})},this.sub=function(s){r.add(s);var o=s.componentWillUnmount;s.componentWillUnmount=function(){r&&r.delete(s),o&&o.call(s)}}),n.children}return e.__c="__cC"+Bn++,e.__=t,e.Provider=e.__l=(e.Consumer=function(n,r){return n.children(r)}).contextType=e,e}Me=Qn.slice,m={__e:function(t,e,n,r){for(var i,s,o;e=e.__;)if((i=e.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(t)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,r||{}),o=i.__d),o)return i.__E=i}catch(l){t=l}throw t}},qn=0,Mn=function(t){return t!=null&&t.constructor==null},F.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=H({},this.state),typeof t=="function"&&(t=t(H({},n),this.props)),t&&H(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),Lt(this))},F.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Lt(this))},F.prototype.render=N,ue=[],On=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Nn=function(t,e){return t.__v.__b-e.__v.__b},st.__r=0,zn=/(PointerCapture)$|Capture$/i,Et=0,Pt=Wn(!1),qt=Wn(!0),Bn=0;var Yi=0;function u(t,e,n,r,i,s){e||(e={});var o,l,a=e;if("ref"in a)for(l in a={},e)l=="ref"?o=e[l]:a[l]=e[l];var h={type:t,props:a,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Yi,__i:-1,__u:0,__source:i,__self:s};if(typeof t=="function"&&(o=t.defaultProps))for(l in o)a[l]===void 0&&(a[l]=o[l]);return m.vnode&&m.vnode(h),h}var ie,S,Bt,Zn,ve=0,Xn=[],j=m,Yn=j.__b,er=j.__r,tr=j.diffed,nr=j.__c,rr=j.unmount,ir=j.__;function _e(t,e){j.__h&&j.__h(S,t,ve||e),ve=0;var n=S.__H||(S.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function T(t){return ve=1,Qt(cr,t)}function Qt(t,e,n){var r=_e(ie++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):cr(void 0,e),function(l){var a=r.__N?r.__N[0]:r.__[0],h=r.t(a,l);a!==h&&(r.__N=[h,r.__[1]],r.__c.setState({}))}],r.__c=S,!S.__f)){var i=function(l,a,h){if(!r.__c.__H)return!0;var d=r.__c.__H.__.filter(function(p){return!!p.__c});if(d.every(function(p){return!p.__N}))return!s||s.call(this,l,a,h);var c=r.__c.props!==l;return d.forEach(function(p){if(p.__N){var f=p.__[0];p.__=p.__N,p.__N=void 0,f!==p.__[0]&&(c=!0)}}),s&&s.call(this,l,a,h)||c};S.__f=!0;var s=S.shouldComponentUpdate,o=S.componentWillUpdate;S.componentWillUpdate=function(l,a,h){if(this.__e){var d=s;s=void 0,i(l,a,h),s=d}o&&o.call(this,l,a,h)},S.shouldComponentUpdate=i}return r.__N||r.__}function M(t,e){var n=_e(ie++,3);!j.__s&&Dt(n.__H,e)&&(n.__=t,n.u=e,S.__H.__h.push(n))}function ze(t,e){var n=_e(ie++,4);!j.__s&&Dt(n.__H,e)&&(n.__=t,n.u=e,S.__h.push(n))}function Be(t){return ve=5,z(function(){return{current:t}},[])}function sr(t,e,n){ve=6,ze(function(){if(typeof t=="function"){var r=t(e());return function(){t(null),r&&typeof r=="function"&&r()}}if(t)return t.current=e(),function(){return t.current=null}},n==null?n:n.concat(t))}function z(t,e){var n=_e(ie++,7);return Dt(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function Qe(t,e){return ve=8,z(function(){return t},e)}function at(t){var e=S.context[t.__c],n=_e(ie++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(S)),e.props.value):t.__}function or(t,e){j.useDebugValue&&j.useDebugValue(e?e(t):t)}function ar(){var t=_e(ie++,11);if(!t.__){for(var e=S.__v;e!==null&&!e.__m&&e.__!==null;)e=e.__;var n=e.__m||(e.__m=[0,0]);t.__="P"+n[0]+"-"+n[1]++}return t.__}function es(){for(var t;t=Xn.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(lt),t.__H.__h.forEach(Ft),t.__H.__h=[]}catch(e){t.__H.__h=[],j.__e(e,t.__v)}}j.__b=function(t){S=null,Yn&&Yn(t)},j.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),ir&&ir(t,e)},j.__r=function(t){er&&er(t),ie=0;var e=(S=t.__c).__H;e&&(Bt===S?(e.__h=[],S.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(lt),e.__h.forEach(Ft),e.__h=[],ie=0)),Bt=S},j.diffed=function(t){tr&&tr(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Xn.push(e)!==1&&Zn===j.requestAnimationFrame||((Zn=j.requestAnimationFrame)||ts)(es)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Bt=S=null},j.__c=function(t,e){e.some(function(n){try{n.__h.forEach(lt),n.__h=n.__h.filter(function(r){return!r.__||Ft(r)})}catch(r){e.some(function(i){i.__h&&(i.__h=[])}),e=[],j.__e(r,n.__v)}}),nr&&nr(t,e)},j.unmount=function(t){rr&&rr(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{lt(r)}catch(i){e=i}}),n.__H=void 0,e&&j.__e(e,n.__v))};var lr=typeof requestAnimationFrame=="function";function ts(t){var e,n=function(){clearTimeout(r),lr&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,35);lr&&(e=requestAnimationFrame(n))}function lt(t){var e=S,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),S=e}function Ft(t){var e=S;t.__c=t.__(),S=e}function Dt(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function cr(t,e){return typeof e=="function"?e(t):e}function ur(t,e){for(var n in e)t[n]=e[n];return t}function Ut(t,e){for(var n in t)if(n!=="__source"&&!(n in e))return!0;for(var r in e)if(r!=="__source"&&t[r]!==e[r])return!0;return!1}function hr(t,e){var n=e(),r=T({t:{__:n,u:e}}),i=r[0].t,s=r[1];return ze(function(){i.__=n,i.u=e,Vt(i)&&s({t:i})},[t,n,e]),M(function(){return Vt(i)&&s({t:i}),t(function(){Vt(i)&&s({t:i})})},[t]),n}function Vt(t){var e,n,r=t.u,i=t.__;try{var s=r();return!((e=i)===(n=s)&&(e!==0||1/e==1/n)||e!=e&&n!=n)}catch{return!0}}function dr(t){t()}function fr(t){return t}function pr(){return[!1,dr]}var gr=ze;function Wt(t,e){this.props=t,this.context=e}function ns(t,e){function n(i){var s=this.props.ref,o=s==i.ref;return!o&&s&&(s.call?s(null):s.current=null),e?!e(this.props,i)||!o:Ut(this.props,i)}function r(i){return this.shouldComponentUpdate=n,O(t,i)}return r.displayName="Memo("+(t.displayName||t.name)+")",r.prototype.isReactComponent=!0,r.__f=!0,r.type=t,r}(Wt.prototype=new F).isPureReactComponent=!0,Wt.prototype.shouldComponentUpdate=function(t,e){return Ut(this.props,t)||Ut(this.state,e)};var mr=m.__b;m.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),mr&&mr(t)};var rs=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function is(t){function e(n){var r=ur({},n);return delete r.ref,t(r,n.ref||null)}return e.$$typeof=rs,e.render=t,e.prototype.isReactComponent=e.__f=!0,e.displayName="ForwardRef("+(t.displayName||t.name)+")",e}var xr=function(t,e){return t==null?null:J(J(t).map(e))},ss={map:xr,forEach:xr,count:function(t){return t?J(t).length:0},only:function(t){var e=J(t);if(e.length!==1)throw"Children.only";return e[0]},toArray:J},os=m.__e;m.__e=function(t,e,n,r){if(t.then){for(var i,s=e;s=s.__;)if((i=s.__c)&&i.__c)return e.__e==null&&(e.__e=n.__e,e.__k=n.__k),i.__c(t,e)}os(t,e,n,r)};var br=m.unmount;function yr(t,e,n){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(r){typeof r.__c=="function"&&r.__c()}),t.__c.__H=null),(t=ur({},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(r){return yr(r,e,n)})),t}function vr(t,e,n){return t&&n&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(r){return vr(r,e,n)}),t.__c&&t.__c.__P===e&&(t.__e&&n.appendChild(t.__e),t.__c.__e=!0,t.__c.__P=n)),t}function ct(){this.__u=0,this.o=null,this.__b=null}function _r(t){var e=t.__.__c;return e&&e.__a&&e.__a(t)}function as(t){var e,n,r;function i(s){if(e||(e=t()).then(function(o){n=o.default||o},function(o){r=o}),r)throw r;if(!n)throw e;return O(n,s)}return i.displayName="Lazy",i.__f=!0,i}function Fe(){this.i=null,this.l=null}m.unmount=function(t){var e=t.__c;e&&e.__R&&e.__R(),e&&32&t.__u&&(t.type=null),br&&br(t)},(ct.prototype=new F).__c=function(t,e){var n=e.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=_r(r.__v),s=!1,o=function(){s||(s=!0,n.__R=null,i?i(l):l())};n.__R=o;var l=function(){if(!--r.__u){if(r.state.__a){var a=r.state.__a;r.__v.__k[0]=vr(a,a.__c.__P,a.__c.__O)}var h;for(r.setState({__a:r.__b=null});h=r.o.pop();)h.forceUpdate()}};r.__u++||32&e.__u||r.setState({__a:r.__b=r.__v.__k[0]}),t.then(o,o)},ct.prototype.componentWillUnmount=function(){this.o=[]},ct.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=yr(this.__b,n,r.__O=r.__P)}this.__b=null}var i=e.__a&&O(N,null,t.fallback);return i&&(i.__u&=-33),[O(N,null,e.__a?null:t.children),i]};var wr=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]}};function ls(t){return this.getChildContext=function(){return t.context},t.children}function cs(t){var e=this,n=t.h;if(e.componentWillUnmount=function(){he(null,e.v),e.v=null,e.h=null},e.h&&e.h!==n&&e.componentWillUnmount(),!e.v){for(var r=e.__v;r!==null&&!r.__m&&r.__!==null;)r=r.__;e.h=n,e.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:r.__m},contains:function(){return!0},insertBefore:function(i,s){this.childNodes.push(i),e.h.insertBefore(i,s)},removeChild:function(i){this.childNodes.splice(this.childNodes.indexOf(i)>>>1,1),e.h.removeChild(i)}}}he(O(ls,{context:e.context},t.__v),e.v)}function us(t,e){var n=O(cs,{__v:t,h:e});return n.containerInfo=e,n}(Fe.prototype=new F).__a=function(t){var e=this,n=_r(e.__v),r=e.l.get(t);return r[0]++,function(i){var s=function(){e.props.revealOrder?(r.push(i),wr(e,t,r)):i()};n?n(s):s()}},Fe.prototype.render=function(t){this.i=null,this.l=new Map;var e=J(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){wr(t,n,e)})};var kr=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,hs=/^(?: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]/,ds=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,fs=/[A-Z0-9]/g,ps=typeof document<"u",gs=function(t){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(t)};function ms(t,e,n){return e.__k==null&&(e.textContent=""),he(t,e),typeof n=="function"&&n(),t?t.__c:null}function xs(t,e,n){return Kn(t,e),typeof n=="function"&&n(),t?t.__c:null}F.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(t){Object.defineProperty(F.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})});var Sr=m.event;function bs(){}function ys(){return this.cancelBubble}function vs(){return this.defaultPrevented}m.event=function(t){return Sr&&(t=Sr(t)),t.persist=bs,t.isPropagationStopped=ys,t.isDefaultPrevented=vs,t.nativeEvent=t};var Ht,_s={enumerable:!1,configurable:!0,get:function(){return this.class}},jr=m.vnode;m.vnode=function(t){typeof t.type=="string"&&(function(e){var n=e.props,r=e.type,i={},s=r.indexOf("-")===-1;for(var o in n){var l=n[o];if(!(o==="value"&&"defaultValue"in n&&l==null||ps&&o==="children"&&r==="noscript"||o==="class"||o==="className")){var a=o.toLowerCase();o==="defaultValue"&&"value"in n&&n.value==null?o="value":o==="download"&&l===!0?l="":a==="translate"&&l==="no"?l=!1:a[0]==="o"&&a[1]==="n"?a==="ondoubleclick"?o="ondblclick":a!=="onchange"||r!=="input"&&r!=="textarea"||gs(n.type)?a==="onfocus"?o="onfocusin":a==="onblur"?o="onfocusout":ds.test(o)&&(o=a):a=o="oninput":s&&hs.test(o)?o=o.replace(fs,"-$&").toLowerCase():l===null&&(l=void 0),a==="oninput"&&i[o=a]&&(o="oninputCapture"),i[o]=l}}r=="select"&&i.multiple&&Array.isArray(i.value)&&(i.value=J(n.children).forEach(function(h){h.props.selected=i.value.indexOf(h.props.value)!=-1})),r=="select"&&i.defaultValue!=null&&(i.value=J(n.children).forEach(function(h){h.props.selected=i.multiple?i.defaultValue.indexOf(h.props.value)!=-1:i.defaultValue==h.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,"className",_s)):(n.className&&!n.class||n.class&&n.className)&&(i.class=i.className=n.className),e.props=i})(t),t.$$typeof=kr,jr&&jr(t)};var Cr=m.__r;m.__r=function(t){Cr&&Cr(t),Ht=t.__c};var Rr=m.diffed;m.diffed=function(t){Rr&&Rr(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),Ht=null};var ws={ReactCurrentDispatcher:{current:{readContext:function(t){return Ht.__n[t.__c].props.value},useCallback:Qe,useContext:at,useDebugValue:or,useDeferredValue:fr,useEffect:M,useId:ar,useImperativeHandle:sr,useInsertionEffect:gr,useLayoutEffect:ze,useMemo:z,useReducer:Qt,useRef:Be,useState:T,useSyncExternalStore:hr,useTransition:pr}}};function ks(t){return O.bind(null,t)}function ut(t){return!!t&&t.$$typeof===kr}function Ss(t){return ut(t)&&t.type===N}function js(t){return!!t&&!!t.displayName&&(typeof t.displayName=="string"||t.displayName instanceof String)&&t.displayName.startsWith("Memo(")}function Cs(t){return ut(t)?Zi.apply(null,arguments):t}function Rs(t){return!!t.__k&&(he(null,t),!0)}function Ts(t){return t&&(t.base||t.nodeType===1&&t)||null}for(var $s=function(t,e){return t(e)},As=function(t,e){return t(e)},Is=N,Es=ut,Jt={useState:T,useId:ar,useReducer:Qt,useEffect:M,useLayoutEffect:ze,useInsertionEffect:gr,useTransition:pr,useDeferredValue:fr,useSyncExternalStore:hr,startTransition:dr,useRef:Be,useImperativeHandle:sr,useMemo:z,useCallback:Qe,useContext:at,useDebugValue:or,version:"18.3.1",Children:ss,render:ms,hydrate:xs,unmountComponentAtNode:Rs,createPortal:us,createElement:O,createContext:Xi,createFactory:ks,cloneElement:Cs,createRef:Wi,Fragment:N,isValidElement:ut,isElement:Es,isFragment:Ss,isMemo:js,findDOMNode:Ts,Component:F,PureComponent:Wt,memo:ns,forwardRef:is,flushSync:As,unstable_batchedUpdates:$s,StrictMode:Is,Suspense:ct,SuspenseList:Fe,lazy:as,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:ws},G=[],B=[],Ps=Uint8Array,Gt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",we=0,qs=Gt.length;we<qs;++we)G[we]=Gt[we],B[Gt.charCodeAt(we)]=we;B[45]=62,B[95]=63;function Ms(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var r=n===e?0:4-n%4;return[n,r]}function Ls(t,e,n){return(e+n)*3/4-n}function De(t){var e,n=Ms(t),r=n[0],i=n[1],s=new Ps(Ls(t,r,i)),o=0,l=i>0?r-4:r,a;for(a=0;a<l;a+=4)e=B[t.charCodeAt(a)]<<18|B[t.charCodeAt(a+1)]<<12|B[t.charCodeAt(a+2)]<<6|B[t.charCodeAt(a+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=B[t.charCodeAt(a)]<<2|B[t.charCodeAt(a+1)]>>4,s[o++]=e&255),i===1&&(e=B[t.charCodeAt(a)]<<10|B[t.charCodeAt(a+1)]<<4|B[t.charCodeAt(a+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function Os(t){return G[t>>18&63]+G[t>>12&63]+G[t>>6&63]+G[t&63]}function Ns(t,e,n){for(var r,i=[],s=e;s<n;s+=3)r=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push(Os(r));return i.join("")}function Ue(t){for(var e,n=t.length,r=n%3,i=[],s=16383,o=0,l=n-r;o<l;o+=s)i.push(Ns(t,o,o+s>l?l:o+s));return r===1?(e=t[n-1],i.push(G[e>>2]+G[e<<4&63]+"==")):r===2&&(e=(t[n-2]<<8)+t[n-1],i.push(G[e>>10]+G[e>>4&63]+G[e<<2&63]+"=")),i.join("")}function ne(t){if(t===void 0)return{};if(!Tr(t))throw new Error(`The arguments to a Convex function must be an object. Received: ${t}`);return t}function zs(t){if(typeof t>"u")throw new Error("Client created with undefined deployment address. If you used an environment variable, check that it's set.");if(typeof t!="string")throw new Error(`Invalid deployment address: found ${t}".`);if(!(t.startsWith("http:")||t.startsWith("https:")))throw new Error(`Invalid deployment address: Must start with "https://" or "http://". Found "${t}".`);try{new URL(t)}catch{throw new Error(`Invalid deployment address: "${t}" is not a valid URL. If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`)}if(t.endsWith(".convex.site"))throw new Error(`Invalid deployment address: "${t}" ends with .convex.site, which is used for HTTP Actions. Convex deployment URLs typically end with .convex.cloud? If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`)}function Tr(t){const e=typeof t=="object",n=Object.getPrototypeOf(t),r=n===null||n===Object.prototype||n?.constructor?.name==="Object";return e&&r}const $r=!0,ke=BigInt("-9223372036854775808"),Kt=BigInt("9223372036854775807"),Zt=BigInt("0"),Bs=BigInt("8"),Qs=BigInt("256");function Ar(t){return Number.isNaN(t)||!Number.isFinite(t)||Object.is(t,-0)}function Fs(t){t<Zt&&(t-=ke+ke);let e=t.toString(16);e.length%2===1&&(e="0"+e);const n=new Uint8Array(new ArrayBuffer(8));let r=0;for(const i of e.match(/.{2}/g).reverse())n.set([parseInt(i,16)],r++),t>>=Bs;return Ue(n)}function Ds(t){const e=De(t);if(e.byteLength!==8)throw new Error(`Received ${e.byteLength} bytes, expected 8 for $integer`);let n=Zt,r=Zt;for(const i of e)n+=BigInt(i)*Qs**r,r++;return n>Kt&&(n+=ke+ke),n}function Us(t){if(t<ke||Kt<t)throw new Error(`BigInt ${t} does not fit into a 64-bit signed integer.`);const e=new ArrayBuffer(8);return new DataView(e).setBigInt64(0,t,!0),Ue(new Uint8Array(e))}function Vs(t){const e=De(t);if(e.byteLength!==8)throw new Error(`Received ${e.byteLength} bytes, expected 8 for $integer`);return new DataView(e.buffer).getBigInt64(0,!0)}const Ws=DataView.prototype.setBigInt64?Us:Fs,Hs=DataView.prototype.getBigInt64?Vs:Ds,Ir=1024;function Er(t){if(t.length>Ir)throw new Error(`Field name ${t} exceeds maximum field name length ${Ir}.`);if(t.startsWith("$"))throw new Error(`Field name ${t} starts with a '$', which is reserved.`);for(let e=0;e<t.length;e+=1){const n=t.charCodeAt(e);if(n<32||n>=127)throw new Error(`Field name ${t} has invalid character '${t[e]}': Field names can only contain non-control ASCII characters`)}}function Se(t){if(t===null||typeof t=="boolean"||typeof t=="number"||typeof t=="string")return t;if(Array.isArray(t))return t.map(r=>Se(r));if(typeof t!="object")throw new Error(`Unexpected type of ${t}`);const e=Object.entries(t);if(e.length===1){const r=e[0][0];if(r==="$bytes"){if(typeof t.$bytes!="string")throw new Error(`Malformed $bytes field on ${t}`);return De(t.$bytes).buffer}if(r==="$integer"){if(typeof t.$integer!="string")throw new Error(`Malformed $integer field on ${t}`);return Hs(t.$integer)}if(r==="$float"){if(typeof t.$float!="string")throw new Error(`Malformed $float field on ${t}`);const i=De(t.$float);if(i.byteLength!==8)throw new Error(`Received ${i.byteLength} bytes, expected 8 for $float`);const o=new DataView(i.buffer).getFloat64(0,$r);if(!Ar(o))throw new Error(`Float ${o} should be encoded as a number`);return o}if(r==="$set")throw new Error("Received a Set which is no longer supported as a Convex type.");if(r==="$map")throw new Error("Received a Map which is no longer supported as a Convex type.")}const n={};for(const[r,i]of Object.entries(t))Er(r),n[r]=Se(i);return n}const Pr=16384;function Ve(t){const e=JSON.stringify(t,(n,r)=>r===void 0?"undefined":typeof r=="bigint"?`${r.toString()}n`:r);if(e.length>Pr){const n="[...truncated]";let r=Pr-n.length;const i=e.codePointAt(r-1);return i!==void 0&&i>65535&&(r-=1),e.substring(0,r)+n}return e}function Xt(t,e,n,r){if(t===void 0){const o=n&&` (present at path ${n} in original object ${Ve(e)})`;throw new Error(`undefined is not a valid Convex value${o}. To learn about Convex's supported types, see https://docs.convex.dev/using/types.`)}if(t===null)return t;if(typeof t=="bigint"){if(t<ke||Kt<t)throw new Error(`BigInt ${t} does not fit into a 64-bit signed integer.`);return{$integer:Ws(t)}}if(typeof t=="number")if(Ar(t)){const o=new ArrayBuffer(8);return new DataView(o).setFloat64(0,t,$r),{$float:Ue(new Uint8Array(o))}}else return t;if(typeof t=="boolean"||typeof t=="string")return t;if(t instanceof ArrayBuffer)return{$bytes:Ue(new Uint8Array(t))};if(Array.isArray(t))return t.map((o,l)=>Xt(o,e,n+`[${l}]`));if(t instanceof Set)throw new Error(Yt(n,"Set",[...t],e));if(t instanceof Map)throw new Error(Yt(n,"Map",[...t],e));if(!Tr(t)){const o=t?.constructor?.name,l=o?`${o} `:"";throw new Error(Yt(n,l,t,e))}const i={},s=Object.entries(t);s.sort(([o,l],[a,h])=>o===a?0:o<a?-1:1);for(const[o,l]of s)l!==void 0&&(Er(o),i[o]=Xt(l,e,n+`.${o}`));return i}function Yt(t,e,n,r){return t?`${e}${Ve(n)} is not a supported Convex type (present at path ${t} in original object ${Ve(r)}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.`:`${e}${Ve(n)} is not a supported Convex type.`}function K(t){return Xt(t,t,"")}var Js=Object.defineProperty,Gs=(t,e,n)=>e in t?Js(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,en=(t,e,n)=>Gs(t,typeof e!="symbol"?e+"":e,n),qr,Mr;const Ks=Symbol.for("ConvexError");class tn extends(Mr=Error,qr=Ks,Mr){constructor(e){super(typeof e=="string"?e:Ve(e)),en(this,"name","ConvexError"),en(this,"data"),en(this,qr,!0),this.data=e}}const Lr=()=>Array.from({length:4},()=>0);Lr(),Lr();const Or="1.38.0";var Zs=Object.defineProperty,Xs=(t,e,n)=>e in t?Zs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Nr=(t,e,n)=>Xs(t,typeof e!="symbol"?e+"":e,n);const Ys="color:rgb(0, 145, 255)";function zr(t){switch(t){case"query":return"Q";case"mutation":return"M";case"action":return"A";case"any":return"?"}}class Br{constructor(e){Nr(this,"_onLogLineFuncs"),Nr(this,"_verbose"),this._onLogLineFuncs={},this._verbose=e.verbose}addLogLineListener(e){let n=Math.random().toString(36).substring(2,15);for(let r=0;r<10&&this._onLogLineFuncs[n]!==void 0;r++)n=Math.random().toString(36).substring(2,15);return this._onLogLineFuncs[n]=e,()=>{delete this._onLogLineFuncs[n]}}logVerbose(...e){if(this._verbose)for(const n of Object.values(this._onLogLineFuncs))n("debug",`${new Date().toISOString()}`,...e)}log(...e){for(const n of Object.values(this._onLogLineFuncs))n("info",...e)}warn(...e){for(const n of Object.values(this._onLogLineFuncs))n("warn",...e)}error(...e){for(const n of Object.values(this._onLogLineFuncs))n("error",...e)}}function Qr(t){const e=new Br(t);return e.addLogLineListener((n,...r)=>{switch(n){case"debug":console.debug(...r);break;case"info":console.log(...r);break;case"warn":console.warn(...r);break;case"error":console.error(...r);break;default:console.log(...r)}}),e}function Fr(t){return new Br(t)}function ht(t,e,n,r,i){const s=zr(n);if(typeof i=="object"&&(i=`ConvexError ${JSON.stringify(i.errorData,null,2)}`),e==="info"){const o=i.match(/^\[.*?\] /);if(o===null){t.error(`[CONVEX ${s}(${r})] Could not parse console.log`);return}const l=i.slice(1,o[0].length-2),a=i.slice(o[0].length);t.log(`%c[CONVEX ${s}(${r})] [${l}]`,Ys,a)}else t.error(`[CONVEX ${s}(${r})] ${i}`)}function eo(t,e){const n=`[CONVEX FATAL ERROR] ${e}`;return t.error(n),new Error(n)}function je(t,e,n){return`[CONVEX ${zr(t)}(${e})] ${n.errorMessage}
|
|
2
|
+
Called by client`}function nn(t,e){return e.data=t.errorData,e}function de(t){const e=t.split(":");let n,r;return e.length===1?(n=e[0],r="default"):(n=e.slice(0,e.length-1).join(":"),r=e[e.length-1]),n.endsWith(".js")&&(n=n.slice(0,-3)),`${n}:${r}`}function fe(t,e){return JSON.stringify({udfPath:de(t),args:K(e)})}function Dr(t,e,n){const{initialNumItems:r,id:i}=n;return JSON.stringify({type:"paginated",udfPath:de(t),args:K(e),options:K({initialNumItems:r,id:i})})}var to=Object.defineProperty,no=(t,e,n)=>e in t?to(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Z=(t,e,n)=>no(t,typeof e!="symbol"?e+"":e,n);class ro{constructor(){Z(this,"nextQueryId"),Z(this,"querySetVersion"),Z(this,"querySet"),Z(this,"queryIdToToken"),Z(this,"identityVersion"),Z(this,"auth"),Z(this,"outstandingQueriesOlderThanRestart"),Z(this,"outstandingAuthOlderThanRestart"),Z(this,"paused"),Z(this,"pendingQuerySetModifications"),this.nextQueryId=0,this.querySetVersion=0,this.identityVersion=0,this.querySet=new Map,this.queryIdToToken=new Map,this.outstandingQueriesOlderThanRestart=new Set,this.outstandingAuthOlderThanRestart=!1,this.paused=!1,this.pendingQuerySetModifications=new Map}hasSyncedPastLastReconnect(){return this.outstandingQueriesOlderThanRestart.size===0&&!this.outstandingAuthOlderThanRestart}markAuthCompletion(){this.outstandingAuthOlderThanRestart=!1}subscribe(e,n,r,i){const s=de(e),o=fe(s,n),l=this.querySet.get(o);if(l!==void 0)return l.numSubscribers+=1,{queryToken:o,modification:null,unsubscribe:()=>this.removeSubscriber(o)};{const a=this.nextQueryId++,h={id:a,canonicalizedUdfPath:s,args:n,numSubscribers:1,journal:r,componentPath:i};this.querySet.set(o,h),this.queryIdToToken.set(a,o);const d=this.querySetVersion,c=this.querySetVersion+1,p={type:"Add",queryId:a,udfPath:s,args:[K(n)],journal:r,componentPath:i};return this.paused?this.pendingQuerySetModifications.set(a,p):this.querySetVersion=c,{queryToken:o,modification:{type:"ModifyQuerySet",baseVersion:d,newVersion:c,modifications:[p]},unsubscribe:()=>this.removeSubscriber(o)}}}transition(e){for(const n of e.modifications)switch(n.type){case"QueryUpdated":case"QueryFailed":{this.outstandingQueriesOlderThanRestart.delete(n.queryId);const r=n.journal;if(r!==void 0){const i=this.queryIdToToken.get(n.queryId);i!==void 0&&(this.querySet.get(i).journal=r)}break}case"QueryRemoved":{this.outstandingQueriesOlderThanRestart.delete(n.queryId);break}default:throw new Error(`Invalid modification ${n.type}`)}}queryId(e,n){const r=de(e),i=fe(r,n),s=this.querySet.get(i);return s!==void 0?s.id:null}isCurrentOrNewerAuthVersion(e){return e>=this.identityVersion}getAuth(){return this.auth}setAuth(e){this.auth={tokenType:"User",value:e};const n=this.identityVersion;return this.paused||(this.identityVersion=n+1),{type:"Authenticate",baseVersion:n,...this.auth}}setAdminAuth(e,n){const r={tokenType:"Admin",value:e,impersonating:n};this.auth=r;const i=this.identityVersion;return this.paused||(this.identityVersion=i+1),{type:"Authenticate",baseVersion:i,...r}}clearAuth(){this.auth=void 0,this.markAuthCompletion();const e=this.identityVersion;return this.paused||(this.identityVersion=e+1),{type:"Authenticate",tokenType:"None",baseVersion:e}}hasAuth(){return!!this.auth}isNewAuth(e){return this.auth?.value!==e}queryPath(e){const n=this.queryIdToToken.get(e);return n?this.querySet.get(n).canonicalizedUdfPath:null}queryArgs(e){const n=this.queryIdToToken.get(e);return n?this.querySet.get(n).args:null}queryToken(e){return this.queryIdToToken.get(e)??null}queryJournal(e){return this.querySet.get(e)?.journal}restart(){this.unpause(),this.outstandingQueriesOlderThanRestart.clear();const e=[];for(const i of this.querySet.values()){const s={type:"Add",queryId:i.id,udfPath:i.canonicalizedUdfPath,args:[K(i.args)],journal:i.journal,componentPath:i.componentPath};e.push(s),this.outstandingQueriesOlderThanRestart.add(i.id)}this.querySetVersion=1;const n={type:"ModifyQuerySet",baseVersion:0,newVersion:1,modifications:e};if(!this.auth)return this.identityVersion=0,[n,void 0];this.outstandingAuthOlderThanRestart=!0;const r={type:"Authenticate",baseVersion:0,...this.auth};return this.identityVersion=1,[n,r]}pause(){this.paused=!0}resume(){const e=this.pendingQuerySetModifications.size>0?{type:"ModifyQuerySet",baseVersion:this.querySetVersion,newVersion:++this.querySetVersion,modifications:Array.from(this.pendingQuerySetModifications.values())}:void 0,n=this.auth!==void 0?{type:"Authenticate",baseVersion:this.identityVersion++,...this.auth}:void 0;return this.unpause(),[e,n]}unpause(){this.paused=!1,this.pendingQuerySetModifications.clear()}removeSubscriber(e){const n=this.querySet.get(e);if(n.numSubscribers>1)return n.numSubscribers-=1,null;{this.querySet.delete(e),this.queryIdToToken.delete(n.id),this.outstandingQueriesOlderThanRestart.delete(n.id);const r=this.querySetVersion,i=this.querySetVersion+1,s={type:"Remove",queryId:n.id};return this.paused?this.pendingQuerySetModifications.has(n.id)?this.pendingQuerySetModifications.delete(n.id):this.pendingQuerySetModifications.set(n.id,s):this.querySetVersion=i,{type:"ModifyQuerySet",baseVersion:r,newVersion:i,modifications:[s]}}}}var io=Object.defineProperty,so=(t,e,n)=>e in t?io(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,dt=(t,e,n)=>so(t,typeof e!="symbol"?e+"":e,n);class oo{constructor(e,n){this.logger=e,this.markConnectionStateDirty=n,dt(this,"inflightRequests"),dt(this,"requestsOlderThanRestart"),dt(this,"inflightMutationsCount",0),dt(this,"inflightActionsCount",0),this.inflightRequests=new Map,this.requestsOlderThanRestart=new Set}request(e,n){const r=new Promise(i=>{const s=n?"Requested":"NotSent";this.inflightRequests.set(e.requestId,{message:e,status:{status:s,requestedAt:new Date,onResult:i}}),e.type==="Mutation"?this.inflightMutationsCount++:e.type==="Action"&&this.inflightActionsCount++});return this.markConnectionStateDirty(),r}onResponse(e){const n=this.inflightRequests.get(e.requestId);if(n===void 0||n.status.status==="Completed")return null;const r=n.message.type==="Mutation"?"mutation":"action",i=n.message.udfPath;for(const a of e.logLines)ht(this.logger,"info",r,i,a);const s=n.status;let o,l;if(e.success)o={success:!0,logLines:e.logLines,value:Se(e.result)},l=()=>s.onResult(o);else{const a=e.result,{errorData:h}=e;ht(this.logger,"error",r,i,a),o={success:!1,errorMessage:a,errorData:h!==void 0?Se(h):void 0,logLines:e.logLines},l=()=>s.onResult(o)}return e.type==="ActionResponse"||!e.success?(l(),this.inflightRequests.delete(e.requestId),this.requestsOlderThanRestart.delete(e.requestId),n.message.type==="Action"?this.inflightActionsCount--:n.message.type==="Mutation"&&this.inflightMutationsCount--,this.markConnectionStateDirty(),{requestId:e.requestId,result:o}):(n.status={status:"Completed",result:o,ts:e.ts,onResolve:l},null)}removeCompleted(e){const n=new Map;for(const[r,i]of this.inflightRequests.entries()){const s=i.status;s.status==="Completed"&&s.ts.lessThanOrEqual(e)&&(s.onResolve(),n.set(r,s.result),i.message.type==="Mutation"?this.inflightMutationsCount--:i.message.type==="Action"&&this.inflightActionsCount--,this.inflightRequests.delete(r),this.requestsOlderThanRestart.delete(r))}return n.size>0&&this.markConnectionStateDirty(),n}restart(){this.requestsOlderThanRestart=new Set(this.inflightRequests.keys());const e=[];for(const[n,r]of this.inflightRequests){if(r.status.status==="NotSent"){r.status.status="Requested",e.push(r.message);continue}if(r.message.type==="Mutation")e.push(r.message);else if(r.message.type==="Action"){if(this.inflightRequests.delete(n),this.requestsOlderThanRestart.delete(n),this.inflightActionsCount--,r.status.status==="Completed")throw new Error("Action should never be in 'Completed' state");r.status.onResult({success:!1,errorMessage:"Connection lost while action was in flight",logLines:[]})}}return this.markConnectionStateDirty(),e}resume(){const e=[];for(const[,n]of this.inflightRequests)if(n.status.status==="NotSent"){n.status.status="Requested",e.push(n.message);continue}return e}hasIncompleteRequests(){for(const e of this.inflightRequests.values())if(e.status.status==="Requested")return!0;return!1}hasInflightRequests(){return this.inflightRequests.size>0}hasSyncedPastLastReconnect(){return this.requestsOlderThanRestart.size===0}timeOfOldestInflightRequest(){if(this.inflightRequests.size===0)return null;let e=Date.now();for(const n of this.inflightRequests.values())n.status.status!=="Completed"&&n.status.requestedAt.getTime()<e&&(e=n.status.requestedAt.getTime());return new Date(e)}inflightMutations(){return this.inflightMutationsCount}inflightActions(){return this.inflightActionsCount}}const We=Symbol.for("functionName"),Ur=Symbol.for("toReferencePath");function ao(t){return t[Ur]??null}function lo(t){return t.startsWith("function://")}function co(t){let e;if(typeof t=="string")lo(t)?e={functionHandle:t}:e={name:t};else if(t[We])e={name:t[We]};else{const n=ao(t);if(!n)throw new Error(`${t} is not a functionReference`);e={reference:n}}return e}function E(t){const e=co(t);if(e.name===void 0)throw e.functionHandle!==void 0?new Error(`Expected function reference like "api.file.func" or "internal.file.func", but received function handle ${e.functionHandle}`):e.reference!==void 0?new Error(`Expected function reference in the current component like "api.file.func" or "internal.file.func", but received reference ${e.reference}`):new Error(`Expected function reference like "api.file.func" or "internal.file.func", but received ${JSON.stringify(e)}`);if(typeof t=="string")return t;const n=t[We];if(!n)throw new Error(`${t} is not a functionReference`);return n}function Vr(t){return{[We]:t}}function Wr(t=[]){const e={get(n,r){if(typeof r=="string"){const i=[...t,r];return Wr(i)}else if(r===We){if(t.length<2){const o=["api",...t].join(".");throw new Error(`API path is expected to be of the form \`api.moduleName.functionName\`. Found: \`${o}\``)}const i=t.slice(0,-1).join("/"),s=t[t.length-1];return s==="default"?i:i+":"+s}else return r===Symbol.toStringTag?"FunctionReference":void 0}};return new Proxy({},e)}const uo=Wr();var ho=Object.defineProperty,fo=(t,e,n)=>e in t?ho(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ft=(t,e,n)=>fo(t,typeof e!="symbol"?e+"":e,n);class He{constructor(e){ft(this,"queryResults"),ft(this,"modifiedQueries"),this.queryResults=e,this.modifiedQueries=[]}getQuery(e,...n){const r=ne(n[0]),i=E(e),s=this.queryResults.get(fe(i,r));if(s!==void 0)return He.queryValue(s.result)}getAllQueries(e){const n=[],r=E(e);for(const i of this.queryResults.values())i.udfPath===de(r)&&n.push({args:i.args,value:He.queryValue(i.result)});return n}setQuery(e,n,r){const i=ne(n),s=E(e),o=fe(s,i);let l;r===void 0?l=void 0:l={success:!0,value:r,logLines:[]};const a={udfPath:s,args:i,result:l};this.queryResults.set(o,a),this.modifiedQueries.push(o)}static queryValue(e){if(e!==void 0)return e.success?e.value:void 0}}class po{constructor(){ft(this,"queryResults"),ft(this,"optimisticUpdates"),this.queryResults=new Map,this.optimisticUpdates=[]}ingestQueryResultsFromServer(e,n){this.optimisticUpdates=this.optimisticUpdates.filter(o=>!n.has(o.mutationId));const r=this.queryResults;this.queryResults=new Map(e);const i=new He(this.queryResults);for(const o of this.optimisticUpdates)o.update(i);const s=[];for(const[o,l]of this.queryResults){const a=r.get(o);(a===void 0||a.result!==l.result)&&s.push(o)}return s}applyOptimisticUpdate(e,n){this.optimisticUpdates.push({update:e,mutationId:n});const r=new He(this.queryResults);return e(r),r.modifiedQueries}rawQueryResult(e){const n=this.queryResults.get(e);if(n!==void 0)return n.result}queryResult(e){const n=this.queryResults.get(e);if(n===void 0)return;const r=n.result;if(r!==void 0){if(r.success)return r.value;throw r.errorData!==void 0?nn(r,new tn(je("query",n.udfPath,r))):new Error(je("query",n.udfPath,r))}}hasQueryResult(e){return this.queryResults.get(e)!==void 0}queryLogs(e){return this.queryResults.get(e)?.result?.logLines}}var go=Object.defineProperty,mo=(t,e,n)=>e in t?go(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,rn=(t,e,n)=>mo(t,typeof e!="symbol"?e+"":e,n);class P{constructor(e,n){rn(this,"low"),rn(this,"high"),rn(this,"__isUnsignedLong__"),this.low=e|0,this.high=n|0,this.__isUnsignedLong__=!0}static isLong(e){return(e&&e.__isUnsignedLong__)===!0}static fromBytesLE(e){return new P(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24)}toBytesLE(){const e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]}static fromNumber(e){return isNaN(e)||e<0?Hr:e>=xo?bo:new P(e%Je|0,e/Je|0)}toString(){return(BigInt(this.high)*BigInt(Je)+BigInt(this.low)).toString()}equals(e){return P.isLong(e)||(e=P.fromValue(e)),this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low}notEquals(e){return!this.equals(e)}comp(e){return P.isLong(e)||(e=P.fromValue(e)),this.equals(e)?0:e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1}lessThanOrEqual(e){return this.comp(e)<=0}static fromValue(e){return typeof e=="number"?P.fromNumber(e):new P(e.low,e.high)}}const Hr=new P(0,0),Jr=65536,Je=Jr*Jr,xo=Je*Je,bo=new P(-1,-1);var yo=Object.defineProperty,vo=(t,e,n)=>e in t?yo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,pt=(t,e,n)=>vo(t,typeof e!="symbol"?e+"":e,n);class Gr{constructor(e,n){pt(this,"version"),pt(this,"remoteQuerySet"),pt(this,"queryPath"),pt(this,"logger"),this.version={querySet:0,ts:P.fromNumber(0),identity:0},this.remoteQuerySet=new Map,this.queryPath=e,this.logger=n}transition(e){const n=e.startVersion;if(this.version.querySet!==n.querySet||this.version.ts.notEquals(n.ts)||this.version.identity!==n.identity)throw new Error(`Invalid start version: ${n.ts.toString()}:${n.querySet}:${n.identity}, transitioning from ${this.version.ts.toString()}:${this.version.querySet}:${this.version.identity}`);for(const r of e.modifications)switch(r.type){case"QueryUpdated":{const i=this.queryPath(r.queryId);if(i)for(const o of r.logLines)ht(this.logger,"info","query",i,o);const s=Se(r.value??null);this.remoteQuerySet.set(r.queryId,{success:!0,value:s,logLines:r.logLines});break}case"QueryFailed":{const i=this.queryPath(r.queryId);if(i)for(const o of r.logLines)ht(this.logger,"info","query",i,o);const{errorData:s}=r;this.remoteQuerySet.set(r.queryId,{success:!1,errorMessage:r.errorMessage,errorData:s!==void 0?Se(s):void 0,logLines:r.logLines});break}case"QueryRemoved":{this.remoteQuerySet.delete(r.queryId);break}default:throw new Error(`Invalid modification ${r.type}`)}this.version=e.endVersion}remoteQueryResults(){return this.remoteQuerySet}timestamp(){return this.version.ts}}function sn(t){const e=De(t);return P.fromBytesLE(Array.from(e))}function _o(t){const e=new Uint8Array(t.toBytesLE());return Ue(e)}function Kr(t){switch(t.type){case"FatalError":case"AuthError":case"ActionResponse":case"TransitionChunk":case"Ping":return{...t};case"MutationResponse":return t.success?{...t,ts:sn(t.ts)}:{...t};case"Transition":return{...t,startVersion:{...t.startVersion,ts:sn(t.startVersion.ts)},endVersion:{...t.endVersion,ts:sn(t.endVersion.ts)}}}}function wo(t){switch(t.type){case"Authenticate":case"ModifyQuerySet":case"Mutation":case"Action":case"Event":return{...t};case"Connect":return t.maxObservedTimestamp!==void 0?{...t,maxObservedTimestamp:_o(t.maxObservedTimestamp)}:{...t,maxObservedTimestamp:void 0}}}var ko=Object.defineProperty,So=(t,e,n)=>e in t?ko(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,C=(t,e,n)=>So(t,typeof e!="symbol"?e+"":e,n);const jo=1e3,Co=1001,Ro=1005,To=4040;let gt;function Ce(){return gt===void 0&&(gt=Date.now()),typeof performance>"u"||!performance.now?Date.now():Math.round(gt+performance.now())}function Zr(){return`t=${Math.round((Ce()-gt)/100)/10}s`}const Xr={InternalServerError:{timeout:1e3},SubscriptionsWorkerFullError:{timeout:3e3},TooManyConcurrentRequests:{timeout:3e3},CommitterFullError:{timeout:3e3},AwsTooManyRequestsException:{timeout:3e3},ExecuteFullError:{timeout:3e3},SystemTimeoutError:{timeout:3e3},ExpiredInQueue:{timeout:3e3},VectorIndexesUnavailable:{timeout:1e3},SearchIndexesUnavailable:{timeout:1e3},TableSummariesUnavailable:{timeout:1e3},VectorIndexTooLarge:{timeout:3e3},SearchIndexTooLarge:{timeout:3e3},TooManyWritesInTimePeriod:{timeout:3e3}};function $o(t){if(t===void 0)return"Unknown";for(const e of Object.keys(Xr))if(t.startsWith(e))return e;return"Unknown"}class Ao{constructor(e,n,r,i,s,o){this.markConnectionStateDirty=s,this.debug=o,C(this,"socket"),C(this,"connectionCount"),C(this,"_hasEverConnected",!1),C(this,"lastCloseReason"),C(this,"transitionChunkBuffer",null),C(this,"defaultInitialBackoff"),C(this,"maxBackoff"),C(this,"retries"),C(this,"serverInactivityThreshold"),C(this,"reconnectDueToServerInactivityTimeout"),C(this,"scheduledReconnect",null),C(this,"networkOnlineHandler",null),C(this,"pendingNetworkRecoveryInfo",null),C(this,"uri"),C(this,"onOpen"),C(this,"onResume"),C(this,"onMessage"),C(this,"webSocketConstructor"),C(this,"logger"),C(this,"onServerDisconnectError"),this.webSocketConstructor=r,this.socket={state:"disconnected"},this.connectionCount=0,this.lastCloseReason="InitialConnect",this.defaultInitialBackoff=1e3,this.maxBackoff=16e3,this.retries=0,this.serverInactivityThreshold=6e4,this.reconnectDueToServerInactivityTimeout=null,this.uri=e,this.onOpen=n.onOpen,this.onResume=n.onResume,this.onMessage=n.onMessage,this.onServerDisconnectError=n.onServerDisconnectError,this.logger=i,this.setupNetworkListener(),this.connect()}setSocketState(e){this.socket=e,this._logVerbose(`socket state changed: ${this.socket.state}, paused: ${"paused"in this.socket?this.socket.paused:void 0}`),this.markConnectionStateDirty()}setupNetworkListener(){typeof window>"u"||typeof window.addEventListener!="function"||this.networkOnlineHandler===null&&(this.networkOnlineHandler=()=>{this._logVerbose("network online event detected"),this.tryReconnectImmediately()},window.addEventListener("online",this.networkOnlineHandler),this._logVerbose("network online event listener registered"))}cleanupNetworkListener(){this.networkOnlineHandler&&typeof window<"u"&&typeof window.removeEventListener=="function"&&(window.removeEventListener("online",this.networkOnlineHandler),this.networkOnlineHandler=null,this._logVerbose("network online event listener removed"))}assembleTransition(e){if(e.partNumber<0||e.partNumber>=e.totalParts||e.totalParts===0||this.transitionChunkBuffer&&(this.transitionChunkBuffer.totalParts!==e.totalParts||this.transitionChunkBuffer.transitionId!==e.transitionId))throw this.transitionChunkBuffer=null,new Error("Invalid TransitionChunk");if(this.transitionChunkBuffer===null&&(this.transitionChunkBuffer={chunks:[],totalParts:e.totalParts,transitionId:e.transitionId}),e.partNumber!==this.transitionChunkBuffer.chunks.length){const n=this.transitionChunkBuffer.chunks.length;throw this.transitionChunkBuffer=null,new Error(`TransitionChunk received out of order: expected part ${n}, got ${e.partNumber}`)}if(this.transitionChunkBuffer.chunks.push(e.chunk),this.transitionChunkBuffer.chunks.length===e.totalParts){const n=this.transitionChunkBuffer.chunks.join("");this.transitionChunkBuffer=null;const r=Kr(JSON.parse(n));if(r.type!=="Transition")throw new Error(`Expected Transition, got ${r.type} after assembling chunks`);return r}return null}connect(){if(this.socket.state==="terminated")return;if(this.socket.state!=="disconnected"&&this.socket.state!=="stopped")throw new Error("Didn't start connection from disconnected state: "+this.socket.state);const e=new this.webSocketConstructor(this.uri);this._logVerbose("constructed WebSocket"),this.setSocketState({state:"connecting",ws:e,paused:"no"}),this.resetServerInactivityTimeout(),e.onopen=()=>{if(this.logger.logVerbose("begin ws.onopen"),this.socket.state!=="connecting")throw new Error("onopen called with socket not in connecting state");if(this.setSocketState({state:"ready",ws:e,paused:this.socket.paused==="yes"?"uninitialized":"no"}),this.resetServerInactivityTimeout(),this.socket.paused==="no"&&(this._hasEverConnected=!0,this.onOpen({connectionCount:this.connectionCount,lastCloseReason:this.lastCloseReason,clientTs:Ce()})),this.lastCloseReason!=="InitialConnect"&&(this.lastCloseReason?this.logger.log("WebSocket reconnected at",Zr(),"after disconnect due to",this.lastCloseReason):this.logger.log("WebSocket reconnected at",Zr())),this.connectionCount+=1,this.lastCloseReason=null,this.pendingNetworkRecoveryInfo!==null){const{timeSavedMs:n}=this.pendingNetworkRecoveryInfo;this.pendingNetworkRecoveryInfo=null,this.sendMessage({type:"Event",eventType:"NetworkRecoveryReconnect",event:{timeSavedMs:n}}),this.logger.log(`Network recovery reconnect saved ~${Math.round(n/1e3)}s of waiting`)}},e.onerror=n=>{this.transitionChunkBuffer=null;const r=n.message;r&&this.logger.log(`WebSocket error message: ${r}`)},e.onmessage=n=>{this.resetServerInactivityTimeout();const r=n.data.length;let i=Kr(JSON.parse(n.data));if(this._logVerbose(`received ws message with type ${i.type}`),i.type==="Ping")return;if(i.type==="TransitionChunk"){const o=this.assembleTransition(i);if(!o)return;i=o,this._logVerbose(`assembled full ws message of type ${i.type}`)}this.transitionChunkBuffer!==null&&(this.transitionChunkBuffer=null,this.logger.log(`Received unexpected ${i.type} while buffering TransitionChunks`)),i.type==="Transition"&&this.reportLargeTransition({messageLength:r,transition:i}),this.onMessage(i).hasSyncedPastLastReconnect&&(this.retries=0,this.markConnectionStateDirty())},e.onclose=n=>{if(this._logVerbose("begin ws.onclose"),this.transitionChunkBuffer=null,this.lastCloseReason===null&&(this.lastCloseReason=n.reason||`closed with code ${n.code}`),n.code!==jo&&n.code!==Co&&n.code!==Ro&&n.code!==To){let i=`WebSocket closed with code ${n.code}`;n.reason&&(i+=`: ${n.reason}`),this.logger.log(i),this.onServerDisconnectError&&n.reason&&this.onServerDisconnectError(i)}const r=$o(n.reason);this.scheduleReconnect(r)}}socketState(){return this.socket.state}sendMessage(e){const n={type:e.type,...e.type==="Authenticate"&&e.tokenType==="User"?{value:`...${e.value.slice(-7)}`}:{}};if(this.socket.state==="ready"&&this.socket.paused==="no"){const r=wo(e),i=JSON.stringify(r);let s=!1;try{this.socket.ws.send(i),s=!0}catch(o){this.logger.log(`Failed to send message on WebSocket, reconnecting: ${o}`),this.closeAndReconnect("FailedToSendMessage")}return this._logVerbose(`${s?"sent":"failed to send"} message with type ${e.type}: ${JSON.stringify(n)}`),!0}return this._logVerbose(`message not sent (socket state: ${this.socket.state}, paused: ${"paused"in this.socket?this.socket.paused:void 0}): ${JSON.stringify(n)}`),!1}resetServerInactivityTimeout(){this.socket.state!=="terminated"&&(this.reconnectDueToServerInactivityTimeout!==null&&(clearTimeout(this.reconnectDueToServerInactivityTimeout),this.reconnectDueToServerInactivityTimeout=null),this.reconnectDueToServerInactivityTimeout=setTimeout(()=>{this.closeAndReconnect("InactiveServer")},this.serverInactivityThreshold))}scheduleReconnect(e){this.scheduledReconnect&&(clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null),this.socket={state:"disconnected"};const n=this.nextBackoff(e);this.markConnectionStateDirty(),this.logger.log(`Attempting reconnect in ${Math.round(n)}ms`);const r=Ce(),i=setTimeout(()=>{this.scheduledReconnect?.timeout===i&&(this.scheduledReconnect=null,this.connect())},n);this.scheduledReconnect={timeout:i,scheduledAt:r,backoffMs:n}}closeAndReconnect(e){switch(this._logVerbose(`begin closeAndReconnect with reason ${e}`),this.socket.state){case"disconnected":case"terminated":case"stopped":return;case"connecting":case"ready":{this.lastCloseReason=e,this.close(),this.scheduleReconnect("client");return}default:this.socket}}close(){switch(this.transitionChunkBuffer=null,this.socket.state){case"disconnected":case"terminated":case"stopped":return Promise.resolve();case"connecting":{const e=this.socket.ws;return e.onmessage=n=>{this._logVerbose("Ignoring message received after close")},new Promise(n=>{e.onclose=()=>{this._logVerbose("Closed after connecting"),n()},e.onopen=()=>{this._logVerbose("Opened after connecting"),e.close()}})}case"ready":{this._logVerbose("ws.close called");const e=this.socket.ws;e.onmessage=r=>{this._logVerbose("Ignoring message received after close")};const n=new Promise(r=>{e.onclose=()=>{r()}});return e.close(),n}default:return this.socket,Promise.resolve()}}terminate(){switch(this.reconnectDueToServerInactivityTimeout&&clearTimeout(this.reconnectDueToServerInactivityTimeout),this.scheduledReconnect&&(clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null),this.cleanupNetworkListener(),this.socket.state){case"terminated":case"stopped":case"disconnected":case"connecting":case"ready":{const e=this.close();return this.setSocketState({state:"terminated"}),e}default:throw this.socket,new Error(`Invalid websocket state: ${this.socket.state}`)}}stop(){switch(this.socket.state){case"terminated":return Promise.resolve();case"connecting":case"stopped":case"disconnected":case"ready":{this.cleanupNetworkListener();const e=this.close();return this.socket={state:"stopped"},e}default:return this.socket,Promise.resolve()}}tryRestart(){switch(this.socket.state){case"stopped":break;case"terminated":case"connecting":case"ready":case"disconnected":this.logger.logVerbose("Restart called without stopping first");return;default:this.socket}this.setupNetworkListener(),this.connect()}pause(){switch(this.socket.state){case"disconnected":case"stopped":case"terminated":return;case"connecting":case"ready":{this.socket={...this.socket,paused:"yes"};return}default:{this.socket;return}}}tryReconnectImmediately(){if(this._logVerbose("tryReconnectImmediately called"),this.socket.state!=="disconnected"){this._logVerbose(`tryReconnectImmediately called but socket state is ${this.socket.state}, no action taken`);return}let e=null;if(this.scheduledReconnect){const n=Ce()-this.scheduledReconnect.scheduledAt;e=Math.max(0,this.scheduledReconnect.backoffMs-n),this._logVerbose(`would have waited ${Math.round(e)}ms more (backoff was ${Math.round(this.scheduledReconnect.backoffMs)}ms, elapsed ${Math.round(n)}ms)`),clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null,this._logVerbose("canceled scheduled reconnect")}this.logger.log("Network recovery detected, reconnecting immediately"),this.pendingNetworkRecoveryInfo=e!==null?{timeSavedMs:e}:null,this.connect()}resume(){switch(this.socket.state){case"connecting":this.socket={...this.socket,paused:"no"};return;case"ready":this.socket.paused==="uninitialized"?(this.socket={...this.socket,paused:"no"},this._hasEverConnected=!0,this.onOpen({connectionCount:this.connectionCount,lastCloseReason:this.lastCloseReason,clientTs:Ce()})):this.socket.paused==="yes"&&(this.socket={...this.socket,paused:"no"},this.onResume());return;case"terminated":case"stopped":case"disconnected":return;default:this.socket}this.connect()}connectionState(){return{isConnected:this.socket.state==="ready",hasEverConnected:this._hasEverConnected,connectionCount:this.connectionCount,connectionRetries:this.retries}}_logVerbose(e){this.logger.logVerbose(e)}nextBackoff(e){const r=(e==="client"?100:e==="Unknown"?this.defaultInitialBackoff:Xr[e].timeout)*Math.pow(2,this.retries);this.retries+=1;const i=Math.min(r,this.maxBackoff),s=i*(Math.random()-.5);return i+s}reportLargeTransition({transition:e,messageLength:n}){if(e.clientClockSkew===void 0||e.serverTs===void 0)return;const r=Ce()-e.clientClockSkew-e.serverTs/1e6,i=`${Math.round(r)}ms`,s=`${Math.round(n/1e4)/100}MB`,o=n/(r/1e3),l=`${Math.round(o/1e4)/100}MB per second`;this._logVerbose(`received ${s} transition in ${i} at ${l}`),n>2e7?this.logger.log(`received query results totaling more that 20MB (${s}) which will take a long time to download on slower connections`):r>2e4&&this.logger.log(`received query results totaling ${s} which took more than 20s to arrive (${i})`),this.debug&&this.sendMessage({type:"Event",eventType:"ClientReceivedTransition",event:{transitionTransitTime:r,messageLength:n}})}}function Io(){return Eo()}function Eo(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}class Ge extends Error{}Ge.prototype.name="InvalidTokenError";function Po(t){return decodeURIComponent(atob(t).replace(/(.)/g,(e,n)=>{let r=n.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}function qo(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return Po(e)}catch{return atob(e)}}function Yr(t,e){if(typeof t!="string")throw new Ge("Invalid token specified: must be a string");e||(e={});const n=e.header===!0?0:1,r=t.split(".")[n];if(typeof r!="string")throw new Ge(`Invalid token specified: missing part #${n+1}`);let i;try{i=qo(r)}catch(s){throw new Ge(`Invalid token specified: invalid base64 for part #${n+1} (${s.message})`)}try{return JSON.parse(i)}catch(s){throw new Ge(`Invalid token specified: invalid json for part #${n+1} (${s.message})`)}}var Mo=Object.defineProperty,Lo=(t,e,n)=>e in t?Mo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Q=(t,e,n)=>Lo(t,typeof e!="symbol"?e+"":e,n);const Oo=480*60*60*1e3,ei=2;class No{constructor(e,n,r){Q(this,"authState",{state:"noAuth"}),Q(this,"configVersion",0),Q(this,"syncState"),Q(this,"authenticate"),Q(this,"stopSocket"),Q(this,"tryRestartSocket"),Q(this,"pauseSocket"),Q(this,"resumeSocket"),Q(this,"clearAuth"),Q(this,"logger"),Q(this,"refreshTokenLeewaySeconds"),Q(this,"tokenConfirmationAttempts",0),this.syncState=e,this.authenticate=n.authenticate,this.stopSocket=n.stopSocket,this.tryRestartSocket=n.tryRestartSocket,this.pauseSocket=n.pauseSocket,this.resumeSocket=n.resumeSocket,this.clearAuth=n.clearAuth,this.logger=r.logger,this.refreshTokenLeewaySeconds=r.refreshTokenLeewaySeconds}async setConfig(e,n){this.resetAuthState(),this._logVerbose("pausing WS for auth token fetch"),this.pauseSocket();const r=await this.fetchTokenAndGuardAgainstRace(e,{forceRefreshToken:!1});r.isFromOutdatedConfig||(r.value?(this.setAuthState({state:"waitingForServerConfirmationOfCachedToken",config:{fetchToken:e,onAuthChange:n},hasRetried:!1}),this.authenticate(r.value)):(this.setAuthState({state:"initialRefetch",config:{fetchToken:e,onAuthChange:n}}),await this.refetchToken()),this._logVerbose("resuming WS after auth token fetch"),this.resumeSocket())}onTransition(e){if(this.syncState.isCurrentOrNewerAuthVersion(e.endVersion.identity)&&!(e.endVersion.identity<=e.startVersion.identity)){if(this._logVerbose(`auth state is ${this.authState.state} when handling transition`),this.syncState.markAuthCompletion(),this.authState.state==="waitingForServerConfirmationOfCachedToken"){this._logVerbose("server confirmed auth token is valid"),this.refetchToken(),this.authState.config.onAuthChange(!0);return}this.authState.state==="waitingForServerConfirmationOfFreshToken"&&(this._logVerbose("server confirmed new auth token is valid"),this.scheduleTokenRefetch(this.authState.token),this.tokenConfirmationAttempts=0,this.authState.hadAuth||this.authState.config.onAuthChange(!0))}}onAuthError(e){if(e.authUpdateAttempted===!1&&(this.authState.state==="waitingForServerConfirmationOfFreshToken"||this.authState.state==="waitingForServerConfirmationOfCachedToken")){this._logVerbose("ignoring non-auth token expired error");return}const{baseVersion:n}=e;if(!this.syncState.isCurrentOrNewerAuthVersion(n+1)){this._logVerbose("ignoring auth error for previous auth attempt");return}this.tryToReauthenticate(e)}async tryToReauthenticate(e){if(this._logVerbose(`attempting to reauthenticate: ${e.error}`),this.authState.state==="noAuth"||this.authState.state==="waitingForServerConfirmationOfFreshToken"&&this.tokenConfirmationAttempts>=ei){this.logger.error(`Failed to authenticate: "${e.error}", check your server auth config`),this.syncState.hasAuth()&&this.syncState.clearAuth(),this.authState.state!=="noAuth"&&this.setAndReportAuthFailed(this.authState.config.onAuthChange);return}this.authState.state==="waitingForServerConfirmationOfFreshToken"&&(this.tokenConfirmationAttempts++,this._logVerbose(`retrying reauthentication, ${ei-this.tokenConfirmationAttempts} attempts remaining`)),await this.stopSocket();const n=await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken,{forceRefreshToken:!0});n.isFromOutdatedConfig||(n.value&&this.syncState.isNewAuth(n.value)?(this.authenticate(n.value),this.setAuthState({state:"waitingForServerConfirmationOfFreshToken",config:this.authState.config,token:n.value,hadAuth:this.authState.state==="notRefetching"||this.authState.state==="waitingForScheduledRefetch"})):(this._logVerbose("reauthentication failed, could not fetch a new token"),this.syncState.hasAuth()&&this.syncState.clearAuth(),this.setAndReportAuthFailed(this.authState.config.onAuthChange)),this.tryRestartSocket())}async refetchToken(){if(this.authState.state==="noAuth")return;this._logVerbose("refetching auth token");const e=await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken,{forceRefreshToken:!0});e.isFromOutdatedConfig||(e.value?this.syncState.isNewAuth(e.value)?(this.setAuthState({state:"waitingForServerConfirmationOfFreshToken",hadAuth:this.syncState.hasAuth(),token:e.value,config:this.authState.config}),this.authenticate(e.value)):this.setAuthState({state:"notRefetching",config:this.authState.config}):(this._logVerbose("refetching token failed"),this.syncState.hasAuth()&&this.clearAuth(),this.setAndReportAuthFailed(this.authState.config.onAuthChange)),this._logVerbose("restarting WS after auth token fetch (if currently stopped)"),this.tryRestartSocket())}scheduleTokenRefetch(e){if(this.authState.state==="noAuth")return;const n=this.decodeToken(e);if(!n){this.logger.error("Auth token is not a valid JWT, cannot refetch the token");return}const{iat:r,exp:i}=n;if(!r||!i){this.logger.error("Auth token does not have required fields, cannot refetch the token");return}const s=i-r;if(s<=2){this.logger.error("Auth token does not live long enough, cannot refetch the token");return}let o=Math.min(Oo,(s-this.refreshTokenLeewaySeconds)*1e3);o<=0&&(this.logger.warn(`Refetching auth token immediately, configured leeway ${this.refreshTokenLeewaySeconds}s is larger than the token's lifetime ${s}s`),o=0);const l=setTimeout(()=>{this._logVerbose("running scheduled token refetch"),this.refetchToken()},o);this.setAuthState({state:"waitingForScheduledRefetch",refetchTokenTimeoutId:l,config:this.authState.config}),this._logVerbose(`scheduled preemptive auth token refetching in ${o}ms`)}async fetchTokenAndGuardAgainstRace(e,n){const r=++this.configVersion;this._logVerbose(`fetching token with config version ${r}`);const i=await e(n);return this.configVersion!==r?(this._logVerbose(`stale config version, expected ${r}, got ${this.configVersion}`),{isFromOutdatedConfig:!0}):{isFromOutdatedConfig:!1,value:i}}stop(){this.resetAuthState(),this.configVersion++,this._logVerbose(`config version bumped to ${this.configVersion}`)}setAndReportAuthFailed(e){e(!1),this.resetAuthState()}resetAuthState(){this.setAuthState({state:"noAuth"})}setAuthState(e){const n=e.state==="waitingForServerConfirmationOfFreshToken"?{hadAuth:e.hadAuth,state:e.state,token:`...${e.token.slice(-7)}`}:{state:e.state};switch(this._logVerbose(`setting auth state to ${JSON.stringify(n)}`),e.state){case"waitingForScheduledRefetch":case"notRefetching":case"noAuth":this.tokenConfirmationAttempts=0;break}this.authState.state==="waitingForScheduledRefetch"&&clearTimeout(this.authState.refetchTokenTimeoutId),this.authState=e}decodeToken(e){try{return Yr(e)}catch(n){return this._logVerbose(`Error decoding token: ${n instanceof Error?n.message:"Unknown error"}`),null}}_logVerbose(e){this.logger.logVerbose(`${e} [v${this.configVersion}]`)}}const zo=["convexClientConstructed","convexWebSocketOpen","convexFirstMessageReceived"];function Bo(t,e){const n={sessionId:e};typeof performance>"u"||!performance.mark||performance.mark(t,{detail:n})}function Qo(t){let e=t.name.slice(6);return e=e.charAt(0).toLowerCase()+e.slice(1),{name:e,startTime:t.startTime}}function Fo(t){if(typeof performance>"u"||!performance.getEntriesByName)return[];const e=[];for(const n of zo){const r=performance.getEntriesByName(n).filter(i=>i.entryType==="mark").filter(i=>i.detail.sessionId===t);e.push(...r)}return e.map(Qo)}var Do=Object.defineProperty,Uo=(t,e,n)=>e in t?Do(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,R=(t,e,n)=>Uo(t,typeof e!="symbol"?e+"":e,n);class Vo{constructor(e,n,r){if(R(this,"address"),R(this,"state"),R(this,"requestManager"),R(this,"webSocketManager"),R(this,"authenticationManager"),R(this,"remoteQuerySet"),R(this,"optimisticQueryResults"),R(this,"_transitionHandlerCounter",0),R(this,"_nextRequestId"),R(this,"_onTransitionFns",new Map),R(this,"_sessionId"),R(this,"firstMessageReceived",!1),R(this,"debug"),R(this,"logger"),R(this,"maxObservedTimestamp"),R(this,"connectionStateSubscribers",new Map),R(this,"nextConnectionStateSubscriberId",0),R(this,"_lastPublishedConnectionState"),R(this,"markConnectionStateDirty",()=>{Promise.resolve().then(()=>{const f=this.connectionState();if(JSON.stringify(f)!==JSON.stringify(this._lastPublishedConnectionState)){this._lastPublishedConnectionState=f;for(const g of this.connectionStateSubscribers.values())g(f)}})}),R(this,"mark",f=>{this.debug&&Bo(f,this.sessionId)}),typeof e=="object")throw new Error("Passing a ClientConfig object is no longer supported. Pass the URL of the Convex deployment as a string directly.");r?.skipConvexDeploymentUrlCheck!==!0&&zs(e),r={...r};const i=r.authRefreshTokenLeewaySeconds??10;let s=r.webSocketConstructor;if(!s&&typeof WebSocket>"u")throw new Error("No WebSocket global variable defined! To use Convex in an environment without WebSocket try the HTTP client: https://docs.convex.dev/api/classes/browser.ConvexHttpClient");s=s||WebSocket,this.debug=r.reportDebugInfoToConvex??!1,this.address=e,this.logger=r.logger===!1?Fr({verbose:r.verbose??!1}):r.logger!==!0&&r.logger?r.logger:Qr({verbose:r.verbose??!1});const o=e.search("://");if(o===-1)throw new Error("Provided address was not an absolute URL.");const l=e.substring(o+3),a=e.substring(0,o);let h;if(a==="http")h="ws";else if(a==="https")h="wss";else throw new Error(`Unknown parent protocol ${a}`);const d=`${h}://${l}/api/${Or}/sync`;this.state=new ro,this.remoteQuerySet=new Gr(f=>this.state.queryPath(f),this.logger),this.requestManager=new oo(this.logger,this.markConnectionStateDirty);const c=()=>{this.webSocketManager.pause(),this.state.pause()};this.authenticationManager=new No(this.state,{authenticate:f=>{const g=this.state.setAuth(f);return this.webSocketManager.sendMessage(g),g.baseVersion},stopSocket:()=>this.webSocketManager.stop(),tryRestartSocket:()=>this.webSocketManager.tryRestart(),pauseSocket:c,resumeSocket:()=>this.webSocketManager.resume(),clearAuth:()=>{this.clearAuth()}},{logger:this.logger,refreshTokenLeewaySeconds:i}),this.optimisticQueryResults=new po,this.addOnTransitionHandler(f=>{n(f.queries.map(g=>g.token))}),this._nextRequestId=0,this._sessionId=Io();const{unsavedChangesWarning:p}=r;if(typeof window>"u"||typeof window.addEventListener>"u"){if(p===!0)throw new Error("unsavedChangesWarning requested, but window.addEventListener not found! Remove {unsavedChangesWarning: true} from Convex client options.")}else p!==!1&&window.addEventListener("beforeunload",f=>{if(this.requestManager.hasIncompleteRequests()){f.preventDefault();const g="Are you sure you want to leave? Your changes may not be saved.";return(f||window.event).returnValue=g,g}});this.webSocketManager=new Ao(d,{onOpen:f=>{this.mark("convexWebSocketOpen"),this.webSocketManager.sendMessage({...f,type:"Connect",sessionId:this._sessionId,maxObservedTimestamp:this.maxObservedTimestamp}),this.remoteQuerySet=new Gr(k=>this.state.queryPath(k),this.logger);const[g,x]=this.state.restart();x&&this.webSocketManager.sendMessage(x),this.webSocketManager.sendMessage(g);for(const k of this.requestManager.restart())this.webSocketManager.sendMessage(k)},onResume:()=>{const[f,g]=this.state.resume();g&&this.webSocketManager.sendMessage(g),f&&this.webSocketManager.sendMessage(f);for(const x of this.requestManager.resume())this.webSocketManager.sendMessage(x)},onMessage:f=>{switch(this.firstMessageReceived||(this.firstMessageReceived=!0,this.mark("convexFirstMessageReceived"),this.reportMarks()),f.type){case"Transition":{this.observedTimestamp(f.endVersion.ts),this.authenticationManager.onTransition(f),this.remoteQuerySet.transition(f),this.state.transition(f);const g=this.requestManager.removeCompleted(this.remoteQuerySet.timestamp());this.notifyOnQueryResultChanges(g);break}case"MutationResponse":{f.success&&this.observedTimestamp(f.ts);const g=this.requestManager.onResponse(f);g!==null&&this.notifyOnQueryResultChanges(new Map([[g.requestId,g.result]]));break}case"ActionResponse":{this.requestManager.onResponse(f);break}case"AuthError":{this.authenticationManager.onAuthError(f);break}case"FatalError":{const g=eo(this.logger,f.error);throw this.webSocketManager.terminate(),g}}return{hasSyncedPastLastReconnect:this.hasSyncedPastLastReconnect()}},onServerDisconnectError:r.onServerDisconnectError},s,this.logger,this.markConnectionStateDirty,this.debug),this.mark("convexClientConstructed"),r.expectAuth&&c()}hasSyncedPastLastReconnect(){return this.requestManager.hasSyncedPastLastReconnect()&&this.state.hasSyncedPastLastReconnect()}observedTimestamp(e){(this.maxObservedTimestamp===void 0||this.maxObservedTimestamp.lessThanOrEqual(e))&&(this.maxObservedTimestamp=e)}getMaxObservedTimestamp(){return this.maxObservedTimestamp}notifyOnQueryResultChanges(e){const n=this.remoteQuerySet.remoteQueryResults(),r=new Map;for(const[s,o]of n){const l=this.state.queryToken(s);if(l!==null){const a={result:o,udfPath:this.state.queryPath(s),args:this.state.queryArgs(s)};r.set(l,a)}}const i=this.optimisticQueryResults.ingestQueryResultsFromServer(r,new Set(e.keys()));this.handleTransition({queries:i.map(s=>{const o=this.optimisticQueryResults.rawQueryResult(s);return{token:s,modification:{kind:"Updated",result:o}}}),reflectedMutations:Array.from(e).map(([s,o])=>({requestId:s,result:o})),timestamp:this.remoteQuerySet.timestamp()})}handleTransition(e){for(const n of this._onTransitionFns.values())n(e)}addOnTransitionHandler(e){const n=this._transitionHandlerCounter++;return this._onTransitionFns.set(n,e),()=>this._onTransitionFns.delete(n)}getCurrentAuthClaims(){const e=this.state.getAuth();let n={};if(e&&e.tokenType==="User")try{n=e?Yr(e.value):{}}catch{n={}}else return;return{token:e.value,decoded:n}}setAuth(e,n){this.authenticationManager.setConfig(e,n)}hasAuth(){return this.state.hasAuth()}setAdminAuth(e,n){const r=this.state.setAdminAuth(e,n);this.webSocketManager.sendMessage(r)}clearAuth(){const e=this.state.clearAuth();this.webSocketManager.sendMessage(e)}subscribe(e,n,r){const i=ne(n),{modification:s,queryToken:o,unsubscribe:l}=this.state.subscribe(e,i,r?.journal,r?.componentPath);return s!==null&&this.webSocketManager.sendMessage(s),{queryToken:o,unsubscribe:()=>{const a=l();a&&this.webSocketManager.sendMessage(a)}}}localQueryResult(e,n){const r=ne(n),i=fe(e,r);return this.optimisticQueryResults.queryResult(i)}localQueryResultByToken(e){return this.optimisticQueryResults.queryResult(e)}hasLocalQueryResultByToken(e){return this.optimisticQueryResults.hasQueryResult(e)}localQueryLogs(e,n){const r=ne(n),i=fe(e,r);return this.optimisticQueryResults.queryLogs(i)}queryJournal(e,n){const r=ne(n),i=fe(e,r);return this.state.queryJournal(i)}connectionState(){const e=this.webSocketManager.connectionState();return{hasInflightRequests:this.requestManager.hasInflightRequests(),isWebSocketConnected:e.isConnected,hasEverConnected:e.hasEverConnected,connectionCount:e.connectionCount,connectionRetries:e.connectionRetries,timeOfOldestInflightRequest:this.requestManager.timeOfOldestInflightRequest(),inflightMutations:this.requestManager.inflightMutations(),inflightActions:this.requestManager.inflightActions()}}subscribeToConnectionState(e){const n=this.nextConnectionStateSubscriberId++;return this.connectionStateSubscribers.set(n,e),()=>{this.connectionStateSubscribers.delete(n)}}async mutation(e,n,r){const i=await this.mutationInternal(e,n,r);if(!i.success)throw i.errorData!==void 0?nn(i,new tn(je("mutation",e,i))):new Error(je("mutation",e,i));return i.value}async mutationInternal(e,n,r,i){const{mutationPromise:s}=this.enqueueMutation(e,n,r,i);return s}enqueueMutation(e,n,r,i){const s=ne(n);this.tryReportLongDisconnect();const o=this.nextRequestId;if(this._nextRequestId++,r!==void 0){const d=r.optimisticUpdate;if(d!==void 0){const c=g=>{d(g,s)instanceof Promise&&this.logger.warn("Optimistic update handler returned a Promise. Optimistic updates should be synchronous.")},f=this.optimisticQueryResults.applyOptimisticUpdate(c,o).map(g=>{const x=this.localQueryResultByToken(g);return{token:g,modification:{kind:"Updated",result:x===void 0?void 0:{success:!0,value:x,logLines:[]}}}});this.handleTransition({queries:f,reflectedMutations:[],timestamp:this.remoteQuerySet.timestamp()})}}const l={type:"Mutation",requestId:o,udfPath:e,componentPath:i,args:[K(s)]},a=this.webSocketManager.sendMessage(l),h=this.requestManager.request(l,a);return{requestId:o,mutationPromise:h}}async action(e,n){const r=await this.actionInternal(e,n);if(!r.success)throw r.errorData!==void 0?nn(r,new tn(je("action",e,r))):new Error(je("action",e,r));return r.value}async actionInternal(e,n,r){const i=ne(n),s=this.nextRequestId;this._nextRequestId++,this.tryReportLongDisconnect();const o={type:"Action",requestId:s,udfPath:e,componentPath:r,args:[K(i)]},l=this.webSocketManager.sendMessage(o);return this.requestManager.request(o,l)}async close(){return this.authenticationManager.stop(),this.webSocketManager.terminate()}get url(){return this.address}get nextRequestId(){return this._nextRequestId}get sessionId(){return this._sessionId}reportMarks(){if(this.debug){const e=Fo(this.sessionId);this.webSocketManager.sendMessage({type:"Event",eventType:"ClientConnect",event:e})}}tryReportLongDisconnect(){if(!this.debug)return;const e=this.connectionState().timeOfOldestInflightRequest;if(e===null||Date.now()-e.getTime()<=60*1e3)return;const n=`${this.address}/api/debug_event`;fetch(n,{method:"POST",headers:{"Content-Type":"application/json","Convex-Client":`npm-${Or}`},body:JSON.stringify({event:"LongWebsocketDisconnect"})}).then(r=>{r.ok||this.logger.warn("Analytics request failed with response:",r.body)}).catch(r=>{this.logger.warn("Analytics response failed with error:",r)})}}function on(t){if(typeof t!="object"||t===null||!Array.isArray(t.page)||typeof t.isDone!="boolean"||typeof t.continueCursor!="string")throw new Error(`Not a valid paginated query result: ${t?.toString()}`);return t}var Wo=Object.defineProperty,Ho=(t,e,n)=>e in t?Wo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ti=(t,e,n)=>Ho(t,typeof e!="symbol"?e+"":e,n);class Jo{constructor(e,n){this.client=e,this.onTransition=n,ti(this,"paginatedQuerySet",new Map),ti(this,"lastTransitionTs"),this.lastTransitionTs=P.fromNumber(0),this.client.addOnTransitionHandler(r=>this.onBaseTransition(r))}subscribe(e,n,r){const i=de(e),s=Dr(i,n,r),o=()=>this.removePaginatedQuerySubscriber(s),l=this.paginatedQuerySet.get(s);return l?(l.numSubscribers+=1,{paginatedQueryToken:s,unsubscribe:o}):(this.paginatedQuerySet.set(s,{token:s,canonicalizedUdfPath:i,args:n,numSubscribers:1,options:{initialNumItems:r.initialNumItems},nextPageKey:0,pageKeys:[],pageKeyToQuery:new Map,ongoingSplits:new Map,skip:!1,id:r.id}),this.addPageToPaginatedQuery(s,null,r.initialNumItems),{paginatedQueryToken:s,unsubscribe:o})}localQueryResult(e,n,r){const i=de(e),s=Dr(i,n,r);return this.localQueryResultByToken(s)}localQueryResultByToken(e){const n=this.paginatedQuerySet.get(e);if(!n)return;const r=this.activePageQueryTokens(n);if(r.length===0)return{results:[],status:"LoadingFirstPage",loadMore:a=>this.loadMoreOfPaginatedQuery(e,a)};let i=[],s=!1,o=!1;for(const a of r){const h=this.client.localQueryResultByToken(a);if(h===void 0){s=!0,o=!1;continue}const d=on(h);i=i.concat(d.page),o=!!d.isDone}let l;return s?l=i.length===0?"LoadingFirstPage":"LoadingMore":o?l="Exhausted":l="CanLoadMore",{results:i,status:l,loadMore:a=>this.loadMoreOfPaginatedQuery(e,a)}}onBaseTransition(e){const n=e.queries.map(o=>o.token),r=this.queriesContainingTokens(n);let i=[];r.length>0&&(this.processPaginatedQuerySplits(r,o=>this.client.localQueryResultByToken(o)),i=r.map(o=>({token:o,modification:{kind:"Updated",result:this.localQueryResultByToken(o)}})));const s={...e,paginatedQueries:i};this.onTransition(s)}loadMoreOfPaginatedQuery(e,n){this.mustGetPaginatedQuery(e);const r=this.queryTokenForLastPageOfPaginatedQuery(e),i=this.client.localQueryResultByToken(r);if(!i)return!1;const s=on(i);if(s.isDone)return!1;this.addPageToPaginatedQuery(e,s.continueCursor,n);const o={timestamp:this.lastTransitionTs,reflectedMutations:[],queries:[],paginatedQueries:[{token:e,modification:{kind:"Updated",result:this.localQueryResultByToken(e)}}]};return this.onTransition(o),!0}queriesContainingTokens(e){if(e.length===0)return[];const n=[],r=new Set(e);for(const[i,s]of this.paginatedQuerySet)for(const o of this.allQueryTokens(s))if(r.has(o)){n.push(i);break}return n}processPaginatedQuerySplits(e,n){for(const r of e){const i=this.mustGetPaginatedQuery(r),{ongoingSplits:s,pageKeyToQuery:o,pageKeys:l}=i;for(const[a,[h,d]]of s)n(o.get(h).queryToken)!==void 0&&n(o.get(d).queryToken)!==void 0&&this.completePaginatedQuerySplit(i,a,h,d);for(const a of l){if(s.has(a))continue;const h=o.get(a).queryToken,d=n(h);if(!d)continue;const c=on(d);c.splitCursor&&(c.pageStatus==="SplitRecommended"||c.pageStatus==="SplitRequired"||c.page.length>i.options.initialNumItems*2)&&this.splitPaginatedQueryPage(i,a,c.splitCursor,c.continueCursor)}}}splitPaginatedQueryPage(e,n,r,i){const s=e.nextPageKey++,o=e.nextPageKey++,l={cursor:i,numItems:e.options.initialNumItems,id:e.id},a=this.client.subscribe(e.canonicalizedUdfPath,{...e.args,paginationOpts:{...l,cursor:null,endCursor:r}});e.pageKeyToQuery.set(s,a);const h=this.client.subscribe(e.canonicalizedUdfPath,{...e.args,paginationOpts:{...l,cursor:r,endCursor:i}});e.pageKeyToQuery.set(o,h),e.ongoingSplits.set(n,[s,o])}addPageToPaginatedQuery(e,n,r){const i=this.mustGetPaginatedQuery(e),s=i.nextPageKey++,o={cursor:n,numItems:r,id:i.id},l={...i.args,paginationOpts:o},a=this.client.subscribe(i.canonicalizedUdfPath,l);return i.pageKeys.push(s),i.pageKeyToQuery.set(s,a),a}removePaginatedQuerySubscriber(e){const n=this.paginatedQuerySet.get(e);if(n&&(n.numSubscribers-=1,!(n.numSubscribers>0))){for(const r of n.pageKeyToQuery.values())r.unsubscribe();this.paginatedQuerySet.delete(e)}}completePaginatedQuerySplit(e,n,r,i){const s=e.pageKeyToQuery.get(n);e.pageKeyToQuery.delete(n);const o=e.pageKeys.indexOf(n);e.pageKeys.splice(o,1,r,i),e.ongoingSplits.delete(n),s.unsubscribe()}activePageQueryTokens(e){return e.pageKeys.map(n=>e.pageKeyToQuery.get(n).queryToken)}allQueryTokens(e){return Array.from(e.pageKeyToQuery.values()).map(n=>n.queryToken)}queryTokenForLastPageOfPaginatedQuery(e){const n=this.mustGetPaginatedQuery(e),r=n.pageKeys[n.pageKeys.length-1];if(r===void 0)throw new Error(`No pages for paginated query ${e}`);return n.pageKeyToQuery.get(r).queryToken}mustGetPaginatedQuery(e){const n=this.paginatedQuerySet.get(e);if(!n)throw new Error("paginated query no longer exists for token "+e);return n}}function Go({getCurrentValue:t,subscribe:e}){const[n,r]=T(()=>({getCurrentValue:t,subscribe:e,value:t()}));let i=n.value;return(n.getCurrentValue!==t||n.subscribe!==e)&&(i=t(),r({getCurrentValue:t,subscribe:e,value:i})),M(()=>{let s=!1;const o=()=>{s||r(a=>{if(a.getCurrentValue!==t||a.subscribe!==e)return a;const h=t();return a.value===h?a:{...a,value:h}})},l=e(o);return o(),()=>{s=!0,l()}},[t,e]),i}var Ko=Object.defineProperty,Zo=(t,e,n)=>e in t?Ko(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,re=(t,e,n)=>Zo(t,typeof e!="symbol"?e+"":e,n);const Xo=5e3;if(typeof Jt>"u")throw new Error("Required dependency 'react' not found");function ni(t,e,n){function r(i){return na(i),e.mutation(t,i,{optimisticUpdate:n})}return r.withOptimisticUpdate=function(s){if(n!==void 0)throw new Error(`Already specified optimistic update for mutation ${E(t)}`);return ni(t,e,s)},r}class Yo{constructor(e,n){if(re(this,"address"),re(this,"cachedSync"),re(this,"cachedPaginatedQueryClient"),re(this,"listeners"),re(this,"options"),re(this,"closed",!1),re(this,"_logger"),re(this,"adminAuth"),re(this,"fakeUserIdentity"),e===void 0)throw new Error("No address provided to ConvexReactClient.\nIf trying to deploy to production, make sure to follow all the instructions found at https://docs.convex.dev/production/hosting/\nIf running locally, make sure to run `convex dev` and ensure the .env.local file is populated.");if(typeof e!="string")throw new Error(`ConvexReactClient requires a URL like 'https://happy-otter-123.convex.cloud', received something of type ${typeof e} instead.`);if(!e.includes("://"))throw new Error("Provided address was not an absolute URL.");this.address=e,this.listeners=new Map,this._logger=n?.logger===!1?Fr({verbose:n?.verbose??!1}):n?.logger!==!0&&n?.logger?n.logger:Qr({verbose:n?.verbose??!1}),this.options={...n,logger:this._logger}}get url(){return this.address}get sync(){if(this.closed)throw new Error("ConvexReactClient has already been closed.");return this.cachedSync?this.cachedSync:(this.cachedSync=new Vo(this.address,()=>{},this.options),this.adminAuth&&this.cachedSync.setAdminAuth(this.adminAuth,this.fakeUserIdentity),this.cachedPaginatedQueryClient=new Jo(this.cachedSync,e=>this.handleTransition(e)),this.cachedSync)}get paginatedQueryClient(){if(this.sync,this.cachedPaginatedQueryClient)return this.cachedPaginatedQueryClient;throw new Error("Should already be instantiated")}setAuth(e,n){if(typeof e=="string")throw new Error("Passing a string to ConvexReactClient.setAuth is no longer supported, please upgrade to passing in an async function to handle reauthentication.");this.sync.setAuth(e,n??(()=>{}))}clearAuth(){this.sync.clearAuth()}setAdminAuth(e,n){if(this.adminAuth=e,this.fakeUserIdentity=n,this.closed)throw new Error("ConvexReactClient has already been closed.");this.cachedSync&&this.sync.setAdminAuth(e,n)}watchQuery(e,...n){const[r,i]=n,s=E(e);return{onUpdate:o=>{const{queryToken:l,unsubscribe:a}=this.sync.subscribe(s,r,i),h=this.listeners.get(l);return h!==void 0?h.add(o):this.listeners.set(l,new Set([o])),()=>{if(this.closed)return;const d=this.listeners.get(l);d.delete(o),d.size===0&&this.listeners.delete(l),a()}},localQueryResult:()=>{if(this.cachedSync)return this.cachedSync.localQueryResult(s,r)},localQueryLogs:()=>{if(this.cachedSync)return this.cachedSync.localQueryLogs(s,r)},journal:()=>{if(this.cachedSync)return this.cachedSync.queryJournal(s,r)}}}prewarmQuery(e){const n=e.extendSubscriptionFor??Xo,i=this.watchQuery(e.query,e.args||{}).onUpdate(()=>{});setTimeout(i,n)}watchPaginatedQuery(e,n,r){const i=E(e);return{onUpdate:s=>{const{paginatedQueryToken:o,unsubscribe:l}=this.paginatedQueryClient.subscribe(i,n||{},r),a=this.listeners.get(o);return a!==void 0?a.add(s):this.listeners.set(o,new Set([s])),()=>{if(this.closed)return;const h=this.listeners.get(o);h.delete(s),h.size===0&&this.listeners.delete(o),l()}},localQueryResult:()=>this.paginatedQueryClient.localQueryResult(i,n,r)}}mutation(e,...n){const[r,i]=n,s=E(e);return this.sync.mutation(s,r,i)}action(e,...n){const r=E(e);return this.sync.action(r,...n)}query(e,...n){const r=this.watchQuery(e,...n),i=r.localQueryResult();return i!==void 0?Promise.resolve(i):new Promise((s,o)=>{const l=r.onUpdate(()=>{l();try{s(r.localQueryResult())}catch(a){o(a)}})})}connectionState(){return this.sync.connectionState()}subscribeToConnectionState(e){return this.sync.subscribeToConnectionState(e)}get logger(){return this._logger}async close(){if(this.closed=!0,this.listeners=new Map,this.cachedPaginatedQueryClient&&(this.cachedPaginatedQueryClient=void 0),this.cachedSync){const e=this.cachedSync;this.cachedSync=void 0,await e.close()}}handleTransition(e){const n=e.queries.map(i=>i.token),r=e.paginatedQueries.map(i=>i.token);this.transition([...n,...r])}transition(e){for(const n of e){const r=this.listeners.get(n);if(r)for(const i of r)i()}}}const an=Jt.createContext(void 0);function ea(){return at(an)}const ta=({client:t,children:e})=>Jt.createElement(an.Provider,{value:t},e);function ri(t,...e){const n=e[0]==="skip",r=e[0]==="skip"?{}:ne(e[0]),i=typeof t=="string"?Vr(t):t,s=E(i),o=z(()=>n?{}:{query:{query:i,args:r}},[JSON.stringify(K(r)),s,n]),a=oa(o).query;if(a instanceof Error)throw a;return a}function mt(t){const e=typeof t=="string"?Vr(t):t,n=at(an);if(n===void 0)throw new Error("Could not find Convex client! `useMutation` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");return z(()=>ni(e,n),[n,E(e)])}function na(t){if(typeof t=="object"&&t!==null&&"bubbles"in t&&"persist"in t&&"isDefaultPrevented"in t)throw new Error("Convex function called with SyntheticEvent object. Did you use a Convex function as an event handler directly? Event handlers like onClick receive an event object as their first argument. These SyntheticEvent objects are not valid Convex values. Try wrapping the function like `const handler = () => myMutation();` and using `handler` in the event handler.")}var ra=Object.defineProperty,ia=(t,e,n)=>e in t?ra(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ln=(t,e,n)=>ia(t,typeof e!="symbol"?e+"":e,n);class sa{constructor(e){ln(this,"createWatch"),ln(this,"queries"),ln(this,"listeners"),this.createWatch=e,this.queries={},this.listeners=new Set}setQueries(e){for(const n of Object.keys(e)){const{query:r,args:i,paginationOptions:s}=e[n];if(E(r),this.queries[n]===void 0)this.addQuery(n,r,i,s?{paginationOptions:s}:{});else{const o=this.queries[n];(E(r)!==E(o.query)||JSON.stringify(K(i))!==JSON.stringify(K(o.args))||JSON.stringify(s)!==JSON.stringify(o.paginationOptions))&&(this.removeQuery(n),this.addQuery(n,r,i,s?{paginationOptions:s}:{}))}}for(const n of Object.keys(this.queries))e[n]===void 0&&this.removeQuery(n)}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}getLocalResults(e){const n={};for(const r of Object.keys(e)){const{query:i,args:s}=e[r],o=e[r].paginationOptions;E(i);const l=this.createWatch(i,s,o?{paginationOptions:o}:{});let a;try{a=l.localQueryResult()}catch(h){if(h instanceof Error)a=h;else throw h}n[r]=a}return n}setCreateWatch(e){this.createWatch=e;for(const n of Object.keys(this.queries)){const{query:r,args:i,watch:s,paginationOptions:o}=this.queries[n],l="journal"in s?s.journal():void 0;this.removeQuery(n),this.addQuery(n,r,i,{...l?{journal:l}:[],...o?{paginationOptions:o}:{}})}}destroy(){for(const e of Object.keys(this.queries))this.removeQuery(e);this.listeners=new Set}addQuery(e,n,r,{paginationOptions:i,journal:s}){if(this.queries[e]!==void 0)throw new Error(`Tried to add a new query with identifier ${e} when it already exists.`);const o=this.createWatch(n,r,{...s?{journal:s}:[],...i?{paginationOptions:i}:{}}),l=o.onUpdate(()=>this.notifyListeners());this.queries[e]={query:n,args:r,watch:o,unsubscribe:l,...i?{paginationOptions:i}:{}}}removeQuery(e){const n=this.queries[e];if(n===void 0)throw new Error(`No query found with identifier ${e}.`);n.unsubscribe(),delete this.queries[e]}notifyListeners(){for(const e of this.listeners)e()}}function oa(t){const e=ea();if(e===void 0)throw new Error("Could not find Convex client! `useQuery` must be used in the React component tree under `ConvexProvider`. Did you forget it? See https://docs.convex.dev/quick-start#set-up-convex-in-your-react-app");const n=z(()=>(r,i,{journal:s,paginationOptions:o})=>o?e.watchPaginatedQuery(r,i,o):e.watchQuery(r,i,s?{journal:s}:{}),[e]);return aa(t,n)}function aa(t,e){const[n]=T(()=>new sa(e));n.createWatch!==e&&n.setCreateWatch(e),M(()=>()=>n.destroy(),[n]);const r=z(()=>({getCurrentValue:()=>n.getLocalResults(t),subscribe:i=>(n.setQueries(t),n.subscribe(i))}),[n,t]);return Go(r)}var la=Symbol.for("preact-signals");function xt(){if(se>1)se--;else{for(var t,e=!1;Ke!==void 0;){var n=Ke;for(Ke=void 0,cn++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&oi(n))try{n.c()}catch(i){e||(t=i,e=!0)}n=r}}if(cn=0,se--,e)throw t}}function ca(t){if(se>0)return t();se++;try{return t()}finally{xt()}}var y=void 0;function ii(t){var e=y;y=void 0;try{return t()}finally{y=e}}var Ke=void 0,se=0,cn=0,bt=0;function si(t){if(y!==void 0){var e=t.n;if(e===void 0||e.t!==y)return e={i:0,S:t,p:y.s,n:void 0,t:y,e:void 0,x:void 0,r:e},y.s!==void 0&&(y.s.n=e),y.s=e,t.n=e,32&y.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=y.s,e.n=void 0,y.s.n=e,y.s=e),e}}function $(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}$.prototype.brand=la,$.prototype.h=function(){return!0},$.prototype.S=function(t){var e=this,n=this.t;n!==t&&t.e===void 0&&(t.x=n,this.t=t,n!==void 0?n.e=t:ii(function(){var r;(r=e.W)==null||r.call(e)}))},$.prototype.U=function(t){var e=this;if(this.t!==void 0){var n=t.e,r=t.x;n!==void 0&&(n.x=r,t.e=void 0),r!==void 0&&(r.e=n,t.x=void 0),t===this.t&&(this.t=r,r===void 0&&ii(function(){var i;(i=e.Z)==null||i.call(e)}))}},$.prototype.subscribe=function(t){var e=this;return Ze(function(){var n=e.value,r=y;y=void 0;try{t(n)}finally{y=r}},{name:"sub"})},$.prototype.valueOf=function(){return this.value},$.prototype.toString=function(){return this.value+""},$.prototype.toJSON=function(){return this.value},$.prototype.peek=function(){var t=y;y=void 0;try{return this.value}finally{y=t}},Object.defineProperty($.prototype,"value",{get:function(){var t=si(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(cn>100)throw new Error("Cycle detected");this.v=t,this.i++,bt++,se++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{xt()}}}});function L(t,e){return new $(t,e)}function oi(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function ai(t){for(var e=t.s;e!==void 0;e=e.n){var n=e.S.n;if(n!==void 0&&(e.r=n),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function li(t){for(var e=t.s,n=void 0;e!==void 0;){var r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):n=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}t.s=n}function pe(t,e){$.call(this,void 0),this.x=t,this.s=void 0,this.g=bt-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}pe.prototype=new $,pe.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===bt))return!0;if(this.g=bt,this.f|=1,this.i>0&&!oi(this))return this.f&=-2,!0;var t=y;try{ai(this),y=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return y=t,li(this),this.f&=-2,!0},pe.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}$.prototype.S.call(this,t)},pe.prototype.U=function(t){if(this.t!==void 0&&($.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}},pe.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}},Object.defineProperty(pe.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=si(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function un(t,e){return new pe(t,e)}function ci(t){var e=t.u;if(t.u=void 0,typeof e=="function"){se++;var n=y;y=void 0;try{e()}catch(r){throw t.f&=-2,t.f|=8,hn(t),r}finally{y=n,xt()}}}function hn(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,ci(t)}function ua(t){if(y!==this)throw new Error("Out-of-order effect");li(this),y=t,this.f&=-2,8&this.f&&hn(this),xt()}function Re(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}Re.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{t()}},Re.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ci(this),ai(this),se++;var t=y;return y=this,ua.bind(this,t)},Re.prototype.N=function(){2&this.f||(this.f|=2,this.o=Ke,Ke=this)},Re.prototype.d=function(){this.f|=8,1&this.f||hn(this)},Re.prototype.dispose=function(){this.d()};function Ze(t,e){var n=new Re(t,e);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var ui,yt,vt,ha=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__,hi=[];Ze(function(){ui=this.N})();function Te(t,e){m[t]=e.bind(null,m[t]||function(){})}function _t(t){if(vt){var e=vt;vt=void 0,e()}vt=t&&t.S()}function di(t){var e=this,n=t.data,r=Xe(n);r.value=n;var i=z(function(){for(var l=e,a=e.__v;a=a.__;)if(a.__c){a.__c.__$f|=4;break}var h=un(function(){var f=r.value.value;return f===0?0:f===!0?"":f||""}),d=un(function(){return!Array.isArray(h.value)&&!Mn(h.value)}),c=Ze(function(){if(this.N=fi,d.value){var f=h.value;l.__v&&l.__v.__e&&l.__v.__e.nodeType===3&&(l.__v.__e.data=f)}}),p=e.__$u.d;return e.__$u.d=function(){c(),p.call(this)},[d,h]},[]),s=i[0],o=i[1];return s.value?o.peek():o.value}di.displayName="ReactiveTextNode",Object.defineProperties($.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:di},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Te("__b",function(t,e){if(typeof e.type=="string"){var n,r=e.props;for(var i in r)if(i!=="children"){var s=r[i];s instanceof $&&(n||(e.__np=n={}),n[i]=s,r[i]=s.peek())}}t(e)}),Te("__r",function(t,e){if(t(e),e.type!==N){_t();var n,r=e.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=(function(i,s){var o;return Ze(function(){o=this},{name:s}),o.c=i,o})(function(){var i;ha&&((i=n.y)==null||i.call(n)),r.__$f|=1,r.setState({})},typeof e.type=="function"?e.type.displayName||e.type.name:""))),yt=r,_t(n)}}),Te("__e",function(t,e,n,r){_t(),yt=void 0,t(e,n,r)}),Te("diffed",function(t,e){_t(),yt=void 0;var n;if(typeof e.type=="string"&&(n=e.__e)){var r=e.__np,i=e.props;if(r){var s=n.U;if(s)for(var o in s){var l=s[o];l!==void 0&&!(o in r)&&(l.d(),s[o]=void 0)}else s={},n.U=s;for(var a in r){var h=s[a],d=r[a];h===void 0?(h=da(n,a,d,i),s[a]=h):h.o(d,i)}}}t(e)});function da(t,e,n,r){var i=e in t&&t.ownerSVGElement===void 0,s=L(n);return{o:function(o,l){s.value=o,r=l},d:Ze(function(){this.N=fi;var o=s.value.value;r[e]!==o&&(r[e]=o,i?t[e]=o:o!=null&&(o!==!1||e[4]==="-")?t.setAttribute(e,o):t.removeAttribute(e))})}}Te("unmount",function(t,e){if(typeof e.type=="string"){var n=e.__e;if(n){var r=n.U;if(r){n.U=void 0;for(var i in r){var s=r[i];s&&s.d()}}}}else{var o=e.__c;if(o){var l=o.__$u;l&&(o.__$u=void 0,l.d())}}t(e)}),Te("__h",function(t,e,n,r){(r<3||r===9)&&(e.__$f|=2),t(e,n,r)}),F.prototype.shouldComponentUpdate=function(t,e){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in e)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var s=2&this.__$f;if(!(r||s||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var o in t)if(o!=="__source"&&t[o]!==this.props[o])return!0;for(var l in this.props)if(!(l in t))return!0;return!1};function Xe(t,e){return z(function(){return L(t,e)},[])}function fa(t,e){var n=Be(t);return n.current=t,yt.__$f|=4,z(function(){return un(function(){return n.current()},e)},[])}var pa=function(t){queueMicrotask(function(){queueMicrotask(t)})};function ga(){ca(function(){for(var t;t=hi.shift();)ui.call(t)})}function fi(){hi.push(this)===1&&(m.requestAnimationFrame||pa)(ga)}const A=L(!1),wt=L(void 0),kt=L(void 0);function ma(t){return t.replace(/\.convex\.site\b/,".convex.cloud")}function dn(t){return t.replace(/\.convex\.cloud\b/,".convex.site")}function xa(t,e){const n=t.title??e?.title??"Assistant";return{title:n,greeting:t.greeting??e?.welcomeMessage??`Hi! I'm ${n}. How can I help?`,locale:t.locale??e?.locale,position:t.position??e?.position,colorScheme:t.colorScheme??e?.colorScheme,hideBranding:t.hideBranding??e?.hideBranding??!1,triggerIcon:t.triggerIcon??e?.triggerIcon??"chat",triggerRadius:t.triggerRadius??e?.triggerRadius??"full",triggerLabel:t.triggerLabel??e?.triggerLabel??"Chatte mit uns",mode:t.mode??"floating",primaryColor:t.primaryColor??e?.primaryColor,accentColor:t.accentColor??e?.accentColor,fontFamily:t.fontFamily??e?.fontFamily,fontSize:t.fontSize??e?.fontSize,borderRadius:t.borderRadius??e?.borderRadius,windowWidth:t.windowWidth??e?.windowWidth,windowHeight:t.windowHeight??e?.windowHeight}}async function ba(t,e,n,r){const i=new URL(`${t}/widget/config`);i.searchParams.set("orgSlug",e),r&&i.searchParams.set("projSlug",r);const s=await fetch(i.toString(),{signal:n});return s.ok?s.json():null}function ya(t,e,n){const[r,i]=T(null);return M(()=>{i(null);const s=n??"https://festive-mouse-978.eu-west-1.convex.cloud",o=s?dn(s):void 0;if(!o||!t)return;const l=new AbortController;async function a(h){try{const d=await ba(h,t,l.signal,e);d&&i(d)}catch(d){if(d instanceof Error&&d.name==="AbortError")return}}return a(o),()=>{l.abort()}},[t,e,n]),r}async function pi(t,e,n){try{const r=await fetch(`${e}/widget/bootstrap`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n?{orgSlug:t,projSlug:n}:{orgSlug:t}),credentials:"omit"});if(r.ok){const i=await r.json();return{ok:!0,token:i.token,excludePaths:i.excludePaths}}return r.status===403?{ok:!1,error:"unauthorized"}:r.status===404?{ok:!1,error:"not_found"}:r.status===429?{ok:!1,error:"rate_limited",retryAfterSec:Number(r.headers.get("Retry-After"))||60}:{ok:!1,error:"network"}}catch{return{ok:!1,error:"network"}}}function va(t,e,n,r){M(()=>{if(n)return;const i=r??"https://festive-mouse-978.eu-west-1.convex.cloud",s=i?dn(i):void 0;if(!s||!t)return;let o=!1;return(async()=>{const l=await pi(t,s,e);if(!o)if(l.ok)kt.value=l.token;else{const a=e?`project '${t}/${e}'`:`org '${t}'`;l.error==="unauthorized"?console.error(`[JexityChat] This domain is not authorized for ${a}. Check the widget's domain rules.`):l.error==="not_found"?console.error(`[JexityChat] No active widget config found for ${a}.`):l.error==="rate_limited"?console.error(`[JexityChat] Bootstrap rate-limited for ${a}. Retry after ${l.retryAfterSec??60}s.`):console.error(`[JexityChat] Bootstrap failed: ${l.error}`)}})(),()=>{o=!0}},[t,e,n,r])}const gi={title:"Assistant",statusOnline:"Online · Responds in seconds",inputPlaceholder:"Type a message…",aiThinking:"AI is responding…",sendAriaLabel:"Send message",openChatAriaLabel:"Open chat",closeChatAriaLabel:"Close chat",errorNetwork:"Network error. Please try again.",errorQuota:"Message limit reached. Please try again later.",errorRateLimited:"Too many messages. Try again in {seconds}s.",localeLabelDe:"DE",localeLabelEn:"EN",resumeConversation:"Resume conversation",sessionNotFound:"Your previous session was not found. Starting a new conversation.",startNewConversation:"Start new conversation",chatWith:"Chat with {title}",haveReferenceNumber:"Have a reference number?",referencePlaceholder:"e.g. JEX-A3B7C2",resume:"Resume",howCanWeHelp:"How can we help?",getInstantHelp:"Get instant help",submitTicket:"Submit a ticket",replyByEmail:"We'll reply by email",ticketSubmitted:"Ticket submitted",yourReferenceNumber:"Your reference number:",sentToEmailHint:"We've sent it to your email. Use this number to follow up.",done:"Done",submittingTicket:"Submitting your ticket…",yourName:"Your name",yourEmail:"Your email",submit:"Submit",back:"Go back",escalationFormTitle:"Leave your details",escalationSubtitle:"Our team will get back to you by email so you don’t have to wait here.",escalationNameLabel:"Your name",escalationEmailLabel:"Your email",escalationSubmit:"Send to team",escalationSubmitting:"Sending…",escalationSubmitted:"Request submitted",escalationConsent:"We’ll only use your email to respond to this conversation.",escalationSkip:"Skip, I’ll wait here",escalationPromptTitle:"Talk to our team",escalationPromptSubtitle:"We can notify you by email when our team replies.",escalationPromptSubmit:"Leave details",escalationSubmitFailed:"Failed to submit. Please try again.",sessionNotFoundPrompt:"Session not found. Would you like to start a new conversation?",sessionResolved:"This conversation has been resolved.",tryAgain:"Try again",goBack:"Go back",somethingWentWrong:"Something went wrong",fabLabel:"Chat with us",chatNoLongerAvailable:"This chat is no longer available."},_a={title:"Assistent",statusOnline:"Online · Antwortet in Sekunden",inputPlaceholder:"Nachricht eingeben…",aiThinking:"KI antwortet…",sendAriaLabel:"Nachricht senden",openChatAriaLabel:"Chat öffnen",closeChatAriaLabel:"Chat schließen",errorNetwork:"Netzwerkfehler. Bitte versuche es erneut.",errorQuota:"Nachrichtenlimit erreicht. Bitte versuche es später erneut.",errorRateLimited:"Zu viele Nachrichten. Bitte in {seconds} Sek. erneut versuchen.",localeLabelDe:"DE",localeLabelEn:"EN",resumeConversation:"Gespräch fortsetzen",sessionNotFound:"Ihre vorherige Sitzung wurde nicht gefunden. Ein neues Gespräch wird gestartet.",startNewConversation:"Neues Gespräch beginnen",chatWith:"Chatte mit {title}",haveReferenceNumber:"Hast du eine Referenznummer?",referencePlaceholder:"z.B. JEX-A3B7C2",resume:"Fortsetzen",howCanWeHelp:"Wie können wir helfen?",getInstantHelp:"Soforthilfe erhalten",submitTicket:"Ticket einreichen",replyByEmail:"Wir antworten per E-Mail",ticketSubmitted:"Ticket eingereicht",yourReferenceNumber:"Deine Referenznummer:",sentToEmailHint:"Wir haben sie an deine E-Mail gesendet. Verwende diese Nummer für Rückfragen.",done:"Fertig",submittingTicket:"Dein Ticket wird übermittelt…",yourName:"Dein Name",yourEmail:"Deine E-Mail",submit:"Absenden",back:"Zurück",escalationFormTitle:"Hinterlassen Sie Ihre Daten",escalationSubtitle:"Unser Team meldet sich per E-Mail bei Ihnen — Sie müssen nicht hier warten.",escalationNameLabel:"Ihr Name",escalationEmailLabel:"Ihre E-Mail",escalationSubmit:"An Team senden",escalationSubmitting:"Wird gesendet…",escalationSubmitted:"Anfrage gesendet",escalationConsent:"Wir verwenden Ihre E-Mail nur, um auf diese Unterhaltung zu antworten.",escalationSkip:"Überspringen, ich warte hier",escalationPromptTitle:"Sprechen Sie mit unserem Team",escalationPromptSubtitle:"Wir benachrichtigen Sie per E-Mail, wenn wir antworten.",escalationPromptSubmit:"Daten hinterlassen",escalationSubmitFailed:"Senden fehlgeschlagen. Bitte versuche es erneut.",sessionNotFoundPrompt:"Sitzung nicht gefunden. Möchten Sie ein neues Gespräch beginnen?",sessionResolved:"Diese Unterhaltung wurde abgeschlossen.",tryAgain:"Erneut versuchen",goBack:"Zurück",somethingWentWrong:"Etwas ist schiefgelaufen",fabLabel:"Chatte mit uns",chatNoLongerAvailable:"Dieser Chat ist nicht mehr verfügbar."},wa=[{value:"de",label:"Deutsch",flag:"🇩🇪"},{value:"en",label:"English",flag:"🇬🇧"}],ka="de",Sa="jex-locale",fn=L("de"),ja={en:gi,de:_a};function q(){return ja[fn.value]??gi}function pn(t){if(!t)return null;const e=(t.split("-")[0]??"").toLowerCase();return wa.some(r=>r.value===e)?e:null}function mi(t){const e=pn(t);if(e)return e;try{const n=pn(localStorage.getItem(Sa));if(n)return n}catch{}if(typeof navigator<"u"){const n=pn(navigator.language);if(n)return n}return ka}function Ca(t){M(()=>{function e(n){const r=t??window.location.origin;if(n.origin!==r||n.data?.type!=="jexity:config")return;const{locale:i}=n.data.payload;i&&(fn.value=mi(i))}return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[t])}const gn="jex-session-ref",St="jex-session-active",oe=L(null),ge=L(!1);function Ra(){return"JEX-"+Math.random().toString(36).slice(2,8).toUpperCase()}function Ta(){try{const t=sessionStorage.getItem(gn),e=sessionStorage.getItem(St);oe.value=t??null,ge.value=t!==null&&e==="true"}catch{oe.value=null,ge.value=!1}}function mn(){const t=Ra();oe.value=t,ge.value=!1;try{sessionStorage.setItem(gn,t),sessionStorage.removeItem(St)}catch{}return t}function $a(t){oe.value=t,ge.value=!0;try{sessionStorage.setItem(gn,t),sessionStorage.setItem(St,"true")}catch{}}function Aa(){if(oe.value){ge.value=!0;try{sessionStorage.setItem(St,"true")}catch{}}}function Ia(t){const e={},{primaryColor:n,theme:r}=t;if(n&&(e["--jex-primary"]=n,e["--jex-bg-trigger"]=n,e["--jex-bg-header"]=n,e["--jex-bg-msg-user"]=n,e["--jex-bg-send-btn"]=n),t.accentColor&&(e["--jex-accent"]=t.accentColor),r?.bg){const i=r.bg;i.trigger&&(e["--jex-bg-trigger"]=i.trigger),i.header&&(e["--jex-bg-header"]=i.header),i.msgUser&&(e["--jex-bg-msg-user"]=i.msgUser),i.msgBot&&(e["--jex-bg-msg-bot"]=i.msgBot),i.window&&(e["--jex-bg-window"]=i.window),i.sendBtn&&(e["--jex-bg-send-btn"]=i.sendBtn)}if(r?.text){const i=r.text;i.header&&(e["--jex-text-header"]=i.header),i.msgUser&&(e["--jex-text-msg-user"]=i.msgUser),i.msgBot&&(e["--jex-text-msg-bot"]=i.msgBot),i.main&&(e["--jex-text-main"]=i.main),i.muted&&(e["--jex-text-muted"]=i.muted)}if(r?.border){const i=r.border;i.window&&(e["--jex-border-window"]=i.window),i.input&&(e["--jex-border-input"]=i.input)}return t.fontFamily&&(e["--jex-font-family"]=t.fontFamily),t.fontSize&&(e["--jex-font-size"]=`${t.fontSize}px`),t.borderRadius&&(e["--jex-radius"]=t.borderRadius),t.windowWidth&&(e["--jex-window-width"]=`${t.windowWidth}px`),t.windowHeight&&(e["--jex-window-height"]=`${t.windowHeight}px`),Object.keys(e).length>0?e:void 0}const D=L([{id:"home"}]),Ea=L("screen");function $e(t){D.value=[...D.value,t]}function xn(){D.value.length>1&&(D.value=D.value.slice(0,-1))}function Ae(t){D.value=[...D.value.slice(0,-1),t]}function bn({size:t=24}){return u("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[u("path",{d:"M12 8V4H8"}),u("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),u("path",{d:"M2 14h2"}),u("path",{d:"M20 14h2"}),u("path",{d:"M15 13v2"}),u("path",{d:"M9 13v2"})]})}function xi({title:t}){const e=q(),n=D.value.length>1;return u("header",{class:"jex-chat-header",children:[n&&u("button",{class:"jex-header-back",onClick:xn,"aria-label":e.back||"Go back",children:u("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:u("path",{d:"m15 18-6-6 6-6"})})}),!n&&u(bn,{size:24}),u("div",{class:"jex-header-info",children:[u("h3",{children:t}),u("p",{children:e.statusOnline})]})]})}function Pa({size:t=14}){return u("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:u("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})})}function bi(){return u("div",{class:"jex-widget-footer",children:u("a",{href:"https://jexitychat.de",target:"_blank",rel:"noopener noreferrer",class:"jex-branding",children:[u(Pa,{size:14}),u("span",{children:["Powered by ",u("strong",{children:"Jexity"})]})]})})}function yi({size:t=28}){return u("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:u("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function qa({size:t=28}){return u("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[u("path",{d:"M18 6 6 18"}),u("path",{d:"m6 6 12 12"})]})}function Ma({size:t=24,...e}){return u("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e,children:u("path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"})})}const La={chat:u(yi,{size:28}),bot:u(bn,{size:28}),sparkles:u(Ma,{size:28})},Oa={none:"0px",sm:"0.5rem",md:"0.75rem",lg:"1.25rem",full:"9999px"};function Na({radius:t="full",iconOption:e="chat",label:n}){const r=q(),i=n??r.fabLabel,s=i!=="";return u("button",{class:`jex-floating-button ${!A.value&&s?"jex-has-label":""}`,style:{borderRadius:Oa[t]??"9999px"},onClick:()=>{A.value=!A.value},"aria-label":A.value?r.closeChatAriaLabel:r.openChatAriaLabel,children:A.value?u(qa,{size:28}):u("div",{class:"jex-fab-inner",children:[La[e],s&&u("span",{class:"jex-fab-label",children:i})]})})}function za({title:t}){const e=q(),n=oe.value,[r,i]=T("");function s(){mn(),$e({id:"chat"})}function o(){$e({id:"chat"})}function l(a){a.preventDefault();const h=r.trim().toUpperCase();h&&($a(h),$e({id:"chat"}))}return u("div",{class:"jex-home",children:[u("div",{class:"jex-home-hero",children:[u("div",{class:"jex-home-avatar",children:[u(yi,{size:24}),u("span",{class:"jex-home-status-dot"})]}),u("div",{class:"jex-home-hero-text",children:[u("h2",{class:"jex-home-title",children:t}),u("span",{class:"jex-home-status",children:e.statusOnline})]})]}),u("form",{class:"jex-home-lookup",onSubmit:l,children:[u("input",{class:"jex-home-lookup-input",type:"text",placeholder:e.referencePlaceholder,value:r,onInput:a=>{i(a.currentTarget.value)}}),u("button",{class:"jex-home-lookup-submit",type:"submit",disabled:!r.trim(),children:e.resume})]}),u("div",{class:"jex-home-actions",children:[n&&u("button",{class:"jex-home-resume-card",onClick:o,children:[u("div",{class:"jex-home-resume-top",children:[u("span",{class:"jex-home-resume-label",children:e.resumeConversation}),u("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",class:"jex-home-resume-arrow",children:u("path",{d:"M6 3l5 5-5 5",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})})]}),u("span",{class:"jex-home-resume-ref",children:n})]}),u("button",{class:"jex-home-new-btn",onClick:s,children:n?e.startNewConversation:e.chatWith.replace("{title}",t)})]})]})}function Ba({title:t}){const e=q();return u("div",{class:"jex-selection",children:[u("h2",{class:"jex-selection-title",children:e.howCanWeHelp}),u("div",{class:"jex-selection-options",children:[u("button",{class:"jex-selection-option",onClick:()=>$e({id:"chat"}),children:[u("span",{class:"jex-selection-icon",children:"💬"}),u("span",{class:"jex-selection-label",children:e.chatWith.replace("{title}",t)}),u("span",{class:"jex-selection-sub",children:e.getInstantHelp})]}),u("button",{class:"jex-selection-option",onClick:()=>$e({id:"form"}),children:[u("span",{class:"jex-selection-icon",children:"📝"}),u("span",{class:"jex-selection-label",children:e.submitTicket}),u("span",{class:"jex-selection-sub",children:e.replyByEmail})]})]})]})}function vi(t,e){const n={get(r,i){if(typeof i=="string"){const s=[...e,i];return vi(t,s)}else if(i===Ur){if(e.length<1){const s=[t,...e].join(".");throw new Error(`API path is expected to be of the form \`${t}.childComponent.functionName\`. Found: \`${s}\``)}return"_reference/childComponent/"+e.join("/")}else return}};return new Proxy({},n)}const Qa=()=>vi("components",[]),Ie=uo;Qa();function Fa(t,e){const n=Be(null),r=Xe(!1),i=Xe(!1),s=Xe(!1),o=Xe(null),l=mt(Ie.functions.chat.public.sessions.createOrResume),a=async p=>{const f=kt.value;if(!f)return console.warn("[JexityChat] No bootstrap token — session creation blocked."),null;const g=await l({orgSlug:t,...e?{projSlug:e}:{},visitorId:p,bootstrapToken:f,...wt.value?{source:wt.value}:{}});o.value=g.status;const x={sessionId:g.sessionId,visitorId:p};return n.current=x,{session:x,result:g}},h=Qe(async()=>{if(n.current)return n.current;if(s.value)return null;r.value=!0;const p=oe.value!==null,f=oe.value??mn();try{const g=await a(f);return g?(p&&g.result.isNew&&(i.value=!0,s.value=!0),g.session):null}catch(g){return console.error("[JexityChat] Failed to create session:",g),null}finally{r.value=!1}},[t,e,l,r,i,s]),d=Qe(async()=>{n.current=null,s.value=!1,i.value=!1;const p=mn();r.value=!0;try{return(await a(p))?.session??null}catch(f){return console.error("[JexityChat] Failed to create fresh session:",f),null}finally{r.value=!1}},[t,e,l,r,i,s,o]),c=n.current;return{sessionId:c?.sessionId??null,visitorId:c?.visitorId??null,isLoading:r.value,sessionNotFound:i.value,resumeFailed:s.value,sessionStatus:o.value,isOrgDeleted:o.value==="org_deleted",ensureSession:h,startFresh:d}}const Da=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();const _i=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Ua=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());const wi=t=>{const e=Ua(t);return e.charAt(0).toUpperCase()+e.slice(1)};var Va={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};const Wa=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const Ha=({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,children:i,iconNode:s,class:o="",...l})=>O("svg",{...Va,width:String(e),height:e,stroke:t,"stroke-width":r?Number(n)*24/Number(e):n,class:["lucide",o].join(" "),...!i&&!Wa(l)&&{"aria-hidden":"true"},...l},[...s.map(([a,h])=>O(a,h)),...J(i)]);const Ja=(t,e)=>{const n=({class:r="",className:i="",children:s,...o})=>O(Ha,{...o,iconNode:e,class:Da(`lucide-${_i(wi(t))}`,`lucide-${_i(t)}`,r,i)},s);return n.displayName=wi(t),n};const Ga=Ja("corner-up-left",[["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}],["path",{d:"M9 14 4 9l5-5",key:"102s5s"}]]);function yn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var me=yn();function ki(t){me=t}var xe={exec:()=>null};function b(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(I.caret,"$1"),n=n.replace(i,o),r},getRegex:()=>new RegExp(n,e)};return r}var Ka=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),I={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},Za=/^(?:[ \t]*(?:\n|$))+/,Xa=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ya=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ye=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,el=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,vn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Si=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ji=b(Si).replace(/bull/g,vn).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),tl=b(Si).replace(/bull/g,vn).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),_n=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,nl=/^[^\n]+/,wn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,rl=b(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",wn).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),il=b(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,vn).getRegex(),jt="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",kn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,sl=b("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",kn).replace("tag",jt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ci=b(_n).replace("hr",Ye).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",jt).getRegex(),ol=b(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ci).getRegex(),Sn={blockquote:ol,code:Xa,def:rl,fences:Ya,heading:el,hr:Ye,html:sl,lheading:ji,list:il,newline:Za,paragraph:Ci,table:xe,text:nl},Ri=b("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ye).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",jt).getRegex(),al={...Sn,lheading:tl,table:Ri,paragraph:b(_n).replace("hr",Ye).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ri).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",jt).getRegex()},ll={...Sn,html:b(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",kn).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:xe,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:b(_n).replace("hr",Ye).replace("heading",` *#{1,6} *[^
|
|
3
3
|
]`).replace("lheading",ji).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},cl=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ul=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ti=/^( {2,}|\\)\n(?!\s*$)/,hl=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ee=/[\p{P}\p{S}]/u,Ct=/[\s\p{P}\p{S}]/u,jn=/[^\s\p{P}\p{S}]/u,dl=b(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ct).getRegex(),$i=/(?!~)[\p{P}\p{S}]/u,fl=/(?!~)[\s\p{P}\p{S}]/u,pl=/(?:[^\s\p{P}\p{S}]|~)/u,gl=b(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Ka?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Ai=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ml=b(Ai,"u").replace(/punct/g,Ee).getRegex(),xl=b(Ai,"u").replace(/punct/g,$i).getRegex(),Ii="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",bl=b(Ii,"gu").replace(/notPunctSpace/g,jn).replace(/punctSpace/g,Ct).replace(/punct/g,Ee).getRegex(),yl=b(Ii,"gu").replace(/notPunctSpace/g,pl).replace(/punctSpace/g,fl).replace(/punct/g,$i).getRegex(),vl=b("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,jn).replace(/punctSpace/g,Ct).replace(/punct/g,Ee).getRegex(),_l=b(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ee).getRegex(),wl="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",kl=b(wl,"gu").replace(/notPunctSpace/g,jn).replace(/punctSpace/g,Ct).replace(/punct/g,Ee).getRegex(),Sl=b(/\\(punct)/,"gu").replace(/punct/g,Ee).getRegex(),jl=b(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Cl=b(kn).replace("(?:-->|$)","-->").getRegex(),Rl=b("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Cl).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Rt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Tl=b(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Rt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ei=b(/^!?\[(label)\]\[(ref)\]/).replace("label",Rt).replace("ref",wn).getRegex(),Pi=b(/^!?\[(ref)\](?:\[\])?/).replace("ref",wn).getRegex(),$l=b("reflink|nolink(?!\\()","g").replace("reflink",Ei).replace("nolink",Pi).getRegex(),qi=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Cn={_backpedal:xe,anyPunctuation:Sl,autolink:jl,blockSkip:gl,br:Ti,code:ul,del:xe,delLDelim:xe,delRDelim:xe,emStrongLDelim:ml,emStrongRDelimAst:bl,emStrongRDelimUnd:vl,escape:cl,link:Tl,nolink:Pi,punctuation:dl,reflink:Ei,reflinkSearch:$l,tag:Rl,text:hl,url:xe},Al={...Cn,link:b(/^!?\[(label)\]\((.*?)\)/).replace("label",Rt).getRegex(),reflink:b(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Rt).getRegex()},Rn={...Cn,emStrongRDelimAst:yl,emStrongLDelim:xl,delLDelim:_l,delRDelim:kl,url:b(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",qi).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:b(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",qi).getRegex()},Il={...Rn,br:b(Ti).replace("{2,}","*").getRegex(),text:b(Rn.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Tt={normal:Sn,gfm:al,pedantic:ll},et={normal:Cn,gfm:Rn,breaks:Il,pedantic:Al},El={"&":"&","<":"<",">":">",'"':""","'":"'"},Mi=t=>El[t];function X(t,e){if(e){if(I.escapeTest.test(t))return t.replace(I.escapeReplace,Mi)}else if(I.escapeTestNoEncode.test(t))return t.replace(I.escapeReplaceNoEncode,Mi);return t}function Li(t){try{t=encodeURI(t).replace(I.percentDecode,"%")}catch{return null}return t}function Oi(t,e){let n=t.replace(I.findPipe,(s,o,l)=>{let a=!1,h=o;for(;--h>=0&&l[h]==="\\";)a=!a;return a?"|":" |"}),r=n.split(I.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(I.slashPipe,"|");return r}function tt(t,e,n){let r=t.length;if(r===0)return"";let i=0;for(;i<r&&t.charAt(r-i-1)===e;)i++;return t.slice(0,r-i)}function Pl(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function ql(t,e=0){let n=e,r="";for(let i of t)if(i===" "){let s=4-n%4;r+=" ".repeat(s),n+=s}else r+=i,n++;return r}function Ni(t,e,n,r,i){let s=e.href,o=e.title||null,l=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let a={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:o,text:l,tokens:r.inlineTokens(l)};return r.state.inLink=!1,a}function Ml(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
|
|
4
4
|
`).map(s=>{let o=s.match(n.other.beginningSpace);if(o===null)return s;let[l]=o;return l.length>=i.length?s.slice(i.length):s}).join(`
|
|
5
5
|
`)}var $t=class{options;rules;lexer;constructor(t){this.options=t||me}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:tt(n,`
|
|
@@ -58,5 +58,5 @@ ${t}</tr>
|
|
|
58
58
|
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
59
59
|
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${X(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),i=Li(t);if(i===null)return r;t=i;let s='<a href="'+t+'"';return e&&(s+=' title="'+X(e)+'"'),s+=">"+r+"</a>",s}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Li(t);if(i===null)return X(n);t=i;let s=`<img src="${t}" alt="${X(n)}"`;return e&&(s+=` title="${X(e)}"`),s+=">",s}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:X(t.text)}},Tn=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},V=class Pn{options;renderer;textRenderer;constructor(e){this.options=e||me,this.options.renderer=this.options.renderer||new At,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Tn}static parse(e,n){return new Pn(n).parse(e)}static parseInline(e,n){return new Pn(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let o=i,l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=l||"";continue}}let s=i;switch(s.type){case"space":{n+=this.renderer.space(s);break}case"hr":{n+=this.renderer.hr(s);break}case"heading":{n+=this.renderer.heading(s);break}case"code":{n+=this.renderer.code(s);break}case"table":{n+=this.renderer.table(s);break}case"blockquote":{n+=this.renderer.blockquote(s);break}case"list":{n+=this.renderer.list(s);break}case"checkbox":{n+=this.renderer.checkbox(s);break}case"html":{n+=this.renderer.html(s);break}case"def":{n+=this.renderer.def(s);break}case"paragraph":{n+=this.renderer.paragraph(s);break}case"text":{n+=this.renderer.text(s);break}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let r="";for(let i=0;i<e.length;i++){let s=e[i];if(this.options.extensions?.renderers?.[s.type]){let l=this.options.extensions.renderers[s.type].call({parser:this},s);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){r+=l||"";continue}}let o=s;switch(o.type){case"escape":{r+=n.text(o);break}case"html":{r+=n.html(o);break}case"link":{r+=n.link(o);break}case"image":{r+=n.image(o);break}case"checkbox":{r+=n.checkbox(o);break}case"strong":{r+=n.strong(o);break}case"em":{r+=n.em(o);break}case"codespan":{r+=n.codespan(o);break}case"br":{r+=n.br(o);break}case"del":{r+=n.del(o);break}case"text":{r+=n.text(o);break}default:{let l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}},nt=class{options;block;constructor(t){this.options=t||me}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?U.lex:U.lexInline}provideParser(){return this.block?V.parse:V.parseInline}},Ll=class{defaults=yn();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=V;Renderer=At;TextRenderer=Tn;Lexer=U;Tokenizer=$t;Hooks=nt;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{let i=r;for(let s of i.header)n=n.concat(this.walkTokens(s.tokens,e));for(let s of i.rows)for(let o of s)n=n.concat(this.walkTokens(o.tokens,e));break}case"list":{let i=r;n=n.concat(this.walkTokens(i.items,e));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(s=>{let o=i[s].flat(1/0);n=n.concat(this.walkTokens(o,e))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let l=i.renderer.apply(this,o);return l===!1&&(l=s.apply(this,o)),l}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=e[i.level];s?s.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){let i=this.defaults.renderer||new At(this.defaults);for(let s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,l=n.renderer[o],a=i[o];i[o]=(...h)=>{let d=l.apply(i,h);return d===!1&&(d=a.apply(i,h)),d||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new $t(this.defaults);for(let s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,l=n.tokenizer[o],a=i[o];i[o]=(...h)=>{let d=l.apply(i,h);return d===!1&&(d=a.apply(i,h)),d}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new nt;for(let s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,l=n.hooks[o],a=i[o];nt.passThroughHooks.has(s)?i[o]=h=>{if(this.defaults.async&&nt.passThroughHooksRespectAsync.has(s))return(async()=>{let c=await l.call(i,h);return a.call(i,c)})();let d=l.call(i,h);return a.call(i,d)}:i[o]=(...h)=>{if(this.defaults.async)return(async()=>{let c=await l.apply(i,h);return c===!1&&(c=await a.apply(i,h)),c})();let d=l.apply(i,h);return d===!1&&(d=a.apply(i,h)),d}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(o){let l=[];return l.push(s.call(this,o)),i&&(l=l.concat(i.call(this,o))),l}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return U.lex(t,e??this.defaults)}parser(t,e){return V.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=t),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(e):e,l=await(i.hooks?await i.hooks.provideLexer():t?U.lex:U.lexInline)(o,i),a=i.hooks?await i.hooks.processAllTokens(l):l;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let h=await(i.hooks?await i.hooks.provideParser():t?V.parse:V.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(h):h})().catch(s);try{i.hooks&&(e=i.hooks.preprocess(e));let o=(i.hooks?i.hooks.provideLexer():t?U.lex:U.lexInline)(e,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let l=(i.hooks?i.hooks.provideParser():t?V.parse:V.parseInline)(o,i);return i.hooks&&(l=i.hooks.postprocess(l)),l}catch(o){return s(o)}}}onError(t,e){return n=>{if(n.message+=`
|
|
60
60
|
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+X(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},be=new Ll;function v(t,e){return be.parse(t,e)}v.options=v.setOptions=function(t){return be.setOptions(t),v.defaults=be.defaults,ki(v.defaults),v},v.getDefaults=yn,v.defaults=me,v.use=function(...t){return be.use(...t),v.defaults=be.defaults,ki(v.defaults),v},v.walkTokens=function(t,e){return be.walkTokens(t,e)},v.parseInline=be.parseInline,v.Parser=V,v.parser=V.parse,v.Renderer=At,v.TextRenderer=Tn,v.Lexer=U,v.lexer=U.lex,v.Tokenizer=$t,v.Hooks=nt,v.parse=v,v.options,v.setOptions,v.use,v.walkTokens,v.parseInline,V.parse,U.lex,v.setOptions({breaks:!0,gfm:!0});function Ol({text:t}){const e=z(()=>{if(!t)return"";const n=v.parse(t);return typeof n=="string"?n:""},[t]);return u("div",{class:"jex-md",dangerouslySetInnerHTML:{__html:e}})}const $n=L(""),ae=L(null),zi=L(Date.now());function Nl(t){if(!t)return;const e=t.trim().split(/\s+/)[0];if(!e)return;const n=`@${e} `,r=$n.value;r.includes(n)||r.includes(`@${e}`)||($n.value=r.trimStart()?`${n}${r.trimStart()}`:n)}function zl(t){const e=t.trim().split(/\s+/).filter(Boolean);return e.length===0?"?":e.map(n=>n[0]).join("").slice(0,2).toUpperCase()}function Pe({text:t,streaming:e,error:n,authorId:r,authorName:i,authorImage:s,botAvatarUrl:o}){const l=!!r,[a,h]=T(!1),d=Qe(()=>h(!0),[]),c=["jex-message bot",n?"jex-message-error":""].filter(Boolean).join(" ");return u("div",{class:"jex-message-row bot",children:[u("div",{class:`jex-avatar ${l?"jex-avatar-agent":"jex-avatar-bot"}`,children:l&&s&&!a?u("img",{src:s,alt:i??"",class:"jex-avatar-img",onError:d}):l?u("span",{class:"jex-avatar-initials",children:zl(i??"")}):o&&!a?u("img",{src:o,alt:"",class:"jex-avatar-img",onError:d}):u(bn,{size:14})}),u("div",{class:"jex-message-content",children:[u("div",{class:c,children:[u(Ol,{text:t}),e&&u("span",{class:"jex-streaming-cursor"})]}),l&&i&&u("div",{class:"jex-message-author-row",children:[u("span",{class:"jex-message-author",children:i}),u("button",{type:"button",class:"jex-reply-tag-btn","aria-label":`Reply to ${i}`,title:`Reply to ${i}`,onClick:()=>{Nl(i)},children:u(Ga,{size:12})})]})]})]})}function Bl({text:t}){return u("div",{class:"jex-message user",children:t})}function Ql({message:t,sessionId:e,visitorId:n}){const r=q();return t.formData?u("div",{class:"jex-inline-form-submitted",children:[u("span",{class:"jex-inline-form-check",children:"✓"}),u("div",{children:[u("div",{class:"jex-inline-form-submitted-title",children:r.escalationSubmitted}),u("div",{class:"jex-inline-form-submitted-detail",children:[t.formData.visitorName," · ",t.formData.visitorEmail]})]})]}):u("div",{class:"jex-message-row bot",children:u(Fl,{messageId:t._id,sessionId:e,visitorId:n})})}function Fl({messageId:t,sessionId:e,visitorId:n}){const r=q(),[i,s]=T(""),[o,l]=T(""),[a,h]=T(!1),d=mt(Ie.functions.chat.public.helpdesk.submitEscalation);async function c(p){if(p.preventDefault(),!a){h(!0);try{await d({sessionId:e,visitorId:n,formMessageId:t,visitorName:i.trim(),visitorEmail:o.trim()})}catch(f){console.error("[FormMessage] Submit failed:",f),h(!1)}}}return u("div",{class:"jex-inline-form",children:[u("div",{class:"jex-inline-form-title",children:r.escalationFormTitle}),u("form",{class:"jex-form",onSubmit:p=>{c(p)},children:[u("input",{class:"jex-form-input",type:"text",placeholder:r.escalationNameLabel,value:i,required:!0,disabled:a,onInput:p=>{s(p.currentTarget.value)}}),u("input",{class:"jex-form-input",type:"email",placeholder:r.escalationEmailLabel,value:o,required:!0,disabled:a,onInput:p=>{l(p.currentTarget.value)}}),u("button",{class:"jex-form-submit",type:"submit",disabled:a,children:a?r.escalationSubmitting:r.escalationSubmit})]}),u("div",{class:"jex-inline-form-consent",children:r.escalationConsent})]})}const Dl={crawl:"🌐",file:"📄",snippet:"💡",qa:"❓"};function Ul({sources:t}){const[e,n]=T(!1);return t.length===0?null:u("div",{class:"jex-sources-row",children:[u("button",{type:"button",class:"jex-sources-toggle",onClick:()=>{n(r=>!r)},"aria-expanded":e,children:[u("span",{class:"jex-sources-icon",children:"📖"}),u("span",{children:[t.length," ",t.length===1?"source":"sources"]}),u("span",{class:`jex-sources-chevron${e?" jex-sources-chevron--open":""}`,children:"▾"})]}),e?u("div",{class:"jex-sources-pills",children:t.map((r,i)=>{const s=r.sourceType==="crawl",o=Vl(r),l=s&&r.url?`${r.title}
|
|
61
|
-
${r.url}`:r.title,a=u(N,{children:[typeof r.id=="number"?u("span",{class:"jex-source-id",children:r.id}):null,u("span",{class:"jex-source-type",children:Dl[r.sourceType]}),u("span",{class:"jex-source-label",children:o}),u("span",{class:"jex-source-score",children:["· ",r.score.toFixed(2)]})]});return s&&r.url?u("a",{class:"jex-source-pill",href:r.url,target:"_blank",rel:"noopener noreferrer",title:l,children:a},i):u("span",{class:"jex-source-pill",title:l,children:a},i)})}):null]})}function Vl(t){if(t.sourceType==="crawl"&&t.url)try{const e=new URL(t.url);return!e.pathname||e.pathname==="/"?e.hostname:e.pathname}catch{}return t.title}function Wl(){return u("div",{class:"jex-typing",children:[u("span",{}),u("span",{}),u("span",{})]})}const Hl=/\s?\[\d+\]/g;function Bi(t){return t.replace(Hl,"")}function Jl({conversations:t,greeting:e,sessionNotFound:n,resumeFailed:r,onStartFresh:i,sessionId:s,visitorId:o}){const l=q(),a=Be(null),[h,d]=T(null);return M(()=>{a.current?.scrollIntoView({behavior:"smooth"})},[t?.length,t?.at(-1)?.content]),u("div",{class:"jex-chat-messages",children:[u(Pe,{text:e}),n&&r&&i?u("div",{class:"jex-session-prompt",children:[u("div",{class:"jex-session-prompt-text",children:l.sessionNotFoundPrompt}),u("button",{class:"jex-session-prompt-btn",type:"button",onClick:()=>{i()},children:l.startNewConversation})]}):n?u("div",{class:"jex-session-notice",children:l.sessionNotFound}):null,t?.map(c=>{if(c.contentType==="human-notice")return u(Pe,{text:c.content},c._id);if(c.contentType==="escalation-form"&&s&&o)return Ea.value==="screen"&&!c.formData?h===c._id?null:u("div",{class:"jex-inline-form jex-inline-form-card",children:[u("div",{class:"jex-inline-form-title",children:l.escalationPromptTitle}),u("div",{class:"jex-inline-form-subtitle",children:l.escalationPromptSubtitle}),u("button",{class:"jex-form-submit",type:"button",onClick:()=>{$e({id:"escalation-form",formMessageId:c._id,sessionId:s,visitorId:o})},children:l.escalationPromptSubmit}),u("button",{class:"jex-escalation-skip",type:"button",onClick:()=>{d(c._id)},children:l.escalationSkip})]},c._id):u(Ql,{message:c,sessionId:s,visitorId:o},c._id);if(c.contentType==="escalation-confirm")return u(Pe,{text:c.content},c._id);if(c.role==="user")return u(Bl,{text:c.content},c._id);const p={authorId:c.authorId,authorName:c.authorName,authorImage:c.authorImage};return c.status==="streaming"&&c.content===""?u(Wl,{},c._id):c.status==="streaming"?u(Pe,{text:Bi(c.content),streaming:!0,...p},c._id):c.status==="error"?u(Pe,{text:c.errorMessage??`${l.somethingWentWrong}. ${l.tryAgain}.`,error:!0,...p},c._id):u("div",{children:[u(Pe,{text:Bi(c.content),...p}),c.sources&&c.sources.length>0?u(Ul,{sources:c.sources}):null]},c._id)}),u("div",{ref:a})]})}function Gl({size:t=18}){return u("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[u("path",{d:"M22 2 11 13"}),u("path",{d:"M22 2 15 22 11 13 2 9l20-7z"})]})}function Kl(){const t=q(),e=fa(()=>{const n=ae.value;return n===null?0:Math.max(0,Math.ceil((n-zi.value)/1e3))});return M(()=>{const n=ae.value;if(n===null)return;const r=setInterval(()=>{zi.value=Date.now()},1e3),i=setTimeout(()=>{ae.value=null},Math.max(0,n-Date.now()));return()=>{clearInterval(r),clearTimeout(i)}},[ae.value]),ae.value===null?null:u("div",{class:"jex-rate-limit-notice",role:"status","aria-live":"polite",children:t.errorRateLimited.replace("{seconds}",String(e.value))})}function Zl({sessionId:t,visitorId:e,isLoading:n,isStreaming:r,sessionStatus:i,ensureSession:s,onStartFresh:o}){const l=q(),a=$n,h=mt(Ie.functions.chat.public.conversations.send),d=ae.value!==null&&ae.value>Date.now(),c=n||r||d;if(i==="resolved")return u("div",{class:"jex-chat-input-resolved",children:[u("div",{class:"jex-resolved-notice",children:l.sessionResolved}),u("button",{class:"jex-resolved-new-btn",type:"button",onClick:()=>{o()},children:l.startNewConversation})]});async function p(){const f=a.value.trim();if(!f||c)return;const g=t&&e?{sessionId:t,visitorId:e}:await s();if(g){Aa(),a.value="";try{const x=await h({sessionId:g.sessionId,visitorId:g.visitorId,content:f});!x.ok&&x.reason==="rate_limited"&&(ae.value=Date.now()+x.retryAfterMs)}catch(x){console.error("[jexity] Failed to send message:",x)}}}return u("div",{class:"jex-chat-input",children:[u(Kl,{}),u("input",{type:"text","aria-label":l.inputPlaceholder,placeholder:r?l.aiThinking:l.inputPlaceholder,value:a.value,onInput:f=>{a.value=f.currentTarget.value},onKeyDown:f=>{f.key==="Enter"&&p()},disabled:n||r}),u("button",{class:"jex-send-btn",onClick:p,"aria-label":l.sendAriaLabel,disabled:c,children:u(Gl,{size:18})})]})}function Qi({message:t}){return u("div",{class:"jex-overlay jex-loading",children:[u("div",{class:"jex-loading-spinner","aria-hidden":"true"}),t&&u("p",{class:"jex-loading-message",children:t})]})}function Xl({greeting:t,orgSlug:e,projSlug:n}){const r=q(),{sessionId:i,visitorId:s,isLoading:o,sessionNotFound:l,resumeFailed:a,isOrgDeleted:h,ensureSession:d,startFresh:c}=Fa(e,n),p=ri(Ie.functions.chat.public.conversations.listBySession,i&&s?{sessionId:i,visitorId:s}:"skip"),f=ri(Ie.functions.chat.public.sessions.getSessionStatus,i&&s?{sessionId:i,visitorId:s}:"skip"),g=i!==null&&p===void 0,x=p?.some(k=>k.status==="streaming")??!1;return M(()=>{ge.value&&!i&&d()},[d,i]),h?u("div",{class:"jex-chat-messages",children:u("div",{class:"jex-session-notice",children:r.chatNoLongerAvailable})}):o||g&&ge.value?u(Qi,{message:r.resumeConversation}):u(N,{children:[u(Jl,{conversations:p,greeting:t,sessionNotFound:l,resumeFailed:a,onStartFresh:c,sessionId:i,visitorId:s}),u(Zl,{sessionId:i,visitorId:s,isLoading:o,isStreaming:x,sessionStatus:f??null,ensureSession:d,onStartFresh:c})]})}function Yl({formMessageId:t,sessionId:e,visitorId:n}){const r=q(),[i,s]=T(""),[o,l]=T(""),a=mt(Ie.functions.chat.public.helpdesk.submitEscalation);async function h(d){d.preventDefault(),Ae({id:"loading",message:r.escalationSubmitting});try{const c=await a({sessionId:e,visitorId:n,formMessageId:t,visitorName:i.trim(),visitorEmail:o.trim()});Ae({id:"confirmation",ref:c.ticketRef})}catch(c){console.error("[EscalationFormScreen] Submit failed:",c),Ae({id:"error",message:r.escalationSubmitFailed})}}return u("div",{class:"jex-form-screen",children:[u("h2",{class:"jex-form-title",children:r.escalationFormTitle}),u("p",{class:"jex-escalation-subtitle",children:r.escalationSubtitle}),u("form",{class:"jex-form",onSubmit:d=>{h(d)},children:[u("input",{class:"jex-form-input",type:"text",placeholder:r.escalationNameLabel,value:i,required:!0,onInput:d=>{s(d.currentTarget.value)}}),u("input",{class:"jex-form-input",type:"email",placeholder:r.escalationEmailLabel,value:o,required:!0,onInput:d=>{l(d.currentTarget.value)}}),u("button",{class:"jex-form-submit",type:"submit",children:r.escalationSubmit})]}),u("div",{class:"jex-inline-form-consent",style:{textAlign:"center",margin:"16px 0 8px 0"},children:r.escalationConsent}),u("button",{class:"jex-escalation-skip",type:"button",onClick:()=>{xn()},children:r.escalationSkip})]})}function ec(){const t=q(),[e,n]=T(""),[r,i]=T(""),[s,o]=T("");async function l(a){a.preventDefault(),Ae({id:"loading",message:t.submittingTicket}),await new Promise(d=>{setTimeout(d,1200)});const h="JEX-"+Math.random().toString(36).slice(2,8).toUpperCase();Ae({id:"confirmation",ref:h})}return u("div",{class:"jex-form-screen",children:[u("h2",{class:"jex-form-title",children:t.submitTicket}),u("form",{class:"jex-form",onSubmit:a=>{l(a)},children:[u("input",{class:"jex-form-input",type:"text",placeholder:t.yourName,value:e,required:!0,onInput:a=>{n(a.currentTarget.value)}}),u("input",{class:"jex-form-input",type:"email",placeholder:t.yourEmail,value:r,required:!0,onInput:a=>{i(a.currentTarget.value)}}),u("textarea",{class:"jex-form-textarea",placeholder:t.howCanWeHelp,value:s,required:!0,onInput:a=>{o(a.currentTarget.value)}}),u("button",{class:"jex-form-submit",type:"submit",children:t.submit})]})]})}function tc({ticketRef:t}){const e=q();return u("div",{class:"jex-confirmation",children:[u("div",{class:"jex-confirmation-icon","aria-hidden":"true",children:"✓"}),u("h2",{class:"jex-confirmation-title",children:e.ticketSubmitted}),u("p",{class:"jex-confirmation-body",children:e.yourReferenceNumber}),u("div",{class:"jex-confirmation-ref",children:t}),u("p",{class:"jex-confirmation-hint",children:e.sentToEmailHint}),u("button",{class:"jex-confirmation-done",onClick:()=>{A.value=!1},children:e.done})]})}function nc({message:t,onRetry:e,onBack:n}){const r=q();return u("div",{class:"jex-overlay jex-error",children:[u("p",{class:"jex-error-message",children:t}),u("div",{class:"jex-error-actions",children:[e&&u("button",{class:"jex-error-retry",onClick:e,children:r.tryAgain}),n&&u("button",{class:"jex-error-back",onClick:n,children:r.goBack})]})]})}function Fi({greeting:t,title:e,orgSlug:n,projSlug:r}){const i=D.value,s=i[i.length-1],o=i.findLast(l=>l.id==="confirmation");return u("div",{class:"jex-screen-container",children:[s.id==="home"&&u(za,{greeting:t,title:e}),s.id==="selection"&&u(Ba,{title:e}),s.id==="form"&&u(ec,{}),s.id==="escalation-form"&&u(Yl,{formMessageId:s.formMessageId,sessionId:s.sessionId,visitorId:s.visitorId}),s.id==="confirmation"&&o&&u(tc,{ticketRef:o.ref}),s.id==="chat"&&u(Xl,{greeting:t,orgSlug:n,projSlug:r}),s.id==="loading"&&u(Qi,{message:s.message}),s.id==="error"&&u(nc,{message:s.message,onRetry:()=>Ae({id:"loading"}),onBack:xn})]})}function rc({options:t}){va(t.orgSlug,t.projSlug,t.bootstrapToken,t.convexUrl);const e=ya(t.orgSlug,t.projSlug,t.convexUrl);Ca(t.parentOrigin),M(()=>{Ta()},[]);const n=xa(t,e);M(()=>{fn.value=mi(n.locale)},[n.locale]);const r=n.position==="bottom-left",i=n.colorScheme==="dark"||n.colorScheme==="light"?n.colorScheme:"",s=Ia({...t,primaryColor:n.primaryColor,accentColor:n.accentColor,fontFamily:n.fontFamily,fontSize:n.fontSize,borderRadius:n.borderRadius,windowWidth:n.windowWidth,windowHeight:n.windowHeight}),o=n.mode==="embedded",a=e!==null||o||!!t.parentOrigin?s:{...s,visibility:"hidden"};return u("div",{class:`jex-widget ${i}`.trim(),style:a,children:o?u("div",{class:"jex-embedded",children:[u(xi,{title:n.title}),u(Fi,{greeting:n.greeting,title:n.title,orgSlug:t.orgSlug,projSlug:t.projSlug}),!n.hideBranding&&u(bi,{})]}):u("div",{class:`jex-container${r?" jex-pos-left":""}`,children:[A.value&&u("div",{class:"jex-chat-window",children:[u(xi,{title:n.title}),u(Fi,{greeting:n.greeting,title:n.title,orgSlug:t.orgSlug,projSlug:t.projSlug}),!n.hideBranding&&u(bi,{})]}),u(Na,{iconOption:n.triggerIcon,radius:n.triggerRadius,label:n.triggerLabel})]})})}const ic='.jex-widget{--jex-primary: #115A62;--jex-primary-hover: var(--jex-accent, color-mix(in srgb, var(--jex-primary) 85%, #000));--jex-radius: .75rem;--jex-font-family: "Inter", system-ui, -apple-system, sans-serif;--jex-font-size: 14px;--jex-window-width: 380px;--jex-window-height: 600px;--jex-shadow: 0 16px 48px -12px rgba(13, 127, 138, .25), 0 4px 16px rgba(0, 0, 0, .08);pointer-events:auto;--jex-bg-trigger: var(--jex-primary);--jex-bg-header: var(--jex-primary);--jex-bg-msg-user: var(--jex-primary);--jex-bg-send-btn: var(--jex-primary);--jex-bg-window: rgba(255, 255, 255, .95);--jex-bg-msg-bot: #f1f5f9;--jex-bg-input: rgba(247, 253, 253, .6);--jex-text-header: #ffffff;--jex-text-msg-user: #ffffff;--jex-text-msg-bot: #0f172a;--jex-text-main: #0f172a;--jex-text-muted: #64748b;--jex-bg-avatar-agent: #d1fae5;--jex-text-avatar-agent: #065f46;--jex-border-window: rgba(226, 232, 240, .8);--jex-border-input: rgba(203, 213, 225, .8);--jex-bg-glass: var(--jex-bg-window);--jex-border-glass: var(--jex-border-window);font-family:var(--jex-font-family);-webkit-font-smoothing:antialiased}.dark .jex-widget,.jex-widget.dark{--jex-primary: #1cb0bf;--jex-primary-hover: var(--jex-accent, color-mix(in srgb, var(--jex-primary) 85%, #000));--jex-bg-window: rgba(10, 15, 26, .95);--jex-bg-msg-bot: #233146;--jex-bg-input: rgba(10, 15, 26, .6);--jex-text-msg-bot: #f8fafc;--jex-text-main: #f8fafc;--jex-text-muted: #94a3b8;--jex-border-window: rgba(30, 41, 59, .8);--jex-border-input: rgba(51, 65, 85, .9);--jex-bg-avatar-agent: #064e3b;--jex-text-avatar-agent: #6ee7b7;--jex-bg-error: #3b1318;--jex-border-error: #5c1d24;--jex-text-error: #fca5a5}@media(prefers-color-scheme:dark){:host:not(.light) .jex-widget:not(.light){--jex-primary: #1cb0bf;--jex-primary-hover: var(--jex-accent, color-mix(in srgb, var(--jex-primary) 85%, #000));--jex-bg-window: rgba(10, 15, 26, .95);--jex-bg-msg-bot: #233146;--jex-bg-input: rgba(10, 15, 26, .6);--jex-text-msg-bot: #f8fafc;--jex-text-main: #f8fafc;--jex-text-muted: #94a3b8;--jex-border-window: rgba(30, 41, 59, .8);--jex-border-input: rgba(51, 65, 85, .9);--jex-bg-error: #3b1318;--jex-border-error: #5c1d24;--jex-text-error: #fca5a5}}.jex-widget *{box-sizing:border-box;margin:0;padding:0}.jex-container{position:fixed;bottom:24px;right:24px;display:flex;flex-direction:column;align-items:flex-end;gap:16px;z-index:9999}.jex-container.jex-pos-left{right:auto;left:24px;align-items:flex-start}:host(.jex-mode-embedded){display:block;width:100%;height:100%}:host(.jex-mode-embedded) .jex-widget{width:100%;height:100%}.jex-embedded{display:flex;flex-direction:column;width:100%;height:100%;background:var(--jex-bg-window);border:1px solid var(--jex-border-window);overflow:hidden}.jex-embedded .jex-screen-container{flex:1;overflow:hidden;display:flex;flex-direction:column}.jex-floating-button{height:56px;min-width:56px;padding:0;background:var(--jex-bg-trigger);color:var(--jex-text-header);border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:var(--jex-shadow);transition:transform .3s cubic-bezier(.175,.885,.32,1.275),background .2s,width .3s ease,border-radius .3s ease}.jex-floating-button.jex-has-label{min-width:110px;padding:0 20px}.jex-fab-inner{display:flex;align-items:center;gap:12px}.jex-fab-label{font-size:15px;font-weight:600;white-space:nowrap}.jex-floating-button:hover{transform:scale(1.1);background:var(--jex-primary-hover)}.jex-floating-button:active{transform:scale(.95)}.jex-chat-window{width:var(--jex-window-width);height:var(--jex-window-height);max-height:calc(100vh - 120px);background:var(--jex-bg-window);backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);border:1px solid var(--jex-border-window);border-radius:calc(var(--jex-radius) * 2);box-shadow:var(--jex-shadow);display:flex;flex-direction:column;overflow:hidden;animation:jexSlideUp .4s cubic-bezier(.16,1,.3,1);transform-origin:bottom right}@keyframes jexSlideUp{0%{opacity:0;transform:scale(.8) translateY(20px)}to{opacity:1;transform:scale(1) translateY(0)}}.jex-chat-header{padding:20px;background:var(--jex-bg-header);color:var(--jex-text-header);display:flex;align-items:center;gap:12px;flex-shrink:0}.jex-header-info h3{font-size:16px;font-weight:600;color:var(--jex-text-header);margin:0}.jex-header-info p{font-size:12px;opacity:.8;color:var(--jex-text-header);margin:0}.jex-header-back{background:none;border:none;color:var(--jex-text-header);cursor:pointer;padding:4px;display:flex;align-items:center;opacity:.8;transition:opacity .2s;flex-shrink:0}.jex-header-back:hover{opacity:1}.jex-screen-container{flex:1;overflow:hidden;display:flex;flex-direction:column}.jex-home{flex:1;display:flex;flex-direction:column;padding:24px;gap:20px;overflow-y:auto}.jex-home-hero{display:flex;align-items:center;gap:14px;animation:jexFadeIn .4s ease both}.jex-home-avatar{position:relative;width:48px;height:48px;border-radius:14px;background:var(--jex-primary);color:var(--jex-text-header);display:flex;align-items:center;justify-content:center;flex-shrink:0;box-shadow:0 4px 12px color-mix(in srgb,var(--jex-primary) 30%,transparent)}.jex-home-status-dot{position:absolute;bottom:-2px;right:-2px;width:14px;height:14px;border-radius:50%;background:#22c55e;border:2.5px solid var(--jex-bg-window);animation:jexPulse 2s ease-in-out infinite}@keyframes jexPulse{0%,to{box-shadow:0 0 #22c55e66}50%{box-shadow:0 0 0 6px #22c55e00}}.jex-home-hero-text{display:flex;flex-direction:column;gap:2px;min-width:0}.jex-home-title{font-size:17px;font-weight:700;color:var(--jex-text-main);margin:0;line-height:1.2;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.jex-home-status{font-size:12px;font-weight:500;color:#22c55e;letter-spacing:.02em}.jex-home-greeting{background:var(--jex-bg-msg-bot);border:1px solid var(--jex-border-window);border-radius:4px 16px 16px;padding:16px 18px;font-size:14px;line-height:1.55;color:var(--jex-text-main);animation:jexFadeIn .4s .1s ease both}.jex-home-greeting p{margin:0}@keyframes jexFadeIn{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.jex-home-actions{display:flex;flex-direction:column;gap:10px;animation:jexFadeIn .4s .2s ease both}.jex-home-start-btn{background:var(--jex-bg-send-btn);color:var(--jex-text-header);border:none;border-radius:12px;padding:14px 20px;font-size:15px;font-weight:600;cursor:pointer;font-family:inherit;transition:background .2s,transform .15s,box-shadow .2s;width:100%;box-shadow:0 2px 8px color-mix(in srgb,var(--jex-primary) 25%,transparent)}.jex-home-start-btn:hover{background:var(--jex-primary-hover);transform:translateY(-1px);box-shadow:0 4px 16px color-mix(in srgb,var(--jex-primary) 35%,transparent)}.jex-home-start-btn:active{transform:translateY(0);box-shadow:0 1px 4px color-mix(in srgb,var(--jex-primary) 20%,transparent)}.jex-home-resume-card{display:flex;flex-direction:column;gap:8px;width:100%;text-align:left;padding:16px 18px;border-radius:14px;border:1.5px solid var(--jex-primary);background:color-mix(in srgb,var(--jex-primary) 6%,var(--jex-bg-window));cursor:pointer;font-family:inherit;transition:background .2s,border-color .2s,transform .15s,box-shadow .2s;box-shadow:0 2px 8px color-mix(in srgb,var(--jex-primary) 12%,transparent)}.jex-home-resume-card:hover{background:color-mix(in srgb,var(--jex-primary) 10%,var(--jex-bg-window));transform:translateY(-1px);box-shadow:0 4px 16px color-mix(in srgb,var(--jex-primary) 20%,transparent)}.jex-home-resume-card:active{transform:translateY(0)}.jex-home-resume-top{display:flex;align-items:center;justify-content:space-between}.jex-home-resume-label{font-size:14px;font-weight:600;color:var(--jex-primary)}.jex-home-resume-arrow{color:var(--jex-primary);opacity:.6;transition:opacity .2s,transform .2s}.jex-home-resume-card:hover .jex-home-resume-arrow{opacity:1;transform:translate(2px)}.jex-home-resume-ref{font-family:ui-monospace,Cascadia Code,Fira Code,monospace;font-size:13px;font-weight:600;letter-spacing:.06em;color:var(--jex-text-muted)}.jex-home-new-btn{background:transparent;color:var(--jex-text-muted);border:1px solid var(--jex-border-input);border-radius:12px;padding:12px 20px;font-size:14px;font-weight:500;cursor:pointer;font-family:inherit;transition:color .2s,border-color .2s,background .2s;width:100%}.jex-home-new-btn:hover{color:var(--jex-text-main);border-color:var(--jex-text-muted);background:color-mix(in srgb,var(--jex-primary) 3%,transparent)}.jex-session-ref{display:flex;align-items:center;gap:8px;padding:8px 12px;background:var(--jex-bg-msg-bot);border:1px solid var(--jex-border-window);border-radius:8px;font-size:12px}.jex-session-ref-label{color:var(--jex-text-muted);font-weight:500}.jex-session-ref-code{color:var(--jex-primary);font-weight:700;font-family:ui-monospace,Cascadia Code,monospace;letter-spacing:.05em}.jex-chat-messages{flex:1;padding:20px;overflow-y:auto;display:flex;flex-direction:column;gap:12px}.jex-message-row{display:flex;align-items:flex-end;gap:8px;max-width:85%}.jex-message-row.bot{align-self:flex-start}.jex-message-content{flex:1;min-width:0}.jex-avatar{width:24px;height:24px;border-radius:50%;flex-shrink:0;display:flex;align-items:center;justify-content:center;font-size:12px;margin-bottom:2px}.jex-avatar-bot{background:var(--jex-bg-msg-bot);color:var(--jex-primary)}.jex-avatar-agent{background:var(--jex-bg-avatar-agent)}.jex-avatar-img{width:100%;height:100%;border-radius:50%;object-fit:cover}.jex-avatar-initials{font-size:9px;font-weight:700;color:var(--jex-text-avatar-agent)}.jex-message-author-row{display:flex;align-items:center;gap:6px;margin-top:2px;padding-left:4px}.jex-message-author{font-size:10px;color:var(--jex-text-muted)}.jex-reply-tag-btn{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;padding:0;border:none;border-radius:4px;background:transparent;color:var(--jex-text-muted, #6b7280);cursor:pointer;transition:background .15s,color .15s}.jex-reply-tag-btn:hover{background:#0000000f;color:var(--jex-primary, #115A62)}.jex-reply-tag-btn:focus-visible{outline:2px solid var(--jex-primary, #115A62);outline-offset:1px}.jex-message{padding:12px 16px;border-radius:18px;font-size:14px;line-height:1.4}.jex-message.bot{background:var(--jex-bg-msg-bot);border:1px solid var(--jex-border-window);color:var(--jex-text-msg-bot);border-bottom-left-radius:4px}.jex-message.user{align-self:flex-end;max-width:80%;background:var(--jex-bg-msg-user);color:var(--jex-text-msg-user);border-bottom-right-radius:4px}.jex-typing{align-self:flex-start;display:flex;gap:4px;padding:12px 16px}.jex-typing span{width:8px;height:8px;border-radius:50%;background:var(--jex-text-muted);animation:jexTypingDot 1.2s infinite ease-in-out}.jex-typing span:nth-child(2){animation-delay:.2s}.jex-typing span:nth-child(3){animation-delay:.4s}@keyframes jexTypingDot{0%,80%,to{transform:scale(.8);opacity:.4}40%{transform:scale(1);opacity:1}}.jex-md{word-break:break-word;overflow-wrap:anywhere}.jex-md p{margin:0 0 8px}.jex-md p:last-child{margin-bottom:0}.jex-md strong{font-weight:600}.jex-md em{font-style:italic}.jex-md ul,.jex-md ol{margin:0 0 8px;padding-left:20px}.jex-md ul:last-child,.jex-md ol:last-child{margin-bottom:0}.jex-md ul{list-style-type:disc}.jex-md ol{list-style-type:decimal}.jex-md li{margin-bottom:2px}.jex-md li:last-child{margin-bottom:0}.jex-md a{color:var(--jex-primary);text-decoration:underline;text-underline-offset:2px}.jex-md a:hover{opacity:.8}.jex-md code{background:#00000014;padding:1px 5px;border-radius:4px;font-size:.9em;font-family:ui-monospace,Cascadia Code,Fira Code,monospace}.jex-md pre{background:#0000000f;border-radius:8px;padding:10px 12px;margin:0 0 8px;overflow-x:auto;font-size:.85em}.jex-md pre:last-child{margin-bottom:0}.jex-md pre code{background:none;padding:0;border-radius:0;font-size:inherit}.jex-md h1,.jex-md h2,.jex-md h3,.jex-md h4{font-weight:600;margin:8px 0 4px}.jex-md h1:first-child,.jex-md h2:first-child,.jex-md h3:first-child,.jex-md h4:first-child{margin-top:0}.jex-md h3{font-size:1em}.jex-md h4{font-size:.95em}.jex-md hr{border:none;border-top:1px solid var(--jex-border-window);margin:8px 0}.jex-md blockquote{border-left:3px solid var(--jex-primary);margin:0 0 8px;padding:4px 12px;color:var(--jex-text-muted)}.jex-md blockquote:last-child{margin-bottom:0}.dark .jex-md code,.jex-widget.dark .jex-md code{background:#ffffff1a}.dark .jex-md pre,.jex-widget.dark .jex-md pre{background:#ffffff14}@media(prefers-color-scheme:dark){:host:not(.light) .jex-widget:not(.light) .jex-md code{background:#ffffff1a}:host:not(.light) .jex-widget:not(.light) .jex-md pre{background:#ffffff14}}.jex-streaming-cursor:after{content:"◊";margin-left:2px;animation:jexBlinkCursor .8s ease-in-out infinite}@keyframes jexBlinkCursor{0%,to{opacity:1}50%{opacity:0}}.jex-session-notice{align-self:center;text-align:center;padding:8px 16px;margin:8px 0;font-size:12px;color:var(--jex-text-muted);background:var(--jex-bg-input, #f1f5f9);border-radius:8px;line-height:1.4}.jex-message-error{background:var(--jex-bg-error, #fef2f2)!important;border-color:var(--jex-border-error, #fecaca)!important;color:var(--jex-text-error, #991b1b)!important}.jex-chat-input{padding:16px;border-top:1px solid var(--jex-border-window);display:flex;gap:8px;flex-shrink:0;flex-wrap:wrap}.jex-rate-limit-notice{flex:1 0 100%;order:-1;margin-bottom:8px;padding:8px 12px;border-radius:10px;background:var(--jex-bg-msg-bot, #f1f5f9);color:var(--jex-text-muted, #64748b);font-size:12px;line-height:1.4;text-align:center}.jex-chat-input input{flex:1;background:var(--jex-bg-input);border:1px solid var(--jex-border-input);border-radius:12px;padding:10px 14px;color:var(--jex-text-main);outline:none;font-family:inherit;font-size:14px}.jex-chat-input input:focus{border-color:var(--jex-primary)}.jex-send-btn{background:var(--jex-bg-send-btn);color:var(--jex-text-header);border:none;border-radius:12px;width:40px;height:40px;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .2s cubic-bezier(.175,.885,.32,1.275);flex-shrink:0}.jex-send-btn:hover{transform:scale(1.05);background:var(--jex-primary-hover)}.jex-send-btn:active{transform:scale(.95)}.jex-widget-footer{display:flex;align-items:center;justify-content:center;padding:8px 16px;border-top:1px solid var(--jex-border-glass);background:#00000005;flex-shrink:0}.jex-widget.dark .jex-widget-footer{background:#ffffff05}@media(prefers-color-scheme:dark){:host:not(.light) .jex-widget:not(.light) .jex-widget-footer{background:#ffffff05}}.jex-branding{display:flex;align-items:center;gap:6px;text-decoration:none;color:var(--jex-text-muted);font-size:11px;font-weight:500;transition:color .2s}.jex-branding:hover{color:var(--jex-text-main)}.jex-branding-icon{color:var(--jex-primary)}.jex-branding span strong{font-weight:700;color:var(--jex-text-main)}.jex-locale-select-wrapper{position:relative;display:flex;align-items:center}.jex-locale-select{appearance:none;-webkit-appearance:none;background:transparent;border:1px solid transparent;padding:4px 20px 4px 6px;border-radius:6px;font-family:inherit;font-size:11px;font-weight:600;color:var(--jex-text-muted);background-color:transparent;cursor:pointer;outline:none;transition:all .2s ease}.jex-locale-select option{background-color:#fff;color:#0f172a}.jex-locale-select:hover,.jex-locale-select:focus-visible{color:var(--jex-text-main);background:#0000000a}.jex-widget.dark .jex-locale-select:hover,.jex-widget.dark .jex-locale-select:focus-visible{background:#ffffff0d}.jex-widget.dark .jex-locale-select option{background-color:#0f172a;color:#f8fafc}@media(prefers-color-scheme:dark){:host:not(.light) .jex-widget:not(.light) .jex-locale-select:hover,:host:not(.light) .jex-widget:not(.light) .jex-locale-select:focus-visible{background:#ffffff0d}:host:not(.light) .jex-widget:not(.light) .jex-locale-select option{background-color:#0f172a;color:#f8fafc}}.jex-locale-select:focus-visible{border-color:var(--jex-primary)}.jex-locale-chevron{position:absolute;right:4px;pointer-events:none;color:var(--jex-text-muted);transition:color .2s ease}.jex-locale-select-wrapper:hover .jex-locale-chevron{color:var(--jex-text-main)}.jex-overlay{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;background:var(--jex-bg-window, #fff);z-index:10;padding:24px;text-align:center}.jex-loading-spinner{width:32px;height:32px;border:3px solid var(--jex-border-input, #e2e8f0);border-top-color:var(--jex-primary, #115A62);border-radius:50%;animation:jex-spin .7s linear infinite}@keyframes jex-spin{to{transform:rotate(360deg)}}.jex-loading-message{font-size:14px;color:var(--jex-text-muted, #64748b)}.jex-error-message{font-size:14px;color:var(--jex-text-main, #334155)}.jex-error-actions{display:flex;gap:8px}.jex-error-retry,.jex-error-back{padding:8px 16px;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;border:none}.jex-error-retry{background:var(--jex-primary, #115A62);color:#fff}.jex-error-back{background:transparent;color:var(--jex-text-muted, #64748b);border:1px solid var(--jex-border-input, #e2e8f0)}.jex-selection{display:flex;flex-direction:column;gap:12px;padding:24px 16px;height:100%}.jex-selection-title{font-size:16px;font-weight:700;color:var(--jex-text-main, #0f172a);margin:0 0 8px}.jex-selection-options{display:flex;flex-direction:column;gap:10px}.jex-selection-option{display:flex;flex-direction:column;align-items:flex-start;gap:2px;padding:16px;border-radius:12px;border:1px solid var(--jex-border-window, #e2e8f0);background:transparent;cursor:pointer;text-align:left;transition:border-color .15s ease,background .15s ease}.jex-selection-option:hover{border-color:var(--jex-primary, #115A62);background:color-mix(in srgb,var(--jex-primary, #115A62) 5%,transparent)}.jex-selection-icon{font-size:20px}.jex-selection-label{font-size:14px;font-weight:600;color:var(--jex-text-main, #0f172a)}.jex-selection-sub{font-size:12px;color:var(--jex-text-muted, #64748b)}.jex-form-screen{display:flex;flex-direction:column;padding:20px 16px;height:100%;overflow-y:auto}.jex-form-title{font-size:16px;font-weight:700;color:var(--jex-text-main, #0f172a);margin:0 0 16px}.jex-form{display:flex;flex-direction:column;gap:10px}.jex-form-input,.jex-form-textarea{padding:10px 12px;border-radius:8px;border:1px solid var(--jex-border-input, #e2e8f0);font-size:14px;background:transparent;color:var(--jex-text-main, #0f172a);outline:none}.jex-form-input:focus,.jex-form-textarea:focus{border-color:var(--jex-primary, #115A62)}.jex-form-textarea{min-height:80px;resize:vertical}.jex-form-submit{padding:10px;border-radius:8px;border:none;background:var(--jex-primary, #115A62);color:#fff;font-size:14px;font-weight:600;cursor:pointer;margin-top:4px}.jex-inline-form{display:flex;flex-direction:column;gap:8px;padding:12px;background:var(--jex-bg-msg-bot, #f1f5f9);border:1px solid var(--jex-border-input, #e2e8f0);border-radius:var(--jex-radius, .75rem);width:100%}.jex-inline-form-title{font-weight:600;font-size:15px;color:var(--jex-text-main, #0f172a);margin:0}.jex-inline-form-subtitle{font-size:13px;color:var(--jex-text-muted, #64748b);line-height:1.4;margin:0 0 4px}.jex-inline-form-consent{font-size:11px;color:var(--jex-text-muted, #64748b);line-height:1.3;margin-top:4px;text-align:center}.jex-inline-form .jex-form-submit:disabled{opacity:.7;cursor:not-allowed}.jex-escalation-subtitle{font-size:13px;color:var(--jex-text-muted, #64748b);line-height:1.45;margin:0 0 8px}.jex-escalation-skip{padding:8px 12px;border:none;background:transparent;color:var(--jex-text-muted, #64748b);font-size:13px;cursor:pointer;text-decoration:underline;text-underline-offset:2px;text-align:center}.jex-escalation-skip:hover{color:var(--jex-text-main, #0f172a)}.jex-inline-form-card{position:relative;padding:14px;gap:8px}.jex-inline-form-dismiss{position:absolute;top:10px;right:10px;width:24px;height:24px;border-radius:50%;border:1px solid var(--jex-border-input, #e2e8f0);background:var(--jex-bg-window, #fff);color:var(--jex-text-muted, #64748b);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;line-height:1}.jex-inline-form-dismiss:hover{background:var(--jex-bg-msg-bot, #f1f5f9);color:var(--jex-text-main, #0f172a)}.jex-inline-form-submitted{display:flex;align-items:center;gap:10px;padding:10px 12px;background:var(--jex-bg-msg-bot, #f1f5f9);border:1px solid var(--jex-border-input, #e2e8f0);border-radius:var(--jex-radius, .75rem);width:100%}.jex-inline-form-check{display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:50%;background:color-mix(in srgb,var(--jex-primary) 15%,transparent);color:var(--jex-primary, #115A62);font-size:14px;font-weight:700;flex-shrink:0}.jex-inline-form-submitted-title{font-weight:600;font-size:var(--jex-font-size, 14px);color:var(--jex-text-main, #0f172a)}.jex-inline-form-submitted-detail{font-size:12px;color:var(--jex-text-muted, #64748b);margin-top:2px}.jex-escalation-confirm{border-left:3px solid var(--jex-primary, #115A62);padding-left:8px}.jex-session-prompt{display:flex;flex-direction:column;align-items:center;gap:8px;padding:12px 16px;margin:8px 0;text-align:center}.jex-session-prompt-text{font-size:13px;color:var(--jex-text-muted, #64748b)}.jex-session-prompt-btn{padding:8px 16px;border-radius:8px;border:1px solid var(--jex-primary, #115A62);background:transparent;color:var(--jex-primary, #115A62);font-size:13px;font-weight:600;cursor:pointer}.jex-session-prompt-btn:hover{background:color-mix(in srgb,var(--jex-primary) 10%,transparent)}.jex-chat-input-resolved{display:flex;flex-direction:column;align-items:center;gap:10px;padding:14px 16px;border-top:1px solid var(--jex-border-input, #e2e8f0);background:var(--jex-bg-msg-bot, #f1f5f9);text-align:center}.jex-resolved-notice{font-size:13px;font-weight:500;color:var(--jex-text-muted, #64748b)}.jex-resolved-new-btn{padding:10px 20px;border-radius:8px;border:none;background:var(--jex-primary, #115A62);color:#fff;font-size:13px;font-weight:600;cursor:pointer;width:100%}.jex-resolved-new-btn:hover{opacity:.9}.jex-confirmation{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:32px 24px;height:100%;text-align:center}.jex-confirmation-icon{width:48px;height:48px;border-radius:50%;background:color-mix(in srgb,var(--jex-primary, #115A62) 15%,transparent);color:var(--jex-primary, #115A62);font-size:22px;display:flex;align-items:center;justify-content:center}.jex-confirmation-title{font-size:18px;font-weight:700;color:var(--jex-text-main, #0f172a);margin:0}.jex-confirmation-body{font-size:13px;color:var(--jex-text-muted, #64748b);margin:0}.jex-confirmation-ref{font-size:20px;font-weight:700;letter-spacing:.05em;color:var(--jex-primary, #115A62);background:color-mix(in srgb,var(--jex-primary, #115A62) 10%,transparent);padding:10px 20px;border-radius:10px}.jex-confirmation-hint{font-size:12px;color:var(--jex-text-muted, #64748b);margin:0}.jex-confirmation-done{margin-top:8px;padding:10px 28px;border-radius:8px;border:none;background:var(--jex-primary, #115A62);color:#fff;font-size:14px;font-weight:600;cursor:pointer}.jex-home-lookup-link{background:none;border:none;font-size:12px;color:var(--jex-text-muted, #64748b);cursor:pointer;text-decoration:underline;padding:0;align-self:center}.jex-home-lookup{display:flex;gap:8px;width:100%;animation:jexFadeIn .4s .1s ease both}.jex-home-lookup-input{flex:1;padding:10px 14px;border-radius:10px;border:1px solid var(--jex-border-input, #e2e8f0);background:var(--jex-bg-input);color:var(--jex-text-main);font-size:13px;font-family:ui-monospace,Cascadia Code,Fira Code,monospace;letter-spacing:.04em;outline:none;transition:border-color .2s}.jex-home-lookup-input::placeholder{font-family:inherit;letter-spacing:.04em;color:var(--jex-text-muted);opacity:.7}.jex-home-lookup-input:focus{border-color:var(--jex-primary, #115A62)}.jex-home-lookup-submit{padding:10px 16px;border-radius:10px;border:none;background:var(--jex-primary, #115A62);color:#fff;font-size:13px;font-weight:600;cursor:pointer;font-family:inherit;transition:background .2s,opacity .2s;flex-shrink:0}.jex-home-lookup-submit:hover:not(:disabled){background:var(--jex-primary-hover)}.jex-home-lookup-submit:disabled{opacity:.4;cursor:default}.jex-sources-row{margin-top:6px;margin-left:32px;display:flex;flex-direction:column;gap:6px}.jex-sources-toggle{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;background:transparent;border:none;border-radius:6px;cursor:pointer;font-size:11px;color:var(--jex-text-muted, #6b7280);font-family:inherit;align-self:flex-start;transition:background .15s,color .15s}.jex-sources-toggle:hover{background:#0000000a;color:inherit}.jex-sources-icon{font-size:12px;line-height:1}.jex-sources-chevron{display:inline-block;font-size:10px;transition:transform .15s}.jex-sources-chevron--open{transform:rotate(180deg)}.jex-sources-pills{display:flex;flex-wrap:wrap;align-items:center;gap:6px}.jex-source-pill{display:inline-flex;align-items:center;gap:6px;max-width:240px;padding:2px 8px;border-radius:999px;border:1px solid rgba(0,0,0,.1);background:#0000000a;color:var(--jex-text-muted, #6b7280);font-size:11px;text-decoration:none;cursor:pointer;transition:background .15s,color .15s}.jex-source-pill:hover{background:#00000014;color:inherit}.jex-source-id{display:inline-flex;align-items:center;justify-content:center;min-width:16px;height:16px;padding:0 4px;border-radius:4px;background:var(--jex-primary, #115A62);color:#fff;font-size:10px;font-weight:600;line-height:1;flex-shrink:0;font-variant-numeric:tabular-nums}.jex-source-type{font-size:10px;flex-shrink:0}.jex-source-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}.jex-source-score{opacity:.6;flex-shrink:0;font-variant-numeric:tabular-nums}';function sc(t){const e=document.createElement("style");e.textContent=ic,t.appendChild(e)}const oc="https://tame-spider-109.eu-west-1.convex.cloud";let An=null;function ac(t){const e=t??oc;if(!e)throw new Error("[jexity] No Convex URL — set VITE_CONVEX_URL at build time or data-convex-url on the script tag");return An||(An=new Yo(ma(e))),An}function lc(t,e){const n=t.shadowRoot??t.attachShadow({mode:"open"});for(;n.firstChild;)n.removeChild(n.firstChild);sc(n),wt.value=e.source,kt.value=e.bootstrapToken,D.value=[{id:"home"}],e.mode==="embedded"&&(t.classList.add("jex-mode-embedded"),A.value=!0);const r=document.createElement("div");return e.mode==="embedded"&&(r.style.cssText="width:100%;height:100%"),n.appendChild(r),he(u(ta,{client:ac(e.convexUrl),children:u(rc,{options:e})}),r),function(){he(null,r),A.value=!1,wt.value=void 0,kt.value=void 0,D.value=[{id:"home"}]}}function cc(t,e,n){const r=lc(t,e),i=new Set,s=A.subscribe(l=>{for(const a of i)a(l)});return{shutdown(){s(),i.clear(),r(),n&&n()},open(){A.value=!0},close(){A.value=!1},toggle(){A.value=!A.value},get isOpen(){return A.value},subscribe(l){return i.add(l),()=>{i.delete(l)}}}}let rt=null;function uc(t){rt&&rt.shutdown();let e;t.container?e=typeof t.container=="string"?document.querySelector(t.container):t.container:(e=document.createElement("div"),e.id="jexity-chat-widget",document.body.appendChild(e));const n=cc(e,t,()=>{t.container||e.remove(),rt===n&&(rt=null)});return rt=n,n}function le(t,e){return t.getAttribute(e)??void 0}async function Di(){const t=document.currentScript??document.querySelector("script[data-org-slug]")??document.querySelector("script[data-org-id]");if(!t)return;const e=t.getAttribute("data-org-slug")??t.getAttribute("data-org-id")??"default-org",n=t.getAttribute("data-proj-slug")??void 0,r=le(t,"data-convex-url")??"https://tame-spider-109.eu-west-1.convex.cloud"??"",i=dn(r),s=await pi(e,i,n);if(!s.ok){const l=window.location.origin,a=n?`project '${e}/${n}'`:`org '${e}'`;s.error==="unauthorized"?console.warn(`[JexityChat] This domain is not authorized for ${a}. Add '${l}' under Allowed Domains in your Jexity dashboard.`):s.error==="not_found"?console.warn(`[JexityChat] No active widget config found for ${a}. Check that the org slug is correct and the widget is enabled.`):s.error==="rate_limited"?console.warn(`[JexityChat] Bootstrap rate-limited for ${a}. Retry after ${s.retryAfterSec??60}s.`):console.warn(`[JexityChat] Bootstrap failed (network error). Check that the Convex deployment is reachable at ${i}.`);return}const o={orgSlug:e,projSlug:n,bootstrapToken:s.token,position:le(t,"data-position")??void 0,theme:le(t,"data-theme")??void 0,greeting:le(t,"data-greeting"),title:le(t,"data-title"),primaryColor:le(t,"data-primary-color"),locale:le(t,"data-locale"),convexUrl:le(t,"data-convex-url")};window.JexityChat=uc(o)}document.readyState==="complete"?Di():window.addEventListener("load",Di)})();
|
|
61
|
+
${r.url}`:r.title,a=u(N,{children:[typeof r.id=="number"?u("span",{class:"jex-source-id",children:r.id}):null,u("span",{class:"jex-source-type",children:Dl[r.sourceType]}),u("span",{class:"jex-source-label",children:o}),u("span",{class:"jex-source-score",children:["· ",r.score.toFixed(2)]})]});return s&&r.url?u("a",{class:"jex-source-pill",href:r.url,target:"_blank",rel:"noopener noreferrer",title:l,children:a},i):u("span",{class:"jex-source-pill",title:l,children:a},i)})}):null]})}function Vl(t){if(t.sourceType==="crawl"&&t.url)try{const e=new URL(t.url);return!e.pathname||e.pathname==="/"?e.hostname:e.pathname}catch{}return t.title}function Wl(){return u("div",{class:"jex-typing",children:[u("span",{}),u("span",{}),u("span",{})]})}const Hl=/\s?\[\d+\]/g;function Bi(t){return t.replace(Hl,"")}function Jl({conversations:t,greeting:e,sessionNotFound:n,resumeFailed:r,onStartFresh:i,sessionId:s,visitorId:o}){const l=q(),a=Be(null),[h,d]=T(null);return M(()=>{a.current?.scrollIntoView({behavior:"smooth"})},[t?.length,t?.at(-1)?.content]),u("div",{class:"jex-chat-messages",children:[u(Pe,{text:e}),n&&r&&i?u("div",{class:"jex-session-prompt",children:[u("div",{class:"jex-session-prompt-text",children:l.sessionNotFoundPrompt}),u("button",{class:"jex-session-prompt-btn",type:"button",onClick:()=>{i()},children:l.startNewConversation})]}):n?u("div",{class:"jex-session-notice",children:l.sessionNotFound}):null,t?.map(c=>{if(c.contentType==="human-notice")return u(Pe,{text:c.content},c._id);if(c.contentType==="escalation-form"&&s&&o)return Ea.value==="screen"&&!c.formData?h===c._id?null:u("div",{class:"jex-inline-form jex-inline-form-card",children:[u("div",{class:"jex-inline-form-title",children:l.escalationPromptTitle}),u("div",{class:"jex-inline-form-subtitle",children:l.escalationPromptSubtitle}),u("button",{class:"jex-form-submit",type:"button",onClick:()=>{$e({id:"escalation-form",formMessageId:c._id,sessionId:s,visitorId:o})},children:l.escalationPromptSubmit}),u("button",{class:"jex-escalation-skip",type:"button",onClick:()=>{d(c._id)},children:l.escalationSkip})]},c._id):u(Ql,{message:c,sessionId:s,visitorId:o},c._id);if(c.contentType==="escalation-confirm")return u(Pe,{text:c.content},c._id);if(c.role==="user")return u(Bl,{text:c.content},c._id);const p={authorId:c.authorId,authorName:c.authorName,authorImage:c.authorImage};return c.status==="streaming"&&c.content===""?u(Wl,{},c._id):c.status==="streaming"?u(Pe,{text:Bi(c.content),streaming:!0,...p},c._id):c.status==="error"?u(Pe,{text:c.errorMessage??`${l.somethingWentWrong}. ${l.tryAgain}.`,error:!0,...p},c._id):u("div",{children:[u(Pe,{text:Bi(c.content),...p}),c.sources&&c.sources.length>0?u(Ul,{sources:c.sources}):null]},c._id)}),u("div",{ref:a})]})}function Gl({size:t=18}){return u("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[u("path",{d:"M22 2 11 13"}),u("path",{d:"M22 2 15 22 11 13 2 9l20-7z"})]})}function Kl(){const t=q(),e=fa(()=>{const n=ae.value;return n===null?0:Math.max(0,Math.ceil((n-zi.value)/1e3))});return M(()=>{const n=ae.value;if(n===null)return;const r=setInterval(()=>{zi.value=Date.now()},1e3),i=setTimeout(()=>{ae.value=null},Math.max(0,n-Date.now()));return()=>{clearInterval(r),clearTimeout(i)}},[ae.value]),ae.value===null?null:u("div",{class:"jex-rate-limit-notice",role:"status","aria-live":"polite",children:t.errorRateLimited.replace("{seconds}",String(e.value))})}function Zl({sessionId:t,visitorId:e,isLoading:n,isStreaming:r,sessionStatus:i,ensureSession:s,onStartFresh:o}){const l=q(),a=$n,h=mt(Ie.functions.chat.public.conversations.send),d=ae.value!==null&&ae.value>Date.now(),c=n||r||d;if(i==="resolved")return u("div",{class:"jex-chat-input-resolved",children:[u("div",{class:"jex-resolved-notice",children:l.sessionResolved}),u("button",{class:"jex-resolved-new-btn",type:"button",onClick:()=>{o()},children:l.startNewConversation})]});async function p(){const f=a.value.trim();if(!f||c)return;const g=t&&e?{sessionId:t,visitorId:e}:await s();if(g){Aa(),a.value="";try{const x=await h({sessionId:g.sessionId,visitorId:g.visitorId,content:f});!x.ok&&x.reason==="rate_limited"&&(ae.value=Date.now()+x.retryAfterMs)}catch(x){console.error("[jexity] Failed to send message:",x)}}}return u("div",{class:"jex-chat-input",children:[u(Kl,{}),u("input",{type:"text","aria-label":l.inputPlaceholder,placeholder:r?l.aiThinking:l.inputPlaceholder,value:a.value,onInput:f=>{a.value=f.currentTarget.value},onKeyDown:f=>{f.key==="Enter"&&p()},disabled:n||r}),u("button",{class:"jex-send-btn",onClick:p,"aria-label":l.sendAriaLabel,disabled:c,children:u(Gl,{size:18})})]})}function Qi({message:t}){return u("div",{class:"jex-overlay jex-loading",children:[u("div",{class:"jex-loading-spinner","aria-hidden":"true"}),t&&u("p",{class:"jex-loading-message",children:t})]})}function Xl({greeting:t,orgSlug:e,projSlug:n}){const r=q(),{sessionId:i,visitorId:s,isLoading:o,sessionNotFound:l,resumeFailed:a,isOrgDeleted:h,ensureSession:d,startFresh:c}=Fa(e,n),p=ri(Ie.functions.chat.public.conversations.listBySession,i&&s?{sessionId:i,visitorId:s}:"skip"),f=ri(Ie.functions.chat.public.sessions.getSessionStatus,i&&s?{sessionId:i,visitorId:s}:"skip"),g=i!==null&&p===void 0,x=p?.some(k=>k.status==="streaming")??!1;return M(()=>{ge.value&&!i&&d()},[d,i]),h?u("div",{class:"jex-chat-messages",children:u("div",{class:"jex-session-notice",children:r.chatNoLongerAvailable})}):o||g&&ge.value?u(Qi,{message:r.resumeConversation}):u(N,{children:[u(Jl,{conversations:p,greeting:t,sessionNotFound:l,resumeFailed:a,onStartFresh:c,sessionId:i,visitorId:s}),u(Zl,{sessionId:i,visitorId:s,isLoading:o,isStreaming:x,sessionStatus:f??null,ensureSession:d,onStartFresh:c})]})}function Yl({formMessageId:t,sessionId:e,visitorId:n}){const r=q(),[i,s]=T(""),[o,l]=T(""),a=mt(Ie.functions.chat.public.helpdesk.submitEscalation);async function h(d){d.preventDefault(),Ae({id:"loading",message:r.escalationSubmitting});try{const c=await a({sessionId:e,visitorId:n,formMessageId:t,visitorName:i.trim(),visitorEmail:o.trim()});Ae({id:"confirmation",ref:c.ticketRef})}catch(c){console.error("[EscalationFormScreen] Submit failed:",c),Ae({id:"error",message:r.escalationSubmitFailed})}}return u("div",{class:"jex-form-screen",children:[u("h2",{class:"jex-form-title",children:r.escalationFormTitle}),u("p",{class:"jex-escalation-subtitle",children:r.escalationSubtitle}),u("form",{class:"jex-form",onSubmit:d=>{h(d)},children:[u("input",{class:"jex-form-input",type:"text",placeholder:r.escalationNameLabel,value:i,required:!0,onInput:d=>{s(d.currentTarget.value)}}),u("input",{class:"jex-form-input",type:"email",placeholder:r.escalationEmailLabel,value:o,required:!0,onInput:d=>{l(d.currentTarget.value)}}),u("button",{class:"jex-form-submit",type:"submit",children:r.escalationSubmit})]}),u("div",{class:"jex-inline-form-consent",style:{textAlign:"center",margin:"16px 0 8px 0"},children:r.escalationConsent}),u("button",{class:"jex-escalation-skip",type:"button",onClick:()=>{xn()},children:r.escalationSkip})]})}function ec(){const t=q(),[e,n]=T(""),[r,i]=T(""),[s,o]=T("");async function l(a){a.preventDefault(),Ae({id:"loading",message:t.submittingTicket}),await new Promise(d=>{setTimeout(d,1200)});const h="JEX-"+Math.random().toString(36).slice(2,8).toUpperCase();Ae({id:"confirmation",ref:h})}return u("div",{class:"jex-form-screen",children:[u("h2",{class:"jex-form-title",children:t.submitTicket}),u("form",{class:"jex-form",onSubmit:a=>{l(a)},children:[u("input",{class:"jex-form-input",type:"text",placeholder:t.yourName,value:e,required:!0,onInput:a=>{n(a.currentTarget.value)}}),u("input",{class:"jex-form-input",type:"email",placeholder:t.yourEmail,value:r,required:!0,onInput:a=>{i(a.currentTarget.value)}}),u("textarea",{class:"jex-form-textarea",placeholder:t.howCanWeHelp,value:s,required:!0,onInput:a=>{o(a.currentTarget.value)}}),u("button",{class:"jex-form-submit",type:"submit",children:t.submit})]})]})}function tc({ticketRef:t}){const e=q();return u("div",{class:"jex-confirmation",children:[u("div",{class:"jex-confirmation-icon","aria-hidden":"true",children:"✓"}),u("h2",{class:"jex-confirmation-title",children:e.ticketSubmitted}),u("p",{class:"jex-confirmation-body",children:e.yourReferenceNumber}),u("div",{class:"jex-confirmation-ref",children:t}),u("p",{class:"jex-confirmation-hint",children:e.sentToEmailHint}),u("button",{class:"jex-confirmation-done",onClick:()=>{A.value=!1},children:e.done})]})}function nc({message:t,onRetry:e,onBack:n}){const r=q();return u("div",{class:"jex-overlay jex-error",children:[u("p",{class:"jex-error-message",children:t}),u("div",{class:"jex-error-actions",children:[e&&u("button",{class:"jex-error-retry",onClick:e,children:r.tryAgain}),n&&u("button",{class:"jex-error-back",onClick:n,children:r.goBack})]})]})}function Fi({greeting:t,title:e,orgSlug:n,projSlug:r}){const i=D.value,s=i[i.length-1],o=i.findLast(l=>l.id==="confirmation");return u("div",{class:"jex-screen-container",children:[s.id==="home"&&u(za,{greeting:t,title:e}),s.id==="selection"&&u(Ba,{title:e}),s.id==="form"&&u(ec,{}),s.id==="escalation-form"&&u(Yl,{formMessageId:s.formMessageId,sessionId:s.sessionId,visitorId:s.visitorId}),s.id==="confirmation"&&o&&u(tc,{ticketRef:o.ref}),s.id==="chat"&&u(Xl,{greeting:t,orgSlug:n,projSlug:r}),s.id==="loading"&&u(Qi,{message:s.message}),s.id==="error"&&u(nc,{message:s.message,onRetry:()=>Ae({id:"loading"}),onBack:xn})]})}function rc({options:t}){va(t.orgSlug,t.projSlug,t.bootstrapToken,t.convexUrl);const e=ya(t.orgSlug,t.projSlug,t.convexUrl);Ca(t.parentOrigin),M(()=>{Ta()},[]);const n=xa(t,e);M(()=>{fn.value=mi(n.locale)},[n.locale]);const r=n.position==="bottom-left",i=n.colorScheme==="dark"||n.colorScheme==="light"?n.colorScheme:"",s=Ia({...t,primaryColor:n.primaryColor,accentColor:n.accentColor,fontFamily:n.fontFamily,fontSize:n.fontSize,borderRadius:n.borderRadius,windowWidth:n.windowWidth,windowHeight:n.windowHeight}),o=n.mode==="embedded",a=e!==null||o||!!t.parentOrigin?s:{...s,visibility:"hidden"};return u("div",{class:`jex-widget ${i}`.trim(),style:a,children:o?u("div",{class:"jex-embedded",children:[u(xi,{title:n.title}),u(Fi,{greeting:n.greeting,title:n.title,orgSlug:t.orgSlug,projSlug:t.projSlug}),!n.hideBranding&&u(bi,{})]}):u("div",{class:`jex-container${r?" jex-pos-left":""}`,children:[A.value&&u("div",{class:"jex-chat-window",children:[u(xi,{title:n.title}),u(Fi,{greeting:n.greeting,title:n.title,orgSlug:t.orgSlug,projSlug:t.projSlug}),!n.hideBranding&&u(bi,{})]}),u(Na,{iconOption:n.triggerIcon,radius:n.triggerRadius,label:n.triggerLabel})]})})}const ic='.jex-widget{--jex-primary: #115A62;--jex-primary-hover: var(--jex-accent, color-mix(in srgb, var(--jex-primary) 85%, #000));--jex-radius: .75rem;--jex-font-family: "Inter", system-ui, -apple-system, sans-serif;--jex-font-size: 14px;--jex-window-width: 380px;--jex-window-height: 600px;--jex-shadow: 0 16px 48px -12px rgba(13, 127, 138, .25), 0 4px 16px rgba(0, 0, 0, .08);pointer-events:auto;--jex-bg-trigger: var(--jex-primary);--jex-bg-header: var(--jex-primary);--jex-bg-msg-user: var(--jex-primary);--jex-bg-send-btn: var(--jex-primary);--jex-bg-window: rgba(255, 255, 255, .95);--jex-bg-msg-bot: #f1f5f9;--jex-bg-input: rgba(247, 253, 253, .6);--jex-text-header: #ffffff;--jex-text-msg-user: #ffffff;--jex-text-msg-bot: #0f172a;--jex-text-main: #0f172a;--jex-text-muted: #64748b;--jex-bg-avatar-agent: #d1fae5;--jex-text-avatar-agent: #065f46;--jex-border-window: rgba(226, 232, 240, .8);--jex-border-input: rgba(203, 213, 225, .8);--jex-bg-glass: var(--jex-bg-window);--jex-border-glass: var(--jex-border-window);font-family:var(--jex-font-family);-webkit-font-smoothing:antialiased}.dark .jex-widget,.jex-widget.dark{--jex-primary: #1cb0bf;--jex-primary-hover: var(--jex-accent, color-mix(in srgb, var(--jex-primary) 85%, #000));--jex-bg-window: rgba(10, 15, 26, .95);--jex-bg-msg-bot: #233146;--jex-bg-input: rgba(10, 15, 26, .6);--jex-text-msg-bot: #f8fafc;--jex-text-main: #f8fafc;--jex-text-muted: #94a3b8;--jex-border-window: rgba(30, 41, 59, .8);--jex-border-input: rgba(51, 65, 85, .9);--jex-bg-avatar-agent: #064e3b;--jex-text-avatar-agent: #6ee7b7;--jex-bg-error: #3b1318;--jex-border-error: #5c1d24;--jex-text-error: #fca5a5}@media(prefers-color-scheme:dark){:host:not(.light) .jex-widget:not(.light){--jex-primary: #1cb0bf;--jex-primary-hover: var(--jex-accent, color-mix(in srgb, var(--jex-primary) 85%, #000));--jex-bg-window: rgba(10, 15, 26, .95);--jex-bg-msg-bot: #233146;--jex-bg-input: rgba(10, 15, 26, .6);--jex-text-msg-bot: #f8fafc;--jex-text-main: #f8fafc;--jex-text-muted: #94a3b8;--jex-border-window: rgba(30, 41, 59, .8);--jex-border-input: rgba(51, 65, 85, .9);--jex-bg-error: #3b1318;--jex-border-error: #5c1d24;--jex-text-error: #fca5a5}}.jex-widget *{box-sizing:border-box;margin:0;padding:0}.jex-container{position:fixed;bottom:24px;right:24px;display:flex;flex-direction:column;align-items:flex-end;gap:16px;z-index:9999}.jex-container.jex-pos-left{right:auto;left:24px;align-items:flex-start}:host(.jex-mode-embedded){display:block;width:100%;height:100%}:host(.jex-mode-embedded) .jex-widget{width:100%;height:100%}.jex-embedded{display:flex;flex-direction:column;width:100%;height:100%;background:var(--jex-bg-window);border:1px solid var(--jex-border-window);overflow:hidden}.jex-embedded .jex-screen-container{flex:1;overflow:hidden;display:flex;flex-direction:column}.jex-floating-button{height:56px;min-width:56px;padding:0;background:var(--jex-bg-trigger);color:var(--jex-text-header);border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:var(--jex-shadow);transition:transform .3s cubic-bezier(.175,.885,.32,1.275),background .2s,width .3s ease,border-radius .3s ease}.jex-floating-button.jex-has-label{min-width:110px;padding:0 20px}.jex-fab-inner{display:flex;align-items:center;gap:12px}.jex-fab-label{font-size:15px;font-weight:600;white-space:nowrap}.jex-floating-button:hover{transform:scale(1.1);background:var(--jex-primary-hover)}.jex-floating-button:active{transform:scale(.95)}.jex-chat-window{width:var(--jex-window-width);height:var(--jex-window-height);max-height:calc(100vh - 120px);background:var(--jex-bg-window);backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);border:1px solid var(--jex-border-window);border-radius:calc(var(--jex-radius) * 2);box-shadow:var(--jex-shadow);display:flex;flex-direction:column;overflow:hidden;animation:jexSlideUp .4s cubic-bezier(.16,1,.3,1);transform-origin:bottom right}@keyframes jexSlideUp{0%{opacity:0;transform:scale(.8) translateY(20px)}to{opacity:1;transform:scale(1) translateY(0)}}.jex-chat-header{padding:20px;background:var(--jex-bg-header);color:var(--jex-text-header);display:flex;align-items:center;gap:12px;flex-shrink:0}.jex-header-info h3{font-size:16px;font-weight:600;color:var(--jex-text-header);margin:0}.jex-header-info p{font-size:12px;opacity:.8;color:var(--jex-text-header);margin:0}.jex-header-back{background:none;border:none;color:var(--jex-text-header);cursor:pointer;padding:4px;display:flex;align-items:center;opacity:.8;transition:opacity .2s;flex-shrink:0}.jex-header-back:hover{opacity:1}.jex-screen-container{flex:1;overflow:hidden;display:flex;flex-direction:column}.jex-home{flex:1;display:flex;flex-direction:column;padding:24px;gap:20px;overflow-y:auto}.jex-home-hero{display:flex;align-items:center;gap:14px;animation:jexFadeIn .4s ease both}.jex-home-avatar{position:relative;width:48px;height:48px;border-radius:14px;background:var(--jex-primary);color:var(--jex-text-header);display:flex;align-items:center;justify-content:center;flex-shrink:0;box-shadow:0 4px 12px color-mix(in srgb,var(--jex-primary) 30%,transparent)}.jex-home-status-dot{position:absolute;bottom:-2px;right:-2px;width:14px;height:14px;border-radius:50%;background:#22c55e;border:2.5px solid var(--jex-bg-window);animation:jexPulse 2s ease-in-out infinite}@keyframes jexPulse{0%,to{box-shadow:0 0 #22c55e66}50%{box-shadow:0 0 0 6px #22c55e00}}.jex-home-hero-text{display:flex;flex-direction:column;gap:2px;min-width:0}.jex-home-title{font-size:17px;font-weight:700;color:var(--jex-text-main);margin:0;line-height:1.2;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.jex-home-status{font-size:12px;font-weight:500;color:#22c55e;letter-spacing:.02em}.jex-home-greeting{background:var(--jex-bg-msg-bot);border:1px solid var(--jex-border-window);border-radius:4px 16px 16px;padding:16px 18px;font-size:14px;line-height:1.55;color:var(--jex-text-main);animation:jexFadeIn .4s .1s ease both}.jex-home-greeting p{margin:0}@keyframes jexFadeIn{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.jex-home-actions{display:flex;flex-direction:column;gap:10px;animation:jexFadeIn .4s .2s ease both}.jex-home-start-btn{background:var(--jex-bg-send-btn);color:var(--jex-text-header);border:none;border-radius:12px;padding:14px 20px;font-size:15px;font-weight:600;cursor:pointer;font-family:inherit;transition:background .2s,transform .15s,box-shadow .2s;width:100%;box-shadow:0 2px 8px color-mix(in srgb,var(--jex-primary) 25%,transparent)}.jex-home-start-btn:hover{background:var(--jex-primary-hover);transform:translateY(-1px);box-shadow:0 4px 16px color-mix(in srgb,var(--jex-primary) 35%,transparent)}.jex-home-start-btn:active{transform:translateY(0);box-shadow:0 1px 4px color-mix(in srgb,var(--jex-primary) 20%,transparent)}.jex-home-resume-card{display:flex;flex-direction:column;gap:8px;width:100%;text-align:left;padding:16px 18px;border-radius:14px;border:1.5px solid var(--jex-primary);background:color-mix(in srgb,var(--jex-primary) 6%,var(--jex-bg-window));cursor:pointer;font-family:inherit;transition:background .2s,border-color .2s,transform .15s,box-shadow .2s;box-shadow:0 2px 8px color-mix(in srgb,var(--jex-primary) 12%,transparent)}.jex-home-resume-card:hover{background:color-mix(in srgb,var(--jex-primary) 10%,var(--jex-bg-window));transform:translateY(-1px);box-shadow:0 4px 16px color-mix(in srgb,var(--jex-primary) 20%,transparent)}.jex-home-resume-card:active{transform:translateY(0)}.jex-home-resume-top{display:flex;align-items:center;justify-content:space-between}.jex-home-resume-label{font-size:14px;font-weight:600;color:var(--jex-primary)}.jex-home-resume-arrow{color:var(--jex-primary);opacity:.6;transition:opacity .2s,transform .2s}.jex-home-resume-card:hover .jex-home-resume-arrow{opacity:1;transform:translate(2px)}.jex-home-resume-ref{font-family:ui-monospace,Cascadia Code,Fira Code,monospace;font-size:13px;font-weight:600;letter-spacing:.06em;color:var(--jex-text-muted)}.jex-home-new-btn{background:transparent;color:var(--jex-text-muted);border:1px solid var(--jex-border-input);border-radius:12px;padding:12px 20px;font-size:14px;font-weight:500;cursor:pointer;font-family:inherit;transition:color .2s,border-color .2s,background .2s;width:100%}.jex-home-new-btn:hover{color:var(--jex-text-main);border-color:var(--jex-text-muted);background:color-mix(in srgb,var(--jex-primary) 3%,transparent)}.jex-session-ref{display:flex;align-items:center;gap:8px;padding:8px 12px;background:var(--jex-bg-msg-bot);border:1px solid var(--jex-border-window);border-radius:8px;font-size:12px}.jex-session-ref-label{color:var(--jex-text-muted);font-weight:500}.jex-session-ref-code{color:var(--jex-primary);font-weight:700;font-family:ui-monospace,Cascadia Code,monospace;letter-spacing:.05em}.jex-chat-messages{flex:1;padding:20px;overflow-y:auto;display:flex;flex-direction:column;gap:12px}.jex-message-row{display:flex;align-items:flex-end;gap:8px;max-width:85%}.jex-message-row.bot{align-self:flex-start}.jex-message-content{flex:1;min-width:0}.jex-avatar{width:24px;height:24px;border-radius:50%;flex-shrink:0;display:flex;align-items:center;justify-content:center;font-size:12px;margin-bottom:2px}.jex-avatar-bot{background:var(--jex-bg-msg-bot);color:var(--jex-primary)}.jex-avatar-agent{background:var(--jex-bg-avatar-agent)}.jex-avatar-img{width:100%;height:100%;border-radius:50%;object-fit:cover}.jex-avatar-initials{font-size:9px;font-weight:700;color:var(--jex-text-avatar-agent)}.jex-message-author-row{display:flex;align-items:center;gap:6px;margin-top:2px;padding-left:4px}.jex-message-author{font-size:10px;color:var(--jex-text-muted)}.jex-reply-tag-btn{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;padding:0;border:none;border-radius:4px;background:transparent;color:var(--jex-text-muted, #6b7280);cursor:pointer;transition:background .15s,color .15s}.jex-reply-tag-btn:hover{background:#0000000f;color:var(--jex-primary, #115A62)}.jex-reply-tag-btn:focus-visible{outline:2px solid var(--jex-primary, #115A62);outline-offset:1px}.jex-message{padding:12px 16px;border-radius:18px;font-size:14px;line-height:1.4}.jex-message.bot{background:var(--jex-bg-msg-bot);border:1px solid var(--jex-border-window);color:var(--jex-text-msg-bot);border-bottom-left-radius:4px}.jex-message.user{align-self:flex-end;max-width:80%;background:var(--jex-bg-msg-user);color:var(--jex-text-msg-user);border-bottom-right-radius:4px}.jex-typing{align-self:flex-start;display:flex;gap:4px;padding:12px 16px}.jex-typing span{width:8px;height:8px;border-radius:50%;background:var(--jex-text-muted);animation:jexTypingDot 1.2s infinite ease-in-out}.jex-typing span:nth-child(2){animation-delay:.2s}.jex-typing span:nth-child(3){animation-delay:.4s}@keyframes jexTypingDot{0%,80%,to{transform:scale(.8);opacity:.4}40%{transform:scale(1);opacity:1}}.jex-md{word-break:break-word;overflow-wrap:anywhere}.jex-md p{margin:0 0 8px}.jex-md p:last-child{margin-bottom:0}.jex-md strong{font-weight:600}.jex-md em{font-style:italic}.jex-md ul,.jex-md ol{margin:0 0 8px;padding-left:20px}.jex-md ul:last-child,.jex-md ol:last-child{margin-bottom:0}.jex-md ul{list-style-type:disc}.jex-md ol{list-style-type:decimal}.jex-md li{margin-bottom:2px}.jex-md li:last-child{margin-bottom:0}.jex-md a{color:var(--jex-primary);text-decoration:underline;text-underline-offset:2px}.jex-md a:hover{opacity:.8}.jex-md code{background:#00000014;padding:1px 5px;border-radius:4px;font-size:.9em;font-family:ui-monospace,Cascadia Code,Fira Code,monospace}.jex-md pre{background:#0000000f;border-radius:8px;padding:10px 12px;margin:0 0 8px;overflow-x:auto;font-size:.85em}.jex-md pre:last-child{margin-bottom:0}.jex-md pre code{background:none;padding:0;border-radius:0;font-size:inherit}.jex-md h1,.jex-md h2,.jex-md h3,.jex-md h4{font-weight:600;margin:8px 0 4px}.jex-md h1:first-child,.jex-md h2:first-child,.jex-md h3:first-child,.jex-md h4:first-child{margin-top:0}.jex-md h3{font-size:1em}.jex-md h4{font-size:.95em}.jex-md hr{border:none;border-top:1px solid var(--jex-border-window);margin:8px 0}.jex-md blockquote{border-left:3px solid var(--jex-primary);margin:0 0 8px;padding:4px 12px;color:var(--jex-text-muted)}.jex-md blockquote:last-child{margin-bottom:0}.dark .jex-md code,.jex-widget.dark .jex-md code{background:#ffffff1a}.dark .jex-md pre,.jex-widget.dark .jex-md pre{background:#ffffff14}@media(prefers-color-scheme:dark){:host:not(.light) .jex-widget:not(.light) .jex-md code{background:#ffffff1a}:host:not(.light) .jex-widget:not(.light) .jex-md pre{background:#ffffff14}}.jex-streaming-cursor:after{content:"◊";margin-left:2px;animation:jexBlinkCursor .8s ease-in-out infinite}@keyframes jexBlinkCursor{0%,to{opacity:1}50%{opacity:0}}.jex-session-notice{align-self:center;text-align:center;padding:8px 16px;margin:8px 0;font-size:12px;color:var(--jex-text-muted);background:var(--jex-bg-input, #f1f5f9);border-radius:8px;line-height:1.4}.jex-message-error{background:var(--jex-bg-error, #fef2f2)!important;border-color:var(--jex-border-error, #fecaca)!important;color:var(--jex-text-error, #991b1b)!important}.jex-chat-input{padding:16px;border-top:1px solid var(--jex-border-window);display:flex;gap:8px;flex-shrink:0;flex-wrap:wrap}.jex-rate-limit-notice{flex:1 0 100%;order:-1;margin-bottom:8px;padding:8px 12px;border-radius:10px;background:var(--jex-bg-msg-bot, #f1f5f9);color:var(--jex-text-muted, #64748b);font-size:12px;line-height:1.4;text-align:center}.jex-chat-input input{flex:1;background:var(--jex-bg-input);border:1px solid var(--jex-border-input);border-radius:12px;padding:10px 14px;color:var(--jex-text-main);outline:none;font-family:inherit;font-size:14px}.jex-chat-input input:focus{border-color:var(--jex-primary)}.jex-send-btn{background:var(--jex-bg-send-btn);color:var(--jex-text-header);border:none;border-radius:12px;width:40px;height:40px;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .2s cubic-bezier(.175,.885,.32,1.275);flex-shrink:0}.jex-send-btn:hover{transform:scale(1.05);background:var(--jex-primary-hover)}.jex-send-btn:active{transform:scale(.95)}.jex-widget-footer{display:flex;align-items:center;justify-content:center;padding:8px 16px;border-top:1px solid var(--jex-border-glass);background:#00000005;flex-shrink:0}.jex-widget.dark .jex-widget-footer{background:#ffffff05}@media(prefers-color-scheme:dark){:host:not(.light) .jex-widget:not(.light) .jex-widget-footer{background:#ffffff05}}.jex-branding{display:flex;align-items:center;gap:6px;text-decoration:none;color:var(--jex-text-muted);font-size:11px;font-weight:500;transition:color .2s}.jex-branding:hover{color:var(--jex-text-main)}.jex-branding-icon{color:var(--jex-primary)}.jex-branding span strong{font-weight:700;color:var(--jex-text-main)}.jex-locale-select-wrapper{position:relative;display:flex;align-items:center}.jex-locale-select{appearance:none;-webkit-appearance:none;background:transparent;border:1px solid transparent;padding:4px 20px 4px 6px;border-radius:6px;font-family:inherit;font-size:11px;font-weight:600;color:var(--jex-text-muted);background-color:transparent;cursor:pointer;outline:none;transition:all .2s ease}.jex-locale-select option{background-color:#fff;color:#0f172a}.jex-locale-select:hover,.jex-locale-select:focus-visible{color:var(--jex-text-main);background:#0000000a}.jex-widget.dark .jex-locale-select:hover,.jex-widget.dark .jex-locale-select:focus-visible{background:#ffffff0d}.jex-widget.dark .jex-locale-select option{background-color:#0f172a;color:#f8fafc}@media(prefers-color-scheme:dark){:host:not(.light) .jex-widget:not(.light) .jex-locale-select:hover,:host:not(.light) .jex-widget:not(.light) .jex-locale-select:focus-visible{background:#ffffff0d}:host:not(.light) .jex-widget:not(.light) .jex-locale-select option{background-color:#0f172a;color:#f8fafc}}.jex-locale-select:focus-visible{border-color:var(--jex-primary)}.jex-locale-chevron{position:absolute;right:4px;pointer-events:none;color:var(--jex-text-muted);transition:color .2s ease}.jex-locale-select-wrapper:hover .jex-locale-chevron{color:var(--jex-text-main)}.jex-overlay{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;background:var(--jex-bg-window, #fff);z-index:10;padding:24px;text-align:center}.jex-loading-spinner{width:32px;height:32px;border:3px solid var(--jex-border-input, #e2e8f0);border-top-color:var(--jex-primary, #115A62);border-radius:50%;animation:jex-spin .7s linear infinite}@keyframes jex-spin{to{transform:rotate(360deg)}}.jex-loading-message{font-size:14px;color:var(--jex-text-muted, #64748b)}.jex-error-message{font-size:14px;color:var(--jex-text-main, #334155)}.jex-error-actions{display:flex;gap:8px}.jex-error-retry,.jex-error-back{padding:8px 16px;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;border:none}.jex-error-retry{background:var(--jex-primary, #115A62);color:#fff}.jex-error-back{background:transparent;color:var(--jex-text-muted, #64748b);border:1px solid var(--jex-border-input, #e2e8f0)}.jex-selection{display:flex;flex-direction:column;gap:12px;padding:24px 16px;height:100%}.jex-selection-title{font-size:16px;font-weight:700;color:var(--jex-text-main, #0f172a);margin:0 0 8px}.jex-selection-options{display:flex;flex-direction:column;gap:10px}.jex-selection-option{display:flex;flex-direction:column;align-items:flex-start;gap:2px;padding:16px;border-radius:12px;border:1px solid var(--jex-border-window, #e2e8f0);background:transparent;cursor:pointer;text-align:left;transition:border-color .15s ease,background .15s ease}.jex-selection-option:hover{border-color:var(--jex-primary, #115A62);background:color-mix(in srgb,var(--jex-primary, #115A62) 5%,transparent)}.jex-selection-icon{font-size:20px}.jex-selection-label{font-size:14px;font-weight:600;color:var(--jex-text-main, #0f172a)}.jex-selection-sub{font-size:12px;color:var(--jex-text-muted, #64748b)}.jex-form-screen{display:flex;flex-direction:column;padding:20px 16px;height:100%;overflow-y:auto}.jex-form-title{font-size:16px;font-weight:700;color:var(--jex-text-main, #0f172a);margin:0 0 16px}.jex-form{display:flex;flex-direction:column;gap:10px}.jex-form-input,.jex-form-textarea{padding:10px 12px;border-radius:8px;border:1px solid var(--jex-border-input, #e2e8f0);font-size:14px;background:transparent;color:var(--jex-text-main, #0f172a);outline:none}.jex-form-input:focus,.jex-form-textarea:focus{border-color:var(--jex-primary, #115A62)}.jex-form-textarea{min-height:80px;resize:vertical}.jex-form-submit{padding:10px;border-radius:8px;border:none;background:var(--jex-primary, #115A62);color:#fff;font-size:14px;font-weight:600;cursor:pointer;margin-top:4px}.jex-inline-form{display:flex;flex-direction:column;gap:8px;padding:12px;background:var(--jex-bg-msg-bot, #f1f5f9);border:1px solid var(--jex-border-input, #e2e8f0);border-radius:var(--jex-radius, .75rem);width:100%}.jex-inline-form-title{font-weight:600;font-size:15px;color:var(--jex-text-main, #0f172a);margin:0}.jex-inline-form-subtitle{font-size:13px;color:var(--jex-text-muted, #64748b);line-height:1.4;margin:0 0 4px}.jex-inline-form-consent{font-size:11px;color:var(--jex-text-muted, #64748b);line-height:1.3;margin-top:4px;text-align:center}.jex-inline-form .jex-form-submit:disabled{opacity:.7;cursor:not-allowed}.jex-escalation-subtitle{font-size:13px;color:var(--jex-text-muted, #64748b);line-height:1.45;margin:0 0 8px}.jex-escalation-skip{padding:8px 12px;border:none;background:transparent;color:var(--jex-text-muted, #64748b);font-size:13px;cursor:pointer;text-decoration:underline;text-underline-offset:2px;text-align:center}.jex-escalation-skip:hover{color:var(--jex-text-main, #0f172a)}.jex-inline-form-card{position:relative;padding:14px;gap:8px}.jex-inline-form-dismiss{position:absolute;top:10px;right:10px;width:24px;height:24px;border-radius:50%;border:1px solid var(--jex-border-input, #e2e8f0);background:var(--jex-bg-window, #fff);color:var(--jex-text-muted, #64748b);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;line-height:1}.jex-inline-form-dismiss:hover{background:var(--jex-bg-msg-bot, #f1f5f9);color:var(--jex-text-main, #0f172a)}.jex-inline-form-submitted{display:flex;align-items:center;gap:10px;padding:10px 12px;background:var(--jex-bg-msg-bot, #f1f5f9);border:1px solid var(--jex-border-input, #e2e8f0);border-radius:var(--jex-radius, .75rem);width:100%}.jex-inline-form-check{display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:50%;background:color-mix(in srgb,var(--jex-primary) 15%,transparent);color:var(--jex-primary, #115A62);font-size:14px;font-weight:700;flex-shrink:0}.jex-inline-form-submitted-title{font-weight:600;font-size:var(--jex-font-size, 14px);color:var(--jex-text-main, #0f172a)}.jex-inline-form-submitted-detail{font-size:12px;color:var(--jex-text-muted, #64748b);margin-top:2px}.jex-escalation-confirm{border-left:3px solid var(--jex-primary, #115A62);padding-left:8px}.jex-session-prompt{display:flex;flex-direction:column;align-items:center;gap:8px;padding:12px 16px;margin:8px 0;text-align:center}.jex-session-prompt-text{font-size:13px;color:var(--jex-text-muted, #64748b)}.jex-session-prompt-btn{padding:8px 16px;border-radius:8px;border:1px solid var(--jex-primary, #115A62);background:transparent;color:var(--jex-primary, #115A62);font-size:13px;font-weight:600;cursor:pointer}.jex-session-prompt-btn:hover{background:color-mix(in srgb,var(--jex-primary) 10%,transparent)}.jex-chat-input-resolved{display:flex;flex-direction:column;align-items:center;gap:10px;padding:14px 16px;border-top:1px solid var(--jex-border-input, #e2e8f0);background:var(--jex-bg-msg-bot, #f1f5f9);text-align:center}.jex-resolved-notice{font-size:13px;font-weight:500;color:var(--jex-text-muted, #64748b)}.jex-resolved-new-btn{padding:10px 20px;border-radius:8px;border:none;background:var(--jex-primary, #115A62);color:#fff;font-size:13px;font-weight:600;cursor:pointer;width:100%}.jex-resolved-new-btn:hover{opacity:.9}.jex-confirmation{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:32px 24px;height:100%;text-align:center}.jex-confirmation-icon{width:48px;height:48px;border-radius:50%;background:color-mix(in srgb,var(--jex-primary, #115A62) 15%,transparent);color:var(--jex-primary, #115A62);font-size:22px;display:flex;align-items:center;justify-content:center}.jex-confirmation-title{font-size:18px;font-weight:700;color:var(--jex-text-main, #0f172a);margin:0}.jex-confirmation-body{font-size:13px;color:var(--jex-text-muted, #64748b);margin:0}.jex-confirmation-ref{font-size:20px;font-weight:700;letter-spacing:.05em;color:var(--jex-primary, #115A62);background:color-mix(in srgb,var(--jex-primary, #115A62) 10%,transparent);padding:10px 20px;border-radius:10px}.jex-confirmation-hint{font-size:12px;color:var(--jex-text-muted, #64748b);margin:0}.jex-confirmation-done{margin-top:8px;padding:10px 28px;border-radius:8px;border:none;background:var(--jex-primary, #115A62);color:#fff;font-size:14px;font-weight:600;cursor:pointer}.jex-home-lookup-link{background:none;border:none;font-size:12px;color:var(--jex-text-muted, #64748b);cursor:pointer;text-decoration:underline;padding:0;align-self:center}.jex-home-lookup{display:flex;gap:8px;width:100%;animation:jexFadeIn .4s .1s ease both}.jex-home-lookup-input{flex:1;padding:10px 14px;border-radius:10px;border:1px solid var(--jex-border-input, #e2e8f0);background:var(--jex-bg-input);color:var(--jex-text-main);font-size:13px;font-family:ui-monospace,Cascadia Code,Fira Code,monospace;letter-spacing:.04em;outline:none;transition:border-color .2s}.jex-home-lookup-input::placeholder{font-family:inherit;letter-spacing:.04em;color:var(--jex-text-muted);opacity:.7}.jex-home-lookup-input:focus{border-color:var(--jex-primary, #115A62)}.jex-home-lookup-submit{padding:10px 16px;border-radius:10px;border:none;background:var(--jex-primary, #115A62);color:#fff;font-size:13px;font-weight:600;cursor:pointer;font-family:inherit;transition:background .2s,opacity .2s;flex-shrink:0}.jex-home-lookup-submit:hover:not(:disabled){background:var(--jex-primary-hover)}.jex-home-lookup-submit:disabled{opacity:.4;cursor:default}.jex-sources-row{margin-top:6px;margin-left:32px;display:flex;flex-direction:column;gap:6px}.jex-sources-toggle{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;background:transparent;border:none;border-radius:6px;cursor:pointer;font-size:11px;color:var(--jex-text-muted, #6b7280);font-family:inherit;align-self:flex-start;transition:background .15s,color .15s}.jex-sources-toggle:hover{background:#0000000a;color:inherit}.jex-sources-icon{font-size:12px;line-height:1}.jex-sources-chevron{display:inline-block;font-size:10px;transition:transform .15s}.jex-sources-chevron--open{transform:rotate(180deg)}.jex-sources-pills{display:flex;flex-wrap:wrap;align-items:center;gap:6px}.jex-source-pill{display:inline-flex;align-items:center;gap:6px;max-width:240px;padding:2px 8px;border-radius:999px;border:1px solid rgba(0,0,0,.1);background:#0000000a;color:var(--jex-text-muted, #6b7280);font-size:11px;text-decoration:none;cursor:pointer;transition:background .15s,color .15s}.jex-source-pill:hover{background:#00000014;color:inherit}.jex-source-id{display:inline-flex;align-items:center;justify-content:center;min-width:16px;height:16px;padding:0 4px;border-radius:4px;background:var(--jex-primary, #115A62);color:#fff;font-size:10px;font-weight:600;line-height:1;flex-shrink:0;font-variant-numeric:tabular-nums}.jex-source-type{font-size:10px;flex-shrink:0}.jex-source-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}.jex-source-score{opacity:.6;flex-shrink:0;font-variant-numeric:tabular-nums}';function sc(t){const e=document.createElement("style");e.textContent=ic,t.appendChild(e)}const oc="https://festive-mouse-978.eu-west-1.convex.cloud";let An=null;function ac(t){const e=t??oc;if(!e)throw new Error("[jexity] No Convex URL — set VITE_CONVEX_URL at build time or data-convex-url on the script tag");return An||(An=new Yo(ma(e))),An}function lc(t,e){const n=t.shadowRoot??t.attachShadow({mode:"open"});for(;n.firstChild;)n.removeChild(n.firstChild);sc(n),wt.value=e.source,kt.value=e.bootstrapToken,D.value=[{id:"home"}],e.mode==="embedded"&&(t.classList.add("jex-mode-embedded"),A.value=!0);const r=document.createElement("div");return e.mode==="embedded"&&(r.style.cssText="width:100%;height:100%"),n.appendChild(r),he(u(ta,{client:ac(e.convexUrl),children:u(rc,{options:e})}),r),function(){he(null,r),A.value=!1,wt.value=void 0,kt.value=void 0,D.value=[{id:"home"}]}}function cc(t,e,n){const r=lc(t,e),i=new Set,s=A.subscribe(l=>{for(const a of i)a(l)});return{shutdown(){s(),i.clear(),r(),n&&n()},open(){A.value=!0},close(){A.value=!1},toggle(){A.value=!A.value},get isOpen(){return A.value},subscribe(l){return i.add(l),()=>{i.delete(l)}}}}let rt=null;function uc(t){rt&&rt.shutdown();let e;t.container?e=typeof t.container=="string"?document.querySelector(t.container):t.container:(e=document.createElement("div"),e.id="jexity-chat-widget",document.body.appendChild(e));const n=cc(e,t,()=>{t.container||e.remove(),rt===n&&(rt=null)});return rt=n,n}function le(t,e){return t.getAttribute(e)??void 0}async function Di(){const t=document.currentScript??document.querySelector("script[data-org-slug]")??document.querySelector("script[data-org-id]");if(!t)return;const e=t.getAttribute("data-org-slug")??t.getAttribute("data-org-id")??"default-org",n=t.getAttribute("data-proj-slug")??void 0,r=le(t,"data-convex-url")??"https://festive-mouse-978.eu-west-1.convex.cloud"??"",i=dn(r),s=await pi(e,i,n);if(!s.ok){const l=window.location.origin,a=n?`project '${e}/${n}'`:`org '${e}'`;s.error==="unauthorized"?console.warn(`[JexityChat] This domain is not authorized for ${a}. Add '${l}' under Allowed Domains in your Jexity dashboard.`):s.error==="not_found"?console.warn(`[JexityChat] No active widget config found for ${a}. Check that the org slug is correct and the widget is enabled.`):s.error==="rate_limited"?console.warn(`[JexityChat] Bootstrap rate-limited for ${a}. Retry after ${s.retryAfterSec??60}s.`):console.warn(`[JexityChat] Bootstrap failed (network error). Check that the Convex deployment is reachable at ${i}.`);return}const o={orgSlug:e,projSlug:n,bootstrapToken:s.token,position:le(t,"data-position")??void 0,theme:le(t,"data-theme")??void 0,greeting:le(t,"data-greeting"),title:le(t,"data-title"),primaryColor:le(t,"data-primary-color"),locale:le(t,"data-locale"),convexUrl:le(t,"data-convex-url")};window.JexityChat=uc(o)}document.readyState==="complete"?Di():window.addEventListener("load",Di)})();
|
|
62
62
|
//# sourceMappingURL=widget.js.map
|