@telnyx/ai-agent-widget 0.8.0 → 0.9.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 +8 -8
- package/package.json +2 -2
package/dist/bundle.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){"use strict";var dn,q,qr,Ae,Kr,Xr,Yr,Zr,Ui,Gi,Hi,Jr,hn={},Qr=[],nd=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,fn=Array.isArray;function Zt(e,t){for(var n in t)e[n]=t[n];return e}function Wi(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Bt(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?dn.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 pn(e,r,i,s,null)}function pn(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??++qr,__i:-1,__u:0};return s==null&&q.vnode!=null&&q.vnode(o),o}function ue(e){return e.children}function Wt(e,t){this.props=e,this.context=t}function Ue(e,t){if(t==null)return e.__?Ue(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"?Ue(e):null}function to(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 to(e)}}function zi(e){(!e.__d&&(e.__d=!0)&&Ae.push(e)&&!Zn.__r++||Kr!=q.debounceRendering)&&((Kr=q.debounceRendering)||Xr)(Zn)}function Zn(){for(var e,t,n,i,s,o,r,a=1;Ae.length;)Ae.length>a&&Ae.sort(Yr),e=Ae.shift(),a=Ae.length,e.__d&&(n=void 0,s=(i=(t=e).__v).__e,o=[],r=[],t.__P&&((n=Zt({},i)).__v=i.__v+1,q.vnode&&q.vnode(n),qi(t.__P,n,i,t.__n,t.__P.namespaceURI,32&i.__u?[s]:null,o,s??Ue(i),!!(32&i.__u),r),n.__v=i.__v,n.__.__k[n.__i]=n,ro(o,n,r),n.__e!=s&&to(n)));Zn.__r=0}function eo(e,t,n,i,s,o,r,a,l,c,d){var u,m,g,_,w,b,y=i&&i.__k||Qr,S=t.length;for(l=id(n,t,y,l,S),u=0;u<S;u++)(g=n.__k[u])!=null&&(m=g.__i==-1?hn:y[g.__i]||hn,g.__i=u,b=qi(e,g,m,s,o,r,a,l,c,d),_=g.__e,g.ref&&m.ref!=g.ref&&(m.ref&&Ki(m.ref,null,g),d.push(g.ref,g.__c||_,g)),w==null&&_!=null&&(w=_),4&g.__u||m.__k===g.__k?l=no(g,l,e):typeof g.type=="function"&&b!==void 0?l=b:_&&(l=_.nextSibling),g.__u&=-7);return n.__e=w,l}function id(e,t,n,i,s){var o,r,a,l,c,d=n.length,u=d,m=0;for(e.__k=new Array(s),o=0;o<s;o++)(r=t[o])!=null&&typeof r!="boolean"&&typeof r!="function"?(l=o+m,(r=e.__k[o]=typeof r=="string"||typeof r=="number"||typeof r=="bigint"||r.constructor==String?pn(null,r,null,null,null):fn(r)?pn(ue,{children:r},null,null,null):r.constructor==null&&r.__b>0?pn(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=sd(r,n,l,u))!=-1&&(u--,(a=n[c])&&(a.__u|=2)),a==null||a.__v==null?(c==-1&&(s>d?m--:s<d&&m++),typeof r.type!="function"&&(r.__u|=4)):c!=l&&(c==l-1?m--:c==l+1?m++:(c>l?m--:m++,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=Ue(a)),ao(a,a));return i}function no(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=no(i[s],t,n));return t}e.__e!=t&&(t&&e.type&&!n.contains(t)&&(t=Ue(e)),n.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Jt(e,t){return t=t||[],e==null||typeof e=="boolean"||(fn(e)?e.some(function(n){Jt(n,t)}):t.push(e)),t}function sd(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 io(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||nd.test(t)?n:n+"px"}function Jn(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||io(e.style,t,"");if(n)for(t in n)i&&n[t]==i[t]||io(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(Zr,"$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=Ui,e.addEventListener(t,o?Hi:Gi,o)):e.removeEventListener(t,o?Hi:Gi,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 so(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Ui++;else if(t.t<n.u)return;return n(q.event?q.event(t):t)}}}function qi(e,t,n,i,s,o,r,a,l,c){var d,u,m,g,_,w,b,y,S,C,I,L,D,x,T,f,p,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],I=d?C?C.props.value:d.__:i,n.__c?b=(u=t.__c=n.__c).__=u.__E:(S?t.__c=u=new h(y,I):(t.__c=u=new Wt(y,I),u.constructor=h,u.render=od),C&&C.sub(u),u.props=y,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=Zt({},u.__s)),Zt(u.__s,h.getDerivedStateFromProps(y,u.__s))),g=u.props,_=u.state,u.__v=t,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&&y!==g&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(y,I),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(y,u.__s,I)===!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,I),S&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(g,_,w)})}if(u.context=I,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),T=0;T<u._sb.length;T++)u.__h.push(u._sb[T]);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=Zt(Zt({},i),u.getChildContext())),S&&!m&&u.getSnapshotBeforeUpdate!=null&&(w=u.getSnapshotBeforeUpdate(g,_)),f=d,d!=null&&d.type===ue&&d.key==null&&(f=oo(d.props.children)),a=eo(e,fn(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),b&&(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(p=o.length;p--;)Wi(o[p]);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=rd(n.__e,t,n,i,s,o,r,l,c);return(d=q.diffed)&&d(t),128&t.__u?void 0:a}function ro(e,t,n){for(var i=0;i<n.length;i++)Ki(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 oo(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:fn(e)?e.map(oo):Zt({},e)}function rd(e,t,n,i,s,o,r,a,l){var c,d,u,m,g,_,w,b=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)b===y||a&&e.data==y||(e.data=y);else{if(o=o&&dn.call(e.childNodes),b=n.props||hn,!a&&o!=null)for(b={},c=0;c<e.attributes.length;c++)b[(g=e.attributes[c]).name]=g.value;for(c in b)if(g=b[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;Jn(e,c,null,g,s)}}for(c in y)g=y[c],c=="children"?m=g:c=="dangerouslySetInnerHTML"?d=g:c=="value"?_=g:c=="checked"?w=g:a&&typeof g!="function"||b[c]===g||Jn(e,c,g,b[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=""),eo(t.type=="template"?e.content:e,fn(m)?m:[m],t,n,i,S=="foreignObject"?"http://www.w3.org/1999/xhtml":s,o,r,o?o[0]:n.__k&&Ue(n,0),a,l),o!=null)for(c=o.length;c--;)Wi(o[c]);a||(c="value",S=="progress"&&_==null?e.removeAttribute("value"):_!=null&&(_!==e[c]||S=="progress"&&!_||S=="option"&&_!=b[c])&&Jn(e,c,_,b[c],s),c="checked",w!=null&&w!=e[c]&&Jn(e,c,w,b[c],s))}return e}function Ki(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 ao(e,t,n){var i,s;if(q.unmount&&q.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||Ki(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]&&ao(i[s],t,n||typeof e.type!="function");n||Wi(e.__e),e.__c=e.__=e.__e=void 0}function od(e,t,n){return this.constructor(e,n)}function Qn(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=[],qi(t,e=(!i&&n||t).__k=Bt(ue,null,[e]),s||hn,hn,t.namespaceURI,!i&&n?[n]:s?null:t.firstChild?dn.call(t.childNodes):null,o,!i&&n?n:s?s.__e:t.firstChild,i,r),ro(o,e,r)}function lo(e,t){Qn(e,t,lo)}function Xi(e,t,n){var i,s,o,r,a=Zt({},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?dn.call(arguments,2):n),pn(e.type,a,i||e.key,s||e.ref,null)}function Ee(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,zi(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"+Jr++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,i){return n.children(i)}).contextType=t,t}dn=Qr.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}},qr=0,Wt.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Zt({},this.state),typeof e=="function"&&(e=e(Zt({},n),this.props)),e&&Zt(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),zi(this))},Wt.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),zi(this))},Wt.prototype.render=ue,Ae=[],Xr=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Yr=function(e,t){return e.__v.__b-t.__v.__b},Zn.__r=0,Zr=/(PointerCapture)$|Capture$/i,Ui=0,Gi=so(!1),Hi=so(!0),Jr=0;var ad=0;function M(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:--ad,__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 Yi(){return(Yi=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 ld=["context","children"];function cd(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,ld);return Xi(t,n)}function ud(){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=Bt(cd,Yi({},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[co(a[r].name)]=a[r].value);for(r=l.length;r--;){var c=t(l[r],null),d=l[r].slot;d?o[d]=Bt(uo,{name:d},c):s[r]=c}var u=i?Bt(uo,null,s):s;return Bt(i||n.nodeName.toLowerCase(),o,u)}(this,this._vdomComponent)),(this.hasAttribute("hydrate")?lo:Qn)(this._vdom,this._root)}function co(e){return e.replace(/-(\w)/g,function(t,n){return n?n.toUpperCase():""})}function dd(e,t,n){if(this._vdom){var i={};i[e]=n=n??void 0,i[co(e)]=n,this._vdom=Xi(this._vdom,i),Qn(this._vdom,this._root)}}function hd(){Qn(this._vdom=null,this._root)}function uo(e,t){var n=this;return Bt("slot",Yi({},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 fd(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=ud,s.prototype.attributeChangedCallback=dd,s.prototype.disconnectedCallback=hd,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 me,at,Zi,ho,mn=0,fo=[],pt=q,po=pt.__b,mo=pt.__r,go=pt.diffed,vo=pt.__c,_o=pt.unmount,yo=pt.__;function Ge(e,t){pt.__h&&pt.__h(at,e,mn||t),mn=0;var n=at.__H||(at.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function ge(e){return mn=1,bo(So,e)}function bo(e,t,n){var i=Ge(me++,2);if(i.t=e,!i.__c&&(i.__=[n?n(t):So(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(m){return!!m.__c});if(d.every(function(m){return!m.__N}))return!o||o.call(this,a,l,c);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,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 zt(e,t){var n=Ge(me++,3);!pt.__s&&es(n.__H,t)&&(n.__=e,n.u=t,at.__H.__h.push(n))}function wo(e,t){var n=Ge(me++,4);!pt.__s&&es(n.__H,t)&&(n.__=e,n.u=t,at.__h.push(n))}function qt(e){return mn=5,Qt(function(){return{current:e}},[])}function Qt(e,t){var n=Ge(me++,7);return es(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ji(e,t){return mn=8,Qt(function(){return e},t)}function wt(e){var t=at.context[e.__c],n=Ge(me++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(at)),t.props.value):e.__}function pd(e,t){pt.useDebugValue&&pt.useDebugValue(t?t(e):e)}function Qi(){var e=Ge(me++,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 md(){for(var e;e=fo.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(ti),e.__H.__h.forEach(ts),e.__H.__h=[]}catch(t){e.__H.__h=[],pt.__e(t,e.__v)}}pt.__b=function(e){at=null,po&&po(e)},pt.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),yo&&yo(e,t)},pt.__r=function(e){mo&&mo(e),me=0;var t=(at=e.__c).__H;t&&(Zi===at?(t.__h=[],at.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(ti),t.__h.forEach(ts),t.__h=[],me=0)),Zi=at},pt.diffed=function(e){go&&go(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(fo.push(t)!==1&&ho===pt.requestAnimationFrame||((ho=pt.requestAnimationFrame)||gd)(md)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Zi=at=null},pt.__c=function(e,t){t.some(function(n){try{n.__h.forEach(ti),n.__h=n.__h.filter(function(i){return!i.__||ts(i)})}catch(i){t.some(function(s){s.__h&&(s.__h=[])}),t=[],pt.__e(i,n.__v)}}),vo&&vo(e,t)},pt.unmount=function(e){_o&&_o(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(i){try{ti(i)}catch(s){t=s}}),n.__H=void 0,t&&pt.__e(t,n.__v))};var xo=typeof requestAnimationFrame=="function";function gd(e){var t,n=function(){clearTimeout(i),xo&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(n,35);xo&&(t=requestAnimationFrame(n))}function ti(e){var t=at,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),at=t}function ts(e){var t=at;e.__c=e.__(),at=t}function es(e,t){return!e||e.length!==t.length||t.some(function(n,i){return n!==e[i]})}function So(e,t){return typeof t=="function"?t(e):t}function Co(e,t){for(var n in t)e[n]=t[n];return e}function To(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 ko=wo;function Ao(e,t){this.props=e,this.context=t}(Ao.prototype=new Wt).isPureReactComponent=!0,Ao.prototype.shouldComponentUpdate=function(e,t){return To(this.props,e)||To(this.state,t)};var Eo=q.__b;q.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Eo&&Eo(e)};var vd=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function _d(e){function t(n){var i=Co({},n);return delete i.ref,e(i,n.ref||null)}return t.$$typeof=vd,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var Ro=function(e,t){return e==null?null:Jt(Jt(e).map(t))},yd={map:Ro,forEach:Ro,count:function(e){return e?Jt(e).length:0},only:function(e){var t=Jt(e);if(t.length!==1)throw"Children.only";return t[0]},toArray:Jt},bd=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)}bd(e,t,n,i)};var Io=q.unmount;function Po(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=Co({},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 Po(i,t,n)})),e}function Lo(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(i){return Lo(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 ns(){this.__u=0,this.o=null,this.__b=null}function Mo(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function ei(){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),Io&&Io(e)},(ns.prototype=new Wt).__c=function(e,t){var n=t.__c,i=this;i.o==null&&(i.o=[]),i.o.push(n);var s=Mo(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]=Lo(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)},ns.prototype.componentWillUnmount=function(){this.o=[]},ns.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]=Po(this.__b,n,i.__O=i.__P)}this.__b=null}var s=t.__a&&Bt(ue,null,e.fallback);return s&&(s.__u&=-33),[Bt(ue,null,t.__a?null:e.children),s]};var Do=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]}};(ei.prototype=new Wt).__a=function(e){var t=this,n=Mo(t.__v),i=t.l.get(e);return i[0]++,function(s){var o=function(){t.props.revealOrder?(i.push(s),Do(t,e,i)):s()};n?n(o):o()}},ei.prototype.render=function(e){this.i=null,this.l=new Map;var t=Jt(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},ei.prototype.componentDidUpdate=ei.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Do(e,n,t)})};var Oo=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,wd=/^(?: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]/,xd=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Sd=/[A-Z0-9]/g,Cd=typeof document<"u",Td=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};Wt.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(Wt.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Vo=q.event;function kd(){}function Ad(){return this.cancelBubble}function Ed(){return this.defaultPrevented}q.event=function(e){return Vo&&(e=Vo(e)),e.persist=kd,e.isPropagationStopped=Ad,e.isDefaultPrevented=Ed,e.nativeEvent=e};var Rd={enumerable:!1,configurable:!0,get:function(){return this.class}},No=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||Cd&&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"||Td(n.type)?l==="onfocus"?r="onfocusin":l==="onblur"?r="onfocusout":xd.test(r)&&(r=l):l=r="oninput":o&&wd.test(r)?r=r.replace(Sd,"-$&").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=Jt(n.children).forEach(function(c){c.props.selected=s.value.indexOf(c.props.value)!=-1})),i=="select"&&s.defaultValue!=null&&(s.value=Jt(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",Rd)):(n.className&&!n.class||n.class&&n.className)&&(s.class=s.className=n.className),t.props=s}(e),e.$$typeof=Oo,No&&No(e)};var Bo=q.__r;q.__r=function(e){Bo&&Bo(e),e.__c};var Fo=q.diffed;q.diffed=function(e){Fo&&Fo(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 jo(e){return!!e&&e.$$typeof===Oo}function Id(e){return jo(e)?Xi.apply(null,arguments):e}var $o={};const is=Ee({});function ni(e){const t=qt(null);return t.current===null&&(t.current=e()),t.current}const ss=typeof window<"u",Uo=ss?wo:zt,ii=Ee(null);function rs(e,t){e.indexOf(t)===-1&&e.push(t)}function os(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const de=(e,t,n)=>n>t?t:n<e?e:n;let as=()=>{};const he={},Go=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function Ho(e){return typeof e=="object"&&e!==null}const Wo=e=>/^0[^.\s]+$/u.test(e);function ls(e){let t;return()=>(t===void 0&&(t=e()),t)}const Ft=e=>e,Pd=(e,t)=>n=>t(e(n)),gn=(...e)=>e.reduce(Pd),vn=(e,t,n)=>{const i=t-e;return i===0?1:(n-e)/i};class cs{constructor(){this.subscriptions=[]}add(t){return rs(this.subscriptions,t),()=>os(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 te=e=>e*1e3,ee=e=>e/1e3;function zo(e,t){return t?e*(1e3/t):0}const qo=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Ld=1e-7,Md=12;function Dd(e,t,n,i,s){let o,r,a=0;do r=t+(n-t)/2,o=qo(r,i,s)-e,o>0?n=r:t=r;while(Math.abs(o)>Ld&&++a<Md);return r}function _n(e,t,n,i){if(e===t&&n===i)return Ft;const s=o=>Dd(o,0,1,e,n);return o=>o===0||o===1?o:qo(s(o),t,i)}const Ko=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Xo=e=>t=>1-e(1-t),Yo=_n(.33,1.53,.69,.99),us=Xo(Yo),Zo=Ko(us),Jo=e=>(e*=2)<1?.5*us(e):.5*(2-Math.pow(2,-10*(e-1))),ds=e=>1-Math.sin(Math.acos(e)),Qo=Xo(ds),ta=Ko(ds),Od=_n(.42,0,1,1),Vd=_n(0,0,.58,1),ea=_n(.42,0,.58,1),Nd=e=>Array.isArray(e)&&typeof e[0]!="number",na=e=>Array.isArray(e)&&typeof e[0]=="number",Bd={linear:Ft,easeIn:Od,easeInOut:ea,easeOut:Vd,circIn:ds,circInOut:ta,circOut:Qo,backIn:us,backInOut:Zo,backOut:Yo,anticipate:Jo},Fd=e=>typeof e=="string",ia=e=>{if(na(e)){as(e.length===4);const[t,n,i,s]=e;return _n(t,n,i,s)}else if(Fd(e))return Bd[e];return e},si=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],sa={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,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(c),t&&sa.value&&sa.value.frameloop[t].push(l),l=0,n.clear(),s=!1,o&&(o=!1,d.process(u))}};return d}const $d=40;function ra(e,t){let n=!1,i=!0;const s={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,r=si.reduce((C,I)=>(C[I]=jd(o,t?I:void 0),C),{}),{setup:a,read:l,resolveKeyframes:c,preUpdate:d,update:u,preRender:m,render:g,postRender:_}=r,w=()=>{const C=he.useManualTiming?s.timestamp:performance.now();n=!1,he.useManualTiming||(s.delta=i?1e3/60:Math.max(Math.min(C-s.timestamp,$d),1)),s.timestamp=C,s.isProcessing=!0,a.process(s),l.process(s),c.process(s),d.process(s),u.process(s),m.process(s),g.process(s),_.process(s),s.isProcessing=!1,n&&t&&(i=!1,e(w))},b=()=>{n=!0,i=!0,s.isProcessing||e(w)};return{schedule:si.reduce((C,I)=>{const L=r[I];return C[I]=(D,x=!1,T=!1)=>(n||b(),L.schedule(D,x,T)),C},{}),cancel:C=>{for(let I=0;I<si.length;I++)r[si[I]].cancel(C)},state:s,steps:r}}const{schedule:ut,cancel:ve,state:St,steps:hs}=ra(typeof requestAnimationFrame<"u"?requestAnimationFrame:Ft,!0);let ri;function Ud(){ri=void 0}const Lt={now:()=>(ri===void 0&&Lt.set(St.isProcessing||he.useManualTiming?St.timestamp:performance.now()),ri),set:e=>{ri=e,queueMicrotask(Ud)}},oa=e=>t=>typeof t=="string"&&t.startsWith(e),fs=oa("--"),Gd=oa("var(--"),ps=e=>Gd(e)?Hd.test(e.split("/*")[0].trim()):!1,Hd=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,He={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},yn={...He,transform:e=>de(0,1,e)},oi={...He,default:1},bn=e=>Math.round(e*1e5)/1e5,ms=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Wd(e){return e==null}const zd=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,gs=(e,t)=>n=>!!(typeof n=="string"&&zd.test(n)&&n.startsWith(e)||t&&!Wd(n)&&Object.prototype.hasOwnProperty.call(n,t)),aa=(e,t,n)=>i=>{if(typeof i!="string")return i;const[s,o,r,a]=i.match(ms);return{[e]:parseFloat(s),[t]:parseFloat(o),[n]:parseFloat(r),alpha:a!==void 0?parseFloat(a):1}},qd=e=>de(0,255,e),vs={...He,transform:e=>Math.round(qd(e))},Re={test:gs("rgb","red"),parse:aa("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:i=1})=>"rgba("+vs.transform(e)+", "+vs.transform(t)+", "+vs.transform(n)+", "+bn(yn.transform(i))+")"};function Kd(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 _s={test:gs("#"),parse:Kd,transform:Re.transform},wn=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),_e=wn("deg"),ne=wn("%"),U=wn("px"),Xd=wn("vh"),Yd=wn("vw"),la={...ne,parse:e=>ne.parse(e)/100,transform:e=>ne.transform(e*100)},We={test:gs("hsl","hue"),parse:aa("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:i=1})=>"hsla("+Math.round(e)+", "+ne.transform(bn(t))+", "+ne.transform(bn(n))+", "+bn(yn.transform(i))+")"},yt={test:e=>Re.test(e)||_s.test(e)||We.test(e),parse:e=>Re.test(e)?Re.parse(e):We.test(e)?We.parse(e):_s.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Re.transform(e):We.transform(e),getAnimatableNone:e=>{const t=yt.parse(e);return t.alpha=0,yt.transform(t)}},Zd=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Jd(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(ms))==null?void 0:t.length)||0)+(((n=e.match(Zd))==null?void 0:n.length)||0)>0}const ca="number",ua="color",Qd="var",th="var(",da="${}",eh=/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 xn(e){const t=e.toString(),n=[],i={color:[],number:[],var:[]},s=[];let o=0;const a=t.replace(eh,l=>(yt.test(l)?(i.color.push(o),s.push(ua),n.push(yt.parse(l))):l.startsWith(th)?(i.var.push(o),s.push(Qd),n.push(l)):(i.number.push(o),s.push(ca),n.push(parseFloat(l))),++o,da)).split(da);return{values:n,split:a,indexes:i,types:s}}function ha(e){return xn(e).values}function fa(e){const{split:t,types:n}=xn(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===ca?o+=bn(s[r]):a===ua?o+=yt.transform(s[r]):o+=s[r]}return o}}const nh=e=>typeof e=="number"?0:yt.test(e)?yt.getAnimatableNone(e):e;function ih(e){const t=ha(e);return fa(e)(t.map(nh))}const ye={test:Jd,parse:ha,createTransformer:fa,getAnimatableNone:ih};function ys(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 sh({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=ys(l,a,e+1/3),o=ys(l,a,e),r=ys(l,a,e-1/3)}return{red:Math.round(s*255),green:Math.round(o*255),blue:Math.round(r*255),alpha:i}}function ai(e,t){return n=>n>0?t:e}const mt=(e,t,n)=>e+(t-e)*n,bs=(e,t,n)=>{const i=e*e,s=n*(t*t-i)+i;return s<0?0:Math.sqrt(s)},rh=[_s,Re,We],oh=e=>rh.find(t=>t.test(e));function pa(e){const t=oh(e);if(!t)return!1;let n=t.parse(e);return t===We&&(n=sh(n)),n}const ma=(e,t)=>{const n=pa(e),i=pa(t);if(!n||!i)return ai(e,t);const s={...n};return o=>(s.red=bs(n.red,i.red,o),s.green=bs(n.green,i.green,o),s.blue=bs(n.blue,i.blue,o),s.alpha=mt(n.alpha,i.alpha,o),Re.transform(s))},ws=new Set(["none","hidden"]);function ah(e,t){return ws.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function lh(e,t){return n=>mt(e,t,n)}function xs(e){return typeof e=="number"?lh:typeof e=="string"?ps(e)?ai:yt.test(e)?ma:dh:Array.isArray(e)?ga:typeof e=="object"?yt.test(e)?ma:ch:ai}function ga(e,t){const n=[...e],i=n.length,s=e.map((o,r)=>xs(o)(o,t[r]));return o=>{for(let r=0;r<i;r++)n[r]=s[r](o);return n}}function ch(e,t){const n={...e,...t},i={};for(const s in n)e[s]!==void 0&&t[s]!==void 0&&(i[s]=xs(e[s])(e[s],t[s]));return s=>{for(const o in i)n[o]=i[o](s);return n}}function uh(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 dh=(e,t)=>{const n=ye.createTransformer(t),i=xn(e),s=xn(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?ws.has(e)&&!s.values.length||ws.has(t)&&!i.values.length?ah(e,t):gn(ga(uh(i,s),s.values),n):ai(e,t)};function va(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?mt(e,t,n):xs(e)(e,t)}const hh=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>ut.update(t,n),stop:()=>ve(t),now:()=>St.isProcessing?St.timestamp:Lt.now()}},_a=(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)})`},li=2e4;function Ss(e){let t=0;const n=50;let i=e.next(t);for(;!i.done&&t<li;)t+=n,i=e.next(t);return t>=li?1/0:t}function fh(e,t=100,n){const i=n({...e,keyframes:[0,t]}),s=Math.min(Ss(i),li);return{type:"keyframes",ease:o=>i.next(s*o).value/t,duration:ee(s)}}const ph=5;function ya(e,t,n){const i=Math.max(t-ph,0);return zo(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},Cs=.001;function mh({duration:e=gt.duration,bounce:t=gt.bounce,velocity:n=gt.velocity,mass:i=gt.mass}){let s,o,r=1-t;r=de(gt.minDamping,gt.maxDamping,r),e=de(gt.minDuration,gt.maxDuration,ee(e)),r<1?(s=c=>{const d=c*r,u=d*e,m=d-n,g=Ts(c,r),_=Math.exp(-u);return Cs-m/g*_},o=c=>{const u=c*r*e,m=u*n+n,g=Math.pow(r,2)*Math.pow(c,2)*e,_=Math.exp(-u),w=Ts(Math.pow(c,2),r);return(-s(c)+Cs>0?-1:1)*((m-g)*_)/w}):(s=c=>{const d=Math.exp(-c*e),u=(c-n)*e+1;return-Cs+d*u},o=c=>{const d=Math.exp(-c*e),u=(n-c)*(e*e);return d*u});const a=5/e,l=vh(s,o,a);if(e=te(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 gh=12;function vh(e,t,n){let i=n;for(let s=1;s<gh;s++)i=i-e(i)/t(i);return i}function Ts(e,t){return e*Math.sqrt(1-t*t)}const _h=["duration","bounce"],yh=["stiffness","damping","mass"];function ba(e,t){return t.some(n=>e[n]!==void 0)}function bh(e){let t={velocity:gt.velocity,stiffness:gt.stiffness,damping:gt.damping,mass:gt.mass,isResolvedFromDuration:!1,...e};if(!ba(e,yh)&&ba(e,_h))if(e.visualDuration){const n=e.visualDuration,i=2*Math.PI/(n*1.2),s=i*i,o=2*de(.05,1,1-(e.bounce||0))*Math.sqrt(s);t={...t,mass:gt.mass,stiffness:s,damping:o}}else{const n=mh(e);t={...t,...n,mass:gt.mass},t.isResolvedFromDuration=!0}return t}function ci(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:m,isResolvedFromDuration:g}=bh({...n,velocity:-ee(n.velocity||0)}),_=m||0,w=c/(2*Math.sqrt(l*d)),b=r-o,y=ee(Math.sqrt(l/d)),S=Math.abs(b)<5;i||(i=S?gt.restSpeed.granular:gt.restSpeed.default),s||(s=S?gt.restDelta.granular:gt.restDelta.default);let C;if(w<1){const L=Ts(y,w);C=D=>{const x=Math.exp(-w*y*D);return r-x*((_+w*y*b)/L*Math.sin(L*D)+b*Math.cos(L*D))}}else if(w===1)C=L=>r-Math.exp(-y*L)*(b+(_+y*b)*L);else{const L=y*Math.sqrt(w*w-1);C=D=>{const x=Math.exp(-w*y*D),T=Math.min(L*D,300);return r-x*((_+w*y*b)*Math.sinh(T)+L*b*Math.cosh(T))/L}}const I={calculatedDuration:g&&u||null,next:L=>{const D=C(L);if(g)a.done=L>=u;else{let x=L===0?_:0;w<1&&(x=L===0?te(_):ya(C,L,D));const T=Math.abs(x)<=i,f=Math.abs(r-D)<=s;a.done=T&&f}return a.value=a.done?r:D,a},toString:()=>{const L=Math.min(Ss(I),li),D=_a(x=>I.next(L*x).value,L,30);return L+"ms "+D},toTransition:()=>{}};return I}ci.applyToOptions=e=>{const t=fh(e,100,ci);return e.ease=t.ease,e.duration=te(t.duration),e.type="keyframes",e};function ks({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],m={done:!1,value:u},g=T=>a!==void 0&&T<a||l!==void 0&&T>l,_=T=>a===void 0?l:l===void 0||Math.abs(a-T)<Math.abs(l-T)?a:l;let w=n*t;const b=u+w,y=r===void 0?b:r(b);y!==b&&(w=y-u);const S=T=>-w*Math.exp(-T/i),C=T=>y+S(T),I=T=>{const f=S(T),p=C(T);m.done=Math.abs(f)<=c,m.value=m.done?y:p};let L,D;const x=T=>{g(m.value)&&(L=T,D=ci({keyframes:[m.value,_(m.value)],velocity:ya(C,T,m.value),damping:s,stiffness:o,restDelta:c,restSpeed:d}))};return x(0),{calculatedDuration:null,next:T=>{let f=!1;return!D&&L===void 0&&(f=!0,I(T),x(T)),L!==void 0&&T>=L?D.next(T-L):(!f&&I(T),m)}}}function wh(e,t,n){const i=[],s=n||he.mix||va,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]||Ft:t;a=gn(l,a)}i.push(a)}return i}function xh(e,t,{clamp:n=!0,ease:i,mixer:s}={}){const o=e.length;if(as(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=wh(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 m=vn(e[u],e[u+1],d);return a[u](m)};return n?d=>c(de(e[0],e[o-1],d)):c}function Sh(e,t){const n=e[e.length-1];for(let i=1;i<=t;i++){const s=vn(0,t,i);e.push(mt(n,1,s))}}function Ch(e){const t=[0];return Sh(t,e.length-1),t}function Th(e,t){return e.map(n=>n*t)}function kh(e,t){return e.map(()=>t||ea).splice(0,e.length-1)}function Sn({duration:e=300,keyframes:t,times:n,ease:i="easeInOut"}){const s=Nd(i)?i.map(ia):ia(i),o={done:!1,value:t[0]},r=Th(n&&n.length===t.length?n:Ch(t),e),a=xh(r,t,{ease:Array.isArray(s)?s:kh(t,s)});return{calculatedDuration:e,next:l=>(o.value=a(l),o.done=l>=e,o)}}const Ah=e=>e!==null;function As(e,{repeat:t,repeatType:n="loop"},i,s=1){const o=e.filter(Ah),a=s<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!a||i===void 0?o[a]:i}const Eh={decay:ks,inertia:ks,tween:Sn,keyframes:Sn,spring:ci};function wa(e){typeof e.type=="string"&&(e.type=Eh[e.type])}class Es{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 Rh=e=>e/100;class Rs extends Es{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;wa(t);const{type:n=Sn,repeat:i=0,repeatDelay:s=0,repeatType:o,velocity:r=0}=t;let{keyframes:a}=t;const l=n||Sn;l!==Sn&&typeof a[0]!="number"&&(this.mixKeyframes=gn(Rh,va(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=Ss(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:m,repeatDelay:g,type:_,onUpdate:w,finalKeyframe:b}=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,I=i;if(u){const T=Math.min(this.currentTime,s)/a;let f=Math.floor(T),p=T%1;!p&&T>=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)),C=de(0,1,p)*a}const L=S?{done:!1,value:d[0]}:I.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&&_!==ks&&(L.value=As(d,this.options,b,this.speed)),w&&w(L.value),x&&this.finish(),L}then(t,n){return this.finished.then(t,n)}get duration(){return ee(this.calculatedDuration)}get time(){return ee(this.currentTime)}set time(t){var n;t=te(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=ee(this.currentTime))}play(){var s,o;if(this.isStopped)return;const{driver:t=hh,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 Ih(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Ie=e=>e*180/Math.PI,Is=e=>{const t=Ie(Math.atan2(e[1],e[0]));return Ps(t)},Ph={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Is,rotateZ:Is,skewX:e=>Ie(Math.atan(e[1])),skewY:e=>Ie(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Ps=e=>(e=e%360,e<0&&(e+=360),e),xa=Is,Sa=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Ca=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Lh={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Sa,scaleY:Ca,scale:e=>(Sa(e)+Ca(e))/2,rotateX:e=>Ps(Ie(Math.atan2(e[6],e[5]))),rotateY:e=>Ps(Ie(Math.atan2(-e[2],e[0]))),rotateZ:xa,rotate:xa,skewX:e=>Ie(Math.atan(e[4])),skewY:e=>Ie(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Ls(e){return e.includes("scale")?1:0}function Ms(e,t){if(!e||e==="none")return Ls(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let i,s;if(n)i=Lh,s=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);i=Ph,s=a}if(!s)return Ls(t);const o=i[t],r=s[1].split(",").map(Dh);return typeof o=="function"?o(r):r[o]}const Mh=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Ms(n,t)};function Dh(e){return parseFloat(e.trim())}const ze=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],qe=new Set(ze),Ta=e=>e===He||e===U,Oh=new Set(["x","y","z"]),Vh=ze.filter(e=>!Oh.has(e));function Nh(e){const t=[];return Vh.forEach(n=>{const i=e.getValue(n);i!==void 0&&(t.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),t}const Pe={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})=>Ms(t,"x"),y:(e,{transform:t})=>Ms(t,"y")};Pe.translateX=Pe.x,Pe.translateY=Pe.y;const Le=new Set;let Ds=!1,Os=!1,Vs=!1;function ka(){if(Os){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=Nh(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)})}Os=!1,Ds=!1,Le.forEach(e=>e.complete(Vs)),Le.clear()}function Aa(){Le.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Os=!0)})}function Bh(){Vs=!0,Aa(),ka(),Vs=!1}class Ns{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),Ds||(Ds=!0,ut.read(Aa),ut.resolveKeyframes(ka))):(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])}Ih(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 Fh=e=>e.startsWith("--");function jh(e,t,n){Fh(t)?e.style.setProperty(t,n):e.style[t]=n}const $h=ls(()=>window.ScrollTimeline!==void 0),Uh={};function Gh(e,t){const n=ls(e);return()=>Uh[t]??n()}const Ea=Gh(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Cn=([e,t,n,i])=>`cubic-bezier(${e}, ${t}, ${n}, ${i})`,Ra={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Cn([0,.65,.55,1]),circOut:Cn([.55,0,1,.45]),backIn:Cn([.31,.01,.66,-.59]),backOut:Cn([.33,1.53,.69,.99])};function Ia(e,t){if(e)return typeof e=="function"?Ea()?_a(e,t):"ease-out":na(e)?Cn(e):Array.isArray(e)?e.map(n=>Ia(n,t)||Ra.easeOut):Ra[e]}function Hh(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=Ia(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 c&&(m.pseudoElement=c),e.animate(d,m)}function Pa(e){return typeof e=="function"&&"applyToOptions"in e}function Wh({type:e,...t}){return Pa(e)&&Ea()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class zh extends Es{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,as(typeof t.type!="string");const c=Wh(t);this.animation=Hh(n,i,s,c,o),c.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):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 ee(Number(t))}get time(){return ee(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=te(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&&$h()?(this.animation.timeline=t,Ft):n(this)}}const La={anticipate:Jo,backInOut:Zo,circInOut:ta};function qh(e){return e in La}function Kh(e){typeof e.ease=="string"&&qh(e.ease)&&(e.ease=La[e.ease])}const Ma=10;class Xh extends zh{constructor(t){Kh(t),wa(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 Rs({...r,autoplay:!1}),l=te(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-Ma).value,a.sample(l).value,Ma),a.stop()}}const Da=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(ye.test(e)||e==="0")&&!e.startsWith("url("));function Yh(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 Zh(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=Da(s,t),a=Da(o,t);return!r||!a?!1:Yh(e)||(n==="spring"||Pa(n))&&i}function Bs(e){return Ho(e)&&"offsetHeight"in e}const Jh=new Set(["opacity","clipPath","filter","transform"]),Qh=ls(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function tf(e){var c;const{motionValue:t,name:n,repeatDelay:i,repeatType:s,damping:o,type:r}=e;if(!Bs((c=t==null?void 0:t.owner)==null?void 0:c.current))return!1;const{onUpdate:a,transformTemplate:l}=t.owner.getProps();return Qh()&&n&&Jh.has(n)&&(n!=="transform"||!l)&&!a&&!i&&s!=="mirror"&&o!==0&&r!=="inertia"}const ef=40;class nf extends Es{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 w,b;this._animation&&(this._animation.stop(),(w=this.stopTimeline)==null||w.call(this)),(b=this.keyframeResolver)==null||b.cancel()},this.createdAt=Lt.now();const m={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)||Ns;this.keyframeResolver=new g(a,(w,b,y)=>this.onKeyframesResolved(w,b,m,!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(),Zh(t,o,r,a)||((he.instantAnimations||!l)&&(d==null||d(As(t,i,n))),t[0]=t[t.length-1],i.duration=0,i.repeat=0);const m={startTime:s?this.resolvedAt?this.resolvedAt-this.createdAt>ef?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...i,keyframes:t},g=!c&&tf(m)?new Xh({...m,element:m.motionValue.owner.current}):new Rs(m);g.finished.then(()=>this.notifyFinished()).catch(Ft),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(),Bh()),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 sf=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function rf(e){const t=sf.exec(e);if(!t)return[,];const[,n,i,s]=t;return[`--${n??i}`,s]}function Oa(e,t,n=1){const[i,s]=rf(e);if(!i)return;const o=window.getComputedStyle(t).getPropertyValue(i);if(o){const r=o.trim();return Go(r)?parseFloat(r):r}return ps(s)?Oa(s,t,n+1):s}function Fs(e,t){return(e==null?void 0:e[t])??(e==null?void 0:e.default)??e}const Va=new Set(["width","height","top","left","right","bottom",...ze]),of={test:e=>e==="auto",parse:e=>e},Na=e=>t=>t.test(e),Ba=[He,U,ne,_e,Yd,Xd,of],Fa=e=>Ba.find(Na(e));function af(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||Wo(e):!0}const lf=new Set(["brightness","contrast","saturate","opacity"]);function cf(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[i]=n.match(ms)||[];if(!i)return e;const s=n.replace(i,"");let o=lf.has(t)?1:0;return i!==n&&(o*=100),t+"("+o+s+")"}const uf=/\b([a-z-]*)\(.*?\)/gu,js={...ye,getAnimatableNone:e=>{const t=e.match(uf);return t?t.map(cf).join(" "):e}},ja={...He,transform:Math.round},$s={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:_e,rotateX:_e,rotateY:_e,rotateZ:_e,scale:oi,scaleX:oi,scaleY:oi,scaleZ:oi,skew:_e,skewX:_e,skewY:_e,distance:U,translateX:U,translateY:U,translateZ:U,x:U,y:U,z:U,perspective:U,transformPerspective:U,opacity:yn,originX:la,originY:la,originZ:U},zIndex:ja,fillOpacity:yn,strokeOpacity:yn,numOctaves:ja},df={...$s,color:yt,backgroundColor:yt,outlineColor:yt,fill:yt,stroke:yt,borderColor:yt,borderTopColor:yt,borderRightColor:yt,borderBottomColor:yt,borderLeftColor:yt,filter:js,WebkitFilter:js},$a=e=>df[e];function Ua(e,t){let n=$a(e);return n!==js&&(n=ye),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const hf=new Set(["auto","none","0"]);function ff(e,t,n){let i=0,s;for(;i<e.length&&!s;){const o=e[i];typeof o=="string"&&!hf.has(o)&&xn(o).values.length&&(s=e[i]),i++}if(s&&n)for(const o of t)e[o]=Ua(n,s)}class pf extends Ns{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(),ps(c))){const d=Oa(c,n.current);d!==void 0&&(t[l]=d),l===t.length-1&&(this.finalKeyframe=c)}}if(this.resolveNoneKeyframes(),!Va.has(i)||t.length!==2)return;const[s,o]=t,r=Fa(s),a=Fa(o);if(r!==a)if(Ta(r)&&Ta(a))for(let l=0;l<t.length;l++){const c=t[l];typeof c=="string"&&(t[l]=parseFloat(c))}else Pe[i]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,i=[];for(let s=0;s<t.length;s++)(t[s]===null||af(t[s]))&&i.push(s);i.length&&ff(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=Pe[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]=Pe[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 mf(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 Ga=(e,t)=>t&&typeof e=="number"?t.transform(e):e,Ha=30,gf=e=>!isNaN(parseFloat(e));class vf{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=gf(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 cs);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>Ha)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Ha);return zo(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 Ke(e,t){return new vf(e,t)}const{schedule:Us}=ra(queueMicrotask,!1),Kt={x:!1,y:!1};function Wa(){return Kt.x||Kt.y}function _f(e){return e==="x"||e==="y"?Kt[e]?null:(Kt[e]=!0,()=>{Kt[e]=!1}):Kt.x||Kt.y?null:(Kt.x=Kt.y=!0,()=>{Kt.x=Kt.y=!1})}function za(e,t){const n=mf(e),i=new AbortController,s={passive:!0,...t,signal:i.signal};return[n,s,()=>i.abort()]}function qa(e){return!(e.pointerType==="touch"||Wa())}function yf(e,t,n={}){const[i,s,o]=za(e,n),r=a=>{if(!qa(a))return;const{target:l}=a,c=t(l,a);if(typeof c!="function"||!l)return;const d=u=>{qa(u)&&(c(u),l.removeEventListener("pointerleave",d))};l.addEventListener("pointerleave",d,s)};return i.forEach(a=>{a.addEventListener("pointerenter",r,s)}),o}const Ka=(e,t)=>t?e===t?!0:Ka(e,t.parentElement):!1,Gs=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,bf=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function wf(e){return bf.has(e.tagName)||e.tabIndex!==-1}const ui=new WeakSet;function Xa(e){return t=>{t.key==="Enter"&&e(t)}}function Hs(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const xf=(e,t)=>{const n=e.currentTarget;if(!n)return;const i=Xa(()=>{if(ui.has(n))return;Hs(n,"down");const s=Xa(()=>{Hs(n,"up")}),o=()=>Hs(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 Ya(e){return Gs(e)&&!Wa()}function Sf(e,t,n={}){const[i,s,o]=za(e,n),r=a=>{const l=a.currentTarget;if(!Ya(a))return;ui.add(l);const c=t(l,a),d=(g,_)=>{window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",m),ui.has(l)&&ui.delete(l),Ya(g)&&typeof c=="function"&&c(g,{success:_})},u=g=>{d(g,l===window||l===document||n.useGlobalTarget||Ka(l,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",c=>xf(c,s)),!wf(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function Za(e){return Ho(e)&&"ownerSVGElement"in e}function Cf(e){return Za(e)&&e.tagName==="svg"}const Tt=e=>!!(e&&e.getVelocity),Tf=[...Ba,yt,ye],kf=e=>Tf.find(Na(e)),Tn=Ee({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class Af extends Wt{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.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 Ef({children:e,isPresent:t,anchorX:n,root:i}){const s=Qi(),o=qt(null),r=qt({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=wt(Tn);return ko(()=>{const{width:l,height:c,top:d,left:u,right:m}=r.current;if(t||!o.current||!l||!c)return;const g=n==="left"?`left: ${u}`:`right: ${m}`;o.current.dataset.motionPopId=s;const _=document.createElement("style");a&&(_.nonce=a);const w=i??document.head;return w.appendChild(_),_.sheet&&_.sheet.insertRule(`
|
|
1
|
+
(function(){"use strict";var hn,q,qr,Ee,Kr,Xr,Yr,Zr,Ui,Gi,Hi,Jr,fn={},Qr=[],nd=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,pn=Array.isArray;function Zt(e,t){for(var n in t)e[n]=t[n];return e}function Wi(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Bt(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?hn.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 mn(e,r,i,s,null)}function mn(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??++qr,__i:-1,__u:0};return s==null&&q.vnode!=null&&q.vnode(o),o}function ue(e){return e.children}function zt(e,t){this.props=e,this.context=t}function Ue(e,t){if(t==null)return e.__?Ue(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"?Ue(e):null}function to(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 to(e)}}function zi(e){(!e.__d&&(e.__d=!0)&&Ee.push(e)&&!Jn.__r++||Kr!=q.debounceRendering)&&((Kr=q.debounceRendering)||Xr)(Jn)}function Jn(){for(var e,t,n,i,s,o,r,a=1;Ee.length;)Ee.length>a&&Ee.sort(Yr),e=Ee.shift(),a=Ee.length,e.__d&&(n=void 0,s=(i=(t=e).__v).__e,o=[],r=[],t.__P&&((n=Zt({},i)).__v=i.__v+1,q.vnode&&q.vnode(n),qi(t.__P,n,i,t.__n,t.__P.namespaceURI,32&i.__u?[s]:null,o,s??Ue(i),!!(32&i.__u),r),n.__v=i.__v,n.__.__k[n.__i]=n,ro(o,n,r),n.__e!=s&&to(n)));Jn.__r=0}function eo(e,t,n,i,s,o,r,a,l,c,d){var u,m,g,_,w,b,y=i&&i.__k||Qr,S=t.length;for(l=id(n,t,y,l,S),u=0;u<S;u++)(g=n.__k[u])!=null&&(m=g.__i==-1?fn:y[g.__i]||fn,g.__i=u,b=qi(e,g,m,s,o,r,a,l,c,d),_=g.__e,g.ref&&m.ref!=g.ref&&(m.ref&&Ki(m.ref,null,g),d.push(g.ref,g.__c||_,g)),w==null&&_!=null&&(w=_),4&g.__u||m.__k===g.__k?l=no(g,l,e):typeof g.type=="function"&&b!==void 0?l=b:_&&(l=_.nextSibling),g.__u&=-7);return n.__e=w,l}function id(e,t,n,i,s){var o,r,a,l,c,d=n.length,u=d,m=0;for(e.__k=new Array(s),o=0;o<s;o++)(r=t[o])!=null&&typeof r!="boolean"&&typeof r!="function"?(l=o+m,(r=e.__k[o]=typeof r=="string"||typeof r=="number"||typeof r=="bigint"||r.constructor==String?mn(null,r,null,null,null):pn(r)?mn(ue,{children:r},null,null,null):r.constructor==null&&r.__b>0?mn(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=sd(r,n,l,u))!=-1&&(u--,(a=n[c])&&(a.__u|=2)),a==null||a.__v==null?(c==-1&&(s>d?m--:s<d&&m++),typeof r.type!="function"&&(r.__u|=4)):c!=l&&(c==l-1?m--:c==l+1?m++:(c>l?m--:m++,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=Ue(a)),ao(a,a));return i}function no(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=no(i[s],t,n));return t}e.__e!=t&&(t&&e.type&&!n.contains(t)&&(t=Ue(e)),n.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Jt(e,t){return t=t||[],e==null||typeof e=="boolean"||(pn(e)?e.some(function(n){Jt(n,t)}):t.push(e)),t}function sd(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 io(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||nd.test(t)?n:n+"px"}function Qn(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||io(e.style,t,"");if(n)for(t in n)i&&n[t]==i[t]||io(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(Zr,"$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=Ui,e.addEventListener(t,o?Hi:Gi,o)):e.removeEventListener(t,o?Hi:Gi,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 so(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Ui++;else if(t.t<n.u)return;return n(q.event?q.event(t):t)}}}function qi(e,t,n,i,s,o,r,a,l,c){var d,u,m,g,_,w,b,y,S,C,I,M,D,x,T,f,p,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],I=d?C?C.props.value:d.__:i,n.__c?b=(u=t.__c=n.__c).__=u.__E:(S?t.__c=u=new h(y,I):(t.__c=u=new zt(y,I),u.constructor=h,u.render=od),C&&C.sub(u),u.props=y,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=Zt({},u.__s)),Zt(u.__s,h.getDerivedStateFromProps(y,u.__s))),g=u.props,_=u.state,u.__v=t,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&&y!==g&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(y,I),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(y,u.__s,I)===!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)}),M=0;M<u._sb.length;M++)u.__h.push(u._sb[M]);u._sb=[],u.__h.length&&r.push(u);break t}u.componentWillUpdate!=null&&u.componentWillUpdate(y,u.__s,I),S&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(g,_,w)})}if(u.context=I,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),T=0;T<u._sb.length;T++)u.__h.push(u._sb[T]);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=Zt(Zt({},i),u.getChildContext())),S&&!m&&u.getSnapshotBeforeUpdate!=null&&(w=u.getSnapshotBeforeUpdate(g,_)),f=d,d!=null&&d.type===ue&&d.key==null&&(f=oo(d.props.children)),a=eo(e,pn(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),b&&(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(p=o.length;p--;)Wi(o[p]);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=rd(n.__e,t,n,i,s,o,r,l,c);return(d=q.diffed)&&d(t),128&t.__u?void 0:a}function ro(e,t,n){for(var i=0;i<n.length;i++)Ki(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 oo(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:pn(e)?e.map(oo):Zt({},e)}function rd(e,t,n,i,s,o,r,a,l){var c,d,u,m,g,_,w,b=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)b===y||a&&e.data==y||(e.data=y);else{if(o=o&&hn.call(e.childNodes),b=n.props||fn,!a&&o!=null)for(b={},c=0;c<e.attributes.length;c++)b[(g=e.attributes[c]).name]=g.value;for(c in b)if(g=b[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;Qn(e,c,null,g,s)}}for(c in y)g=y[c],c=="children"?m=g:c=="dangerouslySetInnerHTML"?d=g:c=="value"?_=g:c=="checked"?w=g:a&&typeof g!="function"||b[c]===g||Qn(e,c,g,b[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=""),eo(t.type=="template"?e.content:e,pn(m)?m:[m],t,n,i,S=="foreignObject"?"http://www.w3.org/1999/xhtml":s,o,r,o?o[0]:n.__k&&Ue(n,0),a,l),o!=null)for(c=o.length;c--;)Wi(o[c]);a||(c="value",S=="progress"&&_==null?e.removeAttribute("value"):_!=null&&(_!==e[c]||S=="progress"&&!_||S=="option"&&_!=b[c])&&Qn(e,c,_,b[c],s),c="checked",w!=null&&w!=e[c]&&Qn(e,c,w,b[c],s))}return e}function Ki(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 ao(e,t,n){var i,s;if(q.unmount&&q.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||Ki(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]&&ao(i[s],t,n||typeof e.type!="function");n||Wi(e.__e),e.__c=e.__=e.__e=void 0}function od(e,t,n){return this.constructor(e,n)}function ti(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=[],qi(t,e=(!i&&n||t).__k=Bt(ue,null,[e]),s||fn,fn,t.namespaceURI,!i&&n?[n]:s?null:t.firstChild?hn.call(t.childNodes):null,o,!i&&n?n:s?s.__e:t.firstChild,i,r),ro(o,e,r)}function lo(e,t){ti(e,t,lo)}function Xi(e,t,n){var i,s,o,r,a=Zt({},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?hn.call(arguments,2):n),mn(e.type,a,i||e.key,s||e.ref,null)}function Ae(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,zi(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"+Jr++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,i){return n.children(i)}).contextType=t,t}hn=Qr.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}},qr=0,zt.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Zt({},this.state),typeof e=="function"&&(e=e(Zt({},n),this.props)),e&&Zt(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),zi(this))},zt.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),zi(this))},zt.prototype.render=ue,Ee=[],Xr=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Yr=function(e,t){return e.__v.__b-t.__v.__b},Jn.__r=0,Zr=/(PointerCapture)$|Capture$/i,Ui=0,Gi=so(!1),Hi=so(!0),Jr=0;var ad=0;function L(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:--ad,__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 Yi(){return(Yi=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 ld=["context","children"];function cd(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,ld);return Xi(t,n)}function ud(){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=Bt(cd,Yi({},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[co(a[r].name)]=a[r].value);for(r=l.length;r--;){var c=t(l[r],null),d=l[r].slot;d?o[d]=Bt(uo,{name:d},c):s[r]=c}var u=i?Bt(uo,null,s):s;return Bt(i||n.nodeName.toLowerCase(),o,u)}(this,this._vdomComponent)),(this.hasAttribute("hydrate")?lo:ti)(this._vdom,this._root)}function co(e){return e.replace(/-(\w)/g,function(t,n){return n?n.toUpperCase():""})}function dd(e,t,n){if(this._vdom){var i={};i[e]=n=n??void 0,i[co(e)]=n,this._vdom=Xi(this._vdom,i),ti(this._vdom,this._root)}}function hd(){ti(this._vdom=null,this._root)}function uo(e,t){var n=this;return Bt("slot",Yi({},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 fd(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=ud,s.prototype.attributeChangedCallback=dd,s.prototype.disconnectedCallback=hd,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 me,at,Zi,ho,gn=0,fo=[],pt=q,po=pt.__b,mo=pt.__r,go=pt.diffed,vo=pt.__c,_o=pt.unmount,yo=pt.__;function Ge(e,t){pt.__h&&pt.__h(at,e,gn||t),gn=0;var n=at.__H||(at.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function ge(e){return gn=1,bo(So,e)}function bo(e,t,n){var i=Ge(me++,2);if(i.t=e,!i.__c&&(i.__=[n?n(t):So(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(m){return!!m.__c});if(d.every(function(m){return!m.__N}))return!o||o.call(this,a,l,c);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,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 qt(e,t){var n=Ge(me++,3);!pt.__s&&es(n.__H,t)&&(n.__=e,n.u=t,at.__H.__h.push(n))}function wo(e,t){var n=Ge(me++,4);!pt.__s&&es(n.__H,t)&&(n.__=e,n.u=t,at.__h.push(n))}function Ft(e){return gn=5,Qt(function(){return{current:e}},[])}function Qt(e,t){var n=Ge(me++,7);return es(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ji(e,t){return gn=8,Qt(function(){return e},t)}function wt(e){var t=at.context[e.__c],n=Ge(me++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(at)),t.props.value):e.__}function pd(e,t){pt.useDebugValue&&pt.useDebugValue(t?t(e):e)}function Qi(){var e=Ge(me++,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 md(){for(var e;e=fo.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(ei),e.__H.__h.forEach(ts),e.__H.__h=[]}catch(t){e.__H.__h=[],pt.__e(t,e.__v)}}pt.__b=function(e){at=null,po&&po(e)},pt.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),yo&&yo(e,t)},pt.__r=function(e){mo&&mo(e),me=0;var t=(at=e.__c).__H;t&&(Zi===at?(t.__h=[],at.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(ei),t.__h.forEach(ts),t.__h=[],me=0)),Zi=at},pt.diffed=function(e){go&&go(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(fo.push(t)!==1&&ho===pt.requestAnimationFrame||((ho=pt.requestAnimationFrame)||gd)(md)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Zi=at=null},pt.__c=function(e,t){t.some(function(n){try{n.__h.forEach(ei),n.__h=n.__h.filter(function(i){return!i.__||ts(i)})}catch(i){t.some(function(s){s.__h&&(s.__h=[])}),t=[],pt.__e(i,n.__v)}}),vo&&vo(e,t)},pt.unmount=function(e){_o&&_o(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(i){try{ei(i)}catch(s){t=s}}),n.__H=void 0,t&&pt.__e(t,n.__v))};var xo=typeof requestAnimationFrame=="function";function gd(e){var t,n=function(){clearTimeout(i),xo&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(n,35);xo&&(t=requestAnimationFrame(n))}function ei(e){var t=at,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),at=t}function ts(e){var t=at;e.__c=e.__(),at=t}function es(e,t){return!e||e.length!==t.length||t.some(function(n,i){return n!==e[i]})}function So(e,t){return typeof t=="function"?t(e):t}function Co(e,t){for(var n in t)e[n]=t[n];return e}function To(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 ko=wo;function Eo(e,t){this.props=e,this.context=t}(Eo.prototype=new zt).isPureReactComponent=!0,Eo.prototype.shouldComponentUpdate=function(e,t){return To(this.props,e)||To(this.state,t)};var Ao=q.__b;q.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Ao&&Ao(e)};var vd=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function _d(e){function t(n){var i=Co({},n);return delete i.ref,e(i,n.ref||null)}return t.$$typeof=vd,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var Ro=function(e,t){return e==null?null:Jt(Jt(e).map(t))},yd={map:Ro,forEach:Ro,count:function(e){return e?Jt(e).length:0},only:function(e){var t=Jt(e);if(t.length!==1)throw"Children.only";return t[0]},toArray:Jt},bd=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)}bd(e,t,n,i)};var Io=q.unmount;function Po(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=Co({},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 Po(i,t,n)})),e}function Mo(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(i){return Mo(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 ns(){this.__u=0,this.o=null,this.__b=null}function Lo(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function ni(){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),Io&&Io(e)},(ns.prototype=new zt).__c=function(e,t){var n=t.__c,i=this;i.o==null&&(i.o=[]),i.o.push(n);var s=Lo(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]=Mo(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)},ns.prototype.componentWillUnmount=function(){this.o=[]},ns.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]=Po(this.__b,n,i.__O=i.__P)}this.__b=null}var s=t.__a&&Bt(ue,null,e.fallback);return s&&(s.__u&=-33),[Bt(ue,null,t.__a?null:e.children),s]};var Do=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]}};(ni.prototype=new zt).__a=function(e){var t=this,n=Lo(t.__v),i=t.l.get(e);return i[0]++,function(s){var o=function(){t.props.revealOrder?(i.push(s),Do(t,e,i)):s()};n?n(o):o()}},ni.prototype.render=function(e){this.i=null,this.l=new Map;var t=Jt(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},ni.prototype.componentDidUpdate=ni.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Do(e,n,t)})};var Oo=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,wd=/^(?: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]/,xd=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Sd=/[A-Z0-9]/g,Cd=typeof document<"u",Td=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};zt.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(zt.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Vo=q.event;function kd(){}function Ed(){return this.cancelBubble}function Ad(){return this.defaultPrevented}q.event=function(e){return Vo&&(e=Vo(e)),e.persist=kd,e.isPropagationStopped=Ed,e.isDefaultPrevented=Ad,e.nativeEvent=e};var Rd={enumerable:!1,configurable:!0,get:function(){return this.class}},No=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||Cd&&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"||Td(n.type)?l==="onfocus"?r="onfocusin":l==="onblur"?r="onfocusout":xd.test(r)&&(r=l):l=r="oninput":o&&wd.test(r)?r=r.replace(Sd,"-$&").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=Jt(n.children).forEach(function(c){c.props.selected=s.value.indexOf(c.props.value)!=-1})),i=="select"&&s.defaultValue!=null&&(s.value=Jt(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",Rd)):(n.className&&!n.class||n.class&&n.className)&&(s.class=s.className=n.className),t.props=s}(e),e.$$typeof=Oo,No&&No(e)};var Bo=q.__r;q.__r=function(e){Bo&&Bo(e),e.__c};var Fo=q.diffed;q.diffed=function(e){Fo&&Fo(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 jo(e){return!!e&&e.$$typeof===Oo}function Id(e){return jo(e)?Xi.apply(null,arguments):e}var $o={};const is=Ae({});function ii(e){const t=Ft(null);return t.current===null&&(t.current=e()),t.current}const ss=typeof window<"u",Uo=ss?wo:qt,si=Ae(null);function rs(e,t){e.indexOf(t)===-1&&e.push(t)}function os(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const de=(e,t,n)=>n>t?t:n<e?e:n;let as=()=>{};const he={},Go=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function Ho(e){return typeof e=="object"&&e!==null}const Wo=e=>/^0[^.\s]+$/u.test(e);function ls(e){let t;return()=>(t===void 0&&(t=e()),t)}const jt=e=>e,Pd=(e,t)=>n=>t(e(n)),vn=(...e)=>e.reduce(Pd),_n=(e,t,n)=>{const i=t-e;return i===0?1:(n-e)/i};class cs{constructor(){this.subscriptions=[]}add(t){return rs(this.subscriptions,t),()=>os(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 te=e=>e*1e3,ee=e=>e/1e3;function zo(e,t){return t?e*(1e3/t):0}const qo=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Md=1e-7,Ld=12;function Dd(e,t,n,i,s){let o,r,a=0;do r=t+(n-t)/2,o=qo(r,i,s)-e,o>0?n=r:t=r;while(Math.abs(o)>Md&&++a<Ld);return r}function yn(e,t,n,i){if(e===t&&n===i)return jt;const s=o=>Dd(o,0,1,e,n);return o=>o===0||o===1?o:qo(s(o),t,i)}const Ko=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Xo=e=>t=>1-e(1-t),Yo=yn(.33,1.53,.69,.99),us=Xo(Yo),Zo=Ko(us),Jo=e=>(e*=2)<1?.5*us(e):.5*(2-Math.pow(2,-10*(e-1))),ds=e=>1-Math.sin(Math.acos(e)),Qo=Xo(ds),ta=Ko(ds),Od=yn(.42,0,1,1),Vd=yn(0,0,.58,1),ea=yn(.42,0,.58,1),Nd=e=>Array.isArray(e)&&typeof e[0]!="number",na=e=>Array.isArray(e)&&typeof e[0]=="number",Bd={linear:jt,easeIn:Od,easeInOut:ea,easeOut:Vd,circIn:ds,circInOut:ta,circOut:Qo,backIn:us,backInOut:Zo,backOut:Yo,anticipate:Jo},Fd=e=>typeof e=="string",ia=e=>{if(na(e)){as(e.length===4);const[t,n,i,s]=e;return yn(t,n,i,s)}else if(Fd(e))return Bd[e];return e},ri=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],sa={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,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(c),t&&sa.value&&sa.value.frameloop[t].push(l),l=0,n.clear(),s=!1,o&&(o=!1,d.process(u))}};return d}const $d=40;function ra(e,t){let n=!1,i=!0;const s={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,r=ri.reduce((C,I)=>(C[I]=jd(o,t?I:void 0),C),{}),{setup:a,read:l,resolveKeyframes:c,preUpdate:d,update:u,preRender:m,render:g,postRender:_}=r,w=()=>{const C=he.useManualTiming?s.timestamp:performance.now();n=!1,he.useManualTiming||(s.delta=i?1e3/60:Math.max(Math.min(C-s.timestamp,$d),1)),s.timestamp=C,s.isProcessing=!0,a.process(s),l.process(s),c.process(s),d.process(s),u.process(s),m.process(s),g.process(s),_.process(s),s.isProcessing=!1,n&&t&&(i=!1,e(w))},b=()=>{n=!0,i=!0,s.isProcessing||e(w)};return{schedule:ri.reduce((C,I)=>{const M=r[I];return C[I]=(D,x=!1,T=!1)=>(n||b(),M.schedule(D,x,T)),C},{}),cancel:C=>{for(let I=0;I<ri.length;I++)r[ri[I]].cancel(C)},state:s,steps:r}}const{schedule:ut,cancel:ve,state:St,steps:hs}=ra(typeof requestAnimationFrame<"u"?requestAnimationFrame:jt,!0);let oi;function Ud(){oi=void 0}const Mt={now:()=>(oi===void 0&&Mt.set(St.isProcessing||he.useManualTiming?St.timestamp:performance.now()),oi),set:e=>{oi=e,queueMicrotask(Ud)}},oa=e=>t=>typeof t=="string"&&t.startsWith(e),fs=oa("--"),Gd=oa("var(--"),ps=e=>Gd(e)?Hd.test(e.split("/*")[0].trim()):!1,Hd=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,He={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},bn={...He,transform:e=>de(0,1,e)},ai={...He,default:1},wn=e=>Math.round(e*1e5)/1e5,ms=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Wd(e){return e==null}const zd=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,gs=(e,t)=>n=>!!(typeof n=="string"&&zd.test(n)&&n.startsWith(e)||t&&!Wd(n)&&Object.prototype.hasOwnProperty.call(n,t)),aa=(e,t,n)=>i=>{if(typeof i!="string")return i;const[s,o,r,a]=i.match(ms);return{[e]:parseFloat(s),[t]:parseFloat(o),[n]:parseFloat(r),alpha:a!==void 0?parseFloat(a):1}},qd=e=>de(0,255,e),vs={...He,transform:e=>Math.round(qd(e))},Re={test:gs("rgb","red"),parse:aa("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:i=1})=>"rgba("+vs.transform(e)+", "+vs.transform(t)+", "+vs.transform(n)+", "+wn(bn.transform(i))+")"};function Kd(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 _s={test:gs("#"),parse:Kd,transform:Re.transform},xn=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),_e=xn("deg"),ne=xn("%"),U=xn("px"),Xd=xn("vh"),Yd=xn("vw"),la={...ne,parse:e=>ne.parse(e)/100,transform:e=>ne.transform(e*100)},We={test:gs("hsl","hue"),parse:aa("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:i=1})=>"hsla("+Math.round(e)+", "+ne.transform(wn(t))+", "+ne.transform(wn(n))+", "+wn(bn.transform(i))+")"},yt={test:e=>Re.test(e)||_s.test(e)||We.test(e),parse:e=>Re.test(e)?Re.parse(e):We.test(e)?We.parse(e):_s.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Re.transform(e):We.transform(e),getAnimatableNone:e=>{const t=yt.parse(e);return t.alpha=0,yt.transform(t)}},Zd=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Jd(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(ms))==null?void 0:t.length)||0)+(((n=e.match(Zd))==null?void 0:n.length)||0)>0}const ca="number",ua="color",Qd="var",th="var(",da="${}",eh=/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 Sn(e){const t=e.toString(),n=[],i={color:[],number:[],var:[]},s=[];let o=0;const a=t.replace(eh,l=>(yt.test(l)?(i.color.push(o),s.push(ua),n.push(yt.parse(l))):l.startsWith(th)?(i.var.push(o),s.push(Qd),n.push(l)):(i.number.push(o),s.push(ca),n.push(parseFloat(l))),++o,da)).split(da);return{values:n,split:a,indexes:i,types:s}}function ha(e){return Sn(e).values}function fa(e){const{split:t,types:n}=Sn(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===ca?o+=wn(s[r]):a===ua?o+=yt.transform(s[r]):o+=s[r]}return o}}const nh=e=>typeof e=="number"?0:yt.test(e)?yt.getAnimatableNone(e):e;function ih(e){const t=ha(e);return fa(e)(t.map(nh))}const ye={test:Jd,parse:ha,createTransformer:fa,getAnimatableNone:ih};function ys(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 sh({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=ys(l,a,e+1/3),o=ys(l,a,e),r=ys(l,a,e-1/3)}return{red:Math.round(s*255),green:Math.round(o*255),blue:Math.round(r*255),alpha:i}}function li(e,t){return n=>n>0?t:e}const mt=(e,t,n)=>e+(t-e)*n,bs=(e,t,n)=>{const i=e*e,s=n*(t*t-i)+i;return s<0?0:Math.sqrt(s)},rh=[_s,Re,We],oh=e=>rh.find(t=>t.test(e));function pa(e){const t=oh(e);if(!t)return!1;let n=t.parse(e);return t===We&&(n=sh(n)),n}const ma=(e,t)=>{const n=pa(e),i=pa(t);if(!n||!i)return li(e,t);const s={...n};return o=>(s.red=bs(n.red,i.red,o),s.green=bs(n.green,i.green,o),s.blue=bs(n.blue,i.blue,o),s.alpha=mt(n.alpha,i.alpha,o),Re.transform(s))},ws=new Set(["none","hidden"]);function ah(e,t){return ws.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function lh(e,t){return n=>mt(e,t,n)}function xs(e){return typeof e=="number"?lh:typeof e=="string"?ps(e)?li:yt.test(e)?ma:dh:Array.isArray(e)?ga:typeof e=="object"?yt.test(e)?ma:ch:li}function ga(e,t){const n=[...e],i=n.length,s=e.map((o,r)=>xs(o)(o,t[r]));return o=>{for(let r=0;r<i;r++)n[r]=s[r](o);return n}}function ch(e,t){const n={...e,...t},i={};for(const s in n)e[s]!==void 0&&t[s]!==void 0&&(i[s]=xs(e[s])(e[s],t[s]));return s=>{for(const o in i)n[o]=i[o](s);return n}}function uh(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 dh=(e,t)=>{const n=ye.createTransformer(t),i=Sn(e),s=Sn(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?ws.has(e)&&!s.values.length||ws.has(t)&&!i.values.length?ah(e,t):vn(ga(uh(i,s),s.values),n):li(e,t)};function va(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?mt(e,t,n):xs(e)(e,t)}const hh=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>ut.update(t,n),stop:()=>ve(t),now:()=>St.isProcessing?St.timestamp:Mt.now()}},_a=(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)})`},ci=2e4;function Ss(e){let t=0;const n=50;let i=e.next(t);for(;!i.done&&t<ci;)t+=n,i=e.next(t);return t>=ci?1/0:t}function fh(e,t=100,n){const i=n({...e,keyframes:[0,t]}),s=Math.min(Ss(i),ci);return{type:"keyframes",ease:o=>i.next(s*o).value/t,duration:ee(s)}}const ph=5;function ya(e,t,n){const i=Math.max(t-ph,0);return zo(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},Cs=.001;function mh({duration:e=gt.duration,bounce:t=gt.bounce,velocity:n=gt.velocity,mass:i=gt.mass}){let s,o,r=1-t;r=de(gt.minDamping,gt.maxDamping,r),e=de(gt.minDuration,gt.maxDuration,ee(e)),r<1?(s=c=>{const d=c*r,u=d*e,m=d-n,g=Ts(c,r),_=Math.exp(-u);return Cs-m/g*_},o=c=>{const u=c*r*e,m=u*n+n,g=Math.pow(r,2)*Math.pow(c,2)*e,_=Math.exp(-u),w=Ts(Math.pow(c,2),r);return(-s(c)+Cs>0?-1:1)*((m-g)*_)/w}):(s=c=>{const d=Math.exp(-c*e),u=(c-n)*e+1;return-Cs+d*u},o=c=>{const d=Math.exp(-c*e),u=(n-c)*(e*e);return d*u});const a=5/e,l=vh(s,o,a);if(e=te(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 gh=12;function vh(e,t,n){let i=n;for(let s=1;s<gh;s++)i=i-e(i)/t(i);return i}function Ts(e,t){return e*Math.sqrt(1-t*t)}const _h=["duration","bounce"],yh=["stiffness","damping","mass"];function ba(e,t){return t.some(n=>e[n]!==void 0)}function bh(e){let t={velocity:gt.velocity,stiffness:gt.stiffness,damping:gt.damping,mass:gt.mass,isResolvedFromDuration:!1,...e};if(!ba(e,yh)&&ba(e,_h))if(e.visualDuration){const n=e.visualDuration,i=2*Math.PI/(n*1.2),s=i*i,o=2*de(.05,1,1-(e.bounce||0))*Math.sqrt(s);t={...t,mass:gt.mass,stiffness:s,damping:o}}else{const n=mh(e);t={...t,...n,mass:gt.mass},t.isResolvedFromDuration=!0}return t}function ui(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:m,isResolvedFromDuration:g}=bh({...n,velocity:-ee(n.velocity||0)}),_=m||0,w=c/(2*Math.sqrt(l*d)),b=r-o,y=ee(Math.sqrt(l/d)),S=Math.abs(b)<5;i||(i=S?gt.restSpeed.granular:gt.restSpeed.default),s||(s=S?gt.restDelta.granular:gt.restDelta.default);let C;if(w<1){const M=Ts(y,w);C=D=>{const x=Math.exp(-w*y*D);return r-x*((_+w*y*b)/M*Math.sin(M*D)+b*Math.cos(M*D))}}else if(w===1)C=M=>r-Math.exp(-y*M)*(b+(_+y*b)*M);else{const M=y*Math.sqrt(w*w-1);C=D=>{const x=Math.exp(-w*y*D),T=Math.min(M*D,300);return r-x*((_+w*y*b)*Math.sinh(T)+M*b*Math.cosh(T))/M}}const I={calculatedDuration:g&&u||null,next:M=>{const D=C(M);if(g)a.done=M>=u;else{let x=M===0?_:0;w<1&&(x=M===0?te(_):ya(C,M,D));const T=Math.abs(x)<=i,f=Math.abs(r-D)<=s;a.done=T&&f}return a.value=a.done?r:D,a},toString:()=>{const M=Math.min(Ss(I),ci),D=_a(x=>I.next(M*x).value,M,30);return M+"ms "+D},toTransition:()=>{}};return I}ui.applyToOptions=e=>{const t=fh(e,100,ui);return e.ease=t.ease,e.duration=te(t.duration),e.type="keyframes",e};function ks({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],m={done:!1,value:u},g=T=>a!==void 0&&T<a||l!==void 0&&T>l,_=T=>a===void 0?l:l===void 0||Math.abs(a-T)<Math.abs(l-T)?a:l;let w=n*t;const b=u+w,y=r===void 0?b:r(b);y!==b&&(w=y-u);const S=T=>-w*Math.exp(-T/i),C=T=>y+S(T),I=T=>{const f=S(T),p=C(T);m.done=Math.abs(f)<=c,m.value=m.done?y:p};let M,D;const x=T=>{g(m.value)&&(M=T,D=ui({keyframes:[m.value,_(m.value)],velocity:ya(C,T,m.value),damping:s,stiffness:o,restDelta:c,restSpeed:d}))};return x(0),{calculatedDuration:null,next:T=>{let f=!1;return!D&&M===void 0&&(f=!0,I(T),x(T)),M!==void 0&&T>=M?D.next(T-M):(!f&&I(T),m)}}}function wh(e,t,n){const i=[],s=n||he.mix||va,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]||jt:t;a=vn(l,a)}i.push(a)}return i}function xh(e,t,{clamp:n=!0,ease:i,mixer:s}={}){const o=e.length;if(as(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=wh(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 m=_n(e[u],e[u+1],d);return a[u](m)};return n?d=>c(de(e[0],e[o-1],d)):c}function Sh(e,t){const n=e[e.length-1];for(let i=1;i<=t;i++){const s=_n(0,t,i);e.push(mt(n,1,s))}}function Ch(e){const t=[0];return Sh(t,e.length-1),t}function Th(e,t){return e.map(n=>n*t)}function kh(e,t){return e.map(()=>t||ea).splice(0,e.length-1)}function Cn({duration:e=300,keyframes:t,times:n,ease:i="easeInOut"}){const s=Nd(i)?i.map(ia):ia(i),o={done:!1,value:t[0]},r=Th(n&&n.length===t.length?n:Ch(t),e),a=xh(r,t,{ease:Array.isArray(s)?s:kh(t,s)});return{calculatedDuration:e,next:l=>(o.value=a(l),o.done=l>=e,o)}}const Eh=e=>e!==null;function Es(e,{repeat:t,repeatType:n="loop"},i,s=1){const o=e.filter(Eh),a=s<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!a||i===void 0?o[a]:i}const Ah={decay:ks,inertia:ks,tween:Cn,keyframes:Cn,spring:ui};function wa(e){typeof e.type=="string"&&(e.type=Ah[e.type])}class As{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 Rh=e=>e/100;class Rs extends As{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!==Mt.now()&&this.tick(Mt.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;wa(t);const{type:n=Cn,repeat:i=0,repeatDelay:s=0,repeatType:o,velocity:r=0}=t;let{keyframes:a}=t;const l=n||Cn;l!==Cn&&typeof a[0]!="number"&&(this.mixKeyframes=vn(Rh,va(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=Ss(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:m,repeatDelay:g,type:_,onUpdate:w,finalKeyframe:b}=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,I=i;if(u){const T=Math.min(this.currentTime,s)/a;let f=Math.floor(T),p=T%1;!p&&T>=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)),C=de(0,1,p)*a}const M=S?{done:!1,value:d[0]}:I.next(C);o&&(M.value=o(M.value));let{done:D}=M;!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&&_!==ks&&(M.value=Es(d,this.options,b,this.speed)),w&&w(M.value),x&&this.finish(),M}then(t,n){return this.finished.then(t,n)}get duration(){return ee(this.calculatedDuration)}get time(){return ee(this.currentTime)}set time(t){var n;t=te(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(Mt.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=ee(this.currentTime))}play(){var s,o;if(this.isStopped)return;const{driver:t=hh,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(Mt.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 Ih(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Ie=e=>e*180/Math.PI,Is=e=>{const t=Ie(Math.atan2(e[1],e[0]));return Ps(t)},Ph={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Is,rotateZ:Is,skewX:e=>Ie(Math.atan(e[1])),skewY:e=>Ie(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Ps=e=>(e=e%360,e<0&&(e+=360),e),xa=Is,Sa=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Ca=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Mh={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Sa,scaleY:Ca,scale:e=>(Sa(e)+Ca(e))/2,rotateX:e=>Ps(Ie(Math.atan2(e[6],e[5]))),rotateY:e=>Ps(Ie(Math.atan2(-e[2],e[0]))),rotateZ:xa,rotate:xa,skewX:e=>Ie(Math.atan(e[4])),skewY:e=>Ie(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Ms(e){return e.includes("scale")?1:0}function Ls(e,t){if(!e||e==="none")return Ms(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let i,s;if(n)i=Mh,s=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);i=Ph,s=a}if(!s)return Ms(t);const o=i[t],r=s[1].split(",").map(Dh);return typeof o=="function"?o(r):r[o]}const Lh=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Ls(n,t)};function Dh(e){return parseFloat(e.trim())}const ze=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],qe=new Set(ze),Ta=e=>e===He||e===U,Oh=new Set(["x","y","z"]),Vh=ze.filter(e=>!Oh.has(e));function Nh(e){const t=[];return Vh.forEach(n=>{const i=e.getValue(n);i!==void 0&&(t.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),t}const Pe={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})=>Ls(t,"x"),y:(e,{transform:t})=>Ls(t,"y")};Pe.translateX=Pe.x,Pe.translateY=Pe.y;const Me=new Set;let Ds=!1,Os=!1,Vs=!1;function ka(){if(Os){const e=Array.from(Me).filter(i=>i.needsMeasurement),t=new Set(e.map(i=>i.element)),n=new Map;t.forEach(i=>{const s=Nh(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)})}Os=!1,Ds=!1,Me.forEach(e=>e.complete(Vs)),Me.clear()}function Ea(){Me.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Os=!0)})}function Bh(){Vs=!0,Ea(),ka(),Vs=!1}class Ns{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?(Me.add(this),Ds||(Ds=!0,ut.read(Ea),ut.resolveKeyframes(ka))):(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])}Ih(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Me.delete(this)}cancel(){this.state==="scheduled"&&(Me.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Fh=e=>e.startsWith("--");function jh(e,t,n){Fh(t)?e.style.setProperty(t,n):e.style[t]=n}const $h=ls(()=>window.ScrollTimeline!==void 0),Uh={};function Gh(e,t){const n=ls(e);return()=>Uh[t]??n()}const Aa=Gh(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Tn=([e,t,n,i])=>`cubic-bezier(${e}, ${t}, ${n}, ${i})`,Ra={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Tn([0,.65,.55,1]),circOut:Tn([.55,0,1,.45]),backIn:Tn([.31,.01,.66,-.59]),backOut:Tn([.33,1.53,.69,.99])};function Ia(e,t){if(e)return typeof e=="function"?Aa()?_a(e,t):"ease-out":na(e)?Tn(e):Array.isArray(e)?e.map(n=>Ia(n,t)||Ra.easeOut):Ra[e]}function Hh(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=Ia(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 c&&(m.pseudoElement=c),e.animate(d,m)}function Pa(e){return typeof e=="function"&&"applyToOptions"in e}function Wh({type:e,...t}){return Pa(e)&&Aa()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class zh extends As{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,as(typeof t.type!="string");const c=Wh(t);this.animation=Hh(n,i,s,c,o),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const d=Es(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 ee(Number(t))}get time(){return ee(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=te(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&&$h()?(this.animation.timeline=t,jt):n(this)}}const Ma={anticipate:Jo,backInOut:Zo,circInOut:ta};function qh(e){return e in Ma}function Kh(e){typeof e.ease=="string"&&qh(e.ease)&&(e.ease=Ma[e.ease])}const La=10;class Xh extends zh{constructor(t){Kh(t),wa(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 Rs({...r,autoplay:!1}),l=te(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-La).value,a.sample(l).value,La),a.stop()}}const Da=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(ye.test(e)||e==="0")&&!e.startsWith("url("));function Yh(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 Zh(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=Da(s,t),a=Da(o,t);return!r||!a?!1:Yh(e)||(n==="spring"||Pa(n))&&i}function Bs(e){return Ho(e)&&"offsetHeight"in e}const Jh=new Set(["opacity","clipPath","filter","transform"]),Qh=ls(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function tf(e){var c;const{motionValue:t,name:n,repeatDelay:i,repeatType:s,damping:o,type:r}=e;if(!Bs((c=t==null?void 0:t.owner)==null?void 0:c.current))return!1;const{onUpdate:a,transformTemplate:l}=t.owner.getProps();return Qh()&&n&&Jh.has(n)&&(n!=="transform"||!l)&&!a&&!i&&s!=="mirror"&&o!==0&&r!=="inertia"}const ef=40;class nf extends As{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 w,b;this._animation&&(this._animation.stop(),(w=this.stopTimeline)==null||w.call(this)),(b=this.keyframeResolver)==null||b.cancel()},this.createdAt=Mt.now();const m={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)||Ns;this.keyframeResolver=new g(a,(w,b,y)=>this.onKeyframesResolved(w,b,m,!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=Mt.now(),Zh(t,o,r,a)||((he.instantAnimations||!l)&&(d==null||d(Es(t,i,n))),t[0]=t[t.length-1],i.duration=0,i.repeat=0);const m={startTime:s?this.resolvedAt?this.resolvedAt-this.createdAt>ef?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...i,keyframes:t},g=!c&&tf(m)?new Xh({...m,element:m.motionValue.owner.current}):new Rs(m);g.finished.then(()=>this.notifyFinished()).catch(jt),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(),Bh()),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 sf=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function rf(e){const t=sf.exec(e);if(!t)return[,];const[,n,i,s]=t;return[`--${n??i}`,s]}function Oa(e,t,n=1){const[i,s]=rf(e);if(!i)return;const o=window.getComputedStyle(t).getPropertyValue(i);if(o){const r=o.trim();return Go(r)?parseFloat(r):r}return ps(s)?Oa(s,t,n+1):s}function Fs(e,t){return(e==null?void 0:e[t])??(e==null?void 0:e.default)??e}const Va=new Set(["width","height","top","left","right","bottom",...ze]),of={test:e=>e==="auto",parse:e=>e},Na=e=>t=>t.test(e),Ba=[He,U,ne,_e,Yd,Xd,of],Fa=e=>Ba.find(Na(e));function af(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||Wo(e):!0}const lf=new Set(["brightness","contrast","saturate","opacity"]);function cf(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[i]=n.match(ms)||[];if(!i)return e;const s=n.replace(i,"");let o=lf.has(t)?1:0;return i!==n&&(o*=100),t+"("+o+s+")"}const uf=/\b([a-z-]*)\(.*?\)/gu,js={...ye,getAnimatableNone:e=>{const t=e.match(uf);return t?t.map(cf).join(" "):e}},ja={...He,transform:Math.round},$s={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:_e,rotateX:_e,rotateY:_e,rotateZ:_e,scale:ai,scaleX:ai,scaleY:ai,scaleZ:ai,skew:_e,skewX:_e,skewY:_e,distance:U,translateX:U,translateY:U,translateZ:U,x:U,y:U,z:U,perspective:U,transformPerspective:U,opacity:bn,originX:la,originY:la,originZ:U},zIndex:ja,fillOpacity:bn,strokeOpacity:bn,numOctaves:ja},df={...$s,color:yt,backgroundColor:yt,outlineColor:yt,fill:yt,stroke:yt,borderColor:yt,borderTopColor:yt,borderRightColor:yt,borderBottomColor:yt,borderLeftColor:yt,filter:js,WebkitFilter:js},$a=e=>df[e];function Ua(e,t){let n=$a(e);return n!==js&&(n=ye),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const hf=new Set(["auto","none","0"]);function ff(e,t,n){let i=0,s;for(;i<e.length&&!s;){const o=e[i];typeof o=="string"&&!hf.has(o)&&Sn(o).values.length&&(s=e[i]),i++}if(s&&n)for(const o of t)e[o]=Ua(n,s)}class pf extends Ns{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(),ps(c))){const d=Oa(c,n.current);d!==void 0&&(t[l]=d),l===t.length-1&&(this.finalKeyframe=c)}}if(this.resolveNoneKeyframes(),!Va.has(i)||t.length!==2)return;const[s,o]=t,r=Fa(s),a=Fa(o);if(r!==a)if(Ta(r)&&Ta(a))for(let l=0;l<t.length;l++){const c=t[l];typeof c=="string"&&(t[l]=parseFloat(c))}else Pe[i]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,i=[];for(let s=0;s<t.length;s++)(t[s]===null||af(t[s]))&&i.push(s);i.length&&ff(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=Pe[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]=Pe[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 mf(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 Ga=(e,t)=>t&&typeof e=="number"?t.transform(e):e,Ha=30,gf=e=>!isNaN(parseFloat(e));class vf{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=(i,s=!0)=>{var r,a;const o=Mt.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=Mt.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=gf(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 cs);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=Mt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>Ha)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Ha);return zo(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 Ke(e,t){return new vf(e,t)}const{schedule:Us}=ra(queueMicrotask,!1),Kt={x:!1,y:!1};function Wa(){return Kt.x||Kt.y}function _f(e){return e==="x"||e==="y"?Kt[e]?null:(Kt[e]=!0,()=>{Kt[e]=!1}):Kt.x||Kt.y?null:(Kt.x=Kt.y=!0,()=>{Kt.x=Kt.y=!1})}function za(e,t){const n=mf(e),i=new AbortController,s={passive:!0,...t,signal:i.signal};return[n,s,()=>i.abort()]}function qa(e){return!(e.pointerType==="touch"||Wa())}function yf(e,t,n={}){const[i,s,o]=za(e,n),r=a=>{if(!qa(a))return;const{target:l}=a,c=t(l,a);if(typeof c!="function"||!l)return;const d=u=>{qa(u)&&(c(u),l.removeEventListener("pointerleave",d))};l.addEventListener("pointerleave",d,s)};return i.forEach(a=>{a.addEventListener("pointerenter",r,s)}),o}const Ka=(e,t)=>t?e===t?!0:Ka(e,t.parentElement):!1,Gs=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,bf=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function wf(e){return bf.has(e.tagName)||e.tabIndex!==-1}const di=new WeakSet;function Xa(e){return t=>{t.key==="Enter"&&e(t)}}function Hs(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const xf=(e,t)=>{const n=e.currentTarget;if(!n)return;const i=Xa(()=>{if(di.has(n))return;Hs(n,"down");const s=Xa(()=>{Hs(n,"up")}),o=()=>Hs(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 Ya(e){return Gs(e)&&!Wa()}function Sf(e,t,n={}){const[i,s,o]=za(e,n),r=a=>{const l=a.currentTarget;if(!Ya(a))return;di.add(l);const c=t(l,a),d=(g,_)=>{window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",m),di.has(l)&&di.delete(l),Ya(g)&&typeof c=="function"&&c(g,{success:_})},u=g=>{d(g,l===window||l===document||n.useGlobalTarget||Ka(l,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",c=>xf(c,s)),!wf(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function Za(e){return Ho(e)&&"ownerSVGElement"in e}function Cf(e){return Za(e)&&e.tagName==="svg"}const Tt=e=>!!(e&&e.getVelocity),Tf=[...Ba,yt,ye],kf=e=>Tf.find(Na(e)),kn=Ae({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class Ef extends zt{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.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 Af({children:e,isPresent:t,anchorX:n,root:i}){const s=Qi(),o=Ft(null),r=Ft({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=wt(kn);return ko(()=>{const{width:l,height:c,top:d,left:u,right:m}=r.current;if(t||!o.current||!l||!c)return;const g=n==="left"?`left: ${u}`:`right: ${m}`;o.current.dataset.motionPopId=s;const _=document.createElement("style");a&&(_.nonce=a);const w=i??document.head;return w.appendChild(_),_.sheet&&_.sheet.insertRule(`
|
|
2
2
|
[data-motion-pop-id="${s}"] {
|
|
3
3
|
position: absolute !important;
|
|
4
4
|
width: ${l}px !important;
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
${g}px !important;
|
|
7
7
|
top: ${d}px !important;
|
|
8
8
|
}
|
|
9
|
-
`),()=>{w.removeChild(_),w.contains(_)&&w.removeChild(_)}},[t]),M(Af,{isPresent:t,childRef:o,sizeRef:r,children:Id(e,{ref:o})})}const Rf=({children:e,initial:t,isPresent:n,onExitComplete:i,custom:s,presenceAffectsLayout:o,mode:r,anchorX:a,root:l})=>{const c=ni(If),d=Qi();let u=!0,m=Qt(()=>(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&&(m={...m}),Qt(()=>{c.forEach((g,_)=>c.set(_,!1))},[n]),zt(()=>{!n&&!c.size&&i&&i()},[n]),r==="popLayout"&&(e=M(Ef,{isPresent:n,anchorX:a,root:l,children:e})),M(ii.Provider,{value:m,children:e})};function If(){return new Map}function Ja(e=!0){const t=wt(ii);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:i,register:s}=t,o=Qi();zt(()=>{if(e)return s(o)},[e]);const r=Ji(()=>e&&i&&i(o),[o,i,e]);return!n&&i?[!1,r]:[!0]}const di=e=>e.key||"";function Qa(e){const t=[];return yd.forEach(e,n=>{jo(n)&&t.push(n)}),t}const Pf=({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]=Ja(r),u=Qt(()=>Qa(e),[e]),m=r&&!c?[]:u.map(di),g=qt(!0),_=qt(u),w=ni(()=>new Map),[b,y]=ge(u),[S,C]=ge(u);Uo(()=>{g.current=!1,_.current=u;for(let D=0;D<S.length;D++){const x=di(S[D]);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 D=[...u];for(let x=0;x<S.length;x++){const T=S[x],f=di(T);m.includes(f)||(D.splice(x,0,T),I.push(T))}return o==="wait"&&I.length&&(D=I),C(Qa(D)),y(u),null}const{forceRender:L}=wt(is);return M(ue,{children:S.map(D=>{const x=di(D),T=r&&!c?!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&&(L==null||L(),C(_.current),r&&(d==null||d()),i&&i())};return M(Rf,{isPresent:T,initial:!g.current||n?void 0:!1,custom:t,presenceAffectsLayout:s,mode:o,root:l,onExitComplete:T?void 0:f,anchorX:a,children:D},x)})})},tl=Ee({strict:!1}),el={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"]},Xe={};for(const e in el)Xe[e]={isEnabled:t=>el[e].some(n=>!!t[n])};function Lf(e){for(const t in e)Xe[t]={...Xe[t],...e[t]}}const Mf=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 hi(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Mf.has(e)}let nl=e=>!hi(e);function il(e){typeof e=="function"&&(nl=t=>t.startsWith("on")?!hi(t):e(t))}try{il(require("@emotion/is-prop-valid").default)}catch{}function Df(e,t,n){const i={};for(const s in e)s==="values"&&typeof e.values=="object"||(nl(s)||n===!0&&hi(s)||!t&&!hi(s)||e.draggable&&s.startsWith("onDrag"))&&(i[s]=e[s]);return i}function Of({children:e,isValidProp:t,...n}){t&&il(t),n={...wt(Tn),...n},n.isStatic=ni(()=>n.isStatic);const i=Qt(()=>n,[JSON.stringify(n.transition),n.transformPagePoint,n.reducedMotion]);return M(Tn.Provider,{value:i,children:e})}function Vf(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 fi=Ee({});function pi(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function kn(e){return typeof e=="string"||Array.isArray(e)}const Ws=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],zs=["initial",...Ws];function mi(e){return pi(e.animate)||zs.some(t=>kn(e[t]))}function sl(e){return!!(mi(e)||e.variants)}function Nf(e,t){if(mi(e)){const{initial:n,animate:i}=e;return{initial:n===!1||kn(n)?n:void 0,animate:kn(i)?i:void 0}}return e.inherit!==!1?t:{}}function Bf(e){const{initial:t,animate:n}=Nf(e,wt(fi));return Qt(()=>({initial:t,animate:n}),[rl(t),rl(n)])}function rl(e){return Array.isArray(e)?e.join(" "):e}const Ff=Symbol.for("motionComponentSymbol");function Ye(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function jf(e,t,n){return Ji(i=>{i&&e.onMount&&e.onMount(i),t&&(i?t.mount(i):t.unmount()),n&&(typeof n=="function"?n(i):Ye(n)&&(n.current=i))},[t])}const qs=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),ol="data-"+qs("framerAppearId"),al=Ee({});function $f(e,t,n,i,s){var w,b;const{visualElement:o}=wt(fi),r=wt(tl),a=wt(ii),l=wt(Tn).reducedMotion,c=qt(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(al);d&&!d.projection&&s&&(d.type==="html"||d.type==="svg")&&Uf(c.current,n,s,u);const m=qt(!1);ko(()=>{d&&m.current&&d.update(n,a)});const g=n[ol],_=qt(!!g&&!((w=window.MotionHandoffIsComplete)!=null&&w.call(window,g))&&((b=window.MotionHasOptimisedAnimation)==null?void 0:b.call(window,g)));return Uo(()=>{d&&(m.current=!0,window.MotionIsMounted=!0,d.updateFeatures(),Us.render(d.render),_.current&&d.animationState&&d.animationState.animateChanges())}),zt(()=>{d&&(!_.current&&d.animationState&&d.animationState.animateChanges(),_.current&&(queueMicrotask(()=>{var y;(y=window.MotionHandoffMarkAsComplete)==null||y.call(window,g)}),_.current=!1))}),d}function Uf(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:ll(e.parent)),e.projection.setOptions({layoutId:s,layout:o,alwaysMeasureLayout:!!r||a&&Ye(a),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:i,crossfade:d,layoutScroll:l,layoutRoot:c})}function ll(e){if(e)return e.options.allowProjection!==!1?e.projection:ll(e.parent)}function Gf({preloadedFeatures:e,createVisualElement:t,useRender:n,useVisualState:i,Component:s}){e&&Lf(e);function o(a,l){let c;const d={...wt(Tn),...a,layoutId:Hf(a)},{isStatic:u}=d,m=Bf(a),g=i(a,u);if(!u&&ss){Wf();const _=zf(d);c=_.MeasureLayout,m.visualElement=$f(s,g,d,t,_.ProjectionNode)}return M(fi.Provider,{value:m,children:[c&&m.visualElement?M(c,{visualElement:m.visualElement,...d}):null,n(s,a,jf(g,m.visualElement,l),g,u,m.visualElement)]})}o.displayName=`motion.${typeof s=="string"?s:`create(${s.displayName??s.name??""})`}`;const r=_d(o);return r[Ff]=s,r}function Hf({layoutId:e}){const t=wt(is).id;return t&&e!==void 0?t+"-"+e:e}function Wf(e,t){wt(tl).strict}function zf(e){const{drag:t,layout:n}=Xe;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 An={};function qf(e){for(const t in e)An[t]=e[t],fs(t)&&(An[t].isCSSVariable=!0)}function cl(e,{layout:t,layoutId:n}){return qe.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!An[e]||e==="opacity")}const Kf={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Xf=ze.length;function Yf(e,t,n){let i="",s=!0;for(let o=0;o<Xf;o++){const r=ze[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=Ga(a,$s[r]);if(!l){s=!1;const d=Kf[r]||r;i+=`${d}(${c}) `}n&&(t[r]=c)}}return i=i.trim(),n?i=n(t,s?"":i):s&&(i="none"),i}function Ks(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(qe.has(l)){r=!0;continue}else if(fs(l)){s[l]=c;continue}else{const d=Ga(c,$s[l]);l.startsWith("origin")?(a=!0,o[l]=d):i[l]=d}}if(t.transform||(r||n?i.transform=Yf(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 Xs=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function ul(e,t,n){for(const i in t)!Tt(t[i])&&!cl(i,n)&&(e[i]=t[i])}function Zf({transformTemplate:e},t){return Qt(()=>{const n=Xs();return Ks(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Jf(e,t){const n=e.style||{},i={};return ul(i,n,e),Object.assign(i,Zf(e,t)),i}function Qf(e,t){const n={},i=Jf(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 tp={offset:"stroke-dashoffset",array:"stroke-dasharray"},ep={offset:"strokeDashoffset",array:"strokeDasharray"};function np(e,t,n=1,i=0,s=!0){e.pathLength=1;const o=s?tp:ep;e[o.offset]=U.transform(-i);const r=U.transform(t),a=U.transform(n);e[o.array]=`${r} ${a}`}function dl(e,{attrX:t,attrY:n,attrScale:i,pathLength:s,pathSpacing:o=1,pathOffset:r=0,...a},l,c,d){if(Ks(e,a,c),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:u,style:m}=e;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),t!==void 0&&(u.x=t),n!==void 0&&(u.y=n),i!==void 0&&(u.scale=i),s!==void 0&&np(u,s,o,r,!1)}const hl=()=>({...Xs(),attrs:{}}),fl=e=>typeof e=="string"&&e.toLowerCase()==="svg";function ip(e,t,n,i){const s=Qt(()=>{const o=hl();return dl(o,t,fl(i),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};ul(o,e.style,e),s.style={...o,...s.style}}return s}const sp=["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 Ys(e){return typeof e!="string"||e.includes("-")?!1:!!(sp.indexOf(e)>-1||/[A-Z]/u.test(e))}function rp(e=!1){return(n,i,s,{latestValues:o},r)=>{const l=(Ys(n)?ip:Qf)(i,o,r,n),c=Df(i,typeof n=="string",e),d=n!==ue?{...c,...l,ref:s}:{},{children:u}=i,m=Qt(()=>Tt(u)?u.get():u,[u]);return Bt(n,{...d,children:m})}}function pl(e){const t=[{},{}];return e==null||e.values.forEach((n,i)=>{t[0][i]=n.get(),t[1][i]=n.getVelocity()}),t}function Zs(e,t,n,i){if(typeof t=="function"){const[s,o]=pl(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]=pl(i);t=t(n!==void 0?n:e.custom,s,o)}return t}function gi(e){return Tt(e)?e.get():e}function op({scrapeMotionValuesFromProps:e,createRenderState:t},n,i,s){return{latestValues:ap(n,i,s,e),renderState:t()}}const ml=e=>(t,n)=>{const i=wt(fi),s=wt(ii),o=()=>op(e,t,i,s);return n?o():ni(o)};function ap(e,t,n,i){const s={},o=i(e,{});for(const m in o)s[m]=gi(o[m]);let{initial:r,animate:a}=e;const l=mi(e),c=sl(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"&&!pi(u)){const m=Array.isArray(u)?u:[u];for(let g=0;g<m.length;g++){const _=Zs(e,m[g]);if(_){const{transitionEnd:w,transition:b,...y}=_;for(const S in y){let C=y[S];if(Array.isArray(C)){const I=d?C.length-1:0;C=C[I]}C!==null&&(s[S]=C)}for(const S in w)s[S]=w[S]}}}return s}function Js(e,t,n){var o;const{style:i}=e,s={};for(const r in i)(Tt(i[r])||t.style&&Tt(t.style[r])||cl(r,e)||((o=n==null?void 0:n.getValue(r))==null?void 0:o.liveStyle)!==void 0)&&(s[r]=i[r]);return s}const lp={useVisualState:ml({scrapeMotionValuesFromProps:Js,createRenderState:Xs})};function gl(e,t,n){const i=Js(e,t,n);for(const s in e)if(Tt(e[s])||Tt(t[s])){const o=ze.indexOf(s)!==-1?"attr"+s.charAt(0).toUpperCase()+s.substring(1):s;i[o]=e[s]}return i}const cp={useVisualState:ml({scrapeMotionValuesFromProps:gl,createRenderState:hl})};function up(e,t){return function(i,{forwardMotionProps:s}={forwardMotionProps:!1}){const r={...Ys(i)?cp:lp,preloadedFeatures:e,useRender:rp(s),createVisualElement:t,Component:i};return Gf(r)}}function En(e,t,n){const i=e.getProps();return Zs(i,t,n!==void 0?n:i.custom,e)}const Qs=e=>Array.isArray(e);function dp(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Ke(n))}function hp(e){return Qs(e)?e[e.length-1]||0:e}function fp(e,t){const n=En(e,t);let{transitionEnd:i={},transition:s={},...o}=n||{};o={...o,...i};for(const r in o){const a=hp(o[r]);dp(e,r,a)}}function pp(e){return!!(Tt(e)&&e.add)}function tr(e,t){const n=e.getValue("willChange");if(pp(n))return n.add(t);if(!n&&he.WillChange){const i=new he.WillChange("auto");e.addValue("willChange",i),i.add(t)}}function vl(e){return e.props[ol]}const mp=e=>e!==null;function gp(e,{repeat:t,repeatType:n="loop"},i){const s=e.filter(mp),o=t&&n!=="loop"&&t%2===1?0:s.length-1;return s[o]}const vp={type:"spring",stiffness:500,damping:25,restSpeed:10},_p=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),yp={type:"keyframes",duration:.8},bp={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},wp=(e,{keyframes:t})=>t.length>2?yp:qe.has(e)?e.startsWith("scale")?_p(t[1]):vp:bp;function xp({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 er=(e,t,n,i={},s,o)=>r=>{const a=Fs(i,e)||{},l=a.delay||i.delay||0;let{elapsed:c=0}=i;c=c-te(l);const d={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...a,delay:-c,onUpdate:m=>{t.set(m),a.onUpdate&&a.onUpdate(m)},onComplete:()=>{r(),a.onComplete&&a.onComplete()},name:e,motionValue:t,element:o?void 0:s};xp(a)||Object.assign(d,wp(e,d)),d.duration&&(d.duration=te(d.duration)),d.repeatDelay&&(d.repeatDelay=te(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)),(he.instantAnimations||he.skipAnimations)&&(u=!0,d.duration=0,d.delay=0),d.allowFlatten=!a.type&&!a.ease,u&&!o&&t.get()!==void 0){const m=gp(d.keyframes,a);if(m!==void 0){ut.update(()=>{d.onUpdate(m),d.onComplete()});return}}return a.isSync?new Rs(d):new nf(d)};function Sp({protectedKeys:e,needsAnimating:t},n){const i=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,i}function _l(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),m=a[d];if(m===void 0||c&&Sp(c,d))continue;const g={delay:n,...Fs(o||{},d)},_=u.get();if(_!==void 0&&!u.isAnimating&&!Array.isArray(m)&&m===_&&!g.velocity)continue;let w=!1;if(window.MotionHandoffAnimation){const y=vl(e);if(y){const S=window.MotionHandoffAnimation(y,d,ut);S!==null&&(g.startTime=S,w=!0)}}tr(e,d),u.start(er(d,u,m,e.shouldReduceMotion&&Va.has(d)?{type:!1}:g,e,w));const b=u.animation;b&&l.push(b)}return r&&Promise.all(l).then(()=>{ut.update(()=>{r&&fp(e,r)})}),l}function nr(e,t,n={}){var l;const i=En(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(_l(e,i,n)):()=>Promise.resolve(),r=e.variantChildren&&e.variantChildren.size?(c=0)=>{const{delayChildren:d=0,staggerChildren:u,staggerDirection:m}=s;return Cp(e,t,c,d,u,m,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 Cp(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?m=>i(m,l):o===1?(m=0)=>m*s:(m=0)=>c-m*s;return Array.from(e.variantChildren).sort(Tp).forEach((m,g)=>{m.notify("AnimationStart",t),a.push(nr(m,t,{...r,delay:n+(d?0:i)+u(g)}).then(()=>m.notify("AnimationComplete",t)))}),Promise.all(a)}function Tp(e,t){return e.sortNodePosition(t)}function kp(e,t,n={}){e.notify("AnimationStart",t);let i;if(Array.isArray(t)){const s=t.map(o=>nr(e,o,n));i=Promise.all(s)}else if(typeof t=="string")i=nr(e,t,n);else{const s=typeof t=="function"?En(e,t,n.custom):t;i=Promise.all(_l(e,s,n))}return i.then(()=>{e.notify("AnimationComplete",t)})}function yl(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 Ap=zs.length;function bl(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?bl(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<Ap;n++){const i=zs[n],s=e.props[i];(kn(s)||s===!1)&&(t[i]=s)}return t}const Ep=[...Ws].reverse(),Rp=Ws.length;function Ip(e){return t=>Promise.all(t.map(({animation:n,options:i})=>kp(e,n,i)))}function Pp(e){let t=Ip(e),n=wl(),i=!0;const s=l=>(c,d)=>{var m;const u=En(e,d,l==="exit"?(m=e.presenceContext)==null?void 0:m.custom:void 0);if(u){const{transition:g,transitionEnd:_,...w}=u;c={...c,...w,..._}}return c};function o(l){t=l(e)}function r(l){const{props:c}=e,d=bl(e.parent)||{},u=[],m=new Set;let g={},_=1/0;for(let b=0;b<Rp;b++){const y=Ep[b],S=n[y],C=c[y]!==void 0?c[y]:d[y],I=kn(C),L=y===l?S.isActive:null;L===!1&&(_=b);let D=C===d[y]&&C!==c[y]&&I;if(D&&i&&e.manuallyAnimateOnMount&&(D=!1),S.protectedKeys={...g},!S.isActive&&L===null||!C&&!S.prevProp||pi(C)||typeof C=="boolean")continue;const x=Lp(S.prevProp,C);let T=x||y===l&&S.isActive&&!D&&I||b>_&&I,f=!1;const p=Array.isArray(C)?C:[C];let h=p.reduce(s(y),{});L===!1&&(h={});const{prevResolvedValues:v={}}=S,k={...v,...h},E=R=>{T=!0,m.has(R)&&(f=!0,m.delete(R)),S.needsAnimating[R]=!0;const V=e.getValue(R);V&&(V.liveStyle=!1)};for(const R in k){const V=h[R],K=v[R];if(g.hasOwnProperty(R))continue;let N=!1;Qs(V)&&Qs(K)?N=!yl(V,K):N=V!==K,N?V!=null?E(R):m.add(R):V!==void 0&&m.has(R)?E(R):S.protectedKeys[R]=!0}S.prevProp=C,S.prevResolvedValues=h,S.isActive&&(g={...g,...h}),i&&e.blockInitialAnimation&&(T=!1),T&&(!(D&&x)||f)&&u.push(...p.map(R=>({animation:R,options:{type:y}})))}if(m.size){const b={};if(typeof c.initial!="boolean"){const y=En(e,Array.isArray(c.initial)?c.initial[0]:c.initial);y&&y.transition&&(b.transition=y.transition)}m.forEach(y=>{const S=e.getBaseTarget(y),C=e.getValue(y);C&&(C.liveStyle=!0),b[y]=S??null}),u.push({animation:b})}let w=!!u.length;return i&&(c.initial===!1||c.initial===c.animate)&&!e.manuallyAnimateOnMount&&(w=!1),i=!1,w?t(u):Promise.resolve()}function a(l,c){var u;if(n[l].isActive===c)return Promise.resolve();(u=e.variantChildren)==null||u.forEach(m=>{var g;return(g=m.animationState)==null?void 0:g.setActive(l,c)}),n[l].isActive=c;const d=r(l);for(const m in n)n[m].protectedKeys={};return d}return{animateChanges:r,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=wl(),i=!0}}}function Lp(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!yl(t,e):!1}function Me(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function wl(){return{animate:Me(!0),whileInView:Me(),whileHover:Me(),whileTap:Me(),whileDrag:Me(),whileFocus:Me(),exit:Me()}}class be{constructor(t){this.isMounted=!1,this.node=t}update(){}}class Mp extends be{constructor(t){super(t),t.animationState||(t.animationState=Pp(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();pi(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 Dp=0;class Op extends be{constructor(){super(...arguments),this.id=Dp++}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 Vp={animation:{Feature:Mp},exit:{Feature:Op}};function Rn(e,t,n,i={passive:!0}){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n)}function In(e){return{point:{x:e.pageX,y:e.pageY}}}const Np=e=>t=>Gs(t)&&e(t,In(t));function Pn(e,t,n,i){return Rn(e,t,Np(n),i)}function xl({top:e,left:t,right:n,bottom:i}){return{x:{min:t,max:n},y:{min:e,max:i}}}function Bp({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Fp(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 Sl=1e-4,jp=1-Sl,$p=1+Sl,Cl=.01,Up=0-Cl,Gp=0+Cl;function At(e){return e.max-e.min}function Hp(e,t,n){return Math.abs(e-t)<=n}function Tl(e,t,n,i=.5){e.origin=i,e.originPoint=mt(t.min,t.max,e.origin),e.scale=At(n)/At(t),e.translate=mt(n.min,n.max,e.origin)-e.originPoint,(e.scale>=jp&&e.scale<=$p||isNaN(e.scale))&&(e.scale=1),(e.translate>=Up&&e.translate<=Gp||isNaN(e.translate))&&(e.translate=0)}function Ln(e,t,n,i){Tl(e.x,t.x,n.x,i?i.originX:void 0),Tl(e.y,t.y,n.y,i?i.originY:void 0)}function kl(e,t,n){e.min=n.min+t.min,e.max=e.min+At(t)}function Wp(e,t,n){kl(e.x,t.x,n.x),kl(e.y,t.y,n.y)}function Al(e,t,n){e.min=t.min-n.min,e.max=e.min+At(t)}function Mn(e,t,n){Al(e.x,t.x,n.x),Al(e.y,t.y,n.y)}const El=()=>({translate:0,scale:1,origin:0,originPoint:0}),Ze=()=>({x:El(),y:El()}),Rl=()=>({min:0,max:0}),_t=()=>({x:Rl(),y:Rl()});function jt(e){return[e("x"),e("y")]}function ir(e){return e===void 0||e===1}function sr({scale:e,scaleX:t,scaleY:n}){return!ir(e)||!ir(t)||!ir(n)}function De(e){return sr(e)||Il(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Il(e){return Pl(e.x)||Pl(e.y)}function Pl(e){return e&&e!=="0%"}function vi(e,t,n){const i=e-n,s=t*i;return n+s}function Ll(e,t,n,i,s){return s!==void 0&&(e=vi(e,s,i)),vi(e,n,i)+t}function rr(e,t=0,n=1,i,s){e.min=Ll(e.min,t,n,i,s),e.max=Ll(e.max,t,n,i,s)}function Ml(e,{x:t,y:n}){rr(e.x,t.translate,t.scale,t.originPoint),rr(e.y,n.translate,n.scale,n.originPoint)}const Dl=.999999999999,Ol=1.0000000000001;function zp(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&&Qe(e,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),r&&(t.x*=r.x.scale,t.y*=r.y.scale,Ml(e,r)),i&&De(o.latestValues)&&Qe(e,o.latestValues))}t.x<Ol&&t.x>Dl&&(t.x=1),t.y<Ol&&t.y>Dl&&(t.y=1)}function Je(e,t){e.min=e.min+t,e.max=e.max+t}function Vl(e,t,n,i,s=.5){const o=mt(e.min,e.max,s);rr(e,t,n,o,i)}function Qe(e,t){Vl(e.x,t.x,t.scaleX,t.scale,t.originX),Vl(e.y,t.y,t.scaleY,t.scale,t.originY)}function Nl(e,t){return xl(Fp(e.getBoundingClientRect(),t))}function qp(e,t,n){const i=Nl(e,n),{scroll:s}=t;return s&&(Je(i.x,s.offset.x),Je(i.y,s.offset.y)),i}const Bl=({current:e})=>e?e.ownerDocument.defaultView:null,Fl=(e,t)=>Math.abs(e-t);function Kp(e,t){const n=Fl(e.x,t.x),i=Fl(e.y,t.y);return Math.sqrt(n**2+i**2)}class jl{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 m=ar(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,_=Kp(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!_)return;const{point:w}=m,{timestamp:b}=St;this.history.push({...w,timestamp:b});const{onStart:y,onMove:S}=this.handlers;g||(y&&y(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,m)},this.handlePointerMove=(m,g)=>{this.lastMoveEvent=m,this.lastMoveEventInfo=or(g,this.transformPagePoint),ut.update(this.updatePoint,!0)},this.handlePointerUp=(m,g)=>{this.end();const{onEnd:_,onSessionEnd:w,resumeAnimation:b}=this.handlers;if(this.dragSnapToOrigin&&b&&b(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=ar(m.type==="pointercancel"?this.lastMoveEventInfo:or(g,this.transformPagePoint),this.history);this.startEvent&&_&&_(m,y),w&&w(m,y)},!Gs(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=i,this.distanceThreshold=r,this.contextWindow=s||window;const a=In(t),l=or(a,this.transformPagePoint),{point:c}=l,{timestamp:d}=St;this.history=[{...c,timestamp:d}];const{onSessionStart:u}=n;u&&u(t,ar(l,this.history)),this.removeListeners=gn(Pn(this.contextWindow,"pointermove",this.handlePointerMove),Pn(this.contextWindow,"pointerup",this.handlePointerUp),Pn(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),ve(this.updatePoint)}}function or(e,t){return t?{point:t(e.point)}:e}function $l(e,t){return{x:e.x-t.x,y:e.y-t.y}}function ar({point:e},t){return{point:e,delta:$l(e,Ul(t)),offset:$l(e,Xp(t)),velocity:Yp(t,.1)}}function Xp(e){return e[0]}function Ul(e){return e[e.length-1]}function Yp(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,i=null;const s=Ul(e);for(;n>=0&&(i=e[n],!(s.timestamp-i.timestamp>te(t)));)n--;if(!i)return{x:0,y:0};const o=ee(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 Zp(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 Gl(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 Jp(e,{top:t,left:n,bottom:i,right:s}){return{x:Gl(e.x,n,s),y:Gl(e.y,t,i)}}function Hl(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 Qp(e,t){return{x:Hl(e.x,t.x),y:Hl(e.y,t.y)}}function tm(e,t){let n=.5;const i=At(e),s=At(t);return s>i?n=vn(t.min,t.max-i,e.min):i>s&&(n=vn(e.min,e.max-s,t.min)),de(0,1,n)}function em(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 lr=.35;function nm(e=lr){return e===!1?e=0:e===!0&&(e=lr),{x:Wl(e,"left","right"),y:Wl(e,"top","bottom")}}function Wl(e,t,n){return{min:zl(e,t),max:zl(e,n)}}function zl(e,t){return typeof e=="number"?e:e[t]||0}const im=new WeakMap;class sm{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:m}=this.getProps();m?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(In(u).point)},r=(u,m)=>{const{drag:g,dragPropagation:_,onDragStart:w}=this.getProps();if(g&&!_&&(this.openDragLock&&this.openDragLock(),this.openDragLock=_f(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),jt(y=>{let S=this.getAxisMotionValue(y).get()||0;if(ne.test(S)){const{projection:C}=this.visualElement;if(C&&C.layout){const I=C.layout.layoutBox[y];I&&(S=At(I)*(parseFloat(S)/100))}}this.originPoint[y]=S}),w&&ut.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:_,onDirectionLock:w,onDrag:b}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:y}=m;if(_&&this.currentDirection===null){this.currentDirection=rm(y),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",m.point,y),this.updateAxis("y",m.point,y),this.visualElement.render(),b&&b(u,m)},l=(u,m)=>{this.latestPointerEvent=u,this.latestPanInfo=m,this.stop(u,m),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>jt(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 jl(t,{onSessionStart:o,onStart:r,onMove:a,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:i,contextWindow:Bl(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||!_i(t,s,this.currentDirection))return;const o=this.getAxisMotionValue(t);let r=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(r=Zp(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&&Ye(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&i?this.constraints=Jp(i.layoutBox,t):this.constraints=!1,this.elastic=nm(n),s!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&jt(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=em(i.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Ye(t))return!1;const i=t.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;const o=qp(i,s.root,this.visualElement.getTransformPagePoint());let r=Qp(s.layout.layoutBox,o);if(n){const a=n(Bp(r));this.hasMutatedConstraints=!!a,a&&(r=xl(a))}return r}startAnimation(t){const{drag:n,dragMomentum:i,dragElastic:s,dragTransition:o,dragSnapToOrigin:r,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},c=jt(d=>{if(!_i(d,n,this.currentDirection))return;let u=l&&l[d]||{};r&&(u={min:0,max:0});const m=s?200:1e6,g=s?40:1e7,_={type:"inertia",velocity:i?t[d]:0,bounceStiffness:m,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 tr(this.visualElement,t),i.start(er(t,i,0,n,this.visualElement,!1))}stopAnimation(){jt(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){jt(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){jt(n=>{const{drag:i}=this.getProps();if(!_i(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(!Ye(n)||!i||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};jt(r=>{const a=this.getAxisMotionValue(r);if(a&&this.constraints!==!1){const l=a.get();s[r]=tm({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(),jt(r=>{if(!_i(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;im.set(this.visualElement,this);const t=this.visualElement.current,n=Pn(t,"pointerdown",l=>{const{drag:c,dragListener:d=!0}=this.getProps();c&&d&&this.start(l)}),i=()=>{const{dragConstraints:l}=this.getProps();Ye(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=Rn(window,"resize",()=>this.scalePositionWithinConstraints()),a=s.addEventListener("didUpdate",({delta:l,hasLayoutChanged:c})=>{this.isDragging&&c&&(jt(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=lr,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:i,dragPropagation:s,dragConstraints:o,dragElastic:r,dragMomentum:a}}}function _i(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function rm(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class om extends be{constructor(t){super(t),this.removeGroupControls=Ft,this.removeListeners=Ft,this.controls=new sm(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ft}unmount(){this.removeGroupControls(),this.removeListeners()}}const ql=e=>(t,n)=>{e&&ut.postRender(()=>e(t,n))};class am extends be{constructor(){super(...arguments),this.removePointerDownListener=Ft}onPointerDown(t){this.session=new jl(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Bl(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:i,onPanEnd:s}=this.node.getProps();return{onSessionStart:ql(t),onStart:ql(n),onMove:i,onEnd:(o,r)=>{delete this.session,s&&ut.postRender(()=>s(o,r))}}}mount(){this.removePointerDownListener=Pn(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 yi={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Kl(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Dn={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(U.test(e))e=parseFloat(e);else return e;const n=Kl(e,t.target.x),i=Kl(e,t.target.y);return`${n}% ${i}%`}},lm={correct:(e,{treeScale:t,projectionDelta:n})=>{const i=e,s=ye.parse(e);if(s.length>5)return i;const o=ye.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 Xl=!1;class cm extends Wt{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i,layoutId:s}=this.props,{projection:o}=t;qf(um),o&&(n.group&&n.group.add(o),i&&i.register&&s&&i.register(o),Xl&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),yi.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:i,drag:s,isPresent:o}=this.props,{projection:r}=i;return r&&(r.isPresent=o,Xl=!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(),Us.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 Yl(e){const[t,n]=Ja(),i=wt(is);return M(cm,{...e,layoutGroup:i,switchLayoutGroup:wt(al),isPresent:t,safeToRemove:n})}const um={borderRadius:{...Dn,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Dn,borderTopRightRadius:Dn,borderBottomLeftRadius:Dn,borderBottomRightRadius:Dn,boxShadow:lm};function dm(e,t,n){const i=Tt(e)?e:Ke(e);return i.start(er("",i,t,n)),i.animation}const hm=(e,t)=>e.depth-t.depth;class fm{constructor(){this.children=[],this.isDirty=!1}add(t){rs(this.children,t),this.isDirty=!0}remove(t){os(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(hm),this.isDirty=!1,this.children.forEach(t)}}function pm(e,t){const n=Lt.now(),i=({timestamp:s})=>{const o=s-n;o>=t&&(ve(i),e(o-t))};return ut.setup(i,!0),()=>ve(i)}const Zl=["TopLeft","TopRight","BottomLeft","BottomRight"],mm=Zl.length,Jl=e=>typeof e=="string"?parseFloat(e):e,Ql=e=>typeof e=="number"||U.test(e);function gm(e,t,n,i,s,o){s?(e.opacity=mt(0,n.opacity??1,vm(i)),e.opacityExit=mt(t.opacity??1,0,_m(i))):o&&(e.opacity=mt(t.opacity??1,n.opacity??1,i));for(let r=0;r<mm;r++){const a=`border${Zl[r]}Radius`;let l=tc(t,a),c=tc(n,a);if(l===void 0&&c===void 0)continue;l||(l=0),c||(c=0),l===0||c===0||Ql(l)===Ql(c)?(e[a]=Math.max(mt(Jl(l),Jl(c),i),0),(ne.test(c)||ne.test(l))&&(e[a]+="%")):e[a]=c}(t.rotate||n.rotate)&&(e.rotate=mt(t.rotate||0,n.rotate||0,i))}function tc(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const vm=ec(0,.5,Qo),_m=ec(.5,.95,Ft);function ec(e,t,n){return i=>i<e?0:i>t?1:n(vn(e,t,i))}function nc(e,t){e.min=t.min,e.max=t.max}function $t(e,t){nc(e.x,t.x),nc(e.y,t.y)}function ic(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function sc(e,t,n,i,s){return e-=t,e=vi(e,1/n,i),s!==void 0&&(e=vi(e,1/s,i)),e}function ym(e,t=0,n=1,i=.5,s,o=e,r=e){if(ne.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=sc(e.min,t,n,a,s),e.max=sc(e.max,t,n,a,s)}function rc(e,t,[n,i,s],o,r){ym(e,t[n],t[i],t[s],t.scale,o,r)}const bm=["x","scaleX","originX"],wm=["y","scaleY","originY"];function oc(e,t,n,i){rc(e.x,t,bm,n?n.x:void 0,i?i.x:void 0),rc(e.y,t,wm,n?n.y:void 0,i?i.y:void 0)}function ac(e){return e.translate===0&&e.scale===1}function lc(e){return ac(e.x)&&ac(e.y)}function cc(e,t){return e.min===t.min&&e.max===t.max}function xm(e,t){return cc(e.x,t.x)&&cc(e.y,t.y)}function uc(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function dc(e,t){return uc(e.x,t.x)&&uc(e.y,t.y)}function hc(e){return At(e.x)/At(e.y)}function fc(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class Sm{constructor(){this.members=[]}add(t){rs(this.members,t),t.scheduleRender()}remove(t){if(os(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 Cm(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:m,skewX:g,skewY:_}=n;c&&(i=`perspective(${c}px) ${i}`),d&&(i+=`rotate(${d}deg) `),u&&(i+=`rotateX(${u}deg) `),m&&(i+=`rotateY(${m}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 cr=["","X","Y","Z"],Tm=1e3;let km=0;function ur(e,t,n,i){const{latestValues:s}=t;s[e]&&(n[e]=s[e],t.setStaticValue(e,0),i&&(i[e]=0))}function pc(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=vl(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&&pc(i)}function mc({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:i,resetTransform:s}){return class{constructor(r={},a=t==null?void 0:t()){this.id=km++,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(Rm),this.nodes.forEach(Mm),this.nodes.forEach(Dm),this.nodes.forEach(Im)},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 fm)}addEventListener(r,a){return this.eventHandlers.has(r)||this.eventHandlers.set(r,new cs),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=Za(r)&&!Cf(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 m=()=>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=pm(m,250),yi.hasAnimatedSinceResize&&(yi.hasAnimatedSinceResize=!1,this.nodes.forEach(_c)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&c&&(a||l)&&this.addEventListener("didUpdate",({delta:d,hasLayoutChanged:u,hasRelativeLayoutChanged:m,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const _=this.options.transition||c.getDefaultTransition()||Fm,{onLayoutAnimationStart:w,onLayoutAnimationComplete:b}=c.getProps(),y=!this.targetLayout||!dc(this.targetLayout,g),S=!u&&m;if(this.options.layoutRoot||this.resumeFrom||S||u&&(y||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const C={...Fs(_,"layout"),onPlay:w,onComplete:b};(c.shouldReduceMotion||this.options.layoutRoot)&&(C.delay=0,C.type=!1),this.startAnimation(C),this.setAnimationOrigin(d,S)}else u||_c(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(),ve(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(Om),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&&pc(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(gc);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(vc);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Lm),this.nodes.forEach(Am),this.nodes.forEach(Em)):this.nodes.forEach(vc),this.clearAllSnapshots();const a=Lt.now();St.delta=de(0,1e3/60,a-St.timestamp),St.timestamp=a,St.isProcessing=!0,hs.update.process(St),hs.preRender.process(St),hs.render.process(St),St.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Us.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Pm),this.sharedNodes.forEach(Vm)}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&&!At(this.snapshot.measuredBox.x)&&!At(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&&!lc(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,d=c!==this.prevTransformTemplateValue;r&&this.instance&&(a||De(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($m))){const{scroll:d}=this.root;d&&(Je(a.x,d.offset.x),Je(a.y,d.offset.y))}return a}removeElementScroll(r){var l;const a=_t();if($t(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:m}=d;d!==this.root&&u&&m.layoutScroll&&(u.wasRoot&&$t(a,r),Je(a.x,u.offset.x),Je(a.y,u.offset.y))}return a}applyTransform(r,a=!1){const l=_t();$t(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&&Qe(l,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),De(d.latestValues)&&Qe(l,d.latestValues)}return De(this.latestValues)&&Qe(l,this.latestValues),l}removeTransform(r){const a=_t();$t(a,r);for(let l=0;l<this.path.length;l++){const c=this.path[l];if(!c.instance||!De(c.latestValues))continue;sr(c.latestValues)&&c.updateSnapshot();const d=_t(),u=c.measurePageBox();$t(d,u),oc(a,c.latestValues,c.snapshot?c.snapshot.layoutBox:void 0,d)}return De(this.latestValues)&&oc(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 m;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||(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=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(),Mn(this.relativeTargetOrigin,this.layout.layoutBox,g.layout.layoutBox),$t(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(),Wp(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):$t(this.target,this.layout.layoutBox),Ml(this.target,this.targetDelta)):$t(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(),Mn(this.relativeTargetOrigin,this.target,g.target),$t(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||sr(this.parent.latestValues)||Il(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;$t(this.layoutCorrected,this.layout.layoutBox);const u=this.treeScale.x,m=this.treeScale.y;zp(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():(ic(this.prevProjectionDelta.x,this.projectionDelta.x),ic(this.prevProjectionDelta.y,this.projectionDelta.y)),Ln(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==u||this.treeScale.y!==m||!fc(this.projectionDelta.x,this.prevProjectionDelta.x)||!fc(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=Ze(),this.projectionDelta=Ze(),this.projectionDeltaWithTransform=Ze()}setAnimationOrigin(r,a=!1){const l=this.snapshot,c=l?l.latestValues:{},d={...this.latestValues},u=Ze();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const m=_t(),g=l?l.source:void 0,_=this.layout?this.layout.source:void 0,w=g!==_,b=this.getStack(),y=!b||b.members.length<=1,S=!!(w&&!y&&this.options.crossfade===!0&&!this.path.some(Bm));this.animationProgress=0;let C;this.mixTargetDelta=I=>{const L=I/1e3;yc(u.x,r.x,L),yc(u.y,r.y,L),this.setTargetDelta(u),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Mn(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Nm(this.relativeTarget,this.relativeTargetOrigin,m,L),C&&xm(this.relativeTarget,C)&&(this.isProjectionDirty=!1),C||(C=_t()),$t(C,this.relativeTarget)),w&&(this.animationValues=d,gm(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&&(ve(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ut.update(()=>{yi.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Ke(0)),this.currentAnimation=dm(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(Tm),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&&Cc(this.options.animationType,this.layout.layoutBox,c.layoutBox)){l=this.target||_t();const u=At(this.layout.layoutBox.x);l.x.min=r.target.x.min,l.x.max=l.x.min+u;const m=At(this.layout.layoutBox.y);l.y.min=r.target.y.min,l.y.max=l.y.min+m}$t(a,l),Qe(a,d),Ln(this.projectionDeltaWithTransform,this.layoutCorrected,a,d)}}registerSharedNode(r,a){this.sharedNodes.has(r)||this.sharedNodes.set(r,new Sm),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&&ur("z",r,c,this.animationValues);for(let d=0;d<cr.length;d++)ur(`rotate${cr[d]}`,r,c,this.animationValues),ur(`skew${cr[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=gi(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=gi(a==null?void 0:a.pointerEvents)||""),this.hasProjected&&!De(this.latestValues)&&(r.transform=l?l({},""):"none",this.hasProjected=!1);return}r.visibility="";const d=c.animationValues||c.latestValues;this.applyTransformsToTarget();let u=Cm(this.projectionDeltaWithTransform,this.treeScale,d);l&&(u=l(d,u)),r.transform=u;const{x:m,y:g}=this.projectionDelta;r.transformOrigin=`${m.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 An){if(d[_]===void 0)continue;const{correct:w,applyTo:b,isCSSVariable:y}=An[_],S=u==="none"?d[_]:w(d[_],c);if(b){const C=b.length;for(let I=0;I<C;I++)r[b[I]]=S}else y?this.options.visualElement.renderState.vars[_]=S:r[_]=S}this.options.layoutId&&(r.pointerEvents=c===this?gi(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(gc),this.root.sharedNodes.clear()}}}function Am(e){e.updateLayout()}function Em(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"?jt(u=>{const m=r?t.measuredBox[u]:t.layoutBox[u],g=At(m);m.min=i[u].min,m.max=m.min+g}):Cc(o,t.layoutBox,i)&&jt(u=>{const m=r?t.measuredBox[u]:t.layoutBox[u],g=At(i[u]);m.max=m.min+g,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[u].max=e.relativeTarget[u].min+g)});const a=Ze();Ln(a,i,t.layoutBox);const l=Ze();r?Ln(l,e.applyTransform(s,!0),t.measuredBox):Ln(l,i,t.layoutBox);const c=!lc(a);let d=!1;if(!e.resumeFrom){const u=e.getClosestProjectingParent();if(u&&!u.resumeFrom){const{snapshot:m,layout:g}=u;if(m&&g){const _=_t();Mn(_,t.layoutBox,m.layoutBox);const w=_t();Mn(w,i,g.layoutBox),dc(_,w)||(d=!0),u.options.layoutRoot&&(e.relativeTarget=w,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 Rm(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 Im(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Pm(e){e.clearSnapshot()}function gc(e){e.clearMeasurements()}function vc(e){e.isLayoutDirty=!1}function Lm(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function _c(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Mm(e){e.resolveTargetDelta()}function Dm(e){e.calcProjection()}function Om(e){e.resetSkewAndRotation()}function Vm(e){e.removeLeadSnapshot()}function yc(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 bc(e,t,n,i){e.min=mt(t.min,n.min,i),e.max=mt(t.max,n.max,i)}function Nm(e,t,n,i){bc(e.x,t.x,n.x,i),bc(e.y,t.y,n.y,i)}function Bm(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const Fm={duration:.45,ease:[.4,0,.1,1]},wc=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),xc=wc("applewebkit/")&&!wc("chrome/")?Math.round:Ft;function Sc(e){e.min=xc(e.min),e.max=xc(e.max)}function jm(e){Sc(e.x),Sc(e.y)}function Cc(e,t,n){return e==="position"||e==="preserve-aspect"&&!Hp(hc(t),hc(n),.2)}function $m(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const Um=mc({attachResizeListener:(e,t)=>Rn(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),dr={current:void 0},Tc=mc({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!dr.current){const e=new Um({});e.mount(window),e.setOptions({layoutScroll:!0}),dr.current=e}return dr.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Gm={pan:{Feature:am},drag:{Feature:om,ProjectionNode:Tc,MeasureLayout:Yl}};function kc(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,In(t)))}class Hm extends be{mount(){const{current:t}=this.node;t&&(this.unmount=yf(t,(n,i)=>(kc(this.node,i,"Start"),s=>kc(this.node,s,"End"))))}unmount(){}}class Wm extends be{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=gn(Rn(this.node.current,"focus",()=>this.onFocus()),Rn(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Ac(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,In(t)))}class zm extends be{mount(){const{current:t}=this.node;t&&(this.unmount=Sf(t,(n,i)=>(Ac(this.node,i,"Start"),(s,{success:o})=>Ac(this.node,s,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const hr=new WeakMap,fr=new WeakMap,qm=e=>{const t=hr.get(e.target);t&&t(e)},Km=e=>{e.forEach(qm)};function Xm({root:e,...t}){const n=e||document;fr.has(n)||fr.set(n,{});const i=fr.get(n),s=JSON.stringify(t);return i[s]||(i[s]=new IntersectionObserver(Km,{root:e,...t})),i[s]}function Ym(e,t,n){const i=Xm(t);return hr.set(e,n),i.observe(e),()=>{hr.delete(e),i.unobserve(e)}}const Zm={some:0,all:1};class Jm extends be{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:Zm[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(),m=c?d:u;m&&m(l)};return Ym(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(Qm(t,n))&&this.startObserver()}unmount(){}}function Qm({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const tg={inView:{Feature:Jm},tap:{Feature:zm},focus:{Feature:Wm},hover:{Feature:Hm}},eg={layout:{ProjectionNode:Tc,MeasureLayout:Yl}},pr={current:null},Ec={current:!1};function ng(){if(Ec.current=!0,!!ss)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>pr.current=e.matches;e.addEventListener("change",t),t()}else pr.current=!1}const ig=new WeakMap;function sg(e,t,n){for(const i in t){const s=t[i],o=n[i];if(Tt(s))e.addValue(i,s);else if(Tt(o))e.addValue(i,Ke(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,Ke(r!==void 0?r:s,{owner:e}))}}for(const i in n)t[i]===void 0&&e.removeValue(i);return t}const Rc=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class rg{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=Ns,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=Lt.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,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=mi(n),this.isVariantNode=sl(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:d,...u}=this.scrapeMotionValuesFromProps(n,{},this);for(const m in u){const g=u[m];l[m]!==void 0&&Tt(g)&&g.set(l[m],!1)}}mount(t){this.current=t,ig.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)),Ec.current||ng(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:pr.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),ve(this.notifyUpdate),ve(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=qe.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 Xe){const n=Xe[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<Rc.length;i++){const s=Rc[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=sg(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=Ke(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"&&(Go(i)||Wo(i))?i=parseFloat(i):!kf(i)&&ye.test(n)&&(i=Ua(t,n)),this.setBaseTarget(t,Tt(i)?i.get():i)),Tt(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=Zs(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&&!Tt(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 cs),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}}class Ic extends rg{constructor(){super(...arguments),this.KeyframeResolver=pf}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;Tt(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Pc(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 og(e){return window.getComputedStyle(e)}class ag extends Ic{constructor(){super(...arguments),this.type="html",this.renderInstance=Pc}readValueFromInstance(t,n){var i;if(qe.has(n))return(i=this.projection)!=null&&i.isProjecting?Ls(n):Mh(t,n);{const s=og(t),o=(fs(n)?s.getPropertyValue(n):s[n])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(t,{transformPagePoint:n}){return Nl(t,n)}build(t,n,i){Ks(t,n,i.transformTemplate)}scrapeMotionValuesFromProps(t,n,i){return Js(t,n,i)}}const Lc=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 lg(e,t,n,i){Pc(e,t,void 0,i);for(const s in t.attrs)e.setAttribute(Lc.has(s)?s:qs(s),t.attrs[s])}class cg extends Ic{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=_t}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(qe.has(n)){const i=$a(n);return i&&i.default||0}return n=Lc.has(n)?n:qs(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,i){return gl(t,n,i)}build(t,n,i){dl(t,n,this.isSVGTag,i.transformTemplate,i.style)}renderInstance(t,n,i,s){lg(t,n,i,s)}mount(t){this.isSVGTag=fl(t.tagName),super.mount(t)}}const ug=(e,t)=>Ys(e)?new cg(t):new ag(t,{allowProjection:e!==ue}),dg=up({...Vp,...tg,...Gm,...eg},ug),On=Vf(dg),Mc=({stream:e})=>{const t=qt(null);return zt(()=>{!t.current||!e||(t.current.srcObject=e)},[e]),M("audio",{muted:!0,ref:t,autoPlay:!0})};/**!
|
|
9
|
+
`),()=>{w.removeChild(_),w.contains(_)&&w.removeChild(_)}},[t]),L(Ef,{isPresent:t,childRef:o,sizeRef:r,children:Id(e,{ref:o})})}const Rf=({children:e,initial:t,isPresent:n,onExitComplete:i,custom:s,presenceAffectsLayout:o,mode:r,anchorX:a,root:l})=>{const c=ii(If),d=Qi();let u=!0,m=Qt(()=>(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&&(m={...m}),Qt(()=>{c.forEach((g,_)=>c.set(_,!1))},[n]),qt(()=>{!n&&!c.size&&i&&i()},[n]),r==="popLayout"&&(e=L(Af,{isPresent:n,anchorX:a,root:l,children:e})),L(si.Provider,{value:m,children:e})};function If(){return new Map}function Ja(e=!0){const t=wt(si);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:i,register:s}=t,o=Qi();qt(()=>{if(e)return s(o)},[e]);const r=Ji(()=>e&&i&&i(o),[o,i,e]);return!n&&i?[!1,r]:[!0]}const hi=e=>e.key||"";function Qa(e){const t=[];return yd.forEach(e,n=>{jo(n)&&t.push(n)}),t}const Pf=({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]=Ja(r),u=Qt(()=>Qa(e),[e]),m=r&&!c?[]:u.map(hi),g=Ft(!0),_=Ft(u),w=ii(()=>new Map),[b,y]=ge(u),[S,C]=ge(u);Uo(()=>{g.current=!1,_.current=u;for(let D=0;D<S.length;D++){const x=hi(S[D]);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 D=[...u];for(let x=0;x<S.length;x++){const T=S[x],f=hi(T);m.includes(f)||(D.splice(x,0,T),I.push(T))}return o==="wait"&&I.length&&(D=I),C(Qa(D)),y(u),null}const{forceRender:M}=wt(is);return L(ue,{children:S.map(D=>{const x=hi(D),T=r&&!c?!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&&(M==null||M(),C(_.current),r&&(d==null||d()),i&&i())};return L(Rf,{isPresent:T,initial:!g.current||n?void 0:!1,custom:t,presenceAffectsLayout:s,mode:o,root:l,onExitComplete:T?void 0:f,anchorX:a,children:D},x)})})},tl=Ae({strict:!1}),el={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"]},Xe={};for(const e in el)Xe[e]={isEnabled:t=>el[e].some(n=>!!t[n])};function Mf(e){for(const t in e)Xe[t]={...Xe[t],...e[t]}}const Lf=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 fi(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Lf.has(e)}let nl=e=>!fi(e);function il(e){typeof e=="function"&&(nl=t=>t.startsWith("on")?!fi(t):e(t))}try{il(require("@emotion/is-prop-valid").default)}catch{}function Df(e,t,n){const i={};for(const s in e)s==="values"&&typeof e.values=="object"||(nl(s)||n===!0&&fi(s)||!t&&!fi(s)||e.draggable&&s.startsWith("onDrag"))&&(i[s]=e[s]);return i}function Of({children:e,isValidProp:t,...n}){t&&il(t),n={...wt(kn),...n},n.isStatic=ii(()=>n.isStatic);const i=Qt(()=>n,[JSON.stringify(n.transition),n.transformPagePoint,n.reducedMotion]);return L(kn.Provider,{value:i,children:e})}function Vf(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 pi=Ae({});function mi(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function En(e){return typeof e=="string"||Array.isArray(e)}const Ws=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],zs=["initial",...Ws];function gi(e){return mi(e.animate)||zs.some(t=>En(e[t]))}function sl(e){return!!(gi(e)||e.variants)}function Nf(e,t){if(gi(e)){const{initial:n,animate:i}=e;return{initial:n===!1||En(n)?n:void 0,animate:En(i)?i:void 0}}return e.inherit!==!1?t:{}}function Bf(e){const{initial:t,animate:n}=Nf(e,wt(pi));return Qt(()=>({initial:t,animate:n}),[rl(t),rl(n)])}function rl(e){return Array.isArray(e)?e.join(" "):e}const Ff=Symbol.for("motionComponentSymbol");function Ye(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function jf(e,t,n){return Ji(i=>{i&&e.onMount&&e.onMount(i),t&&(i?t.mount(i):t.unmount()),n&&(typeof n=="function"?n(i):Ye(n)&&(n.current=i))},[t])}const qs=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),ol="data-"+qs("framerAppearId"),al=Ae({});function $f(e,t,n,i,s){var w,b;const{visualElement:o}=wt(pi),r=wt(tl),a=wt(si),l=wt(kn).reducedMotion,c=Ft(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(al);d&&!d.projection&&s&&(d.type==="html"||d.type==="svg")&&Uf(c.current,n,s,u);const m=Ft(!1);ko(()=>{d&&m.current&&d.update(n,a)});const g=n[ol],_=Ft(!!g&&!((w=window.MotionHandoffIsComplete)!=null&&w.call(window,g))&&((b=window.MotionHasOptimisedAnimation)==null?void 0:b.call(window,g)));return Uo(()=>{d&&(m.current=!0,window.MotionIsMounted=!0,d.updateFeatures(),Us.render(d.render),_.current&&d.animationState&&d.animationState.animateChanges())}),qt(()=>{d&&(!_.current&&d.animationState&&d.animationState.animateChanges(),_.current&&(queueMicrotask(()=>{var y;(y=window.MotionHandoffMarkAsComplete)==null||y.call(window,g)}),_.current=!1))}),d}function Uf(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:ll(e.parent)),e.projection.setOptions({layoutId:s,layout:o,alwaysMeasureLayout:!!r||a&&Ye(a),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:i,crossfade:d,layoutScroll:l,layoutRoot:c})}function ll(e){if(e)return e.options.allowProjection!==!1?e.projection:ll(e.parent)}function Gf({preloadedFeatures:e,createVisualElement:t,useRender:n,useVisualState:i,Component:s}){e&&Mf(e);function o(a,l){let c;const d={...wt(kn),...a,layoutId:Hf(a)},{isStatic:u}=d,m=Bf(a),g=i(a,u);if(!u&&ss){Wf();const _=zf(d);c=_.MeasureLayout,m.visualElement=$f(s,g,d,t,_.ProjectionNode)}return L(pi.Provider,{value:m,children:[c&&m.visualElement?L(c,{visualElement:m.visualElement,...d}):null,n(s,a,jf(g,m.visualElement,l),g,u,m.visualElement)]})}o.displayName=`motion.${typeof s=="string"?s:`create(${s.displayName??s.name??""})`}`;const r=_d(o);return r[Ff]=s,r}function Hf({layoutId:e}){const t=wt(is).id;return t&&e!==void 0?t+"-"+e:e}function Wf(e,t){wt(tl).strict}function zf(e){const{drag:t,layout:n}=Xe;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 An={};function qf(e){for(const t in e)An[t]=e[t],fs(t)&&(An[t].isCSSVariable=!0)}function cl(e,{layout:t,layoutId:n}){return qe.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!An[e]||e==="opacity")}const Kf={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Xf=ze.length;function Yf(e,t,n){let i="",s=!0;for(let o=0;o<Xf;o++){const r=ze[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=Ga(a,$s[r]);if(!l){s=!1;const d=Kf[r]||r;i+=`${d}(${c}) `}n&&(t[r]=c)}}return i=i.trim(),n?i=n(t,s?"":i):s&&(i="none"),i}function Ks(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(qe.has(l)){r=!0;continue}else if(fs(l)){s[l]=c;continue}else{const d=Ga(c,$s[l]);l.startsWith("origin")?(a=!0,o[l]=d):i[l]=d}}if(t.transform||(r||n?i.transform=Yf(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 Xs=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function ul(e,t,n){for(const i in t)!Tt(t[i])&&!cl(i,n)&&(e[i]=t[i])}function Zf({transformTemplate:e},t){return Qt(()=>{const n=Xs();return Ks(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Jf(e,t){const n=e.style||{},i={};return ul(i,n,e),Object.assign(i,Zf(e,t)),i}function Qf(e,t){const n={},i=Jf(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 tp={offset:"stroke-dashoffset",array:"stroke-dasharray"},ep={offset:"strokeDashoffset",array:"strokeDasharray"};function np(e,t,n=1,i=0,s=!0){e.pathLength=1;const o=s?tp:ep;e[o.offset]=U.transform(-i);const r=U.transform(t),a=U.transform(n);e[o.array]=`${r} ${a}`}function dl(e,{attrX:t,attrY:n,attrScale:i,pathLength:s,pathSpacing:o=1,pathOffset:r=0,...a},l,c,d){if(Ks(e,a,c),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:u,style:m}=e;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),t!==void 0&&(u.x=t),n!==void 0&&(u.y=n),i!==void 0&&(u.scale=i),s!==void 0&&np(u,s,o,r,!1)}const hl=()=>({...Xs(),attrs:{}}),fl=e=>typeof e=="string"&&e.toLowerCase()==="svg";function ip(e,t,n,i){const s=Qt(()=>{const o=hl();return dl(o,t,fl(i),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};ul(o,e.style,e),s.style={...o,...s.style}}return s}const sp=["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 Ys(e){return typeof e!="string"||e.includes("-")?!1:!!(sp.indexOf(e)>-1||/[A-Z]/u.test(e))}function rp(e=!1){return(n,i,s,{latestValues:o},r)=>{const l=(Ys(n)?ip:Qf)(i,o,r,n),c=Df(i,typeof n=="string",e),d=n!==ue?{...c,...l,ref:s}:{},{children:u}=i,m=Qt(()=>Tt(u)?u.get():u,[u]);return Bt(n,{...d,children:m})}}function pl(e){const t=[{},{}];return e==null||e.values.forEach((n,i)=>{t[0][i]=n.get(),t[1][i]=n.getVelocity()}),t}function Zs(e,t,n,i){if(typeof t=="function"){const[s,o]=pl(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]=pl(i);t=t(n!==void 0?n:e.custom,s,o)}return t}function vi(e){return Tt(e)?e.get():e}function op({scrapeMotionValuesFromProps:e,createRenderState:t},n,i,s){return{latestValues:ap(n,i,s,e),renderState:t()}}const ml=e=>(t,n)=>{const i=wt(pi),s=wt(si),o=()=>op(e,t,i,s);return n?o():ii(o)};function ap(e,t,n,i){const s={},o=i(e,{});for(const m in o)s[m]=vi(o[m]);let{initial:r,animate:a}=e;const l=gi(e),c=sl(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"&&!mi(u)){const m=Array.isArray(u)?u:[u];for(let g=0;g<m.length;g++){const _=Zs(e,m[g]);if(_){const{transitionEnd:w,transition:b,...y}=_;for(const S in y){let C=y[S];if(Array.isArray(C)){const I=d?C.length-1:0;C=C[I]}C!==null&&(s[S]=C)}for(const S in w)s[S]=w[S]}}}return s}function Js(e,t,n){var o;const{style:i}=e,s={};for(const r in i)(Tt(i[r])||t.style&&Tt(t.style[r])||cl(r,e)||((o=n==null?void 0:n.getValue(r))==null?void 0:o.liveStyle)!==void 0)&&(s[r]=i[r]);return s}const lp={useVisualState:ml({scrapeMotionValuesFromProps:Js,createRenderState:Xs})};function gl(e,t,n){const i=Js(e,t,n);for(const s in e)if(Tt(e[s])||Tt(t[s])){const o=ze.indexOf(s)!==-1?"attr"+s.charAt(0).toUpperCase()+s.substring(1):s;i[o]=e[s]}return i}const cp={useVisualState:ml({scrapeMotionValuesFromProps:gl,createRenderState:hl})};function up(e,t){return function(i,{forwardMotionProps:s}={forwardMotionProps:!1}){const r={...Ys(i)?cp:lp,preloadedFeatures:e,useRender:rp(s),createVisualElement:t,Component:i};return Gf(r)}}function Rn(e,t,n){const i=e.getProps();return Zs(i,t,n!==void 0?n:i.custom,e)}const Qs=e=>Array.isArray(e);function dp(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Ke(n))}function hp(e){return Qs(e)?e[e.length-1]||0:e}function fp(e,t){const n=Rn(e,t);let{transitionEnd:i={},transition:s={},...o}=n||{};o={...o,...i};for(const r in o){const a=hp(o[r]);dp(e,r,a)}}function pp(e){return!!(Tt(e)&&e.add)}function tr(e,t){const n=e.getValue("willChange");if(pp(n))return n.add(t);if(!n&&he.WillChange){const i=new he.WillChange("auto");e.addValue("willChange",i),i.add(t)}}function vl(e){return e.props[ol]}const mp=e=>e!==null;function gp(e,{repeat:t,repeatType:n="loop"},i){const s=e.filter(mp),o=t&&n!=="loop"&&t%2===1?0:s.length-1;return s[o]}const vp={type:"spring",stiffness:500,damping:25,restSpeed:10},_p=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),yp={type:"keyframes",duration:.8},bp={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},wp=(e,{keyframes:t})=>t.length>2?yp:qe.has(e)?e.startsWith("scale")?_p(t[1]):vp:bp;function xp({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 er=(e,t,n,i={},s,o)=>r=>{const a=Fs(i,e)||{},l=a.delay||i.delay||0;let{elapsed:c=0}=i;c=c-te(l);const d={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...a,delay:-c,onUpdate:m=>{t.set(m),a.onUpdate&&a.onUpdate(m)},onComplete:()=>{r(),a.onComplete&&a.onComplete()},name:e,motionValue:t,element:o?void 0:s};xp(a)||Object.assign(d,wp(e,d)),d.duration&&(d.duration=te(d.duration)),d.repeatDelay&&(d.repeatDelay=te(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)),(he.instantAnimations||he.skipAnimations)&&(u=!0,d.duration=0,d.delay=0),d.allowFlatten=!a.type&&!a.ease,u&&!o&&t.get()!==void 0){const m=gp(d.keyframes,a);if(m!==void 0){ut.update(()=>{d.onUpdate(m),d.onComplete()});return}}return a.isSync?new Rs(d):new nf(d)};function Sp({protectedKeys:e,needsAnimating:t},n){const i=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,i}function _l(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),m=a[d];if(m===void 0||c&&Sp(c,d))continue;const g={delay:n,...Fs(o||{},d)},_=u.get();if(_!==void 0&&!u.isAnimating&&!Array.isArray(m)&&m===_&&!g.velocity)continue;let w=!1;if(window.MotionHandoffAnimation){const y=vl(e);if(y){const S=window.MotionHandoffAnimation(y,d,ut);S!==null&&(g.startTime=S,w=!0)}}tr(e,d),u.start(er(d,u,m,e.shouldReduceMotion&&Va.has(d)?{type:!1}:g,e,w));const b=u.animation;b&&l.push(b)}return r&&Promise.all(l).then(()=>{ut.update(()=>{r&&fp(e,r)})}),l}function nr(e,t,n={}){var l;const i=Rn(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(_l(e,i,n)):()=>Promise.resolve(),r=e.variantChildren&&e.variantChildren.size?(c=0)=>{const{delayChildren:d=0,staggerChildren:u,staggerDirection:m}=s;return Cp(e,t,c,d,u,m,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 Cp(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?m=>i(m,l):o===1?(m=0)=>m*s:(m=0)=>c-m*s;return Array.from(e.variantChildren).sort(Tp).forEach((m,g)=>{m.notify("AnimationStart",t),a.push(nr(m,t,{...r,delay:n+(d?0:i)+u(g)}).then(()=>m.notify("AnimationComplete",t)))}),Promise.all(a)}function Tp(e,t){return e.sortNodePosition(t)}function kp(e,t,n={}){e.notify("AnimationStart",t);let i;if(Array.isArray(t)){const s=t.map(o=>nr(e,o,n));i=Promise.all(s)}else if(typeof t=="string")i=nr(e,t,n);else{const s=typeof t=="function"?Rn(e,t,n.custom):t;i=Promise.all(_l(e,s,n))}return i.then(()=>{e.notify("AnimationComplete",t)})}function yl(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 Ep=zs.length;function bl(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?bl(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<Ep;n++){const i=zs[n],s=e.props[i];(En(s)||s===!1)&&(t[i]=s)}return t}const Ap=[...Ws].reverse(),Rp=Ws.length;function Ip(e){return t=>Promise.all(t.map(({animation:n,options:i})=>kp(e,n,i)))}function Pp(e){let t=Ip(e),n=wl(),i=!0;const s=l=>(c,d)=>{var m;const u=Rn(e,d,l==="exit"?(m=e.presenceContext)==null?void 0:m.custom:void 0);if(u){const{transition:g,transitionEnd:_,...w}=u;c={...c,...w,..._}}return c};function o(l){t=l(e)}function r(l){const{props:c}=e,d=bl(e.parent)||{},u=[],m=new Set;let g={},_=1/0;for(let b=0;b<Rp;b++){const y=Ap[b],S=n[y],C=c[y]!==void 0?c[y]:d[y],I=En(C),M=y===l?S.isActive:null;M===!1&&(_=b);let D=C===d[y]&&C!==c[y]&&I;if(D&&i&&e.manuallyAnimateOnMount&&(D=!1),S.protectedKeys={...g},!S.isActive&&M===null||!C&&!S.prevProp||mi(C)||typeof C=="boolean")continue;const x=Mp(S.prevProp,C);let T=x||y===l&&S.isActive&&!D&&I||b>_&&I,f=!1;const p=Array.isArray(C)?C:[C];let h=p.reduce(s(y),{});M===!1&&(h={});const{prevResolvedValues:v={}}=S,k={...v,...h},A=R=>{T=!0,m.has(R)&&(f=!0,m.delete(R)),S.needsAnimating[R]=!0;const V=e.getValue(R);V&&(V.liveStyle=!1)};for(const R in k){const V=h[R],K=v[R];if(g.hasOwnProperty(R))continue;let N=!1;Qs(V)&&Qs(K)?N=!yl(V,K):N=V!==K,N?V!=null?A(R):m.add(R):V!==void 0&&m.has(R)?A(R):S.protectedKeys[R]=!0}S.prevProp=C,S.prevResolvedValues=h,S.isActive&&(g={...g,...h}),i&&e.blockInitialAnimation&&(T=!1),T&&(!(D&&x)||f)&&u.push(...p.map(R=>({animation:R,options:{type:y}})))}if(m.size){const b={};if(typeof c.initial!="boolean"){const y=Rn(e,Array.isArray(c.initial)?c.initial[0]:c.initial);y&&y.transition&&(b.transition=y.transition)}m.forEach(y=>{const S=e.getBaseTarget(y),C=e.getValue(y);C&&(C.liveStyle=!0),b[y]=S??null}),u.push({animation:b})}let w=!!u.length;return i&&(c.initial===!1||c.initial===c.animate)&&!e.manuallyAnimateOnMount&&(w=!1),i=!1,w?t(u):Promise.resolve()}function a(l,c){var u;if(n[l].isActive===c)return Promise.resolve();(u=e.variantChildren)==null||u.forEach(m=>{var g;return(g=m.animationState)==null?void 0:g.setActive(l,c)}),n[l].isActive=c;const d=r(l);for(const m in n)n[m].protectedKeys={};return d}return{animateChanges:r,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=wl(),i=!0}}}function Mp(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!yl(t,e):!1}function Le(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function wl(){return{animate:Le(!0),whileInView:Le(),whileHover:Le(),whileTap:Le(),whileDrag:Le(),whileFocus:Le(),exit:Le()}}class be{constructor(t){this.isMounted=!1,this.node=t}update(){}}class Lp extends be{constructor(t){super(t),t.animationState||(t.animationState=Pp(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();mi(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 Dp=0;class Op extends be{constructor(){super(...arguments),this.id=Dp++}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 Vp={animation:{Feature:Lp},exit:{Feature:Op}};function In(e,t,n,i={passive:!0}){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n)}function Pn(e){return{point:{x:e.pageX,y:e.pageY}}}const Np=e=>t=>Gs(t)&&e(t,Pn(t));function Mn(e,t,n,i){return In(e,t,Np(n),i)}function xl({top:e,left:t,right:n,bottom:i}){return{x:{min:t,max:n},y:{min:e,max:i}}}function Bp({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Fp(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 Sl=1e-4,jp=1-Sl,$p=1+Sl,Cl=.01,Up=0-Cl,Gp=0+Cl;function Et(e){return e.max-e.min}function Hp(e,t,n){return Math.abs(e-t)<=n}function Tl(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<=$p||isNaN(e.scale))&&(e.scale=1),(e.translate>=Up&&e.translate<=Gp||isNaN(e.translate))&&(e.translate=0)}function Ln(e,t,n,i){Tl(e.x,t.x,n.x,i?i.originX:void 0),Tl(e.y,t.y,n.y,i?i.originY:void 0)}function kl(e,t,n){e.min=n.min+t.min,e.max=e.min+Et(t)}function Wp(e,t,n){kl(e.x,t.x,n.x),kl(e.y,t.y,n.y)}function El(e,t,n){e.min=t.min-n.min,e.max=e.min+Et(t)}function Dn(e,t,n){El(e.x,t.x,n.x),El(e.y,t.y,n.y)}const Al=()=>({translate:0,scale:1,origin:0,originPoint:0}),Ze=()=>({x:Al(),y:Al()}),Rl=()=>({min:0,max:0}),_t=()=>({x:Rl(),y:Rl()});function $t(e){return[e("x"),e("y")]}function ir(e){return e===void 0||e===1}function sr({scale:e,scaleX:t,scaleY:n}){return!ir(e)||!ir(t)||!ir(n)}function De(e){return sr(e)||Il(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Il(e){return Pl(e.x)||Pl(e.y)}function Pl(e){return e&&e!=="0%"}function _i(e,t,n){const i=e-n,s=t*i;return n+s}function Ml(e,t,n,i,s){return s!==void 0&&(e=_i(e,s,i)),_i(e,n,i)+t}function rr(e,t=0,n=1,i,s){e.min=Ml(e.min,t,n,i,s),e.max=Ml(e.max,t,n,i,s)}function Ll(e,{x:t,y:n}){rr(e.x,t.translate,t.scale,t.originPoint),rr(e.y,n.translate,n.scale,n.originPoint)}const Dl=.999999999999,Ol=1.0000000000001;function zp(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&&Qe(e,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),r&&(t.x*=r.x.scale,t.y*=r.y.scale,Ll(e,r)),i&&De(o.latestValues)&&Qe(e,o.latestValues))}t.x<Ol&&t.x>Dl&&(t.x=1),t.y<Ol&&t.y>Dl&&(t.y=1)}function Je(e,t){e.min=e.min+t,e.max=e.max+t}function Vl(e,t,n,i,s=.5){const o=mt(e.min,e.max,s);rr(e,t,n,o,i)}function Qe(e,t){Vl(e.x,t.x,t.scaleX,t.scale,t.originX),Vl(e.y,t.y,t.scaleY,t.scale,t.originY)}function Nl(e,t){return xl(Fp(e.getBoundingClientRect(),t))}function qp(e,t,n){const i=Nl(e,n),{scroll:s}=t;return s&&(Je(i.x,s.offset.x),Je(i.y,s.offset.y)),i}const Bl=({current:e})=>e?e.ownerDocument.defaultView:null,Fl=(e,t)=>Math.abs(e-t);function Kp(e,t){const n=Fl(e.x,t.x),i=Fl(e.y,t.y);return Math.sqrt(n**2+i**2)}class jl{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 m=ar(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,_=Kp(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!_)return;const{point:w}=m,{timestamp:b}=St;this.history.push({...w,timestamp:b});const{onStart:y,onMove:S}=this.handlers;g||(y&&y(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,m)},this.handlePointerMove=(m,g)=>{this.lastMoveEvent=m,this.lastMoveEventInfo=or(g,this.transformPagePoint),ut.update(this.updatePoint,!0)},this.handlePointerUp=(m,g)=>{this.end();const{onEnd:_,onSessionEnd:w,resumeAnimation:b}=this.handlers;if(this.dragSnapToOrigin&&b&&b(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=ar(m.type==="pointercancel"?this.lastMoveEventInfo:or(g,this.transformPagePoint),this.history);this.startEvent&&_&&_(m,y),w&&w(m,y)},!Gs(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=i,this.distanceThreshold=r,this.contextWindow=s||window;const a=Pn(t),l=or(a,this.transformPagePoint),{point:c}=l,{timestamp:d}=St;this.history=[{...c,timestamp:d}];const{onSessionStart:u}=n;u&&u(t,ar(l,this.history)),this.removeListeners=vn(Mn(this.contextWindow,"pointermove",this.handlePointerMove),Mn(this.contextWindow,"pointerup",this.handlePointerUp),Mn(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),ve(this.updatePoint)}}function or(e,t){return t?{point:t(e.point)}:e}function $l(e,t){return{x:e.x-t.x,y:e.y-t.y}}function ar({point:e},t){return{point:e,delta:$l(e,Ul(t)),offset:$l(e,Xp(t)),velocity:Yp(t,.1)}}function Xp(e){return e[0]}function Ul(e){return e[e.length-1]}function Yp(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,i=null;const s=Ul(e);for(;n>=0&&(i=e[n],!(s.timestamp-i.timestamp>te(t)));)n--;if(!i)return{x:0,y:0};const o=ee(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 Zp(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 Gl(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 Jp(e,{top:t,left:n,bottom:i,right:s}){return{x:Gl(e.x,n,s),y:Gl(e.y,t,i)}}function Hl(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 Qp(e,t){return{x:Hl(e.x,t.x),y:Hl(e.y,t.y)}}function tm(e,t){let n=.5;const i=Et(e),s=Et(t);return s>i?n=_n(t.min,t.max-i,e.min):i>s&&(n=_n(e.min,e.max-s,t.min)),de(0,1,n)}function em(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 lr=.35;function nm(e=lr){return e===!1?e=0:e===!0&&(e=lr),{x:Wl(e,"left","right"),y:Wl(e,"top","bottom")}}function Wl(e,t,n){return{min:zl(e,t),max:zl(e,n)}}function zl(e,t){return typeof e=="number"?e:e[t]||0}const im=new WeakMap;class sm{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:m}=this.getProps();m?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Pn(u).point)},r=(u,m)=>{const{drag:g,dragPropagation:_,onDragStart:w}=this.getProps();if(g&&!_&&(this.openDragLock&&this.openDragLock(),this.openDragLock=_f(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),$t(y=>{let S=this.getAxisMotionValue(y).get()||0;if(ne.test(S)){const{projection:C}=this.visualElement;if(C&&C.layout){const I=C.layout.layoutBox[y];I&&(S=Et(I)*(parseFloat(S)/100))}}this.originPoint[y]=S}),w&&ut.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:_,onDirectionLock:w,onDrag:b}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:y}=m;if(_&&this.currentDirection===null){this.currentDirection=rm(y),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",m.point,y),this.updateAxis("y",m.point,y),this.visualElement.render(),b&&b(u,m)},l=(u,m)=>{this.latestPointerEvent=u,this.latestPanInfo=m,this.stop(u,m),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>$t(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 jl(t,{onSessionStart:o,onStart:r,onMove:a,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:i,contextWindow:Bl(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||!yi(t,s,this.currentDirection))return;const o=this.getAxisMotionValue(t);let r=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(r=Zp(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&&Ye(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&i?this.constraints=Jp(i.layoutBox,t):this.constraints=!1,this.elastic=nm(n),s!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&$t(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=em(i.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Ye(t))return!1;const i=t.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;const o=qp(i,s.root,this.visualElement.getTransformPagePoint());let r=Qp(s.layout.layoutBox,o);if(n){const a=n(Bp(r));this.hasMutatedConstraints=!!a,a&&(r=xl(a))}return r}startAnimation(t){const{drag:n,dragMomentum:i,dragElastic:s,dragTransition:o,dragSnapToOrigin:r,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},c=$t(d=>{if(!yi(d,n,this.currentDirection))return;let u=l&&l[d]||{};r&&(u={min:0,max:0});const m=s?200:1e6,g=s?40:1e7,_={type:"inertia",velocity:i?t[d]:0,bounceStiffness:m,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 tr(this.visualElement,t),i.start(er(t,i,0,n,this.visualElement,!1))}stopAnimation(){$t(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){$t(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){$t(n=>{const{drag:i}=this.getProps();if(!yi(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(!Ye(n)||!i||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};$t(r=>{const a=this.getAxisMotionValue(r);if(a&&this.constraints!==!1){const l=a.get();s[r]=tm({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(),$t(r=>{if(!yi(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;im.set(this.visualElement,this);const t=this.visualElement.current,n=Mn(t,"pointerdown",l=>{const{drag:c,dragListener:d=!0}=this.getProps();c&&d&&this.start(l)}),i=()=>{const{dragConstraints:l}=this.getProps();Ye(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=In(window,"resize",()=>this.scalePositionWithinConstraints()),a=s.addEventListener("didUpdate",({delta:l,hasLayoutChanged:c})=>{this.isDragging&&c&&($t(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=lr,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:i,dragPropagation:s,dragConstraints:o,dragElastic:r,dragMomentum:a}}}function yi(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function rm(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class om extends be{constructor(t){super(t),this.removeGroupControls=jt,this.removeListeners=jt,this.controls=new sm(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||jt}unmount(){this.removeGroupControls(),this.removeListeners()}}const ql=e=>(t,n)=>{e&&ut.postRender(()=>e(t,n))};class am extends be{constructor(){super(...arguments),this.removePointerDownListener=jt}onPointerDown(t){this.session=new jl(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Bl(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:i,onPanEnd:s}=this.node.getProps();return{onSessionStart:ql(t),onStart:ql(n),onMove:i,onEnd:(o,r)=>{delete this.session,s&&ut.postRender(()=>s(o,r))}}}mount(){this.removePointerDownListener=Mn(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 bi={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Kl(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const On={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(U.test(e))e=parseFloat(e);else return e;const n=Kl(e,t.target.x),i=Kl(e,t.target.y);return`${n}% ${i}%`}},lm={correct:(e,{treeScale:t,projectionDelta:n})=>{const i=e,s=ye.parse(e);if(s.length>5)return i;const o=ye.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 Xl=!1;class cm extends zt{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i,layoutId:s}=this.props,{projection:o}=t;qf(um),o&&(n.group&&n.group.add(o),i&&i.register&&s&&i.register(o),Xl&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),bi.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:i,drag:s,isPresent:o}=this.props,{projection:r}=i;return r&&(r.isPresent=o,Xl=!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(),Us.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 Yl(e){const[t,n]=Ja(),i=wt(is);return L(cm,{...e,layoutGroup:i,switchLayoutGroup:wt(al),isPresent:t,safeToRemove:n})}const um={borderRadius:{...On,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:On,borderTopRightRadius:On,borderBottomLeftRadius:On,borderBottomRightRadius:On,boxShadow:lm};function dm(e,t,n){const i=Tt(e)?e:Ke(e);return i.start(er("",i,t,n)),i.animation}const hm=(e,t)=>e.depth-t.depth;class fm{constructor(){this.children=[],this.isDirty=!1}add(t){rs(this.children,t),this.isDirty=!0}remove(t){os(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(hm),this.isDirty=!1,this.children.forEach(t)}}function pm(e,t){const n=Mt.now(),i=({timestamp:s})=>{const o=s-n;o>=t&&(ve(i),e(o-t))};return ut.setup(i,!0),()=>ve(i)}const Zl=["TopLeft","TopRight","BottomLeft","BottomRight"],mm=Zl.length,Jl=e=>typeof e=="string"?parseFloat(e):e,Ql=e=>typeof e=="number"||U.test(e);function gm(e,t,n,i,s,o){s?(e.opacity=mt(0,n.opacity??1,vm(i)),e.opacityExit=mt(t.opacity??1,0,_m(i))):o&&(e.opacity=mt(t.opacity??1,n.opacity??1,i));for(let r=0;r<mm;r++){const a=`border${Zl[r]}Radius`;let l=tc(t,a),c=tc(n,a);if(l===void 0&&c===void 0)continue;l||(l=0),c||(c=0),l===0||c===0||Ql(l)===Ql(c)?(e[a]=Math.max(mt(Jl(l),Jl(c),i),0),(ne.test(c)||ne.test(l))&&(e[a]+="%")):e[a]=c}(t.rotate||n.rotate)&&(e.rotate=mt(t.rotate||0,n.rotate||0,i))}function tc(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const vm=ec(0,.5,Qo),_m=ec(.5,.95,jt);function ec(e,t,n){return i=>i<e?0:i>t?1:n(_n(e,t,i))}function nc(e,t){e.min=t.min,e.max=t.max}function Ut(e,t){nc(e.x,t.x),nc(e.y,t.y)}function ic(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function sc(e,t,n,i,s){return e-=t,e=_i(e,1/n,i),s!==void 0&&(e=_i(e,1/s,i)),e}function ym(e,t=0,n=1,i=.5,s,o=e,r=e){if(ne.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=sc(e.min,t,n,a,s),e.max=sc(e.max,t,n,a,s)}function rc(e,t,[n,i,s],o,r){ym(e,t[n],t[i],t[s],t.scale,o,r)}const bm=["x","scaleX","originX"],wm=["y","scaleY","originY"];function oc(e,t,n,i){rc(e.x,t,bm,n?n.x:void 0,i?i.x:void 0),rc(e.y,t,wm,n?n.y:void 0,i?i.y:void 0)}function ac(e){return e.translate===0&&e.scale===1}function lc(e){return ac(e.x)&&ac(e.y)}function cc(e,t){return e.min===t.min&&e.max===t.max}function xm(e,t){return cc(e.x,t.x)&&cc(e.y,t.y)}function uc(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function dc(e,t){return uc(e.x,t.x)&&uc(e.y,t.y)}function hc(e){return Et(e.x)/Et(e.y)}function fc(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class Sm{constructor(){this.members=[]}add(t){rs(this.members,t),t.scheduleRender()}remove(t){if(os(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 Cm(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:m,skewX:g,skewY:_}=n;c&&(i=`perspective(${c}px) ${i}`),d&&(i+=`rotate(${d}deg) `),u&&(i+=`rotateX(${u}deg) `),m&&(i+=`rotateY(${m}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 cr=["","X","Y","Z"],Tm=1e3;let km=0;function ur(e,t,n,i){const{latestValues:s}=t;s[e]&&(n[e]=s[e],t.setStaticValue(e,0),i&&(i[e]=0))}function pc(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=vl(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&&pc(i)}function mc({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:i,resetTransform:s}){return class{constructor(r={},a=t==null?void 0:t()){this.id=km++,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(Rm),this.nodes.forEach(Lm),this.nodes.forEach(Dm),this.nodes.forEach(Im)},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 fm)}addEventListener(r,a){return this.eventHandlers.has(r)||this.eventHandlers.set(r,new cs),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=Za(r)&&!Cf(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 m=()=>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=pm(m,250),bi.hasAnimatedSinceResize&&(bi.hasAnimatedSinceResize=!1,this.nodes.forEach(_c)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&c&&(a||l)&&this.addEventListener("didUpdate",({delta:d,hasLayoutChanged:u,hasRelativeLayoutChanged:m,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const _=this.options.transition||c.getDefaultTransition()||Fm,{onLayoutAnimationStart:w,onLayoutAnimationComplete:b}=c.getProps(),y=!this.targetLayout||!dc(this.targetLayout,g),S=!u&&m;if(this.options.layoutRoot||this.resumeFrom||S||u&&(y||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const C={...Fs(_,"layout"),onPlay:w,onComplete:b};(c.shouldReduceMotion||this.options.layoutRoot)&&(C.delay=0,C.type=!1),this.startAnimation(C),this.setAnimationOrigin(d,S)}else u||_c(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(),ve(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(Om),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&&pc(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(gc);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(vc);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Mm),this.nodes.forEach(Em),this.nodes.forEach(Am)):this.nodes.forEach(vc),this.clearAllSnapshots();const a=Mt.now();St.delta=de(0,1e3/60,a-St.timestamp),St.timestamp=a,St.isProcessing=!0,hs.update.process(St),hs.preRender.process(St),hs.render.process(St),St.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Us.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Pm),this.sharedNodes.forEach(Vm)}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&&!lc(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,d=c!==this.prevTransformTemplateValue;r&&this.instance&&(a||De(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($m))){const{scroll:d}=this.root;d&&(Je(a.x,d.offset.x),Je(a.y,d.offset.y))}return a}removeElementScroll(r){var l;const a=_t();if(Ut(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:m}=d;d!==this.root&&u&&m.layoutScroll&&(u.wasRoot&&Ut(a,r),Je(a.x,u.offset.x),Je(a.y,u.offset.y))}return a}applyTransform(r,a=!1){const l=_t();Ut(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&&Qe(l,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),De(d.latestValues)&&Qe(l,d.latestValues)}return De(this.latestValues)&&Qe(l,this.latestValues),l}removeTransform(r){const a=_t();Ut(a,r);for(let l=0;l<this.path.length;l++){const c=this.path[l];if(!c.instance||!De(c.latestValues))continue;sr(c.latestValues)&&c.updateSnapshot();const d=_t(),u=c.measurePageBox();Ut(d,u),oc(a,c.latestValues,c.snapshot?c.snapshot.layoutBox:void 0,d)}return De(this.latestValues)&&oc(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 m;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||(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=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(),Dn(this.relativeTargetOrigin,this.layout.layoutBox,g.layout.layoutBox),Ut(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(),Wp(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Ut(this.target,this.layout.layoutBox),Ll(this.target,this.targetDelta)):Ut(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(),Dn(this.relativeTargetOrigin,this.target,g.target),Ut(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||sr(this.parent.latestValues)||Il(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;Ut(this.layoutCorrected,this.layout.layoutBox);const u=this.treeScale.x,m=this.treeScale.y;zp(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():(ic(this.prevProjectionDelta.x,this.projectionDelta.x),ic(this.prevProjectionDelta.y,this.projectionDelta.y)),Ln(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==u||this.treeScale.y!==m||!fc(this.projectionDelta.x,this.prevProjectionDelta.x)||!fc(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=Ze(),this.projectionDelta=Ze(),this.projectionDeltaWithTransform=Ze()}setAnimationOrigin(r,a=!1){const l=this.snapshot,c=l?l.latestValues:{},d={...this.latestValues},u=Ze();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const m=_t(),g=l?l.source:void 0,_=this.layout?this.layout.source:void 0,w=g!==_,b=this.getStack(),y=!b||b.members.length<=1,S=!!(w&&!y&&this.options.crossfade===!0&&!this.path.some(Bm));this.animationProgress=0;let C;this.mixTargetDelta=I=>{const M=I/1e3;yc(u.x,r.x,M),yc(u.y,r.y,M),this.setTargetDelta(u),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Dn(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Nm(this.relativeTarget,this.relativeTargetOrigin,m,M),C&&xm(this.relativeTarget,C)&&(this.isProjectionDirty=!1),C||(C=_t()),Ut(C,this.relativeTarget)),w&&(this.animationValues=d,gm(d,c,this.latestValues,M,S,y)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=M},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&&(ve(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ut.update(()=>{bi.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Ke(0)),this.currentAnimation=dm(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(Tm),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&&Cc(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 m=Et(this.layout.layoutBox.y);l.y.min=r.target.y.min,l.y.max=l.y.min+m}Ut(a,l),Qe(a,d),Ln(this.projectionDeltaWithTransform,this.layoutCorrected,a,d)}}registerSharedNode(r,a){this.sharedNodes.has(r)||this.sharedNodes.set(r,new Sm),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&&ur("z",r,c,this.animationValues);for(let d=0;d<cr.length;d++)ur(`rotate${cr[d]}`,r,c,this.animationValues),ur(`skew${cr[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=vi(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=vi(a==null?void 0:a.pointerEvents)||""),this.hasProjected&&!De(this.latestValues)&&(r.transform=l?l({},""):"none",this.hasProjected=!1);return}r.visibility="";const d=c.animationValues||c.latestValues;this.applyTransformsToTarget();let u=Cm(this.projectionDeltaWithTransform,this.treeScale,d);l&&(u=l(d,u)),r.transform=u;const{x:m,y:g}=this.projectionDelta;r.transformOrigin=`${m.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 An){if(d[_]===void 0)continue;const{correct:w,applyTo:b,isCSSVariable:y}=An[_],S=u==="none"?d[_]:w(d[_],c);if(b){const C=b.length;for(let I=0;I<C;I++)r[b[I]]=S}else y?this.options.visualElement.renderState.vars[_]=S:r[_]=S}this.options.layoutId&&(r.pointerEvents=c===this?vi(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(gc),this.root.sharedNodes.clear()}}}function Em(e){e.updateLayout()}function Am(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"?$t(u=>{const m=r?t.measuredBox[u]:t.layoutBox[u],g=Et(m);m.min=i[u].min,m.max=m.min+g}):Cc(o,t.layoutBox,i)&&$t(u=>{const m=r?t.measuredBox[u]:t.layoutBox[u],g=Et(i[u]);m.max=m.min+g,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[u].max=e.relativeTarget[u].min+g)});const a=Ze();Ln(a,i,t.layoutBox);const l=Ze();r?Ln(l,e.applyTransform(s,!0),t.measuredBox):Ln(l,i,t.layoutBox);const c=!lc(a);let d=!1;if(!e.resumeFrom){const u=e.getClosestProjectingParent();if(u&&!u.resumeFrom){const{snapshot:m,layout:g}=u;if(m&&g){const _=_t();Dn(_,t.layoutBox,m.layoutBox);const w=_t();Dn(w,i,g.layoutBox),dc(_,w)||(d=!0),u.options.layoutRoot&&(e.relativeTarget=w,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 Rm(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 Im(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Pm(e){e.clearSnapshot()}function gc(e){e.clearMeasurements()}function vc(e){e.isLayoutDirty=!1}function Mm(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function _c(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Lm(e){e.resolveTargetDelta()}function Dm(e){e.calcProjection()}function Om(e){e.resetSkewAndRotation()}function Vm(e){e.removeLeadSnapshot()}function yc(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 bc(e,t,n,i){e.min=mt(t.min,n.min,i),e.max=mt(t.max,n.max,i)}function Nm(e,t,n,i){bc(e.x,t.x,n.x,i),bc(e.y,t.y,n.y,i)}function Bm(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const Fm={duration:.45,ease:[.4,0,.1,1]},wc=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),xc=wc("applewebkit/")&&!wc("chrome/")?Math.round:jt;function Sc(e){e.min=xc(e.min),e.max=xc(e.max)}function jm(e){Sc(e.x),Sc(e.y)}function Cc(e,t,n){return e==="position"||e==="preserve-aspect"&&!Hp(hc(t),hc(n),.2)}function $m(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const Um=mc({attachResizeListener:(e,t)=>In(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),dr={current:void 0},Tc=mc({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!dr.current){const e=new Um({});e.mount(window),e.setOptions({layoutScroll:!0}),dr.current=e}return dr.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Gm={pan:{Feature:am},drag:{Feature:om,ProjectionNode:Tc,MeasureLayout:Yl}};function kc(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,Pn(t)))}class Hm extends be{mount(){const{current:t}=this.node;t&&(this.unmount=yf(t,(n,i)=>(kc(this.node,i,"Start"),s=>kc(this.node,s,"End"))))}unmount(){}}class Wm extends be{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=vn(In(this.node.current,"focus",()=>this.onFocus()),In(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Ec(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,Pn(t)))}class zm extends be{mount(){const{current:t}=this.node;t&&(this.unmount=Sf(t,(n,i)=>(Ec(this.node,i,"Start"),(s,{success:o})=>Ec(this.node,s,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const hr=new WeakMap,fr=new WeakMap,qm=e=>{const t=hr.get(e.target);t&&t(e)},Km=e=>{e.forEach(qm)};function Xm({root:e,...t}){const n=e||document;fr.has(n)||fr.set(n,{});const i=fr.get(n),s=JSON.stringify(t);return i[s]||(i[s]=new IntersectionObserver(Km,{root:e,...t})),i[s]}function Ym(e,t,n){const i=Xm(t);return hr.set(e,n),i.observe(e),()=>{hr.delete(e),i.unobserve(e)}}const Zm={some:0,all:1};class Jm extends be{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:Zm[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(),m=c?d:u;m&&m(l)};return Ym(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(Qm(t,n))&&this.startObserver()}unmount(){}}function Qm({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const tg={inView:{Feature:Jm},tap:{Feature:zm},focus:{Feature:Wm},hover:{Feature:Hm}},eg={layout:{ProjectionNode:Tc,MeasureLayout:Yl}},pr={current:null},Ac={current:!1};function ng(){if(Ac.current=!0,!!ss)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>pr.current=e.matches;e.addEventListener("change",t),t()}else pr.current=!1}const ig=new WeakMap;function sg(e,t,n){for(const i in t){const s=t[i],o=n[i];if(Tt(s))e.addValue(i,s);else if(Tt(o))e.addValue(i,Ke(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,Ke(r!==void 0?r:s,{owner:e}))}}for(const i in n)t[i]===void 0&&e.removeValue(i);return t}const Rc=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class rg{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=Ns,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=Mt.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,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=gi(n),this.isVariantNode=sl(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:d,...u}=this.scrapeMotionValuesFromProps(n,{},this);for(const m in u){const g=u[m];l[m]!==void 0&&Tt(g)&&g.set(l[m],!1)}}mount(t){this.current=t,ig.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)),Ac.current||ng(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:pr.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),ve(this.notifyUpdate),ve(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=qe.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 Xe){const n=Xe[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<Rc.length;i++){const s=Rc[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=sg(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=Ke(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"&&(Go(i)||Wo(i))?i=parseFloat(i):!kf(i)&&ye.test(n)&&(i=Ua(t,n)),this.setBaseTarget(t,Tt(i)?i.get():i)),Tt(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=Zs(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&&!Tt(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 cs),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}}class Ic extends rg{constructor(){super(...arguments),this.KeyframeResolver=pf}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;Tt(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Pc(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 og(e){return window.getComputedStyle(e)}class ag extends Ic{constructor(){super(...arguments),this.type="html",this.renderInstance=Pc}readValueFromInstance(t,n){var i;if(qe.has(n))return(i=this.projection)!=null&&i.isProjecting?Ms(n):Lh(t,n);{const s=og(t),o=(fs(n)?s.getPropertyValue(n):s[n])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(t,{transformPagePoint:n}){return Nl(t,n)}build(t,n,i){Ks(t,n,i.transformTemplate)}scrapeMotionValuesFromProps(t,n,i){return Js(t,n,i)}}const Mc=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 lg(e,t,n,i){Pc(e,t,void 0,i);for(const s in t.attrs)e.setAttribute(Mc.has(s)?s:qs(s),t.attrs[s])}class cg extends Ic{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=_t}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(qe.has(n)){const i=$a(n);return i&&i.default||0}return n=Mc.has(n)?n:qs(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,i){return gl(t,n,i)}build(t,n,i){dl(t,n,this.isSVGTag,i.transformTemplate,i.style)}renderInstance(t,n,i,s){lg(t,n,i,s)}mount(t){this.isSVGTag=fl(t.tagName),super.mount(t)}}const ug=(e,t)=>Ys(e)?new cg(t):new ag(t,{allowProjection:e!==ue}),dg=up({...Vp,...tg,...Gm,...eg},ug),Vn=Vf(dg),Lc=({stream:e})=>{const t=Ft(null);return qt(()=>{!t.current||!e||(t.current.srcObject=e)},[e]),L("audio",{muted:!0,ref:t,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 hg="4.5.1",mr=Math.PI,tn=2*mr,gr=mr/2,Dc=8.17579892,Oc="dual-combined",bi="dual-horizontal",fe="single",ie="dual-vertical",Vc="bar-index",Nc="bar-level",wi="gradient",Bc=60,Fc="click",fg="fullscreenchange",jc="resize",pg="#111",$c="",Uc="A",Gc="B",Hc="C",Wc="D",zc="468",xi="sans-serif",mg="#0f0",gg="#7f7f7f22",en=10,qc="create",Kc="fschange",vg="lores",_g=jc,vr="user",yg="#000c",Xc="#fff",bg="#4f4",Yc="#888",wg="#555",_r="bark",Vn="linear",nn="log",yr="mel",Zc=["#a35","#c66","#e94","#ed0","#9d5","#4d8","#2cb","#0bc","#09c","#36b"],Jc=[["classic",{colorStops:["red",{color:"yellow",level:.85,pos:.6},{color:"lime",level:.475}]}],["prism",{colorStops:Zc}],["rainbow",{dir:"h",colorStops:["#817",...Zc,"#639"]}],["orangered",{bgColor:"#3e2f29",colorStops:["OrangeRed"]}],["steelblue",{bgColor:"#222c35",colorStops:["SteelBlue"]}]],Nn={alphaBars:!1,ansiBands:!1,barSpace:.1,bgAlpha:.7,channelLayout:fe,colorMode:wi,fadePeaks:!1,fftSize:8192,fillAlpha:1,frequencyScale:nn,gradient:Jc[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:$c,width:void 0},xg=["ERR_AUDIO_CONTEXT_FAIL","Could not create audio context. Web Audio API not supported?"],Sg=["ERR_INVALID_AUDIO_CONTEXT","Provided audio context is not valid"],Cg=["ERR_UNKNOWN_GRADIENT","Unknown gradient"],br=["ERR_FREQUENCY_TOO_LOW","Frequency values must be >= 1"],Tg=["ERR_INVALID_MODE","Invalid mode"],kg=["ERR_REFLEX_OUT_OF_RANGE","Reflex ratio must be >= 0 and < 1"],Ag=["ERR_INVALID_AUDIO_SOURCE","Audio source must be an instance of HTMLMediaElement or AudioNode"],Eg=["ERR_GRADIENT_INVALID_NAME","Gradient name must be a non-empty string"],Rg=["ERR_GRADIENT_NOT_AN_OBJECT","Gradient options must be an object"],Ig=["ERR_GRADIENT_MISSING_COLOR","Gradient colorStops must be a non-empty array"];class Ut extends Error{constructor(t,n){const[i,s]=t;super(s+(n!==void 0?`: ${n}`:"")),this.name="AudioMotionError",this.code=i}}const Qc=(e,t)=>console.warn(`${e} is deprecated. Use ${t} instead.`),tu=e=>{for(const t in e)return!1;return!0},Si=(e,t,n="toLowerCase")=>t[Math.max(0,t.indexOf((""+e)[n]()))],Pg=(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 Lg{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||(tu(n)&&!tu(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,m]of Jc)this.registerGradient(u,m);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 Ut(xg)}}if(!s.createGain)throw new Ut(Sg);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(_g),this._fsTimeout=0)},Bc))};window.ResizeObserver&&(this._observer=new ResizeObserver(l),this._observer.observe(this._container)),this._controller=new AbortController;const c=this._controller.signal;window.addEventListener(jc,l,{signal:c}),i.addEventListener(fg,()=>{this._fsChanging=!0,this._fsTimeout&&window.clearTimeout(this._fsTimeout),this._setCanvas(Kc),this._fsTimeout=window.setTimeout(()=>{this._fsChanging=!1,this._fsTimeout=0},Bc)},{signal:c});const d=()=>{s.state=="suspended"&&s.resume().then(()=>window.removeEventListener(Fc,d))};window.addEventListener(Fc,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(qc)}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=Si(t,[fe,bi,ie,Oc]),this._input.disconnect(),this._input.connect(this._chLayout!=fe?this._splitter:this._analyzer[0]),this._analyzer[0].disconnect(),this._outNodes.length&&this._analyzer[0].connect(this._chLayout!=fe?this._merger:this._output),this._calcBars(),this._makeGrad()}get colorMode(){return this._colorMode}set colorMode(t){this._colorMode=Si(t,[wi,Vc,Nc])}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=Si(t,[nn,_r,yr,Vn]),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||Nn.gravity}get height(){return this._height}set height(t){this._height=t,this._setCanvas(vr)}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(vg)}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 Ut(br);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 Ut(br);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 Ut(Tg,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||Nn.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 Ut(kg);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=-gr),this._spinSpeed=t}get splitGradient(){return this._splitGradient}set splitGradient(t){this._splitGradient=!!t,this._makeGrad()}get stereo(){return Qc("stereo","channelLayout"),this._chLayout!=fe}set stereo(t){Qc("stereo","channelLayout"),this.channelLayout=t?ie:fe}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=Si(t,[$c,Uc,Gc,Hc,Wc,zc],"toUpperCase")}get width(){return this._width}set width(t){this._width=t,this._setCanvas(vr)}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 hg}connectInput(t){const n=t instanceof HTMLMediaElement;if(!(n||t.connect))throw new Ut(Ag);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==fe&&!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==fe?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(Nn))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 Ut(Eg);if(typeof n!="object")throw new Ut(Rg);const{colorStops:i}=n;if(!Array.isArray(i)||!i.length)throw new Ut(Ig);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||pg,dir:n.dir,colorStops:i},this._selectedGrads.includes(t)&&this._makeGrad()}setCanvasSize(t,n){this._width=t,this._height=n,this._setCanvas(vr)}setFreqRange(t,n){if(t<1||n<1)throw new Ut(br);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:m}=this,g=s.width>>1,_=s.height>>1,w=o==ie&&!d,b=o==bi,y=c%10!=0,S=y&&this._frequencyScale==nn,C=this._showLeds&&y&&!d,I=this._lumiBars&&y&&!d,L=this._alphaBars&&!I&&c!=en,D=this._outlineBars&&y&&!I&&!C,x=this._roundBars&&y&&!I&&!C,T=o!=ie||m>0&&!I,f=s.height-(w&&!C?.5:0)>>w,p=f*(I||d?1:1-m)|0,h=s.width-g*(b||l!=0),v=w?s.height-f*2:0,k=g*(l==-1&&!b&&!d);let E=Math.min(s.width,s.height)*.375*(o==ie?1:this._radius)|0,A=Math.min(g,_);u&&o!=ie&&([E,A]=[A,E]);const P=W=>t.push({...W,peak:[0,0],hold:[0],alpha:[0],value:[0]}),R=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 V,K,N;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,oe=st/10**it;let Xt=1;for(;Xt<ft.length&&oe>ft[Xt];)Xt++;return oe-ft[Xt-1]<ft[Xt]-oe&&Xt--,(ft[Xt]*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):Dc;do{let st=It;const ft=W(st/dt,4,!0),it=W(st*dt,4,!0),[oe,Xt]=R(ft),[qn,ae]=R(it);n?st=Z<4?Y(st):W(st,st.toString()[0]<5?3:2):st=W(st,4,!0),st>=a&&P({posX:0,freq:st,freqLo:ft,freqHi:it,binLo:oe,binHi:qn,ratioLo:Xt,ratioHi:ae}),It*=tt}while(It<=r);V=h/t.length,t.forEach((st,ft)=>st.posX=k+ft*V);const ht=t[0],kt=t[t.length-1];K=this._freqScaling(ht.freqLo),N=h/(this._freqScaling(kt.freqHi)-K),ht.freqLo<a&&(ht.freqLo=a,[ht.binLo,ht.ratioLo]=R(a)),kt.freqHi>r&&(kt.freqHi=r,[kt.binHi,kt.ratioHi]=R(r))}else if(y){const W=[0,24,12,8,6,4,3,2,1][c]*10,Y=Z=>{switch(this._frequencyScale){case _r:return 1960/(26.81/(Z+.53)-1);case yr:return 700*(2**Z-1);case Vn:return Z}};V=h/W,K=this._freqScaling(a),N=h/(this._freqScaling(r)-K);for(let Z=0,tt=0;Z<W;Z++,tt+=V){const dt=Y(K+tt/N),It=Y(K+(tt+V/2)/N),ht=Y(K+(tt+V)/N),[kt,st]=R(dt),[ft,it]=R(ht);P({posX:k+tt,freq:It,freqLo:dt,freqHi:ht,binLo:kt,binHi:ft,ratioLo:st,ratioHi:it})}}else{V=1,K=this._freqScaling(a),N=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=k+Math.round(N*(this._freqScaling(dt)-K));if(It>Z)P({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,kt=p;if(Z){const st=2*W;let ft;ht=tt+1;do ht--,ft=kt/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,kt/st+.1|0))}T&&(kt+=Q),Z||(ht=Math.min(tt,kt/(Q*2)|0)),rt=It>=1?It:V*It,this._leds=[ht,rt,Q,kt/ht-Q]}const j=Math.min(V-1,i*(i>0&&i<1?V:1));y&&(V-=Math.max(C?rt:0,j)),t.forEach((W,Y)=>{let Z=W.posX,tt=V;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+(V==1?0:tt/2),W.width=tt});const lt=[];for(const W of[0,1]){const Y=o==ie?(f+v)*W:0,Z=Y+f,tt=Y+p-(!C||T?0:Q);lt.push({channelTop:Y,channelBottom:Z,analyzerBottom:tt})}this._aux={analyzerHeight:p,analyzerWidth:h,centerX:g,centerY:_,channelCoords:lt,channelHeight:f,channelGap:v,initialX:k,innerRadius:E,outerRadius:A,scaleMin:K,unitWidth:N},this._flg={isAlpha:L,isBands:y,isLeds:C,isLumi:I,isOctaves:S,isOutline:D,isRound:x,noLedGap:T},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:m}=this,g=u.canvas,_=m.canvas,w=[],b=this._chLayout==bi,y=this._chLayout==ie,S=Math.min(r.width,r.height),C=["C",,"D",,"E","F",,"G",,"A",,"B"],I=S/34|0,L=g.height>>1,D=I>>1,x=L*(c?.7:1.5),T=D*(c?1:2),f=2**(1/12);if(!c&&(this._ansiBands||a!=nn))w.push(16,31.5,63,125,250,500,1e3,2e3,4e3),a==Vn?w.push(6e3,8e3,1e4,12e3,14e3,16e3,18e3,2e4,22e3):w.push(8e3,16e3);else{let A=Dc;for(let P=-1;P<11;P++)for(let R=0;R<12;R++){if(A>=this._minFreq&&A<=this._maxFreq){const V=C[R],K=V=="C";(V&&c&&!l&&!b||K)&&w.push(c?[A,V+(K?P:"")]:A)}A*=f}}_.width=_.height=Math.max(S*.15,(i<<1)+y*I);const p=_.width>>1,h=p-I*.7,v=(A,P)=>{const R=tn*(A/r.width),V=R-gr,K=h*Math.cos(V),N=h*Math.sin(V);m.save(),m.translate(p+K,p+N),m.rotate(R),m.fillText(P,0,0),m.restore()};g.width|=0,u.fillStyle=m.strokeStyle=yg,u.fillRect(0,0,g.width,g.height),m.arc(p,p,p-I/2,0,tn),m.lineWidth=I,m.stroke(),u.fillStyle=m.fillStyle=Xc,u.font=`${L}px ${xi}`,m.font=`${D}px ${xi}`,u.textAlign=m.textAlign="center";let k=-x/4,E=-T;for(const A of w){const[P,R]=Array.isArray(A)?A:[A,A<1e3?A|0:`${(A/100|0)/10}k`],V=o*(this._freqScaling(P)-s),K=g.height*.75,N=R[0]=="C",rt=L*(c&&!l&&!b?N?1.2:.6:3);if(u.fillStyle=m.fillStyle=N&&!l&&!b?bg:Xc,c){const Q=a==nn,j=a==Vn;let lt=["C"];if((Q||P>2e3||!j&&P>250||(!d||y)&&(!j&&P>125||P>1e3))&<.push("G"),(Q||P>4e3||!j&&P>500||(!d||y)&&(!j&&P>250||P>2e3))&<.push("E"),(j&&P>4e3||(!d||y)&&(Q||P>2e3||!j&&P>500))&<.push("D","F","A","B"),!lt.includes(R[0]))continue}V>=k+x/2&&V<=t&&(u.fillText(R,b&&l==-1?t-V:n+V,K,rt),(b||l&&(V>x||l==1))&&u.fillText(R,b&&l!=1?t+V:(n||r.width)-V,K,rt),k=V+Math.min(rt,u.measureText(R).width)/2),V>=E+T&&V<t-T&&(v(b&&l==1?t-V:V,R),(b||l&&(V>T||l==1))&&v(b&&l!=-1?t+V:-V,R),E=V)}}_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:m}=this._flg,{analyzerHeight:g,centerX:_,centerY:w,channelCoords:b,channelHeight:y,channelGap:S,initialX:C,innerRadius:I,outerRadius:L}=this._aux,{_bars:D,canvas:x,_canvasGradients:T,_chLayout:f,_colorMode:p,_ctx:h,_energy:v,_fadePeaks:k,fillAlpha:E,_fps:A,_linearAmplitude:P,_lineWidth:R,maxDecibels:V,minDecibels:K,_mirror:N,_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,kt=this._gravity*1e3,st=A*this._peakHoldTime/1e3,ft=f==Oc,it=f==bi,oe=f==ie,Xt=f==fe,qn=a&&this._trueLeds&&p==wi,ae=j?x.width:this._aux.analyzerWidth,Fr=C+ae,Kn=W&&this._peakLine&&rt==en,Se=j?L-I:g,x_=Se/this._pixelRatio,[S_,P_,Xn,jr]=this._leds||[];v.val>0&&A>0&&(this._spinAngle+=this._spinSpeed*tn/60/A);const C_=O=>{if(this._reflexRatio>0&&!l&&!j){let et,le;this.reflexFit||oe?(et=oe&&O==0?y+S:0,le=y-g):(et=x.height-g*2,le=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[O].channelTop,x.width,g,0,et,x.width,le),h.restore()}},T_=()=>{this.showScaleX&&(j?(h.save(),h.translate(_,w),this._spinSpeed&&h.rotate(this._spinAngle+gr),h.drawImage(dt,-dt.width>>1,-dt.width>>1),h.restore()):h.drawImage(tt,0,x.height-tt.height))},k_=O=>{const et=O**2,le=424.36,Ct=11599.29,Fi=25122.25,Ce=544496.41,pe=148693636,Ne=Be=>20*Math.log10(Be);switch(Z){case Uc:const Be=pe*et**2/((et+le)*Math.sqrt((et+Ct)*(et+Ce))*(et+pe));return 2+Ne(Be);case Gc:const Fe=pe*et*O/((et+le)*Math.sqrt(et+Fi)*(et+pe));return .17+Ne(Fe);case Hc:const Gr=pe*et/((et+le)*(et+pe));return .06+Ne(Gr);case Wc:const ji=((103791848e-2-et)**2+108076816e-2*et)/((9837328-et)**2+11723776*et),Hr=O/68966888496476e-18*Math.sqrt(ji/((et+79919.29)*(et+1345600)));return Ne(Hr);case zc:const $i=-4737338981378384e-39*O**6+2043828333606125e-30*O**4-1363894795463638e-22*et+1,je=1306612257412824e-34*O**5-2118150887518656e-26*O**3+.0005559488023498642*O,Nt=.0001246332637532143*O/Math.hypot($i,je);return 18.2+Ne(Nt)}return 0},$r=(O,et,le)=>{h.beginPath(),h.moveTo(O,et),h.lineTo(O,le),h.stroke()},Ur=O=>{if(O&&R){const et=h.globalAlpha;h.globalAlpha=1,h.stroke(),h.globalAlpha=et}},Ve=O=>Math.max(0,(O*S_|0)*(jr+Xn)-Xn),A_=O=>{v.val=O,v.peak>0&&(v.hold--,v.hold<0&&(v.peak+=v.hold*kt/ht/x.height*this._pixelRatio)),O>=v.peak&&(v.peak=O,v.hold=st)};Q&&h.clearRect(0,0,x.width,x.height);let Zu=0;const Ju=D.length,Qu=Xt?1:2;for(let O=0;O<Qu;O++){const{channelTop:et,channelBottom:le,analyzerBottom:Ct}=b[O],Fi=this._gradients[this._selectedGrads[O]],Ce=Fi.colorStops,pe=Ce.length,Ne=!lt||a&&!Q?"#000":Fi.bgColor,Be=oe&&j&&O?-1:1,Fe=!O&&N==-1||O&&N==1,Gr=!it||O&&N!=1?0:ae>>(O||!Fe),ji=it&&Fe?-1:1,Hr=()=>{const $=tt.height,H=$>>1,z=P?100:V,ct=P?0:K,bt=P?20:5,Ot=g/(z-ct),ce=N!=-1&&(!it||O==0||N==1),Te=N!=1&&(!it||O!=N);h.save(),h.fillStyle=Yc,h.font=`${H}px ${xi}`,h.textAlign="right",h.lineWidth=1;for(let ke=z;ke>ct;ke-=bt){const cn=et+(z-ke)*Ot,xt=ke%2==0|0;if(xt){const Pt=cn+H*(cn==et?.8:.35);ce&&h.fillText(ke,$*.85,Pt),Te&&h.fillText(ke,(it?ae:x.width)-$*.1,Pt),h.strokeStyle=Yc,h.setLineDash([2,4]),h.lineDashOffset=0}else h.strokeStyle=wg,h.setLineDash([2,8]),h.lineDashOffset=1;h.beginPath(),h.moveTo(C+$*xt*ce,~~cn+.5),h.lineTo(Fr-$*xt*Te,~~cn+.5),h.stroke()}h.restore()},$i=($,H)=>{const z=Yt[$]+($<Yt.length-1?(Yt[$+1]-Yt[$])*H:0);return isNaN(z)?-1/0:z},je=($,H=ji)=>H*tn*(($+Gr)/x.width)+this._spinAngle,Nt=($,H,z)=>{const ct=I+H*Be,bt=je($,z);return[_+ct*Math.cos(bt),w+ct*Math.sin(bt)]},Wr=($,H,z,ct,bt)=>{h.beginPath();for(const Ot of N&&!it?[1,-1]:[ji]){const[ce,Te]=u?[je($,Ot),je($+z,Ot)]:[];h.moveTo(...Nt($,H,Ot)),h.lineTo(...Nt($,H+ct,Ot)),u?h.arc(_,w,I+(H+ct)*Be,ce,Te,Ot!=1):h.lineTo(...Nt($+z,H+ct,Ot)),h.lineTo(...Nt($+z,H,Ot)),u&&!bt&&h.arc(_,w,I+H*Be,Te,ce,Ot==1)}Ur(bt),h.fill()},zr=($=0,H=0)=>{let z;if(p==wi&&!qn||rt==en)z=T[O];else{const ct=p==Vc?H%pe:Ce.findLastIndex(bt=>a?Ve($)<=Ve(bt.level):$<=bt.level);z=Ce[ct].color}h.fillStyle=h.strokeStyle=z};if(Y){if(it&&!j){const $=ae*(O+Fe),H=Fe?-1:1;h.setTransform(H,0,0,1,$,0)}if((!Q||lt)&&(Q&&(h.globalAlpha=this.bgAlpha),h.fillStyle=Ne,(O==0||!j&&!ft)&&h.fillRect(C,et-S,ae,(Q&&this.reflexAlpha==1?g:y)+S),h.globalAlpha=1),this.showScaleY&&!l&&!j&&(O==0||!ft)&&Hr(),a?(h.setLineDash([jr,Xn]),h.lineWidth=D[0].width):h.lineWidth=d?Math.min(R,D[0].width/2):R,h.save(),!j){const $=new Path2D;$.rect(0,et,x.width,g),h.clip($)}}let Yt=this._fftData[O];this._analyzer[O].getFloatFrequencyData(Yt),Z&&(Yt=Yt.map(($,H)=>$+k_(this._binToFreq(H)))),h.beginPath();let Yn=[];for(let $=0;$<Ju;$++){const H=D[$],{posX:z,barCenter:ct,width:bt,freq:Ot,binLo:ce,binHi:Te,ratioLo:ke,ratioHi:cn}=H;let xt=Math.max($i(ce,ke),$i(Te,cn));for(let ot=ce+1;ot<Te;ot++)Yt[ot]>xt&&(xt=Yt[ot]);if(xt=this._normalizedB(xt),H.value[O]=xt,Zu+=xt,H.peak[O]>0&&H.alpha[O]>0&&(H.hold[O]--,H.hold[O]<0)){if(k&&!Kn){const ot=!o||d&&R>0?1:o?H.peak[O]:E;H.alpha[O]=ot*(1+H.hold[O]/It)}else H.peak[O]+=H.hold[O]*kt/ht/x_;H.alpha[O]<=0&&(H.peak[O]=0)}if(xt>=H.peak[O]&&(H.peak[O]=xt,H.hold[O]=st,H.alpha[O]=!o||d&&R>0?1:o?xt:E),!Y)continue;h.globalAlpha=l||o?xt:d?E:1,zr(xt,$);const Pt=l?Se:a?Ve(xt):xt*Se|0;if(rt==en){const ot=$?0:(this._normalizedB(Yt[D[1].binLo])*Se+Pt)/2;if(j){if($==0&&(it&&h.moveTo(...Nt(0,0)),h.lineTo(...Nt(0,z<0?ot:Pt))),z>=0){const Ht=[z,Pt];h.lineTo(...Nt(...Ht)),Yn.push(Ht)}}else{if($==0)if(N==-1&&!it)h.moveTo(C,Ct-(z<C?ot:Pt));else{const Ht=ce?this._normalizedB(Yt[ce-1])*Se:Pt;h.moveTo(C-R,Ct-Ht)}(it||N!=-1||z>=C)&&h.lineTo(z,Ct-Pt)}}else if(a){if(lt&&!Q&&(O==0||!ft)){const ot=h.globalAlpha;h.strokeStyle=gg,h.globalAlpha=1,$r(ct,et,Ct),h.strokeStyle=h.fillStyle,h.globalAlpha=ot}if(qn){const ot=l?0:Ce.findLastIndex($e=>Ve(xt)<=Ve($e.level));let Ht=Ct;for(let $e=pe-1;$e>=ot;$e--){h.strokeStyle=Ce[$e].color;let ed=Ct-($e==ot?Pt:Ve(Ce[$e].level));$r(ct,Ht,ed),Ht=ed-Xn}}else $r(ct,Ct,Ct-Pt)}else if(z>=C)if(j)Wr(z,0,bt,Pt,d);else if(u){const ot=bt/2,Ht=Ct+ot;h.beginPath(),h.moveTo(z,Ht),h.lineTo(z,Ht-Pt),h.arc(ct,Ht-Pt,ot,mr,tn),h.lineTo(z+bt,Ht),Ur(d),h.fill()}else{const ot=d?h.lineWidth:0;h.beginPath(),h.rect(z,Ct+ot,bt,-Pt-ot),Ur(d),h.fill()}const un=H.peak[O],td=H.alpha[O];if(un>0&&td>0&&W&&!Kn&&!l&&z>=C&&z<Fr){if(k?h.globalAlpha=td:d&&R>0?h.globalAlpha=1:o&&(h.globalAlpha=un),(p==Nc||qn)&&zr(un),a){const ot=Ve(un);ot>=Xn&&h.fillRect(z,Ct-ot,bt,jr)}else if(!j)h.fillRect(z,Ct-un*Se,bt,2);else if(rt!=en){const ot=un*Se;Wr(z,ot,bt,!this._radialInvert||oe||ot+I>=2?-2:2)}}}if(Y){if(h.globalAlpha=1,rt==en){if(zr(),j&&!it){if(N){let $;for(;$=Yn.pop();)h.lineTo(...Nt(...$,-1))}h.closePath()}if(R>0&&h.stroke(),E>0){if(j){const $=it?je(ae>>1):0,H=it?je(ae):tn;h.moveTo(...Nt(it?ae>>1:0,0)),h.arc(_,w,I,$,H,it?!Fe:!0)}else h.lineTo(Fr,Ct),h.lineTo(C,Ct);h.globalAlpha=E,h.fill(),h.globalAlpha=1}if((Kn||j&&W)&&(Yn=[],h.beginPath(),D.forEach(($,H)=>{let z=$.posX,ct=$.peak[O],bt=H?"lineTo":"moveTo";if(j&&z<0){const Ot=D[H+1];ct=Pg(z,ct,Ot.posX,Ot.peak[O],0),z=0}ct*=Se,Kn?(h[bt](...j?Nt(z,ct):[z,Ct-ct]),j&&N&&!it&&Yn.push([z,ct])):ct>0&&Wr(z,ct,1,-2)}),Kn)){let $;for(;$=Yn.pop();)h.lineTo(...Nt(...$,-1));h.lineWidth=1,h.stroke()}}h.restore(),it&&!j&&h.setTransform(1,0,0,1,0,0),(!it&&!ft||O)&&C_(O)}}if(A_(Zu/(Ju<<Qu-1)),Y&&(N&&!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([]),T_()),this.showFPS){const O=tt.height;h.font=`bold ${O}px ${xi}`,h.fillStyle=mg,h.textAlign="right",h.fillText(Math.round(A),x.width-O,O*2)}this.onCanvasDraw&&(h.save(),h.fillStyle=h.strokeStyle=T[0],this.onCanvasDraw(this,{timestamp:t,canvasGradients:T}),h.restore())}_freqScaling(t){switch(this._frequencyScale){case nn:return Math.log2(t);case _r:return 26.81*t/(1960+t)-.53;case yr:return Math.log2(1+t/700);case Vn: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,m=this._chLayout==ie,g=1-s,_=u?t.height:t.height*(1-s*!m)|0;for(const w of[0,1]){const b=this._gradients[this._selectedGrads[w]],y=b.colorStops,S=b.dir=="h";let C;if(i?C=n.createRadialGradient(r,a,d,r,a,c-(d-c)*m):C=n.createLinearGradient(...S?[l,0,l+o,0]:[0,0,0,_]),y){const I=m&&!this._splitGradient&&(!S||i);for(let L=0;L<1+I;L++){const D=y.length-1;y.forEach((x,T)=>{let f=x.pos;if(I&&(f/=2),m&&!u&&!i&&!S&&(f*=g,!I&&f>.5*g&&(f+=.5*s)),L==1)if(i||u){const p=D-T;x=y[p],f=1-x.pos/2}else T==0&&f>0&&C.addColorStop(.5,x.color),f+=.5;C.addColorStop(f,x.color),m&&T==D&&f<.5&&C.addColorStop(.5,x.color)})}}this._canvasGradients[w]=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!=qc&&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=Kc),this._fsStatus=l,this.onCanvasResize&&this.onCanvasResize(t,this))}_setGradient(t,n){if(!this._gradients.hasOwnProperty(t))throw new Ut(Cg,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(Nn).filter(r=>r!="start").concat(i,s);(n||t===void 0)&&(t={...Nn,...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)}}function eu(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=eu(e[t]))&&(i&&(i+=" "),i+=n)}else for(n in e)e[n]&&(i&&(i+=" "),i+=n);return i}function Bn(){for(var e,t,n=0,i="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=eu(e))&&(i&&(i+=" "),i+=t);return i}const nu=({stream:e,className:t,onClick:n})=>{const i=qt(null);return zt(()=>{if(!i.current||!e)return;const s=new AudioContext,o=s.createMediaStreamSource(e),r=new Lg(i.current,{source:o,audioCtx:s,alphaBars:!1,ansiBands:!1,barSpace:.25,bgAlpha:0,channelLayout:"single",colorMode:"gradient",fadePeaks:!1,fftSize:2048,fillAlpha:0,frequencyScale:"log",gradient:"prism",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:!1,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 r.registerGradient("gradient",{colorStops:[{color:"#D3FFA6",pos:0},{color:"#036B5B",pos:.5},{color:"#D3FFA6",pos:1}]}),r.gradient="gradient",()=>{r.disconnectInput()}},[e]),M("div",{onClick:n,className:Bn("w-full",t),ref:i})},Mg=["agent-id","environment","position"],Ci="widget-layout-id";/**
|
|
16
|
+
*/const hg="4.5.1",mr=Math.PI,tn=2*mr,gr=mr/2,Dc=8.17579892,Oc="dual-combined",wi="dual-horizontal",fe="single",ie="dual-vertical",Vc="bar-index",Nc="bar-level",xi="gradient",Bc=60,Fc="click",fg="fullscreenchange",jc="resize",pg="#111",$c="",Uc="A",Gc="B",Hc="C",Wc="D",zc="468",Si="sans-serif",mg="#0f0",gg="#7f7f7f22",en=10,qc="create",Kc="fschange",vg="lores",_g=jc,vr="user",yg="#000c",Xc="#fff",bg="#4f4",Yc="#888",wg="#555",_r="bark",Nn="linear",nn="log",yr="mel",Zc=["#a35","#c66","#e94","#ed0","#9d5","#4d8","#2cb","#0bc","#09c","#36b"],Jc=[["classic",{colorStops:["red",{color:"yellow",level:.85,pos:.6},{color:"lime",level:.475}]}],["prism",{colorStops:Zc}],["rainbow",{dir:"h",colorStops:["#817",...Zc,"#639"]}],["orangered",{bgColor:"#3e2f29",colorStops:["OrangeRed"]}],["steelblue",{bgColor:"#222c35",colorStops:["SteelBlue"]}]],Bn={alphaBars:!1,ansiBands:!1,barSpace:.1,bgAlpha:.7,channelLayout:fe,colorMode:xi,fadePeaks:!1,fftSize:8192,fillAlpha:1,frequencyScale:nn,gradient:Jc[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:$c,width:void 0},xg=["ERR_AUDIO_CONTEXT_FAIL","Could not create audio context. Web Audio API not supported?"],Sg=["ERR_INVALID_AUDIO_CONTEXT","Provided audio context is not valid"],Cg=["ERR_UNKNOWN_GRADIENT","Unknown gradient"],br=["ERR_FREQUENCY_TOO_LOW","Frequency values must be >= 1"],Tg=["ERR_INVALID_MODE","Invalid mode"],kg=["ERR_REFLEX_OUT_OF_RANGE","Reflex ratio must be >= 0 and < 1"],Eg=["ERR_INVALID_AUDIO_SOURCE","Audio source must be an instance of HTMLMediaElement or AudioNode"],Ag=["ERR_GRADIENT_INVALID_NAME","Gradient name must be a non-empty string"],Rg=["ERR_GRADIENT_NOT_AN_OBJECT","Gradient options must be an object"],Ig=["ERR_GRADIENT_MISSING_COLOR","Gradient colorStops must be a non-empty array"];class Gt extends Error{constructor(t,n){const[i,s]=t;super(s+(n!==void 0?`: ${n}`:"")),this.name="AudioMotionError",this.code=i}}const Qc=(e,t)=>console.warn(`${e} is deprecated. Use ${t} instead.`),tu=e=>{for(const t in e)return!1;return!0},Ci=(e,t,n="toLowerCase")=>t[Math.max(0,t.indexOf((""+e)[n]()))],Pg=(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 Mg{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||(tu(n)&&!tu(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,m]of Jc)this.registerGradient(u,m);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 Gt(xg)}}if(!s.createGain)throw new Gt(Sg);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(_g),this._fsTimeout=0)},Bc))};window.ResizeObserver&&(this._observer=new ResizeObserver(l),this._observer.observe(this._container)),this._controller=new AbortController;const c=this._controller.signal;window.addEventListener(jc,l,{signal:c}),i.addEventListener(fg,()=>{this._fsChanging=!0,this._fsTimeout&&window.clearTimeout(this._fsTimeout),this._setCanvas(Kc),this._fsTimeout=window.setTimeout(()=>{this._fsChanging=!1,this._fsTimeout=0},Bc)},{signal:c});const d=()=>{s.state=="suspended"&&s.resume().then(()=>window.removeEventListener(Fc,d))};window.addEventListener(Fc,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(qc)}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=Ci(t,[fe,wi,ie,Oc]),this._input.disconnect(),this._input.connect(this._chLayout!=fe?this._splitter:this._analyzer[0]),this._analyzer[0].disconnect(),this._outNodes.length&&this._analyzer[0].connect(this._chLayout!=fe?this._merger:this._output),this._calcBars(),this._makeGrad()}get colorMode(){return this._colorMode}set colorMode(t){this._colorMode=Ci(t,[xi,Vc,Nc])}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=Ci(t,[nn,_r,yr,Nn]),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||Bn.gravity}get height(){return this._height}set height(t){this._height=t,this._setCanvas(vr)}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(vg)}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 Gt(br);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 Gt(br);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 Gt(Tg,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||Bn.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 Gt(kg);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=-gr),this._spinSpeed=t}get splitGradient(){return this._splitGradient}set splitGradient(t){this._splitGradient=!!t,this._makeGrad()}get stereo(){return Qc("stereo","channelLayout"),this._chLayout!=fe}set stereo(t){Qc("stereo","channelLayout"),this.channelLayout=t?ie:fe}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=Ci(t,[$c,Uc,Gc,Hc,Wc,zc],"toUpperCase")}get width(){return this._width}set width(t){this._width=t,this._setCanvas(vr)}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 hg}connectInput(t){const n=t instanceof HTMLMediaElement;if(!(n||t.connect))throw new Gt(Eg);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==fe&&!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==fe?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(Bn))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 Gt(Ag);if(typeof n!="object")throw new Gt(Rg);const{colorStops:i}=n;if(!Array.isArray(i)||!i.length)throw new Gt(Ig);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||pg,dir:n.dir,colorStops:i},this._selectedGrads.includes(t)&&this._makeGrad()}setCanvasSize(t,n){this._width=t,this._height=n,this._setCanvas(vr)}setFreqRange(t,n){if(t<1||n<1)throw new Gt(br);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:m}=this,g=s.width>>1,_=s.height>>1,w=o==ie&&!d,b=o==wi,y=c%10!=0,S=y&&this._frequencyScale==nn,C=this._showLeds&&y&&!d,I=this._lumiBars&&y&&!d,M=this._alphaBars&&!I&&c!=en,D=this._outlineBars&&y&&!I&&!C,x=this._roundBars&&y&&!I&&!C,T=o!=ie||m>0&&!I,f=s.height-(w&&!C?.5:0)>>w,p=f*(I||d?1:1-m)|0,h=s.width-g*(b||l!=0),v=w?s.height-f*2:0,k=g*(l==-1&&!b&&!d);let A=Math.min(s.width,s.height)*.375*(o==ie?1:this._radius)|0,E=Math.min(g,_);u&&o!=ie&&([A,E]=[E,A]);const P=W=>t.push({...W,peak:[0,0],hold:[0],alpha:[0],value:[0]}),R=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 V,K,N;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,oe=st/10**it;let Xt=1;for(;Xt<ft.length&&oe>ft[Xt];)Xt++;return oe-ft[Xt-1]<ft[Xt]-oe&&Xt--,(ft[Xt]*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):Dc;do{let st=It;const ft=W(st/dt,4,!0),it=W(st*dt,4,!0),[oe,Xt]=R(ft),[Kn,ae]=R(it);n?st=Z<4?Y(st):W(st,st.toString()[0]<5?3:2):st=W(st,4,!0),st>=a&&P({posX:0,freq:st,freqLo:ft,freqHi:it,binLo:oe,binHi:Kn,ratioLo:Xt,ratioHi:ae}),It*=tt}while(It<=r);V=h/t.length,t.forEach((st,ft)=>st.posX=k+ft*V);const ht=t[0],kt=t[t.length-1];K=this._freqScaling(ht.freqLo),N=h/(this._freqScaling(kt.freqHi)-K),ht.freqLo<a&&(ht.freqLo=a,[ht.binLo,ht.ratioLo]=R(a)),kt.freqHi>r&&(kt.freqHi=r,[kt.binHi,kt.ratioHi]=R(r))}else if(y){const W=[0,24,12,8,6,4,3,2,1][c]*10,Y=Z=>{switch(this._frequencyScale){case _r:return 1960/(26.81/(Z+.53)-1);case yr:return 700*(2**Z-1);case Nn:return Z}};V=h/W,K=this._freqScaling(a),N=h/(this._freqScaling(r)-K);for(let Z=0,tt=0;Z<W;Z++,tt+=V){const dt=Y(K+tt/N),It=Y(K+(tt+V/2)/N),ht=Y(K+(tt+V)/N),[kt,st]=R(dt),[ft,it]=R(ht);P({posX:k+tt,freq:It,freqLo:dt,freqHi:ht,binLo:kt,binHi:ft,ratioLo:st,ratioHi:it})}}else{V=1,K=this._freqScaling(a),N=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=k+Math.round(N*(this._freqScaling(dt)-K));if(It>Z)P({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,kt=p;if(Z){const st=2*W;let ft;ht=tt+1;do ht--,ft=kt/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,kt/st+.1|0))}T&&(kt+=Q),Z||(ht=Math.min(tt,kt/(Q*2)|0)),rt=It>=1?It:V*It,this._leds=[ht,rt,Q,kt/ht-Q]}const j=Math.min(V-1,i*(i>0&&i<1?V:1));y&&(V-=Math.max(C?rt:0,j)),t.forEach((W,Y)=>{let Z=W.posX,tt=V;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+(V==1?0:tt/2),W.width=tt});const lt=[];for(const W of[0,1]){const Y=o==ie?(f+v)*W:0,Z=Y+f,tt=Y+p-(!C||T?0:Q);lt.push({channelTop:Y,channelBottom:Z,analyzerBottom:tt})}this._aux={analyzerHeight:p,analyzerWidth:h,centerX:g,centerY:_,channelCoords:lt,channelHeight:f,channelGap:v,initialX:k,innerRadius:A,outerRadius:E,scaleMin:K,unitWidth:N},this._flg={isAlpha:M,isBands:y,isLeds:C,isLumi:I,isOctaves:S,isOutline:D,isRound:x,noLedGap:T},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:m}=this,g=u.canvas,_=m.canvas,w=[],b=this._chLayout==wi,y=this._chLayout==ie,S=Math.min(r.width,r.height),C=["C",,"D",,"E","F",,"G",,"A",,"B"],I=S/34|0,M=g.height>>1,D=I>>1,x=M*(c?.7:1.5),T=D*(c?1:2),f=2**(1/12);if(!c&&(this._ansiBands||a!=nn))w.push(16,31.5,63,125,250,500,1e3,2e3,4e3),a==Nn?w.push(6e3,8e3,1e4,12e3,14e3,16e3,18e3,2e4,22e3):w.push(8e3,16e3);else{let E=Dc;for(let P=-1;P<11;P++)for(let R=0;R<12;R++){if(E>=this._minFreq&&E<=this._maxFreq){const V=C[R],K=V=="C";(V&&c&&!l&&!b||K)&&w.push(c?[E,V+(K?P:"")]:E)}E*=f}}_.width=_.height=Math.max(S*.15,(i<<1)+y*I);const p=_.width>>1,h=p-I*.7,v=(E,P)=>{const R=tn*(E/r.width),V=R-gr,K=h*Math.cos(V),N=h*Math.sin(V);m.save(),m.translate(p+K,p+N),m.rotate(R),m.fillText(P,0,0),m.restore()};g.width|=0,u.fillStyle=m.strokeStyle=yg,u.fillRect(0,0,g.width,g.height),m.arc(p,p,p-I/2,0,tn),m.lineWidth=I,m.stroke(),u.fillStyle=m.fillStyle=Xc,u.font=`${M}px ${Si}`,m.font=`${D}px ${Si}`,u.textAlign=m.textAlign="center";let k=-x/4,A=-T;for(const E of w){const[P,R]=Array.isArray(E)?E:[E,E<1e3?E|0:`${(E/100|0)/10}k`],V=o*(this._freqScaling(P)-s),K=g.height*.75,N=R[0]=="C",rt=M*(c&&!l&&!b?N?1.2:.6:3);if(u.fillStyle=m.fillStyle=N&&!l&&!b?bg:Xc,c){const Q=a==nn,j=a==Nn;let lt=["C"];if((Q||P>2e3||!j&&P>250||(!d||y)&&(!j&&P>125||P>1e3))&<.push("G"),(Q||P>4e3||!j&&P>500||(!d||y)&&(!j&&P>250||P>2e3))&<.push("E"),(j&&P>4e3||(!d||y)&&(Q||P>2e3||!j&&P>500))&<.push("D","F","A","B"),!lt.includes(R[0]))continue}V>=k+x/2&&V<=t&&(u.fillText(R,b&&l==-1?t-V:n+V,K,rt),(b||l&&(V>x||l==1))&&u.fillText(R,b&&l!=1?t+V:(n||r.width)-V,K,rt),k=V+Math.min(rt,u.measureText(R).width)/2),V>=A+T&&V<t-T&&(v(b&&l==1?t-V:V,R),(b||l&&(V>T||l==1))&&v(b&&l!=-1?t+V:-V,R),A=V)}}_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:m}=this._flg,{analyzerHeight:g,centerX:_,centerY:w,channelCoords:b,channelHeight:y,channelGap:S,initialX:C,innerRadius:I,outerRadius:M}=this._aux,{_bars:D,canvas:x,_canvasGradients:T,_chLayout:f,_colorMode:p,_ctx:h,_energy:v,_fadePeaks:k,fillAlpha:A,_fps:E,_linearAmplitude:P,_lineWidth:R,maxDecibels:V,minDecibels:K,_mirror:N,_mode:rt,overlay:Q,_radial:j,showBgColor:lt,showPeaks:W,useCanvas:Y,_weightingFilter:Z}=this,tt=this._scaleX.canvas,dt=this._scaleR.canvas,It=E*this._peakFadeTime/1e3,ht=E**2,kt=this._gravity*1e3,st=E*this._peakHoldTime/1e3,ft=f==Oc,it=f==wi,oe=f==ie,Xt=f==fe,Kn=a&&this._trueLeds&&p==xi,ae=j?x.width:this._aux.analyzerWidth,Fr=C+ae,Xn=W&&this._peakLine&&rt==en,Se=j?M-I:g,S_=Se/this._pixelRatio,[C_,M_,Yn,jr]=this._leds||[];v.val>0&&E>0&&(this._spinAngle+=this._spinSpeed*tn/60/E);const T_=O=>{if(this._reflexRatio>0&&!l&&!j){let et,le;this.reflexFit||oe?(et=oe&&O==0?y+S:0,le=y-g):(et=x.height-g*2,le=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[O].channelTop,x.width,g,0,et,x.width,le),h.restore()}},k_=()=>{this.showScaleX&&(j?(h.save(),h.translate(_,w),this._spinSpeed&&h.rotate(this._spinAngle+gr),h.drawImage(dt,-dt.width>>1,-dt.width>>1),h.restore()):h.drawImage(tt,0,x.height-tt.height))},E_=O=>{const et=O**2,le=424.36,Ct=11599.29,Fi=25122.25,Ce=544496.41,pe=148693636,Ne=Be=>20*Math.log10(Be);switch(Z){case Uc:const Be=pe*et**2/((et+le)*Math.sqrt((et+Ct)*(et+Ce))*(et+pe));return 2+Ne(Be);case Gc:const Fe=pe*et*O/((et+le)*Math.sqrt(et+Fi)*(et+pe));return .17+Ne(Fe);case Hc:const Gr=pe*et/((et+le)*(et+pe));return .06+Ne(Gr);case Wc:const ji=((103791848e-2-et)**2+108076816e-2*et)/((9837328-et)**2+11723776*et),Hr=O/68966888496476e-18*Math.sqrt(ji/((et+79919.29)*(et+1345600)));return Ne(Hr);case zc:const $i=-4737338981378384e-39*O**6+2043828333606125e-30*O**4-1363894795463638e-22*et+1,je=1306612257412824e-34*O**5-2118150887518656e-26*O**3+.0005559488023498642*O,Nt=.0001246332637532143*O/Math.hypot($i,je);return 18.2+Ne(Nt)}return 0},$r=(O,et,le)=>{h.beginPath(),h.moveTo(O,et),h.lineTo(O,le),h.stroke()},Ur=O=>{if(O&&R){const et=h.globalAlpha;h.globalAlpha=1,h.stroke(),h.globalAlpha=et}},Ve=O=>Math.max(0,(O*C_|0)*(jr+Yn)-Yn),A_=O=>{v.val=O,v.peak>0&&(v.hold--,v.hold<0&&(v.peak+=v.hold*kt/ht/x.height*this._pixelRatio)),O>=v.peak&&(v.peak=O,v.hold=st)};Q&&h.clearRect(0,0,x.width,x.height);let Zu=0;const Ju=D.length,Qu=Xt?1:2;for(let O=0;O<Qu;O++){const{channelTop:et,channelBottom:le,analyzerBottom:Ct}=b[O],Fi=this._gradients[this._selectedGrads[O]],Ce=Fi.colorStops,pe=Ce.length,Ne=!lt||a&&!Q?"#000":Fi.bgColor,Be=oe&&j&&O?-1:1,Fe=!O&&N==-1||O&&N==1,Gr=!it||O&&N!=1?0:ae>>(O||!Fe),ji=it&&Fe?-1:1,Hr=()=>{const $=tt.height,H=$>>1,z=P?100:V,ct=P?0:K,bt=P?20:5,Ot=g/(z-ct),ce=N!=-1&&(!it||O==0||N==1),Te=N!=1&&(!it||O!=N);h.save(),h.fillStyle=Yc,h.font=`${H}px ${Si}`,h.textAlign="right",h.lineWidth=1;for(let ke=z;ke>ct;ke-=bt){const un=et+(z-ke)*Ot,xt=ke%2==0|0;if(xt){const Pt=un+H*(un==et?.8:.35);ce&&h.fillText(ke,$*.85,Pt),Te&&h.fillText(ke,(it?ae:x.width)-$*.1,Pt),h.strokeStyle=Yc,h.setLineDash([2,4]),h.lineDashOffset=0}else h.strokeStyle=wg,h.setLineDash([2,8]),h.lineDashOffset=1;h.beginPath(),h.moveTo(C+$*xt*ce,~~un+.5),h.lineTo(Fr-$*xt*Te,~~un+.5),h.stroke()}h.restore()},$i=($,H)=>{const z=Yt[$]+($<Yt.length-1?(Yt[$+1]-Yt[$])*H:0);return isNaN(z)?-1/0:z},je=($,H=ji)=>H*tn*(($+Gr)/x.width)+this._spinAngle,Nt=($,H,z)=>{const ct=I+H*Be,bt=je($,z);return[_+ct*Math.cos(bt),w+ct*Math.sin(bt)]},Wr=($,H,z,ct,bt)=>{h.beginPath();for(const Ot of N&&!it?[1,-1]:[ji]){const[ce,Te]=u?[je($,Ot),je($+z,Ot)]:[];h.moveTo(...Nt($,H,Ot)),h.lineTo(...Nt($,H+ct,Ot)),u?h.arc(_,w,I+(H+ct)*Be,ce,Te,Ot!=1):h.lineTo(...Nt($+z,H+ct,Ot)),h.lineTo(...Nt($+z,H,Ot)),u&&!bt&&h.arc(_,w,I+H*Be,Te,ce,Ot==1)}Ur(bt),h.fill()},zr=($=0,H=0)=>{let z;if(p==xi&&!Kn||rt==en)z=T[O];else{const ct=p==Vc?H%pe:Ce.findLastIndex(bt=>a?Ve($)<=Ve(bt.level):$<=bt.level);z=Ce[ct].color}h.fillStyle=h.strokeStyle=z};if(Y){if(it&&!j){const $=ae*(O+Fe),H=Fe?-1:1;h.setTransform(H,0,0,1,$,0)}if((!Q||lt)&&(Q&&(h.globalAlpha=this.bgAlpha),h.fillStyle=Ne,(O==0||!j&&!ft)&&h.fillRect(C,et-S,ae,(Q&&this.reflexAlpha==1?g:y)+S),h.globalAlpha=1),this.showScaleY&&!l&&!j&&(O==0||!ft)&&Hr(),a?(h.setLineDash([jr,Yn]),h.lineWidth=D[0].width):h.lineWidth=d?Math.min(R,D[0].width/2):R,h.save(),!j){const $=new Path2D;$.rect(0,et,x.width,g),h.clip($)}}let Yt=this._fftData[O];this._analyzer[O].getFloatFrequencyData(Yt),Z&&(Yt=Yt.map(($,H)=>$+E_(this._binToFreq(H)))),h.beginPath();let Zn=[];for(let $=0;$<Ju;$++){const H=D[$],{posX:z,barCenter:ct,width:bt,freq:Ot,binLo:ce,binHi:Te,ratioLo:ke,ratioHi:un}=H;let xt=Math.max($i(ce,ke),$i(Te,un));for(let ot=ce+1;ot<Te;ot++)Yt[ot]>xt&&(xt=Yt[ot]);if(xt=this._normalizedB(xt),H.value[O]=xt,Zu+=xt,H.peak[O]>0&&H.alpha[O]>0&&(H.hold[O]--,H.hold[O]<0)){if(k&&!Xn){const ot=!o||d&&R>0?1:o?H.peak[O]:A;H.alpha[O]=ot*(1+H.hold[O]/It)}else H.peak[O]+=H.hold[O]*kt/ht/S_;H.alpha[O]<=0&&(H.peak[O]=0)}if(xt>=H.peak[O]&&(H.peak[O]=xt,H.hold[O]=st,H.alpha[O]=!o||d&&R>0?1:o?xt:A),!Y)continue;h.globalAlpha=l||o?xt:d?A:1,zr(xt,$);const Pt=l?Se:a?Ve(xt):xt*Se|0;if(rt==en){const ot=$?0:(this._normalizedB(Yt[D[1].binLo])*Se+Pt)/2;if(j){if($==0&&(it&&h.moveTo(...Nt(0,0)),h.lineTo(...Nt(0,z<0?ot:Pt))),z>=0){const Wt=[z,Pt];h.lineTo(...Nt(...Wt)),Zn.push(Wt)}}else{if($==0)if(N==-1&&!it)h.moveTo(C,Ct-(z<C?ot:Pt));else{const Wt=ce?this._normalizedB(Yt[ce-1])*Se:Pt;h.moveTo(C-R,Ct-Wt)}(it||N!=-1||z>=C)&&h.lineTo(z,Ct-Pt)}}else if(a){if(lt&&!Q&&(O==0||!ft)){const ot=h.globalAlpha;h.strokeStyle=gg,h.globalAlpha=1,$r(ct,et,Ct),h.strokeStyle=h.fillStyle,h.globalAlpha=ot}if(Kn){const ot=l?0:Ce.findLastIndex($e=>Ve(xt)<=Ve($e.level));let Wt=Ct;for(let $e=pe-1;$e>=ot;$e--){h.strokeStyle=Ce[$e].color;let ed=Ct-($e==ot?Pt:Ve(Ce[$e].level));$r(ct,Wt,ed),Wt=ed-Yn}}else $r(ct,Ct,Ct-Pt)}else if(z>=C)if(j)Wr(z,0,bt,Pt,d);else if(u){const ot=bt/2,Wt=Ct+ot;h.beginPath(),h.moveTo(z,Wt),h.lineTo(z,Wt-Pt),h.arc(ct,Wt-Pt,ot,mr,tn),h.lineTo(z+bt,Wt),Ur(d),h.fill()}else{const ot=d?h.lineWidth:0;h.beginPath(),h.rect(z,Ct+ot,bt,-Pt-ot),Ur(d),h.fill()}const dn=H.peak[O],td=H.alpha[O];if(dn>0&&td>0&&W&&!Xn&&!l&&z>=C&&z<Fr){if(k?h.globalAlpha=td:d&&R>0?h.globalAlpha=1:o&&(h.globalAlpha=dn),(p==Nc||Kn)&&zr(dn),a){const ot=Ve(dn);ot>=Yn&&h.fillRect(z,Ct-ot,bt,jr)}else if(!j)h.fillRect(z,Ct-dn*Se,bt,2);else if(rt!=en){const ot=dn*Se;Wr(z,ot,bt,!this._radialInvert||oe||ot+I>=2?-2:2)}}}if(Y){if(h.globalAlpha=1,rt==en){if(zr(),j&&!it){if(N){let $;for(;$=Zn.pop();)h.lineTo(...Nt(...$,-1))}h.closePath()}if(R>0&&h.stroke(),A>0){if(j){const $=it?je(ae>>1):0,H=it?je(ae):tn;h.moveTo(...Nt(it?ae>>1:0,0)),h.arc(_,w,I,$,H,it?!Fe:!0)}else h.lineTo(Fr,Ct),h.lineTo(C,Ct);h.globalAlpha=A,h.fill(),h.globalAlpha=1}if((Xn||j&&W)&&(Zn=[],h.beginPath(),D.forEach(($,H)=>{let z=$.posX,ct=$.peak[O],bt=H?"lineTo":"moveTo";if(j&&z<0){const Ot=D[H+1];ct=Pg(z,ct,Ot.posX,Ot.peak[O],0),z=0}ct*=Se,Xn?(h[bt](...j?Nt(z,ct):[z,Ct-ct]),j&&N&&!it&&Zn.push([z,ct])):ct>0&&Wr(z,ct,1,-2)}),Xn)){let $;for(;$=Zn.pop();)h.lineTo(...Nt(...$,-1));h.lineWidth=1,h.stroke()}}h.restore(),it&&!j&&h.setTransform(1,0,0,1,0,0),(!it&&!ft||O)&&T_(O)}}if(A_(Zu/(Ju<<Qu-1)),Y&&(N&&!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([]),k_()),this.showFPS){const O=tt.height;h.font=`bold ${O}px ${Si}`,h.fillStyle=mg,h.textAlign="right",h.fillText(Math.round(E),x.width-O,O*2)}this.onCanvasDraw&&(h.save(),h.fillStyle=h.strokeStyle=T[0],this.onCanvasDraw(this,{timestamp:t,canvasGradients:T}),h.restore())}_freqScaling(t){switch(this._frequencyScale){case nn:return Math.log2(t);case _r:return 26.81*t/(1960+t)-.53;case yr:return Math.log2(1+t/700);case Nn: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,m=this._chLayout==ie,g=1-s,_=u?t.height:t.height*(1-s*!m)|0;for(const w of[0,1]){const b=this._gradients[this._selectedGrads[w]],y=b.colorStops,S=b.dir=="h";let C;if(i?C=n.createRadialGradient(r,a,d,r,a,c-(d-c)*m):C=n.createLinearGradient(...S?[l,0,l+o,0]:[0,0,0,_]),y){const I=m&&!this._splitGradient&&(!S||i);for(let M=0;M<1+I;M++){const D=y.length-1;y.forEach((x,T)=>{let f=x.pos;if(I&&(f/=2),m&&!u&&!i&&!S&&(f*=g,!I&&f>.5*g&&(f+=.5*s)),M==1)if(i||u){const p=D-T;x=y[p],f=1-x.pos/2}else T==0&&f>0&&C.addColorStop(.5,x.color),f+=.5;C.addColorStop(f,x.color),m&&T==D&&f<.5&&C.addColorStop(.5,x.color)})}}this._canvasGradients[w]=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!=qc&&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=Kc),this._fsStatus=l,this.onCanvasResize&&this.onCanvasResize(t,this))}_setGradient(t,n){if(!this._gradients.hasOwnProperty(t))throw new Gt(Cg,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(Bn).filter(r=>r!="start").concat(i,s);(n||t===void 0)&&(t={...Bn,...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)}}function eu(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=eu(e[t]))&&(i&&(i+=" "),i+=n)}else for(n in e)e[n]&&(i&&(i+=" "),i+=n);return i}function Fn(){for(var e,t,n=0,i="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=eu(e))&&(i&&(i+=" "),i+=t);return i}const nu=({stream:e,className:t,onClick:n})=>{const i=Ft(null);return qt(()=>{if(!i.current||!e)return;const s=new AudioContext,o=s.createMediaStreamSource(e),r=new Mg(i.current,{source:o,audioCtx:s,alphaBars:!1,ansiBands:!1,barSpace:.25,bgAlpha:0,channelLayout:"single",colorMode:"gradient",fadePeaks:!1,fftSize:2048,fillAlpha:0,frequencyScale:"log",gradient:"prism",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:!1,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 r.registerGradient("gradient",{colorStops:[{color:"#D3FFA6",pos:0},{color:"#036B5B",pos:.5},{color:"#D3FFA6",pos:1}]}),r.gradient="gradient",()=>{r.disconnectInput()}},[e]),L("div",{onClick:n,className:Fn("w-full",t),ref:i})},Lg=["agent-id","environment","position"],Ti="widget-layout-id";/**
|
|
17
17
|
* @license lucide-preact v0.515.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
@@ -73,11 +73,11 @@
|
|
|
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 Wg=we("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Fn={},ru=(e,t)=>e.unstable_is?e.unstable_is(t):t===e,ou=e=>"init"in e,wr=e=>!!e.write,au=e=>"v"in e||"e"in e,Ti=e=>{if("e"in e)throw e.e;if((Fn?"production":void 0)!=="production"&&!("v"in e))throw new Error("[Bug] atom state is not initialized");return e.v},ki=new WeakMap,lu=e=>{var t;return Ai(e)&&!!((t=ki.get(e))!=null&&t[0])},zg=e=>{const t=ki.get(e);t!=null&&t[0]&&(t[0]=!1,t[1].forEach(n=>n()))},cu=(e,t)=>{let n=ki.get(e);if(!n){n=[!0,new Set],ki.set(e,n);const i=()=>{n[0]=!1};e.then(i,i)}n[1].add(t)},Ai=e=>typeof(e==null?void 0:e.then)=="function",uu=(e,t,n)=>{n.p.has(e)||(n.p.add(e),t.then(()=>{n.p.delete(e)},()=>{n.p.delete(e)}))},xr=(e,t,n)=>{const i=n(e),s="v"in i,o=i.v;if(Ai(t))for(const r of i.d.keys())uu(e,t,n(r));i.v=t,delete i.e,(!s||!Object.is(o,i.v))&&(++i.n,Ai(o)&&zg(o))},du=(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},qg=()=>{const e=new Set,t=()=>{e.forEach(n=>n())};return t.add=n=>(e.add(n),()=>{e.delete(n)}),t},Sr=()=>{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},Kg=e=>(e.c||(e.c=Sr()),e.m||(e.m=Sr()),e.u||(e.u=Sr()),e.f||(e.f=qg()),e),Xg=Symbol(),hu=(e=new WeakMap,t=new WeakMap,n=new WeakMap,i=new Set,s=new Set,o=new Set,r={},a=(m,...g)=>m.read(...g),l=(m,...g)=>m.write(...g),c=(m,g)=>{var _;return(_=m.unstable_onInit)==null?void 0:_.call(m,g)},d=(m,g)=>{var _;return(_=m.onMount)==null?void 0:_.call(m,g)},...u)=>{const m=u[0]||(x=>{if((Fn?"production":void 0)!=="production"&&!x)throw new Error("Atom is undefined or null");let T=e.get(x);return T||(T={d:new Map,p:new Set,n:0},e.set(x,T),c==null||c(x,D)),T}),g=u[1]||(()=>{const x=[],T=f=>{try{f()}catch(p){x.push(p)}};do{r.f&&T(r.f);const f=new Set,p=f.add.bind(f);i.forEach(h=>{var v;return(v=t.get(h))==null?void 0:v.l.forEach(p)}),i.clear(),o.forEach(p),o.clear(),s.forEach(p),s.clear(),f.forEach(T),i.size&&_()}while(i.size||o.size||s.size);if(x.length)throw new AggregateError(x)}),_=u[2]||(()=>{const x=[],T=new WeakSet,f=new WeakSet,p=Array.from(i);for(;p.length;){const h=p[p.length-1],v=m(h);if(f.has(h)){p.pop();continue}if(T.has(h)){if(n.get(h)===v.n)x.push([h,v]);else if((Fn?"production":void 0)!=="production"&&n.has(h))throw new Error("[Bug] invalidated atom exists");f.add(h),p.pop();continue}T.add(h);for(const k of du(h,v,t))T.has(k)||p.push(k)}for(let h=x.length-1;h>=0;--h){const[v,k]=x[h];let E=!1;for(const A of k.d.keys())if(A!==v&&i.has(A)){E=!0;break}E&&(w(v),S(v)),n.delete(v)}}),w=u[3]||(x=>{var T;const f=m(x);if(au(f)&&(t.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=()=>{t.has(x)&&(S(x),_(),g())},v=R=>{var V;if(ru(x,R)){const N=m(R);if(!au(N))if(ou(R))xr(R,R.init,m);else throw new Error("no atom init");return Ti(N)}const K=w(R);try{return Ti(K)}finally{f.d.set(R,K.n),lu(f.v)&&uu(x,f.v,K),(V=t.get(R))==null||V.t.add(x),p||h()}};let k,E;const A={get signal(){return k||(k=new AbortController),k.signal},get setSelf(){return(Fn?"production":void 0)!=="production"&&!wr(x)&&console.warn("setSelf function cannot be used with read-only atom"),!E&&wr(x)&&(E=(...R)=>{if((Fn?"production":void 0)!=="production"&&p&&console.warn("setSelf function cannot be called in sync"),!p)try{return y(x,...R)}finally{_(),g()}}),E}},P=f.n;try{const R=a(x,v,A);return xr(x,R,m),Ai(R)&&(cu(R,()=>k==null?void 0:k.abort()),R.then(h,h)),f}catch(R){return delete f.v,f.e=R,++f.n,f}finally{p=!1,P!==f.n&&n.get(x)===P&&(n.set(x,f.n),i.add(x),(T=r.c)==null||T.call(r,x))}}),b=u[4]||(x=>{const T=[x];for(;T.length;){const f=T.pop(),p=m(f);for(const h of du(f,p,t)){const v=m(h);n.set(h,v.n),T.push(h)}}}),y=u[5]||((x,...T)=>{let f=!0;const p=v=>Ti(w(v)),h=(v,...k)=>{var E;const A=m(v);try{if(ru(x,v)){if(!ou(v))throw new Error("atom not writable");const P=A.n,R=k[0];xr(v,R,m),S(v),P!==A.n&&(i.add(v),(E=r.c)==null||E.call(r,v),b(v));return}else return y(v,...k)}finally{f||(_(),g())}};try{return l(x,p,h,...T)}finally{f=!1}}),S=u[6]||(x=>{var T;const f=m(x),p=t.get(x);if(p&&!lu(f.v)){for(const[h,v]of f.d)if(!p.d.has(h)){const k=m(h);C(h).t.add(x),p.d.add(h),v!==k.n&&(i.add(h),(T=r.c)==null||T.call(r,h),b(h))}for(const h of p.d||[])if(!f.d.has(h)){p.d.delete(h);const v=I(h);v==null||v.t.delete(x)}}}),C=u[7]||(x=>{var T;const f=m(x);let p=t.get(x);if(!p){w(x);for(const h of f.d.keys())C(h).t.add(x);if(p={l:new Set,d:new Set(f.d.keys()),t:new Set},t.set(x,p),(T=r.m)==null||T.call(r,x),wr(x)){const h=()=>{let v=!0;const k=(...E)=>{try{return y(x,...E)}finally{v||(_(),g())}};try{const E=d(x,k);E&&(p.u=()=>{v=!0;try{E()}finally{v=!1}})}finally{v=!1}};s.add(h)}}return p}),I=u[8]||(x=>{var T;const f=m(x);let p=t.get(x);if(p&&!p.l.size&&!Array.from(p.t).some(h=>{var v;return(v=t.get(h))==null?void 0:v.d.has(x)})){p.u&&o.add(p.u),p=void 0,t.delete(x),(T=r.u)==null||T.call(r,x);for(const h of f.d.keys()){const v=I(h);v==null||v.t.delete(x)}return}return p}),L=[e,t,n,i,s,o,r,a,l,c,d,m,g,_,w,b,y,S,C,I],D={get:x=>Ti(w(x)),set:(x,...T)=>{try{return y(x,...T)}finally{_(),g()}},sub:(x,T)=>{const p=C(x).l;return p.add(T),g(),()=>{p.delete(T),I(x),g()}}};return Object.defineProperty(D,Xg,{value:L}),D},Yg=Kg,fu=cu,Cr={};let Zg=0;function Jg(e,t){const n=`atom${++Zg}`,i={toString(){return(Cr?"production":void 0)!=="production"&&this.debugLabel?n+":"+this.debugLabel:n}};return i.init=e,i.read=Qg,i.write=tv,i}function Qg(e){return e(this)}function tv(e,t,n){return t(this,typeof n=="function"?n(e(this)):n)}const ev=()=>{let e=0;const t=Yg({}),n=new WeakMap,i=new WeakMap,s=hu(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,m]of a)"init"in u&&d(u,m)}finally{--e}}};s.set(l)}})};function nv(){return(Cr?"production":void 0)!=="production"?ev():hu()}let jn;function iv(){return jn||(jn=nv(),(Cr?"production":void 0)!=="production"&&(globalThis.__JOTAI_DEFAULT_STORE__||(globalThis.__JOTAI_DEFAULT_STORE__=jn),globalThis.__JOTAI_DEFAULT_STORE__!==jn&&console.warn("Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"))),jn}const sv={},rv=Ee(void 0);function pu(e){return wt(rv)||iv()}const Tr=e=>typeof(e==null?void 0:e.then)=="function",kr=e=>{e.status||(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}))},ov=$o.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(kr(e),e)}),Ar=new WeakMap,mu=(e,t)=>{let n=Ar.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();Tr(c)?(Ar.set(c,n),o=c,c.then(r(c),a(c)),fu(c,l)):i(c)}catch(c){s(c)}};e.then(r(e),a(e)),fu(e,l)}),Ar.set(e,n)),n};function av(e,t){const{delay:n,unstable_promiseStatus:i=!$o.use}={},s=pu(),[[o,r,a],l]=bo(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)),zt(()=>{const d=s.sub(e,()=>{if(i)try{const u=s.get(e);Tr(u)&&kr(mu(u,()=>s.get(e)))}catch{}if(typeof n=="number"){setTimeout(l,n);return}l()});return l(),d},[s,e,n,i]),pd(c),Tr(c)){const d=mu(c,()=>s.get(e));return i&&kr(d),ov(d)}return c}function lv(e,t){const n=pu();return Ji((...s)=>{if((sv?"production":void 0)!=="production"&&!("write"in e))throw new Error("not writable atom");return n.set(e,...s)},[n,e])}function cv(e,t){return[av(e),lv(e)]}const uv=Jg(!1),dv=()=>cv(uv),Ei=({children:e,className:t,onClick:n,tooltip:i})=>M("button",{title:i,onClick:n,className:Bn("w-8 h-8 rounded-full cursor-pointer text-white flex items-center justify-center",t),children:e}),gu=({call:e})=>{const[t,n]=dv(),i=()=>{n(o=>{const r=!o;return r?e.muteAudio():e.unmuteAudio(),r})},s=()=>{e.hangup()};return M("div",{className:"flex items-center justify-center gap-2",children:[M(Ei,{tooltip:t?"Unmute":"Mute",onClick:i,className:Bn(t?"bg-[#750000]":"bg-[#3C3C3C]"),children:t?M(jg,{className:"w-5 h-5"}):M($g,{className:"w-5 h-5"})}),M(Ei,{tooltip:"End Call",onClick:s,className:"bg-[#750000]",children:M(Ug,{className:"w-4 h-4"})})]})},vu=({call:e,onExpand:t})=>M(On.div,{layoutId:Ci,className:"p-4 rounded-3xl w-[250px] overflow-hidden flex flex-col items-center justify-center bg-black text-white shadow-lg shadow-[#38383878] gap-3",children:[M(nu,{onClick:t,className:"h-[72px] cursor-pointer",stream:e.remoteStream}),M(Mc,{stream:e.remoteStream}),M("h1",{className:"text-xs",children:"Speak to interrupt"}),M(gu,{call:e})]});function hv({item:e}){const t=qt(null);return zt(()=>{t.current&&t.current.scrollIntoView({behavior:"smooth"})},[]),M("li",{className:Bn("flex flex-col gap-1 text-left",{"items-end":e.role==="user"}),ref:t,children:[M("span",{className:"text-xs text-[#969696]",children:e.timestamp.toLocaleTimeString()}),M("p",{className:Bn("text-white text-sm",{"bg-[#222227] px-2.5 py-2 rounded-md":e.role==="user"}),children:e.content})]})}const fv=({transcript:e})=>M("div",{className:"h-[300px] sm:h-[386px] bg-[#38383C] rounded-t-3xl sm:rounded-3xl p-4 flex flex-col w-full",children:[M("ul",{className:"overflow-y-auto flex flex-col gap-4 p-4 flex-1",children:e.map((t,n)=>M(hv,{item:t},t.id+n))}),M("div",{className:"flex items-center h-8 bg-[#222227] rounded-full p-2 gap-2",children:[M("input",{type:"text",placeholder:"Type something here",className:"w-full outline-none text-sm"}),M(Ei,{tooltip:"Send",children:M(Gg,{className:"text-[#969696] w-4 h-4"})})]})]});function pv({onCollapse:e}){return M("div",{className:"flex items-center justify-between w-full",children:M(Ei,{tooltip:"Collapse",className:"ml-auto",onClick:e,children:M(Wg,{})})})}const mv=({call:e,onCollapse:t,transcript:n})=>M(Pf,{children:M(On.div,{exit:{opacity:0,scale:.95},initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},layoutId:"transcript-widget",className:"bg-black gap-3 w-full sm:w-[400px] text-white rounded-t-3xl sm:rounded-3xl shadow-lg shadow-[#38383878]",children:[M("div",{className:"p-4 text-center",children:[M(pv,{onCollapse:t}),M(nu,{className:"h-[144px]",stream:e.remoteStream}),M("h1",{className:"mb-4",children:"Speak or text to interrupt"}),M(gu,{call:e})]}),M(Mc,{stream:e.remoteStream}),M(fv,{transcript:n})]})});function Er(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 G(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 _u=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),gv=new Uint8Array(16);function vv(){if(!_u)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return _u(gv)}for(var yu=[],Ri=0;Ri<256;++Ri)yu[Ri]=(Ri+256).toString(16).substr(1);function $n(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||vv)();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=yu;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 bu="Time to call invite",wu="wss://rtc.telnyx.com",_v={urls:"stun:stun.l.google.com:19302"},yv={urls:"stun:stun.telnyx.com:3478"},xu={urls:"turn:turn.telnyx.com:3478?transport=tcp",username:"testuser",credential:"testpassword"};var B;(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"})(B||(B={}));var bv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Su(e,t){return e(t={exports:{}},t.exports),t.exports}var wv=Su(function(e){var t,n;t=bv,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,y){var S=b[y];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 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(b,y){for(var S=0;S<r.length;S++){var C=r[S];this[C]=S<b?i:this.methodFactory(C,b,y)}this.log=this.debug}function d(b,y,S){return function(){typeof console!==s&&(c.call(this,y,S),this[b].apply(this,arguments))}}function u(b,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)}(b)||d.apply(this,arguments)}function m(b,y,S){var C,I=this;y=y??"WARN";var L="loglevel";function D(){var T;if(typeof window!==s&&L){try{T=window.localStorage[L]}catch{}if(typeof T===s)try{var f=window.document.cookie,p=f.indexOf(encodeURIComponent(L)+"=");p!==-1&&(T=/^([^;]+)/.exec(f.slice(p))[1])}catch{}return I.levels[T]===void 0&&(T=void 0),T}}typeof b=="string"?L+=":"+b:typeof b=="symbol"&&(L=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 C},I.setLevel=function(T,f){if(typeof T=="string"&&I.levels[T.toUpperCase()]!==void 0&&(T=I.levels[T.toUpperCase()]),!(typeof T=="number"&&T>=0&&T<=I.levels.SILENT))throw"log.setLevel() called with invalid level: "+T;if(C=T,f!==!1&&function(p){var h=(r[p]||"silent").toUpperCase();if(typeof window!==s&&L){try{return void(window.localStorage[L]=h)}catch{}try{window.document.cookie=encodeURIComponent(L)+"="+h+";"}catch{}}}(T),c.call(I,T,b),typeof console===s&&T<I.levels.SILENT)return"No console available for logging"},I.setDefaultLevel=function(T){y=T,D()||I.setLevel(T,!1)},I.resetLevel=function(){I.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{}}}()},I.enableAll=function(T){I.setLevel(I.levels.TRACE,T)},I.disableAll=function(T){I.setLevel(I.levels.SILENT,T)};var x=D();x==null&&(x=y),I.setLevel(x,!1)}var g=new m,_={};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 y=_[b];return y||(y=_[b]=new m(b,g.getLevel(),g.methodFactory)),y};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 _},g.default=g,g},e.exports?e.exports=n():t.log=n()});const F=wv.getLogger("telnyx"),xv=F.methodFactory;F.methodFactory=(e,t,n)=>{const i=xv(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)}},F.setLevel(F.getLevel());const Cu=e=>Object.keys(e).length===0,Ii=e=>{const[t,n,i,s,o,r]=e;let a={};try{a=JSON.parse(o.replace(/ID"/g,'Id"'))}catch{F.warn("Verto LA invalid media JSON string:",o)}return{participantId:Number(t),participantNumber:n,participantName:i,codec:s,media:a,participantData:r}},Tu=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},sn=e=>e instanceof Function||typeof e=="function",Un=e=>typeof document=="object"&&"getElementById"in document?typeof e=="string"?document.getElementById(e)||null:typeof e=="function"?e():e instanceof HTMLMediaElement?e:null:null,Sv=/^(ws|wss):\/\//,ku=(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?ku(a,r):{result:s}},Au=(e,t)=>Math.floor(Math.random()*(t-e+1)+e),Rr=({login:e,passwd:t,password:n,login_token:i})=>!!(e&&(t||n)||i),Pi=({anonymous_login:e})=>!!e&&!!e.target_id&&!!e.target_type,Ir=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 Eu({debounceTime:e}){let t,n;return{promise:new Promise((i,s)=>{t=e?Cv(i,e):i,n=s}),resolve:t,reject:n}}const Cv=(e,t)=>{let n;return(...i)=>{clearTimeout(n),n=window.setTimeout(()=>{e(...i)},t)}},Pr="telnyx-voice-sdk-id";function Lr(){return sessionStorage.getItem(Pr)}var Vt,xe,nt;typeof window<"u"&&window.addEventListener("beforeunload",()=>{sessionStorage.removeItem(Pr)}),function(e){e.Offer="offer",e.Answer="answer"}(Vt||(Vt={})),function(e){e.Inbound="inbound",e.Outbound="outbound"}(xe||(xe={})),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 se={generic:"event",[nt.Display]:"participantData",[nt.Attach]:"participantData",conferenceUpdate:"conferenceUpdate",callUpdate:"callUpdate",vertoClientReady:"vertoClientReady",userMediaError:"userMediaError"},Tv={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,Gn,Et,re,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"}(Gn||(Gn={})),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"}(Et||(Et={})),function(e){e.Video="videoinput",e.AudioIn="audioinput",e.AudioOut="audiooutput"}(re||(re={})),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 rn="GLOBAL",Mt={},Hn=(e,t)=>`${e}|${t}`,Ru=(e,t=rn)=>Hn(e,t)in Mt,on=(e,t,n=rn)=>{const i=Hn(e,n);i in Mt||(Mt[i]=[]),Mt[i].push(t)},Iu=(e,t,n=rn)=>{const i=function(s){an(e,i,n),t(s)};return i.prototype.targetRef=t,on(e,i,n)},an=(e,t,n=rn)=>{if(!Ru(e,n))return!1;const i=Hn(e,n);if(sn(t))for(let s=Mt[i].length-1;s>=0;s--){const o=Mt[i][s];(t===o||o.prototype&&t===o.prototype.targetRef)&&Mt[i].splice(s,1)}else Mt[i]=[];return Mt[i].length===0&&delete Mt[i],!0},J=(e,t,n=rn,i=!0)=>{const s=i&&n!==rn;if(!Ru(e,n))return s&&J(e,t),!1;const o=Hn(e,n),r=Mt[o].length;if(!r)return s&&J(e,t),!1;for(let a=r-1;a>=0;a--)Mt[o][a](t);return s&&J(e,t),!0},Mr=e=>{const t=Hn(e,"");Object.keys(Mt).filter(n=>n.indexOf(t)===0).forEach(n=>delete Mt[n])};let kv=typeof WebSocket<"u"?WebSocket:null;const Av=0,Ev=1,Rv=2,Iv=3;class Pu{constructor(t){this.session=t,this.previousGatewayState="",this._wsClient=null,this._host=wu,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":wu),n&&(this._host=(o=>`${Sv.test(o)?"":"wss://"}${o}`)(n)),s&&(this._host=this._host.replace(/rtc(dev)?/,`${s}.rtc$1`))}get connected(){return this._wsClient&&this._wsClient.readyState===Ev}get connecting(){return this._wsClient&&this._wsClient.readyState===Av}get closing(){return this._wsClient&&this._wsClient.readyState===Rv}get closed(){return this._wsClient&&this._wsClient.readyState===Iv}get isAlive(){return this.connecting||this.connected}get isDead(){return this.closing||this.closed}connect(){const t=new URL(this._host),n=Lr();n&&t.searchParams.set("voice_sdk_id",n),this._wsClient=new kv(t.toString()),this._wsClient.onopen=i=>J(B.SocketOpen,i,this.session.uuid),this._wsClient.onclose=i=>J(B.SocketClose,i,this.session.uuid),this._wsClient.onerror=i=>J(B.SocketError,{error:i,sessionId:this.session.sessionid},this.session.uuid),this._wsClient.onmessage=i=>{var s,o;const r=Tu(i.data);var a;if(typeof r!="string"){if(r.voice_sdk_id&&(a=r.voice_sdk_id,sessionStorage.setItem(Pr,a)),this._unsetTimer(r.id),F.debug(`RECV:
|
|
76
|
+
*/const Wg=we("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),jn={},ru=(e,t)=>e.unstable_is?e.unstable_is(t):t===e,ou=e=>"init"in e,wr=e=>!!e.write,au=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},Ei=new WeakMap,lu=e=>{var t;return Ai(e)&&!!((t=Ei.get(e))!=null&&t[0])},zg=e=>{const t=Ei.get(e);t!=null&&t[0]&&(t[0]=!1,t[1].forEach(n=>n()))},cu=(e,t)=>{let n=Ei.get(e);if(!n){n=[!0,new Set],Ei.set(e,n);const i=()=>{n[0]=!1};e.then(i,i)}n[1].add(t)},Ai=e=>typeof(e==null?void 0:e.then)=="function",uu=(e,t,n)=>{n.p.has(e)||(n.p.add(e),t.then(()=>{n.p.delete(e)},()=>{n.p.delete(e)}))},xr=(e,t,n)=>{const i=n(e),s="v"in i,o=i.v;if(Ai(t))for(const r of i.d.keys())uu(e,t,n(r));i.v=t,delete i.e,(!s||!Object.is(o,i.v))&&(++i.n,Ai(o)&&zg(o))},du=(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},qg=()=>{const e=new Set,t=()=>{e.forEach(n=>n())};return t.add=n=>(e.add(n),()=>{e.delete(n)}),t},Sr=()=>{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},Kg=e=>(e.c||(e.c=Sr()),e.m||(e.m=Sr()),e.u||(e.u=Sr()),e.f||(e.f=qg()),e),Xg=Symbol(),hu=(e=new WeakMap,t=new WeakMap,n=new WeakMap,i=new Set,s=new Set,o=new Set,r={},a=(m,...g)=>m.read(...g),l=(m,...g)=>m.write(...g),c=(m,g)=>{var _;return(_=m.unstable_onInit)==null?void 0:_.call(m,g)},d=(m,g)=>{var _;return(_=m.onMount)==null?void 0:_.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 T=e.get(x);return T||(T={d:new Map,p:new Set,n:0},e.set(x,T),c==null||c(x,D)),T}),g=u[1]||(()=>{const x=[],T=f=>{try{f()}catch(p){x.push(p)}};do{r.f&&T(r.f);const f=new Set,p=f.add.bind(f);i.forEach(h=>{var v;return(v=t.get(h))==null?void 0:v.l.forEach(p)}),i.clear(),o.forEach(p),o.clear(),s.forEach(p),s.clear(),f.forEach(T),i.size&&_()}while(i.size||o.size||s.size);if(x.length)throw new AggregateError(x)}),_=u[2]||(()=>{const x=[],T=new WeakSet,f=new WeakSet,p=Array.from(i);for(;p.length;){const h=p[p.length-1],v=m(h);if(f.has(h)){p.pop();continue}if(T.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),p.pop();continue}T.add(h);for(const k of du(h,v,t))T.has(k)||p.push(k)}for(let h=x.length-1;h>=0;--h){const[v,k]=x[h];let A=!1;for(const E of k.d.keys())if(E!==v&&i.has(E)){A=!0;break}A&&(w(v),S(v)),n.delete(v)}}),w=u[3]||(x=>{var T;const f=m(x);if(au(f)&&(t.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=()=>{t.has(x)&&(S(x),_(),g())},v=R=>{var V;if(ru(x,R)){const N=m(R);if(!au(N))if(ou(R))xr(R,R.init,m);else throw new Error("no atom init");return ki(N)}const K=w(R);try{return ki(K)}finally{f.d.set(R,K.n),lu(f.v)&&uu(x,f.v,K),(V=t.get(R))==null||V.t.add(x),p||h()}};let k,A;const E={get signal(){return k||(k=new AbortController),k.signal},get setSelf(){return(jn?"production":void 0)!=="production"&&!wr(x)&&console.warn("setSelf function cannot be used with read-only atom"),!A&&wr(x)&&(A=(...R)=>{if((jn?"production":void 0)!=="production"&&p&&console.warn("setSelf function cannot be called in sync"),!p)try{return y(x,...R)}finally{_(),g()}}),A}},P=f.n;try{const R=a(x,v,E);return xr(x,R,m),Ai(R)&&(cu(R,()=>k==null?void 0:k.abort()),R.then(h,h)),f}catch(R){return delete f.v,f.e=R,++f.n,f}finally{p=!1,P!==f.n&&n.get(x)===P&&(n.set(x,f.n),i.add(x),(T=r.c)==null||T.call(r,x))}}),b=u[4]||(x=>{const T=[x];for(;T.length;){const f=T.pop(),p=m(f);for(const h of du(f,p,t)){const v=m(h);n.set(h,v.n),T.push(h)}}}),y=u[5]||((x,...T)=>{let f=!0;const p=v=>ki(w(v)),h=(v,...k)=>{var A;const E=m(v);try{if(ru(x,v)){if(!ou(v))throw new Error("atom not writable");const P=E.n,R=k[0];xr(v,R,m),S(v),P!==E.n&&(i.add(v),(A=r.c)==null||A.call(r,v),b(v));return}else return y(v,...k)}finally{f||(_(),g())}};try{return l(x,p,h,...T)}finally{f=!1}}),S=u[6]||(x=>{var T;const f=m(x),p=t.get(x);if(p&&!lu(f.v)){for(const[h,v]of f.d)if(!p.d.has(h)){const k=m(h);C(h).t.add(x),p.d.add(h),v!==k.n&&(i.add(h),(T=r.c)==null||T.call(r,h),b(h))}for(const h of p.d||[])if(!f.d.has(h)){p.d.delete(h);const v=I(h);v==null||v.t.delete(x)}}}),C=u[7]||(x=>{var T;const f=m(x);let p=t.get(x);if(!p){w(x);for(const h of f.d.keys())C(h).t.add(x);if(p={l:new Set,d:new Set(f.d.keys()),t:new Set},t.set(x,p),(T=r.m)==null||T.call(r,x),wr(x)){const h=()=>{let v=!0;const k=(...A)=>{try{return y(x,...A)}finally{v||(_(),g())}};try{const A=d(x,k);A&&(p.u=()=>{v=!0;try{A()}finally{v=!1}})}finally{v=!1}};s.add(h)}}return p}),I=u[8]||(x=>{var T;const f=m(x);let p=t.get(x);if(p&&!p.l.size&&!Array.from(p.t).some(h=>{var v;return(v=t.get(h))==null?void 0:v.d.has(x)})){p.u&&o.add(p.u),p=void 0,t.delete(x),(T=r.u)==null||T.call(r,x);for(const h of f.d.keys()){const v=I(h);v==null||v.t.delete(x)}return}return p}),M=[e,t,n,i,s,o,r,a,l,c,d,m,g,_,w,b,y,S,C,I],D={get:x=>ki(w(x)),set:(x,...T)=>{try{return y(x,...T)}finally{_(),g()}},sub:(x,T)=>{const p=C(x).l;return p.add(T),g(),()=>{p.delete(T),I(x),g()}}};return Object.defineProperty(D,Xg,{value:M}),D},Yg=Kg,fu=cu,Cr={};let Zg=0;function Jg(e,t){const n=`atom${++Zg}`,i={toString(){return(Cr?"production":void 0)!=="production"&&this.debugLabel?n+":"+this.debugLabel:n}};return i.init=e,i.read=Qg,i.write=tv,i}function Qg(e){return e(this)}function tv(e,t,n){return t(this,typeof n=="function"?n(e(this)):n)}const ev=()=>{let e=0;const t=Yg({}),n=new WeakMap,i=new WeakMap,s=hu(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,m]of a)"init"in u&&d(u,m)}finally{--e}}};s.set(l)}})};function nv(){return(Cr?"production":void 0)!=="production"?ev():hu()}let $n;function iv(){return $n||($n=nv(),(Cr?"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 sv={},rv=Ae(void 0);function pu(e){return wt(rv)||iv()}const Tr=e=>typeof(e==null?void 0:e.then)=="function",kr=e=>{e.status||(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}))},ov=$o.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(kr(e),e)}),Er=new WeakMap,mu=(e,t)=>{let n=Er.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();Tr(c)?(Er.set(c,n),o=c,c.then(r(c),a(c)),fu(c,l)):i(c)}catch(c){s(c)}};e.then(r(e),a(e)),fu(e,l)}),Er.set(e,n)),n};function av(e,t){const{delay:n,unstable_promiseStatus:i=!$o.use}={},s=pu(),[[o,r,a],l]=bo(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)),qt(()=>{const d=s.sub(e,()=>{if(i)try{const u=s.get(e);Tr(u)&&kr(mu(u,()=>s.get(e)))}catch{}if(typeof n=="number"){setTimeout(l,n);return}l()});return l(),d},[s,e,n,i]),pd(c),Tr(c)){const d=mu(c,()=>s.get(e));return i&&kr(d),ov(d)}return c}function lv(e,t){const n=pu();return Ji((...s)=>{if((sv?"production":void 0)!=="production"&&!("write"in e))throw new Error("not writable atom");return n.set(e,...s)},[n,e])}function cv(e,t){return[av(e),lv(e)]}const uv=Jg(!1),dv=()=>cv(uv),Ri=({children:e,className:t,onClick:n,tooltip:i})=>L("button",{title:i,onClick:n,className:Fn("w-8 h-8 rounded-full cursor-pointer text-white flex items-center justify-center",t),children:e}),gu=({call:e})=>{const[t,n]=dv(),i=()=>{n(o=>{const r=!o;return r?e.muteAudio():e.unmuteAudio(),r})},s=()=>{e.hangup()};return L("div",{className:"flex items-center justify-center gap-2",children:[L(Ri,{tooltip:t?"Unmute":"Mute",onClick:i,className:Fn(t?"bg-[#750000]":"bg-[#3C3C3C]"),children:t?L(jg,{className:"w-5 h-5"}):L($g,{className:"w-5 h-5"})}),L(Ri,{tooltip:"End Call",onClick:s,className:"bg-[#750000]",children:L(Ug,{className:"w-4 h-4"})})]})},vu=({call:e,onExpand:t})=>L(Vn.div,{layoutId:Ti,className:"p-4 rounded-3xl w-[250px] overflow-hidden flex flex-col items-center justify-center bg-black text-white shadow-lg shadow-[#38383878] gap-3",children:[L(nu,{onClick:t,className:"h-[72px] cursor-pointer",stream:e.remoteStream}),L(Lc,{stream:e.remoteStream}),L("h1",{className:"text-xs",children:"Speak to interrupt"}),L(gu,{call:e})]});function hv({item:e}){const t=Ft(null);return qt(()=>{t.current&&t.current.scrollIntoView({behavior:"smooth"})},[]),L("li",{className:Fn("flex flex-col gap-1 text-left",{"items-end":e.role==="user"}),ref:t,children:[L("span",{className:"text-xs text-[#969696]",children:e.timestamp.toLocaleTimeString()}),L("p",{className:Fn("text-white text-sm",{"bg-[#222227] px-2.5 py-2 rounded-md":e.role==="user"}),children:e.content})]})}const fv=({transcript:e,call:t})=>{const n=Ft(null),i=async()=>{if(n.current&&n.current.value.trim()!==""){const o=n.current.value;t.sendConversationMessage(o),n.current.value=""}},s=o=>{o.key==="Enter"&&n.current&&(o.preventDefault(),i())};return L("div",{className:"h-[300px] sm:h-[386px] bg-[#38383C] rounded-t-3xl sm:rounded-3xl p-4 flex flex-col w-full",children:[L("ul",{className:"overflow-y-auto flex flex-col gap-4 p-4 flex-1",children:e.map((o,r)=>L(hv,{item:o},o.id+r))}),L("div",{className:"flex items-center h-8 bg-[#222227] rounded-full p-2 gap-2",children:[L("input",{ref:n,type:"text",onKeyDown:s,placeholder:"Type something here",className:"w-full outline-none text-sm"}),L(Ri,{tooltip:"Send",children:L(Gg,{onClick:i,className:"text-[#969696] w-4 h-4"})})]})]})};function pv({onCollapse:e}){return L("div",{className:"flex items-center justify-between w-full",children:L(Ri,{tooltip:"Collapse",className:"ml-auto",onClick:e,children:L(Wg,{})})})}const mv=({call:e,onCollapse:t,transcript:n})=>L(Pf,{children:L(Vn.div,{exit:{opacity:0,scale:.95},initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},layoutId:"transcript-widget",className:"bg-black gap-3 w-full sm:w-[400px] text-white rounded-t-3xl sm:rounded-3xl shadow-lg shadow-[#38383878]",children:[L("div",{className:"p-4 text-center",children:[L(pv,{onCollapse:t}),L(nu,{className:"h-[144px]",stream:e.remoteStream}),L("h1",{className:"mb-4",children:"Speak or text to interrupt"}),L(gu,{call:e})]}),L(Lc,{stream:e.remoteStream}),L(fv,{call:e,transcript:n})]})});function Ar(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 G(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 _u=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),gv=new Uint8Array(16);function vv(){if(!_u)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return _u(gv)}for(var yu=[],Ii=0;Ii<256;++Ii)yu[Ii]=(Ii+256).toString(16).substr(1);function sn(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||vv)();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=yu;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 bu="Time to call invite",wu="wss://rtc.telnyx.com",_v={urls:"stun:stun.l.google.com:19302"},yv={urls:"stun:stun.telnyx.com:3478"},xu={urls:"turn:turn.telnyx.com:3478?transport=tcp",username:"testuser",credential:"testpassword"};var B;(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"})(B||(B={}));var bv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Su(e,t){return e(t={exports:{}},t.exports),t.exports}var wv=Su(function(e){var t,n;t=bv,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,y){var S=b[y];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 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(b,y){for(var S=0;S<r.length;S++){var C=r[S];this[C]=S<b?i:this.methodFactory(C,b,y)}this.log=this.debug}function d(b,y,S){return function(){typeof console!==s&&(c.call(this,y,S),this[b].apply(this,arguments))}}function u(b,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)}(b)||d.apply(this,arguments)}function m(b,y,S){var C,I=this;y=y??"WARN";var M="loglevel";function D(){var T;if(typeof window!==s&&M){try{T=window.localStorage[M]}catch{}if(typeof T===s)try{var f=window.document.cookie,p=f.indexOf(encodeURIComponent(M)+"=");p!==-1&&(T=/^([^;]+)/.exec(f.slice(p))[1])}catch{}return I.levels[T]===void 0&&(T=void 0),T}}typeof b=="string"?M+=":"+b:typeof b=="symbol"&&(M=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 C},I.setLevel=function(T,f){if(typeof T=="string"&&I.levels[T.toUpperCase()]!==void 0&&(T=I.levels[T.toUpperCase()]),!(typeof T=="number"&&T>=0&&T<=I.levels.SILENT))throw"log.setLevel() called with invalid level: "+T;if(C=T,f!==!1&&function(p){var h=(r[p]||"silent").toUpperCase();if(typeof window!==s&&M){try{return void(window.localStorage[M]=h)}catch{}try{window.document.cookie=encodeURIComponent(M)+"="+h+";"}catch{}}}(T),c.call(I,T,b),typeof console===s&&T<I.levels.SILENT)return"No console available for logging"},I.setDefaultLevel=function(T){y=T,D()||I.setLevel(T,!1)},I.resetLevel=function(){I.setLevel(y,!1),function(){if(typeof window!==s&&M){try{return void window.localStorage.removeItem(M)}catch{}try{window.document.cookie=encodeURIComponent(M)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}()},I.enableAll=function(T){I.setLevel(I.levels.TRACE,T)},I.disableAll=function(T){I.setLevel(I.levels.SILENT,T)};var x=D();x==null&&(x=y),I.setLevel(x,!1)}var g=new m,_={};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 y=_[b];return y||(y=_[b]=new m(b,g.getLevel(),g.methodFactory)),y};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 _},g.default=g,g},e.exports?e.exports=n():t.log=n()});const F=wv.getLogger("telnyx"),xv=F.methodFactory;F.methodFactory=(e,t,n)=>{const i=xv(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)}},F.setLevel(F.getLevel());const Cu=e=>Object.keys(e).length===0,Pi=e=>{const[t,n,i,s,o,r]=e;let a={};try{a=JSON.parse(o.replace(/ID"/g,'Id"'))}catch{F.warn("Verto LA invalid media JSON string:",o)}return{participantId:Number(t),participantNumber:n,participantName:i,codec:s,media:a,participantData:r}},Tu=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},rn=e=>e instanceof Function||typeof e=="function",Un=e=>typeof document=="object"&&"getElementById"in document?typeof e=="string"?document.getElementById(e)||null:typeof e=="function"?e():e instanceof HTMLMediaElement?e:null:null,Sv=/^(ws|wss):\/\//,ku=(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?ku(a,r):{result:s}},Eu=(e,t)=>Math.floor(Math.random()*(t-e+1)+e),Rr=({login:e,passwd:t,password:n,login_token:i})=>!!(e&&(t||n)||i),Mi=({anonymous_login:e})=>!!e&&!!e.target_id&&!!e.target_type,Ir=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 Au({debounceTime:e}){let t,n;return{promise:new Promise((i,s)=>{t=e?Cv(i,e):i,n=s}),resolve:t,reject:n}}const Cv=(e,t)=>{let n;return(...i)=>{clearTimeout(n),n=window.setTimeout(()=>{e(...i)},t)}},Pr="telnyx-voice-sdk-id";function Mr(){return sessionStorage.getItem(Pr)}var Vt,xe,nt;typeof window<"u"&&window.addEventListener("beforeunload",()=>{sessionStorage.removeItem(Pr)}),function(e){e.Offer="offer",e.Answer="answer"}(Vt||(Vt={})),function(e){e.Inbound="inbound",e.Outbound="outbound"}(xe||(xe={})),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 se={generic:"event",[nt.Display]:"participantData",[nt.Attach]:"participantData",conferenceUpdate:"conferenceUpdate",callUpdate:"callUpdate",vertoClientReady:"vertoClientReady",userMediaError:"userMediaError"},Tv={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,Gn,At,re,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"}(Gn||(Gn={})),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"}(re||(re={})),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 on="GLOBAL",Lt={},Hn=(e,t)=>`${e}|${t}`,Ru=(e,t=on)=>Hn(e,t)in Lt,an=(e,t,n=on)=>{const i=Hn(e,n);i in Lt||(Lt[i]=[]),Lt[i].push(t)},Iu=(e,t,n=on)=>{const i=function(s){ln(e,i,n),t(s)};return i.prototype.targetRef=t,an(e,i,n)},ln=(e,t,n=on)=>{if(!Ru(e,n))return!1;const i=Hn(e,n);if(rn(t))for(let s=Lt[i].length-1;s>=0;s--){const o=Lt[i][s];(t===o||o.prototype&&t===o.prototype.targetRef)&&Lt[i].splice(s,1)}else Lt[i]=[];return Lt[i].length===0&&delete Lt[i],!0},J=(e,t,n=on,i=!0)=>{const s=i&&n!==on;if(!Ru(e,n))return s&&J(e,t),!1;const o=Hn(e,n),r=Lt[o].length;if(!r)return s&&J(e,t),!1;for(let a=r-1;a>=0;a--)Lt[o][a](t);return s&&J(e,t),!0},Lr=e=>{const t=Hn(e,"");Object.keys(Lt).filter(n=>n.indexOf(t)===0).forEach(n=>delete Lt[n])};let kv=typeof WebSocket<"u"?WebSocket:null;const Ev=0,Av=1,Rv=2,Iv=3;class Pu{constructor(t){this.session=t,this.previousGatewayState="",this._wsClient=null,this._host=wu,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":wu),n&&(this._host=(o=>`${Sv.test(o)?"":"wss://"}${o}`)(n)),s&&(this._host=this._host.replace(/rtc(dev)?/,`${s}.rtc$1`))}get connected(){return this._wsClient&&this._wsClient.readyState===Av}get connecting(){return this._wsClient&&this._wsClient.readyState===Ev}get closing(){return this._wsClient&&this._wsClient.readyState===Rv}get closed(){return this._wsClient&&this._wsClient.readyState===Iv}get isAlive(){return this.connecting||this.connected}get isDead(){return this.closing||this.closed}connect(){const t=new URL(this._host),n=Mr();n&&t.searchParams.set("voice_sdk_id",n),this._wsClient=new kv(t.toString()),this._wsClient.onopen=i=>J(B.SocketOpen,i,this.session.uuid),this._wsClient.onclose=i=>J(B.SocketClose,i,this.session.uuid),this._wsClient.onerror=i=>J(B.SocketError,{error:i,sessionId:this.session.sessionid},this.session.uuid),this._wsClient.onmessage=i=>{var s,o;const r=Tu(i.data);var a;if(typeof r!="string"){if(r.voice_sdk_id&&(a=r.voice_sdk_id,sessionStorage.setItem(Pr,a)),this._unsetTimer(r.id),F.debug(`RECV:
|
|
77
77
|
`,JSON.stringify(r,null,2),`
|
|
78
78
|
`),Rt[`${(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 l=Ir(r);J(B.SocketMessage,r,this.session.uuid),l&&(this.previousGatewayState=l)}}else this._handleStringResponse(r)}}sendRawText(t){this._wsClient.send(t)}send(t){const{request:n}=t,i=new Promise((s,o)=>{if(n.hasOwnProperty("result"))return s();Iu(n.id,r=>{const{result:a,error:l}=ku(r);return l?o(l):s(a)})});return F.debug(`SEND:
|
|
79
79
|
`,JSON.stringify(n,null,2),`
|
|
80
|
-
`),this._wsClient.send(JSON.stringify(n)),i}close(){this._wsClient&&(sn(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(B.SpeedTest,{upDur:this.upDur,downDur:this.downDur},this.session.uuid)}else F.warn("Unknown message from socket",t)}}class Li{buildRequest(t){this.request=Object.assign({jsonrpc:"2.0",id:$n()},t)}}const Lu={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 Dt extends Li{constructor(t={}){if(super(),t.hasOwnProperty("dialogParams")){const n=Er(t.dialogParams,["remoteSdp","localStream","remoteStream","onNotification","camId","micId","speakerId"]);for(const i in Lu)i&&n.hasOwnProperty(i)&&(n[Lu[i]]=n[i],delete n[i]);t.dialogParams=n}this.buildRequest({method:this.toString(),params:t})}}class Mu extends Dt{constructor(){super(),this.method=nt.GatewayState,this.buildRequest({method:this.method,params:{}})}}class Pv{constructor(t){this.pendingRequestId=null,this.onSocketMessage=n=>G(this,void 0,void 0,function*(){n.id===this.pendingRequestId&&this.gatewayStateTask.resolve(Ir(n))}),this.getIsRegistered=()=>G(this,void 0,void 0,function*(){const n=new Mu;this.pendingRequestId=n.request.id,this.gatewayStateTask=Eu({}),this.session.execute(n);const i=yield this.gatewayStateTask.promise;return!!i&&[Rt.REGISTER,Rt.REGED].includes(i)}),this.session=t,this.gatewayStateTask=Eu({}),this.session.on("telnyx.socket.message",this.onSocketMessage)}}class Lv{constructor(t){if(this.options=t,this.uuid=$n(),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 Pu(this),this.registerAgent=new Pv(this)}get __logger(){return F}get connected(){return this.connection&&this.connection.connected}get reconnectDelay(){return 1e3*Au(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 Rr(this.options)||Pi(this.options)}broadcast(t){}disconnect(){return G(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 on(t,n,this.uuid),this}off(t,n){return an(t,n,this.uuid),this}connect(){return G(this,void 0,void 0,function*(){this.connection||(this.connection=new Pu(this)),this._attachListeners(),this.connection.isAlive||this.connection.connect()})}_handleLoginError(t){J(B.Error,{error:t,sessionId:this.sessionid},this.uuid)}_onSocketOpen(){return G(this,void 0,void 0,function*(){})}onNetworkClose(){this.relayProtocol&&Mr(this.relayProtocol);for(const t in this.subscriptions)Mr(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],an(t,null,n)):(delete this.subscriptions[t],Mr(t)))}_addSubscription(t,n=null,i){this._existsSubscription(t,i)||(this._existsSubscription(t)||(this.subscriptions[t]={}),this.subscriptions[t][i]={},sn(n)&&on(t,n,i))}_existsSubscription(t,n){return!(!this.subscriptions.hasOwnProperty(t)||!(!n||n&&this.subscriptions[t].hasOwnProperty(n)))}_attachListeners(){this._detachListeners(),this.on(B.SocketOpen,this._onSocketOpen),this.on(B.SocketClose,this.onNetworkClose),this.on(B.SocketError,this.onNetworkClose),this.on(B.SocketMessage,this._onSocketMessage)}_detachListeners(){this.off(B.SocketOpen,this._onSocketOpen),this.off(B.SocketClose,this.onNetworkClose),this.off(B.SocketError,this.onNetworkClose),this.off(B.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){on(t,n)}static off(t){an(t)}static uuid(){return $n()}clearConnection(){this.connection=null}hasAutoReconnect(){return this._autoReconnect}getIsRegistered(){return this.registerAgent.getIsRegistered()}}const Dr=e=>navigator.mediaDevices.getUserMedia(e),Mi=e=>e&&e instanceof MediaStream,Di=(e,t)=>{const n=Un(e);n!==null&&(n.getAttribute("autoplay")||n.setAttribute("autoplay","autoplay"),n.getAttribute("playsinline")||n.setAttribute("playsinline","playsinline"),n.srcObject=t)},Du=(e,t)=>G(void 0,void 0,void 0,function*(){const n=Un(e);if(n===null)return F.info("No HTMLMediaElement to attach the speakerId"),!1;if(typeof t!="string")return F.info(`Invalid speaker deviceId: '${t}'`),!1;try{return yield n.setSinkId(t),!0}catch{return!1}}),Mv=e=>{e&&e.readyState==="live"&&e.stop()},Wn=e=>{Mi(e)&&e.getTracks().forEach(Mv),e=null},Oi=e=>G(void 0,void 0,void 0,function*(){F.info("RTCService.getUserMedia",e);const{audio:t,video:n}=e;if(!t&&!n)return null;try{return yield Dr(e)}catch(i){throw F.error("getUserMedia error: ",i),i}}),zn=(e=null,t=!1)=>G(void 0,void 0,void 0,function*(){let n=[];const i=yield navigator.mediaDevices.getUserMedia(((s=null)=>({audio:!s||s===re.AudioIn||s===re.AudioOut,video:!s||s===re.Video}))(e)).catch(s=>(console.error(s),null));if(i){if(Wn(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}),Ou=[[320,240],[640,360],[640,480],[1280,720],[1920,1080]],Vi=(e,t,n)=>G(void 0,void 0,void 0,function*(){const i=yield zn(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}),Vu=e=>{const t=navigator.mediaDevices.getSupportedConstraints();Object.keys(e).map(n=>{t.hasOwnProperty(n)&&e[n]!==null&&e[n]!==void 0||delete e[n]})},Nu=(e,t,n,i)=>G(void 0,void 0,void 0,function*(){const{deviceId:s}=i;if(s===void 0&&(e||t)){const o=yield Vi(e,t,n).catch(r=>null);o&&(i.deviceId={exact:o})}return i}),Ni=(e,t)=>{if(!e)return!1;const{subscribed:n,alreadySubscribed:i}=Or(e);return n.includes(t)||i.includes(t)},Or=e=>{const t={subscribed:[],alreadySubscribed:[],unauthorized:[],unsubscribed:[],notSubscribed:[]};return Object.keys(t).forEach(n=>{t[n]=e[`${n}Channels`]||[]}),t},ln=(e,t=null,n=null)=>{if(!Mi(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}})},Bu=e=>{ln(e,"audio",!0)},Fu=e=>{ln(e,"audio",!1)},ju=e=>{ln(e,"audio",null)};function Dv(){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],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,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:!!Oi}}catch(e){return e.message}}var vt;function $u(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 Uu(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 Gu(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 Hu="2.22.13",Vr=Hu;class Ov extends Dt{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:Vr,data:navigator.userAgent}};s&&(a.sessid=s),this.buildRequest({method:this.method,params:a})}}class Vv extends Dt{constructor(t,n){super(),this.buildRequest({id:t,result:{method:n}})}}class Nv extends Dt{toString(){return nt.Invite}}class Bv extends Dt{toString(){return nt.Answer}}class Fv extends Dt{toString(){return nt.Attach}}class jv extends Dt{toString(){return nt.Bye}}class Nr extends Dt{toString(){return nt.Modify}}class Wu extends Dt{toString(){return nt.Info}}class $v extends Dt{toString(){return nt.Broadcast}}class Uv extends Dt{toString(){return nt.Subscribe}}class Gv extends Dt{toString(){return nt.Unsubscribe}}const zu=(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:se.conferenceUpdate,call:e.calls[s],canvasInfo:Hv(o),currentLayerIdx:r};switch(n){case"layer-info":{const l=Object.assign({action:Et.LayerInfo},a);J(B.Notification,l,e.uuid);break}case"layout-info":{const l=Object.assign({action:Et.LayoutInfo},a);J(B.Notification,l,e.uuid);break}}},Hv=e=>{const t=JSON.stringify(e).replace(/memberID/g,"participantId").replace(/ID"/g,'Id"').replace(/POS"/g,'Pos"');return Tu(t)};var Bi,qu=Su(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,p,h,v){var k,E,A;if(typeof h!="function")throw new TypeError('"listener" argument must be a function');if((E=f._events)?(E.newListener&&(f.emit("newListener",p,h.listener?h.listener:h),E=f._events),A=E[p]):(E=f._events=new i,f._eventsCount=0),A){if(typeof A=="function"?A=E[p]=v?[h,A]:[A,h]:v?A.unshift(h):A.push(h),!A.warned&&(k=o(f))&&0<k&&A.length>k){A.warned=!0;var P=new Error("Possible EventEmitter memory leak detected. "+A.length+" "+p+" listeners added. Use emitter.setMaxListeners() to increase limit");P.name="MaxListenersExceededWarning",P.emitter=f,P.type=p,P.count=A.length,function(R){typeof console.warn=="function"?console.warn(R):console.log(R)}(P)}}else A=E[p]=h,++f._eventsCount;return f}function a(f,p,h){function v(){f.removeListener(p,v),k||(k=!0,h.apply(f,arguments))}var k=!1;return v.listener=h,v}function l(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 c(f,p){for(var h=Array(p);p--;)h[p]=f[p];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 p,h,v,k,E,A,P,R=f==="error";if(A=this._events)R=R&&A.error==null;else if(!R)return!1;if(P=this.domain,R){if(p=arguments[1],!P){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=P,p.domainThrown=!1,P.emit("error",p),!1}if(!(h=A[f]))return!1;var K=typeof h=="function";switch(v=arguments.length){case 1:(function(N,rt,Q){if(rt)N.call(Q);else for(var j=N.length,lt=c(N,j),W=0;W<j;++W)lt[W].call(Q)})(h,K,this);break;case 2:(function(N,rt,Q,j){if(rt)N.call(Q,j);else for(var lt=N.length,W=c(N,lt),Y=0;Y<lt;++Y)W[Y].call(Q,j)})(h,K,this,arguments[1]);break;case 3:(function(N,rt,Q,j,lt){if(rt)N.call(Q,j,lt);else for(var W=N.length,Y=c(N,W),Z=0;Z<W;++Z)Y[Z].call(Q,j,lt)})(h,K,this,arguments[1],arguments[2]);break;case 4:(function(N,rt,Q,j,lt,W){if(rt)N.call(Q,j,lt,W);else for(var Y=N.length,Z=c(N,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(k=Array(v-1),E=1;E<v;E++)k[E-1]=arguments[E];(function(N,rt,Q,j){if(rt)N.apply(Q,j);else for(var lt=N.length,W=c(N,lt),Y=0;Y<lt;++Y)W[Y].apply(Q,j)})(h,K,this,k)}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,v,k,E,A;if(typeof p!="function")throw new TypeError('"listener" argument must be a function');if(!(v=this._events))return this;if(!(h=v[f]))return this;if(h===p||h.listener&&h.listener===p)--this._eventsCount==0?this._events=new i:(delete v[f],v.removeListener&&this.emit("removeListener",f,h.listener||p));else if(typeof h!="function"){for(k=-1,E=h.length;0<E--;)if(h[E]===p||h[E].listener&&h[E].listener===p){A=h[E].listener,k=E;break}if(0>k)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(P,R){for(var V=R,K=V+1,N=P.length;K<N;V+=1,K+=1)P[V]=P[K];P.pop()})(h,k);v.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 v,k=Object.keys(h),E=0;E<k.length;++E)(v=k[E])!=="removeListener"&&this.removeAllListeners(v);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,v=this._events;return v?h=(p=v[f])?typeof p=="function"?[p.listener||p]:function(k){for(var E=Array(k.length),A=0;A<E.length;++A)E[A]=k[A].listener||k[A];return E}(p):[]:h=[],h},s.listenerCount=function(f,p){return typeof f.listenerCount=="function"?f.listenerCount(p):l.call(f,p)},s.prototype.listenerCount=l,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,_=[],w=0;256>w;++w)_.push((w+256).toString(16).substr(1));function b(f){var p=1<arguments.length&&arguments[1]!==void 0?arguments[1]:0,h=(_[f[p+0]]+_[f[p+1]]+_[f[p+2]]+_[f[p+3]]+"-"+_[f[p+4]]+_[f[p+5]]+"-"+_[f[p+6]]+_[f[p+7]]+"-"+_[f[p+8]]+_[f[p+9]]+"-"+_[f[p+10]]+_[f[p+11]]+_[f[p+12]]+_[f[p+13]]+_[f[p+14]]+_[f[p+15]]).toLowerCase();if(!function(v){return typeof v=="string"&&g.test(v)}(h))throw TypeError("Stringified UUID is invalid");return h}function y(f,p,h){var v=(f=f||{}).random||(f.rng||m)();return v[6]=64|15&v[6],v[8]=128|63&v[8],b(v)}function S(f,p){if(!f||!p)return{};const h={...f};if(h.localCandidateId){const v=p.get(h.localCandidateId);h.local={...v}}if(h.remoteCandidateId){const v=p.get(h.remoteCandidateId);h.remote={...v}}return h}function C(f,p,h){return 8*function(v,k,E){const A=v[E],P=k?k[E]:null;return A===null||P===null?null:(A-P)/(v.timestamp-k.timestamp)*1e3}(f,p,h)}function I(f){if(!f.entries)return f;const p={};return f.forEach(function(h,v){p[v]=h}),p}function L(f,p,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 k of f.values())switch(k.type){case"outbound-rtp":{const E=k.mediaType||k.kind,A={};let P={};if(!["audio","video"].includes(E))continue;if(k.codecId){const R=f.get(k.codecId);R&&(A.clockRate=R.clockRate,A.mimeType=R.mimeType,A.payloadType=R.payloadType)}P=f.get(k.mediaSourceId)||f.get(k.trackId)||{},v[E].outbound.push({...k,...A,track:{...P}});break}case"inbound-rtp":{let E=k.mediaType||k.kind,A={};const P={};if(!["audio","video"].includes(E))if(k.id.includes("Video"))E="video";else{if(!k.id.includes("Audio"))continue;E="audio"}if(k.codecId){const R=f.get(k.codecId);R&&(P.clockRate=R.clockRate,P.mimeType=R.mimeType,P.payloadType=R.payloadType)}if(!v.connection.id&&k.transportId){const R=f.get(k.transportId);if(R&&R.selectedCandidatePairId){const V=f.get(R.selectedCandidatePairId);v.connection=S(V,f)}}A=f.get(k.mediaSourceId)||f.get(k.trackId)||{},v[E].inbound.push({...k,...P,track:{...A}});break}case"peer-connection":v.connection.dataChannelsClosed=k.dataChannelsClosed,v.connection.dataChannelsOpened=k.dataChannelsOpened;break;case"remote-inbound-rtp":{if(!h.remote)break;let E=k.mediaType||k.kind;const A={};if(!["audio","video"].includes(E))if(k.id.includes("Video"))E="video";else{if(!k.id.includes("Audio"))continue;E="audio"}if(k.codecId){const P=f.get(k.codecId);P&&(A.clockRate=P.clockRate,A.mimeType=P.mimeType,A.payloadType=P.payloadType)}if(!v.connection.id&&k.transportId){const P=f.get(k.transportId);if(P&&P.selectedCandidatePairId){const R=f.get(P.selectedCandidatePairId);v.connection=S(R,f)}}v.remote[E].inbound.push({...k,...A});break}case"remote-outbound-rtp":{if(!h.remote)break;const E=k.mediaType||k.kind,A={};if(!["audio","video"].includes(E))continue;if(k.codecId){const P=f.get(k.codecId);P&&(A.clockRate=P.clockRate,A.mimeType=P.mimeType,A.payloadType=P.payloadType)}v.remote[E].outbound.push({...k,...A});break}}if(!v.connection.id)for(const k of f.values())k.type==="candidate-pair"&&k.nominated&&k.state==="succeeded"&&(v.connection=S(k,f));return v=function(k,E){return E&&(k.audio.inbound.map(A=>{let P=E.audio.inbound.find(R=>R.id===A.id);A.bitrate=C(A,P,"bytesReceived"),A.packetRate=C(A,P,"packetsReceived")}),k.audio.outbound.map(A=>{let P=E.audio.outbound.find(R=>R.id===A.id);A.bitrate=C(A,P,"bytesSent"),A.packetRate=C(A,P,"packetsSent")}),k.video.inbound.map(A=>{let P=E.video.inbound.find(R=>R.id===A.id);A.bitrate=C(A,P,"bytesReceived"),A.packetRate=C(A,P,"packetsReceived")}),k.video.outbound.map(A=>{let P=E.video.outbound.find(R=>R.id===A.id);A.bitrate=C(A,P,"bytesSent"),A.packetRate=C(A,P,"packetsSent")})),k}(v,p),v}let D,x={},T=[];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 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:v,remote:k}=f;if(k=typeof k=="boolean"?k: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(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 P=this.peersToMonitor[h][A];if(P.pc===p)throw new Error(`We are already monitoring peer with id ${h}.`);P.pc.connectionState==="closed"&&this.removeConnection({pc:P.pc})}}const E=p.getConfiguration();return E.iceServers&&E.iceServers.forEach(function(A){delete A.credential}),v||(v=y()),this.emitEvent({event:"addConnection",tag:"peer",peerId:h,connectionId:v,data:{options:f,peerConfiguration:E}}),this.monitorPeer({peerId:h,connectionId:v,pc:p,remote:k}),{connectionId:v}}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: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 k in this.peersToMonitor)h in this.peersToMonitor[k]&&(v=this.peersToMonitor[k][h].pc,p=k)}else if(v){if(!(v instanceof RTCPeerConnection))throw new Error("pc must be an instance of RTCPeerConnection.");for(let k in this.peersToMonitor)for(let E in this.peersToMonitor[k])this.peersToMonitor[k][E].pc===v&&(h=E,p=k)}if(!v||!h)throw new Error("Could not find the desired connection.");return this.removePeerConnectionEventListeners(h,v),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(),T.forEach(f=>{this.removeTrackEventListeners(f)}),T=[],this.shouldWrapGetUserMedia&&D&&(navigator.mediaDevices.getUserMedia=D)}monitorPeer(f){let{peerId:p,connectionId:h,pc:v,remote:k}=f;if(!v)return void this.logger.warn("Did not receive pc argument when calling monitorPeer()");const E={pc:v,connectionId:h,stream:null,stats:{parsed:null,raw:null},options:{remote:k}};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]=E}else this.peersToMonitor[p]={[h]:E};this.addPeerConnectionEventListeners(p,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(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 v in p)for(const k in p[v]){const E=p[v][k],A=E.pc;if(A&&!this.checkIfConnectionIsClosed(v,k,A))try{const P=this.getTimestamp(),R=A.getStats(null);if(R){const V=await R,K=this.getTimestamp(),N=I(V),rt={remote:E.options.remote},Q=L(V,E.stats.parsed,rt),j={event:"stats",tag:"stats",peerId:v,connectionId:k,timeTaken:K-P,data:Q};this.rawStats===!0&&(j.rawStats=V),this.statsObject===!0&&(j.statsObject=N),this.filteredStats===!0&&(j.filteredStats=this.filteroutStats(N)),h.push(j),E.stats.parsed=Q}else this.logger.error(`PeerConnection from peer ${v} did not return any stats data`)}catch(P){this.logger.error(P)}}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 v=this.isConnectionClosed(h);if(v){this.removeConnection({pc:h});let k=h.connectionState==="closed"?"onconnectionstatechange":"oniceconnectionstatechange";this.emitEvent({event:k,peerId:f,connectionId:p,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(p=>(f({stream:p}),p),p=>(f({error:p}),Promise.reject(p)))}).bind(navigator.mediaDevices)}filteroutStats(f={}){const p={...f};for(const v in p){var h=p[v];this.statsToMonitor.includes(h.type)||delete p[v]}return p}get peerConnectionListeners(){return{icecandidate:(f,p,h,v)=>{this.logger.debug("[pc-event] icecandidate | peerId: ${peerId}",v),this.emitEvent({event:"onicecandidate",tag:"connection",peerId:f,connectionId:p,data:v.candidate})},track:(f,p,h,v)=>{this.logger.debug(`[pc-event] track | peerId: ${f}`,v);const k=v.track,E=v.streams[0];f in this.peersToMonitor&&p in this.peersToMonitor[f]&&(this.peersToMonitor[f][p].stream=E),this.addTrackEventListeners(k,p),this.emitEvent({event:"ontrack",tag:"track",peerId:f,connectionId:p,data:{stream:E?this.getStreamDetails(E):null,track:k?this.getMediaTrackDetails(k):null,title:v.track.kind+":"+v.track.id+" "+v.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,v)=>{this.logger.debug(`[pc-event] icecandidateerror | peerId: ${f}`),this.emitEvent({event:"onicecandidateerror",tag:"connection",peerId:f,connectionId:p,error:{errorCode:v.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,v)=>{this.logger.debug(`[pc-event] datachannel | peerId: ${f}`,v),this.emitEvent({event:"ondatachannel",tag:"datachannel",peerId:f,connectionId:p,data:v.channel})}}}addPeerConnectionEventListeners(f,p,h){this.logger.debug(`Adding event listeners for peer ${f} and connection ${p}.`),x[p]={},Object.keys(this.peerConnectionListeners).forEach(v=>{x[p][v]=this.peerConnectionListeners[v].bind(this,f,p,h),h.addEventListener(v,x[p][v],!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),T.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(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 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(v){return v},function(v){return f.debug("navigator.mediaDevices.getDisplayMediaOnFailure",null,v.name),Promise.reject(v)})};navigator.mediaDevices.getDisplayMedia=h.bind(navigator.mediaDevices)}}}});(Bi=qu)&&Bi.__esModule&&Object.prototype.hasOwnProperty.call(Bi,"default")&&Bi.default;var Wv=qu.WebRTCStats;function zv(e){const{packetsLost:t,packetsReceived:n,jitter:i,rtt:s}=e,o=function(c){const{jitter:d,rtt:u}=c,m=d+u/2;return .024*m+.11*(m-177.3)*(m>177.3?1:0)}({rtt:s,jitter:i}),r=function(c){const{packetsLost:d,packetsReceived:u}=c,m=d/(u+d)*100;return 20*Math.log(1+m)}({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 qv(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 Kv extends Li{constructor(t){super(),this.buildRequest({type:"debug_report_start",debug_report_id:t,debug_report_version:1})}}class Xv extends Li{constructor(t){super(),this.buildRequest({type:"debug_report_stop",debug_report_id:t,debug_report_version:1})}}class Yv extends Li{constructor(t,n){super(),this.buildRequest({type:"debug_report_data",debug_report_id:t,debug_report_version:1,debug_report_data:n})}}function Zv(e){const t=$n(),n=new Wv({getStatsInterval:1e3,rawStats:!1,statsObject:!0,filteredStats:!1,remote:!0,debug:!1,logLevel:"warn"}),i=s=>G(this,void 0,void 0,function*(){s.event==="stats"&&J(B.StatsFrame,function({data:o}){var r,a,l,c,d,u,m,g;const{audio:_,remote:w}=o,{audio:b}=w,y=(a=(r=b.inbound[0])===null||r===void 0?void 0:r.jitter)!==null&&a!==void 0?a:1/0,S=(c=(l=b.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,I=(g=(m=_.inbound[0])===null||m===void 0?void 0:m.packetsLost)!==null&&g!==void 0?g:-1,L=zv({jitter:1e3*y,rtt:1e3*S,packetsLost:I,packetsReceived:C});return{jitter:y,rtt:S,mos:L,quality:qv(L),inboundAudio:_.inbound[0],outboundAudio:_.outbound[0],remoteInboundAudio:b.inbound[0],remoteOutboundAudio:b.outbound[0]}}(s),e.uuid),yield e.execute(new Yv(t,s))});return{start:(s,o,r)=>G(this,void 0,void 0,function*(){yield e.execute(new Kv(t)),n.on("timeline",i),yield new Promise(a=>setTimeout(a,500)),n.addConnection({pc:s,peerId:o,connectionId:r})}),stop:s=>G(this,void 0,void 0,function*(){const o=n.getTimeline();J(B.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 Xv(t)),n.removeAllPeers(),n.destroy()})}}class Ku{constructor(t,n,i){this.type=t,this.options=n,this.onSdpReadyTwice=null,this.statsReporter=null,this._negotiating=!1,this.handleConnectionStateChange=s=>G(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},F.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=Zv(i))}get isOffer(){return this.type===Vt.Offer}get isAnswer(){return this.type===Vt.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(){F.info("Number of transceivers:",this.instance.getTransceivers().length),this.instance.getTransceivers().forEach((t,n)=>{F.info(`>> Transceiver [${n}]:`,t.mid,t.direction,t.stopped),F.info(`>> Sender Params [${n}]:`,JSON.stringify(t.sender.getParameters(),null,2))})}handleSignalingStateChangeEvent(t){switch(F.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(){F.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&&Di(i,o)}createPeerConnection(){return G(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(B.MediaError,n,this.options.id),null))})}_init(){var t;return G(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(Mi(i)){const o=i.getAudioTracks();F.info("Local audio tracks: ",o);const r=i.getVideoTracks();if(F.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=Un(a);l&&(l.muted=!0)})(n),Di(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);F.info("Add transceiver",t,n)}}_createOffer(){return G(this,void 0,void 0,function*(){this._isOffer()&&(this._constraints.offerToReceiveAudio=!!this.options.audio,this._constraints.offerToReceiveVideo=!!this.options.video,F.info("_createOffer - this._constraints",this._constraints),yield this.instance.createOffer(this._constraints).then(this._setLocalDescription.bind(this)).then(this._sdpReady).catch(t=>F.error("Peer _createOffer error:",t)))})}_setRemoteDescription(t){return G(this,void 0,void 0,function*(){yield this.instance.setRemoteDescription(t)})}_createAnswer(){return G(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:Vt.Offer})]));yield this._setRemoteDescription({sdp:this.options.remoteSdp,type:Vt.Offer}),this._logTransceivers();const t=yield this.instance.createAnswer();yield this._setLocalDescription(t)})}_setLocalDescription(t){return G(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
|
|
80
|
+
`),this._wsClient.send(JSON.stringify(n)),i}close(){this._wsClient&&(rn(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(B.SpeedTest,{upDur:this.upDur,downDur:this.downDur},this.session.uuid)}else F.warn("Unknown message from socket",t)}}class Wn{buildRequest(t){this.request=Object.assign({jsonrpc:"2.0",id:sn()},t)}}const Mu={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 Dt extends Wn{constructor(t={}){if(super(),t.hasOwnProperty("dialogParams")){const n=Ar(t.dialogParams,["remoteSdp","localStream","remoteStream","onNotification","camId","micId","speakerId"]);for(const i in Mu)i&&n.hasOwnProperty(i)&&(n[Mu[i]]=n[i],delete n[i]);t.dialogParams=n}this.buildRequest({method:this.toString(),params:t})}}class Lu extends Dt{constructor(){super(),this.method=nt.GatewayState,this.buildRequest({method:this.method,params:{}})}}class Pv{constructor(t){this.pendingRequestId=null,this.onSocketMessage=n=>G(this,void 0,void 0,function*(){n.id===this.pendingRequestId&&this.gatewayStateTask.resolve(Ir(n))}),this.getIsRegistered=()=>G(this,void 0,void 0,function*(){const n=new Lu;this.pendingRequestId=n.request.id,this.gatewayStateTask=Au({}),this.session.execute(n);const i=yield this.gatewayStateTask.promise;return!!i&&[Rt.REGISTER,Rt.REGED].includes(i)}),this.session=t,this.gatewayStateTask=Au({}),this.session.on("telnyx.socket.message",this.onSocketMessage)}}class Mv{constructor(t){if(this.options=t,this.uuid=sn(),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 Pu(this),this.registerAgent=new Pv(this)}get __logger(){return F}get connected(){return this.connection&&this.connection.connected}get reconnectDelay(){return 1e3*Eu(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 Rr(this.options)||Mi(this.options)}broadcast(t){}disconnect(){return G(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 an(t,n,this.uuid),this}off(t,n){return ln(t,n,this.uuid),this}connect(){return G(this,void 0,void 0,function*(){this.connection||(this.connection=new Pu(this)),this._attachListeners(),this.connection.isAlive||this.connection.connect()})}_handleLoginError(t){J(B.Error,{error:t,sessionId:this.sessionid},this.uuid)}_onSocketOpen(){return G(this,void 0,void 0,function*(){})}onNetworkClose(){this.relayProtocol&&Lr(this.relayProtocol);for(const t in this.subscriptions)Lr(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],ln(t,null,n)):(delete this.subscriptions[t],Lr(t)))}_addSubscription(t,n=null,i){this._existsSubscription(t,i)||(this._existsSubscription(t)||(this.subscriptions[t]={}),this.subscriptions[t][i]={},rn(n)&&an(t,n,i))}_existsSubscription(t,n){return!(!this.subscriptions.hasOwnProperty(t)||!(!n||n&&this.subscriptions[t].hasOwnProperty(n)))}_attachListeners(){this._detachListeners(),this.on(B.SocketOpen,this._onSocketOpen),this.on(B.SocketClose,this.onNetworkClose),this.on(B.SocketError,this.onNetworkClose),this.on(B.SocketMessage,this._onSocketMessage)}_detachListeners(){this.off(B.SocketOpen,this._onSocketOpen),this.off(B.SocketClose,this.onNetworkClose),this.off(B.SocketError,this.onNetworkClose),this.off(B.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){an(t,n)}static off(t){ln(t)}static uuid(){return sn()}clearConnection(){this.connection=null}hasAutoReconnect(){return this._autoReconnect}getIsRegistered(){return this.registerAgent.getIsRegistered()}}const Dr=e=>navigator.mediaDevices.getUserMedia(e),Li=e=>e&&e instanceof MediaStream,Di=(e,t)=>{const n=Un(e);n!==null&&(n.getAttribute("autoplay")||n.setAttribute("autoplay","autoplay"),n.getAttribute("playsinline")||n.setAttribute("playsinline","playsinline"),n.srcObject=t)},Du=(e,t)=>G(void 0,void 0,void 0,function*(){const n=Un(e);if(n===null)return F.info("No HTMLMediaElement to attach the speakerId"),!1;if(typeof t!="string")return F.info(`Invalid speaker deviceId: '${t}'`),!1;try{return yield n.setSinkId(t),!0}catch{return!1}}),Lv=e=>{e&&e.readyState==="live"&&e.stop()},zn=e=>{Li(e)&&e.getTracks().forEach(Lv),e=null},Oi=e=>G(void 0,void 0,void 0,function*(){F.info("RTCService.getUserMedia",e);const{audio:t,video:n}=e;if(!t&&!n)return null;try{return yield Dr(e)}catch(i){throw F.error("getUserMedia error: ",i),i}}),qn=(e=null,t=!1)=>G(void 0,void 0,void 0,function*(){let n=[];const i=yield navigator.mediaDevices.getUserMedia(((s=null)=>({audio:!s||s===re.AudioIn||s===re.AudioOut,video:!s||s===re.Video}))(e)).catch(s=>(console.error(s),null));if(i){if(zn(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}),Ou=[[320,240],[640,360],[640,480],[1280,720],[1920,1080]],Vi=(e,t,n)=>G(void 0,void 0,void 0,function*(){const i=yield qn(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}),Vu=e=>{const t=navigator.mediaDevices.getSupportedConstraints();Object.keys(e).map(n=>{t.hasOwnProperty(n)&&e[n]!==null&&e[n]!==void 0||delete e[n]})},Nu=(e,t,n,i)=>G(void 0,void 0,void 0,function*(){const{deviceId:s}=i;if(s===void 0&&(e||t)){const o=yield Vi(e,t,n).catch(r=>null);o&&(i.deviceId={exact:o})}return i}),Ni=(e,t)=>{if(!e)return!1;const{subscribed:n,alreadySubscribed:i}=Or(e);return n.includes(t)||i.includes(t)},Or=e=>{const t={subscribed:[],alreadySubscribed:[],unauthorized:[],unsubscribed:[],notSubscribed:[]};return Object.keys(t).forEach(n=>{t[n]=e[`${n}Channels`]||[]}),t},cn=(e,t=null,n=null)=>{if(!Li(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}})},Bu=e=>{cn(e,"audio",!0)},Fu=e=>{cn(e,"audio",!1)},ju=e=>{cn(e,"audio",null)};function Dv(){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],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,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:!!Oi}}catch(e){return e.message}}var vt;function $u(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 Uu(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 Gu(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 Hu="2.22.14",Vr=Hu;class Ov extends Dt{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:Vr,data:navigator.userAgent}};s&&(a.sessid=s),this.buildRequest({method:this.method,params:a})}}class Vv extends Dt{constructor(t,n){super(),this.buildRequest({id:t,result:{method:n}})}}class Nv extends Dt{toString(){return nt.Invite}}class Bv extends Dt{toString(){return nt.Answer}}class Fv extends Dt{toString(){return nt.Attach}}class jv extends Dt{toString(){return nt.Bye}}class Nr extends Dt{toString(){return nt.Modify}}class Wu extends Dt{toString(){return nt.Info}}class $v extends Dt{toString(){return nt.Broadcast}}class Uv extends Dt{toString(){return nt.Subscribe}}class Gv extends Dt{toString(){return nt.Unsubscribe}}class Hv extends Wn{constructor(t){super(),this.method="ai_conversation",this.buildRequest({method:this.method,params:{type:"conversation.item.create",previous_item_id:null,item:{id:sn(),type:"message",role:"user",content:[{type:"input_text",text:t}]}}})}}const zu=(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:se.conferenceUpdate,call:e.calls[s],canvasInfo:Wv(o),currentLayerIdx:r};switch(n){case"layer-info":{const l=Object.assign({action:At.LayerInfo},a);J(B.Notification,l,e.uuid);break}case"layout-info":{const l=Object.assign({action:At.LayoutInfo},a);J(B.Notification,l,e.uuid);break}}},Wv=e=>{const t=JSON.stringify(e).replace(/memberID/g,"participantId").replace(/ID"/g,'Id"').replace(/POS"/g,'Pos"');return Tu(t)};var Bi,qu=Su(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,p,h,v){var k,A,E;if(typeof h!="function")throw new TypeError('"listener" argument must be a function');if((A=f._events)?(A.newListener&&(f.emit("newListener",p,h.listener?h.listener:h),A=f._events),E=A[p]):(A=f._events=new i,f._eventsCount=0),E){if(typeof E=="function"?E=A[p]=v?[h,E]:[E,h]:v?E.unshift(h):E.push(h),!E.warned&&(k=o(f))&&0<k&&E.length>k){E.warned=!0;var P=new Error("Possible EventEmitter memory leak detected. "+E.length+" "+p+" listeners added. Use emitter.setMaxListeners() to increase limit");P.name="MaxListenersExceededWarning",P.emitter=f,P.type=p,P.count=E.length,function(R){typeof console.warn=="function"?console.warn(R):console.log(R)}(P)}}else E=A[p]=h,++f._eventsCount;return f}function a(f,p,h){function v(){f.removeListener(p,v),k||(k=!0,h.apply(f,arguments))}var k=!1;return v.listener=h,v}function l(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 c(f,p){for(var h=Array(p);p--;)h[p]=f[p];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 p,h,v,k,A,E,P,R=f==="error";if(E=this._events)R=R&&E.error==null;else if(!R)return!1;if(P=this.domain,R){if(p=arguments[1],!P){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=P,p.domainThrown=!1,P.emit("error",p),!1}if(!(h=E[f]))return!1;var K=typeof h=="function";switch(v=arguments.length){case 1:(function(N,rt,Q){if(rt)N.call(Q);else for(var j=N.length,lt=c(N,j),W=0;W<j;++W)lt[W].call(Q)})(h,K,this);break;case 2:(function(N,rt,Q,j){if(rt)N.call(Q,j);else for(var lt=N.length,W=c(N,lt),Y=0;Y<lt;++Y)W[Y].call(Q,j)})(h,K,this,arguments[1]);break;case 3:(function(N,rt,Q,j,lt){if(rt)N.call(Q,j,lt);else for(var W=N.length,Y=c(N,W),Z=0;Z<W;++Z)Y[Z].call(Q,j,lt)})(h,K,this,arguments[1],arguments[2]);break;case 4:(function(N,rt,Q,j,lt,W){if(rt)N.call(Q,j,lt,W);else for(var Y=N.length,Z=c(N,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(k=Array(v-1),A=1;A<v;A++)k[A-1]=arguments[A];(function(N,rt,Q,j){if(rt)N.apply(Q,j);else for(var lt=N.length,W=c(N,lt),Y=0;Y<lt;++Y)W[Y].apply(Q,j)})(h,K,this,k)}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,v,k,A,E;if(typeof p!="function")throw new TypeError('"listener" argument must be a function');if(!(v=this._events))return this;if(!(h=v[f]))return this;if(h===p||h.listener&&h.listener===p)--this._eventsCount==0?this._events=new i:(delete v[f],v.removeListener&&this.emit("removeListener",f,h.listener||p));else if(typeof h!="function"){for(k=-1,A=h.length;0<A--;)if(h[A]===p||h[A].listener&&h[A].listener===p){E=h[A].listener,k=A;break}if(0>k)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(P,R){for(var V=R,K=V+1,N=P.length;K<N;V+=1,K+=1)P[V]=P[K];P.pop()})(h,k);v.removeListener&&this.emit("removeListener",f,E||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 v,k=Object.keys(h),A=0;A<k.length;++A)(v=k[A])!=="removeListener"&&this.removeAllListeners(v);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,v=this._events;return v?h=(p=v[f])?typeof p=="function"?[p.listener||p]:function(k){for(var A=Array(k.length),E=0;E<A.length;++E)A[E]=k[E].listener||k[E];return A}(p):[]:h=[],h},s.listenerCount=function(f,p){return typeof f.listenerCount=="function"?f.listenerCount(p):l.call(f,p)},s.prototype.listenerCount=l,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,_=[],w=0;256>w;++w)_.push((w+256).toString(16).substr(1));function b(f){var p=1<arguments.length&&arguments[1]!==void 0?arguments[1]:0,h=(_[f[p+0]]+_[f[p+1]]+_[f[p+2]]+_[f[p+3]]+"-"+_[f[p+4]]+_[f[p+5]]+"-"+_[f[p+6]]+_[f[p+7]]+"-"+_[f[p+8]]+_[f[p+9]]+"-"+_[f[p+10]]+_[f[p+11]]+_[f[p+12]]+_[f[p+13]]+_[f[p+14]]+_[f[p+15]]).toLowerCase();if(!function(v){return typeof v=="string"&&g.test(v)}(h))throw TypeError("Stringified UUID is invalid");return h}function y(f,p,h){var v=(f=f||{}).random||(f.rng||m)();return v[6]=64|15&v[6],v[8]=128|63&v[8],b(v)}function S(f,p){if(!f||!p)return{};const h={...f};if(h.localCandidateId){const v=p.get(h.localCandidateId);h.local={...v}}if(h.remoteCandidateId){const v=p.get(h.remoteCandidateId);h.remote={...v}}return h}function C(f,p,h){return 8*function(v,k,A){const E=v[A],P=k?k[A]:null;return E===null||P===null?null:(E-P)/(v.timestamp-k.timestamp)*1e3}(f,p,h)}function I(f){if(!f.entries)return f;const p={};return f.forEach(function(h,v){p[v]=h}),p}function M(f,p,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 k of f.values())switch(k.type){case"outbound-rtp":{const A=k.mediaType||k.kind,E={};let P={};if(!["audio","video"].includes(A))continue;if(k.codecId){const R=f.get(k.codecId);R&&(E.clockRate=R.clockRate,E.mimeType=R.mimeType,E.payloadType=R.payloadType)}P=f.get(k.mediaSourceId)||f.get(k.trackId)||{},v[A].outbound.push({...k,...E,track:{...P}});break}case"inbound-rtp":{let A=k.mediaType||k.kind,E={};const P={};if(!["audio","video"].includes(A))if(k.id.includes("Video"))A="video";else{if(!k.id.includes("Audio"))continue;A="audio"}if(k.codecId){const R=f.get(k.codecId);R&&(P.clockRate=R.clockRate,P.mimeType=R.mimeType,P.payloadType=R.payloadType)}if(!v.connection.id&&k.transportId){const R=f.get(k.transportId);if(R&&R.selectedCandidatePairId){const V=f.get(R.selectedCandidatePairId);v.connection=S(V,f)}}E=f.get(k.mediaSourceId)||f.get(k.trackId)||{},v[A].inbound.push({...k,...P,track:{...E}});break}case"peer-connection":v.connection.dataChannelsClosed=k.dataChannelsClosed,v.connection.dataChannelsOpened=k.dataChannelsOpened;break;case"remote-inbound-rtp":{if(!h.remote)break;let A=k.mediaType||k.kind;const E={};if(!["audio","video"].includes(A))if(k.id.includes("Video"))A="video";else{if(!k.id.includes("Audio"))continue;A="audio"}if(k.codecId){const P=f.get(k.codecId);P&&(E.clockRate=P.clockRate,E.mimeType=P.mimeType,E.payloadType=P.payloadType)}if(!v.connection.id&&k.transportId){const P=f.get(k.transportId);if(P&&P.selectedCandidatePairId){const R=f.get(P.selectedCandidatePairId);v.connection=S(R,f)}}v.remote[A].inbound.push({...k,...E});break}case"remote-outbound-rtp":{if(!h.remote)break;const A=k.mediaType||k.kind,E={};if(!["audio","video"].includes(A))continue;if(k.codecId){const P=f.get(k.codecId);P&&(E.clockRate=P.clockRate,E.mimeType=P.mimeType,E.payloadType=P.payloadType)}v.remote[A].outbound.push({...k,...E});break}}if(!v.connection.id)for(const k of f.values())k.type==="candidate-pair"&&k.nominated&&k.state==="succeeded"&&(v.connection=S(k,f));return v=function(k,A){return A&&(k.audio.inbound.map(E=>{let P=A.audio.inbound.find(R=>R.id===E.id);E.bitrate=C(E,P,"bytesReceived"),E.packetRate=C(E,P,"packetsReceived")}),k.audio.outbound.map(E=>{let P=A.audio.outbound.find(R=>R.id===E.id);E.bitrate=C(E,P,"bytesSent"),E.packetRate=C(E,P,"packetsSent")}),k.video.inbound.map(E=>{let P=A.video.inbound.find(R=>R.id===E.id);E.bitrate=C(E,P,"bytesReceived"),E.packetRate=C(E,P,"packetsReceived")}),k.video.outbound.map(E=>{let P=A.video.outbound.find(R=>R.id===E.id);E.bitrate=C(E,P,"bytesSent"),E.packetRate=C(E,P,"packetsSent")})),k}(v,p),v}let D,x={},T=[];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 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:v,remote:k}=f;if(k=typeof k=="boolean"?k: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(v&&v in this.peersToMonitor[h])throw new Error(`We are already monitoring connection with id ${v}.`);for(let E in this.peersToMonitor[h]){const P=this.peersToMonitor[h][E];if(P.pc===p)throw new Error(`We are already monitoring peer with id ${h}.`);P.pc.connectionState==="closed"&&this.removeConnection({pc:P.pc})}}const A=p.getConfiguration();return A.iceServers&&A.iceServers.forEach(function(E){delete E.credential}),v||(v=y()),this.emitEvent({event:"addConnection",tag:"peer",peerId:h,connectionId:v,data:{options:f,peerConfiguration:A}}),this.monitorPeer({peerId:h,connectionId:v,pc:p,remote:k}),{connectionId:v}}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: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 k in this.peersToMonitor)h in this.peersToMonitor[k]&&(v=this.peersToMonitor[k][h].pc,p=k)}else if(v){if(!(v instanceof RTCPeerConnection))throw new Error("pc must be an instance of RTCPeerConnection.");for(let k in this.peersToMonitor)for(let A in this.peersToMonitor[k])this.peersToMonitor[k][A].pc===v&&(h=A,p=k)}if(!v||!h)throw new Error("Could not find the desired connection.");return this.removePeerConnectionEventListeners(h,v),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(),T.forEach(f=>{this.removeTrackEventListeners(f)}),T=[],this.shouldWrapGetUserMedia&&D&&(navigator.mediaDevices.getUserMedia=D)}monitorPeer(f){let{peerId:p,connectionId:h,pc:v,remote:k}=f;if(!v)return void this.logger.warn("Did not receive pc argument when calling monitorPeer()");const A={pc:v,connectionId:h,stream:null,stats:{parsed:null,raw:null},options:{remote:k}};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]=A}else this.peersToMonitor[p]={[h]:A};this.addPeerConnectionEventListeners(p,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(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 v in p)for(const k in p[v]){const A=p[v][k],E=A.pc;if(E&&!this.checkIfConnectionIsClosed(v,k,E))try{const P=this.getTimestamp(),R=E.getStats(null);if(R){const V=await R,K=this.getTimestamp(),N=I(V),rt={remote:A.options.remote},Q=M(V,A.stats.parsed,rt),j={event:"stats",tag:"stats",peerId:v,connectionId:k,timeTaken:K-P,data:Q};this.rawStats===!0&&(j.rawStats=V),this.statsObject===!0&&(j.statsObject=N),this.filteredStats===!0&&(j.filteredStats=this.filteroutStats(N)),h.push(j),A.stats.parsed=Q}else this.logger.error(`PeerConnection from peer ${v} did not return any stats data`)}catch(P){this.logger.error(P)}}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 v=this.isConnectionClosed(h);if(v){this.removeConnection({pc:h});let k=h.connectionState==="closed"?"onconnectionstatechange":"oniceconnectionstatechange";this.emitEvent({event:k,peerId:f,connectionId:p,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(p=>(f({stream:p}),p),p=>(f({error:p}),Promise.reject(p)))}).bind(navigator.mediaDevices)}filteroutStats(f={}){const p={...f};for(const v in p){var h=p[v];this.statsToMonitor.includes(h.type)||delete p[v]}return p}get peerConnectionListeners(){return{icecandidate:(f,p,h,v)=>{this.logger.debug("[pc-event] icecandidate | peerId: ${peerId}",v),this.emitEvent({event:"onicecandidate",tag:"connection",peerId:f,connectionId:p,data:v.candidate})},track:(f,p,h,v)=>{this.logger.debug(`[pc-event] track | peerId: ${f}`,v);const k=v.track,A=v.streams[0];f in this.peersToMonitor&&p in this.peersToMonitor[f]&&(this.peersToMonitor[f][p].stream=A),this.addTrackEventListeners(k,p),this.emitEvent({event:"ontrack",tag:"track",peerId:f,connectionId:p,data:{stream:A?this.getStreamDetails(A):null,track:k?this.getMediaTrackDetails(k):null,title:v.track.kind+":"+v.track.id+" "+v.streams.map(function(E){return"stream:"+E.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,v)=>{this.logger.debug(`[pc-event] icecandidateerror | peerId: ${f}`),this.emitEvent({event:"onicecandidateerror",tag:"connection",peerId:f,connectionId:p,error:{errorCode:v.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,v)=>{this.logger.debug(`[pc-event] datachannel | peerId: ${f}`,v),this.emitEvent({event:"ondatachannel",tag:"datachannel",peerId:f,connectionId:p,data:v.channel})}}}addPeerConnectionEventListeners(f,p,h){this.logger.debug(`Adding event listeners for peer ${f} and connection ${p}.`),x[p]={},Object.keys(this.peerConnectionListeners).forEach(v=>{x[p][v]=this.peerConnectionListeners[v].bind(this,f,p,h),h.addEventListener(v,x[p][v],!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),T.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(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 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(v){return v},function(v){return f.debug("navigator.mediaDevices.getDisplayMediaOnFailure",null,v.name),Promise.reject(v)})};navigator.mediaDevices.getDisplayMedia=h.bind(navigator.mediaDevices)}}}});(Bi=qu)&&Bi.__esModule&&Object.prototype.hasOwnProperty.call(Bi,"default")&&Bi.default;var zv=qu.WebRTCStats;function qv(e){const{packetsLost:t,packetsReceived:n,jitter:i,rtt:s}=e,o=function(c){const{jitter:d,rtt:u}=c,m=d+u/2;return .024*m+.11*(m-177.3)*(m>177.3?1:0)}({rtt:s,jitter:i}),r=function(c){const{packetsLost:d,packetsReceived:u}=c,m=d/(u+d)*100;return 20*Math.log(1+m)}({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 Kv(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 Xv extends Wn{constructor(t){super(),this.buildRequest({type:"debug_report_start",debug_report_id:t,debug_report_version:1})}}class Yv extends Wn{constructor(t){super(),this.buildRequest({type:"debug_report_stop",debug_report_id:t,debug_report_version:1})}}class Zv extends Wn{constructor(t,n){super(),this.buildRequest({type:"debug_report_data",debug_report_id:t,debug_report_version:1,debug_report_data:n})}}function Jv(e){const t=sn(),n=new zv({getStatsInterval:1e3,rawStats:!1,statsObject:!0,filteredStats:!1,remote:!0,debug:!1,logLevel:"warn"}),i=s=>G(this,void 0,void 0,function*(){s.event==="stats"&&J(B.StatsFrame,function({data:o}){var r,a,l,c,d,u,m,g;const{audio:_,remote:w}=o,{audio:b}=w,y=(a=(r=b.inbound[0])===null||r===void 0?void 0:r.jitter)!==null&&a!==void 0?a:1/0,S=(c=(l=b.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,I=(g=(m=_.inbound[0])===null||m===void 0?void 0:m.packetsLost)!==null&&g!==void 0?g:-1,M=qv({jitter:1e3*y,rtt:1e3*S,packetsLost:I,packetsReceived:C});return{jitter:y,rtt:S,mos:M,quality:Kv(M),inboundAudio:_.inbound[0],outboundAudio:_.outbound[0],remoteInboundAudio:b.inbound[0],remoteOutboundAudio:b.outbound[0]}}(s),e.uuid),yield e.execute(new Zv(t,s))});return{start:(s,o,r)=>G(this,void 0,void 0,function*(){yield e.execute(new Xv(t)),n.on("timeline",i),yield new Promise(a=>setTimeout(a,500)),n.addConnection({pc:s,peerId:o,connectionId:r})}),stop:s=>G(this,void 0,void 0,function*(){const o=n.getTimeline();J(B.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 Yv(t)),n.removeAllPeers(),n.destroy()})}}class Ku{constructor(t,n,i){this.type=t,this.options=n,this.onSdpReadyTwice=null,this.statsReporter=null,this._negotiating=!1,this.handleConnectionStateChange=s=>G(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},F.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=Jv(i))}get isOffer(){return this.type===Vt.Offer}get isAnswer(){return this.type===Vt.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(){F.info("Number of transceivers:",this.instance.getTransceivers().length),this.instance.getTransceivers().forEach((t,n)=>{F.info(`>> Transceiver [${n}]:`,t.mid,t.direction,t.stopped),F.info(`>> Sender Params [${n}]:`,JSON.stringify(t.sender.getParameters(),null,2))})}handleSignalingStateChangeEvent(t){switch(F.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(){F.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&&Di(i,o)}createPeerConnection(){return G(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(B.MediaError,n,this.options.id),null))})}_init(){var t;return G(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(Li(i)){const o=i.getAudioTracks();F.info("Local audio tracks: ",o);const r=i.getVideoTracks();if(F.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=Un(a);l&&(l.muted=!0)})(n),Di(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);F.info("Add transceiver",t,n)}}_createOffer(){return G(this,void 0,void 0,function*(){this._isOffer()&&(this._constraints.offerToReceiveAudio=!!this.options.audio,this._constraints.offerToReceiveVideo=!!this.options.video,F.info("_createOffer - this._constraints",this._constraints),yield this.instance.createOffer(this._constraints).then(this._setLocalDescription.bind(this)).then(this._sdpReady).catch(t=>F.error("Peer _createOffer error:",t)))})}_setRemoteDescription(t){return G(this,void 0,void 0,function*(){yield this.instance.setRemoteDescription(t)})}_createAnswer(){return G(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:Vt.Offer})]));yield this._setRemoteDescription({sdp:this.options.remoteSdp,type:Vt.Offer}),this._logTransceivers();const t=yield this.instance.createAnswer();yield this._setLocalDescription(t)})}_setLocalDescription(t){return G(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
|
|
81
81
|
`,c=a.split(l),d=c.findIndex(_=>/^a=rtpmap/.test(_)&&/opus\/48000/.test(_));if(d<0)return a;const u=(_=>{const w=new RegExp("a=rtpmap:(\\d+) \\w+\\/\\d+"),b=_.match(w);return b&&b.length==2?b[1]:null})(c[d]),m=new RegExp(`a=fmtp:${u}`),g=c.findIndex(_=>m.test(_));return g>=0?/stereo=1;/.test(c[g])||(c[g]+="; stereo=1; sprop-stereo=1"):c[d]+=`${l}a=fmtp:${u} stereo=1; sprop-stereo=1`,c.join(l)})(t.sdp)),i&&s&&o&&(t.sdp=((a,l,c,d)=>{const u=a.split(`\r
|
|
82
82
|
`);return u.forEach((m,g)=>{/^a=fmtp:\d*/.test(m)?u[g]+=`;x-google-max-bitrate=${l};x-google-min-bitrate=${c};x-google-start-bitrate=${d}`:/^a=mid:(1|video)/.test(m)&&(u[g]+=`\r
|
|
83
83
|
b=AS:${l}`)}),u.join(`\r
|
|
@@ -85,8 +85,8 @@ b=AS:${l}`)}),u.join(`\r
|
|
|
85
85
|
b=`+c+":"+d+`\r
|
|
86
86
|
`):a.replace(new RegExp("b="+c+`:.*\r
|
|
87
87
|
`),"b="+c+":"+d+`\r
|
|
88
|
-
`)})(t.sdp,r.sdpASBandwidthKbps)),yield this.instance.setLocalDescription(t)})}_sdpReady(){sn(this.onSdpReadyTwice)&&this.onSdpReadyTwice(this.instance.localDescription)}_retrieveLocalStream(){return G(this,void 0,void 0,function*(){if(Mi(this.options.localStream))return this.options.localStream;const t=yield(n=this.options,G(void 0,void 0,void 0,function*(){let{audio:i=!0,micId:s}=n;const{micLabel:o=""}=n;s&&(s=yield Vi(s,o,re.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 Vi(r,l,re.Video).catch(c=>null),r&&(typeof a=="boolean"&&(a={}),a.deviceId={exact:r})),{audio:i,video:a}}));var n;return Oi(t)})}_isOffer(){return this.type===Vt.Offer}_isAnswer(){return this.type===Vt.Answer}_config(){const{prefetchIceCandidates:t,forceRelayCandidate:n}=this.options,i={bundlePolicy:"max-compat",iceCandidatePoolSize:t?10:0,iceServers:[_v,xu],iceTransportPolicy:n?"relay":"all"};return F.info("RTC config",i),i}close(){var t;return G(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 Jv=Vr;class Xu{constructor(t,n){this.session=t,this.id="",this.state=X[X.New],this.prevState="",this.channels=[],this.role=Gn.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=b=>{const y=b<0||!this._lastSerno||this._lastSerno&&b===this._lastSerno+1;return y&&b>=0&&(this._lastSerno=b),y},this._doStats=()=>{this.peer&&this.peer.instance&&this._statsBindings.length!==0&&this.peer.instance.getStats().then(b=>{b.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:m,video:g},ringtoneFile:_,ringbackFile:w}=t;this.options=Object.assign({},Tv,{audio:m,video:g,iceServers:i,localElement:c,remoteElement:d,micId:o,micLabel:r,camId:a,camLabel:l,speakerId:s,ringtoneFile:_,ringbackFile:w,debug:u.debug,debugOutput:u.debugOutput},n),this._onMediaError=this._onMediaError.bind(this),this._init(),this.options&&(this._ringtone=$u(this.options.ringtoneFile,"_ringtone"),this._ringback=$u(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=xe.Outbound,this.peer=new Ku(Vt.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=xe.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 Ku(Vt.Answer,this.options,this.session),this._registerPeerEvents()}playRingtone(){Uu(this._ringtone)}stopRingtone(){Gu(this._ringtone)}playRingback(){Uu(this._ringback)}stopRingback(){Gu(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 jv({sessid:this.session.sessionid,dialogParams:this.options,cause:"USER_BUSY",causeCode:17});this._execute(c).catch(d=>{F.error("telnyx_rtc.bye failed!",d),J(B.Error,{error:d,sessionId:this.session.sessionid},this.session.uuid)}).then(l.bind(this))}else l()}hold(){const t=new Nr({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 Nr({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 Nr({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 Wu({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 Wu({sessid:this.session.sessionid,msg:i,dialogParams:this.options});this._execute(s)}muteAudio(){Fu(this.options.localStream)}unmuteAudio(){Bu(this.options.localStream)}toggleAudioMute(){ju(this.options.localStream)}setAudioInDevice(t){return G(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 Dr({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,ln(t,"video",!1)}unmuteVideo(){var t;t=this.options.localStream,ln(t,"video",!0)}toggleVideoMute(){var t;t=this.options.localStream,ln(t,"video",null)}setVideoDevice(t){return G(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 Dr({video:{deviceId:{exact:t}}}),o=s.getVideoTracks()[0];i.replaceTrack(o);const{localElement:r,localStream:a}=this.options;Di(r,s),this.options.camId=t,a.getAudioTracks().forEach(l=>s.addTrack(l)),a.getVideoTracks().forEach(l=>l.stop()),this.options.localStream=s}})}deaf(){Fu(this.options.remoteStream)}undeaf(){Bu(this.options.remoteStream)}toggleDeaf(){ju(this.options.remoteStream)}setBandwidthEncodingsMaxBps(t,n){return G(this,void 0,void 0,function*(){if(!this||!this.peer)return void F.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 F.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"}]),F.info("Parameters: ",r),F.info("Setting max ",n==="audio"?"audio":"video"," bandwidth to: ",t," [bps]"),r.encodings[0].maxBitrate=t,yield o.setParameters(r).then(()=>{F.info(n==="audio"?"New audio":"New video"," bandwidth settings in use: ",o.getParameters())}).catch(a=>console.error(a))}else F.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(),F.info(`Call ${this.id} state change from ${this.prevState} to ${this.state}`),this._dispatchNotification({type:se.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&&Du(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===xe.Inbound?xe.Outbound:xe.Inbound,c={type:se[n],call:this,displayName:o,displayNumber:r,displayDirection:l};J(B.Notification,c,this.id)||J(B.Notification,c,this.session.uuid);break}case nt.Info:case nt.Event:{const o=Object.assign(Object.assign({},i),{type:se.generic,call:this});J(B.Notification,o,this.id)||J(B.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 G(this,void 0,void 0,function*(){if(!this._checkConferenceSerno(t.wireSerno)&&t.name!==n.laName)return F.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:m}=n;this._dispatchConferenceUpdate({action:Et.Join,conferenceName:d,participantId:Number(u),role:m}),a&&(yield this._subscribeConferenceChat(a)),l&&(yield this._subscribeConferenceInfo(l)),c&&m===Gn.Moderator&&(yield this._subscribeConferenceModerator(c));const g=[];for(const _ in s)g.push(Object.assign({callId:s[_][0],index:Number(_)},Ii(s[_][1])));this._dispatchConferenceUpdate({action:Et.Bootstrap,participants:g});break}case"add":this._dispatchConferenceUpdate(Object.assign({action:Et.Add,callId:o,index:r},Ii(s)));break;case"modify":this._dispatchConferenceUpdate(Object.assign({action:Et.Modify,callId:o,index:r},Ii(s)));break;case"del":this._dispatchConferenceUpdate(Object.assign({action:Et.Delete,callId:o,index:r},Ii(s)));break;case"clear":this._dispatchConferenceUpdate({action:Et.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 G(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:Et.ChatMessage,direction:o,participantNumber:r,participantName:a,messageText:l,messageType:c,messageId:s.eventSerno})}},i=yield this.session.vertoSubscribe(n).catch(s=>{F.error("ConfChat subscription error:",s)});Ni(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 G(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,zu(this.session,o)):F.error("Conference-Info unknown contentType",s)}},i=yield this.session.vertoSubscribe(n).catch(s=>{F.error("ConfInfo subscription error:",s)});Ni(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 G(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"&&Cu(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:Et.LayoutList,layouts:JSON.parse(l)})}}else this._dispatchConferenceUpdate({action:Et.ModCmdResponse,command:a["conf-command"],response:a.response})}},o=yield this.session.vertoSubscribe(s).catch(r=>{F.error("ConfMod subscription error:",r)});Ni(o,t)&&(this.role=Gn.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 F.error(`Failed to ${t.action} on call ${this.id}`),!1}_onRemoteSdp(t){return G(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=>{F.error("Call setRemoteDescription Error: ",i),this.hangup()})})}_requestAnotherLocalDescription(){sn(this.peer.onSdpReadyTwice)?J(B.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 F.info(`No candidate - retry
|
|
89
|
-
`),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-${
|
|
88
|
+
`)})(t.sdp,r.sdpASBandwidthKbps)),yield this.instance.setLocalDescription(t)})}_sdpReady(){rn(this.onSdpReadyTwice)&&this.onSdpReadyTwice(this.instance.localDescription)}_retrieveLocalStream(){return G(this,void 0,void 0,function*(){if(Li(this.options.localStream))return this.options.localStream;const t=yield(n=this.options,G(void 0,void 0,void 0,function*(){let{audio:i=!0,micId:s}=n;const{micLabel:o=""}=n;s&&(s=yield Vi(s,o,re.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 Vi(r,l,re.Video).catch(c=>null),r&&(typeof a=="boolean"&&(a={}),a.deviceId={exact:r})),{audio:i,video:a}}));var n;return Oi(t)})}_isOffer(){return this.type===Vt.Offer}_isAnswer(){return this.type===Vt.Answer}_config(){const{prefetchIceCandidates:t,forceRelayCandidate:n}=this.options,i={bundlePolicy:"max-compat",iceCandidatePoolSize:t?10:0,iceServers:[_v,xu],iceTransportPolicy:n?"relay":"all"};return F.info("RTC config",i),i}close(){var t;return G(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 Qv=Vr;class Xu{constructor(t,n){this.session=t,this.id="",this.state=X[X.New],this.prevState="",this.channels=[],this.role=Gn.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=b=>{const y=b<0||!this._lastSerno||this._lastSerno&&b===this._lastSerno+1;return y&&b>=0&&(this._lastSerno=b),y},this._doStats=()=>{this.peer&&this.peer.instance&&this._statsBindings.length!==0&&this.peer.instance.getStats().then(b=>{b.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:m,video:g},ringtoneFile:_,ringbackFile:w}=t;this.options=Object.assign({},Tv,{audio:m,video:g,iceServers:i,localElement:c,remoteElement:d,micId:o,micLabel:r,camId:a,camLabel:l,speakerId:s,ringtoneFile:_,ringbackFile:w,debug:u.debug,debugOutput:u.debugOutput},n),this._onMediaError=this._onMediaError.bind(this),this._init(),this.options&&(this._ringtone=$u(this.options.ringtoneFile,"_ringtone"),this._ringback=$u(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=xe.Outbound,this.peer=new Ku(Vt.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=xe.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 Ku(Vt.Answer,this.options,this.session),this._registerPeerEvents()}playRingtone(){Uu(this._ringtone)}stopRingtone(){Gu(this._ringtone)}playRingback(){Uu(this._ringback)}stopRingback(){Gu(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 jv({sessid:this.session.sessionid,dialogParams:this.options,cause:"USER_BUSY",causeCode:17});this._execute(c).catch(d=>{F.error("telnyx_rtc.bye failed!",d),J(B.Error,{error:d,sessionId:this.session.sessionid},this.session.uuid)}).then(l.bind(this))}else l()}hold(){const t=new Nr({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 Nr({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 Nr({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 Wu({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 Wu({sessid:this.session.sessionid,msg:i,dialogParams:this.options});this._execute(s)}muteAudio(){Fu(this.options.localStream)}unmuteAudio(){Bu(this.options.localStream)}toggleAudioMute(){ju(this.options.localStream)}setAudioInDevice(t){return G(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 Dr({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,cn(t,"video",!1)}unmuteVideo(){var t;t=this.options.localStream,cn(t,"video",!0)}toggleVideoMute(){var t;t=this.options.localStream,cn(t,"video",null)}setVideoDevice(t){return G(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 Dr({video:{deviceId:{exact:t}}}),o=s.getVideoTracks()[0];i.replaceTrack(o);const{localElement:r,localStream:a}=this.options;Di(r,s),this.options.camId=t,a.getAudioTracks().forEach(l=>s.addTrack(l)),a.getVideoTracks().forEach(l=>l.stop()),this.options.localStream=s}})}deaf(){Fu(this.options.remoteStream)}undeaf(){Bu(this.options.remoteStream)}toggleDeaf(){ju(this.options.remoteStream)}setBandwidthEncodingsMaxBps(t,n){return G(this,void 0,void 0,function*(){if(!this||!this.peer)return void F.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 F.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"}]),F.info("Parameters: ",r),F.info("Setting max ",n==="audio"?"audio":"video"," bandwidth to: ",t," [bps]"),r.encodings[0].maxBitrate=t,yield o.setParameters(r).then(()=>{F.info(n==="audio"?"New audio":"New video"," bandwidth settings in use: ",o.getParameters())}).catch(a=>console.error(a))}else F.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(),F.info(`Call ${this.id} state change from ${this.prevState} to ${this.state}`),this._dispatchNotification({type:se.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&&Du(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===xe.Inbound?xe.Outbound:xe.Inbound,c={type:se[n],call:this,displayName:o,displayNumber:r,displayDirection:l};J(B.Notification,c,this.id)||J(B.Notification,c,this.session.uuid);break}case nt.Info:case nt.Event:{const o=Object.assign(Object.assign({},i),{type:se.generic,call:this});J(B.Notification,o,this.id)||J(B.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 G(this,void 0,void 0,function*(){if(!this._checkConferenceSerno(t.wireSerno)&&t.name!==n.laName)return F.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:m}=n;this._dispatchConferenceUpdate({action:At.Join,conferenceName:d,participantId:Number(u),role:m}),a&&(yield this._subscribeConferenceChat(a)),l&&(yield this._subscribeConferenceInfo(l)),c&&m===Gn.Moderator&&(yield this._subscribeConferenceModerator(c));const g=[];for(const _ in s)g.push(Object.assign({callId:s[_][0],index:Number(_)},Pi(s[_][1])));this._dispatchConferenceUpdate({action:At.Bootstrap,participants:g});break}case"add":this._dispatchConferenceUpdate(Object.assign({action:At.Add,callId:o,index:r},Pi(s)));break;case"modify":this._dispatchConferenceUpdate(Object.assign({action:At.Modify,callId:o,index:r},Pi(s)));break;case"del":this._dispatchConferenceUpdate(Object.assign({action:At.Delete,callId:o,index:r},Pi(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 G(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=>{F.error("ConfChat subscription error:",s)});Ni(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 G(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,zu(this.session,o)):F.error("Conference-Info unknown contentType",s)}},i=yield this.session.vertoSubscribe(n).catch(s=>{F.error("ConfInfo subscription error:",s)});Ni(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 G(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"&&Cu(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=>{F.error("ConfMod subscription error:",r)});Ni(o,t)&&(this.role=Gn.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 F.error(`Failed to ${t.action} on call ${this.id}`),!1}_onRemoteSdp(t){return G(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=>{F.error("Call setRemoteDescription Error: ",i),this.hangup()})})}_requestAnotherLocalDescription(){rn(this.peer.onSdpReadyTwice)?J(B.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 F.info(`No candidate - retry
|
|
89
|
+
`),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-${Qv}`};switch(o){case Vt.Offer:this.setState(X.Requesting),r=new Nv(a);break;case Vt.Answer:this.setState(X.Answering),r=this.options.attach===!0?new Fv(a):new Bv(a);break;default:return F.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===Vt.Offer?this.setState(X.Trying):this.setState(X.Active)}).catch(l=>{F.error(`${this.id} - Sending ${o} error:`,l),this.hangup()}),console.timeEnd(bu)}_onIce(t){const{instance:n}=this.peer;this._iceTimeout===null&&(this._iceTimeout=setTimeout(()=>this._onIceSdp(n.localDescription),1e3)),t.candidate?F.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&&Di(i,s)})}_onMediaError(t){this._dispatchNotification({type:se.userMediaError,error:t}),this.hangup({},!1)}_dispatchConferenceUpdate(t){this._dispatchNotification(Object.assign({type:se.conferenceUpdate,call:this},t))}_dispatchNotification(t){this.options.screenShare!==!0&&(J(B.Notification,t,this.id,!1)||J(B.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=sn()),this.id=this.options.id,n&&!Cu(n)||(this.options.userVariables=this.session.options.userVariables||{}),i||(this.options.remoteCallerNumber=this.options.destinationNumber),this.session.calls[this.id]=this,an(B.MediaError,this._onMediaError,this.id),rn(s)&&an(B.Notification,s.bind(this),this.id),this.setState(X.New),F.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;zn(t),zn(n),ln(B.MediaError,null,this.id),this.session.calls[this.id]=null,delete this.session.calls[this.id]}_startStats(t){this._statsIntervalId=setInterval(this._doStats,t),F.info("Stats started")}_stopStats(){this._statsIntervalId&&(clearInterval(this._statsIntervalId),this._statsIntervalId=null),F.info("Stats stopped")}}Xu.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 Oe extends Xu{constructor(){super(...arguments),this._statsInterval=null,this.sendConversationMessage=t=>this.session.execute(new Hv(t))}hangup(t={},n=!0){this.screenShare instanceof Oe&&this.screenShare.hangup(t,n),super.hangup(t,n)}startScreenShare(t){return G(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 Oe(this.session,l),this.screenShare.invite(),this.screenShare})}stopScreenShare(){this.screenShare instanceof Oe&&this.screenShare.hangup()}setAudioOutDevice(t){return G(this,void 0,void 0,function*(){this.options.speakerId=t;const{remoteElement:n,speakerId:i}=this.options;return!(!n||!i)&&Du(n,i)})}_finalize(){this._stats(!1),super._finalize()}_stats(t=!0){if(t===!1)return clearInterval(this._statsInterval);F.setLevel(2),this._statsInterval=window.setInterval(()=>G(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+=`
|
|
90
90
|
${r.type}
|
|
91
91
|
`,Object.keys(r).forEach(a=>{o.includes(a)||(i+=` ${a}: ${r[a]}
|
|
92
|
-
`)}))}),F.info(i)}),2e3)}}class Qv extends Lv{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 G(this,void 0,void 0,function*(){t.connect.call(this)})}checkPermissions(t=!0,n=!0){return G(this,void 0,void 0,function*(){try{const i=yield Oi({audio:t,video:n});return Wn(i),!0}catch{return!1}})}logout(){this.disconnect()}disconnect(){const t=Object.create(null,{disconnect:{get:()=>super.disconnect}});return G(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(Iu(B.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 zn().catch(t=>(J(B.MediaError,t,this.uuid),[]))}getVideoDevices(){return zn(re.Video).catch(t=>(J(B.MediaError,t,this.uuid),[]))}getAudioInDevices(){return zn(re.AudioIn).catch(t=>(J(B.MediaError,t,this.uuid),[]))}getAudioOutDevices(){return zn(re.AudioOut).catch(t=>(console.error("getAudioOutDevices",t),J(B.MediaError,t,this.uuid),[]))}validateDeviceId(t,n,i){return Vi(t,n,i)}getDeviceResolutions(t){return G(this,void 0,void 0,function*(){try{return yield(n=>G(void 0,void 0,void 0,function*(){const i=[],s=yield Oi({video:{deviceId:{exact:n}}}),o=s.getVideoTracks()[0];for(let r=0;r<Ou.length;r++){const[a,l]=Ou[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 Wn(s),i}))(t)}catch(n){throw n}})}get mediaConstraints(){return{audio:this._audioConstraints,video:this._videoConstraints}}setAudioSettings(t){return G(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=Er(t,["micId","micLabel"]);return Vu(s),this._audioConstraints=yield Nu(n,i,"audioinput",s),this.micId=n,this.micLabel=i,this._audioConstraints})}disableMicrophone(){this._audioConstraints=!1}enableMicrophone(){this._audioConstraints=!0}setVideoSettings(t){return G(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=Er(t,["camId","camLabel"]);return Vu(s),this._videoConstraints=yield Nu(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||[xu,yv,n]}get iceServers(){return this._iceServers}set speaker(t){this._speaker=t}get speaker(){return this._speaker}set localElement(t){this._localElement=Un(t)}get localElement(){return this._localElement}set remoteElement(t){this._remoteElement=Un(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 $v({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 G(this,void 0,void 0,function*(){if(!(n=n.filter(l=>l&&!this._existsSubscription(this.relayProtocol,l))).length)return{};const s=new Uv({sessid:this.sessionid,eventChannel:n});t&&(s.targetNodeId=t);const o=yield this.execute(s),{unauthorized:r=[],subscribed:a=[]}=Or(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 G(this,void 0,void 0,function*(){if(!(n=n.filter(a=>a&&this._existsSubscription(this.relayProtocol,a))).length)return{};const i=new Gv({sessid:this.sessionid,eventChannel:n});t&&(i.targetNodeId=t);const s=yield this.execute(i),{unsubscribed:o=[],notSubscribed:r=[]}=Or(s);return o.forEach(a=>this._removeSubscription(this.relayProtocol,a)),r.forEach(a=>this._removeSubscription(this.relayProtocol,a)),s})}static telnyxStateCall(t){return Oe.setStateTelnyx(t)}}class Yu{constructor(t,n){this.code=n,this.message=t}}class t_ extends Dt{constructor(){super(),this.method=nt.Ping,this.buildRequest({method:this.method,params:{}})}}class Gt{constructor(t){this.session=t}_ack(t,n){const i=new Vv(t,n);this.nodeId&&(i.targetNodeId=this.nodeId),this.session.execute(i)}reconnectDelay(){return 1e3*Au(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,_,w,b;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:(w=n.options.prefetchIceCandidates)!==null&&w!==void 0&&w,forceRelayCandidate:(b=n.options.forceRelayCandidate)!==null&&b!==void 0&&b};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 Oe(n,y);return S.nodeId=this.nodeId,S},u=new Mu,m=new t_;switch(s){case nt.Ping:this.session.execute(m);break;case nt.Punt:n.disconnect();break;case nt.Invite:{const w=d();w.playRingtone(),w.setState(X.Ringing),w.direction=xe.Inbound,this._ack(i,s);break}case nt.Attach:{const w=d();this.session.autoRecoverCalls?w.answer():w.setState(X.Recovering),w.handleMessage(t);break}case nt.Event:case"webrtc.event":if(!a)return void F.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(B.Notification,o,n.uuid);break;case nt.Info:o.type=se.generic,J(B.Notification,o,n.uuid);break;case nt.ClientReady:this.session.execute(u);break;default:{const w=Ir(t);if(w){switch(w){case Rt.REGISTER:case Rt.REGED:n.connection.previousGatewayState!==Rt.REGED&&n.connection.previousGatewayState!==Rt.REGISTER&&(Gt.retriedRegister=0,o.type=se.vertoClientReady,J(B.Ready,o,n.uuid));break;case Rt.UNREGED:case Rt.NOREG:if(Gt.retriedRegister+=1,Gt.retriedRegister===5){Gt.retriedRegister=0,J(B.Error,{error:new Yu("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()){Gt.retriedConnect=0,J(B.Error,{error:new Yu("Fail to connect the server, the server tried 5 times","FAILED|FAIL_WAIT"),sessionId:n.sessionid},n.uuid);break}if(Gt.retriedConnect+=1,Gt.retriedConnect===5){Gt.retriedConnect=0,J(B.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:F.warn("GatewayState message unknown method:",t)}break}F.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 G(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:m}=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:b})=>{const y=m||this._retrieveCallId(b,o);if(y&&n.calls.hasOwnProperty(y)){const S=n.calls[y];S._addChannel(o),S.extension=r,S.handleConferenceUpdate(b,t).then(C=>{C==="INVALID_PACKET"&&g()})}}},w=yield n.vertoSubscribe(_).catch(b=>{F.error("liveArray subscription error:",b)});Ni(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:se.conferenceUpdate,action:Et.Leave,conferenceName:r,participantId:Number(d),role:u};J(B.Notification,b,w,!1)||J(B.Notification,b,n.uuid),g===null&&an(B.Notification,null,w)}}const _=[o,a,l,c];n.vertoUnsubscribe({nodeId:this.nodeId,channels:_}).then(({unsubscribedChannels:w=[]})=>{g&&(g.channels=g.channels.filter(b=>!w.includes(b)))}).catch(w=>{F.error("liveArray unsubscribe error:",w)});break}}})}_handleSessionEvent(t){switch(t.contentType){case"layout-info":case"layer-info":zu(this.session,t);break;case"logo-info":{const n={type:se.conferenceUpdate,action:Et.LogoInfo,logo:t.logoURL};J(B.Notification,n,this.session.uuid);break}}}}Gt.retriedConnect=0,Gt.retriedRegister=0;class e_ extends Dt{constructor(t,n,i,s={},o){super(),this.method="anonymous_login";const r={target_type:t,target_id:n,userVariables:s,reconnection:o,"User-Agent":{sdkVersion:Vr,data:navigator.userAgent}};i&&(r.sessid=i),this.buildRequest({method:this.method,params:r})}}class n_ extends Qv{constructor(t){super(t),this.relayProtocol="verto-protocol",this.timeoutErrorCode=-329990,this.handleLoginOnSocketOpen=()=>G(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 Ov(n,i||s,o,this.sessionid,r,!!Lr()),c=yield this.execute(l).catch(this._handleLoginError);c&&(this._autoReconnect=a,this.sessionid=c.sessid)}),this.handleAnonymousLoginOnSocketOpen=()=>G(this,void 0,void 0,function*(){this._idle=!1;const{anonymous_login:n}=this.options,{target_type:i,target_id:s}=n,o=new e_(i,s,this.sessionid,this.options.userVariables,!!Lr()),r=yield this.execute(o).catch(this._handleLoginError);r&&(this.sessionid=r.sessid)}),window.addEventListener("beforeunload",n=>{this.calls&&Object.keys(this.calls).forEach(i=>{this.calls[i]&&this.calls[i].hangup({},!0)})})}validateOptions(){return Rr(this.options)||Pi(this.options)}newCall(t){if(!this.validateCallOptions(t))throw new Error("Verto.newCall() error: destinationNumber is required.");console.time(bu);const n=new Oe(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!!Pi(this.options)||!!t.destinationNumber}_onSocketOpen(){return G(this,void 0,void 0,function*(){return Rr(this.options)?this.handleLoginOnSocketOpen():Pi(this.options)?this.handleAnonymousLoginOnSocketOpen():void 0})}_onSocketMessage(t){new Gt(this).handleMessage(t)}}class i_ extends n_{constructor(t){super(t),console.log(`SDK version: ${Hu}`)}newCall(t){return super.newCall(t)}static webRTCInfo(){return Dv()}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 s_(e){if(!e||typeof e!="object")return!1;const t=e;return t.method==="ai_conversation"&&typeof t.params=="object"}function r_(e){if(!e||typeof e!="object")return!1;const t=e;return t.params.type!=="response.text.delta"?!1:!!t.params.delta}function o_(e){if(!e||typeof e!="object")return!1;const t=e;return t.params.type!=="conversation.item.created"?!1:!!t.params.item.content}function a_(e){return r_(e)?{id:e.params.item_id,role:"assistant",content:e.params.delta,timestamp:new Date}:null}function l_(e){return!o_(e)||e.params.item.role!=="user"||e.params.item.status!=="completed"?null:{id:e.params.item.id,role:e.params.item.role,content:e.params.item.content.map(t=>t.transcript).join(" "),timestamp:new Date}}function c_(e){const[t,n]=ge([]);return zt(()=>{if(!e)return;const i=s=>{if(s_(s))switch(s.params.type){case"response.text.delta":{n(o=>{const r=a_(s);return r?[...o,r]:o});return}case"conversation.item.created":{const o=l_(s);o&&n(r=>[...r,o]);return}}};return e.on(B.SocketMessage,i),()=>{e.off(B.SocketMessage,i)}},[e]),t}const u_=({call:e,client:t})=>{const[n,i]=ge("collapsed"),s=()=>i("expanded"),o=()=>i("collapsed"),r=c_(t);switch(n){case"collapsed":return M(vu,{onExpand:s,call:e,client:t});case"expanded":return M(mv,{transcript:r,onCollapse:o,call:e});default:return M(vu,{onExpand:s,call:e,client:t})}},Br=()=>M(On.div,{layoutId:Ci,className:"bg-black gap-3 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:M("div",{className:"animate-spin rounded-full",children:M(Fg,{})})}),d_=({call:e,client:t})=>{switch(e==null?void 0:e.state){case"new":case"trying":case"requesting":return M(Br,{});case"done":case"purged":case"destroy":return null;case"active":return M(u_,{client:t,call:e});default:return M(Br,{})}},h_=(e,t)=>{const[n,i]=ge(null);return zt(()=>{if(!e)return;const s=new i_({env:t||"production",anonymous_login:{target_id:e,target_type:"ai_assistant"}});i(s)},[e,t]),n},f_=(e,{onReady:t,onNotification:n,onError:i})=>(zt(()=>{if(e)return e.connect().then().catch(console.error),e.on(B.Ready,t),e.on(B.Notification,n),e.on(B.Error,i),()=>{e.off(B.Ready,t),e.off(B.Notification,n),e.off(B.Error,i),e.disconnect()}},[e]),null),p_=({className:e})=>M("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:[M("g",{clipPath:"url(#:R5lfm:)",children:[M("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"}),M("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"}),M("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"}),M("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"}),M("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"})]}),M("defs",{children:M("clipPath",{id:":R5lfm:",children:M("rect",{width:"236",height:"211",fill:"currentColor"})})})]}),m_=({client:e})=>{const t=()=>{var s;if(!e){console.error("Client is not initialized.");return}const n=(s=RTCRtpReceiver.getCapabilities("audio"))==null?void 0:s.codecs,i=n==null?void 0:n.find(o=>o.mimeType.toLowerCase().includes("opus"));e.newCall({destinationNumber:"xxx",preferred_codecs:[i]})};return M(On.button,{layoutId:Ci,onClick:t,className:"bg-black cursor-pointer text-white px-4 py-2 rounded-full flex items-center text-xl font-medium shadow-lg",children:[M(p_,{className:"w-8 h-8 mr-2"}),"Let's Talk"]})},g_='@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-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-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}.static{position:static}.inset-0{inset:calc(var(--spacing)*0)}.top-0{top:calc(var(--spacing)*0)}.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-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-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-8{height:calc(var(--spacing)*8)}.h-\\[72px\\]{height:72px}.h-\\[144px\\]{height:144px}.h-\\[300px\\]{height:300px}.min-h-\\[180px\\]{min-height:180px}.w-4{width:calc(var(--spacing)*4)}.w-5{width:calc(var(--spacing)*5)}.w-8{width:calc(var(--spacing)*8)}.w-\\[200px\\]{width:200px}.w-\\[240px\\]{width:240px}.w-\\[250px\\]{width:250px}.w-\\[344px\\]{width:344px}.w-full{width:100%}.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}.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-md{border-radius:var(--radius-md)}.rounded-t-3xl{border-top-left-radius:var(--radius-3xl);border-top-right-radius:var(--radius-3xl)}.border-solid{--tw-border-style:solid;border-style:solid}.bg-\\[\\#3C3C3C\\]{background-color:#3c3c3c}.bg-\\[\\#38383C96\\]{background-color:#38383c96}.bg-\\[\\#38383C\\]{background-color:#38383c}.bg-\\[\\#222227\\]{background-color:#222227}.bg-\\[\\#750000\\]{background-color:#750000}.bg-black{background-color:var(--color-black)}.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-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 (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)}}}::-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)}}',v_=({children:e})=>M("main",{className:"fixed inset-0 z-[9999] pointer-events-none",children:M("div",{className:"absolute bottom-0 right-0 md:bottom-10 md:right-10 pointer-events-auto",children:e})}),__={duration:.1,ease:"circOut"},y_=({children:e,position:t="fixed"})=>M(Of,{transition:__,children:[M("style",{children:g_}),t==="fixed"?M(v_,{children:e}):e]}),b_=e=>M(On.div,{layoutId:Ci,className:"bg-black rounded-2xl p-4 flex flex-col items-center justify-center text-white w-[344px] max-w-full",children:[M(Bg,{className:"w-8 h-8 text-red-400"}),M("h1",{className:"text-2xl font-medium mt-2 mb-4",children:"An error occurred"}),M("ul",{className:"list-disc ml-4 text-sm gap-4",children:[M("li",{children:"Failed to initialize the Telnyx AI Agent client. Please check your agent ID and ensure that you are connected to the internet."}),M("li",{children:["Make sure that the"," ",M("a",{href:`https://portal.telnyx.com/#/ai/assistants/edit/${e.agentId}?tab=telephony`,className:"font-medium text-green-400 underline inline-flex items-center gap-1",target:"_blank",rel:"noopener noreferrer",children:["Support Unauthenticated Web Calls"," ",M(Hg,{className:"w-4 h-4"})]})," ","option is enabled in your Telnyx agent settings."]})]})]});function w_({"agent-id":e,environment:t,position:n="fixed"}){const i=h_(e,t),[s,o]=ge(null),[r,a]=ge(!0),[l,c]=ge(!1);return f_(i,{onReady:()=>a(!1),onNotification:_=>{var w;if(((w=_.call)==null?void 0:w.state)==="destroy")return o(null);o(_)},onError:()=>{a(!1),c(!0)}}),M(y_,{position:n,children:e?l?M(b_,{agentId:e}):r?M(Br,{}):s!=null&&s.call?M(d_,{call:s.call,client:i}):M(m_,{client:i}):M("div",{children:"Please provide an assistant ID."})})}fd(w_,"telnyx-ai-agent",Mg,{shadow:!0})})();
|
|
92
|
+
`)}))}),F.info(i)}),2e3)}}class t_ extends Mv{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 G(this,void 0,void 0,function*(){t.connect.call(this)})}checkPermissions(t=!0,n=!0){return G(this,void 0,void 0,function*(){try{const i=yield Oi({audio:t,video:n});return zn(i),!0}catch{return!1}})}logout(){this.disconnect()}disconnect(){const t=Object.create(null,{disconnect:{get:()=>super.disconnect}});return G(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(Iu(B.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 qn().catch(t=>(J(B.MediaError,t,this.uuid),[]))}getVideoDevices(){return qn(re.Video).catch(t=>(J(B.MediaError,t,this.uuid),[]))}getAudioInDevices(){return qn(re.AudioIn).catch(t=>(J(B.MediaError,t,this.uuid),[]))}getAudioOutDevices(){return qn(re.AudioOut).catch(t=>(console.error("getAudioOutDevices",t),J(B.MediaError,t,this.uuid),[]))}validateDeviceId(t,n,i){return Vi(t,n,i)}getDeviceResolutions(t){return G(this,void 0,void 0,function*(){try{return yield(n=>G(void 0,void 0,void 0,function*(){const i=[],s=yield Oi({video:{deviceId:{exact:n}}}),o=s.getVideoTracks()[0];for(let r=0;r<Ou.length;r++){const[a,l]=Ou[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 zn(s),i}))(t)}catch(n){throw n}})}get mediaConstraints(){return{audio:this._audioConstraints,video:this._videoConstraints}}setAudioSettings(t){return G(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=Ar(t,["micId","micLabel"]);return Vu(s),this._audioConstraints=yield Nu(n,i,"audioinput",s),this.micId=n,this.micLabel=i,this._audioConstraints})}disableMicrophone(){this._audioConstraints=!1}enableMicrophone(){this._audioConstraints=!0}setVideoSettings(t){return G(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=Ar(t,["camId","camLabel"]);return Vu(s),this._videoConstraints=yield Nu(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||[xu,yv,n]}get iceServers(){return this._iceServers}set speaker(t){this._speaker=t}get speaker(){return this._speaker}set localElement(t){this._localElement=Un(t)}get localElement(){return this._localElement}set remoteElement(t){this._remoteElement=Un(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 $v({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 G(this,void 0,void 0,function*(){if(!(n=n.filter(l=>l&&!this._existsSubscription(this.relayProtocol,l))).length)return{};const s=new Uv({sessid:this.sessionid,eventChannel:n});t&&(s.targetNodeId=t);const o=yield this.execute(s),{unauthorized:r=[],subscribed:a=[]}=Or(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 G(this,void 0,void 0,function*(){if(!(n=n.filter(a=>a&&this._existsSubscription(this.relayProtocol,a))).length)return{};const i=new Gv({sessid:this.sessionid,eventChannel:n});t&&(i.targetNodeId=t);const s=yield this.execute(i),{unsubscribed:o=[],notSubscribed:r=[]}=Or(s);return o.forEach(a=>this._removeSubscription(this.relayProtocol,a)),r.forEach(a=>this._removeSubscription(this.relayProtocol,a)),s})}static telnyxStateCall(t){return Oe.setStateTelnyx(t)}}class Yu{constructor(t,n){this.code=n,this.message=t}}class e_ extends Dt{constructor(){super(),this.method=nt.Ping,this.buildRequest({method:this.method,params:{}})}}class Ht{constructor(t){this.session=t}_ack(t,n){const i=new Vv(t,n);this.nodeId&&(i.targetNodeId=this.nodeId),this.session.execute(i)}reconnectDelay(){return 1e3*Eu(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,_,w,b;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:(w=n.options.prefetchIceCandidates)!==null&&w!==void 0&&w,forceRelayCandidate:(b=n.options.forceRelayCandidate)!==null&&b!==void 0&&b};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 Oe(n,y);return S.nodeId=this.nodeId,S},u=new Lu,m=new e_;switch(s){case nt.Ping:this.session.execute(m);break;case nt.Punt:n.disconnect();break;case nt.Invite:{const w=d();w.playRingtone(),w.setState(X.Ringing),w.direction=xe.Inbound,this._ack(i,s);break}case nt.Attach:{const w=d();this.session.autoRecoverCalls?w.answer():w.setState(X.Recovering),w.handleMessage(t);break}case nt.Event:case"webrtc.event":if(!a)return void F.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(B.Notification,o,n.uuid);break;case nt.Info:o.type=se.generic,J(B.Notification,o,n.uuid);break;case nt.ClientReady:this.session.execute(u);break;default:{const w=Ir(t);if(w){switch(w){case Rt.REGISTER:case Rt.REGED:n.connection.previousGatewayState!==Rt.REGED&&n.connection.previousGatewayState!==Rt.REGISTER&&(Ht.retriedRegister=0,o.type=se.vertoClientReady,J(B.Ready,o,n.uuid));break;case Rt.UNREGED:case Rt.NOREG:if(Ht.retriedRegister+=1,Ht.retriedRegister===5){Ht.retriedRegister=0,J(B.Error,{error:new Yu("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()){Ht.retriedConnect=0,J(B.Error,{error:new Yu("Fail to connect the server, the server tried 5 times","FAILED|FAIL_WAIT"),sessionId:n.sessionid},n.uuid);break}if(Ht.retriedConnect+=1,Ht.retriedConnect===5){Ht.retriedConnect=0,J(B.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:F.warn("GatewayState message unknown method:",t)}break}F.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 G(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:m}=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:b})=>{const y=m||this._retrieveCallId(b,o);if(y&&n.calls.hasOwnProperty(y)){const S=n.calls[y];S._addChannel(o),S.extension=r,S.handleConferenceUpdate(b,t).then(C=>{C==="INVALID_PACKET"&&g()})}}},w=yield n.vertoSubscribe(_).catch(b=>{F.error("liveArray subscription error:",b)});Ni(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:se.conferenceUpdate,action:At.Leave,conferenceName:r,participantId:Number(d),role:u};J(B.Notification,b,w,!1)||J(B.Notification,b,n.uuid),g===null&&ln(B.Notification,null,w)}}const _=[o,a,l,c];n.vertoUnsubscribe({nodeId:this.nodeId,channels:_}).then(({unsubscribedChannels:w=[]})=>{g&&(g.channels=g.channels.filter(b=>!w.includes(b)))}).catch(w=>{F.error("liveArray unsubscribe error:",w)});break}}})}_handleSessionEvent(t){switch(t.contentType){case"layout-info":case"layer-info":zu(this.session,t);break;case"logo-info":{const n={type:se.conferenceUpdate,action:At.LogoInfo,logo:t.logoURL};J(B.Notification,n,this.session.uuid);break}}}}Ht.retriedConnect=0,Ht.retriedRegister=0;class n_ extends Dt{constructor(t,n,i,s={},o){super(),this.method="anonymous_login";const r={target_type:t,target_id:n,userVariables:s,reconnection:o,"User-Agent":{sdkVersion:Vr,data:navigator.userAgent}};i&&(r.sessid=i),this.buildRequest({method:this.method,params:r})}}class i_ extends t_{constructor(t){super(t),this.relayProtocol="verto-protocol",this.timeoutErrorCode=-329990,this.handleLoginOnSocketOpen=()=>G(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 Ov(n,i||s,o,this.sessionid,r,!!Mr()),c=yield this.execute(l).catch(this._handleLoginError);c&&(this._autoReconnect=a,this.sessionid=c.sessid)}),this.handleAnonymousLoginOnSocketOpen=()=>G(this,void 0,void 0,function*(){this._idle=!1;const{anonymous_login:n}=this.options,{target_type:i,target_id:s}=n,o=new n_(i,s,this.sessionid,this.options.userVariables,!!Mr()),r=yield this.execute(o).catch(this._handleLoginError);r&&(this.sessionid=r.sessid)}),window.addEventListener("beforeunload",n=>{this.calls&&Object.keys(this.calls).forEach(i=>{this.calls[i]&&this.calls[i].hangup({},!0)})})}validateOptions(){return Rr(this.options)||Mi(this.options)}newCall(t){if(!this.validateCallOptions(t))throw new Error("Verto.newCall() error: destinationNumber is required.");console.time(bu);const n=new Oe(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!!Mi(this.options)||!!t.destinationNumber}_onSocketOpen(){return G(this,void 0,void 0,function*(){return Rr(this.options)?this.handleLoginOnSocketOpen():Mi(this.options)?this.handleAnonymousLoginOnSocketOpen():void 0})}_onSocketMessage(t){new Ht(this).handleMessage(t)}}class s_ extends i_{constructor(t){super(t),console.log(`SDK version: ${Hu}`)}newCall(t){return super.newCall(t)}static webRTCInfo(){return Dv()}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 r_(e){if(!e||typeof e!="object")return!1;const t=e;return t.method==="ai_conversation"&&typeof t.params=="object"}function o_(e){if(!e||typeof e!="object")return!1;const t=e;return t.params.type!=="response.text.delta"?!1:!!t.params.delta}function a_(e){if(!e||typeof e!="object")return!1;const t=e;return t.params.type!=="conversation.item.created"?!1:!!t.params.item.content}function l_(e){return o_(e)?{id:e.params.item_id,role:"assistant",content:e.params.delta,timestamp:new Date}:null}function c_(e){return!a_(e)||e.params.item.role!=="user"||e.params.item.status!=="completed"?null:{id:e.params.item.id,role:e.params.item.role,content:e.params.item.content.map(t=>t.transcript).join(" "),timestamp:new Date}}function u_(e){const[t,n]=ge([]);return qt(()=>{if(!e)return;const i=s=>{if(r_(s))switch(s.params.type){case"response.text.delta":{n(o=>{const r=l_(s);return r?[...o,r]:o});return}case"conversation.item.created":{const o=c_(s);o&&n(r=>[...r,o]);return}}};return e.on(B.SocketMessage,i),()=>{e.off(B.SocketMessage,i)}},[e]),t}const d_=({call:e,client:t})=>{const[n,i]=ge("collapsed"),s=()=>i("expanded"),o=()=>i("collapsed"),r=u_(t);switch(n){case"collapsed":return L(vu,{onExpand:s,call:e,client:t});case"expanded":return L(mv,{transcript:r,onCollapse:o,call:e});default:return L(vu,{onExpand:s,call:e,client:t})}},Br=()=>L(Vn.div,{layoutId:Ti,className:"bg-black gap-3 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:L("div",{className:"animate-spin rounded-full",children:L(Fg,{})})}),h_=({call:e,client:t})=>{switch(e==null?void 0:e.state){case"new":case"trying":case"requesting":return L(Br,{});case"done":case"purged":case"destroy":return null;case"active":return L(d_,{client:t,call:e});default:return L(Br,{})}},f_=(e,t)=>{const[n,i]=ge(null);return qt(()=>{if(!e)return;const s=new s_({env:t||"production",anonymous_login:{target_id:e,target_type:"ai_assistant"}});i(s)},[e,t]),n},p_=(e,{onReady:t,onNotification:n,onError:i})=>(qt(()=>{if(e)return e.connect().then().catch(console.error),e.on(B.Ready,t),e.on(B.Notification,n),e.on(B.Error,i),()=>{e.off(B.Ready,t),e.off(B.Notification,n),e.off(B.Error,i),e.disconnect()}},[e]),null),m_=({className:e})=>L("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:[L("g",{clipPath:"url(#:R5lfm:)",children:[L("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"}),L("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"}),L("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"}),L("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"}),L("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"})]}),L("defs",{children:L("clipPath",{id:":R5lfm:",children:L("rect",{width:"236",height:"211",fill:"currentColor"})})})]}),g_=({client:e})=>{const t=()=>{var s;if(!e){console.error("Client is not initialized.");return}const n=(s=RTCRtpReceiver.getCapabilities("audio"))==null?void 0:s.codecs,i=n==null?void 0:n.find(o=>o.mimeType.toLowerCase().includes("opus"));e.newCall({destinationNumber:"xxx",preferred_codecs:[i]})};return L(Vn.button,{layoutId:Ti,onClick:t,className:"bg-black cursor-pointer text-white px-4 py-2 rounded-full flex items-center text-xl font-medium shadow-lg",children:[L(m_,{className:"w-8 h-8 mr-2"}),"Let's Talk"]})},v_='@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-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-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}.static{position:static}.inset-0{inset:calc(var(--spacing)*0)}.top-0{top:calc(var(--spacing)*0)}.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-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-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-8{height:calc(var(--spacing)*8)}.h-\\[72px\\]{height:72px}.h-\\[144px\\]{height:144px}.h-\\[300px\\]{height:300px}.min-h-\\[180px\\]{min-height:180px}.w-4{width:calc(var(--spacing)*4)}.w-5{width:calc(var(--spacing)*5)}.w-8{width:calc(var(--spacing)*8)}.w-\\[200px\\]{width:200px}.w-\\[240px\\]{width:240px}.w-\\[250px\\]{width:250px}.w-\\[344px\\]{width:344px}.w-full{width:100%}.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}.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-md{border-radius:var(--radius-md)}.rounded-t-3xl{border-top-left-radius:var(--radius-3xl);border-top-right-radius:var(--radius-3xl)}.border-solid{--tw-border-style:solid;border-style:solid}.bg-\\[\\#3C3C3C\\]{background-color:#3c3c3c}.bg-\\[\\#38383C96\\]{background-color:#38383c96}.bg-\\[\\#38383C\\]{background-color:#38383c}.bg-\\[\\#222227\\]{background-color:#222227}.bg-\\[\\#750000\\]{background-color:#750000}.bg-black{background-color:var(--color-black)}.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-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 (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)}}}::-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)}}',__=({children:e})=>L("main",{className:"fixed inset-0 z-[9999] pointer-events-none",children:L("div",{className:"absolute bottom-0 right-0 md:bottom-10 md:right-10 pointer-events-auto",children:e})}),y_={duration:.1,ease:"circOut"},b_=({children:e,position:t="fixed"})=>L(Of,{transition:y_,children:[L("style",{children:v_}),t==="fixed"?L(__,{children:e}):e]}),w_=e=>L(Vn.div,{layoutId:Ti,className:"bg-black rounded-2xl p-4 flex flex-col items-center justify-center text-white w-[344px] max-w-full",children:[L(Bg,{className:"w-8 h-8 text-red-400"}),L("h1",{className:"text-2xl font-medium mt-2 mb-4",children:"An error occurred"}),L("ul",{className:"list-disc ml-4 text-sm gap-4",children:[L("li",{children:"Failed to initialize the Telnyx AI Agent client. Please check your agent ID and ensure that you are connected to the internet."}),L("li",{children:["Make sure that the"," ",L("a",{href:`https://portal.telnyx.com/#/ai/assistants/edit/${e.agentId}?tab=telephony`,className:"font-medium text-green-400 underline inline-flex items-center gap-1",target:"_blank",rel:"noopener noreferrer",children:["Support Unauthenticated Web Calls"," ",L(Hg,{className:"w-4 h-4"})]})," ","option is enabled in your Telnyx agent settings."]})]})]});function x_({"agent-id":e,environment:t,position:n="fixed"}){const i=f_(e,t),[s,o]=ge(null),[r,a]=ge(!0),[l,c]=ge(!1);return p_(i,{onReady:()=>a(!1),onNotification:_=>{var w;if(((w=_.call)==null?void 0:w.state)==="destroy")return o(null);o(_)},onError:()=>{a(!1),c(!0)}}),L(b_,{position:n,children:e?l?L(w_,{agentId:e}):r?L(Br,{}):s!=null&&s.call?L(h_,{call:s.call,client:i}):L(g_,{client:i}):L("div",{children:"Please provide an assistant ID."})})}fd(x_,"telnyx-ai-agent",Lg,{shadow:!0})})();
|