@telnyx/ai-agent-widget 0.19.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.min.js +26 -34
- package/package.json +2 -2
package/dist/bundle.min.js
CHANGED
|
@@ -1,117 +1,109 @@
|
|
|
1
|
-
(function(){"use strict";var mn,q,Zr,Ae,Jr,Qr,to,eo,Wi,zi,qi,no,gn={},io=[],pd=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,vn=Array.isArray;function Qt(e,t){for(var n in t)e[n]=t[n];return e}function Ki(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function jt(e,t,n){var i,s,o,r={};for(o in t)o=="key"?i=t[o]:o=="ref"?s=t[o]:r[o]=t[o];if(arguments.length>2&&(r.children=arguments.length>3?mn.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(o in e.defaultProps)r[o]===void 0&&(r[o]=e.defaultProps[o]);return _n(e,r,i,s,null)}function _n(e,t,n,i,s){var o={type:e,props:t,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++Zr,__i:-1,__u:0};return s==null&&q.vnode!=null&&q.vnode(o),o}function te(e){return e.children}function Kt(e,t){this.props=e,this.context=t}function We(e,t){if(t==null)return e.__?We(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?We(e):null}function so(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return so(e)}}function Xi(e){(!e.__d&&(e.__d=!0)&&Ae.push(e)&&!ti.__r++||Jr!=q.debounceRendering)&&((Jr=q.debounceRendering)||Qr)(ti)}function ti(){for(var e,t,n,i,s,o,r,a=1;Ae.length;)Ae.length>a&&Ae.sort(to),e=Ae.shift(),a=Ae.length,e.__d&&(n=void 0,s=(i=(t=e).__v).__e,o=[],r=[],t.__P&&((n=Qt({},i)).__v=i.__v+1,q.vnode&&q.vnode(n),Yi(t.__P,n,i,t.__n,t.__P.namespaceURI,32&i.__u?[s]:null,o,s??We(i),!!(32&i.__u),r),n.__v=i.__v,n.__.__k[n.__i]=n,co(o,n,r),n.__e!=s&&so(n)));ti.__r=0}function ro(e,t,n,i,s,o,r,a,l,c,d){var u,p,g,_,b,w,y=i&&i.__k||io,S=t.length;for(l=md(n,t,y,l,S),u=0;u<S;u++)(g=n.__k[u])!=null&&(p=g.__i==-1?gn:y[g.__i]||gn,g.__i=u,w=Yi(e,g,p,s,o,r,a,l,c,d),_=g.__e,g.ref&&p.ref!=g.ref&&(p.ref&&Zi(p.ref,null,g),d.push(g.ref,g.__c||_,g)),b==null&&_!=null&&(b=_),4&g.__u||p.__k===g.__k?l=oo(g,l,e):typeof g.type=="function"&&w!==void 0?l=w:_&&(l=_.nextSibling),g.__u&=-7);return n.__e=b,l}function md(e,t,n,i,s){var o,r,a,l,c,d=n.length,u=d,p=0;for(e.__k=new Array(s),o=0;o<s;o++)(r=t[o])!=null&&typeof r!="boolean"&&typeof r!="function"?(l=o+p,(r=e.__k[o]=typeof r=="string"||typeof r=="number"||typeof r=="bigint"||r.constructor==String?_n(null,r,null,null,null):vn(r)?_n(te,{children:r},null,null,null):r.constructor==null&&r.__b>0?_n(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):r).__=e,r.__b=e.__b+1,a=null,(c=r.__i=gd(r,n,l,u))!=-1&&(u--,(a=n[c])&&(a.__u|=2)),a==null||a.__v==null?(c==-1&&(s>d?p--:s<d&&p++),typeof r.type!="function"&&(r.__u|=4)):c!=l&&(c==l-1?p--:c==l+1?p++:(c>l?p--:p++,r.__u|=4))):e.__k[o]=null;if(u)for(o=0;o<d;o++)(a=n[o])!=null&&(2&a.__u)==0&&(a.__e==i&&(i=We(a)),ho(a,a));return i}function oo(e,t,n){var i,s;if(typeof e.type=="function"){for(i=e.__k,s=0;i&&s<i.length;s++)i[s]&&(i[s].__=e,t=oo(i[s],t,n));return t}e.__e!=t&&(t&&e.type&&!n.contains(t)&&(t=We(e)),n.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function ee(e,t){return t=t||[],e==null||typeof e=="boolean"||(vn(e)?e.some(function(n){ee(n,t)}):t.push(e)),t}function gd(e,t,n,i){var s,o,r=e.key,a=e.type,l=t[n];if(l===null&&e.key==null||l&&r==l.key&&a==l.type&&(2&l.__u)==0)return n;if(i>(l!=null&&(2&l.__u)==0?1:0))for(s=n-1,o=n+1;s>=0||o<t.length;){if(s>=0){if((l=t[s])&&(2&l.__u)==0&&r==l.key&&a==l.type)return s;s--}if(o<t.length){if((l=t[o])&&(2&l.__u)==0&&r==l.key&&a==l.type)return o;o++}}return-1}function ao(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||pd.test(t)?n:n+"px"}function ei(e,t,n,i,s){var o,r;t:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof i=="string"&&(e.style.cssText=i=""),i)for(t in i)n&&t in n||ao(e.style,t,"");if(n)for(t in n)i&&n[t]==i[t]||ao(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(eo,"$1")),r=t.toLowerCase(),t=r in e||t=="onFocusOut"||t=="onFocusIn"?r.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?i?n.u=i.u:(n.u=Wi,e.addEventListener(t,o?qi:zi,o)):e.removeEventListener(t,o?qi:zi,o);else{if(s=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break t}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function lo(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Wi++;else if(t.t<n.u)return;return n(q.event?q.event(t):t)}}}function Yi(e,t,n,i,s,o,r,a,l,c){var d,u,p,g,_,b,w,y,S,C,P,L,D,x,k,f,m,h=t.type;if(t.constructor!=null)return null;128&n.__u&&(l=!!(32&n.__u),o=[a=t.__e=n.__e]),(d=q.__b)&&d(t);t:if(typeof h=="function")try{if(y=t.props,S="prototype"in h&&h.prototype.render,C=(d=h.contextType)&&i[d.__c],P=d?C?C.props.value:d.__:i,n.__c?w=(u=t.__c=n.__c).__=u.__E:(S?t.__c=u=new h(y,P):(t.__c=u=new Kt(y,P),u.constructor=h,u.render=_d),C&&C.sub(u),u.props=y,u.state||(u.state={}),u.context=P,u.__n=i,p=u.__d=!0,u.__h=[],u._sb=[]),S&&u.__s==null&&(u.__s=u.state),S&&h.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=Qt({},u.__s)),Qt(u.__s,h.getDerivedStateFromProps(y,u.__s))),g=u.props,_=u.state,u.__v=t,p)S&&h.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),S&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(S&&h.getDerivedStateFromProps==null&&y!==g&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(y,P),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(y,u.__s,P)===!1||t.__v==n.__v){for(t.__v!=n.__v&&(u.props=y,u.state=u.__s,u.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(v){v&&(v.__=t)}),L=0;L<u._sb.length;L++)u.__h.push(u._sb[L]);u._sb=[],u.__h.length&&r.push(u);break t}u.componentWillUpdate!=null&&u.componentWillUpdate(y,u.__s,P),S&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(g,_,b)})}if(u.context=P,u.props=y,u.__P=e,u.__e=!1,D=q.__r,x=0,S){for(u.state=u.__s,u.__d=!1,D&&D(t),d=u.render(u.props,u.state,u.context),k=0;k<u._sb.length;k++)u.__h.push(u._sb[k]);u._sb=[]}else do u.__d=!1,D&&D(t),d=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++x<25);u.state=u.__s,u.getChildContext!=null&&(i=Qt(Qt({},i),u.getChildContext())),S&&!p&&u.getSnapshotBeforeUpdate!=null&&(b=u.getSnapshotBeforeUpdate(g,_)),f=d,d!=null&&d.type===te&&d.key==null&&(f=uo(d.props.children)),a=ro(e,vn(f)?f:[f],t,n,i,s,o,r,a,l,c),u.base=t.__e,t.__u&=-161,u.__h.length&&r.push(u),w&&(u.__E=u.__=null)}catch(v){if(t.__v=null,l||o!=null)if(v.then){for(t.__u|=l?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;o[o.indexOf(a)]=null,t.__e=a}else for(m=o.length;m--;)Ki(o[m]);else t.__e=n.__e,t.__k=n.__k;q.__e(v,t,n)}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):a=t.__e=vd(n.__e,t,n,i,s,o,r,l,c);return(d=q.diffed)&&d(t),128&t.__u?void 0:a}function co(e,t,n){for(var i=0;i<n.length;i++)Zi(n[i],n[++i],n[++i]);q.__c&&q.__c(t,e),e.some(function(s){try{e=s.__h,s.__h=[],e.some(function(o){o.call(s)})}catch(o){q.__e(o,s.__v)}})}function uo(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:vn(e)?e.map(uo):Qt({},e)}function vd(e,t,n,i,s,o,r,a,l){var c,d,u,p,g,_,b,w=n.props,y=t.props,S=t.type;if(S=="svg"?s="http://www.w3.org/2000/svg":S=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),o!=null){for(c=0;c<o.length;c++)if((g=o[c])&&"setAttribute"in g==!!S&&(S?g.localName==S:g.nodeType==3)){e=g,o[c]=null;break}}if(e==null){if(S==null)return document.createTextNode(y);e=document.createElementNS(s,S,y.is&&y),a&&(q.__m&&q.__m(t,o),a=!1),o=null}if(S==null)w===y||a&&e.data==y||(e.data=y);else{if(o=o&&mn.call(e.childNodes),w=n.props||gn,!a&&o!=null)for(w={},c=0;c<e.attributes.length;c++)w[(g=e.attributes[c]).name]=g.value;for(c in w)if(g=w[c],c!="children"){if(c=="dangerouslySetInnerHTML")u=g;else if(!(c in y)){if(c=="value"&&"defaultValue"in y||c=="checked"&&"defaultChecked"in y)continue;ei(e,c,null,g,s)}}for(c in y)g=y[c],c=="children"?p=g:c=="dangerouslySetInnerHTML"?d=g:c=="value"?_=g:c=="checked"?b=g:a&&typeof g!="function"||w[c]===g||ei(e,c,g,w[c],s);if(d)a||u&&(d.__html==u.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(u&&(e.innerHTML=""),ro(t.type=="template"?e.content:e,vn(p)?p:[p],t,n,i,S=="foreignObject"?"http://www.w3.org/1999/xhtml":s,o,r,o?o[0]:n.__k&&We(n,0),a,l),o!=null)for(c=o.length;c--;)Ki(o[c]);a||(c="value",S=="progress"&&_==null?e.removeAttribute("value"):_!=null&&(_!==e[c]||S=="progress"&&!_||S=="option"&&_!=w[c])&&ei(e,c,_,w[c],s),c="checked",b!=null&&b!=e[c]&&ei(e,c,b,w[c],s))}return e}function Zi(e,t,n){try{if(typeof e=="function"){var i=typeof e.__u=="function";i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(s){q.__e(s,n)}}function ho(e,t,n){var i,s;if(q.unmount&&q.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||Zi(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(o){q.__e(o,t)}i.base=i.__P=null}if(i=e.__k)for(s=0;s<i.length;s++)i[s]&&ho(i[s],t,n||typeof e.type!="function");n||Ki(e.__e),e.__c=e.__=e.__e=void 0}function _d(e,t,n){return this.constructor(e,n)}function ni(e,t,n){var i,s,o,r;t==document&&(t=document.documentElement),q.__&&q.__(e,t),s=(i=typeof n=="function")?null:n&&n.__k||t.__k,o=[],r=[],Yi(t,e=(!i&&n||t).__k=jt(te,null,[e]),s||gn,gn,t.namespaceURI,!i&&n?[n]:s?null:t.firstChild?mn.call(t.childNodes):null,o,!i&&n?n:s?s.__e:t.firstChild,i,r),co(o,e,r)}function fo(e,t){ni(e,t,fo)}function Ji(e,t,n){var i,s,o,r,a=Qt({},e.props);for(o in e.type&&e.type.defaultProps&&(r=e.type.defaultProps),t)o=="key"?i=t[o]:o=="ref"?s=t[o]:a[o]=t[o]===void 0&&r!=null?r[o]:t[o];return arguments.length>2&&(a.children=arguments.length>3?mn.call(arguments,2):n),_n(e.type,a,i||e.key,s||e.ref,null)}function Re(e){function t(n){var i,s;return this.getChildContext||(i=new Set,(s={})[t.__c]=this,this.getChildContext=function(){return s},this.componentWillUnmount=function(){i=null},this.shouldComponentUpdate=function(o){this.props.value!=o.value&&i.forEach(function(r){r.__e=!0,Xi(r)})},this.sub=function(o){i.add(o);var r=o.componentWillUnmount;o.componentWillUnmount=function(){i&&i.delete(o),r&&r.call(o)}}),n.children}return t.__c="__cC"+no++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,i){return n.children(i)}).contextType=t,t}mn=io.slice,q={__e:function(e,t,n,i){for(var s,o,r;t=t.__;)if((s=t.__c)&&!s.__)try{if((o=s.constructor)&&o.getDerivedStateFromError!=null&&(s.setState(o.getDerivedStateFromError(e)),r=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(e,i||{}),r=s.__d),r)return s.__E=s}catch(a){e=a}throw e}},Zr=0,Kt.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Qt({},this.state),typeof e=="function"&&(e=e(Qt({},n),this.props)),e&&Qt(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Xi(this))},Kt.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Xi(this))},Kt.prototype.render=te,Ae=[],Qr=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,to=function(e,t){return e.__v.__b-t.__v.__b},ti.__r=0,eo=/(PointerCapture)$|Capture$/i,Wi=0,zi=lo(!1),qi=lo(!0),no=0;var yd=0;function E(e,t,n,i,s,o){t||(t={});var r,a,l=t;if("ref"in l)for(a in l={},t)a=="ref"?r=t[a]:l[a]=t[a];var c={type:e,props:l,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--yd,__i:-1,__u:0,__source:s,__self:o};if(typeof e=="function"&&(r=e.defaultProps))for(a in r)l[a]===void 0&&(l[a]=r[a]);return q.vnode&&q.vnode(c),c}function Qi(){return(Qi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}var bd=["context","children"];function wd(e){this.getChildContext=function(){return e.context};var t=e.children,n=function(i,s){if(i==null)return{};var o,r,a={},l=Object.keys(i);for(r=0;r<l.length;r++)s.indexOf(o=l[r])>=0||(a[o]=i[o]);return a}(e,bd);return Ji(t,n)}function xd(){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=jt(wd,Qi({},this._props,{context:e.detail.context}),function t(n,i){if(n.nodeType===3)return n.data;if(n.nodeType!==1)return null;var s=[],o={},r=0,a=n.attributes,l=n.childNodes;for(r=a.length;r--;)a[r].name!=="slot"&&(o[a[r].name]=a[r].value,o[po(a[r].name)]=a[r].value);for(r=l.length;r--;){var c=t(l[r],null),d=l[r].slot;d?o[d]=jt(mo,{name:d},c):s[r]=c}var u=i?jt(mo,null,s):s;return jt(i||n.nodeName.toLowerCase(),o,u)}(this,this._vdomComponent)),(this.hasAttribute("hydrate")?fo:ni)(this._vdom,this._root)}function po(e){return e.replace(/-(\w)/g,function(t,n){return n?n.toUpperCase():""})}function Sd(e,t,n){if(this._vdom){var i={};i[e]=n=n??void 0,i[po(e)]=n,this._vdom=Ji(this._vdom,i),ni(this._vdom,this._root)}}function Cd(){ni(this._vdom=null,this._root)}function mo(e,t){var n=this;return jt("slot",Qi({},e,{ref:function(i){i?(n.ref=i,n._listener||(n._listener=function(s){s.stopPropagation(),s.detail.context=t},i.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function kd(e,t,n,i){function s(){var o=Reflect.construct(HTMLElement,[],s);return o._vdomComponent=e,o._root=i&&i.shadow?o.attachShadow({mode:i.mode||"open"}):o,o}return(s.prototype=Object.create(HTMLElement.prototype)).constructor=s,s.prototype.connectedCallback=xd,s.prototype.attributeChangedCallback=Sd,s.prototype.disconnectedCallback=Cd,n=n||e.observedAttributes||Object.keys(e.propTypes||{}),s.observedAttributes=n,n.forEach(function(o){Object.defineProperty(s.prototype,o,{get:function(){return this._vdom.props[o]},set:function(r){this._vdom?this.attributeChangedCallback(o,null,r):(this._props||(this._props={}),this._props[o]=r,this.connectedCallback());var a=typeof r;r!=null&&a!=="string"&&a!=="boolean"&&a!=="number"||this.setAttribute(o,r)}})}),customElements.define(t,s)}var ve,at,ts,go,yn=0,vo=[],pt=q,_o=pt.__b,yo=pt.__r,bo=pt.diffed,wo=pt.__c,xo=pt.unmount,So=pt.__;function ze(e,t){pt.__h&&pt.__h(at,e,yn||t),yn=0;var n=at.__H||(at.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Xt(e){return yn=1,Co(To,e)}function Co(e,t,n){var i=ze(ve++,2);if(i.t=e,!i.__c&&(i.__=[n?n(t):To(void 0,t),function(a){var l=i.__N?i.__N[0]:i.__[0],c=i.t(l,a);l!==c&&(i.__N=[c,i.__[1]],i.__c.setState({}))}],i.__c=at,!at.__f)){var s=function(a,l,c){if(!i.__c.__H)return!0;var d=i.__c.__H.__.filter(function(p){return!!p.__c});if(d.every(function(p){return!p.__N}))return!o||o.call(this,a,l,c);var u=i.__c.props!==a;return d.forEach(function(p){if(p.__N){var g=p.__[0];p.__=p.__N,p.__N=void 0,g!==p.__[0]&&(u=!0)}}),o&&o.call(this,a,l,c)||u};at.__f=!0;var o=at.shouldComponentUpdate,r=at.componentWillUpdate;at.componentWillUpdate=function(a,l,c){if(this.__e){var d=o;o=void 0,s(a,l,c),o=d}r&&r.call(this,a,l,c)},at.shouldComponentUpdate=s}return i.__N||i.__}function $t(e,t){var n=ze(ve++,3);!pt.__s&&ss(n.__H,t)&&(n.__=e,n.u=t,at.__H.__h.push(n))}function es(e,t){var n=ze(ve++,4);!pt.__s&&ss(n.__H,t)&&(n.__=e,n.u=t,at.__h.push(n))}function Mt(e){return yn=5,ne(function(){return{current:e}},[])}function ne(e,t){var n=ze(ve++,7);return ss(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function ii(e,t){return yn=8,ne(function(){return e},t)}function wt(e){var t=at.context[e.__c],n=ze(ve++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(at)),t.props.value):e.__}function Td(e,t){pt.useDebugValue&&pt.useDebugValue(t?t(e):e)}function ns(){var e=ze(ve++,11);if(!e.__){for(var t=at.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__="P"+n[0]+"-"+n[1]++}return e.__}function Ed(){for(var e;e=vo.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(si),e.__H.__h.forEach(is),e.__H.__h=[]}catch(t){e.__H.__h=[],pt.__e(t,e.__v)}}pt.__b=function(e){at=null,_o&&_o(e)},pt.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),So&&So(e,t)},pt.__r=function(e){yo&&yo(e),ve=0;var t=(at=e.__c).__H;t&&(ts===at?(t.__h=[],at.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(si),t.__h.forEach(is),t.__h=[],ve=0)),ts=at},pt.diffed=function(e){bo&&bo(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(vo.push(t)!==1&&go===pt.requestAnimationFrame||((go=pt.requestAnimationFrame)||Ad)(Ed)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ts=at=null},pt.__c=function(e,t){t.some(function(n){try{n.__h.forEach(si),n.__h=n.__h.filter(function(i){return!i.__||is(i)})}catch(i){t.some(function(s){s.__h&&(s.__h=[])}),t=[],pt.__e(i,n.__v)}}),wo&&wo(e,t)},pt.unmount=function(e){xo&&xo(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(i){try{si(i)}catch(s){t=s}}),n.__H=void 0,t&&pt.__e(t,n.__v))};var ko=typeof requestAnimationFrame=="function";function Ad(e){var t,n=function(){clearTimeout(i),ko&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(n,35);ko&&(t=requestAnimationFrame(n))}function si(e){var t=at,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),at=t}function is(e){var t=at;e.__c=e.__(),at=t}function ss(e,t){return!e||e.length!==t.length||t.some(function(n,i){return n!==e[i]})}function To(e,t){return typeof t=="function"?t(e):t}function Eo(e,t){for(var n in t)e[n]=t[n];return e}function Ao(e,t){for(var n in e)if(n!=="__source"&&!(n in t))return!0;for(var i in t)if(i!=="__source"&&e[i]!==t[i])return!0;return!1}var Ro=es;function Io(e,t){this.props=e,this.context=t}(Io.prototype=new Kt).isPureReactComponent=!0,Io.prototype.shouldComponentUpdate=function(e,t){return Ao(this.props,e)||Ao(this.state,t)};var Po=q.__b;q.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Po&&Po(e)};var Rd=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function Id(e){function t(n){var i=Eo({},n);return delete i.ref,e(i,n.ref||null)}return t.$$typeof=Rd,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var Mo=function(e,t){return e==null?null:ee(ee(e).map(t))},Pd={map:Mo,forEach:Mo,count:function(e){return e?ee(e).length:0},only:function(e){var t=ee(e);if(t.length!==1)throw"Children.only";return t[0]},toArray:ee},Md=q.__e;q.__e=function(e,t,n,i){if(e.then){for(var s,o=t;o=o.__;)if((s=o.__c)&&s.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),s.__c(e,t)}Md(e,t,n,i)};var Lo=q.unmount;function Do(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(i){typeof i.__c=="function"&&i.__c()}),e.__c.__H=null),(e=Eo({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(i){return Do(i,t,n)})),e}function Oo(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(i){return Oo(i,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function rs(){this.__u=0,this.o=null,this.__b=null}function No(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function ri(){this.i=null,this.l=null}q.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Lo&&Lo(e)},(rs.prototype=new Kt).__c=function(e,t){var n=t.__c,i=this;i.o==null&&(i.o=[]),i.o.push(n);var s=No(i.__v),o=!1,r=function(){o||(o=!0,n.__R=null,s?s(a):a())};n.__R=r;var a=function(){if(!--i.__u){if(i.state.__a){var l=i.state.__a;i.__v.__k[0]=Oo(l,l.__c.__P,l.__c.__O)}var c;for(i.setState({__a:i.__b=null});c=i.o.pop();)c.forceUpdate()}};i.__u++||32&t.__u||i.setState({__a:i.__b=i.__v.__k[0]}),e.then(r,r)},rs.prototype.componentWillUnmount=function(){this.o=[]},rs.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=Do(this.__b,n,i.__O=i.__P)}this.__b=null}var s=t.__a&&jt(te,null,e.fallback);return s&&(s.__u&=-33),[jt(te,null,t.__a?null:e.children),s]};var Vo=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};(ri.prototype=new Kt).__a=function(e){var t=this,n=No(t.__v),i=t.l.get(e);return i[0]++,function(s){var o=function(){t.props.revealOrder?(i.push(s),Vo(t,e,i)):s()};n?n(o):o()}},ri.prototype.render=function(e){this.i=null,this.l=new Map;var t=ee(e.children);e.revealOrder&&e.revealOrder[0]==="b"&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},ri.prototype.componentDidUpdate=ri.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Vo(e,n,t)})};var Fo=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,Ld=/^(?: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]/,Dd=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Od=/[A-Z0-9]/g,Nd=typeof document<"u",Vd=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};Kt.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(Kt.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Bo=q.event;function Fd(){}function Bd(){return this.cancelBubble}function jd(){return this.defaultPrevented}q.event=function(e){return Bo&&(e=Bo(e)),e.persist=Fd,e.isPropagationStopped=Bd,e.isDefaultPrevented=jd,e.nativeEvent=e};var $d={enumerable:!1,configurable:!0,get:function(){return this.class}},jo=q.vnode;q.vnode=function(e){typeof e.type=="string"&&function(t){var n=t.props,i=t.type,s={},o=i.indexOf("-")===-1;for(var r in n){var a=n[r];if(!(r==="value"&&"defaultValue"in n&&a==null||Nd&&r==="children"&&i==="noscript"||r==="class"||r==="className")){var l=r.toLowerCase();r==="defaultValue"&&"value"in n&&n.value==null?r="value":r==="download"&&a===!0?a="":l==="translate"&&a==="no"?a=!1:l[0]==="o"&&l[1]==="n"?l==="ondoubleclick"?r="ondblclick":l!=="onchange"||i!=="input"&&i!=="textarea"||Vd(n.type)?l==="onfocus"?r="onfocusin":l==="onblur"?r="onfocusout":Dd.test(r)&&(r=l):l=r="oninput":o&&Ld.test(r)?r=r.replace(Od,"-$&").toLowerCase():a===null&&(a=void 0),l==="oninput"&&s[r=l]&&(r="oninputCapture"),s[r]=a}}i=="select"&&s.multiple&&Array.isArray(s.value)&&(s.value=ee(n.children).forEach(function(c){c.props.selected=s.value.indexOf(c.props.value)!=-1})),i=="select"&&s.defaultValue!=null&&(s.value=ee(n.children).forEach(function(c){c.props.selected=s.multiple?s.defaultValue.indexOf(c.props.value)!=-1:s.defaultValue==c.props.value})),n.class&&!n.className?(s.class=n.class,Object.defineProperty(s,"className",$d)):(n.className&&!n.class||n.class&&n.className)&&(s.class=s.className=n.className),t.props=s}(e),e.$$typeof=Fo,jo&&jo(e)};var $o=q.__r;q.__r=function(e){$o&&$o(e),e.__c};var Uo=q.diffed;q.diffed=function(e){Uo&&Uo(e);var t=e.props,n=e.__e;n!=null&&e.type==="textarea"&&"value"in t&&t.value!==n.value&&(n.value=t.value==null?"":t.value)};function Ho(e){return!!e&&e.$$typeof===Fo}function Ud(e){return Ho(e)?Ji.apply(null,arguments):e}var Go={};const os=Re({});function oi(e){const t=Mt(null);return t.current===null&&(t.current=e()),t.current}const as=typeof window<"u",Wo=as?es:$t,ai=Re(null);function ls(e,t){e.indexOf(t)===-1&&e.push(t)}function cs(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const fe=(e,t,n)=>n>t?t:n<e?e:n;let us=()=>{};const pe={},zo=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function qo(e){return typeof e=="object"&&e!==null}const Ko=e=>/^0[^.\s]+$/u.test(e);function ds(e){let t;return()=>(t===void 0&&(t=e()),t)}const Ut=e=>e,Hd=(e,t)=>n=>t(e(n)),bn=(...e)=>e.reduce(Hd),wn=(e,t,n)=>{const i=t-e;return i===0?1:(n-e)/i};class hs{constructor(){this.subscriptions=[]}add(t){return ls(this.subscriptions,t),()=>cs(this.subscriptions,t)}notify(t,n,i){const s=this.subscriptions.length;if(s)if(s===1)this.subscriptions[0](t,n,i);else for(let o=0;o<s;o++){const r=this.subscriptions[o];r&&r(t,n,i)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const ie=e=>e*1e3,se=e=>e/1e3;function Xo(e,t){return t?e*(1e3/t):0}const Yo=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Gd=1e-7,Wd=12;function zd(e,t,n,i,s){let o,r,a=0;do r=t+(n-t)/2,o=Yo(r,i,s)-e,o>0?n=r:t=r;while(Math.abs(o)>Gd&&++a<Wd);return r}function xn(e,t,n,i){if(e===t&&n===i)return Ut;const s=o=>zd(o,0,1,e,n);return o=>o===0||o===1?o:Yo(s(o),t,i)}const Zo=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Jo=e=>t=>1-e(1-t),Qo=xn(.33,1.53,.69,.99),fs=Jo(Qo),ta=Zo(fs),ea=e=>(e*=2)<1?.5*fs(e):.5*(2-Math.pow(2,-10*(e-1))),ps=e=>1-Math.sin(Math.acos(e)),na=Jo(ps),ia=Zo(ps),qd=xn(.42,0,1,1),Kd=xn(0,0,.58,1),sa=xn(.42,0,.58,1),Xd=e=>Array.isArray(e)&&typeof e[0]!="number",ra=e=>Array.isArray(e)&&typeof e[0]=="number",Yd={linear:Ut,easeIn:qd,easeInOut:sa,easeOut:Kd,circIn:ps,circInOut:ia,circOut:na,backIn:fs,backInOut:ta,backOut:Qo,anticipate:ea},Zd=e=>typeof e=="string",oa=e=>{if(ra(e)){us(e.length===4);const[t,n,i,s]=e;return xn(t,n,i,s)}else if(Zd(e))return Yd[e];return e},li=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],aa={value:null};function Jd(e,t){let n=new Set,i=new Set,s=!1,o=!1;const r=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1},l=0;function c(u){r.has(u)&&(d.schedule(u),e()),l++,u(a)}const d={schedule:(u,p=!1,g=!1)=>{const b=g&&s?n:i;return p&&r.add(u),b.has(u)||b.add(u),u},cancel:u=>{i.delete(u),r.delete(u)},process:u=>{if(a=u,s){o=!0;return}s=!0,[n,i]=[i,n],n.forEach(c),t&&aa.value&&aa.value.frameloop[t].push(l),l=0,n.clear(),s=!1,o&&(o=!1,d.process(u))}};return d}const Qd=40;function la(e,t){let n=!1,i=!0;const s={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,r=li.reduce((C,P)=>(C[P]=Jd(o,t?P:void 0),C),{}),{setup:a,read:l,resolveKeyframes:c,preUpdate:d,update:u,preRender:p,render:g,postRender:_}=r,b=()=>{const C=pe.useManualTiming?s.timestamp:performance.now();n=!1,pe.useManualTiming||(s.delta=i?1e3/60:Math.max(Math.min(C-s.timestamp,Qd),1)),s.timestamp=C,s.isProcessing=!0,a.process(s),l.process(s),c.process(s),d.process(s),u.process(s),p.process(s),g.process(s),_.process(s),s.isProcessing=!1,n&&t&&(i=!1,e(b))},w=()=>{n=!0,i=!0,s.isProcessing||e(b)};return{schedule:li.reduce((C,P)=>{const L=r[P];return C[P]=(D,x=!1,k=!1)=>(n||w(),L.schedule(D,x,k)),C},{}),cancel:C=>{for(let P=0;P<li.length;P++)r[li[P]].cancel(C)},state:s,steps:r}}const{schedule:ut,cancel:_e,state:St,steps:ms}=la(typeof requestAnimationFrame<"u"?requestAnimationFrame:Ut,!0);let ci;function th(){ci=void 0}const Lt={now:()=>(ci===void 0&&Lt.set(St.isProcessing||pe.useManualTiming?St.timestamp:performance.now()),ci),set:e=>{ci=e,queueMicrotask(th)}},ca=e=>t=>typeof t=="string"&&t.startsWith(e),gs=ca("--"),eh=ca("var(--"),vs=e=>eh(e)?nh.test(e.split("/*")[0].trim()):!1,nh=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,qe={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Sn={...qe,transform:e=>fe(0,1,e)},ui={...qe,default:1},Cn=e=>Math.round(e*1e5)/1e5,_s=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function ih(e){return e==null}const sh=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,ys=(e,t)=>n=>!!(typeof n=="string"&&sh.test(n)&&n.startsWith(e)||t&&!ih(n)&&Object.prototype.hasOwnProperty.call(n,t)),ua=(e,t,n)=>i=>{if(typeof i!="string")return i;const[s,o,r,a]=i.match(_s);return{[e]:parseFloat(s),[t]:parseFloat(o),[n]:parseFloat(r),alpha:a!==void 0?parseFloat(a):1}},rh=e=>fe(0,255,e),bs={...qe,transform:e=>Math.round(rh(e))},Ie={test:ys("rgb","red"),parse:ua("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:i=1})=>"rgba("+bs.transform(e)+", "+bs.transform(t)+", "+bs.transform(n)+", "+Cn(Sn.transform(i))+")"};function oh(e){let t="",n="",i="",s="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),i=e.substring(5,7),s=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),i=e.substring(3,4),s=e.substring(4,5),t+=t,n+=n,i+=i,s+=s),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(i,16),alpha:s?parseInt(s,16)/255:1}}const ws={test:ys("#"),parse:oh,transform:Ie.transform},kn=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),ye=kn("deg"),re=kn("%"),U=kn("px"),ah=kn("vh"),lh=kn("vw"),da={...re,parse:e=>re.parse(e)/100,transform:e=>re.transform(e*100)},Ke={test:ys("hsl","hue"),parse:ua("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:i=1})=>"hsla("+Math.round(e)+", "+re.transform(Cn(t))+", "+re.transform(Cn(n))+", "+Cn(Sn.transform(i))+")"},yt={test:e=>Ie.test(e)||ws.test(e)||Ke.test(e),parse:e=>Ie.test(e)?Ie.parse(e):Ke.test(e)?Ke.parse(e):ws.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Ie.transform(e):Ke.transform(e),getAnimatableNone:e=>{const t=yt.parse(e);return t.alpha=0,yt.transform(t)}},ch=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function uh(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(_s))==null?void 0:t.length)||0)+(((n=e.match(ch))==null?void 0:n.length)||0)>0}const ha="number",fa="color",dh="var",hh="var(",pa="${}",fh=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Tn(e){const t=e.toString(),n=[],i={color:[],number:[],var:[]},s=[];let o=0;const a=t.replace(fh,l=>(yt.test(l)?(i.color.push(o),s.push(fa),n.push(yt.parse(l))):l.startsWith(hh)?(i.var.push(o),s.push(dh),n.push(l)):(i.number.push(o),s.push(ha),n.push(parseFloat(l))),++o,pa)).split(pa);return{values:n,split:a,indexes:i,types:s}}function ma(e){return Tn(e).values}function ga(e){const{split:t,types:n}=Tn(e),i=t.length;return s=>{let o="";for(let r=0;r<i;r++)if(o+=t[r],s[r]!==void 0){const a=n[r];a===ha?o+=Cn(s[r]):a===fa?o+=yt.transform(s[r]):o+=s[r]}return o}}const ph=e=>typeof e=="number"?0:yt.test(e)?yt.getAnimatableNone(e):e;function mh(e){const t=ma(e);return ga(e)(t.map(ph))}const be={test:uh,parse:ma,createTransformer:ga,getAnimatableNone:mh};function xs(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function gh({hue:e,saturation:t,lightness:n,alpha:i}){e/=360,t/=100,n/=100;let s=0,o=0,r=0;if(!t)s=o=r=n;else{const a=n<.5?n*(1+t):n+t-n*t,l=2*n-a;s=xs(l,a,e+1/3),o=xs(l,a,e),r=xs(l,a,e-1/3)}return{red:Math.round(s*255),green:Math.round(o*255),blue:Math.round(r*255),alpha:i}}function di(e,t){return n=>n>0?t:e}const mt=(e,t,n)=>e+(t-e)*n,Ss=(e,t,n)=>{const i=e*e,s=n*(t*t-i)+i;return s<0?0:Math.sqrt(s)},vh=[ws,Ie,Ke],_h=e=>vh.find(t=>t.test(e));function va(e){const t=_h(e);if(!t)return!1;let n=t.parse(e);return t===Ke&&(n=gh(n)),n}const _a=(e,t)=>{const n=va(e),i=va(t);if(!n||!i)return di(e,t);const s={...n};return o=>(s.red=Ss(n.red,i.red,o),s.green=Ss(n.green,i.green,o),s.blue=Ss(n.blue,i.blue,o),s.alpha=mt(n.alpha,i.alpha,o),Ie.transform(s))},Cs=new Set(["none","hidden"]);function yh(e,t){return Cs.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function bh(e,t){return n=>mt(e,t,n)}function ks(e){return typeof e=="number"?bh:typeof e=="string"?vs(e)?di:yt.test(e)?_a:Sh:Array.isArray(e)?ya:typeof e=="object"?yt.test(e)?_a:wh:di}function ya(e,t){const n=[...e],i=n.length,s=e.map((o,r)=>ks(o)(o,t[r]));return o=>{for(let r=0;r<i;r++)n[r]=s[r](o);return n}}function wh(e,t){const n={...e,...t},i={};for(const s in n)e[s]!==void 0&&t[s]!==void 0&&(i[s]=ks(e[s])(e[s],t[s]));return s=>{for(const o in i)n[o]=i[o](s);return n}}function xh(e,t){const n=[],i={color:0,var:0,number:0};for(let s=0;s<t.values.length;s++){const o=t.types[s],r=e.indexes[o][i[o]],a=e.values[r]??0;n[s]=a,i[o]++}return n}const Sh=(e,t)=>{const n=be.createTransformer(t),i=Tn(e),s=Tn(t);return i.indexes.var.length===s.indexes.var.length&&i.indexes.color.length===s.indexes.color.length&&i.indexes.number.length>=s.indexes.number.length?Cs.has(e)&&!s.values.length||Cs.has(t)&&!i.values.length?yh(e,t):bn(ya(xh(i,s),s.values),n):di(e,t)};function ba(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?mt(e,t,n):ks(e)(e,t)}const Ch=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>ut.update(t,n),stop:()=>_e(t),now:()=>St.isProcessing?St.timestamp:Lt.now()}},wa=(e,t,n=10)=>{let i="";const s=Math.max(Math.round(t/n),2);for(let o=0;o<s;o++)i+=Math.round(e(o/(s-1))*1e4)/1e4+", ";return`linear(${i.substring(0,i.length-2)})`},hi=2e4;function Ts(e){let t=0;const n=50;let i=e.next(t);for(;!i.done&&t<hi;)t+=n,i=e.next(t);return t>=hi?1/0:t}function kh(e,t=100,n){const i=n({...e,keyframes:[0,t]}),s=Math.min(Ts(i),hi);return{type:"keyframes",ease:o=>i.next(s*o).value/t,duration:se(s)}}const Th=5;function xa(e,t,n){const i=Math.max(t-Th,0);return Xo(n-e(i),t-i)}const gt={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},Es=.001;function Eh({duration:e=gt.duration,bounce:t=gt.bounce,velocity:n=gt.velocity,mass:i=gt.mass}){let s,o,r=1-t;r=fe(gt.minDamping,gt.maxDamping,r),e=fe(gt.minDuration,gt.maxDuration,se(e)),r<1?(s=c=>{const d=c*r,u=d*e,p=d-n,g=As(c,r),_=Math.exp(-u);return Es-p/g*_},o=c=>{const u=c*r*e,p=u*n+n,g=Math.pow(r,2)*Math.pow(c,2)*e,_=Math.exp(-u),b=As(Math.pow(c,2),r);return(-s(c)+Es>0?-1:1)*((p-g)*_)/b}):(s=c=>{const d=Math.exp(-c*e),u=(c-n)*e+1;return-Es+d*u},o=c=>{const d=Math.exp(-c*e),u=(n-c)*(e*e);return d*u});const a=5/e,l=Rh(s,o,a);if(e=ie(e),isNaN(l))return{stiffness:gt.stiffness,damping:gt.damping,duration:e};{const c=Math.pow(l,2)*i;return{stiffness:c,damping:r*2*Math.sqrt(i*c),duration:e}}}const Ah=12;function Rh(e,t,n){let i=n;for(let s=1;s<Ah;s++)i=i-e(i)/t(i);return i}function As(e,t){return e*Math.sqrt(1-t*t)}const Ih=["duration","bounce"],Ph=["stiffness","damping","mass"];function Sa(e,t){return t.some(n=>e[n]!==void 0)}function Mh(e){let t={velocity:gt.velocity,stiffness:gt.stiffness,damping:gt.damping,mass:gt.mass,isResolvedFromDuration:!1,...e};if(!Sa(e,Ph)&&Sa(e,Ih))if(e.visualDuration){const n=e.visualDuration,i=2*Math.PI/(n*1.2),s=i*i,o=2*fe(.05,1,1-(e.bounce||0))*Math.sqrt(s);t={...t,mass:gt.mass,stiffness:s,damping:o}}else{const n=Eh(e);t={...t,...n,mass:gt.mass},t.isResolvedFromDuration=!0}return t}function fi(e=gt.visualDuration,t=gt.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:i,restDelta:s}=n;const o=n.keyframes[0],r=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:l,damping:c,mass:d,duration:u,velocity:p,isResolvedFromDuration:g}=Mh({...n,velocity:-se(n.velocity||0)}),_=p||0,b=c/(2*Math.sqrt(l*d)),w=r-o,y=se(Math.sqrt(l/d)),S=Math.abs(w)<5;i||(i=S?gt.restSpeed.granular:gt.restSpeed.default),s||(s=S?gt.restDelta.granular:gt.restDelta.default);let C;if(b<1){const L=As(y,b);C=D=>{const x=Math.exp(-b*y*D);return r-x*((_+b*y*w)/L*Math.sin(L*D)+w*Math.cos(L*D))}}else if(b===1)C=L=>r-Math.exp(-y*L)*(w+(_+y*w)*L);else{const L=y*Math.sqrt(b*b-1);C=D=>{const x=Math.exp(-b*y*D),k=Math.min(L*D,300);return r-x*((_+b*y*w)*Math.sinh(k)+L*w*Math.cosh(k))/L}}const P={calculatedDuration:g&&u||null,next:L=>{const D=C(L);if(g)a.done=L>=u;else{let x=L===0?_:0;b<1&&(x=L===0?ie(_):xa(C,L,D));const k=Math.abs(x)<=i,f=Math.abs(r-D)<=s;a.done=k&&f}return a.value=a.done?r:D,a},toString:()=>{const L=Math.min(Ts(P),hi),D=wa(x=>P.next(L*x).value,L,30);return L+"ms "+D},toTransition:()=>{}};return P}fi.applyToOptions=e=>{const t=kh(e,100,fi);return e.ease=t.ease,e.duration=ie(t.duration),e.type="keyframes",e};function Rs({keyframes:e,velocity:t=0,power:n=.8,timeConstant:i=325,bounceDamping:s=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:l,restDelta:c=.5,restSpeed:d}){const u=e[0],p={done:!1,value:u},g=k=>a!==void 0&&k<a||l!==void 0&&k>l,_=k=>a===void 0?l:l===void 0||Math.abs(a-k)<Math.abs(l-k)?a:l;let b=n*t;const w=u+b,y=r===void 0?w:r(w);y!==w&&(b=y-u);const S=k=>-b*Math.exp(-k/i),C=k=>y+S(k),P=k=>{const f=S(k),m=C(k);p.done=Math.abs(f)<=c,p.value=p.done?y:m};let L,D;const x=k=>{g(p.value)&&(L=k,D=fi({keyframes:[p.value,_(p.value)],velocity:xa(C,k,p.value),damping:s,stiffness:o,restDelta:c,restSpeed:d}))};return x(0),{calculatedDuration:null,next:k=>{let f=!1;return!D&&L===void 0&&(f=!0,P(k),x(k)),L!==void 0&&k>=L?D.next(k-L):(!f&&P(k),p)}}}function Lh(e,t,n){const i=[],s=n||pe.mix||ba,o=e.length-1;for(let r=0;r<o;r++){let a=s(e[r],e[r+1]);if(t){const l=Array.isArray(t)?t[r]||Ut:t;a=bn(l,a)}i.push(a)}return i}function Dh(e,t,{clamp:n=!0,ease:i,mixer:s}={}){const o=e.length;if(us(o===t.length),o===1)return()=>t[0];if(o===2&&t[0]===t[1])return()=>t[1];const r=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const a=Lh(t,i,s),l=a.length,c=d=>{if(r&&d<e[0])return t[0];let u=0;if(l>1)for(;u<e.length-2&&!(d<e[u+1]);u++);const p=wn(e[u],e[u+1],d);return a[u](p)};return n?d=>c(fe(e[0],e[o-1],d)):c}function Oh(e,t){const n=e[e.length-1];for(let i=1;i<=t;i++){const s=wn(0,t,i);e.push(mt(n,1,s))}}function Nh(e){const t=[0];return Oh(t,e.length-1),t}function Vh(e,t){return e.map(n=>n*t)}function Fh(e,t){return e.map(()=>t||sa).splice(0,e.length-1)}function En({duration:e=300,keyframes:t,times:n,ease:i="easeInOut"}){const s=Xd(i)?i.map(oa):oa(i),o={done:!1,value:t[0]},r=Vh(n&&n.length===t.length?n:Nh(t),e),a=Dh(r,t,{ease:Array.isArray(s)?s:Fh(t,s)});return{calculatedDuration:e,next:l=>(o.value=a(l),o.done=l>=e,o)}}const Bh=e=>e!==null;function Is(e,{repeat:t,repeatType:n="loop"},i,s=1){const o=e.filter(Bh),a=s<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!a||i===void 0?o[a]:i}const jh={decay:Rs,inertia:Rs,tween:En,keyframes:En,spring:fi};function Ca(e){typeof e.type=="string"&&(e.type=jh[e.type])}class Ps{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const $h=e=>e/100;class Ms extends Ps{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{var i,s;const{motionValue:n}=this.options;n&&n.updatedAt!==Lt.now()&&this.tick(Lt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(s=(i=this.options).onStop)==null||s.call(i))},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;Ca(t);const{type:n=En,repeat:i=0,repeatDelay:s=0,repeatType:o,velocity:r=0}=t;let{keyframes:a}=t;const l=n||En;l!==En&&typeof a[0]!="number"&&(this.mixKeyframes=bn($h,ba(a[0],a[1])),a=[0,100]);const c=l({...t,keyframes:a});o==="mirror"&&(this.mirroredGenerator=l({...t,keyframes:[...a].reverse(),velocity:-r})),c.calculatedDuration===null&&(c.calculatedDuration=Ts(c));const{calculatedDuration:d}=c;this.calculatedDuration=d,this.resolvedDuration=d+s,this.totalDuration=this.resolvedDuration*(i+1)-s,this.generator=c}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:i,totalDuration:s,mixKeyframes:o,mirroredGenerator:r,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return i.next(0);const{delay:c=0,keyframes:d,repeat:u,repeatType:p,repeatDelay:g,type:_,onUpdate:b,finalKeyframe:w}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-s/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const y=this.currentTime-c*(this.playbackSpeed>=0?1:-1),S=this.playbackSpeed>=0?y<0:y>s;this.currentTime=Math.max(y,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=s);let C=this.currentTime,P=i;if(u){const k=Math.min(this.currentTime,s)/a;let f=Math.floor(k),m=k%1;!m&&k>=1&&(m=1),m===1&&f--,f=Math.min(f,u+1),!!(f%2)&&(p==="reverse"?(m=1-m,g&&(m-=g/a)):p==="mirror"&&(P=r)),C=fe(0,1,m)*a}const L=S?{done:!1,value:d[0]}:P.next(C);o&&(L.value=o(L.value));let{done:D}=L;!S&&l!==null&&(D=this.playbackSpeed>=0?this.currentTime>=s:this.currentTime<=0);const x=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&D);return x&&_!==Rs&&(L.value=Is(d,this.options,w,this.speed)),b&&b(L.value),x&&this.finish(),L}then(t,n){return this.finished.then(t,n)}get duration(){return se(this.calculatedDuration)}get time(){return se(this.currentTime)}set time(t){var n;t=ie(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),(n=this.driver)==null||n.start(!1)}get speed(){return this.playbackSpeed}set speed(t){this.updateTime(Lt.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=se(this.currentTime))}play(){var s,o;if(this.isStopped)return;const{driver:t=Ch,startTime:n}=this.options;this.driver||(this.driver=t(r=>this.tick(r))),(o=(s=this.options).onPlay)==null||o.call(s);const i=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=i):this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime||(this.startTime=n??i),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Lt.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var t,n;this.notifyFinished(),this.teardown(),this.state="finished",(n=(t=this.options).onComplete)==null||n.call(t)}cancel(){var t,n;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(n=(t=this.options).onCancel)==null||n.call(t)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){var n;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(n=this.driver)==null||n.stop(),t.observe(this)}}function Uh(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Pe=e=>e*180/Math.PI,Ls=e=>{const t=Pe(Math.atan2(e[1],e[0]));return Ds(t)},Hh={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Ls,rotateZ:Ls,skewX:e=>Pe(Math.atan(e[1])),skewY:e=>Pe(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Ds=e=>(e=e%360,e<0&&(e+=360),e),ka=Ls,Ta=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Ea=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Gh={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Ta,scaleY:Ea,scale:e=>(Ta(e)+Ea(e))/2,rotateX:e=>Ds(Pe(Math.atan2(e[6],e[5]))),rotateY:e=>Ds(Pe(Math.atan2(-e[2],e[0]))),rotateZ:ka,rotate:ka,skewX:e=>Pe(Math.atan(e[4])),skewY:e=>Pe(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Os(e){return e.includes("scale")?1:0}function Ns(e,t){if(!e||e==="none")return Os(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let i,s;if(n)i=Gh,s=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);i=Hh,s=a}if(!s)return Os(t);const o=i[t],r=s[1].split(",").map(zh);return typeof o=="function"?o(r):r[o]}const Wh=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Ns(n,t)};function zh(e){return parseFloat(e.trim())}const Xe=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Ye=new Set(Xe),Aa=e=>e===qe||e===U,qh=new Set(["x","y","z"]),Kh=Xe.filter(e=>!qh.has(e));function Xh(e){const t=[];return Kh.forEach(n=>{const i=e.getValue(n);i!==void 0&&(t.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),t}const Me={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Ns(t,"x"),y:(e,{transform:t})=>Ns(t,"y")};Me.translateX=Me.x,Me.translateY=Me.y;const Le=new Set;let Vs=!1,Fs=!1,Bs=!1;function Ra(){if(Fs){const e=Array.from(Le).filter(i=>i.needsMeasurement),t=new Set(e.map(i=>i.element)),n=new Map;t.forEach(i=>{const s=Xh(i);s.length&&(n.set(i,s),i.render())}),e.forEach(i=>i.measureInitialState()),t.forEach(i=>{i.render();const s=n.get(i);s&&s.forEach(([o,r])=>{var a;(a=i.getValue(o))==null||a.set(r)})}),e.forEach(i=>i.measureEndState()),e.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}Fs=!1,Vs=!1,Le.forEach(e=>e.complete(Bs)),Le.clear()}function Ia(){Le.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Fs=!0)})}function Yh(){Bs=!0,Ia(),Ra(),Bs=!1}class js{constructor(t,n,i,s,o,r=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=i,this.motionValue=s,this.element=o,this.isAsync=r}scheduleResolve(){this.state="scheduled",this.isAsync?(Le.add(this),Vs||(Vs=!0,ut.read(Ia),ut.resolveKeyframes(Ra))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:i,motionValue:s}=this;if(t[0]===null){const o=s==null?void 0:s.get(),r=t[t.length-1];if(o!==void 0)t[0]=o;else if(i&&n){const a=i.readValue(n,r);a!=null&&(t[0]=a)}t[0]===void 0&&(t[0]=r),s&&o===void 0&&s.set(t[0])}Uh(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Le.delete(this)}cancel(){this.state==="scheduled"&&(Le.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Zh=e=>e.startsWith("--");function Jh(e,t,n){Zh(t)?e.style.setProperty(t,n):e.style[t]=n}const Qh=ds(()=>window.ScrollTimeline!==void 0),tf={};function ef(e,t){const n=ds(e);return()=>tf[t]??n()}const Pa=ef(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),An=([e,t,n,i])=>`cubic-bezier(${e}, ${t}, ${n}, ${i})`,Ma={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:An([0,.65,.55,1]),circOut:An([.55,0,1,.45]),backIn:An([.31,.01,.66,-.59]),backOut:An([.33,1.53,.69,.99])};function La(e,t){if(e)return typeof e=="function"?Pa()?wa(e,t):"ease-out":ra(e)?An(e):Array.isArray(e)?e.map(n=>La(n,t)||Ma.easeOut):Ma[e]}function nf(e,t,n,{delay:i=0,duration:s=300,repeat:o=0,repeatType:r="loop",ease:a="easeOut",times:l}={},c=void 0){const d={[t]:n};l&&(d.offset=l);const u=La(a,s);Array.isArray(u)&&(d.easing=u);const p={delay:i,duration:s,easing:Array.isArray(u)?"linear":u,fill:"both",iterations:o+1,direction:r==="reverse"?"alternate":"normal"};return c&&(p.pseudoElement=c),e.animate(d,p)}function Da(e){return typeof e=="function"&&"applyToOptions"in e}function sf({type:e,...t}){return Da(e)&&Pa()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class rf extends Ps{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:n,name:i,keyframes:s,pseudoElement:o,allowFlatten:r=!1,finalKeyframe:a,onComplete:l}=t;this.isPseudoElement=!!o,this.allowFlatten=r,this.options=t,us(typeof t.type!="string");const c=sf(t);this.animation=nf(n,i,s,c,o),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const d=Is(s,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(d):Jh(n,i,d),this.animation.cancel()}l==null||l(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var t,n;(n=(t=this.animation).finish)==null||n.call(t)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var t,n;this.isPseudoElement||(n=(t=this.animation).commitStyles)==null||n.call(t)}get duration(){var n,i;const t=((i=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:i.call(n).duration)||0;return se(Number(t))}get time(){return se(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=ie(t)}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(t){this.animation.startTime=t}attachTimeline({timeline:t,observe:n}){var i;return this.allowFlatten&&((i=this.animation.effect)==null||i.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&Qh()?(this.animation.timeline=t,Ut):n(this)}}const Oa={anticipate:ea,backInOut:ta,circInOut:ia};function of(e){return e in Oa}function af(e){typeof e.ease=="string"&&of(e.ease)&&(e.ease=Oa[e.ease])}const Na=10;class lf extends rf{constructor(t){af(t),Ca(t),super(t),t.startTime&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:i,onComplete:s,element:o,...r}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const a=new Ms({...r,autoplay:!1}),l=ie(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-Na).value,a.sample(l).value,Na),a.stop()}}const Va=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(be.test(e)||e==="0")&&!e.startsWith("url("));function cf(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function uf(e,t,n,i){const s=e[0];if(s===null)return!1;if(t==="display"||t==="visibility")return!0;const o=e[e.length-1],r=Va(s,t),a=Va(o,t);return!r||!a?!1:cf(e)||(n==="spring"||Da(n))&&i}function $s(e){return qo(e)&&"offsetHeight"in e}const df=new Set(["opacity","clipPath","filter","transform"]),hf=ds(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function ff(e){var c;const{motionValue:t,name:n,repeatDelay:i,repeatType:s,damping:o,type:r}=e;if(!$s((c=t==null?void 0:t.owner)==null?void 0:c.current))return!1;const{onUpdate:a,transformTemplate:l}=t.owner.getProps();return hf()&&n&&df.has(n)&&(n!=="transform"||!l)&&!a&&!i&&s!=="mirror"&&o!==0&&r!=="inertia"}const pf=40;class mf extends Ps{constructor({autoplay:t=!0,delay:n=0,type:i="keyframes",repeat:s=0,repeatDelay:o=0,repeatType:r="loop",keyframes:a,name:l,motionValue:c,element:d,...u}){var _;super(),this.stop=()=>{var b,w;this._animation&&(this._animation.stop(),(b=this.stopTimeline)==null||b.call(this)),(w=this.keyframeResolver)==null||w.cancel()},this.createdAt=Lt.now();const p={autoplay:t,delay:n,type:i,repeat:s,repeatDelay:o,repeatType:r,name:l,motionValue:c,element:d,...u},g=(d==null?void 0:d.KeyframeResolver)||js;this.keyframeResolver=new g(a,(b,w,y)=>this.onKeyframesResolved(b,w,p,!y),l,c,d),(_=this.keyframeResolver)==null||_.scheduleResolve()}onKeyframesResolved(t,n,i,s){this.keyframeResolver=void 0;const{name:o,type:r,velocity:a,delay:l,isHandoff:c,onUpdate:d}=i;this.resolvedAt=Lt.now(),uf(t,o,r,a)||((pe.instantAnimations||!l)&&(d==null||d(Is(t,i,n))),t[0]=t[t.length-1],i.duration=0,i.repeat=0);const p={startTime:s?this.resolvedAt?this.resolvedAt-this.createdAt>pf?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...i,keyframes:t},g=!c&&ff(p)?new lf({...p,element:p.motionValue.owner.current}):new Ms(p);g.finished.then(()=>this.notifyFinished()).catch(Ut),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){var t;return this._animation||((t=this.keyframeResolver)==null||t.resume(),Yh()),this._animation}get duration(){return this.animation.duration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var t;this._animation&&this.animation.cancel(),(t=this.keyframeResolver)==null||t.cancel()}}const gf=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function vf(e){const t=gf.exec(e);if(!t)return[,];const[,n,i,s]=t;return[`--${n??i}`,s]}function Fa(e,t,n=1){const[i,s]=vf(e);if(!i)return;const o=window.getComputedStyle(t).getPropertyValue(i);if(o){const r=o.trim();return zo(r)?parseFloat(r):r}return vs(s)?Fa(s,t,n+1):s}function Us(e,t){return(e==null?void 0:e[t])??(e==null?void 0:e.default)??e}const Ba=new Set(["width","height","top","left","right","bottom",...Xe]),_f={test:e=>e==="auto",parse:e=>e},ja=e=>t=>t.test(e),$a=[qe,U,re,ye,lh,ah,_f],Ua=e=>$a.find(ja(e));function yf(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||Ko(e):!0}const bf=new Set(["brightness","contrast","saturate","opacity"]);function wf(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[i]=n.match(_s)||[];if(!i)return e;const s=n.replace(i,"");let o=bf.has(t)?1:0;return i!==n&&(o*=100),t+"("+o+s+")"}const xf=/\b([a-z-]*)\(.*?\)/gu,Hs={...be,getAnimatableNone:e=>{const t=e.match(xf);return t?t.map(wf).join(" "):e}},Ha={...qe,transform:Math.round},Gs={borderWidth:U,borderTopWidth:U,borderRightWidth:U,borderBottomWidth:U,borderLeftWidth:U,borderRadius:U,radius:U,borderTopLeftRadius:U,borderTopRightRadius:U,borderBottomRightRadius:U,borderBottomLeftRadius:U,width:U,maxWidth:U,height:U,maxHeight:U,top:U,right:U,bottom:U,left:U,padding:U,paddingTop:U,paddingRight:U,paddingBottom:U,paddingLeft:U,margin:U,marginTop:U,marginRight:U,marginBottom:U,marginLeft:U,backgroundPositionX:U,backgroundPositionY:U,...{rotate:ye,rotateX:ye,rotateY:ye,rotateZ:ye,scale:ui,scaleX:ui,scaleY:ui,scaleZ:ui,skew:ye,skewX:ye,skewY:ye,distance:U,translateX:U,translateY:U,translateZ:U,x:U,y:U,z:U,perspective:U,transformPerspective:U,opacity:Sn,originX:da,originY:da,originZ:U},zIndex:Ha,fillOpacity:Sn,strokeOpacity:Sn,numOctaves:Ha},Sf={...Gs,color:yt,backgroundColor:yt,outlineColor:yt,fill:yt,stroke:yt,borderColor:yt,borderTopColor:yt,borderRightColor:yt,borderBottomColor:yt,borderLeftColor:yt,filter:Hs,WebkitFilter:Hs},Ga=e=>Sf[e];function Wa(e,t){let n=Ga(e);return n!==Hs&&(n=be),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Cf=new Set(["auto","none","0"]);function kf(e,t,n){let i=0,s;for(;i<e.length&&!s;){const o=e[i];typeof o=="string"&&!Cf.has(o)&&Tn(o).values.length&&(s=e[i]),i++}if(s&&n)for(const o of t)e[o]=Wa(n,s)}class Tf extends js{constructor(t,n,i,s,o){super(t,n,i,s,o,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:i}=this;if(!n||!n.current)return;super.readKeyframes();for(let l=0;l<t.length;l++){let c=t[l];if(typeof c=="string"&&(c=c.trim(),vs(c))){const d=Fa(c,n.current);d!==void 0&&(t[l]=d),l===t.length-1&&(this.finalKeyframe=c)}}if(this.resolveNoneKeyframes(),!Ba.has(i)||t.length!==2)return;const[s,o]=t,r=Ua(s),a=Ua(o);if(r!==a)if(Aa(r)&&Aa(a))for(let l=0;l<t.length;l++){const c=t[l];typeof c=="string"&&(t[l]=parseFloat(c))}else Me[i]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,i=[];for(let s=0;s<t.length;s++)(t[s]===null||yf(t[s]))&&i.push(s);i.length&&kf(t,i,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:i}=this;if(!t||!t.current)return;i==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Me[i](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const s=n[n.length-1];s!==void 0&&t.getValue(i,s).jump(s,!1)}measureEndState(){var a;const{element:t,name:n,unresolvedKeyframes:i}=this;if(!t||!t.current)return;const s=t.getValue(n);s&&s.jump(this.measuredOrigin,!1);const o=i.length-1,r=i[o];i[o]=Me[n](t.measureViewportBox(),window.getComputedStyle(t.current)),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),(a=this.removedTransforms)!=null&&a.length&&this.removedTransforms.forEach(([l,c])=>{t.getValue(l).set(c)}),this.resolveNoneKeyframes()}}function Ef(e,t,n){if(e instanceof EventTarget)return[e];if(typeof e=="string"){let i=document;const s=(n==null?void 0:n[e])??i.querySelectorAll(e);return s?Array.from(s):[]}return Array.from(e)}const za=(e,t)=>t&&typeof e=="number"?t.transform(e):e,qa=30,Af=e=>!isNaN(parseFloat(e));class Rf{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=(i,s=!0)=>{var r,a;const o=Lt.now();if(this.updatedAt!==o&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(i),this.current!==this.prev&&((r=this.events.change)==null||r.notify(this.current),this.dependents))for(const l of this.dependents)l.dirty();s&&((a=this.events.renderRequest)==null||a.notify(this.current))},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Lt.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=Af(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new hs);const i=this.events[t].add(n);return t==="change"?()=>{i(),ut.read(()=>{this.events.change.getSize()||this.stop()})}:i}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t,n=!0){!n||!this.passiveEffect?this.updateAndNotify(t,n):this.passiveEffect(t,this.updateAndNotify)}setWithVelocity(t,n,i){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-i}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var t;(t=this.events.change)==null||t.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Lt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>qa)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,qa);return Xo(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var t,n;(t=this.dependents)==null||t.clear(),(n=this.events.destroy)==null||n.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Ze(e,t){return new Rf(e,t)}const{schedule:Ws}=la(queueMicrotask,!1),Yt={x:!1,y:!1};function Ka(){return Yt.x||Yt.y}function If(e){return e==="x"||e==="y"?Yt[e]?null:(Yt[e]=!0,()=>{Yt[e]=!1}):Yt.x||Yt.y?null:(Yt.x=Yt.y=!0,()=>{Yt.x=Yt.y=!1})}function Xa(e,t){const n=Ef(e),i=new AbortController,s={passive:!0,...t,signal:i.signal};return[n,s,()=>i.abort()]}function Ya(e){return!(e.pointerType==="touch"||Ka())}function Pf(e,t,n={}){const[i,s,o]=Xa(e,n),r=a=>{if(!Ya(a))return;const{target:l}=a,c=t(l,a);if(typeof c!="function"||!l)return;const d=u=>{Ya(u)&&(c(u),l.removeEventListener("pointerleave",d))};l.addEventListener("pointerleave",d,s)};return i.forEach(a=>{a.addEventListener("pointerenter",r,s)}),o}const Za=(e,t)=>t?e===t?!0:Za(e,t.parentElement):!1,zs=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Mf=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Lf(e){return Mf.has(e.tagName)||e.tabIndex!==-1}const pi=new WeakSet;function Ja(e){return t=>{t.key==="Enter"&&e(t)}}function qs(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const Df=(e,t)=>{const n=e.currentTarget;if(!n)return;const i=Ja(()=>{if(pi.has(n))return;qs(n,"down");const s=Ja(()=>{qs(n,"up")}),o=()=>qs(n,"cancel");n.addEventListener("keyup",s,t),n.addEventListener("blur",o,t)});n.addEventListener("keydown",i,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),t)};function Qa(e){return zs(e)&&!Ka()}function Of(e,t,n={}){const[i,s,o]=Xa(e,n),r=a=>{const l=a.currentTarget;if(!Qa(a))return;pi.add(l);const c=t(l,a),d=(g,_)=>{window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",p),pi.has(l)&&pi.delete(l),Qa(g)&&typeof c=="function"&&c(g,{success:_})},u=g=>{d(g,l===window||l===document||n.useGlobalTarget||Za(l,g.target))},p=g=>{d(g,!1)};window.addEventListener("pointerup",u,s),window.addEventListener("pointercancel",p,s)};return i.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",r,s),$s(a)&&(a.addEventListener("focus",c=>Df(c,s)),!Lf(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function tl(e){return qo(e)&&"ownerSVGElement"in e}function Nf(e){return tl(e)&&e.tagName==="svg"}const kt=e=>!!(e&&e.getVelocity),Vf=[...$a,yt,be],Ff=e=>Vf.find(ja(e)),Rn=Re({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class Bf extends Kt{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const i=n.offsetParent,s=$s(i)&&i.offsetWidth||0,o=this.props.sizeRef.current;o.height=n.offsetHeight||0,o.width=n.offsetWidth||0,o.top=n.offsetTop,o.left=n.offsetLeft,o.right=s-o.width-o.left}return null}componentDidUpdate(){}render(){return this.props.children}}function jf({children:e,isPresent:t,anchorX:n,root:i}){const s=ns(),o=Mt(null),r=Mt({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=wt(Rn);return Ro(()=>{const{width:l,height:c,top:d,left:u,right:p}=r.current;if(t||!o.current||!l||!c)return;const g=n==="left"?`left: ${u}`:`right: ${p}`;o.current.dataset.motionPopId=s;const _=document.createElement("style");a&&(_.nonce=a);const b=i??document.head;return b.appendChild(_),_.sheet&&_.sheet.insertRule(`
|
|
1
|
+
(function(){"use strict";var mn,K,Yr,At,Zr,Jr,Qr,eo,Gi,Hi,Wi,to,gn={},no=[],md=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_n=Array.isArray;function Qe(t,e){for(var n in e)t[n]=e[n];return t}function zi(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function je(t,e,n){var i,s,o,r={};for(o in e)o=="key"?i=e[o]:o=="ref"?s=e[o]:r[o]=e[o];if(arguments.length>2&&(r.children=arguments.length>3?mn.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)r[o]===void 0&&(r[o]=t.defaultProps[o]);return vn(t,r,i,s,null)}function vn(t,e,n,i,s){var o={type:t,props:e,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++Yr,__i:-1,__u:0};return s==null&&K.vnode!=null&&K.vnode(o),o}function et(t){return t.children}function Ke(t,e){this.props=t,this.context=e}function Wt(t,e){if(e==null)return t.__?Wt(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"?Wt(t):null}function io(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 io(t)}}function qi(t){(!t.__d&&(t.__d=!0)&&At.push(t)&&!Qn.__r++||Zr!=K.debounceRendering)&&((Zr=K.debounceRendering)||Jr)(Qn)}function Qn(){for(var t,e,n,i,s,o,r,a=1;At.length;)At.length>a&&At.sort(Qr),t=At.shift(),a=At.length,t.__d&&(n=void 0,s=(i=(e=t).__v).__e,o=[],r=[],e.__P&&((n=Qe({},i)).__v=i.__v+1,K.vnode&&K.vnode(n),Ki(e.__P,n,i,e.__n,e.__P.namespaceURI,32&i.__u?[s]:null,o,s??Wt(i),!!(32&i.__u),r),n.__v=i.__v,n.__.__k[n.__i]=n,co(o,n,r),n.__e!=s&&io(n)));Qn.__r=0}function so(t,e,n,i,s,o,r,a,c,l,d){var u,m,g,y,w,b,v=i&&i.__k||no,S=e.length;for(c=gd(n,e,v,c,S),u=0;u<S;u++)(g=n.__k[u])!=null&&(m=g.__i==-1?gn:v[g.__i]||gn,g.__i=u,b=Ki(t,g,m,s,o,r,a,c,l,d),y=g.__e,g.ref&&m.ref!=g.ref&&(m.ref&&Xi(m.ref,null,g),d.push(g.ref,g.__c||y,g)),w==null&&y!=null&&(w=y),4&g.__u||m.__k===g.__k?c=ro(g,c,t):typeof g.type=="function"&&b!==void 0?c=b:y&&(c=y.nextSibling),g.__u&=-7);return n.__e=w,c}function gd(t,e,n,i,s){var o,r,a,c,l,d=n.length,u=d,m=0;for(t.__k=new Array(s),o=0;o<s;o++)(r=e[o])!=null&&typeof r!="boolean"&&typeof r!="function"?(c=o+m,(r=t.__k[o]=typeof r=="string"||typeof r=="number"||typeof r=="bigint"||r.constructor==String?vn(null,r,null,null,null):_n(r)?vn(et,{children:r},null,null,null):r.constructor==null&&r.__b>0?vn(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):r).__=t,r.__b=t.__b+1,a=null,(l=r.__i=_d(r,n,c,u))!=-1&&(u--,(a=n[l])&&(a.__u|=2)),a==null||a.__v==null?(l==-1&&(s>d?m--:s<d&&m++),typeof r.type!="function"&&(r.__u|=4)):l!=c&&(l==c-1?m--:l==c+1?m++:(l>c?m--:m++,r.__u|=4))):t.__k[o]=null;if(u)for(o=0;o<d;o++)(a=n[o])!=null&&(2&a.__u)==0&&(a.__e==i&&(i=Wt(a)),uo(a,a));return i}function ro(t,e,n){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=ro(i[s],e,n));return e}t.__e!=e&&(e&&t.type&&!n.contains(e)&&(e=Wt(t)),n.insertBefore(t.__e,e||null),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function tt(t,e){return e=e||[],t==null||typeof t=="boolean"||(_n(t)?t.some(function(n){tt(n,e)}):e.push(t)),e}function _d(t,e,n,i){var s,o,r=t.key,a=t.type,c=e[n];if(c===null&&t.key==null||c&&r==c.key&&a==c.type&&(2&c.__u)==0)return n;if(i>(c!=null&&(2&c.__u)==0?1:0))for(s=n-1,o=n+1;s>=0||o<e.length;){if(s>=0){if((c=e[s])&&(2&c.__u)==0&&r==c.key&&a==c.type)return s;s--}if(o<e.length){if((c=e[o])&&(2&c.__u)==0&&r==c.key&&a==c.type)return o;o++}}return-1}function oo(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||md.test(e)?n:n+"px"}function ei(t,e,n,i,s){var o,r;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof i=="string"&&(t.style.cssText=i=""),i)for(e in i)n&&e in n||oo(t.style,e,"");if(n)for(e in n)i&&n[e]==i[e]||oo(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(eo,"$1")),r=e.toLowerCase(),e=r in t||e=="onFocusOut"||e=="onFocusIn"?r.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?i?n.u=i.u:(n.u=Gi,t.addEventListener(e,o?Wi:Hi,o)):t.removeEventListener(e,o?Wi:Hi,o);else{if(s=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function ao(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=Gi++;else if(e.t<n.u)return;return n(K.event?K.event(e):e)}}}function Ki(t,e,n,i,s,o,r,a,c,l){var d,u,m,g,y,w,b,v,S,k,I,D,O,x,C,f,p,h=e.type;if(e.constructor!=null)return null;128&n.__u&&(c=!!(32&n.__u),o=[a=e.__e=n.__e]),(d=K.__b)&&d(e);e:if(typeof h=="function")try{if(v=e.props,S="prototype"in h&&h.prototype.render,k=(d=h.contextType)&&i[d.__c],I=d?k?k.props.value:d.__:i,n.__c?b=(u=e.__c=n.__c).__=u.__E:(S?e.__c=u=new h(v,I):(e.__c=u=new Ke(v,I),u.constructor=h,u.render=yd),k&&k.sub(u),u.props=v,u.state||(u.state={}),u.context=I,u.__n=i,m=u.__d=!0,u.__h=[],u._sb=[]),S&&u.__s==null&&(u.__s=u.state),S&&h.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=Qe({},u.__s)),Qe(u.__s,h.getDerivedStateFromProps(v,u.__s))),g=u.props,y=u.state,u.__v=e,m)S&&h.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),S&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(S&&h.getDerivedStateFromProps==null&&v!==g&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(v,I),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(v,u.__s,I)===!1||e.__v==n.__v){for(e.__v!=n.__v&&(u.props=v,u.state=u.__s,u.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(_){_&&(_.__=e)}),D=0;D<u._sb.length;D++)u.__h.push(u._sb[D]);u._sb=[],u.__h.length&&r.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(v,u.__s,I),S&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(g,y,w)})}if(u.context=I,u.props=v,u.__P=t,u.__e=!1,O=K.__r,x=0,S){for(u.state=u.__s,u.__d=!1,O&&O(e),d=u.render(u.props,u.state,u.context),C=0;C<u._sb.length;C++)u.__h.push(u._sb[C]);u._sb=[]}else do u.__d=!1,O&&O(e),d=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++x<25);u.state=u.__s,u.getChildContext!=null&&(i=Qe(Qe({},i),u.getChildContext())),S&&!m&&u.getSnapshotBeforeUpdate!=null&&(w=u.getSnapshotBeforeUpdate(g,y)),f=d,d!=null&&d.type===et&&d.key==null&&(f=lo(d.props.children)),a=so(t,_n(f)?f:[f],e,n,i,s,o,r,a,c,l),u.base=e.__e,e.__u&=-161,u.__h.length&&r.push(u),b&&(u.__E=u.__=null)}catch(_){if(e.__v=null,c||o!=null)if(_.then){for(e.__u|=c?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;o[o.indexOf(a)]=null,e.__e=a}else for(p=o.length;p--;)zi(o[p]);else e.__e=n.__e,e.__k=n.__k;K.__e(_,e,n)}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):a=e.__e=vd(n.__e,e,n,i,s,o,r,c,l);return(d=K.diffed)&&d(e),128&e.__u?void 0:a}function co(t,e,n){for(var i=0;i<n.length;i++)Xi(n[i],n[++i],n[++i]);K.__c&&K.__c(e,t),t.some(function(s){try{t=s.__h,s.__h=[],t.some(function(o){o.call(s)})}catch(o){K.__e(o,s.__v)}})}function lo(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:_n(t)?t.map(lo):Qe({},t)}function vd(t,e,n,i,s,o,r,a,c){var l,d,u,m,g,y,w,b=n.props,v=e.props,S=e.type;if(S=="svg"?s="http://www.w3.org/2000/svg":S=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),o!=null){for(l=0;l<o.length;l++)if((g=o[l])&&"setAttribute"in g==!!S&&(S?g.localName==S:g.nodeType==3)){t=g,o[l]=null;break}}if(t==null){if(S==null)return document.createTextNode(v);t=document.createElementNS(s,S,v.is&&v),a&&(K.__m&&K.__m(e,o),a=!1),o=null}if(S==null)b===v||a&&t.data==v||(t.data=v);else{if(o=o&&mn.call(t.childNodes),b=n.props||gn,!a&&o!=null)for(b={},l=0;l<t.attributes.length;l++)b[(g=t.attributes[l]).name]=g.value;for(l in b)if(g=b[l],l!="children"){if(l=="dangerouslySetInnerHTML")u=g;else if(!(l in v)){if(l=="value"&&"defaultValue"in v||l=="checked"&&"defaultChecked"in v)continue;ei(t,l,null,g,s)}}for(l in v)g=v[l],l=="children"?m=g:l=="dangerouslySetInnerHTML"?d=g:l=="value"?y=g:l=="checked"?w=g:a&&typeof g!="function"||b[l]===g||ei(t,l,g,b[l],s);if(d)a||u&&(d.__html==u.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(u&&(t.innerHTML=""),so(e.type=="template"?t.content:t,_n(m)?m:[m],e,n,i,S=="foreignObject"?"http://www.w3.org/1999/xhtml":s,o,r,o?o[0]:n.__k&&Wt(n,0),a,c),o!=null)for(l=o.length;l--;)zi(o[l]);a||(l="value",S=="progress"&&y==null?t.removeAttribute("value"):y!=null&&(y!==t[l]||S=="progress"&&!y||S=="option"&&y!=b[l])&&ei(t,l,y,b[l],s),l="checked",w!=null&&w!=t[l]&&ei(t,l,w,b[l],s))}return t}function Xi(t,e,n){try{if(typeof t=="function"){var i=typeof t.__u=="function";i&&t.__u(),i&&e==null||(t.__u=t(e))}else t.current=e}catch(s){K.__e(s,n)}}function uo(t,e,n){var i,s;if(K.unmount&&K.unmount(t),(i=t.ref)&&(i.current&&i.current!=t.__e||Xi(i,null,e)),(i=t.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(o){K.__e(o,e)}i.base=i.__P=null}if(i=t.__k)for(s=0;s<i.length;s++)i[s]&&uo(i[s],e,n||typeof t.type!="function");n||zi(t.__e),t.__c=t.__=t.__e=void 0}function yd(t,e,n){return this.constructor(t,n)}function ti(t,e,n){var i,s,o,r;e==document&&(e=document.documentElement),K.__&&K.__(t,e),s=(i=typeof n=="function")?null:n&&n.__k||e.__k,o=[],r=[],Ki(e,t=(!i&&n||e).__k=je(et,null,[t]),s||gn,gn,e.namespaceURI,!i&&n?[n]:s?null:e.firstChild?mn.call(e.childNodes):null,o,!i&&n?n:s?s.__e:e.firstChild,i,r),co(o,t,r)}function ho(t,e){ti(t,e,ho)}function Yi(t,e,n){var i,s,o,r,a=Qe({},t.props);for(o in t.type&&t.type.defaultProps&&(r=t.type.defaultProps),e)o=="key"?i=e[o]:o=="ref"?s=e[o]:a[o]=e[o]===void 0&&r!=null?r[o]:e[o];return arguments.length>2&&(a.children=arguments.length>3?mn.call(arguments,2):n),vn(t.type,a,i||t.key,s||t.ref,null)}function It(t){function e(n){var i,s;return this.getChildContext||(i=new Set,(s={})[e.__c]=this,this.getChildContext=function(){return s},this.componentWillUnmount=function(){i=null},this.shouldComponentUpdate=function(o){this.props.value!=o.value&&i.forEach(function(r){r.__e=!0,qi(r)})},this.sub=function(o){i.add(o);var r=o.componentWillUnmount;o.componentWillUnmount=function(){i&&i.delete(o),r&&r.call(o)}}),n.children}return e.__c="__cC"+to++,e.__=t,e.Provider=e.__l=(e.Consumer=function(n,i){return n.children(i)}).contextType=e,e}mn=no.slice,K={__e:function(t,e,n,i){for(var s,o,r;e=e.__;)if((s=e.__c)&&!s.__)try{if((o=s.constructor)&&o.getDerivedStateFromError!=null&&(s.setState(o.getDerivedStateFromError(t)),r=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(t,i||{}),r=s.__d),r)return s.__E=s}catch(a){t=a}throw t}},Yr=0,Ke.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Qe({},this.state),typeof t=="function"&&(t=t(Qe({},n),this.props)),t&&Qe(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),qi(this))},Ke.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),qi(this))},Ke.prototype.render=et,At=[],Jr=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Qr=function(t,e){return t.__v.__b-e.__v.__b},Qn.__r=0,eo=/(PointerCapture)$|Capture$/i,Gi=0,Hi=ao(!1),Wi=ao(!0),to=0;var bd=0;function E(t,e,n,i,s,o){e||(e={});var r,a,c=e;if("ref"in c)for(a in c={},e)a=="ref"?r=e[a]:c[a]=e[a];var l={type:t,props:c,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--bd,__i:-1,__u:0,__source:s,__self:o};if(typeof t=="function"&&(r=t.defaultProps))for(a in r)c[a]===void 0&&(c[a]=r[a]);return K.vnode&&K.vnode(l),l}function Zi(){return(Zi=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}var wd=["context","children"];function xd(t){this.getChildContext=function(){return t.context};var e=t.children,n=function(i,s){if(i==null)return{};var o,r,a={},c=Object.keys(i);for(r=0;r<c.length;r++)s.indexOf(o=c[r])>=0||(a[o]=i[o]);return a}(t,wd);return Yi(e,n)}function Sd(){var t=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(t),this._vdom=je(xd,Zi({},this._props,{context:t.detail.context}),function e(n,i){if(n.nodeType===3)return n.data;if(n.nodeType!==1)return null;var s=[],o={},r=0,a=n.attributes,c=n.childNodes;for(r=a.length;r--;)a[r].name!=="slot"&&(o[a[r].name]=a[r].value,o[fo(a[r].name)]=a[r].value);for(r=c.length;r--;){var l=e(c[r],null),d=c[r].slot;d?o[d]=je(po,{name:d},l):s[r]=l}var u=i?je(po,null,s):s;return je(i||n.nodeName.toLowerCase(),o,u)}(this,this._vdomComponent)),(this.hasAttribute("hydrate")?ho:ti)(this._vdom,this._root)}function fo(t){return t.replace(/-(\w)/g,function(e,n){return n?n.toUpperCase():""})}function kd(t,e,n){if(this._vdom){var i={};i[t]=n=n??void 0,i[fo(t)]=n,this._vdom=Yi(this._vdom,i),ti(this._vdom,this._root)}}function Cd(){ti(this._vdom=null,this._root)}function po(t,e){var n=this;return je("slot",Zi({},t,{ref:function(i){i?(n.ref=i,n._listener||(n._listener=function(s){s.stopPropagation(),s.detail.context=e},i.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function Td(t,e,n,i){function s(){var o=Reflect.construct(HTMLElement,[],s);return o._vdomComponent=t,o._root=i&&i.shadow?o.attachShadow({mode:i.mode||"open"}):o,o}return(s.prototype=Object.create(HTMLElement.prototype)).constructor=s,s.prototype.connectedCallback=Sd,s.prototype.attributeChangedCallback=kd,s.prototype.disconnectedCallback=Cd,n=n||t.observedAttributes||Object.keys(t.propTypes||{}),s.observedAttributes=n,n.forEach(function(o){Object.defineProperty(s.prototype,o,{get:function(){return this._vdom.props[o]},set:function(r){this._vdom?this.attributeChangedCallback(o,null,r):(this._props||(this._props={}),this._props[o]=r,this.connectedCallback());var a=typeof r;r!=null&&a!=="string"&&a!=="boolean"&&a!=="number"||this.setAttribute(o,r)}})}),customElements.define(e,s)}var _t,ae,Ji,mo,yn=0,go=[],pe=K,_o=pe.__b,vo=pe.__r,yo=pe.diffed,bo=pe.__c,wo=pe.unmount,xo=pe.__;function zt(t,e){pe.__h&&pe.__h(ae,t,yn||e),yn=0;var n=ae.__H||(ae.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function Xe(t){return yn=1,So(Co,t)}function So(t,e,n){var i=zt(_t++,2);if(i.t=t,!i.__c&&(i.__=[n?n(e):Co(void 0,e),function(a){var c=i.__N?i.__N[0]:i.__[0],l=i.t(c,a);c!==l&&(i.__N=[l,i.__[1]],i.__c.setState({}))}],i.__c=ae,!ae.__f)){var s=function(a,c,l){if(!i.__c.__H)return!0;var d=i.__c.__H.__.filter(function(m){return!!m.__c});if(d.every(function(m){return!m.__N}))return!o||o.call(this,a,c,l);var u=i.__c.props!==a;return d.forEach(function(m){if(m.__N){var g=m.__[0];m.__=m.__N,m.__N=void 0,g!==m.__[0]&&(u=!0)}}),o&&o.call(this,a,c,l)||u};ae.__f=!0;var o=ae.shouldComponentUpdate,r=ae.componentWillUpdate;ae.componentWillUpdate=function(a,c,l){if(this.__e){var d=o;o=void 0,s(a,c,l),o=d}r&&r.call(this,a,c,l)},ae.shouldComponentUpdate=s}return i.__N||i.__}function $e(t,e){var n=zt(_t++,3);!pe.__s&&ns(n.__H,e)&&(n.__=t,n.u=e,ae.__H.__h.push(n))}function Qi(t,e){var n=zt(_t++,4);!pe.__s&&ns(n.__H,e)&&(n.__=t,n.u=e,ae.__h.push(n))}function De(t){return yn=5,nt(function(){return{current:t}},[])}function nt(t,e){var n=zt(_t++,7);return ns(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function ni(t,e){return yn=8,nt(function(){return t},e)}function we(t){var e=ae.context[t.__c],n=zt(_t++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(ae)),e.props.value):t.__}function Ed(t,e){pe.useDebugValue&&pe.useDebugValue(e?e(t):t)}function es(){var t=zt(_t++,11);if(!t.__){for(var e=ae.__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 Ad(){for(var t;t=go.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ii),t.__H.__h.forEach(ts),t.__H.__h=[]}catch(e){t.__H.__h=[],pe.__e(e,t.__v)}}pe.__b=function(t){ae=null,_o&&_o(t)},pe.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),xo&&xo(t,e)},pe.__r=function(t){vo&&vo(t),_t=0;var e=(ae=t.__c).__H;e&&(Ji===ae?(e.__h=[],ae.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(ii),e.__h.forEach(ts),e.__h=[],_t=0)),Ji=ae},pe.diffed=function(t){yo&&yo(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(go.push(e)!==1&&mo===pe.requestAnimationFrame||((mo=pe.requestAnimationFrame)||Id)(Ad)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Ji=ae=null},pe.__c=function(t,e){e.some(function(n){try{n.__h.forEach(ii),n.__h=n.__h.filter(function(i){return!i.__||ts(i)})}catch(i){e.some(function(s){s.__h&&(s.__h=[])}),e=[],pe.__e(i,n.__v)}}),bo&&bo(t,e)},pe.unmount=function(t){wo&&wo(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(i){try{ii(i)}catch(s){e=s}}),n.__H=void 0,e&&pe.__e(e,n.__v))};var ko=typeof requestAnimationFrame=="function";function Id(t){var e,n=function(){clearTimeout(i),ko&&cancelAnimationFrame(e),setTimeout(t)},i=setTimeout(n,35);ko&&(e=requestAnimationFrame(n))}function ii(t){var e=ae,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),ae=e}function ts(t){var e=ae;t.__c=t.__(),ae=e}function ns(t,e){return!t||t.length!==e.length||e.some(function(n,i){return n!==t[i]})}function Co(t,e){return typeof e=="function"?e(t):e}function To(t,e){for(var n in e)t[n]=e[n];return t}function Eo(t,e){for(var n in t)if(n!=="__source"&&!(n in e))return!0;for(var i in e)if(i!=="__source"&&t[i]!==e[i])return!0;return!1}var Ao=Qi;function Io(t,e){this.props=t,this.context=e}(Io.prototype=new Ke).isPureReactComponent=!0,Io.prototype.shouldComponentUpdate=function(t,e){return Eo(this.props,t)||Eo(this.state,e)};var Po=K.__b;K.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),Po&&Po(t)};var Pd=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function Rd(t){function e(n){var i=To({},n);return delete i.ref,t(i,n.ref||null)}return e.$$typeof=Pd,e.render=e,e.prototype.isReactComponent=e.__f=!0,e.displayName="ForwardRef("+(t.displayName||t.name)+")",e}var Ro=function(t,e){return t==null?null:tt(tt(t).map(e))},Md={map:Ro,forEach:Ro,count:function(t){return t?tt(t).length:0},only:function(t){var e=tt(t);if(e.length!==1)throw"Children.only";return e[0]},toArray:tt},Dd=K.__e;K.__e=function(t,e,n,i){if(t.then){for(var s,o=e;o=o.__;)if((s=o.__c)&&s.__c)return e.__e==null&&(e.__e=n.__e,e.__k=n.__k),s.__c(t,e)}Dd(t,e,n,i)};var Mo=K.unmount;function Do(t,e,n){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(i){typeof i.__c=="function"&&i.__c()}),t.__c.__H=null),(t=To({},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(i){return Do(i,e,n)})),t}function Lo(t,e,n){return t&&n&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(i){return Lo(i,e,n)}),t.__c&&t.__c.__P===e&&(t.__e&&n.appendChild(t.__e),t.__c.__e=!0,t.__c.__P=n)),t}function is(){this.__u=0,this.o=null,this.__b=null}function Oo(t){var e=t.__.__c;return e&&e.__a&&e.__a(t)}function si(){this.i=null,this.l=null}K.unmount=function(t){var e=t.__c;e&&e.__R&&e.__R(),e&&32&t.__u&&(t.type=null),Mo&&Mo(t)},(is.prototype=new Ke).__c=function(t,e){var n=e.__c,i=this;i.o==null&&(i.o=[]),i.o.push(n);var s=Oo(i.__v),o=!1,r=function(){o||(o=!0,n.__R=null,s?s(a):a())};n.__R=r;var a=function(){if(!--i.__u){if(i.state.__a){var c=i.state.__a;i.__v.__k[0]=Lo(c,c.__c.__P,c.__c.__O)}var l;for(i.setState({__a:i.__b=null});l=i.o.pop();)l.forceUpdate()}};i.__u++||32&e.__u||i.setState({__a:i.__b=i.__v.__k[0]}),t.then(r,r)},is.prototype.componentWillUnmount=function(){this.o=[]},is.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=Do(this.__b,n,i.__O=i.__P)}this.__b=null}var s=e.__a&&je(et,null,t.fallback);return s&&(s.__u&=-33),[je(et,null,e.__a?null:t.children),s]};var No=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]}};(si.prototype=new Ke).__a=function(t){var e=this,n=Oo(e.__v),i=e.l.get(t);return i[0]++,function(s){var o=function(){e.props.revealOrder?(i.push(s),No(e,t,i)):s()};n?n(o):o()}},si.prototype.render=function(t){this.i=null,this.l=new Map;var e=tt(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},si.prototype.componentDidUpdate=si.prototype.componentDidMount=function(){var t=this;this.l.forEach(function(e,n){No(t,n,e)})};var Vo=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,Ld=/^(?: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]/,Od=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Nd=/[A-Z0-9]/g,Vd=typeof document<"u",Fd=function(t){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(t)};Ke.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(t){Object.defineProperty(Ke.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})});var Fo=K.event;function Bd(){}function jd(){return this.cancelBubble}function $d(){return this.defaultPrevented}K.event=function(t){return Fo&&(t=Fo(t)),t.persist=Bd,t.isPropagationStopped=jd,t.isDefaultPrevented=$d,t.nativeEvent=t};var Ud={enumerable:!1,configurable:!0,get:function(){return this.class}},Bo=K.vnode;K.vnode=function(t){typeof t.type=="string"&&function(e){var n=e.props,i=e.type,s={},o=i.indexOf("-")===-1;for(var r in n){var a=n[r];if(!(r==="value"&&"defaultValue"in n&&a==null||Vd&&r==="children"&&i==="noscript"||r==="class"||r==="className")){var c=r.toLowerCase();r==="defaultValue"&&"value"in n&&n.value==null?r="value":r==="download"&&a===!0?a="":c==="translate"&&a==="no"?a=!1:c[0]==="o"&&c[1]==="n"?c==="ondoubleclick"?r="ondblclick":c!=="onchange"||i!=="input"&&i!=="textarea"||Fd(n.type)?c==="onfocus"?r="onfocusin":c==="onblur"?r="onfocusout":Od.test(r)&&(r=c):c=r="oninput":o&&Ld.test(r)?r=r.replace(Nd,"-$&").toLowerCase():a===null&&(a=void 0),c==="oninput"&&s[r=c]&&(r="oninputCapture"),s[r]=a}}i=="select"&&s.multiple&&Array.isArray(s.value)&&(s.value=tt(n.children).forEach(function(l){l.props.selected=s.value.indexOf(l.props.value)!=-1})),i=="select"&&s.defaultValue!=null&&(s.value=tt(n.children).forEach(function(l){l.props.selected=s.multiple?s.defaultValue.indexOf(l.props.value)!=-1:s.defaultValue==l.props.value})),n.class&&!n.className?(s.class=n.class,Object.defineProperty(s,"className",Ud)):(n.className&&!n.class||n.class&&n.className)&&(s.class=s.className=n.className),e.props=s}(t),t.$$typeof=Vo,Bo&&Bo(t)};var jo=K.__r;K.__r=function(t){jo&&jo(t),t.__c};var $o=K.diffed;K.diffed=function(t){$o&&$o(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)};function Uo(t){return!!t&&t.$$typeof===Vo}function Gd(t){return Uo(t)?Yi.apply(null,arguments):t}var Go={};const ss=It({});function ri(t){const e=De(null);return e.current===null&&(e.current=t()),e.current}const rs=typeof window<"u",Ho=rs?Qi:$e,oi=It(null);function os(t,e){t.indexOf(e)===-1&&t.push(e)}function as(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const ht=(t,e,n)=>n>e?e:n<t?t:n;let cs=()=>{};const ft={},Wo=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function zo(t){return typeof t=="object"&&t!==null}const qo=t=>/^0[^.\s]+$/u.test(t);function ls(t){let e;return()=>(e===void 0&&(e=t()),e)}const Ue=t=>t,Hd=(t,e)=>n=>e(t(n)),bn=(...t)=>t.reduce(Hd),wn=(t,e,n)=>{const i=e-t;return i===0?1:(n-t)/i};class us{constructor(){this.subscriptions=[]}add(e){return os(this.subscriptions,e),()=>as(this.subscriptions,e)}notify(e,n,i){const s=this.subscriptions.length;if(s)if(s===1)this.subscriptions[0](e,n,i);else for(let o=0;o<s;o++){const r=this.subscriptions[o];r&&r(e,n,i)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const it=t=>t*1e3,st=t=>t/1e3;function Ko(t,e){return e?t*(1e3/e):0}const Xo=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Wd=1e-7,zd=12;function qd(t,e,n,i,s){let o,r,a=0;do r=e+(n-e)/2,o=Xo(r,i,s)-t,o>0?n=r:e=r;while(Math.abs(o)>Wd&&++a<zd);return r}function xn(t,e,n,i){if(t===e&&n===i)return Ue;const s=o=>qd(o,0,1,t,n);return o=>o===0||o===1?o:Xo(s(o),e,i)}const Yo=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Zo=t=>e=>1-t(1-e),Jo=xn(.33,1.53,.69,.99),ds=Zo(Jo),Qo=Yo(ds),ea=t=>(t*=2)<1?.5*ds(t):.5*(2-Math.pow(2,-10*(t-1))),hs=t=>1-Math.sin(Math.acos(t)),ta=Zo(hs),na=Yo(hs),Kd=xn(.42,0,1,1),Xd=xn(0,0,.58,1),ia=xn(.42,0,.58,1),Yd=t=>Array.isArray(t)&&typeof t[0]!="number",sa=t=>Array.isArray(t)&&typeof t[0]=="number",Zd={linear:Ue,easeIn:Kd,easeInOut:ia,easeOut:Xd,circIn:hs,circInOut:na,circOut:ta,backIn:ds,backInOut:Qo,backOut:Jo,anticipate:ea},Jd=t=>typeof t=="string",ra=t=>{if(sa(t)){cs(t.length===4);const[e,n,i,s]=t;return xn(e,n,i,s)}else if(Jd(t))return Zd[t];return t},ai=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],oa={value:null};function Qd(t,e){let n=new Set,i=new Set,s=!1,o=!1;const r=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1},c=0;function l(u){r.has(u)&&(d.schedule(u),t()),c++,u(a)}const d={schedule:(u,m=!1,g=!1)=>{const w=g&&s?n:i;return m&&r.add(u),w.has(u)||w.add(u),u},cancel:u=>{i.delete(u),r.delete(u)},process:u=>{if(a=u,s){o=!0;return}s=!0,[n,i]=[i,n],n.forEach(l),e&&oa.value&&oa.value.frameloop[e].push(c),c=0,n.clear(),s=!1,o&&(o=!1,d.process(u))}};return d}const eh=40;function aa(t,e){let n=!1,i=!0;const s={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,r=ai.reduce((k,I)=>(k[I]=Qd(o,e?I:void 0),k),{}),{setup:a,read:c,resolveKeyframes:l,preUpdate:d,update:u,preRender:m,render:g,postRender:y}=r,w=()=>{const k=ft.useManualTiming?s.timestamp:performance.now();n=!1,ft.useManualTiming||(s.delta=i?1e3/60:Math.max(Math.min(k-s.timestamp,eh),1)),s.timestamp=k,s.isProcessing=!0,a.process(s),c.process(s),l.process(s),d.process(s),u.process(s),m.process(s),g.process(s),y.process(s),s.isProcessing=!1,n&&e&&(i=!1,t(w))},b=()=>{n=!0,i=!0,s.isProcessing||t(w)};return{schedule:ai.reduce((k,I)=>{const D=r[I];return k[I]=(O,x=!1,C=!1)=>(n||b(),D.schedule(O,x,C)),k},{}),cancel:k=>{for(let I=0;I<ai.length;I++)r[ai[I]].cancel(k)},state:s,steps:r}}const{schedule:ue,cancel:vt,state:Se,steps:fs}=aa(typeof requestAnimationFrame<"u"?requestAnimationFrame:Ue,!0);let ci;function th(){ci=void 0}const Le={now:()=>(ci===void 0&&Le.set(Se.isProcessing||ft.useManualTiming?Se.timestamp:performance.now()),ci),set:t=>{ci=t,queueMicrotask(th)}},ca=t=>e=>typeof e=="string"&&e.startsWith(t),ps=ca("--"),nh=ca("var(--"),ms=t=>nh(t)?ih.test(t.split("/*")[0].trim()):!1,ih=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,qt={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Sn={...qt,transform:t=>ht(0,1,t)},li={...qt,default:1},kn=t=>Math.round(t*1e5)/1e5,gs=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function sh(t){return t==null}const rh=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,_s=(t,e)=>n=>!!(typeof n=="string"&&rh.test(n)&&n.startsWith(t)||e&&!sh(n)&&Object.prototype.hasOwnProperty.call(n,e)),la=(t,e,n)=>i=>{if(typeof i!="string")return i;const[s,o,r,a]=i.match(gs);return{[t]:parseFloat(s),[e]:parseFloat(o),[n]:parseFloat(r),alpha:a!==void 0?parseFloat(a):1}},oh=t=>ht(0,255,t),vs={...qt,transform:t=>Math.round(oh(t))},Pt={test:_s("rgb","red"),parse:la("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:i=1})=>"rgba("+vs.transform(t)+", "+vs.transform(e)+", "+vs.transform(n)+", "+kn(Sn.transform(i))+")"};function ah(t){let e="",n="",i="",s="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),i=t.substring(5,7),s=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),i=t.substring(3,4),s=t.substring(4,5),e+=e,n+=n,i+=i,s+=s),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(i,16),alpha:s?parseInt(s,16)/255:1}}const ys={test:_s("#"),parse:ah,transform:Pt.transform},Cn=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),yt=Cn("deg"),rt=Cn("%"),G=Cn("px"),ch=Cn("vh"),lh=Cn("vw"),ua={...rt,parse:t=>rt.parse(t)/100,transform:t=>rt.transform(t*100)},Kt={test:_s("hsl","hue"),parse:la("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:i=1})=>"hsla("+Math.round(t)+", "+rt.transform(kn(e))+", "+rt.transform(kn(n))+", "+kn(Sn.transform(i))+")"},ye={test:t=>Pt.test(t)||ys.test(t)||Kt.test(t),parse:t=>Pt.test(t)?Pt.parse(t):Kt.test(t)?Kt.parse(t):ys.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Pt.transform(t):Kt.transform(t),getAnimatableNone:t=>{const e=ye.parse(t);return e.alpha=0,ye.transform(e)}},uh=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function dh(t){var e,n;return isNaN(t)&&typeof t=="string"&&(((e=t.match(gs))==null?void 0:e.length)||0)+(((n=t.match(uh))==null?void 0:n.length)||0)>0}const da="number",ha="color",hh="var",fh="var(",fa="${}",ph=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Tn(t){const e=t.toString(),n=[],i={color:[],number:[],var:[]},s=[];let o=0;const a=e.replace(ph,c=>(ye.test(c)?(i.color.push(o),s.push(ha),n.push(ye.parse(c))):c.startsWith(fh)?(i.var.push(o),s.push(hh),n.push(c)):(i.number.push(o),s.push(da),n.push(parseFloat(c))),++o,fa)).split(fa);return{values:n,split:a,indexes:i,types:s}}function pa(t){return Tn(t).values}function ma(t){const{split:e,types:n}=Tn(t),i=e.length;return s=>{let o="";for(let r=0;r<i;r++)if(o+=e[r],s[r]!==void 0){const a=n[r];a===da?o+=kn(s[r]):a===ha?o+=ye.transform(s[r]):o+=s[r]}return o}}const mh=t=>typeof t=="number"?0:ye.test(t)?ye.getAnimatableNone(t):t;function gh(t){const e=pa(t);return ma(t)(e.map(mh))}const bt={test:dh,parse:pa,createTransformer:ma,getAnimatableNone:gh};function bs(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function _h({hue:t,saturation:e,lightness:n,alpha:i}){t/=360,e/=100,n/=100;let s=0,o=0,r=0;if(!e)s=o=r=n;else{const a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;s=bs(c,a,t+1/3),o=bs(c,a,t),r=bs(c,a,t-1/3)}return{red:Math.round(s*255),green:Math.round(o*255),blue:Math.round(r*255),alpha:i}}function ui(t,e){return n=>n>0?e:t}const me=(t,e,n)=>t+(e-t)*n,ws=(t,e,n)=>{const i=t*t,s=n*(e*e-i)+i;return s<0?0:Math.sqrt(s)},vh=[ys,Pt,Kt],yh=t=>vh.find(e=>e.test(t));function ga(t){const e=yh(t);if(!e)return!1;let n=e.parse(t);return e===Kt&&(n=_h(n)),n}const _a=(t,e)=>{const n=ga(t),i=ga(e);if(!n||!i)return ui(t,e);const s={...n};return o=>(s.red=ws(n.red,i.red,o),s.green=ws(n.green,i.green,o),s.blue=ws(n.blue,i.blue,o),s.alpha=me(n.alpha,i.alpha,o),Pt.transform(s))},xs=new Set(["none","hidden"]);function bh(t,e){return xs.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function wh(t,e){return n=>me(t,e,n)}function Ss(t){return typeof t=="number"?wh:typeof t=="string"?ms(t)?ui:ye.test(t)?_a:kh:Array.isArray(t)?va:typeof t=="object"?ye.test(t)?_a:xh:ui}function va(t,e){const n=[...t],i=n.length,s=t.map((o,r)=>Ss(o)(o,e[r]));return o=>{for(let r=0;r<i;r++)n[r]=s[r](o);return n}}function xh(t,e){const n={...t,...e},i={};for(const s in n)t[s]!==void 0&&e[s]!==void 0&&(i[s]=Ss(t[s])(t[s],e[s]));return s=>{for(const o in i)n[o]=i[o](s);return n}}function Sh(t,e){const n=[],i={color:0,var:0,number:0};for(let s=0;s<e.values.length;s++){const o=e.types[s],r=t.indexes[o][i[o]],a=t.values[r]??0;n[s]=a,i[o]++}return n}const kh=(t,e)=>{const n=bt.createTransformer(e),i=Tn(t),s=Tn(e);return i.indexes.var.length===s.indexes.var.length&&i.indexes.color.length===s.indexes.color.length&&i.indexes.number.length>=s.indexes.number.length?xs.has(t)&&!s.values.length||xs.has(e)&&!i.values.length?bh(t,e):bn(va(Sh(i,s),s.values),n):ui(t,e)};function ya(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?me(t,e,n):Ss(t)(t,e)}const Ch=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>ue.update(e,n),stop:()=>vt(e),now:()=>Se.isProcessing?Se.timestamp:Le.now()}},ba=(t,e,n=10)=>{let i="";const s=Math.max(Math.round(e/n),2);for(let o=0;o<s;o++)i+=Math.round(t(o/(s-1))*1e4)/1e4+", ";return`linear(${i.substring(0,i.length-2)})`},di=2e4;function ks(t){let e=0;const n=50;let i=t.next(e);for(;!i.done&&e<di;)e+=n,i=t.next(e);return e>=di?1/0:e}function Th(t,e=100,n){const i=n({...t,keyframes:[0,e]}),s=Math.min(ks(i),di);return{type:"keyframes",ease:o=>i.next(s*o).value/e,duration:st(s)}}const Eh=5;function wa(t,e,n){const i=Math.max(e-Eh,0);return Ko(n-t(i),e-i)}const ge={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},Cs=.001;function Ah({duration:t=ge.duration,bounce:e=ge.bounce,velocity:n=ge.velocity,mass:i=ge.mass}){let s,o,r=1-e;r=ht(ge.minDamping,ge.maxDamping,r),t=ht(ge.minDuration,ge.maxDuration,st(t)),r<1?(s=l=>{const d=l*r,u=d*t,m=d-n,g=Ts(l,r),y=Math.exp(-u);return Cs-m/g*y},o=l=>{const u=l*r*t,m=u*n+n,g=Math.pow(r,2)*Math.pow(l,2)*t,y=Math.exp(-u),w=Ts(Math.pow(l,2),r);return(-s(l)+Cs>0?-1:1)*((m-g)*y)/w}):(s=l=>{const d=Math.exp(-l*t),u=(l-n)*t+1;return-Cs+d*u},o=l=>{const d=Math.exp(-l*t),u=(n-l)*(t*t);return d*u});const a=5/t,c=Ph(s,o,a);if(t=it(t),isNaN(c))return{stiffness:ge.stiffness,damping:ge.damping,duration:t};{const l=Math.pow(c,2)*i;return{stiffness:l,damping:r*2*Math.sqrt(i*l),duration:t}}}const Ih=12;function Ph(t,e,n){let i=n;for(let s=1;s<Ih;s++)i=i-t(i)/e(i);return i}function Ts(t,e){return t*Math.sqrt(1-e*e)}const Rh=["duration","bounce"],Mh=["stiffness","damping","mass"];function xa(t,e){return e.some(n=>t[n]!==void 0)}function Dh(t){let e={velocity:ge.velocity,stiffness:ge.stiffness,damping:ge.damping,mass:ge.mass,isResolvedFromDuration:!1,...t};if(!xa(t,Mh)&&xa(t,Rh))if(t.visualDuration){const n=t.visualDuration,i=2*Math.PI/(n*1.2),s=i*i,o=2*ht(.05,1,1-(t.bounce||0))*Math.sqrt(s);e={...e,mass:ge.mass,stiffness:s,damping:o}}else{const n=Ah(t);e={...e,...n,mass:ge.mass},e.isResolvedFromDuration=!0}return e}function hi(t=ge.visualDuration,e=ge.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:i,restDelta:s}=n;const o=n.keyframes[0],r=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:c,damping:l,mass:d,duration:u,velocity:m,isResolvedFromDuration:g}=Dh({...n,velocity:-st(n.velocity||0)}),y=m||0,w=l/(2*Math.sqrt(c*d)),b=r-o,v=st(Math.sqrt(c/d)),S=Math.abs(b)<5;i||(i=S?ge.restSpeed.granular:ge.restSpeed.default),s||(s=S?ge.restDelta.granular:ge.restDelta.default);let k;if(w<1){const D=Ts(v,w);k=O=>{const x=Math.exp(-w*v*O);return r-x*((y+w*v*b)/D*Math.sin(D*O)+b*Math.cos(D*O))}}else if(w===1)k=D=>r-Math.exp(-v*D)*(b+(y+v*b)*D);else{const D=v*Math.sqrt(w*w-1);k=O=>{const x=Math.exp(-w*v*O),C=Math.min(D*O,300);return r-x*((y+w*v*b)*Math.sinh(C)+D*b*Math.cosh(C))/D}}const I={calculatedDuration:g&&u||null,next:D=>{const O=k(D);if(g)a.done=D>=u;else{let x=D===0?y:0;w<1&&(x=D===0?it(y):wa(k,D,O));const C=Math.abs(x)<=i,f=Math.abs(r-O)<=s;a.done=C&&f}return a.value=a.done?r:O,a},toString:()=>{const D=Math.min(ks(I),di),O=ba(x=>I.next(D*x).value,D,30);return D+"ms "+O},toTransition:()=>{}};return I}hi.applyToOptions=t=>{const e=Th(t,100,hi);return t.ease=e.ease,t.duration=it(e.duration),t.type="keyframes",t};function Es({keyframes:t,velocity:e=0,power:n=.8,timeConstant:i=325,bounceDamping:s=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:c,restDelta:l=.5,restSpeed:d}){const u=t[0],m={done:!1,value:u},g=C=>a!==void 0&&C<a||c!==void 0&&C>c,y=C=>a===void 0?c:c===void 0||Math.abs(a-C)<Math.abs(c-C)?a:c;let w=n*e;const b=u+w,v=r===void 0?b:r(b);v!==b&&(w=v-u);const S=C=>-w*Math.exp(-C/i),k=C=>v+S(C),I=C=>{const f=S(C),p=k(C);m.done=Math.abs(f)<=l,m.value=m.done?v:p};let D,O;const x=C=>{g(m.value)&&(D=C,O=hi({keyframes:[m.value,y(m.value)],velocity:wa(k,C,m.value),damping:s,stiffness:o,restDelta:l,restSpeed:d}))};return x(0),{calculatedDuration:null,next:C=>{let f=!1;return!O&&D===void 0&&(f=!0,I(C),x(C)),D!==void 0&&C>=D?O.next(C-D):(!f&&I(C),m)}}}function Lh(t,e,n){const i=[],s=n||ft.mix||ya,o=t.length-1;for(let r=0;r<o;r++){let a=s(t[r],t[r+1]);if(e){const c=Array.isArray(e)?e[r]||Ue:e;a=bn(c,a)}i.push(a)}return i}function Oh(t,e,{clamp:n=!0,ease:i,mixer:s}={}){const o=t.length;if(cs(o===e.length),o===1)return()=>e[0];if(o===2&&e[0]===e[1])return()=>e[1];const r=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=Lh(e,i,s),c=a.length,l=d=>{if(r&&d<t[0])return e[0];let u=0;if(c>1)for(;u<t.length-2&&!(d<t[u+1]);u++);const m=wn(t[u],t[u+1],d);return a[u](m)};return n?d=>l(ht(t[0],t[o-1],d)):l}function Nh(t,e){const n=t[t.length-1];for(let i=1;i<=e;i++){const s=wn(0,e,i);t.push(me(n,1,s))}}function Vh(t){const e=[0];return Nh(e,t.length-1),e}function Fh(t,e){return t.map(n=>n*e)}function Bh(t,e){return t.map(()=>e||ia).splice(0,t.length-1)}function En({duration:t=300,keyframes:e,times:n,ease:i="easeInOut"}){const s=Yd(i)?i.map(ra):ra(i),o={done:!1,value:e[0]},r=Fh(n&&n.length===e.length?n:Vh(e),t),a=Oh(r,e,{ease:Array.isArray(s)?s:Bh(e,s)});return{calculatedDuration:t,next:c=>(o.value=a(c),o.done=c>=t,o)}}const jh=t=>t!==null;function As(t,{repeat:e,repeatType:n="loop"},i,s=1){const o=t.filter(jh),a=s<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!a||i===void 0?o[a]:i}const $h={decay:Es,inertia:Es,tween:En,keyframes:En,spring:hi};function Sa(t){typeof t.type=="string"&&(t.type=$h[t.type])}class Is{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const Uh=t=>t/100;class Ps extends Is{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{var i,s;const{motionValue:n}=this.options;n&&n.updatedAt!==Le.now()&&this.tick(Le.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(s=(i=this.options).onStop)==null||s.call(i))},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;Sa(e);const{type:n=En,repeat:i=0,repeatDelay:s=0,repeatType:o,velocity:r=0}=e;let{keyframes:a}=e;const c=n||En;c!==En&&typeof a[0]!="number"&&(this.mixKeyframes=bn(Uh,ya(a[0],a[1])),a=[0,100]);const l=c({...e,keyframes:a});o==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...a].reverse(),velocity:-r})),l.calculatedDuration===null&&(l.calculatedDuration=ks(l));const{calculatedDuration:d}=l;this.calculatedDuration=d,this.resolvedDuration=d+s,this.totalDuration=this.resolvedDuration*(i+1)-s,this.generator=l}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:i,totalDuration:s,mixKeyframes:o,mirroredGenerator:r,resolvedDuration:a,calculatedDuration:c}=this;if(this.startTime===null)return i.next(0);const{delay:l=0,keyframes:d,repeat:u,repeatType:m,repeatDelay:g,type:y,onUpdate:w,finalKeyframe:b}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-s/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const v=this.currentTime-l*(this.playbackSpeed>=0?1:-1),S=this.playbackSpeed>=0?v<0:v>s;this.currentTime=Math.max(v,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=s);let k=this.currentTime,I=i;if(u){const C=Math.min(this.currentTime,s)/a;let f=Math.floor(C),p=C%1;!p&&C>=1&&(p=1),p===1&&f--,f=Math.min(f,u+1),!!(f%2)&&(m==="reverse"?(p=1-p,g&&(p-=g/a)):m==="mirror"&&(I=r)),k=ht(0,1,p)*a}const D=S?{done:!1,value:d[0]}:I.next(k);o&&(D.value=o(D.value));let{done:O}=D;!S&&c!==null&&(O=this.playbackSpeed>=0?this.currentTime>=s:this.currentTime<=0);const x=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&O);return x&&y!==Es&&(D.value=As(d,this.options,b,this.speed)),w&&w(D.value),x&&this.finish(),D}then(e,n){return this.finished.then(e,n)}get duration(){return st(this.calculatedDuration)}get time(){return st(this.currentTime)}set time(e){var n;e=it(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),(n=this.driver)==null||n.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(Le.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=st(this.currentTime))}play(){var s,o;if(this.isStopped)return;const{driver:e=Ch,startTime:n}=this.options;this.driver||(this.driver=e(r=>this.tick(r))),(o=(s=this.options).onPlay)==null||o.call(s);const i=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=i):this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime||(this.startTime=n??i),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Le.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var e,n;this.notifyFinished(),this.teardown(),this.state="finished",(n=(e=this.options).onComplete)==null||n.call(e)}cancel(){var e,n;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(n=(e=this.options).onCancel)==null||n.call(e)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){var n;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(n=this.driver)==null||n.stop(),e.observe(this)}}function Gh(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const Rt=t=>t*180/Math.PI,Rs=t=>{const e=Rt(Math.atan2(t[1],t[0]));return Ms(e)},Hh={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Rs,rotateZ:Rs,skewX:t=>Rt(Math.atan(t[1])),skewY:t=>Rt(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Ms=t=>(t=t%360,t<0&&(t+=360),t),ka=Rs,Ca=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Ta=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Wh={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Ca,scaleY:Ta,scale:t=>(Ca(t)+Ta(t))/2,rotateX:t=>Ms(Rt(Math.atan2(t[6],t[5]))),rotateY:t=>Ms(Rt(Math.atan2(-t[2],t[0]))),rotateZ:ka,rotate:ka,skewX:t=>Rt(Math.atan(t[4])),skewY:t=>Rt(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Ds(t){return t.includes("scale")?1:0}function Ls(t,e){if(!t||t==="none")return Ds(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let i,s;if(n)i=Wh,s=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);i=Hh,s=a}if(!s)return Ds(e);const o=i[e],r=s[1].split(",").map(qh);return typeof o=="function"?o(r):r[o]}const zh=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return Ls(n,e)};function qh(t){return parseFloat(t.trim())}const Xt=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Yt=new Set(Xt),Ea=t=>t===qt||t===G,Kh=new Set(["x","y","z"]),Xh=Xt.filter(t=>!Kh.has(t));function Yh(t){const e=[];return Xh.forEach(n=>{const i=t.getValue(n);i!==void 0&&(e.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),e}const Mt={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>Ls(e,"x"),y:(t,{transform:e})=>Ls(e,"y")};Mt.translateX=Mt.x,Mt.translateY=Mt.y;const Dt=new Set;let Os=!1,Ns=!1,Vs=!1;function Aa(){if(Ns){const t=Array.from(Dt).filter(i=>i.needsMeasurement),e=new Set(t.map(i=>i.element)),n=new Map;e.forEach(i=>{const s=Yh(i);s.length&&(n.set(i,s),i.render())}),t.forEach(i=>i.measureInitialState()),e.forEach(i=>{i.render();const s=n.get(i);s&&s.forEach(([o,r])=>{var a;(a=i.getValue(o))==null||a.set(r)})}),t.forEach(i=>i.measureEndState()),t.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}Ns=!1,Os=!1,Dt.forEach(t=>t.complete(Vs)),Dt.clear()}function Ia(){Dt.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Ns=!0)})}function Zh(){Vs=!0,Ia(),Aa(),Vs=!1}class Fs{constructor(e,n,i,s,o,r=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=i,this.motionValue=s,this.element=o,this.isAsync=r}scheduleResolve(){this.state="scheduled",this.isAsync?(Dt.add(this),Os||(Os=!0,ue.read(Ia),ue.resolveKeyframes(Aa))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:i,motionValue:s}=this;if(e[0]===null){const o=s==null?void 0:s.get(),r=e[e.length-1];if(o!==void 0)e[0]=o;else if(i&&n){const a=i.readValue(n,r);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=r),s&&o===void 0&&s.set(e[0])}Gh(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Dt.delete(this)}cancel(){this.state==="scheduled"&&(Dt.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Jh=t=>t.startsWith("--");function Qh(t,e,n){Jh(e)?t.style.setProperty(e,n):t.style[e]=n}const ef=ls(()=>window.ScrollTimeline!==void 0),tf={};function nf(t,e){const n=ls(t);return()=>tf[e]??n()}const Pa=nf(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),An=([t,e,n,i])=>`cubic-bezier(${t}, ${e}, ${n}, ${i})`,Ra={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:An([0,.65,.55,1]),circOut:An([.55,0,1,.45]),backIn:An([.31,.01,.66,-.59]),backOut:An([.33,1.53,.69,.99])};function Ma(t,e){if(t)return typeof t=="function"?Pa()?ba(t,e):"ease-out":sa(t)?An(t):Array.isArray(t)?t.map(n=>Ma(n,e)||Ra.easeOut):Ra[t]}function sf(t,e,n,{delay:i=0,duration:s=300,repeat:o=0,repeatType:r="loop",ease:a="easeOut",times:c}={},l=void 0){const d={[e]:n};c&&(d.offset=c);const u=Ma(a,s);Array.isArray(u)&&(d.easing=u);const m={delay:i,duration:s,easing:Array.isArray(u)?"linear":u,fill:"both",iterations:o+1,direction:r==="reverse"?"alternate":"normal"};return l&&(m.pseudoElement=l),t.animate(d,m)}function Da(t){return typeof t=="function"&&"applyToOptions"in t}function rf({type:t,...e}){return Da(t)&&Pa()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class of extends Is{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:i,keyframes:s,pseudoElement:o,allowFlatten:r=!1,finalKeyframe:a,onComplete:c}=e;this.isPseudoElement=!!o,this.allowFlatten=r,this.options=e,cs(typeof e.type!="string");const l=rf(e);this.animation=sf(n,i,s,l,o),l.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const d=As(s,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(d):Qh(n,i,d),this.animation.cancel()}c==null||c(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var e,n;(n=(e=this.animation).finish)==null||n.call(e)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var e,n;this.isPseudoElement||(n=(e=this.animation).commitStyles)==null||n.call(e)}get duration(){var n,i;const e=((i=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:i.call(n).duration)||0;return st(Number(e))}get time(){return st(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=it(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){var i;return this.allowFlatten&&((i=this.animation.effect)==null||i.updateTiming({easing:"linear"})),this.animation.onfinish=null,e&&ef()?(this.animation.timeline=e,Ue):n(this)}}const La={anticipate:ea,backInOut:Qo,circInOut:na};function af(t){return t in La}function cf(t){typeof t.ease=="string"&&af(t.ease)&&(t.ease=La[t.ease])}const Oa=10;class lf extends of{constructor(e){cf(e),Sa(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:i,onComplete:s,element:o,...r}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new Ps({...r,autoplay:!1}),c=it(this.finishedTime??this.time);n.setWithVelocity(a.sample(c-Oa).value,a.sample(c).value,Oa),a.stop()}}const Na=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(bt.test(t)||t==="0")&&!t.startsWith("url("));function uf(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function df(t,e,n,i){const s=t[0];if(s===null)return!1;if(e==="display"||e==="visibility")return!0;const o=t[t.length-1],r=Na(s,e),a=Na(o,e);return!r||!a?!1:uf(t)||(n==="spring"||Da(n))&&i}function Bs(t){return zo(t)&&"offsetHeight"in t}const hf=new Set(["opacity","clipPath","filter","transform"]),ff=ls(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function pf(t){var l;const{motionValue:e,name:n,repeatDelay:i,repeatType:s,damping:o,type:r}=t;if(!Bs((l=e==null?void 0:e.owner)==null?void 0:l.current))return!1;const{onUpdate:a,transformTemplate:c}=e.owner.getProps();return ff()&&n&&hf.has(n)&&(n!=="transform"||!c)&&!a&&!i&&s!=="mirror"&&o!==0&&r!=="inertia"}const mf=40;class gf extends Is{constructor({autoplay:e=!0,delay:n=0,type:i="keyframes",repeat:s=0,repeatDelay:o=0,repeatType:r="loop",keyframes:a,name:c,motionValue:l,element:d,...u}){var y;super(),this.stop=()=>{var w,b;this._animation&&(this._animation.stop(),(w=this.stopTimeline)==null||w.call(this)),(b=this.keyframeResolver)==null||b.cancel()},this.createdAt=Le.now();const m={autoplay:e,delay:n,type:i,repeat:s,repeatDelay:o,repeatType:r,name:c,motionValue:l,element:d,...u},g=(d==null?void 0:d.KeyframeResolver)||Fs;this.keyframeResolver=new g(a,(w,b,v)=>this.onKeyframesResolved(w,b,m,!v),c,l,d),(y=this.keyframeResolver)==null||y.scheduleResolve()}onKeyframesResolved(e,n,i,s){this.keyframeResolver=void 0;const{name:o,type:r,velocity:a,delay:c,isHandoff:l,onUpdate:d}=i;this.resolvedAt=Le.now(),df(e,o,r,a)||((ft.instantAnimations||!c)&&(d==null||d(As(e,i,n))),e[0]=e[e.length-1],i.duration=0,i.repeat=0);const m={startTime:s?this.resolvedAt?this.resolvedAt-this.createdAt>mf?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...i,keyframes:e},g=!l&&pf(m)?new lf({...m,element:m.motionValue.owner.current}):new Ps(m);g.finished.then(()=>this.notifyFinished()).catch(Ue),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){var e;return this._animation||((e=this.keyframeResolver)==null||e.resume(),Zh()),this._animation}get duration(){return this.animation.duration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var e;this._animation&&this.animation.cancel(),(e=this.keyframeResolver)==null||e.cancel()}}const _f=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function vf(t){const e=_f.exec(t);if(!e)return[,];const[,n,i,s]=e;return[`--${n??i}`,s]}function Va(t,e,n=1){const[i,s]=vf(t);if(!i)return;const o=window.getComputedStyle(e).getPropertyValue(i);if(o){const r=o.trim();return Wo(r)?parseFloat(r):r}return ms(s)?Va(s,e,n+1):s}function js(t,e){return(t==null?void 0:t[e])??(t==null?void 0:t.default)??t}const Fa=new Set(["width","height","top","left","right","bottom",...Xt]),yf={test:t=>t==="auto",parse:t=>t},Ba=t=>e=>e.test(t),ja=[qt,G,rt,yt,lh,ch,yf],$a=t=>ja.find(Ba(t));function bf(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||qo(t):!0}const wf=new Set(["brightness","contrast","saturate","opacity"]);function xf(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[i]=n.match(gs)||[];if(!i)return t;const s=n.replace(i,"");let o=wf.has(e)?1:0;return i!==n&&(o*=100),e+"("+o+s+")"}const Sf=/\b([a-z-]*)\(.*?\)/gu,$s={...bt,getAnimatableNone:t=>{const e=t.match(Sf);return e?e.map(xf).join(" "):t}},Ua={...qt,transform:Math.round},Us={borderWidth:G,borderTopWidth:G,borderRightWidth:G,borderBottomWidth:G,borderLeftWidth:G,borderRadius:G,radius:G,borderTopLeftRadius:G,borderTopRightRadius:G,borderBottomRightRadius:G,borderBottomLeftRadius:G,width:G,maxWidth:G,height:G,maxHeight:G,top:G,right:G,bottom:G,left:G,padding:G,paddingTop:G,paddingRight:G,paddingBottom:G,paddingLeft:G,margin:G,marginTop:G,marginRight:G,marginBottom:G,marginLeft:G,backgroundPositionX:G,backgroundPositionY:G,...{rotate:yt,rotateX:yt,rotateY:yt,rotateZ:yt,scale:li,scaleX:li,scaleY:li,scaleZ:li,skew:yt,skewX:yt,skewY:yt,distance:G,translateX:G,translateY:G,translateZ:G,x:G,y:G,z:G,perspective:G,transformPerspective:G,opacity:Sn,originX:ua,originY:ua,originZ:G},zIndex:Ua,fillOpacity:Sn,strokeOpacity:Sn,numOctaves:Ua},kf={...Us,color:ye,backgroundColor:ye,outlineColor:ye,fill:ye,stroke:ye,borderColor:ye,borderTopColor:ye,borderRightColor:ye,borderBottomColor:ye,borderLeftColor:ye,filter:$s,WebkitFilter:$s},Ga=t=>kf[t];function Ha(t,e){let n=Ga(t);return n!==$s&&(n=bt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const Cf=new Set(["auto","none","0"]);function Tf(t,e,n){let i=0,s;for(;i<t.length&&!s;){const o=t[i];typeof o=="string"&&!Cf.has(o)&&Tn(o).values.length&&(s=t[i]),i++}if(s&&n)for(const o of e)t[o]=Ha(n,s)}class Ef extends Fs{constructor(e,n,i,s,o){super(e,n,i,s,o,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:i}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<e.length;c++){let l=e[c];if(typeof l=="string"&&(l=l.trim(),ms(l))){const d=Va(l,n.current);d!==void 0&&(e[c]=d),c===e.length-1&&(this.finalKeyframe=l)}}if(this.resolveNoneKeyframes(),!Fa.has(i)||e.length!==2)return;const[s,o]=e,r=$a(s),a=$a(o);if(r!==a)if(Ea(r)&&Ea(a))for(let c=0;c<e.length;c++){const l=e[c];typeof l=="string"&&(e[c]=parseFloat(l))}else Mt[i]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,i=[];for(let s=0;s<e.length;s++)(e[s]===null||bf(e[s]))&&i.push(s);i.length&&Tf(e,i,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:i}=this;if(!e||!e.current)return;i==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Mt[i](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const s=n[n.length-1];s!==void 0&&e.getValue(i,s).jump(s,!1)}measureEndState(){var a;const{element:e,name:n,unresolvedKeyframes:i}=this;if(!e||!e.current)return;const s=e.getValue(n);s&&s.jump(this.measuredOrigin,!1);const o=i.length-1,r=i[o];i[o]=Mt[n](e.measureViewportBox(),window.getComputedStyle(e.current)),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),(a=this.removedTransforms)!=null&&a.length&&this.removedTransforms.forEach(([c,l])=>{e.getValue(c).set(l)}),this.resolveNoneKeyframes()}}function Af(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let i=document;const s=(n==null?void 0:n[t])??i.querySelectorAll(t);return s?Array.from(s):[]}return Array.from(t)}const Wa=(t,e)=>e&&typeof t=="number"?e.transform(t):t,za=30,If=t=>!isNaN(parseFloat(t));class Pf{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=(i,s=!0)=>{var r,a;const o=Le.now();if(this.updatedAt!==o&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(i),this.current!==this.prev&&((r=this.events.change)==null||r.notify(this.current),this.dependents))for(const c of this.dependents)c.dirty();s&&((a=this.events.renderRequest)==null||a.notify(this.current))},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=Le.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=If(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new us);const i=this.events[e].add(n);return e==="change"?()=>{i(),ue.read(()=>{this.events.change.getSize()||this.stop()})}:i}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e,n=!0){!n||!this.passiveEffect?this.updateAndNotify(e,n):this.passiveEffect(e,this.updateAndNotify)}setWithVelocity(e,n,i){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-i}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var e;(e=this.events.change)==null||e.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=Le.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>za)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,za);return Ko(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var e,n;(e=this.dependents)==null||e.clear(),(n=this.events.destroy)==null||n.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Zt(t,e){return new Pf(t,e)}const{schedule:Gs}=aa(queueMicrotask,!1),Ye={x:!1,y:!1};function qa(){return Ye.x||Ye.y}function Rf(t){return t==="x"||t==="y"?Ye[t]?null:(Ye[t]=!0,()=>{Ye[t]=!1}):Ye.x||Ye.y?null:(Ye.x=Ye.y=!0,()=>{Ye.x=Ye.y=!1})}function Ka(t,e){const n=Af(t),i=new AbortController,s={passive:!0,...e,signal:i.signal};return[n,s,()=>i.abort()]}function Xa(t){return!(t.pointerType==="touch"||qa())}function Mf(t,e,n={}){const[i,s,o]=Ka(t,n),r=a=>{if(!Xa(a))return;const{target:c}=a,l=e(c,a);if(typeof l!="function"||!c)return;const d=u=>{Xa(u)&&(l(u),c.removeEventListener("pointerleave",d))};c.addEventListener("pointerleave",d,s)};return i.forEach(a=>{a.addEventListener("pointerenter",r,s)}),o}const Ya=(t,e)=>e?t===e?!0:Ya(t,e.parentElement):!1,Hs=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Df=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Lf(t){return Df.has(t.tagName)||t.tabIndex!==-1}const fi=new WeakSet;function Za(t){return e=>{e.key==="Enter"&&t(e)}}function Ws(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Of=(t,e)=>{const n=t.currentTarget;if(!n)return;const i=Za(()=>{if(fi.has(n))return;Ws(n,"down");const s=Za(()=>{Ws(n,"up")}),o=()=>Ws(n,"cancel");n.addEventListener("keyup",s,e),n.addEventListener("blur",o,e)});n.addEventListener("keydown",i,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),e)};function Ja(t){return Hs(t)&&!qa()}function Nf(t,e,n={}){const[i,s,o]=Ka(t,n),r=a=>{const c=a.currentTarget;if(!Ja(a))return;fi.add(c);const l=e(c,a),d=(g,y)=>{window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",m),fi.has(c)&&fi.delete(c),Ja(g)&&typeof l=="function"&&l(g,{success:y})},u=g=>{d(g,c===window||c===document||n.useGlobalTarget||Ya(c,g.target))},m=g=>{d(g,!1)};window.addEventListener("pointerup",u,s),window.addEventListener("pointercancel",m,s)};return i.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",r,s),Bs(a)&&(a.addEventListener("focus",l=>Of(l,s)),!Lf(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function Qa(t){return zo(t)&&"ownerSVGElement"in t}function Vf(t){return Qa(t)&&t.tagName==="svg"}const Te=t=>!!(t&&t.getVelocity),Ff=[...ja,ye,bt],Bf=t=>Ff.find(Ba(t)),In=It({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});class jf extends Ke{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const i=n.offsetParent,s=Bs(i)&&i.offsetWidth||0,o=this.props.sizeRef.current;o.height=n.offsetHeight||0,o.width=n.offsetWidth||0,o.top=n.offsetTop,o.left=n.offsetLeft,o.right=s-o.width-o.left}return null}componentDidUpdate(){}render(){return this.props.children}}function $f({children:t,isPresent:e,anchorX:n,root:i}){const s=es(),o=De(null),r=De({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=we(In);return Ao(()=>{const{width:c,height:l,top:d,left:u,right:m}=r.current;if(e||!o.current||!c||!l)return;const g=n==="left"?`left: ${u}`:`right: ${m}`;o.current.dataset.motionPopId=s;const y=document.createElement("style");a&&(y.nonce=a);const w=i??document.head;return w.appendChild(y),y.sheet&&y.sheet.insertRule(`
|
|
2
2
|
[data-motion-pop-id="${s}"] {
|
|
3
3
|
position: absolute !important;
|
|
4
|
-
width: ${
|
|
5
|
-
height: ${
|
|
4
|
+
width: ${c}px !important;
|
|
5
|
+
height: ${l}px !important;
|
|
6
6
|
${g}px !important;
|
|
7
7
|
top: ${d}px !important;
|
|
8
8
|
}
|
|
9
|
-
`),()=>{b.removeChild(_),b.contains(_)&&b.removeChild(_)}},[t]),E(Bf,{isPresent:t,childRef:o,sizeRef:r,children:Ud(e,{ref:o})})}const $f=({children:e,initial:t,isPresent:n,onExitComplete:i,custom:s,presenceAffectsLayout:o,mode:r,anchorX:a,root:l})=>{const c=oi(Uf),d=ns();let u=!0,p=ne(()=>(u=!1,{id:d,initial:t,isPresent:n,custom:s,onExitComplete:g=>{c.set(g,!0);for(const _ of c.values())if(!_)return;i&&i()},register:g=>(c.set(g,!1),()=>c.delete(g))}),[n,c,i]);return o&&u&&(p={...p}),ne(()=>{c.forEach((g,_)=>c.set(_,!1))},[n]),$t(()=>{!n&&!c.size&&i&&i()},[n]),r==="popLayout"&&(e=E(jf,{isPresent:n,anchorX:a,root:l,children:e})),E(ai.Provider,{value:p,children:e})};function Uf(){return new Map}function el(e=!0){const t=wt(ai);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:i,register:s}=t,o=ns();$t(()=>{if(e)return s(o)},[e]);const r=ii(()=>e&&i&&i(o),[o,i,e]);return!n&&i?[!1,r]:[!0]}const mi=e=>e.key||"";function nl(e){const t=[];return Pd.forEach(e,n=>{Ho(n)&&t.push(n)}),t}const Hf=({children:e,custom:t,initial:n=!0,onExitComplete:i,presenceAffectsLayout:s=!0,mode:o="sync",propagate:r=!1,anchorX:a="left",root:l})=>{const[c,d]=el(r),u=ne(()=>nl(e),[e]),p=r&&!c?[]:u.map(mi),g=Mt(!0),_=Mt(u),b=oi(()=>new Map),[w,y]=Xt(u),[S,C]=Xt(u);Wo(()=>{g.current=!1,_.current=u;for(let D=0;D<S.length;D++){const x=mi(S[D]);p.includes(x)?b.delete(x):b.get(x)!==!0&&b.set(x,!1)}},[S,p.length,p.join("-")]);const P=[];if(u!==w){let D=[...u];for(let x=0;x<S.length;x++){const k=S[x],f=mi(k);p.includes(f)||(D.splice(x,0,k),P.push(k))}return o==="wait"&&P.length&&(D=P),C(nl(D)),y(u),null}const{forceRender:L}=wt(os);return E(te,{children:S.map(D=>{const x=mi(D),k=r&&!c?!1:u===S||p.includes(x),f=()=>{if(b.has(x))b.set(x,!0);else return;let m=!0;b.forEach(h=>{h||(m=!1)}),m&&(L==null||L(),C(_.current),r&&(d==null||d()),i&&i())};return E($f,{isPresent:k,initial:!g.current||n?void 0:!1,custom:t,presenceAffectsLayout:s,mode:o,root:l,onExitComplete:k?void 0:f,anchorX:a,children:D},x)})})},il=Re({strict:!1}),sl={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Je={};for(const e in sl)Je[e]={isEnabled:t=>sl[e].some(n=>!!t[n])};function Gf(e){for(const t in e)Je[t]={...Je[t],...e[t]}}const Wf=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function gi(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Wf.has(e)}let rl=e=>!gi(e);function ol(e){typeof e=="function"&&(rl=t=>t.startsWith("on")?!gi(t):e(t))}try{ol(require("@emotion/is-prop-valid").default)}catch{}function zf(e,t,n){const i={};for(const s in e)s==="values"&&typeof e.values=="object"||(rl(s)||n===!0&&gi(s)||!t&&!gi(s)||e.draggable&&s.startsWith("onDrag"))&&(i[s]=e[s]);return i}function qf({children:e,isValidProp:t,...n}){t&&ol(t),n={...wt(Rn),...n},n.isStatic=oi(()=>n.isStatic);const i=ne(()=>n,[JSON.stringify(n.transition),n.transformPagePoint,n.reducedMotion]);return E(Rn.Provider,{value:i,children:e})}function Kf(e){if(typeof Proxy>"u")return e;const t=new Map,n=(...i)=>e(...i);return new Proxy(n,{get:(i,s)=>s==="create"?e:(t.has(s)||t.set(s,e(s)),t.get(s))})}const vi=Re({});function _i(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function In(e){return typeof e=="string"||Array.isArray(e)}const Ks=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Xs=["initial",...Ks];function yi(e){return _i(e.animate)||Xs.some(t=>In(e[t]))}function al(e){return!!(yi(e)||e.variants)}function Xf(e,t){if(yi(e)){const{initial:n,animate:i}=e;return{initial:n===!1||In(n)?n:void 0,animate:In(i)?i:void 0}}return e.inherit!==!1?t:{}}function Yf(e){const{initial:t,animate:n}=Xf(e,wt(vi));return ne(()=>({initial:t,animate:n}),[ll(t),ll(n)])}function ll(e){return Array.isArray(e)?e.join(" "):e}const Zf=Symbol.for("motionComponentSymbol");function Qe(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Jf(e,t,n){return ii(i=>{i&&e.onMount&&e.onMount(i),t&&(i?t.mount(i):t.unmount()),n&&(typeof n=="function"?n(i):Qe(n)&&(n.current=i))},[t])}const Ys=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),cl="data-"+Ys("framerAppearId"),ul=Re({});function Qf(e,t,n,i,s){var b,w;const{visualElement:o}=wt(vi),r=wt(il),a=wt(ai),l=wt(Rn).reducedMotion,c=Mt(null);i=i||r.renderer,!c.current&&i&&(c.current=i(e,{visualState:t,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const d=c.current,u=wt(ul);d&&!d.projection&&s&&(d.type==="html"||d.type==="svg")&&tp(c.current,n,s,u);const p=Mt(!1);Ro(()=>{d&&p.current&&d.update(n,a)});const g=n[cl],_=Mt(!!g&&!((b=window.MotionHandoffIsComplete)!=null&&b.call(window,g))&&((w=window.MotionHasOptimisedAnimation)==null?void 0:w.call(window,g)));return Wo(()=>{d&&(p.current=!0,window.MotionIsMounted=!0,d.updateFeatures(),Ws.render(d.render),_.current&&d.animationState&&d.animationState.animateChanges())}),$t(()=>{d&&(!_.current&&d.animationState&&d.animationState.animateChanges(),_.current&&(queueMicrotask(()=>{var y;(y=window.MotionHandoffMarkAsComplete)==null||y.call(window,g)}),_.current=!1))}),d}function tp(e,t,n,i){const{layoutId:s,layout:o,drag:r,dragConstraints:a,layoutScroll:l,layoutRoot:c,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:dl(e.parent)),e.projection.setOptions({layoutId:s,layout:o,alwaysMeasureLayout:!!r||a&&Qe(a),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:i,crossfade:d,layoutScroll:l,layoutRoot:c})}function dl(e){if(e)return e.options.allowProjection!==!1?e.projection:dl(e.parent)}function ep({preloadedFeatures:e,createVisualElement:t,useRender:n,useVisualState:i,Component:s}){e&&Gf(e);function o(a,l){let c;const d={...wt(Rn),...a,layoutId:np(a)},{isStatic:u}=d,p=Yf(a),g=i(a,u);if(!u&&as){ip();const _=sp(d);c=_.MeasureLayout,p.visualElement=Qf(s,g,d,t,_.ProjectionNode)}return E(vi.Provider,{value:p,children:[c&&p.visualElement?E(c,{visualElement:p.visualElement,...d}):null,n(s,a,Jf(g,p.visualElement,l),g,u,p.visualElement)]})}o.displayName=`motion.${typeof s=="string"?s:`create(${s.displayName??s.name??""})`}`;const r=Id(o);return r[Zf]=s,r}function np({layoutId:e}){const t=wt(os).id;return t&&e!==void 0?t+"-"+e:e}function ip(e,t){wt(il).strict}function sp(e){const{drag:t,layout:n}=Je;if(!t&&!n)return{};const i={...t,...n};return{MeasureLayout:t!=null&&t.isEnabled(e)||n!=null&&n.isEnabled(e)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}const Pn={};function rp(e){for(const t in e)Pn[t]=e[t],gs(t)&&(Pn[t].isCSSVariable=!0)}function hl(e,{layout:t,layoutId:n}){return Ye.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Pn[e]||e==="opacity")}const op={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},ap=Xe.length;function lp(e,t,n){let i="",s=!0;for(let o=0;o<ap;o++){const r=Xe[o],a=e[r];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(r.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const c=za(a,Gs[r]);if(!l){s=!1;const d=op[r]||r;i+=`${d}(${c}) `}n&&(t[r]=c)}}return i=i.trim(),n?i=n(t,s?"":i):s&&(i="none"),i}function Zs(e,t,n){const{style:i,vars:s,transformOrigin:o}=e;let r=!1,a=!1;for(const l in t){const c=t[l];if(Ye.has(l)){r=!0;continue}else if(gs(l)){s[l]=c;continue}else{const d=za(c,Gs[l]);l.startsWith("origin")?(a=!0,o[l]=d):i[l]=d}}if(t.transform||(r||n?i.transform=lp(t,e.transform,n):i.transform&&(i.transform="none")),a){const{originX:l="50%",originY:c="50%",originZ:d=0}=o;i.transformOrigin=`${l} ${c} ${d}`}}const Js=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function fl(e,t,n){for(const i in t)!kt(t[i])&&!hl(i,n)&&(e[i]=t[i])}function cp({transformTemplate:e},t){return ne(()=>{const n=Js();return Zs(n,t,e),Object.assign({},n.vars,n.style)},[t])}function up(e,t){const n=e.style||{},i={};return fl(i,n,e),Object.assign(i,cp(e,t)),i}function dp(e,t){const n={},i=up(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=i,n}const hp={offset:"stroke-dashoffset",array:"stroke-dasharray"},fp={offset:"strokeDashoffset",array:"strokeDasharray"};function pp(e,t,n=1,i=0,s=!0){e.pathLength=1;const o=s?hp:fp;e[o.offset]=U.transform(-i);const r=U.transform(t),a=U.transform(n);e[o.array]=`${r} ${a}`}function pl(e,{attrX:t,attrY:n,attrScale:i,pathLength:s,pathSpacing:o=1,pathOffset:r=0,...a},l,c,d){if(Zs(e,a,c),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:u,style:p}=e;u.transform&&(p.transform=u.transform,delete u.transform),(p.transform||u.transformOrigin)&&(p.transformOrigin=u.transformOrigin??"50% 50%",delete u.transformOrigin),p.transform&&(p.transformBox=(d==null?void 0:d.transformBox)??"fill-box",delete u.transformBox),t!==void 0&&(u.x=t),n!==void 0&&(u.y=n),i!==void 0&&(u.scale=i),s!==void 0&&pp(u,s,o,r,!1)}const ml=()=>({...Js(),attrs:{}}),gl=e=>typeof e=="string"&&e.toLowerCase()==="svg";function mp(e,t,n,i){const s=ne(()=>{const o=ml();return pl(o,t,gl(i),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};fl(o,e.style,e),s.style={...o,...s.style}}return s}const gp=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Qs(e){return typeof e!="string"||e.includes("-")?!1:!!(gp.indexOf(e)>-1||/[A-Z]/u.test(e))}function vp(e=!1){return(n,i,s,{latestValues:o},r)=>{const l=(Qs(n)?mp:dp)(i,o,r,n),c=zf(i,typeof n=="string",e),d=n!==te?{...c,...l,ref:s}:{},{children:u}=i,p=ne(()=>kt(u)?u.get():u,[u]);return jt(n,{...d,children:p})}}function vl(e){const t=[{},{}];return e==null||e.values.forEach((n,i)=>{t[0][i]=n.get(),t[1][i]=n.getVelocity()}),t}function tr(e,t,n,i){if(typeof t=="function"){const[s,o]=vl(i);t=t(n!==void 0?n:e.custom,s,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[s,o]=vl(i);t=t(n!==void 0?n:e.custom,s,o)}return t}function bi(e){return kt(e)?e.get():e}function _p({scrapeMotionValuesFromProps:e,createRenderState:t},n,i,s){return{latestValues:yp(n,i,s,e),renderState:t()}}const _l=e=>(t,n)=>{const i=wt(vi),s=wt(ai),o=()=>_p(e,t,i,s);return n?o():oi(o)};function yp(e,t,n,i){const s={},o=i(e,{});for(const p in o)s[p]=bi(o[p]);let{initial:r,animate:a}=e;const l=yi(e),c=al(e);t&&c&&!l&&e.inherit!==!1&&(r===void 0&&(r=t.initial),a===void 0&&(a=t.animate));let d=n?n.initial===!1:!1;d=d||r===!1;const u=d?a:r;if(u&&typeof u!="boolean"&&!_i(u)){const p=Array.isArray(u)?u:[u];for(let g=0;g<p.length;g++){const _=tr(e,p[g]);if(_){const{transitionEnd:b,transition:w,...y}=_;for(const S in y){let C=y[S];if(Array.isArray(C)){const P=d?C.length-1:0;C=C[P]}C!==null&&(s[S]=C)}for(const S in b)s[S]=b[S]}}}return s}function er(e,t,n){var o;const{style:i}=e,s={};for(const r in i)(kt(i[r])||t.style&&kt(t.style[r])||hl(r,e)||((o=n==null?void 0:n.getValue(r))==null?void 0:o.liveStyle)!==void 0)&&(s[r]=i[r]);return s}const bp={useVisualState:_l({scrapeMotionValuesFromProps:er,createRenderState:Js})};function yl(e,t,n){const i=er(e,t,n);for(const s in e)if(kt(e[s])||kt(t[s])){const o=Xe.indexOf(s)!==-1?"attr"+s.charAt(0).toUpperCase()+s.substring(1):s;i[o]=e[s]}return i}const wp={useVisualState:_l({scrapeMotionValuesFromProps:yl,createRenderState:ml})};function xp(e,t){return function(i,{forwardMotionProps:s}={forwardMotionProps:!1}){const r={...Qs(i)?wp:bp,preloadedFeatures:e,useRender:vp(s),createVisualElement:t,Component:i};return ep(r)}}function Mn(e,t,n){const i=e.getProps();return tr(i,t,n!==void 0?n:i.custom,e)}const nr=e=>Array.isArray(e);function Sp(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Ze(n))}function Cp(e){return nr(e)?e[e.length-1]||0:e}function kp(e,t){const n=Mn(e,t);let{transitionEnd:i={},transition:s={},...o}=n||{};o={...o,...i};for(const r in o){const a=Cp(o[r]);Sp(e,r,a)}}function Tp(e){return!!(kt(e)&&e.add)}function ir(e,t){const n=e.getValue("willChange");if(Tp(n))return n.add(t);if(!n&&pe.WillChange){const i=new pe.WillChange("auto");e.addValue("willChange",i),i.add(t)}}function bl(e){return e.props[cl]}const Ep=e=>e!==null;function Ap(e,{repeat:t,repeatType:n="loop"},i){const s=e.filter(Ep),o=t&&n!=="loop"&&t%2===1?0:s.length-1;return s[o]}const Rp={type:"spring",stiffness:500,damping:25,restSpeed:10},Ip=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Pp={type:"keyframes",duration:.8},Mp={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Lp=(e,{keyframes:t})=>t.length>2?Pp:Ye.has(e)?e.startsWith("scale")?Ip(t[1]):Rp:Mp;function Dp({when:e,delay:t,delayChildren:n,staggerChildren:i,staggerDirection:s,repeat:o,repeatType:r,repeatDelay:a,from:l,elapsed:c,...d}){return!!Object.keys(d).length}const sr=(e,t,n,i={},s,o)=>r=>{const a=Us(i,e)||{},l=a.delay||i.delay||0;let{elapsed:c=0}=i;c=c-ie(l);const d={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...a,delay:-c,onUpdate:p=>{t.set(p),a.onUpdate&&a.onUpdate(p)},onComplete:()=>{r(),a.onComplete&&a.onComplete()},name:e,motionValue:t,element:o?void 0:s};Dp(a)||Object.assign(d,Lp(e,d)),d.duration&&(d.duration=ie(d.duration)),d.repeatDelay&&(d.repeatDelay=ie(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let u=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(d.duration=0,d.delay===0&&(u=!0)),(pe.instantAnimations||pe.skipAnimations)&&(u=!0,d.duration=0,d.delay=0),d.allowFlatten=!a.type&&!a.ease,u&&!o&&t.get()!==void 0){const p=Ap(d.keyframes,a);if(p!==void 0){ut.update(()=>{d.onUpdate(p),d.onComplete()});return}}return a.isSync?new Ms(d):new mf(d)};function Op({protectedKeys:e,needsAnimating:t},n){const i=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,i}function wl(e,t,{delay:n=0,transitionOverride:i,type:s}={}){let{transition:o=e.getDefaultTransition(),transitionEnd:r,...a}=t;i&&(o=i);const l=[],c=s&&e.animationState&&e.animationState.getState()[s];for(const d in a){const u=e.getValue(d,e.latestValues[d]??null),p=a[d];if(p===void 0||c&&Op(c,d))continue;const g={delay:n,...Us(o||{},d)},_=u.get();if(_!==void 0&&!u.isAnimating&&!Array.isArray(p)&&p===_&&!g.velocity)continue;let b=!1;if(window.MotionHandoffAnimation){const y=bl(e);if(y){const S=window.MotionHandoffAnimation(y,d,ut);S!==null&&(g.startTime=S,b=!0)}}ir(e,d),u.start(sr(d,u,p,e.shouldReduceMotion&&Ba.has(d)?{type:!1}:g,e,b));const w=u.animation;w&&l.push(w)}return r&&Promise.all(l).then(()=>{ut.update(()=>{r&&kp(e,r)})}),l}function rr(e,t,n={}){var l;const i=Mn(e,t,n.type==="exit"?(l=e.presenceContext)==null?void 0:l.custom:void 0);let{transition:s=e.getDefaultTransition()||{}}=i||{};n.transitionOverride&&(s=n.transitionOverride);const o=i?()=>Promise.all(wl(e,i,n)):()=>Promise.resolve(),r=e.variantChildren&&e.variantChildren.size?(c=0)=>{const{delayChildren:d=0,staggerChildren:u,staggerDirection:p}=s;return Np(e,t,c,d,u,p,n)}:()=>Promise.resolve(),{when:a}=s;if(a){const[c,d]=a==="beforeChildren"?[o,r]:[r,o];return c().then(()=>d())}else return Promise.all([o(),r(n.delay)])}function Np(e,t,n=0,i=0,s=0,o=1,r){const a=[],l=e.variantChildren.size,c=(l-1)*s,d=typeof i=="function",u=d?p=>i(p,l):o===1?(p=0)=>p*s:(p=0)=>c-p*s;return Array.from(e.variantChildren).sort(Vp).forEach((p,g)=>{p.notify("AnimationStart",t),a.push(rr(p,t,{...r,delay:n+(d?0:i)+u(g)}).then(()=>p.notify("AnimationComplete",t)))}),Promise.all(a)}function Vp(e,t){return e.sortNodePosition(t)}function Fp(e,t,n={}){e.notify("AnimationStart",t);let i;if(Array.isArray(t)){const s=t.map(o=>rr(e,o,n));i=Promise.all(s)}else if(typeof t=="string")i=rr(e,t,n);else{const s=typeof t=="function"?Mn(e,t,n.custom):t;i=Promise.all(wl(e,s,n))}return i.then(()=>{e.notify("AnimationComplete",t)})}function xl(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let i=0;i<n;i++)if(t[i]!==e[i])return!1;return!0}const Bp=Xs.length;function Sl(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?Sl(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<Bp;n++){const i=Xs[n],s=e.props[i];(In(s)||s===!1)&&(t[i]=s)}return t}const jp=[...Ks].reverse(),$p=Ks.length;function Up(e){return t=>Promise.all(t.map(({animation:n,options:i})=>Fp(e,n,i)))}function Hp(e){let t=Up(e),n=Cl(),i=!0;const s=l=>(c,d)=>{var p;const u=Mn(e,d,l==="exit"?(p=e.presenceContext)==null?void 0:p.custom:void 0);if(u){const{transition:g,transitionEnd:_,...b}=u;c={...c,...b,..._}}return c};function o(l){t=l(e)}function r(l){const{props:c}=e,d=Sl(e.parent)||{},u=[],p=new Set;let g={},_=1/0;for(let w=0;w<$p;w++){const y=jp[w],S=n[y],C=c[y]!==void 0?c[y]:d[y],P=In(C),L=y===l?S.isActive:null;L===!1&&(_=w);let D=C===d[y]&&C!==c[y]&&P;if(D&&i&&e.manuallyAnimateOnMount&&(D=!1),S.protectedKeys={...g},!S.isActive&&L===null||!C&&!S.prevProp||_i(C)||typeof C=="boolean")continue;const x=Gp(S.prevProp,C);let k=x||y===l&&S.isActive&&!D&&P||w>_&&P,f=!1;const m=Array.isArray(C)?C:[C];let h=m.reduce(s(y),{});L===!1&&(h={});const{prevResolvedValues:v={}}=S,T={...v,...h},R=I=>{k=!0,p.has(I)&&(f=!0,p.delete(I)),S.needsAnimating[I]=!0;const N=e.getValue(I);N&&(N.liveStyle=!1)};for(const I in T){const N=h[I],K=v[I];if(g.hasOwnProperty(I))continue;let F=!1;nr(N)&&nr(K)?F=!xl(N,K):F=N!==K,F?N!=null?R(I):p.add(I):N!==void 0&&p.has(I)?R(I):S.protectedKeys[I]=!0}S.prevProp=C,S.prevResolvedValues=h,S.isActive&&(g={...g,...h}),i&&e.blockInitialAnimation&&(k=!1),k&&(!(D&&x)||f)&&u.push(...m.map(I=>({animation:I,options:{type:y}})))}if(p.size){const w={};if(typeof c.initial!="boolean"){const y=Mn(e,Array.isArray(c.initial)?c.initial[0]:c.initial);y&&y.transition&&(w.transition=y.transition)}p.forEach(y=>{const S=e.getBaseTarget(y),C=e.getValue(y);C&&(C.liveStyle=!0),w[y]=S??null}),u.push({animation:w})}let b=!!u.length;return i&&(c.initial===!1||c.initial===c.animate)&&!e.manuallyAnimateOnMount&&(b=!1),i=!1,b?t(u):Promise.resolve()}function a(l,c){var u;if(n[l].isActive===c)return Promise.resolve();(u=e.variantChildren)==null||u.forEach(p=>{var g;return(g=p.animationState)==null?void 0:g.setActive(l,c)}),n[l].isActive=c;const d=r(l);for(const p in n)n[p].protectedKeys={};return d}return{animateChanges:r,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=Cl(),i=!0}}}function Gp(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!xl(t,e):!1}function De(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Cl(){return{animate:De(!0),whileInView:De(),whileHover:De(),whileTap:De(),whileDrag:De(),whileFocus:De(),exit:De()}}class we{constructor(t){this.isMounted=!1,this.node=t}update(){}}class Wp extends we{constructor(t){super(t),t.animationState||(t.animationState=Hp(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();_i(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let zp=0;class qp extends we{constructor(){super(...arguments),this.id=zp++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:i}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===i)return;const s=this.node.animationState.setActive("exit",!t);n&&!t&&s.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const Kp={animation:{Feature:Wp},exit:{Feature:qp}};function Ln(e,t,n,i={passive:!0}){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n)}function Dn(e){return{point:{x:e.pageX,y:e.pageY}}}const Xp=e=>t=>zs(t)&&e(t,Dn(t));function On(e,t,n,i){return Ln(e,t,Xp(n),i)}function kl({top:e,left:t,right:n,bottom:i}){return{x:{min:t,max:n},y:{min:e,max:i}}}function Yp({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Zp(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),i=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:i.y,right:i.x}}const Tl=1e-4,Jp=1-Tl,Qp=1+Tl,El=.01,tm=0-El,em=0+El;function Et(e){return e.max-e.min}function nm(e,t,n){return Math.abs(e-t)<=n}function Al(e,t,n,i=.5){e.origin=i,e.originPoint=mt(t.min,t.max,e.origin),e.scale=Et(n)/Et(t),e.translate=mt(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Jp&&e.scale<=Qp||isNaN(e.scale))&&(e.scale=1),(e.translate>=tm&&e.translate<=em||isNaN(e.translate))&&(e.translate=0)}function Nn(e,t,n,i){Al(e.x,t.x,n.x,i?i.originX:void 0),Al(e.y,t.y,n.y,i?i.originY:void 0)}function Rl(e,t,n){e.min=n.min+t.min,e.max=e.min+Et(t)}function im(e,t,n){Rl(e.x,t.x,n.x),Rl(e.y,t.y,n.y)}function Il(e,t,n){e.min=t.min-n.min,e.max=e.min+Et(t)}function Vn(e,t,n){Il(e.x,t.x,n.x),Il(e.y,t.y,n.y)}const Pl=()=>({translate:0,scale:1,origin:0,originPoint:0}),tn=()=>({x:Pl(),y:Pl()}),Ml=()=>({min:0,max:0}),_t=()=>({x:Ml(),y:Ml()});function Ht(e){return[e("x"),e("y")]}function or(e){return e===void 0||e===1}function ar({scale:e,scaleX:t,scaleY:n}){return!or(e)||!or(t)||!or(n)}function Oe(e){return ar(e)||Ll(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Ll(e){return Dl(e.x)||Dl(e.y)}function Dl(e){return e&&e!=="0%"}function wi(e,t,n){const i=e-n,s=t*i;return n+s}function Ol(e,t,n,i,s){return s!==void 0&&(e=wi(e,s,i)),wi(e,n,i)+t}function lr(e,t=0,n=1,i,s){e.min=Ol(e.min,t,n,i,s),e.max=Ol(e.max,t,n,i,s)}function Nl(e,{x:t,y:n}){lr(e.x,t.translate,t.scale,t.originPoint),lr(e.y,n.translate,n.scale,n.originPoint)}const Vl=.999999999999,Fl=1.0000000000001;function sm(e,t,n,i=!1){const s=n.length;if(!s)return;t.x=t.y=1;let o,r;for(let a=0;a<s;a++){o=n[a],r=o.projectionDelta;const{visualElement:l}=o.options;l&&l.props.style&&l.props.style.display==="contents"||(i&&o.options.layoutScroll&&o.scroll&&o!==o.root&&nn(e,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),r&&(t.x*=r.x.scale,t.y*=r.y.scale,Nl(e,r)),i&&Oe(o.latestValues)&&nn(e,o.latestValues))}t.x<Fl&&t.x>Vl&&(t.x=1),t.y<Fl&&t.y>Vl&&(t.y=1)}function en(e,t){e.min=e.min+t,e.max=e.max+t}function Bl(e,t,n,i,s=.5){const o=mt(e.min,e.max,s);lr(e,t,n,o,i)}function nn(e,t){Bl(e.x,t.x,t.scaleX,t.scale,t.originX),Bl(e.y,t.y,t.scaleY,t.scale,t.originY)}function jl(e,t){return kl(Zp(e.getBoundingClientRect(),t))}function rm(e,t,n){const i=jl(e,n),{scroll:s}=t;return s&&(en(i.x,s.offset.x),en(i.y,s.offset.y)),i}const $l=({current:e})=>e?e.ownerDocument.defaultView:null,Ul=(e,t)=>Math.abs(e-t);function om(e,t){const n=Ul(e.x,t.x),i=Ul(e.y,t.y);return Math.sqrt(n**2+i**2)}class Hl{constructor(t,n,{transformPagePoint:i,contextWindow:s=window,dragSnapToOrigin:o=!1,distanceThreshold:r=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const p=ur(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,_=om(p.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!_)return;const{point:b}=p,{timestamp:w}=St;this.history.push({...b,timestamp:w});const{onStart:y,onMove:S}=this.handlers;g||(y&&y(this.lastMoveEvent,p),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,p)},this.handlePointerMove=(p,g)=>{this.lastMoveEvent=p,this.lastMoveEventInfo=cr(g,this.transformPagePoint),ut.update(this.updatePoint,!0)},this.handlePointerUp=(p,g)=>{this.end();const{onEnd:_,onSessionEnd:b,resumeAnimation:w}=this.handlers;if(this.dragSnapToOrigin&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=ur(p.type==="pointercancel"?this.lastMoveEventInfo:cr(g,this.transformPagePoint),this.history);this.startEvent&&_&&_(p,y),b&&b(p,y)},!zs(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=i,this.distanceThreshold=r,this.contextWindow=s||window;const a=Dn(t),l=cr(a,this.transformPagePoint),{point:c}=l,{timestamp:d}=St;this.history=[{...c,timestamp:d}];const{onSessionStart:u}=n;u&&u(t,ur(l,this.history)),this.removeListeners=bn(On(this.contextWindow,"pointermove",this.handlePointerMove),On(this.contextWindow,"pointerup",this.handlePointerUp),On(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),_e(this.updatePoint)}}function cr(e,t){return t?{point:t(e.point)}:e}function Gl(e,t){return{x:e.x-t.x,y:e.y-t.y}}function ur({point:e},t){return{point:e,delta:Gl(e,Wl(t)),offset:Gl(e,am(t)),velocity:lm(t,.1)}}function am(e){return e[0]}function Wl(e){return e[e.length-1]}function lm(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,i=null;const s=Wl(e);for(;n>=0&&(i=e[n],!(s.timestamp-i.timestamp>ie(t)));)n--;if(!i)return{x:0,y:0};const o=se(s.timestamp-i.timestamp);if(o===0)return{x:0,y:0};const r={x:(s.x-i.x)/o,y:(s.y-i.y)/o};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function cm(e,{min:t,max:n},i){return t!==void 0&&e<t?e=i?mt(t,e,i.min):Math.max(e,t):n!==void 0&&e>n&&(e=i?mt(n,e,i.max):Math.min(e,n)),e}function zl(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function um(e,{top:t,left:n,bottom:i,right:s}){return{x:zl(e.x,n,s),y:zl(e.y,t,i)}}function ql(e,t){let n=t.min-e.min,i=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,i]=[i,n]),{min:n,max:i}}function dm(e,t){return{x:ql(e.x,t.x),y:ql(e.y,t.y)}}function hm(e,t){let n=.5;const i=Et(e),s=Et(t);return s>i?n=wn(t.min,t.max-i,e.min):i>s&&(n=wn(e.min,e.max-s,t.min)),fe(0,1,n)}function fm(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const dr=.35;function pm(e=dr){return e===!1?e=0:e===!0&&(e=dr),{x:Kl(e,"left","right"),y:Kl(e,"top","bottom")}}function Kl(e,t,n){return{min:Xl(e,t),max:Xl(e,n)}}function Xl(e,t){return typeof e=="number"?e:e[t]||0}const mm=new WeakMap;class gm{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=_t(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:i}={}){const{presenceContext:s}=this.visualElement;if(s&&s.isPresent===!1)return;const o=u=>{const{dragSnapToOrigin:p}=this.getProps();p?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Dn(u).point)},r=(u,p)=>{const{drag:g,dragPropagation:_,onDragStart:b}=this.getProps();if(g&&!_&&(this.openDragLock&&this.openDragLock(),this.openDragLock=If(g),!this.openDragLock))return;this.latestPointerEvent=u,this.latestPanInfo=p,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Ht(y=>{let S=this.getAxisMotionValue(y).get()||0;if(re.test(S)){const{projection:C}=this.visualElement;if(C&&C.layout){const P=C.layout.layoutBox[y];P&&(S=Et(P)*(parseFloat(S)/100))}}this.originPoint[y]=S}),b&&ut.postRender(()=>b(u,p)),ir(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},a=(u,p)=>{this.latestPointerEvent=u,this.latestPanInfo=p;const{dragPropagation:g,dragDirectionLock:_,onDirectionLock:b,onDrag:w}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:y}=p;if(_&&this.currentDirection===null){this.currentDirection=vm(y),this.currentDirection!==null&&b&&b(this.currentDirection);return}this.updateAxis("x",p.point,y),this.updateAxis("y",p.point,y),this.visualElement.render(),w&&w(u,p)},l=(u,p)=>{this.latestPointerEvent=u,this.latestPanInfo=p,this.stop(u,p),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>Ht(u=>{var p;return this.getAnimationState(u)==="paused"&&((p=this.getAxisMotionValue(u).animation)==null?void 0:p.play())}),{dragSnapToOrigin:d}=this.getProps();this.panSession=new Hl(t,{onSessionStart:o,onStart:r,onMove:a,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:i,contextWindow:$l(this.visualElement)})}stop(t,n){const i=t||this.latestPointerEvent,s=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!s||!i)return;const{velocity:r}=s;this.startAnimation(r);const{onDragEnd:a}=this.getProps();a&&ut.postRender(()=>a(i,s))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,i){const{drag:s}=this.getProps();if(!i||!xi(t,s,this.currentDirection))return;const o=this.getAxisMotionValue(t);let r=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(r=cm(r,this.constraints[t],this.elastic[t])),o.set(r)}resolveConstraints(){var o;const{dragConstraints:t,dragElastic:n}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(o=this.visualElement.projection)==null?void 0:o.layout,s=this.constraints;t&&Qe(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&i?this.constraints=um(i.layoutBox,t):this.constraints=!1,this.elastic=pm(n),s!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&Ht(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=fm(i.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Qe(t))return!1;const i=t.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;const o=rm(i,s.root,this.visualElement.getTransformPagePoint());let r=dm(s.layout.layoutBox,o);if(n){const a=n(Yp(r));this.hasMutatedConstraints=!!a,a&&(r=kl(a))}return r}startAnimation(t){const{drag:n,dragMomentum:i,dragElastic:s,dragTransition:o,dragSnapToOrigin:r,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},c=Ht(d=>{if(!xi(d,n,this.currentDirection))return;let u=l&&l[d]||{};r&&(u={min:0,max:0});const p=s?200:1e6,g=s?40:1e7,_={type:"inertia",velocity:i?t[d]:0,bounceStiffness:p,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...o,...u};return this.startAxisValueAnimation(d,_)});return Promise.all(c).then(a)}startAxisValueAnimation(t,n){const i=this.getAxisMotionValue(t);return ir(this.visualElement,t),i.start(sr(t,i,0,n,this.visualElement,!1))}stopAnimation(){Ht(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){Ht(t=>{var n;return(n=this.getAxisMotionValue(t).animation)==null?void 0:n.pause()})}getAnimationState(t){var n;return(n=this.getAxisMotionValue(t).animation)==null?void 0:n.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,i=this.visualElement.getProps(),s=i[n];return s||this.visualElement.getValue(t,(i.initial?i.initial[t]:void 0)||0)}snapToCursor(t){Ht(n=>{const{drag:i}=this.getProps();if(!xi(n,i,this.currentDirection))return;const{projection:s}=this.visualElement,o=this.getAxisMotionValue(n);if(s&&s.layout){const{min:r,max:a}=s.layout.layoutBox[n];o.set(t[n]-mt(r,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:i}=this.visualElement;if(!Qe(n)||!i||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};Ht(r=>{const a=this.getAxisMotionValue(r);if(a&&this.constraints!==!1){const l=a.get();s[r]=hm({min:l,max:l},this.constraints[r])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.resolveConstraints(),Ht(r=>{if(!xi(r,t,null))return;const a=this.getAxisMotionValue(r),{min:l,max:c}=this.constraints[r];a.set(mt(l,c,s[r]))})}addListeners(){if(!this.visualElement.current)return;mm.set(this.visualElement,this);const t=this.visualElement.current,n=On(t,"pointerdown",l=>{const{drag:c,dragListener:d=!0}=this.getProps();c&&d&&this.start(l)}),i=()=>{const{dragConstraints:l}=this.getProps();Qe(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:s}=this.visualElement,o=s.addEventListener("measure",i);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),ut.read(i);const r=Ln(window,"resize",()=>this.scalePositionWithinConstraints()),a=s.addEventListener("didUpdate",({delta:l,hasLayoutChanged:c})=>{this.isDragging&&c&&(Ht(d=>{const u=this.getAxisMotionValue(d);u&&(this.originPoint[d]+=l[d].translate,u.set(u.get()+l[d].translate))}),this.visualElement.render())});return()=>{r(),n(),o(),a&&a()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:i=!1,dragPropagation:s=!1,dragConstraints:o=!1,dragElastic:r=dr,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:i,dragPropagation:s,dragConstraints:o,dragElastic:r,dragMomentum:a}}}function xi(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function vm(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class _m extends we{constructor(t){super(t),this.removeGroupControls=Ut,this.removeListeners=Ut,this.controls=new gm(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ut}unmount(){this.removeGroupControls(),this.removeListeners()}}const Yl=e=>(t,n)=>{e&&ut.postRender(()=>e(t,n))};class ym extends we{constructor(){super(...arguments),this.removePointerDownListener=Ut}onPointerDown(t){this.session=new Hl(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:$l(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:i,onPanEnd:s}=this.node.getProps();return{onSessionStart:Yl(t),onStart:Yl(n),onMove:i,onEnd:(o,r)=>{delete this.session,s&&ut.postRender(()=>s(o,r))}}}mount(){this.removePointerDownListener=On(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const Si={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Zl(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Fn={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(U.test(e))e=parseFloat(e);else return e;const n=Zl(e,t.target.x),i=Zl(e,t.target.y);return`${n}% ${i}%`}},bm={correct:(e,{treeScale:t,projectionDelta:n})=>{const i=e,s=be.parse(e);if(s.length>5)return i;const o=be.createTransformer(e),r=typeof s[0]!="number"?1:0,a=n.x.scale*t.x,l=n.y.scale*t.y;s[0+r]/=a,s[1+r]/=l;const c=mt(a,l,.5);return typeof s[2+r]=="number"&&(s[2+r]/=c),typeof s[3+r]=="number"&&(s[3+r]/=c),o(s)}};let Jl=!1;class wm extends Kt{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i,layoutId:s}=this.props,{projection:o}=t;rp(xm),o&&(n.group&&n.group.add(o),i&&i.register&&s&&i.register(o),Jl&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),Si.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:i,drag:s,isPresent:o}=this.props,{projection:r}=i;return r&&(r.isPresent=o,Jl=!0,s||t.layoutDependency!==n||n===void 0||t.isPresent!==o?r.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?r.promote():r.relegate()||ut.postRender(()=>{const a=r.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Ws.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i}=this.props,{projection:s}=t;s&&(s.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(s),i&&i.deregister&&i.deregister(s))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function Ql(e){const[t,n]=el(),i=wt(os);return E(wm,{...e,layoutGroup:i,switchLayoutGroup:wt(ul),isPresent:t,safeToRemove:n})}const xm={borderRadius:{...Fn,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Fn,borderTopRightRadius:Fn,borderBottomLeftRadius:Fn,borderBottomRightRadius:Fn,boxShadow:bm};function Sm(e,t,n){const i=kt(e)?e:Ze(e);return i.start(sr("",i,t,n)),i.animation}const Cm=(e,t)=>e.depth-t.depth;class km{constructor(){this.children=[],this.isDirty=!1}add(t){ls(this.children,t),this.isDirty=!0}remove(t){cs(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(Cm),this.isDirty=!1,this.children.forEach(t)}}function Tm(e,t){const n=Lt.now(),i=({timestamp:s})=>{const o=s-n;o>=t&&(_e(i),e(o-t))};return ut.setup(i,!0),()=>_e(i)}const tc=["TopLeft","TopRight","BottomLeft","BottomRight"],Em=tc.length,ec=e=>typeof e=="string"?parseFloat(e):e,nc=e=>typeof e=="number"||U.test(e);function Am(e,t,n,i,s,o){s?(e.opacity=mt(0,n.opacity??1,Rm(i)),e.opacityExit=mt(t.opacity??1,0,Im(i))):o&&(e.opacity=mt(t.opacity??1,n.opacity??1,i));for(let r=0;r<Em;r++){const a=`border${tc[r]}Radius`;let l=ic(t,a),c=ic(n,a);if(l===void 0&&c===void 0)continue;l||(l=0),c||(c=0),l===0||c===0||nc(l)===nc(c)?(e[a]=Math.max(mt(ec(l),ec(c),i),0),(re.test(c)||re.test(l))&&(e[a]+="%")):e[a]=c}(t.rotate||n.rotate)&&(e.rotate=mt(t.rotate||0,n.rotate||0,i))}function ic(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const Rm=sc(0,.5,na),Im=sc(.5,.95,Ut);function sc(e,t,n){return i=>i<e?0:i>t?1:n(wn(e,t,i))}function rc(e,t){e.min=t.min,e.max=t.max}function Gt(e,t){rc(e.x,t.x),rc(e.y,t.y)}function oc(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function ac(e,t,n,i,s){return e-=t,e=wi(e,1/n,i),s!==void 0&&(e=wi(e,1/s,i)),e}function Pm(e,t=0,n=1,i=.5,s,o=e,r=e){if(re.test(t)&&(t=parseFloat(t),t=mt(r.min,r.max,t/100)-r.min),typeof t!="number")return;let a=mt(o.min,o.max,i);e===o&&(a-=t),e.min=ac(e.min,t,n,a,s),e.max=ac(e.max,t,n,a,s)}function lc(e,t,[n,i,s],o,r){Pm(e,t[n],t[i],t[s],t.scale,o,r)}const Mm=["x","scaleX","originX"],Lm=["y","scaleY","originY"];function cc(e,t,n,i){lc(e.x,t,Mm,n?n.x:void 0,i?i.x:void 0),lc(e.y,t,Lm,n?n.y:void 0,i?i.y:void 0)}function uc(e){return e.translate===0&&e.scale===1}function dc(e){return uc(e.x)&&uc(e.y)}function hc(e,t){return e.min===t.min&&e.max===t.max}function Dm(e,t){return hc(e.x,t.x)&&hc(e.y,t.y)}function fc(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function pc(e,t){return fc(e.x,t.x)&&fc(e.y,t.y)}function mc(e){return Et(e.x)/Et(e.y)}function gc(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class Om{constructor(){this.members=[]}add(t){ls(this.members,t),t.scheduleRender()}remove(t){if(cs(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(s=>t===s);if(n===0)return!1;let i;for(let s=n;s>=0;s--){const o=this.members[s];if(o.isPresent!==!1){i=o;break}}return i?(this.promote(i),!0):!1}promote(t,n){const i=this.lead;if(t!==i&&(this.prevLead=i,this.lead=t,t.show(),i)){i.instance&&i.scheduleRender(),t.scheduleRender(),t.resumeFrom=i,n&&(t.resumeFrom.preserveOpacity=!0),i.snapshot&&(t.snapshot=i.snapshot,t.snapshot.latestValues=i.animationValues||i.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:s}=t.options;s===!1&&i.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:i}=t;n.onExitComplete&&n.onExitComplete(),i&&i.options.onExitComplete&&i.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function Nm(e,t,n){let i="";const s=e.x.translate/t.x,o=e.y.translate/t.y,r=(n==null?void 0:n.z)||0;if((s||o||r)&&(i=`translate3d(${s}px, ${o}px, ${r}px) `),(t.x!==1||t.y!==1)&&(i+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:c,rotate:d,rotateX:u,rotateY:p,skewX:g,skewY:_}=n;c&&(i=`perspective(${c}px) ${i}`),d&&(i+=`rotate(${d}deg) `),u&&(i+=`rotateX(${u}deg) `),p&&(i+=`rotateY(${p}deg) `),g&&(i+=`skewX(${g}deg) `),_&&(i+=`skewY(${_}deg) `)}const a=e.x.scale*t.x,l=e.y.scale*t.y;return(a!==1||l!==1)&&(i+=`scale(${a}, ${l})`),i||"none"}const hr=["","X","Y","Z"],Vm=1e3;let Fm=0;function fr(e,t,n,i){const{latestValues:s}=t;s[e]&&(n[e]=s[e],t.setStaticValue(e,0),i&&(i[e]=0))}function vc(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=bl(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:s,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",ut,!(s||o))}const{parent:i}=e;i&&!i.hasCheckedOptimisedAppear&&vc(i)}function _c({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:i,resetTransform:s}){return class{constructor(r={},a=t==null?void 0:t()){this.id=Fm++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach($m),this.nodes.forEach(Wm),this.nodes.forEach(zm),this.nodes.forEach(Um)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=r,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new km)}addEventListener(r,a){return this.eventHandlers.has(r)||this.eventHandlers.set(r,new hs),this.eventHandlers.get(r).add(a)}notifyListeners(r,...a){const l=this.eventHandlers.get(r);l&&l.notify(...a)}hasListeners(r){return this.eventHandlers.has(r)}mount(r){if(this.instance)return;this.isSVG=tl(r)&&!Nf(r),this.instance=r;const{layoutId:a,layout:l,visualElement:c}=this.options;if(c&&!c.current&&c.mount(r),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),e){let d,u=0;const p=()=>this.root.updateBlockedByResize=!1;ut.read(()=>{u=window.innerWidth}),e(r,()=>{const g=window.innerWidth;g!==u&&(u=g,this.root.updateBlockedByResize=!0,d&&d(),d=Tm(p,250),Si.hasAnimatedSinceResize&&(Si.hasAnimatedSinceResize=!1,this.nodes.forEach(wc)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&c&&(a||l)&&this.addEventListener("didUpdate",({delta:d,hasLayoutChanged:u,hasRelativeLayoutChanged:p,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const _=this.options.transition||c.getDefaultTransition()||Zm,{onLayoutAnimationStart:b,onLayoutAnimationComplete:w}=c.getProps(),y=!this.targetLayout||!pc(this.targetLayout,g),S=!u&&p;if(this.options.layoutRoot||this.resumeFrom||S||u&&(y||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const C={...Us(_,"layout"),onPlay:b,onComplete:w};(c.shouldReduceMotion||this.options.layoutRoot)&&(C.delay=0,C.type=!1),this.startAnimation(C),this.setAnimationOrigin(d,S)}else u||wc(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const r=this.getStack();r&&r.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),_e(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(qm),this.animationId++)}getTransformTemplate(){const{visualElement:r}=this.options;return r&&r.getProps().transformTemplate}willUpdate(r=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&vc(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let d=0;d<this.path.length;d++){const u=this.path[d];u.shouldResetTransform=!0,u.updateScroll("snapshot"),u.options.layoutRoot&&u.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const c=this.getTransformTemplate();this.prevTransformTemplateValue=c?c(this.latestValues,""):void 0,this.updateSnapshot(),r&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(yc);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(bc);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Gm),this.nodes.forEach(Bm),this.nodes.forEach(jm)):this.nodes.forEach(bc),this.clearAllSnapshots();const a=Lt.now();St.delta=fe(0,1e3/60,a-St.timestamp),St.timestamp=a,St.isProcessing=!0,ms.update.process(St),ms.preRender.process(St),ms.render.process(St),St.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Ws.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Hm),this.sharedNodes.forEach(Km)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ut.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ut.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Et(this.snapshot.measuredBox.x)&&!Et(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const r=this.layout;this.layout=this.measure(!1),this.layoutCorrected=_t(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,r?r.layoutBox:void 0)}updateScroll(r="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===r&&(a=!1),a&&this.instance){const l=i(this.instance);this.scroll={animationId:this.root.animationId,phase:r,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!s)return;const r=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!dc(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,d=c!==this.prevTransformTemplateValue;r&&this.instance&&(a||Oe(this.latestValues)||d)&&(s(this.instance,c),this.shouldResetTransform=!1,this.scheduleRender())}measure(r=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return r&&(l=this.removeTransform(l)),Jm(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){var c;const{visualElement:r}=this.options;if(!r)return _t();const a=r.measureViewportBox();if(!(((c=this.scroll)==null?void 0:c.wasRoot)||this.path.some(Qm))){const{scroll:d}=this.root;d&&(en(a.x,d.offset.x),en(a.y,d.offset.y))}return a}removeElementScroll(r){var l;const a=_t();if(Gt(a,r),(l=this.scroll)!=null&&l.wasRoot)return a;for(let c=0;c<this.path.length;c++){const d=this.path[c],{scroll:u,options:p}=d;d!==this.root&&u&&p.layoutScroll&&(u.wasRoot&&Gt(a,r),en(a.x,u.offset.x),en(a.y,u.offset.y))}return a}applyTransform(r,a=!1){const l=_t();Gt(l,r);for(let c=0;c<this.path.length;c++){const d=this.path[c];!a&&d.options.layoutScroll&&d.scroll&&d!==d.root&&nn(l,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),Oe(d.latestValues)&&nn(l,d.latestValues)}return Oe(this.latestValues)&&nn(l,this.latestValues),l}removeTransform(r){const a=_t();Gt(a,r);for(let l=0;l<this.path.length;l++){const c=this.path[l];if(!c.instance||!Oe(c.latestValues))continue;ar(c.latestValues)&&c.updateSnapshot();const d=_t(),u=c.measurePageBox();Gt(d,u),cc(a,c.latestValues,c.snapshot?c.snapshot.layoutBox:void 0,d)}return Oe(this.latestValues)&&cc(a,this.latestValues),a}setTargetDelta(r){this.targetDelta=r,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(r){this.options={...this.options,...r,crossfade:r.crossfade!==void 0?r.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==St.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(r=!1){var p;const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(r||l&&this.isSharedProjectionDirty||this.isProjectionDirty||(p=this.parent)!=null&&p.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:d,layoutId:u}=this.options;if(!(!this.layout||!(d||u))){if(this.resolvedRelativeTargetAt=St.timestamp,!this.targetDelta&&!this.relativeTarget){const g=this.getClosestProjectingParent();g&&g.layout&&this.animationProgress!==1?(this.relativeParent=g,this.forceRelativeParentToResolveTarget(),this.relativeTarget=_t(),this.relativeTargetOrigin=_t(),Vn(this.relativeTargetOrigin,this.layout.layoutBox,g.layout.layoutBox),Gt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=_t(),this.targetWithTransforms=_t()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),im(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Gt(this.target,this.layout.layoutBox),Nl(this.target,this.targetDelta)):Gt(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const g=this.getClosestProjectingParent();g&&!!g.resumingFrom==!!this.resumingFrom&&!g.options.layoutScroll&&g.target&&this.animationProgress!==1?(this.relativeParent=g,this.forceRelativeParentToResolveTarget(),this.relativeTarget=_t(),this.relativeTargetOrigin=_t(),Vn(this.relativeTargetOrigin,this.target,g.target),Gt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||ar(this.parent.latestValues)||Ll(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var _;const r=this.getLead(),a=!!this.resumingFrom||this!==r;let l=!0;if((this.isProjectionDirty||(_=this.parent)!=null&&_.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===St.timestamp&&(l=!1),l)return;const{layout:c,layoutId:d}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(c||d))return;Gt(this.layoutCorrected,this.layout.layoutBox);const u=this.treeScale.x,p=this.treeScale.y;sm(this.layoutCorrected,this.treeScale,this.path,a),r.layout&&!r.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(r.target=r.layout.layoutBox,r.targetWithTransforms=_t());const{target:g}=r;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(oc(this.prevProjectionDelta.x,this.projectionDelta.x),oc(this.prevProjectionDelta.y,this.projectionDelta.y)),Nn(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==u||this.treeScale.y!==p||!gc(this.projectionDelta.x,this.prevProjectionDelta.x)||!gc(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(r=!0){var a;if((a=this.options.visualElement)==null||a.scheduleRender(),r){const l=this.getStack();l&&l.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=tn(),this.projectionDelta=tn(),this.projectionDeltaWithTransform=tn()}setAnimationOrigin(r,a=!1){const l=this.snapshot,c=l?l.latestValues:{},d={...this.latestValues},u=tn();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const p=_t(),g=l?l.source:void 0,_=this.layout?this.layout.source:void 0,b=g!==_,w=this.getStack(),y=!w||w.members.length<=1,S=!!(b&&!y&&this.options.crossfade===!0&&!this.path.some(Ym));this.animationProgress=0;let C;this.mixTargetDelta=P=>{const L=P/1e3;xc(u.x,r.x,L),xc(u.y,r.y,L),this.setTargetDelta(u),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Vn(p,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Xm(this.relativeTarget,this.relativeTargetOrigin,p,L),C&&Dm(this.relativeTarget,C)&&(this.isProjectionDirty=!1),C||(C=_t()),Gt(C,this.relativeTarget)),b&&(this.animationValues=d,Am(d,c,this.latestValues,L,S,y)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=L},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(r){var a,l,c;this.notifyListeners("animationStart"),(a=this.currentAnimation)==null||a.stop(),(c=(l=this.resumingFrom)==null?void 0:l.currentAnimation)==null||c.stop(),this.pendingAnimation&&(_e(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ut.update(()=>{Si.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Ze(0)),this.currentAnimation=Sm(this.motionValue,[0,1e3],{...r,velocity:0,isSync:!0,onUpdate:d=>{this.mixTargetDelta(d),r.onUpdate&&r.onUpdate(d)},onStop:()=>{},onComplete:()=>{r.onComplete&&r.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const r=this.getStack();r&&r.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Vm),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const r=this.getLead();let{targetWithTransforms:a,target:l,layout:c,latestValues:d}=r;if(!(!a||!l||!c)){if(this!==r&&this.layout&&c&&Ec(this.options.animationType,this.layout.layoutBox,c.layoutBox)){l=this.target||_t();const u=Et(this.layout.layoutBox.x);l.x.min=r.target.x.min,l.x.max=l.x.min+u;const p=Et(this.layout.layoutBox.y);l.y.min=r.target.y.min,l.y.max=l.y.min+p}Gt(a,l),nn(a,d),Nn(this.projectionDeltaWithTransform,this.layoutCorrected,a,d)}}registerSharedNode(r,a){this.sharedNodes.has(r)||this.sharedNodes.set(r,new Om),this.sharedNodes.get(r).add(a);const c=a.options.initialPromotionConfig;a.promote({transition:c?c.transition:void 0,preserveFollowOpacity:c&&c.shouldPreserveFollowOpacity?c.shouldPreserveFollowOpacity(a):void 0})}isLead(){const r=this.getStack();return r?r.lead===this:!0}getLead(){var a;const{layoutId:r}=this.options;return r?((a=this.getStack())==null?void 0:a.lead)||this:this}getPrevLead(){var a;const{layoutId:r}=this.options;return r?(a=this.getStack())==null?void 0:a.prevLead:void 0}getStack(){const{layoutId:r}=this.options;if(r)return this.root.sharedNodes.get(r)}promote({needsReset:r,transition:a,preserveFollowOpacity:l}={}){const c=this.getStack();c&&c.promote(this,l),r&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const r=this.getStack();return r?r.relegate(this):!1}resetSkewAndRotation(){const{visualElement:r}=this.options;if(!r)return;let a=!1;const{latestValues:l}=r;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const c={};l.z&&fr("z",r,c,this.animationValues);for(let d=0;d<hr.length;d++)fr(`rotate${hr[d]}`,r,c,this.animationValues),fr(`skew${hr[d]}`,r,c,this.animationValues);r.render();for(const d in c)r.setStaticValue(d,c[d]),this.animationValues&&(this.animationValues[d]=c[d]);r.scheduleRender()}applyProjectionStyles(r,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){r.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,r.visibility="",r.opacity="",r.pointerEvents=bi(a==null?void 0:a.pointerEvents)||"",r.transform=l?l(this.latestValues,""):"none";return}const c=this.getLead();if(!this.projectionDelta||!this.layout||!c.target){this.options.layoutId&&(r.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,r.pointerEvents=bi(a==null?void 0:a.pointerEvents)||""),this.hasProjected&&!Oe(this.latestValues)&&(r.transform=l?l({},""):"none",this.hasProjected=!1);return}r.visibility="";const d=c.animationValues||c.latestValues;this.applyTransformsToTarget();let u=Nm(this.projectionDeltaWithTransform,this.treeScale,d);l&&(u=l(d,u)),r.transform=u;const{x:p,y:g}=this.projectionDelta;r.transformOrigin=`${p.origin*100}% ${g.origin*100}% 0`,c.animationValues?r.opacity=c===this?d.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:d.opacityExit:r.opacity=c===this?d.opacity!==void 0?d.opacity:"":d.opacityExit!==void 0?d.opacityExit:0;for(const _ in Pn){if(d[_]===void 0)continue;const{correct:b,applyTo:w,isCSSVariable:y}=Pn[_],S=u==="none"?d[_]:b(d[_],c);if(w){const C=w.length;for(let P=0;P<C;P++)r[w[P]]=S}else y?this.options.visualElement.renderState.vars[_]=S:r[_]=S}this.options.layoutId&&(r.pointerEvents=c===this?bi(a==null?void 0:a.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(r=>{var a;return(a=r.currentAnimation)==null?void 0:a.stop()}),this.root.nodes.forEach(yc),this.root.sharedNodes.clear()}}}function Bm(e){e.updateLayout()}function jm(e){var n;const t=((n=e.resumeFrom)==null?void 0:n.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:i,measuredBox:s}=e.layout,{animationType:o}=e.options,r=t.source!==e.layout.source;o==="size"?Ht(u=>{const p=r?t.measuredBox[u]:t.layoutBox[u],g=Et(p);p.min=i[u].min,p.max=p.min+g}):Ec(o,t.layoutBox,i)&&Ht(u=>{const p=r?t.measuredBox[u]:t.layoutBox[u],g=Et(i[u]);p.max=p.min+g,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[u].max=e.relativeTarget[u].min+g)});const a=tn();Nn(a,i,t.layoutBox);const l=tn();r?Nn(l,e.applyTransform(s,!0),t.measuredBox):Nn(l,i,t.layoutBox);const c=!dc(a);let d=!1;if(!e.resumeFrom){const u=e.getClosestProjectingParent();if(u&&!u.resumeFrom){const{snapshot:p,layout:g}=u;if(p&&g){const _=_t();Vn(_,t.layoutBox,p.layoutBox);const b=_t();Vn(b,i,g.layoutBox),pc(_,b)||(d=!0),u.options.layoutRoot&&(e.relativeTarget=b,e.relativeTargetOrigin=_,e.relativeParent=u)}}}e.notifyListeners("didUpdate",{layout:i,snapshot:t,delta:l,layoutDelta:a,hasLayoutChanged:c,hasRelativeLayoutChanged:d})}else if(e.isLead()){const{onExitComplete:i}=e.options;i&&i()}e.options.transition=void 0}function $m(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function Um(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Hm(e){e.clearSnapshot()}function yc(e){e.clearMeasurements()}function bc(e){e.isLayoutDirty=!1}function Gm(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function wc(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Wm(e){e.resolveTargetDelta()}function zm(e){e.calcProjection()}function qm(e){e.resetSkewAndRotation()}function Km(e){e.removeLeadSnapshot()}function xc(e,t,n){e.translate=mt(t.translate,0,n),e.scale=mt(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Sc(e,t,n,i){e.min=mt(t.min,n.min,i),e.max=mt(t.max,n.max,i)}function Xm(e,t,n,i){Sc(e.x,t.x,n.x,i),Sc(e.y,t.y,n.y,i)}function Ym(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const Zm={duration:.45,ease:[.4,0,.1,1]},Cc=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),kc=Cc("applewebkit/")&&!Cc("chrome/")?Math.round:Ut;function Tc(e){e.min=kc(e.min),e.max=kc(e.max)}function Jm(e){Tc(e.x),Tc(e.y)}function Ec(e,t,n){return e==="position"||e==="preserve-aspect"&&!nm(mc(t),mc(n),.2)}function Qm(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const tg=_c({attachResizeListener:(e,t)=>Ln(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),pr={current:void 0},Ac=_c({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!pr.current){const e=new tg({});e.mount(window),e.setOptions({layoutScroll:!0}),pr.current=e}return pr.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),eg={pan:{Feature:ym},drag:{Feature:_m,ProjectionNode:Ac,MeasureLayout:Ql}};function Rc(e,t,n){const{props:i}=e;e.animationState&&i.whileHover&&e.animationState.setActive("whileHover",n==="Start");const s="onHover"+n,o=i[s];o&&ut.postRender(()=>o(t,Dn(t)))}class ng extends we{mount(){const{current:t}=this.node;t&&(this.unmount=Pf(t,(n,i)=>(Rc(this.node,i,"Start"),s=>Rc(this.node,s,"End"))))}unmount(){}}class ig extends we{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=bn(Ln(this.node.current,"focus",()=>this.onFocus()),Ln(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Ic(e,t,n){const{props:i}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&i.whileTap&&e.animationState.setActive("whileTap",n==="Start");const s="onTap"+(n==="End"?"":n),o=i[s];o&&ut.postRender(()=>o(t,Dn(t)))}class sg extends we{mount(){const{current:t}=this.node;t&&(this.unmount=Of(t,(n,i)=>(Ic(this.node,i,"Start"),(s,{success:o})=>Ic(this.node,s,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const mr=new WeakMap,gr=new WeakMap,rg=e=>{const t=mr.get(e.target);t&&t(e)},og=e=>{e.forEach(rg)};function ag({root:e,...t}){const n=e||document;gr.has(n)||gr.set(n,{});const i=gr.get(n),s=JSON.stringify(t);return i[s]||(i[s]=new IntersectionObserver(og,{root:e,...t})),i[s]}function lg(e,t,n){const i=ag(t);return mr.set(e,n),i.observe(e),()=>{mr.delete(e),i.unobserve(e)}}const cg={some:0,all:1};class ug extends we{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:i,amount:s="some",once:o}=t,r={root:n?n.current:void 0,rootMargin:i,threshold:typeof s=="number"?s:cg[s]},a=l=>{const{isIntersecting:c}=l;if(this.isInView===c||(this.isInView=c,o&&!c&&this.hasEnteredView))return;c&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",c);const{onViewportEnter:d,onViewportLeave:u}=this.node.getProps(),p=c?d:u;p&&p(l)};return lg(this.node.current,r,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(dg(t,n))&&this.startObserver()}unmount(){}}function dg({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const hg={inView:{Feature:ug},tap:{Feature:sg},focus:{Feature:ig},hover:{Feature:ng}},fg={layout:{ProjectionNode:Ac,MeasureLayout:Ql}},vr={current:null},Pc={current:!1};function pg(){if(Pc.current=!0,!!as)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>vr.current=e.matches;e.addEventListener("change",t),t()}else vr.current=!1}const mg=new WeakMap;function gg(e,t,n){for(const i in t){const s=t[i],o=n[i];if(kt(s))e.addValue(i,s);else if(kt(o))e.addValue(i,Ze(s,{owner:e}));else if(o!==s)if(e.hasValue(i)){const r=e.getValue(i);r.liveStyle===!0?r.jump(s):r.hasAnimated||r.set(s)}else{const r=e.getStaticValue(i);e.addValue(i,Ze(r!==void 0?r:s,{owner:e}))}}for(const i in n)t[i]===void 0&&e.removeValue(i);return t}const Mc=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class vg{scrapeMotionValuesFromProps(t,n,i){return{}}constructor({parent:t,props:n,presenceContext:i,reducedMotionConfig:s,blockInitialAnimation:o,visualState:r},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=js,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const p=Lt.now();this.renderScheduledAt<p&&(this.renderScheduledAt=p,ut.render(this.render,!1,!0))};const{latestValues:l,renderState:c}=r;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=c,this.parent=t,this.props=n,this.presenceContext=i,this.depth=t?t.depth+1:0,this.reducedMotionConfig=s,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=yi(n),this.isVariantNode=al(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:d,...u}=this.scrapeMotionValuesFromProps(n,{},this);for(const p in u){const g=u[p];l[p]!==void 0&&kt(g)&&g.set(l[p],!1)}}mount(t){this.current=t,mg.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,i)=>this.bindToMotionValue(i,n)),Pc.current||pg(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:vr.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),_e(this.notifyUpdate),_e(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const i=Ye.has(t);i&&this.onBindTransform&&this.onBindTransform();const s=n.on("change",a=>{this.latestValues[t]=a,this.props.onUpdate&&ut.preRender(this.notifyUpdate),i&&this.projection&&(this.projection.isTransformDirty=!0)}),o=n.on("renderRequest",this.scheduleRender);let r;window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{s(),o(),r&&r(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Je){const n=Je[t];if(!n)continue;const{isEnabled:i,Feature:s}=n;if(!this.features[t]&&s&&i(this.props)&&(this.features[t]=new s(this)),this.features[t]){const o=this.features[t];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):_t()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let i=0;i<Mc.length;i++){const s=Mc[i];this.propEventSubscriptions[s]&&(this.propEventSubscriptions[s](),delete this.propEventSubscriptions[s]);const o="on"+s,r=t[o];r&&(this.propEventSubscriptions[s]=this.on(s,r))}this.prevMotionValues=gg(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const i=this.values.get(t);n!==i&&(i&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let i=this.values.get(t);return i===void 0&&n!==void 0&&(i=Ze(n===null?void 0:n,{owner:this}),this.addValue(t,i)),i}readValue(t,n){let i=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return i!=null&&(typeof i=="string"&&(zo(i)||Ko(i))?i=parseFloat(i):!Ff(i)&&be.test(n)&&(i=Wa(t,n)),this.setBaseTarget(t,kt(i)?i.get():i)),kt(i)?i.get():i}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var o;const{initial:n}=this.props;let i;if(typeof n=="string"||typeof n=="object"){const r=tr(this.props,n,(o=this.presenceContext)==null?void 0:o.custom);r&&(i=r[t])}if(n&&i!==void 0)return i;const s=this.getBaseTargetFromProps(this.props,t);return s!==void 0&&!kt(s)?s:this.initialValues[t]!==void 0&&i===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new hs),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}}class Lc extends vg{constructor(){super(...arguments),this.KeyframeResolver=Tf}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:i}){delete n[t],delete i[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;kt(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Dc(e,{style:t,vars:n},i,s){const o=e.style;let r;for(r in t)o[r]=t[r];s==null||s.applyProjectionStyles(o,i);for(r in n)o.setProperty(r,n[r])}function _g(e){return window.getComputedStyle(e)}class yg extends Lc{constructor(){super(...arguments),this.type="html",this.renderInstance=Dc}readValueFromInstance(t,n){var i;if(Ye.has(n))return(i=this.projection)!=null&&i.isProjecting?Os(n):Wh(t,n);{const s=_g(t),o=(gs(n)?s.getPropertyValue(n):s[n])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(t,{transformPagePoint:n}){return jl(t,n)}build(t,n,i){Zs(t,n,i.transformTemplate)}scrapeMotionValuesFromProps(t,n,i){return er(t,n,i)}}const Oc=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function bg(e,t,n,i){Dc(e,t,void 0,i);for(const s in t.attrs)e.setAttribute(Oc.has(s)?s:Ys(s),t.attrs[s])}class wg extends Lc{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=_t}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Ye.has(n)){const i=Ga(n);return i&&i.default||0}return n=Oc.has(n)?n:Ys(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,i){return yl(t,n,i)}build(t,n,i){pl(t,n,this.isSVGTag,i.transformTemplate,i.style)}renderInstance(t,n,i,s){bg(t,n,i,s)}mount(t){this.isSVGTag=gl(t.tagName),super.mount(t)}}const xg=(e,t)=>Qs(e)?new wg(t):new yg(t,{allowProjection:e!==te}),Sg=xp({...Kp,...hg,...eg,...fg},xg),Bn=Kf(Sg),Cg=["agent-id","environment","position","version-id","call-destination-number","call-caller-number","call-caller-name","call-custom-headers"],Ci="widget-layout-id";function Nc(e){var t,n,i="";if(typeof e=="string"||typeof e=="number")i+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(n=Nc(e[t]))&&(i&&(i+=" "),i+=n)}else for(n in e)e[n]&&(i&&(i+=" "),i+=n);return i}function xe(){for(var e,t,n=0,i="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=Nc(e))&&(i&&(i+=" "),i+=t);return i}const jn={},Vc=(e,t)=>e.unstable_is?e.unstable_is(t):t===e,Fc=e=>"init"in e,_r=e=>!!e.write,Bc=e=>"v"in e||"e"in e,ki=e=>{if("e"in e)throw e.e;if((jn?"production":void 0)!=="production"&&!("v"in e))throw new Error("[Bug] atom state is not initialized");return e.v},Ti=new WeakMap,jc=e=>{var t;return Ei(e)&&!!((t=Ti.get(e))!=null&&t[0])},kg=e=>{const t=Ti.get(e);t!=null&&t[0]&&(t[0]=!1,t[1].forEach(n=>n()))},$c=(e,t)=>{let n=Ti.get(e);if(!n){n=[!0,new Set],Ti.set(e,n);const i=()=>{n[0]=!1};e.then(i,i)}n[1].add(t)},Ei=e=>typeof(e==null?void 0:e.then)=="function",Uc=(e,t,n)=>{n.p.has(e)||(n.p.add(e),t.then(()=>{n.p.delete(e)},()=>{n.p.delete(e)}))},yr=(e,t,n)=>{const i=n(e),s="v"in i,o=i.v;if(Ei(t))for(const r of i.d.keys())Uc(e,t,n(r));i.v=t,delete i.e,(!s||!Object.is(o,i.v))&&(++i.n,Ei(o)&&kg(o))},Hc=(e,t,n)=>{var i;const s=new Set;for(const o of((i=n.get(e))==null?void 0:i.t)||[])n.has(o)&&s.add(o);for(const o of t.p)s.add(o);return s},Tg=()=>{const e=new Set,t=()=>{e.forEach(n=>n())};return t.add=n=>(e.add(n),()=>{e.delete(n)}),t},br=()=>{const e={},t=new WeakMap,n=i=>{var s,o;(s=t.get(e))==null||s.forEach(r=>r(i)),(o=t.get(i))==null||o.forEach(r=>r())};return n.add=(i,s)=>{const o=i||e,r=(t.has(o)?t:t.set(o,new Set)).get(o);return r.add(s),()=>{r==null||r.delete(s),r.size||t.delete(o)}},n},Eg=e=>(e.c||(e.c=br()),e.m||(e.m=br()),e.u||(e.u=br()),e.f||(e.f=Tg()),e),Ag=Symbol(),Gc=(e=new WeakMap,t=new WeakMap,n=new WeakMap,i=new Set,s=new Set,o=new Set,r={},a=(p,...g)=>p.read(...g),l=(p,...g)=>p.write(...g),c=(p,g)=>{var _;return(_=p.unstable_onInit)==null?void 0:_.call(p,g)},d=(p,g)=>{var _;return(_=p.onMount)==null?void 0:_.call(p,g)},...u)=>{const p=u[0]||(x=>{if((jn?"production":void 0)!=="production"&&!x)throw new Error("Atom is undefined or null");let k=e.get(x);return k||(k={d:new Map,p:new Set,n:0},e.set(x,k),c==null||c(x,D)),k}),g=u[1]||(()=>{const x=[],k=f=>{try{f()}catch(m){x.push(m)}};do{r.f&&k(r.f);const f=new Set,m=f.add.bind(f);i.forEach(h=>{var v;return(v=t.get(h))==null?void 0:v.l.forEach(m)}),i.clear(),o.forEach(m),o.clear(),s.forEach(m),s.clear(),f.forEach(k),i.size&&_()}while(i.size||o.size||s.size);if(x.length)throw new AggregateError(x)}),_=u[2]||(()=>{const x=[],k=new WeakSet,f=new WeakSet,m=Array.from(i);for(;m.length;){const h=m[m.length-1],v=p(h);if(f.has(h)){m.pop();continue}if(k.has(h)){if(n.get(h)===v.n)x.push([h,v]);else if((jn?"production":void 0)!=="production"&&n.has(h))throw new Error("[Bug] invalidated atom exists");f.add(h),m.pop();continue}k.add(h);for(const T of Hc(h,v,t))k.has(T)||m.push(T)}for(let h=x.length-1;h>=0;--h){const[v,T]=x[h];let R=!1;for(const A of T.d.keys())if(A!==v&&i.has(A)){R=!0;break}R&&(b(v),S(v)),n.delete(v)}}),b=u[3]||(x=>{var k;const f=p(x);if(Bc(f)&&(t.has(x)&&n.get(x)!==f.n||Array.from(f.d).every(([I,N])=>b(I).n===N)))return f;f.d.clear();let m=!0;const h=()=>{t.has(x)&&(S(x),_(),g())},v=I=>{var N;if(Vc(x,I)){const F=p(I);if(!Bc(F))if(Fc(I))yr(I,I.init,p);else throw new Error("no atom init");return ki(F)}const K=b(I);try{return ki(K)}finally{f.d.set(I,K.n),jc(f.v)&&Uc(x,f.v,K),(N=t.get(I))==null||N.t.add(x),m||h()}};let T,R;const A={get signal(){return T||(T=new AbortController),T.signal},get setSelf(){return(jn?"production":void 0)!=="production"&&!_r(x)&&console.warn("setSelf function cannot be used with read-only atom"),!R&&_r(x)&&(R=(...I)=>{if((jn?"production":void 0)!=="production"&&m&&console.warn("setSelf function cannot be called in sync"),!m)try{return y(x,...I)}finally{_(),g()}}),R}},M=f.n;try{const I=a(x,v,A);return yr(x,I,p),Ei(I)&&($c(I,()=>T==null?void 0:T.abort()),I.then(h,h)),f}catch(I){return delete f.v,f.e=I,++f.n,f}finally{m=!1,M!==f.n&&n.get(x)===M&&(n.set(x,f.n),i.add(x),(k=r.c)==null||k.call(r,x))}}),w=u[4]||(x=>{const k=[x];for(;k.length;){const f=k.pop(),m=p(f);for(const h of Hc(f,m,t)){const v=p(h);n.set(h,v.n),k.push(h)}}}),y=u[5]||((x,...k)=>{let f=!0;const m=v=>ki(b(v)),h=(v,...T)=>{var R;const A=p(v);try{if(Vc(x,v)){if(!Fc(v))throw new Error("atom not writable");const M=A.n,I=T[0];yr(v,I,p),S(v),M!==A.n&&(i.add(v),(R=r.c)==null||R.call(r,v),w(v));return}else return y(v,...T)}finally{f||(_(),g())}};try{return l(x,m,h,...k)}finally{f=!1}}),S=u[6]||(x=>{var k;const f=p(x),m=t.get(x);if(m&&!jc(f.v)){for(const[h,v]of f.d)if(!m.d.has(h)){const T=p(h);C(h).t.add(x),m.d.add(h),v!==T.n&&(i.add(h),(k=r.c)==null||k.call(r,h),w(h))}for(const h of m.d||[])if(!f.d.has(h)){m.d.delete(h);const v=P(h);v==null||v.t.delete(x)}}}),C=u[7]||(x=>{var k;const f=p(x);let m=t.get(x);if(!m){b(x);for(const h of f.d.keys())C(h).t.add(x);if(m={l:new Set,d:new Set(f.d.keys()),t:new Set},t.set(x,m),(k=r.m)==null||k.call(r,x),_r(x)){const h=()=>{let v=!0;const T=(...R)=>{try{return y(x,...R)}finally{v||(_(),g())}};try{const R=d(x,T);R&&(m.u=()=>{v=!0;try{R()}finally{v=!1}})}finally{v=!1}};s.add(h)}}return m}),P=u[8]||(x=>{var k;const f=p(x);let m=t.get(x);if(m&&!m.l.size&&!Array.from(m.t).some(h=>{var v;return(v=t.get(h))==null?void 0:v.d.has(x)})){m.u&&o.add(m.u),m=void 0,t.delete(x),(k=r.u)==null||k.call(r,x);for(const h of f.d.keys()){const v=P(h);v==null||v.t.delete(x)}return}return m}),L=[e,t,n,i,s,o,r,a,l,c,d,p,g,_,b,w,y,S,C,P],D={get:x=>ki(b(x)),set:(x,...k)=>{try{return y(x,...k)}finally{_(),g()}},sub:(x,k)=>{const m=C(x).l;return m.add(k),g(),()=>{m.delete(k),P(x),g()}}};return Object.defineProperty(D,Ag,{value:L}),D},Rg=Eg,Wc=$c,wr={};let Ig=0;function xr(e,t){const n=`atom${++Ig}`,i={toString(){return(wr?"production":void 0)!=="production"&&this.debugLabel?n+":"+this.debugLabel:n}};return typeof e=="function"?i.read=e:(i.init=e,i.read=Pg,i.write=Mg),i}function Pg(e){return e(this)}function Mg(e,t,n){return t(this,typeof n=="function"?n(e(this)):n)}const Lg=()=>{let e=0;const t=Rg({}),n=new WeakMap,i=new WeakMap,s=Gc(n,i,void 0,void 0,void 0,void 0,t,void 0,(a,l,c,...d)=>e?c(a,...d):a.write(l,c,...d)),o=new Set;return t.m.add(void 0,a=>{o.add(a);const l=n.get(a);l.m=i.get(a)}),t.u.add(void 0,a=>{o.delete(a);const l=n.get(a);delete l.m}),Object.assign(s,{dev4_get_internal_weak_map:()=>(console.log("Deprecated: Use devstore from the devtools library"),n),dev4_get_mounted_atoms:()=>o,dev4_restore_atoms:a=>{const l={read:()=>null,write:(c,d)=>{++e;try{for(const[u,p]of a)"init"in u&&d(u,p)}finally{--e}}};s.set(l)}})};function Dg(){return(wr?"production":void 0)!=="production"?Lg():Gc()}let $n;function Og(){return $n||($n=Dg(),(wr?"production":void 0)!=="production"&&(globalThis.__JOTAI_DEFAULT_STORE__||(globalThis.__JOTAI_DEFAULT_STORE__=$n),globalThis.__JOTAI_DEFAULT_STORE__!==$n&&console.warn("Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"))),$n}const Ng={},Vg=Re(void 0);function zc(e){return wt(Vg)||Og()}const Sr=e=>typeof(e==null?void 0:e.then)=="function",Cr=e=>{e.status||(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}))},Fg=Go.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(Cr(e),e)}),kr=new WeakMap,qc=(e,t)=>{let n=kr.get(e);return n||(n=new Promise((i,s)=>{let o=e;const r=c=>d=>{o===c&&i(d)},a=c=>d=>{o===c&&s(d)},l=()=>{try{const c=t();Sr(c)?(kr.set(c,n),o=c,c.then(r(c),a(c)),Wc(c,l)):i(c)}catch(c){s(c)}};e.then(r(e),a(e)),Wc(e,l)}),kr.set(e,n)),n};function Kc(e,t){const{delay:n,unstable_promiseStatus:i=!Go.use}={},s=zc(),[[o,r,a],l]=Co(d=>{const u=s.get(e);return Object.is(d[0],u)&&d[1]===s&&d[2]===e?d:[u,s,e]},void 0,()=>[s.get(e),s,e]);let c=o;if((r!==s||a!==e)&&(l(),c=s.get(e)),$t(()=>{const d=s.sub(e,()=>{if(i)try{const u=s.get(e);Sr(u)&&Cr(qc(u,()=>s.get(e)))}catch{}if(typeof n=="number"){setTimeout(l,n);return}l()});return l(),d},[s,e,n,i]),Td(c),Sr(c)){const d=qc(c,()=>s.get(e));return i&&Cr(d),Fg(d)}return c}function Xc(e,t){const n=zc();return ii((...s)=>{if((Ng?"production":void 0)!=="production"&&!("write"in e))throw new Error("not writable atom");return n.set(e,...s)},[n,e])}function Yc(e,t){return[Kc(e),Xc(e)]}const Bg=xr("waiting"),Zc=()=>Yc(Bg),Ai={theme:"dark",audio_visualizer_config:{color:"verdant",preset:"roundBars"},start_call_text:"Let's chat",default_state:"collapsed",position:"fixed",view_history_url:null,report_issue_url:null,give_feedback_url:null,agent_thinking_text:"Thinking...",speak_to_interrupt_text:"Speak to interrupt",logo_icon_url:null},Jc=xr(Ai),jg=()=>{const e=Xc(Jc);return ii(t=>e(()=>{const n={...t};return n.start_call_text||(n.start_call_text=Ai.start_call_text),n.agent_thinking_text||(n.agent_thinking_text=Ai.agent_thinking_text),n.speak_to_interrupt_text||(n.speak_to_interrupt_text=Ai.speak_to_interrupt_text),n}),[e])},Ne=()=>Kc(Jc),Qc=({size:e="large",className:t})=>{const n=Ne(),[i]=Zc();return E("h1",{className:xe({"text-xs":e==="small"},t),children:i==="waiting"?n.speak_to_interrupt_text:n.agent_thinking_text})},tu=({stream:e})=>{const t=Mt(null);return $t(()=>{!t.current||!e||(t.current.srcObject=e)},[e]),E("audio",{muted:!0,ref:t,autoPlay:!0})};/**!
|
|
9
|
+
`),()=>{w.removeChild(y),w.contains(y)&&w.removeChild(y)}},[e]),E(jf,{isPresent:e,childRef:o,sizeRef:r,children:Gd(t,{ref:o})})}const Uf=({children:t,initial:e,isPresent:n,onExitComplete:i,custom:s,presenceAffectsLayout:o,mode:r,anchorX:a,root:c})=>{const l=ri(Gf),d=es();let u=!0,m=nt(()=>(u=!1,{id:d,initial:e,isPresent:n,custom:s,onExitComplete:g=>{l.set(g,!0);for(const y of l.values())if(!y)return;i&&i()},register:g=>(l.set(g,!1),()=>l.delete(g))}),[n,l,i]);return o&&u&&(m={...m}),nt(()=>{l.forEach((g,y)=>l.set(y,!1))},[n]),$e(()=>{!n&&!l.size&&i&&i()},[n]),r==="popLayout"&&(t=E($f,{isPresent:n,anchorX:a,root:c,children:t})),E(oi.Provider,{value:m,children:t})};function Gf(){return new Map}function ec(t=!0){const e=we(oi);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:i,register:s}=e,o=es();$e(()=>{if(t)return s(o)},[t]);const r=ni(()=>t&&i&&i(o),[o,i,t]);return!n&&i?[!1,r]:[!0]}const pi=t=>t.key||"";function tc(t){const e=[];return Md.forEach(t,n=>{Uo(n)&&e.push(n)}),e}const Hf=({children:t,custom:e,initial:n=!0,onExitComplete:i,presenceAffectsLayout:s=!0,mode:o="sync",propagate:r=!1,anchorX:a="left",root:c})=>{const[l,d]=ec(r),u=nt(()=>tc(t),[t]),m=r&&!l?[]:u.map(pi),g=De(!0),y=De(u),w=ri(()=>new Map),[b,v]=Xe(u),[S,k]=Xe(u);Ho(()=>{g.current=!1,y.current=u;for(let O=0;O<S.length;O++){const x=pi(S[O]);m.includes(x)?w.delete(x):w.get(x)!==!0&&w.set(x,!1)}},[S,m.length,m.join("-")]);const I=[];if(u!==b){let O=[...u];for(let x=0;x<S.length;x++){const C=S[x],f=pi(C);m.includes(f)||(O.splice(x,0,C),I.push(C))}return o==="wait"&&I.length&&(O=I),k(tc(O)),v(u),null}const{forceRender:D}=we(ss);return E(et,{children:S.map(O=>{const x=pi(O),C=r&&!l?!1:u===S||m.includes(x),f=()=>{if(w.has(x))w.set(x,!0);else return;let p=!0;w.forEach(h=>{h||(p=!1)}),p&&(D==null||D(),k(y.current),r&&(d==null||d()),i&&i())};return E(Uf,{isPresent:C,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:s,mode:o,root:c,onExitComplete:C?void 0:f,anchorX:a,children:O},x)})})},nc=It({strict:!1}),ic={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Jt={};for(const t in ic)Jt[t]={isEnabled:e=>ic[t].some(n=>!!e[n])};function Wf(t){for(const e in t)Jt[e]={...Jt[e],...t[e]}}const zf=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function mi(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||zf.has(t)}let sc=t=>!mi(t);function rc(t){typeof t=="function"&&(sc=e=>e.startsWith("on")?!mi(e):t(e))}try{rc(require("@emotion/is-prop-valid").default)}catch{}function qf(t,e,n){const i={};for(const s in t)s==="values"&&typeof t.values=="object"||(sc(s)||n===!0&&mi(s)||!e&&!mi(s)||t.draggable&&s.startsWith("onDrag"))&&(i[s]=t[s]);return i}function Kf({children:t,isValidProp:e,...n}){e&&rc(e),n={...we(In),...n},n.isStatic=ri(()=>n.isStatic);const i=nt(()=>n,[JSON.stringify(n.transition),n.transformPagePoint,n.reducedMotion]);return E(In.Provider,{value:i,children:t})}function Xf(t){if(typeof Proxy>"u")return t;const e=new Map,n=(...i)=>t(...i);return new Proxy(n,{get:(i,s)=>s==="create"?t:(e.has(s)||e.set(s,t(s)),e.get(s))})}const gi=It({});function _i(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Pn(t){return typeof t=="string"||Array.isArray(t)}const zs=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],qs=["initial",...zs];function vi(t){return _i(t.animate)||qs.some(e=>Pn(t[e]))}function oc(t){return!!(vi(t)||t.variants)}function Yf(t,e){if(vi(t)){const{initial:n,animate:i}=t;return{initial:n===!1||Pn(n)?n:void 0,animate:Pn(i)?i:void 0}}return t.inherit!==!1?e:{}}function Zf(t){const{initial:e,animate:n}=Yf(t,we(gi));return nt(()=>({initial:e,animate:n}),[ac(e),ac(n)])}function ac(t){return Array.isArray(t)?t.join(" "):t}const Jf=Symbol.for("motionComponentSymbol");function Qt(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Qf(t,e,n){return ni(i=>{i&&t.onMount&&t.onMount(i),e&&(i?e.mount(i):e.unmount()),n&&(typeof n=="function"?n(i):Qt(n)&&(n.current=i))},[e])}const Ks=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),cc="data-"+Ks("framerAppearId"),lc=It({});function ep(t,e,n,i,s){var w,b;const{visualElement:o}=we(gi),r=we(nc),a=we(oi),c=we(In).reducedMotion,l=De(null);i=i||r.renderer,!l.current&&i&&(l.current=i(t,{visualState:e,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:c}));const d=l.current,u=we(lc);d&&!d.projection&&s&&(d.type==="html"||d.type==="svg")&&tp(l.current,n,s,u);const m=De(!1);Ao(()=>{d&&m.current&&d.update(n,a)});const g=n[cc],y=De(!!g&&!((w=window.MotionHandoffIsComplete)!=null&&w.call(window,g))&&((b=window.MotionHasOptimisedAnimation)==null?void 0:b.call(window,g)));return Ho(()=>{d&&(m.current=!0,window.MotionIsMounted=!0,d.updateFeatures(),Gs.render(d.render),y.current&&d.animationState&&d.animationState.animateChanges())}),$e(()=>{d&&(!y.current&&d.animationState&&d.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{var v;(v=window.MotionHandoffMarkAsComplete)==null||v.call(window,g)}),y.current=!1))}),d}function tp(t,e,n,i){const{layoutId:s,layout:o,drag:r,dragConstraints:a,layoutScroll:c,layoutRoot:l,layoutCrossfade:d}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:uc(t.parent)),t.projection.setOptions({layoutId:s,layout:o,alwaysMeasureLayout:!!r||a&&Qt(a),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:i,crossfade:d,layoutScroll:c,layoutRoot:l})}function uc(t){if(t)return t.options.allowProjection!==!1?t.projection:uc(t.parent)}function np({preloadedFeatures:t,createVisualElement:e,useRender:n,useVisualState:i,Component:s}){t&&Wf(t);function o(a,c){let l;const d={...we(In),...a,layoutId:ip(a)},{isStatic:u}=d,m=Zf(a),g=i(a,u);if(!u&&rs){sp();const y=rp(d);l=y.MeasureLayout,m.visualElement=ep(s,g,d,e,y.ProjectionNode)}return E(gi.Provider,{value:m,children:[l&&m.visualElement?E(l,{visualElement:m.visualElement,...d}):null,n(s,a,Qf(g,m.visualElement,c),g,u,m.visualElement)]})}o.displayName=`motion.${typeof s=="string"?s:`create(${s.displayName??s.name??""})`}`;const r=Rd(o);return r[Jf]=s,r}function ip({layoutId:t}){const e=we(ss).id;return e&&t!==void 0?e+"-"+t:t}function sp(t,e){we(nc).strict}function rp(t){const{drag:e,layout:n}=Jt;if(!e&&!n)return{};const i={...e,...n};return{MeasureLayout:e!=null&&e.isEnabled(t)||n!=null&&n.isEnabled(t)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}const Rn={};function op(t){for(const e in t)Rn[e]=t[e],ps(e)&&(Rn[e].isCSSVariable=!0)}function dc(t,{layout:e,layoutId:n}){return Yt.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Rn[t]||t==="opacity")}const ap={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},cp=Xt.length;function lp(t,e,n){let i="",s=!0;for(let o=0;o<cp;o++){const r=Xt[o],a=t[r];if(a===void 0)continue;let c=!0;if(typeof a=="number"?c=a===(r.startsWith("scale")?1:0):c=parseFloat(a)===0,!c||n){const l=Wa(a,Us[r]);if(!c){s=!1;const d=ap[r]||r;i+=`${d}(${l}) `}n&&(e[r]=l)}}return i=i.trim(),n?i=n(e,s?"":i):s&&(i="none"),i}function Xs(t,e,n){const{style:i,vars:s,transformOrigin:o}=t;let r=!1,a=!1;for(const c in e){const l=e[c];if(Yt.has(c)){r=!0;continue}else if(ps(c)){s[c]=l;continue}else{const d=Wa(l,Us[c]);c.startsWith("origin")?(a=!0,o[c]=d):i[c]=d}}if(e.transform||(r||n?i.transform=lp(e,t.transform,n):i.transform&&(i.transform="none")),a){const{originX:c="50%",originY:l="50%",originZ:d=0}=o;i.transformOrigin=`${c} ${l} ${d}`}}const Ys=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function hc(t,e,n){for(const i in e)!Te(e[i])&&!dc(i,n)&&(t[i]=e[i])}function up({transformTemplate:t},e){return nt(()=>{const n=Ys();return Xs(n,e,t),Object.assign({},n.vars,n.style)},[e])}function dp(t,e){const n=t.style||{},i={};return hc(i,n,t),Object.assign(i,up(t,e)),i}function hp(t,e){const n={},i=dp(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=i,n}const fp={offset:"stroke-dashoffset",array:"stroke-dasharray"},pp={offset:"strokeDashoffset",array:"strokeDasharray"};function mp(t,e,n=1,i=0,s=!0){t.pathLength=1;const o=s?fp:pp;t[o.offset]=G.transform(-i);const r=G.transform(e),a=G.transform(n);t[o.array]=`${r} ${a}`}function fc(t,{attrX:e,attrY:n,attrScale:i,pathLength:s,pathSpacing:o=1,pathOffset:r=0,...a},c,l,d){if(Xs(t,a,l),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:u,style:m}=t;u.transform&&(m.transform=u.transform,delete u.transform),(m.transform||u.transformOrigin)&&(m.transformOrigin=u.transformOrigin??"50% 50%",delete u.transformOrigin),m.transform&&(m.transformBox=(d==null?void 0:d.transformBox)??"fill-box",delete u.transformBox),e!==void 0&&(u.x=e),n!==void 0&&(u.y=n),i!==void 0&&(u.scale=i),s!==void 0&&mp(u,s,o,r,!1)}const pc=()=>({...Ys(),attrs:{}}),mc=t=>typeof t=="string"&&t.toLowerCase()==="svg";function gp(t,e,n,i){const s=nt(()=>{const o=pc();return fc(o,e,mc(i),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[e]);if(t.style){const o={};hc(o,t.style,t),s.style={...o,...s.style}}return s}const _p=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Zs(t){return typeof t!="string"||t.includes("-")?!1:!!(_p.indexOf(t)>-1||/[A-Z]/u.test(t))}function vp(t=!1){return(n,i,s,{latestValues:o},r)=>{const c=(Zs(n)?gp:hp)(i,o,r,n),l=qf(i,typeof n=="string",t),d=n!==et?{...l,...c,ref:s}:{},{children:u}=i,m=nt(()=>Te(u)?u.get():u,[u]);return je(n,{...d,children:m})}}function gc(t){const e=[{},{}];return t==null||t.values.forEach((n,i)=>{e[0][i]=n.get(),e[1][i]=n.getVelocity()}),e}function Js(t,e,n,i){if(typeof e=="function"){const[s,o]=gc(i);e=e(n!==void 0?n:t.custom,s,o)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[s,o]=gc(i);e=e(n!==void 0?n:t.custom,s,o)}return e}function yi(t){return Te(t)?t.get():t}function yp({scrapeMotionValuesFromProps:t,createRenderState:e},n,i,s){return{latestValues:bp(n,i,s,t),renderState:e()}}const _c=t=>(e,n)=>{const i=we(gi),s=we(oi),o=()=>yp(t,e,i,s);return n?o():ri(o)};function bp(t,e,n,i){const s={},o=i(t,{});for(const m in o)s[m]=yi(o[m]);let{initial:r,animate:a}=t;const c=vi(t),l=oc(t);e&&l&&!c&&t.inherit!==!1&&(r===void 0&&(r=e.initial),a===void 0&&(a=e.animate));let d=n?n.initial===!1:!1;d=d||r===!1;const u=d?a:r;if(u&&typeof u!="boolean"&&!_i(u)){const m=Array.isArray(u)?u:[u];for(let g=0;g<m.length;g++){const y=Js(t,m[g]);if(y){const{transitionEnd:w,transition:b,...v}=y;for(const S in v){let k=v[S];if(Array.isArray(k)){const I=d?k.length-1:0;k=k[I]}k!==null&&(s[S]=k)}for(const S in w)s[S]=w[S]}}}return s}function Qs(t,e,n){var o;const{style:i}=t,s={};for(const r in i)(Te(i[r])||e.style&&Te(e.style[r])||dc(r,t)||((o=n==null?void 0:n.getValue(r))==null?void 0:o.liveStyle)!==void 0)&&(s[r]=i[r]);return s}const wp={useVisualState:_c({scrapeMotionValuesFromProps:Qs,createRenderState:Ys})};function vc(t,e,n){const i=Qs(t,e,n);for(const s in t)if(Te(t[s])||Te(e[s])){const o=Xt.indexOf(s)!==-1?"attr"+s.charAt(0).toUpperCase()+s.substring(1):s;i[o]=t[s]}return i}const xp={useVisualState:_c({scrapeMotionValuesFromProps:vc,createRenderState:pc})};function Sp(t,e){return function(i,{forwardMotionProps:s}={forwardMotionProps:!1}){const r={...Zs(i)?xp:wp,preloadedFeatures:t,useRender:vp(s),createVisualElement:e,Component:i};return np(r)}}function Mn(t,e,n){const i=t.getProps();return Js(i,e,n!==void 0?n:i.custom,t)}const er=t=>Array.isArray(t);function kp(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,Zt(n))}function Cp(t){return er(t)?t[t.length-1]||0:t}function Tp(t,e){const n=Mn(t,e);let{transitionEnd:i={},transition:s={},...o}=n||{};o={...o,...i};for(const r in o){const a=Cp(o[r]);kp(t,r,a)}}function Ep(t){return!!(Te(t)&&t.add)}function tr(t,e){const n=t.getValue("willChange");if(Ep(n))return n.add(e);if(!n&&ft.WillChange){const i=new ft.WillChange("auto");t.addValue("willChange",i),i.add(e)}}function yc(t){return t.props[cc]}const Ap=t=>t!==null;function Ip(t,{repeat:e,repeatType:n="loop"},i){const s=t.filter(Ap),o=e&&n!=="loop"&&e%2===1?0:s.length-1;return s[o]}const Pp={type:"spring",stiffness:500,damping:25,restSpeed:10},Rp=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Mp={type:"keyframes",duration:.8},Dp={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Lp=(t,{keyframes:e})=>e.length>2?Mp:Yt.has(t)?t.startsWith("scale")?Rp(e[1]):Pp:Dp;function Op({when:t,delay:e,delayChildren:n,staggerChildren:i,staggerDirection:s,repeat:o,repeatType:r,repeatDelay:a,from:c,elapsed:l,...d}){return!!Object.keys(d).length}const nr=(t,e,n,i={},s,o)=>r=>{const a=js(i,t)||{},c=a.delay||i.delay||0;let{elapsed:l=0}=i;l=l-it(c);const d={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-l,onUpdate:m=>{e.set(m),a.onUpdate&&a.onUpdate(m)},onComplete:()=>{r(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:o?void 0:s};Op(a)||Object.assign(d,Lp(t,d)),d.duration&&(d.duration=it(d.duration)),d.repeatDelay&&(d.repeatDelay=it(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let u=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(d.duration=0,d.delay===0&&(u=!0)),(ft.instantAnimations||ft.skipAnimations)&&(u=!0,d.duration=0,d.delay=0),d.allowFlatten=!a.type&&!a.ease,u&&!o&&e.get()!==void 0){const m=Ip(d.keyframes,a);if(m!==void 0){ue.update(()=>{d.onUpdate(m),d.onComplete()});return}}return a.isSync?new Ps(d):new gf(d)};function Np({protectedKeys:t,needsAnimating:e},n){const i=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,i}function bc(t,e,{delay:n=0,transitionOverride:i,type:s}={}){let{transition:o=t.getDefaultTransition(),transitionEnd:r,...a}=e;i&&(o=i);const c=[],l=s&&t.animationState&&t.animationState.getState()[s];for(const d in a){const u=t.getValue(d,t.latestValues[d]??null),m=a[d];if(m===void 0||l&&Np(l,d))continue;const g={delay:n,...js(o||{},d)},y=u.get();if(y!==void 0&&!u.isAnimating&&!Array.isArray(m)&&m===y&&!g.velocity)continue;let w=!1;if(window.MotionHandoffAnimation){const v=yc(t);if(v){const S=window.MotionHandoffAnimation(v,d,ue);S!==null&&(g.startTime=S,w=!0)}}tr(t,d),u.start(nr(d,u,m,t.shouldReduceMotion&&Fa.has(d)?{type:!1}:g,t,w));const b=u.animation;b&&c.push(b)}return r&&Promise.all(c).then(()=>{ue.update(()=>{r&&Tp(t,r)})}),c}function ir(t,e,n={}){var c;const i=Mn(t,e,n.type==="exit"?(c=t.presenceContext)==null?void 0:c.custom:void 0);let{transition:s=t.getDefaultTransition()||{}}=i||{};n.transitionOverride&&(s=n.transitionOverride);const o=i?()=>Promise.all(bc(t,i,n)):()=>Promise.resolve(),r=t.variantChildren&&t.variantChildren.size?(l=0)=>{const{delayChildren:d=0,staggerChildren:u,staggerDirection:m}=s;return Vp(t,e,l,d,u,m,n)}:()=>Promise.resolve(),{when:a}=s;if(a){const[l,d]=a==="beforeChildren"?[o,r]:[r,o];return l().then(()=>d())}else return Promise.all([o(),r(n.delay)])}function Vp(t,e,n=0,i=0,s=0,o=1,r){const a=[],c=t.variantChildren.size,l=(c-1)*s,d=typeof i=="function",u=d?m=>i(m,c):o===1?(m=0)=>m*s:(m=0)=>l-m*s;return Array.from(t.variantChildren).sort(Fp).forEach((m,g)=>{m.notify("AnimationStart",e),a.push(ir(m,e,{...r,delay:n+(d?0:i)+u(g)}).then(()=>m.notify("AnimationComplete",e)))}),Promise.all(a)}function Fp(t,e){return t.sortNodePosition(e)}function Bp(t,e,n={}){t.notify("AnimationStart",e);let i;if(Array.isArray(e)){const s=e.map(o=>ir(t,o,n));i=Promise.all(s)}else if(typeof e=="string")i=ir(t,e,n);else{const s=typeof e=="function"?Mn(t,e,n.custom):e;i=Promise.all(bc(t,s,n))}return i.then(()=>{t.notify("AnimationComplete",e)})}function wc(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let i=0;i<n;i++)if(e[i]!==t[i])return!1;return!0}const jp=qs.length;function xc(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?xc(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<jp;n++){const i=qs[n],s=t.props[i];(Pn(s)||s===!1)&&(e[i]=s)}return e}const $p=[...zs].reverse(),Up=zs.length;function Gp(t){return e=>Promise.all(e.map(({animation:n,options:i})=>Bp(t,n,i)))}function Hp(t){let e=Gp(t),n=Sc(),i=!0;const s=c=>(l,d)=>{var m;const u=Mn(t,d,c==="exit"?(m=t.presenceContext)==null?void 0:m.custom:void 0);if(u){const{transition:g,transitionEnd:y,...w}=u;l={...l,...w,...y}}return l};function o(c){e=c(t)}function r(c){const{props:l}=t,d=xc(t.parent)||{},u=[],m=new Set;let g={},y=1/0;for(let b=0;b<Up;b++){const v=$p[b],S=n[v],k=l[v]!==void 0?l[v]:d[v],I=Pn(k),D=v===c?S.isActive:null;D===!1&&(y=b);let O=k===d[v]&&k!==l[v]&&I;if(O&&i&&t.manuallyAnimateOnMount&&(O=!1),S.protectedKeys={...g},!S.isActive&&D===null||!k&&!S.prevProp||_i(k)||typeof k=="boolean")continue;const x=Wp(S.prevProp,k);let C=x||v===c&&S.isActive&&!O&&I||b>y&&I,f=!1;const p=Array.isArray(k)?k:[k];let h=p.reduce(s(v),{});D===!1&&(h={});const{prevResolvedValues:_={}}=S,T={..._,...h},P=R=>{C=!0,m.has(R)&&(f=!0,m.delete(R)),S.needsAnimating[R]=!0;const V=t.getValue(R);V&&(V.liveStyle=!1)};for(const R in T){const V=h[R],X=_[R];if(g.hasOwnProperty(R))continue;let B=!1;er(V)&&er(X)?B=!wc(V,X):B=V!==X,B?V!=null?P(R):m.add(R):V!==void 0&&m.has(R)?P(R):S.protectedKeys[R]=!0}S.prevProp=k,S.prevResolvedValues=h,S.isActive&&(g={...g,...h}),i&&t.blockInitialAnimation&&(C=!1),C&&(!(O&&x)||f)&&u.push(...p.map(R=>({animation:R,options:{type:v}})))}if(m.size){const b={};if(typeof l.initial!="boolean"){const v=Mn(t,Array.isArray(l.initial)?l.initial[0]:l.initial);v&&v.transition&&(b.transition=v.transition)}m.forEach(v=>{const S=t.getBaseTarget(v),k=t.getValue(v);k&&(k.liveStyle=!0),b[v]=S??null}),u.push({animation:b})}let w=!!u.length;return i&&(l.initial===!1||l.initial===l.animate)&&!t.manuallyAnimateOnMount&&(w=!1),i=!1,w?e(u):Promise.resolve()}function a(c,l){var u;if(n[c].isActive===l)return Promise.resolve();(u=t.variantChildren)==null||u.forEach(m=>{var g;return(g=m.animationState)==null?void 0:g.setActive(c,l)}),n[c].isActive=l;const d=r(c);for(const m in n)n[m].protectedKeys={};return d}return{animateChanges:r,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=Sc(),i=!0}}}function Wp(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!wc(e,t):!1}function Lt(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Sc(){return{animate:Lt(!0),whileInView:Lt(),whileHover:Lt(),whileTap:Lt(),whileDrag:Lt(),whileFocus:Lt(),exit:Lt()}}class wt{constructor(e){this.isMounted=!1,this.node=e}update(){}}class zp extends wt{constructor(e){super(e),e.animationState||(e.animationState=Hp(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();_i(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)==null||e.call(this)}}let qp=0;class Kp extends wt{constructor(){super(...arguments),this.id=qp++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:i}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===i)return;const s=this.node.animationState.setActive("exit",!e);n&&!e&&s.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const Xp={animation:{Feature:zp},exit:{Feature:Kp}};function Dn(t,e,n,i={passive:!0}){return t.addEventListener(e,n,i),()=>t.removeEventListener(e,n)}function Ln(t){return{point:{x:t.pageX,y:t.pageY}}}const Yp=t=>e=>Hs(e)&&t(e,Ln(e));function On(t,e,n,i){return Dn(t,e,Yp(n),i)}function kc({top:t,left:e,right:n,bottom:i}){return{x:{min:e,max:n},y:{min:t,max:i}}}function Zp({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function Jp(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),i=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:i.y,right:i.x}}const Cc=1e-4,Qp=1-Cc,em=1+Cc,Tc=.01,tm=0-Tc,nm=0+Tc;function Ie(t){return t.max-t.min}function im(t,e,n){return Math.abs(t-e)<=n}function Ec(t,e,n,i=.5){t.origin=i,t.originPoint=me(e.min,e.max,t.origin),t.scale=Ie(n)/Ie(e),t.translate=me(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Qp&&t.scale<=em||isNaN(t.scale))&&(t.scale=1),(t.translate>=tm&&t.translate<=nm||isNaN(t.translate))&&(t.translate=0)}function Nn(t,e,n,i){Ec(t.x,e.x,n.x,i?i.originX:void 0),Ec(t.y,e.y,n.y,i?i.originY:void 0)}function Ac(t,e,n){t.min=n.min+e.min,t.max=t.min+Ie(e)}function sm(t,e,n){Ac(t.x,e.x,n.x),Ac(t.y,e.y,n.y)}function Ic(t,e,n){t.min=e.min-n.min,t.max=t.min+Ie(e)}function Vn(t,e,n){Ic(t.x,e.x,n.x),Ic(t.y,e.y,n.y)}const Pc=()=>({translate:0,scale:1,origin:0,originPoint:0}),en=()=>({x:Pc(),y:Pc()}),Rc=()=>({min:0,max:0}),ve=()=>({x:Rc(),y:Rc()});function Ge(t){return[t("x"),t("y")]}function sr(t){return t===void 0||t===1}function rr({scale:t,scaleX:e,scaleY:n}){return!sr(t)||!sr(e)||!sr(n)}function Ot(t){return rr(t)||Mc(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Mc(t){return Dc(t.x)||Dc(t.y)}function Dc(t){return t&&t!=="0%"}function bi(t,e,n){const i=t-n,s=e*i;return n+s}function Lc(t,e,n,i,s){return s!==void 0&&(t=bi(t,s,i)),bi(t,n,i)+e}function or(t,e=0,n=1,i,s){t.min=Lc(t.min,e,n,i,s),t.max=Lc(t.max,e,n,i,s)}function Oc(t,{x:e,y:n}){or(t.x,e.translate,e.scale,e.originPoint),or(t.y,n.translate,n.scale,n.originPoint)}const Nc=.999999999999,Vc=1.0000000000001;function rm(t,e,n,i=!1){const s=n.length;if(!s)return;e.x=e.y=1;let o,r;for(let a=0;a<s;a++){o=n[a],r=o.projectionDelta;const{visualElement:c}=o.options;c&&c.props.style&&c.props.style.display==="contents"||(i&&o.options.layoutScroll&&o.scroll&&o!==o.root&&nn(t,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),r&&(e.x*=r.x.scale,e.y*=r.y.scale,Oc(t,r)),i&&Ot(o.latestValues)&&nn(t,o.latestValues))}e.x<Vc&&e.x>Nc&&(e.x=1),e.y<Vc&&e.y>Nc&&(e.y=1)}function tn(t,e){t.min=t.min+e,t.max=t.max+e}function Fc(t,e,n,i,s=.5){const o=me(t.min,t.max,s);or(t,e,n,o,i)}function nn(t,e){Fc(t.x,e.x,e.scaleX,e.scale,e.originX),Fc(t.y,e.y,e.scaleY,e.scale,e.originY)}function Bc(t,e){return kc(Jp(t.getBoundingClientRect(),e))}function om(t,e,n){const i=Bc(t,n),{scroll:s}=e;return s&&(tn(i.x,s.offset.x),tn(i.y,s.offset.y)),i}const jc=({current:t})=>t?t.ownerDocument.defaultView:null,$c=(t,e)=>Math.abs(t-e);function am(t,e){const n=$c(t.x,e.x),i=$c(t.y,e.y);return Math.sqrt(n**2+i**2)}class Uc{constructor(e,n,{transformPagePoint:i,contextWindow:s=window,dragSnapToOrigin:o=!1,distanceThreshold:r=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const m=cr(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,y=am(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!y)return;const{point:w}=m,{timestamp:b}=Se;this.history.push({...w,timestamp:b});const{onStart:v,onMove:S}=this.handlers;g||(v&&v(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,m)},this.handlePointerMove=(m,g)=>{this.lastMoveEvent=m,this.lastMoveEventInfo=ar(g,this.transformPagePoint),ue.update(this.updatePoint,!0)},this.handlePointerUp=(m,g)=>{this.end();const{onEnd:y,onSessionEnd:w,resumeAnimation:b}=this.handlers;if(this.dragSnapToOrigin&&b&&b(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const v=cr(m.type==="pointercancel"?this.lastMoveEventInfo:ar(g,this.transformPagePoint),this.history);this.startEvent&&y&&y(m,v),w&&w(m,v)},!Hs(e))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=i,this.distanceThreshold=r,this.contextWindow=s||window;const a=Ln(e),c=ar(a,this.transformPagePoint),{point:l}=c,{timestamp:d}=Se;this.history=[{...l,timestamp:d}];const{onSessionStart:u}=n;u&&u(e,cr(c,this.history)),this.removeListeners=bn(On(this.contextWindow,"pointermove",this.handlePointerMove),On(this.contextWindow,"pointerup",this.handlePointerUp),On(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),vt(this.updatePoint)}}function ar(t,e){return e?{point:e(t.point)}:t}function Gc(t,e){return{x:t.x-e.x,y:t.y-e.y}}function cr({point:t},e){return{point:t,delta:Gc(t,Hc(e)),offset:Gc(t,cm(e)),velocity:lm(e,.1)}}function cm(t){return t[0]}function Hc(t){return t[t.length-1]}function lm(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,i=null;const s=Hc(t);for(;n>=0&&(i=t[n],!(s.timestamp-i.timestamp>it(e)));)n--;if(!i)return{x:0,y:0};const o=st(s.timestamp-i.timestamp);if(o===0)return{x:0,y:0};const r={x:(s.x-i.x)/o,y:(s.y-i.y)/o};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function um(t,{min:e,max:n},i){return e!==void 0&&t<e?t=i?me(e,t,i.min):Math.max(t,e):n!==void 0&&t>n&&(t=i?me(n,t,i.max):Math.min(t,n)),t}function Wc(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function dm(t,{top:e,left:n,bottom:i,right:s}){return{x:Wc(t.x,n,s),y:Wc(t.y,e,i)}}function zc(t,e){let n=e.min-t.min,i=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,i]=[i,n]),{min:n,max:i}}function hm(t,e){return{x:zc(t.x,e.x),y:zc(t.y,e.y)}}function fm(t,e){let n=.5;const i=Ie(t),s=Ie(e);return s>i?n=wn(e.min,e.max-i,t.min):i>s&&(n=wn(t.min,t.max-s,e.min)),ht(0,1,n)}function pm(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const lr=.35;function mm(t=lr){return t===!1?t=0:t===!0&&(t=lr),{x:qc(t,"left","right"),y:qc(t,"top","bottom")}}function qc(t,e,n){return{min:Kc(t,e),max:Kc(t,n)}}function Kc(t,e){return typeof t=="number"?t:t[e]||0}const gm=new WeakMap;class _m{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=ve(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:i}={}){const{presenceContext:s}=this.visualElement;if(s&&s.isPresent===!1)return;const o=u=>{const{dragSnapToOrigin:m}=this.getProps();m?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Ln(u).point)},r=(u,m)=>{const{drag:g,dragPropagation:y,onDragStart:w}=this.getProps();if(g&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Rf(g),!this.openDragLock))return;this.latestPointerEvent=u,this.latestPanInfo=m,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Ge(v=>{let S=this.getAxisMotionValue(v).get()||0;if(rt.test(S)){const{projection:k}=this.visualElement;if(k&&k.layout){const I=k.layout.layoutBox[v];I&&(S=Ie(I)*(parseFloat(S)/100))}}this.originPoint[v]=S}),w&&ue.postRender(()=>w(u,m)),tr(this.visualElement,"transform");const{animationState:b}=this.visualElement;b&&b.setActive("whileDrag",!0)},a=(u,m)=>{this.latestPointerEvent=u,this.latestPanInfo=m;const{dragPropagation:g,dragDirectionLock:y,onDirectionLock:w,onDrag:b}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:v}=m;if(y&&this.currentDirection===null){this.currentDirection=vm(v),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",m.point,v),this.updateAxis("y",m.point,v),this.visualElement.render(),b&&b(u,m)},c=(u,m)=>{this.latestPointerEvent=u,this.latestPanInfo=m,this.stop(u,m),this.latestPointerEvent=null,this.latestPanInfo=null},l=()=>Ge(u=>{var m;return this.getAnimationState(u)==="paused"&&((m=this.getAxisMotionValue(u).animation)==null?void 0:m.play())}),{dragSnapToOrigin:d}=this.getProps();this.panSession=new Uc(e,{onSessionStart:o,onStart:r,onMove:a,onSessionEnd:c,resumeAnimation:l},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:i,contextWindow:jc(this.visualElement)})}stop(e,n){const i=e||this.latestPointerEvent,s=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!s||!i)return;const{velocity:r}=s;this.startAnimation(r);const{onDragEnd:a}=this.getProps();a&&ue.postRender(()=>a(i,s))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(e,n,i){const{drag:s}=this.getProps();if(!i||!wi(e,s,this.currentDirection))return;const o=this.getAxisMotionValue(e);let r=this.originPoint[e]+i[e];this.constraints&&this.constraints[e]&&(r=um(r,this.constraints[e],this.elastic[e])),o.set(r)}resolveConstraints(){var o;const{dragConstraints:e,dragElastic:n}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(o=this.visualElement.projection)==null?void 0:o.layout,s=this.constraints;e&&Qt(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&i?this.constraints=dm(i.layoutBox,e):this.constraints=!1,this.elastic=mm(n),s!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&Ge(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=pm(i.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Qt(e))return!1;const i=e.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;const o=om(i,s.root,this.visualElement.getTransformPagePoint());let r=hm(s.layout.layoutBox,o);if(n){const a=n(Zp(r));this.hasMutatedConstraints=!!a,a&&(r=kc(a))}return r}startAnimation(e){const{drag:n,dragMomentum:i,dragElastic:s,dragTransition:o,dragSnapToOrigin:r,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},l=Ge(d=>{if(!wi(d,n,this.currentDirection))return;let u=c&&c[d]||{};r&&(u={min:0,max:0});const m=s?200:1e6,g=s?40:1e7,y={type:"inertia",velocity:i?e[d]:0,bounceStiffness:m,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...o,...u};return this.startAxisValueAnimation(d,y)});return Promise.all(l).then(a)}startAxisValueAnimation(e,n){const i=this.getAxisMotionValue(e);return tr(this.visualElement,e),i.start(nr(e,i,0,n,this.visualElement,!1))}stopAnimation(){Ge(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){Ge(e=>{var n;return(n=this.getAxisMotionValue(e).animation)==null?void 0:n.pause()})}getAnimationState(e){var n;return(n=this.getAxisMotionValue(e).animation)==null?void 0:n.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,i=this.visualElement.getProps(),s=i[n];return s||this.visualElement.getValue(e,(i.initial?i.initial[e]:void 0)||0)}snapToCursor(e){Ge(n=>{const{drag:i}=this.getProps();if(!wi(n,i,this.currentDirection))return;const{projection:s}=this.visualElement,o=this.getAxisMotionValue(n);if(s&&s.layout){const{min:r,max:a}=s.layout.layoutBox[n];o.set(e[n]-me(r,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:i}=this.visualElement;if(!Qt(n)||!i||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};Ge(r=>{const a=this.getAxisMotionValue(r);if(a&&this.constraints!==!1){const c=a.get();s[r]=fm({min:c,max:c},this.constraints[r])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.resolveConstraints(),Ge(r=>{if(!wi(r,e,null))return;const a=this.getAxisMotionValue(r),{min:c,max:l}=this.constraints[r];a.set(me(c,l,s[r]))})}addListeners(){if(!this.visualElement.current)return;gm.set(this.visualElement,this);const e=this.visualElement.current,n=On(e,"pointerdown",c=>{const{drag:l,dragListener:d=!0}=this.getProps();l&&d&&this.start(c)}),i=()=>{const{dragConstraints:c}=this.getProps();Qt(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:s}=this.visualElement,o=s.addEventListener("measure",i);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),ue.read(i);const r=Dn(window,"resize",()=>this.scalePositionWithinConstraints()),a=s.addEventListener("didUpdate",({delta:c,hasLayoutChanged:l})=>{this.isDragging&&l&&(Ge(d=>{const u=this.getAxisMotionValue(d);u&&(this.originPoint[d]+=c[d].translate,u.set(u.get()+c[d].translate))}),this.visualElement.render())});return()=>{r(),n(),o(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:i=!1,dragPropagation:s=!1,dragConstraints:o=!1,dragElastic:r=lr,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:i,dragPropagation:s,dragConstraints:o,dragElastic:r,dragMomentum:a}}}function wi(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function vm(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class ym extends wt{constructor(e){super(e),this.removeGroupControls=Ue,this.removeListeners=Ue,this.controls=new _m(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ue}unmount(){this.removeGroupControls(),this.removeListeners()}}const Xc=t=>(e,n)=>{t&&ue.postRender(()=>t(e,n))};class bm extends wt{constructor(){super(...arguments),this.removePointerDownListener=Ue}onPointerDown(e){this.session=new Uc(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:jc(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:i,onPanEnd:s}=this.node.getProps();return{onSessionStart:Xc(e),onStart:Xc(n),onMove:i,onEnd:(o,r)=>{delete this.session,s&&ue.postRender(()=>s(o,r))}}}mount(){this.removePointerDownListener=On(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const xi={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Yc(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Fn={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(G.test(t))t=parseFloat(t);else return t;const n=Yc(t,e.target.x),i=Yc(t,e.target.y);return`${n}% ${i}%`}},wm={correct:(t,{treeScale:e,projectionDelta:n})=>{const i=t,s=bt.parse(t);if(s.length>5)return i;const o=bt.createTransformer(t),r=typeof s[0]!="number"?1:0,a=n.x.scale*e.x,c=n.y.scale*e.y;s[0+r]/=a,s[1+r]/=c;const l=me(a,c,.5);return typeof s[2+r]=="number"&&(s[2+r]/=l),typeof s[3+r]=="number"&&(s[3+r]/=l),o(s)}};let Zc=!1;class xm extends Ke{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:i,layoutId:s}=this.props,{projection:o}=e;op(Sm),o&&(n.group&&n.group.add(o),i&&i.register&&s&&i.register(o),Zc&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),xi.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:i,drag:s,isPresent:o}=this.props,{projection:r}=i;return r&&(r.isPresent=o,Zc=!0,s||e.layoutDependency!==n||n===void 0||e.isPresent!==o?r.willUpdate():this.safeToRemove(),e.isPresent!==o&&(o?r.promote():r.relegate()||ue.postRender(()=>{const a=r.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),Gs.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:i}=this.props,{projection:s}=e;s&&(s.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(s),i&&i.deregister&&i.deregister(s))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function Jc(t){const[e,n]=ec(),i=we(ss);return E(xm,{...t,layoutGroup:i,switchLayoutGroup:we(lc),isPresent:e,safeToRemove:n})}const Sm={borderRadius:{...Fn,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Fn,borderTopRightRadius:Fn,borderBottomLeftRadius:Fn,borderBottomRightRadius:Fn,boxShadow:wm};function km(t,e,n){const i=Te(t)?t:Zt(t);return i.start(nr("",i,e,n)),i.animation}const Cm=(t,e)=>t.depth-e.depth;class Tm{constructor(){this.children=[],this.isDirty=!1}add(e){os(this.children,e),this.isDirty=!0}remove(e){as(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Cm),this.isDirty=!1,this.children.forEach(e)}}function Em(t,e){const n=Le.now(),i=({timestamp:s})=>{const o=s-n;o>=e&&(vt(i),t(o-e))};return ue.setup(i,!0),()=>vt(i)}const Qc=["TopLeft","TopRight","BottomLeft","BottomRight"],Am=Qc.length,el=t=>typeof t=="string"?parseFloat(t):t,tl=t=>typeof t=="number"||G.test(t);function Im(t,e,n,i,s,o){s?(t.opacity=me(0,n.opacity??1,Pm(i)),t.opacityExit=me(e.opacity??1,0,Rm(i))):o&&(t.opacity=me(e.opacity??1,n.opacity??1,i));for(let r=0;r<Am;r++){const a=`border${Qc[r]}Radius`;let c=nl(e,a),l=nl(n,a);if(c===void 0&&l===void 0)continue;c||(c=0),l||(l=0),c===0||l===0||tl(c)===tl(l)?(t[a]=Math.max(me(el(c),el(l),i),0),(rt.test(l)||rt.test(c))&&(t[a]+="%")):t[a]=l}(e.rotate||n.rotate)&&(t.rotate=me(e.rotate||0,n.rotate||0,i))}function nl(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Pm=il(0,.5,ta),Rm=il(.5,.95,Ue);function il(t,e,n){return i=>i<t?0:i>e?1:n(wn(t,e,i))}function sl(t,e){t.min=e.min,t.max=e.max}function He(t,e){sl(t.x,e.x),sl(t.y,e.y)}function rl(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function ol(t,e,n,i,s){return t-=e,t=bi(t,1/n,i),s!==void 0&&(t=bi(t,1/s,i)),t}function Mm(t,e=0,n=1,i=.5,s,o=t,r=t){if(rt.test(e)&&(e=parseFloat(e),e=me(r.min,r.max,e/100)-r.min),typeof e!="number")return;let a=me(o.min,o.max,i);t===o&&(a-=e),t.min=ol(t.min,e,n,a,s),t.max=ol(t.max,e,n,a,s)}function al(t,e,[n,i,s],o,r){Mm(t,e[n],e[i],e[s],e.scale,o,r)}const Dm=["x","scaleX","originX"],Lm=["y","scaleY","originY"];function cl(t,e,n,i){al(t.x,e,Dm,n?n.x:void 0,i?i.x:void 0),al(t.y,e,Lm,n?n.y:void 0,i?i.y:void 0)}function ll(t){return t.translate===0&&t.scale===1}function ul(t){return ll(t.x)&&ll(t.y)}function dl(t,e){return t.min===e.min&&t.max===e.max}function Om(t,e){return dl(t.x,e.x)&&dl(t.y,e.y)}function hl(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function fl(t,e){return hl(t.x,e.x)&&hl(t.y,e.y)}function pl(t){return Ie(t.x)/Ie(t.y)}function ml(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class Nm{constructor(){this.members=[]}add(e){os(this.members,e),e.scheduleRender()}remove(e){if(as(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(s=>e===s);if(n===0)return!1;let i;for(let s=n;s>=0;s--){const o=this.members[s];if(o.isPresent!==!1){i=o;break}}return i?(this.promote(i),!0):!1}promote(e,n){const i=this.lead;if(e!==i&&(this.prevLead=i,this.lead=e,e.show(),i)){i.instance&&i.scheduleRender(),e.scheduleRender(),e.resumeFrom=i,n&&(e.resumeFrom.preserveOpacity=!0),i.snapshot&&(e.snapshot=i.snapshot,e.snapshot.latestValues=i.animationValues||i.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:s}=e.options;s===!1&&i.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:i}=e;n.onExitComplete&&n.onExitComplete(),i&&i.options.onExitComplete&&i.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function Vm(t,e,n){let i="";const s=t.x.translate/e.x,o=t.y.translate/e.y,r=(n==null?void 0:n.z)||0;if((s||o||r)&&(i=`translate3d(${s}px, ${o}px, ${r}px) `),(e.x!==1||e.y!==1)&&(i+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:l,rotate:d,rotateX:u,rotateY:m,skewX:g,skewY:y}=n;l&&(i=`perspective(${l}px) ${i}`),d&&(i+=`rotate(${d}deg) `),u&&(i+=`rotateX(${u}deg) `),m&&(i+=`rotateY(${m}deg) `),g&&(i+=`skewX(${g}deg) `),y&&(i+=`skewY(${y}deg) `)}const a=t.x.scale*e.x,c=t.y.scale*e.y;return(a!==1||c!==1)&&(i+=`scale(${a}, ${c})`),i||"none"}const ur=["","X","Y","Z"],Fm=1e3;let Bm=0;function dr(t,e,n,i){const{latestValues:s}=e;s[t]&&(n[t]=s[t],e.setStaticValue(t,0),i&&(i[t]=0))}function gl(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=yc(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:s,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",ue,!(s||o))}const{parent:i}=t;i&&!i.hasCheckedOptimisedAppear&&gl(i)}function _l({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:i,resetTransform:s}){return class{constructor(r={},a=e==null?void 0:e()){this.id=Bm++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(Um),this.nodes.forEach(zm),this.nodes.forEach(qm),this.nodes.forEach(Gm)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=r,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new Tm)}addEventListener(r,a){return this.eventHandlers.has(r)||this.eventHandlers.set(r,new us),this.eventHandlers.get(r).add(a)}notifyListeners(r,...a){const c=this.eventHandlers.get(r);c&&c.notify(...a)}hasListeners(r){return this.eventHandlers.has(r)}mount(r){if(this.instance)return;this.isSVG=Qa(r)&&!Vf(r),this.instance=r;const{layoutId:a,layout:c,visualElement:l}=this.options;if(l&&!l.current&&l.mount(r),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||a)&&(this.isLayoutDirty=!0),t){let d,u=0;const m=()=>this.root.updateBlockedByResize=!1;ue.read(()=>{u=window.innerWidth}),t(r,()=>{const g=window.innerWidth;g!==u&&(u=g,this.root.updateBlockedByResize=!0,d&&d(),d=Em(m,250),xi.hasAnimatedSinceResize&&(xi.hasAnimatedSinceResize=!1,this.nodes.forEach(bl)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&l&&(a||c)&&this.addEventListener("didUpdate",({delta:d,hasLayoutChanged:u,hasRelativeLayoutChanged:m,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||l.getDefaultTransition()||Jm,{onLayoutAnimationStart:w,onLayoutAnimationComplete:b}=l.getProps(),v=!this.targetLayout||!fl(this.targetLayout,g),S=!u&&m;if(this.options.layoutRoot||this.resumeFrom||S||u&&(v||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const k={...js(y,"layout"),onPlay:w,onComplete:b};(l.shouldReduceMotion||this.options.layoutRoot)&&(k.delay=0,k.type=!1),this.startAnimation(k),this.setAnimationOrigin(d,S)}else u||bl(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const r=this.getStack();r&&r.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),vt(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Km),this.animationId++)}getTransformTemplate(){const{visualElement:r}=this.options;return r&&r.getProps().transformTemplate}willUpdate(r=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&gl(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let d=0;d<this.path.length;d++){const u=this.path[d];u.shouldResetTransform=!0,u.updateScroll("snapshot"),u.options.layoutRoot&&u.willUpdate(!1)}const{layoutId:a,layout:c}=this.options;if(a===void 0&&!c)return;const l=this.getTransformTemplate();this.prevTransformTemplateValue=l?l(this.latestValues,""):void 0,this.updateSnapshot(),r&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(vl);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(yl);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Wm),this.nodes.forEach(jm),this.nodes.forEach($m)):this.nodes.forEach(yl),this.clearAllSnapshots();const a=Le.now();Se.delta=ht(0,1e3/60,a-Se.timestamp),Se.timestamp=a,Se.isProcessing=!0,fs.update.process(Se),fs.preRender.process(Se),fs.render.process(Se),Se.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Gs.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Hm),this.sharedNodes.forEach(Xm)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ue.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ue.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Ie(this.snapshot.measuredBox.x)&&!Ie(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const r=this.layout;this.layout=this.measure(!1),this.layoutCorrected=ve(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,r?r.layoutBox:void 0)}updateScroll(r="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===r&&(a=!1),a&&this.instance){const c=i(this.instance);this.scroll={animationId:this.root.animationId,phase:r,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!s)return;const r=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!ul(this.projectionDelta),c=this.getTransformTemplate(),l=c?c(this.latestValues,""):void 0,d=l!==this.prevTransformTemplateValue;r&&this.instance&&(a||Ot(this.latestValues)||d)&&(s(this.instance,l),this.shouldResetTransform=!1,this.scheduleRender())}measure(r=!0){const a=this.measurePageBox();let c=this.removeElementScroll(a);return r&&(c=this.removeTransform(c)),Qm(c),{animationId:this.root.animationId,measuredBox:a,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){var l;const{visualElement:r}=this.options;if(!r)return ve();const a=r.measureViewportBox();if(!(((l=this.scroll)==null?void 0:l.wasRoot)||this.path.some(eg))){const{scroll:d}=this.root;d&&(tn(a.x,d.offset.x),tn(a.y,d.offset.y))}return a}removeElementScroll(r){var c;const a=ve();if(He(a,r),(c=this.scroll)!=null&&c.wasRoot)return a;for(let l=0;l<this.path.length;l++){const d=this.path[l],{scroll:u,options:m}=d;d!==this.root&&u&&m.layoutScroll&&(u.wasRoot&&He(a,r),tn(a.x,u.offset.x),tn(a.y,u.offset.y))}return a}applyTransform(r,a=!1){const c=ve();He(c,r);for(let l=0;l<this.path.length;l++){const d=this.path[l];!a&&d.options.layoutScroll&&d.scroll&&d!==d.root&&nn(c,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),Ot(d.latestValues)&&nn(c,d.latestValues)}return Ot(this.latestValues)&&nn(c,this.latestValues),c}removeTransform(r){const a=ve();He(a,r);for(let c=0;c<this.path.length;c++){const l=this.path[c];if(!l.instance||!Ot(l.latestValues))continue;rr(l.latestValues)&&l.updateSnapshot();const d=ve(),u=l.measurePageBox();He(d,u),cl(a,l.latestValues,l.snapshot?l.snapshot.layoutBox:void 0,d)}return Ot(this.latestValues)&&cl(a,this.latestValues),a}setTargetDelta(r){this.targetDelta=r,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(r){this.options={...this.options,...r,crossfade:r.crossfade!==void 0?r.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Se.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(r=!1){var m;const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==a;if(!(r||c&&this.isSharedProjectionDirty||this.isProjectionDirty||(m=this.parent)!=null&&m.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:d,layoutId:u}=this.options;if(!(!this.layout||!(d||u))){if(this.resolvedRelativeTargetAt=Se.timestamp,!this.targetDelta&&!this.relativeTarget){const g=this.getClosestProjectingParent();g&&g.layout&&this.animationProgress!==1?(this.relativeParent=g,this.forceRelativeParentToResolveTarget(),this.relativeTarget=ve(),this.relativeTargetOrigin=ve(),Vn(this.relativeTargetOrigin,this.layout.layoutBox,g.layout.layoutBox),He(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=ve(),this.targetWithTransforms=ve()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),sm(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):He(this.target,this.layout.layoutBox),Oc(this.target,this.targetDelta)):He(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const g=this.getClosestProjectingParent();g&&!!g.resumingFrom==!!this.resumingFrom&&!g.options.layoutScroll&&g.target&&this.animationProgress!==1?(this.relativeParent=g,this.forceRelativeParentToResolveTarget(),this.relativeTarget=ve(),this.relativeTargetOrigin=ve(),Vn(this.relativeTargetOrigin,this.target,g.target),He(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||rr(this.parent.latestValues)||Mc(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var y;const r=this.getLead(),a=!!this.resumingFrom||this!==r;let c=!0;if((this.isProjectionDirty||(y=this.parent)!=null&&y.isProjectionDirty)&&(c=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===Se.timestamp&&(c=!1),c)return;const{layout:l,layoutId:d}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(l||d))return;He(this.layoutCorrected,this.layout.layoutBox);const u=this.treeScale.x,m=this.treeScale.y;rm(this.layoutCorrected,this.treeScale,this.path,a),r.layout&&!r.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(r.target=r.layout.layoutBox,r.targetWithTransforms=ve());const{target:g}=r;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(rl(this.prevProjectionDelta.x,this.projectionDelta.x),rl(this.prevProjectionDelta.y,this.projectionDelta.y)),Nn(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==u||this.treeScale.y!==m||!ml(this.projectionDelta.x,this.prevProjectionDelta.x)||!ml(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(r=!0){var a;if((a=this.options.visualElement)==null||a.scheduleRender(),r){const c=this.getStack();c&&c.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=en(),this.projectionDelta=en(),this.projectionDeltaWithTransform=en()}setAnimationOrigin(r,a=!1){const c=this.snapshot,l=c?c.latestValues:{},d={...this.latestValues},u=en();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const m=ve(),g=c?c.source:void 0,y=this.layout?this.layout.source:void 0,w=g!==y,b=this.getStack(),v=!b||b.members.length<=1,S=!!(w&&!v&&this.options.crossfade===!0&&!this.path.some(Zm));this.animationProgress=0;let k;this.mixTargetDelta=I=>{const D=I/1e3;wl(u.x,r.x,D),wl(u.y,r.y,D),this.setTargetDelta(u),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Vn(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Ym(this.relativeTarget,this.relativeTargetOrigin,m,D),k&&Om(this.relativeTarget,k)&&(this.isProjectionDirty=!1),k||(k=ve()),He(k,this.relativeTarget)),w&&(this.animationValues=d,Im(d,l,this.latestValues,D,S,v)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=D},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(r){var a,c,l;this.notifyListeners("animationStart"),(a=this.currentAnimation)==null||a.stop(),(l=(c=this.resumingFrom)==null?void 0:c.currentAnimation)==null||l.stop(),this.pendingAnimation&&(vt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ue.update(()=>{xi.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Zt(0)),this.currentAnimation=km(this.motionValue,[0,1e3],{...r,velocity:0,isSync:!0,onUpdate:d=>{this.mixTargetDelta(d),r.onUpdate&&r.onUpdate(d)},onStop:()=>{},onComplete:()=>{r.onComplete&&r.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const r=this.getStack();r&&r.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Fm),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const r=this.getLead();let{targetWithTransforms:a,target:c,layout:l,latestValues:d}=r;if(!(!a||!c||!l)){if(this!==r&&this.layout&&l&&Tl(this.options.animationType,this.layout.layoutBox,l.layoutBox)){c=this.target||ve();const u=Ie(this.layout.layoutBox.x);c.x.min=r.target.x.min,c.x.max=c.x.min+u;const m=Ie(this.layout.layoutBox.y);c.y.min=r.target.y.min,c.y.max=c.y.min+m}He(a,c),nn(a,d),Nn(this.projectionDeltaWithTransform,this.layoutCorrected,a,d)}}registerSharedNode(r,a){this.sharedNodes.has(r)||this.sharedNodes.set(r,new Nm),this.sharedNodes.get(r).add(a);const l=a.options.initialPromotionConfig;a.promote({transition:l?l.transition:void 0,preserveFollowOpacity:l&&l.shouldPreserveFollowOpacity?l.shouldPreserveFollowOpacity(a):void 0})}isLead(){const r=this.getStack();return r?r.lead===this:!0}getLead(){var a;const{layoutId:r}=this.options;return r?((a=this.getStack())==null?void 0:a.lead)||this:this}getPrevLead(){var a;const{layoutId:r}=this.options;return r?(a=this.getStack())==null?void 0:a.prevLead:void 0}getStack(){const{layoutId:r}=this.options;if(r)return this.root.sharedNodes.get(r)}promote({needsReset:r,transition:a,preserveFollowOpacity:c}={}){const l=this.getStack();l&&l.promote(this,c),r&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const r=this.getStack();return r?r.relegate(this):!1}resetSkewAndRotation(){const{visualElement:r}=this.options;if(!r)return;let a=!1;const{latestValues:c}=r;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(a=!0),!a)return;const l={};c.z&&dr("z",r,l,this.animationValues);for(let d=0;d<ur.length;d++)dr(`rotate${ur[d]}`,r,l,this.animationValues),dr(`skew${ur[d]}`,r,l,this.animationValues);r.render();for(const d in l)r.setStaticValue(d,l[d]),this.animationValues&&(this.animationValues[d]=l[d]);r.scheduleRender()}applyProjectionStyles(r,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){r.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,r.visibility="",r.opacity="",r.pointerEvents=yi(a==null?void 0:a.pointerEvents)||"",r.transform=c?c(this.latestValues,""):"none";return}const l=this.getLead();if(!this.projectionDelta||!this.layout||!l.target){this.options.layoutId&&(r.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,r.pointerEvents=yi(a==null?void 0:a.pointerEvents)||""),this.hasProjected&&!Ot(this.latestValues)&&(r.transform=c?c({},""):"none",this.hasProjected=!1);return}r.visibility="";const d=l.animationValues||l.latestValues;this.applyTransformsToTarget();let u=Vm(this.projectionDeltaWithTransform,this.treeScale,d);c&&(u=c(d,u)),r.transform=u;const{x:m,y:g}=this.projectionDelta;r.transformOrigin=`${m.origin*100}% ${g.origin*100}% 0`,l.animationValues?r.opacity=l===this?d.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:d.opacityExit:r.opacity=l===this?d.opacity!==void 0?d.opacity:"":d.opacityExit!==void 0?d.opacityExit:0;for(const y in Rn){if(d[y]===void 0)continue;const{correct:w,applyTo:b,isCSSVariable:v}=Rn[y],S=u==="none"?d[y]:w(d[y],l);if(b){const k=b.length;for(let I=0;I<k;I++)r[b[I]]=S}else v?this.options.visualElement.renderState.vars[y]=S:r[y]=S}this.options.layoutId&&(r.pointerEvents=l===this?yi(a==null?void 0:a.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(r=>{var a;return(a=r.currentAnimation)==null?void 0:a.stop()}),this.root.nodes.forEach(vl),this.root.sharedNodes.clear()}}}function jm(t){t.updateLayout()}function $m(t){var n;const e=((n=t.resumeFrom)==null?void 0:n.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:i,measuredBox:s}=t.layout,{animationType:o}=t.options,r=e.source!==t.layout.source;o==="size"?Ge(u=>{const m=r?e.measuredBox[u]:e.layoutBox[u],g=Ie(m);m.min=i[u].min,m.max=m.min+g}):Tl(o,e.layoutBox,i)&&Ge(u=>{const m=r?e.measuredBox[u]:e.layoutBox[u],g=Ie(i[u]);m.max=m.min+g,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[u].max=t.relativeTarget[u].min+g)});const a=en();Nn(a,i,e.layoutBox);const c=en();r?Nn(c,t.applyTransform(s,!0),e.measuredBox):Nn(c,i,e.layoutBox);const l=!ul(a);let d=!1;if(!t.resumeFrom){const u=t.getClosestProjectingParent();if(u&&!u.resumeFrom){const{snapshot:m,layout:g}=u;if(m&&g){const y=ve();Vn(y,e.layoutBox,m.layoutBox);const w=ve();Vn(w,i,g.layoutBox),fl(y,w)||(d=!0),u.options.layoutRoot&&(t.relativeTarget=w,t.relativeTargetOrigin=y,t.relativeParent=u)}}}t.notifyListeners("didUpdate",{layout:i,snapshot:e,delta:c,layoutDelta:a,hasLayoutChanged:l,hasRelativeLayoutChanged:d})}else if(t.isLead()){const{onExitComplete:i}=t.options;i&&i()}t.options.transition=void 0}function Um(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function Gm(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Hm(t){t.clearSnapshot()}function vl(t){t.clearMeasurements()}function yl(t){t.isLayoutDirty=!1}function Wm(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function bl(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function zm(t){t.resolveTargetDelta()}function qm(t){t.calcProjection()}function Km(t){t.resetSkewAndRotation()}function Xm(t){t.removeLeadSnapshot()}function wl(t,e,n){t.translate=me(e.translate,0,n),t.scale=me(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function xl(t,e,n,i){t.min=me(e.min,n.min,i),t.max=me(e.max,n.max,i)}function Ym(t,e,n,i){xl(t.x,e.x,n.x,i),xl(t.y,e.y,n.y,i)}function Zm(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Jm={duration:.45,ease:[.4,0,.1,1]},Sl=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),kl=Sl("applewebkit/")&&!Sl("chrome/")?Math.round:Ue;function Cl(t){t.min=kl(t.min),t.max=kl(t.max)}function Qm(t){Cl(t.x),Cl(t.y)}function Tl(t,e,n){return t==="position"||t==="preserve-aspect"&&!im(pl(e),pl(n),.2)}function eg(t){var e;return t!==t.root&&((e=t.scroll)==null?void 0:e.wasRoot)}const tg=_l({attachResizeListener:(t,e)=>Dn(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),hr={current:void 0},El=_l({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!hr.current){const t=new tg({});t.mount(window),t.setOptions({layoutScroll:!0}),hr.current=t}return hr.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),ng={pan:{Feature:bm},drag:{Feature:ym,ProjectionNode:El,MeasureLayout:Jc}};function Al(t,e,n){const{props:i}=t;t.animationState&&i.whileHover&&t.animationState.setActive("whileHover",n==="Start");const s="onHover"+n,o=i[s];o&&ue.postRender(()=>o(e,Ln(e)))}class ig extends wt{mount(){const{current:e}=this.node;e&&(this.unmount=Mf(e,(n,i)=>(Al(this.node,i,"Start"),s=>Al(this.node,s,"End"))))}unmount(){}}class sg extends wt{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=bn(Dn(this.node.current,"focus",()=>this.onFocus()),Dn(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Il(t,e,n){const{props:i}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&i.whileTap&&t.animationState.setActive("whileTap",n==="Start");const s="onTap"+(n==="End"?"":n),o=i[s];o&&ue.postRender(()=>o(e,Ln(e)))}class rg extends wt{mount(){const{current:e}=this.node;e&&(this.unmount=Nf(e,(n,i)=>(Il(this.node,i,"Start"),(s,{success:o})=>Il(this.node,s,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const fr=new WeakMap,pr=new WeakMap,og=t=>{const e=fr.get(t.target);e&&e(t)},ag=t=>{t.forEach(og)};function cg({root:t,...e}){const n=t||document;pr.has(n)||pr.set(n,{});const i=pr.get(n),s=JSON.stringify(e);return i[s]||(i[s]=new IntersectionObserver(ag,{root:t,...e})),i[s]}function lg(t,e,n){const i=cg(e);return fr.set(t,n),i.observe(t),()=>{fr.delete(t),i.unobserve(t)}}const ug={some:0,all:1};class dg extends wt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:i,amount:s="some",once:o}=e,r={root:n?n.current:void 0,rootMargin:i,threshold:typeof s=="number"?s:ug[s]},a=c=>{const{isIntersecting:l}=c;if(this.isInView===l||(this.isInView=l,o&&!l&&this.hasEnteredView))return;l&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",l);const{onViewportEnter:d,onViewportLeave:u}=this.node.getProps(),m=l?d:u;m&&m(c)};return lg(this.node.current,r,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(hg(e,n))&&this.startObserver()}unmount(){}}function hg({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const fg={inView:{Feature:dg},tap:{Feature:rg},focus:{Feature:sg},hover:{Feature:ig}},pg={layout:{ProjectionNode:El,MeasureLayout:Jc}},mr={current:null},Pl={current:!1};function mg(){if(Pl.current=!0,!!rs)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>mr.current=t.matches;t.addEventListener("change",e),e()}else mr.current=!1}const gg=new WeakMap;function _g(t,e,n){for(const i in e){const s=e[i],o=n[i];if(Te(s))t.addValue(i,s);else if(Te(o))t.addValue(i,Zt(s,{owner:t}));else if(o!==s)if(t.hasValue(i)){const r=t.getValue(i);r.liveStyle===!0?r.jump(s):r.hasAnimated||r.set(s)}else{const r=t.getStaticValue(i);t.addValue(i,Zt(r!==void 0?r:s,{owner:t}))}}for(const i in n)e[i]===void 0&&t.removeValue(i);return e}const Rl=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class vg{scrapeMotionValuesFromProps(e,n,i){return{}}constructor({parent:e,props:n,presenceContext:i,reducedMotionConfig:s,blockInitialAnimation:o,visualState:r},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Fs,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const m=Le.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,ue.render(this.render,!1,!0))};const{latestValues:c,renderState:l}=r;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=n,this.presenceContext=i,this.depth=e?e.depth+1:0,this.reducedMotionConfig=s,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=vi(n),this.isVariantNode=oc(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:d,...u}=this.scrapeMotionValuesFromProps(n,{},this);for(const m in u){const g=u[m];c[m]!==void 0&&Te(g)&&g.set(c[m],!1)}}mount(e){this.current=e,gg.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,i)=>this.bindToMotionValue(i,n)),Pl.current||mg(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:mr.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),vt(this.notifyUpdate),vt(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const i=Yt.has(e);i&&this.onBindTransform&&this.onBindTransform();const s=n.on("change",a=>{this.latestValues[e]=a,this.props.onUpdate&&ue.preRender(this.notifyUpdate),i&&this.projection&&(this.projection.isTransformDirty=!0)}),o=n.on("renderRequest",this.scheduleRender);let r;window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{s(),o(),r&&r(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in Jt){const n=Jt[e];if(!n)continue;const{isEnabled:i,Feature:s}=n;if(!this.features[e]&&s&&i(this.props)&&(this.features[e]=new s(this)),this.features[e]){const o=this.features[e];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):ve()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let i=0;i<Rl.length;i++){const s=Rl[i];this.propEventSubscriptions[s]&&(this.propEventSubscriptions[s](),delete this.propEventSubscriptions[s]);const o="on"+s,r=e[o];r&&(this.propEventSubscriptions[s]=this.on(s,r))}this.prevMotionValues=_g(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const i=this.values.get(e);n!==i&&(i&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let i=this.values.get(e);return i===void 0&&n!==void 0&&(i=Zt(n===null?void 0:n,{owner:this}),this.addValue(e,i)),i}readValue(e,n){let i=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return i!=null&&(typeof i=="string"&&(Wo(i)||qo(i))?i=parseFloat(i):!Bf(i)&&bt.test(n)&&(i=Ha(e,n)),this.setBaseTarget(e,Te(i)?i.get():i)),Te(i)?i.get():i}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){var o;const{initial:n}=this.props;let i;if(typeof n=="string"||typeof n=="object"){const r=Js(this.props,n,(o=this.presenceContext)==null?void 0:o.custom);r&&(i=r[e])}if(n&&i!==void 0)return i;const s=this.getBaseTargetFromProps(this.props,e);return s!==void 0&&!Te(s)?s:this.initialValues[e]!==void 0&&i===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new us),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}}class Ml extends vg{constructor(){super(...arguments),this.KeyframeResolver=Ef}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){return e.style?e.style[n]:void 0}removeValueFromRenderState(e,{vars:n,style:i}){delete n[e],delete i[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;Te(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Dl(t,{style:e,vars:n},i,s){const o=t.style;let r;for(r in e)o[r]=e[r];s==null||s.applyProjectionStyles(o,i);for(r in n)o.setProperty(r,n[r])}function yg(t){return window.getComputedStyle(t)}class bg extends Ml{constructor(){super(...arguments),this.type="html",this.renderInstance=Dl}readValueFromInstance(e,n){var i;if(Yt.has(n))return(i=this.projection)!=null&&i.isProjecting?Ds(n):zh(e,n);{const s=yg(e),o=(ps(n)?s.getPropertyValue(n):s[n])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Bc(e,n)}build(e,n,i){Xs(e,n,i.transformTemplate)}scrapeMotionValuesFromProps(e,n,i){return Qs(e,n,i)}}const Ll=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function wg(t,e,n,i){Dl(t,e,void 0,i);for(const s in e.attrs)t.setAttribute(Ll.has(s)?s:Ks(s),e.attrs[s])}class xg extends Ml{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=ve}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(Yt.has(n)){const i=Ga(n);return i&&i.default||0}return n=Ll.has(n)?n:Ks(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,i){return vc(e,n,i)}build(e,n,i){fc(e,n,this.isSVGTag,i.transformTemplate,i.style)}renderInstance(e,n,i,s){wg(e,n,i,s)}mount(e){this.isSVGTag=mc(e.tagName),super.mount(e)}}const Sg=(t,e)=>Zs(t)?new xg(e):new bg(e,{allowProjection:t!==et}),kg=Sp({...Xp,...fg,...ng,...pg},Sg),Bn=Xf(kg),Cg=["agent-id","environment","position","version-id","call-destination-number","call-caller-number","call-caller-name","call-custom-headers"],Si="widget-layout-id";function Ol(t){var e,n,i="";if(typeof t=="string"||typeof t=="number")i+=t;else if(typeof t=="object")if(Array.isArray(t)){var s=t.length;for(e=0;e<s;e++)t[e]&&(n=Ol(t[e]))&&(i&&(i+=" "),i+=n)}else for(n in t)t[n]&&(i&&(i+=" "),i+=n);return i}function xt(){for(var t,e,n=0,i="",s=arguments.length;n<s;n++)(t=arguments[n])&&(e=Ol(t))&&(i&&(i+=" "),i+=e);return i}const jn={},Nl=(t,e)=>t.unstable_is?t.unstable_is(e):e===t,Vl=t=>"init"in t,gr=t=>!!t.write,Fl=t=>"v"in t||"e"in t,ki=t=>{if("e"in t)throw t.e;if((jn?"production":void 0)!=="production"&&!("v"in t))throw new Error("[Bug] atom state is not initialized");return t.v},Ci=new WeakMap,Bl=t=>{var e;return Ti(t)&&!!((e=Ci.get(t))!=null&&e[0])},Tg=t=>{const e=Ci.get(t);e!=null&&e[0]&&(e[0]=!1,e[1].forEach(n=>n()))},jl=(t,e)=>{let n=Ci.get(t);if(!n){n=[!0,new Set],Ci.set(t,n);const i=()=>{n[0]=!1};t.then(i,i)}n[1].add(e)},Ti=t=>typeof(t==null?void 0:t.then)=="function",$l=(t,e,n)=>{n.p.has(t)||(n.p.add(t),e.then(()=>{n.p.delete(t)},()=>{n.p.delete(t)}))},_r=(t,e,n)=>{const i=n(t),s="v"in i,o=i.v;if(Ti(e))for(const r of i.d.keys())$l(t,e,n(r));i.v=e,delete i.e,(!s||!Object.is(o,i.v))&&(++i.n,Ti(o)&&Tg(o))},Ul=(t,e,n)=>{var i;const s=new Set;for(const o of((i=n.get(t))==null?void 0:i.t)||[])n.has(o)&&s.add(o);for(const o of e.p)s.add(o);return s},Eg=()=>{const t=new Set,e=()=>{t.forEach(n=>n())};return e.add=n=>(t.add(n),()=>{t.delete(n)}),e},vr=()=>{const t={},e=new WeakMap,n=i=>{var s,o;(s=e.get(t))==null||s.forEach(r=>r(i)),(o=e.get(i))==null||o.forEach(r=>r())};return n.add=(i,s)=>{const o=i||t,r=(e.has(o)?e:e.set(o,new Set)).get(o);return r.add(s),()=>{r==null||r.delete(s),r.size||e.delete(o)}},n},Ag=t=>(t.c||(t.c=vr()),t.m||(t.m=vr()),t.u||(t.u=vr()),t.f||(t.f=Eg()),t),Ig=Symbol(),Gl=(t=new WeakMap,e=new WeakMap,n=new WeakMap,i=new Set,s=new Set,o=new Set,r={},a=(m,...g)=>m.read(...g),c=(m,...g)=>m.write(...g),l=(m,g)=>{var y;return(y=m.unstable_onInit)==null?void 0:y.call(m,g)},d=(m,g)=>{var y;return(y=m.onMount)==null?void 0:y.call(m,g)},...u)=>{const m=u[0]||(x=>{if((jn?"production":void 0)!=="production"&&!x)throw new Error("Atom is undefined or null");let C=t.get(x);return C||(C={d:new Map,p:new Set,n:0},t.set(x,C),l==null||l(x,O)),C}),g=u[1]||(()=>{const x=[],C=f=>{try{f()}catch(p){x.push(p)}};do{r.f&&C(r.f);const f=new Set,p=f.add.bind(f);i.forEach(h=>{var _;return(_=e.get(h))==null?void 0:_.l.forEach(p)}),i.clear(),o.forEach(p),o.clear(),s.forEach(p),s.clear(),f.forEach(C),i.size&&y()}while(i.size||o.size||s.size);if(x.length)throw new AggregateError(x)}),y=u[2]||(()=>{const x=[],C=new WeakSet,f=new WeakSet,p=Array.from(i);for(;p.length;){const h=p[p.length-1],_=m(h);if(f.has(h)){p.pop();continue}if(C.has(h)){if(n.get(h)===_.n)x.push([h,_]);else if((jn?"production":void 0)!=="production"&&n.has(h))throw new Error("[Bug] invalidated atom exists");f.add(h),p.pop();continue}C.add(h);for(const T of Ul(h,_,e))C.has(T)||p.push(T)}for(let h=x.length-1;h>=0;--h){const[_,T]=x[h];let P=!1;for(const A of T.d.keys())if(A!==_&&i.has(A)){P=!0;break}P&&(w(_),S(_)),n.delete(_)}}),w=u[3]||(x=>{var C;const f=m(x);if(Fl(f)&&(e.has(x)&&n.get(x)!==f.n||Array.from(f.d).every(([R,V])=>w(R).n===V)))return f;f.d.clear();let p=!0;const h=()=>{e.has(x)&&(S(x),y(),g())},_=R=>{var V;if(Nl(x,R)){const B=m(R);if(!Fl(B))if(Vl(R))_r(R,R.init,m);else throw new Error("no atom init");return ki(B)}const X=w(R);try{return ki(X)}finally{f.d.set(R,X.n),Bl(f.v)&&$l(x,f.v,X),(V=e.get(R))==null||V.t.add(x),p||h()}};let T,P;const A={get signal(){return T||(T=new AbortController),T.signal},get setSelf(){return(jn?"production":void 0)!=="production"&&!gr(x)&&console.warn("setSelf function cannot be used with read-only atom"),!P&&gr(x)&&(P=(...R)=>{if((jn?"production":void 0)!=="production"&&p&&console.warn("setSelf function cannot be called in sync"),!p)try{return v(x,...R)}finally{y(),g()}}),P}},M=f.n;try{const R=a(x,_,A);return _r(x,R,m),Ti(R)&&(jl(R,()=>T==null?void 0:T.abort()),R.then(h,h)),f}catch(R){return delete f.v,f.e=R,++f.n,f}finally{p=!1,M!==f.n&&n.get(x)===M&&(n.set(x,f.n),i.add(x),(C=r.c)==null||C.call(r,x))}}),b=u[4]||(x=>{const C=[x];for(;C.length;){const f=C.pop(),p=m(f);for(const h of Ul(f,p,e)){const _=m(h);n.set(h,_.n),C.push(h)}}}),v=u[5]||((x,...C)=>{let f=!0;const p=_=>ki(w(_)),h=(_,...T)=>{var P;const A=m(_);try{if(Nl(x,_)){if(!Vl(_))throw new Error("atom not writable");const M=A.n,R=T[0];_r(_,R,m),S(_),M!==A.n&&(i.add(_),(P=r.c)==null||P.call(r,_),b(_));return}else return v(_,...T)}finally{f||(y(),g())}};try{return c(x,p,h,...C)}finally{f=!1}}),S=u[6]||(x=>{var C;const f=m(x),p=e.get(x);if(p&&!Bl(f.v)){for(const[h,_]of f.d)if(!p.d.has(h)){const T=m(h);k(h).t.add(x),p.d.add(h),_!==T.n&&(i.add(h),(C=r.c)==null||C.call(r,h),b(h))}for(const h of p.d||[])if(!f.d.has(h)){p.d.delete(h);const _=I(h);_==null||_.t.delete(x)}}}),k=u[7]||(x=>{var C;const f=m(x);let p=e.get(x);if(!p){w(x);for(const h of f.d.keys())k(h).t.add(x);if(p={l:new Set,d:new Set(f.d.keys()),t:new Set},e.set(x,p),(C=r.m)==null||C.call(r,x),gr(x)){const h=()=>{let _=!0;const T=(...P)=>{try{return v(x,...P)}finally{_||(y(),g())}};try{const P=d(x,T);P&&(p.u=()=>{_=!0;try{P()}finally{_=!1}})}finally{_=!1}};s.add(h)}}return p}),I=u[8]||(x=>{var C;const f=m(x);let p=e.get(x);if(p&&!p.l.size&&!Array.from(p.t).some(h=>{var _;return(_=e.get(h))==null?void 0:_.d.has(x)})){p.u&&o.add(p.u),p=void 0,e.delete(x),(C=r.u)==null||C.call(r,x);for(const h of f.d.keys()){const _=I(h);_==null||_.t.delete(x)}return}return p}),D=[t,e,n,i,s,o,r,a,c,l,d,m,g,y,w,b,v,S,k,I],O={get:x=>ki(w(x)),set:(x,...C)=>{try{return v(x,...C)}finally{y(),g()}},sub:(x,C)=>{const p=k(x).l;return p.add(C),g(),()=>{p.delete(C),I(x),g()}}};return Object.defineProperty(O,Ig,{value:D}),O},Pg=Ag,Hl=jl,yr={};let Rg=0;function br(t,e){const n=`atom${++Rg}`,i={toString(){return(yr?"production":void 0)!=="production"&&this.debugLabel?n+":"+this.debugLabel:n}};return typeof t=="function"?i.read=t:(i.init=t,i.read=Mg,i.write=Dg),i}function Mg(t){return t(this)}function Dg(t,e,n){return e(this,typeof n=="function"?n(t(this)):n)}const Lg=()=>{let t=0;const e=Pg({}),n=new WeakMap,i=new WeakMap,s=Gl(n,i,void 0,void 0,void 0,void 0,e,void 0,(a,c,l,...d)=>t?l(a,...d):a.write(c,l,...d)),o=new Set;return e.m.add(void 0,a=>{o.add(a);const c=n.get(a);c.m=i.get(a)}),e.u.add(void 0,a=>{o.delete(a);const c=n.get(a);delete c.m}),Object.assign(s,{dev4_get_internal_weak_map:()=>(console.log("Deprecated: Use devstore from the devtools library"),n),dev4_get_mounted_atoms:()=>o,dev4_restore_atoms:a=>{const c={read:()=>null,write:(l,d)=>{++t;try{for(const[u,m]of a)"init"in u&&d(u,m)}finally{--t}}};s.set(c)}})};function Og(){return(yr?"production":void 0)!=="production"?Lg():Gl()}let $n;function Ng(){return $n||($n=Og(),(yr?"production":void 0)!=="production"&&(globalThis.__JOTAI_DEFAULT_STORE__||(globalThis.__JOTAI_DEFAULT_STORE__=$n),globalThis.__JOTAI_DEFAULT_STORE__!==$n&&console.warn("Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"))),$n}const Vg={},Fg=It(void 0);function Wl(t){return we(Fg)||Ng()}const wr=t=>typeof(t==null?void 0:t.then)=="function",xr=t=>{t.status||(t.status="pending",t.then(e=>{t.status="fulfilled",t.value=e},e=>{t.status="rejected",t.reason=e}))},Bg=Go.use||(t=>{if(t.status==="pending")throw t;if(t.status==="fulfilled")return t.value;throw t.status==="rejected"?t.reason:(xr(t),t)}),Sr=new WeakMap,zl=(t,e)=>{let n=Sr.get(t);return n||(n=new Promise((i,s)=>{let o=t;const r=l=>d=>{o===l&&i(d)},a=l=>d=>{o===l&&s(d)},c=()=>{try{const l=e();wr(l)?(Sr.set(l,n),o=l,l.then(r(l),a(l)),Hl(l,c)):i(l)}catch(l){s(l)}};t.then(r(t),a(t)),Hl(t,c)}),Sr.set(t,n)),n};function ql(t,e){const{delay:n,unstable_promiseStatus:i=!Go.use}={},s=Wl(),[[o,r,a],c]=So(d=>{const u=s.get(t);return Object.is(d[0],u)&&d[1]===s&&d[2]===t?d:[u,s,t]},void 0,()=>[s.get(t),s,t]);let l=o;if((r!==s||a!==t)&&(c(),l=s.get(t)),$e(()=>{const d=s.sub(t,()=>{if(i)try{const u=s.get(t);wr(u)&&xr(zl(u,()=>s.get(t)))}catch{}if(typeof n=="number"){setTimeout(c,n);return}c()});return c(),d},[s,t,n,i]),Ed(l),wr(l)){const d=zl(l,()=>s.get(t));return i&&xr(d),Bg(d)}return l}function Kl(t,e){const n=Wl();return ni((...s)=>{if((Vg?"production":void 0)!=="production"&&!("write"in t))throw new Error("not writable atom");return n.set(t,...s)},[n,t])}function Xl(t,e){return[ql(t),Kl(t)]}const jg=br("waiting"),Yl=()=>Xl(jg),Ei={theme:"dark",audio_visualizer_config:{color:"verdant",preset:"roundBars"},start_call_text:"Let's chat",default_state:"collapsed",position:"fixed",view_history_url:null,report_issue_url:null,give_feedback_url:null,agent_thinking_text:"Thinking...",speak_to_interrupt_text:"Speak to interrupt",logo_icon_url:null},Zl=br(Ei),$g=()=>{const t=Kl(Zl);return ni(e=>t(()=>{const n={...e};return n.start_call_text||(n.start_call_text=Ei.start_call_text),n.agent_thinking_text||(n.agent_thinking_text=Ei.agent_thinking_text),n.speak_to_interrupt_text||(n.speak_to_interrupt_text=Ei.speak_to_interrupt_text),n}),[t])},Nt=()=>ql(Zl),Jl=({size:t="large",className:e})=>{const n=Nt(),[i]=Yl();return E("h1",{className:xt({"text-xs":t==="small"},e),children:i==="waiting"?n.speak_to_interrupt_text:n.agent_thinking_text})},Ql=({stream:t})=>{const e=De(null);return $e(()=>{!e.current||!t||(e.current.srcObject=t)},[t]),E("audio",{muted:!0,ref:e,autoPlay:!0})};/**!
|
|
10
10
|
* audioMotion-analyzer
|
|
11
11
|
* High-resolution real-time graphic audio spectrum analyzer JS module
|
|
12
12
|
*
|
|
13
13
|
* @version 4.5.1
|
|
14
14
|
* @author Henrique Avila Vianna <hvianna@gmail.com> <https://henriquevianna.com>
|
|
15
15
|
* @license AGPL-3.0-or-later
|
|
16
|
-
*/const $g="4.5.1",Tr=Math.PI,sn=2*Tr,Er=Tr/2,eu=8.17579892,nu="dual-combined",Ri="dual-horizontal",me="single",oe="dual-vertical",iu="bar-index",su="bar-level",Ii="gradient",ru=60,ou="click",Ug="fullscreenchange",au="resize",Hg="#111",lu="",cu="A",uu="B",du="C",hu="D",fu="468",Pi="sans-serif",Gg="#0f0",Wg="#7f7f7f22",rn=10,pu="create",mu="fschange",zg="lores",qg=au,Ar="user",Kg="#000c",gu="#fff",Xg="#4f4",vu="#888",Yg="#555",Rr="bark",Un="linear",on="log",Ir="mel",_u=["#a35","#c66","#e94","#ed0","#9d5","#4d8","#2cb","#0bc","#09c","#36b"],yu=[["classic",{colorStops:["red",{color:"yellow",level:.85,pos:.6},{color:"lime",level:.475}]}],["prism",{colorStops:_u}],["rainbow",{dir:"h",colorStops:["#817",..._u,"#639"]}],["orangered",{bgColor:"#3e2f29",colorStops:["OrangeRed"]}],["steelblue",{bgColor:"#222c35",colorStops:["SteelBlue"]}]],Hn={alphaBars:!1,ansiBands:!1,barSpace:.1,bgAlpha:.7,channelLayout:me,colorMode:Ii,fadePeaks:!1,fftSize:8192,fillAlpha:1,frequencyScale:on,gradient:yu[0][0],gravity:3.8,height:void 0,ledBars:!1,linearAmplitude:!1,linearBoost:1,lineWidth:0,loRes:!1,lumiBars:!1,maxDecibels:-25,maxFPS:0,maxFreq:22e3,minDecibels:-85,minFreq:20,mirror:0,mode:0,noteLabels:!1,outlineBars:!1,overlay:!1,peakFadeTime:750,peakHoldTime:500,peakLine:!1,radial:!1,radialInvert:!1,radius:.3,reflexAlpha:.15,reflexBright:1,reflexFit:!0,reflexRatio:0,roundBars:!1,showBgColor:!0,showFPS:!1,showPeaks:!0,showScaleX:!0,showScaleY:!1,smoothing:.5,spinSpeed:0,splitGradient:!1,start:!0,trueLeds:!1,useCanvas:!0,volume:1,weightingFilter:lu,width:void 0},Zg=["ERR_AUDIO_CONTEXT_FAIL","Could not create audio context. Web Audio API not supported?"],Jg=["ERR_INVALID_AUDIO_CONTEXT","Provided audio context is not valid"],Qg=["ERR_UNKNOWN_GRADIENT","Unknown gradient"],Pr=["ERR_FREQUENCY_TOO_LOW","Frequency values must be >= 1"],tv=["ERR_INVALID_MODE","Invalid mode"],ev=["ERR_REFLEX_OUT_OF_RANGE","Reflex ratio must be >= 0 and < 1"],nv=["ERR_INVALID_AUDIO_SOURCE","Audio source must be an instance of HTMLMediaElement or AudioNode"],iv=["ERR_GRADIENT_INVALID_NAME","Gradient name must be a non-empty string"],sv=["ERR_GRADIENT_NOT_AN_OBJECT","Gradient options must be an object"],rv=["ERR_GRADIENT_MISSING_COLOR","Gradient colorStops must be a non-empty array"];class Wt extends Error{constructor(t,n){const[i,s]=t;super(s+(n!==void 0?`: ${n}`:"")),this.name="AudioMotionError",this.code=i}}const bu=(e,t)=>console.warn(`${e} is deprecated. Use ${t} instead.`),wu=e=>{for(const t in e)return!1;return!0},Mi=(e,t,n="toLowerCase")=>t[Math.max(0,t.indexOf((""+e)[n]()))],ov=(e,t,n,i,s)=>t+(i-t)*(s-e)/(n-e);Array.prototype.findLastIndex||(Array.prototype.findLastIndex=function(e){let t=this.length;for(;t-- >0;)if(e(this[t]))return t;return-1});class av{constructor(t,n={}){this._ready=!1,this._aux={},this._canvasGradients=[],this._destroyed=!1,this._energy={val:0,peak:0,hold:0},this._flg={},this._fps=0,this._gradients={},this._last=0,this._outNodes=[],this._ownContext=!1,this._selectedGrads=[],this._sources=[],t instanceof Element||(wu(n)&&!wu(t)&&(n=t),t=null),this._ownCanvas=!(n.canvas instanceof HTMLCanvasElement);const i=this._ownCanvas?document.createElement("canvas"):n.canvas;i.style="max-width: 100%;",this._ctx=i.getContext("2d");for(const[u,p]of yu)this.registerGradient(u,p);this._container=t||!this._ownCanvas&&i.parentElement||document.body,this._defaultWidth=this._container.clientWidth||640,this._defaultHeight=this._container.clientHeight||270;let s;if(!(n.source&&(s=n.source.context))){if(!(s=n.audioCtx))try{s=new(window.AudioContext||window.webkitAudioContext),this._ownContext=!0}catch{throw new Wt(Zg)}}if(!s.createGain)throw new Wt(Jg);const o=this._analyzer=[s.createAnalyser(),s.createAnalyser()],r=this._splitter=s.createChannelSplitter(2),a=this._merger=s.createChannelMerger(2);this._input=s.createGain(),this._output=s.createGain(),n.source&&this.connectInput(n.source);for(const u of[0,1])r.connect(o[u],u);a.connect(this._output),n.connectSpeakers!==!1&&this.connectOutput();for(const u of["_scaleX","_scaleR"])this[u]=document.createElement("canvas").getContext("2d");this._fsEl=n.fsElement||i;const l=()=>{this._fsTimeout||(this._fsTimeout=window.setTimeout(()=>{this._fsChanging||(this._setCanvas(qg),this._fsTimeout=0)},ru))};window.ResizeObserver&&(this._observer=new ResizeObserver(l),this._observer.observe(this._container)),this._controller=new AbortController;const c=this._controller.signal;window.addEventListener(au,l,{signal:c}),i.addEventListener(Ug,()=>{this._fsChanging=!0,this._fsTimeout&&window.clearTimeout(this._fsTimeout),this._setCanvas(mu),this._fsTimeout=window.setTimeout(()=>{this._fsChanging=!1,this._fsTimeout=0},ru)},{signal:c});const d=()=>{s.state=="suspended"&&s.resume().then(()=>window.removeEventListener(ou,d))};window.addEventListener(ou,d),document.addEventListener("visibilitychange",()=>{document.visibilityState!="hidden"&&(this._frames=0,this._time=performance.now())},{signal:c}),this._setProps(n,!0),this.useCanvas&&this._ownCanvas&&this._container.appendChild(i),this._ready=!0,this._setCanvas(pu)}get alphaBars(){return this._alphaBars}set alphaBars(t){this._alphaBars=!!t,this._calcBars()}get ansiBands(){return this._ansiBands}set ansiBands(t){this._ansiBands=!!t,this._calcBars()}get barSpace(){return this._barSpace}set barSpace(t){this._barSpace=+t||0,this._calcBars()}get channelLayout(){return this._chLayout}set channelLayout(t){this._chLayout=Mi(t,[me,Ri,oe,nu]),this._input.disconnect(),this._input.connect(this._chLayout!=me?this._splitter:this._analyzer[0]),this._analyzer[0].disconnect(),this._outNodes.length&&this._analyzer[0].connect(this._chLayout!=me?this._merger:this._output),this._calcBars(),this._makeGrad()}get colorMode(){return this._colorMode}set colorMode(t){this._colorMode=Mi(t,[Ii,iu,su])}get fadePeaks(){return this._fadePeaks}set fadePeaks(t){this._fadePeaks=!!t}get fftSize(){return this._analyzer[0].fftSize}set fftSize(t){for(const i of[0,1])this._analyzer[i].fftSize=t;const n=this._analyzer[0].frequencyBinCount;this._fftData=[new Float32Array(n),new Float32Array(n)],this._calcBars()}get frequencyScale(){return this._frequencyScale}set frequencyScale(t){this._frequencyScale=Mi(t,[on,Rr,Ir,Un]),this._calcBars()}get gradient(){return this._selectedGrads[0]}set gradient(t){this._setGradient(t)}get gradientLeft(){return this._selectedGrads[0]}set gradientLeft(t){this._setGradient(t,0)}get gradientRight(){return this._selectedGrads[1]}set gradientRight(t){this._setGradient(t,1)}get gravity(){return this._gravity}set gravity(t){this._gravity=t>0?+t:this._gravity||Hn.gravity}get height(){return this._height}set height(t){this._height=t,this._setCanvas(Ar)}get ledBars(){return this._showLeds}set ledBars(t){this._showLeds=!!t,this._calcBars()}get linearAmplitude(){return this._linearAmplitude}set linearAmplitude(t){this._linearAmplitude=!!t}get linearBoost(){return this._linearBoost}set linearBoost(t){this._linearBoost=t>=1?+t:1}get lineWidth(){return this._lineWidth}set lineWidth(t){this._lineWidth=+t||0}get loRes(){return this._loRes}set loRes(t){this._loRes=!!t,this._setCanvas(zg)}get lumiBars(){return this._lumiBars}set lumiBars(t){this._lumiBars=!!t,this._calcBars(),this._makeGrad()}get maxDecibels(){return this._analyzer[0].maxDecibels}set maxDecibels(t){for(const n of[0,1])this._analyzer[n].maxDecibels=t}get maxFPS(){return this._maxFPS}set maxFPS(t){this._maxFPS=t<0?0:+t||0}get maxFreq(){return this._maxFreq}set maxFreq(t){if(t<1)throw new Wt(Pr);this._maxFreq=Math.min(t,this.audioCtx.sampleRate/2),this._calcBars()}get minDecibels(){return this._analyzer[0].minDecibels}set minDecibels(t){for(const n of[0,1])this._analyzer[n].minDecibels=t}get minFreq(){return this._minFreq}set minFreq(t){if(t<1)throw new Wt(Pr);this._minFreq=+t,this._calcBars()}get mirror(){return this._mirror}set mirror(t){this._mirror=Math.sign(t)|0,this._calcBars(),this._makeGrad()}get mode(){return this._mode}set mode(t){const n=t|0;if(n>=0&&n<=10&&n!=9)this._mode=n,this._calcBars(),this._makeGrad();else throw new Wt(tv,t)}get noteLabels(){return this._noteLabels}set noteLabels(t){this._noteLabels=!!t,this._createScales()}get outlineBars(){return this._outlineBars}set outlineBars(t){this._outlineBars=!!t,this._calcBars()}get peakFadeTime(){return this._peakFadeTime}set peakFadeTime(t){this._peakFadeTime=t>=0?+t:this._peakFadeTime||Hn.peakFadeTime}get peakHoldTime(){return this._peakHoldTime}set peakHoldTime(t){this._peakHoldTime=+t||0}get peakLine(){return this._peakLine}set peakLine(t){this._peakLine=!!t}get radial(){return this._radial}set radial(t){this._radial=!!t,this._calcBars(),this._makeGrad()}get radialInvert(){return this._radialInvert}set radialInvert(t){this._radialInvert=!!t,this._calcBars(),this._makeGrad()}get radius(){return this._radius}set radius(t){this._radius=+t||0,this._calcBars(),this._makeGrad()}get reflexRatio(){return this._reflexRatio}set reflexRatio(t){if(t=+t||0,t<0||t>=1)throw new Wt(ev);this._reflexRatio=t,this._calcBars(),this._makeGrad()}get roundBars(){return this._roundBars}set roundBars(t){this._roundBars=!!t,this._calcBars()}get smoothing(){return this._analyzer[0].smoothingTimeConstant}set smoothing(t){for(const n of[0,1])this._analyzer[n].smoothingTimeConstant=t}get spinSpeed(){return this._spinSpeed}set spinSpeed(t){t=+t||0,(this._spinSpeed===void 0||t==0)&&(this._spinAngle=-Er),this._spinSpeed=t}get splitGradient(){return this._splitGradient}set splitGradient(t){this._splitGradient=!!t,this._makeGrad()}get stereo(){return bu("stereo","channelLayout"),this._chLayout!=me}set stereo(t){bu("stereo","channelLayout"),this.channelLayout=t?oe:me}get trueLeds(){return this._trueLeds}set trueLeds(t){this._trueLeds=!!t}get volume(){return this._output.gain.value}set volume(t){this._output.gain.value=t}get weightingFilter(){return this._weightingFilter}set weightingFilter(t){this._weightingFilter=Mi(t,[lu,cu,uu,du,hu,fu],"toUpperCase")}get width(){return this._width}set width(t){this._width=t,this._setCanvas(Ar)}get audioCtx(){return this._input.context}get canvas(){return this._ctx.canvas}get canvasCtx(){return this._ctx}get connectedSources(){return this._sources}get connectedTo(){return this._outNodes}get fps(){return this._fps}get fsHeight(){return this._fsHeight}get fsWidth(){return this._fsWidth}get isAlphaBars(){return this._flg.isAlpha}get isBandsMode(){return this._flg.isBands}get isDestroyed(){return this._destroyed}get isFullscreen(){return this._fsEl&&(document.fullscreenElement||document.webkitFullscreenElement)===this._fsEl}get isLedBars(){return this._flg.isLeds}get isLumiBars(){return this._flg.isLumi}get isOctaveBands(){return this._flg.isOctaves}get isOn(){return!!this._runId}get isOutlineBars(){return this._flg.isOutline}get pixelRatio(){return this._pixelRatio}get isRoundBars(){return this._flg.isRound}static get version(){return $g}connectInput(t){const n=t instanceof HTMLMediaElement;if(!(n||t.connect))throw new Wt(nv);const i=n?this.audioCtx.createMediaElementSource(t):t;return this._sources.includes(i)||(i.connect(this._input),this._sources.push(i)),i}connectOutput(t=this.audioCtx.destination){if(!this._outNodes.includes(t)&&(this._output.connect(t),this._outNodes.push(t),this._outNodes.length==1))for(const n of[0,1])this._analyzer[n].connect(this._chLayout==me&&!n?this._output:this._merger,0,n)}destroy(){if(!this._ready)return;const{audioCtx:t,canvas:n,_controller:i,_input:s,_merger:o,_observer:r,_ownCanvas:a,_ownContext:l,_splitter:c}=this;this._destroyed=!0,this._ready=!1,this.stop(),i.abort(),r&&r.disconnect(),this.onCanvasResize=null,this.onCanvasDraw=null,this._fsEl=null,this.disconnectInput(),this.disconnectOutput(),s.disconnect(),c.disconnect(),o.disconnect(),l&&t.close(),a&&n.remove(),this._calcBars()}disconnectInput(t,n){t?Array.isArray(t)||(t=[t]):t=Array.from(this._sources);for(const i of t){const s=this._sources.indexOf(i);if(n&&i.mediaStream)for(const o of i.mediaStream.getAudioTracks())o.stop();s>=0&&(i.disconnect(this._input),this._sources.splice(s,1))}}disconnectOutput(t){if(!(t&&!this._outNodes.includes(t))&&(this._output.disconnect(t),this._outNodes=t?this._outNodes.filter(n=>n!==t):[],this._outNodes.length==0))for(const n of[0,1])this._analyzer[n].disconnect()}getBars(){return Array.from(this._bars,({posX:t,freq:n,freqLo:i,freqHi:s,hold:o,peak:r,value:a})=>({posX:t,freq:n,freqLo:i,freqHi:s,hold:o,peak:r,value:a}))}getEnergy(t,n){if(t===void 0)return this._energy.val;if(t!=+t){if(t=="peak")return this._energy.peak;const a={bass:[20,250],lowMid:[250,500],mid:[500,2e3],highMid:[2e3,4e3],treble:[4e3,16e3]};if(!a[t])return null;[t,n]=a[t]}const i=this._freqToBin(t),s=n?this._freqToBin(n):i,o=this._chLayout==me?1:2;let r=0;for(let a=0;a<o;a++)for(let l=i;l<=s;l++)r+=this._normalizedB(this._fftData[a][l]);return r/(s-i+1)/o}getOptions(t){Array.isArray(t)||(t=[t]);let n={};for(const i of Object.keys(Hn))t.includes(i)||(i=="gradient"&&this.gradientLeft!=this.gradientRight?(n.gradientLeft=this.gradientLeft,n.gradientRight=this.gradientRight):i!="start"&&(n[i]=this[i]));return n}registerGradient(t,n){if(typeof t!="string"||t.trim().length==0)throw new Wt(iv);if(typeof n!="object")throw new Wt(sv);const{colorStops:i}=n;if(!Array.isArray(i)||!i.length)throw new Wt(rv);const s=i.length,o=r=>+r!=r||r<0||r>1;i.forEach((r,a)=>{const l=a/Math.max(1,s-1);typeof r!="object"?i[a]={pos:l,color:r}:o(r.pos)&&(r.pos=l),o(r.level)&&(i[a].level=1-a/s)}),i.sort((r,a)=>r.level<a.level?1:r.level>a.level?-1:0),i[0].level=1,this._gradients[t]={bgColor:n.bgColor||Hg,dir:n.dir,colorStops:i},this._selectedGrads.includes(t)&&this._makeGrad()}setCanvasSize(t,n){this._width=t,this._height=n,this._setCanvas(Ar)}setFreqRange(t,n){if(t<1||n<1)throw new Wt(Pr);this._minFreq=Math.min(t,n),this.maxFreq=Math.max(t,n)}setLedParams(t){let n,i,s;t&&(n=t.maxLeds|0,i=+t.spaceV,s=+t.spaceH),this._ledParams=n>0&&i>0&&s>=0?[n,i,s]:void 0,this._calcBars()}setOptions(t){this._setProps(t)}setSensitivity(t,n){for(const i of[0,1])this._analyzer[i].minDecibels=Math.min(t,n),this._analyzer[i].maxDecibels=Math.max(t,n)}start(){this.toggleAnalyzer(!0)}stop(){this.toggleAnalyzer(!1)}toggleAnalyzer(t){const n=this.isOn;return t===void 0&&(t=!n),n&&!t?(cancelAnimationFrame(this._runId),this._runId=0):!n&&t&&!this._destroyed&&(this._frames=0,this._time=performance.now(),this._runId=requestAnimationFrame(i=>this._draw(i))),this.isOn}toggleFullscreen(){if(this.isFullscreen)document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen&&document.webkitExitFullscreen();else{const t=this._fsEl;if(!t)return;t.requestFullscreen?t.requestFullscreen():t.webkitRequestFullscreen&&t.webkitRequestFullscreen()}}_binToFreq(t){return t*this.audioCtx.sampleRate/this.fftSize||1}_calcBars(){const t=this._bars=[];if(!this._ready){this._flg={isAlpha:!1,isBands:!1,isLeds:!1,isLumi:!1,isOctaves:!1,isOutline:!1,isRound:!1,noLedGap:!1};return}const{_ansiBands:n,_barSpace:i,canvas:s,_chLayout:o,_maxFreq:r,_minFreq:a,_mirror:l,_mode:c,_radial:d,_radialInvert:u,_reflexRatio:p}=this,g=s.width>>1,_=s.height>>1,b=o==oe&&!d,w=o==Ri,y=c%10!=0,S=y&&this._frequencyScale==on,C=this._showLeds&&y&&!d,P=this._lumiBars&&y&&!d,L=this._alphaBars&&!P&&c!=rn,D=this._outlineBars&&y&&!P&&!C,x=this._roundBars&&y&&!P&&!C,k=o!=oe||p>0&&!P,f=s.height-(b&&!C?.5:0)>>b,m=f*(P||d?1:1-p)|0,h=s.width-g*(w||l!=0),v=b?s.height-f*2:0,T=g*(l==-1&&!w&&!d);let R=Math.min(s.width,s.height)*.375*(o==oe?1:this._radius)|0,A=Math.min(g,_);u&&o!=oe&&([R,A]=[A,R]);const M=W=>t.push({...W,peak:[0,0],hold:[0],alpha:[0],value:[0]}),I=W=>{const Y=this._freqToBin(W,"floor"),Z=this._binToFreq(Y),tt=this._binToFreq(Y+1),dt=Math.log2(W/Z)/Math.log2(tt/Z);return[Y,dt]};let N,K,F;if(S){const W=(st,ft,it)=>+st.toPrecision(it?Math.max(ft,1+Math.log10(st)|0):ft),Y=st=>{const ft=[1,1.12,1.25,1.4,1.6,1.8,2,2.24,2.5,2.8,3.15,3.55,4,4.5,5,5.6,6.3,7.1,8,9,10],it=Math.log10(st)|0,ce=st/10**it;let Zt=1;for(;Zt<ft.length&&ce>ft[Zt];)Zt++;return ce-ft[Zt-1]<ft[Zt]-ce&&Zt--,(ft[Zt]*10**(it+5)|0)/1e5},Z=[0,24,12,8,6,4,3,2,1][c],tt=n?10**(3/(Z*10)):2**(1/Z),dt=tt**.5;let It=n?7.94328235/(Z%2?1:dt):eu;do{let st=It;const ft=W(st/dt,4,!0),it=W(st*dt,4,!0),[ce,Zt]=I(ft),[Yn,ue]=I(it);n?st=Z<4?Y(st):W(st,st.toString()[0]<5?3:2):st=W(st,4,!0),st>=a&&M({posX:0,freq:st,freqLo:ft,freqHi:it,binLo:ce,binHi:Yn,ratioLo:Zt,ratioHi:ue}),It*=tt}while(It<=r);N=h/t.length,t.forEach((st,ft)=>st.posX=T+ft*N);const ht=t[0],Tt=t[t.length-1];K=this._freqScaling(ht.freqLo),F=h/(this._freqScaling(Tt.freqHi)-K),ht.freqLo<a&&(ht.freqLo=a,[ht.binLo,ht.ratioLo]=I(a)),Tt.freqHi>r&&(Tt.freqHi=r,[Tt.binHi,Tt.ratioHi]=I(r))}else if(y){const W=[0,24,12,8,6,4,3,2,1][c]*10,Y=Z=>{switch(this._frequencyScale){case Rr:return 1960/(26.81/(Z+.53)-1);case Ir:return 700*(2**Z-1);case Un:return Z}};N=h/W,K=this._freqScaling(a),F=h/(this._freqScaling(r)-K);for(let Z=0,tt=0;Z<W;Z++,tt+=N){const dt=Y(K+tt/F),It=Y(K+(tt+N/2)/F),ht=Y(K+(tt+N)/F),[Tt,st]=I(dt),[ft,it]=I(ht);M({posX:T+tt,freq:It,freqLo:dt,freqHi:ht,binLo:Tt,binHi:ft,ratioLo:st,ratioHi:it})}}else{N=1,K=this._freqScaling(a),F=h/(this._freqScaling(r)-K);const W=this._freqToBin(a,"floor"),Y=this._freqToBin(r);let Z=-999;for(let tt=W;tt<=Y;tt++){const dt=this._binToFreq(tt),It=T+Math.round(F*(this._freqScaling(dt)-K));if(It>Z)M({posX:It,freq:dt,freqLo:dt,freqHi:dt,binLo:tt,binHi:tt,ratioLo:0,ratioHi:0}),Z=It;else if(t.length){const ht=t[t.length-1];ht.binHi=tt,ht.freqHi=dt,ht.freq=(ht.freqLo*dt)**.5}}}let rt=0,Q=0;if(C){const W=this._pixelRatio/(window.devicePixelRatio>1&&window.screen.height<=540?2:1),Y=[[],[128,3,.45],[128,4,.225],[96,6,.225],[80,6,.225],[80,6,.125],[64,6,.125],[48,8,.125],[24,16,.125]],Z=this._ledParams,[tt,dt,It]=Z||Y[c];let ht,Tt=m;if(Z){const st=2*W;let ft;ht=tt+1;do ht--,ft=Tt/ht/(1+dt),Q=ft*dt;while((ft<st||Q<st)&&ht>1)}else{const st=540/dt;Q=Math.min(dt*W,Math.max(2,Tt/st+.1|0))}k&&(Tt+=Q),Z||(ht=Math.min(tt,Tt/(Q*2)|0)),rt=It>=1?It:N*It,this._leds=[ht,rt,Q,Tt/ht-Q]}const j=Math.min(N-1,i*(i>0&&i<1?N:1));y&&(N-=Math.max(C?rt:0,j)),t.forEach((W,Y)=>{let Z=W.posX,tt=N;y&&(i==0&&!C?(Z|=0,tt|=0,Y>0&&Z>t[Y-1].posX+t[Y-1].width&&(Z--,tt++)):Z+=Math.max(C?rt:0,j)/2,W.posX=Z),W.barCenter=Z+(N==1?0:tt/2),W.width=tt});const lt=[];for(const W of[0,1]){const Y=o==oe?(f+v)*W:0,Z=Y+f,tt=Y+m-(!C||k?0:Q);lt.push({channelTop:Y,channelBottom:Z,analyzerBottom:tt})}this._aux={analyzerHeight:m,analyzerWidth:h,centerX:g,centerY:_,channelCoords:lt,channelHeight:f,channelGap:v,initialX:T,innerRadius:R,outerRadius:A,scaleMin:K,unitWidth:F},this._flg={isAlpha:L,isBands:y,isLeds:C,isLumi:P,isOctaves:S,isOutline:D,isRound:x,noLedGap:k},this._createScales()}_createScales(){if(!this._ready)return;const{analyzerWidth:t,initialX:n,innerRadius:i,scaleMin:s,unitWidth:o}=this._aux,{canvas:r,_frequencyScale:a,_mirror:l,_noteLabels:c,_radial:d,_scaleX:u,_scaleR:p}=this,g=u.canvas,_=p.canvas,b=[],w=this._chLayout==Ri,y=this._chLayout==oe,S=Math.min(r.width,r.height),C=["C",,"D",,"E","F",,"G",,"A",,"B"],P=S/34|0,L=g.height>>1,D=P>>1,x=L*(c?.7:1.5),k=D*(c?1:2),f=2**(1/12);if(!c&&(this._ansiBands||a!=on))b.push(16,31.5,63,125,250,500,1e3,2e3,4e3),a==Un?b.push(6e3,8e3,1e4,12e3,14e3,16e3,18e3,2e4,22e3):b.push(8e3,16e3);else{let A=eu;for(let M=-1;M<11;M++)for(let I=0;I<12;I++){if(A>=this._minFreq&&A<=this._maxFreq){const N=C[I],K=N=="C";(N&&c&&!l&&!w||K)&&b.push(c?[A,N+(K?M:"")]:A)}A*=f}}_.width=_.height=Math.max(S*.15,(i<<1)+y*P);const m=_.width>>1,h=m-P*.7,v=(A,M)=>{const I=sn*(A/r.width),N=I-Er,K=h*Math.cos(N),F=h*Math.sin(N);p.save(),p.translate(m+K,m+F),p.rotate(I),p.fillText(M,0,0),p.restore()};g.width|=0,u.fillStyle=p.strokeStyle=Kg,u.fillRect(0,0,g.width,g.height),p.arc(m,m,m-P/2,0,sn),p.lineWidth=P,p.stroke(),u.fillStyle=p.fillStyle=gu,u.font=`${L}px ${Pi}`,p.font=`${D}px ${Pi}`,u.textAlign=p.textAlign="center";let T=-x/4,R=-k;for(const A of b){const[M,I]=Array.isArray(A)?A:[A,A<1e3?A|0:`${(A/100|0)/10}k`],N=o*(this._freqScaling(M)-s),K=g.height*.75,F=I[0]=="C",rt=L*(c&&!l&&!w?F?1.2:.6:3);if(u.fillStyle=p.fillStyle=F&&!l&&!w?Xg:gu,c){const Q=a==on,j=a==Un;let lt=["C"];if((Q||M>2e3||!j&&M>250||(!d||y)&&(!j&&M>125||M>1e3))&<.push("G"),(Q||M>4e3||!j&&M>500||(!d||y)&&(!j&&M>250||M>2e3))&<.push("E"),(j&&M>4e3||(!d||y)&&(Q||M>2e3||!j&&M>500))&<.push("D","F","A","B"),!lt.includes(I[0]))continue}N>=T+x/2&&N<=t&&(u.fillText(I,w&&l==-1?t-N:n+N,K,rt),(w||l&&(N>x||l==1))&&u.fillText(I,w&&l!=1?t+N:(n||r.width)-N,K,rt),T=N+Math.min(rt,u.measureText(I).width)/2),N>=R+k&&N<t-k&&(v(w&&l==1?t-N:N,I),(w||l&&(N>k||l==1))&&v(w&&l!=-1?t+N:-N,I),R=N)}}_draw(t){this._runId=requestAnimationFrame(O=>this._draw(O));const n=t-this._time,i=t-this._last,s=this._maxFPS?975/this._maxFPS:0;if(i<s)return;this._last=t-(s?i%s:0),this._frames++,n>=1e3&&(this._fps=this._frames/n*1e3,this._frames=0,this._time=t);const{isAlpha:o,isBands:r,isLeds:a,isLumi:l,isOctaves:c,isOutline:d,isRound:u,noLedGap:p}=this._flg,{analyzerHeight:g,centerX:_,centerY:b,channelCoords:w,channelHeight:y,channelGap:S,initialX:C,innerRadius:P,outerRadius:L}=this._aux,{_bars:D,canvas:x,_canvasGradients:k,_chLayout:f,_colorMode:m,_ctx:h,_energy:v,_fadePeaks:T,fillAlpha:R,_fps:A,_linearAmplitude:M,_lineWidth:I,maxDecibels:N,minDecibels:K,_mirror:F,_mode:rt,overlay:Q,_radial:j,showBgColor:lt,showPeaks:W,useCanvas:Y,_weightingFilter:Z}=this,tt=this._scaleX.canvas,dt=this._scaleR.canvas,It=A*this._peakFadeTime/1e3,ht=A**2,Tt=this._gravity*1e3,st=A*this._peakHoldTime/1e3,ft=f==nu,it=f==Ri,ce=f==oe,Zt=f==me,Yn=a&&this._trueLeds&&m==Ii,ue=j?x.width:this._aux.analyzerWidth,Hr=C+ue,Zn=W&&this._peakLine&&rt==rn,Ce=j?L-P:g,j_=Ce/this._pixelRatio,[$_,X_,Jn,Gr]=this._leds||[];v.val>0&&A>0&&(this._spinAngle+=this._spinSpeed*sn/60/A);const U_=O=>{if(this._reflexRatio>0&&!l&&!j){let et,de;this.reflexFit||ce?(et=ce&&O==0?y+S:0,de=y-g):(et=x.height-g*2,de=g),h.save(),h.globalAlpha=this.reflexAlpha,this.reflexBright!=1&&(h.filter=`brightness(${this.reflexBright})`),h.setTransform(1,0,0,-1,0,x.height),h.drawImage(x,0,w[O].channelTop,x.width,g,0,et,x.width,de),h.restore()}},H_=()=>{this.showScaleX&&(j?(h.save(),h.translate(_,b),this._spinSpeed&&h.rotate(this._spinAngle+Er),h.drawImage(dt,-dt.width>>1,-dt.width>>1),h.restore()):h.drawImage(tt,0,x.height-tt.height))},G_=O=>{const et=O**2,de=424.36,Ct=11599.29,Ui=25122.25,ke=544496.41,ge=148693636,je=$e=>20*Math.log10($e);switch(Z){case cu:const $e=ge*et**2/((et+de)*Math.sqrt((et+Ct)*(et+ke))*(et+ge));return 2+je($e);case uu:const Ue=ge*et*O/((et+de)*Math.sqrt(et+Ui)*(et+ge));return .17+je(Ue);case du:const qr=ge*et/((et+de)*(et+ge));return .06+je(qr);case hu:const Hi=((103791848e-2-et)**2+108076816e-2*et)/((9837328-et)**2+11723776*et),Kr=O/68966888496476e-18*Math.sqrt(Hi/((et+79919.29)*(et+1345600)));return je(Kr);case fu:const Gi=-4737338981378384e-39*O**6+2043828333606125e-30*O**4-1363894795463638e-22*et+1,He=1306612257412824e-34*O**5-2118150887518656e-26*O**3+.0005559488023498642*O,Bt=.0001246332637532143*O/Math.hypot(Gi,He);return 18.2+je(Bt)}return 0},Wr=(O,et,de)=>{h.beginPath(),h.moveTo(O,et),h.lineTo(O,de),h.stroke()},zr=O=>{if(O&&I){const et=h.globalAlpha;h.globalAlpha=1,h.stroke(),h.globalAlpha=et}},Be=O=>Math.max(0,(O*$_|0)*(Gr+Jn)-Jn),W_=O=>{v.val=O,v.peak>0&&(v.hold--,v.hold<0&&(v.peak+=v.hold*Tt/ht/x.height*this._pixelRatio)),O>=v.peak&&(v.peak=O,v.hold=st)};Q&&h.clearRect(0,0,x.width,x.height);let cd=0;const ud=D.length,dd=Zt?1:2;for(let O=0;O<dd;O++){const{channelTop:et,channelBottom:de,analyzerBottom:Ct}=w[O],Ui=this._gradients[this._selectedGrads[O]],ke=Ui.colorStops,ge=ke.length,je=!lt||a&&!Q?"#000":Ui.bgColor,$e=ce&&j&&O?-1:1,Ue=!O&&F==-1||O&&F==1,qr=!it||O&&F!=1?0:ue>>(O||!Ue),Hi=it&&Ue?-1:1,Kr=()=>{const $=tt.height,G=$>>1,z=M?100:N,ct=M?0:K,bt=M?20:5,Nt=g/(z-ct),he=F!=-1&&(!it||O==0||F==1),Te=F!=1&&(!it||O!=F);h.save(),h.fillStyle=vu,h.font=`${G}px ${Pi}`,h.textAlign="right",h.lineWidth=1;for(let Ee=z;Ee>ct;Ee-=bt){const fn=et+(z-Ee)*Nt,xt=Ee%2==0|0;if(xt){const Pt=fn+G*(fn==et?.8:.35);he&&h.fillText(Ee,$*.85,Pt),Te&&h.fillText(Ee,(it?ue:x.width)-$*.1,Pt),h.strokeStyle=vu,h.setLineDash([2,4]),h.lineDashOffset=0}else h.strokeStyle=Yg,h.setLineDash([2,8]),h.lineDashOffset=1;h.beginPath(),h.moveTo(C+$*xt*he,~~fn+.5),h.lineTo(Hr-$*xt*Te,~~fn+.5),h.stroke()}h.restore()},Gi=($,G)=>{const z=Jt[$]+($<Jt.length-1?(Jt[$+1]-Jt[$])*G:0);return isNaN(z)?-1/0:z},He=($,G=Hi)=>G*sn*(($+qr)/x.width)+this._spinAngle,Bt=($,G,z)=>{const ct=P+G*$e,bt=He($,z);return[_+ct*Math.cos(bt),b+ct*Math.sin(bt)]},Xr=($,G,z,ct,bt)=>{h.beginPath();for(const Nt of F&&!it?[1,-1]:[Hi]){const[he,Te]=u?[He($,Nt),He($+z,Nt)]:[];h.moveTo(...Bt($,G,Nt)),h.lineTo(...Bt($,G+ct,Nt)),u?h.arc(_,b,P+(G+ct)*$e,he,Te,Nt!=1):h.lineTo(...Bt($+z,G+ct,Nt)),h.lineTo(...Bt($+z,G,Nt)),u&&!bt&&h.arc(_,b,P+G*$e,Te,he,Nt==1)}zr(bt),h.fill()},Yr=($=0,G=0)=>{let z;if(m==Ii&&!Yn||rt==rn)z=k[O];else{const ct=m==iu?G%ge:ke.findLastIndex(bt=>a?Be($)<=Be(bt.level):$<=bt.level);z=ke[ct].color}h.fillStyle=h.strokeStyle=z};if(Y){if(it&&!j){const $=ue*(O+Ue),G=Ue?-1:1;h.setTransform(G,0,0,1,$,0)}if((!Q||lt)&&(Q&&(h.globalAlpha=this.bgAlpha),h.fillStyle=je,(O==0||!j&&!ft)&&h.fillRect(C,et-S,ue,(Q&&this.reflexAlpha==1?g:y)+S),h.globalAlpha=1),this.showScaleY&&!l&&!j&&(O==0||!ft)&&Kr(),a?(h.setLineDash([Gr,Jn]),h.lineWidth=D[0].width):h.lineWidth=d?Math.min(I,D[0].width/2):I,h.save(),!j){const $=new Path2D;$.rect(0,et,x.width,g),h.clip($)}}let Jt=this._fftData[O];this._analyzer[O].getFloatFrequencyData(Jt),Z&&(Jt=Jt.map(($,G)=>$+G_(this._binToFreq(G)))),h.beginPath();let Qn=[];for(let $=0;$<ud;$++){const G=D[$],{posX:z,barCenter:ct,width:bt,freq:Nt,binLo:he,binHi:Te,ratioLo:Ee,ratioHi:fn}=G;let xt=Math.max(Gi(he,Ee),Gi(Te,fn));for(let ot=he+1;ot<Te;ot++)Jt[ot]>xt&&(xt=Jt[ot]);if(xt=this._normalizedB(xt),G.value[O]=xt,cd+=xt,G.peak[O]>0&&G.alpha[O]>0&&(G.hold[O]--,G.hold[O]<0)){if(T&&!Zn){const ot=!o||d&&I>0?1:o?G.peak[O]:R;G.alpha[O]=ot*(1+G.hold[O]/It)}else G.peak[O]+=G.hold[O]*Tt/ht/j_;G.alpha[O]<=0&&(G.peak[O]=0)}if(xt>=G.peak[O]&&(G.peak[O]=xt,G.hold[O]=st,G.alpha[O]=!o||d&&I>0?1:o?xt:R),!Y)continue;h.globalAlpha=l||o?xt:d?R:1,Yr(xt,$);const Pt=l?Ce:a?Be(xt):xt*Ce|0;if(rt==rn){const ot=$?0:(this._normalizedB(Jt[D[1].binLo])*Ce+Pt)/2;if(j){if($==0&&(it&&h.moveTo(...Bt(0,0)),h.lineTo(...Bt(0,z<0?ot:Pt))),z>=0){const qt=[z,Pt];h.lineTo(...Bt(...qt)),Qn.push(qt)}}else{if($==0)if(F==-1&&!it)h.moveTo(C,Ct-(z<C?ot:Pt));else{const qt=he?this._normalizedB(Jt[he-1])*Ce:Pt;h.moveTo(C-I,Ct-qt)}(it||F!=-1||z>=C)&&h.lineTo(z,Ct-Pt)}}else if(a){if(lt&&!Q&&(O==0||!ft)){const ot=h.globalAlpha;h.strokeStyle=Wg,h.globalAlpha=1,Wr(ct,et,Ct),h.strokeStyle=h.fillStyle,h.globalAlpha=ot}if(Yn){const ot=l?0:ke.findLastIndex(Ge=>Be(xt)<=Be(Ge.level));let qt=Ct;for(let Ge=ge-1;Ge>=ot;Ge--){h.strokeStyle=ke[Ge].color;let fd=Ct-(Ge==ot?Pt:Be(ke[Ge].level));Wr(ct,qt,fd),qt=fd-Jn}}else Wr(ct,Ct,Ct-Pt)}else if(z>=C)if(j)Xr(z,0,bt,Pt,d);else if(u){const ot=bt/2,qt=Ct+ot;h.beginPath(),h.moveTo(z,qt),h.lineTo(z,qt-Pt),h.arc(ct,qt-Pt,ot,Tr,sn),h.lineTo(z+bt,qt),zr(d),h.fill()}else{const ot=d?h.lineWidth:0;h.beginPath(),h.rect(z,Ct+ot,bt,-Pt-ot),zr(d),h.fill()}const pn=G.peak[O],hd=G.alpha[O];if(pn>0&&hd>0&&W&&!Zn&&!l&&z>=C&&z<Hr){if(T?h.globalAlpha=hd:d&&I>0?h.globalAlpha=1:o&&(h.globalAlpha=pn),(m==su||Yn)&&Yr(pn),a){const ot=Be(pn);ot>=Jn&&h.fillRect(z,Ct-ot,bt,Gr)}else if(!j)h.fillRect(z,Ct-pn*Ce,bt,2);else if(rt!=rn){const ot=pn*Ce;Xr(z,ot,bt,!this._radialInvert||ce||ot+P>=2?-2:2)}}}if(Y){if(h.globalAlpha=1,rt==rn){if(Yr(),j&&!it){if(F){let $;for(;$=Qn.pop();)h.lineTo(...Bt(...$,-1))}h.closePath()}if(I>0&&h.stroke(),R>0){if(j){const $=it?He(ue>>1):0,G=it?He(ue):sn;h.moveTo(...Bt(it?ue>>1:0,0)),h.arc(_,b,P,$,G,it?!Ue:!0)}else h.lineTo(Hr,Ct),h.lineTo(C,Ct);h.globalAlpha=R,h.fill(),h.globalAlpha=1}if((Zn||j&&W)&&(Qn=[],h.beginPath(),D.forEach(($,G)=>{let z=$.posX,ct=$.peak[O],bt=G?"lineTo":"moveTo";if(j&&z<0){const Nt=D[G+1];ct=ov(z,ct,Nt.posX,Nt.peak[O],0),z=0}ct*=Ce,Zn?(h[bt](...j?Bt(z,ct):[z,Ct-ct]),j&&F&&!it&&Qn.push([z,ct])):ct>0&&Xr(z,ct,1,-2)}),Zn)){let $;for(;$=Qn.pop();)h.lineTo(...Bt(...$,-1));h.lineWidth=1,h.stroke()}}h.restore(),it&&!j&&h.setTransform(1,0,0,1,0,0),(!it&&!ft||O)&&U_(O)}}if(W_(cd/(ud<<dd-1)),Y&&(F&&!j&&!it&&(h.setTransform(-1,0,0,1,x.width-C,0),h.drawImage(x,C,0,_,x.height,0,0,_,x.height),h.setTransform(1,0,0,1,0,0)),h.setLineDash([]),H_()),this.showFPS){const O=tt.height;h.font=`bold ${O}px ${Pi}`,h.fillStyle=Gg,h.textAlign="right",h.fillText(Math.round(A),x.width-O,O*2)}this.onCanvasDraw&&(h.save(),h.fillStyle=h.strokeStyle=k[0],this.onCanvasDraw(this,{timestamp:t,canvasGradients:k}),h.restore())}_freqScaling(t){switch(this._frequencyScale){case on:return Math.log2(t);case Rr:return 26.81*t/(1960+t)-.53;case Ir:return Math.log2(1+t/700);case Un:return t}}_freqToBin(t,n="round"){const i=this._analyzer[0].frequencyBinCount-1,s=Math[n](t*this.fftSize/this.audioCtx.sampleRate);return s<i?s:i}_makeGrad(){if(!this._ready)return;const{canvas:t,_ctx:n,_radial:i,_reflexRatio:s}=this,{analyzerWidth:o,centerX:r,centerY:a,initialX:l,innerRadius:c,outerRadius:d}=this._aux,{isLumi:u}=this._flg,p=this._chLayout==oe,g=1-s,_=u?t.height:t.height*(1-s*!p)|0;for(const b of[0,1]){const w=this._gradients[this._selectedGrads[b]],y=w.colorStops,S=w.dir=="h";let C;if(i?C=n.createRadialGradient(r,a,d,r,a,c-(d-c)*p):C=n.createLinearGradient(...S?[l,0,l+o,0]:[0,0,0,_]),y){const P=p&&!this._splitGradient&&(!S||i);for(let L=0;L<1+P;L++){const D=y.length-1;y.forEach((x,k)=>{let f=x.pos;if(P&&(f/=2),p&&!u&&!i&&!S&&(f*=g,!P&&f>.5*g&&(f+=.5*s)),L==1)if(i||u){const m=D-k;x=y[m],f=1-x.pos/2}else k==0&&f>0&&C.addColorStop(.5,x.color),f+=.5;C.addColorStop(f,x.color),p&&k==D&&f<.5&&C.addColorStop(.5,x.color)})}}this._canvasGradients[b]=C}}_normalizedB(t){const n=this._linearAmplitude,i=n?1/this._linearBoost:1,s=(l,c,d)=>l<=c?c:l>=d?d:l,o=l=>10**(l/20);let r=this.maxDecibels,a=this.minDecibels;return n&&(r=o(r),a=o(a),t=o(t)**i),s((t-a)/(r-a)**i,0,1)}_setCanvas(t){if(!this._ready)return;const{canvas:n,_ctx:i}=this,s=this._scaleX.canvas,o=window.devicePixelRatio/(this._loRes+1);let r=window.screen.width*o,a=window.screen.height*o;Math.abs(window.orientation)==90&&r<a&&([r,a]=[a,r]);const l=this.isFullscreen,c=l&&this._fsEl==n,d=c?r:(this._width||this._container.clientWidth||this._defaultWidth)*o|0,u=c?a:(this._height||this._container.clientHeight||this._defaultHeight)*o|0;this._pixelRatio=o,this._fsWidth=r,this._fsHeight=a,!(t!=pu&&n.width==d&&n.height==u)&&(n.width=d,n.height=u,this.overlay||(i.fillStyle="#000",i.fillRect(0,0,d,u)),i.lineJoin="bevel",s.width=d,s.height=Math.max(20*o,Math.min(d,u)/32|0),this._calcBars(),this._makeGrad(),this._fsStatus!==void 0&&this._fsStatus!==l&&(t=mu),this._fsStatus=l,this.onCanvasResize&&this.onCanvasResize(t,this))}_setGradient(t,n){if(!this._gradients.hasOwnProperty(t))throw new Wt(Qg,t);[0,1].includes(n)||(this._selectedGrads[1]=t,n=0),this._selectedGrads[n]=t,this._makeGrad()}_setProps(t,n){const i=["onCanvasDraw","onCanvasResize"],s=["gradientLeft","gradientRight","stereo"],o=Object.keys(Hn).filter(r=>r!="start").concat(i,s);(n||t===void 0)&&(t={...Hn,...t});for(const r of Object.keys(t))i.includes(r)&&typeof t[r]!="function"?this[r]=void 0:o.includes(r)&&(this[r]=t[r]);t.start!==void 0&&this.toggleAnalyzer(t.start)}}const lv={verdant:{colorStops:[{color:"#D3FFA6",pos:0},{color:"#036B5B",pos:.5},{color:"#D3FFA6",pos:1}]},twilight:{colorStops:[{color:"#81B9FF",pos:0},{color:"#371A5E",pos:.5},{color:"#81B9FF",pos:1}]},bloom:{colorStops:[{color:"#FFD4FE",pos:0},{color:"#FD05F9",pos:.5},{color:"#FFD4FE",pos:1}]},mystic:{colorStops:[{color:"#1F023A",pos:0},{color:"#CA76FF",pos:.5},{color:"#1F023A",pos:1}]},flare:{colorStops:[{color:"#FFFFFF",pos:0},{color:"#FC5F00",pos:.5},{color:"#FFFFFF",pos:1}]},glacier:{colorStops:[{color:"#4CE5F2",pos:0},{color:"#005A98",pos:.5},{color:"#4CE5F2",pos:1}]}},xu=({stream:e,className:t,onClick:n})=>{var o;const i=Mt(null),s=Ne();return $t(()=>{var c;if(!i.current||!e)return;const r=new AudioContext,a=r.createMediaStreamSource(e),l=new av(i.current,{source:a,audioCtx:r,alphaBars:!1,ansiBands:!1,barSpace:.25,bgAlpha:0,channelLayout:"single",colorMode:"gradient",fadePeaks:!1,fftSize:2048,fillAlpha:0,frequencyScale:"log",gravity:3.8,ledBars:!1,linearAmplitude:!0,linearBoost:2,lineWidth:1.5,loRes:!1,lumiBars:!1,maxDecibels:-20,maxFPS:0,maxFreq:16e3,minDecibels:-90,minFreq:30,mirror:0,mode:7,noteLabels:!1,outlineBars:!1,overlay:!0,peakFadeTime:750,peakHoldTime:500,peakLine:!1,radial:!1,radialInvert:!1,radius:.7,reflexAlpha:1,reflexBright:1,reflexFit:!0,reflexRatio:.5,roundBars:!0,showBgColor:!1,showFPS:!1,showPeaks:!1,showScaleX:!1,showScaleY:!1,smoothing:.7,spinSpeed:0,splitGradient:!1,trueLeds:!1,useCanvas:!0,volume:1,weightingFilter:"D"});return l.registerGradient("gradient",lv[((c=s.audio_visualizer_config)==null?void 0:c.color)||"verdant"]),l.gradient="gradient",()=>{l.destroy()}},[(o=s.audio_visualizer_config)==null?void 0:o.color,e]),E("div",{onClick:n,className:xe("w-full",t),ref:i})};/**
|
|
16
|
+
*/const Ug="4.5.1",kr=Math.PI,sn=2*kr,Cr=kr/2,eu=8.17579892,tu="dual-combined",Ai="dual-horizontal",pt="single",ot="dual-vertical",nu="bar-index",iu="bar-level",Ii="gradient",su=60,ru="click",Gg="fullscreenchange",ou="resize",Hg="#111",au="",cu="A",lu="B",uu="C",du="D",hu="468",Pi="sans-serif",Wg="#0f0",zg="#7f7f7f22",rn=10,fu="create",pu="fschange",qg="lores",Kg=ou,Tr="user",Xg="#000c",mu="#fff",Yg="#4f4",gu="#888",Zg="#555",Er="bark",Un="linear",on="log",Ar="mel",_u=["#a35","#c66","#e94","#ed0","#9d5","#4d8","#2cb","#0bc","#09c","#36b"],vu=[["classic",{colorStops:["red",{color:"yellow",level:.85,pos:.6},{color:"lime",level:.475}]}],["prism",{colorStops:_u}],["rainbow",{dir:"h",colorStops:["#817",..._u,"#639"]}],["orangered",{bgColor:"#3e2f29",colorStops:["OrangeRed"]}],["steelblue",{bgColor:"#222c35",colorStops:["SteelBlue"]}]],Gn={alphaBars:!1,ansiBands:!1,barSpace:.1,bgAlpha:.7,channelLayout:pt,colorMode:Ii,fadePeaks:!1,fftSize:8192,fillAlpha:1,frequencyScale:on,gradient:vu[0][0],gravity:3.8,height:void 0,ledBars:!1,linearAmplitude:!1,linearBoost:1,lineWidth:0,loRes:!1,lumiBars:!1,maxDecibels:-25,maxFPS:0,maxFreq:22e3,minDecibels:-85,minFreq:20,mirror:0,mode:0,noteLabels:!1,outlineBars:!1,overlay:!1,peakFadeTime:750,peakHoldTime:500,peakLine:!1,radial:!1,radialInvert:!1,radius:.3,reflexAlpha:.15,reflexBright:1,reflexFit:!0,reflexRatio:0,roundBars:!1,showBgColor:!0,showFPS:!1,showPeaks:!0,showScaleX:!0,showScaleY:!1,smoothing:.5,spinSpeed:0,splitGradient:!1,start:!0,trueLeds:!1,useCanvas:!0,volume:1,weightingFilter:au,width:void 0},Jg=["ERR_AUDIO_CONTEXT_FAIL","Could not create audio context. Web Audio API not supported?"],Qg=["ERR_INVALID_AUDIO_CONTEXT","Provided audio context is not valid"],e_=["ERR_UNKNOWN_GRADIENT","Unknown gradient"],Ir=["ERR_FREQUENCY_TOO_LOW","Frequency values must be >= 1"],t_=["ERR_INVALID_MODE","Invalid mode"],n_=["ERR_REFLEX_OUT_OF_RANGE","Reflex ratio must be >= 0 and < 1"],i_=["ERR_INVALID_AUDIO_SOURCE","Audio source must be an instance of HTMLMediaElement or AudioNode"],s_=["ERR_GRADIENT_INVALID_NAME","Gradient name must be a non-empty string"],r_=["ERR_GRADIENT_NOT_AN_OBJECT","Gradient options must be an object"],o_=["ERR_GRADIENT_MISSING_COLOR","Gradient colorStops must be a non-empty array"];class We extends Error{constructor(e,n){const[i,s]=e;super(s+(n!==void 0?`: ${n}`:"")),this.name="AudioMotionError",this.code=i}}const yu=(t,e)=>console.warn(`${t} is deprecated. Use ${e} instead.`),bu=t=>{for(const e in t)return!1;return!0},Ri=(t,e,n="toLowerCase")=>e[Math.max(0,e.indexOf((""+t)[n]()))],a_=(t,e,n,i,s)=>e+(i-e)*(s-t)/(n-t);Array.prototype.findLastIndex||(Array.prototype.findLastIndex=function(t){let e=this.length;for(;e-- >0;)if(t(this[e]))return e;return-1});class c_{constructor(e,n={}){this._ready=!1,this._aux={},this._canvasGradients=[],this._destroyed=!1,this._energy={val:0,peak:0,hold:0},this._flg={},this._fps=0,this._gradients={},this._last=0,this._outNodes=[],this._ownContext=!1,this._selectedGrads=[],this._sources=[],e instanceof Element||(bu(n)&&!bu(e)&&(n=e),e=null),this._ownCanvas=!(n.canvas instanceof HTMLCanvasElement);const i=this._ownCanvas?document.createElement("canvas"):n.canvas;i.style="max-width: 100%;",this._ctx=i.getContext("2d");for(const[u,m]of vu)this.registerGradient(u,m);this._container=e||!this._ownCanvas&&i.parentElement||document.body,this._defaultWidth=this._container.clientWidth||640,this._defaultHeight=this._container.clientHeight||270;let s;if(!(n.source&&(s=n.source.context))){if(!(s=n.audioCtx))try{s=new(window.AudioContext||window.webkitAudioContext),this._ownContext=!0}catch{throw new We(Jg)}}if(!s.createGain)throw new We(Qg);const o=this._analyzer=[s.createAnalyser(),s.createAnalyser()],r=this._splitter=s.createChannelSplitter(2),a=this._merger=s.createChannelMerger(2);this._input=s.createGain(),this._output=s.createGain(),n.source&&this.connectInput(n.source);for(const u of[0,1])r.connect(o[u],u);a.connect(this._output),n.connectSpeakers!==!1&&this.connectOutput();for(const u of["_scaleX","_scaleR"])this[u]=document.createElement("canvas").getContext("2d");this._fsEl=n.fsElement||i;const c=()=>{this._fsTimeout||(this._fsTimeout=window.setTimeout(()=>{this._fsChanging||(this._setCanvas(Kg),this._fsTimeout=0)},su))};window.ResizeObserver&&(this._observer=new ResizeObserver(c),this._observer.observe(this._container)),this._controller=new AbortController;const l=this._controller.signal;window.addEventListener(ou,c,{signal:l}),i.addEventListener(Gg,()=>{this._fsChanging=!0,this._fsTimeout&&window.clearTimeout(this._fsTimeout),this._setCanvas(pu),this._fsTimeout=window.setTimeout(()=>{this._fsChanging=!1,this._fsTimeout=0},su)},{signal:l});const d=()=>{s.state=="suspended"&&s.resume().then(()=>window.removeEventListener(ru,d))};window.addEventListener(ru,d),document.addEventListener("visibilitychange",()=>{document.visibilityState!="hidden"&&(this._frames=0,this._time=performance.now())},{signal:l}),this._setProps(n,!0),this.useCanvas&&this._ownCanvas&&this._container.appendChild(i),this._ready=!0,this._setCanvas(fu)}get alphaBars(){return this._alphaBars}set alphaBars(e){this._alphaBars=!!e,this._calcBars()}get ansiBands(){return this._ansiBands}set ansiBands(e){this._ansiBands=!!e,this._calcBars()}get barSpace(){return this._barSpace}set barSpace(e){this._barSpace=+e||0,this._calcBars()}get channelLayout(){return this._chLayout}set channelLayout(e){this._chLayout=Ri(e,[pt,Ai,ot,tu]),this._input.disconnect(),this._input.connect(this._chLayout!=pt?this._splitter:this._analyzer[0]),this._analyzer[0].disconnect(),this._outNodes.length&&this._analyzer[0].connect(this._chLayout!=pt?this._merger:this._output),this._calcBars(),this._makeGrad()}get colorMode(){return this._colorMode}set colorMode(e){this._colorMode=Ri(e,[Ii,nu,iu])}get fadePeaks(){return this._fadePeaks}set fadePeaks(e){this._fadePeaks=!!e}get fftSize(){return this._analyzer[0].fftSize}set fftSize(e){for(const i of[0,1])this._analyzer[i].fftSize=e;const n=this._analyzer[0].frequencyBinCount;this._fftData=[new Float32Array(n),new Float32Array(n)],this._calcBars()}get frequencyScale(){return this._frequencyScale}set frequencyScale(e){this._frequencyScale=Ri(e,[on,Er,Ar,Un]),this._calcBars()}get gradient(){return this._selectedGrads[0]}set gradient(e){this._setGradient(e)}get gradientLeft(){return this._selectedGrads[0]}set gradientLeft(e){this._setGradient(e,0)}get gradientRight(){return this._selectedGrads[1]}set gradientRight(e){this._setGradient(e,1)}get gravity(){return this._gravity}set gravity(e){this._gravity=e>0?+e:this._gravity||Gn.gravity}get height(){return this._height}set height(e){this._height=e,this._setCanvas(Tr)}get ledBars(){return this._showLeds}set ledBars(e){this._showLeds=!!e,this._calcBars()}get linearAmplitude(){return this._linearAmplitude}set linearAmplitude(e){this._linearAmplitude=!!e}get linearBoost(){return this._linearBoost}set linearBoost(e){this._linearBoost=e>=1?+e:1}get lineWidth(){return this._lineWidth}set lineWidth(e){this._lineWidth=+e||0}get loRes(){return this._loRes}set loRes(e){this._loRes=!!e,this._setCanvas(qg)}get lumiBars(){return this._lumiBars}set lumiBars(e){this._lumiBars=!!e,this._calcBars(),this._makeGrad()}get maxDecibels(){return this._analyzer[0].maxDecibels}set maxDecibels(e){for(const n of[0,1])this._analyzer[n].maxDecibels=e}get maxFPS(){return this._maxFPS}set maxFPS(e){this._maxFPS=e<0?0:+e||0}get maxFreq(){return this._maxFreq}set maxFreq(e){if(e<1)throw new We(Ir);this._maxFreq=Math.min(e,this.audioCtx.sampleRate/2),this._calcBars()}get minDecibels(){return this._analyzer[0].minDecibels}set minDecibels(e){for(const n of[0,1])this._analyzer[n].minDecibels=e}get minFreq(){return this._minFreq}set minFreq(e){if(e<1)throw new We(Ir);this._minFreq=+e,this._calcBars()}get mirror(){return this._mirror}set mirror(e){this._mirror=Math.sign(e)|0,this._calcBars(),this._makeGrad()}get mode(){return this._mode}set mode(e){const n=e|0;if(n>=0&&n<=10&&n!=9)this._mode=n,this._calcBars(),this._makeGrad();else throw new We(t_,e)}get noteLabels(){return this._noteLabels}set noteLabels(e){this._noteLabels=!!e,this._createScales()}get outlineBars(){return this._outlineBars}set outlineBars(e){this._outlineBars=!!e,this._calcBars()}get peakFadeTime(){return this._peakFadeTime}set peakFadeTime(e){this._peakFadeTime=e>=0?+e:this._peakFadeTime||Gn.peakFadeTime}get peakHoldTime(){return this._peakHoldTime}set peakHoldTime(e){this._peakHoldTime=+e||0}get peakLine(){return this._peakLine}set peakLine(e){this._peakLine=!!e}get radial(){return this._radial}set radial(e){this._radial=!!e,this._calcBars(),this._makeGrad()}get radialInvert(){return this._radialInvert}set radialInvert(e){this._radialInvert=!!e,this._calcBars(),this._makeGrad()}get radius(){return this._radius}set radius(e){this._radius=+e||0,this._calcBars(),this._makeGrad()}get reflexRatio(){return this._reflexRatio}set reflexRatio(e){if(e=+e||0,e<0||e>=1)throw new We(n_);this._reflexRatio=e,this._calcBars(),this._makeGrad()}get roundBars(){return this._roundBars}set roundBars(e){this._roundBars=!!e,this._calcBars()}get smoothing(){return this._analyzer[0].smoothingTimeConstant}set smoothing(e){for(const n of[0,1])this._analyzer[n].smoothingTimeConstant=e}get spinSpeed(){return this._spinSpeed}set spinSpeed(e){e=+e||0,(this._spinSpeed===void 0||e==0)&&(this._spinAngle=-Cr),this._spinSpeed=e}get splitGradient(){return this._splitGradient}set splitGradient(e){this._splitGradient=!!e,this._makeGrad()}get stereo(){return yu("stereo","channelLayout"),this._chLayout!=pt}set stereo(e){yu("stereo","channelLayout"),this.channelLayout=e?ot:pt}get trueLeds(){return this._trueLeds}set trueLeds(e){this._trueLeds=!!e}get volume(){return this._output.gain.value}set volume(e){this._output.gain.value=e}get weightingFilter(){return this._weightingFilter}set weightingFilter(e){this._weightingFilter=Ri(e,[au,cu,lu,uu,du,hu],"toUpperCase")}get width(){return this._width}set width(e){this._width=e,this._setCanvas(Tr)}get audioCtx(){return this._input.context}get canvas(){return this._ctx.canvas}get canvasCtx(){return this._ctx}get connectedSources(){return this._sources}get connectedTo(){return this._outNodes}get fps(){return this._fps}get fsHeight(){return this._fsHeight}get fsWidth(){return this._fsWidth}get isAlphaBars(){return this._flg.isAlpha}get isBandsMode(){return this._flg.isBands}get isDestroyed(){return this._destroyed}get isFullscreen(){return this._fsEl&&(document.fullscreenElement||document.webkitFullscreenElement)===this._fsEl}get isLedBars(){return this._flg.isLeds}get isLumiBars(){return this._flg.isLumi}get isOctaveBands(){return this._flg.isOctaves}get isOn(){return!!this._runId}get isOutlineBars(){return this._flg.isOutline}get pixelRatio(){return this._pixelRatio}get isRoundBars(){return this._flg.isRound}static get version(){return Ug}connectInput(e){const n=e instanceof HTMLMediaElement;if(!(n||e.connect))throw new We(i_);const i=n?this.audioCtx.createMediaElementSource(e):e;return this._sources.includes(i)||(i.connect(this._input),this._sources.push(i)),i}connectOutput(e=this.audioCtx.destination){if(!this._outNodes.includes(e)&&(this._output.connect(e),this._outNodes.push(e),this._outNodes.length==1))for(const n of[0,1])this._analyzer[n].connect(this._chLayout==pt&&!n?this._output:this._merger,0,n)}destroy(){if(!this._ready)return;const{audioCtx:e,canvas:n,_controller:i,_input:s,_merger:o,_observer:r,_ownCanvas:a,_ownContext:c,_splitter:l}=this;this._destroyed=!0,this._ready=!1,this.stop(),i.abort(),r&&r.disconnect(),this.onCanvasResize=null,this.onCanvasDraw=null,this._fsEl=null,this.disconnectInput(),this.disconnectOutput(),s.disconnect(),l.disconnect(),o.disconnect(),c&&e.close(),a&&n.remove(),this._calcBars()}disconnectInput(e,n){e?Array.isArray(e)||(e=[e]):e=Array.from(this._sources);for(const i of e){const s=this._sources.indexOf(i);if(n&&i.mediaStream)for(const o of i.mediaStream.getAudioTracks())o.stop();s>=0&&(i.disconnect(this._input),this._sources.splice(s,1))}}disconnectOutput(e){if(!(e&&!this._outNodes.includes(e))&&(this._output.disconnect(e),this._outNodes=e?this._outNodes.filter(n=>n!==e):[],this._outNodes.length==0))for(const n of[0,1])this._analyzer[n].disconnect()}getBars(){return Array.from(this._bars,({posX:e,freq:n,freqLo:i,freqHi:s,hold:o,peak:r,value:a})=>({posX:e,freq:n,freqLo:i,freqHi:s,hold:o,peak:r,value:a}))}getEnergy(e,n){if(e===void 0)return this._energy.val;if(e!=+e){if(e=="peak")return this._energy.peak;const a={bass:[20,250],lowMid:[250,500],mid:[500,2e3],highMid:[2e3,4e3],treble:[4e3,16e3]};if(!a[e])return null;[e,n]=a[e]}const i=this._freqToBin(e),s=n?this._freqToBin(n):i,o=this._chLayout==pt?1:2;let r=0;for(let a=0;a<o;a++)for(let c=i;c<=s;c++)r+=this._normalizedB(this._fftData[a][c]);return r/(s-i+1)/o}getOptions(e){Array.isArray(e)||(e=[e]);let n={};for(const i of Object.keys(Gn))e.includes(i)||(i=="gradient"&&this.gradientLeft!=this.gradientRight?(n.gradientLeft=this.gradientLeft,n.gradientRight=this.gradientRight):i!="start"&&(n[i]=this[i]));return n}registerGradient(e,n){if(typeof e!="string"||e.trim().length==0)throw new We(s_);if(typeof n!="object")throw new We(r_);const{colorStops:i}=n;if(!Array.isArray(i)||!i.length)throw new We(o_);const s=i.length,o=r=>+r!=r||r<0||r>1;i.forEach((r,a)=>{const c=a/Math.max(1,s-1);typeof r!="object"?i[a]={pos:c,color:r}:o(r.pos)&&(r.pos=c),o(r.level)&&(i[a].level=1-a/s)}),i.sort((r,a)=>r.level<a.level?1:r.level>a.level?-1:0),i[0].level=1,this._gradients[e]={bgColor:n.bgColor||Hg,dir:n.dir,colorStops:i},this._selectedGrads.includes(e)&&this._makeGrad()}setCanvasSize(e,n){this._width=e,this._height=n,this._setCanvas(Tr)}setFreqRange(e,n){if(e<1||n<1)throw new We(Ir);this._minFreq=Math.min(e,n),this.maxFreq=Math.max(e,n)}setLedParams(e){let n,i,s;e&&(n=e.maxLeds|0,i=+e.spaceV,s=+e.spaceH),this._ledParams=n>0&&i>0&&s>=0?[n,i,s]:void 0,this._calcBars()}setOptions(e){this._setProps(e)}setSensitivity(e,n){for(const i of[0,1])this._analyzer[i].minDecibels=Math.min(e,n),this._analyzer[i].maxDecibels=Math.max(e,n)}start(){this.toggleAnalyzer(!0)}stop(){this.toggleAnalyzer(!1)}toggleAnalyzer(e){const n=this.isOn;return e===void 0&&(e=!n),n&&!e?(cancelAnimationFrame(this._runId),this._runId=0):!n&&e&&!this._destroyed&&(this._frames=0,this._time=performance.now(),this._runId=requestAnimationFrame(i=>this._draw(i))),this.isOn}toggleFullscreen(){if(this.isFullscreen)document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen&&document.webkitExitFullscreen();else{const e=this._fsEl;if(!e)return;e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen()}}_binToFreq(e){return e*this.audioCtx.sampleRate/this.fftSize||1}_calcBars(){const e=this._bars=[];if(!this._ready){this._flg={isAlpha:!1,isBands:!1,isLeds:!1,isLumi:!1,isOctaves:!1,isOutline:!1,isRound:!1,noLedGap:!1};return}const{_ansiBands:n,_barSpace:i,canvas:s,_chLayout:o,_maxFreq:r,_minFreq:a,_mirror:c,_mode:l,_radial:d,_radialInvert:u,_reflexRatio:m}=this,g=s.width>>1,y=s.height>>1,w=o==ot&&!d,b=o==Ai,v=l%10!=0,S=v&&this._frequencyScale==on,k=this._showLeds&&v&&!d,I=this._lumiBars&&v&&!d,D=this._alphaBars&&!I&&l!=rn,O=this._outlineBars&&v&&!I&&!k,x=this._roundBars&&v&&!I&&!k,C=o!=ot||m>0&&!I,f=s.height-(w&&!k?.5:0)>>w,p=f*(I||d?1:1-m)|0,h=s.width-g*(b||c!=0),_=w?s.height-f*2:0,T=g*(c==-1&&!b&&!d);let P=Math.min(s.width,s.height)*.375*(o==ot?1:this._radius)|0,A=Math.min(g,y);u&&o!=ot&&([P,A]=[A,P]);const M=z=>e.push({...z,peak:[0,0],hold:[0],alpha:[0],value:[0]}),R=z=>{const Y=this._freqToBin(z,"floor"),Z=this._binToFreq(Y),ee=this._binToFreq(Y+1),de=Math.log2(z/Z)/Math.log2(ee/Z);return[Y,de]};let V,X,B;if(S){const z=(se,fe,ie)=>+se.toPrecision(ie?Math.max(fe,1+Math.log10(se)|0):fe),Y=se=>{const fe=[1,1.12,1.25,1.4,1.6,1.8,2,2.24,2.5,2.8,3.15,3.55,4,4.5,5,5.6,6.3,7.1,8,9,10],ie=Math.log10(se)|0,ct=se/10**ie;let Ze=1;for(;Ze<fe.length&&ct>fe[Ze];)Ze++;return ct-fe[Ze-1]<fe[Ze]-ct&&Ze--,(fe[Ze]*10**(ie+5)|0)/1e5},Z=[0,24,12,8,6,4,3,2,1][l],ee=n?10**(3/(Z*10)):2**(1/Z),de=ee**.5;let Re=n?7.94328235/(Z%2?1:de):eu;do{let se=Re;const fe=z(se/de,4,!0),ie=z(se*de,4,!0),[ct,Ze]=R(fe),[Xn,lt]=R(ie);n?se=Z<4?Y(se):z(se,se.toString()[0]<5?3:2):se=z(se,4,!0),se>=a&&M({posX:0,freq:se,freqLo:fe,freqHi:ie,binLo:ct,binHi:Xn,ratioLo:Ze,ratioHi:lt}),Re*=ee}while(Re<=r);V=h/e.length,e.forEach((se,fe)=>se.posX=T+fe*V);const he=e[0],Ae=e[e.length-1];X=this._freqScaling(he.freqLo),B=h/(this._freqScaling(Ae.freqHi)-X),he.freqLo<a&&(he.freqLo=a,[he.binLo,he.ratioLo]=R(a)),Ae.freqHi>r&&(Ae.freqHi=r,[Ae.binHi,Ae.ratioHi]=R(r))}else if(v){const z=[0,24,12,8,6,4,3,2,1][l]*10,Y=Z=>{switch(this._frequencyScale){case Er:return 1960/(26.81/(Z+.53)-1);case Ar:return 700*(2**Z-1);case Un:return Z}};V=h/z,X=this._freqScaling(a),B=h/(this._freqScaling(r)-X);for(let Z=0,ee=0;Z<z;Z++,ee+=V){const de=Y(X+ee/B),Re=Y(X+(ee+V/2)/B),he=Y(X+(ee+V)/B),[Ae,se]=R(de),[fe,ie]=R(he);M({posX:T+ee,freq:Re,freqLo:de,freqHi:he,binLo:Ae,binHi:fe,ratioLo:se,ratioHi:ie})}}else{V=1,X=this._freqScaling(a),B=h/(this._freqScaling(r)-X);const z=this._freqToBin(a,"floor"),Y=this._freqToBin(r);let Z=-999;for(let ee=z;ee<=Y;ee++){const de=this._binToFreq(ee),Re=T+Math.round(B*(this._freqScaling(de)-X));if(Re>Z)M({posX:Re,freq:de,freqLo:de,freqHi:de,binLo:ee,binHi:ee,ratioLo:0,ratioHi:0}),Z=Re;else if(e.length){const he=e[e.length-1];he.binHi=ee,he.freqHi=de,he.freq=(he.freqLo*de)**.5}}}let re=0,Q=0;if(k){const z=this._pixelRatio/(window.devicePixelRatio>1&&window.screen.height<=540?2:1),Y=[[],[128,3,.45],[128,4,.225],[96,6,.225],[80,6,.225],[80,6,.125],[64,6,.125],[48,8,.125],[24,16,.125]],Z=this._ledParams,[ee,de,Re]=Z||Y[l];let he,Ae=p;if(Z){const se=2*z;let fe;he=ee+1;do he--,fe=Ae/he/(1+de),Q=fe*de;while((fe<se||Q<se)&&he>1)}else{const se=540/de;Q=Math.min(de*z,Math.max(2,Ae/se+.1|0))}C&&(Ae+=Q),Z||(he=Math.min(ee,Ae/(Q*2)|0)),re=Re>=1?Re:V*Re,this._leds=[he,re,Q,Ae/he-Q]}const $=Math.min(V-1,i*(i>0&&i<1?V:1));v&&(V-=Math.max(k?re:0,$)),e.forEach((z,Y)=>{let Z=z.posX,ee=V;v&&(i==0&&!k?(Z|=0,ee|=0,Y>0&&Z>e[Y-1].posX+e[Y-1].width&&(Z--,ee++)):Z+=Math.max(k?re:0,$)/2,z.posX=Z),z.barCenter=Z+(V==1?0:ee/2),z.width=ee});const ce=[];for(const z of[0,1]){const Y=o==ot?(f+_)*z:0,Z=Y+f,ee=Y+p-(!k||C?0:Q);ce.push({channelTop:Y,channelBottom:Z,analyzerBottom:ee})}this._aux={analyzerHeight:p,analyzerWidth:h,centerX:g,centerY:y,channelCoords:ce,channelHeight:f,channelGap:_,initialX:T,innerRadius:P,outerRadius:A,scaleMin:X,unitWidth:B},this._flg={isAlpha:D,isBands:v,isLeds:k,isLumi:I,isOctaves:S,isOutline:O,isRound:x,noLedGap:C},this._createScales()}_createScales(){if(!this._ready)return;const{analyzerWidth:e,initialX:n,innerRadius:i,scaleMin:s,unitWidth:o}=this._aux,{canvas:r,_frequencyScale:a,_mirror:c,_noteLabels:l,_radial:d,_scaleX:u,_scaleR:m}=this,g=u.canvas,y=m.canvas,w=[],b=this._chLayout==Ai,v=this._chLayout==ot,S=Math.min(r.width,r.height),k=["C",,"D",,"E","F",,"G",,"A",,"B"],I=S/34|0,D=g.height>>1,O=I>>1,x=D*(l?.7:1.5),C=O*(l?1:2),f=2**(1/12);if(!l&&(this._ansiBands||a!=on))w.push(16,31.5,63,125,250,500,1e3,2e3,4e3),a==Un?w.push(6e3,8e3,1e4,12e3,14e3,16e3,18e3,2e4,22e3):w.push(8e3,16e3);else{let A=eu;for(let M=-1;M<11;M++)for(let R=0;R<12;R++){if(A>=this._minFreq&&A<=this._maxFreq){const V=k[R],X=V=="C";(V&&l&&!c&&!b||X)&&w.push(l?[A,V+(X?M:"")]:A)}A*=f}}y.width=y.height=Math.max(S*.15,(i<<1)+v*I);const p=y.width>>1,h=p-I*.7,_=(A,M)=>{const R=sn*(A/r.width),V=R-Cr,X=h*Math.cos(V),B=h*Math.sin(V);m.save(),m.translate(p+X,p+B),m.rotate(R),m.fillText(M,0,0),m.restore()};g.width|=0,u.fillStyle=m.strokeStyle=Xg,u.fillRect(0,0,g.width,g.height),m.arc(p,p,p-I/2,0,sn),m.lineWidth=I,m.stroke(),u.fillStyle=m.fillStyle=mu,u.font=`${D}px ${Pi}`,m.font=`${O}px ${Pi}`,u.textAlign=m.textAlign="center";let T=-x/4,P=-C;for(const A of w){const[M,R]=Array.isArray(A)?A:[A,A<1e3?A|0:`${(A/100|0)/10}k`],V=o*(this._freqScaling(M)-s),X=g.height*.75,B=R[0]=="C",re=D*(l&&!c&&!b?B?1.2:.6:3);if(u.fillStyle=m.fillStyle=B&&!c&&!b?Yg:mu,l){const Q=a==on,$=a==Un;let ce=["C"];if((Q||M>2e3||!$&&M>250||(!d||v)&&(!$&&M>125||M>1e3))&&ce.push("G"),(Q||M>4e3||!$&&M>500||(!d||v)&&(!$&&M>250||M>2e3))&&ce.push("E"),($&&M>4e3||(!d||v)&&(Q||M>2e3||!$&&M>500))&&ce.push("D","F","A","B"),!ce.includes(R[0]))continue}V>=T+x/2&&V<=e&&(u.fillText(R,b&&c==-1?e-V:n+V,X,re),(b||c&&(V>x||c==1))&&u.fillText(R,b&&c!=1?e+V:(n||r.width)-V,X,re),T=V+Math.min(re,u.measureText(R).width)/2),V>=P+C&&V<e-C&&(_(b&&c==1?e-V:V,R),(b||c&&(V>C||c==1))&&_(b&&c!=-1?e+V:-V,R),P=V)}}_draw(e){this._runId=requestAnimationFrame(N=>this._draw(N));const n=e-this._time,i=e-this._last,s=this._maxFPS?975/this._maxFPS:0;if(i<s)return;this._last=e-(s?i%s:0),this._frames++,n>=1e3&&(this._fps=this._frames/n*1e3,this._frames=0,this._time=e);const{isAlpha:o,isBands:r,isLeds:a,isLumi:c,isOctaves:l,isOutline:d,isRound:u,noLedGap:m}=this._flg,{analyzerHeight:g,centerX:y,centerY:w,channelCoords:b,channelHeight:v,channelGap:S,initialX:k,innerRadius:I,outerRadius:D}=this._aux,{_bars:O,canvas:x,_canvasGradients:C,_chLayout:f,_colorMode:p,_ctx:h,_energy:_,_fadePeaks:T,fillAlpha:P,_fps:A,_linearAmplitude:M,_lineWidth:R,maxDecibels:V,minDecibels:X,_mirror:B,_mode:re,overlay:Q,_radial:$,showBgColor:ce,showPeaks:z,useCanvas:Y,_weightingFilter:Z}=this,ee=this._scaleX.canvas,de=this._scaleR.canvas,Re=A*this._peakFadeTime/1e3,he=A**2,Ae=this._gravity*1e3,se=A*this._peakHoldTime/1e3,fe=f==tu,ie=f==Ai,ct=f==ot,Ze=f==pt,Xn=a&&this._trueLeds&&p==Ii,lt=$?x.width:this._aux.analyzerWidth,Ur=k+lt,Yn=z&&this._peakLine&&re==rn,kt=$?D-I:g,Bv=kt/this._pixelRatio,[jv,Kv,Zn,Gr]=this._leds||[];_.val>0&&A>0&&(this._spinAngle+=this._spinSpeed*sn/60/A);const $v=N=>{if(this._reflexRatio>0&&!c&&!$){let ne,ut;this.reflexFit||ct?(ne=ct&&N==0?v+S:0,ut=v-g):(ne=x.height-g*2,ut=g),h.save(),h.globalAlpha=this.reflexAlpha,this.reflexBright!=1&&(h.filter=`brightness(${this.reflexBright})`),h.setTransform(1,0,0,-1,0,x.height),h.drawImage(x,0,b[N].channelTop,x.width,g,0,ne,x.width,ut),h.restore()}},Uv=()=>{this.showScaleX&&($?(h.save(),h.translate(y,w),this._spinSpeed&&h.rotate(this._spinAngle+Cr),h.drawImage(de,-de.width>>1,-de.width>>1),h.restore()):h.drawImage(ee,0,x.height-ee.height))},Gv=N=>{const ne=N**2,ut=424.36,Ce=11599.29,ji=25122.25,Ct=544496.41,gt=148693636,jt=$t=>20*Math.log10($t);switch(Z){case cu:const $t=gt*ne**2/((ne+ut)*Math.sqrt((ne+Ce)*(ne+Ct))*(ne+gt));return 2+jt($t);case lu:const Ut=gt*ne*N/((ne+ut)*Math.sqrt(ne+ji)*(ne+gt));return .17+jt(Ut);case uu:const zr=gt*ne/((ne+ut)*(ne+gt));return .06+jt(zr);case du:const $i=((103791848e-2-ne)**2+108076816e-2*ne)/((9837328-ne)**2+11723776*ne),qr=N/68966888496476e-18*Math.sqrt($i/((ne+79919.29)*(ne+1345600)));return jt(qr);case hu:const Ui=-4737338981378384e-39*N**6+2043828333606125e-30*N**4-1363894795463638e-22*ne+1,Gt=1306612257412824e-34*N**5-2118150887518656e-26*N**3+.0005559488023498642*N,Be=.0001246332637532143*N/Math.hypot(Ui,Gt);return 18.2+jt(Be)}return 0},Hr=(N,ne,ut)=>{h.beginPath(),h.moveTo(N,ne),h.lineTo(N,ut),h.stroke()},Wr=N=>{if(N&&R){const ne=h.globalAlpha;h.globalAlpha=1,h.stroke(),h.globalAlpha=ne}},Bt=N=>Math.max(0,(N*jv|0)*(Gr+Zn)-Zn),Hv=N=>{_.val=N,_.peak>0&&(_.hold--,_.hold<0&&(_.peak+=_.hold*Ae/he/x.height*this._pixelRatio)),N>=_.peak&&(_.peak=N,_.hold=se)};Q&&h.clearRect(0,0,x.width,x.height);let ud=0;const dd=O.length,hd=Ze?1:2;for(let N=0;N<hd;N++){const{channelTop:ne,channelBottom:ut,analyzerBottom:Ce}=b[N],ji=this._gradients[this._selectedGrads[N]],Ct=ji.colorStops,gt=Ct.length,jt=!ce||a&&!Q?"#000":ji.bgColor,$t=ct&&$&&N?-1:1,Ut=!N&&B==-1||N&&B==1,zr=!ie||N&&B!=1?0:lt>>(N||!Ut),$i=ie&&Ut?-1:1,qr=()=>{const U=ee.height,H=U>>1,q=M?100:V,le=M?0:X,be=M?20:5,Ne=g/(q-le),dt=B!=-1&&(!ie||N==0||B==1),Tt=B!=1&&(!ie||N!=B);h.save(),h.fillStyle=gu,h.font=`${H}px ${Pi}`,h.textAlign="right",h.lineWidth=1;for(let Et=q;Et>le;Et-=be){const fn=ne+(q-Et)*Ne,xe=Et%2==0|0;if(xe){const Me=fn+H*(fn==ne?.8:.35);dt&&h.fillText(Et,U*.85,Me),Tt&&h.fillText(Et,(ie?lt:x.width)-U*.1,Me),h.strokeStyle=gu,h.setLineDash([2,4]),h.lineDashOffset=0}else h.strokeStyle=Zg,h.setLineDash([2,8]),h.lineDashOffset=1;h.beginPath(),h.moveTo(k+U*xe*dt,~~fn+.5),h.lineTo(Ur-U*xe*Tt,~~fn+.5),h.stroke()}h.restore()},Ui=(U,H)=>{const q=Je[U]+(U<Je.length-1?(Je[U+1]-Je[U])*H:0);return isNaN(q)?-1/0:q},Gt=(U,H=$i)=>H*sn*((U+zr)/x.width)+this._spinAngle,Be=(U,H,q)=>{const le=I+H*$t,be=Gt(U,q);return[y+le*Math.cos(be),w+le*Math.sin(be)]},Kr=(U,H,q,le,be)=>{h.beginPath();for(const Ne of B&&!ie?[1,-1]:[$i]){const[dt,Tt]=u?[Gt(U,Ne),Gt(U+q,Ne)]:[];h.moveTo(...Be(U,H,Ne)),h.lineTo(...Be(U,H+le,Ne)),u?h.arc(y,w,I+(H+le)*$t,dt,Tt,Ne!=1):h.lineTo(...Be(U+q,H+le,Ne)),h.lineTo(...Be(U+q,H,Ne)),u&&!be&&h.arc(y,w,I+H*$t,Tt,dt,Ne==1)}Wr(be),h.fill()},Xr=(U=0,H=0)=>{let q;if(p==Ii&&!Xn||re==rn)q=C[N];else{const le=p==nu?H%gt:Ct.findLastIndex(be=>a?Bt(U)<=Bt(be.level):U<=be.level);q=Ct[le].color}h.fillStyle=h.strokeStyle=q};if(Y){if(ie&&!$){const U=lt*(N+Ut),H=Ut?-1:1;h.setTransform(H,0,0,1,U,0)}if((!Q||ce)&&(Q&&(h.globalAlpha=this.bgAlpha),h.fillStyle=jt,(N==0||!$&&!fe)&&h.fillRect(k,ne-S,lt,(Q&&this.reflexAlpha==1?g:v)+S),h.globalAlpha=1),this.showScaleY&&!c&&!$&&(N==0||!fe)&&qr(),a?(h.setLineDash([Gr,Zn]),h.lineWidth=O[0].width):h.lineWidth=d?Math.min(R,O[0].width/2):R,h.save(),!$){const U=new Path2D;U.rect(0,ne,x.width,g),h.clip(U)}}let Je=this._fftData[N];this._analyzer[N].getFloatFrequencyData(Je),Z&&(Je=Je.map((U,H)=>U+Gv(this._binToFreq(H)))),h.beginPath();let Jn=[];for(let U=0;U<dd;U++){const H=O[U],{posX:q,barCenter:le,width:be,freq:Ne,binLo:dt,binHi:Tt,ratioLo:Et,ratioHi:fn}=H;let xe=Math.max(Ui(dt,Et),Ui(Tt,fn));for(let oe=dt+1;oe<Tt;oe++)Je[oe]>xe&&(xe=Je[oe]);if(xe=this._normalizedB(xe),H.value[N]=xe,ud+=xe,H.peak[N]>0&&H.alpha[N]>0&&(H.hold[N]--,H.hold[N]<0)){if(T&&!Yn){const oe=!o||d&&R>0?1:o?H.peak[N]:P;H.alpha[N]=oe*(1+H.hold[N]/Re)}else H.peak[N]+=H.hold[N]*Ae/he/Bv;H.alpha[N]<=0&&(H.peak[N]=0)}if(xe>=H.peak[N]&&(H.peak[N]=xe,H.hold[N]=se,H.alpha[N]=!o||d&&R>0?1:o?xe:P),!Y)continue;h.globalAlpha=c||o?xe:d?P:1,Xr(xe,U);const Me=c?kt:a?Bt(xe):xe*kt|0;if(re==rn){const oe=U?0:(this._normalizedB(Je[O[1].binLo])*kt+Me)/2;if($){if(U==0&&(ie&&h.moveTo(...Be(0,0)),h.lineTo(...Be(0,q<0?oe:Me))),q>=0){const qe=[q,Me];h.lineTo(...Be(...qe)),Jn.push(qe)}}else{if(U==0)if(B==-1&&!ie)h.moveTo(k,Ce-(q<k?oe:Me));else{const qe=dt?this._normalizedB(Je[dt-1])*kt:Me;h.moveTo(k-R,Ce-qe)}(ie||B!=-1||q>=k)&&h.lineTo(q,Ce-Me)}}else if(a){if(ce&&!Q&&(N==0||!fe)){const oe=h.globalAlpha;h.strokeStyle=zg,h.globalAlpha=1,Hr(le,ne,Ce),h.strokeStyle=h.fillStyle,h.globalAlpha=oe}if(Xn){const oe=c?0:Ct.findLastIndex(Ht=>Bt(xe)<=Bt(Ht.level));let qe=Ce;for(let Ht=gt-1;Ht>=oe;Ht--){h.strokeStyle=Ct[Ht].color;let pd=Ce-(Ht==oe?Me:Bt(Ct[Ht].level));Hr(le,qe,pd),qe=pd-Zn}}else Hr(le,Ce,Ce-Me)}else if(q>=k)if($)Kr(q,0,be,Me,d);else if(u){const oe=be/2,qe=Ce+oe;h.beginPath(),h.moveTo(q,qe),h.lineTo(q,qe-Me),h.arc(le,qe-Me,oe,kr,sn),h.lineTo(q+be,qe),Wr(d),h.fill()}else{const oe=d?h.lineWidth:0;h.beginPath(),h.rect(q,Ce+oe,be,-Me-oe),Wr(d),h.fill()}const pn=H.peak[N],fd=H.alpha[N];if(pn>0&&fd>0&&z&&!Yn&&!c&&q>=k&&q<Ur){if(T?h.globalAlpha=fd:d&&R>0?h.globalAlpha=1:o&&(h.globalAlpha=pn),(p==iu||Xn)&&Xr(pn),a){const oe=Bt(pn);oe>=Zn&&h.fillRect(q,Ce-oe,be,Gr)}else if(!$)h.fillRect(q,Ce-pn*kt,be,2);else if(re!=rn){const oe=pn*kt;Kr(q,oe,be,!this._radialInvert||ct||oe+I>=2?-2:2)}}}if(Y){if(h.globalAlpha=1,re==rn){if(Xr(),$&&!ie){if(B){let U;for(;U=Jn.pop();)h.lineTo(...Be(...U,-1))}h.closePath()}if(R>0&&h.stroke(),P>0){if($){const U=ie?Gt(lt>>1):0,H=ie?Gt(lt):sn;h.moveTo(...Be(ie?lt>>1:0,0)),h.arc(y,w,I,U,H,ie?!Ut:!0)}else h.lineTo(Ur,Ce),h.lineTo(k,Ce);h.globalAlpha=P,h.fill(),h.globalAlpha=1}if((Yn||$&&z)&&(Jn=[],h.beginPath(),O.forEach((U,H)=>{let q=U.posX,le=U.peak[N],be=H?"lineTo":"moveTo";if($&&q<0){const Ne=O[H+1];le=a_(q,le,Ne.posX,Ne.peak[N],0),q=0}le*=kt,Yn?(h[be](...$?Be(q,le):[q,Ce-le]),$&&B&&!ie&&Jn.push([q,le])):le>0&&Kr(q,le,1,-2)}),Yn)){let U;for(;U=Jn.pop();)h.lineTo(...Be(...U,-1));h.lineWidth=1,h.stroke()}}h.restore(),ie&&!$&&h.setTransform(1,0,0,1,0,0),(!ie&&!fe||N)&&$v(N)}}if(Hv(ud/(dd<<hd-1)),Y&&(B&&!$&&!ie&&(h.setTransform(-1,0,0,1,x.width-k,0),h.drawImage(x,k,0,y,x.height,0,0,y,x.height),h.setTransform(1,0,0,1,0,0)),h.setLineDash([]),Uv()),this.showFPS){const N=ee.height;h.font=`bold ${N}px ${Pi}`,h.fillStyle=Wg,h.textAlign="right",h.fillText(Math.round(A),x.width-N,N*2)}this.onCanvasDraw&&(h.save(),h.fillStyle=h.strokeStyle=C[0],this.onCanvasDraw(this,{timestamp:e,canvasGradients:C}),h.restore())}_freqScaling(e){switch(this._frequencyScale){case on:return Math.log2(e);case Er:return 26.81*e/(1960+e)-.53;case Ar:return Math.log2(1+e/700);case Un:return e}}_freqToBin(e,n="round"){const i=this._analyzer[0].frequencyBinCount-1,s=Math[n](e*this.fftSize/this.audioCtx.sampleRate);return s<i?s:i}_makeGrad(){if(!this._ready)return;const{canvas:e,_ctx:n,_radial:i,_reflexRatio:s}=this,{analyzerWidth:o,centerX:r,centerY:a,initialX:c,innerRadius:l,outerRadius:d}=this._aux,{isLumi:u}=this._flg,m=this._chLayout==ot,g=1-s,y=u?e.height:e.height*(1-s*!m)|0;for(const w of[0,1]){const b=this._gradients[this._selectedGrads[w]],v=b.colorStops,S=b.dir=="h";let k;if(i?k=n.createRadialGradient(r,a,d,r,a,l-(d-l)*m):k=n.createLinearGradient(...S?[c,0,c+o,0]:[0,0,0,y]),v){const I=m&&!this._splitGradient&&(!S||i);for(let D=0;D<1+I;D++){const O=v.length-1;v.forEach((x,C)=>{let f=x.pos;if(I&&(f/=2),m&&!u&&!i&&!S&&(f*=g,!I&&f>.5*g&&(f+=.5*s)),D==1)if(i||u){const p=O-C;x=v[p],f=1-x.pos/2}else C==0&&f>0&&k.addColorStop(.5,x.color),f+=.5;k.addColorStop(f,x.color),m&&C==O&&f<.5&&k.addColorStop(.5,x.color)})}}this._canvasGradients[w]=k}}_normalizedB(e){const n=this._linearAmplitude,i=n?1/this._linearBoost:1,s=(c,l,d)=>c<=l?l:c>=d?d:c,o=c=>10**(c/20);let r=this.maxDecibels,a=this.minDecibels;return n&&(r=o(r),a=o(a),e=o(e)**i),s((e-a)/(r-a)**i,0,1)}_setCanvas(e){if(!this._ready)return;const{canvas:n,_ctx:i}=this,s=this._scaleX.canvas,o=window.devicePixelRatio/(this._loRes+1);let r=window.screen.width*o,a=window.screen.height*o;Math.abs(window.orientation)==90&&r<a&&([r,a]=[a,r]);const c=this.isFullscreen,l=c&&this._fsEl==n,d=l?r:(this._width||this._container.clientWidth||this._defaultWidth)*o|0,u=l?a:(this._height||this._container.clientHeight||this._defaultHeight)*o|0;this._pixelRatio=o,this._fsWidth=r,this._fsHeight=a,!(e!=fu&&n.width==d&&n.height==u)&&(n.width=d,n.height=u,this.overlay||(i.fillStyle="#000",i.fillRect(0,0,d,u)),i.lineJoin="bevel",s.width=d,s.height=Math.max(20*o,Math.min(d,u)/32|0),this._calcBars(),this._makeGrad(),this._fsStatus!==void 0&&this._fsStatus!==c&&(e=pu),this._fsStatus=c,this.onCanvasResize&&this.onCanvasResize(e,this))}_setGradient(e,n){if(!this._gradients.hasOwnProperty(e))throw new We(e_,e);[0,1].includes(n)||(this._selectedGrads[1]=e,n=0),this._selectedGrads[n]=e,this._makeGrad()}_setProps(e,n){const i=["onCanvasDraw","onCanvasResize"],s=["gradientLeft","gradientRight","stereo"],o=Object.keys(Gn).filter(r=>r!="start").concat(i,s);(n||e===void 0)&&(e={...Gn,...e});for(const r of Object.keys(e))i.includes(r)&&typeof e[r]!="function"?this[r]=void 0:o.includes(r)&&(this[r]=e[r]);e.start!==void 0&&this.toggleAnalyzer(e.start)}}const l_={verdant:{colorStops:[{color:"#D3FFA6",pos:0},{color:"#036B5B",pos:.5},{color:"#D3FFA6",pos:1}]},twilight:{colorStops:[{color:"#81B9FF",pos:0},{color:"#371A5E",pos:.5},{color:"#81B9FF",pos:1}]},bloom:{colorStops:[{color:"#FFD4FE",pos:0},{color:"#FD05F9",pos:.5},{color:"#FFD4FE",pos:1}]},mystic:{colorStops:[{color:"#1F023A",pos:0},{color:"#CA76FF",pos:.5},{color:"#1F023A",pos:1}]},flare:{colorStops:[{color:"#FFFFFF",pos:0},{color:"#FC5F00",pos:.5},{color:"#FFFFFF",pos:1}]},glacier:{colorStops:[{color:"#4CE5F2",pos:0},{color:"#005A98",pos:.5},{color:"#4CE5F2",pos:1}]}},wu=({stream:t,className:e,onClick:n})=>{var o;const i=De(null),s=Nt();return $e(()=>{var l;if(!i.current||!t)return;const r=new AudioContext,a=r.createMediaStreamSource(t),c=new c_(i.current,{source:a,audioCtx:r,alphaBars:!1,ansiBands:!1,barSpace:.25,bgAlpha:0,channelLayout:"single",colorMode:"gradient",fadePeaks:!1,fftSize:2048,fillAlpha:0,frequencyScale:"log",gravity:3.8,ledBars:!1,linearAmplitude:!0,linearBoost:2,lineWidth:1.5,loRes:!1,lumiBars:!1,maxDecibels:-20,maxFPS:0,maxFreq:16e3,minDecibels:-90,minFreq:30,mirror:0,mode:7,noteLabels:!1,outlineBars:!1,overlay:!0,peakFadeTime:750,peakHoldTime:500,peakLine:!1,radial:!1,radialInvert:!1,radius:.7,reflexAlpha:1,reflexBright:1,reflexFit:!0,reflexRatio:.5,roundBars:!0,showBgColor:!1,showFPS:!1,showPeaks:!1,showScaleX:!1,showScaleY:!1,smoothing:.7,spinSpeed:0,splitGradient:!1,trueLeds:!1,useCanvas:!0,volume:1,weightingFilter:"D"});return c.registerGradient("gradient",l_[((l=s.audio_visualizer_config)==null?void 0:l.color)||"verdant"]),c.gradient="gradient",()=>{c.destroy()}},[(o=s.audio_visualizer_config)==null?void 0:o.color,t]),E("div",{onClick:n,className:xt("w-full",e),ref:i})};/**
|
|
17
17
|
* @license lucide-preact v0.515.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const xu=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),u_=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,i)=>i?i.toUpperCase():n.toLowerCase()),Su=t=>{const e=u_(t);return e.charAt(0).toUpperCase()+e.slice(1)},d_=(...t)=>t.filter((e,n,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===n).join(" ").trim();/**
|
|
22
22
|
* @license lucide-preact v0.515.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/var
|
|
26
|
+
*/var h_={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"};/**
|
|
27
27
|
* @license lucide-preact v0.515.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const
|
|
31
|
+
*/const f_=({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:i,children:s,iconNode:o,class:r="",...a})=>je("svg",{...h_,width:String(e),height:e,stroke:t,"stroke-width":i?Number(n)*24/Number(e):n,class:["lucide",r].join(" "),...a},[...o.map(([c,l])=>je(c,l)),...tt(s)]);/**
|
|
32
32
|
* @license lucide-preact v0.515.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const
|
|
36
|
+
*/const Ve=(t,e)=>{const n=({class:i="",children:s,...o})=>je(f_,{...o,iconNode:e,class:d_(`lucide-${xu(Su(t))}`,`lucide-${xu(t)}`,i)},s);return n.displayName=Su(t),n};/**
|
|
37
37
|
* @license lucide-preact v0.515.0 - ISC
|
|
38
38
|
*
|
|
39
39
|
* This source code is licensed under the ISC license.
|
|
40
40
|
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const
|
|
41
|
+
*/const p_=Ve("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
|
42
42
|
* @license lucide-preact v0.515.0 - ISC
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the ISC license.
|
|
45
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const ku=
|
|
46
|
+
*/const ku=Ve("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);/**
|
|
47
47
|
* @license lucide-preact v0.515.0 - ISC
|
|
48
48
|
*
|
|
49
49
|
* This source code is licensed under the ISC license.
|
|
50
50
|
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const
|
|
51
|
+
*/const m_=Ve("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
|
|
52
52
|
* @license lucide-preact v0.515.0 - ISC
|
|
53
53
|
*
|
|
54
54
|
* This source code is licensed under the ISC license.
|
|
55
55
|
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const
|
|
56
|
+
*/const g_=Ve("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
|
|
57
57
|
* @license lucide-preact v0.515.0 - ISC
|
|
58
58
|
*
|
|
59
59
|
* This source code is licensed under the ISC license.
|
|
60
60
|
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const
|
|
61
|
+
*/const __=Ve("mic-off",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M18.89 13.23A7.12 7.12 0 0 0 19 12v-2",key:"80xlxr"}],["path",{d:"M5 10v2a7 7 0 0 0 12 5",key:"p2k8kg"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/**
|
|
62
62
|
* @license lucide-preact v0.515.0 - ISC
|
|
63
63
|
*
|
|
64
64
|
* This source code is licensed under the ISC license.
|
|
65
65
|
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const
|
|
66
|
+
*/const v_=Ve("mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/**
|
|
67
67
|
* @license lucide-preact v0.515.0 - ISC
|
|
68
68
|
*
|
|
69
69
|
* This source code is licensed under the ISC license.
|
|
70
70
|
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const
|
|
71
|
+
*/const y_=Ve("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]);/**
|
|
72
72
|
* @license lucide-preact v0.515.0 - ISC
|
|
73
73
|
*
|
|
74
74
|
* This source code is licensed under the ISC license.
|
|
75
75
|
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
-
*/const
|
|
76
|
+
*/const b_=Ve("phone-off",[["path",{d:"M10.1 13.9a14 14 0 0 0 3.732 2.668 1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 18 18 0 0 1-12.728-5.272",key:"1wngk7"}],["path",{d:"M22 2 2 22",key:"y4kqgn"}],["path",{d:"M4.76 13.582A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 .244.473",key:"10hv5p"}]]);/**
|
|
77
77
|
* @license lucide-preact v0.515.0 - ISC
|
|
78
78
|
*
|
|
79
79
|
* This source code is licensed under the ISC license.
|
|
80
80
|
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
-
*/const
|
|
81
|
+
*/const w_=Ve("send-horizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]);/**
|
|
82
82
|
* @license lucide-preact v0.515.0 - ISC
|
|
83
83
|
*
|
|
84
84
|
* This source code is licensed under the ISC license.
|
|
85
85
|
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
-
*/const
|
|
86
|
+
*/const x_=Ve("square-arrow-out-up-right",[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]]);/**
|
|
87
87
|
* @license lucide-preact v0.515.0 - ISC
|
|
88
88
|
*
|
|
89
89
|
* This source code is licensed under the ISC license.
|
|
90
90
|
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
-
*/const
|
|
91
|
+
*/const S_=Ve("thumbs-up",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);/**
|
|
92
92
|
* @license lucide-preact v0.515.0 - ISC
|
|
93
93
|
*
|
|
94
94
|
* This source code is licensed under the ISC license.
|
|
95
95
|
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
-
*/const
|
|
96
|
+
*/const k_=Ve("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
97
97
|
* @license lucide-preact v0.515.0 - ISC
|
|
98
98
|
*
|
|
99
99
|
* This source code is licensed under the ISC license.
|
|
100
100
|
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
-
*/const Tu=Vt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Cv=xr(!1),kv=()=>Yc(Cv),Ve=({children:e,className:t,onClick:n,tooltip:i})=>E("button",{title:i,onClick:n,className:xe("w-8 h-8 rounded-full cursor-pointer text-white flex items-center justify-center",t),children:e}),Eu=({call:e})=>{const[t,n]=kv(),i=()=>{n(o=>{const r=!o;return r?e.muteAudio():e.unmuteAudio(),r})},s=()=>{e.hangup()};return E("div",{className:"flex items-center justify-center gap-2",children:[E(Ve,{tooltip:t?"Unmute":"Mute",onClick:i,className:xe(t?"bg-[#F36666] dark:bg-[#750000]":"bg-[#E6E3D3] dark:bg-[#3C3C3C]"),children:t?E(gv,{className:"w-5 h-5 text-black dark:text-white"}):E(vv,{className:"w-5 h-5 text-black dark:text-white"})}),E(Ve,{tooltip:"End Call",onClick:s,className:"bg-[#F36666] text-black dark:text-black dark:bg-[#750000]",children:E(yv,{className:"w-4 h-4 text-black dark:text-white"})})]})},Au=({call:e,onExpand:t})=>E(Bn.div,{layoutId:Ci,className:"bg-[#FEFDF5] text-black p-4 rounded-3xl w-[250px] overflow-hidden flex flex-col items-center justify-center dark:bg-black dark:text-white shadow-lg shadow-[#38383878] gap-3",children:[E(xu,{onClick:t,className:"h-[72px] cursor-pointer",stream:e.remoteStream}),E(tu,{stream:e.remoteStream}),E(Qc,{size:"small"}),E(Eu,{call:e})]});function Tv(){const[e,t]=Xt(!1),n=Ne();if(!n.give_feedback_url&&!n.report_issue_url&&!n.view_history_url)return null;const i=a=>{a&&window.open(a,"_blank","noopener,noreferrer"),t(!1)},s=()=>{i(n.give_feedback_url)},o=()=>{i(n.report_issue_url)},r=()=>{i(n.view_history_url)};return E("div",{children:[E(Ve,{tooltip:"More",onClick:()=>t(!e),children:E(ku,{className:"text-black dark:text-white"})}),e&&E("div",{className:"absolute p-4 w-[200px] min-h-[180px] top-0 left-0 bg-[#FEFDF599] dark:bg-[#38383C96] rounded-3xl backdrop-blur-xs z-10",children:[E(Ve,{tooltip:"More",onClick:()=>t(!e),children:E(ku,{className:"text-black dark:text-white"})}),E("ul",{className:"text-sm font-semibold divide-y text-left divider-solid divide-[#3D3D46]",children:[n.give_feedback_url&&E("li",{onClick:s,className:"flex items-center gap-2 px-4 py-3 border-solid cursor-pointer",children:["Give Feedback ",E(xv,{className:"w-4 h-4"})]}),n.report_issue_url&&E("li",{onClick:o,className:"flex items-center gap-2 px-4 py-3 border-solid cursor-pointer",children:["Report Issue ",E(Sv,{className:"w-4 h-4"})]}),n.view_history_url&&E("li",{onClick:r,className:"flex items-center gap-2 px-4 py-3 border-solid cursor-pointer",children:["View History ",E(pv,{className:"w-4 h-4"})]})]})]})]})}function Ev({item:e,containerRef:t}){const n=Mt(null);return $t(()=>{var i;n.current&&((i=t==null?void 0:t.current)==null||i.scrollTo({top:n.current.offsetTop,behavior:"smooth"}))},[t]),E("li",{className:xe("flex flex-col gap-1 text-left",{"items-end":e.role==="user"}),ref:n,children:[E("span",{className:"text-xs text-[#969696]",children:e.timestamp.toLocaleTimeString()}),E("div",{className:xe("flex flex-col gap-2",{"items-end":e.role==="user"}),children:[e.attachments&&e.attachments.length>0&&E("div",{className:"flex flex-wrap gap-2",children:e.attachments.map((i,s)=>i.type==="image"&&E("img",{src:i.url,alt:"Attached image",className:"max-w-32 max-h-32 object-cover rounded-lg border border-[#969696] dark:border-[#3D3D46]"},s))}),e.content&&E("p",{className:xe("text-sm",{"bg-[#FEFDF5] dark:bg-[#222227] px-2.5 py-2 rounded-md":e.role==="user"}),children:e.content})]})]})}const Av=({transcript:e,call:t})=>{const n=Mt(null),i=Mt(null),s=Mt(null),[o,r]=Xt([]);$t(()=>()=>{o.forEach(b=>URL.revokeObjectURL(b.preview))},[o]);const a=b=>new Promise((w,y)=>{const S=new FileReader;S.onload=()=>w(S.result),S.onerror=y,S.readAsDataURL(b)}),l=async b=>{if(b.type.startsWith("image/"))try{const w=await a(b),y=URL.createObjectURL(b),S={id:Date.now().toString(),file:b,base64:w,preview:y};r(C=>[...C,S])}catch(w){console.error("Error processing image:",w)}},c=b=>{r(w=>{const y=w.find(S=>S.id===b);return y&&URL.revokeObjectURL(y.preview),w.filter(S=>S.id!==b)})},d=b=>{const w=b.target,y=w.files;y&&y.length>0&&(Array.from(y).forEach(l),w.value="")},u=b=>{var y;const w=(y=b.clipboardData)==null?void 0:y.items;w&&Array.from(w).forEach(S=>{if(S.type.startsWith("image/")){const C=S.getAsFile();C&&l(C)}})},p=()=>{var b;(b=i.current)==null||b.click()},g=async()=>{var y;const b=n.current&&n.current.value.trim()!=="",w=o.length>0;if(b||w){const S=((y=n.current)==null?void 0:y.value)||"";t.sendConversationMessage(S,o.map(C=>C.base64)),n.current&&(n.current.value=""),o.forEach(C=>URL.revokeObjectURL(C.preview)),r([])}},_=b=>{b.key==="Enter"&&(b.preventDefault(),g())};return E("div",{className:"h-[300px] sm:h-[386px] bg-[#E6E3D3] dark:bg-[#38383C] rounded-t-3xl sm:rounded-3xl p-4 flex flex-col w-full",children:[E("ul",{className:"flex flex-col flex-1 gap-4 p-4 overflow-y-auto",ref:s,children:e.map((b,w)=>E(Ev,{item:b,containerRef:s},b.id+w))}),o.length>0&&E("div",{className:"flex flex-wrap gap-2 mb-2",children:o.map(b=>E("div",{className:"relative",children:[E("img",{src:b.preview,alt:"Preview",className:"w-16 h-16 object-cover rounded-lg border border-[#969696] dark:border-[#3D3D46]"}),E("button",{onClick:()=>c(b.id),className:"absolute flex items-center justify-center w-5 h-5 text-xs text-white bg-red-500 rounded-full -top-1 -right-1 hover:bg-red-600",title:"Remove image",children:E(Tu,{className:"w-3 h-3"})})]},b.id))}),E("div",{className:"flex items-center h-8 bg-[#FEFDF5] border border-[#969696] dark:border-[#3D3D46] dark:bg-[#222227] rounded-full p-2 gap-2",children:[E("input",{ref:n,type:"text",onKeyDown:_,onPaste:u,placeholder:"Type something here",className:"w-full text-sm bg-transparent outline-none dark:text-white"}),E("input",{ref:i,type:"file",accept:"image/*",multiple:!0,onChange:d,className:"hidden"}),E(Ve,{tooltip:"Attach image",onClick:p,children:E(_v,{className:"text-[#969696] w-4 h-4"})}),E(Ve,{tooltip:"Send",children:E(bv,{onClick:g,className:"text-[#969696] w-4 h-4"})})]})]})};function Rv({onCollapse:e}){return E("div",{className:"flex items-center justify-between w-full",children:[E(Tv,{}),E(Ve,{tooltip:"Collapse",className:"ml-auto",onClick:e,children:E(Tu,{className:"text-black dark:text-white"})})]})}const Iv=({call:e,onCollapse:t,transcript:n})=>E(Hf,{children:E(Bn.div,{exit:{opacity:0,scale:.95},initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},layoutId:"transcript-widget",className:"relative bg-[#FEFDF5] text-black dark:bg-black gap-3 w-full sm:w-[400px] dark:text-white rounded-t-3xl sm:rounded-3xl shadow-lg shadow-[#38383878]",children:[E("div",{className:"p-4 text-center",children:[E(Rv,{onCollapse:t}),E(xu,{className:"h-[144px]",stream:e.remoteStream}),E(Qc,{size:"large",className:"mb-4"}),E(Eu,{call:e})]}),E(tu,{stream:e.remoteStream}),E(Av,{call:e,transcript:n})]})});function Mr(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(i=Object.getOwnPropertySymbols(e);s<i.length;s++)t.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(e,i[s])&&(n[i[s]]=e[i[s]])}return n}function H(e,t,n,i){return new(n||(n=Promise))(function(s,o){function r(c){try{l(i.next(c))}catch(d){o(d)}}function a(c){try{l(i.throw(c))}catch(d){o(d)}}function l(c){var d;c.done?s(c.value):(d=c.value,d instanceof n?d:new n(function(u){u(d)})).then(r,a)}l((i=i.apply(e,[])).next())})}typeof SuppressedError=="function"&&SuppressedError;var Ru=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),Pv=new Uint8Array(16);function Mv(){if(!Ru)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ru(Pv)}for(var Iu=[],Li=0;Li<256;++Li)Iu[Li]=(Li+256).toString(16).substr(1);function an(e,t,n){var i=t&&n||0;typeof e=="string"&&(t=e==="binary"?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||Mv)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var o=0;o<16;++o)t[i+o]=s[o];return t||function(r,a){var l=0,c=Iu;return[c[r[l++]],c[r[l++]],c[r[l++]],c[r[l++]],"-",c[r[l++]],c[r[l++]],"-",c[r[l++]],c[r[l++]],"-",c[r[l++]],c[r[l++]],"-",c[r[l++]],c[r[l++]],c[r[l++]],c[r[l++]],c[r[l++]],c[r[l++]]].join("")}(s)}const Pu="Time to call invite",Mu="wss://rtc.telnyx.com",Lv={urls:"stun:stun.l.google.com:19302"},Dv={urls:"stun:stun.telnyx.com:3478"},Lu={urls:"turn:turn.telnyx.com:3478?transport=tcp",username:"testuser",credential:"testpassword"};var V;(function(e){e.SocketOpen="telnyx.socket.open",e.SocketClose="telnyx.socket.close",e.SocketError="telnyx.socket.error",e.SocketMessage="telnyx.socket.message",e.SpeedTest="telnyx.internal.speedtest",e.Ready="telnyx.ready",e.Error="telnyx.error",e.Notification="telnyx.notification",e.StatsFrame="telnyx.stats.frame",e.StatsReport="telnyx.stats.report",e.Messages="telnyx.messages",e.Calls="telnyx.calls",e.MediaError="telnyx.rtc.mediaError"})(V||(V={}));var Ov=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Du(e,t){return e(t={exports:{}},t.exports),t.exports}var Nv=Du(function(e){var t,n;t=Ov,n=function(){var i=function(){},s="undefined",o=typeof window!==s&&typeof window.navigator!==s&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"];function a(w,y){var S=w[y];if(typeof S.bind=="function")return S.bind(w);try{return Function.prototype.bind.call(S,w)}catch{return function(){return Function.prototype.apply.apply(S,[w,arguments])}}}function l(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(w,y){for(var S=0;S<r.length;S++){var C=r[S];this[C]=S<w?i:this.methodFactory(C,w,y)}this.log=this.debug}function d(w,y,S){return function(){typeof console!==s&&(c.call(this,y,S),this[w].apply(this,arguments))}}function u(w,y,S){return function(C){return C==="debug"&&(C="log"),typeof console!==s&&(C==="trace"&&o?l:console[C]!==void 0?a(console,C):console.log!==void 0?a(console,"log"):i)}(w)||d.apply(this,arguments)}function p(w,y,S){var C,P=this;y=y??"WARN";var L="loglevel";function D(){var k;if(typeof window!==s&&L){try{k=window.localStorage[L]}catch{}if(typeof k===s)try{var f=window.document.cookie,m=f.indexOf(encodeURIComponent(L)+"=");m!==-1&&(k=/^([^;]+)/.exec(f.slice(m))[1])}catch{}return P.levels[k]===void 0&&(k=void 0),k}}typeof w=="string"?L+=":"+w:typeof w=="symbol"&&(L=void 0),P.name=w,P.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},P.methodFactory=S||u,P.getLevel=function(){return C},P.setLevel=function(k,f){if(typeof k=="string"&&P.levels[k.toUpperCase()]!==void 0&&(k=P.levels[k.toUpperCase()]),!(typeof k=="number"&&k>=0&&k<=P.levels.SILENT))throw"log.setLevel() called with invalid level: "+k;if(C=k,f!==!1&&function(m){var h=(r[m]||"silent").toUpperCase();if(typeof window!==s&&L){try{return void(window.localStorage[L]=h)}catch{}try{window.document.cookie=encodeURIComponent(L)+"="+h+";"}catch{}}}(k),c.call(P,k,w),typeof console===s&&k<P.levels.SILENT)return"No console available for logging"},P.setDefaultLevel=function(k){y=k,D()||P.setLevel(k,!1)},P.resetLevel=function(){P.setLevel(y,!1),function(){if(typeof window!==s&&L){try{return void window.localStorage.removeItem(L)}catch{}try{window.document.cookie=encodeURIComponent(L)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}()},P.enableAll=function(k){P.setLevel(P.levels.TRACE,k)},P.disableAll=function(k){P.setLevel(P.levels.SILENT,k)};var x=D();x==null&&(x=y),P.setLevel(x,!1)}var g=new p,_={};g.getLogger=function(w){if(typeof w!="symbol"&&typeof w!="string"||w==="")throw new TypeError("You must supply a name when creating a logger.");var y=_[w];return y||(y=_[w]=new p(w,g.getLevel(),g.methodFactory)),y};var b=typeof window!==s?window.log:void 0;return g.noConflict=function(){return typeof window!==s&&window.log===g&&(window.log=b),g},g.getLoggers=function(){return _},g.default=g,g},e.exports?e.exports=n():t.log=n()});const B=Nv.getLogger("telnyx"),Vv=B.methodFactory;B.methodFactory=(e,t,n)=>{const i=Vv(e,t,n);return function(){const s=[new Date().toISOString().replace("T"," ").replace("Z",""),"-"];for(let o=0;o<arguments.length;o++)s.push(arguments[o]);i.apply(void 0,s)}},B.setLevel(B.getLevel());const Ou=e=>Object.keys(e).length===0,Di=e=>{const[t,n,i,s,o,r]=e;let a={};try{a=JSON.parse(o.replace(/ID"/g,'Id"'))}catch{B.warn("Verto LA invalid media JSON string:",o)}return{participantId:Number(t),participantNumber:n,participantName:i,codec:s,media:a,participantData:r}},Nu=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},ln=e=>e instanceof Function||typeof e=="function",Gn=e=>typeof document=="object"&&"getElementById"in document?typeof e=="string"?document.getElementById(e)||null:typeof e=="function"?e():e instanceof HTMLMediaElement?e:null:null,Fv=/^(ws|wss):\/\//,Vu=(e,t=null)=>{const{result:n={},error:i}=e;if(i)return{error:i};const{result:s=null}=n;if(s===null)return t!==null&&(n.node_id=t),{result:n};const{code:o=null,node_id:r=null,result:a=null}=s;return o&&o!=="200"?{error:s}:a?Vu(a,r):{result:s}},Fu=(e,t)=>Math.floor(Math.random()*(t-e+1)+e),Lr=({login:e,passwd:t,password:n,login_token:i})=>!!(e&&(t||n)||i),Oi=({anonymous_login:e})=>!!e&&!!e.target_id&&!!e.target_type,Dr=e=>{var t,n,i,s,o,r;let a="",l="";return!((n=(t=e==null?void 0:e.result)===null||t===void 0?void 0:t.params)===null||n===void 0)&&n.state&&(a=(s=(i=e==null?void 0:e.result)===null||i===void 0?void 0:i.params)===null||s===void 0?void 0:s.state),!((o=e==null?void 0:e.params)===null||o===void 0)&&o.state&&(l=(r=e==null?void 0:e.params)===null||r===void 0?void 0:r.state),a||l};function Bu({debounceTime:e}){let t,n;return{promise:new Promise((i,s)=>{t=e?Bv(i,e):i,n=s}),resolve:t,reject:n}}const Bv=(e,t)=>{let n;return(...i)=>{clearTimeout(n),n=window.setTimeout(()=>{e(...i)},t)}},Or="telnyx-voice-sdk-id";function Nr(){return sessionStorage.getItem(Or)}var Ft,Se,nt;typeof window<"u"&&window.addEventListener("beforeunload",()=>{sessionStorage.removeItem(Or)}),function(e){e.Offer="offer",e.Answer="answer"}(Ft||(Ft={})),function(e){e.Inbound="inbound",e.Outbound="outbound"}(Se||(Se={})),function(e){e.Invite="telnyx_rtc.invite",e.Attach="telnyx_rtc.attach",e.Answer="telnyx_rtc.answer",e.Info="telnyx_rtc.info",e.Display="telnyx_rtc.display",e.Media="telnyx_rtc.media",e.Event="telnyx_rtc.event",e.Bye="telnyx_rtc.bye",e.Punt="telnyx_rtc.punt",e.Broadcast="telnyx_rtc.broadcast",e.Subscribe="telnyx_rtc.subscribe",e.Unsubscribe="telnyx_rtc.unsubscribe",e.ClientReady="telnyx_rtc.clientReady",e.Modify="telnyx_rtc.modify",e.Ringing="telnyx_rtc.ringing",e.GatewayState="telnyx_rtc.gatewayState",e.Ping="telnyx_rtc.ping",e.Pong="telnyx_rtc.pong"}(nt||(nt={}));const ae={generic:"event",[nt.Display]:"participantData",[nt.Attach]:"participantData",conferenceUpdate:"conferenceUpdate",callUpdate:"callUpdate",vertoClientReady:"vertoClientReady",userMediaError:"userMediaError"},jv={destinationNumber:"",remoteCallerName:"Outbound Call",remoteCallerNumber:"",callerName:"",callerNumber:"",audio:!0,video:!1,useStereo:!1,debug:!1,debugOutput:"socket",attach:!1,screenShare:!1,userVariables:{},mediaSettings:{useSdpASBandwidthKbps:!1,sdpASBandwidthKbps:0}};var X,Wn,At,le,Rt;(function(e){e[e.New=0]="New",e[e.Requesting=1]="Requesting",e[e.Trying=2]="Trying",e[e.Recovering=3]="Recovering",e[e.Ringing=4]="Ringing",e[e.Answering=5]="Answering",e[e.Early=6]="Early",e[e.Active=7]="Active",e[e.Held=8]="Held",e[e.Hangup=9]="Hangup",e[e.Destroy=10]="Destroy",e[e.Purge=11]="Purge"})(X||(X={})),function(e){e.Participant="participant",e.Moderator="moderator"}(Wn||(Wn={})),function(e){e.Join="join",e.Leave="leave",e.Bootstrap="bootstrap",e.Add="add",e.Modify="modify",e.Delete="delete",e.Clear="clear",e.ChatMessage="chatMessage",e.LayerInfo="layerInfo",e.LogoInfo="logoInfo",e.LayoutInfo="layoutInfo",e.LayoutList="layoutList",e.ModCmdResponse="modCommandResponse"}(At||(At={})),function(e){e.Video="videoinput",e.AudioIn="audioinput",e.AudioOut="audiooutput"}(le||(le={})),function(e){e.REGED="REGED",e.UNREGED="UNREGED",e.NOREG="NOREG",e.FAILED="FAILED",e.FAIL_WAIT="FAIL_WAIT",e.REGISTER="REGISTER",e.TRYING="TRYING",e.EXPIRED="EXPIRED",e.UNREGISTER="UNREGISTER"}(Rt||(Rt={}));const cn="GLOBAL",Dt={},zn=(e,t)=>`${e}|${t}`,ju=(e,t=cn)=>zn(e,t)in Dt,un=(e,t,n=cn)=>{const i=zn(e,n);i in Dt||(Dt[i]=[]),Dt[i].push(t)},$u=(e,t,n=cn)=>{const i=function(s){dn(e,i,n),t(s)};return i.prototype.targetRef=t,un(e,i,n)},dn=(e,t,n=cn)=>{if(!ju(e,n))return!1;const i=zn(e,n);if(ln(t))for(let s=Dt[i].length-1;s>=0;s--){const o=Dt[i][s];(t===o||o.prototype&&t===o.prototype.targetRef)&&Dt[i].splice(s,1)}else Dt[i]=[];return Dt[i].length===0&&delete Dt[i],!0},J=(e,t,n=cn,i=!0)=>{const s=i&&n!==cn;if(!ju(e,n))return s&&J(e,t),!1;const o=zn(e,n),r=Dt[o].length;if(!r)return s&&J(e,t),!1;for(let a=r-1;a>=0;a--)Dt[o][a](t);return s&&J(e,t),!0},Vr=e=>{const t=zn(e,"");Object.keys(Dt).filter(n=>n.indexOf(t)===0).forEach(n=>delete Dt[n])};let $v=typeof WebSocket<"u"?WebSocket:null;const Uv=0,Hv=1,Gv=2,Wv=3;class Uu{constructor(t){this.session=t,this.previousGatewayState="",this._wsClient=null,this._host=Mu,this._timers={},this.upDur=null,this.downDur=null;const{host:n,env:i,region:s}=t.options;i&&(this._host=i==="development"?"wss://rtcdev.telnyx.com":Mu),n&&(this._host=(o=>`${Fv.test(o)?"":"wss://"}${o}`)(n)),s&&(this._host=this._host.replace(/rtc(dev)?/,`${s}.rtc$1`))}get connected(){return this._wsClient&&this._wsClient.readyState===Hv}get connecting(){return this._wsClient&&this._wsClient.readyState===Uv}get closing(){return this._wsClient&&this._wsClient.readyState===Gv}get closed(){return this._wsClient&&this._wsClient.readyState===Wv}get isAlive(){return this.connecting||this.connected}get isDead(){return this.closing||this.closed}connect(){const t=new URL(this._host),n=Nr();n&&t.searchParams.set("voice_sdk_id",n),this._wsClient=new $v(t.toString()),this._wsClient.onopen=i=>J(V.SocketOpen,i,this.session.uuid),this._wsClient.onclose=i=>J(V.SocketClose,i,this.session.uuid),this._wsClient.onerror=i=>J(V.SocketError,{error:i,sessionId:this.session.sessionid},this.session.uuid),this._wsClient.onmessage=i=>{var s,o;const r=Nu(i.data);var a;if(typeof r!="string"){if(r.voice_sdk_id&&(a=r.voice_sdk_id,sessionStorage.setItem(Or,a)),this._unsetTimer(r.id),B.debug(`RECV:
|
|
101
|
+
*/const Cu=Ve("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),C_=br(!1),T_=()=>Xl(C_),Vt=({children:t,className:e,onClick:n,tooltip:i})=>E("button",{title:i,onClick:n,className:xt("w-8 h-8 rounded-full cursor-pointer text-white flex items-center justify-center",e),children:t}),Tu=({call:t})=>{const[e,n]=T_(),i=()=>{n(o=>{const r=!o;return r?t.muteAudio():t.unmuteAudio(),r})},s=()=>{t.hangup()};return E("div",{className:"flex items-center justify-center gap-2",children:[E(Vt,{tooltip:e?"Unmute":"Mute",onClick:i,className:xt(e?"bg-[#F36666] dark:bg-[#750000]":"bg-[#E6E3D3] dark:bg-[#3C3C3C]"),children:e?E(__,{className:"w-5 h-5 text-black dark:text-white"}):E(v_,{className:"w-5 h-5 text-black dark:text-white"})}),E(Vt,{tooltip:"End Call",onClick:s,className:"bg-[#F36666] text-black dark:text-black dark:bg-[#750000]",children:E(b_,{className:"w-4 h-4 text-black dark:text-white"})})]})},Eu=({call:t,onExpand:e})=>E(Bn.div,{layoutId:Si,className:"bg-[#FEFDF5] text-black p-4 rounded-3xl w-[250px] overflow-hidden flex flex-col items-center justify-center dark:bg-black dark:text-white shadow-lg shadow-[#38383878] gap-3",children:[E(wu,{onClick:e,className:"h-[72px] cursor-pointer",stream:t.remoteStream}),E(Ql,{stream:t.remoteStream}),E(Jl,{size:"small"}),E(Tu,{call:t})]});function E_(){const[t,e]=Xe(!1),n=Nt();if(!n.give_feedback_url&&!n.report_issue_url&&!n.view_history_url)return null;const i=a=>{a&&window.open(a,"_blank","noopener,noreferrer"),e(!1)},s=()=>{i(n.give_feedback_url)},o=()=>{i(n.report_issue_url)},r=()=>{i(n.view_history_url)};return E("div",{children:[E(Vt,{tooltip:"More",onClick:()=>e(!t),children:E(ku,{className:"text-black dark:text-white"})}),t&&E("div",{className:"absolute p-4 w-[200px] min-h-[180px] top-0 left-0 bg-[#FEFDF599] dark:bg-[#38383C96] rounded-3xl backdrop-blur-xs z-10",children:[E(Vt,{tooltip:"More",onClick:()=>e(!t),children:E(ku,{className:"text-black dark:text-white"})}),E("ul",{className:"text-sm font-semibold divide-y text-left divider-solid divide-[#3D3D46]",children:[n.give_feedback_url&&E("li",{onClick:s,className:"flex items-center gap-2 px-4 py-3 border-solid cursor-pointer",children:["Give Feedback ",E(S_,{className:"w-4 h-4"})]}),n.report_issue_url&&E("li",{onClick:o,className:"flex items-center gap-2 px-4 py-3 border-solid cursor-pointer",children:["Report Issue ",E(k_,{className:"w-4 h-4"})]}),n.view_history_url&&E("li",{onClick:r,className:"flex items-center gap-2 px-4 py-3 border-solid cursor-pointer",children:["View History ",E(m_,{className:"w-4 h-4"})]})]})]})]})}function A_({item:t,containerRef:e}){const n=De(null);return $e(()=>{var i;n.current&&((i=e==null?void 0:e.current)==null||i.scrollTo({top:n.current.offsetTop,behavior:"smooth"}))},[e]),E("li",{className:xt("flex flex-col gap-1 text-left",{"items-end":t.role==="user"}),ref:n,children:[E("span",{className:"text-xs text-[#969696]",children:t.timestamp.toLocaleTimeString()}),E("div",{className:xt("flex flex-col gap-2",{"items-end":t.role==="user"}),children:[t.attachments&&t.attachments.length>0&&E("div",{className:"flex flex-wrap gap-2",children:t.attachments.map((i,s)=>i.type==="image"&&E("img",{src:i.url,alt:"Attached image",className:"max-w-32 max-h-32 object-cover rounded-lg border border-[#969696] dark:border-[#3D3D46]"},s))}),t.content&&E("p",{className:xt("text-sm",{"bg-[#FEFDF5] dark:bg-[#222227] px-2.5 py-2 rounded-md":t.role==="user"}),children:t.content})]})]})}const I_=({transcript:t,call:e})=>{const n=De(null),i=De(null),s=De(null),[o,r]=Xe([]);$e(()=>()=>{o.forEach(w=>URL.revokeObjectURL(w.preview))},[o]);const a=w=>new Promise((b,v)=>{const S=new FileReader;S.onload=()=>b(S.result),S.onerror=v,S.readAsDataURL(w)}),c=async w=>{if(w.type.startsWith("image/"))try{const b=await a(w),v=URL.createObjectURL(w),S={id:Date.now().toString(),file:w,base64:b,preview:v};r(k=>[...k,S])}catch(b){console.error("Error processing image:",b)}},l=w=>{r(b=>{const v=b.find(S=>S.id===w);return v&&URL.revokeObjectURL(v.preview),b.filter(S=>S.id!==w)})},d=w=>{const b=w.target,v=b.files;v&&v.length>0&&(Array.from(v).forEach(c),b.value="")},u=w=>{var v;const b=(v=w.clipboardData)==null?void 0:v.items;b&&Array.from(b).forEach(S=>{if(S.type.startsWith("image/")){const k=S.getAsFile();k&&c(k)}})},m=()=>{var w;(w=i.current)==null||w.click()},g=async()=>{var v;const w=n.current&&n.current.value.trim()!=="",b=o.length>0;if(w||b){const S=((v=n.current)==null?void 0:v.value)||"";e.sendConversationMessage(S,o.map(k=>k.base64)),n.current&&(n.current.value=""),o.forEach(k=>URL.revokeObjectURL(k.preview)),r([])}},y=w=>{w.key==="Enter"&&(w.preventDefault(),g())};return E("div",{className:"h-[300px] sm:h-[386px] bg-[#E6E3D3] dark:bg-[#38383C] rounded-t-3xl sm:rounded-3xl p-4 flex flex-col w-full",children:[E("ul",{className:"flex flex-col flex-1 gap-4 p-4 overflow-y-auto",ref:s,children:t.map((w,b)=>E(A_,{item:w,containerRef:s},w.id+b))}),o.length>0&&E("div",{className:"flex flex-wrap gap-2 mb-2",children:o.map(w=>E("div",{className:"relative",children:[E("img",{src:w.preview,alt:"Preview",className:"w-16 h-16 object-cover rounded-lg border border-[#969696] dark:border-[#3D3D46]"}),E("button",{onClick:()=>l(w.id),className:"absolute flex items-center justify-center w-5 h-5 text-xs text-white bg-red-500 rounded-full -top-1 -right-1 hover:bg-red-600",title:"Remove image",children:E(Cu,{className:"w-3 h-3"})})]},w.id))}),E("div",{className:"flex items-center h-8 bg-[#FEFDF5] border border-[#969696] dark:border-[#3D3D46] dark:bg-[#222227] rounded-full p-2 gap-2",children:[E("input",{ref:n,type:"text",onKeyDown:y,onPaste:u,placeholder:"Type something here",className:"w-full text-sm bg-transparent outline-none dark:text-white"}),E("input",{ref:i,type:"file",accept:"image/*",multiple:!0,onChange:d,className:"hidden"}),E(Vt,{tooltip:"Attach image",onClick:m,children:E(y_,{className:"text-[#969696] w-4 h-4"})}),E(Vt,{tooltip:"Send",children:E(w_,{onClick:g,className:"text-[#969696] w-4 h-4"})})]})]})};function P_({onCollapse:t}){return E("div",{className:"flex items-center justify-between w-full",children:[E(E_,{}),E(Vt,{tooltip:"Collapse",className:"ml-auto",onClick:t,children:E(Cu,{className:"text-black dark:text-white"})})]})}const R_=({call:t,onCollapse:e,transcript:n})=>E(Hf,{children:E(Bn.div,{exit:{opacity:0,scale:.95},initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},layoutId:"transcript-widget",className:"relative bg-[#FEFDF5] text-black dark:bg-black gap-3 w-full sm:w-[400px] dark:text-white rounded-t-3xl sm:rounded-3xl shadow-lg shadow-[#38383878]",children:[E("div",{className:"p-4 text-center",children:[E(P_,{onCollapse:e}),E(wu,{className:"h-[144px]",stream:t.remoteStream}),E(Jl,{size:"large",className:"mb-4"}),E(Tu,{call:t})]}),E(Ql,{stream:t.remoteStream}),E(I_,{call:t,transcript:n})]})});function Au(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(n[i[s]]=t[i[s]])}return n}function j(t,e,n,i){return new(n||(n=Promise))(function(s,o){function r(l){try{c(i.next(l))}catch(d){o(d)}}function a(l){try{c(i.throw(l))}catch(d){o(d)}}function c(l){var d;l.done?s(l.value):(d=l.value,d instanceof n?d:new n(function(u){u(d)})).then(r,a)}c((i=i.apply(t,[])).next())})}typeof SuppressedError=="function"&&SuppressedError;var Iu=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),M_=new Uint8Array(16);function D_(){if(!Iu)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Iu(M_)}for(var Pu=[],Mi=0;Mi<256;++Mi)Pu[Mi]=(Mi+256).toString(16).substr(1);function an(t,e,n){var i=e&&n||0;typeof t=="string"&&(e=t==="binary"?new Array(16):null,t=null);var s=(t=t||{}).random||(t.rng||D_)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,e)for(var o=0;o<16;++o)e[i+o]=s[o];return e||function(r,a){var c=0,l=Pu;return[l[r[c++]],l[r[c++]],l[r[c++]],l[r[c++]],"-",l[r[c++]],l[r[c++]],"-",l[r[c++]],l[r[c++]],"-",l[r[c++]],l[r[c++]],"-",l[r[c++]],l[r[c++]],l[r[c++]],l[r[c++]],l[r[c++]],l[r[c++]]].join("")}(s)}const Ru="wss://rtc.telnyx.com",L_={urls:"stun:stun.l.google.com:19302"},O_={urls:"stun:stun.telnyx.com:3478"},Mu={urls:"turn:turn.telnyx.com:3478?transport=tcp",username:"testuser",credential:"testpassword"};var F;(function(t){t.SocketOpen="telnyx.socket.open",t.SocketClose="telnyx.socket.close",t.SocketError="telnyx.socket.error",t.SocketMessage="telnyx.socket.message",t.SpeedTest="telnyx.internal.speedtest",t.Ready="telnyx.ready",t.Error="telnyx.error",t.Notification="telnyx.notification",t.StatsFrame="telnyx.stats.frame",t.StatsReport="telnyx.stats.report",t.Messages="telnyx.messages",t.Calls="telnyx.calls",t.MediaError="telnyx.rtc.mediaError"})(F||(F={}));var N_=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Du(t,e){return t(e={exports:{}},e.exports),e.exports}var V_=Du(function(t){var e,n;e=N_,n=function(){var i=function(){},s="undefined",o=typeof window!==s&&typeof window.navigator!==s&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"];function a(b,v){var S=b[v];if(typeof S.bind=="function")return S.bind(b);try{return Function.prototype.bind.call(S,b)}catch{return function(){return Function.prototype.apply.apply(S,[b,arguments])}}}function c(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(b,v){for(var S=0;S<r.length;S++){var k=r[S];this[k]=S<b?i:this.methodFactory(k,b,v)}this.log=this.debug}function d(b,v,S){return function(){typeof console!==s&&(l.call(this,v,S),this[b].apply(this,arguments))}}function u(b,v,S){return function(k){return k==="debug"&&(k="log"),typeof console!==s&&(k==="trace"&&o?c:console[k]!==void 0?a(console,k):console.log!==void 0?a(console,"log"):i)}(b)||d.apply(this,arguments)}function m(b,v,S){var k,I=this;v=v??"WARN";var D="loglevel";function O(){var C;if(typeof window!==s&&D){try{C=window.localStorage[D]}catch{}if(typeof C===s)try{var f=window.document.cookie,p=f.indexOf(encodeURIComponent(D)+"=");p!==-1&&(C=/^([^;]+)/.exec(f.slice(p))[1])}catch{}return I.levels[C]===void 0&&(C=void 0),C}}typeof b=="string"?D+=":"+b:typeof b=="symbol"&&(D=void 0),I.name=b,I.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},I.methodFactory=S||u,I.getLevel=function(){return k},I.setLevel=function(C,f){if(typeof C=="string"&&I.levels[C.toUpperCase()]!==void 0&&(C=I.levels[C.toUpperCase()]),!(typeof C=="number"&&C>=0&&C<=I.levels.SILENT))throw"log.setLevel() called with invalid level: "+C;if(k=C,f!==!1&&function(p){var h=(r[p]||"silent").toUpperCase();if(typeof window!==s&&D){try{return void(window.localStorage[D]=h)}catch{}try{window.document.cookie=encodeURIComponent(D)+"="+h+";"}catch{}}}(C),l.call(I,C,b),typeof console===s&&C<I.levels.SILENT)return"No console available for logging"},I.setDefaultLevel=function(C){v=C,O()||I.setLevel(C,!1)},I.resetLevel=function(){I.setLevel(v,!1),function(){if(typeof window!==s&&D){try{return void window.localStorage.removeItem(D)}catch{}try{window.document.cookie=encodeURIComponent(D)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}()},I.enableAll=function(C){I.setLevel(I.levels.TRACE,C)},I.disableAll=function(C){I.setLevel(I.levels.SILENT,C)};var x=O();x==null&&(x=v),I.setLevel(x,!1)}var g=new m,y={};g.getLogger=function(b){if(typeof b!="symbol"&&typeof b!="string"||b==="")throw new TypeError("You must supply a name when creating a logger.");var v=y[b];return v||(v=y[b]=new m(b,g.getLevel(),g.methodFactory)),v};var w=typeof window!==s?window.log:void 0;return g.noConflict=function(){return typeof window!==s&&window.log===g&&(window.log=w),g},g.getLoggers=function(){return y},g.default=g,g},t.exports?t.exports=n():e.log=n()});const L=V_.getLogger("telnyx"),F_=L.methodFactory;L.methodFactory=(t,e,n)=>{const i=F_(t,e,n);return function(){const s=[new Date().toISOString().replace("T"," ").replace("Z",""),"-"];for(let o=0;o<arguments.length;o++)s.push(arguments[o]);i.apply(void 0,s)}},L.setLevel(L.getLevel());const Di=t=>{const[e,n,i,s,o,r]=t;let a={};try{a=JSON.parse(o.replace(/ID"/g,'Id"'))}catch{L.warn("Verto LA invalid media JSON string:",o)}return{participantId:Number(e),participantNumber:n,participantName:i,codec:s,media:a,participantData:r}},Lu=t=>{if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}},cn=t=>t instanceof Function||typeof t=="function",Li=t=>typeof document=="object"&&"getElementById"in document?typeof t=="string"?document.getElementById(t)||null:typeof t=="function"?t():t instanceof HTMLMediaElement?t:null:null,B_=/^(ws|wss):\/\//,Ou=(t,e=null)=>{const{result:n={},error:i}=t;if(i)return{error:i};const{result:s=null}=n;if(s===null)return e!==null&&(n.node_id=e),{result:n};const{code:o=null,node_id:r=null,result:a=null}=s;return o&&o!=="200"?{error:s}:a?Ou(a,r):{result:s}},Nu=(t,e)=>Math.floor(Math.random()*(e-t+1)+t),Pr=({login:t,passwd:e,password:n,login_token:i})=>!!(t&&(e||n)||i),Oi=({anonymous_login:t})=>!!t&&!!t.target_id&&!!t.target_type,Rr=t=>{var e,n,i,s,o,r;let a="",c="";return!((n=(e=t==null?void 0:t.result)===null||e===void 0?void 0:e.params)===null||n===void 0)&&n.state&&(a=(s=(i=t==null?void 0:t.result)===null||i===void 0?void 0:i.params)===null||s===void 0?void 0:s.state),!((o=t==null?void 0:t.params)===null||o===void 0)&&o.state&&(c=(r=t==null?void 0:t.params)===null||r===void 0?void 0:r.state),a||c};function Vu({debounceTime:t}){let e,n;return{promise:new Promise((i,s)=>{e=t?j_(i,t):i,n=s}),resolve:e,reject:n}}const j_=(t,e)=>{let n;return(...i)=>{clearTimeout(n),n=window.setTimeout(()=>{t(...i)},e)}},Mr="telnyx-voice-sdk-id";function Ni(){return sessionStorage.getItem(Mr)}var ke,St,te;typeof window<"u"&&window.addEventListener("beforeunload",()=>{sessionStorage.removeItem(Mr)}),function(t){t.Offer="offer",t.Answer="answer"}(ke||(ke={})),function(t){t.Inbound="inbound",t.Outbound="outbound"}(St||(St={})),function(t){t.Invite="telnyx_rtc.invite",t.Attach="telnyx_rtc.attach",t.Answer="telnyx_rtc.answer",t.Info="telnyx_rtc.info",t.Candidate="telnyx_rtc.candidate",t.EndOfCandidates="telnyx_rtc.endOfCandidates",t.Display="telnyx_rtc.display",t.Media="telnyx_rtc.media",t.Event="telnyx_rtc.event",t.Bye="telnyx_rtc.bye",t.Punt="telnyx_rtc.punt",t.Broadcast="telnyx_rtc.broadcast",t.Subscribe="telnyx_rtc.subscribe",t.Unsubscribe="telnyx_rtc.unsubscribe",t.ClientReady="telnyx_rtc.clientReady",t.Modify="telnyx_rtc.modify",t.Ringing="telnyx_rtc.ringing",t.GatewayState="telnyx_rtc.gatewayState",t.Ping="telnyx_rtc.ping",t.Pong="telnyx_rtc.pong"}(te||(te={}));const at={generic:"event",[te.Display]:"participantData",[te.Attach]:"participantData",conferenceUpdate:"conferenceUpdate",callUpdate:"callUpdate",vertoClientReady:"vertoClientReady",userMediaError:"userMediaError"},$_={destinationNumber:"",remoteCallerName:"Outbound Call",remoteCallerNumber:"",callerName:"",callerNumber:"",audio:!0,useStereo:!1,debug:!1,debugOutput:"socket",attach:!1,screenShare:!1,userVariables:{},mediaSettings:{useSdpASBandwidthKbps:!1,sdpASBandwidthKbps:0}};var W,Dr,Fe,mt,Pe;(function(t){t[t.New=0]="New",t[t.Requesting=1]="Requesting",t[t.Trying=2]="Trying",t[t.Recovering=3]="Recovering",t[t.Ringing=4]="Ringing",t[t.Answering=5]="Answering",t[t.Early=6]="Early",t[t.Active=7]="Active",t[t.Held=8]="Held",t[t.Hangup=9]="Hangup",t[t.Destroy=10]="Destroy",t[t.Purge=11]="Purge"})(W||(W={})),function(t){t.Participant="participant",t.Moderator="moderator"}(Dr||(Dr={})),function(t){t.Join="join",t.Leave="leave",t.Bootstrap="bootstrap",t.Add="add",t.Modify="modify",t.Delete="delete",t.Clear="clear",t.ChatMessage="chatMessage",t.LayerInfo="layerInfo",t.LogoInfo="logoInfo",t.LayoutInfo="layoutInfo",t.LayoutList="layoutList",t.ModCmdResponse="modCommandResponse"}(Fe||(Fe={})),function(t){t.Video="videoinput",t.AudioIn="audioinput",t.AudioOut="audiooutput"}(mt||(mt={})),function(t){t.REGED="REGED",t.UNREGED="UNREGED",t.NOREG="NOREG",t.FAILED="FAILED",t.FAIL_WAIT="FAIL_WAIT",t.REGISTER="REGISTER",t.TRYING="TRYING",t.EXPIRED="EXPIRED",t.UNREGISTER="UNREGISTER"}(Pe||(Pe={}));const ln="GLOBAL",Oe={},Hn=(t,e)=>`${t}|${e}`,Fu=(t,e=ln)=>Hn(t,e)in Oe,un=(t,e,n=ln)=>{const i=Hn(t,n);i in Oe||(Oe[i]=[]),Oe[i].push(e)},Bu=(t,e,n=ln)=>{const i=function(s){dn(t,i,n),e(s)};return i.prototype.targetRef=e,un(t,i,n)},dn=(t,e,n=ln)=>{if(!Fu(t,n))return!1;const i=Hn(t,n);if(cn(e))for(let s=Oe[i].length-1;s>=0;s--){const o=Oe[i][s];(e===o||o.prototype&&e===o.prototype.targetRef)&&Oe[i].splice(s,1)}else Oe[i]=[];return Oe[i].length===0&&delete Oe[i],!0},J=(t,e,n=ln,i=!0)=>{const s=i&&n!==ln;if(!Fu(t,n))return s&&J(t,e),!1;const o=Hn(t,n),r=Oe[o].length;if(!r)return s&&J(t,e),!1;for(let a=r-1;a>=0;a--)Oe[o][a](e);return s&&J(t,e),!0},Lr=t=>{const e=Hn(t,"");Object.keys(Oe).filter(n=>n.indexOf(e)===0).forEach(n=>delete Oe[n])};let U_=typeof WebSocket<"u"?WebSocket:null;const G_=0,H_=1,W_=2,z_=3;class ju{constructor(e){this.session=e,this.previousGatewayState="",this._wsClient=null,this._host=Ru,this._timers={},this._hasTrickleIceCanaryBeenUsed=!1,this._trickleIceCanaryEnabled=!1,this.upDur=null,this.downDur=null;const{host:n,env:i,region:s,trickleIce:o}=e.options;i&&(this._host=i==="development"?"wss://rtcdev.telnyx.com":Ru),n&&(this._host=(r=>`${B_.test(r)?"":"wss://"}${r}`)(n)),s&&(this._host=this._host.replace(/rtc(dev)?/,`${s}.rtc$1`)),o&&(this._trickleIceCanaryEnabled=!0)}get connected(){return this._wsClient&&this._wsClient.readyState===H_}get connecting(){return this._wsClient&&this._wsClient.readyState===G_}get closing(){return this._wsClient&&this._wsClient.readyState===W_}get closed(){return this._wsClient&&this._wsClient.readyState===z_}get isAlive(){return this.connecting||this.connected}get isDead(){return this.closing||this.closed}connect(){const e=new URL(this._host);let n=Ni();this.session.options.rtcIp&&this.session.options.rtcPort&&(n=null,this._trickleIceCanaryEnabled=!1,e.searchParams.set("rtc_ip",this.session.options.rtcIp),e.searchParams.set("rtc_port",this.session.options.rtcPort.toString())),n&&e.searchParams.set("voice_sdk_id",n),this._trickleIceCanaryEnabled&&(e.searchParams.set("canary","true"),n&&!this._hasTrickleIceCanaryBeenUsed&&(e.searchParams.delete("voice_sdk_id"),L.debug("first trickle ice canary connection. Refreshing voice_sdk_id")),this.session.options.trickleIce=!0,this._hasTrickleIceCanaryBeenUsed=!0),this._wsClient=new U_(e.toString()),this._wsClient.onopen=i=>J(F.SocketOpen,i,this.session.uuid),this._wsClient.onclose=i=>J(F.SocketClose,i,this.session.uuid),this._wsClient.onerror=i=>J(F.SocketError,{error:i,sessionId:this.session.sessionid},this.session.uuid),this._wsClient.onmessage=i=>{var s,o;const r=Lu(i.data);var a;if(typeof r!="string"){if(r.voice_sdk_id&&(a=r.voice_sdk_id,sessionStorage.setItem(Mr,a)),this._unsetTimer(r.id),L.debug(`RECV:
|
|
102
102
|
`,JSON.stringify(r,null,2),`
|
|
103
|
-
`),
|
|
103
|
+
`),Pe[`${(o=(s=r==null?void 0:r.result)===null||s===void 0?void 0:s.params)===null||o===void 0?void 0:o.state}`]||!J(r.id,r)){const c=Rr(r);J(F.SocketMessage,r,this.session.uuid),c&&(this.previousGatewayState=c)}}else this._handleStringResponse(r)}}sendRawText(e){this._wsClient.send(e)}send(e){const{request:n}=e,i=new Promise((s,o)=>{if(n.hasOwnProperty("result"))return s();Bu(n.id,r=>{const{result:a,error:c}=Ou(r);return c?o(c):s(a)})});return L.debug(`SEND:
|
|
104
104
|
`,JSON.stringify(n,null,2),`
|
|
105
|
-
`),this._wsClient.send(JSON.stringify(n)),i}close(){this._wsClient&&(ln(this._wsClient._beginClose)?this._wsClient._beginClose():this._wsClient.close()),this._wsClient=null}_unsetTimer(t){clearTimeout(this._timers[t]),delete this._timers[t]}_handleStringResponse(t){if(/^#SP/.test(t))switch(t[3]){case"U":this.upDur=parseInt(t.substring(4));break;case"D":this.downDur=parseInt(t.substring(4)),J(V.SpeedTest,{upDur:this.upDur,downDur:this.downDur},this.session.uuid)}else B.warn("Unknown message from socket",t)}}class qn{buildRequest(t){this.request=Object.assign({jsonrpc:"2.0",id:an()},t)}}const Hu={id:"callID",destinationNumber:"destination_number",remoteCallerName:"remote_caller_id_name",remoteCallerNumber:"remote_caller_id_number",callerName:"caller_id_name",callerNumber:"caller_id_number",customHeaders:"custom_headers"};class Ot extends qn{constructor(t={}){if(super(),t.hasOwnProperty("dialogParams")){const n=Mr(t.dialogParams,["remoteSdp","localStream","remoteStream","onNotification","camId","micId","speakerId"]);for(const i in Hu)i&&n.hasOwnProperty(i)&&(n[Hu[i]]=n[i],delete n[i]);t.dialogParams=n}this.buildRequest({method:this.toString(),params:t})}}class Gu extends Ot{constructor(){super(),this.method=nt.GatewayState,this.buildRequest({method:this.method,params:{}})}}class zv{constructor(t){this.pendingRequestId=null,this.onSocketMessage=n=>H(this,void 0,void 0,function*(){n.id===this.pendingRequestId&&this.gatewayStateTask.resolve(Dr(n))}),this.getIsRegistered=()=>H(this,void 0,void 0,function*(){const n=new Gu;this.pendingRequestId=n.request.id,this.gatewayStateTask=Bu({}),this.session.execute(n);const i=yield this.gatewayStateTask.promise;return!!i&&[Rt.REGISTER,Rt.REGED].includes(i)}),this.session=t,this.gatewayStateTask=Bu({}),this.session.on("telnyx.socket.message",this.onSocketMessage)}}class qv{constructor(t){if(this.options=t,this.uuid=an(),this.sessionid="",this.subscriptions={},this.signature=null,this.relayProtocol=null,this.contexts=[],this.timeoutErrorCode=-32e3,this.connection=null,this._jwtAuth=!1,this._doKeepAlive=!1,this._autoReconnect=!0,this._idle=!1,this._executeQueue=[],!this.validateOptions())throw new Error("Invalid init options");this._onSocketOpen=this._onSocketOpen.bind(this),this.onNetworkClose=this.onNetworkClose.bind(this),this._onSocketMessage=this._onSocketMessage.bind(this),this._handleLoginError=this._handleLoginError.bind(this),this._attachListeners(),this.connection=new Uu(this),this.registerAgent=new zv(this)}get __logger(){return B}get connected(){return this.connection&&this.connection.connected}get reconnectDelay(){return 1e3*Fu(2,6)}execute(t){return this._idle?new Promise(n=>this._executeQueue.push({resolve:n,msg:t})):this.connected?this.connection.send(t):new Promise(n=>{this._executeQueue.push({resolve:n,msg:t}),this.connect()})}executeRaw(t){this._idle?this._executeQueue.push({msg:t}):this.connection.sendRawText(t)}validateOptions(){return Lr(this.options)||Oi(this.options)}broadcast(t){}disconnect(){return H(this,void 0,void 0,function*(){clearTimeout(this._reconnectTimeout),this.subscriptions={},this._autoReconnect=!1,this.relayProtocol=null,this._closeConnection(),yield sessionStorage.removeItem(this.signature),this._executeQueue=[],this._detachListeners()})}on(t,n){return un(t,n,this.uuid),this}off(t,n){return dn(t,n,this.uuid),this}connect(){return H(this,void 0,void 0,function*(){this.connection||(this.connection=new Uu(this)),this._attachListeners(),this.connection.isAlive||this.connection.connect()})}_handleLoginError(t){J(V.Error,{error:t,sessionId:this.sessionid},this.uuid)}_onSocketOpen(){return H(this,void 0,void 0,function*(){})}onNetworkClose(){this.relayProtocol&&Vr(this.relayProtocol);for(const t in this.subscriptions)Vr(t);this.subscriptions={},this.contexts=[],this._autoReconnect&&(this._reconnectTimeout=setTimeout(()=>this.connect(),this.reconnectDelay))}_onSocketMessage(t){}_removeSubscription(t,n){this._existsSubscription(t,n)&&(n?(delete this.subscriptions[t][n],dn(t,null,n)):(delete this.subscriptions[t],Vr(t)))}_addSubscription(t,n=null,i){this._existsSubscription(t,i)||(this._existsSubscription(t)||(this.subscriptions[t]={}),this.subscriptions[t][i]={},ln(n)&&un(t,n,i))}_existsSubscription(t,n){return!(!this.subscriptions.hasOwnProperty(t)||!(!n||n&&this.subscriptions[t].hasOwnProperty(n)))}_attachListeners(){this._detachListeners(),this.on(V.SocketOpen,this._onSocketOpen),this.on(V.SocketClose,this.onNetworkClose),this.on(V.SocketError,this.onNetworkClose),this.on(V.SocketMessage,this._onSocketMessage)}_detachListeners(){this.off(V.SocketOpen,this._onSocketOpen),this.off(V.SocketClose,this.onNetworkClose),this.off(V.SocketError,this.onNetworkClose),this.off(V.SocketMessage,this._onSocketMessage)}_emptyExecuteQueues(){this._executeQueue.forEach(({resolve:t,msg:n})=>{typeof n=="string"?this.executeRaw(n):t(this.execute(n))})}_closeConnection(){this._idle=!0,clearTimeout(this._keepAliveTimeout),this.connection&&this.connection.close()}_keepAlive(){this._doKeepAlive===!0&&(this._pong=!1,this._keepAliveTimeout=setTimeout(()=>this._keepAlive(),3e4))}static on(t,n){un(t,n)}static off(t){dn(t)}static uuid(){return an()}clearConnection(){this.connection=null}hasAutoReconnect(){return this._autoReconnect}getIsRegistered(){return this.registerAgent.getIsRegistered()}}const Fr=e=>navigator.mediaDevices.getUserMedia(e),Ni=e=>e&&e instanceof MediaStream,Vi=(e,t)=>{const n=Gn(e);n!==null&&(n.getAttribute("autoplay")||n.setAttribute("autoplay","autoplay"),n.getAttribute("playsinline")||n.setAttribute("playsinline","playsinline"),n.srcObject=t)},Wu=(e,t)=>H(void 0,void 0,void 0,function*(){const n=Gn(e);if(n===null)return B.info("No HTMLMediaElement to attach the speakerId"),!1;if(typeof t!="string")return B.info(`Invalid speaker deviceId: '${t}'`),!1;try{return yield n.setSinkId(t),!0}catch{return!1}}),Kv=e=>{e&&e.readyState==="live"&&e.stop()},Kn=e=>{Ni(e)&&e.getTracks().forEach(Kv),e=null},Fi=e=>H(void 0,void 0,void 0,function*(){B.info("RTCService.getUserMedia",e);const{audio:t,video:n}=e;if(!t&&!n)return null;try{return yield Fr(e)}catch(i){throw B.error("getUserMedia error: ",i),i}}),Xn=(e=null,t=!1)=>H(void 0,void 0,void 0,function*(){let n=[];const i=yield navigator.mediaDevices.getUserMedia(((s=null)=>({audio:!s||s===le.AudioIn||s===le.AudioOut,video:!s||s===le.Video}))(e)).catch(s=>(console.error(s),null));if(i){if(Kn(i),n=yield navigator.mediaDevices.enumerateDevices(),e&&(n=n.filter(o=>o.kind===e)),t===!0)return n;const s=[];n=n.filter(o=>{if(!o.groupId)return!0;const r=`${o.kind}-${o.groupId}`;return!s.includes(r)&&(s.push(r),!0)})}return n}),zu=[[320,240],[640,360],[640,480],[1280,720],[1920,1080]],Bi=(e,t,n)=>H(void 0,void 0,void 0,function*(){const i=yield Xn(n,!0);for(let s=0;s<i.length;s++){const{deviceId:o,label:r}=i[s];if(e===o||t===r)return o}return null}),qu=e=>{const t=navigator.mediaDevices.getSupportedConstraints();Object.keys(e).map(n=>{t.hasOwnProperty(n)&&e[n]!==null&&e[n]!==void 0||delete e[n]})},Ku=(e,t,n,i)=>H(void 0,void 0,void 0,function*(){const{deviceId:s}=i;if(s===void 0&&(e||t)){const o=yield Bi(e,t,n).catch(r=>null);o&&(i.deviceId={exact:o})}return i}),ji=(e,t)=>{if(!e)return!1;const{subscribed:n,alreadySubscribed:i}=Br(e);return n.includes(t)||i.includes(t)},Br=e=>{const t={subscribed:[],alreadySubscribed:[],unauthorized:[],unsubscribed:[],notSubscribed:[]};return Object.keys(t).forEach(n=>{t[n]=e[`${n}Channels`]||[]}),t},hn=(e,t=null,n=null)=>{if(!Ni(e))return null;let i=[];switch(t){case"audio":i=e.getAudioTracks();break;case"video":i=e.getVideoTracks();break;default:i=e.getTracks()}i.forEach(s=>{switch(n){case"on":case!0:s.enabled=!0;break;case"off":case!1:s.enabled=!1;break;default:s.enabled=!s.enabled}})},Xu=e=>{hn(e,"audio",!0)},Yu=e=>{hn(e,"audio",!1)},Zu=e=>{hn(e,"audio",null)};function Xv(){try{const{browserInfo:e,name:t,version:n,supportAudio:i,supportVideo:s}=function(){if(!window||!window.navigator||!window.navigator.userAgent)throw new Error("You should use @telnyx/webrtc in a web browser such as Chrome|Firefox|Safari");if(navigator.userAgent.match(/chrom(e|ium)/gim)&&!navigator.userAgent.match(/OPR\/[0-9]{2}/gi)&&!navigator.userAgent.match(/edg/gim)){const d=navigator.userAgent.match(/chrom(e|ium)\/[0-9]+\./gim)[0].split("/"),u=d[0],p=parseInt(d[1],10);return{browserInfo:navigator.userAgent,name:u,version:p,supportAudio:!0,supportVideo:!0}}if(navigator.userAgent.match(/firefox/gim)&&!navigator.userAgent.match(/OPR\/[0-9]{2}/gi)&&!navigator.userAgent.match(/edg/gim)){const d=navigator.userAgent.match(/firefox\/[0-9]+\./gim)[0].split("/"),u=d[0],p=parseInt(d[1],10);return{browserInfo:navigator.userAgent,name:u,version:p,supportAudio:!0,supportVideo:!1}}if(navigator.userAgent.match(/safari/gim)&&!navigator.userAgent.match(/OPR\/[0-9]{2}/gi)&&!navigator.userAgent.match(/edg/gim)){const d=navigator.userAgent.match(/safari/gim)[0],u=navigator.userAgent.match(/version\/[0-9]+\./gim)[0].split("/"),p=parseInt(u[1],10);return{browserInfo:navigator.userAgent,name:d,version:p,supportAudio:!0,supportVideo:!0}}if(navigator.userAgent.match(/edg/gim)&&!navigator.userAgent.match(/OPR\/[0-9]{2}/gi)){const d=navigator.userAgent.match(/edg\/[0-9]+\./gim)[0].split("/"),u=d[0],p=parseInt(d[1],10);return{browserInfo:navigator.userAgent,name:u,version:p,supportAudio:!0,supportVideo:!0}}throw new Error("This browser does not support @telnyx/webrtc. To see browser support list: `TelnyxRTC.webRTCSupportedBrowserList()`")}(),o=window.RTCPeerConnection,r=window.RTCSessionDescription,a=window.RTCIceCandidate,l=window.navigator&&window.navigator.mediaDevices,c=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.msGetUserMedia||navigator.mozGetUserMedia;return{browserInfo:e,browserName:t,browserVersion:n,supportWebRTC:!!(o&&r&&a&&l&&c),supportWebRTCAudio:i,supportWebRTCVideo:s,supportRTCPeerConnection:!!o,supportSessionDescription:!!r,supportIceCandidate:!!a,supportMediaDevices:!!l,supportGetUserMedia:!!Fi}}catch(e){return e.message}}var vt;function Ju(e,t){const n=document.getElementById(t);if(n)return n;if(e&&t){const i=document.createElement("audio");return i.id=t,i.loop=!0,i.src=e,i.preload="auto",i.load(),document.body.appendChild(i),i}return null}function Qu(e){e&&(e._playFulfilled=!1,e._promise=e.play(),e._promise.then(()=>{e._playFulfilled=!0}).catch(t=>{console.error("playAudio",t),e._playFulfilled=!0}))}function td(e){e&&(e._playFulfilled?(e.pause(),e.currentTime=0):e._promise&&e._promise.then?e._promise.then(()=>{e.pause(),e.currentTime=0}):setTimeout(()=>{e.pause(),e.currentTime=0},1e3))}(function(e){e.not_supported="not supported",e.full="full",e.partial="partial"})(vt||(vt={}));var ed="2.22.16",jr=ed;class Yv extends Ot{constructor(t,n,i,s,o={},r){super(),this.method="login";const a={login:t,passwd:n,login_token:i,userVariables:o,reconnection:r,loginParams:{},"User-Agent":{sdkVersion:jr,data:navigator.userAgent}};s&&(a.sessid=s),this.buildRequest({method:this.method,params:a})}}class Zv extends Ot{constructor(t,n){super(),this.buildRequest({id:t,result:{method:n}})}}class Jv extends Ot{toString(){return nt.Invite}}class Qv extends Ot{toString(){return nt.Answer}}class t_ extends Ot{toString(){return nt.Attach}}class e_ extends Ot{toString(){return nt.Bye}}class $r extends Ot{toString(){return nt.Modify}}class nd extends Ot{toString(){return nt.Info}}class n_ extends Ot{toString(){return nt.Broadcast}}class i_ extends Ot{toString(){return nt.Subscribe}}class s_ extends Ot{toString(){return nt.Unsubscribe}}class r_ extends qn{constructor(t,n){super(),this.method="ai_conversation",this.buildRequest({method:this.method,params:{type:"conversation.item.create",previous_item_id:null,item:{id:an(),type:"message",role:"user",content:[{type:"input_text",text:t},...n==null?void 0:n.map(i=>({type:"image_url",image_url:{url:i}}))]}}})}}const id=(e,t)=>{const{contentType:n,canvasType:i,callID:s,canvasInfo:o=null,currentLayerIdx:r=-1}=t;o&&i!=="mcu-personal-canvas"&&delete o.memberID;const a={type:ae.conferenceUpdate,call:e.calls[s],canvasInfo:o_(o),currentLayerIdx:r};switch(n){case"layer-info":{const l=Object.assign({action:At.LayerInfo},a);J(V.Notification,l,e.uuid);break}case"layout-info":{const l=Object.assign({action:At.LayoutInfo},a);J(V.Notification,l,e.uuid);break}}},o_=e=>{const t=JSON.stringify(e).replace(/memberID/g,"participantId").replace(/ID"/g,'Id"').replace(/POS"/g,'Pos"');return Nu(t)};var $i,sd=Du(function(e,t){var n;function i(){}function s(){s.init.call(this)}function o(f){return f._maxListeners===void 0?s.defaultMaxListeners:f._maxListeners}function r(f,m,h,v){var T,R,A;if(typeof h!="function")throw new TypeError('"listener" argument must be a function');if((R=f._events)?(R.newListener&&(f.emit("newListener",m,h.listener?h.listener:h),R=f._events),A=R[m]):(R=f._events=new i,f._eventsCount=0),A){if(typeof A=="function"?A=R[m]=v?[h,A]:[A,h]:v?A.unshift(h):A.push(h),!A.warned&&(T=o(f))&&0<T&&A.length>T){A.warned=!0;var M=new Error("Possible EventEmitter memory leak detected. "+A.length+" "+m+" listeners added. Use emitter.setMaxListeners() to increase limit");M.name="MaxListenersExceededWarning",M.emitter=f,M.type=m,M.count=A.length,function(I){typeof console.warn=="function"?console.warn(I):console.log(I)}(M)}}else A=R[m]=h,++f._eventsCount;return f}function a(f,m,h){function v(){f.removeListener(m,v),T||(T=!0,h.apply(f,arguments))}var T=!1;return v.listener=h,v}function l(f){var m=this._events;if(m){var h=m[f];if(typeof h=="function")return 1;if(h)return h.length}return 0}function c(f,m){for(var h=Array(m);m--;)h[m]=f[m];return h}Object.defineProperty(t,"__esModule",{value:!0}),i.prototype=Object.create(null),s.EventEmitter=s,s.usingDomains=!1,s.prototype.domain=void 0,s.prototype._events=void 0,s.prototype._maxListeners=void 0,s.defaultMaxListeners=10,s.init=function(){this.domain=null,s.usingDomains&&n.active&&!(this instanceof n.Domain)&&(this.domain=n.active),this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new i,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(f){if(typeof f!="number"||0>f||isNaN(f))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=f,this},s.prototype.getMaxListeners=function(){return o(this)},s.prototype.emit=function(f){var m,h,v,T,R,A,M,I=f==="error";if(A=this._events)I=I&&A.error==null;else if(!I)return!1;if(M=this.domain,I){if(m=arguments[1],!M){if(m instanceof Error)throw m;var N=new Error('Uncaught, unspecified "error" event. ('+m+")");throw N.context=m,N}return m||(m=new Error('Uncaught, unspecified "error" event')),m.domainEmitter=this,m.domain=M,m.domainThrown=!1,M.emit("error",m),!1}if(!(h=A[f]))return!1;var K=typeof h=="function";switch(v=arguments.length){case 1:(function(F,rt,Q){if(rt)F.call(Q);else for(var j=F.length,lt=c(F,j),W=0;W<j;++W)lt[W].call(Q)})(h,K,this);break;case 2:(function(F,rt,Q,j){if(rt)F.call(Q,j);else for(var lt=F.length,W=c(F,lt),Y=0;Y<lt;++Y)W[Y].call(Q,j)})(h,K,this,arguments[1]);break;case 3:(function(F,rt,Q,j,lt){if(rt)F.call(Q,j,lt);else for(var W=F.length,Y=c(F,W),Z=0;Z<W;++Z)Y[Z].call(Q,j,lt)})(h,K,this,arguments[1],arguments[2]);break;case 4:(function(F,rt,Q,j,lt,W){if(rt)F.call(Q,j,lt,W);else for(var Y=F.length,Z=c(F,Y),tt=0;tt<Y;++tt)Z[tt].call(Q,j,lt,W)})(h,K,this,arguments[1],arguments[2],arguments[3]);break;default:for(T=Array(v-1),R=1;R<v;R++)T[R-1]=arguments[R];(function(F,rt,Q,j){if(rt)F.apply(Q,j);else for(var lt=F.length,W=c(F,lt),Y=0;Y<lt;++Y)W[Y].apply(Q,j)})(h,K,this,T)}return!0},s.prototype.addListener=function(f,m){return r(this,f,m,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(f,m){return r(this,f,m,!0)},s.prototype.once=function(f,m){if(typeof m!="function")throw new TypeError('"listener" argument must be a function');return this.on(f,a(this,f,m)),this},s.prototype.prependOnceListener=function(f,m){if(typeof m!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(f,a(this,f,m)),this},s.prototype.removeListener=function(f,m){var h,v,T,R,A;if(typeof m!="function")throw new TypeError('"listener" argument must be a function');if(!(v=this._events))return this;if(!(h=v[f]))return this;if(h===m||h.listener&&h.listener===m)--this._eventsCount==0?this._events=new i:(delete v[f],v.removeListener&&this.emit("removeListener",f,h.listener||m));else if(typeof h!="function"){for(T=-1,R=h.length;0<R--;)if(h[R]===m||h[R].listener&&h[R].listener===m){A=h[R].listener,T=R;break}if(0>T)return this;if(h.length===1){if(h[0]=void 0,--this._eventsCount==0)return this._events=new i,this;delete v[f]}else(function(M,I){for(var N=I,K=N+1,F=M.length;K<F;N+=1,K+=1)M[N]=M[K];M.pop()})(h,T);v.removeListener&&this.emit("removeListener",f,A||m)}return this},s.prototype.removeAllListeners=function(f){var m,h;if(!(h=this._events))return this;if(!h.removeListener)return arguments.length===0?(this._events=new i,this._eventsCount=0):h[f]&&(--this._eventsCount==0?this._events=new i:delete h[f]),this;if(arguments.length===0){for(var v,T=Object.keys(h),R=0;R<T.length;++R)(v=T[R])!=="removeListener"&&this.removeAllListeners(v);return this.removeAllListeners("removeListener"),this._events=new i,this._eventsCount=0,this}if(typeof(m=h[f])=="function")this.removeListener(f,m);else if(m)do this.removeListener(f,m[m.length-1]);while(m[0]);return this},s.prototype.listeners=function(f){var m,h,v=this._events;return v?h=(m=v[f])?typeof m=="function"?[m.listener||m]:function(T){for(var R=Array(T.length),A=0;A<R.length;++A)R[A]=T[A].listener||T[A];return R}(m):[]:h=[],h},s.listenerCount=function(f,m){return typeof f.listenerCount=="function"?f.listenerCount(m):l.call(f,m)},s.prototype.listenerCount=l,s.prototype.eventNames=function(){return 0<this._eventsCount?Reflect.ownKeys(this._events):[]};var d,u=new Uint8Array(16);function p(){if(!d&&!(d=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return d(u)}for(var g=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,_=[],b=0;256>b;++b)_.push((b+256).toString(16).substr(1));function w(f){var m=1<arguments.length&&arguments[1]!==void 0?arguments[1]:0,h=(_[f[m+0]]+_[f[m+1]]+_[f[m+2]]+_[f[m+3]]+"-"+_[f[m+4]]+_[f[m+5]]+"-"+_[f[m+6]]+_[f[m+7]]+"-"+_[f[m+8]]+_[f[m+9]]+"-"+_[f[m+10]]+_[f[m+11]]+_[f[m+12]]+_[f[m+13]]+_[f[m+14]]+_[f[m+15]]).toLowerCase();if(!function(v){return typeof v=="string"&&g.test(v)}(h))throw TypeError("Stringified UUID is invalid");return h}function y(f,m,h){var v=(f=f||{}).random||(f.rng||p)();return v[6]=64|15&v[6],v[8]=128|63&v[8],w(v)}function S(f,m){if(!f||!m)return{};const h={...f};if(h.localCandidateId){const v=m.get(h.localCandidateId);h.local={...v}}if(h.remoteCandidateId){const v=m.get(h.remoteCandidateId);h.remote={...v}}return h}function C(f,m,h){return 8*function(v,T,R){const A=v[R],M=T?T[R]:null;return A===null||M===null?null:(A-M)/(v.timestamp-T.timestamp)*1e3}(f,m,h)}function P(f){if(!f.entries)return f;const m={};return f.forEach(function(h,v){m[v]=h}),m}function L(f,m,h={}){if(!f)return null;let v={audio:{inbound:[],outbound:[]},video:{inbound:[],outbound:[]},connection:{inbound:[],outbound:[]}};h.remote&&(v.remote={audio:{inbound:[],outbound:[]},video:{inbound:[],outbound:[]}});for(const T of f.values())switch(T.type){case"outbound-rtp":{const R=T.mediaType||T.kind,A={};let M={};if(!["audio","video"].includes(R))continue;if(T.codecId){const I=f.get(T.codecId);I&&(A.clockRate=I.clockRate,A.mimeType=I.mimeType,A.payloadType=I.payloadType)}M=f.get(T.mediaSourceId)||f.get(T.trackId)||{},v[R].outbound.push({...T,...A,track:{...M}});break}case"inbound-rtp":{let R=T.mediaType||T.kind,A={};const M={};if(!["audio","video"].includes(R))if(T.id.includes("Video"))R="video";else{if(!T.id.includes("Audio"))continue;R="audio"}if(T.codecId){const I=f.get(T.codecId);I&&(M.clockRate=I.clockRate,M.mimeType=I.mimeType,M.payloadType=I.payloadType)}if(!v.connection.id&&T.transportId){const I=f.get(T.transportId);if(I&&I.selectedCandidatePairId){const N=f.get(I.selectedCandidatePairId);v.connection=S(N,f)}}A=f.get(T.mediaSourceId)||f.get(T.trackId)||{},v[R].inbound.push({...T,...M,track:{...A}});break}case"peer-connection":v.connection.dataChannelsClosed=T.dataChannelsClosed,v.connection.dataChannelsOpened=T.dataChannelsOpened;break;case"remote-inbound-rtp":{if(!h.remote)break;let R=T.mediaType||T.kind;const A={};if(!["audio","video"].includes(R))if(T.id.includes("Video"))R="video";else{if(!T.id.includes("Audio"))continue;R="audio"}if(T.codecId){const M=f.get(T.codecId);M&&(A.clockRate=M.clockRate,A.mimeType=M.mimeType,A.payloadType=M.payloadType)}if(!v.connection.id&&T.transportId){const M=f.get(T.transportId);if(M&&M.selectedCandidatePairId){const I=f.get(M.selectedCandidatePairId);v.connection=S(I,f)}}v.remote[R].inbound.push({...T,...A});break}case"remote-outbound-rtp":{if(!h.remote)break;const R=T.mediaType||T.kind,A={};if(!["audio","video"].includes(R))continue;if(T.codecId){const M=f.get(T.codecId);M&&(A.clockRate=M.clockRate,A.mimeType=M.mimeType,A.payloadType=M.payloadType)}v.remote[R].outbound.push({...T,...A});break}}if(!v.connection.id)for(const T of f.values())T.type==="candidate-pair"&&T.nominated&&T.state==="succeeded"&&(v.connection=S(T,f));return v=function(T,R){return R&&(T.audio.inbound.map(A=>{let M=R.audio.inbound.find(I=>I.id===A.id);A.bitrate=C(A,M,"bytesReceived"),A.packetRate=C(A,M,"packetsReceived")}),T.audio.outbound.map(A=>{let M=R.audio.outbound.find(I=>I.id===A.id);A.bitrate=C(A,M,"bytesSent"),A.packetRate=C(A,M,"packetsSent")}),T.video.inbound.map(A=>{let M=R.video.inbound.find(I=>I.id===A.id);A.bitrate=C(A,M,"bytesReceived"),A.packetRate=C(A,M,"packetsReceived")}),T.video.outbound.map(A=>{let M=R.video.outbound.find(I=>I.id===A.id);A.bitrate=C(A,M,"bytesSent"),A.packetRate=C(A,M,"packetsSent")})),T}(v,m),v}let D,x={},k=[];t.WebRTCStats=class extends s{constructor(f){if(super(),this.monitoringSetInterval=0,this.connectionMonitoringSetInterval=0,this.connectionMonitoringInterval=1e3,this.remote=!0,this.peersToMonitor={},this.timeline=[],this.statsToMonitor=["inbound-rtp","outbound-rtp","remote-inbound-rtp","remote-outbound-rtp","peer-connection","data-channel","stream","track","sender","receiver","transport","candidate-pair","local-candidate","remote-candidate"],typeof window>"u")throw new Error("WebRTCStats only works in browser");const m={...f};this.isEdge=!!window.RTCIceGatherer,this.getStatsInterval=m.getStatsInterval||1e3,this.rawStats=!!m.rawStats,this.statsObject=!!m.statsObject,this.filteredStats=!!m.filteredStats,this.shouldWrapGetUserMedia=!!m.wrapGetUserMedia,typeof m.remote=="boolean"&&(this.remote=m.remote),this.debug=!!m.debug,this.logLevel=m.logLevel||"none",this.shouldWrapGetUserMedia&&this.wrapGetUserMedia()}async addPeer(f,m){return console.warn("The addPeer() method has been deprecated, please use addConnection()"),this.addConnection({peerId:f,pc:m})}async addConnection(f){const{pc:m,peerId:h}=f;let{connectionId:v,remote:T}=f;if(T=typeof T=="boolean"?T:this.remote,!(m&&m instanceof RTCPeerConnection))throw new Error("Missing argument 'pc' or is not of instance RTCPeerConnection");if(!h)throw new Error("Missing argument peerId");if(this.isEdge)throw new Error("Can't monitor peers in Edge at this time.");if(this.peersToMonitor[h]){if(v&&v in this.peersToMonitor[h])throw new Error(`We are already monitoring connection with id ${v}.`);for(let A in this.peersToMonitor[h]){const M=this.peersToMonitor[h][A];if(M.pc===m)throw new Error(`We are already monitoring peer with id ${h}.`);M.pc.connectionState==="closed"&&this.removeConnection({pc:M.pc})}}const R=m.getConfiguration();return R.iceServers&&R.iceServers.forEach(function(A){delete A.credential}),v||(v=y()),this.emitEvent({event:"addConnection",tag:"peer",peerId:h,connectionId:v,data:{options:f,peerConfiguration:R}}),this.monitorPeer({peerId:h,connectionId:v,pc:m,remote:T}),{connectionId:v}}getTimeline(f){return this.timeline=this.timeline.sort((m,h)=>m.timestamp.getTime()-h.timestamp.getTime()),f?this.timeline.filter(m=>m.tag===f):this.timeline}get logger(){const f=m=>{const h=["none","error","warn","info","debug"];return h.slice(0,h.indexOf(this.logLevel)+1).indexOf(m)>-1};return{error(...m){this.debug&&f("error")&&console.error("[webrtc-stats][error] ",...m)},warn(...m){this.debug&&f("warn")&&console.warn("[webrtc-stats][warn] ",...m)},info(...m){this.debug&&f("info")&&console.log("[webrtc-stats][info] ",...m)},debug(...m){this.debug&&f("debug")&&console.debug("[webrtc-stats][debug] ",...m)}}}removeConnection(f){let m,{connectionId:h,pc:v}=f;if(!v&&!h)throw new Error("Missing arguments. You need to either send pc or a connectionId.");if(h){if(typeof h!="string")throw new Error("connectionId must be a string.");for(let T in this.peersToMonitor)h in this.peersToMonitor[T]&&(v=this.peersToMonitor[T][h].pc,m=T)}else if(v){if(!(v instanceof RTCPeerConnection))throw new Error("pc must be an instance of RTCPeerConnection.");for(let T in this.peersToMonitor)for(let R in this.peersToMonitor[T])this.peersToMonitor[T][R].pc===v&&(h=R,m=T)}if(!v||!h)throw new Error("Could not find the desired connection.");return this.removePeerConnectionEventListeners(h,v),delete this.peersToMonitor[m][h],Object.values(this.peersToMonitor[m]).length===0&&delete this.peersToMonitor[m],{connectionId:h}}removeAllPeers(){for(let f in this.peersToMonitor)this.removePeer(f)}removePeer(f){if(this.logger.info(`Removing PeerConnection with id ${f}.`),this.peersToMonitor[f]){for(let m in this.peersToMonitor[f]){let h=this.peersToMonitor[f][m].pc;this.removePeerConnectionEventListeners(m,h)}delete this.peersToMonitor[f]}}destroy(){this.removeAllPeers(),k.forEach(f=>{this.removeTrackEventListeners(f)}),k=[],this.shouldWrapGetUserMedia&&D&&(navigator.mediaDevices.getUserMedia=D)}monitorPeer(f){let{peerId:m,connectionId:h,pc:v,remote:T}=f;if(!v)return void this.logger.warn("Did not receive pc argument when calling monitorPeer()");const R={pc:v,connectionId:h,stream:null,stats:{parsed:null,raw:null},options:{remote:T}};if(this.peersToMonitor[m]){if(h in this.peersToMonitor[m])return void this.logger.warn(`Already watching connection with ID ${h}`);this.peersToMonitor[m][h]=R}else this.peersToMonitor[m]={[h]:R};this.addPeerConnectionEventListeners(m,h,v),this.numberOfMonitoredPeers===1&&(this.startStatsMonitoring(),this.startConnectionStateMonitoring())}startStatsMonitoring(){this.monitoringSetInterval||(this.monitoringSetInterval=window.setInterval(()=>{this.numberOfMonitoredPeers||this.stopStatsMonitoring(),this.getStats().then(f=>{f.forEach(m=>{this.emitEvent(m)})})},this._getStatsInterval))}stopStatsMonitoring(){this.monitoringSetInterval&&(window.clearInterval(this.monitoringSetInterval),this.monitoringSetInterval=0)}async getStats(f=null){this.logger.info(f?`Getting stats from peer ${f}`:"Getting stats from all peers");let m={};if(f){if(!this.peersToMonitor[f])throw new Error(`Cannot get stats. Peer with id ${f} does not exist`);m[f]=this.peersToMonitor[f]}else m=this.peersToMonitor;let h=[];for(const v in m)for(const T in m[v]){const R=m[v][T],A=R.pc;if(A&&!this.checkIfConnectionIsClosed(v,T,A))try{const M=this.getTimestamp(),I=A.getStats(null);if(I){const N=await I,K=this.getTimestamp(),F=P(N),rt={remote:R.options.remote},Q=L(N,R.stats.parsed,rt),j={event:"stats",tag:"stats",peerId:v,connectionId:T,timeTaken:K-M,data:Q};this.rawStats===!0&&(j.rawStats=N),this.statsObject===!0&&(j.statsObject=F),this.filteredStats===!0&&(j.filteredStats=this.filteroutStats(F)),h.push(j),R.stats.parsed=Q}else this.logger.error(`PeerConnection from peer ${v} did not return any stats data`)}catch(M){this.logger.error(M)}}return h}startConnectionStateMonitoring(){this.connectionMonitoringSetInterval=window.setInterval(()=>{this.numberOfMonitoredPeers||this.stopConnectionStateMonitoring();for(const f in this.peersToMonitor)for(const m in this.peersToMonitor[f]){const h=this.peersToMonitor[f][m].pc;this.checkIfConnectionIsClosed(f,m,h)}},this.connectionMonitoringInterval)}checkIfConnectionIsClosed(f,m,h){const v=this.isConnectionClosed(h);if(v){this.removeConnection({pc:h});let T=h.connectionState==="closed"?"onconnectionstatechange":"oniceconnectionstatechange";this.emitEvent({event:T,peerId:f,connectionId:m,tag:"connection",data:"closed"})}return v}isConnectionClosed(f){return f.connectionState==="closed"||f.iceConnectionState==="closed"}stopConnectionStateMonitoring(){this.connectionMonitoringSetInterval&&(window.clearInterval(this.connectionMonitoringSetInterval),this.connectionMonitoringSetInterval=0)}wrapGetUserMedia(){if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)return void this.logger.warn("'navigator.mediaDevices.getUserMedia' is not available in browser. Will not wrap getUserMedia.");this.logger.info("Wrapping getUsermedia functions."),D=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);const f=this.parseGetUserMedia.bind(this);navigator.mediaDevices.getUserMedia=(function(){return f({constraints:arguments[0]}),D.apply(navigator.mediaDevices,arguments).then(m=>(f({stream:m}),m),m=>(f({error:m}),Promise.reject(m)))}).bind(navigator.mediaDevices)}filteroutStats(f={}){const m={...f};for(const v in m){var h=m[v];this.statsToMonitor.includes(h.type)||delete m[v]}return m}get peerConnectionListeners(){return{icecandidate:(f,m,h,v)=>{this.logger.debug("[pc-event] icecandidate | peerId: ${peerId}",v),this.emitEvent({event:"onicecandidate",tag:"connection",peerId:f,connectionId:m,data:v.candidate})},track:(f,m,h,v)=>{this.logger.debug(`[pc-event] track | peerId: ${f}`,v);const T=v.track,R=v.streams[0];f in this.peersToMonitor&&m in this.peersToMonitor[f]&&(this.peersToMonitor[f][m].stream=R),this.addTrackEventListeners(T,m),this.emitEvent({event:"ontrack",tag:"track",peerId:f,connectionId:m,data:{stream:R?this.getStreamDetails(R):null,track:T?this.getMediaTrackDetails(T):null,title:v.track.kind+":"+v.track.id+" "+v.streams.map(function(A){return"stream:"+A.id})}})},signalingstatechange:(f,m,h)=>{this.logger.debug(`[pc-event] signalingstatechange | peerId: ${f}`),this.emitEvent({event:"onsignalingstatechange",tag:"connection",peerId:f,connectionId:m,data:{signalingState:h.signalingState,localDescription:h.localDescription,remoteDescription:h.remoteDescription}})},iceconnectionstatechange:(f,m,h)=>{this.logger.debug(`[pc-event] iceconnectionstatechange | peerId: ${f}`),this.emitEvent({event:"oniceconnectionstatechange",tag:"connection",peerId:f,connectionId:m,data:h.iceConnectionState})},icegatheringstatechange:(f,m,h)=>{this.logger.debug(`[pc-event] icegatheringstatechange | peerId: ${f}`),this.emitEvent({event:"onicegatheringstatechange",tag:"connection",peerId:f,connectionId:m,data:h.iceGatheringState})},icecandidateerror:(f,m,h,v)=>{this.logger.debug(`[pc-event] icecandidateerror | peerId: ${f}`),this.emitEvent({event:"onicecandidateerror",tag:"connection",peerId:f,connectionId:m,error:{errorCode:v.errorCode}})},connectionstatechange:(f,m,h)=>{this.logger.debug(`[pc-event] connectionstatechange | peerId: ${f}`),this.emitEvent({event:"onconnectionstatechange",tag:"connection",peerId:f,connectionId:m,data:h.connectionState})},negotiationneeded:(f,m,h)=>{this.logger.debug(`[pc-event] negotiationneeded | peerId: ${f}`),this.emitEvent({event:"onnegotiationneeded",tag:"connection",peerId:f,connectionId:m})},datachannel:(f,m,h,v)=>{this.logger.debug(`[pc-event] datachannel | peerId: ${f}`,v),this.emitEvent({event:"ondatachannel",tag:"datachannel",peerId:f,connectionId:m,data:v.channel})}}}addPeerConnectionEventListeners(f,m,h){this.logger.debug(`Adding event listeners for peer ${f} and connection ${m}.`),x[m]={},Object.keys(this.peerConnectionListeners).forEach(v=>{x[m][v]=this.peerConnectionListeners[v].bind(this,f,m,h),h.addEventListener(v,x[m][v],!1)})}parseGetUserMedia(f){try{const m={event:"getUserMedia",tag:"getUserMedia",data:{...f}};f.stream&&(m.data.details=this.parseStream(f.stream),f.stream.getTracks().map(h=>{this.addTrackEventListeners(h),k.push(h)})),this.emitEvent(m)}catch{}}parseStream(f){const m={audio:[],video:[]};return f.getTracks().forEach(h=>{m[h.kind].push(this.getMediaTrackDetails(h))}),m}getMediaTrackDetails(f){return{enabled:f.enabled,id:f.id,contentHint:f.contentHint,kind:f.kind,label:f.label,muted:f.muted,readyState:f.readyState,constructorName:f.constructor.name,capabilities:f.getCapabilities?f.getCapabilities():{},constraints:f.getConstraints?f.getConstraints():{},settings:f.getSettings?f.getSettings():{},_track:f}}getStreamDetails(f){return{active:f.active,id:f.id,_stream:f}}getTrackEventObject(f){return{mute:m=>{this.emitEvent({event:"mute",tag:"track",connectionId:f,data:{event:m}})},unmute:m=>{this.emitEvent({event:"unmute",tag:"track",connectionId:f,data:{event:m}})},overconstrained:m=>{this.emitEvent({event:"overconstrained",tag:"track",connectionId:f,data:{event:m}})},ended:m=>{this.emitEvent({event:"ended",tag:"track",connectionId:f,data:{event:m}}),this.removeTrackEventListeners(m.target)}}}addTrackEventListeners(f,m){x[f.id]={};const h=this.getTrackEventObject(m);Object.keys(h).forEach(v=>{x[f.id][v]=h[v].bind(this),f.addEventListener(v,x[f.id][v])}),x[f.id].readyState=setInterval(()=>{if(f.readyState==="ended"){let v=new CustomEvent("ended",{detail:{check:"readyState"}});f.dispatchEvent(v)}},1e3)}removeTrackEventListeners(f){if(f.id in x){const m=this.getTrackEventObject();Object.keys(m).forEach(h=>{f.removeEventListener(h,x[f.id][h])}),clearInterval(x[f.id].readyState),delete x[f.id]}}addToTimeline(f){this.timeline.push(f),this.emit("timeline",f)}emitEvent(f){const m={...f,timestamp:new Date};this.addToTimeline(m),m.tag&&this.emit(m.tag,m)}set getStatsInterval(f){if(!Number.isInteger(f))throw new Error(`getStatsInterval should be an integer, got: ${f}`);this._getStatsInterval=f,this.monitoringSetInterval&&(this.stopStatsMonitoring(),this.startStatsMonitoring())}get numberOfMonitoredPeers(){return Object.keys(this.peersToMonitor).length}removePeerConnectionEventListeners(f,m){f in x&&(Object.keys(this.peerConnectionListeners).forEach(h=>{m.removeEventListener(h,x[f][h],!1)}),delete x[f]),m.getSenders().forEach(h=>{h.track&&this.removeTrackEventListeners(h.track)}),m.getReceivers().forEach(h=>{h.track&&this.removeTrackEventListeners(h.track)})}getTimestamp(){return Date.now()}wrapGetDisplayMedia(){const f=this;if(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia){const m=navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices),h=function(){return f.debug("navigator.mediaDevices.getDisplayMedia",null,arguments[0]),m.apply(navigator.mediaDevices,arguments).then(function(v){return v},function(v){return f.debug("navigator.mediaDevices.getDisplayMediaOnFailure",null,v.name),Promise.reject(v)})};navigator.mediaDevices.getDisplayMedia=h.bind(navigator.mediaDevices)}}}});($i=sd)&&$i.__esModule&&Object.prototype.hasOwnProperty.call($i,"default")&&$i.default;var a_=sd.WebRTCStats;function l_(e){const{packetsLost:t,packetsReceived:n,jitter:i,rtt:s}=e,o=function(c){const{jitter:d,rtt:u}=c,p=d+u/2;return .024*p+.11*(p-177.3)*(p>177.3?1:0)}({rtt:s,jitter:i}),r=function(c){const{packetsLost:d,packetsReceived:u}=c,p=d/(u+d)*100;return 20*Math.log(1+p)}({packetsLost:t,packetsReceived:n}),a=93.2-o-r+0,l=1+.035*a+7e-6*a*(a-60)*(100-a);return Math.min(Math.max(l,1),5)}function c_(e){return isNaN(e)?null:e>4.2?"excellent":e>=4.1&&e<=4.2?"good":e>=3.7&&e<=4?"fair":e>=3.1&&e<=3.6?"poor":"bad"}class u_ extends qn{constructor(t){super(),this.buildRequest({type:"debug_report_start",debug_report_id:t,debug_report_version:1})}}class d_ extends qn{constructor(t){super(),this.buildRequest({type:"debug_report_stop",debug_report_id:t,debug_report_version:1})}}class h_ extends qn{constructor(t,n){super(),this.buildRequest({type:"debug_report_data",debug_report_id:t,debug_report_version:1,debug_report_data:n})}}function f_(e){const t=an(),n=new a_({getStatsInterval:1e3,rawStats:!1,statsObject:!0,filteredStats:!1,remote:!0,debug:!1,logLevel:"warn"}),i=s=>H(this,void 0,void 0,function*(){s.event==="stats"&&J(V.StatsFrame,function({data:o}){var r,a,l,c,d,u,p,g;const{audio:_,remote:b}=o,{audio:w}=b,y=(a=(r=w.inbound[0])===null||r===void 0?void 0:r.jitter)!==null&&a!==void 0?a:1/0,S=(c=(l=w.inbound[0])===null||l===void 0?void 0:l.roundTripTime)!==null&&c!==void 0?c:1/0,C=(u=(d=_.inbound[0])===null||d===void 0?void 0:d.packetsReceived)!==null&&u!==void 0?u:-1,P=(g=(p=_.inbound[0])===null||p===void 0?void 0:p.packetsLost)!==null&&g!==void 0?g:-1,L=l_({jitter:1e3*y,rtt:1e3*S,packetsLost:P,packetsReceived:C});return{jitter:y,rtt:S,mos:L,quality:c_(L),inboundAudio:_.inbound[0],outboundAudio:_.outbound[0],remoteInboundAudio:w.inbound[0],remoteOutboundAudio:w.outbound[0]}}(s),e.uuid),yield e.execute(new h_(t,s))});return{start:(s,o,r)=>H(this,void 0,void 0,function*(){yield e.execute(new u_(t)),n.on("timeline",i),yield new Promise(a=>setTimeout(a,500)),n.addConnection({pc:s,peerId:o,connectionId:r})}),stop:s=>H(this,void 0,void 0,function*(){const o=n.getTimeline();J(V.StatsReport,o,e.uuid),s==="file"&&function(r,a){const l=new Blob([JSON.stringify(r)],{type:"application/json"}),c=URL.createObjectURL(l),d=document.createElement("a");d.href=c,d.download=`${a}.json`,d.click(),URL.revokeObjectURL(c)}(o,`webrtc-stats-${t}-${Date.now()}`),yield e.execute(new d_(t)),n.removeAllPeers(),n.destroy()})}}class rd{constructor(t,n,i){this.type=t,this.options=n,this.onSdpReadyTwice=null,this.statsReporter=null,this._negotiating=!1,this.handleConnectionStateChange=s=>H(this,void 0,void 0,function*(){const{connectionState:o}=this.instance;if(console.log(`[${new Date().toISOString()}] Connection State`,o),o==="failed"||o==="disconnected"){const r=()=>{this.instance.restartIce(),this._session._closeConnection(),this._session.connect(),window.removeEventListener("online",r)};if(navigator.onLine)return r();window.addEventListener("online",r)}}),this._handleIceConnectionStateChange=s=>{console.log(`[${new Date().toISOString()}] ICE Connection State`,this.instance.iceConnectionState)},this._handleIceGatheringStateChange=s=>{console.log(`[${new Date().toISOString()}] ICE Gathering State`,this.instance.iceGatheringState)},this._setAudioCodec=s=>{if(this.options.preferred_codecs&&this.options.preferred_codecs.length!==0)return s.setCodecPreferences?s.setCodecPreferences(this.options.preferred_codecs):void 0},B.info("New Peer with type:",this.type,"Options:",this.options),this._constraints={offerToReceiveAudio:!0,offerToReceiveVideo:!0},this._sdpReady=this._sdpReady.bind(this),this.handleSignalingStateChangeEvent=this.handleSignalingStateChangeEvent.bind(this),this.handleNegotiationNeededEvent=this.handleNegotiationNeededEvent.bind(this),this.handleTrackEvent=this.handleTrackEvent.bind(this),this.createPeerConnection=this.createPeerConnection.bind(this),this._session=i,this._init(),this.isDebugEnabled&&(this.statsReporter=f_(i))}get isOffer(){return this.type===Ft.Offer}get isAnswer(){return this.type===Ft.Answer}get isDebugEnabled(){return this.options.debug||this._session.options.debug}get debugOutput(){return this.options.debugOutput||this._session.options.debugOutput}startNegotiation(){this._negotiating=!0,this._isOffer()?this._createOffer():this._createAnswer()}_logTransceivers(){B.info("Number of transceivers:",this.instance.getTransceivers().length),this.instance.getTransceivers().forEach((t,n)=>{B.info(`>> Transceiver [${n}]:`,t.mid,t.direction,t.stopped),B.info(`>> Sender Params [${n}]:`,JSON.stringify(t.sender.getParameters(),null,2))})}handleSignalingStateChangeEvent(t){switch(B.info("signalingState:",this.instance.signalingState),this.instance.signalingState){case"stable":this._negotiating=!1;break;case"closed":this.instance=null;break;default:this._negotiating=!0}}handleNegotiationNeededEvent(){B.info("Negotiation needed event"),this.instance.signalingState==="stable"&&this.startNegotiation()}handleTrackEvent(t){const{streams:[n]}=t,{remoteElement:i,screenShare:s}=this.options;let{remoteStream:o}=this.options;o=n,s===!1&&Vi(i,o)}createPeerConnection(){return H(this,void 0,void 0,function*(){var t;this.instance=(t=this._config(),new window.RTCPeerConnection(t)),this.instance.onsignalingstatechange=this.handleSignalingStateChangeEvent,this.instance.onnegotiationneeded=this.handleNegotiationNeededEvent,this.instance.ontrack=this.handleTrackEvent,this.instance.addEventListener("connectionstatechange",this.handleConnectionStateChange),this.instance.addEventListener("iceconnectionstatechange",this._handleIceConnectionStateChange),this.instance.addEventListener("icegatheringstatechange",this._handleIceGatheringStateChange),this.instance.addEventListener("addstream",n=>{this.options.remoteStream=n.stream}),this.options.localStream=yield this._retrieveLocalStream().catch(n=>(J(V.MediaError,n,this.options.id),null))})}_init(){var t;return H(this,void 0,void 0,function*(){yield this.createPeerConnection(),yield(t=this.statsReporter)===null||t===void 0?void 0:t.start(this.instance,this._session.sessionid,this._session.sessionid);const{localElement:n,localStream:i=null,screenShare:s=!1}=this.options;if(Ni(i)){const o=i.getAudioTracks();B.info("Local audio tracks: ",o);const r=i.getVideoTracks();if(B.info("Local video tracks: ",r),this.isOffer&&typeof this.instance.addTransceiver=="function"){const a={direction:"sendrecv",streams:[i]};o.forEach(l=>{this.options.userVariables.microphoneLabel=l.label;const c=this.instance.addTransceiver(l,a);this._setAudioCodec(c)}),console.debug("Applying video transceiverParams",a),r.forEach(l=>{this.options.userVariables.cameraLabel=l.label,this.instance.addTransceiver(l,a)})}else typeof this.instance.addTrack=="function"?(o.forEach(a=>{this.options.userVariables.microphoneLabel=a.label,this.instance.addTrack(a,i)}),this.instance.getTransceivers().forEach(a=>this._setAudioCodec(a)),r.forEach(a=>{this.options.userVariables.cameraLabel=a.label,this.instance.addTrack(a,i)})):this.instance.addStream(i);s===!1&&((a=>{const l=Gn(a);l&&(l.muted=!0)})(n),Vi(n,i))}this.isOffer?(this.options.negotiateAudio&&this._checkMediaToNegotiate("audio"),this.options.negotiateVideo&&this._checkMediaToNegotiate("video")):this.startNegotiation(),this._logTransceivers()})}_getSenderByKind(t){return this.instance.getSenders().find(({track:n})=>n&&n.kind===t)}_checkMediaToNegotiate(t){if(!this._getSenderByKind(t)){const n=this.instance.addTransceiver(t);B.info("Add transceiver",t,n)}}_createOffer(){return H(this,void 0,void 0,function*(){this._isOffer()&&(this._constraints.offerToReceiveAudio=!!this.options.audio,this._constraints.offerToReceiveVideo=!!this.options.video,B.info("_createOffer - this._constraints",this._constraints),yield this.instance.createOffer(this._constraints).then(this._setLocalDescription.bind(this)).then(this._sdpReady).catch(t=>B.error("Peer _createOffer error:",t)))})}_setRemoteDescription(t){return H(this,void 0,void 0,function*(){yield this.instance.setRemoteDescription(t)})}_createAnswer(){return H(this,void 0,void 0,function*(){if(!this._isAnswer())return;if(this.instance.signalingState!=="stable")return console.log(" - But the signaling state isn't stable, so triggering rollback"),void(yield Promise.all([this.instance.setLocalDescription({type:"rollback"}),this.instance.setRemoteDescription({sdp:this.options.remoteSdp,type:Ft.Offer})]));yield this._setRemoteDescription({sdp:this.options.remoteSdp,type:Ft.Offer}),this._logTransceivers();const t=yield this.instance.createAnswer();yield this._setLocalDescription(t)})}_setLocalDescription(t){return H(this,void 0,void 0,function*(){const{useStereo:n,googleMaxBitrate:i,googleMinBitrate:s,googleStartBitrate:o,mediaSettings:r}=this.options;n&&(t.sdp=(a=>{const l=`\r
|
|
106
|
-
|
|
107
|
-
`);return u.forEach((p,g)=>{/^a=fmtp:\d*/.test(p)?u[g]+=`;x-google-max-bitrate=${l};x-google-min-bitrate=${c};x-google-start-bitrate=${d}`:/^a=mid:(1|video)/.test(p)&&(u[g]+=`\r
|
|
108
|
-
b=AS:${l}`)}),u.join(`\r
|
|
109
|
-
`)})(t.sdp,i,s,o)),r&&r.useSdpASBandwidthKbps&&r.sdpASBandwidthKbps!==null&&(t.sdp=((a,l)=>{let c="AS",d=l;return!navigator.userAgent.match(/firefox/gim)||navigator.userAgent.match(/OPR\/[0-9]{2}/gi)||navigator.userAgent.match(/edg/gim)||(c="TIAS",d=1e3*(l>>>0)),a.indexOf("b="+c+":")===-1?a.replace(/c=IN (.*)\r\n/,`c=IN $1\r
|
|
110
|
-
b=`+c+":"+d+`\r
|
|
111
|
-
`):a.replace(new RegExp("b="+c+`:.*\r
|
|
112
|
-
`),"b="+c+":"+d+`\r
|
|
113
|
-
`)})(t.sdp,r.sdpASBandwidthKbps)),yield this.instance.setLocalDescription(t)})}_sdpReady(){ln(this.onSdpReadyTwice)&&this.onSdpReadyTwice(this.instance.localDescription)}_retrieveLocalStream(){return H(this,void 0,void 0,function*(){if(Ni(this.options.localStream))return this.options.localStream;const t=yield(n=this.options,H(void 0,void 0,void 0,function*(){let{audio:i=!0,micId:s}=n;const{micLabel:o=""}=n;s&&(s=yield Bi(s,o,le.AudioIn).catch(c=>null),s&&(typeof i=="boolean"&&(i={}),i.deviceId={exact:s}));let{camId:r}=n,a=n.video;const{camLabel:l=""}=n;return r&&(r=yield Bi(r,l,le.Video).catch(c=>null),r&&(typeof a=="boolean"&&(a={}),a.deviceId={exact:r})),{audio:i,video:a}}));var n;return Fi(t)})}_isOffer(){return this.type===Ft.Offer}_isAnswer(){return this.type===Ft.Answer}_config(){const{prefetchIceCandidates:t,forceRelayCandidate:n}=this.options,i={bundlePolicy:"max-compat",iceCandidatePoolSize:t?10:0,iceServers:[Lv,Lu],iceTransportPolicy:n?"relay":"all"};return B.info("RTC config",i),i}close(){var t;return H(this,void 0,void 0,function*(){yield(t=this.statsReporter)===null||t===void 0?void 0:t.stop(this.debugOutput),this.instance&&(this.instance.close(),this.instance=null)})}}const p_=jr;class od{constructor(t,n){this.session=t,this.id="",this.state=X[X.New],this.prevState="",this.channels=[],this.role=Wn.Participant,this.extension=null,this._state=X.New,this._prevState=X.New,this.gotAnswer=!1,this.gotEarly=!1,this._lastSerno=0,this._targetNodeId=null,this._iceTimeout=null,this._iceDone=!1,this._statsBindings=[],this._statsIntervalId=null,this._checkConferenceSerno=w=>{const y=w<0||!this._lastSerno||this._lastSerno&&w===this._lastSerno+1;return y&&w>=0&&(this._lastSerno=w),y},this._doStats=()=>{this.peer&&this.peer.instance&&this._statsBindings.length!==0&&this.peer.instance.getStats().then(w=>{w.forEach(y=>{this._statsBindings.forEach(S=>{if(S.callback){if(S.constraints){for(var C in S.constraints)if(S.constraints.hasOwnProperty(C)&&S.constraints[C]!==y[C])return}S.callback(y)}})})})};const{iceServers:i,speaker:s,micId:o,micLabel:r,camId:a,camLabel:l,localElement:c,remoteElement:d,options:u,mediaConstraints:{audio:p,video:g},ringtoneFile:_,ringbackFile:b}=t;this.options=Object.assign({},jv,{audio:p,video:g,iceServers:i,localElement:c,remoteElement:d,micId:o,micLabel:r,camId:a,camLabel:l,speakerId:s,ringtoneFile:_,ringbackFile:b,debug:u.debug,debugOutput:u.debugOutput},n),this._onMediaError=this._onMediaError.bind(this),this._init(),this.options&&(this._ringtone=Ju(this.options.ringtoneFile,"_ringtone"),this._ringback=Ju(this.options.ringbackFile,"_ringback"))}get nodeId(){return this._targetNodeId}set nodeId(t){this._targetNodeId=t}get telnyxIDs(){return{telnyxCallControlId:this.options.telnyxCallControlId,telnyxSessionId:this.options.telnyxSessionId,telnyxLegId:this.options.telnyxLegId}}get localStream(){return this.options.localStream}get remoteStream(){return this.options.remoteStream}get memberChannel(){return`conference-member.${this.id}`}invite(){this.direction=Se.Outbound,this.peer=new rd(Ft.Offer,this.options,this.session),this._registerPeerEvents()}answer(t={}){var n,i,s,o;this.stopRingtone(),this.options.video=(i=(n=t.video)!==null&&n!==void 0?n:this.options.video)!==null&&i!==void 0&&i,this.direction=Se.Inbound,((s=t==null?void 0:t.customHeaders)===null||s===void 0?void 0:s.length)>0&&(this.options=Object.assign(Object.assign({},this.options),{customHeaders:t.customHeaders})),((o=t.preferred_codecs)===null||o===void 0?void 0:o.length)>0&&(this.options.preferred_codecs=t.preferred_codecs),this.peer=new rd(Ft.Answer,this.options,this.session),this._registerPeerEvents()}playRingtone(){Qu(this._ringtone)}stopRingtone(){td(this._ringtone)}playRingback(){Qu(this._ringback)}stopRingback(){td(this._ringback)}hangup(t,n){var i,s,o;let r=t||{},a=n!==!1;this.cause=r.cause||"NORMAL_CLEARING",this.causeCode=r.causeCode||16,this.sipCode=r.sipCode||null,this.sipReason=r.sipReason||null,this.sipCallId=r.sip_call_id||null,this.options.customHeaders=[...(i=this.options.customHeaders)!==null&&i!==void 0?i:[],...(o=(s=r==null?void 0:r.dialogParams)===null||s===void 0?void 0:s.customHeaders)!==null&&o!==void 0?o:[]],this.setState(X.Hangup);const l=()=>{var c;return(c=this.peer)===null||c===void 0||c.close(),this.setState(X.Destroy)};if(this.stopRingtone(),this.stopRingback(),a){const c=new e_({sessid:this.session.sessionid,dialogParams:this.options,cause:"USER_BUSY",causeCode:17});this._execute(c).catch(d=>{B.error("telnyx_rtc.bye failed!",d),J(V.Error,{error:d,sessionId:this.session.sessionid},this.session.uuid)}).then(l.bind(this))}else l()}hold(){const t=new $r({sessid:this.session.sessionid,action:"hold",dialogParams:this.options});return this._execute(t).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this))}unhold(){const t=new $r({sessid:this.session.sessionid,action:"unhold",dialogParams:this.options});return this._execute(t).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this))}toggleHold(){const t=new $r({sessid:this.session.sessionid,action:"toggleHold",dialogParams:this.options});return this._execute(t).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this))}dtmf(t){const n=new nd({sessid:this.session.sessionid,dtmf:t,dialogParams:this.options});this._execute(n)}message(t,n){const i={from:this.session.options.login,to:t,body:n},s=new nd({sessid:this.session.sessionid,msg:i,dialogParams:this.options});this._execute(s)}muteAudio(){Yu(this.options.localStream)}unmuteAudio(){Xu(this.options.localStream)}toggleAudioMute(){Zu(this.options.localStream)}setAudioInDevice(t){return H(this,void 0,void 0,function*(){const{instance:n}=this.peer,i=n.getSenders().find(({track:{kind:s}})=>s==="audio");if(i){const s=yield Fr({audio:{deviceId:{exact:t}}}),o=s.getAudioTracks()[0];i.replaceTrack(o),this.options.micId=t;const{localStream:r}=this.options;r.getAudioTracks().forEach(a=>a.stop()),r.getVideoTracks().forEach(a=>s.addTrack(a)),this.options.localStream=s}})}muteVideo(){var t;t=this.options.localStream,hn(t,"video",!1)}unmuteVideo(){var t;t=this.options.localStream,hn(t,"video",!0)}toggleVideoMute(){var t;t=this.options.localStream,hn(t,"video",null)}setVideoDevice(t){return H(this,void 0,void 0,function*(){const{instance:n}=this.peer,i=n.getSenders().find(({track:{kind:s}})=>s==="video");if(i){const s=yield Fr({video:{deviceId:{exact:t}}}),o=s.getVideoTracks()[0];i.replaceTrack(o);const{localElement:r,localStream:a}=this.options;Vi(r,s),this.options.camId=t,a.getAudioTracks().forEach(l=>s.addTrack(l)),a.getVideoTracks().forEach(l=>l.stop()),this.options.localStream=s}})}deaf(){Yu(this.options.remoteStream)}undeaf(){Xu(this.options.remoteStream)}toggleDeaf(){Zu(this.options.remoteStream)}setBandwidthEncodingsMaxBps(t,n){return H(this,void 0,void 0,function*(){if(!this||!this.peer)return void B.error("Could not set bandwidth (reason: no peer connection). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");const{instance:i}=this.peer,s=i.getSenders();if(!s)return void B.error("Could not set bandwidth (reason: no senders). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");const o=s.find(({track:{kind:r}})=>r===n);if(o){const r=o.getParameters();r.encodings||(r.encodings=[{rid:"h"}]),B.info("Parameters: ",r),B.info("Setting max ",n==="audio"?"audio":"video"," bandwidth to: ",t," [bps]"),r.encodings[0].maxBitrate=t,yield o.setParameters(r).then(()=>{B.info(n==="audio"?"New audio":"New video"," bandwidth settings in use: ",o.getParameters())}).catch(a=>console.error(a))}else B.error("Could not set bandwidth (reason: no "+n+" sender). Dynamic bandwidth can only be set when there is a call running - is there any call running?)")})}setAudioBandwidthEncodingsMaxBps(t){this.setBandwidthEncodingsMaxBps(t,"audio")}setVideoBandwidthEncodingsMaxBps(t){this.setBandwidthEncodingsMaxBps(t,"video")}getStats(t,n){if(!t)return;const i={callback:t,constraints:n};this._statsBindings.push(i),!this._statsIntervalId&&this._startStats(2e3)}setState(t){switch(this._prevState=this._state,this._state=t,this.state=X[this._state].toLowerCase(),this.prevState=X[this._prevState].toLowerCase(),B.info(`Call ${this.id} state change from ${this.prevState} to ${this.state}`),this._dispatchNotification({type:ae.callUpdate,call:this}),t){case X.Purge:this.hangup({cause:"PURGE",causeCode:"01"},!1);break;case X.Active:setTimeout(()=>{const{remoteElement:n,speakerId:i}=this.options;n&&i&&Wu(n,i)},0);break;case X.Destroy:this._finalize()}}handleMessage(t){const{method:n,params:i}=t;switch(n){case nt.Answer:if(this.gotAnswer=!0,this._state>=X.Active)return;this._state>=X.Early&&this.setState(X.Active),this.gotEarly||this._onRemoteSdp(i.sdp),this.stopRingback(),this.stopRingtone();break;case nt.Media:if(this._state>=X.Early)return;this.gotEarly=!0,this._onRemoteSdp(i.sdp);break;case nt.Display:case nt.Attach:{const{display_name:o,display_number:r,display_direction:a}=i;this.extension=r;const l=a===Se.Inbound?Se.Outbound:Se.Inbound,c={type:ae[n],call:this,displayName:o,displayNumber:r,displayDirection:l};J(V.Notification,c,this.id)||J(V.Notification,c,this.session.uuid);break}case nt.Info:case nt.Event:{const o=Object.assign(Object.assign({},i),{type:ae.generic,call:this});J(V.Notification,o,this.id)||J(V.Notification,o,this.session.uuid);break}case nt.Ringing:this.playRingback(),i.telnyx_call_control_id&&(this.options.telnyxCallControlId=i.telnyx_call_control_id),i.telnyx_session_id&&(this.options.telnyxSessionId=i.telnyx_session_id),i.telnyx_leg_id&&(this.options.telnyxLegId=i.telnyx_leg_id);break;case nt.Bye:const s=i.client_state||i.clientState;s&&(this.options.clientState=s),this.stopRingback(),this.stopRingtone(),this.hangup(i,!1)}}handleConferenceUpdate(t,n){return H(this,void 0,void 0,function*(){if(!this._checkConferenceSerno(t.wireSerno)&&t.name!==n.laName)return B.error("ConferenceUpdate invalid wireSerno or packet name:",t),"INVALID_PACKET";const{action:i,data:s,hashKey:o=String(this._lastSerno),arrIndex:r}=t;switch(i){case"bootObj":{this._lastSerno=0;const{chatChannel:a,infoChannel:l,modChannel:c,laName:d,conferenceMemberID:u,role:p}=n;this._dispatchConferenceUpdate({action:At.Join,conferenceName:d,participantId:Number(u),role:p}),a&&(yield this._subscribeConferenceChat(a)),l&&(yield this._subscribeConferenceInfo(l)),c&&p===Wn.Moderator&&(yield this._subscribeConferenceModerator(c));const g=[];for(const _ in s)g.push(Object.assign({callId:s[_][0],index:Number(_)},Di(s[_][1])));this._dispatchConferenceUpdate({action:At.Bootstrap,participants:g});break}case"add":this._dispatchConferenceUpdate(Object.assign({action:At.Add,callId:o,index:r},Di(s)));break;case"modify":this._dispatchConferenceUpdate(Object.assign({action:At.Modify,callId:o,index:r},Di(s)));break;case"del":this._dispatchConferenceUpdate(Object.assign({action:At.Delete,callId:o,index:r},Di(s)));break;case"clear":this._dispatchConferenceUpdate({action:At.Clear});break;default:this._dispatchConferenceUpdate({action:i,data:s,callId:o,index:r})}})}_addChannel(t){this.channels.includes(t)||this.channels.push(t);const n=this.session.relayProtocol;this.session._existsSubscription(n,t)&&(this.session.subscriptions[n][t]=Object.assign(Object.assign({},this.session.subscriptions[n][t]),{callId:this.id}))}_subscribeConferenceChat(t){return H(this,void 0,void 0,function*(){const n={nodeId:this.nodeId,channels:[t],handler:s=>{const{direction:o,from:r,fromDisplay:a,message:l,type:c}=s.data;this._dispatchConferenceUpdate({action:At.ChatMessage,direction:o,participantNumber:r,participantName:a,messageText:l,messageType:c,messageId:s.eventSerno})}},i=yield this.session.vertoSubscribe(n).catch(s=>{B.error("ConfChat subscription error:",s)});ji(i,t)&&(this._addChannel(t),Object.defineProperties(this,{sendChatMessage:{configurable:!0,value:(s,o)=>{this.session.vertoBroadcast({nodeId:this.nodeId,channel:t,data:{action:"send",message:s,type:o}})}}}))})}_subscribeConferenceInfo(t){return H(this,void 0,void 0,function*(){const n={nodeId:this.nodeId,channels:[t],handler:s=>{const{eventData:o}=s;o.contentType==="layout-info"?(o.callID=this.id,id(this.session,o)):B.error("Conference-Info unknown contentType",s)}},i=yield this.session.vertoSubscribe(n).catch(s=>{B.error("ConfInfo subscription error:",s)});ji(i,t)&&this._addChannel(t)})}_confControl(t,n={}){const i=Object.assign({application:"conf-control",callID:this.id,value:null},n);this.session.vertoBroadcast({nodeId:this.nodeId,channel:t,data:i})}_subscribeConferenceModerator(t){return H(this,void 0,void 0,function*(){const n=(r,a=null,l=null)=>{const c=parseInt(a)||null;this._confControl(t,{command:r,id:c,value:l})},i=()=>{const{video:r}=this.options;if(typeof r=="boolean"&&!r||typeof r=="object"&&Ou(r))throw`Conference ${this.id} has no video!`},s={nodeId:this.nodeId,channels:[t],handler:r=>{const{data:a}=r;if(a["conf-command"]==="list-videoLayouts"){if(a.responseData){const l=JSON.stringify(a.responseData).replace(/IDS"/g,'Ids"');this._dispatchConferenceUpdate({action:At.LayoutList,layouts:JSON.parse(l)})}}else this._dispatchConferenceUpdate({action:At.ModCmdResponse,command:a["conf-command"],response:a.response})}},o=yield this.session.vertoSubscribe(s).catch(r=>{B.error("ConfMod subscription error:",r)});ji(o,t)&&(this.role=Wn.Moderator,this._addChannel(t),Object.defineProperties(this,{listVideoLayouts:{configurable:!0,value:()=>{n("list-videoLayouts")}},playMedia:{configurable:!0,value:r=>{n("play",null,r)}},stopMedia:{configurable:!0,value:()=>{n("stop",null,"all")}},deaf:{configurable:!0,value:r=>{n("deaf",r)}},undeaf:{configurable:!0,value:r=>{n("undeaf",r)}},startRecord:{configurable:!0,value:r=>{n("recording",null,["start",r])}},stopRecord:{configurable:!0,value:()=>{n("recording",null,["stop","all"])}},snapshot:{configurable:!0,value:r=>{i(),n("vid-write-png",null,r)}},setVideoLayout:{configurable:!0,value:(r,a)=>{i(),n("vid-layout",null,a?[r,a]:r)}},kick:{configurable:!0,value:r=>{n("kick",r)}},muteMic:{configurable:!0,value:r=>{n("tmute",r)}},muteVideo:{configurable:!0,value:r=>{i(),n("tvmute",r)}},presenter:{configurable:!0,value:r=>{i(),n("vid-res-id",r,"presenter")}},videoFloor:{configurable:!0,value:r=>{i(),n("vid-floor",r,"force")}},banner:{configurable:!0,value:(r,a)=>{i(),n("vid-banner",r,encodeURI(a))}},volumeDown:{configurable:!0,value:r=>{n("volume_out",r,"down")}},volumeUp:{configurable:!0,value:r=>{n("volume_out",r,"up")}},gainDown:{configurable:!0,value:r=>{n("volume_in",r,"down")}},gainUp:{configurable:!0,value:r=>{n("volume_in",r,"up")}},transfer:{configurable:!0,value:(r,a)=>{n("transfer",r,a)}}}))})}_handleChangeHoldStateSuccess(t){return t.holdState==="active"?this.setState(X.Active):this.setState(X.Held),!0}_handleChangeHoldStateError(t){return B.error(`Failed to ${t.action} on call ${this.id}`),!1}_onRemoteSdp(t){return H(this,void 0,void 0,function*(){const n=new RTCSessionDescription({sdp:t,type:"answer"});yield this.peer.instance.setRemoteDescription(n).then(()=>{this.gotEarly&&this.setState(X.Early),this.gotAnswer&&this.setState(X.Active)}).catch(i=>{B.error("Call setRemoteDescription Error: ",i),this.hangup()})})}_requestAnotherLocalDescription(){ln(this.peer.onSdpReadyTwice)?J(V.Error,{error:new Error("SDP without candidates for the second time!"),sessionId:this.session.sessionid},this.session.uuid):(Object.defineProperty(this.peer,"onSdpReadyTwice",{value:this._onIceSdp.bind(this)}),this._iceDone=!1,this.peer.startNegotiation())}_onIceSdp(t){var n,i;this._iceTimeout&&clearTimeout(this._iceTimeout),this._iceTimeout=null,this._iceDone=!0;const{sdp:s,type:o}=t;if(s.indexOf("candidate")===-1)return B.info(`No candidate - retry
|
|
114
|
-
`),void this._requestAnotherLocalDescription();(i=(n=this.peer)===null||n===void 0?void 0:n.instance)===null||i===void 0||i.removeEventListener("icecandidate",this._onIce);let r=null;const a={sessid:this.session.sessionid,sdp:s,dialogParams:this.options,"User-Agent":`Web-${p_}`};switch(o){case Ft.Offer:this.setState(X.Requesting),r=new Jv(a);break;case Ft.Answer:this.setState(X.Answering),r=this.options.attach===!0?new t_(a):new Qv(a);break;default:return B.error(`${this.id} - Unknown local SDP type:`,t),this.hangup({},!1)}this._execute(r).then(l=>{const{node_id:c=null}=l;this._targetNodeId=c,o===Ft.Offer?this.setState(X.Trying):this.setState(X.Active)}).catch(l=>{B.error(`${this.id} - Sending ${o} error:`,l),this.hangup()}),console.timeEnd(Pu)}_onIce(t){const{instance:n}=this.peer;this._iceTimeout===null&&(this._iceTimeout=setTimeout(()=>this._onIceSdp(n.localDescription),1e3)),t.candidate?B.debug("RTCPeer Candidate:",t.candidate):this._onIceSdp(n.localDescription)}_registerPeerEvents(){const{instance:t}=this.peer;this._iceDone=!1,t.onicecandidate=n=>{this._iceDone||this._onIce(n)},t.addEventListener("addstream",n=>{this.options.remoteStream=n.stream}),t.addEventListener("track",n=>{this.options.remoteStream=n.streams[0];const{remoteElement:i,remoteStream:s,screenShare:o}=this.options;o===!1&&Vi(i,s)})}_onMediaError(t){this._dispatchNotification({type:ae.userMediaError,error:t}),this.hangup({},!1)}_dispatchConferenceUpdate(t){this._dispatchNotification(Object.assign({type:ae.conferenceUpdate,call:this},t))}_dispatchNotification(t){this.options.screenShare!==!0&&(J(V.Notification,t,this.id,!1)||J(V.Notification,t,this.session.uuid))}_execute(t){return this.nodeId&&(t.targetNodeId=this.nodeId),this.session.execute(t)}_init(){const{id:t,userVariables:n,remoteCallerNumber:i,onNotification:s}=this.options;t||(this.options.id=an()),this.id=this.options.id,n&&!Ou(n)||(this.options.userVariables=this.session.options.userVariables||{}),i||(this.options.remoteCallerNumber=this.options.destinationNumber),this.session.calls[this.id]=this,un(V.MediaError,this._onMediaError,this.id),ln(s)&&un(V.Notification,s.bind(this),this.id),this.setState(X.New),B.info("New Call with Options:",this.options)}_finalize(){this._stopStats(),this.peer&&this.peer.instance&&(this.peer.instance.close(),this.peer=null);const{remoteStream:t,localStream:n}=this.options;Kn(t),Kn(n),dn(V.MediaError,null,this.id),this.session.calls[this.id]=null,delete this.session.calls[this.id]}_startStats(t){this._statsIntervalId=setInterval(this._doStats,t),B.info("Stats started")}_stopStats(){this._statsIntervalId&&(clearInterval(this._statsIntervalId),this._statsIntervalId=null),B.info("Stats stopped")}}od.setStateTelnyx=e=>{if(e){switch(e._state){case X.Requesting:case X.Recovering:case X.Trying:case X.Early:e.state="connecting";break;case X.Active:e.state="active";break;case X.Held:e.state="held";break;case X.Hangup:case X.Destroy:e.state="done";break;case X.Answering:e.state="ringing";break;case X.New:e.state="new"}return e}};class Fe extends od{constructor(){super(...arguments),this._statsInterval=null,this.sendConversationMessage=(t,n)=>this.session.execute(new r_(t,n))}hangup(t={},n=!0){this.screenShare instanceof Fe&&this.screenShare.hangup(t,n),super.hangup(t,n)}startScreenShare(t){return H(this,void 0,void 0,function*(){const n=yield(i={video:!0},navigator.mediaDevices.getDisplayMedia(i));var i;n.getTracks().forEach(c=>{c.addEventListener("ended",()=>{this.screenShare&&this.screenShare.hangup()})});const{remoteCallerName:s,remoteCallerNumber:o,callerName:r,callerNumber:a}=this.options,l=Object.assign({screenShare:!0,localStream:n,destinationNumber:`${this.extension}-screen`,remoteCallerName:s,remoteCallerNumber:`${o}-screen`,callerName:`${r} (Screen)`,callerNumber:`${a} (Screen)`},t);return this.screenShare=new Fe(this.session,l),this.screenShare.invite(),this.screenShare})}stopScreenShare(){this.screenShare instanceof Fe&&this.screenShare.hangup()}setAudioOutDevice(t){return H(this,void 0,void 0,function*(){this.options.speakerId=t;const{remoteElement:n,speakerId:i}=this.options;return!(!n||!i)&&Wu(n,i)})}_finalize(){this._stats(!1),super._finalize()}_stats(t=!0){if(t===!1)return clearInterval(this._statsInterval);B.setLevel(2),this._statsInterval=window.setInterval(()=>H(this,void 0,void 0,function*(){const n=yield this.peer.instance.getStats(null);let i="";const s=["certificate","codec","peer-connection","stream","local-candidate","remote-candidate"],o=["id","type","timestamp"];n.forEach(r=>{s.includes(r.type)||(i+=`
|
|
105
|
+
`),this._wsClient.send(JSON.stringify(n)),i}close(){this._wsClient&&(cn(this._wsClient._beginClose)?this._wsClient._beginClose():this._wsClient.close()),this._wsClient=null}_unsetTimer(e){clearTimeout(this._timers[e]),delete this._timers[e]}_handleStringResponse(e){if(/^#SP/.test(e))switch(e[3]){case"U":this.upDur=parseInt(e.substring(4));break;case"D":this.downDur=parseInt(e.substring(4)),J(F.SpeedTest,{upDur:this.upDur,downDur:this.downDur},this.session.uuid)}else L.warn("Unknown message from socket",e)}}class Wn{buildRequest(e){this.request=Object.assign({jsonrpc:"2.0",id:an()},e)}}const $u={id:"callID",destinationNumber:"destination_number",remoteCallerName:"remote_caller_id_name",remoteCallerNumber:"remote_caller_id_number",callerName:"caller_id_name",callerNumber:"caller_id_number",customHeaders:"custom_headers"};class Ee extends Wn{constructor(e={}){if(super(),e.hasOwnProperty("dialogParams")){const n=Au(e.dialogParams,["remoteSdp","localStream","remoteStream","onNotification","camId","micId","speakerId"]);for(const i in $u)i&&n.hasOwnProperty(i)&&(n[$u[i]]=n[i],delete n[i]);e.dialogParams=n}this.buildRequest({method:this.toString(),params:e})}}class Uu extends Ee{constructor(e){super(),this.method=te.GatewayState,this.buildRequest({method:this.method,voice_sdk_id:e,params:{}})}}class q_{constructor(e){this.pendingRequestId=null,this.onSocketMessage=n=>j(this,void 0,void 0,function*(){n.id===this.pendingRequestId&&this.gatewayStateTask.resolve(Rr(n))}),this.getIsRegistered=()=>j(this,void 0,void 0,function*(){const n=new Uu(Ni());this.pendingRequestId=n.request.id,this.gatewayStateTask=Vu({}),this.session.execute(n);const i=yield this.gatewayStateTask.promise;return!!i&&[Pe.REGISTER,Pe.REGED].includes(i)}),this.session=e,this.gatewayStateTask=Vu({}),this.session.on("telnyx.socket.message",this.onSocketMessage)}}class K_{constructor(e){if(this.options=e,this.uuid=an(),this.sessionid="",this.subscriptions={},this.signature=null,this.relayProtocol=null,this.contexts=[],this.timeoutErrorCode=-32e3,this.invalidMethodErrorCode=-32601,this.connection=null,this._jwtAuth=!1,this._doKeepAlive=!1,this._autoReconnect=!0,this._idle=!1,this._executeQueue=[],!this.validateOptions())throw new Error("Invalid init options");this._onSocketOpen=this._onSocketOpen.bind(this),this.onNetworkClose=this.onNetworkClose.bind(this),this._onSocketMessage=this._onSocketMessage.bind(this),this._handleLoginError=this._handleLoginError.bind(this),this._attachListeners(),this.connection=new ju(this),this.registerAgent=new q_(this)}get __logger(){return L}get connected(){return this.connection&&this.connection.connected}getIsRegistered(){return j(this,void 0,void 0,function*(){return this.registerAgent.getIsRegistered()})}get reconnectDelay(){return 1e3*Nu(2,6)}execute(e){return this._idle?new Promise(n=>this._executeQueue.push({resolve:n,msg:e})):this.connected?this.connection.send(e):new Promise(n=>{this._executeQueue.push({resolve:n,msg:e}),this.connect()})}executeRaw(e){this._idle?this._executeQueue.push({msg:e}):this.connection.sendRawText(e)}validateOptions(){return Pr(this.options)||Oi(this.options)}broadcast(e){}disconnect(){return j(this,void 0,void 0,function*(){clearTimeout(this._reconnectTimeout),this.subscriptions={},this._autoReconnect=!1,this.relayProtocol=null,this._closeConnection(),yield sessionStorage.removeItem(this.signature),this._executeQueue=[],this._detachListeners()})}on(e,n){return un(e,n,this.uuid),this}off(e,n){return dn(e,n,this.uuid),this}connect(){return j(this,void 0,void 0,function*(){this.connection||(this.connection=new ju(this)),this._attachListeners(),this.connection.isAlive||this.connection.connect()})}_handleLoginError(e){J(F.Error,{error:e,sessionId:this.sessionid},this.uuid)}_onSocketOpen(){return j(this,void 0,void 0,function*(){})}onNetworkClose(){this.relayProtocol&&Lr(this.relayProtocol);for(const e in this.subscriptions)Lr(e);this.subscriptions={},this.contexts=[],this._autoReconnect&&(this._reconnectTimeout=setTimeout(()=>this.connect(),this.reconnectDelay))}_onSocketMessage(e){}_removeSubscription(e,n){this._existsSubscription(e,n)&&(n?(delete this.subscriptions[e][n],dn(e,null,n)):(delete this.subscriptions[e],Lr(e)))}_addSubscription(e,n=null,i){this._existsSubscription(e,i)||(this._existsSubscription(e)||(this.subscriptions[e]={}),this.subscriptions[e][i]={},cn(n)&&un(e,n,i))}_existsSubscription(e,n){return!(!this.subscriptions.hasOwnProperty(e)||!(!n||n&&this.subscriptions[e].hasOwnProperty(n)))}_attachListeners(){this._detachListeners(),this.on(F.SocketOpen,this._onSocketOpen),this.on(F.SocketClose,this.onNetworkClose),this.on(F.SocketError,this.onNetworkClose),this.on(F.SocketMessage,this._onSocketMessage)}_detachListeners(){this.off(F.SocketOpen,this._onSocketOpen),this.off(F.SocketClose,this.onNetworkClose),this.off(F.SocketError,this.onNetworkClose),this.off(F.SocketMessage,this._onSocketMessage)}_emptyExecuteQueues(){this._executeQueue.forEach(({resolve:e,msg:n})=>{typeof n=="string"?this.executeRaw(n):e(this.execute(n))})}_closeConnection(){this._idle=!0,clearTimeout(this._keepAliveTimeout),this.connection&&this.connection.close()}_keepAlive(){this._doKeepAlive===!0&&(this._pong=!1,this._keepAliveTimeout=setTimeout(()=>this._keepAlive(),3e4))}static on(e,n){un(e,n)}static off(e){dn(e)}static uuid(){return an()}clearConnection(){this.connection=null}hasAutoReconnect(){return this._autoReconnect}}const Or=t=>navigator.mediaDevices.getUserMedia(t),Vi=t=>t&&t instanceof MediaStream,zn=(t,e)=>{const n=Li(t);n!==null&&(n.getAttribute("autoplay")||n.setAttribute("autoplay","autoplay"),n.getAttribute("playsinline")||n.setAttribute("playsinline","playsinline"),n.srcObject=e)},Gu=(t,e)=>j(void 0,void 0,void 0,function*(){const n=Li(t);if(n===null)return L.info("No HTMLMediaElement to attach the speakerId"),!1;if(typeof e!="string")return L.info(`Invalid speaker deviceId: '${e}'`),!1;try{return yield n.setSinkId(e),!0}catch{return!1}}),X_=t=>{t&&t.readyState==="live"&&t.stop()},qn=t=>{Vi(t)&&t.getTracks().forEach(X_),t=null},Fi=t=>j(void 0,void 0,void 0,function*(){L.info("RTCService.getUserMedia",t);const{audio:e}=t;if(!e)return null;try{return yield Or(t)}catch(n){throw L.error("getUserMedia error: ",n),n}}),Kn=(t=null,e=!1)=>j(void 0,void 0,void 0,function*(){let n=[];const i=yield navigator.mediaDevices.getUserMedia(((s=null)=>({audio:!s||s===mt.AudioIn||s===mt.AudioOut,video:!s||s===mt.Video}))(t)).catch(s=>(console.error(s),null));if(i){if(qn(i),n=yield navigator.mediaDevices.enumerateDevices(),t&&(n=n.filter(o=>o.kind===t)),e===!0)return n;const s=[];n=n.filter(o=>{if(!o.groupId)return!0;const r=`${o.kind}-${o.groupId}`;return!s.includes(r)&&(s.push(r),!0)})}return n}),Hu=[[320,240],[640,360],[640,480],[1280,720],[1920,1080]],Nr=(t,e,n)=>j(void 0,void 0,void 0,function*(){const i=yield Kn(n,!0);for(let s=0;s<i.length;s++){const{deviceId:o,label:r}=i[s];if(t===o||e===r)return o}return null}),Y_=t=>{const e=navigator.mediaDevices.getSupportedConstraints();Object.keys(t).map(n=>{e.hasOwnProperty(n)&&t[n]!==null&&t[n]!==void 0||delete t[n]})},Vr=(t,e)=>{if(!t)return!1;const{subscribed:n,alreadySubscribed:i}=Fr(t);return n.includes(e)||i.includes(e)},Fr=t=>{const e={subscribed:[],alreadySubscribed:[],unauthorized:[],unsubscribed:[],notSubscribed:[]};return Object.keys(e).forEach(n=>{e[n]=t[`${n}Channels`]||[]}),e},hn=(t,e=null,n=null)=>{if(!Vi(t))return null;let i=[];switch(e){case"audio":i=t.getAudioTracks();break;case"video":i=t.getVideoTracks();break;default:i=t.getTracks()}i.forEach(s=>{switch(n){case"on":case!0:s.enabled=!0;break;case"off":case!1:s.enabled=!1;break;default:s.enabled=!s.enabled}})},Wu=t=>{hn(t,"audio",!0)},zu=t=>{hn(t,"audio",!1)},qu=t=>{hn(t,"audio",null)};function Z_(){try{const{browserInfo:t,name:e,version:n,supportAudio:i,supportVideo:s}=function(){if(!window||!window.navigator||!window.navigator.userAgent)throw new Error("You should use @telnyx/webrtc in a web browser such as Chrome|Firefox|Safari");if(navigator.userAgent.match(/chrom(e|ium)/gim)&&!navigator.userAgent.match(/OPR\/[0-9]{2}/gi)&&!navigator.userAgent.match(/edg/gim)){const d=navigator.userAgent.match(/chrom(e|ium)\/[0-9]+\./gim)[0].split("/"),u=d[0],m=parseInt(d[1],10);return{browserInfo:navigator.userAgent,name:u,version:m,supportAudio:!0,supportVideo:!0}}if(navigator.userAgent.match(/firefox/gim)&&!navigator.userAgent.match(/OPR\/[0-9]{2}/gi)&&!navigator.userAgent.match(/edg/gim)){const d=navigator.userAgent.match(/firefox\/[0-9]+\./gim)[0].split("/"),u=d[0],m=parseInt(d[1],10);return{browserInfo:navigator.userAgent,name:u,version:m,supportAudio:!0,supportVideo:!1}}if(navigator.userAgent.match(/safari/gim)&&!navigator.userAgent.match(/OPR\/[0-9]{2}/gi)&&!navigator.userAgent.match(/edg/gim)){const d=navigator.userAgent.match(/safari/gim)[0],u=navigator.userAgent.match(/version\/[0-9]+\./gim)[0].split("/"),m=parseInt(u[1],10);return{browserInfo:navigator.userAgent,name:d,version:m,supportAudio:!0,supportVideo:!0}}if(navigator.userAgent.match(/edg/gim)&&!navigator.userAgent.match(/OPR\/[0-9]{2}/gi)){const d=navigator.userAgent.match(/edg\/[0-9]+\./gim)[0].split("/"),u=d[0],m=parseInt(d[1],10);return{browserInfo:navigator.userAgent,name:u,version:m,supportAudio:!0,supportVideo:!0}}throw new Error("This browser does not support @telnyx/webrtc. To see browser support list: `TelnyxRTC.webRTCSupportedBrowserList()`")}(),o=window.RTCPeerConnection,r=window.RTCSessionDescription,a=window.RTCIceCandidate,c=window.navigator&&window.navigator.mediaDevices,l=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.msGetUserMedia||navigator.mozGetUserMedia;return{browserInfo:t,browserName:e,browserVersion:n,supportWebRTC:!!(o&&r&&a&&c&&l),supportWebRTCAudio:i,supportWebRTCVideo:s,supportRTCPeerConnection:!!o,supportSessionDescription:!!r,supportIceCandidate:!!a,supportMediaDevices:!!c,supportGetUserMedia:!!Fi}}catch(t){return t.message}}var _e;function Ku(t,e){const n=document.getElementById(e);if(n)return n;if(t&&e){const i=document.createElement("audio");return i.id=e,i.loop=!0,i.src=t,i.preload="auto",i.load(),document.body.appendChild(i),i}return null}function Xu(t){t&&(t._playFulfilled=!1,t._promise=t.play(),t._promise.then(()=>{t._playFulfilled=!0}).catch(e=>{console.error("playAudio",e),t._playFulfilled=!0}))}function Yu(t){t&&(t._playFulfilled?(t.pause(),t.currentTime=0):t._promise&&t._promise.then?t._promise.then(()=>{t.pause(),t.currentTime=0}):setTimeout(()=>{t.pause(),t.currentTime=0},1e3))}(function(t){t.not_supported="not supported",t.full="full",t.partial="partial"})(_e||(_e={}));var Zu="2.24.1",Br=Zu;class J_ extends Ee{constructor(e,n,i,s,o={},r){super(),this.method="login";const a={login:e,passwd:n,login_token:i,userVariables:o,reconnection:r,loginParams:{},"User-Agent":{sdkVersion:Br,data:navigator.userAgent}};s&&(a.sessid=s),this.buildRequest({method:this.method,params:a})}}class Q_ extends Ee{constructor(e,n){super(),this.buildRequest({id:e,result:{method:n}})}}class Ju extends Ee{toString(){return te.Invite}}class Qu extends Ee{toString(){return te.Answer}}class ed extends Ee{toString(){return te.Attach}}class ev extends Ee{toString(){return te.Bye}}class td extends Ee{toString(){return te.Candidate}}class tv extends Ee{toString(){return te.EndOfCandidates}}class jr extends Ee{toString(){return te.Modify}}class nd extends Ee{toString(){return te.Info}}class nv extends Ee{toString(){return te.Broadcast}}class iv extends Ee{toString(){return te.Subscribe}}class sv extends Ee{toString(){return te.Unsubscribe}}class rv extends Wn{constructor(e,n){super(),this.method="ai_conversation",this.buildRequest({method:this.method,params:{type:"conversation.item.create",previous_item_id:null,item:{id:an(),type:"message",role:"user",content:[{type:"input_text",text:e},...n==null?void 0:n.map(i=>({type:"image_url",image_url:{url:i}}))]}}})}}const id=(t,e)=>{const{contentType:n,canvasType:i,callID:s,canvasInfo:o=null,currentLayerIdx:r=-1}=e;o&&i!=="mcu-personal-canvas"&&delete o.memberID;const a={type:at.conferenceUpdate,call:t.calls[s],canvasInfo:ov(o),currentLayerIdx:r};switch(n){case"layer-info":{const c=Object.assign({action:Fe.LayerInfo},a);J(F.Notification,c,t.uuid);break}case"layout-info":{const c=Object.assign({action:Fe.LayoutInfo},a);J(F.Notification,c,t.uuid);break}}},ov=t=>{const e=JSON.stringify(t).replace(/memberID/g,"participantId").replace(/ID"/g,'Id"').replace(/POS"/g,'Pos"');return Lu(e)};var Bi,sd=Du(function(t,e){var n;function i(){}function s(){s.init.call(this)}function o(f){return f._maxListeners===void 0?s.defaultMaxListeners:f._maxListeners}function r(f,p,h,_){var T,P,A;if(typeof h!="function")throw new TypeError('"listener" argument must be a function');if((P=f._events)?(P.newListener&&(f.emit("newListener",p,h.listener?h.listener:h),P=f._events),A=P[p]):(P=f._events=new i,f._eventsCount=0),A){if(typeof A=="function"?A=P[p]=_?[h,A]:[A,h]:_?A.unshift(h):A.push(h),!A.warned&&(T=o(f))&&0<T&&A.length>T){A.warned=!0;var M=new Error("Possible EventEmitter memory leak detected. "+A.length+" "+p+" listeners added. Use emitter.setMaxListeners() to increase limit");M.name="MaxListenersExceededWarning",M.emitter=f,M.type=p,M.count=A.length,function(R){typeof console.warn=="function"?console.warn(R):console.log(R)}(M)}}else A=P[p]=h,++f._eventsCount;return f}function a(f,p,h){function _(){f.removeListener(p,_),T||(T=!0,h.apply(f,arguments))}var T=!1;return _.listener=h,_}function c(f){var p=this._events;if(p){var h=p[f];if(typeof h=="function")return 1;if(h)return h.length}return 0}function l(f,p){for(var h=Array(p);p--;)h[p]=f[p];return h}Object.defineProperty(e,"__esModule",{value:!0}),i.prototype=Object.create(null),s.EventEmitter=s,s.usingDomains=!1,s.prototype.domain=void 0,s.prototype._events=void 0,s.prototype._maxListeners=void 0,s.defaultMaxListeners=10,s.init=function(){this.domain=null,s.usingDomains&&n.active&&!(this instanceof n.Domain)&&(this.domain=n.active),this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new i,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(f){if(typeof f!="number"||0>f||isNaN(f))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=f,this},s.prototype.getMaxListeners=function(){return o(this)},s.prototype.emit=function(f){var p,h,_,T,P,A,M,R=f==="error";if(A=this._events)R=R&&A.error==null;else if(!R)return!1;if(M=this.domain,R){if(p=arguments[1],!M){if(p instanceof Error)throw p;var V=new Error('Uncaught, unspecified "error" event. ('+p+")");throw V.context=p,V}return p||(p=new Error('Uncaught, unspecified "error" event')),p.domainEmitter=this,p.domain=M,p.domainThrown=!1,M.emit("error",p),!1}if(!(h=A[f]))return!1;var X=typeof h=="function";switch(_=arguments.length){case 1:(function(B,re,Q){if(re)B.call(Q);else for(var $=B.length,ce=l(B,$),z=0;z<$;++z)ce[z].call(Q)})(h,X,this);break;case 2:(function(B,re,Q,$){if(re)B.call(Q,$);else for(var ce=B.length,z=l(B,ce),Y=0;Y<ce;++Y)z[Y].call(Q,$)})(h,X,this,arguments[1]);break;case 3:(function(B,re,Q,$,ce){if(re)B.call(Q,$,ce);else for(var z=B.length,Y=l(B,z),Z=0;Z<z;++Z)Y[Z].call(Q,$,ce)})(h,X,this,arguments[1],arguments[2]);break;case 4:(function(B,re,Q,$,ce,z){if(re)B.call(Q,$,ce,z);else for(var Y=B.length,Z=l(B,Y),ee=0;ee<Y;++ee)Z[ee].call(Q,$,ce,z)})(h,X,this,arguments[1],arguments[2],arguments[3]);break;default:for(T=Array(_-1),P=1;P<_;P++)T[P-1]=arguments[P];(function(B,re,Q,$){if(re)B.apply(Q,$);else for(var ce=B.length,z=l(B,ce),Y=0;Y<ce;++Y)z[Y].apply(Q,$)})(h,X,this,T)}return!0},s.prototype.addListener=function(f,p){return r(this,f,p,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(f,p){return r(this,f,p,!0)},s.prototype.once=function(f,p){if(typeof p!="function")throw new TypeError('"listener" argument must be a function');return this.on(f,a(this,f,p)),this},s.prototype.prependOnceListener=function(f,p){if(typeof p!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(f,a(this,f,p)),this},s.prototype.removeListener=function(f,p){var h,_,T,P,A;if(typeof p!="function")throw new TypeError('"listener" argument must be a function');if(!(_=this._events))return this;if(!(h=_[f]))return this;if(h===p||h.listener&&h.listener===p)--this._eventsCount==0?this._events=new i:(delete _[f],_.removeListener&&this.emit("removeListener",f,h.listener||p));else if(typeof h!="function"){for(T=-1,P=h.length;0<P--;)if(h[P]===p||h[P].listener&&h[P].listener===p){A=h[P].listener,T=P;break}if(0>T)return this;if(h.length===1){if(h[0]=void 0,--this._eventsCount==0)return this._events=new i,this;delete _[f]}else(function(M,R){for(var V=R,X=V+1,B=M.length;X<B;V+=1,X+=1)M[V]=M[X];M.pop()})(h,T);_.removeListener&&this.emit("removeListener",f,A||p)}return this},s.prototype.removeAllListeners=function(f){var p,h;if(!(h=this._events))return this;if(!h.removeListener)return arguments.length===0?(this._events=new i,this._eventsCount=0):h[f]&&(--this._eventsCount==0?this._events=new i:delete h[f]),this;if(arguments.length===0){for(var _,T=Object.keys(h),P=0;P<T.length;++P)(_=T[P])!=="removeListener"&&this.removeAllListeners(_);return this.removeAllListeners("removeListener"),this._events=new i,this._eventsCount=0,this}if(typeof(p=h[f])=="function")this.removeListener(f,p);else if(p)do this.removeListener(f,p[p.length-1]);while(p[0]);return this},s.prototype.listeners=function(f){var p,h,_=this._events;return _?h=(p=_[f])?typeof p=="function"?[p.listener||p]:function(T){for(var P=Array(T.length),A=0;A<P.length;++A)P[A]=T[A].listener||T[A];return P}(p):[]:h=[],h},s.listenerCount=function(f,p){return typeof f.listenerCount=="function"?f.listenerCount(p):c.call(f,p)},s.prototype.listenerCount=c,s.prototype.eventNames=function(){return 0<this._eventsCount?Reflect.ownKeys(this._events):[]};var d,u=new Uint8Array(16);function m(){if(!d&&!(d=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return d(u)}for(var g=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,y=[],w=0;256>w;++w)y.push((w+256).toString(16).substr(1));function b(f){var p=1<arguments.length&&arguments[1]!==void 0?arguments[1]:0,h=(y[f[p+0]]+y[f[p+1]]+y[f[p+2]]+y[f[p+3]]+"-"+y[f[p+4]]+y[f[p+5]]+"-"+y[f[p+6]]+y[f[p+7]]+"-"+y[f[p+8]]+y[f[p+9]]+"-"+y[f[p+10]]+y[f[p+11]]+y[f[p+12]]+y[f[p+13]]+y[f[p+14]]+y[f[p+15]]).toLowerCase();if(!function(_){return typeof _=="string"&&g.test(_)}(h))throw TypeError("Stringified UUID is invalid");return h}function v(f,p,h){var _=(f=f||{}).random||(f.rng||m)();return _[6]=64|15&_[6],_[8]=128|63&_[8],b(_)}function S(f,p){if(!f||!p)return{};const h={...f};if(h.localCandidateId){const _=p.get(h.localCandidateId);h.local={..._}}if(h.remoteCandidateId){const _=p.get(h.remoteCandidateId);h.remote={..._}}return h}function k(f,p,h){return 8*function(_,T,P){const A=_[P],M=T?T[P]:null;return A===null||M===null?null:(A-M)/(_.timestamp-T.timestamp)*1e3}(f,p,h)}function I(f){if(!f.entries)return f;const p={};return f.forEach(function(h,_){p[_]=h}),p}function D(f,p,h={}){if(!f)return null;let _={audio:{inbound:[],outbound:[]},video:{inbound:[],outbound:[]},connection:{inbound:[],outbound:[]}};h.remote&&(_.remote={audio:{inbound:[],outbound:[]},video:{inbound:[],outbound:[]}});for(const T of f.values())switch(T.type){case"outbound-rtp":{const P=T.mediaType||T.kind,A={};let M={};if(!["audio","video"].includes(P))continue;if(T.codecId){const R=f.get(T.codecId);R&&(A.clockRate=R.clockRate,A.mimeType=R.mimeType,A.payloadType=R.payloadType)}M=f.get(T.mediaSourceId)||f.get(T.trackId)||{},_[P].outbound.push({...T,...A,track:{...M}});break}case"inbound-rtp":{let P=T.mediaType||T.kind,A={};const M={};if(!["audio","video"].includes(P))if(T.id.includes("Video"))P="video";else{if(!T.id.includes("Audio"))continue;P="audio"}if(T.codecId){const R=f.get(T.codecId);R&&(M.clockRate=R.clockRate,M.mimeType=R.mimeType,M.payloadType=R.payloadType)}if(!_.connection.id&&T.transportId){const R=f.get(T.transportId);if(R&&R.selectedCandidatePairId){const V=f.get(R.selectedCandidatePairId);_.connection=S(V,f)}}A=f.get(T.mediaSourceId)||f.get(T.trackId)||{},_[P].inbound.push({...T,...M,track:{...A}});break}case"peer-connection":_.connection.dataChannelsClosed=T.dataChannelsClosed,_.connection.dataChannelsOpened=T.dataChannelsOpened;break;case"remote-inbound-rtp":{if(!h.remote)break;let P=T.mediaType||T.kind;const A={};if(!["audio","video"].includes(P))if(T.id.includes("Video"))P="video";else{if(!T.id.includes("Audio"))continue;P="audio"}if(T.codecId){const M=f.get(T.codecId);M&&(A.clockRate=M.clockRate,A.mimeType=M.mimeType,A.payloadType=M.payloadType)}if(!_.connection.id&&T.transportId){const M=f.get(T.transportId);if(M&&M.selectedCandidatePairId){const R=f.get(M.selectedCandidatePairId);_.connection=S(R,f)}}_.remote[P].inbound.push({...T,...A});break}case"remote-outbound-rtp":{if(!h.remote)break;const P=T.mediaType||T.kind,A={};if(!["audio","video"].includes(P))continue;if(T.codecId){const M=f.get(T.codecId);M&&(A.clockRate=M.clockRate,A.mimeType=M.mimeType,A.payloadType=M.payloadType)}_.remote[P].outbound.push({...T,...A});break}}if(!_.connection.id)for(const T of f.values())T.type==="candidate-pair"&&T.nominated&&T.state==="succeeded"&&(_.connection=S(T,f));return _=function(T,P){return P&&(T.audio.inbound.map(A=>{let M=P.audio.inbound.find(R=>R.id===A.id);A.bitrate=k(A,M,"bytesReceived"),A.packetRate=k(A,M,"packetsReceived")}),T.audio.outbound.map(A=>{let M=P.audio.outbound.find(R=>R.id===A.id);A.bitrate=k(A,M,"bytesSent"),A.packetRate=k(A,M,"packetsSent")}),T.video.inbound.map(A=>{let M=P.video.inbound.find(R=>R.id===A.id);A.bitrate=k(A,M,"bytesReceived"),A.packetRate=k(A,M,"packetsReceived")}),T.video.outbound.map(A=>{let M=P.video.outbound.find(R=>R.id===A.id);A.bitrate=k(A,M,"bytesSent"),A.packetRate=k(A,M,"packetsSent")})),T}(_,p),_}let O,x={},C=[];e.WebRTCStats=class extends s{constructor(f){if(super(),this.monitoringSetInterval=0,this.connectionMonitoringSetInterval=0,this.connectionMonitoringInterval=1e3,this.remote=!0,this.peersToMonitor={},this.timeline=[],this.statsToMonitor=["inbound-rtp","outbound-rtp","remote-inbound-rtp","remote-outbound-rtp","peer-connection","data-channel","stream","track","sender","receiver","transport","candidate-pair","local-candidate","remote-candidate"],typeof window>"u")throw new Error("WebRTCStats only works in browser");const p={...f};this.isEdge=!!window.RTCIceGatherer,this.getStatsInterval=p.getStatsInterval||1e3,this.rawStats=!!p.rawStats,this.statsObject=!!p.statsObject,this.filteredStats=!!p.filteredStats,this.shouldWrapGetUserMedia=!!p.wrapGetUserMedia,typeof p.remote=="boolean"&&(this.remote=p.remote),this.debug=!!p.debug,this.logLevel=p.logLevel||"none",this.shouldWrapGetUserMedia&&this.wrapGetUserMedia()}async addPeer(f,p){return console.warn("The addPeer() method has been deprecated, please use addConnection()"),this.addConnection({peerId:f,pc:p})}async addConnection(f){const{pc:p,peerId:h}=f;let{connectionId:_,remote:T}=f;if(T=typeof T=="boolean"?T:this.remote,!(p&&p instanceof RTCPeerConnection))throw new Error("Missing argument 'pc' or is not of instance RTCPeerConnection");if(!h)throw new Error("Missing argument peerId");if(this.isEdge)throw new Error("Can't monitor peers in Edge at this time.");if(this.peersToMonitor[h]){if(_&&_ in this.peersToMonitor[h])throw new Error(`We are already monitoring connection with id ${_}.`);for(let A in this.peersToMonitor[h]){const M=this.peersToMonitor[h][A];if(M.pc===p)throw new Error(`We are already monitoring peer with id ${h}.`);M.pc.connectionState==="closed"&&this.removeConnection({pc:M.pc})}}const P=p.getConfiguration();return P.iceServers&&P.iceServers.forEach(function(A){delete A.credential}),_||(_=v()),this.emitEvent({event:"addConnection",tag:"peer",peerId:h,connectionId:_,data:{options:f,peerConfiguration:P}}),this.monitorPeer({peerId:h,connectionId:_,pc:p,remote:T}),{connectionId:_}}getTimeline(f){return this.timeline=this.timeline.sort((p,h)=>p.timestamp.getTime()-h.timestamp.getTime()),f?this.timeline.filter(p=>p.tag===f):this.timeline}get logger(){const f=p=>{const h=["none","error","warn","info","debug"];return h.slice(0,h.indexOf(this.logLevel)+1).indexOf(p)>-1};return{error(...p){this.debug&&f("error")&&console.error("[webrtc-stats][error] ",...p)},warn(...p){this.debug&&f("warn")&&console.warn("[webrtc-stats][warn] ",...p)},info(...p){this.debug&&f("info")&&console.log("[webrtc-stats][info] ",...p)},debug(...p){this.debug&&f("debug")&&console.debug("[webrtc-stats][debug] ",...p)}}}removeConnection(f){let p,{connectionId:h,pc:_}=f;if(!_&&!h)throw new Error("Missing arguments. You need to either send pc or a connectionId.");if(h){if(typeof h!="string")throw new Error("connectionId must be a string.");for(let T in this.peersToMonitor)h in this.peersToMonitor[T]&&(_=this.peersToMonitor[T][h].pc,p=T)}else if(_){if(!(_ instanceof RTCPeerConnection))throw new Error("pc must be an instance of RTCPeerConnection.");for(let T in this.peersToMonitor)for(let P in this.peersToMonitor[T])this.peersToMonitor[T][P].pc===_&&(h=P,p=T)}if(!_||!h)throw new Error("Could not find the desired connection.");return this.removePeerConnectionEventListeners(h,_),delete this.peersToMonitor[p][h],Object.values(this.peersToMonitor[p]).length===0&&delete this.peersToMonitor[p],{connectionId:h}}removeAllPeers(){for(let f in this.peersToMonitor)this.removePeer(f)}removePeer(f){if(this.logger.info(`Removing PeerConnection with id ${f}.`),this.peersToMonitor[f]){for(let p in this.peersToMonitor[f]){let h=this.peersToMonitor[f][p].pc;this.removePeerConnectionEventListeners(p,h)}delete this.peersToMonitor[f]}}destroy(){this.removeAllPeers(),C.forEach(f=>{this.removeTrackEventListeners(f)}),C=[],this.shouldWrapGetUserMedia&&O&&(navigator.mediaDevices.getUserMedia=O)}monitorPeer(f){let{peerId:p,connectionId:h,pc:_,remote:T}=f;if(!_)return void this.logger.warn("Did not receive pc argument when calling monitorPeer()");const P={pc:_,connectionId:h,stream:null,stats:{parsed:null,raw:null},options:{remote:T}};if(this.peersToMonitor[p]){if(h in this.peersToMonitor[p])return void this.logger.warn(`Already watching connection with ID ${h}`);this.peersToMonitor[p][h]=P}else this.peersToMonitor[p]={[h]:P};this.addPeerConnectionEventListeners(p,h,_),this.numberOfMonitoredPeers===1&&(this.startStatsMonitoring(),this.startConnectionStateMonitoring())}startStatsMonitoring(){this.monitoringSetInterval||(this.monitoringSetInterval=window.setInterval(()=>{this.numberOfMonitoredPeers||this.stopStatsMonitoring(),this.getStats().then(f=>{f.forEach(p=>{this.emitEvent(p)})})},this._getStatsInterval))}stopStatsMonitoring(){this.monitoringSetInterval&&(window.clearInterval(this.monitoringSetInterval),this.monitoringSetInterval=0)}async getStats(f=null){this.logger.info(f?`Getting stats from peer ${f}`:"Getting stats from all peers");let p={};if(f){if(!this.peersToMonitor[f])throw new Error(`Cannot get stats. Peer with id ${f} does not exist`);p[f]=this.peersToMonitor[f]}else p=this.peersToMonitor;let h=[];for(const _ in p)for(const T in p[_]){const P=p[_][T],A=P.pc;if(A&&!this.checkIfConnectionIsClosed(_,T,A))try{const M=this.getTimestamp(),R=A.getStats(null);if(R){const V=await R,X=this.getTimestamp(),B=I(V),re={remote:P.options.remote},Q=D(V,P.stats.parsed,re),$={event:"stats",tag:"stats",peerId:_,connectionId:T,timeTaken:X-M,data:Q};this.rawStats===!0&&($.rawStats=V),this.statsObject===!0&&($.statsObject=B),this.filteredStats===!0&&($.filteredStats=this.filteroutStats(B)),h.push($),P.stats.parsed=Q}else this.logger.error(`PeerConnection from peer ${_} did not return any stats data`)}catch(M){this.logger.error(M)}}return h}startConnectionStateMonitoring(){this.connectionMonitoringSetInterval=window.setInterval(()=>{this.numberOfMonitoredPeers||this.stopConnectionStateMonitoring();for(const f in this.peersToMonitor)for(const p in this.peersToMonitor[f]){const h=this.peersToMonitor[f][p].pc;this.checkIfConnectionIsClosed(f,p,h)}},this.connectionMonitoringInterval)}checkIfConnectionIsClosed(f,p,h){const _=this.isConnectionClosed(h);if(_){this.removeConnection({pc:h});let T=h.connectionState==="closed"?"onconnectionstatechange":"oniceconnectionstatechange";this.emitEvent({event:T,peerId:f,connectionId:p,tag:"connection",data:"closed"})}return _}isConnectionClosed(f){return f.connectionState==="closed"||f.iceConnectionState==="closed"}stopConnectionStateMonitoring(){this.connectionMonitoringSetInterval&&(window.clearInterval(this.connectionMonitoringSetInterval),this.connectionMonitoringSetInterval=0)}wrapGetUserMedia(){if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)return void this.logger.warn("'navigator.mediaDevices.getUserMedia' is not available in browser. Will not wrap getUserMedia.");this.logger.info("Wrapping getUsermedia functions."),O=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);const f=this.parseGetUserMedia.bind(this);navigator.mediaDevices.getUserMedia=(function(){return f({constraints:arguments[0]}),O.apply(navigator.mediaDevices,arguments).then(p=>(f({stream:p}),p),p=>(f({error:p}),Promise.reject(p)))}).bind(navigator.mediaDevices)}filteroutStats(f={}){const p={...f};for(const _ in p){var h=p[_];this.statsToMonitor.includes(h.type)||delete p[_]}return p}get peerConnectionListeners(){return{icecandidate:(f,p,h,_)=>{this.logger.debug("[pc-event] icecandidate | peerId: ${peerId}",_),this.emitEvent({event:"onicecandidate",tag:"connection",peerId:f,connectionId:p,data:_.candidate})},track:(f,p,h,_)=>{this.logger.debug(`[pc-event] track | peerId: ${f}`,_);const T=_.track,P=_.streams[0];f in this.peersToMonitor&&p in this.peersToMonitor[f]&&(this.peersToMonitor[f][p].stream=P),this.addTrackEventListeners(T,p),this.emitEvent({event:"ontrack",tag:"track",peerId:f,connectionId:p,data:{stream:P?this.getStreamDetails(P):null,track:T?this.getMediaTrackDetails(T):null,title:_.track.kind+":"+_.track.id+" "+_.streams.map(function(A){return"stream:"+A.id})}})},signalingstatechange:(f,p,h)=>{this.logger.debug(`[pc-event] signalingstatechange | peerId: ${f}`),this.emitEvent({event:"onsignalingstatechange",tag:"connection",peerId:f,connectionId:p,data:{signalingState:h.signalingState,localDescription:h.localDescription,remoteDescription:h.remoteDescription}})},iceconnectionstatechange:(f,p,h)=>{this.logger.debug(`[pc-event] iceconnectionstatechange | peerId: ${f}`),this.emitEvent({event:"oniceconnectionstatechange",tag:"connection",peerId:f,connectionId:p,data:h.iceConnectionState})},icegatheringstatechange:(f,p,h)=>{this.logger.debug(`[pc-event] icegatheringstatechange | peerId: ${f}`),this.emitEvent({event:"onicegatheringstatechange",tag:"connection",peerId:f,connectionId:p,data:h.iceGatheringState})},icecandidateerror:(f,p,h,_)=>{this.logger.debug(`[pc-event] icecandidateerror | peerId: ${f}`),this.emitEvent({event:"onicecandidateerror",tag:"connection",peerId:f,connectionId:p,error:{errorCode:_.errorCode}})},connectionstatechange:(f,p,h)=>{this.logger.debug(`[pc-event] connectionstatechange | peerId: ${f}`),this.emitEvent({event:"onconnectionstatechange",tag:"connection",peerId:f,connectionId:p,data:h.connectionState})},negotiationneeded:(f,p,h)=>{this.logger.debug(`[pc-event] negotiationneeded | peerId: ${f}`),this.emitEvent({event:"onnegotiationneeded",tag:"connection",peerId:f,connectionId:p})},datachannel:(f,p,h,_)=>{this.logger.debug(`[pc-event] datachannel | peerId: ${f}`,_),this.emitEvent({event:"ondatachannel",tag:"datachannel",peerId:f,connectionId:p,data:_.channel})}}}addPeerConnectionEventListeners(f,p,h){this.logger.debug(`Adding event listeners for peer ${f} and connection ${p}.`),x[p]={},Object.keys(this.peerConnectionListeners).forEach(_=>{x[p][_]=this.peerConnectionListeners[_].bind(this,f,p,h),h.addEventListener(_,x[p][_],!1)})}parseGetUserMedia(f){try{const p={event:"getUserMedia",tag:"getUserMedia",data:{...f}};f.stream&&(p.data.details=this.parseStream(f.stream),f.stream.getTracks().map(h=>{this.addTrackEventListeners(h),C.push(h)})),this.emitEvent(p)}catch{}}parseStream(f){const p={audio:[],video:[]};return f.getTracks().forEach(h=>{p[h.kind].push(this.getMediaTrackDetails(h))}),p}getMediaTrackDetails(f){return{enabled:f.enabled,id:f.id,contentHint:f.contentHint,kind:f.kind,label:f.label,muted:f.muted,readyState:f.readyState,constructorName:f.constructor.name,capabilities:f.getCapabilities?f.getCapabilities():{},constraints:f.getConstraints?f.getConstraints():{},settings:f.getSettings?f.getSettings():{},_track:f}}getStreamDetails(f){return{active:f.active,id:f.id,_stream:f}}getTrackEventObject(f){return{mute:p=>{this.emitEvent({event:"mute",tag:"track",connectionId:f,data:{event:p}})},unmute:p=>{this.emitEvent({event:"unmute",tag:"track",connectionId:f,data:{event:p}})},overconstrained:p=>{this.emitEvent({event:"overconstrained",tag:"track",connectionId:f,data:{event:p}})},ended:p=>{this.emitEvent({event:"ended",tag:"track",connectionId:f,data:{event:p}}),this.removeTrackEventListeners(p.target)}}}addTrackEventListeners(f,p){x[f.id]={};const h=this.getTrackEventObject(p);Object.keys(h).forEach(_=>{x[f.id][_]=h[_].bind(this),f.addEventListener(_,x[f.id][_])}),x[f.id].readyState=setInterval(()=>{if(f.readyState==="ended"){let _=new CustomEvent("ended",{detail:{check:"readyState"}});f.dispatchEvent(_)}},1e3)}removeTrackEventListeners(f){if(f.id in x){const p=this.getTrackEventObject();Object.keys(p).forEach(h=>{f.removeEventListener(h,x[f.id][h])}),clearInterval(x[f.id].readyState),delete x[f.id]}}addToTimeline(f){this.timeline.push(f),this.emit("timeline",f)}emitEvent(f){const p={...f,timestamp:new Date};this.addToTimeline(p),p.tag&&this.emit(p.tag,p)}set getStatsInterval(f){if(!Number.isInteger(f))throw new Error(`getStatsInterval should be an integer, got: ${f}`);this._getStatsInterval=f,this.monitoringSetInterval&&(this.stopStatsMonitoring(),this.startStatsMonitoring())}get numberOfMonitoredPeers(){return Object.keys(this.peersToMonitor).length}removePeerConnectionEventListeners(f,p){f in x&&(Object.keys(this.peerConnectionListeners).forEach(h=>{p.removeEventListener(h,x[f][h],!1)}),delete x[f]),p.getSenders().forEach(h=>{h.track&&this.removeTrackEventListeners(h.track)}),p.getReceivers().forEach(h=>{h.track&&this.removeTrackEventListeners(h.track)})}getTimestamp(){return Date.now()}wrapGetDisplayMedia(){const f=this;if(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia){const p=navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices),h=function(){return f.debug("navigator.mediaDevices.getDisplayMedia",null,arguments[0]),p.apply(navigator.mediaDevices,arguments).then(function(_){return _},function(_){return f.debug("navigator.mediaDevices.getDisplayMediaOnFailure",null,_.name),Promise.reject(_)})};navigator.mediaDevices.getDisplayMedia=h.bind(navigator.mediaDevices)}}}});(Bi=sd)&&Bi.__esModule&&Object.prototype.hasOwnProperty.call(Bi,"default")&&Bi.default;var av=sd.WebRTCStats;function cv(t){const{packetsLost:e,packetsReceived:n,jitter:i,rtt:s}=t,o=function(l){const{jitter:d,rtt:u}=l,m=d+u/2;return .024*m+.11*(m-177.3)*(m>177.3?1:0)}({rtt:s,jitter:i}),r=function(l){const{packetsLost:d,packetsReceived:u}=l,m=d/(u+d)*100;return 20*Math.log(1+m)}({packetsLost:e,packetsReceived:n}),a=93.2-o-r+0,c=1+.035*a+7e-6*a*(a-60)*(100-a);return Math.min(Math.max(c,1),5)}function lv(t){return isNaN(t)?null:t>4.2?"excellent":t>=4.1&&t<=4.2?"good":t>=3.7&&t<=4?"fair":t>=3.1&&t<=3.6?"poor":"bad"}class uv extends Wn{constructor(e){super(),this.buildRequest({type:"debug_report_start",debug_report_id:e,debug_report_version:1})}}class dv extends Wn{constructor(e){super(),this.buildRequest({type:"debug_report_stop",debug_report_id:e,debug_report_version:1})}}class hv extends Wn{constructor(e,n){super(),this.buildRequest({type:"debug_report_data",debug_report_id:e,debug_report_version:1,debug_report_data:n})}}function fv(t){const e=an(),n=new av({getStatsInterval:1e3,rawStats:!1,statsObject:!0,filteredStats:!1,remote:!0,debug:!1,logLevel:"warn"}),i=s=>j(this,void 0,void 0,function*(){s.event==="stats"&&J(F.StatsFrame,function({data:o}){var r,a,c,l,d,u,m,g;const{audio:y,remote:w}=o,{audio:b}=w,v=(a=(r=b.inbound[0])===null||r===void 0?void 0:r.jitter)!==null&&a!==void 0?a:1/0,S=(l=(c=b.inbound[0])===null||c===void 0?void 0:c.roundTripTime)!==null&&l!==void 0?l:1/0,k=(u=(d=y.inbound[0])===null||d===void 0?void 0:d.packetsReceived)!==null&&u!==void 0?u:-1,I=(g=(m=y.inbound[0])===null||m===void 0?void 0:m.packetsLost)!==null&&g!==void 0?g:-1,D=cv({jitter:1e3*v,rtt:1e3*S,packetsLost:I,packetsReceived:k});return{jitter:v,rtt:S,mos:D,quality:lv(D),inboundAudio:y.inbound[0],outboundAudio:y.outbound[0],remoteInboundAudio:b.inbound[0],remoteOutboundAudio:b.outbound[0]}}(s),t.uuid),yield t.execute(new hv(e,s))});return{start:(s,o,r)=>j(this,void 0,void 0,function*(){yield t.execute(new uv(e)),n.on("timeline",i),yield new Promise(a=>setTimeout(a,500)),n.addConnection({pc:s,peerId:o,connectionId:r})}),stop:s=>j(this,void 0,void 0,function*(){const o=n.getTimeline();J(F.StatsReport,o,t.uuid),s==="file"&&function(r,a){const c=new Blob([JSON.stringify(r)],{type:"application/json"}),l=URL.createObjectURL(c),d=document.createElement("a");d.href=l,d.download=`${a}.json`,d.click(),URL.revokeObjectURL(l)}(o,`webrtc-stats-${e}-${Date.now()}`),yield t.execute(new dv(e)),n.removeAllPeers(),n.destroy()})}}class rd{constructor(e,n,i,s,o){this.type=e,this.options=n,this.onSdpReadyTwice=null,this.statsReporter=null,this._negotiating=!1,this._prevConnectionState=null,this.handleConnectionStateChange=r=>j(this,void 0,void 0,function*(){const{connectionState:a}=this.instance;console.log(`[${new Date().toISOString()}] Connection State changed: ${this._prevConnectionState} -> ${a}`),this._prevConnectionState==="disconnected"&&a==="failed"&&(this.instance.restartIce(),this._isTrickleIce()?yield this.startTrickleIceNegotiation():this.startNegotiation()),this._prevConnectionState==="connected"&&a==="disconnected"&&(yield this._resetJitterBuffer()),this._prevConnectionState==="disconnected"&&a==="connected"&&(yield this._resetJitterBuffer()),this._prevConnectionState=a,this._isTrickleIce()&&(a==="connecting"&&performance.mark("peer-connection-connecting"),a==="connected"&&(performance.mark("peer-connection-connected"),console.group("Performance Metrics"),console.table(this.trickleIcePerformanceMetrics),console.groupEnd(),performance.clearMarks()))}),this._handleIceConnectionStateChange=r=>{console.log(`[${new Date().toISOString()}] ICE Connection State`,this.instance.iceConnectionState)},this._handleIceGatheringStateChange=r=>{console.log(`[${new Date().toISOString()}] ICE Gathering State`,this.instance.iceGatheringState)},this._setAudioCodec=r=>{if(this.options.preferred_codecs&&this.options.preferred_codecs.length!==0)return r.setCodecPreferences?r.setCodecPreferences(this.options.preferred_codecs):void 0},L.info("New Peer with type:",this.type,"Options:",this.options),this._constraints={offerToReceiveAudio:!0},this._sdpReady=this._sdpReady.bind(this),this.handleSignalingStateChangeEvent=this.handleSignalingStateChangeEvent.bind(this),this.handleNegotiationNeededEvent=this.handleNegotiationNeededEvent.bind(this),this.handleTrackEvent=this.handleTrackEvent.bind(this),this.createPeerConnection=this.createPeerConnection.bind(this),this._session=i,this._trickleIceSdpFn=s,this._registerPeerEvents=o}get isOffer(){return this.type===ke.Offer}get isAnswer(){return this.type===ke.Answer}get isDebugEnabled(){return this.options.debug||this._session.options.debug}get debugOutput(){return this.options.debugOutput||this._session.options.debugOutput}startNegotiation(){performance.mark("ice-gathering-start"),this._negotiating=!0,this._isOffer()?this._createOffer():this._createAnswer()}startTrickleIceNegotiation(){return j(this,void 0,void 0,function*(){performance.mark("ice-gathering-start"),this._negotiating=!0,this._isOffer()?yield this._createOffer().then(this._trickleIceSdpFn.bind(this)):yield this._createAnswer().then(this._trickleIceSdpFn.bind(this))})}_logTransceivers(){L.info("Number of transceivers:",this.instance.getTransceivers().length),this.instance.getTransceivers().forEach((e,n)=>{L.info(`>> Transceiver [${n}]:`,e.mid,e.direction,e.stopped),L.info(`>> Sender Params [${n}]:`,JSON.stringify(e.sender.getParameters(),null,2))})}get trickleIcePerformanceMetrics(){const e=performance.measure("new-call","new-call-start","new-call-end"),n=performance.measure("peer-creation","peer-creation-start","peer-creation-end"),i=performance.measure("ice-gathering","ice-gathering-start","ice-gathering-end"),s=performance.measure("sdp-send","sdp-send-start","sdp-send-end"),o=performance.measure("invite-send","new-call-start","sdp-send-start"),r=performance.measure("total-duration","peer-creation-start","sdp-send-end"),a=c=>`${c.toFixed(2)}ms`;return{"New Call":{duration:a(e.duration)},"Peer Creation":{duration:a(n.duration)},"ICE Gathering":{duration:a(i.duration)},[this._isOffer()?"Invite Send":"Answer Send"]:{duration:a(o.duration)},"SDP Send":{duration:a(s.duration)},"Total Duration":{duration:a(r.duration)}}}handleSignalingStateChangeEvent(e){switch(L.info("signalingState:",this.instance.signalingState),this.instance.signalingState){case"stable":this._negotiating=!1;break;case"closed":this.instance=null;break;default:this._negotiating=!0}}handleNegotiationNeededEvent(){L.info("Negotiation needed event"),this.instance.signalingState!=="stable"||this._negotiating?L.debug("Skipping negotiation, state:",this.instance.signalingState,"negotiating:",this._negotiating):this._isTrickleIce()?this.startTrickleIceNegotiation():this.startNegotiation()}handleTrackEvent(e){const{streams:[n]}=e,{remoteElement:i,screenShare:s}=this.options;let{remoteStream:o}=this.options;o=n,s===!1&&zn(i,o)}createPeerConnection(){return j(this,void 0,void 0,function*(){var e;this.instance=(e=this._config(),new window.RTCPeerConnection(e)),this.instance.onsignalingstatechange=this.handleSignalingStateChangeEvent,this.instance.onnegotiationneeded=this.handleNegotiationNeededEvent,this.instance.ontrack=this.handleTrackEvent,this.instance.addEventListener("connectionstatechange",this.handleConnectionStateChange),this.instance.addEventListener("iceconnectionstatechange",this._handleIceConnectionStateChange),this.instance.addEventListener("icegatheringstatechange",this._handleIceGatheringStateChange),this.instance.addEventListener("addstream",n=>{this.options.remoteStream=n.stream}),this._registerPeerEvents(this.instance),this._prevConnectionState=this.instance.connectionState,this.isAnswer&&(yield this._setRemoteDescription({sdp:this.options.remoteSdp,type:ke.Offer})),this.options.localStream=yield this._retrieveLocalStream().catch(n=>(J(F.MediaError,n,this.options.id),null)),performance.mark("peer-creation-end")})}init(){var e;return j(this,void 0,void 0,function*(){yield this.createPeerConnection(),yield(e=this.statsReporter)===null||e===void 0?void 0:e.start(this.instance,this._session.sessionid,this._session.sessionid);const{localElement:n,localStream:i=null,screenShare:s=!1}=this.options;if(Vi(i)){const o=i.getAudioTracks();if(L.info("Local audio tracks: ",o),this.isOffer&&typeof this.instance.addTransceiver=="function"){const r={direction:"sendrecv",streams:[i]};o.forEach(a=>{this.options.userVariables.microphoneLabel=a.label;const c=this.instance.addTransceiver(a,r);this._setAudioCodec(c)})}else typeof this.instance.addTrack=="function"?(o.forEach(r=>{this.options.userVariables.microphoneLabel=r.label,this.instance.addTrack(r,i)}),this.instance.getTransceivers().forEach(r=>this._setAudioCodec(r))):this.instance.addStream(i);s===!1&&zn(n,i)}this.isOffer?this.options.negotiateAudio&&this._checkMediaToNegotiate("audio"):this._isTrickleIce()||this.startNegotiation(),this._isTrickleIce()&&this.startTrickleIceNegotiation(),this._logTransceivers(),this.isDebugEnabled&&(this.statsReporter=fv(this._session))})}_getSenderByKind(e){return this.instance.getSenders().find(({track:n})=>n&&n.kind===e)}_checkMediaToNegotiate(e){if(!this._getSenderByKind(e)){const n=this.instance.addTransceiver(e);L.info("Add transceiver",e,n)}}_createOffer(){return j(this,void 0,void 0,function*(){if(this._isOffer()){this._constraints.offerToReceiveAudio=!!this.options.audio,L.info("_createOffer - this._constraints",this._constraints);try{const e=yield this.instance.createOffer(this._constraints);return yield this._setLocalDescription(e),this._isTrickleIce()||this._sdpReady(),e}catch(e){L.error("Peer _createOffer error:",e)}}})}_setRemoteDescription(e){return j(this,void 0,void 0,function*(){L.debug("Setting remote description",e),yield this.instance.setRemoteDescription(e)})}_createAnswer(){return j(this,void 0,void 0,function*(){if(this._isAnswer()){if(this.instance.signalingState!=="stable"&&this.instance.signalingState!=="have-remote-offer")return L.debug("Skipping negotiation, state:",this.instance.signalingState),console.log(" - But the signaling state isn't stable, so triggering rollback"),void(yield Promise.all([this.instance.setLocalDescription({type:"rollback"}),this.instance.setRemoteDescription({sdp:this.options.remoteSdp,type:ke.Offer})]));this._logTransceivers();try{const e=yield this.instance.createAnswer();return yield this._setLocalDescription(e),e}catch(e){L.error("Peer _createAnswer error:",e)}}})}_setLocalDescription(e){return j(this,void 0,void 0,function*(){yield this.instance.setLocalDescription(e)})}_sdpReady(){cn(this.onSdpReadyTwice)&&this.onSdpReadyTwice(this.instance.localDescription)}_retrieveLocalStream(){return j(this,void 0,void 0,function*(){if(Vi(this.options.localStream))return this.options.localStream;const e=yield(n=this.options,j(void 0,void 0,void 0,function*(){let{audio:i=!0,micId:s}=n;const{micLabel:o=""}=n;return s&&(s=yield Nr(s,o,mt.AudioIn).catch(r=>null),s&&(typeof i=="boolean"&&(i={}),i.deviceId={exact:s})),{audio:i}}));var n;return Fi(e)})}_resetJitterBuffer(){return j(this,void 0,void 0,function*(){try{const e=this.instance.getReceivers().find(i=>i.track&&i.track.kind==="audio");e&&"jitterBufferTarget"in e&&(e.jitterBufferTarget=20,L.debug("[jitter] target set to",e.jitterBufferTarget,"ms"));const n=this._getSenderByKind("audio");if(n){const i=n.track;yield n.replaceTrack(null),yield new Promise(s=>setTimeout(s,50)),yield n.replaceTrack(i)}}catch(e){L.error("Peer _resetJitterBuffer error:",e)}})}_isOffer(){return this.type===ke.Offer}_isAnswer(){return this.type===ke.Answer}_isTrickleIce(){return this.options.trickleIce===!0}_config(){const{prefetchIceCandidates:e,forceRelayCandidate:n}=this.options,i={bundlePolicy:"balanced",iceCandidatePoolSize:e?10:0,iceServers:[L_,Mu],iceTransportPolicy:n?"relay":"all"};return L.info("RTC config",i),i}close(){var e;return j(this,void 0,void 0,function*(){yield(e=this.statsReporter)===null||e===void 0?void 0:e.stop(this.debugOutput),this.instance&&(this.instance.close(),this.instance=null)})}}const od=Br;class ad{constructor(e,n){this.session=e,this.id="",this.state=W[W.New],this.prevState="",this.channels=[],this.role=Dr.Participant,this.extension=null,this._state=W.New,this._prevState=W.New,this.gotAnswer=!1,this.gotEarly=!1,this._lastSerno=0,this._targetNodeId=null,this._iceTimeout=null,this._iceDone=!1,this._statsBindings=[],this._statsIntervalId=null,this._pendingIceCandidates=[],this._isRemoteDescriptionSet=!1,this._checkConferenceSerno=w=>{const b=w<0||!this._lastSerno||this._lastSerno&&w===this._lastSerno+1;return b&&w>=0&&(this._lastSerno=w),b},this._doStats=()=>{this.peer&&this.peer.instance&&this._statsBindings.length!==0&&this.peer.instance.getStats().then(w=>{w.forEach(b=>{this._statsBindings.forEach(v=>{if(v.callback){if(v.constraints){for(var S in v.constraints)if(v.constraints.hasOwnProperty(S)&&v.constraints[S]!==b[S])return}v.callback(b)}})})})};const{iceServers:i,speaker:s,micId:o,micLabel:r,camId:a,camLabel:c,localElement:l,remoteElement:d,options:u,mediaConstraints:{audio:m},ringtoneFile:g,ringbackFile:y}=e;this.options=Object.assign({},$_,{audio:m,iceServers:i,localElement:l,remoteElement:d,micId:o,micLabel:r,camId:a,camLabel:c,speakerId:s,ringtoneFile:g,ringbackFile:y,debug:u.debug,debugOutput:u.debugOutput,trickleIce:u.trickleIce,prefetchIceCandidates:u.prefetchIceCandidates},n),this._onMediaError=this._onMediaError.bind(this),this._onTrickleIceSdp=this._onTrickleIceSdp.bind(this),this._registerPeerEvents=this._registerPeerEvents.bind(this),this._registerTrickleIcePeerEvents=this._registerTrickleIcePeerEvents.bind(this),this._init(),this.options&&(this._ringtone=Ku(this.options.ringtoneFile,"_ringtone"),this._ringback=Ku(this.options.ringbackFile,"_ringback"))}get performanceMetrics(){const e=performance.measure("peer-creation","peer-creation-start","peer-creation-end"),n=performance.measure("ice-gathering","ice-gathering-start","ice-gathering-end"),i=performance.measure("sdp-send","sdp-send-start","sdp-send-end"),s=performance.measure("total-duration","peer-creation-start","sdp-send-end"),o=r=>`${r.toFixed(2)}ms`;return{"Peer Creation":{duration:o(e.duration)},"ICE Gathering":{duration:o(n.duration)},"SDP Send":{duration:o(i.duration)},"Total Duration":{duration:o(s.duration)}}}get nodeId(){return this._targetNodeId}set nodeId(e){this._targetNodeId=e}get telnyxIDs(){return{telnyxCallControlId:this.options.telnyxCallControlId,telnyxSessionId:this.options.telnyxSessionId,telnyxLegId:this.options.telnyxLegId}}get localStream(){return this.options.localStream}get remoteStream(){return this.options.remoteStream}get memberChannel(){return`conference-member.${this.id}`}invite(){return j(this,void 0,void 0,function*(){this.direction=St.Outbound,this.options.trickleIce&&this._resetTrickleIceCandidateState(),performance.mark("peer-creation-start"),this.peer=new rd(ke.Offer,this.options,this.session,this._onTrickleIceSdp,this.options.trickleIce?this._registerTrickleIcePeerEvents:this._registerPeerEvents),yield this.peer.init()})}answer(e={}){var n;return j(this,void 0,void 0,function*(){performance.mark("new-call-start"),this.stopRingtone(),this.direction=St.Inbound,((n=e==null?void 0:e.customHeaders)===null||n===void 0?void 0:n.length)>0&&(this.options=Object.assign(Object.assign({},this.options),{customHeaders:e.customHeaders})),this.options.trickleIce&&this._resetTrickleIceCandidateState(),performance.mark("peer-creation-start"),this.peer=new rd(ke.Answer,this.options,this.session,this._onTrickleIceSdp,this.options.trickleIce?this._registerTrickleIcePeerEvents:this._registerPeerEvents),yield this.peer.init(),performance.mark("new-call-end")})}playRingtone(){Xu(this._ringtone)}stopRingtone(){Yu(this._ringtone)}playRingback(){Xu(this._ringback)}stopRingback(){Yu(this._ringback)}hangup(e,n){var i,s,o;let r=e||{},a=n!==!1;this.cause=r.cause||"NORMAL_CLEARING",this.causeCode=r.causeCode||16,this.sipCode=r.sipCode||null,this.sipReason=r.sipReason||null,this.sipCallId=r.sip_call_id||null,this.options.customHeaders=[...(i=this.options.customHeaders)!==null&&i!==void 0?i:[],...(o=(s=r==null?void 0:r.dialogParams)===null||s===void 0?void 0:s.customHeaders)!==null&&o!==void 0?o:[]],this.setState(W.Hangup);const c=()=>{var l;return(l=this.peer)===null||l===void 0||l.close(),this.setState(W.Destroy)};if(this.stopRingtone(),this.stopRingback(),a){const l=new ev({sipCode:this.sipCode,sip_call_id:this.sipCallId,sessid:this.session.sessionid,dialogParams:this.options,cause:"USER_BUSY",causeCode:17});this._execute(l).catch(d=>{L.error("telnyx_rtc.bye failed!",d),J(F.Error,{error:d,sessionId:this.session.sessionid},this.session.uuid)}).then(c.bind(this))}else c()}hold(){const e=new jr({sessid:this.session.sessionid,action:"hold",dialogParams:this.options});return this._execute(e).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this))}unhold(){const e=new jr({sessid:this.session.sessionid,action:"unhold",dialogParams:this.options});return this._execute(e).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this))}toggleHold(){const e=new jr({sessid:this.session.sessionid,action:"toggleHold",dialogParams:this.options});return this._execute(e).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this))}dtmf(e){const n=new nd({sessid:this.session.sessionid,dtmf:e,dialogParams:this.options});this._execute(n)}message(e,n){const i={from:this.session.options.login,to:e,body:n},s=new nd({sessid:this.session.sessionid,msg:i,dialogParams:this.options});this._execute(s)}muteAudio(){zu(this.options.localStream)}unmuteAudio(){Wu(this.options.localStream)}toggleAudioMute(){qu(this.options.localStream)}setAudioInDevice(e){return j(this,void 0,void 0,function*(){const{instance:n}=this.peer,i=n.getSenders().find(({track:{kind:s}})=>s==="audio");if(i){const s=yield Or({audio:{deviceId:{exact:e}}}),o=s.getAudioTracks()[0];i.replaceTrack(o),this.options.micId=e;const{localStream:r}=this.options;r.getAudioTracks().forEach(a=>a.stop()),r.getVideoTracks().forEach(a=>s.addTrack(a)),this.options.localStream=s}})}muteVideo(){var e;e=this.options.localStream,hn(e,"video",!1)}unmuteVideo(){var e;e=this.options.localStream,hn(e,"video",!0)}toggleVideoMute(){var e;e=this.options.localStream,hn(e,"video",null)}setVideoDevice(e){return j(this,void 0,void 0,function*(){const{instance:n}=this.peer,i=n.getSenders().find(({track:{kind:s}})=>s==="video");if(i){const s=yield Or({video:{deviceId:{exact:e}}}),o=s.getVideoTracks()[0];i.replaceTrack(o);const{localElement:r,localStream:a}=this.options;zn(r,s),this.options.camId=e,a.getAudioTracks().forEach(c=>s.addTrack(c)),a.getVideoTracks().forEach(c=>c.stop()),this.options.localStream=s}})}deaf(){zu(this.options.remoteStream)}undeaf(){Wu(this.options.remoteStream)}toggleDeaf(){qu(this.options.remoteStream)}setBandwidthEncodingsMaxBps(e,n){return j(this,void 0,void 0,function*(){if(!this||!this.peer)return void L.error("Could not set bandwidth (reason: no peer connection). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");const{instance:i}=this.peer,s=i.getSenders();if(!s)return void L.error("Could not set bandwidth (reason: no senders). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");const o=s.find(({track:{kind:r}})=>r===n);if(o){const r=o.getParameters();r.encodings||(r.encodings=[{rid:"h"}]),L.info("Parameters: ",r),L.info("Setting max ",n==="audio"?"audio":"video"," bandwidth to: ",e," [bps]"),r.encodings[0].maxBitrate=e,yield o.setParameters(r).then(()=>{L.info(n==="audio"?"New audio":"New video"," bandwidth settings in use: ",o.getParameters())}).catch(a=>console.error(a))}else L.error("Could not set bandwidth (reason: no "+n+" sender). Dynamic bandwidth can only be set when there is a call running - is there any call running?)")})}setAudioBandwidthEncodingsMaxBps(e){this.setBandwidthEncodingsMaxBps(e,"audio")}setVideoBandwidthEncodingsMaxBps(e){this.setBandwidthEncodingsMaxBps(e,"video")}getStats(e,n){if(!e)return;const i={callback:e,constraints:n};this._statsBindings.push(i),!this._statsIntervalId&&this._startStats(2e3)}setState(e){switch(this._prevState=this._state,this._state=e,this.state=W[this._state].toLowerCase(),this.prevState=W[this._prevState].toLowerCase(),L.info(`Call ${this.id} state change from ${this.prevState} to ${this.state}`),this._dispatchNotification({type:at.callUpdate,call:this}),e){case W.Purge:this.hangup({cause:"PURGE",causeCode:"01"},!1);break;case W.Active:setTimeout(()=>{const{remoteElement:n,speakerId:i}=this.options;n&&i&&Gu(n,i)},0);break;case W.Destroy:this._finalize()}}handleMessage(e){const{method:n,params:i}=e;switch(n){case te.Answer:if(this.gotAnswer=!0,this._state>=W.Active)return;this._state>=W.Early&&this.setState(W.Active),this.gotEarly||this._onRemoteSdp(i.sdp),this.stopRingback(),this.stopRingtone();break;case te.Media:if(this._state>=W.Early)return;this.gotEarly=!0,this._onRemoteSdp(i.sdp);break;case te.Display:case te.Attach:{const{display_name:o,display_number:r,display_direction:a}=i;this.extension=r;const c=a===St.Inbound?St.Outbound:St.Inbound,l={type:at[n],call:this,displayName:o,displayNumber:r,displayDirection:c};J(F.Notification,l,this.id)||J(F.Notification,l,this.session.uuid);break}case te.Candidate:this._addIceCandidate(i);break;case te.Info:case te.Event:{const o=Object.assign(Object.assign({},i),{type:at.generic,call:this});J(F.Notification,o,this.id)||J(F.Notification,o,this.session.uuid);break}case te.Ringing:this.playRingback(),i.telnyx_call_control_id&&(this.options.telnyxCallControlId=i.telnyx_call_control_id),i.telnyx_session_id&&(this.options.telnyxSessionId=i.telnyx_session_id),i.telnyx_leg_id&&(this.options.telnyxLegId=i.telnyx_leg_id);break;case te.Bye:const s=i.client_state||i.clientState;s&&(this.options.clientState=s),this.stopRingback(),this.stopRingtone(),this.hangup(i,!1)}}handleConferenceUpdate(e,n){return j(this,void 0,void 0,function*(){if(!this._checkConferenceSerno(e.wireSerno)&&e.name!==n.laName)return L.error("ConferenceUpdate invalid wireSerno or packet name:",e),"INVALID_PACKET";const{action:i,data:s,hashKey:o=String(this._lastSerno),arrIndex:r}=e;switch(i){case"bootObj":{this._lastSerno=0;const{chatChannel:a,infoChannel:c,modChannel:l,laName:d,conferenceMemberID:u,role:m}=n;this._dispatchConferenceUpdate({action:Fe.Join,conferenceName:d,participantId:Number(u),role:m}),a&&(yield this._subscribeConferenceChat(a)),c&&(yield this._subscribeConferenceInfo(c));const g=[];for(const y in s)g.push(Object.assign({callId:s[y][0],index:Number(y)},Di(s[y][1])));this._dispatchConferenceUpdate({action:Fe.Bootstrap,participants:g});break}case"add":this._dispatchConferenceUpdate(Object.assign({action:Fe.Add,callId:o,index:r},Di(s)));break;case"modify":this._dispatchConferenceUpdate(Object.assign({action:Fe.Modify,callId:o,index:r},Di(s)));break;case"del":this._dispatchConferenceUpdate(Object.assign({action:Fe.Delete,callId:o,index:r},Di(s)));break;case"clear":this._dispatchConferenceUpdate({action:Fe.Clear});break;default:this._dispatchConferenceUpdate({action:i,data:s,callId:o,index:r})}})}_addChannel(e){this.channels.includes(e)||this.channels.push(e);const n=this.session.relayProtocol;this.session._existsSubscription(n,e)&&(this.session.subscriptions[n][e]=Object.assign(Object.assign({},this.session.subscriptions[n][e]),{callId:this.id}))}_subscribeConferenceChat(e){return j(this,void 0,void 0,function*(){const n={nodeId:this.nodeId,channels:[e],handler:s=>{const{direction:o,from:r,fromDisplay:a,message:c,type:l}=s.data;this._dispatchConferenceUpdate({action:Fe.ChatMessage,direction:o,participantNumber:r,participantName:a,messageText:c,messageType:l,messageId:s.eventSerno})}},i=yield this.session.vertoSubscribe(n).catch(s=>{L.error("ConfChat subscription error:",s)});Vr(i,e)&&(this._addChannel(e),Object.defineProperties(this,{sendChatMessage:{configurable:!0,value:(s,o)=>{this.session.vertoBroadcast({nodeId:this.nodeId,channel:e,data:{action:"send",message:s,type:o}})}}}))})}_subscribeConferenceInfo(e){return j(this,void 0,void 0,function*(){const n={nodeId:this.nodeId,channels:[e],handler:s=>{const{eventData:o}=s;o.contentType==="layout-info"?(o.callID=this.id,id(this.session,o)):L.error("Conference-Info unknown contentType",s)}},i=yield this.session.vertoSubscribe(n).catch(s=>{L.error("ConfInfo subscription error:",s)});Vr(i,e)&&this._addChannel(e)})}_confControl(e,n={}){const i=Object.assign({application:"conf-control",callID:this.id,value:null},n);this.session.vertoBroadcast({nodeId:this.nodeId,channel:e,data:i})}_handleChangeHoldStateSuccess(e){return e.holdState==="active"?this.setState(W.Active):this.setState(W.Held),!0}_handleChangeHoldStateError(e){return L.error(`Failed to ${e.action} on call ${this.id}`),!1}_onRemoteSdp(e){return j(this,void 0,void 0,function*(){const n=new RTCSessionDescription({sdp:e,type:ke.Answer});yield this.peer.instance.setRemoteDescription(n).then(()=>{this.options.trickleIce&&(this._isRemoteDescriptionSet=!0,this._flushPendingTrickleIceCandidates()),this.gotEarly&&this.setState(W.Early),this.gotAnswer&&this.setState(W.Active)}).catch(i=>{L.error("Call setRemoteDescription Error: ",i),this.hangup()})})}_requestAnotherLocalDescription(){cn(this.peer.onSdpReadyTwice)?J(F.Error,{error:new Error("SDP without candidates for the second time!"),sessionId:this.session.sessionid},this.session.uuid):(Object.defineProperty(this.peer,"onSdpReadyTwice",{value:this._onIceSdp.bind(this)}),this._iceDone=!1,this.peer.startNegotiation())}_onIceSdp(e){var n,i;this._iceTimeout&&clearTimeout(this._iceTimeout),this._iceTimeout=null,this._iceDone=!0;const{sdp:s,type:o}=e;if(s.indexOf("candidate")===-1)return L.info(`No candidate - retry
|
|
106
|
+
`),void this._requestAnotherLocalDescription();(i=(n=this.peer)===null||n===void 0?void 0:n.instance)===null||i===void 0||i.removeEventListener("icecandidate",this._onIce),performance.mark("ice-gathering-end");let r=null;const a={sessid:this.session.sessionid,sdp:s,dialogParams:this.options,"User-Agent":`Web-${od}`};switch(o){case ke.Offer:this.setState(W.Requesting),r=new Ju(a);break;case ke.Answer:this.setState(W.Answering),r=this.options.attach===!0?new ed(a):new Qu(a);break;default:return L.error(`${this.id} - Unknown local SDP type:`,e),this.hangup({},!1)}performance.mark("sdp-send-start"),this._execute(r).then(c=>{const{node_id:l=null}=c;this._targetNodeId=l,o===ke.Offer?this.setState(W.Trying):this.setState(W.Active)}).catch(c=>{L.error(`${this.id} - Sending ${o} error:`,c),this.hangup()}).finally(()=>{performance.mark("sdp-send-end"),console.group("Performance Metrics"),console.table(this.performanceMetrics),console.groupEnd(),performance.clearMarks()})}_onTrickleIceSdp(e){if(!e)return L.error("No SDP data provided"),this.hangup({},!1);const{sdp:n,type:i}=e;let s=null;const o={sessid:this.session.sessionid,sdp:n,dialogParams:this.options,trickle:!0,"User-Agent":`Web-${od}`};switch(i){case ke.Offer:this.setState(W.Requesting),s=new Ju(o);break;case ke.Answer:this.setState(W.Answering),s=this.options.attach===!0?new ed(o):new Qu(o);break;default:return L.error(`${this.id} - Unknown local SDP type:`,e),this.hangup({},!1)}performance.mark("sdp-send-start"),this._execute(s).then(r=>{const{node_id:a=null}=r;this._targetNodeId=a,i===ke.Offer?this.setState(W.Trying):this.setState(W.Active)}).catch(r=>{L.error(`${this.id} - Sending ${i} error:`,r),this.hangup()}).finally(()=>{performance.mark("sdp-send-end")})}_onIce(e){const{instance:n}=this.peer;this._iceTimeout===null&&(this._iceTimeout=setTimeout(()=>this._onIceSdp(n.localDescription),1e3)),e.candidate?L.debug("RTCPeer Candidate:",e.candidate):this._onIceSdp(n.localDescription)}_onTrickleIce(e){e.candidate&&e.candidate.candidate?(L.debug("RTCPeer Candidate:",e.candidate),this._sendIceCandidate(e.candidate)):this._sendEndOfCandidates()}_sendIceCandidate(e){const n=new td({sessid:this.session.sessionid,candidate:e.candidate,sdpMLineIndex:e.sdpMLineIndex,sdpMid:e.sdpMid,dialogParams:this.options});this._execute(n)}_addIceCandidate(e){if(!this._isRemoteDescriptionSet)return L.debug("Remote description not set. Queued ICE candidate.",e),void this._pendingIceCandidates.push(e);this._addIceCandidateToPeer(e)}_addIceCandidateToPeer(e){const n=this.peer.instance.addIceCandidate(e);Promise.resolve(n).then(()=>{L.debug("Successfully added ICE candidate:",e)}).catch(i=>{L.error("Failed to add ICE candidate:",i,e)})}_sendEndOfCandidates(){const e=new tv({sessid:this.session.sessionid,endOfCandidates:!0,dialogParams:this.options});this._execute(e),performance.mark("ice-gathering-end")}_resetTrickleIceCandidateState(){this._pendingIceCandidates=[],this._isRemoteDescriptionSet=!1}_flushPendingTrickleIceCandidates(){if(!this._pendingIceCandidates.length)return;const e=[...this._pendingIceCandidates];this._pendingIceCandidates=[],e.forEach(n=>{this._addIceCandidateToPeer(n)})}_registerPeerEvents(e){this._iceDone=!1,e.onicecandidate=n=>{this._iceDone||this._onIce(n)},e.addEventListener("addstream",n=>{this.options.remoteStream=n.stream}),e.addEventListener("track",n=>{this.options.remoteStream=n.streams[0];const{remoteElement:i,remoteStream:s,screenShare:o}=this.options;o===!1&&zn(i,s)})}_registerTrickleIcePeerEvents(e){e.onicecandidate=n=>{this._onTrickleIce(n)},e.onicegatheringstatechange=n=>{L.debug("ICE gathering state changed:",e.iceGatheringState),e.iceGatheringState==="complete"&&L.debug("Finished gathering candidates")},e.onicecandidateerror=n=>{L.debug("ICE candidate error:",n)},e.addEventListener("addstream",n=>{this.options.remoteStream=n.stream}),e.addEventListener("track",n=>{this.options.remoteStream=n.streams[0];const{remoteElement:i,remoteStream:s,screenShare:o}=this.options;o===!1&&zn(i,s)})}_onMediaError(e){this._dispatchNotification({type:at.userMediaError,error:e}),this.hangup({},!1)}_dispatchConferenceUpdate(e){this._dispatchNotification(Object.assign({type:at.conferenceUpdate,call:this},e))}_dispatchNotification(e){this.options.screenShare!==!0&&(J(F.Notification,e,this.id,!1)||J(F.Notification,e,this.session.uuid))}_execute(e){return this.nodeId&&(e.targetNodeId=this.nodeId),this.session.execute(e)}_init(){const{id:e,userVariables:n,remoteCallerNumber:i,onNotification:s}=this.options;var o;this.options.id=e?e.toString():an(),this.id=this.options.id,n&&(o=n,Object.keys(o).length!==0)||(this.options.userVariables=this.session.options.userVariables||{}),i||(this.options.remoteCallerNumber=this.options.destinationNumber),this.session.calls[this.id]=this,un(F.MediaError,this._onMediaError,this.id),cn(s)&&un(F.Notification,s.bind(this),this.id),this.setState(W.New),L.info("New Call with Options:",this.options)}_finalize(){this._stopStats(),this.peer&&this.peer.instance&&(this.peer.instance.close(),this.peer=null);const{remoteStream:e,localStream:n}=this.options;qn(e),qn(n),dn(F.MediaError,null,this.id),this.session.calls[this.id]=null,delete this.session.calls[this.id]}_startStats(e){this._statsIntervalId=setInterval(this._doStats,e),L.info("Stats started")}_stopStats(){this._statsIntervalId&&(clearInterval(this._statsIntervalId),this._statsIntervalId=null),L.info("Stats stopped")}}ad.setStateTelnyx=t=>{if(t){switch(t._state){case W.Requesting:case W.Recovering:case W.Trying:case W.Early:t.state="connecting";break;case W.Active:t.state="active";break;case W.Held:t.state="held";break;case W.Hangup:case W.Destroy:t.state="done";break;case W.Answering:t.state="ringing";break;case W.New:t.state="new"}return t}};class Ft extends ad{constructor(){super(...arguments),this._statsInterval=null,this.sendConversationMessage=(e,n)=>this.session.execute(new rv(e,n))}hangup(e={},n=!0){this.screenShare instanceof Ft&&this.screenShare.hangup(e,n),super.hangup(e,n)}startScreenShare(e){return j(this,void 0,void 0,function*(){const n=yield(i={video:!0},navigator.mediaDevices.getDisplayMedia(i));var i;n.getTracks().forEach(l=>{l.addEventListener("ended",()=>{this.screenShare&&this.screenShare.hangup()})});const{remoteCallerName:s,remoteCallerNumber:o,callerName:r,callerNumber:a}=this.options,c=Object.assign({screenShare:!0,localStream:n,destinationNumber:`${this.extension}-screen`,remoteCallerName:s,remoteCallerNumber:`${o}-screen`,callerName:`${r} (Screen)`,callerNumber:`${a} (Screen)`},e);return this.screenShare=new Ft(this.session,c),this.screenShare.invite(),this.screenShare})}stopScreenShare(){this.screenShare instanceof Ft&&this.screenShare.hangup()}setAudioOutDevice(e){return j(this,void 0,void 0,function*(){this.options.speakerId=e;const{remoteElement:n,speakerId:i}=this.options;return!(!n||!i)&&Gu(n,i)})}_finalize(){this._stats(!1),super._finalize()}_stats(e=!0){if(e===!1)return clearInterval(this._statsInterval);L.setLevel(2),this._statsInterval=window.setInterval(()=>j(this,void 0,void 0,function*(){const n=yield this.peer.instance.getStats(null);let i="";const s=["certificate","codec","peer-connection","stream","local-candidate","remote-candidate"],o=["id","type","timestamp"];n.forEach(r=>{s.includes(r.type)||(i+=`
|
|
115
107
|
${r.type}
|
|
116
108
|
`,Object.keys(r).forEach(a=>{o.includes(a)||(i+=` ${a}: ${r[a]}
|
|
117
|
-
`)}))}),B.info(i)}),2e3)}}class m_ extends qv{constructor(t){super(t),this.calls={},this.autoRecoverCalls=!0,this._iceServers=[],this._localElement=null,this._remoteElement=null,this._jwtAuth=!0,this._audioConstraints=!0,this._videoConstraints=!1,this._speaker=null,this.iceServers=t.iceServers,this.ringtoneFile=t.ringtoneFile,this.ringbackFile=t.ringbackFile}get reconnectDelay(){return 1e3}connect(){const t=Object.create(null,{connect:{get:()=>super.connect}});return H(this,void 0,void 0,function*(){t.connect.call(this)})}checkPermissions(t=!0,n=!0){return H(this,void 0,void 0,function*(){try{const i=yield Fi({audio:t,video:n});return Kn(i),!0}catch{return!1}})}logout(){this.disconnect()}disconnect(){const t=Object.create(null,{disconnect:{get:()=>super.disconnect}});return H(this,void 0,void 0,function*(){Object.keys(this.calls).forEach(n=>this.calls[n].setState(X.Purge)),this.calls={},yield t.disconnect.call(this)})}speedTest(t){return new Promise((n,i)=>{if($u(V.SpeedTest,r=>{const{upDur:a,downDur:l}=r,c=l?8*t/(l/1e3)/1024:0;n({upDur:a,downDur:l,upKps:(a?8*t/(a/1e3)/1024:0).toFixed(0),downKps:c.toFixed(0)})},this.uuid),!(t=Number(t)))return i(`Invalid parameter 'bytes': ${t}`);this.executeRaw(`#SPU ${t}`);let s=t/1024;t%1024&&s++;const o=".".repeat(1024);for(let r=0;r<s;r++)this.executeRaw(`#SPB ${o}`);this.executeRaw("#SPE")})}getDevices(){return Xn().catch(t=>(J(V.MediaError,t,this.uuid),[]))}getVideoDevices(){return Xn(le.Video).catch(t=>(J(V.MediaError,t,this.uuid),[]))}getAudioInDevices(){return Xn(le.AudioIn).catch(t=>(J(V.MediaError,t,this.uuid),[]))}getAudioOutDevices(){return Xn(le.AudioOut).catch(t=>(console.error("getAudioOutDevices",t),J(V.MediaError,t,this.uuid),[]))}validateDeviceId(t,n,i){return Bi(t,n,i)}getDeviceResolutions(t){return H(this,void 0,void 0,function*(){try{return yield(n=>H(void 0,void 0,void 0,function*(){const i=[],s=yield Fi({video:{deviceId:{exact:n}}}),o=s.getVideoTracks()[0];for(let r=0;r<zu.length;r++){const[a,l]=zu[r];(yield o.applyConstraints({width:{exact:a},height:{exact:l}}).then(()=>!0).catch(()=>!1))&&i.push({resolution:`${a}x${l}`,width:a,height:l})}return Kn(s),i}))(t)}catch(n){throw n}})}get mediaConstraints(){return{audio:this._audioConstraints,video:this._videoConstraints}}setAudioSettings(t){return H(this,void 0,void 0,function*(){if(!t)throw new Error("You need to provide the settings object");const{micId:n,micLabel:i}=t,s=Mr(t,["micId","micLabel"]);return qu(s),this._audioConstraints=yield Ku(n,i,"audioinput",s),this.micId=n,this.micLabel=i,this._audioConstraints})}disableMicrophone(){this._audioConstraints=!1}enableMicrophone(){this._audioConstraints=!0}setVideoSettings(t){return H(this,void 0,void 0,function*(){if(!t)throw new Error("You need to provide the settings object");const{camId:n,camLabel:i}=t,s=Mr(t,["camId","camLabel"]);return qu(s),this._videoConstraints=yield Ku(n,i,"videoinput",s),this.camId=n,this.camLabel=i,this._videoConstraints})}disableWebcam(){this._videoConstraints=!1}enableWebcam(){this._videoConstraints=!0}set iceServers(t){const n={urls:["stun:stun.l.google.com:19302"]};this._iceServers=typeof t=="boolean"?t?[n]:[]:t||[Lu,Dv,n]}get iceServers(){return this._iceServers}set speaker(t){this._speaker=t}get speaker(){return this._speaker}set localElement(t){this._localElement=Gn(t)}get localElement(){return this._localElement}set remoteElement(t){this._remoteElement=Gn(t)}get remoteElement(){return this._remoteElement}vertoBroadcast({nodeId:t,channel:n="",data:i}){if(!n)throw new Error(`Invalid channel for broadcast: ${n}`);const s=new n_({sessid:this.sessionid,eventChannel:n,data:i});t&&(s.targetNodeId=t),this.execute(s).catch(o=>o)}vertoSubscribe({nodeId:t,channels:n=[],handler:i}){return H(this,void 0,void 0,function*(){if(!(n=n.filter(l=>l&&!this._existsSubscription(this.relayProtocol,l))).length)return{};const s=new i_({sessid:this.sessionid,eventChannel:n});t&&(s.targetNodeId=t);const o=yield this.execute(s),{unauthorized:r=[],subscribed:a=[]}=Br(o);return r.length&&r.forEach(l=>this._removeSubscription(this.relayProtocol,l)),a.forEach(l=>this._addSubscription(this.relayProtocol,i,l)),o})}vertoUnsubscribe({nodeId:t,channels:n=[]}){return H(this,void 0,void 0,function*(){if(!(n=n.filter(a=>a&&this._existsSubscription(this.relayProtocol,a))).length)return{};const i=new s_({sessid:this.sessionid,eventChannel:n});t&&(i.targetNodeId=t);const s=yield this.execute(i),{unsubscribed:o=[],notSubscribed:r=[]}=Br(s);return o.forEach(a=>this._removeSubscription(this.relayProtocol,a)),r.forEach(a=>this._removeSubscription(this.relayProtocol,a)),s})}static telnyxStateCall(t){return Fe.setStateTelnyx(t)}}class ad{constructor(t,n){this.code=n,this.message=t}}class g_ extends Ot{constructor(){super(),this.method=nt.Ping,this.buildRequest({method:this.method,params:{}})}}class zt{constructor(t){this.session=t}_ack(t,n){const i=new Zv(t,n);this.nodeId&&(i.targetNodeId=this.nodeId),this.session.execute(i)}reconnectDelay(){return 1e3*Fu(2,6)}handleMessage(t){const{session:n}=this,{id:i,method:s,params:o={}}=t,r=o==null?void 0:o.callID,a=o==null?void 0:o.eventChannel,l=o==null?void 0:o.eventType,c=s===nt.Attach;if(l==="channelPvtData")return this._handlePvtEvent(o.pvtData);if(r&&n.calls.hasOwnProperty(r)){if(!c)return n.calls[r].handleMessage(t),void this._ack(i,s);n.calls[r].hangup({},!1)}const d=()=>{var g,_,b,w;const y={id:r,remoteSdp:o.sdp,destinationNumber:o.callee_id_number,remoteCallerName:o.caller_id_name,remoteCallerNumber:o.caller_id_number,callerName:o.callee_id_name,callerNumber:o.callee_id_number,attach:c,mediaSettings:o.mediaSettings,debug:(g=n.options.debug)!==null&&g!==void 0&&g,debugOutput:(_=n.options.debugOutput)!==null&&_!==void 0?_:"socket",prefetchIceCandidates:(b=n.options.prefetchIceCandidates)!==null&&b!==void 0&&b,forceRelayCandidate:(w=n.options.forceRelayCandidate)!==null&&w!==void 0&&w};o.telnyx_call_control_id&&(y.telnyxCallControlId=o.telnyx_call_control_id),o.telnyx_session_id&&(y.telnyxSessionId=o.telnyx_session_id),o.telnyx_leg_id&&(y.telnyxLegId=o.telnyx_leg_id),o.client_state&&(y.clientState=o.client_state),o.dialogParams&&o.dialogParams.custom_headers&&o.dialogParams.custom_headers.length&&(y.customHeaders=o.dialogParams.custom_headers);const S=new Fe(n,y);return S.nodeId=this.nodeId,S},u=new Gu,p=new g_;switch(s){case nt.Ping:this.session.execute(p);break;case nt.Punt:n.disconnect();break;case nt.Invite:{const b=d();b.playRingtone(),b.setState(X.Ringing),b.direction=Se.Inbound,this._ack(i,s);break}case nt.Attach:{const b=d();this.session.autoRecoverCalls?b.answer():b.setState(X.Recovering),b.handleMessage(t);break}case nt.Event:case"webrtc.event":if(!a)return void B.error("Verto received an unknown event:",o);const g=n.relayProtocol,_=a.split(".")[0];n._existsSubscription(g,a)?J(g,o,a):a===n.sessionid?this._handleSessionEvent(o.eventData):n._existsSubscription(g,_)?J(g,o,_):n.calls.hasOwnProperty(a)?n.calls[a].handleMessage(t):J(V.Notification,o,n.uuid);break;case nt.Info:o.type=ae.generic,J(V.Notification,o,n.uuid);break;case nt.ClientReady:this.session.execute(u);break;default:{const b=Dr(t);if(b){switch(b){case Rt.REGISTER:case Rt.REGED:n.connection.previousGatewayState!==Rt.REGED&&n.connection.previousGatewayState!==Rt.REGISTER&&(zt.retriedRegister=0,o.type=ae.vertoClientReady,J(V.Ready,o,n.uuid));break;case Rt.UNREGED:case Rt.NOREG:if(zt.retriedRegister+=1,zt.retriedRegister===5){zt.retriedRegister=0,J(V.Error,{error:new ad("Fail to register the user, the server tried 5 times","UNREGED|NOREG"),sessionId:n.sessionid},n.uuid);break}setTimeout(()=>{this.session.execute(u)},this.reconnectDelay());break;case Rt.FAILED:case Rt.FAIL_WAIT:if(n.connection.previousGatewayState!==Rt.FAILED&&n.connection.previousGatewayState!==Rt.FAIL_WAIT){if(!this.session.hasAutoReconnect()){zt.retriedConnect=0,J(V.Error,{error:new ad("Fail to connect the server, the server tried 5 times","FAILED|FAIL_WAIT"),sessionId:n.sessionid},n.uuid);break}if(zt.retriedConnect+=1,zt.retriedConnect===5){zt.retriedConnect=0,J(V.Error,{error:new Error("Connection Retry Failed"),sessionId:n.sessionid},n.uuid);break}setTimeout(()=>{this.session.disconnect().then(()=>{this.session.clearConnection(),this.session.connect()})},this.reconnectDelay())}break;default:B.warn("GatewayState message unknown method:",t)}break}B.debug("Verto message unknown method:",t);break}}}_retrieveCallId(t,n){const i=Object.keys(this.session.calls);if(t.action!=="bootObj")return i.find(s=>this.session.calls[s].channels.includes(n));{const s=t.data.find(o=>i.includes(o[0]));if(s instanceof Array)return s[0]}}_handlePvtEvent(t){return H(this,void 0,void 0,function*(){const{session:n}=this,i=n.relayProtocol,{action:s,laChannel:o,laName:r,chatChannel:a,infoChannel:l,modChannel:c,conferenceMemberID:d,role:u,callID:p}=t;switch(s){case"conference-liveArray-join":{const g=()=>{n.vertoBroadcast({nodeId:this.nodeId,channel:o,data:{liveArray:{command:"bootstrap",context:o,name:r}}})},_={nodeId:this.nodeId,channels:[o],handler:({data:w})=>{const y=p||this._retrieveCallId(w,o);if(y&&n.calls.hasOwnProperty(y)){const S=n.calls[y];S._addChannel(o),S.extension=r,S.handleConferenceUpdate(w,t).then(C=>{C==="INVALID_PACKET"&&g()})}}},b=yield n.vertoSubscribe(_).catch(w=>{B.error("liveArray subscription error:",w)});ji(b,o)&&g();break}case"conference-liveArray-part":{let g=null;if(o&&n._existsSubscription(i,o)){const{callId:b=null}=n.subscriptions[i][o];if(g=n.calls[b]||null,b!==null){const w={type:ae.conferenceUpdate,action:At.Leave,conferenceName:r,participantId:Number(d),role:u};J(V.Notification,w,b,!1)||J(V.Notification,w,n.uuid),g===null&&dn(V.Notification,null,b)}}const _=[o,a,l,c];n.vertoUnsubscribe({nodeId:this.nodeId,channels:_}).then(({unsubscribedChannels:b=[]})=>{g&&(g.channels=g.channels.filter(w=>!b.includes(w)))}).catch(b=>{B.error("liveArray unsubscribe error:",b)});break}}})}_handleSessionEvent(t){switch(t.contentType){case"layout-info":case"layer-info":id(this.session,t);break;case"logo-info":{const n={type:ae.conferenceUpdate,action:At.LogoInfo,logo:t.logoURL};J(V.Notification,n,this.session.uuid);break}}}}zt.retriedConnect=0,zt.retriedRegister=0;class v_ extends Ot{constructor(t){super(),this.method="anonymous_login";const{target_type:n,target_id:i,target_version_id:s,userVariables:o,sessionId:r,reconnection:a}=t,l={target_type:n,target_id:i,userVariables:o,reconnection:a,"User-Agent":{sdkVersion:jr,data:navigator.userAgent}};r&&(l.sessid=r),s&&(l.target_version_id=s),this.buildRequest({method:this.method,params:l})}}class __ extends m_{constructor(t){super(t),this.relayProtocol="verto-protocol",this.timeoutErrorCode=-329990,this.handleLoginOnSocketOpen=()=>H(this,void 0,void 0,function*(){this._idle=!1;const{login:n,password:i,passwd:s,login_token:o,userVariables:r,autoReconnect:a=!0}=this.options,l=new Yv(n,i||s,o,this.sessionid,r,!!Nr()),c=yield this.execute(l).catch(this._handleLoginError);c&&(this._autoReconnect=a,this.sessionid=c.sessid)}),this.handleAnonymousLoginOnSocketOpen=()=>H(this,void 0,void 0,function*(){this._idle=!1;const{anonymous_login:n}=this.options,i=new v_({target_id:n.target_id,target_type:n.target_type,target_version_id:n.target_version_id,sessionId:this.sessionid,userVariables:this.options.userVariables,reconnection:!!Nr()}),s=yield this.execute(i).catch(this._handleLoginError);s&&(this.sessionid=s.sessid)}),window.addEventListener("beforeunload",n=>{this.calls&&Object.keys(this.calls).forEach(i=>{this.calls[i]&&this.calls[i].hangup({},!0)})})}validateOptions(){return Lr(this.options)||Oi(this.options)}newCall(t){if(!this.validateCallOptions(t))throw new Error("Verto.newCall() error: destinationNumber is required.");console.time(Pu);const n=new Fe(this,t);return n.invite(),n}broadcast(t){return this.vertoBroadcast(t)}subscribe(t){return this.vertoSubscribe(t)}unsubscribe(t){return this.vertoUnsubscribe(t)}validateCallOptions(t){return!!Oi(this.options)||!!t.destinationNumber}_onSocketOpen(){return H(this,void 0,void 0,function*(){return Lr(this.options)?this.handleLoginOnSocketOpen():Oi(this.options)?this.handleAnonymousLoginOnSocketOpen():void 0})}_onSocketMessage(t){new zt(this).handleMessage(t)}}class y_ extends __{constructor(t){super(t),console.log(`SDK version: ${ed}`)}newCall(t){return super.newCall(t)}static webRTCInfo(){return Xv()}static webRTCSupportedBrowserList(){return[{operationSystem:"Android",supported:[{browserName:"Chrome",features:["audio"],supported:vt.full},{browserName:"Firefox",features:["audio"],supported:vt.partial},{browserName:"Safari",supported:vt.not_supported},{browserName:"Edge",supported:vt.not_supported}]},{operationSystem:"iOS",supported:[{browserName:"Chrome",supported:vt.not_supported},{browserName:"Firefox",supported:vt.not_supported},{browserName:"Safari",features:["video","audio"],supported:vt.full},{browserName:"Edge",supported:vt.not_supported}]},{operationSystem:"Linux",supported:[{browserName:"Chrome",features:["video","audio"],supported:vt.full},{browserName:"Firefox",features:["audio"],supported:vt.partial},{browserName:"Safari",supported:vt.not_supported},{browserName:"Edge",supported:vt.not_supported}]},{operationSystem:"MacOS",supported:[{browserName:"Chrome",features:["video","audio"],supported:vt.full},{browserName:"Firefox",features:["audio"],supported:vt.partial},{browserName:"Safari",features:["video","audio"],supported:vt.full},{browserName:"Edge",features:["audio"],supported:vt.partial}]},{operationSystem:"Windows",supported:[{browserName:"Chrome",features:["video","audio"],supported:vt.full},{browserName:"Firefox",features:["audio"],supported:vt.partial},{browserName:"Safari",supported:vt.not_supported},{browserName:"Edge",features:["audio"],supported:vt.partial}]}]}}function b_(e){if(!e||typeof e!="object")return!1;const t=e;return t.method==="ai_conversation"&&typeof t.params=="object"}function w_(e){if(!e||typeof e!="object")return!1;const t=e;return t.params.type!=="response.text.delta"?!1:!!t.params.delta}function x_(e){if(!e||typeof e!="object")return!1;const t=e;return t.params.type!=="conversation.item.created"?!1:!!t.params.item.content}function S_(e){if(!x_(e)||e.params.item.role!=="user"||e.params.item.status!=="completed")return null;let t="",n=[];return Array.isArray(e.params.item.content)?(t=e.params.item.content.reduce((i,s)=>(s.type==="text"&&(i+=s.text),i),""),n=e.params.item.content.reduce((i,s)=>(s.type==="image_url"&&s.image_url.url&&i.push({type:"image",url:s.image_url.url}),i),[])):t=e.params.item.content,{id:e.params.item.id,role:e.params.item.role,timestamp:new Date,content:t,attachments:n}}function C_(e){const[t,n]=Xt([]),[,i]=Zc();return $t(()=>{if(!e)return;const s=o=>{if(b_(o))switch(o.params.type){case"response.text.delta":{w_(o)&&n(r=>{const a=r[r.length-1];if(a&&a.id===o.params.item_id&&a.role==="assistant"){const l={...a,content:a.content+o.params.delta};return[...r.slice(0,-1),l]}else{const l={id:o.params.item_id,role:"assistant",content:o.params.delta,timestamp:new Date};return[...r,l]}}),i("waiting");return}case"conversation.item.created":{const r=S_(o);r&&(i("thinking"),n(a=>{const l=a[a.length-1];if(l&&l.role==="user"&&r.role==="user"&&r.timestamp.getTime()-l.timestamp.getTime()<2e3){const d={...l,id:r.id,content:l.content+" "+r.content,timestamp:r.timestamp,attachments:[...l.attachments||[],...r.attachments||[]]};return[...a.slice(0,-1),d]}return[...a,r]}));return}}};return e.on(V.SocketMessage,s),()=>{e.off(V.SocketMessage,s)}},[e,i]),t}const k_=({call:e,client:t})=>{const n=Ne(),[i,s]=Xt(n.default_state),o=()=>s("expanded"),r=()=>s("collapsed"),a=C_(t);switch(i){case"collapsed":return E(Au,{onExpand:o,call:e,client:t});case"expanded":return E(Iv,{transcript:a,onCollapse:r,call:e});default:return E(Au,{onExpand:o,call:e,client:t})}},Ur=()=>E(Bn.div,{layoutId:Ci,className:"bg-[#FEFDF5] text-black dark:bg-black gap-3 dark:text-white w-[240px] max-w-full rounded-4xl p-4 text-center flex items-center justify-center flex-col shadow-lg shadow-[#38383878]",children:E("div",{className:"rounded-full animate-spin",children:E(mv,{})})}),T_=({call:e,client:t})=>{switch(e==null?void 0:e.state){case"new":case"trying":case"requesting":return E(Ur,{});case"done":case"purged":case"destroy":return null;case"active":return E(k_,{client:t,call:e});default:return E(Ur,{})}},E_=(e,t,n)=>{const[i,s]=Xt(null);return $t(()=>{if(!e)return;const o=new y_({env:t||"production",anonymous_login:{target_id:e,target_type:"ai_assistant",target_version_id:n}});s(o)},[e,t,n]),i},A_=(e,{onReady:t,onNotification:n,onError:i,onSocketMessage:s})=>($t(()=>{if(e)return e.connect().then().catch(console.error),e.on(V.Ready,t),e.on(V.Notification,n),e.on(V.Error,i),e.on(V.SocketMessage,s),()=>{e.off(V.Ready,t),e.off(V.Notification,n),e.off(V.Error,i),e.off(V.SocketMessage,s),e.disconnect()}},[e]),null),R_=({className:e})=>E("svg",{className:e,width:"236",height:"211",viewBox:"0 0 236 211",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E("g",{clipPath:"url(#:R5lfm:)",children:[E("path",{d:"M231.927 194.514C235.881 187.393 237.006 179.067 235.083 171.168C234.531 168.984 233.769 166.858 232.806 164.819C232.502 164.15 232.156 163.501 231.771 162.874L200.418 104.252H168.341L201.143 165.69C202.172 167.475 202.714 169.496 202.714 171.552C202.714 173.608 202.172 175.628 201.143 177.414C200.139 179.082 198.715 180.464 197.01 181.424C195.305 182.385 193.378 182.89 191.416 182.892H154.009C153.595 188.612 151.801 194.15 148.776 199.041C145.751 203.931 141.584 208.033 136.625 211H205.385C209.975 210.698 214.443 209.405 218.475 207.211C224.164 204.438 228.859 200.007 231.927 194.514Z",fill:"currentColor"}),E("path",{d:"M56.0698 65.9049H88.1473L104.134 36.466C105.487 33.9253 107.515 31.7984 109.999 30.3146C112.484 28.8309 115.331 28.0467 118.233 28.0467C121.135 28.0467 123.982 28.8309 126.466 30.3146C128.951 31.7984 130.979 33.9253 132.331 36.466L147.853 65.9049H179.93L157.166 23.3081C153.391 16.2702 147.751 10.3822 140.851 6.27586C133.951 2.16956 126.052 0 118 0C109.948 0 102.049 2.16956 95.1487 6.27586C88.2488 10.3822 82.6089 16.2702 78.8345 23.3081L56.0698 65.9049Z",fill:"currentColor"}),E("path",{d:"M81.9387 99.1324C82.275 93.4362 83.9987 87.9051 86.9627 83.0107C89.9266 78.1164 94.0429 74.0041 98.9604 71.0247H36.875V99.1324H81.9387Z",fill:"currentColor"}),E("path",{d:"M87.0591 101.18V177.977H101.649C104.692 177.944 107.64 176.924 110.041 175.075C112.443 173.226 114.165 170.648 114.946 167.738C115.26 166.621 115.416 165.467 115.411 164.308V118.229C115.425 113.227 117.432 108.432 120.997 104.885C124.561 101.338 129.396 99.3264 134.451 99.286H199.382V71.0247H117.481C109.408 71.0382 101.67 74.2213 95.9663 79.8751C90.2626 85.5289 87.0591 93.1914 87.0591 101.18Z",fill:"currentColor"}),E("path",{d:"M3.1927 164.819C2.23008 166.858 1.46775 168.984 0.916237 171.168C-1.00574 179.084 0.119328 187.425 4.07225 194.565C7.14854 200.039 11.8422 204.452 17.5241 207.211C21.5555 209.405 26.0233 210.698 30.6138 211H117.999C126.232 211 134.128 207.764 139.949 202.003C145.771 196.242 149.042 188.428 149.042 180.281V104.201H134.245C130.607 104.294 127.148 105.782 124.6 108.352C122.051 110.922 120.611 114.372 120.586 117.973V164.051C120.572 169.053 118.555 173.845 114.976 177.377C111.397 180.909 106.549 182.892 101.495 182.892H44.8417C42.8798 182.89 40.9521 182.385 39.2471 181.424C37.5421 180.464 36.1182 179.082 35.1149 177.414C34.0855 175.619 33.5443 173.59 33.5443 171.526C33.5443 169.462 34.0855 167.434 35.1149 165.638L67.9167 104.201H35.5806L4.22746 162.823C3.86529 163.539 3.50313 164.154 3.1927 164.819Z",fill:"currentColor"})]}),E("defs",{children:E("clipPath",{id:":R5lfm:",children:E("rect",{width:"236",height:"211",fill:"currentColor"})})})]});function I_(){const e=Ne();return e.logo_icon_url?E("div",{className:"object-center w-8 h-8 mr-2 overflow-hidden rounded-full",children:E("img",{src:e.logo_icon_url,className:"object-cover w-full h-full",alt:"Logo"})}):E(R_,{className:"w-8 h-8 mr-2"})}const P_=({client:e,versionId:t,callProps:n})=>{const i=Ne(),s=()=>{var d;if(!e){console.error("Client is not initialized.");return}const o=(d=RTCRtpReceiver.getCapabilities("audio"))==null?void 0:d.codecs,r=o==null?void 0:o.find(u=>u.mimeType.toLowerCase().includes("opus")),{customHeaders:a,...l}=n||{},c=a?[...a]:[];t&&c.push({name:"X-AI-Assistant-Version-ID",value:t}),e.newCall({destinationNumber:"xxx",...l,preferred_codecs:[r],customHeaders:c.length>0?c:void 0})};return E(Bn.button,{layoutId:Ci,onClick:s,className:"bg-[#FEFDF5] text-black flex items-center px-4 py-2 text-xl font-medium rounded-full shadow-lg cursor-pointer dark:bg-black dark:text-white ",children:[E(I_,{}),i.start_call_text]})},M_='@layer components;/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-green-400:oklch(79.2% .209 151.711);--color-black:#000;--color-white:#fff;--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--font-weight-medium:500;--font-weight-semibold:600;--radius-md:.375rem;--radius-lg:.5rem;--radius-2xl:1rem;--radius-3xl:1.5rem;--radius-4xl:2rem;--animate-spin:spin 1s linear infinite;--blur-xs:4px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.inset-0{inset:calc(var(--spacing)*0)}.-top-1{top:calc(var(--spacing)*-1)}.top-0{top:calc(var(--spacing)*0)}.-right-1{right:calc(var(--spacing)*-1)}.right-0{right:calc(var(--spacing)*0)}.bottom-0{bottom:calc(var(--spacing)*0)}.left-0{left:calc(var(--spacing)*0)}.z-10{z-index:10}.z-\\[9999\\]{z-index:9999}.mt-2{margin-top:calc(var(--spacing)*2)}.mr-2{margin-right:calc(var(--spacing)*2)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.ml-4{margin-left:calc(var(--spacing)*4)}.ml-auto{margin-left:auto}.flex{display:flex}.hidden{display:none}.inline-flex{display:inline-flex}.h-3{height:calc(var(--spacing)*3)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-8{height:calc(var(--spacing)*8)}.h-16{height:calc(var(--spacing)*16)}.h-\\[72px\\]{height:72px}.h-\\[144px\\]{height:144px}.h-\\[300px\\]{height:300px}.h-full{height:100%}.max-h-32{max-height:calc(var(--spacing)*32)}.min-h-\\[180px\\]{min-height:180px}.w-3{width:calc(var(--spacing)*3)}.w-4{width:calc(var(--spacing)*4)}.w-5{width:calc(var(--spacing)*5)}.w-8{width:calc(var(--spacing)*8)}.w-16{width:calc(var(--spacing)*16)}.w-\\[200px\\]{width:200px}.w-\\[240px\\]{width:240px}.w-\\[250px\\]{width:250px}.w-\\[344px\\]{width:344px}.w-full{width:100%}.max-w-32{max-width:calc(var(--spacing)*32)}.max-w-full{max-width:100%}.flex-1{flex:1}.animate-spin{animation:var(--animate-spin)}.cursor-pointer{cursor:pointer}.list-disc{list-style-type:disc}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:calc(var(--spacing)*1)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px*var(--tw-divide-y-reverse));border-bottom-width:calc(1px*calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-\\[\\#3D3D46\\]>:not(:last-child)){border-color:#3d3d46}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-3xl{border-radius:var(--radius-3xl)}.rounded-4xl{border-radius:var(--radius-4xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-t-3xl{border-top-left-radius:var(--radius-3xl);border-top-right-radius:var(--radius-3xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-solid{--tw-border-style:solid;border-style:solid}.border-\\[\\#969696\\]{border-color:#969696}.bg-\\[\\#E6E3D3\\]{background-color:#e6e3d3}.bg-\\[\\#F36666\\]{background-color:#f36666}.bg-\\[\\#FEFDF5\\]{background-color:#fefdf5}.bg-\\[\\#FEFDF599\\]{background-color:#fefdf599}.bg-red-500{background-color:var(--color-red-500)}.bg-transparent{background-color:#0000}.object-cover{object-fit:cover}.object-center{object-position:center}.p-2{padding:calc(var(--spacing)*2)}.p-4{padding:calc(var(--spacing)*4)}.px-2\\.5{padding-inline:calc(var(--spacing)*2.5)}.px-4{padding-inline:calc(var(--spacing)*4)}.py-2{padding-block:calc(var(--spacing)*2)}.py-3{padding-block:calc(var(--spacing)*3)}.text-center{text-align:center}.text-left{text-align:left}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.text-\\[\\#969696\\]{color:#969696}.text-black{color:var(--color-black)}.text-green-400{color:var(--color-green-400)}.text-red-400{color:var(--color-red-400)}.text-white{color:var(--color-white)}.underline{text-decoration-line:underline}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\\[\\#38383878\\]{--tw-shadow-color:#38383878}@supports (color:color-mix(in lab,red,red)){.shadow-\\[\\#38383878\\]{--tw-shadow-color:color-mix(in oklab,#38383878 var(--tw-shadow-alpha),transparent)}}.backdrop-blur-xs{--tw-backdrop-blur:blur(var(--blur-xs));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,visibility,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.outline-none{--tw-outline-style:none;outline-style:none}@media (hover:hover){.hover\\:bg-red-600:hover{background-color:var(--color-red-600)}}@media (min-width:40rem){.sm\\:h-\\[386px\\]{height:386px}.sm\\:w-\\[400px\\]{width:400px}.sm\\:rounded-3xl{border-radius:var(--radius-3xl)}}@media (min-width:48rem){.md\\:right-10{right:calc(var(--spacing)*10)}.md\\:bottom-10{bottom:calc(var(--spacing)*10)}}.dark\\:border-\\[\\#3D3D46\\]:where(.dark,.dark *){border-color:#3d3d46}.dark\\:bg-\\[\\#3C3C3C\\]:where(.dark,.dark *){background-color:#3c3c3c}.dark\\:bg-\\[\\#38383C96\\]:where(.dark,.dark *){background-color:#38383c96}.dark\\:bg-\\[\\#38383C\\]:where(.dark,.dark *){background-color:#38383c}.dark\\:bg-\\[\\#222227\\]:where(.dark,.dark *){background-color:#222227}.dark\\:bg-\\[\\#750000\\]:where(.dark,.dark *){background-color:#750000}.dark\\:bg-black:where(.dark,.dark *){background-color:var(--color-black)}.dark\\:text-black:where(.dark,.dark *){color:var(--color-black)}.dark\\:text-white:where(.dark,.dark *){color:var(--color-white)}}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:0 0}::-webkit-scrollbar-thumb{background-color:#888;background-clip:content-box;border:2px solid #0000;border-radius:4px}::-webkit-scrollbar-thumb:hover{background-color:#555}html{scrollbar-width:thin;scrollbar-color:#888 transparent}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}',L_=({children:e})=>E("main",{className:"fixed inset-0 z-[9999] pointer-events-none",children:E("div",{className:"absolute bottom-0 right-0 pointer-events-auto md:bottom-10 md:right-10",children:e})}),D_={duration:.1,ease:"circOut"},O_=({children:e,position:t="fixed"})=>{const n=Ne(),s=(t??n.position??"fixed")==="fixed"?E(L_,{children:e}):e;return E("div",{className:xe(n.theme==="dark"&&"dark"),children:E(qf,{transition:D_,children:[E("style",{children:M_}),s]})})},N_=e=>E(Bn.div,{layoutId:Ci,className:"bg-[#FEFDF5] text-black dark:bg-black rounded-2xl p-4 flex flex-col items-center justify-center dark:text-white w-[344px] max-w-full",children:[E(fv,{className:"w-8 h-8 text-red-400"}),E("h1",{className:"mt-2 mb-4 text-2xl font-medium",children:"An error occurred"}),E("ul",{className:"gap-4 ml-4 text-sm list-disc",children:[E("li",{children:"Failed to initialize the Telnyx AI Agent client. Please check your agent ID and ensure that you are connected to the internet."}),E("li",{children:["Make sure that the"," ",E("a",{href:`https://portal.telnyx.com/#/ai/assistants/edit/${e.agentId}?tab=telephony`,className:"inline-flex items-center gap-1 font-medium text-green-400 underline",target:"_blank",rel:"noopener noreferrer",children:["Support Unauthenticated Web Calls"," ",E(wv,{className:"w-4 h-4"})]})," ","option is enabled in your Telnyx agent settings."]})]})]});function V_(e){return Object.keys(e).length===0}function ld(e){var n;if(typeof e!="object"||e===null)return!1;const t=e;return t.method==="ai_conversation"&&((n=t.params)==null?void 0:n.type)==="widget_settings"&&typeof t.params.widget_settings=="object"}const F_=({client:e})=>{const t=jg();return es(()=>{if(!e)return;const n=i=>{if(ld(i)&&!V_(i.params.widget_settings)){const s=i.params.widget_settings;t(s)}};return e.on(V.SocketMessage,n),()=>{e.off(V.SocketMessage,n)}},[e,t]),null};function B_({"agent-id":e,"call-destination-number":t,"call-caller-number":n,"call-caller-name":i,"call-custom-headers":s,environment:o,position:r="fixed","version-id":a}){const l=E_(e,o,a),[c,d]=Xt(null),[u,p]=Xt(!1),[g,_]=Xt(!1),[b,w]=Xt(!1),y={};if(t&&(y.destinationNumber=t),n&&(y.callerNumber=n),i&&(y.callerName=i),s)try{y.customHeaders=JSON.parse(s)}catch{console.error("Invalid JSON for call-custom-headers attribute:",s)}return A_(l,{onReady:()=>p(!1),onNotification:x=>{var k;if(((k=x.call)==null?void 0:k.state)==="destroy")return d(null);d(x)},onError:()=>{p(!1),_(!0)},onSocketMessage:x=>{ld(x)&&w(!0)}}),E(te,{children:[E(O_,{position:r,children:e?g?E(N_,{agentId:e}):u?E(Ur,{}):c!=null&&c.call?E(T_,{call:c.call,client:l}):b?E(P_,{versionId:a,client:l,callProps:y}):null:E("div",{children:"Please provide an assistant ID."})}),E(F_,{client:l})]})}kd(B_,"telnyx-ai-agent",Cg,{shadow:!0})})();
|
|
109
|
+
`)}))}),L.info(i)}),2e3)}}class pv extends K_{constructor(e){super(e),this.calls={},this.autoRecoverCalls=!0,this._iceServers=[],this._localElement=null,this._remoteElement=null,this._jwtAuth=!0,this._audioConstraints=!0,this._speaker=null,this.iceServers=e.iceServers,this.ringtoneFile=e.ringtoneFile,this.ringbackFile=e.ringbackFile}get reconnectDelay(){return 1e3}getIsRegistered(){const e=Object.create(null,{getIsRegistered:{get:()=>super.getIsRegistered}});return j(this,void 0,void 0,function*(){return e.getIsRegistered.call(this)})}connect(){const e=Object.create(null,{connect:{get:()=>super.connect}});return j(this,void 0,void 0,function*(){e.connect.call(this)})}checkPermissions(e=!0,n=!0){return j(this,void 0,void 0,function*(){try{const i=yield Fi({audio:e,video:n});return qn(i),!0}catch{return!1}})}logout(){this.disconnect()}disconnect(){const e=Object.create(null,{disconnect:{get:()=>super.disconnect}});return j(this,void 0,void 0,function*(){Object.keys(this.calls).forEach(n=>this.calls[n].setState(W.Purge)),this.calls={},yield e.disconnect.call(this)})}speedTest(e){return new Promise((n,i)=>{if(Bu(F.SpeedTest,r=>{const{upDur:a,downDur:c}=r,l=c?8*e/(c/1e3)/1024:0;n({upDur:a,downDur:c,upKps:(a?8*e/(a/1e3)/1024:0).toFixed(0),downKps:l.toFixed(0)})},this.uuid),!(e=Number(e)))return i(`Invalid parameter 'bytes': ${e}`);this.executeRaw(`#SPU ${e}`);let s=e/1024;e%1024&&s++;const o=".".repeat(1024);for(let r=0;r<s;r++)this.executeRaw(`#SPB ${o}`);this.executeRaw("#SPE")})}getDevices(){return Kn().catch(e=>(J(F.MediaError,e,this.uuid),[]))}getVideoDevices(){return Kn(mt.Video).catch(e=>(J(F.MediaError,e,this.uuid),[]))}getAudioInDevices(){return Kn(mt.AudioIn).catch(e=>(J(F.MediaError,e,this.uuid),[]))}getAudioOutDevices(){return Kn(mt.AudioOut).catch(e=>(console.error("getAudioOutDevices",e),J(F.MediaError,e,this.uuid),[]))}validateDeviceId(e,n,i){return Nr(e,n,i)}getDeviceResolutions(e){return j(this,void 0,void 0,function*(){try{return yield(n=>j(void 0,void 0,void 0,function*(){const i=[],s=yield Fi({video:{deviceId:{exact:n}}}),o=s.getVideoTracks()[0];for(let r=0;r<Hu.length;r++){const[a,c]=Hu[r];(yield o.applyConstraints({width:{exact:a},height:{exact:c}}).then(()=>!0).catch(()=>!1))&&i.push({resolution:`${a}x${c}`,width:a,height:c})}return qn(s),i}))(e)}catch(n){throw n}})}get mediaConstraints(){return{audio:this._audioConstraints}}setAudioSettings(e){return j(this,void 0,void 0,function*(){if(!e)throw new Error("You need to provide the settings object");const{micId:n,micLabel:i}=e,s=Au(e,["micId","micLabel"]);return Y_(s),this._audioConstraints=yield((o,r,a,c)=>j(void 0,void 0,void 0,function*(){const{deviceId:l}=c;if(l===void 0&&(o||r)){const d=yield Nr(o,r,a).catch(u=>null);d&&(c.deviceId={exact:d})}return c}))(n,i,"audioinput",s),this.micId=n,this.micLabel=i,this._audioConstraints})}disableMicrophone(){this._audioConstraints=!1}enableMicrophone(){this._audioConstraints=!0}set iceServers(e){const n={urls:["stun:stun.l.google.com:19302"]};this._iceServers=typeof e=="boolean"?e?[n]:[]:e||[Mu,O_,n]}get iceServers(){return this._iceServers}set speaker(e){this._speaker=e}get speaker(){return this._speaker}set localElement(e){this._localElement=Li(e)}get localElement(){return this._localElement}set remoteElement(e){this._remoteElement=Li(e)}get remoteElement(){return this._remoteElement}vertoBroadcast({nodeId:e,channel:n="",data:i}){if(!n)throw new Error(`Invalid channel for broadcast: ${n}`);const s=new nv({sessid:this.sessionid,eventChannel:n,data:i});e&&(s.targetNodeId=e),this.execute(s).catch(o=>o)}vertoSubscribe({nodeId:e,channels:n=[],handler:i}){return j(this,void 0,void 0,function*(){if(!(n=n.filter(c=>c&&!this._existsSubscription(this.relayProtocol,c))).length)return{};const s=new iv({sessid:this.sessionid,eventChannel:n});e&&(s.targetNodeId=e);const o=yield this.execute(s),{unauthorized:r=[],subscribed:a=[]}=Fr(o);return r.length&&r.forEach(c=>this._removeSubscription(this.relayProtocol,c)),a.forEach(c=>this._addSubscription(this.relayProtocol,i,c)),o})}vertoUnsubscribe({nodeId:e,channels:n=[]}){return j(this,void 0,void 0,function*(){if(!(n=n.filter(a=>a&&this._existsSubscription(this.relayProtocol,a))).length)return{};const i=new sv({sessid:this.sessionid,eventChannel:n});e&&(i.targetNodeId=e);const s=yield this.execute(i),{unsubscribed:o=[],notSubscribed:r=[]}=Fr(s);return o.forEach(a=>this._removeSubscription(this.relayProtocol,a)),r.forEach(a=>this._removeSubscription(this.relayProtocol,a)),s})}static telnyxStateCall(e){return Ft.setStateTelnyx(e)}}class cd{constructor(e,n){this.code=n,this.message=e}}class mv extends Ee{constructor(){super(),this.method=te.Ping,this.buildRequest({method:this.method,params:{}})}}class ze{constructor(e){this.session=e}_ack(e,n){const i=new Q_(e,n);this.nodeId&&(i.targetNodeId=this.nodeId),this.session.execute(i)}reconnectDelay(){return 1e3*Nu(2,6)}handleMessage(e){const{session:n}=this,{id:i,method:s,params:o={},voice_sdk_id:r}=e,a=o==null?void 0:o.callID,c=o==null?void 0:o.eventChannel,l=o==null?void 0:o.eventType,d=s===te.Attach;if(l==="channelPvtData")return this._handlePvtEvent(o.pvtData);if(a&&n.calls.hasOwnProperty(a)){if(!d)return n.calls[a].handleMessage(e),void this._ack(i,s);n.calls[a].hangup({},!1)}const u=()=>{var y,w,b,v,S;const k={id:a,remoteSdp:o.sdp,destinationNumber:o.callee_id_number,remoteCallerName:o.caller_id_name,remoteCallerNumber:o.caller_id_number,callerName:o.callee_id_name,callerNumber:o.callee_id_number,attach:d,mediaSettings:o.mediaSettings,debug:(y=n.options.debug)!==null&&y!==void 0&&y,debugOutput:(w=n.options.debugOutput)!==null&&w!==void 0?w:"socket",trickleIce:(b=n.options.trickleIce)!==null&&b!==void 0&&b,prefetchIceCandidates:(v=n.options.prefetchIceCandidates)!==null&&v!==void 0&&v,forceRelayCandidate:(S=n.options.forceRelayCandidate)!==null&&S!==void 0&&S};o.telnyx_call_control_id&&(k.telnyxCallControlId=o.telnyx_call_control_id),o.telnyx_session_id&&(k.telnyxSessionId=o.telnyx_session_id),o.telnyx_leg_id&&(k.telnyxLegId=o.telnyx_leg_id),o.client_state&&(k.clientState=o.client_state),o.dialogParams&&o.dialogParams.custom_headers&&o.dialogParams.custom_headers.length&&(k.customHeaders=o.dialogParams.custom_headers);const I=new Ft(n,k);return I.nodeId=this.nodeId,I},m=new Uu(r),g=new mv;switch(s){case te.Ping:this.session.execute(g);break;case te.Punt:n.disconnect();break;case te.Invite:{const b=u();b.playRingtone(),b.setState(W.Ringing),b.direction=St.Inbound,this._ack(i,s);break}case te.Attach:{const b=u();this.session.autoRecoverCalls?b.answer():b.setState(W.Recovering),b.handleMessage(e);break}case te.Event:case"webrtc.event":if(!c)return void L.error("Verto received an unknown event:",o);const y=n.relayProtocol,w=c.split(".")[0];n._existsSubscription(y,c)?J(y,o,c):c===n.sessionid?this._handleSessionEvent(o.eventData):n._existsSubscription(y,w)?J(y,o,w):n.calls.hasOwnProperty(c)?n.calls[c].handleMessage(e):J(F.Notification,o,n.uuid);break;case te.Info:o.type=at.generic,J(F.Notification,o,n.uuid);break;case te.ClientReady:this.session.execute(m);break;default:{const b=Rr(e);if(b){switch(b){case Pe.REGISTER:case Pe.REGED:n.connection.previousGatewayState!==Pe.REGED&&n.connection.previousGatewayState!==Pe.REGISTER&&(ze.retriedRegister=0,o.type=at.vertoClientReady,J(F.Ready,o,n.uuid),n.options.trickleIce&&(L.debug("Trickle ICE is enabled. Checking Gateway support"),this.session.execute(new td({candidate:""})).catch(v=>{v.code===this.session.invalidMethodErrorCode?(console.warn("Trickle ICE is not supported by the server, disabling it."),L.debug("Trickle ICE check error:",JSON.stringify(v,null,2)),n.options.trickleIce=!1):L.debug("Trickle ICE check:",JSON.stringify(v,null,2))})));break;case Pe.UNREGED:case Pe.NOREG:if(ze.retriedRegister+=1,ze.retriedRegister===5){ze.retriedRegister=0,J(F.Error,{error:new cd("Fail to register the user, the server tried 5 times","UNREGED|NOREG"),sessionId:n.sessionid},n.uuid);break}setTimeout(()=>{this.session.execute(m)},this.reconnectDelay());break;case Pe.FAILED:case Pe.FAIL_WAIT:if(n.connection.previousGatewayState!==Pe.FAILED&&n.connection.previousGatewayState!==Pe.FAIL_WAIT){if(!this.session.hasAutoReconnect()){ze.retriedConnect=0,J(F.Error,{error:new cd("Fail to connect the server, the server tried 5 times","FAILED|FAIL_WAIT"),sessionId:n.sessionid},n.uuid);break}if(ze.retriedConnect+=1,ze.retriedConnect===5){ze.retriedConnect=0,J(F.Error,{error:new Error("Connection Retry Failed"),sessionId:n.sessionid},n.uuid);break}setTimeout(()=>{this.session.disconnect().then(()=>{this.session.clearConnection(),this.session.connect()})},this.reconnectDelay())}break;default:L.warn("GatewayState message unknown method:",e)}break}L.debug("Verto message unknown method:",e);break}}}_retrieveCallId(e,n){const i=Object.keys(this.session.calls);if(e.action!=="bootObj")return i.find(s=>this.session.calls[s].channels.includes(n));{const s=e.data.find(o=>i.includes(o[0]));if(s instanceof Array)return s[0]}}_handlePvtEvent(e){return j(this,void 0,void 0,function*(){const{session:n}=this,i=n.relayProtocol,{action:s,laChannel:o,laName:r,chatChannel:a,infoChannel:c,modChannel:l,conferenceMemberID:d,role:u,callID:m}=e;switch(s){case"conference-liveArray-join":{const g=()=>{n.vertoBroadcast({nodeId:this.nodeId,channel:o,data:{liveArray:{command:"bootstrap",context:o,name:r}}})},y={nodeId:this.nodeId,channels:[o],handler:({data:b})=>{const v=m||this._retrieveCallId(b,o);if(v&&n.calls.hasOwnProperty(v)){const S=n.calls[v];S._addChannel(o),S.extension=r,S.handleConferenceUpdate(b,e).then(k=>{k==="INVALID_PACKET"&&g()})}}},w=yield n.vertoSubscribe(y).catch(b=>{L.error("liveArray subscription error:",b)});Vr(w,o)&&g();break}case"conference-liveArray-part":{let g=null;if(o&&n._existsSubscription(i,o)){const{callId:w=null}=n.subscriptions[i][o];if(g=n.calls[w]||null,w!==null){const b={type:at.conferenceUpdate,action:Fe.Leave,conferenceName:r,participantId:Number(d),role:u};J(F.Notification,b,w,!1)||J(F.Notification,b,n.uuid),g===null&&dn(F.Notification,null,w)}}const y=[o,a,c,l];n.vertoUnsubscribe({nodeId:this.nodeId,channels:y}).then(({unsubscribedChannels:w=[]})=>{g&&(g.channels=g.channels.filter(b=>!w.includes(b)))}).catch(w=>{L.error("liveArray unsubscribe error:",w)});break}}})}_handleSessionEvent(e){switch(e.contentType){case"layout-info":case"layer-info":id(this.session,e);break;case"logo-info":{const n={type:at.conferenceUpdate,action:Fe.LogoInfo,logo:e.logoURL};J(F.Notification,n,this.session.uuid);break}}}}ze.retriedConnect=0,ze.retriedRegister=0;class gv extends Ee{constructor(e){super(),this.method="anonymous_login";const{target_type:n,target_id:i,target_version_id:s,userVariables:o,sessionId:r,reconnection:a}=e,c={target_type:n,target_id:i,userVariables:o,reconnection:a,"User-Agent":{sdkVersion:Br,data:navigator.userAgent}};r&&(c.sessid=r),s&&(c.target_version_id=s),this.buildRequest({method:this.method,params:c})}}class _v extends pv{constructor(e){super(e),this.relayProtocol="verto-protocol",this.timeoutErrorCode=-329990,this.handleLoginOnSocketOpen=()=>j(this,void 0,void 0,function*(){this._idle=!1;const{login:n,password:i,passwd:s,login_token:o,userVariables:r,autoReconnect:a=!0}=this.options,c=new J_(n,i||s,o,this.sessionid,r,!!Ni()),l=yield this.execute(c).catch(this._handleLoginError);l&&(this._autoReconnect=a,this.sessionid=l.sessid)}),this.handleAnonymousLoginOnSocketOpen=()=>j(this,void 0,void 0,function*(){this._idle=!1;const{anonymous_login:n}=this.options,i=new gv({target_id:n.target_id,target_type:n.target_type,target_version_id:n.target_version_id,sessionId:this.sessionid,userVariables:this.options.userVariables,reconnection:!!Ni()}),s=yield this.execute(i).catch(this._handleLoginError);s&&(this.sessionid=s.sessid)}),window.addEventListener("beforeunload",n=>{this.calls&&Object.keys(this.calls).forEach(i=>{this.calls[i]&&this.calls[i].hangup({},!0)})})}validateOptions(){return Pr(this.options)||Oi(this.options)}newCall(e){if(!this.validateCallOptions(e))throw new Error("Verto.newCall() error: destinationNumber is required.");performance.mark("new-call-start");const n=new Ft(this,e);return n.invite(),performance.mark("new-call-end"),n}broadcast(e){return this.vertoBroadcast(e)}subscribe(e){return this.vertoSubscribe(e)}unsubscribe(e){return this.vertoUnsubscribe(e)}validateCallOptions(e){return!!Oi(this.options)||!!e.destinationNumber}_onSocketOpen(){return j(this,void 0,void 0,function*(){return Pr(this.options)?this.handleLoginOnSocketOpen():Oi(this.options)?this.handleAnonymousLoginOnSocketOpen():void 0})}_onSocketMessage(e){new ze(this).handleMessage(e)}}class vv extends _v{constructor(e){super(e),console.log(`SDK version: ${Zu}`)}newCall(e){return super.newCall(e)}static webRTCInfo(){return Z_()}static webRTCSupportedBrowserList(){return[{operationSystem:"Android",supported:[{browserName:"Chrome",features:["audio"],supported:_e.full},{browserName:"Firefox",features:["audio"],supported:_e.partial},{browserName:"Safari",supported:_e.not_supported},{browserName:"Edge",supported:_e.not_supported}]},{operationSystem:"iOS",supported:[{browserName:"Chrome",supported:_e.not_supported},{browserName:"Firefox",supported:_e.not_supported},{browserName:"Safari",features:["video","audio"],supported:_e.full},{browserName:"Edge",supported:_e.not_supported}]},{operationSystem:"Linux",supported:[{browserName:"Chrome",features:["video","audio"],supported:_e.full},{browserName:"Firefox",features:["audio"],supported:_e.partial},{browserName:"Safari",supported:_e.not_supported},{browserName:"Edge",supported:_e.not_supported}]},{operationSystem:"MacOS",supported:[{browserName:"Chrome",features:["video","audio"],supported:_e.full},{browserName:"Firefox",features:["audio"],supported:_e.partial},{browserName:"Safari",features:["video","audio"],supported:_e.full},{browserName:"Edge",features:["audio"],supported:_e.partial}]},{operationSystem:"Windows",supported:[{browserName:"Chrome",features:["video","audio"],supported:_e.full},{browserName:"Firefox",features:["audio"],supported:_e.partial},{browserName:"Safari",supported:_e.not_supported},{browserName:"Edge",features:["audio"],supported:_e.partial}]}]}}function yv(t){if(!t||typeof t!="object")return!1;const e=t;return e.method==="ai_conversation"&&typeof e.params=="object"}function bv(t){if(!t||typeof t!="object")return!1;const e=t;return e.params.type!=="response.text.delta"?!1:!!e.params.delta}function wv(t){if(!t||typeof t!="object")return!1;const e=t;return e.params.type!=="conversation.item.created"?!1:!!e.params.item.content}function xv(t){if(!wv(t)||t.params.item.role!=="user"||t.params.item.status!=="completed")return null;let e="",n=[];return Array.isArray(t.params.item.content)?(e=t.params.item.content.reduce((i,s)=>(s.type==="text"&&(i+=s.text),i),""),n=t.params.item.content.reduce((i,s)=>(s.type==="image_url"&&s.image_url.url&&i.push({type:"image",url:s.image_url.url}),i),[])):e=t.params.item.content,{id:t.params.item.id,role:t.params.item.role,timestamp:new Date,content:e,attachments:n}}function Sv(t){const[e,n]=Xe([]),[,i]=Yl();return $e(()=>{if(!t)return;const s=o=>{if(yv(o))switch(o.params.type){case"response.text.delta":{bv(o)&&n(r=>{const a=r[r.length-1];if(a&&a.id===o.params.item_id&&a.role==="assistant"){const c={...a,content:a.content+o.params.delta};return[...r.slice(0,-1),c]}else{const c={id:o.params.item_id,role:"assistant",content:o.params.delta,timestamp:new Date};return[...r,c]}}),i("waiting");return}case"conversation.item.created":{const r=xv(o);r&&(i("thinking"),n(a=>{const c=a[a.length-1];if(c&&c.role==="user"&&r.role==="user"&&r.timestamp.getTime()-c.timestamp.getTime()<2e3){const d={...c,id:r.id,content:c.content+" "+r.content,timestamp:r.timestamp,attachments:[...c.attachments||[],...r.attachments||[]]};return[...a.slice(0,-1),d]}return[...a,r]}));return}}};return t.on(F.SocketMessage,s),()=>{t.off(F.SocketMessage,s)}},[t,i]),e}const kv=({call:t,client:e})=>{const n=Nt(),[i,s]=Xe(n.default_state),o=()=>s("expanded"),r=()=>s("collapsed"),a=Sv(e);switch(i){case"collapsed":return E(Eu,{onExpand:o,call:t,client:e});case"expanded":return E(R_,{transcript:a,onCollapse:r,call:t});default:return E(Eu,{onExpand:o,call:t,client:e})}},$r=()=>E(Bn.div,{layoutId:Si,className:"bg-[#FEFDF5] text-black dark:bg-black gap-3 dark:text-white w-[240px] max-w-full rounded-4xl p-4 text-center flex items-center justify-center flex-col shadow-lg shadow-[#38383878]",children:E("div",{className:"rounded-full animate-spin",children:E(g_,{})})}),Cv=({call:t,client:e})=>{switch(t==null?void 0:t.state){case"new":case"trying":case"requesting":return E($r,{});case"done":case"purged":case"destroy":return null;case"active":return E(kv,{client:e,call:t});default:return E($r,{})}},Tv=(t,e,n)=>{const[i,s]=Xe(null);return $e(()=>{if(!t)return;const o=new vv({env:e||"production",anonymous_login:{target_id:t,target_type:"ai_assistant",target_version_id:n}});s(o)},[t,e,n]),i},Ev=(t,{onReady:e,onNotification:n,onError:i,onSocketMessage:s})=>($e(()=>{if(t)return t.connect().then().catch(console.error),t.on(F.Ready,e),t.on(F.Notification,n),t.on(F.Error,i),t.on(F.SocketMessage,s),()=>{t.off(F.Ready,e),t.off(F.Notification,n),t.off(F.Error,i),t.off(F.SocketMessage,s),t.disconnect()}},[t]),null),Av=({className:t})=>E("svg",{className:t,width:"236",height:"211",viewBox:"0 0 236 211",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[E("g",{clipPath:"url(#:R5lfm:)",children:[E("path",{d:"M231.927 194.514C235.881 187.393 237.006 179.067 235.083 171.168C234.531 168.984 233.769 166.858 232.806 164.819C232.502 164.15 232.156 163.501 231.771 162.874L200.418 104.252H168.341L201.143 165.69C202.172 167.475 202.714 169.496 202.714 171.552C202.714 173.608 202.172 175.628 201.143 177.414C200.139 179.082 198.715 180.464 197.01 181.424C195.305 182.385 193.378 182.89 191.416 182.892H154.009C153.595 188.612 151.801 194.15 148.776 199.041C145.751 203.931 141.584 208.033 136.625 211H205.385C209.975 210.698 214.443 209.405 218.475 207.211C224.164 204.438 228.859 200.007 231.927 194.514Z",fill:"currentColor"}),E("path",{d:"M56.0698 65.9049H88.1473L104.134 36.466C105.487 33.9253 107.515 31.7984 109.999 30.3146C112.484 28.8309 115.331 28.0467 118.233 28.0467C121.135 28.0467 123.982 28.8309 126.466 30.3146C128.951 31.7984 130.979 33.9253 132.331 36.466L147.853 65.9049H179.93L157.166 23.3081C153.391 16.2702 147.751 10.3822 140.851 6.27586C133.951 2.16956 126.052 0 118 0C109.948 0 102.049 2.16956 95.1487 6.27586C88.2488 10.3822 82.6089 16.2702 78.8345 23.3081L56.0698 65.9049Z",fill:"currentColor"}),E("path",{d:"M81.9387 99.1324C82.275 93.4362 83.9987 87.9051 86.9627 83.0107C89.9266 78.1164 94.0429 74.0041 98.9604 71.0247H36.875V99.1324H81.9387Z",fill:"currentColor"}),E("path",{d:"M87.0591 101.18V177.977H101.649C104.692 177.944 107.64 176.924 110.041 175.075C112.443 173.226 114.165 170.648 114.946 167.738C115.26 166.621 115.416 165.467 115.411 164.308V118.229C115.425 113.227 117.432 108.432 120.997 104.885C124.561 101.338 129.396 99.3264 134.451 99.286H199.382V71.0247H117.481C109.408 71.0382 101.67 74.2213 95.9663 79.8751C90.2626 85.5289 87.0591 93.1914 87.0591 101.18Z",fill:"currentColor"}),E("path",{d:"M3.1927 164.819C2.23008 166.858 1.46775 168.984 0.916237 171.168C-1.00574 179.084 0.119328 187.425 4.07225 194.565C7.14854 200.039 11.8422 204.452 17.5241 207.211C21.5555 209.405 26.0233 210.698 30.6138 211H117.999C126.232 211 134.128 207.764 139.949 202.003C145.771 196.242 149.042 188.428 149.042 180.281V104.201H134.245C130.607 104.294 127.148 105.782 124.6 108.352C122.051 110.922 120.611 114.372 120.586 117.973V164.051C120.572 169.053 118.555 173.845 114.976 177.377C111.397 180.909 106.549 182.892 101.495 182.892H44.8417C42.8798 182.89 40.9521 182.385 39.2471 181.424C37.5421 180.464 36.1182 179.082 35.1149 177.414C34.0855 175.619 33.5443 173.59 33.5443 171.526C33.5443 169.462 34.0855 167.434 35.1149 165.638L67.9167 104.201H35.5806L4.22746 162.823C3.86529 163.539 3.50313 164.154 3.1927 164.819Z",fill:"currentColor"})]}),E("defs",{children:E("clipPath",{id:":R5lfm:",children:E("rect",{width:"236",height:"211",fill:"currentColor"})})})]});function Iv(){const t=Nt();return t.logo_icon_url?E("div",{className:"object-center w-8 h-8 mr-2 overflow-hidden rounded-full",children:E("img",{src:t.logo_icon_url,className:"object-cover w-full h-full",alt:"Logo"})}):E(Av,{className:"w-8 h-8 mr-2"})}const Pv=({client:t,versionId:e,callProps:n})=>{const i=Nt(),s=()=>{var d;if(!t){console.error("Client is not initialized.");return}const o=(d=RTCRtpReceiver.getCapabilities("audio"))==null?void 0:d.codecs,r=o==null?void 0:o.find(u=>u.mimeType.toLowerCase().includes("opus")),{customHeaders:a,...c}=n||{},l=a?[...a]:[];e&&l.push({name:"X-AI-Assistant-Version-ID",value:e}),t.newCall({destinationNumber:"xxx",...c,preferred_codecs:[r],customHeaders:l.length>0?l:void 0})};return E(Bn.button,{layoutId:Si,onClick:s,className:"bg-[#FEFDF5] text-black flex items-center px-4 py-2 text-xl font-medium rounded-full shadow-lg cursor-pointer dark:bg-black dark:text-white ",children:[E(Iv,{}),i.start_call_text]})},Rv='@layer components;/*! tailwindcss v4.1.11 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-green-400:oklch(79.2% .209 151.711);--color-black:#000;--color-white:#fff;--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--font-weight-medium:500;--font-weight-semibold:600;--radius-md:.375rem;--radius-lg:.5rem;--radius-2xl:1rem;--radius-3xl:1.5rem;--radius-4xl:2rem;--animate-spin:spin 1s linear infinite;--blur-xs:4px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.inset-0{inset:calc(var(--spacing)*0)}.-top-1{top:calc(var(--spacing)*-1)}.top-0{top:calc(var(--spacing)*0)}.-right-1{right:calc(var(--spacing)*-1)}.right-0{right:calc(var(--spacing)*0)}.bottom-0{bottom:calc(var(--spacing)*0)}.left-0{left:calc(var(--spacing)*0)}.z-10{z-index:10}.z-\\[9999\\]{z-index:9999}.mt-2{margin-top:calc(var(--spacing)*2)}.mr-2{margin-right:calc(var(--spacing)*2)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.ml-4{margin-left:calc(var(--spacing)*4)}.ml-auto{margin-left:auto}.flex{display:flex}.hidden{display:none}.inline-flex{display:inline-flex}.h-3{height:calc(var(--spacing)*3)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-8{height:calc(var(--spacing)*8)}.h-16{height:calc(var(--spacing)*16)}.h-\\[72px\\]{height:72px}.h-\\[144px\\]{height:144px}.h-\\[300px\\]{height:300px}.h-full{height:100%}.max-h-32{max-height:calc(var(--spacing)*32)}.min-h-\\[180px\\]{min-height:180px}.w-3{width:calc(var(--spacing)*3)}.w-4{width:calc(var(--spacing)*4)}.w-5{width:calc(var(--spacing)*5)}.w-8{width:calc(var(--spacing)*8)}.w-16{width:calc(var(--spacing)*16)}.w-\\[200px\\]{width:200px}.w-\\[240px\\]{width:240px}.w-\\[250px\\]{width:250px}.w-\\[344px\\]{width:344px}.w-full{width:100%}.max-w-32{max-width:calc(var(--spacing)*32)}.max-w-full{max-width:100%}.flex-1{flex:1}.animate-spin{animation:var(--animate-spin)}.cursor-pointer{cursor:pointer}.list-disc{list-style-type:disc}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:calc(var(--spacing)*1)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px*var(--tw-divide-y-reverse));border-bottom-width:calc(1px*calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-\\[\\#3D3D46\\]>:not(:last-child)){border-color:#3d3d46}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-3xl{border-radius:var(--radius-3xl)}.rounded-4xl{border-radius:var(--radius-4xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-t-3xl{border-top-left-radius:var(--radius-3xl);border-top-right-radius:var(--radius-3xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-solid{--tw-border-style:solid;border-style:solid}.border-\\[\\#969696\\]{border-color:#969696}.bg-\\[\\#E6E3D3\\]{background-color:#e6e3d3}.bg-\\[\\#F36666\\]{background-color:#f36666}.bg-\\[\\#FEFDF5\\]{background-color:#fefdf5}.bg-\\[\\#FEFDF599\\]{background-color:#fefdf599}.bg-red-500{background-color:var(--color-red-500)}.bg-transparent{background-color:#0000}.object-cover{object-fit:cover}.object-center{object-position:center}.p-2{padding:calc(var(--spacing)*2)}.p-4{padding:calc(var(--spacing)*4)}.px-2\\.5{padding-inline:calc(var(--spacing)*2.5)}.px-4{padding-inline:calc(var(--spacing)*4)}.py-2{padding-block:calc(var(--spacing)*2)}.py-3{padding-block:calc(var(--spacing)*3)}.text-center{text-align:center}.text-left{text-align:left}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.text-\\[\\#969696\\]{color:#969696}.text-black{color:var(--color-black)}.text-green-400{color:var(--color-green-400)}.text-red-400{color:var(--color-red-400)}.text-white{color:var(--color-white)}.underline{text-decoration-line:underline}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\\[\\#38383878\\]{--tw-shadow-color:#38383878}@supports (color:color-mix(in lab,red,red)){.shadow-\\[\\#38383878\\]{--tw-shadow-color:color-mix(in oklab,#38383878 var(--tw-shadow-alpha),transparent)}}.backdrop-blur-xs{--tw-backdrop-blur:blur(var(--blur-xs));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,visibility,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.outline-none{--tw-outline-style:none;outline-style:none}@media (hover:hover){.hover\\:bg-red-600:hover{background-color:var(--color-red-600)}}@media (min-width:40rem){.sm\\:h-\\[386px\\]{height:386px}.sm\\:w-\\[400px\\]{width:400px}.sm\\:rounded-3xl{border-radius:var(--radius-3xl)}}@media (min-width:48rem){.md\\:right-10{right:calc(var(--spacing)*10)}.md\\:bottom-10{bottom:calc(var(--spacing)*10)}}.dark\\:border-\\[\\#3D3D46\\]:where(.dark,.dark *){border-color:#3d3d46}.dark\\:bg-\\[\\#3C3C3C\\]:where(.dark,.dark *){background-color:#3c3c3c}.dark\\:bg-\\[\\#38383C96\\]:where(.dark,.dark *){background-color:#38383c96}.dark\\:bg-\\[\\#38383C\\]:where(.dark,.dark *){background-color:#38383c}.dark\\:bg-\\[\\#222227\\]:where(.dark,.dark *){background-color:#222227}.dark\\:bg-\\[\\#750000\\]:where(.dark,.dark *){background-color:#750000}.dark\\:bg-black:where(.dark,.dark *){background-color:var(--color-black)}.dark\\:text-black:where(.dark,.dark *){color:var(--color-black)}.dark\\:text-white:where(.dark,.dark *){color:var(--color-white)}}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:0 0}::-webkit-scrollbar-thumb{background-color:#888;background-clip:content-box;border:2px solid #0000;border-radius:4px}::-webkit-scrollbar-thumb:hover{background-color:#555}html{scrollbar-width:thin;scrollbar-color:#888 transparent}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}',Mv=({children:t})=>E("main",{className:"fixed inset-0 z-[9999] pointer-events-none",children:E("div",{className:"absolute bottom-0 right-0 pointer-events-auto md:bottom-10 md:right-10",children:t})}),Dv={duration:.1,ease:"circOut"},Lv=({children:t,position:e="fixed"})=>{const n=Nt(),s=(e??n.position??"fixed")==="fixed"?E(Mv,{children:t}):t;return E("div",{className:xt(n.theme==="dark"&&"dark"),children:E(Kf,{transition:Dv,children:[E("style",{children:Rv}),s]})})},Ov=t=>E(Bn.div,{layoutId:Si,className:"bg-[#FEFDF5] text-black dark:bg-black rounded-2xl p-4 flex flex-col items-center justify-center dark:text-white w-[344px] max-w-full",children:[E(p_,{className:"w-8 h-8 text-red-400"}),E("h1",{className:"mt-2 mb-4 text-2xl font-medium",children:"An error occurred"}),E("ul",{className:"gap-4 ml-4 text-sm list-disc",children:[E("li",{children:"Failed to initialize the Telnyx AI Agent client. Please check your agent ID and ensure that you are connected to the internet."}),E("li",{children:["Make sure that the"," ",E("a",{href:`https://portal.telnyx.com/#/ai/assistants/edit/${t.agentId}?tab=telephony`,className:"inline-flex items-center gap-1 font-medium text-green-400 underline",target:"_blank",rel:"noopener noreferrer",children:["Support Unauthenticated Web Calls"," ",E(x_,{className:"w-4 h-4"})]})," ","option is enabled in your Telnyx agent settings."]})]})]});function Nv(t){return Object.keys(t).length===0}function ld(t){var n;if(typeof t!="object"||t===null)return!1;const e=t;return e.method==="ai_conversation"&&((n=e.params)==null?void 0:n.type)==="widget_settings"&&typeof e.params.widget_settings=="object"}const Vv=({client:t})=>{const e=$g();return Qi(()=>{if(!t)return;const n=i=>{if(ld(i)&&!Nv(i.params.widget_settings)){const s=i.params.widget_settings;e(s)}};return t.on(F.SocketMessage,n),()=>{t.off(F.SocketMessage,n)}},[t,e]),null};function Fv({"agent-id":t,"call-destination-number":e,"call-caller-number":n,"call-caller-name":i,"call-custom-headers":s,environment:o,position:r="fixed","version-id":a}){const c=Tv(t,o,a),[l,d]=Xe(null),[u,m]=Xe(!1),[g,y]=Xe(!1),[w,b]=Xe(!1),v={};if(e&&(v.destinationNumber=e),n&&(v.callerNumber=n),i&&(v.callerName=i),s)try{v.customHeaders=JSON.parse(s)}catch{console.error("Invalid JSON for call-custom-headers attribute:",s)}return Ev(c,{onReady:()=>m(!1),onNotification:x=>{var C;if(((C=x.call)==null?void 0:C.state)==="destroy")return d(null);d(x)},onError:()=>{m(!1),y(!0)},onSocketMessage:x=>{ld(x)&&b(!0)}}),E(et,{children:[E(Lv,{position:r,children:t?g?E(Ov,{agentId:t}):u?E($r,{}):l!=null&&l.call?E(Cv,{call:l.call,client:c}):w?E(Pv,{versionId:a,client:c,callProps:v}):null:E("div",{children:"Please provide an assistant ID."})}),E(Vv,{client:c})]})}Td(Fv,"telnyx-ai-agent",Cg,{shadow:!0})})();
|